@formspec/build 0.1.0-alpha.11 → 0.1.0-alpha.13

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 (135) hide show
  1. package/README.md +51 -15
  2. package/dist/__tests__/chain-dsl-canonicalizer.test.d.ts +2 -0
  3. package/dist/__tests__/chain-dsl-canonicalizer.test.d.ts.map +1 -0
  4. package/dist/__tests__/constraint-validator.test.d.ts +2 -0
  5. package/dist/__tests__/constraint-validator.test.d.ts.map +1 -0
  6. package/dist/__tests__/extension-api.test.d.ts +2 -0
  7. package/dist/__tests__/extension-api.test.d.ts.map +1 -0
  8. package/dist/__tests__/fixtures/example-a-builtins.d.ts +18 -0
  9. package/dist/__tests__/fixtures/example-a-builtins.d.ts.map +1 -1
  10. package/dist/__tests__/guards.test.d.ts +2 -0
  11. package/dist/__tests__/guards.test.d.ts.map +1 -0
  12. package/dist/__tests__/ir-analyzer.test.d.ts +11 -0
  13. package/dist/__tests__/ir-analyzer.test.d.ts.map +1 -0
  14. package/dist/__tests__/ir-jsdoc-constraints.test.d.ts +12 -0
  15. package/dist/__tests__/ir-jsdoc-constraints.test.d.ts.map +1 -0
  16. package/dist/__tests__/ir-json-schema-generator.test.d.ts +11 -0
  17. package/dist/__tests__/ir-json-schema-generator.test.d.ts.map +1 -0
  18. package/dist/__tests__/ir-ui-schema-generator.test.d.ts +2 -0
  19. package/dist/__tests__/ir-ui-schema-generator.test.d.ts.map +1 -0
  20. package/dist/__tests__/jsdoc-constraints.test.d.ts +4 -4
  21. package/dist/__tests__/parity/fixtures/address/chain-dsl.d.ts +9 -0
  22. package/dist/__tests__/parity/fixtures/address/chain-dsl.d.ts.map +1 -0
  23. package/dist/__tests__/parity/fixtures/address/expected-ir.d.ts +9 -0
  24. package/dist/__tests__/parity/fixtures/address/expected-ir.d.ts.map +1 -0
  25. package/dist/__tests__/parity/fixtures/address/tsdoc.d.ts +19 -0
  26. package/dist/__tests__/parity/fixtures/address/tsdoc.d.ts.map +1 -0
  27. package/dist/__tests__/parity/fixtures/product-config/chain-dsl.d.ts +13 -0
  28. package/dist/__tests__/parity/fixtures/product-config/chain-dsl.d.ts.map +1 -0
  29. package/dist/__tests__/parity/fixtures/product-config/expected-ir.d.ts +9 -0
  30. package/dist/__tests__/parity/fixtures/product-config/expected-ir.d.ts.map +1 -0
  31. package/dist/__tests__/parity/fixtures/product-config/tsdoc.d.ts +28 -0
  32. package/dist/__tests__/parity/fixtures/product-config/tsdoc.d.ts.map +1 -0
  33. package/dist/__tests__/parity/fixtures/user-registration/chain-dsl.d.ts +12 -0
  34. package/dist/__tests__/parity/fixtures/user-registration/chain-dsl.d.ts.map +1 -0
  35. package/dist/__tests__/parity/fixtures/user-registration/expected-ir.d.ts +9 -0
  36. package/dist/__tests__/parity/fixtures/user-registration/expected-ir.d.ts.map +1 -0
  37. package/dist/__tests__/parity/fixtures/user-registration/tsdoc.d.ts +19 -0
  38. package/dist/__tests__/parity/fixtures/user-registration/tsdoc.d.ts.map +1 -0
  39. package/dist/__tests__/parity/parity.test.d.ts +14 -0
  40. package/dist/__tests__/parity/parity.test.d.ts.map +1 -0
  41. package/dist/__tests__/parity/utils.d.ts +139 -0
  42. package/dist/__tests__/parity/utils.d.ts.map +1 -0
  43. package/dist/analyzer/class-analyzer.d.ts +54 -99
  44. package/dist/analyzer/class-analyzer.d.ts.map +1 -1
  45. package/dist/analyzer/jsdoc-constraints.d.ts +78 -30
  46. package/dist/analyzer/jsdoc-constraints.d.ts.map +1 -1
  47. package/dist/analyzer/tsdoc-parser.d.ts +61 -0
  48. package/dist/analyzer/tsdoc-parser.d.ts.map +1 -0
  49. package/dist/browser.cjs +998 -309
  50. package/dist/browser.cjs.map +1 -1
  51. package/dist/browser.d.ts +10 -6
  52. package/dist/browser.d.ts.map +1 -1
  53. package/dist/browser.js +996 -308
  54. package/dist/browser.js.map +1 -1
  55. package/dist/build.d.ts +65 -150
  56. package/dist/canonicalize/chain-dsl-canonicalizer.d.ts +18 -0
  57. package/dist/canonicalize/chain-dsl-canonicalizer.d.ts.map +1 -0
  58. package/dist/canonicalize/index.d.ts +8 -0
  59. package/dist/canonicalize/index.d.ts.map +1 -0
  60. package/dist/canonicalize/tsdoc-canonicalizer.d.ts +34 -0
  61. package/dist/canonicalize/tsdoc-canonicalizer.d.ts.map +1 -0
  62. package/dist/cli.cjs +1455 -1656
  63. package/dist/cli.cjs.map +1 -1
  64. package/dist/cli.js +1459 -1647
  65. package/dist/cli.js.map +1 -1
  66. package/dist/extensions/index.d.ts +8 -0
  67. package/dist/extensions/index.d.ts.map +1 -0
  68. package/dist/extensions/registry.d.ts +55 -0
  69. package/dist/extensions/registry.d.ts.map +1 -0
  70. package/dist/generators/class-schema.d.ts +23 -38
  71. package/dist/generators/class-schema.d.ts.map +1 -1
  72. package/dist/generators/method-schema.d.ts +6 -8
  73. package/dist/generators/method-schema.d.ts.map +1 -1
  74. package/dist/index.cjs +1391 -1614
  75. package/dist/index.cjs.map +1 -1
  76. package/dist/index.d.ts +6 -8
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +1403 -1610
  79. package/dist/index.js.map +1 -1
  80. package/dist/internals.cjs +1642 -824
  81. package/dist/internals.cjs.map +1 -1
  82. package/dist/internals.d.ts +12 -3
  83. package/dist/internals.d.ts.map +1 -1
  84. package/dist/internals.js +1645 -820
  85. package/dist/internals.js.map +1 -1
  86. package/dist/json-schema/generator.d.ts +10 -5
  87. package/dist/json-schema/generator.d.ts.map +1 -1
  88. package/dist/json-schema/ir-generator.d.ts +84 -0
  89. package/dist/json-schema/ir-generator.d.ts.map +1 -0
  90. package/dist/json-schema/schema.d.ts +3 -3
  91. package/dist/json-schema/types.d.ts +5 -6
  92. package/dist/json-schema/types.d.ts.map +1 -1
  93. package/dist/ui-schema/generator.d.ts +5 -15
  94. package/dist/ui-schema/generator.d.ts.map +1 -1
  95. package/dist/ui-schema/ir-generator.d.ts +53 -0
  96. package/dist/ui-schema/ir-generator.d.ts.map +1 -0
  97. package/dist/validate/constraint-validator.d.ts +66 -0
  98. package/dist/validate/constraint-validator.d.ts.map +1 -0
  99. package/dist/validate/index.d.ts +9 -0
  100. package/dist/validate/index.d.ts.map +1 -0
  101. package/package.json +5 -4
  102. package/dist/__tests__/analyzer-edge-cases.test.d.ts +0 -13
  103. package/dist/__tests__/analyzer-edge-cases.test.d.ts.map +0 -1
  104. package/dist/__tests__/analyzer.test.d.ts +0 -5
  105. package/dist/__tests__/analyzer.test.d.ts.map +0 -1
  106. package/dist/__tests__/codegen.test.d.ts +0 -5
  107. package/dist/__tests__/codegen.test.d.ts.map +0 -1
  108. package/dist/__tests__/decorator-pipeline.test.d.ts +0 -11
  109. package/dist/__tests__/decorator-pipeline.test.d.ts.map +0 -1
  110. package/dist/__tests__/fixtures/example-b-decorators.d.ts +0 -5
  111. package/dist/__tests__/fixtures/example-b-decorators.d.ts.map +0 -1
  112. package/dist/__tests__/fixtures/example-b-extended.d.ts +0 -5
  113. package/dist/__tests__/fixtures/example-b-extended.d.ts.map +0 -1
  114. package/dist/__tests__/fixtures/example-c-custom.d.ts +0 -5
  115. package/dist/__tests__/fixtures/example-c-custom.d.ts.map +0 -1
  116. package/dist/__tests__/fixtures/example-c-decorators.d.ts +0 -5
  117. package/dist/__tests__/fixtures/example-c-decorators.d.ts.map +0 -1
  118. package/dist/__tests__/fixtures/example-d-mixed-decorators.d.ts +0 -6
  119. package/dist/__tests__/fixtures/example-d-mixed-decorators.d.ts.map +0 -1
  120. package/dist/__tests__/fixtures/example-e-decorators.d.ts +0 -11
  121. package/dist/__tests__/fixtures/example-e-decorators.d.ts.map +0 -1
  122. package/dist/__tests__/fixtures/example-e-no-namespace.d.ts +0 -5
  123. package/dist/__tests__/fixtures/example-e-no-namespace.d.ts.map +0 -1
  124. package/dist/__tests__/fixtures/example-jsdoc-constraints.d.ts +0 -16
  125. package/dist/__tests__/fixtures/example-jsdoc-constraints.d.ts.map +0 -1
  126. package/dist/__tests__/fixtures/example-nested-class.d.ts +0 -45
  127. package/dist/__tests__/fixtures/example-nested-class.d.ts.map +0 -1
  128. package/dist/__tests__/interface-types.test.d.ts +0 -11
  129. package/dist/__tests__/interface-types.test.d.ts.map +0 -1
  130. package/dist/analyzer/decorator-extractor.d.ts +0 -78
  131. package/dist/analyzer/decorator-extractor.d.ts.map +0 -1
  132. package/dist/analyzer/type-converter.d.ts +0 -75
  133. package/dist/analyzer/type-converter.d.ts.map +0 -1
  134. package/dist/codegen/index.d.ts +0 -75
  135. package/dist/codegen/index.d.ts.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
