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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +85 -0
  2. package/dist/__tests__/constraint-definitions.test.d.ts +2 -0
  3. package/dist/__tests__/constraint-definitions.test.d.ts.map +1 -0
  4. package/dist/__tests__/guards.test.d.ts +2 -0
  5. package/dist/__tests__/guards.test.d.ts.map +1 -0
  6. package/dist/core.d.ts +1459 -0
  7. package/dist/extensions/index.d.ts +252 -0
  8. package/dist/extensions/index.d.ts.map +1 -0
  9. package/dist/guards.d.ts +73 -0
  10. package/dist/guards.d.ts.map +1 -0
  11. package/dist/index.cjs +159 -0
  12. package/dist/index.cjs.map +1 -0
  13. package/dist/index.d.ts +6 -2
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +111 -12
  16. package/dist/index.js.map +1 -1
  17. package/dist/types/constraint-definitions.d.ts +64 -0
  18. package/dist/types/constraint-definitions.d.ts.map +1 -0
  19. package/dist/types/data-source.d.ts +8 -0
  20. package/dist/types/data-source.d.ts.map +1 -1
  21. package/dist/types/elements.d.ts +40 -0
  22. package/dist/types/elements.d.ts.map +1 -1
  23. package/dist/types/field-state.d.ts +4 -0
  24. package/dist/types/field-state.d.ts.map +1 -1
  25. package/dist/types/form-state.d.ts +2 -0
  26. package/dist/types/form-state.d.ts.map +1 -1
  27. package/dist/types/index.d.ts +4 -0
  28. package/dist/types/index.d.ts.map +1 -1
  29. package/dist/types/ir.d.ts +578 -0
  30. package/dist/types/ir.d.ts.map +1 -0
  31. package/dist/types/predicate.d.ts +4 -0
  32. package/dist/types/predicate.d.ts.map +1 -1
  33. package/dist/types/validity.d.ts +2 -0
  34. package/dist/types/validity.d.ts.map +1 -1
  35. package/package.json +17 -5
  36. package/dist/types/data-source.js +0 -2
  37. package/dist/types/data-source.js.map +0 -1
  38. package/dist/types/elements.js +0 -8
  39. package/dist/types/elements.js.map +0 -1
  40. package/dist/types/field-state.js +0 -17
  41. package/dist/types/field-state.js.map +0 -1
  42. package/dist/types/form-state.js +0 -2
  43. package/dist/types/form-state.js.map +0 -1
  44. package/dist/types/index.js +0 -3
  45. package/dist/types/index.js.map +0 -1
  46. package/dist/types/predicate.js +0 -7
  47. package/dist/types/predicate.js.map +0 -1
  48. package/dist/types/validity.js +0 -2
  49. package/dist/types/validity.js.map +0 -1
