@formspec/build 0.1.0-alpha.4 → 0.1.0-alpha.41

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 (113) 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 +94 -0
  8. package/dist/analyzer/program.d.ts.map +1 -0
  9. package/dist/analyzer/tsdoc-parser.d.ts +126 -0
  10. package/dist/analyzer/tsdoc-parser.d.ts.map +1 -0
  11. package/dist/browser.cjs +2113 -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 +2070 -0
  16. package/dist/browser.js.map +1 -0
  17. package/dist/build-alpha.d.ts +1501 -0
  18. package/dist/build-beta.d.ts +1501 -0
  19. package/dist/build-internal.d.ts +1501 -0
  20. package/dist/build.d.ts +1194 -43
  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 +6715 -0
  28. package/dist/cli.cjs.map +1 -0
  29. package/dist/cli.js +6687 -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 +83 -0
  34. package/dist/extensions/registry.d.ts.map +1 -0
  35. package/dist/generators/class-schema.d.ts +347 -0
  36. package/dist/generators/class-schema.d.ts.map +1 -0
  37. package/dist/generators/discovered-schema.d.ts +152 -0
  38. package/dist/generators/discovered-schema.d.ts.map +1 -0
  39. package/dist/generators/method-schema.d.ts +72 -0
  40. package/dist/generators/method-schema.d.ts.map +1 -0
  41. package/dist/generators/mixed-authoring.d.ts +52 -0
  42. package/dist/generators/mixed-authoring.d.ts.map +1 -0
  43. package/dist/index.cjs +6412 -0
  44. package/dist/index.cjs.map +1 -0
  45. package/dist/index.d.ts +50 -8
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +6387 -107
  48. package/dist/index.js.map +1 -1
  49. package/dist/internals.cjs +5573 -0
  50. package/dist/internals.cjs.map +1 -0
  51. package/dist/internals.d.ts +32 -0
  52. package/dist/internals.d.ts.map +1 -0
  53. package/dist/internals.js +5554 -0
  54. package/dist/internals.js.map +1 -0
  55. package/dist/json-schema/generator.d.ts +32 -6
  56. package/dist/json-schema/generator.d.ts.map +1 -1
  57. package/dist/json-schema/ir-generator.d.ts +149 -0
  58. package/dist/json-schema/ir-generator.d.ts.map +1 -0
  59. package/dist/json-schema/schema.d.ts +23 -0
  60. package/dist/json-schema/schema.d.ts.map +1 -0
  61. package/dist/json-schema/types.d.ts +76 -2
  62. package/dist/json-schema/types.d.ts.map +1 -1
  63. package/dist/metadata/collision-guards.d.ts +3 -0
  64. package/dist/metadata/collision-guards.d.ts.map +1 -0
  65. package/dist/metadata/index.d.ts +7 -0
  66. package/dist/metadata/index.d.ts.map +1 -0
  67. package/dist/metadata/policy.d.ts +12 -0
  68. package/dist/metadata/policy.d.ts.map +1 -0
  69. package/dist/metadata/resolve.d.ts +21 -0
  70. package/dist/metadata/resolve.d.ts.map +1 -0
  71. package/dist/static-build.d.ts +61 -0
  72. package/dist/static-build.d.ts.map +1 -0
  73. package/dist/ui-schema/generator.d.ts +18 -2
  74. package/dist/ui-schema/generator.d.ts.map +1 -1
  75. package/dist/ui-schema/ir-generator.d.ts +54 -0
  76. package/dist/ui-schema/ir-generator.d.ts.map +1 -0
  77. package/dist/ui-schema/schema.d.ts +429 -0
  78. package/dist/ui-schema/schema.d.ts.map +1 -0
  79. package/dist/ui-schema/types.d.ts +179 -35
  80. package/dist/ui-schema/types.d.ts.map +1 -1
  81. package/dist/validate/constraint-validator.d.ts +85 -0
  82. package/dist/validate/constraint-validator.d.ts.map +1 -0
  83. package/dist/validate/index.d.ts +9 -0
  84. package/dist/validate/index.d.ts.map +1 -0
  85. package/package.json +31 -11
  86. package/dist/__tests__/cli.test.d.ts +0 -2
  87. package/dist/__tests__/cli.test.d.ts.map +0 -1
  88. package/dist/__tests__/cli.test.js +0 -178
  89. package/dist/__tests__/cli.test.js.map +0 -1
  90. package/dist/__tests__/edge-cases.test.d.ts +0 -7
  91. package/dist/__tests__/edge-cases.test.d.ts.map +0 -1
  92. package/dist/__tests__/edge-cases.test.js +0 -217
  93. package/dist/__tests__/edge-cases.test.js.map +0 -1
  94. package/dist/__tests__/generator.test.d.ts +0 -2
  95. package/dist/__tests__/generator.test.d.ts.map +0 -1
  96. package/dist/__tests__/generator.test.js +0 -225
  97. package/dist/__tests__/generator.test.js.map +0 -1
  98. package/dist/__tests__/integration.test.d.ts +0 -8
  99. package/dist/__tests__/integration.test.d.ts.map +0 -1
  100. package/dist/__tests__/integration.test.js +0 -163
  101. package/dist/__tests__/integration.test.js.map +0 -1
  102. package/dist/__tests__/write-schemas.test.d.ts +0 -2
  103. package/dist/__tests__/write-schemas.test.d.ts.map +0 -1
  104. package/dist/__tests__/write-schemas.test.js +0 -196
  105. package/dist/__tests__/write-schemas.test.js.map +0 -1
  106. package/dist/json-schema/generator.js +0 -161
  107. package/dist/json-schema/generator.js.map +0 -1
  108. package/dist/json-schema/types.js +0 -7
  109. package/dist/json-schema/types.js.map +0 -1
  110. package/dist/ui-schema/generator.js +0 -150
  111. package/dist/ui-schema/generator.js.map +0 -1
  112. package/dist/ui-schema/types.js +0 -8
  113. package/dist/ui-schema/types.js.map +0 -1
package/dist/build.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * `@formspec/build` - Build tools for FormSpec
3
3
  *
4
4
  * This package provides generators to compile FormSpec forms into:
5
- * - JSON Schema (for validation)
5
+ * - JSON Schema 2020-12 (for validation)
6
6
  * - JSON Forms UI Schema (for rendering)
7
7
  *
8
8
  * @example
@@ -23,8 +23,37 @@
23
23
  * @packageDocumentation
24
24
  */
25
25
 
26
- import type { FormElement } from '@formspec/core';
27
- import type { FormSpec } from '@formspec/core';
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 { Conditional } from '@formspec/core';
31
+ import { ConstraintTagRegistration } from '@formspec/core';
32
+ import { CustomAnnotationRegistration } from '@formspec/core';
33
+ import { CustomConstraintRegistration } from '@formspec/core';
34
+ import { CustomTypeRegistration } from '@formspec/core';
35
+ import { DynamicEnumField } from '@formspec/core';
36
+ import { DynamicSchemaField } from '@formspec/core';
37
+ import { EnumOption } from '@formspec/core';
38
+ import { EnumOptionValue } from '@formspec/core';
39
+ import { ExtensionDefinition } from '@formspec/core';
40
+ import { FormElement } from '@formspec/core';
41
+ import { FormSpec } from '@formspec/core';
42
+ import { Group } from '@formspec/core';
43
+ import type { MetadataPolicyInput } from '@formspec/core';
44
+ import { NumberField } from '@formspec/core';
45
+ import { ObjectField } from '@formspec/core';
46
+ import type { ResolvedMetadata } from '@formspec/core';
47
+ import { StaticEnumField } from '@formspec/core';
48
+ import { TextField } from '@formspec/core';
49
+ import * as ts from 'typescript';
50
+ import { z } from 'zod';
51
+
52
+ export { AnyField }
53
+
54
+ export { ArrayField }
55
+
56
+ export { BooleanField }
28
57
 
