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,7 +1,8 @@
1
1
  import type { GraphQLFieldResolver, GraphQLScalarLiteralParser, GraphQLScalarSerializer, GraphQLScalarValueParser } from "graphql";
2
2
  import { GraphQLSchema } from "graphql";
3
- import type { EnumValueApplyPlanResolver, FieldPlanResolver, ScalarPlanResolver } from "./interfaces.js";
4
- import type { ExecutableStep } from "./step.js";
3
+ import * as graphql from "graphql";
4
+ import type { ArgumentApplyPlanResolver, EnumValueApplyResolver, FieldPlanResolver, InputObjectFieldApplyResolver, InputObjectTypeBakedResolver, ScalarPlanResolver } from "./interfaces.js";
5
+ import type { Step } from "./step.js";
5
6
  /**
6
7
  * When defining a field with `typeDefs/plans` you can declare the field plan
7
8
  * directly, or you can define a configuration object that accepts the plan and
@@ -13,15 +14,19 @@ export type FieldPlans = FieldPlanResolver<any, any, any> | {
13
14
  resolve?: GraphQLFieldResolver<any, any>;
14
15
  subscribe?: GraphQLFieldResolver<any, any>;
15
16
  args?: {
16
- [argName: string]: Grafast.ArgumentExtensions;
17
+ [argName: string]: ArgumentApplyPlanResolver | {
18
+ applyPlan?: ArgumentApplyPlanResolver;
19
+ applySubscribePlan?: ArgumentApplyPlanResolver;
20
+ extensions?: graphql.GraphQLArgumentExtensions;
21
+ };
17
22
  };
18
23
  };
19
24
  /**
20
25
  * The plans/config for each field of a GraphQL object type.
21
26
  */
