@webiny/app 6.6.0-alpha.1 → 6.6.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/App.js +6 -1
  2. package/App.js.map +1 -1
  3. package/components/Image.d.ts +1 -1
  4. package/errors/GraphQLOperationError.d.ts +10 -0
  5. package/errors/GraphQLOperationError.js +11 -0
  6. package/errors/GraphQLOperationError.js.map +1 -0
  7. package/errors/__tests__/GraphQLOperationError.test.d.ts +1 -0
  8. package/errors/__tests__/GraphQLOperationError.test.js +97 -0
  9. package/errors/__tests__/GraphQLOperationError.test.js.map +1 -0
  10. package/errors/index.d.ts +2 -0
  11. package/errors/index.js +1 -0
  12. package/exports/admin.d.ts +2 -0
  13. package/exports/admin.js +2 -0
  14. package/features/apiRequestHeaders/ApiRequestHeadersResolver.d.ts +13 -0
  15. package/features/apiRequestHeaders/ApiRequestHeadersResolver.js +15 -0
  16. package/features/apiRequestHeaders/ApiRequestHeadersResolver.js.map +1 -0
  17. package/features/apiRequestHeaders/ApiStreamClientDecorator.d.ts +12 -0
  18. package/features/apiRequestHeaders/ApiStreamClientDecorator.js +25 -0
  19. package/features/apiRequestHeaders/ApiStreamClientDecorator.js.map +1 -0
  20. package/features/apiRequestHeaders/GraphQLClientDecorator.d.ts +12 -0
  21. package/features/apiRequestHeaders/GraphQLClientDecorator.js +25 -0
  22. package/features/apiRequestHeaders/GraphQLClientDecorator.js.map +1 -0
  23. package/features/apiRequestHeaders/__tests__/ApiRequestHeaders.test.d.ts +1 -0
  24. package/features/apiRequestHeaders/__tests__/ApiRequestHeaders.test.js +199 -0
  25. package/features/apiRequestHeaders/__tests__/ApiRequestHeaders.test.js.map +1 -0
  26. package/features/apiRequestHeaders/abstractions.d.ts +26 -0
  27. package/features/apiRequestHeaders/abstractions.js +6 -0
  28. package/features/apiRequestHeaders/abstractions.js.map +1 -0
  29. package/features/apiRequestHeaders/feature.d.ts +6 -0
  30. package/features/apiRequestHeaders/feature.js +16 -0
  31. package/features/apiRequestHeaders/feature.js.map +1 -0
  32. package/features/apiRequestHeaders/index.d.ts +2 -0
  33. package/features/apiRequestHeaders/index.js +2 -0
  34. package/features/apiRequestHeaders/mergeHeaders.d.ts +13 -0
  35. package/features/apiRequestHeaders/mergeHeaders.js +20 -0
  36. package/features/apiRequestHeaders/mergeHeaders.js.map +1 -0
  37. package/features/graphqlClient/BatchingGraphQLClient.d.ts +3 -1
  38. package/features/graphqlClient/BatchingGraphQLClient.js +13 -3
  39. package/features/graphqlClient/BatchingGraphQLClient.js.map +1 -1
  40. package/features/graphqlClient/FetchGraphQLClient.d.ts +3 -0
  41. package/features/graphqlClient/FetchGraphQLClient.js +18 -4
  42. package/features/graphqlClient/FetchGraphQLClient.js.map +1 -1
  43. package/features/graphqlClient/GraphQLExtensionsEvent.d.ts +18 -0
  44. package/features/graphqlClient/GraphQLExtensionsEvent.js +13 -0
  45. package/features/graphqlClient/GraphQLExtensionsEvent.js.map +1 -0
  46. package/features/graphqlClient/__tests__/GraphQLClient.test.js +202 -0
  47. package/features/graphqlClient/__tests__/GraphQLClient.test.js.map +1 -1
  48. package/features/graphqlClient/abstractions.d.ts +7 -0
  49. package/features/graphqlClient/abstractions.js +2 -1
  50. package/features/graphqlClient/abstractions.js.map +1 -1
  51. package/features/graphqlClient/index.d.ts +3 -0
  52. package/features/graphqlClient/index.js +2 -1
  53. package/features/graphqlClient/publishExtensions.d.ts +13 -0
  54. package/features/graphqlClient/publishExtensions.js +16 -0
  55. package/features/graphqlClient/publishExtensions.js.map +1 -0
  56. package/features/router/HistoryRouterGateway.test.js +68 -0
  57. package/features/router/HistoryRouterGateway.test.js.map +1 -1
  58. package/features/router/Router.d.ts +9 -2
  59. package/features/router/Router.js +4 -5
  60. package/features/router/Router.js.map +1 -1
  61. package/package.json +17 -17
package/App.js CHANGED
@@ -53,10 +53,15 @@ const AppBase = /*#__PURE__*/ react.memo(({ routes = [], plugins = [], providers
53
53
  ...routes,
54
54
  ...routesFromConfig
55
55
  ];
56
+ const routeKeys = combinedRoutes.map((item)=>[
57
+ item.route.name,
58
+ item.route.path
59
+ ]);
60
+ const routesKey = JSON.stringify(routeKeys);
56
61
  useEffect(()=>{
57
62
  router.setRoutes(combinedRoutes);
58
63
  }, [
59
- combinedRoutes.length
64
+ routesKey
60
65
  ]);
61
66
  return null;
62
67
  }, []);
