@webiny/app 0.0.0-ee-vpcs.549378cf03

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/App.d.ts +24 -0
  2. package/App.js +116 -0
  3. package/App.js.map +1 -0
  4. package/LICENSE +21 -0
  5. package/README.md +19 -0
  6. package/apollo-client/InMemoryCache.d.ts +7 -0
  7. package/apollo-client/InMemoryCache.js +79 -0
  8. package/apollo-client/InMemoryCache.js.map +1 -0
  9. package/components/Image.d.ts +3 -0
  10. package/components/Image.js +43 -0
  11. package/components/Image.js.map +1 -0
  12. package/components/Routes.d.ts +2 -0
  13. package/components/Routes.js +51 -0
  14. package/components/Routes.js.map +1 -0
  15. package/components/View.d.ts +8 -0
  16. package/components/View.js +41 -0
  17. package/components/View.js.map +1 -0
  18. package/components/index.d.ts +2 -0
  19. package/components/index.js +21 -0
  20. package/components/index.js.map +1 -0
  21. package/config.d.ts +8 -0
  22. package/config.js +33 -0
  23. package/config.js.map +1 -0
  24. package/contexts/Ui/index.d.ts +24 -0
  25. package/contexts/Ui/index.js +81 -0
  26. package/contexts/Ui/index.js.map +1 -0
  27. package/core/AddRoute.d.ts +3 -0
  28. package/core/AddRoute.js +26 -0
  29. package/core/AddRoute.js.map +1 -0
  30. package/core/DebounceRender.d.ts +11 -0
  31. package/core/DebounceRender.js +51 -0
  32. package/core/DebounceRender.js.map +1 -0
  33. package/core/Plugins.d.ts +8 -0
  34. package/core/Plugins.js +52 -0
  35. package/core/Plugins.js.map +1 -0
  36. package/core/Provider.d.ts +9 -0
  37. package/core/Provider.js +27 -0
  38. package/core/Provider.js.map +1 -0
  39. package/core/Routes.d.ts +6 -0
  40. package/core/Routes.js +49 -0
  41. package/core/Routes.js.map +1 -0
  42. package/core/createProviderPlugin.d.ts +8 -0
  43. package/core/createProviderPlugin.js +25 -0
  44. package/core/createProviderPlugin.js.map +1 -0
  45. package/hooks/useAutocomplete/index.d.ts +1 -0
  46. package/hooks/useAutocomplete/index.js +13 -0
  47. package/hooks/useAutocomplete/index.js.map +1 -0
  48. package/hooks/useAutocomplete/useAutocomplete.d.ts +11 -0
  49. package/hooks/useAutocomplete/useAutocomplete.js +38 -0
  50. package/hooks/useAutocomplete/useAutocomplete.js.map +1 -0
  51. package/hooks/useDataList/functions/getData.d.ts +2 -0
  52. package/hooks/useDataList/functions/getData.js +16 -0
  53. package/hooks/useDataList/functions/getData.js.map +1 -0
  54. package/hooks/useDataList/functions/getError.d.ts +2 -0
  55. package/hooks/useDataList/functions/getError.js +16 -0
  56. package/hooks/useDataList/functions/getError.js.map +1 -0
  57. package/hooks/useDataList/functions/getMeta.d.ts +2 -0
  58. package/hooks/useDataList/functions/getMeta.js +16 -0
  59. package/hooks/useDataList/functions/getMeta.js.map +1 -0
  60. package/hooks/useDataList/functions/index.d.ts +3 -0
  61. package/hooks/useDataList/functions/index.js +31 -0
  62. package/hooks/useDataList/functions/index.js.map +1 -0
  63. package/hooks/useDataList/functions/searchDataByKey.d.ts +2 -0
  64. package/hooks/useDataList/functions/searchDataByKey.js +29 -0
  65. package/hooks/useDataList/functions/searchDataByKey.js.map +1 -0
  66. package/hooks/useDataList/index.d.ts +1 -0
  67. package/hooks/useDataList/index.js +13 -0
  68. package/hooks/useDataList/index.js.map +1 -0
  69. package/hooks/useDataList/useDataList.d.ts +36 -0
  70. package/hooks/useDataList/useDataList.js +208 -0
  71. package/hooks/useDataList/useDataList.js.map +1 -0
  72. package/hooks/useDataList/utils/index.d.ts +2 -0
  73. package/hooks/useDataList/utils/index.js +23 -0
  74. package/hooks/useDataList/utils/index.js.map +1 -0
  75. package/hooks/useDataList/utils/prepareLoadListParams.d.ts +11 -0
  76. package/hooks/useDataList/utils/prepareLoadListParams.js +48 -0
  77. package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -0
  78. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.d.ts +14 -0
  79. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +31 -0
  80. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +1 -0
  81. package/hooks/useDataList/utils/types.d.ts +34 -0
  82. package/hooks/useDataList/utils/types.js +5 -0
  83. package/hooks/useDataList/utils/types.js.map +1 -0
  84. package/hooks/useHandler.d.ts +11 -0
  85. package/hooks/useHandler.js +20 -0
  86. package/hooks/useHandler.js.map +1 -0
  87. package/hooks/useHandlers.d.ts +11 -0
  88. package/hooks/useHandlers.js +30 -0
  89. package/hooks/useHandlers.js.map +1 -0
  90. package/hooks/useUi.d.ts +2 -0
  91. package/hooks/useUi.js +16 -0
  92. package/hooks/useUi.js.map +1 -0
  93. package/i18n/i18n.d.ts +2 -0
  94. package/i18n/i18n.js +21 -0
  95. package/i18n/i18n.js.map +1 -0
  96. package/i18n/index.d.ts +1 -0
  97. package/i18n/index.js +15 -0
  98. package/i18n/index.js.map +1 -0
  99. package/index.d.ts +13 -0
  100. package/index.js +141 -0
  101. package/index.js.map +1 -0
  102. package/package.json +78 -0
  103. package/plugins/AddQuerySelectionPlugin.d.ts +15 -0
  104. package/plugins/AddQuerySelectionPlugin.js +132 -0
  105. package/plugins/AddQuerySelectionPlugin.js.map +1 -0
  106. package/plugins/ApolloCacheObjectIdPlugin.d.ts +15 -0
  107. package/plugins/ApolloCacheObjectIdPlugin.js +53 -0
  108. package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -0
  109. package/plugins/ApolloDynamicLink.d.ts +6 -0
  110. package/plugins/ApolloDynamicLink.js +83 -0
  111. package/plugins/ApolloDynamicLink.js.map +1 -0
  112. package/plugins/ApolloLinkPlugin.d.ts +13 -0
  113. package/plugins/ApolloLinkPlugin.js +63 -0
  114. package/plugins/ApolloLinkPlugin.js.map +1 -0
  115. package/plugins/ConsoleLinkPlugin.d.ts +8 -0
  116. package/plugins/ConsoleLinkPlugin.js +63 -0
  117. package/plugins/ConsoleLinkPlugin.js.map +1 -0
  118. package/plugins/LocaleHeaderLinkPlugin.d.ts +15 -0
  119. package/plugins/LocaleHeaderLinkPlugin.js +77 -0
  120. package/plugins/LocaleHeaderLinkPlugin.js.map +1 -0
  121. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts +14 -0
  122. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +97 -0
  123. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -0
  124. package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +5 -0
  125. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +21 -0
  126. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -0
  127. package/plugins/NetworkErrorLinkPlugin/assets/close_24px.svg +1 -0
  128. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.d.ts +7 -0
  129. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +38 -0
  130. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -0
  131. package/plugins/NetworkErrorLinkPlugin.d.ts +7 -0
  132. package/plugins/NetworkErrorLinkPlugin.js +65 -0
  133. package/plugins/NetworkErrorLinkPlugin.js.map +1 -0
  134. package/plugins/OmitTypenameLinkPlugin.d.ts +8 -0
  135. package/plugins/OmitTypenameLinkPlugin.js +55 -0
  136. package/plugins/OmitTypenameLinkPlugin.js.map +1 -0
  137. package/plugins/RoutePlugin.d.ts +12 -0
  138. package/plugins/RoutePlugin.js +53 -0
  139. package/plugins/RoutePlugin.js.map +1 -0
  140. package/plugins/TenantHeaderLinkPlugin.d.ts +15 -0
  141. package/plugins/TenantHeaderLinkPlugin.js +85 -0
  142. package/plugins/TenantHeaderLinkPlugin.js.map +1 -0
  143. package/plugins/ViewPlugin.d.ts +14 -0
  144. package/plugins/ViewPlugin.js +58 -0
  145. package/plugins/ViewPlugin.js.map +1 -0
  146. package/plugins/image.d.ts +3 -0
  147. package/plugins/image.js +184 -0
  148. package/plugins/image.js.map +1 -0
  149. package/plugins/index.d.ts +20 -0
  150. package/plugins/index.js +110 -0
  151. package/plugins/index.js.map +1 -0
  152. package/types.d.ts +70 -0
  153. package/types.js +13 -0
  154. package/types.js.map +1 -0
