Skip to content

Commit

Permalink
Rename search/material fbi scopes to local/global
Browse files Browse the repository at this point in the history
In order to have a better understanding of where the material is coming
from.
  • Loading branch information
spaceo committed Mar 22, 2024
1 parent cee3179 commit 3fb3cfe
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 46 deletions.
36 changes: 17 additions & 19 deletions src/core/dbc-gateway/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ if (import.meta.vitest) {
vi.mock("../utils/reduxMiddleware/extractServiceBaseUrls", async () => {
const urls = {
fbiBaseUrl: "i-am-fbi-url",
fbiSearchBaseUrl: "i-am-fbi-search-url",
fbiMaterialBaseUrl: "i-am-fbi-material-url"
fbiLocalBaseUrl: "i-am-fbi-local-url",
fbiGlobalBaseUrl: "i-am-fbi-global-url"
} as const;

const actual = await vi.importActual(
Expand All @@ -58,40 +58,38 @@ if (import.meta.vitest) {

it("should resolve baseurl based on query name", () => {
expect(resolveBaseUrl("complexSearchWithPagination")).toEqual(
"i-am-fbi-search-url"
"i-am-fbi-local-url"
);
expect(resolveBaseUrl("complexSearchWithPaginationWorkAccess")).toEqual(
"i-am-fbi-search-url"
);
expect(resolveBaseUrl("intelligentFacets")).toEqual(
"i-am-fbi-search-url"
"i-am-fbi-local-url"
);
expect(resolveBaseUrl("intelligentFacets")).toEqual("i-am-fbi-local-url");
expect(resolveBaseUrl("recommendFromFaust")).toEqual(
"i-am-fbi-search-url"
"i-am-fbi-local-url"
);
expect(resolveBaseUrl("searchFacet")).toEqual("i-am-fbi-search-url");
expect(resolveBaseUrl("searchFacet")).toEqual("i-am-fbi-local-url");
expect(resolveBaseUrl("searchWithPagination")).toEqual(
"i-am-fbi-search-url"
"i-am-fbi-local-url"
);
expect(resolveBaseUrl("suggestionsFromQueryString")).toEqual(
"i-am-fbi-search-url"
"i-am-fbi-local-url"
);
expect(resolveBaseUrl("getInfomedia")).toEqual("i-am-fbi-material-url");
expect(resolveBaseUrl("getInfomedia")).toEqual("i-am-fbi-global-url");
expect(
resolveBaseUrl("getManifestationViaBestRepresentationByFaust")
).toEqual("i-am-fbi-material-url");
).toEqual("i-am-fbi-global-url");
expect(resolveBaseUrl("getManifestationViaMaterialByFaust")).toEqual(
"i-am-fbi-material-url"
"i-am-fbi-global-url"
);
expect(resolveBaseUrl("getMaterial")).toEqual("i-am-fbi-search-url");
expect(resolveBaseUrl("getMaterial")).toEqual("i-am-fbi-local-url");
expect(resolveBaseUrl("getMaterialGlobally")).toEqual(
"i-am-fbi-material-url"
"i-am-fbi-global-url"
);
expect(resolveBaseUrl("getReviewManifestations")).toEqual(
"i-am-fbi-material-url"
"i-am-fbi-global-url"
);
expect(resolveBaseUrl("getSmallWork")).toEqual("i-am-fbi-material-url");
expect(resolveBaseUrl("openOrder")).toEqual("i-am-fbi-material-url");
expect(resolveBaseUrl("getSmallWork")).toEqual("i-am-fbi-global-url");
expect(resolveBaseUrl("openOrder")).toEqual("i-am-fbi-global-url");
});

it("should resolve default to the fbi base url if the query is unknown", () => {
Expand Down
34 changes: 17 additions & 17 deletions src/core/dbc-gateway/queryMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import { serviceUrlKeys } from "../utils/reduxMiddleware/extractServiceBaseUrls"

// This map is for mapping query names to FBI service base urls.
export default {
// Search requests.
complexSearchWithPagination: serviceUrlKeys.fbiSearch,
complexSearchWithPaginationWorkAccess: serviceUrlKeys.fbiSearch,
getMaterial: serviceUrlKeys.fbiSearch,
intelligentFacets: serviceUrlKeys.fbiSearch,
recommendFromFaust: serviceUrlKeys.fbiSearch,
searchFacet: serviceUrlKeys.fbiSearch,
searchWithPagination: serviceUrlKeys.fbiSearch,
suggestionsFromQueryString: serviceUrlKeys.fbiSearch,
// Material requests.
getInfomedia: serviceUrlKeys.fbiMaterial,
getManifestationViaBestRepresentationByFaust: serviceUrlKeys.fbiMaterial,
getManifestationViaMaterialByFaust: serviceUrlKeys.fbiMaterial,
getMaterialGlobally: serviceUrlKeys.fbiMaterial,
getReviewManifestations: serviceUrlKeys.fbiMaterial,
getSmallWork: serviceUrlKeys.fbiMaterial,
openOrder: serviceUrlKeys.fbiMaterial,
// Local requests.
complexSearchWithPagination: serviceUrlKeys.fbiLocal,
complexSearchWithPaginationWorkAccess: serviceUrlKeys.fbiLocal,
getMaterial: serviceUrlKeys.fbiLocal,
intelligentFacets: serviceUrlKeys.fbiLocal,
recommendFromFaust: serviceUrlKeys.fbiLocal,
searchFacet: serviceUrlKeys.fbiLocal,
searchWithPagination: serviceUrlKeys.fbiLocal,
suggestionsFromQueryString: serviceUrlKeys.fbiLocal,
// Global requests.
getInfomedia: serviceUrlKeys.fbiGlobal,
getManifestationViaBestRepresentationByFaust: serviceUrlKeys.fbiGlobal,
getManifestationViaMaterialByFaust: serviceUrlKeys.fbiGlobal,
getMaterialGlobally: serviceUrlKeys.fbiGlobal,
getReviewManifestations: serviceUrlKeys.fbiGlobal,
getSmallWork: serviceUrlKeys.fbiGlobal,
openOrder: serviceUrlKeys.fbiGlobal,
// All other requests.
default: serviceUrlKeys.fbi
} as const;
8 changes: 4 additions & 4 deletions src/core/storybook/serviceUrlArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ export default {
defaultValue: "https://fbi-api.dbc.dk/next-present/graphql",
control: { type: "text" }
},
[serviceUrlKeys.fbiSearch]: {
name: "Base url for the FBI API (search)",
[serviceUrlKeys.fbiLocal]: {
name: "Base url for the FBI API (local inventory)",
defaultValue: "https://fbi-api.dbc.dk/next/graphql",
control: { type: "text" }
},
[serviceUrlKeys.fbiMaterial]: {
name: "Base url for the FBI API (material)",
[serviceUrlKeys.fbiGlobal]: {
name: "Base url for the FBI API (global inventory)",
defaultValue: "https://fbi-api.dbc.dk/next-present/graphql",
control: { type: "text" }
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/utils/reduxMiddleware/extractServiceBaseUrls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ type Api =
| "cover"
| "materialList"
| "fbi"
| "fbiSearch"
| "fbiMaterial";
| "fbiLocal"
| "fbiGlobal";

export type ApiBaseUrlKey = `${Api}BaseUrl`;

Expand All @@ -26,8 +26,8 @@ export const serviceUrlKeys = {
cover: "coverBaseUrl",
materialList: "materialListBaseUrl",
fbi: "fbiBaseUrl",
fbiSearch: "fbiSearchBaseUrl",
fbiMaterial: "fbiMaterialBaseUrl"
fbiLocal: "fbiLocalBaseUrl",
fbiGlobal: "fbiGlobalBaseUrl"
} as const;

// ServiceBaseUrls "store". We use this to store the base urls for the different services.
Expand Down
4 changes: 2 additions & 2 deletions src/core/utils/types/global-url-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ interface GlobalUrlEntryPropsInterface {
coverBaseUrl: string;
materialBaseUrl: string;
fbiBaseUrl: string;
fbiSearchBaseUrl: string;
fbiMaterialBaseUrl: string;
fbiLocalBaseUrl: string;
fbiGlobalBaseUrl: string;
authUrl: string;
ereolenHomepageUrl: string;
}
Expand Down

0 comments on commit 3fb3cfe

Please sign in to comment.