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/prepare.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type { ExecutionArgs } from "graphql";
|
|
2
|
-
import type { AsyncExecutionResult, ExecutionResult } from "graphql/execution/execute";
|
|
3
1
|
import type { GrafastPlanJSON } from "./index.js";
|
|
4
|
-
import type { GrafastTimeouts
|
|
2
|
+
import type { GrafastTimeouts } from "./interfaces.js";
|
|
5
3
|
declare const $$contextPlanCache: unique symbol;
|
|
6
4
|
export interface GrafastPrepareOptions {
|
|
7
5
|
/**
|
|
@@ -26,9 +24,5 @@ declare module "./engine/OperationPlan.js" {
|
|
|
26
24
|
[$$contextPlanCache]?: GrafastPlanJSON;
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
|
-
/**
|
|
30
|
-
* @internal
|
|
31
|
-
*/
|
|
32
|
-
export declare function grafastPrepare(args: ExecutionArgs, options?: GrafastPrepareOptions): PromiseOrDirect<ExecutionResult | AsyncGenerator<AsyncExecutionResult, void, void>>;
|
|
33
27
|
export {};
|
|
34
28
|
//# sourceMappingURL=prepare.d.ts.map
|
package/dist/prepare.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.grafastPrepare =
|
|
3
|
+
exports.grafastPrepare = grafastPrepare;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const graphql = tslib_1.__importStar(require("graphql"));
|
|
6
6
|
const execute_1 = require("graphql/execution/execute");
|
|
@@ -12,7 +12,6 @@ const executeBucket_js_1 = require("./engine/executeBucket.js");
|
|
|
12
12
|
const executeOutputPlan_js_1 = require("./engine/executeOutputPlan.js");
|
|
13
13
|
const OperationPlan_js_1 = require("./engine/OperationPlan.js");
|
|
14
14
|
const OutputPlan_js_1 = require("./engine/OutputPlan.js");
|
|
15
|
-
const error_js_1 = require("./error.js");
|
|
16
15
|
const establishOperationPlan_js_1 = require("./establishOperationPlan.js");
|
|
17
16
|
const interfaces_js_1 = require("./interfaces.js");
|
|
18
17
|
const timeSource_js_1 = require("./timeSource.js");
|
|
@@ -153,7 +152,7 @@ function outputBucket(outputPlan, rootBucket, rootBucketIndex, requestContext, p
|
|
|
153
152
|
childBucketIndex = rootBucketIndex;
|
|
154
153
|
}
|
|
155
154
|
else {
|
|
156
|
-
const c = (0, OutputPlan_js_1.getChildBucketAndIndex)(outputPlan, null, rootBucket, rootBucketIndex, null);
|
|
155
|
+
const c = (0, OutputPlan_js_1.getChildBucketAndIndex)(outputPlan.layerPlan, null, rootBucket, rootBucketIndex, null);
|
|
157
156
|
if (!c) {
|
|
158
157
|
throw new Error(`GrafastInternalError<8bbf56c1-8e2a-4ee9-b5fc-724fd0ee222b>: could not find relevant bucket for output plan`);
|
|
159
158
|
}
|
|
@@ -172,34 +171,27 @@ function outputBucket(outputPlan, rootBucket, rootBucketIndex, requestContext, p
|
|
|
172
171
|
releaseUnusedIterators(rootBucket, rootBucketIndex, ctx.root.streams);
|
|
173
172
|
}
|
|
174
173
|
}
|
|
175
|
-
function executePreemptive(operationPlan, variableValues, context, rootValue, outputDataAsString, executionTimeout) {
|
|
176
|
-
// PERF: batch this method so it can process multiple GraphQL requests in parallel
|
|
177
|
-
// TODO: when we batch, we need to change `rootBucketIndex` and `size`, and make sure that we only batch where `executionTimeout` is the same.
|
|
174
|
+
function executePreemptive(args, operationPlan, variableValues, context, rootValue, outputDataAsString, executionTimeout) {
|
|
178
175
|
const rootBucketIndex = 0;
|
|
179
176
|
const size = 1;
|
|
180
|
-
const requestIndex = [0];
|
|
181
|
-
const vars = [variableValues];
|
|
182
|
-
const ctxs = [context];
|
|
183
|
-
const rvs = [rootValue];
|
|
184
177
|
const polymorphicPathList = [OperationPlan_js_1.POLYMORPHIC_ROOT_PATH];
|
|
185
178
|
const iterators = [new Set()];
|
|
186
179
|
const store = new Map();
|
|
187
|
-
store.set(
|
|
188
|
-
store.set(operationPlan.
|
|
189
|
-
store.set(operationPlan.
|
|
190
|
-
store.set(operationPlan.contextStep.id, ctxs);
|
|
191
|
-
store.set(operationPlan.rootValueStep.id, rvs);
|
|
180
|
+
store.set(operationPlan.variableValuesStep.id, (0, executeBucket_js_1.unaryExecutionValue)(variableValues));
|
|
181
|
+
store.set(operationPlan.contextStep.id, (0, executeBucket_js_1.unaryExecutionValue)(context));
|
|
182
|
+
store.set(operationPlan.rootValueStep.id, (0, executeBucket_js_1.unaryExecutionValue)(rootValue));
|
|
192
183
|
const rootBucket = (0, executeBucket_js_1.newBucket)({
|
|
193
184
|
layerPlan: operationPlan.rootLayerPlan,
|
|
194
185
|
size,
|
|
195
186
|
store,
|
|
196
|
-
|
|
187
|
+
flagUnion: 0,
|
|
197
188
|
polymorphicPathList,
|
|
198
189
|
iterators,
|
|
199
190
|
}, null);
|
|
200
191
|
const startTime = timeSource_js_1.timeSource.now();
|
|
201
192
|
const stopTime = executionTimeout !== null ? startTime + executionTimeout : null;
|
|
202
193
|
const requestContext = {
|
|
194
|
+
args,
|
|
203
195
|
startTime,
|
|
204
196
|
stopTime,
|
|
205
197
|
// toSerialize: [],
|
|
@@ -210,29 +202,33 @@ function executePreemptive(operationPlan, variableValues, context, rootValue, ou
|
|
|
210
202
|
const subscriptionLayerPlan = rootBucket.layerPlan.children.find((c) => c.reason.type === "subscription");
|
|
211
203
|
function executeStreamPayload(payload, index) {
|
|
212
204
|
const layerPlan = subscriptionLayerPlan;
|
|
205
|
+
const { rootStep } = layerPlan;
|
|
213
206
|
// PERF: we could consider batching this.
|
|
214
207
|
const store = new Map();
|
|
215
|
-
const
|
|
216
|
-
for (const depId of layerPlan.copyStepIds) {
|
|
217
|
-
store.set(depId, []);
|
|
218
|
-
}
|
|
219
|
-
store.set(layerPlan.rootStep.id, [payload]);
|
|
208
|
+
const ZERO = 0;
|
|
220
209
|
for (const depId of layerPlan.copyStepIds) {
|
|
221
|
-
store.get(depId)
|
|
222
|
-
|
|
223
|
-
|
|
210
|
+
const executionVal = rootBucket.store.get(depId);
|
|
211
|
+
// Normally this would need scaling, but not this time since we know it only represents a single entry
|
|
212
|
+
store.set(depId, executionVal);
|
|
213
|
+
}
|
|
214
|
+
const rootExecutionValue = rootStep._isUnary
|
|
215
|
+
? (0, executeBucket_js_1.unaryExecutionValue)(payload)
|
|
216
|
+
: (0, executeBucket_js_1.batchExecutionValue)([payload]);
|
|
217
|
+
store.set(rootStep.id, rootExecutionValue);
|
|
224
218
|
const subscriptionBucket = (0, executeBucket_js_1.newBucket)({
|
|
225
219
|
layerPlan,
|
|
226
220
|
store,
|
|
227
|
-
|
|
221
|
+
flagUnion: rootBucket.flagUnion,
|
|
228
222
|
polymorphicPathList: [OperationPlan_js_1.POLYMORPHIC_ROOT_PATH],
|
|
229
223
|
iterators: [new Set()],
|
|
230
224
|
size: 1, //store.size
|
|
231
225
|
}, rootBucket.metaByMetaKey);
|
|
232
226
|
const bucketPromise = (0, executeBucket_js_1.executeBucket)(subscriptionBucket, requestContext);
|
|
233
227
|
function outputStreamBucket() {
|
|
234
|
-
const [ctx, result] = outputBucket(operationPlan.rootOutputPlan, subscriptionBucket,
|
|
235
|
-
|
|
228
|
+
const [ctx, result] = outputBucket(operationPlan.rootOutputPlan, subscriptionBucket, ZERO, requestContext, [], rootBucket.store
|
|
229
|
+
.get(operationPlan.variableValuesStep.id)
|
|
230
|
+
.at(rootBucketIndex), outputDataAsString);
|
|
231
|
+
return finalize(result, ctx, index === 0 ? (rootValue[interfaces_js_1.$$extensions] ?? undefined) : undefined, outputDataAsString);
|
|
236
232
|
}
|
|
237
233
|
if ((0, utils_js_1.isPromiseLike)(bucketPromise)) {
|
|
238
234
|
return bucketPromise.then(outputStreamBucket);
|
|
@@ -244,19 +240,21 @@ function executePreemptive(operationPlan, variableValues, context, rootValue, ou
|
|
|
244
240
|
function output() {
|
|
245
241
|
// Later we'll need to loop
|
|
246
242
|
// If it's a subscription we need to use the stream
|
|
247
|
-
const
|
|
243
|
+
const bucketRootEValue = rootBucket.layerPlan.rootStep != null &&
|
|
244
|
+
rootBucket.layerPlan.rootStep.id != null
|
|
248
245
|
? rootBucket.store.get(rootBucket.layerPlan.rootStep.id)
|
|
249
246
|
: null;
|
|
250
|
-
const bucketRootValue =
|
|
251
|
-
|
|
247
|
+
const bucketRootValue = bucketRootEValue?.at(rootBucketIndex);
|
|
248
|
+
const bucketRootFlags = bucketRootEValue?._flagsAt(rootBucketIndex) ?? interfaces_js_1.NO_FLAGS;
|
|
249
|
+
if (bucketRootFlags & interfaces_js_1.FLAG_ERROR) {
|
|
252
250
|
releaseUnusedIterators(rootBucket, rootBucketIndex, null);
|
|
253
251
|
// Something major went wrong!
|
|
254
252
|
const errors = [
|
|
255
|
-
new GraphQLError(bucketRootValue.
|
|
253
|
+
new GraphQLError(bucketRootValue.message, operationPlan.rootOutputPlan.locationDetails.node, // node
|
|
256
254
|
undefined, // source
|
|
257
255
|
null, // positions
|
|
258
256
|
null, // path
|
|
259
|
-
bucketRootValue
|
|
257
|
+
bucketRootValue, // originalError
|
|
260
258
|
null),
|
|
261
259
|
];
|
|
262
260
|
const payload = Object.create(null);
|
|
@@ -267,6 +265,7 @@ function executePreemptive(operationPlan, variableValues, context, rootValue, ou
|
|
|
267
265
|
}
|
|
268
266
|
return payload;
|
|
269
267
|
}
|
|
268
|
+
// NOTE: this is where we determine whether to stream or not
|
|
270
269
|
if (bucketRootValue != null &&
|
|
271
270
|
subscriptionLayerPlan != null &&
|
|
272
271
|
Array.isArray(bucketRootValue) &&
|
|
@@ -331,7 +330,7 @@ function executePreemptive(operationPlan, variableValues, context, rootValue, ou
|
|
|
331
330
|
});
|
|
332
331
|
return iterator;
|
|
333
332
|
}
|
|
334
|
-
const [ctx, result] = outputBucket(operationPlan.rootOutputPlan, rootBucket, rootBucketIndex, requestContext, [], rootBucket.store.get(operationPlan.variableValuesStep.id)
|
|
333
|
+
const [ctx, result] = outputBucket(operationPlan.rootOutputPlan, rootBucket, rootBucketIndex, requestContext, [], rootBucket.store.get(operationPlan.variableValuesStep.id).at(0), outputDataAsString);
|
|
335
334
|
return finalize(result, ctx, rootValue[interfaces_js_1.$$extensions] ?? undefined, outputDataAsString);
|
|
336
335
|
}
|
|
337
336
|
if ((0, utils_js_1.isPromiseLike)(bucketPromise)) {
|
|
@@ -341,14 +340,17 @@ function executePreemptive(operationPlan, variableValues, context, rootValue, ou
|
|
|
341
340
|
return output();
|
|
342
341
|
}
|
|
343
342
|
}
|
|
343
|
+
function establishOperationPlanFromEvent(event) {
|
|
344
|
+
return (0, establishOperationPlan_js_1.establishOperationPlan)(event.schema, event.operation, event.fragments, event.variableValues, event.context, event.rootValue, event.planningTimeout);
|
|
345
|
+
}
|
|
344
346
|
/**
|
|
345
347
|
* @internal
|
|
346
348
|
*/
|
|
347
349
|
function grafastPrepare(args, options = {}) {
|
|
348
|
-
const { schema, contextValue: context, rootValue = Object.create(null),
|
|
350
|
+
const { schema, contextValue: context, rootValue = Object.create(null),
|
|
349
351
|
// operationName,
|
|
350
352
|
// document,
|
|
351
|
-
|
|
353
|
+
middleware, } = args;
|
|
352
354
|
const exeContext = (0, execute_1.buildExecutionContext)(args);
|
|
353
355
|
// If a list of errors was returned, abort
|
|
354
356
|
if (Array.isArray(exeContext) || "length" in exeContext) {
|
|
@@ -361,7 +363,21 @@ function grafastPrepare(args, options = {}) {
|
|
|
361
363
|
const planningTimeout = options.timeouts?.planning;
|
|
362
364
|
let operationPlan;
|
|
363
365
|
try {
|
|
364
|
-
|
|
366
|
+
if (middleware != null) {
|
|
367
|
+
operationPlan = middleware.runSync("establishOperationPlan", {
|
|
368
|
+
schema,
|
|
369
|
+
operation,
|
|
370
|
+
fragments,
|
|
371
|
+
variableValues,
|
|
372
|
+
context: context,
|
|
373
|
+
rootValue,
|
|
374
|
+
planningTimeout,
|
|
375
|
+
args,
|
|
376
|
+
}, establishOperationPlanFromEvent);
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
operationPlan = (0, establishOperationPlan_js_1.establishOperationPlan)(schema, operation, fragments, variableValues, context, rootValue, planningTimeout);
|
|
380
|
+
}
|
|
365
381
|
}
|
|
366
382
|
catch (error) {
|
|
367
383
|
const graphqlError = error instanceof GraphQLError
|
|
@@ -382,9 +398,8 @@ function grafastPrepare(args, options = {}) {
|
|
|
382
398
|
});
|
|
383
399
|
}
|
|
384
400
|
const executionTimeout = options.timeouts?.execution ?? null;
|
|
385
|
-
return executePreemptive(operationPlan, variableValues, context, rootValue, options.outputDataAsString ?? false, executionTimeout);
|
|
401
|
+
return executePreemptive(args, operationPlan, variableValues, context, rootValue, options.outputDataAsString ?? false, executionTimeout);
|
|
386
402
|
}
|
|
387
|
-
exports.grafastPrepare = grafastPrepare;
|
|
388
403
|
function newIterator(abort) {
|
|
389
404
|
const valueQueue = [];
|
|
390
405
|
const pullQueue = [];
|
|
@@ -402,7 +417,7 @@ function newIterator(abort) {
|
|
|
402
417
|
const cbs = pullQueue.shift();
|
|
403
418
|
if (cbs !== undefined) {
|
|
404
419
|
if ((0, utils_js_1.isPromiseLike)(v)) {
|
|
405
|
-
v.then((v) => cbs[0]({ done, value: v }), (e) => {
|
|
420
|
+
v.then((v) => cbs[0]({ done: false, value: v }), (e) => {
|
|
406
421
|
try {
|
|
407
422
|
const r = cbs[1](e);
|
|
408
423
|
if ((0, utils_js_1.isPromiseLike)(r)) {
|
|
@@ -416,7 +431,7 @@ function newIterator(abort) {
|
|
|
416
431
|
});
|
|
417
432
|
}
|
|
418
433
|
else {
|
|
419
|
-
cbs[0]({ done, value: v });
|
|
434
|
+
cbs[0]({ done: false, value: v });
|
|
420
435
|
}
|
|
421
436
|
}
|
|
422
437
|
else {
|
|
@@ -448,7 +463,7 @@ function newIterator(abort) {
|
|
|
448
463
|
abort();
|
|
449
464
|
for (const entry of pullQueue) {
|
|
450
465
|
try {
|
|
451
|
-
entry[0]({ done, value: undefined });
|
|
466
|
+
entry[0]({ done: true, value: undefined });
|
|
452
467
|
}
|
|
453
468
|
catch (e) {
|
|
454
469
|
// ignore
|
|
@@ -493,38 +508,40 @@ async function processStream(requestContext, iterator, spec, outputDataAsString)
|
|
|
493
508
|
}
|
|
494
509
|
directLayerPlanChild = parent;
|
|
495
510
|
}
|
|
496
|
-
const listItemStepId = directLayerPlanChild.rootStep
|
|
497
|
-
const
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
511
|
+
const { id: listItemStepId, _isUnary: isUnary } = directLayerPlanChild.rootStep;
|
|
512
|
+
for (const copyStepId of directLayerPlanChild.copyStepIds) {
|
|
513
|
+
const executionValue = spec.bucket.store.get(copyStepId);
|
|
514
|
+
if (!executionValue) {
|
|
515
|
+
throw new Error(`GrafastInternalError<2db7b749-399f-486b-bd12-7ca337b937e4>: ${spec.bucket.layerPlan} doesn't seem to include ${copyStepId} (required by ${directLayerPlanChild} via ${spec.outputPlan})`);
|
|
516
|
+
}
|
|
517
|
+
if (executionValue.isBatch) {
|
|
518
|
+
const values = (0, utils_js_1.arrayOfLength)(size, executionValue.at(spec.bucketIndex));
|
|
519
|
+
store.set(copyStepId, (0, executeBucket_js_1.batchExecutionValue)(values));
|
|
520
|
+
}
|
|
521
|
+
else {
|
|
522
|
+
store.set(copyStepId, executionValue);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
if (isUnary) {
|
|
526
|
+
assert.ok(entries.length === 0, "Unary step should only have one index");
|
|
527
|
+
store.set(listItemStepId, (0, executeBucket_js_1.unaryExecutionValue)(entries[0][0]));
|
|
528
|
+
}
|
|
529
|
+
else {
|
|
530
|
+
const listItemStepIdList = entries.map((e) => e[0]);
|
|
531
|
+
store.set(listItemStepId, (0, executeBucket_js_1.batchExecutionValue)(listItemStepIdList));
|
|
501
532
|
}
|
|
502
|
-
let bucketIndex = 0;
|
|
503
|
-
for (const entry of entries) {
|
|
504
|
-
const [result] = entry;
|
|
505
|
-
listItemStepIdList[bucketIndex] = result;
|
|
533
|
+
for (let bucketIndex = 0; bucketIndex < size; bucketIndex++) {
|
|
506
534
|
polymorphicPathList[bucketIndex] =
|
|
507
535
|
spec.bucket.polymorphicPathList[spec.bucketIndex];
|
|
508
536
|
iterators[bucketIndex] = new Set();
|
|
509
|
-
for (const copyPlanId of directLayerPlanChild.copyStepIds) {
|
|
510
|
-
const list = spec.bucket.store.get(copyPlanId);
|
|
511
|
-
if (!list) {
|
|
512
|
-
throw new Error(`GrafastInternalError<2db7b749-399f-486b-bd12-7ca337b937e4>: ${spec.bucket.layerPlan} doesn't seem to include ${copyPlanId} (required by ${directLayerPlanChild} via ${spec.outputPlan})`);
|
|
513
|
-
}
|
|
514
|
-
// PERF: optimize away these .get calls
|
|
515
|
-
store.get(copyPlanId)[bucketIndex] = list[spec.bucketIndex];
|
|
516
|
-
}
|
|
517
|
-
// PERF: we should be able to optimize this
|
|
518
|
-
bucketIndex++;
|
|
519
537
|
}
|
|
520
|
-
assert.strictEqual(bucketIndex, size, "GrafastInternalError<7c8deab0-8dfa-40f2-b625-97026f8fedcc>: expected bucket size does not match");
|
|
521
538
|
// const childBucket = newBucket(directLayerPlanChild, noDepsList, store);
|
|
522
539
|
// const childBucketIndex = 0;
|
|
523
540
|
const rootBucket = (0, executeBucket_js_1.newBucket)({
|
|
524
541
|
layerPlan: directLayerPlanChild,
|
|
525
542
|
size,
|
|
526
543
|
store,
|
|
527
|
-
|
|
544
|
+
flagUnion: 0,
|
|
528
545
|
polymorphicPathList,
|
|
529
546
|
iterators,
|
|
530
547
|
}, spec.bucket.metaByMetaKey);
|
|
@@ -631,29 +648,38 @@ function processSingleDeferred(requestContext, outputPlan, specs, asString) {
|
|
|
631
648
|
const store = new Map();
|
|
632
649
|
const polymorphicPathList = [];
|
|
633
650
|
const iterators = [];
|
|
634
|
-
|
|
635
|
-
|
|
651
|
+
// HACK: when we re-write stream/defer this needs fixing.
|
|
652
|
+
const firstBucket = specs[0][1].bucket;
|
|
653
|
+
if (dev_js_1.isDev) {
|
|
654
|
+
for (const spec of specs) {
|
|
655
|
+
if (spec[1].bucket !== firstBucket) {
|
|
656
|
+
throw new Error(`GrafastInternalError<c277422e-adb7-4b07-861e-acab931fc01a>: sorry, it seems the unary dependencies feature broke our incremental delivery support. This incremental delivery is going to be fully rewritten at some point anyway, so we recommend you avoid using it for now (the spec itself has changed since we implemented it).`);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
636
659
|
}
|
|
637
|
-
|
|
638
|
-
|
|
660
|
+
for (const copyStepId of outputPlan.layerPlan.copyStepIds) {
|
|
661
|
+
const executionValue = firstBucket.store.get(copyStepId);
|
|
662
|
+
if (executionValue.isBatch) {
|
|
663
|
+
const values = specs.map(([, spec]) => executionValue.at(spec.bucketIndex));
|
|
664
|
+
store.set(copyStepId, (0, executeBucket_js_1.batchExecutionValue)(values));
|
|
665
|
+
}
|
|
666
|
+
else {
|
|
667
|
+
store.set(copyStepId, executionValue);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
for (let bucketIndex = 0; bucketIndex < size; bucketIndex++) {
|
|
671
|
+
const spec = specs[bucketIndex][1];
|
|
639
672
|
polymorphicPathList[bucketIndex] =
|
|
640
673
|
spec.bucket.polymorphicPathList[spec.bucketIndex];
|
|
641
674
|
iterators[bucketIndex] = new Set();
|
|
642
|
-
for (const copyPlanId of outputPlan.layerPlan.copyStepIds) {
|
|
643
|
-
store.get(copyPlanId)[bucketIndex] =
|
|
644
|
-
spec.bucket.store.get(copyPlanId)[spec.bucketIndex];
|
|
645
|
-
}
|
|
646
|
-
// PERF: we should be able to optimize this
|
|
647
|
-
bucketIndex++;
|
|
648
675
|
}
|
|
649
|
-
assert.strictEqual(bucketIndex, size, "GrafastInternalError<4e88c671-f65b-42a6-8756-61247b188093>: expected bucket size does not match");
|
|
650
676
|
// const childBucket = newBucket(spec.outputPlan.layerPlan, noDepsList, store);
|
|
651
677
|
// const childBucketIndex = 0;
|
|
652
678
|
const rootBucket = (0, executeBucket_js_1.newBucket)({
|
|
653
679
|
layerPlan: outputPlan.layerPlan,
|
|
654
680
|
size,
|
|
655
681
|
store,
|
|
656
|
-
|
|
682
|
+
flagUnion: 0,
|
|
657
683
|
polymorphicPathList,
|
|
658
684
|
iterators,
|
|
659
685
|
}, null);
|