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/steps/remapKeys.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.RemapKeysStep = void 0;
|
|
4
|
+
exports.remapKeys = remapKeys;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
6
7
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
8
|
const tamedevil_1 = tslib_1.__importStar(require("tamedevil"));
|
|
8
9
|
const step_js_1 = require("../step.js");
|
|
10
|
+
const utils_js_1 = require("../utils.js");
|
|
9
11
|
function makeMapper(actualKeyByDesiredKey, callback) {
|
|
10
12
|
const entries = Object.entries(actualKeyByDesiredKey);
|
|
11
13
|
if (entries.every(([key, val]) => (0, tamedevil_1.isSafeObjectPropertyName)(key) && (0, tamedevil_1.isSafeObjectPropertyName)(val))) {
|
|
@@ -29,7 +31,7 @@ function makeMapper(actualKeyByDesiredKey, callback) {
|
|
|
29
31
|
* A plan that returns an object resulting from extracting the given
|
|
30
32
|
* `actualKey` from the input and storing it as the `desiredKey` in the output.
|
|
31
33
|
*/
|
|
32
|
-
class RemapKeysStep extends step_js_1.
|
|
34
|
+
class RemapKeysStep extends step_js_1.UnbatchedStep {
|
|
33
35
|
static { this.$$export = {
|
|
34
36
|
moduleName: "grafast",
|
|
35
37
|
exportName: "RemapKeysStep",
|
|
@@ -40,6 +42,10 @@ class RemapKeysStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
40
42
|
this.isSyncAndSafe = true;
|
|
41
43
|
this.allowMultipleOptimizations = true;
|
|
42
44
|
this.addDependency($plan);
|
|
45
|
+
this.peerKey = (0, utils_js_1.digestKeys)([
|
|
46
|
+
...Object.keys(this.actualKeyByDesiredKey),
|
|
47
|
+
...Object.values(this.actualKeyByDesiredKey),
|
|
48
|
+
]);
|
|
43
49
|
}
|
|
44
50
|
toStringMeta() {
|
|
45
51
|
return (chalk_1.default.bold.yellow(String(this.dependencies[0].id)) +
|
|
@@ -61,15 +67,17 @@ class RemapKeysStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
61
67
|
});
|
|
62
68
|
super.finalize();
|
|
63
69
|
}
|
|
64
|
-
execute(
|
|
65
|
-
return
|
|
70
|
+
execute({ count, values: [values0], }) {
|
|
71
|
+
return values0.isBatch
|
|
72
|
+
? values0.entries.map(this.mapper)
|
|
73
|
+
: new Array(count).fill(this.mapper(values0.value));
|
|
66
74
|
}
|
|
67
75
|
unbatchedExecute(_extra, value) {
|
|
68
76
|
return this.mapper(value);
|
|
69
77
|
}
|
|
70
78
|
deduplicate(peers) {
|
|
71
|
-
|
|
72
|
-
return peers
|
|
79
|
+
// Handled by peerKey
|
|
80
|
+
return peers;
|
|
73
81
|
}
|
|
74
82
|
}
|
|
75
83
|
exports.RemapKeysStep = RemapKeysStep;
|
|
@@ -80,5 +88,4 @@ exports.RemapKeysStep = RemapKeysStep;
|
|
|
80
88
|
function remapKeys($step, actualKeyByDesiredKey) {
|
|
81
89
|
return new RemapKeysStep($step, actualKeyByDesiredKey);
|
|
82
90
|
}
|
|
83
|
-
exports.remapKeys = remapKeys;
|
|
84
91
|
//# sourceMappingURL=remapKeys.js.map
|
package/dist/steps/reverse.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
1
|
+
import type { ExecutionDetails, GrafastResultsList, UnbatchedExecutionExtra } from "../interfaces.js";
|
|
2
|
+
import type { Step } from "../step.js";
|
|
3
|
+
import { UnbatchedStep } from "../step.js";
|
|
4
4
|
/**
|
|
5
5
|
* Returns a reversed copy of the list.
|
|
6
6
|
*/
|
|
@@ -8,20 +8,20 @@ export declare function reverseArray<TData = any>(list: readonly TData[]): TData
|
|
|
8
8
|
/**
|
|
9
9
|
* Reverses a list.
|
|
10
10
|
*/
|
|
11
|
-
export declare class ReverseStep<TData> extends
|
|
11
|
+
export declare class ReverseStep<TData> extends UnbatchedStep<readonly TData[]> {
|
|
12
12
|
static $$export: {
|
|
13
13
|
moduleName: string;
|
|
14
14
|
exportName: string;
|
|
15
15
|
};
|
|
16
16
|
isSyncAndSafe: boolean;
|
|
17
17
|
allowMultipleOptimizations: boolean;
|
|
18
|
-
constructor(plan:
|
|
19
|
-
execute(
|
|
20
|
-
unbatchedExecute(_extra:
|
|
18
|
+
constructor(plan: Step<readonly TData[]>);
|
|
19
|
+
execute({ indexMap, values: [values0], }: ExecutionDetails<[TData[]]>): GrafastResultsList<TData[]>;
|
|
20
|
+
unbatchedExecute(_extra: UnbatchedExecutionExtra, arr: TData[]): TData[];
|
|
21
21
|
deduplicate(peers: ReverseStep<TData>[]): ReverseStep<TData>[];
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Reverses a list.
|
|
25
25
|
*/
|
|
26
|
-
export declare function reverse<TData>(plan:
|
|
26
|
+
export declare function reverse<TData>(plan: Step<readonly TData[]>): ReverseStep<TData>;
|
|
27
27
|
//# sourceMappingURL=reverse.d.ts.map
|
package/dist/steps/reverse.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ReverseStep = void 0;
|
|
4
|
+
exports.reverseArray = reverseArray;
|
|
5
|
+
exports.reverse = reverse;
|
|
4
6
|
const step_js_1 = require("../step.js");
|
|
5
7
|
/**
|
|
6
8
|
* Returns a reversed copy of the list.
|
|
@@ -16,11 +18,10 @@ function reverseArray(list) {
|
|
|
16
18
|
}
|
|
17
19
|
return newList;
|
|
18
20
|
}
|
|
19
|
-
exports.reverseArray = reverseArray;
|
|
20
21
|
/**
|
|
21
22
|
* Reverses a list.
|
|
22
23
|
*/
|
|
23
|
-
class ReverseStep extends step_js_1.
|
|
24
|
+
class ReverseStep extends step_js_1.UnbatchedStep {
|
|
24
25
|
static { this.$$export = {
|
|
25
26
|
moduleName: "grafast",
|
|
26
27
|
exportName: "ReverseStep",
|
|
@@ -31,8 +32,11 @@ class ReverseStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
31
32
|
this.allowMultipleOptimizations = true;
|
|
32
33
|
this.addDependency(plan);
|
|
33
34
|
}
|
|
34
|
-
execute(
|
|
35
|
-
return
|
|
35
|
+
execute({ indexMap, values: [values0], }) {
|
|
36
|
+
return indexMap((i) => {
|
|
37
|
+
const arr = values0.at(i);
|
|
38
|
+
return arr == null ? arr : reverseArray(arr);
|
|
39
|
+
});
|
|
36
40
|
}
|
|
37
41
|
unbatchedExecute(_extra, arr) {
|
|
38
42
|
return arr == null ? arr : reverseArray(arr);
|
|
@@ -46,7 +50,6 @@ exports.ReverseStep = ReverseStep;
|
|
|
46
50
|
* Reverses a list.
|
|
47
51
|
*/
|
|
48
52
|
function reverse(plan) {
|
|
49
|
-
return new ReverseStep(plan);
|
|
53
|
+
return plan.operationPlan.cacheStep(plan, "GrafastInternal:reverse()", "", () => new ReverseStep(plan));
|
|
50
54
|
}
|
|
51
|
-
exports.reverse = reverse;
|
|
52
55
|
//# sourceMappingURL=reverse.js.map
|
package/dist/steps/setter.d.ts
CHANGED
|
@@ -1,27 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
export interface
|
|
4
|
-
|
|
5
|
-
}> extends BaseStep {
|
|
6
|
-
set<TKey extends keyof TPlans>(key: TKey, value: TPlans[TKey]): void;
|
|
1
|
+
import type { InputObjectTypeBakedInfo } from "../index.js";
|
|
2
|
+
import { Modifier } from "./applyInput.js";
|
|
3
|
+
export interface SetterCapable<TObj extends Record<string, any>> {
|
|
4
|
+
set<TKey extends keyof TObj>(key: TKey, value: TObj[TKey]): void;
|
|
7
5
|
}
|
|
8
|
-
export declare class
|
|
9
|
-
[key: string]: ExecutableStep;
|
|
10
|
-
} = {
|
|
11
|
-
[key: string]: ExecutableStep;
|
|
12
|
-
}, TParentStep extends SetterCapableStep<TPlans> = SetterCapableStep<TPlans>> extends ModifierStep<TParentStep> {
|
|
6
|
+
export declare class Setter<TObj extends Record<string, any> = Record<string, any>, TParent extends SetterCapable<TObj> = SetterCapable<TObj>> extends Modifier<TParent> {
|
|
13
7
|
static $$export: {
|
|
14
8
|
moduleName: string;
|
|
15
9
|
exportName: string;
|
|
16
10
|
};
|
|
17
11
|
private setters;
|
|
18
|
-
constructor(
|
|
19
|
-
set<TKey extends keyof
|
|
12
|
+
constructor(parent: TParent);
|
|
13
|
+
set<TKey extends keyof TObj>(key: TKey, value: TObj[TKey]): void;
|
|
20
14
|
apply(): void;
|
|
21
15
|
}
|
|
22
|
-
export declare function setter<
|
|
23
|
-
|
|
24
|
-
} = {
|
|
25
|
-
[key: string]: ExecutableStep;
|
|
26
|
-
}, TParentStep extends SetterCapableStep<TPlans> = SetterCapableStep<TPlans>>($parent: TParentStep): SetterStep<TPlans, TParentStep>;
|
|
16
|
+
export declare function setter<TObj extends Record<string, any> = Record<string, any>, TParent extends SetterCapable<TObj> = SetterCapable<TObj>>(parent: TParent): Setter<TObj, TParent>;
|
|
17
|
+
export declare function createObjectAndApplyChildren<TObj extends Record<string, any>>(_input: Record<string, any>, info: InputObjectTypeBakedInfo): TObj;
|
|
27
18
|
//# sourceMappingURL=setter.d.ts.map
|
package/dist/steps/setter.js
CHANGED
|
@@ -1,28 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
exports.Setter = void 0;
|
|
4
|
+
exports.setter = setter;
|
|
5
|
+
exports.createObjectAndApplyChildren = createObjectAndApplyChildren;
|
|
6
|
+
const applyInput_js_1 = require("./applyInput.js");
|
|
7
|
+
class Setter extends applyInput_js_1.Modifier {
|
|
6
8
|
static { this.$$export = {
|
|
7
9
|
moduleName: "grafast",
|
|
8
|
-
exportName: "
|
|
10
|
+
exportName: "Setter",
|
|
9
11
|
}; }
|
|
10
|
-
constructor(
|
|
11
|
-
super(
|
|
12
|
+
constructor(parent) {
|
|
13
|
+
super(parent);
|
|
12
14
|
this.setters = new Map();
|
|
13
15
|
}
|
|
14
|
-
set(key,
|
|
15
|
-
this.setters.set(key,
|
|
16
|
+
set(key, value) {
|
|
17
|
+
this.setters.set(key, value);
|
|
16
18
|
}
|
|
17
19
|
apply() {
|
|
18
|
-
for (const [key,
|
|
19
|
-
this
|
|
20
|
+
for (const [key, value] of this.setters.entries()) {
|
|
21
|
+
this.parent.set(key, value);
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
|
-
exports.
|
|
24
|
-
function setter(
|
|
25
|
-
return new
|
|
25
|
+
exports.Setter = Setter;
|
|
26
|
+
function setter(parent) {
|
|
27
|
+
return new Setter(parent);
|
|
28
|
+
}
|
|
29
|
+
function createObjectAndApplyChildren(_input, info) {
|
|
30
|
+
const obj = Object.create(null);
|
|
31
|
+
info.applyChildren(setter({
|
|
32
|
+
set(key, value) {
|
|
33
|
+
obj[key] = value;
|
|
34
|
+
},
|
|
35
|
+
}));
|
|
36
|
+
return obj;
|
|
26
37
|
}
|
|
27
|
-
exports.setter = setter;
|
|
28
38
|
//# sourceMappingURL=setter.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PromiseOrDirect, UnbatchedExecutionExtra } from "../interfaces.js";
|
|
2
|
+
import type { Multistep, UnwrapMultistep } from "../multistep.js";
|
|
3
|
+
import type { Step } from "../step.js";
|
|
4
|
+
import { UnbatchedStep } from "../step.js";
|
|
5
|
+
/**
|
|
6
|
+
* Calls the given callback function for each tuple
|
|
7
|
+
*/
|
|
8
|
+
export declare class SideEffectStep<TIn, TOut> extends UnbatchedStep<TOut> {
|
|
9
|
+
private fn;
|
|
10
|
+
static $$export: {
|
|
11
|
+
moduleName: string;
|
|
12
|
+
exportName: string;
|
|
13
|
+
};
|
|
14
|
+
isSyncAndSafe: boolean;
|
|
15
|
+
allowMultipleOptimizations: boolean;
|
|
16
|
+
private planDep;
|
|
17
|
+
constructor($plan: Step<TIn> | null | undefined, fn: (value: TIn) => PromiseOrDirect<TOut>);
|
|
18
|
+
toStringMeta(): any;
|
|
19
|
+
unbatchedExecute(_extra: UnbatchedExecutionExtra, value: TIn): PromiseOrDirect<TOut>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A plan that takes the input `$plan` and feeds each value through the `fn`
|
|
23
|
+
* callback. Note: if you need to pass more than one value, pass a `ListStep`
|
|
24
|
+
* as the `$plan` argument.
|
|
25
|
+
*/
|
|
26
|
+
declare function sideEffect<const TInMultistep extends Multistep, TOut>(spec: TInMultistep, fn: (value: UnwrapMultistep<TInMultistep>) => PromiseOrDirect<TOut>): SideEffectStep<UnwrapMultistep<TInMultistep>, TOut>;
|
|
27
|
+
export { sideEffect };
|
|
28
|
+
//# sourceMappingURL=sideEffect.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SideEffectStep = void 0;
|
|
4
|
+
exports.sideEffect = sideEffect;
|
|
5
|
+
const multistep_js_1 = require("../multistep.js");
|
|
6
|
+
const step_js_1 = require("../step.js");
|
|
7
|
+
/**
|
|
8
|
+
* Calls the given callback function for each tuple
|
|
9
|
+
*/
|
|
10
|
+
class SideEffectStep extends step_js_1.UnbatchedStep {
|
|
11
|
+
static { this.$$export = {
|
|
12
|
+
moduleName: "grafast",
|
|
13
|
+
exportName: "SideEffectStep",
|
|
14
|
+
}; }
|
|
15
|
+
constructor($plan, fn) {
|
|
16
|
+
super();
|
|
17
|
+
this.fn = fn;
|
|
18
|
+
this.isSyncAndSafe = false;
|
|
19
|
+
this.allowMultipleOptimizations = false;
|
|
20
|
+
this.hasSideEffects = true;
|
|
21
|
+
this.planDep = $plan != null ? this.addDependency($plan) : null;
|
|
22
|
+
}
|
|
23
|
+
toStringMeta() {
|
|
24
|
+
return this.fn.displayName || this.fn.name;
|
|
25
|
+
}
|
|
26
|
+
unbatchedExecute(_extra, value) {
|
|
27
|
+
return this.fn(value);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.SideEffectStep = SideEffectStep;
|
|
31
|
+
/**
|
|
32
|
+
* A plan that takes the input `$plan` and feeds each value through the `fn`
|
|
33
|
+
* callback. Note: if you need to pass more than one value, pass a `ListStep`
|
|
34
|
+
* as the `$plan` argument.
|
|
35
|
+
*/
|
|
36
|
+
function sideEffect(spec, fn) {
|
|
37
|
+
if (fn.length > 1) {
|
|
38
|
+
throw new Error("sideEffect callback should accept one argument, perhaps you forgot to destructure the arguments?");
|
|
39
|
+
}
|
|
40
|
+
const $in = (0, multistep_js_1.multistep)(spec);
|
|
41
|
+
const $result = new SideEffectStep($in, fn);
|
|
42
|
+
return $result;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=sideEffect.js.map
|
package/dist/stringifyPayload.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stringifyPayload =
|
|
3
|
+
exports.stringifyPayload = stringifyPayload;
|
|
4
4
|
function stringifyPayload(payload, outputDataAsString) {
|
|
5
5
|
if (!outputDataAsString || typeof payload.data !== "string") {
|
|
6
6
|
return JSON.stringify(payload);
|
|
@@ -55,5 +55,4 @@ function stringifyPayload(payload, outputDataAsString) {
|
|
|
55
55
|
str += "}";
|
|
56
56
|
return str;
|
|
57
57
|
}
|
|
58
|
-
exports.stringifyPayload = stringifyPayload;
|
|
59
58
|
//# sourceMappingURL=stringifyPayload.js.map
|
package/dist/stripAnsi.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ANSI_REGEXP = void 0;
|
|
4
|
+
exports.stripAnsi = stripAnsi;
|
|
4
5
|
// Extracted from https://github.com/chalk/ansi-regex MIT license
|
|
5
6
|
// Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
6
7
|
// Copyright (c) Benjie (https://twitter.com/benjie)
|
|
@@ -10,5 +11,4 @@ exports.ANSI_REGEXP =
|
|
|
10
11
|
function stripAnsi(str) {
|
|
11
12
|
return str.replace(exports.ANSI_REGEXP, "");
|
|
12
13
|
}
|
|
13
|
-
exports.stripAnsi = stripAnsi;
|
|
14
14
|
//# sourceMappingURL=stripAnsi.js.map
|
package/dist/subscribe.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import type { AsyncExecutionResult, ExecutionArgs, ExecutionResult } from "graphql";
|
|
2
2
|
import type { PromiseOrValue } from "graphql/jsutils/PromiseOrValue";
|
|
3
|
+
import type { GrafastExecutionArgs } from "./index.js";
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Second and third parameters should be passed as part of args,
|
|
6
|
+
* specifically `resolvedPreset` and `outputDataAsString`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function subscribe(args: ExecutionArgs, resolvedPreset: GraphileConfig.ResolvedPreset | undefined, outputDataAsString?: boolean): PromiseOrValue<AsyncGenerator<ExecutionResult | AsyncExecutionResult, void, void> | ExecutionResult>;
|
|
3
9
|
/**
|
|
4
10
|
* Use this instead of GraphQL.js' subscribe method and we'll automatically
|
|
5
11
|
* run grafastPrepare for you and handle the result.
|
|
6
12
|
*/
|
|
7
|
-
export declare function subscribe(args:
|
|
13
|
+
export declare function subscribe(args: GrafastExecutionArgs): PromiseOrValue<AsyncGenerator<ExecutionResult | AsyncExecutionResult, void, void> | ExecutionResult>;
|
|
8
14
|
//# sourceMappingURL=subscribe.d.ts.map
|
package/dist/subscribe.js
CHANGED
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.subscribe =
|
|
4
|
-
const config_js_1 = require("./config.js");
|
|
3
|
+
exports.subscribe = subscribe;
|
|
5
4
|
const execute_js_1 = require("./execute.js");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
const middleware_js_1 = require("./middleware.js");
|
|
6
|
+
function subscribe(args, legacyResolvedPreset, legacyOutputDataAsString) {
|
|
7
|
+
// TODO: remove legacy compatibility
|
|
8
|
+
if (legacyResolvedPreset !== undefined) {
|
|
9
|
+
args.resolvedPreset = legacyResolvedPreset;
|
|
10
|
+
}
|
|
11
|
+
if (legacyOutputDataAsString !== undefined) {
|
|
12
|
+
args.outputDataAsString = legacyOutputDataAsString;
|
|
13
|
+
}
|
|
14
|
+
const { resolvedPreset } = args;
|
|
15
|
+
const middleware = args.middleware === undefined && resolvedPreset != null
|
|
16
|
+
? (0, middleware_js_1.getGrafastMiddleware)(resolvedPreset)
|
|
17
|
+
: (args.middleware ?? null);
|
|
18
|
+
if (args.middleware === undefined) {
|
|
19
|
+
args.middleware = middleware;
|
|
20
|
+
}
|
|
21
|
+
if (middleware !== null) {
|
|
22
|
+
return middleware.run("subscribe", { args }, subscribeMiddlewareCallback);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return (0, execute_js_1.withGrafastArgs)(args);
|
|
26
|
+
}
|
|
12
27
|
}
|
|
13
|
-
|
|
28
|
+
const subscribeMiddlewareCallback = (event) => (0, execute_js_1.withGrafastArgs)(event.args);
|
|
14
29
|
//# sourceMappingURL=subscribe.js.map
|
|
@@ -6,7 +6,7 @@ if (globalAny[$$grafast] === true) {
|
|
|
6
6
|
// Already warned
|
|
7
7
|
}
|
|
8
8
|
else if (globalAny[$$grafast]) {
|
|
9
|
-
console.trace(`WARNING: more than one version of the 'grafast' module has been instantiated - you must ensure there is exactly one grafast (e.g. using yarn "resolutions" or similar techniques). Try clearing your package lockfile and reinstalling
|
|
9
|
+
console.trace(`WARNING: more than one version of the 'grafast' module has been instantiated - you must ensure there is exactly one grafast (e.g. using yarn "resolutions" or similar techniques). Try clearing your package lockfile and reinstalling.\n ${String(globalAny[$$grafast].stack).replace(/\n/g, "\n ")}`);
|
|
10
10
|
globalAny[$$grafast] = true;
|
|
11
11
|
}
|
|
12
12
|
else {
|
package/dist/timeSource.d.ts
CHANGED
package/dist/utils.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ConstValueNode, FieldNode, GraphQLEnumValueConfig, GraphQLFieldConfig, GraphQLInputFieldConfig, GraphQLInputObjectTypeConfig, GraphQLInputType, GraphQLNamedType, GraphQLObjectTypeConfig, GraphQLOutputType, GraphQLSchema } from "graphql";
|
|
1
|
+
import type { ConstValueNode, DirectiveNode, FieldNode, GraphQLEnumValueConfig, GraphQLFieldConfig, GraphQLInputFieldConfig, GraphQLInputObjectTypeConfig, GraphQLInputType, GraphQLNamedType, GraphQLObjectTypeConfig, GraphQLOutputType, GraphQLSchema, ValueNode } from "graphql";
|
|
2
2
|
import * as graphql from "graphql";
|
|
3
3
|
import type { Deferred } from "./deferred.js";
|
|
4
4
|
import type { OperationPlan } from "./engine/OperationPlan.js";
|
|
5
|
-
import type { BaseGraphQLArguments, GrafastFieldConfig, GrafastInputFieldConfig,
|
|
6
|
-
import type {
|
|
5
|
+
import type { BaseGraphQLArguments, GrafastFieldConfig, GrafastInputFieldConfig, OutputPlanForType } from "./interfaces.js";
|
|
6
|
+
import type { Step } from "./step.js";
|
|
7
7
|
/**
|
|
8
8
|
* The parent object is used as the key in `GetValueStepId()`; for root level
|
|
9
9
|
* fields it's possible that the parent will be null/undefined (in all other
|
|
@@ -21,7 +21,7 @@ export declare function isPromise<T>(t: T | Promise<T>): t is Promise<T>;
|
|
|
21
21
|
/**
|
|
22
22
|
* Is "thenable".
|
|
23
23
|
*/
|
|
24
|
-
export declare function isPromiseLike<T>(t: T |
|
|
24
|
+
export declare function isPromiseLike<T>(t: T | PromiseLike<T>): t is PromiseLike<T>;
|
|
25
25
|
/**
|
|
26
26
|
* Is a promise that can be externally resolved.
|
|
27
27
|
*/
|
|
@@ -31,61 +31,62 @@ export declare function isDeferred<T>(t: T | Promise<T> | Deferred<T>): t is Def
|
|
|
31
31
|
* values within them pass the `comparator` check (which defaults to `===`).
|
|
32
32
|
*/
|
|
33
33
|
export declare function arraysMatch<T>(array1: ReadonlyArray<T>, array2: ReadonlyArray<T>, comparator?: (val1: T, val2: T) => boolean): boolean;
|
|
34
|
-
export type ObjectTypeFields<
|
|
35
|
-
[key: string]: GrafastFieldConfig<GraphQLOutputType,
|
|
34
|
+
export type ObjectTypeFields<TParentStep extends Step> = {
|
|
35
|
+
[key: string]: GrafastFieldConfig<GraphQLOutputType, TParentStep, any, any>;
|
|
36
36
|
};
|
|
37
|
-
export type ObjectTypeSpec<
|
|
37
|
+
export type ObjectTypeSpec<TParentStep extends Step, TFields extends ObjectTypeFields<TParentStep>> = Omit<GraphQLObjectTypeConfig<any, Grafast.Context>, "fields"> & {
|
|
38
38
|
fields: TFields | (() => TFields);
|
|
39
|
-
assertStep?: TParentStep extends
|
|
39
|
+
assertStep?: TParentStep extends Step ? ((step: Step) => asserts step is TParentStep) | {
|
|
40
40
|
new (...args: any[]): TParentStep;
|
|
41
41
|
} : null;
|
|
42
42
|
};
|
|
43
43
|
/**
|
|
44
44
|
* Saves us having to write `extensions: {grafast: {...}}` everywhere.
|
|
45
45
|
*/
|
|
46
|
-
export declare function objectSpec<
|
|
47
|
-
export type GrafastObjectType<
|
|
46
|
+
export declare function objectSpec<TParentStep extends Step, TFields extends ObjectTypeFields<TParentStep>>(spec: ObjectTypeSpec<TParentStep, TFields>): GraphQLObjectTypeConfig<any, Grafast.Context>;
|
|
47
|
+
export type GrafastObjectType<TParentStep extends Step, TFields extends ObjectTypeFields<TParentStep>> = graphql.GraphQLObjectType<TParentStep extends Step<infer U> ? U : never> & {
|
|
48
48
|
TParentStep: TParentStep;
|
|
49
49
|
TFields: TFields;
|
|
50
50
|
};
|
|
51
51
|
/**
|
|
52
52
|
* @remarks This is a mess because the first two generics need to be specified manually, but the latter one we want inferred.
|
|
53
53
|
*/
|
|
54
|
-
export declare function newObjectTypeBuilder<
|
|
54
|
+
export declare function newObjectTypeBuilder<TParentStep extends Step>(assertStep: TParentStep extends Step ? ((step: Step) => asserts step is TParentStep) | {
|
|
55
55
|
new (...args: any[]): TParentStep;
|
|
56
|
-
} : never): <TFields extends ObjectTypeFields<
|
|
56
|
+
} : never): <TFields extends ObjectTypeFields<TParentStep>>(spec: ObjectTypeSpec<TParentStep, TFields>) => GrafastObjectType<TParentStep, TFields>;
|
|
57
57
|
/**
|
|
58
58
|
* Saves us having to write `extensions: {grafast: {...}}` everywhere.
|
|
59
59
|
*/
|
|
60
|
-
export declare function objectFieldSpec<
|
|
60
|
+
export declare function objectFieldSpec<TSource extends Step, TResult extends Step = Step, TArgs extends BaseGraphQLArguments = BaseGraphQLArguments>(grafastSpec: GrafastFieldConfig<GraphQLOutputType, TSource, TResult, TArgs>, path: string): GraphQLFieldConfig<any, TArgs>;
|
|
61
61
|
/**
|
|
62
62
|
* "Constrainted identity function" for field configs.
|
|
63
63
|
*
|
|
64
64
|
* @see {@link https://kentcdodds.com/blog/how-to-write-a-constrained-identity-function-in-typescript}
|
|
65
65
|
*/
|
|
66
|
-
export declare function newGrafastFieldConfigBuilder<
|
|
67
|
-
export type GrafastInputFieldConfigMap<
|
|
68
|
-
[key: string]: GrafastInputFieldConfig<
|
|
66
|
+
export declare function newGrafastFieldConfigBuilder<TParentStep extends Step>(): <TType extends GraphQLOutputType, TFieldStep extends OutputPlanForType<TType>, TArgs extends BaseGraphQLArguments>(config: GrafastFieldConfig<TType, TParentStep, TFieldStep, TArgs>) => typeof config;
|
|
67
|
+
export type GrafastInputFieldConfigMap<TParent> = {
|
|
68
|
+
[key: string]: GrafastInputFieldConfig<TParent, GraphQLInputType>;
|
|
69
69
|
};
|
|
70
|
-
export type InputObjectTypeSpec<
|
|
71
|
-
fields:
|
|
70
|
+
export type InputObjectTypeSpec<TParent> = Omit<GraphQLInputObjectTypeConfig, "fields"> & {
|
|
71
|
+
fields: GrafastInputFieldConfigMap<TParent> | (() => GrafastInputFieldConfigMap<TParent>);
|
|
72
72
|
};
|
|
73
|
-
export type GrafastInputObjectType<
|
|
74
|
-
|
|
75
|
-
TParentStep: TParentStep;
|
|
76
|
-
TFields: TFields;
|
|
73
|
+
export type GrafastInputObjectType<TParent> = graphql.GraphQLInputObjectType & {
|
|
74
|
+
TParent: TParent;
|
|
77
75
|
};
|
|
78
|
-
export declare function newInputObjectTypeBuilder<
|
|
76
|
+
export declare function newInputObjectTypeBuilder<TParent = any>(): (spec: InputObjectTypeSpec<TParent>) => GrafastInputObjectType<TParent>;
|
|
79
77
|
/**
|
|
80
78
|
* Saves us having to write `extensions: {grafast: {...}}` everywhere.
|
|
81
79
|
*/
|
|
82
|
-
export declare function inputObjectFieldSpec<
|
|
80
|
+
export declare function inputObjectFieldSpec<TParent>(grafastSpec: GrafastInputFieldConfig<TParent, GraphQLInputType>, path: string): GraphQLInputFieldConfig;
|
|
83
81
|
declare module "graphql" {
|
|
84
82
|
interface GraphQLEnumType {
|
|
85
83
|
[$$valueConfigByValue]?: Record<string, GraphQLEnumValueConfig>;
|
|
86
84
|
}
|
|
87
85
|
}
|
|
88
86
|
declare const $$valueConfigByValue: unique symbol;
|
|
87
|
+
export declare function getEnumValueConfigs(enumType: graphql.GraphQLEnumType): {
|
|
88
|
+
[outputValue: string]: GraphQLEnumValueConfig | undefined;
|
|
89
|
+
};
|
|
89
90
|
/**
|
|
90
91
|
* This would be equivalent to `enumType._valueLookup.get(outputValue)` except
|
|
91
92
|
* that's not a public API so we have to do a bit of heavy lifting here. Since
|
|
@@ -93,46 +94,28 @@ declare const $$valueConfigByValue: unique symbol;
|
|
|
93
94
|
* will go away so we use a weakmap.
|
|
94
95
|
*/
|
|
95
96
|
export declare function getEnumValueConfig(enumType: graphql.GraphQLEnumType, outputValue: string): GraphQLEnumValueConfig | undefined;
|
|
96
|
-
/**
|
|
97
|
-
* It's a peculiarity of V8 that `{}` is twice as fast as
|
|
98
|
-
* `Object.create(null)`, but `Object.create(sharedNull)` is the same speed as
|
|
99
|
-
* `{}`. Hat tip to `@purge` for bringing this to my attention.
|
|
100
|
-
*
|
|
101
|
-
* @internal
|
|
102
|
-
*/
|
|
103
|
-
export declare const sharedNull: any;
|
|
104
|
-
/**
|
|
105
|
-
* Prints out the stack trace to the current position with a message; useful
|
|
106
|
-
* for debugging which code path has hit this line.
|
|
107
|
-
*
|
|
108
|
-
* @internal
|
|
109
|
-
*/
|
|
110
|
-
export declare function stack(message: string, length?: number): void;
|
|
111
97
|
/**
|
|
112
98
|
* Ridiculously, this is faster than `new Array(length).fill(fill)`
|
|
113
|
-
*
|
|
114
|
-
* @internal
|
|
115
99
|
*/
|
|
116
100
|
export declare function arrayOfLength(length: number, fill?: any): any[];
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
* list and storing the result.
|
|
120
|
-
*
|
|
121
|
-
* @internal
|
|
122
|
-
*/
|
|
123
|
-
export declare function arrayOfLengthCb(length: number, fill: () => any): any[];
|
|
101
|
+
export declare const valueNodeToStaticValue: typeof graphql.valueFromAST;
|
|
102
|
+
export declare function findVariableNamesUsedInValueNode(valueNode: ValueNode, variableNames: Set<string>): void;
|
|
124
103
|
/**
|
|
125
104
|
* Given a FieldNode, recursively walks and finds all the variable references,
|
|
126
105
|
* returning a list of the (unique) variable names used.
|
|
127
106
|
*/
|
|
128
107
|
export declare function findVariableNamesUsed(operationPlan: OperationPlan, field: FieldNode): string[];
|
|
129
108
|
export declare function isTypePlanned(schema: GraphQLSchema, namedType: GraphQLNamedType): boolean;
|
|
130
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Returns `true` if the first argument depends on the second argument either
|
|
111
|
+
* directly or indirectly (via a chain of dependencies).
|
|
112
|
+
*/
|
|
113
|
+
export declare function stepADependsOnStepB(stepA: Step, stepB: Step): boolean;
|
|
131
114
|
/**
|
|
132
115
|
* Returns true if stepA is allowed to depend on stepB, false otherwise. (This
|
|
133
116
|
* mostly relates to heirarchy.)
|
|
134
117
|
*/
|
|
135
|
-
export declare function stepAMayDependOnStepB($a:
|
|
118
|
+
export declare function stepAMayDependOnStepB($a: Step, $b: Step): boolean;
|
|
136
119
|
/**
|
|
137
120
|
* For a regular GraphQL query with no `@stream`/`@defer`, the entire result is
|
|
138
121
|
* calculated and then the output is generated and sent to the client at once.
|
|
@@ -160,13 +143,31 @@ export declare function stepAMayDependOnStepB($a: ExecutableStep, $b: Executable
|
|
|
160
143
|
* approach. Once you have, you can use this function to help you, should you
|
|
161
144
|
* need it.
|
|
162
145
|
*/
|
|
163
|
-
export declare function stepsAreInSamePhase(ancestor:
|
|
146
|
+
export declare function stepsAreInSamePhase(ancestor: Step, descendent: Step): boolean;
|
|
164
147
|
export declare const canonicalJSONStringify: (o: object) => string;
|
|
165
148
|
export declare function assertNotAsync(fn: any, name: string): void;
|
|
166
|
-
export declare function
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
149
|
+
export declare function assertNotPromise<TVal>(value: TVal, fn: any, name: string): TVal;
|
|
150
|
+
export declare function hasItemPlan(step: Step & {
|
|
151
|
+
itemPlan?: ($item: Step) => Step;
|
|
152
|
+
}): step is Step & {
|
|
153
|
+
itemPlan: ($item: Step) => Step;
|
|
170
154
|
};
|
|
155
|
+
export declare function exportNameHint(obj: any, nameHint: string): void;
|
|
156
|
+
export declare function isTuple<T extends readonly [...(readonly any[])]>(t: any | T): t is T;
|
|
157
|
+
/**
|
|
158
|
+
* Turns an array of keys into a digest, avoiding conflicts.
|
|
159
|
+
* Symbols are treated as equivalent. (Theoretically faster
|
|
160
|
+
* than JSON.stringify().)
|
|
161
|
+
*/
|
|
162
|
+
export declare function digestKeys(keys: ReadonlyArray<string | number | symbol>): string;
|
|
163
|
+
/**
|
|
164
|
+
* If the directive has the argument `argName`, return a step representing that
|
|
165
|
+
* arguments value, whether that be a step representing the relevant variable
|
|
166
|
+
* or a constant step representing the hardcoded value in the document.
|
|
167
|
+
*
|
|
168
|
+
* @remarks NOT SUITABLE FOR USAGE WITH LISTS OR OBJECTS! Does not evaluate
|
|
169
|
+
* internal variable usages e.g. `[1, $b, 3]`
|
|
170
|
+
*/
|
|
171
|
+
export declare function directiveArgument<T>(operationPlan: OperationPlan, directive: DirectiveNode, argName: string, expectedKind: graphql.Kind.INT | graphql.Kind.FLOAT | graphql.Kind.BOOLEAN | graphql.Kind.STRING): Step<T> | undefined;
|
|
171
172
|
export {};
|
|
172
173
|
//# sourceMappingURL=utils.d.ts.map
|