@apollo/client 3.5.10 → 3.6.4

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 (144) hide show
  1. package/LICENSE +1 -1
  2. package/apollo-client.cjs +509 -341
  3. package/apollo-client.cjs.map +1 -1
  4. package/apollo-client.min.cjs +1 -1
  5. package/cache/cache.cjs.native.js +2289 -0
  6. package/core/ApolloClient.d.ts +2 -3
  7. package/core/ApolloClient.d.ts.map +1 -1
  8. package/core/ApolloClient.js +4 -8
  9. package/core/ApolloClient.js.map +1 -1
  10. package/core/ObservableQuery.d.ts +10 -4
  11. package/core/ObservableQuery.d.ts.map +1 -1
  12. package/core/ObservableQuery.js +97 -45
  13. package/core/ObservableQuery.js.map +1 -1
  14. package/core/QueryInfo.d.ts.map +1 -1
  15. package/core/QueryInfo.js +4 -2
  16. package/core/QueryInfo.js.map +1 -1
  17. package/core/QueryManager.d.ts +5 -2
  18. package/core/QueryManager.d.ts.map +1 -1
  19. package/core/QueryManager.js +29 -23
  20. package/core/QueryManager.js.map +1 -1
  21. package/core/core.cjs +138 -85
  22. package/core/core.cjs.map +1 -1
  23. package/core/core.cjs.native.js +2141 -0
  24. package/core/index.d.ts +1 -1
  25. package/core/index.d.ts.map +1 -1
  26. package/core/index.js +1 -1
  27. package/core/index.js.map +1 -1
  28. package/core/watchQueryOptions.d.ts +9 -1
  29. package/core/watchQueryOptions.d.ts.map +1 -1
  30. package/core/watchQueryOptions.js.map +1 -1
  31. package/errors/errors.cjs.native.js +48 -0
  32. package/invariantErrorCodes.js +1 -1
  33. package/link/batch/batch.cjs +47 -37
  34. package/link/batch/batch.cjs.map +1 -1
  35. package/link/batch/batch.cjs.native.js +161 -0
  36. package/link/batch/batching.d.ts +2 -6
  37. package/link/batch/batching.d.ts.map +1 -1
  38. package/link/batch/batching.js +47 -37
  39. package/link/batch/batching.js.map +1 -1
  40. package/link/batch-http/batch-http.cjs.native.js +127 -0
  41. package/link/context/context.cjs.native.js +38 -0
  42. package/link/core/core.cjs.native.js +121 -0
  43. package/link/error/error.cjs.native.js +90 -0
  44. package/link/http/http.cjs.native.js +320 -0
  45. package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
  46. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  47. package/link/persisted-queries/index.d.ts +2 -1
  48. package/link/persisted-queries/index.d.ts.map +1 -1
  49. package/link/persisted-queries/index.js +26 -13
  50. package/link/persisted-queries/index.js.map +1 -1
  51. package/link/persisted-queries/persisted-queries.cjs +25 -12
  52. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  53. package/link/persisted-queries/persisted-queries.cjs.native.js +174 -0
  54. package/link/retry/retry.cjs.native.js +170 -0
  55. package/link/schema/schema.cjs.native.js +56 -0
  56. package/link/subscriptions/subscriptions.cjs.native.js +45 -0
  57. package/link/utils/utils.cjs.native.js +115 -0
  58. package/link/ws/ws.cjs.native.js +28 -0
  59. package/main.cjs.native.js +16 -0
  60. package/package.json +28 -26
  61. package/react/components/components.cjs.native.js +79 -0
  62. package/react/context/ApolloConsumer.js +2 -2
  63. package/react/context/ApolloProvider.js +2 -2
  64. package/react/context/context.cjs +4 -4
  65. package/react/context/context.cjs.map +1 -1
  66. package/react/context/context.cjs.native.js +67 -0
  67. package/react/hoc/hoc.cjs.native.js +325 -0
  68. package/react/hooks/hooks.cjs +351 -247
  69. package/react/hooks/hooks.cjs.map +1 -1
  70. package/react/hooks/hooks.cjs.native.js +604 -0
  71. package/react/hooks/index.d.ts +1 -1
  72. package/react/hooks/index.d.ts.map +1 -1
  73. package/react/hooks/index.js +1 -1
  74. package/react/hooks/index.js.map +1 -1
  75. package/react/hooks/useLazyQuery.d.ts +2 -2
  76. package/react/hooks/useLazyQuery.d.ts.map +1 -1
  77. package/react/hooks/useLazyQuery.js +22 -21
  78. package/react/hooks/useLazyQuery.js.map +1 -1
  79. package/react/hooks/useMutation.d.ts.map +1 -1
  80. package/react/hooks/useMutation.js +6 -3
  81. package/react/hooks/useMutation.js.map +1 -1
  82. package/react/hooks/useQuery.d.ts +36 -2
  83. package/react/hooks/useQuery.d.ts.map +1 -1
  84. package/react/hooks/useQuery.js +238 -204
  85. package/react/hooks/useQuery.js.map +1 -1
  86. package/react/hooks/useSubscription.d.ts.map +1 -1
  87. package/react/hooks/useSubscription.js +17 -7
  88. package/react/hooks/useSubscription.js.map +1 -1
  89. package/react/hooks/useSyncExternalStore.d.ts +4 -0
  90. package/react/hooks/useSyncExternalStore.d.ts.map +1 -0
  91. package/react/hooks/useSyncExternalStore.js +48 -0
  92. package/react/hooks/useSyncExternalStore.js.map +1 -0
  93. package/react/parser/index.d.ts.map +1 -1
  94. package/react/parser/index.js +24 -10
  95. package/react/parser/index.js.map +1 -1
  96. package/react/parser/parser.cjs +24 -10
  97. package/react/parser/parser.cjs.map +1 -1
  98. package/react/parser/parser.cjs.native.js +103 -0
  99. package/react/react.cjs.native.js +22 -0
  100. package/react/ssr/RenderPromises.d.ts +3 -2
  101. package/react/ssr/RenderPromises.d.ts.map +1 -1
  102. package/react/ssr/RenderPromises.js +25 -3
  103. package/react/ssr/RenderPromises.js.map +1 -1
  104. package/react/ssr/ssr.cjs +25 -3
  105. package/react/ssr/ssr.cjs.map +1 -1
  106. package/react/ssr/ssr.cjs.native.js +150 -0
  107. package/react/types/types.d.ts +10 -11
  108. package/react/types/types.d.ts.map +1 -1
  109. package/react/types/types.js.map +1 -1
  110. package/testing/core/core.cjs.native.js +288 -0
  111. package/testing/core/mocking/mockFetch.js +1 -1
  112. package/testing/core/mocking/mockFetch.js.map +1 -1
  113. package/testing/core/mocking/mockQueryManager.js +1 -1
  114. package/testing/core/mocking/mockWatchQuery.js +1 -1
  115. package/testing/core/wrap.js +1 -1
  116. package/testing/testing.cjs.native.js +58 -0
  117. package/utilities/common/canUse.d.ts +2 -0
  118. package/utilities/common/canUse.d.ts.map +1 -1
  119. package/utilities/common/canUse.js +6 -2
  120. package/utilities/common/canUse.js.map +1 -1
  121. package/utilities/common/mergeOptions.d.ts +5 -0
  122. package/utilities/common/mergeOptions.d.ts.map +1 -0
  123. package/utilities/common/mergeOptions.js +8 -0
  124. package/utilities/common/mergeOptions.js.map +1 -0
  125. package/utilities/globals/global.js +1 -2
  126. package/utilities/globals/globals.cjs.native.js +56 -0
  127. package/utilities/graphql/transform.d.ts +2 -2
  128. package/utilities/graphql/transform.d.ts.map +1 -1
  129. package/utilities/graphql/transform.js +1 -1
  130. package/utilities/graphql/transform.js.map +1 -1
  131. package/utilities/index.d.ts +1 -0
  132. package/utilities/index.d.ts.map +1 -1
  133. package/utilities/index.js +1 -0
  134. package/utilities/index.js.map +1 -1
  135. package/utilities/observables/Concast.d.ts.map +1 -1
  136. package/utilities/observables/Concast.js +5 -2
  137. package/utilities/observables/Concast.js.map +1 -1
  138. package/utilities/policies/pagination.d.ts.map +1 -1
  139. package/utilities/policies/pagination.js +9 -7
  140. package/utilities/policies/pagination.js.map +1 -1
  141. package/utilities/utilities.cjs +29 -12
  142. package/utilities/utilities.cjs.map +1 -1
  143. package/utilities/utilities.cjs.native.js +1284 -0
  144. package/version.js +1 -1
@@ -14,11 +14,11 @@ export function createMockedIResponse(result, options) {
14
14
  }
