@formspec/core 0.1.0-alpha.10 → 0.1.0-alpha.12

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.
package/dist/core.d.ts CHANGED
@@ -5,15 +5,32 @@
5
5
  * - Form element types (fields, groups, conditionals)
6
6
  * - Field and form state types
7
7
  * - Data source registry for dynamic enums
8
+ * - Canonical IR types (FormIR, FieldNode, TypeNode, ConstraintNode, AnnotationNode, etc.)
8
9
  *
9
10
  * @packageDocumentation
10
11
  */
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
+ export declare type AnnotationNode = DisplayNameAnnotationNode | DescriptionAnnotationNode | PlaceholderAnnotationNode | DefaultValueAnnotationNode | DeprecatedAnnotationNode | FormatHintAnnotationNode | CustomAnnotationNode;
19
+
12
20
  /**
13
21
  * Union of all field types.
14
22
  */
15
23
  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[]>;
16
24
 
25
+ /** Array uniqueness constraint. */
26
+ export declare interface ArrayCardinalityConstraintNode {
27
+ readonly kind: "constraint";
28
+ readonly constraintKind: "uniqueItems";
29
+ readonly value: true;
30
+ readonly path?: PathTarget;
31
+ readonly provenance: Provenance;
32
+ }
33
+
17
34
  /**
18
35
  * An array field containing repeating items.
19
36
  *
@@ -41,6 +58,12 @@ export declare interface ArrayField<N extends string, Items extends readonly For
41
58
  readonly maxItems?: number;
42
59
  }
43
60
 
61
+ /** Array type with a single items type. */
62
+ export declare interface ArrayTypeNode {
63
+ readonly kind: "array";
64
+ readonly items: TypeNode;
65
+ }
66
+
44
67
  /**
45
68
  * A boolean checkbox field.
46
69
  *
@@ -59,6 +82,25 @@ export declare interface BooleanField<N extends string> {
59
82
  readonly required?: boolean;
60
83
  }
61
84
 
85
+ /**
86
+ * Built-in constraint names mapped to their expected value type for parsing.
87
+ * Constraints are surface-agnostic — they manifest as both TSDoc tags
88
+ * (e.g., `@Minimum 0`) and chain DSL options (e.g., `{ minimum: 0 }`).
89
+ */
90
+ export declare const BUILTIN_CONSTRAINT_DEFINITIONS: {
91
+ readonly Minimum: "number";
92
+ readonly Maximum: "number";
93
+ readonly ExclusiveMinimum: "number";
94
+ readonly ExclusiveMaximum: "number";
95
+ readonly MinLength: "number";
96
+ readonly MaxLength: "number";
97
+ readonly Pattern: "string";
98
+ readonly EnumOptions: "json";
99
+ };
100
+
101
+ /** Type of a built-in constraint name. */
102
+ export declare type BuiltinConstraintName = keyof typeof BUILTIN_CONSTRAINT_DEFINITIONS;
103
+
62
104
  /**
63
105
  * A conditional wrapper that shows/hides elements based on another field's value.
64
106
  *
@@ -77,27 +119,23 @@ export declare interface Conditional<FieldName extends string, Value, Elements e
77
119
  readonly elements: Elements;
78
120
  }
79
121
 
122
+ /** Conditional visibility based on another field's value. */
123
+ export declare interface ConditionalLayoutNode {
124
+ readonly kind: "conditional";
125
+ /** The field whose value triggers visibility. */
126
+ readonly fieldName: string;
127
+ /** The value that makes the condition true (SHOW). */
128
+ readonly value: JsonValue;
129
+ /** Elements shown when the condition is met. */
130
+ readonly elements: readonly FormIRElement[];
131
+ readonly provenance: Provenance;
132
+ }
133
+
80
134
  /**
81
- * Constraint decorator names that are valid as TSDoc tags, mapped to
82
- * their expected value type for parsing.
83
- *
84
- * Both `@formspec/build` (schema generation) and `@formspec/eslint-plugin`
85
- * (lint-time validation) import this to determine which JSDoc tags to
86
- * recognize and how to parse their values.
135
+ * Discriminated union of all constraint types.
136
+ * Constraints are set-influencing: they narrow the set of valid values.
87
137
  */
