@astrale-os/kernel-dsl 1.0.0-beta.10 → 1.0.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/v1/addressing/class-key.js +3 -3
  2. package/dist/v1/addressing/key.d.ts +4 -1
  3. package/dist/v1/addressing/key.js +21 -2
  4. package/dist/v1/builder/callable/authoring.d.ts +1 -1
  5. package/dist/v1/builder/class/authoring.d.ts +6 -256
  6. package/dist/v1/builder/class/handle.d.ts +27 -0
  7. package/dist/v1/builder/class/handle.js +1 -0
  8. package/dist/v1/builder/class/input.d.ts +129 -0
  9. package/dist/v1/builder/class/input.js +1 -0
  10. package/dist/v1/builder/class/projection.d.ts +129 -0
  11. package/dist/v1/builder/class/projection.js +1 -0
  12. package/dist/v1/builder/core/authoring.d.ts +1 -1
  13. package/dist/v1/builder/index.d.ts +3 -1
  14. package/dist/v1/builder/lowering/class.d.ts +1 -1
  15. package/dist/v1/builder/lowering/schema/context.d.ts +2 -1
  16. package/dist/v1/builder/lowering/value/path.d.ts +1 -1
  17. package/dist/v1/builder/policy/authoring.d.ts +1 -1
  18. package/dist/v1/builder/schema/input.d.ts +1 -1
  19. package/dist/v1/builder/schema/projection/class.d.ts +2 -1
  20. package/dist/v1/builder/schema/projection/core-input.d.ts +2 -1
  21. package/dist/v1/builder/schema/projection/identity.d.ts +2 -1
  22. package/dist/v1/builder/schema/projection/property.d.ts +1 -1
  23. package/dist/v1/builder/value/path-metadata.d.ts +1 -1
  24. package/dist/v1/builder/value/path.d.ts +1 -1
  25. package/dist/v1/language/index.d.ts +1 -0
  26. package/dist/v1/language/index.js +1 -0
  27. package/dist/v1/language/validation/diagnostic.d.ts +1 -1
  28. package/dist/v1/language/value/inclusion/arrays.d.ts +3 -0
  29. package/dist/v1/language/value/inclusion/arrays.js +85 -0
  30. package/dist/v1/language/value/inclusion/assertions.d.ts +18 -0
  31. package/dist/v1/language/value/inclusion/assertions.js +29 -0
  32. package/dist/v1/language/value/inclusion/combinators.d.ts +3 -0
  33. package/dist/v1/language/value/inclusion/combinators.js +67 -0
  34. package/dist/v1/language/value/inclusion/equivalence.d.ts +4 -0
  35. package/dist/v1/language/value/inclusion/equivalence.js +74 -0
  36. package/dist/v1/language/value/inclusion/evidence.d.ts +34 -0
  37. package/dist/v1/language/value/inclusion/evidence.js +138 -0
  38. package/dist/v1/language/value/inclusion/includes.d.ts +17 -0
  39. package/dist/v1/language/value/inclusion/includes.js +25 -719
  40. package/dist/v1/language/value/inclusion/keywords.d.ts +5 -0
  41. package/dist/v1/language/value/inclusion/keywords.js +31 -0
  42. package/dist/v1/language/value/inclusion/kinds.d.ts +17 -0
  43. package/dist/v1/language/value/inclusion/kinds.js +57 -0
  44. package/dist/v1/language/value/inclusion/location.d.ts +24 -0
  45. package/dist/v1/language/value/inclusion/location.js +63 -0
  46. package/dist/v1/language/value/inclusion/numbers.d.ts +3 -0
  47. package/dist/v1/language/value/inclusion/numbers.js +41 -0
  48. package/dist/v1/language/value/inclusion/objects.d.ts +3 -0
  49. package/dist/v1/language/value/inclusion/objects.js +190 -0
  50. package/dist/v1/language/value/inclusion/strings.d.ts +3 -0
  51. package/dist/v1/language/value/inclusion/strings.js +29 -0
  52. package/dist/v1/language/value/inclusion/types.d.ts +3 -0
  53. package/dist/v1/language/value/inclusion/types.js +11 -0
  54. package/dist/v1/language/value/index.d.ts +1 -1
  55. package/dist/v1/language/value/index.js +1 -1
  56. package/dist/v1/language/value/ordering.d.ts +9 -0
  57. package/dist/v1/language/value/ordering.js +72 -9
  58. package/dist/v1/schema/validation/value-api.d.ts +9 -0
  59. package/dist/v1/schema/validation/value-api.js +23 -1
  60. package/dist/value/canonical.d.ts +3 -2
  61. package/dist/value/canonical.js +30 -6
  62. package/dist/value/decode.d.ts +7 -0
  63. package/dist/value/decode.js +159 -9
  64. package/dist/value/index.d.ts +1 -1
  65. package/dist/value/json.d.ts +1 -1
  66. package/dist/value/json.js +1 -1
  67. package/dist/value/types.d.ts +6 -0
  68. package/dist/value/unicode.d.ts +2 -1
  69. package/dist/value/unicode.js +2 -0
  70. package/package.json +1 -1
