@webiny/app 6.0.0-beta.0 → 6.0.0-rc.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 (435) hide show
  1. package/App.d.ts +6 -13
  2. package/App.js +70 -83
  3. package/App.js.map +1 -1
  4. package/AppContainer.d.ts +23 -0
  5. package/AppContainer.js +9 -0
  6. package/AppContainer.js.map +1 -0
  7. package/README.md +7 -15
  8. package/apollo-client/InMemoryCache.d.ts +3 -2
  9. package/apollo-client/InMemoryCache.js +16 -48
  10. package/apollo-client/InMemoryCache.js.map +1 -1
  11. package/apollo-client/IntrospectionFragmentMatcher.d.ts +2 -2
  12. package/apollo-client/IntrospectionFragmentMatcher.js +33 -50
  13. package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -1
  14. package/components/Image.d.ts +1 -2
  15. package/components/Image.js +11 -19
  16. package/components/Image.js.map +1 -1
  17. package/components/index.d.ts +1 -2
  18. package/components/index.js +1 -19
  19. package/components/index.js.map +1 -1
  20. package/config/RouterConfig/Route.d.ts +29 -0
  21. package/config/RouterConfig/Route.js +33 -0
  22. package/config/RouterConfig/Route.js.map +1 -0
  23. package/config/RouterConfig.d.ts +31 -0
  24. package/config/RouterConfig.js +18 -0
  25. package/config/RouterConfig.js.map +1 -0
  26. package/config.d.ts +1 -1
  27. package/config.js +7 -13
  28. package/config.js.map +1 -1
  29. package/contexts/Ui/index.d.ts +2 -2
  30. package/contexts/Ui/index.js +28 -52
  31. package/contexts/Ui/index.js.map +1 -1
  32. package/core/DebounceRender.js +13 -24
  33. package/core/DebounceRender.js.map +1 -1
  34. package/core/Plugin.d.ts +1 -1
  35. package/core/Plugin.js +11 -19
  36. package/core/Plugin.js.map +1 -1
  37. package/core/Plugins.d.ts +1 -1
  38. package/core/Plugins.js +20 -25
  39. package/core/Plugins.js.map +1 -1
  40. package/core/Provider.d.ts +1 -1
  41. package/core/Provider.js +9 -13
  42. package/core/Provider.js.map +1 -1
  43. package/core/Routes.d.ts +2 -1
  44. package/core/Routes.js +13 -23
  45. package/core/Routes.js.map +1 -1
  46. package/core/createProvider.d.ts +7 -3
  47. package/core/createProvider.js +3 -9
  48. package/core/createProvider.js.map +1 -1
  49. package/core/createProviderPlugin.d.ts +1 -1
  50. package/core/createProviderPlugin.js +4 -10
  51. package/core/createProviderPlugin.js.map +1 -1
  52. package/errors/AuthenticationErrorEvent.d.ts +9 -0
  53. package/errors/AuthenticationErrorEvent.js +10 -0
  54. package/errors/AuthenticationErrorEvent.js.map +1 -0
  55. package/errors/NetworkErrorEvent.d.ts +15 -0
  56. package/errors/NetworkErrorEvent.js +10 -0
  57. package/errors/NetworkErrorEvent.js.map +1 -0
  58. package/errors/abstractions.d.ts +12 -0
  59. package/errors/abstractions.js +5 -0
  60. package/errors/abstractions.js.map +1 -0
  61. package/errors/index.d.ts +6 -0
  62. package/errors/index.js +6 -0
  63. package/errors/index.js.map +1 -0
  64. package/exports/admin/envConfig.d.ts +1 -0
  65. package/exports/admin/envConfig.js +3 -0
  66. package/exports/admin/envConfig.js.map +1 -0
  67. package/exports/admin/graphqlClient.d.ts +1 -0
  68. package/exports/admin/graphqlClient.js +3 -0
  69. package/exports/admin/graphqlClient.js.map +1 -0
  70. package/exports/admin/localStorage.d.ts +2 -0
  71. package/exports/admin/localStorage.js +4 -0
  72. package/exports/admin/localStorage.js.map +1 -0
  73. package/exports/admin/router.d.ts +4 -0
  74. package/exports/admin/router.js +6 -0
  75. package/exports/admin/router.js.map +1 -0
  76. package/exports/admin/security.d.ts +1 -0
  77. package/exports/admin/security.js +3 -0
  78. package/exports/admin/security.js.map +1 -0
  79. package/exports/admin.d.ts +6 -0
  80. package/exports/admin.js +8 -0
  81. package/exports/admin.js.map +1 -0
  82. package/features/envConfig/EnvConfig.d.ts +6 -0
  83. package/features/envConfig/EnvConfig.js +14 -0
  84. package/features/envConfig/EnvConfig.js.map +1 -0
  85. package/features/envConfig/abstractions.d.ts +27 -0
  86. package/features/envConfig/abstractions.js +4 -0
  87. package/features/envConfig/abstractions.js.map +1 -0
  88. package/features/envConfig/feature.d.ts +17 -0
  89. package/features/envConfig/feature.js +14 -0
  90. package/features/envConfig/feature.js.map +1 -0
  91. package/features/envConfig/index.d.ts +1 -0
  92. package/features/envConfig/index.js +3 -0
  93. package/features/envConfig/index.js.map +1 -0
  94. package/features/eventPublisher/EventPublisher.d.ts +8 -0
  95. package/features/eventPublisher/EventPublisher.js +27 -0
  96. package/features/eventPublisher/EventPublisher.js.map +1 -0
  97. package/features/eventPublisher/abstractions.d.ts +18 -0
  98. package/features/eventPublisher/abstractions.js +14 -0
  99. package/features/eventPublisher/abstractions.js.map +1 -0
  100. package/features/eventPublisher/feature.d.ts +1 -0
  101. package/features/eventPublisher/feature.js +11 -0
  102. package/features/eventPublisher/feature.js.map +1 -0
  103. package/features/eventPublisher/index.d.ts +3 -0
  104. package/features/eventPublisher/index.js +4 -0
  105. package/features/eventPublisher/index.js.map +1 -0
  106. package/features/graphqlClient/AuthenticationErrorPublishing.d.ts +13 -0
  107. package/features/graphqlClient/AuthenticationErrorPublishing.js +35 -0
  108. package/features/graphqlClient/AuthenticationErrorPublishing.js.map +1 -0
  109. package/features/graphqlClient/BatchingGraphQLClient.d.ts +18 -0
  110. package/features/graphqlClient/BatchingGraphQLClient.js +164 -0
  111. package/features/graphqlClient/BatchingGraphQLClient.js.map +1 -0
  112. package/features/graphqlClient/FetchGraphQLClient.d.ts +10 -0
  113. package/features/graphqlClient/FetchGraphQLClient.js +62 -0
  114. package/features/graphqlClient/FetchGraphQLClient.js.map +1 -0
  115. package/features/graphqlClient/NetworkErrorPublishing.d.ts +14 -0
  116. package/features/graphqlClient/NetworkErrorPublishing.js +55 -0
  117. package/features/graphqlClient/NetworkErrorPublishing.js.map +1 -0
  118. package/features/graphqlClient/RequestValue.d.ts +20 -0
  119. package/features/graphqlClient/RequestValue.js +42 -0
  120. package/features/graphqlClient/RequestValue.js.map +1 -0
  121. package/features/graphqlClient/RetryGraphQLClient.d.ts +18 -0
  122. package/features/graphqlClient/RetryGraphQLClient.js +54 -0
  123. package/features/graphqlClient/RetryGraphQLClient.js.map +1 -0
  124. package/features/graphqlClient/__tests__/GraphQLClient.test.d.ts +1 -0
  125. package/features/graphqlClient/__tests__/GraphQLClient.test.js +350 -0
  126. package/features/graphqlClient/__tests__/GraphQLClient.test.js.map +1 -0
  127. package/features/graphqlClient/abstractions.d.ts +17 -0
  128. package/features/graphqlClient/abstractions.js +4 -0
  129. package/features/graphqlClient/abstractions.js.map +1 -0
  130. package/features/graphqlClient/feature.d.ts +6 -0
  131. package/features/graphqlClient/feature.js +31 -0
  132. package/features/graphqlClient/feature.js.map +1 -0
  133. package/features/graphqlClient/index.d.ts +1 -0
  134. package/features/graphqlClient/index.js +3 -0
  135. package/features/graphqlClient/index.js.map +1 -0
  136. package/features/graphqlClient/types.d.ts +5 -0
  137. package/features/graphqlClient/types.js +3 -0
  138. package/features/graphqlClient/types.js.map +1 -0
  139. package/features/localStorage/BrowserLocalStorageGateway.d.ts +9 -0
  140. package/features/localStorage/BrowserLocalStorageGateway.js +68 -0
  141. package/features/localStorage/BrowserLocalStorageGateway.js.map +1 -0
  142. package/features/localStorage/LocalStorage.d.ts +12 -0
  143. package/features/localStorage/LocalStorage.js +31 -0
  144. package/features/localStorage/LocalStorage.js.map +1 -0
  145. package/features/localStorage/LocalStorageRepository.d.ts +20 -0
  146. package/features/localStorage/LocalStorageRepository.js +95 -0
  147. package/features/localStorage/LocalStorageRepository.js.map +1 -0
  148. package/features/localStorage/abstractions.d.ts +48 -0
  149. package/features/localStorage/abstractions.js +19 -0
  150. package/features/localStorage/abstractions.js.map +1 -0
  151. package/features/localStorage/feature.d.ts +12 -0
  152. package/features/localStorage/feature.js +34 -0
  153. package/features/localStorage/feature.js.map +1 -0
  154. package/features/localStorage/index.d.ts +1 -0
  155. package/features/localStorage/index.js +3 -0
  156. package/features/localStorage/index.js.map +1 -0
  157. package/features/router/HistoryRouterGateway.d.ts +18 -0
  158. package/features/router/HistoryRouterGateway.js +82 -0
  159. package/features/router/HistoryRouterGateway.js.map +1 -0
  160. package/features/router/HistoryRouterGateway.test.d.ts +1 -0
  161. package/features/router/HistoryRouterGateway.test.js +204 -0
  162. package/features/router/HistoryRouterGateway.test.js.map +1 -0
  163. package/features/router/Route.d.ts +19 -0
  164. package/features/router/Route.js +59 -0
  165. package/features/router/Route.js.map +1 -0
  166. package/features/router/RouteUrl.d.ts +85 -0
  167. package/features/router/RouteUrl.js +232 -0
  168. package/features/router/RouteUrl.js.map +1 -0
  169. package/features/router/Router.d.ts +45 -0
  170. package/features/router/Router.js +129 -0
  171. package/features/router/Router.js.map +1 -0
  172. package/features/router/RouterPresenter.d.ts +17 -0
  173. package/features/router/RouterPresenter.js +45 -0
  174. package/features/router/RouterPresenter.js.map +1 -0
  175. package/features/router/RouterRepository.d.ts +21 -0
  176. package/features/router/RouterRepository.js +71 -0
  177. package/features/router/RouterRepository.js.map +1 -0
  178. package/features/router/RouterRepository.test.d.ts +1 -0
  179. package/features/router/RouterRepository.test.js +154 -0
  180. package/features/router/RouterRepository.test.js.map +1 -0
  181. package/features/router/abstractions.d.ts +68 -0
  182. package/features/router/abstractions.js +15 -0
  183. package/features/router/abstractions.js.map +1 -0
  184. package/features/router/feature.d.ts +4 -0
  185. package/features/router/feature.js +18 -0
  186. package/features/router/feature.js.map +1 -0
  187. package/features/router/index.d.ts +1 -0
  188. package/features/router/index.js +3 -0
  189. package/features/router/index.js.map +1 -0
  190. package/helpers/InterfaceGenerator/date.d.ts +15 -0
  191. package/helpers/InterfaceGenerator/date.js +3 -0
  192. package/helpers/InterfaceGenerator/date.js.map +1 -0
  193. package/helpers/InterfaceGenerator/id.d.ts +23 -0
  194. package/helpers/InterfaceGenerator/id.js +3 -0
  195. package/helpers/InterfaceGenerator/id.js.map +1 -0
  196. package/helpers/InterfaceGenerator/identity.d.ts +10 -0
  197. package/helpers/InterfaceGenerator/identity.js +3 -0
  198. package/helpers/InterfaceGenerator/identity.js.map +1 -0
  199. package/helpers/InterfaceGenerator/index.d.ts +5 -0
  200. package/helpers/InterfaceGenerator/index.js +3 -0
  201. package/helpers/InterfaceGenerator/index.js.map +1 -0
  202. package/helpers/InterfaceGenerator/numeric.d.ts +12 -0
  203. package/helpers/InterfaceGenerator/numeric.js +3 -0
  204. package/helpers/InterfaceGenerator/numeric.js.map +1 -0
  205. package/helpers/InterfaceGenerator/truthful.d.ts +7 -0
  206. package/helpers/InterfaceGenerator/truthful.js +3 -0
  207. package/helpers/InterfaceGenerator/truthful.js.map +1 -0
  208. package/hooks/useAutocomplete/index.d.ts +1 -1
  209. package/hooks/useAutocomplete/index.js +1 -12
  210. package/hooks/useAutocomplete/index.js.map +1 -1
  211. package/hooks/useAutocomplete/useAutocomplete.d.ts +1 -1
  212. package/hooks/useAutocomplete/useAutocomplete.js +6 -16
  213. package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
  214. package/hooks/useDataList/functions/getData.js +2 -11
  215. package/hooks/useDataList/functions/getData.js.map +1 -1
  216. package/hooks/useDataList/functions/getError.js +2 -11
  217. package/hooks/useDataList/functions/getError.js.map +1 -1
  218. package/hooks/useDataList/functions/getMeta.js +2 -11
  219. package/hooks/useDataList/functions/getMeta.js.map +1 -1
  220. package/hooks/useDataList/functions/index.d.ts +3 -3
  221. package/hooks/useDataList/functions/index.js +3 -27
  222. package/hooks/useDataList/functions/index.js.map +1 -1
  223. package/hooks/useDataList/functions/searchDataByKey.js +4 -10
  224. package/hooks/useDataList/functions/searchDataByKey.js.map +1 -1
  225. package/hooks/useDataList/index.d.ts +1 -1
  226. package/hooks/useDataList/index.js +1 -12
  227. package/hooks/useDataList/index.js.map +1 -1
  228. package/hooks/useDataList/useDataList.d.ts +2 -3
  229. package/hooks/useDataList/useDataList.js +74 -94
  230. package/hooks/useDataList/useDataList.js.map +1 -1
  231. package/hooks/useDataList/utils/index.d.ts +1 -2
  232. package/hooks/useDataList/utils/index.js +1 -20
  233. package/hooks/useDataList/utils/index.js.map +1 -1
  234. package/hooks/useDataList/utils/prepareLoadListParams.js +10 -16
  235. package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
  236. package/hooks/useHandler.js +7 -12
  237. package/hooks/useHandler.js.map +1 -1
  238. package/hooks/useHandlers.d.ts +3 -3
  239. package/hooks/useHandlers.js +11 -17
  240. package/hooks/useHandlers.js.map +1 -1
  241. package/hooks/useRegisterLegacyPlugin.d.ts +2 -0
  242. package/hooks/useRegisterLegacyPlugin.js +11 -0
  243. package/hooks/useRegisterLegacyPlugin.js.map +1 -0
  244. package/hooks/useUi.d.ts +1 -1
  245. package/hooks/useUi.js +4 -10
  246. package/hooks/useUi.js.map +1 -1
  247. package/i18n/i18n.js +5 -13
  248. package/i18n/i18n.js.map +1 -1
  249. package/i18n/index.d.ts +1 -1
  250. package/i18n/index.js +1 -13
  251. package/i18n/index.js.map +1 -1
  252. package/index.d.ts +23 -14
  253. package/index.js +25 -165
  254. package/index.js.map +1 -1
  255. package/package.json +26 -29
  256. package/plugins/AddQuerySelectionPlugin.d.ts +2 -2
  257. package/plugins/AddQuerySelectionPlugin.js +61 -107
  258. package/plugins/AddQuerySelectionPlugin.js.map +1 -1
  259. package/plugins/ApolloCacheObjectIdPlugin.js +12 -31
  260. package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -1
  261. package/plugins/ApolloDynamicLink.d.ts +3 -2
  262. package/plugins/ApolloDynamicLink.js +19 -46
  263. package/plugins/ApolloDynamicLink.js.map +1 -1
  264. package/plugins/ApolloLinkPlugin.d.ts +1 -1
  265. package/plugins/ApolloLinkPlugin.js +18 -37
  266. package/plugins/ApolloLinkPlugin.js.map +1 -1
  267. package/plugins/ConsoleLinkPlugin.d.ts +1 -1
  268. package/plugins/ConsoleLinkPlugin.js +20 -41
  269. package/plugins/ConsoleLinkPlugin.js.map +1 -1
  270. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts +8 -13
  271. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +35 -58
  272. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
  273. package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.d.ts +14 -0
  274. package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js +31 -0
  275. package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js.map +1 -0
  276. package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.d.ts +2 -0
  277. package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js +31 -0
  278. package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js.map +1 -0
  279. package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +4 -5
  280. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +68 -12
  281. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
  282. package/plugins/NetworkErrorLinkPlugin/Typography.d.ts +8 -0
  283. package/plugins/NetworkErrorLinkPlugin/Typography.js +18 -0
  284. package/plugins/NetworkErrorLinkPlugin/Typography.js.map +1 -0
  285. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.d.ts +3 -3
  286. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +10 -20
  287. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
  288. package/plugins/NetworkErrorLinkPlugin.d.ts +4 -1
  289. package/plugins/NetworkErrorLinkPlugin.js +60 -37
  290. package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
  291. package/plugins/OmitTypenameLinkPlugin.d.ts +1 -1
  292. package/plugins/OmitTypenameLinkPlugin.js +11 -30
  293. package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
  294. package/plugins/TenantHeaderLinkPlugin.d.ts +3 -3
  295. package/plugins/TenantHeaderLinkPlugin.js +29 -48
  296. package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
  297. package/plugins/components/Image.d.ts +6 -0
  298. package/plugins/components/Image.js +19 -0
  299. package/plugins/components/Image.js.map +1 -0
  300. package/plugins/image.d.ts +1 -1
  301. package/plugins/image.js +46 -53
  302. package/plugins/image.js.map +1 -1
  303. package/plugins/index.d.ts +5 -5
  304. package/plugins/index.js +31 -53
  305. package/plugins/index.js.map +1 -1
  306. package/presentation/localStorage/index.d.ts +3 -0
  307. package/presentation/localStorage/index.js +5 -0
  308. package/presentation/localStorage/index.js.map +1 -0
  309. package/presentation/localStorage/useLocalStorage.d.ts +6 -0
  310. package/presentation/localStorage/useLocalStorage.js +21 -0
  311. package/presentation/localStorage/useLocalStorage.js.map +1 -0
  312. package/presentation/localStorage/useLocalStorageValue.d.ts +1 -0
  313. package/presentation/localStorage/useLocalStorageValue.js +20 -0
  314. package/presentation/localStorage/useLocalStorageValue.js.map +1 -0
  315. package/presentation/localStorage/useLocalStorageValues.d.ts +5 -0
  316. package/presentation/localStorage/useLocalStorageValues.js +39 -0
  317. package/presentation/localStorage/useLocalStorageValues.js.map +1 -0
  318. package/presentation/router/RouteElementRegistry.d.ts +14 -0
  319. package/presentation/router/RouteElementRegistry.js +32 -0
  320. package/presentation/router/RouteElementRegistry.js.map +1 -0
  321. package/presentation/router/abstractions.d.ts +13 -0
  322. package/presentation/router/abstractions.js +4 -0
  323. package/presentation/router/abstractions.js.map +1 -0
  324. package/presentation/router/components/RouteContent.d.ts +2 -0
  325. package/presentation/router/components/RouteContent.js +17 -0
  326. package/presentation/router/components/RouteContent.js.map +1 -0
  327. package/presentation/router/components/RouteLink.d.ts +50 -0
  328. package/presentation/router/components/RouteLink.js +22 -0
  329. package/presentation/router/components/RouteLink.js.map +1 -0
  330. package/presentation/router/components/SimpleLink.d.ts +44 -0
  331. package/presentation/router/components/SimpleLink.js +30 -0
  332. package/presentation/router/components/SimpleLink.js.map +1 -0
  333. package/presentation/router/hooks/useRoute.d.ts +6 -0
  334. package/presentation/router/hooks/useRoute.js +30 -0
  335. package/presentation/router/hooks/useRoute.js.map +1 -0
  336. package/presentation/router/hooks/useRouter.d.ts +7 -0
  337. package/presentation/router/hooks/useRouter.js +26 -0
  338. package/presentation/router/hooks/useRouter.js.map +1 -0
  339. package/presentation/router/index.d.ts +4 -0
  340. package/presentation/router/index.js +5 -0
  341. package/presentation/router/index.js.map +1 -0
  342. package/presentation/router/types.d.ts +5 -0
  343. package/presentation/router/types.js +3 -0
  344. package/presentation/router/types.js.map +1 -0
  345. package/react-butterfiles/Files.d.ts +69 -0
  346. package/react-butterfiles/Files.js +227 -0
  347. package/react-butterfiles/Files.js.map +1 -0
  348. package/react-butterfiles/file.todo +1 -0
  349. package/react-butterfiles/index.d.ts +2 -0
  350. package/react-butterfiles/index.js +4 -0
  351. package/react-butterfiles/index.js.map +1 -0
  352. package/react-butterfiles/utils/generateId.d.ts +1 -0
  353. package/react-butterfiles/utils/generateId.js +5 -0
  354. package/react-butterfiles/utils/generateId.js.map +1 -0
  355. package/react-butterfiles/utils/readFileContent.d.ts +1 -0
  356. package/react-butterfiles/utils/readFileContent.js +15 -0
  357. package/react-butterfiles/utils/readFileContent.js.map +1 -0
  358. package/renderApp.d.ts +1 -1
  359. package/renderApp.js +4 -11
  360. package/renderApp.js.map +1 -1
  361. package/router.d.ts +5 -0
  362. package/router.js +8 -0
  363. package/router.js.map +1 -0
  364. package/shared/di/DiContainerProvider.d.ts +8 -0
  365. package/shared/di/DiContainerProvider.js +17 -0
  366. package/shared/di/DiContainerProvider.js.map +1 -0
  367. package/shared/di/createFeature.d.ts +11 -0
  368. package/shared/di/createFeature.js +11 -0
  369. package/shared/di/createFeature.js.map +1 -0
  370. package/shared/di/useFeature.d.ts +2 -0
  371. package/shared/di/useFeature.js +18 -0
  372. package/shared/di/useFeature.js.map +1 -0
  373. package/types.d.ts +16 -13
  374. package/types.js +1 -12
  375. package/types.js.map +1 -1
  376. package/utils/createGenericContext.d.ts +13 -0
  377. package/utils/createGenericContext.js +25 -0
  378. package/utils/createGenericContext.js.map +1 -0
  379. package/utils/createHashing.d.ts +2 -0
  380. package/utils/createHashing.js +18 -0
  381. package/utils/createHashing.js.map +1 -0
  382. package/utils/index.d.ts +2 -8
  383. package/utils/index.js +2 -93
  384. package/utils/index.js.map +1 -1
  385. package/utils/legacyPluginToReactComponent.d.ts +7 -0
  386. package/utils/legacyPluginToReactComponent.js +14 -0
  387. package/utils/legacyPluginToReactComponent.js.map +1 -0
  388. package/components/Routes.d.ts +0 -2
  389. package/components/Routes.js +0 -46
  390. package/components/Routes.js.map +0 -1
  391. package/components/View.d.ts +0 -8
  392. package/components/View.js +0 -31
  393. package/components/View.js.map +0 -1
  394. package/core/AddRoute.d.ts +0 -17
  395. package/core/AddRoute.js +0 -21
  396. package/core/AddRoute.js.map +0 -1
  397. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.d.ts +0 -14
  398. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +0 -30
  399. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +0 -1
  400. package/hooks/useDataList/utils/types.d.ts +0 -40
  401. package/hooks/useDataList/utils/types.js +0 -7
  402. package/hooks/useDataList/utils/types.js.map +0 -1
  403. package/plugins/LocaleHeaderLinkPlugin.d.ts +0 -10
  404. package/plugins/LocaleHeaderLinkPlugin.js +0 -49
  405. package/plugins/LocaleHeaderLinkPlugin.js.map +0 -1
  406. package/plugins/RoutePlugin.d.ts +0 -12
  407. package/plugins/RoutePlugin.js +0 -35
  408. package/plugins/RoutePlugin.js.map +0 -1
  409. package/plugins/ViewPlugin.d.ts +0 -14
  410. package/plugins/ViewPlugin.js +0 -40
  411. package/plugins/ViewPlugin.js.map +0 -1
  412. package/utils/getApiUrl.d.ts +0 -1
  413. package/utils/getApiUrl.js +0 -12
  414. package/utils/getApiUrl.js.map +0 -1
  415. package/utils/getGqlApiUrl.d.ts +0 -1
  416. package/utils/getGqlApiUrl.js +0 -12
  417. package/utils/getGqlApiUrl.js.map +0 -1
  418. package/utils/getHeadlessCmsGqlApiUrl.d.ts +0 -5
  419. package/utils/getHeadlessCmsGqlApiUrl.js +0 -18
  420. package/utils/getHeadlessCmsGqlApiUrl.js.map +0 -1
  421. package/utils/getLocaleCode.d.ts +0 -6
  422. package/utils/getLocaleCode.js +0 -43
  423. package/utils/getLocaleCode.js.map +0 -1
  424. package/utils/getPrerenderId.d.ts +0 -6
  425. package/utils/getPrerenderId.js +0 -11
  426. package/utils/getPrerenderId.js.map +0 -1
  427. package/utils/getTenantId.d.ts +0 -6
  428. package/utils/getTenantId.js +0 -35
  429. package/utils/getTenantId.js.map +0 -1
  430. package/utils/isLocalhost.d.ts +0 -1
  431. package/utils/isLocalhost.js +0 -15
  432. package/utils/isLocalhost.js.map +0 -1
  433. package/utils/isPrerendering.d.ts +0 -1
  434. package/utils/isPrerendering.js +0 -11
  435. package/utils/isPrerendering.js.map +0 -1