package/App.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"App.js","sources":["../src/App.tsx"],"sourcesContent":["import React, {\n createContext,\n Fragment,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState\n} from \"react\";\nimport {\n compose,\n CompositionProvider,\n Decorator,\n DecoratorsCollection,\n GenericComponent\n} from \"@webiny/react-composition\";\nimport { PluginsProvider } from \"./core/Plugins.js\";\nimport { RouterWithConfig, useRouterConfig } from \"./config/RouterConfig.js\";\nimport { AppContainer } from \"./AppContainer.js\";\nimport { RouteContent } from \"~/presentation/router/components/RouteContent.js\";\nimport { useRouter } from \"~/router.js\";\n\ninterface State {\n plugins: React.JSX.Element[];\n providers: Decorator<GenericComponent<ProviderProps>>[];\n}\n\ninterface AppContext extends State {\n addProvider(hoc: Decorator<GenericComponent<ProviderProps>>): void;\n addPlugin(plugin: React.ReactNode): void;\n}\n\nconst AppContext = createContext<AppContext | undefined>(undefined);\n\nAppContext.displayName = \"AppContext\";\n\nexport const useApp = () => {\n const appContext = useContext(AppContext);\n if (!appContext) {\n throw Error(\n `AppContext provider was not found. Are you using the \"useApp()\" hook in the right place?`\n );\n }\n return appContext;\n};\n\nexport interface AppProps {\n routes?: Array<any>;\n plugins?: any[];\n providers?: Array<Decorator<GenericComponent<ProviderProps>>>;\n decorators?: DecoratorsCollection;\n children?: React.ReactNode | React.ReactNode[];\n}\n\ninterface ProviderProps {\n children: React.ReactNode;\n}\n\ntype ComponentWithChildren = React.ComponentType<{ children?: React.ReactNode }>;\n\nexport const AppBase = React.memo(\n ({ routes = [], plugins = [], providers = [], children }: AppProps) => {\n const [state, setState] = useState<State>({\n plugins,\n providers\n });\n\n const addProvider = useCallback((component: Decorator<any>) => {\n setState(state => {\n if (state.providers.findIndex(m => m === component) > -1) {\n return state;\n }\n\n return {\n ...state,\n providers: [...state.providers, component]\n };\n });\n }, []);\n\n const addPlugin = useCallback((element: React.JSX.Element) => {\n setState(state => {\n return {\n ...state,\n plugins: [...state.plugins, element]\n };\n });\n }, []);\n\n const appContext = useMemo(\n () => ({\n ...state,\n addProvider,\n addPlugin\n }),\n [state]\n );\n\n const AppRouter = useMemo(() => {\n return function AppRouter() {\n const router = useRouter();\n const routerConfig = useRouterConfig();\n const routesFromConfig = routerConfig.routes;\n const combinedRoutes = [...routes, ...routesFromConfig];\n\n useEffect(() => {\n router.setRoutes(combinedRoutes);\n }, [combinedRoutes.length]);\n\n return null;\n };\n }, []);\n\n const Providers = useMemo(() => {\n return React.memo(\n compose(...(state.providers || []))(({ children }: ProviderProps) => {\n return <>{children}</>;\n })\n );\n }, [state.providers.length]) as ComponentWithChildren;\n\n Providers.displayName = \"Providers\";\n\n return (\n <AppContext.Provider value={appContext}>\n {children}\n <AppContainer>\n <Providers>\n <PluginsProvider>\n {state.plugins.map((plugin, index) => (\n <Fragment key={index}>{plugin}</Fragment>\n ))}\n </PluginsProvider>\n <RouterWithConfig>\n <AppRouter />\n <RouteContent />\n </RouterWithConfig>\n </Providers>\n </AppContainer>\n </AppContext.Provider>\n );\n }\n);\n\nAppBase.displayName = \"AppBase\";\n\nexport const App = ({ decorators, ...props }: AppProps) => {\n return (\n <CompositionProvider decorators={decorators}>\n <AppBase decorators={decorators} {...props} />\n </CompositionProvider>\n );\n};\n"],"names":["AppContext","createContext","undefined","useApp","appContext","useContext","Error","AppBase","React","routes","plugins","providers","children","state","setState","useState","addProvider","useCallback","component","m","addPlugin","element","useMemo","AppRouter","router","useRouter","routerConfig","useRouterConfig","routesFromConfig","combinedRoutes","useEffect","Providers","compose","AppContainer","PluginsProvider","plugin","index","Fragment","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bwB,WAAYnB,MAAM,SAAS,IAAI,EAAE,EAAG,CAAC,EAAED,QAAQ,EAAiB,GACrD,WAAP,GAAO,0CAAGA,aAGnB;QAACC,MAAM,SAAS,CAAC,MAAM;KAAC;IAE3BkB,UAAU,WAAW,GAAG;IAExB,OAAO,WAAP,GACI,oBAAC/B,WAAW,QAAQ;QAAC,OAAOI;OACvBQ,UAAAA,WAAAA,GACD,oBAACqB,cAAYA,MAAAA,WAAAA,GACT,oBAACF,WAAAA,MAAAA,WAAAA,GACG,oBAACG,iBAAeA,MACXrB,MAAM,OAAO,CAAC,GAAG,CAAC,CAACsB,QAAQC,QAAAA,WAAAA,GACxB,oBAACC,UAAQA;YAAC,KAAKD;WAAQD,WAAAA,WAAAA,GAG/B,oBAACG,kBAAgBA,MAAAA,WAAAA,GACb,oBAACf,WAAAA,OAAAA,WAAAA,GACD,oBAACgB,cAAYA;AAMrC;AAGJhC,QAAQ,WAAW,GAAG;AAEf,MAAMiC,MAAM,CAAC,EAAEC,UAAU,EAAE,GAAGC,OAAiB,GAC3C,WAAP,GACI,oBAACC,qBAAmBA;QAAC,YAAYF;qBAC7B,oBAAClC,SAAOA;QAAC,YAAYkC;QAAa,GAAGC,KAAK"}
1
+ {"version":3,"file":"App.js","sources":["../src/App.tsx"],"sourcesContent":["import React, {\n createContext,\n Fragment,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState\n} from \"react\";\nimport {\n compose,\n CompositionProvider,\n Decorator,\n DecoratorsCollection,\n GenericComponent\n} from \"@webiny/react-composition\";\nimport { PluginsProvider } from \"./core/Plugins.js\";\nimport { RouterWithConfig, useRouterConfig } from \"./config/RouterConfig.js\";\nimport { AppContainer } from \"./AppContainer.js\";\nimport { RouteContent } from \"~/presentation/router/components/RouteContent.js\";\nimport { useRouter } from \"~/router.js\";\n\ninterface State {\n plugins: React.JSX.Element[];\n providers: Decorator<GenericComponent<ProviderProps>>[];\n}\n\ninterface AppContext extends State {\n addProvider(hoc: Decorator<GenericComponent<ProviderProps>>): void;\n addPlugin(plugin: React.ReactNode): void;\n}\n\nconst AppContext = createContext<AppContext | undefined>(undefined);\n\nAppContext.displayName = \"AppContext\";\n\nexport const useApp = () => {\n const appContext = useContext(AppContext);\n if (!appContext) {\n throw Error(\n `AppContext provider was not found. Are you using the \"useApp()\" hook in the right place?`\n );\n }\n return appContext;\n};\n\nexport interface AppProps {\n routes?: Array<any>;\n plugins?: any[];\n providers?: Array<Decorator<GenericComponent<ProviderProps>>>;\n decorators?: DecoratorsCollection;\n children?: React.ReactNode | React.ReactNode[];\n}\n\ninterface ProviderProps {\n children: React.ReactNode;\n}\n\ntype ComponentWithChildren = React.ComponentType<{ children?: React.ReactNode }>;\n\nexport const AppBase = React.memo(\n ({ routes = [], plugins = [], providers = [], children }: AppProps) => {\n const [state, setState] = useState<State>({\n plugins,\n providers\n });\n\n const addProvider = useCallback((component: Decorator<any>) => {\n setState(state => {\n if (state.providers.findIndex(m => m === component) > -1) {\n return state;\n }\n\n return {\n ...state,\n providers: [...state.providers, component]\n };\n });\n }, []);\n\n const addPlugin = useCallback((element: React.JSX.Element) => {\n setState(state => {\n return {\n ...state,\n plugins: [...state.plugins, element]\n };\n });\n }, []);\n\n const appContext = useMemo(\n () => ({\n ...state,\n addProvider,\n addPlugin\n }),\n [state]\n );\n\n const AppRouter = useMemo(() => {\n return function AppRouter() {\n const router = useRouter();\n const routerConfig = useRouterConfig();\n const routesFromConfig = routerConfig.routes;\n const combinedRoutes = [...routes, ...routesFromConfig];\n\n /*\n * Keyed by each route's name and path, not the count: switching users can remove one\n * route and add another, and an override can keep a name under a different path. The\n * router has to see both. Elements and callbacks are left out of the key because they\n * get a new identity on every render.\n */\n const routeKeys = combinedRoutes.map(item => [item.route.name, item.route.path]);\n const routesKey = JSON.stringify(routeKeys);\n\n useEffect(() => {\n router.setRoutes(combinedRoutes);\n }, [routesKey]);\n\n return null;\n };\n }, []);\n\n const Providers = useMemo(() => {\n return React.memo(\n compose(...(state.providers || []))(({ children }: ProviderProps) => {\n return <>{children}</>;\n })\n );\n }, [state.providers.length]) as ComponentWithChildren;\n\n Providers.displayName = \"Providers\";\n\n return (\n <AppContext.Provider value={appContext}>\n {children}\n <AppContainer>\n <Providers>\n <PluginsProvider>\n {state.plugins.map((plugin, index) => (\n <Fragment key={index}>{plugin}</Fragment>\n ))}\n </PluginsProvider>\n <RouterWithConfig>\n <AppRouter />\n <RouteContent />\n </RouterWithConfig>\n </Providers>\n </AppContainer>\n </AppContext.Provider>\n );\n }\n);\n\nAppBase.displayName = \"AppBase\";\n\nexport const App = ({ decorators, ...props }: AppProps) => {\n return (\n <CompositionProvider decorators={decorators}>\n <AppBase decorators={decorators} {...props} />\n </CompositionProvider>\n );\n};\n"],"names":["AppContext","createContext","undefined","useApp","appContext","useContext","Error","AppBase","React","routes","plugins","providers","children","state","setState","useState","addProvider","useCallback","component","m","addPlugin","element","useMemo","AppRouter","router","useRouter","routerConfig","useRouterConfig","routesFromConfig","combinedRoutes","routeKeys","item","routesKey","JSON","useEffect","Providers","compose","AppContainer","PluginsProvider","plugin","index","Fragment","RouterWithConfig","RouteContent","App","decorators","props","CompositionProvider"],"mappings":";;;;;;;AAgCA,MAAMA,aAAa,WAAHA,GAAGC,cAAsCC;AAEzDF,WAAW,WAAW,GAAG;AAElB,MAAMG,SAAS;IAClB,MAAMC,aAAaC,WAAWL;IAC9B,IAAI,CAACI,YACD,MAAME,MACF;IAGR,OAAOF;AACX;AAgBO,MAAMG,UAAU,WAAHA,GAAGC,MAAAA,IAAU,CAC7B,CAAC,EAAEC,SAAS,EAAE,EAAEC,UAAU,EAAE,EAAEC,YAAY,EAAE,EAAEC,QAAQ,EAAY;IAC9D,MAAM,CAACC,OAAOC,SAAS,GAAGC,SAAgB;QACtCL;QACAC;IACJ;IAEA,MAAMK,cAAcC,YAAY,CAACC;QAC7BJ,SAASD,CAAAA;YACL,IAAIA,MAAM,SAAS,CAAC,SAAS,CAACM,CAAAA,IAAKA,MAAMD,aAAa,IAClD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xB,oBAACC,UAAQA;YAAC,KAAKD;WAAQD,WAAAA,WAAAA,GAG/B,oBAACG,kBAAgBA,MAAAA,WAAAA,GACb,oBAACnB,WAAAA,OAAAA,WAAAA,GACD,oBAACoB,cAAYA;AAMrC;AAGJpC,QAAQ,WAAW,GAAG;AAEf,MAAMqC,MAAM,CAAC,EAAEC,UAAU,EAAE,GAAGC,OAAiB,GAC3C,WAAP,GACI,oBAACC,qBAAmBA;QAAC,YAAYF;qBAC7B,oBAACtC,SAAOA;QAAC,YAAYsC;QAAa,GAAGC,KAAK"}
@@ -1,2 +1,2 @@
1
1
  import type { ImageProps } from "../types.js";
