@apollo/client 3.12.4 → 3.12.6

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 (37) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +0 -3
  3. package/apollo-client.cjs +1 -1
  4. package/apollo-client.cjs.map +1 -1
  5. package/apollo-client.min.cjs +1 -1
  6. package/core/ObservableQuery.d.ts +1 -1
  7. package/core/core.cjs +1 -1
  8. package/core/core.cjs.map +1 -1
  9. package/core/core.cjs.native.js +1 -1
  10. package/dev/dev.cjs +1 -1
  11. package/dev/dev.cjs.map +1 -1
  12. package/dev/dev.cjs.native.js +1 -1
  13. package/masking/__benches__/types.bench.js +50 -13
  14. package/masking/__benches__/types.bench.js.map +1 -1
  15. package/masking/internal/types.d.ts +2 -2
  16. package/masking/internal/types.js.map +1 -1
  17. package/masking/types.d.ts +7 -5
  18. package/masking/types.js.map +1 -1
  19. package/package.json +1 -1
  20. package/react/hooks/useQuery.d.ts +1 -1
  21. package/react/hooks/useSubscription.d.ts +1 -2
  22. package/react/internal/cache/QueryReference.d.ts +2 -2
  23. package/react/internal/internal.cjs +1 -1
  24. package/react/internal/internal.cjs.map +1 -1
  25. package/react/internal/internal.cjs.native.js +1 -1
  26. package/testing/internal/ObservableStream.d.ts +11 -9
  27. package/testing/internal/ObservableStream.js +29 -4
  28. package/testing/internal/ObservableStream.js.map +1 -1
  29. package/utilities/globals/globals.cjs +1 -1
  30. package/utilities/globals/globals.cjs.map +1 -1
  31. package/utilities/globals/globals.cjs.native.js +1 -1
  32. package/utilities/index.d.ts +1 -0
  33. package/utilities/index.js.map +1 -1
  34. package/version.js +1 -1
  35. package/testing/core/observableToPromise.d.ts +0 -29
  36. package/testing/core/observableToPromise.js +0 -74
  37. package/testing/core/observableToPromise.js.map +0 -1
