@formspec/build 0.1.0-alpha.2 → 0.1.0-alpha.21

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 (177) hide show
  1. package/README.md +120 -0
  2. package/dist/__tests__/alias-chain-propagation.test.d.ts +9 -0
  3. package/dist/__tests__/alias-chain-propagation.test.d.ts.map +1 -0
  4. package/dist/__tests__/chain-dsl-canonicalizer.test.d.ts +2 -0
  5. package/dist/__tests__/chain-dsl-canonicalizer.test.d.ts.map +1 -0
  6. package/dist/__tests__/class-schema.test.d.ts +2 -0
  7. package/dist/__tests__/class-schema.test.d.ts.map +1 -0
  8. package/dist/__tests__/constraint-validator.test.d.ts +2 -0
  9. package/dist/__tests__/constraint-validator.test.d.ts.map +1 -0
  10. package/dist/__tests__/date-extension.integration.test.d.ts +2 -0
  11. package/dist/__tests__/date-extension.integration.test.d.ts.map +1 -0
  12. package/dist/__tests__/extension-api.test.d.ts +2 -0
  13. package/dist/__tests__/extension-api.test.d.ts.map +1 -0
  14. package/dist/__tests__/extension-runtime.integration.test.d.ts +2 -0
  15. package/dist/__tests__/extension-runtime.integration.test.d.ts.map +1 -0
  16. package/dist/__tests__/fixtures/alias-chains.d.ts +37 -0
  17. package/dist/__tests__/fixtures/alias-chains.d.ts.map +1 -0
  18. package/dist/__tests__/fixtures/class-schema-regressions.d.ts +86 -0
  19. package/dist/__tests__/fixtures/class-schema-regressions.d.ts.map +1 -0
  20. package/dist/__tests__/fixtures/edge-cases.d.ts +132 -0
  21. package/dist/__tests__/fixtures/edge-cases.d.ts.map +1 -0
  22. package/dist/__tests__/fixtures/example-a-builtins.d.ts +31 -0
  23. package/dist/__tests__/fixtures/example-a-builtins.d.ts.map +1 -0
  24. package/dist/__tests__/fixtures/example-date-extension.d.ts +12 -0
  25. package/dist/__tests__/fixtures/example-date-extension.d.ts.map +1 -0
  26. package/dist/__tests__/fixtures/example-interface-types.d.ts +107 -0
  27. package/dist/__tests__/fixtures/example-interface-types.d.ts.map +1 -0
  28. package/dist/__tests__/fixtures/example-numeric-extension.d.ts +20 -0
  29. package/dist/__tests__/fixtures/example-numeric-extension.d.ts.map +1 -0
  30. package/dist/__tests__/fixtures/extension-forms.d.ts +7 -0
  31. package/dist/__tests__/fixtures/extension-forms.d.ts.map +1 -0
  32. package/dist/__tests__/fixtures/mixed-authoring-shipping-address.d.ts +31 -0
  33. package/dist/__tests__/fixtures/mixed-authoring-shipping-address.d.ts.map +1 -0
  34. package/dist/__tests__/fixtures/named-primitive-aliases.d.ts +15 -0
  35. package/dist/__tests__/fixtures/named-primitive-aliases.d.ts.map +1 -0
  36. package/dist/__tests__/fixtures/nested-array-path-constraints.d.ts +14 -0
  37. package/dist/__tests__/fixtures/nested-array-path-constraints.d.ts.map +1 -0
  38. package/dist/__tests__/fixtures/sample-forms.d.ts +65 -0
  39. package/dist/__tests__/fixtures/sample-forms.d.ts.map +1 -0
  40. package/dist/__tests__/generate-schemas.test.d.ts +2 -0
  41. package/dist/__tests__/generate-schemas.test.d.ts.map +1 -0
  42. package/dist/__tests__/guards.test.d.ts +2 -0
  43. package/dist/__tests__/guards.test.d.ts.map +1 -0
  44. package/dist/__tests__/ir-analyzer.test.d.ts +11 -0
  45. package/dist/__tests__/ir-analyzer.test.d.ts.map +1 -0
  46. package/dist/__tests__/ir-jsdoc-constraints.test.d.ts +12 -0
  47. package/dist/__tests__/ir-jsdoc-constraints.test.d.ts.map +1 -0
  48. package/dist/__tests__/ir-json-schema-generator.test.d.ts +11 -0
  49. package/dist/__tests__/ir-json-schema-generator.test.d.ts.map +1 -0
  50. package/dist/__tests__/ir-ui-schema-generator.test.d.ts +2 -0
  51. package/dist/__tests__/ir-ui-schema-generator.test.d.ts.map +1 -0
  52. package/dist/__tests__/mixed-authoring.test.d.ts +2 -0
  53. package/dist/__tests__/mixed-authoring.test.d.ts.map +1 -0
  54. package/dist/__tests__/numeric-extension.integration.test.d.ts +2 -0
  55. package/dist/__tests__/numeric-extension.integration.test.d.ts.map +1 -0
  56. package/dist/__tests__/parity/fixtures/address/chain-dsl.d.ts +9 -0
  57. package/dist/__tests__/parity/fixtures/address/chain-dsl.d.ts.map +1 -0
  58. package/dist/__tests__/parity/fixtures/address/expected-ir.d.ts +9 -0
  59. package/dist/__tests__/parity/fixtures/address/expected-ir.d.ts.map +1 -0
  60. package/dist/__tests__/parity/fixtures/address/tsdoc.d.ts +19 -0
  61. package/dist/__tests__/parity/fixtures/address/tsdoc.d.ts.map +1 -0
  62. package/dist/__tests__/parity/fixtures/plan-status/chain-dsl.d.ts +19 -0
  63. package/dist/__tests__/parity/fixtures/plan-status/chain-dsl.d.ts.map +1 -0
  64. package/dist/__tests__/parity/fixtures/plan-status/expected-ir.d.ts +6 -0
  65. package/dist/__tests__/parity/fixtures/plan-status/expected-ir.d.ts.map +1 -0
  66. package/dist/__tests__/parity/fixtures/plan-status/tsdoc.d.ts +17 -0
  67. package/dist/__tests__/parity/fixtures/plan-status/tsdoc.d.ts.map +1 -0
  68. package/dist/__tests__/parity/fixtures/product-config/chain-dsl.d.ts +13 -0
  69. package/dist/__tests__/parity/fixtures/product-config/chain-dsl.d.ts.map +1 -0
  70. package/dist/__tests__/parity/fixtures/product-config/expected-ir.d.ts +9 -0
  71. package/dist/__tests__/parity/fixtures/product-config/expected-ir.d.ts.map +1 -0
  72. package/dist/__tests__/parity/fixtures/product-config/tsdoc.d.ts +28 -0
  73. package/dist/__tests__/parity/fixtures/product-config/tsdoc.d.ts.map +1 -0
  74. package/dist/__tests__/parity/fixtures/usd-cents/chain-dsl.d.ts +9 -0
  75. package/dist/__tests__/parity/fixtures/usd-cents/chain-dsl.d.ts.map +1 -0
  76. package/dist/__tests__/parity/fixtures/usd-cents/expected-ir.d.ts +6 -0
  77. package/dist/__tests__/parity/fixtures/usd-cents/expected-ir.d.ts.map +1 -0
  78. package/dist/__tests__/parity/fixtures/usd-cents/tsdoc.d.ts +19 -0
  79. package/dist/__tests__/parity/fixtures/usd-cents/tsdoc.d.ts.map +1 -0
  80. package/dist/__tests__/parity/fixtures/user-registration/chain-dsl.d.ts +12 -0
  81. package/dist/__tests__/parity/fixtures/user-registration/chain-dsl.d.ts.map +1 -0
  82. package/dist/__tests__/parity/fixtures/user-registration/expected-ir.d.ts +9 -0
  83. package/dist/__tests__/parity/fixtures/user-registration/expected-ir.d.ts.map +1 -0
  84. package/dist/__tests__/parity/fixtures/user-registration/tsdoc.d.ts +19 -0
  85. package/dist/__tests__/parity/fixtures/user-registration/tsdoc.d.ts.map +1 -0
  86. package/dist/__tests__/parity/parity.test.d.ts +18 -0
  87. package/dist/__tests__/parity/parity.test.d.ts.map +1 -0
  88. package/dist/__tests__/parity/utils.d.ts +152 -0
  89. package/dist/__tests__/parity/utils.d.ts.map +1 -0
  90. package/dist/__tests__/path-target-parser.test.d.ts +9 -0
  91. package/dist/__tests__/path-target-parser.test.d.ts.map +1 -0
  92. package/dist/analyzer/class-analyzer.d.ts +100 -0
  93. package/dist/analyzer/class-analyzer.d.ts.map +1 -0
  94. package/dist/analyzer/jsdoc-constraints.d.ts +53 -0
  95. package/dist/analyzer/jsdoc-constraints.d.ts.map +1 -0
  96. package/dist/analyzer/program.d.ts +68 -0
  97. package/dist/analyzer/program.d.ts.map +1 -0
  98. package/dist/analyzer/tsdoc-parser.d.ts +123 -0
  99. package/dist/analyzer/tsdoc-parser.d.ts.map +1 -0
  100. package/dist/browser.cjs +1294 -0
  101. package/dist/browser.cjs.map +1 -0
  102. package/dist/browser.d.ts +73 -0
  103. package/dist/browser.d.ts.map +1 -0
  104. package/dist/browser.js +1245 -0
  105. package/dist/browser.js.map +1 -0
  106. package/dist/build.d.ts +1144 -0
  107. package/dist/canonicalize/chain-dsl-canonicalizer.d.ts +18 -0
  108. package/dist/canonicalize/chain-dsl-canonicalizer.d.ts.map +1 -0
  109. package/dist/canonicalize/index.d.ts +8 -0
  110. package/dist/canonicalize/index.d.ts.map +1 -0
  111. package/dist/canonicalize/tsdoc-canonicalizer.d.ts +34 -0
  112. package/dist/canonicalize/tsdoc-canonicalizer.d.ts.map +1 -0
  113. package/dist/cli.cjs +3859 -0
  114. package/dist/cli.cjs.map +1 -0
  115. package/dist/cli.js +3823 -103
  116. package/dist/cli.js.map +1 -1
  117. package/dist/extensions/index.d.ts +8 -0
  118. package/dist/extensions/index.d.ts.map +1 -0
  119. package/dist/extensions/registry.d.ts +83 -0
  120. package/dist/extensions/registry.d.ts.map +1 -0
  121. package/dist/generators/class-schema.d.ts +111 -0
  122. package/dist/generators/class-schema.d.ts.map +1 -0
  123. package/dist/generators/method-schema.d.ts +65 -0
  124. package/dist/generators/method-schema.d.ts.map +1 -0
  125. package/dist/generators/mixed-authoring.d.ts +51 -0
  126. package/dist/generators/mixed-authoring.d.ts.map +1 -0
  127. package/dist/index.cjs +3624 -0
  128. package/dist/index.cjs.map +1 -0
  129. package/dist/index.d.ts +45 -8
  130. package/dist/index.d.ts.map +1 -1
  131. package/dist/index.js +3584 -106
  132. package/dist/index.js.map +1 -1
  133. package/dist/internals.cjs +3368 -0
  134. package/dist/internals.cjs.map +1 -0
  135. package/dist/internals.d.ts +30 -0
  136. package/dist/internals.d.ts.map +1 -0
  137. package/dist/internals.js +3342 -0
  138. package/dist/internals.js.map +1 -0
  139. package/dist/json-schema/generator.d.ts +20 -5
  140. package/dist/json-schema/generator.d.ts.map +1 -1
  141. package/dist/json-schema/ir-generator.d.ts +114 -0
  142. package/dist/json-schema/ir-generator.d.ts.map +1 -0
  143. package/dist/json-schema/schema.d.ts +23 -0
  144. package/dist/json-schema/schema.d.ts.map +1 -0
  145. package/dist/json-schema/types.d.ts +45 -2
  146. package/dist/json-schema/types.d.ts.map +1 -1
  147. package/dist/ui-schema/generator.d.ts +7 -0
  148. package/dist/ui-schema/generator.d.ts.map +1 -1
  149. package/dist/ui-schema/ir-generator.d.ts +53 -0
  150. package/dist/ui-schema/ir-generator.d.ts.map +1 -0
  151. package/dist/ui-schema/schema.d.ts +434 -0
  152. package/dist/ui-schema/schema.d.ts.map +1 -0
  153. package/dist/ui-schema/types.d.ts +10 -73
  154. package/dist/ui-schema/types.d.ts.map +1 -1
  155. package/dist/validate/constraint-validator.d.ts +23 -0
  156. package/dist/validate/constraint-validator.d.ts.map +1 -0
  157. package/dist/validate/index.d.ts +9 -0
  158. package/dist/validate/index.d.ts.map +1 -0
  159. package/package.json +27 -7
  160. package/dist/__tests__/cli.test.js +0 -178
  161. package/dist/__tests__/cli.test.js.map +0 -1
  162. package/dist/__tests__/edge-cases.test.js +0 -217
  163. package/dist/__tests__/edge-cases.test.js.map +0 -1
  164. package/dist/__tests__/generator.test.js +0 -225
  165. package/dist/__tests__/generator.test.js.map +0 -1
  166. package/dist/__tests__/integration.test.js +0 -163
  167. package/dist/__tests__/integration.test.js.map +0 -1
  168. package/dist/__tests__/write-schemas.test.js +0 -196
  169. package/dist/__tests__/write-schemas.test.js.map +0 -1
  170. package/dist/json-schema/generator.js +0 -161
  171. package/dist/json-schema/generator.js.map +0 -1
  172. package/dist/json-schema/types.js +0 -7
  173. package/dist/json-schema/types.js.map +0 -1
  174. package/dist/ui-schema/generator.js +0 -150
  175. package/dist/ui-schema/generator.js.map +0 -1
  176. package/dist/ui-schema/types.js +0 -8
  177. package/dist/ui-schema/types.js.map +0 -1