@@ -60,8 +60,8 @@ export declare function buildFormSchemas<E extends readonly FormElement[]>(form:
60
60
  * Result of building form schemas.
61
61
  */
62
62
  export declare interface BuildResult {
63
- /** JSON Schema for validation */
64
- readonly jsonSchema: JSONSchema7;
63
+ /** JSON Schema 2020-12 for validation */
64
+ readonly jsonSchema: JsonSchema2020;
65
65
  /** JSON Forms UI Schema for rendering */
66
66
  readonly uiSchema: UISchema;
67
67
  }
@@ -98,24 +98,12 @@ export declare const categorySchema: z.ZodType<Category>;
98
98
  * Generated schemas for a class.
99
99
  */
100
100
  export declare interface ClassSchemas {
101
- /** JSON Schema for validation */
102
- jsonSchema: ExtendedJSONSchema7;
101
+ /** JSON Schema 2020-12 for validation */
102
+ jsonSchema: JsonSchema2020;
103
103
  /** JSON Forms UI Schema for rendering */
104
104
  uiSchema: UISchema;
105
105
  }
106
106
 
107
- /**
108
- * Options for code generation.
109
- */
110
- export declare interface CodegenOptions {
111
- /** Source files to analyze (glob patterns supported) */
112
- files: string[];
113
- /** Output file path */
114
- output: string;
115
- /** Base directory for relative imports */
116
- baseDir?: string;
117
- }
118
-
119
107
  /**
120
108
  * A Control element that binds to a JSON Schema property.
121
109
  */
@@ -216,66 +204,12 @@ export declare const controlSchema: z.ZodObject<{
216
204
  options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
217
205
  }, z.ZodTypeAny, "passthrough">>;
218
206
 
219
- /**
220
- * Information about a decorated class found during codegen analysis.
221
- *
222
- * Used to track which classes need type metadata patches and where
223
- * they are located in the source tree.
224
- */
225
- export declare interface DecoratedClassInfo {
226
- /** Class name as it appears in the source file */
227
- name: string;
228
- /** Import path to the source file (relative to output, without extension) */
229
- sourcePath: string;
230
- /** Type metadata for all decorated properties in the class */
231
- typeMetadata: Record<string, TypeMetadata>;
232
- /** Whether the class is exported from its source file */
233
- isExported: boolean;
234
- }
235
-
236
207
  /** JSON Schema with FormSpec extension properties for arbitrary x-formspec-* keys. */
237
208
  export declare type ExtendedJSONSchema7 = JSONSchema7 & FormSpecSchemaExtensions;
238
209
 
239
- /**
240
- * Finds all decorated classes in the given source files.
241
- */
242
- export declare function findDecoratedClasses(files: string[], baseDir: string): DecoratedClassInfo[];
243
-
244
- /**
245
- * FormSpec field definition (simplified for output).
246
- */
247
- export declare interface FormSpecField {
248
- _field: string;
249
- id: string;
250
- label?: string;
251
- placeholder?: string;
252
- description?: string;
253
- required?: boolean;
254
- min?: number;
255
- max?: number;
256
- step?: number;
257
- minLength?: number;
258
- maxLength?: number;
259
- minItems?: number;
260
- maxItems?: number;
261
- pattern?: string;
262
- options?: (string | {
263
- id: string;
264
- label: string;
265
- })[];
266
- showWhen?: object;
267
- group?: string;
268
- fields?: FormSpecField[];
269
- }
270
-
271
210
  /** Extension properties for custom FormSpec decorators. */
272
211
  export declare type FormSpecSchemaExtensions = Record<`x-formspec-${string}`, unknown>;
273
212
 
274
- /**
275
- * Generates the codegen output file content.
276
- */
277
- export declare function generateCodegenOutput(classes: DecoratedClassInfo[], outputPath: string, baseDir: string): string;
278
-
279
213
  /**
280
214
  * Options for generating schemas from a decorated class.
281
215
  */
@@ -290,14 +224,17 @@ export declare interface GenerateFromClassOptions {
290
224
  * Result of generating schemas from a decorated class.
291
225
  */
292
226
  export declare interface GenerateFromClassResult {
293
- /** JSON Schema for validation */
294
- jsonSchema: ExtendedJSONSchema7;
227
+ /** JSON Schema 2020-12 for validation */
228
+ jsonSchema: JsonSchema2020;
295
229
  /** JSON Forms UI Schema for rendering */
296
230
  uiSchema: UISchema;
297
231
  }
298
232
 
299
233
  /**
300
- * Generates a JSON Schema from a FormSpec.
234
+ * Generates a JSON Schema 2020-12 from a FormSpec.
235
+ *
236
+ * All generation routes through the canonical IR. The chain DSL is first
237
+ * canonicalized to a FormIR, then the IR-based generator produces the schema.
301
238
  *
302
239
  * @example
303
240
  * ```typescript
@@ -308,7 +245,7 @@ export declare interface GenerateFromClassResult {
308
245
  *
309
246
  * const schema = generateJsonSchema(form);
310
247
  * // {
311
- * // $schema: "https://json-schema.org/draft-07/schema#",
248
+ * // $schema: "https://json-schema.org/draft/2020-12/schema",
312
249
  * // type: "object",
313
250
  * // properties: {
314
251
  * // name: { type: "string", title: "Name" },
@@ -319,25 +256,20 @@ export declare interface GenerateFromClassResult {
319
256
  * ```
320
257
  *
321
258
  * @param form - The FormSpec to convert
322
- * @returns A JSON Schema object
259
+ * @returns A JSON Schema 2020-12 object
323
260
  */
324
- export declare function generateJsonSchema<E extends readonly FormElement[]>(form: FormSpec<E>): JSONSchema7;
261
+ export declare function generateJsonSchema<E extends readonly FormElement[]>(form: FormSpec<E>): JsonSchema2020;
325
262
 
326
263
  /**
327
- * Generates JSON Schema and FormSpec/UI Schema from a named TypeScript
264
+ * Generates JSON Schema and UI Schema from a named TypeScript
328
265
  * type — a decorated class, an interface with TSDoc tags, or a type alias.
329
266
  *
330
267
  * This is the recommended entry point. It automatically detects whether
331
268
  * the name resolves to a class, interface, or type alias and uses the
332
- * appropriate analysis pipeline:
333
- *
334
- * - **Classes**: extracts decorators and JSDoc constraints
335
- * - **Interfaces**: extracts TSDoc tags (`@Field_displayName`, `@Minimum`, etc.)
336
- * - **Type aliases**: object literal bodies analyzed like interfaces
269
+ * appropriate IR analysis pipeline.
337
270
  *
338
271
  * @example
339
272
  * ```typescript
340
- * // Works with both classes and interfaces — caller doesn't need to know
341
273
  * const result = generateSchemas({
342
274
  * filePath: "./src/config.ts",
343
275
  * typeName: "DiscountConfig",
@@ -345,15 +277,15 @@ export declare function generateJsonSchema<E extends readonly FormElement[]>(for
345
277
  * ```
346
278
  *
347
279
  * @param options - File path and type name
348
- * @returns Generated JSON Schema and FormSpec/UI Schema
280
+ * @returns Generated JSON Schema and UI Schema
349
281
  */
350
282
  export declare function generateSchemas(options: GenerateSchemasOptions): GenerateFromClassResult;
351
283
 
352
284
  /**
353
- * Generates JSON Schema and FormSpec/UI Schema from a decorated TypeScript class.
285
+ * Generates JSON Schema and UI Schema from a decorated TypeScript class.
354
286
  *
355
287
  * This is a high-level entry point that handles the entire pipeline:
356
- * creating a TypeScript program, finding the class, analyzing it,
288
+ * creating a TypeScript program, finding the class, analyzing it to IR,
357
289
  * and generating schemas — all in one call.
358
290
  *
359
291
  * @example
@@ -366,7 +298,7 @@ export declare function generateSchemas(options: GenerateSchemasOptions): Genera
366
298
  * ```
367
299
  *
368
300
  * @param options - File path, class name, and optional compiler options
369
- * @returns Generated JSON Schema and FormSpec/UI Schema
301
+ * @returns Generated JSON Schema and UI Schema
370
302
  */
371
303
  export declare function generateSchemasFromClass(options: GenerateFromClassOptions): GenerateFromClassResult;
372
304
 
@@ -383,6 +315,9 @@ export declare interface GenerateSchemasOptions {
383
315
  /**
384
316
  * Generates a JSON Forms UI Schema from a FormSpec.
385
317
  *
318
+ * All generation routes through the canonical IR. The chain DSL is first
319
+ * canonicalized to a FormIR, then the IR-based generator produces the schema.
320
+ *
386
321
  * @example
387
322
  * ```typescript
388
323
  * const form = formspec(
@@ -423,32 +358,16 @@ export declare interface GenerateSchemasOptions {
423
358
  */
424
359
  export declare function generateUiSchema<E extends readonly FormElement[]>(form: FormSpec<E>): UISchema;
425
360
 
426
- /**
427
- * Converts FormSpecField[] (from decorator/interface/type analysis) to a JSON Forms UISchema.
428
- *
429
- * Mapping:
430
- * - Each field → `{ type: "Control", scope: "#/properties/{id}", label? }`
431
- * - `showWhen: { field, value }` → rule with SHOW effect
432
- * - `group` property → Groups fields by group name, preserving insertion order
433
- * - `fields` (nested object) → single Control pointing to the object property
434
- * - Root wrapper → `{ type: "VerticalLayout", elements }`
435
- *
436
- * @param fields - The FormSpecField array to convert
437
- * @returns A JSON Forms UISchema
438
- */
439
- export declare function generateUiSchemaFromFields(fields: FormSpecField[]): UISchema;
440
-
441
361
  /**
442
362
  * Reads a FormSpec extension property from a JSON Schema node.
443
363
  *
444
- * Use this to safely read `x-formspec-*` properties from any schema,
445
- * including nested schemas typed as `JSONSchema7`.
364
+ * Accepts any schema object `JSONSchema7`, `JsonSchema2020`, `ExtendedJSONSchema7`, etc.
446
365
  *
447
366
  * @param schema - Any JSON Schema node
448
367
  * @param key - Extension key (must start with `x-formspec-`)
449
368
  * @returns The extension value, or `undefined` if not present
450
369
  */
451
- export declare function getSchemaExtension(schema: JSONSchema7, key: `x-formspec-${string}`): unknown;
370
+ export declare function getSchemaExtension(schema: object, key: `x-formspec-${string}`): unknown;
452
371
 
453
372
  /**
454
373
  * A group element with a label.
@@ -478,7 +397,44 @@ export declare interface HorizontalLayout {
478
397
  export declare const horizontalLayoutSchema: z.ZodType<HorizontalLayout>;
479
398
 
480
399
  /**
481
- * A JSON Schema definition (draft-07 subset).
400
+ * A JSON Schema 2020-12 document, sub-schema, or keyword collection.
401
+ *
402
+ * This interface covers the subset of JSON Schema 2020-12 that this generator
403
+ * emits, plus an index signature for custom `x-formspec-*` extension keywords.
404
+ */
405
+ export declare interface JsonSchema2020 {
406
+ $schema?: string;
407
+ $ref?: string;
408
+ $defs?: Record<string, JsonSchema2020>;
409
+ type?: string;
410
+ properties?: Record<string, JsonSchema2020>;
411
+ required?: string[];
412
+ items?: JsonSchema2020;
413
+ additionalProperties?: boolean;
414
+ enum?: readonly (string | number)[];
415
+ const?: string | number | boolean | null;
416
+ oneOf?: readonly JsonSchema2020[];
417
+ anyOf?: readonly JsonSchema2020[];
418
+ minimum?: number;
419
+ maximum?: number;
420
+ exclusiveMinimum?: number;
421
+ exclusiveMaximum?: number;
422
+ multipleOf?: number;
423
+ minLength?: number;
424
+ maxLength?: number;
425
+ minItems?: number;
426
+ maxItems?: number;
427
+ pattern?: string;
428
+ uniqueItems?: boolean;
429
+ title?: string;
430
+ description?: string;
431
+ default?: unknown;
432
+ deprecated?: boolean;
433
+ [key: `x-${string}`]: unknown;
434
+ }
435
+
436
+ /**
437
+ * A JSON Schema definition (legacy subset used by Zod validator and types.ts).
482
438
  */
483
439
  export declare interface JSONSchema7 {
484
440
  $schema?: string;
@@ -532,7 +488,7 @@ export declare interface JSONSchema7 {
532
488
  export declare const jsonSchema7Schema: z.ZodType<JSONSchema7>;
533
489
 
534
490
  /**
535
- * JSON Schema Draft-07 type definitions.
491
+ * JSON Schema type definitions.
536
492
  *
537
493
  * These types are a subset of JSON Schema sufficient for form generation.
538
494
  */
@@ -707,11 +663,6 @@ export declare const ruleSchema: z.ZodObject<{
707
663
  };
708
664
  }>;
709
665
 
710
- /**
711
- * Runs the code generation.
712
- */
713
- export declare function runCodegen(options: CodegenOptions): void;
714
-
715
666
  /**
716
667
  * Condition for a rule.
717
668
  */
@@ -742,43 +693,7 @@ export declare const schemaBasedConditionSchema: z.ZodObject<{
742
693
  * @param key - Extension key (must start with `x-formspec-`)
743
694
  * @param value - Extension value
744
695
  */
745
- export declare function setSchemaExtension(schema: JSONSchema7, key: `x-formspec-${string}`, value: unknown): void;
746
-
747
- /**
748
- * Code generation for FormSpec type metadata.
749
- *
750
- * Generates a TypeScript file that patches decorated classes with
751
- * their extracted type metadata, enabling runtime schema generation
752
- * as an alternative to a TypeScript transformer.
753
- *
754
- * Usage:
755
- * formspec codegen ./src/forms.ts -o ./src/__formspec_types__.ts
756
- *
757
- * Then in your code:
758
- * import './__formspec_types__'; // Patches all decorated classes
759
- * import { UserFormSchema, getUserFormFormSpec } from './__formspec_types__';
760
- * const spec = getUserFormFormSpec();
761
- */
762
- /**
763
- * Type metadata format used by `@formspec/decorators`.
764
- *
765
- * Represents the runtime type information for a field that TypeScript
766
- * normally erases at compile time.
767
- */
768
- export declare interface TypeMetadata {
769
- /** Base type: "string", "number", "boolean", "enum", "array", "object", "unknown" */
770
- type: string;
771
- /** For enum types, the possible literal values */
772
- values?: unknown[];
773
- /** For array types, metadata about the array element type */
774
- itemType?: TypeMetadata;
775
- /** For object types, metadata about each property */
776
- properties?: Record<string, TypeMetadata>;
777
- /** Whether the field accepts null */
778
- nullable?: boolean;
779
- /** Whether the field is optional (T | undefined or ?: modifier) */
780
- optional?: boolean;
781
- }
696
+ export declare function setSchemaExtension(schema: object, key: `x-formspec-${string}`, value: unknown): void;
782
697
 
783
698
  /**
784
699
  * Root UI Schema (always a layout — not a Control, Category, or Label).
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Canonicalizer that translates chain DSL `FormSpec` objects into the
3
+ * canonical FormIR intermediate representation.
4
+ *
5
+ * This module maps the runtime objects produced by `@formspec/dsl` builder
6
+ * functions (`field.*`, `group`, `when`, `formspec`) into the IR that all
7
+ * downstream phases (validation, JSON Schema generation, UI Schema generation)
8
+ * consume.
9
+ */
10
+ import type { FormElement, FormSpec, FormIR } from "@formspec/core";
11
+ /**
12
+ * Translates a chain DSL `FormSpec` into the canonical `FormIR`.
13
+ *
14
+ * @param form - A form specification created via `formspec(...)` from `@formspec/dsl`
15
+ * @returns The canonical intermediate representation
16
+ */
17
+ export declare function canonicalizeChainDSL(form: FormSpec<readonly FormElement[]>): FormIR;
18
+ //# sourceMappingURL=chain-dsl-canonicalizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain-dsl-canonicalizer.d.ts","sourceRoot":"","sources":["../../src/canonicalize/chain-dsl-canonicalizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EASV,WAAW,EACX,QAAQ,EAiBR,MAAM,EAYP,MAAM,gBAAgB,CAAC;AAqCxB;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,WAAW,EAAE,CAAC,GAAG,MAAM,CAQnF"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Canonicalization layer — converts authoring surface output to canonical IR.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export { canonicalizeChainDSL } from "./chain-dsl-canonicalizer.js";
7
+ export { canonicalizeTSDoc, type TSDocSource } from "./tsdoc-canonicalizer.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/canonicalize/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * TSDoc canonicalizer — assembles an {@link IRClassAnalysis} into a canonical
3
+ * {@link FormIR}, applying layout metadata from `@Group` and `@ShowWhen`
4
+ * decorators.
5
+ *
6
+ * The analysis functions in `class-analyzer.ts` produce `FieldNode[]`,
7
+ * `fieldLayouts`, and `typeRegistry` directly. This canonicalizer uses
8
+ * the layout metadata to wrap fields in `GroupLayoutNode` and
9
+ * `ConditionalLayoutNode` elements.
10
+ */
11
+ import type { FormIR } from "@formspec/core";
12
+ import type { IRClassAnalysis } from "../analyzer/class-analyzer.js";
13
+ /**
14
+ * Source-level metadata for provenance tracking.
15
+ */
16
+ export interface TSDocSource {
17
+ /** Absolute path to the source file. */
18
+ readonly file: string;
19
+ }
20
+ /**
21
+ * Wraps an {@link IRClassAnalysis} (from `analyzeClassToIR`,
22
+ * `analyzeInterfaceToIR`, or `analyzeTypeAliasToIR`) into a canonical
23
+ * {@link FormIR}.
24
+ *
25
+ * Fields with `@Group` decorators are grouped into `GroupLayoutNode` elements.
26
+ * Fields with `@ShowWhen` decorators are wrapped in `ConditionalLayoutNode` elements.
27
+ * When both are present, the conditional wraps the field inside the group.
28
+ *
29
+ * @param analysis - IR analysis result (fields are already FieldNode[])
30
+ * @param source - Optional source file metadata for provenance
31
+ * @returns The canonical FormIR
32
+ */
33
+ export declare function canonicalizeTSDoc(analysis: IRClassAnalysis, source?: TSDocSource): FormIR;
34
+ //# sourceMappingURL=tsdoc-canonicalizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsdoc-canonicalizer.d.ts","sourceRoot":"","sources":["../../src/canonicalize/tsdoc-canonicalizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,MAAM,EAMP,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,eAAe,EAAuB,MAAM,+BAA+B,CAAC;AAE1F;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,wCAAwC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,CAmBzF"}