88
- export declare const CONSTRAINT_TAG_DEFINITIONS: {
89
- readonly Minimum: "number";
90
- readonly Maximum: "number";
91
- readonly ExclusiveMinimum: "number";
92
- readonly ExclusiveMaximum: "number";
93
- readonly MinLength: "number";
94
- readonly MaxLength: "number";
95
- readonly Pattern: "string";
96
- readonly EnumOptions: "json";
97
- };
98
-
99
- /** Type of a constraint tag name. */
100
- export declare type ConstraintTagName = keyof typeof CONSTRAINT_TAG_DEFINITIONS;
138
+ export declare type ConstraintNode = NumericConstraintNode | LengthConstraintNode | PatternConstraintNode | ArrayCardinalityConstraintNode | EnumMemberConstraintNode | CustomConstraintNode;
101
139
 
102
140
  /**
103
141
  * Creates initial field state with default values.
@@ -108,6 +146,110 @@ export declare type ConstraintTagName = keyof typeof CONSTRAINT_TAG_DEFINITIONS;
108
146
  */
109
147
  export declare function createInitialFieldState<T>(value: T): FieldState<T>;
110
148
 
149
+ /** Extension-registered custom annotation. */
150
+ export declare interface CustomAnnotationNode {
151
+ readonly kind: "annotation";
152
+ readonly annotationKind: "custom";
153
+ /** Extension-qualified ID: `"<vendor-prefix>/<extension-name>/<annotation-name>"` */
154
+ readonly annotationId: string;
155
+ readonly value: JsonValue;
156
+ readonly provenance: Provenance;
157
+ }
158
+
159
+ /**
160
+ * Registration for a custom annotation that may produce JSON Schema keywords.
161
+ *
162
+ * Custom annotations are referenced via {@link CustomAnnotationNode} in the IR.
163
+ * They describe or present a field but do not affect which values are valid.
164
+ */
165
+ export declare interface CustomAnnotationRegistration {
166
+ /** The annotation name, unique within the extension. */
167
+ readonly annotationName: string;
168
+ /**
169
+ * Optionally converts the annotation value into JSON Schema keywords.
170
+ * If omitted, the annotation has no JSON Schema representation (UI-only).
171
+ */
172
+ readonly toJsonSchema?: (value: JsonValue, vendorPrefix: string) => Record<string, unknown>;
173
+ }
174
+
175
+ /** Extension-registered custom constraint. */
176
+ export declare interface CustomConstraintNode {
177
+ readonly kind: "constraint";
178
+ readonly constraintKind: "custom";
179
+ /** Extension-qualified ID: `"<vendor-prefix>/<extension-name>/<constraint-name>"` */
180
+ readonly constraintId: string;
181
+ /** JSON-serializable payload defined by the extension. */
182
+ readonly payload: JsonValue;
183
+ /** How this constraint composes with others of the same `constraintId`. */
184
+ readonly compositionRule: "intersect" | "override";
185
+ readonly path?: PathTarget;
186
+ readonly provenance: Provenance;
187
+ }
188
+
189
+ /**
190
+ * Registration for a custom constraint that maps to JSON Schema keywords.
191
+ *
192
+ * Custom constraints are referenced via {@link CustomConstraintNode} in the IR.
193
+ */
194
+ export declare interface CustomConstraintRegistration {
195
+ /** The constraint name, unique within the extension. */
196
+ readonly constraintName: string;
197
+ /**
198
+ * How this constraint composes with other constraints of the same kind.
199
+ * - "intersect": combine with logical AND (both must hold)
200
+ * - "override": last writer wins
201
+ */
202
+ readonly compositionRule: "intersect" | "override";
203
+ /**
204
+ * TypeNode kinds this constraint is applicable to, or `null` for any type.
205
+ * Used by the validator to emit TYPE_MISMATCH diagnostics.
206
+ */
207
+ readonly applicableTypes: readonly TypeNode["kind"][] | null;
208
+ /**
209
+ * Converts the custom constraint's payload into JSON Schema keywords.
210
+ *
211
+ * @param payload - The opaque JSON payload from the {@link CustomConstraintNode}.
212
+ * @param vendorPrefix - The vendor prefix for extension keywords.
213
+ * @returns A JSON Schema fragment with the constraint keywords.
214
+ */
215
+ readonly toJsonSchema: (payload: JsonValue, vendorPrefix: string) => Record<string, unknown>;
216
+ }
217
+
218
+ /** Custom type registered by an extension. */
219
+ export declare interface CustomTypeNode {
220
+ readonly kind: "custom";
221
+ /**
222
+ * The extension-qualified type identifier.
223
+ * Format: `"<vendor-prefix>/<extension-name>/<type-name>"`
224
+ * e.g., `"x-stripe/monetary/MonetaryAmount"`
225
+ */
226
+ readonly typeId: string;
227
+ /**
228
+ * Opaque payload serialized by the extension that registered this type.
229
+ * Must be JSON-serializable.
230
+ */
231
+ readonly payload: JsonValue;
232
+ }
233
+
234
+ /**
235
+ * Registration for a custom type that maps to a JSON Schema representation.
236
+ *
237
+ * Custom types are referenced via {@link CustomTypeNode} in the IR and
238
+ * resolved to JSON Schema via `toJsonSchema` during generation.
239
+ */
240
+ export declare interface CustomTypeRegistration {
241
+ /** The type name, unique within the extension. */
242
+ readonly typeName: string;
243
+ /**
244
+ * Converts the custom type's payload into a JSON Schema fragment.
245
+ *
246
+ * @param payload - The opaque JSON payload from the {@link CustomTypeNode}.
247
+ * @param vendorPrefix - The vendor prefix for extension keywords (e.g., "x-stripe").
248
+ * @returns A JSON Schema fragment representing this type.
249
+ */
250
+ readonly toJsonSchema: (payload: JsonValue, vendorPrefix: string) => Record<string, unknown>;
251
+ }
252
+
111
253
  /**
112
254
  * A single option returned by a data source resolver.
113
255
  *
@@ -150,6 +292,72 @@ export declare type DataSourceValueType<Source extends string> = Source extends
150
292
  id: infer ID;
151
293
  } ? ID : string : string;
152
294
 
295
+ export declare interface DefaultValueAnnotationNode {
296
+ readonly kind: "annotation";
297
+ readonly annotationKind: "defaultValue";
298
+ /** Must be JSON-serializable and type-compatible (verified during Validate phase). */
299
+ readonly value: JsonValue;
300
+ readonly provenance: Provenance;
301
+ }
302
+
303
+ /**
304
+ * Defines a custom annotation registration. Currently an identity function
305
+ * that provides type-checking and IDE autocompletion.
306
+ *
307
+ * @param reg - The custom annotation registration.
308
+ * @returns The same registration, validated at the type level.
309
+ */
310
+ export declare function defineAnnotation(reg: CustomAnnotationRegistration): CustomAnnotationRegistration;
311
+
312
+ /**
313
+ * Defines a custom constraint registration. Currently an identity function
314
+ * that provides type-checking and IDE autocompletion.
315
+ *
316
+ * @param reg - The custom constraint registration.
317
+ * @returns The same registration, validated at the type level.
318
+ */
319
+ export declare function defineConstraint(reg: CustomConstraintRegistration): CustomConstraintRegistration;
320
+
321
+ /**
322
+ * Defines a custom type registration. Currently an identity function that
323
+ * provides type-checking and IDE autocompletion.
324
+ *
325
+ * @param reg - The custom type registration.
326
+ * @returns The same registration, validated at the type level.
327
+ */
328
+ export declare function defineCustomType(reg: CustomTypeRegistration): CustomTypeRegistration;
329
+
330
+ /**
331
+ * Defines a complete extension. Currently an identity function that provides
332
+ * type-checking and IDE autocompletion for the definition shape.
333
+ *
334
+ * @param def - The extension definition.
335
+ * @returns The same definition, validated at the type level.
336
+ */
337
+ export declare function defineExtension(def: ExtensionDefinition): ExtensionDefinition;
338
+
339
+ export declare interface DeprecatedAnnotationNode {
340
+ readonly kind: "annotation";
341
+ readonly annotationKind: "deprecated";
342
+ /** Optional deprecation message. */
343
+ readonly message?: string;
344
+ readonly provenance: Provenance;
345
+ }
346
+
347
+ export declare interface DescriptionAnnotationNode {
348
+ readonly kind: "annotation";
349
+ readonly annotationKind: "description";
350
+ readonly value: string;
351
+ readonly provenance: Provenance;
352
+ }
353
+
354
+ export declare interface DisplayNameAnnotationNode {
355
+ readonly kind: "annotation";
356
+ readonly annotationKind: "displayName";
357
+ readonly value: string;
358
+ readonly provenance: Provenance;
359
+ }
360
+
153
361
  /**
154
362
  * A field with dynamic enum options (fetched from a data source at runtime).
155
363
  *
@@ -193,6 +401,36 @@ export declare interface DynamicSchemaField<N extends string> {
193
401
  readonly required?: boolean;
194
402
  }
195
403
 
404
+ /** Dynamic type — schema resolved at runtime from a named data source. */
405
+ export declare interface DynamicTypeNode {
406
+ readonly kind: "dynamic";
407
+ readonly dynamicKind: "enum" | "schema";
408
+ /** Key identifying the runtime data source or schema provider. */
409
+ readonly sourceKey: string;
410
+ /**
411
+ * For dynamic enums: field names whose current values are passed as
412
+ * parameters to the data source resolver.
413
+ */
414
+ readonly parameterFields: readonly string[];
415
+ }
416
+
417
+ /** A member of a static enum type. */
418
+ export declare interface EnumMember {
419
+ /** The serialized value stored in data. */
420
+ readonly value: string | number;
421
+ /** Optional per-member display name. */
422
+ readonly displayName?: string;
423
+ }
424
+
425
+ /** Enum member subset constraint (refinement — only narrows). */
426
+ export declare interface EnumMemberConstraintNode {
427
+ readonly kind: "constraint";
428
+ readonly constraintKind: "allowedMembers";
429
+ readonly members: readonly (string | number)[];
430
+ readonly path?: PathTarget;
431
+ readonly provenance: Provenance;
432
+ }
433
+
196
434
  /**
197
435
  * An enum option with a separate ID and display label.
198
436
  *
@@ -208,6 +446,12 @@ export declare interface EnumOption {
208
446
  */
