grafast 0.1.1-beta.20 → 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 (133) hide show
  1. package/dist/args.js +2 -3
  2. package/dist/assert.js +2 -3
  3. package/dist/constraints.js +1 -2
  4. package/dist/deferred.js +1 -2
  5. package/dist/dev.js +2 -2
  6. package/dist/engine/LayerPlan.d.ts +20 -16
  7. package/dist/engine/LayerPlan.js +5 -10
  8. package/dist/engine/OperationPlan.d.ts +12 -13
  9. package/dist/engine/OperationPlan.js +210 -146
  10. package/dist/engine/OutputPlan.d.ts +4 -4
  11. package/dist/engine/OutputPlan.js +13 -10
  12. package/dist/engine/StepTracker.js +11 -2
  13. package/dist/engine/executeBucket.js +135 -94
  14. package/dist/engine/executeOutputPlan.js +1 -2
  15. package/dist/engine/lib/defaultPlanResolver.d.ts +6 -0
  16. package/dist/engine/lib/defaultPlanResolver.js +11 -0
  17. package/dist/engine/lib/withGlobalLayerPlan.d.ts +2 -2
  18. package/dist/engine/lib/withGlobalLayerPlan.js +4 -5
  19. package/dist/engine/lock.d.ts +3 -3
  20. package/dist/engine/lock.js +3 -3
  21. package/dist/error.js +4 -4
  22. package/dist/establishOperationPlan.js +2 -3
  23. package/dist/execute.js +3 -4
  24. package/dist/exportAs.js +2 -3
  25. package/dist/global.js +2 -3
  26. package/dist/grafastGraphql.js +2 -3
  27. package/dist/grafastPrint.js +7 -8
  28. package/dist/graphqlCollectFields.js +6 -7
  29. package/dist/graphqlMergeSelectionSets.js +1 -2
  30. package/dist/index.d.ts +22 -18
  31. package/dist/index.js +41 -16
  32. package/dist/input.js +75 -28
  33. package/dist/inspect.d.ts +9 -4
  34. package/dist/inspect.js +2 -2
  35. package/dist/interfaces.d.ts +110 -89
  36. package/dist/makeGrafastSchema.d.ts +18 -9
  37. package/dist/makeGrafastSchema.js +64 -30
  38. package/dist/mermaid.js +53 -14
  39. package/dist/middleware.js +1 -2
  40. package/dist/multistep.d.ts +6 -6
  41. package/dist/multistep.js +6 -7
  42. package/dist/operationPlan-input.d.ts +5 -4
  43. package/dist/operationPlan-input.js +131 -399
  44. package/dist/planJSONInterfaces.d.ts +6 -2
  45. package/dist/polymorphic.js +4 -5
  46. package/dist/prepare.js +6 -6
  47. package/dist/step.d.ts +67 -99
  48. package/dist/step.js +99 -127
  49. package/dist/steps/__flag.d.ts +16 -16
  50. package/dist/steps/__flag.js +9 -6
  51. package/dist/steps/__inputDefault.d.ts +14 -0
  52. package/dist/steps/__inputDefault.js +48 -0
  53. package/dist/steps/__inputDynamicScalar.d.ts +2 -4
  54. package/dist/steps/__inputDynamicScalar.js +4 -2
  55. package/dist/steps/__inputList.d.ts +5 -9
  56. package/dist/steps/__inputList.js +4 -1
  57. package/dist/steps/__inputObject.d.ts +6 -11
  58. package/dist/steps/__inputObject.js +13 -3
  59. package/dist/steps/__inputStaticLeaf.d.ts +2 -4
  60. package/dist/steps/__inputStaticLeaf.js +3 -1
  61. package/dist/steps/__item.d.ts +6 -6
  62. package/dist/steps/__item.js +1 -1
  63. package/dist/steps/__trackedValue.d.ts +4 -49
  64. package/dist/steps/__trackedValue.js +24 -6
  65. package/dist/steps/__value.d.ts +3 -3
  66. package/dist/steps/__value.js +3 -2
  67. package/dist/steps/access.d.ts +7 -6
  68. package/dist/steps/access.js +14 -7
  69. package/dist/steps/applyInput.d.ts +44 -0
  70. package/dist/steps/applyInput.js +206 -0
  71. package/dist/steps/applyTransforms.d.ts +2 -2
  72. package/dist/steps/applyTransforms.js +7 -5
  73. package/dist/steps/bakedInput.d.ts +23 -0
  74. package/dist/steps/bakedInput.js +90 -0
  75. package/dist/steps/condition.d.ts +5 -5
  76. package/dist/steps/condition.js +3 -3
  77. package/dist/steps/connection.d.ts +42 -39
  78. package/dist/steps/connection.js +51 -35
  79. package/dist/steps/constant.d.ts +4 -8
  80. package/dist/steps/constant.js +54 -6
  81. package/dist/steps/each.d.ts +3 -3
  82. package/dist/steps/each.js +1 -2
  83. package/dist/steps/error.d.ts +2 -2
  84. package/dist/steps/error.js +3 -3
  85. package/dist/steps/filter.d.ts +3 -2
  86. package/dist/steps/filter.js +1 -2
  87. package/dist/steps/first.d.ts +6 -5
  88. package/dist/steps/first.js +5 -4
  89. package/dist/steps/graphqlResolver.d.ts +2 -2
  90. package/dist/steps/graphqlResolver.js +44 -56
  91. package/dist/steps/groupBy.d.ts +3 -2
  92. package/dist/steps/groupBy.js +1 -2
  93. package/dist/steps/index.d.ts +4 -2
  94. package/dist/steps/index.js +21 -9
  95. package/dist/steps/lambda.d.ts +5 -5
  96. package/dist/steps/lambda.js +4 -4
  97. package/dist/steps/last.d.ts +6 -5
  98. package/dist/steps/last.js +5 -4
  99. package/dist/steps/list.d.ts +7 -7
  100. package/dist/steps/list.js +3 -3
  101. package/dist/steps/listTransform.d.ts +14 -12
  102. package/dist/steps/listTransform.js +14 -7
  103. package/dist/steps/listen.d.ts +6 -8
  104. package/dist/steps/listen.js +7 -7
  105. package/dist/steps/load.d.ts +6 -6
  106. package/dist/steps/load.js +7 -7
  107. package/dist/steps/node.d.ts +16 -10
  108. package/dist/steps/node.js +14 -7
  109. package/dist/steps/object.d.ts +11 -11
  110. package/dist/steps/object.js +5 -5
  111. package/dist/steps/partitionByIndex.d.ts +3 -2
  112. package/dist/steps/partitionByIndex.js +1 -2
  113. package/dist/steps/polymorphicBranch.d.ts +8 -8
  114. package/dist/steps/polymorphicBranch.js +4 -4
  115. package/dist/steps/proxy.d.ts +8 -8
  116. package/dist/steps/proxy.js +3 -3
  117. package/dist/steps/remapKeys.d.ts +6 -6
  118. package/dist/steps/remapKeys.js +3 -3
  119. package/dist/steps/reverse.d.ts +5 -5
  120. package/dist/steps/reverse.js +4 -4
  121. package/dist/steps/setter.d.ts +9 -18
  122. package/dist/steps/setter.js +24 -14
  123. package/dist/steps/sideEffect.d.ts +4 -4
  124. package/dist/steps/sideEffect.js +3 -3
  125. package/dist/stringifyPayload.js +1 -2
  126. package/dist/stripAnsi.js +2 -2
  127. package/dist/subscribe.js +2 -3
  128. package/dist/timeSource.d.ts +0 -1
  129. package/dist/utils.d.ts +43 -31
  130. package/dist/utils.js +97 -61
  131. package/dist/version.d.ts +1 -1
  132. package/dist/version.js +1 -1
  133. package/package.json +2 -2
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.connection = exports.EdgeStep = exports.assertEdgeCapableStep = exports.ConnectionStep = exports.assertPageInfoCapableStep = void 0;
3
+ exports.EdgeStep = exports.ConnectionStep = void 0;
4
+ exports.assertPageInfoCapableStep = assertPageInfoCapableStep;
5
+ exports.assertEdgeCapableStep = assertEdgeCapableStep;
6
+ exports.connection = connection;
7
+ exports.itemsOrStep = itemsOrStep;
4
8
  const tslib_1 = require("tslib");
