grafast 0.1.1-beta.20 → 0.1.1-beta.22

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 (147) hide show
  1. package/README.md +0 -4
  2. package/dist/args.js +5 -6
  3. package/dist/assert.js +2 -3
  4. package/dist/constants.d.ts +79 -0
  5. package/dist/constants.js +79 -0
  6. package/dist/constraints.js +1 -2
  7. package/dist/deferred.js +1 -2
  8. package/dist/dev.js +2 -2
  9. package/dist/engine/LayerPlan.d.ts +88 -21
  10. package/dist/engine/LayerPlan.js +378 -273
  11. package/dist/engine/OperationPlan.d.ts +84 -22
  12. package/dist/engine/OperationPlan.js +1661 -471
  13. package/dist/engine/OperationPlanTypes.d.ts +66 -0
  14. package/dist/engine/OperationPlanTypes.js +3 -0
  15. package/dist/engine/OutputPlan.d.ts +10 -4
  16. package/dist/engine/OutputPlan.js +149 -90
  17. package/dist/engine/StepTracker.js +86 -18
  18. package/dist/engine/executeBucket.js +446 -244
  19. package/dist/engine/executeOutputPlan.js +1 -2
  20. package/dist/engine/lib/defaultPlanResolver.d.ts +3 -0
  21. package/dist/engine/lib/defaultPlanResolver.js +7 -0
  22. package/dist/engine/lib/withGlobalLayerPlan.d.ts +5 -3
  23. package/dist/engine/lib/withGlobalLayerPlan.js +23 -6
  24. package/dist/engine/lock.d.ts +3 -3
  25. package/dist/engine/lock.js +3 -3
  26. package/dist/envelop.js +14 -3
  27. package/dist/error.d.ts +1 -1
  28. package/dist/error.js +13 -13
  29. package/dist/establishOperationPlan.d.ts +2 -1
  30. package/dist/establishOperationPlan.js +12 -13
  31. package/dist/execute.js +10 -9
  32. package/dist/exportAs.js +2 -3
  33. package/dist/global.d.ts +10 -0
  34. package/dist/global.js +27 -3
  35. package/dist/grafastGraphql.js +6 -6
  36. package/dist/grafastPrint.js +43 -12
  37. package/dist/graphqlCollectFields.js +6 -7
  38. package/dist/graphqlMergeSelectionSets.js +1 -2
  39. package/dist/index.d.ts +92 -20
  40. package/dist/index.js +74 -45
  41. package/dist/input.js +95 -29
  42. package/dist/inspect.d.ts +9 -4
  43. package/dist/inspect.js +3 -2
  44. package/dist/interfaces.d.ts +170 -191
  45. package/dist/interfaces.js +0 -77
  46. package/dist/makeGrafastSchema.d.ts +129 -37
  47. package/dist/makeGrafastSchema.js +257 -55
  48. package/dist/mermaid.js +235 -95
  49. package/dist/middleware.js +1 -2
  50. package/dist/multistep.d.ts +6 -6
  51. package/dist/multistep.js +6 -7
  52. package/dist/operationPlan-input.d.ts +5 -4
  53. package/dist/operationPlan-input.js +143 -401
  54. package/dist/planJSONInterfaces.d.ts +30 -7
  55. package/dist/prepare.d.ts +16 -9
  56. package/dist/prepare.js +59 -56
  57. package/dist/step.d.ts +107 -103
  58. package/dist/step.js +234 -145
  59. package/dist/steps/__flag.d.ts +18 -17
  60. package/dist/steps/__flag.js +40 -35
  61. package/dist/steps/__inputDefault.d.ts +14 -0
  62. package/dist/steps/__inputDefault.js +48 -0
  63. package/dist/steps/__inputDynamicScalar.d.ts +2 -4
  64. package/dist/steps/__inputDynamicScalar.js +4 -2
  65. package/dist/steps/__inputList.d.ts +5 -9
  66. package/dist/steps/__inputList.js +4 -1
  67. package/dist/steps/__inputObject.d.ts +5 -10
  68. package/dist/steps/__inputObject.js +13 -3
  69. package/dist/steps/__inputStaticLeaf.d.ts +5 -6
  70. package/dist/steps/__inputStaticLeaf.js +16 -8
  71. package/dist/steps/__item.d.ts +7 -7
  72. package/dist/steps/__item.js +4 -4
  73. package/dist/steps/__trackedValue.d.ts +10 -52
  74. package/dist/steps/__trackedValue.js +49 -15
  75. package/dist/steps/__value.d.ts +5 -4
  76. package/dist/steps/__value.js +8 -2
  77. package/dist/steps/access.d.ts +24 -7
  78. package/dist/steps/access.js +28 -8
  79. package/dist/steps/applyInput.d.ts +44 -0
  80. package/dist/steps/applyInput.js +207 -0
  81. package/dist/steps/applyTransforms.d.ts +2 -2
  82. package/dist/steps/applyTransforms.js +16 -12
  83. package/dist/steps/bakedInput.d.ts +23 -0
  84. package/dist/steps/bakedInput.js +90 -0
  85. package/dist/steps/coalesce.d.ts +15 -0
  86. package/dist/steps/coalesce.js +36 -0
  87. package/dist/steps/condition.d.ts +5 -5
  88. package/dist/steps/condition.js +3 -3
  89. package/dist/steps/connection.d.ts +42 -39
  90. package/dist/steps/connection.js +51 -35
  91. package/dist/steps/constant.d.ts +4 -8
  92. package/dist/steps/constant.js +56 -6
  93. package/dist/steps/each.d.ts +4 -4
  94. package/dist/steps/each.js +1 -2
  95. package/dist/steps/error.d.ts +2 -2
  96. package/dist/steps/error.js +3 -3
  97. package/dist/steps/filter.d.ts +3 -2
  98. package/dist/steps/filter.js +1 -2
  99. package/dist/steps/first.d.ts +8 -5
  100. package/dist/steps/first.js +9 -4
  101. package/dist/steps/graphqlResolver.d.ts +3 -3
  102. package/dist/steps/graphqlResolver.js +95 -205
  103. package/dist/steps/groupBy.d.ts +3 -2
  104. package/dist/steps/groupBy.js +1 -2
  105. package/dist/steps/index.d.ts +7 -17
  106. package/dist/steps/index.js +19 -42
  107. package/dist/steps/lambda.d.ts +5 -5
  108. package/dist/steps/lambda.js +4 -4
  109. package/dist/steps/last.d.ts +8 -5
  110. package/dist/steps/last.js +9 -4
  111. package/dist/steps/list.d.ts +7 -7
  112. package/dist/steps/list.js +3 -3
  113. package/dist/steps/listTransform.d.ts +15 -13
  114. package/dist/steps/listTransform.js +18 -13
  115. package/dist/steps/listen.d.ts +6 -8
  116. package/dist/steps/listen.js +7 -7
  117. package/dist/steps/load.d.ts +31 -25
  118. package/dist/steps/load.js +54 -8
  119. package/dist/steps/node.d.ts +22 -13
  120. package/dist/steps/node.js +19 -26
  121. package/dist/steps/object.d.ts +11 -11
  122. package/dist/steps/object.js +11 -6
  123. package/dist/steps/partitionByIndex.d.ts +3 -2
  124. package/dist/steps/partitionByIndex.js +1 -2
  125. package/dist/steps/proxy.d.ts +7 -13
  126. package/dist/steps/proxy.js +6 -6
  127. package/dist/steps/remapKeys.d.ts +6 -6
  128. package/dist/steps/remapKeys.js +3 -4
  129. package/dist/steps/reverse.d.ts +5 -5
  130. package/dist/steps/reverse.js +4 -4
  131. package/dist/steps/setter.d.ts +9 -18
  132. package/dist/steps/setter.js +24 -14
  133. package/dist/steps/sideEffect.d.ts +4 -4
  134. package/dist/steps/sideEffect.js +3 -3
  135. package/dist/stringifyPayload.js +1 -2
  136. package/dist/stripAnsi.js +2 -2
  137. package/dist/subscribe.js +2 -3
  138. package/dist/timeSource.d.ts +0 -1
  139. package/dist/utils.d.ts +65 -31
  140. package/dist/utils.js +332 -76
  141. package/dist/version.d.ts +1 -1
  142. package/dist/version.js +1 -1
  143. package/package.json +6 -6
  144. package/dist/polymorphic.d.ts +0 -14
  145. package/dist/polymorphic.js +0 -73
  146. package/dist/steps/polymorphicBranch.d.ts +0 -27
  147. package/dist/steps/polymorphicBranch.js +0 -62
