grafast 0.0.1-alpha.13 → 0.0.1-alpha.15

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.
Files changed (66) hide show
  1. package/dist/args.d.ts +7 -5
  2. package/dist/assert.d.ts +2 -0
  3. package/dist/bucket.d.ts +64 -0
  4. package/dist/constraints.d.ts +31 -0
  5. package/dist/deferred.d.ts +7 -0
  6. package/dist/dev.d.ts +3 -0
  7. package/dist/engine/LayerPlan.d.ts +131 -0
  8. package/dist/engine/OperationPlan.d.ts +151 -0
  9. package/dist/engine/OutputPlan.d.ts +105 -1
  10. package/dist/engine/StepTracker.d.ts +53 -0
  11. package/dist/engine/executeBucket.d.ts +2 -0
  12. package/dist/engine/executeOutputPlan.d.ts +41 -0
  13. package/dist/envelop.d.ts +12 -0
  14. package/dist/envelop.js +4 -4
  15. package/dist/error.d.ts +23 -0
  16. package/dist/establishOperationPlan.d.ts +7 -0
  17. package/dist/execute.d.ts +8 -0
  18. package/dist/exportAs.d.ts +14 -0
  19. package/dist/grafastGraphql.d.ts +8 -3
  20. package/dist/grafastPrint.d.ts +8 -0
  21. package/dist/graphqlCollectFields.d.ts +22 -0
  22. package/dist/graphqlMergeSelectionSets.d.ts +4 -0
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.js +4 -4
  25. package/dist/input.d.ts +7 -0
  26. package/dist/interfaces.d.ts +267 -5
  27. package/dist/makeGrafastSchema.d.ts +27 -0
  28. package/dist/mermaid.d.ts +28 -0
  29. package/dist/polymorphic.d.ts +8 -0
  30. package/dist/prepare.d.ts +16 -0
  31. package/dist/step.d.ts +183 -0
  32. package/dist/steps/__inputDynamicScalar.d.ts +3 -0
  33. package/dist/steps/__inputList.d.ts +3 -0
  34. package/dist/steps/__inputObject.d.ts +3 -0
  35. package/dist/steps/__inputStaticLeaf.d.ts +5 -0
  36. package/dist/steps/__item.d.ts +8 -0
  37. package/dist/steps/__trackedValue.d.ts +74 -0
  38. package/dist/steps/__value.d.ts +5 -0
  39. package/dist/steps/access.d.ts +19 -0
  40. package/dist/steps/applyTransforms.d.ts +13 -0
  41. package/dist/steps/connection.d.ts +47 -0
  42. package/dist/steps/constant.d.ts +7 -0
  43. package/dist/steps/each.d.ts +3 -0
  44. package/dist/steps/filter.d.ts +4 -0
  45. package/dist/steps/first.d.ts +4 -0
  46. package/dist/steps/graphqlResolver.d.ts +18 -0
  47. package/dist/steps/groupBy.d.ts +6 -0
  48. package/dist/steps/index.d.ts +4 -0
  49. package/dist/steps/lambda.d.ts +8 -0
  50. package/dist/steps/last.d.ts +4 -0
  51. package/dist/steps/list.d.ts +7 -0
  52. package/dist/steps/listTransform.d.ts +21 -0
  53. package/dist/steps/listen.d.ts +16 -0
  54. package/dist/steps/load.d.ts +13 -0
  55. package/dist/steps/node.d.ts +12 -0
  56. package/dist/steps/object.d.ts +15 -0
  57. package/dist/steps/partitionByIndex.d.ts +35 -0
  58. package/dist/steps/proxy.d.ts +11 -0
  59. package/dist/steps/remapKeys.d.ts +8 -0
  60. package/dist/steps/reverse.d.ts +9 -0
  61. package/dist/subscribe.d.ts +4 -0
  62. package/dist/utils.d.ts +102 -0
  63. package/dist/version.d.ts +1 -1
  64. package/fwd/graphql/index.d.ts +1 -0
  65. package/fwd/graphql/index.js +1 -0
  66. package/package.json +2 -2
