@formspec/build 0.1.0-alpha.5 → 0.1.0-alpha.50

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.
Files changed (119) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +238 -93
  3. package/dist/analyzer/class-analyzer.d.ts +135 -0
  4. package/dist/analyzer/class-analyzer.d.ts.map +1 -0
  5. package/dist/analyzer/jsdoc-constraints.d.ts +53 -0
  6. package/dist/analyzer/jsdoc-constraints.d.ts.map +1 -0
  7. package/dist/analyzer/program.d.ts +97 -0
  8. package/dist/analyzer/program.d.ts.map +1 -0
  9. package/dist/analyzer/tsdoc-parser.d.ts +124 -0
  10. package/dist/analyzer/tsdoc-parser.d.ts.map +1 -0
  11. package/dist/browser.cjs +2212 -0
  12. package/dist/browser.cjs.map +1 -0
  13. package/dist/browser.d.ts +74 -0
  14. package/dist/browser.d.ts.map +1 -0
  15. package/dist/browser.js +2167 -0
  16. package/dist/browser.js.map +1 -0
  17. package/dist/build-alpha.d.ts +2408 -0
  18. package/dist/build-beta.d.ts +2408 -0
  19. package/dist/build-internal.d.ts +2408 -0
  20. package/dist/build.d.ts +2209 -151
  21. package/dist/canonicalize/chain-dsl-canonicalizer.d.ts +22 -0
  22. package/dist/canonicalize/chain-dsl-canonicalizer.d.ts.map +1 -0
  23. package/dist/canonicalize/index.d.ts +8 -0
  24. package/dist/canonicalize/index.d.ts.map +1 -0
  25. package/dist/canonicalize/tsdoc-canonicalizer.d.ts +38 -0
  26. package/dist/canonicalize/tsdoc-canonicalizer.d.ts.map +1 -0
  27. package/dist/cli.cjs +7111 -0
  28. package/dist/cli.cjs.map +1 -0
  29. package/dist/cli.js +7070 -103
  30. package/dist/cli.js.map +1 -1
  31. package/dist/extensions/index.d.ts +8 -0
  32. package/dist/extensions/index.d.ts.map +1 -0
  33. package/dist/extensions/registry.d.ts +142 -0
  34. package/dist/extensions/registry.d.ts.map +1 -0
  35. package/dist/extensions/resolve-custom-type.d.ts +37 -0
  36. package/dist/extensions/resolve-custom-type.d.ts.map +1 -0
  37. package/dist/extensions/symbol-registry.d.ts +33 -0
  38. package/dist/extensions/symbol-registry.d.ts.map +1 -0
  39. package/dist/extensions/ts-type-utils.d.ts +40 -0
  40. package/dist/extensions/ts-type-utils.d.ts.map +1 -0
  41. package/dist/generators/class-schema.d.ts +392 -0
  42. package/dist/generators/class-schema.d.ts.map +1 -0
  43. package/dist/generators/discovered-schema.d.ts +152 -0
  44. package/dist/generators/discovered-schema.d.ts.map +1 -0
  45. package/dist/generators/method-schema.d.ts +72 -0
  46. package/dist/generators/method-schema.d.ts.map +1 -0
  47. package/dist/generators/mixed-authoring.d.ts +52 -0
  48. package/dist/generators/mixed-authoring.d.ts.map +1 -0
  49. package/dist/index.cjs +6786 -0
  50. package/dist/index.cjs.map +1 -0
  51. package/dist/index.d.ts +51 -8
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +6751 -107
  54. package/dist/index.js.map +1 -1
  55. package/dist/internals.cjs +5736 -0
  56. package/dist/internals.cjs.map +1 -0
  57. package/dist/internals.d.ts +32 -0
  58. package/dist/internals.d.ts.map +1 -0
  59. package/dist/internals.js +5706 -0
  60. package/dist/internals.js.map +1 -0
  61. package/dist/json-schema/generator.d.ts +32 -6
  62. package/dist/json-schema/generator.d.ts.map +1 -1
  63. package/dist/json-schema/ir-generator.d.ts +149 -0
  64. package/dist/json-schema/ir-generator.d.ts.map +1 -0
  65. package/dist/json-schema/schema.d.ts +23 -0
  66. package/dist/json-schema/schema.d.ts.map +1 -0
  67. package/dist/json-schema/types.d.ts +76 -2
  68. package/dist/json-schema/types.d.ts.map +1 -1
  69. package/dist/metadata/collision-guards.d.ts +3 -0
  70. package/dist/metadata/collision-guards.d.ts.map +1 -0
  71. package/dist/metadata/index.d.ts +7 -0
  72. package/dist/metadata/index.d.ts.map +1 -0
  73. package/dist/metadata/policy.d.ts +12 -0
  74. package/dist/metadata/policy.d.ts.map +1 -0
  75. package/dist/metadata/resolve.d.ts +21 -0
  76. package/dist/metadata/resolve.d.ts.map +1 -0
  77. package/dist/static-build.d.ts +61 -0
  78. package/dist/static-build.d.ts.map +1 -0
  79. package/dist/ui-schema/generator.d.ts +18 -2
  80. package/dist/ui-schema/generator.d.ts.map +1 -1
  81. package/dist/ui-schema/ir-generator.d.ts +54 -0
  82. package/dist/ui-schema/ir-generator.d.ts.map +1 -0
  83. package/dist/ui-schema/schema.d.ts +429 -0
  84. package/dist/ui-schema/schema.d.ts.map +1 -0
  85. package/dist/ui-schema/types.d.ts +179 -35
  86. package/dist/ui-schema/types.d.ts.map +1 -1
  87. package/dist/validate/constraint-validator.d.ts +85 -0
  88. package/dist/validate/constraint-validator.d.ts.map +1 -0
  89. package/dist/validate/index.d.ts +9 -0
  90. package/dist/validate/index.d.ts.map +1 -0
  91. package/package.json +30 -11
  92. package/dist/__tests__/cli.test.d.ts +0 -2
  93. package/dist/__tests__/cli.test.d.ts.map +0 -1
  94. package/dist/__tests__/cli.test.js +0 -178
  95. package/dist/__tests__/cli.test.js.map +0 -1
  96. package/dist/__tests__/edge-cases.test.d.ts +0 -7
  97. package/dist/__tests__/edge-cases.test.d.ts.map +0 -1
  98. package/dist/__tests__/edge-cases.test.js +0 -217
  99. package/dist/__tests__/edge-cases.test.js.map +0 -1
  100. package/dist/__tests__/generator.test.d.ts +0 -2
  101. package/dist/__tests__/generator.test.d.ts.map +0 -1
  102. package/dist/__tests__/generator.test.js +0 -234
  103. package/dist/__tests__/generator.test.js.map +0 -1
  104. package/dist/__tests__/integration.test.d.ts +0 -8
  105. package/dist/__tests__/integration.test.d.ts.map +0 -1
  106. package/dist/__tests__/integration.test.js +0 -163
  107. package/dist/__tests__/integration.test.js.map +0 -1
  108. package/dist/__tests__/write-schemas.test.d.ts +0 -2
  109. package/dist/__tests__/write-schemas.test.d.ts.map +0 -1
  110. package/dist/__tests__/write-schemas.test.js +0 -196
  111. package/dist/__tests__/write-schemas.test.js.map +0 -1
  112. package/dist/json-schema/generator.js +0 -167
  113. package/dist/json-schema/generator.js.map +0 -1
  114. package/dist/json-schema/types.js +0 -7
  115. package/dist/json-schema/types.js.map +0 -1
  116. package/dist/ui-schema/generator.js +0 -150
  117. package/dist/ui-schema/generator.js.map +0 -1
  118. package/dist/ui-schema/types.js +0 -8
  119. package/dist/ui-schema/types.js.map +0 -1