package/README.md CHANGED
@@ -50,11 +50,7 @@ And please give some love to our featured sponsors 🤩:
50
50
 
51
51
  <table><tr>
52
52
  <td align="center"><a href="https://www.the-guild.dev/"><img src="https://graphile.org/images/sponsors/theguild.png" width="90" height="90" alt="The Guild" /><br />The Guild</a> *</td>
53
- <td align="center"><a href="https://dovetailapp.com/"><img src="https://graphile.org/images/sponsors/dovetail.png" width="90" height="90" alt="Dovetail" /><br />Dovetail</a> *</td>
54
- <td align="center"><a href="https://stellate.co/"><img src="https://graphile.org/images/sponsors/Stellate.png" width="90" height="90" alt="Stellate" /><br />Stellate</a> *</td>
55
53
  <td align="center"><a href="https://gosteelhead.com/"><img src="https://graphile.org/images/sponsors/steelhead.svg" width="90" height="90" alt="Steelhead" /><br />Steelhead</a> *</td>
56
- </tr><tr>
57
- <td align="center"><a href=""><img src="https://graphile.org/images/sponsors/latchbio.jpg" width="90" height="90" alt="LatchBio" /><br />LatchBio</a> *</td>
58
54
  </tr></table>
59
55
 
60
56
  <em>\* Sponsors the entire Graphile suite</em>
