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

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 (153) hide show
  1. package/README.md +9 -4
  2. package/dist/analyzer/class-analyzer.d.ts +1 -1
  3. package/dist/analyzer/class-analyzer.d.ts.map +1 -1
  4. package/dist/analyzer/jsdoc-constraints.d.ts +1 -1
  5. package/dist/analyzer/jsdoc-constraints.d.ts.map +1 -1
  6. package/dist/analyzer/tsdoc-parser.d.ts +1 -1
  7. package/dist/analyzer/tsdoc-parser.d.ts.map +1 -1
  8. package/dist/browser.cjs +5 -4
  9. package/dist/browser.cjs.map +1 -1
  10. package/dist/browser.js +4 -3
  11. package/dist/browser.js.map +1 -1
  12. package/dist/build-alpha.d.ts +836 -0
  13. package/dist/build-beta.d.ts +836 -0
  14. package/dist/build-internal.d.ts +836 -0
  15. package/dist/build.d.ts +157 -538
  16. package/dist/canonicalize/chain-dsl-canonicalizer.d.ts +2 -1
  17. package/dist/canonicalize/chain-dsl-canonicalizer.d.ts.map +1 -1
  18. package/dist/canonicalize/tsdoc-canonicalizer.d.ts +1 -1
  19. package/dist/canonicalize/tsdoc-canonicalizer.d.ts.map +1 -1
  20. package/dist/cli.cjs +82 -126
  21. package/dist/cli.cjs.map +1 -1
  22. package/dist/cli.js +72 -116
  23. package/dist/cli.js.map +1 -1
  24. package/dist/generators/class-schema.d.ts +20 -3
  25. package/dist/generators/class-schema.d.ts.map +1 -1
  26. package/dist/generators/mixed-authoring.d.ts +3 -2
  27. package/dist/generators/mixed-authoring.d.ts.map +1 -1
  28. package/dist/index.cjs +79 -127
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.ts +4 -12
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +72 -101
  33. package/dist/index.js.map +1 -1
  34. package/dist/internals.cjs +77 -15
  35. package/dist/internals.cjs.map +1 -1
  36. package/dist/internals.d.ts +2 -1
  37. package/dist/internals.d.ts.map +1 -1
  38. package/dist/internals.js +69 -7
  39. package/dist/internals.js.map +1 -1
  40. package/dist/json-schema/generator.d.ts +8 -4
  41. package/dist/json-schema/generator.d.ts.map +1 -1
  42. package/dist/json-schema/ir-generator.d.ts +4 -4
  43. package/dist/json-schema/ir-generator.d.ts.map +1 -1
  44. package/dist/json-schema/schema.d.ts +2 -2
  45. package/dist/json-schema/types.d.ts +6 -6
  46. package/dist/ui-schema/ir-generator.d.ts +1 -1
  47. package/dist/ui-schema/ir-generator.d.ts.map +1 -1
  48. package/dist/ui-schema/schema.d.ts +28 -28
  49. package/dist/ui-schema/types.d.ts +152 -3
  50. package/dist/ui-schema/types.d.ts.map +1 -1
  51. package/dist/validate/constraint-validator.d.ts +1 -1
  52. package/dist/validate/constraint-validator.d.ts.map +1 -1
  53. package/package.json +8 -8
  54. package/dist/__tests__/alias-chain-propagation.test.d.ts +0 -9
  55. package/dist/__tests__/alias-chain-propagation.test.d.ts.map +0 -1
  56. package/dist/__tests__/chain-dsl-canonicalizer.test.d.ts +0 -2
  57. package/dist/__tests__/chain-dsl-canonicalizer.test.d.ts.map +0 -1
  58. package/dist/__tests__/class-schema.test.d.ts +0 -2
  59. package/dist/__tests__/class-schema.test.d.ts.map +0 -1
  60. package/dist/__tests__/cli.test.d.ts +0 -2
  61. package/dist/__tests__/cli.test.d.ts.map +0 -1
  62. package/dist/__tests__/constraint-validator.test.d.ts +0 -2
  63. package/dist/__tests__/constraint-validator.test.d.ts.map +0 -1
  64. package/dist/__tests__/date-extension.integration.test.d.ts +0 -2
  65. package/dist/__tests__/date-extension.integration.test.d.ts.map +0 -1
  66. package/dist/__tests__/edge-cases.test.d.ts +0 -7
  67. package/dist/__tests__/edge-cases.test.d.ts.map +0 -1
  68. package/dist/__tests__/extension-api.test.d.ts +0 -2
  69. package/dist/__tests__/extension-api.test.d.ts.map +0 -1
  70. package/dist/__tests__/extension-runtime.integration.test.d.ts +0 -2
  71. package/dist/__tests__/extension-runtime.integration.test.d.ts.map +0 -1
  72. package/dist/__tests__/fixtures/alias-chains.d.ts +0 -37
  73. package/dist/__tests__/fixtures/alias-chains.d.ts.map +0 -1
  74. package/dist/__tests__/fixtures/class-schema-regressions.d.ts +0 -86
  75. package/dist/__tests__/fixtures/class-schema-regressions.d.ts.map +0 -1
  76. package/dist/__tests__/fixtures/edge-cases.d.ts +0 -132
  77. package/dist/__tests__/fixtures/edge-cases.d.ts.map +0 -1
  78. package/dist/__tests__/fixtures/example-a-builtins.d.ts +0 -31
  79. package/dist/__tests__/fixtures/example-a-builtins.d.ts.map +0 -1
  80. package/dist/__tests__/fixtures/example-date-extension.d.ts +0 -12
  81. package/dist/__tests__/fixtures/example-date-extension.d.ts.map +0 -1
  82. package/dist/__tests__/fixtures/example-interface-types.d.ts +0 -107
  83. package/dist/__tests__/fixtures/example-interface-types.d.ts.map +0 -1
  84. package/dist/__tests__/fixtures/example-numeric-extension.d.ts +0 -20
  85. package/dist/__tests__/fixtures/example-numeric-extension.d.ts.map +0 -1
  86. package/dist/__tests__/fixtures/extension-forms.d.ts +0 -7
  87. package/dist/__tests__/fixtures/extension-forms.d.ts.map +0 -1
  88. package/dist/__tests__/fixtures/mixed-authoring-shipping-address.d.ts +0 -31
  89. package/dist/__tests__/fixtures/mixed-authoring-shipping-address.d.ts.map +0 -1
  90. package/dist/__tests__/fixtures/named-primitive-aliases.d.ts +0 -15
  91. package/dist/__tests__/fixtures/named-primitive-aliases.d.ts.map +0 -1
  92. package/dist/__tests__/fixtures/nested-array-path-constraints.d.ts +0 -14
  93. package/dist/__tests__/fixtures/nested-array-path-constraints.d.ts.map +0 -1
  94. package/dist/__tests__/fixtures/sample-forms.d.ts +0 -65
  95. package/dist/__tests__/fixtures/sample-forms.d.ts.map +0 -1
  96. package/dist/__tests__/generate-schemas.test.d.ts +0 -2
  97. package/dist/__tests__/generate-schemas.test.d.ts.map +0 -1
  98. package/dist/__tests__/generator.test.d.ts +0 -2
  99. package/dist/__tests__/generator.test.d.ts.map +0 -1
  100. package/dist/__tests__/guards.test.d.ts +0 -2
  101. package/dist/__tests__/guards.test.d.ts.map +0 -1
  102. package/dist/__tests__/integration.test.d.ts +0 -8
  103. package/dist/__tests__/integration.test.d.ts.map +0 -1
  104. package/dist/__tests__/ir-analyzer.test.d.ts +0 -11
  105. package/dist/__tests__/ir-analyzer.test.d.ts.map +0 -1
  106. package/dist/__tests__/ir-jsdoc-constraints.test.d.ts +0 -12
  107. package/dist/__tests__/ir-jsdoc-constraints.test.d.ts.map +0 -1
  108. package/dist/__tests__/ir-json-schema-generator.test.d.ts +0 -11
  109. package/dist/__tests__/ir-json-schema-generator.test.d.ts.map +0 -1
  110. package/dist/__tests__/ir-ui-schema-generator.test.d.ts +0 -2
  111. package/dist/__tests__/ir-ui-schema-generator.test.d.ts.map +0 -1
  112. package/dist/__tests__/mixed-authoring.test.d.ts +0 -2
  113. package/dist/__tests__/mixed-authoring.test.d.ts.map +0 -1
  114. package/dist/__tests__/numeric-extension.integration.test.d.ts +0 -2
  115. package/dist/__tests__/numeric-extension.integration.test.d.ts.map +0 -1
  116. package/dist/__tests__/parity/fixtures/address/chain-dsl.d.ts +0 -9
  117. package/dist/__tests__/parity/fixtures/address/chain-dsl.d.ts.map +0 -1
  118. package/dist/__tests__/parity/fixtures/address/expected-ir.d.ts +0 -9
  119. package/dist/__tests__/parity/fixtures/address/expected-ir.d.ts.map +0 -1
  120. package/dist/__tests__/parity/fixtures/address/tsdoc.d.ts +0 -19
  121. package/dist/__tests__/parity/fixtures/address/tsdoc.d.ts.map +0 -1
  122. package/dist/__tests__/parity/fixtures/plan-status/chain-dsl.d.ts +0 -19
  123. package/dist/__tests__/parity/fixtures/plan-status/chain-dsl.d.ts.map +0 -1
  124. package/dist/__tests__/parity/fixtures/plan-status/expected-ir.d.ts +0 -6
  125. package/dist/__tests__/parity/fixtures/plan-status/expected-ir.d.ts.map +0 -1
  126. package/dist/__tests__/parity/fixtures/plan-status/tsdoc.d.ts +0 -17
  127. package/dist/__tests__/parity/fixtures/plan-status/tsdoc.d.ts.map +0 -1
  128. package/dist/__tests__/parity/fixtures/product-config/chain-dsl.d.ts +0 -13
  129. package/dist/__tests__/parity/fixtures/product-config/chain-dsl.d.ts.map +0 -1
  130. package/dist/__tests__/parity/fixtures/product-config/expected-ir.d.ts +0 -9
  131. package/dist/__tests__/parity/fixtures/product-config/expected-ir.d.ts.map +0 -1
  132. package/dist/__tests__/parity/fixtures/product-config/tsdoc.d.ts +0 -28
  133. package/dist/__tests__/parity/fixtures/product-config/tsdoc.d.ts.map +0 -1
  134. package/dist/__tests__/parity/fixtures/usd-cents/chain-dsl.d.ts +0 -9
  135. package/dist/__tests__/parity/fixtures/usd-cents/chain-dsl.d.ts.map +0 -1
  136. package/dist/__tests__/parity/fixtures/usd-cents/expected-ir.d.ts +0 -6
  137. package/dist/__tests__/parity/fixtures/usd-cents/expected-ir.d.ts.map +0 -1
  138. package/dist/__tests__/parity/fixtures/usd-cents/tsdoc.d.ts +0 -19
  139. package/dist/__tests__/parity/fixtures/usd-cents/tsdoc.d.ts.map +0 -1
  140. package/dist/__tests__/parity/fixtures/user-registration/chain-dsl.d.ts +0 -12
  141. package/dist/__tests__/parity/fixtures/user-registration/chain-dsl.d.ts.map +0 -1
  142. package/dist/__tests__/parity/fixtures/user-registration/expected-ir.d.ts +0 -9
  143. package/dist/__tests__/parity/fixtures/user-registration/expected-ir.d.ts.map +0 -1
  144. package/dist/__tests__/parity/fixtures/user-registration/tsdoc.d.ts +0 -19
  145. package/dist/__tests__/parity/fixtures/user-registration/tsdoc.d.ts.map +0 -1
  146. package/dist/__tests__/parity/parity.test.d.ts +0 -18
  147. package/dist/__tests__/parity/parity.test.d.ts.map +0 -1
  148. package/dist/__tests__/parity/utils.d.ts +0 -152
  149. package/dist/__tests__/parity/utils.d.ts.map +0 -1
  150. package/dist/__tests__/path-target-parser.test.d.ts +0 -9
  151. package/dist/__tests__/path-target-parser.test.d.ts.map +0 -1
  152. package/dist/__tests__/write-schemas.test.d.ts +0 -2
  153. package/dist/__tests__/write-schemas.test.d.ts.map +0 -1