29
58
  /**
30
59
  * Builds both JSON Schema and UI Schema from a FormSpec.
@@ -52,30 +81,354 @@ import type { FormSpec } from '@formspec/core';
52
81
  *
53
82
  * @param form - The FormSpec to build schemas from
54
83
  * @returns Object containing both jsonSchema and uiSchema
84
+ *
85
+ * @public
86
+ */
87
+ export declare function buildFormSchemas<E extends readonly FormElement[]>(form: FormSpec<E>, options?: BuildFormSchemasOptions): BuildResult;
88
+
89
+ /**
90
+ * Options for building schemas from a FormSpec.
91
+ *
92
+ * Currently identical to `GenerateJsonSchemaOptions`. Defined separately so the
93
+ * Chain DSL surface can grow independently in the future if needed.
94
+ *
95
+ * @public
55
96
  */
56
- export declare function buildFormSchemas<E extends readonly FormElement[]>(form: FormSpec<E>): BuildResult;
97
+ export declare interface BuildFormSchemasOptions extends GenerateJsonSchemaOptions, GenerateUiSchemaOptions {
98
+ }
99
+
100
+ /**
101
+ * Builds JSON Schema and UI Schema from a TSDoc-derived model with ChainDSL
102
+ * field overlays.
103
+ *
104
+ * Overlays are matched by field name. The static model wins for structure,
105
+ * ordering, and constraints; ChainDSL overlays may contribute dynamic runtime
106
+ * field metadata such as dynamic enum or dynamic schema keywords, and may fill
107
+ * in missing annotations.
108
+ *
109
+ * @public
110
+ */
111
+ export declare function buildMixedAuthoringSchemas(options: BuildMixedAuthoringSchemasOptions): MixedAuthoringSchemas;
112
+
113
+ /**
114
+ * Options for generating mixed-authoring schemas.
115
+ *
116
+ * The `typeName` can resolve to a class, interface, or object type alias, just
117
+ * like `generateSchemas()`.
118
+ *
119
+ * @public
120
+ */
121
+ export declare interface BuildMixedAuthoringSchemasOptions extends StaticSchemaGenerationOptions {
122
+ /** Path to the TypeScript source file. */
123
+ readonly filePath: string;
124
+ /** Name of the class, interface, or type alias to analyze. */
125
+ readonly typeName: string;
126
+ /** ChainDSL overlays to apply to the static model. Groups and conditionals are flattened by field name. */
127
+ readonly overlays: FormSpec<readonly FormElement[]>;
128
+ }
57
129
 
58
130
  /**
59
131
  * Result of building form schemas.
132
+ *
133
+ * @public
60
134
  */
61
135
  export declare interface BuildResult {
62
- /** JSON Schema for validation */
63
- readonly jsonSchema: JSONSchema7;
136
+ /** JSON Schema 2020-12 for validation */
137
+ readonly jsonSchema: JsonSchema2020;
64
138
  /** JSON Forms UI Schema for rendering */
65
139
  readonly uiSchema: UISchema;
66
140
  }
67
141
 
142
+ export { BuiltinConstraintBroadeningRegistration }
143
+
144
+ /**
145
+ * A Categorization element (tab-based layout).
146
+ *
147
+ * @public
148
+ */
149
+ export declare interface Categorization {
150
+ /** Discriminator identifying a categorization layout. */
151
+ readonly type: "Categorization";
152
+ /** Categories rendered as tabs or steps. */
153
+ readonly elements: Category[];
154
+ /** Optional label for the overall categorization container. */
155
+ readonly label?: string | undefined;
156
+ /** Optional rule controlling visibility or enablement. */
157
+ readonly rule?: Rule | undefined;
158
+ /** Renderer-specific categorization options. */
159
+ readonly options?: Record<string, unknown> | undefined;
160
+ /** Additional renderer-specific extension properties. */
161
+ readonly [k: string]: unknown;
162
+ }
163
+
164
+ /**
165
+ * A Category element, used inside a Categorization layout.
166
+ *
167
+ * @public
168
+ */
169
+ export declare interface Category {
170
+ /** Discriminator identifying a category inside a categorization layout. */
171
+ readonly type: "Category";
172
+ /** Category label shown in tabs or step navigation. */
173
+ readonly label: string;
174
+ /** Child elements rendered inside the category. */
175
+ readonly elements: UISchemaElement[];
176
+ /** Optional rule controlling visibility or enablement. */
177
+ readonly rule?: Rule | undefined;
178
+ /** Renderer-specific category options. */
179
+ readonly options?: Record<string, unknown> | undefined;
180
+ /** Additional renderer-specific extension properties. */
181
+ readonly [k: string]: unknown;
182
+ }
183
+
184
+ export { Conditional }
185
+
186
+ export { ConstraintTagRegistration }
187
+
68
188
  /**
69
189
  * A Control element that binds to a JSON Schema property.
190
+ *
191
+ * @public
70
192
  */
