@webiny/app 6.3.0 → 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.
Files changed (276) hide show
  1. package/App.js +70 -77
  2. package/App.js.map +1 -1
  3. package/AppContainer.js +3 -6
  4. package/AppContainer.js.map +1 -1
  5. package/apollo-client/InMemoryCache.js +11 -13
  6. package/apollo-client/InMemoryCache.js.map +1 -1
  7. package/apollo-client/IntrospectionFragmentMatcher.js +26 -38
  8. package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -1
  9. package/components/Image.js +11 -17
  10. package/components/Image.js.map +1 -1
  11. package/components/index.js +0 -2
  12. package/config/RouterConfig/Route.js +23 -28
  13. package/config/RouterConfig/Route.js.map +1 -1
  14. package/config/RouterConfig.js +11 -10
  15. package/config/RouterConfig.js.map +1 -1
  16. package/config.js +19 -20
  17. package/config.js.map +1 -1
  18. package/contexts/Ui/index.js +26 -28
  19. package/contexts/Ui/index.js.map +1 -1
  20. package/core/Plugin.js +7 -9
  21. package/core/Plugin.js.map +1 -1
  22. package/core/Plugins.js +15 -34
  23. package/core/Plugins.js.map +1 -1
  24. package/core/Provider.js +5 -13
  25. package/core/Provider.js.map +1 -1
  26. package/core/createProvider.js +3 -6
  27. package/core/createProvider.js.map +1 -1
  28. package/core/createProviderPlugin.js +8 -13
  29. package/core/createProviderPlugin.js.map +1 -1
  30. package/errors/AuthenticationErrorEvent.js +8 -5
  31. package/errors/AuthenticationErrorEvent.js.map +1 -1
  32. package/errors/NetworkErrorEvent.js +8 -5
  33. package/errors/NetworkErrorEvent.js.map +1 -1
  34. package/errors/abstractions.js +3 -2
  35. package/errors/abstractions.js.map +1 -1
  36. package/errors/index.js +1 -4
  37. package/exports/admin/env-config.js +0 -2
  38. package/exports/admin/graphql-client.js +0 -2
  39. package/exports/admin/local-storage.js +0 -2
  40. package/exports/admin/router.js +0 -2
  41. package/exports/admin/security.js +0 -2
  42. package/exports/admin.js +0 -2
  43. package/features/envConfig/EnvConfig.js +12 -13
  44. package/features/envConfig/EnvConfig.js.map +1 -1
  45. package/features/envConfig/abstractions.js +2 -1
  46. package/features/envConfig/abstractions.js.map +1 -1
  47. package/features/envConfig/feature.js +9 -8
  48. package/features/envConfig/feature.js.map +1 -1
  49. package/features/envConfig/index.js +0 -2
  50. package/features/eventPublisher/EventPublisher.js +13 -21
  51. package/features/eventPublisher/EventPublisher.js.map +1 -1
  52. package/features/eventPublisher/abstractions.js +7 -9
  53. package/features/eventPublisher/abstractions.js.map +1 -1
  54. package/features/eventPublisher/feature.js +13 -12
  55. package/features/eventPublisher/feature.js.map +1 -1
  56. package/features/eventPublisher/index.js +1 -3
  57. package/features/graphqlClient/AuthenticationErrorPublishing.js +26 -26
  58. package/features/graphqlClient/AuthenticationErrorPublishing.js.map +1 -1
  59. package/features/graphqlClient/BatchingGraphQLClient.js +104 -149
  60. package/features/graphqlClient/BatchingGraphQLClient.js.map +1 -1
  61. package/features/graphqlClient/FetchGraphQLClient.js +41 -48
  62. package/features/graphqlClient/FetchGraphQLClient.js.map +1 -1
  63. package/features/graphqlClient/NetworkErrorPublishing.js +35 -42
  64. package/features/graphqlClient/NetworkErrorPublishing.js.map +1 -1
  65. package/features/graphqlClient/RequestValue.js +42 -41
  66. package/features/graphqlClient/RequestValue.js.map +1 -1
  67. package/features/graphqlClient/RetryGraphQLClient.js +36 -45
  68. package/features/graphqlClient/RetryGraphQLClient.js.map +1 -1
  69. package/features/graphqlClient/__tests__/GraphQLClient.test.js +383 -356
  70. package/features/graphqlClient/__tests__/GraphQLClient.test.js.map +1 -1
  71. package/features/graphqlClient/abstractions.js +2 -1
  72. package/features/graphqlClient/abstractions.js.map +1 -1
  73. package/features/graphqlClient/feature.js +14 -20
  74. package/features/graphqlClient/feature.js.map +1 -1
  75. package/features/graphqlClient/index.js +0 -2
  76. package/features/graphqlClient/types.js +0 -3
  77. package/features/localStorage/BrowserLocalStorageGateway.js +56 -63
  78. package/features/localStorage/BrowserLocalStorageGateway.js.map +1 -1
  79. package/features/localStorage/LocalStorage.js +27 -24
  80. package/features/localStorage/LocalStorage.js.map +1 -1
  81. package/features/localStorage/LocalStorageRepository.js +75 -88
  82. package/features/localStorage/LocalStorageRepository.js.map +1 -1
  83. package/features/localStorage/abstractions.js +5 -16
  84. package/features/localStorage/abstractions.js.map +1 -1
  85. package/features/localStorage/feature.js +17 -28
  86. package/features/localStorage/feature.js.map +1 -1
  87. package/features/localStorage/index.js +1 -3
  88. package/features/mainGraphQLClient/MainGraphQLClient.js +18 -14
  89. package/features/mainGraphQLClient/MainGraphQLClient.js.map +1 -1
  90. package/features/mainGraphQLClient/abstractions.js +2 -1
  91. package/features/mainGraphQLClient/abstractions.js.map +1 -1
  92. package/features/mainGraphQLClient/feature.js +11 -10
  93. package/features/mainGraphQLClient/feature.js.map +1 -1
  94. package/features/mainGraphQLClient/index.js +0 -2
  95. package/features/router/HistoryRouterGateway.js +75 -105
  96. package/features/router/HistoryRouterGateway.js.map +1 -1
  97. package/features/router/HistoryRouterGateway.test.js +184 -193
  98. package/features/router/HistoryRouterGateway.test.js.map +1 -1
  99. package/features/router/Route.js +38 -54
  100. package/features/router/Route.js.map +1 -1
  101. package/features/router/RouteUrl.js +84 -217
  102. package/features/router/RouteUrl.js.map +1 -1
  103. package/features/router/Router.js +67 -124
  104. package/features/router/Router.js.map +1 -1
  105. package/features/router/RouterPresenter.js +44 -49
  106. package/features/router/RouterPresenter.js.map +1 -1
  107. package/features/router/RouterRepository.js +103 -111
  108. package/features/router/RouterRepository.js.map +1 -1
  109. package/features/router/RouterRepository.test.js +119 -150
  110. package/features/router/RouterRepository.test.js.map +1 -1
  111. package/features/router/abstractions.js +4 -14
  112. package/features/router/abstractions.js.map +1 -1
  113. package/features/router/feature.js +13 -12
  114. package/features/router/feature.js.map +1 -1
  115. package/features/router/index.js +1 -3
  116. package/helpers/InterfaceGenerator/date.js +0 -3
  117. package/helpers/InterfaceGenerator/id.js +0 -3
  118. package/helpers/InterfaceGenerator/identity.js +0 -3
  119. package/helpers/InterfaceGenerator/index.js +0 -3
  120. package/helpers/InterfaceGenerator/numeric.js +0 -3
  121. package/helpers/InterfaceGenerator/truthful.js +0 -3
  122. package/hooks/useAutocomplete/index.js +0 -2
  123. package/hooks/useAutocomplete/useAutocomplete.js +12 -15
  124. package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
  125. package/hooks/useDataList/functions/getData.js +2 -1
  126. package/hooks/useDataList/functions/getData.js.map +1 -1
  127. package/hooks/useDataList/functions/getError.js +2 -1
  128. package/hooks/useDataList/functions/getError.js.map +1 -1
  129. package/hooks/useDataList/functions/getMeta.js +2 -1
  130. package/hooks/useDataList/functions/getMeta.js.map +1 -1
  131. package/hooks/useDataList/functions/index.js +0 -2
  132. package/hooks/useDataList/functions/searchDataByKey.js +9 -14
  133. package/hooks/useDataList/functions/searchDataByKey.js.map +1 -1
  134. package/hooks/useDataList/index.js +0 -2
  135. package/hooks/useDataList/useDataList.js +131 -152
  136. package/hooks/useDataList/useDataList.js.map +1 -1
  137. package/hooks/useDataList/utils/index.js +0 -2
  138. package/hooks/useDataList/utils/prepareLoadListParams.js +25 -34
  139. package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
  140. package/hooks/useHandler.js +12 -16
  141. package/hooks/useHandler.js.map +1 -1
  142. package/hooks/useHandlers.js +18 -20
  143. package/hooks/useHandlers.js.map +1 -1
  144. package/hooks/useRegisterLegacyPlugin.js +7 -6
  145. package/hooks/useRegisterLegacyPlugin.js.map +1 -1
  146. package/hooks/useUi.js +2 -3
  147. package/hooks/useUi.js.map +1 -1
  148. package/i18n/i18n.js +8 -4
  149. package/i18n/i18n.js.map +1 -1
  150. package/i18n/index.js +0 -2
  151. package/index.js +6 -11
  152. package/package.json +13 -13
  153. package/plugins/AddQuerySelectionPlugin.js +36 -61
  154. package/plugins/AddQuerySelectionPlugin.js.map +1 -1
  155. package/plugins/ApolloCacheObjectIdPlugin.js +12 -11
  156. package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -1
  157. package/plugins/ApolloDynamicLink.js +20 -22
  158. package/plugins/ApolloDynamicLink.js.map +1 -1
  159. package/plugins/ApolloLinkPlugin.js +16 -15
  160. package/plugins/ApolloLinkPlugin.js.map +1 -1
  161. package/plugins/ConsoleLinkPlugin.js +19 -21
  162. package/plugins/ConsoleLinkPlugin.js.map +1 -1
  163. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +39 -45
  164. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
  165. package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js +18 -22
  166. package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js.map +1 -1
  167. package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js +21 -29
  168. package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js.map +1 -1
  169. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +6 -15
  170. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
  171. package/plugins/NetworkErrorLinkPlugin/Typography.js +9 -14
  172. package/plugins/NetworkErrorLinkPlugin/Typography.js.map +1 -1
  173. package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js +19 -0
  174. package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js.map +1 -0
  175. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +11 -18
  176. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
  177. package/plugins/NetworkErrorLinkPlugin.js +41 -58
  178. package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
  179. package/plugins/OmitTypenameLinkPlugin.js +9 -14
  180. package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
  181. package/plugins/TenantHeaderLinkPlugin.js +23 -32
  182. package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
  183. package/plugins/components/Image.js +8 -15
  184. package/plugins/components/Image.js.map +1 -1
  185. package/plugins/image.js +94 -133
  186. package/plugins/image.js.map +1 -1
  187. package/plugins/index.js +35 -59
  188. package/plugins/index.js.map +1 -1
  189. package/presentation/envConfig/useEnvConfig.js +4 -8
  190. package/presentation/envConfig/useEnvConfig.js.map +1 -1
  191. package/presentation/localStorage/index.js +0 -2
  192. package/presentation/localStorage/useLocalStorage.js +10 -16
  193. package/presentation/localStorage/useLocalStorage.js.map +1 -1
  194. package/presentation/localStorage/useLocalStorageValue.js +15 -13
  195. package/presentation/localStorage/useLocalStorageValue.js.map +1 -1
  196. package/presentation/localStorage/useLocalStorageValues.js +23 -30
  197. package/presentation/localStorage/useLocalStorageValues.js.map +1 -1
  198. package/presentation/router/RouteElementRegistry.js +22 -25
  199. package/presentation/router/RouteElementRegistry.js.map +1 -1
  200. package/presentation/router/abstractions.js +2 -1
  201. package/presentation/router/abstractions.js.map +1 -1
  202. package/presentation/router/components/Redirect.js +8 -10
  203. package/presentation/router/components/Redirect.js.map +1 -1
  204. package/presentation/router/components/RouteContent.js +14 -17
  205. package/presentation/router/components/RouteContent.js.map +1 -1
  206. package/presentation/router/components/RouteLink.js +11 -16
  207. package/presentation/router/components/RouteLink.js.map +1 -1
  208. package/presentation/router/components/SimpleLink.js +18 -24
  209. package/presentation/router/components/SimpleLink.js.map +1 -1
  210. package/presentation/router/hooks/useRoute.js +15 -23
  211. package/presentation/router/hooks/useRoute.js.map +1 -1
  212. package/presentation/router/hooks/useRouter.js +22 -23
  213. package/presentation/router/hooks/useRouter.js.map +1 -1
  214. package/presentation/router/index.js +0 -2
  215. package/presentation/router/types.js +0 -3
  216. package/react-butterfiles/Files.js +148 -217
  217. package/react-butterfiles/Files.js.map +1 -1
  218. package/react-butterfiles/index.js +2 -1
  219. package/react-butterfiles/index.js.map +1 -1
  220. package/react-butterfiles/utils/generateId.js +2 -3
  221. package/react-butterfiles/utils/generateId.js.map +1 -1
  222. package/react-butterfiles/utils/readFileContent.js +9 -13
  223. package/react-butterfiles/utils/readFileContent.js.map +1 -1
  224. package/renderApp.js +7 -6
  225. package/renderApp.js.map +1 -1
  226. package/router.js +0 -3
  227. package/rslib-runtime.js +14 -0
  228. package/rslib-runtime.js.map +1 -0
  229. package/shared/di/DiContainerProvider.js +8 -12
  230. package/shared/di/DiContainerProvider.js.map +1 -1
  231. package/shared/di/createFeature.js +7 -8
  232. package/shared/di/createFeature.js.map +1 -1
  233. package/shared/di/useFeature.js +7 -3
  234. package/shared/di/useFeature.js.map +1 -1
  235. package/static/svg/close_24px.33adaadc.svg +1 -0
  236. package/types.js +0 -3
  237. package/utils/createGenericContext.js +17 -21
  238. package/utils/createGenericContext.js.map +1 -1
  239. package/utils/createHashing.js +13 -16
  240. package/utils/createHashing.js.map +1 -1
  241. package/utils/index.js +0 -2
  242. package/utils/legacyPluginToReactComponent.js +11 -10
  243. package/utils/legacyPluginToReactComponent.js.map +1 -1
  244. package/components/index.js.map +0 -1
  245. package/errors/index.js.map +0 -1
  246. package/exports/admin/env-config.js.map +0 -1
  247. package/exports/admin/graphql-client.js.map +0 -1
  248. package/exports/admin/local-storage.js.map +0 -1
  249. package/exports/admin/router.js.map +0 -1
  250. package/exports/admin/security.js.map +0 -1
  251. package/exports/admin.js.map +0 -1
  252. package/features/envConfig/index.js.map +0 -1
  253. package/features/eventPublisher/index.js.map +0 -1
  254. package/features/graphqlClient/index.js.map +0 -1
  255. package/features/graphqlClient/types.js.map +0 -1
  256. package/features/localStorage/index.js.map +0 -1
  257. package/features/mainGraphQLClient/index.js.map +0 -1
  258. package/features/router/index.js.map +0 -1
  259. package/helpers/InterfaceGenerator/date.js.map +0 -1
  260. package/helpers/InterfaceGenerator/id.js.map +0 -1
  261. package/helpers/InterfaceGenerator/identity.js.map +0 -1
  262. package/helpers/InterfaceGenerator/index.js.map +0 -1
  263. package/helpers/InterfaceGenerator/numeric.js.map +0 -1
  264. package/helpers/InterfaceGenerator/truthful.js.map +0 -1
  265. package/hooks/useAutocomplete/index.js.map +0 -1
  266. package/hooks/useDataList/functions/index.js.map +0 -1
  267. package/hooks/useDataList/index.js.map +0 -1
  268. package/hooks/useDataList/utils/index.js.map +0 -1
  269. package/i18n/index.js.map +0 -1
  270. package/index.js.map +0 -1
  271. package/presentation/localStorage/index.js.map +0 -1
  272. package/presentation/router/index.js.map +0 -1
  273. package/presentation/router/types.js.map +0 -1
  274. package/router.js.map +0 -1
  275. package/types.js.map +0 -1
  276. 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