package/dist/args.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hookArgs = void 0;
4
- const interfaces_js_1 = require("./interfaces.js");
3
+ exports.hookArgs = hookArgs;
4
+ const constants_js_1 = require("./constants.js");
5
5
  const middleware_js_1 = require("./middleware.js");
6
6
  const utils_js_1 = require("./utils.js");
7
7
  const EMPTY_OBJECT = Object.freeze(Object.create(null));
@@ -29,16 +29,16 @@ function hookArgs(rawArgs, legacyResolvedPreset, legacyCtx) {
29
29
  }
30
30
  const middleware = rawMiddleware === undefined && resolvedPreset != null
31
31
  ? (0, middleware_js_1.getGrafastMiddleware)(resolvedPreset)
32
- : rawMiddleware ?? null;
32
+ : (rawMiddleware ?? null);
33
33
  if (rawMiddleware === undefined) {
34
34
  rawArgs.middleware = middleware;
35
35
  }
36
36
  const args = rawArgs;
37
37
  // Assert that args haven't already been hooked
38
- if (args[interfaces_js_1.$$hooked]) {
38
+ if (args[constants_js_1.$$hooked]) {
39
39
  throw new Error("Must not call hookArgs twice!");
40
40
  }
41
- args[interfaces_js_1.$$hooked] = true;
41
+ args[constants_js_1.$$hooked] = true;
42
42
  if (middleware != null) {
43
43
  return middleware.run("prepareArgs", { args }, finalizeWithEvent);
44
44
  }
@@ -46,7 +46,6 @@ function hookArgs(rawArgs, legacyResolvedPreset, legacyCtx) {
46
46
  return finalize(args);
47
47
  }
48
48
  }