@@ -1,10 +1,34 @@
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
- import type { FormElement, FormSpec } from "@formspec/core";
5
- import type { JSONSchema7 } from "./types.js";
13
+ export interface GenerateJsonSchemaOptions {
14
+ /**
15
+ * Vendor prefix for emitted extension keywords.
16
+ * @defaultValue "x-formspec"
17
+ */
18
+ readonly vendorPrefix?: string | undefined;
19
+ /**
20
+ * JSON Schema representation to use for static enums.
21
+ * @defaultValue "enum"
22
+ */
23
+ readonly enumSerialization?: "enum" | "oneOf";
24
+ /** Metadata resolution policy for chain DSL generation. */
25
+ readonly metadata?: MetadataPolicyInput | undefined;
26
+ }
6
27
  /**
7
- * Generates a JSON Schema from a FormSpec.
28
+ * Generates a JSON Schema 2020-12 from a FormSpec.
29
+ *
30
+ * All generation routes through the canonical IR. The chain DSL is first
31
+ * canonicalized to a FormIR, then the IR-based generator produces the schema.
8
32
  *
9
33
  * @example
10
34
  * ```typescript
@@ -15,7 +39,7 @@ import type { JSONSchema7 } from "./types.js";
15
39
  *
16
40
  * const schema = generateJsonSchema(form);
17
41
  * // {
18
- * // $schema: "https://json-schema.org/draft-07/schema#",
42
+ * // $schema: "https://json-schema.org/draft/2020-12/schema",
19
43
  * // type: "object",
20
44
  * // properties: {
21
45
  * // name: { type: "string", title: "Name" },
@@ -26,7 +50,9 @@ import type { JSONSchema7 } from "./types.js";
26
50
  * ```
27
51
  *
28
52
  * @param form - The FormSpec to convert
29
- * @returns A JSON Schema object
53
+ * @returns A JSON Schema 2020-12 object
54
+ *
55
+ * @public
30
56
  */