@@ -0,0 +1,54 @@
1
+ import { GraphQLClient } from "./abstractions.js";
2
+ import { EnvConfig } from "../envConfig/index.js";
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));
27
+ }
28
+ }
29
+ }
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
+ }
49
+ export const RetryGraphQLClient = GraphQLClient.createDecorator({
50
+ decorator: RetryGraphQLClientImpl,
51
+ dependencies: [EnvConfig]
52
+ });
53
+
54
+ //# sourceMappingURL=RetryGraphQLClient.js.map
@@ -0,0 +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;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{ Container } from "@webiny/di";
3
+ import { GraphQLClient } from "../abstractions.js";
4
+ import { FetchGraphQLClient } from "../FetchGraphQLClient.js";
5
+ import { BatchingGraphQLClient } from "../BatchingGraphQLClient.js";
6
+ import { RetryGraphQLClient } from "../RetryGraphQLClient.js";
7
+ import { EnvConfig } from "../../envConfig/index.js";
8
+ describe("GraphQLClient Feature", () => {
9
+ let container;
10
+ let mockEnvConfig;
11
+ beforeEach(() => {
12
+ container = new Container();
13
+ mockEnvConfig = {
14
+ get: vi.fn(key => {
15
+ if (key === "graphqlApiUrl") {
16
+ return "https://api.example.com/graphql";
17
+ }
18
+ return undefined;
19
+ })
20
+ };
21
+ container.registerInstance(EnvConfig, mockEnvConfig);
22
+ });
23
+ describe("FetchGraphQLClient", () => {
24
+ beforeEach(() => {
25
+ container.register(FetchGraphQLClient).inSingletonScope();
26
+ });
27
+ it("should execute a query successfully", async () => {
28
+ const mockResponse = {
29
+ data: {
30
+ user: {
31
+ id: "1",
32
+ name: "John"
33
+ }
34
+ }
35
+ };
36
+ global.fetch = vi.fn().mockResolvedValue({
37
+ status: 200,
38
+ json: async () => mockResponse
39
+ });
40
+ const client = container.resolve(GraphQLClient);
41
+ const result = await client.execute({
42
+ query: "query GetUser { user { id name } }"
43
+ });
44
+ expect(result).toEqual(mockResponse.data);
45
+ expect(global.fetch).toHaveBeenCalledWith("https://api.example.com/graphql", expect.objectContaining({
46
+ method: "POST",
47
+ headers: {
48
+ "Content-Type": "application/json"
49
+ }
50
+ }));
51
+ });
52
+ it("should execute a mutation successfully", async () => {
53
+ const mockResponse = {
54
+ data: {
55
+ createUser: {
56
+ id: "2",
57
+ name: "Jane"
58
+ }
59
+ }
60
+ };
61
+ global.fetch = vi.fn().mockResolvedValue({
62
+ status: 200,
63
+ json: async () => mockResponse
64
+ });
65
+ const client = container.resolve(GraphQLClient);
66
+ const result = await client.execute({
67
+ query: "mutation CreateUser($name: String!) { createUser(name: $name) { id name } }",
68
+ variables: {
69
+ name: "Jane"
70
+ }
71
+ });
72
+ expect(result).toEqual(mockResponse.data);
73
+ });
74
+ it("should include custom headers", async () => {
75
+ const mockResponse = {
76
+ data: {
77
+ user: {
78
+ id: "1"
79
+ }
80
+ }
81
+ };
82
+ global.fetch = vi.fn().mockResolvedValue({
83
+ status: 200,
84
+ json: async () => mockResponse
85
+ });
86
+ const client = container.resolve(GraphQLClient);
87
+ await client.execute({
88
+ query: "query GetUser { user { id } }",
89
+ headers: {
90
+ "x-tenant": "root",
91
+ Authorization: "Bearer token"
92
+ }
93
+ });
94
+ expect(global.fetch).toHaveBeenCalledWith("https://api.example.com/graphql", expect.objectContaining({
95
+ headers: {
96
+ "Content-Type": "application/json",
97
+ "x-tenant": "root",
98
+ Authorization: "Bearer token"
99
+ }
100
+ }));
101
+ });
102
+ it("should throw on network error", async () => {
103
+ global.fetch = vi.fn().mockRejectedValue(new Error("Network failure"));
104
+ const client = container.resolve(GraphQLClient);
105
+ await expect(client.execute({
106
+ query: "query { user { id } }"
107
+ })).rejects.toThrow("Network error: Network failure");
108
+ });
109
+ it("should throw on GraphQL errors", async () => {
110
+ const mockResponse = {
111
+ errors: [{
112
+ message: "User not found"
113
+ }],
114
+ data: null
115
+ };
116
+ global.fetch = vi.fn().mockResolvedValue({
117
+ status: 200,
118
+ json: async () => mockResponse
119
+ });
120
+ const client = container.resolve(GraphQLClient);
121
+ await expect(client.execute({
122
+ query: "query { user { id } }"
123
+ })).rejects.toThrow("GraphQL errors");
124
+ });
125
+ it("should throw on invalid JSON response", async () => {
126
+ global.fetch = vi.fn().mockResolvedValue({
127
+ json: async () => {
128
+ throw new Error("Invalid JSON");
129
+ }
130
+ });
131
+ const client = container.resolve(GraphQLClient);
132
+ await expect(client.execute({
133
+ query: "query { user { id } }"
134
+ })).rejects.toThrow("Failed to parse GraphQL response as JSON");
135
+ });
136
+ });
137
+ describe("BatchingGraphQLClient", () => {
138
+ beforeEach(() => {
139
+ container.register(FetchGraphQLClient).inSingletonScope();
140
+ container.registerDecorator(BatchingGraphQLClient);
141
+ });
142
+ it("should batch multiple requests within the batch window", async () => {
143
+ const mockResponse = [{
144
+ data: {
145
+ user: {
146
+ id: "1",
147
+ name: "John"
148
+ }
149
+ }
150
+ }, {
151
+ data: {
152
+ post: {
153
+ id: "2",
154
+ title: "Hello"
155
+ }
156
+ }
157
+ }];
158
+ global.fetch = vi.fn().mockResolvedValue({
159
+ json: async () => mockResponse
160
+ });
161
+ const client = container.resolve(GraphQLClient);
162
+ const [result1, result2] = await Promise.all([client.execute({
163
+ query: "query GetUser { user { id name } }"
164
+ }), client.execute({
165
+ query: "query GetPost { post { id title } }"
166
+ })]);
167
+ expect(result1).toEqual(mockResponse[0].data);
168
+ expect(result2).toEqual(mockResponse[1].data);
169
+ expect(global.fetch).toHaveBeenCalledTimes(1);
170
+ const callBody = JSON.parse(global.fetch.mock.calls[0][1].body);
171
+ expect(callBody).toHaveLength(2);
172
+ });
173
+ it("should execute single request without batching", async () => {
174
+ const mockResponse = {
175
+ data: {
176
+ user: {
177
+ id: "1",
178
+ name: "John"
179
+ }
180
+ }
181
+ };
182
+ global.fetch = vi.fn().mockResolvedValue({
183
+ status: 200,
184
+ json: async () => mockResponse
185
+ });
186
+ const client = container.resolve(GraphQLClient);
187
+ const result = await client.execute({
188
+ query: "query GetUser { user { id name } }"
189
+ });
190
+ expect(result).toEqual(mockResponse.data);
191
+
192
+ // Should use decoratee directly for single request
193
+ const callBody = JSON.parse(global.fetch.mock.calls[0][1].body);
194
+ expect(callBody).toHaveProperty("query");
195
+ expect(callBody).not.toBeInstanceOf(Array);
196
+ });
197
+ it("should handle mixed queries and mutations in batch", async () => {
198
+ const mockResponse = [{
199
+ data: {
200
+ user: {
201
+ id: "1"
202
+ }
203
+ }
204
+ }, {
205
+ data: {
206
+ createPost: {
207
+ id: "2"
208
+ }
209
+ }
210
+ }];
211
+ global.fetch = vi.fn().mockResolvedValue({
212
+ status: 200,
213
+ json: async () => mockResponse
214
+ });
215
+ const client = container.resolve(GraphQLClient);
216
+ await Promise.all([client.execute({
217
+ query: "query { user { id } }"
218
+ }), client.execute({
219
+ query: "mutation { createPost { id } }"
220
+ })]);
221
+ expect(global.fetch).toHaveBeenCalledTimes(1);
222
+ const callBody = JSON.parse(global.fetch.mock.calls[0][1].body);
223
+ expect(callBody[0]).toHaveProperty("query");
224
+ expect(callBody[1]).toHaveProperty("query");
225
+ });
226
+ it("should reject all requests if batch fails", async () => {
227
+ global.fetch = vi.fn().mockRejectedValue(new Error("Network error"));
228
+ const client = container.resolve(GraphQLClient);
229
+ const promises = [client.execute({
230
+ query: "query { user { id } }"
231
+ }), client.execute({
232
+ query: "query { post { id } }"
233
+ })];
234
+ await expect(Promise.all(promises)).rejects.toThrow("Network error");
235
+ });
236
+ it("should handle GraphQL errors in batched operations", async () => {
237
+ const mockResponse = [{
238
+ data: {
239
+ user: {
240
+ id: "1"
241
+ }
242
+ }
243
+ }, {
244
+ errors: [{
245
+ message: "Post not found"
246
+ }],
247
+ data: null
248
+ }];
249
+ global.fetch = vi.fn().mockResolvedValue({
250
+ json: async () => mockResponse
251
+ });
252
+ const client = container.resolve(GraphQLClient);
253
+ const promises = [client.execute({
254
+ query: "query { user { id } }"
255
+ }), client.execute({
256
+ query: "query { post { id } }"
257
+ })];
258
+ await expect(Promise.all(promises)).rejects.toThrow("GraphQL errors in operation 1");
259
+ });
260
+ });
261
+ describe("RetryGraphQLClient", () => {
262
+ beforeEach(() => {
263
+ container.register(FetchGraphQLClient).inSingletonScope();
264
+ container.registerDecorator(RetryGraphQLClient);
265
+ });
266
+ it("should retry on network errors", async () => {
267
+ const mockResponse = {
268
+ data: {
269
+ user: {
270
+ id: "1"
271
+ }
272
+ }
273
+ };
274
+ global.fetch = vi.fn().mockRejectedValueOnce(new Error("Network timeout")).mockRejectedValueOnce(new Error("Network timeout")).mockResolvedValueOnce({
275
+ status: 200,
276
+ json: async () => mockResponse
277
+ });
278
+ const client = container.resolve(GraphQLClient);
279
+ const result = await client.execute({
280
+ query: "query { user { id } }"
281
+ });
282
+ expect(result).toEqual(mockResponse.data);
283
+ expect(global.fetch).toHaveBeenCalledTimes(3);
284
+ });
285
+ it("should not retry on GraphQL errors", async () => {
286
+ const mockResponse = {
287
+ errors: [{
288
+ message: "Unauthorized"
289
+ }],
290
+ data: null
291
+ };
292
+ global.fetch = vi.fn().mockResolvedValue({
293
+ status: 200,
294
+ json: async () => mockResponse
295
+ });
296
+ const client = container.resolve(GraphQLClient);
297
+ await expect(client.execute({
298
+ query: "query { user { id } }"
299
+ })).rejects.toThrow("GraphQL errors");
300
+ expect(global.fetch).toHaveBeenCalledTimes(1);
301
+ });
302
+ it("should give up after max retries", async () => {
303
+ global.fetch = vi.fn().mockRejectedValue(new Error("Network error"));
304
+ const client = container.resolve(GraphQLClient);
305
+ await expect(client.execute({
306
+ query: "query { user { id } }"
307
+ })).rejects.toThrow("Network error");
308
+
309
+ // Should try 4 times: initial + 3 retries
310
+ expect(global.fetch).toHaveBeenCalledTimes(4);
311
+ });
312
+ });
313
+ describe("Combined decorators (Retry + Batching)", () => {
314
+ beforeEach(() => {
315
+ container.register(FetchGraphQLClient).inSingletonScope();
316
+ container.registerDecorator(BatchingGraphQLClient);
317
+ container.registerDecorator(RetryGraphQLClient);
318
+ });
319
+ it("should retry batched requests on failure", async () => {
320
+ const mockResponse = [{
321
+ data: {
322
+ user: {
323
+ id: "1"
324
+ }
325
+ }
326
+ }, {
327
+ data: {
328
+ post: {
329
+ id: "2"
330
+ }
331
+ }
332
+ }];
333
+ global.fetch = vi.fn().mockRejectedValueOnce(new Error("Network error")).mockResolvedValueOnce({
334
+ status: 200,
335
+ json: async () => mockResponse
336
+ });
337
+ const client = container.resolve(GraphQLClient);
338
+ const [result1, result2] = await Promise.all([client.execute({
339
+ query: "query { user { id } }"
340
+ }), client.execute({
341
+ query: "query { post { id } }"
342
+ })]);
343
+ expect(result1).toEqual(mockResponse[0].data);
344
+ expect(result2).toEqual(mockResponse[1].data);
345
+ expect(global.fetch).toHaveBeenCalledTimes(2);
346
+ });
347
+ });
348
+ });
349
+
350
+ //# sourceMappingURL=GraphQLClient.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["describe","it","expect","vi","beforeEach","Container","GraphQLClient","FetchGraphQLClient","BatchingGraphQLClient","RetryGraphQLClient","EnvConfig","container","mockEnvConfig","get","fn","key","undefined","registerInstance","register","inSingletonScope","mockResponse","data","user","id","name","global","fetch","mockResolvedValue","status","json","client","resolve","result","execute","query","toEqual","toHaveBeenCalledWith","objectContaining","method","headers","createUser","variables","Authorization","mockRejectedValue","Error","rejects","toThrow","errors","message","registerDecorator","post","title","result1","result2","Promise","all","toHaveBeenCalledTimes","callBody","JSON","parse","mock","calls","body","toHaveLength","toHaveProperty","not","toBeInstanceOf","Array","createPost","promises","mockRejectedValueOnce","mockResolvedValueOnce"],"sources":["GraphQLClient.test.ts"],"sourcesContent":["import { describe, it, expect, vi, beforeEach } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { GraphQLClient } from \"../abstractions.js\";\nimport { FetchGraphQLClient } from \"../FetchGraphQLClient.js\";\nimport { BatchingGraphQLClient } from \"../BatchingGraphQLClient.js\";\nimport { RetryGraphQLClient } from \"../RetryGraphQLClient.js\";\nimport { EnvConfig } from \"~/features/envConfig/index.js\";\n\ndescribe(\"GraphQLClient Feature\", () => {\n let container: Container;\n let mockEnvConfig: EnvConfig.Interface;\n\n beforeEach(() => {\n container = new Container();\n\n mockEnvConfig = {\n get: vi.fn((key: string) => {\n if (key === \"graphqlApiUrl\") {\n return \"https://api.example.com/graphql\";\n }\n return undefined;\n })\n } as any;\n\n container.registerInstance(EnvConfig, mockEnvConfig);\n });\n\n describe(\"FetchGraphQLClient\", () => {\n beforeEach(() => {\n container.register(FetchGraphQLClient).inSingletonScope();\n });\n\n it(\"should execute a query successfully\", async () => {\n const mockResponse = {\n data: { user: { id: \"1\", name: \"John\" } }\n };\n\n global.fetch = vi.fn().mockResolvedValue({\n status: 200,\n json: async () => mockResponse\n });\n\n const client = container.resolve(GraphQLClient);\n const result = await client.execute({\n query: \"query GetUser { user { id name } }\"\n });\n\n expect(result).toEqual(mockResponse.data);\n expect(global.fetch).toHaveBeenCalledWith(\n \"https://api.example.com/graphql\",\n expect.objectContaining({\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" }\n })\n );\n });\n\n it(\"should execute a mutation successfully\", async () => {\n const mockResponse = {\n data: { createUser: { id: \"2\", name: \"Jane\" } }\n };\n\n global.fetch = vi.fn().mockResolvedValue({\n status: 200,\n json: async () => mockResponse\n });\n\n const client = container.resolve(GraphQLClient);\n const result = await client.execute({\n query: \"mutation CreateUser($name: String!) { createUser(name: $name) { id name } }\",\n variables: { name: \"Jane\" }\n });\n\n expect(result).toEqual(mockResponse.data);\n });\n\n it(\"should include custom headers\", async () => {\n const mockResponse = { data: { user: { id: \"1\" } } };\n\n global.fetch = vi.fn().mockResolvedValue({\n status: 200,\n json: async () => mockResponse\n });\n\n const client = container.resolve(GraphQLClient);\n await client.execute({\n query: \"query GetUser { user { id } }\",\n headers: { \"x-tenant\": \"root\", Authorization: \"Bearer token\" }\n });\n\n expect(global.fetch).toHaveBeenCalledWith(\n \"https://api.example.com/graphql\",\n expect.objectContaining({\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-tenant\": \"root\",\n Authorization: \"Bearer token\"\n }\n })\n );\n });\n\n it(\"should throw on network error\", async () => {\n global.fetch = vi.fn().mockRejectedValue(new Error(\"Network failure\"));\n\n const client = container.resolve(GraphQLClient);\n\n await expect(client.execute({ query: \"query { user { id } }\" })).rejects.toThrow(\n \"Network error: Network failure\"\n );\n });\n\n it(\"should throw on GraphQL errors\", async () => {\n const mockResponse = {\n errors: [{ message: \"User not found\" }],\n data: null\n };\n\n global.fetch = vi.fn().mockResolvedValue({\n status: 200,\n json: async () => mockResponse\n });\n\n const client = container.resolve(GraphQLClient);\n\n await expect(client.execute({ query: \"query { user { id } }\" })).rejects.toThrow(\n \"GraphQL errors\"\n );\n });\n\n it(\"should throw on invalid JSON response\", async () => {\n global.fetch = vi.fn().mockResolvedValue({\n json: async () => {\n throw new Error(\"Invalid JSON\");\n }\n });\n\n const client = container.resolve(GraphQLClient);\n\n await expect(client.execute({ query: \"query { user { id } }\" })).rejects.toThrow(\n \"Failed to parse GraphQL response as JSON\"\n );\n });\n });\n\n describe(\"BatchingGraphQLClient\", () => {\n beforeEach(() => {\n container.register(FetchGraphQLClient).inSingletonScope();\n container.registerDecorator(BatchingGraphQLClient);\n });\n\n it(\"should batch multiple requests within the batch window\", async () => {\n const mockResponse = [\n { data: { user: { id: \"1\", name: \"John\" } } },\n { data: { post: { id: \"2\", title: \"Hello\" } } }\n ];\n\n global.fetch = vi.fn().mockResolvedValue({\n json: async () => mockResponse\n });\n\n const client = container.resolve(GraphQLClient);\n\n const [result1, result2] = await Promise.all([\n client.execute({ query: \"query GetUser { user { id name } }\" }),\n client.execute({ query: \"query GetPost { post { id title } }\" })\n ]);\n\n expect(result1).toEqual(mockResponse[0].data);\n expect(result2).toEqual(mockResponse[1].data);\n expect(global.fetch).toHaveBeenCalledTimes(1);\n\n const callBody = JSON.parse((global.fetch as any).mock.calls[0][1].body);\n expect(callBody).toHaveLength(2);\n });\n\n it(\"should execute single request without batching\", async () => {\n const mockResponse = {\n data: { user: { id: \"1\", name: \"John\" } }\n };\n\n global.fetch = vi.fn().mockResolvedValue({\n status: 200,\n json: async () => mockResponse\n });\n\n const client = container.resolve(GraphQLClient);\n const result = await client.execute({\n query: \"query GetUser { user { id name } }\"\n });\n\n expect(result).toEqual(mockResponse.data);\n\n // Should use decoratee directly for single request\n const callBody = JSON.parse((global.fetch as any).mock.calls[0][1].body);\n expect(callBody).toHaveProperty(\"query\");\n expect(callBody).not.toBeInstanceOf(Array);\n });\n\n it(\"should handle mixed queries and mutations in batch\", async () => {\n const mockResponse = [\n { data: { user: { id: \"1\" } } },\n { data: { createPost: { id: \"2\" } } }\n ];\n\n global.fetch = vi.fn().mockResolvedValue({\n status: 200,\n json: async () => mockResponse\n });\n\n const client = container.resolve(GraphQLClient);\n\n await Promise.all([\n client.execute({ query: \"query { user { id } }\" }),\n client.execute({ query: \"mutation { createPost { id } }\" })\n ]);\n\n expect(global.fetch).toHaveBeenCalledTimes(1);\n const callBody = JSON.parse((global.fetch as any).mock.calls[0][1].body);\n expect(callBody[0]).toHaveProperty(\"query\");\n expect(callBody[1]).toHaveProperty(\"query\");\n });\n\n it(\"should reject all requests if batch fails\", async () => {\n global.fetch = vi.fn().mockRejectedValue(new Error(\"Network error\"));\n\n const client = container.resolve(GraphQLClient);\n\n const promises = [\n client.execute({ query: \"query { user { id } }\" }),\n client.execute({ query: \"query { post { id } }\" })\n ];\n\n await expect(Promise.all(promises)).rejects.toThrow(\"Network error\");\n });\n\n it(\"should handle GraphQL errors in batched operations\", async () => {\n const mockResponse = [\n { data: { user: { id: \"1\" } } },\n { errors: [{ message: \"Post not found\" }], data: null }\n ];\n\n global.fetch = vi.fn().mockResolvedValue({\n json: async () => mockResponse\n });\n\n const client = container.resolve(GraphQLClient);\n\n const promises = [\n client.execute({ query: \"query { user { id } }\" }),\n client.execute({ query: \"query { post { id } }\" })\n ];\n\n await expect(Promise.all(promises)).rejects.toThrow(\"GraphQL errors in operation 1\");\n });\n });\n\n describe(\"RetryGraphQLClient\", () => {\n beforeEach(() => {\n container.register(FetchGraphQLClient).inSingletonScope();\n container.registerDecorator(RetryGraphQLClient);\n });\n\n it(\"should retry on network errors\", async () => {\n const mockResponse = { data: { user: { id: \"1\" } } };\n\n global.fetch = vi\n .fn()\n .mockRejectedValueOnce(new Error(\"Network timeout\"))\n .mockRejectedValueOnce(new Error(\"Network timeout\"))\n .mockResolvedValueOnce({\n status: 200,\n json: async () => mockResponse\n });\n\n const client = container.resolve(GraphQLClient);\n const result = await client.execute({ query: \"query { user { id } }\" });\n\n expect(result).toEqual(mockResponse.data);\n expect(global.fetch).toHaveBeenCalledTimes(3);\n });\n\n it(\"should not retry on GraphQL errors\", async () => {\n const mockResponse = {\n errors: [{ message: \"Unauthorized\" }],\n data: null\n };\n\n global.fetch = vi.fn().mockResolvedValue({\n status: 200,\n json: async () => mockResponse\n });\n\n const client = container.resolve(GraphQLClient);\n\n await expect(client.execute({ query: \"query { user { id } }\" })).rejects.toThrow(\n \"GraphQL errors\"\n );\n\n expect(global.fetch).toHaveBeenCalledTimes(1);\n });\n\n it(\"should give up after max retries\", async () => {\n global.fetch = vi.fn().mockRejectedValue(new Error(\"Network error\"));\n\n const client = container.resolve(GraphQLClient);\n\n await expect(client.execute({ query: \"query { user { id } }\" })).rejects.toThrow(\n \"Network error\"\n );\n\n // Should try 4 times: initial + 3 retries\n expect(global.fetch).toHaveBeenCalledTimes(4);\n });\n });\n\n describe(\"Combined decorators (Retry + Batching)\", () => {\n beforeEach(() => {\n container.register(FetchGraphQLClient).inSingletonScope();\n container.registerDecorator(BatchingGraphQLClient);\n container.registerDecorator(RetryGraphQLClient);\n });\n\n it(\"should retry batched requests on failure\", async () => {\n const mockResponse = [{ data: { user: { id: \"1\" } } }, { data: { post: { id: \"2\" } } }];\n\n global.fetch = vi\n .fn()\n .mockRejectedValueOnce(new Error(\"Network error\"))\n .mockResolvedValueOnce({\n status: 200,\n json: async () => mockResponse\n });\n\n const client = container.resolve(GraphQLClient);\n\n const [result1, result2] = await Promise.all([\n client.execute({ query: \"query { user { id } }\" }),\n client.execute({ query: \"query { post { id } }\" })\n ]);\n\n expect(result1).toEqual(mockResponse[0].data);\n expect(result2).toEqual(mockResponse[1].data);\n expect(global.fetch).toHaveBeenCalledTimes(2);\n });\n });\n});\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,EAAE,EAAEC,MAAM,EAAEC,EAAE,EAAEC,UAAU,QAAQ,QAAQ;AAC7D,SAASC,SAAS,QAAQ,YAAY;AACtC,SAASC,aAAa;AACtB,SAASC,kBAAkB;AAC3B,SAASC,qBAAqB;AAC9B,SAASC,kBAAkB;AAC3B,SAASC,SAAS;AAElBV,QAAQ,CAAC,uBAAuB,EAA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AAO,CAACf,YAAY,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC;MAC7CnB,MAAM,CAACuB,MAAM,CAACC,KAAK,CAAC,CAAC8B,qBAAqB,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ import type { DocumentNode } from "graphql";
2
+ type IHeaders = Record<string, string | number | undefined>;
3
+ type GraphQLRequest<TVariables = any> = {
4
+ query: DocumentNode | string;
5
+ variables?: TVariables;
6
+ headers?: IHeaders;
7
+ };
8
+ export interface IGraphQLClient {
9
+ execute<TResult = any, TVariables = any>(params: GraphQLRequest<TVariables>): Promise<TResult>;
10
+ }
11
+ export declare const GraphQLClient: import("@webiny/di").Abstraction<IGraphQLClient>;
12
+ export declare namespace GraphQLClient {
13
+ type Headers = IHeaders;
14
+ type Interface = IGraphQLClient;
15
+ type Request<TVariables = any> = GraphQLRequest<TVariables>;
16
+ }
17
+ export {};
@@ -0,0 +1,4 @@
1
+ import { createAbstraction } from "@webiny/feature/admin";
2
+ export const GraphQLClient = createAbstraction("GraphQLClient");
3
+
4
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createAbstraction","GraphQLClient"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { DocumentNode } from \"graphql\";\n\ntype IHeaders = Record<string, string | number | undefined>;\n\ntype GraphQLRequest<TVariables = any> = {\n query: DocumentNode | string;\n variables?: TVariables;\n headers?: IHeaders;\n};\n\nexport interface IGraphQLClient {\n execute<TResult = any, TVariables = any>(params: GraphQLRequest<TVariables>): Promise<TResult>;\n}\nexport const GraphQLClient = createAbstraction<IGraphQLClient>(\"GraphQLClient\");\n\nexport namespace GraphQLClient {\n export type Headers = IHeaders;\n export type Interface = IGraphQLClient;\n export type Request<TVariables = any> = GraphQLRequest<TVariables>;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,uBAAuB;AAczD,OAAO,MAAMC,aAAa,GAAGD,iBAAiB,CAAiB,eAAe,CAAC","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ export declare const GraphQLClientFeature: import("~/shared/di/createFeature.js").FeatureDefinition<{
2
+ client: import("./abstractions.js").IGraphQLClient;
3
+ }, [options: {
4
+ batching: boolean;
5
+ retry: boolean;
6
+ }]>;
@@ -0,0 +1,31 @@
1
+ import { GraphQLClient } from "./abstractions.js";
2
+ import { BatchingGraphQLClient } from "./BatchingGraphQLClient.js";
3
+ import { FetchGraphQLClient } from "./FetchGraphQLClient.js";
4
+ import { createFeature } from "../../shared/di/createFeature.js";
5
+ import { RetryGraphQLClient } from "./RetryGraphQLClient.js";
6
+ import { NetworkErrorPublishing } from "./NetworkErrorPublishing.js";
7
+ import { AuthenticationErrorPublishing } from "./AuthenticationErrorPublishing.js";
8
+ export const GraphQLClientFeature = createFeature({
9
+ name: "GraphQLClient",
10
+ register(container, options) {
11
+ // Base implementation
12
+ container.register(FetchGraphQLClient).inSingletonScope();
13
+
14
+ // Optional decorators (order matters: retry wraps batching)
15
+ if (options.batching) {
16
+ container.registerDecorator(BatchingGraphQLClient);
17
+ }
18
+ if (options.retry) {
19
+ container.registerDecorator(RetryGraphQLClient);
20
+ }
21
+ container.registerDecorator(NetworkErrorPublishing);
22
+ container.registerDecorator(AuthenticationErrorPublishing);
23
+ },
24
+ resolve(container) {
25
+ return {
26
+ client: container.resolve(GraphQLClient)
27
+ };
28
+ }
29
+ });
30
+
31
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["GraphQLClient","BatchingGraphQLClient","FetchGraphQLClient","createFeature","RetryGraphQLClient","NetworkErrorPublishing","AuthenticationErrorPublishing","GraphQLClientFeature","name","register","container","options","inSingletonScope","batching","registerDecorator","retry","resolve","client"],"sources":["feature.ts"],"sourcesContent":["import { GraphQLClient } from \"./abstractions.js\";\nimport { BatchingGraphQLClient } from \"./BatchingGraphQLClient.js\";\nimport { FetchGraphQLClient } from \"./FetchGraphQLClient.js\";\nimport { createFeature } from \"~/shared/di/createFeature.js\";\nimport { RetryGraphQLClient } from \"./RetryGraphQLClient.js\";\nimport { NetworkErrorPublishing } from \"./NetworkErrorPublishing.js\";\nimport { AuthenticationErrorPublishing } from \"./AuthenticationErrorPublishing.js\";\n\nexport const GraphQLClientFeature = createFeature({\n name: \"GraphQLClient\",\n register(\n container,\n options: {\n batching: boolean;\n retry: boolean;\n }\n ) {\n // Base implementation\n container.register(FetchGraphQLClient).inSingletonScope();\n\n // Optional decorators (order matters: retry wraps batching)\n if (options.batching) {\n container.registerDecorator(BatchingGraphQLClient);\n }\n\n if (options.retry) {\n container.registerDecorator(RetryGraphQLClient);\n }\n\n container.registerDecorator(NetworkErrorPublishing);\n container.registerDecorator(AuthenticationErrorPublishing);\n },\n resolve(container) {\n return {\n client: container.resolve(GraphQLClient)\n };\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,qBAAqB;AAC9B,SAASC,kBAAkB;AAC3B,SAASC,aAAa;AACtB,SAASC,kBAAkB;AAC3B,SAASC,sBAAsB;AAC/B,SAASC,6BAA6B;AAEtC,OAAO,MAAMC,oBAAoB,GAAGJ,aAAa,CAAC;EAC9CK,IAAI,EAAE,eAAe;EACrBC,QAAQA,CACJC,SAAS,EACTC,OAGC,EACH;IACE;IACAD,SAAS,CAACD,QAAQ,CAACP,kBAAkB,CAAC,CAACU,gBAAgB,CAAC,CAAC;;IAEzD;IACA,IAAID,OAAO,CAACE,QAAQ,EAAE;MAClBH,SAAS,CAACI,iBAAiB,CAACb,qBAAqB,CAAC;IACtD;IAEA,IAAIU,OAAO,CAACI,KAAK,EAAE;MACfL,SAAS,CAACI,iBAAiB,CAACV,kBAAkB,CAAC;IACnD;IAEAM,SAAS,CAACI,iBAAiB,CAACT,sBAAsB,CAAC;IACnDK,SAAS,CAACI,iBAAiB,CAACR,6BAA6B,CAAC;EAC9D,CAAC;EACDU,OAAOA,CAACN,SAAS,EAAE;IACf,OAAO;MACHO,MAAM,EAAEP,SAAS,CAACM,OAAO,CAAChB,aAAa;IAC3C,CAAC;EACL;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ export { GraphQLClient } from "./abstractions.js";
@@ -0,0 +1,3 @@
1
+ export { GraphQLClient } from "./abstractions.js";
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["GraphQLClient"],"sources":["index.ts"],"sourcesContent":["export { GraphQLClient } from \"./abstractions.js\";\n"],"mappings":"AAAA,SAASA,aAAa","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ export interface BatchingOptions {
2
+ enabled?: boolean;
3
+ batchWindowMs?: number;
4
+ maxBatchSize?: number;
5
+ }
@@ -0,0 +1,3 @@
1
+ export {};
2
+
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export interface BatchingOptions {\n enabled?: boolean;\n batchWindowMs?: number;\n maxBatchSize?: number;\n}\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ import { ILocalStorageGateway } from "./abstractions.js";
2
+ export declare class BrowserLocalStorageGateway implements ILocalStorageGateway {
3
+ get<T = string>(key: string): T | null;
4
+ set<T = string>(key: string, value: T): void;
5
+ remove(key: string): void;
6
+ clear(): void;
7
+ getAll(): Record<string, unknown>;
8
+ subscribe(listener: (event: StorageEvent | CustomEvent) => void): () => void;
9
+ }
@@ -0,0 +1,68 @@
1
+ export class BrowserLocalStorageGateway {
2
+ get(key) {
3
+ const value = window.localStorage.getItem(key);
4
+ try {
5
+ return value ? JSON.parse(value) : null;
6
+ } catch {
7
+ return value;
8
+ }
9
+ }
10
+ set(key, value) {
11
+ const serialized = typeof value === "string" ? value : JSON.stringify(value);
12
+ window.localStorage.setItem(key, serialized);
13
+
14
+ // Dispatch local event so same-tab listeners are notified.
15
+ window.dispatchEvent(new CustomEvent("localstorage:changed", {
16
+ detail: {
17
+ key,
18
+ value,
19
+ action: "set"
20
+ }
21
+ }));
22
+ }
23
+ remove(key) {
24
+ window.localStorage.removeItem(key);
25
+ window.dispatchEvent(new CustomEvent("localstorage:changed", {
26
+ detail: {
27
+ key,
28
+ action: "remove"
29
+ }
30
+ }));
31
+ }
32
+ clear() {
33
+ window.localStorage.clear();
34
+ window.dispatchEvent(new CustomEvent("localstorage:changed", {
35
+ detail: {
36
+ action: "clear"
37
+ }
38
+ }));
39
+ }
40
+ getAll() {
41
+ const result = {};
42
+ for (let i = 0; i < window.localStorage.length; i++) {
43
+ const key = window.localStorage.key(i);
44
+ const val = this.get(key);
45
+ if (val !== null) {
46
+ result[key] = val;
47
+ }
48
+ }
49
+ return result;
50
+ }
51
+
52
+ // Subscribe to changes (cross-tab + same-tab)
53
+ subscribe(listener) {
54
+ const handler = ev => {
55
+ if (ev instanceof StorageEvent || ev instanceof CustomEvent) {
56
+ listener(ev);
57
+ }
58
+ };
59
+ window.addEventListener("storage", handler);
60
+ window.addEventListener("localstorage:changed", handler);
61
+ return () => {
62
+ window.removeEventListener("storage", handler);
63
+ window.removeEventListener("localstorage:changed", handler);
64
+ };
65
+ }
66
+ }
67
+
68
+ //# sourceMappingURL=BrowserLocalStorageGateway.js.map