@webiny/app 6.3.0-beta.4 → 6.4.0-beta.0
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.
- package/App.js +70 -77
- package/App.js.map +1 -1
- package/AppContainer.js +3 -6
- package/AppContainer.js.map +1 -1
- package/apollo-client/InMemoryCache.js +11 -13
- package/apollo-client/InMemoryCache.js.map +1 -1
- package/apollo-client/IntrospectionFragmentMatcher.js +26 -38
- package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -1
- package/components/Image.js +11 -17
- package/components/Image.js.map +1 -1
- package/components/index.js +0 -2
- package/config/RouterConfig/Route.js +23 -28
- package/config/RouterConfig/Route.js.map +1 -1
- package/config/RouterConfig.js +11 -10
- package/config/RouterConfig.js.map +1 -1
- package/config.js +19 -20
- package/config.js.map +1 -1
- package/contexts/Ui/index.js +26 -28
- package/contexts/Ui/index.js.map +1 -1
- package/core/Plugin.js +7 -9
- package/core/Plugin.js.map +1 -1
- package/core/Plugins.js +15 -34
- package/core/Plugins.js.map +1 -1
- package/core/Provider.js +5 -13
- package/core/Provider.js.map +1 -1
- package/core/createProvider.js +3 -6
- package/core/createProvider.js.map +1 -1
- package/core/createProviderPlugin.js +8 -13
- package/core/createProviderPlugin.js.map +1 -1
- package/errors/AuthenticationErrorEvent.js +8 -5
- package/errors/AuthenticationErrorEvent.js.map +1 -1
- package/errors/NetworkErrorEvent.js +8 -5
- package/errors/NetworkErrorEvent.js.map +1 -1
- package/errors/abstractions.js +3 -2
- package/errors/abstractions.js.map +1 -1
- package/errors/index.js +1 -4
- package/exports/admin/env-config.js +0 -2
- package/exports/admin/graphql-client.js +0 -2
- package/exports/admin/local-storage.js +0 -2
- package/exports/admin/router.js +0 -2
- package/exports/admin/security.js +0 -2
- package/exports/admin.js +0 -2
- package/features/envConfig/EnvConfig.js +12 -13
- package/features/envConfig/EnvConfig.js.map +1 -1
- package/features/envConfig/abstractions.js +2 -1
- package/features/envConfig/abstractions.js.map +1 -1
- package/features/envConfig/feature.js +9 -8
- package/features/envConfig/feature.js.map +1 -1
- package/features/envConfig/index.js +0 -2
- package/features/eventPublisher/EventPublisher.js +13 -21
- package/features/eventPublisher/EventPublisher.js.map +1 -1
- package/features/eventPublisher/abstractions.js +7 -9
- package/features/eventPublisher/abstractions.js.map +1 -1
- package/features/eventPublisher/feature.js +13 -12
- package/features/eventPublisher/feature.js.map +1 -1
- package/features/eventPublisher/index.js +1 -3
- package/features/graphqlClient/AuthenticationErrorPublishing.js +26 -26
- package/features/graphqlClient/AuthenticationErrorPublishing.js.map +1 -1
- package/features/graphqlClient/BatchingGraphQLClient.js +104 -149
- package/features/graphqlClient/BatchingGraphQLClient.js.map +1 -1
- package/features/graphqlClient/FetchGraphQLClient.js +41 -48
- package/features/graphqlClient/FetchGraphQLClient.js.map +1 -1
- package/features/graphqlClient/NetworkErrorPublishing.js +35 -42
- package/features/graphqlClient/NetworkErrorPublishing.js.map +1 -1
- package/features/graphqlClient/RequestValue.js +42 -41
- package/features/graphqlClient/RequestValue.js.map +1 -1
- package/features/graphqlClient/RetryGraphQLClient.js +36 -45
- package/features/graphqlClient/RetryGraphQLClient.js.map +1 -1
- package/features/graphqlClient/__tests__/GraphQLClient.test.js +383 -356
- package/features/graphqlClient/__tests__/GraphQLClient.test.js.map +1 -1
- package/features/graphqlClient/abstractions.js +2 -1
- package/features/graphqlClient/abstractions.js.map +1 -1
- package/features/graphqlClient/feature.js +14 -20
- package/features/graphqlClient/feature.js.map +1 -1
- package/features/graphqlClient/index.js +0 -2
- package/features/graphqlClient/types.js +0 -3
- package/features/localStorage/BrowserLocalStorageGateway.js +56 -63
- package/features/localStorage/BrowserLocalStorageGateway.js.map +1 -1
- package/features/localStorage/LocalStorage.js +27 -24
- package/features/localStorage/LocalStorage.js.map +1 -1
- package/features/localStorage/LocalStorageRepository.js +75 -88
- package/features/localStorage/LocalStorageRepository.js.map +1 -1
- package/features/localStorage/abstractions.js +5 -16
- package/features/localStorage/abstractions.js.map +1 -1
- package/features/localStorage/feature.js +17 -28
- package/features/localStorage/feature.js.map +1 -1
- package/features/localStorage/index.js +1 -3
- package/features/mainGraphQLClient/MainGraphQLClient.js +18 -14
- package/features/mainGraphQLClient/MainGraphQLClient.js.map +1 -1
- package/features/mainGraphQLClient/abstractions.js +2 -1
- package/features/mainGraphQLClient/abstractions.js.map +1 -1
- package/features/mainGraphQLClient/feature.js +11 -10
- package/features/mainGraphQLClient/feature.js.map +1 -1
- package/features/mainGraphQLClient/index.js +0 -2
- package/features/router/HistoryRouterGateway.js +75 -105
- package/features/router/HistoryRouterGateway.js.map +1 -1
- package/features/router/HistoryRouterGateway.test.js +184 -193
- package/features/router/HistoryRouterGateway.test.js.map +1 -1
- package/features/router/Route.js +38 -54
- package/features/router/Route.js.map +1 -1
- package/features/router/RouteUrl.js +84 -217
- package/features/router/RouteUrl.js.map +1 -1
- package/features/router/Router.js +67 -124
- package/features/router/Router.js.map +1 -1
- package/features/router/RouterPresenter.js +44 -49
- package/features/router/RouterPresenter.js.map +1 -1
- package/features/router/RouterRepository.js +103 -111
- package/features/router/RouterRepository.js.map +1 -1
- package/features/router/RouterRepository.test.js +119 -150
- package/features/router/RouterRepository.test.js.map +1 -1
- package/features/router/abstractions.js +4 -14
- package/features/router/abstractions.js.map +1 -1
- package/features/router/feature.js +13 -12
- package/features/router/feature.js.map +1 -1
- package/features/router/index.js +1 -3
- package/helpers/InterfaceGenerator/date.js +0 -3
- package/helpers/InterfaceGenerator/id.js +0 -3
- package/helpers/InterfaceGenerator/identity.js +0 -3
- package/helpers/InterfaceGenerator/index.js +0 -3
- package/helpers/InterfaceGenerator/numeric.js +0 -3
- package/helpers/InterfaceGenerator/truthful.js +0 -3
- package/hooks/useAutocomplete/index.js +0 -2
- package/hooks/useAutocomplete/useAutocomplete.js +12 -15
- package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
- package/hooks/useDataList/functions/getData.js +2 -1
- package/hooks/useDataList/functions/getData.js.map +1 -1
- package/hooks/useDataList/functions/getError.js +2 -1
- package/hooks/useDataList/functions/getError.js.map +1 -1
- package/hooks/useDataList/functions/getMeta.js +2 -1
- package/hooks/useDataList/functions/getMeta.js.map +1 -1
- package/hooks/useDataList/functions/index.js +0 -2
- package/hooks/useDataList/functions/searchDataByKey.js +9 -14
- package/hooks/useDataList/functions/searchDataByKey.js.map +1 -1
- package/hooks/useDataList/index.js +0 -2
- package/hooks/useDataList/useDataList.js +131 -152
- package/hooks/useDataList/useDataList.js.map +1 -1
- package/hooks/useDataList/utils/index.js +0 -2
- package/hooks/useDataList/utils/prepareLoadListParams.js +25 -34
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
- package/hooks/useHandler.js +12 -16
- package/hooks/useHandler.js.map +1 -1
- package/hooks/useHandlers.js +18 -20
- package/hooks/useHandlers.js.map +1 -1
- package/hooks/useRegisterLegacyPlugin.js +7 -6
- package/hooks/useRegisterLegacyPlugin.js.map +1 -1
- package/hooks/useUi.js +2 -3
- package/hooks/useUi.js.map +1 -1
- package/i18n/i18n.js +8 -4
- package/i18n/i18n.js.map +1 -1
- package/i18n/index.js +0 -2
- package/index.js +6 -11
- package/package.json +13 -13
- package/plugins/AddQuerySelectionPlugin.js +36 -61
- package/plugins/AddQuerySelectionPlugin.js.map +1 -1
- package/plugins/ApolloCacheObjectIdPlugin.js +12 -11
- package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -1
- package/plugins/ApolloDynamicLink.js +20 -22
- package/plugins/ApolloDynamicLink.js.map +1 -1
- package/plugins/ApolloLinkPlugin.js +16 -15
- package/plugins/ApolloLinkPlugin.js.map +1 -1
- package/plugins/ConsoleLinkPlugin.js +19 -21
- package/plugins/ConsoleLinkPlugin.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +39 -45
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js +18 -22
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js +21 -29
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +6 -15
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/Typography.js +9 -14
- package/plugins/NetworkErrorLinkPlugin/Typography.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js +19 -0
- package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +11 -18
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin.js +41 -58
- package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
- package/plugins/OmitTypenameLinkPlugin.js +9 -14
- package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
- package/plugins/TenantHeaderLinkPlugin.js +23 -32
- package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
- package/plugins/components/Image.js +8 -15
- package/plugins/components/Image.js.map +1 -1
- package/plugins/image.js +94 -133
- package/plugins/image.js.map +1 -1
- package/plugins/index.js +35 -59
- package/plugins/index.js.map +1 -1
- package/presentation/envConfig/useEnvConfig.js +4 -8
- package/presentation/envConfig/useEnvConfig.js.map +1 -1
- package/presentation/localStorage/index.js +0 -2
- package/presentation/localStorage/useLocalStorage.js +10 -16
- package/presentation/localStorage/useLocalStorage.js.map +1 -1
- package/presentation/localStorage/useLocalStorageValue.js +15 -13
- package/presentation/localStorage/useLocalStorageValue.js.map +1 -1
- package/presentation/localStorage/useLocalStorageValues.js +23 -30
- package/presentation/localStorage/useLocalStorageValues.js.map +1 -1
- package/presentation/router/RouteElementRegistry.js +22 -25
- package/presentation/router/RouteElementRegistry.js.map +1 -1
- package/presentation/router/abstractions.js +2 -1
- package/presentation/router/abstractions.js.map +1 -1
- package/presentation/router/components/Redirect.js +8 -10
- package/presentation/router/components/Redirect.js.map +1 -1
- package/presentation/router/components/RouteContent.js +14 -17
- package/presentation/router/components/RouteContent.js.map +1 -1
- package/presentation/router/components/RouteLink.js +11 -16
- package/presentation/router/components/RouteLink.js.map +1 -1
- package/presentation/router/components/SimpleLink.js +18 -24
- package/presentation/router/components/SimpleLink.js.map +1 -1
- package/presentation/router/hooks/useRoute.js +15 -23
- package/presentation/router/hooks/useRoute.js.map +1 -1
- package/presentation/router/hooks/useRouter.js +22 -23
- package/presentation/router/hooks/useRouter.js.map +1 -1
- package/presentation/router/index.js +0 -2
- package/presentation/router/types.js +0 -3
- package/react-butterfiles/Files.js +148 -217
- package/react-butterfiles/Files.js.map +1 -1
- package/react-butterfiles/index.js +2 -1
- package/react-butterfiles/index.js.map +1 -1
- package/react-butterfiles/utils/generateId.js +2 -3
- package/react-butterfiles/utils/generateId.js.map +1 -1
- package/react-butterfiles/utils/readFileContent.js +9 -13
- package/react-butterfiles/utils/readFileContent.js.map +1 -1
- package/renderApp.js +7 -6
- package/renderApp.js.map +1 -1
- package/router.js +0 -3
- package/rslib-runtime.js +14 -0
- package/rslib-runtime.js.map +1 -0
- package/shared/di/DiContainerProvider.js +8 -12
- package/shared/di/DiContainerProvider.js.map +1 -1
- package/shared/di/createFeature.js +7 -8
- package/shared/di/createFeature.js.map +1 -1
- package/shared/di/useFeature.js +7 -3
- package/shared/di/useFeature.js.map +1 -1
- package/static/svg/close_24px.33adaadc.svg +1 -0
- package/types.js +0 -3
- package/utils/createGenericContext.js +17 -21
- package/utils/createGenericContext.js.map +1 -1
- package/utils/createHashing.js +13 -16
- package/utils/createHashing.js.map +1 -1
- package/utils/index.js +0 -2
- package/utils/legacyPluginToReactComponent.js +11 -10
- package/utils/legacyPluginToReactComponent.js.map +1 -1
- package/components/index.js.map +0 -1
- package/errors/index.js.map +0 -1
- package/exports/admin/env-config.js.map +0 -1
- package/exports/admin/graphql-client.js.map +0 -1
- package/exports/admin/local-storage.js.map +0 -1
- package/exports/admin/router.js.map +0 -1
- package/exports/admin/security.js.map +0 -1
- package/exports/admin.js.map +0 -1
- package/features/envConfig/index.js.map +0 -1
- package/features/eventPublisher/index.js.map +0 -1
- package/features/graphqlClient/index.js.map +0 -1
- package/features/graphqlClient/types.js.map +0 -1
- package/features/localStorage/index.js.map +0 -1
- package/features/mainGraphQLClient/index.js.map +0 -1
- package/features/router/index.js.map +0 -1
- package/helpers/InterfaceGenerator/date.js.map +0 -1
- package/helpers/InterfaceGenerator/id.js.map +0 -1
- package/helpers/InterfaceGenerator/identity.js.map +0 -1
- package/helpers/InterfaceGenerator/index.js.map +0 -1
- package/helpers/InterfaceGenerator/numeric.js.map +0 -1
- package/helpers/InterfaceGenerator/truthful.js.map +0 -1
- package/hooks/useAutocomplete/index.js.map +0 -1
- package/hooks/useDataList/functions/index.js.map +0 -1
- package/hooks/useDataList/index.js.map +0 -1
- package/hooks/useDataList/utils/index.js.map +0 -1
- package/i18n/index.js.map +0 -1
- package/index.js.map +0 -1
- package/presentation/localStorage/index.js.map +0 -1
- package/presentation/router/index.js.map +0 -1
- package/presentation/router/types.js.map +0 -1
- package/router.js.map +0 -1
- package/types.js.map +0 -1
- package/utils/index.js.map +0 -1
|
@@ -3,53 +3,46 @@ import { EventPublisher } from "../eventPublisher/index.js";
|
|
|
3
3
|
import { NetworkErrorEvent } from "../../errors/index.js";
|
|
4
4
|
import { RequestValue } from "./RequestValue.js";
|
|
5
5
|
class NetworkErrorPublishingDecorator {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
async execute(params) {
|
|
11
|
-
try {
|
|
12
|
-
return await this.decoratee.execute(params);
|
|
13
|
-
} catch (error) {
|
|
14
|
-
// Only publish network errors, not GraphQL errors
|
|
15
|
-
if (this.isNetworkError(error)) {
|
|
16
|
-
const request = RequestValue.from(params);
|
|
17
|
-
const event = new NetworkErrorEvent({
|
|
18
|
-
message: error.message,
|
|
19
|
-
code: error.code ?? undefined,
|
|
20
|
-
operationName: request.operationName,
|
|
21
|
-
query: request.queryAsString,
|
|
22
|
-
variables: request.variables,
|
|
23
|
-
errorType: this.determineErrorType(error)
|
|
24
|
-
});
|
|
25
|
-
await this.eventPublisher.publish(event);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Re-throw to preserve existing behavior
|
|
29
|
-
throw error;
|
|
6
|
+
constructor(eventPublisher, decoratee){
|
|
7
|
+
this.eventPublisher = eventPublisher;
|
|
8
|
+
this.decoratee = decoratee;
|
|
30
9
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
10
|
+
async execute(params) {
|
|
11
|
+
try {
|
|
12
|
+
return await this.decoratee.execute(params);
|
|
13
|
+
} catch (error) {
|
|
14
|
+
if (this.isNetworkError(error)) {
|
|
15
|
+
const request = RequestValue.from(params);
|
|
16
|
+
const event = new NetworkErrorEvent({
|
|
17
|
+
message: error.message,
|
|
18
|
+
code: error.code ?? void 0,
|
|
19
|
+
operationName: request.operationName,
|
|
20
|
+
query: request.queryAsString,
|
|
21
|
+
variables: request.variables,
|
|
22
|
+
errorType: this.determineErrorType(error)
|
|
23
|
+
});
|
|
24
|
+
await this.eventPublisher.publish(event);
|
|
25
|
+
}
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
40
28
|
}
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
isNetworkError(error) {
|
|
30
|
+
return error.message.includes("Tenant is disabled") || error.message.includes("Network error") || error.message.includes("Failed to fetch") || error.message.includes("network failure") || error.message.includes("Local AWS Lambda");
|
|
43
31
|
}
|
|
44
|
-
|
|
45
|
-
|
|
32
|
+
determineErrorType(error) {
|
|
33
|
+
const message = error.message.toLowerCase();
|
|
34
|
+
if (message.includes("timeout")) return "timeout";
|
|
35
|
+
if (message.includes("fetch") || message.includes("failed to fetch")) return "fetch";
|
|
36
|
+
if (message.includes("network")) return "network";
|
|
37
|
+
return "unknown";
|
|
46
38
|
}
|
|
47
|
-
return "unknown";
|
|
48
|
-
}
|
|
49
39
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
40
|
+
const NetworkErrorPublishing = GraphQLClient.createDecorator({
|
|
41
|
+
decorator: NetworkErrorPublishingDecorator,
|
|
42
|
+
dependencies: [
|
|
43
|
+
EventPublisher
|
|
44
|
+
]
|
|
53
45
|
});
|
|
46
|
+
export { NetworkErrorPublishing };
|
|
54
47
|
|
|
55
48
|
//# sourceMappingURL=NetworkErrorPublishing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/graphqlClient/NetworkErrorPublishing.js","sources":["../../../src/features/graphqlClient/NetworkErrorPublishing.ts"],"sourcesContent":["import { GraphQLClient } from \"./abstractions.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { NetworkErrorEvent } from \"~/errors/index.js\";\nimport { RequestValue } from \"./RequestValue.js\";\n\nclass NetworkErrorPublishingDecorator implements GraphQLClient.Interface {\n constructor(\n private eventPublisher: EventPublisher.Interface,\n private decoratee: GraphQLClient.Interface\n ) {}\n\n async execute<TResult = any, TVariables = any>(\n params: GraphQLClient.Request<TVariables>\n ): Promise<TResult> {\n try {\n return await this.decoratee.execute(params);\n } catch (error) {\n // Only publish network errors, not GraphQL errors\n if (this.isNetworkError(error as Error)) {\n const request = RequestValue.from(params);\n\n const event = new NetworkErrorEvent({\n message: (error as Error).message,\n code: error.code ?? undefined,\n operationName: request.operationName,\n query: request.queryAsString,\n variables: request.variables,\n errorType: this.determineErrorType(error as Error)\n });\n\n await this.eventPublisher.publish(event);\n }\n\n // Re-throw to preserve existing behavior\n throw error;\n }\n }\n\n private isNetworkError(error: Error): boolean {\n // Network errors typically have these patterns in the message\n return (\n error.message.includes(\"Tenant is disabled\") ||\n error.message.includes(\"Network error\") ||\n error.message.includes(\"Failed to fetch\") ||\n error.message.includes(\"network failure\") ||\n error.message.includes(\"Local AWS Lambda\")\n );\n }\n\n private determineErrorType(error: Error): \"network\" | \"timeout\" | \"fetch\" | \"unknown\" {\n const message = error.message.toLowerCase();\n\n if (message.includes(\"timeout\")) {\n return \"timeout\";\n }\n\n if (message.includes(\"fetch\") || message.includes(\"failed to fetch\")) {\n return \"fetch\";\n }\n\n if (message.includes(\"network\")) {\n return \"network\";\n }\n\n return \"unknown\";\n }\n}\n\nexport const NetworkErrorPublishing = GraphQLClient.createDecorator({\n decorator: NetworkErrorPublishingDecorator,\n dependencies: [EventPublisher]\n});\n"],"names":["NetworkErrorPublishingDecorator","eventPublisher","decoratee","params","error","request","RequestValue","event","NetworkErrorEvent","undefined","message","NetworkErrorPublishing","GraphQLClient","EventPublisher"],"mappings":";;;;AAKA,MAAMA;IACF,YACYC,cAAwC,EACxCC,SAAkC,CAC5C;aAFUD,cAAc,GAAdA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,QACFC,MAAyC,EACzB;QAChB,IAAI;YACA,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACA;QACxC,EAAE,OAAOC,OAAO;YAEZ,IAAI,IAAI,CAAC,cAAc,CAACA,QAAiB;gBACrC,MAAMC,UAAUC,aAAa,IAAI,CAACH;gBAElC,MAAMI,QAAQ,IAAIC,kBAAkB;oBAChC,SAAUJ,MAAgB,OAAO;oBACjC,MAAMA,MAAM,IAAI,IAAIK;oBACpB,eAAeJ,QAAQ,aAAa;oBACpC,OAAOA,QAAQ,aAAa;oBAC5B,WAAWA,QAAQ,SAAS;oBAC5B,WAAW,IAAI,CAAC,kBAAkB,CAACD;gBACvC;gBAEA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAACG;YACtC;YAGA,MAAMH;QACV;IACJ;IAEQ,eAAeA,KAAY,EAAW;QAE1C,OACIA,MAAM,OAAO,CAAC,QAAQ,CAAC,yBACvBA,MAAM,OAAO,CAAC,QAAQ,CAAC,oBACvBA,MAAM,OAAO,CAAC,QAAQ,CAAC,sBACvBA,MAAM,OAAO,CAAC,QAAQ,CAAC,sBACvBA,MAAM,OAAO,CAAC,QAAQ,CAAC;IAE/B;IAEQ,mBAAmBA,KAAY,EAA+C;QAClF,MAAMM,UAAUN,MAAM,OAAO,CAAC,WAAW;QAEzC,IAAIM,QAAQ,QAAQ,CAAC,YACjB,OAAO;QAGX,IAAIA,QAAQ,QAAQ,CAAC,YAAYA,QAAQ,QAAQ,CAAC,oBAC9C,OAAO;QAGX,IAAIA,QAAQ,QAAQ,CAAC,YACjB,OAAO;QAGX,OAAO;IACX;AACJ;AAEO,MAAMC,yBAAyBC,cAAc,eAAe,CAAC;IAChE,WAAWZ;IACX,cAAc;QAACa;KAAe;AAClC"}
|
|
@@ -1,45 +1,46 @@
|
|
|
1
1
|
import { getOperationAST, parse, print } from "graphql";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
2
|
+
class RequestValue {
|
|
3
|
+
static from(value) {
|
|
4
|
+
return new RequestValue(value);
|
|
5
|
+
}
|
|
6
|
+
constructor(value){
|
|
7
|
+
this.value = value;
|
|
8
|
+
this._request = value;
|
|
9
|
+
if ("string" == typeof value.query) {
|
|
10
|
+
this._queryAsString = value.query;
|
|
11
|
+
this._queryAsDocumentNode = parse(value.query);
|
|
12
|
+
} else {
|
|
13
|
+
this._queryAsString = print(value.query);
|
|
14
|
+
this._queryAsDocumentNode = value.query;
|
|
15
|
+
}
|
|
16
|
+
this._operationName = this.getOperationName(this._queryAsDocumentNode);
|
|
17
|
+
}
|
|
18
|
+
get request() {
|
|
19
|
+
return this._request;
|
|
20
|
+
}
|
|
21
|
+
get variables() {
|
|
22
|
+
return this._request.variables;
|
|
23
|
+
}
|
|
24
|
+
get queryAsString() {
|
|
25
|
+
return this._queryAsString;
|
|
26
|
+
}
|
|
27
|
+
get queryAsDocumentNode() {
|
|
28
|
+
return this._queryAsDocumentNode;
|
|
29
|
+
}
|
|
30
|
+
get headers() {
|
|
31
|
+
return this._request.headers;
|
|
32
|
+
}
|
|
33
|
+
get endpoint() {
|
|
34
|
+
return this._request.endpoint;
|
|
35
|
+
}
|
|
36
|
+
get operationName() {
|
|
37
|
+
return this._operationName;
|
|
38
|
+
}
|
|
39
|
+
getOperationName(query) {
|
|
40
|
+
const operationAST = getOperationAST(query, void 0);
|
|
41
|
+
return operationAST?.name?.value;
|
|
42
|
+
}
|
|
43
43
|
}
|
|
44
|
+
export { RequestValue };
|
|
44
45
|
|
|
45
46
|
//# sourceMappingURL=RequestValue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/graphqlClient/RequestValue.js","sources":["../../../src/features/graphqlClient/RequestValue.ts"],"sourcesContent":["import { getOperationAST, parse, print, type DocumentNode } from \"graphql\";\nimport { GraphQLClient } from \"./abstractions.js\";\n\nexport class RequestValue {\n private readonly _operationName: string | undefined;\n private readonly _queryAsString: string;\n private readonly _queryAsDocumentNode: DocumentNode;\n private readonly _request: GraphQLClient.Request;\n\n static from(value: GraphQLClient.Request) {\n return new RequestValue(value);\n }\n\n private constructor(readonly value: GraphQLClient.Request) {\n this._request = value;\n if (typeof value.query === \"string\") {\n this._queryAsString = value.query;\n this._queryAsDocumentNode = parse(value.query);\n } else {\n this._queryAsString = print(value.query);\n this._queryAsDocumentNode = value.query;\n }\n\n this._operationName = this.getOperationName(this._queryAsDocumentNode);\n }\n\n get request() {\n return this._request;\n }\n\n get variables() {\n return this._request.variables;\n }\n\n get queryAsString() {\n return this._queryAsString;\n }\n\n get queryAsDocumentNode() {\n return this._queryAsDocumentNode;\n }\n\n get headers() {\n return this._request.headers;\n }\n\n get endpoint() {\n return this._request.endpoint;\n }\n\n get operationName() {\n return this._operationName;\n }\n\n private getOperationName(query: DocumentNode): string | undefined {\n const operationAST = getOperationAST(query, undefined);\n return operationAST?.name?.value;\n }\n}\n"],"names":["RequestValue","value","parse","print","query","operationAST","getOperationAST","undefined"],"mappings":";AAGO,MAAMA;IAMT,OAAO,KAAKC,KAA4B,EAAE;QACtC,OAAO,IAAID,aAAaC;IAC5B;IAEA,YAA6BA,KAA4B,CAAE;aAA9BA,KAAK,GAALA;QACzB,IAAI,CAAC,QAAQ,GAAGA;QAChB,IAAI,AAAuB,YAAvB,OAAOA,MAAM,KAAK,EAAe;YACjC,IAAI,CAAC,cAAc,GAAGA,MAAM,KAAK;YACjC,IAAI,CAAC,oBAAoB,GAAGC,MAAMD,MAAM,KAAK;QACjD,OAAO;YACH,IAAI,CAAC,cAAc,GAAGE,MAAMF,MAAM,KAAK;YACvC,IAAI,CAAC,oBAAoB,GAAGA,MAAM,KAAK;QAC3C;QAEA,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,oBAAoB;IACzE;IAEA,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,QAAQ;IACxB;IAEA,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS;IAClC;IAEA,IAAI,gBAAgB;QAChB,OAAO,IAAI,CAAC,cAAc;IAC9B;IAEA,IAAI,sBAAsB;QACtB,OAAO,IAAI,CAAC,oBAAoB;IACpC;IAEA,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO;IAChC;IAEA,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ;IACjC;IAEA,IAAI,gBAAgB;QAChB,OAAO,IAAI,CAAC,cAAc;IAC9B;IAEQ,iBAAiBG,KAAmB,EAAsB;QAC9D,MAAMC,eAAeC,gBAAgBF,OAAOG;QAC5C,OAAOF,cAAc,MAAM;IAC/B;AACJ"}
|
|
@@ -1,54 +1,45 @@
|
|
|
1
1
|
import { GraphQLClient } from "./abstractions.js";
|
|
2
2
|
import { EnvConfig } from "../envConfig/index.js";
|
|
3
3
|
class RetryGraphQLClientImpl {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// Don't retry GraphQL errors (business logic errors)
|
|
19
|
-
// Only retry network/infrastructure errors
|
|
20
|
-
if (this.isGraphQLError(error) || this.isAuthenticationError(error) || this.isMaintenanceError(error)) {
|
|
21
|
-
throw error;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Don't delay after the last attempt
|
|
25
|
-
if (attempt < this.maxRetries) {
|
|
26
|
-
await this.delay(this.calculateBackoff(attempt));
|
|
4
|
+
constructor(envConfig, decoratee){
|
|
5
|
+
this.decoratee = decoratee;
|
|
6
|
+
const gqlClientConfig = envConfig.get("graphqlClient");
|
|
7
|
+
this.maxRetries = gqlClientConfig?.retries.maxRetries ?? 3;
|
|
8
|
+
this.baseDelayMs = gqlClientConfig?.retries.delayInMillis ?? 100;
|
|
9
|
+
}
|
|
10
|
+
async execute(params) {
|
|
11
|
+
let lastError;
|
|
12
|
+
for(let attempt = 0; attempt <= this.maxRetries; attempt++)try {
|
|
13
|
+
return await this.decoratee.execute(params);
|
|
14
|
+
} catch (error) {
|
|
15
|
+
lastError = error;
|
|
16
|
+
if (this.isGraphQLError(error) || this.isAuthenticationError(error) || this.isMaintenanceError(error)) throw error;
|
|
17
|
+
if (attempt < this.maxRetries) await this.delay(this.calculateBackoff(attempt));
|
|
27
18
|
}
|
|
28
|
-
|
|
19
|
+
throw lastError;
|
|
20
|
+
}
|
|
21
|
+
isGraphQLError(error) {
|
|
22
|
+
return error.message.includes("GraphQL");
|
|
23
|
+
}
|
|
24
|
+
isAuthenticationError(error) {
|
|
25
|
+
return error.code?.includes("Authentication/");
|
|
26
|
+
}
|
|
27
|
+
isMaintenanceError(error) {
|
|
28
|
+
return error.code?.includes("Tenancy/");
|
|
29
|
+
}
|
|
30
|
+
calculateBackoff(attempt) {
|
|
31
|
+
return Math.pow(2, attempt) * this.baseDelayMs;
|
|
32
|
+
}
|
|
33
|
+
delay(ms) {
|
|
34
|
+
return new Promise((resolve)=>setTimeout(resolve, ms));
|
|
29
35
|
}
|
|
30
|
-
throw lastError;
|
|
31
|
-
}
|
|
32
|
-
isGraphQLError(error) {
|
|
33
|
-
return error.message.includes("GraphQL");
|
|
34
|
-
}
|
|
35
|
-
isAuthenticationError(error) {
|
|
36
|
-
return error.code?.includes("Authentication/");
|
|
37
|
-
}
|
|
38
|
-
isMaintenanceError(error) {
|
|
39
|
-
return error.code?.includes("Tenancy/");
|
|
40
|
-
}
|
|
41
|
-
calculateBackoff(attempt) {
|
|
42
|
-
// Exponential backoff: 100ms, 200ms, 400ms, etc.
|
|
43
|
-
return Math.pow(2, attempt) * this.baseDelayMs;
|
|
44
|
-
}
|
|
45
|
-
delay(ms) {
|
|
46
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
47
|
-
}
|
|
48
36
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
37
|
+
const RetryGraphQLClient = GraphQLClient.createDecorator({
|
|
38
|
+
decorator: RetryGraphQLClientImpl,
|
|
39
|
+
dependencies: [
|
|
40
|
+
EnvConfig
|
|
41
|
+
]
|
|
52
42
|
});
|
|
43
|
+
export { RetryGraphQLClient };
|
|
53
44
|
|
|
54
45
|
//# sourceMappingURL=RetryGraphQLClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/graphqlClient/RetryGraphQLClient.js","sources":["../../../src/features/graphqlClient/RetryGraphQLClient.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/admin\";\nimport { GraphQLClient } from \"./abstractions.js\";\nimport { EnvConfig } from \"~/features/envConfig/index.js\";\n\nclass RetryGraphQLClientImpl implements GraphQLClient.Interface {\n private readonly maxRetries: number;\n private readonly baseDelayMs: number;\n\n constructor(\n envConfig: EnvConfig.Interface,\n private decoratee: GraphQLClient.Interface\n ) {\n const gqlClientConfig = envConfig.get(\"graphqlClient\");\n\n this.maxRetries = gqlClientConfig?.retries.maxRetries ?? 3;\n this.baseDelayMs = gqlClientConfig?.retries.delayInMillis ?? 100;\n }\n\n async execute<TResult = any, TVariables = any>(\n params: GraphQLClient.Request<TVariables>\n ): Promise<TResult> {\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n try {\n return await this.decoratee.execute(params);\n } catch (error) {\n lastError = error as Error;\n\n // Don't retry GraphQL errors (business logic errors)\n // Only retry network/infrastructure errors\n if (\n this.isGraphQLError(error as Error) ||\n this.isAuthenticationError(error as BaseError) ||\n this.isMaintenanceError(error as BaseError)\n ) {\n throw error;\n }\n\n // Don't delay after the last attempt\n if (attempt < this.maxRetries) {\n await this.delay(this.calculateBackoff(attempt));\n }\n }\n }\n\n throw lastError!;\n }\n\n private isGraphQLError(error: Error): boolean {\n return error.message.includes(\"GraphQL\");\n }\n\n private isAuthenticationError(error: BaseError): boolean {\n return error.code?.includes(\"Authentication/\");\n }\n\n private isMaintenanceError(error: BaseError): boolean {\n return error.code?.includes(\"Tenancy/\");\n }\n\n private calculateBackoff(attempt: number): number {\n // Exponential backoff: 100ms, 200ms, 400ms, etc.\n return Math.pow(2, attempt) * this.baseDelayMs;\n }\n\n private delay(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n }\n}\n\nexport const RetryGraphQLClient = GraphQLClient.createDecorator({\n decorator: RetryGraphQLClientImpl,\n dependencies: [EnvConfig]\n});\n"],"names":["RetryGraphQLClientImpl","envConfig","decoratee","gqlClientConfig","params","lastError","attempt","error","Math","ms","Promise","resolve","setTimeout","RetryGraphQLClient","GraphQLClient","EnvConfig"],"mappings":";;AAIA,MAAMA;IAIF,YACIC,SAA8B,EACtBC,SAAkC,CAC5C;aADUA,SAAS,GAATA;QAER,MAAMC,kBAAkBF,UAAU,GAAG,CAAC;QAEtC,IAAI,CAAC,UAAU,GAAGE,iBAAiB,QAAQ,cAAc;QACzD,IAAI,CAAC,WAAW,GAAGA,iBAAiB,QAAQ,iBAAiB;IACjE;IAEA,MAAM,QACFC,MAAyC,EACzB;QAChB,IAAIC;QAEJ,IAAK,IAAIC,UAAU,GAAGA,WAAW,IAAI,CAAC,UAAU,EAAEA,UAC9C,IAAI;YACA,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACF;QACxC,EAAE,OAAOG,OAAO;YACZF,YAAYE;YAIZ,IACI,IAAI,CAAC,cAAc,CAACA,UACpB,IAAI,CAAC,qBAAqB,CAACA,UAC3B,IAAI,CAAC,kBAAkB,CAACA,QAExB,MAAMA;YAIV,IAAID,UAAU,IAAI,CAAC,UAAU,EACzB,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAACA;QAE/C;QAGJ,MAAMD;IACV;IAEQ,eAAeE,KAAY,EAAW;QAC1C,OAAOA,MAAM,OAAO,CAAC,QAAQ,CAAC;IAClC;IAEQ,sBAAsBA,KAAgB,EAAW;QACrD,OAAOA,MAAM,IAAI,EAAE,SAAS;IAChC;IAEQ,mBAAmBA,KAAgB,EAAW;QAClD,OAAOA,MAAM,IAAI,EAAE,SAAS;IAChC;IAEQ,iBAAiBD,OAAe,EAAU;QAE9C,OAAOE,KAAK,GAAG,CAAC,GAAGF,WAAW,IAAI,CAAC,WAAW;IAClD;IAEQ,MAAMG,EAAU,EAAiB;QACrC,OAAO,IAAIC,QAAQC,CAAAA,UAAWC,WAAWD,SAASF;IACtD;AACJ;AAEO,MAAMI,qBAAqBC,cAAc,eAAe,CAAC;IAC5D,WAAWd;IACX,cAAc;QAACe;KAAU;AAC7B"}
|