@@ -10,11 +10,11 @@ export function ClassKey(input) {
10
10
  /** Construction, admission, and structural-coordinate operations for exact Class keys. */
11
11
  (function (ClassKey) {
12
12
  function of(ref) {
13
- const admitted = acceptDefinitionRef(ref);
14
- if (admitted.kind !== 'class') {
13
+ const key = Key.of(ref);
14
+ if (!key.slice(key.indexOf(':') + 1).startsWith('class.')) {
15
15
  throw new TypeError(`Invalid ClassKey coordinate: ${JSON.stringify(ref)}.`);
16
16
  }
17
- return Key.of(admitted);
17
+ return key;
18
18
  }
19
19
  ClassKey.of = of;
20
20
  function is(input) {
@@ -12,7 +12,10 @@ export declare namespace Key {
12
12
  type Definition<Kind extends DefinitionKind = DefinitionKind, Name extends string = string, Origin extends Key.Origin = Key.Origin> = DefinitionKey<Origin, Kind, Name>;
13
13
  type Callable = DefinitionKey<Key.Origin, 'function'> | MethodKey;
14
14
  type View = DefinitionKey<Key.Origin, 'view'>;
15
- /** Derive a canonical Definition key from its structured coordinate. */
15
+ /**
16
+ * Derive a canonical Definition key from its structured coordinate. A frozen coordinate of data
17
+ * fields cannot change, so its key is derived once and read back for every later call.
18
+ */
16
19
  function of<const Ref extends DefinitionRef>(ref: Ref): DefinitionKey<Ref['origin'], Ref['kind'], Ref['name']>;
17
20
  function origin(input: Key): Key.Origin;
18
21
  function is(input: unknown): input is Key;
@@ -3,6 +3,8 @@ import { DOMAIN_ORIGIN_PATTERN } from './patterns.js';
3
3
  const DEFINITION_KEY = /^(?:class|function|policy|view)\.([A-Za-z][A-Za-z0-9_]*)$/u;
4
4
  const CORE_KEY = /^core\.([a-z][a-z0-9-]{0,99})$/u;
5
5
  const MEMBER_KEY = /^class\.([A-Za-z][A-Za-z0-9_]*)\.(property|method)\.([A-Za-z][A-Za-z0-9_]*)$/u;
6
+ /** The keys of frozen Definition coordinates, derived once each. */
7
+ const derived = new WeakMap();
6
8
  export function Key(input) {
7
9
  if (typeof input !== 'string' || !isCanonicalKey(input)) {
8
10
  throw new TypeError(`Invalid Key: ${JSON.stringify(input)}.`);
@@ -11,10 +13,22 @@ export function Key(input) {
11
13
  }
12
14
  /** Canonical origin-qualified address operations. */
13
15
  (function (Key) {
14
- /** Derive a canonical Definition key from its structured coordinate. */
16
+ /**
17
+ * Derive a canonical Definition key from its structured coordinate. A frozen coordinate of data
18
+ * fields cannot change, so its key is derived once and read back for every later call.
19
+ */
15
20
  function of(ref) {
21
+ const object = typeof ref === 'object' && ref !== null;
22
+ const known = object ? derived.get(ref) : undefined;
23
+ if (known !== undefined)
24
+ return known;
25
+ // Decided before admission reads the fields: only then are the fields read the final ones.
26
+ const stable = object && immutable(ref);
16
27
  const definition = acceptDefinitionRef(ref);
17
- return Key(`${definition.origin}:${definition.kind}.${definition.name}`);
28
+ const key = Key(`${definition.origin}:${definition.kind}.${definition.name}`);
29
+ if (stable)
30
+ derived.set(ref, key);
31
+ return key;
18
32
  }
19
33
  Key.of = of;
20
34
  function origin(input) {
@@ -37,3 +51,8 @@ function isCanonicalKey(input) {
37
51
  function isCanonicalCoordinate(input) {
38
52
  return DEFINITION_KEY.test(input) || CORE_KEY.test(input) || MEMBER_KEY.test(input);
39
53
  }
54
+ /** A frozen object of data fields answers every read alike; a getter may not. */
55
+ function immutable(ref) {
56
+ return (Object.isFrozen(ref) &&
57
+ Reflect.ownKeys(ref).every((key) => 'value' in Reflect.getOwnPropertyDescriptor(ref, key)));
58
+ }
@@ -3,7 +3,7 @@ import type { z } from 'zod';
3
3
  import type { PolicyRef } from '../../addressing/index.js';
4
4
  import type { BinaryInputProjection, CallableAdmission, CallableExecution, FunctionAuth } from '../../language/callable/model/callable.js';
5
5
  import type { PolicyCheckExpression, PolicyCheckObject, PolicyObjectRef } from '../../language/policy/model/policy.js';
6
- import type { Class } from '../class/authoring.js';
6
+ import type { Class } from '../class/handle.js';
7
7
  import type { ValueSchemaInput } from '../class/property.js';
8
8
  import type { CoreNode } from '../core/authoring.js';
9
9
  import type { Policy, PolicyInput } from '../policy/authoring.js';
@@ -1,147 +1,16 @@
1
1
  import type { Value as PortableValue } from '@astrale-os/kernel-dsl/value';
2
2
  import type { z } from 'zod';
3
- import type { ClassRef } from '../../addressing/index.js';
4
- import type { MethodRecord } from '../../language/callable/model/callable.js';
5
- import type { ResolvedMethod } from '../../language/callable/resolved.js';
6
- import type { Inheritance } from '../../language/class/model/class.js';
7
- import type { MediaType } from '../../language/class/model/data.js';
8
- import type { EdgeCount, EdgeLifetime } from '../../language/class/model/edge.js';
9
3
  import type { ResolvedClass, ResolvedProperty } from '../../language/class/resolved.js';
10
- import type { ClassRuleChecks, ClassRuleObject } from '../../language/policy/model/policy.js';
11
- import type { StateTopology, StateTopologyOf } from '../../language/state/topology.js';
4
+ import type { StateTopologyOf } from '../../language/state/topology.js';
12
5
  import type { BlobReceipt, BlobRef, BlobSchema } from '../../language/value/model/blob.js';
13
- import type { Method, PolicyCheckContext, ProjectionOfCallable } from '../callable/authoring.js';
14
- import type { Policy } from '../policy/authoring.js';
15
- import type { Lazy } from '../schema/lazy.js';
6
+ import type { Method, ProjectionOfCallable } from '../callable/authoring.js';
16
7
  import type { ClassProjectionOfResolved } from '../schema/projection.js';
17
8
  import type { TypedValueSchema } from '../value/schema.js';
9
+ import type { Class, DirectedEdgeClass, EdgeClass, NodeClass, UndirectedEdgeClass } from './handle.js';
10
+ import type { DirectedEdgeInput, DirectedSourceInput, DirectedTargetInput, IncidentEndpointInput, NodeClassInput, UndirectedEdgeInput } from './input.js';
11
+ import type { AuthoredMethodProjection, AuthoredPropertyProjection, BindMethodOwners, BindPropertyOwners, ClassOwnerProjectionOf, ClassReferenceProjectionOf } from './projection.js';
18
12
  import type { AutoProperty, Property, PropertyOptions, PropertyStateMachineOf, ValueSchemaInput } from './property.js';
19
- import type { PropertyRecordInput } from './property.js';
20
- import { type AUTHORING } from '../schema/handle.js';
21
- declare const CLASS_TYPE: unique symbol;
22
- export type ClassReferenceInput = Lazy<Class | ClassRef | ResolvedClass<'node'> | ResolvedClass<'edge'>>;
23
- export type NodeClassReferenceInput = Lazy<NodeClass | ClassRef | ResolvedClass<'node'>>;
24
- export type EdgeClassReferenceInput = Lazy<EdgeClass | ClassRef | ResolvedClass<'edge'>>;
25
- export interface DirectedSourceInput {
26
- readonly as: string;
27
- readonly accepts: readonly NodeClassReferenceInput[];
28
- readonly outgoing: EdgeCount;
29
- /** What deleting a Node at this endpoint does to the Edge; derived when omitted. */
30
- readonly onDelete?: EdgeLifetime;
31
- }
32
- export interface DirectedTargetInput {
33
- readonly as: string;
34
- readonly accepts: readonly NodeClassReferenceInput[];
35
- readonly incoming: EdgeCount;
36
- /** What deleting a Node at this endpoint does to the Edge; derived when omitted. */
37
- readonly onDelete?: EdgeLifetime;
38
- }
39
- export interface IncidentEndpointInput {
40
- readonly as: string;
41
- readonly accepts: readonly NodeClassReferenceInput[];
42
- readonly incident: EdgeCount;
43
- /** What deleting a Node at this endpoint does to the Edge; derived when omitted. */
44
- readonly onDelete?: EdgeLifetime;
45
- }
46
13
  type ExactEndpointInput<Input, Shape> = Input & Record<Exclude<keyof Input, keyof Shape>, never>;
47
- /** One observation slot: a local Policy, or its constant value. Absent means `true`. */
48
- export type ClassPolicyInput = Lazy<Policy> | boolean;
49
- export interface ClassPoliciesInput {
50
- readonly read?: ClassPolicyInput;
51
- readonly traverse?: ClassPolicyInput;
52
- }
53
- /**
54
- * Policy checks deciding one Node Class observation. `self` is the observed Node; `ref` names one
55
- * exact member, the same Node for every observed candidate.
56
- */
57
- export interface ClassRuleContext extends PolicyCheckContext<ClassRuleObject> {
58
- }
59
- export type ClassRuleBuilder = (context: ClassRuleContext) => ClassRuleChecks;
60
- /** One Node Class observation slot: a local Policy, a constant value, or Policy checks. */
61
- export type NodeClassPolicyInput = ClassPolicyInput | ClassRuleBuilder;
62
- export interface NodeClassPoliciesInput {
63
- readonly read?: NodeClassPolicyInput;
64
- readonly traverse?: NodeClassPolicyInput;
65
- }
66
- export interface NodeClassInput {
67
- readonly abstract?: boolean;
68
- /** Which Classes may extend this one; omitted, those of its own Domain only (`'internal'`). */
69
- readonly inheritance?: Inheritance;
70
- readonly description?: string;
71
- readonly extends?: readonly NodeClassReferenceInput[];
72
- readonly properties?: PropertyRecordInput;
73
- readonly data?: MediaType;
74
- readonly methods?: Readonly<Record<string, Method>>;
75
- readonly icon?: string;
76
- /** Local observation Policies; inherited by no descendant and forbidden on abstract Classes. */
77
- readonly policies?: NodeClassPoliciesInput;
78
- /**
79
- * The tuples no two Nodes of this Class and of its active concrete descendants share while every
80
- * Property is present; omitted, none. A descendant is covered without declaring them again.
81
- */
82
- readonly unique?: readonly NodeUniqueTupleInput[];
83
- }
84
- /**
85
- * The distinct Properties of one Node key, in any order, each a Property of the Class, own or
86
- * inherited, by its name or, when names collide, by its full key.
87
- */
88
- export type NodeUniqueTupleInput = readonly [string, ...string[]];
89
- export interface EdgeClassOptions {
90
- readonly abstract?: boolean;
91
- /** Which Classes may extend this one; omitted, those of its own Domain only (`'internal'`). */
92
- readonly inheritance?: Inheritance;
93
- readonly description?: string;
94
- readonly extends?: readonly EdgeClassReferenceInput[];
95
- readonly properties?: PropertyRecordInput;
96
- /** Local observation Policies; inherited by no descendant and forbidden on abstract Classes. */
97
- readonly policies?: ClassPoliciesInput;
98
- readonly constraints?: {
99
- readonly noSelf?: true;
100
- readonly acyclic?: true;
101
- };
102
- }
103
- /**
104
- * A key field as authored: an endpoint, the slug, or a Property of the Class, own or inherited, by
105
- * its name or, when names collide, by its full key.
106
- */
107
- export type EdgeUniqueFieldInput = 'source' | 'target' | 'slug' | {
108
- readonly property: string;
109
- };
110
- /** The distinct fields of one key, in any order. */
111
- export type EdgeUniqueTupleInput = readonly [EdgeUniqueFieldInput, ...EdgeUniqueFieldInput[]];
112
- export interface DirectedEdgeInput extends EdgeClassOptions {
113
- readonly orientation: 'directed';
114
- readonly source: DirectedSourceInput;
115
- readonly target: DirectedTargetInput;
116
- /**
117
- * The tuples no two Edges of this Class and of its active concrete descendants share while every
118
- * field is present; omitted, none. A descendant is covered without declaring them again.
119
- */
120
- readonly unique?: readonly EdgeUniqueTupleInput[];
121
- }
122
- export interface UndirectedEdgeInput extends Omit<EdgeClassOptions, 'constraints'> {
123
- readonly orientation: 'undirected';
124
- readonly endpoints: readonly [IncidentEndpointInput, IncidentEndpointInput];
125
- readonly constraints?: {
126
- readonly noSelf?: true;
127
- };
128
- }
129
- export type EdgeClassCommon = EdgeClassOptions;
130
- export type EdgeClassInput = DirectedEdgeInput | UndirectedEdgeInput;
131
- export type Class = NodeClass | EdgeClass;
132
- export interface AuthoredPropertyProjection<out Input = unknown, out Output = unknown, out Required extends boolean = boolean, out Name extends string = string, out Owner = 'self', out State extends StateTopology | undefined = StateTopology | undefined> {
133
- readonly input: Input;
134
- readonly output: Output;
135
- readonly required: Required;
136
- readonly name: Name;
137
- readonly owner: Owner;
138
- readonly state?: State;
139
- }
140
- export interface AuthoredMethodProjection<out Value extends Method = Method, out Name extends string = string, out Owner = 'self'> {
141
- readonly value: Value;
142
- readonly name: Name;
143
- readonly owner: Owner;
144
- }
145
14
  type PropertySchemaOf<Field> = Field extends AutoProperty<infer Value> ? PropertySchemaOf<Value> : Field extends Property<infer Schema, PropertyOptions, unknown> ? Schema : Field;
146
15
  type PropertyOptionsOf<Field> = Field extends AutoProperty<infer Value> ? PropertyOptionsOf<Value> : Field extends Property<ValueSchemaInput, infer Options, unknown> ? Options : Record<never, never>;
147
16
  type ValueInputOf<Schema> = Schema extends BlobSchema ? BlobReceipt : Schema extends TypedValueSchema<infer Value> ? Value : Schema extends z.ZodType ? z.input<Schema> : PortableValue;
@@ -166,7 +35,6 @@ type ParentPropertyProjectionsOf<Input> = Input extends {
166
35
  type EffectivePropertyProjectionsOf<Input> = PropertyProjectionEntriesOf<'properties' extends keyof Input ? Input extends {
167
36
  readonly properties?: infer Value;
168
37
  } ? NonNullable<Value> : never : never> | ParentPropertyProjectionsOf<Input>;
169
- type BindPropertyOwners<Entries, Owner> = Entries extends AuthoredPropertyProjection<infer Input, infer Output, infer Required, infer Name, infer ExistingOwner, infer State> ? AuthoredPropertyProjection<Input, Output, Required, Name, ExistingOwner extends 'self' ? Owner : ExistingOwner, State> : Entries;
170
38
  type MethodFieldsOf<Input> = 'methods' extends keyof Input ? Input extends {
171
39
  readonly methods?: infer Methods extends Readonly<Record<string, Method>>;
172
40
  } ? NonNullable<Methods> : Readonly<Record<never, never>> : Readonly<Record<never, never>>;
@@ -176,7 +44,6 @@ type MethodIsStatic<Value extends Method> = ProjectionOfCallable<Value> extends
176
44
  type OwnMethodProjectionsOf<Input, Static extends boolean> = {
177
45
  [Name in keyof MethodFieldsOf<Input>]: MethodFieldsOf<Input>[Name] extends infer Value extends Method ? MethodIsStatic<Value> extends Static ? AuthoredMethodProjection<Value, Extract<Name, string>> : never : never;
178
46
  }[keyof MethodFieldsOf<Input>];
179
- type BindMethodOwners<Entries, Owner> = Entries extends AuthoredMethodProjection<infer Value, infer Name, infer ExistingOwner> ? AuthoredMethodProjection<Value, Name, ExistingOwner extends 'self' ? Owner : ExistingOwner> : Entries;
180
47
  type AbstractMethodEntries<Entry> = Entry extends AuthoredMethodProjection<infer Value> ? ProjectionOfCallable<Value> extends {
181
48
  readonly abstract: true;
182
49
  } ? Entry : never : Entry extends {
@@ -213,104 +80,6 @@ type Increment<Depth extends number> = number extends Depth ? number : [...Tuple
213
80
  type ClassDepthOfInput<Input> = Input extends {
214
81
  readonly extends?: infer Parents extends readonly unknown[];
215
82
  } ? Parents extends readonly [] ? 0 : Increment<ClassDepthOf<Parents[number]>> : 0;
216
- export interface ClassIdentityProjection<out Kind extends 'node' | 'edge' = 'node' | 'edge', out Identity = unknown> {
217
- readonly kind: Kind;
218
- readonly identity: Identity;
219
- }
220
- export interface ClassOwnerProjection<out Kind extends 'node' | 'edge' = 'node' | 'edge', out Identity = unknown, out Properties = unknown, out InstanceMethods = unknown, out StaticMethods = unknown> extends ClassIdentityProjection<Kind, Identity> {
221
- readonly properties: Properties;
222
- readonly instanceMethods: InstanceMethods;
223
- readonly staticMethods: StaticMethods;
224
- }
225
- export interface ClassReferenceProjection<out Kind extends 'node' | 'edge' = 'node' | 'edge', out Identity = unknown, out EffectiveProperties = AuthoredPropertyProjection, out EffectiveInstanceMethods = unknown, out EffectiveStaticMethods = unknown> extends ClassIdentityProjection<Kind, Identity> {
226
- readonly effectiveProperties: EffectiveProperties;
227
- readonly effectiveInstanceMethods: EffectiveInstanceMethods;
228
- readonly effectiveStaticMethods: EffectiveStaticMethods;
229
- }
230
- type NodeClassIdentity<Config> = Config extends {
231
- readonly abstract: infer Abstract;
232
- readonly depth: infer Depth;
233
- readonly properties: infer Properties;
234
- readonly methods: infer Methods;
235
- } ? {
236
- readonly abstract: Abstract;
237
- readonly depth: Depth;
238
- readonly properties: Properties;
239
- readonly methods: Methods;
240
- } : never;
241
- type DirectedEdgeClassIdentity<Config> = Config extends {
242
- readonly abstract: infer Abstract;
243
- readonly depth: infer Depth;
244
- readonly properties: infer Properties;
245
- readonly source: infer Source;
246
- readonly target: infer Target;
247
- readonly constraints: infer Constraints;
248
- } ? {
249
- readonly abstract: Abstract;
250
- readonly depth: Depth;
251
- readonly properties: Properties;
252
- readonly source: Source;
253
- readonly target: Target;
254
- readonly constraints: Constraints;
255
- } : never;
256
- type UndirectedEdgeClassIdentity<Config> = Config extends {
257
- readonly abstract: infer Abstract;
258
- readonly depth: infer Depth;
259
- readonly properties: infer Properties;
260
- readonly endpoints: infer Endpoints;
261
- readonly constraints: infer Constraints;
262
- } ? {
263
- readonly abstract: Abstract;
264
- readonly depth: Depth;
265
- readonly properties: Properties;
266
- readonly endpoints: Endpoints;
267
- readonly constraints: Constraints;
268
- } : never;
269
- type OwnerErasedPropertyProjection<Entry> = Entry extends AuthoredPropertyProjection<infer Input, infer Output, infer Required, infer Name, unknown, infer State> ? AuthoredPropertyProjection<Input, Output, Required, Name, unknown, State> : Entry extends ResolvedProperty<infer Value, infer Required, infer State, infer Input> & {
270
- readonly name: infer Name;
271
- readonly key: infer Key;
272
- } ? {
273
- readonly value: Value;
274
- readonly input: Input;
275
- readonly required: Required;
276
- readonly name: Name;
277
- readonly key: Key;
278
- readonly state?: State;
279
- } : never;
280
- type OwnerErasedMethodProjection<Entry> = Entry extends AuthoredMethodProjection<infer Value, infer Name, unknown> ? AuthoredMethodProjection<Value, Name, unknown> : Entry extends ResolvedMethod<infer Input, infer Output, infer Static, infer Abstract, infer Auth, infer _Policy, infer Key> & {
281
- readonly name: infer Name;
282
- } ? {
283
- readonly input: Input;
284
- readonly output: Output;
285
- readonly static: Static;
286
- readonly abstract: Abstract;
287
- readonly auth: Auth;
288
- readonly name: Name;
289
- readonly key: Key;
290
- } : never;
291
- export type ClassIdentityProjectionOf<Value> = Value extends NodeClass<infer Config> ? ClassIdentityProjection<'node', NodeClassIdentity<Config>> : Value extends DirectedEdgeClass<infer Config> ? ClassIdentityProjection<'edge', DirectedEdgeClassIdentity<Config>> : Value extends UndirectedEdgeClass<infer Config> ? ClassIdentityProjection<'edge', UndirectedEdgeClassIdentity<Config>> : never;
292
- export type ClassOwnerProjectionOf<Value> = Value extends NodeClass<infer Config> ? ClassOwnerProjection<'node', NodeClassIdentity<Config>, Config extends {
293
- readonly effectiveProperties: infer Properties;
294
- } ? OwnerErasedPropertyProjection<Properties> : never, Config extends {
295
- readonly effectiveInstanceMethods: infer Methods;
296
- } ? OwnerErasedMethodProjection<Methods> : never, Config extends {
297
- readonly effectiveStaticMethods: infer Methods;
298
- } ? OwnerErasedMethodProjection<Methods> : never> : Value extends DirectedEdgeClass<infer Config> ? ClassOwnerProjection<'edge', DirectedEdgeClassIdentity<Config>, Config extends {
299
- readonly effectiveProperties: infer Properties;
300
- } ? OwnerErasedPropertyProjection<Properties> : never, never, never> : Value extends UndirectedEdgeClass<infer Config> ? ClassOwnerProjection<'edge', UndirectedEdgeClassIdentity<Config>, Config extends {
301
- readonly effectiveProperties: infer Properties;
302
- } ? OwnerErasedPropertyProjection<Properties> : never, never, never> : never;
303
- export type ClassReferenceProjectionOf<Value> = Value extends NodeClass<infer Config> ? ClassReferenceProjection<'node', NodeClassIdentity<Config>, Config extends {
304
- readonly effectiveProperties: infer Properties;
305
- } ? BindPropertyOwners<Properties, ClassOwnerProjectionOf<NodeClass<Config>>> : never, Config extends {
306
- readonly effectiveInstanceMethods: infer Methods;
307
- } ? BindMethodOwners<Methods, ClassOwnerProjectionOf<NodeClass<Config>>> : never, Config extends {
308
- readonly effectiveStaticMethods: infer Methods;
309
- } ? BindMethodOwners<Methods, ClassOwnerProjectionOf<NodeClass<Config>>> : never> : Value extends DirectedEdgeClass<infer Config> ? ClassReferenceProjection<'edge', DirectedEdgeClassIdentity<Config>, Config extends {
310
- readonly effectiveProperties: infer Properties;
311
- } ? BindPropertyOwners<Properties, ClassOwnerProjectionOf<DirectedEdgeClass<Config>>> : never, never, never> : Value extends UndirectedEdgeClass<infer Config> ? ClassReferenceProjection<'edge', UndirectedEdgeClassIdentity<Config>, Config extends {
312
- readonly effectiveProperties: infer Properties;
313
- } ? BindPropertyOwners<Properties, ClassOwnerProjectionOf<UndirectedEdgeClass<Config>>> : never, never, never> : never;
314
83
  type CompactReference<Value> = Value extends () => infer Resolved ? () => CompactReference<Resolved> : Value extends ResolvedClass ? ClassProjectionOfResolved<Value> : Value extends Class ? ClassReferenceProjectionOf<Value> : Value;
315
84
  type CompactReferences<Values extends readonly unknown[]> = Values extends readonly [] ? readonly [] : Values extends readonly [infer Value, ...infer Rest] ? readonly [CompactReference<Value>, ...CompactReferences<Rest>] : readonly CompactReference<Values[number]>[];
316
85
  type CompactParentsOf<Input> = Input extends {
@@ -380,24 +149,6 @@ type CompactUndirectedInput<Input extends Omit<UndirectedEdgeInput, 'orientation
380
149
  } ? NonNullable<Value> : Record<never, never>;
381
150
  readonly effectiveProperties: EffectivePropertyProjectionsOf<Input>;
382
151
  };
383
- export interface NodeClass<out Config = unknown> {
384
- readonly [AUTHORING]: 'definition';
385
- readonly kind: 'node';
386
- readonly [CLASS_TYPE]: () => Config;
387
- }
388
- export interface DirectedEdgeClass<out Input = unknown> {
389
- readonly [AUTHORING]: 'definition';
390
- readonly kind: 'edge';
391
- readonly orientation: 'directed';
392
- readonly [CLASS_TYPE]: () => Input;
393
- }
394
- export interface UndirectedEdgeClass<out Input = unknown> {
395
- readonly [AUTHORING]: 'definition';
396
- readonly kind: 'edge';
397
- readonly orientation: 'undirected';
398
- readonly [CLASS_TYPE]: () => Input;
399
- }
400
- export type EdgeClass = DirectedEdgeClass | UndirectedEdgeClass;
401
152
  export declare function defineClass(config: {
402
153
  readonly kind: 'node';
403
154
  readonly abstract: boolean;
@@ -430,9 +181,8 @@ type WithoutStateProperties<Input> = Input extends {
430
181
  readonly [Name in keyof Properties]: Properties[Name] extends Property ? [PropertyStateMachineOf<Properties[Name]>] extends [never] ? Properties[Name] : never : Properties[Name];
431
182
  };
432
183
  } : unknown;
433
- export type ProjectionOfClass<Value extends Class> = Value extends NodeClass<infer Config> ? Config : Value extends DirectedEdgeClass<infer Input> ? Input : Value extends UndirectedEdgeClass<infer Input> ? Input : never;
434
184
  export declare function classConfiguration(value: NodeClass): NodeClassInput;
435
185
  export declare function classConfiguration(value: DirectedEdgeClass): Omit<DirectedEdgeInput, 'orientation'>;
436
186
  export declare function classConfiguration(value: UndirectedEdgeClass): Omit<UndirectedEdgeInput, 'orientation'>;
437
187
  export declare function classConfiguration(value: EdgeClass): Omit<DirectedEdgeInput, 'orientation'> | Omit<UndirectedEdgeInput, 'orientation'>;
438
- export type { MethodRecord };
188
+ export {};
@@ -0,0 +1,27 @@
1
+ import { type AUTHORING } from '../schema/handle.js';
2
+ declare const CLASS_TYPE: unique symbol;
3
+ /** Authored Node Class handle; its type carries the compact projection of its input. */
4
+ export interface NodeClass<out Config = unknown> {
5
+ readonly [AUTHORING]: 'definition';
6
+ readonly kind: 'node';
7
+ readonly [CLASS_TYPE]: () => Config;
8
+ }
9
+ /** Authored directed Edge Class handle; its type carries the compact projection of its input. */
10
+ export interface DirectedEdgeClass<out Input = unknown> {
11
+ readonly [AUTHORING]: 'definition';
12
+ readonly kind: 'edge';
13
+ readonly orientation: 'directed';
14
+ readonly [CLASS_TYPE]: () => Input;
15
+ }
16
+ /** Authored undirected Edge Class handle; its type carries the compact projection of its input. */
17
+ export interface UndirectedEdgeClass<out Input = unknown> {
18
+ readonly [AUTHORING]: 'definition';
19
+ readonly kind: 'edge';
20
+ readonly orientation: 'undirected';
21
+ readonly [CLASS_TYPE]: () => Input;
22
+ }
23
+ export type EdgeClass = DirectedEdgeClass | UndirectedEdgeClass;
24
+ export type Class = NodeClass | EdgeClass;
25
+ /** The compact projection a Class handle carries. */
26
+ export type ProjectionOfClass<Value extends Class> = Value extends NodeClass<infer Config> ? Config : Value extends DirectedEdgeClass<infer Input> ? Input : Value extends UndirectedEdgeClass<infer Input> ? Input : never;
27
+ export {};
@@ -0,0 +1 @@
1
+ import {} from '../schema/handle.js';
@@ -0,0 +1,129 @@
1
+ import type { ClassRef } from '../../addressing/index.js';
2
+ import type { Inheritance } from '../../language/class/model/class.js';
3
+ import type { MediaType } from '../../language/class/model/data.js';
4
+ import type { EdgeCount, EdgeLifetime } from '../../language/class/model/edge.js';
5
+ import type { ResolvedClass } from '../../language/class/resolved.js';
6
+ import type { ClassRuleChecks, ClassRuleObject } from '../../language/policy/model/policy.js';
7
+ import type { Method, PolicyCheckContext } from '../callable/authoring.js';
8
+ import type { Policy } from '../policy/authoring.js';
9
+ import type { Lazy } from '../schema/lazy.js';
10
+ import type { Class, EdgeClass, NodeClass } from './handle.js';
11
+ import type { PropertyRecordInput } from './property.js';
12
+ /** Reference to a Class: an authored handle, a ClassRef or a resolved Class, possibly lazy. */
13
+ export type ClassReferenceInput = Lazy<Class | ClassRef | ResolvedClass<'node'> | ResolvedClass<'edge'>>;
14
+ export type NodeClassReferenceInput = Lazy<NodeClass | ClassRef | ResolvedClass<'node'>>;
15
+ export type EdgeClassReferenceInput = Lazy<EdgeClass | ClassRef | ResolvedClass<'edge'>>;
16
+ /** Source side of a directed Edge Class. */
17
+ export interface DirectedSourceInput {
18
+ readonly as: string;
19
+ readonly accepts: readonly NodeClassReferenceInput[];
20
+ readonly outgoing: EdgeCount;
21
+ /** What deleting a Node at this endpoint does to the Edge; derived when omitted. */
22
+ readonly onDelete?: EdgeLifetime;
23
+ }
24
+ /** Target side of a directed Edge Class. */
25
+ export interface DirectedTargetInput {
26
+ readonly as: string;
27
+ readonly accepts: readonly NodeClassReferenceInput[];
28
+ readonly incoming: EdgeCount;
29
+ /** What deleting a Node at this endpoint does to the Edge; derived when omitted. */
30
+ readonly onDelete?: EdgeLifetime;
31
+ }
32
+ /** One endpoint of an undirected Edge Class. */
33
+ export interface IncidentEndpointInput {
34
+ readonly as: string;
35
+ readonly accepts: readonly NodeClassReferenceInput[];
36
+ readonly incident: EdgeCount;
37
+ /** What deleting a Node at this endpoint does to the Edge; derived when omitted. */
38
+ readonly onDelete?: EdgeLifetime;
39
+ }
40
+ /** One observation slot: a local Policy, or its constant value. Absent means `true`. */
41
+ export type ClassPolicyInput = Lazy<Policy> | boolean;
42
+ /** Local observation Policies of a Class. */
43
+ export interface ClassPoliciesInput {
44
+ readonly read?: ClassPolicyInput;
45
+ readonly traverse?: ClassPolicyInput;
46
+ }
47
+ /**
48
+ * Policy checks deciding one Node Class observation. `self` is the observed Node; `ref` names one
49
+ * exact member, the same Node for every observed candidate.
50
+ */
51
+ export interface ClassRuleContext extends PolicyCheckContext<ClassRuleObject> {
52
+ }
53
+ export type ClassRuleBuilder = (context: ClassRuleContext) => ClassRuleChecks;
54
+ /** One Node Class observation slot: a local Policy, a constant value, or Policy checks. */
55
+ export type NodeClassPolicyInput = ClassPolicyInput | ClassRuleBuilder;
56
+ /** Local observation Policies of a Node Class. */
57
+ export interface NodeClassPoliciesInput {
58
+ readonly read?: NodeClassPolicyInput;
59
+ readonly traverse?: NodeClassPolicyInput;
60
+ }
61
+ /** Authored Node Class. */
62
+ export interface NodeClassInput {
63
+ readonly abstract?: boolean;
64
+ /** Which Classes may extend this one; omitted, those of its own Domain only (`'internal'`). */
65
+ readonly inheritance?: Inheritance;
66
+ readonly description?: string;
67
+ readonly extends?: readonly NodeClassReferenceInput[];
68
+ readonly properties?: PropertyRecordInput;
69
+ readonly data?: MediaType;
70
+ readonly methods?: Readonly<Record<string, Method>>;
71
+ readonly icon?: string;
72
+ /** Local observation Policies; inherited by no descendant and forbidden on abstract Classes. */
73
+ readonly policies?: NodeClassPoliciesInput;
74
+ /**
75
+ * The tuples no two Nodes of this Class and of its active concrete descendants share while every
76
+ * Property is present; omitted, none. A descendant is covered without declaring them again.
77
+ */
78
+ readonly unique?: readonly NodeUniqueTupleInput[];
79
+ }
80
+ /**
81
+ * The distinct Properties of one Node key, in any order, each a Property of the Class, own or
82
+ * inherited, by its name or, when names collide, by its full key.
83
+ */
84
+ export type NodeUniqueTupleInput = readonly [string, ...string[]];
85
+ /** Members every authored Edge Class shares. */
86
+ export interface EdgeClassOptions {
87
+ readonly abstract?: boolean;
88
+ /** Which Classes may extend this one; omitted, those of its own Domain only (`'internal'`). */
89
+ readonly inheritance?: Inheritance;
90
+ readonly description?: string;
91
+ readonly extends?: readonly EdgeClassReferenceInput[];
92
+ readonly properties?: PropertyRecordInput;
93
+ /** Local observation Policies; inherited by no descendant and forbidden on abstract Classes. */
94
+ readonly policies?: ClassPoliciesInput;
95
+ readonly constraints?: {
96
+ readonly noSelf?: true;
97
+ readonly acyclic?: true;
98
+ };
99
+ }
100
+ /**
101
+ * A key field as authored: an endpoint, the slug, or a Property of the Class, own or inherited, by
102
+ * its name or, when names collide, by its full key.
103
+ */
104
+ export type EdgeUniqueFieldInput = 'source' | 'target' | 'slug' | {
105
+ readonly property: string;
106
+ };
107
+ /** The distinct fields of one key, in any order. */
108
+ export type EdgeUniqueTupleInput = readonly [EdgeUniqueFieldInput, ...EdgeUniqueFieldInput[]];
109
+ /** Authored directed Edge Class. */
110
+ export interface DirectedEdgeInput extends EdgeClassOptions {
111
+ readonly orientation: 'directed';
112
+ readonly source: DirectedSourceInput;
113
+ readonly target: DirectedTargetInput;
114
+ /**
115
+ * The tuples no two Edges of this Class and of its active concrete descendants share while every
116
+ * field is present; omitted, none. A descendant is covered without declaring them again.
117
+ */
118
+ readonly unique?: readonly EdgeUniqueTupleInput[];
119
+ }
120
+ /** Authored undirected Edge Class. */
121
+ export interface UndirectedEdgeInput extends Omit<EdgeClassOptions, 'constraints'> {
122
+ readonly orientation: 'undirected';
123
+ readonly endpoints: readonly [IncidentEndpointInput, IncidentEndpointInput];
124
+ readonly constraints?: {
125
+ readonly noSelf?: true;
126
+ };
127
+ }
128
+ export type EdgeClassCommon = EdgeClassOptions;
129
+ export type EdgeClassInput = DirectedEdgeInput | UndirectedEdgeInput;
@@ -0,0 +1 @@
1
+ export {};