- constructor(eventPublisher, decoratee) {
7
- this.eventPublisher = eventPublisher;
8
- this.decoratee = decoratee;
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
- isNetworkError(error) {
33
- // Network errors typically have these patterns in the message
34
- 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");
35
- }
36
- determineErrorType(error) {
37
- const message = error.message.toLowerCase();
38
- if (message.includes("timeout")) {
39
- return "timeout";
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
- if (message.includes("fetch") || message.includes("failed to fetch")) {
42
- return "fetch";
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
- if (message.includes("network")) {
45
- return "network";
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
- export const NetworkErrorPublishing = GraphQLClient.createDecorator({
51
- decorator: NetworkErrorPublishingDecorator,
52
- dependencies: [EventPublisher]
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,"names":["GraphQLClient","EventPublisher","NetworkErrorEvent","RequestValue","NetworkErrorPublishingDecorator","constructor","eventPublisher","decoratee","execute","params","error","isNetworkError","request","from","event","message","code","undefined","operationName","query","queryAsString","variables","errorType","determineErrorType","publish","includes","toLowerCase","NetworkErrorPublishing","createDecorator","decorator","dependencies"],"sources":["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"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,cAAc;AACvB,SAASC,iBAAiB;AAC1B,SAASC,YAAY;AAErB,MAAMC,+BAA+B,CAAoC;EACrEC,WAAWA,CACCC,cAAwC,EACxCC,SAAkC,EAC5C;IAAA,KAFUD,cAAwC,GAAxCA,cAAwC;IAAA,KACxCC,SAAkC,GAAlCA,SAAkC;EAC3C;EAEH,MAAMC,OAAOA,CACTC,MAAyC,EACzB;IAChB,IAAI;MACA,OAAO,MAAM,IAAI,CAACF,SAAS,CAACC,OAAO,CAACC,MAAM,CAAC;IAC/C,CAAC,CAAC,OAAOC,KAAK,EAAE;MACZ;MACA,IAAI,IAAI,CAACC,cAAc,CAACD,KAAc,CAAC,EAAE;QACrC,MAAME,OAAO,GAAGT,YAAY,CAACU,IAAI,CAACJ,MAAM,CAAC;QAEzC,MAAMK,KAAK,GAAG,IAAIZ,iBAAiB,CAAC;UAChCa,OAAO,EAAGL,KAAK,CAAWK,OAAO;UACjCC,IAAI,EAAEN,KAAK,CAACM,IAAI,IAAIC,SAAS;UAC7BC,aAAa,EAAEN,OAAO,CAACM,aAAa;UACpCC,KAAK,EAAEP,OAAO,CAACQ,aAAa;UAC5BC,SAAS,EAAET,OAAO,CAACS,SAAS;UAC5BC,SAAS,EAAE,IAAI,CAACC,kBAAkB,CAACb,KAAc;QACrD,CAAC,CAAC;QAEF,MAAM,IAAI,CAACJ,cAAc,CAACkB,OAAO,CAACV,KAAK,CAAC;MAC5C;;MAEA;MACA,MAAMJ,KAAK;IACf;EACJ;EAEQC,cAAcA,CAACD,KAAY,EAAW;IAC1C;IACA,OACIA,KAAK,CAACK,OAAO,CAACU,QAAQ,CAAC,oBAAoB,CAAC,IAC5Cf,KAAK,CAACK,OAAO,CAACU,QAAQ,CAAC,eAAe,CAAC,IACvCf,KAAK,CAACK,OAAO,CAACU,QAAQ,CAAC,iBAAiB,CAAC,IACzCf,KAAK,CAACK,OAAO,CAACU,QAAQ,CAAC,iBAAiB,CAAC,IACzCf,KAAK,CAACK,OAAO,CAACU,QAAQ,CAAC,kBAAkB,CAAC;EAElD;EAEQF,kBAAkBA,CAACb,KAAY,EAA+C;IAClF,MAAMK,OAAO,GAAGL,KAAK,CAACK,OAAO,CAACW,WAAW,CAAC,CAAC;IAE3C,IAAIX,OAAO,CAACU,QAAQ,CAAC,SAAS,CAAC,EAAE;MAC7B,OAAO,SAAS;IACpB;IAEA,IAAIV,OAAO,CAACU,QAAQ,CAAC,OAAO,CAAC,IAAIV,OAAO,CAACU,QAAQ,CAAC,iBAAiB,CAAC,EAAE;MAClE,OAAO,OAAO;IAClB;IAEA,IAAIV,OAAO,CAACU,QAAQ,CAAC,SAAS,CAAC,EAAE;MAC7B,OAAO,SAAS;IACpB;IAEA,OAAO,SAAS;EACpB;AACJ;AAEA,OAAO,MAAME,sBAAsB,GAAG3B,aAAa,CAAC4B,eAAe,CAAC;EAChEC,SAAS,EAAEzB,+BAA+B;EAC1C0B,YAAY,EAAE,CAAC7B,cAAc;AACjC,CAAC,CAAC","ignoreList":[]}
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
- export 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 (typeof value.query === "string") {
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, undefined);
41
- return operationAST?.name?.value;
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,"names":["getOperationAST","parse","print","RequestValue","from","value","constructor","_request","query","_queryAsString","_queryAsDocumentNode","_operationName","getOperationName","request","variables","queryAsString","queryAsDocumentNode","headers","endpoint","operationName","operationAST","undefined","name"],"sources":["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"],"mappings":"AAAA,SAASA,eAAe,EAAEC,KAAK,EAAEC,KAAK,QAA2B,SAAS;AAG1E,OAAO,MAAMC,YAAY,CAAC;EAMtB,OAAOC,IAAIA,CAACC,KAA4B,EAAE;IACtC,OAAO,IAAIF,YAAY,CAACE,KAAK,CAAC;EAClC;EAEQC,WAAWA,CAAUD,KAA4B,EAAE;IAAA,KAA9BA,KAA4B,GAA5BA,KAA4B;IACrD,IAAI,CAACE,QAAQ,GAAGF,KAAK;IACrB,IAAI,OAAOA,KAAK,CAACG,KAAK,KAAK,QAAQ,EAAE;MACjC,IAAI,CAACC,cAAc,GAAGJ,KAAK,CAACG,KAAK;MACjC,IAAI,CAACE,oBAAoB,GAAGT,KAAK,CAACI,KAAK,CAACG,KAAK,CAAC;IAClD,CAAC,MAAM;MACH,IAAI,CAACC,cAAc,GAAGP,KAAK,CAACG,KAAK,CAACG,KAAK,CAAC;MACxC,IAAI,CAACE,oBAAoB,GAAGL,KAAK,CAACG,KAAK;IAC3C;IAEA,IAAI,CAACG,cAAc,GAAG,IAAI,CAACC,gBAAgB,CAAC,IAAI,CAACF,oBAAoB,CAAC;EAC1E;EAEA,IAAIG,OAAOA,CAAA,EAAG;IACV,OAAO,IAAI,CAACN,QAAQ;EACxB;EAEA,IAAIO,SAASA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACP,QAAQ,CAACO,SAAS;EAClC;EAEA,IAAIC,aAAaA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACN,cAAc;EAC9B;EAEA,IAAIO,mBAAmBA,CAAA,EAAG;IACtB,OAAO,IAAI,CAACN,oBAAoB;EACpC;EAEA,IAAIO,OAAOA,CAAA,EAAG;IACV,OAAO,IAAI,CAACV,QAAQ,CAACU,OAAO;EAChC;EAEA,IAAIC,QAAQA,CAAA,EAAG;IACX,OAAO,IAAI,CAACX,QAAQ,CAACW,QAAQ;EACjC;EAEA,IAAIC,aAAaA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACR,cAAc;EAC9B;EAEQC,gBAAgBA,CAACJ,KAAmB,EAAsB;IAC9D,MAAMY,YAAY,GAAGpB,eAAe,CAACQ,KAAK,EAAEa,SAAS,CAAC;IACtD,OAAOD,YAAY,EAAEE,IAAI,EAAEjB,KAAK;EACpC;AACJ","ignoreList":[]}
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
- 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++) {
13
- try {
14
- return await this.decoratee.execute(params);
15
- } catch (error) {
16
- lastError = error;
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
- export const RetryGraphQLClient = GraphQLClient.createDecorator({
50
- decorator: RetryGraphQLClientImpl,
51
- dependencies: [EnvConfig]
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,"names":["GraphQLClient","EnvConfig","RetryGraphQLClientImpl","constructor","envConfig","decoratee","gqlClientConfig","get","maxRetries","retries","baseDelayMs","delayInMillis","execute","params","lastError","attempt","error","isGraphQLError","isAuthenticationError","isMaintenanceError","delay","calculateBackoff","message","includes","code","Math","pow","ms","Promise","resolve","setTimeout","RetryGraphQLClient","createDecorator","decorator","dependencies"],"sources":["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"],"mappings":"AACA,SAASA,aAAa;AACtB,SAASC,SAAS;AAElB,MAAMC,sBAAsB,CAAoC;EAI5DC,WAAWA,CACPC,SAA8B,EACtBC,SAAkC,EAC5C;IAAA,KADUA,SAAkC,GAAlCA,SAAkC;IAE1C,MAAMC,eAAe,GAAGF,SAAS,CAACG,GAAG,CAAC,eAAe,CAAC;IAEtD,IAAI,CAACC,UAAU,GAAGF,eAAe,EAAEG,OAAO,CAACD,UAAU,IAAI,CAAC;IAC1D,IAAI,CAACE,WAAW,GAAGJ,eAAe,EAAEG,OAAO,CAACE,aAAa,IAAI,GAAG;EACpE;EAEA,MAAMC,OAAOA,CACTC,MAAyC,EACzB;IAChB,IAAIC,SAA4B;IAEhC,KAAK,IAAIC,OAAO,GAAG,CAAC,EAAEA,OAAO,IAAI,IAAI,CAACP,UAAU,EAAEO,OAAO,EAAE,EAAE;MACzD,IAAI;QACA,OAAO,MAAM,IAAI,CAACV,SAAS,CAACO,OAAO,CAACC,MAAM,CAAC;MAC/C,CAAC,CAAC,OAAOG,KAAK,EAAE;QACZF,SAAS,GAAGE,KAAc;;QAE1B;QACA;QACA,IACI,IAAI,CAACC,cAAc,CAACD,KAAc,CAAC,IACnC,IAAI,CAACE,qBAAqB,CAACF,KAAkB,CAAC,IAC9C,IAAI,CAACG,kBAAkB,CAACH,KAAkB,CAAC,EAC7C;UACE,MAAMA,KAAK;QACf;;QAEA;QACA,IAAID,OAAO,GAAG,IAAI,CAACP,UAAU,EAAE;UAC3B,MAAM,IAAI,CAACY,KAAK,CAAC,IAAI,CAACC,gBAAgB,CAACN,OAAO,CAAC,CAAC;QACpD;MACJ;IACJ;IAEA,MAAMD,SAAS;EACnB;EAEQG,cAAcA,CAACD,KAAY,EAAW;IAC1C,OAAOA,KAAK,CAACM,OAAO,CAACC,QAAQ,CAAC,SAAS,CAAC;EAC5C;EAEQL,qBAAqBA,CAACF,KAAgB,EAAW;IACrD,OAAOA,KAAK,CAACQ,IAAI,EAAED,QAAQ,CAAC,iBAAiB,CAAC;EAClD;EAEQJ,kBAAkBA,CAACH,KAAgB,EAAW;IAClD,OAAOA,KAAK,CAACQ,IAAI,EAAED,QAAQ,CAAC,UAAU,CAAC;EAC3C;EAEQF,gBAAgBA,CAACN,OAAe,EAAU;IAC9C;IACA,OAAOU,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEX,OAAO,CAAC,GAAG,IAAI,CAACL,WAAW;EAClD;EAEQU,KAAKA,CAACO,EAAU,EAAiB;IACrC,OAAO,IAAIC,OAAO,CAACC,OAAO,IAAIC,UAAU,CAACD,OAAO,EAAEF,EAAE,CAAC,CAAC;EAC1D;AACJ;AAEA,OAAO,MAAMI,kBAAkB,GAAG/B,aAAa,CAACgC,eAAe,CAAC;EAC5DC,SAAS,EAAE/B,sBAAsB;EACjCgC,YAAY,EAAE,CAACjC,SAAS;AAC5B,CAAC,CAAC","ignoreList":[]}
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"}