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.
- package/README.md +2 -3
- package/dist/args.d.ts +4 -7
- package/dist/args.js +53 -38
- package/dist/assert.js +2 -3
- package/dist/bucket.d.ts +1 -89
- package/dist/config.d.ts +0 -17
- package/dist/config.js +1 -95
- package/dist/constraints.d.ts +15 -1
- package/dist/constraints.js +41 -3
- package/dist/deferred.js +1 -2
- package/dist/dev.d.ts +1 -4
- package/dist/dev.js +18 -3
- package/dist/engine/LayerPlan.d.ts +21 -111
- package/dist/engine/LayerPlan.js +196 -78
- package/dist/engine/OperationPlan.d.ts +30 -104
- package/dist/engine/OperationPlan.js +763 -471
- package/dist/engine/OutputPlan.d.ts +9 -20
- package/dist/engine/OutputPlan.js +432 -444
- package/dist/engine/StepTracker.d.ts +1 -95
- package/dist/engine/StepTracker.js +94 -20
- package/dist/engine/executeBucket.d.ts +5 -7
- package/dist/engine/executeBucket.js +646 -244
- package/dist/engine/executeOutputPlan.d.ts +0 -53
- package/dist/engine/executeOutputPlan.js +7 -2
- package/dist/engine/lib/defaultPlanResolver.d.ts +6 -0
- package/dist/engine/lib/defaultPlanResolver.js +11 -0
- package/dist/engine/lib/withGlobalLayerPlan.d.ts +2 -0
- package/dist/engine/lib/withGlobalLayerPlan.js +7 -4
- package/dist/engine/lock.d.ts +4 -0
- package/dist/engine/lock.js +82 -0
- package/dist/envelop.js +5 -4
- package/dist/error.d.ts +18 -49
- package/dist/error.js +50 -39
- package/dist/establishOperationPlan.js +57 -42
- package/dist/execute.d.ts +5 -4
- package/dist/execute.js +31 -15
- package/dist/exportAs.d.ts +1 -18
- package/dist/exportAs.js +2 -3
- package/dist/global.js +2 -3
- package/dist/grafastGraphql.d.ts +6 -1
- package/dist/grafastGraphql.js +35 -16
- package/dist/grafastPrint.d.ts +3 -0
- package/dist/grafastPrint.js +67 -6
- package/dist/graphqlCollectFields.d.ts +7 -34
- package/dist/graphqlCollectFields.js +24 -13
- package/dist/graphqlMergeSelectionSets.js +1 -2
- package/dist/index.d.ts +44 -29
- package/dist/index.js +91 -18
- package/dist/input.d.ts +1 -9
- package/dist/input.js +75 -28
- package/dist/inspect.d.ts +9 -3
- package/dist/inspect.js +3 -3
- package/dist/interfaces.d.ts +238 -93
- package/dist/interfaces.js +20 -3
- package/dist/makeGrafastSchema.d.ts +21 -9
- package/dist/makeGrafastSchema.js +353 -133
- package/dist/mermaid.d.ts +0 -17
- package/dist/mermaid.js +131 -19
- package/dist/middleware.d.ts +7 -0
- package/dist/middleware.js +24 -0
- package/dist/multistep.d.ts +19 -0
- package/dist/multistep.js +54 -0
- package/dist/operationPlan-input.d.ts +5 -4
- package/dist/operationPlan-input.js +140 -368
- package/dist/planJSONInterfaces.d.ts +12 -2
- package/dist/polymorphic.js +4 -5
- package/dist/prepare.d.ts +1 -7
- package/dist/prepare.js +100 -74
- package/dist/step.d.ts +118 -172
- package/dist/step.js +262 -183
- package/dist/steps/__flag.d.ts +65 -0
- package/dist/steps/__flag.js +261 -0
- package/dist/steps/__inputDefault.d.ts +14 -0
- package/dist/steps/__inputDefault.js +48 -0
- package/dist/steps/__inputDynamicScalar.d.ts +4 -6
- package/dist/steps/__inputDynamicScalar.js +4 -2
- package/dist/steps/__inputList.d.ts +5 -9
- package/dist/steps/__inputList.js +4 -1
- package/dist/steps/__inputObject.d.ts +7 -11
- package/dist/steps/__inputObject.js +49 -3
- package/dist/steps/__inputStaticLeaf.d.ts +2 -4
- package/dist/steps/__inputStaticLeaf.js +3 -1
- package/dist/steps/__item.d.ts +10 -12
- package/dist/steps/__item.js +8 -2
- package/dist/steps/__trackedValue.d.ts +7 -55
- package/dist/steps/__trackedValue.js +69 -8
- package/dist/steps/__value.d.ts +5 -4
- package/dist/steps/__value.js +5 -4
- package/dist/steps/access.d.ts +10 -10
- package/dist/steps/access.js +50 -17
- package/dist/steps/applyInput.d.ts +44 -0
- package/dist/steps/applyInput.js +206 -0
- package/dist/steps/applyTransforms.d.ts +2 -25
- package/dist/steps/applyTransforms.js +53 -31
- package/dist/steps/bakedInput.d.ts +23 -0
- package/dist/steps/bakedInput.js +90 -0
- package/dist/steps/condition.d.ts +31 -0
- package/dist/steps/condition.js +94 -0
- package/dist/steps/connection.d.ts +56 -42
- package/dist/steps/connection.js +97 -44
- package/dist/steps/constant.d.ts +7 -7
- package/dist/steps/constant.js +86 -7
- package/dist/steps/each.d.ts +3 -3
- package/dist/steps/each.js +2 -3
- package/dist/steps/error.d.ts +4 -4
- package/dist/steps/error.js +7 -6
- package/dist/steps/filter.d.ts +3 -2
- package/dist/steps/filter.js +1 -2
- package/dist/steps/first.d.ts +10 -9
- package/dist/steps/first.js +9 -13
- package/dist/steps/graphqlResolver.d.ts +3 -76
- package/dist/steps/graphqlResolver.js +89 -72
- package/dist/steps/groupBy.d.ts +3 -2
- package/dist/steps/groupBy.js +1 -2
- package/dist/steps/index.d.ts +12 -3
- package/dist/steps/index.js +48 -6
- package/dist/steps/lambda.d.ts +9 -9
- package/dist/steps/lambda.js +18 -9
- package/dist/steps/last.d.ts +9 -8
- package/dist/steps/last.js +7 -6
- package/dist/steps/list.d.ts +20 -9
- package/dist/steps/list.js +56 -13
- package/dist/steps/listTransform.d.ts +18 -22
- package/dist/steps/listTransform.js +58 -27
- package/dist/steps/listen.d.ts +6 -11
- package/dist/steps/listen.js +14 -16
- package/dist/steps/load.d.ts +42 -33
- package/dist/steps/load.js +60 -27
- package/dist/steps/node.d.ts +17 -10
- package/dist/steps/node.js +18 -6
- package/dist/steps/object.d.ts +33 -27
- package/dist/steps/object.js +53 -32
- package/dist/steps/partitionByIndex.d.ts +3 -2
- package/dist/steps/partitionByIndex.js +1 -2
- package/dist/steps/polymorphicBranch.d.ts +27 -0
- package/dist/steps/polymorphicBranch.js +62 -0
- package/dist/steps/proxy.d.ts +11 -12
- package/dist/steps/proxy.js +8 -5
- package/dist/steps/remapKeys.d.ts +10 -10
- package/dist/steps/remapKeys.js +14 -7
- package/dist/steps/reverse.d.ts +8 -8
- package/dist/steps/reverse.js +10 -7
- package/dist/steps/setter.d.ts +9 -18
- package/dist/steps/setter.js +24 -14
- package/dist/steps/sideEffect.d.ts +28 -0
- package/dist/steps/sideEffect.js +44 -0
- package/dist/stringifyPayload.js +1 -2
- package/dist/stripAnsi.js +2 -2
- package/dist/subscribe.d.ts +7 -1
- package/dist/subscribe.js +24 -9
- package/dist/thereCanBeOnlyOne.js +1 -1
- package/dist/timeSource.d.ts +0 -1
- package/dist/utils.d.ts +56 -55
- package/dist/utils.js +179 -59
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -8
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.
|
|
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}`}]${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
|
|
@@ -159,13 +166,49 @@ concise = false, skipBuckets = global.grafastExplainMermaidSkipBuckets ?? false,
|
|
|
159
166
|
graph.push("");
|
|
160
167
|
graph.push(" %% plan dependencies");
|
|
161
168
|
const chainByDep = Object.create(null);
|
|
169
|
+
const depDeets = (step, idx) => {
|
|
170
|
+
const forbiddenFlags = step.dependencyForbiddenFlags[idx];
|
|
171
|
+
const onReject = step.dependencyOnReject[idx];
|
|
172
|
+
const info = [];
|
|
173
|
+
if (forbiddenFlags) {
|
|
174
|
+
if ((forbiddenFlags & 2) === 2) {
|
|
175
|
+
info.push("rejectNull");
|
|
176
|
+
}
|
|
177
|
+
if ((forbiddenFlags & 1) === 0) {
|
|
178
|
+
info.push("trapError");
|
|
179
|
+
}
|
|
180
|
+
if ((forbiddenFlags & 4) === 0) {
|
|
181
|
+
info.push("trapInhibited");
|
|
182
|
+
}
|
|
183
|
+
if (onReject) {
|
|
184
|
+
info.push(`onReject=${trim((0, stripAnsi_js_1.stripAnsi)(onReject))}`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const str = info.join(";");
|
|
188
|
+
if (str) {
|
|
189
|
+
return `|${(0, exports.mermaidEscape)(str)}|`;
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
return "";
|
|
193
|
+
}
|
|
194
|
+
};
|
|
162
195
|
sortedSteps.forEach(
|
|
163
196
|
// This comment is here purely to maintain the previous formatting to reduce a git diff.
|
|
164
197
|
(plan) => {
|
|
198
|
+
if (shouldHideStep(plan))
|
|
199
|
+
return;
|
|
165
200
|
const planNode = planId(plan);
|
|
166
|
-
const depNodes = plan.dependencyIds
|
|
167
|
-
|
|
168
|
-
|
|
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);
|
|
169
212
|
const transformItemPlanNode = null;
|
|
170
213
|
/*
|
|
171
214
|
plan.stepClass === '__ListTransformStep'
|
|
@@ -178,9 +221,20 @@ concise = false, skipBuckets = global.grafastExplainMermaidSkipBuckets ?? false,
|
|
|
178
221
|
if (plan.stepClass === "__ItemStep") {
|
|
179
222
|
const [firstDep, ...rest] = depNodes;
|
|
180
223
|
const arrow = plan.extra?.transformStepId == null ? "==>" : "-.->";
|
|
181
|
-
graph.push(` ${firstDep} ${arrow} ${planNode}`);
|
|
224
|
+
graph.push(` ${firstDep} ${arrow}${depDeets(plan, 0)} ${planNode}`);
|
|
182
225
|
if (rest.length > 0) {
|
|
183
|
-
|
|
226
|
+
const normal = [];
|
|
227
|
+
for (let i = 0; i < rest.length; i++) {
|
|
228
|
+
const r = rest[i];
|
|
229
|
+
const deets = depDeets(plan, i + 1);
|
|
230
|
+
if (deets) {
|
|
231
|
+
graph.push(` ${r} -->${deets} ${planNode}`);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
normal.push(r);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
outputGroupedNormalLinks(graph, planNode, normal);
|
|
184
238
|
}
|
|
185
239
|
}
|
|
186
240
|
else {
|
|
@@ -190,15 +244,26 @@ concise = false, skipBuckets = global.grafastExplainMermaidSkipBuckets ?? false,
|
|
|
190
244
|
// Try alternating the nodes so they render closer together
|
|
191
245
|
const depNode = depNodes[0];
|
|
192
246
|
if (chainByDep[depNode] === undefined) {
|
|
193
|
-
graph.push(` ${depNode}
|
|
247
|
+
graph.push(` ${depNode} -->${depDeets(plan, 0)} ${planNode}`);
|
|
194
248
|
}
|
|
195
249
|
else {
|
|
196
|
-
graph.push(` ${chainByDep[depNode]} o--o ${planNode}`);
|
|
250
|
+
graph.push(` ${chainByDep[depNode]} o--o${depDeets(plan, 0)} ${planNode}`);
|
|
197
251
|
}
|
|
198
252
|
chainByDep[depNode] = planNode;
|
|
199
253
|
}
|
|
200
254
|
else {
|
|
201
|
-
|
|
255
|
+
const normal = [];
|
|
256
|
+
for (let i = 0; i < depNodes.length; i++) {
|
|
257
|
+
const r = depNodes[i];
|
|
258
|
+
const deets = depDeets(plan, i + 1);
|
|
259
|
+
if (deets) {
|
|
260
|
+
graph.push(` ${r} -->${deets} ${planNode}`);
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
normal.push(r);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
outputGroupedNormalLinks(graph, planNode, normal);
|
|
202
267
|
}
|
|
203
268
|
}
|
|
204
269
|
}
|
|
@@ -210,11 +275,25 @@ concise = false, skipBuckets = global.grafastExplainMermaidSkipBuckets ?? false,
|
|
|
210
275
|
graph.push("");
|
|
211
276
|
graph.push(" %% define steps");
|
|
212
277
|
sortedSteps.forEach((step) => {
|
|
213
|
-
|
|
278
|
+
if (!shouldHideStep(step)) {
|
|
279
|
+
planId(step);
|
|
280
|
+
}
|
|
214
281
|
});
|
|
215
282
|
const stepToString = (step) => {
|
|
216
283
|
return `${step.stepClass.replace(/Step$/, "")}${step.bucketId === 0 ? "" : `{${step.bucketId}}`}${step.metaString ? `<${step.metaString}>` : ""}[${step.id}]`;
|
|
217
284
|
};
|
|
285
|
+
let firstSideEffect = true;
|
|
286
|
+
sortedSteps.forEach((step) => {
|
|
287
|
+
if (step.implicitSideEffectStepId) {
|
|
288
|
+
if (firstSideEffect) {
|
|
289
|
+
graph.push("");
|
|
290
|
+
graph.push(" %% implicit side effects");
|
|
291
|
+
firstSideEffect = false;
|
|
292
|
+
}
|
|
293
|
+
const sideEffectStep = stepById[step.implicitSideEffectStepId];
|
|
294
|
+
graph.push(` ${planId(sideEffectStep)} -.-o ${planId(step)}`);
|
|
295
|
+
}
|
|
296
|
+
});
|
|
218
297
|
graph.push("");
|
|
219
298
|
if (!concise && !skipBuckets)
|
|
220
299
|
graph.push(" subgraph Buckets");
|
|
@@ -226,20 +305,24 @@ concise = false, skipBuckets = global.grafastExplainMermaidSkipBuckets ?? false,
|
|
|
226
305
|
(layerPlan.reason.type === "polymorphic"
|
|
227
306
|
? `\n${layerPlan.reason.typeNames}`
|
|
228
307
|
: ``);
|
|
229
|
-
const outputMapStuff = [];
|
|
230
308
|
if (!skipBuckets) {
|
|
231
|
-
graph.push(` Bucket${layerPlan.id}(${(0, exports.mermaidEscape)(`Bucket ${layerPlan.id}${raisonDEtre}${layerPlan.
|
|
309
|
+
graph.push(` Bucket${layerPlan.id}(${(0, exports.mermaidEscape)(`Bucket ${layerPlan.id}${raisonDEtre}${layerPlan.parentSideEffectStepId != null
|
|
310
|
+
? `\nParent side effect step: ${stepById[layerPlan.parentSideEffectStepId].id}`
|
|
311
|
+
: ""}${layerPlan.copyStepIds.length > 0
|
|
232
312
|
? `\nDeps: ${layerPlan.copyStepIds
|
|
233
313
|
.map((pId) => stepById[pId].id)
|
|
234
|
-
.join(", ")}
|
|
314
|
+
.join(", ")}`
|
|
235
315
|
: ""}${layerPlan.reason.type === "polymorphic"
|
|
236
|
-
? pp(layerPlan.reason.polymorphicPaths)
|
|
237
|
-
: ""}${layerPlan.rootStepId != null && layerPlan.reason.type !== "root"
|
|
316
|
+
? "\n" + pp(layerPlan.reason.polymorphicPaths)
|
|
317
|
+
: ""}\n${layerPlan.rootStepId != null && layerPlan.reason.type !== "root"
|
|
238
318
|
? `\nROOT ${stepToString(stepById[layerPlan.rootStepId])}`
|
|
239
|
-
: ""}${startSteps(layerPlan)}
|
|
319
|
+
: ""}${startSteps(layerPlan)}`)}):::bucket`);
|
|
240
320
|
}
|
|
241
321
|
graph.push(` classDef bucket${layerPlan.id} stroke:${color(layerPlan.id)}`);
|
|
242
|
-
graph.push(` class ${[
|
|
322
|
+
graph.push(` class ${[
|
|
323
|
+
`Bucket${layerPlan.id}`,
|
|
324
|
+
...steps.filter((s) => !shouldHideStep(s)).map(planId),
|
|
325
|
+
].join(",")} bucket${layerPlan.id}`);
|
|
243
326
|
}
|
|
244
327
|
if (!skipBuckets) {
|
|
245
328
|
for (let i = 0, l = layerPlans.length; i < l; i++) {
|
|
@@ -279,7 +362,6 @@ concise = false, skipBuckets = global.grafastExplainMermaidSkipBuckets ?? false,
|
|
|
279
362
|
.join("\n")}`;
|
|
280
363
|
}
|
|
281
364
|
}
|
|
282
|
-
exports.planToMermaid = planToMermaid;
|
|
283
365
|
function pp(polymorphicPaths) {
|
|
284
366
|
if (!polymorphicPaths) {
|
|
285
367
|
return "";
|
|
@@ -287,4 +369,34 @@ function pp(polymorphicPaths) {
|
|
|
287
369
|
return polymorphicPaths.map((p) => `${p}`).join("\n");
|
|
288
370
|
}
|
|
289
371
|
tslib_1.__exportStar(require("./planJSONInterfaces.js"), exports);
|
|
372
|
+
function trim(string, length = 15) {
|
|
373
|
+
if (string.length > length) {
|
|
374
|
+
return string.substring(0, length - 2) + "…";
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
return string;
|
|
378
|
+
}
|
|
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
|
+
}
|
|
290
402
|
//# sourceMappingURL=mermaid.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Middleware } from "graphile-config";
|
|
2
|
+
declare const $$middleware: unique symbol;
|
|
3
|
+
export declare function getGrafastMiddleware(resolvedPreset: GraphileConfig.ResolvedPreset & {
|
|
4
|
+
[$$middleware]?: Middleware<GraphileConfig.GrafastMiddleware> | null;
|
|
5
|
+
}): Middleware<GraphileConfig.GrafastMiddleware> | null;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGrafastMiddleware = getGrafastMiddleware;
|
|
4
|
+
const graphile_config_1 = require("graphile-config");
|
|
5
|
+
const $$middleware = Symbol("middleware");
|
|
6
|
+
function getGrafastMiddleware(resolvedPreset) {
|
|
7
|
+
if (resolvedPreset[$$middleware] !== undefined) {
|
|
8
|
+
return resolvedPreset[$$middleware];
|
|
9
|
+
}
|
|
10
|
+
let middleware = null;
|
|
11
|
+
(0, graphile_config_1.orderedApply)(resolvedPreset.plugins, (p) => p.grafast?.middleware, (name, fn, _plugin) => {
|
|
12
|
+
if (!middleware)
|
|
13
|
+
middleware = new graphile_config_1.Middleware();
|
|
14
|
+
middleware.register(name, fn);
|
|
15
|
+
});
|
|
16
|
+
try {
|
|
17
|
+
resolvedPreset[$$middleware] = middleware;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// Ignore - preset must be readonly
|
|
21
|
+
}
|
|
22
|
+
return middleware;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Step } from "./step.js";
|
|
2
|
+
/**
|
|
3
|
+
* When using this, always use `const`! Otherwise tuples will show up as arrays
|
|
4
|
+
* and break things.
|
|
5
|
+
*/
|
|
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
|
+
} : {
|
|
10
|
+
[key in keyof TMultistepSpec]: TMultistepSpec[key] extends Step<infer V> ? V : never;
|
|
11
|
+
};
|
|
12
|
+
interface MultistepCacheConfig {
|
|
13
|
+
identifier: string;
|
|
14
|
+
cacheSize: number;
|
|
15
|
+
}
|
|
16
|
+
export declare function multistep<const TMultistepSpec extends Multistep>(spec: TMultistepSpec, stable?: string | true | MultistepCacheConfig): Step<UnwrapMultistep<TMultistepSpec>>;
|
|
17
|
+
export declare function isMultistep<const TMultistepSpec extends Multistep>(spec: any): spec is TMultistepSpec;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=multistep.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.multistep = multistep;
|
|
4
|
+
exports.isMultistep = isMultistep;
|
|
5
|
+
const step_js_1 = require("./step.js");
|
|
6
|
+
const constant_js_1 = require("./steps/constant.js");
|
|
7
|
+
const list_js_1 = require("./steps/list.js");
|
|
8
|
+
const object_js_1 = require("./steps/object.js");
|
|
9
|
+
const utils_js_1 = require("./utils.js");
|
|
10
|
+
function multistep(spec, stable) {
|
|
11
|
+
if (spec == null) {
|
|
12
|
+
return (0, constant_js_1.constant)(spec);
|
|
13
|
+
}
|
|
14
|
+
else if (spec instanceof step_js_1.Step) {
|
|
15
|
+
return spec;
|
|
16
|
+
}
|
|
17
|
+
else if ((0, utils_js_1.isTuple)(spec)) {
|
|
18
|
+
const config = stable === true
|
|
19
|
+
? { identifier: `multistep` }
|
|
20
|
+
: typeof stable === "string"
|
|
21
|
+
? { identifier: stable }
|
|
22
|
+
: stable;
|
|
23
|
+
const $step = (0, list_js_1.list)(spec, config);
|
|
24
|
+
return $step;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const config = stable === true
|
|
28
|
+
? { identifier: `multistep` }
|
|
29
|
+
: typeof stable === "string"
|
|
30
|
+
? { identifier: stable }
|
|
31
|
+
: stable;
|
|
32
|
+
const $step = (0, object_js_1.object)(spec, config);
|
|
33
|
+
return $step;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function isMultistep(spec) {
|
|
37
|
+
if (spec == null) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
else if (spec instanceof step_js_1.Step) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
else if ((0, utils_js_1.isTuple)(spec) && spec.every((s) => s instanceof step_js_1.Step)) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
else if (typeof spec === "object" &&
|
|
47
|
+
Object.values(spec).every((s) => s instanceof step_js_1.Step)) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
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 {
|
|
5
|
-
export type ApplyAfterModeArg = "
|
|
6
|
-
export declare function withFieldArgsForArguments<T extends
|
|
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
|