@astrale-os/kernel-dsl 1.0.0-beta.11 → 1.0.0-beta.13
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/dist/v1/addressing/definition-ref.js +21 -37
- package/dist/v1/addressing/ordering.d.ts +2 -0
- package/dist/v1/addressing/ordering.js +4 -0
- package/dist/v1/addressing/patterns.d.ts +0 -1
- package/dist/v1/addressing/patterns.js +0 -5
- package/dist/v1/builder/callable/authoring.d.ts +1 -1
- package/dist/v1/builder/class/authoring.d.ts +6 -256
- package/dist/v1/builder/class/authoring.js +5 -28
- package/dist/v1/builder/class/handle.d.ts +27 -0
- package/dist/v1/builder/class/handle.js +1 -0
- package/dist/v1/builder/class/input.d.ts +129 -0
- package/dist/v1/builder/class/projection.d.ts +129 -0
- package/dist/v1/builder/class/projection.js +1 -0
- package/dist/v1/builder/core/authoring.d.ts +1 -1
- package/dist/v1/builder/index.d.ts +3 -1
- package/dist/v1/builder/lowering/class.d.ts +1 -1
- package/dist/v1/builder/lowering/schema/context.d.ts +2 -1
- package/dist/v1/builder/lowering/schema/context.js +2 -4
- package/dist/v1/builder/lowering/value/path.d.ts +1 -1
- package/dist/v1/builder/lowering/value/path.js +2 -4
- package/dist/v1/builder/lowering/value/zod.js +1 -3
- package/dist/v1/builder/policy/authoring.d.ts +1 -1
- package/dist/v1/builder/schema/define.d.ts +0 -1
- package/dist/v1/builder/schema/diagnostic.d.ts +2 -1
- package/dist/v1/builder/schema/diagnostic.js +5 -10
- package/dist/v1/builder/schema/input.d.ts +1 -1
- package/dist/v1/builder/schema/projection/class.d.ts +2 -1
- package/dist/v1/builder/schema/projection/core-input.d.ts +2 -1
- package/dist/v1/builder/schema/projection/identity.d.ts +2 -1
- package/dist/v1/builder/schema/projection/property.d.ts +1 -1
- package/dist/v1/builder/schema/projection.d.ts +1 -1
- package/dist/v1/builder/value/full-match.d.ts +0 -1
- package/dist/v1/builder/value/full-match.js +0 -1
- package/dist/v1/builder/value/path-metadata.d.ts +1 -1
- package/dist/v1/builder/value/path.d.ts +1 -1
- package/dist/v1/bundle/codec.js +2 -4
- package/dist/v1/bundle/diagnostic.js +3 -7
- package/dist/v1/bundle/structure.js +2 -4
- package/dist/v1/compiled/admission/diagnostic.d.ts +1 -1
- package/dist/v1/compiled/admission/diagnostic.js +1 -3
- package/dist/v1/compiled/admission/revision.d.ts +9 -1
- package/dist/v1/compiled/admission/revision.js +6 -3
- package/dist/v1/compiled/admission/semantics/class.d.ts +4 -1
- package/dist/v1/compiled/admission/semantics/class.js +4 -8
- package/dist/v1/compiled/admission/semantics/core.d.ts +1 -24
- package/dist/v1/compiled/admission/semantics/core.js +54 -34
- package/dist/v1/compiled/admission/semantics/edge.d.ts +2 -4
- package/dist/v1/compiled/admission/semantics/edge.js +6 -65
- package/dist/v1/compiled/admission/semantics/policy/callable.js +0 -2
- package/dist/v1/compiled/admission/semantics/policy/contracts.d.ts +5 -20
- package/dist/v1/compiled/admission/semantics/policy/contracts.js +8 -21
- package/dist/v1/compiled/admission/semantics/policy/parity.js +13 -22
- package/dist/v1/compiled/admission/semantics/policy/pattern.d.ts +4 -1
- package/dist/v1/compiled/admission/semantics/policy/pattern.js +4 -16
- package/dist/v1/compiled/admission/semantics/policy/typing.d.ts +2 -24
- package/dist/v1/compiled/admission/semantics/policy/typing.js +19 -201
- package/dist/v1/compiled/compiler/compile.js +6 -8
- package/dist/v1/compiled/diagnostic.js +2 -3
- package/dist/v1/compiled/loader/load.d.ts +3 -2
- package/dist/v1/compiled/loader/load.js +10 -44
- package/dist/v1/domain/create.js +3 -5
- package/dist/v1/domain/namespace/member-collection.js +4 -6
- package/dist/v1/domain/validation/create.d.ts +0 -1
- package/dist/v1/domain/validation/create.js +0 -35
- package/dist/v1/language/class/inheritance.d.ts +18 -0
- package/dist/v1/language/class/inheritance.js +73 -0
- package/dist/v1/language/class/property-values.js +2 -4
- package/dist/v1/language/core/facts.d.ts +72 -0
- package/dist/v1/language/core/facts.js +95 -0
- package/dist/v1/language/index.d.ts +1 -0
- package/dist/v1/language/index.js +1 -0
- package/dist/v1/language/policy/analysis/branches.d.ts +8 -0
- package/dist/v1/language/policy/analysis/branches.js +2 -1
- package/dist/v1/language/policy/analysis/budgets.d.ts +13 -1
- package/dist/v1/language/policy/analysis/budgets.js +104 -0
- package/dist/v1/language/policy/analysis/typing.d.ts +48 -0
- package/dist/v1/language/policy/analysis/typing.js +338 -0
- package/dist/v1/language/validation/diagnostic.d.ts +15 -1
- package/dist/v1/language/validation/diagnostic.js +21 -0
- package/dist/v1/language/value/compile/fields.js +4 -8
- package/dist/v1/language/value/inclusion/arrays.d.ts +3 -0
- package/dist/v1/language/value/inclusion/arrays.js +85 -0
- package/dist/v1/language/value/inclusion/assertions.d.ts +18 -0
- package/dist/v1/language/value/inclusion/assertions.js +29 -0
- package/dist/v1/language/value/inclusion/combinators.d.ts +3 -0
- package/dist/v1/language/value/inclusion/combinators.js +67 -0
- package/dist/v1/language/value/inclusion/equivalence.d.ts +4 -0
- package/dist/v1/language/value/inclusion/equivalence.js +74 -0
- package/dist/v1/language/value/inclusion/evidence.d.ts +34 -0
- package/dist/v1/language/value/inclusion/evidence.js +138 -0
- package/dist/v1/language/value/inclusion/includes.d.ts +17 -0
- package/dist/v1/language/value/inclusion/includes.js +25 -719
- package/dist/v1/language/value/inclusion/keywords.d.ts +5 -0
- package/dist/v1/language/value/inclusion/keywords.js +31 -0
- package/dist/v1/language/value/inclusion/kinds.d.ts +17 -0
- package/dist/v1/language/value/inclusion/kinds.js +57 -0
- package/dist/v1/language/value/inclusion/location.d.ts +24 -0
- package/dist/v1/language/value/inclusion/location.js +63 -0
- package/dist/v1/language/value/inclusion/numbers.d.ts +3 -0
- package/dist/v1/language/value/inclusion/numbers.js +41 -0
- package/dist/v1/language/value/inclusion/objects.d.ts +3 -0
- package/dist/v1/language/value/inclusion/objects.js +190 -0
- package/dist/v1/language/value/inclusion/strings.d.ts +3 -0
- package/dist/v1/language/value/inclusion/strings.js +29 -0
- package/dist/v1/language/value/inclusion/types.d.ts +3 -0
- package/dist/v1/language/value/inclusion/types.js +11 -0
- package/dist/v1/language/value/ordering.d.ts +9 -0
- package/dist/v1/language/value/ordering.js +72 -9
- package/dist/v1/language/value/profile/rules.js +5 -7
- package/dist/v1/language/value/profile/validate.js +1 -10
- package/dist/v1/language/value/reference/recursion.js +2 -22
- package/dist/v1/language/value/syntax/pointer.d.ts +2 -0
- package/dist/v1/language/value/syntax/pointer.js +5 -2
- package/dist/v1/language/value/syntax/walk.d.ts +2 -0
- package/dist/v1/language/value/syntax/walk.js +19 -20
- package/dist/v1/schema/compatibility/diff.js +2 -4
- package/dist/v1/schema/compatibility/meaning/footprint.js +16 -50
- package/dist/v1/schema/compatibility/structure/requirements.js +26 -58
- package/dist/v1/schema/compatibility/walk.d.ts +17 -0
- package/dist/v1/schema/compatibility/walk.js +41 -0
- package/dist/v1/schema/diagnostic.js +3 -11
- package/dist/v1/schema/resolution/context.js +3 -5
- package/dist/v1/schema/validation/callable.js +3 -5
- package/dist/v1/schema/validation/class.js +10 -52
- package/dist/v1/schema/validation/core.js +65 -199
- package/dist/v1/schema/validation/domain.js +1 -10
- package/dist/v1/schema/validation/domain.structure.js +2 -4
- package/dist/v1/schema/validation/policy/budgets.js +5 -112
- package/dist/v1/schema/validation/policy/context.d.ts +5 -3
- package/dist/v1/schema/validation/policy/context.js +5 -3
- package/dist/v1/schema/validation/policy/objects.d.ts +1 -1
- package/dist/v1/schema/validation/policy/objects.js +6 -14
- package/dist/v1/schema/validation/policy/references.js +5 -6
- package/dist/v1/schema/validation/policy/typing.d.ts +3 -18
- package/dist/v1/schema/validation/policy/typing.js +22 -356
- package/dist/v1/schema/validation/policy/uses.d.ts +1 -1
- package/dist/v1/schema/validation/policy/uses.js +9 -22
- package/dist/v1/schema/validation/policy/validate.js +3 -2
- package/dist/v1/schema/validation/value-api.d.ts +9 -0
- package/dist/v1/schema/validation/value-api.js +23 -1
- package/dist/v1/schema/validation/value.js +5 -7
- package/dist/v1/schema/validation/view.js +4 -8
- package/dist/value/canonical.d.ts +3 -2
- package/dist/value/canonical.js +30 -6
- package/dist/value/decode.d.ts +7 -0
- package/dist/value/decode.js +159 -9
- package/dist/value/index.d.ts +1 -1
- package/dist/value/json.d.ts +1 -1
- package/dist/value/json.js +1 -1
- package/dist/value/types.d.ts +6 -0
- package/dist/value/unicode.d.ts +2 -1
- package/dist/value/unicode.js +2 -0
- package/package.json +1 -1
- package/dist/v1/compiled/admission/semantics/cardinality.d.ts +0 -5
- package/dist/v1/compiled/admission/semantics/cardinality.js +0 -128
- package/dist/v1/compiled/admission/semantics/policy/equality.d.ts +0 -8
- package/dist/v1/compiled/admission/semantics/policy/equality.js +0 -27
- package/dist/v1/compiled/admission/semantics/policy/measure.d.ts +0 -9
- package/dist/v1/compiled/admission/semantics/policy/measure.js +0 -81
- package/dist/v1/compiled/admission/semantics/policy/variants.d.ts +0 -10
- package/dist/v1/compiled/admission/semantics/policy/variants.js +0 -65
- package/dist/v1/language/class/index.d.ts +0 -8
- package/dist/v1/language/class/index.js +0 -1
- package/dist/v1/language/core/index.d.ts +0 -2
- package/dist/v1/language/value/index.d.ts +0 -11
- package/dist/v1/language/value/index.js +0 -8
- /package/dist/v1/{language/core/index.js → builder/class/input.js} +0 -0
|
@@ -8,55 +8,39 @@ const DEFINITION_KINDS = new Set([
|
|
|
8
8
|
]);
|
|
9
9
|
/** Admit and detach one canonical DefinitionRef from an untrusted value. */
|
|
10
10
|
export function acceptDefinitionRef(input) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
return readDefinitionRef(input) ?? invalid(input);
|
|
12
|
+
}
|
|
13
|
+
/** Identify a canonical DefinitionRef-shaped value without retaining caller state. */
|
|
14
|
+
export function isDefinitionRef(input) {
|
|
15
|
+
return readDefinitionRef(input) !== undefined;
|
|
16
|
+
}
|
|
17
|
+
/** Compare exact Definition coordinates, independent of object identity. */
|
|
18
|
+
export function equalDefinitionRefs(left, right) {
|
|
19
|
+
return left.origin === right.origin && left.kind === right.kind && left.name === right.name;
|
|
20
|
+
}
|
|
21
|
+
function invalid(input) {
|
|
22
|
+
throw new TypeError(`Invalid DefinitionRef: ${JSON.stringify(input)}.`);
|
|
23
|
+
}
|
|
24
|
+
/** A detached copy of the canonical DefinitionRef `input` holds, reading each field once. */
|
|
25
|
+
function readDefinitionRef(input) {
|
|
26
|
+
if (input === null || typeof input !== 'object' || Array.isArray(input))
|
|
27
|
+
return undefined;
|
|
14
28
|
const value = input;
|
|
15
29
|
const keys = Reflect.ownKeys(value);
|
|
16
30
|
if (keys.length !== 3 ||
|
|
17
31
|
!keys.every((key) => key === 'origin' || key === 'kind' || key === 'name')) {
|
|
18
|
-
|
|
32
|
+
return undefined;
|
|
19
33
|
}
|
|
20
|
-
const origin = value
|
|
21
|
-
const kind = value.kind;
|
|
22
|
-
const name = value.name;
|
|
34
|
+
const { origin, kind, name } = value;
|
|
23
35
|
if (typeof origin !== 'string' ||
|
|
24
36
|
!DOMAIN_ORIGIN_PATTERN.test(origin) ||
|
|
25
37
|
typeof kind !== 'string' ||
|
|
26
38
|
!DEFINITION_KINDS.has(kind) ||
|
|
27
39
|
typeof name !== 'string' ||
|
|
28
40
|
!definitionNameMatches(kind, name)) {
|
|
29
|
-
|
|
41
|
+
return undefined;
|
|
30
42
|
}
|
|
31
|
-
return Object.freeze({
|
|
32
|
-
origin,
|
|
33
|
-
kind: kind,
|
|
34
|
-
name,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
/** Identify a canonical DefinitionRef-shaped value without retaining caller state. */
|
|
38
|
-
export function isDefinitionRef(input) {
|
|
39
|
-
if (input === null || typeof input !== 'object' || Array.isArray(input))
|
|
40
|
-
return false;
|
|
41
|
-
const value = input;
|
|
42
|
-
const keys = Reflect.ownKeys(value);
|
|
43
|
-
if (keys.length !== 3 ||
|
|
44
|
-
!keys.every((key) => key === 'origin' || key === 'kind' || key === 'name')) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
return (typeof value.origin === 'string' &&
|
|
48
|
-
DOMAIN_ORIGIN_PATTERN.test(value.origin) &&
|
|
49
|
-
typeof value.kind === 'string' &&
|
|
50
|
-
DEFINITION_KINDS.has(value.kind) &&
|
|
51
|
-
typeof value.name === 'string' &&
|
|
52
|
-
definitionNameMatches(value.kind, value.name));
|
|
53
|
-
}
|
|
54
|
-
/** Compare exact Definition coordinates, independent of object identity. */
|
|
55
|
-
export function equalDefinitionRefs(left, right) {
|
|
56
|
-
return left.origin === right.origin && left.kind === right.kind && left.name === right.name;
|
|
57
|
-
}
|
|
58
|
-
function invalid(input) {
|
|
59
|
-
throw new TypeError(`Invalid DefinitionRef: ${JSON.stringify(input)}.`);
|
|
43
|
+
return Object.freeze({ origin, kind: kind, name });
|
|
60
44
|
}
|
|
61
45
|
function definitionNameMatches(kind, name) {
|
|
62
46
|
return kind === 'core' ? CORE_SLUG_PATTERN.test(name) : MEMBER_NAME_PATTERN.test(name);
|
|
@@ -4,3 +4,5 @@ export declare function definitionRefIndex(ref: DefinitionRef): string;
|
|
|
4
4
|
export declare function compareDefinitionRefs(left: DefinitionRef, right: DefinitionRef): number;
|
|
5
5
|
/** Locale-independent Unicode code-point ordering for canonical DSL values. */
|
|
6
6
|
export declare function compareUnicode(left: string, right: string): number;
|
|
7
|
+
/** Order strings by UTF-16 code unit, the order `<` gives strings. */
|
|
8
|
+
export declare function compareCodeUnits(left: string, right: string): number;
|
|
@@ -18,3 +18,7 @@ export function compareUnicode(left, right) {
|
|
|
18
18
|
}
|
|
19
19
|
return a.length - b.length;
|
|
20
20
|
}
|
|
21
|
+
/** Order strings by UTF-16 code unit, the order `<` gives strings. */
|
|
22
|
+
export function compareCodeUnits(left, right) {
|
|
23
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
24
|
+
}
|
|
@@ -22,8 +22,3 @@ export const patterns = Object.freeze({
|
|
|
22
22
|
revision: DOMAIN_REVISION_PATTERN,
|
|
23
23
|
revisionFullMatch: DOMAIN_REVISION_FULL_MATCH,
|
|
24
24
|
});
|
|
25
|
-
export function assertMemberName(name) {
|
|
26
|
-
if (!MEMBER_NAME_PATTERN.test(name)) {
|
|
27
|
-
throw new TypeError(`Invalid member name: ${JSON.stringify(name)}.`);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -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/
|
|
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 {
|
|
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,
|
|
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
|
|
188
|
+
export {};
|
|
@@ -59,7 +59,7 @@ export const edgeClass = Object.freeze({
|
|
|
59
59
|
validateDirectedSourceInput(input.source);
|
|
60
60
|
validateDirectedTargetInput(input.target);
|
|
61
61
|
const { source, target, unique, ...options } = input;
|
|
62
|
-
validateEdgeClassOptions(options);
|
|
62
|
+
validateEdgeClassOptions(options, ['noSelf', 'acyclic']);
|
|
63
63
|
const value = authoringValue('definition', {
|
|
64
64
|
kind: 'edge',
|
|
65
65
|
orientation: 'directed',
|
|
@@ -94,7 +94,7 @@ export const edgeClass = Object.freeze({
|
|
|
94
94
|
validateIncidentEndpointInput(input.endpoints[0]);
|
|
95
95
|
validateIncidentEndpointInput(input.endpoints[1]);
|
|
96
96
|
const { endpoints, ...options } = input;
|
|
97
|
-
|
|
97
|
+
validateEdgeClassOptions(options, ['noSelf']);
|
|
98
98
|
const value = authoringValue('definition', {
|
|
99
99
|
kind: 'edge',
|
|
100
100
|
orientation: 'undirected',
|
|
@@ -122,33 +122,10 @@ function validateDirectedTargetInput(value) {
|
|
|
122
122
|
function validateIncidentEndpointInput(value) {
|
|
123
123
|
assertKnownKeys(value, ['as', 'accepts', 'incident', 'onDelete']);
|
|
124
124
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
'abstract',
|
|
128
|
-
'inheritance',
|
|
129
|
-
'description',
|
|
130
|
-
'extends',
|
|
131
|
-
'properties',
|
|
132
|
-
'policies',
|
|
133
|
-
'constraints',
|
|
134
|
-
]);
|
|
135
|
-
if (value.policies !== undefined)
|
|
136
|
-
assertKnownKeys(value.policies, ['read', 'traverse']);
|
|
137
|
-
if (value.constraints !== undefined)
|
|
138
|
-
assertKnownKeys(value.constraints, ['noSelf', 'acyclic']);
|
|
139
|
-
}
|
|
140
|
-
function validateUndirectedEdgeClassOptions(value) {
|
|
141
|
-
assertKnownKeys(value, [
|
|
142
|
-
'abstract',
|
|
143
|
-
'inheritance',
|
|
144
|
-
'description',
|
|
145
|
-
'extends',
|
|
146
|
-
'properties',
|
|
147
|
-
'policies',
|
|
148
|
-
'constraints',
|
|
149
|
-
]);
|
|
125
|
+
/** Check the nested Edge Class options; the caller has checked the option keys themselves. */
|
|
126
|
+
function validateEdgeClassOptions(value, constraints) {
|
|
150
127
|
if (value.policies !== undefined)
|
|
151
128
|
assertKnownKeys(value.policies, ['read', 'traverse']);
|
|
152
129
|
if (value.constraints !== undefined)
|
|
153
|
-
assertKnownKeys(value.constraints,
|
|
130
|
+
assertKnownKeys(value.constraints, constraints);
|
|
154
131
|
}
|
|
@@ -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;
|