package/dist/core.d.ts ADDED
@@ -0,0 +1,1459 @@
1
+ /**
2
+ * `@formspec/core` - Core type definitions for FormSpec
3
+ *
4
+ * This package provides the foundational types used throughout the FormSpec ecosystem:
5
+ * - Form element types (fields, groups, conditionals)
6
+ * - Field and form state types
7
+ * - Data source registry for dynamic enums
8
+ * - Canonical IR types (FormIR, FieldNode, TypeNode, ConstraintNode, AnnotationNode, etc.)
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+
13
+ /**
14
+ * Discriminated union of all annotation types.
15
+ * Annotations are value-influencing: they describe or present a field
16
+ * but do not affect which values are valid.
17
+ *
18
+ * @public
19
+ */
20
+ export declare type AnnotationNode = DisplayNameAnnotationNode | DescriptionAnnotationNode | RemarksAnnotationNode | FormatAnnotationNode | PlaceholderAnnotationNode | DefaultValueAnnotationNode | DeprecatedAnnotationNode | FormatHintAnnotationNode | CustomAnnotationNode;
21
+
22
+ /**
23
+ * Union of all field types.
24
+ *
25
+ * @public
26
+ */
27
+ export declare type AnyField = TextField<string> | NumberField<string> | BooleanField<string> | StaticEnumField<string, readonly EnumOptionValue[]> | DynamicEnumField<string, string> | DynamicSchemaField<string> | ArrayField<string, readonly FormElement[]> | ObjectField<string, readonly FormElement[]>;
28
+
29
+ /**
30
+ * Array uniqueness constraint.
31
+ *
32
+ * @public
33
+ */
34
+ export declare interface ArrayCardinalityConstraintNode {
35
+ readonly kind: "constraint";
36
+ readonly constraintKind: "uniqueItems";
37
+ readonly value: true;
38
+ readonly path?: PathTarget;
39
+ readonly provenance: Provenance;
40
+ }
41
+
42
+ /**
43
+ * An array field containing repeating items.
44
+ *
45
+ * Use this for lists of values (e.g., multiple addresses, line items).
46
+ *
47
+ * @typeParam N - The field name (string literal type)
48
+ * @typeParam Items - The form elements that define each array item
49
+ *
50
+ * @public
51
+ */
52
+ export declare interface ArrayField<N extends string, Items extends readonly FormElement[]> {
53
+ /** Type discriminator for form elements */
54
+ readonly _type: "field";
55
+ /** Field type discriminator - identifies this as an array field */
56
+ readonly _field: "array";
57
+ /** Unique field identifier used as the schema key */
58
+ readonly name: N;
59
+ /** Form elements that define the schema for each array item */
60
+ readonly items: Items;
61
+ /** Display label for the field */
62
+ readonly label?: string;
63
+ /** Whether this field is required for form submission */
64
+ readonly required?: boolean;
65
+ /** Minimum number of items required */
66
+ readonly minItems?: number;
67
+ /** Maximum number of items allowed */
68
+ readonly maxItems?: number;
69
+ }
70
+
71
+ /**
72
+ * Array type with a single items type.
73
+ *
74
+ * @public
75
+ */
76
+ export declare interface ArrayTypeNode {
77
+ readonly kind: "array";
78
+ readonly items: TypeNode;
79
+ }
80
+
81
+ /**
82
+ * A boolean checkbox field.
83
+ *
84
+ * @typeParam N - The field name (string literal type)
85
+ *
86
+ * @public
87
+ */
88
+ export declare interface BooleanField<N extends string> {
89
+ /** Type discriminator for form elements */
90
+ readonly _type: "field";
91
+ /** Field type discriminator - identifies this as a boolean field */
92
+ readonly _field: "boolean";
93
+ /** Unique field identifier used as the schema key */
94
+ readonly name: N;
95
+ /** Display label for the field */
96
+ readonly label?: string;
97
+ /** Whether this field is required for form submission */
98
+ readonly required?: boolean;
99
+ }
100
+
101
+ /**
102
+ * Built-in constraint names mapped to their expected value type for parsing.
103
+ * Constraints are surface-agnostic — they manifest as both TSDoc tags
104
+ * (e.g., `@minimum 0`) and chain DSL options (e.g., `{ minimum: 0 }`).
105
+ *
106
+ * Keys use camelCase matching JSON Schema property names.
107
+ *
108
+ * @public
109
+ */
110
+ export declare const BUILTIN_CONSTRAINT_DEFINITIONS: {
111
+ readonly minimum: "number";
112
+ readonly maximum: "number";
113
+ readonly exclusiveMinimum: "number";
114
+ readonly exclusiveMaximum: "number";
115
+ readonly multipleOf: "number";
116
+ readonly minLength: "number";
117
+ readonly maxLength: "number";
118
+ readonly minItems: "number";
119
+ readonly maxItems: "number";
120
+ readonly uniqueItems: "boolean";
121
+ readonly pattern: "string";
122
+ readonly const: "json";
123
+ readonly enumOptions: "json";
124
+ };
125
+
126
+ /**
127
+ * Registration for mapping a built-in TSDoc tag onto a custom constraint when
128
+ * it is used on a particular custom type.
129
+ *
130
+ * @public
131
+ */
132
+ export declare interface BuiltinConstraintBroadeningRegistration {
133
+ /** The built-in tag being broadened, without the `@` prefix. */
134
+ readonly tagName: BuiltinConstraintName;
135
+ /** The custom constraint to emit for this built-in tag. */
136
+ readonly constraintName: string;
137
+ /** Parser from raw TSDoc text to extension payload. */
138
+ readonly parseValue: (raw: string) => JsonValue;
139
+ }
140
+
141
+ /**
142
+ * Type of a built-in constraint name.
143
+ *
144
+ * @public
145
+ */
146
+ export declare type BuiltinConstraintName = keyof typeof BUILTIN_CONSTRAINT_DEFINITIONS;
147
+
148
+ /**
149
+ * A conditional wrapper that shows/hides elements based on another field's value.
150
+ *
151
+ * @typeParam FieldName - The field to check
152
+ * @typeParam Value - The value that triggers the condition
153
+ * @typeParam Elements - Tuple of contained form elements
154
+ *
155
+ * @public
156
+ */
157
+ export declare interface Conditional<FieldName extends string, Value, Elements extends readonly FormElement[]> {
158
+ /** Type discriminator - identifies this as a conditional element */
159
+ readonly _type: "conditional";
160
+ /** Name of the field whose value determines visibility */
161
+ readonly field: FieldName;
162
+ /** Value that triggers the condition (shows nested elements) */
163
+ readonly value: Value;
164
+ /** Form elements shown when condition is met */
165
+ readonly elements: Elements;
166
+ }
167
+
168
+ /**
169
+ * Conditional visibility based on another field's value.
170
+ *
171
+ * @public
172
+ */
173
+ export declare interface ConditionalLayoutNode {
174
+ readonly kind: "conditional";
175
+ /** The field whose value triggers visibility. */
176
+ readonly fieldName: string;
177
+ /** The value that makes the condition true (SHOW). */
178
+ readonly value: JsonValue;
179
+ /** Elements shown when the condition is met. */
180
+ readonly elements: readonly FormIRElement[];
181
+ readonly provenance: Provenance;
182
+ }
183
+
184
+ /**
185
+ * Literal-value equality constraint.
186
+ *
187
+ * @public
188
+ */
189
+ export declare interface ConstConstraintNode {
190
+ readonly kind: "constraint";
191
+ readonly constraintKind: "const";
192
+ readonly value: JsonValue;
193
+ readonly path?: PathTarget;
194
+ readonly provenance: Provenance;
195
+ }
196
+
197
+ /**
198
+ * Discriminated union of all constraint types.
199
+ * Constraints are set-influencing: they narrow the set of valid values.
200
+ *
201
+ * @public
202
+ */
203
+ export declare type ConstraintNode = NumericConstraintNode | LengthConstraintNode | PatternConstraintNode | ArrayCardinalityConstraintNode | EnumMemberConstraintNode | ConstConstraintNode | CustomConstraintNode;
204
+
205
+ /**
206
+ * Semantic metadata for ordered custom constraints that should participate in
207
+ * the generic contradiction/broadening logic.
208
+ *
209
+ * @public
210
+ */
211
+ export declare interface ConstraintSemanticRole {
212
+ /**
213
+ * Logical family identifier shared by related constraints, for example
214
+ * `"decimal-bound"` or `"date-bound"`.
215
+ */
216
+ readonly family: string;
217
+ /** Whether this constraint acts as a lower or upper bound. */
218
+ readonly bound: "lower" | "upper" | "exact";
219
+ /** Whether equality is allowed when comparing against the bound. */
220
+ readonly inclusive: boolean;
221
+ }
222
+
223
+ /**
224
+ * Declarative authoring-side registration for a custom TSDoc constraint tag.
225
+ *
226
+ * @public
227
+ */
228
+ export declare interface ConstraintTagRegistration {
229
+ /** Tag name without the `@` prefix, e.g. `"maxSigFig"`. */
230
+ readonly tagName: string;
231
+ /** The custom constraint that this tag should produce. */
232
+ readonly constraintName: string;
233
+ /** Parser from raw TSDoc text to JSON-serializable payload. */
234
+ readonly parseValue: (raw: string) => JsonValue;
235
+ /**
236
+ * Optional precise applicability predicate for the field type being parsed.
237
+ * When omitted, the target custom constraint registration controls type
238
+ * applicability during validation.
239
+ */
240
+ readonly isApplicableToType?: (type: TypeNode) => boolean;
241
+ }
242
+
243
+ /**
244
+ * Creates initial field state with default values.
245
+ *
246
+ * @typeParam T - The value type of the field
247
+ * @param value - The initial value for the field
248
+ * @returns Initial field state
249
+ *
250
+ * @public
251
+ */
252
+ export declare function createInitialFieldState<T>(value: T): FieldState<T>;
253
+
254
+ /**
255
+ * Extension-registered custom annotation.
256
+ *
257
+ * @public
258
+ */
259
+ export declare interface CustomAnnotationNode {
260
+ readonly kind: "annotation";
261
+ readonly annotationKind: "custom";
262
+ /** Extension-qualified ID: `"<vendor-prefix>/<extension-name>/<annotation-name>"` */
263
+ readonly annotationId: string;
264
+ readonly value: JsonValue;
265
+ readonly provenance: Provenance;
266
+ }
267
+
268
+ /**
269
+ * Registration for a custom annotation that may produce JSON Schema keywords.
270
+ *
271
+ * Custom annotations are referenced via {@link CustomAnnotationNode} in the IR.
272
+ * They describe or present a field but do not affect which values are valid.
273
+ *
274
+ * @public
275
+ */
276
+ export declare interface CustomAnnotationRegistration {
277
+ /** The annotation name, unique within the extension. */
278
+ readonly annotationName: string;
279
+ /**
280
+ * Optionally converts the annotation value into JSON Schema keywords.
281
+ * If omitted, the annotation has no JSON Schema representation (UI-only).
282
+ */
283
+ readonly toJsonSchema?: (value: JsonValue, vendorPrefix: string) => Record<string, unknown>;
284
+ }
285
+
286
+ /**
287
+ * Extension-registered custom constraint.
288
+ *
289
+ * @public
290
+ */
291
+ export declare interface CustomConstraintNode {
292
+ readonly kind: "constraint";
293
+ readonly constraintKind: "custom";
294
+ /** Extension-qualified ID: `"<vendor-prefix>/<extension-name>/<constraint-name>"` */
295
+ readonly constraintId: string;
296
+ /** JSON-serializable payload defined by the extension. */
297
+ readonly payload: JsonValue;
298
+ /** How this constraint composes with others of the same `constraintId`. */
299
+ readonly compositionRule: "intersect" | "override";
300
+ readonly path?: PathTarget;
301
+ readonly provenance: Provenance;
302
+ }
303
+
304
+ /**
305
+ * Registration for a custom constraint that maps to JSON Schema keywords.
306
+ *
307
+ * Custom constraints are referenced via {@link CustomConstraintNode} in the IR.
308
+ *
309
+ * @public
310
+ */
311
+ export declare interface CustomConstraintRegistration {
312
+ /** The constraint name, unique within the extension. */
313
+ readonly constraintName: string;
314
+ /**
315
+ * How this constraint composes with other constraints of the same kind.
316
+ * - "intersect": combine with logical AND (both must hold)
317
+ * - "override": last writer wins
318
+ */
319
+ readonly compositionRule: "intersect" | "override";
320
+ /**
321
+ * TypeNode kinds this constraint is applicable to, or `null` for any type.
322
+ * Used by the validator to emit TYPE_MISMATCH diagnostics.
323
+ */
324
+ readonly applicableTypes: readonly TypeNode["kind"][] | null;
325
+ /**
326
+ * Optional precise type predicate used when kind-level applicability is too
327
+ * broad (for example, constraints that apply to integer-like primitives but
328
+ * not strings).
329
+ */
330
+ readonly isApplicableToType?: (type: TypeNode) => boolean;
331
+ /**
332
+ * Optional comparator for payloads belonging to the same custom constraint.
333
+ * Return values follow the `Array.prototype.sort()` contract.
334
+ */
335
+ readonly comparePayloads?: (left: JsonValue, right: JsonValue) => number;
336
+ /**
337
+ * Optional semantic family metadata for generic contradiction/broadening
338
+ * handling across ordered constraints.
339
+ */
340
+ readonly semanticRole?: ConstraintSemanticRole;
341
+ /**
342
+ * Converts the custom constraint's payload into JSON Schema keywords.
343
+ *
344
+ * @param payload - The opaque JSON payload from the {@link CustomConstraintNode}.
345
+ * @param vendorPrefix - The vendor prefix for extension keywords.
346
+ * @returns A JSON Schema fragment with the constraint keywords.
347
+ */
348
+ readonly toJsonSchema: (payload: JsonValue, vendorPrefix: string) => Record<string, unknown>;
349
+ }
350
+
351
+ /**
352
+ * Custom type registered by an extension.
353
+ *
354
+ * @public
355
+ */
356
+ export declare interface CustomTypeNode {
357
+ readonly kind: "custom";
358
+ /**
359
+ * The extension-qualified type identifier.
360
+ * Format: `"<vendor-prefix>/<extension-name>/<type-name>"`
361
+ * e.g., `"x-stripe/monetary/MonetaryAmount"`
362
+ */
363
+ readonly typeId: string;
364
+ /**
365
+ * Opaque payload serialized by the extension that registered this type.
366
+ * Must be JSON-serializable.
367
+ */
368
+ readonly payload: JsonValue;
369
+ }
370
+
371
+ /**
372
+ * Registration for a custom type that maps to a JSON Schema representation.
373
+ *
374
+ * Custom types are referenced via {@link CustomTypeNode} in the IR and
375
+ * resolved to JSON Schema via `toJsonSchema` during generation.
376
+ *
377
+ * @public
378
+ */
379
+ export declare interface CustomTypeRegistration {
380
+ /** The type name, unique within the extension. */
381
+ readonly typeName: string;
382
+ /**
383
+ * Optional TypeScript surface names that should resolve to this custom type
384
+ * during TSDoc/class analysis. Defaults to `typeName` when omitted.
385
+ */
386
+ readonly tsTypeNames?: readonly string[];
387
+ /**
388
+ * Converts the custom type's payload into a JSON Schema fragment.
389
+ *
390
+ * @param payload - The opaque JSON payload from the {@link CustomTypeNode}.
391
+ * @param vendorPrefix - The vendor prefix for extension keywords (e.g., "x-stripe").
392
+ * @returns A JSON Schema fragment representing this type.
393
+ */
394
+ readonly toJsonSchema: (payload: JsonValue, vendorPrefix: string) => Record<string, unknown>;
395
+ /**
396
+ * Optional broadening of built-in constraint tags so they can apply to this
397
+ * custom type without modifying the core built-in constraint tables.
398
+ */
399
+ readonly builtinConstraintBroadenings?: readonly BuiltinConstraintBroadeningRegistration[];
400
+ }
401
+
402
+ /**
403
+ * A single option returned by a data source resolver.
404
+ *
405
+ * @typeParam T - The data type for additional option metadata
406
+ *
407
+ * @public
408
+ */
409
+ export declare interface DataSourceOption<T = unknown> {
410
+ /** The value stored when this option is selected */
411
+ readonly value: string;
412
+ /** The display label for this option */
413
+ readonly label: string;
414
+ /** Optional additional data associated with this option */
415
+ readonly data?: T;
416
+ }
417
+
418
+ /**
419
+ * Registry for dynamic data sources.
420
+ *
421
+ * Extend this interface via module augmentation to register your data sources:
422
+ *
423
+ * @example
424
+ * ```typescript
425
+ * declare module "@formspec/core" {
426
+ * interface DataSourceRegistry {
427
+ * countries: { id: string; code: string; name: string };
428
+ * templates: { id: string; name: string; category: string };
429
+ * }
430
+ * }
431
+ * ```
432
+ *
433
+ * @public
434
+ */
435
+ export declare interface DataSourceRegistry {
436
+ }
437
+
438
+ /**
439
+ * Gets the value type for a registered data source.
440
+ *
441
+ * If the source has an `id` property, that becomes the value type.
442
+ * Otherwise, defaults to `string`.
443
+ *
444
+ * @public
445
+ */
446
+ export declare type DataSourceValueType<Source extends string> = Source extends keyof DataSourceRegistry ? DataSourceRegistry[Source] extends {
447
+ id: infer ID;
448
+ } ? ID : string : string;
449
+
450
+ /**
451
+ * Default-value annotation.
452
+ *
453
+ * @public
454
+ */
455
+ export declare interface DefaultValueAnnotationNode {
456
+ readonly kind: "annotation";
457
+ readonly annotationKind: "defaultValue";
458
+ /** Must be JSON-serializable and type-compatible (verified during Validate phase). */
459
+ readonly value: JsonValue;
460
+ readonly provenance: Provenance;
461
+ }
462
+
463
+ /**
464
+ * Defines a custom annotation registration. Currently an identity function
465
+ * that provides type-checking and IDE autocompletion.
466
+ *
467
+ * @param reg - The custom annotation registration.
468
+ * @returns The same registration, validated at the type level.
469
+ *
470
+ * @public
471
+ */
472
+ export declare function defineAnnotation(reg: CustomAnnotationRegistration): CustomAnnotationRegistration;
473
+
474
+ /**
475
+ * Defines a custom constraint registration. Currently an identity function
476
+ * that provides type-checking and IDE autocompletion.
477
+ *
478
+ * @param reg - The custom constraint registration.
479
+ * @returns The same registration, validated at the type level.
480
+ *
481
+ * @public
482
+ */
483
+ export declare function defineConstraint(reg: CustomConstraintRegistration): CustomConstraintRegistration;
484
+
485
+ /**
486
+ * Defines a custom TSDoc constraint tag registration.
487
+ *
488
+ * @param reg - The custom tag registration.
489
+ * @returns The same registration, validated at the type level.
490
+ *
491
+ * @public
492
+ */
493
+ export declare function defineConstraintTag(reg: ConstraintTagRegistration): ConstraintTagRegistration;
494
+
495
+ /**
496
+ * Defines a custom type registration. Currently an identity function that
497
+ * provides type-checking and IDE autocompletion.
498
+ *
499
+ * @param reg - The custom type registration.
500
+ * @returns The same registration, validated at the type level.
501
+ *
502
+ * @public
503
+ */
504
+ export declare function defineCustomType(reg: CustomTypeRegistration): CustomTypeRegistration;
505
+
506
+ /**
507
+ * Defines a complete extension. Currently an identity function that provides
508
+ * type-checking and IDE autocompletion for the definition shape.
509
+ *
510
+ * @param def - The extension definition.
511
+ * @returns The same definition, validated at the type level.
512
+ *
513
+ * @public
514
+ */
515
+ export declare function defineExtension(def: ExtensionDefinition): ExtensionDefinition;
516
+
517
+ /**
518
+ * Deprecated annotation.
519
+ *
520
+ * @public
521
+ */
522
+ export declare interface DeprecatedAnnotationNode {
523
+ readonly kind: "annotation";
524
+ readonly annotationKind: "deprecated";
525
+ /** Optional deprecation message. */
526
+ readonly message?: string;
527
+ readonly provenance: Provenance;
528
+ }
529
+
530
+ /**
531
+ * Description annotation.
532
+ *
533
+ * @public
534
+ */
535
+ export declare interface DescriptionAnnotationNode {
536
+ readonly kind: "annotation";
537
+ readonly annotationKind: "description";
538
+ readonly value: string;
539
+ readonly provenance: Provenance;
540
+ }
541
+
542
+ /**
543
+ * Display-name annotation.
544
+ *
545
+ * @public
546
+ */
547
+ export declare interface DisplayNameAnnotationNode {
548
+ readonly kind: "annotation";
549
+ readonly annotationKind: "displayName";
550
+ readonly value: string;
551
+ readonly provenance: Provenance;
552
+ }
553
+
554
+ /**
555
+ * A field with dynamic enum options (fetched from a data source at runtime).
556
+ *
557
+ * @typeParam N - The field name (string literal type)
558
+ * @typeParam Source - The data source key (from DataSourceRegistry)
559
+ *
560
+ * @public
561
+ */
562
+ export declare interface DynamicEnumField<N extends string, Source extends string> {
563
+ /** Type discriminator for form elements */
564
+ readonly _type: "field";
565
+ /** Field type discriminator - identifies this as a dynamic enum field */
566
+ readonly _field: "dynamic_enum";
567
+ /** Unique field identifier used as the schema key */
568
+ readonly name: N;
569
+ /** Data source key for fetching options at runtime */
570
+ readonly source: Source;
571
+ /** Display label for the field */
572
+ readonly label?: string;
573
+ /** Whether this field is required for form submission */
574
+ readonly required?: boolean;
575
+ /** Field names whose values are needed to fetch options */
576
+ readonly params?: readonly string[];
577
+ }
578
+
579
+ /**
580
+ * A field that loads its schema dynamically (e.g., from an extension).
581
+ *
582
+ * @typeParam N - The field name (string literal type)
583
+ *
584
+ * @public
585
+ */
586
+ export declare interface DynamicSchemaField<N extends string> {
587
+ /** Type discriminator for form elements */
588
+ readonly _type: "field";
589
+ /** Field type discriminator - identifies this as a dynamic schema field */
590
+ readonly _field: "dynamic_schema";
591
+ /** Unique field identifier used as the schema key */
592
+ readonly name: N;
593
+ /** Identifier for the schema source */
594
+ readonly schemaSource: string;
595
+ /** Display label for the field */
596
+ readonly label?: string;
597
+ /** Whether this field is required for form submission */
598
+ readonly required?: boolean;
599
+ /** Field names whose values are needed to configure the schema */
600
+ readonly params?: readonly string[];
601
+ }
602
+
603
+ /**
604
+ * Dynamic type whose schema is resolved at runtime from a named data source.
605
+ *
606
+ * @public
607
+ */
608
+ export declare interface DynamicTypeNode {
609
+ readonly kind: "dynamic";
610
+ readonly dynamicKind: "enum" | "schema";
611
+ /** Key identifying the runtime data source or schema provider. */
612
+ readonly sourceKey: string;
613
+ /**
614
+ * For dynamic enums: field names whose current values are passed as
615
+ * parameters to the data source resolver.
616
+ */
617
+ readonly parameterFields: readonly string[];
618
+ }
619
+
620
+ /**
621
+ * A member of a static enum type.
622
+ *
623
+ * @public
624
+ */
625
+ export declare interface EnumMember {
626
+ /** The serialized value stored in data. */
627
+ readonly value: string | number;
628
+ /** Optional per-member display name. */
629
+ readonly displayName?: string;
630
+ }
631
+
632
+ /**
633
+ * Enum member subset constraint that only narrows the allowed member set.
634
+ *
635
+ * @public
636
+ */
637
+ export declare interface EnumMemberConstraintNode {
638
+ readonly kind: "constraint";
639
+ readonly constraintKind: "allowedMembers";
640
+ readonly members: readonly (string | number)[];
641
+ readonly path?: PathTarget;
642
+ readonly provenance: Provenance;
643
+ }
644
+
645
+ /**
646
+ * An enum option with a separate ID and display label.
647
+ *
648
+ * Use this when the stored value (id) should differ from the display text (label).
649
+ *
650
+ * @public
651
+ */
652
+ export declare interface EnumOption {
653
+ readonly id: string;
654
+ readonly label: string;
655
+ }
656
+
657
+ /**
658
+ * Valid enum option types: either plain strings or objects with id/label.
659
+ *
660
+ * @public
661
+ */
662
+ export declare type EnumOptionValue = string | EnumOption;
663
+
664
+ /**
665
+ * Static enum type with members known at build time.
666
+ *
667
+ * @public
668
+ */
669
+ export declare interface EnumTypeNode {
670
+ readonly kind: "enum";
671
+ readonly members: readonly EnumMember[];
672
+ }
673
+
674
+ /**
675
+ * Predicate types for conditional logic.
676
+ *
677
+ * Predicates are used with `when()` to define conditions in a readable way.
678
+ */
679
+ /**
680
+ * An equality predicate that checks if a field equals a specific value.
681
+ *
682
+ * @typeParam K - The field name to check
683
+ * @typeParam V - The value to compare against
684
+ *
685
+ * @public
686
+ */
687
+ export declare interface EqualsPredicate<K extends string, V> {
688
+ /** Predicate type discriminator */
689
+ readonly _predicate: "equals";
690
+ /** Name of the field to check */
691
+ readonly field: K;
692
+ /** Value that the field must equal */
693
+ readonly value: V;
694
+ }
695
+
696
+ /**
697
+ * A complete extension definition bundling types, constraints, annotations,
698
+ * and vocabulary keywords.
699
+ *
700
+ * @example
701
+ * ```typescript
702
+ * const monetaryExtension = defineExtension({
703
+ * extensionId: "x-stripe/monetary",
704
+ * types: [
705
+ * defineCustomType({
706
+ * typeName: "Decimal",
707
+ * toJsonSchema: (_payload, prefix) => ({
708
+ * type: "string",
709
+ * [`${prefix}-decimal`]: true,
710
+ * }),
711
+ * }),
712
+ * ],
713
+ * });
714
+ * ```
715
+ *
716
+ * @public
717
+ */
718
+ export declare interface ExtensionDefinition {
719
+ /** Globally unique extension identifier, e.g., "x-stripe/monetary". */
720
+ readonly extensionId: string;
721
+ /** Custom type registrations provided by this extension. */
722
+ readonly types?: readonly CustomTypeRegistration[];
723
+ /** Custom constraint registrations provided by this extension. */
724
+ readonly constraints?: readonly CustomConstraintRegistration[];
725
+ /** Authoring-side TSDoc tag registrations provided by this extension. */
726
+ readonly constraintTags?: readonly ConstraintTagRegistration[];
727
+ /** Custom annotation registrations provided by this extension. */
728
+ readonly annotations?: readonly CustomAnnotationRegistration[];
729
+ /** Vocabulary keyword registrations provided by this extension. */
730
+ readonly vocabularyKeywords?: readonly VocabularyKeywordRegistration[];
731
+ }
732
+
733
+ /**
734
+ * Response from a data source resolver function.
735
+ *
736
+ * @typeParam T - The data type for option metadata
737
+ *
738
+ * @public
739
+ */
740
+ export declare interface FetchOptionsResponse<T = unknown> {
741
+ /** The available options */
742
+ readonly options: readonly DataSourceOption<T>[];
743
+ /** Validity state of the fetch operation */
744
+ readonly validity: "valid" | "invalid" | "unknown";
745
+ /** Optional message (e.g., error description) */
746
+ readonly message?: string;
747
+ }
748
+
749
+ /**
750
+ * A single form field after canonicalization.
751
+ *
752
+ * @public
753
+ */
754
+ export declare interface FieldNode {
755
+ readonly kind: "field";
756
+ /** The field's key in the data schema. */
757
+ readonly name: string;
758
+ /** The resolved type of this field. */
759
+ readonly type: TypeNode;
760
+ /** Whether this field is required in the data schema. */
761
+ readonly required: boolean;
762
+ /** Set-influencing constraints, after merging. */
763
+ readonly constraints: readonly ConstraintNode[];
764
+ /** Value-influencing annotations, after merging. */
765
+ readonly annotations: readonly AnnotationNode[];
766
+ /** Where this field was declared. */
767
+ readonly provenance: Provenance;
768
+ /**
769
+ * Debug only — ordered list of constraint/annotation nodes that participated
770
+ * in merging, including dominated ones.
771
+ */
772
+ readonly mergeHistory?: readonly {
773
+ readonly node: ConstraintNode | AnnotationNode;
774
+ readonly dominated: boolean;
775
+ }[];
776
+ }
777
+
778
+ /**
779
+ * Represents the runtime state of a single form field.
780
+ *
781
+ * @typeParam T - The value type of the field
782
+ *
783
+ * @public
784
+ */
785
+ export declare interface FieldState<T> {
786
+ /** Current value of the field */
787
+ readonly value: T;
788
+ /** Whether the field has been modified by the user */
789
+ readonly dirty: boolean;
790
+ /** Whether the field has been focused and blurred */
791
+ readonly touched: boolean;
792
+ /** Current validity state */
793
+ readonly validity: Validity;
794
+ /** Validation error messages, if any */
795
+ readonly errors: readonly string[];
796
+ }
797
+
798
+ /**
799
+ * Schema format annotation, for example `email`, `date`, or `uri`.
800
+ *
801
+ * @public
802
+ */
803
+ export declare interface FormatAnnotationNode {
804
+ readonly kind: "annotation";
805
+ readonly annotationKind: "format";
806
+ readonly value: string;
807
+ readonly provenance: Provenance;
808
+ }
809
+
810
+ /**
811
+ * UI rendering hint — does not affect schema validation.
812
+ * Unlike FormatAnnotationNode, this never emits a JSON Schema `format`.
813
+ *
814
+ * @public
815
+ */
816
+ export declare interface FormatHintAnnotationNode {
817
+ readonly kind: "annotation";
818
+ readonly annotationKind: "formatHint";
819
+ /** Renderer-specific format identifier: "textarea", "radio", "date", "color", etc. */
820
+ readonly format: string;
821
+ readonly provenance: Provenance;
822
+ }
823
+
824
+ /**
825
+ * Union of all form element types (fields and structural elements).
826
+ *
827
+ * @public
828
+ */
829
+ export declare type FormElement = AnyField | Group<readonly FormElement[]> | Conditional<string, unknown, readonly FormElement[]>;
830
+
831
+ /**
832
+ * The complete Canonical Intermediate Representation for a form.
833
+ *
834
+ * Output of the Canonicalize phase; input to Validate, Generate (JSON Schema),
835
+ * and Generate (UI Schema) phases.
836
+ *
837
+ * Serializable to JSON — no live compiler objects.
838
+ *
839
+ * @public
840
+ */
841
+ export declare interface FormIR {
842
+ readonly kind: "form-ir";
843
+ /**
844
+ * Schema version for the IR format itself.
845
+ * Should equal `IR_VERSION`.
846
+ */
847
+ readonly irVersion: string;
848
+ /** Top-level elements of the form: fields and layout nodes. */
849
+ readonly elements: readonly FormIRElement[];
850
+ /** Root-level annotations derived from the source declaration itself. */
851
+ readonly rootAnnotations?: readonly AnnotationNode[];
852
+ /**
853
+ * Registry of named types referenced by fields in this form.
854
+ * Keys are fully-qualified type names matching `ReferenceTypeNode.name`.
855
+ */
856
+ readonly typeRegistry: Readonly<Record<string, TypeDefinition>>;
857
+ /** Root-level metadata for the form itself. */
858
+ readonly annotations?: readonly AnnotationNode[];
859
+ /** Provenance of the form definition itself. */
860
+ readonly provenance: Provenance;
861
+ }
862
+
863
+ /**
864
+ * Union of all IR element types.
865
+ *
866
+ * @public
867
+ */
868
+ export declare type FormIRElement = FieldNode | LayoutNode;
869
+
870
+ /**
871
+ * A complete form specification.
872
+ *
873
+ * @typeParam Elements - Tuple of top-level form elements
874
+ *
875
+ * @public
876
+ */
877
+ export declare interface FormSpec<Elements extends readonly FormElement[]> {
878
+ /** Top-level form elements */
879
+ readonly elements: Elements;
880
+ }
881
+
882
+ /**
883
+ * Represents the runtime state of an entire form.
884
+ *
885
+ * @typeParam Schema - The form schema type (maps field names to value types)
886
+ *
887
+ * @public
888
+ */
889
+ export declare interface FormState<Schema extends Record<string, unknown>> {
890
+ /** State for each field, keyed by field name */
891
+ readonly fields: {
892
+ readonly [K in keyof Schema]: FieldState<Schema[K]>;
893
+ };
894
+ /** Whether any field has been modified */
895
+ readonly dirty: boolean;
896
+ /** Whether the form is currently being submitted */
897
+ readonly submitting: boolean;
898
+ /** Overall form validity (derived from all field validities) */
899
+ readonly validity: Validity;
900
+ }
901
+
902
+ /**
903
+ * A visual grouping of form elements.
904
+ *
905
+ * Groups provide visual organization and can be rendered as fieldsets or sections.
906
+ *
907
+ * @typeParam Elements - Tuple of contained form elements
908
+ *
909
+ * @public
910
+ */
911
+ export declare interface Group<Elements extends readonly FormElement[]> {
912
+ /** Type discriminator - identifies this as a group element */
913
+ readonly _type: "group";
914
+ /** Display label for the group */
915
+ readonly label: string;
916
+ /** Form elements contained within this group */
917
+ readonly elements: Elements;
918
+ }
919
+
920
+ /**
921
+ * A visual grouping of form elements.
922
+ *
923
+ * @public
924
+ */
925
+ export declare interface GroupLayoutNode {
926
+ readonly kind: "group";
927
+ readonly label: string;
928
+ /** Elements contained in this group — may be fields or nested groups. */
929
+ readonly elements: readonly FormIRElement[];
930
+ readonly provenance: Provenance;
931
+ }
932
+
933
+ /**
934
+ * The current IR format version. Centralized here so all canonicalizers
935
+ * and consumers reference a single source of truth.
936
+ *
937
+ * @public
938
+ */
939
+ export declare const IR_VERSION: "0.1.0";
940
+
941
+ /**
942
+ * Narrows a `FormElement` to an array field.
943
+ *
944
+ * @public
945
+ */
946
+ export declare function isArrayField(element: FormElement): element is ArrayField<string, readonly FormElement[]>;
947
+
948
+ /**
949
+ * Narrows a `FormElement` to a boolean checkbox field.
950
+ *
951
+ * @public
952
+ */
953
+ export declare function isBooleanField(element: FormElement): element is BooleanField<string>;
954
+
955
+ /**
956
+ * Type guard: checks whether a tag name is a known built-in constraint.
957
+ *
958
+ * Uses `Object.hasOwn()` rather than `in` to prevent prototype-chain
959
+ * matches on names like `"toString"` or `"constructor"`.
960
+ *
961
+ * Callers should normalize with {@link normalizeConstraintTagName} first
962
+ * if the input may be PascalCase.
963
+ *
964
+ * @public
965
+ */
966
+ export declare function isBuiltinConstraintName(tagName: string): tagName is BuiltinConstraintName;
967
+
968
+ /**
969
+ * Narrows a `FormElement` to a conditional wrapper.
970
+ *
971
+ * @public
972
+ */
973
+ export declare function isConditional(element: FormElement): element is Conditional<string, unknown, readonly FormElement[]>;
974
+
975
+ /**
976
+ * Narrows a `FormElement` to a dynamic enum field.
977
+ *
978
+ * @public
979
+ */
980
+ export declare function isDynamicEnumField(element: FormElement): element is DynamicEnumField<string, string>;
981
+
982
+ /**
983
+ * Narrows a `FormElement` to a dynamic schema field.
984
+ *
985
+ * @public
986
+ */
987
+ export declare function isDynamicSchemaField(element: FormElement): element is DynamicSchemaField<string>;
988
+
989
+ /**
990
+ * Narrows a `FormElement` to any field type.
991
+ *
992
+ * @public
993
+ */
994
+ export declare function isField(element: FormElement): element is AnyField;
995
+
996
+ /**
997
+ * Narrows a `FormElement` to a visual group.
998
+ *
999
+ * @public
1000
+ */
1001
+ export declare function isGroup(element: FormElement): element is Group<readonly FormElement[]>;
1002
+
1003
+ /**
1004
+ * Narrows a `FormElement` to a numeric input field.
1005
+ *
1006
+ * @public
1007
+ */
1008
+ export declare function isNumberField(element: FormElement): element is NumberField<string>;
1009
+
1010
+ /**
1011
+ * Narrows a `FormElement` to an object field.
1012
+ *
1013
+ * @public
1014
+ */
1015
+ export declare function isObjectField(element: FormElement): element is ObjectField<string, readonly FormElement[]>;
1016
+
1017
+ /**
1018
+ * Narrows a `FormElement` to a static enum field.
1019
+ *
1020
+ * @public
1021
+ */
1022
+ export declare function isStaticEnumField(element: FormElement): element is StaticEnumField<string, readonly EnumOptionValue[]>;
1023
+
1024
+ /**
1025
+ * Narrows a `FormElement` to a text input field.
1026
+ *
1027
+ * @public
1028
+ */
1029
+ export declare function isTextField(element: FormElement): element is TextField<string>;
1030
+
1031
+ /**
1032
+ * A JSON-serializable value. All IR nodes must be representable as JSON.
1033
+ *
1034
+ * @public
1035
+ */
1036
+ export declare type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
1037
+ readonly [key: string]: JsonValue;
1038
+ };
1039
+
1040
+ /**
1041
+ * Union of layout node types.
1042
+ *
1043
+ * @public
1044
+ */
1045
+ export declare type LayoutNode = GroupLayoutNode | ConditionalLayoutNode;
1046
+
1047
+ /**
1048
+ * String length and array item count constraints.
1049
+ *
1050
+ * `minLength`/`maxLength` apply to strings; `minItems`/`maxItems` apply to
1051
+ * arrays. They share the same node shape because the composition rules are
1052
+ * identical.
1053
+ *
1054
+ * Type applicability: `minLength`/`maxLength` require `PrimitiveTypeNode("string")`;
1055
+ * `minItems`/`maxItems` require `ArrayTypeNode`.
1056
+ *
1057
+ * @public
1058
+ */
1059
+ export declare interface LengthConstraintNode {
1060
+ readonly kind: "constraint";
1061
+ readonly constraintKind: "minLength" | "maxLength" | "minItems" | "maxItems";
1062
+ readonly value: number;
1063
+ readonly path?: PathTarget;
1064
+ readonly provenance: Provenance;
1065
+ }
1066
+
1067
+ /**
1068
+ * Normalizes a constraint tag name from PascalCase to camelCase.
1069
+ *
1070
+ * Lowercases the first character so that e.g. `"Minimum"` becomes `"minimum"`.
1071
+ * Callers must strip the `@` prefix before calling this function.
1072
+ *
1073
+ * @example
1074
+ * normalizeConstraintTagName("Minimum") // "minimum"
1075
+ * normalizeConstraintTagName("MinLength") // "minLength"
1076
+ * normalizeConstraintTagName("minimum") // "minimum" (idempotent)
1077
+ *
1078
+ * @public
1079
+ */
1080
+ export declare function normalizeConstraintTagName(tagName: string): string;
1081
+
1082
+ /**
1083
+ * A numeric input field.
1084
+ *
1085
+ * @typeParam N - The field name (string literal type)
1086
+ *
1087
+ * @public
1088
+ */
1089
+ export declare interface NumberField<N extends string> {
1090
+ /** Type discriminator for form elements */
1091
+ readonly _type: "field";
1092
+ /** Field type discriminator - identifies this as a number field */
1093
+ readonly _field: "number";
1094
+ /** Unique field identifier used as the schema key */
1095
+ readonly name: N;
1096
+ /** Display label for the field */
1097
+ readonly label?: string;
1098
+ /** Minimum allowed value */
1099
+ readonly min?: number;
1100
+ /** Maximum allowed value */
1101
+ readonly max?: number;
1102
+ /** Whether this field is required for form submission */
1103
+ readonly required?: boolean;
1104
+ /** Value must be a multiple of this number (use 1 for integer semantics) */
1105
+ readonly multipleOf?: number;
1106
+ }
1107
+
1108
+ /**
1109
+ * Numeric constraints: bounds and multipleOf.
1110
+ *
1111
+ * `minimum` and `maximum` are inclusive; `exclusiveMinimum` and
1112
+ * `exclusiveMaximum` are exclusive bounds (matching JSON Schema 2020-12
1113
+ * semantics).
1114
+ *
1115
+ * Type applicability: may only attach to fields with `PrimitiveTypeNode("number")`
1116
+ * or a `ReferenceTypeNode` that resolves to one.
1117
+ *
1118
+ * @public
1119
+ */
1120
+ export declare interface NumericConstraintNode {
1121
+ readonly kind: "constraint";
1122
+ readonly constraintKind: "minimum" | "maximum" | "exclusiveMinimum" | "exclusiveMaximum" | "multipleOf";
1123
+ readonly value: number;
1124
+ /** If present, targets a nested sub-field rather than the field itself. */
1125
+ readonly path?: PathTarget;
1126
+ readonly provenance: Provenance;
1127
+ }
1128
+
1129
+ /**
1130
+ * An object field containing nested properties.
1131
+ *
1132
+ * Use this for grouping related fields under a single key in the schema.
1133
+ *
1134
+ * @typeParam N - The field name (string literal type)
1135
+ * @typeParam Properties - The form elements that define the object's properties
1136
+ *
1137
+ * @public
1138
+ */
1139
+ export declare interface ObjectField<N extends string, Properties extends readonly FormElement[]> {
1140
+ /** Type discriminator for form elements */
1141
+ readonly _type: "field";
1142
+ /** Field type discriminator - identifies this as an object field */
1143
+ readonly _field: "object";
1144
+ /** Unique field identifier used as the schema key */
1145
+ readonly name: N;
1146
+ /** Form elements that define the properties of this object */
1147
+ readonly properties: Properties;
1148
+ /** Display label for the field */
1149
+ readonly label?: string;
1150
+ /** Whether this field is required for form submission */
1151
+ readonly required?: boolean;
1152
+ }
1153
+
1154
+ /**
1155
+ * A named property within an object type.
1156
+ *
1157
+ * @public
1158
+ */
1159
+ export declare interface ObjectProperty {
1160
+ readonly name: string;
1161
+ readonly type: TypeNode;
1162
+ readonly optional: boolean;
1163
+ /**
1164
+ * Use-site constraints on this property.
1165
+ * Distinct from constraints on the property's type — these are
1166
+ * use-site constraints (e.g., `@minimum :amount 0` targets the
1167
+ * `amount` property of a `MonetaryAmount` field).
1168
+ */
1169
+ readonly constraints: readonly ConstraintNode[];
1170
+ /** Use-site annotations on this property. */
1171
+ readonly annotations: readonly AnnotationNode[];
1172
+ readonly provenance: Provenance;
1173
+ }
1174
+
1175
+ /**
1176
+ * Object type with named properties.
1177
+ *
1178
+ * @public
1179
+ */
1180
+ export declare interface ObjectTypeNode {
1181
+ readonly kind: "object";
1182
+ /**
1183
+ * Named properties of this object. Order is preserved from the source
1184
+ * declaration for deterministic output.
1185
+ */
1186
+ readonly properties: readonly ObjectProperty[];
1187
+ /**
1188
+ * Whether additional properties beyond those listed are permitted.
1189
+ * Ordinary static object types default to true under the current spec.
1190
+ * Explicitly closed-object modes may still set this to false.
1191
+ */
1192
+ readonly additionalProperties: boolean;
1193
+ }
1194
+
1195
+ /**
1196
+ * A path targeting a sub-field within a complex type.
1197
+ * Used by constraints and annotations to target nested properties.
1198
+ *
1199
+ * @public
1200
+ */
1201
+ export declare interface PathTarget {
1202
+ /**
1203
+ * Sequence of property names forming a path from the annotated field's type
1204
+ * to the target sub-field.
1205
+ * e.g., `["value"]` or `["address", "zip"]`
1206
+ */
1207
+ readonly segments: readonly string[];
1208
+ }
1209
+
1210
+ /**
1211
+ * String pattern constraint (ECMA-262 regex without delimiters).
1212
+ *
1213
+ * Multiple `pattern` constraints on the same field compose via intersection:
1214
+ * all patterns must match simultaneously.
1215
+ *
1216
+ * Type applicability: requires `PrimitiveTypeNode("string")`.
1217
+ *
1218
+ * @public
1219
+ */
1220
+ export declare interface PatternConstraintNode {
1221
+ readonly kind: "constraint";
1222
+ readonly constraintKind: "pattern";
1223
+ /** ECMA-262 regular expression, without delimiters. */
1224
+ readonly pattern: string;
1225
+ readonly path?: PathTarget;
1226
+ readonly provenance: Provenance;
1227
+ }
1228
+
1229
+ /**
1230
+ * Placeholder annotation.
1231
+ *
1232
+ * @public
1233
+ */
1234
+ export declare interface PlaceholderAnnotationNode {
1235
+ readonly kind: "annotation";
1236
+ readonly annotationKind: "placeholder";
1237
+ readonly value: string;
1238
+ readonly provenance: Provenance;
1239
+ }
1240
+
1241
+ /**
1242
+ * Union of all predicate types.
1243
+ *
1244
+ * Currently only supports equality, but can be extended with:
1245
+ * - `OneOfPredicate` - field value is one of several options
1246
+ * - `NotPredicate` - negation of another predicate
1247
+ * - `AndPredicate` / `OrPredicate` - logical combinations
1248
+ *
1249
+ * @public
1250
+ */
1251
+ export declare type Predicate<K extends string = string, V = unknown> = EqualsPredicate<K, V>;
1252
+
1253
+ /**
1254
+ * Primitive types mapping directly to JSON Schema primitives.
1255
+ *
1256
+ * Note: integer is NOT a primitive kind — integer semantics are expressed
1257
+ * via a `multipleOf: 1` constraint on a number type.
1258
+ *
1259
+ * @public
1260
+ */
1261
+ export declare interface PrimitiveTypeNode {
1262
+ readonly kind: "primitive";
1263
+ readonly primitiveKind: "string" | "number" | "integer" | "bigint" | "boolean" | "null";
1264
+ }
1265
+
1266
+ /**
1267
+ * Describes the origin of an IR node.
1268
+ * Enables diagnostics that point to the source of a contradiction or error.
1269
+ *
1270
+ * @public
1271
+ */
1272
+ export declare interface Provenance {
1273
+ /** The authoring surface that produced this node. */
1274
+ readonly surface: "tsdoc" | "chain-dsl" | "extension" | "inferred";
1275
+ /** Absolute path to the source file. */
1276
+ readonly file: string;
1277
+ /** 1-based line number in the source file. */
1278
+ readonly line: number;
1279
+ /** 0-based column number in the source file. */
1280
+ readonly column: number;
1281
+ /** Length of the source span in characters (for IDE underline ranges). */
1282
+ readonly length?: number;
1283
+ /**
1284
+ * The specific tag, call, or construct that produced this node.
1285
+ * Examples: `@minimum`, `field.number({ min: 0 })`, `optional`
1286
+ */
1287
+ readonly tagName?: string;
1288
+ }
1289
+
1290
+ /**
1291
+ * Record (dictionary) type — an object with a string index signature and no
1292
+ * named properties. Corresponds to `Record<string, T>` or `{ [k: string]: T }`.
1293
+ *
1294
+ * Emitted as `{ "type": "object", "additionalProperties": <value schema> }` in
1295
+ * JSON Schema per spec 003 §2.5.
1296
+ *
1297
+ * @public
1298
+ */
1299
+ export declare interface RecordTypeNode {
1300
+ readonly kind: "record";
1301
+ /** The type of each value in the dictionary. */
1302
+ readonly valueType: TypeNode;
1303
+ }
1304
+
1305
+ /**
1306
+ * Named type reference preserved for `$defs` and `$ref` emission.
1307
+ *
1308
+ * @public
1309
+ */
1310
+ export declare interface ReferenceTypeNode {
1311
+ readonly kind: "reference";
1312
+ /**
1313
+ * The fully-qualified name of the referenced type.
1314
+ * For TypeScript interfaces/type aliases: `"<module>#<TypeName>"`.
1315
+ * For built-in types: the primitive kind string.
1316
+ */
1317
+ readonly name: string;
1318
+ /**
1319
+ * Type arguments if this is a generic instantiation.
1320
+ * e.g., `Array<string>` → `{ name: "Array", typeArguments: [PrimitiveTypeNode("string")] }`
1321
+ */
1322
+ readonly typeArguments: readonly TypeNode[];
1323
+ }
1324
+
1325
+ /**
1326
+ * Remarks annotation — programmatic-persona documentation carried via
1327
+ * the `x-<vendor>-remarks` JSON Schema extension keyword.
1328
+ *
1329
+ * Populated from `@remarks` TSDoc tag content. SDK codegen can include
1330
+ * this in doc comments; API Documenter renders the source `@remarks`
1331
+ * natively in a dedicated Remarks section.
1332
+ *
1333
+ * @public
1334
+ */
1335
+ export declare interface RemarksAnnotationNode {
1336
+ readonly kind: "annotation";
1337
+ readonly annotationKind: "remarks";
1338
+ readonly value: string;
1339
+ readonly provenance: Provenance;
1340
+ }
1341
+
1342
+ /**
1343
+ * A field with static enum options (known at compile time).
1344
+ *
1345
+ * Options can be plain strings or objects with `id` and `label` properties.
1346
+ *
1347
+ * @typeParam N - The field name (string literal type)
1348
+ * @typeParam O - Tuple of option values (strings or EnumOption objects)
1349
+ *
1350
+ * @public
1351
+ */
1352
+ export declare interface StaticEnumField<N extends string, O extends readonly EnumOptionValue[]> {
1353
+ /** Type discriminator for form elements */
1354
+ readonly _type: "field";
1355
+ /** Field type discriminator - identifies this as an enum field */
1356
+ readonly _field: "enum";
1357
+ /** Unique field identifier used as the schema key */
1358
+ readonly name: N;
1359
+ /** Array of allowed option values */
1360
+ readonly options: O;
1361
+ /** Display label for the field */
1362
+ readonly label?: string;
1363
+ /** Whether this field is required for form submission */
1364
+ readonly required?: boolean;
1365
+ }
1366
+
1367
+ /**
1368
+ * Form element type definitions.
1369
+ *
1370
+ * These types define the structure of form specifications.
1371
+ * The structure IS the definition - nesting implies layout and conditional logic.
1372
+ */
1373
+ /**
1374
+ * A text input field.
1375
+ *
1376
+ * @typeParam N - The field name (string literal type)
1377
+ *
1378
+ * @public
1379
+ */
1380
+ export declare interface TextField<N extends string> {
1381
+ /** Type discriminator for form elements */
1382
+ readonly _type: "field";
1383
+ /** Field type discriminator - identifies this as a text field */
1384
+ readonly _field: "text";
1385
+ /** Unique field identifier used as the schema key */
1386
+ readonly name: N;
1387
+ /** Display label for the field */
1388
+ readonly label?: string;
1389
+ /** Placeholder text shown when field is empty */
1390
+ readonly placeholder?: string;
1391
+ /** Whether this field is required for form submission */
1392
+ readonly required?: boolean;
1393
+ /** Minimum string length */
1394
+ readonly minLength?: number;
1395
+ /** Maximum string length */
1396
+ readonly maxLength?: number;
1397
+ /** Regular expression pattern the value must match */
1398
+ readonly pattern?: string;
1399
+ }
1400
+
1401
+ /**
1402
+ * A named type definition stored in the type registry.
1403
+ *
1404
+ * @public
1405
+ */
1406
+ export declare interface TypeDefinition {
1407
+ /** The fully-qualified reference name (key in the registry). */
1408
+ readonly name: string;
1409
+ /** The resolved type node. */
1410
+ readonly type: TypeNode;
1411
+ /** Constraints declared on the named type itself. */
1412
+ readonly constraints?: readonly ConstraintNode[];
1413
+ /** Root-level value metadata for a named type definition. */
1414
+ readonly annotations?: readonly AnnotationNode[];
1415
+ /** Where this type was declared. */
1416
+ readonly provenance: Provenance;
1417
+ }
1418
+
1419
+ /**
1420
+ * Discriminated union of all type representations in the IR.
1421
+ *
1422
+ * @public
1423
+ */
1424
+ export declare type TypeNode = PrimitiveTypeNode | EnumTypeNode | ArrayTypeNode | ObjectTypeNode | RecordTypeNode | UnionTypeNode | ReferenceTypeNode | DynamicTypeNode | CustomTypeNode;
1425
+
1426
+ /**
1427
+ * Union type for non-enum unions. Nullable types are represented as `T | null`.
1428
+ *
1429
+ * @public
1430
+ */
1431
+ export declare interface UnionTypeNode {
1432
+ readonly kind: "union";
1433
+ readonly members: readonly TypeNode[];
1434
+ }
1435
+
1436
+ /**
1437
+ * Represents the validity state of a field or form.
1438
+ *
1439
+ * - `"valid"` - All validations pass
1440
+ * - `"invalid"` - One or more validations failed
1441
+ * - `"unknown"` - Validation state not yet determined (e.g., async validation pending)
1442
+ *
1443
+ * @public
1444
+ */
1445
+ export declare type Validity = "valid" | "invalid" | "unknown";
1446
+
1447
+ /**
1448
+ * Registration for a vocabulary keyword to include in a JSON Schema `$vocabulary` declaration.
1449
+ *
1450
+ * @public
1451
+ */
1452
+ export declare interface VocabularyKeywordRegistration {
1453
+ /** The keyword name (without vendor prefix). */
1454
+ readonly keyword: string;
1455
+ /** JSON Schema that describes the valid values for this keyword. */
1456
+ readonly schema: JsonValue;
1457
+ }
1458
+
1459
+ export { }