22
27
  export type ObjectPlans = {
23
- __assertStep?: ((step: ExecutableStep) => asserts step is ExecutableStep) | {
24
- new (...args: any[]): ExecutableStep;
28
+ __assertStep?: ((step: Step) => asserts step is Step) | {
29
+ new (...args: any[]): Step;
25
30
  };
26
31
  } & {
27
32
  [fieldName: string]: FieldPlans;
@@ -30,9 +35,12 @@ export type ObjectPlans = {
30
35
  * The plans for each field of a GraphQL input object type.
31
36
  */
32
37
  export type InputObjectPlans = {
33
- __inputPlan?: () => ExecutableStep;
38
+ __baked?: InputObjectTypeBakedResolver;
34
39
  } & {
35
- [fieldName: string]: Grafast.InputFieldExtensions;
40
+ [fieldName: string]: InputObjectFieldApplyResolver<any> | {
41
+ apply?: InputObjectFieldApplyResolver<any>;
42
+ extensions?: graphql.GraphQLInputFieldExtensions;
43
+ };
36
44
  };
37
45
  /**
38
46
  * The plan config for an interface or union type.
@@ -53,9 +61,10 @@ export type ScalarPlans = {
53
61
  * The values/configs for the entries in a GraphQL enum type.
54
62
  */
55
63
  export type EnumPlans = {
56
- [enumValueName: string]: EnumValueApplyPlanResolver | string | number | boolean | {
64
+ [enumValueName: string]: EnumValueApplyResolver | string | number | boolean | {
57
65
  value?: unknown;
58
- applyPlan?: EnumValueApplyPlanResolver;
66
+ extensions?: graphql.GraphQLEnumValueExtensions;
67
+ apply?: EnumValueApplyResolver;
59
68
  };
60
69
  };
61
70
  /**
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeGrafastSchema = void 0;
3
+ exports.makeGrafastSchema = makeGrafastSchema;
4
4
  const tslib_1 = require("tslib");
5
5
  const graphql_1 = require("graphql");
6
6
  const graphql = tslib_1.__importStar(require("graphql"));
@@ -82,7 +82,7 @@ function makeGrafastSchema(details) {
82
82
  for (const [argName, _argSpec] of Object.entries(fieldSpec.args)) {
83
83
  const arg = field.args?.[argName];
84
84
  if (!arg) {
85
- console.warn(`'plans' specified configuration for object type '${typeName}' field '${fieldName}' arg '${argName}', but that arg was not present in the type`);
85
+ console.warn(`'plans' specified configuration for object type '${typeName}' field '${fieldName}' arg '${argName}', but that arg was not present on the field`);
86
86
  continue;
87
87
  }
88
88
  }
@@ -98,12 +98,19 @@ function makeGrafastSchema(details) {
98
98
  if (fieldName.startsWith("__")) {
99
99
  continue;
100
100
  }
101
- const fieldSpec = objectPlans?.[fieldName];
101
+ const fieldSpec = objectPlans && Object.hasOwn(objectPlans, fieldName)
102
+ ? objectPlans[fieldName]
103
+ : undefined;
102
104
  const fieldConfig = {
103
105
  ...rawFieldSpec,
104
106
  type: mapType(rawFieldSpec.type),
105
107
  };
106
108
  fields[fieldName] = fieldConfig;
109
+ if (fieldConfig.args) {
110
+ for (const [_argName, arg] of Object.entries(fieldConfig.args)) {
111
+ arg.type = mapType(arg.type);
112
+ }
113
+ }
107
114
  if (fieldSpec) {
108
115
  if (typeof fieldSpec === "function") {
109
116
  (0, utils_js_1.exportNameHint)(fieldSpec, `${typeName}_${fieldName}_plan`);
@@ -134,18 +141,30 @@ function makeGrafastSchema(details) {
134
141
  }
135
142
  if (fieldConfig.args) {
136
143
  for (const [argName, arg] of Object.entries(fieldConfig.args)) {
137
- arg.type = mapType(arg.type);
138
144
  const argSpec = fieldSpec.args?.[argName];
139
145
  if (typeof argSpec === "function") {
140
- // Invalid
141
- throw new Error(`Invalid configuration for plans.${typeName}.${fieldName}.args.${argName} - saw a function, but expected an object with 'inputPlan' (optional) and 'applyPlan' (optional) plans`);
146
+ const applyPlan = argSpec;
147
+ (0, utils_js_1.exportNameHint)(applyPlan, `${typeName}_${fieldName}_${argName}_applyPlan`);
148
+ Object.assign(arg.extensions, {
149
+ grafast: { applyPlan },
150
+ });
142
151
  }
143
- else if (argSpec) {
144
- (0, utils_js_1.exportNameHint)(argSpec.applyPlan, `${typeName}_${fieldName}_${argName}_applyPlan`);
145
- (0, utils_js_1.exportNameHint)(argSpec.inputPlan, `${typeName}_${fieldName}_${argName}_inputPlan`);
146
- const grafastExtensions = Object.create(null);
147
- arg.extensions.grafast = grafastExtensions;
148
- Object.assign(grafastExtensions, argSpec);
152
+ else if (typeof argSpec === "object" &&
153
+ argSpec !== null) {
154
+ const { extensions, applyPlan, applySubscribePlan } = argSpec;
155
+ if (extensions) {
156
+ Object.assign(arg.extensions, extensions);
157
+ }
158
+ if (applyPlan || applySubscribePlan) {
159
+ (0, utils_js_1.exportNameHint)(applyPlan, `${typeName}_${fieldName}_${argName}_applyPlan`);
160
+ (0, utils_js_1.exportNameHint)(applySubscribePlan, `${typeName}_${fieldName}_${argName}_applySubscribePlan`);
161
+ Object.assign(arg.extensions, {
162
+ grafast: {
163
+ applyPlan,
164
+ applySubscribePlan,
165
+ },
166
+ });
167
+ }
149
168
  }
150
169
  }
151
170
  }
@@ -170,39 +189,51 @@ function makeGrafastSchema(details) {
170
189
  const inputObjectPlans = plans[astType.name];
171
190
  if (inputObjectPlans) {
172
191
  for (const [fieldName, fieldSpec] of Object.entries(inputObjectPlans)) {
173
- if (fieldName === "__inputPlan") {
174
- config.extensions.grafast.inputPlan =
192
+ if (fieldName === "__baked") {
193
+ config.extensions.grafast.baked =
175
194
  fieldSpec;
176
195
  continue;
177
196
  }
197
+ if (config.extensions?.grafast?.baked) {
198
+ (0, utils_js_1.exportNameHint)(config.extensions.grafast.baked, `${typeName}__baked`);
199
+ }
178
200
  const field = rawConfig.fields[fieldName];
179
201
  if (!field) {
180
202
  console.warn(`'plans' specified configuration for input object type '${typeName}' field '${fieldName}', but that field was not present in the type`);
181
203
  continue;
182
204
  }
183
- if (typeof fieldSpec === "function") {
184
- throw new Error(`Expected input object type '${typeName}' field '${fieldName}' to be an object, but found a function. We don't know if this should be the 'inputPlan' or 'applyPlan' - please supply an object.`);
185
- }
186
205
  }
187
206
  }
188
207
  const rawFields = rawConfig.fields;
189
208
  config.fields = function () {
190
209
  const fields = Object.create(null);
191
210
  for (const [fieldName, rawFieldConfig] of Object.entries(rawFields)) {
192
- const fieldSpec = inputObjectPlans?.[fieldName];
211
+ const fieldSpec = inputObjectPlans && Object.hasOwn(inputObjectPlans, fieldName)
212
+ ? inputObjectPlans[fieldName]
213
+ : undefined;
193
214
  const fieldConfig = {
194
215
  ...rawFieldConfig,
195
216
  type: mapType(rawFieldConfig.type),
196
217
  };
197
218
  fields[fieldName] = fieldConfig;
198
219
  if (fieldSpec) {
199
- (0, utils_js_1.exportNameHint)(fieldSpec.inputPlan, `${typeName}_${fieldName}_inputPlan`);
200
- (0, utils_js_1.exportNameHint)(fieldSpec.applyPlan, `${typeName}_${fieldName}_applyPlan`);
220
+ const grafastExtensions = Object.create(null);
221
+ fieldConfig.extensions.grafast = grafastExtensions;
222
+ if (typeof fieldSpec === "function") {
223
+ (0, utils_js_1.exportNameHint)(fieldSpec, `${typeName}_${fieldName}_apply`);
224
+ grafastExtensions.apply = fieldSpec;
225
+ }
226
+ else {
227
+ const { apply, extensions } = fieldSpec;
228
+ if (extensions) {
229
+ Object.assign(fieldConfig.extensions, extensions);
230
+ }
231
+ if (apply) {
232
+ (0, utils_js_1.exportNameHint)(fieldSpec.apply, `${typeName}_${fieldName}_apply`);
233
+ Object.assign(grafastExtensions, { apply });
234
+ }
235
+ }
201
236
  }
202
- // it's a spec
203
- const grafastExtensions = Object.create(null);
204
- fieldConfig.extensions.grafast = grafastExtensions;
205
- Object.assign(grafastExtensions, fieldSpec);
206
237
  }
207
238
  return fields;
208
239
  };
@@ -299,22 +330,26 @@ function makeGrafastSchema(details) {
299
330
  continue;
300
331
  }
301
332
  if (typeof enumValueSpec === "function") {
302
- (0, utils_js_1.exportNameHint)(enumValueSpec, `${typeName}_${enumValueName}_applyPlan`);
333
+ (0, utils_js_1.exportNameHint)(enumValueSpec, `${typeName}_${enumValueName}_apply`);
303
334
  // It's a plan
304
335
  if (!enumValue.extensions) {
305
336
  enumValue.extensions = Object.create(null);
306
337
  }
307
338
  enumValue.extensions.grafast = {
308
- applyPlan: enumValueSpec,
339
+ apply: enumValueSpec,
309
340
  };
310
341
  }
311
342
  else if (typeof enumValueSpec === "object" &&
312
343
  enumValueSpec != null) {
313
344
  // It's a full spec
314
- if (enumValueSpec.applyPlan) {
315
- (0, utils_js_1.exportNameHint)(enumValueSpec.applyPlan, `${typeName}_${enumValueName}_applyPlan`);
345
+ if (enumValueSpec.extensions) {
346
+ (0, utils_js_1.exportNameHint)(enumValueSpec.extensions, `${typeName}_${enumValueName}_extensions`);
347
+ Object.assign(enumValue.extensions, enumValueSpec.extensions);
348
+ }
349
+ if (enumValueSpec.apply) {
350
+ (0, utils_js_1.exportNameHint)(enumValueSpec.apply, `${typeName}_${enumValueName}_apply`);
316
351
  enumValue.extensions.grafast = {
317
- applyPlan: enumValueSpec.applyPlan,
352
+ apply: enumValueSpec.apply,
318
353
  };
319
354
  }
320
355
  if ("value" in enumValueSpec) {
@@ -356,5 +391,4 @@ function makeGrafastSchema(details) {
356
391
  const schema = new graphql_1.GraphQLSchema(schemaConfig);
357
392
  return schema;
358
393
  }
359
- exports.makeGrafastSchema = makeGrafastSchema;
360
394
  //# sourceMappingURL=makeGrafastSchema.js.map
package/dist/mermaid.js CHANGED
@@ -3,7 +3,8 @@
3
3
  * This file contains all our utilities for dealing with Mermaid-js
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.planToMermaid = exports.mermaidEscape = exports.COLORS = void 0;
6
+ exports.mermaidEscape = exports.COLORS = void 0;
7
+ exports.planToMermaid = planToMermaid;
7
8
  const tslib_1 = require("tslib");
8
9
  const stripAnsi_js_1 = require("./stripAnsi.js");
9
10
  /**
@@ -64,6 +65,9 @@ exports.mermaidEscape = mermaidEscape;
64
65
  function isGrafastPlanJSONv1(json) {
65
66
  return json.version === "v1";
66
67
  }
68
+ function shouldHideStep(step) {
69
+ return step.extra?.constant?.type === "undefined";
70
+ }
67
71
  function planToMermaid(planJSON, {
68
72
  // printPathRelations = false,
69
73
  concise = false, skipBuckets = global.grafastExplainMermaidSkipBuckets ?? false, } = {}) {
@@ -125,6 +129,9 @@ concise = false, skipBuckets = global.grafastExplainMermaidSkipBuckets ?? false,
125
129
  const planIdMap = Object.create(null);
126
130
  const planId = (plan) => {
127
131
  if (!planIdMap[plan.id]) {
132
+ if (shouldHideStep(plan)) {
133
+ console.warn(`Was expecting to hide step ${plan.id}, but we're rendering it anyway?`);
134
+ }
128
135
  const planName = plan.stepClass.replace(/Step$/, "");
129
136
  const planNode = `${planName}${plan.id}`;
130
137
  planIdMap[plan.id] = planNode;
@@ -137,7 +144,7 @@ concise = false, skipBuckets = global.grafastExplainMermaidSkipBuckets ?? false,
137
144
  pp(stepById[plan.dependencyIds[0]].polymorphicPaths) === polyPaths
138
145
  ? ""
139
146
  : `\n${polyPaths}`;
140
- const planString = `${planName}[${plan.id}${`∈${plan.bucketId}`}]${plan.isUnary ? " ➊" : ""}${meta ? `\n<${meta}>` : ""}${polyPathsIfDifferent}`;
147
+ const planString = `${planName}[${plan.id}${`∈${plan.bucketId}`}${plan.stream ? "@s" : ""}]${plan.isUnary ? " ➊" : ""}${meta ? `\n<${meta}>` : ""}${polyPathsIfDifferent}`;
141
148
  const [lBrace, rBrace] = plan.stepClass === "__ItemStep"
142
149
  ? ["[/", "\\]"]
143
150
  : plan.isSyncAndSafe
@@ -188,10 +195,20 @@ concise = false, skipBuckets = global.grafastExplainMermaidSkipBuckets ?? false,
188
195
  sortedSteps.forEach(
189
196
  // This comment is here purely to maintain the previous formatting to reduce a git diff.
190
197
  (plan) => {
198
+ if (shouldHideStep(plan))
199
+ return;
191
200
  const planNode = planId(plan);
192
- const depNodes = plan.dependencyIds.map((depId) => {
193
- return planId(stepById[depId]);
194
- });
201
+ const depNodes = plan.dependencyIds
202
+ .map((depId) => {
203
+ const step = stepById[depId];
204
+ if (shouldHideStep(step)) {
205
+ return null;
206
+ }
207
+ else {
208
+ return planId(step);
209
+ }
210
+ })
211
+ .filter((n) => n !== null);
195
212
  const transformItemPlanNode = null;
196
213
  /*
197
214
  plan.stepClass === '__ListTransformStep'
@@ -217,9 +234,7 @@ concise = false, skipBuckets = global.grafastExplainMermaidSkipBuckets ?? false,
217
234
  normal.push(r);
218
235
  }
219
236
  }
220
- if (normal.length) {
221
- graph.push(` ${normal.join(" & ")} --> ${planNode}`);
222
- }
237
+ outputGroupedNormalLinks(graph, planNode, normal);
223
238
  }
224
239
  }
225
240
  else {
@@ -248,9 +263,7 @@ concise = false, skipBuckets = global.grafastExplainMermaidSkipBuckets ?? false,
248
263
  normal.push(r);
249
264
  }
250
265
  }
251
- if (normal.length) {
252
- graph.push(` ${normal.join(" & ")} --> ${planNode}`);
253
- }
266
+ outputGroupedNormalLinks(graph, planNode, normal);
254
267
  }
255
268
  }
256
269
  }
@@ -262,7 +275,9 @@ concise = false, skipBuckets = global.grafastExplainMermaidSkipBuckets ?? false,
262
275
  graph.push("");
263
276
  graph.push(" %% define steps");
264
277
  sortedSteps.forEach((step) => {
265
- planId(step);
278
+ if (!shouldHideStep(step)) {
279
+ planId(step);
280
+ }
266
281
  });
267
282
  const stepToString = (step) => {
268
283
  return `${step.stepClass.replace(/Step$/, "")}${step.bucketId === 0 ? "" : `{${step.bucketId}}`}${step.metaString ? `<${step.metaString}>` : ""}[${step.id}]`;
@@ -304,7 +319,10 @@ concise = false, skipBuckets = global.grafastExplainMermaidSkipBuckets ?? false,
304
319
  : ""}${startSteps(layerPlan)}`)}):::bucket`);
305
320
  }
306
321
  graph.push(` classDef bucket${layerPlan.id} stroke:${color(layerPlan.id)}`);
307
- graph.push(` class ${[`Bucket${layerPlan.id}`, ...steps.map(planId)].join(",")} bucket${layerPlan.id}`);
322
+ graph.push(` class ${[
323
+ `Bucket${layerPlan.id}`,
324
+ ...steps.filter((s) => !shouldHideStep(s)).map(planId),
325
+ ].join(",")} bucket${layerPlan.id}`);
308
326
  }
309
327
  if (!skipBuckets) {
310
328
  for (let i = 0, l = layerPlans.length; i < l; i++) {
@@ -344,7 +362,6 @@ concise = false, skipBuckets = global.grafastExplainMermaidSkipBuckets ?? false,
344
362
  .join("\n")}`;
345
363
  }
346
364
  }
347
- exports.planToMermaid = planToMermaid;
348
365
  function pp(polymorphicPaths) {
349
366
  if (!polymorphicPaths) {
350
367
  return "";
@@ -360,4 +377,26 @@ function trim(string, length = 15) {
360
377
  return string;
361
378
  }
362
379
  }
380
+ function outputGroupedNormalLinks(graph, planNode, normal) {
381
+ if (normal.length) {
382
+ const counts = Object.create(null);
383
+ for (const n of normal) {
384
+ if (counts[n]) {
385
+ counts[n]++;
386
+ }
387
+ else {
388
+ counts[n] = 1;
389
+ }
390
+ }
391
+ const oners = Object.keys(counts).filter((n) => counts[n] === 1);
392
+ if (oners.length >= 1) {
393
+ graph.push(` ${oners.join(" & ")} --> ${planNode}`);
394
+ }
395
+ for (const [n, c] of Object.entries(counts)) {
396
+ if (c !== 1) {
397
+ graph.push(` ${n} -- ${c} --> ${planNode}`);
398
+ }
399
+ }
400
+ }
401
+ }
363
402
  //# sourceMappingURL=mermaid.js.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getGrafastMiddleware = void 0;
3
+ exports.getGrafastMiddleware = getGrafastMiddleware;
4
4
  const graphile_config_1 = require("graphile-config");
5
5
  const $$middleware = Symbol("middleware");
6
6
  function getGrafastMiddleware(resolvedPreset) {
@@ -21,5 +21,4 @@ function getGrafastMiddleware(resolvedPreset) {
21
21
  }
22
22
  return middleware;
23
23
  }
24
- exports.getGrafastMiddleware = getGrafastMiddleware;
25
24
  //# sourceMappingURL=middleware.js.map
@@ -1,19 +1,19 @@
1
- import { ExecutableStep } from "./step.js";
1
+ import { Step } from "./step.js";
2
2
  /**
3
3
  * When using this, always use `const`! Otherwise tuples will show up as arrays
4
4
  * and break things.
5
5
  */
6
- export type Multistep = null | undefined | ExecutableStep | readonly [...(readonly ExecutableStep[])] | Record<string, ExecutableStep>;
7
- export type UnwrapMultistep<TMultistepSpec extends Multistep> = TMultistepSpec extends null ? null : TMultistepSpec extends undefined ? undefined : TMultistepSpec extends ExecutableStep<infer U> ? U : TMultistepSpec extends readonly [...(readonly any[])] ? {
8
- [index in keyof TMultistepSpec]: TMultistepSpec[index] extends ExecutableStep<infer V> ? V : never;
6
+ export type Multistep = null | undefined | Step | readonly [...(readonly Step[])] | Record<string, Step>;
7
+ export type UnwrapMultistep<TMultistepSpec extends Multistep> = TMultistepSpec extends null ? null : TMultistepSpec extends undefined ? undefined : TMultistepSpec extends Step<infer U> ? U : TMultistepSpec extends readonly [...(readonly any[])] ? {
8
+ [index in keyof TMultistepSpec]: TMultistepSpec[index] extends Step<infer V> ? V : never;
9
9
  } : {
10
- [key in keyof TMultistepSpec]: TMultistepSpec[key] extends ExecutableStep<infer V> ? V : never;
10
+ [key in keyof TMultistepSpec]: TMultistepSpec[key] extends Step<infer V> ? V : never;
11
11
  };
12
12
  interface MultistepCacheConfig {
13
13
  identifier: string;
14
14
  cacheSize: number;
15
15
  }
16
- export declare function multistep<const TMultistepSpec extends Multistep>(spec: TMultistepSpec, stable?: string | true | MultistepCacheConfig): ExecutableStep<UnwrapMultistep<TMultistepSpec>>;
16
+ export declare function multistep<const TMultistepSpec extends Multistep>(spec: TMultistepSpec, stable?: string | true | MultistepCacheConfig): Step<UnwrapMultistep<TMultistepSpec>>;
17
17
  export declare function isMultistep<const TMultistepSpec extends Multistep>(spec: any): spec is TMultistepSpec;
18
18
  export {};
19
19
  //# sourceMappingURL=multistep.d.ts.map
package/dist/multistep.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isMultistep = exports.multistep = void 0;
3
+ exports.multistep = multistep;
4
+ exports.isMultistep = isMultistep;
4
5
  const step_js_1 = require("./step.js");
5
6
  const constant_js_1 = require("./steps/constant.js");
6
7
  const list_js_1 = require("./steps/list.js");
@@ -10,7 +11,7 @@ function multistep(spec, stable) {
10
11
  if (spec == null) {
11
12
  return (0, constant_js_1.constant)(spec);
12
13
  }
13
- else if (spec instanceof step_js_1.ExecutableStep) {
14
+ else if (spec instanceof step_js_1.Step) {
14
15
  return spec;
15
16
  }
16
17
  else if ((0, utils_js_1.isTuple)(spec)) {
@@ -32,24 +33,22 @@ function multistep(spec, stable) {
32
33
  return $step;
33
34
  }
34
35
  }
35
- exports.multistep = multistep;
36
36
  function isMultistep(spec) {
37
37
  if (spec == null) {
38
38
  return true;
39
39
  }
40
- else if (spec instanceof step_js_1.ExecutableStep) {
40
+ else if (spec instanceof step_js_1.Step) {
41
41
  return true;
42
42
  }
43
- else if ((0, utils_js_1.isTuple)(spec) && spec.every((s) => s instanceof step_js_1.ExecutableStep)) {
43
+ else if ((0, utils_js_1.isTuple)(spec) && spec.every((s) => s instanceof step_js_1.Step)) {
44
44
  return true;
45
45
  }
46
46
  else if (typeof spec === "object" &&
47
- Object.values(spec).every((s) => s instanceof step_js_1.ExecutableStep)) {
47
+ Object.values(spec).every((s) => s instanceof step_js_1.Step)) {
48
48
  return true;
49
49
  }
50
50
  else {
51
51
  return false;
52
52
  }
53
53
  }
54
- exports.isMultistep = isMultistep;
55
54
  //# sourceMappingURL=multistep.js.map
@@ -1,7 +1,8 @@
1
- import type { GraphQLField } from "graphql";
1
+ import type { GraphQLField, GraphQLInputType, GraphQLNullableType } from "graphql";
2
2
  import type { OperationPlan } from "./engine/OperationPlan.js";
3
3
  import type { FieldArgs, TrackedArguments } from "./interfaces.js";
4
- import type { ExecutableStep } from "./step.js";
5
- export type ApplyAfterModeArg = "autoApplyAfterParentPlan" | "autoApplyAfterParentSubscribePlan";
6
- export declare function withFieldArgsForArguments<T extends ExecutableStep, TParentStep extends ExecutableStep = ExecutableStep>(operationPlan: OperationPlan, $parent: TParentStep, $all: TrackedArguments, field: GraphQLField<any, any, any>, applyAfterMode: ApplyAfterModeArg, callback: (fieldArgs: FieldArgs) => T | null | undefined): Exclude<T, undefined | null> | null;
4
+ import type { Step } from "./step.js";
5
+ export type ApplyAfterModeArg = "plan" | "subscribePlan";
6
+ export declare function withFieldArgsForArguments<T extends Step>(operationPlan: OperationPlan, $all: TrackedArguments, field: GraphQLField<any, any, any>, $parent: Step, applyAfterMode: ApplyAfterModeArg, coordinate: string, callback: (fieldArgs: FieldArgs) => T | null | undefined): Exclude<T, undefined | null> | null;
7
+ export declare function getNullableInputTypeAtPath(startType: GraphQLInputType, path: ReadonlyArray<string | number>): GraphQLInputType & GraphQLNullableType;
7
8
  //# sourceMappingURL=operationPlan-input.d.ts.map