209
447
  export declare type EnumOptionValue = string | EnumOption;
210
448
 
449
+ /** Static enum type — members known at build time. */
450
+ export declare interface EnumTypeNode {
451
+ readonly kind: "enum";
452
+ readonly members: readonly EnumMember[];
453
+ }
454
+
211
455
  /**
212
456
  * Predicate types for conditional logic.
213
457
  *
@@ -228,6 +472,39 @@ export declare interface EqualsPredicate<K extends string, V> {
228
472
  readonly value: V;
229
473
  }
230
474
 
475
+ /**
476
+ * A complete extension definition bundling types, constraints, annotations,
477
+ * and vocabulary keywords.
478
+ *
479
+ * @example
480
+ * ```typescript
481
+ * const monetaryExtension = defineExtension({
482
+ * extensionId: "x-stripe/monetary",
483
+ * types: [
484
+ * defineCustomType({
485
+ * typeName: "Decimal",
486
+ * toJsonSchema: (_payload, prefix) => ({
487
+ * type: "string",
488
+ * [`${prefix}-decimal`]: true,
489
+ * }),
490
+ * }),
491
+ * ],
492
+ * });
493
+ * ```
494
+ */
495
+ export declare interface ExtensionDefinition {
496
+ /** Globally unique extension identifier, e.g., "x-stripe/monetary". */
497
+ readonly extensionId: string;
498
+ /** Custom type registrations provided by this extension. */
499
+ readonly types?: readonly CustomTypeRegistration[];
500
+ /** Custom constraint registrations provided by this extension. */
501
+ readonly constraints?: readonly CustomConstraintRegistration[];
502
+ /** Custom annotation registrations provided by this extension. */
503
+ readonly annotations?: readonly CustomAnnotationRegistration[];
504
+ /** Vocabulary keyword registrations provided by this extension. */
505
+ readonly vocabularyKeywords?: readonly VocabularyKeywordRegistration[];
506
+ }
507
+
231
508
  /**
232
509
  * Response from a data source resolver function.
233
510
  *
@@ -242,6 +519,31 @@ export declare interface FetchOptionsResponse<T = unknown> {
242
519
  readonly message?: string;
243
520
  }
244
521
 
522
+ /** A single form field after canonicalization. */
523
+ export declare interface FieldNode {
524
+ readonly kind: "field";
525
+ /** The field's key in the data schema. */
526
+ readonly name: string;
527
+ /** The resolved type of this field. */
528
+ readonly type: TypeNode;
529
+ /** Whether this field is required in the data schema. */
530
+ readonly required: boolean;
531
+ /** Set-influencing constraints, after merging. */
532
+ readonly constraints: readonly ConstraintNode[];
533
+ /** Value-influencing annotations, after merging. */
534
+ readonly annotations: readonly AnnotationNode[];
535
+ /** Where this field was declared. */
536
+ readonly provenance: Provenance;
537
+ /**
538
+ * Debug only — ordered list of constraint/annotation nodes that participated
539
+ * in merging, including dominated ones.
540
+ */
541
+ readonly mergeHistory?: readonly {
542
+ readonly node: ConstraintNode | AnnotationNode;
543
+ readonly dominated: boolean;
544
+ }[];
545
+ }
546
+
245
547
  /**
246
548
  * Represents the runtime state of a single form field.
247
549
  *
@@ -260,11 +562,49 @@ export declare interface FieldState<T> {
260
562
  readonly errors: readonly string[];
261
563
  }
262
564
 
565
+ /** UI rendering hint — does not affect schema validation. */
566
+ export declare interface FormatHintAnnotationNode {
567
+ readonly kind: "annotation";
568
+ readonly annotationKind: "formatHint";
569
+ /** Renderer-specific format identifier: "textarea", "radio", "date", "color", etc. */
570
+ readonly format: string;
571
+ readonly provenance: Provenance;
572
+ }
573
+
263
574
  /**
264
575
  * Union of all form element types (fields and structural elements).
265
576
  */
