@formspec/constraints 0.1.0-alpha.19 → 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.
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/constraints-alpha.d.ts +914 -0
- package/dist/constraints-beta.d.ts +914 -0
- package/dist/constraints-internal.d.ts +914 -0
- package/dist/constraints.d.ts +342 -122
- package/dist/defaults.d.ts +6 -0
- package/dist/defaults.d.ts.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +10 -0
- package/dist/loader.d.ts.map +1 -1
- package/dist/types.d.ts +32 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/validators/field-options.d.ts +12 -0
- package/dist/validators/field-options.d.ts.map +1 -1
- package/dist/validators/field-types.d.ts +8 -0
- package/dist/validators/field-types.d.ts.map +1 -1
- package/dist/validators/formspec.d.ts +6 -0
- package/dist/validators/formspec.d.ts.map +1 -1
- package/dist/validators/layout.d.ts +8 -0
- package/dist/validators/layout.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/constraints.d.ts
CHANGED
|
@@ -35,11 +35,86 @@
|
|
|
35
35
|
* @packageDocumentation
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Union of all field types.
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
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[]>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* An array field containing repeating items.
|
|
47
|
+
*
|
|
48
|
+
* Use this for lists of values (e.g., multiple addresses, line items).
|
|
49
|
+
*
|
|
50
|
+
* @typeParam N - The field name (string literal type)
|
|
51
|
+
* @typeParam Items - The form elements that define each array item
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
export declare interface ArrayField<N extends string, Items extends readonly FormElement[]> {
|
|
56
|
+
/** Type discriminator for form elements */
|
|
57
|
+
readonly _type: "field";
|
|
58
|
+
/** Field type discriminator - identifies this as an array field */
|
|
59
|
+
readonly _field: "array";
|
|
60
|
+
/** Unique field identifier used as the schema key */
|
|
61
|
+
readonly name: N;
|
|
62
|
+
/** Form elements that define the schema for each array item */
|
|
63
|
+
readonly items: Items;
|
|
64
|
+
/** Display label for the field */
|
|
65
|
+
readonly label?: string;
|
|
66
|
+
/** Whether this field is required for form submission */
|
|
67
|
+
readonly required?: boolean;
|
|
68
|
+
/** Minimum number of items required */
|
|
69
|
+
readonly minItems?: number;
|
|
70
|
+
/** Maximum number of items allowed */
|
|
71
|
+
readonly maxItems?: number;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* A boolean checkbox field.
|
|
76
|
+
*
|
|
77
|
+
* @typeParam N - The field name (string literal type)
|
|
78
|
+
*
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
export declare interface BooleanField<N extends string> {
|
|
82
|
+
/** Type discriminator for form elements */
|
|
83
|
+
readonly _type: "field";
|
|
84
|
+
/** Field type discriminator - identifies this as a boolean field */
|
|
85
|
+
readonly _field: "boolean";
|
|
86
|
+
/** Unique field identifier used as the schema key */
|
|
87
|
+
readonly name: N;
|
|
88
|
+
/** Display label for the field */
|
|
89
|
+
readonly label?: string;
|
|
90
|
+
/** Whether this field is required for form submission */
|
|
91
|
+
readonly required?: boolean;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* A conditional wrapper that shows/hides elements based on another field's value.
|
|
96
|
+
*
|
|
97
|
+
* @typeParam FieldName - The field to check
|
|
98
|
+
* @typeParam Value - The value that triggers the condition
|
|
99
|
+
* @typeParam Elements - Tuple of contained form elements
|
|
100
|
+
*
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
export declare interface Conditional<FieldName extends string, Value, Elements extends readonly FormElement[]> {
|
|
104
|
+
/** Type discriminator - identifies this as a conditional element */
|
|
105
|
+
readonly _type: "conditional";
|
|
106
|
+
/** Name of the field whose value determines visibility */
|
|
107
|
+
readonly field: FieldName;
|
|
108
|
+
/** Value that triggers the condition (shows nested elements) */
|
|
109
|
+
readonly value: Value;
|
|
110
|
+
/** Form elements shown when condition is met */
|
|
111
|
+
readonly elements: Elements;
|
|
112
|
+
}
|
|
40
113
|
|
|
41
114
|
/**
|
|
42
115
|
* Complete constraint configuration for a FormSpec project.
|
|
116
|
+
*
|
|
117
|
+
* @public
|
|
43
118
|
*/
|
|
44
119
|
export declare interface ConstraintConfig {
|
|
45
120
|
/** Field type constraints */
|
|
@@ -57,6 +132,8 @@ export declare interface ConstraintConfig {
|
|
|
57
132
|
/**
|
|
58
133
|
* Control options constraints - control which JSONForms Control.options are allowed.
|
|
59
134
|
* These are renderer-specific options that may not be universally supported.
|
|
135
|
+
*
|
|
136
|
+
* @public
|
|
60
137
|
*/
|
|
61
138
|
export declare interface ControlOptionConstraints {
|
|
62
139
|
/** format - renderer format hint (e.g., "radio", "textarea") */
|
|
@@ -73,16 +150,9 @@ export declare interface ControlOptionConstraints {
|
|
|
73
150
|
custom?: Record<string, Severity>;
|
|
74
151
|
}
|
|
75
152
|
|
|
76
|
-
|
|
77
|
-
* Default FormSpec configuration.
|
|
78
|
-
*/
|
|
79
|
-
export declare const DEFAULT_CONFIG: FormSpecConfig;
|
|
153
|
+
/* Excluded from this release type: DEFAULT_CONFIG */
|
|
80
154
|
|
|
81
|
-
|
|
82
|
-
* Default constraint configuration that allows all features.
|
|
83
|
-
* All constraints default to "off" (allowed).
|
|
84
|
-
*/
|
|
85
|
-
export declare const DEFAULT_CONSTRAINTS: ResolvedConstraintConfig;
|
|
155
|
+
/* Excluded from this release type: DEFAULT_CONSTRAINTS */
|
|
86
156
|
|
|
87
157
|
/**
|
|
88
158
|
* Creates a constraint configuration directly from an object.
|
|
@@ -103,25 +173,87 @@ export declare const DEFAULT_CONSTRAINTS: ResolvedConstraintConfig;
|
|
|
103
173
|
* },
|
|
104
174
|
* });
|
|
105
175
|
* ```
|
|
176
|
+
*
|
|
177
|
+
* @public
|
|
106
178
|
*/
|
|
107
179
|
export declare function defineConstraints(config: ConstraintConfig): ResolvedConstraintConfig;
|
|
108
180
|
|
|
109
181
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
182
|
+
* A field with dynamic enum options (fetched from a data source at runtime).
|
|
183
|
+
*
|
|
184
|
+
* @typeParam N - The field name (string literal type)
|
|
185
|
+
* @typeParam Source - The data source key (from DataSourceRegistry)
|
|
186
|
+
*
|
|
187
|
+
* @public
|
|
188
|
+
*/
|
|
189
|
+
export declare interface DynamicEnumField<N extends string, Source extends string> {
|
|
190
|
+
/** Type discriminator for form elements */
|
|
191
|
+
readonly _type: "field";
|
|
192
|
+
/** Field type discriminator - identifies this as a dynamic enum field */
|
|
193
|
+
readonly _field: "dynamic_enum";
|
|
194
|
+
/** Unique field identifier used as the schema key */
|
|
195
|
+
readonly name: N;
|
|
196
|
+
/** Data source key for fetching options at runtime */
|
|
197
|
+
readonly source: Source;
|
|
198
|
+
/** Display label for the field */
|
|
199
|
+
readonly label?: string;
|
|
200
|
+
/** Whether this field is required for form submission */
|
|
201
|
+
readonly required?: boolean;
|
|
202
|
+
/** Field names whose values are needed to fetch options */
|
|
203
|
+
readonly params?: readonly string[];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* A field that loads its schema dynamically (e.g., from an extension).
|
|
208
|
+
*
|
|
209
|
+
* @typeParam N - The field name (string literal type)
|
|
210
|
+
*
|
|
211
|
+
* @public
|
|
212
|
+
*/
|
|
213
|
+
export declare interface DynamicSchemaField<N extends string> {
|
|
214
|
+
/** Type discriminator for form elements */
|
|
215
|
+
readonly _type: "field";
|
|
216
|
+
/** Field type discriminator - identifies this as a dynamic schema field */
|
|
217
|
+
readonly _field: "dynamic_schema";
|
|
218
|
+
/** Unique field identifier used as the schema key */
|
|
219
|
+
readonly name: N;
|
|
220
|
+
/** Identifier for the schema source */
|
|
221
|
+
readonly schemaSource: string;
|
|
222
|
+
/** Display label for the field */
|
|
223
|
+
readonly label?: string;
|
|
224
|
+
/** Whether this field is required for form submission */
|
|
225
|
+
readonly required?: boolean;
|
|
226
|
+
/** Field names whose values are needed to configure the schema */
|
|
227
|
+
readonly params?: readonly string[];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* An enum option with a separate ID and display label.
|
|
232
|
+
*
|
|
233
|
+
* Use this when the stored value (id) should differ from the display text (label).
|
|
112
234
|
*
|
|
113
|
-
* @
|
|
114
|
-
* @returns Array of present option names
|
|
235
|
+
* @public
|
|
115
236
|
*/
|
|
116
|
-
export declare
|
|
237
|
+
export declare interface EnumOption {
|
|
238
|
+
readonly id: string;
|
|
239
|
+
readonly label: string;
|
|
240
|
+
}
|
|
117
241
|
|
|
118
242
|
/**
|
|
119
|
-
*
|
|
243
|
+
* Valid enum option types: either plain strings or objects with id/label.
|
|
244
|
+
*
|
|
245
|
+
* @public
|
|
120
246
|
*/
|
|
121
|
-
export declare type
|
|
247
|
+
export declare type EnumOptionValue = string | EnumOption;
|
|
248
|
+
|
|
249
|
+
/* Excluded from this release type: extractFieldOptions */
|
|
250
|
+
|
|
251
|
+
/* Excluded from this release type: FieldOption */
|
|
122
252
|
|
|
123
253
|
/**
|
|
124
254
|
* Field configuration option constraints - control which field options are allowed.
|
|
255
|
+
*
|
|
256
|
+
* @public
|
|
125
257
|
*/
|
|
126
258
|
export declare interface FieldOptionConstraints {
|
|
127
259
|
/** label - field label text */
|
|
@@ -140,21 +272,13 @@ export declare interface FieldOptionConstraints {
|
|
|
140
272
|
maxItems?: Severity;
|
|
141
273
|
}
|
|
142
274
|
|
|
143
|
-
|
|
144
|
-
* Context for field option validation.
|
|
145
|
-
*/
|
|
146
|
-
export declare interface FieldOptionsContext {
|
|
147
|
-
/** The field name */
|
|
148
|
-
fieldName: string;
|
|
149
|
-
/** Which options are present on this field */
|
|
150
|
-
presentOptions: FieldOption[];
|
|
151
|
-
/** Path to this field */
|
|
152
|
-
path?: string;
|
|
153
|
-
}
|
|
275
|
+
/* Excluded from this release type: FieldOptionsContext */
|
|
154
276
|
|
|
155
277
|
/**
|
|
156
278
|
* Field type constraints - control which field types are allowed.
|
|
157
279
|
* Fine-grained control over each DSL field builder.
|
|
280
|
+
*
|
|
281
|
+
* @public
|
|
158
282
|
*/
|
|
159
283
|
export declare interface FieldTypeConstraints {
|
|
160
284
|
/** field.text() - basic text input */
|
|
@@ -175,21 +299,32 @@ export declare interface FieldTypeConstraints {
|
|
|
175
299
|
object?: Severity;
|
|
176
300
|
}
|
|
177
301
|
|
|
302
|
+
/* Excluded from this release type: FieldTypeContext */
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Union of all form element types (fields and structural elements).
|
|
306
|
+
*
|
|
307
|
+
* @public
|
|
308
|
+
*/
|
|
309
|
+
export declare type FormElement = AnyField | Group<readonly FormElement[]> | Conditional<string, unknown, readonly FormElement[]>;
|
|
310
|
+
|
|
178
311
|
/**
|
|
179
|
-
*
|
|
312
|
+
* A complete form specification.
|
|
313
|
+
*
|
|
314
|
+
* @typeParam Elements - Tuple of top-level form elements
|
|
315
|
+
*
|
|
316
|
+
* @public
|
|
180
317
|
*/
|
|
181
|
-
export declare interface
|
|
182
|
-
/**
|
|
183
|
-
|
|
184
|
-
/** The field name */
|
|
185
|
-
fieldName: string;
|
|
186
|
-
/** Optional path for nested fields */
|
|
187
|
-
path?: string;
|
|
318
|
+
export declare interface FormSpec<Elements extends readonly FormElement[]> {
|
|
319
|
+
/** Top-level form elements */
|
|
320
|
+
readonly elements: Elements;
|
|
188
321
|
}
|
|
189
322
|
|
|
190
323
|
/**
|
|
191
324
|
* Top-level FormSpec configuration file structure.
|
|
192
325
|
* The .formspec.yml file uses this structure.
|
|
326
|
+
*
|
|
327
|
+
* @public
|
|
193
328
|
*/
|
|
194
329
|
export declare interface FormSpecConfig {
|
|
195
330
|
/** Constraint configuration */
|
|
@@ -198,69 +333,48 @@ export declare interface FormSpecConfig {
|
|
|
198
333
|
|
|
199
334
|
/**
|
|
200
335
|
* Options for validating FormSpec elements.
|
|
336
|
+
*
|
|
337
|
+
* @public
|
|
201
338
|
*/
|
|
202
339
|
export declare interface FormSpecValidationOptions {
|
|
203
340
|
/** Constraint configuration (will be merged with defaults) */
|
|
204
341
|
constraints?: ConstraintConfig;
|
|
205
342
|
}
|
|
206
343
|
|
|
207
|
-
|
|
208
|
-
* Gets the severity level for a field option.
|
|
209
|
-
*
|
|
210
|
-
* @param option - The option to check
|
|
211
|
-
* @param constraints - Field option constraints
|
|
212
|
-
* @returns Severity level, or "off" if not constrained
|
|
213
|
-
*/
|
|
214
|
-
export declare function getFieldOptionSeverity(option: FieldOption, constraints: FieldOptionConstraints): Severity;
|
|
344
|
+
/* Excluded from this release type: getFieldOptionSeverity */
|
|
215
345
|
|
|
216
|
-
|
|
217
|
-
* Gets the severity level for a field type.
|
|
218
|
-
*
|
|
219
|
-
* @param fieldType - The _field discriminator value
|
|
220
|
-
* @param constraints - Field type constraints
|
|
221
|
-
* @returns Severity level, or "off" if not constrained
|
|
222
|
-
*/
|
|
223
|
-
export declare function getFieldTypeSeverity(fieldType: string, constraints: FieldTypeConstraints): Severity;
|
|
346
|
+
/* Excluded from this release type: getFieldTypeSeverity */
|
|
224
347
|
|
|
225
348
|
/**
|
|
226
|
-
*
|
|
349
|
+
* A visual grouping of form elements.
|
|
227
350
|
*
|
|
228
|
-
*
|
|
229
|
-
* @param constraints - Field option constraints
|
|
230
|
-
* @returns true if allowed, false if disallowed
|
|
231
|
-
*/
|
|
232
|
-
export declare function isFieldOptionAllowed(option: FieldOption, constraints: FieldOptionConstraints): boolean;
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Checks if a field type is allowed by the constraints.
|
|
236
|
-
* Useful for quick checks without generating issues.
|
|
351
|
+
* Groups provide visual organization and can be rendered as fieldsets or sections.
|
|
237
352
|
*
|
|
238
|
-
* @
|
|
239
|
-
* @param constraints - Field type constraints
|
|
240
|
-
* @returns true if allowed, false if disallowed
|
|
241
|
-
*/
|
|
242
|
-
export declare function isFieldTypeAllowed(fieldType: string, constraints: FieldTypeConstraints): boolean;
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Checks if a layout type is allowed by the constraints.
|
|
353
|
+
* @typeParam Elements - Tuple of contained form elements
|
|
246
354
|
*
|
|
247
|
-
* @
|
|
248
|
-
* @param constraints - Layout constraints
|
|
249
|
-
* @returns true if allowed, false if disallowed
|
|
355
|
+
* @public
|
|
250
356
|
*/
|
|
251
|
-
export declare
|
|
357
|
+
export declare interface Group<Elements extends readonly FormElement[]> {
|
|
358
|
+
/** Type discriminator - identifies this as a group element */
|
|
359
|
+
readonly _type: "group";
|
|
360
|
+
/** Display label for the group */
|
|
361
|
+
readonly label: string;
|
|
362
|
+
/** Form elements contained within this group */
|
|
363
|
+
readonly elements: Elements;
|
|
364
|
+
}
|
|
252
365
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
*/
|
|
260
|
-
export declare function isNestingDepthAllowed(depth: number, constraints: LayoutConstraints): boolean;
|
|
366
|
+
/* Excluded from this release type: isFieldOptionAllowed */
|
|
367
|
+
|
|
368
|
+
/* Excluded from this release type: isFieldTypeAllowed */
|
|
369
|
+
|
|
370
|
+
/* Excluded from this release type: isLayoutTypeAllowed */
|
|
371
|
+
|
|
372
|
+
/* Excluded from this release type: isNestingDepthAllowed */
|
|
261
373
|
|
|
262
374
|
/**
|
|
263
375
|
* Layout and structure constraints - control grouping, conditionals, nesting.
|
|
376
|
+
*
|
|
377
|
+
* @public
|
|
264
378
|
*/
|
|
265
379
|
export declare interface LayoutConstraints {
|
|
266
380
|
/** group() - visual grouping of fields */
|
|
@@ -271,22 +385,12 @@ export declare interface LayoutConstraints {
|
|
|
271
385
|
maxNestingDepth?: number;
|
|
272
386
|
}
|
|
273
387
|
|
|
274
|
-
|
|
275
|
-
* Context for layout validation.
|
|
276
|
-
*/
|
|
277
|
-
export declare interface LayoutContext {
|
|
278
|
-
/** The type of layout element ("group" | "conditional") */
|
|
279
|
-
layoutType: "group" | "conditional";
|
|
280
|
-
/** Optional label for the element (for groups) */
|
|
281
|
-
label?: string;
|
|
282
|
-
/** Current nesting depth */
|
|
283
|
-
depth: number;
|
|
284
|
-
/** Path to this element */
|
|
285
|
-
path?: string;
|
|
286
|
-
}
|
|
388
|
+
/* Excluded from this release type: LayoutContext */
|
|
287
389
|
|
|
288
390
|
/**
|
|
289
391
|
* JSONForms layout type constraints.
|
|
392
|
+
*
|
|
393
|
+
* @public
|
|
290
394
|
*/
|
|
291
395
|
export declare interface LayoutTypeConstraints {
|
|
292
396
|
/** VerticalLayout - stack elements vertically */
|
|
@@ -318,6 +422,8 @@ export declare interface LayoutTypeConstraints {
|
|
|
318
422
|
* // Load from specific file
|
|
319
423
|
* const result = await loadConfig({ configPath: '/path/to/config.yml' });
|
|
320
424
|
* ```
|
|
425
|
+
*
|
|
426
|
+
* @public
|
|
321
427
|
*/
|
|
322
428
|
export declare function loadConfig(options?: LoadConfigOptions): Promise<LoadConfigResult>;
|
|
323
429
|
|
|
@@ -327,11 +433,15 @@ export declare function loadConfig(options?: LoadConfigOptions): Promise<LoadCon
|
|
|
327
433
|
*
|
|
328
434
|
* @param yamlContent - The YAML content to parse
|
|
329
435
|
* @returns The parsed and merged configuration
|
|
436
|
+
*
|
|
437
|
+
* @public
|
|
330
438
|
*/
|
|
331
439
|
export declare function loadConfigFromString(yamlContent: string): ResolvedConstraintConfig;
|
|
332
440
|
|
|
333
441
|
/**
|
|
334
442
|
* Options for loading configuration.
|
|
443
|
+
*
|
|
444
|
+
* @public
|
|
335
445
|
*/
|
|
336
446
|
export declare interface LoadConfigOptions {
|
|
337
447
|
/**
|
|
@@ -353,6 +463,8 @@ export declare interface LoadConfigOptions {
|
|
|
353
463
|
|
|
354
464
|
/**
|
|
355
465
|
* Result of loading configuration.
|
|
466
|
+
*
|
|
467
|
+
* @public
|
|
356
468
|
*/
|
|
357
469
|
export declare interface LoadConfigResult {
|
|
358
470
|
/** The loaded and merged configuration */
|
|
@@ -363,14 +475,64 @@ export declare interface LoadConfigResult {
|
|
|
363
475
|
found: boolean;
|
|
364
476
|
}
|
|
365
477
|
|
|
478
|
+
/* Excluded from this release type: mergeWithDefaults */
|
|
479
|
+
|
|
366
480
|
/**
|
|
367
|
-
*
|
|
481
|
+
* A numeric input field.
|
|
482
|
+
*
|
|
483
|
+
* @typeParam N - The field name (string literal type)
|
|
484
|
+
*
|
|
485
|
+
* @public
|
|
368
486
|
*/
|
|
369
|
-
export declare
|
|
487
|
+
export declare interface NumberField<N extends string> {
|
|
488
|
+
/** Type discriminator for form elements */
|
|
489
|
+
readonly _type: "field";
|
|
490
|
+
/** Field type discriminator - identifies this as a number field */
|
|
491
|
+
readonly _field: "number";
|
|
492
|
+
/** Unique field identifier used as the schema key */
|
|
493
|
+
readonly name: N;
|
|
494
|
+
/** Display label for the field */
|
|
495
|
+
readonly label?: string;
|
|
496
|
+
/** Minimum allowed value */
|
|
497
|
+
readonly min?: number;
|
|
498
|
+
/** Maximum allowed value */
|
|
499
|
+
readonly max?: number;
|
|
500
|
+
/** Whether this field is required for form submission */
|
|
501
|
+
readonly required?: boolean;
|
|
502
|
+
/** Value must be a multiple of this number (use 1 for integer semantics) */
|
|
503
|
+
readonly multipleOf?: number;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* An object field containing nested properties.
|
|
508
|
+
*
|
|
509
|
+
* Use this for grouping related fields under a single key in the schema.
|
|
510
|
+
*
|
|
511
|
+
* @typeParam N - The field name (string literal type)
|
|
512
|
+
* @typeParam Properties - The form elements that define the object's properties
|
|
513
|
+
*
|
|
514
|
+
* @public
|
|
515
|
+
*/
|
|
516
|
+
export declare interface ObjectField<N extends string, Properties extends readonly FormElement[]> {
|
|
517
|
+
/** Type discriminator for form elements */
|
|
518
|
+
readonly _type: "field";
|
|
519
|
+
/** Field type discriminator - identifies this as an object field */
|
|
520
|
+
readonly _field: "object";
|
|
521
|
+
/** Unique field identifier used as the schema key */
|
|
522
|
+
readonly name: N;
|
|
523
|
+
/** Form elements that define the properties of this object */
|
|
524
|
+
readonly properties: Properties;
|
|
525
|
+
/** Display label for the field */
|
|
526
|
+
readonly label?: string;
|
|
527
|
+
/** Whether this field is required for form submission */
|
|
528
|
+
readonly required?: boolean;
|
|
529
|
+
}
|
|
370
530
|
|
|
371
531
|
/**
|
|
372
532
|
* Fully resolved constraint configuration with all properties required.
|
|
373
533
|
* This is the type returned by mergeWithDefaults().
|
|
534
|
+
*
|
|
535
|
+
* @public
|
|
374
536
|
*/
|
|
375
537
|
export declare interface ResolvedConstraintConfig {
|
|
376
538
|
fieldTypes: Required<FieldTypeConstraints>;
|
|
@@ -382,6 +544,8 @@ export declare interface ResolvedConstraintConfig {
|
|
|
382
544
|
|
|
383
545
|
/**
|
|
384
546
|
* Fully resolved rule constraints with all properties required.
|
|
547
|
+
*
|
|
548
|
+
* @public
|
|
385
549
|
*/
|
|
386
550
|
export declare interface ResolvedRuleConstraints {
|
|
387
551
|
enabled: Severity;
|
|
@@ -390,6 +554,8 @@ export declare interface ResolvedRuleConstraints {
|
|
|
390
554
|
|
|
391
555
|
/**
|
|
392
556
|
* Fully resolved UI schema constraints with all properties required.
|
|
557
|
+
*
|
|
558
|
+
* @public
|
|
393
559
|
*/
|
|
394
560
|
export declare interface ResolvedUISchemaConstraints {
|
|
395
561
|
layouts: Required<LayoutTypeConstraints>;
|
|
@@ -398,6 +564,8 @@ export declare interface ResolvedUISchemaConstraints {
|
|
|
398
564
|
|
|
399
565
|
/**
|
|
400
566
|
* JSONForms rule constraints.
|
|
567
|
+
*
|
|
568
|
+
* @public
|
|
401
569
|
*/
|
|
402
570
|
export declare interface RuleConstraints {
|
|
403
571
|
/** Whether rules are enabled at all */
|
|
@@ -408,6 +576,8 @@ export declare interface RuleConstraints {
|
|
|
408
576
|
|
|
409
577
|
/**
|
|
410
578
|
* JSONForms rule effect constraints.
|
|
579
|
+
*
|
|
580
|
+
* @public
|
|
411
581
|
*/
|
|
412
582
|
export declare interface RuleEffectConstraints {
|
|
413
583
|
/** SHOW - show element when condition is true */
|
|
@@ -425,36 +595,85 @@ export declare interface RuleEffectConstraints {
|
|
|
425
595
|
* - "error": Violation fails validation
|
|
426
596
|
* - "warn": Violation emits warning but passes
|
|
427
597
|
* - "off": Feature is allowed (no violation)
|
|
598
|
+
*
|
|
599
|
+
* @public
|
|
428
600
|
*/
|
|
429
601
|
export declare type Severity = "error" | "warn" | "off";
|
|
430
602
|
|
|
431
603
|
/**
|
|
432
|
-
*
|
|
604
|
+
* A field with static enum options (known at compile time).
|
|
605
|
+
*
|
|
606
|
+
* Options can be plain strings or objects with `id` and `label` properties.
|
|
607
|
+
*
|
|
608
|
+
* @typeParam N - The field name (string literal type)
|
|
609
|
+
* @typeParam O - Tuple of option values (strings or EnumOption objects)
|
|
610
|
+
*
|
|
611
|
+
* @public
|
|
433
612
|
*/
|
|
434
|
-
export declare interface
|
|
435
|
-
/**
|
|
436
|
-
|
|
437
|
-
/**
|
|
438
|
-
|
|
613
|
+
export declare interface StaticEnumField<N extends string, O extends readonly EnumOptionValue[]> {
|
|
614
|
+
/** Type discriminator for form elements */
|
|
615
|
+
readonly _type: "field";
|
|
616
|
+
/** Field type discriminator - identifies this as an enum field */
|
|
617
|
+
readonly _field: "enum";
|
|
618
|
+
/** Unique field identifier used as the schema key */
|
|
619
|
+
readonly name: N;
|
|
620
|
+
/** Array of allowed option values */
|
|
621
|
+
readonly options: O;
|
|
622
|
+
/** Display label for the field */
|
|
623
|
+
readonly label?: string;
|
|
624
|
+
/** Whether this field is required for form submission */
|
|
625
|
+
readonly required?: boolean;
|
|
439
626
|
}
|
|
440
627
|
|
|
441
628
|
/**
|
|
442
|
-
*
|
|
629
|
+
* Form element type definitions.
|
|
630
|
+
*
|
|
631
|
+
* These types define the structure of form specifications.
|
|
632
|
+
* The structure IS the definition - nesting implies layout and conditional logic.
|
|
633
|
+
*/
|
|
634
|
+
/**
|
|
635
|
+
* A text input field.
|
|
443
636
|
*
|
|
444
|
-
* @
|
|
445
|
-
*
|
|
446
|
-
* @
|
|
637
|
+
* @typeParam N - The field name (string literal type)
|
|
638
|
+
*
|
|
639
|
+
* @public
|
|
447
640
|
*/
|
|
448
|
-
export declare
|
|
641
|
+
export declare interface TextField<N extends string> {
|
|
642
|
+
/** Type discriminator for form elements */
|
|
643
|
+
readonly _type: "field";
|
|
644
|
+
/** Field type discriminator - identifies this as a text field */
|
|
645
|
+
readonly _field: "text";
|
|
646
|
+
/** Unique field identifier used as the schema key */
|
|
647
|
+
readonly name: N;
|
|
648
|
+
/** Display label for the field */
|
|
649
|
+
readonly label?: string;
|
|
650
|
+
/** Placeholder text shown when field is empty */
|
|
651
|
+
readonly placeholder?: string;
|
|
652
|
+
/** Whether this field is required for form submission */
|
|
653
|
+
readonly required?: boolean;
|
|
654
|
+
/** Minimum string length */
|
|
655
|
+
readonly minLength?: number;
|
|
656
|
+
/** Maximum string length */
|
|
657
|
+
readonly maxLength?: number;
|
|
658
|
+
/** Regular expression pattern the value must match */
|
|
659
|
+
readonly pattern?: string;
|
|
660
|
+
}
|
|
449
661
|
|
|
450
662
|
/**
|
|
451
|
-
*
|
|
663
|
+
* UI Schema feature constraints - control JSONForms-specific features.
|
|
452
664
|
*
|
|
453
|
-
* @
|
|
454
|
-
* @param constraints - Field type constraints
|
|
455
|
-
* @returns Array of validation issues (empty if valid)
|
|
665
|
+
* @public
|
|
456
666
|
*/
|
|
457
|
-
export declare
|
|
667
|
+
export declare interface UISchemaConstraints {
|
|
668
|
+
/** Layout type constraints */
|
|
669
|
+
layouts?: LayoutTypeConstraints;
|
|
670
|
+
/** Rule (conditional) constraints */
|
|
671
|
+
rules?: RuleConstraints;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
/* Excluded from this release type: validateFieldOptions */
|
|
675
|
+
|
|
676
|
+
/* Excluded from this release type: validateFieldTypes */
|
|
458
677
|
|
|
459
678
|
/**
|
|
460
679
|
* Validates a complete FormSpec against constraints.
|
|
@@ -462,6 +681,8 @@ export declare function validateFieldTypes(context: FieldTypeContext, constraint
|
|
|
462
681
|
* @param formSpec - The FormSpec to validate
|
|
463
682
|
* @param options - Validation options including constraints
|
|
464
683
|
* @returns Validation result with all issues found
|
|
684
|
+
*
|
|
685
|
+
* @public
|
|
465
686
|
*/
|
|
466
687
|
export declare function validateFormSpec(formSpec: FormSpec<readonly FormElement[]>, options?: FormSpecValidationOptions): ValidationResult;
|
|
467
688
|
|
|
@@ -499,20 +720,17 @@ export declare function validateFormSpec(formSpec: FormSpec<readonly FormElement
|
|
|
499
720
|
* console.error('Validation failed:', result.issues);
|
|
500
721
|
* }
|
|
501
722
|
* ```
|
|
723
|
+
*
|
|
724
|
+
* @public
|
|
502
725
|
*/
|
|
503
726
|
export declare function validateFormSpecElements(elements: readonly FormElement[], options?: FormSpecValidationOptions): ValidationResult;
|
|
504
727
|
|
|
505
|
-
|
|
506
|
-
* Validates a layout element against constraints.
|
|
507
|
-
*
|
|
508
|
-
* @param context - Information about the layout element
|
|
509
|
-
* @param constraints - Layout constraints
|
|
510
|
-
* @returns Array of validation issues (empty if valid)
|
|
511
|
-
*/
|
|
512
|
-
export declare function validateLayout(context: LayoutContext, constraints: LayoutConstraints): ValidationIssue[];
|
|
728
|
+
/* Excluded from this release type: validateLayout */
|
|
513
729
|
|
|
514
730
|
/**
|
|
515
731
|
* A single validation issue found during constraint checking.
|
|
732
|
+
*
|
|
733
|
+
* @public
|
|
516
734
|
*/
|
|
517
735
|
export declare interface ValidationIssue {
|
|
518
736
|
/** Unique code identifying the issue type */
|
|
@@ -533,6 +751,8 @@ export declare interface ValidationIssue {
|
|
|
533
751
|
|
|
534
752
|
/**
|
|
535
753
|
* Result of validating a FormSpec or schema against constraints.
|
|
754
|
+
*
|
|
755
|
+
* @public
|
|
536
756
|
*/
|
|
537
757
|
export declare interface ValidationResult {
|
|
538
758
|
/** Whether validation passed (no errors, warnings OK) */
|
package/dist/defaults.d.ts
CHANGED
|
@@ -2,14 +2,20 @@ import type { ConstraintConfig, FormSpecConfig, ResolvedConstraintConfig } from
|
|
|
2
2
|
/**
|
|
3
3
|
* Default constraint configuration that allows all features.
|
|
4
4
|
* All constraints default to "off" (allowed).
|
|
5
|
+
*
|
|
6
|
+
* @beta
|
|
5
7
|
*/
|
|
6
8
|
export declare const DEFAULT_CONSTRAINTS: ResolvedConstraintConfig;
|
|
7
9
|
/**
|
|
8
10
|
* Default FormSpec configuration.
|
|
11
|
+
*
|
|
12
|
+
* @beta
|
|
9
13
|
*/
|
|
10
14
|
export declare const DEFAULT_CONFIG: FormSpecConfig;
|
|
11
15
|
/**
|
|
12
16
|
* Merges user constraints with defaults, filling in any missing values.
|
|
17
|
+
*
|
|
18
|
+
* @beta
|
|
13
19
|
*/
|
|
14
20
|
export declare function mergeWithDefaults(config: ConstraintConfig | undefined): ResolvedConstraintConfig;
|
|
15
21
|
//# sourceMappingURL=defaults.d.ts.map
|