@webiny/app 0.0.0-unstable.eb196ccd2f → 0.0.0-unstable.eb81deee7e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App.d.ts +5 -6
- package/App.js +75 -88
- package/App.js.map +1 -1
- package/AppContainer.js +3 -6
- package/AppContainer.js.map +1 -1
- package/README.md +7 -15
- package/components/Image.d.ts +1 -2
- package/components/Image.js +12 -18
- package/components/Image.js.map +1 -1
- package/components/index.d.ts +1 -2
- package/components/index.js +1 -4
- package/config/RouterConfig/Route.d.ts +9 -10
- package/config/RouterConfig/Route.js +23 -37
- package/config/RouterConfig/Route.js.map +1 -1
- package/config/RouterConfig.d.ts +11 -14
- package/config/RouterConfig.js +12 -11
- package/config/RouterConfig.js.map +1 -1
- package/config.js +19 -20
- package/config.js.map +1 -1
- package/contexts/Ui/index.js +26 -28
- package/contexts/Ui/index.js.map +1 -1
- package/core/Plugin.d.ts +1 -1
- package/core/Plugin.js +9 -11
- package/core/Plugin.js.map +1 -1
- package/core/Plugins.d.ts +4 -3
- package/core/Plugins.js +18 -36
- package/core/Plugins.js.map +1 -1
- package/core/Provider.d.ts +1 -1
- package/core/Provider.js +6 -14
- package/core/Provider.js.map +1 -1
- package/core/createProvider.js +3 -6
- package/core/createProvider.js.map +1 -1
- package/core/createProviderPlugin.js +9 -14
- package/core/createProviderPlugin.js.map +1 -1
- package/errors/AuthenticationErrorEvent.d.ts +9 -0
- package/errors/AuthenticationErrorEvent.js +13 -0
- package/errors/AuthenticationErrorEvent.js.map +1 -0
- package/errors/NetworkErrorEvent.d.ts +15 -0
- package/errors/NetworkErrorEvent.js +13 -0
- package/errors/NetworkErrorEvent.js.map +1 -0
- package/errors/abstractions.d.ts +12 -0
- package/errors/abstractions.js +6 -0
- package/errors/abstractions.js.map +1 -0
- package/errors/index.d.ts +6 -0
- package/errors/index.js +3 -0
- package/errors/overlay/ErrorOverlay.d.ts +9 -0
- package/errors/overlay/ErrorOverlay.js +43 -0
- package/errors/overlay/ErrorOverlay.js.map +1 -0
- package/{plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts → errors/overlay/GqlErrorOverlay.d.ts} +2 -2
- package/errors/overlay/GqlErrorOverlay.js +27 -0
- package/errors/overlay/GqlErrorOverlay.js.map +1 -0
- package/errors/overlay/LocalAwsLambdaTimeoutMessage.d.ts +2 -0
- package/errors/overlay/LocalAwsLambdaTimeoutMessage.js +20 -0
- package/errors/overlay/LocalAwsLambdaTimeoutMessage.js.map +1 -0
- package/errors/overlay/StyledComponents.d.ts +7 -0
- package/errors/overlay/StyledComponents.js +10 -0
- package/errors/overlay/StyledComponents.js.map +1 -0
- package/errors/overlay/Typography.d.ts +8 -0
- package/errors/overlay/Typography.js +13 -0
- package/errors/overlay/Typography.js.map +1 -0
- package/errors/overlay/assets/close_24px.js +19 -0
- package/errors/overlay/assets/close_24px.js.map +1 -0
- package/errors/overlay/createErrorOverlay.d.ts +7 -0
- package/errors/overlay/createErrorOverlay.js +15 -0
- package/errors/overlay/createErrorOverlay.js.map +1 -0
- package/exports/admin/env-config.d.ts +2 -0
- package/exports/admin/env-config.js +2 -0
- package/exports/admin/graphql-client.d.ts +1 -0
- package/exports/admin/graphql-client.js +1 -0
- package/exports/admin/local-storage.d.ts +2 -0
- package/exports/admin/local-storage.js +2 -0
- package/exports/admin/router.d.ts +5 -0
- package/exports/admin/router.js +5 -0
- package/exports/admin/security.d.ts +1 -0
- package/exports/admin/security.js +1 -0
- package/exports/admin.d.ts +8 -0
- package/exports/admin.js +8 -0
- package/features/apiStreamClient/FetchApiStreamClient.d.ts +9 -0
- package/features/apiStreamClient/FetchApiStreamClient.js +63 -0
- package/features/apiStreamClient/FetchApiStreamClient.js.map +1 -0
- package/features/apiStreamClient/__tests__/FetchApiStreamClient.test.d.ts +1 -0
- package/features/apiStreamClient/__tests__/FetchApiStreamClient.test.js +170 -0
- package/features/apiStreamClient/__tests__/FetchApiStreamClient.test.js.map +1 -0
- package/features/apiStreamClient/__tests__/readServerSentEvents.test.d.ts +1 -0
- package/features/apiStreamClient/__tests__/readServerSentEvents.test.js +160 -0
- package/features/apiStreamClient/__tests__/readServerSentEvents.test.js.map +1 -0
- package/features/apiStreamClient/abstractions.d.ts +44 -0
- package/features/apiStreamClient/abstractions.js +10 -0
- package/features/apiStreamClient/abstractions.js.map +1 -0
- package/features/apiStreamClient/feature.d.ts +3 -0
- package/features/apiStreamClient/feature.js +17 -0
- package/features/apiStreamClient/feature.js.map +1 -0
- package/features/apiStreamClient/index.d.ts +5 -0
- package/features/apiStreamClient/index.js +5 -0
- package/features/apiStreamClient/readServerSentEvents.d.ts +10 -0
- package/features/apiStreamClient/readServerSentEvents.js +29 -0
- package/features/apiStreamClient/readServerSentEvents.js.map +1 -0
- package/features/apiStreamClient/toPayloadHash.d.ts +14 -0
- package/features/apiStreamClient/toPayloadHash.js +7 -0
- package/features/apiStreamClient/toPayloadHash.js.map +1 -0
- package/features/envConfig/EnvConfig.d.ts +7 -0
- package/features/envConfig/EnvConfig.js +16 -0
- package/features/envConfig/EnvConfig.js.map +1 -0
- package/features/envConfig/abstractions.d.ts +28 -0
- package/features/envConfig/abstractions.js +5 -0
- package/features/envConfig/abstractions.js.map +1 -0
- package/features/envConfig/feature.d.ts +17 -0
- package/features/envConfig/feature.js +15 -0
- package/features/envConfig/feature.js.map +1 -0
- package/features/envConfig/index.d.ts +1 -0
- package/features/envConfig/index.js +1 -0
- package/features/eventPublisher/EventPublisher.d.ts +8 -0
- package/features/eventPublisher/EventPublisher.js +19 -0
- package/features/eventPublisher/EventPublisher.js.map +1 -0
- package/features/eventPublisher/abstractions.d.ts +18 -0
- package/features/eventPublisher/abstractions.js +12 -0
- package/features/eventPublisher/abstractions.js.map +1 -0
- package/features/eventPublisher/feature.d.ts +3 -0
- package/features/eventPublisher/feature.js +17 -0
- package/features/eventPublisher/feature.js.map +1 -0
- package/features/eventPublisher/index.d.ts +3 -0
- package/features/eventPublisher/index.js +2 -0
- package/features/graphqlClient/AuthenticationErrorPublishing.d.ts +13 -0
- package/features/graphqlClient/AuthenticationErrorPublishing.js +35 -0
- package/features/graphqlClient/AuthenticationErrorPublishing.js.map +1 -0
- package/features/graphqlClient/BatchingGraphQLClient.d.ts +16 -0
- package/features/graphqlClient/BatchingGraphQLClient.js +118 -0
- package/features/graphqlClient/BatchingGraphQLClient.js.map +1 -0
- package/features/graphqlClient/FetchGraphQLClient.d.ts +7 -0
- package/features/graphqlClient/FetchGraphQLClient.js +51 -0
- package/features/graphqlClient/FetchGraphQLClient.js.map +1 -0
- package/features/graphqlClient/NetworkErrorPublishing.d.ts +14 -0
- package/features/graphqlClient/NetworkErrorPublishing.js +48 -0
- package/features/graphqlClient/NetworkErrorPublishing.js.map +1 -0
- package/features/graphqlClient/RequestValue.d.ts +21 -0
- package/features/graphqlClient/RequestValue.js +46 -0
- package/features/graphqlClient/RequestValue.js.map +1 -0
- package/features/graphqlClient/RetryGraphQLClient.d.ts +18 -0
- package/features/graphqlClient/RetryGraphQLClient.js +45 -0
- package/features/graphqlClient/RetryGraphQLClient.js.map +1 -0
- package/features/graphqlClient/__tests__/GraphQLClient.test.d.ts +1 -0
- package/features/graphqlClient/__tests__/GraphQLClient.test.js +471 -0
- package/features/graphqlClient/__tests__/GraphQLClient.test.js.map +1 -0
- package/features/graphqlClient/abstractions.d.ts +18 -0
- package/features/graphqlClient/abstractions.js +5 -0
- package/features/graphqlClient/abstractions.js.map +1 -0
- package/features/graphqlClient/feature.d.ts +6 -0
- package/features/graphqlClient/feature.js +25 -0
- package/features/graphqlClient/feature.js.map +1 -0
- package/features/graphqlClient/index.d.ts +1 -0
- package/features/graphqlClient/index.js +1 -0
- package/features/graphqlClient/types.d.ts +5 -0
- package/features/graphqlClient/types.js +0 -0
- package/features/localStorage/BrowserLocalStorageGateway.d.ts +9 -0
- package/features/localStorage/BrowserLocalStorageGateway.js +61 -0
- package/features/localStorage/BrowserLocalStorageGateway.js.map +1 -0
- package/features/localStorage/LocalStorage.d.ts +12 -0
- package/features/localStorage/LocalStorage.js +34 -0
- package/features/localStorage/LocalStorage.js.map +1 -0
- package/features/localStorage/LocalStorageRepository.d.ts +20 -0
- package/features/localStorage/LocalStorageRepository.js +82 -0
- package/features/localStorage/LocalStorageRepository.js.map +1 -0
- package/features/localStorage/abstractions.d.ts +48 -0
- package/features/localStorage/abstractions.js +8 -0
- package/features/localStorage/abstractions.js.map +1 -0
- package/features/localStorage/feature.d.ts +12 -0
- package/features/localStorage/feature.js +23 -0
- package/features/localStorage/feature.js.map +1 -0
- package/features/localStorage/index.d.ts +1 -0
- package/features/localStorage/index.js +1 -0
- package/features/mainGraphQLClient/MainGraphQLClient.d.ts +11 -0
- package/features/mainGraphQLClient/MainGraphQLClient.js +27 -0
- package/features/mainGraphQLClient/MainGraphQLClient.js.map +1 -0
- package/features/mainGraphQLClient/abstractions.d.ts +17 -0
- package/features/mainGraphQLClient/abstractions.js +5 -0
- package/features/mainGraphQLClient/abstractions.js.map +1 -0
- package/features/mainGraphQLClient/feature.d.ts +3 -0
- package/features/mainGraphQLClient/feature.js +17 -0
- package/features/mainGraphQLClient/feature.js.map +1 -0
- package/features/mainGraphQLClient/index.d.ts +1 -0
- package/features/mainGraphQLClient/index.js +1 -0
- package/features/router/HistoryRouterGateway.d.ts +25 -0
- package/features/router/HistoryRouterGateway.js +100 -0
- package/features/router/HistoryRouterGateway.js.map +1 -0
- package/features/router/HistoryRouterGateway.test.d.ts +1 -0
- package/features/router/HistoryRouterGateway.test.js +195 -0
- package/features/router/HistoryRouterGateway.test.js.map +1 -0
- package/features/router/Route.d.ts +19 -0
- package/features/router/Route.js +43 -0
- package/features/router/Route.js.map +1 -0
- package/features/router/RouteUrl.d.ts +85 -0
- package/features/router/RouteUrl.js +99 -0
- package/features/router/RouteUrl.js.map +1 -0
- package/features/router/Router.d.ts +45 -0
- package/features/router/Router.js +72 -0
- package/features/router/Router.js.map +1 -0
- package/features/router/RouterPresenter.d.ts +23 -0
- package/features/router/RouterPresenter.js +62 -0
- package/features/router/RouterPresenter.js.map +1 -0
- package/features/router/RouterRepository.d.ts +32 -0
- package/features/router/RouterRepository.js +123 -0
- package/features/router/RouterRepository.js.map +1 -0
- package/features/router/RouterRepository.test.d.ts +1 -0
- package/features/router/RouterRepository.test.js +138 -0
- package/features/router/RouterRepository.test.js.map +1 -0
- package/features/router/abstractions.d.ts +90 -0
- package/features/router/abstractions.js +7 -0
- package/features/router/abstractions.js.map +1 -0
- package/features/router/feature.d.ts +4 -0
- package/features/router/feature.js +19 -0
- package/features/router/feature.js.map +1 -0
- package/features/router/index.d.ts +2 -0
- package/features/router/index.js +1 -0
- package/helpers/InterfaceGenerator/date.d.ts +15 -0
- package/helpers/InterfaceGenerator/date.js +0 -0
- package/helpers/InterfaceGenerator/id.d.ts +23 -0
- package/helpers/InterfaceGenerator/id.js +0 -0
- package/helpers/InterfaceGenerator/identity.d.ts +10 -0
- package/helpers/InterfaceGenerator/identity.js +0 -0
- package/helpers/InterfaceGenerator/index.d.ts +5 -0
- package/helpers/InterfaceGenerator/index.js +0 -0
- package/helpers/InterfaceGenerator/numeric.d.ts +12 -0
- package/helpers/InterfaceGenerator/numeric.js +0 -0
- package/helpers/InterfaceGenerator/truthful.d.ts +7 -0
- package/helpers/InterfaceGenerator/truthful.js +0 -0
- package/hooks/useHandler.js +12 -16
- package/hooks/useHandler.js.map +1 -1
- package/hooks/useHandlers.js +18 -20
- package/hooks/useHandlers.js.map +1 -1
- package/hooks/useRegisterLegacyPlugin.d.ts +1 -1
- package/hooks/useRegisterLegacyPlugin.js +7 -6
- package/hooks/useRegisterLegacyPlugin.js.map +1 -1
- package/hooks/useUi.d.ts +1 -1
- package/hooks/useUi.js +3 -4
- package/hooks/useUi.js.map +1 -1
- package/i18n/i18n.js +8 -4
- package/i18n/i18n.js.map +1 -1
- package/i18n/index.d.ts +1 -1
- package/i18n/index.js +1 -3
- package/index.d.ts +20 -15
- package/index.js +19 -19
- package/package.json +34 -42
- package/plugins/components/Image.d.ts +6 -0
- package/plugins/components/Image.js +12 -0
- package/plugins/components/Image.js.map +1 -0
- package/plugins/image.d.ts +2 -2
- package/plugins/image.js +95 -134
- package/plugins/image.js.map +1 -1
- package/plugins/index.d.ts +3 -3
- package/plugins/index.js +35 -59
- package/plugins/index.js.map +1 -1
- package/presentation/envConfig/useEnvConfig.d.ts +6 -0
- package/presentation/envConfig/useEnvConfig.js +9 -0
- package/presentation/envConfig/useEnvConfig.js.map +1 -0
- package/presentation/localStorage/index.d.ts +3 -0
- package/presentation/localStorage/index.js +3 -0
- package/presentation/localStorage/useLocalStorage.d.ts +6 -0
- package/presentation/localStorage/useLocalStorage.js +15 -0
- package/presentation/localStorage/useLocalStorage.js.map +1 -0
- package/presentation/localStorage/useLocalStorageValue.d.ts +1 -0
- package/presentation/localStorage/useLocalStorageValue.js +22 -0
- package/presentation/localStorage/useLocalStorageValue.js.map +1 -0
- package/presentation/localStorage/useLocalStorageValues.d.ts +5 -0
- package/presentation/localStorage/useLocalStorageValues.js +32 -0
- package/presentation/localStorage/useLocalStorageValues.js.map +1 -0
- package/presentation/router/RouteElementRegistry.d.ts +14 -0
- package/presentation/router/RouteElementRegistry.js +29 -0
- package/presentation/router/RouteElementRegistry.js.map +1 -0
- package/presentation/router/abstractions.d.ts +13 -0
- package/presentation/router/abstractions.js +5 -0
- package/presentation/router/abstractions.js.map +1 -0
- package/presentation/router/components/Redirect.d.ts +14 -0
- package/presentation/router/components/Redirect.js +13 -0
- package/presentation/router/components/Redirect.js.map +1 -0
- package/presentation/router/components/RouteContent.d.ts +2 -0
- package/presentation/router/components/RouteContent.js +20 -0
- package/presentation/router/components/RouteContent.js.map +1 -0
- package/presentation/router/components/RouteLink.d.ts +50 -0
- package/presentation/router/components/RouteLink.js +17 -0
- package/presentation/router/components/RouteLink.js.map +1 -0
- package/presentation/router/components/RouteParamsSync.d.ts +22 -0
- package/presentation/router/components/RouteParamsSync.js +53 -0
- package/presentation/router/components/RouteParamsSync.js.map +1 -0
- package/presentation/router/components/SimpleLink.d.ts +44 -0
- package/presentation/router/components/SimpleLink.js +24 -0
- package/presentation/router/components/SimpleLink.js.map +1 -0
- package/presentation/router/hooks/useRoute.d.ts +7 -0
- package/presentation/router/hooks/useRoute.js +23 -0
- package/presentation/router/hooks/useRoute.js.map +1 -0
- package/presentation/router/hooks/useRouter.d.ts +12 -0
- package/presentation/router/hooks/useRouter.js +30 -0
- package/presentation/router/hooks/useRouter.js.map +1 -0
- package/presentation/router/index.d.ts +6 -0
- package/presentation/router/index.js +4 -0
- package/presentation/router/types.d.ts +5 -0
- package/presentation/router/types.js +0 -0
- package/renderApp.d.ts +1 -1
- package/renderApp.js +7 -6
- package/renderApp.js.map +1 -1
- package/router.d.ts +5 -0
- package/router.js +5 -0
- package/rslib-runtime.js +14 -0
- package/rslib-runtime.js.map +1 -0
- package/shared/di/DiContainerProvider.d.ts +8 -0
- package/shared/di/DiContainerProvider.js +13 -0
- package/shared/di/DiContainerProvider.js.map +1 -0
- package/shared/di/createFeature.d.ts +11 -0
- package/shared/di/createFeature.js +10 -0
- package/shared/di/createFeature.js.map +1 -0
- package/shared/di/useFeature.d.ts +2 -0
- package/shared/di/useFeature.js +12 -0
- package/shared/di/useFeature.js.map +1 -0
- package/static/svg/close_24px.33adaadc.svg +1 -0
- package/types.d.ts +6 -24
- package/types.js +0 -14
- package/utils/createGenericContext.js +17 -21
- package/utils/createGenericContext.js.map +1 -1
- package/utils/createHashing.js +13 -16
- package/utils/createHashing.js.map +1 -1
- package/utils/index.d.ts +2 -10
- package/utils/index.js +2 -12
- package/utils/legacyPluginToReactComponent.js +12 -11
- package/utils/legacyPluginToReactComponent.js.map +1 -1
- package/apollo-client/InMemoryCache.d.ts +0 -8
- package/apollo-client/InMemoryCache.js +0 -20
- package/apollo-client/InMemoryCache.js.map +0 -1
- package/apollo-client/IntrospectionFragmentMatcher.d.ts +0 -11
- package/apollo-client/IntrospectionFragmentMatcher.js +0 -45
- package/apollo-client/IntrospectionFragmentMatcher.js.map +0 -1
- package/components/Routes.d.ts +0 -2
- package/components/Routes.js +0 -36
- package/components/Routes.js.map +0 -1
- package/components/View.d.ts +0 -8
- package/components/View.js +0 -19
- package/components/View.js.map +0 -1
- package/components/index.js.map +0 -1
- package/core/DebounceRender.d.ts +0 -12
- package/core/DebounceRender.js +0 -31
- package/core/DebounceRender.js.map +0 -1
- package/core/Routes.d.ts +0 -6
- package/core/Routes.js +0 -34
- package/core/Routes.js.map +0 -1
- package/hooks/useAutocomplete/index.d.ts +0 -1
- package/hooks/useAutocomplete/index.js +0 -3
- package/hooks/useAutocomplete/index.js.map +0 -1
- package/hooks/useAutocomplete/useAutocomplete.d.ts +0 -11
- package/hooks/useAutocomplete/useAutocomplete.js +0 -23
- package/hooks/useAutocomplete/useAutocomplete.js.map +0 -1
- package/hooks/useDataList/functions/getData.d.ts +0 -2
- package/hooks/useDataList/functions/getData.js +0 -4
- package/hooks/useDataList/functions/getData.js.map +0 -1
- package/hooks/useDataList/functions/getError.d.ts +0 -2
- package/hooks/useDataList/functions/getError.js +0 -4
- package/hooks/useDataList/functions/getError.js.map +0 -1
- package/hooks/useDataList/functions/getMeta.d.ts +0 -2
- package/hooks/useDataList/functions/getMeta.js +0 -4
- package/hooks/useDataList/functions/getMeta.js.map +0 -1
- package/hooks/useDataList/functions/index.d.ts +0 -3
- package/hooks/useDataList/functions/index.js +0 -5
- package/hooks/useDataList/functions/index.js.map +0 -1
- package/hooks/useDataList/functions/searchDataByKey.d.ts +0 -2
- package/hooks/useDataList/functions/searchDataByKey.js +0 -18
- package/hooks/useDataList/functions/searchDataByKey.js.map +0 -1
- package/hooks/useDataList/index.d.ts +0 -1
- package/hooks/useDataList/index.js +0 -3
- package/hooks/useDataList/index.js.map +0 -1
- package/hooks/useDataList/useDataList.d.ts +0 -36
- package/hooks/useDataList/useDataList.js +0 -183
- package/hooks/useDataList/useDataList.js.map +0 -1
- package/hooks/useDataList/utils/index.d.ts +0 -2
- package/hooks/useDataList/utils/index.js +0 -4
- package/hooks/useDataList/utils/index.js.map +0 -1
- package/hooks/useDataList/utils/prepareLoadListParams.d.ts +0 -10
- package/hooks/useDataList/utils/prepareLoadListParams.js +0 -38
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +0 -1
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.d.ts +0 -14
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +0 -26
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +0 -1
- package/hooks/useDataList/utils/types.d.ts +0 -40
- package/hooks/useDataList/utils/types.js +0 -3
- package/hooks/useDataList/utils/types.js.map +0 -1
- package/i18n/index.js.map +0 -1
- package/index.js.map +0 -1
- package/plugins/AddQuerySelectionPlugin.d.ts +0 -22
- package/plugins/AddQuerySelectionPlugin.js +0 -72
- package/plugins/AddQuerySelectionPlugin.js.map +0 -1
- package/plugins/ApolloCacheObjectIdPlugin.d.ts +0 -15
- package/plugins/ApolloCacheObjectIdPlugin.js +0 -16
- package/plugins/ApolloCacheObjectIdPlugin.js.map +0 -1
- package/plugins/ApolloDynamicLink.d.ts +0 -7
- package/plugins/ApolloDynamicLink.js +0 -31
- package/plugins/ApolloDynamicLink.js.map +0 -1
- package/plugins/ApolloLinkPlugin.d.ts +0 -13
- package/plugins/ApolloLinkPlugin.js +0 -22
- package/plugins/ApolloLinkPlugin.js.map +0 -1
- package/plugins/ConsoleLinkPlugin.d.ts +0 -8
- package/plugins/ConsoleLinkPlugin.js +0 -26
- package/plugins/ConsoleLinkPlugin.js.map +0 -1
- package/plugins/LocaleHeaderLinkPlugin.d.ts +0 -10
- package/plugins/LocaleHeaderLinkPlugin.js +0 -32
- package/plugins/LocaleHeaderLinkPlugin.js.map +0 -1
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +0 -66
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +0 -1
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +0 -9
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +0 -78
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +0 -1
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.d.ts +0 -7
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +0 -31
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +0 -1
- package/plugins/NetworkErrorLinkPlugin.d.ts +0 -7
- package/plugins/NetworkErrorLinkPlugin.js +0 -30
- package/plugins/NetworkErrorLinkPlugin.js.map +0 -1
- package/plugins/OmitTypenameLinkPlugin.d.ts +0 -8
- package/plugins/OmitTypenameLinkPlugin.js +0 -21
- package/plugins/OmitTypenameLinkPlugin.js.map +0 -1
- package/plugins/RoutePlugin.d.ts +0 -12
- package/plugins/RoutePlugin.js +0 -16
- package/plugins/RoutePlugin.js.map +0 -1
- package/plugins/TenantHeaderLinkPlugin.d.ts +0 -10
- package/plugins/TenantHeaderLinkPlugin.js +0 -39
- package/plugins/TenantHeaderLinkPlugin.js.map +0 -1
- package/plugins/ViewPlugin.d.ts +0 -14
- package/plugins/ViewPlugin.js +0 -19
- package/plugins/ViewPlugin.js.map +0 -1
- package/react-butterfiles/Files.d.ts +0 -69
- package/react-butterfiles/Files.js +0 -227
- package/react-butterfiles/Files.js.map +0 -1
- package/react-butterfiles/index.d.ts +0 -2
- package/react-butterfiles/index.js +0 -4
- package/react-butterfiles/index.js.map +0 -1
- package/react-butterfiles/utils/generateId.d.ts +0 -1
- package/react-butterfiles/utils/generateId.js +0 -5
- package/react-butterfiles/utils/generateId.js.map +0 -1
- package/react-butterfiles/utils/readFileContent.d.ts +0 -1
- package/react-butterfiles/utils/readFileContent.js +0 -15
- package/react-butterfiles/utils/readFileContent.js.map +0 -1
- package/types.js.map +0 -1
- package/utils/getApiUrl.d.ts +0 -1
- package/utils/getApiUrl.js +0 -5
- package/utils/getApiUrl.js.map +0 -1
- package/utils/getGqlApiUrl.d.ts +0 -1
- package/utils/getGqlApiUrl.js +0 -6
- package/utils/getGqlApiUrl.js.map +0 -1
- package/utils/getHeadlessCmsGqlApiUrl.d.ts +0 -5
- package/utils/getHeadlessCmsGqlApiUrl.js +0 -12
- package/utils/getHeadlessCmsGqlApiUrl.js.map +0 -1
- package/utils/getLocaleCode.d.ts +0 -6
- package/utils/getLocaleCode.js +0 -33
- package/utils/getLocaleCode.js.map +0 -1
- package/utils/getPrerenderId.d.ts +0 -6
- package/utils/getPrerenderId.js +0 -5
- package/utils/getPrerenderId.js.map +0 -1
- package/utils/getTenantId.d.ts +0 -6
- package/utils/getTenantId.js +0 -45
- package/utils/getTenantId.js.map +0 -1
- package/utils/index.js.map +0 -1
- package/utils/isLocalhost.d.ts +0 -1
- package/utils/isLocalhost.js +0 -7
- package/utils/isLocalhost.js.map +0 -1
- package/utils/isPrerendering.d.ts +0 -1
- package/utils/isPrerendering.js +0 -5
- package/utils/isPrerendering.js.map +0 -1
- /package/{plugins/NetworkErrorLinkPlugin → errors/overlay}/assets/close_24px.svg +0 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { readServerSentEvents } from "../readServerSentEvents.js";
|
|
3
|
+
const encoder = new TextEncoder();
|
|
4
|
+
function responseFrom(chunks) {
|
|
5
|
+
const stream = new ReadableStream({
|
|
6
|
+
start (controller) {
|
|
7
|
+
for (const chunk of chunks)controller.enqueue("string" == typeof chunk ? encoder.encode(chunk) : chunk);
|
|
8
|
+
controller.close();
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
return {
|
|
12
|
+
body: stream
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
async function collect(response) {
|
|
16
|
+
const events = [];
|
|
17
|
+
for await (const event of readServerSentEvents(response))events.push(event);
|
|
18
|
+
return events;
|
|
19
|
+
}
|
|
20
|
+
describe("readServerSentEvents", ()=>{
|
|
21
|
+
it("should parse one event per record", async ()=>{
|
|
22
|
+
const events = await collect(responseFrom([
|
|
23
|
+
'data: {"type":"start"}\n\n',
|
|
24
|
+
'data: {"type":"done"}\n\n'
|
|
25
|
+
]));
|
|
26
|
+
expect(events).toEqual([
|
|
27
|
+
{
|
|
28
|
+
type: "start"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: "done"
|
|
32
|
+
}
|
|
33
|
+
]);
|
|
34
|
+
});
|
|
35
|
+
it("should parse multiple records arriving in a single chunk", async ()=>{
|
|
36
|
+
const events = await collect(responseFrom([
|
|
37
|
+
'data: {"n":1}\n\ndata: {"n":2}\n\ndata: {"n":3}\n\n'
|
|
38
|
+
]));
|
|
39
|
+
expect(events).toEqual([
|
|
40
|
+
{
|
|
41
|
+
n: 1
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
n: 2
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
n: 3
|
|
48
|
+
}
|
|
49
|
+
]);
|
|
50
|
+
});
|
|
51
|
+
it("should parse a record split across chunks", async ()=>{
|
|
52
|
+
const events = await collect(responseFrom([
|
|
53
|
+
'data: {"ty',
|
|
54
|
+
'pe":"partial"}',
|
|
55
|
+
"\n\n"
|
|
56
|
+
]));
|
|
57
|
+
expect(events).toEqual([
|
|
58
|
+
{
|
|
59
|
+
type: "partial"
|
|
60
|
+
}
|
|
61
|
+
]);
|
|
62
|
+
});
|
|
63
|
+
it("should handle CRLF line endings", async ()=>{
|
|
64
|
+
const events = await collect(responseFrom([
|
|
65
|
+
'data: {"ok":true}\r\n\r\n'
|
|
66
|
+
]));
|
|
67
|
+
expect(events).toEqual([
|
|
68
|
+
{
|
|
69
|
+
ok: true
|
|
70
|
+
}
|
|
71
|
+
]);
|
|
72
|
+
});
|
|
73
|
+
it("should ignore comments and non-data fields", async ()=>{
|
|
74
|
+
const events = await collect(responseFrom([
|
|
75
|
+
": heartbeat\n\n",
|
|
76
|
+
'event: message\nid: 7\nretry: 500\ndata: {"kept":true}\n\n'
|
|
77
|
+
]));
|
|
78
|
+
expect(events).toEqual([
|
|
79
|
+
{
|
|
80
|
+
kept: true
|
|
81
|
+
}
|
|
82
|
+
]);
|
|
83
|
+
});
|
|
84
|
+
it("should join multi-line data fields", async ()=>{
|
|
85
|
+
const events = await collect(responseFrom([
|
|
86
|
+
'data: {"a":1,\ndata: "b":2}\n\n'
|
|
87
|
+
]));
|
|
88
|
+
expect(events).toEqual([
|
|
89
|
+
{
|
|
90
|
+
a: 1,
|
|
91
|
+
b: 2
|
|
92
|
+
}
|
|
93
|
+
]);
|
|
94
|
+
});
|
|
95
|
+
it("should preserve multi-byte characters split across chunks", async ()=>{
|
|
96
|
+
const payload = encoder.encode('data: {"text":"café"}\n\n');
|
|
97
|
+
const split = 18;
|
|
98
|
+
const events = await collect(responseFrom([
|
|
99
|
+
payload.slice(0, split),
|
|
100
|
+
payload.slice(split)
|
|
101
|
+
]));
|
|
102
|
+
expect(events).toEqual([
|
|
103
|
+
{
|
|
104
|
+
text: "café"
|
|
105
|
+
}
|
|
106
|
+
]);
|
|
107
|
+
});
|
|
108
|
+
it("should drop a trailing record that never terminated", async ()=>{
|
|
109
|
+
const events = await collect(responseFrom([
|
|
110
|
+
'data: {"complete":true}\n\ndata: {"trunc'
|
|
111
|
+
]));
|
|
112
|
+
expect(events).toEqual([
|
|
113
|
+
{
|
|
114
|
+
complete: true
|
|
115
|
+
}
|
|
116
|
+
]);
|
|
117
|
+
});
|
|
118
|
+
it("should yield events as they arrive rather than after the stream closes", async ()=>{
|
|
119
|
+
let released;
|
|
120
|
+
const gate = new Promise((resolve)=>{
|
|
121
|
+
released = resolve;
|
|
122
|
+
});
|
|
123
|
+
const stream = new ReadableStream({
|
|
124
|
+
async start (controller) {
|
|
125
|
+
controller.enqueue(encoder.encode('data: {"n":1}\n\n'));
|
|
126
|
+
await gate;
|
|
127
|
+
controller.enqueue(encoder.encode('data: {"n":2}\n\n'));
|
|
128
|
+
controller.close();
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
const iterator = readServerSentEvents({
|
|
132
|
+
body: stream
|
|
133
|
+
});
|
|
134
|
+
expect((await iterator.next()).value).toEqual({
|
|
135
|
+
n: 1
|
|
136
|
+
});
|
|
137
|
+
released();
|
|
138
|
+
expect((await iterator.next()).value).toEqual({
|
|
139
|
+
n: 2
|
|
140
|
+
});
|
|
141
|
+
expect((await iterator.next()).done).toBe(true);
|
|
142
|
+
});
|
|
143
|
+
it("should throw when the response has no body", async ()=>{
|
|
144
|
+
await expect(collect({
|
|
145
|
+
body: null
|
|
146
|
+
})).rejects.toThrow("The response carried no readable body.");
|
|
147
|
+
});
|
|
148
|
+
it("should propagate a stream error", async ()=>{
|
|
149
|
+
const stream = new ReadableStream({
|
|
150
|
+
start (controller) {
|
|
151
|
+
controller.error(new Error("stream broke"));
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
await expect(collect({
|
|
155
|
+
body: stream
|
|
156
|
+
})).rejects.toThrow("stream broke");
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
//# sourceMappingURL=readServerSentEvents.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/apiStreamClient/__tests__/readServerSentEvents.test.js","sources":["../../../../src/features/apiStreamClient/__tests__/readServerSentEvents.test.ts"],"sourcesContent":["import { describe, it, expect } from \"vitest\";\nimport { readServerSentEvents } from \"../readServerSentEvents.js\";\n\nconst encoder = new TextEncoder();\n\nfunction responseFrom(chunks: (string | Uint8Array)[]): Response {\n const stream = new ReadableStream<Uint8Array>({\n start(controller) {\n for (const chunk of chunks) {\n controller.enqueue(typeof chunk === \"string\" ? encoder.encode(chunk) : chunk);\n }\n controller.close();\n }\n });\n\n return { body: stream } as Response;\n}\n\nasync function collect<T>(response: Response): Promise<T[]> {\n const events: T[] = [];\n for await (const event of readServerSentEvents<T>(response)) {\n events.push(event);\n }\n return events;\n}\n\ndescribe(\"readServerSentEvents\", () => {\n it(\"should parse one event per record\", async () => {\n const events = await collect(\n responseFrom(['data: {\"type\":\"start\"}\\n\\n', 'data: {\"type\":\"done\"}\\n\\n'])\n );\n\n expect(events).toEqual([{ type: \"start\" }, { type: \"done\" }]);\n });\n\n it(\"should parse multiple records arriving in a single chunk\", async () => {\n const events = await collect(\n responseFrom(['data: {\"n\":1}\\n\\ndata: {\"n\":2}\\n\\ndata: {\"n\":3}\\n\\n'])\n );\n\n expect(events).toEqual([{ n: 1 }, { n: 2 }, { n: 3 }]);\n });\n\n it(\"should parse a record split across chunks\", async () => {\n const events = await collect(responseFrom(['data: {\"ty', 'pe\":\"partial\"}', \"\\n\\n\"]));\n\n expect(events).toEqual([{ type: \"partial\" }]);\n });\n\n it(\"should handle CRLF line endings\", async () => {\n const events = await collect(responseFrom(['data: {\"ok\":true}\\r\\n\\r\\n']));\n\n expect(events).toEqual([{ ok: true }]);\n });\n\n it(\"should ignore comments and non-data fields\", async () => {\n const events = await collect(\n responseFrom([\n \": heartbeat\\n\\n\",\n 'event: message\\nid: 7\\nretry: 500\\ndata: {\"kept\":true}\\n\\n'\n ])\n );\n\n expect(events).toEqual([{ kept: true }]);\n });\n\n it(\"should join multi-line data fields\", async () => {\n const events = await collect(responseFrom(['data: {\"a\":1,\\ndata: \"b\":2}\\n\\n']));\n\n expect(events).toEqual([{ a: 1, b: 2 }]);\n });\n\n it(\"should preserve multi-byte characters split across chunks\", async () => {\n const payload = encoder.encode('data: {\"text\":\"café\"}\\n\\n');\n const split = 18;\n\n const events = await collect(responseFrom([payload.slice(0, split), payload.slice(split)]));\n\n expect(events).toEqual([{ text: \"café\" }]);\n });\n\n it(\"should drop a trailing record that never terminated\", async () => {\n // A truncated stream (server died mid-record) must not yield a half-parsed event.\n const events = await collect(responseFrom(['data: {\"complete\":true}\\n\\ndata: {\"trunc']));\n\n expect(events).toEqual([{ complete: true }]);\n });\n\n it(\"should yield events as they arrive rather than after the stream closes\", async () => {\n let released!: () => void;\n const gate = new Promise<void>(resolve => {\n released = resolve;\n });\n\n const stream = new ReadableStream<Uint8Array>({\n async start(controller) {\n controller.enqueue(encoder.encode('data: {\"n\":1}\\n\\n'));\n await gate;\n controller.enqueue(encoder.encode('data: {\"n\":2}\\n\\n'));\n controller.close();\n }\n });\n\n const iterator = readServerSentEvents<{ n: number }>({ body: stream } as Response);\n\n // Resolving before the gate opens proves events aren't buffered until close.\n expect((await iterator.next()).value).toEqual({ n: 1 });\n released();\n expect((await iterator.next()).value).toEqual({ n: 2 });\n expect((await iterator.next()).done).toBe(true);\n });\n\n it(\"should throw when the response has no body\", async () => {\n await expect(collect({ body: null } as Response)).rejects.toThrow(\n \"The response carried no readable body.\"\n );\n });\n\n it(\"should propagate a stream error\", async () => {\n const stream = new ReadableStream<Uint8Array>({\n start(controller) {\n controller.error(new Error(\"stream broke\"));\n }\n });\n\n await expect(collect({ body: stream } as Response)).rejects.toThrow(\"stream broke\");\n });\n});\n"],"names":["encoder","TextEncoder","responseFrom","chunks","stream","ReadableStream","controller","chunk","collect","response","events","event","readServerSentEvents","describe","it","expect","payload","split","released","gate","Promise","resolve","iterator","Error"],"mappings":";;AAGA,MAAMA,UAAU,IAAIC;AAEpB,SAASC,aAAaC,MAA+B;IACjD,MAAMC,SAAS,IAAIC,eAA2B;QAC1C,OAAMC,UAAU;YACZ,KAAK,MAAMC,SAASJ,OAChBG,WAAW,OAAO,CAAC,AAAiB,YAAjB,OAAOC,QAAqBP,QAAQ,MAAM,CAACO,SAASA;YAE3ED,WAAW,KAAK;QACpB;IACJ;IAEA,OAAO;QAAE,MAAMF;IAAO;AAC1B;AAEA,eAAeI,QAAWC,QAAkB;IACxC,MAAMC,SAAc,EAAE;IACtB,WAAW,MAAMC,SAASC,qBAAwBH,UAC9CC,OAAO,IAAI,CAACC;IAEhB,OAAOD;AACX;AAEAG,SAAS,wBAAwB;IAC7BC,GAAG,qCAAqC;QACpC,MAAMJ,SAAS,MAAMF,QACjBN,aAAa;YAAC;YAA8B;SAA4B;QAG5Ea,OAAOL,QAAQ,OAAO,CAAC;YAAC;gBAAE,MAAM;YAAQ;YAAG;gBAAE,MAAM;YAAO;SAAE;IAChE;IAEAI,GAAG,4DAA4D;QAC3D,MAAMJ,SAAS,MAAMF,QACjBN,aAAa;YAAC;SAAsD;QAGxEa,OAAOL,QAAQ,OAAO,CAAC;YAAC;gBAAE,GAAG;YAAE;YAAG;gBAAE,GAAG;YAAE;YAAG;gBAAE,GAAG;YAAE;SAAE;IACzD;IAEAI,GAAG,6CAA6C;QAC5C,MAAMJ,SAAS,MAAMF,QAAQN,aAAa;YAAC;YAAc;YAAkB;SAAO;QAElFa,OAAOL,QAAQ,OAAO,CAAC;YAAC;gBAAE,MAAM;YAAU;SAAE;IAChD;IAEAI,GAAG,mCAAmC;QAClC,MAAMJ,SAAS,MAAMF,QAAQN,aAAa;YAAC;SAA4B;QAEvEa,OAAOL,QAAQ,OAAO,CAAC;YAAC;gBAAE,IAAI;YAAK;SAAE;IACzC;IAEAI,GAAG,8CAA8C;QAC7C,MAAMJ,SAAS,MAAMF,QACjBN,aAAa;YACT;YACA;SACH;QAGLa,OAAOL,QAAQ,OAAO,CAAC;YAAC;gBAAE,MAAM;YAAK;SAAE;IAC3C;IAEAI,GAAG,sCAAsC;QACrC,MAAMJ,SAAS,MAAMF,QAAQN,aAAa;YAAC;SAAkC;QAE7Ea,OAAOL,QAAQ,OAAO,CAAC;YAAC;gBAAE,GAAG;gBAAG,GAAG;YAAE;SAAE;IAC3C;IAEAI,GAAG,6DAA6D;QAC5D,MAAME,UAAUhB,QAAQ,MAAM,CAAC;QAC/B,MAAMiB,QAAQ;QAEd,MAAMP,SAAS,MAAMF,QAAQN,aAAa;YAACc,QAAQ,KAAK,CAAC,GAAGC;YAAQD,QAAQ,KAAK,CAACC;SAAO;QAEzFF,OAAOL,QAAQ,OAAO,CAAC;YAAC;gBAAE,MAAM;YAAO;SAAE;IAC7C;IAEAI,GAAG,uDAAuD;QAEtD,MAAMJ,SAAS,MAAMF,QAAQN,aAAa;YAAC;SAA2C;QAEtFa,OAAOL,QAAQ,OAAO,CAAC;YAAC;gBAAE,UAAU;YAAK;SAAE;IAC/C;IAEAI,GAAG,0EAA0E;QACzE,IAAII;QACJ,MAAMC,OAAO,IAAIC,QAAcC,CAAAA;YAC3BH,WAAWG;QACf;QAEA,MAAMjB,SAAS,IAAIC,eAA2B;YAC1C,MAAM,OAAMC,UAAU;gBAClBA,WAAW,OAAO,CAACN,QAAQ,MAAM,CAAC;gBAClC,MAAMmB;gBACNb,WAAW,OAAO,CAACN,QAAQ,MAAM,CAAC;gBAClCM,WAAW,KAAK;YACpB;QACJ;QAEA,MAAMgB,WAAWV,qBAAoC;YAAE,MAAMR;QAAO;QAGpEW,OAAQ,OAAMO,SAAS,IAAI,EAAC,EAAG,KAAK,EAAE,OAAO,CAAC;YAAE,GAAG;QAAE;QACrDJ;QACAH,OAAQ,OAAMO,SAAS,IAAI,EAAC,EAAG,KAAK,EAAE,OAAO,CAAC;YAAE,GAAG;QAAE;QACrDP,OAAQ,OAAMO,SAAS,IAAI,EAAC,EAAG,IAAI,EAAE,IAAI,CAAC;IAC9C;IAEAR,GAAG,8CAA8C;QAC7C,MAAMC,OAAOP,QAAQ;YAAE,MAAM;QAAK,IAAgB,OAAO,CAAC,OAAO,CAC7D;IAER;IAEAM,GAAG,mCAAmC;QAClC,MAAMV,SAAS,IAAIC,eAA2B;YAC1C,OAAMC,UAAU;gBACZA,WAAW,KAAK,CAAC,IAAIiB,MAAM;YAC/B;QACJ;QAEA,MAAMR,OAAOP,QAAQ;YAAE,MAAMJ;QAAO,IAAgB,OAAO,CAAC,OAAO,CAAC;IACxE;AACJ"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
type IHeaders = Record<string, string | number | undefined>;
|
|
2
|
+
/**
|
|
3
|
+
* The raw `fetch` response, handed to the caller unread so it owns the read loop. Aliased through
|
|
4
|
+
* the abstraction so consumers name the contract rather than the DOM type it currently happens to
|
|
5
|
+
* be — and so `ApiStreamClient.Response` reads as the counterpart to `ApiStreamClient.Request`.
|
|
6
|
+
*/
|
|
7
|
+
type IApiStreamResponse = globalThis.Response;
|
|
8
|
+
export interface IApiStreamRequest {
|
|
9
|
+
/** Path relative to the API root, e.g. `/stream/fm/files/abc/enrich`. */
|
|
10
|
+
path: string;
|
|
11
|
+
/** Serialized as JSON when present. */
|
|
12
|
+
body?: unknown;
|
|
13
|
+
headers?: IHeaders;
|
|
14
|
+
/**
|
|
15
|
+
* Aborts the request AND the caller's read loop. Streaming responses stay open for as long as the
|
|
16
|
+
* producer runs, so without this a caller that navigates away or closes its UI would leave the
|
|
17
|
+
* connection open and keep consuming events into a component that no longer exists.
|
|
18
|
+
*/
|
|
19
|
+
signal?: AbortSignal;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Client for API endpoints that stream their response.
|
|
23
|
+
*
|
|
24
|
+
* Deliberately separate from `GraphQLClient`: that abstraction returns `Promise<TResult>` — a
|
|
25
|
+
* buffered contract by type — and Webiny's GraphQL layer (graphql-js 16) has no incremental
|
|
26
|
+
* delivery, so a streaming response can't travel through it. This returns the raw `Response` so the
|
|
27
|
+
* caller owns the read loop and can hand `response.body` to any stream consumer.
|
|
28
|
+
*/
|
|
29
|
+
export interface IApiStreamClient {
|
|
30
|
+
execute(params: IApiStreamRequest): Promise<IApiStreamResponse>;
|
|
31
|
+
}
|
|
32
|
+
export declare const ApiStreamClient: import("@webiny/di").Abstraction<IApiStreamClient>;
|
|
33
|
+
export declare namespace ApiStreamClient {
|
|
34
|
+
type Headers = IHeaders;
|
|
35
|
+
type Interface = IApiStreamClient;
|
|
36
|
+
type Request = IApiStreamRequest;
|
|
37
|
+
type Response = IApiStreamResponse;
|
|
38
|
+
}
|
|
39
|
+
export declare class ApiStreamRequestError extends Error {
|
|
40
|
+
readonly statusCode: number;
|
|
41
|
+
readonly code?: string | undefined;
|
|
42
|
+
constructor(message: string, statusCode: number, code?: string | undefined);
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/admin";
|
|
2
|
+
const ApiStreamClient = createAbstraction("ApiStreamClient");
|
|
3
|
+
class ApiStreamRequestError extends Error {
|
|
4
|
+
constructor(message, statusCode, code){
|
|
5
|
+
super(message), this.statusCode = statusCode, this.code = code;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export { ApiStreamClient, ApiStreamRequestError };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/apiStreamClient/abstractions.js","sources":["../../../src/features/apiStreamClient/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\n\ntype IHeaders = Record<string, string | number | undefined>;\n\n/**\n * The raw `fetch` response, handed to the caller unread so it owns the read loop. Aliased through\n * the abstraction so consumers name the contract rather than the DOM type it currently happens to\n * be — and so `ApiStreamClient.Response` reads as the counterpart to `ApiStreamClient.Request`.\n */\ntype IApiStreamResponse = globalThis.Response;\n\nexport interface IApiStreamRequest {\n /** Path relative to the API root, e.g. `/stream/fm/files/abc/enrich`. */\n path: string;\n /** Serialized as JSON when present. */\n body?: unknown;\n headers?: IHeaders;\n /**\n * Aborts the request AND the caller's read loop. Streaming responses stay open for as long as the\n * producer runs, so without this a caller that navigates away or closes its UI would leave the\n * connection open and keep consuming events into a component that no longer exists.\n */\n signal?: AbortSignal;\n}\n\n/**\n * Client for API endpoints that stream their response.\n *\n * Deliberately separate from `GraphQLClient`: that abstraction returns `Promise<TResult>` — a\n * buffered contract by type — and Webiny's GraphQL layer (graphql-js 16) has no incremental\n * delivery, so a streaming response can't travel through it. This returns the raw `Response` so the\n * caller owns the read loop and can hand `response.body` to any stream consumer.\n */\nexport interface IApiStreamClient {\n execute(params: IApiStreamRequest): Promise<IApiStreamResponse>;\n}\n\nexport const ApiStreamClient = createAbstraction<IApiStreamClient>(\"ApiStreamClient\");\n\nexport namespace ApiStreamClient {\n export type Headers = IHeaders;\n export type Interface = IApiStreamClient;\n export type Request = IApiStreamRequest;\n export type Response = IApiStreamResponse;\n}\n\nexport class ApiStreamRequestError extends Error {\n constructor(\n message: string,\n readonly statusCode: number,\n readonly code?: string\n ) {\n super(message);\n }\n}\n"],"names":["ApiStreamClient","createAbstraction","ApiStreamRequestError","Error","message","statusCode","code"],"mappings":";AAqCO,MAAMA,kBAAkBC,kBAAoC;AAS5D,MAAMC,8BAA8BC;IACvC,YACIC,OAAe,EACNC,UAAkB,EAClBC,IAAa,CACxB;QACE,KAAK,CAACF,UAAAA,IAAAA,CAHGC,UAAU,GAAVA,YAAAA,IAAAA,CACAC,IAAI,GAAJA;IAGb;AACJ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ApiStreamClient } from "./abstractions.js";
|
|
2
|
+
import { FetchApiStreamClient } from "./FetchApiStreamClient.js";
|
|
3
|
+
import { createFeature } from "../../shared/di/createFeature.js";
|
|
4
|
+
const ApiStreamClientFeature = createFeature({
|
|
5
|
+
name: "ApiStreamClient",
|
|
6
|
+
register (container) {
|
|
7
|
+
container.register(FetchApiStreamClient).inSingletonScope();
|
|
8
|
+
},
|
|
9
|
+
resolve (container) {
|
|
10
|
+
return {
|
|
11
|
+
client: container.resolve(ApiStreamClient)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
export { ApiStreamClientFeature };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/apiStreamClient/feature.js","sources":["../../../src/features/apiStreamClient/feature.ts"],"sourcesContent":["import { ApiStreamClient } from \"./abstractions.js\";\nimport { FetchApiStreamClient } from \"./FetchApiStreamClient.js\";\nimport { createFeature } from \"~/shared/di/createFeature.js\";\n\nexport const ApiStreamClientFeature = createFeature({\n name: \"ApiStreamClient\",\n register(container) {\n container.register(FetchApiStreamClient).inSingletonScope();\n },\n resolve(container) {\n return {\n client: container.resolve(ApiStreamClient)\n };\n }\n});\n"],"names":["ApiStreamClientFeature","createFeature","container","FetchApiStreamClient","ApiStreamClient"],"mappings":";;;AAIO,MAAMA,yBAAyBC,cAAc;IAChD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,sBAAsB,gBAAgB;IAC7D;IACA,SAAQD,SAAS;QACb,OAAO;YACH,QAAQA,UAAU,OAAO,CAACE;QAC9B;IACJ;AACJ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a `text/event-stream` response as a sequence of parsed JSON events.
|
|
3
|
+
*
|
|
4
|
+
* Written against `Response.body` rather than `EventSource` on purpose: `EventSource` can only issue
|
|
5
|
+
* GET requests and cannot set an `Authorization` header, both of which the API requires.
|
|
6
|
+
*
|
|
7
|
+
* Only the `data:` field is interpreted — enough for Webiny's streaming routes, which frame one JSON
|
|
8
|
+
* object per record. Comment lines (`:` heartbeats), `event:`, `id:` and `retry:` are ignored.
|
|
9
|
+
*/
|
|
10
|
+
export declare function readServerSentEvents<TEvent>(response: Response): AsyncGenerator<TEvent>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
async function* readServerSentEvents(response) {
|
|
2
|
+
const body = response.body;
|
|
3
|
+
if (!body) throw new Error("The response carried no readable body.");
|
|
4
|
+
const reader = body.getReader();
|
|
5
|
+
const decoder = new TextDecoder();
|
|
6
|
+
let buffer = "";
|
|
7
|
+
try {
|
|
8
|
+
while(true){
|
|
9
|
+
const { done, value } = await reader.read();
|
|
10
|
+
if (done) break;
|
|
11
|
+
buffer += decoder.decode(value, {
|
|
12
|
+
stream: true
|
|
13
|
+
}).replace(/\r\n/g, "\n");
|
|
14
|
+
let separator = buffer.indexOf("\n\n");
|
|
15
|
+
while(-1 !== separator){
|
|
16
|
+
const record = buffer.slice(0, separator);
|
|
17
|
+
buffer = buffer.slice(separator + 2);
|
|
18
|
+
const data = record.split("\n").filter((line)=>line.startsWith("data:")).map((line)=>line.slice(5).trim()).join("\n");
|
|
19
|
+
if (data) yield JSON.parse(data);
|
|
20
|
+
separator = buffer.indexOf("\n\n");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
} finally{
|
|
24
|
+
reader.releaseLock();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export { readServerSentEvents };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=readServerSentEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/apiStreamClient/readServerSentEvents.js","sources":["../../../src/features/apiStreamClient/readServerSentEvents.ts"],"sourcesContent":["/**\n * Read a `text/event-stream` response as a sequence of parsed JSON events.\n *\n * Written against `Response.body` rather than `EventSource` on purpose: `EventSource` can only issue\n * GET requests and cannot set an `Authorization` header, both of which the API requires.\n *\n * Only the `data:` field is interpreted — enough for Webiny's streaming routes, which frame one JSON\n * object per record. Comment lines (`:` heartbeats), `event:`, `id:` and `retry:` are ignored.\n */\nexport async function* readServerSentEvents<TEvent>(response: Response): AsyncGenerator<TEvent> {\n const body = response.body;\n if (!body) {\n throw new Error(\"The response carried no readable body.\");\n }\n\n const reader = body.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) {\n break;\n }\n\n // `stream: true` keeps a multi-byte character split across chunks intact.\n buffer += decoder.decode(value, { stream: true }).replace(/\\r\\n/g, \"\\n\");\n\n let separator = buffer.indexOf(\"\\n\\n\");\n while (separator !== -1) {\n const record = buffer.slice(0, separator);\n buffer = buffer.slice(separator + 2);\n\n const data = record\n .split(\"\\n\")\n .filter(line => line.startsWith(\"data:\"))\n .map(line => line.slice(\"data:\".length).trim())\n .join(\"\\n\");\n\n if (data) {\n yield JSON.parse(data) as TEvent;\n }\n\n separator = buffer.indexOf(\"\\n\\n\");\n }\n }\n } finally {\n reader.releaseLock();\n }\n}\n"],"names":["readServerSentEvents","response","body","Error","reader","decoder","TextDecoder","buffer","done","value","separator","record","data","line","JSON"],"mappings":"AASO,gBAAgBA,qBAA6BC,QAAkB;IAClE,MAAMC,OAAOD,SAAS,IAAI;IAC1B,IAAI,CAACC,MACD,MAAM,IAAIC,MAAM;IAGpB,MAAMC,SAASF,KAAK,SAAS;IAC7B,MAAMG,UAAU,IAAIC;IACpB,IAAIC,SAAS;IAEb,IAAI;QACA,MAAO,KAAM;YACT,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAG,MAAML,OAAO,IAAI;YAEzC,IAAII,MACA;YAIJD,UAAUF,QAAQ,MAAM,CAACI,OAAO;gBAAE,QAAQ;YAAK,GAAG,OAAO,CAAC,SAAS;YAEnE,IAAIC,YAAYH,OAAO,OAAO,CAAC;YAC/B,MAAOG,AAAc,OAAdA,UAAkB;gBACrB,MAAMC,SAASJ,OAAO,KAAK,CAAC,GAAGG;gBAC/BH,SAASA,OAAO,KAAK,CAACG,YAAY;gBAElC,MAAME,OAAOD,OACR,KAAK,CAAC,MACN,MAAM,CAACE,CAAAA,OAAQA,KAAK,UAAU,CAAC,UAC/B,GAAG,CAACA,CAAAA,OAAQA,KAAK,KAAK,CAAC,GAAgB,IAAI,IAC3C,IAAI,CAAC;gBAEV,IAAID,MACA,MAAME,KAAK,KAAK,CAACF;gBAGrBF,YAAYH,OAAO,OAAO,CAAC;YAC/B;QACJ;IACJ,SAAU;QACNH,OAAO,WAAW;IACtB;AACJ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hex SHA-256 of a request body, for the `x-amz-content-sha256` header.
|
|
3
|
+
*
|
|
4
|
+
* Required whenever a streaming route is reached through CloudFront with Origin Access Control. OAC
|
|
5
|
+
* signs the request with SigV4 but does NOT hash the body itself — it folds whatever this header says
|
|
6
|
+
* into the signature, and the Lambda Function URL's IAM authorizer then recomputes the hash from the
|
|
7
|
+
* body it received. Omit the header and the two disagree, so a POST WITH a body is rejected with
|
|
8
|
+
* `InvalidSignatureException` while a bodyless POST succeeds, because an empty payload hashes
|
|
9
|
+
* predictably.
|
|
10
|
+
*
|
|
11
|
+
* `crypto.subtle` needs a secure context, which the streaming behavior already requires
|
|
12
|
+
* (`viewerProtocolPolicy: "https-only"`).
|
|
13
|
+
*/
|
|
14
|
+
export declare function toPayloadHash(body: string): Promise<string>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
async function toPayloadHash(body) {
|
|
2
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(body));
|
|
3
|
+
return Array.from(new Uint8Array(digest)).map((byte)=>byte.toString(16).padStart(2, "0")).join("");
|
|
4
|
+
}
|
|
5
|
+
export { toPayloadHash };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=toPayloadHash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/apiStreamClient/toPayloadHash.js","sources":["../../../src/features/apiStreamClient/toPayloadHash.ts"],"sourcesContent":["/**\n * Hex SHA-256 of a request body, for the `x-amz-content-sha256` header.\n *\n * Required whenever a streaming route is reached through CloudFront with Origin Access Control. OAC\n * signs the request with SigV4 but does NOT hash the body itself — it folds whatever this header says\n * into the signature, and the Lambda Function URL's IAM authorizer then recomputes the hash from the\n * body it received. Omit the header and the two disagree, so a POST WITH a body is rejected with\n * `InvalidSignatureException` while a bodyless POST succeeds, because an empty payload hashes\n * predictably.\n *\n * `crypto.subtle` needs a secure context, which the streaming behavior already requires\n * (`viewerProtocolPolicy: \"https-only\"`).\n */\nexport async function toPayloadHash(body: string): Promise<string> {\n const digest = await crypto.subtle.digest(\"SHA-256\", new TextEncoder().encode(body));\n\n return Array.from(new Uint8Array(digest))\n .map(byte => byte.toString(16).padStart(2, \"0\"))\n .join(\"\");\n}\n"],"names":["toPayloadHash","body","digest","crypto","TextEncoder","Array","Uint8Array","byte"],"mappings":"AAaO,eAAeA,cAAcC,IAAY;IAC5C,MAAMC,SAAS,MAAMC,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,IAAIC,cAAc,MAAM,CAACH;IAE9E,OAAOI,MAAM,IAAI,CAAC,IAAIC,WAAWJ,SAC5B,GAAG,CAACK,CAAAA,OAAQA,KAAK,QAAQ,CAAC,IAAI,QAAQ,CAAC,GAAG,MAC1C,IAAI,CAAC;AACd"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EnvConfig as Abstraction } from "./abstractions.js";
|
|
2
|
+
export declare class DefaultEnvConfig implements Abstraction.Interface {
|
|
3
|
+
private readonly env;
|
|
4
|
+
constructor(env: Abstraction.Config);
|
|
5
|
+
get<K extends keyof Abstraction.Config>(key: K, defaultValue?: Abstraction.Config[K]): Abstraction.Config[K];
|
|
6
|
+
getAll(): Abstraction.Config;
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class DefaultEnvConfig {
|
|
2
|
+
constructor(env){
|
|
3
|
+
this.env = env;
|
|
4
|
+
}
|
|
5
|
+
get(key, defaultValue) {
|
|
6
|
+
const rawValue = this.env[key];
|
|
7
|
+
if (null == rawValue && void 0 !== defaultValue) return defaultValue;
|
|
8
|
+
return rawValue;
|
|
9
|
+
}
|
|
10
|
+
getAll() {
|
|
11
|
+
return this.env;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export { DefaultEnvConfig };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=EnvConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/envConfig/EnvConfig.js","sources":["../../../src/features/envConfig/EnvConfig.ts"],"sourcesContent":["import { EnvConfig as Abstraction } from \"./abstractions.js\";\n\nexport class DefaultEnvConfig implements Abstraction.Interface {\n private readonly env: Abstraction.Config;\n\n constructor(env: Abstraction.Config) {\n this.env = env;\n }\n\n public get<K extends keyof Abstraction.Config>(\n key: K,\n defaultValue?: Abstraction.Config[K]\n ): Abstraction.Config[K] {\n const rawValue = this.env[key];\n\n if ((rawValue === undefined || rawValue === null) && defaultValue !== undefined) {\n return defaultValue;\n }\n\n return rawValue;\n }\n\n getAll(): Abstraction.Config {\n return this.env;\n }\n}\n"],"names":["DefaultEnvConfig","env","key","defaultValue","rawValue","undefined"],"mappings":"AAEO,MAAMA;IAGT,YAAYC,GAAuB,CAAE;QACjC,IAAI,CAAC,GAAG,GAAGA;IACf;IAEO,IACHC,GAAM,EACNC,YAAoC,EACf;QACrB,MAAMC,WAAW,IAAI,CAAC,GAAG,CAACF,IAAI;QAE9B,IAAKE,QAAAA,YAAgDD,AAAiBE,WAAjBF,cACjD,OAAOA;QAGX,OAAOC;IACX;IAEA,SAA6B;QACzB,OAAO,IAAI,CAAC,GAAG;IACnB;AACJ"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Abstraction } from "@webiny/di";
|
|
2
|
+
type Env = {
|
|
3
|
+
apiUrl: string;
|
|
4
|
+
debug: boolean;
|
|
5
|
+
deploymentId: string;
|
|
6
|
+
graphqlApiUrl: string;
|
|
7
|
+
telemetryEnabled: boolean;
|
|
8
|
+
telemetryUserId: string | undefined;
|
|
9
|
+
trashBinRetentionPeriodDays: number;
|
|
10
|
+
wcpProjectId: string | undefined;
|
|
11
|
+
websocketUrl: string;
|
|
12
|
+
graphqlClient?: {
|
|
13
|
+
retries: {
|
|
14
|
+
maxRetries: number;
|
|
15
|
+
delayInMillis: number;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export interface IEnvConfig {
|
|
20
|
+
get<K extends keyof Env>(key: K, defaultValue?: Env[K]): Env[K];
|
|
21
|
+
getAll(): Env;
|
|
22
|
+
}
|
|
23
|
+
export declare const EnvConfig: Abstraction<IEnvConfig>;
|
|
24
|
+
export declare namespace EnvConfig {
|
|
25
|
+
type Interface = IEnvConfig;
|
|
26
|
+
type Config = Env;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/envConfig/abstractions.js","sources":["../../../src/features/envConfig/abstractions.ts"],"sourcesContent":["import { Abstraction } from \"@webiny/di\";\n\ntype Env = {\n apiUrl: string;\n debug: boolean;\n deploymentId: string;\n graphqlApiUrl: string;\n telemetryEnabled: boolean;\n telemetryUserId: string | undefined;\n trashBinRetentionPeriodDays: number;\n wcpProjectId: string | undefined;\n websocketUrl: string;\n graphqlClient?: {\n retries: {\n maxRetries: number;\n delayInMillis: number;\n };\n };\n};\n\nexport interface IEnvConfig {\n get<K extends keyof Env>(key: K, defaultValue?: Env[K]): Env[K];\n getAll(): Env;\n}\n\nexport const EnvConfig = new Abstraction<IEnvConfig>(\"EnvConfig\");\n\nexport namespace EnvConfig {\n export type Interface = IEnvConfig;\n export type Config = Env;\n}\n"],"names":["EnvConfig","Abstraction"],"mappings":";AAyBO,MAAMA,YAAY,IAAIC,YAAwB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const EnvConfigFeature: import("~/shared/di/createFeature.js").FeatureDefinition<import("./abstractions.js").IEnvConfig, [params: {
|
|
2
|
+
apiUrl: string;
|
|
3
|
+
debug: boolean;
|
|
4
|
+
deploymentId: string;
|
|
5
|
+
graphqlApiUrl: string;
|
|
6
|
+
telemetryEnabled: boolean;
|
|
7
|
+
telemetryUserId: string | undefined;
|
|
8
|
+
trashBinRetentionPeriodDays: number;
|
|
9
|
+
wcpProjectId: string | undefined;
|
|
10
|
+
websocketUrl: string;
|
|
11
|
+
graphqlClient?: {
|
|
12
|
+
retries: {
|
|
13
|
+
maxRetries: number;
|
|
14
|
+
delayInMillis: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}]>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EnvConfig } from "./abstractions.js";
|
|
2
|
+
import { DefaultEnvConfig } from "./EnvConfig.js";
|
|
3
|
+
import { createFeature } from "../../shared/di/createFeature.js";
|
|
4
|
+
const EnvConfigFeature = createFeature({
|
|
5
|
+
name: "EnvConfig",
|
|
6
|
+
register (container, params) {
|
|
7
|
+
container.registerInstance(EnvConfig, new DefaultEnvConfig(params));
|
|
8
|
+
},
|
|
9
|
+
resolve (container) {
|
|
10
|
+
return container.resolve(EnvConfig);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
export { EnvConfigFeature };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/envConfig/feature.js","sources":["../../../src/features/envConfig/feature.ts"],"sourcesContent":["import { EnvConfig } from \"./abstractions.js\";\nimport { DefaultEnvConfig } from \"./EnvConfig.js\";\nimport { createFeature } from \"~/shared/di/createFeature.js\";\n\nexport const EnvConfigFeature = createFeature({\n name: \"EnvConfig\",\n register(container, params: EnvConfig.Config) {\n container.registerInstance(EnvConfig, new DefaultEnvConfig(params));\n },\n resolve(container) {\n return container.resolve(EnvConfig);\n }\n});\n"],"names":["EnvConfigFeature","createFeature","container","params","EnvConfig","DefaultEnvConfig"],"mappings":";;;AAIO,MAAMA,mBAAmBC,cAAc;IAC1C,MAAM;IACN,UAASC,SAAS,EAAEC,MAAwB;QACxCD,UAAU,gBAAgB,CAACE,WAAW,IAAIC,iBAAiBF;IAC/D;IACA,SAAQD,SAAS;QACb,OAAOA,UAAU,OAAO,CAACE;IAC7B;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EnvConfig } from "./abstractions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EnvConfig } from "./abstractions.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Container } from "@webiny/di";
|
|
2
|
+
import { EventPublisher as Abstraction, BaseEvent } from "./abstractions.js";
|
|
3
|
+
export declare class EventPublisher implements Abstraction.Interface {
|
|
4
|
+
private container;
|
|
5
|
+
constructor(container: Container);
|
|
6
|
+
publish<TEvent extends BaseEvent>(event: TEvent): Promise<void>;
|
|
7
|
+
private logEvent;
|
|
8
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EnvConfig } from "../envConfig/index.js";
|
|
2
|
+
class EventPublisher {
|
|
3
|
+
constructor(container){
|
|
4
|
+
this.container = container;
|
|
5
|
+
}
|
|
6
|
+
async publish(event) {
|
|
7
|
+
this.logEvent(event);
|
|
8
|
+
const handlerAbstraction = event.getHandlerAbstraction();
|
|
9
|
+
const handlers = this.container.resolveAll(handlerAbstraction);
|
|
10
|
+
for (const handler of handlers)await handler.handle(event);
|
|
11
|
+
}
|
|
12
|
+
logEvent(event) {
|
|
13
|
+
const envConfig = this.container.resolve(EnvConfig);
|
|
14
|
+
if (envConfig.get("debug")) console.log(`[EventPublisher] Publishing event "${event.eventType}".`, event.payload);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export { EventPublisher };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=EventPublisher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/eventPublisher/EventPublisher.js","sources":["../../../src/features/eventPublisher/EventPublisher.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport { EventPublisher as Abstraction, BaseEvent } from \"./abstractions.js\";\nimport { EnvConfig } from \"~/features/envConfig/index.js\";\n\nexport class EventPublisher implements Abstraction.Interface {\n constructor(private container: Container) {}\n\n async publish<TEvent extends BaseEvent>(event: TEvent): Promise<void> {\n this.logEvent(event);\n // Get handler abstraction from the event itself\n const handlerAbstraction = event.getHandlerAbstraction();\n\n // Resolve ALL implementations of that abstraction\n const handlers = this.container.resolveAll(handlerAbstraction);\n\n // Execute all handlers\n for (const handler of handlers) {\n await handler.handle(event);\n }\n }\n\n private logEvent(event: BaseEvent) {\n const envConfig = this.container.resolve(EnvConfig);\n if (envConfig.get(\"debug\")) {\n console.log(`[EventPublisher] Publishing event \"${event.eventType}\".`, event.payload);\n }\n }\n}\n"],"names":["EventPublisher","container","event","handlerAbstraction","handlers","handler","envConfig","EnvConfig","console"],"mappings":";AAIO,MAAMA;IACT,YAAoBC,SAAoB,CAAE;aAAtBA,SAAS,GAATA;IAAuB;IAE3C,MAAM,QAAkCC,KAAa,EAAiB;QAClE,IAAI,CAAC,QAAQ,CAACA;QAEd,MAAMC,qBAAqBD,MAAM,qBAAqB;QAGtD,MAAME,WAAW,IAAI,CAAC,SAAS,CAAC,UAAU,CAACD;QAG3C,KAAK,MAAME,WAAWD,SAClB,MAAMC,QAAQ,MAAM,CAACH;IAE7B;IAEQ,SAASA,KAAgB,EAAE;QAC/B,MAAMI,YAAY,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC;QACzC,IAAID,UAAU,GAAG,CAAC,UACdE,QAAQ,GAAG,CAAC,CAAC,mCAAmC,EAAEN,MAAM,SAAS,CAAC,EAAE,CAAC,EAAEA,MAAM,OAAO;IAE5F;AACJ"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Abstraction } from "@webiny/di";
|
|
2
|
+
export declare abstract class BaseEvent<TPayload = void> {
|
|
3
|
+
abstract readonly eventType: string;
|
|
4
|
+
readonly occurredAt: Date;
|
|
5
|
+
readonly payload: TPayload extends void ? undefined : TPayload;
|
|
6
|
+
constructor(payload: TPayload);
|
|
7
|
+
abstract getHandlerAbstraction(): Abstraction<IEventHandler<any>>;
|
|
8
|
+
}
|
|
9
|
+
export interface IEventHandler<TEvent extends BaseEvent<any> = BaseEvent<any>> {
|
|
10
|
+
handle(event: TEvent): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export interface IEventPublisher {
|
|
13
|
+
publish<TEvent extends BaseEvent<any>>(event: TEvent): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export declare const EventPublisher: Abstraction<IEventPublisher>;
|
|
16
|
+
export declare namespace EventPublisher {
|
|
17
|
+
type Interface = IEventPublisher;
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/admin";
|
|
2
|
+
class BaseEvent {
|
|
3
|
+
constructor(payload){
|
|
4
|
+
this.occurredAt = new Date();
|
|
5
|
+
if (void 0 === payload) this.payload = void 0;
|
|
6
|
+
else this.payload = payload;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
const EventPublisher = createAbstraction("EventPublisher");
|
|
10
|
+
export { BaseEvent, EventPublisher };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/eventPublisher/abstractions.js","sources":["../../../src/features/eventPublisher/abstractions.ts"],"sourcesContent":["import type { Abstraction } from \"@webiny/di\";\nimport { createAbstraction } from \"@webiny/feature/admin\";\n\nexport abstract class BaseEvent<TPayload = void> {\n public abstract readonly eventType: string;\n public readonly occurredAt: Date;\n public readonly payload: TPayload extends void ? undefined : TPayload;\n\n constructor(payload: TPayload);\n constructor(payload?: never) {\n this.occurredAt = new Date();\n\n if (payload === undefined) {\n this.payload = undefined as any;\n } else {\n this.payload = payload;\n }\n }\n\n abstract getHandlerAbstraction(): Abstraction<IEventHandler<any>>;\n}\n\nexport interface IEventHandler<TEvent extends BaseEvent<any> = BaseEvent<any>> {\n handle(event: TEvent): Promise<void>;\n}\n\nexport interface IEventPublisher {\n publish<TEvent extends BaseEvent<any>>(event: TEvent): Promise<void>;\n}\n\nexport const EventPublisher = createAbstraction<IEventPublisher>(\"EventPublisher\");\n\nexport namespace EventPublisher {\n export type Interface = IEventPublisher;\n}\n"],"names":["BaseEvent","payload","Date","undefined","EventPublisher","createAbstraction"],"mappings":";AAGO,MAAeA;IAMlB,YAAYC,OAAe,CAAE;QACzB,IAAI,CAAC,UAAU,GAAG,IAAIC;QAEtB,IAAID,AAAYE,WAAZF,SACA,IAAI,CAAC,OAAO,GAAGE;aAEf,IAAI,CAAC,OAAO,GAAGF;IAEvB;AAGJ;AAUO,MAAMG,iBAAiBC,kBAAmC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/admin";
|
|
2
|
+
import { EventPublisher } from "./abstractions.js";
|
|
3
|
+
import { EventPublisher as external_EventPublisher_js_EventPublisher } from "./EventPublisher.js";
|
|
4
|
+
const EventPublisherFeature = createFeature({
|
|
5
|
+
name: "EventPublisher",
|
|
6
|
+
register (container) {
|
|
7
|
+
container.registerInstance(EventPublisher, new external_EventPublisher_js_EventPublisher(container));
|
|
8
|
+
},
|
|
9
|
+
resolve (container) {
|
|
10
|
+
return {
|
|
11
|
+
eventPublisher: container.resolve(EventPublisher)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
export { EventPublisherFeature };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/eventPublisher/feature.js","sources":["../../../src/features/eventPublisher/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { Container } from \"@webiny/di\";\nimport { EventPublisher as EventPublisherAbstraction } from \"./abstractions.js\";\nimport { EventPublisher } from \"./EventPublisher.js\";\n\nexport const EventPublisherFeature = createFeature({\n name: \"EventPublisher\",\n register(container: Container) {\n container.registerInstance(EventPublisherAbstraction, new EventPublisher(container));\n },\n resolve(container: Container) {\n return {\n eventPublisher: container.resolve(EventPublisherAbstraction)\n };\n }\n});\n"],"names":["EventPublisherFeature","createFeature","container","EventPublisherAbstraction","EventPublisher"],"mappings":";;;AAKO,MAAMA,wBAAwBC,cAAc;IAC/C,MAAM;IACN,UAASC,SAAoB;QACzBA,UAAU,gBAAgB,CAACC,gBAA2B,IAAIC,0CAAeF;IAC7E;IACA,SAAQA,SAAoB;QACxB,OAAO;YACH,gBAAgBA,UAAU,OAAO,CAACC;QACtC;IACJ;AACJ"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GraphQLClient } from "./abstractions.js";
|
|
2
|
+
import { EventPublisher } from "../../features/eventPublisher/index.js";
|
|
3
|
+
declare class AuthenticationErrorPublishingDecorator implements GraphQLClient.Interface {
|
|
4
|
+
private eventPublisher;
|
|
5
|
+
private decoratee;
|
|
6
|
+
constructor(eventPublisher: EventPublisher.Interface, decoratee: GraphQLClient.Interface);
|
|
7
|
+
execute<TResult = any, TVariables = any>(params: GraphQLClient.Request<TVariables>): Promise<TResult>;
|
|
8
|
+
private isAuthenticationError;
|
|
9
|
+
}
|
|
10
|
+
export declare const AuthenticationErrorPublishing: typeof AuthenticationErrorPublishingDecorator & {
|
|
11
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGraphQLClient>;
|
|
12
|
+
};
|
|
13
|
+
export {};
|