@@ -4,6 +4,12 @@ import type { ExecutionExtra, GrafastResultsList, GrafastResultStreamList, Grafa
4
4
  import type { PolymorphicStep } from "../step.js";
5
5
  import { ExecutableStep, UnbatchedExecutableStep } from "../step.js";
6
6
  type ResolveInfoBase = Omit<GraphQLResolveInfo, "path" | "rootValue" | "variableValues">;
7
+ /**
8
+ * Calls the given GraphQL resolver for each input - emulates GraphQL
9
+ * resolution.
10
+ *
11
+ * @internal
12
+ */
7
13
  export declare class GraphQLResolverStep extends UnbatchedExecutableStep {
8
14
  private resolver;
9
15
  private subscriber;
@@ -20,6 +26,7 @@ export declare class GraphQLResolverStep extends UnbatchedExecutableStep {
20
26
  private contextDep;
21
27
  private variableValuesDep;
22
28
  private rootValueDep;
29
+ /** root fields can have null parent */
23
30
  private isNotRoot;
24
31
  constructor(resolver: (GraphQLFieldResolver<any, any> & {
25
32
  displayName?: string;
@@ -32,6 +39,7 @@ export declare class GraphQLResolverStep extends UnbatchedExecutableStep {
32
39
  unbatchedStream(_extra: ExecutionExtra, source: any, args: any, context: any, variableValues: any, rootValue: any): any;
33
40
  stream(count: number, values: ReadonlyArray<GrafastValuesList<any>>, extra: ExecutionExtra): Promise<GrafastResultStreamList<any>>;
34
41
  }
42
+ /** @internal */
35
43
  export declare class GraphQLItemHandler extends ExecutableStep implements PolymorphicStep {
36
44
  static $$export: {
37
45
  moduleName: string;
@@ -43,6 +51,10 @@ export declare class GraphQLItemHandler extends ExecutableStep implements Polymo
43
51
  constructor($parent: ExecutableStep, nullableType: GraphQLNullableType & GraphQLOutputType);
44
52
  planForType(): this;
45
53
  listItem($item: __ItemStep<any>): GraphQLItemHandler;
54
+ /**
55
+ * Akin to graphql-js' completeAbstractValue... but just the typeName
56
+ * resolution part.
57
+ */
46
58
  private figureOutTheTypeOf;
47
59
  private actuallyWrapData;
48
60
  private polymorphicWrapData;
@@ -54,6 +66,12 @@ export declare class GraphQLItemHandler extends ExecutableStep implements Polymo
54
66
  execute(_count: number, values: [GrafastValuesList<any>]): GrafastResultsList<any>;
55
67
  }
56
68
  export declare function graphqlItemHandler($item: ExecutableStep, nullableType: GraphQLNullableType & GraphQLOutputType): GraphQLItemHandler;
69
+ /**
70
+ * Emulates what GraphQL does when calling a resolver, including handling of
71
+ * polymorphism.
72
+ *
73
+ * @internal
74
+ */
57
75
  export declare function graphqlResolver(resolver: GraphQLFieldResolver<any, any> | null | undefined, subscriber: GraphQLFieldResolver<any, any> | null | undefined, $step: ExecutableStep, $args: ObjectStep, resolveInfoBase: ResolveInfoBase): ExecutableStep;
58
76
  export {};
59
77
  //# sourceMappingURL=graphqlResolver.d.ts.map
@@ -1,5 +1,11 @@
1
1
  import type { ExecutableStep } from "../step.js";
2
2
  import type { __ListTransformStep, ListTransformItemPlanCallback } from "./listTransform.js";
3
3
  export type GroupByPlanMemo = Map<unknown, unknown[]>;
4
+ /**
5
+ * Takes a single dimensional list plan and a mapper that returns a grouping
6
+ * key. Returns a plan that results in a Map where the keys are the grouping
7
+ * keys and the values are lists of the original entries that match these
8
+ * grouping keys.
9
+ */
4
10
  export declare function groupBy<TListStep extends ExecutableStep<readonly any[]>, TItemStep extends ExecutableStep<number>>(listStep: TListStep, mapper: ListTransformItemPlanCallback<TListStep, TItemStep>): __ListTransformStep<TListStep, TItemStep, GroupByPlanMemo, any>;
5
11
  //# sourceMappingURL=groupBy.d.ts.map
@@ -2,6 +2,10 @@ import type { OperationPlan } from "../index.js";
2
2
  import type { __ValueStep } from "./__value.js";
3
3
  export declare function operationPlan(): OperationPlan;
4
4
  export declare function context<TContext extends Grafast.Context = Grafast.Context>(): __ValueStep<TContext>;
5
+ /**
6
+ * Turns on debug mode, calls the callback, and then turns debug mode back off
7
+ * again.
8
+ */
5
9
  export declare function debugPlans<T>(callback: () => T): T;
6
10
  export { access, AccessStep } from "./access.js";
7
11
  export { assertEdgeCapableStep, assertPageInfoCapableStep, connection, ConnectionCapableStep, ConnectionStep, EdgeCapableStep, EdgeStep, PageInfoCapableStep, } from "./connection.js";
@@ -1,6 +1,9 @@
1
1
  import type { ExecutionExtra, PromiseOrDirect, UnwrapPlanTuple } from "../interfaces.js";
2
2
  import type { ExecutableStep } from "../step.js";
3
3
  import { UnbatchedExecutableStep } from "../step.js";
4
+ /**
5
+ * Calls the given lambda function for each tuple
6
+ */
4
7
  export declare class LambdaStep<TIn, TOut> extends UnbatchedExecutableStep<TOut> {
5
8
  private fn;
6
9
  static $$export: {
@@ -15,6 +18,11 @@ export declare class LambdaStep<TIn, TOut> extends UnbatchedExecutableStep<TOut>
15
18
  deduplicate(peers: LambdaStep<any, any>[]): LambdaStep<TIn, TOut>[];
16
19
  unbatchedExecute(_extra: ExecutionExtra, value: TIn): PromiseOrDirect<TOut>;
17
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
+ */
18
26
  declare function lambda<const TIn extends readonly ExecutableStep[], TOut>(plans: TIn, fn: (value: UnwrapPlanTuple<TIn>) => PromiseOrDirect<TOut>, isSyncAndSafe?: boolean): LambdaStep<UnwrapPlanTuple<TIn>, TOut>;
19
27
  declare function lambda<const TIn, TOut>($plan: ExecutableStep<TIn> | null | undefined, fn: (value: TIn) => PromiseOrDirect<TOut>, isSyncAndSafe?: boolean): LambdaStep<TIn, TOut>;
20
28
  export { lambda };
@@ -13,5 +13,9 @@ export declare class LastStep<TData> extends UnbatchedExecutableStep<TData> {
13
13
  deduplicate(peers: LastStep<TData>[]): LastStep<TData>[];
14
14
  optimize(): ExecutableStep<any> | this;
15
15
  }
16
+ /**
17
+ * A plan that resolves to the last entry in the list returned by the given
18
+ * plan.
19
+ */
16
20
  export declare function last<TData>(plan: ExecutableStep<ReadonlyArray<TData>>): LastStep<TData>;
17
21
  //# sourceMappingURL=last.d.ts.map
@@ -16,7 +16,14 @@ export declare class ListStep<const TPlanTuple extends readonly ExecutableStep[]
16
16
  unbatchedExecute(_extra: ExecutionExtra, ...values: any[]): UnwrapPlanTuple<TPlanTuple>;
17
17
  deduplicate(peers: ListStep<TPlanTuple>[]): ListStep<TPlanTuple>[];
18
18
  optimize(opts: StepOptimizeOptions): this | ConstantStep<any[]>;
19
+ /**
20
+ * Get the original plan at the given index back again.
21
+ */
19
22
  at<TIndex extends keyof TPlanTuple>(index: TIndex): TPlanTuple[TIndex];
20
23
  }
24
+ /**
25
+ * Takes a list of plans and turns it into a single plan that represents the
26
+ * list of their values.
27
+ */
21
28
  export declare function list<const TPlanTuple extends readonly ExecutableStep[]>(list: TPlanTuple): ListStep<TPlanTuple>;
22
29
  //# sourceMappingURL=list.d.ts.map
@@ -19,6 +19,15 @@ export interface ListTransformOptions<TListStep extends ExecutableStep<readonly
19
19
  optimize?: (this: __ListTransformStep<TListStep, TDepsStep, TMemo, TItemStep>) => ExecutableStep;
20
20
  connectionClone?: ConnectionCapableStep<TListStep, any>["connectionClone"];
21
21
  }
22
+ /**
23
+ * **Experimental.**
24
+ *
25
+ * A "special" plan that has custom handling in Grafast. Used for turning lists
26
+ * into other things (or maybe more lists!).
27
+ *
28
+ * It's recommended that you don't use this directly, please use one of the
29
+ * functions that uses this under the hood such as `filter()`.
30
+ */
22
31
  export declare class __ListTransformStep<TListStep extends ExecutableStep<readonly any[]> = ExecutableStep<readonly any[]>, TDepsStep extends ExecutableStep = ExecutableStep, TMemo = any, TItemStep extends ExecutableStep | undefined = ExecutableStep | undefined> extends ExecutableStep<TMemo> {
23
32
  static $$export: {
24
33
  moduleName: string;
@@ -33,7 +42,11 @@ export declare class __ListTransformStep<TListStep extends ExecutableStep<readon
33
42
  listItem?: (itemPlan: __ItemStep<this>) => TItemStep;
34
43
  private meta;
35
44
  connectionClone?: ConnectionCapableStep<TListStep, any>["connectionClone"];
45
+ /** Set during query planning. */
36
46
  itemStepId: number;
47
+ /**
48
+ * @internal
49
+ */
37
50
  subroutineLayer: LayerPlan<LayerPlanReasonSubroutine>;
38
51
  constructor(options: ListTransformOptions<TListStep, TDepsStep, TMemo, TItemStep>);
39
52
  toStringMeta(): string | null;
@@ -44,5 +57,13 @@ export declare class __ListTransformStep<TListStep extends ExecutableStep<readon
44
57
  optimize(): ExecutableStep;
45
58
  execute(_count: number, values: [GrafastValuesList<any[] | null | undefined | GrafastError>], extra: ExecutionExtra): Promise<GrafastResultsList<TMemo>>;
46
59
  }
60
+ /**
61
+ * **Experimental.**
62
+ *
63
+ * A "special" plan that has custom handling in Grafast. Used for turning lists
64
+ * into other things (or maybe more lists!).
65
+ *
66
+ * {@page ~grafast/steps/listTransform.md}
67
+ */
47
68
  export declare function listTransform<TListStep extends ExecutableStep<readonly any[]>, TDepsStep extends ExecutableStep, TMemo, TItemStep extends ExecutableStep | undefined = undefined>(options: ListTransformOptions<TListStep, TDepsStep, TMemo, TItemStep>): __ListTransformStep<TListStep, TDepsStep, TMemo, TItemStep>;
48
69
  //# sourceMappingURL=listTransform.d.ts.map
@@ -2,6 +2,11 @@ import type { GrafastResultStreamList, GrafastSubscriber, GrafastValuesList } fr
2
2
  import type { StreamableStep } from "../step.js";
3
3
  import { ExecutableStep } from "../step.js";
4
4
  import type { __ItemStep } from "./__item.js";
5
+ /**
6
+ * Subscribes to the given `pubsubOrPlan` to get realtime updates on a given
7
+ * topic (`topicOrPlan`), mapping the resulting event via the `itemPlan`
8
+ * callback.
9
+ */
5
10
  export declare class ListenStep<TTopics extends {
6
11
  [topic: string]: any;
7
12
  }, TTopic extends keyof TTopics, TPayloadStep extends ExecutableStep> extends ExecutableStep<TTopics[TTopic]> implements StreamableStep<TTopics[TTopic]> {
@@ -11,7 +16,13 @@ export declare class ListenStep<TTopics extends {
11
16
  exportName: string;
12
17
  };
13
18
  isSyncAndSafe: boolean;
19
+ /**
20
+ * The id for the PostgreSQL context plan.
21
+ */
14
22
  private pubsubDep;
23
+ /**
24
+ * The plan that will tell us which topic we're subscribing to.
25
+ */
15
26
  private topicDep;
16
27
  constructor(pubsubOrPlan: ExecutableStep<GrafastSubscriber<TTopics> | null> | GrafastSubscriber<TTopics> | null, topicOrPlan: ExecutableStep<TTopic> | string, itemPlan?: (itemPlan: __ItemStep<TTopics[TTopic]>) => TPayloadStep);
17
28
  execute(): never;
@@ -20,6 +31,11 @@ export declare class ListenStep<TTopics extends {
20
31
  GrafastValuesList<TTopic>
21
32
  ]): GrafastResultStreamList<TTopics[TTopic]>;
22
33
  }
34
+ /**
35
+ * Subscribes to the given `pubsubOrPlan` to get realtime updates on a given
36
+ * topic (`topicOrPlan`), mapping the resulting event via the `itemPlan`
37
+ * callback.
38
+ */
23
39
  export declare function listen<TTopics extends {
24
40
  [topic: string]: any;
25
41
  }, TTopic extends keyof TTopics, TPayloadStep extends ExecutableStep>(pubsubOrPlan: ExecutableStep<GrafastSubscriber<TTopics> | null> | GrafastSubscriber<TTopics> | null, topicOrPlan: ExecutableStep<TTopic> | string, itemPlan?: (itemPlan: __ItemStep<TTopics[TTopic]>) => TPayloadStep): ListenStep<TTopics, TTopic, TPayloadStep>;
@@ -11,8 +11,21 @@ type LoadCallback<TSpec, TItem, TData extends TItem | ReadonlyArray<TItem>, TPar
11
11
  };
12
12
  export type LoadOneCallback<TSpec, TItem, TParams extends Record<string, any>> = LoadCallback<TSpec, TItem, TItem, TParams>;
13
13
  export type LoadManyCallback<TSpec, TItem, TParams extends Record<string, any>> = LoadCallback<TSpec, TItem, ReadonlyArray<TItem>, TParams>;
14
+ /**
15
+ * A TypeScript Identity Function to help you strongly type your
16
+ * LoadOneCallback.
17
+ */
14
18
  export declare function loadOneCallback<TSpec, TItem, TParams extends Record<string, any>>(callback: LoadOneCallback<TSpec, TItem, TParams>): LoadOneCallback<TSpec, TItem, TParams>;
19
+ /**
20
+ * A TypeScript Identity Function to help you strongly type your
21
+ * LoadManyCallback.
22
+ */
15
23
  export declare function loadManyCallback<TSpec, TItem, TParams extends Record<string, any>>(callback: LoadManyCallback<TSpec, TItem, TParams>): LoadManyCallback<TSpec, TItem, TParams>;
24
+ /**
25
+ * You shouldn't create instances of this yourself - use `loadOne` or `loadMany` instead.
26
+ *
27
+ * @internal
28
+ */
16
29
  export declare class LoadedRecordStep<TItem, TParams extends Record<string, any>> extends ExecutableStep<TItem> {
17
30
  private isSingle;
18
31
  private sourceDescription;
@@ -2,6 +2,12 @@ import type { GraphQLObjectType } from "graphql";
2
2
  import type { ExecutionExtra, NodeIdHandler, PolymorphicData } from "../interfaces.js";
3
3
  import type { ExecutableStep, PolymorphicStep } from "../step.js";
4
4
  import { UnbatchedExecutableStep } from "../step.js";
5
+ /**
6
+ * A plan to get a Node by it's global object identifier (string). Accepts an
7
+ * object specifying the supported codecs, an object map detailing the
8
+ * typeNames supported and their details (codec to use, how to find the record,
9
+ * etc), and finally the Node id string plan.
10
+ */
5
11
  export declare class NodeStep extends UnbatchedExecutableStep implements PolymorphicStep {
6
12
  private possibleTypes;
7
13
  static $$export: {
@@ -18,6 +24,12 @@ export declare class NodeStep extends UnbatchedExecutableStep implements Polymor
18
24
  private getTypeNameFromSpecifier;
19
25
  unbatchedExecute: (_extra: ExecutionExtra, specifier: any) => PolymorphicData<string, ReadonlyArray<any>> | null;
20
26
  }
27
+ /**
28
+ * A plan to get a Node by it's global object identifier (string). Accepts an
29
+ * object specifying the supported codecs, an object map detailing the
30
+ * typeNames supported and their details (codec to use, how to find the record,
31
+ * etc), and finally the Node id string plan.
32
+ */
21
33
  export declare function node(possibleTypes: {
22
34
  [typeName: string]: NodeIdHandler;
23
35
  }, $id: ExecutableStep<string>): NodeStep;
@@ -20,6 +20,10 @@ export interface ObjectPlanMeta<TPlans extends {
20
20
  }> {
21
21
  results: Results<TPlans>;
22
22
  }
23
+ /**
24
+ * A plan that represents an object using the keys given and the values being
25
+ * the results of the associated plans.
26
+ */
23
27
  export declare class ObjectStep<TPlans extends {
24
28
  [key: string]: ExecutableStep;
25
29
  } = {
@@ -34,6 +38,10 @@ export declare class ObjectStep<TPlans extends {
34
38
  private keys;
35
39
  optimizeMetaKey: string;
36
40
  constructor(obj: TPlans);
41
+ /**
42
+ * This key doesn't get typed, but it can be added later which can be quite
43
+ * handy.
44
+ */
37
45
  set<TKey extends keyof TPlans>(key: TKey, plan: TPlans[TKey]): void;
38
46
  getStepForKey<TKey extends keyof TPlans>(key: TKey, allowMissing?: boolean): TKey extends keyof TPlans ? TPlans[TKey] : null;
39
47
  toStringMeta(): string;
@@ -43,8 +51,15 @@ export declare class ObjectStep<TPlans extends {
43
51
  unbatchedExecute(_extra: ExecutionExtra, ..._values: any[]): any;
44
52
  deduplicate(peers: ObjectStep<any>[]): ObjectStep<TPlans>[];
45
53
  optimize(opts: StepOptimizeOptions): this | ConstantStep<any>;
54
+ /**
55
+ * Get the original plan with the given key back again.
56
+ */
46
57
  get<TKey extends keyof TPlans>(key: TKey): TPlans[TKey];
47
58
  }
59
+ /**
60
+ * A plan that represents an object using the keys given and the values being
61
+ * the results of the associated plans.
62
+ */
48
63
  export declare function object<TPlans extends {
49
64
  [key: string]: ExecutableStep;
50
65
  }>(obj: TPlans): ObjectStep<TPlans>;
@@ -1,4 +1,39 @@
1
1
  import type { ExecutableStep } from "../step.js";
2
2
  import type { __ListTransformStep, ListTransformItemPlanCallback } from "./listTransform.js";
3
+ /**
4
+ * Takes a single dimensional list plan and a mapper that calculates a
5
+ * (potentially duplicate) target index for each entry in the list. Returns a
6
+ * plan that results in a two dimensional list of the items in the original
7
+ * list partitioned (grouped) by their target index.
8
+ *
9
+ * If your datasource returns indexes that are 1-indexed then you may pass `1`
10
+ * as the third argument and we'll account for this.
11
+ *
12
+ * @example For this data:
13
+ *
14
+ * ```jsonc
15
+ * [
16
+ * {"array_idx": 1, "id": "b0b00000-0000-0000-0000-000000000b0b", "username": "Bob"},
17
+ * {"array_idx": 2, "id": "a11ce000-0000-0000-0000-0000000a11ce", "username": "Alice"}],
18
+ * {"array_idx": 2, "id": "cec111a0-0000-0000-0000-00000cec111a", "username": "Cecilia"}],
19
+ * ]
20
+ * ```
21
+ *
22
+ * partitioning by the array_idx (which is 1-indexed), would result in:
23
+ *
24
+ * ```jsonc
25
+ * [
26
+ * [
27
+ * {"array_idx": 1, "id": "b0b00000-0000-0000-0000-000000000b0b", "username": "Bob"},
28
+ * ],
29
+ * [
30
+ * {"array_idx": 2, "id": "a11ce000-0000-0000-0000-0000000a11ce", "username": "Alice"}],
31
+ * {"array_idx": 2, "id": "cec111a0-0000-0000-0000-00000cec111a", "username": "Cecilia"}],
32
+ * ],
33
+ * ]
34
+ * ```
35
+ *
36
+ * Beware: the target indexes should not contain gaps.
37
+ */
3
38
  export declare function partitionByIndex<TListStep extends ExecutableStep<readonly any[]>, TItemStep extends ExecutableStep<number>>(listStep: TListStep, mapper: ListTransformItemPlanCallback<TListStep, TItemStep>, startIndex?: 0 | 1): __ListTransformStep<TListStep, TItemStep, unknown[][], any>;
4
39
  //# sourceMappingURL=partitionByIndex.d.ts.map
@@ -3,6 +3,11 @@ import type { ExecutionExtra } from "../interfaces.js";
3
3
  import { $$proxy } from "../interfaces.js";
4
4
  import type { ExecutableStep } from "../step.js";
5
5
  import { UnbatchedExecutableStep } from "../step.js";
6
+ /**
7
+ * @experimental
8
+ *
9
+ * Never build this class directly.
10
+ */
6
11
  export declare class ProxyStep<T> extends UnbatchedExecutableStep<T> {
7
12
  static $$export: {
8
13
  moduleName: string;
@@ -22,6 +27,12 @@ declare module "../step.js" {
22
27
  [$$proxy]?: any;
23
28
  }
24
29
  }
30
+ /**
31
+ * @experimental
32
+ *
33
+ * This could change at any time, may impact performance, and just, generally,
34
+ * needs more work. You shouldn't need this in the vast majority of cases.
35
+ */
25
36
  export declare function proxy<TData, TStep extends ExecutableStep<TData>>($step: TStep, $actualDep?: ExecutableStep): TStep & {
26
37
  addDependency(step: ExecutableStep): number;
27
38
  };
@@ -4,6 +4,10 @@ import { UnbatchedExecutableStep } from "../step.js";
4
4
  export type ActualKeyByDesiredKey = {
5
5
  [desiredKey: string]: string;
6
6
  };
7
+ /**
8
+ * A plan that returns an object resulting from extracting the given
9
+ * `actualKey` from the input and storing it as the `desiredKey` in the output.
10
+ */
7
11
  export declare class RemapKeysStep extends UnbatchedExecutableStep {
8
12
  private actualKeyByDesiredKey;
9
13
  static $$export: {
@@ -21,6 +25,10 @@ export declare class RemapKeysStep extends UnbatchedExecutableStep {
21
25
  unbatchedExecute(_extra: ExecutionExtra, value: any): any;
22
26
  deduplicate(peers: RemapKeysStep[]): RemapKeysStep[];
23
27
  }
28
+ /**
29
+ * A plan that returns an object resulting from extracting the given
30
+ * `actualKey` from the input and storing it as the `desiredKey` in the output.
31
+ */
24
32
  export declare function remapKeys($step: ExecutableStep, actualKeyByDesiredKey: {
25
33
  [desiredKey: string]: string;
26
34
  }): RemapKeysStep;
@@ -1,7 +1,13 @@
1
1
  import type { ExecutionExtra, GrafastResultsList, GrafastValuesList } from "../interfaces.js";
2
2
  import type { ExecutableStep } from "../step.js";
3
3
  import { UnbatchedExecutableStep } from "../step.js";
4
+ /**
5
+ * Returns a reversed copy of the list.
6
+ */
4
7
  export declare function reverseArray<TData = any>(list: readonly TData[]): TData[];
8
+ /**
9
+ * Reverses a list.
10
+ */
5
11
  export declare class ReverseStep<TData> extends UnbatchedExecutableStep<readonly TData[]> {
6
12
  static $$export: {
7
13
  moduleName: string;
@@ -14,5 +20,8 @@ export declare class ReverseStep<TData> extends UnbatchedExecutableStep<readonly
14
20
  unbatchedExecute(_extra: ExecutionExtra, arr: TData[]): TData[];
15
21
  deduplicate(peers: ReverseStep<TData>[]): ReverseStep<TData>[];
16
22
  }
23
+ /**
24
+ * Reverses a list.
25
+ */
17
26
  export declare function reverse<TData>(plan: ExecutableStep<readonly TData[]>): ReverseStep<TData>;
18
27
  //# sourceMappingURL=reverse.d.ts.map
@@ -1,4 +1,8 @@
1
1
  import type { AsyncExecutionResult, ExecutionArgs, ExecutionResult } from "graphql";
2
2
  import type { PromiseOrValue } from "graphql/jsutils/PromiseOrValue";
3
+ /**
4
+ * Use this instead of GraphQL.js' subscribe method and we'll automatically
5
+ * run grafastPrepare for you and handle the result.
6
+ */
3
7
  export declare function subscribe(args: ExecutionArgs, resolvedPreset?: GraphileConfig.ResolvedPreset, outputDataAsString?: boolean): PromiseOrValue<AsyncGenerator<ExecutionResult | AsyncExecutionResult, void, void> | ExecutionResult>;
4
8
  //# sourceMappingURL=subscribe.d.ts.map
package/dist/utils.d.ts CHANGED
@@ -4,12 +4,32 @@ import type { Deferred } from "./deferred.js";
4
4
  import type { OperationPlan } from "./engine/OperationPlan.js";
5
5
  import type { BaseGraphQLArguments, GrafastFieldConfig, GrafastInputFieldConfig, InputStep, OutputPlanForType } from "./interfaces.js";
6
6
  import type { ExecutableStep, ModifierStep } from "./step.js";
7
+ /**
8
+ * The parent object is used as the key in `GetValueStepId()`; for root level
9
+ * fields it's possible that the parent will be null/undefined (in all other
10
+ * cases it will be an object), so we need a value that can be the key in a
11
+ * WeakMap to represent the root.
12
+ */
7
13
  export declare const ROOT_VALUE_OBJECT: any;
8
14
  export declare function assertNullPrototype(object: Record<string, unknown>, description: string): void;
15
+ /**
16
+ * Specifically allows for the `defaultValue` to be undefined, but otherwise
17
+ * defers to {@link rawValueToValueNode}
18
+ */
9
19
  export declare function defaultValueToValueNode(type: GraphQLInputType, defaultValue: unknown): ConstValueNode | undefined;
10
20
  export declare function isPromise<T>(t: T | Promise<T>): t is Promise<T>;
21
+ /**
22
+ * Is "thenable".
23
+ */
11
24
  export declare function isPromiseLike<T>(t: T | Promise<T> | PromiseLike<T>): t is PromiseLike<T>;
25
+ /**
26
+ * Is a promise that can be externally resolved.
27
+ */
12
28
  export declare function isDeferred<T>(t: T | Promise<T> | Deferred<T>): t is Deferred<T>;
29
+ /**
30
+ * Returns true if array1 and array2 have the same length, and every pair of
31
+ * values within them pass the `comparator` check (which defaults to `===`).
32
+ */
13
33
  export declare function arraysMatch<T>(array1: ReadonlyArray<T>, array2: ReadonlyArray<T>, comparator?: (val1: T, val2: T) => boolean): boolean;
14
34
  export type ObjectTypeFields<TContext extends Grafast.Context, TParentStep extends ExecutableStep> = {
15
35
  [key: string]: GrafastFieldConfig<GraphQLOutputType, TContext, TParentStep, any, any>;
@@ -20,15 +40,29 @@ export type ObjectTypeSpec<TContext extends Grafast.Context, TParentStep extends
20
40
  new (...args: any[]): TParentStep;
21
41
  } : null;
22
42
  };
43
+ /**
44
+ * Saves us having to write `extensions: {grafast: {...}}` everywhere.
45
+ */
23
46
  export declare function objectSpec<TContext extends Grafast.Context, TParentStep extends ExecutableStep, TFields extends ObjectTypeFields<TContext, TParentStep>>(spec: ObjectTypeSpec<TContext, TParentStep, TFields>): GraphQLObjectTypeConfig<any, TContext>;
24
47
  export type GrafastObjectType<TContext extends Grafast.Context, TParentStep extends ExecutableStep, TFields extends ObjectTypeFields<TContext, TParentStep>> = graphql.GraphQLObjectType<TParentStep extends ExecutableStep<infer U> ? U : never, TContext> & {
25
48
  TParentStep: TParentStep;
26
49
  TFields: TFields;
27
50
  };
51
+ /**
52
+ * @remarks This is a mess because the first two generics need to be specified manually, but the latter one we want inferred.
53
+ */
28
54
  export declare function newObjectTypeBuilder<TContext extends Grafast.Context, TParentStep extends ExecutableStep>(assertStep: TParentStep extends ExecutableStep ? ((step: ExecutableStep) => asserts step is TParentStep) | {
29
55
  new (...args: any[]): TParentStep;
30
56
  } : never): <TFields extends ObjectTypeFields<TContext, TParentStep>>(spec: ObjectTypeSpec<TContext, TParentStep, TFields>) => GrafastObjectType<TContext, TParentStep, TFields>;
57
+ /**
58
+ * Saves us having to write `extensions: {grafast: {...}}` everywhere.
59
+ */
31
60
  export declare function objectFieldSpec<TContext extends Grafast.Context, TSource extends ExecutableStep, TResult extends ExecutableStep = ExecutableStep, TArgs extends BaseGraphQLArguments = BaseGraphQLArguments>(grafastSpec: GrafastFieldConfig<GraphQLOutputType, TContext, TSource, TResult, TArgs>, path: string): GraphQLFieldConfig<any, TContext, TArgs>;
61
+ /**
62
+ * "Constrainted identity function" for field configs.
63
+ *
64
+ * @see {@link https://kentcdodds.com/blog/how-to-write-a-constrained-identity-function-in-typescript}
65
+ */
32
66
  export declare function newGrafastFieldConfigBuilder<TContext extends Grafast.Context, TParentStep extends ExecutableStep>(): <TType extends GraphQLOutputType, TFieldStep extends OutputPlanForType<TType>, TArgs extends BaseGraphQLArguments>(config: GrafastFieldConfig<TType, TContext, TParentStep, TFieldStep, TArgs>) => typeof config;
33
67
  export type GrafastInputFieldConfigMap<TContext extends Grafast.Context, TParentStep extends ModifierStep<any>> = {
34
68
  [key: string]: GrafastInputFieldConfig<GraphQLInputType, TContext, TParentStep, any, any>;
@@ -42,6 +76,9 @@ export type GrafastInputObjectType<TContext extends Grafast.Context, TParentStep
42
76
  TFields: TFields;
43
77
  };
44
78
  export declare function newInputObjectTypeBuilder<TContext extends Grafast.Context, TParentStep extends ModifierStep<any>>(): <TFields extends GrafastInputFieldConfigMap<TContext, TParentStep>>(spec: InputObjectTypeSpec<TContext, TParentStep, TFields>) => GrafastInputObjectType<TContext, TParentStep, TFields>;
79
+ /**
80
+ * Saves us having to write `extensions: {grafast: {...}}` everywhere.
81
+ */
45
82
  export declare function inputObjectFieldSpec<TContext extends Grafast.Context, TParent extends ModifierStep<any>, TResult extends ModifierStep<TParent> = ModifierStep<TParent>, TInput extends InputStep = InputStep>(grafastSpec: GrafastInputFieldConfig<GraphQLInputType, TContext, TParent, TResult, TInput>, path: string): GraphQLInputFieldConfig;
46
83
  declare module "graphql" {
47
84
  interface GraphQLEnumType {
@@ -49,15 +86,80 @@ declare module "graphql" {
49
86
  }
50
87
  }
51
88
  declare const $$valueConfigByValue: unique symbol;
89
+ /**
90
+ * This would be equivalent to `enumType._valueLookup.get(outputValue)` except
91
+ * that's not a public API so we have to do a bit of heavy lifting here. Since
92
+ * it is heavy lifting, we cache the result, but we don't know when enumType
93
+ * will go away so we use a weakmap.
94
+ */
52
95
  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
+ */
53
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
+ */
54
110
  export declare function stack(message: string, length?: number): void;
111
+ /**
112
+ * Ridiculously, this is faster than `new Array(length).fill(fill)`
113
+ *
114
+ * @internal
115
+ */
55
116
  export declare function arrayOfLength(length: number, fill?: any): any[];
117
+ /**
118
+ * Builds an array of length `length` calling `fill` for each entry in the
119
+ * list and storing the result.
120
+ *
121
+ * @internal
122
+ */
56
123
  export declare function arrayOfLengthCb(length: number, fill: () => any): any[];
124
+ /**
125
+ * Given a FieldNode, recursively walks and finds all the variable references,
126
+ * returning a list of the (unique) variable names used.
127
+ */
57
128
  export declare function findVariableNamesUsed(operationPlan: OperationPlan, field: FieldNode): string[];
58
129
  export declare function isTypePlanned(schema: GraphQLSchema, namedType: GraphQLNamedType): boolean;
59
130
  export declare function stepADependsOnStepB(stepA: ExecutableStep, stepB: ExecutableStep): boolean;
131
+ /**
132
+ * Returns true if stepA is allowed to depend on stepB, false otherwise. (This
133
+ * mostly relates to heirarchy.)
134
+ */
60
135
  export declare function stepAMayDependOnStepB($a: ExecutableStep, $b: ExecutableStep): boolean;
136
+ /**
137
+ * For a regular GraphQL query with no `@stream`/`@defer`, the entire result is
138
+ * calculated and then the output is generated and sent to the client at once.
139
+ * Thus you can think of this as every plan is in the same "phase".
140
+ *
141
+ * However, if you introduce a `@stream`/`@defer` selection, then the steps
142
+ * inside that selection should run _later_ than the steps in the parent
143
+ * selection - they should run in two different phases. Similar is true for
144
+ * subscriptions.
145
+ *
146
+ * When optimizing your plans, if you are not careful you may end up pushing
147
+ * what should be later work into the earlier phase, resulting in the initial
148
+ * payload being delayed whilst things that should have been deferred are being
149
+ * calculated. Thus, you should generally check that two plans are in the same phase
150
+ * before you try and merge them.
151
+ *
152
+ * This is not a strict rule, though, because sometimes it makes more sense to
153
+ * push work into the parent phase because it would be faster overall to do
154
+ * that work there, and would not significantly delay the initial payload's
155
+ * execution time - for example it's unlikely that it would make sense to defer
156
+ * selecting an additional boolean column from a database table even if the
157
+ * operation indicates that's what you should do.
158
+ *
159
+ * As a step class author, it's your responsiblity to figure out the right
160
+ * approach. Once you have, you can use this function to help you, should you
161
+ * need it.
162
+ */
61
163
  export declare function stepsAreInSamePhase(ancestor: ExecutableStep, descendent: ExecutableStep): boolean;
62
164
  export declare const canonicalJSONStringify: (o: object) => string;
63
165
  export declare function assertNotAsync(fn: any, name: string): void;
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const version = "0.0.1-alpha.13";
1
+ export declare const version = "0.0.1-alpha.15";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ export * from "graphql";
@@ -0,0 +1 @@
1
+ module.exports = require("graphql");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grafast",
3
- "version": "0.0.1-alpha.13",
3
+ "version": "0.0.1-alpha.15",
4
4
  "description": "Cutting edge GraphQL planning and execution engine",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -57,7 +57,7 @@
57
57
  },
58
58
  "peerDependencies": {
59
59
  "@envelop/core": "^3.0.4",
60
- "graphile-config": "^0.0.1-alpha.6",
60
+ "graphile-config": "^0.0.1-alpha.7",
61
61
  "graphql": "^16.1.0-experimental-stream-defer.6",
62
62
  "tamedevil": "^0.0.0-alpha.4"
63
63
  },