266
577
  export declare type FormElement = AnyField | Group<readonly FormElement[]> | Conditional<string, unknown, readonly FormElement[]>;
267
578
 
579
+ /**
580
+ * The complete Canonical Intermediate Representation for a form.
581
+ *
582
+ * Output of the Canonicalize phase; input to Validate, Generate (JSON Schema),
583
+ * and Generate (UI Schema) phases.
584
+ *
585
+ * Serializable to JSON — no live compiler objects.
586
+ */
587
+ export declare interface FormIR {
588
+ readonly kind: "form-ir";
589
+ /**
590
+ * Schema version for the IR format itself.
591
+ * Should equal `IR_VERSION`.
592
+ */
593
+ readonly irVersion: string;
594
+ /** Top-level elements of the form: fields and layout nodes. */
595
+ readonly elements: readonly FormIRElement[];
596
+ /**
597
+ * Registry of named types referenced by fields in this form.
598
+ * Keys are fully-qualified type names matching `ReferenceTypeNode.name`.
599
+ */
600
+ readonly typeRegistry: Readonly<Record<string, TypeDefinition>>;
601
+ /** Provenance of the form definition itself. */
602
+ readonly provenance: Provenance;
603
+ }
604
+
605
+ /** Union of all IR element types. */
606
+ export declare type FormIRElement = FieldNode | LayoutNode;
607
+
268
608
  /**
269
609
  * A complete form specification.
270
610
  *
@@ -275,12 +615,6 @@ export declare interface FormSpec<Elements extends readonly FormElement[]> {
275
615
  readonly elements: Elements;
276
616
  }
277
617
 
278
- /** Names of all built-in FormSpec decorators. */
279
- export declare const FORMSPEC_DECORATOR_NAMES: readonly ["Field", "Group", "ShowWhen", "EnumOptions", "Minimum", "Maximum", "ExclusiveMinimum", "ExclusiveMaximum", "MinLength", "MaxLength", "Pattern"];
280
-
281
- /** Type of a FormSpec decorator name. */
282
- export declare type FormSpecDecoratorName = (typeof FORMSPEC_DECORATOR_NAMES)[number];
283
-
284
618
  /**
285
619
  * Represents the runtime state of an entire form.
286
620
  *
@@ -315,6 +649,49 @@ export declare interface Group<Elements extends readonly FormElement[]> {
315
649
  readonly elements: Elements;
316
650
  }
317
651
 
652
+ /** A visual grouping of form elements. */
653
+ export declare interface GroupLayoutNode {
654
+ readonly kind: "group";
655
+ readonly label: string;
656
+ /** Elements contained in this group — may be fields or nested groups. */
657
+ readonly elements: readonly FormIRElement[];
658
+ readonly provenance: Provenance;
659
+ }
660
+
661
+ /**
662
+ * The current IR format version. Centralized here so all canonicalizers
663
+ * and consumers reference a single source of truth.
664
+ */
665
+ export declare const IR_VERSION: "0.1.0";
666
+
667
+ /**
668
+ * A JSON-serializable value. All IR nodes must be representable as JSON.
669
+ */
670
+ export declare type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
671
+ readonly [key: string]: JsonValue;
672
+ };
673
+
674
+ /** Union of layout node types. */
675
+ export declare type LayoutNode = GroupLayoutNode | ConditionalLayoutNode;
676
+
677
+ /**
678
+ * String length and array item count constraints.
679
+ *
680
+ * `minLength`/`maxLength` apply to strings; `minItems`/`maxItems` apply to
681
+ * arrays. They share the same node shape because the composition rules are
682
+ * identical.
683
+ *
684
+ * Type applicability: `minLength`/`maxLength` require `PrimitiveTypeNode("string")`;
685
+ * `minItems`/`maxItems` require `ArrayTypeNode`.
686
+ */
687
+ export declare interface LengthConstraintNode {
688
+ readonly kind: "constraint";
689
+ readonly constraintKind: "minLength" | "maxLength" | "minItems" | "maxItems";
690
+ readonly value: number;
691
+ readonly path?: PathTarget;
692
+ readonly provenance: Provenance;
693
+ }
694
+
318
695
  /**
319
696
  * A numeric input field.
320
697
  *
@@ -337,6 +714,25 @@ export declare interface NumberField<N extends string> {
337
714
  readonly required?: boolean;
338
715
  }
339
716
 
717
+ /**
718
+ * Numeric constraints: bounds and multipleOf.
719
+ *
720
+ * `minimum` and `maximum` are inclusive; `exclusiveMinimum` and
721
+ * `exclusiveMaximum` are exclusive bounds (matching JSON Schema 2020-12
722
+ * semantics).
723
+ *
724
+ * Type applicability: may only attach to fields with `PrimitiveTypeNode("number")`
725
+ * or a `ReferenceTypeNode` that resolves to one.
726
+ */
727
+ export declare interface NumericConstraintNode {
728
+ readonly kind: "constraint";
729
+ readonly constraintKind: "minimum" | "maximum" | "exclusiveMinimum" | "exclusiveMaximum" | "multipleOf";
730
+ readonly value: number;
731
+ /** If present, targets a nested sub-field rather than the field itself. */
732
+ readonly path?: PathTarget;
733
+ readonly provenance: Provenance;
734
+ }
735
+
340
736
  /**
341
737
  * An object field containing nested properties.
342
738
  *
@@ -360,6 +756,75 @@ export declare interface ObjectField<N extends string, Properties extends readon
360
756
  readonly required?: boolean;
361
757
  }
362
758
 
759
+ /** A named property within an object type. */
760
+ export declare interface ObjectProperty {
761
+ readonly name: string;
762
+ readonly type: TypeNode;
763
+ readonly optional: boolean;
764
+ /**
765
+ * Use-site constraints on this property.
766
+ * Distinct from constraints on the property's type — these are
767
+ * use-site constraints (e.g., `@minimum :amount 0` targets the
768
+ * `amount` property of a `MonetaryAmount` field).
769
+ */
770
+ readonly constraints: readonly ConstraintNode[];
771
+ /** Use-site annotations on this property. */
772
+ readonly annotations: readonly AnnotationNode[];
773
+ readonly provenance: Provenance;
774
+ }
775
+
776
+ /** Object type with named properties. */
777
+ export declare interface ObjectTypeNode {
778
+ readonly kind: "object";
779
+ /**
780
+ * Named properties of this object. Order is preserved from the source
781
+ * declaration for deterministic output.
782
+ */
783
+ readonly properties: readonly ObjectProperty[];
784
+ /**
785
+ * Whether additional properties beyond those listed are permitted.
786
+ * Defaults to false — object types in FormSpec are closed.
787
+ */
788
+ readonly additionalProperties: boolean;
789
+ }
790
+
791
+ /**
792
+ * A path targeting a sub-field within a complex type.
793
+ * Used by constraints and annotations to target nested properties.
794
+ */
795
+ export declare interface PathTarget {
796
+ /**
797
+ * Sequence of property names forming a path from the annotated field's type
798
+ * to the target sub-field.
799
+ * e.g., `["value"]` or `["address", "zip"]`
800
+ */
801
+ readonly segments: readonly string[];
802
+ }
803
+
804
+ /**
805
+ * String pattern constraint (ECMA-262 regex without delimiters).
806
+ *
807
+ * Multiple `pattern` constraints on the same field compose via intersection:
808
+ * all patterns must match simultaneously.
809
+ *
810
+ * Type applicability: requires `PrimitiveTypeNode("string")`.
811
+ */
812
+ export declare interface PatternConstraintNode {
813
+ readonly kind: "constraint";
814
+ readonly constraintKind: "pattern";
815
+ /** ECMA-262 regular expression, without delimiters. */
816
+ readonly pattern: string;
817
+ readonly path?: PathTarget;
818
+ readonly provenance: Provenance;
819
+ }
820
+
821
+ export declare interface PlaceholderAnnotationNode {
822
+ readonly kind: "annotation";
823
+ readonly annotationKind: "placeholder";
824
+ readonly value: string;
825
+ readonly provenance: Provenance;
826
+ }
827
+
363
828
  /**
364
829
  * Union of all predicate types.
365
830
  *
@@ -370,6 +835,55 @@ export declare interface ObjectField<N extends string, Properties extends readon
370
835
  */
