@panproto/core 0.3.0 → 0.4.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../src/instance.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;;;;;;;;;;;GAcG;AACH,qBAAa,QAAQ;IACnB,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAE5B,4CAA4C;IAC5C,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAE9B,gBAAgB;IAChB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;gBAEf,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU;IAMpE,2CAA2C;IAC3C,MAAM,IAAI,UAAU;IAOpB,iDAAiD;IACjD,QAAQ,IAAI,wBAAwB;IAYpC,mDAAmD;IACnD,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,GAAG,QAAQ;CAInF"}
package/dist/io.d.ts ADDED
@@ -0,0 +1,65 @@
1
+ import { WasmModule } from './types.js';
2
+ import { WasmHandle } from './wasm.js';
3
+ import { BuiltSchema } from './schema.js';
4
+ import { Instance } from './instance.js';
5
+ /** Protocol names organized by category. */
6
+ export declare const PROTOCOL_CATEGORIES: Readonly<Record<string, readonly string[]>>;
7
+ /**
8
+ * Registry of I/O protocol codecs for parsing and emitting instances.
9
+ *
10
+ * Wraps a WASM-side IoRegistry handle and provides methods for
11
+ * listing protocols, parsing raw bytes into instances, and emitting
12
+ * instances back to raw format bytes.
13
+ *
14
+ * Implements `Disposable` so it can be used with `using` to automatically
15
+ * clean up the WASM resource.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const panproto = await Panproto.init();
20
+ * using registry = panproto.io();
21
+ *
22
+ * console.log(registry.protocols);
23
+ * const instance = registry.parse('graphql', schema, inputBytes);
24
+ * const output = registry.emit('graphql', schema, instance);
25
+ * ```
26
+ */
27
+ export declare class IoRegistry implements Disposable {
28
+ readonly _handle: WasmHandle;
29
+ readonly _wasm: WasmModule;
30
+ private _protocolsCache;
31
+ constructor(handle: WasmHandle, wasm: WasmModule);
32
+ /**
33
+ * List all registered protocol names.
34
+ *
35
+ * The result is cached after the first call.
36
+ */
37
+ get protocols(): readonly string[];
38
+ /** Protocol names organized by category. */
39
+ get categories(): Readonly<Record<string, readonly string[]>>;
40
+ /** Check if a protocol is registered. */
41
+ hasProtocol(name: string): boolean;
42
+ /**
43
+ * Parse raw format bytes into an Instance.
44
+ *
45
+ * @param protocolName - The protocol codec name (e.g., 'graphql', 'protobuf')
46
+ * @param schema - The schema the data conforms to
47
+ * @param input - Raw format bytes to parse
48
+ * @returns A new Instance wrapping the parsed data
49
+ * @throws {@link PanprotoError} if the protocol is not registered or parsing fails
50
+ */
51
+ parse(protocolName: string, schema: BuiltSchema, input: Uint8Array): Instance;
52
+ /**
53
+ * Emit an Instance to raw format bytes.
54
+ *
55
+ * @param protocolName - The protocol codec name (e.g., 'graphql', 'protobuf')
56
+ * @param schema - The schema the instance conforms to
57
+ * @param instance - The instance to emit
58
+ * @returns Raw format bytes
59
+ * @throws {@link PanprotoError} if the protocol is not registered or emission fails
60
+ */
61
+ emit(protocolName: string, schema: BuiltSchema, instance: Instance): Uint8Array;
62
+ /** Release the WASM-side IoRegistry resource. */
63
+ [Symbol.dispose](): void;
64
+ }
65
+ //# sourceMappingURL=io.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../src/io.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ectional transformations.
3
- *
4
- * Every migration is a lens with `get` (forward projection) and
5
- * `put` (restore from complement). This module provides Cambria-style
6
- * combinators that compose into migrations.
7
- *
8
- * @module
9
- */
1
+ import { WasmModule, LawCheckResult, LiftResult, GetResult } from './types.js';
2
+ import { WasmHandle } from './wasm.js';
3
+ import { BuiltSchema } from './schema.js';
4
+ import { Protocol } from './protocol.js';
10
5
  /** Rename a field from one name to another. */