31
- export declare function generateJsonSchema<E extends readonly FormElement[]>(form: FormSpec<E>): JSONSchema7;
57
+ export declare function generateJsonSchema<E extends readonly FormElement[]>(form: FormSpec<E>, options?: GenerateJsonSchemaOptions): JsonSchema2020;
32
58
  //# sourceMappingURL=generator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/json-schema/generator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,QAAQ,EAMT,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAgK9C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,SAAS,WAAW,EAAE,EACjE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,GAChB,WAAW,CAgBb"}
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;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9C,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,CAahB"}
@@ -0,0 +1,149 @@
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
+ * JSON Schema representation to use for static enums.
102
+ * @defaultValue "enum"
103
+ */
104
+ readonly enumSerialization?: "enum" | "oneOf" | undefined;
105
+ }
106
+ /**
107
+ * Generates a JSON Schema 2020-12 object from a canonical FormIR.
108
+ *
109
+ * Groups and conditionals are flattened — they influence UI layout but do not
110
+ * affect the data schema. All fields appear at the level they would occupy in
111
+ * the output data.
112
+ *
113
+ * Named types in the `typeRegistry` are emitted as `$defs` entries and
114
+ * referenced via `$ref` (per PP7 — high-fidelity output).
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * import { canonicalizeDSL } from "./canonicalize/index.js";
119
+ * import { generateJsonSchemaFromIR } from "./json-schema/ir-generator.js";
120
+ * import { formspec, field } from "@formspec/dsl";
121
+ *
122
+ * const form = formspec(
123
+ * field.text("name", { label: "Name", required: true }),
124
+ * field.number("age", { min: 0 }),
125
+ * );
126
+ * const ir = canonicalizeDSL(form);
127
+ * const schema = generateJsonSchemaFromIR(ir);
128
+ * // {
129
+ * // $schema: "https://json-schema.org/draft/2020-12/schema",
130
+ * // type: "object",
131
+ * // properties: {
132
+ * // name: { type: "string", title: "Name" },
133
+ * // age: { type: "number", minimum: 0 }
134
+ * // },
135
+ * // required: ["name"]
136
+ * // }
137
+ * ```
138
+ *
139
+ * Advanced API — most consumers should use `generateJsonSchema()` or
140
+ * `buildFormSchemas()`, which canonicalize form definitions automatically.
141
+ * Callers of this function are responsible for providing pre-canonicalized IR.
142
+ *
143
+ * @param ir - The canonical FormIR produced by a canonicalizer
144
+ * @returns A plain JSON-serializable JSON Schema 2020-12 object
145
+ *
146
+ * @internal
147
+ */
148
+ export declare function generateJsonSchemaFromIR(ir: FormIR, options?: GenerateJsonSchemaFromIROptions): JsonSchema2020;
149
+ //# 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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AS,CAAC,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,OAAO,CAAC;IAGrB,qDAAqD;IACrD,CAAC,GAAG,EAAE,KAAK,MAAM,EAAE,GAAG,OAAO,CAAC;CAC/B;AA2BD;;;;GAIG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;;;;OAKG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC3D;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CAC3D;AAmCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,wBAAwB,CACtC,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,+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 Draft-07 type definitions.
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 (draft-07 subset).
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;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,SAAS,GACT,QAAQ,GACR,OAAO,GACP,MAAM,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,W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E,MAAM,CAAC;CACpC;AAED;;;;GAIG;AACH,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,cAAc,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC;AAE/E;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,wBAAwB,CAAC;AAEzE;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,cAAc,MAAM,EAAE,EAC3B,KAAK,EAAE,OAAO,GACb,IAAI,CAEN;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,MAAM,EAAE,GAAG,OAAO,CAEvF"}
@@ -0,0 +1,3 @@
1
+ import type { FormIR } from "@formspec/core/internals";
2
+ export declare function assertNoSerializedNameCollisions(ir: FormIR): void;
3
+ //# sourceMappingURL=collision-guards.d.ts.map
@@ -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;AAsHlC,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,12 @@
1
+ import type { EnumMemberMetadataInferenceContext, MetadataAuthoringSurface, MetadataDeclarationKind, MetadataInferenceContext, MetadataPolicyInput, NormalizedDeclarationMetadataPolicy, NormalizedMetadataPolicy, NormalizedMetadataValuePolicy } from "@formspec/core/internals";
2
+ export type { NormalizedDeclarationMetadataPolicy, NormalizedEnumMemberDisplayNamePolicy, NormalizedEnumMemberMetadataPolicy, NormalizedMetadataPolicy, NormalizedMetadataPluralizationPolicy as NormalizedPluralizationPolicy, } from "@formspec/core/internals";
3
+ export type MetadataResolutionContext = MetadataInferenceContext;
4
+ export type EnumMemberResolutionContext = EnumMemberMetadataInferenceContext;
5
+ export type NormalizedMetadataScalarPolicy = NormalizedMetadataValuePolicy;
6
+ export declare function defaultApiNameInference(_context: MetadataResolutionContext): string;
7
+ export declare function defaultDisplayNameInference(_context: MetadataResolutionContext): string;
8
+ export declare function normalizeMetadataPolicy(input?: MetadataPolicyInput): NormalizedMetadataPolicy;
9
+ export declare function getDeclarationMetadataPolicy(policy: NormalizedMetadataPolicy, declarationKind: MetadataDeclarationKind): NormalizedDeclarationMetadataPolicy;
10
+ export declare function makeMetadataContext(surface: MetadataAuthoringSurface, declarationKind: MetadataDeclarationKind, logicalName: string, buildContext?: unknown): MetadataResolutionContext;
11
+ export declare function getDefaultMetadataPolicy(): NormalizedMetadataPolicy;
12
+ //# 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,EAEV,kCAAkC,EAClC,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EAGxB,mBAAmB,EAEnB,mCAAmC,EAGnC,wBAAwB,EAExB,6BAA6B,EAC9B,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,mCAAmC,EACnC,qCAAqC,EACrC,kCAAkC,EAClC,wBAAwB,EACxB,qCAAqC,IAAI,6BAA6B,GACvE,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,yBAAyB,GAAG,wBAAwB,CAAC;AACjE,MAAM,MAAM,2BAA2B,GAAG,kCAAkC,CAAC;AAC7E,MAAM,MAAM,8BAA8B,GAAG,6BAA6B,CAAC;AAE3E,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,yBAAyB,GAAG,MAAM,CAEnF;AAED,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,yBAAyB,GAAG,MAAM,CAEvF;AAgGD,wBAAgB,uBAAuB,CAAC,KAAK,CAAC,EAAE,mBAAmB,GAAG,wBAAwB,CAO7F;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,21 @@
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
+ readonly resolveRootTypeMetadata?: boolean;
15
+ }
16
+ export declare function resolveMetadata(explicit: ExplicitMetadataInput | undefined, policy: NormalizedDeclarationMetadataPolicy, context: MetadataResolutionContext): ResolvedMetadata | undefined;
17
+ export declare function mergeResolvedMetadata(baseMetadata: ResolvedMetadata | undefined, overlayMetadata: ResolvedMetadata | undefined): ResolvedMetadata | undefined;
18
+ export declare function getSerializedName(logicalName: string, metadata: ResolvedMetadata | undefined): string;
19
+ export declare function getDisplayName(metadata: ResolvedMetadata | undefined): string | undefined;
20
+ export declare function resolveFormIRMetadata(ir: FormIR, options: ResolveFormIRMetadataOptions): FormIR;
21
+ //# 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,EAGV,MAAM,EAEN,wBAAwB,EAExB,gBAAgB,EAIjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAEV,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;IAClC,QAAQ,CAAC,uBAAuB,CAAC,EAAE,OAAO,CAAC;CAC5C;AAoTD,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,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,4BAA4B,GAAG,MAAM,CAsB/F"}
@@ -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>): UISchema;
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;;GAEG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,QAAQ,EAGT,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAEV,QAAQ,EAIT,MAAM,YAAY,CAAC;AA2HpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,SAAS,WAAW,EAAE,EAC/D,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,GAChB,QAAQ,CAKV"}
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;AA6MpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,CAS3D"}