grafast 0.1.1-beta.21 → 0.1.1-beta.22
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 +0 -4
- package/dist/args.js +3 -3
- package/dist/constants.d.ts +79 -0
- package/dist/constants.js +79 -0
- package/dist/engine/LayerPlan.d.ts +71 -8
- package/dist/engine/LayerPlan.js +375 -265
- package/dist/engine/OperationPlan.d.ts +77 -14
- package/dist/engine/OperationPlan.js +1508 -382
- package/dist/engine/OperationPlanTypes.d.ts +66 -0
- package/dist/engine/OperationPlanTypes.js +3 -0
- package/dist/engine/OutputPlan.d.ts +6 -0
- package/dist/engine/OutputPlan.js +138 -82
- package/dist/engine/StepTracker.js +76 -17
- package/dist/engine/executeBucket.js +327 -166
- package/dist/engine/lib/defaultPlanResolver.d.ts +1 -4
- package/dist/engine/lib/defaultPlanResolver.js +1 -5
- package/dist/engine/lib/withGlobalLayerPlan.d.ts +3 -1
- package/dist/engine/lib/withGlobalLayerPlan.js +19 -1
- package/dist/envelop.js +14 -3
- package/dist/error.d.ts +1 -1
- package/dist/error.js +9 -9
- package/dist/establishOperationPlan.d.ts +2 -1
- package/dist/establishOperationPlan.js +10 -10
- package/dist/execute.js +7 -5
- package/dist/global.d.ts +10 -0
- package/dist/global.js +25 -0
- package/dist/grafastGraphql.js +4 -3
- package/dist/grafastPrint.js +36 -4
- package/dist/index.d.ts +76 -8
- package/dist/index.js +37 -33
- package/dist/input.js +20 -1
- package/dist/inspect.js +1 -0
- package/dist/interfaces.d.ts +80 -122
- package/dist/interfaces.js +0 -77
- package/dist/makeGrafastSchema.d.ts +118 -35
- package/dist/makeGrafastSchema.js +197 -29
- package/dist/mermaid.js +198 -97
- package/dist/operationPlan-input.d.ts +1 -1
- package/dist/operationPlan-input.js +15 -5
- package/dist/planJSONInterfaces.d.ts +24 -5
- package/dist/prepare.d.ts +16 -9
- package/dist/prepare.js +54 -51
- package/dist/step.d.ts +45 -9
- package/dist/step.js +139 -22
- package/dist/steps/__flag.d.ts +3 -2
- package/dist/steps/__flag.js +31 -29
- package/dist/steps/__inputObject.d.ts +1 -1
- package/dist/steps/__inputStaticLeaf.d.ts +3 -2
- package/dist/steps/__inputStaticLeaf.js +13 -7
- package/dist/steps/__item.d.ts +1 -1
- package/dist/steps/__item.js +3 -3
- package/dist/steps/__trackedValue.d.ts +6 -3
- package/dist/steps/__trackedValue.js +25 -9
- package/dist/steps/__value.d.ts +2 -1
- package/dist/steps/__value.js +5 -0
- package/dist/steps/access.d.ts +17 -1
- package/dist/steps/access.js +14 -1
- package/dist/steps/applyInput.d.ts +1 -1
- package/dist/steps/applyInput.js +7 -6
- package/dist/steps/applyTransforms.js +9 -7
- package/dist/steps/bakedInput.js +2 -2
- package/dist/steps/coalesce.d.ts +15 -0
- package/dist/steps/coalesce.js +36 -0
- package/dist/steps/constant.js +16 -14
- package/dist/steps/each.d.ts +2 -2
- package/dist/steps/first.d.ts +2 -0
- package/dist/steps/first.js +5 -1
- package/dist/steps/graphqlResolver.d.ts +2 -2
- package/dist/steps/graphqlResolver.js +63 -161
- package/dist/steps/index.d.ts +3 -15
- package/dist/steps/index.js +6 -41
- package/dist/steps/lambda.js +1 -1
- package/dist/steps/last.d.ts +2 -0
- package/dist/steps/last.js +4 -0
- package/dist/steps/listTransform.d.ts +2 -2
- package/dist/steps/listTransform.js +11 -13
- package/dist/steps/load.d.ts +28 -22
- package/dist/steps/load.js +47 -1
- package/dist/steps/node.d.ts +10 -7
- package/dist/steps/node.js +5 -19
- package/dist/steps/object.js +6 -1
- package/dist/steps/proxy.d.ts +0 -6
- package/dist/steps/proxy.js +3 -3
- package/dist/steps/remapKeys.d.ts +1 -1
- package/dist/steps/remapKeys.js +0 -1
- package/dist/utils.d.ts +27 -5
- package/dist/utils.js +235 -15
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -6
- package/dist/polymorphic.d.ts +0 -14
- package/dist/polymorphic.js +0 -72
- package/dist/steps/polymorphicBranch.d.ts +0 -27
- package/dist/steps/polymorphicBranch.js +0 -62
package/dist/steps/load.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExecutionDetails } from "../index.js";
|
|
2
2
|
import type { GrafastResultsList, Maybe, PromiseOrDirect } from "../interfaces.js";
|
|
3
3
|
import type { Multistep, UnwrapMultistep } from "../multistep.js";
|
|
4
4
|
import { Step } from "../step.js";
|
|
@@ -7,26 +7,27 @@ export interface LoadOptions<TItem, TParams extends Record<string, any>, TUnaryS
|
|
|
7
7
|
attributes: ReadonlyArray<keyof TItem>;
|
|
8
8
|
params: Partial<TParams>;
|
|
9
9
|
}
|
|
10
|
-
type LoadCallback<TSpec, TItem, TData extends TItem | ReadonlyArray<TItem
|
|
11
|
-
|
|
10
|
+
type LoadCallback<TSpec, TItem, TData extends Maybe<TItem> | Maybe<ReadonlyArray<Maybe<TItem>>>, // loadMany
|
|
11
|
+
TParams extends Record<string, any>, TUnarySpec = never> = {
|
|
12
|
+
(specs: ReadonlyArray<TSpec>, options: LoadOptions<TItem, TParams, TUnarySpec>): PromiseOrDirect<ReadonlyArray<TData>>;
|
|
12
13
|
displayName?: string;
|
|
13
14
|
};
|
|
14
|
-
export type LoadOneCallback<TSpec, TItem, TParams extends Record<string, any>, TUnarySpec = never> = LoadCallback<TSpec, TItem,
|
|
15
|
-
export type LoadManyCallback<TSpec, TItem, TParams extends Record<string, any>, TUnarySpec = never> = LoadCallback<TSpec, TItem,
|
|
15
|
+
export type LoadOneCallback<TSpec, TItem, TData extends Maybe<TItem> = Maybe<TItem>, TParams extends Record<string, any> = Record<string, any>, TUnarySpec = never> = LoadCallback<TSpec, TItem, TData, TParams, TUnarySpec>;
|
|
16
|
+
export type LoadManyCallback<TSpec, TItem, TData extends Maybe<ReadonlyArray<Maybe<TItem>>> = Maybe<ReadonlyArray<Maybe<TItem>>>, TParams extends Record<string, any> = Record<string, any>, TUnarySpec = never> = LoadCallback<TSpec, TItem, TData, TParams, TUnarySpec>;
|
|
16
17
|
/**
|
|
17
18
|
* A TypeScript Identity Function to help you strongly type your
|
|
18
19
|
* LoadOneCallback.
|
|
19
20
|
*/
|
|
20
|
-
export declare function loadOneCallback<TSpec, TItem, TParams extends Record<string, any>, TUnarySpec = never>(callback: LoadOneCallback<TSpec, TItem, TParams, TUnarySpec>): LoadOneCallback<TSpec, TItem, TParams, TUnarySpec>;
|
|
21
|
+
export declare function loadOneCallback<TSpec, TItem, TData extends Maybe<TItem> = Maybe<TItem>, TParams extends Record<string, any> = Record<string, any>, TUnarySpec = never>(callback: LoadOneCallback<TSpec, TItem, TData, TParams, TUnarySpec>): LoadOneCallback<TSpec, TItem, TData, TParams, TUnarySpec>;
|
|
21
22
|
/**
|
|
22
23
|
* A TypeScript Identity Function to help you strongly type your
|
|
23
24
|
* LoadManyCallback.
|
|
24
25
|
*/
|
|
25
|
-
export declare function loadManyCallback<TSpec, TItem, TParams extends Record<string, any>, TUnarySpec = never>(callback: LoadManyCallback<TSpec, TItem, TParams, TUnarySpec>): LoadManyCallback<TSpec, TItem, TParams, TUnarySpec>;
|
|
26
|
+
export declare function loadManyCallback<TSpec, TItem, TData extends Maybe<ReadonlyArray<Maybe<TItem>>> = Maybe<ReadonlyArray<Maybe<TItem>>>, TParams extends Record<string, any> = Record<string, any>, TUnarySpec = never>(callback: LoadManyCallback<TSpec, TItem, TData, TParams, TUnarySpec>): LoadManyCallback<TSpec, TItem, TData, TParams, TUnarySpec>;
|
|
26
27
|
/**
|
|
27
28
|
* You shouldn't create instances of this yourself - use `loadOne` or `loadMany` instead.
|
|
28
29
|
*/
|
|
29
|
-
export declare class LoadedRecordStep<TItem, TParams extends Record<string, any> = Record<string, any>> extends Step<
|
|
30
|
+
export declare class LoadedRecordStep<TItem, TData extends Maybe<TItem> = Maybe<TItem>, TParams extends Record<string, any> = Record<string, any>> extends Step<TData> {
|
|
30
31
|
private isSingle;
|
|
31
32
|
private sourceDescription;
|
|
32
33
|
private ioEquivalence;
|
|
@@ -37,15 +38,18 @@ export declare class LoadedRecordStep<TItem, TParams extends Record<string, any>
|
|
|
37
38
|
isSyncAndSafe: boolean;
|
|
38
39
|
attributes: Set<keyof TItem>;
|
|
39
40
|
params: Partial<TParams>;
|
|
40
|
-
constructor($data: Step<
|
|
41
|
+
constructor($data: Step<TData>, isSingle: boolean, sourceDescription: string, ioEquivalence: Record<string, Step>);
|
|
41
42
|
toStringMeta(): string;
|
|
42
43
|
get(attr: keyof TItem & (string | number)): Step<any>;
|
|
43
44
|
private _getInner;
|
|
44
45
|
setParam<TParamKey extends keyof TParams>(paramKey: TParamKey, value: TParams[TParamKey]): void;
|
|
46
|
+
deduplicate(peers: LoadedRecordStep<any, any>[]): LoadedRecordStep<any, any, Record<string, any>>[];
|
|
47
|
+
deduplicatedWith(replacement: LoadedRecordStep<any, any>): void;
|
|
45
48
|
optimize(): Step<any> | import("./__flag.js").__FlagStep<Step<any>>;
|
|
46
|
-
execute({ count, values: [values0], }: ExecutionDetails<[
|
|
49
|
+
execute({ count, values: [values0], }: ExecutionDetails<[TData]>): GrafastResultsList<TData>;
|
|
47
50
|
}
|
|
48
|
-
export declare class LoadStep<const TMultistep extends Multistep, TItem, TData extends TItem | ReadonlyArray<TItem
|
|
51
|
+
export declare class LoadStep<const TMultistep extends Multistep, TItem, TData extends Maybe<TItem> | Maybe<ReadonlyArray<Maybe<TItem>>>, // loadMany
|
|
52
|
+
TParams extends Record<string, any>, const TUnaryMultistep extends Multistep = never> extends Step<TData> {
|
|
49
53
|
private ioEquivalence;
|
|
50
54
|
private load;
|
|
51
55
|
static $$export: {
|
|
@@ -61,28 +65,30 @@ export declare class LoadStep<const TMultistep extends Multistep, TItem, TData e
|
|
|
61
65
|
constructor(spec: TMultistep, unarySpec: TUnaryMultistep | null, ioEquivalence: IOEquivalence<TMultistep>, load: LoadCallback<UnwrapMultistep<TMultistep>, TItem, TData, TParams, UnwrapMultistep<TUnaryMultistep>>);
|
|
62
66
|
toStringMeta(): string;
|
|
63
67
|
private makeAccessMap;
|
|
64
|
-
listItem($item:
|
|
65
|
-
single(): TData extends
|
|
68
|
+
listItem($item: Step): LoadedRecordStep<TItem, TData extends Maybe<readonly (infer U)[]> ? U extends Maybe<TItem> ? U : never : never, TParams>;
|
|
69
|
+
single(): TData extends Maybe<TItem> ? LoadedRecordStep<TItem, TData, TParams> : never;
|
|
66
70
|
setParam<TParamKey extends keyof TParams>(paramKey: TParamKey, value: TParams[TParamKey]): void;
|
|
67
71
|
addAttributes(attributes: Set<keyof TItem>): void;
|
|
72
|
+
deduplicate(peers: readonly LoadStep<any, any, any, any, any>[]): LoadStep<any, any, any, any, any>[];
|
|
73
|
+
deduplicatedWith(replacement: LoadStep<any, any, any, any, any>): void;
|
|
68
74
|
finalize(): void;
|
|
69
75
|
execute({ count, values: [values0, values1], extra, }: ExecutionDetails<[
|
|
70
76
|
UnwrapMultistep<TMultistep>,
|
|
71
77
|
UnwrapMultistep<TUnaryMultistep>
|
|
72
|
-
]>): PromiseOrDirect<GrafastResultsList<
|
|
78
|
+
]>): PromiseOrDirect<GrafastResultsList<TData>>;
|
|
73
79
|
}
|
|
74
|
-
export declare function loadMany<const TMultistep extends Multistep, TItem, TParams extends Record<string, any> = Record<string, any>, const TUnaryMultistep extends Multistep = never>(spec: TMultistep, loadCallback: LoadManyCallback<UnwrapMultistep<TMultistep>, TItem, TParams, UnwrapMultistep<TUnaryMultistep>>): LoadStep<UnwrapMultistep<TMultistep>, TItem,
|
|
75
|
-
export declare function loadMany<const TMultistep extends Multistep, TItem, TParams extends Record<string, any> = Record<string, any>, const TUnaryMultistep extends Multistep = never>(spec: TMultistep, ioEquivalence: IOEquivalence<TMultistep>, loadCallback: LoadManyCallback<UnwrapMultistep<TMultistep>, TItem, TParams, UnwrapMultistep<TUnaryMultistep>>): LoadStep<UnwrapMultistep<TMultistep>, TItem,
|
|
76
|
-
export declare function loadMany<const TMultistep extends Multistep, TItem, TParams extends Record<string, any> = Record<string, any>, const TUnaryMultistep extends Multistep = never>(spec: TMultistep, unarySpec: TUnaryMultistep | null, loadCallback: LoadManyCallback<UnwrapMultistep<TMultistep>, TItem, TParams, UnwrapMultistep<TUnaryMultistep>>): LoadStep<UnwrapMultistep<TMultistep>, TItem,
|
|
77
|
-
export declare function loadMany<const TMultistep extends Multistep, TItem, TParams extends Record<string, any> = Record<string, any>, const TUnaryMultistep extends Multistep = never>(spec: TMultistep, unarySpec: TUnaryMultistep | null, ioEquivalence: IOEquivalence<TMultistep>, loadCallback: LoadManyCallback<UnwrapMultistep<TMultistep>, TItem, TParams, UnwrapMultistep<TUnaryMultistep>>): LoadStep<UnwrapMultistep<TMultistep>, TItem,
|
|
80
|
+
export declare function loadMany<const TMultistep extends Multistep, TItem, TData extends Maybe<ReadonlyArray<Maybe<TItem>>> = Maybe<ReadonlyArray<Maybe<TItem>>>, TParams extends Record<string, any> = Record<string, any>, const TUnaryMultistep extends Multistep = never>(spec: TMultistep, loadCallback: LoadManyCallback<UnwrapMultistep<TMultistep>, TItem, TData, TParams, UnwrapMultistep<TUnaryMultistep>>): LoadStep<UnwrapMultistep<TMultistep>, TItem, TData, TParams, UnwrapMultistep<TUnaryMultistep>>;
|
|
81
|
+
export declare function loadMany<const TMultistep extends Multistep, TItem, TData extends Maybe<ReadonlyArray<Maybe<TItem>>> = Maybe<ReadonlyArray<Maybe<TItem>>>, TParams extends Record<string, any> = Record<string, any>, const TUnaryMultistep extends Multistep = never>(spec: TMultistep, ioEquivalence: IOEquivalence<TMultistep>, loadCallback: LoadManyCallback<UnwrapMultistep<TMultistep>, TItem, TData, TParams, UnwrapMultistep<TUnaryMultistep>>): LoadStep<UnwrapMultistep<TMultistep>, TItem, TData, TParams, UnwrapMultistep<TUnaryMultistep>>;
|
|
82
|
+
export declare function loadMany<const TMultistep extends Multistep, TItem, TData extends Maybe<ReadonlyArray<Maybe<TItem>>> = Maybe<ReadonlyArray<Maybe<TItem>>>, TParams extends Record<string, any> = Record<string, any>, const TUnaryMultistep extends Multistep = never>(spec: TMultistep, unarySpec: TUnaryMultistep | null, loadCallback: LoadManyCallback<UnwrapMultistep<TMultistep>, TItem, TData, TParams, UnwrapMultistep<TUnaryMultistep>>): LoadStep<UnwrapMultistep<TMultistep>, TItem, TData, TParams, UnwrapMultistep<TUnaryMultistep>>;
|
|
83
|
+
export declare function loadMany<const TMultistep extends Multistep, TItem, TData extends Maybe<ReadonlyArray<Maybe<TItem>>> = Maybe<ReadonlyArray<Maybe<TItem>>>, TParams extends Record<string, any> = Record<string, any>, const TUnaryMultistep extends Multistep = never>(spec: TMultistep, unarySpec: TUnaryMultistep | null, ioEquivalence: IOEquivalence<TMultistep>, loadCallback: LoadManyCallback<UnwrapMultistep<TMultistep>, TItem, TData, TParams, UnwrapMultistep<TUnaryMultistep>>): LoadStep<UnwrapMultistep<TMultistep>, TItem, TData, TParams, UnwrapMultistep<TUnaryMultistep>>;
|
|
78
84
|
type IOEquivalence<TMultistep extends Multistep> = null | string | (UnwrapMultistep<TMultistep> extends readonly [...(readonly any[])] ? {
|
|
79
85
|
[key in Exclude<keyof UnwrapMultistep<TMultistep>, keyof any[]>]: string | null;
|
|
80
86
|
} : UnwrapMultistep<TMultistep> extends Record<string, any> ? {
|
|
81
87
|
[key in keyof UnwrapMultistep<TMultistep>]?: string | null;
|
|
82
88
|
} : never);
|
|
83
|
-
export declare function loadOne<const TMultistep extends Multistep, TItem, TParams extends Record<string, any> = Record<string, any>, const TUnaryMultistep extends Multistep = never>(spec: TMultistep, loadCallback: LoadOneCallback<UnwrapMultistep<TMultistep>, TItem, TParams, UnwrapMultistep<TUnaryMultistep>>): LoadedRecordStep<TItem, TParams>;
|
|
84
|
-
export declare function loadOne<const TMultistep extends Multistep, TItem, TParams extends Record<string, any> = Record<string, any>, const TUnaryMultistep extends Multistep = never>(spec: TMultistep, ioEquivalence: IOEquivalence<TMultistep>, loadCallback: LoadOneCallback<UnwrapMultistep<TMultistep>, TItem, TParams, UnwrapMultistep<TUnaryMultistep>>): LoadedRecordStep<TItem, TParams>;
|
|
85
|
-
export declare function loadOne<const TMultistep extends Multistep, TItem, TParams extends Record<string, any> = Record<string, any>, const TUnaryMultistep extends Multistep = never>(spec: TMultistep, unarySpec: TUnaryMultistep | null, loadCallback: LoadOneCallback<UnwrapMultistep<TMultistep>, TItem, TParams, UnwrapMultistep<TUnaryMultistep>>): LoadedRecordStep<TItem, TParams>;
|
|
86
|
-
export declare function loadOne<const TMultistep extends Multistep, TItem, TParams extends Record<string, any> = Record<string, any>, const TUnaryMultistep extends Multistep = never>(spec: TMultistep, unarySpec: TUnaryMultistep | null, ioEquivalence: IOEquivalence<TMultistep>, loadCallback: LoadOneCallback<UnwrapMultistep<TMultistep>, TItem, TParams, UnwrapMultistep<TUnaryMultistep>>): LoadedRecordStep<TItem, TParams>;
|
|
89
|
+
export declare function loadOne<const TMultistep extends Multistep, TItem, TData extends Maybe<TItem> = Maybe<TItem>, TParams extends Record<string, any> = Record<string, any>, const TUnaryMultistep extends Multistep = never>(spec: TMultistep, loadCallback: LoadOneCallback<UnwrapMultistep<TMultistep>, TItem, TData, TParams, UnwrapMultistep<TUnaryMultistep>>): LoadedRecordStep<TItem, TData, TParams>;
|
|
90
|
+
export declare function loadOne<const TMultistep extends Multistep, TItem, TData extends Maybe<TItem> = Maybe<TItem>, TParams extends Record<string, any> = Record<string, any>, const TUnaryMultistep extends Multistep = never>(spec: TMultistep, ioEquivalence: IOEquivalence<TMultistep>, loadCallback: LoadOneCallback<UnwrapMultistep<TMultistep>, TItem, TData, TParams, UnwrapMultistep<TUnaryMultistep>>): LoadedRecordStep<TItem, TData, TParams>;
|
|
91
|
+
export declare function loadOne<const TMultistep extends Multistep, TItem, TData extends Maybe<TItem> = Maybe<TItem>, TParams extends Record<string, any> = Record<string, any>, const TUnaryMultistep extends Multistep = never>(spec: TMultistep, unarySpec: TUnaryMultistep | null, loadCallback: LoadOneCallback<UnwrapMultistep<TMultistep>, TItem, TData, TParams, UnwrapMultistep<TUnaryMultistep>>): LoadedRecordStep<TItem, TData, TParams>;
|
|
92
|
+
export declare function loadOne<const TMultistep extends Multistep, TItem, TData extends Maybe<TItem> = Maybe<TItem>, TParams extends Record<string, any> = Record<string, any>, const TUnaryMultistep extends Multistep = never>(spec: TMultistep, unarySpec: TUnaryMultistep | null, ioEquivalence: IOEquivalence<TMultistep>, loadCallback: LoadOneCallback<UnwrapMultistep<TMultistep>, TItem, TData, TParams, UnwrapMultistep<TUnaryMultistep>>): LoadedRecordStep<TItem, TData, TParams>;
|
|
87
93
|
export {};
|
|
88
94
|
//# sourceMappingURL=load.d.ts.map
|
package/dist/steps/load.js
CHANGED
|
@@ -10,6 +10,9 @@ const multistep_js_1 = require("../multistep.js");
|
|
|
10
10
|
const step_js_1 = require("../step.js");
|
|
11
11
|
const utils_js_1 = require("../utils.js");
|
|
12
12
|
const access_js_1 = require("./access.js");
|
|
13
|
+
const nextTick = typeof process !== "undefined" && typeof process.nextTick === "function"
|
|
14
|
+
? (cb) => process.nextTick(cb)
|
|
15
|
+
: (cb) => setTimeout(cb, 0);
|
|
13
16
|
/**
|
|
14
17
|
* A TypeScript Identity Function to help you strongly type your
|
|
15
18
|
* LoadOneCallback.
|
|
@@ -67,6 +70,17 @@ class LoadedRecordStep extends step_js_1.Step {
|
|
|
67
70
|
}
|
|
68
71
|
this.params[paramKey] = value;
|
|
69
72
|
}
|
|
73
|
+
deduplicate(peers) {
|
|
74
|
+
return peers.filter((p) => p.isSingle === this.isSingle &&
|
|
75
|
+
p.sourceDescription === this.sourceDescription &&
|
|
76
|
+
(0, utils_js_1.recordsMatch)(p.ioEquivalence, this.ioEquivalence) &&
|
|
77
|
+
(0, utils_js_1.recordsMatch)(p.params, this.params));
|
|
78
|
+
}
|
|
79
|
+
deduplicatedWith(replacement) {
|
|
80
|
+
for (const attr of this.attributes) {
|
|
81
|
+
replacement.attributes.add(attr);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
70
84
|
optimize() {
|
|
71
85
|
const $source = this.getDepDeep(0);
|
|
72
86
|
if ($source instanceof LoadStep) {
|
|
@@ -161,6 +175,16 @@ class LoadStep extends step_js_1.Step {
|
|
|
161
175
|
this.attributes.add(attribute);
|
|
162
176
|
}
|
|
163
177
|
}
|
|
178
|
+
deduplicate(peers) {
|
|
179
|
+
return peers.filter((p) => p.load === this.load &&
|
|
180
|
+
ioEquivalenceMatches(p.ioEquivalence, this.ioEquivalence) &&
|
|
181
|
+
(0, utils_js_1.recordsMatch)(p.params, this.params));
|
|
182
|
+
}
|
|
183
|
+
deduplicatedWith(replacement) {
|
|
184
|
+
for (const attr of this.attributes) {
|
|
185
|
+
replacement.attributes.add(attr);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
164
188
|
finalize() {
|
|
165
189
|
// Find all steps of this type that use the same callback and have
|
|
166
190
|
// equivalent params and then match their list of attributes together.
|
|
@@ -242,7 +266,7 @@ class LoadStep extends step_js_1.Step {
|
|
|
242
266
|
meta.loadBatchesByLoad.set(this.load, loadBatches);
|
|
243
267
|
// Guaranteed by the metaKey to be equivalent for all entries sharing the same `meta`. Note equivalent is not identical; key order may change.
|
|
244
268
|
const loadOptions = this.loadOptions;
|
|
245
|
-
|
|
269
|
+
nextTick(() => {
|
|
246
270
|
// Don't allow adding anything else to the batch
|
|
247
271
|
meta.loadBatchesByLoad.delete(this.load);
|
|
248
272
|
executeBatches(loadBatches, this.load, {
|
|
@@ -340,4 +364,26 @@ function loadOne(spec, loadCallbackOrIoEquivalenceOrUnarySpec, loadCallbackOrIoE
|
|
|
340
364
|
return load(spec, null, null, loadCallbackOrIoEquivalenceOrUnarySpec).single();
|
|
341
365
|
}
|
|
342
366
|
}
|
|
367
|
+
function ioEquivalenceMatches(io1, io2) {
|
|
368
|
+
if (io1 === io2)
|
|
369
|
+
return true;
|
|
370
|
+
if (io1 == null)
|
|
371
|
+
return false;
|
|
372
|
+
if (io2 == null)
|
|
373
|
+
return false;
|
|
374
|
+
if (typeof io1 === "string")
|
|
375
|
+
return false;
|
|
376
|
+
if (typeof io2 === "string")
|
|
377
|
+
return false;
|
|
378
|
+
if (Array.isArray(io1)) {
|
|
379
|
+
if (!Array.isArray(io2))
|
|
380
|
+
return false;
|
|
381
|
+
return (0, utils_js_1.arraysMatch)(io1, io2);
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
if (Array.isArray(io2))
|
|
385
|
+
return false;
|
|
386
|
+
return (0, utils_js_1.recordsMatch)(io1, io2);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
343
389
|
//# sourceMappingURL=load.js.map
|
package/dist/steps/node.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { PolymorphicStep, Step } from "../step.js";
|
|
1
|
+
import type { Maybe, NodeIdHandler, UnbatchedExecutionExtra } from "../interfaces.js";
|
|
2
|
+
import type { Step } from "../step.js";
|
|
4
3
|
import { UnbatchedStep } from "../step.js";
|
|
5
4
|
/**
|
|
6
5
|
* A plan to get a Node by its global object identifier (string). Accepts an
|
|
@@ -8,7 +7,10 @@ import { UnbatchedStep } from "../step.js";
|
|
|
8
7
|
* typeNames supported and their details (codec to use, how to find the record,
|
|
9
8
|
* etc), and finally the Node id string plan.
|
|
10
9
|
*/
|
|
11
|
-
export declare class NodeStep extends UnbatchedStep
|
|
10
|
+
export declare class NodeStep extends UnbatchedStep<{
|
|
11
|
+
__typename: string;
|
|
12
|
+
specifier: any;
|
|
13
|
+
} | null> {
|
|
12
14
|
private possibleTypes;
|
|
13
15
|
static $$export: {
|
|
14
16
|
moduleName: string;
|
|
@@ -16,13 +18,14 @@ export declare class NodeStep extends UnbatchedStep implements PolymorphicStep {
|
|
|
16
18
|
};
|
|
17
19
|
isSyncAndSafe: boolean;
|
|
18
20
|
allowMultipleOptimizations: boolean;
|
|
19
|
-
private specPlanDep;
|
|
20
21
|
constructor(possibleTypes: {
|
|
21
22
|
[typeName: string]: NodeIdHandler;
|
|
22
23
|
}, $id: Step<string | null | undefined>);
|
|
23
|
-
planForType(type: GraphQLObjectType): Step;
|
|
24
24
|
private getTypeNameFromSpecifier;
|
|
25
|
-
unbatchedExecute
|
|
25
|
+
unbatchedExecute(_extra: UnbatchedExecutionExtra, specifier: any): {
|
|
26
|
+
__typename: string;
|
|
27
|
+
specifier: any;
|
|
28
|
+
} | null;
|
|
26
29
|
}
|
|
27
30
|
/**
|
|
28
31
|
* A plan to get a Node by its global object identifier (string). Accepts an
|
package/dist/steps/node.js
CHANGED
|
@@ -8,10 +8,7 @@ exports.makeDecodeNodeIdRuntime = makeDecodeNodeIdRuntime;
|
|
|
8
8
|
exports.makeDecodeNodeId = makeDecodeNodeId;
|
|
9
9
|
const dev_js_1 = require("../dev.js");
|
|
10
10
|
const inspect_js_1 = require("../inspect.js");
|
|
11
|
-
const polymorphic_js_1 = require("../polymorphic.js");
|
|
12
11
|
const step_js_1 = require("../step.js");
|
|
13
|
-
const access_js_1 = require("./access.js");
|
|
14
|
-
const constant_js_1 = require("./constant.js");
|
|
15
12
|
const lambda_js_1 = require("./lambda.js");
|
|
16
13
|
/**
|
|
17
14
|
* A plan to get a Node by its global object identifier (string). Accepts an
|
|
@@ -29,23 +26,8 @@ class NodeStep extends step_js_1.UnbatchedStep {
|
|
|
29
26
|
this.possibleTypes = possibleTypes;
|
|
30
27
|
this.isSyncAndSafe = true;
|
|
31
28
|
this.allowMultipleOptimizations = true;
|
|
32
|
-
this.unbatchedExecute = (_extra, specifier) => {
|
|
33
|
-
const typeName = specifier
|
|
34
|
-
? this.getTypeNameFromSpecifier(specifier)
|
|
35
|
-
: null;
|
|
36
|
-
return typeName ? (0, polymorphic_js_1.polymorphicWrap)(typeName) : null;
|
|
37
|
-
};
|
|
38
29
|
const decodeNodeId = makeDecodeNodeId(Object.values(possibleTypes));
|
|
39
|
-
this.
|
|
40
|
-
}
|
|
41
|
-
planForType(type) {
|
|
42
|
-
const spec = this.possibleTypes[type.name];
|
|
43
|
-
if (spec !== undefined) {
|
|
44
|
-
return spec.get(spec.getSpec((0, access_js_1.access)(this.getDep(this.specPlanDep), [spec.codec.name])));
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
return (0, constant_js_1.constant)(null);
|
|
48
|
-
}
|
|
30
|
+
this.addDependency(decodeNodeId($id));
|
|
49
31
|
}
|
|
50
32
|
getTypeNameFromSpecifier(specifier) {
|
|
51
33
|
for (const [typeName, typeSpec] of Object.entries(this.possibleTypes)) {
|
|
@@ -59,6 +41,10 @@ class NodeStep extends step_js_1.UnbatchedStep {
|
|
|
59
41
|
}
|
|
60
42
|
return null;
|
|
61
43
|
}
|
|
44
|
+
unbatchedExecute(_extra, specifier) {
|
|
45
|
+
const __typename = specifier != null ? this.getTypeNameFromSpecifier(specifier) : null;
|
|
46
|
+
return __typename != null ? { __typename, specifier } : null;
|
|
47
|
+
}
|
|
62
48
|
}
|
|
63
49
|
exports.NodeStep = NodeStep;
|
|
64
50
|
/**
|
package/dist/steps/object.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.ObjectStep = void 0;
|
|
|
5
5
|
exports.object = object;
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
7
|
const tamedevil_1 = tslib_1.__importStar(require("tamedevil"));
|
|
8
|
+
const dev_js_1 = require("../dev.js");
|
|
8
9
|
const step_js_1 = require("../step.js");
|
|
9
10
|
const utils_js_1 = require("../utils.js");
|
|
10
11
|
const constant_js_1 = require("./constant.js");
|
|
@@ -200,7 +201,11 @@ ${inner}
|
|
|
200
201
|
get(key) {
|
|
201
202
|
const index = this.keys.indexOf(key);
|
|
202
203
|
if (index < 0) {
|
|
203
|
-
|
|
204
|
+
if (dev_js_1.isDev) {
|
|
205
|
+
// TODO: move this to diagnostics
|
|
206
|
+
console.warn(`${this} doesn't have key '${String(key)}'; supported keys: '${this.keys.join("', '")}'`);
|
|
207
|
+
}
|
|
208
|
+
return (0, constant_js_1.constant)(undefined);
|
|
204
209
|
}
|
|
205
210
|
return this.getDepOptions(index).step;
|
|
206
211
|
}
|
package/dist/steps/proxy.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ExecutionDetails, GrafastResultsList, UnbatchedExecutionExtra } from "../interfaces.js";
|
|
2
|
-
import { $$proxy } from "../interfaces.js";
|
|
3
2
|
import type { Step } from "../step.js";
|
|
4
3
|
import { UnbatchedStep } from "../step.js";
|
|
5
4
|
/**
|
|
@@ -21,11 +20,6 @@ export declare class ProxyStep<T> extends UnbatchedStep<T> {
|
|
|
21
20
|
unbatchedExecute(_extra: UnbatchedExecutionExtra, value: T): T;
|
|
22
21
|
stream: undefined;
|
|
23
22
|
}
|
|
24
|
-
declare module "../step.js" {
|
|
25
|
-
interface Step {
|
|
26
|
-
[$$proxy]?: any;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
23
|
/**
|
|
30
24
|
* @experimental
|
|
31
25
|
*
|
package/dist/steps/proxy.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProxyStep = void 0;
|
|
4
4
|
exports.proxy = proxy;
|
|
5
|
-
const
|
|
5
|
+
const constants_js_1 = require("../constants.js");
|
|
6
6
|
const step_js_1 = require("../step.js");
|
|
7
7
|
const utils_js_1 = require("../utils.js");
|
|
8
8
|
/**
|
|
@@ -53,7 +53,7 @@ function makeProxyHandler($toStep) {
|
|
|
53
53
|
}
|
|
54
54
|
// DO optimize the proxy-ness away, so execution doesn't need to be proxied
|
|
55
55
|
if (p === "optimize") {
|
|
56
|
-
delete $proxy[
|
|
56
|
+
delete $proxy[constants_js_1.$$proxy];
|
|
57
57
|
return () => [$proxy];
|
|
58
58
|
}
|
|
59
59
|
if (p in $proxy) {
|
|
@@ -111,7 +111,7 @@ function makeProxyHandler($toStep) {
|
|
|
111
111
|
function proxy($step, $actualDep = $step) {
|
|
112
112
|
const $proxy = new ProxyStep($step, $actualDep);
|
|
113
113
|
const proxy = new Proxy($proxy, makeProxyHandler($step)); // Lie.
|
|
114
|
-
$proxy[
|
|
114
|
+
$proxy[constants_js_1.$$proxy] = proxy;
|
|
115
115
|
return proxy;
|
|
116
116
|
}
|
|
117
117
|
//# sourceMappingURL=proxy.js.map
|
|
@@ -19,7 +19,7 @@ export declare class RemapKeysStep extends UnbatchedStep {
|
|
|
19
19
|
private mapper;
|
|
20
20
|
constructor($plan: Step, actualKeyByDesiredKey: ActualKeyByDesiredKey);
|
|
21
21
|
toStringMeta(): string;
|
|
22
|
-
optimize(): Step
|
|
22
|
+
optimize(): Step;
|
|
23
23
|
finalize(): void;
|
|
24
24
|
execute({ count, values: [values0], }: ExecutionDetails): GrafastResultsList<any>;
|
|
25
25
|
unbatchedExecute(_extra: UnbatchedExecutionExtra, value: any): any;
|
package/dist/steps/remapKeys.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RemapKeysStep = void 0;
|
|
4
4
|
exports.remapKeys = remapKeys;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
-
/* eslint-disable @typescript-eslint/ban-types */
|
|
7
6
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
7
|
const tamedevil_1 = tslib_1.__importStar(require("tamedevil"));
|
|
9
8
|
const step_js_1 = require("../step.js");
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { ConstValueNode, DirectiveNode, FieldNode, GraphQLEnumValueConfig, GraphQLFieldConfig, GraphQLInputFieldConfig, GraphQLInputObjectTypeConfig, GraphQLInputType, GraphQLNamedType, GraphQLObjectTypeConfig,
|
|
1
|
+
import type { ConstValueNode, DirectiveNode, FieldNode, GraphQLEnumValueConfig, GraphQLFieldConfig, GraphQLInputFieldConfig, GraphQLInputObjectTypeConfig, GraphQLInputType, GraphQLNamedType, GraphQLObjectTypeConfig, GraphQLSchema, ValueNode } from "graphql";
|
|
2
2
|
import * as graphql from "graphql";
|
|
3
3
|
import type { Deferred } from "./deferred.js";
|
|
4
|
+
import type { LayerPlan, LayerPlanReasonDefer, LayerPlanReasonListItem, LayerPlanReasonSubscription } from "./engine/LayerPlan.js";
|
|
4
5
|
import type { OperationPlan } from "./engine/OperationPlan.js";
|
|
5
|
-
import type { BaseGraphQLArguments, GrafastFieldConfig, GrafastInputFieldConfig
|
|
6
|
+
import type { BaseGraphQLArguments, GrafastFieldConfig, GrafastInputFieldConfig } from "./interfaces.js";
|
|
6
7
|
import type { Step } from "./step.js";
|
|
7
8
|
/**
|
|
8
9
|
* The parent object is used as the key in `GetValueStepId()`; for root level
|
|
@@ -31,14 +32,31 @@ export declare function isDeferred<T>(t: T | Promise<T> | Deferred<T>): t is Def
|
|
|
31
32
|
* values within them pass the `comparator` check (which defaults to `===`).
|
|
32
33
|
*/
|
|
33
34
|
export declare function arraysMatch<T>(array1: ReadonlyArray<T>, array2: ReadonlyArray<T>, comparator?: (val1: T, val2: T) => boolean): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Returns true if map1 and map2 have the same keys, and every matching entry
|
|
37
|
+
* value within them pass the `comparator` check (which defaults to `===`).
|
|
38
|
+
*/
|
|
39
|
+
export declare function mapsMatch<TKey, TVal>(map1: ReadonlyMap<TKey, TVal>, map2: ReadonlyMap<TKey, TVal>, comparator?: (k: TKey, val1: TVal | undefined, val2: TVal | undefined) => boolean): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Returns true if record1 and record2 are equivalent, i.e. every value within
|
|
42
|
+
* them pass the `comparator` check (which defaults to `===`).
|
|
43
|
+
*
|
|
44
|
+
* Currently keys are ignored (`record[key] = undefined` is treated the same as
|
|
45
|
+
* `record[key]` being unset), but this may not always be the case.
|
|
46
|
+
*/
|
|
47
|
+
export declare function recordsMatch<TRecord extends {
|
|
48
|
+
readonly [k: string | symbol | number]: any;
|
|
49
|
+
}>(record1: TRecord, record2: TRecord, comparator?: (k: keyof TRecord, val1: TRecord[typeof k], val2: TRecord[typeof k]) => boolean): boolean;
|
|
50
|
+
export declare function setsMatch(s1: ReadonlySet<string> | null, s2: ReadonlySet<string> | null): boolean;
|
|
34
51
|
export type ObjectTypeFields<TParentStep extends Step> = {
|
|
35
|
-
[key: string]: GrafastFieldConfig<
|
|
52
|
+
[key: string]: GrafastFieldConfig<TParentStep, any, any>;
|
|
36
53
|
};
|
|
37
54
|
export type ObjectTypeSpec<TParentStep extends Step, TFields extends ObjectTypeFields<TParentStep>> = Omit<GraphQLObjectTypeConfig<any, Grafast.Context>, "fields"> & {
|
|
38
55
|
fields: TFields | (() => TFields);
|
|
39
56
|
assertStep?: TParentStep extends Step ? ((step: Step) => asserts step is TParentStep) | {
|
|
40
57
|
new (...args: any[]): TParentStep;
|
|
41
58
|
} : null;
|
|
59
|
+
planType?: ($specifier: Step) => TParentStep;
|
|
42
60
|
};
|
|
43
61
|
/**
|
|
44
62
|
* Saves us having to write `extensions: {grafast: {...}}` everywhere.
|
|
@@ -57,13 +75,13 @@ export declare function newObjectTypeBuilder<TParentStep extends Step>(assertSte
|
|
|
57
75
|
/**
|
|
58
76
|
* Saves us having to write `extensions: {grafast: {...}}` everywhere.
|
|
59
77
|
*/
|
|
60
|
-
export declare function objectFieldSpec<TSource extends Step,
|
|
78
|
+
export declare function objectFieldSpec<TSource extends Step, TArgs extends BaseGraphQLArguments = BaseGraphQLArguments, TResult extends Step = Step>(grafastSpec: GrafastFieldConfig<TSource, TArgs, TResult>, path: string): GraphQLFieldConfig<any, Grafast.Context, TArgs>;
|
|
61
79
|
/**
|
|
62
80
|
* "Constrainted identity function" for field configs.
|
|
63
81
|
*
|
|
64
82
|
* @see {@link https://kentcdodds.com/blog/how-to-write-a-constrained-identity-function-in-typescript}
|
|
65
83
|
*/
|
|
66
|
-
export declare function newGrafastFieldConfigBuilder<TParentStep extends Step>(): <
|
|
84
|
+
export declare function newGrafastFieldConfigBuilder<TParentStep extends Step>(): <TArgs extends BaseGraphQLArguments = BaseGraphQLArguments, TFieldStep extends Step = Step>(config: GrafastFieldConfig<TParentStep, TArgs, TFieldStep>) => typeof config;
|
|
67
85
|
export type GrafastInputFieldConfigMap<TParent> = {
|
|
68
86
|
[key: string]: GrafastInputFieldConfig<TParent, GraphQLInputType>;
|
|
69
87
|
};
|
|
@@ -116,6 +134,9 @@ export declare function stepADependsOnStepB(stepA: Step, stepB: Step): boolean;
|
|
|
116
134
|
* mostly relates to heirarchy.)
|
|
117
135
|
*/
|
|
118
136
|
export declare function stepAMayDependOnStepB($a: Step, $b: Step): boolean;
|
|
137
|
+
export declare function stepAShouldTryAndInlineIntoStepB($a: Step, $b: Step): boolean;
|
|
138
|
+
export declare function pathsFromAncestorToTargetLayerPlan(ancestor: LayerPlan, lp: LayerPlan): readonly LayerPlan[][];
|
|
139
|
+
export declare function layerPlanHeirarchyContains(lp: LayerPlan, targetLp: LayerPlan): boolean;
|
|
119
140
|
/**
|
|
120
141
|
* For a regular GraphQL query with no `@stream`/`@defer`, the entire result is
|
|
121
142
|
* calculated and then the output is generated and sent to the client at once.
|
|
@@ -144,6 +165,7 @@ export declare function stepAMayDependOnStepB($a: Step, $b: Step): boolean;
|
|
|
144
165
|
* need it.
|
|
145
166
|
*/
|
|
146
167
|
export declare function stepsAreInSamePhase(ancestor: Step, descendent: Step): boolean;
|
|
168
|
+
export declare function isPhaseTransitionLayerPlan(layerPlan: LayerPlan): layerPlan is LayerPlan<LayerPlanReasonListItem> | LayerPlan<LayerPlanReasonDefer> | LayerPlan<LayerPlanReasonSubscription>;
|
|
147
169
|
export declare const canonicalJSONStringify: (o: object) => string;
|
|
148
170
|
export declare function assertNotAsync(fn: any, name: string): void;
|
|
149
171
|
export declare function assertNotPromise<TVal>(value: TVal, fn: any, name: string): TVal;
|