grafast 0.1.1-beta.2 → 0.1.1-beta.21

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 (157) hide show
  1. package/README.md +2 -3
  2. package/dist/args.d.ts +4 -7
  3. package/dist/args.js +53 -38
  4. package/dist/assert.js +2 -3
  5. package/dist/bucket.d.ts +1 -89
  6. package/dist/config.d.ts +0 -17
  7. package/dist/config.js +1 -95
  8. package/dist/constraints.d.ts +15 -1
  9. package/dist/constraints.js +41 -3
  10. package/dist/deferred.js +1 -2
  11. package/dist/dev.d.ts +1 -4
  12. package/dist/dev.js +18 -3
  13. package/dist/engine/LayerPlan.d.ts +21 -111
  14. package/dist/engine/LayerPlan.js +196 -78
  15. package/dist/engine/OperationPlan.d.ts +30 -104
  16. package/dist/engine/OperationPlan.js +763 -471
  17. package/dist/engine/OutputPlan.d.ts +9 -20
  18. package/dist/engine/OutputPlan.js +432 -444
  19. package/dist/engine/StepTracker.d.ts +1 -95
  20. package/dist/engine/StepTracker.js +94 -20
  21. package/dist/engine/executeBucket.d.ts +5 -7
  22. package/dist/engine/executeBucket.js +646 -244
  23. package/dist/engine/executeOutputPlan.d.ts +0 -53
  24. package/dist/engine/executeOutputPlan.js +7 -2
  25. package/dist/engine/lib/defaultPlanResolver.d.ts +6 -0
  26. package/dist/engine/lib/defaultPlanResolver.js +11 -0
  27. package/dist/engine/lib/withGlobalLayerPlan.d.ts +2 -0
  28. package/dist/engine/lib/withGlobalLayerPlan.js +7 -4
  29. package/dist/engine/lock.d.ts +4 -0
  30. package/dist/engine/lock.js +82 -0
  31. package/dist/envelop.js +5 -4
  32. package/dist/error.d.ts +18 -49
  33. package/dist/error.js +50 -39
  34. package/dist/establishOperationPlan.js +57 -42
  35. package/dist/execute.d.ts +5 -4
  36. package/dist/execute.js +31 -15
  37. package/dist/exportAs.d.ts +1 -18
  38. package/dist/exportAs.js +2 -3
  39. package/dist/global.js +2 -3
  40. package/dist/grafastGraphql.d.ts +6 -1
  41. package/dist/grafastGraphql.js +35 -16
  42. package/dist/grafastPrint.d.ts +3 -0
  43. package/dist/grafastPrint.js +67 -6
  44. package/dist/graphqlCollectFields.d.ts +7 -34
  45. package/dist/graphqlCollectFields.js +24 -13
  46. package/dist/graphqlMergeSelectionSets.js +1 -2
  47. package/dist/index.d.ts +44 -29
  48. package/dist/index.js +91 -18
  49. package/dist/input.d.ts +1 -9
  50. package/dist/input.js +75 -28
  51. package/dist/inspect.d.ts +9 -3
  52. package/dist/inspect.js +3 -3
  53. package/dist/interfaces.d.ts +238 -93
  54. package/dist/interfaces.js +20 -3
  55. package/dist/makeGrafastSchema.d.ts +21 -9
  56. package/dist/makeGrafastSchema.js +353 -133
  57. package/dist/mermaid.d.ts +0 -17
  58. package/dist/mermaid.js +131 -19
  59. package/dist/middleware.d.ts +7 -0
  60. package/dist/middleware.js +24 -0
  61. package/dist/multistep.d.ts +19 -0
  62. package/dist/multistep.js +54 -0
  63. package/dist/operationPlan-input.d.ts +5 -4
  64. package/dist/operationPlan-input.js +140 -368
  65. package/dist/planJSONInterfaces.d.ts +12 -2
  66. package/dist/polymorphic.js +4 -5
  67. package/dist/prepare.d.ts +1 -7
  68. package/dist/prepare.js +100 -74
  69. package/dist/step.d.ts +118 -172
  70. package/dist/step.js +262 -183
  71. package/dist/steps/__flag.d.ts +65 -0
  72. package/dist/steps/__flag.js +261 -0
  73. package/dist/steps/__inputDefault.d.ts +14 -0
  74. package/dist/steps/__inputDefault.js +48 -0
  75. package/dist/steps/__inputDynamicScalar.d.ts +4 -6
  76. package/dist/steps/__inputDynamicScalar.js +4 -2
  77. package/dist/steps/__inputList.d.ts +5 -9
  78. package/dist/steps/__inputList.js +4 -1
  79. package/dist/steps/__inputObject.d.ts +7 -11
  80. package/dist/steps/__inputObject.js +49 -3
  81. package/dist/steps/__inputStaticLeaf.d.ts +2 -4
  82. package/dist/steps/__inputStaticLeaf.js +3 -1
  83. package/dist/steps/__item.d.ts +10 -12
  84. package/dist/steps/__item.js +8 -2
  85. package/dist/steps/__trackedValue.d.ts +7 -55
  86. package/dist/steps/__trackedValue.js +69 -8
  87. package/dist/steps/__value.d.ts +5 -4
  88. package/dist/steps/__value.js +5 -4
  89. package/dist/steps/access.d.ts +10 -10
  90. package/dist/steps/access.js +50 -17
  91. package/dist/steps/applyInput.d.ts +44 -0
  92. package/dist/steps/applyInput.js +206 -0
  93. package/dist/steps/applyTransforms.d.ts +2 -25
  94. package/dist/steps/applyTransforms.js +53 -31
  95. package/dist/steps/bakedInput.d.ts +23 -0
  96. package/dist/steps/bakedInput.js +90 -0
  97. package/dist/steps/condition.d.ts +31 -0
  98. package/dist/steps/condition.js +94 -0
  99. package/dist/steps/connection.d.ts +56 -42
  100. package/dist/steps/connection.js +97 -44
  101. package/dist/steps/constant.d.ts +7 -7
  102. package/dist/steps/constant.js +86 -7
  103. package/dist/steps/each.d.ts +3 -3
  104. package/dist/steps/each.js +2 -3
  105. package/dist/steps/error.d.ts +4 -4
  106. package/dist/steps/error.js +7 -6
  107. package/dist/steps/filter.d.ts +3 -2
  108. package/dist/steps/filter.js +1 -2
  109. package/dist/steps/first.d.ts +10 -9
  110. package/dist/steps/first.js +9 -13
  111. package/dist/steps/graphqlResolver.d.ts +3 -76
  112. package/dist/steps/graphqlResolver.js +89 -72
  113. package/dist/steps/groupBy.d.ts +3 -2
  114. package/dist/steps/groupBy.js +1 -2
  115. package/dist/steps/index.d.ts +12 -3
  116. package/dist/steps/index.js +48 -6
  117. package/dist/steps/lambda.d.ts +9 -9
  118. package/dist/steps/lambda.js +18 -9
  119. package/dist/steps/last.d.ts +9 -8
  120. package/dist/steps/last.js +7 -6
  121. package/dist/steps/list.d.ts +20 -9
  122. package/dist/steps/list.js +56 -13
  123. package/dist/steps/listTransform.d.ts +18 -22
  124. package/dist/steps/listTransform.js +58 -27
  125. package/dist/steps/listen.d.ts +6 -11
  126. package/dist/steps/listen.js +14 -16
  127. package/dist/steps/load.d.ts +42 -33
  128. package/dist/steps/load.js +60 -27
  129. package/dist/steps/node.d.ts +17 -10
  130. package/dist/steps/node.js +18 -6
  131. package/dist/steps/object.d.ts +33 -27
  132. package/dist/steps/object.js +53 -32
  133. package/dist/steps/partitionByIndex.d.ts +3 -2
  134. package/dist/steps/partitionByIndex.js +1 -2
  135. package/dist/steps/polymorphicBranch.d.ts +27 -0
  136. package/dist/steps/polymorphicBranch.js +62 -0
  137. package/dist/steps/proxy.d.ts +11 -12
  138. package/dist/steps/proxy.js +8 -5
  139. package/dist/steps/remapKeys.d.ts +10 -10
  140. package/dist/steps/remapKeys.js +14 -7
  141. package/dist/steps/reverse.d.ts +8 -8
  142. package/dist/steps/reverse.js +10 -7
  143. package/dist/steps/setter.d.ts +9 -18
  144. package/dist/steps/setter.js +24 -14
  145. package/dist/steps/sideEffect.d.ts +28 -0
  146. package/dist/steps/sideEffect.js +44 -0
  147. package/dist/stringifyPayload.js +1 -2
  148. package/dist/stripAnsi.js +2 -2
  149. package/dist/subscribe.d.ts +7 -1
  150. package/dist/subscribe.js +24 -9
  151. package/dist/thereCanBeOnlyOne.js +1 -1
  152. package/dist/timeSource.d.ts +0 -1
  153. package/dist/utils.d.ts +56 -55
  154. package/dist/utils.js +179 -59
  155. package/dist/version.d.ts +1 -1
  156. package/dist/version.js +1 -1
  157. package/package.json +5 -8
