@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
package/dist/core.d.ts ADDED
@@ -0,0 +1,917 @@
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
+ /* Excluded from this release type: AnnotationNode */
14
+
15
+ /**
16
+ * Union of all field types.
17
+ *
18
+ * @public
19
+ */
20
+ 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[]>;
21
+
22
+ /* Excluded from this release type: ArrayCardinalityConstraintNode */
23
+
24
+ /**
25
+ * An array field containing repeating items.
26
+ *
27
+ * Use this for lists of values (e.g., multiple addresses, line items).
28
+ *
29
+ * @typeParam N - The field name (string literal type)
30
+ * @typeParam Items - The form elements that define each array item
31
+ *
32
+ * @public
33
+ */
34
+ export declare interface ArrayField<N extends string, Items extends readonly FormElement[]> {
35
+ /** Type discriminator for form elements */
36
+ readonly _type: "field";
37
+ /** Field type discriminator - identifies this as an array field */
38
+ readonly _field: "array";
39
+ /** Unique field identifier used as the schema key */
40
+ readonly name: N;
41
+ /** Form elements that define the schema for each array item */
42
+ readonly items: Items;
43
+ /** Display label for the field */
44
+ readonly label?: string;
45
+ /** Whether this field is required for form submission */
46
+ readonly required?: boolean;
47
+ /** Minimum number of items required */
48
+ readonly minItems?: number;
49
+ /** Maximum number of items allowed */
50
+ readonly maxItems?: number;
51
+ }
52
+
53
+ /* Excluded from this release type: ArrayTypeNode */
54
+
55
+ /**
56
+ * A boolean checkbox field.
57
+ *
58
+ * @typeParam N - The field name (string literal type)
59
+ *
60
+ * @public
61
+ */
62
+ export declare interface BooleanField<N extends string> {
63
+ /** Type discriminator for form elements */
64
+ readonly _type: "field";
65
+ /** Field type discriminator - identifies this as a boolean field */
66
+ readonly _field: "boolean";
67
+ /** Unique field identifier used as the schema key */
68
+ readonly name: N;
69
+ /** Display label for the field */
70
+ readonly label?: string;
71
+ /** Whether this field is required for form submission */
72
+ readonly required?: boolean;
73
+ }
74
+
75
+ /**
76
+ * Registration for mapping a built-in TSDoc tag onto a custom constraint when
77
+ * it is used on a particular custom type.
78
+ *
79
+ * @public
80
+ */
81
+ export declare interface BuiltinConstraintBroadeningRegistration {
82
+ /** The built-in tag being broadened, without the `@` prefix. */
83
+ readonly tagName: BuiltinConstraintName;
84
+ /** The custom constraint to emit for this built-in tag. */
85
+ readonly constraintName: string;
86
+ /** Parser from raw TSDoc text to extension payload. */
87
+ readonly parseValue: (raw: string) => ExtensionPayloadValue;
88
+ }
89
+
90
+ /**
91
+ * Type of a built-in constraint name.
92
+ *
93
+ * @public
94
+ */
95
+ export declare type BuiltinConstraintName = "minimum" | "maximum" | "exclusiveMinimum" | "exclusiveMaximum" | "multipleOf" | "minLength" | "maxLength" | "minItems" | "maxItems" | "uniqueItems" | "pattern" | "const" | "enumOptions";
96
+
97
+ /**
98
+ * A conditional wrapper that shows/hides elements based on another field's value.
99
+ *
100
+ * @typeParam FieldName - The field to check
101
+ * @typeParam Value - The value that triggers the condition
102
+ * @typeParam Elements - Tuple of contained form elements
103
+ *
104
+ * @public
105
+ */
106
+ export declare interface Conditional<FieldName extends string, Value, Elements extends readonly FormElement[]> {
107
+ /** Type discriminator - identifies this as a conditional element */
108
+ readonly _type: "conditional";
109
+ /** Name of the field whose value determines visibility */
110
+ readonly field: FieldName;
111
+ /** Value that triggers the condition (shows nested elements) */
112
+ readonly value: Value;
113
+ /** Form elements shown when condition is met */
114
+ readonly elements: Elements;
115
+ }
116
+
117
+ /* Excluded from this release type: ConditionalLayoutNode */
118
+
119
+ /* Excluded from this release type: ConstConstraintNode */
120
+
121
+ /* Excluded from this release type: ConstraintNode */
122
+
123
+ /**
124
+ * Semantic metadata for ordered custom constraints that should participate in
125
+ * the generic contradiction/broadening logic.
126
+ *
127
+ * @public
128
+ */
129
+ export declare interface ConstraintSemanticRole {
130
+ /**
131
+ * Logical family identifier shared by related constraints, for example
132
+ * `"decimal-bound"` or `"date-bound"`.
133
+ */
134
+ readonly family: string;
135
+ /** Whether this constraint acts as a lower or upper bound. */
136
+ readonly bound: "lower" | "upper" | "exact";
137
+ /** Whether equality is allowed when comparing against the bound. */
138
+ readonly inclusive: boolean;
139
+ }
140
+
141
+ /**
142
+ * Declarative authoring-side registration for a custom TSDoc constraint tag.
143
+ *
144
+ * @public
145
+ */
146
+ export declare interface ConstraintTagRegistration {
147
+ /** Tag name without the `@` prefix, e.g. `"maxSigFig"`. */
148
+ readonly tagName: string;
149
+ /** The custom constraint that this tag should produce. */
150
+ readonly constraintName: string;
151
+ /** Parser from raw TSDoc text to JSON-serializable payload. */
152
+ readonly parseValue: (raw: string) => ExtensionPayloadValue;
153
+ /**
154
+ * Optional precise applicability predicate for the field type being parsed.
155
+ * When omitted, the target custom constraint registration controls type
156
+ * applicability during validation.
157
+ */
158
+ readonly isApplicableToType?: (type: ExtensionApplicableType) => boolean;
159
+ }
160
+
161
+ /**
162
+ * Creates initial field state with default values.
163
+ *
164
+ * @typeParam T - The value type of the field
165
+ * @param value - The initial value for the field
166
+ * @returns Initial field state
167
+ *
168
+ * @public
169
+ */
170
+ export declare function createInitialFieldState<T>(value: T): FieldState<T>;
171
+
172
+ /* Excluded from this release type: CustomAnnotationNode */
173
+
174
+ /**
175
+ * Registration for a custom annotation that may produce JSON Schema keywords.
176
+ *
177
+ * Custom annotations are referenced by FormSpec's internal custom-annotation nodes.
178
+ * They describe or present a field but do not affect which values are valid.
179
+ *
180
+ * @public
181
+ */
182
+ export declare interface CustomAnnotationRegistration {
183
+ /** The annotation name, unique within the extension. */
184
+ readonly annotationName: string;
185
+ /**
186
+ * Optionally converts the annotation value into JSON Schema keywords.
187
+ * If omitted, the annotation has no JSON Schema representation (UI-only).
188
+ */
189
+ readonly toJsonSchema?: (value: ExtensionPayloadValue, vendorPrefix: string) => Record<string, unknown>;
190
+ }
191
+
192
+ /* Excluded from this release type: CustomConstraintNode */
193
+
194
+ /**
195
+ * Registration for a custom constraint that maps to JSON Schema keywords.
196
+ *
197
+ * Custom constraints are referenced by FormSpec's internal custom-constraint nodes.
198
+ *
199
+ * @public
200
+ */
201
+ export declare interface CustomConstraintRegistration {
202
+ /** The constraint name, unique within the extension. */
203
+ readonly constraintName: string;
204
+ /**
205
+ * How this constraint composes with other constraints of the same kind.
206
+ * - "intersect": combine with logical AND (both must hold)
207
+ * - "override": last writer wins
208
+ */
209
+ readonly compositionRule: "intersect" | "override";
210
+ /**
211
+ * TypeNode kinds this constraint is applicable to, or `null` for any type.
212
+ * Used by the validator to emit TYPE_MISMATCH diagnostics.
213
+ */
214
+ readonly applicableTypes: readonly ExtensionApplicableType["kind"][] | null;
215
+ /**
216
+ * Optional precise type predicate used when kind-level applicability is too
217
+ * broad (for example, constraints that apply to integer-like primitives but
218
+ * not strings).
219
+ */
220
+ readonly isApplicableToType?: (type: ExtensionApplicableType) => boolean;
221
+ /**
222
+ * Optional comparator for payloads belonging to the same custom constraint.
223
+ * Return values follow the `Array.prototype.sort()` contract.
224
+ */
225
+ readonly comparePayloads?: (left: ExtensionPayloadValue, right: ExtensionPayloadValue) => number;
226
+ /**
227
+ * Optional semantic family metadata for generic contradiction/broadening
228
+ * handling across ordered constraints.
229
+ */
230
+ readonly semanticRole?: ConstraintSemanticRole;
231
+ /**
232
+ * Converts the custom constraint's payload into JSON Schema keywords.
233
+ *
234
+ * @param payload - The opaque JSON payload stored on the custom constraint node.
235
+ * @param vendorPrefix - The vendor prefix for extension keywords.
236
+ * @returns A JSON Schema fragment with the constraint keywords.
237
+ */
238
+ readonly toJsonSchema: (payload: ExtensionPayloadValue, vendorPrefix: string) => Record<string, unknown>;
239
+ }
240
+
241
+ /* Excluded from this release type: CustomTypeNode */
242
+
243
+ /**
244
+ * Registration for a custom type that maps to a JSON Schema representation.
245
+ *
246
+ * Custom types are referenced by FormSpec's internal custom-type IR nodes and
247
+ * resolved to JSON Schema via `toJsonSchema` during generation.
248
+ *
249
+ * @public
250
+ */
251
+ export declare interface CustomTypeRegistration {
252
+ /** The type name, unique within the extension. */
253
+ readonly typeName: string;
254
+ /**
255
+ * Optional TypeScript surface names that should resolve to this custom type
256
+ * during TSDoc/class analysis. Defaults to `typeName` when omitted.
257
+ */
258
+ readonly tsTypeNames?: readonly string[];
259
+ /**
260
+ * Converts the custom type's payload into a JSON Schema fragment.
261
+ *
262
+ * @param payload - The opaque JSON payload stored on the custom type node.
263
+ * @param vendorPrefix - The vendor prefix for extension keywords (e.g., "x-stripe").
264
+ * @returns A JSON Schema fragment representing this type.
265
+ */
266
+ readonly toJsonSchema: (payload: ExtensionPayloadValue, vendorPrefix: string) => Record<string, unknown>;
267
+ /**
268
+ * Optional broadening of built-in constraint tags so they can apply to this
269
+ * custom type without modifying the core built-in constraint tables.
270
+ */
271
+ readonly builtinConstraintBroadenings?: readonly BuiltinConstraintBroadeningRegistration[];
272
+ }
273
+
274
+ /**
275
+ * A single option returned by a data source resolver.
276
+ *
277
+ * @typeParam T - The data type for additional option metadata
278
+ *
279
+ * @public
280
+ */
281
+ export declare interface DataSourceOption<T = unknown> {
282
+ /** The value stored when this option is selected */
283
+ readonly value: string;
284
+ /** The display label for this option */
285
+ readonly label: string;
286
+ /** Optional additional data associated with this option */
287
+ readonly data?: T;
288
+ }
289
+
290
+ /**
291
+ * Registry for dynamic data sources.
292
+ *
293
+ * Extend this interface via module augmentation to register your data sources:
294
+ *
295
+ * @example
296
+ * ```typescript
297
+ * declare module "@formspec/core" {
298
+ * interface DataSourceRegistry {
299
+ * countries: { id: string; code: string; name: string };
300
+ * templates: { id: string; name: string; category: string };
301
+ * }
302
+ * }
303
+ * ```
304
+ *
305
+ * @public
306
+ */
307
+ export declare interface DataSourceRegistry {
308
+ }
309
+
310
+ /**
311
+ * Gets the value type for a registered data source.
312
+ *
313
+ * If the source has an `id` property, that becomes the value type.
314
+ * Otherwise, defaults to `string`.
315
+ *
316
+ * @public
317
+ */
318
+ export declare type DataSourceValueType<Source extends string> = Source extends keyof DataSourceRegistry ? DataSourceRegistry[Source] extends {
319
+ id: infer ID;
320
+ } ? ID : string : string;
321
+
322
+ /* Excluded from this release type: DefaultValueAnnotationNode */
323
+
324
+ /**
325
+ * Defines a custom annotation registration. Currently an identity function
326
+ * that provides type-checking and IDE autocompletion.
327
+ *
328
+ * @param reg - The custom annotation registration.
329
+ * @returns The same registration, validated at the type level.
330
+ *
331
+ * @public
332
+ */
333
+ export declare function defineAnnotation(reg: CustomAnnotationRegistration): CustomAnnotationRegistration;
334
+
335
+ /**
336
+ * Defines a custom constraint registration. Currently an identity function
337
+ * that provides type-checking and IDE autocompletion.
338
+ *
339
+ * @param reg - The custom constraint registration.
340
+ * @returns The same registration, validated at the type level.
341
+ *
342
+ * @public
343
+ */
344
+ export declare function defineConstraint(reg: CustomConstraintRegistration): CustomConstraintRegistration;
345
+
346
+ /**
347
+ * Defines a custom TSDoc constraint tag registration.
348
+ *
349
+ * @param reg - The custom tag registration.
350
+ * @returns The same registration, validated at the type level.
351
+ *
352
+ * @public
353
+ */
354
+ export declare function defineConstraintTag(reg: ConstraintTagRegistration): ConstraintTagRegistration;
355
+
356
+ /**
357
+ * Defines a custom type registration. Currently an identity function that
358
+ * provides type-checking and IDE autocompletion.
359
+ *
360
+ * @param reg - The custom type registration.
361
+ * @returns The same registration, validated at the type level.
362
+ *
363
+ * @public
364
+ */
365
+ export declare function defineCustomType(reg: CustomTypeRegistration): CustomTypeRegistration;
366
+
367
+ /**
368
+ * Defines a complete extension. Currently an identity function that provides
369
+ * type-checking and IDE autocompletion for the definition shape.
370
+ *
371
+ * @param def - The extension definition.
372
+ * @returns The same definition, validated at the type level.
373
+ *
374
+ * @public
375
+ */
376
+ export declare function defineExtension(def: ExtensionDefinition): ExtensionDefinition;
377
+
378
+ /* Excluded from this release type: DeprecatedAnnotationNode */
379
+
380
+ /* Excluded from this release type: DescriptionAnnotationNode */
381
+
382
+ /* Excluded from this release type: DisplayNameAnnotationNode */
383
+
384
+ /**
385
+ * A field with dynamic enum options (fetched from a data source at runtime).
386
+ *
387
+ * @typeParam N - The field name (string literal type)
388
+ * @typeParam Source - The data source key (from DataSourceRegistry)
389
+ *
390
+ * @public
391
+ */
392
+ export declare interface DynamicEnumField<N extends string, Source extends string> {
393
+ /** Type discriminator for form elements */
394
+ readonly _type: "field";
395
+ /** Field type discriminator - identifies this as a dynamic enum field */
396
+ readonly _field: "dynamic_enum";
397
+ /** Unique field identifier used as the schema key */
398
+ readonly name: N;
399
+ /** Data source key for fetching options at runtime */
400
+ readonly source: Source;
401
+ /** Display label for the field */
402
+ readonly label?: string;
403
+ /** Whether this field is required for form submission */
404
+ readonly required?: boolean;
405
+ /** Field names whose values are needed to fetch options */
406
+ readonly params?: readonly string[];
407
+ }
408
+
409
+ /**
410
+ * A field that loads its schema dynamically (e.g., from an extension).
411
+ *
412
+ * @typeParam N - The field name (string literal type)
413
+ *
414
+ * @public
415
+ */
416
+ export declare interface DynamicSchemaField<N extends string> {
417
+ /** Type discriminator for form elements */
418
+ readonly _type: "field";
419
+ /** Field type discriminator - identifies this as a dynamic schema field */
420
+ readonly _field: "dynamic_schema";
421
+ /** Unique field identifier used as the schema key */
422
+ readonly name: N;
423
+ /** Identifier for the schema source */
424
+ readonly schemaSource: string;
425
+ /** Display label for the field */
426
+ readonly label?: string;
427
+ /** Whether this field is required for form submission */
428
+ readonly required?: boolean;
429
+ /** Field names whose values are needed to configure the schema */
430
+ readonly params?: readonly string[];
431
+ }
432
+
433
+ /* Excluded from this release type: DynamicTypeNode */
434
+
435
+ /* Excluded from this release type: EnumMember */
436
+
437
+ /* Excluded from this release type: EnumMemberConstraintNode */
438
+
439
+ /**
440
+ * An enum option with a separate ID and display label.
441
+ *
442
+ * Use this when the stored value (id) should differ from the display text (label).
443
+ *
444
+ * @public
445
+ */
446
+ export declare interface EnumOption {
447
+ readonly id: string;
448
+ readonly label: string;
449
+ }
450
+
451
+ /**
452
+ * Valid enum option types: either plain strings or objects with id/label.
453
+ *
454
+ * @public
455
+ */
456
+ export declare type EnumOptionValue = string | EnumOption;
457
+
458
+ /* Excluded from this release type: EnumTypeNode */
459
+
460
+ /**
461
+ * Predicate types for conditional logic.
462
+ *
463
+ * Predicates are used with `when()` to define conditions in a readable way.
464
+ */
465
+ /**
466
+ * An equality predicate that checks if a field equals a specific value.
467
+ *
468
+ * @typeParam K - The field name to check
469
+ * @typeParam V - The value to compare against
470
+ *
471
+ * @public
472
+ */
473
+ export declare interface EqualsPredicate<K extends string, V> {
474
+ /** Predicate type discriminator */
475
+ readonly _predicate: "equals";
476
+ /** Name of the field to check */
477
+ readonly field: K;
478
+ /** Value that the field must equal */
479
+ readonly value: V;
480
+ }
481
+
482
+ /**
483
+ * A curated type shape exposed to extension applicability hooks.
484
+ *
485
+ * This intentionally exposes only the fields needed to determine tag/type
486
+ * applicability without committing the entire canonical IR as public API.
487
+ *
488
+ * @public
489
+ */
490
+ export declare type ExtensionApplicableType = {
491
+ readonly kind: "primitive";
492
+ readonly primitiveKind: "string" | "number" | "integer" | "bigint" | "boolean" | "null";
493
+ } | {
494
+ readonly kind: "custom";
495
+ readonly typeId: string;
496
+ readonly payload: ExtensionPayloadValue;
497
+ } | {
498
+ readonly kind: Exclude<ExtensionTypeKind, "primitive" | "custom">;
499
+ };
500
+
501
+ /**
502
+ * A complete extension definition bundling types, constraints, annotations,
503
+ * and vocabulary keywords.
504
+ *
505
+ * @example
506
+ * ```typescript
507
+ * const monetaryExtension = defineExtension({
508
+ * extensionId: "x-stripe/monetary",
509
+ * types: [
510
+ * defineCustomType({
511
+ * typeName: "Decimal",
512
+ * toJsonSchema: (_payload, prefix) => ({
513
+ * type: "string",
514
+ * [`${prefix}-decimal`]: true,
515
+ * }),
516
+ * }),
517
+ * ],
518
+ * });
519
+ * ```
520
+ *
521
+ * @public
522
+ */
523
+ export declare interface ExtensionDefinition {
524
+ /** Globally unique extension identifier, e.g., "x-stripe/monetary". */
525
+ readonly extensionId: string;
526
+ /** Custom type registrations provided by this extension. */
527
+ readonly types?: readonly CustomTypeRegistration[];
528
+ /** Custom constraint registrations provided by this extension. */
529
+ readonly constraints?: readonly CustomConstraintRegistration[];
530
+ /** Authoring-side TSDoc tag registrations provided by this extension. */
531
+ readonly constraintTags?: readonly ConstraintTagRegistration[];
532
+ /** Custom annotation registrations provided by this extension. */
533
+ readonly annotations?: readonly CustomAnnotationRegistration[];
534
+ /** Vocabulary keyword registrations provided by this extension. */
535
+ readonly vocabularyKeywords?: readonly VocabularyKeywordRegistration[];
536
+ }
537
+
538
+ /**
539
+ * A JSON-serializable payload value used by extension registration hooks.
540
+ *
541
+ * @public
542
+ */
543
+ export declare type ExtensionPayloadValue = null | boolean | number | string | readonly ExtensionPayloadValue[] | {
544
+ readonly [key: string]: ExtensionPayloadValue;
545
+ };
546
+
547
+ /**
548
+ * Top-level type kinds that extension applicability hooks may inspect.
549
+ *
550
+ * @public
551
+ */
552
+ export declare type ExtensionTypeKind = "primitive" | "enum" | "array" | "object" | "record" | "union" | "reference" | "dynamic" | "custom";
553
+
554
+ /**
555
+ * Response from a data source resolver function.
556
+ *
557
+ * @typeParam T - The data type for option metadata
558
+ *
559
+ * @public
560
+ */
561
+ export declare interface FetchOptionsResponse<T = unknown> {
562
+ /** The available options */
563
+ readonly options: readonly DataSourceOption<T>[];
564
+ /** Validity state of the fetch operation */
565
+ readonly validity: "valid" | "invalid" | "unknown";
566
+ /** Optional message (e.g., error description) */
567
+ readonly message?: string;
568
+ }
569
+
570
+ /* Excluded from this release type: FieldNode */
571
+
572
+ /**
573
+ * Represents the runtime state of a single form field.
574
+ *
575
+ * @typeParam T - The value type of the field
576
+ *
577
+ * @public
578
+ */
579
+ export declare interface FieldState<T> {
580
+ /** Current value of the field */
581
+ readonly value: T;
582
+ /** Whether the field has been modified by the user */
583
+ readonly dirty: boolean;
584
+ /** Whether the field has been focused and blurred */
585
+ readonly touched: boolean;
586
+ /** Current validity state */
587
+ readonly validity: Validity;
588
+ /** Validation error messages, if any */
589
+ readonly errors: readonly string[];
590
+ }
591
+
592
+ /* Excluded from this release type: FormatAnnotationNode */
593
+
594
+ /* Excluded from this release type: FormatHintAnnotationNode */
595
+
596
+ /**
597
+ * Union of all form element types (fields and structural elements).
598
+ *
599
+ * @public
600
+ */
601
+ export declare type FormElement = AnyField | Group<readonly FormElement[]> | Conditional<string, unknown, readonly FormElement[]>;
602
+
603
+ /* Excluded from this release type: FormIR */
604
+
605
+ /* Excluded from this release type: FormIRElement */
606
+
607
+ /**
608
+ * A complete form specification.
609
+ *
610
+ * @typeParam Elements - Tuple of top-level form elements
611
+ *
612
+ * @public
613
+ */
614
+ export declare interface FormSpec<Elements extends readonly FormElement[]> {
615
+ /** Top-level form elements */
616
+ readonly elements: Elements;
617
+ }
618
+
619
+ /**
620
+ * Represents the runtime state of an entire form.
621
+ *
622
+ * @typeParam Schema - The form schema type (maps field names to value types)
623
+ *
624
+ * @public
625
+ */
626
+ export declare interface FormState<Schema extends Record<string, unknown>> {
627
+ /** State for each field, keyed by field name */
628
+ readonly fields: {
629
+ readonly [K in keyof Schema]: FieldState<Schema[K]>;
630
+ };
631
+ /** Whether any field has been modified */
632
+ readonly dirty: boolean;
633
+ /** Whether the form is currently being submitted */
634
+ readonly submitting: boolean;
635
+ /** Overall form validity (derived from all field validities) */
636
+ readonly validity: Validity;
637
+ }
638
+
639
+ /**
640
+ * A visual grouping of form elements.
641
+ *
642
+ * Groups provide visual organization and can be rendered as fieldsets or sections.
643
+ *
644
+ * @typeParam Elements - Tuple of contained form elements
645
+ *
646
+ * @public
647
+ */
648
+ export declare interface Group<Elements extends readonly FormElement[]> {
649
+ /** Type discriminator - identifies this as a group element */
650
+ readonly _type: "group";
651
+ /** Display label for the group */
652
+ readonly label: string;
653
+ /** Form elements contained within this group */
654
+ readonly elements: Elements;
655
+ }
656
+
657
+ /* Excluded from this release type: GroupLayoutNode */
658
+
659
+ /* Excluded from this release type: IR_VERSION */
660
+
661
+ /**
662
+ * Narrows a `FormElement` to an array field.
663
+ *
664
+ * @public
665
+ */
666
+ export declare function isArrayField(element: FormElement): element is ArrayField<string, readonly FormElement[]>;
667
+
668
+ /**
669
+ * Narrows a `FormElement` to a boolean checkbox field.
670
+ *
671
+ * @public
672
+ */
673
+ export declare function isBooleanField(element: FormElement): element is BooleanField<string>;
674
+
675
+ /**
676
+ * Narrows a `FormElement` to a conditional wrapper.
677
+ *
678
+ * @public
679
+ */
680
+ export declare function isConditional(element: FormElement): element is Conditional<string, unknown, readonly FormElement[]>;
681
+
682
+ /**
683
+ * Narrows a `FormElement` to a dynamic enum field.
684
+ *
685
+ * @public
686
+ */
687
+ export declare function isDynamicEnumField(element: FormElement): element is DynamicEnumField<string, string>;
688
+
689
+ /**
690
+ * Narrows a `FormElement` to a dynamic schema field.
691
+ *
692
+ * @public
693
+ */
694
+ export declare function isDynamicSchemaField(element: FormElement): element is DynamicSchemaField<string>;
695
+
696
+ /**
697
+ * Narrows a `FormElement` to any field type.
698
+ *
699
+ * @public
700
+ */
701
+ export declare function isField(element: FormElement): element is AnyField;
702
+
703
+ /**
704
+ * Narrows a `FormElement` to a visual group.
705
+ *
706
+ * @public
707
+ */
708
+ export declare function isGroup(element: FormElement): element is Group<readonly FormElement[]>;
709
+
710
+ /**
711
+ * Narrows a `FormElement` to a numeric input field.
712
+ *
713
+ * @public
714
+ */
715
+ export declare function isNumberField(element: FormElement): element is NumberField<string>;
716
+
717
+ /**
718
+ * Narrows a `FormElement` to an object field.
719
+ *
720
+ * @public
721
+ */
722
+ export declare function isObjectField(element: FormElement): element is ObjectField<string, readonly FormElement[]>;
723
+
724
+ /**
725
+ * Narrows a `FormElement` to a static enum field.
726
+ *
727
+ * @public
728
+ */
729
+ export declare function isStaticEnumField(element: FormElement): element is StaticEnumField<string, readonly EnumOptionValue[]>;
730
+
731
+ /**
732
+ * Narrows a `FormElement` to a text input field.
733
+ *
734
+ * @public
735
+ */
736
+ export declare function isTextField(element: FormElement): element is TextField<string>;
737
+
738
+ /* Excluded from this release type: JsonValue */
739
+
740
+ /* Excluded from this release type: LayoutNode */
741
+
742
+ /* Excluded from this release type: LengthConstraintNode */
743
+
744
+ /**
745
+ * A numeric input field.
746
+ *
747
+ * @typeParam N - The field name (string literal type)
748
+ *
749
+ * @public
750
+ */
751
+ export declare interface NumberField<N extends string> {
752
+ /** Type discriminator for form elements */
753
+ readonly _type: "field";
754
+ /** Field type discriminator - identifies this as a number field */
755
+ readonly _field: "number";
756
+ /** Unique field identifier used as the schema key */
757
+ readonly name: N;
758
+ /** Display label for the field */
759
+ readonly label?: string;
760
+ /** Minimum allowed value */
761
+ readonly min?: number;
762
+ /** Maximum allowed value */
763
+ readonly max?: number;
764
+ /** Whether this field is required for form submission */
765
+ readonly required?: boolean;
766
+ /** Value must be a multiple of this number (use 1 for integer semantics) */
767
+ readonly multipleOf?: number;
768
+ }
769
+
770
+ /* Excluded from this release type: NumericConstraintNode */
771
+
772
+ /**
773
+ * An object field containing nested properties.
774
+ *
775
+ * Use this for grouping related fields under a single key in the schema.
776
+ *
777
+ * @typeParam N - The field name (string literal type)
778
+ * @typeParam Properties - The form elements that define the object's properties
779
+ *
780
+ * @public
781
+ */
782
+ export declare interface ObjectField<N extends string, Properties extends readonly FormElement[]> {
783
+ /** Type discriminator for form elements */
784
+ readonly _type: "field";
785
+ /** Field type discriminator - identifies this as an object field */
786
+ readonly _field: "object";
787
+ /** Unique field identifier used as the schema key */
788
+ readonly name: N;
789
+ /** Form elements that define the properties of this object */
790
+ readonly properties: Properties;
791
+ /** Display label for the field */
792
+ readonly label?: string;
793
+ /** Whether this field is required for form submission */
794
+ readonly required?: boolean;
795
+ }
796
+
797
+ /* Excluded from this release type: ObjectProperty */
798
+
799
+ /* Excluded from this release type: ObjectTypeNode */
800
+
801
+ /* Excluded from this release type: PathTarget */
802
+
803
+ /* Excluded from this release type: PatternConstraintNode */
804
+
805
+ /* Excluded from this release type: PlaceholderAnnotationNode */
806
+
807
+ /**
808
+ * Union of all predicate types.
809
+ *
810
+ * Currently only supports equality, but can be extended with:
811
+ * - `OneOfPredicate` - field value is one of several options
812
+ * - `NotPredicate` - negation of another predicate
813
+ * - `AndPredicate` / `OrPredicate` - logical combinations
814
+ *
815
+ * @public
816
+ */
817
+ export declare type Predicate<K extends string = string, V = unknown> = EqualsPredicate<K, V>;
818
+
819
+ /* Excluded from this release type: PrimitiveTypeNode */
820
+
821
+ /* Excluded from this release type: Provenance */
822
+
823
+ /* Excluded from this release type: RecordTypeNode */
824
+
825
+ /* Excluded from this release type: ReferenceTypeNode */
826
+
827
+ /* Excluded from this release type: RemarksAnnotationNode */
828
+
829
+ /**
830
+ * A field with static enum options (known at compile time).
831
+ *
832
+ * Options can be plain strings or objects with `id` and `label` properties.
833
+ *
834
+ * @typeParam N - The field name (string literal type)
835
+ * @typeParam O - Tuple of option values (strings or EnumOption objects)
836
+ *
837
+ * @public
838
+ */
839
+ export declare interface StaticEnumField<N extends string, O extends readonly EnumOptionValue[]> {
840
+ /** Type discriminator for form elements */
841
+ readonly _type: "field";
842
+ /** Field type discriminator - identifies this as an enum field */
843
+ readonly _field: "enum";
844
+ /** Unique field identifier used as the schema key */
845
+ readonly name: N;
846
+ /** Array of allowed option values */
847
+ readonly options: O;
848
+ /** Display label for the field */
849
+ readonly label?: string;
850
+ /** Whether this field is required for form submission */
851
+ readonly required?: boolean;
852
+ }
853
+
854
+ /**
855
+ * Form element type definitions.
856
+ *
857
+ * These types define the structure of form specifications.
858
+ * The structure IS the definition - nesting implies layout and conditional logic.
859
+ */
860
+ /**
861
+ * A text input field.
862
+ *
863
+ * @typeParam N - The field name (string literal type)
864
+ *
865
+ * @public
866
+ */
867
+ export declare interface TextField<N extends string> {
868
+ /** Type discriminator for form elements */
869
+ readonly _type: "field";
870
+ /** Field type discriminator - identifies this as a text field */
871
+ readonly _field: "text";
872
+ /** Unique field identifier used as the schema key */
873
+ readonly name: N;
874
+ /** Display label for the field */
875
+ readonly label?: string;
876
+ /** Placeholder text shown when field is empty */
877
+ readonly placeholder?: string;
878
+ /** Whether this field is required for form submission */
879
+ readonly required?: boolean;
880
+ /** Minimum string length */
881
+ readonly minLength?: number;
882
+ /** Maximum string length */
883
+ readonly maxLength?: number;
884
+ /** Regular expression pattern the value must match */
885
+ readonly pattern?: string;
886
+ }
887
+
888
+ /* Excluded from this release type: TypeDefinition */
889
+
890
+ /* Excluded from this release type: TypeNode */
891
+
892
+ /* Excluded from this release type: UnionTypeNode */
893
+
894
+ /**
895
+ * Represents the validity state of a field or form.
896
+ *
897
+ * - `"valid"` - All validations pass
898
+ * - `"invalid"` - One or more validations failed
899
+ * - `"unknown"` - Validation state not yet determined (e.g., async validation pending)
900
+ *
901
+ * @public
902
+ */
903
+ export declare type Validity = "valid" | "invalid" | "unknown";
904
+
905
+ /**
906
+ * Registration for a vocabulary keyword to include in a JSON Schema `$vocabulary` declaration.
907
+ *
908
+ * @public
909
+ */
910
+ export declare interface VocabularyKeywordRegistration {
911
+ /** The keyword name (without vendor prefix). */
912
+ readonly keyword: string;
913
+ /** JSON Schema that describes the valid values for this keyword. */
914
+ readonly schema: ExtensionPayloadValue;
915
+ }
916
+
917
+ export { }