@astrale-os/sdk 0.6.0-beta.43 → 0.6.0-beta.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/application/action/authoring.d.ts +1 -1
- package/dist/application/action/context.d.ts +9 -8
- package/dist/application/error/error.d.ts +7 -7
- package/dist/application/error/error.js +12 -12
- package/dist/application/error/index.d.ts +1 -1
- package/dist/application/error/index.js +1 -1
- package/dist/application/mutation/authoring/builder.d.ts +12 -12
- package/dist/application/mutation/authoring/builder.js +3 -3
- package/dist/application/mutation/authoring/guard.d.ts +2 -2
- package/dist/application/mutation/authoring/index.d.ts +1 -1
- package/dist/application/mutation/define.d.ts +8 -8
- package/dist/application/mutation/define.js +12 -12
- package/dist/application/mutation/execution/execute.d.ts +2 -2
- package/dist/application/mutation/execution/execute.js +10 -10
- package/dist/application/mutation/execution/executor.d.ts +2 -2
- package/dist/application/mutation/execution/executor.js +2 -2
- package/dist/application/mutation/index.d.ts +2 -2
- package/dist/application/mutation/legacy/v6/define.d.ts +1 -1
- package/dist/application/mutation/legacy/v6/mutation.d.ts +1 -1
- package/dist/application/mutation/mutation.d.ts +12 -12
- package/dist/application/query/composite/builder.js +1 -1
- package/dist/application/query/define.d.ts +1 -1
- package/dist/application/query/define.js +3 -3
- package/dist/application/query/defined/define.d.ts +45 -0
- package/dist/application/query/defined/define.js +96 -0
- package/dist/application/query/{recipe/recipe.d.ts → defined/query.d.ts} +21 -20
- package/dist/application/query/definition.d.ts +5 -5
- package/dist/application/query/definition.js +4 -4
- package/dist/application/query/execution/bounds.d.ts +5 -5
- package/dist/application/query/execution/bounds.js +2 -2
- package/dist/application/query/execution/client.d.ts +20 -0
- package/dist/application/query/execution/client.js +1 -0
- package/dist/application/query/execution/crossings.d.ts +3 -3
- package/dist/application/query/execution/crossings.js +23 -23
- package/dist/application/query/execution/error.d.ts +8 -8
- package/dist/application/query/execution/error.js +5 -5
- package/dist/application/query/execution/execute.d.ts +4 -4
- package/dist/application/query/execution/executor.d.ts +2 -2
- package/dist/application/query/execution/rows.d.ts +5 -5
- package/dist/application/query/execution/rows.js +42 -30
- package/dist/application/query/execution/{recipe.d.ts → run.d.ts} +21 -31
- package/dist/application/query/execution/{recipe.js → run.js} +49 -49
- package/dist/application/query/execution/split.d.ts +3 -3
- package/dist/application/query/execution/split.js +1 -1
- package/dist/application/query/handles/build.d.ts +1 -1
- package/dist/application/query/handles/domain.d.ts +1 -1
- package/dist/application/query/handles/handles.d.ts +14 -12
- package/dist/application/query/handles/plan.d.ts +10 -9
- package/dist/application/query/handles/plan.js +1 -1
- package/dist/application/query/handles/reads.js +4 -4
- package/dist/application/query/handles/rows.d.ts +1 -1
- package/dist/application/query/index.d.ts +8 -5
- package/dist/application/query/index.js +3 -3
- package/dist/application/query/language/index.d.ts +1 -1
- package/dist/application/query/language/query.d.ts +5 -5
- package/dist/application/query/legacy/v6/collection/union.d.ts +1 -1
- package/dist/application/query/legacy/v6/collection/union.js +3 -3
- package/dist/application/query/legacy/v6/define.d.ts +1 -1
- package/dist/application/query/legacy/v6/define.js +3 -3
- package/dist/application/query/legacy/v6/execution/execute.d.ts +6 -4
- package/dist/application/query/legacy/v6/index.d.ts +1 -1
- package/dist/application/query/legacy/v6/index.js +1 -1
- package/dist/application/query/query.d.ts +3 -3
- package/dist/application/routes/admission.d.ts +1 -1
- package/dist/application/routes/admission.js +2 -2
- package/dist/application/routes/index.d.ts +3 -2
- package/dist/application/routes/route.d.ts +1 -1
- package/dist/application/runtime/declarations.d.ts +6 -6
- package/dist/application/runtime/define.d.ts +5 -5
- package/dist/application/workflow/durable.d.ts +9 -9
- package/dist/execution/invocation/capabilities/bind.d.ts +1 -1
- package/dist/execution/invocation/capabilities/bind.js +8 -8
- package/dist/execution/invocation/dispatch/action.js +2 -2
- package/dist/execution/invocation/dispatch/workflow.js +2 -2
- package/dist/execution/invocation/result/index.d.ts +1 -1
- package/dist/execution/invocation/result/index.js +1 -1
- package/dist/execution/invocation/result/undeclared.d.ts +7 -0
- package/dist/execution/invocation/result/undeclared.js +18 -0
- package/dist/execution/workflows/failure.d.ts +7 -7
- package/dist/execution/workflows/failure.js +19 -18
- package/dist/execution/workflows/receiver.d.ts +1 -1
- package/dist/execution/workflows/run.js +2 -2
- package/dist/execution/workflows/steps.d.ts +1 -1
- package/dist/platform/schema/class-authoring.d.ts +2 -8
- package/dist/platform/schema/index.d.ts +1 -1
- package/dist/platform/schema/kernel-compiled.d.ts +1 -1
- package/dist/platform/schema/kernel-compiled.js +1 -1
- package/dist/platform/schema/kernel.d.ts +4 -2
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +1 -1
- package/dist/testing/{recipe.d.ts → query.d.ts} +5 -5
- package/dist/testing/{recipe.js → query.js} +9 -9
- package/dist/tooling/cli/orchestrate.js +7 -6
- package/dist/tooling/linter/adapters/typescript/{recipe-definitions.d.ts → definition-calls.d.ts} +10 -10
- package/dist/tooling/linter/adapters/typescript/{recipe-definitions.js → definition-calls.js} +10 -10
- package/dist/tooling/linter/adapters/typescript/index.d.ts +1 -1
- package/dist/tooling/linter/adapters/typescript/index.js +1 -1
- package/dist/tooling/linter/adapters/typescript/query-observation.js +6 -6
- package/dist/tooling/linter/implementations/source/definitions.d.ts +2 -0
- package/dist/tooling/linter/implementations/source/{recipes.js → definitions.js} +27 -27
- package/dist/tooling/linter/implementations/source/global.js +8 -6
- package/dist/tooling/linter/implementations/source/mutations.js +5 -5
- package/dist/tooling/linter/implementations/source/shared.d.ts +2 -2
- package/dist/tooling/linter/implementations/source/shared.js +7 -7
- package/dist/tooling/linter/implementations/source/verifiers.js +2 -2
- package/dist/tooling/linter/policy/generated.js +3 -3
- package/dist/tooling/linter/requirements/registry.js +4 -4
- package/docs/durable-workflows.md +8 -8
- package/docs/handler-dependencies.md +1 -1
- package/docs/legacy/query-v6.md +6 -6
- package/docs/queries.md +38 -38
- package/package.json +6 -6
- package/dist/application/query/recipe/define.d.ts +0 -44
- package/dist/application/query/recipe/define.js +0 -95
- package/dist/execution/invocation/result/recipe.d.ts +0 -6
- package/dist/execution/invocation/result/recipe.js +0 -17
- package/dist/tooling/linter/implementations/source/recipes.d.ts +0 -2
- /package/dist/application/query/{recipe/recipe.js → defined/query.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Typed handles over a Domain (spec §
|
|
2
|
+
* Typed handles over a Domain (spec § Queries: the read layer): what a Query's `build` receives,
|
|
3
3
|
* and the reads it returns. Handles are interfaces with lazy members; the per-Class parts
|
|
4
4
|
* (Properties, named relations, rows) are mapped types computed once per Class key (D5).
|
|
5
5
|
*/
|
|
@@ -11,7 +11,7 @@ import type { Cond, Conditions, HandleMembers, IsCond, Ordering, PropOf, PropsOf
|
|
|
11
11
|
import type { Cls, Dom, KeyOf, LayoutOf, OriginOf, PropNamesOf, Satisfies, Single, Untyped, ValueOfEntry } from './domain.js';
|
|
12
12
|
import type { Far, RelationsOf, SourceKeys, SourceRole, TargetKeys, TargetRole, ViaCheck, ViaOptions } from './relations.js';
|
|
13
13
|
import type { Count, EdgeRootRef, EdgeRootRow, EdgeValues, Page, Ref, Row, RowKeys, WithheldEdgeRow, WithheldRow } from './rows.js';
|
|
14
|
-
/** A read: what a verb returns, an opaque description the
|
|
14
|
+
/** A read: what a verb returns, an opaque description the Query runs, typed by its answer `T`. */
|
|
15
15
|
export interface Read<out T> {
|
|
16
16
|
readonly '~read': T;
|
|
17
17
|
}
|
|
@@ -19,7 +19,7 @@ export interface Read<out T> {
|
|
|
19
19
|
export interface RelationRead<out T> extends Read<T> {
|
|
20
20
|
readonly '~relation': true;
|
|
21
21
|
}
|
|
22
|
-
/** One page of a root: only as a
|
|
22
|
+
/** One page of a root: only as a Query's single read (D22). */
|
|
23
23
|
export interface PageRead<out T> {
|
|
24
24
|
readonly '~page': T;
|
|
25
25
|
}
|
|
@@ -39,21 +39,23 @@ type Answers<X> = {
|
|
|
39
39
|
* at that name.
|
|
40
40
|
*/
|
|
41
41
|
type WithCheck<S, K, W, X> = {
|
|
42
|
-
readonly [P in keyof X as P extends PropNamesOf<Cls<S, K>> | RowKeys | keyof W | `$${string}` ? P : X[P] extends RelationRead<unknown> ? never : P]: P extends PropNamesOf<Cls<S, K>> | RowKeys | keyof W | `$${string}` ? `✗ "${P & string}" is already a row key of this Class: give the .with another name` : `✗ "${P & string}" reads another root: read it as a facet of the
|
|
42
|
+
readonly [P in keyof X as P extends PropNamesOf<Cls<S, K>> | RowKeys | keyof W | `$${string}` ? P : X[P] extends RelationRead<unknown> ? never : P]: P extends PropNamesOf<Cls<S, K>> | RowKeys | keyof W | `$${string}` ? `✗ "${P & string}" is already a row key of this Class: give the .with another name` : `✗ "${P & string}" reads another root: read it as a facet of the Query`;
|
|
43
43
|
};
|
|
44
44
|
type RowOf<S, K, W, M extends Rendering, H extends boolean> = ((M extends 'reference' ? Ref<S, K> : Row<S, K>) & W) | (H extends true ? WithheldRow<S, K> : never);
|
|
45
45
|
/** The id of a Node, its path, or a Core node of the Domain. */
|
|
46
|
-
export type Target = NodeId | NodePath |
|
|
46
|
+
export type Target = NodeId | NodePath | CoreNodeHandle<string>;
|
|
47
47
|
/** A Core node of the Domain (`d.core.<node>`). */
|
|
48
|
-
export interface
|
|
48
|
+
export interface CoreNodeHandle<Key extends string> {
|
|
49
49
|
readonly '~core': Key;
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
/** The `id` of a Node handle: its identity, matched by id, path or Core node. */
|
|
52
|
+
export interface IdProp {
|
|
52
53
|
eq(id: Target): Cond;
|
|
53
54
|
/** Any length. */
|
|
54
55
|
in(ids: readonly Target[]): Cond;
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
+
/** The `path` of a Node handle. */
|
|
58
|
+
export interface PathProp {
|
|
57
59
|
eq(path: NodePath): Cond;
|
|
58
60
|
in(paths: readonly NodePath[]): Cond;
|
|
59
61
|
}
|
|
@@ -137,7 +139,7 @@ export interface NodeSet<S, K extends string, W, M extends Rendering, H extends
|
|
|
137
139
|
readonly rows: readonly RowOf<S, K, W, M, H>[];
|
|
138
140
|
readonly more: boolean;
|
|
139
141
|
}>;
|
|
140
|
-
/** Only as a
|
|
142
|
+
/** Only as a Query's single read: the call sets the size, up to `max`, and continues it. */
|
|
141
143
|
page(options: {
|
|
142
144
|
readonly max: number;
|
|
143
145
|
}): PageRead<RowOf<S, K, W, M, H>>;
|
|
@@ -233,10 +235,10 @@ type ClassHandles<S, Classes> = {
|
|
|
233
235
|
type CoreHandles<Core> = Core extends {
|
|
234
236
|
readonly nodes: infer Nodes;
|
|
235
237
|
} ? {
|
|
236
|
-
readonly [N in keyof Nodes]:
|
|
238
|
+
readonly [N in keyof Nodes]: CoreNodeHandle<KeyOf<Nodes[N]>>;
|
|
237
239
|
} : never;
|
|
238
240
|
/** The escape hatch: one canonical document, its rows typed `unknown` (D23). */
|
|
239
|
-
interface DocumentRead<S> {
|
|
241
|
+
export interface DocumentRead<S> {
|
|
240
242
|
document(query: Extract<SizedQuery<S>, {
|
|
241
243
|
readonly list: unknown;
|
|
242
244
|
}>): Read<readonly unknown[]>;
|
|
@@ -248,7 +250,7 @@ interface DocumentRead<S> {
|
|
|
248
250
|
}>): Read<Count>;
|
|
249
251
|
}
|
|
250
252
|
/**
|
|
251
|
-
* The handles a
|
|
253
|
+
* The handles a Query's `build` receives (S1): the Domain's own Classes, each dependency under
|
|
252
254
|
* its alias, the Kernel's Classes under `d.kernel`, the Domain's Core nodes under `d.core`, and
|
|
253
255
|
* `d.origin`. A Class the Domain neither declares nor depends on has no handle.
|
|
254
256
|
*/
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* What a read lowers to: its canonical v7 document, and the plan the
|
|
2
|
+
* What a read lowers to: its canonical v7 document, and the plan the Query runtime answers it
|
|
3
3
|
* by (WP-S3): the verb, its bound, and for each pattern the Classes its rows may be, how they
|
|
4
4
|
* render and the relations they carry. A read whose condition can match nothing is `empty`: it
|
|
5
5
|
* has no document, and the runtime answers it without sending. When the input folds a condition
|
|
6
6
|
* (an empty list), the read keeps its document as written: the one S12 checks.
|
|
7
7
|
*/
|
|
8
|
-
import type {
|
|
8
|
+
import type { QueryDocument } from '../language/query.js';
|
|
9
9
|
import type { Scope } from './terms.js';
|
|
10
10
|
/** The verbs of a root read; `document` is the escape hatch (D23). */
|
|
11
11
|
export type Verb = 'get' | 'find' | 'first' | 'firstN' | 'firstMore' | 'page' | 'all' | 'exists' | 'count' | 'document';
|
|
@@ -34,16 +34,17 @@ export interface BranchPlan extends Pattern {
|
|
|
34
34
|
readonly bound?: number;
|
|
35
35
|
/** Its condition matches nothing: it is not sent, and every parent gets the empty answer. */
|
|
36
36
|
readonly empty: boolean;
|
|
37
|
-
/** Each row carries `$edge` (`.withEdge()`). */
|
|
38
|
-
readonly edge
|
|
37
|
+
/** Each row carries `$edge` (`.withEdge()`): the Edge's Class, and its values when selected. */
|
|
38
|
+
readonly edge?: Rendering;
|
|
39
39
|
}
|
|
40
40
|
export interface NodeRootPlan extends Pattern {
|
|
41
41
|
readonly kind: 'nodes';
|
|
42
42
|
}
|
|
43
|
-
/** One end of an Edge root: its role on the rows,
|
|
43
|
+
/** One end of an Edge root: its role on the rows, the Classes it accepts, how it is answered. */
|
|
44
44
|
export interface EndPlan {
|
|
45
45
|
readonly role: string;
|
|
46
46
|
readonly classes: readonly string[];
|
|
47
|
+
readonly select: Rendering;
|
|
47
48
|
}
|
|
48
49
|
export interface EdgeRootPlan {
|
|
49
50
|
readonly kind: 'edges';
|
|
@@ -61,9 +62,9 @@ export interface ReadPlan {
|
|
|
61
62
|
/** Its condition matches nothing: answered without sending. */
|
|
62
63
|
readonly empty: boolean;
|
|
63
64
|
/** Absent when `empty`. */
|
|
64
|
-
readonly document?:
|
|
65
|
+
readonly document?: QueryDocument;
|
|
65
66
|
/** The document as written, when the input folds it: as no empty list folds it. */
|
|
66
|
-
readonly written?:
|
|
67
|
+
readonly written?: QueryDocument;
|
|
67
68
|
/** Absent for `document`, whose rows are unknown. */
|
|
68
69
|
readonly root?: NodeRootPlan | EdgeRootPlan;
|
|
69
70
|
/** The id or path `get`, `find` or `exists` was given, as `NOT_FOUND` names it. */
|
|
@@ -91,9 +92,9 @@ export declare class RelationRead {
|
|
|
91
92
|
/** The handle it was read from: a `.with` takes only its own handle's relations. */
|
|
92
93
|
scope: Scope, lower: (key: string, name: string) => LoweredBranch);
|
|
93
94
|
}
|
|
94
|
-
/** Whether a value is a read a
|
|
95
|
+
/** Whether a value is a read a Query runs (a root read). */
|
|
95
96
|
export declare function isRead(value: unknown): value is RootRead;
|
|
96
97
|
/** The plan of a root read. */
|
|
97
98
|
export declare function planOf(read: unknown): ReadPlan;
|
|
98
99
|
/** The canonical document of a root read; an `empty` read has none. */
|
|
99
|
-
export declare function lower(read: unknown):
|
|
100
|
+
export declare function lower(read: unknown): QueryDocument | undefined;
|
|
@@ -18,7 +18,7 @@ export class RelationRead {
|
|
|
18
18
|
Object.freeze(this);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
/** Whether a value is a read a
|
|
21
|
+
/** Whether a value is a read a Query runs (a root read). */
|
|
22
22
|
export function isRead(value) {
|
|
23
23
|
return value instanceof RootRead;
|
|
24
24
|
}
|
|
@@ -280,7 +280,7 @@ function withsOf(value, handleScope, taken, earlier) {
|
|
|
280
280
|
throw new TypeError(`"${name}" is already a row key of this Class: give the .with another name.`);
|
|
281
281
|
const read = entry instanceof Exists ? entry.read : entry;
|
|
282
282
|
if (read instanceof RootRead)
|
|
283
|
-
throw new TypeError(`"${name}" reads another root: read it as a facet of the
|
|
283
|
+
throw new TypeError(`"${name}" reads another root: read it as a facet of the Query.`);
|
|
284
284
|
if (!(read instanceof RelationRead))
|
|
285
285
|
throw new TypeError(`"${name}" is not a relation read: end the relation with a verb (find, first, all, count, exists).`);
|
|
286
286
|
if (read.scope !== handleScope)
|
|
@@ -445,7 +445,7 @@ export class Relation {
|
|
|
445
445
|
verb,
|
|
446
446
|
...(bound === undefined ? {} : { bound }),
|
|
447
447
|
empty: sent === undefined,
|
|
448
|
-
edge:
|
|
448
|
+
...(s.selectEdge ? { edge: 'value' } : {}),
|
|
449
449
|
classes: keysOf(s.far),
|
|
450
450
|
select: s.select,
|
|
451
451
|
withheld: s.withheld,
|
|
@@ -780,8 +780,8 @@ export class EdgeSet {
|
|
|
780
780
|
classes: [edge.key],
|
|
781
781
|
select: this.#s.select,
|
|
782
782
|
withheld: this.#s.withheld,
|
|
783
|
-
source: { role: source.role, classes: keysOf(model.far(source)) },
|
|
784
|
-
target: { role: target.role, classes: keysOf(model.far(target)) },
|
|
783
|
+
source: { role: source.role, classes: keysOf(model.far(source)), select: this.#s.select },
|
|
784
|
+
target: { role: target.role, classes: keysOf(model.far(target)), select: this.#s.select },
|
|
785
785
|
};
|
|
786
786
|
}
|
|
787
787
|
#list(verb, limit, bound) {
|
|
@@ -38,7 +38,7 @@ export type WithheldRow<S, K> = K extends unknown ? {
|
|
|
38
38
|
readonly $withheld: readonly PropNamesOf<Cls<S, K>>[];
|
|
39
39
|
} : never;
|
|
40
40
|
/**
|
|
41
|
-
* An Edge's identity: its Class and both ends. An object type, not an interface: a
|
|
41
|
+
* An Edge's identity: its Class and both ends. An object type, not an interface: a Query's
|
|
42
42
|
* exported declaration then spells it out.
|
|
43
43
|
*/
|
|
44
44
|
type EdgeIdentity<E> = {
|
|
@@ -3,11 +3,14 @@ export { executeQuery, type QueryClient, type QueryExecutor } from './execution/
|
|
|
3
3
|
export { QueryPaginationError, QueryValueMismatchError, type QueryFailure, type QueryPaginationErrorCode, } from './failure.js';
|
|
4
4
|
export type { CompositeQueryDefinition, QueryDefinition, QueryInputOf, QueryOutputOf, QueryPagination, } from './query.js';
|
|
5
5
|
export type { CompositeQuery, ProjectedCompositeQuery, QueryComposition, QueryPlan, QueryPlanInput, QueryPlanOutput, QueryPlanValue, RawCompositeQuery, } from './composite/index.js';
|
|
6
|
-
export { defineQuery } from './
|
|
7
|
-
export { edgeKey, type Count, type EdgeKey, type EdgeRow, type Page, type Ref, type Row, } from './handles/rows.js';
|
|
8
|
-
export type { Handles } from './handles/handles.js';
|
|
9
|
-
export type {
|
|
6
|
+
export { defineQuery } from './defined/define.js';
|
|
7
|
+
export { edgeKey, type Count, type EdgeKey, type EdgeRow, type Page, type EdgeRootRef, type EdgeRootRow, type Ref, type Row, type WithheldEdgeRow, type WithheldRow, } from './handles/rows.js';
|
|
8
|
+
export type { CoreNodeHandle, DocumentRead, EdgeHandle, EdgeRootHandle, EdgeSet, Handles, IdProp, NodeHandle, NodeMethods, NodeSet, PageRead, PathProp, Read, RelationRead, RelSet, } from './handles/handles.js';
|
|
9
|
+
export type { BooleanProp, Cond, EnumProp, IsCond, JsonProp, NumberProp, OpenProp, OrderKey, PropsOf, SetProp, TextProp, Unordered, } from './handles/conditions.js';
|
|
10
|
+
export type { DefinedQuery, InputOf, OutputOf, Stepped, Steps } from './defined/query.js';
|
|
11
|
+
export type { QueryDocument } from './language/query.js';
|
|
12
|
+
export type { QueryRequestOptions } from './execution/client.js';
|
|
10
13
|
export { isQueryError, QueryError, type QueryErrorCode, type QueryErrorDetails, } from './execution/error.js';
|
|
11
|
-
export {
|
|
14
|
+
export { runQuery, type QueryOptions, type QueryPageOptions } from './execution/run.js';
|
|
12
15
|
export { defineCollectionQuery, queryResult, type CollectionQueryDefinition, type CollectionQuerySpec, type CollectionValue, type CompleteQueryProjectionContext, type PaginatedQuery, type ProjectedQuery, type QueryAstOf, type QueryPages, type QueryProjectionContext, type RawQuery, type SingleQuery, type SingleQueryDefinition, } from './legacy/v6/index.js';
|
|
13
16
|
export * from './legacy/v6/kernel.js';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { defineCompositeQuery, realizeQuery } from './define.js';
|
|
2
2
|
export { executeQuery } from './execution/index.js';
|
|
3
3
|
export { QueryPaginationError, QueryValueMismatchError, } from './failure.js';
|
|
4
|
-
// Query v7
|
|
5
|
-
export { defineQuery } from './
|
|
4
|
+
// Query v7. `defineQuery` defines a Query v7 from a string id, and a V6 Query from a function.
|
|
5
|
+
export { defineQuery } from './defined/define.js';
|
|
6
6
|
export { edgeKey, } from './handles/rows.js';
|
|
7
7
|
export { isQueryError, QueryError, } from './execution/error.js';
|
|
8
|
-
export {
|
|
8
|
+
export { runQuery } from './execution/run.js';
|
|
9
9
|
// Query V6.
|
|
10
10
|
export { defineCollectionQuery, queryResult, } from './legacy/v6/index.js';
|
|
11
11
|
export * from './legacy/v6/kernel.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** The Query v7 language: the static type of a Query's canonical JSON, over one Domain. */
|
|
2
|
-
export { QUERY, type
|
|
2
|
+
export { QUERY, type QueryDocument, type Query, type QueryBounds, type QueryBranch, type QueryClassKey, type QueryCondition, type QueryDomainOf, type QueryEdgeClassKey, type QueryNodeClassKey, type QueryOperatorOf, type QueryOrderKey, type QueryPropertyKey, type QueryPropertyValue, type QueryPropertyValues, type QueryRange, type QueryRendering, type QueryRoot, type QueryTraversal, type Refused, type SizedList, type SizedQuery, type TraversalDirection, type UnsizedList, } from './query.js';
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* `Query<Schema>` is the static type of the canonical JSON (`"query": "astrale.query/7"`). Every
|
|
6
6
|
* name is a key of the Domain (its own Classes, its direct dependencies' and the Kernel's), every
|
|
7
|
-
* condition one its key's value kind admits, every value of its key's type. A
|
|
8
|
-
* to it; an LLM, a tool or a person writes it; tsc checks it at the leaf that is wrong.
|
|
7
|
+
* condition one its key's value kind admits, every value of its key's type. A defined Query's reads
|
|
8
|
+
* lower to it; an LLM, a tool or a person writes it; tsc checks it at the leaf that is wrong.
|
|
9
9
|
*
|
|
10
10
|
* It neither wraps nor re-exports the Kernel's builders (`where`, `key`, `property`, `ref`): the
|
|
11
11
|
* SDK owns its language surface; the Kernel's wire decoder is the one judge of a document.
|
|
@@ -77,7 +77,7 @@ export type QueryPropertyValues<Source> = QueryDomainOf<Source> extends infer D
|
|
|
77
77
|
* `text` or an `instant` (an annotation of its schema), an array a `set` or a `json` (its
|
|
78
78
|
* `uniqueItems`), the portable `Value` any kind. tsc admits what any of them admits, so it never
|
|
79
79
|
* refuses a condition the Kernel answers; the Kernel's decoder refuses the rest (law L4). A value
|
|
80
|
-
* of unknown type (a Query over any Domain, `
|
|
80
|
+
* of unknown type (a Query over any Domain, `QueryDocument`) admits every kind.
|
|
81
81
|
*/
|
|
82
82
|
type KindsOf<V> = unknown extends V ? keyof Admits : V extends boolean ? 'boolean' : V extends number ? 'number' : V extends string ? string extends V ? 'text' | 'instant' : 'enum' : V extends readonly unknown[] ? 'set' | 'json' : V extends null ? never : 'json';
|
|
83
83
|
/** The operators each value kind admits; `key` orders a list (page § Atoms et value kinds). */
|
|
@@ -309,7 +309,7 @@ type QueryOver<D extends Domain, L extends Size> = D extends Domain ? {
|
|
|
309
309
|
} : never;
|
|
310
310
|
/** A Query of the Domain, as its canonical JSON: the root fold names its family. */
|
|
311
311
|
export type Query<Source> = QueryOver<QueryDomainOf<Source>, UnsizedList>;
|
|
312
|
-
/** A Query whose every list is sized by `limit`: the
|
|
312
|
+
/** A Query whose every list is sized by `limit`: the document a defined Query reads (W1). */
|
|
313
313
|
export type SizedQuery<Source> = QueryOver<QueryDomainOf<Source>, SizedList>;
|
|
314
314
|
/** The parts of a Query, for authors who build one piece by piece. */
|
|
315
315
|
export type QueryCondition<Source> = Where<QueryDomainOf<Source>>;
|
|
@@ -319,5 +319,5 @@ export type QueryBranch<Source> = Branch<QueryDomainOf<Source>, UnsizedList>;
|
|
|
319
319
|
export type QueryRoot<Source> = Root<QueryDomainOf<Source>, UnsizedList>;
|
|
320
320
|
export type QueryRange<Source> = Range<QueryDomainOf<Source>>;
|
|
321
321
|
/** Any v7 Query, of any Domain: what code that does not know the Domain handles. */
|
|
322
|
-
export type
|
|
322
|
+
export type QueryDocument = Query<Domain>;
|
|
323
323
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { QueryAST } from '@astrale-os/kernel-core/graph/query';
|
|
2
1
|
import type { AnyResolvedClass } from '@astrale-os/kernel-dsl/v1';
|
|
2
|
+
import { QueryAST } from '@astrale-os/kernel-core/graph/query';
|
|
3
3
|
import type { Edge } from '../../../../../platform/graph/edge/index.js';
|
|
4
4
|
import type { Node } from '../../../../../platform/graph/node/index.js';
|
|
5
5
|
import type { Domain } from '../../../../../platform/schema/index.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { definedClass } from '@astrale-os/kernel-client/graph';
|
|
2
|
-
import { Query, QueryAST
|
|
2
|
+
import { Query, QueryAST } from '@astrale-os/kernel-core/graph/query';
|
|
3
3
|
import { QueryCompositionError } from '../../../composite/errors.js';
|
|
4
4
|
import { collectionIdentityOf } from './identity.js';
|
|
5
5
|
import { COLLECTION_QUERY_LIMITS } from './limits.js';
|
|
@@ -31,8 +31,8 @@ export function compileCollectionUnion(domain, definitions, outputPath) {
|
|
|
31
31
|
name,
|
|
32
32
|
specification: realizeMember(definition, domain, outputPath, name),
|
|
33
33
|
}));
|
|
34
|
-
if (realized.length >
|
|
35
|
-
limit(`${pathOf(outputPath)} has ${realized.length} collection members; maximum is ${
|
|
34
|
+
if (realized.length > QueryAST.limits.sourceTerms) {
|
|
35
|
+
limit(`${pathOf(outputPath)} has ${realized.length} collection members; maximum is ${QueryAST.limits.sourceTerms}.`);
|
|
36
36
|
}
|
|
37
37
|
const ids = new Map();
|
|
38
38
|
const classes = new Map();
|
|
@@ -28,7 +28,7 @@ export interface SingleQueryProjector<Schema extends schema.DomainSchema> {
|
|
|
28
28
|
export interface CollectionQueryProjector<Schema extends schema.DomainSchema> {
|
|
29
29
|
<Class extends AnyResolvedClass>(project: (domain: ResolvedDomainOf<Schema>) => CollectionQuerySpec<Class>): CollectionQueryDefinition<ResolvedDomainOf<Schema>, Class>;
|
|
30
30
|
}
|
|
31
|
-
/** Define one inert single Query
|
|
31
|
+
/** Define one inert single Query projected from its exact loaded Domain. */
|
|
32
32
|
export declare function defineQuery<Schema extends schema.DomainSchema>(): SingleQueryProjector<Schema>;
|
|
33
33
|
/** Define one reusable complete polymorphic Class-extent Query. */
|
|
34
34
|
export declare function defineCollectionQuery<Schema extends schema.DomainSchema>(): CollectionQueryProjector<Schema>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Query } from '@astrale-os/kernel-core/graph/query';
|
|
2
|
-
import { definitionBase,
|
|
2
|
+
import { definitionBase, inertQuery } from '../../definition.js';
|
|
3
3
|
import { requireUniqueCollectionValues } from './collection/identity.js';
|
|
4
4
|
import { COLLECTION_QUERY_LIMITS } from './collection/limits.js';
|
|
5
5
|
import { realizeCollectionQuery, registerCollectionQuery, } from './collection/metadata.js';
|
|
@@ -7,9 +7,9 @@ import { definedValues } from './conformance.js';
|
|
|
7
7
|
import { queryResult } from './single/index.js';
|
|
8
8
|
const DEFAULT_PAGE_SIZE = 256;
|
|
9
9
|
const MAXIMUM_PAGES = 1_024;
|
|
10
|
-
/** Define one inert single Query
|
|
10
|
+
/** Define one inert single Query projected from its exact loaded Domain. */
|
|
11
11
|
export function defineQuery() {
|
|
12
|
-
return ((project) =>
|
|
12
|
+
return ((project) => inertQuery('query', project));
|
|
13
13
|
}
|
|
14
14
|
/** Define one reusable complete polymorphic Class-extent Query. */
|
|
15
15
|
export function defineCollectionQuery() {
|
|
@@ -4,13 +4,15 @@ import type { Domain } from '../../../../../platform/schema/index.js';
|
|
|
4
4
|
import type { QueryDefinition } from '../../../query.js';
|
|
5
5
|
import type { CollectionDefinitionRecord } from '../collection/union.js';
|
|
6
6
|
import type { SingleQuery } from '../single/index.js';
|
|
7
|
-
|
|
7
|
+
import type { QueryPageExecutor } from '../single/pagination.js';
|
|
8
|
+
/** The client a V6 Query reads through, page by page. Every `QueryClient` serves it. */
|
|
9
|
+
export interface QueryV6Client {
|
|
8
10
|
query<Ast extends QueryAST>(ast: Ast, options: {
|
|
9
11
|
readonly page: QueryPageRequest;
|
|
10
12
|
}): Promise<QueryResponse<QueryResultFor<Ast>>>;
|
|
11
13
|
}
|
|
12
14
|
/** The client's V6 reads, each value checked against this client's Domain. */
|
|
13
|
-
export declare function conformingClient(client:
|
|
14
|
-
export declare function runCollectionUnion(execute:
|
|
15
|
+
export declare function conformingClient(client: QueryV6Client, domain: Domain): QueryPageExecutor;
|
|
16
|
+
export declare function runCollectionUnion(execute: QueryPageExecutor, domain: Domain, definitions: CollectionDefinitionRecord, outputPath: readonly string[]): Promise<Readonly<Record<string, readonly unknown[]>>>;
|
|
15
17
|
export declare function realizeSingle<DomainValue extends Domain>(definition: QueryDefinition<Domain, unknown, unknown>, domain: DomainValue): SingleQuery<unknown, unknown>;
|
|
16
|
-
export declare function runSingle(execute:
|
|
18
|
+
export declare function runSingle(execute: QueryPageExecutor, definition: SingleQuery<unknown, unknown>, input: unknown): Promise<unknown>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Query V6: the names `@astrale-os/sdk/query` exports for V6
|
|
1
|
+
/** Query V6: the names `@astrale-os/sdk/query` exports for V6 Queries and their results. */
|
|
2
2
|
export { defineCollectionQuery, defineQuery } from './define.js';
|
|
3
3
|
export type { CollectionQuerySpec } from './collection/metadata.js';
|
|
4
4
|
export type { CollectionQueryDefinition, CollectionValue, QueryAstOf, SingleQueryDefinition, } from '../../query.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/** Query V6: the names `@astrale-os/sdk/query` exports for V6
|
|
1
|
+
/** Query V6: the names `@astrale-os/sdk/query` exports for V6 Queries and their results. */
|
|
2
2
|
export { defineCollectionQuery, defineQuery } from './define.js';
|
|
3
3
|
export { queryResult } from './single/index.js';
|
|
@@ -24,7 +24,7 @@ export interface QueryLifecycle<Input, Output> {
|
|
|
24
24
|
export interface QueryPagination {
|
|
25
25
|
readonly maximumPages: number;
|
|
26
26
|
}
|
|
27
|
-
/** Inert Domain-bound Query
|
|
27
|
+
/** Inert Domain-bound Query definition. Its projector is retained privately by the SDK. */
|
|
28
28
|
export interface QueryDefinition<DomainValue extends Domain = Domain, Input = unknown, Output = QueryResult> {
|
|
29
29
|
readonly kind: 'query' | 'composite-query';
|
|
30
30
|
readonly [QUERY_DOMAIN]: (domain: DomainValue) => DomainValue;
|
|
@@ -35,14 +35,14 @@ export interface SingleQueryDefinition<DomainValue extends Domain = Domain, Inpu
|
|
|
35
35
|
readonly kind: 'query';
|
|
36
36
|
}
|
|
37
37
|
export type CollectionValue<Class extends AnyResolvedClass> = Class extends ResolvedClass<'node'> ? Node : Class extends ResolvedClass<'edge'> ? Edge : never;
|
|
38
|
-
/** Closed complete-Class Query
|
|
38
|
+
/** Closed complete-Class Query definition admitted for explicit physical union planning. */
|
|
39
39
|
export interface CollectionQueryDefinition<DomainValue extends Domain = Domain, Class extends AnyResolvedClass = AnyResolvedClass> extends SingleQueryDefinition<DomainValue, void, readonly CollectionValue<Class>[]> {
|
|
40
40
|
readonly [COLLECTION_QUERY_CLASS]: Class;
|
|
41
41
|
}
|
|
42
42
|
export interface CompositeQueryDefinition<DomainValue extends Domain = Domain, Input = unknown, Output = unknown> extends QueryDefinition<DomainValue, Input, Output> {
|
|
43
43
|
readonly kind: 'composite-query';
|
|
44
44
|
}
|
|
45
|
-
/** Canonical admitted operation produced by realizing one Query
|
|
45
|
+
/** Canonical admitted operation produced by realizing one Query definition. */
|
|
46
46
|
export type RealizedQuery<Input, Output = QueryResult, Ast extends QueryAST = QueryAST> = SingleQuery<Input, Output, Ast> | CompositeQuery<Input, unknown, Output, Domain>;
|
|
47
47
|
export type QueryInputOf<Value> = Value extends QueryDefinition<infer _Domain, infer Input, infer _Output> ? Input : Value extends QueryLifecycle<infer Input, infer _Output> ? Input : never;
|
|
48
48
|
export type QueryOutputOf<Value> = Value extends QueryDefinition<infer _Domain, infer _Input, infer Output> ? Output : Value extends QueryLifecycle<infer _Input, infer Output> ? Output : never;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { release } from '@astrale-os/kernel-protocol';
|
|
2
2
|
import type { RuntimeRegistry } from '../runtime/index.js';
|
|
3
3
|
import type { Routes } from './collection.js';
|
|
4
|
-
/** Lower
|
|
4
|
+
/** Lower definition identities to canonical callable keys after Runtime admission. */
|
|
5
5
|
export declare function admit(input: Routes | undefined, registry: RuntimeRegistry): readonly release.HttpRouteDeclaration[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isRoutes } from './collection.js';
|
|
2
|
-
/** Lower
|
|
2
|
+
/** Lower definition identities to canonical callable keys after Runtime admission. */
|
|
3
3
|
export function admit(input, registry) {
|
|
4
4
|
if (input === undefined)
|
|
5
5
|
return Object.freeze([]);
|
|
@@ -8,7 +8,7 @@ export function admit(input, registry) {
|
|
|
8
8
|
return Object.freeze(input.entries.map(({ target, ...declaration }) => {
|
|
9
9
|
const implementation = registry.implementations.find(({ definition }) => definition === target);
|
|
10
10
|
if (implementation === undefined) {
|
|
11
|
-
throw new TypeError(`Route ${declaration.name} targets a
|
|
11
|
+
throw new TypeError(`Route ${declaration.name} targets a definition outside the Runtime.`);
|
|
12
12
|
}
|
|
13
13
|
return Object.freeze({ ...declaration, callable: implementation.callable.key });
|
|
14
14
|
}));
|
|
@@ -2,8 +2,9 @@ import type { Route, RouteInput, RouteTarget } from './route.js';
|
|
|
2
2
|
export { admit } from './admission.js';
|
|
3
3
|
export { isRoute, isRoutes, routes, type Routes } from './collection.js';
|
|
4
4
|
export type { Route, RouteInput, RouteTarget } from './route.js';
|
|
5
|
-
|
|
5
|
+
/** An Action or Workflow definition: what a route targets. */
|
|
6
|
+
type Callable = RouteTarget & {
|
|
6
7
|
readonly run: (...input: never[]) => unknown;
|
|
7
8
|
};
|
|
8
9
|
/** Define one HTTP route without exposing DSL Function or Method topology. */
|
|
9
|
-
export declare function route<const Target extends
|
|
10
|
+
export declare function route<const Target extends Callable>(target: Target, input: RouteInput): Route<Target>;
|
|
@@ -4,7 +4,7 @@ export interface RouteTarget {
|
|
|
4
4
|
readonly address: string;
|
|
5
5
|
}
|
|
6
6
|
export type RouteInput = Omit<release.HttpRouteDeclaration, 'callable'>;
|
|
7
|
-
/** One provider-neutral HTTP route targeting an admitted Action or Workflow
|
|
7
|
+
/** One provider-neutral HTTP route targeting an admitted Action or Workflow definition. */
|
|
8
8
|
export interface Route<Target extends RouteTarget = RouteTarget> extends RouteInput {
|
|
9
9
|
readonly target: Target;
|
|
10
10
|
}
|
|
@@ -6,22 +6,22 @@ import type { WorkflowAddress, WorkflowDefinition } from '../workflow/index.js';
|
|
|
6
6
|
import type { RuntimeInitialization, RuntimeInitializer } from './initialize.js';
|
|
7
7
|
import type { RuntimeIntegrations } from './integrations.js';
|
|
8
8
|
import type { Runtime } from './runtime.js';
|
|
9
|
-
/** Retain each
|
|
10
|
-
type RuntimeFunctionSignature<
|
|
9
|
+
/** Retain each Function's exact contract without repeating the owning Schema in every tuple slot. */
|
|
10
|
+
type RuntimeFunctionSignature<Callable> = Callable extends ActionDefinition<infer Schema, infer Address, infer Definitions, infer Errors> ? readonly [
|
|
11
11
|
'action',
|
|
12
12
|
Address,
|
|
13
13
|
Definitions,
|
|
14
14
|
Errors,
|
|
15
15
|
{
|
|
16
|
-
[Key in keyof
|
|
16
|
+
[Key in keyof Callable as Exclude<Key, keyof ActionDefinition<Schema, Address, Definitions, Errors>>]: Callable[Key];
|
|
17
17
|
}
|
|
18
|
-
] :
|
|
18
|
+
] : Callable extends WorkflowDefinition<infer Schema, infer Address, infer Definitions, infer Errors> ? readonly [
|
|
19
19
|
'workflow',
|
|
20
20
|
Address,
|
|
21
21
|
Definitions,
|
|
22
22
|
Errors,
|
|
23
23
|
{
|
|
24
|
-
[Key in keyof
|
|
24
|
+
[Key in keyof Callable as Exclude<Key, keyof WorkflowDefinition<Schema, Address, Definitions, Errors>>]: Callable[Key];
|
|
25
25
|
}
|
|
26
26
|
] : never;
|
|
27
27
|
export type RuntimeFunctionSignatures<Functions extends readonly unknown[]> = {
|
|
@@ -37,7 +37,7 @@ type RuntimeFunction<Schema extends schema.DomainSchema, Signature> = Signature
|
|
|
37
37
|
type RuntimeFunctions<Schema extends schema.DomainSchema, Signatures extends readonly unknown[]> = {
|
|
38
38
|
[Index in keyof Signatures]: RuntimeFunction<Schema, Signatures[Index]>;
|
|
39
39
|
};
|
|
40
|
-
/** A portable inferred Runtime keeps its Schema once while retaining the exact
|
|
40
|
+
/** A portable inferred Runtime keeps its Schema once while retaining the exact Function tuple. */
|
|
41
41
|
export interface AuthoredRuntime<Schema extends schema.DomainSchema, Integrations extends RuntimeIntegrations, Initialize extends RuntimeInitializer<never, RuntimeInitialization, Schema>, Signatures extends readonly unknown[]> extends Runtime<Schema, Integrations, Initialize, RuntimeFunctions<Schema, Signatures>> {
|
|
42
42
|
}
|
|
43
43
|
export {};
|
|
@@ -11,11 +11,11 @@ type AnyRuntimeInitializer<Schema extends schema.DomainSchema> = RuntimeInitiali
|
|
|
11
11
|
type Same<Left, Right> = [Left] extends [Right] ? ([Right] extends [Left] ? true : false) : false;
|
|
12
12
|
type ActionSchema<Value> = Value extends ActionDefinition<infer Schema, infer _Address, infer _Services> ? Schema : never;
|
|
13
13
|
type WorkflowSchema<Value> = Value extends WorkflowDefinition<infer Schema, infer _Address, infer _Services> ? Schema : never;
|
|
14
|
-
type
|
|
15
|
-
type
|
|
14
|
+
type FunctionIntegrations<Value> = Value extends ActionDefinition<infer _Schema, infer _Address, infer Definitions> ? Definitions : Value extends WorkflowDefinition<infer _Schema, infer _Address, infer Definitions> ? Definitions : never;
|
|
15
|
+
type AdmitsFunctionSchema<Schema extends schema.DomainSchema, Functions extends readonly unknown[]> = [Functions[number]] extends [never] ? unknown : Same<ActionSchema<Functions[number]> | WorkflowSchema<Functions[number]>, Schema> extends true ? unknown : never;
|
|
16
16
|
type InitializationOf<Initialize extends RuntimeInitializerValue> = Awaited<ReturnType<Initialize>>;
|
|
17
|
-
type
|
|
18
|
-
type AdmitsIntegrations<Definitions extends RuntimeIntegrations, Functions extends readonly unknown[]> = [Functions[number]] extends [never] ? unknown : false extends
|
|
17
|
+
type AdmitsFunctionIntegrations<Definitions extends RuntimeIntegrations, Callable> = FunctionIntegrations<Callable> extends infer Required extends RuntimeIntegrations ? Exclude<keyof Required, keyof Definitions> extends never ? Required extends Pick<Definitions, Extract<keyof Required, keyof Definitions>> ? true : false : false : false;
|
|
18
|
+
type AdmitsIntegrations<Definitions extends RuntimeIntegrations, Functions extends readonly unknown[]> = [Functions[number]] extends [never] ? unknown : false extends AdmitsFunctionIntegrations<Definitions, Functions[number]> ? never : unknown;
|
|
19
19
|
type AdmitsProviders<Integrations extends RuntimeIntegrations, Initialize extends RuntimeInitializerValue> = Same<InitializationOf<Initialize>['providers'], Providers<Integrations>> extends true ? unknown : never;
|
|
20
20
|
export interface RuntimeInput<Integrations extends RuntimeIntegrations, Initialize extends RuntimeInitializerValue, Functions extends readonly unknown[]> {
|
|
21
21
|
readonly integrations: Integrations;
|
|
@@ -23,6 +23,6 @@ export interface RuntimeInput<Integrations extends RuntimeIntegrations, Initiali
|
|
|
23
23
|
readonly functions: Functions;
|
|
24
24
|
}
|
|
25
25
|
/** Define one inert Runtime declaration; realization requires an exact loaded DSL Domain. */
|
|
26
|
-
export declare function defineRuntime<Schema extends schema.DomainSchema>(): <const Integrations extends RuntimeIntegrations, Initialize extends AnyRuntimeInitializer<Schema>, const Functions extends readonly unknown[]>(input: RuntimeInput<Integrations, Initialize, Functions> &
|
|
26
|
+
export declare function defineRuntime<Schema extends schema.DomainSchema>(): <const Integrations extends RuntimeIntegrations, Initialize extends AnyRuntimeInitializer<Schema>, const Functions extends readonly unknown[]>(input: RuntimeInput<Integrations, Initialize, Functions> & AdmitsFunctionSchema<Schema, Functions> & AdmitsIntegrations<Integrations, Functions> & AdmitsProviders<Integrations, Initialize>) => AuthoredRuntime<Schema, Integrations, Initialize, RuntimeFunctionSignatures<Functions>>;
|
|
27
27
|
export declare function isRuntime(input: unknown): input is Runtime;
|
|
28
28
|
export {};
|
|
@@ -6,8 +6,8 @@ import type { DomainCapabilities, DomainKernelSessions, DomainMutate } from '../
|
|
|
6
6
|
import type { HandlerDependencies } from '../dependency/index.js';
|
|
7
7
|
import type { DeclaredErrorFactory, DeclaredErrors, NoDeclaredErrors } from '../error/index.js';
|
|
8
8
|
import type { Integrations, ReplayableIntegrationClients } from '../integration/index.js';
|
|
9
|
-
import type { Mutation, MutationInputOf, MutationOutputOf,
|
|
10
|
-
import type { InputOf, OutputOf, QueryDefinition,
|
|
9
|
+
import type { Mutation, MutationInputOf, MutationOutputOf, DefinedMutation } from '../mutation/index.js';
|
|
10
|
+
import type { InputOf, OutputOf, QueryDefinition, DefinedQuery, QueryOptions } from '../query/index.js';
|
|
11
11
|
/** A callable whose Schema declares `execution: { durable: true }`. */
|
|
12
12
|
export interface DurableCallable {
|
|
13
13
|
readonly execution: {
|
|
@@ -99,8 +99,8 @@ export interface DurableStepDeclaration {
|
|
|
99
99
|
/**
|
|
100
100
|
* A Step's id alone, under the deployment's retry budget and Step timeout, or a declaration of its
|
|
101
101
|
* own. A Step that spends its budget, or that the Kernel refuses for good, throws an error
|
|
102
|
-
* `exhausted` recognizes. A Step whose
|
|
103
|
-
* unless the Kernel refused the read; a
|
|
102
|
+
* `exhausted` recognizes. A Step whose Query read fails throws its `QueryError`, not retried
|
|
103
|
+
* unless the Kernel refused the read; a Query that crosses a dependency's Class its Domain does
|
|
104
104
|
* not require throws its `TypeError`, not retried. Uncaught, each ends the Execution `failed`
|
|
105
105
|
* with code `STEP_EXHAUSTED`.
|
|
106
106
|
*/
|
|
@@ -114,19 +114,19 @@ export interface DurableStep<DomainValue extends Domain = Domain, Definitions ex
|
|
|
114
114
|
run<Output>(step: DurableStepId, execute: (authority: DurableStepAuthority<DomainValue, Definitions>) => Output | Promise<Output>): Promise<Output>;
|
|
115
115
|
/**
|
|
116
116
|
* One journaled Query. A replay returns the result of its first run, so a later Step that depends
|
|
117
|
-
* on it resends the same request whenever it is retried. A
|
|
117
|
+
* on it resends the same request whenever it is retried. A Query v7 reads as the executor; its
|
|
118
118
|
* `QueryError`, or the `TypeError` of a dependency's Class its Domain does not require, is
|
|
119
119
|
* journaled as the Step's failure, is not retried, and a replay throws it again. A read the
|
|
120
120
|
* Kernel refused is a failed attempt instead, as any Kernel refusal.
|
|
121
121
|
*/
|
|
122
|
-
query<R extends
|
|
122
|
+
query<R extends DefinedQuery>(step: DurableStepId, query: R, input: InputOf<R>, options: QueryOptions<R, 'executor'>): Promise<OutputOf<R>>;
|
|
123
123
|
query<Output>(step: DurableStepId, query: QueryDefinition<DomainValue, void, Output>): Promise<Output>;
|
|
124
124
|
query<Input, Output>(step: DurableStepId, query: QueryDefinition<DomainValue, Input, Output>, input: Input): Promise<Output>;
|
|
125
125
|
/**
|
|
126
126
|
* One journaled Mutation, as the executor. A Step replayed after its commit receives the result
|
|
127
127
|
* of that commit from the Kernel's receipt instead of writing again.
|
|
128
128
|
*/
|
|
129
|
-
mutate<M extends
|
|
129
|
+
mutate<M extends DefinedMutation>(step: DurableStepId, mutation: M, input: MutationInputOf<M>, options: {
|
|
130
130
|
readonly as: 'executor';
|
|
131
131
|
}): Promise<MutationOutputOf<M>>;
|
|
132
132
|
mutate<Input, Output>(step: DurableStepId, mutation: Mutation<DomainValue, Input, Output>, input: Input): Promise<Output>;
|
|
@@ -147,10 +147,10 @@ export interface DurableParallelStep<out Output> {
|
|
|
147
147
|
/** The Steps one `step.parallel` declares, with the arguments of `step.run`, `query` and `mutate`. */
|
|
148
148
|
export interface DurableParallelSteps<DomainValue extends Domain = Domain, Definitions extends Integrations = Readonly<Record<never, never>>> {
|
|
149
149
|
run<Output>(step: DurableStepId, execute: (authority: DurableStepAuthority<DomainValue, Definitions>) => Output | Promise<Output>): DurableParallelStep<Output>;
|
|
150
|
-
query<R extends
|
|
150
|
+
query<R extends DefinedQuery>(step: DurableStepId, query: R, input: InputOf<R>, options: QueryOptions<R, 'executor'>): DurableParallelStep<OutputOf<R>>;
|
|
151
151
|
query<Output>(step: DurableStepId, query: QueryDefinition<DomainValue, void, Output>): DurableParallelStep<Output>;
|
|
152
152
|
query<Input, Output>(step: DurableStepId, query: QueryDefinition<DomainValue, Input, Output>, input: Input): DurableParallelStep<Output>;
|
|
153
|
-
mutate<M extends
|
|
153
|
+
mutate<M extends DefinedMutation>(step: DurableStepId, mutation: M, input: MutationInputOf<M>, options: {
|
|
154
154
|
readonly as: 'executor';
|
|
155
155
|
}): DurableParallelStep<MutationOutputOf<M>>;
|
|
156
156
|
mutate<Input, Output>(step: DurableStepId, mutation: Mutation<DomainValue, Input, Output>, input: Input): DurableParallelStep<Output>;
|
|
@@ -5,7 +5,7 @@ import type { Domain } from '../../../platform/schema/index.js';
|
|
|
5
5
|
import type { InvocationSessions } from '../admission/index.js';
|
|
6
6
|
/**
|
|
7
7
|
* Bind what code acting under `sessions` holds: self-default Kernel and graph, and dependency
|
|
8
|
-
* invokers per authority. An Action and a durable Step receive these same capabilities. A
|
|
8
|
+
* invokers per authority. An Action and a durable Step receive these same capabilities. A Query's
|
|
9
9
|
* reads are checked against the Class requirements the Domain's build `declared` (S12).
|
|
10
10
|
*/
|
|
11
11
|
export declare function bindCapabilities(domain: Domain, sessions: Readonly<Record<'caller' | 'self', BoundClientSession>>, declared?: readonly DeclaredClass[]): DomainCapabilities;
|