11
6
  export interface RenameFieldCombinator {
12
7
  readonly type: 'rename-field';
@@ -113,6 +108,76 @@ export declare function compose(first: Combinator, second: Combinator): ComposeC
113
108
  * @throws If the combinators array is empty
114
109
  */
115
110
  export declare function pipeline(combinators: readonly [Combinator, ...Combinator[]]): Combinator;
111
+ /**
112
+ * A disposable handle to a WASM-side lens (migration) resource.
113
+ *
114
+ * Wraps a migration handle created via `lens_from_combinators` or
115
+ * `compose_lenses`. Provides `get`, `put`, and law-checking operations.
116
+ *
117
+ * Implements `Symbol.dispose` for use with `using` declarations.
118
+ */
119
+ export declare class LensHandle implements Disposable {
120
+ #private;
121
+ constructor(handle: WasmHandle, wasm: WasmModule);
122
+ /** The underlying WASM handle. Internal use only. */
123
+ get _handle(): WasmHandle;
124
+ /**
125
+ * Forward projection: extract the view from a record.
126
+ *
127
+ * @param record - MessagePack-encoded input record
128
+ * @returns The projected view and opaque complement bytes
129
+ * @throws {@link WasmError} if the WASM call fails
130
+ */
131
+ get(record: Uint8Array): GetResult;
132
+ /**
133
+ * Backward put: restore a full record from a modified view and complement.
134
+ *
135
+ * @param view - MessagePack-encoded (possibly modified) projected view
136
+ * @param complement - The complement from a prior `get()` call
137
+ * @returns The restored full record
138
+ * @throws {@link WasmError} if the WASM call fails
139
+ */
140
+ put(view: Uint8Array, complement: Uint8Array): LiftResult;
141
+ /**
142
+ * Check both GetPut and PutGet lens laws for an instance.
143
+ *
144
+ * @param instance - MessagePack-encoded instance data
145
+ * @returns Whether both laws hold and any violation message
146
+ * @throws {@link WasmError} if the WASM call fails
147
+ */
148
+ checkLaws(instance: Uint8Array): LawCheckResult;
149
+ /**
150
+ * Check the GetPut lens law for an instance.
151
+ *
152
+ * @param instance - MessagePack-encoded instance data
153
+ * @returns Whether the law holds and any violation message
154
+ * @throws {@link WasmError} if the WASM call fails
155
+ */
156
+ checkGetPut(instance: Uint8Array): LawCheckResult;
157
+ /**
158
+ * Check the PutGet lens law for an instance.
159
+ *
160
+ * @param instance - MessagePack-encoded instance data
161
+ * @returns Whether the law holds and any violation message
162
+ * @throws {@link WasmError} if the WASM call fails
163
+ */
164
+ checkPutGet(instance: Uint8Array): LawCheckResult;
165
+ /** Release the underlying WASM resource. */
166
+ [Symbol.dispose](): void;
167
+ }
168
+ /**
169
+ * Build a lens from combinators.
170
+ *
171
+ * Serializes the combinators to MessagePack and calls the
172
+ * `lens_from_combinators` WASM entry point.
173
+ *
174
+ * @param schema - The schema to build the lens against
175
+ * @param protocol - The protocol defining the schema theory
176
+ * @param combinators - One or more combinators to compose into a lens
177
+ * @returns A LensHandle wrapping the WASM migration resource
178
+ * @throws {@link WasmError} if the WASM call fails
179
+ */
180
+ export declare function fromCombinators(schema: BuiltSchema, protocol: Protocol, wasm: WasmModule, ...combinators: Combinator[]): LensHandle;
116
181
  /**
117
182
  * Serialize a combinator to a plain object for MessagePack encoding.
118
183
  *
@@ -1 +1 @@
1
- {"version":3,"file":"lens.d.ts","sourceRoot":"","sources":["../src/lens.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,+CAA+C;AAC/C,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,4CAA4C;AAC5C,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UA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C,QAAQ,EAAE,UAAU,GAAG,cAAc;IAejD;;;;;;OAMG;IACH,WAAW,CAAC,QAAQ,EAAE,UAAU,GAAG,cAAc;IAejD,4CAA4C;IAC5C,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAGzB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,UAAU,EAChB,GAAG,WAAW,EAAE,UAAU,EAAE,GAC3B,UAAU,CAkBZ;AAMD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiBhF"}
@@ -53,6 +53,17 @@ export declare class MigrationBuilder {
53
53
  * @returns The migration spec with all accumulated mappings
54
54
  */
55
55
  toSpec(): MigrationSpec;
56
+ /**
57
+ * Invert a bijective migration.
58
+ *
59
+ * Serializes the current mapping to MessagePack and calls the
60
+ * `invert_migration` WASM entry point. Returns a new MigrationSpec
61
+ * representing the inverted migration.
62
+ *
63
+ * @returns The inverted migration specification
64
+ * @throws {@link MigrationError} if the migration is not bijective or inversion fails
65
+ */
66
+ invert(): MigrationSpec;
56
67
  /**
57
68
  * Compile the migration for fast per-record application.
58
69
  *
@@ -1 +1 @@
1
- {"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../src/migration.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,IAAI,EACJ,UAAU,EACV,SAAS,EACT,eAAe,EACf,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,UAAU,EAAgB,MAAM,WAAW,CAAC;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;;;;;;;;;GAcG;AACH,qBAAa,gBAAgB;;gBASzB,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,WAAW,E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,MAAM,IAAI,aAAa;IAoCvB;;;;;;;;OAQG;IACH,OAAO,IAAI,iBAAiB;CAqC7B;AAED;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,UAAU;;gBAKtC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa;IAMrE,6DAA6D;IAC7D,IAAI,OAAO,IAAI,UAAU,CAExB;IAED,gEAAgE;IAChE,IAAI,IAAI,IAAI,aAAa,CAExB;IAED;;;;;;;;;OASG;IACH,IAAI,CAAC,MAAM,EAAE,OAAO,GAAG,UAAU;IAkBjC;;;;;;;;;OASG;IACH,GAAG,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS;IAuB/B;;;;;;;OAOG;IACH,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,GAAG,UAAU;IAmBtD,yDAAyD;IACzD,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAGzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,aAAa,EACnB,IAAI,EAAE,UAAU,GACf,eAAe,CA6BjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,iBAAiB,EACrB,EAAE,EAAE,iBAAiB,EACrB,IAAI,EAAE,UAAU,GACf,iBAAiB,CAgCnB"}
@@ -1,8 +1,13 @@
1
1
  import { ProtocolSpec, DiffReport } from './types.js';
2
2
  import { WasmGlueModule } from './wasm.js';
3
+ import { LensHandle } from './lens.js';
3
4
  import { Protocol } from './protocol.js';
4
5
  import { BuiltSchema } from './schema.js';
5
6
  import { MigrationBuilder, CompiledMigration } from './migration.js';
7
+ import { FullDiffReport, ValidationResult } from './check.js';
8
+ import { Instance } from './instance.js';
9
+ import { IoRegistry } from './io.js';
10
+ import { Repository } from './vcs.js';
6
11
  /**
7
12
  * The main entry point for the panproto SDK.
8
13
  *
@@ -95,6 +100,17 @@ export declare class Panproto implements Disposable {
95
100
  * @throws {@link import('./types.js').MigrationError} if composition fails
96
101
  */
97
102
  compose(m1: CompiledMigration, m2: CompiledMigration): CompiledMigration;
103
+ /**
104
+ * Compose two lenses into a single lens.
105
+ *
106
+ * The resulting lens is equivalent to applying `l1` then `l2`.
107
+ *
108
+ * @param l1 - First lens (applied first)
109
+ * @param l2 - Second lens (applied second)
110
+ * @returns A new LensHandle representing the composition
111
+ * @throws {@link import('./types.js').WasmError} if composition fails
112
+ */
113
+ composeLenses(l1: LensHandle, l2: LensHandle): LensHandle;
98
114
  /**
99
115
  * Diff two schemas and produce a compatibility report.
100
116
  *
@@ -103,6 +119,57 @@ export declare class Panproto implements Disposable {
103
119
  * @returns A diff report with changes and compatibility classification
104
120
  */
105
121
  diff(oldSchema: BuiltSchema, newSchema: BuiltSchema): DiffReport;
122
+ /** Diff two schemas using the full panproto-check engine (20+ change categories). */
123
+ diffFull(oldSchema: BuiltSchema, newSchema: BuiltSchema): FullDiffReport;
124
+ /** Normalize a schema by collapsing reference chains. Returns a new BuiltSchema. */
125
+ normalize(schema: BuiltSchema): BuiltSchema;
126
+ /** Validate a schema against its protocol's rules. */
127
+ validateSchema(schema: BuiltSchema, protocol: Protocol): ValidationResult;
128
+ /**
129
+ * Create an I/O protocol registry for parsing and emitting instances.
130
+ *
131
+ * The returned registry wraps all 77 built-in protocol codecs and
132
+ * implements `Disposable` for automatic cleanup.
133
+ *
134
+ * @returns A new IoRegistry
135
+ */
136
+ io(): IoRegistry;
137
+ /**
138
+ * Parse JSON bytes into an Instance.
139
+ *
140
+ * Convenience method that wraps `json_to_instance`.
141
+ *
142
+ * @param schema - The schema the JSON data conforms to
143
+ * @param json - JSON bytes or a JSON string
144
+ * @returns A new Instance
145
+ */
146
+ parseJson(schema: BuiltSchema, json: Uint8Array | string): Instance;
147
+ /**
148
+ * Convert an Instance to JSON bytes.
149
+ *
150
+ * Convenience method that wraps `instance_to_json`.
151
+ *
152
+ * @param schema - The schema the instance conforms to
153
+ * @param instance - The instance to convert
154
+ * @returns JSON bytes
155
+ */
156
+ toJson(schema: BuiltSchema, instance: Instance): Uint8Array;
157
+ /**
158
+ * List all built-in protocol names.
159
+ *
160
+ * Returns the names of all 76 built-in protocols supported by the
161
+ * WASM layer.
162
+ *
163
+ * @returns Array of protocol name strings
164
+ */
165
+ listProtocols(): string[];
166
+ /**
167
+ * Initialize an in-memory VCS repository.
168
+ *
169
+ * @param protocolName - The protocol name for this repository
170
+ * @returns A disposable VCS Repository
171
+ */
172
+ initRepo(protocolName: string): Repository;
106
173
  /**
107
174
  * Release all WASM resources held by this instance.
108
175
  *
@@ -1 +1 @@
1
- {"version":3,"file":"panproto.d.ts","sourceRoot":"","sources":["../src/panproto.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAc,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEvE,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EACL,QAAQ,EAGT,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EAGlB,MAAM,gBAAgB,CAAC;AAGxB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,QAAS,YAAW,UAAU;;IAIzC,OAAO;IAKP;;;;;;;;OAQG;WACU,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,GAAG,GAAG,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IAK3E;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ;IAiBhC;;;;;;OAMG;IACH,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,QAAQ;IAM5C;;;;;;OAMG;IACH,SAAS,CAAC,GAA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G;IACH,aAAa,IAAI,MAAM,EAAE;IAIzB;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU;IAI1C;;;;;OAKG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAMzB"}
@@ -1,4 +1,4 @@
1
- import { WasmModule, ProtocolSpec } from './types.js';
1
+ import { WasmModule, ProtocolSpec, EdgeRule } from './types.js';
2
2
  import { WasmHandle } from './wasm.js';
3
3
  import { SchemaBuilder } from './schema.js';
4
4
  /**
@@ -14,6 +14,12 @@ export declare class Protocol implements Disposable {
14
14
  get name(): string;
15
15
  /** The full protocol specification. */
16
16
  get spec(): ProtocolSpec;
17
+ /** The edge rules for this protocol. */
18
+ get edgeRules(): readonly EdgeRule[];
19
+ /** The constraint sorts for this protocol. */
20
+ get constraintSorts(): readonly string[];
21
+ /** The object kinds for this protocol. */
22
+ get objectKinds(): readonly string[];
17
23
  /** The WASM handle. Internal use only. */
18
24
  get _handle(): WasmHandle;
19
25
  /**
@@ -62,4 +68,24 @@ export declare const GRAPHQL_SPEC: ProtocolSpec;
62
68
  export declare const JSON_SCHEMA_SPEC: ProtocolSpec;
63
69
  /** Registry of built-in protocol specs, keyed by name. */
64
70
  export declare const BUILTIN_PROTOCOLS: ReadonlyMap<string, ProtocolSpec>;
71
+ /**
72
+ * Get the list of all built-in protocol names.
73
+ *
74
+ * Lazily fetches the full list from WASM on first call and caches it.
75
+ *
76
+ * @param wasm - The WASM module
77
+ * @returns Array of all 76 built-in protocol names
78
+ */
79
+ export declare function getProtocolNames(wasm: WasmModule): readonly string[];
80
+ /**
81
+ * Get a built-in protocol spec by name from WASM.
82
+ *
83
+ * This fetches the full protocol definition from the WASM layer,
84
+ * which includes all 76 protocols (not just the 5 hardcoded ones).
85
+ *
86
+ * @param name - The protocol name
87
+ * @param wasm - The WASM module
88
+ * @returns The protocol spec, or undefined if not found
89
+ */
90
+ export declare function getBuiltinProtocol(name: string, wasm: WasmModule): ProtocolSpec | undefined;
65
91
  //# sourceMappingURL=protocol.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAY,MAAM,YAAY,CAAC;AAErE,OAAO,EAAE,UAAU,EAAgB,MAAM,WAAW,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;GAKG;AACH,qBAAa,QAAS,YAAW,UAAU;;gBAK7B,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU;IAMpE,yBAAyB;IACzB,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,uCAAuC;IACvC,IAAI,IAAI,IAAI,YAAY,CAEvB;IAED,0CAA0C;IAC1C,IAAI,OAAO,IAAI,UAAU,CAExB;IAED;;;;OAIG;IACH,MAAM,IAAI,aAAa;IAIvB,+CAA+C;IAC/C,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAGzB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,GAAG,QAAQ,CAyB7E;AAMD;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,YAqB1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,EAAE,YAWtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,YAW3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,YAY1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,YAW9B,CAAC;AAEF,0DAA0D;AAC1D,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,CAM9D,CAAC"}
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["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iBAAiB,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,CAM9D,CAAC;AAKH;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,MAAM,EAAE,CAKpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,YAAY,GAAG,SAAS,CA2B3F"}
package/dist/schema.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { WasmModule, Vertex, Edge, HyperEdge, Constraint, VertexOptions, EdgeOptions, SchemaData } from './types.js';
2
2
  import { WasmHandle } from './wasm.js';
3
3
  import { SchemaOp } from './msgpack.js';
4
+ import { Protocol } from './protocol.js';
5
+ import { ValidationResult } from './check.js';
4
6
  /**
5
7
  * Immutable fluent builder for constructing schemas.
6
8
  *
@@ -101,6 +103,12 @@ export declare class BuiltSchema implements Disposable {
101
103
  get vertices(): Readonly<Record<string, Vertex>>;
102
104
  /** All edges in the schema. */
103
105
  get edges(): readonly Edge[];
106
+ /** @internal Create from raw handle (used by normalize). */
107
+ static _fromHandle(handle: number, data: SchemaData, _protocol: string, wasm: WasmModule): BuiltSchema;
108
+ /** Normalize this schema by collapsing reference chains. Returns a new BuiltSchema. */
109
+ normalize(): BuiltSchema;
110
+ /** Validate this schema against a protocol's rules. */
111
+ validate(protocol: Protocol): ValidationResult;
104
112
  /** Release the WASM-side schema resource. */
105
113
  [Symbol.dispose](): void;
106
114
  }
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,MAAM,EACN,IAAI,EACJ,SAAS,EACT,UAAU,EACV,aAAa,EACb,WAAW,EACX,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,UAAU,EAAgB,MAAM,WAAW,CAAC;AACrD,OAAO,KA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AkC;IAClC,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAE/C;IAED,+BAA+B;IAC/B,IAAI,KAAK,IAAI,SAAS,IAAI,EAAE,CAE3B;IAED,4DAA4D;IAC5D,MAAM,CAAC,WAAW,CAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,UAAU,GACf,WAAW;IAKd,uFAAuF;IACvF,SAAS,IAAI,WAAW;IAKxB,uDAAuD;IACvD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,gBAAgB;IAS9C,6CAA6C;IAC7C,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAGzB"}
package/dist/types.d.ts CHANGED
@@ -154,7 +154,159 @@ export interface ExistenceReport {
154
154
  readonly valid: boolean;
155
155
  readonly errors: readonly ExistenceError[];
156
156
  }