package/index.js ADDED
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ AddQuerySelectionPlugin: true,
8
+ ApolloLinkPlugin: true,
9
+ RoutePlugin: true,
10
+ ApolloCacheObjectIdPlugin: true
11
+ };
12
+ Object.defineProperty(exports, "AddQuerySelectionPlugin", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _AddQuerySelectionPlugin.AddQuerySelectionPlugin;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "ApolloCacheObjectIdPlugin", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _ApolloCacheObjectIdPlugin.ApolloCacheObjectIdPlugin;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "ApolloLinkPlugin", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _ApolloLinkPlugin.ApolloLinkPlugin;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "RoutePlugin", {
31
+ enumerable: true,
32
+ get: function get() {
33
+ return _RoutePlugin.RoutePlugin;
34
+ }
35
+ });
36
+
37
+ var _AddQuerySelectionPlugin = require("./plugins/AddQuerySelectionPlugin");
38
+
39
+ var _ApolloLinkPlugin = require("./plugins/ApolloLinkPlugin");
40
+
41
+ var _RoutePlugin = require("./plugins/RoutePlugin");
42
+
43
+ var _ApolloCacheObjectIdPlugin = require("./plugins/ApolloCacheObjectIdPlugin");
44
+
45
+ var _reactComposition = require("@webiny/react-composition");
46
+
47
+ Object.keys(_reactComposition).forEach(function (key) {
48
+ if (key === "default" || key === "__esModule") return;
49
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
50
+ if (key in exports && exports[key] === _reactComposition[key]) return;
51
+ Object.defineProperty(exports, key, {
52
+ enumerable: true,
53
+ get: function get() {
54
+ return _reactComposition[key];
55
+ }
56
+ });
57
+ });
58
+
59
+ var _App = require("./App");
60
+
61
+ Object.keys(_App).forEach(function (key) {
62
+ if (key === "default" || key === "__esModule") return;
63
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
64
+ if (key in exports && exports[key] === _App[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function get() {
68
+ return _App[key];
69
+ }
70
+ });
71
+ });
72
+
73
+ var _Plugins = require("./core/Plugins");
74
+
75
+ Object.keys(_Plugins).forEach(function (key) {
76
+ if (key === "default" || key === "__esModule") return;
77
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
78
+ if (key in exports && exports[key] === _Plugins[key]) return;
79
+ Object.defineProperty(exports, key, {
80
+ enumerable: true,
81
+ get: function get() {
82
+ return _Plugins[key];
83
+ }
84
+ });
85
+ });
86
+
87
+ var _Provider = require("./core/Provider");
88
+
89
+ Object.keys(_Provider).forEach(function (key) {
90
+ if (key === "default" || key === "__esModule") return;
91
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
92
+ if (key in exports && exports[key] === _Provider[key]) return;
93
+ Object.defineProperty(exports, key, {
94
+ enumerable: true,
95
+ get: function get() {
96
+ return _Provider[key];
97
+ }
98
+ });
99
+ });
100
+
101
+ var _AddRoute = require("./core/AddRoute");
102
+
103
+ Object.keys(_AddRoute).forEach(function (key) {
104
+ if (key === "default" || key === "__esModule") return;
105
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
106
+ if (key in exports && exports[key] === _AddRoute[key]) return;
107
+ Object.defineProperty(exports, key, {
108
+ enumerable: true,
109
+ get: function get() {
110
+ return _AddRoute[key];
111
+ }
112
+ });
113
+ });
114
+
115
+ var _DebounceRender = require("./core/DebounceRender");
116
+
117
+ Object.keys(_DebounceRender).forEach(function (key) {
118
+ if (key === "default" || key === "__esModule") return;
119
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
120
+ if (key in exports && exports[key] === _DebounceRender[key]) return;
121
+ Object.defineProperty(exports, key, {
122
+ enumerable: true,
123
+ get: function get() {
124
+ return _DebounceRender[key];
125
+ }
126
+ });
127
+ });
128
+
129
+ var _createProviderPlugin = require("./core/createProviderPlugin");
130
+
131
+ Object.keys(_createProviderPlugin).forEach(function (key) {
132
+ if (key === "default" || key === "__esModule") return;
133
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
134
+ if (key in exports && exports[key] === _createProviderPlugin[key]) return;
135
+ Object.defineProperty(exports, key, {
136
+ enumerable: true,
137
+ get: function get() {
138
+ return _createProviderPlugin[key];
139
+ }
140
+ });
141
+ });
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { AddQuerySelectionPlugin } from \"./plugins/AddQuerySelectionPlugin\";\nexport { ApolloLinkPlugin } from \"./plugins/ApolloLinkPlugin\";\nexport { RoutePlugin } from \"./plugins/RoutePlugin\";\nexport { ApolloCacheObjectIdPlugin } from \"./plugins/ApolloCacheObjectIdPlugin\";\n\n// Composition - we re-export this for ease of use\nexport * from \"@webiny/react-composition\";\nexport type { HigherOrderComponent, ComposeProps, ComposableFC } from \"@webiny/react-composition\";\n\n// App framework\nexport * from \"./App\";\nexport type { AppProps } from \"./App\";\nexport * from \"./core/Plugins\";\nexport * from \"./core/Provider\";\nexport * from \"./core/AddRoute\";\nexport * from \"./core/DebounceRender\";\nexport * from \"./core/createProviderPlugin\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAGA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAIA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@webiny/app",
3
+ "version": "0.0.0-ee-vpcs.549378cf03",
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.19.0",
19
+ "@emotion/styled": "10.3.0",
20
+ "@types/react": "17.0.39",
21
+ "@types/web": "0.0.61",
22
+ "@webiny/i18n": "0.0.0-ee-vpcs.549378cf03",
23
+ "@webiny/i18n-react": "0.0.0-ee-vpcs.549378cf03",
24
+ "@webiny/plugins": "0.0.0-ee-vpcs.549378cf03",
25
+ "@webiny/react-composition": "0.0.0-ee-vpcs.549378cf03",
26
+ "@webiny/react-router": "0.0.0-ee-vpcs.549378cf03",
27
+ "@webiny/ui": "0.0.0-ee-vpcs.549378cf03",
28
+ "apollo-cache": "1.3.5",
29
+ "apollo-cache-inmemory": "1.6.6",
30
+ "apollo-client": "2.6.10",
31
+ "apollo-link": "1.2.14",
32
+ "apollo-link-context": "1.0.20",
33
+ "apollo-link-error": "1.1.13",
34
+ "apollo-link-http-common": "0.2.16",
35
+ "apollo-utilities": "1.3.4",
36
+ "boolean": "3.2.0",
37
+ "graphql": "15.8.0",
38
+ "invariant": "2.2.4",
39
+ "lodash": "4.17.21",
40
+ "lodash.debounce": "4.0.8",
41
+ "nanoid": "3.3.4",
42
+ "react": "17.0.2",
43
+ "react-dom": "17.0.2",
44
+ "warning": "4.0.3"
45
+ },
46
+ "devDependencies": {
47
+ "@babel/cli": "^7.19.3",
48
+ "@babel/core": "^7.19.3",
49
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
50
+ "@babel/preset-env": "^7.19.4",
51
+ "@babel/preset-react": "^7.18.6",
52
+ "@babel/preset-typescript": "^7.18.6",
53
+ "@types/lodash.debounce": "^4.0.7",
54
+ "@types/warning": "^3.0.0",
55
+ "@webiny/cli": "^0.0.0-ee-vpcs.549378cf03",
56
+ "@webiny/project-utils": "^0.0.0-ee-vpcs.549378cf03",
57
+ "babel-plugin-lodash": "^3.3.4",
58
+ "rimraf": "^3.0.2",
59
+ "typescript": "4.7.4"
60
+ },
61
+ "publishConfig": {
62
+ "access": "public",
63
+ "directory": "dist"
64
+ },
65
+ "scripts": {
66
+ "build": "yarn webiny run build",
67
+ "watch": "yarn webiny run watch"
68
+ },
69
+ "adio": {
70
+ "ignore": {
71
+ "dependencies": [
72
+ "@types/web",
73
+ "react-dom"
74
+ ]
75
+ }
76
+ },
77
+ "gitHead": "549378cf03fcd27845fc3fa23d1dc6b32896f630"
78
+ }
@@ -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 readonly config;
11
+ constructor(config: Config);
12
+ createLink(): ApolloLink;
13
+ addSelectionToQuery(operationName: string, query: DocumentNode): void;
14
+ }
15
+ export {};
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.AddQuerySelectionPlugin = void 0;
9
+
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+
12
+ var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
13
+
14
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
+
16
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
+
18
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
19
+
20
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
21
+
22
+ var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
23
+
24
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
+
26
+ var _apolloLink = require("apollo-link");
27
+
28
+ var _ApolloLinkPlugin2 = require("./ApolloLinkPlugin");
29
+
30
+ var AddQuerySelectionPlugin = /*#__PURE__*/function (_ApolloLinkPlugin) {
31
+ (0, _inherits2.default)(AddQuerySelectionPlugin, _ApolloLinkPlugin);
32
+
33
+ var _super = (0, _createSuper2.default)(AddQuerySelectionPlugin);
34
+
35
+ function AddQuerySelectionPlugin(config) {
36
+ var _this;
37
+
38
+ (0, _classCallCheck2.default)(this, AddQuerySelectionPlugin);
39
+ _this = _super.call(this);
40
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "config", void 0);
41
+ _this.config = config;
42
+ return _this;
43
+ }
44
+
45
+ (0, _createClass2.default)(AddQuerySelectionPlugin, [{
46
+ key: "createLink",
47
+ value: function createLink() {
48
+ var _this2 = this;
49
+
50
+ return new _apolloLink.ApolloLink(function (operation, forward) {
51
+ if (operation.operationName !== _this2.config.operationName) {
52
+ return forward(operation);
53
+ }
54
+
55
+ _this2.addSelectionToQuery(operation.operationName, operation.query);
56
+
57
+ return forward(operation);
58
+ });
59
+ }
60
+ }, {
61
+ key: "addSelectionToQuery",
62
+ value: function addSelectionToQuery(operationName, query) {
63
+ var _tree;
64
+
65
+ if (operationName !== this.config.operationName) {
66
+ return;
67
+ }
68
+
69
+ var _this$config = this.config,
70
+ addSelection = _this$config.addSelection,
71
+ selectionPath = _this$config.selectionPath; // TODO: check if the selection is already in the query and don't add it again if not necessary.
72
+
73
+ var firstQueryDefinition = query.definitions[0];
74
+
75
+ if (!firstQueryDefinition) {
76
+ return;
77
+ } else if (!firstQueryDefinition.selectionSet) {
78
+ return;
79
+ }
80
+
81
+ var tree = firstQueryDefinition.selectionSet.selections;
82
+ var fields = selectionPath.split(".");
83
+
84
+ var _iterator = (0, _createForOfIteratorHelper2.default)(fields),
85
+ _step;
86
+
87
+ try {
88
+ fieldLoop: for (_iterator.s(); !(_step = _iterator.n()).done;) {
89
+ var field = _step.value;
90
+
91
+ var _iterator2 = (0, _createForOfIteratorHelper2.default)(tree),
92
+ _step2;
93
+
94
+ try {
95
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
96
+ var selection = _step2.value;
97
+
98
+ if (!selection.selectionSet) {
99
+ continue;
100
+ }
101
+
102
+ if (selection.name.value === field) {
103
+ tree = selection.selectionSet.selections;
104
+ continue fieldLoop;
105
+ }
106
+ } // If we get here, it means we didn't find the necessary selection
107
+
108
+ } catch (err) {
109
+ _iterator2.e(err);
110
+ } finally {
111
+ _iterator2.f();
112
+ }
113
+
114
+ return;
115
+ }
116
+ } catch (err) {
117
+ _iterator.e(err);
118
+ } finally {
119
+ _iterator.f();
120
+ }
121
+ /**
122
+ * We must cast because there are a lot of types that are not intertwined and TS is complaining
123
+ */
124
+
125
+
126
+ (_tree = tree).push.apply(_tree, (0, _toConsumableArray2.default)(addSelection.definitions[0].selectionSet.selections));
127
+ }
128
+ }]);
129
+ return AddQuerySelectionPlugin;
130
+ }(_ApolloLinkPlugin2.ApolloLinkPlugin);
131
+
132
+ exports.AddQuerySelectionPlugin = AddQuerySelectionPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["AddQuerySelectionPlugin","config","ApolloLink","operation","forward","operationName","addSelectionToQuery","query","addSelection","selectionPath","firstQueryDefinition","definitions","selectionSet","tree","selections","fields","split","fieldLoop","field","selection","name","value","push","ApolloLinkPlugin"],"sources":["AddQuerySelectionPlugin.ts"],"sourcesContent":["import { ApolloLink } from \"apollo-link\";\nimport { DocumentNode } from \"graphql\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin\";\nimport { ExecutableDefinitionNode, FieldNode } from \"graphql/language/ast\";\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, query: DocumentNode): void {\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 const firstQueryDefinition = query.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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;IASaA,uB;;;;;EAGT,iCAAYC,MAAZ,EAA4B;IAAA;;IAAA;IACxB;IADwB;IAExB,MAAKA,MAAL,GAAcA,MAAd;IAFwB;EAG3B;;;;WAED,sBAAyC;MAAA;;MACrC,OAAO,IAAIC,sBAAJ,CAAe,UAACC,SAAD,EAAYC,OAAZ,EAAwB;QAC1C,IAAID,SAAS,CAACE,aAAV,KAA4B,MAAI,CAACJ,MAAL,CAAYI,aAA5C,EAA2D;UACvD,OAAOD,OAAO,CAACD,SAAD,CAAd;QACH;;QAED,MAAI,CAACG,mBAAL,CAAyBH,SAAS,CAACE,aAAnC,EAAkDF,SAAS,CAACI,KAA5D;;QAEA,OAAOH,OAAO,CAACD,SAAD,CAAd;MACH,CARM,CAAP;IASH;;;WAED,6BAA2BE,aAA3B,EAAkDE,KAAlD,EAA6E;MAAA;;MACzE,IAAIF,aAAa,KAAK,KAAKJ,MAAL,CAAYI,aAAlC,EAAiD;QAC7C;MACH;;MAED,mBAAwC,KAAKJ,MAA7C;MAAA,IAAQO,YAAR,gBAAQA,YAAR;MAAA,IAAsBC,aAAtB,gBAAsBA,aAAtB,CALyE,CAOzE;;MAEA,IAAMC,oBAAoB,GAAGH,KAAK,CAACI,WAAN,CAAkB,CAAlB,CAA7B;;MACA,IAAI,CAACD,oBAAL,EAA2B;QACvB;MACH,CAFD,MAEO,IAAI,CAACA,oBAAoB,CAACE,YAA1B,EAAwC;QAC3C;MACH;;MAED,IAAIC,IAAI,GAAGH,oBAAoB,CAACE,YAArB,CAAkCE,UAA7C;MACA,IAAMC,MAAM,GAAGN,aAAa,CAACO,KAAd,CAAoB,GAApB,CAAf;;MAjByE,yDAmB1CD,MAnB0C;MAAA;;MAAA;QAmBzEE,SAnByE,EAmB9D,oDAA4B;UAAA,IAAjBC,KAAiB;;UAAA,0DACXL,IADW;UAAA;;UAAA;YACnC,uDAA8B;cAAA,IAAnBM,SAAmB;;cAC1B,IAAI,CAACA,SAAS,CAACP,YAAf,EAA6B;gBACzB;cACH;;cACD,IAAIO,SAAS,CAACC,IAAV,CAAeC,KAAf,KAAyBH,KAA7B,EAAoC;gBAChCL,IAAI,GAAGM,SAAS,CAACP,YAAV,CAAuBE,UAA9B;gBACA,SAASG,SAAT;cACH;YACJ,CATkC,CAUnC;;UAVmC;YAAA;UAAA;YAAA;UAAA;;UAWnC;QACH;MA/BwE;QAAA;MAAA;QAAA;MAAA;MAgCzE;AACR;AACA;;;MACQ,SAAAJ,IAAI,EAACS,IAAL,+CACSd,YAAY,CAACG,WAAb,CAAyB,CAAzB,CAAD,CAA0DC,YAA1D,CACCE,UAFT;IAIH;;;EA3DwCS,mC"}
@@ -0,0 +1,15 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ export interface ApolloCacheObject {
3
+ __typename?: string;
4
+ [key: string]: any;
5
+ }
6
+ interface ApolloCacheObjectIdPluginCallable<T> {
7
+ (data: T): string | null | undefined;
8
+ }
9
+ export declare class ApolloCacheObjectIdPlugin<T extends ApolloCacheObject = ApolloCacheObject> extends Plugin {
10
+ static readonly type: string;
11
+ private readonly _getObjectId?;
12
+ constructor(getObjectId?: ApolloCacheObjectIdPluginCallable<T>);
13
+ getObjectId(data: T): string | null | undefined;
14
+ }
15
+ export {};
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ApolloCacheObjectIdPlugin = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
+
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+
18
+ var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
19
+
20
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
21
+
22
+ var _plugins = require("@webiny/plugins");
23
+
24
+ var ApolloCacheObjectIdPlugin = /*#__PURE__*/function (_Plugin) {
25
+ (0, _inherits2.default)(ApolloCacheObjectIdPlugin, _Plugin);
26
+
27
+ var _super = (0, _createSuper2.default)(ApolloCacheObjectIdPlugin);
28
+
29
+ function ApolloCacheObjectIdPlugin(getObjectId) {
30
+ var _this;
31
+
32
+ (0, _classCallCheck2.default)(this, ApolloCacheObjectIdPlugin);
33
+ _this = _super.call(this);
34
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_getObjectId", void 0);
35
+ _this._getObjectId = getObjectId;
36
+ return _this;
37
+ }
38
+
39
+ (0, _createClass2.default)(ApolloCacheObjectIdPlugin, [{
40
+ key: "getObjectId",
41
+ value: function getObjectId(data) {
42
+ if (typeof this._getObjectId !== "function") {
43
+ throw Error("You must provide a \"getObjectId\" callable to the plugin constructor or extend the ApolloCacheObjectIdPlugin.");
44
+ }
45
+
46
+ return this._getObjectId(data);
47
+ }
48
+ }]);
49
+ return ApolloCacheObjectIdPlugin;
50
+ }(_plugins.Plugin);
51
+
52
+ exports.ApolloCacheObjectIdPlugin = ApolloCacheObjectIdPlugin;
53
+ (0, _defineProperty2.default)(ApolloCacheObjectIdPlugin, "type", "cache-get-object-id");
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ApolloCacheObjectIdPlugin","getObjectId","_getObjectId","data","Error","Plugin"],"sources":["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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;IAYaA,yB;;;;;EAMT,mCAAmBC,WAAnB,EAAuE;IAAA;;IAAA;IACnE;IADmE;IAEnE,MAAKC,YAAL,GAAoBD,WAApB;IAFmE;EAGtE;;;;WAED,qBAAmBE,IAAnB,EAA4B;MACxB,IAAI,OAAO,KAAKD,YAAZ,KAA6B,UAAjC,EAA6C;QACzC,MAAME,KAAK,kHAAX;MAGH;;MAED,OAAO,KAAKF,YAAL,CAAkBC,IAAlB,CAAP;IACH;;;EAjBKE,e;;;8BAFGL,yB,UAGsC,qB"}
@@ -0,0 +1,6 @@
1
+ import { ApolloLink, NextLink } from "apollo-link";
2
+ import { Operation } from "apollo-link/lib/types";
3
+ export declare class ApolloDynamicLink extends ApolloLink {
4
+ private cache;
5
+ request(operation: Operation, forward: NextLink): any;
6
+ }
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ApolloDynamicLink = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
+
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+
18
+ var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
19
+
20
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
21
+
22
+ var _apolloLink = require("apollo-link");
23
+
24
+ var _plugins = require("@webiny/plugins");
25
+
26
+ function createLink(plugin) {
27
+ try {
28
+ return plugin.createLink();
29
+ } catch (e) {
30
+ console.error("Caught an error while executing \"createLink\" on plugin", plugin);
31
+ console.error(e);
32
+ }
33
+
34
+ return null;
35
+ }
36
+
37
+ var ApolloDynamicLink = /*#__PURE__*/function (_ApolloLink) {
38
+ (0, _inherits2.default)(ApolloDynamicLink, _ApolloLink);
39
+
40
+ var _super = (0, _createSuper2.default)(ApolloDynamicLink);
41
+
42
+ function ApolloDynamicLink() {
43
+ var _this;
44
+
45
+ (0, _classCallCheck2.default)(this, ApolloDynamicLink);
46
+
47
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
48
+ args[_key] = arguments[_key];
49
+ }
50
+
51
+ _this = _super.call.apply(_super, [this].concat(args));
52
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "cache", new Map());
53
+ return _this;
54
+ }
55
+
56
+ (0, _createClass2.default)(ApolloDynamicLink, [{
57
+ key: "request",
58
+ value: function request(operation, forward) {
59
+ var linkPlugins = _plugins.plugins.byType("apollo-link");
60
+
61
+ if (!linkPlugins.length) {
62
+ return forward(operation);
63
+ }
64
+
65
+ var cacheKey = linkPlugins.map(function (pl) {
66
+ return pl.cacheKey;
67
+ }).join(",");
68
+
69
+ if (!this.cache.has(cacheKey)) {
70
+ /**
71
+ * We filter out falsy items from the linkPlugins because there might be some error while creating link.
72
+ */
73
+ var links = linkPlugins.map(createLink).filter(Boolean);
74
+ this.cache.set(cacheKey, _apolloLink.ApolloLink.from(links));
75
+ }
76
+
77
+ return this.cache.get(cacheKey).request(operation, forward);
78
+ }
79
+ }]);
80
+ return ApolloDynamicLink;
81
+ }(_apolloLink.ApolloLink);
82
+
83
+ exports.ApolloDynamicLink = ApolloDynamicLink;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createLink","plugin","e","console","error","ApolloDynamicLink","Map","operation","forward","linkPlugins","plugins","byType","length","cacheKey","map","pl","join","cache","has","links","filter","Boolean","set","ApolloLink","from","get","request"],"sources":["ApolloDynamicLink.ts"],"sourcesContent":["import { ApolloLink, NextLink } from \"apollo-link\";\nimport { plugins } from \"@webiny/plugins\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin\";\nimport { 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":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAIA,SAASA,UAAT,CAAoBC,MAApB,EAA8C;EAC1C,IAAI;IACA,OAAOA,MAAM,CAACD,UAAP,EAAP;EACH,CAFD,CAEE,OAAOE,CAAP,EAAU;IACRC,OAAO,CAACC,KAAR,6DAAwEH,MAAxE;IACAE,OAAO,CAACC,KAAR,CAAcF,CAAd;EACH;;EACD,OAAO,IAAP;AACH;;IAEYG,iB;;;;;;;;;;;;;;;wFACO,IAAIC,GAAJ,E;;;;;;WAEhB,iBAAwBC,SAAxB,EAA8CC,OAA9C,EAAiE;MAC7D,IAAMC,WAAW,GAAGC,gBAAA,CAAQC,MAAR,CAAiC,aAAjC,CAApB;;MAEA,IAAI,CAACF,WAAW,CAACG,MAAjB,EAAyB;QACrB,OAAOJ,OAAO,CAACD,SAAD,CAAd;MACH;;MAED,IAAMM,QAAQ,GAAGJ,WAAW,CAACK,GAAZ,CAAgB,UAAAC,EAAE;QAAA,OAAIA,EAAE,CAACF,QAAP;MAAA,CAAlB,EAAmCG,IAAnC,CAAwC,GAAxC,CAAjB;;MAEA,IAAI,CAAC,KAAKC,KAAL,CAAWC,GAAX,CAAeL,QAAf,CAAL,EAA+B;QAC3B;AACZ;AACA;QACY,IAAMM,KAAK,GAAGV,WAAW,CAACK,GAAZ,CAAgBd,UAAhB,EAA4BoB,MAA5B,CAAmCC,OAAnC,CAAd;QACA,KAAKJ,KAAL,CAAWK,GAAX,CAAeT,QAAf,EAAyBU,sBAAA,CAAWC,IAAX,CAAgBL,KAAhB,CAAzB;MACH;;MAED,OAAO,KAAKF,KAAL,CAAWQ,GAAX,CAAeZ,QAAf,EAAyBa,OAAzB,CAAiCnB,SAAjC,EAA4CC,OAA5C,CAAP;IACH;;;EArBkCe,sB"}
@@ -0,0 +1,13 @@
1
+ import { ApolloLink } from "apollo-link";
2
+ import { Plugin } from "@webiny/plugins";
3
+ export interface ApolloLinkFactory {
4
+ (): ApolloLink;
5
+ }
6
+ export declare class ApolloLinkPlugin extends Plugin {
7
+ static readonly type: string;
8
+ readonly cacheKey: string;
9
+ private readonly factory?;
10
+ private cache?;
11
+ constructor(factory?: ApolloLinkFactory);
12
+ createLink(): ApolloLink;
13
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ApolloLinkPlugin = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
+
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+
18
+ var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
19
+
20
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
21
+
22
+ var _nanoid = require("nanoid");
23
+
24
+ var _plugins = require("@webiny/plugins");
25
+
26
+ var ApolloLinkPlugin = /*#__PURE__*/function (_Plugin) {
27
+ (0, _inherits2.default)(ApolloLinkPlugin, _Plugin);
28
+
29
+ var _super = (0, _createSuper2.default)(ApolloLinkPlugin);
30
+
31
+ function ApolloLinkPlugin(factory) {
32
+ var _this;
33
+
34
+ (0, _classCallCheck2.default)(this, ApolloLinkPlugin);
35
+ _this = _super.call(this);
36
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "cacheKey", void 0);
37
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "factory", void 0);
38
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "cache", void 0);
39
+ _this.factory = factory;
40
+ _this.cacheKey = (0, _nanoid.nanoid)();
41
+ return _this;
42
+ }
43
+
44
+ (0, _createClass2.default)(ApolloLinkPlugin, [{
45
+ key: "createLink",
46
+ value: function createLink() {
47
+ if (this.cache) {
48
+ return this.cache;
49
+ }
50
+
51
+ if (typeof this.factory === "function") {
52
+ this.cache = this.factory();
53
+ return this.cache;
54
+ }
55
+
56
+ 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."));
57
+ }
58
+ }]);
59
+ return ApolloLinkPlugin;
60
+ }(_plugins.Plugin);
61
+
62
+ exports.ApolloLinkPlugin = ApolloLinkPlugin;
63
+ (0, _defineProperty2.default)(ApolloLinkPlugin, "type", "apollo-link");
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ApolloLinkPlugin","factory","cacheKey","nanoid","cache","Error","name","Plugin"],"sources":["ApolloLinkPlugin.ts"],"sourcesContent":["import { 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;;AACA;;IAMaA,gB;;;;;EAMT,0BAAYC,OAAZ,EAAyC;IAAA;;IAAA;IACrC;IADqC;IAAA;IAAA;IAErC,MAAKA,OAAL,GAAeA,OAAf;IACA,MAAKC,QAAL,GAAgB,IAAAC,cAAA,GAAhB;IAHqC;EAIxC;;;;WAED,sBAAgC;MAC5B,IAAI,KAAKC,KAAT,EAAgB;QACZ,OAAO,KAAKA,KAAZ;MACH;;MAED,IAAI,OAAO,KAAKH,OAAZ,KAAwB,UAA5B,EAAwC;QACpC,KAAKG,KAAL,GAAa,KAAKH,OAAL,EAAb;QAEA,OAAO,KAAKG,KAAZ;MACH;;MAED,MAAMC,KAAK,iDACiC,KAAKC,IADtC,2HAAX;IAGH;;;EA1BiCC,e;;;8BAAzBP,gB,UACsC,a"}
@@ -0,0 +1,8 @@
1
+ import { ApolloLink } from "apollo-link";
2
+ import { ApolloLinkPlugin } from "./ApolloLinkPlugin";
3
+ /**
4
+ * This link checks for presence of `extensions.console` in the response and logs all items to browser console.
5
+ */
6
+ export declare class ConsoleLinkPlugin extends ApolloLinkPlugin {
7
+ createLink(): ApolloLink;
8
+ }