15
15
  var MockFetch = (function () {
16
16
  function MockFetch() {
17
- var _this = this;
18
17
  var mockedResponses = [];
19
18
  for (var _i = 0; _i < arguments.length; _i++) {
20
19
  mockedResponses[_i] = arguments[_i];
21
20
  }
21
+ var _this = this;
22
22
  this.mockedResponsesByKey = {};
23
23
  mockedResponses.forEach(function (mockedResponse) {
24
24
  _this.addMockedResponse(mockedResponse);
@@ -1 +1 @@
1
- {"version":3,"file":"mockFetch.js","sourceRoot":"","sources":["../../../../src/testing/core/mocking/mockFetch.ts"],"names":[],"mappings":";AAAA,OAAO,cAAc,CAAC;AAmBtB,MAAM,UAAU,qBAAqB,CACnC,MAAc,EACd,OAAa;IAEb,IAAM,MAAM,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,GAAG,CA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E,CACH,CAAC;AACN,CAAC;AAED,MAAM,UAAU,eAAe;IAAC,yBAAyC;SAAzC,UAAyC,EAAzC,qBAAyC,EAAzC,IAAyC;QAAzC,oCAAyC;;IACvE,OAAO,KAAI,SAAS,YAAT,SAAS,0BAAI,eAAe,aAAE,QAAQ,EAAE,CAAC;AACtD,CAAC","sourcesContent":["import 'whatwg-fetch';\n\n// This is an implementation of a mocked window.fetch implementation similar in\n// structure to the MockedNetworkInterface.\n\nexport interface MockedIResponse {\n ok: boolean;\n status: number;\n statusText?: string;\n json(): Promise<Object>;\n}\n\nexport interface MockedFetchResponse {\n url: string;\n opts: RequestInit;\n result: MockedIResponse;\n delay?: number;\n}\n\nexport function createMockedIResponse(\n result: Object,\n options?: any,\n): MockedIResponse {\n const status = (options && options.status) || 200;\n const statusText = (options && options.statusText) || undefined;\n\n return {\n ok: status === 200,\n status,\n statusText,\n json() {\n return Promise.resolve<Object>(result);\n },\n };\n}\n\nexport class MockFetch {\n private mockedResponsesByKey: { [key: string]: MockedFetchResponse[] };\n\n constructor(...mockedResponses: MockedFetchResponse[]) {\n this.mockedResponsesByKey = {};\n\n mockedResponses.forEach(mockedResponse => {\n this.addMockedResponse(mockedResponse);\n });\n }\n\n public addMockedResponse(mockedResponse: MockedFetchResponse) {\n const key = this.fetchParamsToKey(mockedResponse.url, mockedResponse.opts);\n let mockedResponses = this.mockedResponsesByKey[key];\n\n if (!mockedResponses) {\n mockedResponses = [];\n this.mockedResponsesByKey[key] = mockedResponses;\n }\n\n mockedResponses.push(mockedResponse);\n }\n\n public fetch(url: string, opts: RequestInit) {\n const key = this.fetchParamsToKey(url, opts);\n const responses = this.mockedResponsesByKey[key];\n if (!responses || responses.length === 0) {\n throw new Error(\n `No more mocked fetch responses for the params ${url} and ${opts}`,\n );\n }\n\n const { result, delay } = responses.shift()!;\n\n if (!result) {\n throw new Error(`Mocked fetch response should contain a result.`);\n }\n\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve(result);\n }, delay ? delay : 0);\n });\n }\n\n public fetchParamsToKey(url: string, opts: RequestInit): string {\n return JSON.stringify({\n url,\n opts: sortByKey(opts),\n });\n }\n\n // Returns a \"fetch\" function equivalent that mocks the given responses.\n // The function by returned by this should be tacked onto the global scope\n // in order to test functions that use \"fetch\".\n public getFetch() {\n return this.fetch.bind(this);\n }\n}\n\nfunction sortByKey(obj: any): Object {\n return Object.keys(obj)\n .sort()\n .reduce(\n (ret: any, key: string): Object =>\n Object.assign(\n {\n [key]:\n Object.prototype.toString.call(obj[key]).slice(8, -1) === 'Object'\n ? sortByKey(obj[key])\n : obj[key],\n },\n ret,\n ),\n {},\n );\n}\n\nexport function createMockFetch(...mockedResponses: MockedFetchResponse[]) {\n return new MockFetch(...mockedResponses).getFetch();\n}\n"]}
1
+ {"version":3,"file":"mockFetch.js","sourceRoot":"","sources":["../../../../src/testing/core/mocking/mockFetch.ts"],"names":[],"mappings":";AAAA,OAAO,cAAc,CAAC;AAmBtB,MAAM,UAAU,qBAAqB,CACnC,MAAc,EACd,OAAa;IAEb,IAAM,MAAM,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC;IAClD,IAAM,UAAU,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,SAAS,CAAC;IAEhE,OAAO;QACL,EAAE,EAAE,MAAM,KAAK,GAAG;QAClB,MAAM,QAAA;QACN,UAAU,YAAA;QACV,IAAI,EAAJ;YACE,OAAO,OAAO,CAAC,OAAO,CAAS,MAAM,CAAC,CAAC;QACzC,CAAC;KACF,CAAC;AACJ,CAAC;AAED;IAGE;QAAY,yBAAyC;aAAzC,UAAyC,EAAzC,qBAAyC,EAAzC,IAAyC;YAAzC,oCAAyC;;QAArD,iBAMC;QALC,IAAI,CAAC,oBAAoB,GAAG,EAAE,CAAC;QAE/B,eAAe,CAAC,OAAO,CAAC,UAAA,cAAc;YACpC,KAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,CA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I,CAAC,SAAS,CAAC;YACpB,GAAG,KAAA;YACH,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC;SACtB,CAAC,CAAC;IACL,CAAC;IAKM,4BAAQ,GAAf;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IACH,gBAAC;AAAD,CAAC,AA1DD,IA0DC;;AAED,SAAS,SAAS,CAAC,GAAQ;IACzB,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;SACpB,IAAI,EAAE;SACN,MAAM,CACL,UAAC,GAAQ,EAAE,GAAW;;QACpB,OAAA,MAAM,CAAC,MAAM;YAET,GAAC,GAAG,IACF,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,QAAQ;gBAChE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACrB,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;iBAEhB,GAAG,CACJ;IARD,CAQC,EACH,EAAE,CACH,CAAC;AACN,CAAC;AAED,MAAM,UAAU,eAAe;IAAC,yBAAyC;SAAzC,UAAyC,EAAzC,qBAAyC,EAAzC,IAAyC;QAAzC,oCAAyC;;IACvE,OAAO,KAAI,SAAS,YAAT,SAAS,0BAAI,eAAe,aAAE,QAAQ,EAAE,CAAC;AACtD,CAAC","sourcesContent":["import 'whatwg-fetch';\n\n// This is an implementation of a mocked window.fetch implementation similar in\n// structure to the MockedNetworkInterface.\n\nexport interface MockedIResponse {\n ok: boolean;\n status: number;\n statusText?: string;\n json(): Promise<Object>;\n}\n\nexport interface MockedFetchResponse {\n url: string;\n opts: RequestInit;\n result: MockedIResponse;\n delay?: number;\n}\n\nexport function createMockedIResponse(\n result: Object,\n options?: any,\n): MockedIResponse {\n const status = (options && options.status) || 200;\n const statusText = (options && options.statusText) || undefined;\n\n return {\n ok: status === 200,\n status,\n statusText,\n json() {\n return Promise.resolve<Object>(result);\n },\n };\n}\n\nexport class MockFetch {\n private mockedResponsesByKey: { [key: string]: MockedFetchResponse[] };\n\n constructor(...mockedResponses: MockedFetchResponse[]) {\n this.mockedResponsesByKey = {};\n\n mockedResponses.forEach(mockedResponse => {\n this.addMockedResponse(mockedResponse);\n });\n }\n\n public addMockedResponse(mockedResponse: MockedFetchResponse) {\n const key = this.fetchParamsToKey(mockedResponse.url, mockedResponse.opts);\n let mockedResponses = this.mockedResponsesByKey[key];\n\n if (!mockedResponses) {\n mockedResponses = [];\n this.mockedResponsesByKey[key] = mockedResponses;\n }\n\n mockedResponses.push(mockedResponse);\n }\n\n public fetch(url: string, opts: RequestInit) {\n const key = this.fetchParamsToKey(url, opts);\n const responses = this.mockedResponsesByKey[key];\n if (!responses || responses.length === 0) {\n throw new Error(\n `No more mocked fetch responses for the params ${url} and ${opts}`,\n );\n }\n\n const { result, delay } = responses.shift()!;\n\n if (!result) {\n throw new Error(`Mocked fetch response should contain a result.`);\n }\n\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve(result);\n }, delay ? delay : 0);\n });\n }\n\n public fetchParamsToKey(url: string, opts: RequestInit): string {\n return JSON.stringify({\n url,\n opts: sortByKey(opts),\n });\n }\n\n // Returns a \"fetch\" function equivalent that mocks the given responses.\n // The function by returned by this should be tacked onto the global scope\n // in order to test functions that use \"fetch\".\n public getFetch() {\n return this.fetch.bind(this);\n }\n}\n\nfunction sortByKey(obj: any): Object {\n return Object.keys(obj)\n .sort()\n .reduce(\n (ret: any, key: string): Object =>\n Object.assign(\n {\n [key]:\n Object.prototype.toString.call(obj[key]).slice(8, -1) === 'Object'\n ? sortByKey(obj[key])\n : obj[key],\n },\n ret,\n ),\n {},\n );\n}\n\nexport function createMockFetch(...mockedResponses: MockedFetchResponse[]) {\n return new MockFetch(...mockedResponses).getFetch();\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { QueryManager } from "../../../core/QueryManager.js";
2
2
  import { mockSingleLink } from "./mockLink.js";
3
3
  import { InMemoryCache } from "../../../cache/index.js";
4
- export default (function (reject) {
4
+ export default (function(reject) {
5
5
  var mockedResponses = [];
6
6
  for (var _i = 1; _i < arguments.length; _i++) {
7
7
  mockedResponses[_i - 1] = arguments[_i];
@@ -1,6 +1,6 @@
1
1
  import { __spreadArray } from "tslib";
2
2
  import mockQueryManager from "./mockQueryManager.js";
3
- export default (function (reject) {
3
+ export default (function(reject) {
4
4
  var mockedResponses = [];
5
5
  for (var _i = 1; _i < arguments.length; _i++) {
6
6
  mockedResponses[_i - 1] = arguments[_i];
@@ -1,4 +1,4 @@
1
- export default (function (reject, cb) { return function () {
1
+ export default (function(reject, cb) { return function () {
2
2
  var args = [];
3
3
  for (var _i = 0; _i < arguments.length; _i++) {
4
4
  args[_i] = arguments[_i];
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ require('../utilities/globals');
6
+ var tslib = require('tslib');
7
+ var React = require('react');
8
+ var core$1 = require('../core');
9
+ var cache = require('../cache');
10
+ var context = require('../react/context');
11
+ var core = require('./core');
12
+
13
+ function _interopNamespace(e) {
14
+ if (e && e.__esModule) return e;
15
+ var n = Object.create(null);
16
+ if (e) {
17
+ for (var k in e) {
18
+ n[k] = e[k];
19
+ }
20
+ }
21
+ n["default"] = e;
22
+ return Object.freeze(n);
23
+ }
24
+
25
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
26
+
27
+ var MockedProvider = (function (_super) {
28
+ tslib.__extends(MockedProvider, _super);
29
+ function MockedProvider(props) {
30
+ var _this = _super.call(this, props) || this;
31
+ var _a = _this.props, mocks = _a.mocks, addTypename = _a.addTypename, defaultOptions = _a.defaultOptions, cache$1 = _a.cache, resolvers = _a.resolvers, link = _a.link;
32
+ var client = new core$1.ApolloClient({
33
+ cache: cache$1 || new cache.InMemoryCache({ addTypename: addTypename }),
34
+ defaultOptions: defaultOptions,
35
+ link: link || new core.MockLink(mocks || [], addTypename),
36
+ resolvers: resolvers,
37
+ });
38
+ _this.state = { client: client };
39
+ return _this;
40
+ }
41
+ MockedProvider.prototype.render = function () {
42
+ var _a = this.props, children = _a.children, childProps = _a.childProps;
43
+ return React__namespace.isValidElement(children) ? (React__namespace.createElement(context.ApolloProvider, { client: this.state.client }, React__namespace.cloneElement(React__namespace.Children.only(children), tslib.__assign({}, childProps)))) : null;
44
+ };
45
+ MockedProvider.prototype.componentWillUnmount = function () {
46
+ this.state.client.stop();
47
+ };
48
+ MockedProvider.defaultProps = {
49
+ addTypename: true
50
+ };
51
+ return MockedProvider;
52
+ }(React__namespace.Component));
53
+
54
+ exports.MockedProvider = MockedProvider;
55
+ for (var k in core) {
56
+ if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = core[k];
57
+ }
58
+ //# sourceMappingURL=testing.cjs.map
@@ -1,4 +1,6 @@
1
1
  export declare const canUseWeakMap: boolean;
2
2
  export declare const canUseWeakSet: boolean;
3
3
  export declare const canUseSymbol: boolean;
4
+ export declare const canUseDOM: boolean;
5
+ export declare const canUseLayoutEffect: boolean;
4
6
  //# sourceMappingURL=canUse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"canUse.d.ts","sourceRoot":"","sources":["../../../src/utilities/common/canUse.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,SAGzB,CAAC;AAEF,eAAO,MAAM,aAAa,SAAgC,CAAC;AAE3D,eAAO,MAAM,YAAY,SAES,CAAC"}
1
+ {"version":3,"file":"canUse.d.ts","sourceRoot":"","sources":["../../../src/utilities/common/canUse.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,SAEwB,CAAC;AAEnD,eAAO,MAAM,aAAa,SAAgC,CAAC;AAE3D,eAAO,MAAM,YAAY,SAES,CAAC;AAEnC,eAAO,MAAM,SAAS,SAC4C,CAAC;AAmBnE,eAAO,MAAM,kBAAkB,SAA2B,CAAC"}
@@ -1,6 +1,10 @@
1
- export var canUseWeakMap = typeof WeakMap === 'function' && !(typeof navigator === 'object' &&
2
- navigator.product === 'ReactNative');
1
+ import { maybe } from "../globals/index.js";
2
+ export var canUseWeakMap = typeof WeakMap === 'function' &&
3
+ maybe(function () { return navigator.product; }) !== 'ReactNative';
3
4
  export var canUseWeakSet = typeof WeakSet === 'function';
4
5
  export var canUseSymbol = typeof Symbol === 'function' &&
5
6
  typeof Symbol.for === 'function';
7
+ export var canUseDOM = typeof maybe(function () { return window.document.createElement; }) === "function";
8
+ var usingJSDOM = maybe(function () { return navigator.userAgent.indexOf("jsdom") >= 0; }) || false;
9
+ export var canUseLayoutEffect = canUseDOM && !usingJSDOM;
6
10
  //# sourceMappingURL=canUse.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"canUse.js","sourceRoot":"","sources":["../../../src/utilities/common/canUse.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,aAAa,GAAG,OAAO,OAAO,KAAK,UAAU,IAAI,CAAC,CAC7D,OAAO,SAAS,KAAK,QAAQ;IAC7B,SAAS,CAAC,OAAO,KAAK,aAAa,CACpC,CAAC;AAEF,MAAM,CAAC,IAAM,aAAa,GAAG,OAAO,OAAO,KAAK,UAAU,CAAC;AAE3D,MAAM,CAAC,IAAM,YAAY,GACvB,OAAO,MAAM,KAAK,UAAU;IAC5B,OAAO,MAAM,CAAC,GAAG,KAAK,UAAU,CAAC","sourcesContent":["export const canUseWeakMap = typeof WeakMap === 'function' && !(\n typeof navigator === 'object' &&\n navigator.product === 'ReactNative'\n);\n\nexport const canUseWeakSet = typeof WeakSet === 'function';\n\nexport const canUseSymbol =\n typeof Symbol === 'function' &&\n typeof Symbol.for === 'function';\n"]}
1
+ {"version":3,"file":"canUse.js","sourceRoot":"","sources":["../../../src/utilities/common/canUse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,CAAC,IAAM,aAAa,GACxB,OAAO,OAAO,KAAK,UAAU;IAC7B,KAAK,CAAC,cAAM,OAAA,SAAS,CAAC,OAAO,EAAjB,CAAiB,CAAC,KAAK,aAAa,CAAC;AAEnD,MAAM,CAAC,IAAM,aAAa,GAAG,OAAO,OAAO,KAAK,UAAU,CAAC;AAE3D,MAAM,CAAC,IAAM,YAAY,GACvB,OAAO,MAAM,KAAK,UAAU;IAC5B,OAAO,MAAM,CAAC,GAAG,KAAK,UAAU,CAAC;AAEnC,MAAM,CAAC,IAAM,SAAS,GACpB,OAAO,KAAK,CAAC,cAAM,OAAA,MAAM,CAAC,QAAQ,CAAC,aAAa,EAA7B,CAA6B,CAAC,KAAK,UAAU,CAAC;AAEnE,IAAM,UAAU,GASd,KAAK,CAAC,cAAM,OAAA,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAzC,CAAyC,CAAC,IAAI,KAAK,CAAC;AAQlE,MAAM,CAAC,IAAM,kBAAkB,GAAG,SAAS,IAAI,CAAC,UAAU,CAAC","sourcesContent":["import { maybe } from \"../globals\";\n\nexport const canUseWeakMap =\n typeof WeakMap === 'function' &&\n maybe(() => navigator.product) !== 'ReactNative';\n\nexport const canUseWeakSet = typeof WeakSet === 'function';\n\nexport const canUseSymbol =\n typeof Symbol === 'function' &&\n typeof Symbol.for === 'function';\n\nexport const canUseDOM =\n typeof maybe(() => window.document.createElement) === \"function\";\n\nconst usingJSDOM: boolean =\n // Following advice found in this comment from @domenic (maintainer of jsdom):\n // https://github.com/jsdom/jsdom/issues/1537#issuecomment-229405327\n //\n // Since we control the version of Jest and jsdom used when running Apollo\n // Client tests, and that version is recent enought to include \" jsdom/x.y.z\"\n // at the end of the user agent string, I believe this case is all we need to\n // check. Testing for \"Node.js\" was recommended for backwards compatibility\n // with older version of jsdom, but we don't have that problem.\n maybe(() => navigator.userAgent.indexOf(\"jsdom\") >= 0) || false;\n\n// Our tests should all continue to pass if we remove this !usingJSDOM\n// condition, thereby allowing useLayoutEffect when using jsdom. Unfortunately,\n// if we allow useLayoutEffect, then useSyncExternalStore generates many\n// warnings about useLayoutEffect doing nothing on the server. While these\n// warnings are harmless, this !usingJSDOM condition seems to be the best way to\n// prevent them (i.e. skipping useLayoutEffect when using jsdom).\nexport const canUseLayoutEffect = canUseDOM && !usingJSDOM;\n"]}
@@ -0,0 +1,5 @@
1
+ import type { QueryOptions, WatchQueryOptions, MutationOptions } from "../../core";
2
+ declare type OptionsUnion<TData, TVariables, TContext> = WatchQueryOptions<TVariables, TData> | QueryOptions<TVariables, TData> | MutationOptions<TData, TVariables, TContext>;
3
+ export declare function mergeOptions<TOptions extends OptionsUnion<any, any, any>>(defaults: TOptions | Partial<TOptions> | undefined, options: TOptions | Partial<TOptions>): TOptions;
4
+ export {};
5
+ //# sourceMappingURL=mergeOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeOptions.d.ts","sourceRoot":"","sources":["../../../src/utilities/common/mergeOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,eAAe,EAChB,MAAM,YAAY,CAAC;AAIpB,aAAK,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,IACzC,iBAAiB,CAAC,UAAU,EAAE,KAAK,CAAC,GACpC,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,GAC/B,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AAEjD,wBAAgB,YAAY,CAC1B,QAAQ,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAE5C,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,SAAS,EAClD,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,GACpC,QAAQ,CAOV"}
@@ -0,0 +1,8 @@
1
+ import { __assign } from "tslib";
2
+ import { compact } from "./compact.js";
3
+ export function mergeOptions(defaults, options) {
4
+ return compact(defaults, options, options.variables && {
5
+ variables: __assign(__assign({}, (defaults && defaults.variables)), options.variables),
6
+ });
7
+ }
8
+ //# sourceMappingURL=mergeOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeOptions.js","sourceRoot":"","sources":["../../../src/utilities/common/mergeOptions.ts"],"names":[],"mappings":";AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,MAAM,UAAU,YAAY,CAG1B,QAAkD,EAClD,OAAqC;IAErC,OAAO,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,SAAS,IAAI;QACrD,SAAS,wBACJ,CAAC,QAAQ,IAAI,QAAQ,CAAC,SAAS,CAAC,GAChC,OAAO,CAAC,SAAS,CACrB;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type {\n QueryOptions,\n WatchQueryOptions,\n MutationOptions,\n} from \"../../core\";\n\nimport { compact } from \"./compact\";\n\ntype OptionsUnion<TData, TVariables, TContext> =\n | WatchQueryOptions<TVariables, TData>\n | QueryOptions<TVariables, TData>\n | MutationOptions<TData, TVariables, TContext>;\n\nexport function mergeOptions<\n TOptions extends OptionsUnion<any, any, any>\n>(\n defaults: TOptions | Partial<TOptions> | undefined,\n options: TOptions | Partial<TOptions>,\n): TOptions {\n return compact(defaults, options, options.variables && {\n variables: {\n ...(defaults && defaults.variables),\n ...options.variables,\n },\n });\n}\n"]}
@@ -2,6 +2,5 @@ import { maybe } from "./maybe.js";
2
2
  export default (maybe(function () { return globalThis; }) ||
3
3
  maybe(function () { return window; }) ||
4
4
  maybe(function () { return self; }) ||
5
- maybe(function () { return global; }) ||
6
- maybe(function () { return maybe.constructor("return this")(); }));
5
+ maybe(function () { return global; }) || maybe(function () { return maybe.constructor("return this")(); }));
7
6
  //# sourceMappingURL=global.js.map
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tsInvariant = require('ts-invariant');
6
+ var process$1 = require('ts-invariant/process');
7
+ var graphql = require('graphql');
8
+
9
+ function maybe(thunk) {
10
+ try {
11
+ return thunk();
12
+ }
13
+ catch (_a) { }
14
+ }
15
+
16
+ var global$1 = (maybe(function () { return globalThis; }) ||
17
+ maybe(function () { return window; }) ||
18
+ maybe(function () { return self; }) ||
19
+ maybe(function () { return global; }) ||
20
+ maybe(function () { return maybe.constructor("return this")(); }));
21
+
22
+ var __ = "__";
23
+ var GLOBAL_KEY = [__, __].join("DEV");
24
+ function getDEV() {
25
+ try {
26
+ return Boolean(__DEV__);
27
+ }
28
+ catch (_a) {
29
+ Object.defineProperty(global$1, GLOBAL_KEY, {
30
+ value: maybe(function () { return process.env.NODE_ENV; }) !== "production",
31
+ enumerable: false,
32
+ configurable: true,
33
+ writable: true,
34
+ });
35
+ return global$1[GLOBAL_KEY];
36
+ }
37
+ }
38
+ var DEV = getDEV();
39
+
40
+ function removeTemporaryGlobals() {
41
+ return typeof graphql.Source === "function" ? process$1.remove() : process$1.remove();
42
+ }
43
+
44
+ function checkDEV() {
45
+ __DEV__ ? tsInvariant.invariant("boolean" === typeof DEV, DEV) : tsInvariant.invariant("boolean" === typeof DEV, 36);
46
+ }
47
+ removeTemporaryGlobals();
48
+ checkDEV();
49
+
50
+ exports.InvariantError = tsInvariant.InvariantError;
51
+ exports.invariant = tsInvariant.invariant;
52
+ exports.DEV = DEV;
53
+ exports.checkDEV = checkDEV;
54
+ exports.global = global$1;
55
+ exports.maybe = maybe;
56
+ //# sourceMappingURL=globals.cjs.map
@@ -1,4 +1,4 @@
1
- import { DocumentNode, FieldNode, DirectiveNode, FragmentDefinitionNode, ArgumentNode, FragmentSpreadNode, VariableDefinitionNode } from 'graphql';
1
+ import { DocumentNode, FieldNode, DirectiveNode, FragmentDefinitionNode, ArgumentNode, FragmentSpreadNode, VariableDefinitionNode, ASTNode } from 'graphql';
2
2
  export declare type RemoveNodeConfig<N> = {
3
3
  name?: string;
4
4
  test?: (node: N) => boolean;
@@ -16,7 +16,7 @@ export declare type RemoveFragmentSpreadConfig = RemoveNodeConfig<FragmentSpread
16
16
  export declare type RemoveFragmentDefinitionConfig = RemoveNodeConfig<FragmentDefinitionNode>;
17
17
  export declare type RemoveVariableDefinitionConfig = RemoveNodeConfig<VariableDefinitionNode>;
18
18
  export declare function removeDirectivesFromDocument(directives: RemoveDirectiveConfig[], doc: DocumentNode): DocumentNode | null;
19
- export declare const addTypenameToDocument: ((doc: DocumentNode) => DocumentNode) & {
19
+ export declare const addTypenameToDocument: (<TNode extends ASTNode>(doc: TNode) => TNode) & {
20
20
  added(field: FieldNode): boolean;
21
21
  };
22
22
  export declare function removeConnectionDirectiveFromDocument(doc: DocumentNode): DocumentNode | null;
@@ -1 +1 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/utilities/graphql/transform.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EAIZ,SAAS,EACT,aAAa,EACb,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EAGvB,MAAM,SAAS,CAAC;AAmBjB,oBAAY,gBAAgB,CAAC,CAAC,IAAI;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,oBAAY,aAAa,CAAC,CAAC,IAAI;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;CAC7B,CAAC;AAEF,oBAAY,qBAAqB,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC;AACpE,oBAAY,kBAAkB,GAAG,aAAa,CAAC,aAAa,CAAC,CAAC;AAC9D,oBAAY,qBAAqB,GAAG,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACnE,oBAAY,uBAAuB,GAAG,aAA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 -97,7 +97,7 @@ export function removeDirectivesFromDocument(directives, doc) {
97
97
  return modifiedDoc;
98
98
  }
99
99
  export var addTypenameToDocument = Object.assign(function (doc) {
100
- return visit(checkDocument(doc), {
100
+ return visit(doc, {
101
101
  SelectionSet: {
102
102
  enter: function (node, _key, parent) {
103
103
  if (parent &&
@@ -1 +1 @@
1
- {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/utilities/graphql/transform.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAYL,KAAK,GACN,MAAM,SAAS,CAAC;AAKjB,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EACL,iBAAiB,GAElB,MAAM,aAAa,CAAC;AAyBrB,IAAM,cAAc,GAAc;IAChC,IAAI,EAAE,OAAe;IACrB,IAAI,EAAE;QACJ,IAAI,EAAE,MAAc;QACpB,KAAK,EAAE,YAAY;KACpB;CACF,CAAC;AAEF,SAAS,OAAO,CACd,EAAoD,EACpD,SAAsB;IAEtB,OAAO,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,CACrC,UAAA,SAAS;QACP,OAAA,SAAS,CAAC,IAAI,KAAK,gBAAgB;YACnC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IADnD,CACmD,CACtD,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,GAAiB;IACzC,OAAO,OAAO,CACZ,sBAAsB,CAAC,GAAG,CAAC,IAAI,qBAAqB,CAAC,GAAG,CAAC,EACzD,iBAAiB,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAA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AI,CAAC,KAAK,KAAK,QAAQ,EAAjC,CAAiC;YACrE,MAAM,EAAE,IAAI;SACb;KACF,EACD,QAAQ,CACT,CAAC;IAMF,IAAI,WAAW,EAAE;QACf,WAAW,GAAG,KAAK,CAAC,WAAW,EAAE;YAC/B,kBAAkB,EAAE;gBAClB,KAAK,YAAC,IAAI;oBACR,IAAI,IAAI,CAAC,YAAY,EAAE;wBACrB,IAAM,cAAc,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,CACvD,UAAA,SAAS;4BACP,OAAA,OAAO,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,KAAK,YAAY;wBAA3D,CAA2D,CAC9D,CAAC;wBACF,IAAI,cAAc,EAAE;4BAClB,OAAO,IAAI,CAAC;yBACb;qBACF;gBACH,CAAC;aACF;SACF,CAAC,CAAC;KACJ;IAED,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { invariant } from '../globals';\n\nimport {\n DocumentNode,\n SelectionNode,\n SelectionSetNode,\n OperationDefinitionNode,\n FieldNode,\n DirectiveNode,\n FragmentDefinitionNode,\n ArgumentNode,\n FragmentSpreadNode,\n VariableDefinitionNode,\n VariableNode,\n visit,\n} from 'graphql';\n\n// TODO(brian): A hack until this issue is resolved (https://github.com/graphql/graphql-js/issues/3356)\ntype Kind = any;\n\nimport {\n checkDocument,\n getOperationDefinition,\n getFragmentDefinition,\n getFragmentDefinitions,\n getMainDefinition,\n} from './getFromAST';\nimport { filterInPlace } from '../common/filterInPlace';\nimport { isField, isInlineFragment } from './storeUtils';\nimport {\n createFragmentMap,\n FragmentMap,\n} from './fragments';\n\nexport type RemoveNodeConfig<N> = {\n name?: string;\n test?: (node: N) => boolean;\n remove?: boolean;\n};\n\nexport type GetNodeConfig<N> = {\n name?: string;\n test?: (node: N) => boolean;\n};\n\nexport type RemoveDirectiveConfig = RemoveNodeConfig<DirectiveNode>;\nexport type GetDirectiveConfig = GetNodeConfig<DirectiveNode>;\nexport type RemoveArgumentsConfig = RemoveNodeConfig<ArgumentNode>;\nexport type GetFragmentSpreadConfig = GetNodeConfig<FragmentSpreadNode>;\nexport type RemoveFragmentSpreadConfig = RemoveNodeConfig<FragmentSpreadNode>;\nexport type RemoveFragmentDefinitionConfig = RemoveNodeConfig<\n FragmentDefinitionNode\n>;\nexport type RemoveVariableDefinitionConfig = RemoveNodeConfig<\n VariableDefinitionNode\n>;\n\nconst TYPENAME_FIELD: FieldNode = {\n kind: 'Field' as Kind,\n name: {\n kind: 'Name' as Kind,\n value: '__typename',\n },\n};\n\nfunction isEmpty(\n op: OperationDefinitionNode | FragmentDefinitionNode,\n fragments: FragmentMap,\n): boolean {\n return op.selectionSet.selections.every(\n selection =>\n selection.kind === 'FragmentSpread' &&\n isEmpty(fragments[selection.name.value], fragments),\n );\n}\n\nfunction nullIfDocIsEmpty(doc: DocumentNode) {\n return isEmpty(\n getOperationDefinition(doc) || getFragmentDefinition(doc),\n createFragmentMap(getFragmentDefinitions(doc)),\n )\n ? null\n : doc;\n}\n\nfunction getDirectiveMatcher(\n directives: (RemoveDirectiveConfig | GetDirectiveConfig)[],\n) {\n return function directiveMatcher(directive: DirectiveNode) {\n return directives.some(\n dir =>\n (dir.name && dir.name === directive.name.value) ||\n (dir.test && dir.test(directive)),\n );\n };\n}\n\nexport function removeDirectivesFromDocument(\n directives: RemoveDirectiveConfig[],\n doc: DocumentNode,\n): DocumentNode | null {\n const variablesInUse: Record<string, boolean> = Object.create(null);\n let variablesToRemove: RemoveArgumentsConfig[] = [];\n\n const fragmentSpreadsInUse: Record<string, boolean> = Object.create(null);\n let fragmentSpreadsToRemove: RemoveFragmentSpreadConfig[] = [];\n\n let modifiedDoc = nullIfDocIsEmpty(\n visit(doc, {\n Variable: {\n enter(node, _key, parent) {\n // Store each variable that's referenced as part of an argument\n // (excluding operation definition variables), so we know which\n // variables are being used. If we later want to remove a variable\n // we'll first check to see if it's being used, before continuing with\n // the removal.\n if (\n (parent as VariableDefinitionNode).kind !== 'VariableDefinition'\n ) {\n variablesInUse[node.name.value] = true;\n }\n },\n },\n\n Field: {\n enter(node) {\n if (directives && node.directives) {\n // If `remove` is set to true for a directive, and a directive match\n // is found for a field, remove the field as well.\n const shouldRemoveField = directives.some(\n directive => directive.remove,\n );\n\n if (\n shouldRemoveField &&\n node.directives &&\n node.directives.some(getDirectiveMatcher(directives))\n ) {\n if (node.arguments) {\n // Store field argument variables so they can be removed\n // from the operation definition.\n node.arguments.forEach(arg => {\n if (arg.value.kind === 'Variable') {\n variablesToRemove.push({\n name: (arg.value as VariableNode).name.value,\n });\n }\n });\n }\n\n if (node.selectionSet) {\n // Store fragment spread names so they can be removed from the\n // document.\n getAllFragmentSpreadsFromSelectionSet(node.selectionSet).forEach(\n frag => {\n fragmentSpreadsToRemove.push({\n name: frag.name.value,\n });\n },\n );\n }\n\n // Remove the field.\n return null;\n }\n }\n },\n },\n\n FragmentSpread: {\n enter(node) {\n // Keep track of referenced fragment spreads. This is used to\n // determine if top level fragment definitions should be removed.\n fragmentSpreadsInUse[node.name.value] = true;\n },\n },\n\n Directive: {\n enter(node) {\n // If a matching directive is found, remove it.\n if (getDirectiveMatcher(directives)(node)) {\n return null;\n }\n },\n },\n }),\n );\n\n // If we've removed fields with arguments, make sure the associated\n // variables are also removed from the rest of the document, as long as they\n // aren't being used elsewhere.\n if (\n modifiedDoc &&\n filterInPlace(variablesToRemove, v => !!v.name && !variablesInUse[v.name]).length\n ) {\n modifiedDoc = removeArgumentsFromDocument(variablesToRemove, modifiedDoc);\n }\n\n // If we've removed selection sets with fragment spreads, make sure the\n // associated fragment definitions are also removed from the rest of the\n // document, as long as they aren't being used elsewhere.\n if (\n modifiedDoc &&\n filterInPlace(fragmentSpreadsToRemove, fs => !!fs.name && !fragmentSpreadsInUse[fs.name])\n .length\n ) {\n modifiedDoc = removeFragmentSpreadFromDocument(\n fragmentSpreadsToRemove,\n modifiedDoc,\n );\n }\n\n return modifiedDoc;\n}\n\nexport const addTypenameToDocument = Object.assign(function (\n doc: DocumentNode\n): DocumentNode {\n return visit(checkDocument(doc), {\n SelectionSet: {\n enter(node, _key, parent) {\n // Don't add __typename to OperationDefinitions.\n if (\n parent &&\n (parent as OperationDefinitionNode).kind === 'OperationDefinition'\n ) {\n return;\n }\n\n // No changes if no selections.\n const { selections } = node;\n if (!selections) {\n return;\n }\n\n // If selections already have a __typename, or are part of an\n // introspection query, do nothing.\n const skip = selections.some(selection => {\n return (\n isField(selection) &&\n (selection.name.value === '__typename' ||\n selection.name.value.lastIndexOf('__', 0) === 0)\n );\n });\n if (skip) {\n return;\n }\n\n // If this SelectionSet is @export-ed as an input variable, it should\n // not have a __typename field (see issue #4691).\n const field = parent as FieldNode;\n if (\n isField(field) &&\n field.directives &&\n field.directives.some(d => d.name.value === 'export')\n ) {\n return;\n }\n\n // Create and return a new SelectionSet with a __typename Field.\n return {\n ...node,\n selections: [...selections, TYPENAME_FIELD],\n };\n },\n },\n });\n}, {\n added(field: FieldNode): boolean {\n return field === TYPENAME_FIELD;\n },\n});\n\nconst connectionRemoveConfig = {\n test: (directive: DirectiveNode) => {\n const willRemove = directive.name.value === 'connection';\n if (willRemove) {\n if (\n !directive.arguments ||\n !directive.arguments.some(arg => arg.name.value === 'key')\n ) {\n invariant.warn(\n 'Removing an @connection directive even though it does not have a key. ' +\n 'You may want to use the key parameter to specify a store key.',\n );\n }\n }\n\n return willRemove;\n },\n};\n\nexport function removeConnectionDirectiveFromDocument(doc: DocumentNode) {\n return removeDirectivesFromDocument(\n [connectionRemoveConfig],\n checkDocument(doc),\n );\n}\n\nfunction hasDirectivesInSelectionSet(\n directives: GetDirectiveConfig[],\n selectionSet: SelectionSetNode | undefined,\n nestedCheck = true,\n): boolean {\n return (\n !!selectionSet &&\n selectionSet.selections &&\n selectionSet.selections.some(selection =>\n hasDirectivesInSelection(directives, selection, nestedCheck),\n )\n );\n}\n\nfunction hasDirectivesInSelection(\n directives: GetDirectiveConfig[],\n selection: SelectionNode,\n nestedCheck = true,\n): boolean {\n if (!isField(selection)) {\n return true;\n }\n\n if (!selection.directives) {\n return false;\n }\n\n return (\n selection.directives.some(getDirectiveMatcher(directives)) ||\n (nestedCheck &&\n hasDirectivesInSelectionSet(\n directives,\n selection.selectionSet,\n nestedCheck,\n ))\n );\n}\n\nfunction getArgumentMatcher(config: RemoveArgumentsConfig[]) {\n return function argumentMatcher(argument: ArgumentNode) {\n return config.some(\n (aConfig: RemoveArgumentsConfig) =>\n argument.value &&\n argument.value.kind === 'Variable' &&\n argument.value.name &&\n (aConfig.name === argument.value.name.value ||\n (aConfig.test && aConfig.test(argument))),\n );\n };\n}\n\nexport function removeArgumentsFromDocument(\n config: RemoveArgumentsConfig[],\n doc: DocumentNode,\n): DocumentNode | null {\n const argMatcher = getArgumentMatcher(config);\n\n return nullIfDocIsEmpty(\n visit(doc, {\n OperationDefinition: {\n enter(node) {\n return {\n ...node,\n // Remove matching top level variables definitions.\n variableDefinitions: node.variableDefinitions ? node.variableDefinitions.filter(\n varDef =>\n !config.some(arg => arg.name === varDef.variable.name.value),\n ) : [],\n };\n },\n },\n\n Field: {\n enter(node) {\n // If `remove` is set to true for an argument, and an argument match\n // is found for a field, remove the field as well.\n const shouldRemoveField = config.some(argConfig => argConfig.remove);\n\n if (shouldRemoveField) {\n let argMatchCount = 0;\n if (node.arguments) {\n node.arguments.forEach(arg => {\n if (argMatcher(arg)) {\n argMatchCount += 1;\n }\n });\n }\n\n if (argMatchCount === 1) {\n return null;\n }\n }\n },\n },\n\n Argument: {\n enter(node) {\n // Remove all matching arguments.\n if (argMatcher(node)) {\n return null;\n }\n },\n },\n }),\n );\n}\n\nexport function removeFragmentSpreadFromDocument(\n config: RemoveFragmentSpreadConfig[],\n doc: DocumentNode,\n): DocumentNode | null {\n function enter(\n node: FragmentSpreadNode | FragmentDefinitionNode,\n ): null | void {\n if (config.some(def => def.name === node.name.value)) {\n return null;\n }\n }\n\n return nullIfDocIsEmpty(\n visit(doc, {\n FragmentSpread: { enter },\n FragmentDefinition: { enter },\n }),\n );\n}\n\nfunction getAllFragmentSpreadsFromSelectionSet(\n selectionSet: SelectionSetNode,\n): FragmentSpreadNode[] {\n const allFragments: FragmentSpreadNode[] = [];\n\n selectionSet.selections.forEach(selection => {\n if (\n (isField(selection) || isInlineFragment(selection)) &&\n selection.selectionSet\n ) {\n getAllFragmentSpreadsFromSelectionSet(selection.selectionSet).forEach(\n frag => allFragments.push(frag),\n );\n } else if (selection.kind === 'FragmentSpread') {\n allFragments.push(selection);\n }\n });\n\n return allFragments;\n}\n\n// If the incoming document is a query, return it as is. Otherwise, build a\n// new document containing a query operation based on the selection set\n// of the previous main operation.\nexport function buildQueryFromSelectionSet(\n document: DocumentNode,\n): DocumentNode {\n const definition = getMainDefinition(document);\n const definitionOperation = (<OperationDefinitionNode>definition).operation;\n\n if (definitionOperation === 'query') {\n // Already a query, so return the existing document.\n return document;\n }\n\n // Build a new query using the selection set of the main operation.\n const modifiedDoc = visit(document, {\n OperationDefinition: {\n enter(node) {\n return {\n ...node,\n operation: 'query',\n };\n },\n },\n });\n return modifiedDoc;\n}\n\n// Remove fields / selection sets that include an @client directive.\nexport function removeClientSetsFromDocument(\n document: DocumentNode,\n): DocumentNode | null {\n checkDocument(document);\n\n let modifiedDoc = removeDirectivesFromDocument(\n [\n {\n test: (directive: DirectiveNode) => directive.name.value === 'client',\n remove: true,\n },\n ],\n document,\n );\n\n // After a fragment definition has had its @client related document\n // sets removed, if the only field it has left is a __typename field,\n // remove the entire fragment operation to prevent it from being fired\n // on the server.\n if (modifiedDoc) {\n modifiedDoc = visit(modifiedDoc, {\n FragmentDefinition: {\n enter(node) {\n if (node.selectionSet) {\n const isTypenameOnly = node.selectionSet.selections.every(\n selection =>\n isField(selection) && selection.name.value === '__typename',\n );\n if (isTypenameOnly) {\n return null;\n }\n }\n },\n },\n });\n }\n\n return modifiedDoc;\n}\n"]}
1
+ {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/utilities/graphql/transform.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,CAAC,UAAU,CAAC,KAAK,CACvD,UAAA,SAAS;4BACP,OAAA,OAAO,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,KAAK,YAAY;wBAA3D,CAA2D,CAC9D,CAAC;wBACF,IAAI,cAAc,EAAE;4BAClB,OAAO,IAAI,CAAC;yBACb;qBACF;gBACH,CAAC;aACF;SACF,CAAC,CAAC;KACJ;IAED,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { invariant } from '../globals';\n\nimport {\n DocumentNode,\n SelectionNode,\n SelectionSetNode,\n OperationDefinitionNode,\n FieldNode,\n DirectiveNode,\n FragmentDefinitionNode,\n ArgumentNode,\n FragmentSpreadNode,\n VariableDefinitionNode,\n VariableNode,\n visit,\n ASTNode,\n} from 'graphql';\n\n// TODO(brian): A hack until this issue is resolved (https://github.com/graphql/graphql-js/issues/3356)\ntype Kind = any;\n\nimport {\n checkDocument,\n getOperationDefinition,\n getFragmentDefinition,\n getFragmentDefinitions,\n getMainDefinition,\n} from './getFromAST';\nimport { filterInPlace } from '../common/filterInPlace';\nimport { isField, isInlineFragment } from './storeUtils';\nimport {\n createFragmentMap,\n FragmentMap,\n} from './fragments';\n\nexport type RemoveNodeConfig<N> = {\n name?: string;\n test?: (node: N) => boolean;\n remove?: boolean;\n};\n\nexport type GetNodeConfig<N> = {\n name?: string;\n test?: (node: N) => boolean;\n};\n\nexport type RemoveDirectiveConfig = RemoveNodeConfig<DirectiveNode>;\nexport type GetDirectiveConfig = GetNodeConfig<DirectiveNode>;\nexport type RemoveArgumentsConfig = RemoveNodeConfig<ArgumentNode>;\nexport type GetFragmentSpreadConfig = GetNodeConfig<FragmentSpreadNode>;\nexport type RemoveFragmentSpreadConfig = RemoveNodeConfig<FragmentSpreadNode>;\nexport type RemoveFragmentDefinitionConfig = RemoveNodeConfig<\n FragmentDefinitionNode\n>;\nexport type RemoveVariableDefinitionConfig = RemoveNodeConfig<\n VariableDefinitionNode\n>;\n\nconst TYPENAME_FIELD: FieldNode = {\n kind: 'Field' as Kind,\n name: {\n kind: 'Name' as Kind,\n value: '__typename',\n },\n};\n\nfunction isEmpty(\n op: OperationDefinitionNode | FragmentDefinitionNode,\n fragments: FragmentMap,\n): boolean {\n return op.selectionSet.selections.every(\n selection =>\n selection.kind === 'FragmentSpread' &&\n isEmpty(fragments[selection.name.value], fragments),\n );\n}\n\nfunction nullIfDocIsEmpty(doc: DocumentNode) {\n return isEmpty(\n getOperationDefinition(doc) || getFragmentDefinition(doc),\n createFragmentMap(getFragmentDefinitions(doc)),\n )\n ? null\n : doc;\n}\n\nfunction getDirectiveMatcher(\n directives: (RemoveDirectiveConfig | GetDirectiveConfig)[],\n) {\n return function directiveMatcher(directive: DirectiveNode) {\n return directives.some(\n dir =>\n (dir.name && dir.name === directive.name.value) ||\n (dir.test && dir.test(directive)),\n );\n };\n}\n\nexport function removeDirectivesFromDocument(\n directives: RemoveDirectiveConfig[],\n doc: DocumentNode,\n): DocumentNode | null {\n const variablesInUse: Record<string, boolean> = Object.create(null);\n let variablesToRemove: RemoveArgumentsConfig[] = [];\n\n const fragmentSpreadsInUse: Record<string, boolean> = Object.create(null);\n let fragmentSpreadsToRemove: RemoveFragmentSpreadConfig[] = [];\n\n let modifiedDoc = nullIfDocIsEmpty(\n visit(doc, {\n Variable: {\n enter(node, _key, parent) {\n // Store each variable that's referenced as part of an argument\n // (excluding operation definition variables), so we know which\n // variables are being used. If we later want to remove a variable\n // we'll first check to see if it's being used, before continuing with\n // the removal.\n if (\n (parent as VariableDefinitionNode).kind !== 'VariableDefinition'\n ) {\n variablesInUse[node.name.value] = true;\n }\n },\n },\n\n Field: {\n enter(node) {\n if (directives && node.directives) {\n // If `remove` is set to true for a directive, and a directive match\n // is found for a field, remove the field as well.\n const shouldRemoveField = directives.some(\n directive => directive.remove,\n );\n\n if (\n shouldRemoveField &&\n node.directives &&\n node.directives.some(getDirectiveMatcher(directives))\n ) {\n if (node.arguments) {\n // Store field argument variables so they can be removed\n // from the operation definition.\n node.arguments.forEach(arg => {\n if (arg.value.kind === 'Variable') {\n variablesToRemove.push({\n name: (arg.value as VariableNode).name.value,\n });\n }\n });\n }\n\n if (node.selectionSet) {\n // Store fragment spread names so they can be removed from the\n // document.\n getAllFragmentSpreadsFromSelectionSet(node.selectionSet).forEach(\n frag => {\n fragmentSpreadsToRemove.push({\n name: frag.name.value,\n });\n },\n );\n }\n\n // Remove the field.\n return null;\n }\n }\n },\n },\n\n FragmentSpread: {\n enter(node) {\n // Keep track of referenced fragment spreads. This is used to\n // determine if top level fragment definitions should be removed.\n fragmentSpreadsInUse[node.name.value] = true;\n },\n },\n\n Directive: {\n enter(node) {\n // If a matching directive is found, remove it.\n if (getDirectiveMatcher(directives)(node)) {\n return null;\n }\n },\n },\n }),\n );\n\n // If we've removed fields with arguments, make sure the associated\n // variables are also removed from the rest of the document, as long as they\n // aren't being used elsewhere.\n if (\n modifiedDoc &&\n filterInPlace(variablesToRemove, v => !!v.name && !variablesInUse[v.name]).length\n ) {\n modifiedDoc = removeArgumentsFromDocument(variablesToRemove, modifiedDoc);\n }\n\n // If we've removed selection sets with fragment spreads, make sure the\n // associated fragment definitions are also removed from the rest of the\n // document, as long as they aren't being used elsewhere.\n if (\n modifiedDoc &&\n filterInPlace(fragmentSpreadsToRemove, fs => !!fs.name && !fragmentSpreadsInUse[fs.name])\n .length\n ) {\n modifiedDoc = removeFragmentSpreadFromDocument(\n fragmentSpreadsToRemove,\n modifiedDoc,\n );\n }\n\n return modifiedDoc;\n}\n\nexport const addTypenameToDocument = Object.assign(function <\n TNode extends ASTNode\n>(\n doc: TNode\n): TNode {\n return visit(doc, {\n SelectionSet: {\n enter(node, _key, parent) {\n // Don't add __typename to OperationDefinitions.\n if (\n parent &&\n (parent as OperationDefinitionNode).kind === 'OperationDefinition'\n ) {\n return;\n }\n\n // No changes if no selections.\n const { selections } = node;\n if (!selections) {\n return;\n }\n\n // If selections already have a __typename, or are part of an\n // introspection query, do nothing.\n const skip = selections.some(selection => {\n return (\n isField(selection) &&\n (selection.name.value === '__typename' ||\n selection.name.value.lastIndexOf('__', 0) === 0)\n );\n });\n if (skip) {\n return;\n }\n\n // If this SelectionSet is @export-ed as an input variable, it should\n // not have a __typename field (see issue #4691).\n const field = parent as FieldNode;\n if (\n isField(field) &&\n field.directives &&\n field.directives.some(d => d.name.value === 'export')\n ) {\n return;\n }\n\n // Create and return a new SelectionSet with a __typename Field.\n return {\n ...node,\n selections: [...selections, TYPENAME_FIELD],\n };\n },\n },\n });\n}, {\n added(field: FieldNode): boolean {\n return field === TYPENAME_FIELD;\n },\n});\n\nconst connectionRemoveConfig = {\n test: (directive: DirectiveNode) => {\n const willRemove = directive.name.value === 'connection';\n if (willRemove) {\n if (\n !directive.arguments ||\n !directive.arguments.some(arg => arg.name.value === 'key')\n ) {\n invariant.warn(\n 'Removing an @connection directive even though it does not have a key. ' +\n 'You may want to use the key parameter to specify a store key.',\n );\n }\n }\n\n return willRemove;\n },\n};\n\nexport function removeConnectionDirectiveFromDocument(doc: DocumentNode) {\n return removeDirectivesFromDocument(\n [connectionRemoveConfig],\n checkDocument(doc),\n );\n}\n\nfunction hasDirectivesInSelectionSet(\n directives: GetDirectiveConfig[],\n selectionSet: SelectionSetNode | undefined,\n nestedCheck = true,\n): boolean {\n return (\n !!selectionSet &&\n selectionSet.selections &&\n selectionSet.selections.some(selection =>\n hasDirectivesInSelection(directives, selection, nestedCheck),\n )\n );\n}\n\nfunction hasDirectivesInSelection(\n directives: GetDirectiveConfig[],\n selection: SelectionNode,\n nestedCheck = true,\n): boolean {\n if (!isField(selection)) {\n return true;\n }\n\n if (!selection.directives) {\n return false;\n }\n\n return (\n selection.directives.some(getDirectiveMatcher(directives)) ||\n (nestedCheck &&\n hasDirectivesInSelectionSet(\n directives,\n selection.selectionSet,\n nestedCheck,\n ))\n );\n}\n\nfunction getArgumentMatcher(config: RemoveArgumentsConfig[]) {\n return function argumentMatcher(argument: ArgumentNode) {\n return config.some(\n (aConfig: RemoveArgumentsConfig) =>\n argument.value &&\n argument.value.kind === 'Variable' &&\n argument.value.name &&\n (aConfig.name === argument.value.name.value ||\n (aConfig.test && aConfig.test(argument))),\n );\n };\n}\n\nexport function removeArgumentsFromDocument(\n config: RemoveArgumentsConfig[],\n doc: DocumentNode,\n): DocumentNode | null {\n const argMatcher = getArgumentMatcher(config);\n\n return nullIfDocIsEmpty(\n visit(doc, {\n OperationDefinition: {\n enter(node) {\n return {\n ...node,\n // Remove matching top level variables definitions.\n variableDefinitions: node.variableDefinitions ? node.variableDefinitions.filter(\n varDef =>\n !config.some(arg => arg.name === varDef.variable.name.value),\n ) : [],\n };\n },\n },\n\n Field: {\n enter(node) {\n // If `remove` is set to true for an argument, and an argument match\n // is found for a field, remove the field as well.\n const shouldRemoveField = config.some(argConfig => argConfig.remove);\n\n if (shouldRemoveField) {\n let argMatchCount = 0;\n if (node.arguments) {\n node.arguments.forEach(arg => {\n if (argMatcher(arg)) {\n argMatchCount += 1;\n }\n });\n }\n\n if (argMatchCount === 1) {\n return null;\n }\n }\n },\n },\n\n Argument: {\n enter(node) {\n // Remove all matching arguments.\n if (argMatcher(node)) {\n return null;\n }\n },\n },\n }),\n );\n}\n\nexport function removeFragmentSpreadFromDocument(\n config: RemoveFragmentSpreadConfig[],\n doc: DocumentNode,\n): DocumentNode | null {\n function enter(\n node: FragmentSpreadNode | FragmentDefinitionNode,\n ): null | void {\n if (config.some(def => def.name === node.name.value)) {\n return null;\n }\n }\n\n return nullIfDocIsEmpty(\n visit(doc, {\n FragmentSpread: { enter },\n FragmentDefinition: { enter },\n }),\n );\n}\n\nfunction getAllFragmentSpreadsFromSelectionSet(\n selectionSet: SelectionSetNode,\n): FragmentSpreadNode[] {\n const allFragments: FragmentSpreadNode[] = [];\n\n selectionSet.selections.forEach(selection => {\n if (\n (isField(selection) || isInlineFragment(selection)) &&\n selection.selectionSet\n ) {\n getAllFragmentSpreadsFromSelectionSet(selection.selectionSet).forEach(\n frag => allFragments.push(frag),\n );\n } else if (selection.kind === 'FragmentSpread') {\n allFragments.push(selection);\n }\n });\n\n return allFragments;\n}\n\n// If the incoming document is a query, return it as is. Otherwise, build a\n// new document containing a query operation based on the selection set\n// of the previous main operation.\nexport function buildQueryFromSelectionSet(\n document: DocumentNode,\n): DocumentNode {\n const definition = getMainDefinition(document);\n const definitionOperation = (<OperationDefinitionNode>definition).operation;\n\n if (definitionOperation === 'query') {\n // Already a query, so return the existing document.\n return document;\n }\n\n // Build a new query using the selection set of the main operation.\n const modifiedDoc = visit(document, {\n OperationDefinition: {\n enter(node) {\n return {\n ...node,\n operation: 'query',\n };\n },\n },\n });\n return modifiedDoc;\n}\n\n// Remove fields / selection sets that include an @client directive.\nexport function removeClientSetsFromDocument(\n document: DocumentNode,\n): DocumentNode | null {\n checkDocument(document);\n\n let modifiedDoc = removeDirectivesFromDocument(\n [\n {\n test: (directive: DirectiveNode) => directive.name.value === 'client',\n remove: true,\n },\n ],\n document,\n );\n\n // After a fragment definition has had its @client related document\n // sets removed, if the only field it has left is a __typename field,\n // remove the entire fragment operation to prevent it from being fired\n // on the server.\n if (modifiedDoc) {\n modifiedDoc = visit(modifiedDoc, {\n FragmentDefinition: {\n enter(node) {\n if (node.selectionSet) {\n const isTypenameOnly = node.selectionSet.selections.every(\n selection =>\n isField(selection) && selection.name.value === '__typename',\n );\n if (isTypenameOnly) {\n return null;\n }\n }\n },\n },\n });\n }\n\n return modifiedDoc;\n}\n"]}
@@ -20,5 +20,6 @@ export * from './common/canUse';
20
20
  export * from './common/compact';
21
21
  export * from './common/makeUniqueId';
22
22
  export * from './common/stringifyForDisplay';
23
+ export * from './common/mergeOptions';
23
24
  export * from './types/IsStrictlyAny';
24
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,OA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iB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAE7C,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,WAAW,EACX,SAAS,EACT,UAAU,EACV,UAAU,EACV,aAAa,EACb,aAAa,EACb,cAAc,EACd,WAAW,EACX,OAAO,EACP,gBAAgB,EAChB,2BAA2B,EAC3B,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,eAAe,EACf,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,8BAA8B,EAC9B,8BAA8B,EAC9B,qBAAqB,EACrB,0BAA0B,EAC1B,4BAA4B,EAC5B,qCAAqC,EACrC,2BAA2B,EAC3B,gCAAgC,EAChC,4BAA4B,GAC7B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,UAAU,EACV,QAAQ,EACR,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAElC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AAEtC,cAAc,uBAAuB,CAAC"}
@@ -20,5 +20,6 @@ export * from "./common/canUse.js";
20
20
  export * from "./common/compact.js";
21
21
  export * from "./common/makeUniqueId.js";
22
22
  export * from "./common/stringifyForDisplay.js";
23
+ export * from "./common/mergeOptions.js";
23
24
  export * from "./types/IsStrictlyAny.js";
24
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAGL,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEL,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAML,aAAa,EACb,cAAc,EACd,WAAW,EACX,OAAO,EACP,gBAAgB,EAChB,2BAA2B,EAC3B,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,eAAe,EACf,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAUL,qBAAqB,EACrB,0BAA0B,EAC1B,4BAA4B,EAC5B,qCAAqC,EACrC,2BAA2B,EAC3B,gCAAgC,EAChC,4BAA4B,GAC7B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,UAAU,EAGX,MAAM,0BAA0B,CAAC;AAElC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAE7C,cAAc,uBAAuB,CAAC","sourcesContent":["export { DEV, maybe } from './globals';\n\nexport {\n DirectiveInfo,\n InclusionDirectives,\n shouldInclude,\n hasDirectives,\n hasClientExports,\n getDirectiveNames,\n getInclusionDirectives,\n} from './graphql/directives';\n\nexport {\n FragmentMap,\n createFragmentMap,\n getFragmentQueryDocument,\n getFragmentFromSelection,\n} from './graphql/fragments';\n\nexport {\n checkDocument,\n getOperationDefinition,\n getOperationName,\n getFragmentDefinitions,\n getQueryDefinition,\n getFragmentDefinition,\n getMainDefinition,\n getDefaultValues,\n} from './graphql/getFromAST';\n\nexport {\n StoreObject,\n Reference,\n StoreValue,\n Directives,\n VariableValue,\n makeReference,\n isDocumentNode,\n isReference,\n isField,\n isInlineFragment,\n valueToObjectRepresentation,\n storeKeyNameFromField,\n argumentsObjectFromField,\n resultKeyNameFromField,\n getStoreKeyName,\n getTypenameFromResult,\n} from './graphql/storeUtils';\n\nexport {\n RemoveNodeConfig,\n GetNodeConfig,\n RemoveDirectiveConfig,\n GetDirectiveConfig,\n RemoveArgumentsConfig,\n GetFragmentSpreadConfig,\n RemoveFragmentSpreadConfig,\n RemoveFragmentDefinitionConfig,\n RemoveVariableDefinitionConfig,\n addTypenameToDocument,\n buildQueryFromSelectionSet,\n removeDirectivesFromDocument,\n removeConnectionDirectiveFromDocument,\n removeArgumentsFromDocument,\n removeFragmentSpreadFromDocument,\n removeClientSetsFromDocument,\n} from './graphql/transform';\n\nexport {\n concatPagination,\n offsetLimitPagination,\n relayStylePagination,\n} from './policies/pagination';\n\nexport {\n Observable,\n Observer,\n ObservableSubscription\n} from './observables/Observable';\n\nexport * from './common/mergeDeep';\nexport * from './common/cloneDeep';\nexport * from './common/maybeDeepFreeze';\nexport * from './observables/iteration';\nexport * from './observables/asyncMap';\nexport * from './observables/Concast';\nexport * from './observables/subclassing';\nexport * from './common/arrays';\nexport * from './common/objects';\nexport * from './common/errorHandling';\nexport * from './common/canUse';\nexport * from './common/compact';\nexport * from './common/makeUniqueId';\nexport * from './common/stringifyForDisplay';\n\nexport * from './types/IsStrictlyAny';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAGL,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEL,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAML,aAAa,EACb,cAAc,EACd,WAAW,EACX,OAAO,EACP,gBAAgB,EAChB,2BAA2B,EAC3B,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,eAAe,EACf,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAUL,qBAAqB,EACrB,0BAA0B,EAC1B,4BAA4B,EAC5B,qCAAqC,EACrC,2BAA2B,EAC3B,gCAAgC,EAChC,4BAA4B,GAC7B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,UAAU,EAGX,MAAM,0BAA0B,CAAC;AAElC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AAEtC,cAAc,uBAAuB,CAAC","sourcesContent":["export { DEV, maybe } from './globals';\n\nexport {\n DirectiveInfo,\n InclusionDirectives,\n shouldInclude,\n hasDirectives,\n hasClientExports,\n getDirectiveNames,\n getInclusionDirectives,\n} from './graphql/directives';\n\nexport {\n FragmentMap,\n createFragmentMap,\n getFragmentQueryDocument,\n getFragmentFromSelection,\n} from './graphql/fragments';\n\nexport {\n checkDocument,\n getOperationDefinition,\n getOperationName,\n getFragmentDefinitions,\n getQueryDefinition,\n getFragmentDefinition,\n getMainDefinition,\n getDefaultValues,\n} from './graphql/getFromAST';\n\nexport {\n StoreObject,\n Reference,\n StoreValue,\n Directives,\n VariableValue,\n makeReference,\n isDocumentNode,\n isReference,\n isField,\n isInlineFragment,\n valueToObjectRepresentation,\n storeKeyNameFromField,\n argumentsObjectFromField,\n resultKeyNameFromField,\n getStoreKeyName,\n getTypenameFromResult,\n} from './graphql/storeUtils';\n\nexport {\n RemoveNodeConfig,\n GetNodeConfig,\n RemoveDirectiveConfig,\n GetDirectiveConfig,\n RemoveArgumentsConfig,\n GetFragmentSpreadConfig,\n RemoveFragmentSpreadConfig,\n RemoveFragmentDefinitionConfig,\n RemoveVariableDefinitionConfig,\n addTypenameToDocument,\n buildQueryFromSelectionSet,\n removeDirectivesFromDocument,\n removeConnectionDirectiveFromDocument,\n removeArgumentsFromDocument,\n removeFragmentSpreadFromDocument,\n removeClientSetsFromDocument,\n} from './graphql/transform';\n\nexport {\n concatPagination,\n offsetLimitPagination,\n relayStylePagination,\n} from './policies/pagination';\n\nexport {\n Observable,\n Observer,\n ObservableSubscription\n} from './observables/Observable';\n\nexport * from './common/mergeDeep';\nexport * from './common/cloneDeep';\nexport * from './common/maybeDeepFreeze';\nexport * from './observables/iteration';\nexport * from './observables/asyncMap';\nexport * from './observables/Concast';\nexport * from './observables/subclassing';\nexport * from './common/arrays';\nexport * from './common/objects';\nexport * from './common/errorHandling';\nexport * from './common/canUse';\nexport * from './common/compact';\nexport * from './common/makeUniqueId';\nexport * from './common/stringifyForDisplay';\nexport * from './common/mergeOptions';\n\nexport * from './types/IsStrictlyAny';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Concast.d.ts","sourceRoot":"","sources":["../../../src/utilities/observables/Concast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAA0B,UAAU,EAAE,M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,CAAC,CAAC,CAAC;AAOxC,aAAK,MAAM,CAAC,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3C,oBAAY,sBAAsB,CAAC,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AA+B5D,qBAAa,OAAO,CAAC,CAAC,CAAE,SAAQ,UAAU,CAAC,CAAC,CAAC;IAI3C,OAAO,CAAC,SAAS,CAA0B;IAM3C,OAAO,CAAC,GAAG,CAAC,CAAgC;gBAIhC,OAAO,EAAE,UAAU,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IA8B1E,OAAO,CAAC,OAAO,CAAc;IAE7B,OAAO,CAAC,KAAK;IAeb,OAAO,CAAC,kBAAkB;IAmB1B,OAAO,CAAC,QAAQ,CAAK;IAEd,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IAUjC,cAAc,CACnB,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EACrB,OAAO,CAAC,EAAE,OAAO;IAenB,OAAO,CAAC,OAAO,CAAwC;IACvD,OAAO,CAAC,MAAM,CAAwB;IACtC,SAAgB,OAAO,aAGpB;IAIH,OAAO,CAAC,MAAM,CAAC,CAA0B;IAIzC,OAAO,CAAC,QAAQ,CAiDd;IAEK,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG;IA0B3B,MAAM,WAAY,GAAG,UAI3B;CACF"}
@@ -37,9 +37,12 @@ var Concast = (function (_super) {
37
37
  }
38
38
  },
39
39
  complete: function () {
40
- if (_this.sub !== null) {
40
+ var sub = _this.sub;
41
+ if (sub !== null) {
41
42
  var value = _this.sources.shift();
42
43
  if (!value) {
44
+ if (sub)
45
+ setTimeout(function () { return sub.unsubscribe(); });
43
46
  _this.sub = null;
44
47
  if (_this.latest &&
45
48
  _this.latest[0] === "next") {
@@ -107,7 +110,7 @@ var Concast = (function (_super) {
107
110
  if (this.observers.delete(observer) &&
108
111
  --this.addCount < 1 &&
109
112
  !quietly) {
110
- this.handlers.error(new Error("Observable cancelled prematurely"));
113
+ this.handlers.complete();
111
114
  }
112
115
  };
113
116
  Concast.prototype.cleanup = function (callback) {
@@ -1 +1 @@
1
- {"version":3,"file":"Concast.js","sourceRoot":"","sources":["../../../src/utilities/observables/Concast.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAgD,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAItD,SAAS,aAAa,CAAI,KAAoB;IAC5C,OAAO,KAAK,IAAI,OAAQ,KAAa,CAAC,IAAI,KAAK,UAAU,CAAC;AAC5D,CAAC;AAoCD;IAAgC,2BAAa;IAc3C,iBAAY,OAA8D;QAA1E,YACE,kBAAM,UAAA,QAAQ;YACZ,KAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAC3B,OAAO,cAAM,OAAA,KAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAA7B,CAA6B,CAAC;QAC7C,CAAC,CAAC,SAsBH;QApCO,eAAS,GAAG,IAAI,GAAG,EAAe,CAAC;QA4EnC,cAAQ,GAAG,CAAC,CAAC;QA+BL,aAAO,GAAG,IAAI,OAAO,CAAI,UAAC,OAAO,EAAE,MAAM;YACvD,KAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACvB,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACvB,CAAC,CAAC,CAAC;QAQK,cAAQ,GAAG;YACjB,IAAI,EAAE,UAAC,MAAS;gBACd,IAAI,KAAI,CAAC,GAAG,KAAK,IAAI,EAAE;oBACrB,KAAI,CAAC,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;oBAC/B,sBAAsB,CAAC,KAAI,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,CA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AC5B,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAI3B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;IACxB,CAAC;IAQH,cAAC;AAAD,CAAC,AA1MD,CAAgC,UAAU,GA0MzC;;AAID,qBAAqB,CAAC,OAAO,CAAC,CAAC","sourcesContent":["import { Observable, Observer, ObservableSubscription, Subscriber } from \"./Observable\";\nimport { iterateObserversSafely } from \"./iteration\";\nimport { fixObservableSubclass } from \"./subclassing\";\n\ntype MaybeAsync<T> = T | PromiseLike<T>;\n\nfunction isPromiseLike<T>(value: MaybeAsync<T>): value is PromiseLike<T> {\n return value && typeof (value as any).then === \"function\";\n}\n\n// Any individual Source<T> can be an Observable<T> or a promise for one.\ntype Source<T> = MaybeAsync<Observable<T>>;\n\nexport type ConcastSourcesIterable<T> = Iterable<Source<T>>;\n\n// A Concast<T> observable concatenates the given sources into a single\n// non-overlapping sequence of Ts, automatically unwrapping any promises,\n// and broadcasts the T elements of that sequence to any number of\n// subscribers, all without creating a bunch of intermediary Observable\n// wrapper objects.\n//\n// Even though any number of observers can subscribe to the Concast, each\n// source observable is guaranteed to receive at most one subscribe call,\n// and the results are multicast to all observers.\n//\n// In addition to broadcasting every next/error message to this.observers,\n// the Concast stores the most recent message using this.latest, so any\n// new observers can immediately receive the latest message, even if it\n// was originally delivered in the past. This behavior means we can assume\n// every active observer in this.observers has received the same most\n// recent message.\n//\n// With the exception of this.latest replay, a Concast is a \"hot\"\n// observable in the sense that it does not replay past results from the\n// beginning of time for each new observer.\n//\n// Could we have used some existing RxJS class instead? Concast<T> is\n// similar to a BehaviorSubject<T>, because it is multicast and redelivers\n// the latest next/error message to new subscribers. Unlike Subject<T>,\n// Concast<T> does not expose an Observer<T> interface (this.handlers is\n// intentionally private), since Concast<T> gets its inputs from the\n// concatenated sources. If we ever switch to RxJS, there may be some\n// value in reusing their code, but for now we use zen-observable, which\n// does not contain any Subject implementations.\nexport class Concast<T> extends Observable<T> {\n // Active observers receiving broadcast messages. Thanks to this.latest,\n // we can assume all observers in this Set have received the same most\n // recent message, though possibly at different times in the past.\n private observers = new Set<Observer<T>>();\n\n // This property starts off undefined to indicate the initial\n // subscription has not yet begun, then points to each source\n // subscription in turn, and finally becomes null after the sources have\n // been exhausted. After that, it stays null.\n private sub?: ObservableSubscription | null;\n\n // Not only can the individual elements of the iterable be promises, but\n // also the iterable itself can be wrapped in a promise.\n constructor(sources: MaybeAsync<ConcastSourcesIterable<T>> | Subscriber<T>) {\n super(observer => {\n this.addObserver(observer);\n return () => this.removeObserver(observer);\n });\n\n // Suppress rejection warnings for this.promise, since it's perfectly\n // acceptable to pay no attention to this.promise if you're consuming\n // the results through the normal observable API.\n this.promise.catch(_ => {});\n\n // If someone accidentally tries to create a Concast using a subscriber\n // function, recover by creating an Observable from that subscriber and\n // using it as the source.\n if (typeof sources === \"function\") {\n sources = [new Observable(sources)];\n }\n\n if (isPromiseLike(sources)) {\n sources.then(\n iterable => this.start(iterable),\n this.handlers.error,\n );\n } else {\n this.start(sources);\n }\n }\n\n // A consumable array of source observables, incrementally consumed\n // each time this.handlers.complete is called.\n private sources: Source<T>[];\n\n private start(sources: ConcastSourcesIterable<T>) {\n if (this.sub !== void 0) return;\n\n // In practice, sources is most often simply an Array of observables.\n // TODO Consider using sources[Symbol.iterator]() to take advantage\n // of the laziness of non-Array iterables.\n this.sources = Array.from(sources);\n\n // Calling this.handlers.complete() kicks off consumption of the first\n // source observable. It's tempting to do this step lazily in\n // addObserver, but this.promise can be accessed without calling\n // addObserver, so consumption needs to begin eagerly.\n this.handlers.complete();\n }\n\n private deliverLastMessage(observer: Observer<T>) {\n if (this.latest) {\n const nextOrError = this.latest[0];\n const method = observer[nextOrError];\n if (method) {\n method.call(observer, this.latest[1]);\n }\n // If the subscription is already closed, and the last message was\n // a 'next' message, simulate delivery of the final 'complete'\n // message again.\n if (this.sub === null &&\n nextOrError === \"next\" &&\n observer.complete) {\n observer.complete();\n }\n }\n }\n\n // Note: cleanup observers do not count towards this total.\n private addCount = 0;\n\n public addObserver(observer: Observer<T>) {\n if (!this.observers.has(observer)) {\n // Immediately deliver the most recent message, so we can always\n // be sure all observers have the latest information.\n this.deliverLastMessage(observer);\n this.observers.add(observer);\n ++this.addCount;\n }\n }\n\n public removeObserver(\n observer: Observer<T>,\n quietly?: boolean,\n ) {\n if (this.observers.delete(observer) &&\n --this.addCount < 1 &&\n !quietly) {\n // In case there are still any cleanup observers in this.observers,\n // and no error or completion has been broadcast yet, make sure\n // those observers receive an error that terminates them.\n this.handlers.error(new Error(\"Observable cancelled prematurely\"));\n }\n }\n\n // Any Concast object can be trivially converted to a Promise, without\n // having to create a new wrapper Observable. This promise provides an\n // easy way to observe the final state of the Concast.\n private resolve: (result?: T | PromiseLike<T>) => void;\n private reject: (reason: any) => void;\n public readonly promise = new Promise<T>((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n\n // Name and argument of the most recently invoked observer method, used\n // to deliver latest results immediately to new observers.\n private latest?: [\"next\" | \"error\", any];\n\n // Bound handler functions that can be reused for every internal\n // subscription.\n private handlers = {\n next: (result: T) => {\n if (this.sub !== null) {\n this.latest = [\"next\", result];\n iterateObserversSafely(this.observers, \"next\", result);\n }\n },\n\n error: (error: any) => {\n const { sub } = this;\n if (sub !== null) {\n // Delay unsubscribing from the underlying subscription slightly,\n // so that immediately subscribing another observer can keep the\n // subscription active.\n if (sub) setTimeout(() => sub.unsubscribe());\n this.sub = null;\n this.latest = [\"error\", error];\n this.reject(error);\n iterateObserversSafely(this.observers, \"error\", error);\n }\n },\n\n complete: () => {\n if (this.sub !== null) {\n const value = this.sources.shift();\n if (!value) {\n this.sub = null;\n if (this.latest &&\n this.latest[0] === \"next\") {\n this.resolve(this.latest[1]);\n } else {\n this.resolve();\n }\n // We do not store this.latest = [\"complete\"], because doing so\n // discards useful information about the previous next (or\n // error) message. Instead, if new observers subscribe after\n // this Concast has completed, they will receive the final\n // 'next' message (unless there was an error) immediately\n // followed by a 'complete' message (see addObserver).\n iterateObserversSafely(this.observers, \"complete\");\n } else if (isPromiseLike(value)) {\n value.then(obs => this.sub = obs.subscribe(this.handlers));\n } else {\n this.sub = value.subscribe(this.handlers);\n }\n }\n },\n };\n\n public cleanup(callback: () => any) {\n let called = false;\n const once = () => {\n if (!called) {\n called = true;\n // Removing a cleanup observer should not unsubscribe from the\n // underlying Observable, so the only removeObserver behavior we\n // need here is to delete observer from this.observers.\n this.observers.delete(observer);\n callback();\n }\n }\n const observer = {\n next: once,\n error: once,\n complete: once,\n };\n const count = this.addCount;\n this.addObserver(observer);\n // Normally addObserver increments this.addCount, but we can \"hide\"\n // cleanup observers by restoring this.addCount to its previous value\n // after adding any cleanup observer.\n this.addCount = count;\n }\n\n // A public way to abort observation and broadcast.\n public cancel = (reason: any) => {\n this.reject(reason);\n this.sources = [];\n this.handlers.complete();\n }\n}\n\n// Necessary because the Concast constructor has a different signature\n// than the Observable constructor.\nfixObservableSubclass(Concast);\n"]}
1
+ {"version":3,"file":"Concast.js","sourceRoot":"","sources":["../../../src/utilities/observables/Concast.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAgD,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAItD,SAAS,aAAa,CAAI,KAAoB;IAC5C,OAAO,KAAK,IAAI,OAAQ,KAAa,CAAC,IAAI,KAAK,UAAU,CAAC;AAC5D,CAAC;AAoCD;IAAgC,2BAAa;IAc3C,iBAAY,OAA8D;QAA1E,YACE,kBAAM,UAAA,QAAQ;YACZ,KAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAC3B,OAAO,cAAM,OAAA,KAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAA7B,CAA6B,CAAC;QAC7C,CAAC,CAAC,SAsBH;QApCO,eAAS,GAAG,IAAI,GAAG,EAAe,CAAC;QA4EnC,cA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ACnB,CAAC,OAAO,EAAE;YAIZ,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;SAC1B;IACH,CAAC;IAqEM,yBAAO,GAAd,UAAe,QAAmB;QAAlC,iBAuBC;QAtBC,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,IAAM,IAAI,GAAG;YACX,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,GAAG,IAAI,CAAC;gBAId,KAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAChC,QAAQ,EAAE,CAAC;aACZ;QACH,CAAC,CAAA;QACD,IAAM,QAAQ,GAAG;YACf,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,IAAI;YACX,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,IAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC5B,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAI3B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;IACxB,CAAC;IAQH,cAAC;AAAD,CAAC,AA5MD,CAAgC,UAAU,GA4MzC;;AAID,qBAAqB,CAAC,OAAO,CAAC,CAAC","sourcesContent":["import { Observable, Observer, ObservableSubscription, Subscriber } from \"./Observable\";\nimport { iterateObserversSafely } from \"./iteration\";\nimport { fixObservableSubclass } from \"./subclassing\";\n\ntype MaybeAsync<T> = T | PromiseLike<T>;\n\nfunction isPromiseLike<T>(value: MaybeAsync<T>): value is PromiseLike<T> {\n return value && typeof (value as any).then === \"function\";\n}\n\n// Any individual Source<T> can be an Observable<T> or a promise for one.\ntype Source<T> = MaybeAsync<Observable<T>>;\n\nexport type ConcastSourcesIterable<T> = Iterable<Source<T>>;\n\n// A Concast<T> observable concatenates the given sources into a single\n// non-overlapping sequence of Ts, automatically unwrapping any promises,\n// and broadcasts the T elements of that sequence to any number of\n// subscribers, all without creating a bunch of intermediary Observable\n// wrapper objects.\n//\n// Even though any number of observers can subscribe to the Concast, each\n// source observable is guaranteed to receive at most one subscribe call,\n// and the results are multicast to all observers.\n//\n// In addition to broadcasting every next/error message to this.observers,\n// the Concast stores the most recent message using this.latest, so any\n// new observers can immediately receive the latest message, even if it\n// was originally delivered in the past. This behavior means we can assume\n// every active observer in this.observers has received the same most\n// recent message.\n//\n// With the exception of this.latest replay, a Concast is a \"hot\"\n// observable in the sense that it does not replay past results from the\n// beginning of time for each new observer.\n//\n// Could we have used some existing RxJS class instead? Concast<T> is\n// similar to a BehaviorSubject<T>, because it is multicast and redelivers\n// the latest next/error message to new subscribers. Unlike Subject<T>,\n// Concast<T> does not expose an Observer<T> interface (this.handlers is\n// intentionally private), since Concast<T> gets its inputs from the\n// concatenated sources. If we ever switch to RxJS, there may be some\n// value in reusing their code, but for now we use zen-observable, which\n// does not contain any Subject implementations.\nexport class Concast<T> extends Observable<T> {\n // Active observers receiving broadcast messages. Thanks to this.latest,\n // we can assume all observers in this Set have received the same most\n // recent message, though possibly at different times in the past.\n private observers = new Set<Observer<T>>();\n\n // This property starts off undefined to indicate the initial\n // subscription has not yet begun, then points to each source\n // subscription in turn, and finally becomes null after the sources have\n // been exhausted. After that, it stays null.\n private sub?: ObservableSubscription | null;\n\n // Not only can the individual elements of the iterable be promises, but\n // also the iterable itself can be wrapped in a promise.\n constructor(sources: MaybeAsync<ConcastSourcesIterable<T>> | Subscriber<T>) {\n super(observer => {\n this.addObserver(observer);\n return () => this.removeObserver(observer);\n });\n\n // Suppress rejection warnings for this.promise, since it's perfectly\n // acceptable to pay no attention to this.promise if you're consuming\n // the results through the normal observable API.\n this.promise.catch(_ => {});\n\n // If someone accidentally tries to create a Concast using a subscriber\n // function, recover by creating an Observable from that subscriber and\n // using it as the source.\n if (typeof sources === \"function\") {\n sources = [new Observable(sources)];\n }\n\n if (isPromiseLike(sources)) {\n sources.then(\n iterable => this.start(iterable),\n this.handlers.error,\n );\n } else {\n this.start(sources);\n }\n }\n\n // A consumable array of source observables, incrementally consumed\n // each time this.handlers.complete is called.\n private sources: Source<T>[];\n\n private start(sources: ConcastSourcesIterable<T>) {\n if (this.sub !== void 0) return;\n\n // In practice, sources is most often simply an Array of observables.\n // TODO Consider using sources[Symbol.iterator]() to take advantage\n // of the laziness of non-Array iterables.\n this.sources = Array.from(sources);\n\n // Calling this.handlers.complete() kicks off consumption of the first\n // source observable. It's tempting to do this step lazily in\n // addObserver, but this.promise can be accessed without calling\n // addObserver, so consumption needs to begin eagerly.\n this.handlers.complete();\n }\n\n private deliverLastMessage(observer: Observer<T>) {\n if (this.latest) {\n const nextOrError = this.latest[0];\n const method = observer[nextOrError];\n if (method) {\n method.call(observer, this.latest[1]);\n }\n // If the subscription is already closed, and the last message was\n // a 'next' message, simulate delivery of the final 'complete'\n // message again.\n if (this.sub === null &&\n nextOrError === \"next\" &&\n observer.complete) {\n observer.complete();\n }\n }\n }\n\n // Note: cleanup observers do not count towards this total.\n private addCount = 0;\n\n public addObserver(observer: Observer<T>) {\n if (!this.observers.has(observer)) {\n // Immediately deliver the most recent message, so we can always\n // be sure all observers have the latest information.\n this.deliverLastMessage(observer);\n this.observers.add(observer);\n ++this.addCount;\n }\n }\n\n public removeObserver(\n observer: Observer<T>,\n quietly?: boolean,\n ) {\n if (this.observers.delete(observer) &&\n --this.addCount < 1 &&\n !quietly) {\n // In case there are still any cleanup observers in this.observers, and no\n // error or completion has been broadcast yet, make sure those observers\n // have a chance to run and then remove themselves from this.observers.\n this.handlers.complete();\n }\n }\n\n // Any Concast object can be trivially converted to a Promise, without\n // having to create a new wrapper Observable. This promise provides an\n // easy way to observe the final state of the Concast.\n private resolve: (result?: T | PromiseLike<T>) => void;\n private reject: (reason: any) => void;\n public readonly promise = new Promise<T>((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n\n // Name and argument of the most recently invoked observer method, used\n // to deliver latest results immediately to new observers.\n private latest?: [\"next\" | \"error\", any];\n\n // Bound handler functions that can be reused for every internal\n // subscription.\n private handlers = {\n next: (result: T) => {\n if (this.sub !== null) {\n this.latest = [\"next\", result];\n iterateObserversSafely(this.observers, \"next\", result);\n }\n },\n\n error: (error: any) => {\n const { sub } = this;\n if (sub !== null) {\n // Delay unsubscribing from the underlying subscription slightly,\n // so that immediately subscribing another observer can keep the\n // subscription active.\n if (sub) setTimeout(() => sub.unsubscribe());\n this.sub = null;\n this.latest = [\"error\", error];\n this.reject(error);\n iterateObserversSafely(this.observers, \"error\", error);\n }\n },\n\n complete: () => {\n const { sub } = this;\n if (sub !== null) {\n const value = this.sources.shift();\n if (!value) {\n if (sub) setTimeout(() => sub.unsubscribe());\n this.sub = null;\n if (this.latest &&\n this.latest[0] === \"next\") {\n this.resolve(this.latest[1]);\n } else {\n this.resolve();\n }\n // We do not store this.latest = [\"complete\"], because doing so\n // discards useful information about the previous next (or\n // error) message. Instead, if new observers subscribe after\n // this Concast has completed, they will receive the final\n // 'next' message (unless there was an error) immediately\n // followed by a 'complete' message (see addObserver).\n iterateObserversSafely(this.observers, \"complete\");\n } else if (isPromiseLike(value)) {\n value.then(obs => this.sub = obs.subscribe(this.handlers));\n } else {\n this.sub = value.subscribe(this.handlers);\n }\n }\n },\n };\n\n public cleanup(callback: () => any) {\n let called = false;\n const once = () => {\n if (!called) {\n called = true;\n // Removing a cleanup observer should not unsubscribe from the\n // underlying Observable, so the only removeObserver behavior we\n // need here is to delete observer from this.observers.\n this.observers.delete(observer);\n callback();\n }\n }\n const observer = {\n next: once,\n error: once,\n complete: once,\n };\n const count = this.addCount;\n this.addObserver(observer);\n // Normally addObserver increments this.addCount, but we can \"hide\"\n // cleanup observers by restoring this.addCount to its previous value\n // after adding any cleanup observer.\n this.addCount = count;\n }\n\n // A public way to abort observation and broadcast.\n public cancel = (reason: any) => {\n this.reject(reason);\n this.sources = [];\n this.handlers.complete();\n }\n}\n\n// Necessary because the Concast constructor has a different signature\n// than the Observable constructor.\nfixObservableSubclass(Concast);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/utilities/policies/pag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CAAC,KAAK,IAAI,WAAW,CAC/C,cAAc,CAAC,KAAK,CAAC,GAAG,IAAI,EAC5B,cAAc,CAAC,KAAK,CAAC,GAAG,IAAI,EAC5B,cAAc,CAAC,KAAK,CAAC,GAAG,IAAI,CAC7B,CAAC;AAKF,wBAAgB,oBAAoB,CAAC,KAAK,GAAG,SAAS,EACpD,OAAO,GAAE,OAAe,GACvB,gBAAgB,CAAC,KAAK,CAAC,CA2KzB"}
@@ -17,14 +17,16 @@ export function offsetLimitPagination(keyArgs) {
17
17
  merge: function (existing, incoming, _a) {
18
18
  var args = _a.args;
19
19
  var merged = existing ? existing.slice(0) : [];
20
- if (args) {
21
- var _b = args.offset, offset = _b === void 0 ? 0 : _b;
22
- for (var i = 0; i < incoming.length; ++i) {
23
- merged[offset + i] = incoming[i];
20
+ if (incoming) {
21
+ if (args) {
22
+ var _b = args.offset, offset = _b === void 0 ? 0 : _b;
23
+ for (var i = 0; i < incoming.length; ++i) {
24
+ merged[offset + i] = incoming[i];
25
+ }
26
+ }
27
+ else {
28
+ merged.push.apply(merged, incoming);
24
29
  }
25
- }
26
- else {
27
- merged.push.apply(merged, incoming);
28
30
  }
29
31
  return merged;
30
32
  },