constructa-schema 2.3.0 → 2.4.1

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/README.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  Portable generator definitions, versioned generator documents, validation schemas, and related types shared by every Constructa interface.
4
4
 
5
+ ## Example
6
+
7
+ Validate an untrusted, versioned document before saving or passing it to an
8
+ execution layer.
9
+
10
+ ```ts
11
+ import { parseDocument } from "jsr:@constructa/schema";
12
+
13
+ const document = parseDocument({
14
+ schemaVersion: 1,
15
+ name: "Adult age",
16
+ definition: { type: "integer", min: 18, max: 65 },
17
+ });
18
+ ```
19
+
5
20
  ## Portable data constraint
6
21
 
7
22
  Documents and definitions are JSON-only data. Supported values are strings, booleans, `null`, finite numbers other than negative zero, arrays, and plain object records whose properties are all JSON values. Functions, symbols, bigints, `NaN`, infinities, cyclic objects, sparse arrays, custom `toJSON` behavior, class instances, maps, sets, dates, accessors, symbol keys, and non-enumerable properties are rejected.
@@ -31,6 +46,8 @@ A `GeneratorDocumentV1` wraps exactly one root definition and carries versioning
31
46
 
32
47
  Use `parseDocument` to validate and obtain a `GeneratorDocumentV1`, or `safeParseDocument` for a non-throwing parse result. Use `isGeneratorDefinition` or `assertGeneratorDefinition` when validating an unwrapped definition.
33
48
 
49
+ `parseDocument` dispatches only supported schema versions and never migrates input implicitly. Unsupported versions throw `UNSUPPORTED_SCHEMA_VERSION` at `schemaVersion`. To migrate an older portable document deliberately, call `migrateDocument(value, { from, to, migrate })`; the migration receives a JSON copy, and its result is validated through the target version parser.
50
+
34
51
  Use `serializeDefinition()` or `serializeDocument()` when stable JSON text is needed for storage, review, or diffs. Both validate their input through the same schema boundary and emit two-space JSON with recursively sorted object keys and one trailing newline. The serialized text remains ordinary JSON and round-trips through `JSON.parse`; generated values are not documents and cannot be serialized as one.
35
52
 
36
53
  ## Validation issues
package/dist/index.d.ts CHANGED
@@ -1,22 +1,34 @@
1
1
  //#region src/index.d.ts
2
+ /** A JSON scalar value supported by Constructa documents. */
2
3
  type JsonPrimitive = boolean | null | number | string;
4
+ /** Any portable JSON value supported by Constructa documents. */
3
5
  type JsonValue = JsonArray | JsonObject | JsonPrimitive;
6
+ /** A readonly array of portable JSON values. */
4
7
  type JsonArray = readonly JsonValue[];
8
+ /** A readonly string-keyed record of portable JSON values. */
5
9
  type JsonObject = {
6
10
  readonly [key: string]: JsonValue;
7
11
  };
12
+ /** One property or array-index segment in a validation path. */
8
13
  type ValidationPathSegment = string | number;
14
+ /** The location of a validation issue inside a portable value. */
9
15
  type ValidationPath = readonly ValidationPathSegment[];
16
+ /** A stable, machine-readable validation failure. */
10
17
  type ValidationIssue = {
11
18
  readonly code: string;
12
19
  readonly path: ValidationPath;
13
20
  readonly message: string;
14
21
  readonly details?: JsonObject;
15
22
  };
23
+ /** The supported categories for safe Constructa errors. */
16
24
  declare const CONSTRUCTA_ERROR_KINDS: readonly ["configuration", "dependency", "execution", "system"];
25
+ /** A supported category for a safe Constructa error. */
17
26
  type ConstructaErrorKind = (typeof CONSTRUCTA_ERROR_KINDS)[number];
27
+ /** Error codes reserved by Constructa's public error contract. */
18
28
  declare const RESERVED_CONSTRUCTA_ERROR_CODES: readonly ["INVALID_RANGE", "EMPTY_CHOICE", "INVALID_LENGTH", "UNKNOWN_GENERATOR", "REFERENCE_NOT_FOUND", "CIRCULAR_REFERENCE", "EXECUTION_FAILED", "UNSUPPORTED_SCHEMA_VERSION", "INVALID_CONFIGURATION", "INVALID_JSON_VALUE"];
29
+ /** An uppercase, stable error code. */
19
30
  type ConstructaErrorCode = Uppercase<string>;
