@webiny/app 5.15.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/LICENSE +21 -0
- package/README.md +19 -0
- package/apollo-client/InMemoryCache.d.ts +7 -0
- package/apollo-client/InMemoryCache.js +60 -0
- package/apollo-client/InMemoryCache.js.map +1 -0
- package/components/Image.d.ts +3 -0
- package/components/Image.js +29 -0
- package/components/Image.js.map +1 -0
- package/components/Routes.d.ts +2 -0
- package/components/Routes.js +36 -0
- package/components/Routes.js.map +1 -0
- package/components/View.d.ts +8 -0
- package/components/View.js +24 -0
- package/components/View.js.map +1 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +2 -0
- package/components/index.js.map +1 -0
- package/contexts/Ui/index.d.ts +27 -0
- package/contexts/Ui/index.js +70 -0
- package/contexts/Ui/index.js.map +1 -0
- package/hooks/useAutocomplete/index.d.ts +1 -0
- package/hooks/useAutocomplete/index.js +2 -0
- package/hooks/useAutocomplete/index.js.map +1 -0
- package/hooks/useAutocomplete/useAutocomplete.d.ts +6 -0
- package/hooks/useAutocomplete/useAutocomplete.js +28 -0
- package/hooks/useAutocomplete/useAutocomplete.js.map +1 -0
- package/hooks/useDataList/functions/getData.d.ts +2 -0
- package/hooks/useDataList/functions/getData.js +5 -0
- package/hooks/useDataList/functions/getData.js.map +1 -0
- package/hooks/useDataList/functions/getError.d.ts +2 -0
- package/hooks/useDataList/functions/getError.js +5 -0
- package/hooks/useDataList/functions/getError.js.map +1 -0
- package/hooks/useDataList/functions/getMeta.d.ts +2 -0
- package/hooks/useDataList/functions/getMeta.js +5 -0
- package/hooks/useDataList/functions/getMeta.js.map +1 -0
- package/hooks/useDataList/functions/index.d.ts +3 -0
- package/hooks/useDataList/functions/index.js +4 -0
- package/hooks/useDataList/functions/index.js.map +1 -0
- package/hooks/useDataList/functions/searchDataByKey.d.ts +2 -0
- package/hooks/useDataList/functions/searchDataByKey.js +22 -0
- package/hooks/useDataList/functions/searchDataByKey.js.map +1 -0
- package/hooks/useDataList/index.d.ts +1 -0
- package/hooks/useDataList/index.js +2 -0
- package/hooks/useDataList/index.js.map +1 -0
- package/hooks/useDataList/useDataList.d.ts +36 -0
- package/hooks/useDataList/useDataList.js +194 -0
- package/hooks/useDataList/useDataList.js.map +1 -0
- package/hooks/useDataList/utils/index.d.ts +2 -0
- package/hooks/useDataList/utils/index.js +3 -0
- package/hooks/useDataList/utils/index.js.map +1 -0
- package/hooks/useDataList/utils/prepareLoadListParams.d.ts +4 -0
- package/hooks/useDataList/utils/prepareLoadListParams.js +35 -0
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -0
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.d.ts +5 -0
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +23 -0
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +1 -0
- package/hooks/useDataList/utils/types.d.ts +34 -0
- package/hooks/useDataList/utils/types.js +2 -0
- package/hooks/useDataList/utils/types.js.map +1 -0
- package/hooks/useHandler.d.ts +1 -0
- package/hooks/useHandler.js +13 -0
- package/hooks/useHandler.js.map +1 -0
- package/hooks/useHandlers.d.ts +11 -0
- package/hooks/useHandlers.js +20 -0
- package/hooks/useHandlers.js.map +1 -0
- package/hooks/useUi.d.ts +2 -0
- package/hooks/useUi.js +6 -0
- package/hooks/useUi.js.map +1 -0
- package/i18n/i18n.d.ts +2 -0
- package/i18n/i18n.js +6 -0
- package/i18n/i18n.js.map +1 -0
- package/i18n/index.d.ts +1 -0
- package/i18n/index.js +2 -0
- package/i18n/index.js.map +1 -0
- package/package.json +70 -0
- package/plugins/AddQuerySelectionPlugin.d.ts +15 -0
- package/plugins/AddQuerySelectionPlugin.js +102 -0
- package/plugins/AddQuerySelectionPlugin.js.map +1 -0
- package/plugins/ApolloCacheObjectIdPlugin.d.ts +15 -0
- package/plugins/ApolloCacheObjectIdPlugin.js +41 -0
- package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -0
- package/plugins/ApolloDynamicLink.d.ts +5 -0
- package/plugins/ApolloDynamicLink.js +63 -0
- package/plugins/ApolloDynamicLink.js.map +1 -0
- package/plugins/ApolloLinkPlugin.d.ts +12 -0
- package/plugins/ApolloLinkPlugin.js +41 -0
- package/plugins/ApolloLinkPlugin.js.map +1 -0
- package/plugins/ConsoleLinkPlugin.d.ts +8 -0
- package/plugins/ConsoleLinkPlugin.js +48 -0
- package/plugins/ConsoleLinkPlugin.js.map +1 -0
- package/plugins/LocaleHeaderLinkPlugin.d.ts +14 -0
- package/plugins/LocaleHeaderLinkPlugin.js +62 -0
- package/plugins/LocaleHeaderLinkPlugin.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts +6 -0
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +77 -0
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +3 -0
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +10 -0
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/assets/close_24px.svg +1 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.d.ts +5 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +28 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin.d.ts +7 -0
- package/plugins/NetworkErrorLinkPlugin.js +46 -0
- package/plugins/NetworkErrorLinkPlugin.js.map +1 -0
- package/plugins/OmitTypenameLinkPlugin.d.ts +8 -0
- package/plugins/OmitTypenameLinkPlugin.js +42 -0
- package/plugins/OmitTypenameLinkPlugin.js.map +1 -0
- package/plugins/RoutePlugin.d.ts +12 -0
- package/plugins/RoutePlugin.js +37 -0
- package/plugins/RoutePlugin.js.map +1 -0
- package/plugins/TenantHeaderLinkPlugin.d.ts +14 -0
- package/plugins/TenantHeaderLinkPlugin.js +64 -0
- package/plugins/TenantHeaderLinkPlugin.js.map +1 -0
- package/plugins/ViewPlugin.d.ts +14 -0
- package/plugins/ViewPlugin.js +42 -0
- package/plugins/ViewPlugin.js.map +1 -0
- package/plugins/image.d.ts +3 -0
- package/plugins/image.js +166 -0
- package/plugins/image.js.map +1 -0
- package/plugins/index.d.ts +20 -0
- package/plugins/index.js +74 -0
- package/plugins/index.js.map +1 -0
- package/types.d.ts +62 -0
- package/types.js +3 -0
- package/types.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useHandler.ts"],"names":["useRef","useEffect","useHandler","props","factory","propsRef","handlerRef","handler","current"],"mappings":"AAAA,SAASA,MAAT,EAAiBC,SAAjB,QAAkC,OAAlC;AAEA,OAAO,SAASC,UAAT,CAAoBC,KAApB,EAA2BC,OAA3B,EAAoC;AACvC,MAAMC,QAAQ,GAAGL,MAAM,CAACG,KAAD,CAAvB;AAEA,MAAMG,UAAU,GAAGN,MAAM,CAAC,YAAa;AACnC,QAAMO,OAAO,GAAGH,OAAO,CAACC,QAAQ,CAACG,OAAV,CAAvB;AACA,WAAOD,OAAO,MAAP,mBAAP;AACH,GAHwB,CAAzB;AAKAN,EAAAA,SAAS,CAAC,YAAM;AACZI,IAAAA,QAAQ,CAACG,OAAT,GAAmBL,KAAnB;AACH,GAFQ,CAAT;AAIA,SAAOG,UAAU,CAACE,OAAlB;AACH","sourcesContent":["import { useRef, useEffect } from \"react\";\n\nexport function useHandler(props, factory) {\n const propsRef = useRef(props);\n\n const handlerRef = useRef((...args) => {\n const handler = factory(propsRef.current);\n return handler(...args);\n });\n\n useEffect(() => {\n propsRef.current = props;\n });\n\n return handlerRef.current;\n}\n"],"file":"useHandler.js"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare type HandlerProps = {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
};
|
|
4
|
+
declare type HandlerFactories = {
|
|
5
|
+
[key: string]: (props: HandlerProps) => (...params: any[]) => any;
|
|
6
|
+
};
|
|
7
|
+
declare type Handlers = {
|
|
8
|
+
[K in keyof HandlerFactories]: (...params: any[]) => any;
|
|
9
|
+
};
|
|
10
|
+
export declare function useHandlers(props: HandlerProps, factories: HandlerFactories): Handlers;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useRef, useEffect } from "react";
|
|
2
|
+
export function useHandlers(props, factories) {
|
|
3
|
+
var propsRef = useRef(props);
|
|
4
|
+
var handlersRef = useRef(function () {
|
|
5
|
+
var names = Object.keys(factories);
|
|
6
|
+
return names.reduce(function (handlers, name) {
|
|
7
|
+
handlers[name] = function () {
|
|
8
|
+
var handler = factories[name](propsRef.current);
|
|
9
|
+
return handler.apply(void 0, arguments);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
return handlers;
|
|
13
|
+
}, {});
|
|
14
|
+
}());
|
|
15
|
+
useEffect(function () {
|
|
16
|
+
propsRef.current = props;
|
|
17
|
+
});
|
|
18
|
+
return handlersRef.current;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=useHandlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useHandlers.ts"],"names":["useRef","useEffect","useHandlers","props","factories","propsRef","handlersRef","names","Object","keys","reduce","handlers","name","handler","current"],"mappings":"AAAA,SAASA,MAAT,EAAiBC,SAAjB,QAAkC,OAAlC;AAQA,OAAO,SAASC,WAAT,CAAqBC,KAArB,EAA0CC,SAA1C,EAAuE;AAC1E,MAAMC,QAAQ,GAAGL,MAAM,CAACG,KAAD,CAAvB;AAEA,MAAMG,WAAW,GAAGN,MAAM,CACrB,YAAM;AACH,QAAMO,KAAK,GAAGC,MAAM,CAACC,IAAP,CAAYL,SAAZ,CAAd;AACA,WAAOG,KAAK,CAACG,MAAN,CAAa,UAACC,QAAD,EAAWC,IAAX,EAAoB;AACpCD,MAAAA,QAAQ,CAACC,IAAD,CAAR,GAAiB,YAAa;AAC1B,YAAMC,OAAO,GAAGT,SAAS,CAACQ,IAAD,CAAT,CAAgBP,QAAQ,CAACS,OAAzB,CAAhB;AACA,eAAOD,OAAO,MAAP,mBAAP;AACH,OAHD;;AAIA,aAAOF,QAAP;AACH,KANM,EAMJ,EANI,CAAP;AAOH,GATD,EADsB,CAA1B;AAaAV,EAAAA,SAAS,CAAC,YAAM;AACZI,IAAAA,QAAQ,CAACS,OAAT,GAAmBX,KAAnB;AACH,GAFQ,CAAT;AAIA,SAAOG,WAAW,CAACQ,OAAnB;AACH","sourcesContent":["import { useRef, useEffect } from \"react\";\n\ntype HandlerProps = { [key: string]: any };\ntype HandlerFactories = { [key: string]: (props: HandlerProps) => (...params: any[]) => any };\ntype Handlers = {\n [K in keyof HandlerFactories]: (...params: any[]) => any;\n};\n\nexport function useHandlers(props: HandlerProps, factories: HandlerFactories) {\n const propsRef = useRef(props);\n\n const handlersRef = useRef(\n (() => {\n const names = Object.keys(factories);\n return names.reduce((handlers, name) => {\n handlers[name] = (...args) => {\n const handler = factories[name](propsRef.current);\n return handler(...args);\n };\n return handlers;\n }, {});\n })()\n );\n\n useEffect(() => {\n propsRef.current = props;\n });\n\n return handlersRef.current as Handlers;\n}\n"],"file":"useHandlers.js"}
|
package/hooks/useUi.d.ts
ADDED
package/hooks/useUi.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useUi.ts"],"names":["useContext","UiContext","useUi"],"mappings":"AAAA,SAASA,UAAT,QAA2B,OAA3B;AACA,SAASC,SAAT;AAEA,OAAO,IAAMC,KAAK,GAAG,SAARA,KAAQ,GAAM;AACvB,SAAOF,UAAU,CAACC,SAAD,CAAjB;AACH,CAFM","sourcesContent":["import { useContext } from \"react\";\nimport { UiContext, UiContextValue } from \"./../contexts/Ui\";\n\nexport const useUi = () => {\n return useContext(UiContext) as UiContextValue;\n};\n"],"file":"useUi.js"}
|
package/i18n/i18n.d.ts
ADDED
package/i18n/i18n.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import i18n, { defaultProcessor, defaultModifiers } from "@webiny/i18n";
|
|
2
|
+
import reactProcessor from "@webiny/i18n-react";
|
|
3
|
+
i18n.registerProcessors([defaultProcessor, reactProcessor]);
|
|
4
|
+
i18n.registerModifiers(defaultModifiers);
|
|
5
|
+
export default i18n;
|
|
6
|
+
//# sourceMappingURL=i18n.js.map
|
package/i18n/i18n.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/i18n/i18n.ts"],"names":["i18n","defaultProcessor","defaultModifiers","reactProcessor","registerProcessors","registerModifiers"],"mappings":"AAAA,OAAOA,IAAP,IAAeC,gBAAf,EAAiCC,gBAAjC,QAAyD,cAAzD;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AAEAH,IAAI,CAACI,kBAAL,CAAwB,CAACH,gBAAD,EAAmBE,cAAnB,CAAxB;AACAH,IAAI,CAACK,iBAAL,CAAuBH,gBAAvB;AAEA,eAAeF,IAAf","sourcesContent":["import i18n, { defaultProcessor, defaultModifiers } from \"@webiny/i18n\";\nimport reactProcessor from \"@webiny/i18n-react\";\n\ni18n.registerProcessors([defaultProcessor, reactProcessor]);\ni18n.registerModifiers(defaultModifiers);\n\nexport default i18n;\n"],"file":"i18n.js"}
|
package/i18n/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as i18n } from "./i18n";
|
package/i18n/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/i18n/index.ts"],"names":["default","i18n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,IAApB","sourcesContent":["export { default as i18n } from \"./i18n\";\n"],"file":"index.js"}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webiny/app",
|
|
3
|
+
"version": "5.15.0-beta.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/webiny/webiny-js.git"
|
|
8
|
+
},
|
|
9
|
+
"description": "The base package for building Webiny and React powered web apps.",
|
|
10
|
+
"contributors": [
|
|
11
|
+
"Pavel Denisjuk <pavel@webiny.com>",
|
|
12
|
+
"Sven Al Hamad <sven@webiny.com>",
|
|
13
|
+
"Adrian Smijulj <adrian@webiny.com>"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@apollo/react-hooks": "3.1.5",
|
|
18
|
+
"@babel/runtime": "7.15.3",
|
|
19
|
+
"@emotion/styled": "10.0.27",
|
|
20
|
+
"@types/react": "16.14.2",
|
|
21
|
+
"@webiny/i18n": "5.15.0-beta.0",
|
|
22
|
+
"@webiny/i18n-react": "5.15.0-beta.0",
|
|
23
|
+
"@webiny/plugins": "5.15.0-beta.0",
|
|
24
|
+
"@webiny/react-router": "5.15.0-beta.0",
|
|
25
|
+
"@webiny/ui": "5.15.0-beta.0",
|
|
26
|
+
"apollo-cache": "1.3.5",
|
|
27
|
+
"apollo-cache-inmemory": "1.6.6",
|
|
28
|
+
"apollo-client": "2.6.10",
|
|
29
|
+
"apollo-link": "1.2.14",
|
|
30
|
+
"apollo-link-context": "1.0.20",
|
|
31
|
+
"apollo-link-error": "1.1.13",
|
|
32
|
+
"apollo-utilities": "1.3.4",
|
|
33
|
+
"boolean": "3.1.2",
|
|
34
|
+
"graphql": "14.7.0",
|
|
35
|
+
"invariant": "2.2.4",
|
|
36
|
+
"lodash": "4.17.21",
|
|
37
|
+
"react": "16.14.0",
|
|
38
|
+
"react-dom": "16.14.0",
|
|
39
|
+
"warning": "4.0.3"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@babel/cli": "^7.5.5",
|
|
43
|
+
"@babel/core": "^7.5.5",
|
|
44
|
+
"@babel/plugin-proposal-class-properties": "^7.5.5",
|
|
45
|
+
"@babel/preset-env": "^7.5.5",
|
|
46
|
+
"@babel/preset-react": "^7.0.0",
|
|
47
|
+
"@babel/preset-typescript": "^7.8.3",
|
|
48
|
+
"@webiny/cli": "^5.15.0-beta.0",
|
|
49
|
+
"@webiny/project-utils": "^5.15.0-beta.0",
|
|
50
|
+
"babel-plugin-lodash": "^3.3.4",
|
|
51
|
+
"rimraf": "^3.0.2",
|
|
52
|
+
"typescript": "^4.1.3"
|
|
53
|
+
},
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public",
|
|
56
|
+
"directory": "dist"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "yarn webiny run build",
|
|
60
|
+
"watch": "yarn webiny run watch"
|
|
61
|
+
},
|
|
62
|
+
"adio": {
|
|
63
|
+
"ignore": {
|
|
64
|
+
"dependencies": [
|
|
65
|
+
"react-dom"
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"gitHead": "baf2dbb8cae1b623b59d20fedc0cd0e11a310ca1"
|
|
70
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ApolloLink } from "apollo-link";
|
|
2
|
+
import { DocumentNode } from "graphql";
|
|
3
|
+
import { ApolloLinkPlugin } from "./ApolloLinkPlugin";
|
|
4
|
+
interface Config {
|
|
5
|
+
operationName: string;
|
|
6
|
+
selectionPath: string;
|
|
7
|
+
addSelection: DocumentNode;
|
|
8
|
+
}
|
|
9
|
+
export declare class AddQuerySelectionPlugin extends ApolloLinkPlugin {
|
|
10
|
+
private config;
|
|
11
|
+
constructor(config: Config);
|
|
12
|
+
createLink(): ApolloLink;
|
|
13
|
+
addSelectionToQuery(operationName: string, query: DocumentNode): void;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/createForOfIteratorHelper";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
+
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
8
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
+
import { ApolloLink } from "apollo-link";
|
|
10
|
+
import { ApolloLinkPlugin } from "./ApolloLinkPlugin";
|
|
11
|
+
export var AddQuerySelectionPlugin = /*#__PURE__*/function (_ApolloLinkPlugin) {
|
|
12
|
+
_inherits(AddQuerySelectionPlugin, _ApolloLinkPlugin);
|
|
13
|
+
|
|
14
|
+
var _super = _createSuper(AddQuerySelectionPlugin);
|
|
15
|
+
|
|
16
|
+
function AddQuerySelectionPlugin(config) {
|
|
17
|
+
var _this;
|
|
18
|
+
|
|
19
|
+
_classCallCheck(this, AddQuerySelectionPlugin);
|
|
20
|
+
|
|
21
|
+
_this = _super.call(this);
|
|
22
|
+
|
|
23
|
+
_defineProperty(_assertThisInitialized(_this), "config", void 0);
|
|
24
|
+
|
|
25
|
+
_this.config = config;
|
|
26
|
+
return _this;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_createClass(AddQuerySelectionPlugin, [{
|
|
30
|
+
key: "createLink",
|
|
31
|
+
value: function createLink() {
|
|
32
|
+
var _this2 = this;
|
|
33
|
+
|
|
34
|
+
return new ApolloLink(function (operation, forward) {
|
|
35
|
+
if (operation.operationName !== _this2.config.operationName) {
|
|
36
|
+
return forward(operation);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
_this2.addSelectionToQuery(operation.operationName, operation.query);
|
|
40
|
+
|
|
41
|
+
return forward(operation);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}, {
|
|
45
|
+
key: "addSelectionToQuery",
|
|
46
|
+
value: function addSelectionToQuery(operationName, query) {
|
|
47
|
+
var _tree;
|
|
48
|
+
|
|
49
|
+
if (operationName !== this.config.operationName) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
var _this$config = this.config,
|
|
54
|
+
addSelection = _this$config.addSelection,
|
|
55
|
+
selectionPath = _this$config.selectionPath; // TODO: check if the selection is already in the query and don't add it again if not necessary.
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
|
|
58
|
+
var tree = query.definitions[0].selectionSet.selections;
|
|
59
|
+
var fields = selectionPath.split(".");
|
|
60
|
+
|
|
61
|
+
var _iterator = _createForOfIteratorHelper(fields),
|
|
62
|
+
_step;
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
fieldLoop: for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
66
|
+
var field = _step.value;
|
|
67
|
+
|
|
68
|
+
var _iterator2 = _createForOfIteratorHelper(tree),
|
|
69
|
+
_step2;
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
73
|
+
var selection = _step2.value;
|
|
74
|
+
|
|
75
|
+
if (selection.name.value === field) {
|
|
76
|
+
tree = selection.selectionSet.selections;
|
|
77
|
+
continue fieldLoop;
|
|
78
|
+
}
|
|
79
|
+
} // If we get here, it means we didn't find the necessary selection
|
|
80
|
+
|
|
81
|
+
} catch (err) {
|
|
82
|
+
_iterator2.e(err);
|
|
83
|
+
} finally {
|
|
84
|
+
_iterator2.f();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
} catch (err) {
|
|
90
|
+
_iterator.e(err);
|
|
91
|
+
} finally {
|
|
92
|
+
_iterator.f();
|
|
93
|
+
} // @ts-ignore
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
(_tree = tree).push.apply(_tree, _toConsumableArray(addSelection.definitions[0].selectionSet.selections));
|
|
97
|
+
}
|
|
98
|
+
}]);
|
|
99
|
+
|
|
100
|
+
return AddQuerySelectionPlugin;
|
|
101
|
+
}(ApolloLinkPlugin);
|
|
102
|
+
//# sourceMappingURL=AddQuerySelectionPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/AddQuerySelectionPlugin.ts"],"names":["ApolloLink","ApolloLinkPlugin","AddQuerySelectionPlugin","config","operation","forward","operationName","addSelectionToQuery","query","addSelection","selectionPath","tree","definitions","selectionSet","selections","fields","split","fieldLoop","field","selection","name","value","push"],"mappings":";;;;;;;;AAAA,SAASA,UAAT,QAA2B,aAA3B;AAEA,SAASC,gBAAT;AAQA,WAAaC,uBAAb;AAAA;;AAAA;;AAGI,mCAAYC,MAAZ,EAA4B;AAAA;;AAAA;;AACxB;;AADwB;;AAExB,UAAKA,MAAL,GAAcA,MAAd;AAFwB;AAG3B;;AANL;AAAA;AAAA,WAQI,sBAAa;AAAA;;AACT,aAAO,IAAIH,UAAJ,CAAe,UAACI,SAAD,EAAYC,OAAZ,EAAwB;AAC1C,YAAID,SAAS,CAACE,aAAV,KAA4B,MAAI,CAACH,MAAL,CAAYG,aAA5C,EAA2D;AACvD,iBAAOD,OAAO,CAACD,SAAD,CAAd;AACH;;AAED,QAAA,MAAI,CAACG,mBAAL,CAAyBH,SAAS,CAACE,aAAnC,EAAkDF,SAAS,CAACI,KAA5D;;AAEA,eAAOH,OAAO,CAACD,SAAD,CAAd;AACH,OARM,CAAP;AASH;AAlBL;AAAA;AAAA,WAoBI,6BAAoBE,aAApB,EAA2CE,KAA3C,EAAgE;AAAA;;AAC5D,UAAIF,aAAa,KAAK,KAAKH,MAAL,CAAYG,aAAlC,EAAiD;AAC7C;AACH;;AAED,yBAAwC,KAAKH,MAA7C;AAAA,UAAQM,YAAR,gBAAQA,YAAR;AAAA,UAAsBC,aAAtB,gBAAsBA,aAAtB,CAL4D,CAO5D;AAEA;;AACA,UAAIC,IAAI,GAAGH,KAAK,CAACI,WAAN,CAAkB,CAAlB,EAAqBC,YAArB,CAAkCC,UAA7C;AACA,UAAMC,MAAM,GAAGL,aAAa,CAACM,KAAd,CAAoB,GAApB,CAAf;;AAX4D,iDAa7BD,MAb6B;AAAA;;AAAA;AAa5DE,QAAAA,SAb4D,EAajD,oDAA4B;AAAA,cAAjBC,KAAiB;;AAAA,sDACXP,IADW;AAAA;;AAAA;AACnC,mEAA8B;AAAA,kBAAnBQ,SAAmB;;AAC1B,kBAAIA,SAAS,CAACC,IAAV,CAAeC,KAAf,KAAyBH,KAA7B,EAAoC;AAChCP,gBAAAA,IAAI,GAAGQ,SAAS,CAACN,YAAV,CAAuBC,UAA9B;AACA,yBAASG,SAAT;AACH;AACJ,aANkC,CAOnC;;AAPmC;AAAA;AAAA;AAAA;AAAA;;AAQnC;AACH;AAtB2D;AAAA;AAAA;AAAA;AAAA,QAwB5D;;;AACA,eAAAN,IAAI,EAACW,IAAL,iCAAab,YAAY,CAACG,WAAb,CAAyB,CAAzB,EAA4BC,YAA5B,CAAyCC,UAAtD;AACH;AA9CL;;AAAA;AAAA,EAA6Cb,gBAA7C","sourcesContent":["import { ApolloLink } from \"apollo-link\";\nimport { DocumentNode } from \"graphql\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin\";\n\ninterface Config {\n operationName: string;\n selectionPath: string;\n addSelection: DocumentNode;\n}\n\nexport class AddQuerySelectionPlugin extends ApolloLinkPlugin {\n private config: Config;\n\n constructor(config: Config) {\n super();\n this.config = config;\n }\n\n createLink() {\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 addSelectionToQuery(operationName: string, query: DocumentNode) {\n if (operationName !== this.config.operationName) {\n return;\n }\n\n const { addSelection, selectionPath } = this.config;\n\n // TODO: check if the selection is already in the query and don't add it again if not necessary.\n\n // @ts-ignore\n let tree = query.definitions[0].selectionSet.selections;\n const fields = selectionPath.split(\".\");\n\n fieldLoop: for (const field of fields) {\n for (const selection of tree) {\n if (selection.name.value === field) {\n tree = selection.selectionSet.selections;\n continue fieldLoop;\n }\n }\n // If we get here, it means we didn't find the necessary selection\n return;\n }\n\n // @ts-ignore\n tree.push(...addSelection.definitions[0].selectionSet.selections);\n }\n}\n"],"file":"AddQuerySelectionPlugin.js"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
export interface Object {
|
|
3
|
+
__typename?: string;
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
}
|
|
6
|
+
interface Callable<T> {
|
|
7
|
+
(data: T): any;
|
|
8
|
+
}
|
|
9
|
+
export declare class ApolloCacheObjectIdPlugin<T extends Object = Object> extends Plugin {
|
|
10
|
+
static readonly type = "cache-get-object-id";
|
|
11
|
+
private _getObjectId;
|
|
12
|
+
constructor(getObjectId?: Callable<T>);
|
|
13
|
+
getObjectId(data: T): any;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
import { Plugin } from "@webiny/plugins";
|
|
8
|
+
export var ApolloCacheObjectIdPlugin = /*#__PURE__*/function (_Plugin) {
|
|
9
|
+
_inherits(ApolloCacheObjectIdPlugin, _Plugin);
|
|
10
|
+
|
|
11
|
+
var _super = _createSuper(ApolloCacheObjectIdPlugin);
|
|
12
|
+
|
|
13
|
+
function ApolloCacheObjectIdPlugin(getObjectId) {
|
|
14
|
+
var _this;
|
|
15
|
+
|
|
16
|
+
_classCallCheck(this, ApolloCacheObjectIdPlugin);
|
|
17
|
+
|
|
18
|
+
_this = _super.call(this);
|
|
19
|
+
|
|
20
|
+
_defineProperty(_assertThisInitialized(_this), "_getObjectId", void 0);
|
|
21
|
+
|
|
22
|
+
_this._getObjectId = getObjectId;
|
|
23
|
+
return _this;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
_createClass(ApolloCacheObjectIdPlugin, [{
|
|
27
|
+
key: "getObjectId",
|
|
28
|
+
value: function getObjectId(data) {
|
|
29
|
+
if (typeof this._getObjectId !== "function") {
|
|
30
|
+
throw Error("You must provide a \"getObjectId\" callable to the plugin constructor or extend the ApolloCacheObjectIdPlugin.");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return this._getObjectId(data);
|
|
34
|
+
}
|
|
35
|
+
}]);
|
|
36
|
+
|
|
37
|
+
return ApolloCacheObjectIdPlugin;
|
|
38
|
+
}(Plugin);
|
|
39
|
+
|
|
40
|
+
_defineProperty(ApolloCacheObjectIdPlugin, "type", "cache-get-object-id");
|
|
41
|
+
//# sourceMappingURL=ApolloCacheObjectIdPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/ApolloCacheObjectIdPlugin.ts"],"names":["Plugin","ApolloCacheObjectIdPlugin","getObjectId","_getObjectId","data","Error"],"mappings":";;;;;;AAAA,SAASA,MAAT,QAAuB,iBAAvB;AAWA,WAAaC,yBAAb;AAAA;;AAAA;;AAII,qCAAYC,WAAZ,EAAuC;AAAA;;AAAA;;AACnC;;AADmC;;AAEnC,UAAKC,YAAL,GAAoBD,WAApB;AAFmC;AAGtC;;AAPL;AAAA;AAAA,WASI,qBAAYE,IAAZ,EAAqB;AACjB,UAAI,OAAO,KAAKD,YAAZ,KAA6B,UAAjC,EAA6C;AACzC,cAAME,KAAK,kHAAX;AAGH;;AAED,aAAO,KAAKF,YAAL,CAAkBC,IAAlB,CAAP;AACH;AAjBL;;AAAA;AAAA,EAA0EJ,MAA1E;;gBAAaC,yB,UACqB,qB","sourcesContent":["import { Plugin } from \"@webiny/plugins\";\n\nexport interface Object {\n __typename?: string;\n [key: string]: any;\n}\n\ninterface Callable<T> {\n (data: T): any;\n}\n\nexport class ApolloCacheObjectIdPlugin<T extends Object = Object> extends Plugin {\n public static readonly type = \"cache-get-object-id\";\n private _getObjectId: Callable<T>;\n\n constructor(getObjectId?: Callable<T>) {\n super();\n this._getObjectId = getObjectId;\n }\n\n 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"],"file":"ApolloCacheObjectIdPlugin.js"}
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
import { ApolloLink } from "apollo-link";
|
|
8
|
+
import { plugins } from "@webiny/plugins";
|
|
9
|
+
|
|
10
|
+
function createLink(plugin) {
|
|
11
|
+
try {
|
|
12
|
+
return plugin.createLink();
|
|
13
|
+
} catch (e) {
|
|
14
|
+
console.error("Caught an error while executing \"createLink\" on plugin", plugin);
|
|
15
|
+
console.error(e);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export var ApolloDynamicLink = /*#__PURE__*/function (_ApolloLink) {
|
|
20
|
+
_inherits(ApolloDynamicLink, _ApolloLink);
|
|
21
|
+
|
|
22
|
+
var _super = _createSuper(ApolloDynamicLink);
|
|
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];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
|
+
|
|
35
|
+
_defineProperty(_assertThisInitialized(_this), "cache", new Map());
|
|
36
|
+
|
|
37
|
+
return _this;
|
|
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.name;
|
|
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);
|
|
58
|
+
}
|
|
59
|
+
}]);
|
|
60
|
+
|
|
61
|
+
return ApolloDynamicLink;
|
|
62
|
+
}(ApolloLink);
|
|
63
|
+
//# sourceMappingURL=ApolloDynamicLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/ApolloDynamicLink.ts"],"names":["ApolloLink","plugins","createLink","plugin","e","console","error","ApolloDynamicLink","Map","operation","forward","linkPlugins","byType","length","cacheKey","map","pl","name","join","cache","has","set","from","get","request"],"mappings":";;;;;;AAAA,SAASA,UAAT,QAA2B,aAA3B;AACA,SAASC,OAAT,QAAwB,iBAAxB;;AAGA,SAASC,UAAT,CAAoBC,MAApB,EAA8C;AAC1C,MAAI;AACA,WAAOA,MAAM,CAACD,UAAP,EAAP;AACH,GAFD,CAEE,OAAOE,CAAP,EAAU;AACRC,IAAAA,OAAO,CAACC,KAAR,6DAAwEH,MAAxE;AACAE,IAAAA,OAAO,CAACC,KAAR,CAAcF,CAAd;AACH;AACJ;;AAED,WAAaG,iBAAb;AAAA;;AAAA;;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;;AAAA;;AAAA,4DACoB,IAAIC,GAAJ,EADpB;;AAAA;AAAA;;AAAA;AAAA;AAAA,WAGI,iBAAQC,SAAR,EAAmBC,OAAnB,EAA4B;AACxB,UAAMC,WAAW,GAAGV,OAAO,CAACW,MAAR,CAAiC,aAAjC,CAApB;;AAEA,UAAI,CAACD,WAAW,CAACE,MAAjB,EAAyB;AACrB,eAAOH,OAAO,CAACD,SAAD,CAAd;AACH;;AAED,UAAMK,QAAQ,GAAGH,WAAW,CAACI,GAAZ,CAAgB,UAAAC,EAAE;AAAA,eAAIA,EAAE,CAACC,IAAP;AAAA,OAAlB,EAA+BC,IAA/B,CAAoC,GAApC,CAAjB;;AAEA,UAAI,CAAC,KAAKC,KAAL,CAAWC,GAAX,CAAeN,QAAf,CAAL,EAA+B;AAC3B,aAAKK,KAAL,CAAWE,GAAX,CAAeP,QAAf,EAAyBd,UAAU,CAACsB,IAAX,CAAgBX,WAAW,CAACI,GAAZ,CAAgBb,UAAhB,CAAhB,CAAzB;AACH;;AAED,aAAO,KAAKiB,KAAL,CAAWI,GAAX,CAAeT,QAAf,EAAyBU,OAAzB,CAAiCf,SAAjC,EAA4CC,OAA5C,CAAP;AACH;AAjBL;;AAAA;AAAA,EAAuCV,UAAvC","sourcesContent":["import { ApolloLink } from \"apollo-link\";\nimport { plugins } from \"@webiny/plugins\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin\";\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}\n\nexport class ApolloDynamicLink extends ApolloLink {\n private cache = new Map();\n\n request(operation, forward) {\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.name).join(\",\");\n\n if (!this.cache.has(cacheKey)) {\n this.cache.set(cacheKey, ApolloLink.from(linkPlugins.map(createLink)));\n }\n\n return this.cache.get(cacheKey).request(operation, forward);\n }\n}\n"],"file":"ApolloDynamicLink.js"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ApolloLink } from "apollo-link";
|
|
2
|
+
import { Plugin } from "@webiny/plugins";
|
|
3
|
+
interface ApolloLinkFactory {
|
|
4
|
+
(): ApolloLink;
|
|
5
|
+
}
|
|
6
|
+
export declare class ApolloLinkPlugin extends Plugin {
|
|
7
|
+
static readonly type = "apollo-link";
|
|
8
|
+
private factory;
|
|
9
|
+
constructor(factory?: ApolloLinkFactory);
|
|
10
|
+
createLink(): ApolloLink;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
import { Plugin } from "@webiny/plugins";
|
|
8
|
+
export var ApolloLinkPlugin = /*#__PURE__*/function (_Plugin) {
|
|
9
|
+
_inherits(ApolloLinkPlugin, _Plugin);
|
|
10
|
+
|
|
11
|
+
var _super = _createSuper(ApolloLinkPlugin);
|
|
12
|
+
|
|
13
|
+
function ApolloLinkPlugin(factory) {
|
|
14
|
+
var _this;
|
|
15
|
+
|
|
16
|
+
_classCallCheck(this, ApolloLinkPlugin);
|
|
17
|
+
|
|
18
|
+
_this = _super.call(this);
|
|
19
|
+
|
|
20
|
+
_defineProperty(_assertThisInitialized(_this), "factory", void 0);
|
|
21
|
+
|
|
22
|
+
_this.factory = factory;
|
|
23
|
+
return _this;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
_createClass(ApolloLinkPlugin, [{
|
|
27
|
+
key: "createLink",
|
|
28
|
+
value: function createLink() {
|
|
29
|
+
if (typeof this.factory === "function") {
|
|
30
|
+
return this.factory();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
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."));
|
|
34
|
+
}
|
|
35
|
+
}]);
|
|
36
|
+
|
|
37
|
+
return ApolloLinkPlugin;
|
|
38
|
+
}(Plugin);
|
|
39
|
+
|
|
40
|
+
_defineProperty(ApolloLinkPlugin, "type", "apollo-link");
|
|
41
|
+
//# sourceMappingURL=ApolloLinkPlugin.js.map
|