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

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