@@ -1,5 +1,5 @@
1
1
  import type { Bucket } from "../bucket.js";
2
- import type { ExecutableStep, ModifierStep, UnbatchedExecutableStep } from "../step";
2
+ import type { Step } from "../step";
3
3
  import type { OperationPlan } from "./OperationPlan";
4
4
  /** Non-branching, non-deferred */
5
5
  export interface LayerPlanReasonRoot {
@@ -15,7 +15,12 @@ export interface LayerPlanReasonNullableField {
15
15
  *
16
16
  * Also needed for execution (see `executeBucket`).
17
17
  */
18
- parentStep: ExecutableStep;
18
+ parentStep: Step;
19
+ }
20
+ export interface LayerPlanReasonListItemStream {
21
+ initialCountStepId?: number;
22
+ ifStepId?: number;
23
+ labelStepId?: number;
19
24
  }
20
25
  /** Non-branching, non-deferred */
21
26
  export interface LayerPlanReasonListItem {
@@ -27,12 +32,11 @@ export interface LayerPlanReasonListItem {
27
32
  *
28
33
  * Also needed for execution (see `executeBucket`).
29
34
  */
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
- };
35
+ parentStep: Step;
36
+ /**
37
+ * If this listItem is to be streamed, the configuration for that streaming.
38
+ */
39
+ stream?: LayerPlanReasonListItemStream;
36
40
  }
37
41
  /** Non-branching, deferred */
38
42
  export interface LayerPlanReasonSubscription {
@@ -55,59 +59,22 @@ export interface LayerPlanReasonPolymorphic {
55
59
  /**
56
60
  * Needed for execution (see `executeBucket`).
57
61
  */
58
- parentStep: ExecutableStep;
62
+ parentStep: Step;
59
63
  polymorphicPaths: Set<string>;
60
64
  }
61
65
  /** Non-branching, non-deferred */
62
66
  export interface LayerPlanReasonSubroutine {
63
67
  type: "subroutine";
64
- parentStep: ExecutableStep;
68
+ parentStep: Step;
65
69
  }
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;
70
+ export declare function isBranchingLayerPlan(layerPlan: LayerPlan): boolean;
71
+ export declare function isDeferredLayerPlan(layerPlan: LayerPlan): boolean;
72
+ export declare function isPolymorphicLayerPlan(layerPlan: LayerPlan): boolean;
69
73
  export type LayerPlanReason = LayerPlanReasonRoot | LayerPlanReasonNullableField | LayerPlanReasonListItem | LayerPlanReasonSubscription | LayerPlanReasonMutationField | LayerPlanReasonDefer | LayerPlanReasonPolymorphic | LayerPlanReasonSubroutine;
70
74
  export type HasParent<A extends LayerPlanReason> = A extends any ? A extends {
71
- parentStep: ExecutableStep;
75
+ parentStep: Step;
72
76
  } ? A : never : never;
73
77
  export type LayerPlanReasonsWithParentStep = HasParent<LayerPlanReason>;
74
- /** @internal */
75
- export interface LayerPlanPhase {
76
- /**
77
- * If true, we should check before the layer plan executes to see if the
78
- * execution has already timed out.
79
- *
80
- * @see {@link RequestTools.stopTime}
81
- */
82
- checkTimeout: boolean;
83
- /**
84
- * A list of steps that can be ran in parallel at this point, since all
85
- * their previous dependencies have already been satisfied.
86
- */
87
- normalSteps: Array<{
88
- step: ExecutableStep;
89
- }> | undefined;
90
- /**
91
- * A list of 'isSyncAndSafe' steps with unbatchedExecute methods that can be
92
- * ran once the `normalSteps` have completed; they must only depend on steps
93
- * that have already been executed before them (including previous
94
- * unbatchedSyncAndSafeSteps in the same list).
95
- */
96
- unbatchedSyncAndSafeSteps: Array<{
97
- step: UnbatchedExecutableStep;
98
- /**
99
- * Store the result of the step here if you want - useful to avoid lookups
100
- * and when there's no storage. HIGHLY VOLATILE, will not survive a tick!
101
- */
102
- scratchpad: any;
103
- }> | undefined;
104
- /**
105
- * Optimization - a digest of all steps in normalSteps and unbatchedSyncAndSafeSteps
106
- *
107
- * @internal
108
- */
109
- _allSteps: ExecutableStep[];
110
- }
111
78
  /**
112
79
  * A LayerPlan represents (via "reason") either the root (root), when something
113
80
  * happens at a later time (mutationField, defer), when plurality changes
@@ -138,58 +105,6 @@ export declare class LayerPlan<TReason extends LayerPlanReason = LayerPlanReason
138
105
  parentLayerPlan: LayerPlan | null;
139
106
  readonly reason: TReason;
140
107
  id: number;
141
- /**
142
- * Every layer plan has a "root step" that shapes the value the layer
143
- * returns. Note that this step may be dependent on other steps included in
144
- * the LayerPlan, or could be provided externally.
145
- *
146
- * The root step is different for different layer step reasons:
147
- *
148
- * - root: the `operationPlan.rootValue`
149
- * - listItem: the `__ItemStep`
150
- * - stream: also the `__ItemStep`
151
- * - subscription: also the `__ItemStep`
152
- * - mutationField: the result plan of the mutation field
153
- * - defer: the parent layer's rootStep (defer always results in an object, unless an error occurs)
154
- * - polymorphic: the plan for the particular type
155
- * - subroutine: the result (returned) plan of the subroutine
156
- *
157
- * @internal
158
- */
159
- readonly rootStep: ExecutableStep | null;
160
- /**
161
- * Which plans the results for which are available in a parent bucket need to
162
- * be "copied across" to this bucket because plans in this bucket still
163
- * reference them?
164
- *
165
- * @internal
166
- */
167
- copyStepIds: number[];
168
- /** @internal */
169
- children: LayerPlan[];
170
- /** @internal */
171
- steps: ExecutableStep[];
172
- /** @internal */
173
- pendingSteps: ExecutableStep[];
174
- /**
175
- * Describes the order in which the steps within this LayerPlan are executed.
176
- *
177
- * Special attention must be paid to steps that have side effects.
178
- *
179
- * @internal
180
- */
181
- phases: Array<LayerPlanPhase>;
182
- /**
183
- * The list of layerPlans that steps added to this LayerPlan may depend upon.
184
- * Note this includes self, so it has one more entry than `depth`.
185
- *
186
- * ```
187
- * this.ancestry[this.depth] === this;
188
- * ```
189
- *
190
- * @internal
191
- */
192
- ancestry: LayerPlan[];
193
108
  /** How "deep" this layer plan is (how many ancestors it has). The root layer plan has a depth of 0. */
194
109
  depth: number;
195
110
  /** The depth at which a "defer boundary" occurs (OperationPlan.getPeers cannot pass a defer boundary), or 0. */
@@ -198,17 +113,12 @@ export declare class LayerPlan<TReason extends LayerPlanReason = LayerPlanReason
198
113
  * An optimization for OperationPlan.getPeers; this tracks the steps in this
199
114
  * layer plan, grouped by their step class.
200
115
  */
201
- stepsByConstructor: Map<Function, Set<ExecutableStep>>;
116
+ stepsByConstructor: Map<Function, Set<Step>>;
202
117
  constructor(operationPlan: OperationPlan, parentLayerPlan: LayerPlan | null, reason: TReason);
203
118
  toString(): string;
204
119
  print(depth?: number): string;
205
- setRootStep($root: ExecutableStep): void;
206
- /** @internal Use plan.getStep(id) instead. */
207
- getStep(id: number, requestingStep: ExecutableStep): ExecutableStep;
208
- /** @internal */
209
- _addStep(step: ExecutableStep): number;
210
- /** @internal */
211
- _addModifierStep(step: ModifierStep<any>): string;
120
+ _hasSetRootStep: boolean;
121
+ setRootStep($root: Step): void;
212
122
  finalize(): void;
213
123
  newBucket(parentBucket: Bucket): Bucket | null;
214
124
  }