@@ -0,0 +1,1144 @@
1
+ /**
2
+ * `@formspec/build` - Build tools for FormSpec
3
+ *
4
+ * This package provides generators to compile FormSpec forms into:
5
+ * - JSON Schema 2020-12 (for validation)
6
+ * - JSON Forms UI Schema (for rendering)
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { buildFormSchemas } from "@formspec/build";
11
+ * import { formspec, field, group } from "@formspec/dsl";
12
+ *
13
+ * const form = formspec(
14
+ * group("Customer",
15
+ * field.text("name", { label: "Name", required: true }),
16
+ * field.text("email", { label: "Email" }),
17
+ * ),
18
+ * );
19
+ *
20
+ * const { jsonSchema, uiSchema } = buildFormSchemas(form);
21
+ * ```
22
+ *
23
+ * @packageDocumentation
24
+ */
25
+
26
+ import type { BuiltinConstraintBroadeningRegistration } from '@formspec/core';
27
+ import type { ConstraintTagRegistration } from '@formspec/core';
28
+ import type { CustomAnnotationRegistration } from '@formspec/core';
29
+ import type { CustomConstraintRegistration } from '@formspec/core';
30
+ import type { CustomTypeRegistration } from '@formspec/core';
31
+ import type { ExtensionDefinition } from '@formspec/core';
32
+ import type { FormElement } from '@formspec/core';
33
+ import type { FormIR } from '@formspec/core';
34
+ import type { FormSpec } from '@formspec/core';
35
+ import type { JsonValue } from '@formspec/core';
36
+ import { z } from 'zod';
37
+
38
+ /**
39
+ * Builds both JSON Schema and UI Schema from a FormSpec.
40
+ *
41
+ * This is a convenience function that combines `generateJsonSchema`
42
+ * and `generateUiSchema`.
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * const form = formspec(
47
+ * field.text("name", { required: true }),
48
+ * field.number("age", { min: 0 }),
49
+ * );
50
+ *
51
+ * const { jsonSchema, uiSchema } = buildFormSchemas(form);
52
+ *
53
+ * // Use with JSON Forms renderer
54
+ * <JsonForms
55
+ * schema={jsonSchema}
56
+ * uischema={uiSchema}
57
+ * data={formData}
58
+ * renderers={materialRenderers}
59
+ * />
60
+ * ```
61
+ *
62
+ * @param form - The FormSpec to build schemas from
63
+ * @returns Object containing both jsonSchema and uiSchema
64
+ *
65
+ * @public
66
+ */
67
+ export declare function buildFormSchemas<E extends readonly FormElement[]>(form: FormSpec<E>, options?: BuildFormSchemasOptions): BuildResult;
68
+
69
+ /**
70
+ * Options for building schemas from a FormSpec.
71
+ *
72
+ * Currently identical to `GenerateJsonSchemaOptions`. Defined separately so the
73
+ * Chain DSL surface can grow independently in the future if needed.
74
+ *
75
+ * @public
76
+ */
77
+ export declare type BuildFormSchemasOptions = GenerateJsonSchemaOptions;
78
+
79
+ /**
80
+ * Builds JSON Schema and UI Schema from a TSDoc-derived model with ChainDSL
81
+ * field overlays.
82
+ *
83
+ * Overlays are matched by field name. The static model wins for structure,
84
+ * ordering, and constraints; ChainDSL overlays may contribute dynamic runtime
85
+ * field metadata such as dynamic enum or dynamic schema keywords, and may fill
86
+ * in missing annotations.
87
+ *
88
+ * @public
89
+ */
90
+ export declare function buildMixedAuthoringSchemas(options: BuildMixedAuthoringSchemasOptions): MixedAuthoringSchemas;
91
+
92
+ /**
93
+ * Options for generating mixed-authoring schemas.
94
+ *
95
+ * The `typeName` can resolve to a class, interface, or object type alias, just
96
+ * like `generateSchemas()`.
97
+ *
98
+ * @public
99
+ */
100
+ export declare interface BuildMixedAuthoringSchemasOptions extends GenerateJsonSchemaFromIROptions {
101
+ /** Path to the TypeScript source file. */
102
+ readonly filePath: string;
103
+ /** Name of the class, interface, or type alias to analyze. */
104
+ readonly typeName: string;
105
+ /** ChainDSL overlays to apply to the static model. Groups and conditionals are flattened by field name. */
106
+ readonly overlays: FormSpec<readonly FormElement[]>;
107
+ }
108
+
109
+ /**
110
+ * Result of building form schemas.
111
+ *
112
+ * @public
113
+ */
114
+ export declare interface BuildResult {
115
+ /** JSON Schema 2020-12 for validation */
116
+ readonly jsonSchema: JsonSchema2020;
117
+ /** JSON Forms UI Schema for rendering */
118
+ readonly uiSchema: UISchema;
119
+ }
120
+
121
+ /**
122
+ * A Categorization element (tab-based layout).
123
+ *
124
+ * @public
125
+ */
126
+ export declare interface Categorization {
127
+ type: "Categorization";
128
+ elements: Category[];
129
+ label?: string | undefined;
130
+ rule?: Rule | undefined;
131
+ options?: Record<string, unknown> | undefined;
132
+ [k: string]: unknown;
133
+ }
134
+
135
+ /**
136
+ * Zod schema for a categorization element.
137
+ *
138
+ * @public
139
+ */
140
+ export declare const categorizationSchema: z.ZodType<Categorization>;
141
+
142
+ /**
143
+ * A Category element, used inside a Categorization layout.
144
+ *
145
+ * @public
146
+ */
147
+ export declare interface Category {
148
+ type: "Category";
149
+ label: string;
150
+ elements: UISchemaElement[];
151
+ rule?: Rule | undefined;
152
+ options?: Record<string, unknown> | undefined;
153
+ [k: string]: unknown;
154
+ }
155
+
156
+ /**
157
+ * Zod schema for a category element.
158
+ *
159
+ * @public
160
+ */
161
+ export declare const categorySchema: z.ZodType<Category>;
162
+
163
+ /**
164
+ * Generated schemas for a class.
165
+ *
166
+ * @public
167
+ */
168
+ export declare interface ClassSchemas {
169
+ /** JSON Schema 2020-12 for validation */
170
+ jsonSchema: JsonSchema2020;
171
+ /** JSON Forms UI Schema for rendering */
172
+ uiSchema: UISchema;
173
+ }
174
+
175
+ /**
176
+ * A Control element that binds to a JSON Schema property.
177
+ *
178
+ * @public
179
+ */
180
+ export declare type ControlElement = z.infer<typeof controlSchema>;
181
+
182
+ /**
183
+ * Zod schema for a Control element.
184
+ *
185
+ * @public
186
+ */
187
+ export declare const controlSchema: z.ZodObject<{
188
+ type: z.ZodLiteral<"Control">;
189
+ scope: z.ZodString;
190
+ label: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodLiteral<false>]>>;
191
+ rule: z.ZodOptional<z.ZodObject<{
192
+ effect: z.ZodEnum<["SHOW", "HIDE", "ENABLE", "DISABLE"]>;
193
+ condition: z.ZodObject<{
194
+ scope: z.ZodString;
195
+ schema: z.ZodType<RuleConditionSchema, z.ZodTypeDef, RuleConditionSchema>;
196
+ }, "strict", z.ZodTypeAny, {
197
+ schema: RuleConditionSchema;
198
+ scope: string;
199
+ }, {
200
+ schema: RuleConditionSchema;
201
+ scope: string;
202
+ }>;
203
+ }, "strict", z.ZodTypeAny, {
204
+ condition: {
205
+ schema: RuleConditionSchema;
206
+ scope: string;
207
+ };
208
+ effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
209
+ }, {
210
+ condition: {
211
+ schema: RuleConditionSchema;
212
+ scope: string;
213
+ };
214
+ effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
215
+ }>>;
216
+ options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
217
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
218
+ type: z.ZodLiteral<"Control">;
219
+ scope: z.ZodString;
220
+ label: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodLiteral<false>]>>;
221
+ rule: z.ZodOptional<z.ZodObject<{
222
+ effect: z.ZodEnum<["SHOW", "HIDE", "ENABLE", "DISABLE"]>;
223
+ condition: z.ZodObject<{
224
+ scope: z.ZodString;
225
+ schema: z.ZodType<RuleConditionSchema, z.ZodTypeDef, RuleConditionSchema>;
226
+ }, "strict", z.ZodTypeAny, {
227
+ schema: RuleConditionSchema;
228
+ scope: string;
229
+ }, {
230
+ schema: RuleConditionSchema;
231
+ scope: string;
232
+ }>;
233
+ }, "strict", z.ZodTypeAny, {
234
+ condition: {
235
+ schema: RuleConditionSchema;
236
+ scope: string;
237
+ };
238
+ effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
239
+ }, {
240
+ condition: {
241
+ schema: RuleConditionSchema;
242
+ scope: string;
243
+ };
244
+ effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
245
+ }>>;
246
+ options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
247
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
248
+ type: z.ZodLiteral<"Control">;
249
+ scope: z.ZodString;
250
+ label: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodLiteral<false>]>>;
251
+ rule: z.ZodOptional<z.ZodObject<{
252
+ effect: z.ZodEnum<["SHOW", "HIDE", "ENABLE", "DISABLE"]>;
253
+ condition: z.ZodObject<{
254
+ scope: z.ZodString;
255
+ schema: z.ZodType<RuleConditionSchema, z.ZodTypeDef, RuleConditionSchema>;
256
+ }, "strict", z.ZodTypeAny, {
257
+ schema: RuleConditionSchema;
258
+ scope: string;
259
+ }, {
260
+ schema: RuleConditionSchema;
261
+ scope: string;
262
+ }>;
263
+ }, "strict", z.ZodTypeAny, {
264
+ condition: {
265
+ schema: RuleConditionSchema;
266
+ scope: string;
267
+ };
268
+ effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
269
+ }, {
270
+ condition: {
271
+ schema: RuleConditionSchema;
272
+ scope: string;
273
+ };
274
+ effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
275
+ }>>;
276
+ options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
277
+ }, z.ZodTypeAny, "passthrough">>;
278
+
279
+ /**
280
+ * Creates an extension registry from a list of extension definitions.
281
+ *
282
+ * The registry indexes all types, constraints, and annotations by their
283
+ * fully-qualified IDs (`<extensionId>/<name>`) for O(1) lookup during
284
+ * generation and validation.
285
+ *
286
+ * @param extensions - The extension definitions to register.
287
+ * @returns An {@link ExtensionRegistry} instance.
288
+ * @throws If duplicate type/constraint/annotation IDs are detected across extensions.
289
+ *
290
+ * @public
291
+ */
292
+ export declare function createExtensionRegistry(extensions: readonly ExtensionDefinition[]): ExtensionRegistry;
293
+
294
+ /**
295
+ * JSON Schema with FormSpec extension properties for arbitrary `x-formspec-*` keys.
296
+ *
297
+ * @public
298
+ */
299
+ export declare type ExtendedJSONSchema7 = JSONSchema7 & FormSpecSchemaExtensions;
300
+
301
+ /**
302
+ * A registry of extensions that provides lookup by fully-qualified ID.
303
+ *
304
+ * Type IDs follow the format: `<extensionId>/<typeName>`
305
+ * Constraint IDs follow the format: `<extensionId>/<constraintName>`
306
+ * Annotation IDs follow the format: `<extensionId>/<annotationName>`
307
+ *
308
+ * @public
309
+ */
310
+ export declare interface ExtensionRegistry {
311
+ /** The extensions registered in this registry (in registration order). */
312
+ readonly extensions: readonly ExtensionDefinition[];
313
+ /**
314
+ * Look up a custom type registration by its fully-qualified type ID.
315
+ *
316
+ * @param typeId - The fully-qualified type ID (e.g., "x-stripe/monetary/Decimal").
317
+ * @returns The registration if found, otherwise `undefined`.
318
+ */
319
+ findType(typeId: string): CustomTypeRegistration | undefined;
320
+ /**
321
+ * Look up a custom type registration by a TypeScript-facing type name.
322
+ *
323
+ * This is used during TSDoc/class analysis to resolve extension-defined
324
+ * custom types from source-level declarations.
325
+ */
326
+ findTypeByName(typeName: string): {
327
+ readonly extensionId: string;
328
+ readonly registration: CustomTypeRegistration;
329
+ } | undefined;
330
+ /**
331
+ * Look up a custom constraint registration by its fully-qualified constraint ID.
332
+ *
333
+ * @param constraintId - The fully-qualified constraint ID.
334
+ * @returns The registration if found, otherwise `undefined`.
335
+ */
336
+ findConstraint(constraintId: string): CustomConstraintRegistration | undefined;
337
+ /**
338
+ * Look up a TSDoc custom constraint-tag registration by tag name.
339
+ */
340
+ findConstraintTag(tagName: string): {
341
+ readonly extensionId: string;
342
+ readonly registration: ConstraintTagRegistration;
343
+ } | undefined;
344
+ /**
345
+ * Look up built-in tag broadening for a given custom type ID.
346
+ */
347
+ findBuiltinConstraintBroadening(typeId: string, tagName: string): {
348
+ readonly extensionId: string;
349
+ readonly registration: BuiltinConstraintBroadeningRegistration;
350
+ } | undefined;
351
+ /**
352
+ * Look up a custom annotation registration by its fully-qualified annotation ID.
353
+ *
354
+ * @param annotationId - The fully-qualified annotation ID.
355
+ * @returns The registration if found, otherwise `undefined`.
356
+ */
357
+ findAnnotation(annotationId: string): CustomAnnotationRegistration | undefined;
358
+ }
359
+
360
+ /**
361
+ * Extension properties for custom FormSpec constraint tags.
362
+ *
363
+ * @public
364
+ */
365
+ export declare type FormSpecSchemaExtensions = Record<`x-formspec-${string}`, unknown>;
366
+
367
+ /**
368
+ * Options for generating schemas from a decorated class.
369
+ *
370
+ * @public
371
+ */
372
+ export declare interface GenerateFromClassOptions extends GenerateJsonSchemaFromIROptions {
373
+ /** Path to the TypeScript source file */
374
+ filePath: string;
375
+ /** Class name to analyze */
376
+ className: string;
377
+ }
378
+
379
+ /**
380
+ * Result of generating schemas from a decorated class.
381
+ *
382
+ * @public
383
+ */
384
+ export declare interface GenerateFromClassResult {
385
+ /** JSON Schema 2020-12 for validation */
386
+ jsonSchema: JsonSchema2020;
387
+ /** JSON Forms UI Schema for rendering */
388
+ uiSchema: UISchema;
389
+ }
390
+
391
+ /**
392
+ * Generates a JSON Schema 2020-12 from a FormSpec.
393
+ *
394
+ * All generation routes through the canonical IR. The chain DSL is first
395
+ * canonicalized to a FormIR, then the IR-based generator produces the schema.
396
+ *
397
+ * @example
398
+ * ```typescript
399
+ * const form = formspec(
400
+ * field.text("name", { label: "Name", required: true }),
401
+ * field.number("age", { min: 0 }),
402
+ * );
403
+ *
404
+ * const schema = generateJsonSchema(form);
405
+ * // {
406
+ * // $schema: "https://json-schema.org/draft/2020-12/schema",
407
+ * // type: "object",
408
+ * // properties: {
409
+ * // name: { type: "string", title: "Name" },
410
+ * // age: { type: "number", minimum: 0 }
411
+ * // },
412
+ * // required: ["name"]
413
+ * // }
414
+ * ```
415
+ *
416
+ * @param form - The FormSpec to convert
417
+ * @returns A JSON Schema 2020-12 object
418
+ *
419
+ * @public
420
+ */
421
+ export declare function generateJsonSchema<E extends readonly FormElement[]>(form: FormSpec<E>, options?: GenerateJsonSchemaOptions): JsonSchema2020;
422
+
423
+ /**
424
+ * Generates a JSON Schema 2020-12 object from a canonical FormIR.
425
+ *
426
+ * Groups and conditionals are flattened — they influence UI layout but do not
427
+ * affect the data schema. All fields appear at the level they would occupy in
428
+ * the output data.
429
+ *
430
+ * Named types in the `typeRegistry` are emitted as `$defs` entries and
431
+ * referenced via `$ref` (per PP7 — high-fidelity output).
432
+ *
433
+ * @example
434
+ * ```typescript
435
+ * import { canonicalizeDSL } from "./canonicalize/index.js";
436
+ * import { generateJsonSchemaFromIR } from "./json-schema/ir-generator.js";
437
+ * import { formspec, field } from "@formspec/dsl";
438
+ *
439
+ * const form = formspec(
440
+ * field.text("name", { label: "Name", required: true }),
441
+ * field.number("age", { min: 0 }),
442
+ * );
443
+ * const ir = canonicalizeDSL(form);
444
+ * const schema = generateJsonSchemaFromIR(ir);
445
+ * // {
446
+ * // $schema: "https://json-schema.org/draft/2020-12/schema",
447
+ * // type: "object",
448
+ * // properties: {
449
+ * // name: { type: "string", title: "Name" },
450
+ * // age: { type: "number", minimum: 0 }
451
+ * // },
452
+ * // required: ["name"]
453
+ * // }
454
+ * ```
455
+ *
456
+ * Advanced API — most consumers should use `generateJsonSchema()` or
457
+ * `buildFormSchemas()`, which canonicalize form definitions automatically.
458
+ * Callers of this function are responsible for providing pre-canonicalized IR.
459
+ *
460
+ * @param ir - The canonical FormIR produced by a canonicalizer
461
+ * @returns A plain JSON-serializable JSON Schema 2020-12 object
462
+ *
463
+ * @public
464
+ */
465
+ export declare function generateJsonSchemaFromIR(ir: FormIR, options?: GenerateJsonSchemaFromIROptions): JsonSchema2020;
466
+
467
+ /**
468
+ * Options for generating JSON Schema from a canonical FormIR.
469
+ *
470
+ * @public
471
+ */
472
+ export declare interface GenerateJsonSchemaFromIROptions {
473
+ /**
474
+ * Registry used to resolve custom types, constraints, and annotations.
475
+ *
476
+ * JSON Schema generation throws when custom IR nodes are present without a
477
+ * matching registration in this registry.
478
+ */
479
+ readonly extensionRegistry?: ExtensionRegistry | undefined;
480
+ /**
481
+ * Vendor prefix passed to extension `toJsonSchema` hooks.
482
+ * @defaultValue "x-formspec"
483
+ */
484
+ readonly vendorPrefix?: string | undefined;
485
+ }
486
+
487
+ /**
488
+ * Options for generating JSON Schema from a Chain DSL form.
489
+ *
490
+ * These options are forwarded to the IR-based JSON Schema generator.
491
+ *
492
+ * @public
493
+ */
494
+ export declare type GenerateJsonSchemaOptions = GenerateJsonSchemaFromIROptions;
495
+
496
+ /**
497
+ * Generates JSON Schema and UI Schema from a named TypeScript
498
+ * type — a decorated class, an interface with TSDoc tags, or a type alias.
499
+ *
500
+ * This is the recommended entry point. It automatically detects whether
501
+ * the name resolves to a class, interface, or type alias and uses the
502
+ * appropriate IR analysis pipeline.
503
+ *
504
+ * @example
505
+ * ```typescript
506
+ * const result = generateSchemas({
507
+ * filePath: "./src/config.ts",
508
+ * typeName: "DiscountConfig",
509
+ * });
510
+ * ```
511
+ *
512
+ * @param options - File path and type name
513
+ * @returns Generated JSON Schema and UI Schema
514
+ *
515
+ * @public
516
+ */
517
+ export declare function generateSchemas(options: GenerateSchemasOptions): GenerateFromClassResult;
518
+
519
+ /**
520
+ * Generates JSON Schema and UI Schema from a decorated TypeScript class.
521
+ *
522
+ * This is a high-level entry point that handles the entire pipeline:
523
+ * creating a TypeScript program, finding the class, analyzing it to IR,
524
+ * and generating schemas — all in one call.
525
+ *
526
+ * @example
527
+ * ```typescript
528
+ * const result = generateSchemasFromClass({
529
+ * filePath: "./src/forms.ts",
530
+ * className: "UserForm",
531
+ * });
532
+ * console.log(result.jsonSchema);
533
+ * ```
534
+ *
535
+ * @param options - File path, class name, and optional compiler options
536
+ * @returns Generated JSON Schema and UI Schema
537
+ *
538
+ * @public
539
+ */
540
+ export declare function generateSchemasFromClass(options: GenerateFromClassOptions): GenerateFromClassResult;
541
+
542
+ /**
543
+ * Options for generating schemas from a named type (class, interface, or type alias).
544
+ *
545
+ * @public
546
+ */
547
+ export declare interface GenerateSchemasOptions extends GenerateJsonSchemaFromIROptions {
548
+ /** Path to the TypeScript source file */
549
+ filePath: string;
550
+ /** Name of the exported class, interface, or type alias to analyze */
551
+ typeName: string;
552
+ }
553
+
554
+ /**
555
+ * Generates a JSON Forms UI Schema from a FormSpec.
556
+ *
557
+ * All generation routes through the canonical IR. The chain DSL is first
558
+ * canonicalized to a FormIR, then the IR-based generator produces the schema.
559
+ *
560
+ * @example
561
+ * ```typescript
562
+ * const form = formspec(
563
+ * group("Customer",
564
+ * field.text("name", { label: "Name" }),
565
+ * ),
566
+ * when("status", "draft",
567
+ * field.text("notes", { label: "Notes" }),
568
+ * ),
569
+ * );
570
+ *
571
+ * const uiSchema = generateUiSchema(form);
572
+ * // {
573
+ * // type: "VerticalLayout",
574
+ * // elements: [
575
+ * // {
576
+ * // type: "Group",
577
+ * // label: "Customer",
578
+ * // elements: [
579
+ * // { type: "Control", scope: "#/properties/name", label: "Name" }
580
+ * // ]
581
+ * // },
582
+ * // {
583
+ * // type: "Control",
584
+ * // scope: "#/properties/notes",
585
+ * // label: "Notes",
586
+ * // rule: {
587
+ * // effect: "SHOW",
588
+ * // condition: { scope: "#/properties/status", schema: { const: "draft" } }
589
+ * // }
590
+ * // }
591
+ * // ]
592
+ * // }
593
+ * ```
594
+ *
595
+ * @param form - The FormSpec to convert
596
+ * @returns A JSON Forms UI Schema
597
+ *
598
+ * @public
599
+ */
600
+ export declare function generateUiSchema<E extends readonly FormElement[]>(form: FormSpec<E>): UISchema;
601
+
602
+ /**
603
+ * Reads a FormSpec extension property from a JSON Schema node.
604
+ *
605
+ * Accepts any schema object — `JSONSchema7`, `JsonSchema2020`, `ExtendedJSONSchema7`, etc.
606
+ *
607
+ * @param schema - Any JSON Schema node
608
+ * @param key - Extension key (must start with `x-formspec-`)
609
+ * @returns The extension value, or `undefined` if not present
610
+ *
611
+ * @public
612
+ */
613
+ export declare function getSchemaExtension(schema: object, key: `x-formspec-${string}`): unknown;
614
+
615
+ /**
616
+ * A group element with a label.
617
+ *
618
+ * @public
619
+ */
620
+ export declare interface GroupLayout {
621
+ type: "Group";
622
+ label: string;
623
+ elements: UISchemaElement[];
624
+ rule?: Rule | undefined;
625
+ options?: Record<string, unknown> | undefined;
626
+ [k: string]: unknown;
627
+ }
628
+
629
+ /**
630
+ * Zod schema for a group layout element.
631
+ *
632
+ * @public
633
+ */
634
+ export declare const groupLayoutSchema: z.ZodType<GroupLayout>;
635
+
636
+ /**
637
+ * A horizontal layout element.
638
+ *
639
+ * @public
640
+ */
641
+ export declare interface HorizontalLayout {
642
+ type: "HorizontalLayout";
643
+ elements: UISchemaElement[];
644
+ rule?: Rule | undefined;
645
+ options?: Record<string, unknown> | undefined;
646
+ [k: string]: unknown;
647
+ }
648
+
649
+ /**
650
+ * Zod schema for a horizontal layout element.
651
+ *
652
+ * @public
653
+ */
654
+ export declare const horizontalLayoutSchema: z.ZodType<HorizontalLayout>;
655
+
656
+ /**
657
+ * A JSON Schema 2020-12 document, sub-schema, or keyword collection.
658
+ *
659
+ * This interface covers the subset of JSON Schema 2020-12 that this generator
660
+ * emits, plus an index signature for custom `x-formspec-*` extension keywords.
661
+ *
662
+ * @public
663
+ */
664
+ export declare interface JsonSchema2020 {
665
+ $schema?: string;
666
+ $ref?: string;
667
+ $defs?: Record<string, JsonSchema2020>;
668
+ type?: string;
669
+ properties?: Record<string, JsonSchema2020>;
670
+ required?: string[];
671
+ items?: JsonSchema2020;
672
+ additionalProperties?: boolean | JsonSchema2020;
673
+ enum?: readonly (string | number)[];
674
+ const?: JsonValue;
675
+ allOf?: readonly JsonSchema2020[];
676
+ oneOf?: readonly JsonSchema2020[];
677
+ anyOf?: readonly JsonSchema2020[];
678
+ minimum?: number;
679
+ maximum?: number;
680
+ exclusiveMinimum?: number;
681
+ exclusiveMaximum?: number;
682
+ multipleOf?: number;
683
+ minLength?: number;
684
+ maxLength?: number;
685
+ minItems?: number;
686
+ maxItems?: number;
687
+ pattern?: string;
688
+ uniqueItems?: boolean;
689
+ format?: string;
690
+ title?: string;
691
+ description?: string;
692
+ default?: unknown;
693
+ deprecated?: boolean;
694
+ [key: `x-${string}`]: unknown;
695
+ }
696
+
697
+ /**
698
+ * A JSON Schema definition (legacy subset used by Zod validator and types.ts).
699
+ *
700
+ * @public
701
+ */
702
+ export declare interface JSONSchema7 {
703
+ $schema?: string;
704
+ $id?: string;
705
+ $ref?: string;
706
+ title?: string;
707
+ description?: string;
708
+ deprecated?: boolean;
709
+ type?: JSONSchemaType | JSONSchemaType[];
710
+ minLength?: number;
711
+ maxLength?: number;
712
+ pattern?: string;
713
+ minimum?: number;
714
+ maximum?: number;
715
+ exclusiveMinimum?: number;
716
+ exclusiveMaximum?: number;
717
+ enum?: readonly (string | number | boolean | null)[];
718
+ const?: string | number | boolean | null;
719
+ properties?: Record<string, JSONSchema7>;
720
+ required?: string[];
721
+ additionalProperties?: boolean | JSONSchema7;
722
+ items?: JSONSchema7 | JSONSchema7[];
723
+ minItems?: number;
724
+ maxItems?: number;
725
+ allOf?: JSONSchema7[];
726
+ anyOf?: JSONSchema7[];
727
+ oneOf?: JSONSchema7[];
728
+ not?: JSONSchema7;
729
+ if?: JSONSchema7;
730
+ then?: JSONSchema7;
731
+ else?: JSONSchema7;
732
+ format?: string;
733
+ default?: unknown;
734
+ /**
735
+ * Data source key for dynamic enum fields.
736
+ * Indicates that options should be fetched from a registered resolver.
737
+ */
738
+ "x-formspec-source"?: string;
739
+ /**
740
+ * Field names whose values are needed to fetch dynamic enum options.
741
+ * Used for dependent/cascading dropdowns.
742
+ */
743
+ "x-formspec-params"?: readonly string[];
744
+ /**
745
+ * Schema source identifier for dynamic schema fields.
746
+ * Indicates that the schema should be loaded dynamically at runtime.
747
+ */
748
+ "x-formspec-schemaSource"?: string;
749
+ }
750
+
751
+ /**
752
+ * Zod schema for the legacy JSON Schema 7 subset used by `@formspec/build`.
753
+ *
754
+ * @public
755
+ */
756
+ export declare const jsonSchema7Schema: z.ZodType<JSONSchema7>;
757
+
758
+ /**
759
+ * JSON Schema type definitions.
760
+ *
761
+ * These types are a subset of JSON Schema sufficient for form generation.
762
+ */
763
+ /**
764
+ * JSON Schema primitive types.
765
+ *
766
+ * @public
767
+ */
768
+ export declare type JSONSchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
769
+
770
+ /**
771
+ * Zod schema for JSON Schema primitive type strings.
772
+ *
773
+ * @public
774
+ */
775
+ export declare const jsonSchemaTypeSchema: z.ZodEnum<["string", "number", "integer", "boolean", "object", "array", "null"]>;
776
+
777
+ /**
778
+ * A Label element for displaying static text.
779
+ *
780
+ * @public
781
+ */
782
+ export declare type LabelElement = z.infer<typeof labelElementSchema>;
783
+
784
+ /**
785
+ * Zod schema for a Label element.
786
+ *
787
+ * @public
788
+ */
789
+ export declare const labelElementSchema: z.ZodObject<{
790
+ type: z.ZodLiteral<"Label">;
791
+ text: z.ZodString;
792
+ rule: z.ZodOptional<z.ZodObject<{
793
+ effect: z.ZodEnum<["SHOW", "HIDE", "ENABLE", "DISABLE"]>;
794
+ condition: z.ZodObject<{
795
+ scope: z.ZodString;
796
+ schema: z.ZodType<RuleConditionSchema, z.ZodTypeDef, RuleConditionSchema>;
797
+ }, "strict", z.ZodTypeAny, {
798
+ schema: RuleConditionSchema;
799
+ scope: string;
800
+ }, {
801
+ schema: RuleConditionSchema;
802
+ scope: string;
803
+ }>;
804
+ }, "strict", z.ZodTypeAny, {
805
+ condition: {
806
+ schema: RuleConditionSchema;
807
+ scope: string;
808
+ };
809
+ effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
810
+ }, {
811
+ condition: {
812
+ schema: RuleConditionSchema;
813
+ scope: string;
814
+ };
815
+ effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
816
+ }>>;
817
+ options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
818
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
819
+ type: z.ZodLiteral<"Label">;
820
+ text: z.ZodString;
821
+ rule: z.ZodOptional<z.ZodObject<{
822
+ effect: z.ZodEnum<["SHOW", "HIDE", "ENABLE", "DISABLE"]>;
823
+ condition: z.ZodObject<{
824
+ scope: z.ZodString;
825
+ schema: z.ZodType<RuleConditionSchema, z.ZodTypeDef, RuleConditionSchema>;
826
+ }, "strict", z.ZodTypeAny, {
827
+ schema: RuleConditionSchema;
828
+ scope: string;
829
+ }, {
830
+ schema: RuleConditionSchema;
831
+ scope: string;
832
+ }>;
833
+ }, "strict", z.ZodTypeAny, {
834
+ condition: {
835
+ schema: RuleConditionSchema;
836
+ scope: string;
837
+ };
838
+ effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
839
+ }, {
840
+ condition: {
841
+ schema: RuleConditionSchema;
842
+ scope: string;
843
+ };
844
+ effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
845
+ }>>;
846
+ options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
847
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
848
+ type: z.ZodLiteral<"Label">;
849
+ text: z.ZodString;
850
+ rule: z.ZodOptional<z.ZodObject<{
851
+ effect: z.ZodEnum<["SHOW", "HIDE", "ENABLE", "DISABLE"]>;
852
+ condition: z.ZodObject<{
853
+ scope: z.ZodString;
854
+ schema: z.ZodType<RuleConditionSchema, z.ZodTypeDef, RuleConditionSchema>;
855
+ }, "strict", z.ZodTypeAny, {
856
+ schema: RuleConditionSchema;
857
+ scope: string;
858
+ }, {
859
+ schema: RuleConditionSchema;
860
+ scope: string;
861
+ }>;
862
+ }, "strict", z.ZodTypeAny, {
863
+ condition: {
864
+ schema: RuleConditionSchema;
865
+ scope: string;
866
+ };
867
+ effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
868
+ }, {
869
+ condition: {
870
+ schema: RuleConditionSchema;
871
+ scope: string;
872
+ };
873
+ effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
874
+ }>>;
875
+ options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
876
+ }, z.ZodTypeAny, "passthrough">>;
877
+
878
+ /**
879
+ * Result of generating schemas from a mixed-authoring composition.
880
+ *
881
+ * @public
882
+ */
883
+ export declare interface MixedAuthoringSchemas {
884
+ /** JSON Schema 2020-12 for validation. */
885
+ readonly jsonSchema: JsonSchema2020;
886
+ /** JSON Forms UI Schema for rendering. */
887
+ readonly uiSchema: UISchema;
888
+ }
889
+
890
+ /**
891
+ * Rule for conditional element visibility/enablement.
892
+ *
893
+ * @public
894
+ */
895
+ export declare type Rule = z.infer<typeof ruleSchema>;
896
+
897
+ /**
898
+ * JSON Schema subset used in rule conditions.
899
+ *
900
+ * @public
901
+ */
902
+ export declare interface RuleConditionSchema {
903
+ const?: unknown;
904
+ enum?: readonly unknown[];
905
+ type?: string;
906
+ not?: RuleConditionSchema;
907
+ minimum?: number;
908
+ maximum?: number;
909
+ exclusiveMinimum?: number;
910
+ exclusiveMaximum?: number;
911
+ minLength?: number;
912
+ properties?: Record<string, RuleConditionSchema>;
913
+ required?: string[];
914
+ allOf?: RuleConditionSchema[];
915
+ }
916
+
917
+ /**
918
+ * Zod schema for the rule-condition JSON Schema subset.
919
+ *
920
+ * @public
921
+ */
922
+ export declare const ruleConditionSchema: z.ZodType<RuleConditionSchema>;
923
+
924
+ /**
925
+ * Rule effect types for conditional visibility.
926
+ *
927
+ * @public
928
+ */
929
+ export declare type RuleEffect = z.infer<typeof ruleEffectSchema>;
930
+
931
+ /**
932
+ * Zod schema for rule effect values.
933
+ *
934
+ * @public
935
+ */
936
+ export declare const ruleEffectSchema: z.ZodEnum<["SHOW", "HIDE", "ENABLE", "DISABLE"]>;
937
+
938
+ /**
939
+ * Zod schema for a UI Schema rule.
940
+ *
941
+ * @public
942
+ */
943
+ export declare const ruleSchema: z.ZodObject<{
944
+ effect: z.ZodEnum<["SHOW", "HIDE", "ENABLE", "DISABLE"]>;
945
+ condition: z.ZodObject<{
946
+ scope: z.ZodString;
947
+ schema: z.ZodType<RuleConditionSchema, z.ZodTypeDef, RuleConditionSchema>;
948
+ }, "strict", z.ZodTypeAny, {
949
+ schema: RuleConditionSchema;
950
+ scope: string;
951
+ }, {
952
+ schema: RuleConditionSchema;
953
+ scope: string;
954
+ }>;
955
+ }, "strict", z.ZodTypeAny, {
956
+ condition: {
957
+ schema: RuleConditionSchema;
958
+ scope: string;
959
+ };
960
+ effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
961
+ }, {
962
+ condition: {
963
+ schema: RuleConditionSchema;
964
+ scope: string;
965
+ };
966
+ effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
967
+ }>;
968
+
969
+ /**
970
+ * Condition for a rule.
971
+ *
972
+ * @public
973
+ */
974
+ export declare type SchemaBasedCondition = z.infer<typeof schemaBasedConditionSchema>;
975
+
976
+ /**
977
+ * Zod schema for a schema-based rule condition.
978
+ *
979
+ * @public
980
+ */
981
+ export declare const schemaBasedConditionSchema: z.ZodObject<{
982
+ scope: z.ZodString;
983
+ schema: z.ZodType<RuleConditionSchema, z.ZodTypeDef, RuleConditionSchema>;
984
+ }, "strict", z.ZodTypeAny, {
985
+ schema: RuleConditionSchema;
986
+ scope: string;
987
+ }, {
988
+ schema: RuleConditionSchema;
989
+ scope: string;
990
+ }>;
991
+
992
+ /**
993
+ * Sets a FormSpec extension property on a JSON Schema node.
994
+ *
995
+ * Use this to safely add `x-formspec-*` properties to any schema,
996
+ * including nested schemas typed as `JSONSchema7` (which don't carry
997
+ * the extension index signature).
998
+ *
999
+ * @param schema - Any JSON Schema node
1000
+ * @param key - Extension key (must start with `x-formspec-`)
1001
+ * @param value - Extension value
1002
+ *
1003
+ * @public
1004
+ */
1005
+ export declare function setSchemaExtension(schema: object, key: `x-formspec-${string}`, value: unknown): void;
1006
+
1007
+ /**
1008
+ * Root UI Schema (always a layout — not a Control, Category, or Label).
1009
+ *
1010
+ * @public
1011
+ */
1012
+ export declare type UISchema = VerticalLayout | HorizontalLayout | GroupLayout | Categorization;
1013
+
1014
+ /**
1015
+ * Union of all UI Schema element types.
1016
+ *
1017
+ * @public
1018
+ */
1019
+ export declare type UISchemaElement = ControlElement | VerticalLayout | HorizontalLayout | GroupLayout | Categorization | Category | LabelElement;
1020
+
1021
+ /**
1022
+ * Base interface for all UI Schema elements.
1023
+ *
1024
+ * This is a manually maintained interface representing the common shape
1025
+ * shared by all element types. It is kept as an interface (rather than
1026
+ * derived from Zod) because it is the base of a discriminated union, not
1027
+ * a union member itself.
1028
+ *
1029
+ * @public
1030
+ */
1031
+ export declare interface UISchemaElementBase {
1032
+ type: UISchemaElementType;
1033
+ rule?: Rule;
1034
+ options?: Record<string, unknown>;
1035
+ }
1036
+
1037
+ /**
1038
+ * Zod schema for any UI Schema element.
1039
+ *
1040
+ * @public
1041
+ */
1042
+ export declare const uiSchemaElementSchema: z.ZodType<UISchemaElement>;
1043
+
1044
+ /**
1045
+ * UI Schema element types.
1046
+ *
1047
+ * @public
1048
+ */
1049
+ export declare type UISchemaElementType = z.infer<typeof uiSchemaElementTypeSchema>;
1050
+
1051
+ /**
1052
+ * Zod schema for UI Schema element type strings.
1053
+ *
1054
+ * @public
1055
+ */
1056
+ export declare const uiSchemaElementTypeSchema: z.ZodEnum<["Control", "VerticalLayout", "HorizontalLayout", "Group", "Categorization", "Category", "Label"]>;
1057
+
1058
+ /**
1059
+ * Zod schema for the root UI Schema (layout types only).
1060
+ *
1061
+ * @public
1062
+ */
1063
+ export declare const uiSchemaSchema: z.ZodType<UISchema>;
1064
+
1065
+ /**
1066
+ * A vertical layout element.
1067
+ *
1068
+ * @public
1069
+ */
1070
+ export declare interface VerticalLayout {
1071
+ type: "VerticalLayout";
1072
+ elements: UISchemaElement[];
1073
+ rule?: Rule | undefined;
1074
+ options?: Record<string, unknown> | undefined;
1075
+ [k: string]: unknown;
1076
+ }
1077
+
1078
+ /**
1079
+ * Zod schema for a vertical layout element.
1080
+ *
1081
+ * @public
1082
+ */
1083
+ export declare const verticalLayoutSchema: z.ZodType<VerticalLayout>;
1084
+
1085
+ /**
1086
+ * Builds and writes both JSON Schema and UI Schema files to disk.
1087
+ *
1088
+ * This is a convenience function for build-time schema generation.
1089
+ * It creates the output directory if it doesn't exist.
1090
+ *
1091
+ * @example
1092
+ * ```typescript
1093
+ * import { formspec, field } from "formspec";
1094
+ * import { writeSchemas } from "@formspec/build";
1095
+ *
1096
+ * const ProductForm = formspec(
1097
+ * field.text("name", { required: true }),
1098
+ * field.enum("status", ["draft", "active"]),
1099
+ * );
1100
+ *
1101
+ * // Write schemas to ./generated/product-schema.json and ./generated/product-uischema.json
1102
+ * const { jsonSchemaPath, uiSchemaPath } = writeSchemas(ProductForm, {
1103
+ * outDir: "./generated",
1104
+ * name: "product",
1105
+ * });
1106
+ *
1107
+ * console.log(`Generated: ${jsonSchemaPath}, ${uiSchemaPath}`);
1108
+ * ```
1109
+ *
1110
+ * @param form - The FormSpec to build schemas from
1111
+ * @param options - Output options (directory, file name, indentation)
1112
+ * @returns Object containing paths to the generated files
1113
+ *
1114
+ * @public
1115
+ */
1116
+ export declare function writeSchemas<E extends readonly FormElement[]>(form: FormSpec<E>, options: WriteSchemasOptions): WriteSchemasResult;
1117
+
1118
+ /**
1119
+ * Options for writing schemas to disk.
1120
+ *
1121
+ * @public
1122
+ */
1123
+ export declare interface WriteSchemasOptions extends GenerateJsonSchemaFromIROptions {
1124
+ /** Output directory for the schema files */
1125
+ readonly outDir: string;
1126
+ /** Base name for the output files (without extension). Defaults to "schema" */
1127
+ readonly name?: string;
1128
+ /** Number of spaces for JSON indentation. Defaults to 2 */
1129
+ readonly indent?: number;
1130
+ }
1131
+
1132
+ /**
1133
+ * Result of writing schemas to disk.
1134
+ *
1135
+ * @public
1136
+ */
1137
+ export declare interface WriteSchemasResult {
1138
+ /** Path to the generated JSON Schema file */
1139
+ readonly jsonSchemaPath: string;
1140
+ /** Path to the generated UI Schema file */
1141
+ readonly uiSchemaPath: string;
1142
+ }
1143
+
1144
+ export { }