constructa-schema 0.0.4 → 2.0.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 +26 -24
- package/dist/index.d.ts +90 -38
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +254 -132
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,46 +1,48 @@
|
|
|
1
1
|
# `constructa-schema`
|
|
2
2
|
|
|
3
|
-
Portable generator definitions, validation schemas, and related types shared by every Constructa interface.
|
|
4
|
-
|
|
5
|
-
Planned areas include definition versioning, primitive and composite definitions, validation results, and safe serialization. This package must remain independent of execution, UI, network, and persistence concerns.
|
|
3
|
+
Portable generator definitions, versioned generator documents, validation schemas, and related types shared by every Constructa interface.
|
|
6
4
|
|
|
7
5
|
## Portable data constraint
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Omit optional data by leaving the property out. `undefined` is not a portable value, including in object properties or array items. Values that JSON would coerce, execute, or silently omit are rejected, including functions, symbols, bigints, `NaN`, infinities, cyclic objects, sparse arrays, custom `toJSON` behavior, class instances, maps, sets, dates, accessors, symbol keys, and non-enumerable properties.
|
|
12
|
-
|
|
13
|
-
Use `isJsonValue`, `assertJsonValue`, or `findJsonValueError` to enforce this constraint before later schema-specific validation.
|
|
7
|
+
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.
|
|
14
8
|
|
|
15
|
-
##
|
|
9
|
+
## Definitions and documents
|
|
16
10
|
|
|
17
|
-
|
|
11
|
+
A `GeneratorDefinition` is executable generator data. It has a stable, non-empty `type` discriminator, with generator-specific fields at the same level:
|
|
18
12
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
```json
|
|
14
|
+
{ "type": "integer", "min": 1, "max": 100 }
|
|
15
|
+
```
|
|
22
16
|
|
|
23
|
-
|
|
17
|
+
A `GeneratorDocumentV1` wraps exactly one root definition and carries versioning and optional display metadata:
|
|
24
18
|
|
|
25
19
|
```json
|
|
26
20
|
{
|
|
27
21
|
"schemaVersion": 1,
|
|
28
|
-
"type": "integer",
|
|
29
|
-
"configuration": {
|
|
30
|
-
"min": 1,
|
|
31
|
-
"max": 100
|
|
32
|
-
},
|
|
33
22
|
"name": "Small integer",
|
|
34
|
-
"description": "An integer in a bounded range."
|
|
23
|
+
"description": "An integer in a bounded range.",
|
|
24
|
+
"definition": { "type": "integer", "min": 1, "max": 100 }
|
|
35
25
|
}
|
|
36
26
|
```
|
|
37
27
|
|
|
38
|
-
`
|
|
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
|
+
|
|
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
|
+
## Semantic generator metadata
|
|
39
|
+
|
|
40
|
+
`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`.
|
|
39
41
|
|
|
40
|
-
|
|
42
|
+
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.
|
|
41
43
|
|
|
42
|
-
Use `
|
|
44
|
+
Use `isGeneratorMetadata`, `assertGeneratorMetadata`, or `validateGeneratorMetadata` to validate metadata.
|
|
43
45
|
|
|
44
46
|
## Dependency boundary
|
|
45
47
|
|
|
46
|
-
This is the bottom of the domain dependency graph and has no Constructa runtime dependencies.
|
|
48
|
+
This is the bottom of the domain dependency graph and has no Constructa runtime dependencies.
|
package/dist/index.d.ts
CHANGED
|
@@ -5,72 +5,124 @@ 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
|
+
};
|
|
8
16
|
declare const CURRENT_SCHEMA_VERSION = 1;
|
|
9
17
|
declare const SUPPORTED_SCHEMA_VERSIONS: readonly [1];
|
|
10
18
|
type SchemaVersion = (typeof SUPPORTED_SCHEMA_VERSIONS)[number];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
type DefinitionEnvelope = {
|
|
15
|
-
readonly schemaVersion: SchemaVersion;
|
|
19
|
+
/** Portable executable generator data. Generator fields live beside `type`. */
|
|
20
|
+
type GeneratorDefinition = JsonObject & {
|
|
16
21
|
readonly type: string;
|
|
17
|
-
|
|
22
|
+
};
|
|
23
|
+
/** Versioned document containing exactly one root generator definition. */
|
|
24
|
+
type GeneratorDocumentV1 = {
|
|
25
|
+
readonly schemaVersion: 1;
|
|
26
|
+
readonly definition: GeneratorDefinition;
|
|
18
27
|
readonly name?: string;
|
|
19
28
|
readonly description?: string;
|
|
20
29
|
};
|
|
21
|
-
|
|
30
|
+
type GeneratorDocument = GeneratorDocumentV1;
|
|
31
|
+
/** A stable, lowercase identifier used to classify portable metadata. */
|
|
32
|
+
type SemanticMetadataId = string;
|
|
33
|
+
/** A coarse output-preview classification, not an execution or inference type. */
|
|
34
|
+
type GeneratorOutputCategory = SemanticMetadataId;
|
|
35
|
+
/**
|
|
36
|
+
* Portable, descriptive metadata for a generator implementation.
|
|
37
|
+
* It is intentionally separate from executable generator definitions.
|
|
38
|
+
*/
|
|
39
|
+
type GeneratorMetadata = {
|
|
40
|
+
readonly typeId?: SemanticMetadataId;
|
|
41
|
+
readonly displayName?: string;
|
|
42
|
+
readonly description?: string;
|
|
43
|
+
readonly category?: SemanticMetadataId;
|
|
44
|
+
readonly outputCategory?: GeneratorOutputCategory;
|
|
45
|
+
readonly documentationUrl?: string;
|
|
46
|
+
readonly examples?: readonly JsonValue[];
|
|
47
|
+
};
|
|
48
|
+
declare const GENERATOR_DOCUMENT_TOP_LEVEL_KEYS: readonly ["schemaVersion", "name", "description", "definition"];
|
|
49
|
+
declare const GENERATOR_METADATA_KEYS: readonly ["typeId", "displayName", "description", "category", "outputCategory", "documentationUrl", "examples"];
|
|
22
50
|
type SchemaVersionFailureCode = "schema_version_missing" | "schema_version_unsupported";
|
|
23
51
|
type SchemaVersionFailure = {
|
|
24
52
|
readonly code: SchemaVersionFailureCode;
|
|
25
53
|
readonly message: string;
|
|
26
|
-
readonly path:
|
|
54
|
+
readonly path: ValidationPath;
|
|
55
|
+
readonly severity: "error";
|
|
56
|
+
readonly details: {
|
|
57
|
+
readonly supportedVersions: readonly SchemaVersion[];
|
|
58
|
+
};
|
|
59
|
+
} & ValidationIssue;
|
|
60
|
+
type GeneratorDefinitionFailureCode = "generator_definition_not_json" | "generator_definition_not_object" | "generator_type_missing" | "generator_type_invalid" | "definition_document_metadata";
|
|
61
|
+
type GeneratorDefinitionFailure = {
|
|
62
|
+
readonly code: GeneratorDefinitionFailureCode;
|
|
63
|
+
readonly message: string;
|
|
64
|
+
readonly path: ValidationPath;
|
|
65
|
+
readonly severity: "error";
|
|
66
|
+
};
|
|
67
|
+
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";
|
|
68
|
+
type GeneratorMetadataFailure = {
|
|
69
|
+
readonly code: GeneratorMetadataFailureCode;
|
|
70
|
+
readonly message: string;
|
|
71
|
+
readonly path: ValidationPath;
|
|
27
72
|
readonly severity: "error";
|
|
28
|
-
readonly supportedVersions: readonly SchemaVersion[];
|
|
29
73
|
};
|
|
30
|
-
type
|
|
31
|
-
type
|
|
32
|
-
|
|
33
|
-
readonly code: DefinitionEnvelopeShapeFailureCode;
|
|
74
|
+
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";
|
|
75
|
+
type GeneratorDocumentFailure = SchemaVersionFailure | {
|
|
76
|
+
readonly code: Exclude<GeneratorDocumentFailureCode, SchemaVersionFailureCode>;
|
|
34
77
|
readonly message: string;
|
|
35
|
-
readonly path:
|
|
78
|
+
readonly path: ValidationPath;
|
|
36
79
|
readonly severity: "error";
|
|
37
80
|
};
|
|
38
|
-
type
|
|
39
|
-
type DefinitionEnvelopeParseResult = {
|
|
81
|
+
type GeneratorDocumentParseResult = {
|
|
40
82
|
readonly success: true;
|
|
41
|
-
readonly value:
|
|
83
|
+
readonly value: GeneratorDocumentV1;
|
|
42
84
|
} | {
|
|
43
85
|
readonly success: false;
|
|
44
|
-
readonly failure:
|
|
86
|
+
readonly failure: GeneratorDocumentFailure;
|
|
45
87
|
};
|
|
46
88
|
declare class JsonValueError extends TypeError {
|
|
47
|
-
|
|
89
|
+
readonly issue: ValidationIssue;
|
|
90
|
+
constructor(path: ValidationPath, reason: string);
|
|
48
91
|
}
|
|
49
92
|
declare class SchemaVersionError extends TypeError {
|
|
50
93
|
readonly failure: SchemaVersionFailure;
|
|
51
94
|
constructor(failure: SchemaVersionFailure);
|
|
52
95
|
}
|
|
53
|
-
declare class
|
|
54
|
-
readonly failure:
|
|
55
|
-
constructor(failure:
|
|
96
|
+
declare class GeneratorDefinitionError extends TypeError {
|
|
97
|
+
readonly failure: GeneratorDefinitionFailure;
|
|
98
|
+
constructor(failure: GeneratorDefinitionFailure);
|
|
99
|
+
}
|
|
100
|
+
declare class GeneratorMetadataError extends TypeError {
|
|
101
|
+
readonly failure: GeneratorMetadataFailure;
|
|
102
|
+
constructor(failure: GeneratorMetadataFailure);
|
|
103
|
+
}
|
|
104
|
+
declare class GeneratorDocumentError extends TypeError {
|
|
105
|
+
readonly failure: GeneratorDocumentFailure;
|
|
106
|
+
constructor(failure: GeneratorDocumentFailure);
|
|
56
107
|
}
|
|
57
108
|
declare function isJsonValue(value: unknown): value is JsonValue;
|
|
58
109
|
declare function isSchemaVersion(value: unknown): value is SchemaVersion;
|
|
59
|
-
declare function
|
|
60
|
-
declare function
|
|
61
|
-
declare function
|
|
62
|
-
declare function
|
|
63
|
-
declare function
|
|
64
|
-
declare function
|
|
65
|
-
declare function
|
|
66
|
-
declare function
|
|
67
|
-
declare function
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
declare function
|
|
72
|
-
|
|
73
|
-
declare function
|
|
110
|
+
declare function isGeneratorDefinition(value: unknown): value is GeneratorDefinition;
|
|
111
|
+
declare function isDocument(value: unknown): value is GeneratorDocumentV1;
|
|
112
|
+
declare function isGeneratorMetadata(value: unknown): value is GeneratorMetadata;
|
|
113
|
+
declare function assertJsonValue(value: unknown, path?: ValidationPath): asserts value is JsonValue;
|
|
114
|
+
declare function assertSchemaVersion(value: unknown, path?: ValidationPath): asserts value is SchemaVersion;
|
|
115
|
+
declare function assertGeneratorDefinition(value: unknown, path?: ValidationPath): asserts value is GeneratorDefinition;
|
|
116
|
+
declare function assertGeneratorMetadata(value: unknown, path?: ValidationPath): asserts value is GeneratorMetadata;
|
|
117
|
+
declare function assertDocument(value: unknown, path?: ValidationPath): asserts value is GeneratorDocumentV1;
|
|
118
|
+
declare function parseDocument(value: unknown, path?: ValidationPath): GeneratorDocumentV1;
|
|
119
|
+
declare function safeParseDocument(value: unknown, path?: ValidationPath): GeneratorDocumentParseResult;
|
|
120
|
+
declare function validateJsonValue(value: unknown, path?: ValidationPath): readonly ValidationIssue[];
|
|
121
|
+
/** Returns all independent document validation issues in deterministic order. */
|
|
122
|
+
declare function validateDocument(value: unknown, path?: ValidationPath): readonly GeneratorDocumentFailure[];
|
|
123
|
+
/** Returns definition issues. Nested typed definitions are validated recursively. */
|
|
124
|
+
declare function validateGeneratorDefinition(value: unknown, path?: ValidationPath): readonly GeneratorDefinitionFailure[];
|
|
125
|
+
declare function validateGeneratorMetadata(value: unknown, path?: ValidationPath): readonly GeneratorMetadataFailure[];
|
|
74
126
|
//#endregion
|
|
75
|
-
export { CURRENT_SCHEMA_VERSION,
|
|
127
|
+
export { CURRENT_SCHEMA_VERSION, 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, SUPPORTED_SCHEMA_VERSIONS, SchemaVersion, SchemaVersionError, SchemaVersionFailure, SchemaVersionFailureCode, SemanticMetadataId, ValidationIssue, ValidationPath, ValidationPathSegment, assertDocument, assertGeneratorDefinition, assertGeneratorMetadata, assertJsonValue, assertSchemaVersion, isDocument, isGeneratorDefinition, isGeneratorMetadata, isJsonValue, isSchemaVersion, parseDocument, safeParseDocument, validateDocument, validateGeneratorDefinition, validateGeneratorMetadata, validateJsonValue };
|
|
76
128
|
//# 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;
|
|
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;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;;cAOvB,2BAA2B;WAC7B,SAAS;EACN,YAAA,SAAS;;cAOV,iCAAiC;WACnC,SAAS;EACN,YAAA,SAAS;;cAOV,+BAA+B;WACjC,SAAS;EACN,YAAA,SAAS;;cAOV,+BAA+B;WACjC,SAAS;EACN,YAAA,SAAS;;iBAOP,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,117 +1,283 @@
|
|
|
1
1
|
//#region src/index.ts
|
|
2
2
|
const CURRENT_SCHEMA_VERSION = 1;
|
|
3
3
|
const SUPPORTED_SCHEMA_VERSIONS = [1];
|
|
4
|
-
const
|
|
4
|
+
const GENERATOR_DOCUMENT_TOP_LEVEL_KEYS = [
|
|
5
5
|
"schemaVersion",
|
|
6
|
-
"type",
|
|
7
|
-
"configuration",
|
|
8
6
|
"name",
|
|
9
|
-
"description"
|
|
7
|
+
"description",
|
|
8
|
+
"definition"
|
|
10
9
|
];
|
|
10
|
+
const GENERATOR_METADATA_KEYS = [
|
|
11
|
+
"typeId",
|
|
12
|
+
"displayName",
|
|
13
|
+
"description",
|
|
14
|
+
"category",
|
|
15
|
+
"outputCategory",
|
|
16
|
+
"documentationUrl",
|
|
17
|
+
"examples"
|
|
18
|
+
];
|
|
19
|
+
const DOCUMENT_METADATA_KEYS = /* @__PURE__ */ new Set([
|
|
20
|
+
"schemaVersion",
|
|
21
|
+
"name",
|
|
22
|
+
"description",
|
|
23
|
+
"owner",
|
|
24
|
+
"ownership",
|
|
25
|
+
"visibility",
|
|
26
|
+
"createdAt",
|
|
27
|
+
"updatedAt",
|
|
28
|
+
"timestamps"
|
|
29
|
+
]);
|
|
11
30
|
var JsonValueError = class extends TypeError {
|
|
31
|
+
issue;
|
|
12
32
|
constructor(path, reason) {
|
|
13
|
-
super(`${path}: ${reason}`);
|
|
33
|
+
super(`${formatValidationPath(path)}: ${reason}`);
|
|
14
34
|
this.name = "JsonValueError";
|
|
35
|
+
this.issue = {
|
|
36
|
+
code: "invalid_json_value",
|
|
37
|
+
path,
|
|
38
|
+
message: reason
|
|
39
|
+
};
|
|
15
40
|
}
|
|
16
41
|
};
|
|
17
42
|
var SchemaVersionError = class extends TypeError {
|
|
18
43
|
failure;
|
|
19
44
|
constructor(failure) {
|
|
20
|
-
super(`${failure.path}: ${failure.message}`);
|
|
45
|
+
super(`${formatValidationPath(failure.path)}: ${failure.message}`);
|
|
21
46
|
this.name = "SchemaVersionError";
|
|
22
47
|
this.failure = failure;
|
|
23
48
|
}
|
|
24
49
|
};
|
|
25
|
-
var
|
|
50
|
+
var GeneratorDefinitionError = class extends TypeError {
|
|
51
|
+
failure;
|
|
52
|
+
constructor(failure) {
|
|
53
|
+
super(`${formatValidationPath(failure.path)}: ${failure.message}`);
|
|
54
|
+
this.name = "GeneratorDefinitionError";
|
|
55
|
+
this.failure = failure;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var GeneratorMetadataError = class extends TypeError {
|
|
26
59
|
failure;
|
|
27
60
|
constructor(failure) {
|
|
28
|
-
super(`${failure.path}: ${failure.message}`);
|
|
29
|
-
this.name = "
|
|
61
|
+
super(`${formatValidationPath(failure.path)}: ${failure.message}`);
|
|
62
|
+
this.name = "GeneratorMetadataError";
|
|
63
|
+
this.failure = failure;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var GeneratorDocumentError = class extends TypeError {
|
|
67
|
+
failure;
|
|
68
|
+
constructor(failure) {
|
|
69
|
+
super(`${formatValidationPath(failure.path)}: ${failure.message}`);
|
|
70
|
+
this.name = "GeneratorDocumentError";
|
|
30
71
|
this.failure = failure;
|
|
31
72
|
}
|
|
32
73
|
};
|
|
33
74
|
function isJsonValue(value) {
|
|
34
|
-
return
|
|
75
|
+
return validateJsonValue(value).length === 0;
|
|
35
76
|
}
|
|
36
77
|
function isSchemaVersion(value) {
|
|
37
78
|
return value === 1;
|
|
38
79
|
}
|
|
39
|
-
function
|
|
40
|
-
return
|
|
80
|
+
function isGeneratorDefinition(value) {
|
|
81
|
+
return validateGeneratorDefinition(value).length === 0;
|
|
41
82
|
}
|
|
42
|
-
function
|
|
43
|
-
return
|
|
83
|
+
function isDocument(value) {
|
|
84
|
+
return validateDocument(value).length === 0;
|
|
44
85
|
}
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
86
|
+
function isGeneratorMetadata(value) {
|
|
87
|
+
return validateGeneratorMetadata(value).length === 0;
|
|
88
|
+
}
|
|
89
|
+
function assertJsonValue(value, path = []) {
|
|
90
|
+
const [issue] = validateJsonValue(value, path);
|
|
91
|
+
if (issue !== void 0) throw new JsonValueError(issue.path, issue.message);
|
|
48
92
|
}
|
|
49
|
-
function assertSchemaVersion(value, path = "
|
|
93
|
+
function assertSchemaVersion(value, path = ["schemaVersion"]) {
|
|
50
94
|
const failure = findSchemaVersionValueFailure(value, path);
|
|
51
95
|
if (failure !== void 0) throw new SchemaVersionError(failure);
|
|
52
96
|
}
|
|
53
|
-
function
|
|
54
|
-
const failure =
|
|
55
|
-
if (failure !== void 0) throw new
|
|
56
|
-
assertJsonValue(value, path);
|
|
97
|
+
function assertGeneratorDefinition(value, path = []) {
|
|
98
|
+
const [failure] = validateGeneratorDefinition(value, path);
|
|
99
|
+
if (failure !== void 0) throw new GeneratorDefinitionError(failure);
|
|
57
100
|
}
|
|
58
|
-
function
|
|
59
|
-
const failure =
|
|
60
|
-
if (failure !== void 0) throw new
|
|
101
|
+
function assertGeneratorMetadata(value, path = []) {
|
|
102
|
+
const [failure] = validateGeneratorMetadata(value, path);
|
|
103
|
+
if (failure !== void 0) throw new GeneratorMetadataError(failure);
|
|
61
104
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
105
|
+
function assertDocument(value, path = []) {
|
|
106
|
+
const [issue] = validateDocument(value, path);
|
|
107
|
+
if (issue !== void 0) throw new GeneratorDocumentError(issue);
|
|
108
|
+
}
|
|
109
|
+
function parseDocument(value, path = []) {
|
|
110
|
+
assertDocument(value, path);
|
|
64
111
|
return value;
|
|
65
112
|
}
|
|
66
|
-
function
|
|
67
|
-
const failure =
|
|
68
|
-
|
|
69
|
-
failure,
|
|
70
|
-
success: false
|
|
71
|
-
};
|
|
72
|
-
return {
|
|
113
|
+
function safeParseDocument(value, path = []) {
|
|
114
|
+
const [failure] = validateDocument(value, path);
|
|
115
|
+
return failure === void 0 ? {
|
|
73
116
|
success: true,
|
|
74
117
|
value
|
|
118
|
+
} : {
|
|
119
|
+
success: false,
|
|
120
|
+
failure
|
|
75
121
|
};
|
|
76
122
|
}
|
|
77
|
-
function
|
|
123
|
+
function validateJsonValue(value, path = []) {
|
|
124
|
+
const error = findJsonValueError(value, path);
|
|
125
|
+
return error === void 0 ? [] : [{
|
|
126
|
+
code: "invalid_json_value",
|
|
127
|
+
path: error.path,
|
|
128
|
+
message: error.reason
|
|
129
|
+
}];
|
|
130
|
+
}
|
|
131
|
+
function findJsonValueError(value, path) {
|
|
78
132
|
return findJsonValueErrorInternal(value, path, /* @__PURE__ */ new Set());
|
|
79
133
|
}
|
|
80
|
-
|
|
134
|
+
/** Returns all independent document validation issues in deterministic order. */
|
|
135
|
+
function validateDocument(value, path = []) {
|
|
81
136
|
const jsonError = findJsonValueError(value, path);
|
|
82
|
-
if (jsonError !== void 0) return
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
137
|
+
if (jsonError !== void 0) return [documentFailure("generator_document_not_json", jsonError.path, jsonError.reason)];
|
|
138
|
+
if (!isJsonRecord(value)) return [documentFailure("generator_document_not_object", path)];
|
|
139
|
+
const issues = [];
|
|
140
|
+
if (Object.hasOwn(value, "configuration") && Object.hasOwn(value, "type")) issues.push(documentFailure("configuration_envelope_removed", path));
|
|
141
|
+
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}`));
|
|
87
142
|
const versionFailure = findSchemaVersionFailure(value, path);
|
|
88
|
-
if (versionFailure !== void 0)
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (
|
|
143
|
+
if (versionFailure !== void 0) issues.push(versionFailure);
|
|
144
|
+
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)));
|
|
145
|
+
if (!Object.hasOwn(value, "definition")) issues.push(documentFailure("definition_missing", appendPathSegment(path, "definition")));
|
|
146
|
+
else issues.push(...validateGeneratorDefinition(value.definition, appendPathSegment(path, "definition")));
|
|
147
|
+
return issues;
|
|
148
|
+
}
|
|
149
|
+
/** Returns definition issues. Nested typed definitions are validated recursively. */
|
|
150
|
+
function validateGeneratorDefinition(value, path = []) {
|
|
151
|
+
const jsonError = findJsonValueError(value, path);
|
|
152
|
+
if (jsonError !== void 0) return [definitionFailure("generator_definition_not_json", jsonError.path, jsonError.reason)];
|
|
153
|
+
if (!isJsonRecord(value)) return [definitionFailure("generator_definition_not_object", path)];
|
|
154
|
+
const issues = [];
|
|
155
|
+
collectDefinitionMetadataIssues(value, path, issues, true);
|
|
156
|
+
return issues;
|
|
157
|
+
}
|
|
158
|
+
function validateGeneratorMetadata(value, path = []) {
|
|
159
|
+
const failure = findGeneratorMetadataFailure(value, path);
|
|
160
|
+
return failure === void 0 ? [] : [failure];
|
|
161
|
+
}
|
|
162
|
+
function findGeneratorMetadataFailure(value, path = []) {
|
|
163
|
+
const jsonError = findJsonValueError(value, path);
|
|
164
|
+
if (jsonError !== void 0) return metadataFailure("generator_metadata_not_json", jsonError.path, jsonError.reason);
|
|
165
|
+
if (!isJsonRecord(value)) return metadataFailure("generator_metadata_not_object", path);
|
|
166
|
+
const unknownKey = Object.keys(value).find((key) => !GENERATOR_METADATA_KEYS.includes(key));
|
|
167
|
+
if (unknownKey !== void 0) return metadataFailure("metadata_property_unknown", appendPathSegment(path, unknownKey), `Unknown metadata property: ${unknownKey}`);
|
|
168
|
+
for (const property of [
|
|
169
|
+
"typeId",
|
|
170
|
+
"category",
|
|
171
|
+
"outputCategory"
|
|
172
|
+
]) 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));
|
|
173
|
+
for (const property of [
|
|
174
|
+
"displayName",
|
|
175
|
+
"description",
|
|
176
|
+
"documentationUrl"
|
|
177
|
+
]) 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));
|
|
178
|
+
if (Object.hasOwn(value, "examples") && !Array.isArray(value.examples)) return metadataFailure("metadata_examples_invalid", appendPathSegment(path, "examples"));
|
|
179
|
+
}
|
|
180
|
+
function findSchemaVersionFailure(value, path = []) {
|
|
181
|
+
if (!isJsonRecord(value) || !Object.hasOwn(value, "schemaVersion")) return createSchemaVersionFailure("schema_version_missing", appendPathSegment(path, "schemaVersion"));
|
|
110
182
|
return findSchemaVersionValueFailure(value.schemaVersion, appendPathSegment(path, "schemaVersion"));
|
|
111
183
|
}
|
|
112
|
-
function findSchemaVersionValueFailure(value, path = "
|
|
113
|
-
|
|
114
|
-
|
|
184
|
+
function findSchemaVersionValueFailure(value, path = ["schemaVersion"]) {
|
|
185
|
+
return isSchemaVersion(value) ? void 0 : createSchemaVersionFailure("schema_version_unsupported", path);
|
|
186
|
+
}
|
|
187
|
+
function createSchemaVersionFailure(code, path) {
|
|
188
|
+
return {
|
|
189
|
+
code,
|
|
190
|
+
message: code === "schema_version_missing" ? `schemaVersion is required and must be 1` : `schemaVersion must be 1`,
|
|
191
|
+
path,
|
|
192
|
+
severity: "error",
|
|
193
|
+
details: { supportedVersions: SUPPORTED_SCHEMA_VERSIONS }
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function definitionFailure(code, path, message) {
|
|
197
|
+
return {
|
|
198
|
+
code,
|
|
199
|
+
message: message ?? {
|
|
200
|
+
generator_definition_not_json: "generator definition must be portable JSON data",
|
|
201
|
+
generator_definition_not_object: "generator definition must be a JSON object",
|
|
202
|
+
generator_type_missing: "type is required",
|
|
203
|
+
generator_type_invalid: "type must be a non-empty string",
|
|
204
|
+
definition_document_metadata: "document metadata is not allowed in a generator definition"
|
|
205
|
+
}[code],
|
|
206
|
+
path,
|
|
207
|
+
severity: "error"
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function metadataFailure(code, path, message) {
|
|
211
|
+
return {
|
|
212
|
+
code,
|
|
213
|
+
message: message ?? {
|
|
214
|
+
generator_metadata_not_json: "generator metadata must be portable JSON data",
|
|
215
|
+
generator_metadata_not_object: "generator metadata must be a JSON object",
|
|
216
|
+
metadata_type_id_invalid: "typeId must be a stable metadata ID",
|
|
217
|
+
metadata_display_name_invalid: "displayName must be a string when present",
|
|
218
|
+
metadata_description_invalid: "description must be a string when present",
|
|
219
|
+
metadata_category_invalid: "category must be a stable metadata ID",
|
|
220
|
+
metadata_output_category_invalid: "outputCategory must be a stable metadata ID",
|
|
221
|
+
metadata_documentation_url_invalid: "documentationUrl must be a string when present",
|
|
222
|
+
metadata_examples_invalid: "examples must be an array when present",
|
|
223
|
+
metadata_property_unknown: "unknown metadata properties are not allowed"
|
|
224
|
+
}[code],
|
|
225
|
+
path,
|
|
226
|
+
severity: "error"
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
function documentFailure(code, path, message) {
|
|
230
|
+
return {
|
|
231
|
+
code,
|
|
232
|
+
message: message ?? {
|
|
233
|
+
generator_document_not_json: "generator document must be portable JSON data",
|
|
234
|
+
generator_document_not_object: "generator document must be a JSON object",
|
|
235
|
+
generator_definition_not_json: "generator definition must be portable JSON data",
|
|
236
|
+
generator_definition_not_object: "generator definition must be a JSON object",
|
|
237
|
+
generator_type_missing: "type is required",
|
|
238
|
+
generator_type_invalid: "type must be a non-empty string",
|
|
239
|
+
definition_document_metadata: "document metadata is not allowed in a generator definition",
|
|
240
|
+
definition_missing: "definition is required",
|
|
241
|
+
name_invalid: "name must be a string when present",
|
|
242
|
+
description_invalid: "description must be a string when present",
|
|
243
|
+
top_level_property_unknown: "unknown top-level properties are not allowed",
|
|
244
|
+
configuration_envelope_removed: "The configuration envelope was removed; put generator fields directly inside definition."
|
|
245
|
+
}[code],
|
|
246
|
+
path,
|
|
247
|
+
severity: "error"
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function appendPathSegment(path, segment) {
|
|
251
|
+
return [...path, segment];
|
|
252
|
+
}
|
|
253
|
+
function formatValidationPath(path) {
|
|
254
|
+
return path.length === 0 ? "$" : path.map((segment) => typeof segment === "number" ? `[${segment}]` : `.${segment}`).join("").replace(/^\./u, "$");
|
|
255
|
+
}
|
|
256
|
+
function isMetadataId(value) {
|
|
257
|
+
return /^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u.test(value);
|
|
258
|
+
}
|
|
259
|
+
function collectDefinitionMetadataIssues(value, path, issues, isDefinition) {
|
|
260
|
+
if (isDefinition) {
|
|
261
|
+
if (!Object.hasOwn(value, "type")) issues.push(definitionFailure("generator_type_missing", appendPathSegment(path, "type")));
|
|
262
|
+
else if (typeof value.type !== "string" || value.type.trim().length === 0) issues.push(definitionFailure("generator_type_invalid", appendPathSegment(path, "type")));
|
|
263
|
+
for (const key of Object.keys(value)) if (key !== "type" && DOCUMENT_METADATA_KEYS.has(key)) issues.push(definitionFailure("definition_document_metadata", appendPathSegment(path, key)));
|
|
264
|
+
}
|
|
265
|
+
for (const [key, child] of Object.entries(value)) {
|
|
266
|
+
if (key === "type") continue;
|
|
267
|
+
collectNestedDefinitionMetadataIssues(child, appendPathSegment(path, key), issues);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function collectNestedDefinitionMetadataIssues(value, path, issues) {
|
|
271
|
+
if (Array.isArray(value)) {
|
|
272
|
+
for (let index = 0; index < value.length; index += 1) collectNestedDefinitionMetadataIssues(value[index], appendPathSegment(path, index), issues);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (!isJsonRecord(value)) return;
|
|
276
|
+
collectDefinitionMetadataIssues(value, path, issues, Object.hasOwn(value, "type"));
|
|
277
|
+
}
|
|
278
|
+
function isJsonRecord(value) {
|
|
279
|
+
const prototype = typeof value === "object" && value !== null ? Object.getPrototypeOf(value) : void 0;
|
|
280
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && (prototype === null || prototype === Object.prototype);
|
|
115
281
|
}
|
|
116
282
|
function findJsonValueErrorInternal(value, path, ancestors) {
|
|
117
283
|
switch (typeof value) {
|
|
@@ -122,14 +288,11 @@ function findJsonValueErrorInternal(value, path, ancestors) {
|
|
|
122
288
|
path,
|
|
123
289
|
reason: "number must be finite"
|
|
124
290
|
};
|
|
125
|
-
|
|
291
|
+
return Object.is(value, -0) ? {
|
|
126
292
|
path,
|
|
127
293
|
reason: "number must not be negative zero"
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
case "object":
|
|
131
|
-
if (value === null) return;
|
|
132
|
-
return findJsonObjectError(value, path, ancestors);
|
|
294
|
+
} : void 0;
|
|
295
|
+
case "object": return value === null ? void 0 : findJsonObjectError(value, path, ancestors);
|
|
133
296
|
case "bigint":
|
|
134
297
|
case "function":
|
|
135
298
|
case "symbol":
|
|
@@ -139,53 +302,12 @@ function findJsonValueErrorInternal(value, path, ancestors) {
|
|
|
139
302
|
};
|
|
140
303
|
}
|
|
141
304
|
}
|
|
142
|
-
function createSchemaVersionFailure(code, options) {
|
|
143
|
-
return {
|
|
144
|
-
code,
|
|
145
|
-
message: code === "schema_version_missing" ? `schemaVersion is required and must be 1` : `schemaVersion must be 1`,
|
|
146
|
-
path: options.path,
|
|
147
|
-
severity: "error",
|
|
148
|
-
supportedVersions: SUPPORTED_SCHEMA_VERSIONS
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
function createDefinitionEnvelopeFailure(code, options) {
|
|
152
|
-
return {
|
|
153
|
-
code,
|
|
154
|
-
message: options.message ?? getDefinitionEnvelopeFailureMessage(code),
|
|
155
|
-
path: options.path,
|
|
156
|
-
severity: "error"
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
function getDefinitionEnvelopeFailureMessage(code) {
|
|
160
|
-
switch (code) {
|
|
161
|
-
case "definition_envelope_not_json": return "definition envelope must be portable JSON data";
|
|
162
|
-
case "definition_envelope_not_object": return "definition envelope must be a JSON object";
|
|
163
|
-
case "generator_type_missing": return "type is required";
|
|
164
|
-
case "generator_type_invalid": return "type must be a non-empty string";
|
|
165
|
-
case "configuration_missing": return "configuration is required";
|
|
166
|
-
case "configuration_invalid": return "configuration must be a JSON object";
|
|
167
|
-
case "name_invalid": return "name must be a string when present";
|
|
168
|
-
case "description_invalid": return "description must be a string when present";
|
|
169
|
-
case "top_level_property_unknown": return "unknown top-level properties are not allowed";
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
function findDefinitionEnvelopeStringFieldFailure(value, options) {
|
|
173
|
-
if (!Object.hasOwn(value, options.property)) return;
|
|
174
|
-
return typeof value[options.property] === "string" ? void 0 : createDefinitionEnvelopeFailure(options.invalidCode, { path: options.path });
|
|
175
|
-
}
|
|
176
|
-
function appendPathSegment(path, segment) {
|
|
177
|
-
return path === "$" ? `$.${segment}` : `${path}.${segment}`;
|
|
178
|
-
}
|
|
179
|
-
function isJsonRecord(value) {
|
|
180
|
-
const prototype = typeof value === "object" && value !== null ? Object.getPrototypeOf(value) : void 0;
|
|
181
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) && (prototype === null || prototype === Object.prototype);
|
|
182
|
-
}
|
|
183
305
|
function findJsonObjectError(value, path, ancestors) {
|
|
184
306
|
if (ancestors.has(value)) return {
|
|
185
307
|
path,
|
|
186
308
|
reason: "cyclic objects are not JSON-compatible"
|
|
187
309
|
};
|
|
188
|
-
if (
|
|
310
|
+
if ("toJSON" in value && typeof value.toJSON === "function") return {
|
|
189
311
|
path,
|
|
190
312
|
reason: "objects with toJSON behavior are not portable"
|
|
191
313
|
};
|
|
@@ -194,23 +316,20 @@ function findJsonObjectError(value, path, ancestors) {
|
|
|
194
316
|
ancestors.delete(value);
|
|
195
317
|
return error;
|
|
196
318
|
}
|
|
197
|
-
function hasCallableToJson(value) {
|
|
198
|
-
return "toJSON" in value && typeof value.toJSON === "function";
|
|
199
|
-
}
|
|
200
319
|
function findJsonArrayError(value, path, ancestors) {
|
|
201
320
|
const extraProperty = Object.keys(value).find((key) => !isArrayIndexKey(key));
|
|
202
321
|
if (extraProperty !== void 0) return {
|
|
203
|
-
path:
|
|
322
|
+
path: appendPathSegment(path, extraProperty),
|
|
204
323
|
reason: "array object properties would be omitted from JSON"
|
|
205
324
|
};
|
|
206
|
-
const
|
|
207
|
-
if (
|
|
325
|
+
const propertyError = findUnsupportedOwnProperty(value, path, ["length"]);
|
|
326
|
+
if (propertyError !== void 0) return propertyError;
|
|
208
327
|
for (let index = 0; index < value.length; index += 1) {
|
|
209
328
|
if (!(index in value)) return {
|
|
210
|
-
path:
|
|
329
|
+
path: appendPathSegment(path, index),
|
|
211
330
|
reason: "sparse array slots are not JSON-compatible"
|
|
212
331
|
};
|
|
213
|
-
const itemError = findJsonValueErrorInternal(value[index],
|
|
332
|
+
const itemError = findJsonValueErrorInternal(value[index], appendPathSegment(path, index), ancestors);
|
|
214
333
|
if (itemError !== void 0) return itemError;
|
|
215
334
|
}
|
|
216
335
|
}
|
|
@@ -224,32 +343,35 @@ function findJsonRecordError(value, path, ancestors) {
|
|
|
224
343
|
path,
|
|
225
344
|
reason: "object must be a plain JSON record"
|
|
226
345
|
};
|
|
227
|
-
const
|
|
228
|
-
if (
|
|
346
|
+
const propertyError = findUnsupportedOwnProperty(value, path);
|
|
347
|
+
if (propertyError !== void 0) return propertyError;
|
|
229
348
|
for (const key of Object.keys(value)) {
|
|
230
|
-
const itemError = findJsonValueErrorInternal(value[key],
|
|
349
|
+
const itemError = findJsonValueErrorInternal(value[key], appendPathSegment(path, key), ancestors);
|
|
231
350
|
if (itemError !== void 0) return itemError;
|
|
232
351
|
}
|
|
233
352
|
}
|
|
234
353
|
function findUnsupportedOwnProperty(value, path, allowedNonEnumerableProperties = []) {
|
|
354
|
+
if (Object.hasOwn(value, "__proto__")) return {
|
|
355
|
+
path: appendPathSegment(path, "__proto__"),
|
|
356
|
+
reason: "__proto__ keys are not portable JSON data"
|
|
357
|
+
};
|
|
235
358
|
if (Object.getOwnPropertySymbols(value).length > 0) return {
|
|
236
359
|
path,
|
|
237
360
|
reason: "symbol keys are not JSON-compatible"
|
|
238
361
|
};
|
|
239
|
-
const
|
|
240
|
-
const
|
|
241
|
-
for (const [key, descriptor] of Object.entries(descriptors)) {
|
|
362
|
+
const allowed = new Set(allowedNonEnumerableProperties);
|
|
363
|
+
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(value))) {
|
|
242
364
|
if ("get" in descriptor || "set" in descriptor) return {
|
|
243
|
-
path:
|
|
365
|
+
path: appendPathSegment(path, key),
|
|
244
366
|
reason: "accessor properties are not portable JSON data"
|
|
245
367
|
};
|
|
246
|
-
if (!descriptor.enumerable && !
|
|
247
|
-
path:
|
|
368
|
+
if (!descriptor.enumerable && !allowed.has(key)) return {
|
|
369
|
+
path: appendPathSegment(path, key),
|
|
248
370
|
reason: "non-enumerable properties would be omitted from JSON"
|
|
249
371
|
};
|
|
250
372
|
}
|
|
251
373
|
}
|
|
252
374
|
//#endregion
|
|
253
|
-
export { CURRENT_SCHEMA_VERSION,
|
|
375
|
+
export { CURRENT_SCHEMA_VERSION, GENERATOR_DOCUMENT_TOP_LEVEL_KEYS, GENERATOR_METADATA_KEYS, GeneratorDefinitionError, GeneratorDocumentError, GeneratorMetadataError, JsonValueError, SUPPORTED_SCHEMA_VERSIONS, SchemaVersionError, assertDocument, assertGeneratorDefinition, assertGeneratorMetadata, assertJsonValue, assertSchemaVersion, isDocument, isGeneratorDefinition, isGeneratorMetadata, isJsonValue, isSchemaVersion, parseDocument, safeParseDocument, validateDocument, validateGeneratorDefinition, validateGeneratorMetadata, validateJsonValue };
|
|
254
376
|
|
|
255
377
|
//# 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;\n\nexport type JsonValue = JsonArray | JsonObject | JsonPrimitive;\n\nexport type JsonArray = readonly JsonValue[];\n\nexport type JsonObject = {\n readonly [key: string]: JsonValue;\n};\n\nexport const CURRENT_SCHEMA_VERSION = 1;\n\nexport const SUPPORTED_SCHEMA_VERSIONS = [CURRENT_SCHEMA_VERSION] as const;\n\nexport type SchemaVersion = (typeof SUPPORTED_SCHEMA_VERSIONS)[number];\n\nexport type VersionedDefinition = JsonObject & {\n readonly schemaVersion: SchemaVersion;\n};\n\nexport type DefinitionEnvelope = {\n readonly schemaVersion: SchemaVersion;\n readonly type: string;\n readonly configuration: JsonObject;\n readonly name?: string;\n readonly description?: string;\n};\n\nexport const DEFINITION_ENVELOPE_TOP_LEVEL_KEYS = [\n \"schemaVersion\",\n \"type\",\n \"configuration\",\n \"name\",\n \"description\",\n] as const;\n\nexport type SchemaVersionFailureCode =\n | \"schema_version_missing\"\n | \"schema_version_unsupported\";\n\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 DefinitionEnvelopeFailureCode =\n | SchemaVersionFailureCode\n | \"definition_envelope_not_json\"\n | \"definition_envelope_not_object\"\n | \"generator_type_missing\"\n | \"generator_type_invalid\"\n | \"configuration_missing\"\n | \"configuration_invalid\"\n | \"name_invalid\"\n | \"description_invalid\"\n | \"top_level_property_unknown\";\n\nexport type DefinitionEnvelopeShapeFailureCode = Exclude<\n DefinitionEnvelopeFailureCode,\n SchemaVersionFailureCode\n>;\n\nexport type DefinitionEnvelopeShapeFailure = {\n readonly code: DefinitionEnvelopeShapeFailureCode;\n readonly message: string;\n readonly path: string;\n readonly severity: \"error\";\n};\n\nexport type DefinitionEnvelopeFailure =\n | SchemaVersionFailure\n | DefinitionEnvelopeShapeFailure;\n\nexport type DefinitionEnvelopeParseResult =\n | {\n readonly success: true;\n readonly value: DefinitionEnvelope;\n }\n | {\n readonly success: false;\n readonly failure: DefinitionEnvelopeFailure;\n };\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\n constructor(failure: SchemaVersionFailure) {\n super(`${failure.path}: ${failure.message}`);\n this.name = \"SchemaVersionError\";\n this.failure = failure;\n }\n}\n\nexport class DefinitionEnvelopeError extends TypeError {\n readonly failure: DefinitionEnvelopeFailure;\n\n constructor(failure: DefinitionEnvelopeFailure) {\n super(`${failure.path}: ${failure.message}`);\n this.name = \"DefinitionEnvelopeError\";\n this.failure = failure;\n }\n}\n\nexport function isJsonValue(value: unknown): value is JsonValue {\n return findJsonValueError(value) === undefined;\n}\n\nexport function isSchemaVersion(value: unknown): value is SchemaVersion {\n return value === CURRENT_SCHEMA_VERSION;\n}\n\nexport function isVersionedDefinition(\n value: unknown,\n): value is VersionedDefinition {\n return (\n findSchemaVersionFailure(value) === undefined &&\n isJsonRecord(value) &&\n isJsonValue(value)\n );\n}\n\nexport function isDefinitionEnvelope(\n value: unknown,\n): value is DefinitionEnvelope {\n return findDefinitionEnvelopeFailure(value) === undefined;\n}\n\nexport function assertJsonValue(\n value: unknown,\n path = \"$\",\n): asserts value is JsonValue {\n const error = findJsonValueError(value, path);\n\n if (error !== undefined) {\n throw new JsonValueError(error.path, error.reason);\n }\n}\n\nexport function assertSchemaVersion(\n value: unknown,\n path = \"$.schemaVersion\",\n): asserts value is SchemaVersion {\n const failure = findSchemaVersionValueFailure(value, path);\n\n if (failure !== undefined) {\n throw new SchemaVersionError(failure);\n }\n}\n\nexport function assertVersionedDefinition(\n value: unknown,\n path = \"$\",\n): asserts value is VersionedDefinition {\n const failure = findSchemaVersionFailure(value, path);\n\n if (failure !== undefined) {\n throw new SchemaVersionError(failure);\n }\n\n assertJsonValue(value, path);\n}\n\nexport function assertDefinitionEnvelope(\n value: unknown,\n path = \"$\",\n): asserts value is DefinitionEnvelope {\n const failure = findDefinitionEnvelopeFailure(value, path);\n\n if (failure !== undefined) {\n throw new DefinitionEnvelopeError(failure);\n }\n}\n\nexport function parseDefinitionEnvelope(\n value: unknown,\n path = \"$\",\n): DefinitionEnvelope {\n assertDefinitionEnvelope(value, path);\n return value;\n}\n\nexport function safeParseDefinitionEnvelope(\n value: unknown,\n path = \"$\",\n): DefinitionEnvelopeParseResult {\n const failure = findDefinitionEnvelopeFailure(value, path);\n\n if (failure !== undefined) {\n return { failure, success: false };\n }\n\n return { success: true, value: value as DefinitionEnvelope };\n}\n\nexport function findJsonValueError(\n value: unknown,\n path = \"$\",\n): { path: string; reason: string } | undefined {\n return findJsonValueErrorInternal(value, path, new Set());\n}\n\nexport function findDefinitionEnvelopeFailure(\n value: unknown,\n path = \"$\",\n): DefinitionEnvelopeFailure | undefined {\n const jsonError = findJsonValueError(value, path);\n\n if (jsonError !== undefined) {\n return createDefinitionEnvelopeFailure(\"definition_envelope_not_json\", {\n message: jsonError.reason,\n path: jsonError.path,\n });\n }\n\n if (!isJsonRecord(value)) {\n return createDefinitionEnvelopeFailure(\"definition_envelope_not_object\", {\n path,\n });\n }\n\n const versionFailure = findSchemaVersionFailure(value, path);\n\n if (versionFailure !== undefined) {\n return versionFailure;\n }\n\n if (!Object.hasOwn(value, \"type\")) {\n return createDefinitionEnvelopeFailure(\"generator_type_missing\", {\n path: appendPathSegment(path, \"type\"),\n });\n }\n\n const typeValue = value.type;\n\n if (typeof typeValue !== \"string\" || typeValue.trim().length === 0) {\n return createDefinitionEnvelopeFailure(\"generator_type_invalid\", {\n path: appendPathSegment(path, \"type\"),\n });\n }\n\n if (!Object.hasOwn(value, \"configuration\")) {\n return createDefinitionEnvelopeFailure(\"configuration_missing\", {\n path: appendPathSegment(path, \"configuration\"),\n });\n }\n\n if (!isJsonRecord(value.configuration)) {\n return createDefinitionEnvelopeFailure(\"configuration_invalid\", {\n path: appendPathSegment(path, \"configuration\"),\n });\n }\n\n for (const optionalStringField of [\"name\", \"description\"] as const) {\n const fieldFailure = findDefinitionEnvelopeStringFieldFailure(value, {\n invalidCode:\n optionalStringField === \"name\" ? \"name_invalid\" : \"description_invalid\",\n path: appendPathSegment(path, optionalStringField),\n property: optionalStringField,\n });\n\n if (fieldFailure !== undefined) {\n return fieldFailure;\n }\n }\n\n const unknownKey = Object.keys(value).find(\n (key) =>\n !DEFINITION_ENVELOPE_TOP_LEVEL_KEYS.includes(\n key as (typeof DEFINITION_ENVELOPE_TOP_LEVEL_KEYS)[number],\n ),\n );\n\n if (unknownKey !== undefined) {\n return createDefinitionEnvelopeFailure(\"top_level_property_unknown\", {\n message: `Unknown top-level property: ${unknownKey}`,\n path: appendPathSegment(path, unknownKey),\n });\n }\n\n return undefined;\n}\n\nexport function findSchemaVersionFailure(\n value: unknown,\n path = \"$\",\n): SchemaVersionFailure | undefined {\n if (!isJsonRecord(value) || !Object.hasOwn(value, \"schemaVersion\")) {\n return createSchemaVersionFailure(\"schema_version_missing\", {\n path: appendPathSegment(path, \"schemaVersion\"),\n });\n }\n\n return findSchemaVersionValueFailure(\n value.schemaVersion,\n appendPathSegment(path, \"schemaVersion\"),\n );\n}\n\nexport function findSchemaVersionValueFailure(\n value: unknown,\n path = \"$.schemaVersion\",\n): SchemaVersionFailure | undefined {\n if (isSchemaVersion(value)) {\n return undefined;\n }\n\n return createSchemaVersionFailure(\"schema_version_unsupported\", { path });\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 }\n if (Object.is(value, -0)) {\n return { path, reason: \"number must not be negative zero\" };\n }\n return undefined;\n case \"object\":\n if (value === null) {\n return undefined;\n }\n return 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}\n\nfunction createSchemaVersionFailure(\n code: SchemaVersionFailureCode,\n options: { readonly 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: options.path,\n severity: \"error\",\n supportedVersions: SUPPORTED_SCHEMA_VERSIONS,\n };\n}\n\nfunction createDefinitionEnvelopeFailure(\n code: DefinitionEnvelopeShapeFailureCode,\n options: { readonly message?: string; readonly path: string },\n): DefinitionEnvelopeShapeFailure {\n return {\n code,\n message: options.message ?? getDefinitionEnvelopeFailureMessage(code),\n path: options.path,\n severity: \"error\",\n };\n}\n\nfunction getDefinitionEnvelopeFailureMessage(\n code: DefinitionEnvelopeShapeFailureCode,\n) {\n switch (code) {\n case \"definition_envelope_not_json\":\n return \"definition envelope must be portable JSON data\";\n case \"definition_envelope_not_object\":\n return \"definition envelope must be a JSON object\";\n case \"generator_type_missing\":\n return \"type is required\";\n case \"generator_type_invalid\":\n return \"type must be a non-empty string\";\n case \"configuration_missing\":\n return \"configuration is required\";\n case \"configuration_invalid\":\n return \"configuration must be a JSON object\";\n case \"name_invalid\":\n return \"name must be a string when present\";\n case \"description_invalid\":\n return \"description must be a string when present\";\n case \"top_level_property_unknown\":\n return \"unknown top-level properties are not allowed\";\n }\n}\n\nfunction findDefinitionEnvelopeStringFieldFailure(\n value: Record<string, unknown>,\n options: {\n readonly invalidCode: DefinitionEnvelopeShapeFailureCode;\n readonly path: string;\n readonly property: string;\n },\n): DefinitionEnvelopeShapeFailure | undefined {\n if (!Object.hasOwn(value, options.property)) {\n return undefined;\n }\n\n return typeof value[options.property] === \"string\"\n ? undefined\n : createDefinitionEnvelopeFailure(options.invalidCode, {\n path: options.path,\n });\n}\n\nfunction appendPathSegment(path: string, segment: string) {\n return path === \"$\" ? `$.${segment}` : `${path}.${segment}`;\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\n return (\n typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value) &&\n (prototype === null || prototype === Object.prototype)\n );\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 }\n\n if (hasCallableToJson(value)) {\n return { path, reason: \"objects with toJSON behavior are not portable\" };\n }\n\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\n return error;\n}\n\nfunction hasCallableToJson(value: object) {\n return (\n \"toJSON\" in value &&\n typeof (value as { readonly toJSON?: unknown }).toJSON === \"function\"\n );\n}\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\n if (extraProperty !== undefined) {\n return {\n path: `${path}.${extraProperty}`,\n reason: \"array object properties would be omitted from JSON\",\n };\n }\n\n const ownPropertyError = findUnsupportedOwnProperty(value, path, [\"length\"]);\n\n if (ownPropertyError !== undefined) {\n return ownPropertyError;\n }\n\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 }\n\n const itemError = findJsonValueErrorInternal(\n value[index],\n `${path}[${index}]`,\n ancestors,\n );\n\n if (itemError !== undefined) {\n return itemError;\n }\n }\n\n return undefined;\n}\n\nfunction isArrayIndexKey(key: string) {\n const index = Number(key);\n\n return (\n Number.isInteger(index) &&\n index >= 0 &&\n index < 2 ** 32 - 1 &&\n String(index) === key\n );\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\n if (prototype !== null && prototype !== Object.prototype) {\n return { path, reason: \"object must be a plain JSON record\" };\n }\n\n const ownPropertyError = findUnsupportedOwnProperty(value, path);\n\n if (ownPropertyError !== undefined) {\n return ownPropertyError;\n }\n\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\n if (itemError !== undefined) {\n return itemError;\n }\n }\n\n return undefined;\n}\n\nfunction findUnsupportedOwnProperty(\n value: object,\n path: string,\n allowedNonEnumerableProperties: readonly string[] = [],\n): { path: string; reason: string } | undefined {\n if (Object.getOwnPropertySymbols(value).length > 0) {\n return { path, reason: \"symbol keys are not JSON-compatible\" };\n }\n\n const allowedNonEnumerable = new Set(allowedNonEnumerableProperties);\n const descriptors = Object.getOwnPropertyDescriptors(value);\n\n for (const [key, descriptor] of Object.entries(descriptors)) {\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 }\n\n if (!descriptor.enumerable && !allowedNonEnumerable.has(key)) {\n return {\n path: `${path}.${key}`,\n reason: \"non-enumerable properties would be omitted from JSON\",\n };\n }\n }\n\n return undefined;\n}\n"],"mappings":";AAUA,MAAa,yBAAyB;AAEtC,MAAa,4BAA4B,CAAA,CAAuB;AAgBhE,MAAa,qCAAqC;CAChD;CACA;CACA;CACA;CACA;AACF;AAoDA,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;CAEA,YAAY,SAA+B;EACzC,MAAM,GAAG,QAAQ,KAAK,IAAI,QAAQ,SAAS;EAC3C,KAAK,OAAO;EACZ,KAAK,UAAU;CACjB;AACF;AAEA,IAAa,0BAAb,cAA6C,UAAU;CACrD;CAEA,YAAY,SAAoC;EAC9C,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;AAEA,SAAgB,gBAAgB,OAAwC;CACtE,OAAO,UAAA;AACT;AAEA,SAAgB,sBACd,OAC8B;CAC9B,OACE,yBAAyB,KAAK,MAAM,KAAA,KACpC,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AAG,KAAK,GAAG;GACjB,QAAQ;EACV;CAEJ;AAGF"}
|
|
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 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 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 TypeError {\n readonly issue: ValidationIssue;\n constructor(path: ValidationPath, reason: string) {\n super(`${formatValidationPath(path)}: ${reason}`);\n this.name = \"JsonValueError\";\n this.issue = { code: \"invalid_json_value\", path, message: reason };\n }\n}\n\nexport class SchemaVersionError extends TypeError {\n readonly failure: SchemaVersionFailure;\n constructor(failure: SchemaVersionFailure) {\n super(`${formatValidationPath(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(`${formatValidationPath(failure.path)}: ${failure.message}`);\n this.name = \"GeneratorDefinitionError\";\n this.failure = failure;\n }\n}\n\nexport class GeneratorMetadataError extends TypeError {\n readonly failure: GeneratorMetadataFailure;\n constructor(failure: GeneratorMetadataFailure) {\n super(`${formatValidationPath(failure.path)}: ${failure.message}`);\n this.name = \"GeneratorMetadataError\";\n this.failure = failure;\n }\n}\n\nexport class GeneratorDocumentError extends TypeError {\n readonly failure: GeneratorDocumentFailure;\n constructor(failure: GeneratorDocumentFailure) {\n super(`${formatValidationPath(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 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 formatValidationPath(path: ValidationPath) {\n return path.length === 0\n ? \"$\"\n : path\n .map((segment) =>\n typeof segment === \"number\" ? `[${segment}]` : `.${segment}`,\n )\n .join(\"\")\n .replace(/^\\./u, \"$\");\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;AACtC,MAAa,4BAA4B,CAAA,CAAuB;AAoChE,MAAa,oCAAoC;CAC/C;CACA;CACA;CACA;AACF;AAEA,MAAa,0BAA0B;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,yCAAyB,IAAI,IAAI;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAqED,IAAa,iBAAb,cAAoC,UAAU;CAC5C;CACA,YAAY,MAAsB,QAAgB;EAChD,MAAM,GAAG,qBAAqB,IAAI,EAAE,IAAI,QAAQ;EAChD,KAAK,OAAO;EACZ,KAAK,QAAQ;GAAE,MAAM;GAAsB;GAAM,SAAS;EAAO;CACnE;AACF;AAEA,IAAa,qBAAb,cAAwC,UAAU;CAChD;CACA,YAAY,SAA+B;EACzC,MAAM,GAAG,qBAAqB,QAAQ,IAAI,EAAE,IAAI,QAAQ,SAAS;EACjE,KAAK,OAAO;EACZ,KAAK,UAAU;CACjB;AACF;AAEA,IAAa,2BAAb,cAA8C,UAAU;CACtD;CACA,YAAY,SAAqC;EAC/C,MAAM,GAAG,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