@astrale-os/kernel-dsl 1.0.0-beta.17 → 1.0.0-beta.19

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.
@@ -1,9 +1,9 @@
1
- import type { Value as PortableValue } from '@astrale-os/kernel-dsl/value';
1
+ import type { Array as PortableArray, Object as PortableObject, Value as PortableValue } from '@astrale-os/kernel-dsl/value';
2
2
  import type { z } from 'zod';
3
3
  import type { ClassRef } from '../../addressing/index.js';
4
4
  import type { ResolvedClass, ResolvedProperty } from '../../language/class/resolved.js';
5
5
  import type { StateTopologyOf } from '../../language/state/topology.js';
6
- import type { BlobReceipt, BlobRef, BlobSchema } from '../../language/value/model/blob.js';
6
+ import type { BLOB_VALUE_KIND, BlobReceipt, BlobRef, BlobSchema } from '../../language/value/model/blob.js';
7
7
  import type { Method, ProjectionOfCallable } from '../callable/authoring.js';
8
8
  import type { ClassProjectionOfResolved } from '../schema/projection.js';
9
9
  import type { TypedValueSchema } from '../value/schema.js';
@@ -14,8 +14,44 @@ import type { AutoProperty, Property, PropertyOptions, PropertyStateMachineOf, V
14
14
  type ExactEndpointInput<Input, Shape> = Input & Record<Exclude<keyof Input, keyof Shape>, never>;
15
15
  type PropertySchemaOf<Field> = Field extends AutoProperty<infer Value> ? PropertySchemaOf<Value> : Field extends Property<infer Schema, PropertyOptions, unknown> ? Schema : Field;
16
16
  type PropertyOptionsOf<Field> = Field extends AutoProperty<infer Value> ? PropertyOptionsOf<Value> : Field extends Property<ValueSchemaInput, infer Options, unknown> ? Options : Record<never, never>;
17
- type ValueInputOf<Schema> = Schema extends BlobSchema ? BlobReceipt : Schema extends TypedValueSchema<infer Value> ? Value : Schema extends z.ZodType ? z.input<Schema> : PortableValue;
18
- type ValueOutputOf<Schema> = Schema extends BlobSchema ? BlobRef : Schema extends TypedValueSchema<infer Value> ? Value : Schema extends z.ZodType ? z.output<Schema> : PortableValue;
17
+ type JsonSchemaValueOf<Schema> = 0 extends 1 & Schema ? PortableValue : Schema extends {
18
+ readonly const: infer Value;
19
+ } ? JsonKnownOf<Value> : Schema extends {
20
+ readonly enum: readonly (infer Value)[];
21
+ } ? JsonKnownOf<Value> : Schema extends {
22
+ readonly anyOf: readonly (infer Branch)[];
23
+ } ? JsonSchemaValueOf<Branch> : Schema extends {
24
+ readonly oneOf: readonly (infer Branch)[];
25
+ } ? JsonSchemaValueOf<Branch> : Schema extends {
26
+ readonly type: infer Type;
27
+ } ? JsonTypeValueOf<Type, Schema> : PortableValue;
28
+ type JsonKnownOf<Value> = 0 extends 1 & Value ? PortableValue : Value;
29
+ type JsonTypeValueOf<Type, Schema> = Type extends readonly (infer Each)[] ? JsonTypeValueOf<Each, Schema> : Type extends 'string' ? string : Type extends 'number' | 'integer' ? number : Type extends 'boolean' ? boolean : Type extends 'null' ? null : Type extends 'array' ? JsonArrayValueOf<Schema> : Type extends 'object' ? JsonObjectValueOf<Schema> : PortableValue;
30
+ type JsonArrayValueOf<Schema> = 'prefixItems' extends keyof Schema ? PortableArray : Schema extends {
31
+ readonly items: infer Items;
32
+ } ? readonly JsonSchemaValueOf<Items>[] : PortableArray;
33
+ type JsonObjectValueOf<Schema> = 'patternProperties' extends keyof Schema ? PortableObject : Schema extends {
34
+ readonly properties: infer Properties extends Readonly<Record<string, unknown>>;
35
+ readonly additionalProperties: false;
36
+ } ? JsonClosedObjectOf<Properties, Schema extends {
37
+ readonly required: infer Names;
38
+ } ? Names : readonly []> : PortableObject;
39
+ type JsonListsName<Names, Name> = [Names] extends [never] ? false : Names extends readonly unknown[] ? number extends Names['length'] ? false : true extends {
40
+ [At in keyof Names]: JsonNamesExactly<Names[At], Name>;
41
+ }[number] ? true : false : false;
42
+ type JsonNamesExactly<Element, Name> = [Element] extends [never] ? false : 0 extends 1 & Element ? false : [Element] extends [Name] ? true : false;
43
+ type JsonClosedObjectOf<Properties, Names> = [keyof Properties] extends [never] ? Readonly<Record<string, never>> : {
44
+ readonly [Name in keyof Properties as JsonListsName<Names, Name> extends true ? Name : never]: JsonSchemaValueOf<Properties[Name]>;
45
+ } & {
46
+ readonly [Name in keyof Properties as JsonListsName<Names, Name> extends true ? never : Name]?: JsonSchemaValueOf<Properties[Name]>;
47
+ } extends infer Value ? {
48
+ [Name in keyof Value]: Value[Name];
49
+ } : never;
50
+ type BlobMarkedSchema = BlobSchema | {
51
+ readonly 'x-astrale-value-kind': typeof BLOB_VALUE_KIND;
52
+ };
53
+ type ValueInputOf<Schema> = Schema extends BlobMarkedSchema ? BlobReceipt : Schema extends TypedValueSchema<infer Value> ? Value : Schema extends z.ZodType ? z.input<Schema> : JsonSchemaValueOf<Schema>;
54
+ type ValueOutputOf<Schema> = Schema extends BlobMarkedSchema ? BlobRef : Schema extends TypedValueSchema<infer Value> ? Value : Schema extends z.ZodType ? z.output<Schema> : JsonSchemaValueOf<Schema>;
19
55
  type PropertyRequiredOf<Field> = PropertyOptionsOf<Field> extends {
20
56
  readonly required: infer Required extends boolean;
21
57
  } ? Required : undefined extends ValueInputOf<PropertySchemaOf<Field>> ? false : true;
@@ -114,7 +114,7 @@ export interface NodeClassInput {
114
114
  */
115
115
  export type NodeUniqueTupleInput = readonly [string, ...string[]];
116
116
  /** Members every authored Edge Class shares. */
117
- export interface EdgeClassOptions {
117
+ export interface EdgeClassCommon {
118
118
  readonly abstract?: boolean;
119
119
  /** Which Classes may extend this one; omitted, those of its own Domain only (`'internal'`). */
120
120
  readonly inheritance?: Inheritance;
@@ -138,7 +138,7 @@ export type EdgeUniqueFieldInput = 'source' | 'target' | 'slug' | {
138
138
  /** The distinct fields of one key, in any order. */
139
139
  export type EdgeUniqueTupleInput = readonly [EdgeUniqueFieldInput, ...EdgeUniqueFieldInput[]];
140
140
  /** Authored directed Edge Class. */
141
- export interface DirectedEdgeInput extends EdgeClassOptions {
141
+ export interface DirectedEdgeInput extends EdgeClassCommon {
142
142
  readonly orientation: 'directed';
143
143
  readonly source: DirectedSourceInput;
144
144
  readonly target: DirectedTargetInput;
@@ -149,12 +149,11 @@ export interface DirectedEdgeInput extends EdgeClassOptions {
149
149
  readonly unique?: readonly EdgeUniqueTupleInput[];
150
150
  }
151
151
  /** Authored undirected Edge Class. */
152
- export interface UndirectedEdgeInput extends Omit<EdgeClassOptions, 'constraints'> {
152
+ export interface UndirectedEdgeInput extends Omit<EdgeClassCommon, 'constraints'> {
153
153
  readonly orientation: 'undirected';
154
154
  readonly endpoints: readonly [IncidentEndpointInput, IncidentEndpointInput];
155
155
  readonly constraints?: {
156
156
  readonly noSelf?: true;
157
157
  };
158
158
  }
159
- export type EdgeClassCommon = EdgeClassOptions;
160
159
  export type EdgeClassInput = DirectedEdgeInput | UndirectedEdgeInput;
@@ -1,11 +1,6 @@
1
1
  import type { DefinitionKey, DefinitionRef, Key, Revision } from '../../addressing/index.js';
2
2
  import type { DomainDependency } from '../../addressing/index.js';
3
- import type { MethodOwnerKeyOf, ResolvedCallable, ResolvedFunction } from '../../language/callable/resolved.js';
4
- import type { AnyResolvedClass } from '../../language/class/resolved.js';
5
- import type { ResolvedCoreDefinition, ResolvedCoreEdge } from '../../language/core/resolved.js';
6
- import type { ResolvedPolicy } from '../../language/policy/resolved.js';
7
- import type { ResolvedDefinition, ResolvedDefinitionOf } from '../../language/resolved.js';
8
- import type { ResolvedView } from '../../language/view/resolved.js';
3
+ import type { AnyResolvedClass, MethodOwnerKeyOf, PropertyInputOf, ResolvedCallable, ResolvedCoreDefinition, ResolvedCoreEdge, ResolvedDefinition, ResolvedDefinitionOf, ResolvedFunction, ResolvedPolicy, ResolvedView } from '../../language/index.js';
9
4
  export type ClassNamespace<Classes extends Readonly<Record<string, unknown>> = Readonly<Record<string, AnyResolvedClass>>> = Readonly<Classes>;
10
5
  export type FunctionNamespace<Functions extends Readonly<Record<string, unknown>> = Readonly<Record<string, ResolvedFunction>>> = Readonly<Functions>;
11
6
  export type PolicyNamespace<Policies extends Readonly<Record<string, unknown>> = Readonly<Record<string, ResolvedPolicy>>> = Readonly<Policies>;
@@ -53,6 +48,6 @@ export type MethodOwnerOf<Work extends Domain, Method> = Extract<ClassesOf<Work>
53
48
  export type FunctionsOf<Value> = Value extends Domain<Readonly<Record<string, unknown>>, infer Functions> ? Functions : never;
54
49
  export type PoliciesOf<Value> = Value extends Domain<Readonly<Record<string, unknown>>, Readonly<Record<string, unknown>>, infer Policies> ? Policies : never;
55
50
  export type ViewsOf<Value> = Value extends Domain<Readonly<Record<string, unknown>>, Readonly<Record<string, unknown>>, Readonly<Record<string, unknown>>, infer Views> ? Views : never;
56
- export type PropertyInputFor<Class extends AnyResolvedClass> = import('../../language/class/resolved.js').PropertyInputOf<Class>;
51
+ export type PropertyInputFor<Class extends AnyResolvedClass> = PropertyInputOf<Class>;
57
52
  export type PropertyValuesFor<Class extends AnyResolvedClass> = ReturnType<Class['properties']['from']>;
58
53
  export {};
@@ -1,7 +1,6 @@
1
1
  import type { Value } from '@astrale-os/kernel-dsl/value';
2
2
  import type { Definition, Key, Revision } from '../../addressing/index.js';
3
3
  import type { DomainSchema } from '../model/schema.js';
4
- import type { ReferenceSite } from '../resolution/origins.js';
5
4
  import type { MeaningDifference } from './diff.js';
6
5
  export type Fingerprint = `sha256:${string}`;
7
6
  /**
@@ -56,7 +55,7 @@ export interface Subject {
56
55
  export interface Usage {
57
56
  readonly source: SchemaIdentity;
58
57
  readonly key?: Key;
59
- readonly relation: ReferenceSite | 'member' | 'abstract' | 'selection' | 'capability';
58
+ readonly relation: 'extends' | 'core' | 'endpoint' | 'value' | 'policy' | 'pattern' | 'member' | 'abstract' | 'selection' | 'capability';
60
59
  }
61
60
  export type Facet = 'class.reference' | 'class.inherit' | 'class.composition' | 'class.properties' | 'class.endpoints' | 'class.inheritance' | 'property' | 'property.required' | 'method.existence' | 'method.object' | 'method.inheritance' | 'method.signature' | 'function.existence' | 'function.signature' | 'policy' | 'view' | 'core';
62
61
  /** A fact about a compared facet, including unchanged facets. No admission decision is implied. */
@@ -28,7 +28,8 @@ export interface DomainSchemaIR {
28
28
  * its in-process proofs. The structure the Kernel enforces has this type, which the build checks
29
29
  * (`validation/domain.structure.typecheck.ts`), and the published JSON Schema describes it.
30
30
  */
31
- export type DomainSchemaDocument = DocumentOf<DomainSchemaIR>;
31
+ export interface DomainSchemaDocument extends DocumentOf<DomainSchemaIR> {
32
+ }
32
33
  /**
33
34
  * The JSON document a model type describes. A `Revision` and `PropertyValues` are in-process
34
35
  * proofs: the document carries them as plain text and plain values.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/kernel-dsl",
3
- "version": "1.0.0-beta.17",
3
+ "version": "1.0.0-beta.19",
4
4
  "description": "Astrale Kernel DSL - Schema authoring, inference, and IR serialization",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -79,6 +79,10 @@
79
79
  "types": "./dist/v1/schema/revision.d.ts",
80
80
  "import": "./dist/v1/schema/revision.js"
81
81
  },
82
+ "./v1/schema/values": {
83
+ "types": "./dist/v1/schema/validation/value-api.d.ts",
84
+ "import": "./dist/v1/schema/validation/value-api.js"
85
+ },
82
86
  "./v1/schema/domain-schema.schema.json": "./dist/v1/schema/.spec/schemas/domain-schema.schema.json",
83
87
  "./v1/schema/value-schema.schema.json": "./dist/v1/language/.spec/schemas/value-schema.schema.json",
84
88
  "./v1/schema/draft-2020-12.schema.json": "./dist/v1/language/.spec/schemas/draft-2020-12.schema.json",