49
- exports.hookArgs = hookArgs;
50
49
  function finalize(args) {
51
50
  const userContext = args.resolvedPreset?.grafast?.context;
52
51
  const contextValue = args.contextValue;
package/dist/assert.js CHANGED
@@ -6,19 +6,18 @@
6
6
  * https://github.com/facebook/jest/issues/2549
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.strictEqual = exports.ok = void 0;
9
+ exports.ok = ok;
10
+ exports.strictEqual = strictEqual;
10
11
  /** Equivalent to `assert.ok(...)` */
11
12
  function ok(val, message) {
12
13
  if (!val) {
13
14
  throw new Error(message);
14
15
  }
15
16
  }
16
- exports.ok = ok;
17
17
  /** Equivalent to `assert.strictEqual(...)` */
18
18
  function strictEqual(actual, expected, message) {
19
19
  if (actual !== expected) {
20
20
  throw new Error(message + ` (${actual} !== ${expected})`);
21
21
  }
22
22
  }
23
- exports.strictEqual = strictEqual;
24
23
  //# sourceMappingURL=assert.js.map
@@ -0,0 +1,79 @@
1
+ export declare const $$hooked: unique symbol;
2
+ export declare const $$grafastContext: unique symbol;
3
+ export declare const $$planResults: unique symbol;
4
+ export declare const $$id: unique symbol;
5
+ /** Return the value verbatim, don't execute */
6
+ export declare const $$verbatim: unique symbol;
7
+ /**
8
+ * If we're sure the data is the right shape and valid, we can set this key and
9
+ * it can be returned directly
10
+ */
11
+ export declare const $$bypassGraphQL: unique symbol;
12
+ export declare const $$data: unique symbol;
13
+ /**
14
+ * For attaching additional metadata to the GraphQL execution result, for
15
+ * example details of the plan or SQL queries or similar that were executed.
16
+ */
17
+ export declare const $$extensions: unique symbol;
18
+ /**
19
+ * Set this key on a type if that type's serialization is idempotent (that is
20
+ * to say `serialize(serialize(thing)) === serialize(thing)`). This means we
21
+ * don't have to "roll-back" serialization if we need to fallback to graphql-js
22
+ * execution.
23
+ */
24
+ export declare const $$idempotent: unique symbol;
25
+ /**
26
+ * The event emitter used for outputting execution events.
27
+ */
28
+ export declare const $$eventEmitter: unique symbol;
29
+ /**
30
+ * Used to indicate that an array has more results available via a stream.
31
+ */
32
+ export declare const $$streamMore: unique symbol;
33
+ export declare const $$proxy: unique symbol;
34
+ /**
35
+ * If an error has this property set then it's safe to send through to the user
36
+ * without being masked.
37
+ */
38
+ export declare const $$safeError: unique symbol;
39
+ /** The layerPlan used as a subroutine for this step */
40
+ export declare const $$subroutine: unique symbol;
41
+ /** For tracking the timeout a TimeoutError happened from */
42
+ export declare const $$timeout: unique symbol;
43
+ /** For tracking _when_ the timeout happened (because once the JIT has warmed it might not need so long) */
44
+ export declare const $$ts: unique symbol;
45
+ export declare const $$queryCache: unique symbol;
46
+ /**
47
+ * We store the cache directly onto the GraphQLSchema so that it gets garbage
48
+ * collected along with the schema when it's not needed any more. To do so, we
49
+ * attach it using this symbol.
50
+ */
51
+ export declare const $$cacheByOperation: unique symbol;
52
+ export declare const $$contextPlanCache: unique symbol;
53
+ /**
54
+ * A bitwise number representing a number of flags:
55
+ *
56
+ * - 0: normal execution value
57
+ * - 1: errored (trappable)
58
+ * - 2: null (trappable)
59
+ * - 4: inhibited (trappable)
60
+ * - 8: disabled due to polymorphism (untrappable)
61
+ * - 16: stopped (untrappable) - e.g. due to fatal (unrecoverable) error
62
+ * - 32: ...
63
+ */
64
+ export type ExecutionEntryFlags = number & {
65
+ readonly tsBrand?: unique symbol;
66
+ };
67
+ export declare const NO_FLAGS: ExecutionEntryFlags;
68
+ export declare const FLAG_ERROR: ExecutionEntryFlags;
69
+ export declare const FLAG_NULL: ExecutionEntryFlags;
70
+ export declare const FLAG_INHIBITED: ExecutionEntryFlags;
71
+ export declare const FLAG_POLY_SKIPPED: ExecutionEntryFlags;
72
+ export declare const FLAG_STOPPED: ExecutionEntryFlags;
73
+ export declare const ALL_FLAGS: ExecutionEntryFlags;
74
+ /** By default, accept null values as an input */
75
+ export declare const DEFAULT_ACCEPT_FLAGS: ExecutionEntryFlags;
76
+ export declare const TRAPPABLE_FLAGS: ExecutionEntryFlags;
77
+ export declare const DEFAULT_FORBIDDEN_FLAGS: ExecutionEntryFlags;
78
+ export declare const FORBIDDEN_BY_NULLABLE_BOUNDARY_FLAGS: ExecutionEntryFlags;
79
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FORBIDDEN_BY_NULLABLE_BOUNDARY_FLAGS = exports.DEFAULT_FORBIDDEN_FLAGS = exports.TRAPPABLE_FLAGS = exports.DEFAULT_ACCEPT_FLAGS = exports.ALL_FLAGS = exports.FLAG_STOPPED = exports.FLAG_POLY_SKIPPED = exports.FLAG_INHIBITED = exports.FLAG_NULL = exports.FLAG_ERROR = exports.NO_FLAGS = exports.$$contextPlanCache = exports.$$cacheByOperation = exports.$$queryCache = exports.$$deepDepSkip = exports.$$ts = exports.$$timeout = exports.$$subroutine = exports.$$safeError = exports.$$proxy = exports.$$streamMore = exports.$$eventEmitter = exports.$$idempotent = exports.$$extensions = exports.$$data = exports.$$bypassGraphQL = exports.$$verbatim = exports.$$id = exports.$$planResults = exports.$$grafastContext = exports.$$hooked = void 0;
4
+ exports.$$hooked = Symbol("hookArgsApplied");
5
+ exports.$$grafastContext = Symbol("context");
6
+ exports.$$planResults = Symbol("planResults");
7
+ exports.$$id = Symbol("id");
8
+ /** Return the value verbatim, don't execute */
9
+ exports.$$verbatim = Symbol("verbatim");
10
+ /**
11
+ * If we're sure the data is the right shape and valid, we can set this key and
12
+ * it can be returned directly
13
+ */
14
+ exports.$$bypassGraphQL = Symbol("bypassGraphQL");
15
+ exports.$$data = Symbol("data");
16
+ /**
17
+ * For attaching additional metadata to the GraphQL execution result, for
18
+ * example details of the plan or SQL queries or similar that were executed.
19
+ */
20
+ exports.$$extensions = Symbol("extensions");
21
+ /**
22
+ * Set this key on a type if that type's serialization is idempotent (that is
23
+ * to say `serialize(serialize(thing)) === serialize(thing)`). This means we
24
+ * don't have to "roll-back" serialization if we need to fallback to graphql-js
25
+ * execution.
26
+ */
27
+ exports.$$idempotent = Symbol("idempotent");
28
+ /**
29
+ * The event emitter used for outputting execution events.
30
+ */
31
+ exports.$$eventEmitter = Symbol("executionEventEmitter");
32
+ /**
33
+ * Used to indicate that an array has more results available via a stream.
34
+ */
35
+ exports.$$streamMore = Symbol("streamMore");
36
+ exports.$$proxy = Symbol("proxy");
37
+ /**
38
+ * If an error has this property set then it's safe to send through to the user
39
+ * without being masked.
40
+ */
41
+ exports.$$safeError = Symbol("safeError");
42
+ /** The layerPlan used as a subroutine for this step */
43
+ exports.$$subroutine = Symbol("subroutine");
44
+ /** For tracking the timeout a TimeoutError happened from */
45
+ exports.$$timeout = Symbol("timeout");
46
+ /** For tracking _when_ the timeout happened (because once the JIT has warmed it might not need so long) */
47
+ exports.$$ts = Symbol("timestamp");
48
+ /**
49
+ * @internal
50
+ */
51
+ exports.$$deepDepSkip = Symbol("deepDepSkip_experimental");
52
+ exports.$$queryCache = Symbol("queryCache");
53
+ /**
54
+ * We store the cache directly onto the GraphQLSchema so that it gets garbage
55
+ * collected along with the schema when it's not needed any more. To do so, we
56
+ * attach it using this symbol.
57
+ */
58
+ exports.$$cacheByOperation = Symbol("cacheByOperation");
59
+ exports.$$contextPlanCache = Symbol("contextPlanCache");
60
+ function flag(f) {
61
+ return f;
62
+ }
63
+ exports.NO_FLAGS = flag(0); // 0
64
+ exports.FLAG_ERROR = flag(1 << 0); // 1
65
+ exports.FLAG_NULL = flag(1 << 1); // 2
66
+ exports.FLAG_INHIBITED = flag(1 << 2); // 4
67
+ exports.FLAG_POLY_SKIPPED = flag(1 << 3); // 8
68
+ exports.FLAG_STOPPED = flag(1 << 4); // 16
69
+ exports.ALL_FLAGS = flag(exports.FLAG_ERROR | exports.FLAG_NULL | exports.FLAG_INHIBITED | exports.FLAG_POLY_SKIPPED | exports.FLAG_STOPPED);
70
+ /** By default, accept null values as an input */
71
+ exports.DEFAULT_ACCEPT_FLAGS = flag(exports.FLAG_NULL);
72
+ exports.TRAPPABLE_FLAGS = flag(exports.FLAG_ERROR | exports.FLAG_NULL | exports.FLAG_INHIBITED);
73
+ exports.DEFAULT_FORBIDDEN_FLAGS = flag(exports.ALL_FLAGS & ~exports.DEFAULT_ACCEPT_FLAGS);
74
+ exports.FORBIDDEN_BY_NULLABLE_BOUNDARY_FLAGS = flag(exports.FLAG_NULL | exports.FLAG_POLY_SKIPPED);
75
+ // TODO: make `FORBIDDEN_BY_NULLABLE_BOUNDARY_FLAGS = flag(FLAG_ERROR | FLAG_NULL | FLAG_POLY_SKIPPED | FLAG_INHIBITED | FLAG_STOPPED);`
76
+ // Currently this isn't enabled because the bucket has to exist for the output
77
+ // plan to throw the error; really the root should be evaluated before
78
+ // descending into the output plan rather than as part of descending?
79
+ //# sourceMappingURL=constants.js.map
@@ -3,7 +3,7 @@
3
3
  // and then compiling (JIT-style) remaining constraints into a function using
4
4
  // tamedevil
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.matchesConstraints = void 0;
6
+ exports.matchesConstraints = matchesConstraints;
7
7
  function valueAtPath(object, path) {
8
8
  let value = object;
9
9
  for (let i = 0, l = path.length; i < l; i++) {
@@ -107,5 +107,4 @@ function matchesConstraints(constraints, object) {
107
107
  }
108
108
  return true;
109
109
  }
110
- exports.matchesConstraints = matchesConstraints;
111
110
  //# sourceMappingURL=constraints.js.map
package/dist/deferred.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defer = void 0;
3
+ exports.defer = defer;
4
4
  function NOOP() { }
5
5
  /**
6
6
  * Returns a promise that can be `.resolve()`-ed or `.reject()`-ed at a later
@@ -21,5 +21,4 @@ function defer() {
21
21
  promise.then(null, NOOP);
22
22
  return promise;
23
23
  }
24
- exports.defer = defer;
25
24
  //# sourceMappingURL=deferred.js.map
package/dist/dev.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noop = exports.isTest = exports.isDev = void 0;
3
+ exports.isTest = exports.isDev = void 0;
4
+ exports.noop = noop;
4
5
  /**
5
6
  * @internal
6
7
  */
@@ -13,7 +14,6 @@ const mode = graphileEnv !== undefined ? graphileEnv : nodeEnv;
13
14
  exports.isDev = mode === "development" || mode === "test";
14
15
  exports.isTest = mode === "test";
15
16
  function noop() { }
16
- exports.noop = noop;
17
17
  if (typeof process !== "undefined" &&
18
18
  typeof graphileEnv === "undefined" &&
19
19
  typeof nodeEnv === "undefined") {
@@ -1,5 +1,6 @@
1
1
  import type { Bucket } from "../bucket.js";
2
- import type { ExecutableStep } from "../step";
2
+ import type { Step } from "../step";
3
+ import type { __ValueStep } from "../steps/index.js";
3
4
  import type { OperationPlan } from "./OperationPlan";
4
5
  /** Non-branching, non-deferred */
5
6
  export interface LayerPlanReasonRoot {
@@ -8,6 +9,7 @@ export interface LayerPlanReasonRoot {
8
9
  /** Non-branching, non-deferred */
9
10
  export interface LayerPlanReasonNullableField {
10
11
  type: "nullableBoundary";
12
+ parentLayerPlan: LayerPlan;
11
13
  /**
12
14
  * Can be used such that the same LayerPlan can be used for two selection
13
15
  * sets for the same parent plan. In this case an additional output plan
@@ -15,11 +17,17 @@ export interface LayerPlanReasonNullableField {
15
17
  *
16
18
  * Also needed for execution (see `executeBucket`).
17
19
  */
18
- parentStep: ExecutableStep;
20
+ parentStep: Step;
21
+ }
22
+ export interface LayerPlanReasonListItemStream {
23
+ initialCountStepId?: number;
24
+ ifStepId?: number;
25
+ labelStepId?: number;
19
26
  }
20
27
  /** Non-branching, non-deferred */
21
28
  export interface LayerPlanReasonListItem {
22
29
  type: "listItem";
30
+ parentLayerPlan: LayerPlan;
23
31
  /**
24
32
  * Can be used such that the same LayerPlan can be used for two lists for
25
33
  * the same parent plan. In this case an additional output plan would be
@@ -27,48 +35,93 @@ export interface LayerPlanReasonListItem {
27
35
  *
28
36
  * Also needed for execution (see `executeBucket`).
29
37
  */
30
- parentStep: ExecutableStep;
31
- /** If this listItem is to be streamed, the configuration for that streaming */
32
- stream?: {
33
- initialCount: number;
34
- label?: string;
35
- };
38
+ parentStep: Step;
39
+ /**
40
+ * If this listItem is to be streamed, the configuration for that streaming.
41
+ */
42
+ stream?: LayerPlanReasonListItemStream;
36
43
  }
37
44
  /** Non-branching, deferred */
38
45
  export interface LayerPlanReasonSubscription {
39
46
  type: "subscription";
47
+ parentLayerPlan: LayerPlan;
40
48
  }
41
49
  /** Non-branching, deferred */
42
50
  export interface LayerPlanReasonMutationField {
43
51
  type: "mutationField";
52
+ parentLayerPlan: LayerPlan;
44
53
  mutationIndex: number;
45
54
  }
46
55
  /** Non-branching, deferred */
47
56
  export interface LayerPlanReasonDefer {
48
57
  type: "defer";
58
+ parentLayerPlan: LayerPlan;
49
59
  label?: string;
50
60
  }
51
- /** Branching, non-deferred */
61
+ /**
62
+ * Non-branching, non-deferred
63
+ *
64
+ * A polymorphic bucket indicates a transition between values of unknown type
65
+ * and values of a known polymorphic type. This is predicated based on the
66
+ * given typename - before the typename is known, we must run all steps for all
67
+ * types, but once the type is known we can be more selective about which steps
68
+ * to run.
69
+ *
70
+ * When a polymorphic type is met, there will always be a polymorphic layer
71
+ * plan, even if all steps within it run for all types. This is necessary to
72
+ * advance the `polymorphicPathList` index for the relevant indicies.
73
+ */
52
74
  export interface LayerPlanReasonPolymorphic {
53
75
  type: "polymorphic";
76
+ parentLayerPlan: LayerPlan;
54
77
  typeNames: string[];
55
78
  /**
56
- * Needed for execution (see `executeBucket`).
79
+ * Stores the __typename, needed for execution (see `executeBucket`).
57
80
  */
58
- parentStep: ExecutableStep;
81
+ parentStep: Step<string | null>;
59
82
  polymorphicPaths: Set<string>;
60
83
  }
84
+ /**
85
+ * Branching, non-deferred
86
+ *
87
+ * A polymorphicPartition bucket accepts a subset of types and contains only
88
+ * steps relevant to those types; it's a way to avoid having to do a lot of
89
+ * filtering of values being passed into steps' execute methods by
90
+ * pre-filtering the values.
91
+ */
92
+ export interface LayerPlanReasonPolymorphicPartition {
93
+ type: "polymorphicPartition";
94
+ parentLayerPlan: LayerPlan<LayerPlanReasonPolymorphic>;
95
+ typeNames: string[];
96
+ polymorphicPaths: ReadonlySet<string>;
97
+ }
61
98
  /** Non-branching, non-deferred */
62
99
  export interface LayerPlanReasonSubroutine {
63
100
  type: "subroutine";
64
- parentStep: ExecutableStep;
101
+ parentLayerPlan: LayerPlan;
102
+ parentStep: Step;
65
103
  }
66
- export declare function isBranchingLayerPlan(layerPlan: LayerPlan<any>): boolean;
67
- export declare function isDeferredLayerPlan(layerPlan: LayerPlan<any>): boolean;
68
- export declare function isPolymorphicLayerPlan(layerPlan: LayerPlan<any>): boolean;
69
- export type LayerPlanReason = LayerPlanReasonRoot | LayerPlanReasonNullableField | LayerPlanReasonListItem | LayerPlanReasonSubscription | LayerPlanReasonMutationField | LayerPlanReasonDefer | LayerPlanReasonPolymorphic | LayerPlanReasonSubroutine;
104
+ /**
105
+ * Anti-branching, non-deferred
106
+ *
107
+ * A "combined" layer plan exists to re-combine values from multiple layer
108
+ * plans together again, to allow future steps to be more efficient. It's
109
+ * typically relevant when polymorphism has occurred and has caused branching,
110
+ * the combined layer plan allows the values to be recombined before branching
111
+ * again, such that L layers of polymorphism, where there are P different
112
+ * polymorphic branches at each layer, results in P*L branches rather than P^L
113
+ * branches - i.e. it scales linary with number of layers rather than
114
+ * exponentially.
115
+ */
116
+ export interface LayerPlanReasonCombined {
117
+ type: "combined";
118
+ parentLayerPlans: ReadonlyArray<LayerPlan>;
119
+ }
120
+ export declare function hasParentLayerPlan(reason: LayerPlanReason): reason is Exclude<LayerPlanReason, LayerPlanReasonRoot | LayerPlanReasonCombined>;
121
+ export declare function isDeferredLayerPlan(layerPlan: LayerPlan): boolean;
122
+ export type LayerPlanReason = LayerPlanReasonRoot | LayerPlanReasonNullableField | LayerPlanReasonListItem | LayerPlanReasonSubscription | LayerPlanReasonMutationField | LayerPlanReasonDefer | LayerPlanReasonPolymorphic | LayerPlanReasonPolymorphicPartition | LayerPlanReasonCombined | LayerPlanReasonSubroutine;
70
123
  export type HasParent<A extends LayerPlanReason> = A extends any ? A extends {
71
- parentStep: ExecutableStep;
124
+ parentStep: Step;
72
125
  } ? A : never : never;
73
126
  export type LayerPlanReasonsWithParentStep = HasParent<LayerPlanReason>;
74
127
  /**
@@ -98,7 +151,6 @@ export type LayerPlanReasonsWithParentStep = HasParent<LayerPlanReason>;
98
151
  */
99
152
  export declare class LayerPlan<TReason extends LayerPlanReason = LayerPlanReason> {
100
153
  readonly operationPlan: OperationPlan;
101
- parentLayerPlan: LayerPlan | null;
102
154
  readonly reason: TReason;
103
155
  id: number;
104
156
  /** How "deep" this layer plan is (how many ancestors it has). The root layer plan has a depth of 0. */
@@ -109,13 +161,28 @@ export declare class LayerPlan<TReason extends LayerPlanReason = LayerPlanReason
109
161
  * An optimization for OperationPlan.getPeers; this tracks the steps in this
110
162
  * layer plan, grouped by their step class.
111
163
  */
112
- stepsByConstructor: Map<Function, Set<ExecutableStep>>;
113
- constructor(operationPlan: OperationPlan, parentLayerPlan: LayerPlan | null, reason: TReason);
164
+ stepsByConstructor: Map<Function, Set<Step>>;
165
+ /**
166
+ * Populated during `finalize`, this will be empty except for phase
167
+ * transition layer plans (defer/stream) wherein it will contain a list of
168
+ * "unreachable" layer plan IDs relevant to the "combined" layer plans trying
169
+ * to refer to parent layer plans which are outside of this incremental
170
+ * boundary (e.g. if two lists both stream, we might combine those, but at
171
+ * runtime only one will be populated so we can't wait for the other to
172
+ * complete otherwise nothing will happen).
173
+ */
174
+ outOfBoundsLayerPlanIds: Set<number>;
175
+ constructor(operationPlan: OperationPlan, reason: TReason);
114
176
  toString(): string;
115
177
  print(depth?: number): string;
116
178
  _hasSetRootStep: boolean;
117
- setRootStep($root: ExecutableStep): void;
179
+ setRootStep($root: Step): void;
118
180
  finalize(): void;
119
181
  newBucket(parentBucket: Bucket): Bucket | null;
182
+ newCombinedBucket(finalParentBucket: Pick<Bucket, "sharedState">): Bucket | null;
183
+ addCombo(sources: ReadonlyArray<{
184
+ layerPlan: LayerPlan;
185
+ step: Step;
186
+ }>, $target: __ValueStep<any>): void;
120
187
  }
121
188
  //# sourceMappingURL=LayerPlan.d.ts.map