@formspec/build 0.1.0-alpha.4 → 0.1.0-alpha.40
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/LICENSE +21 -0
- package/README.md +238 -93
- package/dist/analyzer/class-analyzer.d.ts +135 -0
- package/dist/analyzer/class-analyzer.d.ts.map +1 -0
- package/dist/analyzer/jsdoc-constraints.d.ts +53 -0
- package/dist/analyzer/jsdoc-constraints.d.ts.map +1 -0
- package/dist/analyzer/program.d.ts +94 -0
- package/dist/analyzer/program.d.ts.map +1 -0
- package/dist/analyzer/tsdoc-parser.d.ts +126 -0
- package/dist/analyzer/tsdoc-parser.d.ts.map +1 -0
- package/dist/browser.cjs +1904 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.ts +74 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +1861 -0
- package/dist/browser.js.map +1 -0
- package/dist/build-alpha.d.ts +1491 -0
- package/dist/build-beta.d.ts +1491 -0
- package/dist/build-internal.d.ts +1491 -0
- package/dist/build.d.ts +1184 -43
- package/dist/canonicalize/chain-dsl-canonicalizer.d.ts +22 -0
- package/dist/canonicalize/chain-dsl-canonicalizer.d.ts.map +1 -0
- package/dist/canonicalize/index.d.ts +8 -0
- package/dist/canonicalize/index.d.ts.map +1 -0
- package/dist/canonicalize/tsdoc-canonicalizer.d.ts +38 -0
- package/dist/canonicalize/tsdoc-canonicalizer.d.ts.map +1 -0
- package/dist/cli.cjs +6579 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.js +6551 -103
- package/dist/cli.js.map +1 -1
- package/dist/extensions/index.d.ts +8 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/extensions/registry.d.ts +83 -0
- package/dist/extensions/registry.d.ts.map +1 -0
- package/dist/generators/class-schema.d.ts +342 -0
- package/dist/generators/class-schema.d.ts.map +1 -0
- package/dist/generators/discovered-schema.d.ts +152 -0
- package/dist/generators/discovered-schema.d.ts.map +1 -0
- package/dist/generators/method-schema.d.ts +65 -0
- package/dist/generators/method-schema.d.ts.map +1 -0
- package/dist/generators/mixed-authoring.d.ts +52 -0
- package/dist/generators/mixed-authoring.d.ts.map +1 -0
- package/dist/index.cjs +6293 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +50 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6268 -107
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +5480 -0
- package/dist/internals.cjs.map +1 -0
- package/dist/internals.d.ts +32 -0
- package/dist/internals.d.ts.map +1 -0
- package/dist/internals.js +5461 -0
- package/dist/internals.js.map +1 -0
- package/dist/json-schema/generator.d.ts +27 -6
- package/dist/json-schema/generator.d.ts.map +1 -1
- package/dist/json-schema/ir-generator.d.ts +144 -0
- package/dist/json-schema/ir-generator.d.ts.map +1 -0
- package/dist/json-schema/schema.d.ts +23 -0
- package/dist/json-schema/schema.d.ts.map +1 -0
- package/dist/json-schema/types.d.ts +76 -2
- package/dist/json-schema/types.d.ts.map +1 -1
- package/dist/metadata/collision-guards.d.ts +3 -0
- package/dist/metadata/collision-guards.d.ts.map +1 -0
- package/dist/metadata/index.d.ts +7 -0
- package/dist/metadata/index.d.ts.map +1 -0
- package/dist/metadata/policy.d.ts +11 -0
- package/dist/metadata/policy.d.ts.map +1 -0
- package/dist/metadata/resolve.d.ts +20 -0
- package/dist/metadata/resolve.d.ts.map +1 -0
- package/dist/static-build.d.ts +61 -0
- package/dist/static-build.d.ts.map +1 -0
- package/dist/ui-schema/generator.d.ts +18 -2
- package/dist/ui-schema/generator.d.ts.map +1 -1
- package/dist/ui-schema/ir-generator.d.ts +54 -0
- package/dist/ui-schema/ir-generator.d.ts.map +1 -0
- package/dist/ui-schema/schema.d.ts +429 -0
- package/dist/ui-schema/schema.d.ts.map +1 -0
- package/dist/ui-schema/types.d.ts +179 -35
- package/dist/ui-schema/types.d.ts.map +1 -1
- package/dist/validate/constraint-validator.d.ts +85 -0
- package/dist/validate/constraint-validator.d.ts.map +1 -0
- package/dist/validate/index.d.ts +9 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/package.json +31 -11
- package/dist/__tests__/cli.test.d.ts +0 -2
- package/dist/__tests__/cli.test.d.ts.map +0 -1
- package/dist/__tests__/cli.test.js +0 -178
- package/dist/__tests__/cli.test.js.map +0 -1
- package/dist/__tests__/edge-cases.test.d.ts +0 -7
- package/dist/__tests__/edge-cases.test.d.ts.map +0 -1
- package/dist/__tests__/edge-cases.test.js +0 -217
- package/dist/__tests__/edge-cases.test.js.map +0 -1
- package/dist/__tests__/generator.test.d.ts +0 -2
- package/dist/__tests__/generator.test.d.ts.map +0 -1
- package/dist/__tests__/generator.test.js +0 -225
- package/dist/__tests__/generator.test.js.map +0 -1
- package/dist/__tests__/integration.test.d.ts +0 -8
- package/dist/__tests__/integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration.test.js +0 -163
- package/dist/__tests__/integration.test.js.map +0 -1
- package/dist/__tests__/write-schemas.test.d.ts +0 -2
- package/dist/__tests__/write-schemas.test.d.ts.map +0 -1
- package/dist/__tests__/write-schemas.test.js +0 -196
- package/dist/__tests__/write-schemas.test.js.map +0 -1
- package/dist/json-schema/generator.js +0 -161
- package/dist/json-schema/generator.js.map +0 -1
- package/dist/json-schema/types.js +0 -7
- package/dist/json-schema/types.js.map +0 -1
- package/dist/ui-schema/generator.js +0 -150
- package/dist/ui-schema/generator.js.map +0 -1
- package/dist/ui-schema/types.js +0 -8
- package/dist/ui-schema/types.js.map +0 -1
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* JSON Schema generator for FormSpec forms.
|
|
3
|
+
*
|
|
4
|
+
* Routes through the canonical IR pipeline: Chain DSL → FormIR → JSON Schema 2020-12.
|
|
5
|
+
*/
|
|
6
|
+
import type { FormElement, FormSpec, MetadataPolicyInput } from "@formspec/core";
|
|
7
|
+
import { type JsonSchema2020 } from "./ir-generator.js";
|
|
8
|
+
/**
|
|
9
|
+
* Options for generating JSON Schema from a Chain DSL form.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
3
12
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
13
|
+
export interface GenerateJsonSchemaOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Vendor prefix for emitted extension keywords.
|
|
16
|
+
* @defaultValue "x-formspec"
|
|
17
|
+
*/
|
|
18
|
+
readonly vendorPrefix?: string | undefined;
|
|
19
|
+
/** Metadata resolution policy for chain DSL generation. */
|
|
20
|
+
readonly metadata?: MetadataPolicyInput | undefined;
|
|
21
|
+
}
|
|
6
22
|
/**
|
|
7
|
-
* Generates a JSON Schema from a FormSpec.
|
|
23
|
+
* Generates a JSON Schema 2020-12 from a FormSpec.
|
|
24
|
+
*
|
|
25
|
+
* All generation routes through the canonical IR. The chain DSL is first
|
|
26
|
+
* canonicalized to a FormIR, then the IR-based generator produces the schema.
|
|
8
27
|
*
|
|
9
28
|
* @example
|
|
10
29
|
* ```typescript
|
|
@@ -15,7 +34,7 @@ import type { JSONSchema7 } from "./types.js";
|
|
|
15
34
|
*
|
|
16
35
|
* const schema = generateJsonSchema(form);
|
|
17
36
|
* // {
|
|
18
|
-
* // $schema: "https://json-schema.org/draft-
|
|
37
|
+
* // $schema: "https://json-schema.org/draft/2020-12/schema",
|
|
19
38
|
* // type: "object",
|
|
20
39
|
* // properties: {
|
|
21
40
|
* // name: { type: "string", title: "Name" },
|
|
@@ -26,7 +45,9 @@ import type { JSONSchema7 } from "./types.js";
|
|
|
26
45
|
* ```
|
|
27
46
|
*
|
|
28
47
|
* @param form - The FormSpec to convert
|
|
29
|
-
* @returns A JSON Schema object
|
|
48
|
+
* @returns A JSON Schema 2020-12 object
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
30
51
|
*/
|
|
31
|
-
export declare function generateJsonSchema<E extends readonly FormElement[]>(form: FormSpec<E
|
|
52
|
+
export declare function generateJsonSchema<E extends readonly FormElement[]>(form: FormSpec<E>, options?: GenerateJsonSchemaOptions): JsonSchema2020;
|
|
32
53
|
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/json-schema/generator.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/json-schema/generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEjF,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAE3B;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,2DAA2D;IAC3D,QAAQ,CAAC,QAAQ,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;CACrD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,SAAS,WAAW,EAAE,EACjE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EACjB,OAAO,CAAC,EAAE,yBAAyB,GAClC,cAAc,CAQhB"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Schema 2020-12 generator that consumes the canonical FormIR.
|
|
3
|
+
*
|
|
4
|
+
* This generator is a pure function of the IR. It never consults the TypeScript
|
|
5
|
+
* AST or surface syntax directly — only the IR (per the JSON Schema vocabulary spec §1.2).
|
|
6
|
+
*
|
|
7
|
+
* @see https://json-schema.org/draft/2020-12/schema
|
|
8
|
+
* @see https://json-schema.org/draft/2020-12/schema
|
|
9
|
+
*/
|
|
10
|
+
import type { FormIR } from "@formspec/core/internals";
|
|
11
|
+
import type { ExtensionRegistry } from "../extensions/index.js";
|
|
12
|
+
/**
|
|
13
|
+
* A JSON Schema 2020-12 document, sub-schema, or keyword collection.
|
|
14
|
+
*
|
|
15
|
+
* This interface covers the subset of JSON Schema 2020-12 that this generator
|
|
16
|
+
* emits, plus an index signature for custom `x-formspec-*` extension keywords.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export interface JsonSchema2020 {
|
|
21
|
+
/** Declared JSON Schema dialect URI for the document root. */
|
|
22
|
+
$schema?: string;
|
|
23
|
+
/** Reference to another schema location. */
|
|
24
|
+
$ref?: string;
|
|
25
|
+
/** Named reusable schema definitions keyed by definition name. */
|
|
26
|
+
$defs?: Record<string, JsonSchema2020>;
|
|
27
|
+
/** JSON Schema type keyword for the current node. */
|
|
28
|
+
type?: string;
|
|
29
|
+
/** Object properties keyed by property name. */
|
|
30
|
+
properties?: Record<string, JsonSchema2020>;
|
|
31
|
+
/** Property names that must be present on object values. */
|
|
32
|
+
required?: string[];
|
|
33
|
+
/** Item schema applied to array elements. */
|
|
34
|
+
items?: JsonSchema2020;
|
|
35
|
+
/** Whether, or how, additional object properties are allowed. */
|
|
36
|
+
additionalProperties?: boolean | JsonSchema2020;
|
|
37
|
+
/** Closed set of allowed scalar values. */
|
|
38
|
+
enum?: readonly (string | number)[];
|
|
39
|
+
/** Literal value the instance must equal. */
|
|
40
|
+
const?: unknown;
|
|
41
|
+
/** Schemas that must all validate successfully. */
|
|
42
|
+
allOf?: readonly JsonSchema2020[];
|
|
43
|
+
/** Schemas of which exactly one should validate successfully. */
|
|
44
|
+
oneOf?: readonly JsonSchema2020[];
|
|
45
|
+
/** Schemas of which at least one may validate successfully. */
|
|
46
|
+
anyOf?: readonly JsonSchema2020[];
|
|
47
|
+
/** Inclusive numeric lower bound. */
|
|
48
|
+
minimum?: number;
|
|
49
|
+
/** Inclusive numeric upper bound. */
|
|
50
|
+
maximum?: number;
|
|
51
|
+
/** Exclusive numeric lower bound. */
|
|
52
|
+
exclusiveMinimum?: number;
|
|
53
|
+
/** Exclusive numeric upper bound. */
|
|
54
|
+
exclusiveMaximum?: number;
|
|
55
|
+
/** Required numeric step interval. */
|
|
56
|
+
multipleOf?: number;
|
|
57
|
+
/** Inclusive minimum string length. */
|
|
58
|
+
minLength?: number;
|
|
59
|
+
/** Inclusive maximum string length. */
|
|
60
|
+
maxLength?: number;
|
|
61
|
+
/** Inclusive minimum array length. */
|
|
62
|
+
minItems?: number;
|
|
63
|
+
/** Inclusive maximum array length. */
|
|
64
|
+
maxItems?: number;
|
|
65
|
+
/** Regular expression pattern applied to string values. */
|
|
66
|
+
pattern?: string;
|
|
67
|
+
/** Whether array elements must be unique. */
|
|
68
|
+
uniqueItems?: boolean;
|
|
69
|
+
/** Format hint for downstream validators and tooling. */
|
|
70
|
+
format?: string;
|
|
71
|
+
/** Human-readable title for the schema node. */
|
|
72
|
+
title?: string;
|
|
73
|
+
/** Human-readable description for the schema node. */
|
|
74
|
+
description?: string;
|
|
75
|
+
/** Default value suggested for the schema node. */
|
|
76
|
+
default?: unknown;
|
|
77
|
+
/** Whether the schema node is deprecated. */
|
|
78
|
+
deprecated?: boolean;
|
|
79
|
+
/** Additional vendor-prefixed extension keywords. */
|
|
80
|
+
[key: `x-${string}`]: unknown;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Options for generating JSON Schema from a canonical FormIR.
|
|
84
|
+
*
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
export interface GenerateJsonSchemaFromIROptions {
|
|
88
|
+
/**
|
|
89
|
+
* Registry used to resolve custom types, constraints, and annotations.
|
|
90
|
+
*
|
|
91
|
+
* JSON Schema generation throws when custom IR nodes are present without a
|
|
92
|
+
* matching registration in this registry.
|
|
93
|
+
*/
|
|
94
|
+
readonly extensionRegistry?: ExtensionRegistry | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Vendor prefix passed to extension `toJsonSchema` hooks.
|
|
97
|
+
* @defaultValue "x-formspec"
|
|
98
|
+
*/
|
|
99
|
+
readonly vendorPrefix?: string | undefined;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Generates a JSON Schema 2020-12 object from a canonical FormIR.
|
|
103
|
+
*
|
|
104
|
+
* Groups and conditionals are flattened — they influence UI layout but do not
|
|
105
|
+
* affect the data schema. All fields appear at the level they would occupy in
|
|
106
|
+
* the output data.
|
|
107
|
+
*
|
|
108
|
+
* Named types in the `typeRegistry` are emitted as `$defs` entries and
|
|
109
|
+
* referenced via `$ref` (per PP7 — high-fidelity output).
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* import { canonicalizeDSL } from "./canonicalize/index.js";
|
|
114
|
+
* import { generateJsonSchemaFromIR } from "./json-schema/ir-generator.js";
|
|
115
|
+
* import { formspec, field } from "@formspec/dsl";
|
|
116
|
+
*
|
|
117
|
+
* const form = formspec(
|
|
118
|
+
* field.text("name", { label: "Name", required: true }),
|
|
119
|
+
* field.number("age", { min: 0 }),
|
|
120
|
+
* );
|
|
121
|
+
* const ir = canonicalizeDSL(form);
|
|
122
|
+
* const schema = generateJsonSchemaFromIR(ir);
|
|
123
|
+
* // {
|
|
124
|
+
* // $schema: "https://json-schema.org/draft/2020-12/schema",
|
|
125
|
+
* // type: "object",
|
|
126
|
+
* // properties: {
|
|
127
|
+
* // name: { type: "string", title: "Name" },
|
|
128
|
+
* // age: { type: "number", minimum: 0 }
|
|
129
|
+
* // },
|
|
130
|
+
* // required: ["name"]
|
|
131
|
+
* // }
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* Advanced API — most consumers should use `generateJsonSchema()` or
|
|
135
|
+
* `buildFormSchemas()`, which canonicalize form definitions automatically.
|
|
136
|
+
* Callers of this function are responsible for providing pre-canonicalized IR.
|
|
137
|
+
*
|
|
138
|
+
* @param ir - The canonical FormIR produced by a canonicalizer
|
|
139
|
+
* @returns A plain JSON-serializable JSON Schema 2020-12 object
|
|
140
|
+
*
|
|
141
|
+
* @internal
|
|
142
|
+
*/
|
|
143
|
+
export declare function generateJsonSchemaFromIR(ir: FormIR, options?: GenerateJsonSchemaFromIROptions): JsonSchema2020;
|
|
144
|
+
//# sourceMappingURL=ir-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ir-generator.d.ts","sourceRoot":"","sources":["../../src/json-schema/ir-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,MAAM,EAgBP,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAQhE;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACvC,qDAAqD;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC5C,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,iEAAiE;IACjE,oBAAoB,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IAChD,2CAA2C;IAC3C,IAAI,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IACpC,6CAA6C;IAC7C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,mDAAmD;IACnD,KAAK,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IAClC,iEAAiE;IACjE,KAAK,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IAClC,+DAA+D;IAC/D,KAAK,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IAElC,qC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AE,+BAA+B,GACxC,cAAc,CAsDhB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for JSON Schema output validation.
|
|
3
|
+
*
|
|
4
|
+
* These schemas cover the subset of JSON Schema that FormSpec generates,
|
|
5
|
+
* plus the FormSpec-specific `x-formspec-*` extension properties.
|
|
6
|
+
*
|
|
7
|
+
* @see https://json-schema.org/draft/2020-12/schema
|
|
8
|
+
*/
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import type { JSONSchema7 } from "./types.js";
|
|
11
|
+
/**
|
|
12
|
+
* Zod schema for JSON Schema primitive type strings.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export declare const jsonSchemaTypeSchema: z.ZodEnum<["string", "number", "integer", "boolean", "object", "array", "null"]>;
|
|
17
|
+
/**
|
|
18
|
+
* Zod schema for the legacy JSON Schema 7 subset used by `@formspec/build`.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export declare const jsonSchema7Schema: z.ZodType<JSONSchema7>;
|
|
23
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/json-schema/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAM9C;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,kFAQ/B,CAAC;AAaH;;;;GAIG;AAGH,eAAO,MAAM,iBAAiB,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAoEpD,CAAC"}
|
|
@@ -1,45 +1,81 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* JSON Schema
|
|
2
|
+
* JSON Schema type definitions.
|
|
3
3
|
*
|
|
4
4
|
* These types are a subset of JSON Schema sufficient for form generation.
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* JSON Schema primitive types.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
8
10
|
*/
|
|
9
11
|
export type JSONSchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
|
|
10
12
|
/**
|
|
11
|
-
* A JSON Schema definition (
|
|
13
|
+
* A JSON Schema definition (legacy subset used by Zod validator and types.ts).
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
12
16
|
*/
|
|
13
17
|
export interface JSONSchema7 {
|
|
18
|
+
/** Declared JSON Schema dialect URI for the document root. */
|
|
14
19
|
$schema?: string;
|
|
20
|
+
/** Stable identifier for the schema document or sub-schema. */
|
|
15
21
|
$id?: string;
|
|
22
|
+
/** Reference to another schema location. */
|
|
16
23
|
$ref?: string;
|
|
24
|
+
/** Human-readable title for the schema node. */
|
|
17
25
|
title?: string;
|
|
26
|
+
/** Human-readable description for the schema node. */
|
|
18
27
|
description?: string;
|
|
28
|
+
/** Whether the schema node is deprecated. */
|
|
29
|
+
deprecated?: boolean;
|
|
30
|
+
/** JSON Schema type keyword for the current node. */
|
|
19
31
|
type?: JSONSchemaType | JSONSchemaType[];
|
|
32
|
+
/** Inclusive minimum string length. */
|
|
20
33
|
minLength?: number;
|
|
34
|
+
/** Inclusive maximum string length. */
|
|
21
35
|
maxLength?: number;
|
|
36
|
+
/** Regular expression pattern applied to string values. */
|
|
22
37
|
pattern?: string;
|
|
38
|
+
/** Inclusive numeric lower bound. */
|
|
23
39
|
minimum?: number;
|
|
40
|
+
/** Inclusive numeric upper bound. */
|
|
24
41
|
maximum?: number;
|
|
42
|
+
/** Exclusive numeric lower bound. */
|
|
25
43
|
exclusiveMinimum?: number;
|
|
44
|
+
/** Exclusive numeric upper bound. */
|
|
26
45
|
exclusiveMaximum?: number;
|
|
46
|
+
/** Closed set of allowed scalar values. */
|
|
27
47
|
enum?: readonly (string | number | boolean | null)[];
|
|
48
|
+
/** Literal value the instance must equal. */
|
|
28
49
|
const?: string | number | boolean | null;
|
|
50
|
+
/** Object properties keyed by property name. */
|
|
29
51
|
properties?: Record<string, JSONSchema7>;
|
|
52
|
+
/** Property names that must be present on object values. */
|
|
30
53
|
required?: string[];
|
|
54
|
+
/** Whether, or how, additional object properties are allowed. */
|
|
31
55
|
additionalProperties?: boolean | JSONSchema7;
|
|
56
|
+
/** Item schema or tuple schemas applied to array elements. */
|
|
32
57
|
items?: JSONSchema7 | JSONSchema7[];
|
|
58
|
+
/** Inclusive minimum array length. */
|
|
33
59
|
minItems?: number;
|
|
60
|
+
/** Inclusive maximum array length. */
|
|
34
61
|
maxItems?: number;
|
|
62
|
+
/** Schemas that must all validate successfully. */
|
|
35
63
|
allOf?: JSONSchema7[];
|
|
64
|
+
/** Schemas of which at least one may validate successfully. */
|
|
36
65
|
anyOf?: JSONSchema7[];
|
|
66
|
+
/** Schemas of which exactly one should validate successfully. */
|
|
37
67
|
oneOf?: JSONSchema7[];
|
|
68
|
+
/** Schema that must not validate successfully. */
|
|
38
69
|
not?: JSONSchema7;
|
|
70
|
+
/** Conditional branch predicate schema. */
|
|
39
71
|
if?: JSONSchema7;
|
|
72
|
+
/** Schema applied when the `if` branch matches. */
|
|
40
73
|
then?: JSONSchema7;
|
|
74
|
+
/** Schema applied when the `if` branch does not match. */
|
|
41
75
|
else?: JSONSchema7;
|
|
76
|
+
/** Format hint for downstream validators and tooling. */
|
|
42
77
|
format?: string;
|
|
78
|
+
/** Default value suggested for the schema node. */
|
|
43
79
|
default?: unknown;
|
|
44
80
|
/**
|
|
45
81
|
* Data source key for dynamic enum fields.
|
|
@@ -57,4 +93,42 @@ export interface JSONSchema7 {
|
|
|
57
93
|
*/
|
|
58
94
|
"x-formspec-schemaSource"?: string;
|
|
59
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Extension properties for custom FormSpec constraint tags.
|
|
98
|
+
*
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
101
|
+
export type FormSpecSchemaExtensions = Record<`x-formspec-${string}`, unknown>;
|
|
102
|
+
/**
|
|
103
|
+
* JSON Schema with FormSpec extension properties for arbitrary `x-formspec-*` keys.
|
|
104
|
+
*
|
|
105
|
+
* @public
|
|
106
|
+
*/
|
|
107
|
+
export type ExtendedJSONSchema7 = JSONSchema7 & FormSpecSchemaExtensions;
|
|
108
|
+
/**
|
|
109
|
+
* Sets a FormSpec extension property on a JSON Schema node.
|
|
110
|
+
*
|
|
111
|
+
* Use this to safely add `x-formspec-*` properties to any schema,
|
|
112
|
+
* including nested schemas typed as `JSONSchema7` (which don't carry
|
|
113
|
+
* the extension index signature).
|
|
114
|
+
*
|
|
115
|
+
* @param schema - Any JSON Schema node
|
|
116
|
+
* @param key - Extension key (must start with `x-formspec-`)
|
|
117
|
+
* @param value - Extension value
|
|
118
|
+
*
|
|
119
|
+
* @internal
|
|
120
|
+
*/
|
|
121
|
+
export declare function setSchemaExtension(schema: object, key: `x-formspec-${string}`, value: unknown): void;
|
|
122
|
+
/**
|
|
123
|
+
* Reads a FormSpec extension property from a JSON Schema node.
|
|
124
|
+
*
|
|
125
|
+
* Accepts any schema object — `JSONSchema7`, `JsonSchema2020`, `ExtendedJSONSchema7`, etc.
|
|
126
|
+
*
|
|
127
|
+
* @param schema - Any JSON Schema node
|
|
128
|
+
* @param key - Extension key (must start with `x-formspec-`)
|
|
129
|
+
* @returns The extension value, or `undefined` if not present
|
|
130
|
+
*
|
|
131
|
+
* @internal
|
|
132
|
+
*/
|
|
133
|
+
export declare function getSchemaExtension(schema: object, key: `x-formspec-${string}`): unknown;
|
|
60
134
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/json-schema/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/json-schema/types.ts"],"names":[],"mappings":"AAAA;;;;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,CAEN;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,MAAM,EAAE,GAAG,OAAO,CAEvF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collision-guards.d.ts","sourceRoot":"","sources":["../../src/metadata/collision-guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,MAAM,EAKP,MAAM,0BAA0B,CAAC;AA4HlC,wBAAgB,gCAAgC,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAejE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { NormalizedPluralizationPolicy as NormalizedMetadataPluralizationPolicy, NormalizedMetadataScalarPolicy, NormalizedDeclarationMetadataPolicy, NormalizedMetadataPolicy, MetadataResolutionContext, } from "./policy.js";
|
|
2
|
+
export { normalizeMetadataPolicy, getDeclarationMetadataPolicy, makeMetadataContext, defaultApiNameInference, defaultDisplayNameInference, getDefaultMetadataPolicy, } from "./policy.js";
|
|
3
|
+
export type { ExplicitMetadataInput } from "./resolve.js";
|
|
4
|
+
export { resolveMetadata, getSerializedName, getDisplayName } from "./resolve.js";
|
|
5
|
+
export type { ResolveFormIRMetadataOptions } from "./resolve.js";
|
|
6
|
+
export { resolveFormIRMetadata, mergeResolvedMetadata } from "./resolve.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/metadata/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,6BAA6B,IAAI,qCAAqC,EACtE,8BAA8B,EAC9B,mCAAmC,EACnC,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,uBAAuB,EACvB,4BAA4B,EAC5B,mBAAmB,EACnB,uBAAuB,EACvB,2BAA2B,EAC3B,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAClF,YAAY,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MetadataAuthoringSurface, MetadataDeclarationKind, MetadataInferenceContext, MetadataPolicyInput, NormalizedDeclarationMetadataPolicy, NormalizedMetadataPolicy, NormalizedMetadataValuePolicy } from "@formspec/core/internals";
|
|
2
|
+
export type { NormalizedDeclarationMetadataPolicy, NormalizedMetadataPolicy, NormalizedMetadataPluralizationPolicy as NormalizedPluralizationPolicy, } from "@formspec/core/internals";
|
|
3
|
+
export type MetadataResolutionContext = MetadataInferenceContext;
|
|
4
|
+
export type NormalizedMetadataScalarPolicy = NormalizedMetadataValuePolicy;
|
|
5
|
+
export declare function defaultApiNameInference(_context: MetadataResolutionContext): string;
|
|
6
|
+
export declare function defaultDisplayNameInference(_context: MetadataResolutionContext): string;
|
|
7
|
+
export declare function normalizeMetadataPolicy(input?: MetadataPolicyInput): NormalizedMetadataPolicy;
|
|
8
|
+
export declare function getDeclarationMetadataPolicy(policy: NormalizedMetadataPolicy, declarationKind: MetadataDeclarationKind): NormalizedDeclarationMetadataPolicy;
|
|
9
|
+
export declare function makeMetadataContext(surface: MetadataAuthoringSurface, declarationKind: MetadataDeclarationKind, logicalName: string, buildContext?: unknown): MetadataResolutionContext;
|
|
10
|
+
export declare function getDefaultMetadataPolicy(): NormalizedMetadataPolicy;
|
|
11
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/metadata/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EAGxB,mBAAmB,EAEnB,mCAAmC,EACnC,wBAAwB,EAExB,6BAA6B,EAC9B,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,mCAAmC,EACnC,wBAAwB,EACxB,qCAAqC,IAAI,6BAA6B,GACvE,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,yBAAyB,GAAG,wBAAwB,CAAC;AACjE,MAAM,MAAM,8BAA8B,GAAG,6BAA6B,CAAC;AAE3E,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,yBAAyB,GAClC,MAAM,CAER;AAED,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,yBAAyB,GAClC,MAAM,CAER;AAiED,wBAAgB,uBAAuB,CACrC,KAAK,CAAC,EAAE,mBAAmB,GAC1B,wBAAwB,CAM1B;AAED,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,wBAAwB,EAChC,eAAe,EAAE,uBAAuB,GACvC,mCAAmC,CAErC;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,wBAAwB,EACjC,eAAe,EAAE,uBAAuB,EACxC,WAAW,EAAE,MAAM,EACnB,YAAY,CAAC,EAAE,OAAO,GACrB,yBAAyB,CAO3B;AAED,wBAAgB,wBAAwB,IAAI,wBAAwB,CAEnE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FormIR, MetadataAuthoringSurface, ResolvedMetadata } from "@formspec/core/internals";
|
|
2
|
+
import type { MetadataResolutionContext, NormalizedDeclarationMetadataPolicy, NormalizedMetadataPolicy } from "./policy.js";
|
|
3
|
+
export interface ExplicitMetadataInput {
|
|
4
|
+
readonly apiName?: string;
|
|
5
|
+
readonly displayName?: string;
|
|
6
|
+
readonly apiNamePlural?: string;
|
|
7
|
+
readonly displayNamePlural?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ResolveFormIRMetadataOptions {
|
|
10
|
+
readonly policy: NormalizedMetadataPolicy;
|
|
11
|
+
readonly surface: MetadataAuthoringSurface;
|
|
12
|
+
readonly buildContext?: unknown;
|
|
13
|
+
readonly rootLogicalName?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function resolveMetadata(explicit: ExplicitMetadataInput | undefined, policy: NormalizedDeclarationMetadataPolicy, context: MetadataResolutionContext): ResolvedMetadata | undefined;
|
|
16
|
+
export declare function mergeResolvedMetadata(baseMetadata: ResolvedMetadata | undefined, overlayMetadata: ResolvedMetadata | undefined): ResolvedMetadata | undefined;
|
|
17
|
+
export declare function getSerializedName(logicalName: string, metadata: ResolvedMetadata | undefined): string;
|
|
18
|
+
export declare function getDisplayName(metadata: ResolvedMetadata | undefined): string | undefined;
|
|
19
|
+
export declare function resolveFormIRMetadata(ir: FormIR, options: ResolveFormIRMetadataOptions): FormIR;
|
|
20
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/metadata/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,MAAM,EAEN,wBAAwB,EAExB,gBAAgB,EAIjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,yBAAyB,EACzB,mCAAmC,EACnC,wBAAwB,EACzB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACrC;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,MAAM,EAAE,wBAAwB,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;IAC3C,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AAkQD,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,qBAAqB,GAAG,SAAS,EAC3C,MAAM,EAAE,mCAAmC,EAC3C,OAAO,EAAE,yBAAyB,GACjC,gBAAgB,GAAG,SAAS,CAE9B;AAED,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,gBAAgB,GAAG,SAAS,EAC1C,eAAe,EAAE,gBAAgB,GAAG,SAAS,GAC5C,gBAAgB,GAAG,SAAS,CA8B9B;AAED,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,gBAAgB,GAAG,SAAS,GACrC,MAAM,CAER;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,gBAAgB,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAEzF;AAED,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,4BAA4B,GACpC,MAAM,CAoBR"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
/**
|
|
3
|
+
* Supported compiler context for static build-time analysis workflows.
|
|
4
|
+
*
|
|
5
|
+
* This context gives consumers access to the TypeScript program, checker, and
|
|
6
|
+
* source file used to discover declarations before invoking FormSpec schema
|
|
7
|
+
* generation helpers.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export interface StaticBuildContext {
|
|
12
|
+
/** Host-owned or FormSpec-created TypeScript program. */
|
|
13
|
+
readonly program: ts.Program;
|
|
14
|
+
/** TypeScript checker for symbol and type analysis. */
|
|
15
|
+
readonly checker: ts.TypeChecker;
|
|
16
|
+
/** Source file used as the entry module for export resolution. */
|
|
17
|
+
readonly sourceFile: ts.SourceFile;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates a supported static build context for a source file.
|
|
21
|
+
*
|
|
22
|
+
* @param filePath - Entry TypeScript source file used for export resolution
|
|
23
|
+
* @returns Reusable build context containing the program, checker, and source file
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare function createStaticBuildContext(filePath: string): StaticBuildContext;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a supported static build context from an existing host-owned program.
|
|
30
|
+
*
|
|
31
|
+
* @param program - Existing TypeScript program supplied by the caller
|
|
32
|
+
* @param filePath - Entry TypeScript source file used for export resolution
|
|
33
|
+
* @returns Reusable build context containing the program, checker, and source file
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export declare function createStaticBuildContextFromProgram(program: ts.Program, filePath: string): StaticBuildContext;
|
|
38
|
+
/**
|
|
39
|
+
* Resolves an export from the context source file, following aliases and re-exports.
|
|
40
|
+
*
|
|
41
|
+
* @param context - Static build context created for the entry source file
|
|
42
|
+
* @param exportName - Export name to resolve. Defaults to `"default"`.
|
|
43
|
+
* @returns Resolved symbol for the export, or `null` when it cannot be found
|
|
44
|
+
*
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveModuleExport(context: StaticBuildContext, exportName?: string): ts.Symbol | null;
|
|
48
|
+
/**
|
|
49
|
+
* Resolves the declaration behind an export from the context source file,
|
|
50
|
+
* following aliases and re-exports. This helper is intentionally limited to
|
|
51
|
+
* declaration kinds accepted by declaration-driven schema generation.
|
|
52
|
+
*
|
|
53
|
+
* @param context - Static build context created for the entry source file
|
|
54
|
+
* @param exportName - Export name to resolve. Defaults to `"default"`.
|
|
55
|
+
* @returns Resolved class, interface, or type-alias declaration for the export,
|
|
56
|
+
* or `null` when the export does not resolve to one of those schema-source kinds
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare function resolveModuleExportDeclaration(context: StaticBuildContext, exportName?: string): ts.ClassDeclaration | ts.InterfaceDeclaration | ts.TypeAliasDeclaration | null;
|
|
61
|
+
//# sourceMappingURL=static-build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-build.d.ts","sourceRoot":"","sources":["../src/static-build.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAOjC;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IACjC,yDAAyD;IACzD,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC;IAC7B,uDAAuD;IACvD,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC;IACjC,kEAAkE;IAClE,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC;CACpC;AAMD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,kBAAkB,CAE7E;AAED;;;;;;;;GAQG;AACH,wBAAgB,mCAAmC,CACjD,OAAO,EAAE,EAAE,CAAC,OAAO,EACnB,QAAQ,EAAE,MAAM,GACf,kBAAkB,CAEpB;AAiBD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,kBAAkB,EAC3B,UAAU,SAAY,GACrB,EAAE,CAAC,MAAM,GAAG,IAAI,CAiBlB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,kBAAkB,EAC3B,UAAU,SAAY,GACrB,EAAE,CAAC,gBAAgB,GAAG,EAAE,CAAC,oBAAoB,GAAG,EAAE,CAAC,oBAAoB,GAAG,IAAI,CAIhF"}
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* JSON Forms UI Schema generator for FormSpec forms.
|
|
3
|
+
*
|
|
4
|
+
* Routes through the canonical IR pipeline: Chain DSL → FormIR → UI Schema.
|
|
3
5
|
*/
|
|
4
|
-
import type { FormElement, FormSpec } from "@formspec/core";
|
|
6
|
+
import type { FormElement, FormSpec, MetadataPolicyInput } from "@formspec/core";
|
|
5
7
|
import type { UISchema } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Options for generating a UI Schema from a Chain DSL form.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export interface GenerateUiSchemaOptions {
|
|
14
|
+
/** Metadata resolution policy for chain DSL UI generation. */
|
|
15
|
+
readonly metadata?: MetadataPolicyInput | undefined;
|
|
16
|
+
}
|
|
6
17
|
/**
|
|
7
18
|
* Generates a JSON Forms UI Schema from a FormSpec.
|
|
8
19
|
*
|
|
20
|
+
* All generation routes through the canonical IR. The chain DSL is first
|
|
21
|
+
* canonicalized to a FormIR, then the IR-based generator produces the schema.
|
|
22
|
+
*
|
|
9
23
|
* @example
|
|
10
24
|
* ```typescript
|
|
11
25
|
* const form = formspec(
|
|
@@ -43,6 +57,8 @@ import type { UISchema } from "./types.js";
|
|
|
43
57
|
*
|
|
44
58
|
* @param form - The FormSpec to convert
|
|
45
59
|
* @returns A JSON Forms UI Schema
|
|
60
|
+
*
|
|
61
|
+
* @public
|
|
46
62
|
*/
|
|
47
|
-
export declare function generateUiSchema<E extends readonly FormElement[]>(form: FormSpec<E
|
|
63
|
+
export declare function generateUiSchema<E extends readonly FormElement[]>(form: FormSpec<E>, options?: GenerateUiSchemaOptions): UISchema;
|
|
48
64
|
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/ui-schema/generator.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/ui-schema/generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;CACrD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,SAAS,WAAW,EAAE,EAC/D,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EACjB,OAAO,CAAC,EAAE,uBAAuB,GAChC,QAAQ,CAMV"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Forms UI Schema generator that operates on the canonical FormIR.
|
|
3
|
+
*
|
|
4
|
+
* This generator consumes the IR produced by the Canonicalize phase and
|
|
5
|
+
* produces a JSON Forms UI Schema. All downstream UI Schema generation
|
|
6
|
+
* should use this module for UI Schema generation.
|
|
7
|
+
*/
|
|
8
|
+
import type { FormIR } from "@formspec/core/internals";
|
|
9
|
+
import type { UISchema } from "./types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Generates a JSON Forms UI Schema from a canonical `FormIR`.
|
|
12
|
+
*
|
|
13
|
+
* Mapping rules:
|
|
14
|
+
* - `FieldNode` → `ControlElement` with `scope: "#/properties/<name>"`
|
|
15
|
+
* - resolved `displayName` metadata → `label` on the `ControlElement`
|
|
16
|
+
* - `displayName` annotation → fallback `label` when metadata is absent
|
|
17
|
+
* - `GroupLayoutNode` → `GroupLayout` with recursively converted `elements`
|
|
18
|
+
* - `ConditionalLayoutNode` → children flattened with a `SHOW` rule
|
|
19
|
+
* - Nested conditionals → combined `allOf` rule
|
|
20
|
+
* - Root wrapper is always `{ type: "VerticalLayout", elements: [...] }`
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const ir = canonicalizeDSL(
|
|
25
|
+
* formspec(
|
|
26
|
+
* group("Customer", field.text("name", { label: "Name" })),
|
|
27
|
+
* when(is("status", "draft"), field.text("notes", { label: "Notes" })),
|
|
28
|
+
* )
|
|
29
|
+
* );
|
|
30
|
+
*
|
|
31
|
+
* const uiSchema = generateUiSchemaFromIR(ir);
|
|
32
|
+
* // {
|
|
33
|
+
* // type: "VerticalLayout",
|
|
34
|
+
* // elements: [
|
|
35
|
+
* // {
|
|
36
|
+
* // type: "Group",
|
|
37
|
+
* // label: "Customer",
|
|
38
|
+
* // elements: [{ type: "Control", scope: "#/properties/name", label: "Name" }]
|
|
39
|
+
* // },
|
|
40
|
+
* // {
|
|
41
|
+
* // type: "Control",
|
|
42
|
+
* // scope: "#/properties/notes",
|
|
43
|
+
* // label: "Notes",
|
|
44
|
+
* // rule: { effect: "SHOW", condition: { scope: "#/properties/status", schema: { const: "draft" } } }
|
|
45
|
+
* // }
|
|
46
|
+
* // ]
|
|
47
|
+
* // }
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @param ir - The canonical FormIR produced by the Canonicalize phase
|
|
51
|
+
* @returns A validated JSON Forms UI Schema
|
|
52
|
+
*/
|
|
53
|
+
export declare function generateUiSchemaFromIR(ir: FormIR): UISchema;
|
|
54
|
+
//# sourceMappingURL=ir-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ir-generator.d.ts","sourceRoot":"","sources":["../../src/ui-schema/ir-generator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAA6C,MAAM,0BAA0B,CAAC;AAGlG,OAAO,KAAK,EACV,QAAQ,EAMT,MAAM,YAAY,CAAC;AAqMpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,CAS3D"}
|