grafast 0.0.1-alpha.9 → 0.0.1-beta.2

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 (69) hide show
  1. package/LICENSE.md +15 -17
  2. package/README.md +138 -1
  3. package/dist/LICENSES.txt +1 -1
  4. package/dist/args.d.ts +7 -1
  5. package/dist/assert.d.ts +2 -0
  6. package/dist/bucket.d.ts +66 -1
  7. package/dist/constraints.d.ts +31 -0
  8. package/dist/deferred.d.ts +7 -0
  9. package/dist/dev.d.ts +3 -0
  10. package/dist/engine/LayerPlan.d.ts +131 -0
  11. package/dist/engine/OperationPlan.d.ts +151 -0
  12. package/dist/engine/OutputPlan.d.ts +105 -1
  13. package/dist/engine/StepTracker.d.ts +56 -1
  14. package/dist/engine/executeBucket.d.ts +4 -1
  15. package/dist/engine/executeOutputPlan.d.ts +42 -1
  16. package/dist/envelop.d.ts +12 -0
  17. package/dist/envelop.js +2 -51
  18. package/dist/error.d.ts +23 -0
  19. package/dist/establishOperationPlan.d.ts +10 -31
  20. package/dist/execute.d.ts +8 -0
  21. package/dist/exportAs.d.ts +14 -0
  22. package/dist/grafastGraphql.d.ts +8 -3
  23. package/dist/grafastPrint.d.ts +8 -0
  24. package/dist/graphqlCollectFields.d.ts +22 -0
  25. package/dist/graphqlMergeSelectionSets.d.ts +4 -0
  26. package/dist/index.d.ts +9 -4
  27. package/dist/index.js +387 -53
  28. package/dist/input.d.ts +8 -1
  29. package/dist/interfaces.d.ts +356 -59
  30. package/dist/makeGrafastSchema.d.ts +30 -3
  31. package/dist/mermaid.d.ts +28 -0
  32. package/dist/polymorphic.d.ts +8 -0
  33. package/dist/prepare.d.ts +16 -2
  34. package/dist/step.d.ts +183 -0
  35. package/dist/steps/__inputDynamicScalar.d.ts +3 -0
  36. package/dist/steps/__inputList.d.ts +3 -0
  37. package/dist/steps/__inputObject.d.ts +3 -0
  38. package/dist/steps/__inputStaticLeaf.d.ts +5 -0
  39. package/dist/steps/__item.d.ts +8 -0
  40. package/dist/steps/__trackedValue.d.ts +74 -0
  41. package/dist/steps/__value.d.ts +5 -0
  42. package/dist/steps/access.d.ts +20 -0
  43. package/dist/steps/{deepEval.d.ts → applyTransforms.d.ts} +16 -3
  44. package/dist/steps/connection.d.ts +49 -0
  45. package/dist/steps/constant.d.ts +11 -3
  46. package/dist/steps/each.d.ts +3 -0
  47. package/dist/steps/filter.d.ts +4 -0
  48. package/dist/steps/first.d.ts +4 -0
  49. package/dist/steps/graphqlResolver.d.ts +18 -0
  50. package/dist/steps/groupBy.d.ts +6 -0
  51. package/dist/steps/index.d.ts +6 -2
  52. package/dist/steps/lambda.d.ts +8 -0
  53. package/dist/steps/last.d.ts +4 -0
  54. package/dist/steps/list.d.ts +7 -0
  55. package/dist/steps/listTransform.d.ts +21 -0
  56. package/dist/steps/listen.d.ts +16 -0
  57. package/dist/steps/load.d.ts +13 -0
  58. package/dist/steps/node.d.ts +20 -12
  59. package/dist/steps/object.d.ts +15 -0
  60. package/dist/steps/partitionByIndex.d.ts +35 -0
  61. package/dist/steps/proxy.d.ts +11 -0
  62. package/dist/steps/remapKeys.d.ts +8 -0
  63. package/dist/steps/reverse.d.ts +9 -0
  64. package/dist/subscribe.d.ts +4 -0
  65. package/dist/utils.d.ts +113 -5
  66. package/dist/version.d.ts +2 -0
  67. package/fwd/graphql/index.d.ts +1 -0
  68. package/fwd/graphql/index.js +1 -0
  69. package/package.json +14 -6
