grafast 0.1.1-beta.24 → 0.1.1-beta.25
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/dist/engine/lib/defaultPlanResolver.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/makeGrafastSchema.d.ts +2 -2
- package/dist/steps/__trackedValue.d.ts +3 -0
- package/dist/steps/__value.d.ts +3 -0
- package/dist/steps/access.d.ts +3 -16
- package/dist/steps/access.js +0 -9
- package/dist/steps/connection.d.ts +3 -2
- package/dist/steps/connection.js +4 -0
- package/dist/steps/constant.d.ts +4 -1
- package/dist/steps/get.d.ts +50 -0
- package/dist/steps/get.js +13 -0
- package/dist/steps/index.d.ts +2 -1
- package/dist/steps/index.js +3 -2
- package/dist/steps/object.d.ts +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defaultPlanResolver = void 0;
|
|
4
|
-
const
|
|
5
|
-
const defaultPlanResolver = ($step, _, info) => (0,
|
|
4
|
+
const get_js_1 = require("../../steps/get.js");
|
|
5
|
+
const defaultPlanResolver = ($step, _, info) => (0, get_js_1.get)($step, info.fieldName);
|
|
6
6
|
exports.defaultPlanResolver = defaultPlanResolver;
|
|
7
7
|
//# sourceMappingURL=defaultPlanResolver.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { DataFromObjectSteps } from "./steps/object.js";
|
|
|
6
6
|
type PromiseOrValue<T> = T | Promise<T>;
|
|
7
7
|
import { exportAs, exportAsMany } from "./exportAs.js";
|
|
8
8
|
import { grafastPrint } from "./grafastPrint.js";
|
|
9
|
-
import { AbstractTypePlan, DeprecatedInputObjectPlan, DeprecatedObjectPlan, EnumPlan, EnumValueConfig, EnumValueInput, FieldPlan, GrafastSchemaConfig, InputFieldPlan, InputObjectPlan, InterfacePlan, makeGrafastSchema, ObjectFieldConfig, ObjectPlan, ScalarPlan, UnionPlan } from "./makeGrafastSchema.js";
|
|
9
|
+
import { AbstractTypePlan, DeprecatedInputObjectPlan, DeprecatedObjectPlan, EnumPlan, EnumValueConfig, EnumValueInput, FieldPlan, GrafastSchemaConfig, InputFieldPlan, InputObjectFieldConfig, InputObjectPlan, InterfacePlan, makeGrafastSchema, ObjectFieldConfig, ObjectPlan, ScalarPlan, UnionPlan } from "./makeGrafastSchema.js";
|
|
10
10
|
import type { $$cacheByOperation, $$hooked, $$queryCache } from "./constants.js";
|
|
11
11
|
import { $$bypassGraphQL, $$eventEmitter, $$extensions, $$idempotent, $$verbatim, DEFAULT_ACCEPT_FLAGS } from "./constants.js";
|
|
12
12
|
import { defer, Deferred } from "./deferred.js";
|
|
@@ -31,7 +31,7 @@ import { stripAnsi } from "./stripAnsi.js";
|
|
|
31
31
|
import { subscribe } from "./subscribe.js";
|
|
32
32
|
import { arrayOfLength, arraysMatch, getEnumValueConfig, getEnumValueConfigs, GrafastInputFieldConfigMap, GrafastInputObjectType, GrafastObjectType, inputObjectFieldSpec, InputObjectTypeSpec, isPromiseLike, mapsMatch, newGrafastFieldConfigBuilder, newInputObjectTypeBuilder, newObjectTypeBuilder, objectFieldSpec, objectSpec, ObjectTypeFields, ObjectTypeSpec, recordsMatch, setsMatch, stepADependsOnStepB, stepAMayDependOnStepB, stepAShouldTryAndInlineIntoStepB, stepsAreInSamePhase } from "./utils.js";
|
|
33
33
|
export { isAsyncIterable } from "iterall";
|
|
34
|
-
export { __FlagStep, __InputListStep, __InputObjectStep, __InputObjectStepWithDollars, __InputStaticLeafStep, __ItemStep, __ListTransformStep, __TrackedValueStep, __TrackedValueStepWithDollars, __ValueStep, $$bypassGraphQL, $$eventEmitter, $$extensions, $$idempotent, $$inhibit, $$verbatim, AbstractTypePlan, AbstractTypePlanner, access, AccessStep, ActualKeyByDesiredKey, applyInput, ApplyInputStep, applyTransforms, ApplyTransformsStep, arrayOfLength, arraysMatch, assertEdgeCapableStep, assertExecutableStep, assertListCapableStep, assertModifier, assertNotNull, assertPageInfoCapableStep, assertStep, bakedInput, bakedInputRuntime, BakedInputStep, BaseEventMap, BaseGraphQLArguments, BaseGraphQLRootValue, BaseGraphQLVariables, BatchExecutionValue, coalesce, CoalesceStep, condition, ConditionStep, connection, ConnectionCapableStep, ConnectionStep, constant, ConstantStep, context, createObjectAndApplyChildren, DataFromObjectSteps, DataFromStep, debugPlans, DEFAULT_ACCEPT_FLAGS, defaultPlanResolver, defer, Deferred, DeprecatedInputObjectPlan, DeprecatedObjectPlan, each, EdgeCapableStep, EdgeStep, EnumPlan, EnumValueConfig, EnumValueInput, error, ErrorStep, EventCallback, EventMapKey, Step as ExecutableStep, execute, ExecutionDetails, ExecutionDetailsStream, ExecutionEventEmitter, ExecutionEventMap, ExecutionExtra, ExecutionResults, ExecutionResultValue, ExecutionValue, exportAs, exportAsMany, FieldArg, FieldArgs, FieldInfo, FieldPlan, FieldPlanResolver, filter, FilterPlanMemo, first, FirstStep, flagError, get, getEnumValueConfig, getEnumValueConfigs, getGrafastMiddleware, getNullableInputTypeAtPath, grafast, GrafastArgumentConfig, GrafastExecutionArgs, GrafastFieldConfig, GrafastFieldConfigArgumentMap, grafast as grafastGraphql, grafastSync as grafastGraphqlSync, GrafastInputFieldConfig, GrafastInputFieldConfigMap, GrafastInputObjectType, GrafastObjectType, GrafastPlanJSON, grafastPrint, GrafastResultsList, GrafastResultStreamList, GrafastSchemaConfig, GrafastSubscriber, grafastSync, GrafastValuesList, graphqlResolver, GraphQLResolverStep, groupBy, GroupByPlanMemo, inhibitOnNull, InputFieldPlan, InputObjectFieldApplyResolver, inputObjectFieldSpec, InputObjectPlan, InputObjectTypeBakedInfo, InputObjectTypeBakedResolver, InputObjectTypeSpec, inspect, AbstractTypePlan as InterfaceOrUnionPlans, InterfacePlan, isDev, isExecutableStep, isListCapableStep, isListLikeStep, isModifier, isObjectLikeStep, isPromiseLike, isSafeError, isStep, isUnaryStep, JSONArray, JSONObject, JSONValue, lambda, LambdaStep, last, LastStep, list, ListCapableStep, listen, ListenStep, ListLikeStep, ListStep, listTransform, ListTransformItemPlanCallback, ListTransformOptions, ListTransformReduce, LoadedRecordStep, loadMany, LoadManyCallback, loadManyCallback, loadOne, LoadOneCallback, loadOneCallback, LoadOptions, LoadStep, makeDecodeNodeId, makeDecodeNodeIdRuntime, makeGrafastSchema, mapsMatch, Maybe, Modifier, Multistep, multistep, newGrafastFieldConfigBuilder, newInputObjectTypeBuilder, newObjectTypeBuilder, node, NodeIdCodec, nodeIdFromNode, NodeIdHandler, NodeStep, noop, object, ObjectFieldConfig, objectFieldSpec, ObjectLikeStep, ObjectPlan, ObjectPlanMeta, objectSpec, ObjectStep, ObjectTypeFields, ObjectTypeSpec, OperationPlan, operationPlan, PageInfoCapableStep, partitionByIndex, PlanTypeInfo, PromiseOrDirect, proxy, ProxyStep, recordsMatch, remapKeys, RemapKeysStep, reverse, reverseArray, ReverseStep, rootValue, SafeError, ScalarPlan, ScalarPlanResolver, setsMatch, Setter, setter, SetterCapable, sideEffect, SideEffectStep, specFromNodeId, Step, stepADependsOnStepB, stepAMayDependOnStepB, stepAShouldTryAndInlineIntoStepB, StepOptimizeOptions, stepsAreInSamePhase, StepStreamOptions, stringifyPayload, stripAnsi, subscribe, trap, TRAP_ERROR, TRAP_ERROR_OR_INHIBITED, TRAP_INHIBITED, TypedEventEmitter, UnaryExecutionValue, UnbatchedStep as UnbatchedExecutableStep, UnbatchedExecutionExtra, UnbatchedStep, UnionPlan, UnwrapMultistep, };
|
|
34
|
+
export { __FlagStep, __InputListStep, __InputObjectStep, __InputObjectStepWithDollars, __InputStaticLeafStep, __ItemStep, __ListTransformStep, __TrackedValueStep, __TrackedValueStepWithDollars, __ValueStep, $$bypassGraphQL, $$eventEmitter, $$extensions, $$idempotent, $$inhibit, $$verbatim, AbstractTypePlan, AbstractTypePlanner, access, AccessStep, ActualKeyByDesiredKey, applyInput, ApplyInputStep, applyTransforms, ApplyTransformsStep, arrayOfLength, arraysMatch, assertEdgeCapableStep, assertExecutableStep, assertListCapableStep, assertModifier, assertNotNull, assertPageInfoCapableStep, assertStep, bakedInput, bakedInputRuntime, BakedInputStep, BaseEventMap, BaseGraphQLArguments, BaseGraphQLRootValue, BaseGraphQLVariables, BatchExecutionValue, coalesce, CoalesceStep, condition, ConditionStep, connection, ConnectionCapableStep, ConnectionStep, constant, ConstantStep, context, createObjectAndApplyChildren, DataFromObjectSteps, DataFromStep, debugPlans, DEFAULT_ACCEPT_FLAGS, defaultPlanResolver, defer, Deferred, DeprecatedInputObjectPlan, DeprecatedObjectPlan, each, EdgeCapableStep, EdgeStep, EnumPlan, EnumValueConfig, EnumValueInput, error, ErrorStep, EventCallback, EventMapKey, Step as ExecutableStep, execute, ExecutionDetails, ExecutionDetailsStream, ExecutionEventEmitter, ExecutionEventMap, ExecutionExtra, ExecutionResults, ExecutionResultValue, ExecutionValue, exportAs, exportAsMany, FieldArg, FieldArgs, FieldInfo, FieldPlan, FieldPlanResolver, filter, FilterPlanMemo, first, FirstStep, flagError, get, getEnumValueConfig, getEnumValueConfigs, getGrafastMiddleware, getNullableInputTypeAtPath, grafast, GrafastArgumentConfig, GrafastExecutionArgs, GrafastFieldConfig, GrafastFieldConfigArgumentMap, grafast as grafastGraphql, grafastSync as grafastGraphqlSync, GrafastInputFieldConfig, GrafastInputFieldConfigMap, GrafastInputObjectType, GrafastObjectType, GrafastPlanJSON, grafastPrint, GrafastResultsList, GrafastResultStreamList, GrafastSchemaConfig, GrafastSubscriber, grafastSync, GrafastValuesList, graphqlResolver, GraphQLResolverStep, groupBy, GroupByPlanMemo, inhibitOnNull, InputFieldPlan, InputObjectFieldApplyResolver, InputObjectFieldConfig, inputObjectFieldSpec, InputObjectPlan, InputObjectTypeBakedInfo, InputObjectTypeBakedResolver, InputObjectTypeSpec, inspect, AbstractTypePlan as InterfaceOrUnionPlans, InterfacePlan, isDev, isExecutableStep, isListCapableStep, isListLikeStep, isModifier, isObjectLikeStep, isPromiseLike, isSafeError, isStep, isUnaryStep, JSONArray, JSONObject, JSONValue, lambda, LambdaStep, last, LastStep, list, ListCapableStep, listen, ListenStep, ListLikeStep, ListStep, listTransform, ListTransformItemPlanCallback, ListTransformOptions, ListTransformReduce, LoadedRecordStep, loadMany, LoadManyCallback, loadManyCallback, loadOne, LoadOneCallback, loadOneCallback, LoadOptions, LoadStep, makeDecodeNodeId, makeDecodeNodeIdRuntime, makeGrafastSchema, mapsMatch, Maybe, Modifier, Multistep, multistep, newGrafastFieldConfigBuilder, newInputObjectTypeBuilder, newObjectTypeBuilder, node, NodeIdCodec, nodeIdFromNode, NodeIdHandler, NodeStep, noop, object, ObjectFieldConfig, objectFieldSpec, ObjectLikeStep, ObjectPlan, ObjectPlanMeta, objectSpec, ObjectStep, ObjectTypeFields, ObjectTypeSpec, OperationPlan, operationPlan, PageInfoCapableStep, partitionByIndex, PlanTypeInfo, PromiseOrDirect, proxy, ProxyStep, recordsMatch, remapKeys, RemapKeysStep, reverse, reverseArray, ReverseStep, rootValue, SafeError, ScalarPlan, ScalarPlanResolver, setsMatch, Setter, setter, SetterCapable, sideEffect, SideEffectStep, specFromNodeId, Step, stepADependsOnStepB, stepAMayDependOnStepB, stepAShouldTryAndInlineIntoStepB, StepOptimizeOptions, stepsAreInSamePhase, StepStreamOptions, stringifyPayload, stripAnsi, subscribe, trap, TRAP_ERROR, TRAP_ERROR_OR_INHIBITED, TRAP_INHIBITED, TypedEventEmitter, UnaryExecutionValue, UnbatchedStep as UnbatchedExecutableStep, UnbatchedExecutionExtra, UnbatchedStep, UnionPlan, UnwrapMultistep, };
|
|
35
35
|
export { hookArgs } from "./args.js";
|
|
36
36
|
export { version } from "./version.js";
|
|
37
37
|
/** @deprecated Renamed to 'applyTransforms' */
|
|
@@ -118,11 +118,11 @@ export type EnumValueInput = EnumValueApplyResolver | EnumValueConfig | string |
|
|
|
118
118
|
/**
|
|
119
119
|
* The values/configs for the entries in a GraphQL enum type.
|
|
120
120
|
*/
|
|
121
|
-
export
|
|
121
|
+
export interface EnumPlan {
|
|
122
122
|
values?: {
|
|
123
123
|
[enumValueName: string]: EnumValueInput | undefined;
|
|
124
124
|
};
|
|
125
|
-
}
|
|
125
|
+
}
|
|
126
126
|
/**
|
|
127
127
|
* A map from GraphQL named type to the config for that type.
|
|
128
128
|
*
|
|
@@ -47,6 +47,9 @@ export declare class __TrackedValueStep<TData = any, TInputType extends GraphQLI
|
|
|
47
47
|
execute({ count, values: [values0], }: ExecutionDetails<[TData]>): GrafastResultsList<TData>;
|
|
48
48
|
unbatchedExecute(_extra: UnbatchedExecutionExtra, v: TData): TData;
|
|
49
49
|
private getValuePlan;
|
|
50
|
+
__inferGet?: {
|
|
51
|
+
[TAttribute in keyof TData & string]: __TrackedValueStepWithDollars<TData[TAttribute], TInputType extends GraphQLInputObjectType ? ReturnType<TInputType["getFields"]>[TAttribute]["type"] : undefined>;
|
|
52
|
+
};
|
|
50
53
|
/**
|
|
51
54
|
* Get the named property of an object.
|
|
52
55
|
*/
|
package/dist/steps/__value.d.ts
CHANGED
|
@@ -17,6 +17,9 @@ export declare class __ValueStep<TData> extends Step<TData> {
|
|
|
17
17
|
planJSONExtra(): undefined | Record<string, JSONValue>;
|
|
18
18
|
toStringMeta(): string | null;
|
|
19
19
|
execute(): GrafastResultsList<TData>;
|
|
20
|
+
__inferGet?: {
|
|
21
|
+
[TAttr in keyof TData]: AccessStep<TData[TAttr]>;
|
|
22
|
+
};
|
|
20
23
|
get<TAttr extends keyof TData>(attrName: TAttr): AccessStep<TData[TAttr]>;
|
|
21
24
|
at<TIndex extends keyof TData>(index: TIndex): AccessStep<TData[TIndex]>;
|
|
22
25
|
}
|
package/dist/steps/access.d.ts
CHANGED
|
@@ -22,6 +22,9 @@ export declare class AccessStep<TData> extends UnbatchedStep<TData> {
|
|
|
22
22
|
constructor(parentPlan: Step<unknown>, path: (string | number | symbol)[], fallback?: any | undefined);
|
|
23
23
|
toStringMeta(): string;
|
|
24
24
|
getParentStep(): Step<any> | import("./__flag.js").__FlagStep<Step<any>>;
|
|
25
|
+
__inferGet?: {
|
|
26
|
+
[TAttr in keyof TData]: AccessStep<TData[TAttr]>;
|
|
27
|
+
};
|
|
25
28
|
/**
|
|
26
29
|
* Get the named property of an object.
|
|
27
30
|
*/
|
|
@@ -40,20 +43,4 @@ export declare class AccessStep<TData> extends UnbatchedStep<TData> {
|
|
|
40
43
|
* falling back to `fallback` if it were null-ish.
|
|
41
44
|
*/
|
|
42
45
|
export declare function access<TData>(parentPlan: Step<unknown>, rawPath?: (string | number | symbol)[] | string | number | symbol, fallback?: any): AccessStep<TData>;
|
|
43
|
-
type StepGetReturn<TStep, TAttr extends string> = TStep extends {
|
|
44
|
-
get: (attr: TAttr) => infer U;
|
|
45
|
-
} ? U : TStep extends {
|
|
46
|
-
get: (attr: string) => infer U;
|
|
47
|
-
} ? U : never;
|
|
48
|
-
type StepGetKeys<TStep extends Step> = TStep extends {
|
|
49
|
-
get(attr: infer U): any;
|
|
50
|
-
} ? U : TStep extends Step<infer UData> ? UData extends Record<string, any> ? keyof UData : string : never;
|
|
51
|
-
type StepAccessKey<TStep extends Step, TAttr extends StepGetKeys<TStep> & string> = TStep extends {
|
|
52
|
-
get(attr: any): any;
|
|
53
|
-
} ? StepGetReturn<TStep, TAttr> : TStep extends Step<infer UData> ? UData extends Record<string, any> ? Step<UData[TAttr]> : Step<any> : never;
|
|
54
|
-
/**
|
|
55
|
-
* Call `$step.get(attr)` if possible, falling back to `access($step, attr)`.
|
|
56
|
-
*/
|
|
57
|
-
export declare function get<TStep extends Step, TAttr extends StepGetKeys<TStep> & string>($step: TStep, attr: TAttr): StepAccessKey<TStep, TAttr>;
|
|
58
|
-
export {};
|
|
59
46
|
//# sourceMappingURL=access.d.ts.map
|
package/dist/steps/access.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AccessStep = exports.expressionSymbol = void 0;
|
|
4
4
|
exports.access = access;
|
|
5
|
-
exports.get = get;
|
|
6
5
|
const tslib_1 = require("tslib");
|
|
7
6
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
7
|
const tamedevil_1 = tslib_1.__importDefault(require("tamedevil"));
|
|
@@ -218,12 +217,4 @@ function access(parentPlan, rawPath, fallback) {
|
|
|
218
217
|
}
|
|
219
218
|
return new AccessStep(parentPlan, path, fallback);
|
|
220
219
|
}
|
|
221
|
-
/**
|
|
222
|
-
* Call `$step.get(attr)` if possible, falling back to `access($step, attr)`.
|
|
223
|
-
*/
|
|
224
|
-
function get($step, attr) {
|
|
225
|
-
return "get" in $step && typeof $step.get === "function"
|
|
226
|
-
? $step.get(attr)
|
|
227
|
-
: access($step, attr);
|
|
228
|
-
}
|
|
229
220
|
//# sourceMappingURL=access.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ExecutionDetails, GrafastResultsList, Maybe, UnbatchedExecutionExtra } from "../interfaces.js";
|
|
2
2
|
import type { Step } from "../step.js";
|
|
3
3
|
import { UnbatchedStep } from "../step.js";
|
|
4
|
+
import { ConstantStep } from "./constant.js";
|
|
4
5
|
type ParametersExceptFirst<F> = F extends (arg0: any, ...rest: infer R) => any ? R : never[];
|
|
5
6
|
/**
|
|
6
7
|
* Describes what a plan needs to implement in order to be suitable for
|
|
@@ -96,7 +97,7 @@ export declare class ConnectionStep<TItemStep extends Step, TCursorStep extends
|
|
|
96
97
|
* functions so that they are thrown "earlier", avoiding error bubbling.
|
|
97
98
|
*/
|
|
98
99
|
addValidation(callback: () => Step): void;
|
|
99
|
-
get(fieldName: string): Step<any
|
|
100
|
+
get(fieldName: string): Step<any>;
|
|
100
101
|
edges(): Step;
|
|
101
102
|
nodes(): import("./listTransform.js").__ListTransformStep<any, any, any, any> | TStep;
|
|
102
103
|
wrapEdge($edge: TItemStep): EdgeStep<TItemStep, TCursorStep, TStep, TEdgeDataStep, TNodeStep>;
|
|
@@ -120,7 +121,7 @@ export declare class EdgeStep<TItemStep extends Step, TCursorStep extends Step,
|
|
|
120
121
|
private readonly cursorDepId;
|
|
121
122
|
private needCursor;
|
|
122
123
|
constructor($connection: ConnectionStep<TItemStep, TCursorStep, TStep, TEdgeDataStep, TNodeStep>, $item: TItemStep, skipCursor?: boolean);
|
|
123
|
-
get(fieldName: string): Step<string | null> | TNodeStep
|
|
124
|
+
get(fieldName: string): ConstantStep<undefined> | Step<string | null> | TNodeStep;
|
|
124
125
|
private getConnectionStep;
|
|
125
126
|
private getItemStep;
|
|
126
127
|
data(): TEdgeDataStep;
|
package/dist/steps/connection.js
CHANGED
|
@@ -216,6 +216,8 @@ class ConnectionStep extends step_js_1.UnbatchedStep {
|
|
|
216
216
|
return this.nodes();
|
|
217
217
|
case "pageInfo":
|
|
218
218
|
return this.pageInfo();
|
|
219
|
+
default:
|
|
220
|
+
return (0, constant_js_1.constant)(undefined);
|
|
219
221
|
}
|
|
220
222
|
}
|
|
221
223
|
edges() {
|
|
@@ -298,6 +300,8 @@ class EdgeStep extends step_js_1.UnbatchedStep {
|
|
|
298
300
|
return this.node();
|
|
299
301
|
case "cursor":
|
|
300
302
|
return this.cursor();
|
|
303
|
+
default:
|
|
304
|
+
return (0, constant_js_1.constant)(undefined);
|
|
301
305
|
}
|
|
302
306
|
}
|
|
303
307
|
getConnectionStep() {
|
package/dist/steps/constant.d.ts
CHANGED
|
@@ -19,7 +19,10 @@ export declare class ConstantStep<TData> extends UnbatchedStep<TData> {
|
|
|
19
19
|
unbatchedExecute(): TData;
|
|
20
20
|
isNull(): boolean;
|
|
21
21
|
isUndefined(): boolean;
|
|
22
|
-
|
|
22
|
+
__inferGet?: {
|
|
23
|
+
[TKey in keyof TData]: ConstantStep<TData[TKey]>;
|
|
24
|
+
};
|
|
25
|
+
get<TKey extends keyof TData>(key: TKey): ConstantStep<TData[TKey]>;
|
|
23
26
|
at(index: number): ConstantStep<any>;
|
|
24
27
|
}
|
|
25
28
|
/**
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Step } from "../step.js";
|
|
2
|
+
/**
|
|
3
|
+
* If your step class has a `get` method you should implement this so users
|
|
4
|
+
* benefit from type safety.
|
|
5
|
+
*
|
|
6
|
+
* e.g.
|
|
7
|
+
* ```ts
|
|
8
|
+
* class MyStep extends Step {
|
|
9
|
+
* __inferGet?: {
|
|
10
|
+
* [TKey in keyof MyData]: MySpecialStep<MyData[TKey]>;
|
|
11
|
+
* };
|
|
12
|
+
* get<TKey extends keyof MyData>(key: TKey): MySpecialStep<MyData[TKey]> {
|
|
13
|
+
* // ...
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
interface HasInferredGet<TStepByKey extends Record<string, Step>> {
|
|
19
|
+
/**
|
|
20
|
+
* TypeScript hack so we can infer the type of getting each key; this key
|
|
21
|
+
* won't actually have a value
|
|
22
|
+
*/
|
|
23
|
+
__inferGet?: TStepByKey;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Determines the keys that a given step represents
|
|
27
|
+
*
|
|
28
|
+
* 1. If it implements HasInferredGet, get the explicit keys
|
|
29
|
+
* 2. Otherwise, if it has a get method, figure out which attributes it accepts
|
|
30
|
+
* 3. Otherwise, determine the type the Step encodes and extract the keys of that
|
|
31
|
+
*/
|
|
32
|
+
type StepGetKeys<TStep extends Step> = TStep extends HasInferredGet<infer UStepByKey> ? keyof UStepByKey : TStep extends {
|
|
33
|
+
get(attr: infer U): any;
|
|
34
|
+
} ? U : TStep extends Step<infer UData | null | undefined> ? keyof UData : never;
|
|
35
|
+
/**
|
|
36
|
+
* Determines the type of the step returned from `get(step, attr)`.
|
|
37
|
+
*
|
|
38
|
+
* 1. If it implements HasInferredGet, get a step representing that specific attribute
|
|
39
|
+
* 2. Otherwise, if it has a get method, return the ReturnType of that method
|
|
40
|
+
* 3. Otherwise, determine the type the Step encodes and return a Step representing the relevant key of that
|
|
41
|
+
*/
|
|
42
|
+
type GetResult<TStep extends Step, TAttr extends StepGetKeys<TStep>> = TStep extends HasInferredGet<infer UStepByKey> ? TAttr extends keyof UStepByKey ? UStepByKey[TAttr] : never : TStep extends {
|
|
43
|
+
get(attr: any): infer UGetStep;
|
|
44
|
+
} ? UGetStep : TStep extends Step<infer UData | null | undefined> ? TAttr extends keyof UData ? Step<UData[TAttr]> : never : never;
|
|
45
|
+
/**
|
|
46
|
+
* Call `$step.get(attr)` if possible, falling back to `access($step, attr)`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function get<TStep extends Step, TAttr extends StepGetKeys<TStep> & string>($step: TStep, attr: TAttr): GetResult<TStep, TAttr>;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=get.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.get = get;
|
|
4
|
+
const access_js_1 = require("./access.js");
|
|
5
|
+
/**
|
|
6
|
+
* Call `$step.get(attr)` if possible, falling back to `access($step, attr)`.
|
|
7
|
+
*/
|
|
8
|
+
function get($step, attr) {
|
|
9
|
+
return "get" in $step && typeof $step.get === "function"
|
|
10
|
+
? $step.get(attr)
|
|
11
|
+
: (0, access_js_1.access)($step, attr);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=get.js.map
|
package/dist/steps/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { __FlagStep, assertNotNull, inhibitOnNull, trap, TRAP_ERROR, TRAP_ERROR_OR_INHIBITED, TRAP_INHIBITED, } from "./__flag.js";
|
|
2
|
-
export { access, AccessStep
|
|
2
|
+
export { access, AccessStep } from "./access.js";
|
|
3
3
|
export { coalesce, CoalesceStep } from "./coalesce.js";
|
|
4
4
|
export { assertEdgeCapableStep, assertPageInfoCapableStep, connection, ConnectionCapableStep, ConnectionStep, EdgeCapableStep, EdgeStep, PageInfoCapableStep, } from "./connection.js";
|
|
5
5
|
export { constant, ConstantStep } from "./constant.js";
|
|
@@ -7,6 +7,7 @@ export { each } from "./each.js";
|
|
|
7
7
|
export { error, ErrorStep } from "./error.js";
|
|
8
8
|
export { filter, FilterPlanMemo } from "./filter.js";
|
|
9
9
|
export { first, FirstStep } from "./first.js";
|
|
10
|
+
export { get } from "./get.js";
|
|
10
11
|
export { groupBy, GroupByPlanMemo } from "./groupBy.js";
|
|
11
12
|
export { lambda, LambdaStep } from "./lambda.js";
|
|
12
13
|
export { last, LastStep } from "./last.js";
|
package/dist/steps/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReverseStep = exports.reverseArray = exports.reverse = exports.RemapKeysStep = exports.remapKeys = exports.partitionByIndex = exports.ObjectStep = exports.object = exports.specFromNodeId = exports.NodeStep = exports.nodeIdFromNode = exports.node = exports.makeDecodeNodeIdRuntime = exports.makeDecodeNodeId = exports.listTransform = exports.__ListTransformStep = exports.ListenStep = exports.listen = exports.ListStep = exports.list = exports.LastStep = exports.last = exports.LambdaStep = exports.lambda = exports.groupBy = exports.FirstStep = exports.first = exports.filter = exports.ErrorStep = exports.error = exports.each = exports.ConstantStep = exports.constant = exports.EdgeStep = exports.ConnectionStep = exports.connection = exports.assertPageInfoCapableStep = exports.assertEdgeCapableStep = exports.CoalesceStep = exports.coalesce = exports.
|
|
3
|
+
exports.ReverseStep = exports.reverseArray = exports.reverse = exports.RemapKeysStep = exports.remapKeys = exports.partitionByIndex = exports.ObjectStep = exports.object = exports.specFromNodeId = exports.NodeStep = exports.nodeIdFromNode = exports.node = exports.makeDecodeNodeIdRuntime = exports.makeDecodeNodeId = exports.listTransform = exports.__ListTransformStep = exports.ListenStep = exports.listen = exports.ListStep = exports.list = exports.LastStep = exports.last = exports.LambdaStep = exports.lambda = exports.groupBy = exports.get = exports.FirstStep = exports.first = exports.filter = exports.ErrorStep = exports.error = exports.each = exports.ConstantStep = exports.constant = exports.EdgeStep = exports.ConnectionStep = exports.connection = exports.assertPageInfoCapableStep = exports.assertEdgeCapableStep = exports.CoalesceStep = exports.coalesce = exports.AccessStep = exports.access = exports.TRAP_INHIBITED = exports.TRAP_ERROR_OR_INHIBITED = exports.TRAP_ERROR = exports.trap = exports.inhibitOnNull = exports.assertNotNull = exports.__FlagStep = void 0;
|
|
4
4
|
exports.ProxyStep = exports.proxy = exports.LoadStep = exports.loadOneCallback = exports.loadOne = exports.loadManyCallback = exports.loadMany = exports.LoadedRecordStep = exports.GraphQLResolverStep = exports.graphqlResolver = exports.ConditionStep = exports.condition = exports.BakedInputStep = exports.bakedInputRuntime = exports.bakedInput = exports.ApplyTransformsStep = exports.applyTransforms = exports.Modifier = exports.isModifier = exports.assertModifier = exports.ApplyInputStep = exports.applyInput = exports.__ValueStep = exports.__TrackedValueStep = exports.__ItemStep = exports.__InputStaticLeafStep = exports.__InputObjectStep = exports.__InputListStep = exports.SideEffectStep = exports.sideEffect = exports.setter = exports.Setter = exports.createObjectAndApplyChildren = void 0;
|
|
5
5
|
var __flag_js_1 = require("./__flag.js");
|
|
6
6
|
Object.defineProperty(exports, "__FlagStep", { enumerable: true, get: function () { return __flag_js_1.__FlagStep; } });
|
|
@@ -13,7 +13,6 @@ Object.defineProperty(exports, "TRAP_INHIBITED", { enumerable: true, get: functi
|
|
|
13
13
|
var access_js_1 = require("./access.js");
|
|
14
14
|
Object.defineProperty(exports, "access", { enumerable: true, get: function () { return access_js_1.access; } });
|
|
15
15
|
Object.defineProperty(exports, "AccessStep", { enumerable: true, get: function () { return access_js_1.AccessStep; } });
|
|
16
|
-
Object.defineProperty(exports, "get", { enumerable: true, get: function () { return access_js_1.get; } });
|
|
17
16
|
var coalesce_js_1 = require("./coalesce.js");
|
|
18
17
|
Object.defineProperty(exports, "coalesce", { enumerable: true, get: function () { return coalesce_js_1.coalesce; } });
|
|
19
18
|
Object.defineProperty(exports, "CoalesceStep", { enumerable: true, get: function () { return coalesce_js_1.CoalesceStep; } });
|
|
@@ -36,6 +35,8 @@ Object.defineProperty(exports, "filter", { enumerable: true, get: function () {
|
|
|
36
35
|
var first_js_1 = require("./first.js");
|
|
37
36
|
Object.defineProperty(exports, "first", { enumerable: true, get: function () { return first_js_1.first; } });
|
|
38
37
|
Object.defineProperty(exports, "FirstStep", { enumerable: true, get: function () { return first_js_1.FirstStep; } });
|
|
38
|
+
var get_js_1 = require("./get.js");
|
|
39
|
+
Object.defineProperty(exports, "get", { enumerable: true, get: function () { return get_js_1.get; } });
|
|
39
40
|
var groupBy_js_1 = require("./groupBy.js");
|
|
40
41
|
Object.defineProperty(exports, "groupBy", { enumerable: true, get: function () { return groupBy_js_1.groupBy; } });
|
|
41
42
|
var lambda_js_1 = require("./lambda.js");
|
package/dist/steps/object.d.ts
CHANGED
|
@@ -57,6 +57,7 @@ export declare class ObjectStep<TPlans extends {
|
|
|
57
57
|
unbatchedExecute(_extra: UnbatchedExecutionExtra, ..._values: any[]): any;
|
|
58
58
|
deduplicate(peers: ObjectStep<any>[]): ObjectStep<TPlans>[];
|
|
59
59
|
optimize(opts: StepOptimizeOptions): ConstantStep<any> | this | ConstantStep<Record<string, any>>;
|
|
60
|
+
__inferGet?: TPlans;
|
|
60
61
|
/**
|
|
61
62
|
* Get the original plan with the given key back again.
|
|
62
63
|
*/
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "0.1.1-beta.
|
|
1
|
+
export declare const version = "0.1.1-beta.25";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED