@nekostack/schema 1.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/CHANGELOG.md +422 -0
- package/LICENSE +202 -0
- package/README.md +656 -0
- package/dist/src/builders/array.d.ts +12 -0
- package/dist/src/builders/array.d.ts.map +1 -0
- package/dist/src/builders/array.js +29 -0
- package/dist/src/builders/array.js.map +1 -0
- package/dist/src/builders/object.d.ts +62 -0
- package/dist/src/builders/object.d.ts.map +1 -0
- package/dist/src/builders/object.js +263 -0
- package/dist/src/builders/object.js.map +1 -0
- package/dist/src/builders/primitives.d.ts +37 -0
- package/dist/src/builders/primitives.d.ts.map +1 -0
- package/dist/src/builders/primitives.js +125 -0
- package/dist/src/builders/primitives.js.map +1 -0
- package/dist/src/builders/s.d.ts +27 -0
- package/dist/src/builders/s.d.ts.map +1 -0
- package/dist/src/builders/s.js +39 -0
- package/dist/src/builders/s.js.map +1 -0
- package/dist/src/builders/schema.d.ts +70 -0
- package/dist/src/builders/schema.d.ts.map +1 -0
- package/dist/src/builders/schema.js +98 -0
- package/dist/src/builders/schema.js.map +1 -0
- package/dist/src/cli-integration.d.ts +43 -0
- package/dist/src/cli-integration.d.ts.map +1 -0
- package/dist/src/cli-integration.js +48 -0
- package/dist/src/cli-integration.js.map +1 -0
- package/dist/src/errors/issue.d.ts +34 -0
- package/dist/src/errors/issue.d.ts.map +1 -0
- package/dist/src/errors/issue.js +89 -0
- package/dist/src/errors/issue.js.map +1 -0
- package/dist/src/generators/errors.d.ts +31 -0
- package/dist/src/generators/errors.d.ts.map +1 -0
- package/dist/src/generators/errors.js +34 -0
- package/dist/src/generators/errors.js.map +1 -0
- package/dist/src/generators/header.d.ts +42 -0
- package/dist/src/generators/header.d.ts.map +1 -0
- package/dist/src/generators/header.js +43 -0
- package/dist/src/generators/header.js.map +1 -0
- package/dist/src/generators/json-schema-meta.d.ts +36 -0
- package/dist/src/generators/json-schema-meta.d.ts.map +1 -0
- package/dist/src/generators/json-schema-meta.js +35 -0
- package/dist/src/generators/json-schema-meta.js.map +1 -0
- package/dist/src/generators/json-schema.d.ts +26 -0
- package/dist/src/generators/json-schema.d.ts.map +1 -0
- package/dist/src/generators/json-schema.js +88 -0
- package/dist/src/generators/json-schema.js.map +1 -0
- package/dist/src/generators/openapi.d.ts +33 -0
- package/dist/src/generators/openapi.d.ts.map +1 -0
- package/dist/src/generators/openapi.js +61 -0
- package/dist/src/generators/openapi.js.map +1 -0
- package/dist/src/generators/schema-fragment.d.ts +55 -0
- package/dist/src/generators/schema-fragment.d.ts.map +1 -0
- package/dist/src/generators/schema-fragment.js +253 -0
- package/dist/src/generators/schema-fragment.js.map +1 -0
- package/dist/src/generators/ts.d.ts +19 -0
- package/dist/src/generators/ts.d.ts.map +1 -0
- package/dist/src/generators/ts.js +252 -0
- package/dist/src/generators/ts.js.map +1 -0
- package/dist/src/generators/types.d.ts +96 -0
- package/dist/src/generators/types.d.ts.map +1 -0
- package/dist/src/generators/types.js +10 -0
- package/dist/src/generators/types.js.map +1 -0
- package/dist/src/generators/version.d.ts +11 -0
- package/dist/src/generators/version.d.ts.map +1 -0
- package/dist/src/generators/version.js +11 -0
- package/dist/src/generators/version.js.map +1 -0
- package/dist/src/generators/zod-mapping.d.ts +90 -0
- package/dist/src/generators/zod-mapping.d.ts.map +1 -0
- package/dist/src/generators/zod-mapping.js +174 -0
- package/dist/src/generators/zod-mapping.js.map +1 -0
- package/dist/src/generators/zod.d.ts +17 -0
- package/dist/src/generators/zod.d.ts.map +1 -0
- package/dist/src/generators/zod.js +118 -0
- package/dist/src/generators/zod.js.map +1 -0
- package/dist/src/index.d.ts +21 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +43 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/ir/hash.d.ts +19 -0
- package/dist/src/ir/hash.d.ts.map +1 -0
- package/dist/src/ir/hash.js +22 -0
- package/dist/src/ir/hash.js.map +1 -0
- package/dist/src/ir/nodes.d.ts +121 -0
- package/dist/src/ir/nodes.d.ts.map +1 -0
- package/dist/src/ir/nodes.js +14 -0
- package/dist/src/ir/nodes.js.map +1 -0
- package/dist/src/ir/serialize.d.ts +8 -0
- package/dist/src/ir/serialize.d.ts.map +1 -0
- package/dist/src/ir/serialize.js +23 -0
- package/dist/src/ir/serialize.js.map +1 -0
- package/dist/src/migrations/build-migration-registry.d.ts +46 -0
- package/dist/src/migrations/build-migration-registry.d.ts.map +1 -0
- package/dist/src/migrations/build-migration-registry.js +134 -0
- package/dist/src/migrations/build-migration-registry.js.map +1 -0
- package/dist/src/migrations/handlers/list.d.ts +35 -0
- package/dist/src/migrations/handlers/list.d.ts.map +1 -0
- package/dist/src/migrations/handlers/list.js +55 -0
- package/dist/src/migrations/handlers/list.js.map +1 -0
- package/dist/src/migrations/handlers/plan.d.ts +26 -0
- package/dist/src/migrations/handlers/plan.d.ts.map +1 -0
- package/dist/src/migrations/handlers/plan.js +28 -0
- package/dist/src/migrations/handlers/plan.js.map +1 -0
- package/dist/src/migrations/handlers/stub.d.ts +22 -0
- package/dist/src/migrations/handlers/stub.d.ts.map +1 -0
- package/dist/src/migrations/handlers/stub.js +24 -0
- package/dist/src/migrations/handlers/stub.js.map +1 -0
- package/dist/src/migrations/handlers/verify.d.ts +25 -0
- package/dist/src/migrations/handlers/verify.d.ts.map +1 -0
- package/dist/src/migrations/handlers/verify.js +27 -0
- package/dist/src/migrations/handlers/verify.js.map +1 -0
- package/dist/src/migrations/parse-provenance.d.ts +78 -0
- package/dist/src/migrations/parse-provenance.d.ts.map +1 -0
- package/dist/src/migrations/parse-provenance.js +157 -0
- package/dist/src/migrations/parse-provenance.js.map +1 -0
- package/dist/src/migrations/plan-migration.d.ts +50 -0
- package/dist/src/migrations/plan-migration.d.ts.map +1 -0
- package/dist/src/migrations/plan-migration.js +256 -0
- package/dist/src/migrations/plan-migration.js.map +1 -0
- package/dist/src/migrations/stub.d.ts +55 -0
- package/dist/src/migrations/stub.d.ts.map +1 -0
- package/dist/src/migrations/stub.js +201 -0
- package/dist/src/migrations/stub.js.map +1 -0
- package/dist/src/migrations/types.d.ts +297 -0
- package/dist/src/migrations/types.d.ts.map +1 -0
- package/dist/src/migrations/types.js +28 -0
- package/dist/src/migrations/types.js.map +1 -0
- package/dist/src/migrations/verify-provenance.d.ts +46 -0
- package/dist/src/migrations/verify-provenance.d.ts.map +1 -0
- package/dist/src/migrations/verify-provenance.js +158 -0
- package/dist/src/migrations/verify-provenance.js.map +1 -0
- package/dist/src/registry/build-registry.d.ts +65 -0
- package/dist/src/registry/build-registry.d.ts.map +1 -0
- package/dist/src/registry/build-registry.js +172 -0
- package/dist/src/registry/build-registry.js.map +1 -0
- package/dist/src/registry/diff.d.ts +25 -0
- package/dist/src/registry/diff.d.ts.map +1 -0
- package/dist/src/registry/diff.js +497 -0
- package/dist/src/registry/diff.js.map +1 -0
- package/dist/src/registry/handlers/check.d.ts +57 -0
- package/dist/src/registry/handlers/check.d.ts.map +1 -0
- package/dist/src/registry/handlers/check.js +181 -0
- package/dist/src/registry/handlers/check.js.map +1 -0
- package/dist/src/registry/handlers/diff.d.ts +33 -0
- package/dist/src/registry/handlers/diff.d.ts.map +1 -0
- package/dist/src/registry/handlers/diff.js +61 -0
- package/dist/src/registry/handlers/diff.js.map +1 -0
- package/dist/src/registry/handlers/generate.d.ts +87 -0
- package/dist/src/registry/handlers/generate.d.ts.map +1 -0
- package/dist/src/registry/handlers/generate.js +223 -0
- package/dist/src/registry/handlers/generate.js.map +1 -0
- package/dist/src/registry/handlers/list.d.ts +36 -0
- package/dist/src/registry/handlers/list.d.ts.map +1 -0
- package/dist/src/registry/handlers/list.js +84 -0
- package/dist/src/registry/handlers/list.js.map +1 -0
- package/dist/src/registry/parse-provenance.d.ts +63 -0
- package/dist/src/registry/parse-provenance.d.ts.map +1 -0
- package/dist/src/registry/parse-provenance.js +182 -0
- package/dist/src/registry/parse-provenance.js.map +1 -0
- package/dist/src/registry/source-hash.d.ts +28 -0
- package/dist/src/registry/source-hash.d.ts.map +1 -0
- package/dist/src/registry/source-hash.js +32 -0
- package/dist/src/registry/source-hash.js.map +1 -0
- package/dist/src/registry/types.d.ts +185 -0
- package/dist/src/registry/types.d.ts.map +1 -0
- package/dist/src/registry/types.js +22 -0
- package/dist/src/registry/types.js.map +1 -0
- package/dist/src/runtime/compile.d.ts +38 -0
- package/dist/src/runtime/compile.d.ts.map +1 -0
- package/dist/src/runtime/compile.js +45 -0
- package/dist/src/runtime/compile.js.map +1 -0
- package/dist/src/runtime/errors.d.ts +25 -0
- package/dist/src/runtime/errors.d.ts.map +1 -0
- package/dist/src/runtime/errors.js +43 -0
- package/dist/src/runtime/errors.js.map +1 -0
- package/dist/src/runtime/normalize-issues.d.ts +65 -0
- package/dist/src/runtime/normalize-issues.d.ts.map +1 -0
- package/dist/src/runtime/normalize-issues.js +208 -0
- package/dist/src/runtime/normalize-issues.js.map +1 -0
- package/dist/src/runtime/parse.d.ts +62 -0
- package/dist/src/runtime/parse.d.ts.map +1 -0
- package/dist/src/runtime/parse.js +107 -0
- package/dist/src/runtime/parse.js.map +1 -0
- package/dist/src/runtime/strip-defaults.d.ts +51 -0
- package/dist/src/runtime/strip-defaults.d.ts.map +1 -0
- package/dist/src/runtime/strip-defaults.js +81 -0
- package/dist/src/runtime/strip-defaults.js.map +1 -0
- package/dist/src/runtime/zod-compile.d.ts +27 -0
- package/dist/src/runtime/zod-compile.d.ts.map +1 -0
- package/dist/src/runtime/zod-compile.js +92 -0
- package/dist/src/runtime/zod-compile.js.map +1 -0
- package/dist/src/types.d.ts +116 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/docs/ABSENCE_SEMANTICS.md +37 -0
- package/docs/BENCHMARKS.md +64 -0
- package/docs/COMPOSITION.md +206 -0
- package/docs/DIFF_CLASSIFICATION.md +137 -0
- package/docs/EXAMPLES.md +221 -0
- package/docs/HEADER_FORMAT.md +66 -0
- package/docs/INVARIANTS.md +58 -0
- package/docs/IR_CONTRACT.md +67 -0
- package/docs/ISSUE_CODES.md +99 -0
- package/docs/JSON_SCHEMA_MAPPING.md +149 -0
- package/docs/MIGRATIONS.md +406 -0
- package/docs/MIGRATION_GUIDE.md +150 -0
- package/docs/OPENAPI_MAPPING.md +66 -0
- package/docs/REGISTRY.md +336 -0
- package/docs/RUNTIME.md +279 -0
- package/docs/SCOPE.md +119 -0
- package/docs/USAGE.md +376 -0
- package/docs/ZOD_MODIFIER_ORDERING.md +77 -0
- package/package.json +45 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { JsonValue, Refinement, SchemaNode } from "../ir/nodes.js";
|
|
2
|
+
import type { ObjectKey } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Base of every schema builder.
|
|
5
|
+
*
|
|
6
|
+
* Type parameters:
|
|
7
|
+
* - TInput: shape `parse`/`validate` accepts (pre-default, pre-transform)
|
|
8
|
+
* - TOutput: shape `parse` returns (post-default, post-transform)
|
|
9
|
+
* - TKey: "required" | "optional" — controls object-field absence
|
|
10
|
+
*
|
|
11
|
+
* The phantom `declare` fields exist purely for type inference; they emit no
|
|
12
|
+
* runtime code. The single source of truth at runtime is `this.node`.
|
|
13
|
+
*/
|
|
14
|
+
export declare abstract class Schema<TInput = unknown, TOutput = TInput, TInputKey extends ObjectKey = "required", TOutputKey extends ObjectKey = TInputKey> {
|
|
15
|
+
readonly _input: TInput;
|
|
16
|
+
readonly _output: TOutput;
|
|
17
|
+
readonly _inputKey: TInputKey;
|
|
18
|
+
readonly _outputKey: TOutputKey;
|
|
19
|
+
readonly node: SchemaNode;
|
|
20
|
+
protected constructor(node: SchemaNode);
|
|
21
|
+
optional(): Schema<TInput | undefined, TOutput | undefined, "optional", "optional">;
|
|
22
|
+
nullable(): Schema<TInput | null, TOutput | null, TInputKey, TOutputKey>;
|
|
23
|
+
nullish(): Schema<TInput | null | undefined, TOutput | null | undefined, "optional", "optional">;
|
|
24
|
+
/**
|
|
25
|
+
* Provide a default for missing input. Input becomes optional; output stays
|
|
26
|
+
* required because the default fills `undefined` in before downstream code
|
|
27
|
+
* sees it. See the absence-semantics table in the README.
|
|
28
|
+
*/
|
|
29
|
+
default(value: JsonValue): Schema<TInput | undefined, Exclude<TOutput, undefined>, "optional", "required">;
|
|
30
|
+
id(id: string): this;
|
|
31
|
+
version(version: string): this;
|
|
32
|
+
describe(description: string): this;
|
|
33
|
+
deprecated(value?: boolean): this;
|
|
34
|
+
/**
|
|
35
|
+
* Subclasses override to construct the correct concrete class. The base
|
|
36
|
+
* class itself never produces instances (it's abstract), but optional /
|
|
37
|
+
* nullable etc. drop down to `BaseSchema` to surface the right type params.
|
|
38
|
+
*
|
|
39
|
+
* **Subclass invariant (load-bearing for v0.5 composition):** `clone(node)`
|
|
40
|
+
* MUST be a pure IR-replacement operation — return a new instance of the
|
|
41
|
+
* same concrete subclass with the new `node` and otherwise identical
|
|
42
|
+
* subclass state. It must NOT mutate `this`, must NOT carry over the old
|
|
43
|
+
* `node`, and must preserve any subclass-specific bookkeeping the
|
|
44
|
+
* subclass already passes through its constructor (e.g.
|
|
45
|
+
* `ArraySchema`'s `elementSchema`, `ObjectSchema`'s `shape`).
|
|
46
|
+
*
|
|
47
|
+
* v0.5 composition (`ObjectSchema.partial` / `.required`) reaches into
|
|
48
|
+
* field-level `clone` via a cast to swap a field's modifiers without
|
|
49
|
+
* losing subclass identity (`StringSchema.partial()` still yields a
|
|
50
|
+
* `StringSchema`-shaped instance). Any future Schema subclass that
|
|
51
|
+
* doesn't honor this invariant — e.g., a `clone` that drops a
|
|
52
|
+
* subclass-private field — will silently break composition for that
|
|
53
|
+
* kind of schema. New subclasses ship with a composition-roundtrip
|
|
54
|
+
* test, or document the divergence explicitly.
|
|
55
|
+
*/
|
|
56
|
+
protected abstract clone(node: SchemaNode): this;
|
|
57
|
+
protected cloneSelf(node: SchemaNode): this;
|
|
58
|
+
/**
|
|
59
|
+
* Cast a clone as a Schema<TIn, TOut, TKey> for modifier returns. The
|
|
60
|
+
* runtime instance is still the original subclass — we only narrow the
|
|
61
|
+
* static type to drop subclass-specific methods (e.g., calling `.optional()`
|
|
62
|
+
* on a StringSchema yields a base Schema with no further `.min(n)`).
|
|
63
|
+
*/
|
|
64
|
+
protected cloneAsBase<I, O, IK extends ObjectKey, OK extends ObjectKey>(node: SchemaNode): Schema<I, O, IK, OK>;
|
|
65
|
+
/** Append a refinement and clone — used by primitive subclasses. */
|
|
66
|
+
protected withRefinement(refinement: Refinement): this;
|
|
67
|
+
}
|
|
68
|
+
/** Erased Schema reference for generic constraints. */
|
|
69
|
+
export type AnySchema = Schema<any, any, ObjectKey, ObjectKey>;
|
|
70
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/builders/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EAGT,UAAU,EACV,UAAU,EACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,8BAAsB,MAAM,CAE1B,MAAM,GAAG,OAAO,EAEhB,OAAO,GAAG,MAAM,EAEhB,SAAS,SAAS,SAAS,GAAG,UAAU,EAExC,UAAU,SAAS,SAAS,GAAG,SAAS;IAExC,SAAiB,MAAM,EAAE,MAAM,CAAC;IAChC,SAAiB,OAAO,EAAE,OAAO,CAAC;IAClC,SAAiB,SAAS,EAAE,SAAS,CAAC;IACtC,SAAiB,UAAU,EAAE,UAAU,CAAC;IAExC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAE1B,SAAS,aAAa,IAAI,EAAE,UAAU;IAMtC,QAAQ,IAAI,MAAM,CAChB,MAAM,GAAG,SAAS,EAClB,OAAO,GAAG,SAAS,EACnB,UAAU,EACV,UAAU,CACX;IAID,QAAQ,IAAI,MAAM,CAAC,MA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`parse`/`validate` accepts (pre-default, pre-transform)
|
|
6
|
+
* - TOutput: shape `parse` returns (post-default, post-transform)
|
|
7
|
+
* - TKey: "required" | "optional" — controls object-field absence
|
|
8
|
+
*
|
|
9
|
+
* The phantom `declare` fields exist purely for type inference; they emit no
|
|
10
|
+
* runtime code. The single source of truth at runtime is `this.node`.
|
|
11
|
+
*/
|
|
12
|
+
export class Schema {
|
|
13
|
+
node;
|
|
14
|
+
constructor(node) {
|
|
15
|
+
this.node = freeze(node);
|
|
16
|
+
}
|
|
17
|
+
// ---- Modifiers (applicable to every schema) ----
|
|
18
|
+
optional() {
|
|
19
|
+
return this.cloneAsBase(withModifier(this.node, { optional: true }));
|
|
20
|
+
}
|
|
21
|
+
nullable() {
|
|
22
|
+
return this.cloneAsBase(withModifier(this.node, { nullable: true }));
|
|
23
|
+
}
|
|
24
|
+
nullish() {
|
|
25
|
+
return this.cloneAsBase(withModifier(this.node, { optional: true, nullable: true }));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Provide a default for missing input. Input becomes optional; output stays
|
|
29
|
+
* required because the default fills `undefined` in before downstream code
|
|
30
|
+
* sees it. See the absence-semantics table in the README.
|
|
31
|
+
*/
|
|
32
|
+
default(value) {
|
|
33
|
+
return this.cloneAsBase(withModifier(this.node, { optional: true, default: { value } }));
|
|
34
|
+
}
|
|
35
|
+
// ---- Metadata ----
|
|
36
|
+
id(id) {
|
|
37
|
+
return this.cloneSelf(withMetadata(this.node, { id }));
|
|
38
|
+
}
|
|
39
|
+
version(version) {
|
|
40
|
+
return this.cloneSelf(withMetadata(this.node, { version }));
|
|
41
|
+
}
|
|
42
|
+
describe(description) {
|
|
43
|
+
return this.cloneSelf(withMetadata(this.node, { description }));
|
|
44
|
+
}
|
|
45
|
+
deprecated(value = true) {
|
|
46
|
+
return this.cloneSelf(withMetadata(this.node, { deprecated: value }));
|
|
47
|
+
}
|
|
48
|
+
cloneSelf(node) {
|
|
49
|
+
return this.clone(node);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Cast a clone as a Schema<TIn, TOut, TKey> for modifier returns. The
|
|
53
|
+
* runtime instance is still the original subclass — we only narrow the
|
|
54
|
+
* static type to drop subclass-specific methods (e.g., calling `.optional()`
|
|
55
|
+
* on a StringSchema yields a base Schema with no further `.min(n)`).
|
|
56
|
+
*/
|
|
57
|
+
cloneAsBase(node) {
|
|
58
|
+
return this.clone(node);
|
|
59
|
+
}
|
|
60
|
+
/** Append a refinement and clone — used by primitive subclasses. */
|
|
61
|
+
withRefinement(refinement) {
|
|
62
|
+
const existing = this.node.refinements ?? [];
|
|
63
|
+
return this.clone({
|
|
64
|
+
...this.node,
|
|
65
|
+
refinements: [...existing, refinement],
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// ---- Helpers ----
|
|
70
|
+
function withModifier(node, patch) {
|
|
71
|
+
return {
|
|
72
|
+
...node,
|
|
73
|
+
modifiers: { ...node.modifiers, ...patch },
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function withMetadata(node, patch) {
|
|
77
|
+
return {
|
|
78
|
+
...node,
|
|
79
|
+
metadata: { ...node.metadata, ...patch },
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Deep-freeze in dev/test to make IR mutation immediately loud. Object.freeze
|
|
84
|
+
* is shallow; we recurse through composites (fields / element / options). The
|
|
85
|
+
* cost is negligible at definition time and prevents an entire class of bugs
|
|
86
|
+
* where a downstream consumer mutates a shared IR node.
|
|
87
|
+
*/
|
|
88
|
+
function freeze(value) {
|
|
89
|
+
if (value === null || typeof value !== "object")
|
|
90
|
+
return value;
|
|
91
|
+
if (Object.isFrozen(value))
|
|
92
|
+
return value;
|
|
93
|
+
for (const key of Object.keys(value)) {
|
|
94
|
+
freeze(value[key]);
|
|
95
|
+
}
|
|
96
|
+
return Object.freeze(value);
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=schema.js.map
|
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,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC9D,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACzC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAe,CAAC,EAAE,CAAC;QAC/C,MAAM,CAAE,KAAiC,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@nekostack/schema/cli` integration barrel (Master plan Decision #10).
|
|
3
|
+
*
|
|
4
|
+
* This module is the **package-internal integration surface** for
|
|
5
|
+
* `@nekostack/cli` to import schema primitives that are not part of
|
|
6
|
+
* the public consumer API:
|
|
7
|
+
*
|
|
8
|
+
* - v0.7 — registry / freshness / generation primitives
|
|
9
|
+
* - v0.8 — schema-data migration planning / verification /
|
|
10
|
+
* stub-generation primitives (this commit extends the barrel)
|
|
11
|
+
*
|
|
12
|
+
* **External consumers should NOT import from this path.** The root
|
|
13
|
+
* `@nekostack/schema` import surface remains the v0.6 contract
|
|
14
|
+
* (`s`, `parse`, `safeParse`, `validate`, `ParseError`, IR types,
|
|
15
|
+
* generators). The names re-exported here are subject to internal
|
|
16
|
+
* change; engine-swap-safety lives at the root index, not at this
|
|
17
|
+
* subpath. The negative-leakage gate in
|
|
18
|
+
* `tests/public-surface.test.ts` enforces that the root never
|
|
19
|
+
* exposes a v0.7 or v0.8 surface name.
|
|
20
|
+
*
|
|
21
|
+
* Re-exports only. No new functions, no new types, no behavior
|
|
22
|
+
* changes.
|
|
23
|
+
*/
|
|
24
|
+
export { sourceHashFromText } from "./registry/source-hash.js";
|
|
25
|
+
export { parseProvenanceFromText } from "./registry/parse-provenance.js";
|
|
26
|
+
export { buildRegistry, findSchema } from "./registry/build-registry.js";
|
|
27
|
+
export { diffNodes } from "./registry/diff.js";
|
|
28
|
+
export { listHandler } from "./registry/handlers/list.js";
|
|
29
|
+
export { diffHandler } from "./registry/handlers/diff.js";
|
|
30
|
+
export { checkHandler } from "./registry/handlers/check.js";
|
|
31
|
+
export { generateHandler, suggestedPathFor, GENERATOR_KINDS, } from "./registry/handlers/generate.js";
|
|
32
|
+
export type { RegistrySourceEntry, RegistryEntry, Registry, DiffSeverity, DiffKind, DiffChange, FreshnessVerdict, GeneratorKind, GeneratedArtifact, CommittedArtifact, GenerateOpts, GenerateResult, CheckOpts, CheckResult, DiffOpts, DiffResult, ListOpts, ListResult, } from "./registry/types.js";
|
|
33
|
+
export { parseMigrationProvenanceFromText } from "./migrations/parse-provenance.js";
|
|
34
|
+
export { buildMigrationRegistry } from "./migrations/build-migration-registry.js";
|
|
35
|
+
export { planMigration } from "./migrations/plan-migration.js";
|
|
36
|
+
export { verifyMigrationProvenance } from "./migrations/verify-provenance.js";
|
|
37
|
+
export { stubMigration, suggestedMigrationPathFor, } from "./migrations/stub.js";
|
|
38
|
+
export { listMigrationsHandler } from "./migrations/handlers/list.js";
|
|
39
|
+
export { planMigrationHandler } from "./migrations/handlers/plan.js";
|
|
40
|
+
export { verifyMigrationsHandler } from "./migrations/handlers/verify.js";
|
|
41
|
+
export { stubMigrationHandler } from "./migrations/handlers/stub.js";
|
|
42
|
+
export type { Migration, AnyMigration, MigrationSourceEntry, MigrationEntry, MigrationRegistry, MigrationPlan, PlanNote, MigrationVerdict, VerificationResult, MigrationStub, MigrationListOpts, MigrationListResult, MigrationPlanOpts, MigrationPlanResult, MigrationVerifyOpts, MigrationVerifyResult, MigrationStubOpts, MigrationStubResult, } from "./migrations/types.js";
|
|
43
|
+
//# sourceMappingURL=cli-integration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-integration.d.ts","sourceRoot":"","sources":["../../src/cli-integration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;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ACT,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@nekostack/schema/cli` integration barrel (Master plan Decision #10).
|
|
3
|
+
*
|
|
4
|
+
* This module is the **package-internal integration surface** for
|
|
5
|
+
* `@nekostack/cli` to import schema primitives that are not part of
|
|
6
|
+
* the public consumer API:
|
|
7
|
+
*
|
|
8
|
+
* - v0.7 — registry / freshness / generation primitives
|
|
9
|
+
* - v0.8 — schema-data migration planning / verification /
|
|
10
|
+
* stub-generation primitives (this commit extends the barrel)
|
|
11
|
+
*
|
|
12
|
+
* **External consumers should NOT import from this path.** The root
|
|
13
|
+
* `@nekostack/schema` import surface remains the v0.6 contract
|
|
14
|
+
* (`s`, `parse`, `safeParse`, `validate`, `ParseError`, IR types,
|
|
15
|
+
* generators). The names re-exported here are subject to internal
|
|
16
|
+
* change; engine-swap-safety lives at the root index, not at this
|
|
17
|
+
* subpath. The negative-leakage gate in
|
|
18
|
+
* `tests/public-surface.test.ts` enforces that the root never
|
|
19
|
+
* exposes a v0.7 or v0.8 surface name.
|
|
20
|
+
*
|
|
21
|
+
* Re-exports only. No new functions, no new types, no behavior
|
|
22
|
+
* changes.
|
|
23
|
+
*/
|
|
24
|
+
// ---- Pure registry primitives ----------------------------------------------
|
|
25
|
+
export { sourceHashFromText } from "./registry/source-hash.js";
|
|
26
|
+
export { parseProvenanceFromText } from "./registry/parse-provenance.js";
|
|
27
|
+
export { buildRegistry, findSchema } from "./registry/build-registry.js";
|
|
28
|
+
export { diffNodes } from "./registry/diff.js";
|
|
29
|
+
// ---- Handlers --------------------------------------------------------------
|
|
30
|
+
export { listHandler } from "./registry/handlers/list.js";
|
|
31
|
+
export { diffHandler } from "./registry/handlers/diff.js";
|
|
32
|
+
export { checkHandler } from "./registry/handlers/check.js";
|
|
33
|
+
export { generateHandler, suggestedPathFor, GENERATOR_KINDS, } from "./registry/handlers/generate.js";
|
|
34
|
+
// =============================================================================
|
|
35
|
+
// v0.8 migration surface
|
|
36
|
+
// =============================================================================
|
|
37
|
+
// ---- Pure migration primitives ---------------------------------------------
|
|
38
|
+
export { parseMigrationProvenanceFromText } from "./migrations/parse-provenance.js";
|
|
39
|
+
export { buildMigrationRegistry } from "./migrations/build-migration-registry.js";
|
|
40
|
+
export { planMigration } from "./migrations/plan-migration.js";
|
|
41
|
+
export { verifyMigrationProvenance } from "./migrations/verify-provenance.js";
|
|
42
|
+
export { stubMigration, suggestedMigrationPathFor, } from "./migrations/stub.js";
|
|
43
|
+
// ---- Migration handlers ----------------------------------------------------
|
|
44
|
+
export { listMigrationsHandler } from "./migrations/handlers/list.js";
|
|
45
|
+
export { planMigrationHandler } from "./migrations/handlers/plan.js";
|
|
46
|
+
export { verifyMigrationsHandler } from "./migrations/handlers/verify.js";
|
|
47
|
+
export { stubMigrationHandler } from "./migrations/handlers/stub.js";
|
|
48
|
+
//# sourceMappingURL=cli-integration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-integration.js","sourceRoot":"","sources":["../../src/cli-integration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,+EAA+E;AAE/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,+EAA+E;AAE/E,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,eAAe,GAChB,MAAM,iCAAiC,CAAC;AAyBzC,gFAAgF;AAChF,yBAAyB;AACzB,gFAAgF;AAEhF,+EAA+E;AAE/E,OAAO,EAAE,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EACL,aAAa,EACb,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAE9B,+EAA+E;AAE/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable, machine-readable codes for validation issues. The runtime normalizes
|
|
3
|
+
* raw validator errors (Zod, etc.) into this set so every NekoStack consumer
|
|
4
|
+
* (form display, API responses, admin diagnostics) reads the same vocabulary.
|
|
5
|
+
*
|
|
6
|
+
* Adding a code is a breaking change for consumers that switch on it; removing
|
|
7
|
+
* one is breaking for anyone that emits it. v1.0 freezes the set.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ISSUE_CODES: readonly ["invalid_type", "missing_required", "unknown_key", "too_small", "too_big", "invalid_enum", "invalid_literal", "invalid_union", "invalid_format", "custom_refinement_failed", "schema_version_unsupported", "recursive_reference_unresolved", "integrity_error", "duplicate_schema_id", "schema_not_found", "version_not_found", "duplicate_migration", "migration_missing_endpoint", "migration_not_found", "migration_chain_broken", "migration_ambiguous_chain", "migration_drift", "migration_cosmetic_drift"];
|
|
10
|
+
export type IssueCode = (typeof ISSUE_CODES)[number];
|
|
11
|
+
export type IssuePath = ReadonlyArray<string | number>;
|
|
12
|
+
export interface Issue {
|
|
13
|
+
code: IssueCode;
|
|
14
|
+
path: IssuePath;
|
|
15
|
+
message: string;
|
|
16
|
+
expected?: unknown;
|
|
17
|
+
received?: unknown;
|
|
18
|
+
schemaId?: string;
|
|
19
|
+
schemaVersion?: string;
|
|
20
|
+
severity: "error" | "warning";
|
|
21
|
+
metadata?: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Result discriminator used by validate / parse. The output type can differ
|
|
25
|
+
* from the input type once transforms land (v0.6+).
|
|
26
|
+
*/
|
|
27
|
+
export type Result<T> = {
|
|
28
|
+
success: true;
|
|
29
|
+
data: T;
|
|
30
|
+
} | {
|
|
31
|
+
success: false;
|
|
32
|
+
issues: readonly Issue[];
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=issue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issue.d.ts","sourceRoot":"","sources":["../../../src/errors/issue.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,6fA+Ed,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAErD,MAAM,MAAM,SAAS,GAAG,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;AAEvD,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAChB;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAC1B;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,SAAS,KAAK,EAAE,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable, machine-readable codes for validation issues. The runtime normalizes
|
|
3
|
+
* raw validator errors (Zod, etc.) into this set so every NekoStack consumer
|
|
4
|
+
* (form display, API responses, admin diagnostics) reads the same vocabulary.
|
|
5
|
+
*
|
|
6
|
+
* Adding a code is a breaking change for consumers that switch on it; removing
|
|
7
|
+
* one is breaking for anyone that emits it. v1.0 freezes the set.
|
|
8
|
+
*/
|
|
9
|
+
export const ISSUE_CODES = [
|
|
10
|
+
"invalid_type",
|
|
11
|
+
"missing_required",
|
|
12
|
+
"unknown_key",
|
|
13
|
+
"too_small",
|
|
14
|
+
"too_big",
|
|
15
|
+
"invalid_enum",
|
|
16
|
+
"invalid_literal",
|
|
17
|
+
"invalid_union",
|
|
18
|
+
"invalid_format",
|
|
19
|
+
"custom_refinement_failed",
|
|
20
|
+
"schema_version_unsupported",
|
|
21
|
+
"recursive_reference_unresolved",
|
|
22
|
+
// v0.7 — registry / freshness / loader codes. Added per the Master
|
|
23
|
+
// plan Decision #15 change-control rule, at each code's first use
|
|
24
|
+
// site:
|
|
25
|
+
// - `integrity_error` — first constructed by `parse-provenance.ts`
|
|
26
|
+
// (Step 5) for missing / malformed / self-inconsistent provenance
|
|
27
|
+
// blocks. Reused by `checkHandler` (Step 10) for the impossible
|
|
28
|
+
// row of the two-hash freshness matrix.
|
|
29
|
+
// - `duplicate_schema_id` — first constructed by `build-registry.ts`
|
|
30
|
+
// (Step 6) when the same `(schemaId, schemaVersion)` pair appears
|
|
31
|
+
// in more than one `RegistrySourceEntry`.
|
|
32
|
+
// - `schema_not_found` / `version_not_found` — first constructed by
|
|
33
|
+
// `handlers/check.ts` (Step 10) when a committed artifact's
|
|
34
|
+
// provenance points at a schema id (or `(id, version)` pair) that
|
|
35
|
+
// isn't in the current Registry. Distinct codes so the CLI can
|
|
36
|
+
// format orphan-by-id vs. orphan-by-version differently. Anonymous
|
|
37
|
+
// artifacts also use `schema_not_found` (with `metadata.reason =
|
|
38
|
+
// "anonymous_artifact"`) since the registry never indexes them.
|
|
39
|
+
// Remaining v0.7 codes (`schema_load_failed`, plus the verdict-only
|
|
40
|
+
// identifiers `stale_artifact` / `cosmetic_drift`) — the former lands
|
|
41
|
+
// in the CLI loader (Step 22); the latter pair are *not* issue codes,
|
|
42
|
+
// only FreshnessVerdict statuses on `checkHandler`'s success path.
|
|
43
|
+
"integrity_error",
|
|
44
|
+
"duplicate_schema_id",
|
|
45
|
+
"schema_not_found",
|
|
46
|
+
"version_not_found",
|
|
47
|
+
// v0.8 — migration codes. Added per the Master plan Decision #15
|
|
48
|
+
// change-control rule, at each code's first use site:
|
|
49
|
+
// - `duplicate_migration` — first constructed by
|
|
50
|
+
// `migrations/build-migration-registry.ts` (Step 3) when the same
|
|
51
|
+
// `(schemaId, fromVersion, toVersion)` triple appears in more than
|
|
52
|
+
// one `MigrationSourceEntry`. Mirrors `duplicate_schema_id` from
|
|
53
|
+
// v0.7; the planner / verifier rely on the triple being unique.
|
|
54
|
+
// - `migration_missing_endpoint` — first constructed by
|
|
55
|
+
// `migrations/plan-migration.ts` (Step 4) when either the from-
|
|
56
|
+
// or to-version is absent from the schema registry. Also used by
|
|
57
|
+
// Step 5's verifier when a registered migration references a
|
|
58
|
+
// schema version that has since vanished.
|
|
59
|
+
// - `migration_not_found` — first constructed by `plan-migration.ts`
|
|
60
|
+
// (Step 4) when the requested transition is `breaking` and no
|
|
61
|
+
// migrations are registered for the schemaId at all.
|
|
62
|
+
// - `migration_chain_broken` — first constructed by
|
|
63
|
+
// `plan-migration.ts` (Step 4) when migrations exist for the
|
|
64
|
+
// schemaId but no path bridges (from, to).
|
|
65
|
+
// - `migration_ambiguous_chain` — first constructed by
|
|
66
|
+
// `plan-migration.ts` (Step 4) when two or more distinct chains
|
|
67
|
+
// reach the target. The planner refuses to pick.
|
|
68
|
+
// - `migration_drift` — first constructed by
|
|
69
|
+
// `migrations/verify-provenance.ts` (Step 5) when a migration's
|
|
70
|
+
// recorded `fromIrHash` or `toIrHash` doesn't match the schema
|
|
71
|
+
// registry's current irHash for that version. The migration was
|
|
72
|
+
// authored against a schema state that has since changed
|
|
73
|
+
// semantically; the transform may no longer be correct. CLI
|
|
74
|
+
// maps to LOGICAL_FAILURE.
|
|
75
|
+
// - `migration_cosmetic_drift` — first constructed by
|
|
76
|
+
// `verify-provenance.ts` (Step 5) when irHash matches at both
|
|
77
|
+
// endpoints but at least one sourceHash differs. Source was
|
|
78
|
+
// edited without semantic effect. v0.8 verifier classifies this
|
|
79
|
+
// as a warning verdict; the CLI prints to stderr but the run
|
|
80
|
+
// still succeeds.
|
|
81
|
+
"duplicate_migration",
|
|
82
|
+
"migration_missing_endpoint",
|
|
83
|
+
"migration_not_found",
|
|
84
|
+
"migration_chain_broken",
|
|
85
|
+
"migration_ambiguous_chain",
|
|
86
|
+
"migration_drift",
|
|
87
|
+
"migration_cosmetic_drift",
|
|
88
|
+
];
|
|
89
|
+
//# sourceMappingURL=issue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issue.js","sourceRoot":"","sources":["../../../src/errors/issue.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,cAAc;IACd,kBAAkB;IAClB,aAAa;IACb,WAAW;IACX,SAAS;IACT,cAAc;IACd,iBAAiB;IACjB,eAAe;IACf,gBAAgB;IAChB,0BAA0B;IAC1B,4BAA4B;IAC5B,gCAAgC;IAChC,mEAAmE;IACnE,kEAAkE;IAClE,QAAQ;IACR,uEAAuE;IACvE,oEAAoE;IACpE,kEAAkE;IAClE,0CAA0C;IAC1C,qEAAqE;IACrE,oEAAoE;IACpE,4CAA4C;IAC5C,oEAAoE;IACpE,8DAA8D;IAC9D,oEAAoE;IACpE,iEAAiE;IACjE,qEAAqE;IACrE,mEAAmE;IACnE,kEAAkE;IAClE,oEAAoE;IACpE,sEAAsE;IACtE,sEAAsE;IACtE,mEAAmE;IACnE,iBAAiB;IACjB,qBAAqB;IACrB,kBAAkB;IAClB,mBAAmB;IACnB,iEAAiE;IACjE,sDAAsD;IACtD,iDAAiD;IACjD,oEAAoE;IACpE,qEAAqE;IACrE,mEAAmE;IACnE,kEAAkE;IAClE,wDAAwD;IACxD,kEAAkE;IAClE,mEAAmE;IACnE,+DAA+D;IAC/D,4CAA4C;IAC5C,qEAAqE;IACrE,gEAAgE;IAChE,uDAAuD;IACvD,oDAAoD;IACpD,+DAA+D;IAC/D,6CAA6C;IAC7C,uDAAuD;IACvD,kEAAkE;IAClE,mDAAmD;IACnD,6CAA6C;IAC7C,kEAAkE;IAClE,iEAAiE;IACjE,kEAAkE;IAClE,2DAA2D;IAC3D,8DAA8D;IAC9D,6BAA6B;IAC7B,sDAAsD;IACtD,gEAAgE;IAChE,8DAA8D;IAC9D,kEAAkE;IAClE,+DAA+D;IAC/D,oBAAoB;IACpB,qBAAqB;IACrB,4BAA4B;IAC5B,qBAAqB;IACrB,wBAAwB;IACxB,2BAA2B;IAC3B,iBAAiB;IACjB,0BAA0B;CAClB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable, machine-readable error thrown when a generator encounters IR it
|
|
3
|
+
* cannot represent — either an unsupported node kind or a refinement whose
|
|
4
|
+
* absence would change validation behavior (per Invariant 7).
|
|
5
|
+
*
|
|
6
|
+
* Tests assert on `code` / `kind` / `generator` — never on `message`, which
|
|
7
|
+
* is for humans and can change without breaking the contract.
|
|
8
|
+
*
|
|
9
|
+
* Current `kind` values:
|
|
10
|
+
* - IR node kinds without generator support: `date`, `union`,
|
|
11
|
+
* `recursiveRef`, `transform`.
|
|
12
|
+
* - Refinement-level: `runtimeRefinement` (all generators);
|
|
13
|
+
* `regexFlags` (JSON Schema / OpenAPI — `pattern` has no flag support).
|
|
14
|
+
*
|
|
15
|
+
* Current `generator` values: `typescript`, `zod`, `jsonSchema`, `openApi`,
|
|
16
|
+
* `diff` (v0.7+ — emitted by `src/registry/diff.ts` for unsupported IR
|
|
17
|
+
* kinds at diff time). Both unions extend over time as new generators
|
|
18
|
+
* or new throw cases land; see the active generator docs in
|
|
19
|
+
* `packages/schema/docs/` for the authoritative per-generator throw
|
|
20
|
+
* contract.
|
|
21
|
+
*/
|
|
22
|
+
export declare class UnsupportedNodeKindError extends Error {
|
|
23
|
+
readonly code: "UNSUPPORTED_NODE_KIND";
|
|
24
|
+
readonly kind: string;
|
|
25
|
+
readonly generator: "typescript" | "zod" | "jsonSchema" | "openApi" | "diff";
|
|
26
|
+
constructor(args: {
|
|
27
|
+
kind: string;
|
|
28
|
+
generator: "typescript" | "zod" | "jsonSchema" | "openApi" | "diff";
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/generators/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,QAAQ,CAAC,IAAI,EAAG,uBAAuB,CAAU;IACjD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,YAAY,GAAG,KAAK,GAAG,YAAY,GAAG,SAAS,GAAG,MAAM,CAAC;gBAEjE,IAAI,EAAE;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,YAAY,GAAG,KAAK,GAAG,YAAY,GAAG,SAAS,GAAG,MAAM,CAAC;KACrE;CASF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable, machine-readable error thrown when a generator encounters IR it
|
|
3
|
+
* cannot represent — either an unsupported node kind or a refinement whose
|
|
4
|
+
* absence would change validation behavior (per Invariant 7).
|
|
5
|
+
*
|
|
6
|
+
* Tests assert on `code` / `kind` / `generator` — never on `message`, which
|
|
7
|
+
* is for humans and can change without breaking the contract.
|
|
8
|
+
*
|
|
9
|
+
* Current `kind` values:
|
|
10
|
+
* - IR node kinds without generator support: `date`, `union`,
|
|
11
|
+
* `recursiveRef`, `transform`.
|
|
12
|
+
* - Refinement-level: `runtimeRefinement` (all generators);
|
|
13
|
+
* `regexFlags` (JSON Schema / OpenAPI — `pattern` has no flag support).
|
|
14
|
+
*
|
|
15
|
+
* Current `generator` values: `typescript`, `zod`, `jsonSchema`, `openApi`,
|
|
16
|
+
* `diff` (v0.7+ — emitted by `src/registry/diff.ts` for unsupported IR
|
|
17
|
+
* kinds at diff time). Both unions extend over time as new generators
|
|
18
|
+
* or new throw cases land; see the active generator docs in
|
|
19
|
+
* `packages/schema/docs/` for the authoritative per-generator throw
|
|
20
|
+
* contract.
|
|
21
|
+
*/
|
|
22
|
+
export class UnsupportedNodeKindError extends Error {
|
|
23
|
+
code = "UNSUPPORTED_NODE_KIND";
|
|
24
|
+
kind;
|
|
25
|
+
generator;
|
|
26
|
+
constructor(args) {
|
|
27
|
+
super(`Generator '${args.generator}' does not support IR node kind '${args.kind}' in this phase. ` +
|
|
28
|
+
`See packages/schema/docs/ for the active generator contracts.`);
|
|
29
|
+
this.name = "UnsupportedNodeKindError";
|
|
30
|
+
this.kind = args.kind;
|
|
31
|
+
this.generator = args.generator;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/generators/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACxC,IAAI,GAAG,uBAAgC,CAAC;IACxC,IAAI,CAAS;IACb,SAAS,CAA2D;IAE7E,YAAY,IAGX;QACC,KAAK,CACH,cAAc,IAAI,CAAC,SAAS,oCAAoC,IAAI,CAAC,IAAI,mBAAmB;YAC1F,+DAA+D,CAClE,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { SchemaNode } from "../ir/nodes.js";
|
|
2
|
+
export interface HeaderOptions {
|
|
3
|
+
/** Which generator emitted this file. Affects the header's `generator` field. */
|
|
4
|
+
generator: "typescript" | "zod";
|
|
5
|
+
/** Optional override for the schema-version field, when no `metadata.version` is set on the node. */
|
|
6
|
+
schemaVersion?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Optional sha256 of the originating `*.schema.ts` source bytes
|
|
9
|
+
* (`registry/source-hash.ts → sourceHashFromText`). When provided,
|
|
10
|
+
* emitted as a `sourceHash:` line between `irHash:` and `generator:`.
|
|
11
|
+
* When omitted, the line is **absent entirely** (Master plan Decision #8;
|
|
12
|
+
* NOT emitted as `null` — older parsers and direct generator callers
|
|
13
|
+
* see a header indistinguishable from the v0.2–v0.6 shape).
|
|
14
|
+
*
|
|
15
|
+
* The CLI (v0.7+, `neko schema *`) passes this through; direct
|
|
16
|
+
* generator calls (vitest snapshots, ad-hoc scripts) omit it so
|
|
17
|
+
* existing snapshots remain byte-identical.
|
|
18
|
+
*/
|
|
19
|
+
sourceHash?: `sha256:${string}`;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Build the deterministic JSDoc block prepended to every generated file.
|
|
23
|
+
*
|
|
24
|
+
* Fields (one per line):
|
|
25
|
+
*
|
|
26
|
+
* @generated by @nekostack/schema
|
|
27
|
+
* schemaId: <metadata.id, or `null` for anonymous schemas>
|
|
28
|
+
* schemaVersion: <metadata.version, or `null` for unversioned schemas>
|
|
29
|
+
* irHash: sha256:<hex>
|
|
30
|
+
* [sourceHash: sha256:<hex>] ← v0.7+, only when options.sourceHash is set
|
|
31
|
+
* generator: <typescript|zod>
|
|
32
|
+
* generatorVersion: <package version string>
|
|
33
|
+
*
|
|
34
|
+
* DO NOT EDIT MANUALLY.
|
|
35
|
+
*
|
|
36
|
+
* Determinism: same IR + same generator version + same sourceHash (or
|
|
37
|
+
* same absence) → byte-identical header. Anonymous schemas (no
|
|
38
|
+
* `.id()`) emit `schemaId: null` and include a `// anonymous schema`
|
|
39
|
+
* comment so the omission is intentional and visible.
|
|
40
|
+
*/
|
|
41
|
+
export declare function buildHeader(node: SchemaNode, options: HeaderOptions): string;
|
|
42
|
+
//# sourceMappingURL=header.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../src/generators/header.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAIjD,MAAM,WAAW,aAAa;IAC5B,iFAAiF;IACjF,SAAS,EAAE,YAAY,GAAG,KAAK,CAAC;IAChC,qGAAqG;IACrG,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,EAAE,UAAU,MAAM,EAAE,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CA8B5E"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { irHash } from "../ir/hash.js";
|
|
2
|
+
import { GENERATOR_VERSION } from "./version.js";
|
|
3
|
+
/**
|
|
4
|
+
* Build the deterministic JSDoc block prepended to every generated file.
|
|
5
|
+
*
|
|
6
|
+
* Fields (one per line):
|
|
7
|
+
*
|
|
8
|
+
* @generated by @nekostack/schema
|
|
9
|
+
* schemaId: <metadata.id, or `null` for anonymous schemas>
|
|
10
|
+
* schemaVersion: <metadata.version, or `null` for unversioned schemas>
|
|
11
|
+
* irHash: sha256:<hex>
|
|
12
|
+
* [sourceHash: sha256:<hex>] ← v0.7+, only when options.sourceHash is set
|
|
13
|
+
* generator: <typescript|zod>
|
|
14
|
+
* generatorVersion: <package version string>
|
|
15
|
+
*
|
|
16
|
+
* DO NOT EDIT MANUALLY.
|
|
17
|
+
*
|
|
18
|
+
* Determinism: same IR + same generator version + same sourceHash (or
|
|
19
|
+
* same absence) → byte-identical header. Anonymous schemas (no
|
|
20
|
+
* `.id()`) emit `schemaId: null` and include a `// anonymous schema`
|
|
21
|
+
* comment so the omission is intentional and visible.
|
|
22
|
+
*/
|
|
23
|
+
export function buildHeader(node, options) {
|
|
24
|
+
const id = node.metadata?.id ?? null;
|
|
25
|
+
const version = node.metadata?.version ?? options.schemaVersion ?? null;
|
|
26
|
+
const hash = irHash(node);
|
|
27
|
+
const lines = [
|
|
28
|
+
"/**",
|
|
29
|
+
" * @generated by @nekostack/schema",
|
|
30
|
+
];
|
|
31
|
+
if (id === null) {
|
|
32
|
+
lines.push(" * // anonymous schema");
|
|
33
|
+
}
|
|
34
|
+
lines.push(` * schemaId: ${id === null ? "null" : id}`, ` * schemaVersion: ${version === null ? "null" : version}`, ` * irHash: sha256:${hash}`);
|
|
35
|
+
if (options.sourceHash !== undefined) {
|
|
36
|
+
// 11 chars "sourceHash:" + 7 spaces to land the value at column 18,
|
|
37
|
+
// matching the existing field-name column width.
|
|
38
|
+
lines.push(` * sourceHash: ${options.sourceHash}`);
|
|
39
|
+
}
|
|
40
|
+
lines.push(` * generator: ${options.generator}`, ` * generatorVersion: ${GENERATOR_VERSION}`, " *", " * DO NOT EDIT MANUALLY.", " */");
|
|
41
|
+
return lines.join("\n");
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header.js","sourceRoot":"","sources":["../../../src/generators/header.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAsBjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,WAAW,CAAC,IAAgB,EAAE,OAAsB;IAClE,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,IAAI,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,EAAE,OAAO,IAAI,OAAO,CAAC,aAAa,IAAI,IAAI,CAAC;IACxE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAE1B,MAAM,KAAK,GAAa;QACtB,KAAK;QACL,oCAAoC;KACrC,CAAC;IACF,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;QAChB,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACvC,CAAC;IACD,KAAK,CAAC,IAAI,CACR,wBAAwB,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,EACnD,wBAAwB,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,EAC7D,+BAA+B,IAAI,EAAE,CACtC,CAAC;IACF,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACrC,oEAAoE;QACpE,iDAAiD;QACjD,KAAK,CAAC,IAAI,CAAC,wBAAwB,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAC3D,CAAC;IACD,KAAK,CAAC,IAAI,CACR,wBAAwB,OAAO,CAAC,SAAS,EAAE,EAC3C,wBAAwB,iBAAiB,EAAE,EAC3C,IAAI,EACJ,0BAA0B,EAC1B,KAAK,CACN,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codified `x-nekostack-*` extension keys used by the JSON Schema generator.
|
|
3
|
+
*
|
|
4
|
+
* These are the contract; any new extension key the generator emits must
|
|
5
|
+
* land here first. Stringly-typed extensions in the generator body would
|
|
6
|
+
* make typos and drift easy — the constants make both the spelling and the
|
|
7
|
+
* meaning grep-able.
|
|
8
|
+
*
|
|
9
|
+
* See [`docs/JSON_SCHEMA_MAPPING.md`](../../docs/JSON_SCHEMA_MAPPING.md) for
|
|
10
|
+
* the per-key contract: when each is emitted, what it means, and what
|
|
11
|
+
* NekoStack-aware consumers should do with it.
|
|
12
|
+
*/
|
|
13
|
+
export declare const JSON_SCHEMA_EXTENSIONS: {
|
|
14
|
+
/**
|
|
15
|
+
* Top-level provenance object: `{ generator, generatorVersion, irHash,
|
|
16
|
+
* schemaId, schemaVersion }`. Replaces the v0.2-style JSDoc header since
|
|
17
|
+
* JSON has no comment syntax.
|
|
18
|
+
*/
|
|
19
|
+
readonly provenance: "x-nekostack";
|
|
20
|
+
/**
|
|
21
|
+
* Tag on a node carrying `default()`: signals that JSON Schema validators
|
|
22
|
+
* will NOT apply the default (it's annotation only); the NekoStack runtime
|
|
23
|
+
* (or the generated Zod) is responsible. Value is the literal string
|
|
24
|
+
* `"runtime"`.
|
|
25
|
+
*/
|
|
26
|
+
readonly defaultAppliedBy: "x-nekostack-default-applied-by";
|
|
27
|
+
/**
|
|
28
|
+
* Tag on an object whose unknown-key policy is `stripUnknown`: signals
|
|
29
|
+
* that the schema accepts unknown keys (`additionalProperties: true`)
|
|
30
|
+
* and that NekoStack-aware runtime/CLI consumers should strip them.
|
|
31
|
+
* JSON Schema cannot express mutation; this is the bridge.
|
|
32
|
+
*/
|
|
33
|
+
readonly strip: "x-nekostack-strip";
|
|
34
|
+
};
|
|
35
|
+
export type JsonSchemaExtensionKey = (typeof JSON_SCHEMA_EXTENSIONS)[keyof typeof JSON_SCHEMA_EXTENSIONS];
|
|
36
|
+
//# sourceMappingURL=json-schema-meta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema-meta.d.ts","sourceRoot":"","sources":["../../../src/generators/json-schema-meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB;IACjC;;;;OAIG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;CAEK,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAChC,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,OAAO,sBAAsB,CAAC,CAAC"}
|