constructa-schema 1.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -1
- package/dist/index.d.ts +91 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +246 -70
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,7 +27,27 @@ A `GeneratorDocumentV1` wraps exactly one root definition and carries versioning
|
|
|
27
27
|
|
|
28
28
|
`name` and `description` are optional strings; empty strings are preserved rather than normalized. Unknown document keys are rejected. Document metadata, ownership, visibility, and timestamps do not belong in generator definitions. The former `{ type, configuration }` envelope is rejected; move its generator fields directly into `definition`.
|
|
29
29
|
|
|
30
|
-
Use `parseDocument` to validate and obtain a `GeneratorDocumentV1`, or `safeParseDocument`
|
|
30
|
+
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.
|
|
31
|
+
|
|
32
|
+
## Validation issues
|
|
33
|
+
|
|
34
|
+
Validation APIs expose stable issues with a `code`, human-readable `message`, segment-based `path`, and optional JSON-safe `details`. A path is a `readonly (string | number)[]`: a property named `profile.age` remains the single segment `"profile.age"`, while an array item uses a numeric segment such as `0`.
|
|
35
|
+
|
|
36
|
+
Use `validateDocument` to receive every independent document issue in deterministic order, or `validateGeneratorDefinition` for a definition and its nested typed definitions. `parseDocument` and `safeParseDocument` use the first issue when a single parse result is required. Path rendering is intentionally left to the consuming interface.
|
|
37
|
+
|
|
38
|
+
## Structured errors
|
|
39
|
+
|
|
40
|
+
`ConstructaError` is the shared safe error model. Every error has a `kind` (`configuration`, `dependency`, `execution`, or `system`), an uppercase stable `code`, segment `path`, human-readable `message`, and optional JSON-safe `details`. Reserved codes include `INVALID_RANGE`, `EMPTY_CHOICE`, `INVALID_LENGTH`, `UNKNOWN_GENERATOR`, `REFERENCE_NOT_FOUND`, `CIRCULAR_REFERENCE`, `EXECUTION_FAILED`, and `UNSUPPORTED_SCHEMA_VERSION`.
|
|
41
|
+
|
|
42
|
+
Use `createConstructaError` for a known failure or `normalizeConstructaError` to wrap an unknown cause. Calling `toJSON()` returns only the safe error data; original causes are never serialized. Schema validation exceptions are categorized as configuration errors.
|
|
43
|
+
|
|
44
|
+
## Semantic generator metadata
|
|
45
|
+
|
|
46
|
+
`GeneratorMetadata` describes a generator without influencing execution. All fields are optional so third-party generators can provide only what they know: `typeId`, `displayName`, `description`, `category`, `outputCategory`, `documentationUrl`, and JSON-only `examples`.
|
|
47
|
+
|
|
48
|
+
Metadata IDs use lowercase stable identifiers (for example, `integer`, `numeric`, or `date-time`). `outputCategory` is a coarse preview hint only; it does not replace runtime validation or future TypeScript output inference. Presentation details—including React components, icons, CSS classes, controls, routes, and layout—are deliberately not part of this contract.
|
|
49
|
+
|
|
50
|
+
Use `isGeneratorMetadata`, `assertGeneratorMetadata`, or `validateGeneratorMetadata` to validate metadata.
|
|
31
51
|
|
|
32
52
|
## Dependency boundary
|
|
33
53
|
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,40 @@ type JsonArray = readonly JsonValue[];
|
|
|
5
5
|
type JsonObject = {
|
|
6
6
|
readonly [key: string]: JsonValue;
|
|
7
7
|
};
|
|
8
|
+
type ValidationPathSegment = string | number;
|
|
9
|
+
type ValidationPath = readonly ValidationPathSegment[];
|
|
10
|
+
type ValidationIssue = {
|
|
11
|
+
readonly code: string;
|
|
12
|
+
readonly path: ValidationPath;
|
|
13
|
+
readonly message: string;
|
|
14
|
+
readonly details?: JsonObject;
|
|
15
|
+
};
|
|
16
|
+
declare const CONSTRUCTA_ERROR_KINDS: readonly ["configuration", "dependency", "execution", "system"];
|
|
17
|
+
type ConstructaErrorKind = (typeof CONSTRUCTA_ERROR_KINDS)[number];
|
|
18
|
+
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"];
|
|
19
|
+
type ConstructaErrorCode = Uppercase<string>;
|
|
20
|
+
type ConstructaErrorOptions = {
|
|
21
|
+
readonly kind: ConstructaErrorKind;
|
|
22
|
+
readonly code: ConstructaErrorCode;
|
|
23
|
+
readonly path: ValidationPath;
|
|
24
|
+
readonly message: string;
|
|
25
|
+
readonly details?: JsonObject;
|
|
26
|
+
};
|
|
27
|
+
type SafeConstructaError = ConstructaErrorOptions;
|
|
28
|
+
/** A safe, serializable error shared by every Constructa surface. */
|
|
29
|
+
declare class ConstructaError extends TypeError {
|
|
30
|
+
#private;
|
|
31
|
+
readonly kind: ConstructaErrorKind;
|
|
32
|
+
readonly code: ConstructaErrorCode;
|
|
33
|
+
readonly path: ValidationPath;
|
|
34
|
+
readonly details?: JsonObject;
|
|
35
|
+
constructor(options: ConstructaErrorOptions, cause?: unknown);
|
|
36
|
+
/** Returns only data that is safe to send across a process or network boundary. */
|
|
37
|
+
toJSON(): SafeConstructaError;
|
|
38
|
+
hasCause(): boolean;
|
|
39
|
+
}
|
|
40
|
+
declare function createConstructaError(options: ConstructaErrorOptions): ConstructaError;
|
|
41
|
+
declare function normalizeConstructaError(cause: unknown, options: ConstructaErrorOptions): ConstructaError;
|
|
8
42
|
declare const CURRENT_SCHEMA_VERSION = 1;
|
|
9
43
|
declare const SUPPORTED_SCHEMA_VERSIONS: readonly [1];
|
|
10
44
|
type SchemaVersion = (typeof SUPPORTED_SCHEMA_VERSIONS)[number];
|
|
@@ -20,27 +54,54 @@ type GeneratorDocumentV1 = {
|
|
|
20
54
|
readonly description?: string;
|
|
21
55
|
};
|
|
22
56
|
type GeneratorDocument = GeneratorDocumentV1;
|
|
57
|
+
/** A stable, lowercase identifier used to classify portable metadata. */
|
|
58
|
+
type SemanticMetadataId = string;
|
|
59
|
+
/** A coarse output-preview classification, not an execution or inference type. */
|
|
60
|
+
type GeneratorOutputCategory = SemanticMetadataId;
|
|
61
|
+
/**
|
|
62
|
+
* Portable, descriptive metadata for a generator implementation.
|
|
63
|
+
* It is intentionally separate from executable generator definitions.
|
|
64
|
+
*/
|
|
65
|
+
type GeneratorMetadata = {
|
|
66
|
+
readonly typeId?: SemanticMetadataId;
|
|
67
|
+
readonly displayName?: string;
|
|
68
|
+
readonly description?: string;
|
|
69
|
+
readonly category?: SemanticMetadataId;
|
|
70
|
+
readonly outputCategory?: GeneratorOutputCategory;
|
|
71
|
+
readonly documentationUrl?: string;
|
|
72
|
+
readonly examples?: readonly JsonValue[];
|
|
73
|
+
};
|
|
23
74
|
declare const GENERATOR_DOCUMENT_TOP_LEVEL_KEYS: readonly ["schemaVersion", "name", "description", "definition"];
|
|
75
|
+
declare const GENERATOR_METADATA_KEYS: readonly ["typeId", "displayName", "description", "category", "outputCategory", "documentationUrl", "examples"];
|
|
24
76
|
type SchemaVersionFailureCode = "schema_version_missing" | "schema_version_unsupported";
|
|
25
77
|
type SchemaVersionFailure = {
|
|
26
78
|
readonly code: SchemaVersionFailureCode;
|
|
27
79
|
readonly message: string;
|
|
28
|
-
readonly path:
|
|
80
|
+
readonly path: ValidationPath;
|
|
29
81
|
readonly severity: "error";
|
|
30
|
-
readonly
|
|
31
|
-
|
|
82
|
+
readonly details: {
|
|
83
|
+
readonly supportedVersions: readonly SchemaVersion[];
|
|
84
|
+
};
|
|
85
|
+
} & ValidationIssue;
|
|
32
86
|
type GeneratorDefinitionFailureCode = "generator_definition_not_json" | "generator_definition_not_object" | "generator_type_missing" | "generator_type_invalid" | "definition_document_metadata";
|
|
33
87
|
type GeneratorDefinitionFailure = {
|
|
34
88
|
readonly code: GeneratorDefinitionFailureCode;
|
|
35
89
|
readonly message: string;
|
|
36
|
-
readonly path:
|
|
90
|
+
readonly path: ValidationPath;
|
|
91
|
+
readonly severity: "error";
|
|
92
|
+
};
|
|
93
|
+
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";
|
|
94
|
+
type GeneratorMetadataFailure = {
|
|
95
|
+
readonly code: GeneratorMetadataFailureCode;
|
|
96
|
+
readonly message: string;
|
|
97
|
+
readonly path: ValidationPath;
|
|
37
98
|
readonly severity: "error";
|
|
38
99
|
};
|
|
39
100
|
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";
|
|
40
101
|
type GeneratorDocumentFailure = SchemaVersionFailure | {
|
|
41
102
|
readonly code: Exclude<GeneratorDocumentFailureCode, SchemaVersionFailureCode>;
|
|
42
103
|
readonly message: string;
|
|
43
|
-
readonly path:
|
|
104
|
+
readonly path: ValidationPath;
|
|
44
105
|
readonly severity: "error";
|
|
45
106
|
};
|
|
46
107
|
type GeneratorDocumentParseResult = {
|
|
@@ -50,18 +111,23 @@ type GeneratorDocumentParseResult = {
|
|
|
50
111
|
readonly success: false;
|
|
51
112
|
readonly failure: GeneratorDocumentFailure;
|
|
52
113
|
};
|
|
53
|
-
declare class JsonValueError extends
|
|
54
|
-
|
|
114
|
+
declare class JsonValueError extends ConstructaError {
|
|
115
|
+
readonly issue: ValidationIssue;
|
|
116
|
+
constructor(path: ValidationPath, reason: string);
|
|
55
117
|
}
|
|
56
|
-
declare class SchemaVersionError extends
|
|
118
|
+
declare class SchemaVersionError extends ConstructaError {
|
|
57
119
|
readonly failure: SchemaVersionFailure;
|
|
58
120
|
constructor(failure: SchemaVersionFailure);
|
|
59
121
|
}
|
|
60
|
-
declare class GeneratorDefinitionError extends
|
|
122
|
+
declare class GeneratorDefinitionError extends ConstructaError {
|
|
61
123
|
readonly failure: GeneratorDefinitionFailure;
|
|
62
124
|
constructor(failure: GeneratorDefinitionFailure);
|
|
63
125
|
}
|
|
64
|
-
declare class
|
|
126
|
+
declare class GeneratorMetadataError extends ConstructaError {
|
|
127
|
+
readonly failure: GeneratorMetadataFailure;
|
|
128
|
+
constructor(failure: GeneratorMetadataFailure);
|
|
129
|
+
}
|
|
130
|
+
declare class GeneratorDocumentError extends ConstructaError {
|
|
65
131
|
readonly failure: GeneratorDocumentFailure;
|
|
66
132
|
constructor(failure: GeneratorDocumentFailure);
|
|
67
133
|
}
|
|
@@ -69,20 +135,20 @@ declare function isJsonValue(value: unknown): value is JsonValue;
|
|
|
69
135
|
declare function isSchemaVersion(value: unknown): value is SchemaVersion;
|
|
70
136
|
declare function isGeneratorDefinition(value: unknown): value is GeneratorDefinition;
|
|
71
137
|
declare function isDocument(value: unknown): value is GeneratorDocumentV1;
|
|
72
|
-
declare function
|
|
73
|
-
declare function
|
|
74
|
-
declare function
|
|
75
|
-
declare function
|
|
76
|
-
declare function
|
|
77
|
-
declare function
|
|
78
|
-
declare function
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
declare function
|
|
83
|
-
|
|
84
|
-
declare function
|
|
85
|
-
declare function
|
|
138
|
+
declare function isGeneratorMetadata(value: unknown): value is GeneratorMetadata;
|
|
139
|
+
declare function assertJsonValue(value: unknown, path?: ValidationPath): asserts value is JsonValue;
|
|
140
|
+
declare function assertSchemaVersion(value: unknown, path?: ValidationPath): asserts value is SchemaVersion;
|
|
141
|
+
declare function assertGeneratorDefinition(value: unknown, path?: ValidationPath): asserts value is GeneratorDefinition;
|
|
142
|
+
declare function assertGeneratorMetadata(value: unknown, path?: ValidationPath): asserts value is GeneratorMetadata;
|
|
143
|
+
declare function assertDocument(value: unknown, path?: ValidationPath): asserts value is GeneratorDocumentV1;
|
|
144
|
+
declare function parseDocument(value: unknown, path?: ValidationPath): GeneratorDocumentV1;
|
|
145
|
+
declare function safeParseDocument(value: unknown, path?: ValidationPath): GeneratorDocumentParseResult;
|
|
146
|
+
declare function validateJsonValue(value: unknown, path?: ValidationPath): readonly ValidationIssue[];
|
|
147
|
+
/** Returns all independent document validation issues in deterministic order. */
|
|
148
|
+
declare function validateDocument(value: unknown, path?: ValidationPath): readonly GeneratorDocumentFailure[];
|
|
149
|
+
/** Returns definition issues. Nested typed definitions are validated recursively. */
|
|
150
|
+
declare function validateGeneratorDefinition(value: unknown, path?: ValidationPath): readonly GeneratorDefinitionFailure[];
|
|
151
|
+
declare function validateGeneratorMetadata(value: unknown, path?: ValidationPath): readonly GeneratorMetadataFailure[];
|
|
86
152
|
//#endregion
|
|
87
|
-
export { CURRENT_SCHEMA_VERSION, GENERATOR_DOCUMENT_TOP_LEVEL_KEYS, GeneratorDefinition, GeneratorDefinitionError, GeneratorDefinitionFailure, GeneratorDefinitionFailureCode, GeneratorDocument, GeneratorDocumentError, GeneratorDocumentFailure, GeneratorDocumentFailureCode, GeneratorDocumentParseResult, GeneratorDocumentV1, JsonArray, JsonObject, JsonPrimitive, JsonValue, JsonValueError, SUPPORTED_SCHEMA_VERSIONS, SchemaVersion, SchemaVersionError, SchemaVersionFailure, SchemaVersionFailureCode,
|
|
153
|
+
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, JsonArray, JsonObject, JsonPrimitive, JsonValue, JsonValueError, RESERVED_CONSTRUCTA_ERROR_CODES, 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, validateDocument, validateGeneratorDefinition, validateGeneratorMetadata, validateJsonValue };
|
|
88
154
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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;;
|
|
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;;KAGxB,sBAAsB;WAAwB;;;KAG9C;WACD;WACA,YAAY;WACZ;WACA;;KAGC,oBAAoB;;KAGpB;;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;iBAOa,kBACd,gBACA,OAAM,0BACI;;iBAeI,iBACd,gBACA,OAAM,0BACI;;iBA8DI,4BACd,gBACA,OAAM,0BACI;iBAmBI,0BACd,gBACA,OAAM,0BACI"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,64 @@
|
|
|
1
1
|
//#region src/index.ts
|
|
2
|
+
const CONSTRUCTA_ERROR_KINDS = [
|
|
3
|
+
"configuration",
|
|
4
|
+
"dependency",
|
|
5
|
+
"execution",
|
|
6
|
+
"system"
|
|
7
|
+
];
|
|
8
|
+
const RESERVED_CONSTRUCTA_ERROR_CODES = [
|
|
9
|
+
"INVALID_RANGE",
|
|
10
|
+
"EMPTY_CHOICE",
|
|
11
|
+
"INVALID_LENGTH",
|
|
12
|
+
"UNKNOWN_GENERATOR",
|
|
13
|
+
"REFERENCE_NOT_FOUND",
|
|
14
|
+
"CIRCULAR_REFERENCE",
|
|
15
|
+
"EXECUTION_FAILED",
|
|
16
|
+
"UNSUPPORTED_SCHEMA_VERSION",
|
|
17
|
+
"INVALID_CONFIGURATION",
|
|
18
|
+
"INVALID_JSON_VALUE"
|
|
19
|
+
];
|
|
20
|
+
/** A safe, serializable error shared by every Constructa surface. */
|
|
21
|
+
var ConstructaError = class extends TypeError {
|
|
22
|
+
kind;
|
|
23
|
+
code;
|
|
24
|
+
path;
|
|
25
|
+
details;
|
|
26
|
+
#cause;
|
|
27
|
+
constructor(options, cause) {
|
|
28
|
+
validateConstructaErrorOptions(options);
|
|
29
|
+
super(options.message);
|
|
30
|
+
this.name = "ConstructaError";
|
|
31
|
+
this.kind = options.kind;
|
|
32
|
+
this.code = options.code;
|
|
33
|
+
this.path = options.path;
|
|
34
|
+
this.details = options.details;
|
|
35
|
+
this.#cause = cause;
|
|
36
|
+
}
|
|
37
|
+
/** Returns only data that is safe to send across a process or network boundary. */
|
|
38
|
+
toJSON() {
|
|
39
|
+
return this.details === void 0 ? {
|
|
40
|
+
kind: this.kind,
|
|
41
|
+
code: this.code,
|
|
42
|
+
path: this.path,
|
|
43
|
+
message: this.message
|
|
44
|
+
} : {
|
|
45
|
+
kind: this.kind,
|
|
46
|
+
code: this.code,
|
|
47
|
+
path: this.path,
|
|
48
|
+
message: this.message,
|
|
49
|
+
details: this.details
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
hasCause() {
|
|
53
|
+
return this.#cause !== void 0;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
function createConstructaError(options) {
|
|
57
|
+
return new ConstructaError(options);
|
|
58
|
+
}
|
|
59
|
+
function normalizeConstructaError(cause, options) {
|
|
60
|
+
return cause instanceof ConstructaError ? cause : new ConstructaError(options, cause);
|
|
61
|
+
}
|
|
2
62
|
const CURRENT_SCHEMA_VERSION = 1;
|
|
3
63
|
const SUPPORTED_SCHEMA_VERSIONS = [1];
|
|
4
64
|
const GENERATOR_DOCUMENT_TOP_LEVEL_KEYS = [
|
|
@@ -7,6 +67,15 @@ const GENERATOR_DOCUMENT_TOP_LEVEL_KEYS = [
|
|
|
7
67
|
"description",
|
|
8
68
|
"definition"
|
|
9
69
|
];
|
|
70
|
+
const GENERATOR_METADATA_KEYS = [
|
|
71
|
+
"typeId",
|
|
72
|
+
"displayName",
|
|
73
|
+
"description",
|
|
74
|
+
"category",
|
|
75
|
+
"outputCategory",
|
|
76
|
+
"documentationUrl",
|
|
77
|
+
"examples"
|
|
78
|
+
];
|
|
10
79
|
const DOCUMENT_METADATA_KEYS = /* @__PURE__ */ new Set([
|
|
11
80
|
"schemaVersion",
|
|
12
81
|
"name",
|
|
@@ -18,70 +87,121 @@ const DOCUMENT_METADATA_KEYS = /* @__PURE__ */ new Set([
|
|
|
18
87
|
"updatedAt",
|
|
19
88
|
"timestamps"
|
|
20
89
|
]);
|
|
21
|
-
var JsonValueError = class extends
|
|
90
|
+
var JsonValueError = class extends ConstructaError {
|
|
91
|
+
issue;
|
|
22
92
|
constructor(path, reason) {
|
|
23
|
-
super(
|
|
93
|
+
super({
|
|
94
|
+
kind: "configuration",
|
|
95
|
+
code: "INVALID_JSON_VALUE",
|
|
96
|
+
path,
|
|
97
|
+
message: reason,
|
|
98
|
+
details: { issueCode: "invalid_json_value" }
|
|
99
|
+
});
|
|
24
100
|
this.name = "JsonValueError";
|
|
101
|
+
this.issue = {
|
|
102
|
+
code: "invalid_json_value",
|
|
103
|
+
path,
|
|
104
|
+
message: reason
|
|
105
|
+
};
|
|
25
106
|
}
|
|
26
107
|
};
|
|
27
|
-
var SchemaVersionError = class extends
|
|
108
|
+
var SchemaVersionError = class extends ConstructaError {
|
|
28
109
|
failure;
|
|
29
110
|
constructor(failure) {
|
|
30
|
-
super(
|
|
111
|
+
super({
|
|
112
|
+
kind: "configuration",
|
|
113
|
+
code: "UNSUPPORTED_SCHEMA_VERSION",
|
|
114
|
+
path: failure.path,
|
|
115
|
+
message: failure.message,
|
|
116
|
+
details: { issueCode: failure.code }
|
|
117
|
+
});
|
|
31
118
|
this.name = "SchemaVersionError";
|
|
32
119
|
this.failure = failure;
|
|
33
120
|
}
|
|
34
121
|
};
|
|
35
|
-
var GeneratorDefinitionError = class extends
|
|
122
|
+
var GeneratorDefinitionError = class extends ConstructaError {
|
|
36
123
|
failure;
|
|
37
124
|
constructor(failure) {
|
|
38
|
-
super(
|
|
125
|
+
super({
|
|
126
|
+
kind: "configuration",
|
|
127
|
+
code: "INVALID_CONFIGURATION",
|
|
128
|
+
path: failure.path,
|
|
129
|
+
message: failure.message,
|
|
130
|
+
details: { issueCode: failure.code }
|
|
131
|
+
});
|
|
39
132
|
this.name = "GeneratorDefinitionError";
|
|
40
133
|
this.failure = failure;
|
|
41
134
|
}
|
|
42
135
|
};
|
|
43
|
-
var
|
|
136
|
+
var GeneratorMetadataError = class extends ConstructaError {
|
|
137
|
+
failure;
|
|
138
|
+
constructor(failure) {
|
|
139
|
+
super({
|
|
140
|
+
kind: "configuration",
|
|
141
|
+
code: "INVALID_CONFIGURATION",
|
|
142
|
+
path: failure.path,
|
|
143
|
+
message: failure.message,
|
|
144
|
+
details: { issueCode: failure.code }
|
|
145
|
+
});
|
|
146
|
+
this.name = "GeneratorMetadataError";
|
|
147
|
+
this.failure = failure;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
var GeneratorDocumentError = class extends ConstructaError {
|
|
44
151
|
failure;
|
|
45
152
|
constructor(failure) {
|
|
46
|
-
super(
|
|
153
|
+
super({
|
|
154
|
+
kind: "configuration",
|
|
155
|
+
code: "INVALID_CONFIGURATION",
|
|
156
|
+
path: failure.path,
|
|
157
|
+
message: failure.message,
|
|
158
|
+
details: { issueCode: failure.code }
|
|
159
|
+
});
|
|
47
160
|
this.name = "GeneratorDocumentError";
|
|
48
161
|
this.failure = failure;
|
|
49
162
|
}
|
|
50
163
|
};
|
|
51
164
|
function isJsonValue(value) {
|
|
52
|
-
return
|
|
165
|
+
return validateJsonValue(value).length === 0;
|
|
53
166
|
}
|
|
54
167
|
function isSchemaVersion(value) {
|
|
55
168
|
return value === 1;
|
|
56
169
|
}
|
|
57
170
|
function isGeneratorDefinition(value) {
|
|
58
|
-
return
|
|
171
|
+
return validateGeneratorDefinition(value).length === 0;
|
|
59
172
|
}
|
|
60
173
|
function isDocument(value) {
|
|
61
|
-
return
|
|
174
|
+
return validateDocument(value).length === 0;
|
|
62
175
|
}
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
|
|
176
|
+
function isGeneratorMetadata(value) {
|
|
177
|
+
return validateGeneratorMetadata(value).length === 0;
|
|
178
|
+
}
|
|
179
|
+
function assertJsonValue(value, path = []) {
|
|
180
|
+
const [issue] = validateJsonValue(value, path);
|
|
181
|
+
if (issue !== void 0) throw new JsonValueError(issue.path, issue.message);
|
|
66
182
|
}
|
|
67
|
-
function assertSchemaVersion(value, path = "
|
|
183
|
+
function assertSchemaVersion(value, path = ["schemaVersion"]) {
|
|
68
184
|
const failure = findSchemaVersionValueFailure(value, path);
|
|
69
185
|
if (failure !== void 0) throw new SchemaVersionError(failure);
|
|
70
186
|
}
|
|
71
|
-
function assertGeneratorDefinition(value, path =
|
|
72
|
-
const failure =
|
|
187
|
+
function assertGeneratorDefinition(value, path = []) {
|
|
188
|
+
const [failure] = validateGeneratorDefinition(value, path);
|
|
73
189
|
if (failure !== void 0) throw new GeneratorDefinitionError(failure);
|
|
74
190
|
}
|
|
75
|
-
function
|
|
76
|
-
const failure =
|
|
77
|
-
if (failure !== void 0) throw new
|
|
191
|
+
function assertGeneratorMetadata(value, path = []) {
|
|
192
|
+
const [failure] = validateGeneratorMetadata(value, path);
|
|
193
|
+
if (failure !== void 0) throw new GeneratorMetadataError(failure);
|
|
78
194
|
}
|
|
79
|
-
function
|
|
195
|
+
function assertDocument(value, path = []) {
|
|
196
|
+
const [issue] = validateDocument(value, path);
|
|
197
|
+
if (issue !== void 0) throw new GeneratorDocumentError(issue);
|
|
198
|
+
}
|
|
199
|
+
function parseDocument(value, path = []) {
|
|
80
200
|
assertDocument(value, path);
|
|
81
201
|
return value;
|
|
82
202
|
}
|
|
83
|
-
function safeParseDocument(value, path =
|
|
84
|
-
const failure =
|
|
203
|
+
function safeParseDocument(value, path = []) {
|
|
204
|
+
const [failure] = validateDocument(value, path);
|
|
85
205
|
return failure === void 0 ? {
|
|
86
206
|
success: true,
|
|
87
207
|
value
|
|
@@ -90,38 +210,68 @@ function safeParseDocument(value, path = "$") {
|
|
|
90
210
|
failure
|
|
91
211
|
};
|
|
92
212
|
}
|
|
93
|
-
function
|
|
213
|
+
function validateJsonValue(value, path = []) {
|
|
214
|
+
const error = findJsonValueError(value, path);
|
|
215
|
+
return error === void 0 ? [] : [{
|
|
216
|
+
code: "invalid_json_value",
|
|
217
|
+
path: error.path,
|
|
218
|
+
message: error.reason
|
|
219
|
+
}];
|
|
220
|
+
}
|
|
221
|
+
function findJsonValueError(value, path) {
|
|
94
222
|
return findJsonValueErrorInternal(value, path, /* @__PURE__ */ new Set());
|
|
95
223
|
}
|
|
96
|
-
|
|
224
|
+
/** Returns all independent document validation issues in deterministic order. */
|
|
225
|
+
function validateDocument(value, path = []) {
|
|
97
226
|
const jsonError = findJsonValueError(value, path);
|
|
98
|
-
if (jsonError !== void 0) return
|
|
99
|
-
if (!isJsonRecord(value)) return
|
|
100
|
-
|
|
101
|
-
if (
|
|
102
|
-
const
|
|
103
|
-
if (metadataKey !== void 0) return definitionFailure("definition_document_metadata", appendPathSegment(path, metadataKey));
|
|
104
|
-
const nestedMetadataPath = findNestedDefinitionMetadataPath(value, path);
|
|
105
|
-
return nestedMetadataPath === void 0 ? void 0 : definitionFailure("definition_document_metadata", nestedMetadataPath);
|
|
106
|
-
}
|
|
107
|
-
function findDocumentFailure(value, path = "$") {
|
|
108
|
-
const jsonError = findJsonValueError(value, path);
|
|
109
|
-
if (jsonError !== void 0) return documentFailure("generator_document_not_json", jsonError.path, jsonError.reason);
|
|
110
|
-
if (!isJsonRecord(value)) return documentFailure("generator_document_not_object", path);
|
|
111
|
-
if (Object.hasOwn(value, "configuration") && Object.hasOwn(value, "type")) return documentFailure("configuration_envelope_removed", path);
|
|
112
|
-
const unknownKey = Object.keys(value).find((key) => !GENERATOR_DOCUMENT_TOP_LEVEL_KEYS.includes(key));
|
|
113
|
-
if (unknownKey !== void 0) return documentFailure("top_level_property_unknown", appendPathSegment(path, unknownKey), `Unknown top-level property: ${unknownKey}`);
|
|
227
|
+
if (jsonError !== void 0) return [documentFailure("generator_document_not_json", jsonError.path, jsonError.reason)];
|
|
228
|
+
if (!isJsonRecord(value)) return [documentFailure("generator_document_not_object", path)];
|
|
229
|
+
const issues = [];
|
|
230
|
+
if (Object.hasOwn(value, "configuration") && Object.hasOwn(value, "type")) issues.push(documentFailure("configuration_envelope_removed", path));
|
|
231
|
+
for (const key of Object.keys(value)) if (!GENERATOR_DOCUMENT_TOP_LEVEL_KEYS.includes(key)) issues.push(documentFailure("top_level_property_unknown", appendPathSegment(path, key), `Unknown top-level property: ${key}`));
|
|
114
232
|
const versionFailure = findSchemaVersionFailure(value, path);
|
|
115
|
-
if (versionFailure !== void 0)
|
|
116
|
-
for (const property of ["name", "description"]) if (Object.hasOwn(value, property) && typeof value[property] !== "string")
|
|
117
|
-
if (!Object.hasOwn(value, "definition"))
|
|
118
|
-
|
|
233
|
+
if (versionFailure !== void 0) issues.push(versionFailure);
|
|
234
|
+
for (const property of ["name", "description"]) if (Object.hasOwn(value, property) && typeof value[property] !== "string") issues.push(documentFailure(property === "name" ? "name_invalid" : "description_invalid", appendPathSegment(path, property)));
|
|
235
|
+
if (!Object.hasOwn(value, "definition")) issues.push(documentFailure("definition_missing", appendPathSegment(path, "definition")));
|
|
236
|
+
else issues.push(...validateGeneratorDefinition(value.definition, appendPathSegment(path, "definition")));
|
|
237
|
+
return issues;
|
|
238
|
+
}
|
|
239
|
+
/** Returns definition issues. Nested typed definitions are validated recursively. */
|
|
240
|
+
function validateGeneratorDefinition(value, path = []) {
|
|
241
|
+
const jsonError = findJsonValueError(value, path);
|
|
242
|
+
if (jsonError !== void 0) return [definitionFailure("generator_definition_not_json", jsonError.path, jsonError.reason)];
|
|
243
|
+
if (!isJsonRecord(value)) return [definitionFailure("generator_definition_not_object", path)];
|
|
244
|
+
const issues = [];
|
|
245
|
+
collectDefinitionMetadataIssues(value, path, issues, true);
|
|
246
|
+
return issues;
|
|
119
247
|
}
|
|
120
|
-
function
|
|
248
|
+
function validateGeneratorMetadata(value, path = []) {
|
|
249
|
+
const failure = findGeneratorMetadataFailure(value, path);
|
|
250
|
+
return failure === void 0 ? [] : [failure];
|
|
251
|
+
}
|
|
252
|
+
function findGeneratorMetadataFailure(value, path = []) {
|
|
253
|
+
const jsonError = findJsonValueError(value, path);
|
|
254
|
+
if (jsonError !== void 0) return metadataFailure("generator_metadata_not_json", jsonError.path, jsonError.reason);
|
|
255
|
+
if (!isJsonRecord(value)) return metadataFailure("generator_metadata_not_object", path);
|
|
256
|
+
const unknownKey = Object.keys(value).find((key) => !GENERATOR_METADATA_KEYS.includes(key));
|
|
257
|
+
if (unknownKey !== void 0) return metadataFailure("metadata_property_unknown", appendPathSegment(path, unknownKey), `Unknown metadata property: ${unknownKey}`);
|
|
258
|
+
for (const property of [
|
|
259
|
+
"typeId",
|
|
260
|
+
"category",
|
|
261
|
+
"outputCategory"
|
|
262
|
+
]) if (Object.hasOwn(value, property) && (typeof value[property] !== "string" || !isMetadataId(value[property]))) return metadataFailure(property === "typeId" ? "metadata_type_id_invalid" : property === "category" ? "metadata_category_invalid" : "metadata_output_category_invalid", appendPathSegment(path, property));
|
|
263
|
+
for (const property of [
|
|
264
|
+
"displayName",
|
|
265
|
+
"description",
|
|
266
|
+
"documentationUrl"
|
|
267
|
+
]) if (Object.hasOwn(value, property) && typeof value[property] !== "string") return metadataFailure(property === "displayName" ? "metadata_display_name_invalid" : property === "description" ? "metadata_description_invalid" : "metadata_documentation_url_invalid", appendPathSegment(path, property));
|
|
268
|
+
if (Object.hasOwn(value, "examples") && !Array.isArray(value.examples)) return metadataFailure("metadata_examples_invalid", appendPathSegment(path, "examples"));
|
|
269
|
+
}
|
|
270
|
+
function findSchemaVersionFailure(value, path = []) {
|
|
121
271
|
if (!isJsonRecord(value) || !Object.hasOwn(value, "schemaVersion")) return createSchemaVersionFailure("schema_version_missing", appendPathSegment(path, "schemaVersion"));
|
|
122
272
|
return findSchemaVersionValueFailure(value.schemaVersion, appendPathSegment(path, "schemaVersion"));
|
|
123
273
|
}
|
|
124
|
-
function findSchemaVersionValueFailure(value, path = "
|
|
274
|
+
function findSchemaVersionValueFailure(value, path = ["schemaVersion"]) {
|
|
125
275
|
return isSchemaVersion(value) ? void 0 : createSchemaVersionFailure("schema_version_unsupported", path);
|
|
126
276
|
}
|
|
127
277
|
function createSchemaVersionFailure(code, path) {
|
|
@@ -130,7 +280,7 @@ function createSchemaVersionFailure(code, path) {
|
|
|
130
280
|
message: code === "schema_version_missing" ? `schemaVersion is required and must be 1` : `schemaVersion must be 1`,
|
|
131
281
|
path,
|
|
132
282
|
severity: "error",
|
|
133
|
-
supportedVersions: SUPPORTED_SCHEMA_VERSIONS
|
|
283
|
+
details: { supportedVersions: SUPPORTED_SCHEMA_VERSIONS }
|
|
134
284
|
};
|
|
135
285
|
}
|
|
136
286
|
function definitionFailure(code, path, message) {
|
|
@@ -147,6 +297,25 @@ function definitionFailure(code, path, message) {
|
|
|
147
297
|
severity: "error"
|
|
148
298
|
};
|
|
149
299
|
}
|
|
300
|
+
function metadataFailure(code, path, message) {
|
|
301
|
+
return {
|
|
302
|
+
code,
|
|
303
|
+
message: message ?? {
|
|
304
|
+
generator_metadata_not_json: "generator metadata must be portable JSON data",
|
|
305
|
+
generator_metadata_not_object: "generator metadata must be a JSON object",
|
|
306
|
+
metadata_type_id_invalid: "typeId must be a stable metadata ID",
|
|
307
|
+
metadata_display_name_invalid: "displayName must be a string when present",
|
|
308
|
+
metadata_description_invalid: "description must be a string when present",
|
|
309
|
+
metadata_category_invalid: "category must be a stable metadata ID",
|
|
310
|
+
metadata_output_category_invalid: "outputCategory must be a stable metadata ID",
|
|
311
|
+
metadata_documentation_url_invalid: "documentationUrl must be a string when present",
|
|
312
|
+
metadata_examples_invalid: "examples must be an array when present",
|
|
313
|
+
metadata_property_unknown: "unknown metadata properties are not allowed"
|
|
314
|
+
}[code],
|
|
315
|
+
path,
|
|
316
|
+
severity: "error"
|
|
317
|
+
};
|
|
318
|
+
}
|
|
150
319
|
function documentFailure(code, path, message) {
|
|
151
320
|
return {
|
|
152
321
|
code,
|
|
@@ -169,29 +338,36 @@ function documentFailure(code, path, message) {
|
|
|
169
338
|
};
|
|
170
339
|
}
|
|
171
340
|
function appendPathSegment(path, segment) {
|
|
172
|
-
return path
|
|
341
|
+
return [...path, segment];
|
|
342
|
+
}
|
|
343
|
+
function validateConstructaErrorOptions(options) {
|
|
344
|
+
if (!CONSTRUCTA_ERROR_KINDS.includes(options.kind)) throw new TypeError("kind must be a Constructa error kind");
|
|
345
|
+
if (!/^[A-Z][A-Z0-9_]*$/u.test(options.code)) throw new TypeError("code must be an uppercase stable error code");
|
|
346
|
+
if (typeof options.message !== "string" || options.message.length === 0) throw new TypeError("message must be a non-empty string");
|
|
347
|
+
for (const segment of options.path) if (typeof segment !== "string" && (typeof segment !== "number" || !Number.isSafeInteger(segment))) throw new TypeError("path segments must be strings or safe integers");
|
|
348
|
+
if (options.details !== void 0 && (!isJsonRecord(options.details) || !isJsonValue(options.details))) throw new TypeError("details must be a portable JSON object");
|
|
349
|
+
}
|
|
350
|
+
function isMetadataId(value) {
|
|
351
|
+
return /^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u.test(value);
|
|
173
352
|
}
|
|
174
|
-
function
|
|
353
|
+
function collectDefinitionMetadataIssues(value, path, issues, isDefinition) {
|
|
354
|
+
if (isDefinition) {
|
|
355
|
+
if (!Object.hasOwn(value, "type")) issues.push(definitionFailure("generator_type_missing", appendPathSegment(path, "type")));
|
|
356
|
+
else if (typeof value.type !== "string" || value.type.trim().length === 0) issues.push(definitionFailure("generator_type_invalid", appendPathSegment(path, "type")));
|
|
357
|
+
for (const key of Object.keys(value)) if (key !== "type" && DOCUMENT_METADATA_KEYS.has(key)) issues.push(definitionFailure("definition_document_metadata", appendPathSegment(path, key)));
|
|
358
|
+
}
|
|
175
359
|
for (const [key, child] of Object.entries(value)) {
|
|
176
360
|
if (key === "type") continue;
|
|
177
|
-
|
|
178
|
-
if (metadataPath !== void 0) return metadataPath;
|
|
361
|
+
collectNestedDefinitionMetadataIssues(child, appendPathSegment(path, key), issues);
|
|
179
362
|
}
|
|
180
363
|
}
|
|
181
|
-
function
|
|
364
|
+
function collectNestedDefinitionMetadataIssues(value, path, issues) {
|
|
182
365
|
if (Array.isArray(value)) {
|
|
183
|
-
for (let index = 0; index < value.length; index += 1)
|
|
184
|
-
const metadataPath = findDefinitionMetadataPath(value[index], `${path}[${index}]`);
|
|
185
|
-
if (metadataPath !== void 0) return metadataPath;
|
|
186
|
-
}
|
|
366
|
+
for (let index = 0; index < value.length; index += 1) collectNestedDefinitionMetadataIssues(value[index], appendPathSegment(path, index), issues);
|
|
187
367
|
return;
|
|
188
368
|
}
|
|
189
|
-
if (!isJsonRecord(value)) return
|
|
190
|
-
|
|
191
|
-
const metadataKey = Object.keys(value).find((key) => key !== "type" && DOCUMENT_METADATA_KEYS.has(key));
|
|
192
|
-
if (metadataKey !== void 0) return appendPathSegment(path, metadataKey);
|
|
193
|
-
}
|
|
194
|
-
return findNestedDefinitionMetadataPath(value, path);
|
|
369
|
+
if (!isJsonRecord(value)) return;
|
|
370
|
+
collectDefinitionMetadataIssues(value, path, issues, Object.hasOwn(value, "type"));
|
|
195
371
|
}
|
|
196
372
|
function isJsonRecord(value) {
|
|
197
373
|
const prototype = typeof value === "object" && value !== null ? Object.getPrototypeOf(value) : void 0;
|
|
@@ -237,17 +413,17 @@ function findJsonObjectError(value, path, ancestors) {
|
|
|
237
413
|
function findJsonArrayError(value, path, ancestors) {
|
|
238
414
|
const extraProperty = Object.keys(value).find((key) => !isArrayIndexKey(key));
|
|
239
415
|
if (extraProperty !== void 0) return {
|
|
240
|
-
path:
|
|
416
|
+
path: appendPathSegment(path, extraProperty),
|
|
241
417
|
reason: "array object properties would be omitted from JSON"
|
|
242
418
|
};
|
|
243
419
|
const propertyError = findUnsupportedOwnProperty(value, path, ["length"]);
|
|
244
420
|
if (propertyError !== void 0) return propertyError;
|
|
245
421
|
for (let index = 0; index < value.length; index += 1) {
|
|
246
422
|
if (!(index in value)) return {
|
|
247
|
-
path:
|
|
423
|
+
path: appendPathSegment(path, index),
|
|
248
424
|
reason: "sparse array slots are not JSON-compatible"
|
|
249
425
|
};
|
|
250
|
-
const itemError = findJsonValueErrorInternal(value[index],
|
|
426
|
+
const itemError = findJsonValueErrorInternal(value[index], appendPathSegment(path, index), ancestors);
|
|
251
427
|
if (itemError !== void 0) return itemError;
|
|
252
428
|
}
|
|
253
429
|
}
|
|
@@ -264,7 +440,7 @@ function findJsonRecordError(value, path, ancestors) {
|
|
|
264
440
|
const propertyError = findUnsupportedOwnProperty(value, path);
|
|
265
441
|
if (propertyError !== void 0) return propertyError;
|
|
266
442
|
for (const key of Object.keys(value)) {
|
|
267
|
-
const itemError = findJsonValueErrorInternal(value[key],
|
|
443
|
+
const itemError = findJsonValueErrorInternal(value[key], appendPathSegment(path, key), ancestors);
|
|
268
444
|
if (itemError !== void 0) return itemError;
|
|
269
445
|
}
|
|
270
446
|
}
|
|
@@ -280,16 +456,16 @@ function findUnsupportedOwnProperty(value, path, allowedNonEnumerableProperties
|
|
|
280
456
|
const allowed = new Set(allowedNonEnumerableProperties);
|
|
281
457
|
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(value))) {
|
|
282
458
|
if ("get" in descriptor || "set" in descriptor) return {
|
|
283
|
-
path:
|
|
459
|
+
path: appendPathSegment(path, key),
|
|
284
460
|
reason: "accessor properties are not portable JSON data"
|
|
285
461
|
};
|
|
286
462
|
if (!descriptor.enumerable && !allowed.has(key)) return {
|
|
287
|
-
path:
|
|
463
|
+
path: appendPathSegment(path, key),
|
|
288
464
|
reason: "non-enumerable properties would be omitted from JSON"
|
|
289
465
|
};
|
|
290
466
|
}
|
|
291
467
|
}
|
|
292
468
|
//#endregion
|
|
293
|
-
export { CURRENT_SCHEMA_VERSION, GENERATOR_DOCUMENT_TOP_LEVEL_KEYS, GeneratorDefinitionError, GeneratorDocumentError, JsonValueError, SUPPORTED_SCHEMA_VERSIONS, SchemaVersionError, assertDocument, assertGeneratorDefinition, assertJsonValue, assertSchemaVersion,
|
|
469
|
+
export { CONSTRUCTA_ERROR_KINDS, CURRENT_SCHEMA_VERSION, ConstructaError, GENERATOR_DOCUMENT_TOP_LEVEL_KEYS, GENERATOR_METADATA_KEYS, GeneratorDefinitionError, GeneratorDocumentError, GeneratorMetadataError, JsonValueError, RESERVED_CONSTRUCTA_ERROR_CODES, SUPPORTED_SCHEMA_VERSIONS, SchemaVersionError, assertDocument, assertGeneratorDefinition, assertGeneratorMetadata, assertJsonValue, assertSchemaVersion, createConstructaError, isDocument, isGeneratorDefinition, isGeneratorMetadata, isJsonValue, isSchemaVersion, normalizeConstructaError, parseDocument, safeParseDocument, validateDocument, validateGeneratorDefinition, validateGeneratorMetadata, validateJsonValue };
|
|
294
470
|
|
|
295
471
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"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 const CURRENT_SCHEMA_VERSION = 1;\nexport const SUPPORTED_SCHEMA_VERSIONS = [CURRENT_SCHEMA_VERSION] as const;\nexport type SchemaVersion = (typeof SUPPORTED_SCHEMA_VERSIONS)[number];\n\n/** Portable executable generator data. Generator fields live beside `type`. */\nexport type GeneratorDefinition = JsonObject & { readonly type: string };\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\nexport const GENERATOR_DOCUMENT_TOP_LEVEL_KEYS = [\n \"schemaVersion\",\n \"name\",\n \"description\",\n \"definition\",\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: string;\n readonly severity: \"error\";\n readonly supportedVersions: readonly SchemaVersion[];\n};\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: string;\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: string;\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 TypeError {\n constructor(path: string, reason: string) {\n super(`${path}: ${reason}`);\n this.name = \"JsonValueError\";\n }\n}\n\nexport class SchemaVersionError extends TypeError {\n readonly failure: SchemaVersionFailure;\n constructor(failure: SchemaVersionFailure) {\n super(`${failure.path}: ${failure.message}`);\n this.name = \"SchemaVersionError\";\n this.failure = failure;\n }\n}\n\nexport class GeneratorDefinitionError extends TypeError {\n readonly failure: GeneratorDefinitionFailure;\n constructor(failure: GeneratorDefinitionFailure) {\n super(`${failure.path}: ${failure.message}`);\n this.name = \"GeneratorDefinitionError\";\n this.failure = failure;\n }\n}\n\nexport class GeneratorDocumentError extends TypeError {\n readonly failure: GeneratorDocumentFailure;\n constructor(failure: GeneratorDocumentFailure) {\n super(`${failure.path}: ${failure.message}`);\n this.name = \"GeneratorDocumentError\";\n this.failure = failure;\n }\n}\n\nexport function isJsonValue(value: unknown): value is JsonValue {\n return findJsonValueError(value) === undefined;\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 findGeneratorDefinitionFailure(value) === undefined;\n}\nexport function isDocument(value: unknown): value is GeneratorDocumentV1 {\n return findDocumentFailure(value) === undefined;\n}\nexport function assertJsonValue(\n value: unknown,\n path = \"$\",\n): asserts value is JsonValue {\n const error = findJsonValueError(value, path);\n if (error !== undefined) throw new JsonValueError(error.path, error.reason);\n}\nexport function assertSchemaVersion(\n value: unknown,\n path = \"$.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 = \"$\",\n): asserts value is GeneratorDefinition {\n const failure = findGeneratorDefinitionFailure(value, path);\n if (failure !== undefined) throw new GeneratorDefinitionError(failure);\n}\nexport function assertDocument(\n value: unknown,\n path = \"$\",\n): asserts value is GeneratorDocumentV1 {\n const failure = findDocumentFailure(value, path);\n if (failure !== undefined) throw new GeneratorDocumentError(failure);\n}\nexport function parseDocument(value: unknown, path = \"$\"): GeneratorDocumentV1 {\n assertDocument(value, path);\n return value;\n}\nexport function safeParseDocument(\n value: unknown,\n path = \"$\",\n): GeneratorDocumentParseResult {\n const failure = findDocumentFailure(value, path);\n return failure === undefined\n ? { success: true, value: value as GeneratorDocumentV1 }\n : { success: false, failure };\n}\n\nexport function findJsonValueError(\n value: unknown,\n path = \"$\",\n): { path: string; reason: string } | undefined {\n return findJsonValueErrorInternal(value, path, new Set());\n}\nexport function findGeneratorDefinitionFailure(\n value: unknown,\n path = \"$\",\n): GeneratorDefinitionFailure | undefined {\n const jsonError = findJsonValueError(value, path);\n if (jsonError !== undefined)\n return definitionFailure(\n \"generator_definition_not_json\",\n jsonError.path,\n jsonError.reason,\n );\n if (!isJsonRecord(value))\n return definitionFailure(\"generator_definition_not_object\", path);\n if (!Object.hasOwn(value, \"type\"))\n return definitionFailure(\n \"generator_type_missing\",\n appendPathSegment(path, \"type\"),\n );\n if (typeof value.type !== \"string\" || value.type.trim().length === 0)\n return definitionFailure(\n \"generator_type_invalid\",\n appendPathSegment(path, \"type\"),\n );\n const metadataKey = Object.keys(value).find(\n (key) => key !== \"type\" && DOCUMENT_METADATA_KEYS.has(key),\n );\n if (metadataKey !== undefined) {\n return definitionFailure(\n \"definition_document_metadata\",\n appendPathSegment(path, metadataKey),\n );\n }\n\n const nestedMetadataPath = findNestedDefinitionMetadataPath(\n value as JsonObject,\n path,\n );\n return nestedMetadataPath === undefined\n ? undefined\n : definitionFailure(\"definition_document_metadata\", nestedMetadataPath);\n}\nexport function findDocumentFailure(\n value: unknown,\n path = \"$\",\n): GeneratorDocumentFailure | undefined {\n const jsonError = findJsonValueError(value, path);\n if (jsonError !== undefined)\n return documentFailure(\n \"generator_document_not_json\",\n jsonError.path,\n jsonError.reason,\n );\n if (!isJsonRecord(value))\n return documentFailure(\"generator_document_not_object\", path);\n if (Object.hasOwn(value, \"configuration\") && Object.hasOwn(value, \"type\"))\n return documentFailure(\"configuration_envelope_removed\", path);\n const unknownKey = Object.keys(value).find(\n (key) => !GENERATOR_DOCUMENT_TOP_LEVEL_KEYS.includes(key as never),\n );\n if (unknownKey !== undefined)\n return documentFailure(\n \"top_level_property_unknown\",\n appendPathSegment(path, unknownKey),\n `Unknown top-level property: ${unknownKey}`,\n );\n const versionFailure = findSchemaVersionFailure(value, path);\n if (versionFailure !== undefined) return versionFailure;\n for (const property of [\"name\", \"description\"] as const) {\n if (Object.hasOwn(value, property) && typeof value[property] !== \"string\")\n return documentFailure(\n property === \"name\" ? \"name_invalid\" : \"description_invalid\",\n appendPathSegment(path, property),\n );\n }\n if (!Object.hasOwn(value, \"definition\"))\n return documentFailure(\n \"definition_missing\",\n appendPathSegment(path, \"definition\"),\n );\n return findGeneratorDefinitionFailure(\n value.definition,\n appendPathSegment(path, \"definition\"),\n );\n}\nexport function findSchemaVersionFailure(\n value: unknown,\n path = \"$\",\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}\nexport function findSchemaVersionValueFailure(\n value: unknown,\n path = \"$.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: string,\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 supportedVersions: SUPPORTED_SCHEMA_VERSIONS,\n };\n}\nfunction definitionFailure(\n code: GeneratorDefinitionFailureCode,\n path: string,\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 documentFailure(\n code: Exclude<GeneratorDocumentFailureCode, SchemaVersionFailureCode>,\n path: string,\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(path: string, segment: string) {\n return path === \"$\" ? `$.${segment}` : `${path}.${segment}`;\n}\n\nfunction findNestedDefinitionMetadataPath(\n value: JsonObject,\n path: string,\n): string | undefined {\n for (const [key, child] of Object.entries(value)) {\n if (key === \"type\") continue;\n\n const childPath = appendPathSegment(path, key);\n const metadataPath = findDefinitionMetadataPath(child, childPath);\n if (metadataPath !== undefined) return metadataPath;\n }\n\n return undefined;\n}\n\nfunction findDefinitionMetadataPath(\n value: JsonValue,\n path: string,\n): string | undefined {\n if (Array.isArray(value)) {\n for (let index = 0; index < value.length; index += 1) {\n const metadataPath = findDefinitionMetadataPath(\n value[index],\n `${path}[${index}]`,\n );\n if (metadataPath !== undefined) return metadataPath;\n }\n return undefined;\n }\n\n if (!isJsonRecord(value)) return undefined;\n\n if (typeof value.type === \"string\") {\n const metadataKey = Object.keys(value).find(\n (key) => key !== \"type\" && DOCUMENT_METADATA_KEYS.has(key),\n );\n if (metadataKey !== undefined) return appendPathSegment(path, metadataKey);\n }\n\n return findNestedDefinitionMetadataPath(value, path);\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: string,\n ancestors: Set<object>,\n): { path: string; 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: string,\n ancestors: Set<object>,\n): { path: string; 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: string,\n ancestors: Set<object>,\n): { path: string; reason: string } | undefined {\n const extraProperty = Object.keys(value).find((key) => !isArrayIndexKey(key));\n if (extraProperty !== undefined)\n return {\n path: `${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: `${path}[${index}]`,\n reason: \"sparse array slots are not JSON-compatible\",\n };\n const itemError = findJsonValueErrorInternal(\n value[index],\n `${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: string,\n ancestors: Set<object>,\n): { path: string; 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 `${path}.${key}`,\n ancestors,\n );\n if (itemError !== undefined) return itemError;\n }\n return undefined;\n}\nfunction findUnsupportedOwnProperty(\n value: object,\n path: string,\n allowedNonEnumerableProperties: readonly string[] = [],\n): { path: string; 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: `${path}.${key}`,\n reason: \"accessor properties are not portable JSON data\",\n };\n if (!descriptor.enumerable && !allowed.has(key))\n return {\n path: `${path}.${key}`,\n reason: \"non-enumerable properties would be omitted from JSON\",\n };\n }\n return undefined;\n}\n"],"mappings":";AAKA,MAAa,yBAAyB;AACtC,MAAa,4BAA4B,CAAA,CAAuB;AAgBhE,MAAa,oCAAoC;CAC/C;CACA;CACA;CACA;AACF;AAEA,MAAM,yCAAyB,IAAI,IAAI;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAmDD,IAAa,iBAAb,cAAoC,UAAU;CAC5C,YAAY,MAAc,QAAgB;EACxC,MAAM,GAAG,KAAK,IAAI,QAAQ;EAC1B,KAAK,OAAO;CACd;AACF;AAEA,IAAa,qBAAb,cAAwC,UAAU;CAChD;CACA,YAAY,SAA+B;EACzC,MAAM,GAAG,QAAQ,KAAK,IAAI,QAAQ,SAAS;EAC3C,KAAK,OAAO;EACZ,KAAK,UAAU;CACjB;AACF;AAEA,IAAa,2BAAb,cAA8C,UAAU;CACtD;CACA,YAAY,SAAqC;EAC/C,MAAM,GAAG,QAAQ,KAAK,IAAI,QAAQ,SAAS;EAC3C,KAAK,OAAO;EACZ,KAAK,UAAU;CACjB;AACF;AAEA,IAAa,yBAAb,cAA4C,UAAU;CACpD;CACA,YAAY,SAAmC;EAC7C,MAAM,GAAG,QAAQ,KAAK,IAAI,QAAQ,SAAS;EAC3C,KAAK,OAAO;EACZ,KAAK,UAAU;CACjB;AACF;AAEA,SAAgB,YAAY,OAAoC;CAC9D,OAAO,mBAAmB,KAAK,MAAM,KAAA;AACvC;AACA,SAAgB,gBAAgB,OAAwC;CACtE,OAAO,UAA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ACA,SAAS,oBACP,OACA,MACA,WAC8C;CAC9C,MAAM,YAAY,OAAO,eAAe,KAAK;CAC7C,IAAI,cAAc,QAAQ,cAAc,OAAO,WAC7C,OAAO;EAAE;EAAM,QAAQ;CAAqC;CAC9D,MAAM,gBAAgB,2BAA2B,OAAO,IAAI;CAC5D,IAAI,kBAAkB,KAAA,GAAW,OAAO;CACxC,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAG;EACpC,MAAM,YAAY,2BACf,MAAkC,MACnC,GAAG,KAAK,GAAG,OACX,SACF;EACA,IAAI,cAAc,KAAA,GAAW,OAAO;CACtC;AAEF;AACA,SAAS,2BACP,OACA,MACA,iCAAoD,CAAC,GACP;CAC9C,IAAI,OAAO,OAAO,OAAO,WAAW,GAClC,OAAO;EACL,MAAM,kBAAkB,MAAM,WAAW;EACzC,QAAQ;CACV;CAEF,IAAI,OAAO,sBAAsB,KAAK,CAAC,CAAC,SAAS,GAC/C,OAAO;EAAE;EAAM,QAAQ;CAAsC;CAC/D,MAAM,UAAU,IAAI,IAAI,8BAA8B;CACtD,KAAK,MAAM,CAAC,KAAK,eAAe,OAAO,QACrC,OAAO,0BAA0B,KAAK,CACxC,GAAG;EACD,IAAI,SAAS,cAAc,SAAS,YAClC,OAAO;GACL,MAAM,GAAG,KAAK,GAAG;GACjB,QAAQ;EACV;EACF,IAAI,CAAC,WAAW,cAAc,CAAC,QAAQ,IAAI,GAAG,GAC5C,OAAO;GACL,MAAM,GAAG,KAAK,GAAG;GACjB,QAAQ;EACV;CACJ;AAEF"}
|
|
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\n/** Portable executable generator data. Generator fields live beside `type`. */\nexport type GeneratorDefinition = JsonObject & { readonly type: string };\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/** 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\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,OA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