71
- export declare interface ControlElement extends UISchemaElementBase {
72
- type: "Control";
73
- scope: string;
74
- label?: string;
193
+ export declare interface ControlElement {
194
+ /** Discriminator identifying a JSON Forms control element. */
195
+ readonly type: "Control";
196
+ /** JSON Pointer scope that this control binds to. */
197
+ readonly scope: string;
198
+ /** Optional label override, or `false` to suppress the label. */
199
+ readonly label?: string | false | undefined;
200
+ /** Optional rule controlling visibility or enablement. */
201
+ readonly rule?: Rule | undefined;
202
+ /** Renderer-specific control options. */
203
+ readonly options?: Record<string, unknown> | undefined;
204
+ /** Additional renderer-specific extension properties. */
205
+ readonly [k: string]: unknown;
75
206
  }
76
207
 
77
208
  /**
78
- * Generates a JSON Schema from a FormSpec.
209
+ * Creates an extension registry from a list of extension definitions.
210
+ *
211
+ * The registry indexes all types, constraints, and annotations by their
212
+ * fully-qualified IDs (`<extensionId>/<name>`) for O(1) lookup during
213
+ * generation and validation.
214
+ *
215
+ * @param extensions - The extension definitions to register.
216
+ * @returns An {@link ExtensionRegistry} instance.
217
+ * @throws If duplicate type/constraint/annotation IDs are detected across extensions.
218
+ *
219
+ * @public
220
+ */
221
+ export declare function createExtensionRegistry(extensions: readonly ExtensionDefinition[]): ExtensionRegistry;
222
+
223
+ /**
224
+ * Creates a supported static build context for a source file.
225
+ *
226
+ * @param filePath - Entry TypeScript source file used for export resolution
227
+ * @returns Reusable build context containing the program, checker, and source file
228
+ *
229
+ * @public
230
+ */
231
+ export declare function createStaticBuildContext(filePath: string): StaticBuildContext;
232
+
233
+ /**
234
+ * Creates a supported static build context from an existing host-owned program.
235
+ *
236
+ * @param program - Existing TypeScript program supplied by the caller
237
+ * @param filePath - Entry TypeScript source file used for export resolution
238
+ * @returns Reusable build context containing the program, checker, and source file
239
+ *
240
+ * @public
241
+ */
242
+ export declare function createStaticBuildContextFromProgram(program: ts.Program, filePath: string): StaticBuildContext;
243
+
244
+ export { CustomAnnotationRegistration }
245
+
246
+ export { CustomConstraintRegistration }
247
+
248
+ export { CustomTypeRegistration }
249
+
250
+ /**
251
+ * Non-throwing schema generation result with structured diagnostics.
252
+ *
253
+ * @public
254
+ */
255
+ export declare interface DetailedClassSchemasResult {
256
+ /** Whether schema generation completed without error-severity diagnostics. */
257
+ readonly ok: boolean;
258
+ /** Collected analysis and validation diagnostics for this target. */
259
+ readonly diagnostics: readonly ValidationDiagnostic[];
260
+ /** JSON Schema 2020-12 for validation, when generation succeeds. */
261
+ readonly jsonSchema?: JsonSchema2020 | undefined;
262
+ /** JSON Forms UI Schema for rendering, when generation succeeds. */
263
+ readonly uiSchema?: UISchema | undefined;
264
+ }
265
+
266
+ /**
267
+ * Result for a single target in a batch generation request.
268
+ *
269
+ * @public
270
+ */
271
+ export declare interface DetailedSchemaGenerationTargetResult extends DetailedClassSchemasResult {
272
+ /** Path to the TypeScript source file. */
273
+ readonly filePath: string;
274
+ /** Name of the exported class, interface, or type alias that was analyzed. */
275
+ readonly typeName: string;
276
+ }
277
+
278
+ /**
279
+ * Generated schemas for a discovered declaration or signature type.
280
+ *
281
+ * `uiSchema` is `null` when the discovered type does not have an object-shaped
282
+ * root that can be represented as a JSON Forms layout.
283
+ *
284
+ * @public
285
+ */
286
+ export declare interface DiscoveredTypeSchemas {
287
+ /** JSON Schema 2020-12 for the resolved type. */
288
+ readonly jsonSchema: JsonSchema2020;
289
+ /** UI Schema for object-shaped roots, or `null` when not applicable. */
290
+ readonly uiSchema: UISchema | null;
291
+ /**
292
+ * Resolved type-level metadata used during generation, when available.
293
+ *
294
+ * This preserves explicit and inferred naming metadata such as singular and
295
+ * plural API/display names for consumers that need the resolved values in
296
+ * addition to the emitted schema artifacts.
297
+ */
298
+ readonly resolvedMetadata?: ResolvedMetadata | undefined;
299
+ }
300
+
301
+ /**
302
+ * Discriminator-specific schema generation options.
303
+ *
304
+ * @public
305
+ */
306
+ export declare interface DiscriminatorResolutionOptions {
307
+ /**
308
+ * Optional prefix applied only to metadata-derived discriminator values.
309
+ *
310
+ * Literal discriminator identities taken directly from a bound type remain
311
+ * unchanged.
312
+ */
313
+ readonly apiNamePrefix?: string | undefined;
314
+ }
315
+
316
+ export { DynamicEnumField }
317
+
318
+ export { DynamicSchemaField }
319
+
320
+ export { EnumOption }
321
+
322
+ export { EnumOptionValue }
323
+
324
+ /**
325
+ * JSON Schema with FormSpec extension properties for arbitrary `x-formspec-*` keys.
326
+ *
327
+ * @public
328
+ */
329
+ export declare type ExtendedJSONSchema7 = JSONSchema7 & FormSpecSchemaExtensions;
330
+
331
+ export { ExtensionDefinition }
332
+
333
+ /**
334
+ * A registry of extensions that provides lookup by fully-qualified ID.
335
+ *
336
+ * Type IDs follow the format: `<extensionId>/<typeName>`
337
+ * Constraint IDs follow the format: `<extensionId>/<constraintName>`
338
+ * Annotation IDs follow the format: `<extensionId>/<annotationName>`
339
+ *
340
+ * @public
341
+ */
342
+ export declare interface ExtensionRegistry {
343
+ /** The extensions registered in this registry (in registration order). */
344
+ readonly extensions: readonly ExtensionDefinition[];
345
+ /**
346
+ * Look up a custom type registration by its fully-qualified type ID.
347
+ *
348
+ * @param typeId - The fully-qualified type ID (e.g., "x-stripe/monetary/Decimal").
349
+ * @returns The registration if found, otherwise `undefined`.
350
+ */
351
+ findType(typeId: string): CustomTypeRegistration | undefined;
352
+ /**
353
+ * Look up a custom type registration by a TypeScript-facing type name.
354
+ *
355
+ * This is used during TSDoc/class analysis to resolve extension-defined
356
+ * custom types from source-level declarations.
357
+ */
358
+ findTypeByName(typeName: string): {
359
+ readonly extensionId: string;
360
+ readonly registration: CustomTypeRegistration;
361
+ } | undefined;
362
+ /**
363
+ * Look up a custom constraint registration by its fully-qualified constraint ID.
364
+ *
365
+ * @param constraintId - The fully-qualified constraint ID.
366
+ * @returns The registration if found, otherwise `undefined`.
367
+ */
368
+ findConstraint(constraintId: string): CustomConstraintRegistration | undefined;
369
+ /**
370
+ * Look up a TSDoc custom constraint-tag registration by tag name.
371
+ */
372
+ findConstraintTag(tagName: string): {
373
+ readonly extensionId: string;
374
+ readonly registration: ConstraintTagRegistration;
375
+ } | undefined;
376
+ /**
377
+ * Look up built-in tag broadening for a given custom type ID.
378
+ */
379
+ findBuiltinConstraintBroadening(typeId: string, tagName: string): {
380
+ readonly extensionId: string;
381
+ readonly registration: BuiltinConstraintBroadeningRegistration;
382
+ } | undefined;
383
+ /**
384
+ * Look up a custom annotation registration by its fully-qualified annotation ID.
385
+ *
386
+ * @param annotationId - The fully-qualified annotation ID.
387
+ * @returns The registration if found, otherwise `undefined`.
388
+ */
389
+ findAnnotation(annotationId: string): CustomAnnotationRegistration | undefined;
390
+ }
391
+
392
+ export { FormElement }
393
+
394
+ export { FormSpec }
395
+
396
+ /**
397
+ * Extension properties for custom FormSpec constraint tags.
398
+ *
399
+ * @public
400
+ */
401
+ export declare type FormSpecSchemaExtensions = Record<`x-formspec-${string}`, unknown>;
402
+
403
+ /**
404
+ * Options for generating schemas from a decorated class.
405
+ *
406
+ * @public
407
+ */
408
+ export declare interface GenerateFromClassOptions extends StaticSchemaGenerationOptions {
409
+ /** Path to the TypeScript source file */
410
+ filePath: string;
411
+ /** Class name to analyze */
412
+ className: string;
413
+ }
414
+
415
+ /**
416
+ * Result of generating schemas from a decorated class.
417
+ *
418
+ * @public
419
+ */
420
+ export declare interface GenerateFromClassResult {
421
+ /** JSON Schema 2020-12 for validation */
422
+ jsonSchema: JsonSchema2020;
423
+ /** JSON Forms UI Schema for rendering */
424
+ uiSchema: UISchema;
425
+ }
426
+
427
+ /**
428
+ * Generates a JSON Schema 2020-12 from a FormSpec.
429
+ *
430
+ * All generation routes through the canonical IR. The chain DSL is first
431
+ * canonicalized to a FormIR, then the IR-based generator produces the schema.
79
432
  *
80
433
  * @example
81
434
  * ```typescript
@@ -86,7 +439,7 @@ export declare interface ControlElement extends UISchemaElementBase {
86
439
  *
87
440
  * const schema = generateJsonSchema(form);
88
441
  * // {
89
- * // $schema: "https://json-schema.org/draft-07/schema#",
442
+ * // $schema: "https://json-schema.org/draft/2020-12/schema",
90
443
  * // type: "object",
91
444
  * // properties: {
92
445
  * // name: { type: "string", title: "Name" },
@@ -97,13 +450,362 @@ export declare interface ControlElement extends UISchemaElementBase {
97
450
  * ```
98
451
  *
99
452
  * @param form - The FormSpec to convert
100
- * @returns A JSON Schema object
453
+ * @returns A JSON Schema 2020-12 object
454
+ *
455
+ * @public
456
+ */
457
+ export declare function generateJsonSchema<E extends readonly FormElement[]>(form: FormSpec<E>, options?: GenerateJsonSchemaOptions): JsonSchema2020;
458
+
459
+ /**
460
+ * Options for generating JSON Schema from a Chain DSL form.
461
+ *
462
+ * @public
463
+ */
464
+ export declare interface GenerateJsonSchemaOptions {
465
+ /**
466
+ * Vendor prefix for emitted extension keywords.
467
+ * @defaultValue "x-formspec"
468
+ */
469
+ readonly vendorPrefix?: string | undefined;
470
+ /**
471
+ * JSON Schema representation to use for static enums.
472
+ * @defaultValue "enum"
473
+ */
474
+ readonly enumSerialization?: "enum" | "oneOf";
475
+ /** Metadata resolution policy for chain DSL generation. */
476
+ readonly metadata?: MetadataPolicyInput | undefined;
477
+ }
478
+
479
+ /**
480
+ * Generates JSON Schema and UI Schema from a named TypeScript
481
+ * type — a decorated class, an interface with TSDoc tags, or a type alias.
482
+ *
483
+ * This is the recommended entry point. It automatically detects whether
484
+ * the name resolves to a class, interface, or type alias and uses the
485
+ * appropriate IR analysis pipeline.
486
+ *
487
+ * @example
488
+ * ```typescript
489
+ * const result = generateSchemas({
490
+ * filePath: "./src/config.ts",
491
+ * typeName: "DiscountConfig",
492
+ * errorReporting: "throw",
493
+ * });
494
+ * ```
495
+ */
496
+ /**
497
+ * Generates JSON Schema and UI Schema from a named type and throws when
498
+ * generation reports error-severity diagnostics.
499
+ *
500
+ * @param options - File path, type name, and explicit throw-on-error reporting
501
+ * @returns Generated JSON Schema and UI Schema
502
+ *
503
+ * @public
504
+ */
505
+ export declare function generateSchemas(options: GenerateSchemasOptions & {
506
+ readonly errorReporting: "throw";
507
+ }): GenerateFromClassResult;
508
+
509
+ /**
510
+ * Generates JSON Schema and UI Schema from a named type and returns structured
511
+ * diagnostics instead of throwing on validation or analysis failures.
512
+ *
513
+ * @param options - File path, type name, and explicit diagnostics reporting
514
+ * @returns Structured generation result with diagnostics
515
+ *
516
+ * @public
517
+ */
518
+ export declare function generateSchemas(options: GenerateSchemasOptions & {
519
+ readonly errorReporting: "diagnostics";
520
+ }): DetailedClassSchemasResult;
521
+
522
+ /**
523
+ * Generates JSON Schema and UI Schema from a named type.
524
+ *
525
+ * @deprecated Pass `errorReporting` explicitly. Omitting it defaults to `"throw"` only for backward compatibility.
526
+ * @param options - File path and type name
527
+ * @returns Generated JSON Schema and UI Schema
528
+ *
529
+ * @public
530
+ */
531
+ export declare function generateSchemas(options: StaticSchemaGenerationOptions & {
532
+ readonly filePath: string;
533
+ readonly typeName: string;
534
+ }): GenerateFromClassResult;
535
+
536
+ /**
537
+ * Generates schemas for many targets and returns per-target diagnostics instead
538
+ * of failing on the first problem.
539
+ *
540
+ * @public
541
+ */
542
+ export declare function generateSchemasBatch(options: GenerateSchemasBatchOptions): readonly DetailedSchemaGenerationTargetResult[];
543
+
544
+ /**
545
+ * Generates schemas for many targets from an existing TypeScript program and
546
+ * returns per-target diagnostics instead of failing on the first problem.
547
+ *
548
+ * @public
549
+ */
550
+ export declare function generateSchemasBatchFromProgram(options: GenerateSchemasBatchFromProgramOptions): readonly DetailedSchemaGenerationTargetResult[];
551
+
552
+ /**
553
+ * Batch options for non-throwing schema generation using an existing program.
554
+ *
555
+ * @public
556
+ */
557
+ export declare interface GenerateSchemasBatchFromProgramOptions extends StaticSchemaGenerationOptions {
558
+ /** Existing TypeScript program supplied by the caller. */
559
+ readonly program: ts.Program;
560
+ /** Targets to analyze and generate. */
561
+ readonly targets: readonly SchemaGenerationTarget[];
562
+ }
563
+
564
+ /**
565
+ * Batch options for non-throwing schema generation.
566
+ *
567
+ * @public
568
+ */
569
+ export declare interface GenerateSchemasBatchOptions extends StaticSchemaGenerationOptions {
570
+ /** Targets to analyze and generate. */
571
+ readonly targets: readonly SchemaGenerationTarget[];
572
+ }
573
+
574
+ /**
575
+ * Generates JSON Schema and UI Schema from a named type and returns structured
576
+ * diagnostics instead of throwing on validation or analysis failures.
577
+ * @deprecated Use `generateSchemas({ ...options, errorReporting: "diagnostics" })` instead.
578
+ *
579
+ * @public
580
+ */
581
+ export declare function generateSchemasDetailed(options: StaticSchemaGenerationOptions & {
582
+ readonly filePath: string;
583
+ readonly typeName: string;
584
+ }): DetailedClassSchemasResult;
585
+
586
+ /**
587
+ * Generates JSON Schema and UI Schema from a decorated TypeScript class.
588
+ *
589
+ * This is a high-level entry point that handles the entire pipeline:
590
+ * creating a TypeScript program, finding the class, analyzing it to IR,
591
+ * and generating schemas — all in one call.
592
+ *
593
+ * @example
594
+ * ```typescript
595
+ * const result = generateSchemasFromClass({
596
+ * filePath: "./src/forms.ts",
597
+ * className: "UserForm",
598
+ * });
599
+ * console.log(result.jsonSchema);
600
+ * ```
601
+ *
602
+ * @param options - File path, class name, and optional compiler options
603
+ * @returns Generated JSON Schema and UI Schema
604
+ *
605
+ * @public
606
+ */
607
+ export declare function generateSchemasFromClass(options: GenerateFromClassOptions): GenerateFromClassResult;
608
+
609
+ /**
610
+ * Generates schemas from a resolved declaration using the supported public
611
+ * static-build workflow.
612
+ *
613
+ * Named declarations reuse the same analyzer semantics as FormSpec's existing
614
+ * top-level generation APIs. Non-object type aliases fall back to the generic
615
+ * resolved-type entry point.
616
+ *
617
+ * @public
618
+ */
619
+ export declare function generateSchemasFromDeclaration(options: GenerateSchemasFromDeclarationOptions): DiscoveredTypeSchemas;
620
+
621
+ /**
622
+ * Options for generating schemas from a resolved declaration.
623
+ *
624
+ * @public
625
+ */
626
+ export declare interface GenerateSchemasFromDeclarationOptions extends StaticSchemaGenerationOptions {
627
+ /** Supported build context used for checker access and related analysis. */
628
+ readonly context: StaticBuildContext;
629
+ /** Declaration to turn into schemas. */
630
+ readonly declaration: SchemaSourceDeclaration;
631
+ }
632
+
633
+ /**
634
+ * Generates schemas for a method or function parameter type.
635
+ *
636
+ * @public
637
+ */
638
+ export declare function generateSchemasFromParameter(options: GenerateSchemasFromParameterOptions): DiscoveredTypeSchemas;
639
+
640
+ /**
641
+ * Options for generating schemas from a method or function parameter type.
642
+ *
643
+ * @public
644
+ */
645
+ export declare interface GenerateSchemasFromParameterOptions extends StaticSchemaGenerationOptions {
646
+ /** Supported build context used for checker access and related analysis. */
647
+ readonly context: StaticBuildContext;
648
+ /** Parameter declaration whose type should be converted into schemas. */
649
+ readonly parameter: ts.ParameterDeclaration;
650
+ }
651
+
652
+ /**
653
+ * Generates JSON Schema and UI Schema from a named type within an existing
654
+ * TypeScript program supplied by the caller.
655
+ *
656
+ * This low-level entry point lets downstream tooling reuse a host-owned
657
+ * `Program` for both FormSpec extraction and other TypeScript analysis.
658
+ */
659
+ /**
660
+ * Generates JSON Schema and UI Schema from a named type within an existing
661
+ * TypeScript program and throws when generation reports error-severity diagnostics.
662
+ *
663
+ * @param options - Host program, file path, type name, and explicit throw-on-error reporting
664
+ * @returns Generated JSON Schema and UI Schema
665
+ *
666
+ * @public
667
+ */
668
+ export declare function generateSchemasFromProgram(options: GenerateSchemasFromProgramOptions & {
669
+ readonly errorReporting: "throw";
670
+ }): GenerateFromClassResult;
671
+
672
+ /**
673
+ * Generates JSON Schema and UI Schema from a named type within an existing
674
+ * TypeScript program and returns structured diagnostics instead of throwing on
675
+ * validation or analysis failures.
676
+ *
677
+ * @param options - Host program, file path, type name, and explicit diagnostics reporting
678
+ * @returns Structured generation result with diagnostics
679
+ *
680
+ * @public
681
+ */
682
+ export declare function generateSchemasFromProgram(options: GenerateSchemasFromProgramOptions & {
683
+ readonly errorReporting: "diagnostics";
684
+ }): DetailedClassSchemasResult;
685
+
686
+ /**
687
+ * Generates JSON Schema and UI Schema from a named type within an existing
688
+ * TypeScript program.
689
+ *
690
+ * @deprecated Pass `errorReporting` explicitly. Omitting it defaults to `"throw"` only for backward compatibility.
691
+ * @param options - Host program, file path, and type name
692
+ * @returns Generated JSON Schema and UI Schema
693
+ *
694
+ * @public
695
+ */
696
+ export declare function generateSchemasFromProgram(options: StaticSchemaGenerationOptions & {
697
+ readonly program: ts.Program;
698
+ readonly filePath: string;
699
+ readonly typeName: string;
700
+ }): GenerateFromClassResult;
701
+
702
+ /**
703
+ * Generates JSON Schema and UI Schema from a named type within an existing
704
+ * TypeScript program and returns structured diagnostics instead of throwing on
705
+ * validation or analysis failures.
706
+ * @deprecated Use `generateSchemasFromProgram({ ...options, errorReporting: "diagnostics" })` instead.
707
+ *
708
+ * @public
709
+ */
710
+ export declare function generateSchemasFromProgramDetailed(options: StaticSchemaGenerationOptions & {
711
+ readonly program: ts.Program;
712
+ readonly filePath: string;
713
+ readonly typeName: string;
714
+ }): DetailedClassSchemasResult;
715
+
716
+ /**
717
+ * Options for generating schemas from a named type inside an existing TypeScript program.
718
+ *
719
+ * @public
720
+ */
721
+ export declare interface GenerateSchemasFromProgramOptions extends StaticSchemaGenerationOptions {
722
+ /** Existing TypeScript program supplied by the caller. */
723
+ readonly program: ts.Program;
724
+ /** Path to the TypeScript source file */
725
+ readonly filePath: string;
726
+ /** Name of the exported class, interface, or type alias to analyze */
727
+ readonly typeName: string;
728
+ /**
729
+ * Controls whether error-severity diagnostics throw or are returned in the result.
730
+ */
731
+ readonly errorReporting: "throw" | "diagnostics";
732
+ }
733
+
734
+ /**
735
+ * Generates schemas for a method or function return type.
736
+ *
737
+ * Awaited `Promise<T>`-style return types are unwrapped before generation.
738
+ *
739
+ * @public
740
+ */
741
+ export declare function generateSchemasFromReturnType(options: GenerateSchemasFromReturnTypeOptions): DiscoveredTypeSchemas;
742
+
743
+ /**
744
+ * Options for generating schemas from a method or function return type.
745
+ *
746
+ * @public
747
+ */
748
+ export declare interface GenerateSchemasFromReturnTypeOptions extends StaticSchemaGenerationOptions {
749
+ /** Supported build context used for checker access and related analysis. */
750
+ readonly context: StaticBuildContext;
751
+ /** Signature declaration whose return type should be converted into schemas. */
752
+ readonly declaration: ts.SignatureDeclaration;
753
+ }
754
+
755
+ /**
756
+ * Generates schemas from a resolved TypeScript type.
757
+ *
758
+ * This is the advanced public entry point for build tooling that already uses
759
+ * the TypeScript compiler API to discover types before handing them to
760
+ * FormSpec.
761
+ *
762
+ * @public
101
763
  */
102
- export declare function generateJsonSchema<E extends readonly FormElement[]>(form: FormSpec<E>): JSONSchema7;
764
+ export declare function generateSchemasFromType(options: GenerateSchemasFromTypeOptions): DiscoveredTypeSchemas;
765
+
766
+ /**
767
+ * Options for generating schemas from a resolved TypeScript type.
768
+ *
769
+ * @public
770
+ */
771
+ export declare interface GenerateSchemasFromTypeOptions extends StaticSchemaGenerationOptions {
772
+ /** Supported build context used for checker access and related analysis. */
773
+ readonly context: StaticBuildContext;
774
+ /** TypeScript type to turn into schemas. */
775
+ readonly type: ts.Type;
776
+ /**
777
+ * Optional source node associated with the type.
778
+ *
779
+ * When provided, FormSpec uses it as the source location for provenance and
780
+ * inline-type analysis.
781
+ */
782
+ readonly sourceNode?: ts.Node | undefined;
783
+ /** Optional logical name used for anonymous roots. */
784
+ readonly name?: string | undefined;
785
+ }
786
+
787
+ /**
788
+ * Options for generating schemas from a named type (class, interface, or type alias).
789
+ *
790
+ * @public
791
+ */
792
+ export declare interface GenerateSchemasOptions extends StaticSchemaGenerationOptions {
793
+ /** Path to the TypeScript source file */
794
+ readonly filePath: string;
795
+ /** Name of the exported class, interface, or type alias to analyze */
796
+ readonly typeName: string;
797
+ /**
798
+ * Controls whether error-severity diagnostics throw or are returned in the result.
799
+ */
800
+ readonly errorReporting: "throw" | "diagnostics";
801
+ }
103
802
 
104
803
  /**
105
804
  * Generates a JSON Forms UI Schema from a FormSpec.
106
805
  *
806
+ * All generation routes through the canonical IR. The chain DSL is first
807
+ * canonicalized to a FormIR, then the IR-based generator produces the schema.
808
+ *
107
809
  * @example
108
810
  * ```typescript
109
811
  * const form = formspec(
@@ -141,59 +843,199 @@ export declare function generateJsonSchema<E extends readonly FormElement[]>(for
141
843
  *
142
844
  * @param form - The FormSpec to convert
143
845
  * @returns A JSON Forms UI Schema
846
+ *
847
+ * @public
848
+ */
849
+ export declare function generateUiSchema<E extends readonly FormElement[]>(form: FormSpec<E>, options?: GenerateUiSchemaOptions): UISchema;
850
+
851
+ /**
852
+ * Options for generating a UI Schema from a Chain DSL form.
853
+ *
854
+ * @public
144
855
  */
145
- export declare function generateUiSchema<E extends readonly FormElement[]>(form: FormSpec<E>): UISchema;
856
+ export declare interface GenerateUiSchemaOptions {
857
+ /** Metadata resolution policy for chain DSL UI generation. */
858
+ readonly metadata?: MetadataPolicyInput | undefined;
859
+ }
860
+
861
+ export { Group }
146
862
 
147
863
  /**
148
864
  * A group element with a label.
865
+ *
866
+ * @public
149
867
  */
150
- export declare interface GroupLayout extends UISchemaElementBase {
151
- type: "Group";
152
- label: string;
153
- elements: UISchemaElement[];
868
+ export declare interface GroupLayout {
869
+ /** Discriminator identifying a labeled group container. */
870
+ readonly type: "Group";
871
+ /** Group label shown by compatible renderers. */
872
+ readonly label: string;
873
+ /** Child elements rendered inside the group. */
874
+ readonly elements: UISchemaElement[];
875
+ /** Optional rule controlling visibility or enablement. */
876
+ readonly rule?: Rule | undefined;
877
+ /** Renderer-specific group options. */
878
+ readonly options?: Record<string, unknown> | undefined;
879
+ /** Additional renderer-specific extension properties. */
880
+ readonly [k: string]: unknown;
154
881
  }
155
882
 
156
883
  /**
157
884
  * A horizontal layout element.
885
+ *
886
+ * @public
158
887
  */
159
- export declare interface HorizontalLayout extends UISchemaElementBase {
160
- type: "HorizontalLayout";
161
- elements: UISchemaElement[];
888
+ export declare interface HorizontalLayout {
889
+ /** Discriminator identifying a horizontal layout container. */
890
+ readonly type: "HorizontalLayout";
891
+ /** Child elements rendered side by side. */
892
+ readonly elements: UISchemaElement[];
893
+ /** Optional rule controlling visibility or enablement. */
894
+ readonly rule?: Rule | undefined;
895
+ /** Renderer-specific layout options. */
896
+ readonly options?: Record<string, unknown> | undefined;
897
+ /** Additional renderer-specific extension properties. */
898
+ readonly [k: string]: unknown;
162
899
  }
163
900
 
164
901
  /**
165
- * A JSON Schema definition (draft-07 subset).
902
+ * A JSON Schema 2020-12 document, sub-schema, or keyword collection.
903
+ *
904
+ * This interface covers the subset of JSON Schema 2020-12 that this generator
905
+ * emits, plus an index signature for custom `x-formspec-*` extension keywords.
906
+ *
907
+ * @public
908
+ */
909
+ export declare interface JsonSchema2020 {
910
+ /** Declared JSON Schema dialect URI for the document root. */
911
+ $schema?: string;
912
+ /** Reference to another schema location. */
913
+ $ref?: string;
914
+ /** Named reusable schema definitions keyed by definition name. */
915
+ $defs?: Record<string, JsonSchema2020>;
916
+ /** JSON Schema type keyword for the current node. */
917
+ type?: string;
918
+ /** Object properties keyed by property name. */
919
+ properties?: Record<string, JsonSchema2020>;
920
+ /** Property names that must be present on object values. */
921
+ required?: string[];
922
+ /** Item schema applied to array elements. */
923
+ items?: JsonSchema2020;
924
+ /** Whether, or how, additional object properties are allowed. */
925
+ additionalProperties?: boolean | JsonSchema2020;
926
+ /** Closed set of allowed scalar values. */
927
+ enum?: readonly (string | number)[];
928
+ /** Literal value the instance must equal. */
929
+ const?: unknown;
930
+ /** Schemas that must all validate successfully. */
931
+ allOf?: readonly JsonSchema2020[];
932
+ /** Schemas of which exactly one should validate successfully. */
933
+ oneOf?: readonly JsonSchema2020[];
934
+ /** Schemas of which at least one may validate successfully. */
935
+ anyOf?: readonly JsonSchema2020[];
936
+ /** Inclusive numeric lower bound. */
937
+ minimum?: number;
938
+ /** Inclusive numeric upper bound. */
939
+ maximum?: number;
940
+ /** Exclusive numeric lower bound. */
941
+ exclusiveMinimum?: number;
942
+ /** Exclusive numeric upper bound. */
943
+ exclusiveMaximum?: number;
944
+ /** Required numeric step interval. */
945
+ multipleOf?: number;
946
+ /** Inclusive minimum string length. */
947
+ minLength?: number;
948
+ /** Inclusive maximum string length. */
949
+ maxLength?: number;
950
+ /** Inclusive minimum array length. */
951
+ minItems?: number;
952
+ /** Inclusive maximum array length. */
953
+ maxItems?: number;
954
+ /** Regular expression pattern applied to string values. */
955
+ pattern?: string;
956
+ /** Whether array elements must be unique. */
957
+ uniqueItems?: boolean;
958
+ /** Format hint for downstream validators and tooling. */
959
+ format?: string;
960
+ /** Human-readable title for the schema node. */
961
+ title?: string;
962
+ /** Human-readable description for the schema node. */
963
+ description?: string;
964
+ /** Default value suggested for the schema node. */
965
+ default?: unknown;
966
+ /** Whether the schema node is deprecated. */
967
+ deprecated?: boolean;
968
+ /** Additional vendor-prefixed extension keywords. */
969
+ [key: `x-${string}`]: unknown;
970
+ }
971
+
972
+ /**
973
+ * A JSON Schema definition (legacy subset used by Zod validator and types.ts).
974
+ *
975
+ * @public
166
976
  */
167
977
  export declare interface JSONSchema7 {
978
+ /** Declared JSON Schema dialect URI for the document root. */
168
979
  $schema?: string;
980
+ /** Stable identifier for the schema document or sub-schema. */
169
981
  $id?: string;
982
+ /** Reference to another schema location. */
170
983
  $ref?: string;
984
+ /** Human-readable title for the schema node. */
171
985
  title?: string;
986
+ /** Human-readable description for the schema node. */
172
987
  description?: string;
988
+ /** Whether the schema node is deprecated. */
989
+ deprecated?: boolean;
990
+ /** JSON Schema type keyword for the current node. */
173
991
  type?: JSONSchemaType | JSONSchemaType[];
992
+ /** Inclusive minimum string length. */
174
993
  minLength?: number;
994
+ /** Inclusive maximum string length. */
175
995
  maxLength?: number;
996
+ /** Regular expression pattern applied to string values. */
176
997
  pattern?: string;
998
+ /** Inclusive numeric lower bound. */
177
999
  minimum?: number;
1000
+ /** Inclusive numeric upper bound. */
178
1001
  maximum?: number;
1002
+ /** Exclusive numeric lower bound. */
179
1003
  exclusiveMinimum?: number;
1004
+ /** Exclusive numeric upper bound. */
180
1005
  exclusiveMaximum?: number;
1006
+ /** Closed set of allowed scalar values. */
181
1007
  enum?: readonly (string | number | boolean | null)[];
1008
+ /** Literal value the instance must equal. */
182
1009
  const?: string | number | boolean | null;
1010
+ /** Object properties keyed by property name. */
183
1011
  properties?: Record<string, JSONSchema7>;
1012
+ /** Property names that must be present on object values. */
184
1013
  required?: string[];
1014
+ /** Whether, or how, additional object properties are allowed. */
185
1015
  additionalProperties?: boolean | JSONSchema7;
1016
+ /** Item schema or tuple schemas applied to array elements. */
186
1017
  items?: JSONSchema7 | JSONSchema7[];
1018
+ /** Inclusive minimum array length. */
187
1019
  minItems?: number;
1020
+ /** Inclusive maximum array length. */
188
1021
  maxItems?: number;
1022
+ /** Schemas that must all validate successfully. */
189
1023
  allOf?: JSONSchema7[];
1024
+ /** Schemas of which at least one may validate successfully. */
190
1025
  anyOf?: JSONSchema7[];
1026
+ /** Schemas of which exactly one should validate successfully. */
191
1027
  oneOf?: JSONSchema7[];
1028
+ /** Schema that must not validate successfully. */
192
1029
  not?: JSONSchema7;
1030
+ /** Conditional branch predicate schema. */
193
1031
  if?: JSONSchema7;
1032
+ /** Schema applied when the `if` branch matches. */
194
1033
  then?: JSONSchema7;
1034
+ /** Schema applied when the `if` branch does not match. */
195
1035
  else?: JSONSchema7;
1036
+ /** Format hint for downstream validators and tooling. */
196
1037
  format?: string;
1038
+ /** Default value suggested for the schema node. */
197
1039
  default?: unknown;
198
1040
  /**
199
1041
  * Data source key for dynamic enum fields.
@@ -213,85 +1055,388 @@ export declare interface JSONSchema7 {
213
1055
  }
214
1056
 
215
1057
  /**
216
- * JSON Schema Draft-07 type definitions.
1058
+ * Zod schema for the legacy JSON Schema 7 subset used by `@formspec/build`.
1059
+ *
1060
+ * @public
1061
+ */
1062
+ export declare const jsonSchema7Schema: z.ZodType<JSONSchema7>;
1063
+
1064
+ /**
1065
+ * JSON Schema type definitions.
217
1066
  *
218
1067
  * These types are a subset of JSON Schema sufficient for form generation.
219
1068
  */
220
1069
  /**
221
1070
  * JSON Schema primitive types.
1071
+ *
1072
+ * @public
222
1073
  */
223
1074
  export declare type JSONSchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
224
1075
 
1076
+ /**
1077
+ * A Label element for displaying static text.
1078
+ *
1079
+ * @public
1080
+ */
1081
+ export declare interface LabelElement {
1082
+ /** Discriminator identifying a static text label element. */
1083
+ readonly type: "Label";
1084
+ /** Static text content rendered by the label element. */
1085
+ readonly text: string;
1086
+ /** Optional rule controlling visibility or enablement. */
1087
+ readonly rule?: Rule | undefined;
1088
+ /** Renderer-specific label options. */
1089
+ readonly options?: Record<string, unknown> | undefined;
1090
+ /** Additional renderer-specific extension properties. */
1091
+ readonly [k: string]: unknown;
1092
+ }
1093
+
1094
+ /**
1095
+ * Supported declaration kinds for standalone metadata resolution.
1096
+ *
1097
+ * This helper is intentionally limited to named type declarations,
1098
+ * methods/functions, and object-like properties. It does not currently expose
1099
+ * parameter or variable metadata resolution on the public build surface.
1100
+ *
1101
+ * @public
1102
+ */
1103
+ export declare type MetadataSourceDeclaration = SchemaSourceDeclaration | ts.MethodDeclaration | ts.FunctionDeclaration | ts.PropertyDeclaration | ts.PropertySignature;
1104
+
1105
+ /**
1106
+ * Result of generating schemas from a mixed-authoring composition.
1107
+ *
1108
+ * @public
1109
+ */
1110
+ export declare interface MixedAuthoringSchemas {
1111
+ /** JSON Schema 2020-12 for validation. */
1112
+ readonly jsonSchema: JsonSchema2020;
1113
+ /** JSON Forms UI Schema for rendering. */
1114
+ readonly uiSchema: UISchema;
1115
+ }
1116
+
1117
+ export { NumberField }
1118
+
1119
+ export { ObjectField }
1120
+
1121
+ /**
1122
+ * Resolves metadata from a declaration using FormSpec's configured metadata
1123
+ * policy for the matching declaration kind.
1124
+ *
1125
+ * @public
1126
+ */
1127
+ export declare function resolveDeclarationMetadata(options: ResolveDeclarationMetadataOptions): ResolvedMetadata | undefined;
1128
+
1129
+ /**
1130
+ * Options for resolving metadata from a declaration against the active
1131
+ * metadata policy.
1132
+ *
1133
+ * @public
1134
+ */
1135
+ export declare interface ResolveDeclarationMetadataOptions extends StaticSchemaGenerationOptions {
1136
+ /** Supported build context used for checker access and related analysis. */
1137
+ readonly context: StaticBuildContext;
1138
+ /** Declaration whose metadata should be resolved. */
1139
+ readonly declaration: MetadataSourceDeclaration;
1140
+ }
1141
+
1142
+ /**
1143
+ * Resolves an export from the context source file, following aliases and re-exports.
1144
+ *
1145
+ * @param context - Static build context created for the entry source file
1146
+ * @param exportName - Export name to resolve. Defaults to `"default"`.
1147
+ * @returns Resolved symbol for the export, or `null` when it cannot be found
1148
+ *
1149
+ * @public
1150
+ */
1151
+ export declare function resolveModuleExport(context: StaticBuildContext, exportName?: string): ts.Symbol | null;
1152
+
1153
+ /**
1154
+ * Resolves the declaration behind an export from the context source file,
1155
+ * following aliases and re-exports. This helper is intentionally limited to
1156
+ * declaration kinds accepted by declaration-driven schema generation.
1157
+ *
1158
+ * @param context - Static build context created for the entry source file
1159
+ * @param exportName - Export name to resolve. Defaults to `"default"`.
1160
+ * @returns Resolved class, interface, or type-alias declaration for the export,
1161
+ * or `null` when the export does not resolve to one of those schema-source kinds
1162
+ *
1163
+ * @public
1164
+ */
1165
+ export declare function resolveModuleExportDeclaration(context: StaticBuildContext, exportName?: string): ts.ClassDeclaration | ts.InterfaceDeclaration | ts.TypeAliasDeclaration | null;
1166
+
225
1167
  /**
226
1168
  * Rule for conditional element visibility/enablement.
1169
+ *
1170
+ * @public
227
1171
  */
228
1172
  export declare interface Rule {
229
- effect: RuleEffect;
230
- condition: SchemaBasedCondition;
1173
+ /** UI effect to apply when the rule condition matches. */
1174
+ readonly effect: RuleEffect;
1175
+ /** Predicate that controls when the UI effect applies. */
1176
+ readonly condition: SchemaBasedCondition;
231
1177
  }
232
1178
 
233
1179
  /**
234
- * JSON Schema subset for rule conditions.
1180
+ * JSON Schema subset used in rule conditions.
1181
+ *
1182
+ * @public
235
1183
  */
236
- declare interface RuleConditionSchema {
1184
+ export declare interface RuleConditionSchema {
1185
+ /** Literal value the condition schema must equal. */
237
1186
  const?: unknown;
1187
+ /** Allowed values for the condition schema. */
238
1188
  enum?: readonly unknown[];
1189
+ /** JSON Schema type required by the condition schema. */
239
1190
  type?: string;
1191
+ /** Negated branch of the condition schema. */
1192
+ not?: RuleConditionSchema;
1193
+ /** Inclusive numeric lower bound in the condition schema. */
240
1194
  minimum?: number;
1195
+ /** Inclusive numeric upper bound in the condition schema. */
241
1196
  maximum?: number;
1197
+ /** Exclusive numeric lower bound in the condition schema. */
1198
+ exclusiveMinimum?: number;
1199
+ /** Exclusive numeric upper bound in the condition schema. */
1200
+ exclusiveMaximum?: number;
1201
+ /** Inclusive minimum string length in the condition schema. */
1202
+ minLength?: number;
1203
+ /** Nested property conditions keyed by property name. */
242
1204
  properties?: Record<string, RuleConditionSchema>;
1205
+ /** Property names that must be present for the condition to match. */
1206
+ required?: string[];
1207
+ /** Schemas that must all match for the condition to succeed. */
243
1208
  allOf?: RuleConditionSchema[];
244
1209
  }
245
1210
 
1211
+ /**
1212
+ * JSON Forms UI Schema type definitions.
1213
+ *
1214
+ * These are the consumer-facing TypeScript shapes. Runtime validation remains
1215
+ * defined separately in `./schema.ts`.
1216
+ *
1217
+ * See: https://jsonforms.io/docs/uischema/
1218
+ */
246
1219
  /**
247
1220
  * Rule effect types for conditional visibility.
1221
+ *
1222
+ * @public
248
1223
  */
249
1224
  export declare type RuleEffect = "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
250
1225
 
251
1226
  /**
252
1227
  * Condition for a rule.
1228
+ *
1229
+ * @public
253
1230
  */
254
1231
  export declare interface SchemaBasedCondition {
255
- scope: string;
256
- schema: RuleConditionSchema;
1232
+ /** JSON Pointer scope the rule evaluates against. */
1233
+ readonly scope: string;
1234
+ /** JSON Schema fragment evaluated at the scoped location. */
1235
+ readonly schema: RuleConditionSchema;
1236
+ }
1237
+
1238
+ /**
1239
+ * A batch target for non-throwing schema generation.
1240
+ *
1241
+ * @public
1242
+ */
1243
+ export declare interface SchemaGenerationTarget {
1244
+ /** Path to the TypeScript source file. */
1245
+ readonly filePath: string;
1246
+ /** Name of the exported class, interface, or type alias to analyze. */
1247
+ readonly typeName: string;
1248
+ }
1249
+
1250
+ /**
1251
+ * Supported declaration kinds for declaration-driven schema generation.
1252
+ *
1253
+ * @public
1254
+ */
1255
+ export declare type SchemaSourceDeclaration = ts.ClassDeclaration | ts.InterfaceDeclaration | ts.TypeAliasDeclaration;
1256
+
1257
+ /**
1258
+ * Supported compiler context for static build-time analysis workflows.
1259
+ *
1260
+ * This context gives consumers access to the TypeScript program, checker, and
1261
+ * source file used to discover declarations before invoking FormSpec schema
1262
+ * generation helpers.
1263
+ *
1264
+ * @public
1265
+ */
1266
+ export declare interface StaticBuildContext {
1267
+ /** Host-owned or FormSpec-created TypeScript program. */
1268
+ readonly program: ts.Program;
1269
+ /** TypeScript checker for symbol and type analysis. */
1270
+ readonly checker: ts.TypeChecker;
1271
+ /** Source file used as the entry module for export resolution. */
1272
+ readonly sourceFile: ts.SourceFile;
257
1273
  }
258
1274
 
1275
+ export { StaticEnumField }
1276
+
259
1277
  /**
260
- * Root UI Schema (always a layout).
1278
+ * Shared options for schema generation flows that support custom extensions.
1279
+ *
1280
+ * @public
261
1281
  */
262
- export declare type UISchema = VerticalLayout | HorizontalLayout | GroupLayout;
1282
+ export declare interface StaticSchemaGenerationOptions {
1283
+ /**
1284
+ * Registry used to resolve custom types, constraints, and annotations.
1285
+ */
1286
+ readonly extensionRegistry?: ExtensionRegistry | undefined;
1287
+ /**
1288
+ * Vendor prefix for emitted extension keywords.
1289
+ * @defaultValue "x-formspec"
1290
+ */
1291
+ readonly vendorPrefix?: string | undefined;
1292
+ /**
1293
+ * JSON Schema representation to use for static enums.
1294
+ * @defaultValue "enum"
1295
+ */
1296
+ readonly enumSerialization?: "enum" | "oneOf";
1297
+ /** Metadata resolution policy for static schema generation. */
1298
+ readonly metadata?: MetadataPolicyInput | undefined;
1299
+ /** Discriminator-specific schema generation behavior. */
1300
+ readonly discriminator?: DiscriminatorResolutionOptions | undefined;
1301
+ }
1302
+
1303
+ export { TextField }
1304
+
1305
+ /**
1306
+ * Root UI Schema (always a layout — not a Control, Category, or Label).
1307
+ *
1308
+ * @public
1309
+ */
1310
+ export declare type UISchema = VerticalLayout | HorizontalLayout | GroupLayout | Categorization;
263
1311
 
264
1312
  /**
265
1313
  * Union of all UI Schema element types.
1314
+ *
1315
+ * @public
266
1316
  */
267
- export declare type UISchemaElement = ControlElement | VerticalLayout | HorizontalLayout | GroupLayout;
1317
+ export declare type UISchemaElement = ControlElement | VerticalLayout | HorizontalLayout | GroupLayout | Categorization | Category | LabelElement;
268
1318
 
269
1319
  /**
270
1320
  * Base interface for all UI Schema elements.
1321
+ *
1322
+ * This is a manually maintained interface representing the common shape
1323
+ * shared by all element types. It is kept as an interface (rather than
1324
+ * derived from Zod) because it is the base of a discriminated union, not
1325
+ * a union member itself.
1326
+ *
1327
+ * @public
271
1328
  */
272
- declare interface UISchemaElementBase {
1329
+ export declare interface UISchemaElementBase {
1330
+ /** Discriminator for the concrete JSON Forms element type. */
273
1331
  type: UISchemaElementType;
1332
+ /** Optional rule controlling visibility or enablement. */
274
1333
  rule?: Rule;
1334
+ /** Renderer-specific options shared by UI schema elements. */
275
1335
  options?: Record<string, unknown>;
276
1336
  }
277
1337
 
278
1338
  /**
279
- * JSON Forms UI Schema type definitions.
1339
+ * UI Schema element types.
280
1340
  *
281
- * These types define the UI layout structure for JSON Forms.
282
- * See: https://jsonforms.io/docs/uischema/
1341
+ * @public
283
1342
  */
1343
+ export declare type UISchemaElementType = "Control" | "VerticalLayout" | "HorizontalLayout" | "Group" | "Categorization" | "Category" | "Label";
1344
+
284
1345
  /**
285
- * UI Schema element types.
1346
+ * Zod schema for the root UI Schema (layout types only).
1347
+ *
1348
+ * @public
286
1349
  */
287
- export declare type UISchemaElementType = "Control" | "VerticalLayout" | "HorizontalLayout" | "Group" | "Categorization" | "Category";
1350
+ export declare const uiSchemaSchema: z.ZodType<UISchema>;
1351
+
1352
+ /**
1353
+ * Options for validating canonical FormIR.
1354
+ *
1355
+ * @public
1356
+ */
1357
+ export declare interface ValidateIROptions {
1358
+ /** Vendor prefix used when resolving extension-backed keywords. */
1359
+ readonly vendorPrefix?: string;
1360
+ /** Extension registry used to resolve custom constraints and types. */
1361
+ readonly extensionRegistry?: ExtensionRegistry;
1362
+ }
1363
+
1364
+ /**
1365
+ * A machine-readable validation diagnostic returned by static schema analysis.
1366
+ *
1367
+ * @public
1368
+ */
1369
+ export declare interface ValidationDiagnostic {
1370
+ /** Stable machine-readable diagnostic code. */
1371
+ readonly code: string;
1372
+ /** Human-readable explanation of the validation problem. */
1373
+ readonly message: string;
1374
+ /** Severity of the reported validation problem. */
1375
+ readonly severity: ValidationDiagnosticSeverity;
1376
+ /** Primary source location associated with the diagnostic. */
1377
+ readonly primaryLocation: ValidationDiagnosticLocation;
1378
+ /** Related source locations that add context to the diagnostic. */
1379
+ readonly relatedLocations: readonly ValidationDiagnosticLocation[];
1380
+ }
1381
+
1382
+ /**
1383
+ * Public source-location shape attached to validation diagnostics.
1384
+ *
1385
+ * This mirrors the provenance information surfaced by the shared analysis
1386
+ * layer without exposing `@formspec/core/internals` through the public API.
1387
+ *
1388
+ * @public
1389
+ */
1390
+ export declare interface ValidationDiagnosticLocation {
1391
+ /** Authoring surface that produced the diagnostic location. */
1392
+ readonly surface: "tsdoc" | "chain-dsl" | "extension" | "inferred";
1393
+ /** Absolute path to the source file. */
1394
+ readonly file: string;
1395
+ /** 1-based line number in the source file. */
1396
+ readonly line: number;
1397
+ /** 0-based column number in the source file. */
1398
+ readonly column: number;
1399
+ /** Optional span length in characters. */
1400
+ readonly length?: number;
1401
+ /** Optional tag or construct associated with the location. */
1402
+ readonly tagName?: string;
1403
+ }
1404
+
1405
+ /**
1406
+ * Supported severity levels returned by static build validation.
1407
+ *
1408
+ * @public
1409
+ */
1410
+ export declare type ValidationDiagnosticSeverity = "error" | "warning";
1411
+
1412
+ /**
1413
+ * Result of validating canonical FormIR before schema emission.
1414
+ *
1415
+ * @public
1416
+ */
1417
+ export declare interface ValidationResult {
1418
+ /** Diagnostics produced during validation. */
1419
+ readonly diagnostics: readonly ValidationDiagnostic[];
1420
+ /** Whether any error-severity diagnostics were produced. */
1421
+ readonly valid: boolean;
1422
+ }
288
1423
 
289
1424
  /**
290
1425
  * A vertical layout element.
1426
+ *
1427
+ * @public
291
1428
  */
292
- export declare interface VerticalLayout extends UISchemaElementBase {
293
- type: "VerticalLayout";
294
- elements: UISchemaElement[];
1429
+ export declare interface VerticalLayout {
1430
+ /** Discriminator identifying a vertical layout container. */
1431
+ readonly type: "VerticalLayout";
1432
+ /** Child elements rendered in vertical order. */
1433
+ readonly elements: UISchemaElement[];
1434
+ /** Optional rule controlling visibility or enablement. */
1435
+ readonly rule?: Rule | undefined;
1436
+ /** Renderer-specific layout options. */
1437
+ readonly options?: Record<string, unknown> | undefined;
1438
+ /** Additional renderer-specific extension properties. */
1439
+ readonly [k: string]: unknown;
295
1440
  }
296
1441
 
297
1442
  /**
@@ -322,13 +1467,17 @@ export declare interface VerticalLayout extends UISchemaElementBase {
322
1467
  * @param form - The FormSpec to build schemas from
323
1468
  * @param options - Output options (directory, file name, indentation)
324
1469
  * @returns Object containing paths to the generated files
1470
+ *
1471
+ * @public
325
1472
  */
326
1473
  export declare function writeSchemas<E extends readonly FormElement[]>(form: FormSpec<E>, options: WriteSchemasOptions): WriteSchemasResult;
327
1474
 
328
1475
  /**
329
1476
  * Options for writing schemas to disk.
1477
+ *
1478
+ * @public
330
1479
  */
331
- export declare interface WriteSchemasOptions {
1480
+ export declare interface WriteSchemasOptions extends GenerateJsonSchemaOptions {
332
1481
  /** Output directory for the schema files */
333
1482
  readonly outDir: string;
334
1483
  /** Base name for the output files (without extension). Defaults to "schema" */
@@ -339,6 +1488,8 @@ export declare interface WriteSchemasOptions {
339
1488
 
340
1489
  /**
341
1490
  * Result of writing schemas to disk.
1491
+ *
1492
+ * @public
342
1493
  */
343
1494
  export declare interface WriteSchemasResult {
344
1495
  /** Path to the generated JSON Schema file */