@@ -1,74 +0,0 @@
1
- import { __spreadArray } from "tslib";
2
- // Take an observable and N callbacks, and observe the observable,
3
- // ensuring it is called exactly N times, resolving once it has done so.
4
- // Optionally takes a timeout, which it will wait X ms after the Nth callback
5
- // to ensure it is not called again.
6
- export function observableToPromiseAndSubscription(_a) {
7
- var observable = _a.observable, _b = _a.shouldResolve, shouldResolve = _b === void 0 ? true : _b, _c = _a.wait, wait = _c === void 0 ? -1 : _c, _d = _a.errorCallbacks, errorCallbacks = _d === void 0 ? [] : _d;
8
- var cbs = [];
9
- for (var _i = 1; _i < arguments.length; _i++) {
10
- cbs[_i - 1] = arguments[_i];
11
- }
12
- var subscription = null;
13
- var promise = new Promise(function (resolve, reject) {
14
- var errorIndex = 0;
15
- var cbIndex = 0;
16
- var results = [];
17
- var tryToResolve = function () {
18
- if (!shouldResolve) {
19
- return;
20
- }
21
- var done = function () {
22
- subscription.unsubscribe();
23
- // XXX: we could pass a few other things out here?
24
- resolve(results);
25
- };
26
- if (cbIndex === cbs.length && errorIndex === errorCallbacks.length) {
27
- if (wait === -1) {
28
- done();
29
- }
30
- else {
31
- setTimeout(done, wait);
32
- }
33
- }
34
- };
35
- var queue = Promise.resolve();
36
- subscription = observable.subscribe({
37
- next: function (result) {
38
- queue = queue
39
- .then(function () {
40
- var cb = cbs[cbIndex++];
41
- if (cb)
42
- return cb(result);
43
- reject(new Error("Observable 'next' method called more than ".concat(cbs.length, " times")));
44
- })
45
- .then(function (res) {
46
- results.push(res);
47
- tryToResolve();
48
- }, reject);
49
- },
50
- error: function (error) {
51
- queue = queue
52
- .then(function () {
53
- var errorCb = errorCallbacks[errorIndex++];
54
- if (errorCb)
55
- return errorCb(error);
56
- reject(error);
57
- })
58
- .then(tryToResolve, reject);
59
- },
60
- });
61
- });
62
- return {
63
- promise: promise,
64
- subscription: subscription,
65
- };
66
- }
67
- export default function (options) {
68
- var cbs = [];
69
- for (var _i = 1; _i < arguments.length; _i++) {
70
- cbs[_i - 1] = arguments[_i];
71
- }
72
- return observableToPromiseAndSubscription.apply(void 0, __spreadArray([options], cbs, false)).promise;
73
- }
74
- //# sourceMappingURL=observableToPromise.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"observableToPromise.js","sourceRoot":"","sources":["../../../src/testing/core/observableToPromise.ts"],"names":[],"mappings":";AA0BA,kEAAkE;AAClE,wEAAwE;AACxE,6EAA6E;AAC7E,oCAAoC;AACpC,MAAM,UAAU,kCAAkC,CAChD,EAA6E;QAA3E,UAAU,gBAAA,EAAE,qBAAoB,EAApB,aAAa,mBAAG,IAAI,KAAA,EAAE,YAAS,EAAT,IAAI,mBAAG,CAAC,CAAC,KAAA,EAAE,sBAAmB,EAAnB,cAAc,mBAAG,EAAE,KAAA;IAClE,aAAwB;SAAxB,UAAwB,EAAxB,qBAAwB,EAAxB,IAAwB;QAAxB,4BAAwB;;IAExB,IAAI,YAAY,GAA2B,IAAa,CAAC;IACzD,IAAM,OAAO,GAAG,IAAI,OAAO,CAAQ,UAAC,OAAO,EAAE,MAAM;QACjD,IAAI,UAAU,GAAG,CAAC,CAAC;QACnB,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,IAAM,OAAO,GAAU,EAAE,CAAC;QAE1B,IAAM,YAAY,GAAG;YACnB,IAAI,CAAC,aAAa,EAAE,CAAC;gBACnB,OAAO;YACT,CAAC;YAED,IAAM,IAAI,GAAG;gBACX,YAAY,CAAC,WAAW,EAAE,CAAC;gBAC3B,kDAAkD;gBAClD,OAAO,CAAC,OAAO,CAAC,CAAC;YACnB,CAAC,CAAC;YAEF,IAAI,OAAO,KAAK,GAAG,CAAC,MAAM,IAAI,UAAU,KAAK,cAAc,CAAC,MAAM,EAAE,CAAC;gBACnE,IAAI,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC;oBAChB,IAAI,EAAE,CAAC;gBACT,CAAC;qBAAM,CAAC;oBACN,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACzB,CAAC;YACH,CAAC;QACH,CAAC,CAAC;QAEF,IAAI,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;QAE9B,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC;YAClC,IAAI,YAAC,MAA8B;gBACjC,KAAK,GAAG,KAAK;qBACV,IAAI,CAAC;oBACJ,IAAM,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;oBAC1B,IAAI,EAAE;wBAAE,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;oBAC1B,MAAM,CACJ,IAAI,KAAK,CACP,oDAA6C,GAAG,CAAC,MAAM,WAAQ,CAChE,CACF,CAAC;gBACJ,CAAC,CAAC;qBACD,IAAI,CAAC,UAAC,GAAG;oBACR,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBAClB,YAAY,EAAE,CAAC;gBACjB,CAAC,EAAE,MAAM,CAAC,CAAC;YACf,CAAC;YACD,KAAK,YAAC,KAAY;gBAChB,KAAK,GAAG,KAAK;qBACV,IAAI,CAAC;oBACJ,IAAM,OAAO,GAAG,cAAc,CAAC,UAAU,EAAE,CAAC,CAAC;oBAC7C,IAAI,OAAO;wBAAE,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;oBACnC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAChB,CAAC,CAAC;qBACD,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;YAChC,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,SAAA;QACP,YAAY,cAAA;KACb,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,OAAO,WACZ,OAAgB;IAChB,aAAwB;SAAxB,UAAwB,EAAxB,qBAAwB,EAAxB,IAAwB;QAAxB,4BAAwB;;IAExB,OAAO,kCAAkC,8BAAC,OAAO,GAAK,GAAG,UAAE,OAAO,CAAC;AACrE,CAAC","sourcesContent":["import type { ObservableQuery, ApolloQueryResult } from \"../../core/index.js\";\nimport type { ObservableSubscription } from \"../../utilities/index.js\";\n\nexport interface Options {\n /**\n * The ObservableQuery to subscribe to.\n */\n observable: ObservableQuery<any, any>;\n /**\n * Should we resolve after seeing all our callbacks? [default: true]\n * (use this if you are racing the promise against another)\n */\n shouldResolve?: boolean;\n /**\n * How long to wait after seeing desired callbacks before resolving?\n * [default: -1 => don't wait]\n */\n wait?: number;\n /**\n * An expected set of errors.\n */\n errorCallbacks?: ((error: Error) => any)[];\n}\n\nexport type ResultCallback = (result: ApolloQueryResult<any>) => any;\n\n// Take an observable and N callbacks, and observe the observable,\n// ensuring it is called exactly N times, resolving once it has done so.\n// Optionally takes a timeout, which it will wait X ms after the Nth callback\n// to ensure it is not called again.\nexport function observableToPromiseAndSubscription(\n { observable, shouldResolve = true, wait = -1, errorCallbacks = [] }: Options,\n ...cbs: ResultCallback[]\n): { promise: Promise<any[]>; subscription: ObservableSubscription } {\n let subscription: ObservableSubscription = null as never;\n const promise = new Promise<any[]>((resolve, reject) => {\n let errorIndex = 0;\n let cbIndex = 0;\n const results: any[] = [];\n\n const tryToResolve = () => {\n if (!shouldResolve) {\n return;\n }\n\n const done = () => {\n subscription.unsubscribe();\n // XXX: we could pass a few other things out here?\n resolve(results);\n };\n\n if (cbIndex === cbs.length && errorIndex === errorCallbacks.length) {\n if (wait === -1) {\n done();\n } else {\n setTimeout(done, wait);\n }\n }\n };\n\n let queue = Promise.resolve();\n\n subscription = observable.subscribe({\n next(result: ApolloQueryResult<any>) {\n queue = queue\n .then(() => {\n const cb = cbs[cbIndex++];\n if (cb) return cb(result);\n reject(\n new Error(\n `Observable 'next' method called more than ${cbs.length} times`\n )\n );\n })\n .then((res) => {\n results.push(res);\n tryToResolve();\n }, reject);\n },\n error(error: Error) {\n queue = queue\n .then(() => {\n const errorCb = errorCallbacks[errorIndex++];\n if (errorCb) return errorCb(error);\n reject(error);\n })\n .then(tryToResolve, reject);\n },\n });\n });\n\n return {\n promise,\n subscription,\n };\n}\n\nexport default function (\n options: Options,\n ...cbs: ResultCallback[]\n): Promise<any[]> {\n return observableToPromiseAndSubscription(options, ...cbs).promise;\n}\n"]}