@webiny/app 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f
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 +26 -0
- package/App.js +95 -0
- package/App.js.map +1 -0
- package/AppContainer.d.ts +23 -0
- package/AppContainer.js +9 -0
- package/AppContainer.js.map +1 -0
- package/apollo-client/InMemoryCache.d.ts +4 -3
- package/apollo-client/InMemoryCache.js +13 -52
- package/apollo-client/InMemoryCache.js.map +1 -0
- package/apollo-client/IntrospectionFragmentMatcher.d.ts +11 -0
- package/apollo-client/IntrospectionFragmentMatcher.js +45 -0
- package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -0
- package/components/Image.d.ts +3 -3
- package/components/Image.js +12 -17
- package/components/Image.js.map +1 -0
- package/components/Routes.d.ts +2 -2
- package/components/Routes.js +20 -19
- package/components/Routes.js.map +1 -0
- package/components/View.d.ts +1 -1
- package/components/View.js +13 -17
- package/components/View.js.map +1 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +4 -1
- package/components/index.js.map +1 -0
- package/config/RouterConfig/Route.d.ts +30 -0
- package/config/RouterConfig/Route.js +42 -0
- package/config/RouterConfig/Route.js.map +1 -0
- package/config/RouterConfig.d.ts +32 -0
- package/config/RouterConfig.js +18 -0
- package/config/RouterConfig.js.map +1 -0
- package/config.d.ts +8 -0
- package/config.js +25 -0
- package/config.js.map +1 -0
- package/contexts/Ui/index.d.ts +5 -8
- package/contexts/Ui/index.js +27 -64
- package/contexts/Ui/index.js.map +1 -0
- package/core/DebounceRender.d.ts +12 -0
- package/core/DebounceRender.js +31 -0
- package/core/DebounceRender.js.map +1 -0
- package/core/Plugin.d.ts +8 -0
- package/core/Plugin.js +14 -0
- package/core/Plugin.js.map +1 -0
- package/core/Plugins.d.ts +15 -0
- package/core/Plugins.js +39 -0
- package/core/Plugins.js.map +1 -0
- package/core/Provider.d.ts +8 -0
- package/core/Provider.js +18 -0
- package/core/Provider.js.map +1 -0
- package/core/Routes.d.ts +6 -0
- package/core/Routes.js +34 -0
- package/core/Routes.js.map +1 -0
- package/core/createProvider.d.ts +10 -0
- package/core/createProvider.js +9 -0
- package/core/createProvider.js.map +1 -0
- package/core/createProviderPlugin.d.ts +8 -0
- package/core/createProviderPlugin.js +17 -0
- package/core/createProviderPlugin.js.map +1 -0
- package/hooks/useAutocomplete/index.js +3 -1
- package/hooks/useAutocomplete/index.js.map +1 -0
- package/hooks/useAutocomplete/useAutocomplete.d.ts +6 -1
- package/hooks/useAutocomplete/useAutocomplete.js +11 -15
- package/hooks/useAutocomplete/useAutocomplete.js.map +1 -0
- package/hooks/useDataList/functions/getData.d.ts +1 -1
- package/hooks/useDataList/functions/getData.js +3 -3
- package/hooks/useDataList/functions/getData.js.map +1 -0
- package/hooks/useDataList/functions/getError.d.ts +1 -1
- package/hooks/useDataList/functions/getError.js +3 -3
- package/hooks/useDataList/functions/getError.js.map +1 -0
- package/hooks/useDataList/functions/getMeta.d.ts +1 -1
- package/hooks/useDataList/functions/getMeta.js +3 -3
- package/hooks/useDataList/functions/getMeta.js.map +1 -0
- package/hooks/useDataList/functions/index.js +3 -1
- package/hooks/useDataList/functions/index.js.map +1 -0
- package/hooks/useDataList/functions/searchDataByKey.d.ts +1 -1
- package/hooks/useDataList/functions/searchDataByKey.js +5 -8
- package/hooks/useDataList/functions/searchDataByKey.js.map +1 -0
- package/hooks/useDataList/index.js +3 -1
- package/hooks/useDataList/index.js.map +1 -0
- package/hooks/useDataList/useDataList.d.ts +6 -6
- package/hooks/useDataList/useDataList.js +80 -90
- package/hooks/useDataList/useDataList.js.map +1 -0
- package/hooks/useDataList/utils/index.js +3 -1
- package/hooks/useDataList/utils/index.js.map +1 -0
- package/hooks/useDataList/utils/prepareLoadListParams.d.ts +9 -3
- package/hooks/useDataList/utils/prepareLoadListParams.js +35 -31
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -0
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.d.ts +13 -4
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +13 -9
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +1 -0
- package/hooks/useDataList/utils/types.d.ts +21 -15
- package/hooks/useDataList/utils/types.js +3 -1
- package/hooks/useDataList/utils/types.js.map +1 -0
- package/hooks/useHandler.d.ts +11 -1
- package/hooks/useHandler.js +13 -6
- package/hooks/useHandler.js.map +1 -0
- package/hooks/useHandlers.d.ts +4 -4
- package/hooks/useHandlers.js +15 -11
- package/hooks/useHandlers.js.map +1 -0
- package/hooks/useRegisterLegacyPlugin.d.ts +2 -0
- package/hooks/useRegisterLegacyPlugin.js +11 -0
- package/hooks/useRegisterLegacyPlugin.js.map +1 -0
- package/hooks/useUi.d.ts +1 -1
- package/hooks/useUi.js +5 -3
- package/hooks/useUi.js.map +1 -0
- package/i18n/i18n.js +3 -1
- package/i18n/i18n.js.map +1 -0
- package/i18n/index.js +3 -1
- package/i18n/index.js.map +1 -0
- package/index.d.ts +17 -0
- package/index.js +20 -0
- package/index.js.map +1 -0
- package/package.json +27 -27
- package/plugins/AddQuerySelectionPlugin.d.ts +10 -3
- package/plugins/AddQuerySelectionPlugin.js +63 -92
- package/plugins/AddQuerySelectionPlugin.js.map +1 -0
- package/plugins/ApolloCacheObjectIdPlugin.d.ts +8 -8
- package/plugins/ApolloCacheObjectIdPlugin.js +12 -36
- package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -0
- package/plugins/ApolloDynamicLink.d.ts +3 -1
- package/plugins/ApolloDynamicLink.js +19 -50
- package/plugins/ApolloDynamicLink.js.map +1 -0
- package/plugins/ApolloLinkPlugin.d.ts +6 -6
- package/plugins/ApolloLinkPlugin.js +18 -39
- package/plugins/ApolloLinkPlugin.js.map +1 -0
- package/plugins/ConsoleLinkPlugin.js +19 -40
- package/plugins/ConsoleLinkPlugin.js.map +1 -0
- package/plugins/LocaleHeaderLinkPlugin.d.ts +3 -7
- package/plugins/LocaleHeaderLinkPlugin.js +22 -51
- package/plugins/LocaleHeaderLinkPlugin.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts +13 -5
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +21 -31
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +8 -2
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +76 -7
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.d.ts +6 -4
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +20 -16
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin.js +20 -35
- package/plugins/NetworkErrorLinkPlugin.js.map +1 -0
- package/plugins/OmitTypenameLinkPlugin.js +11 -31
- package/plugins/OmitTypenameLinkPlugin.js.map +1 -0
- package/plugins/RoutePlugin.d.ts +3 -3
- package/plugins/RoutePlugin.js +12 -32
- package/plugins/RoutePlugin.js.map +1 -0
- package/plugins/TenantHeaderLinkPlugin.d.ts +3 -7
- package/plugins/TenantHeaderLinkPlugin.js +29 -61
- package/plugins/TenantHeaderLinkPlugin.js.map +1 -0
- package/plugins/ViewPlugin.d.ts +5 -5
- package/plugins/ViewPlugin.js +15 -37
- package/plugins/ViewPlugin.js.map +1 -0
- package/plugins/image.d.ts +1 -1
- package/plugins/image.js +65 -85
- package/plugins/image.js.map +1 -0
- package/plugins/index.d.ts +3 -3
- package/plugins/index.js +35 -42
- package/plugins/index.js.map +1 -0
- package/react-butterfiles/Files.d.ts +69 -0
- package/react-butterfiles/Files.js +227 -0
- package/react-butterfiles/Files.js.map +1 -0
- package/react-butterfiles/index.d.ts +2 -0
- package/react-butterfiles/index.js +4 -0
- package/react-butterfiles/index.js.map +1 -0
- package/react-butterfiles/utils/generateId.d.ts +1 -0
- package/react-butterfiles/utils/generateId.js +5 -0
- package/react-butterfiles/utils/generateId.js.map +1 -0
- package/react-butterfiles/utils/readFileContent.d.ts +1 -0
- package/react-butterfiles/utils/readFileContent.js +15 -0
- package/react-butterfiles/utils/readFileContent.js.map +1 -0
- package/renderApp.d.ts +2 -0
- package/renderApp.js +9 -0
- package/renderApp.js.map +1 -0
- package/types.d.ts +29 -24
- package/types.js +13 -1
- package/types.js.map +1 -0
- package/utils/createGenericContext.d.ts +13 -0
- package/utils/createGenericContext.js +25 -0
- package/utils/createGenericContext.js.map +1 -0
- package/utils/createHashing.d.ts +2 -0
- package/utils/createHashing.js +18 -0
- package/utils/createHashing.js.map +1 -0
- package/utils/getApiUrl.d.ts +1 -0
- package/utils/getApiUrl.js +5 -0
- package/utils/getApiUrl.js.map +1 -0
- package/utils/getGqlApiUrl.d.ts +1 -0
- package/utils/getGqlApiUrl.js +6 -0
- package/utils/getGqlApiUrl.js.map +1 -0
- package/utils/getHeadlessCmsGqlApiUrl.d.ts +5 -0
- package/utils/getHeadlessCmsGqlApiUrl.js +12 -0
- package/utils/getHeadlessCmsGqlApiUrl.js.map +1 -0
- package/utils/getLocaleCode.d.ts +6 -0
- package/utils/getLocaleCode.js +33 -0
- package/utils/getLocaleCode.js.map +1 -0
- package/utils/getPrerenderId.d.ts +6 -0
- package/utils/getPrerenderId.js +5 -0
- package/utils/getPrerenderId.js.map +1 -0
- package/utils/getTenantId.d.ts +6 -0
- package/utils/getTenantId.js +45 -0
- package/utils/getTenantId.js.map +1 -0
- package/utils/index.d.ts +10 -0
- package/utils/index.js +12 -0
- package/utils/index.js.map +1 -0
- package/utils/isLocalhost.d.ts +1 -0
- package/utils/isLocalhost.js +7 -0
- package/utils/isLocalhost.js.map +1 -0
- package/utils/isPrerendering.d.ts +1 -0
- package/utils/isPrerendering.js +5 -0
- package/utils/isPrerendering.js.map +1 -0
- package/utils/legacyPluginToReactComponent.d.ts +7 -0
- package/utils/legacyPluginToReactComponent.js +14 -0
- package/utils/legacyPluginToReactComponent.js.map +1 -0
|
@@ -1,62 +1,31 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
6
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
1
|
import { ApolloLink } from "apollo-link";
|
|
8
2
|
import { plugins } from "@webiny/plugins";
|
|
9
|
-
|
|
10
3
|
function createLink(plugin) {
|
|
11
4
|
try {
|
|
12
5
|
return plugin.createLink();
|
|
13
6
|
} catch (e) {
|
|
14
|
-
console.error(
|
|
7
|
+
console.error(`Caught an error while executing "createLink" on plugin`, plugin);
|
|
15
8
|
console.error(e);
|
|
16
9
|
}
|
|
10
|
+
return null;
|
|
17
11
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function ApolloDynamicLink() {
|
|
25
|
-
var _this;
|
|
26
|
-
|
|
27
|
-
_classCallCheck(this, ApolloDynamicLink);
|
|
28
|
-
|
|
29
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
30
|
-
args[_key] = arguments[_key];
|
|
12
|
+
export class ApolloDynamicLink extends ApolloLink {
|
|
13
|
+
cache = new Map();
|
|
14
|
+
request(operation, forward) {
|
|
15
|
+
const linkPlugins = plugins.byType("apollo-link");
|
|
16
|
+
if (!linkPlugins.length) {
|
|
17
|
+
return forward(operation);
|
|
31
18
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
_createClass(ApolloDynamicLink, [{
|
|
41
|
-
key: "request",
|
|
42
|
-
value: function request(operation, forward) {
|
|
43
|
-
var linkPlugins = plugins.byType("apollo-link");
|
|
44
|
-
|
|
45
|
-
if (!linkPlugins.length) {
|
|
46
|
-
return forward(operation);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
var cacheKey = linkPlugins.map(function (pl) {
|
|
50
|
-
return pl.cacheKey;
|
|
51
|
-
}).join(",");
|
|
52
|
-
|
|
53
|
-
if (!this.cache.has(cacheKey)) {
|
|
54
|
-
this.cache.set(cacheKey, ApolloLink.from(linkPlugins.map(createLink)));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return this.cache.get(cacheKey).request(operation, forward);
|
|
19
|
+
const cacheKey = linkPlugins.map(pl => pl.cacheKey).join(",");
|
|
20
|
+
if (!this.cache.has(cacheKey)) {
|
|
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));
|
|
58
26
|
}
|
|
59
|
-
|
|
27
|
+
return this.cache.get(cacheKey).request(operation, forward);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
60
30
|
|
|
61
|
-
|
|
62
|
-
}(ApolloLink);
|
|
31
|
+
//# sourceMappingURL=ApolloDynamicLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ApolloLink","plugins","createLink","plugin","e","console","error","ApolloDynamicLink","cache","Map","request","operation","forward","linkPlugins","byType","length","cacheKey","map","pl","join","has","links","filter","Boolean","set","from","get"],"sources":["ApolloDynamicLink.ts"],"sourcesContent":["import type { NextLink } from \"apollo-link\";\nimport { ApolloLink } from \"apollo-link\";\nimport { plugins } from \"@webiny/plugins\";\nimport type { ApolloLinkPlugin } from \"./ApolloLinkPlugin\";\nimport type { Operation } from \"apollo-link/lib/types\";\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"],"mappings":"AACA,SAASA,UAAU,QAAQ,aAAa;AACxC,SAASC,OAAO,QAAQ,iBAAiB;AAIzC,SAASC,UAAUA,CAACC,MAAwB,EAAE;EAC1C,IAAI;IACA,OAAOA,MAAM,CAACD,UAAU,CAAC,CAAC;EAC9B,CAAC,CAAC,OAAOE,CAAC,EAAE;IACRC,OAAO,CAACC,KAAK,CAAC,wDAAwD,EAAEH,MAAM,CAAC;IAC/EE,OAAO,CAACC,KAAK,CAACF,CAAC,CAAC;EACpB;EACA,OAAO,IAAI;AACf;AAEA,OAAO,MAAMG,iBAAiB,SAASP,UAAU,CAAC;EACtCQ,KAAK,GAAG,IAAIC,GAAG,CAAC,CAAC;EAETC,OAAOA,CAACC,SAAoB,EAAEC,OAAiB,EAAE;IAC7D,MAAMC,WAAW,GAAGZ,OAAO,CAACa,MAAM,CAAmB,aAAa,CAAC;IAEnE,IAAI,CAACD,WAAW,CAACE,MAAM,EAAE;MACrB,OAAOH,OAAO,CAACD,SAAS,CAAC;IAC7B;IAEA,MAAMK,QAAQ,GAAGH,WAAW,CAACI,GAAG,CAACC,EAAE,IAAIA,EAAE,CAACF,QAAQ,CAAC,CAACG,IAAI,CAAC,GAAG,CAAC;IAE7D,IAAI,CAAC,IAAI,CAACX,KAAK,CAACY,GAAG,CAACJ,QAAQ,CAAC,EAAE;MAC3B;AACZ;AACA;MACY,MAAMK,KAAK,GAAGR,WAAW,CAACI,GAAG,CAACf,UAAU,CAAC,CAACoB,MAAM,CAACC,OAAO,CAAiB;MACzE,IAAI,CAACf,KAAK,CAACgB,GAAG,CAACR,QAAQ,EAAEhB,UAAU,CAACyB,IAAI,CAACJ,KAAK,CAAC,CAAC;IACpD;IAEA,OAAO,IAAI,CAACb,KAAK,CAACkB,GAAG,CAACV,QAAQ,CAAC,CAACN,OAAO,CAACC,SAAS,EAAEC,OAAO,CAAC;EAC/D;AACJ","ignoreList":[]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ApolloLink } from "apollo-link";
|
|
1
|
+
import type { ApolloLink } from "apollo-link";
|
|
2
2
|
import { Plugin } from "@webiny/plugins";
|
|
3
|
-
interface ApolloLinkFactory {
|
|
3
|
+
export interface ApolloLinkFactory {
|
|
4
4
|
(): ApolloLink;
|
|
5
5
|
}
|
|
6
6
|
export declare class ApolloLinkPlugin extends Plugin {
|
|
7
|
-
static readonly type
|
|
8
|
-
readonly cacheKey:
|
|
9
|
-
private factory
|
|
7
|
+
static readonly type: string;
|
|
8
|
+
readonly cacheKey: string;
|
|
9
|
+
private readonly factory?;
|
|
10
|
+
private cache?;
|
|
10
11
|
constructor(factory?: ApolloLinkFactory);
|
|
11
12
|
createLink(): ApolloLink;
|
|
12
13
|
}
|
|
13
|
-
export {};
|
|
@@ -1,43 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
6
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
|
+
import { nanoid } from "nanoid";
|
|
7
2
|
import { Plugin } from "@webiny/plugins";
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _this;
|
|
15
|
-
|
|
16
|
-
_classCallCheck(this, ApolloLinkPlugin);
|
|
17
|
-
|
|
18
|
-
_this = _super.call(this);
|
|
19
|
-
|
|
20
|
-
_defineProperty(_assertThisInitialized(_this), "cacheKey", void 0);
|
|
21
|
-
|
|
22
|
-
_defineProperty(_assertThisInitialized(_this), "factory", void 0);
|
|
23
|
-
|
|
24
|
-
_this.factory = factory;
|
|
25
|
-
_this.cacheKey = Date.now();
|
|
26
|
-
return _this;
|
|
3
|
+
export class ApolloLinkPlugin extends Plugin {
|
|
4
|
+
static type = "apollo-link";
|
|
5
|
+
constructor(factory) {
|
|
6
|
+
super();
|
|
7
|
+
this.factory = factory;
|
|
8
|
+
this.cacheKey = nanoid();
|
|
27
9
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
value: function createLink() {
|
|
32
|
-
if (typeof this.factory === "function") {
|
|
33
|
-
return this.factory();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
throw Error("Missing ApolloLinkFactory in plugin \"".concat(this.name, "\"! Either pass a factory to ApolloLinkPlugin constructor or extend the class and override the \"createLink\" method."));
|
|
10
|
+
createLink() {
|
|
11
|
+
if (this.cache) {
|
|
12
|
+
return this.cache;
|
|
37
13
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
14
|
+
if (typeof this.factory === "function") {
|
|
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.`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
42
21
|
|
|
43
|
-
|
|
22
|
+
//# sourceMappingURL=ApolloLinkPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["nanoid","Plugin","ApolloLinkPlugin","type","constructor","factory","cacheKey","createLink","cache","Error","name"],"sources":["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"],"mappings":"AACA,SAASA,MAAM,QAAQ,QAAQ;AAC/B,SAASC,MAAM,QAAQ,iBAAiB;AAMxC,OAAO,MAAMC,gBAAgB,SAASD,MAAM,CAAC;EACzC,OAAgCE,IAAI,GAAW,aAAa;EAK5DC,WAAWA,CAACC,OAA2B,EAAE;IACrC,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,QAAQ,GAAGN,MAAM,CAAC,CAAC;EAC5B;EAEOO,UAAUA,CAAA,EAAe;IAC5B,IAAI,IAAI,CAACC,KAAK,EAAE;MACZ,OAAO,IAAI,CAACA,KAAK;IACrB;IAEA,IAAI,OAAO,IAAI,CAACH,OAAO,KAAK,UAAU,EAAE;MACpC,IAAI,CAACG,KAAK,GAAG,IAAI,CAACH,OAAO,CAAC,CAAC;MAE3B,OAAO,IAAI,CAACG,KAAK;IACrB;IAEA,MAAMC,KAAK,CACP,wCAAwC,IAAI,CAACC,IAAI,oHACrD,CAAC;EACL;AACJ","ignoreList":[]}
|
|
@@ -1,47 +1,26 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
6
1
|
import { ApolloLink } from "apollo-link";
|
|
7
2
|
import { ApolloLinkPlugin } from "./ApolloLinkPlugin";
|
|
8
3
|
/**
|
|
9
4
|
* This link checks for presence of `extensions.console` in the response and logs all items to browser console.
|
|
10
5
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return new ApolloLink(function (operation, forward) {
|
|
27
|
-
var isQuery = operation.query.definitions[0]["operation"] === "query";
|
|
28
|
-
return forward(operation).map(function (data) {
|
|
29
|
-
if (data.extensions && Array.isArray(data.extensions.console) && data.extensions.console.length) {
|
|
30
|
-
var variables = isQuery ? JSON.stringify(operation.variables) : "{ see request details in the Network tab }";
|
|
31
|
-
console.groupCollapsed("Logs for graphQL ".concat(isQuery ? "query" : "mutation", ": %c").concat(operation.operationName || "anonymous operation", " %c").concat(variables, "%c"), "color: #fa5a28", "color: #6b6b6b", "color: black");
|
|
32
|
-
data.extensions.console.forEach(function (log) {
|
|
33
|
-
var _console;
|
|
34
|
-
|
|
35
|
-
(_console = console)[log.method].apply(_console, _toConsumableArray(log.args));
|
|
36
|
-
});
|
|
37
|
-
console.groupEnd();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return data;
|
|
41
|
-
});
|
|
6
|
+
export class ConsoleLinkPlugin extends ApolloLinkPlugin {
|
|
7
|
+
createLink() {
|
|
8
|
+
return new ApolloLink((operation, forward) => {
|
|
9
|
+
const firstDefinition = operation.query.definitions[0];
|
|
10
|
+
const isQuery = firstDefinition["operation"] === "query";
|
|
11
|
+
return forward(operation).map(data => {
|
|
12
|
+
if (data.extensions && Array.isArray(data.extensions.console) && data.extensions.console.length) {
|
|
13
|
+
const variables = isQuery ? JSON.stringify(operation.variables) : "{ see request details in the Network tab }";
|
|
14
|
+
console.groupCollapsed(`Logs for graphQL ${isQuery ? "query" : "mutation"}: %c${operation.operationName || "anonymous operation"} %c${variables}%c`, "color: #fa5a28", "color: #6b6b6b", "color: black");
|
|
15
|
+
data.extensions.console.forEach(log => {
|
|
16
|
+
console[log.method](...log.args);
|
|
17
|
+
});
|
|
18
|
+
console.groupEnd();
|
|
19
|
+
}
|
|
20
|
+
return data;
|
|
42
21
|
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
45
25
|
|
|
46
|
-
|
|
47
|
-
}(ApolloLinkPlugin);
|
|
26
|
+
//# sourceMappingURL=ConsoleLinkPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ApolloLink","ApolloLinkPlugin","ConsoleLinkPlugin","createLink","operation","forward","firstDefinition","query","definitions","isQuery","map","data","extensions","Array","isArray","console","length","variables","JSON","stringify","groupCollapsed","operationName","forEach","log","method","args","groupEnd"],"sources":["ConsoleLinkPlugin.ts"],"sourcesContent":["import type { FetchResult as BaseFetchResult } from \"apollo-link\";\nimport { ApolloLink } from \"apollo-link\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin\";\nimport type { OperationDefinitionNode } from \"graphql/language/ast\";\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"],"mappings":"AACA,SAASA,UAAU,QAAQ,aAAa;AACxC,SAASC,gBAAgB;AAczB;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,SAASD,gBAAgB,CAAC;EACpCE,UAAUA,CAAA,EAAG;IACzB,OAAO,IAAIH,UAAU,CAAC,CAACI,SAAS,EAAEC,OAAO,KAAK;MAC1C,MAAMC,eAAe,GAAGF,SAAS,CAACG,KAAK,CAACC,WAAW,CAAC,CAAC,CAA4B;MACjF,MAAMC,OAAO,GAAGH,eAAe,CAAC,WAAW,CAAC,KAAK,OAAO;MAExD,OAAOD,OAAO,CAACD,SAAS,CAAC,CAACM,GAAG,CAAEC,IAAiB,IAAK;QACjD,IACIA,IAAI,CAACC,UAAU,IACfC,KAAK,CAACC,OAAO,CAACH,IAAI,CAACC,UAAU,CAACG,OAAO,CAAC,IACtCJ,IAAI,CAACC,UAAU,CAACG,OAAO,CAACC,MAAM,EAChC;UACE,MAAMC,SAAS,GAAGR,OAAO,GACnBS,IAAI,CAACC,SAAS,CAACf,SAAS,CAACa,SAAS,CAAC,GACnC,4CAA4C;UAClDF,OAAO,CAACK,cAAc,CAClB,oBAAoBX,OAAO,GAAG,OAAO,GAAG,UAAU,OAC9CL,SAAS,CAACiB,aAAa,IAAI,qBAAqB,MAC9CJ,SAAS,IAAI,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,cACJ,CAAC;UACDN,IAAI,CAACC,UAAU,CAACG,OAAO,CAACO,OAAO,CAAEC,GAAQ,IAAK;YAC1CR,OAAO,CAACQ,GAAG,CAACC,MAAM,CAAC,CAAC,GAAGD,GAAG,CAACE,IAAI,CAAC;UACpC,CAAC,CAAC;UACFV,OAAO,CAACW,QAAQ,CAAC,CAAC;QACtB;QAEA,OAAOf,IAAI;MACf,CAAC,CAAC;IACN,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { ApolloLinkPlugin } from "./ApolloLinkPlugin";
|
|
2
|
-
|
|
3
|
-
interface Window {
|
|
4
|
-
__PS_RENDER_LOCALE__: string;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
2
|
+
import type { ApolloLink } from "apollo-link";
|
|
7
3
|
/**
|
|
8
4
|
* Append `x-i18n-locale` header from URL query (necessary for prerendering service).
|
|
9
5
|
*/
|
|
10
6
|
export declare class LocaleHeaderLinkPlugin extends ApolloLinkPlugin {
|
|
11
|
-
private locale;
|
|
7
|
+
private readonly locale;
|
|
12
8
|
constructor(locale?: string);
|
|
13
|
-
createLink():
|
|
9
|
+
createLink(): ApolloLink;
|
|
14
10
|
}
|
|
@@ -1,61 +1,32 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
-
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
7
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
1
|
import { setContext } from "apollo-link-context";
|
|
9
2
|
import { ApolloLinkPlugin } from "./ApolloLinkPlugin";
|
|
3
|
+
import { getLocaleCode } from "../utils";
|
|
10
4
|
|
|
11
5
|
/**
|
|
12
6
|
* Append `x-i18n-locale` header from URL query (necessary for prerendering service).
|
|
13
7
|
*/
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
function LocaleHeaderLinkPlugin(locale) {
|
|
20
|
-
var _this;
|
|
21
|
-
|
|
22
|
-
_classCallCheck(this, LocaleHeaderLinkPlugin);
|
|
23
|
-
|
|
24
|
-
_this = _super.call(this);
|
|
25
|
-
|
|
26
|
-
_defineProperty(_assertThisInitialized(_this), "locale", void 0);
|
|
27
|
-
|
|
28
|
-
if (!locale) {
|
|
29
|
-
var query = new URLSearchParams(location.search);
|
|
30
|
-
locale = query.get("__locale") || window.__PS_RENDER_LOCALE__;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
_this.locale = locale;
|
|
34
|
-
return _this;
|
|
8
|
+
export class LocaleHeaderLinkPlugin extends ApolloLinkPlugin {
|
|
9
|
+
constructor(locale) {
|
|
10
|
+
super();
|
|
11
|
+
this.locale = locale || getLocaleCode();
|
|
35
12
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return setContext(function (_, _ref) {
|
|
43
|
-
var headers = _ref.headers;
|
|
44
|
-
|
|
45
|
-
if (_this2.locale) {
|
|
46
|
-
return {
|
|
47
|
-
headers: _objectSpread(_objectSpread({}, headers), {}, {
|
|
48
|
-
"x-i18n-locale": "content:".concat(_this2.locale, ";")
|
|
49
|
-
})
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
13
|
+
createLink() {
|
|
14
|
+
return setContext((_, {
|
|
15
|
+
headers
|
|
16
|
+
}) => {
|
|
17
|
+
if (this.locale) {
|
|
53
18
|
return {
|
|
54
|
-
headers:
|
|
19
|
+
headers: {
|
|
20
|
+
...headers,
|
|
21
|
+
"x-i18n-locale": `content:${this.locale};`
|
|
22
|
+
}
|
|
55
23
|
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
headers
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
59
31
|
|
|
60
|
-
|
|
61
|
-
}(ApolloLinkPlugin);
|
|
32
|
+
//# sourceMappingURL=LocaleHeaderLinkPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["setContext","ApolloLinkPlugin","getLocaleCode","LocaleHeaderLinkPlugin","constructor","locale","createLink","_","headers"],"sources":["LocaleHeaderLinkPlugin.ts"],"sourcesContent":["import { setContext } from \"apollo-link-context\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin\";\nimport type { ApolloLink } from \"apollo-link\";\nimport { getLocaleCode } from \"~/utils\";\n\n/**\n * Append `x-i18n-locale` header from URL query (necessary for prerendering service).\n */\nexport class LocaleHeaderLinkPlugin extends ApolloLinkPlugin {\n private readonly locale: string;\n\n constructor(locale?: string) {\n super();\n\n this.locale = locale || (getLocaleCode() as string);\n }\n\n public override createLink(): ApolloLink {\n return setContext((_, { headers }) => {\n if (this.locale) {\n return {\n headers: {\n ...headers,\n \"x-i18n-locale\": `content:${this.locale};`\n }\n };\n }\n\n return { headers };\n });\n }\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,qBAAqB;AAChD,SAASC,gBAAgB;AAEzB,SAASC,aAAa;;AAEtB;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,SAASF,gBAAgB,CAAC;EAGzDG,WAAWA,CAACC,MAAe,EAAE;IACzB,KAAK,CAAC,CAAC;IAEP,IAAI,CAACA,MAAM,GAAGA,MAAM,IAAKH,aAAa,CAAC,CAAY;EACvD;EAEgBI,UAAUA,CAAA,EAAe;IACrC,OAAON,UAAU,CAAC,CAACO,CAAC,EAAE;MAAEC;IAAQ,CAAC,KAAK;MAClC,IAAI,IAAI,CAACH,MAAM,EAAE;QACb,OAAO;UACHG,OAAO,EAAE;YACL,GAAGA,OAAO;YACV,eAAe,EAAE,WAAW,IAAI,CAACH,MAAM;UAC3C;QACJ,CAAC;MACL;MAEA,OAAO;QAAEG;MAAQ,CAAC;IACtB,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
query:
|
|
4
|
-
networkError:
|
|
5
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface ErrorOverlayProps {
|
|
3
|
+
query: string;
|
|
4
|
+
networkError: {
|
|
5
|
+
message: string;
|
|
6
|
+
result?: {
|
|
7
|
+
error?: {
|
|
8
|
+
stack?: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
declare const ErrorOverlay: (props: ErrorOverlayProps) => React.JSX.Element | null;
|
|
6
14
|
export default ErrorOverlay;
|
|
@@ -1,37 +1,26 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
|
|
4
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
5
|
-
|
|
6
1
|
import React, { useState } from "react";
|
|
7
2
|
import get from "lodash/get";
|
|
8
3
|
import { IconButton } from "@webiny/ui/Button";
|
|
9
4
|
import { Typography } from "@webiny/ui/Typography";
|
|
10
5
|
import { i18n } from "../../i18n";
|
|
11
6
|
import { OverlayWrapper, Pre } from "./StyledComponents";
|
|
12
|
-
import { ReactComponent as CloseIcon } from "
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
open = _useState2[0],
|
|
23
|
-
setOpen = _useState2[1]; // Log error in browser's developer console for further inspection.
|
|
24
|
-
|
|
25
|
-
|
|
7
|
+
import { ReactComponent as CloseIcon } from "./assets/close_24px.svg";
|
|
8
|
+
const t = i18n.ns("app/graphql/error-overlay");
|
|
9
|
+
const ENVIRONMENT_VARIABLES_ARTICLE_LINK = "https://www.webiny.com/docs/how-to-guides/environment-variables";
|
|
10
|
+
const ErrorOverlay = props => {
|
|
11
|
+
const {
|
|
12
|
+
query,
|
|
13
|
+
networkError
|
|
14
|
+
} = props;
|
|
15
|
+
const [open, setOpen] = useState(true);
|
|
16
|
+
// Log error in browser's developer console for further inspection.
|
|
26
17
|
console.error({
|
|
27
|
-
networkError
|
|
18
|
+
networkError
|
|
28
19
|
});
|
|
29
|
-
|
|
30
20
|
if (!open) {
|
|
31
21
|
return null;
|
|
32
22
|
}
|
|
33
|
-
|
|
34
|
-
var stackTrace = get(networkError, "result.error.stack");
|
|
23
|
+
const stackTrace = get(networkError, "result.error.stack");
|
|
35
24
|
return /*#__PURE__*/React.createElement(OverlayWrapper, null, /*#__PURE__*/React.createElement("div", {
|
|
36
25
|
className: "inner"
|
|
37
26
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -44,24 +33,24 @@ var ErrorOverlay = function ErrorOverlay(_ref) {
|
|
|
44
33
|
className: "header__action"
|
|
45
34
|
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
46
35
|
icon: /*#__PURE__*/React.createElement(CloseIcon, null),
|
|
47
|
-
onClick:
|
|
48
|
-
return setOpen(false);
|
|
49
|
-
}
|
|
36
|
+
onClick: () => setOpen(false)
|
|
50
37
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
51
38
|
className: "body"
|
|
52
39
|
}, /*#__PURE__*/React.createElement("div", {
|
|
53
40
|
className: "body__summary"
|
|
54
41
|
}, /*#__PURE__*/React.createElement(Typography, {
|
|
55
42
|
use: "subtitle1"
|
|
56
|
-
}, t
|
|
43
|
+
}, t`Error occurred while executing operation:`), /*#__PURE__*/React.createElement(Pre, null, /*#__PURE__*/React.createElement("code", null, query))), stackTrace && /*#__PURE__*/React.createElement("div", {
|
|
57
44
|
className: "body__description"
|
|
58
45
|
}, /*#__PURE__*/React.createElement(Typography, {
|
|
59
46
|
use: "subtitle1"
|
|
60
|
-
}, t
|
|
47
|
+
}, t`Complete stack trace:`), /*#__PURE__*/React.createElement(Pre, null, /*#__PURE__*/React.createElement("code", null, stackTrace)))), /*#__PURE__*/React.createElement("div", {
|
|
61
48
|
className: "footer"
|
|
62
49
|
}, /*#__PURE__*/React.createElement(Typography, {
|
|
63
50
|
use: "body2"
|
|
64
|
-
}, t
|
|
51
|
+
}, t`
|
|
52
|
+
This screen is only visible if {message} environment variable is set.
|
|
53
|
+
Read more about it in the {link}. `({
|
|
65
54
|
message: /*#__PURE__*/React.createElement("span", {
|
|
66
55
|
className: "highlight"
|
|
67
56
|
}, "`REACT_APP_DEBUG=true`"),
|
|
@@ -70,7 +59,8 @@ var ErrorOverlay = function ErrorOverlay(_ref) {
|
|
|
70
59
|
target: "_blank",
|
|
71
60
|
rel: "noreferrer noopener"
|
|
72
61
|
}, "environment variables article")
|
|
73
|
-
}), /*#__PURE__*/React.createElement("br", null), t
|
|
62
|
+
}), /*#__PURE__*/React.createElement("br", null), t`Open your browser's developer console to further inspect this error.`))));
|
|
74
63
|
};
|
|
64
|
+
export default ErrorOverlay;
|
|
75
65
|
|
|
76
|
-
|
|
66
|
+
//# sourceMappingURL=ErrorOverlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useState","get","IconButton","Typography","i18n","OverlayWrapper","Pre","ReactComponent","CloseIcon","t","ns","ENVIRONMENT_VARIABLES_ARTICLE_LINK","ErrorOverlay","props","query","networkError","open","setOpen","console","error","stackTrace","createElement","className","use","message","icon","onClick","link","href","target","rel"],"sources":["ErrorOverlay.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport get from \"lodash/get\";\nimport { IconButton } from \"@webiny/ui/Button\";\nimport { Typography } from \"@webiny/ui/Typography\";\nimport { i18n } from \"../../i18n\";\nimport { OverlayWrapper, Pre } from \"./StyledComponents\";\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\ninterface ErrorOverlayProps {\n query: string;\n networkError: {\n message: string;\n result?: {\n error?: {\n stack?: string;\n };\n };\n };\n}\nconst ErrorOverlay = (props: ErrorOverlayProps) => {\n const { query, networkError } = props;\n const [open, setOpen] = useState(true);\n // Log error in browser's developer console for further inspection.\n console.error({ networkError });\n\n if (!open) {\n return null;\n }\n\n const stackTrace = get(networkError, \"result.error.stack\");\n\n return (\n <OverlayWrapper>\n <div className=\"inner\">\n <div className=\"header\">\n <div className=\"header__title\">\n <Typography use={\"headline4\"}>{networkError.message}</Typography>\n </div>\n <div className=\"header__action\">\n <IconButton icon={<CloseIcon />} onClick={() => setOpen(false)} />\n </div>\n </div>\n <div className=\"body\">\n <div className=\"body__summary\">\n <Typography\n use={\"subtitle1\"}\n >{t`Error occurred while executing operation:`}</Typography>\n <Pre>\n <code>{query}</code>\n </Pre>\n </div>\n {stackTrace && (\n <div className=\"body__description\">\n <Typography use={\"subtitle1\"}>{t`Complete stack trace:`}</Typography>\n <Pre>\n <code>{stackTrace}</code>\n </Pre>\n </div>\n )}\n </div>\n <div className=\"footer\">\n <Typography use={\"body2\"}>\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\nexport default ErrorOverlay;\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const OverlayWrapper: import("@emotion/styled
|
|
3
|
-
|
|
2
|
+
export declare const OverlayWrapper: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
6
|
+
export declare const Pre: import("@emotion/styled").StyledComponent<{
|
|
7
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
8
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
9
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLPreElement>, HTMLPreElement>, {}>;
|