5
9
  const assert = tslib_1.__importStar(require("../assert.js"));
6
10
  const step_js_1 = require("../step.js");
7
11
  const utils_js_1 = require("../utils.js");
12
+ const constant_js_1 = require("./constant.js");
8
13
  const each_js_1 = require("./each.js");
9
14
  function assertPageInfoCapableStep($step) {
10
15
  const $typed = $step;
@@ -15,13 +20,12 @@ function assertPageInfoCapableStep($step) {
15
20
  throw new Error(`Expected a PageInfoCapableStep, but found '${$step}'`);
16
21
  }
17
22
  }
18
- exports.assertPageInfoCapableStep = assertPageInfoCapableStep;
19
23
  const EMPTY_OBJECT = Object.freeze(Object.create(null));
20
24
  /**
21
25
  * Handles GraphQL cursor pagination in a standard and consistent way
22
26
  * indepdenent of data source.
23
27
  */
24
- class ConnectionStep extends step_js_1.UnbatchedExecutableStep {
28
+ class ConnectionStep extends step_js_1.UnbatchedStep {
25
29
  static { this.$$export = {
26
30
  moduleName: "grafast",
27
31
  exportName: "ConnectionStep",
@@ -52,65 +56,75 @@ class ConnectionStep extends step_js_1.UnbatchedExecutableStep {
52
56
  return String(this.subplanId);
53
57
  }
54
58
  getFirst() {
55
- return this._firstDepId != null
56
- ? this.getDep(this._firstDepId)
57
- : null;
59
+ return this.maybeGetDep(this._firstDepId);
58
60
  }
59
- setFirst($firstPlan) {
61
+ setFirst(first) {
60
62
  if (this._firstDepId != null) {
61
63
  throw new Error(`${this}->setFirst already called`);
62
64
  }
63
- this._firstDepId = this.addDependency($firstPlan);
65
+ const $first = typeof first === "number" ? (0, constant_js_1.constant)(first) : first;
66
+ this._firstDepId = this.addUnaryDependency({
67
+ step: $first,
68
+ nonUnaryMessage: () => `${this}.setFirst(...) must be passed a _unary_ step, but ${$first} is not unary. See: https://err.red/gud#connection`,
69
+ });
64
70
  }
65
71
  getLast() {
66
- return this._lastDepId != null
67
- ? this.getDep(this._lastDepId)
68
- : null;
72
+ return this.maybeGetDep(this._lastDepId);
69
73
  }
70
- setLast($lastPlan) {
74
+ setLast(last) {
71
75
  if (this._lastDepId != null) {
72
76
  throw new Error(`${this}->setLast already called`);
73
77
  }
74
- this._lastDepId = this.addDependency($lastPlan);
78
+ const $last = typeof last === "number" ? (0, constant_js_1.constant)(last) : last;
79
+ this._lastDepId = this.addUnaryDependency({
80
+ step: $last,
81
+ nonUnaryMessage: () => `${this}.setLast(...) must be passed a _unary_ step, but ${$last} is not unary. See: https://err.red/gud#connection`,
82
+ });
75
83
  }
76
84
  getOffset() {
77
- return this._offsetDepId != null
78
- ? this.getDep(this._offsetDepId)
79
- : null;
85
+ return this.maybeGetDep(this._offsetDepId);
80
86
  }
81
- setOffset($offsetPlan) {
87
+ setOffset(offset) {
82
88
  if (this._offsetDepId != null) {
83
89
  throw new Error(`${this}->setOffset already called`);
84
90
  }
85
- this._offsetDepId = this.addDependency($offsetPlan);
91
+ const $offset = typeof offset === "number" ? (0, constant_js_1.constant)(offset) : offset;
92
+ this._offsetDepId = this.addUnaryDependency({
93
+ step: $offset,
94
+ nonUnaryMessage: () => `${this}.setOffset(...) must be passed a _unary_ step, but ${$offset} is not unary. See: https://err.red/gud#connection`,
95
+ });
86
96
  }
87
97
  getBefore() {
88
- return this._beforeDepId != null
89
- ? this.getDep(this._beforeDepId)
90
- : null;
98
+ return this.maybeGetDep(this._beforeDepId, true);
91
99
  }
92
100
  setBefore($beforePlan) {
101
+ if ($beforePlan instanceof constant_js_1.ConstantStep && $beforePlan.data == null) {
102
+ return;
103
+ }
93
104
  if (this._beforeDepId !== undefined) {
94
105
  throw new Error(`${this}->setBefore already called`);
95
106
  }
96
107
  const $parsedBeforePlan = this.getSubplan().parseCursor($beforePlan);
97
- this._beforeDepId = $parsedBeforePlan
98
- ? this.addDependency($parsedBeforePlan)
99
- : null;
108
+ this._beforeDepId = this.addUnaryDependency({
109
+ step: $parsedBeforePlan,
110
+ nonUnaryMessage: () => `${this}.setBefore(...) must be passed a _unary_ step, but ${$parsedBeforePlan} (and presumably ${$beforePlan}) is not unary. See: https://err.red/gud#connection`,
111
+ });
100
112
  }
101
113
  getAfter() {
102
- return this._afterDepId != null
103
- ? this.getDep(this._afterDepId)
104
- : null;
114
+ return this.maybeGetDep(this._afterDepId, true);
105
115
  }
106
116
  setAfter($afterPlan) {
117
+ if ($afterPlan instanceof constant_js_1.ConstantStep && $afterPlan.data == null) {
118
+ return;
119
+ }
107
120
  if (this._afterDepId !== undefined) {
108
121
  throw new Error(`${this}->setAfter already called`);
109
122
  }
110
123
  const $parsedAfterPlan = this.getSubplan().parseCursor($afterPlan);
111
- this._afterDepId = $parsedAfterPlan
112
- ? this.addDependency($parsedAfterPlan)
113
- : null;
124
+ this._afterDepId = this.addUnaryDependency({
125
+ step: $parsedAfterPlan,
126
+ nonUnaryMessage: () => `${this}.setAfter(...) must be passed a _unary_ step, but ${$parsedAfterPlan} (and presumably ${$afterPlan}) is not unary. See: https://err.red/gud#connection`,
127
+ });
114
128
  }
115
129
  /**
116
130
  * This should not be called after the arguments have been finalized.
@@ -225,8 +239,7 @@ class ConnectionStep extends step_js_1.UnbatchedExecutableStep {
225
239
  return new EdgeStep(this, $edge);
226
240
  }
227
241
  pageInfo() {
228
- const plan = this.getStep(this.subplanId);
229
- return plan.pageInfo(this);
242
+ return this.cloneSubplanWithPagination().pageInfo(this);
230
243
  }
231
244
  /*
232
245
 
@@ -253,8 +266,7 @@ function assertEdgeCapableStep($step) {
253
266
  throw new Error(`Expected a EdgeCapableStep, but found '${$step}'`);
254
267
  }
255
268
  }
256
- exports.assertEdgeCapableStep = assertEdgeCapableStep;
257
- class EdgeStep extends step_js_1.UnbatchedExecutableStep {
269
+ class EdgeStep extends step_js_1.UnbatchedStep {
258
270
  static { this.$$export = {
259
271
  moduleName: "grafast",
260
272
  exportName: "EdgeStep",
@@ -348,5 +360,9 @@ function connection(step, config) {
348
360
  }
349
361
  return new ConnectionStep(step, config);
350
362
  }
351
- exports.connection = connection;
363
+ function itemsOrStep($step) {
364
+ return "items" in $step && typeof $step.items === "function"
365
+ ? $step.items()
366
+ : $step;
367
+ }
352
368
  //# sourceMappingURL=connection.js.map
@@ -1,9 +1,9 @@
1
- import type { ExecutionDetails, GrafastResultsList } from "../interfaces.js";
2
- import { UnbatchedExecutableStep } from "../step.js";
1
+ import type { ExecutionDetails, GrafastResultsList, JSONValue } from "../interfaces.js";
2
+ import { UnbatchedStep } from "../step.js";
3
3
  /**
4
4
  * Converts a constant value (e.g. a string/number/etc) into a plan
5
5
  */
6
- export declare class ConstantStep<TData> extends UnbatchedExecutableStep<TData> {
6
+ export declare class ConstantStep<TData> extends UnbatchedStep<TData> {
7
7
  readonly data: TData;
8
8
  readonly isSensitive: boolean;
9
9
  static $$export: {
@@ -13,13 +13,9 @@ export declare class ConstantStep<TData> extends UnbatchedExecutableStep<TData>
13
13
  isSyncAndSafe: boolean;
14
14
  constructor(data: TData, isSensitive?: boolean);
15
15
  toStringMeta(): string;
16
+ planJSONExtra(): undefined | Record<string, JSONValue>;
16
17
  deduplicate(peers: readonly ConstantStep<any>[]): ConstantStep<any>[];
17
18
  execute({ count }: ExecutionDetails): GrafastResultsList<TData>;
18
- eval(): TData;
19
- evalIs(value: any): boolean;
20
- evalIsEmpty(): boolean;
21
- evalLength(): number | null;
22
- evalKeys(): ReadonlyArray<keyof TData & string> | null;
23
19
  unbatchedExecute(): TData;
24
20
  isNull(): boolean;
25
21
  isUndefined(): boolean;
@@ -1,13 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.constant = exports.ConstantStep = void 0;
3
+ exports.ConstantStep = void 0;
4
+ exports.constant = constant;
4
5
  const inspect_js_1 = require("../inspect.js");
5
6
  const step_js_1 = require("../step.js");
6
7
  const utils_js_1 = require("../utils.js");
8
+ const index_js_1 = require("./index.js");
7
9
  /**
8
10
  * Converts a constant value (e.g. a string/number/etc) into a plan
9
11
  */
10
- class ConstantStep extends step_js_1.UnbatchedExecutableStep {
12
+ class ConstantStep extends step_js_1.UnbatchedStep {
11
13
  static { this.$$export = {
12
14
  moduleName: "grafast",
13
15
  exportName: "ConstantStep",
@@ -29,30 +31,61 @@ class ConstantStep extends step_js_1.UnbatchedExecutableStep {
29
31
  // ENHANCE: use nicer simplification
30
32
  return this.isSensitive
31
33
  ? `[HIDDEN]`
32
- : (0, inspect_js_1.inspect)(this.data)
34
+ : (0, inspect_js_1.inspect)(this.data, {
35
+ compact: Infinity,
36
+ breakLength: Infinity,
37
+ })
33
38
  .replace(/[\r\n]/g, " ")
39
+ .replaceAll("[Object: null prototype] ", "§")
34
40
  .slice(0, 60);
35
41
  }
42
+ planJSONExtra() {
43
+ if (this.isSensitive)
44
+ return;
45
+ const data = this.data;
46
+ if (data === null) {
47
+ return {
48
+ constant: {
49
+ type: "null",
50
+ },
51
+ };
52
+ }
53
+ else if (data === undefined ||
54
+ typeof data === "boolean" ||
55
+ typeof data === "number" ||
56
+ typeof data === "string") {
57
+ return {
58
+ constant: {
59
+ type: typeof data,
60
+ },
61
+ };
62
+ }
63
+ }
36
64
  deduplicate(peers) {
37
65
  return peers.filter((p) => p.data === this.data);
38
66
  }
39
67
  execute({ count }) {
40
68
  return (0, utils_js_1.arrayOfLength)(count, this.data);
41
69
  }
70
+ /** @internal */
42
71
  eval() {
43
72
  return this.data;
44
73
  }
74
+ /** @internal */
45
75
  evalIs(value) {
46
76
  return this.data === value;
47
77
  }
78
+ /** @internal */
48
79
  evalIsEmpty() {
49
80
  return (typeof this.data === "object" &&
50
81
  this.data !== null &&
51
82
  Object.keys(this.data).length === 0);
52
83
  }
84
+ /** @internal */
53
85
  evalLength() {
54
86
  return Array.isArray(this.data) ? this.data.length : null;
55
87
  }
88
+ /** @internal */
56
89
  evalKeys() {
57
90
  if (this.data == null || typeof this.data !== "object") {
58
91
  return null;
@@ -95,9 +128,24 @@ function constant(data, isSecret) {
95
128
  if (data.length !== 1) {
96
129
  throw new Error("constant`...` doesn't currently support placeholders; please use 'constant(`...`)' instead");
97
130
  }
98
- return new ConstantStep(data[0], false);
131
+ return constant(data[0], false);
132
+ }
133
+ const opPlan = (0, index_js_1.operationPlan)();
134
+ const makeConst = () => (0, index_js_1.operationPlan)().withRootLayerPlan(() => new ConstantStep(data, isSecret));
135
+ const t = typeof data;
136
+ if (data == null ||
137
+ t === "boolean" ||
138
+ t === "string" ||
139
+ t === "number" ||
140
+ t === "symbol") {
141
+ return opPlan.cacheStep(opPlan.contextStep, isSecret ? `constant-secret` : `constant`, data, makeConst);
142
+ }
143
+ else {
144
+ return makeConst();
99
145
  }
100
- return new ConstantStep(data, isSecret);
101
146
  }
102
- exports.constant = constant;
147
+ // Have to overwrite the getDepOrConstant method due to circular dependency
148
+ step_js_1.Step.prototype.getDepOrConstant = function (depId, fallback) {
149
+ return this.maybeGetDep(depId) ?? constant(fallback, false);
150
+ };
103
151
  //# sourceMappingURL=constant.js.map
@@ -1,9 +1,9 @@
1
- import type { ExecutableStep, ListCapableStep } from "../step.js";
1
+ import type { ListCapableStep, Step } from "../step.js";
2
2
  import { __ItemStep } from "./__item.js";
3
- import type { ConnectionCapableStep } from "./connection.js";
3
+ import type { ConnectionCapableStep, ItemsStep } from "./connection.js";
4
4
  import type { __ListTransformStep } from "./listTransform.js";
5
5
  /**
6
6
  * Transforms a list by wrapping each element in the list with the given mapper.
7
7
  */
8
- export declare function each<TListStep extends ExecutableStep<readonly any[]> & Partial<ConnectionCapableStep<any, any>>, TResultItemStep extends ExecutableStep>(listStep: TListStep, mapper: (itemPlan: TListStep extends ListCapableStep<any, any> ? ReturnType<TListStep["listItem"]> : __ItemStep<any>) => TResultItemStep): __ListTransformStep<any, any, any, any>;
8
+ export declare function each<TListStep extends (Step<readonly any[]> & Partial<ConnectionCapableStep<any, any>>) | ConnectionCapableStep<any, any>, TResultItemStep extends Step>(listStep: TListStep, mapper: (itemPlan: ItemsStep<TListStep> extends ListCapableStep<any, any> ? ReturnType<ItemsStep<TListStep>["listItem"]> : __ItemStep<any>) => TResultItemStep): __ListTransformStep<any, any, any, any>;
9
9
  //# sourceMappingURL=each.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.each = void 0;
3
+ exports.each = each;
4
4
  const tslib_1 = require("tslib");
5
5
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
6
  const step_js_1 = require("../step.js");
@@ -60,5 +60,4 @@ function each(listStep, mapper) {
60
60
  : null),
61
61
  });
62
62
  }
63
- exports.each = each;
64
63
  //# sourceMappingURL=each.js.map
@@ -1,6 +1,6 @@
1
1
  import type { ExecutionDetails, GrafastResultsList } from "../interfaces.js";
2
- import { UnbatchedExecutableStep } from "../step.js";
3
- export declare class ErrorStep<TError extends Error> extends UnbatchedExecutableStep<never> {
2
+ import { UnbatchedStep } from "../step.js";
3
+ export declare class ErrorStep<TError extends Error> extends UnbatchedStep<never> {
4
4
  static $$export: {
5
5
  moduleName: string;
6
6
  exportName: string;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.error = exports.ErrorStep = void 0;
3
+ exports.ErrorStep = void 0;
4
+ exports.error = error;
4
5
  const error_js_1 = require("../error.js");
5
6
  const inspect_js_1 = require("../inspect.js");
6
7
  const step_js_1 = require("../step.js");
7
8
  const utils_js_1 = require("../utils.js");
8
- class ErrorStep extends step_js_1.UnbatchedExecutableStep {
9
+ class ErrorStep extends step_js_1.UnbatchedStep {
9
10
  static { this.$$export = {
10
11
  moduleName: "grafast",
11
12
  exportName: "ErrorStep",
@@ -29,5 +30,4 @@ exports.ErrorStep = ErrorStep;
29
30
  function error(error) {
30
31
  return new ErrorStep(error);
31
32
  }
32
- exports.error = error;
33
33
  //# sourceMappingURL=error.js.map
@@ -1,10 +1,11 @@
1
- import type { ExecutableStep, ListCapableStep } from "../step.js";
1
+ import type { ListCapableStep, Step } from "../step.js";
2
2
  import type { __ItemStep } from "./__item.js";
3
+ import type { ConnectionCapableStep, ItemsStep } from "./connection.js";
3
4
  import type { __ListTransformStep, ListTransformItemPlanCallback } from "./listTransform.js";
4
5
  export type FilterPlanMemo = unknown[];
5
6
  /**
6
7
  * Filters a list plan to only include entries for which the `filterCallback`
7
8
  * plan results in a truthy value.
8
9
  */
9
- export declare function filter<TListStep extends ExecutableStep<readonly any[]>, TItemStep extends ExecutableStep<boolean>>(listStep: TListStep, filterCallback: ListTransformItemPlanCallback<TListStep, TItemStep>): __ListTransformStep<TListStep, TItemStep, FilterPlanMemo, TListStep extends ListCapableStep<any, any> ? ReturnType<TListStep["listItem"]> : __ItemStep<any>>;
10
+ export declare function filter<TListStep extends Step<readonly any[]> | ConnectionCapableStep<any, any>, TItemStep extends Step<boolean>>(listStep: TListStep, filterCallback: ListTransformItemPlanCallback<ItemsStep<TListStep>, TItemStep>): __ListTransformStep<TListStep, TItemStep, FilterPlanMemo, TListStep extends ListCapableStep<any, any> ? ReturnType<TListStep["listItem"]> : __ItemStep<any>>;
10
11
  //# sourceMappingURL=filter.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filter = void 0;
3
+ exports.filter = filter;
4
4
  const tslib_1 = require("tslib");
5
5
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
6
  const step_js_1 = require("../step.js");
@@ -28,5 +28,4 @@ function filter(listStep, filterCallback) {
28
28
  meta: `filter:${chalk_1.default.yellow(listStep.id)}${filterCallback.name ? `/${filterCallback.name}` : ""}`,
29
29
  });
30
30
  }
31
- exports.filter = filter;
32
31
  //# sourceMappingURL=filter.js.map
@@ -1,14 +1,15 @@
1
1
  import type { ExecutionDetails, GrafastResultsList, UnbatchedExecutionExtra } from "../interfaces.js";
2
- import type { ExecutableStep } from "../step.js";
3
- import { UnbatchedExecutableStep } from "../step.js";
4
- export declare class FirstStep<TData> extends UnbatchedExecutableStep<TData> {
2
+ import type { Step } from "../step.js";
3
+ import { UnbatchedStep } from "../step.js";
4
+ import type { ConnectionCapableStep } from "./connection.js";
5
+ export declare class FirstStep<TData> extends UnbatchedStep<TData> {
5
6
  static $$export: {
6
7
  moduleName: string;
7
8
  exportName: string;
8
9
  };
9
10
  isSyncAndSafe: boolean;
10
11
  allowMultipleOptimizations: boolean;
11
- constructor(parentPlan: ExecutableStep<ReadonlyArray<TData>>);
12
+ constructor(parentPlan: Step<ReadonlyArray<TData>> | ConnectionCapableStep<Step<TData>, any>);
12
13
  execute({ indexMap, values: [values0], }: ExecutionDetails<[ReadonlyArray<TData>]>): GrafastResultsList<TData>;
13
14
  unbatchedExecute(_extra: UnbatchedExecutionExtra, list: any[]): any;
14
15
  deduplicate(peers: FirstStep<TData>[]): FirstStep<TData>[];
@@ -18,5 +19,5 @@ export declare class FirstStep<TData> extends UnbatchedExecutableStep<TData> {
18
19
  * A plan that resolves to the first entry in the list returned by the given
19
20
  * plan.
20
21
  */
21
- export declare function first<TData>(plan: ExecutableStep<ReadonlyArray<TData>>): FirstStep<TData>;
22
+ export declare function first<TData>(plan: Step<ReadonlyArray<TData>> | ConnectionCapableStep<Step<TData>, any>): FirstStep<TData>;
22
23
  //# sourceMappingURL=first.d.ts.map
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.first = exports.FirstStep = void 0;
3
+ exports.FirstStep = void 0;
4
+ exports.first = first;
4
5
  const step_js_1 = require("../step.js");
6
+ const connection_js_1 = require("./connection.js");
5
7
  const list_js_1 = require("./list.js");
6
- class FirstStep extends step_js_1.UnbatchedExecutableStep {
8
+ class FirstStep extends step_js_1.UnbatchedStep {
7
9
  static { this.$$export = {
8
10
  moduleName: "grafast",
9
11
  exportName: "FirstStep",
@@ -12,7 +14,7 @@ class FirstStep extends step_js_1.UnbatchedExecutableStep {
12
14
  super();
13
15
  this.isSyncAndSafe = true;
14
16
  this.allowMultipleOptimizations = true;
15
- this.addDependency(parentPlan);
17
+ this.addDependency((0, connection_js_1.itemsOrStep)(parentPlan));
16
18
  }
17
19
  execute({ indexMap, values: [values0], }) {
18
20
  return indexMap((i) => values0.at(i)?.[0]);
@@ -40,5 +42,4 @@ exports.FirstStep = FirstStep;
40
42
  function first(plan) {
41
43
  return plan.operationPlan.cacheStep(plan, "GrafastInternal:first()", "", () => new FirstStep(plan));
42
44
  }
43
- exports.first = first;
44
45
  //# sourceMappingURL=first.js.map
@@ -1,4 +1,4 @@
1
1
  import type { GraphQLNullableType, GraphQLOutputType } from "graphql";
2
- import { ExecutableStep } from "../step.js";
3
- export declare function graphqlItemHandler($item: ExecutableStep, nullableType: GraphQLNullableType & GraphQLOutputType): GraphQLItemHandler;
2
+ import { Step } from "../step.js";
3
+ export declare function graphqlItemHandler($item: Step, nullableType: GraphQLNullableType & GraphQLOutputType): GraphQLItemHandler;
4
4
  //# sourceMappingURL=graphqlResolver.d.ts.map
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.graphqlResolver = exports.graphqlItemHandler = exports.GraphQLItemHandler = exports.GraphQLResolverStep = void 0;
3
+ exports.GraphQLItemHandler = exports.GraphQLResolverStep = void 0;
4
+ exports.graphqlItemHandler = graphqlItemHandler;
5
+ exports.graphqlResolver = graphqlResolver;
4
6
  const tslib_1 = require("tslib");
5
7
  const graphql = tslib_1.__importStar(require("graphql"));
6
8
  const iterall_1 = require("iterall");
@@ -38,7 +40,7 @@ context, resolveInfo) {
38
40
  *
39
41
  * @internal
40
42
  */
41
- class GraphQLResolverStep extends step_js_1.UnbatchedExecutableStep {
43
+ class GraphQLResolverStep extends step_js_1.UnbatchedStep {
42
44
  static { this.$$export = {
43
45
  moduleName: "grafast",
44
46
  exportName: "GraphQLResolverStep",
@@ -69,66 +71,54 @@ class GraphQLResolverStep extends step_js_1.UnbatchedExecutableStep {
69
71
  this.subscriber?.name ||
70
72
  null);
71
73
  }
72
- unbatchedExecute(_extra, source, args, context, variableValues, rootValue) {
73
- if (this.isNotRoot && source == null) {
74
- return source;
75
- }
76
- const resolveInfo = Object.assign(Object.create(this.resolveInfoBase), {
77
- variableValues,
78
- rootValue,
79
- path: {
80
- typename: this.resolveInfoBase.parentType.name,
81
- key: this.resolveInfoBase.fieldName,
82
- // ENHANCE: add full support for path (requires runtime indexes)
83
- prev: undefined,
84
- },
85
- });
86
- const data = this.resolver?.(source, args, context, resolveInfo);
87
- if (this.returnContextAndResolveInfo) {
88
- return dcr(data, context, resolveInfo);
74
+ unbatchedExecute(extra, source, args, context, variableValues, rootValue) {
75
+ if (!extra.stream) {
76
+ if (this.isNotRoot && source == null) {
77
+ return source;
78
+ }
79
+ const resolveInfo = Object.assign(Object.create(this.resolveInfoBase), {
80
+ variableValues,
81
+ rootValue,
82
+ path: {
83
+ typename: this.resolveInfoBase.parentType.name,
84
+ key: this.resolveInfoBase.fieldName,
85
+ // ENHANCE: add full support for path (requires runtime indexes)
86
+ prev: undefined,
87
+ },
88
+ });
89
+ const data = this.resolver?.(source, args, context, resolveInfo);
90
+ if (this.returnContextAndResolveInfo) {
91
+ return dcr(data, context, resolveInfo);
92
+ }
93
+ else {
94
+ return flagErrorIfErrorAsync(data);
95
+ }
89
96
  }
90
97
  else {
91
- return flagErrorIfErrorAsync(data);
92
- }
93
- }
94
- unbatchedStream(_extra, source, args, context, variableValues, rootValue) {
95
- if (this.isNotRoot) {
96
- return Promise.reject(new Error(`Invalid non-root subscribe`));
97
- }
98
- if (this.subscriber == null) {
99
- return Promise.reject(new Error(`Cannot subscribe to field`));
100
- }
101
- if (this.returnContextAndResolveInfo) {
102
- return Promise.reject(new Error(`Subscription with returnContextAndResolveInfo is not supported`));
103
- }
104
- const resolveInfo = Object.assign(Object.create(this.resolveInfoBase), {
105
- // ENHANCE: add support for path
106
- variableValues,
107
- rootValue,
108
- });
109
- const data = this.subscriber(source, args, context, resolveInfo);
110
- // TODO: should apply flagErrorIfError to each value data yields
111
- return flagErrorIfErrorAsync(data);
112
- }
113
- async stream({ indexMap, values, extra, }) {
114
- const depCount = this.dependencies.length;
115
- return indexMap((i) => {
116
- try {
117
- const tuple = [];
118
- for (let j = 0; j < depCount; j++) {
119
- tuple[j] = values[j].at(i);
120
- }
121
- return this.unbatchedStream(extra, ...tuple);
98
+ if (this.isNotRoot) {
99
+ return Promise.reject(new Error(`Invalid non-root subscribe`));
100
+ }
101
+ if (this.subscriber == null) {
102
+ return Promise.reject(new Error(`Cannot subscribe to field`));
122
103
  }
123
- catch (e) {
124
- return (0, index_js_1.flagError)(e);
104
+ if (this.returnContextAndResolveInfo) {
105
+ return Promise.reject(new Error(`Subscription with returnContextAndResolveInfo is not supported`));
125
106
  }
126
- });
107
+ const resolveInfo = Object.assign(Object.create(this.resolveInfoBase), {
108
+ // ENHANCE: add support for path
109
+ variableValues,
110
+ rootValue,
111
+ });
112
+ // TODO: we also need to call the resolver on each result?
113
+ const data = this.subscriber(source, args, context, resolveInfo);
114
+ // TODO: should apply flagErrorIfError to each value data yields
115
+ return flagErrorIfErrorAsync(data);
116
+ }
127
117
  }
128
118
  }
129
119
  exports.GraphQLResolverStep = GraphQLResolverStep;
130
120
  /** @internal */
131
- class GraphQLItemHandler extends step_js_1.ExecutableStep {
121
+ class GraphQLItemHandler extends step_js_1.Step {
132
122
  static { this.$$export = {
133
123
  moduleName: "grafast",
134
124
  exportName: "GraphQLItemHandler",
@@ -251,7 +241,6 @@ exports.GraphQLItemHandler = GraphQLItemHandler;
251
241
  function graphqlItemHandler($item, nullableType) {
252
242
  return new GraphQLItemHandler($item, nullableType);
253
243
  }
254
- exports.graphqlItemHandler = graphqlItemHandler;
255
244
  /**
256
245
  * Emulates what GraphQL does when calling a resolver, including handling of
257
246
  * polymorphism.
@@ -274,7 +263,6 @@ function graphqlResolver(resolver, subscriber, $step, $args, resolveInfoBase) {
274
263
  return $resolverResult;
275
264
  }
276
265
  }
277
- exports.graphqlResolver = graphqlResolver;
278
266
  function flagErrorIfError(data) {
279
267
  return data instanceof Error ? (0, index_js_1.flagError)(data) : data;
280
268
  }
@@ -1,4 +1,5 @@
1
- import type { ExecutableStep } from "../step.js";
1
+ import type { Step } from "../step.js";
2
+ import type { ConnectionCapableStep, ItemsStep } from "./connection.js";
2
3
  import type { __ListTransformStep, ListTransformItemPlanCallback } from "./listTransform.js";
3
4
  export type GroupByPlanMemo = Map<unknown, unknown[]>;
4
5
  /**
@@ -7,5 +8,5 @@ export type GroupByPlanMemo = Map<unknown, unknown[]>;
7
8
  * keys and the values are lists of the original entries that match these
8
9
  * grouping keys.
9
10
  */
10
- export declare function groupBy<TListStep extends ExecutableStep<readonly any[]>, TItemStep extends ExecutableStep<number>>(listStep: TListStep, mapper: ListTransformItemPlanCallback<TListStep, TItemStep>): __ListTransformStep<TListStep, TItemStep, GroupByPlanMemo, any>;
11
+ export declare function groupBy<TListStep extends Step<readonly any[]> | ConnectionCapableStep<any, any>, TItemStep extends Step<number>>(listStep: TListStep, mapper: ListTransformItemPlanCallback<ItemsStep<TListStep>, TItemStep>): __ListTransformStep<TListStep, TItemStep, GroupByPlanMemo, any>;
11
12
  //# sourceMappingURL=groupBy.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.groupBy = void 0;
3
+ exports.groupBy = groupBy;
4
4
  const tslib_1 = require("tslib");
5
5
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
6
  const step_js_1 = require("../step.js");
@@ -36,5 +36,4 @@ function groupBy(listStep, mapper) {
36
36
  meta: `groupBy:${chalk_1.default.yellow(listStep.id)}${mapper.name ? `/${mapper.name}` : ""}`,
37
37
  });
38
38
  }
39
- exports.groupBy = groupBy;
40
39
  //# sourceMappingURL=groupBy.js.map
@@ -24,12 +24,12 @@ export { last, LastStep } from "./last.js";
24
24
  export { list, ListStep } from "./list.js";
25
25
  export { listen, ListenStep } from "./listen.js";
26
26
  export { __ListTransformStep, listTransform, ListTransformItemPlanCallback, ListTransformOptions, ListTransformReduce, } from "./listTransform.js";
27
- export { makeDecodeNodeId, node, nodeIdFromNode, NodeStep, specFromNodeId, } from "./node.js";
27
+ export { makeDecodeNodeId, makeDecodeNodeIdRuntime, node, nodeIdFromNode, NodeStep, specFromNodeId, } from "./node.js";
28
28
  export { object, ObjectPlanMeta, ObjectStep } from "./object.js";
29
29
  export { partitionByIndex } from "./partitionByIndex.js";
30
30
  export { ActualKeyByDesiredKey, remapKeys, RemapKeysStep, } from "./remapKeys.js";
31
31
  export { reverse, reverseArray, ReverseStep } from "./reverse.js";
32
- export { setter, SetterCapableStep, SetterStep } from "./setter.js";
32
+ export { createObjectAndApplyChildren, Setter, setter, SetterCapable, } from "./setter.js";
33
33
  export { sideEffect, SideEffectStep } from "./sideEffect.js";
34
34
  export { __InputListStep } from "./__inputList.js";
35
35
  export { __InputObjectStep, __InputObjectStepWithDollars, } from "./__inputObject.js";
@@ -37,7 +37,9 @@ export { __InputStaticLeafStep } from "./__inputStaticLeaf.js";
37
37
  export { __ItemStep } from "./__item.js";
38
38
  export { __TrackedValueStep, __TrackedValueStepWithDollars, } from "./__trackedValue.js";
39
39
  export { __ValueStep } from "./__value.js";
40
+ export { applyInput, ApplyInputStep, assertModifier, isModifier, Modifier, } from "./applyInput.js";
40
41
  export { applyTransforms, ApplyTransformsStep } from "./applyTransforms.js";
42
+ export { bakedInput, bakedInputRuntime, BakedInputStep } from "./bakedInput.js";
41
43
  export { condition, ConditionStep } from "./condition.js";
42
44
  export { GraphQLItemHandler, graphqlItemHandler, graphqlResolver, GraphQLResolverStep, } from "./graphqlResolver.js";
43
45
  export { LoadedRecordStep, loadMany, LoadManyCallback, loadManyCallback, loadOne, LoadOneCallback, loadOneCallback, LoadOptions, LoadStep, } from "./load.js";