@webiny/app 6.3.0-beta.4 → 6.4.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App.js +70 -77
- package/App.js.map +1 -1
- package/AppContainer.js +3 -6
- package/AppContainer.js.map +1 -1
- package/apollo-client/InMemoryCache.js +11 -13
- package/apollo-client/InMemoryCache.js.map +1 -1
- package/apollo-client/IntrospectionFragmentMatcher.js +26 -38
- package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -1
- package/components/Image.js +11 -17
- package/components/Image.js.map +1 -1
- package/components/index.js +0 -2
- package/config/RouterConfig/Route.js +23 -28
- package/config/RouterConfig/Route.js.map +1 -1
- package/config/RouterConfig.js +11 -10
- package/config/RouterConfig.js.map +1 -1
- package/config.js +19 -20
- package/config.js.map +1 -1
- package/contexts/Ui/index.js +26 -28
- package/contexts/Ui/index.js.map +1 -1
- package/core/Plugin.js +7 -9
- package/core/Plugin.js.map +1 -1
- package/core/Plugins.js +15 -34
- package/core/Plugins.js.map +1 -1
- package/core/Provider.js +5 -13
- package/core/Provider.js.map +1 -1
- package/core/createProvider.js +3 -6
- package/core/createProvider.js.map +1 -1
- package/core/createProviderPlugin.js +8 -13
- package/core/createProviderPlugin.js.map +1 -1
- package/errors/AuthenticationErrorEvent.js +8 -5
- package/errors/AuthenticationErrorEvent.js.map +1 -1
- package/errors/NetworkErrorEvent.js +8 -5
- package/errors/NetworkErrorEvent.js.map +1 -1
- package/errors/abstractions.js +3 -2
- package/errors/abstractions.js.map +1 -1
- package/errors/index.js +1 -4
- package/exports/admin/env-config.js +0 -2
- package/exports/admin/graphql-client.js +0 -2
- package/exports/admin/local-storage.js +0 -2
- package/exports/admin/router.js +0 -2
- package/exports/admin/security.js +0 -2
- package/exports/admin.js +0 -2
- package/features/envConfig/EnvConfig.js +12 -13
- package/features/envConfig/EnvConfig.js.map +1 -1
- package/features/envConfig/abstractions.js +2 -1
- package/features/envConfig/abstractions.js.map +1 -1
- package/features/envConfig/feature.js +9 -8
- package/features/envConfig/feature.js.map +1 -1
- package/features/envConfig/index.js +0 -2
- package/features/eventPublisher/EventPublisher.js +13 -21
- package/features/eventPublisher/EventPublisher.js.map +1 -1
- package/features/eventPublisher/abstractions.js +7 -9
- package/features/eventPublisher/abstractions.js.map +1 -1
- package/features/eventPublisher/feature.js +13 -12
- package/features/eventPublisher/feature.js.map +1 -1
- package/features/eventPublisher/index.js +1 -3
- package/features/graphqlClient/AuthenticationErrorPublishing.js +26 -26
- package/features/graphqlClient/AuthenticationErrorPublishing.js.map +1 -1
- package/features/graphqlClient/BatchingGraphQLClient.js +104 -149
- package/features/graphqlClient/BatchingGraphQLClient.js.map +1 -1
- package/features/graphqlClient/FetchGraphQLClient.js +41 -48
- package/features/graphqlClient/FetchGraphQLClient.js.map +1 -1
- package/features/graphqlClient/NetworkErrorPublishing.js +35 -42
- package/features/graphqlClient/NetworkErrorPublishing.js.map +1 -1
- package/features/graphqlClient/RequestValue.js +42 -41
- package/features/graphqlClient/RequestValue.js.map +1 -1
- package/features/graphqlClient/RetryGraphQLClient.js +36 -45
- package/features/graphqlClient/RetryGraphQLClient.js.map +1 -1
- package/features/graphqlClient/__tests__/GraphQLClient.test.js +383 -356
- package/features/graphqlClient/__tests__/GraphQLClient.test.js.map +1 -1
- package/features/graphqlClient/abstractions.js +2 -1
- package/features/graphqlClient/abstractions.js.map +1 -1
- package/features/graphqlClient/feature.js +14 -20
- package/features/graphqlClient/feature.js.map +1 -1
- package/features/graphqlClient/index.js +0 -2
- package/features/graphqlClient/types.js +0 -3
- package/features/localStorage/BrowserLocalStorageGateway.js +56 -63
- package/features/localStorage/BrowserLocalStorageGateway.js.map +1 -1
- package/features/localStorage/LocalStorage.js +27 -24
- package/features/localStorage/LocalStorage.js.map +1 -1
- package/features/localStorage/LocalStorageRepository.js +75 -88
- package/features/localStorage/LocalStorageRepository.js.map +1 -1
- package/features/localStorage/abstractions.js +5 -16
- package/features/localStorage/abstractions.js.map +1 -1
- package/features/localStorage/feature.js +17 -28
- package/features/localStorage/feature.js.map +1 -1
- package/features/localStorage/index.js +1 -3
- package/features/mainGraphQLClient/MainGraphQLClient.js +18 -14
- package/features/mainGraphQLClient/MainGraphQLClient.js.map +1 -1
- package/features/mainGraphQLClient/abstractions.js +2 -1
- package/features/mainGraphQLClient/abstractions.js.map +1 -1
- package/features/mainGraphQLClient/feature.js +11 -10
- package/features/mainGraphQLClient/feature.js.map +1 -1
- package/features/mainGraphQLClient/index.js +0 -2
- package/features/router/HistoryRouterGateway.js +75 -105
- package/features/router/HistoryRouterGateway.js.map +1 -1
- package/features/router/HistoryRouterGateway.test.js +184 -193
- package/features/router/HistoryRouterGateway.test.js.map +1 -1
- package/features/router/Route.js +38 -54
- package/features/router/Route.js.map +1 -1
- package/features/router/RouteUrl.js +84 -217
- package/features/router/RouteUrl.js.map +1 -1
- package/features/router/Router.js +67 -124
- package/features/router/Router.js.map +1 -1
- package/features/router/RouterPresenter.js +44 -49
- package/features/router/RouterPresenter.js.map +1 -1
- package/features/router/RouterRepository.js +103 -111
- package/features/router/RouterRepository.js.map +1 -1
- package/features/router/RouterRepository.test.js +119 -150
- package/features/router/RouterRepository.test.js.map +1 -1
- package/features/router/abstractions.js +4 -14
- package/features/router/abstractions.js.map +1 -1
- package/features/router/feature.js +13 -12
- package/features/router/feature.js.map +1 -1
- package/features/router/index.js +1 -3
- package/helpers/InterfaceGenerator/date.js +0 -3
- package/helpers/InterfaceGenerator/id.js +0 -3
- package/helpers/InterfaceGenerator/identity.js +0 -3
- package/helpers/InterfaceGenerator/index.js +0 -3
- package/helpers/InterfaceGenerator/numeric.js +0 -3
- package/helpers/InterfaceGenerator/truthful.js +0 -3
- package/hooks/useAutocomplete/index.js +0 -2
- package/hooks/useAutocomplete/useAutocomplete.js +12 -15
- package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
- package/hooks/useDataList/functions/getData.js +2 -1
- package/hooks/useDataList/functions/getData.js.map +1 -1
- package/hooks/useDataList/functions/getError.js +2 -1
- package/hooks/useDataList/functions/getError.js.map +1 -1
- package/hooks/useDataList/functions/getMeta.js +2 -1
- package/hooks/useDataList/functions/getMeta.js.map +1 -1
- package/hooks/useDataList/functions/index.js +0 -2
- package/hooks/useDataList/functions/searchDataByKey.js +9 -14
- package/hooks/useDataList/functions/searchDataByKey.js.map +1 -1
- package/hooks/useDataList/index.js +0 -2
- package/hooks/useDataList/useDataList.js +131 -152
- package/hooks/useDataList/useDataList.js.map +1 -1
- package/hooks/useDataList/utils/index.js +0 -2
- package/hooks/useDataList/utils/prepareLoadListParams.js +25 -34
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
- package/hooks/useHandler.js +12 -16
- package/hooks/useHandler.js.map +1 -1
- package/hooks/useHandlers.js +18 -20
- package/hooks/useHandlers.js.map +1 -1
- package/hooks/useRegisterLegacyPlugin.js +7 -6
- package/hooks/useRegisterLegacyPlugin.js.map +1 -1
- package/hooks/useUi.js +2 -3
- package/hooks/useUi.js.map +1 -1
- package/i18n/i18n.js +8 -4
- package/i18n/i18n.js.map +1 -1
- package/i18n/index.js +0 -2
- package/index.js +6 -11
- package/package.json +13 -13
- package/plugins/AddQuerySelectionPlugin.js +36 -61
- package/plugins/AddQuerySelectionPlugin.js.map +1 -1
- package/plugins/ApolloCacheObjectIdPlugin.js +12 -11
- package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -1
- package/plugins/ApolloDynamicLink.js +20 -22
- package/plugins/ApolloDynamicLink.js.map +1 -1
- package/plugins/ApolloLinkPlugin.js +16 -15
- package/plugins/ApolloLinkPlugin.js.map +1 -1
- package/plugins/ConsoleLinkPlugin.js +19 -21
- package/plugins/ConsoleLinkPlugin.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +39 -45
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js +18 -22
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js +21 -29
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +6 -15
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/Typography.js +9 -14
- package/plugins/NetworkErrorLinkPlugin/Typography.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js +19 -0
- package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +11 -18
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin.js +41 -58
- package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
- package/plugins/OmitTypenameLinkPlugin.js +9 -14
- package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
- package/plugins/TenantHeaderLinkPlugin.js +23 -32
- package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
- package/plugins/components/Image.js +8 -15
- package/plugins/components/Image.js.map +1 -1
- package/plugins/image.js +94 -133
- package/plugins/image.js.map +1 -1
- package/plugins/index.js +35 -59
- package/plugins/index.js.map +1 -1
- package/presentation/envConfig/useEnvConfig.js +4 -8
- package/presentation/envConfig/useEnvConfig.js.map +1 -1
- package/presentation/localStorage/index.js +0 -2
- package/presentation/localStorage/useLocalStorage.js +10 -16
- package/presentation/localStorage/useLocalStorage.js.map +1 -1
- package/presentation/localStorage/useLocalStorageValue.js +15 -13
- package/presentation/localStorage/useLocalStorageValue.js.map +1 -1
- package/presentation/localStorage/useLocalStorageValues.js +23 -30
- package/presentation/localStorage/useLocalStorageValues.js.map +1 -1
- package/presentation/router/RouteElementRegistry.js +22 -25
- package/presentation/router/RouteElementRegistry.js.map +1 -1
- package/presentation/router/abstractions.js +2 -1
- package/presentation/router/abstractions.js.map +1 -1
- package/presentation/router/components/Redirect.js +8 -10
- package/presentation/router/components/Redirect.js.map +1 -1
- package/presentation/router/components/RouteContent.js +14 -17
- package/presentation/router/components/RouteContent.js.map +1 -1
- package/presentation/router/components/RouteLink.js +11 -16
- package/presentation/router/components/RouteLink.js.map +1 -1
- package/presentation/router/components/SimpleLink.js +18 -24
- package/presentation/router/components/SimpleLink.js.map +1 -1
- package/presentation/router/hooks/useRoute.js +15 -23
- package/presentation/router/hooks/useRoute.js.map +1 -1
- package/presentation/router/hooks/useRouter.js +22 -23
- package/presentation/router/hooks/useRouter.js.map +1 -1
- package/presentation/router/index.js +0 -2
- package/presentation/router/types.js +0 -3
- package/react-butterfiles/Files.js +148 -217
- package/react-butterfiles/Files.js.map +1 -1
- package/react-butterfiles/index.js +2 -1
- package/react-butterfiles/index.js.map +1 -1
- package/react-butterfiles/utils/generateId.js +2 -3
- package/react-butterfiles/utils/generateId.js.map +1 -1
- package/react-butterfiles/utils/readFileContent.js +9 -13
- package/react-butterfiles/utils/readFileContent.js.map +1 -1
- package/renderApp.js +7 -6
- package/renderApp.js.map +1 -1
- package/router.js +0 -3
- package/rslib-runtime.js +14 -0
- package/rslib-runtime.js.map +1 -0
- package/shared/di/DiContainerProvider.js +8 -12
- package/shared/di/DiContainerProvider.js.map +1 -1
- package/shared/di/createFeature.js +7 -8
- package/shared/di/createFeature.js.map +1 -1
- package/shared/di/useFeature.js +7 -3
- package/shared/di/useFeature.js.map +1 -1
- package/static/svg/close_24px.33adaadc.svg +1 -0
- package/types.js +0 -3
- package/utils/createGenericContext.js +17 -21
- package/utils/createGenericContext.js.map +1 -1
- package/utils/createHashing.js +13 -16
- package/utils/createHashing.js.map +1 -1
- package/utils/index.js +0 -2
- package/utils/legacyPluginToReactComponent.js +11 -10
- package/utils/legacyPluginToReactComponent.js.map +1 -1
- package/components/index.js.map +0 -1
- package/errors/index.js.map +0 -1
- package/exports/admin/env-config.js.map +0 -1
- package/exports/admin/graphql-client.js.map +0 -1
- package/exports/admin/local-storage.js.map +0 -1
- package/exports/admin/router.js.map +0 -1
- package/exports/admin/security.js.map +0 -1
- package/exports/admin.js.map +0 -1
- package/features/envConfig/index.js.map +0 -1
- package/features/eventPublisher/index.js.map +0 -1
- package/features/graphqlClient/index.js.map +0 -1
- package/features/graphqlClient/types.js.map +0 -1
- package/features/localStorage/index.js.map +0 -1
- package/features/mainGraphQLClient/index.js.map +0 -1
- package/features/router/index.js.map +0 -1
- package/helpers/InterfaceGenerator/date.js.map +0 -1
- package/helpers/InterfaceGenerator/id.js.map +0 -1
- package/helpers/InterfaceGenerator/identity.js.map +0 -1
- package/helpers/InterfaceGenerator/index.js.map +0 -1
- package/helpers/InterfaceGenerator/numeric.js.map +0 -1
- package/helpers/InterfaceGenerator/truthful.js.map +0 -1
- package/hooks/useAutocomplete/index.js.map +0 -1
- package/hooks/useDataList/functions/index.js.map +0 -1
- package/hooks/useDataList/index.js.map +0 -1
- package/hooks/useDataList/utils/index.js.map +0 -1
- package/i18n/index.js.map +0 -1
- package/index.js.map +0 -1
- package/presentation/localStorage/index.js.map +0 -1
- package/presentation/router/index.js.map +0 -1
- package/presentation/router/types.js.map +0 -1
- package/router.js.map +0 -1
- package/types.js.map +0 -1
- package/utils/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.0-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"@emotion/styled": "11.14.1",
|
|
23
23
|
"@types/react": "18.3.28",
|
|
24
24
|
"@webiny/di": "0.2.3",
|
|
25
|
-
"@webiny/feature": "6.
|
|
26
|
-
"@webiny/i18n": "6.
|
|
27
|
-
"@webiny/i18n-react": "6.
|
|
28
|
-
"@webiny/plugins": "6.
|
|
29
|
-
"@webiny/react-composition": "6.
|
|
30
|
-
"@webiny/react-properties": "6.
|
|
25
|
+
"@webiny/feature": "6.4.0-beta.0",
|
|
26
|
+
"@webiny/i18n": "6.4.0-beta.0",
|
|
27
|
+
"@webiny/i18n-react": "6.4.0-beta.0",
|
|
28
|
+
"@webiny/plugins": "6.4.0-beta.0",
|
|
29
|
+
"@webiny/react-composition": "6.4.0-beta.0",
|
|
30
|
+
"@webiny/react-properties": "6.4.0-beta.0",
|
|
31
31
|
"apollo-cache": "1.3.5",
|
|
32
32
|
"apollo-cache-inmemory": "1.6.6",
|
|
33
33
|
"apollo-client": "2.6.10",
|
|
@@ -38,27 +38,27 @@
|
|
|
38
38
|
"apollo-utilities": "1.3.4",
|
|
39
39
|
"boolean": "3.2.0",
|
|
40
40
|
"bytes": "3.1.2",
|
|
41
|
-
"graphql": "16.
|
|
41
|
+
"graphql": "16.14.0",
|
|
42
42
|
"history": "5.3.0",
|
|
43
43
|
"invariant": "2.2.4",
|
|
44
44
|
"lodash": "4.18.1",
|
|
45
45
|
"minimatch": "10.2.5",
|
|
46
|
-
"mobx": "6.15.
|
|
46
|
+
"mobx": "6.15.3",
|
|
47
47
|
"nanoid": "5.1.11",
|
|
48
48
|
"react": "18.3.1",
|
|
49
49
|
"react-dom": "18.3.1",
|
|
50
50
|
"ts-invariant": "0.10.3",
|
|
51
51
|
"warning": "4.0.3",
|
|
52
|
-
"zod": "4.3
|
|
52
|
+
"zod": "4.4.3"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/lodash": "4.17.24",
|
|
56
56
|
"@types/warning": "3.0.4",
|
|
57
|
-
"@webiny/build-tools": "6.
|
|
57
|
+
"@webiny/build-tools": "6.4.0-beta.0",
|
|
58
58
|
"rimraf": "6.1.3",
|
|
59
59
|
"type-fest": "5.6.0",
|
|
60
60
|
"typescript": "6.0.3",
|
|
61
|
-
"vitest": "4.1.
|
|
61
|
+
"vitest": "4.1.6"
|
|
62
62
|
},
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
]
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "a545d7529828af07d08d49c3da1bcb967483b9ce"
|
|
75
75
|
}
|
|
@@ -1,72 +1,47 @@
|
|
|
1
1
|
import { ApolloLink } from "apollo-link";
|
|
2
2
|
import { ApolloLinkPlugin } from "./ApolloLinkPlugin.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
createLink() {
|
|
9
|
-
return new ApolloLink((operation, forward) => {
|
|
10
|
-
if (operation.operationName !== this.config.operationName) {
|
|
11
|
-
return forward(operation);
|
|
12
|
-
}
|
|
13
|
-
this.addSelectionToQuery(operation.operationName, operation.query);
|
|
14
|
-
return forward(operation);
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
addSelectionToQuery(operationName, document) {
|
|
18
|
-
if (operationName !== this.config.operationName) {
|
|
19
|
-
return;
|
|
3
|
+
class AddQuerySelectionPlugin extends ApolloLinkPlugin {
|
|
4
|
+
constructor(config){
|
|
5
|
+
super();
|
|
6
|
+
this.config = config;
|
|
20
7
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.markProcessed(document);
|
|
28
|
-
const {
|
|
29
|
-
addSelection,
|
|
30
|
-
selectionPath
|
|
31
|
-
} = this.config;
|
|
32
|
-
const firstQueryDefinition = document.definitions[0];
|
|
33
|
-
if (!firstQueryDefinition) {
|
|
34
|
-
return;
|
|
35
|
-
} else if (!firstQueryDefinition.selectionSet) {
|
|
36
|
-
return;
|
|
8
|
+
createLink() {
|
|
9
|
+
return new ApolloLink((operation, forward)=>{
|
|
10
|
+
if (operation.operationName !== this.config.operationName) return forward(operation);
|
|
11
|
+
this.addSelectionToQuery(operation.operationName, operation.query);
|
|
12
|
+
return forward(operation);
|
|
13
|
+
});
|
|
37
14
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
|
|
15
|
+
addSelectionToQuery(operationName, document) {
|
|
16
|
+
if (operationName !== this.config.operationName) return;
|
|
17
|
+
if (this.isProcessed(document)) return;
|
|
18
|
+
this.markProcessed(document);
|
|
19
|
+
const { addSelection, selectionPath } = this.config;
|
|
20
|
+
const firstQueryDefinition = document.definitions[0];
|
|
21
|
+
if (!firstQueryDefinition) return;
|
|
22
|
+
if (!firstQueryDefinition.selectionSet) return;
|
|
23
|
+
let tree = firstQueryDefinition.selectionSet.selections;
|
|
24
|
+
const fields = selectionPath.split(".");
|
|
25
|
+
fieldLoop: for (const field of fields){
|
|
26
|
+
for (const selection of tree)if (selection.selectionSet) {
|
|
27
|
+
if (selection.name.value === field) {
|
|
28
|
+
tree = selection.selectionSet.selections;
|
|
29
|
+
continue fieldLoop;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return;
|
|
48
33
|
}
|
|
49
|
-
|
|
50
|
-
// If we get here, it means we didn't find the necessary selection
|
|
51
|
-
return;
|
|
34
|
+
tree.push(...addSelection.definitions[0].selectionSet.selections);
|
|
52
35
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
tree.push(...addSelection.definitions[0].selectionSet.selections);
|
|
57
|
-
}
|
|
58
|
-
isProcessed(document) {
|
|
59
|
-
if (!document.hasOwnProperty("__webiny__")) {
|
|
60
|
-
document.__webiny__ = new Set();
|
|
36
|
+
isProcessed(document) {
|
|
37
|
+
if (!document.hasOwnProperty("__webiny__")) document.__webiny__ = new Set();
|
|
38
|
+
return document.__webiny__.has(this.cacheKey);
|
|
61
39
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (!document.hasOwnProperty("__webiny__")) {
|
|
66
|
-
document.__webiny__ = new Set();
|
|
40
|
+
markProcessed(document) {
|
|
41
|
+
if (!document.hasOwnProperty("__webiny__")) document.__webiny__ = new Set();
|
|
42
|
+
document.__webiny__.add(this.cacheKey);
|
|
67
43
|
}
|
|
68
|
-
document.__webiny__.add(this.cacheKey);
|
|
69
|
-
}
|
|
70
44
|
}
|
|
45
|
+
export { AddQuerySelectionPlugin };
|
|
71
46
|
|
|
72
47
|
//# sourceMappingURL=AddQuerySelectionPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/AddQuerySelectionPlugin.js","sources":["../../src/plugins/AddQuerySelectionPlugin.ts"],"sourcesContent":["import { ApolloLink } from \"apollo-link\";\nimport type { DocumentNode } from \"graphql\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin.js\";\nimport type { ExecutableDefinitionNode, FieldNode } from \"graphql/language/ast.js\";\n\ndeclare module \"graphql\" {\n interface DocumentNode {\n __webiny__: Set<string>;\n }\n}\n\ninterface Config {\n operationName: string;\n selectionPath: string;\n addSelection: DocumentNode;\n}\n\nexport class AddQuerySelectionPlugin extends ApolloLinkPlugin {\n private readonly config: Config;\n\n constructor(config: Config) {\n super();\n this.config = config;\n }\n\n public override createLink(): ApolloLink {\n return new ApolloLink((operation, forward) => {\n if (operation.operationName !== this.config.operationName) {\n return forward(operation);\n }\n\n this.addSelectionToQuery(operation.operationName, operation.query);\n\n return forward(operation);\n });\n }\n\n public addSelectionToQuery(operationName: string, document: DocumentNode): void {\n if (operationName !== this.config.operationName) {\n return;\n }\n\n // If this plugin already processed the given document (documents are always passed by reference),\n // then we don't want to apply the selection again, to avoid adding duplicate selections.\n if (this.isProcessed(document)) {\n return;\n }\n\n this.markProcessed(document);\n\n const { addSelection, selectionPath } = this.config;\n\n const firstQueryDefinition = document.definitions[0] as ExecutableDefinitionNode;\n if (!firstQueryDefinition) {\n return;\n } else if (!firstQueryDefinition.selectionSet) {\n return;\n }\n\n let tree = firstQueryDefinition.selectionSet.selections as FieldNode[];\n const fields = selectionPath.split(\".\");\n\n fieldLoop: for (const field of fields) {\n for (const selection of tree) {\n if (!selection.selectionSet) {\n continue;\n }\n if (selection.name.value === field) {\n tree = selection.selectionSet.selections as FieldNode[];\n continue fieldLoop;\n }\n }\n // If we get here, it means we didn't find the necessary selection\n return;\n }\n /**\n * We must cast because there are a lot of types that are not intertwined and TS is complaining\n */\n tree.push(\n ...((addSelection.definitions[0] as ExecutableDefinitionNode).selectionSet\n .selections as FieldNode[])\n );\n }\n\n private isProcessed(document: DocumentNode) {\n if (!document.hasOwnProperty(\"__webiny__\")) {\n document.__webiny__ = new Set();\n }\n\n return document.__webiny__.has(this.cacheKey);\n }\n\n private markProcessed(document: DocumentNode) {\n if (!document.hasOwnProperty(\"__webiny__\")) {\n document.__webiny__ = new Set();\n }\n\n document.__webiny__.add(this.cacheKey);\n }\n}\n"],"names":["AddQuerySelectionPlugin","ApolloLinkPlugin","config","ApolloLink","operation","forward","operationName","document","addSelection","selectionPath","firstQueryDefinition","tree","fields","fieldLoop","field","selection","Set"],"mappings":";;AAiBO,MAAMA,gCAAgCC;IAGzC,YAAYC,MAAc,CAAE;QACxB,KAAK;QACL,IAAI,CAAC,MAAM,GAAGA;IAClB;IAEgB,aAAyB;QACrC,OAAO,IAAIC,WAAW,CAACC,WAAWC;YAC9B,IAAID,UAAU,aAAa,KAAK,IAAI,CAAC,MAAM,CAAC,aAAa,EACrD,OAAOC,QAAQD;YAGnB,IAAI,CAAC,mBAAmB,CAACA,UAAU,aAAa,EAAEA,UAAU,KAAK;YAEjE,OAAOC,QAAQD;QACnB;IACJ;IAEO,oBAAoBE,aAAqB,EAAEC,QAAsB,EAAQ;QAC5E,IAAID,kBAAkB,IAAI,CAAC,MAAM,CAAC,aAAa,EAC3C;QAKJ,IAAI,IAAI,CAAC,WAAW,CAACC,WACjB;QAGJ,IAAI,CAAC,aAAa,CAACA;QAEnB,MAAM,EAAEC,YAAY,EAAEC,aAAa,EAAE,GAAG,IAAI,CAAC,MAAM;QAEnD,MAAMC,uBAAuBH,SAAS,WAAW,CAAC,EAAE;QACpD,IAAI,CAACG,sBACD;QACG,IAAI,CAACA,qBAAqB,YAAY,EACzC;QAGJ,IAAIC,OAAOD,qBAAqB,YAAY,CAAC,UAAU;QACvD,MAAME,SAASH,cAAc,KAAK,CAAC;QAEnCI,WAAW,KAAK,MAAMC,SAASF,OAAQ;YACnC,KAAK,MAAMG,aAAaJ,KACpB,IAAKI,UAAU,YAAY,EAG3B;gBAAA,IAAIA,UAAU,IAAI,CAAC,KAAK,KAAKD,OAAO;oBAChCH,OAAOI,UAAU,YAAY,CAAC,UAAU;oBACxC,SAASF;gBACb;YAAA;YAGJ;QACJ;QAIAF,KAAK,IAAI,IACAH,aAAa,WAAW,CAAC,EAAE,CAA8B,YAAY,CACrE,UAAU;IAEvB;IAEQ,YAAYD,QAAsB,EAAE;QACxC,IAAI,CAACA,SAAS,cAAc,CAAC,eACzBA,SAAS,UAAU,GAAG,IAAIS;QAG9B,OAAOT,SAAS,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ;IAChD;IAEQ,cAAcA,QAAsB,EAAE;QAC1C,IAAI,CAACA,SAAS,cAAc,CAAC,eACzBA,SAAS,UAAU,GAAG,IAAIS;QAG9BT,SAAS,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ;IACzC;AACJ"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
class ApolloCacheObjectIdPlugin extends Plugin {
|
|
3
|
+
static{
|
|
4
|
+
this.type = "cache-get-object-id";
|
|
5
|
+
}
|
|
6
|
+
constructor(getObjectId){
|
|
7
|
+
super();
|
|
8
|
+
this._getObjectId = getObjectId;
|
|
9
|
+
}
|
|
10
|
+
getObjectId(data) {
|
|
11
|
+
if ("function" != typeof this._getObjectId) throw Error('You must provide a "getObjectId" callable to the plugin constructor or extend the ApolloCacheObjectIdPlugin.');
|
|
12
|
+
return this._getObjectId(data);
|
|
11
13
|
}
|
|
12
|
-
return this._getObjectId(data);
|
|
13
|
-
}
|
|
14
14
|
}
|
|
15
|
+
export { ApolloCacheObjectIdPlugin };
|
|
15
16
|
|
|
16
17
|
//# sourceMappingURL=ApolloCacheObjectIdPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/ApolloCacheObjectIdPlugin.js","sources":["../../src/plugins/ApolloCacheObjectIdPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\n\nexport interface ApolloCacheObject {\n __typename?: string;\n [key: string]: any;\n}\n\ninterface ApolloCacheObjectIdPluginCallable<T> {\n // A value for `id`, null to prevent normalization, or undefined to continue with defaults.\n (data: T): string | null | undefined;\n}\n\nexport class ApolloCacheObjectIdPlugin<\n T extends ApolloCacheObject = ApolloCacheObject\n> extends Plugin {\n public static override readonly type: string = \"cache-get-object-id\";\n private readonly _getObjectId?: ApolloCacheObjectIdPluginCallable<T>;\n\n public constructor(getObjectId?: ApolloCacheObjectIdPluginCallable<T>) {\n super();\n this._getObjectId = getObjectId;\n }\n\n public getObjectId(data: T) {\n if (typeof this._getObjectId !== \"function\") {\n throw Error(\n `You must provide a \"getObjectId\" callable to the plugin constructor or extend the ApolloCacheObjectIdPlugin.`\n );\n }\n\n return this._getObjectId(data);\n }\n}\n"],"names":["ApolloCacheObjectIdPlugin","Plugin","getObjectId","data","Error"],"mappings":";AAYO,MAAMA,kCAEHC;;aAC0B,IAAI,GAAW;;IAG/C,YAAmBC,WAAkD,CAAE;QACnE,KAAK;QACL,IAAI,CAAC,YAAY,GAAGA;IACxB;IAEO,YAAYC,IAAO,EAAE;QACxB,IAAI,AAA6B,cAA7B,OAAO,IAAI,CAAC,YAAY,EACxB,MAAMC,MACF;QAIR,OAAO,IAAI,CAAC,YAAY,CAACD;IAC7B;AACJ"}
|
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
import { ApolloLink } from "apollo-link";
|
|
2
2
|
import { plugins } from "@webiny/plugins";
|
|
3
3
|
function createLink(plugin) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
try {
|
|
5
|
+
return plugin.createLink();
|
|
6
|
+
} catch (e) {
|
|
7
|
+
console.error('Caught an error while executing "createLink" on plugin', plugin);
|
|
8
|
+
console.error(e);
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
class ApolloDynamicLink extends ApolloLink {
|
|
13
|
+
request(operation, forward) {
|
|
14
|
+
const linkPlugins = plugins.byType("apollo-link");
|
|
15
|
+
if (!linkPlugins.length) return forward(operation);
|
|
16
|
+
const cacheKey = linkPlugins.map((pl)=>pl.cacheKey).join(",");
|
|
17
|
+
if (!this.cache.has(cacheKey)) {
|
|
18
|
+
const links = linkPlugins.map(createLink).filter(Boolean);
|
|
19
|
+
this.cache.set(cacheKey, ApolloLink.from(links));
|
|
20
|
+
}
|
|
21
|
+
return this.cache.get(cacheKey).request(operation, forward);
|
|
18
22
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* We filter out falsy items from the linkPlugins because there might be some error while creating link.
|
|
23
|
-
*/
|
|
24
|
-
const links = linkPlugins.map(createLink).filter(Boolean);
|
|
25
|
-
this.cache.set(cacheKey, ApolloLink.from(links));
|
|
23
|
+
constructor(...args){
|
|
24
|
+
super(...args), this.cache = new Map();
|
|
26
25
|
}
|
|
27
|
-
return this.cache.get(cacheKey).request(operation, forward);
|
|
28
|
-
}
|
|
29
26
|
}
|
|
27
|
+
export { ApolloDynamicLink };
|
|
30
28
|
|
|
31
29
|
//# sourceMappingURL=ApolloDynamicLink.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/ApolloDynamicLink.js","sources":["../../src/plugins/ApolloDynamicLink.ts"],"sourcesContent":["import type { NextLink } from \"apollo-link\";\nimport { ApolloLink } from \"apollo-link\";\nimport { plugins } from \"@webiny/plugins\";\nimport type { ApolloLinkPlugin } from \"./ApolloLinkPlugin.js\";\nimport type { Operation } from \"apollo-link/lib/types.js\";\n\nfunction createLink(plugin: ApolloLinkPlugin) {\n try {\n return plugin.createLink();\n } catch (e) {\n console.error(`Caught an error while executing \"createLink\" on plugin`, plugin);\n console.error(e);\n }\n return null;\n}\n\nexport class ApolloDynamicLink extends ApolloLink {\n private cache = new Map();\n\n public override request(operation: Operation, forward: NextLink) {\n const linkPlugins = plugins.byType<ApolloLinkPlugin>(\"apollo-link\");\n\n if (!linkPlugins.length) {\n return forward(operation);\n }\n\n const cacheKey = linkPlugins.map(pl => pl.cacheKey).join(\",\");\n\n if (!this.cache.has(cacheKey)) {\n /**\n * We filter out falsy items from the linkPlugins because there might be some error while creating link.\n */\n const links = linkPlugins.map(createLink).filter(Boolean) as ApolloLink[];\n this.cache.set(cacheKey, ApolloLink.from(links));\n }\n\n return this.cache.get(cacheKey).request(operation, forward);\n }\n}\n"],"names":["createLink","plugin","e","console","ApolloDynamicLink","ApolloLink","operation","forward","linkPlugins","plugins","cacheKey","pl","links","Boolean","Map"],"mappings":";;AAMA,SAASA,WAAWC,MAAwB;IACxC,IAAI;QACA,OAAOA,OAAO,UAAU;IAC5B,EAAE,OAAOC,GAAG;QACRC,QAAQ,KAAK,CAAC,0DAA0DF;QACxEE,QAAQ,KAAK,CAACD;IAClB;IACA,OAAO;AACX;AAEO,MAAME,0BAA0BC;IAGnB,QAAQC,SAAoB,EAAEC,OAAiB,EAAE;QAC7D,MAAMC,cAAcC,QAAQ,MAAM,CAAmB;QAErD,IAAI,CAACD,YAAY,MAAM,EACnB,OAAOD,QAAQD;QAGnB,MAAMI,WAAWF,YAAY,GAAG,CAACG,CAAAA,KAAMA,GAAG,QAAQ,EAAE,IAAI,CAAC;QAEzD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAACD,WAAW;YAI3B,MAAME,QAAQJ,YAAY,GAAG,CAACR,YAAY,MAAM,CAACa;YACjD,IAAI,CAAC,KAAK,CAAC,GAAG,CAACH,UAAUL,WAAW,IAAI,CAACO;QAC7C;QAEA,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAACF,UAAU,OAAO,CAACJ,WAAWC;IACvD;;QArBG,qBACK,KAAK,GAAG,IAAIO;;AAqBxB"}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { nanoid } from "nanoid";
|
|
2
2
|
import { Plugin } from "@webiny/plugins";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
super();
|
|
7
|
-
this.factory = factory;
|
|
8
|
-
this.cacheKey = nanoid();
|
|
9
|
-
}
|
|
10
|
-
createLink() {
|
|
11
|
-
if (this.cache) {
|
|
12
|
-
return this.cache;
|
|
3
|
+
class ApolloLinkPlugin extends Plugin {
|
|
4
|
+
static{
|
|
5
|
+
this.type = "apollo-link";
|
|
13
6
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
constructor(factory){
|
|
8
|
+
super();
|
|
9
|
+
this.factory = factory;
|
|
10
|
+
this.cacheKey = nanoid();
|
|
11
|
+
}
|
|
12
|
+
createLink() {
|
|
13
|
+
if (this.cache) return this.cache;
|
|
14
|
+
if ("function" == typeof this.factory) {
|
|
15
|
+
this.cache = this.factory();
|
|
16
|
+
return this.cache;
|
|
17
|
+
}
|
|
18
|
+
throw Error(`Missing ApolloLinkFactory in plugin "${this.name}"! Either pass a factory to ApolloLinkPlugin constructor or extend the class and override the "createLink" method.`);
|
|
17
19
|
}
|
|
18
|
-
throw Error(`Missing ApolloLinkFactory in plugin "${this.name}"! Either pass a factory to ApolloLinkPlugin constructor or extend the class and override the "createLink" method.`);
|
|
19
|
-
}
|
|
20
20
|
}
|
|
21
|
+
export { ApolloLinkPlugin };
|
|
21
22
|
|
|
22
23
|
//# sourceMappingURL=ApolloLinkPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/ApolloLinkPlugin.js","sources":["../../src/plugins/ApolloLinkPlugin.ts"],"sourcesContent":["import type { ApolloLink } from \"apollo-link\";\nimport { nanoid } from \"nanoid\";\nimport { Plugin } from \"@webiny/plugins\";\n\nexport interface ApolloLinkFactory {\n (): ApolloLink;\n}\n\nexport class ApolloLinkPlugin extends Plugin {\n public static override readonly type: string = \"apollo-link\";\n public readonly cacheKey;\n private readonly factory?: ApolloLinkFactory;\n private cache?: ApolloLink;\n\n constructor(factory?: ApolloLinkFactory) {\n super();\n this.factory = factory;\n this.cacheKey = nanoid();\n }\n\n public createLink(): ApolloLink {\n if (this.cache) {\n return this.cache;\n }\n\n if (typeof this.factory === \"function\") {\n this.cache = this.factory();\n\n return this.cache;\n }\n\n throw Error(\n `Missing ApolloLinkFactory in plugin \"${this.name}\"! Either pass a factory to ApolloLinkPlugin constructor or extend the class and override the \"createLink\" method.`\n );\n }\n}\n"],"names":["ApolloLinkPlugin","Plugin","factory","nanoid","Error"],"mappings":";;AAQO,MAAMA,yBAAyBC;;aACF,IAAI,GAAW;;IAK/C,YAAYC,OAA2B,CAAE;QACrC,KAAK;QACL,IAAI,CAAC,OAAO,GAAGA;QACf,IAAI,CAAC,QAAQ,GAAGC;IACpB;IAEO,aAAyB;QAC5B,IAAI,IAAI,CAAC,KAAK,EACV,OAAO,IAAI,CAAC,KAAK;QAGrB,IAAI,AAAwB,cAAxB,OAAO,IAAI,CAAC,OAAO,EAAiB;YACpC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO;YAEzB,OAAO,IAAI,CAAC,KAAK;QACrB;QAEA,MAAMC,MACF,CAAC,qCAAqC,EAAE,IAAI,CAAC,IAAI,CAAC,kHAAkH,CAAC;IAE7K;AACJ"}
|
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
import { ApolloLink } from "apollo-link";
|
|
2
2
|
import { ApolloLinkPlugin } from "./ApolloLinkPlugin.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
}
|
|
3
|
+
class ConsoleLinkPlugin extends ApolloLinkPlugin {
|
|
4
|
+
createLink() {
|
|
5
|
+
return new ApolloLink((operation, forward)=>{
|
|
6
|
+
const firstDefinition = operation.query.definitions[0];
|
|
7
|
+
const isQuery = "query" === firstDefinition["operation"];
|
|
8
|
+
return forward(operation).map((data)=>{
|
|
9
|
+
if (data.extensions && Array.isArray(data.extensions.console) && data.extensions.console.length) {
|
|
10
|
+
const variables = isQuery ? JSON.stringify(operation.variables) : "{ see request details in the Network tab }";
|
|
11
|
+
console.groupCollapsed(`Logs for graphQL ${isQuery ? "query" : "mutation"}: %c${operation.operationName || "anonymous operation"} %c${variables}%c`, "color: #fa5a28", "color: #6b6b6b", "color: black");
|
|
12
|
+
data.extensions.console.forEach((log)=>{
|
|
13
|
+
console[log.method](...log.args);
|
|
14
|
+
});
|
|
15
|
+
console.groupEnd();
|
|
16
|
+
}
|
|
17
|
+
return data;
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
24
21
|
}
|
|
22
|
+
export { ConsoleLinkPlugin };
|
|
25
23
|
|
|
26
24
|
//# sourceMappingURL=ConsoleLinkPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/ConsoleLinkPlugin.js","sources":["../../src/plugins/ConsoleLinkPlugin.ts"],"sourcesContent":["import type { FetchResult as BaseFetchResult } from \"apollo-link\";\nimport { ApolloLink } from \"apollo-link\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin.js\";\nimport type { OperationDefinitionNode } from \"graphql/language/ast.js\";\n\ninterface Log {\n args: any[];\n method: \"error\" | \"info\" | \"log\" | \"warn\";\n}\n\ninterface FetchResult extends BaseFetchResult {\n extensions?: {\n console?: Log[];\n };\n}\n\n/**\n * This link checks for presence of `extensions.console` in the response and logs all items to browser console.\n */\nexport class ConsoleLinkPlugin extends ApolloLinkPlugin {\n public override createLink() {\n return new ApolloLink((operation, forward) => {\n const firstDefinition = operation.query.definitions[0] as OperationDefinitionNode;\n const isQuery = firstDefinition[\"operation\"] === \"query\";\n\n return forward(operation).map((data: FetchResult) => {\n if (\n data.extensions &&\n Array.isArray(data.extensions.console) &&\n data.extensions.console.length\n ) {\n const variables = isQuery\n ? JSON.stringify(operation.variables)\n : \"{ see request details in the Network tab }\";\n console.groupCollapsed(\n `Logs for graphQL ${isQuery ? \"query\" : \"mutation\"}: %c${\n operation.operationName || \"anonymous operation\"\n } %c${variables}%c`,\n \"color: #fa5a28\",\n \"color: #6b6b6b\",\n \"color: black\"\n );\n data.extensions.console.forEach((log: Log) => {\n console[log.method](...log.args);\n });\n console.groupEnd();\n }\n\n return data;\n });\n });\n }\n}\n"],"names":["ConsoleLinkPlugin","ApolloLinkPlugin","ApolloLink","operation","forward","firstDefinition","isQuery","data","Array","variables","JSON","console","log"],"mappings":";;AAmBO,MAAMA,0BAA0BC;IACnB,aAAa;QACzB,OAAO,IAAIC,WAAW,CAACC,WAAWC;YAC9B,MAAMC,kBAAkBF,UAAU,KAAK,CAAC,WAAW,CAAC,EAAE;YACtD,MAAMG,UAAUD,AAAiC,YAAjCA,eAAe,CAAC,YAAY;YAE5C,OAAOD,QAAQD,WAAW,GAAG,CAAC,CAACI;gBAC3B,IACIA,KAAK,UAAU,IACfC,MAAM,OAAO,CAACD,KAAK,UAAU,CAAC,OAAO,KACrCA,KAAK,UAAU,CAAC,OAAO,CAAC,MAAM,EAChC;oBACE,MAAME,YAAYH,UACZI,KAAK,SAAS,CAACP,UAAU,SAAS,IAClC;oBACNQ,QAAQ,cAAc,CAClB,CAAC,iBAAiB,EAAEL,UAAU,UAAU,WAAW,IAAI,EACnDH,UAAU,aAAa,IAAI,sBAC9B,GAAG,EAAEM,UAAU,EAAE,CAAC,EACnB,kBACA,kBACA;oBAEJF,KAAK,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAACK;wBAC7BD,OAAO,CAACC,IAAI,MAAM,CAAC,IAAIA,IAAI,IAAI;oBACnC;oBACAD,QAAQ,QAAQ;gBACpB;gBAEA,OAAOJ;YACX;QACJ;IACJ;AACJ"}
|
|
@@ -1,55 +1,49 @@
|
|
|
1
|
-
import
|
|
1
|
+
import react, { useState } from "react";
|
|
2
2
|
import { Typography } from "./Typography.js";
|
|
3
3
|
import { i18n } from "../../i18n/index.js";
|
|
4
4
|
import { OverlayWrapper } from "./StyledComponents.js";
|
|
5
|
-
import { ReactComponent
|
|
5
|
+
import { ReactComponent } from "./assets/close_24px.js";
|
|
6
6
|
const t = i18n.ns("app/graphql/error-overlay");
|
|
7
7
|
const ENVIRONMENT_VARIABLES_ARTICLE_LINK = "https://www.webiny.com/docs/how-to-guides/environment-variables";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}, message), description && /*#__PURE__*/React.createElement("div", {
|
|
36
|
-
className: "body__description"
|
|
37
|
-
}, description)), /*#__PURE__*/React.createElement("div", {
|
|
38
|
-
className: "footer"
|
|
39
|
-
}, /*#__PURE__*/React.createElement(Typography, {
|
|
40
|
-
use: "body"
|
|
41
|
-
}, t`
|
|
8
|
+
const ErrorOverlay = (props)=>{
|
|
9
|
+
const { title = "An error occurred", message, description, closeable } = props;
|
|
10
|
+
const [open, setOpen] = useState(true);
|
|
11
|
+
if (!open) return null;
|
|
12
|
+
return /*#__PURE__*/ react.createElement(OverlayWrapper, null, /*#__PURE__*/ react.createElement("div", {
|
|
13
|
+
className: "inner"
|
|
14
|
+
}, /*#__PURE__*/ react.createElement("div", {
|
|
15
|
+
className: "header"
|
|
16
|
+
}, /*#__PURE__*/ react.createElement("div", {
|
|
17
|
+
className: "header__title"
|
|
18
|
+
}, /*#__PURE__*/ react.createElement(Typography, {
|
|
19
|
+
use: "headline"
|
|
20
|
+
}, title)), false !== closeable && /*#__PURE__*/ react.createElement("div", {
|
|
21
|
+
className: "header__action"
|
|
22
|
+
}, /*#__PURE__*/ react.createElement("span", {
|
|
23
|
+
onClick: ()=>setOpen(false)
|
|
24
|
+
}, /*#__PURE__*/ react.createElement(ReactComponent, null)))), /*#__PURE__*/ react.createElement("div", {
|
|
25
|
+
className: "body"
|
|
26
|
+
}, /*#__PURE__*/ react.createElement("div", {
|
|
27
|
+
className: "body__summary"
|
|
28
|
+
}, message), description && /*#__PURE__*/ react.createElement("div", {
|
|
29
|
+
className: "body__description"
|
|
30
|
+
}, description)), /*#__PURE__*/ react.createElement("div", {
|
|
31
|
+
className: "footer"
|
|
32
|
+
}, /*#__PURE__*/ react.createElement(Typography, {
|
|
33
|
+
use: "body"
|
|
34
|
+
}, t`
|
|
42
35
|
This screen is only visible if {message} environment variable is set.
|
|
43
36
|
Read more about it in the {link}. `({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
37
|
+
message: /*#__PURE__*/ react.createElement("span", {
|
|
38
|
+
className: "highlight"
|
|
39
|
+
}, "`REACT_APP_DEBUG=true`"),
|
|
40
|
+
link: /*#__PURE__*/ react.createElement("a", {
|
|
41
|
+
href: ENVIRONMENT_VARIABLES_ARTICLE_LINK,
|
|
42
|
+
target: "_blank",
|
|
43
|
+
rel: "noreferrer noopener"
|
|
44
|
+
}, "environment variables article")
|
|
45
|
+
}), /*#__PURE__*/ react.createElement("br", null), t`Open your browser's developer console to further inspect this error.`))));
|
|
53
46
|
};
|
|
47
|
+
export { ErrorOverlay };
|
|
54
48
|
|
|
55
49
|
//# sourceMappingURL=ErrorOverlay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/NetworkErrorLinkPlugin/ErrorOverlay.js","sources":["../../../src/plugins/NetworkErrorLinkPlugin/ErrorOverlay.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { Typography } from \"./Typography.js\";\nimport { i18n } from \"../../i18n/index.js\";\nimport { OverlayWrapper } from \"./StyledComponents.js\";\nimport { ReactComponent as CloseIcon } from \"./assets/close_24px.svg\";\n\nconst t = i18n.ns(\"app/graphql/error-overlay\");\n\nconst ENVIRONMENT_VARIABLES_ARTICLE_LINK =\n \"https://www.webiny.com/docs/how-to-guides/environment-variables\";\n\ntype ErrorOverlayProps = Partial<{\n title: React.ReactNode;\n message: React.ReactNode;\n description: React.ReactNode;\n closeable?: boolean;\n}>;\n\nexport const ErrorOverlay = (props: ErrorOverlayProps) => {\n const { title = \"An error occurred\", message, description, closeable } = props;\n const [open, setOpen] = useState(true);\n if (!open) {\n return null;\n }\n\n return (\n <OverlayWrapper>\n <div className=\"inner\">\n <div className=\"header\">\n <div className=\"header__title\">\n <Typography use={\"headline\"}>{title}</Typography>\n </div>\n {closeable !== false && (\n <div className=\"header__action\">\n <span onClick={() => setOpen(false)}>\n <CloseIcon />\n </span>\n </div>\n )}\n </div>\n <div className=\"body\">\n <div className=\"body__summary\">{message}</div>\n {description && <div className=\"body__description\">{description}</div>}\n </div>\n <div className=\"footer\">\n <Typography use={\"body\"}>\n {t`\n This screen is only visible if {message} environment variable is set.\n Read more about it in the {link}. `({\n message: <span className={\"highlight\"}>`REACT_APP_DEBUG=true`</span>,\n link: (\n <a\n href={ENVIRONMENT_VARIABLES_ARTICLE_LINK}\n target={\"_blank\"}\n rel={\"noreferrer noopener\"}\n >\n environment variables article\n </a>\n )\n })}\n <br />\n {t`Open your browser's developer console to further inspect this error.`}\n </Typography>\n </div>\n </div>\n </OverlayWrapper>\n );\n};\n"],"names":["t","i18n","ENVIRONMENT_VARIABLES_ARTICLE_LINK","ErrorOverlay","props","title","message","description","closeable","open","setOpen","useState","OverlayWrapper","Typography","CloseIcon"],"mappings":";;;;;AAMA,MAAMA,IAAIC,KAAK,EAAE,CAAC;AAElB,MAAMC,qCACF;AASG,MAAMC,eAAe,CAACC;IACzB,MAAM,EAAEC,QAAQ,mBAAmB,EAAEC,OAAO,EAAEC,WAAW,EAAEC,SAAS,EAAE,GAAGJ;IACzE,MAAM,CAACK,MAAMC,QAAQ,GAAGC,SAAS;IACjC,IAAI,CAACF,MACD,OAAO;IAGX,OAAO,WAAP,GACI,oBAACG,gBAAcA,MAAAA,WAAAA,GACX,oBAAC;QAAI,WAAU;qBACX,oBAAC;QAAI,WAAU;qBACX,oBAAC;QAAI,WAAU;qBACX,oBAACC,YAAUA;QAAC,KAAK;OAAaR,SAEjCG,AAAc,UAAdA,aAAuB,WAAT,GACX,oBAAC;QAAI,WAAU;qBACX,oBAAC;QAAK,SAAS,IAAME,QAAQ;qBACzB,oBAACI,gBAASA,UAAAA,WAAAA,GAK1B,oBAAC;QAAI,WAAU;qBACX,oBAAC;QAAI,WAAU;OAAiBR,UAC/BC,eAAe,WAAfA,GAAe,oBAAC;QAAI,WAAU;OAAqBA,eAAAA,WAAAA,GAExD,oBAAC;QAAI,WAAU;qBACX,oBAACM,YAAUA;QAAC,KAAK;OACZb,CAAC,CAAC;;0DAE+B,CAAC,CAAC;QAChC,SAAS,WAAT,GAAS,oBAAC;YAAK,WAAW;WAAa;QACvC,MAAM,WAAN,GACI,oBAAC;YACG,MAAME;YACN,QAAQ;YACR,KAAK;WACR;IAIT,kBACA,oBAAC,aACAF,CAAC,CAAC,oEAAoE,CAAC;AAMhG"}
|