@@ -4,16 +4,29 @@ import type { GrafastError } from "../error.js";
4
4
  import type { ExecutionExtra, GrafastResultsList, GrafastValuesList } from "../interfaces.js";
5
5
  import type { ListCapableStep } from "../step.js";
6
6
  import { ExecutableStep } from "../step.js";
7
- export declare class DeepEvalStep extends ExecutableStep {
7
+ /**
8
+ * @internal
9
+ */
10
+ export declare class ApplyTransformsStep extends ExecutableStep {
8
11
  static $$export: {
9
12
  moduleName: string;
10
13
  exportName: string;
11
14
  };
12
15
  isSyncAndSafe: boolean;
16
+ /** Set during query planning. */
13
17
  itemStepId: number;
18
+ /**
19
+ * @internal
20
+ */
14
21
  subroutineLayer: LayerPlan<LayerPlanReasonSubroutine>;
15
22
  constructor(listPlan: ListCapableStep<any, any>);
16
23
  execute(_count: number, values: [GrafastValuesList<any[] | null | undefined | GrafastError>], extra: ExecutionExtra): Promise<GrafastResultsList<any[]>>;
17
24
  }
18
- export declare function deepEval($step: ExecutableStep): ExecutableStep<any>;
19
- //# sourceMappingURL=deepEval.d.ts.map
25
+ /**
26
+ * If you want to use a step that might represent a list and you need all of
27
+ * the `listItem` transforms to have already taken place (e.g. you're going to
28
+ * send the result to an external service) rather than processing them through
29
+ * the GraphQL response, then you may need to call `applyTransforms` on it.
30
+ */
31
+ export declare function applyTransforms($step: ExecutableStep): ExecutableStep<any>;
32
+ //# sourceMappingURL=applyTransforms.d.ts.map
@@ -2,13 +2,27 @@ import type { ExecutionExtra, GrafastResultsList, InputStep } from "../interface
2
2
  import type { ExecutableStep } from "../step.js";
3
3
  import { UnbatchedExecutableStep } from "../step.js";
4
4
  type ParametersExceptFirst<F> = F extends (arg0: any, ...rest: infer R) => any ? R : never[];
5
+ /**
6
+ * Describes what a plan needs to implement in order to be suitable for
7
+ * supplying what the `PageInfo` type requires.
8
+ */
5
9
  export interface PageInfoCapableStep extends ExecutableStep {
6
10
  hasNextPage(): ExecutableStep<boolean>;
7
11
  hasPreviousPage(): ExecutableStep<boolean>;
8
12
  startCursor(): ExecutableStep<string | null>;
9
13
  endCursor(): ExecutableStep<string | null>;
10
14
  }
15
+ export declare function assertPageInfoCapableStep($step: ExecutableStep | PageInfoCapableStep): asserts $step is PageInfoCapableStep;
16
+ /**
17
+ * Describes what a plan needs to implement in order to be suitable for
18
+ * supplying what a ConnectionStep requires.
19
+ */
11
20
  export interface ConnectionCapableStep<TItemStep extends ExecutableStep, TCursorStep extends ExecutableStep> extends ExecutableStep<ReadonlyArray<TItemStep extends ExecutableStep<infer U> ? U : any>> {
21
+ /**
22
+ * Clone the plan; it's recommended that you add `$connection` as a
23
+ * dependency so that you can abort execution early in the case of errors
24
+ * (e.g. if the cursors cannot be parsed).
25
+ */
12
26
  connectionClone($connection: ConnectionStep<TItemStep, TCursorStep, any, any>, ...args: any[]): ConnectionCapableStep<TItemStep, TCursorStep>;
13
27
  pageInfo($connection: ConnectionStep<TItemStep, TCursorStep, ConnectionCapableStep<TItemStep, TCursorStep>, any>): PageInfoCapableStep;
14
28
  setFirst($plan: InputStep): void;
@@ -18,6 +32,10 @@ export interface ConnectionCapableStep<TItemStep extends ExecutableStep, TCursor
18
32
  setBefore($plan: TCursorStep): void;
19
33
  setAfter($plan: TCursorStep): void;
20
34
  }
35
+ /**
36
+ * Handles GraphQL cursor pagination in a standard and consistent way
37
+ * indepdenent of data source.
38
+ */
21
39
  export declare class ConnectionStep<TItemStep extends ExecutableStep, TCursorStep extends ExecutableStep, TStep extends ConnectionCapableStep<TItemStep, TCursorStep>, TNodeStep extends ExecutableStep = ExecutableStep> extends UnbatchedExecutableStep<unknown> {
22
40
  readonly itemPlan?: (($item: TItemStep) => TNodeStep) | undefined;
23
41
  readonly cursorPlan?: (($item: TItemStep) => ExecutableStep<string | null> | undefined) | undefined;
@@ -44,9 +62,35 @@ export declare class ConnectionStep<TItemStep extends ExecutableStep, TCursorSte
44
62
  setBefore($beforePlan: InputStep): void;
45
63
  getAfter(): TCursorStep | null;
46
64
  setAfter($afterPlan: InputStep): void;
65
+ /**
66
+ * This should not be called after the arguments have been finalized.
67
+ */
47
68
  getSubplan(): TStep;
69
+ /**
70
+ * This represents the entire collection with conditions and ordering
71
+ * applied, but without any pagination constraints (before, after, first,
72
+ * last, offset) applied. It's useful for the following:
73
+ *
74
+ * - performing aggregates e.g. totalCount across the entire collection
75
+ * - determining fields for pageInfo, e.g. is there a next/previous page
76
+ *
77
+ * This cannot be called before the arguments have been finalized.
78
+ */
48
79
  cloneSubplanWithoutPagination(...args: ParametersExceptFirst<TStep["connectionClone"]>): TStep;
80
+ /**
81
+ * This represents a single page from the collection - not only have
82
+ * conditions and ordering been applied but we've also applied the pagination
83
+ * constraints (before, after, first, last, offset). It's useful for
84
+ * returning the actual edges and nodes of the connection.
85
+ *
86
+ * This cannot be called before the arguments have been finalized.
87
+ */
49
88
  cloneSubplanWithPagination(...args: ParametersExceptFirst<TStep["connectionClone"]> | []): TStep;
89
+ /**
90
+ * Subplans may call this from their `setBefore`/`setAfter`/etc plans in order
91
+ * to add a dependency to us, which is typically useful for adding validation
92
+ * functions so that they are thrown "earlier", avoiding error bubbling.
93
+ */
50
94
  addValidation(callback: () => ExecutableStep): void;
51
95
  edges(): ExecutableStep;
52
96
  nodes(): TStep | import("./listTransform.js").__ListTransformStep<any, any, any, any>;
@@ -59,6 +103,7 @@ export interface EdgeCapableStep<TNodeStep extends ExecutableStep> extends Execu
59
103
  node(): TNodeStep;
60
104
  cursor(): ExecutableStep<string | null>;
61
105
  }
106
+ export declare function assertEdgeCapableStep<TNodeStep extends ExecutableStep>($step: ExecutableStep | EdgeCapableStep<TNodeStep>): asserts $step is EdgeCapableStep<TNodeStep>;
62
107
  export declare class EdgeStep<TItemStep extends ExecutableStep, TCursorStep extends ExecutableStep, TStep extends ConnectionCapableStep<TItemStep, TCursorStep>, TNodeStep extends ExecutableStep = ExecutableStep> extends UnbatchedExecutableStep implements EdgeCapableStep<TNodeStep> {
63
108
  private skipCursor;
64
109
  static $$export: {
@@ -79,6 +124,10 @@ export declare class EdgeStep<TItemStep extends ExecutableStep, TCursorStep exte
79
124
  deduplicatedWith(replacement: EdgeStep<any, any, any, any>): void;
80
125
  unbatchedExecute(_extra: ExecutionExtra, record: any, cursor: any): any;
81
126
  }
127
+ /**
128
+ * Wraps a collection fetch to provide the utilities for working with GraphQL
129
+ * cursor connections.
130
+ */
82
131
  export declare function connection<TItemStep extends ExecutableStep, TCursorStep extends ExecutableStep, TStep extends ConnectionCapableStep<TItemStep, TCursorStep>, TNodeStep extends ExecutableStep = ExecutableStep>(step: TStep, itemPlan?: ($item: TItemStep) => TNodeStep, cursorPlan?: ($item: TItemStep) => ExecutableStep<string | null>): ConnectionStep<TItemStep, TCursorStep, TStep, TNodeStep>;
83
132
  export {};
84
133
  //# sourceMappingURL=connection.d.ts.map
@@ -1,13 +1,17 @@
1
1
  import type { GrafastResultsList } from "../interfaces.js";
2
2
  import { UnbatchedExecutableStep } from "../step.js";
3
+ /**
4
+ * Converts a constant value (e.g. a string/number/etc) into a plan
5
+ */
3
6
  export declare class ConstantStep<TData> extends UnbatchedExecutableStep<TData> {
4
7
  readonly data: TData;
8
+ readonly isSensitive: boolean;
5
9
  static $$export: {
6
10
  moduleName: string;
7
11
  exportName: string;
8
12
  };
9
13
  isSyncAndSafe: boolean;
10
- constructor(data: TData);
14
+ constructor(data: TData, isSensitive?: boolean);
11
15
  toStringMeta(): string;
12
16
  deduplicate(peers: readonly ConstantStep<any>[]): ConstantStep<any>[];
13
17
  execute(count: number): GrafastResultsList<TData>;
@@ -18,6 +22,10 @@ export declare class ConstantStep<TData> extends UnbatchedExecutableStep<TData>
18
22
  isNull(): boolean;
19
23
  isUndefined(): boolean;
20
24
  }
21
- export declare function constant(strings: TemplateStringsArray & [string]): ConstantStep<string>;
22
- export declare function constant<TData>(data: TData): ConstantStep<TData>;
25
+ /**
26
+ * Call this as a template string or as a function. Only intended for handling
27
+ * scalar values, not arrays/objects/etc.
28
+ */
29
+ export declare function constant<const TString extends string>(strings: TemplateStringsArray & [TString]): ConstantStep<TString>;
30
+ export declare function constant<TData>(data: TData, isSecret?: boolean): ConstantStep<TData>;
23
31
  //# sourceMappingURL=constant.d.ts.map
@@ -2,5 +2,8 @@ import type { ExecutableStep, ListCapableStep } from "../step.js";
2
2
  import { __ItemStep } from "./__item.js";
3
3
  import type { ConnectionCapableStep } from "./connection.js";
4
4
  import type { __ListTransformStep } from "./listTransform.js";
5
+ /**
6
+ * Transforms a list by wrapping each element in the list with the given mapper.
7
+ */
5
8
  export declare function each<TListStep extends ExecutableStep<readonly any[]> & Partial<ConnectionCapableStep<any, any>>, TResultItemStep extends ExecutableStep>(listStep: TListStep, mapper: (itemPlan: TListStep extends ListCapableStep<any, any> ? ReturnType<TListStep["listItem"]> : __ItemStep<any>) => TResultItemStep): __ListTransformStep<any, any, any, any>;
6
9
  //# sourceMappingURL=each.d.ts.map
@@ -2,5 +2,9 @@ import type { ExecutableStep, ListCapableStep } from "../step.js";
2
2
  import type { __ItemStep } from "./__item.js";
3
3
  import type { __ListTransformStep, ListTransformItemPlanCallback } from "./listTransform.js";
4
4
  export type FilterPlanMemo = unknown[];
5
+ /**
6
+ * Filters a list plan to only include entries for which the `filterCallback`
7
+ * plan results in a truthy value.
8
+ */
5
9
  export declare function filter<TListStep extends ExecutableStep<readonly any[]>, TItemStep extends ExecutableStep<boolean>>(listStep: TListStep, filterCallback: ListTransformItemPlanCallback<TListStep, TItemStep>): __ListTransformStep<TListStep, TItemStep, FilterPlanMemo, TListStep extends ListCapableStep<any, any> ? ReturnType<TListStep["listItem"]> : __ItemStep<any>>;
6
10
  //# sourceMappingURL=filter.d.ts.map
@@ -14,5 +14,9 @@ export declare class FirstStep<TData> extends UnbatchedExecutableStep<TData> {
14
14
  deduplicate(peers: FirstStep<TData>[]): FirstStep<TData>[];
15
15
  optimize(): ExecutableStep<any> | this;
16
16
  }
17
+ /**
18
+ * A plan that resolves to the first entry in the list returned by the given
19
+ * plan.
20
+ */
17
21
  export declare function first<TData>(plan: ExecutableStep<ReadonlyArray<TData>>): FirstStep<TData>;
18
22
  //# sourceMappingURL=first.d.ts.map
@@ -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,9 +2,13 @@ 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
- export { connection, ConnectionCapableStep, ConnectionStep, EdgeCapableStep, EdgeStep, PageInfoCapableStep, } from "./connection.js";
11
+ export { assertEdgeCapableStep, assertPageInfoCapableStep, connection, ConnectionCapableStep, ConnectionStep, EdgeCapableStep, EdgeStep, PageInfoCapableStep, } from "./connection.js";
8
12
  export { constant, ConstantStep } from "./constant.js";
9
13
  export { each } from "./each.js";
10
14
  export { error, ErrorStep } from "./error.js";
@@ -28,7 +32,7 @@ export { __InputStaticLeafStep } from "./__inputStaticLeaf.js";
28
32
  export { __ItemStep } from "./__item.js";
29
33
  export { __TrackedValueStep, __TrackedValueStepWithDollars, } from "./__trackedValue.js";
30
34
  export { __ValueStep } from "./__value.js";
31
- export { deepEval, DeepEvalStep } from "./deepEval.js";
35
+ export { applyTransforms, ApplyTransformsStep } from "./applyTransforms.js";
32
36
  export { GraphQLItemHandler, graphqlItemHandler, graphqlResolver, GraphQLResolverStep, } from "./graphqlResolver.js";
33
37
  export { LoadedRecordStep, loadMany, LoadManyCallback, loadManyCallback, loadOne, LoadOneCallback, loadOneCallback, LoadOptions, LoadStep, } from "./load.js";
34
38
  export { proxy, ProxyStep } from "./proxy.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;
@@ -1,10 +1,14 @@
1
1
  import type { GraphQLObjectType } from "graphql";
2
- import type { ExecutionExtra, NodeIdCodec, NodeIdHandler, PolymorphicData } from "../interfaces.js";
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
- export declare class NodeStep<TCodecs extends {
6
- [key: string]: NodeIdCodec<any>;
7
- }> extends UnbatchedExecutableStep implements PolymorphicStep {
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
+ */
11
+ export declare class NodeStep extends UnbatchedExecutableStep implements PolymorphicStep {
8
12
  private possibleTypes;
9
13
  static $$export: {
10
14
  moduleName: string;
@@ -13,17 +17,21 @@ export declare class NodeStep<TCodecs extends {
13
17
  isSyncAndSafe: boolean;
14
18
  allowMultipleOptimizations: boolean;
15
19
  private specPlanDep;
16
- constructor(codecs: TCodecs, possibleTypes: {
17
- [typeName: string]: NodeIdHandler<TCodecs>;
20
+ constructor(possibleTypes: {
21
+ [typeName: string]: NodeIdHandler;
18
22
  }, $id: ExecutableStep<string>);
19
23
  planForType(type: GraphQLObjectType): ExecutableStep;
20
24
  private getTypeNameFromSpecifier;
21
25
  unbatchedExecute: (_extra: ExecutionExtra, specifier: any) => PolymorphicData<string, ReadonlyArray<any>> | null;
22
26
  }
23
- export declare function node<TCodecs extends {
24
- [key: string]: NodeIdCodec<any>;
25
- }>(codecs: TCodecs, possibleTypes: {
26
- [typeName: string]: NodeIdHandler<TCodecs>;
27
- }, $id: ExecutableStep<string>): NodeStep<TCodecs>;
28
- export declare function specFromNodeId(codec: NodeIdCodec<any>, handler: NodeIdHandler<any>, $id: ExecutableStep<string>): any;
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
+ */
33
+ export declare function node(possibleTypes: {
34
+ [typeName: string]: NodeIdHandler;
35
+ }, $id: ExecutableStep<string>): NodeStep;
36
+ export declare function specFromNodeId(handler: NodeIdHandler<any>, $id: ExecutableStep<string>): any;
29
37
  //# sourceMappingURL=node.d.ts.map
@@ -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