@@ -0,0 +1,836 @@
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 { AnyField } from '@formspec/core';
27
+ import { ArrayField } from '@formspec/core';
28
+ import { BooleanField } from '@formspec/core';
29
+ import { BuiltinConstraintBroadeningRegistration } from '@formspec/core';
30
+ import { BuiltinConstraintName } from '@formspec/core';
31
+ import { Conditional } from '@formspec/core';
32
+ import { ConstraintSemanticRole } from '@formspec/core';
33
+ import { ConstraintTagRegistration } from '@formspec/core';
34
+ import { CustomAnnotationRegistration } from '@formspec/core';
35
+ import { CustomConstraintRegistration } from '@formspec/core';
36
+ import { CustomTypeRegistration } from '@formspec/core';
37
+ import { DynamicEnumField } from '@formspec/core';
38
+ import { DynamicSchemaField } from '@formspec/core';
39
+ import { EnumOption } from '@formspec/core';
40
+ import { EnumOptionValue } from '@formspec/core';
41
+ import { ExtensionApplicableType } from '@formspec/core';
42
+ import { ExtensionDefinition } from '@formspec/core';
43
+ import { ExtensionPayloadValue } from '@formspec/core';
44
+ import { ExtensionTypeKind } from '@formspec/core';
45
+ import { FormElement } from '@formspec/core';
46
+ import { FormSpec } from '@formspec/core';
47
+ import { Group } from '@formspec/core';
48
+ import { NumberField } from '@formspec/core';
49
+ import { ObjectField } from '@formspec/core';
50
+ import { StaticEnumField } from '@formspec/core';
51
+ import { TextField } from '@formspec/core';
52
+ import { VocabularyKeywordRegistration } from '@formspec/core';
53
+
54
+ export { AnyField }
55
+
56
+ export { ArrayField }
57
+
58
+ export { BooleanField }
59
+
60
+ /**
61
+ * Builds both JSON Schema and UI Schema from a FormSpec.
62
+ *
63
+ * This is a convenience function that combines `generateJsonSchema`
64
+ * and `generateUiSchema`.
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * const form = formspec(
69
+ * field.text("name", { required: true }),
70
+ * field.number("age", { min: 0 }),
71
+ * );
72
+ *
73
+ * const { jsonSchema, uiSchema } = buildFormSchemas(form);
74
+ *
75
+ * // Use with JSON Forms renderer
76
+ * <JsonForms
77
+ * schema={jsonSchema}
78
+ * uischema={uiSchema}
79
+ * data={formData}
80
+ * renderers={materialRenderers}
81
+ * />
82
+ * ```
83
+ *
84
+ * @param form - The FormSpec to build schemas from
85
+ * @returns Object containing both jsonSchema and uiSchema
86
+ *
87
+ * @public
88
+ */
89
+ export declare function buildFormSchemas<E extends readonly FormElement[]>(form: FormSpec<E>, options?: BuildFormSchemasOptions): BuildResult;
90
+
91
+ /**
92
+ * Options for building schemas from a FormSpec.
93
+ *
94
+ * Currently identical to `GenerateJsonSchemaOptions`. Defined separately so the
95
+ * Chain DSL surface can grow independently in the future if needed.
96
+ *
97
+ * @public
98
+ */
99
+ export declare type BuildFormSchemasOptions = GenerateJsonSchemaOptions;
100
+
101
+ /**
102
+ * Builds JSON Schema and UI Schema from a TSDoc-derived model with ChainDSL
103
+ * field overlays.
104
+ *
105
+ * Overlays are matched by field name. The static model wins for structure,
106
+ * ordering, and constraints; ChainDSL overlays may contribute dynamic runtime
107
+ * field metadata such as dynamic enum or dynamic schema keywords, and may fill
108
+ * in missing annotations.
109
+ *
110
+ * @public
111
+ */
112
+ export declare function buildMixedAuthoringSchemas(options: BuildMixedAuthoringSchemasOptions): MixedAuthoringSchemas;
113
+
114
+ /**
115
+ * Options for generating mixed-authoring schemas.
116
+ *
117
+ * The `typeName` can resolve to a class, interface, or object type alias, just
118
+ * like `generateSchemas()`.
119
+ *
120
+ * @public
121
+ */
122
+ export declare interface BuildMixedAuthoringSchemasOptions extends StaticSchemaGenerationOptions {
123
+ /** Path to the TypeScript source file. */
124
+ readonly filePath: string;
125
+ /** Name of the class, interface, or type alias to analyze. */
126
+ readonly typeName: string;
127
+ /** ChainDSL overlays to apply to the static model. Groups and conditionals are flattened by field name. */
128
+ readonly overlays: FormSpec<readonly FormElement[]>;
129
+ }
130
+
131
+ /**
132
+ * Result of building form schemas.
133
+ *
134
+ * @public
135
+ */
136
+ export declare interface BuildResult {
137
+ /** JSON Schema 2020-12 for validation */
138
+ readonly jsonSchema: JsonSchema2020;
139
+ /** JSON Forms UI Schema for rendering */
140
+ readonly uiSchema: UISchema;
141
+ }
142
+
143
+ export { BuiltinConstraintBroadeningRegistration }
144
+
145
+ export { BuiltinConstraintName }
146
+
147
+ /**
148
+ * A Categorization element (tab-based layout).
149
+ *
150
+ * @public
151
+ */
152
+ export declare interface Categorization {
153
+ readonly type: "Categorization";
154
+ readonly elements: Category[];
155
+ readonly label?: string | undefined;
156
+ readonly rule?: Rule | undefined;
157
+ readonly options?: Record<string, unknown> | undefined;
158
+ readonly [k: string]: unknown;
159
+ }
160
+
161
+ /**
162
+ * A Category element, used inside a Categorization layout.
163
+ *
164
+ * @public
165
+ */
166
+ export declare interface Category {
167
+ readonly type: "Category";
168
+ readonly label: string;
169
+ readonly elements: UISchemaElement[];
170
+ readonly rule?: Rule | undefined;
171
+ readonly options?: Record<string, unknown> | undefined;
172
+ readonly [k: string]: unknown;
173
+ }
174
+
175
+ export { Conditional }
176
+
177
+ export { ConstraintSemanticRole }
178
+
179
+ export { ConstraintTagRegistration }
180
+
181
+ /**
182
+ * A Control element that binds to a JSON Schema property.
183
+ *
184
+ * @public
185
+ */
186
+ export declare interface ControlElement {
187
+ readonly type: "Control";
188
+ readonly scope: string;
189
+ readonly label?: string | false | undefined;
190
+ readonly rule?: Rule | undefined;
191
+ readonly options?: Record<string, unknown> | undefined;
192
+ readonly [k: string]: unknown;
193
+ }
194
+
195
+ /**
196
+ * Creates an extension registry from a list of extension definitions.
197
+ *
198
+ * The registry indexes all types, constraints, and annotations by their
199
+ * fully-qualified IDs (`<extensionId>/<name>`) for O(1) lookup during
200
+ * generation and validation.
201
+ *
202
+ * @param extensions - The extension definitions to register.
203
+ * @returns An {@link ExtensionRegistry} instance.
204
+ * @throws If duplicate type/constraint/annotation IDs are detected across extensions.
205
+ *
206
+ * @public
207
+ */
208
+ export declare function createExtensionRegistry(extensions: readonly ExtensionDefinition[]): ExtensionRegistry;
209
+
210
+ export { CustomAnnotationRegistration }
211
+
212
+ export { CustomConstraintRegistration }
213
+
214
+ export { CustomTypeRegistration }
215
+
216
+ export { DynamicEnumField }
217
+
218
+ export { DynamicSchemaField }
219
+
220
+ export { EnumOption }
221
+
222
+ export { EnumOptionValue }
223
+
224
+ /**
225
+ * JSON Schema with FormSpec extension properties for arbitrary `x-formspec-*` keys.
226
+ *
227
+ * @beta
228
+ */
229
+ export declare type ExtendedJSONSchema7 = JSONSchema7 & FormSpecSchemaExtensions;
230
+
231
+ export { ExtensionApplicableType }
232
+
233
+ export { ExtensionDefinition }
234
+
235
+ export { ExtensionPayloadValue }
236
+
237
+ /**
238
+ * A registry of extensions that provides lookup by fully-qualified ID.
239
+ *
240
+ * Type IDs follow the format: `<extensionId>/<typeName>`
241
+ * Constraint IDs follow the format: `<extensionId>/<constraintName>`
242
+ * Annotation IDs follow the format: `<extensionId>/<annotationName>`
243
+ *
244
+ * @public
245
+ */
246
+ export declare interface ExtensionRegistry {
247
+ /** The extensions registered in this registry (in registration order). */
248
+ readonly extensions: readonly ExtensionDefinition[];
249
+ /**
250
+ * Look up a custom type registration by its fully-qualified type ID.
251
+ *
252
+ * @param typeId - The fully-qualified type ID (e.g., "x-stripe/monetary/Decimal").
253
+ * @returns The registration if found, otherwise `undefined`.
254
+ */
255
+ findType(typeId: string): CustomTypeRegistration | undefined;
256
+ /**
257
+ * Look up a custom type registration by a TypeScript-facing type name.
258
+ *
259
+ * This is used during TSDoc/class analysis to resolve extension-defined
260
+ * custom types from source-level declarations.
261
+ */
262
+ findTypeByName(typeName: string): {
263
+ readonly extensionId: string;
264
+ readonly registration: CustomTypeRegistration;
265
+ } | undefined;
266
+ /**
267
+ * Look up a custom constraint registration by its fully-qualified constraint ID.
268
+ *
269
+ * @param constraintId - The fully-qualified constraint ID.
270
+ * @returns The registration if found, otherwise `undefined`.
271
+ */
272
+ findConstraint(constraintId: string): CustomConstraintRegistration | undefined;
273
+ /**
274
+ * Look up a TSDoc custom constraint-tag registration by tag name.
275
+ */
276
+ findConstraintTag(tagName: string): {
277
+ readonly extensionId: string;
278
+ readonly registration: ConstraintTagRegistration;
279
+ } | undefined;
280
+ /**
281
+ * Look up built-in tag broadening for a given custom type ID.
282
+ */
283
+ findBuiltinConstraintBroadening(typeId: string, tagName: string): {
284
+ readonly extensionId: string;
285
+ readonly registration: BuiltinConstraintBroadeningRegistration;
286
+ } | undefined;
287
+ /**
288
+ * Look up a custom annotation registration by its fully-qualified annotation ID.
289
+ *
290
+ * @param annotationId - The fully-qualified annotation ID.
291
+ * @returns The registration if found, otherwise `undefined`.
292
+ */
293
+ findAnnotation(annotationId: string): CustomAnnotationRegistration | undefined;
294
+ }
295
+
296
+ export { ExtensionTypeKind }
297
+
298
+ export { FormElement }
299
+
300
+ export { FormSpec }
301
+
302
+ /**
303
+ * Extension properties for custom FormSpec constraint tags.
304
+ *
305
+ * @beta
306
+ */
307
+ export declare type FormSpecSchemaExtensions = Record<`x-formspec-${string}`, unknown>;
308
+
309
+ /**
310
+ * Options for generating schemas from a decorated class.
311
+ *
312
+ * @public
313
+ */
314
+ export declare interface GenerateFromClassOptions extends StaticSchemaGenerationOptions {
315
+ /** Path to the TypeScript source file */
316
+ filePath: string;
317
+ /** Class name to analyze */
318
+ className: string;
319
+ }
320
+
321
+ /**
322
+ * Result of generating schemas from a decorated class.
323
+ *
324
+ * @public
325
+ */
326
+ export declare interface GenerateFromClassResult {
327
+ /** JSON Schema 2020-12 for validation */
328
+ jsonSchema: JsonSchema2020;
329
+ /** JSON Forms UI Schema for rendering */
330
+ uiSchema: UISchema;
331
+ }
332
+
333
+ /**
334
+ * Generates a JSON Schema 2020-12 from a FormSpec.
335
+ *
336
+ * All generation routes through the canonical IR. The chain DSL is first
337
+ * canonicalized to a FormIR, then the IR-based generator produces the schema.
338
+ *
339
+ * @example
340
+ * ```typescript
341
+ * const form = formspec(
342
+ * field.text("name", { label: "Name", required: true }),
343
+ * field.number("age", { min: 0 }),
344
+ * );
345
+ *
346
+ * const schema = generateJsonSchema(form);
347
+ * // {
348
+ * // $schema: "https://json-schema.org/draft/2020-12/schema",
349
+ * // type: "object",
350
+ * // properties: {
351
+ * // name: { type: "string", title: "Name" },
352
+ * // age: { type: "number", minimum: 0 }
353
+ * // },
354
+ * // required: ["name"]
355
+ * // }
356
+ * ```
357
+ *
358
+ * @param form - The FormSpec to convert
359
+ * @returns A JSON Schema 2020-12 object
360
+ *
361
+ * @public
362
+ */
363
+ export declare function generateJsonSchema<E extends readonly FormElement[]>(form: FormSpec<E>, options?: GenerateJsonSchemaOptions): JsonSchema2020;
364
+
365
+ /**
366
+ * Options for generating JSON Schema from a Chain DSL form.
367
+ *
368
+ * @public
369
+ */
370
+ export declare interface GenerateJsonSchemaOptions {
371
+ /**
372
+ * Vendor prefix for emitted extension keywords.
373
+ * @defaultValue "x-formspec"
374
+ */
375
+ readonly vendorPrefix?: string | undefined;
376
+ }
377
+
378
+ /**
379
+ * Generates JSON Schema and UI Schema from a named TypeScript
380
+ * type — a decorated class, an interface with TSDoc tags, or a type alias.
381
+ *
382
+ * This is the recommended entry point. It automatically detects whether
383
+ * the name resolves to a class, interface, or type alias and uses the
384
+ * appropriate IR analysis pipeline.
385
+ *
386
+ * @example
387
+ * ```typescript
388
+ * const result = generateSchemas({
389
+ * filePath: "./src/config.ts",
390
+ * typeName: "DiscountConfig",
391
+ * });
392
+ * ```
393
+ *
394
+ * @param options - File path and type name
395
+ * @returns Generated JSON Schema and UI Schema
396
+ *
397
+ * @public
398
+ */
399
+ export declare function generateSchemas(options: GenerateSchemasOptions): GenerateFromClassResult;
400
+
401
+ /**
402
+ * Generates JSON Schema and UI Schema from a decorated TypeScript class.
403
+ *
404
+ * This is a high-level entry point that handles the entire pipeline:
405
+ * creating a TypeScript program, finding the class, analyzing it to IR,
406
+ * and generating schemas — all in one call.
407
+ *
408
+ * @example
409
+ * ```typescript
410
+ * const result = generateSchemasFromClass({
411
+ * filePath: "./src/forms.ts",
412
+ * className: "UserForm",
413
+ * });
414
+ * console.log(result.jsonSchema);
415
+ * ```
416
+ *
417
+ * @param options - File path, class name, and optional compiler options
418
+ * @returns Generated JSON Schema and UI Schema
419
+ *
420
+ * @public
421
+ */
422
+ export declare function generateSchemasFromClass(options: GenerateFromClassOptions): GenerateFromClassResult;
423
+
424
+ /**
425
+ * Options for generating schemas from a named type (class, interface, or type alias).
426
+ *
427
+ * @public
428
+ */
429
+ export declare interface GenerateSchemasOptions extends StaticSchemaGenerationOptions {
430
+ /** Path to the TypeScript source file */
431
+ filePath: string;
432
+ /** Name of the exported class, interface, or type alias to analyze */
433
+ typeName: string;
434
+ }
435
+
436
+ /**
437
+ * Generates a JSON Forms UI Schema from a FormSpec.
438
+ *
439
+ * All generation routes through the canonical IR. The chain DSL is first
440
+ * canonicalized to a FormIR, then the IR-based generator produces the schema.
441
+ *
442
+ * @example
443
+ * ```typescript
444
+ * const form = formspec(
445
+ * group("Customer",
446
+ * field.text("name", { label: "Name" }),
447
+ * ),
448
+ * when("status", "draft",
449
+ * field.text("notes", { label: "Notes" }),
450
+ * ),
451
+ * );
452
+ *
453
+ * const uiSchema = generateUiSchema(form);
454
+ * // {
455
+ * // type: "VerticalLayout",
456
+ * // elements: [
457
+ * // {
458
+ * // type: "Group",
459
+ * // label: "Customer",
460
+ * // elements: [
461
+ * // { type: "Control", scope: "#/properties/name", label: "Name" }
462
+ * // ]
463
+ * // },
464
+ * // {
465
+ * // type: "Control",
466
+ * // scope: "#/properties/notes",
467
+ * // label: "Notes",
468
+ * // rule: {
469
+ * // effect: "SHOW",
470
+ * // condition: { scope: "#/properties/status", schema: { const: "draft" } }
471
+ * // }
472
+ * // }
473
+ * // ]
474
+ * // }
475
+ * ```
476
+ *
477
+ * @param form - The FormSpec to convert
478
+ * @returns A JSON Forms UI Schema
479
+ *
480
+ * @public
481
+ */
482
+ export declare function generateUiSchema<E extends readonly FormElement[]>(form: FormSpec<E>): UISchema;
483
+
484
+ export { Group }
485
+
486
+ /**
487
+ * A group element with a label.
488
+ *
489
+ * @public
490
+ */
491
+ export declare interface GroupLayout {
492
+ readonly type: "Group";
493
+ readonly label: string;
494
+ readonly elements: UISchemaElement[];
495
+ readonly rule?: Rule | undefined;
496
+ readonly options?: Record<string, unknown> | undefined;
497
+ readonly [k: string]: unknown;
498
+ }
499
+
500
+ /**
501
+ * A horizontal layout element.
502
+ *
503
+ * @public
504
+ */
505
+ export declare interface HorizontalLayout {
506
+ readonly type: "HorizontalLayout";
507
+ readonly elements: UISchemaElement[];
508
+ readonly rule?: Rule | undefined;
509
+ readonly options?: Record<string, unknown> | undefined;
510
+ readonly [k: string]: unknown;
511
+ }
512
+
513
+ /**
514
+ * A JSON Schema 2020-12 document, sub-schema, or keyword collection.
515
+ *
516
+ * This interface covers the subset of JSON Schema 2020-12 that this generator
517
+ * emits, plus an index signature for custom `x-formspec-*` extension keywords.
518
+ *
519
+ * @public
520
+ */
521
+ export declare interface JsonSchema2020 {
522
+ $schema?: string;
523
+ $ref?: string;
524
+ $defs?: Record<string, JsonSchema2020>;
525
+ type?: string;
526
+ properties?: Record<string, JsonSchema2020>;
527
+ required?: string[];
528
+ items?: JsonSchema2020;
529
+ additionalProperties?: boolean | JsonSchema2020;
530
+ enum?: readonly (string | number)[];
531
+ const?: unknown;
532
+ allOf?: readonly JsonSchema2020[];
533
+ oneOf?: readonly JsonSchema2020[];
534
+ anyOf?: readonly JsonSchema2020[];
535
+ minimum?: number;
536
+ maximum?: number;
537
+ exclusiveMinimum?: number;
538
+ exclusiveMaximum?: number;
539
+ multipleOf?: number;
540
+ minLength?: number;
541
+ maxLength?: number;
542
+ minItems?: number;
543
+ maxItems?: number;
544
+ pattern?: string;
545
+ uniqueItems?: boolean;
546
+ format?: string;
547
+ title?: string;
548
+ description?: string;
549
+ default?: unknown;
550
+ deprecated?: boolean;
551
+ [key: `x-${string}`]: unknown;
552
+ }
553
+
554
+ /**
555
+ * A JSON Schema definition (legacy subset used by Zod validator and types.ts).
556
+ *
557
+ * @beta
558
+ */
559
+ export declare interface JSONSchema7 {
560
+ $schema?: string;
561
+ $id?: string;
562
+ $ref?: string;
563
+ title?: string;
564
+ description?: string;
565
+ deprecated?: boolean;
566
+ type?: JSONSchemaType | JSONSchemaType[];
567
+ minLength?: number;
568
+ maxLength?: number;
569
+ pattern?: string;
570
+ minimum?: number;
571
+ maximum?: number;
572
+ exclusiveMinimum?: number;
573
+ exclusiveMaximum?: number;
574
+ enum?: readonly (string | number | boolean | null)[];
575
+ const?: string | number | boolean | null;
576
+ properties?: Record<string, JSONSchema7>;
577
+ required?: string[];
578
+ additionalProperties?: boolean | JSONSchema7;
579
+ items?: JSONSchema7 | JSONSchema7[];
580
+ minItems?: number;
581
+ maxItems?: number;
582
+ allOf?: JSONSchema7[];
583
+ anyOf?: JSONSchema7[];
584
+ oneOf?: JSONSchema7[];
585
+ not?: JSONSchema7;
586
+ if?: JSONSchema7;
587
+ then?: JSONSchema7;
588
+ else?: JSONSchema7;
589
+ format?: string;
590
+ default?: unknown;
591
+ /**
592
+ * Data source key for dynamic enum fields.
593
+ * Indicates that options should be fetched from a registered resolver.
594
+ */
595
+ "x-formspec-source"?: string;
596
+ /**
597
+ * Field names whose values are needed to fetch dynamic enum options.
598
+ * Used for dependent/cascading dropdowns.
599
+ */
600
+ "x-formspec-params"?: readonly string[];
601
+ /**
602
+ * Schema source identifier for dynamic schema fields.
603
+ * Indicates that the schema should be loaded dynamically at runtime.
604
+ */
605
+ "x-formspec-schemaSource"?: string;
606
+ }
607
+
608
+ /**
609
+ * JSON Schema type definitions.
610
+ *
611
+ * These types are a subset of JSON Schema sufficient for form generation.
612
+ */
613
+ /**
614
+ * JSON Schema primitive types.
615
+ *
616
+ * @beta
617
+ */
618
+ export declare type JSONSchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
619
+
620
+ /**
621
+ * A Label element for displaying static text.
622
+ *
623
+ * @public
624
+ */
625
+ export declare interface LabelElement {
626
+ readonly type: "Label";
627
+ readonly text: string;
628
+ readonly rule?: Rule | undefined;
629
+ readonly options?: Record<string, unknown> | undefined;
630
+ readonly [k: string]: unknown;
631
+ }
632
+
633
+ /**
634
+ * Result of generating schemas from a mixed-authoring composition.
635
+ *
636
+ * @public
637
+ */
638
+ export declare interface MixedAuthoringSchemas {
639
+ /** JSON Schema 2020-12 for validation. */
640
+ readonly jsonSchema: JsonSchema2020;
641
+ /** JSON Forms UI Schema for rendering. */
642
+ readonly uiSchema: UISchema;
643
+ }
644
+
645
+ export { NumberField }
646
+
647
+ export { ObjectField }
648
+
649
+ /**
650
+ * Rule for conditional element visibility/enablement.
651
+ *
652
+ * @public
653
+ */
654
+ export declare interface Rule {
655
+ readonly effect: RuleEffect;
656
+ readonly condition: SchemaBasedCondition;
657
+ }
658
+
659
+ /**
660
+ * JSON Schema subset used in rule conditions.
661
+ *
662
+ * @public
663
+ */
664
+ export declare interface RuleConditionSchema {
665
+ const?: unknown;
666
+ enum?: readonly unknown[];
667
+ type?: string;
668
+ not?: RuleConditionSchema;
669
+ minimum?: number;
670
+ maximum?: number;
671
+ exclusiveMinimum?: number;
672
+ exclusiveMaximum?: number;
673
+ minLength?: number;
674
+ properties?: Record<string, RuleConditionSchema>;
675
+ required?: string[];
676
+ allOf?: RuleConditionSchema[];
677
+ }
678
+
679
+ /**
680
+ * JSON Forms UI Schema type definitions.
681
+ *
682
+ * These are the consumer-facing TypeScript shapes. Runtime validation remains
683
+ * defined separately in `./schema.ts`.
684
+ *
685
+ * See: https://jsonforms.io/docs/uischema/
686
+ */
687
+ /**
688
+ * Rule effect types for conditional visibility.
689
+ *
690
+ * @public
691
+ */
692
+ export declare type RuleEffect = "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
693
+
694
+ /**
695
+ * Condition for a rule.
696
+ *
697
+ * @public
698
+ */
699
+ export declare interface SchemaBasedCondition {
700
+ readonly scope: string;
701
+ readonly schema: RuleConditionSchema;
702
+ }
703
+
704
+ export { StaticEnumField }
705
+
706
+ /**
707
+ * Shared options for schema generation flows that support custom extensions.
708
+ *
709
+ * @public
710
+ */
711
+ export declare interface StaticSchemaGenerationOptions {
712
+ /**
713
+ * Registry used to resolve custom types, constraints, and annotations.
714
+ */
715
+ readonly extensionRegistry?: ExtensionRegistry | undefined;
716
+ /**
717
+ * Vendor prefix for emitted extension keywords.
718
+ * @defaultValue "x-formspec"
719
+ */
720
+ readonly vendorPrefix?: string | undefined;
721
+ }
722
+
723
+ export { TextField }
724
+
725
+ /**
726
+ * Root UI Schema (always a layout — not a Control, Category, or Label).
727
+ *
728
+ * @public
729
+ */
730
+ export declare type UISchema = VerticalLayout | HorizontalLayout | GroupLayout | Categorization;
731
+
732
+ /**
733
+ * Union of all UI Schema element types.
734
+ *
735
+ * @public
736
+ */
737
+ export declare type UISchemaElement = ControlElement | VerticalLayout | HorizontalLayout | GroupLayout | Categorization | Category | LabelElement;
738
+
739
+ /**
740
+ * Base interface for all UI Schema elements.
741
+ *
742
+ * This is a manually maintained interface representing the common shape
743
+ * shared by all element types. It is kept as an interface (rather than
744
+ * derived from Zod) because it is the base of a discriminated union, not
745
+ * a union member itself.
746
+ *
747
+ * @public
748
+ */
749
+ export declare interface UISchemaElementBase {
750
+ type: UISchemaElementType;
751
+ rule?: Rule;
752
+ options?: Record<string, unknown>;
753
+ }
754
+
755
+ /**
756
+ * UI Schema element types.
757
+ *
758
+ * @public
759
+ */
760
+ export declare type UISchemaElementType = "Control" | "VerticalLayout" | "HorizontalLayout" | "Group" | "Categorization" | "Category" | "Label";
761
+
762
+ /**
763
+ * A vertical layout element.
764
+ *
765
+ * @public
766
+ */
767
+ export declare interface VerticalLayout {
768
+ readonly type: "VerticalLayout";
769
+ readonly elements: UISchemaElement[];
770
+ readonly rule?: Rule | undefined;
771
+ readonly options?: Record<string, unknown> | undefined;
772
+ readonly [k: string]: unknown;
773
+ }
774
+
775
+ export { VocabularyKeywordRegistration }
776
+
777
+ /**
778
+ * Builds and writes both JSON Schema and UI Schema files to disk.
779
+ *
780
+ * This is a convenience function for build-time schema generation.
781
+ * It creates the output directory if it doesn't exist.
782
+ *
783
+ * @example
784
+ * ```typescript
785
+ * import { formspec, field } from "formspec";
786
+ * import { writeSchemas } from "@formspec/build";
787
+ *
788
+ * const ProductForm = formspec(
789
+ * field.text("name", { required: true }),
790
+ * field.enum("status", ["draft", "active"]),
791
+ * );
792
+ *
793
+ * // Write schemas to ./generated/product-schema.json and ./generated/product-uischema.json
794
+ * const { jsonSchemaPath, uiSchemaPath } = writeSchemas(ProductForm, {
795
+ * outDir: "./generated",
796
+ * name: "product",
797
+ * });
798
+ *
799
+ * console.log(`Generated: ${jsonSchemaPath}, ${uiSchemaPath}`);
800
+ * ```
801
+ *
802
+ * @param form - The FormSpec to build schemas from
803
+ * @param options - Output options (directory, file name, indentation)
804
+ * @returns Object containing paths to the generated files
805
+ *
806
+ * @public
807
+ */
808
+ export declare function writeSchemas<E extends readonly FormElement[]>(form: FormSpec<E>, options: WriteSchemasOptions): WriteSchemasResult;
809
+
810
+ /**
811
+ * Options for writing schemas to disk.
812
+ *
813
+ * @public
814
+ */
815
+ export declare interface WriteSchemasOptions extends GenerateJsonSchemaOptions {
816
+ /** Output directory for the schema files */
817
+ readonly outDir: string;
818
+ /** Base name for the output files (without extension). Defaults to "schema" */
819
+ readonly name?: string;
820
+ /** Number of spaces for JSON indentation. Defaults to 2 */
821
+ readonly indent?: number;
822
+ }
823
+
824
+ /**
825
+ * Result of writing schemas to disk.
826
+ *
827
+ * @public
828
+ */
829
+ export declare interface WriteSchemasResult {
830
+ /** Path to the generated JSON Schema file */
831
+ readonly jsonSchemaPath: string;
832
+ /** Path to the generated UI Schema file */
833
+ readonly uiSchemaPath: string;
834
+ }
835
+
836
+ export { }