@astrale-os/kernel-client 1.0.0-beta.25 → 1.0.0-beta.26

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.
@@ -43,7 +43,7 @@ export interface QueryItem {
43
43
  }>>>;
44
44
  }
45
45
  /**
46
- * What a Query answers, by the family of its root fold: a list's Page, the table of the facts it
46
+ * What a Query answers, by its family: a list's Page, the table of the facts it
47
47
  * renders as values, the revision it was read at and whether its cursor came from another (W6);
48
48
  * an `exists`; or a `count`.
49
49
  */
@@ -57,7 +57,7 @@ export type QueryAnswer = {
57
57
  } | Exclude<Answer, {
58
58
  readonly list: unknown;
59
59
  }>;
60
- /** The answer of the family a Query's root fold names. */
60
+ /** The answer of the family a Query names: `list`, `exists` or `count`. */
61
61
  export type QueryAnswerFor<Query extends wire.Document> = Query extends {
62
62
  readonly list: unknown;
63
63
  } ? Extract<QueryAnswer, {
@@ -94,7 +94,7 @@ function invalid(what, detail, cause) {
94
94
  const subject = what === 'query' ? 'Graph query' : 'Graph query paging';
95
95
  throw new TypeError(`${subject} is invalid: ${detail}.`, { cause });
96
96
  }
97
- /** The family a Query's root fold names; undefined unless it names exactly one. */
97
+ /** The family a Query names (`list`, `exists` or `count`); undefined unless it names one. */
98
98
  function familyOf(query) {
99
99
  const families = ['list', 'exists', 'count'].filter((family) => family in query);
100
100
  return families.length === 1 ? families[0] : undefined;
@@ -23,7 +23,7 @@ async function refusals() {
23
23
  await graph.query(ast);
24
24
  // @ts-expect-error A Query names the v7 version.
25
25
  await graph.query({ query: 'astrale.query/6', list: { nodes: [Task] } });
26
- // @ts-expect-error A Query's root fold is list, exists or count.
26
+ // @ts-expect-error A Query is a list, an exists or a count.
27
27
  await graph.query({ query: QUERY, nodes: [Task] });
28
28
  // @ts-expect-error A count needs its bound.
29
29
  await graph.query({ query: QUERY, count: { nodes: [Task] } });
@@ -0,0 +1,31 @@
1
+ /** The Kernel `View` Class. */
2
+ export declare const VIEW_CLASS: Readonly<{
3
+ origin: 'kernel.astrale.ai';
4
+ kind: 'class';
5
+ name: "View";
6
+ }>;
7
+ /** The Kernel `of_domain` Edge Class, which only projection writes. */
8
+ export declare const OF_DOMAIN_CLASS: Readonly<{
9
+ origin: 'kernel.astrale.ai';
10
+ kind: 'class';
11
+ name: "of_domain";
12
+ }>;
13
+ /** The Kernel `Domain` Class. */
14
+ export declare const DOMAIN_CLASS: Readonly<{
15
+ origin: 'kernel.astrale.ai';
16
+ kind: 'class';
17
+ name: "Domain";
18
+ }>;
19
+ export declare const VIEW: "kernel.astrale.ai:class.View";
20
+ export declare const OF_DOMAIN: "kernel.astrale.ai:class.of_domain";
21
+ export declare const DOMAIN: "kernel.astrale.ai:class.Domain";
22
+ /** `View.placement`: where and how a Shell mounts the View. */
23
+ export declare const PLACEMENT: "kernel.astrale.ai:class.View.property.placement";
24
+ /** `of_domain.member`: the member name under which a Domain declares the Node. */
25
+ export declare const MEMBER: "kernel.astrale.ai:class.of_domain.property.member";
26
+ /** `Domain.origin`. */
27
+ export declare const ORIGIN: "kernel.astrale.ai:class.Domain.property.origin";
28
+ /** `Descriptable.description`. */
29
+ export declare const DESCRIPTION: "kernel.astrale.ai:class.Descriptable.property.description";
30
+ /** `Identity.iss`. */
31
+ export declare const ISSUER: "kernel.astrale.ai:class.Identity.property.iss";
@@ -0,0 +1,30 @@
1
+ import { ClassKey, PropertyKey } from '@astrale-os/kernel-dsl/v1/addressing';
2
+ // The Kernel Classes a View read names, by their coordinates. `K` is built by the DSL builder when
3
+ // its module loads, and the Session must not resolve the Kernel Schema on loading, so these are
4
+ // written out here and the tests hold them equal to `K`.
5
+ function kernelClass(name) {
6
+ return Object.freeze({
7
+ origin: 'kernel.astrale.ai',
8
+ kind: 'class',
9
+ name,
10
+ });
11
+ }
12
+ /** The Kernel `View` Class. */
13
+ export const VIEW_CLASS = kernelClass('View');
14
+ /** The Kernel `of_domain` Edge Class, which only projection writes. */
15
+ export const OF_DOMAIN_CLASS = kernelClass('of_domain');
16
+ /** The Kernel `Domain` Class. */
17
+ export const DOMAIN_CLASS = kernelClass('Domain');
18
+ export const VIEW = ClassKey.of(VIEW_CLASS);
19
+ export const OF_DOMAIN = ClassKey.of(OF_DOMAIN_CLASS);
20
+ export const DOMAIN = ClassKey.of(DOMAIN_CLASS);
21
+ /** `View.placement`: where and how a Shell mounts the View. */
22
+ export const PLACEMENT = PropertyKey.of(VIEW_CLASS, 'placement');
23
+ /** `of_domain.member`: the member name under which a Domain declares the Node. */
24
+ export const MEMBER = PropertyKey.of(OF_DOMAIN_CLASS, 'member');
25
+ /** `Domain.origin`. */
26
+ export const ORIGIN = PropertyKey.of(DOMAIN_CLASS, 'origin');
27
+ /** `Descriptable.description`. */
28
+ export const DESCRIPTION = PropertyKey.of(kernelClass('Descriptable'), 'description');
29
+ /** `Identity.iss`. */
30
+ export const ISSUER = PropertyKey.of(kernelClass('Identity'), 'iss');
@@ -1,15 +1,10 @@
1
1
  import { equal } from '@astrale-os/kernel-core/graph/properties';
2
2
  import { Query } from '@astrale-os/kernel-core/graph/query';
3
3
  import { Path } from '@astrale-os/kernel-core/path';
4
- import { K } from '@astrale-os/kernel-core/schema';
5
4
  import { patterns } from '@astrale-os/kernel-dsl/v1/addressing';
6
5
  import { ClientError } from '../../errors/index.js';
6
+ import { DOMAIN, MEMBER, OF_DOMAIN, OF_DOMAIN_CLASS, ORIGIN, PLACEMENT, VIEW_CLASS, } from './kernel.js';
7
7
  import { declaredView } from './view.js';
8
- const OF_DOMAIN = K.classes.of_domain.key;
9
- const MEMBER = K.classes.of_domain.properties.member.key;
10
- const DOMAIN = K.classes.Domain.key;
11
- const ORIGIN = K.classes.Domain.properties.origin.key;
12
- const PLACEMENT = K.classes.View.properties.placement.key;
13
8
  /** Reads of one answer before giving up, the bound View.resolve put on its Registry reads. */
14
9
  const ATTEMPTS = 3;
15
10
  /** Selected Edges per page: one of_domain Edge per View the Domain declares. */
@@ -127,15 +122,15 @@ async function readAnswer(reader, ast, operation) {
127
122
  /** The of_domain Edge from the View a Path reaches to the Domain that declares it, if any. */
128
123
  function declarationQuery(target) {
129
124
  const declared = Query.from({ nodes: [target] })
130
- .filter({ class: K.classes.View.ref })
131
- .expand({ via: [K.classes.of_domain.ref], direction: 'outgoing' });
125
+ .filter({ class: VIEW_CLASS })
126
+ .expand({ via: [OF_DOMAIN_CLASS], direction: 'outgoing' });
132
127
  return declared.select({ kind: 'graph', binding: declared.edge });
133
128
  }
134
129
  /** The of_domain Edges that reach a Domain from its Views, with both endpoints. */
135
130
  function domainViewsQuery(origin) {
136
131
  const views = Query.from({ nodes: [Path.domain(origin)] })
137
- .expand({ via: [K.classes.of_domain.ref], direction: 'incoming' })
138
- .filter({ class: K.classes.View.ref });
132
+ .expand({ via: [OF_DOMAIN_CLASS], direction: 'incoming' })
133
+ .filter({ class: VIEW_CLASS });
139
134
  return views.select({ kind: 'graph', binding: views.edge });
140
135
  }
141
136
  /** The origin of a Domain, named by itself or by its exact Domain Path. */
@@ -1,15 +1,10 @@
1
1
  import { issuer, register } from '@astrale-os/kernel-core/auth';
2
2
  import { Path } from '@astrale-os/kernel-core/path';
3
- import { K } from '@astrale-os/kernel-core/schema';
4
3
  import { Key as DefinitionKey } from '@astrale-os/kernel-dsl/v1/addressing';
5
4
  import { acceptViewPlacement, PlacementError } from '@astrale-os/kernel-protocol/placement';
6
5
  import { ClientError } from '../../errors/index.js';
7
6
  import { allowEndpoint } from '../context/index.js';
8
- const VIEW = K.classes.View.key;
9
- const PLACEMENT = K.classes.View.properties.placement.key;
10
- const DESCRIPTION = K.classes.Descriptable.properties.description.key;
11
- const ISSUER = K.classes.Identity.properties.iss.key;
12
- const ORIGIN = K.classes.Domain.properties.origin.key;
7
+ import { DESCRIPTION, ISSUER, ORIGIN, PLACEMENT, VIEW } from './kernel.js';
13
8
  const MEMBER = /^view\.([A-Za-z][A-Za-z0-9_]*)$/u;
14
9
  /**
15
10
  * Admit one View from its Node, with the Declaration that names it, or none for an instance. The
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/kernel-client",
3
- "version": "1.0.0-beta.25",
3
+ "version": "1.0.0-beta.26",
4
4
  "description": "Universal Client — protocol-first, transport-agnostic",
5
5
  "keywords": [
6
6
  "astrale",
@@ -65,15 +65,16 @@
65
65
  "access": "public"
66
66
  },
67
67
  "dependencies": {
68
- "@astrale-os/kernel-core": "1.0.0-beta.22",
69
- "@astrale-os/kernel-dsl": "1.0.0-beta.15",
70
- "@astrale-os/kernel-protocol": "1.0.0-beta.22",
68
+ "@astrale-os/kernel-core": "1.0.0-beta.23",
69
+ "@astrale-os/kernel-dsl": "1.0.0-beta.16",
70
+ "@astrale-os/kernel-protocol": "1.0.0-beta.23",
71
71
  "@tanstack/pacer": "0.20.1"
72
72
  },
73
73
  "devDependencies": {
74
- "@astrale-os/kernel-server": "1.0.0-beta.22",
74
+ "@astrale-os/kernel-server": "1.0.0-beta.23",
75
75
  "@astrale/typescript-config": "npm:@jsr/astrale__typescript-config@~1.1.0",
76
76
  "@types/node": "^22.0.0",
77
+ "esbuild": "0.28.1",
77
78
  "typescript": "7.0.2",
78
79
  "undici": "8.10.0",
79
80
  "vitest": "^5.0.1"