@astrale-os/sdk 0.6.0-beta.41 → 0.6.0-beta.42
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 +22 -2
- package/dist/application/action/context.d.ts +49 -18
- package/dist/application/action/index.d.ts +1 -1
- package/dist/application/error/error.d.ts +16 -1
- package/dist/application/error/error.js +39 -5
- 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 +81 -33
- package/dist/application/mutation/authoring/builder.js +100 -30
- package/dist/application/mutation/authoring/guard.d.ts +37 -0
- package/dist/application/mutation/authoring/guard.js +150 -0
- package/dist/application/mutation/authoring/index.d.ts +5 -2
- package/dist/application/mutation/authoring/index.js +2 -1
- package/dist/application/mutation/authoring/names.d.ts +19 -0
- package/dist/application/mutation/authoring/names.js +83 -0
- package/dist/application/mutation/authoring/transition.d.ts +3 -2
- package/dist/application/mutation/define.d.ts +24 -10
- package/dist/application/mutation/define.js +49 -53
- package/dist/application/mutation/execution/execute.d.ts +2 -2
- package/dist/application/mutation/execution/execute.js +78 -7
- package/dist/application/mutation/execution/executor.d.ts +4 -1
- package/dist/application/mutation/execution/executor.js +6 -1
- package/dist/application/mutation/failure.d.ts +11 -1
- package/dist/application/mutation/failure.js +18 -3
- package/dist/application/mutation/index.d.ts +8 -4
- package/dist/application/mutation/index.js +5 -2
- package/dist/application/mutation/legacy/v6/builder.d.ts +84 -0
- package/dist/application/mutation/legacy/v6/define.d.ts +18 -0
- package/dist/application/mutation/legacy/v6/define.js +56 -0
- package/dist/application/mutation/legacy/v6/mutation.d.ts +28 -0
- package/dist/application/mutation/legacy/v6/mutation.js +1 -0
- package/dist/application/mutation/{authoring → legacy/v6}/precondition.d.ts +4 -0
- package/dist/application/mutation/mutation.d.ts +30 -19
- package/dist/application/query/answer/answer.d.ts +117 -0
- package/dist/application/query/answer/answer.js +1 -0
- package/dist/application/query/answer/conformance.d.ts +4 -0
- package/dist/application/query/answer/conformance.js +27 -0
- package/dist/application/query/answer/facts.d.ts +17 -0
- package/dist/application/query/answer/facts.js +57 -0
- package/dist/application/query/composite/builder.d.ts +1 -1
- package/dist/application/query/composite/builder.js +1 -1
- package/dist/application/query/composite/plan.d.ts +1 -1
- package/dist/application/query/composite/plan.js +1 -1
- package/dist/application/query/composite/query.d.ts +1 -2
- package/dist/application/query/define.d.ts +2 -33
- package/dist/application/query/define.js +3 -130
- package/dist/application/query/definition.d.ts +12 -0
- package/dist/application/query/definition.js +47 -0
- package/dist/application/query/execution/bounds.d.ts +20 -0
- package/dist/application/query/execution/bounds.js +86 -0
- package/dist/application/query/execution/crossings.d.ts +25 -0
- package/dist/application/query/execution/crossings.js +169 -0
- package/dist/application/query/execution/error.d.ts +68 -0
- package/dist/application/query/execution/error.js +50 -0
- package/dist/application/query/execution/execute.d.ts +2 -7
- package/dist/application/query/execution/execute.js +3 -51
- package/dist/application/query/execution/recipe.d.ts +70 -0
- package/dist/application/query/execution/recipe.js +276 -0
- package/dist/application/query/execution/refusal.d.ts +37 -0
- package/dist/application/query/execution/refusal.js +80 -0
- package/dist/application/query/execution/rows.d.ts +42 -0
- package/dist/application/query/execution/rows.js +308 -0
- package/dist/application/query/execution/split.d.ts +24 -0
- package/dist/application/query/execution/split.js +190 -0
- package/dist/application/query/handles/build.d.ts +10 -0
- package/dist/application/query/handles/build.js +53 -0
- package/dist/application/query/handles/conditions.d.ts +94 -0
- package/dist/application/query/handles/conditions.js +1 -0
- package/dist/application/query/handles/domain.d.ts +157 -0
- package/dist/application/query/handles/domain.js +1 -0
- package/dist/application/query/handles/handles.d.ts +268 -0
- package/dist/application/query/handles/handles.js +1 -0
- package/dist/application/query/handles/model.d.ts +96 -0
- package/dist/application/query/handles/model.js +246 -0
- package/dist/application/query/handles/plan.d.ts +99 -0
- package/dist/application/query/handles/plan.js +37 -0
- package/dist/application/query/handles/reads.d.ts +106 -0
- package/dist/application/query/handles/reads.js +839 -0
- package/dist/application/query/handles/relations.d.ts +100 -0
- package/dist/application/query/handles/relations.js +1 -0
- package/dist/application/query/handles/rows.d.ts +94 -0
- package/dist/application/query/handles/rows.js +4 -0
- package/dist/application/query/handles/terms.d.ts +95 -0
- package/dist/application/query/handles/terms.js +265 -0
- package/dist/application/query/index.d.ts +10 -7
- package/dist/application/query/index.js +9 -4
- package/dist/application/query/language/index.d.ts +2 -0
- package/dist/application/query/language/index.js +2 -0
- package/dist/application/query/language/query.d.ts +323 -0
- package/dist/application/query/language/query.js +2 -0
- package/dist/application/query/{collection → legacy/v6/collection}/identity.d.ts +2 -2
- package/dist/application/query/{collection → legacy/v6/collection}/metadata.d.ts +1 -1
- package/dist/application/query/{collection → legacy/v6/collection}/union.d.ts +3 -3
- package/dist/application/query/{collection → legacy/v6/collection}/union.js +1 -1
- package/dist/application/query/{conformance.d.ts → legacy/v6/conformance.d.ts} +3 -3
- package/dist/application/query/{conformance.js → legacy/v6/conformance.js} +1 -1
- package/dist/application/query/legacy/v6/define.d.ts +37 -0
- package/dist/application/query/legacy/v6/define.js +90 -0
- package/dist/application/query/legacy/v6/execution/execute.d.ts +16 -0
- package/dist/application/query/legacy/v6/execution/execute.js +50 -0
- package/dist/application/query/legacy/v6/index.d.ts +6 -0
- package/dist/application/query/legacy/v6/index.js +3 -0
- package/dist/application/query/legacy/v6/kernel.d.ts +6 -0
- package/dist/application/query/legacy/v6/kernel.js +5 -0
- package/dist/application/query/{single → legacy/v6/single}/pagination.js +1 -1
- package/dist/application/query/{single → legacy/v6/single}/query.d.ts +2 -14
- package/dist/application/query/legacy/v6/single/query.js +1 -0
- package/dist/application/query/query.d.ts +16 -1
- package/dist/application/query/recipe/define.d.ts +45 -0
- package/dist/application/query/recipe/define.js +102 -0
- package/dist/application/query/recipe/recipe.d.ts +134 -0
- package/dist/application/query/recipe/recipe.js +1 -0
- package/dist/application/workflow/durable.d.ts +22 -8
- package/dist/execution/invocation/capabilities/bind.d.ts +6 -4
- package/dist/execution/invocation/capabilities/bind.js +39 -3
- package/dist/execution/invocation/dispatch/action.js +4 -2
- package/dist/execution/invocation/dispatch/context.js +1 -1
- package/dist/execution/invocation/dispatch/workflow.js +4 -2
- package/dist/execution/invocation/result/index.d.ts +1 -0
- package/dist/execution/invocation/result/index.js +1 -0
- package/dist/execution/invocation/result/recipe.d.ts +6 -0
- package/dist/execution/invocation/result/recipe.js +17 -0
- package/dist/execution/service/create.js +1 -0
- package/dist/execution/workflows/failure.d.ts +23 -6
- package/dist/execution/workflows/failure.js +78 -18
- package/dist/execution/workflows/receiver.d.ts +3 -0
- package/dist/execution/workflows/receiver.js +1 -0
- package/dist/execution/workflows/run.js +13 -9
- package/dist/execution/workflows/steps.d.ts +3 -0
- package/dist/execution/workflows/steps.js +2 -2
- package/dist/platform/schema/kernel-compiled.d.ts +2 -0
- package/dist/platform/schema/kernel-compiled.js +2 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.js +1 -0
- package/dist/testing/recipe.d.ts +17 -0
- package/dist/testing/recipe.js +29 -0
- package/dist/tooling/cli/orchestrate.js +6 -2
- package/dist/tooling/linter/adapters/typescript/index.d.ts +2 -1
- package/dist/tooling/linter/adapters/typescript/index.js +2 -1
- package/dist/tooling/linter/adapters/typescript/query-observation.js +37 -12
- package/dist/tooling/linter/adapters/typescript/recipe-definitions.d.ts +34 -0
- package/dist/tooling/linter/adapters/typescript/recipe-definitions.js +88 -0
- package/dist/tooling/linter/adapters/typescript/type-analysis.d.ts +2 -0
- package/dist/tooling/linter/adapters/typescript/type-analysis.js +10 -0
- package/dist/tooling/linter/implementations/source/global.js +15 -9
- package/dist/tooling/linter/implementations/source/mutations.js +128 -19
- package/dist/tooling/linter/implementations/source/policy-edges.d.ts +2 -0
- package/dist/tooling/linter/implementations/source/policy-edges.js +113 -0
- package/dist/tooling/linter/implementations/source/recipes.d.ts +2 -0
- package/dist/tooling/linter/implementations/source/recipes.js +409 -0
- package/dist/tooling/linter/implementations/source/shared.d.ts +7 -1
- package/dist/tooling/linter/implementations/source/shared.js +31 -10
- package/dist/tooling/linter/implementations/source/verifiers.js +4 -0
- package/dist/tooling/linter/policy/generated.js +2 -2
- package/dist/tooling/linter/requirements/registry.js +4 -0
- package/docs/durable-workflows.md +48 -20
- package/docs/handler-dependencies.md +76 -4
- package/docs/legacy/query-v6.md +62 -0
- package/docs/queries.md +438 -0
- package/package.json +11 -8
- /package/dist/application/{query/single/query.js → mutation/legacy/v6/builder.js} +0 -0
- /package/dist/application/mutation/{authoring → legacy/v6}/precondition.js +0 -0
- /package/dist/application/query/{collection → legacy/v6/collection}/identity.js +0 -0
- /package/dist/application/query/{collection → legacy/v6/collection}/limits.d.ts +0 -0
- /package/dist/application/query/{collection → legacy/v6/collection}/limits.js +0 -0
- /package/dist/application/query/{collection → legacy/v6/collection}/metadata.js +0 -0
- /package/dist/application/query/{execution → legacy/v6/execution}/pages.d.ts +0 -0
- /package/dist/application/query/{execution → legacy/v6/execution}/pages.js +0 -0
- /package/dist/application/query/{single → legacy/v6/single}/index.d.ts +0 -0
- /package/dist/application/query/{single → legacy/v6/single}/index.js +0 -0
- /package/dist/application/query/{single → legacy/v6/single}/node.d.ts +0 -0
- /package/dist/application/query/{single → legacy/v6/single}/node.js +0 -0
- /package/dist/application/query/{single → legacy/v6/single}/pagination.d.ts +0 -0
- /package/dist/application/query/{single → legacy/v6/single}/selection.d.ts +0 -0
- /package/dist/application/query/{single → legacy/v6/single}/selection.js +0 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Domain a recipe reads, indexed once per Schema (spike designs D1, D3 and D10).
|
|
3
|
+
*
|
|
4
|
+
* Every generic is keyed by the Schema type `S` and Class keys, never by resolved Classes:
|
|
5
|
+
* instantiations are cached per (Schema, key), and messages print the key. The Domain is indexed
|
|
6
|
+
* once (`Index<S>`, key → resolved Class), and every other lookup is an indexed access into it.
|
|
7
|
+
*/
|
|
8
|
+
import type { schema } from '../../../platform/schema/index.js';
|
|
9
|
+
import type { KernelDomain } from '../../../platform/schema/kernel.js';
|
|
10
|
+
import type { SDK_KEYS } from './model.js';
|
|
11
|
+
export type Values<R> = R[keyof R];
|
|
12
|
+
/**
|
|
13
|
+
* A Class a degraded Schema types as `any` (D10). `unknown extends T` holds only for `any` (and
|
|
14
|
+
* `unknown`), and fails at once on a resolved Class; `0 extends 1 & T` would reduce an
|
|
15
|
+
* intersection with each one, walking its whole type.
|
|
16
|
+
*/
|
|
17
|
+
export type Untyped<T> = unknown extends T ? true : false;
|
|
18
|
+
/** The key of the graph's root Class, which every Node Class satisfies. */
|
|
19
|
+
export type NodeRoot = 'kernel.astrale.ai:class.Node';
|
|
20
|
+
/** The resolved Domain of a Schema. */
|
|
21
|
+
export type Dom<S> = S extends schema.DomainSchema ? schema.DomainOf<S> : never;
|
|
22
|
+
/** A namespace of Classes, without the Classes a degraded Schema types as `any` (D10). */
|
|
23
|
+
type Typed<R> = {
|
|
24
|
+
readonly [N in keyof R as Untyped<R[N]> extends true ? never : N]: R[N];
|
|
25
|
+
};
|
|
26
|
+
type ClassesOf<D> = D extends {
|
|
27
|
+
readonly classes: infer Own;
|
|
28
|
+
readonly dependencies: infer Deps;
|
|
29
|
+
} ? Values<Typed<Own>> | Values<{
|
|
30
|
+
[A in keyof Deps]: Deps[A] extends {
|
|
31
|
+
readonly classes: infer C;
|
|
32
|
+
} ? Values<Typed<C>> : never;
|
|
33
|
+
}> : never;
|
|
34
|
+
export type KeyOf<C> = C extends {
|
|
35
|
+
readonly key: infer K extends string;
|
|
36
|
+
} ? K : never;
|
|
37
|
+
/**
|
|
38
|
+
* Every Class a read names, by key: the Domain's own, its direct dependencies' and the Kernel's.
|
|
39
|
+
*/
|
|
40
|
+
export type Index<S> = {
|
|
41
|
+
readonly [C in ClassesOf<Dom<S>> | Values<KernelDomain['classes']> as KeyOf<C>]: C;
|
|
42
|
+
};
|
|
43
|
+
/** One Class of the index, by key (through `infer`: tsc does not index a remapped type by its keys). */
|
|
44
|
+
export type Cls<S, K> = Index<S> extends infer I ? I[K & keyof I] : never;
|
|
45
|
+
/** The key of every Node Class a read names. */
|
|
46
|
+
export type NodeClassKey<S> = KeyOf<Exclude<Values<Index<S>>, {
|
|
47
|
+
readonly kind: 'edge';
|
|
48
|
+
}>>;
|
|
49
|
+
/** The Domain's origin, as the Schema declares it: its resolved Domain types it as `string`. */
|
|
50
|
+
export type OriginOf<S> = S extends {
|
|
51
|
+
readonly origin: infer O extends string;
|
|
52
|
+
} ? O : never;
|
|
53
|
+
/** Every Edge Class of the index, as resolved Classes. */
|
|
54
|
+
export type EdgesOf<S> = Extract<Values<Index<S>>, {
|
|
55
|
+
readonly kind: 'edge';
|
|
56
|
+
}>;
|
|
57
|
+
/** The keys a Class satisfies: its own and its parents', transitively. */
|
|
58
|
+
type SatKeys<C, Depth extends readonly 0[] = []> = Depth['length'] extends 8 ? never : C extends {
|
|
59
|
+
readonly key: infer K extends string;
|
|
60
|
+
readonly extends: infer P extends readonly unknown[];
|
|
61
|
+
} ? `${string}:class.${string}` extends K ? never : K | SatKeys<P[number], [...Depth, 0]> : never;
|
|
62
|
+
/** The keys a Class satisfies, and the graph root for a Node Class. */
|
|
63
|
+
type SatisfiedBy<C> = SatKeys<C> | (C extends {
|
|
64
|
+
readonly kind: 'edge';
|
|
65
|
+
} ? never : NodeRoot);
|
|
66
|
+
export type Satisfies<S, K> = K extends unknown ? SatisfiedBy<Cls<S, K>> : never;
|
|
67
|
+
interface Sub<At extends string, K extends string> {
|
|
68
|
+
readonly at: At;
|
|
69
|
+
readonly sub: K;
|
|
70
|
+
}
|
|
71
|
+
/** One entry per parent link: a Class under each key it satisfies, its own and the root apart. */
|
|
72
|
+
type SubEntries<S> = Values<Index<S>> extends infer C ? C extends unknown ? Exclude<SatKeys<C>, KeyOf<C>> extends infer At ? At extends string ? Sub<At, KeyOf<C>> : never : never : never : never;
|
|
73
|
+
/** The proper subclasses of each Class that has one: computed once per Schema (D3). */
|
|
74
|
+
type SubclassesByClass<S> = {
|
|
75
|
+
readonly [E in SubEntries<S> as E['at']]: E['sub'];
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* A Class key, or the key of any subclass the Domain can name (D6). The graph root's are every
|
|
79
|
+
* Node Class: only parent links are grouped, so a Schema without inheritance groups nothing.
|
|
80
|
+
*/
|
|
81
|
+
export type ClassOf<S, K> = K extends NodeRoot ? NodeClassKey<S> : K | SubclassesByClass<S>[K & keyof SubclassesByClass<S>];
|
|
82
|
+
type ByKeyOf<C> = C extends {
|
|
83
|
+
readonly properties: {
|
|
84
|
+
readonly byKey: infer B;
|
|
85
|
+
};
|
|
86
|
+
} ? B : never;
|
|
87
|
+
/** The Property entries of a Class, own and inherited. */
|
|
88
|
+
export type EntriesOf<C> = ByKeyOf<C> extends infer B ? B[keyof B] : never;
|
|
89
|
+
export type NameOfEntry<P> = P extends {
|
|
90
|
+
readonly name: infer N extends string;
|
|
91
|
+
} ? N : never;
|
|
92
|
+
export type ValueOfEntry<P> = P extends {
|
|
93
|
+
readonly __value?: infer V;
|
|
94
|
+
} ? Exclude<V, undefined> : never;
|
|
95
|
+
export type RequiredEntry<P> = P extends {
|
|
96
|
+
readonly definition: {
|
|
97
|
+
readonly required: true;
|
|
98
|
+
};
|
|
99
|
+
} ? true : false;
|
|
100
|
+
type KeyOfEntry<P> = P extends {
|
|
101
|
+
readonly key: infer K extends string;
|
|
102
|
+
} ? K : never;
|
|
103
|
+
/** The name of the Class that declares a Property, from its key (distributive: no entry, no owner). */
|
|
104
|
+
type OwnerOfEntry<P> = P extends {
|
|
105
|
+
readonly key: `${string}:class.${infer O}.property.${string}`;
|
|
106
|
+
} ? O : never;
|
|
107
|
+
/** A name two members claim names neither: members a key-remapped type sends to one name reach its template as one union. */
|
|
108
|
+
export type Single<C, All = C> = C extends unknown ? [Exclude<All, C>] extends [never] ? true : false : never;
|
|
109
|
+
/** The Property entries of a Class by name: a name several entries claim maps to their union. */
|
|
110
|
+
type ByName<C> = {
|
|
111
|
+
readonly [P in EntriesOf<C> as NameOfEntry<P>]: P;
|
|
112
|
+
};
|
|
113
|
+
/** The entry a name keeps on the Class: the only one, or the Class's own among inherited duplicates. */
|
|
114
|
+
type FlatEntry<C, Es> = Single<Es> extends true ? Es : Extract<Es, {
|
|
115
|
+
readonly key: `${KeyOf<C>}.property.${string}`;
|
|
116
|
+
}> extends infer Own ? [Own] extends [never] ? never : Single<Own> extends true ? Own : never : never;
|
|
117
|
+
/**
|
|
118
|
+
* Where each Property of a Class goes on a row or a handle (F6): under its name; under `$prop` when
|
|
119
|
+
* the name is taken (`Taken`: the row keys, the handle's members or the Edge's roles); under `$`
|
|
120
|
+
* and its owner's name in lower camel case when it is an inherited duplicate its name does not
|
|
121
|
+
* keep, and under `$$` and that name when `$` and it is one of the SDK's keys.
|
|
122
|
+
*/
|
|
123
|
+
export interface Layout<Flat, Groups> {
|
|
124
|
+
readonly flat: Flat;
|
|
125
|
+
readonly groups: Groups;
|
|
126
|
+
}
|
|
127
|
+
type FlatOf<C, Taken> = ByName<C> extends infer Names ? {
|
|
128
|
+
readonly [N in keyof Names as N extends Taken ? never : [FlatEntry<C, Names[N]>] extends [never] ? never : N]: FlatEntry<C, Names[N]>;
|
|
129
|
+
} : never;
|
|
130
|
+
/** The entries the taken names keep: they go under `$prop`. */
|
|
131
|
+
type TakenOf<C, Taken> = ByName<C> extends infer Names ? {
|
|
132
|
+
readonly [N in keyof Names & Taken as [FlatEntry<C, Names[N]>] extends [never] ? never : N]: FlatEntry<C, Names[N]>;
|
|
133
|
+
} : never;
|
|
134
|
+
/** The inherited duplicates a name does not keep (`FlatEntry`). */
|
|
135
|
+
type Duplicates<C> = EntriesOf<C> extends infer P ? P extends unknown ? KeyOfEntry<P> extends KeyOfEntry<FlatEntry<C, ByName<C>[NameOfEntry<P> & keyof ByName<C>]>> ? never : P : never : never;
|
|
136
|
+
/**
|
|
137
|
+
* The keys the SDK writes on rows besides `id`, all named with `$`: `SDK_KEYS`, the one list. Frozen;
|
|
138
|
+
* an owner group named as one of them is escaped with one more `$`.
|
|
139
|
+
*/
|
|
140
|
+
export type SdkKeys = (typeof SDK_KEYS)[number];
|
|
141
|
+
/** The group of an owner's duplicates; an owner named `Class` groups under `$$class`. */
|
|
142
|
+
type OwnerGroup<O> = O extends string ? `$${Uncapitalize<O>}` extends SdkKeys ? `$$${Uncapitalize<O>}` : `$${Uncapitalize<O>}` : never;
|
|
143
|
+
/**
|
|
144
|
+
* The owner groups, and `$prop` when the taken names `T` keep any entry. Written inline: an alias
|
|
145
|
+
* for the `$prop` part costs about 8% more instantiations on the type budget's fixtures.
|
|
146
|
+
*/
|
|
147
|
+
type GroupsOf<C, T> = {
|
|
148
|
+
readonly [P in Duplicates<C> as OwnerGroup<OwnerOfEntry<P>>]: {
|
|
149
|
+
readonly [Q in P as NameOfEntry<Q>]: Q;
|
|
150
|
+
};
|
|
151
|
+
} & {
|
|
152
|
+
readonly [G in '$prop' as [keyof TakenOf<C, T>] extends [never] ? never : G]: TakenOf<C, T>;
|
|
153
|
+
};
|
|
154
|
+
export type LayoutOf<C, Taken> = Layout<FlatOf<C, Taken>, GroupsOf<C, Taken>>;
|
|
155
|
+
/** Every Property name of a Class, flat or grouped: a relation or a `.with` name avoids them. */
|
|
156
|
+
export type PropNamesOf<C> = keyof ByName<C>;
|
|
157
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed handles over a Domain (spec § Recipes: the read layer): what a recipe's `build` receives,
|
|
3
|
+
* and the reads it returns. Handles are interfaces with lazy members; the per-Class parts
|
|
4
|
+
* (Properties, named relations, rows) are mapped types computed once per Class key (D5).
|
|
5
|
+
*/
|
|
6
|
+
import type { NodeId } from '../../../platform/graph/node/index.js';
|
|
7
|
+
import type { NodePath } from '../../../platform/graph/path/index.js';
|
|
8
|
+
import type { KernelDomain } from '../../../platform/schema/kernel.js';
|
|
9
|
+
import type { SizedQuery } from '../language/query.js';
|
|
10
|
+
import type { Cond, Conditions, HandleMembers, IsCond, Ordering, PropOf, PropsOf, Unordered } from './conditions.js';
|
|
11
|
+
import type { Cls, Dom, KeyOf, LayoutOf, OriginOf, PropNamesOf, Satisfies, Single, Untyped, ValueOfEntry } from './domain.js';
|
|
12
|
+
import type { Far, RelationsOf, SourceKeys, SourceRole, TargetKeys, TargetRole, ViaCheck, ViaOptions } from './relations.js';
|
|
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 recipe runs, typed by its answer `T`. */
|
|
15
|
+
export interface Read<out T> {
|
|
16
|
+
readonly '~read': T;
|
|
17
|
+
}
|
|
18
|
+
/** A read of a relation, per parent row: what a `.with` takes. */
|
|
19
|
+
export interface RelationRead<out T> extends Read<T> {
|
|
20
|
+
readonly '~relation': true;
|
|
21
|
+
}
|
|
22
|
+
/** One page of a root: only as a recipe's single read (D22). */
|
|
23
|
+
export interface PageRead<out T> {
|
|
24
|
+
readonly '~page': T;
|
|
25
|
+
}
|
|
26
|
+
/** What a read answers: a page read answers one `Page`. */
|
|
27
|
+
export type ResultOf<R> = R extends Read<infer T> ? T : R extends PageRead<infer T> ? Page<T> : never;
|
|
28
|
+
/** Rows render values, or references (`.pick()`). */
|
|
29
|
+
export type Rendering = 'value' | 'reference';
|
|
30
|
+
/** The answers a `.with` adds to each row, by the names the author picks. */
|
|
31
|
+
type Withs = {
|
|
32
|
+
readonly [name: string]: Read<unknown>;
|
|
33
|
+
};
|
|
34
|
+
type Answers<X> = {
|
|
35
|
+
readonly [P in keyof X]: ResultOf<X[P]>;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* A `.with` name a row already carries, or a `.with` that reads another root, fails to compile
|
|
39
|
+
* at that name.
|
|
40
|
+
*/
|
|
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 recipe`;
|
|
43
|
+
};
|
|
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
|
+
/** The id of a Node, its path, or a Core node of the Domain. */
|
|
46
|
+
export type Target = NodeId | NodePath | CoreNode<string>;
|
|
47
|
+
/** A Core node of the Domain (`d.core.<node>`). */
|
|
48
|
+
export interface CoreNode<Key extends string> {
|
|
49
|
+
readonly '~core': Key;
|
|
50
|
+
}
|
|
51
|
+
interface IdProp {
|
|
52
|
+
eq(id: Target): Cond;
|
|
53
|
+
/** Any length. */
|
|
54
|
+
in(ids: readonly Target[]): Cond;
|
|
55
|
+
}
|
|
56
|
+
interface PathProp {
|
|
57
|
+
eq(path: NodePath): Cond;
|
|
58
|
+
in(paths: readonly NodePath[]): Cond;
|
|
59
|
+
}
|
|
60
|
+
/** A Class handle, matched by its phantom key alone. */
|
|
61
|
+
interface ClassHandle<K extends string> {
|
|
62
|
+
readonly '~class': K;
|
|
63
|
+
}
|
|
64
|
+
type IsCheck<S, K, X> = X extends unknown ? [Extract<Satisfies<S, X> | X, K>] extends [never] ? `✗ ${X & string} is not ${K & string} nor one of its subclasses: narrow to a subclass, or read both with .union` : unknown : never;
|
|
65
|
+
/** An Edge Class handle, matched by its phantom key alone. */
|
|
66
|
+
type AnyEdgeSet = {
|
|
67
|
+
readonly '~edge': string;
|
|
68
|
+
};
|
|
69
|
+
type EdgeKeyOf<X> = X extends {
|
|
70
|
+
readonly '~edge': infer E extends string;
|
|
71
|
+
} ? E : never;
|
|
72
|
+
type EdgeKeysOf<X> = X extends readonly (infer One)[] ? EdgeKeyOf<One> : EdgeKeyOf<X>;
|
|
73
|
+
/** What every Node handle offers besides its Properties and named relations. */
|
|
74
|
+
export interface NodeMethods<S, K extends string> {
|
|
75
|
+
readonly id: IdProp;
|
|
76
|
+
readonly path: PathProp;
|
|
77
|
+
/** The Node is a `cls`, or one of its subclasses: narrows the handle and the rows. */
|
|
78
|
+
is<X extends string>(cls: ClassHandle<X> & IsCheck<S, K, X>): IsCond<X>;
|
|
79
|
+
/** The Node is a `cls` and meets `conditions`, written on a handle narrowed to `cls`. */
|
|
80
|
+
is<X extends string>(cls: ClassHandle<X> & IsCheck<S, K, X>, conditions: (node: NodeHandle<S, X>) => Conditions): Cond;
|
|
81
|
+
isExactly<X extends string>(cls: ClassHandle<X> & IsCheck<S, K, X>): IsCond<X>;
|
|
82
|
+
/** The Edges of one Class (or several) from this Node; the far end's Classes come from the Edge. */
|
|
83
|
+
via<const X extends AnyEdgeSet | readonly [AnyEdgeSet, ...AnyEdgeSet[]], const O extends ViaOptions = {}>(edge: X & ViaCheck<S, K, EdgeKeysOf<X>, O>, options?: O): RelSet<S, Far<S, K, EdgeKeysOf<X>, O>, EdgeKeysOf<X>, {}, 'value', false>;
|
|
84
|
+
}
|
|
85
|
+
type IsUnion<K, All = K> = K extends unknown ? ([All] extends [K] ? false : true) : never;
|
|
86
|
+
type FlatOf<S, K> = LayoutOf<Cls<S, K>, HandleMembers>['flat'];
|
|
87
|
+
type EntryNamed<S, K, N> = K extends unknown ? FlatOf<S, K>[N & keyof FlatOf<S, K>] : never;
|
|
88
|
+
type KeyOfEntry<P> = P extends {
|
|
89
|
+
readonly key: infer Key extends string;
|
|
90
|
+
} ? Key : never;
|
|
91
|
+
/**
|
|
92
|
+
* The Properties a union's Classes share, by name. A name that maps to several Property keys
|
|
93
|
+
* filters but does not order (F7).
|
|
94
|
+
*/
|
|
95
|
+
type UnionProps<S, K> = {
|
|
96
|
+
readonly [N in keyof (K extends unknown ? FlatOf<S, K> : never)]: Single<KeyOfEntry<EntryNamed<S, K, N>>> extends true ? PropOf<ValueOfEntry<EntryNamed<S, K, N>>> : Unordered<PropOf<ValueOfEntry<EntryNamed<S, K, N>>>, `✗ "${N & string}" is a different Property on each Class of this union: order by a Property of one Class`>;
|
|
97
|
+
};
|
|
98
|
+
/** A Node handle in a callback: Properties, named to-one relations, and the methods above. */
|
|
99
|
+
export type NodeHandle<S, K extends string> = (true extends IsUnion<K> ? UnionProps<S, K> & (K extends unknown ? RelationsOf<S, K> : never) : PropsOf<Cls<S, K>> & RelationsOf<S, K>) & NodeMethods<S, K>;
|
|
100
|
+
/** An Edge handle in a `(node, edge) =>` callback: its Properties. */
|
|
101
|
+
export type EdgeHandle<S, E extends string> = E extends unknown ? PropsOf<Cls<S, E>, never> : never;
|
|
102
|
+
/** The Classes of the `is` conditions among `C`. */
|
|
103
|
+
type IsOf<C> = C extends IsCond<infer X> ? X : never;
|
|
104
|
+
/** Those of an entry that is always an `is`: a falsy value `where` skips may replace any other. */
|
|
105
|
+
type SureOf<C> = [C] extends [IsCond<string>] ? IsOf<C> : never;
|
|
106
|
+
/** A list narrows to its `is` Classes, and keeps `K` too if a skipped entry may leave none. */
|
|
107
|
+
type Narrowed<K, Any, Sure> = [Any] extends [never] ? K : [Sure] extends [never] ? K | Any : Any;
|
|
108
|
+
/** The Classes a `where` narrows to (S3), for each list it may return. */
|
|
109
|
+
type Narrow<K, R> = R extends readonly unknown[] ? Narrowed<K, IsOf<R[number]>, {
|
|
110
|
+
readonly [I in keyof R]: SureOf<R[I]>;
|
|
111
|
+
}[number]> : Narrowed<K, IsOf<R>, SureOf<R>>;
|
|
112
|
+
/** The Nodes of a Class (or a union of Classes) at the root of a read. */
|
|
113
|
+
export interface NodeSet<S, K extends string, W, M extends Rendering, H extends boolean> {
|
|
114
|
+
readonly '~class': K;
|
|
115
|
+
where<const R extends Conditions>(conditions: (node: NodeHandle<S, K>) => R): NodeSet<S, Narrow<K, R>, W, M, H>;
|
|
116
|
+
orderBy(keys: (node: NodeHandle<S, K>) => Ordering): NodeSet<S, K, W, M, H>;
|
|
117
|
+
/** Rows gain each relation's answer under the name given. */
|
|
118
|
+
with<const X extends Withs>(relations: (node: NodeHandle<S, K>) => X & WithCheck<S, K, W, X>): NodeSet<S, K, W & Answers<X>, M, H>;
|
|
119
|
+
/** Rows of references: `{ id, $class }`. */
|
|
120
|
+
pick(): NodeSet<S, K, W, 'reference', H>;
|
|
121
|
+
/** Rows the reader may not read stay, as `{ id, $class, $withheld }`. */
|
|
122
|
+
includeWithheld(): NodeSet<S, K, W, M, true>;
|
|
123
|
+
union<K2 extends string>(other: ClassHandle<K2>): NodeSet<S, K | K2, W, M, H>;
|
|
124
|
+
/**
|
|
125
|
+
* Exactly one; none is `NOT_FOUND`, a second is `INTEGRITY`, one the reader may not read
|
|
126
|
+
* `NOT_READABLE`.
|
|
127
|
+
*/
|
|
128
|
+
get(id?: Target): Read<RowOf<S, K, W, M, false>>;
|
|
129
|
+
/** Zero or one; a second is `INTEGRITY`, one the reader may not read `NOT_READABLE`. */
|
|
130
|
+
find(id?: Target): Read<RowOf<S, K, W, M, false> | undefined>;
|
|
131
|
+
first(): Read<RowOf<S, K, W, M, H> | undefined>;
|
|
132
|
+
first(n: number): Read<readonly RowOf<S, K, W, M, H>[]>;
|
|
133
|
+
/** Reads n + 1 rows to say whether more exist. */
|
|
134
|
+
first(n: number, options: {
|
|
135
|
+
readonly more: true;
|
|
136
|
+
}): Read<{
|
|
137
|
+
readonly rows: readonly RowOf<S, K, W, M, H>[];
|
|
138
|
+
readonly more: boolean;
|
|
139
|
+
}>;
|
|
140
|
+
/** Only as a recipe's single read: the call sets the size, up to `max`, and continues it. */
|
|
141
|
+
page(options: {
|
|
142
|
+
readonly max: number;
|
|
143
|
+
}): PageRead<RowOf<S, K, W, M, H>>;
|
|
144
|
+
/** Every row; past `max`, `TOO_MANY`. */
|
|
145
|
+
all(options: {
|
|
146
|
+
readonly max: number;
|
|
147
|
+
}): Read<readonly RowOf<S, K, W, M, H>[]>;
|
|
148
|
+
exists(id?: Target): Read<boolean>;
|
|
149
|
+
count(options: {
|
|
150
|
+
readonly upTo: number;
|
|
151
|
+
}): Read<Count>;
|
|
152
|
+
}
|
|
153
|
+
/** A relation from a Node: the Nodes at the far end of its Edges. */
|
|
154
|
+
export interface RelSet<S, K extends string, E extends string, W, M extends Rendering, H extends boolean> {
|
|
155
|
+
/** Its far Classes and Edges: a relation is not a Class handle, so `is` and `union` refuse it. */
|
|
156
|
+
readonly '~via': readonly [K, E];
|
|
157
|
+
where<const R extends Conditions>(conditions: (node: NodeHandle<S, K>, edge: EdgeHandle<S, E>) => R): RelSet<S, Narrow<K, R>, E, W, M, H>;
|
|
158
|
+
orderBy(keys: (node: NodeHandle<S, K>, edge: EdgeHandle<S, E>) => Ordering): RelSet<S, K, E, W, M, H>;
|
|
159
|
+
with<const X extends Withs>(relations: (node: NodeHandle<S, K>) => X & WithCheck<S, K, W, X>): RelSet<S, K, E, W & Answers<X>, M, H>;
|
|
160
|
+
/** Each row gains `$edge`: the Edge's Class and Properties. */
|
|
161
|
+
withEdge(): RelSet<S, K, E, W & {
|
|
162
|
+
readonly $edge: EdgeValues<S, E>;
|
|
163
|
+
}, M, H>;
|
|
164
|
+
pick(): RelSet<S, K, E, W, 'reference', H>;
|
|
165
|
+
includeWithheld(): RelSet<S, K, E, W, M, true>;
|
|
166
|
+
distinct(): RelSet<S, K, E, W, M, H>;
|
|
167
|
+
/**
|
|
168
|
+
* Exactly one per parent; none or a second is `INTEGRITY`, naming the relation; one the reader
|
|
169
|
+
* may not read is `NOT_READABLE`.
|
|
170
|
+
*/
|
|
171
|
+
get(): RelationRead<RowOf<S, K, W, M, false>>;
|
|
172
|
+
find(): RelationRead<RowOf<S, K, W, M, false> | undefined>;
|
|
173
|
+
first(): RelationRead<RowOf<S, K, W, M, H> | undefined>;
|
|
174
|
+
first(n: number): RelationRead<readonly RowOf<S, K, W, M, H>[]>;
|
|
175
|
+
all(options: {
|
|
176
|
+
readonly max: number;
|
|
177
|
+
}): RelationRead<readonly RowOf<S, K, W, M, H>[]>;
|
|
178
|
+
count(options: {
|
|
179
|
+
readonly upTo: number;
|
|
180
|
+
}): RelationRead<Count>;
|
|
181
|
+
/** A boolean per parent in a `.with`; a condition in a `where`. */
|
|
182
|
+
exists(): RelationRead<boolean> & Cond;
|
|
183
|
+
/** The relation reaches this Node. */
|
|
184
|
+
is(target: Target): Cond;
|
|
185
|
+
some(conditions?: (node: NodeHandle<S, K>, edge: EdgeHandle<S, E>) => Conditions): Cond;
|
|
186
|
+
every(conditions: (node: NodeHandle<S, K>, edge: EdgeHandle<S, E>) => Conditions): Cond;
|
|
187
|
+
none(conditions?: (node: NodeHandle<S, K>, edge: EdgeHandle<S, E>) => Conditions): Cond;
|
|
188
|
+
atLeast(n: number, conditions?: (node: NodeHandle<S, K>, edge: EdgeHandle<S, E>) => Conditions): Cond;
|
|
189
|
+
atMost(n: number, conditions?: (node: NodeHandle<S, K>, edge: EdgeHandle<S, E>) => Conditions): Cond;
|
|
190
|
+
exactly(n: number, conditions?: (node: NodeHandle<S, K>, edge: EdgeHandle<S, E>) => Conditions): Cond;
|
|
191
|
+
}
|
|
192
|
+
/** An Edge handle at the root: its Properties, and both ends by role. */
|
|
193
|
+
export type EdgeRootHandle<S, E extends string> = E extends unknown ? PropsOf<Cls<S, E>, SourceRole<S, E> | TargetRole<S, E>> & {
|
|
194
|
+
readonly [R in SourceRole<S, E>]: NodeHandle<S, SourceKeys<S, E>>;
|
|
195
|
+
} & {
|
|
196
|
+
readonly [R in TargetRole<S, E>]: NodeHandle<S, TargetKeys<S, E>>;
|
|
197
|
+
} : never;
|
|
198
|
+
type EdgeRowOf<S, E, M extends Rendering, H extends boolean> = (M extends 'reference' ? EdgeRootRef<S, E> : EdgeRootRow<S, E>) | (H extends true ? WithheldEdgeRow<S, E> : never);
|
|
199
|
+
/** The Edges of a Class at the root of a read. */
|
|
200
|
+
export interface EdgeSet<S, E extends string, M extends Rendering, H extends boolean> {
|
|
201
|
+
readonly '~edge': E;
|
|
202
|
+
where(conditions: (edge: EdgeRootHandle<S, E>) => Conditions): EdgeSet<S, E, M, H>;
|
|
203
|
+
orderBy(keys: (edge: EdgeRootHandle<S, E>) => Ordering): EdgeSet<S, E, M, H>;
|
|
204
|
+
/** Rows of `{ $class, $source, $target }`, with both ends as references. */
|
|
205
|
+
pick(): EdgeSet<S, E, 'reference', H>;
|
|
206
|
+
includeWithheld(): EdgeSet<S, E, M, true>;
|
|
207
|
+
get(): Read<EdgeRowOf<S, E, M, false>>;
|
|
208
|
+
find(): Read<EdgeRowOf<S, E, M, false> | undefined>;
|
|
209
|
+
first(): Read<EdgeRowOf<S, E, M, H> | undefined>;
|
|
210
|
+
first(n: number): Read<readonly EdgeRowOf<S, E, M, H>[]>;
|
|
211
|
+
page(options: {
|
|
212
|
+
readonly max: number;
|
|
213
|
+
}): PageRead<EdgeRowOf<S, E, M, H>>;
|
|
214
|
+
all(options: {
|
|
215
|
+
readonly max: number;
|
|
216
|
+
}): Read<readonly EdgeRowOf<S, E, M, H>[]>;
|
|
217
|
+
exists(): Read<boolean>;
|
|
218
|
+
count(options: {
|
|
219
|
+
readonly upTo: number;
|
|
220
|
+
}): Read<Count>;
|
|
221
|
+
}
|
|
222
|
+
type HandleOf<S, C> = C extends {
|
|
223
|
+
readonly kind: 'edge';
|
|
224
|
+
readonly key: infer K extends string;
|
|
225
|
+
} ? EdgeSet<S, K, 'value', false> : C extends {
|
|
226
|
+
readonly key: infer K extends string;
|
|
227
|
+
} ? NodeSet<S, K, {}, 'value', false> : never;
|
|
228
|
+
/** The names `d` owns: a Class or an alias of the same name has no handle. */
|
|
229
|
+
type Fixed = 'kernel' | 'core' | 'origin' | 'document';
|
|
230
|
+
type ClassHandles<S, Classes> = {
|
|
231
|
+
readonly [N in keyof Classes as N extends Fixed ? never : Untyped<Classes[N]> extends true ? never : N]: HandleOf<S, Classes[N]>;
|
|
232
|
+
};
|
|
233
|
+
type CoreHandles<Core> = Core extends {
|
|
234
|
+
readonly nodes: infer Nodes;
|
|
235
|
+
} ? {
|
|
236
|
+
readonly [N in keyof Nodes]: CoreNode<KeyOf<Nodes[N]>>;
|
|
237
|
+
} : never;
|
|
238
|
+
/** The escape hatch: one canonical document, its rows typed `unknown` (D23). */
|
|
239
|
+
interface DocumentRead<S> {
|
|
240
|
+
document(query: Extract<SizedQuery<S>, {
|
|
241
|
+
readonly list: unknown;
|
|
242
|
+
}>): Read<readonly unknown[]>;
|
|
243
|
+
document(query: Extract<SizedQuery<S>, {
|
|
244
|
+
readonly exists: unknown;
|
|
245
|
+
}>): Read<boolean>;
|
|
246
|
+
document(query: Extract<SizedQuery<S>, {
|
|
247
|
+
readonly count: unknown;
|
|
248
|
+
}>): Read<Count>;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* The handles a recipe's `build` receives (S1): the Domain's own Classes, each dependency under
|
|
252
|
+
* its alias, the Kernel's Classes under `d.kernel`, the Domain's Core nodes under `d.core`, and
|
|
253
|
+
* `d.origin`. A Class the Domain neither declares nor depends on has no handle.
|
|
254
|
+
*/
|
|
255
|
+
export type Handles<S> = Dom<S> extends {
|
|
256
|
+
readonly classes: infer Own;
|
|
257
|
+
readonly dependencies: infer Deps;
|
|
258
|
+
readonly core: infer Core;
|
|
259
|
+
} ? ClassHandles<S, Own> & {
|
|
260
|
+
readonly [A in keyof Deps as A extends Fixed ? never : A]: Deps[A] extends {
|
|
261
|
+
readonly classes: infer C;
|
|
262
|
+
} ? ClassHandles<S, C> : never;
|
|
263
|
+
} & {
|
|
264
|
+
readonly kernel: ClassHandles<S, KernelDomain['classes']>;
|
|
265
|
+
readonly core: CoreHandles<Core>;
|
|
266
|
+
readonly origin: OriginOf<S>;
|
|
267
|
+
} & DocumentRead<S> : never;
|
|
268
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { AnyResolvedClass, Domain } from '../../../platform/schema/index.js';
|
|
2
|
+
/** The key of the graph's root Class, which every Node Class satisfies. */
|
|
3
|
+
export declare const NODE_ROOT = "kernel.astrale.ai:class.Node";
|
|
4
|
+
/**
|
|
5
|
+
* Names a Node handle owns (`HandleMembers`): a Property of the same name goes under `$prop`. The
|
|
6
|
+
* list is frozen, as `SDK_KEYS` is, so no SDK release moves a Property or an owner group.
|
|
7
|
+
*/
|
|
8
|
+
export declare const HANDLE_MEMBERS: ReadonlySet<string>;
|
|
9
|
+
/** The group of the Properties whose name a handle member, a row key or an Edge role takes. */
|
|
10
|
+
export declare const PROP_GROUP = "$prop";
|
|
11
|
+
/**
|
|
12
|
+
* The keys the SDK writes on rows besides `id` (`SdkKeys`), all named with `$`: `$class`, `$edge`
|
|
13
|
+
* on a row read `.withEdge()`, `$source` and `$target` on an Edge root's row, `$withheld` on a row
|
|
14
|
+
* the reader may not read, and the `$prop` group. Frozen; an owner group named as one of them
|
|
15
|
+
* goes under `$` and that name (`ownerGroup`).
|
|
16
|
+
*/
|
|
17
|
+
export declare const SDK_KEYS: readonly ['$class', '$edge', '$source', '$target', '$withheld', "$prop"];
|
|
18
|
+
/**
|
|
19
|
+
* Names a row owns (`RowKeys`): `id` and the SDK's keys. A Property named `id` goes under `$prop`;
|
|
20
|
+
* no Property name starts with `$`. Frozen as `HANDLE_MEMBERS` is.
|
|
21
|
+
*/
|
|
22
|
+
export declare const ROW_KEYS: ReadonlySet<string>;
|
|
23
|
+
export type Direction = 'outgoing' | 'incoming' | 'incident';
|
|
24
|
+
/** One end of an Edge Class: its role, the Class keys it accepts and how many Edges it holds. */
|
|
25
|
+
export interface End {
|
|
26
|
+
readonly role: string;
|
|
27
|
+
readonly accepts: readonly string[];
|
|
28
|
+
readonly count: string;
|
|
29
|
+
}
|
|
30
|
+
/** An Edge's two ends; an undirected Edge's are its two incident ends, in declared order. */
|
|
31
|
+
export interface Ends {
|
|
32
|
+
readonly source: End;
|
|
33
|
+
readonly target: End;
|
|
34
|
+
}
|
|
35
|
+
/** A named to-one relation of a Class (S2). */
|
|
36
|
+
export interface Relation {
|
|
37
|
+
readonly name: string;
|
|
38
|
+
readonly edge: AnyResolvedClass;
|
|
39
|
+
readonly direction: Direction;
|
|
40
|
+
readonly far: readonly AnyResolvedClass[];
|
|
41
|
+
}
|
|
42
|
+
/** A name several ends claim: it names no relation, and reading it says to use `.via`. */
|
|
43
|
+
export interface Ambiguous {
|
|
44
|
+
readonly name: string;
|
|
45
|
+
readonly ambiguous: true;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Where each Property of a Class goes on a row or a handle (F6), by Property key: under its name
|
|
49
|
+
* (`flat`), or in a group (`groups`): `$prop` when its name is taken, `$` and its owner's name in
|
|
50
|
+
* lower camel case when it is an inherited duplicate its name does not keep, and `$$` and that
|
|
51
|
+
* name when `$` and it is one of the SDK's keys.
|
|
52
|
+
*/
|
|
53
|
+
export interface Layout {
|
|
54
|
+
readonly flat: ReadonlyMap<string, string>;
|
|
55
|
+
readonly groups: ReadonlyMap<string, ReadonlyMap<string, string>>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The Kernel's Classes, realized once from its compiled Schema reduced to them: a Worker reaches
|
|
59
|
+
* them without the Kernel's builder or its Functions' value programs.
|
|
60
|
+
*/
|
|
61
|
+
export declare function kernelClasses(): Readonly<Record<string, AnyResolvedClass>>;
|
|
62
|
+
/** The Class model of one resolved Domain. */
|
|
63
|
+
export declare class Model {
|
|
64
|
+
#private;
|
|
65
|
+
readonly origin: string;
|
|
66
|
+
constructor(domain: Domain);
|
|
67
|
+
/** One Class of the model, by key. */
|
|
68
|
+
classOf(key: string): AnyResolvedClass;
|
|
69
|
+
/** The keys a Class satisfies: its own and its parents', transitively, and the graph root. */
|
|
70
|
+
satisfies(c: AnyResolvedClass): ReadonlySet<string>;
|
|
71
|
+
/** Both ends of an Edge Class. */
|
|
72
|
+
ends(edge: AnyResolvedClass): Ends;
|
|
73
|
+
/** The Classes an end accepts that the Domain can name. */
|
|
74
|
+
far(end: End): readonly AnyResolvedClass[];
|
|
75
|
+
/** Whether an end accepts one of `classes`, or one of their parents. */
|
|
76
|
+
touches(classes: readonly AnyResolvedClass[], end: End): boolean;
|
|
77
|
+
/** The Classes a traversal of `edges` in `direction` reaches. */
|
|
78
|
+
reached(edges: readonly AnyResolvedClass[], direction: Direction): readonly AnyResolvedClass[];
|
|
79
|
+
/** Every Property name of a Class, flat or grouped: a relation or a `.with` name avoids them. */
|
|
80
|
+
propertyNames(c: AnyResolvedClass): ReadonlySet<string>;
|
|
81
|
+
/**
|
|
82
|
+
* The named to-one relations of a Class (S2): one per to-one end that accepts the Class or a
|
|
83
|
+
* parent, named by the far end's role when that end accepts specific Classes. The Domain's own
|
|
84
|
+
* relations shadow its dependencies'; a name that clashes with a Property or a handle member
|
|
85
|
+
* names nothing, and a name several ends claim is ambiguous.
|
|
86
|
+
*/
|
|
87
|
+
relations(c: AnyResolvedClass): ReadonlyMap<string, Relation | Ambiguous>;
|
|
88
|
+
/**
|
|
89
|
+
* Where each Property of a Class goes when `taken` names are a row's or a handle's (F6). A name
|
|
90
|
+
* keeps its only Property, or the Class's own among inherited duplicates: flat, or under
|
|
91
|
+
* `$prop` when the name is taken. Each duplicate it does not keep goes under its owner.
|
|
92
|
+
*/
|
|
93
|
+
layout(c: AnyResolvedClass, taken: ReadonlySet<string>): Layout;
|
|
94
|
+
}
|
|
95
|
+
/** The Class model of a resolved Domain, built once. */
|
|
96
|
+
export declare function modelOf(domain: Domain): Model;
|