371
836
  export declare type Predicate<K extends string = string, V = unknown> = EqualsPredicate<K, V>;
372
837
 
838
+ /**
839
+ * Primitive types mapping directly to JSON Schema primitives.
840
+ *
841
+ * Note: integer is NOT a primitive kind — integer semantics are expressed
842
+ * via a `multipleOf: 1` constraint on a number type.
843
+ */
844
+ export declare interface PrimitiveTypeNode {
845
+ readonly kind: "primitive";
846
+ readonly primitiveKind: "string" | "number" | "boolean" | "null";
847
+ }
848
+
849
+ /**
850
+ * Describes the origin of an IR node.
851
+ * Enables diagnostics that point to the source of a contradiction or error.
852
+ */
853
+ export declare interface Provenance {
854
+ /** The authoring surface that produced this node. */
855
+ readonly surface: "tsdoc" | "chain-dsl" | "extension" | "inferred";
856
+ /** Absolute path to the source file. */
857
+ readonly file: string;
858
+ /** 1-based line number in the source file. */
859
+ readonly line: number;
860
+ /** 0-based column number in the source file. */
861
+ readonly column: number;
862
+ /** Length of the source span in characters (for IDE underline ranges). */
863
+ readonly length?: number;
864
+ /**
865
+ * The specific tag, call, or construct that produced this node.
866
+ * Examples: `@minimum`, `field.number({ min: 0 })`, `optional`
867
+ */
868
+ readonly tagName?: string;
869
+ }
870
+
871
+ /** Named type reference — preserved as references for `$defs`/`$ref` emission. */
872
+ export declare interface ReferenceTypeNode {
873
+ readonly kind: "reference";
874
+ /**
875
+ * The fully-qualified name of the referenced type.
876
+ * For TypeScript interfaces/type aliases: `"<module>#<TypeName>"`.
877
+ * For built-in types: the primitive kind string.
878
+ */
879
+ readonly name: string;
880
+ /**
881
+ * Type arguments if this is a generic instantiation.
882
+ * e.g., `Array<string>` → `{ name: "Array", typeArguments: [PrimitiveTypeNode("string")] }`
883
+ */
884
+ readonly typeArguments: readonly TypeNode[];
885
+ }
886
+
373
887
  /**
374
888
  * A field with static enum options (known at compile time).
375
889
  *
@@ -419,6 +933,27 @@ export declare interface TextField<N extends string> {
419
933
  readonly required?: boolean;
420
934
  }
421
935
 
936
+ /** A named type definition stored in the type registry. */
937
+ export declare interface TypeDefinition {
938
+ /** The fully-qualified reference name (key in the registry). */
939
+ readonly name: string;
940
+ /** The resolved type node. */
941
+ readonly type: TypeNode;
942
+ /** Where this type was declared. */
943
+ readonly provenance: Provenance;
944
+ }
945
+
946
+ /**
947
+ * Discriminated union of all type representations in the IR.
948
+ */
949
+ export declare type TypeNode = PrimitiveTypeNode | EnumTypeNode | ArrayTypeNode | ObjectTypeNode | UnionTypeNode | ReferenceTypeNode | DynamicTypeNode | CustomTypeNode;
950
+
951
+ /** Union type for non-enum unions. Nullable types are `T | null` using this. */
952
+ export declare interface UnionTypeNode {
953
+ readonly kind: "union";
954
+ readonly members: readonly TypeNode[];
955
+ }
956
+
422
957
  /**
423
958
  * Represents the validity state of a field or form.
424
959
  *
@@ -428,4 +963,14 @@ export declare interface TextField<N extends string> {
428
963
  */
429
964
  export declare type Validity = "valid" | "invalid" | "unknown";
430
965
 
966
+ /**
967
+ * Registration for a vocabulary keyword to include in a JSON Schema `$vocabulary` declaration.
968
+ */
969
+ export declare interface VocabularyKeywordRegistration {
970
+ /** The keyword name (without vendor prefix). */
971
+ readonly keyword: string;
972
+ /** JSON Schema that describes the valid values for this keyword. */
973
+ readonly schema: JsonValue;
974
+ }
975
+
431
976
  export { }