31
+ /** Data used to construct a safe Constructa error. */
20
32
  type ConstructaErrorOptions = {
21
33
  readonly kind: ConstructaErrorKind;
22
34
  readonly code: ConstructaErrorCode;
@@ -24,6 +36,7 @@ type ConstructaErrorOptions = {
24
36
  readonly message: string;
25
37
  readonly details?: JsonObject;
26
38
  };
39
+ /** The serializable representation of a Constructa error. */
27
40
  type SafeConstructaError = ConstructaErrorOptions;
28
41
  /** A safe, serializable error shared by every Constructa surface. */
29
42
  declare class ConstructaError extends TypeError {
@@ -37,10 +50,15 @@ declare class ConstructaError extends TypeError {
37
50
  toJSON(): SafeConstructaError;
38
51
  hasCause(): boolean;
39
52
  }
53
+ /** Creates a known safe error without retaining an underlying cause. */
40
54
  declare function createConstructaError(options: ConstructaErrorOptions): ConstructaError;
55
+ /** Returns a Constructa error, wrapping an unknown cause when necessary. */
41
56
  declare function normalizeConstructaError(cause: unknown, options: ConstructaErrorOptions): ConstructaError;
57
+ /** The schema version emitted by this release. */
42
58
  declare const CURRENT_SCHEMA_VERSION = 1;
59
+ /** All document schema versions accepted by this release. */
43
60
  declare const SUPPORTED_SCHEMA_VERSIONS: readonly [1];
61
+ /** A supported document schema version. */
44
62
  type SchemaVersion = (typeof SUPPORTED_SCHEMA_VERSIONS)[number];
45
63
  declare const generatorOutput: unique symbol;
46
64
  /**
@@ -51,6 +69,7 @@ type GeneratorDefinition<Output = unknown> = JsonObject & {
51
69
  readonly type: string;
52
70
  readonly [generatorOutput]?: Output;
53
71
  };
72
+ /** Infers a generator definition's output type. */
54
73
  type Infer<Definition> = Definition extends GeneratorDefinition<infer Output> ? Output : never;
55
74
  /** Versioned document containing exactly one root generator definition. */
56
75
  type GeneratorDocumentV1 = {
@@ -59,14 +78,22 @@ type GeneratorDocumentV1 = {
59
78
  readonly name?: string;
60
79
  readonly description?: string;
61
80
  };
81
+ /** A document in any schema version currently supported by Constructa. */
62
82
  type GeneratorDocument = GeneratorDocumentV1;
83
+ /** An explicit one-step migration into a supported document schema version. */
84
+ type DocumentMigration = {
85
+ readonly from: number;
86
+ readonly to: SchemaVersion;
87
+ readonly migrate: (document: JsonObject) => unknown;
88
+ };
89
+ /** Reusable portable definitions for serialization and integration fixtures. */
63
90
  /** Reusable portable definitions for serialization and integration fixtures. */
64
91
  declare const SERIALIZATION_DEFINITION_FIXTURES: readonly GeneratorDefinition[];
65
92
  /** Reusable versioned documents for serialization and integration fixtures. */
66
93
  declare const SERIALIZATION_DOCUMENT_FIXTURES: readonly GeneratorDocumentV1[];
67
- /** A stable, lowercase identifier used to classify portable metadata. */
94
+ /** A stable, lowercase identifier used by generator metadata. */
68
95
  type SemanticMetadataId = string;
69
- /** A coarse output-preview classification, not an execution or inference type. */
96
+ /** A coarse semantic category for a generator's output. */
70
97
  type GeneratorOutputCategory = SemanticMetadataId;
71
98
  /**
72
99
  * Portable, descriptive metadata for a generator implementation.
@@ -81,9 +108,13 @@ type GeneratorMetadata = {
81
108
  readonly documentationUrl?: string;
82
109
  readonly examples?: readonly JsonValue[];
83
110
  };
111
+ /** The allowed top-level keys of a versioned generator document. */
84
112
  declare const GENERATOR_DOCUMENT_TOP_LEVEL_KEYS: readonly ["schemaVersion", "name", "description", "definition"];
113
+ /** The allowed keys of portable generator metadata. */
85
114
  declare const GENERATOR_METADATA_KEYS: readonly ["typeId", "displayName", "description", "category", "outputCategory", "documentationUrl", "examples"];
115
+ /** Codes emitted when a document schema version cannot be accepted. */
86
116
  type SchemaVersionFailureCode = "schema_version_missing" | "schema_version_unsupported";
117
+ /** Details of an unsupported or missing schema-version failure. */
87
118
  type SchemaVersionFailure = {
88
119
  readonly code: SchemaVersionFailureCode;
89
120
  readonly message: string;
@@ -93,27 +124,34 @@ type SchemaVersionFailure = {
93
124
  readonly supportedVersions: readonly SchemaVersion[];
94
125
  };
95
126
  } & ValidationIssue;
127
+ /** Codes emitted while validating a generator definition. */
96
128
  type GeneratorDefinitionFailureCode = "generator_definition_not_json" | "generator_definition_not_object" | "generator_type_missing" | "generator_type_invalid" | "definition_document_metadata";
129
+ /** Details of a generator-definition validation failure. */
97
130
  type GeneratorDefinitionFailure = {
98
131
  readonly code: GeneratorDefinitionFailureCode;
99
132
  readonly message: string;
100
133
  readonly path: ValidationPath;
101
134
  readonly severity: "error";
102
135
  };
136
+ /** Codes emitted while validating portable generator metadata. */
103
137
  type GeneratorMetadataFailureCode = "generator_metadata_not_json" | "generator_metadata_not_object" | "metadata_type_id_invalid" | "metadata_display_name_invalid" | "metadata_description_invalid" | "metadata_category_invalid" | "metadata_output_category_invalid" | "metadata_documentation_url_invalid" | "metadata_examples_invalid" | "metadata_property_unknown";
138
+ /** Details of a generator-metadata validation failure. */
104
139
  type GeneratorMetadataFailure = {
105
140
  readonly code: GeneratorMetadataFailureCode;
106
141
  readonly message: string;
107
142
  readonly path: ValidationPath;
108
143
  readonly severity: "error";
109
144
  };
145
+ /** Codes emitted while validating a versioned generator document. */
110
146
  type GeneratorDocumentFailureCode = SchemaVersionFailureCode | GeneratorDefinitionFailureCode | "generator_document_not_json" | "generator_document_not_object" | "definition_missing" | "name_invalid" | "description_invalid" | "top_level_property_unknown" | "configuration_envelope_removed";
147
+ /** Details of a generator-document validation failure. */
111
148
  type GeneratorDocumentFailure = SchemaVersionFailure | {
112
149
  readonly code: Exclude<GeneratorDocumentFailureCode, SchemaVersionFailureCode>;
113
150
  readonly message: string;
114
151
  readonly path: ValidationPath;
115
152
  readonly severity: "error";
116
153
  };
154
+ /** The success-or-failure result returned by `safeParseDocument`. */
117
155
  type GeneratorDocumentParseResult = {
118
156
  readonly success: true;
119
157
  readonly value: GeneratorDocumentV1;
@@ -121,38 +159,60 @@ type GeneratorDocumentParseResult = {
121
159
  readonly success: false;
122
160
  readonly failure: GeneratorDocumentFailure;
123
161
  };
162
+ /** Thrown when a value cannot be represented as portable JSON. */
124
163
  declare class JsonValueError extends ConstructaError {
125
164
  readonly issue: ValidationIssue;
126
165
  constructor(path: ValidationPath, reason: string);
127
166
  }
167
+ /** Thrown when a document's schema version is unsupported. */
128
168
  declare class SchemaVersionError extends ConstructaError {
129
169
  readonly failure: SchemaVersionFailure;
130
170
  constructor(failure: SchemaVersionFailure);
131
171
  }
172
+ /** Thrown when a generator definition is invalid. */
132
173
  declare class GeneratorDefinitionError extends ConstructaError {
133
174
  readonly failure: GeneratorDefinitionFailure;
134
175
  constructor(failure: GeneratorDefinitionFailure);
135
176
  }
177
+ /** Thrown when portable generator metadata is invalid. */
136
178
  declare class GeneratorMetadataError extends ConstructaError {
137
179
  readonly failure: GeneratorMetadataFailure;
138
180
  constructor(failure: GeneratorMetadataFailure);
139
181
  }
182
+ /** Thrown when a versioned generator document is invalid. */
140
183
  declare class GeneratorDocumentError extends ConstructaError {
141
184
  readonly failure: GeneratorDocumentFailure;
142
185
  constructor(failure: GeneratorDocumentFailure);
143
186
  }
187
+ /** Returns whether a value is portable JSON. */
144
188
  declare function isJsonValue(value: unknown): value is JsonValue;
189
+ /** Returns whether a value is a schema version supported by this release. */
145
190
  declare function isSchemaVersion(value: unknown): value is SchemaVersion;
191
+ /** Returns whether a value is a valid portable generator definition. */
146
192
  declare function isGeneratorDefinition(value: unknown): value is GeneratorDefinition;
193
+ /** Returns whether a value is a valid current generator document. */
147
194
  declare function isDocument(value: unknown): value is GeneratorDocumentV1;
195
+ /** Returns whether a value is valid portable generator metadata. */
148
196
  declare function isGeneratorMetadata(value: unknown): value is GeneratorMetadata;
197
+ /** Asserts that a value is portable JSON. */
149
198
  declare function assertJsonValue(value: unknown, path?: ValidationPath): asserts value is JsonValue;
199
+ /** Asserts that a value is a supported schema version. */
150
200
  declare function assertSchemaVersion(value: unknown, path?: ValidationPath): asserts value is SchemaVersion;
201
+ /** Asserts that a value is a valid portable generator definition. */
151
202
  declare function assertGeneratorDefinition(value: unknown, path?: ValidationPath): asserts value is GeneratorDefinition;
203
+ /** Asserts that a value is valid portable generator metadata. */
152
204
  declare function assertGeneratorMetadata(value: unknown, path?: ValidationPath): asserts value is GeneratorMetadata;
205
+ /** Asserts that a value is a valid current generator document. */
153
206
  declare function assertDocument(value: unknown, path?: ValidationPath): asserts value is GeneratorDocumentV1;
207
+ /** Parses a document or throws its first validation failure. */
154
208
  declare function parseDocument(value: unknown, path?: ValidationPath): GeneratorDocumentV1;
209
+ /** Validates a document without throwing. */
155
210
  declare function safeParseDocument(value: unknown, path?: ValidationPath): GeneratorDocumentParseResult;
211
+ /**
212
+ * Applies one declared migration and validates its result through the normal
213
+ * version parser. Migrations are never applied implicitly by `parseDocument`.
214
+ */
215
+ declare function migrateDocument(value: unknown, migration: DocumentMigration): GeneratorDocumentV1;
156
216
  /**
157
217
  * Serializes a portable definition with recursively sorted object keys and a
158
218
  * trailing newline. The result is intended for stable diffs, not execution.
@@ -160,12 +220,14 @@ declare function safeParseDocument(value: unknown, path?: ValidationPath): Gener
160
220
  declare function serializeDefinition(value: unknown): string;
161
221
  /** Serializes a validated versioned document using the same canonical format. */
162
222
  declare function serializeDocument(value: unknown): string;
223
+ /** Returns the validation issue when a value is not portable JSON. */
163
224
  declare function validateJsonValue(value: unknown, path?: ValidationPath): readonly ValidationIssue[];
164
225
  /** Returns all independent document validation issues in deterministic order. */
165
226
  declare function validateDocument(value: unknown, path?: ValidationPath): readonly GeneratorDocumentFailure[];
166
227
  /** Returns definition issues. Nested typed definitions are validated recursively. */
167
228
  declare function validateGeneratorDefinition(value: unknown, path?: ValidationPath): readonly GeneratorDefinitionFailure[];
229
+ /** Returns metadata validation failures without throwing. */
168
230
  declare function validateGeneratorMetadata(value: unknown, path?: ValidationPath): readonly GeneratorMetadataFailure[];
169
231
  //#endregion
170
- export { CONSTRUCTA_ERROR_KINDS, CURRENT_SCHEMA_VERSION, ConstructaError, ConstructaErrorCode, ConstructaErrorKind, ConstructaErrorOptions, GENERATOR_DOCUMENT_TOP_LEVEL_KEYS, GENERATOR_METADATA_KEYS, GeneratorDefinition, GeneratorDefinitionError, GeneratorDefinitionFailure, GeneratorDefinitionFailureCode, GeneratorDocument, GeneratorDocumentError, GeneratorDocumentFailure, GeneratorDocumentFailureCode, GeneratorDocumentParseResult, GeneratorDocumentV1, GeneratorMetadata, GeneratorMetadataError, GeneratorMetadataFailure, GeneratorMetadataFailureCode, GeneratorOutputCategory, Infer, JsonArray, JsonObject, JsonPrimitive, JsonValue, JsonValueError, RESERVED_CONSTRUCTA_ERROR_CODES, SERIALIZATION_DEFINITION_FIXTURES, SERIALIZATION_DOCUMENT_FIXTURES, SUPPORTED_SCHEMA_VERSIONS, SafeConstructaError, SchemaVersion, SchemaVersionError, SchemaVersionFailure, SchemaVersionFailureCode, SemanticMetadataId, ValidationIssue, ValidationPath, ValidationPathSegment, assertDocument, assertGeneratorDefinition, assertGeneratorMetadata, assertJsonValue, assertSchemaVersion, createConstructaError, isDocument, isGeneratorDefinition, isGeneratorMetadata, isJsonValue, isSchemaVersion, normalizeConstructaError, parseDocument, safeParseDocument, serializeDefinition, serializeDocument, validateDocument, validateGeneratorDefinition, validateGeneratorMetadata, validateJsonValue };
232
+ export { CONSTRUCTA_ERROR_KINDS, CURRENT_SCHEMA_VERSION, ConstructaError, ConstructaErrorCode, ConstructaErrorKind, ConstructaErrorOptions, DocumentMigration, GENERATOR_DOCUMENT_TOP_LEVEL_KEYS, GENERATOR_METADATA_KEYS, GeneratorDefinition, GeneratorDefinitionError, GeneratorDefinitionFailure, GeneratorDefinitionFailureCode, GeneratorDocument, GeneratorDocumentError, GeneratorDocumentFailure, GeneratorDocumentFailureCode, GeneratorDocumentParseResult, GeneratorDocumentV1, GeneratorMetadata, GeneratorMetadataError, GeneratorMetadataFailure, GeneratorMetadataFailureCode, GeneratorOutputCategory, Infer, JsonArray, JsonObject, JsonPrimitive, JsonValue, JsonValueError, RESERVED_CONSTRUCTA_ERROR_CODES, SERIALIZATION_DEFINITION_FIXTURES, SERIALIZATION_DOCUMENT_FIXTURES, SUPPORTED_SCHEMA_VERSIONS, SafeConstructaError, SchemaVersion, SchemaVersionError, SchemaVersionFailure, SchemaVersionFailureCode, SemanticMetadataId, ValidationIssue, ValidationPath, ValidationPathSegment, assertDocument, assertGeneratorDefinition, assertGeneratorMetadata, assertJsonValue, assertSchemaVersion, createConstructaError, isDocument, isGeneratorDefinition, isGeneratorMetadata, isJsonValue, isSchemaVersion, migrateDocument, normalizeConstructaError, parseDocument, safeParseDocument, serializeDefinition, serializeDocument, validateDocument, validateGeneratorDefinition, validateGeneratorMetadata, validateJsonValue };
171
233
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";KAAY;KACA,YAAY,YAAY,aAAa;KACrC,qBAAqB;KACrB;YAAyB,cAAc;;KAEvC;KACA,0BAA0B;KAC1B;WACD;WACA,MAAM;WACN;WACA,UAAU;;cAGR;KAMD,8BAA8B;cAE7B;KAYD,sBAAsB;KAEtB;WACD,MAAM;WACN,MAAM;WACN,MAAM;WACN;WACA,UAAU;;KAGT,sBAAsB;;cAGrB,wBAAwB;;WAC1B,MAAM;WACN,MAAM;WACN,MAAM;WACN,UAAU;EAGP,YAAA,SAAS,wBAAwB;;EAY7C,UAAU;EAiBV;;iBAKc,sBACd,SAAS,yBACR;iBAIa,yBACd,gBACA,SAAS,yBACR;cAMU;cACA;KACD,wBAAwB;cAEtB;;;;;KAMF,oBAAoB,oBAAoB;WACzC;YACC,mBAAmB;;KAGnB,MAAM,cAChB,mBAAmB,0BAA0B,UAAU;;KAG7C;WACD;WACA,YAAY;WACZ;WACA;;KAGC,oBAAoB;;cAGnB,4CAA4C;;cAiB5C,0CAA0C;;KAe3C;;KAGA,0BAA0B;;;;;KAM1B;WACD,SAAS;WACT;WACA;WACA,WAAW;WACX,iBAAiB;WACjB;WACA,oBAAoB;;cAGlB;cAOA;KAsBD;KAGA;WACD,MAAM;WACN;WACA,MAAM;WACN;WACA;aAAoB,4BAA4B;;IACvD;KAEQ;KAMA;WACD,MAAM;WACN;WACA,MAAM;WACN;;KAGC;KAWA;WACD,MAAM;WACN;WACA,MAAM;WACN;;KAGC,+BACR,2BACA;KAQQ,2BACR;WAEW,MAAM,QACb,8BACA;WAEO;WACA,MAAM;WACN;;KAEH;WACG;WAAwB,OAAO;;WAC/B;WAAyB,SAAS;;cAEpC,uBAAuB;WACzB,OAAO;EACJ,YAAA,MAAM,gBAAgB;;cAavB,2BAA2B;WAC7B,SAAS;EACN,YAAA,SAAS;;cAaV,iCAAiC;WACnC,SAAS;EACN,YAAA,SAAS;;cAaV,+BAA+B;WACjC,SAAS;EACN,YAAA,SAAS;;cAaV,+BAA+B;WACjC,SAAS;EACN,YAAA,SAAS;;iBAaP,YAAY,iBAAiB,SAAS;iBAGtC,gBAAgB,iBAAiB,SAAS;iBAG1C,sBACd,iBACC,SAAS;iBAGI,WAAW,iBAAiB,SAAS;iBAGrC,oBACd,iBACC,SAAS;iBAGI,gBACd,gBACA,OAAM,yBACG,SAAS;iBAIJ,oBACd,gBACA,OAAM,yBACG,SAAS;iBAIJ,0BACd,gBACA,OAAM,yBACG,SAAS;iBAIJ,wBACd,gBACA,OAAM,yBACG,SAAS;iBAIJ,eACd,gBACA,OAAM,yBACG,SAAS;iBAIJ,cACd,gBACA,OAAM,iBACL;iBAIa,kBACd,gBACA,OAAM,iBACL;;;;;iBAWa,oBAAoB;;iBAMpB,kBAAkB;iBAqBlB,kBACd,gBACA,OAAM,0BACI;;iBAeI,iBACd,gBACA,OAAM,0BACI;;iBA8DI,4BACd,gBACA,OAAM,0BACI;iBAmBI,0BACd,gBACA,OAAM,0BACI"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;KACY;;KAEA,YAAY,YAAY,aAAa;;KAErC,qBAAqB;;KAErB;YAAyB,cAAc;;;KAGvC;;KAEA,0BAA0B;;KAE1B;WACD;WACA,MAAM;WACN;WACA,UAAU;;;cAIR;;KAOD,8BAA8B;;cAG7B;;KAaD,sBAAsB;;KAGtB;WACD,MAAM;WACN,MAAM;WACN,MAAM;WACN;WACA,UAAU;;;KAIT,sBAAsB;;cAGrB,wBAAwB;;WAC1B,MAAM;WACN,MAAM;WACN,MAAM;WACN,UAAU;EAGP,YAAA,SAAS,wBAAwB;;EAY7C,UAAU;EAiBV;;;iBAMc,sBACd,SAAS,yBACR;;iBAKa,yBACd,gBACA,SAAS,yBACR;;cAOU;;cAEA;;KAED,wBAAwB;cAEtB;;;;;KAMF,oBAAoB,oBAAoB;WACzC;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,OAAM,iBACL;;;;;iBAWa,gBACd,gBACA,WAAW,oBACV;;;;;iBAsGa,oBAAoB;;iBAMpB,kBAAkB;;iBAsBlB,kBACd,gBACA,OAAM,0BACI;;iBAeI,iBACd,gBACA,OAAM,0BACI;;iBA8DI,4BACd,gBACA,OAAM,0BACI;;iBAoBI,0BACd,gBACA,OAAM,0BACI"}
package/dist/index.js CHANGED
@@ -1,10 +1,12 @@
1
1
  //#region src/index.ts
2
+ /** The supported categories for safe Constructa errors. */
2
3
  const CONSTRUCTA_ERROR_KINDS = [
3
4
  "configuration",
4
5
  "dependency",
5
6
  "execution",
6
7
  "system"
7
8
  ];
9
+ /** Error codes reserved by Constructa's public error contract. */
8
10
  const RESERVED_CONSTRUCTA_ERROR_CODES = [
9
11
  "INVALID_RANGE",
10
12
  "EMPTY_CHOICE",
@@ -53,15 +55,20 @@ var ConstructaError = class extends TypeError {
53
55
  return this.#cause !== void 0;
54
56
  }
55
57
  };
58
+ /** Creates a known safe error without retaining an underlying cause. */
56
59
  function createConstructaError(options) {
57
60
  return new ConstructaError(options);
58
61
  }
62
+ /** Returns a Constructa error, wrapping an unknown cause when necessary. */
59
63
  function normalizeConstructaError(cause, options) {
60
64
  return cause instanceof ConstructaError ? cause : new ConstructaError(options, cause);
61
65
  }
66
+ /** The schema version emitted by this release. */
62
67
  const CURRENT_SCHEMA_VERSION = 1;
68
+ /** All document schema versions accepted by this release. */
63
69
  const SUPPORTED_SCHEMA_VERSIONS = [1];
64
70
  /** Reusable portable definitions for serialization and integration fixtures. */
71
+ /** Reusable portable definitions for serialization and integration fixtures. */
65
72
  const SERIALIZATION_DEFINITION_FIXTURES = Object.freeze([Object.freeze({ type: "boolean" }), Object.freeze({
66
73
  type: "object",
67
74
  fields: Object.freeze({ account: Object.freeze({
@@ -86,12 +93,14 @@ const SERIALIZATION_DOCUMENT_FIXTURES = Object.freeze([Object.freeze({
86
93
  max: 100
87
94
  })
88
95
  })]);
96
+ /** The allowed top-level keys of a versioned generator document. */
89
97
  const GENERATOR_DOCUMENT_TOP_LEVEL_KEYS = [
90
98
  "schemaVersion",
91
99
  "name",
92
100
  "description",
93
101
  "definition"
94
102
  ];
103
+ /** The allowed keys of portable generator metadata. */
95
104
  const GENERATOR_METADATA_KEYS = [
96
105
  "typeId",
97
106
  "displayName",
@@ -112,6 +121,7 @@ const DOCUMENT_METADATA_KEYS = /* @__PURE__ */ new Set([
112
121
  "updatedAt",
113
122
  "timestamps"
114
123
  ]);
124
+ /** Thrown when a value cannot be represented as portable JSON. */
115
125
  var JsonValueError = class extends ConstructaError {
116
126
  issue;
117
127
  constructor(path, reason) {
@@ -130,6 +140,7 @@ var JsonValueError = class extends ConstructaError {
130
140
  };
131
141
  }
132
142
  };
143
+ /** Thrown when a document's schema version is unsupported. */
133
144
  var SchemaVersionError = class extends ConstructaError {
134
145
  failure;
135
146
  constructor(failure) {
@@ -144,6 +155,7 @@ var SchemaVersionError = class extends ConstructaError {
144
155
  this.failure = failure;
145
156
  }
146
157
  };
158
+ /** Thrown when a generator definition is invalid. */
147
159
  var GeneratorDefinitionError = class extends ConstructaError {
148
160
  failure;
149
161
  constructor(failure) {
@@ -158,6 +170,7 @@ var GeneratorDefinitionError = class extends ConstructaError {
158
170
  this.failure = failure;
159
171
  }
160
172
  };
173
+ /** Thrown when portable generator metadata is invalid. */
161
174
  var GeneratorMetadataError = class extends ConstructaError {
162
175
  failure;
163
176
  constructor(failure) {
@@ -172,6 +185,7 @@ var GeneratorMetadataError = class extends ConstructaError {
172
185
  this.failure = failure;
173
186
  }
174
187
  };
188
+ /** Thrown when a versioned generator document is invalid. */
175
189
  var GeneratorDocumentError = class extends ConstructaError {
176
190
  failure;
177
191
  constructor(failure) {
@@ -186,45 +200,56 @@ var GeneratorDocumentError = class extends ConstructaError {
186
200
  this.failure = failure;
187
201
  }
188
202
  };
203
+ /** Returns whether a value is portable JSON. */
189
204
  function isJsonValue(value) {
190
205
  return validateJsonValue(value).length === 0;
191
206
  }
207
+ /** Returns whether a value is a schema version supported by this release. */
192
208
  function isSchemaVersion(value) {
193
209
  return value === 1;
194
210
  }
211
+ /** Returns whether a value is a valid portable generator definition. */
195
212
  function isGeneratorDefinition(value) {
196
213
  return validateGeneratorDefinition(value).length === 0;
197
214
  }
215
+ /** Returns whether a value is a valid current generator document. */
198
216
  function isDocument(value) {
199
217
  return validateDocument(value).length === 0;
200
218
  }
219
+ /** Returns whether a value is valid portable generator metadata. */
201
220
  function isGeneratorMetadata(value) {
202
221
  return validateGeneratorMetadata(value).length === 0;
203
222
  }
223
+ /** Asserts that a value is portable JSON. */
204
224
  function assertJsonValue(value, path = []) {
205
225
  const [issue] = validateJsonValue(value, path);
206
226
  if (issue !== void 0) throw new JsonValueError(issue.path, issue.message);
207
227
  }
228
+ /** Asserts that a value is a supported schema version. */
208
229
  function assertSchemaVersion(value, path = ["schemaVersion"]) {
209
230
  const failure = findSchemaVersionValueFailure(value, path);
210
231
  if (failure !== void 0) throw new SchemaVersionError(failure);
211
232
  }
233
+ /** Asserts that a value is a valid portable generator definition. */
212
234
  function assertGeneratorDefinition(value, path = []) {
213
235
  const [failure] = validateGeneratorDefinition(value, path);
214
236
  if (failure !== void 0) throw new GeneratorDefinitionError(failure);
215
237
  }
238
+ /** Asserts that a value is valid portable generator metadata. */
216
239
  function assertGeneratorMetadata(value, path = []) {
217
240
  const [failure] = validateGeneratorMetadata(value, path);
218
241
  if (failure !== void 0) throw new GeneratorMetadataError(failure);
219
242
  }
243
+ /** Asserts that a value is a valid current generator document. */
220
244
  function assertDocument(value, path = []) {
221
245
  const [issue] = validateDocument(value, path);
222
246
  if (issue !== void 0) throw new GeneratorDocumentError(issue);
223
247
  }
248
+ /** Parses a document or throws its first validation failure. */
224
249
  function parseDocument(value, path = []) {
225
- assertDocument(value, path);
226
- return value;
250
+ return resolveDocumentParser(value, path)(value, path);
227
251
  }
252
+ /** Validates a document without throwing. */
228
253
  function safeParseDocument(value, path = []) {
229
254
  const [failure] = validateDocument(value, path);
230
255
  return failure === void 0 ? {
@@ -236,6 +261,66 @@ function safeParseDocument(value, path = []) {
236
261
  };
237
262
  }
238
263
  /**
264
+ * Applies one declared migration and validates its result through the normal
265
+ * version parser. Migrations are never applied implicitly by `parseDocument`.
266
+ */
267
+ function migrateDocument(value, migration) {
268
+ assertDocumentMigration(migration);
269
+ assertJsonValue(value);
270
+ if (!isJsonRecord(value)) throw new GeneratorDocumentError(documentFailure("generator_document_not_object", []));
271
+ const sourceVersion = value.schemaVersion;
272
+ if (!Number.isSafeInteger(sourceVersion) || sourceVersion !== migration.from) throw new SchemaVersionError({
273
+ code: "schema_version_unsupported",
274
+ path: ["schemaVersion"],
275
+ severity: "error",
276
+ message: `schemaVersion must be ${migration.from} before this migration.`,
277
+ details: { supportedVersions: [migration.to] }
278
+ });
279
+ const source = JSON.parse(JSON.stringify(value));
280
+ let migrated;
281
+ try {
282
+ migrated = migration.migrate(source);
283
+ } catch (cause) {
284
+ throw normalizeConstructaError(cause, {
285
+ kind: "configuration",
286
+ code: "INVALID_CONFIGURATION",
287
+ path: ["migration"],
288
+ message: "Document migration failed."
289
+ });
290
+ }
291
+ return parseDocument(migrated);
292
+ }
293
+ const DOCUMENT_PARSERS = /* @__PURE__ */ new Map([[1, parseCurrentDocument]]);
294
+ function resolveDocumentParser(value, path) {
295
+ if (!isJsonRecord(value) || !Object.hasOwn(value, "schemaVersion")) {
296
+ assertDocument(value, path);
297
+ throw new ConstructaError({
298
+ kind: "system",
299
+ code: "INVALID_CONFIGURATION",
300
+ path,
301
+ message: "Document validation unexpectedly succeeded without a schema version."
302
+ });
303
+ }
304
+ const parser = DOCUMENT_PARSERS.get(value.schemaVersion);
305
+ if (parser === void 0) {
306
+ const failure = findSchemaVersionValueFailure(value.schemaVersion, appendPathSegment(path, "schemaVersion"));
307
+ if (failure !== void 0) throw new SchemaVersionError(failure);
308
+ }
309
+ return parser ?? parseCurrentDocument;
310
+ }
311
+ function parseCurrentDocument(value, path) {
312
+ assertDocument(value, path);
313
+ return value;
314
+ }
315
+ function assertDocumentMigration(migration) {
316
+ if (typeof migration !== "object" || migration === null || !Number.isSafeInteger(migration.from) || migration.from < 0 || !isSchemaVersion(migration.to) || typeof migration.migrate !== "function") throw new ConstructaError({
317
+ kind: "configuration",
318
+ code: "INVALID_CONFIGURATION",
319
+ path: ["migration"],
320
+ message: "A migration must declare a non-negative source version, a supported target version, and a migrate function."
321
+ });
322
+ }
323
+ /**
239
324
  * Serializes a portable definition with recursively sorted object keys and a
240
325
  * trailing newline. The result is intended for stable diffs, not execution.
241
326
  */
@@ -260,6 +345,7 @@ function canonicalizeJson(value) {
260
345
  }
261
346
  return value;
262
347
  }
348
+ /** Returns the validation issue when a value is not portable JSON. */
263
349
  function validateJsonValue(value, path = []) {
264
350
  const error = findJsonValueError(value, path);
265
351
  return error === void 0 ? [] : [{
@@ -295,6 +381,7 @@ function validateGeneratorDefinition(value, path = []) {
295
381
  collectDefinitionMetadataIssues(value, path, issues, true);
296
382
  return issues;
297
383
  }
384
+ /** Returns metadata validation failures without throwing. */
298
385
  function validateGeneratorMetadata(value, path = []) {
299
386
  const failure = findGeneratorMetadataFailure(value, path);
300
387
  return failure === void 0 ? [] : [failure];
@@ -516,6 +603,6 @@ function findUnsupportedOwnProperty(value, path, allowedNonEnumerableProperties
516
603
  }
517
604
  }
518
605
  //#endregion
519
- export { CONSTRUCTA_ERROR_KINDS, CURRENT_SCHEMA_VERSION, ConstructaError, GENERATOR_DOCUMENT_TOP_LEVEL_KEYS, GENERATOR_METADATA_KEYS, GeneratorDefinitionError, GeneratorDocumentError, GeneratorMetadataError, JsonValueError, RESERVED_CONSTRUCTA_ERROR_CODES, SERIALIZATION_DEFINITION_FIXTURES, SERIALIZATION_DOCUMENT_FIXTURES, SUPPORTED_SCHEMA_VERSIONS, SchemaVersionError, assertDocument, assertGeneratorDefinition, assertGeneratorMetadata, assertJsonValue, assertSchemaVersion, createConstructaError, isDocument, isGeneratorDefinition, isGeneratorMetadata, isJsonValue, isSchemaVersion, normalizeConstructaError, parseDocument, safeParseDocument, serializeDefinition, serializeDocument, validateDocument, validateGeneratorDefinition, validateGeneratorMetadata, validateJsonValue };
606
+ export { CONSTRUCTA_ERROR_KINDS, CURRENT_SCHEMA_VERSION, ConstructaError, GENERATOR_DOCUMENT_TOP_LEVEL_KEYS, GENERATOR_METADATA_KEYS, GeneratorDefinitionError, GeneratorDocumentError, GeneratorMetadataError, JsonValueError, RESERVED_CONSTRUCTA_ERROR_CODES, SERIALIZATION_DEFINITION_FIXTURES, SERIALIZATION_DOCUMENT_FIXTURES, SUPPORTED_SCHEMA_VERSIONS, SchemaVersionError, assertDocument, assertGeneratorDefinition, assertGeneratorMetadata, assertJsonValue, assertSchemaVersion, createConstructaError, isDocument, isGeneratorDefinition, isGeneratorMetadata, isJsonValue, isSchemaVersion, migrateDocument, normalizeConstructaError, parseDocument, safeParseDocument, serializeDefinition, serializeDocument, validateDocument, validateGeneratorDefinition, validateGeneratorMetadata, validateJsonValue };
520
607
 
521
608
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["#cause"],"sources":["../src/index.ts"],"sourcesContent":["export type JsonPrimitive = boolean | null | number | string;\nexport type JsonValue = JsonArray | JsonObject | JsonPrimitive;\nexport type JsonArray = readonly JsonValue[];\nexport type JsonObject = { readonly [key: string]: JsonValue };\n\nexport type ValidationPathSegment = string | number;\nexport type ValidationPath = readonly ValidationPathSegment[];\nexport type ValidationIssue = {\n readonly code: string;\n readonly path: ValidationPath;\n readonly message: string;\n readonly details?: JsonObject;\n};\n\nexport const CONSTRUCTA_ERROR_KINDS = [\n \"configuration\",\n \"dependency\",\n \"execution\",\n \"system\",\n] as const;\nexport type ConstructaErrorKind = (typeof CONSTRUCTA_ERROR_KINDS)[number];\n\nexport const RESERVED_CONSTRUCTA_ERROR_CODES = [\n \"INVALID_RANGE\",\n \"EMPTY_CHOICE\",\n \"INVALID_LENGTH\",\n \"UNKNOWN_GENERATOR\",\n \"REFERENCE_NOT_FOUND\",\n \"CIRCULAR_REFERENCE\",\n \"EXECUTION_FAILED\",\n \"UNSUPPORTED_SCHEMA_VERSION\",\n \"INVALID_CONFIGURATION\",\n \"INVALID_JSON_VALUE\",\n] as const;\nexport type ConstructaErrorCode = Uppercase<string>;\n\nexport type ConstructaErrorOptions = {\n readonly kind: ConstructaErrorKind;\n readonly code: ConstructaErrorCode;\n readonly path: ValidationPath;\n readonly message: string;\n readonly details?: JsonObject;\n};\n\nexport type SafeConstructaError = ConstructaErrorOptions;\n\n/** A safe, serializable error shared by every Constructa surface. */\nexport class ConstructaError extends TypeError {\n readonly kind: ConstructaErrorKind;\n readonly code: ConstructaErrorCode;\n readonly path: ValidationPath;\n readonly details?: JsonObject;\n readonly #cause: unknown;\n\n constructor(options: ConstructaErrorOptions, cause?: unknown) {\n validateConstructaErrorOptions(options);\n super(options.message);\n this.name = \"ConstructaError\";\n this.kind = options.kind;\n this.code = options.code;\n this.path = options.path;\n this.details = options.details;\n this.#cause = cause;\n }\n\n /** Returns only data that is safe to send across a process or network boundary. */\n toJSON(): SafeConstructaError {\n return this.details === undefined\n ? {\n kind: this.kind,\n code: this.code,\n path: this.path,\n message: this.message,\n }\n : {\n kind: this.kind,\n code: this.code,\n path: this.path,\n message: this.message,\n details: this.details,\n };\n }\n\n hasCause(): boolean {\n return this.#cause !== undefined;\n }\n}\n\nexport function createConstructaError(\n options: ConstructaErrorOptions,\n): ConstructaError {\n return new ConstructaError(options);\n}\n\nexport function normalizeConstructaError(\n cause: unknown,\n options: ConstructaErrorOptions,\n): ConstructaError {\n return cause instanceof ConstructaError\n ? cause\n : new ConstructaError(options, cause);\n}\n\nexport const CURRENT_SCHEMA_VERSION = 1;\nexport const SUPPORTED_SCHEMA_VERSIONS = [CURRENT_SCHEMA_VERSION] as const;\nexport type SchemaVersion = (typeof SUPPORTED_SCHEMA_VERSIONS)[number];\n\ndeclare const generatorOutput: unique symbol;\n\n/**\n * Portable executable generator data. `Output` exists only to carry compile-time\n * inference and never creates a runtime property.\n */\nexport type GeneratorDefinition<Output = unknown> = JsonObject & {\n readonly type: string;\n readonly [generatorOutput]?: Output;\n};\n\nexport type Infer<Definition> =\n Definition extends GeneratorDefinition<infer Output> ? Output : never;\n\n/** Versioned document containing exactly one root generator definition. */\nexport type GeneratorDocumentV1 = {\n readonly schemaVersion: 1;\n readonly definition: GeneratorDefinition;\n readonly name?: string;\n readonly description?: string;\n};\n\nexport type GeneratorDocument = GeneratorDocumentV1;\n\n/** Reusable portable definitions for serialization and integration fixtures. */\nexport const SERIALIZATION_DEFINITION_FIXTURES: readonly GeneratorDefinition[] =\n Object.freeze([\n Object.freeze({ type: \"boolean\" }) as GeneratorDefinition,\n Object.freeze({\n type: \"object\",\n fields: Object.freeze({\n account: Object.freeze({\n type: \"object\",\n fields: Object.freeze({\n id: Object.freeze({ type: \"integer\", min: 1 }),\n }),\n }),\n }),\n }) as GeneratorDefinition,\n ]);\n\n/** Reusable versioned documents for serialization and integration fixtures. */\nexport const SERIALIZATION_DOCUMENT_FIXTURES: readonly GeneratorDocumentV1[] =\n Object.freeze([\n Object.freeze({\n schemaVersion: 1,\n definition: SERIALIZATION_DEFINITION_FIXTURES[0] as GeneratorDefinition,\n }) as GeneratorDocumentV1,\n Object.freeze({\n schemaVersion: 1,\n name: \"Small integer\",\n description: \"An integer in a bounded range.\",\n definition: Object.freeze({ type: \"integer\", min: 1, max: 100 }),\n }) as GeneratorDocumentV1,\n ]);\n\n/** A stable, lowercase identifier used to classify portable metadata. */\nexport type SemanticMetadataId = string;\n\n/** A coarse output-preview classification, not an execution or inference type. */\nexport type GeneratorOutputCategory = SemanticMetadataId;\n\n/**\n * Portable, descriptive metadata for a generator implementation.\n * It is intentionally separate from executable generator definitions.\n */\nexport type GeneratorMetadata = {\n readonly typeId?: SemanticMetadataId;\n readonly displayName?: string;\n readonly description?: string;\n readonly category?: SemanticMetadataId;\n readonly outputCategory?: GeneratorOutputCategory;\n readonly documentationUrl?: string;\n readonly examples?: readonly JsonValue[];\n};\n\nexport const GENERATOR_DOCUMENT_TOP_LEVEL_KEYS = [\n \"schemaVersion\",\n \"name\",\n \"description\",\n \"definition\",\n] as const;\n\nexport const GENERATOR_METADATA_KEYS = [\n \"typeId\",\n \"displayName\",\n \"description\",\n \"category\",\n \"outputCategory\",\n \"documentationUrl\",\n \"examples\",\n] as const;\n\nconst DOCUMENT_METADATA_KEYS = new Set([\n \"schemaVersion\",\n \"name\",\n \"description\",\n \"owner\",\n \"ownership\",\n \"visibility\",\n \"createdAt\",\n \"updatedAt\",\n \"timestamps\",\n]);\n\nexport type SchemaVersionFailureCode =\n | \"schema_version_missing\"\n | \"schema_version_unsupported\";\nexport type SchemaVersionFailure = {\n readonly code: SchemaVersionFailureCode;\n readonly message: string;\n readonly path: ValidationPath;\n readonly severity: \"error\";\n readonly details: { readonly supportedVersions: readonly SchemaVersion[] };\n} & ValidationIssue;\n\nexport type GeneratorDefinitionFailureCode =\n | \"generator_definition_not_json\"\n | \"generator_definition_not_object\"\n | \"generator_type_missing\"\n | \"generator_type_invalid\"\n | \"definition_document_metadata\";\nexport type GeneratorDefinitionFailure = {\n readonly code: GeneratorDefinitionFailureCode;\n readonly message: string;\n readonly path: ValidationPath;\n readonly severity: \"error\";\n};\n\nexport type GeneratorMetadataFailureCode =\n | \"generator_metadata_not_json\"\n | \"generator_metadata_not_object\"\n | \"metadata_type_id_invalid\"\n | \"metadata_display_name_invalid\"\n | \"metadata_description_invalid\"\n | \"metadata_category_invalid\"\n | \"metadata_output_category_invalid\"\n | \"metadata_documentation_url_invalid\"\n | \"metadata_examples_invalid\"\n | \"metadata_property_unknown\";\nexport type GeneratorMetadataFailure = {\n readonly code: GeneratorMetadataFailureCode;\n readonly message: string;\n readonly path: ValidationPath;\n readonly severity: \"error\";\n};\n\nexport type GeneratorDocumentFailureCode =\n | SchemaVersionFailureCode\n | GeneratorDefinitionFailureCode\n | \"generator_document_not_json\"\n | \"generator_document_not_object\"\n | \"definition_missing\"\n | \"name_invalid\"\n | \"description_invalid\"\n | \"top_level_property_unknown\"\n | \"configuration_envelope_removed\";\nexport type GeneratorDocumentFailure =\n | SchemaVersionFailure\n | {\n readonly code: Exclude<\n GeneratorDocumentFailureCode,\n SchemaVersionFailureCode\n >;\n readonly message: string;\n readonly path: ValidationPath;\n readonly severity: \"error\";\n };\nexport type GeneratorDocumentParseResult =\n | { readonly success: true; readonly value: GeneratorDocumentV1 }\n | { readonly success: false; readonly failure: GeneratorDocumentFailure };\n\nexport class JsonValueError extends ConstructaError {\n readonly issue: ValidationIssue;\n constructor(path: ValidationPath, reason: string) {\n super({\n kind: \"configuration\",\n code: \"INVALID_JSON_VALUE\",\n path,\n message: reason,\n details: { issueCode: \"invalid_json_value\" },\n });\n this.name = \"JsonValueError\";\n this.issue = { code: \"invalid_json_value\", path, message: reason };\n }\n}\n\nexport class SchemaVersionError extends ConstructaError {\n readonly failure: SchemaVersionFailure;\n constructor(failure: SchemaVersionFailure) {\n super({\n kind: \"configuration\",\n code: \"UNSUPPORTED_SCHEMA_VERSION\",\n path: failure.path,\n message: failure.message,\n details: { issueCode: failure.code },\n });\n this.name = \"SchemaVersionError\";\n this.failure = failure;\n }\n}\n\nexport class GeneratorDefinitionError extends ConstructaError {\n readonly failure: GeneratorDefinitionFailure;\n constructor(failure: GeneratorDefinitionFailure) {\n super({\n kind: \"configuration\",\n code: \"INVALID_CONFIGURATION\",\n path: failure.path,\n message: failure.message,\n details: { issueCode: failure.code },\n });\n this.name = \"GeneratorDefinitionError\";\n this.failure = failure;\n }\n}\n\nexport class GeneratorMetadataError extends ConstructaError {\n readonly failure: GeneratorMetadataFailure;\n constructor(failure: GeneratorMetadataFailure) {\n super({\n kind: \"configuration\",\n code: \"INVALID_CONFIGURATION\",\n path: failure.path,\n message: failure.message,\n details: { issueCode: failure.code },\n });\n this.name = \"GeneratorMetadataError\";\n this.failure = failure;\n }\n}\n\nexport class GeneratorDocumentError extends ConstructaError {\n readonly failure: GeneratorDocumentFailure;\n constructor(failure: GeneratorDocumentFailure) {\n super({\n kind: \"configuration\",\n code: \"INVALID_CONFIGURATION\",\n path: failure.path,\n message: failure.message,\n details: { issueCode: failure.code },\n });\n this.name = \"GeneratorDocumentError\";\n this.failure = failure;\n }\n}\n\nexport function isJsonValue(value: unknown): value is JsonValue {\n return validateJsonValue(value).length === 0;\n}\nexport function isSchemaVersion(value: unknown): value is SchemaVersion {\n return value === CURRENT_SCHEMA_VERSION;\n}\nexport function isGeneratorDefinition(\n value: unknown,\n): value is GeneratorDefinition {\n return validateGeneratorDefinition(value).length === 0;\n}\nexport function isDocument(value: unknown): value is GeneratorDocumentV1 {\n return validateDocument(value).length === 0;\n}\nexport function isGeneratorMetadata(\n value: unknown,\n): value is GeneratorMetadata {\n return validateGeneratorMetadata(value).length === 0;\n}\nexport function assertJsonValue(\n value: unknown,\n path: ValidationPath = [],\n): asserts value is JsonValue {\n const [issue] = validateJsonValue(value, path);\n if (issue !== undefined) throw new JsonValueError(issue.path, issue.message);\n}\nexport function assertSchemaVersion(\n value: unknown,\n path: ValidationPath = [\"schemaVersion\"],\n): asserts value is SchemaVersion {\n const failure = findSchemaVersionValueFailure(value, path);\n if (failure !== undefined) throw new SchemaVersionError(failure);\n}\nexport function assertGeneratorDefinition(\n value: unknown,\n path: ValidationPath = [],\n): asserts value is GeneratorDefinition {\n const [failure] = validateGeneratorDefinition(value, path);\n if (failure !== undefined) throw new GeneratorDefinitionError(failure);\n}\nexport function assertGeneratorMetadata(\n value: unknown,\n path: ValidationPath = [],\n): asserts value is GeneratorMetadata {\n const [failure] = validateGeneratorMetadata(value, path);\n if (failure !== undefined) throw new GeneratorMetadataError(failure);\n}\nexport function assertDocument(\n value: unknown,\n path: ValidationPath = [],\n): asserts value is GeneratorDocumentV1 {\n const [issue] = validateDocument(value, path);\n if (issue !== undefined) throw new GeneratorDocumentError(issue);\n}\nexport function parseDocument(\n value: unknown,\n path: ValidationPath = [],\n): GeneratorDocumentV1 {\n assertDocument(value, path);\n return value;\n}\nexport function safeParseDocument(\n value: unknown,\n path: ValidationPath = [],\n): GeneratorDocumentParseResult {\n const [failure] = validateDocument(value, path);\n return failure === undefined\n ? { success: true, value: value as GeneratorDocumentV1 }\n : { success: false, failure };\n}\n\n/**\n * Serializes a portable definition with recursively sorted object keys and a\n * trailing newline. The result is intended for stable diffs, not execution.\n */\nexport function serializeDefinition(value: unknown): string {\n assertGeneratorDefinition(value);\n return serializeCanonicalJson(value);\n}\n\n/** Serializes a validated versioned document using the same canonical format. */\nexport function serializeDocument(value: unknown): string {\n assertDocument(value);\n return serializeCanonicalJson(value);\n}\n\nfunction serializeCanonicalJson(value: JsonValue): string {\n return `${JSON.stringify(canonicalizeJson(value), null, 2)}\\n`;\n}\n\nfunction canonicalizeJson(value: JsonValue): JsonValue {\n if (Array.isArray(value)) return value.map(canonicalizeJson);\n if (isJsonRecord(value)) {\n const result: Record<string, JsonValue> = {};\n for (const key of Object.keys(value).sort()) {\n result[key] = canonicalizeJson(value[key] as JsonValue);\n }\n return result;\n }\n return value;\n}\n\nexport function validateJsonValue(\n value: unknown,\n path: ValidationPath = [],\n): readonly ValidationIssue[] {\n const error = findJsonValueError(value, path);\n return error === undefined\n ? []\n : [{ code: \"invalid_json_value\", path: error.path, message: error.reason }];\n}\n\nfunction findJsonValueError(\n value: unknown,\n path: ValidationPath,\n): { path: ValidationPath; reason: string } | undefined {\n return findJsonValueErrorInternal(value, path, new Set());\n}\n\n/** Returns all independent document validation issues in deterministic order. */\nexport function validateDocument(\n value: unknown,\n path: ValidationPath = [],\n): readonly GeneratorDocumentFailure[] {\n const jsonError = findJsonValueError(value, path);\n if (jsonError !== undefined) {\n return [\n documentFailure(\n \"generator_document_not_json\",\n jsonError.path,\n jsonError.reason,\n ),\n ];\n }\n if (!isJsonRecord(value)) {\n return [documentFailure(\"generator_document_not_object\", path)];\n }\n\n const issues: GeneratorDocumentFailure[] = [];\n if (Object.hasOwn(value, \"configuration\") && Object.hasOwn(value, \"type\")) {\n issues.push(documentFailure(\"configuration_envelope_removed\", path));\n }\n for (const key of Object.keys(value)) {\n if (!GENERATOR_DOCUMENT_TOP_LEVEL_KEYS.includes(key as never)) {\n issues.push(\n documentFailure(\n \"top_level_property_unknown\",\n appendPathSegment(path, key),\n `Unknown top-level property: ${key}`,\n ),\n );\n }\n }\n\n const versionFailure = findSchemaVersionFailure(value, path);\n if (versionFailure !== undefined) issues.push(versionFailure);\n for (const property of [\"name\", \"description\"] as const) {\n if (Object.hasOwn(value, property) && typeof value[property] !== \"string\") {\n issues.push(\n documentFailure(\n property === \"name\" ? \"name_invalid\" : \"description_invalid\",\n appendPathSegment(path, property),\n ),\n );\n }\n }\n if (!Object.hasOwn(value, \"definition\")) {\n issues.push(\n documentFailure(\n \"definition_missing\",\n appendPathSegment(path, \"definition\"),\n ),\n );\n } else {\n issues.push(\n ...validateGeneratorDefinition(\n value.definition,\n appendPathSegment(path, \"definition\"),\n ),\n );\n }\n return issues;\n}\n\n/** Returns definition issues. Nested typed definitions are validated recursively. */\nexport function validateGeneratorDefinition(\n value: unknown,\n path: ValidationPath = [],\n): readonly GeneratorDefinitionFailure[] {\n const jsonError = findJsonValueError(value, path);\n if (jsonError !== undefined) {\n return [\n definitionFailure(\n \"generator_definition_not_json\",\n jsonError.path,\n jsonError.reason,\n ),\n ];\n }\n if (!isJsonRecord(value)) {\n return [definitionFailure(\"generator_definition_not_object\", path)];\n }\n\n const issues: GeneratorDefinitionFailure[] = [];\n collectDefinitionMetadataIssues(value as JsonObject, path, issues, true);\n return issues;\n}\nexport function validateGeneratorMetadata(\n value: unknown,\n path: ValidationPath = [],\n): readonly GeneratorMetadataFailure[] {\n const failure = findGeneratorMetadataFailure(value, path);\n return failure === undefined ? [] : [failure];\n}\n\nfunction findGeneratorMetadataFailure(\n value: unknown,\n path: ValidationPath = [],\n): GeneratorMetadataFailure | undefined {\n const jsonError = findJsonValueError(value, path);\n if (jsonError !== undefined) {\n return metadataFailure(\n \"generator_metadata_not_json\",\n jsonError.path,\n jsonError.reason,\n );\n }\n if (!isJsonRecord(value)) {\n return metadataFailure(\"generator_metadata_not_object\", path);\n }\n\n const unknownKey = Object.keys(value).find(\n (key) => !GENERATOR_METADATA_KEYS.includes(key as never),\n );\n if (unknownKey !== undefined) {\n return metadataFailure(\n \"metadata_property_unknown\",\n appendPathSegment(path, unknownKey),\n `Unknown metadata property: ${unknownKey}`,\n );\n }\n\n for (const property of [\"typeId\", \"category\", \"outputCategory\"] as const) {\n if (\n Object.hasOwn(value, property) &&\n (typeof value[property] !== \"string\" || !isMetadataId(value[property]))\n ) {\n const code =\n property === \"typeId\"\n ? \"metadata_type_id_invalid\"\n : property === \"category\"\n ? \"metadata_category_invalid\"\n : \"metadata_output_category_invalid\";\n return metadataFailure(code, appendPathSegment(path, property));\n }\n }\n\n for (const property of [\n \"displayName\",\n \"description\",\n \"documentationUrl\",\n ] as const) {\n if (Object.hasOwn(value, property) && typeof value[property] !== \"string\") {\n const code =\n property === \"displayName\"\n ? \"metadata_display_name_invalid\"\n : property === \"description\"\n ? \"metadata_description_invalid\"\n : \"metadata_documentation_url_invalid\";\n return metadataFailure(code, appendPathSegment(path, property));\n }\n }\n\n if (Object.hasOwn(value, \"examples\") && !Array.isArray(value.examples)) {\n return metadataFailure(\n \"metadata_examples_invalid\",\n appendPathSegment(path, \"examples\"),\n );\n }\n\n return undefined;\n}\nfunction findSchemaVersionFailure(\n value: unknown,\n path: ValidationPath = [],\n): SchemaVersionFailure | undefined {\n if (!isJsonRecord(value) || !Object.hasOwn(value, \"schemaVersion\"))\n return createSchemaVersionFailure(\n \"schema_version_missing\",\n appendPathSegment(path, \"schemaVersion\"),\n );\n return findSchemaVersionValueFailure(\n value.schemaVersion,\n appendPathSegment(path, \"schemaVersion\"),\n );\n}\nfunction findSchemaVersionValueFailure(\n value: unknown,\n path: ValidationPath = [\"schemaVersion\"],\n): SchemaVersionFailure | undefined {\n return isSchemaVersion(value)\n ? undefined\n : createSchemaVersionFailure(\"schema_version_unsupported\", path);\n}\n\nfunction createSchemaVersionFailure(\n code: SchemaVersionFailureCode,\n path: ValidationPath,\n): SchemaVersionFailure {\n return {\n code,\n message:\n code === \"schema_version_missing\"\n ? `schemaVersion is required and must be ${CURRENT_SCHEMA_VERSION}`\n : `schemaVersion must be ${CURRENT_SCHEMA_VERSION}`,\n path,\n severity: \"error\",\n details: { supportedVersions: SUPPORTED_SCHEMA_VERSIONS },\n };\n}\nfunction definitionFailure(\n code: GeneratorDefinitionFailureCode,\n path: ValidationPath,\n message?: string,\n): GeneratorDefinitionFailure {\n const messages: Record<GeneratorDefinitionFailureCode, string> = {\n generator_definition_not_json:\n \"generator definition must be portable JSON data\",\n generator_definition_not_object:\n \"generator definition must be a JSON object\",\n generator_type_missing: \"type is required\",\n generator_type_invalid: \"type must be a non-empty string\",\n definition_document_metadata:\n \"document metadata is not allowed in a generator definition\",\n };\n return { code, message: message ?? messages[code], path, severity: \"error\" };\n}\nfunction metadataFailure(\n code: GeneratorMetadataFailureCode,\n path: ValidationPath,\n message?: string,\n): GeneratorMetadataFailure {\n const messages: Record<GeneratorMetadataFailureCode, string> = {\n generator_metadata_not_json:\n \"generator metadata must be portable JSON data\",\n generator_metadata_not_object: \"generator metadata must be a JSON object\",\n metadata_type_id_invalid: \"typeId must be a stable metadata ID\",\n metadata_display_name_invalid: \"displayName must be a string when present\",\n metadata_description_invalid: \"description must be a string when present\",\n metadata_category_invalid: \"category must be a stable metadata ID\",\n metadata_output_category_invalid:\n \"outputCategory must be a stable metadata ID\",\n metadata_documentation_url_invalid:\n \"documentationUrl must be a string when present\",\n metadata_examples_invalid: \"examples must be an array when present\",\n metadata_property_unknown: \"unknown metadata properties are not allowed\",\n };\n return { code, message: message ?? messages[code], path, severity: \"error\" };\n}\nfunction documentFailure(\n code: Exclude<GeneratorDocumentFailureCode, SchemaVersionFailureCode>,\n path: ValidationPath,\n message?: string,\n): Exclude<GeneratorDocumentFailure, SchemaVersionFailure> {\n const messages: Record<\n Exclude<GeneratorDocumentFailureCode, SchemaVersionFailureCode>,\n string\n > = {\n generator_document_not_json:\n \"generator document must be portable JSON data\",\n generator_document_not_object: \"generator document must be a JSON object\",\n generator_definition_not_json:\n \"generator definition must be portable JSON data\",\n generator_definition_not_object:\n \"generator definition must be a JSON object\",\n generator_type_missing: \"type is required\",\n generator_type_invalid: \"type must be a non-empty string\",\n definition_document_metadata:\n \"document metadata is not allowed in a generator definition\",\n definition_missing: \"definition is required\",\n name_invalid: \"name must be a string when present\",\n description_invalid: \"description must be a string when present\",\n top_level_property_unknown: \"unknown top-level properties are not allowed\",\n configuration_envelope_removed:\n \"The configuration envelope was removed; put generator fields directly inside definition.\",\n };\n return { code, message: message ?? messages[code], path, severity: \"error\" };\n}\nfunction appendPathSegment(\n path: ValidationPath,\n segment: ValidationPathSegment,\n): ValidationPath {\n return [...path, segment];\n}\n\nfunction validateConstructaErrorOptions(options: ConstructaErrorOptions): void {\n if (!CONSTRUCTA_ERROR_KINDS.includes(options.kind)) {\n throw new TypeError(\"kind must be a Constructa error kind\");\n }\n if (!/^[A-Z][A-Z0-9_]*$/u.test(options.code)) {\n throw new TypeError(\"code must be an uppercase stable error code\");\n }\n if (typeof options.message !== \"string\" || options.message.length === 0) {\n throw new TypeError(\"message must be a non-empty string\");\n }\n for (const segment of options.path) {\n if (\n typeof segment !== \"string\" &&\n (typeof segment !== \"number\" || !Number.isSafeInteger(segment))\n ) {\n throw new TypeError(\"path segments must be strings or safe integers\");\n }\n }\n if (\n options.details !== undefined &&\n (!isJsonRecord(options.details) || !isJsonValue(options.details))\n ) {\n throw new TypeError(\"details must be a portable JSON object\");\n }\n}\n\nfunction isMetadataId(value: string) {\n return /^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u.test(value);\n}\n\nfunction collectDefinitionMetadataIssues(\n value: JsonObject,\n path: ValidationPath,\n issues: GeneratorDefinitionFailure[],\n isDefinition: boolean,\n): void {\n if (isDefinition) {\n if (!Object.hasOwn(value, \"type\")) {\n issues.push(\n definitionFailure(\n \"generator_type_missing\",\n appendPathSegment(path, \"type\"),\n ),\n );\n } else if (\n typeof value.type !== \"string\" ||\n value.type.trim().length === 0\n ) {\n issues.push(\n definitionFailure(\n \"generator_type_invalid\",\n appendPathSegment(path, \"type\"),\n ),\n );\n }\n for (const key of Object.keys(value)) {\n if (key !== \"type\" && DOCUMENT_METADATA_KEYS.has(key)) {\n issues.push(\n definitionFailure(\n \"definition_document_metadata\",\n appendPathSegment(path, key),\n ),\n );\n }\n }\n }\n\n for (const [key, child] of Object.entries(value)) {\n if (key === \"type\") continue;\n collectNestedDefinitionMetadataIssues(\n child,\n appendPathSegment(path, key),\n issues,\n );\n }\n}\n\nfunction collectNestedDefinitionMetadataIssues(\n value: JsonValue,\n path: ValidationPath,\n issues: GeneratorDefinitionFailure[],\n): void {\n if (Array.isArray(value)) {\n for (let index = 0; index < value.length; index += 1) {\n collectNestedDefinitionMetadataIssues(\n value[index],\n appendPathSegment(path, index),\n issues,\n );\n }\n return;\n }\n if (!isJsonRecord(value)) return;\n collectDefinitionMetadataIssues(\n value,\n path,\n issues,\n Object.hasOwn(value, \"type\"),\n );\n}\n\nfunction isJsonRecord(value: unknown): value is Record<string, unknown> {\n const prototype =\n typeof value === \"object\" && value !== null\n ? Object.getPrototypeOf(value)\n : undefined;\n return (\n typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value) &&\n (prototype === null || prototype === Object.prototype)\n );\n}\nfunction findJsonValueErrorInternal(\n value: unknown,\n path: ValidationPath,\n ancestors: Set<object>,\n): { path: ValidationPath; reason: string } | undefined {\n switch (typeof value) {\n case \"boolean\":\n case \"string\":\n return undefined;\n case \"number\":\n if (!Number.isFinite(value))\n return { path, reason: \"number must be finite\" };\n return Object.is(value, -0)\n ? { path, reason: \"number must not be negative zero\" }\n : undefined;\n case \"object\":\n return value === null\n ? undefined\n : findJsonObjectError(value, path, ancestors);\n case \"bigint\":\n case \"function\":\n case \"symbol\":\n case \"undefined\":\n return { path, reason: `${typeof value} is not JSON-compatible` };\n }\n}\nfunction findJsonObjectError(\n value: object,\n path: ValidationPath,\n ancestors: Set<object>,\n): { path: ValidationPath; reason: string } | undefined {\n if (ancestors.has(value))\n return { path, reason: \"cyclic objects are not JSON-compatible\" };\n if (\n \"toJSON\" in value &&\n typeof (value as { readonly toJSON?: unknown }).toJSON === \"function\"\n )\n return { path, reason: \"objects with toJSON behavior are not portable\" };\n ancestors.add(value);\n const error = Array.isArray(value)\n ? findJsonArrayError(value, path, ancestors)\n : findJsonRecordError(value, path, ancestors);\n ancestors.delete(value);\n return error;\n}\nfunction findJsonArrayError(\n value: readonly unknown[],\n path: ValidationPath,\n ancestors: Set<object>,\n): { path: ValidationPath; reason: string } | undefined {\n const extraProperty = Object.keys(value).find((key) => !isArrayIndexKey(key));\n if (extraProperty !== undefined)\n return {\n path: appendPathSegment(path, extraProperty),\n reason: \"array object properties would be omitted from JSON\",\n };\n const propertyError = findUnsupportedOwnProperty(value, path, [\"length\"]);\n if (propertyError !== undefined) return propertyError;\n for (let index = 0; index < value.length; index += 1) {\n if (!(index in value))\n return {\n path: appendPathSegment(path, index),\n reason: \"sparse array slots are not JSON-compatible\",\n };\n const itemError = findJsonValueErrorInternal(\n value[index],\n appendPathSegment(path, index),\n ancestors,\n );\n if (itemError !== undefined) return itemError;\n }\n return undefined;\n}\nfunction isArrayIndexKey(key: string) {\n const index = Number(key);\n return (\n Number.isInteger(index) &&\n index >= 0 &&\n index < 2 ** 32 - 1 &&\n String(index) === key\n );\n}\nfunction findJsonRecordError(\n value: object,\n path: ValidationPath,\n ancestors: Set<object>,\n): { path: ValidationPath; reason: string } | undefined {\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== null && prototype !== Object.prototype)\n return { path, reason: \"object must be a plain JSON record\" };\n const propertyError = findUnsupportedOwnProperty(value, path);\n if (propertyError !== undefined) return propertyError;\n for (const key of Object.keys(value)) {\n const itemError = findJsonValueErrorInternal(\n (value as Record<string, unknown>)[key],\n appendPathSegment(path, key),\n ancestors,\n );\n if (itemError !== undefined) return itemError;\n }\n return undefined;\n}\nfunction findUnsupportedOwnProperty(\n value: object,\n path: ValidationPath,\n allowedNonEnumerableProperties: readonly string[] = [],\n): { path: ValidationPath; reason: string } | undefined {\n if (Object.hasOwn(value, \"__proto__\")) {\n return {\n path: appendPathSegment(path, \"__proto__\"),\n reason: \"__proto__ keys are not portable JSON data\",\n };\n }\n if (Object.getOwnPropertySymbols(value).length > 0)\n return { path, reason: \"symbol keys are not JSON-compatible\" };\n const allowed = new Set(allowedNonEnumerableProperties);\n for (const [key, descriptor] of Object.entries(\n Object.getOwnPropertyDescriptors(value),\n )) {\n if (\"get\" in descriptor || \"set\" in descriptor)\n return {\n path: appendPathSegment(path, key),\n reason: \"accessor properties are not portable JSON data\",\n };\n if (!descriptor.enumerable && !allowed.has(key))\n return {\n path: appendPathSegment(path, key),\n reason: \"non-enumerable properties would be omitted from JSON\",\n };\n }\n return undefined;\n}\n"],"mappings":";AAcA,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;AACF;AAGA,MAAa,kCAAkC;CAC7C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAcA,IAAa,kBAAb,cAAqC,UAAU;CAC7C;CACA;CACA;CACA;CACA;CAEA,YAAY,SAAiC,OAAiB;EAC5D,+BAA+B,OAAO;EACtC,MAAM,QAAQ,OAAO;EACrB,KAAK,OAAO;EACZ,KAAK,OAAO,QAAQ;EACpB,KAAK,OAAO,QAAQ;EACpB,KAAK,OAAO,QAAQ;EACpB,KAAK,UAAU,QAAQ;EACvB,KAAKA,SAAS;CAChB;;CAGA,SAA8B;EAC5B,OAAO,KAAK,YAAY,KAAA,IACpB;GACE,MAAM,KAAK;GACX,MAAM,KAAK;GACX,MAAM,KAAK;GACX,SAAS,KAAK;EAChB,IACA;GACE,MAAM,KAAK;GACX,MAAM,KAAK;GACX,MAAM,KAAK;GACX,SAAS,KAAK;GACd,SAAS,KAAK;EAChB;CAC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A JSON scalar value supported by Constructa documents. */\nexport type JsonPrimitive = boolean | null | number | string;\n/** Any portable JSON value supported by Constructa documents. */\nexport type JsonValue = JsonArray | JsonObject | JsonPrimitive;\n/** A readonly array of portable JSON values. */\nexport type JsonArray = readonly JsonValue[];\n/** A readonly string-keyed record of portable JSON values. */\nexport type JsonObject = { readonly [key: string]: JsonValue };\n\n/** One property or array-index segment in a validation path. */\nexport type ValidationPathSegment = string | number;\n/** The location of a validation issue inside a portable value. */\nexport type ValidationPath = readonly ValidationPathSegment[];\n/** A stable, machine-readable validation failure. */\nexport type ValidationIssue = {\n readonly code: string;\n readonly path: ValidationPath;\n readonly message: string;\n readonly details?: JsonObject;\n};\n\n/** The supported categories for safe Constructa errors. */\nexport const CONSTRUCTA_ERROR_KINDS = [\n \"configuration\",\n \"dependency\",\n \"execution\",\n \"system\",\n] as const;\n/** A supported category for a safe Constructa error. */\nexport type ConstructaErrorKind = (typeof CONSTRUCTA_ERROR_KINDS)[number];\n\n/** Error codes reserved by Constructa's public error contract. */\nexport const RESERVED_CONSTRUCTA_ERROR_CODES = [\n \"INVALID_RANGE\",\n \"EMPTY_CHOICE\",\n \"INVALID_LENGTH\",\n \"UNKNOWN_GENERATOR\",\n \"REFERENCE_NOT_FOUND\",\n \"CIRCULAR_REFERENCE\",\n \"EXECUTION_FAILED\",\n \"UNSUPPORTED_SCHEMA_VERSION\",\n \"INVALID_CONFIGURATION\",\n \"INVALID_JSON_VALUE\",\n] as const;\n/** An uppercase, stable error code. */\nexport type ConstructaErrorCode = Uppercase<string>;\n\n/** Data used to construct a safe Constructa error. */\nexport type ConstructaErrorOptions = {\n readonly kind: ConstructaErrorKind;\n readonly code: ConstructaErrorCode;\n readonly path: ValidationPath;\n readonly message: string;\n readonly details?: JsonObject;\n};\n\n/** The serializable representation of a Constructa error. */\nexport type SafeConstructaError = ConstructaErrorOptions;\n\n/** A safe, serializable error shared by every Constructa surface. */\nexport class ConstructaError extends TypeError {\n readonly kind: ConstructaErrorKind;\n readonly code: ConstructaErrorCode;\n readonly path: ValidationPath;\n readonly details?: JsonObject;\n readonly #cause: unknown;\n\n constructor(options: ConstructaErrorOptions, cause?: unknown) {\n validateConstructaErrorOptions(options);\n super(options.message);\n this.name = \"ConstructaError\";\n this.kind = options.kind;\n this.code = options.code;\n this.path = options.path;\n this.details = options.details;\n this.#cause = cause;\n }\n\n /** Returns only data that is safe to send across a process or network boundary. */\n toJSON(): SafeConstructaError {\n return this.details === undefined\n ? {\n kind: this.kind,\n code: this.code,\n path: this.path,\n message: this.message,\n }\n : {\n kind: this.kind,\n code: this.code,\n path: this.path,\n message: this.message,\n details: this.details,\n };\n }\n\n hasCause(): boolean {\n return this.#cause !== undefined;\n }\n}\n\n/** Creates a known safe error without retaining an underlying cause. */\nexport function createConstructaError(\n options: ConstructaErrorOptions,\n): ConstructaError {\n return new ConstructaError(options);\n}\n\n/** Returns a Constructa error, wrapping an unknown cause when necessary. */\nexport function normalizeConstructaError(\n cause: unknown,\n options: ConstructaErrorOptions,\n): ConstructaError {\n return cause instanceof ConstructaError\n ? cause\n : new ConstructaError(options, cause);\n}\n\n/** The schema version emitted by this release. */\nexport const CURRENT_SCHEMA_VERSION = 1;\n/** All document schema versions accepted by this release. */\nexport const SUPPORTED_SCHEMA_VERSIONS = [CURRENT_SCHEMA_VERSION] as const;\n/** A supported document schema version. */\nexport type SchemaVersion = (typeof SUPPORTED_SCHEMA_VERSIONS)[number];\n\ndeclare const generatorOutput: unique symbol;\n\n/**\n * Portable executable generator data. `Output` exists only to carry compile-time\n * inference and never creates a runtime property.\n */\nexport type GeneratorDefinition<Output = unknown> = JsonObject & {\n readonly type: string;\n readonly [generatorOutput]?: Output;\n};\n\n/** Infers a generator definition's output type. */\nexport type Infer<Definition> =\n Definition extends GeneratorDefinition<infer Output> ? Output : never;\n\n/** Versioned document containing exactly one root generator definition. */\nexport type GeneratorDocumentV1 = {\n readonly schemaVersion: 1;\n readonly definition: GeneratorDefinition;\n readonly name?: string;\n readonly description?: string;\n};\n\n/** A document in any schema version currently supported by Constructa. */\nexport type GeneratorDocument = GeneratorDocumentV1;\n\n/** An explicit one-step migration into a supported document schema version. */\nexport type DocumentMigration = {\n readonly from: number;\n readonly to: SchemaVersion;\n readonly migrate: (document: JsonObject) => unknown;\n};\n\n/** Reusable portable definitions for serialization and integration fixtures. */\n/** Reusable portable definitions for serialization and integration fixtures. */\nexport const SERIALIZATION_DEFINITION_FIXTURES: readonly GeneratorDefinition[] =\n Object.freeze([\n Object.freeze({ type: \"boolean\" }) as GeneratorDefinition,\n Object.freeze({\n type: \"object\",\n fields: Object.freeze({\n account: Object.freeze({\n type: \"object\",\n fields: Object.freeze({\n id: Object.freeze({ type: \"integer\", min: 1 }),\n }),\n }),\n }),\n }) as GeneratorDefinition,\n ]);\n\n/** Reusable versioned documents for serialization and integration fixtures. */\nexport const SERIALIZATION_DOCUMENT_FIXTURES: readonly GeneratorDocumentV1[] =\n Object.freeze([\n Object.freeze({\n schemaVersion: 1,\n definition: SERIALIZATION_DEFINITION_FIXTURES[0] as GeneratorDefinition,\n }) as GeneratorDocumentV1,\n Object.freeze({\n schemaVersion: 1,\n name: \"Small integer\",\n description: \"An integer in a bounded range.\",\n definition: Object.freeze({ type: \"integer\", min: 1, max: 100 }),\n }) as GeneratorDocumentV1,\n ]);\n\n/** A stable, lowercase identifier used by generator metadata. */\nexport type SemanticMetadataId = string;\n\n/** A coarse semantic category for a generator's output. */\nexport type GeneratorOutputCategory = SemanticMetadataId;\n\n/**\n * Portable, descriptive metadata for a generator implementation.\n * It is intentionally separate from executable generator definitions.\n */\nexport type GeneratorMetadata = {\n readonly typeId?: SemanticMetadataId;\n readonly displayName?: string;\n readonly description?: string;\n readonly category?: SemanticMetadataId;\n readonly outputCategory?: GeneratorOutputCategory;\n readonly documentationUrl?: string;\n readonly examples?: readonly JsonValue[];\n};\n\n/** The allowed top-level keys of a versioned generator document. */\nexport const GENERATOR_DOCUMENT_TOP_LEVEL_KEYS = [\n \"schemaVersion\",\n \"name\",\n \"description\",\n \"definition\",\n] as const;\n\n/** The allowed keys of portable generator metadata. */\nexport const GENERATOR_METADATA_KEYS = [\n \"typeId\",\n \"displayName\",\n \"description\",\n \"category\",\n \"outputCategory\",\n \"documentationUrl\",\n \"examples\",\n] as const;\n\nconst DOCUMENT_METADATA_KEYS = new Set([\n \"schemaVersion\",\n \"name\",\n \"description\",\n \"owner\",\n \"ownership\",\n \"visibility\",\n \"createdAt\",\n \"updatedAt\",\n \"timestamps\",\n]);\n\n/** Codes emitted when a document schema version cannot be accepted. */\nexport type SchemaVersionFailureCode =\n | \"schema_version_missing\"\n | \"schema_version_unsupported\";\n/** Details of an unsupported or missing schema-version failure. */\nexport type SchemaVersionFailure = {\n readonly code: SchemaVersionFailureCode;\n readonly message: string;\n readonly path: ValidationPath;\n readonly severity: \"error\";\n readonly details: { readonly supportedVersions: readonly SchemaVersion[] };\n} & ValidationIssue;\n\n/** Codes emitted while validating a generator definition. */\nexport type GeneratorDefinitionFailureCode =\n | \"generator_definition_not_json\"\n | \"generator_definition_not_object\"\n | \"generator_type_missing\"\n | \"generator_type_invalid\"\n | \"definition_document_metadata\";\n/** Details of a generator-definition validation failure. */\nexport type GeneratorDefinitionFailure = {\n readonly code: GeneratorDefinitionFailureCode;\n readonly message: string;\n readonly path: ValidationPath;\n readonly severity: \"error\";\n};\n\n/** Codes emitted while validating portable generator metadata. */\nexport type GeneratorMetadataFailureCode =\n | \"generator_metadata_not_json\"\n | \"generator_metadata_not_object\"\n | \"metadata_type_id_invalid\"\n | \"metadata_display_name_invalid\"\n | \"metadata_description_invalid\"\n | \"metadata_category_invalid\"\n | \"metadata_output_category_invalid\"\n | \"metadata_documentation_url_invalid\"\n | \"metadata_examples_invalid\"\n | \"metadata_property_unknown\";\n/** Details of a generator-metadata validation failure. */\nexport type GeneratorMetadataFailure = {\n readonly code: GeneratorMetadataFailureCode;\n readonly message: string;\n readonly path: ValidationPath;\n readonly severity: \"error\";\n};\n\n/** Codes emitted while validating a versioned generator document. */\nexport type GeneratorDocumentFailureCode =\n | SchemaVersionFailureCode\n | GeneratorDefinitionFailureCode\n | \"generator_document_not_json\"\n | \"generator_document_not_object\"\n | \"definition_missing\"\n | \"name_invalid\"\n | \"description_invalid\"\n | \"top_level_property_unknown\"\n | \"configuration_envelope_removed\";\n/** Details of a generator-document validation failure. */\nexport type GeneratorDocumentFailure =\n | SchemaVersionFailure\n | {\n readonly code: Exclude<\n GeneratorDocumentFailureCode,\n SchemaVersionFailureCode\n >;\n readonly message: string;\n readonly path: ValidationPath;\n readonly severity: \"error\";\n };\n/** The success-or-failure result returned by `safeParseDocument`. */\nexport type GeneratorDocumentParseResult =\n | { readonly success: true; readonly value: GeneratorDocumentV1 }\n | { readonly success: false; readonly failure: GeneratorDocumentFailure };\n\n/** Thrown when a value cannot be represented as portable JSON. */\nexport class JsonValueError extends ConstructaError {\n readonly issue: ValidationIssue;\n constructor(path: ValidationPath, reason: string) {\n super({\n kind: \"configuration\",\n code: \"INVALID_JSON_VALUE\",\n path,\n message: reason,\n details: { issueCode: \"invalid_json_value\" },\n });\n this.name = \"JsonValueError\";\n this.issue = { code: \"invalid_json_value\", path, message: reason };\n }\n}\n\n/** Thrown when a document's schema version is unsupported. */\nexport class SchemaVersionError extends ConstructaError {\n readonly failure: SchemaVersionFailure;\n constructor(failure: SchemaVersionFailure) {\n super({\n kind: \"configuration\",\n code: \"UNSUPPORTED_SCHEMA_VERSION\",\n path: failure.path,\n message: failure.message,\n details: { issueCode: failure.code },\n });\n this.name = \"SchemaVersionError\";\n this.failure = failure;\n }\n}\n\n/** Thrown when a generator definition is invalid. */\nexport class GeneratorDefinitionError extends ConstructaError {\n readonly failure: GeneratorDefinitionFailure;\n constructor(failure: GeneratorDefinitionFailure) {\n super({\n kind: \"configuration\",\n code: \"INVALID_CONFIGURATION\",\n path: failure.path,\n message: failure.message,\n details: { issueCode: failure.code },\n });\n this.name = \"GeneratorDefinitionError\";\n this.failure = failure;\n }\n}\n\n/** Thrown when portable generator metadata is invalid. */\nexport class GeneratorMetadataError extends ConstructaError {\n readonly failure: GeneratorMetadataFailure;\n constructor(failure: GeneratorMetadataFailure) {\n super({\n kind: \"configuration\",\n code: \"INVALID_CONFIGURATION\",\n path: failure.path,\n message: failure.message,\n details: { issueCode: failure.code },\n });\n this.name = \"GeneratorMetadataError\";\n this.failure = failure;\n }\n}\n\n/** Thrown when a versioned generator document is invalid. */\nexport class GeneratorDocumentError extends ConstructaError {\n readonly failure: GeneratorDocumentFailure;\n constructor(failure: GeneratorDocumentFailure) {\n super({\n kind: \"configuration\",\n code: \"INVALID_CONFIGURATION\",\n path: failure.path,\n message: failure.message,\n details: { issueCode: failure.code },\n });\n this.name = \"GeneratorDocumentError\";\n this.failure = failure;\n }\n}\n\n/** Returns whether a value is portable JSON. */\nexport function isJsonValue(value: unknown): value is JsonValue {\n return validateJsonValue(value).length === 0;\n}\n/** Returns whether a value is a schema version supported by this release. */\nexport function isSchemaVersion(value: unknown): value is SchemaVersion {\n return value === CURRENT_SCHEMA_VERSION;\n}\n/** Returns whether a value is a valid portable generator definition. */\nexport function isGeneratorDefinition(\n value: unknown,\n): value is GeneratorDefinition {\n return validateGeneratorDefinition(value).length === 0;\n}\n/** Returns whether a value is a valid current generator document. */\nexport function isDocument(value: unknown): value is GeneratorDocumentV1 {\n return validateDocument(value).length === 0;\n}\n/** Returns whether a value is valid portable generator metadata. */\nexport function isGeneratorMetadata(\n value: unknown,\n): value is GeneratorMetadata {\n return validateGeneratorMetadata(value).length === 0;\n}\n/** Asserts that a value is portable JSON. */\nexport function assertJsonValue(\n value: unknown,\n path: ValidationPath = [],\n): asserts value is JsonValue {\n const [issue] = validateJsonValue(value, path);\n if (issue !== undefined) throw new JsonValueError(issue.path, issue.message);\n}\n/** Asserts that a value is a supported schema version. */\nexport function assertSchemaVersion(\n value: unknown,\n path: ValidationPath = [\"schemaVersion\"],\n): asserts value is SchemaVersion {\n const failure = findSchemaVersionValueFailure(value, path);\n if (failure !== undefined) throw new SchemaVersionError(failure);\n}\n/** Asserts that a value is a valid portable generator definition. */\nexport function assertGeneratorDefinition(\n value: unknown,\n path: ValidationPath = [],\n): asserts value is GeneratorDefinition {\n const [failure] = validateGeneratorDefinition(value, path);\n if (failure !== undefined) throw new GeneratorDefinitionError(failure);\n}\n/** Asserts that a value is valid portable generator metadata. */\nexport function assertGeneratorMetadata(\n value: unknown,\n path: ValidationPath = [],\n): asserts value is GeneratorMetadata {\n const [failure] = validateGeneratorMetadata(value, path);\n if (failure !== undefined) throw new GeneratorMetadataError(failure);\n}\n/** Asserts that a value is a valid current generator document. */\nexport function assertDocument(\n value: unknown,\n path: ValidationPath = [],\n): asserts value is GeneratorDocumentV1 {\n const [issue] = validateDocument(value, path);\n if (issue !== undefined) throw new GeneratorDocumentError(issue);\n}\n/** Parses a document or throws its first validation failure. */\nexport function parseDocument(\n value: unknown,\n path: ValidationPath = [],\n): GeneratorDocumentV1 {\n const parser = resolveDocumentParser(value, path);\n return parser(value, path);\n}\n/** Validates a document without throwing. */\nexport function safeParseDocument(\n value: unknown,\n path: ValidationPath = [],\n): GeneratorDocumentParseResult {\n const [failure] = validateDocument(value, path);\n return failure === undefined\n ? { success: true, value: value as GeneratorDocumentV1 }\n : { success: false, failure };\n}\n\n/**\n * Applies one declared migration and validates its result through the normal\n * version parser. Migrations are never applied implicitly by `parseDocument`.\n */\nexport function migrateDocument(\n value: unknown,\n migration: DocumentMigration,\n): GeneratorDocumentV1 {\n assertDocumentMigration(migration);\n assertJsonValue(value);\n if (!isJsonRecord(value)) {\n throw new GeneratorDocumentError(\n documentFailure(\"generator_document_not_object\", []),\n );\n }\n const sourceVersion = value.schemaVersion;\n if (\n !Number.isSafeInteger(sourceVersion) ||\n sourceVersion !== migration.from\n ) {\n throw new SchemaVersionError({\n code: \"schema_version_unsupported\",\n path: [\"schemaVersion\"],\n severity: \"error\",\n message: `schemaVersion must be ${migration.from} before this migration.`,\n details: { supportedVersions: [migration.to] },\n });\n }\n\n const source = JSON.parse(JSON.stringify(value)) as JsonObject;\n let migrated: unknown;\n try {\n migrated = migration.migrate(source);\n } catch (cause) {\n throw normalizeConstructaError(cause, {\n kind: \"configuration\",\n code: \"INVALID_CONFIGURATION\",\n path: [\"migration\"],\n message: \"Document migration failed.\",\n });\n }\n return parseDocument(migrated);\n}\n\ntype DocumentParser = (\n value: unknown,\n path: ValidationPath,\n) => GeneratorDocumentV1;\n\nconst DOCUMENT_PARSERS: ReadonlyMap<SchemaVersion, DocumentParser> = new Map([\n [CURRENT_SCHEMA_VERSION, parseCurrentDocument],\n]);\n\nfunction resolveDocumentParser(\n value: unknown,\n path: ValidationPath,\n): DocumentParser {\n if (!isJsonRecord(value) || !Object.hasOwn(value, \"schemaVersion\")) {\n assertDocument(value, path);\n throw new ConstructaError({\n kind: \"system\",\n code: \"INVALID_CONFIGURATION\",\n path,\n message:\n \"Document validation unexpectedly succeeded without a schema version.\",\n });\n }\n const parser = DOCUMENT_PARSERS.get(value.schemaVersion as SchemaVersion);\n if (parser === undefined) {\n const failure = findSchemaVersionValueFailure(\n value.schemaVersion,\n appendPathSegment(path, \"schemaVersion\"),\n );\n if (failure !== undefined) throw new SchemaVersionError(failure);\n }\n return parser ?? parseCurrentDocument;\n}\n\nfunction parseCurrentDocument(\n value: unknown,\n path: ValidationPath,\n): GeneratorDocumentV1 {\n assertDocument(value, path);\n return value;\n}\n\nfunction assertDocumentMigration(migration: DocumentMigration): void {\n if (\n typeof migration !== \"object\" ||\n migration === null ||\n !Number.isSafeInteger(migration.from) ||\n migration.from < 0 ||\n !isSchemaVersion(migration.to) ||\n typeof migration.migrate !== \"function\"\n ) {\n throw new ConstructaError({\n kind: \"configuration\",\n code: \"INVALID_CONFIGURATION\",\n path: [\"migration\"],\n message:\n \"A migration must declare a non-negative source version, a supported target version, and a migrate function.\",\n });\n }\n}\n\n/**\n * Serializes a portable definition with recursively sorted object keys and a\n * trailing newline. The result is intended for stable diffs, not execution.\n */\nexport function serializeDefinition(value: unknown): string {\n assertGeneratorDefinition(value);\n return serializeCanonicalJson(value);\n}\n\n/** Serializes a validated versioned document using the same canonical format. */\nexport function serializeDocument(value: unknown): string {\n assertDocument(value);\n return serializeCanonicalJson(value);\n}\n\nfunction serializeCanonicalJson(value: JsonValue): string {\n return `${JSON.stringify(canonicalizeJson(value), null, 2)}\\n`;\n}\n\nfunction canonicalizeJson(value: JsonValue): JsonValue {\n if (Array.isArray(value)) return value.map(canonicalizeJson);\n if (isJsonRecord(value)) {\n const result: Record<string, JsonValue> = {};\n for (const key of Object.keys(value).sort()) {\n result[key] = canonicalizeJson(value[key] as JsonValue);\n }\n return result;\n }\n return value;\n}\n\n/** Returns the validation issue when a value is not portable JSON. */\nexport function validateJsonValue(\n value: unknown,\n path: ValidationPath = [],\n): readonly ValidationIssue[] {\n const error = findJsonValueError(value, path);\n return error === undefined\n ? []\n : [{ code: \"invalid_json_value\", path: error.path, message: error.reason }];\n}\n\nfunction findJsonValueError(\n value: unknown,\n path: ValidationPath,\n): { path: ValidationPath; reason: string } | undefined {\n return findJsonValueErrorInternal(value, path, new Set());\n}\n\n/** Returns all independent document validation issues in deterministic order. */\nexport function validateDocument(\n value: unknown,\n path: ValidationPath = [],\n): readonly GeneratorDocumentFailure[] {\n const jsonError = findJsonValueError(value, path);\n if (jsonError !== undefined) {\n return [\n documentFailure(\n \"generator_document_not_json\",\n jsonError.path,\n jsonError.reason,\n ),\n ];\n }\n if (!isJsonRecord(value)) {\n return [documentFailure(\"generator_document_not_object\", path)];\n }\n\n const issues: GeneratorDocumentFailure[] = [];\n if (Object.hasOwn(value, \"configuration\") && Object.hasOwn(value, \"type\")) {\n issues.push(documentFailure(\"configuration_envelope_removed\", path));\n }\n for (const key of Object.keys(value)) {\n if (!GENERATOR_DOCUMENT_TOP_LEVEL_KEYS.includes(key as never)) {\n issues.push(\n documentFailure(\n \"top_level_property_unknown\",\n appendPathSegment(path, key),\n `Unknown top-level property: ${key}`,\n ),\n );\n }\n }\n\n const versionFailure = findSchemaVersionFailure(value, path);\n if (versionFailure !== undefined) issues.push(versionFailure);\n for (const property of [\"name\", \"description\"] as const) {\n if (Object.hasOwn(value, property) && typeof value[property] !== \"string\") {\n issues.push(\n documentFailure(\n property === \"name\" ? \"name_invalid\" : \"description_invalid\",\n appendPathSegment(path, property),\n ),\n );\n }\n }\n if (!Object.hasOwn(value, \"definition\")) {\n issues.push(\n documentFailure(\n \"definition_missing\",\n appendPathSegment(path, \"definition\"),\n ),\n );\n } else {\n issues.push(\n ...validateGeneratorDefinition(\n value.definition,\n appendPathSegment(path, \"definition\"),\n ),\n );\n }\n return issues;\n}\n\n/** Returns definition issues. Nested typed definitions are validated recursively. */\nexport function validateGeneratorDefinition(\n value: unknown,\n path: ValidationPath = [],\n): readonly GeneratorDefinitionFailure[] {\n const jsonError = findJsonValueError(value, path);\n if (jsonError !== undefined) {\n return [\n definitionFailure(\n \"generator_definition_not_json\",\n jsonError.path,\n jsonError.reason,\n ),\n ];\n }\n if (!isJsonRecord(value)) {\n return [definitionFailure(\"generator_definition_not_object\", path)];\n }\n\n const issues: GeneratorDefinitionFailure[] = [];\n collectDefinitionMetadataIssues(value as JsonObject, path, issues, true);\n return issues;\n}\n/** Returns metadata validation failures without throwing. */\nexport function validateGeneratorMetadata(\n value: unknown,\n path: ValidationPath = [],\n): readonly GeneratorMetadataFailure[] {\n const failure = findGeneratorMetadataFailure(value, path);\n return failure === undefined ? [] : [failure];\n}\n\nfunction findGeneratorMetadataFailure(\n value: unknown,\n path: ValidationPath = [],\n): GeneratorMetadataFailure | undefined {\n const jsonError = findJsonValueError(value, path);\n if (jsonError !== undefined) {\n return metadataFailure(\n \"generator_metadata_not_json\",\n jsonError.path,\n jsonError.reason,\n );\n }\n if (!isJsonRecord(value)) {\n return metadataFailure(\"generator_metadata_not_object\", path);\n }\n\n const unknownKey = Object.keys(value).find(\n (key) => !GENERATOR_METADATA_KEYS.includes(key as never),\n );\n if (unknownKey !== undefined) {\n return metadataFailure(\n \"metadata_property_unknown\",\n appendPathSegment(path, unknownKey),\n `Unknown metadata property: ${unknownKey}`,\n );\n }\n\n for (const property of [\"typeId\", \"category\", \"outputCategory\"] as const) {\n if (\n Object.hasOwn(value, property) &&\n (typeof value[property] !== \"string\" || !isMetadataId(value[property]))\n ) {\n const code =\n property === \"typeId\"\n ? \"metadata_type_id_invalid\"\n : property === \"category\"\n ? \"metadata_category_invalid\"\n : \"metadata_output_category_invalid\";\n return metadataFailure(code, appendPathSegment(path, property));\n }\n }\n\n for (const property of [\n \"displayName\",\n \"description\",\n \"documentationUrl\",\n ] as const) {\n if (Object.hasOwn(value, property) && typeof value[property] !== \"string\") {\n const code =\n property === \"displayName\"\n ? \"metadata_display_name_invalid\"\n : property === \"description\"\n ? \"metadata_description_invalid\"\n : \"metadata_documentation_url_invalid\";\n return metadataFailure(code, appendPathSegment(path, property));\n }\n }\n\n if (Object.hasOwn(value, \"examples\") && !Array.isArray(value.examples)) {\n return metadataFailure(\n \"metadata_examples_invalid\",\n appendPathSegment(path, \"examples\"),\n );\n }\n\n return undefined;\n}\nfunction findSchemaVersionFailure(\n value: unknown,\n path: ValidationPath = [],\n): SchemaVersionFailure | undefined {\n if (!isJsonRecord(value) || !Object.hasOwn(value, \"schemaVersion\"))\n return createSchemaVersionFailure(\n \"schema_version_missing\",\n appendPathSegment(path, \"schemaVersion\"),\n );\n return findSchemaVersionValueFailure(\n value.schemaVersion,\n appendPathSegment(path, \"schemaVersion\"),\n );\n}\nfunction findSchemaVersionValueFailure(\n value: unknown,\n path: ValidationPath = [\"schemaVersion\"],\n): SchemaVersionFailure | undefined {\n return isSchemaVersion(value)\n ? undefined\n : createSchemaVersionFailure(\"schema_version_unsupported\", path);\n}\n\nfunction createSchemaVersionFailure(\n code: SchemaVersionFailureCode,\n path: ValidationPath,\n): SchemaVersionFailure {\n return {\n code,\n message:\n code === \"schema_version_missing\"\n ? `schemaVersion is required and must be ${CURRENT_SCHEMA_VERSION}`\n : `schemaVersion must be ${CURRENT_SCHEMA_VERSION}`,\n path,\n severity: \"error\",\n details: { supportedVersions: SUPPORTED_SCHEMA_VERSIONS },\n };\n}\nfunction definitionFailure(\n code: GeneratorDefinitionFailureCode,\n path: ValidationPath,\n message?: string,\n): GeneratorDefinitionFailure {\n const messages: Record<GeneratorDefinitionFailureCode, string> = {\n generator_definition_not_json:\n \"generator definition must be portable JSON data\",\n generator_definition_not_object:\n \"generator definition must be a JSON object\",\n generator_type_missing: \"type is required\",\n generator_type_invalid: \"type must be a non-empty string\",\n definition_document_metadata:\n \"document metadata is not allowed in a generator definition\",\n };\n return { code, message: message ?? messages[code], path, severity: \"error\" };\n}\nfunction metadataFailure(\n code: GeneratorMetadataFailureCode,\n path: ValidationPath,\n message?: string,\n): GeneratorMetadataFailure {\n const messages: Record<GeneratorMetadataFailureCode, string> = {\n generator_metadata_not_json:\n \"generator metadata must be portable JSON data\",\n generator_metadata_not_object: \"generator metadata must be a JSON object\",\n metadata_type_id_invalid: \"typeId must be a stable metadata ID\",\n metadata_display_name_invalid: \"displayName must be a string when present\",\n metadata_description_invalid: \"description must be a string when present\",\n metadata_category_invalid: \"category must be a stable metadata ID\",\n metadata_output_category_invalid:\n \"outputCategory must be a stable metadata ID\",\n metadata_documentation_url_invalid:\n \"documentationUrl must be a string when present\",\n metadata_examples_invalid: \"examples must be an array when present\",\n metadata_property_unknown: \"unknown metadata properties are not allowed\",\n };\n return { code, message: message ?? messages[code], path, severity: \"error\" };\n}\nfunction documentFailure(\n code: Exclude<GeneratorDocumentFailureCode, SchemaVersionFailureCode>,\n path: ValidationPath,\n message?: string,\n): Exclude<GeneratorDocumentFailure, SchemaVersionFailure> {\n const messages: Record<\n Exclude<GeneratorDocumentFailureCode, SchemaVersionFailureCode>,\n string\n > = {\n generator_document_not_json:\n \"generator document must be portable JSON data\",\n generator_document_not_object: \"generator document must be a JSON object\",\n generator_definition_not_json:\n \"generator definition must be portable JSON data\",\n generator_definition_not_object:\n \"generator definition must be a JSON object\",\n generator_type_missing: \"type is required\",\n generator_type_invalid: \"type must be a non-empty string\",\n definition_document_metadata:\n \"document metadata is not allowed in a generator definition\",\n definition_missing: \"definition is required\",\n name_invalid: \"name must be a string when present\",\n description_invalid: \"description must be a string when present\",\n top_level_property_unknown: \"unknown top-level properties are not allowed\",\n configuration_envelope_removed:\n \"The configuration envelope was removed; put generator fields directly inside definition.\",\n };\n return { code, message: message ?? messages[code], path, severity: \"error\" };\n}\nfunction appendPathSegment(\n path: ValidationPath,\n segment: ValidationPathSegment,\n): ValidationPath {\n return [...path, segment];\n}\n\nfunction validateConstructaErrorOptions(options: ConstructaErrorOptions): void {\n if (!CONSTRUCTA_ERROR_KINDS.includes(options.kind)) {\n throw new TypeError(\"kind must be a Constructa error kind\");\n }\n if (!/^[A-Z][A-Z0-9_]*$/u.test(options.code)) {\n throw new TypeError(\"code must be an uppercase stable error code\");\n }\n if (typeof options.message !== \"string\" || options.message.length === 0) {\n throw new TypeError(\"message must be a non-empty string\");\n }\n for (const segment of options.path) {\n if (\n typeof segment !== \"string\" &&\n (typeof segment !== \"number\" || !Number.isSafeInteger(segment))\n ) {\n throw new TypeError(\"path segments must be strings or safe integers\");\n }\n }\n if (\n options.details !== undefined &&\n (!isJsonRecord(options.details) || !isJsonValue(options.details))\n ) {\n throw new TypeError(\"details must be a portable JSON object\");\n }\n}\n\nfunction isMetadataId(value: string) {\n return /^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u.test(value);\n}\n\nfunction collectDefinitionMetadataIssues(\n value: JsonObject,\n path: ValidationPath,\n issues: GeneratorDefinitionFailure[],\n isDefinition: boolean,\n): void {\n if (isDefinition) {\n if (!Object.hasOwn(value, \"type\")) {\n issues.push(\n definitionFailure(\n \"generator_type_missing\",\n appendPathSegment(path, \"type\"),\n ),\n );\n } else if (\n typeof value.type !== \"string\" ||\n value.type.trim().length === 0\n ) {\n issues.push(\n definitionFailure(\n \"generator_type_invalid\",\n appendPathSegment(path, \"type\"),\n ),\n );\n }\n for (const key of Object.keys(value)) {\n if (key !== \"type\" && DOCUMENT_METADATA_KEYS.has(key)) {\n issues.push(\n definitionFailure(\n \"definition_document_metadata\",\n appendPathSegment(path, key),\n ),\n );\n }\n }\n }\n\n for (const [key, child] of Object.entries(value)) {\n if (key === \"type\") continue;\n collectNestedDefinitionMetadataIssues(\n child,\n appendPathSegment(path, key),\n issues,\n );\n }\n}\n\nfunction collectNestedDefinitionMetadataIssues(\n value: JsonValue,\n path: ValidationPath,\n issues: GeneratorDefinitionFailure[],\n): void {\n if (Array.isArray(value)) {\n for (let index = 0; index < value.length; index += 1) {\n collectNestedDefinitionMetadataIssues(\n value[index],\n appendPathSegment(path, index),\n issues,\n );\n }\n return;\n }\n if (!isJsonRecord(value)) return;\n collectDefinitionMetadataIssues(\n value,\n path,\n issues,\n Object.hasOwn(value, \"type\"),\n );\n}\n\nfunction isJsonRecord(value: unknown): value is Record<string, unknown> {\n const prototype =\n typeof value === \"object\" && value !== null\n ? Object.getPrototypeOf(value)\n : undefined;\n return (\n typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value) &&\n (prototype === null || prototype === Object.prototype)\n );\n}\nfunction findJsonValueErrorInternal(\n value: unknown,\n path: ValidationPath,\n ancestors: Set<object>,\n): { path: ValidationPath; reason: string } | undefined {\n switch (typeof value) {\n case \"boolean\":\n case \"string\":\n return undefined;\n case \"number\":\n if (!Number.isFinite(value))\n return { path, reason: \"number must be finite\" };\n return Object.is(value, -0)\n ? { path, reason: \"number must not be negative zero\" }\n : undefined;\n case \"object\":\n return value === null\n ? undefined\n : findJsonObjectError(value, path, ancestors);\n case \"bigint\":\n case \"function\":\n case \"symbol\":\n case \"undefined\":\n return { path, reason: `${typeof value} is not JSON-compatible` };\n }\n}\nfunction findJsonObjectError(\n value: object,\n path: ValidationPath,\n ancestors: Set<object>,\n): { path: ValidationPath; reason: string } | undefined {\n if (ancestors.has(value))\n return { path, reason: \"cyclic objects are not JSON-compatible\" };\n if (\n \"toJSON\" in value &&\n typeof (value as { readonly toJSON?: unknown }).toJSON === \"function\"\n )\n return { path, reason: \"objects with toJSON behavior are not portable\" };\n ancestors.add(value);\n const error = Array.isArray(value)\n ? findJsonArrayError(value, path, ancestors)\n : findJsonRecordError(value, path, ancestors);\n ancestors.delete(value);\n return error;\n}\nfunction findJsonArrayError(\n value: readonly unknown[],\n path: ValidationPath,\n ancestors: Set<object>,\n): { path: ValidationPath; reason: string } | undefined {\n const extraProperty = Object.keys(value).find((key) => !isArrayIndexKey(key));\n if (extraProperty !== undefined)\n return {\n path: appendPathSegment(path, extraProperty),\n reason: \"array object properties would be omitted from JSON\",\n };\n const propertyError = findUnsupportedOwnProperty(value, path, [\"length\"]);\n if (propertyError !== undefined) return propertyError;\n for (let index = 0; index < value.length; index += 1) {\n if (!(index in value))\n return {\n path: appendPathSegment(path, index),\n reason: \"sparse array slots are not JSON-compatible\",\n };\n const itemError = findJsonValueErrorInternal(\n value[index],\n appendPathSegment(path, index),\n ancestors,\n );\n if (itemError !== undefined) return itemError;\n }\n return undefined;\n}\nfunction isArrayIndexKey(key: string) {\n const index = Number(key);\n return (\n Number.isInteger(index) &&\n index >= 0 &&\n index < 2 ** 32 - 1 &&\n String(index) === key\n );\n}\nfunction findJsonRecordError(\n value: object,\n path: ValidationPath,\n ancestors: Set<object>,\n): { path: ValidationPath; reason: string } | undefined {\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== null && prototype !== Object.prototype)\n return { path, reason: \"object must be a plain JSON record\" };\n const propertyError = findUnsupportedOwnProperty(value, path);\n if (propertyError !== undefined) return propertyError;\n for (const key of Object.keys(value)) {\n const itemError = findJsonValueErrorInternal(\n (value as Record<string, unknown>)[key],\n appendPathSegment(path, key),\n ancestors,\n );\n if (itemError !== undefined) return itemError;\n }\n return undefined;\n}\nfunction findUnsupportedOwnProperty(\n value: object,\n path: ValidationPath,\n allowedNonEnumerableProperties: readonly string[] = [],\n): { path: ValidationPath; reason: string } | undefined {\n if (Object.hasOwn(value, \"__proto__\")) {\n return {\n path: appendPathSegment(path, \"__proto__\"),\n reason: \"__proto__ keys are not portable JSON data\",\n };\n }\n if (Object.getOwnPropertySymbols(value).length > 0)\n return { path, reason: \"symbol keys are not JSON-compatible\" };\n const allowed = new Set(allowedNonEnumerableProperties);\n for (const [key, descriptor] of Object.entries(\n Object.getOwnPropertyDescriptors(value),\n )) {\n if (\"get\" in descriptor || \"set\" in descriptor)\n return {\n path: appendPathSegment(path, key),\n reason: \"accessor properties are not portable JSON data\",\n };\n if (!descriptor.enumerable && !allowed.has(key))\n return {\n path: appendPathSegment(path, key),\n reason: \"non-enumerable properties would be omitted from JSON\",\n };\n }\n return undefined;\n}\n"],"mappings":";;AAsBA,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;AACF;;AAKA,MAAa,kCAAkC;CAC7C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAiBA,IAAa,kBAAb,cAAqC,UAAU;CAC7C;CACA;CACA;CACA;CACA;CAEA,YAAY,SAAiC,OAAiB;EAC5D,+BAA+B,OAAO;EACtC,MAAM,QAAQ,OAAO;EACrB,KAAK,OAAO;EACZ,KAAK,OAAO,QAAQ;EACpB,KAAK,OAAO,QAAQ;EACpB,KAAK,OAAO,QAAQ;EACpB,KAAK,UAAU,QAAQ;EACvB,KAAKA,SAAS;CAChB;;CAGA,SAA8B;EAC5B,OAAO,KAAK,YAAY,KAAA,IACpB;GACE,MAAM,KAAK;GACX,MAAM,KAAK;GACX,MAAM,KAAK;GACX,SAAS,KAAK;EAChB,IACA;GACE,MAAM,KAAK;GACX,MAAM,KAAK;GACX,MAAM,KAAK;GACX,SAAS,KAAK;GACd,SAAS,KAAK;EAChB;CACN;CAEA,WAAoB;EAClB,OAAO,KAAKA,WAAW,KAAA;CACzB;AACF;;AAGA,SAAgB,sBACd,SACiB;CACjB,OAAO,IAAI,gBAAgB,OAAO;AACpC;;AAGA,SAAgB,yBACd,OACA,SACiB;CACjB,OAAO,iBAAiB,kBACpB,QACA,IAAI,gBAAg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C,QAAQ,IAAI,GAAG,GAC5C,OAAO;GACL,MAAM,kBAAkB,MAAM,GAAG;GACjC,QAAQ;EACV;CACJ;AAEF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "constructa-schema",
3
- "version": "2.3.0",
3
+ "version": "2.4.1",
4
4
  "description": "Portable schemas and types for Constructa generator definitions.",
5
5
  "private": false,
6
6
  "license": "MIT",