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

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