2
- export declare const Image: ({ preset: presetName, ...props }: ImageProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
2
+ export declare const Image: ({ preset: presetName, ...props }: ImageProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
@@ -0,0 +1,10 @@
1
+ export interface GraphQLOperationErrorInput {
2
+ message: string;
3
+ code?: string | null;
4
+ data?: unknown;
5
+ }
6
+ export declare class GraphQLOperationError extends Error {
7
+ readonly code: string | null;
8
+ readonly data: unknown;
9
+ constructor(input: GraphQLOperationErrorInput);
10
+ }
@@ -0,0 +1,11 @@
1
+ class GraphQLOperationError extends Error {
2
+ constructor(input){
3
+ super(input.message);
4
+ this.name = "GraphQLOperationError";
5
+ this.code = input.code ?? null;
6
+ this.data = input.data ?? null;
7
+ }
8
+ }
9
+ export { GraphQLOperationError };
10
+
11
+ //# sourceMappingURL=GraphQLOperationError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors/GraphQLOperationError.js","sources":["../../src/errors/GraphQLOperationError.ts"],"sourcesContent":["export interface GraphQLOperationErrorInput {\n message: string;\n code?: string | null;\n data?: unknown;\n}\n\n/*\n * Thrown by gateways and use cases when a GraphQL operation answers with an error envelope.\n * Unlike a plain `Error`, it keeps the server's machine-readable `code` and its `data`, so\n * callers can react to a specific refusal with `instanceof` and `code`.\n */\nexport class GraphQLOperationError extends Error {\n readonly code: string | null;\n readonly data: unknown;\n\n constructor(input: GraphQLOperationErrorInput) {\n super(input.message);\n this.name = \"GraphQLOperationError\";\n this.code = input.code ?? null;\n this.data = input.data ?? null;\n }\n}\n"],"names":["GraphQLOperationError","Error","input"],"mappings":"AAWO,MAAMA,8BAA8BC;IAIvC,YAAYC,KAAiC,CAAE;QAC3C,KAAK,CAACA,MAAM,OAAO;QACnB,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,IAAI,GAAGA,MAAM,IAAI,IAAI;QAC1B,IAAI,CAAC,IAAI,GAAGA,MAAM,IAAI,IAAI;IAC9B;AACJ"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,97 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { GraphQLOperationError } from "../GraphQLOperationError.js";
3
+ import { GraphQLOperationError as external_index_js_GraphQLOperationError } from "../index.js";
4
+ describe("GraphQLOperationError", ()=>{
5
+ it("keeps the message, the code and the data", ()=>{
6
+ const data = {
7
+ reviews: [
8
+ {
9
+ reviewId: "review-1",
10
+ title: "Spring launch"
11
+ }
12
+ ]
13
+ };
14
+ const error = new GraphQLOperationError({
15
+ message: "This content has a review in progress.",
16
+ code: "Workflows/Review/ActiveReviewOnTrash",
17
+ data
18
+ });
19
+ expect(error.message).toBe("This content has a review in progress.");
20
+ expect(error.code).toBe("Workflows/Review/ActiveReviewOnTrash");
21
+ expect(error.data).toBe(data);
22
+ });
23
+ it("defaults code and data to null when they are omitted", ()=>{
24
+ const error = new GraphQLOperationError({
25
+ message: "The request failed."
26
+ });
27
+ expect(error.code).toBeNull();
28
+ expect(error.data).toBeNull();
29
+ });
30
+ it("defaults code and data to null when they are null or undefined", ()=>{
31
+ const withNulls = new GraphQLOperationError({
32
+ message: "The request failed.",
33
+ code: null,
34
+ data: null
35
+ });
36
+ const withUndefined = new GraphQLOperationError({
37
+ message: "The request failed.",
38
+ code: void 0,
39
+ data: void 0
40
+ });
41
+ expect(withNulls.code).toBeNull();
42
+ expect(withNulls.data).toBeNull();
43
+ expect(withUndefined.code).toBeNull();
44
+ expect(withUndefined.data).toBeNull();
45
+ });
46
+ it("keeps falsy data values that are not null or undefined", ()=>{
47
+ const withZero = new GraphQLOperationError({
48
+ message: "m",
49
+ data: 0
50
+ });
51
+ const withEmptyString = new GraphQLOperationError({
52
+ message: "m",
53
+ data: ""
54
+ });
55
+ const withFalse = new GraphQLOperationError({
56
+ message: "m",
57
+ data: false
58
+ });
59
+ expect(withZero.data).toBe(0);
60
+ expect(withEmptyString.data).toBe("");
61
+ expect(withFalse.data).toBe(false);
62
+ });
63
+ it("is an Error with its own name and a stack", ()=>{
64
+ const error = new GraphQLOperationError({
65
+ message: "The request failed."
66
+ });
67
+ expect(error).toBeInstanceOf(Error);
68
+ expect(error).toBeInstanceOf(GraphQLOperationError);
69
+ expect(error.name).toBe("GraphQLOperationError");
70
+ expect(typeof error.stack).toBe("string");
71
+ expect(String(error)).toBe("GraphQLOperationError: The request failed.");
72
+ });
73
+ it("is told apart from a plain Error by instanceof after a throw and catch", ()=>{
74
+ let caught = null;
75
+ try {
76
+ throw new GraphQLOperationError({
77
+ message: "Nope",
78
+ code: "Workflows/NotAuthorized"
79
+ });
80
+ } catch (error) {
81
+ caught = error;
82
+ }
83
+ let plain = null;
84
+ try {
85
+ throw new Error("Nope");
86
+ } catch (error) {
87
+ plain = error;
88
+ }
89
+ expect(caught instanceof GraphQLOperationError).toBe(true);
90
+ expect(plain instanceof GraphQLOperationError).toBe(false);
91
+ });
92
+ it("is exported from the errors barrel as the same class", ()=>{
93
+ expect(external_index_js_GraphQLOperationError).toBe(GraphQLOperationError);
94
+ });
95
+ });
96
+
97
+ //# sourceMappingURL=GraphQLOperationError.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors/__tests__/GraphQLOperationError.test.js","sources":["../../../src/errors/__tests__/GraphQLOperationError.test.ts"],"sourcesContent":["import { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { GraphQLOperationError } from \"../GraphQLOperationError.js\";\nimport { GraphQLOperationError as ExportedGraphQLOperationError } from \"../index.js\";\n\ndescribe(\"GraphQLOperationError\", () => {\n it(\"keeps the message, the code and the data\", () => {\n const data = { reviews: [{ reviewId: \"review-1\", title: \"Spring launch\" }] };\n\n const error = new GraphQLOperationError({\n message: \"This content has a review in progress.\",\n code: \"Workflows/Review/ActiveReviewOnTrash\",\n data\n });\n\n expect(error.message).toBe(\"This content has a review in progress.\");\n expect(error.code).toBe(\"Workflows/Review/ActiveReviewOnTrash\");\n expect(error.data).toBe(data);\n });\n\n it(\"defaults code and data to null when they are omitted\", () => {\n const error = new GraphQLOperationError({ message: \"The request failed.\" });\n\n expect(error.code).toBeNull();\n expect(error.data).toBeNull();\n });\n\n it(\"defaults code and data to null when they are null or undefined\", () => {\n const withNulls = new GraphQLOperationError({\n message: \"The request failed.\",\n code: null,\n data: null\n });\n const withUndefined = new GraphQLOperationError({\n message: \"The request failed.\",\n code: undefined,\n data: undefined\n });\n\n expect(withNulls.code).toBeNull();\n expect(withNulls.data).toBeNull();\n expect(withUndefined.code).toBeNull();\n expect(withUndefined.data).toBeNull();\n });\n\n it(\"keeps falsy data values that are not null or undefined\", () => {\n const withZero = new GraphQLOperationError({ message: \"m\", data: 0 });\n const withEmptyString = new GraphQLOperationError({ message: \"m\", data: \"\" });\n const withFalse = new GraphQLOperationError({ message: \"m\", data: false });\n\n expect(withZero.data).toBe(0);\n expect(withEmptyString.data).toBe(\"\");\n expect(withFalse.data).toBe(false);\n });\n\n it(\"is an Error with its own name and a stack\", () => {\n const error = new GraphQLOperationError({ message: \"The request failed.\" });\n\n expect(error).toBeInstanceOf(Error);\n expect(error).toBeInstanceOf(GraphQLOperationError);\n expect(error.name).toBe(\"GraphQLOperationError\");\n expect(typeof error.stack).toBe(\"string\");\n expect(String(error)).toBe(\"GraphQLOperationError: The request failed.\");\n });\n\n it(\"is told apart from a plain Error by instanceof after a throw and catch\", () => {\n let caught: unknown = null;\n try {\n throw new GraphQLOperationError({ message: \"Nope\", code: \"Workflows/NotAuthorized\" });\n } catch (error) {\n caught = error;\n }\n\n let plain: unknown = null;\n try {\n throw new Error(\"Nope\");\n } catch (error) {\n plain = error;\n }\n\n expect(caught instanceof GraphQLOperationError).toBe(true);\n expect(plain instanceof GraphQLOperationError).toBe(false);\n });\n\n it(\"is exported from the errors barrel as the same class\", () => {\n expect(ExportedGraphQLOperationError).toBe(GraphQLOperationError);\n });\n});\n"],"names":["describe","it","data","error","GraphQLOperationError","expect","withNulls","withUndefined","undefined","withZero","withEmptyString","withFalse","Error","String","caught","plain","ExportedGraphQLOperationError"],"mappings":";;;AAMAA,SAAS,yBAAyB;IAC9BC,GAAG,4CAA4C;QAC3C,MAAMC,OAAO;YAAE,SAAS;gBAAC;oBAAE,UAAU;oBAAY,OAAO;gBAAgB;aAAE;QAAC;QAE3E,MAAMC,QAAQ,IAAIC,sBAAsB;YACpC,SAAS;YACT,MAAM;YACNF;QACJ;QAEAG,OAAOF,MAAM,OAAO,EAAE,IAAI,CAAC;QAC3BE,OAAOF,MAAM,IAAI,EAAE,IAAI,CAAC;QACxBE,OAAOF,MAAM,IAAI,EAAE,IAAI,CAACD;IAC5B;IAEAD,GAAG,wDAAwD;QACvD,MAAME,QAAQ,IAAIC,sBAAsB;YAAE,SAAS;QAAsB;QAEzEC,OAAOF,MAAM,IAAI,EAAE,QAAQ;QAC3BE,OAAOF,MAAM,IAAI,EAAE,QAAQ;IAC/B;IAEAF,GAAG,kEAAkE;QACjE,MAAMK,YAAY,IAAIF,sBAAsB;YACxC,SAAS;YACT,MAAM;YACN,MAAM;QACV;QACA,MAAMG,gBAAgB,IAAIH,sBAAsB;YAC5C,SAAS;YACT,MAAMI;YACN,MAAMA;QACV;QAEAH,OAAOC,UAAU,IAAI,EAAE,QAAQ;QAC/BD,OAAOC,UAAU,IAAI,EAAE,QAAQ;QAC/BD,OAAOE,cAAc,IAAI,EAAE,Q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"./AuthenticationErrorEvent.js";
5
5
  export type { AuthenticationErrorPayload } from "./AuthenticationErrorEvent.js";
6
6
  export { AuthenticationErrorEventHandler } from "./abstractions.js";
7
+ export { GraphQLOperationError } from "./GraphQLOperationError.js";
8
+ export type { GraphQLOperationErrorInput } from "./GraphQLOperationError.js";
package/errors/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { NetworkErrorEvent } from "./NetworkErrorEvent.js";
2
2
  export { AuthenticationErrorEventHandler, NetworkErrorEventHandler } from "./abstractions.js";
3
3
  export { AuthenticationErrorEvent } from "./AuthenticationErrorEvent.js";
4
+ export { GraphQLOperationError } from "./GraphQLOperationError.js";
@@ -1,8 +1,10 @@
1
1
  export { MainGraphQLClient } from "../features/mainGraphQLClient/index.js";
2
2
  export { ApiStreamClient, readServerSentEvents } from "../features/apiStreamClient/index.js";
3
+ export { ApiRequestHeaders } from "../features/apiRequestHeaders/index.js";
3
4
  export { useFeature } from "../shared/di/useFeature.js";
4
5
  export { NetworkErrorEventHandler } from "../errors/index.js";
5
6
  export { createProviderPlugin } from "../core/createProviderPlugin.js";
6
7
  export { createProvider } from "../core/createProvider.js";
7
8
  export { Provider } from "../core/Provider.js";
8
9
  export { Plugin } from "../core/Plugin.js";
10
+ export { DiContainerProvider } from "../shared/di/DiContainerProvider.js";
package/exports/admin.js CHANGED
@@ -1,8 +1,10 @@
1
1
  export { MainGraphQLClient } from "../features/mainGraphQLClient/index.js";
2
2
  export { ApiStreamClient, readServerSentEvents } from "../features/apiStreamClient/index.js";
3
+ export { ApiRequestHeaders } from "../features/apiRequestHeaders/index.js";
3
4
  export { useFeature } from "../shared/di/useFeature.js";
4
5
  export { NetworkErrorEventHandler } from "../errors/index.js";
5
6
  export { createProviderPlugin } from "../core/createProviderPlugin.js";
6
7
  export { createProvider } from "../core/createProvider.js";
7
8
  export { Provider } from "../core/Provider.js";
8
9
  export { Plugin } from "../core/Plugin.js";
10
+ export { DiContainerProvider } from "../shared/di/DiContainerProvider.js";
@@ -0,0 +1,13 @@
1
+ import type { Container } from "@webiny/di";
2
+ import { ApiRequestHeaders } from "./abstractions.js";
3
+ import type { ApiRequestHeadersResolver as Abstraction } from "./abstractions.js";
4
+ /**
5
+ * Looks the providers up on every request, not once: the clients are singletons built at boot, and
6
+ * extensions register their providers later, while the app renders (like `EventPublisher` with its
7
+ * handlers).
8
+ */
9
+ export declare class ApiRequestHeadersResolver implements Abstraction.Interface {
10
+ private container;
11
+ constructor(container: Container);
12
+ resolve(): Promise<ApiRequestHeaders.Headers>;
13
+ }
@@ -0,0 +1,15 @@
1
+ import { ApiRequestHeaders } from "./abstractions.js";
2
+ import { mergeProviderHeaders } from "./mergeHeaders.js";
3
+ class ApiRequestHeadersResolver {
4
+ constructor(container){
5
+ this.container = container;
6
+ }
7
+ async resolve() {
8
+ const providers = this.container.resolveAll(ApiRequestHeaders);
9
+ const results = await Promise.all(providers.map((provider)=>provider.getHeaders()));
10
+ return mergeProviderHeaders(results);
11
+ }
12
+ }
13
+ export { ApiRequestHeadersResolver };
14
+
15
+ //# sourceMappingURL=ApiRequestHeadersResolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/apiRequestHeaders/ApiRequestHeadersResolver.js","sources":["../../../src/features/apiRequestHeaders/ApiRequestHeadersResolver.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport { ApiRequestHeaders } from \"./abstractions.js\";\nimport { mergeProviderHeaders } from \"./mergeHeaders.js\";\nimport type { ApiRequestHeadersResolver as Abstraction } from \"./abstractions.js\";\n\n/**\n * Looks the providers up on every request, not once: the clients are singletons built at boot, and\n * extensions register their providers later, while the app renders (like `EventPublisher` with its\n * handlers).\n */\nexport class ApiRequestHeadersResolver implements Abstraction.Interface {\n constructor(private container: Container) {}\n\n async resolve(): Promise<ApiRequestHeaders.Headers> {\n const providers = this.container.resolveAll(ApiRequestHeaders);\n const results = await Promise.all(providers.map(provider => provider.getHeaders()));\n return mergeProviderHeaders(results);\n }\n}\n"],"names":["ApiRequestHeadersResolver","container","providers","ApiRequestHeaders","results","Promise","provider","mergeProviderHeaders"],"mappings":";;AAUO,MAAMA;IACT,YAAoBC,SAAoB,CAAE;aAAtBA,SAAS,GAATA;IAAuB;IAE3C,MAAM,UAA8C;QAChD,MAAMC,YAAY,IAAI,CAAC,SAAS,CAAC,UAAU,CAACC;QAC5C,MAAMC,UAAU,MAAMC,QAAQ,GAAG,CAACH,UAAU,GAAG,CAACI,CAAAA,WAAYA,SAAS,UAAU;QAC/E,OAAOC,qBAAqBH;IAChC;AACJ"}
@@ -0,0 +1,12 @@
1
+ import { ApiStreamClient } from "../../features/apiStreamClient/abstractions.js";
2
+ import { ApiRequestHeadersResolver } from "./abstractions.js";
3
+ declare class ApiStreamClientWithApiRequestHeaders implements ApiStreamClient.Interface {
4
+ private resolver;
5
+ private decoratee;
6
+ constructor(resolver: ApiRequestHeadersResolver.Interface, decoratee: ApiStreamClient.Interface);
7
+ execute(params: ApiStreamClient.Request): Promise<ApiStreamClient.Response>;
8
+ }
9
+ export declare const ApiStreamClientDecorator: typeof ApiStreamClientWithApiRequestHeaders & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("~/features/apiStreamClient/abstractions.js").IApiStreamClient>;
11
+ };
12
+ export {};
@@ -0,0 +1,25 @@
1
+ import { ApiStreamClient } from "../apiStreamClient/abstractions.js";
2
+ import { ApiRequestHeadersResolver } from "./abstractions.js";
3
+ import { withProviderHeaders } from "./mergeHeaders.js";
4
+ class ApiStreamClientWithApiRequestHeaders {
5
+ constructor(resolver, decoratee){
6
+ this.resolver = resolver;
7
+ this.decoratee = decoratee;
8
+ }
9
+ async execute(params) {
10
+ const headers = await this.resolver.resolve();
11
+ return this.decoratee.execute({
12
+ ...params,
13
+ headers: withProviderHeaders(headers, params.headers)
14
+ });
15
+ }
16
+ }
17
+ const ApiStreamClientDecorator = ApiStreamClient.createDecorator({
18
+ decorator: ApiStreamClientWithApiRequestHeaders,
19
+ dependencies: [
20
+ ApiRequestHeadersResolver
21
+ ]
22
+ });
23
+ export { ApiStreamClientDecorator };
24
+
25
+ //# sourceMappingURL=ApiStreamClientDecorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/apiRequestHeaders/ApiStreamClientDecorator.js","sources":["../../../src/features/apiRequestHeaders/ApiStreamClientDecorator.ts"],"sourcesContent":["import { ApiStreamClient } from \"~/features/apiStreamClient/abstractions.js\";\nimport { ApiRequestHeadersResolver } from \"./abstractions.js\";\nimport { withProviderHeaders } from \"./mergeHeaders.js\";\n\nclass ApiStreamClientWithApiRequestHeaders implements ApiStreamClient.Interface {\n constructor(\n private resolver: ApiRequestHeadersResolver.Interface,\n private decoratee: ApiStreamClient.Interface\n ) {}\n\n async execute(params: ApiStreamClient.Request): Promise<ApiStreamClient.Response> {\n const headers = await this.resolver.resolve();\n return this.decoratee.execute({\n ...params,\n headers: withProviderHeaders(headers, params.headers)\n });\n }\n}\n\nexport const ApiStreamClientDecorator = ApiStreamClient.createDecorator({\n decorator: ApiStreamClientWithApiRequestHeaders,\n dependencies: [ApiRequestHeadersResolver]\n});\n"],"names":["ApiStreamClientWithApiRequestHeaders","resolver","decoratee","params","headers","withProviderHeaders","ApiStreamClientDecorator","ApiStreamClient","ApiRequestHeadersResolver"],"mappings":";;;AAIA,MAAMA;IACF,YACYC,QAA6C,EAC7CC,SAAoC,CAC9C;aAFUD,QAAQ,GAARA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,QAAQC,MAA+B,EAAqC;QAC9E,MAAMC,UAAU,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO;QAC3C,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAC1B,GAAGD,MAAM;YACT,SAASE,oBAAoBD,SAASD,OAAO,OAAO;QACxD;IACJ;AACJ;AAEO,MAAMG,2BAA2BC,gBAAgB,eAAe,CAAC;IACpE,WAAWP;IACX,cAAc;QAACQ;KAA0B;AAC7C"}
@@ -0,0 +1,12 @@
1
+ import { GraphQLClient } from "../../features/graphqlClient/abstractions.js";
2
+ import { ApiRequestHeadersResolver } from "./abstractions.js";
3
+ declare class GraphQLClientWithApiRequestHeaders implements GraphQLClient.Interface {
4
+ private resolver;
5
+ private decoratee;
6
+ constructor(resolver: ApiRequestHeadersResolver.Interface, decoratee: GraphQLClient.Interface);
7
+ execute<TResult = any, TVariables = any>(params: GraphQLClient.Request<TVariables>): Promise<TResult>;
8
+ }
9
+ export declare const GraphQLClientDecorator: typeof GraphQLClientWithApiRequestHeaders & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("~/features/graphqlClient/abstractions.js").IGraphQLClient>;
11
+ };
12
+ export {};
@@ -0,0 +1,25 @@
1
+ import { GraphQLClient } from "../graphqlClient/abstractions.js";
2
+ import { ApiRequestHeadersResolver } from "./abstractions.js";
3
+ import { withProviderHeaders } from "./mergeHeaders.js";
4
+ class GraphQLClientWithApiRequestHeaders {
5
+ constructor(resolver, decoratee){
6
+ this.resolver = resolver;
7
+ this.decoratee = decoratee;
8
+ }
9
+ async execute(params) {
10
+ const headers = await this.resolver.resolve();
11
+ return this.decoratee.execute({
12
+ ...params,
13
+ headers: withProviderHeaders(headers, params.headers)
14
+ });
15
+ }
16
+ }
17
+ const GraphQLClientDecorator = GraphQLClient.createDecorator({
18
+ decorator: GraphQLClientWithApiRequestHeaders,
19
+ dependencies: [
20
+ ApiRequestHeadersResolver
21
+ ]
22
+ });
23
+ export { GraphQLClientDecorator };
24
+
25
+ //# sourceMappingURL=GraphQLClientDecorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/apiRequestHeaders/GraphQLClientDecorator.js","sources":["../../../src/features/apiRequestHeaders/GraphQLClientDecorator.ts"],"sourcesContent":["import { GraphQLClient } from \"~/features/graphqlClient/abstractions.js\";\nimport { ApiRequestHeadersResolver } from \"./abstractions.js\";\nimport { withProviderHeaders } from \"./mergeHeaders.js\";\n\nclass GraphQLClientWithApiRequestHeaders implements GraphQLClient.Interface {\n constructor(\n private resolver: ApiRequestHeadersResolver.Interface,\n private decoratee: GraphQLClient.Interface\n ) {}\n\n async execute<TResult = any, TVariables = any>(\n params: GraphQLClient.Request<TVariables>\n ): Promise<TResult> {\n const headers = await this.resolver.resolve();\n return this.decoratee.execute({\n ...params,\n headers: withProviderHeaders(headers, params.headers)\n });\n }\n}\n\nexport const GraphQLClientDecorator = GraphQLClient.createDecorator({\n decorator: GraphQLClientWithApiRequestHeaders,\n dependencies: [ApiRequestHeadersResolver]\n});\n"],"names":["GraphQLClientWithApiRequestHeaders","resolver","decoratee","params","headers","withProviderHeaders","GraphQLClientDecorator","GraphQLClient","ApiRequestHeadersResolver"],"mappings":";;;AAIA,MAAMA;IACF,YACYC,QAA6C,EAC7CC,SAAkC,CAC5C;aAFUD,QAAQ,GAARA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,QACFC,MAAyC,EACzB;QAChB,MAAMC,UAAU,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO;QAC3C,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAC1B,GAAGD,MAAM;YACT,SAASE,oBAAoBD,SAASD,OAAO,OAAO;QACxD;IACJ;AACJ;AAEO,MAAMG,yBAAyBC,cAAc,eAAe,CAAC;IAChE,WAAWP;IACX,cAAc;QAACQ;KAA0B;AAC7C"}
@@ -0,0 +1,199 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+ import { Container } from "@webiny/di";
3
+ import { GraphQLClient } from "../../graphqlClient/abstractions.js";
4
+ import { ApiStreamClient } from "../../apiStreamClient/abstractions.js";
5
+ import { ApiRequestHeaders } from "../abstractions.js";
6
+ import { ApiRequestHeadersFeature } from "../feature.js";
7
+ function createContainer() {
8
+ const container = new Container();
9
+ const graphql = vi.fn(async (_params)=>({}));
10
+ const stream = vi.fn(async (_params)=>new Response());
11
+ class FetchGraphQL {
12
+ execute(params) {
13
+ return graphql(params);
14
+ }
15
+ }
16
+ class FetchStream {
17
+ execute(params) {
18
+ return stream(params);
19
+ }
20
+ }
21
+ container.register(GraphQLClient.createImplementation({
22
+ implementation: FetchGraphQL,
23
+ dependencies: []
24
+ })).inSingletonScope();
25
+ container.register(ApiStreamClient.createImplementation({
26
+ implementation: FetchStream,
27
+ dependencies: []
28
+ })).inSingletonScope();
29
+ ApiRequestHeadersFeature.register(container);
30
+ class WithTenant {
31
+ constructor(decoratee){
32
+ this.decoratee = decoratee;
33
+ }
34
+ execute(params) {
35
+ return this.decoratee.execute({
36
+ ...params,
37
+ headers: {
38
+ ...params.headers,
39
+ "x-tenant": "root"
40
+ }
41
+ });
42
+ }
43
+ }
44
+ container.registerDecorator(GraphQLClient.createDecorator({
45
+ decorator: WithTenant,
46
+ dependencies: []
47
+ }));
48
+ return {
49
+ container,
50
+ graphql,
51
+ stream
52
+ };
53
+ }
54
+ const sentHeaders = (mock)=>mock.mock.calls.at(-1)[0].headers;
55
+ describe("ApiRequestHeaders", ()=>{
56
+ it("adds a provider registered after the clients were built, on the next request", async ()=>{
57
+ const { container, graphql, stream } = createContainer();
58
+ const client = container.resolve(GraphQLClient);
59
+ const streamClient = container.resolve(ApiStreamClient);
60
+ expect(container.resolve(GraphQLClient)).toBe(client);
61
+ await client.execute({
62
+ endpoint: "/graphql",
63
+ query: "{ a }"
64
+ });
65
+ expect(sentHeaders(graphql)).toEqual({
66
+ "x-tenant": "root"
67
+ });
68
+ container.registerInstance(ApiRequestHeaders, {
69
+ getHeaders: async ()=>({
70
+ "x-site": "a"
71
+ })
72
+ });
73
+ await client.execute({
74
+ endpoint: "/graphql",
75
+ query: "{ a }"
76
+ });
77
+ await streamClient.execute({
78
+ path: "/stream/x"
79
+ });
80
+ expect(sentHeaders(graphql)).toEqual({
81
+ "x-site": "a",
82
+ "x-tenant": "root"
83
+ });
84
+ expect(sentHeaders(stream)).toEqual({
85
+ "x-site": "a"
86
+ });
87
+ });
88
+ it("reads a provider on every request", async ()=>{
89
+ const { container, graphql } = createContainer();
90
+ let site = "a";
91
+ container.registerInstance(ApiRequestHeaders, {
92
+ getHeaders: ()=>site ? {
93
+ "x-site": site
94
+ } : {}
95
+ });
96
+ const client = container.resolve(GraphQLClient);
97
+ await client.execute({
98
+ endpoint: "/graphql",
99
+ query: "{ a }"
100
+ });
101
+ expect(sentHeaders(graphql)["x-site"]).toBe("a");
102
+ site = void 0;
103
+ await client.execute({
104
+ endpoint: "/graphql",
105
+ query: "{ a }"
106
+ });
107
+ expect(sentHeaders(graphql)).not.toHaveProperty("x-site");
108
+ });
109
+ it("doesn't let a provider's undefined value overwrite another provider's header", async ()=>{
110
+ const { container, graphql, stream } = createContainer();
111
+ container.registerInstance(ApiRequestHeaders, {
112
+ getHeaders: ()=>({
113
+ "x-site": "a"
114
+ })
115
+ });
116
+ container.registerInstance(ApiRequestHeaders, {
117
+ getHeaders: ()=>({
118
+ "x-site": void 0
119
+ })
120
+ });
121
+ await container.resolve(GraphQLClient).execute({
122
+ endpoint: "/graphql",
123
+ query: "{ a }"
124
+ });
125
+ await container.resolve(ApiStreamClient).execute({
126
+ path: "/stream/x"
127
+ });
128
+ expect(sentHeaders(graphql)["x-site"]).toBe("a");
129
+ expect(sentHeaders(stream)["x-site"]).toBe("a");
130
+ });
131
+ it("lets the request's own and the outer decorators' headers win", async ()=>{
132
+ const { container, graphql } = createContainer();
133
+ container.registerInstance(ApiRequestHeaders, {
134
+ getHeaders: ()=>({
135
+ "x-tenant": "other",
136
+ "x-request": "provider"
137
+ })
138
+ });
139
+ await container.resolve(GraphQLClient).execute({
140
+ endpoint: "/graphql",
141
+ query: "{ a }",
142
+ headers: {
143
+ "x-request": "own"
144
+ }
145
+ });
146
+ expect(sentHeaders(graphql)).toEqual({
147
+ "x-tenant": "root",
148
+ "x-request": "own"
149
+ });
150
+ });
151
+ it("merges header names case-insensitively, the later provider and the request winning", async ()=>{
152
+ for (const [first, second] of [
153
+ [
154
+ "x-site",
155
+ "X-Site"
156
+ ],
157
+ [
158
+ "X-Site",
159
+ "x-site"
160
+ ]
161
+ ]){
162
+ const { container, graphql, stream } = createContainer();
163
+ container.registerInstance(ApiRequestHeaders, {
164
+ getHeaders: ()=>({
165
+ [first]: "a"
166
+ })
167
+ });
168
+ container.registerInstance(ApiRequestHeaders, {
169
+ getHeaders: ()=>({
170
+ [second]: "b",
171
+ "X-Tenant": "other",
172
+ "x-request": "provider"
173
+ })
174
+ });
175
+ await container.resolve(GraphQLClient).execute({
176
+ endpoint: "/graphql",
177
+ query: "{ a }",
178
+ headers: {
179
+ "X-Request": "own"
180
+ }
181
+ });
182
+ await container.resolve(ApiStreamClient).execute({
183
+ path: "/stream/x"
184
+ });
185
+ expect(sentHeaders(graphql)).toEqual({
186
+ [second]: "b",
187
+ "x-tenant": "root",
188
+ "X-Request": "own"
189
+ });
190
+ expect(sentHeaders(stream)).toEqual({
191
+ [second]: "b",
192
+ "X-Tenant": "other",
193
+ "x-request": "provider"
194
+ });
195
+ }
196
+ });
197
+ });
198
+
199
+ //# sourceMappingURL=ApiRequestHeaders.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/apiRequestHeaders/__tests__/ApiRequestHeaders.test.js","sources":["../../../../src/features/apiRequestHeaders/__tests__/ApiRequestHeaders.test.ts"],"sourcesContent":["import { describe, expect, it, vi } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { GraphQLClient } from \"~/features/graphqlClient/abstractions.js\";\nimport { ApiStreamClient } from \"~/features/apiStreamClient/abstractions.js\";\nimport { ApiRequestHeaders } from \"../abstractions.js\";\nimport { ApiRequestHeadersFeature } from \"../feature.js\";\n\n// The clients as the root container has them: singletons, with an outer decorator that sets the tenant.\nfunction createContainer() {\n const container = new Container();\n const graphql = vi.fn(async (_params: GraphQLClient.Request) => ({}));\n const stream = vi.fn(async (_params: ApiStreamClient.Request) => new Response());\n class FetchGraphQL implements GraphQLClient.Interface {\n execute(params: GraphQLClient.Request) {\n return graphql(params) as any;\n }\n }\n class FetchStream implements ApiStreamClient.Interface {\n execute(params: ApiStreamClient.Request) {\n return stream(params) as any;\n }\n }\n container\n .register(\n GraphQLClient.createImplementation({\n implementation: FetchGraphQL,\n dependencies: []\n })\n )\n .inSingletonScope();\n container\n .register(\n ApiStreamClient.createImplementation({\n implementation: FetchStream,\n dependencies: []\n })\n )\n .inSingletonScope();\n ApiRequestHeadersFeature.register(container);\n\n class WithTenant implements GraphQLClient.Interface {\n constructor(private decoratee: GraphQLClient.Interface) {}\n execute(params: GraphQLClient.Request) {\n return this.decoratee.execute({\n ...params,\n headers: { ...params.headers, \"x-tenant\": \"root\" }\n });\n }\n }\n container.registerDecorator(\n GraphQLClient.createDecorator({ decorator: WithTenant, dependencies: [] })\n );\n return { container, graphql, stream };\n}\n\nconst sentHeaders = (mock: ReturnType<typeof vi.fn>) =>\n (mock.mock.calls.at(-1) as any[])[0].headers;\n\ndescribe(\"ApiRequestHeaders\", () => {\n it(\"adds a provider registered after the clients were built, on the next request\", async () => {\n const { container, graphql, stream } = createContainer();\n const client = container.resolve(GraphQLClient);\n const streamClient = container.resolve(ApiStreamClient);\n // Built once and cached, as at the admin's boot.\n expect(container.resolve(GraphQLClient)).toBe(client);\n\n await client.execute({ endpoint: \"/graphql\", query: \"{ a }\" });\n expect(sentHeaders(graphql)).toEqual({ \"x-tenant\": \"root\" });\n\n container.registerInstance(ApiRequestHeaders, {\n getHeaders: async () => ({ \"x-site\": \"a\" })\n });\n\n await client.execute({ endpoint: \"/graphql\", query: \"{ a }\" });\n await streamClient.execute({ path: \"/stream/x\" });\n expect(sentHeaders(graphql)).toEqual({ \"x-site\": \"a\", \"x-tenant\": \"root\" });\n expect(sentHeaders(stream)).toEqual({ \"x-site\": \"a\" });\n });\n\n it(\"reads a provider on every request\", async () => {\n const { container, graphql } = createContainer();\n let site: string | undefined = \"a\";\n container.registerInstance(ApiRequestHeaders, {\n getHeaders: () => (site ? { \"x-site\": site } : {})\n });\n const client = container.resolve(GraphQLClient);\n\n await client.execute({ endpoint: \"/graphql\", query: \"{ a }\" });\n expect(sentHeaders(graphql)[\"x-site\"]).toBe(\"a\");\n\n site = undefined;\n await client.execute({ endpoint: \"/graphql\", query: \"{ a }\" });\n expect(sentHeaders(graphql)).not.toHaveProperty(\"x-site\");\n });\n\n it(\"doesn't let a provider's undefined value overwrite another provider's header\", async () => {\n const { container, graphql, stream } = createContainer();\n container.registerInstance(ApiRequestHeaders, {\n getHeaders: () => ({ \"x-site\": \"a\" })\n });\n container.registerInstance(ApiRequestHeaders, {\n getHeaders: () => ({ \"x-site\": undefined })\n });\n\n await container.resolve(GraphQLClient).execute({ endpoint: \"/graphql\", query: \"{ a }\" });\n await container.resolve(ApiStreamClient).execute({ path: \"/stream/x\" });\n\n expect(sentHeaders(graphql)[\"x-site\"]).toBe(\"a\");\n expect(sentHeaders(stream)[\"x-site\"]).toBe(\"a\");\n });\n\n it(\"lets the request's own and the outer decorators' headers win\", async () => {\n const { container, graphql } = createContainer();\n container.registerInstance(ApiRequestHeaders, {\n getHeaders: () => ({ \"x-tenant\": \"other\", \"x-request\": \"provider\" })\n });\n\n await container.resolve(GraphQLClient).execute({\n endpoint: \"/graphql\",\n query: \"{ a }\",\n headers: { \"x-request\": \"own\" }\n });\n\n expect(sentHeaders(graphql)).toEqual({\n \"x-tenant\": \"root\",\n \"x-request\": \"own\"\n });\n });\n\n it(\"merges header names case-insensitively, the later provider and the request winning\", async () => {\n for (const [first, second] of [\n [\"x-site\", \"X-Site\"],\n [\"X-Site\", \"x-site\"]\n ]) {\n const { container, graphql, stream } = createContainer();\n container.registerInstance(ApiRequestHeaders, {\n getHeaders: () => ({ [first]: \"a\" })\n });\n container.registerInstance(ApiRequestHeaders, {\n getHeaders: () => ({\n [second]: \"b\",\n \"X-Tenant\": \"other\",\n \"x-request\": \"provider\"\n })\n });\n\n await container.resolve(GraphQLClient).execute({\n endpoint: \"/graphql\",\n query: \"{ a }\",\n headers: { \"X-Request\": \"own\" }\n });\n await container.resolve(ApiStreamClient).execute({ path: \"/stream/x\" });\n\n expect(sentHeaders(graphql)).toEqual({\n [second]: \"b\",\n \"x-tenant\": \"root\",\n \"X-Request\": \"own\"\n });\n expect(sentHeaders(stream)).toEqual({\n [second]: \"b\",\n \"X-Tenant\": \"other\",\n \"x-request\": \"provider\"\n });\n }\n });\n});\n"],"names":["createContainer","container","Container","graphql","vi","_params","stream","Response","FetchGraphQL","params","FetchStream","GraphQLClient","ApiStreamClient","ApiRequestHeadersFeature","WithTenant","decoratee","sentHeaders","mock","describe","it","client","streamClient","expect","ApiRequestHeaders","site","undefined","first","second"],"mappings":";;;;;;AAQA,SAASA;IACL,MAAMC,YAAY,IAAIC;IACtB,MAAMC,UAAUC,GAAG,EAAE,CAAC,OAAOC,UAAoC,EAAC;IAClE,MAAMC,SAASF,GAAG,EAAE,CAAC,OAAOC,UAAqC,IAAIE;IACrE,MAAMC;QACF,QAAQC,MAA6B,EAAE;YACnC,OAAON,QAAQM;QACnB;IACJ;IACA,MAAMC;QACF,QAAQD,MAA+B,EAAE;YACrC,OAAOH,OAAOG;QAClB;IACJ;IACAR,UACK,QAAQ,CACLU,cAAc,oBAAoB,CAAC;QAC/B,gBAAgBH;QAChB,cAAc,EAAE;IACpB,IAEH,gBAAgB;IACrBP,UACK,QAAQ,CACLW,gBAAgB,oBAAoB,CAAC;QACjC,gBAAgBF;QAChB,cAAc,EAAE;IACpB,IAEH,gBAAgB;IACrBG,yBAAyB,QAAQ,CAACZ;IAElC,MAAMa;QACF,YAAoBC,SAAkC,CAAE;iBAApCA,SAAS,GAATA;QAAqC;QACzD,QAAQN,MAA6B,EAAE;YACnC,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;gBAC1B,GAAGA,MAAM;gBACT,SAAS;oBAAE,GAAGA,OAAO,OAAO;oBAAE,YAAY;gBAAO;YACrD;QACJ;IACJ;IACAR,UAAU,iBAAiB,CACvBU,cAAc,eAAe,CAAC;QAAE,WAAWG;QAAY,cAAc,EAAE;IAAC;IAE5E,OAAO;QAAEb;QAAWE;QAASG;IAAO;AACxC;AAEA,MAAMU,cAAc,CAACC,OAChBA,K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,gBAAgB,CAACsB,mBAAmB;gBAC1C,YAAY,IAAO;wBACf,CAACI,OAAO,EAAE;wBACV,YAAY;wBACZ,aAAa;oBACjB;YACJ;YAEA,MAAM1B,UAAU,OAAO,CAACU,eAAe,OAAO,CAAC;gBAC3C,UAAU;gBACV,OAAO;gBACP,SAAS;oBAAE,aAAa;gBAAM;YAClC;YACA,MAAMV,UAAU,OAAO,CAACW,iBAAiB,OAAO,CAAC;gBAAE,MAAM;YAAY;YAErEU,OAAON,YAAYb,UAAU,OAAO,CAAC;gBACjC,CAACwB,OAAO,EAAE;gBACV,YAAY;gBACZ,aAAa;YACjB;YACAL,OAAON,YAAYV,SAAS,OAAO,CAAC;gBAChC,CAACqB,OAAO,EAAE;gBACV,YAAY;gBACZ,aAAa;YACjB;QACJ;IACJ;AACJ"}
@@ -0,0 +1,26 @@
1
+ type IHeaders = Record<string, string | number | undefined>;
2
+ /**
3
+ * Extra headers for every request to Webiny's API (`GraphQLClient` and `ApiStreamClient`), read when
4
+ * a request is sent. An extension registers one for a header the API needs on each request, e.g. a
5
+ * scope its own decorators read. Headers the request sets itself (tenant, auth, …) win.
6
+ *
7
+ * Register it in the root container (as `RegisterFeature` does): the clients look providers up there.
8
+ * Only for Webiny's API: requests to other hosts (storage uploads, identity providers) don't get them.
9
+ */
10
+ export interface IApiRequestHeaders {
11
+ getHeaders(): IHeaders | Promise<IHeaders>;
12
+ }
13
+ export declare const ApiRequestHeaders: import("@webiny/di").Abstraction<IApiRequestHeaders>;
14
+ export declare namespace ApiRequestHeaders {
15
+ type Interface = IApiRequestHeaders;
16
+ type Headers = IHeaders;
17
+ }
18
+ /** The headers of every registered `ApiRequestHeaders`, collected for one request. */
19
+ export interface IApiRequestHeadersResolver {
20
+ resolve(): Promise<IHeaders>;
21
+ }
22
+ export declare const ApiRequestHeadersResolver: import("@webiny/di").Abstraction<IApiRequestHeadersResolver>;
23
+ export declare namespace ApiRequestHeadersResolver {
24
+ type Interface = IApiRequestHeadersResolver;
25
+ }
26
+ export {};