@astrale-os/sdk 0.6.0-beta.49 → 0.6.0-beta.50
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.
|
@@ -25,7 +25,7 @@ export interface PageRead<out T> {
|
|
|
25
25
|
}
|
|
26
26
|
/** What a read answers: a page read answers one `Page`. */
|
|
27
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 (`.
|
|
28
|
+
/** Rows render values, or references (`.ref()`). */
|
|
29
29
|
export type Rendering = 'value' | 'reference';
|
|
30
30
|
/** The answers a `.with` adds to each row, by the names the author picks. */
|
|
31
31
|
type Withs = {
|
|
@@ -119,7 +119,7 @@ export interface NodeSet<S, K extends string, W, M extends Rendering, H extends
|
|
|
119
119
|
/** Rows gain each relation's answer under the name given. */
|
|
120
120
|
with<const X extends Withs>(relations: (node: NodeHandle<S, K>) => X & WithCheck<S, K, W, X>): NodeSet<S, K, W & Answers<X>, M, H>;
|
|
121
121
|
/** Rows of references: `{ id, $class }`. */
|
|
122
|
-
|
|
122
|
+
ref(): NodeSet<S, K, W, 'reference', H>;
|
|
123
123
|
/** Rows the reader may not read stay, as `{ id, $class, $withheld }`. */
|
|
124
124
|
includeWithheld(): NodeSet<S, K, W, M, true>;
|
|
125
125
|
union<K2 extends string>(other: ClassHandle<K2>): NodeSet<S, K | K2, W, M, H>;
|
|
@@ -163,7 +163,8 @@ export interface RelSet<S, K extends string, E extends string, W, M extends Rend
|
|
|
163
163
|
withEdge(): RelSet<S, K, E, W & {
|
|
164
164
|
readonly $edge: EdgeValues<S, E>;
|
|
165
165
|
}, M, H>;
|
|
166
|
-
|
|
166
|
+
/** Rows of references: `{ id, $class }`. */
|
|
167
|
+
ref(): RelSet<S, K, E, W, 'reference', H>;
|
|
167
168
|
includeWithheld(): RelSet<S, K, E, W, M, true>;
|
|
168
169
|
distinct(): RelSet<S, K, E, W, M, H>;
|
|
169
170
|
/**
|
|
@@ -204,7 +205,7 @@ export interface EdgeSet<S, E extends string, M extends Rendering, H extends boo
|
|
|
204
205
|
where(conditions: (edge: EdgeRootHandle<S, E>) => Conditions): EdgeSet<S, E, M, H>;
|
|
205
206
|
orderBy(keys: (edge: EdgeRootHandle<S, E>) => Ordering): EdgeSet<S, E, M, H>;
|
|
206
207
|
/** Rows of `{ $class, $source, $target }`, with both ends as references. */
|
|
207
|
-
|
|
208
|
+
ref(): EdgeSet<S, E, 'reference', H>;
|
|
208
209
|
includeWithheld(): EdgeSet<S, E, M, true>;
|
|
209
210
|
get(): Read<EdgeRowOf<S, E, M, false>>;
|
|
210
211
|
find(): Read<EdgeRowOf<S, E, M, false> | undefined>;
|
|
@@ -16,7 +16,7 @@ export declare function handleClass(value: unknown): AnyResolvedClass | undefine
|
|
|
16
16
|
/**
|
|
17
17
|
* A guard's range (S7), the roots of a Class handle after `where`, `union` and `orderBy`, as a
|
|
18
18
|
* read: of whether one exists, or, `ordered`, of them in their order. `undefined` for a value that
|
|
19
|
-
* is no set of roots; a set whose rows render (`with`, `
|
|
19
|
+
* is no set of roots; a set whose rows render (`with`, `ref`, `includeWithheld`) is refused.
|
|
20
20
|
*/
|
|
21
21
|
export declare function rangeRead(value: unknown, ordered: boolean): RootRead | undefined;
|
|
22
22
|
/** A Node handle: its Properties, its named to-one relations, and the methods every Node has. */
|
|
@@ -35,7 +35,7 @@ export declare class Relation {
|
|
|
35
35
|
orderBy(keys: unknown): Relation;
|
|
36
36
|
with(relations: unknown): Relation;
|
|
37
37
|
withEdge(): Relation;
|
|
38
|
-
|
|
38
|
+
ref(): Relation;
|
|
39
39
|
includeWithheld(): Relation;
|
|
40
40
|
distinct(): Relation;
|
|
41
41
|
/** Exactly one per parent: two rows, to see a second. */
|
|
@@ -70,7 +70,7 @@ export declare class NodeSet {
|
|
|
70
70
|
where(conditions: unknown): NodeSet;
|
|
71
71
|
orderBy(keys: unknown): NodeSet;
|
|
72
72
|
with(relations: unknown): NodeSet;
|
|
73
|
-
|
|
73
|
+
ref(): NodeSet;
|
|
74
74
|
includeWithheld(): NodeSet;
|
|
75
75
|
union(other: unknown): NodeSet;
|
|
76
76
|
/** Exactly one: two rows, to see a second. */
|
|
@@ -93,7 +93,7 @@ export declare class EdgeSet {
|
|
|
93
93
|
static range(set: EdgeSet, ordered: boolean): RootRead;
|
|
94
94
|
where(conditions: unknown): EdgeSet;
|
|
95
95
|
orderBy(keys: unknown): EdgeSet;
|
|
96
|
-
|
|
96
|
+
ref(): EdgeSet;
|
|
97
97
|
includeWithheld(): EdgeSet;
|
|
98
98
|
get(): RootRead;
|
|
99
99
|
find(): RootRead;
|
|
@@ -126,7 +126,7 @@ export function handleClass(value) {
|
|
|
126
126
|
/**
|
|
127
127
|
* A guard's range (S7), the roots of a Class handle after `where`, `union` and `orderBy`, as a
|
|
128
128
|
* read: of whether one exists, or, `ordered`, of them in their order. `undefined` for a value that
|
|
129
|
-
* is no set of roots; a set whose rows render (`with`, `
|
|
129
|
+
* is no set of roots; a set whose rows render (`with`, `ref`, `includeWithheld`) is refused.
|
|
130
130
|
*/
|
|
131
131
|
export function rangeRead(value, ordered) {
|
|
132
132
|
if (value instanceof NodeSet)
|
|
@@ -136,7 +136,7 @@ export function rangeRead(value, ordered) {
|
|
|
136
136
|
return undefined;
|
|
137
137
|
}
|
|
138
138
|
function renderedRange() {
|
|
139
|
-
throw new TypeError("A guard reads its range's roots alone: `.with`, `.
|
|
139
|
+
throw new TypeError("A guard reads its range's roots alone: `.with`, `.ref` and `.includeWithheld` render rows, which a guard never reads.");
|
|
140
140
|
}
|
|
141
141
|
const DIRECTIONS = new Set(['outgoing', 'incoming', 'incident']);
|
|
142
142
|
/** The direction from `classes` along `edge`, written or derived from the end that accepts them. */
|
|
@@ -435,7 +435,7 @@ export class Relation {
|
|
|
435
435
|
throw new TypeError(DISTINCT_EDGE);
|
|
436
436
|
return this.#next({ selectEdge: true });
|
|
437
437
|
}
|
|
438
|
-
|
|
438
|
+
ref() {
|
|
439
439
|
return this.#next({ select: 'reference' });
|
|
440
440
|
}
|
|
441
441
|
includeWithheld() {
|
|
@@ -662,7 +662,7 @@ export class NodeSet {
|
|
|
662
662
|
with: [...this.#s.with, ...withsOf(value, handleScope, taken, this.#s.with)],
|
|
663
663
|
});
|
|
664
664
|
}
|
|
665
|
-
|
|
665
|
+
ref() {
|
|
666
666
|
return this.#next({ select: 'reference' });
|
|
667
667
|
}
|
|
668
668
|
includeWithheld() {
|
|
@@ -877,7 +877,7 @@ export class EdgeSet {
|
|
|
877
877
|
throw new TypeError(`An undirected Edge's ends have no order: ${this.#s.edge.key} orders by its own Properties, not by its ${ends[role].role}'s.`);
|
|
878
878
|
return this.#next({ orderBy: [...this.#s.orderBy, ...listed] });
|
|
879
879
|
}
|
|
880
|
-
|
|
880
|
+
ref() {
|
|
881
881
|
return this.#next({ select: 'reference' });
|
|
882
882
|
}
|
|
883
883
|
includeWithheld() {
|
|
@@ -26,7 +26,7 @@ export type Row<S, K> = K extends unknown ? {
|
|
|
26
26
|
readonly id: NodeId;
|
|
27
27
|
readonly $class: ClassOf<S, K>;
|
|
28
28
|
} & ValuesOf<S, K, RowKeys> : never;
|
|
29
|
-
/** A reference row (`.
|
|
29
|
+
/** A reference row (`.ref()`): `id` and `$class`. */
|
|
30
30
|
export type Ref<S, K> = K extends unknown ? {
|
|
31
31
|
readonly id: NodeId;
|
|
32
32
|
readonly $class: ClassOf<S, K>;
|
|
@@ -59,7 +59,7 @@ export type EdgeRootRow<S, E> = E extends unknown ? EdgeIdentity<ClassOf<S, E>>
|
|
|
59
59
|
} & {
|
|
60
60
|
readonly [R in TargetRole<S, E>]: Row<S, TargetKeys<S, E>>;
|
|
61
61
|
} : never;
|
|
62
|
-
/** An Edge reference row at the root (`.
|
|
62
|
+
/** An Edge reference row at the root (`.ref()`): both ends as references. */
|
|
63
63
|
export type EdgeRootRef<S, E> = E extends unknown ? EdgeIdentity<ClassOf<S, E>> & {
|
|
64
64
|
readonly [R in SourceRole<S, E>]: Ref<S, SourceKeys<S, E>>;
|
|
65
65
|
} & {
|
package/docs/queries.md
CHANGED
|
@@ -94,7 +94,7 @@ relations with `with`, and ends with the verb that says how much it reads:
|
|
|
94
94
|
`get` asserts that the row exists, so it reads the ids the Domain itself holds; for an id a caller
|
|
95
95
|
sends, use `find` and raise a declared error from `output` (see [Errors](#errors)).
|
|
96
96
|
|
|
97
|
-
`id` is a `NodeId`, a `NodePath` or a Core node. `.
|
|
97
|
+
`id` is a `NodeId`, a `NodePath` or a Core node. `.ref()` renders rows as references,
|
|
98
98
|
`{ id, $class }`. `.includeWithheld()` keeps the rows the reader may not read in a list, as
|
|
99
99
|
`{ id, $class, $withheld }` naming the values withheld. `get` and `find` raise `NOT_READABLE` on
|
|
100
100
|
such a row, since it exists. `d.A.union(d.B)` reads the Nodes of both Classes.
|
|
@@ -158,7 +158,7 @@ Class, or when the Edges listed leave it in different directions.
|
|
|
158
158
|
|
|
159
159
|
A relation reads with the root verbs, per parent row: `get`, `find`, `first`, `all`, `count` and
|
|
160
160
|
`exists`. A relation's `get` that finds none, or a second row, raises `INTEGRITY` naming the
|
|
161
|
-
relation. A relation also takes `where`, `orderBy`, `with`, `
|
|
161
|
+
relation. A relation also takes `where`, `orderBy`, `with`, `ref`, `includeWithheld`, `distinct`
|
|
162
162
|
and `withEdge()`, which adds the Edge's Class and Properties to each row under `$edge`.
|
|
163
163
|
|
|
164
164
|
`.with((a) => ({ name: read }))` adds each relation's answer to the row under the name given. A
|
|
@@ -433,7 +433,7 @@ A Mutation guards its write on a range: a Class handle after `where`, `union` an
|
|
|
433
433
|
canonical v7 Query. `mutation.expect.none(range)`, `expect.exists(range)`,
|
|
434
434
|
`expect.count(range, n | { atLeast?, atMost? })` or `expect.unchanged(range, ids)`. The Kernel
|
|
435
435
|
decides the guard with the Mutation, on the range's Classes and `where`, and for `unchanged` its
|
|
436
|
-
`orderBy`. A read (`first`, `exists`, `count`…) and a rendered set (`with`, `
|
|
436
|
+
`orderBy`. A read (`first`, `exists`, `count`…) and a rendered set (`with`, `ref`) are refused:
|
|
437
437
|
their verb, size or rendering would not reach the guard. Each verb takes `{ name }` last, and a
|
|
438
438
|
refusal carries the failed precondition's name as `failure.precondition`.
|
|
439
439
|
|