157
- /** The raw WASM module interface (10 entry points). */
157
+ /** A kind change on a vertex. */
158
+ export interface KindChange {
159
+ readonly vertexId: string;
160
+ readonly oldKind: string;
161
+ readonly newKind: string;
162
+ }
163
+ /** A constraint change on a vertex. */
164
+ export interface ConstraintChange {
165
+ readonly sort: string;
166
+ readonly oldValue: string;
167
+ readonly newValue: string;
168
+ }
169
+ /** Constraint diff for a single vertex. */
170
+ export interface ConstraintDiff {
171
+ readonly added: readonly Constraint[];
172
+ readonly removed: readonly Constraint[];
173
+ readonly changed: readonly ConstraintChange[];
174
+ }
175
+ /** Full schema diff with 20+ change categories. */
176
+ export interface FullSchemaDiff {
177
+ readonly added_vertices: readonly string[];
178
+ readonly removed_vertices: readonly string[];
179
+ readonly kind_changes: readonly KindChange[];
180
+ readonly added_edges: readonly Edge[];
181
+ readonly removed_edges: readonly Edge[];
182
+ readonly modified_constraints: Readonly<Record<string, ConstraintDiff>>;
183
+ readonly added_hyper_edges: readonly string[];
184
+ readonly removed_hyper_edges: readonly string[];
185
+ readonly modified_hyper_edges: readonly Record<string, unknown>[];
186
+ readonly added_required: Readonly<Record<string, readonly Edge[]>>;
187
+ readonly removed_required: Readonly<Record<string, readonly Edge[]>>;
188
+ readonly added_nsids: Readonly<Record<string, string>>;
189
+ readonly removed_nsids: readonly string[];
190
+ readonly changed_nsids: readonly [string, string, string][];
191
+ readonly added_variants: readonly Variant[];
192
+ readonly removed_variants: readonly Variant[];
193
+ readonly modified_variants: readonly Record<string, unknown>[];
194
+ readonly order_changes: readonly [Edge, number | null, number | null][];
195
+ readonly added_recursion_points: readonly RecursionPoint[];
196
+ readonly removed_recursion_points: readonly RecursionPoint[];
197
+ readonly modified_recursion_points: readonly Record<string, unknown>[];
198
+ readonly usage_mode_changes: readonly [Edge, UsageMode, UsageMode][];
199
+ readonly added_spans: readonly string[];
200
+ readonly removed_spans: readonly string[];
201
+ readonly modified_spans: readonly Record<string, unknown>[];
202
+ readonly nominal_changes: readonly [string, boolean, boolean][];
203
+ }
204
+ /** A breaking change detected by the compatibility checker. */
205
+ export interface BreakingChange {
206
+ readonly type: string;
207
+ readonly details: Record<string, unknown>;
208
+ }
209
+ /** A non-breaking change detected by the compatibility checker. */
210
+ export interface NonBreakingChange {
211
+ readonly type: string;
212
+ readonly details: Record<string, unknown>;
213
+ }
214
+ /** Compatibility report from classifying a schema diff. */
215
+ export interface CompatReportData {
216
+ readonly breaking: readonly BreakingChange[];
217
+ readonly non_breaking: readonly NonBreakingChange[];
218
+ readonly compatible: boolean;
219
+ }
220
+ /** A schema validation error. */
221
+ export interface SchemaValidationIssue {
222
+ readonly type: string;
223
+ readonly [key: string]: unknown;
224
+ }
225
+ /** A parameter of a dependent sort. */
226
+ export interface SortParam {
227
+ readonly name: string;
228
+ readonly sort: string;
229
+ }
230
+ /** A sort declaration in a GAT. */
231
+ export interface Sort {
232
+ readonly name: string;
233
+ readonly params: readonly SortParam[];
234
+ }
235
+ /** A GAT operation (term constructor). */
236
+ export interface GatOperation {
237
+ readonly name: string;
238
+ readonly inputs: readonly [string, string][];
239
+ readonly output: string;
240
+ }
241
+ /** A term in a GAT expression. */
242
+ export type Term = {
243
+ readonly Var: string;
244
+ } | {
245
+ readonly App: {
246
+ readonly op: string;
247
+ readonly args: readonly Term[];
248
+ };
249
+ };
250
+ /** An equation (axiom) in a GAT. */
251
+ export interface Equation {
252
+ readonly name: string;
253
+ readonly lhs: Term;
254
+ readonly rhs: Term;
255
+ }
256
+ /** A theory specification. */
257
+ export interface TheorySpec {
258
+ readonly name: string;
259
+ readonly extends: readonly string[];
260
+ readonly sorts: readonly Sort[];
261
+ readonly ops: readonly GatOperation[];
262
+ readonly eqs: readonly Equation[];
263
+ }
264
+ /** A theory morphism (structure-preserving map between theories). */
265
+ export interface TheoryMorphism {
266
+ readonly name: string;
267
+ readonly domain: string;
268
+ readonly codomain: string;
269
+ readonly sort_map: Readonly<Record<string, string>>;
270
+ readonly op_map: Readonly<Record<string, string>>;
271
+ }
272
+ /** Result of checking a morphism. */
273
+ export interface MorphismCheckResult {
274
+ readonly valid: boolean;
275
+ readonly error: string | null;
276
+ }
277
+ /** Branded handle for a theory resource. */
278
+ export interface TheoryHandle extends Handle {
279
+ readonly __kind: 'theory';
280
+ }
281
+ /** Branded handle for a VCS repository resource. */
282
+ export interface VcsRepoHandle extends Handle {
283
+ readonly __kind: 'vcs-repo';
284
+ }
285
+ /** A VCS commit log entry. */
286
+ export interface VcsLogEntry {
287
+ readonly message: string;
288
+ readonly author: string;
289
+ readonly timestamp: number;
290
+ readonly protocol: string;
291
+ }
292
+ /** VCS repository status. */
293
+ export interface VcsStatus {
294
+ readonly branch: string | null;
295
+ readonly head_commit: string | null;
296
+ }
297
+ /** VCS operation result. */
298
+ export interface VcsOpResult {
299
+ readonly success: boolean;
300
+ readonly message: string;
301
+ }
302
+ /** VCS blame result. */
303
+ export interface VcsBlameResult {
304
+ readonly commit_id: string;
305
+ readonly author: string;
306
+ readonly timestamp: number;
307
+ readonly message: string;
308
+ }
309
+ /** The raw WASM module interface. */
158
310
  export interface WasmExports {
159
311
  define_protocol(spec: Uint8Array): number;
160
312
  build_schema(proto: number, ops: Uint8Array): number;
@@ -166,12 +318,62 @@ export interface WasmExports {
166
318
  compose_migrations(m1: number, m2: number): number;
167
319
  diff_schemas(s1: number, s2: number): Uint8Array;
168
320
  free_handle(handle: number): void;
321
+ diff_schemas_full(s1: number, s2: number): Uint8Array;
322
+ classify_diff(proto: number, diff_bytes: Uint8Array): Uint8Array;
323
+ report_text(report_bytes: Uint8Array): string;
324
+ report_json(report_bytes: Uint8Array): string;
325
+ normalize_schema(schema: number): number;
326
+ validate_schema(schema: number, proto: number): Uint8Array;
327
+ register_io_protocols(): number;
328
+ list_io_protocols(registry: number): Uint8Array;
329
+ parse_instance(registry: number, proto_name: Uint8Array, schema: number, input: Uint8Array): Uint8Array;
330
+ emit_instance(registry: number, proto_name: Uint8Array, schema: number, instance: Uint8Array): Uint8Array;
331
+ validate_instance(schema: number, instance: Uint8Array): Uint8Array;
332
+ instance_to_json(schema: number, instance: Uint8Array): Uint8Array;
333
+ json_to_instance(schema: number, json: Uint8Array): Uint8Array;
334
+ instance_element_count(instance: Uint8Array): number;
335
+ lens_from_combinators(schema: number, proto: number, combinators: Uint8Array): number;
336
+ check_lens_laws(migration: number, instance: Uint8Array): Uint8Array;
337
+ check_get_put(migration: number, instance: Uint8Array): Uint8Array;
338
+ check_put_get(migration: number, instance: Uint8Array): Uint8Array;
339
+ invert_migration(mapping: Uint8Array, src: number, tgt: number): Uint8Array;
340
+ compose_lenses(l1: number, l2: number): number;
341
+ list_builtin_protocols(): Uint8Array;
342
+ get_builtin_protocol(name: Uint8Array): Uint8Array;
343
+ create_theory(spec: Uint8Array): number;
344
+ colimit_theories(t1: number, t2: number, shared: number): number;
345
+ check_morphism(morphism: Uint8Array, domain: number, codomain: number): Uint8Array;
346
+ migrate_model(model: Uint8Array, morphism: Uint8Array): Uint8Array;
347
+ vcs_init(protocol_name: Uint8Array): number;
348
+ vcs_add(repo: number, schema: number): Uint8Array;
349
+ vcs_commit(repo: number, message: Uint8Array, author: Uint8Array): Uint8Array;
350
+ vcs_log(repo: number, count: number): Uint8Array;
351
+ vcs_status(repo: number): Uint8Array;
352
+ vcs_diff(repo: number): Uint8Array;
353
+ vcs_branch(repo: number, name: Uint8Array): Uint8Array;
354
+ vcs_checkout(repo: number, target: Uint8Array): Uint8Array;
355
+ vcs_merge(repo: number, branch: Uint8Array): Uint8Array;
356
+ vcs_stash(repo: number): Uint8Array;
357
+ vcs_stash_pop(repo: number): Uint8Array;
358
+ vcs_blame(repo: number, vertex: Uint8Array): Uint8Array;
359
+ }
360
+ /** Result of checking a lens law (GetPut or PutGet). */
361
+ export interface LawCheckResult {
362
+ readonly holds: boolean;
363
+ readonly violation: string | null;
169
364
  }
170
365
  /** WASM module wrapper including exports and memory. */
171
366
  export interface WasmModule {
172
367
  readonly exports: WasmExports;
173
368
  readonly memory: WebAssembly.Memory;
174
369
  }
370
+ /** Instance shape discriminator. */
371
+ export type InstanceShape = 'wtype' | 'functor' | 'graph';
372
+ /** Validation result for an instance. */
373
+ export interface InstanceValidationResult {
374
+ readonly isValid: boolean;
375
+ readonly errors: readonly string[];
376
+ }
175
377
  /** Base error class for all panproto errors. */
176
378
  export declare class PanprotoError extends Error {
177
379
  readonly name: string;