@formspec/build 0.1.0-alpha.5 → 0.1.0-alpha.50
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/LICENSE +21 -0
- package/README.md +238 -93
- package/dist/analyzer/class-analyzer.d.ts +135 -0
- package/dist/analyzer/class-analyzer.d.ts.map +1 -0
- package/dist/analyzer/jsdoc-constraints.d.ts +53 -0
- package/dist/analyzer/jsdoc-constraints.d.ts.map +1 -0
- package/dist/analyzer/program.d.ts +97 -0
- package/dist/analyzer/program.d.ts.map +1 -0
- package/dist/analyzer/tsdoc-parser.d.ts +124 -0
- package/dist/analyzer/tsdoc-parser.d.ts.map +1 -0
- package/dist/browser.cjs +2212 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.ts +74 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +2167 -0
- package/dist/browser.js.map +1 -0
- package/dist/build-alpha.d.ts +2408 -0
- package/dist/build-beta.d.ts +2408 -0
- package/dist/build-internal.d.ts +2408 -0
- package/dist/build.d.ts +2209 -151
- package/dist/canonicalize/chain-dsl-canonicalizer.d.ts +22 -0
- package/dist/canonicalize/chain-dsl-canonicalizer.d.ts.map +1 -0
- package/dist/canonicalize/index.d.ts +8 -0
- package/dist/canonicalize/index.d.ts.map +1 -0
- package/dist/canonicalize/tsdoc-canonicalizer.d.ts +38 -0
- package/dist/canonicalize/tsdoc-canonicalizer.d.ts.map +1 -0
- package/dist/cli.cjs +7111 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.js +7070 -103
- package/dist/cli.js.map +1 -1
- package/dist/extensions/index.d.ts +8 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/extensions/registry.d.ts +142 -0
- package/dist/extensions/registry.d.ts.map +1 -0
- package/dist/extensions/resolve-custom-type.d.ts +37 -0
- package/dist/extensions/resolve-custom-type.d.ts.map +1 -0
- package/dist/extensions/symbol-registry.d.ts +33 -0
- package/dist/extensions/symbol-registry.d.ts.map +1 -0
- package/dist/extensions/ts-type-utils.d.ts +40 -0
- package/dist/extensions/ts-type-utils.d.ts.map +1 -0
- package/dist/generators/class-schema.d.ts +392 -0
- package/dist/generators/class-schema.d.ts.map +1 -0
- package/dist/generators/discovered-schema.d.ts +152 -0
- package/dist/generators/discovered-schema.d.ts.map +1 -0
- package/dist/generators/method-schema.d.ts +72 -0
- package/dist/generators/method-schema.d.ts.map +1 -0
- package/dist/generators/mixed-authoring.d.ts +52 -0
- package/dist/generators/mixed-authoring.d.ts.map +1 -0
- package/dist/index.cjs +6786 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +51 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6751 -107
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +5736 -0
- package/dist/internals.cjs.map +1 -0
- package/dist/internals.d.ts +32 -0
- package/dist/internals.d.ts.map +1 -0
- package/dist/internals.js +5706 -0
- package/dist/internals.js.map +1 -0
- package/dist/json-schema/generator.d.ts +32 -6
- package/dist/json-schema/generator.d.ts.map +1 -1
- package/dist/json-schema/ir-generator.d.ts +149 -0
- package/dist/json-schema/ir-generator.d.ts.map +1 -0
- package/dist/json-schema/schema.d.ts +23 -0
- package/dist/json-schema/schema.d.ts.map +1 -0
- package/dist/json-schema/types.d.ts +76 -2
- package/dist/json-schema/types.d.ts.map +1 -1
- package/dist/metadata/collision-guards.d.ts +3 -0
- package/dist/metadata/collision-guards.d.ts.map +1 -0
- package/dist/metadata/index.d.ts +7 -0
- package/dist/metadata/index.d.ts.map +1 -0
- package/dist/metadata/policy.d.ts +12 -0
- package/dist/metadata/policy.d.ts.map +1 -0
- package/dist/metadata/resolve.d.ts +21 -0
- package/dist/metadata/resolve.d.ts.map +1 -0
- package/dist/static-build.d.ts +61 -0
- package/dist/static-build.d.ts.map +1 -0
- package/dist/ui-schema/generator.d.ts +18 -2
- package/dist/ui-schema/generator.d.ts.map +1 -1
- package/dist/ui-schema/ir-generator.d.ts +54 -0
- package/dist/ui-schema/ir-generator.d.ts.map +1 -0
- package/dist/ui-schema/schema.d.ts +429 -0
- package/dist/ui-schema/schema.d.ts.map +1 -0
- package/dist/ui-schema/types.d.ts +179 -35
- package/dist/ui-schema/types.d.ts.map +1 -1
- package/dist/validate/constraint-validator.d.ts +85 -0
- package/dist/validate/constraint-validator.d.ts.map +1 -0
- package/dist/validate/index.d.ts +9 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/package.json +30 -11
- package/dist/__tests__/cli.test.d.ts +0 -2
- package/dist/__tests__/cli.test.d.ts.map +0 -1
- package/dist/__tests__/cli.test.js +0 -178
- package/dist/__tests__/cli.test.js.map +0 -1
- package/dist/__tests__/edge-cases.test.d.ts +0 -7
- package/dist/__tests__/edge-cases.test.d.ts.map +0 -1
- package/dist/__tests__/edge-cases.test.js +0 -217
- package/dist/__tests__/edge-cases.test.js.map +0 -1
- package/dist/__tests__/generator.test.d.ts +0 -2
- package/dist/__tests__/generator.test.d.ts.map +0 -1
- package/dist/__tests__/generator.test.js +0 -234
- package/dist/__tests__/generator.test.js.map +0 -1
- package/dist/__tests__/integration.test.d.ts +0 -8
- package/dist/__tests__/integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration.test.js +0 -163
- package/dist/__tests__/integration.test.js.map +0 -1
- package/dist/__tests__/write-schemas.test.d.ts +0 -2
- package/dist/__tests__/write-schemas.test.d.ts.map +0 -1
- package/dist/__tests__/write-schemas.test.js +0 -196
- package/dist/__tests__/write-schemas.test.js.map +0 -1
- package/dist/json-schema/generator.js +0 -167
- package/dist/json-schema/generator.js.map +0 -1
- package/dist/json-schema/types.js +0 -7
- package/dist/json-schema/types.js.map +0 -1
- package/dist/ui-schema/generator.js +0 -150
- package/dist/ui-schema/generator.js.map +0 -1
- package/dist/ui-schema/types.js +0 -8
- package/dist/ui-schema/types.js.map +0 -1
|
@@ -0,0 +1,2408 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@formspec/build` - Build tools for FormSpec
|
|
3
|
+
*
|
|
4
|
+
* This package provides generators to compile FormSpec forms into:
|
|
5
|
+
* - JSON Schema 2020-12 (for validation)
|
|
6
|
+
* - JSON Forms UI Schema (for rendering)
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { buildFormSchemas } from "@formspec/build";
|
|
11
|
+
* import { formspec, field, group } from "@formspec/dsl";
|
|
12
|
+
*
|
|
13
|
+
* const form = formspec(
|
|
14
|
+
* group("Customer",
|
|
15
|
+
* field.text("name", { label: "Name", required: true }),
|
|
16
|
+
* field.text("email", { label: "Email" }),
|
|
17
|
+
* ),
|
|
18
|
+
* );
|
|
19
|
+
*
|
|
20
|
+
* const { jsonSchema, uiSchema } = buildFormSchemas(form);
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @packageDocumentation
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { AnyField } from '@formspec/core';
|
|
27
|
+
import { ArrayField } from '@formspec/core';
|
|
28
|
+
import { BooleanField } from '@formspec/core';
|
|
29
|
+
import { BuiltinConstraintBroadeningRegistration } from '@formspec/core';
|
|
30
|
+
import { Conditional } from '@formspec/core';
|
|
31
|
+
import { ConstraintTagRegistration } from '@formspec/core';
|
|
32
|
+
import { CustomAnnotationRegistration } from '@formspec/core';
|
|
33
|
+
import { CustomConstraintRegistration } from '@formspec/core';
|
|
34
|
+
import { CustomTypeRegistration } from '@formspec/core';
|
|
35
|
+
import { DynamicEnumField } from '@formspec/core';
|
|
36
|
+
import { DynamicSchemaField } from '@formspec/core';
|
|
37
|
+
import { EnumOption } from '@formspec/core';
|
|
38
|
+
import { EnumOptionValue } from '@formspec/core';
|
|
39
|
+
import { ExtensionDefinition } from '@formspec/core';
|
|
40
|
+
import { FormElement } from '@formspec/core';
|
|
41
|
+
import { FormSpec } from '@formspec/core';
|
|
42
|
+
import { Group } from '@formspec/core';
|
|
43
|
+
import type { MetadataPolicyInput } from '@formspec/core';
|
|
44
|
+
import { NumberField } from '@formspec/core';
|
|
45
|
+
import { ObjectField } from '@formspec/core';
|
|
46
|
+
import type { ResolvedMetadata } from '@formspec/core';
|
|
47
|
+
import { StaticEnumField } from '@formspec/core';
|
|
48
|
+
import { TextField } from '@formspec/core';
|
|
49
|
+
import * as ts from 'typescript';
|
|
50
|
+
import { z } from 'zod';
|
|
51
|
+
|
|
52
|
+
export { AnyField }
|
|
53
|
+
|
|
54
|
+
export { ArrayField }
|
|
55
|
+
|
|
56
|
+
export { BooleanField }
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Builds both JSON Schema and UI Schema from a FormSpec.
|
|
60
|
+
*
|
|
61
|
+
* This is a convenience function that combines `generateJsonSchema`
|
|
62
|
+
* and `generateUiSchema`.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const form = formspec(
|
|
67
|
+
* field.text("name", { required: true }),
|
|
68
|
+
* field.number("age", { min: 0 }),
|
|
69
|
+
* );
|
|
70
|
+
*
|
|
71
|
+
* const { jsonSchema, uiSchema } = buildFormSchemas(form);
|
|
72
|
+
*
|
|
73
|
+
* // Use with JSON Forms renderer
|
|
74
|
+
* <JsonForms
|
|
75
|
+
* schema={jsonSchema}
|
|
76
|
+
* uischema={uiSchema}
|
|
77
|
+
* data={formData}
|
|
78
|
+
* renderers={materialRenderers}
|
|
79
|
+
* />
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @param form - The FormSpec to build schemas from
|
|
83
|
+
* @returns Object containing both jsonSchema and uiSchema
|
|
84
|
+
*
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
export declare function buildFormSchemas<E extends readonly FormElement[]>(form: FormSpec<E>, options?: BuildFormSchemasOptions): BuildResult;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Options for building schemas from a FormSpec.
|
|
91
|
+
*
|
|
92
|
+
* Currently identical to `GenerateJsonSchemaOptions`. Defined separately so the
|
|
93
|
+
* Chain DSL surface can grow independently in the future if needed.
|
|
94
|
+
*
|
|
95
|
+
* @public
|
|
96
|
+
*/
|
|
97
|
+
export declare interface BuildFormSchemasOptions extends GenerateJsonSchemaOptions, GenerateUiSchemaOptions {
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Builds JSON Schema and UI Schema from a TSDoc-derived model with ChainDSL
|
|
102
|
+
* field overlays.
|
|
103
|
+
*
|
|
104
|
+
* Overlays are matched by field name. The static model wins for structure,
|
|
105
|
+
* ordering, and constraints; ChainDSL overlays may contribute dynamic runtime
|
|
106
|
+
* field metadata such as dynamic enum or dynamic schema keywords, and may fill
|
|
107
|
+
* in missing annotations.
|
|
108
|
+
*
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
111
|
+
export declare function buildMixedAuthoringSchemas(options: BuildMixedAuthoringSchemasOptions): MixedAuthoringSchemas;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Options for generating mixed-authoring schemas.
|
|
115
|
+
*
|
|
116
|
+
* The `typeName` can resolve to a class, interface, or object type alias, just
|
|
117
|
+
* like `generateSchemas()`.
|
|
118
|
+
*
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
export declare interface BuildMixedAuthoringSchemasOptions extends StaticSchemaGenerationOptions {
|
|
122
|
+
/** Path to the TypeScript source file. */
|
|
123
|
+
readonly filePath: string;
|
|
124
|
+
/** Name of the class, interface, or type alias to analyze. */
|
|
125
|
+
readonly typeName: string;
|
|
126
|
+
/** ChainDSL overlays to apply to the static model. Groups and conditionals are flattened by field name. */
|
|
127
|
+
readonly overlays: FormSpec<readonly FormElement[]>;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Result of building form schemas.
|
|
132
|
+
*
|
|
133
|
+
* @public
|
|
134
|
+
*/
|
|
135
|
+
export declare interface BuildResult {
|
|
136
|
+
/** JSON Schema 2020-12 for validation */
|
|
137
|
+
readonly jsonSchema: JsonSchema2020;
|
|
138
|
+
/** JSON Forms UI Schema for rendering */
|
|
139
|
+
readonly uiSchema: UISchema;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export { BuiltinConstraintBroadeningRegistration }
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Registration for mapping a built-in TSDoc tag onto a custom constraint when
|
|
146
|
+
* it is used on a particular custom type.
|
|
147
|
+
*
|
|
148
|
+
* @public
|
|
149
|
+
*/
|
|
150
|
+
declare interface BuiltinConstraintBroadeningRegistration_2 {
|
|
151
|
+
/** The built-in tag being broadened, without the `@` prefix. */
|
|
152
|
+
readonly tagName: BuiltinConstraintName;
|
|
153
|
+
/** The custom constraint to emit for this built-in tag. */
|
|
154
|
+
readonly constraintName: string;
|
|
155
|
+
/** Parser from raw TSDoc text to extension payload. */
|
|
156
|
+
readonly parseValue: (raw: string) => ExtensionPayloadValue;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Type of a built-in constraint name.
|
|
161
|
+
*
|
|
162
|
+
* @public
|
|
163
|
+
*/
|
|
164
|
+
declare type BuiltinConstraintName = "minimum" | "maximum" | "exclusiveMinimum" | "exclusiveMaximum" | "multipleOf" | "minLength" | "maxLength" | "minItems" | "maxItems" | "uniqueItems" | "pattern" | "const" | "enumOptions";
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* A Categorization element (tab-based layout).
|
|
168
|
+
*
|
|
169
|
+
* @public
|
|
170
|
+
*/
|
|
171
|
+
export declare interface Categorization {
|
|
172
|
+
/** Discriminator identifying a categorization layout. */
|
|
173
|
+
readonly type: "Categorization";
|
|
174
|
+
/** Categories rendered as tabs or steps. */
|
|
175
|
+
readonly elements: Category[];
|
|
176
|
+
/** Optional label for the overall categorization container. */
|
|
177
|
+
readonly label?: string | undefined;
|
|
178
|
+
/** Optional rule controlling visibility or enablement. */
|
|
179
|
+
readonly rule?: Rule | undefined;
|
|
180
|
+
/** Renderer-specific categorization options. */
|
|
181
|
+
readonly options?: Record<string, unknown> | undefined;
|
|
182
|
+
/** Additional renderer-specific extension properties. */
|
|
183
|
+
readonly [k: string]: unknown;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* A Category element, used inside a Categorization layout.
|
|
188
|
+
*
|
|
189
|
+
* @public
|
|
190
|
+
*/
|
|
191
|
+
export declare interface Category {
|
|
192
|
+
/** Discriminator identifying a category inside a categorization layout. */
|
|
193
|
+
readonly type: "Category";
|
|
194
|
+
/** Category label shown in tabs or step navigation. */
|
|
195
|
+
readonly label: string;
|
|
196
|
+
/** Child elements rendered inside the category. */
|
|
197
|
+
readonly elements: UISchemaElement[];
|
|
198
|
+
/** Optional rule controlling visibility or enablement. */
|
|
199
|
+
readonly rule?: Rule | undefined;
|
|
200
|
+
/** Renderer-specific category options. */
|
|
201
|
+
readonly options?: Record<string, unknown> | undefined;
|
|
202
|
+
/** Additional renderer-specific extension properties. */
|
|
203
|
+
readonly [k: string]: unknown;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export { Conditional }
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Complete constraint configuration for a FormSpec project.
|
|
210
|
+
*
|
|
211
|
+
* @public
|
|
212
|
+
*/
|
|
213
|
+
declare interface ConstraintConfig {
|
|
214
|
+
/** Field type constraints */
|
|
215
|
+
fieldTypes?: FieldTypeConstraints;
|
|
216
|
+
/** Layout and structure constraints */
|
|
217
|
+
layout?: LayoutConstraints;
|
|
218
|
+
/** UI Schema feature constraints */
|
|
219
|
+
uiSchema?: UISchemaConstraints;
|
|
220
|
+
/** Field configuration option constraints */
|
|
221
|
+
fieldOptions?: FieldOptionConstraints;
|
|
222
|
+
/** Control options constraints */
|
|
223
|
+
controlOptions?: ControlOptionConstraints;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Semantic metadata for ordered custom constraints that should participate in
|
|
228
|
+
* the generic contradiction/broadening logic.
|
|
229
|
+
*
|
|
230
|
+
* @public
|
|
231
|
+
*/
|
|
232
|
+
declare interface ConstraintSemanticRole {
|
|
233
|
+
/**
|
|
234
|
+
* Logical family identifier shared by related constraints, for example
|
|
235
|
+
* `"decimal-bound"` or `"date-bound"`.
|
|
236
|
+
*/
|
|
237
|
+
readonly family: string;
|
|
238
|
+
/** Whether this constraint acts as a lower or upper bound. */
|
|
239
|
+
readonly bound: "lower" | "upper" | "exact";
|
|
240
|
+
/** Whether equality is allowed when comparing against the bound. */
|
|
241
|
+
readonly inclusive: boolean;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export { ConstraintTagRegistration }
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Declarative authoring-side registration for a custom TSDoc constraint tag.
|
|
248
|
+
*
|
|
249
|
+
* @public
|
|
250
|
+
*/
|
|
251
|
+
declare interface ConstraintTagRegistration_2 {
|
|
252
|
+
/** Tag name without the `@` prefix, e.g. `"maxSigFig"`. */
|
|
253
|
+
readonly tagName: string;
|
|
254
|
+
/** The custom constraint that this tag should produce. */
|
|
255
|
+
readonly constraintName: string;
|
|
256
|
+
/** Parser from raw TSDoc text to JSON-serializable payload. */
|
|
257
|
+
readonly parseValue: (raw: string) => ExtensionPayloadValue;
|
|
258
|
+
/**
|
|
259
|
+
* Optional precise applicability predicate for the field type being parsed.
|
|
260
|
+
* When omitted, the target custom constraint registration controls type
|
|
261
|
+
* applicability during validation.
|
|
262
|
+
*/
|
|
263
|
+
readonly isApplicableToType?: (type: ExtensionApplicableType) => boolean;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* A Control element that binds to a JSON Schema property.
|
|
268
|
+
*
|
|
269
|
+
* @public
|
|
270
|
+
*/
|
|
271
|
+
export declare interface ControlElement {
|
|
272
|
+
/** Discriminator identifying a JSON Forms control element. */
|
|
273
|
+
readonly type: "Control";
|
|
274
|
+
/** JSON Pointer scope that this control binds to. */
|
|
275
|
+
readonly scope: string;
|
|
276
|
+
/** Optional label override, or `false` to suppress the label. */
|
|
277
|
+
readonly label?: string | false | undefined;
|
|
278
|
+
/** Optional rule controlling visibility or enablement. */
|
|
279
|
+
readonly rule?: Rule | undefined;
|
|
280
|
+
/** Renderer-specific control options. */
|
|
281
|
+
readonly options?: Record<string, unknown> | undefined;
|
|
282
|
+
/** Additional renderer-specific extension properties. */
|
|
283
|
+
readonly [k: string]: unknown;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Control options constraints - control which JSONForms Control.options are allowed.
|
|
288
|
+
* These are renderer-specific options that may not be universally supported.
|
|
289
|
+
*
|
|
290
|
+
* @public
|
|
291
|
+
*/
|
|
292
|
+
declare interface ControlOptionConstraints {
|
|
293
|
+
/** format - renderer format hint (e.g., "radio", "textarea") */
|
|
294
|
+
format?: Severity;
|
|
295
|
+
/** readonly - read-only mode */
|
|
296
|
+
readonly?: Severity;
|
|
297
|
+
/** multi - multi-select for enums */
|
|
298
|
+
multi?: Severity;
|
|
299
|
+
/** showUnfocusedDescription - show description when unfocused */
|
|
300
|
+
showUnfocusedDescription?: Severity;
|
|
301
|
+
/** hideRequiredAsterisk - hide required indicator */
|
|
302
|
+
hideRequiredAsterisk?: Severity;
|
|
303
|
+
/** Custom control options (extensible dictionary) */
|
|
304
|
+
custom?: Record<string, Severity>;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Creates an extension registry from a list of extension definitions.
|
|
309
|
+
*
|
|
310
|
+
* The registry indexes all types, constraints, and annotations by their
|
|
311
|
+
* fully-qualified IDs (`<extensionId>/<name>`) for O(1) lookup during
|
|
312
|
+
* generation and validation.
|
|
313
|
+
*
|
|
314
|
+
* @param extensions - The extension definitions to register.
|
|
315
|
+
* @returns An {@link ExtensionRegistry} instance.
|
|
316
|
+
* @throws If duplicate type/constraint/annotation IDs are detected across extensions.
|
|
317
|
+
*
|
|
318
|
+
* @public
|
|
319
|
+
*/
|
|
320
|
+
export declare function createExtensionRegistry(extensions: readonly ExtensionDefinition[]): MutableExtensionRegistry;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Creates a supported static build context for a source file.
|
|
324
|
+
*
|
|
325
|
+
* @param filePath - Entry TypeScript source file used for export resolution
|
|
326
|
+
* @returns Reusable build context containing the program, checker, and source file
|
|
327
|
+
*
|
|
328
|
+
* @public
|
|
329
|
+
*/
|
|
330
|
+
export declare function createStaticBuildContext(filePath: string): StaticBuildContext;
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Creates a supported static build context from an existing host-owned program.
|
|
334
|
+
*
|
|
335
|
+
* @param program - Existing TypeScript program supplied by the caller
|
|
336
|
+
* @param filePath - Entry TypeScript source file used for export resolution
|
|
337
|
+
* @returns Reusable build context containing the program, checker, and source file
|
|
338
|
+
*
|
|
339
|
+
* @public
|
|
340
|
+
*/
|
|
341
|
+
export declare function createStaticBuildContextFromProgram(program: ts.Program, filePath: string): StaticBuildContext;
|
|
342
|
+
|
|
343
|
+
export { CustomAnnotationRegistration }
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Registration for a custom annotation that may produce JSON Schema keywords.
|
|
347
|
+
*
|
|
348
|
+
* Custom annotations are referenced by FormSpec's internal custom-annotation nodes.
|
|
349
|
+
* They describe or present a field but do not affect which values are valid.
|
|
350
|
+
*
|
|
351
|
+
* @public
|
|
352
|
+
*/
|
|
353
|
+
declare interface CustomAnnotationRegistration_2 {
|
|
354
|
+
/** The annotation name, unique within the extension. */
|
|
355
|
+
readonly annotationName: string;
|
|
356
|
+
/**
|
|
357
|
+
* Optionally converts the annotation value into JSON Schema keywords.
|
|
358
|
+
* If omitted, the annotation has no JSON Schema representation (UI-only).
|
|
359
|
+
*/
|
|
360
|
+
readonly toJsonSchema?: (value: ExtensionPayloadValue, vendorPrefix: string) => Record<string, unknown>;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export { CustomConstraintRegistration }
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Registration for a custom constraint that maps to JSON Schema keywords.
|
|
367
|
+
*
|
|
368
|
+
* Custom constraints are referenced by FormSpec's internal custom-constraint nodes.
|
|
369
|
+
*
|
|
370
|
+
* @public
|
|
371
|
+
*/
|
|
372
|
+
declare interface CustomConstraintRegistration_2 {
|
|
373
|
+
/** The constraint name, unique within the extension. */
|
|
374
|
+
readonly constraintName: string;
|
|
375
|
+
/**
|
|
376
|
+
* How this constraint composes with other constraints of the same kind.
|
|
377
|
+
* - "intersect": combine with logical AND (both must hold)
|
|
378
|
+
* - "override": last writer wins
|
|
379
|
+
*/
|
|
380
|
+
readonly compositionRule: "intersect" | "override";
|
|
381
|
+
/**
|
|
382
|
+
* TypeNode kinds this constraint is applicable to, or `null` for any type.
|
|
383
|
+
* Used by the validator to emit TYPE_MISMATCH diagnostics.
|
|
384
|
+
*/
|
|
385
|
+
readonly applicableTypes: readonly ExtensionApplicableType["kind"][] | null;
|
|
386
|
+
/**
|
|
387
|
+
* Optional precise type predicate used when kind-level applicability is too
|
|
388
|
+
* broad (for example, constraints that apply to integer-like primitives but
|
|
389
|
+
* not strings).
|
|
390
|
+
*/
|
|
391
|
+
readonly isApplicableToType?: (type: ExtensionApplicableType) => boolean;
|
|
392
|
+
/**
|
|
393
|
+
* Optional comparator for payloads belonging to the same custom constraint.
|
|
394
|
+
* Return values follow the `Array.prototype.sort()` contract.
|
|
395
|
+
*/
|
|
396
|
+
readonly comparePayloads?: (left: ExtensionPayloadValue, right: ExtensionPayloadValue) => number;
|
|
397
|
+
/**
|
|
398
|
+
* Optional semantic family metadata for generic contradiction/broadening
|
|
399
|
+
* handling across ordered constraints.
|
|
400
|
+
*/
|
|
401
|
+
readonly semanticRole?: ConstraintSemanticRole;
|
|
402
|
+
/**
|
|
403
|
+
* Converts the custom constraint's payload into JSON Schema keywords.
|
|
404
|
+
*
|
|
405
|
+
* @param payload - The opaque JSON payload stored on the custom constraint node.
|
|
406
|
+
* @param vendorPrefix - The vendor prefix for extension keywords.
|
|
407
|
+
* @returns A JSON Schema fragment with the constraint keywords.
|
|
408
|
+
*/
|
|
409
|
+
readonly toJsonSchema: (payload: ExtensionPayloadValue, vendorPrefix: string) => Record<string, unknown>;
|
|
410
|
+
/**
|
|
411
|
+
* When true, `toJsonSchema` may emit vocabulary keywords that do not carry
|
|
412
|
+
* the vendor prefix. By default, all keys returned from `toJsonSchema` must
|
|
413
|
+
* start with `${vendorPrefix}-`; setting this flag relaxes that check so
|
|
414
|
+
* the constraint can produce standard or custom vocabulary keywords such as
|
|
415
|
+
* `decimalMinimum`.
|
|
416
|
+
*
|
|
417
|
+
* Use this for constraints that define their own JSON Schema vocabulary
|
|
418
|
+
* rather than namespacing under the vendor prefix.
|
|
419
|
+
*/
|
|
420
|
+
readonly emitsVocabularyKeywords?: boolean;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
export { CustomTypeRegistration }
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Registration for a custom type that maps to a JSON Schema representation.
|
|
427
|
+
*
|
|
428
|
+
* Custom types are referenced by FormSpec's internal custom-type IR nodes and
|
|
429
|
+
* resolved to JSON Schema via `toJsonSchema` during generation.
|
|
430
|
+
*
|
|
431
|
+
* @public
|
|
432
|
+
*/
|
|
433
|
+
declare interface CustomTypeRegistration_2 {
|
|
434
|
+
/** The type name, unique within the extension. */
|
|
435
|
+
readonly typeName: string;
|
|
436
|
+
/**
|
|
437
|
+
* Optional TypeScript surface names that should resolve to this custom type
|
|
438
|
+
* during TSDoc/class analysis. Defaults to `typeName` when omitted.
|
|
439
|
+
* @deprecated Prefer `brand` for structural detection or type parameters
|
|
440
|
+
* on `defineCustomType<T>()` for symbol-based detection. String name
|
|
441
|
+
* matching will be removed in a future major version.
|
|
442
|
+
*/
|
|
443
|
+
readonly tsTypeNames?: readonly string[];
|
|
444
|
+
/**
|
|
445
|
+
* Optional brand identifier for structural type detection.
|
|
446
|
+
*
|
|
447
|
+
* When provided, the type resolver checks `type.getProperties()` for a
|
|
448
|
+
* computed property whose name matches this identifier. This is more
|
|
449
|
+
* reliable than `tsTypeNames` for aliased branded types because it does not
|
|
450
|
+
* depend on the local type name.
|
|
451
|
+
*
|
|
452
|
+
* Brand detection is attempted after name-based resolution (`tsTypeNames`)
|
|
453
|
+
* as a structural fallback. If both match, name-based resolution wins.
|
|
454
|
+
*
|
|
455
|
+
* The value should match the identifier text of a `unique symbol` declaration
|
|
456
|
+
* used as a computed property key on the branded type. For example, if the
|
|
457
|
+
* type is `string & { readonly [__decimalBrand]: true }`, the brand is
|
|
458
|
+
* `"__decimalBrand"`.
|
|
459
|
+
*
|
|
460
|
+
* Brand identifiers are stored as plain strings in the extension registry, so
|
|
461
|
+
* they must be unique across the extensions loaded into the same build.
|
|
462
|
+
*
|
|
463
|
+
* Note: `"__integerBrand"` is reserved for the builtin Integer type.
|
|
464
|
+
*/
|
|
465
|
+
readonly brand?: string;
|
|
466
|
+
/**
|
|
467
|
+
* Converts the custom type's payload into a JSON Schema fragment.
|
|
468
|
+
*
|
|
469
|
+
* @param payload - The opaque JSON payload stored on the custom type node.
|
|
470
|
+
* @param vendorPrefix - The vendor prefix for extension keywords (e.g., "x-stripe").
|
|
471
|
+
* @returns A JSON Schema fragment representing this type.
|
|
472
|
+
*/
|
|
473
|
+
readonly toJsonSchema: (payload: ExtensionPayloadValue, vendorPrefix: string) => Record<string, unknown>;
|
|
474
|
+
/**
|
|
475
|
+
* Optional broadening of built-in constraint tags so they can apply to this
|
|
476
|
+
* custom type without modifying the core built-in constraint tables.
|
|
477
|
+
*/
|
|
478
|
+
readonly builtinConstraintBroadenings?: readonly BuiltinConstraintBroadeningRegistration_2[];
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Per-declaration metadata policy input.
|
|
483
|
+
*
|
|
484
|
+
* @public
|
|
485
|
+
*/
|
|
486
|
+
declare interface DeclarationMetadataPolicyInput {
|
|
487
|
+
/** Policy for JSON-facing serialized names. */
|
|
488
|
+
readonly apiName?: MetadataValuePolicyInput | undefined;
|
|
489
|
+
/** Policy for human-facing labels and titles. */
|
|
490
|
+
readonly displayName?: MetadataValuePolicyInput | undefined;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Non-throwing schema generation result with structured diagnostics.
|
|
495
|
+
*
|
|
496
|
+
* @public
|
|
497
|
+
*/
|
|
498
|
+
export declare interface DetailedClassSchemasResult {
|
|
499
|
+
/** Whether schema generation completed without error-severity diagnostics. */
|
|
500
|
+
readonly ok: boolean;
|
|
501
|
+
/** Collected analysis and validation diagnostics for this target. */
|
|
502
|
+
readonly diagnostics: readonly ValidationDiagnostic[];
|
|
503
|
+
/** JSON Schema 2020-12 for validation, when generation succeeds. */
|
|
504
|
+
readonly jsonSchema?: JsonSchema2020 | undefined;
|
|
505
|
+
/** JSON Forms UI Schema for rendering, when generation succeeds. */
|
|
506
|
+
readonly uiSchema?: UISchema | undefined;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Result for a single target in a batch generation request.
|
|
511
|
+
*
|
|
512
|
+
* @public
|
|
513
|
+
*/
|
|
514
|
+
export declare interface DetailedSchemaGenerationTargetResult extends DetailedClassSchemasResult {
|
|
515
|
+
/** Path to the TypeScript source file. */
|
|
516
|
+
readonly filePath: string;
|
|
517
|
+
/** Name of the exported class, interface, or type alias that was analyzed. */
|
|
518
|
+
readonly typeName: string;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Generated schemas for a discovered declaration or signature type.
|
|
523
|
+
*
|
|
524
|
+
* `uiSchema` is `null` when the discovered type does not have an object-shaped
|
|
525
|
+
* root that can be represented as a JSON Forms layout.
|
|
526
|
+
*
|
|
527
|
+
* @public
|
|
528
|
+
*/
|
|
529
|
+
export declare interface DiscoveredTypeSchemas {
|
|
530
|
+
/** JSON Schema 2020-12 for the resolved type. */
|
|
531
|
+
readonly jsonSchema: JsonSchema2020;
|
|
532
|
+
/** UI Schema for object-shaped roots, or `null` when not applicable. */
|
|
533
|
+
readonly uiSchema: UISchema | null;
|
|
534
|
+
/**
|
|
535
|
+
* Resolved type-level metadata used during generation, when available.
|
|
536
|
+
*
|
|
537
|
+
* This preserves explicit and inferred naming metadata such as singular and
|
|
538
|
+
* plural API/display names for consumers that need the resolved values in
|
|
539
|
+
* addition to the emitted schema artifacts.
|
|
540
|
+
*/
|
|
541
|
+
readonly resolvedMetadata?: ResolvedMetadata | undefined;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Discriminator-specific schema generation options.
|
|
546
|
+
*
|
|
547
|
+
* @public
|
|
548
|
+
*/
|
|
549
|
+
export declare interface DiscriminatorResolutionOptions {
|
|
550
|
+
/**
|
|
551
|
+
* Optional prefix applied only to metadata-derived discriminator values.
|
|
552
|
+
*
|
|
553
|
+
* Literal discriminator identities taken directly from a bound type remain
|
|
554
|
+
* unchanged.
|
|
555
|
+
*/
|
|
556
|
+
readonly apiNamePrefix?: string | undefined;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
export { DynamicEnumField }
|
|
560
|
+
|
|
561
|
+
export { DynamicSchemaField }
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Enum-member display names remain unset unless authored explicitly.
|
|
565
|
+
*
|
|
566
|
+
* @public
|
|
567
|
+
*/
|
|
568
|
+
declare interface EnumMemberDisplayNameDisabledPolicyInput {
|
|
569
|
+
/** Leaves missing enum-member display names unresolved. */
|
|
570
|
+
readonly mode: "disabled";
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Missing enum-member display names may be inferred.
|
|
575
|
+
*
|
|
576
|
+
* @public
|
|
577
|
+
*/
|
|
578
|
+
declare interface EnumMemberDisplayNameInferIfMissingPolicyInput {
|
|
579
|
+
/** Infers an enum-member display name when it is not authored explicitly. */
|
|
580
|
+
readonly mode: "infer-if-missing";
|
|
581
|
+
/** Callback used to infer the missing display name. */
|
|
582
|
+
readonly infer: EnumMemberMetadataInferenceFn;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Enum-member display-name policy input.
|
|
587
|
+
*
|
|
588
|
+
* @public
|
|
589
|
+
*/
|
|
590
|
+
declare type EnumMemberDisplayNamePolicyInput = EnumMemberDisplayNameDisabledPolicyInput | EnumMemberDisplayNameRequireExplicitPolicyInput | EnumMemberDisplayNameInferIfMissingPolicyInput;
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Enum members must declare display names explicitly.
|
|
594
|
+
*
|
|
595
|
+
* @public
|
|
596
|
+
*/
|
|
597
|
+
declare interface EnumMemberDisplayNameRequireExplicitPolicyInput {
|
|
598
|
+
/** Fails when an enum member has no authored display name. */
|
|
599
|
+
readonly mode: "require-explicit";
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Build-facing context passed to enum-member metadata inference callbacks.
|
|
604
|
+
*
|
|
605
|
+
* Enum members are resolved separately from declaration-level metadata so they
|
|
606
|
+
* do not participate in the shared declaration-kind model used by TSDoc and
|
|
607
|
+
* extension metadata slots.
|
|
608
|
+
*
|
|
609
|
+
* @public
|
|
610
|
+
*/
|
|
611
|
+
declare interface EnumMemberMetadataInferenceContext {
|
|
612
|
+
/** Authoring surface the enum originated from. */
|
|
613
|
+
readonly surface: MetadataAuthoringSurface;
|
|
614
|
+
/** Logical member identifier used for policy inference. */
|
|
615
|
+
readonly logicalName: string;
|
|
616
|
+
/** Underlying enum value before stringification. */
|
|
617
|
+
readonly memberValue: string | number;
|
|
618
|
+
/** Optional build-only context supplied by the resolver. */
|
|
619
|
+
readonly buildContext?: unknown;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Callback used to infer enum-member display names.
|
|
624
|
+
*
|
|
625
|
+
* @public
|
|
626
|
+
*/
|
|
627
|
+
declare type EnumMemberMetadataInferenceFn = (context: EnumMemberMetadataInferenceContext) => string;
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* User-facing enum-member metadata policy input.
|
|
631
|
+
*
|
|
632
|
+
* @public
|
|
633
|
+
*/
|
|
634
|
+
declare interface EnumMemberMetadataPolicyInput {
|
|
635
|
+
/** Policy for human-facing enum-member labels. */
|
|
636
|
+
readonly displayName?: EnumMemberDisplayNamePolicyInput | undefined;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
export { EnumOption }
|
|
640
|
+
|
|
641
|
+
export { EnumOptionValue }
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* JSON Schema with FormSpec extension properties for arbitrary `x-formspec-*` keys.
|
|
645
|
+
*
|
|
646
|
+
* @public
|
|
647
|
+
*/
|
|
648
|
+
export declare type ExtendedJSONSchema7 = JSONSchema7 & FormSpecSchemaExtensions;
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* A curated type shape exposed to extension applicability hooks.
|
|
652
|
+
*
|
|
653
|
+
* This intentionally exposes only the fields needed to determine tag/type
|
|
654
|
+
* applicability without committing the entire canonical IR as public API.
|
|
655
|
+
*
|
|
656
|
+
* @public
|
|
657
|
+
*/
|
|
658
|
+
declare type ExtensionApplicableType = {
|
|
659
|
+
readonly kind: "primitive";
|
|
660
|
+
readonly primitiveKind: "string" | "number" | "integer" | "bigint" | "boolean" | "null";
|
|
661
|
+
} | {
|
|
662
|
+
readonly kind: "custom";
|
|
663
|
+
readonly typeId: string;
|
|
664
|
+
readonly payload: ExtensionPayloadValue;
|
|
665
|
+
} | {
|
|
666
|
+
readonly kind: Exclude<ExtensionTypeKind, "primitive" | "custom">;
|
|
667
|
+
};
|
|
668
|
+
|
|
669
|
+
export { ExtensionDefinition }
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* A complete extension definition bundling types, constraints, annotations,
|
|
673
|
+
* and vocabulary keywords.
|
|
674
|
+
*
|
|
675
|
+
* @example
|
|
676
|
+
* ```typescript
|
|
677
|
+
* const monetaryExtension = defineExtension({
|
|
678
|
+
* extensionId: "x-stripe/monetary",
|
|
679
|
+
* types: [
|
|
680
|
+
* defineCustomType({
|
|
681
|
+
* typeName: "Decimal",
|
|
682
|
+
* toJsonSchema: (_payload, prefix) => ({
|
|
683
|
+
* type: "string",
|
|
684
|
+
* [`${prefix}-decimal`]: true,
|
|
685
|
+
* }),
|
|
686
|
+
* }),
|
|
687
|
+
* ],
|
|
688
|
+
* });
|
|
689
|
+
* ```
|
|
690
|
+
*
|
|
691
|
+
* @public
|
|
692
|
+
*/
|
|
693
|
+
declare interface ExtensionDefinition_2 {
|
|
694
|
+
/** Globally unique extension identifier, e.g., "x-stripe/monetary". */
|
|
695
|
+
readonly extensionId: string;
|
|
696
|
+
/** Custom type registrations provided by this extension. */
|
|
697
|
+
readonly types?: readonly CustomTypeRegistration_2[];
|
|
698
|
+
/** Custom constraint registrations provided by this extension. */
|
|
699
|
+
readonly constraints?: readonly CustomConstraintRegistration_2[];
|
|
700
|
+
/** Authoring-side TSDoc tag registrations provided by this extension. */
|
|
701
|
+
readonly constraintTags?: readonly ConstraintTagRegistration_2[];
|
|
702
|
+
/** Metadata-slot registrations shared by build- and lint-time analysis. */
|
|
703
|
+
readonly metadataSlots?: readonly MetadataSlotRegistration[];
|
|
704
|
+
/** Custom annotation registrations provided by this extension. */
|
|
705
|
+
readonly annotations?: readonly CustomAnnotationRegistration_2[];
|
|
706
|
+
/** Vocabulary keyword registrations provided by this extension. */
|
|
707
|
+
readonly vocabularyKeywords?: readonly VocabularyKeywordRegistration[];
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* A JSON-serializable payload value used by extension registration hooks.
|
|
712
|
+
*
|
|
713
|
+
* @public
|
|
714
|
+
*/
|
|
715
|
+
declare type ExtensionPayloadValue = null | boolean | number | string | readonly ExtensionPayloadValue[] | {
|
|
716
|
+
readonly [key: string]: ExtensionPayloadValue;
|
|
717
|
+
};
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* A registry of extensions that provides lookup by fully-qualified ID.
|
|
721
|
+
*
|
|
722
|
+
* Type IDs follow the format: `<extensionId>/<typeName>`
|
|
723
|
+
* Constraint IDs follow the format: `<extensionId>/<constraintName>`
|
|
724
|
+
* Annotation IDs follow the format: `<extensionId>/<annotationName>`
|
|
725
|
+
*
|
|
726
|
+
* @public
|
|
727
|
+
*/
|
|
728
|
+
export declare interface ExtensionRegistry {
|
|
729
|
+
/** The extensions registered in this registry (in registration order). */
|
|
730
|
+
readonly extensions: readonly ExtensionDefinition[];
|
|
731
|
+
/**
|
|
732
|
+
* Look up a custom type registration by its fully-qualified type ID.
|
|
733
|
+
*
|
|
734
|
+
* @param typeId - The fully-qualified type ID (e.g., "x-stripe/monetary/Decimal").
|
|
735
|
+
* @returns The registration if found, otherwise `undefined`.
|
|
736
|
+
*/
|
|
737
|
+
findType(typeId: string): CustomTypeRegistration | undefined;
|
|
738
|
+
/**
|
|
739
|
+
* Look up a custom type registration by a TypeScript-facing type name.
|
|
740
|
+
*
|
|
741
|
+
* This is used during TSDoc/class analysis to resolve extension-defined
|
|
742
|
+
* custom types from source-level declarations.
|
|
743
|
+
*/
|
|
744
|
+
findTypeByName(typeName: string): ExtensionTypeLookupResult | undefined;
|
|
745
|
+
/**
|
|
746
|
+
* Look up a custom type registration by a brand identifier.
|
|
747
|
+
*
|
|
748
|
+
* This is used during class analysis to resolve extension-defined custom types
|
|
749
|
+
* via structural brand detection (`unique symbol` computed property keys).
|
|
750
|
+
* Brand identifiers are stored as plain strings, so they must be unique
|
|
751
|
+
* across all extensions loaded into the registry.
|
|
752
|
+
*
|
|
753
|
+
* @param brand - The identifier text of the `unique symbol` brand variable.
|
|
754
|
+
*/
|
|
755
|
+
findTypeByBrand(brand: string): ExtensionTypeLookupResult | undefined;
|
|
756
|
+
/**
|
|
757
|
+
* Look up a custom type by its TypeScript symbol identity.
|
|
758
|
+
*
|
|
759
|
+
* Built from `defineCustomType<T>()` type parameter extraction in the config file.
|
|
760
|
+
* This is the most precise detection path — it uses `ts.Symbol` identity, which is
|
|
761
|
+
* immune to import aliases and name collisions.
|
|
762
|
+
*
|
|
763
|
+
* Returns `undefined` until {@link MutableExtensionRegistry.setSymbolMap} has been
|
|
764
|
+
* called (i.e., before the TypeScript program is available), or when the symbol is
|
|
765
|
+
* not registered via a type parameter.
|
|
766
|
+
*
|
|
767
|
+
* @param symbol - The canonical TypeScript symbol to look up.
|
|
768
|
+
*/
|
|
769
|
+
findTypeBySymbol(symbol: ts.Symbol): ExtensionTypeLookupResult | undefined;
|
|
770
|
+
/**
|
|
771
|
+
* Look up a custom constraint registration by its fully-qualified constraint ID.
|
|
772
|
+
*
|
|
773
|
+
* @param constraintId - The fully-qualified constraint ID.
|
|
774
|
+
* @returns The registration if found, otherwise `undefined`.
|
|
775
|
+
*/
|
|
776
|
+
findConstraint(constraintId: string): CustomConstraintRegistration | undefined;
|
|
777
|
+
/**
|
|
778
|
+
* Look up a TSDoc custom constraint-tag registration by tag name.
|
|
779
|
+
*/
|
|
780
|
+
findConstraintTag(tagName: string): {
|
|
781
|
+
readonly extensionId: string;
|
|
782
|
+
readonly registration: ConstraintTagRegistration;
|
|
783
|
+
} | undefined;
|
|
784
|
+
/**
|
|
785
|
+
* Look up built-in tag broadening for a given custom type ID.
|
|
786
|
+
*/
|
|
787
|
+
findBuiltinConstraintBroadening(typeId: string, tagName: string): {
|
|
788
|
+
readonly extensionId: string;
|
|
789
|
+
readonly registration: BuiltinConstraintBroadeningRegistration;
|
|
790
|
+
} | undefined;
|
|
791
|
+
/**
|
|
792
|
+
* Look up a custom annotation registration by its fully-qualified annotation ID.
|
|
793
|
+
*
|
|
794
|
+
* @param annotationId - The fully-qualified annotation ID.
|
|
795
|
+
* @returns The registration if found, otherwise `undefined`.
|
|
796
|
+
*/
|
|
797
|
+
findAnnotation(annotationId: string): CustomAnnotationRegistration | undefined;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* Top-level type kinds that extension applicability hooks may inspect.
|
|
802
|
+
*
|
|
803
|
+
* @public
|
|
804
|
+
*/
|
|
805
|
+
declare type ExtensionTypeKind = "primitive" | "enum" | "array" | "object" | "record" | "union" | "reference" | "dynamic" | "custom";
|
|
806
|
+
|
|
807
|
+
/**
|
|
808
|
+
* The result of a successful extension type lookup.
|
|
809
|
+
*
|
|
810
|
+
* Returned by {@link ExtensionRegistry.findTypeByName},
|
|
811
|
+
* {@link ExtensionRegistry.findTypeByBrand}, and
|
|
812
|
+
* {@link ExtensionRegistry.findTypeBySymbol}.
|
|
813
|
+
*
|
|
814
|
+
* @public
|
|
815
|
+
*/
|
|
816
|
+
export declare interface ExtensionTypeLookupResult {
|
|
817
|
+
/** The fully-qualified extension ID (e.g., "x-stripe/monetary"). */
|
|
818
|
+
readonly extensionId: string;
|
|
819
|
+
/** The custom type registration matched by this lookup. */
|
|
820
|
+
readonly registration: CustomTypeRegistration;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Field configuration option constraints - control which field options are allowed.
|
|
825
|
+
*
|
|
826
|
+
* @public
|
|
827
|
+
*/
|
|
828
|
+
declare interface FieldOptionConstraints {
|
|
829
|
+
/** label - field label text */
|
|
830
|
+
label?: Severity;
|
|
831
|
+
/** placeholder - input placeholder text */
|
|
832
|
+
placeholder?: Severity;
|
|
833
|
+
/** required - whether field is required */
|
|
834
|
+
required?: Severity;
|
|
835
|
+
/** minValue - minimum value for numbers */
|
|
836
|
+
minValue?: Severity;
|
|
837
|
+
/** maxValue - maximum value for numbers */
|
|
838
|
+
maxValue?: Severity;
|
|
839
|
+
/** minItems - minimum array length */
|
|
840
|
+
minItems?: Severity;
|
|
841
|
+
/** maxItems - maximum array length */
|
|
842
|
+
maxItems?: Severity;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* Field type constraints - control which field types are allowed.
|
|
847
|
+
* Fine-grained control over each DSL field builder.
|
|
848
|
+
*
|
|
849
|
+
* @public
|
|
850
|
+
*/
|
|
851
|
+
declare interface FieldTypeConstraints {
|
|
852
|
+
/** field.text() - basic text input */
|
|
853
|
+
text?: Severity;
|
|
854
|
+
/** field.number() - numeric input */
|
|
855
|
+
number?: Severity;
|
|
856
|
+
/** field.boolean() - checkbox/toggle */
|
|
857
|
+
boolean?: Severity;
|
|
858
|
+
/** field.enum() with literal options */
|
|
859
|
+
staticEnum?: Severity;
|
|
860
|
+
/** field.dynamicEnum() - runtime-fetched options */
|
|
861
|
+
dynamicEnum?: Severity;
|
|
862
|
+
/** field.dynamicSchema() - runtime-fetched schema */
|
|
863
|
+
dynamicSchema?: Severity;
|
|
864
|
+
/** field.array() / field.arrayWithConfig() */
|
|
865
|
+
array?: Severity;
|
|
866
|
+
/** field.object() / field.objectWithConfig() */
|
|
867
|
+
object?: Severity;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
export { FormElement }
|
|
871
|
+
|
|
872
|
+
export { FormSpec }
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* Top-level FormSpec configuration file structure.
|
|
876
|
+
* The .formspec.yml file uses this structure.
|
|
877
|
+
*
|
|
878
|
+
* @public
|
|
879
|
+
*/
|
|
880
|
+
export declare interface FormSpecConfig {
|
|
881
|
+
/**
|
|
882
|
+
* Extension definitions providing custom types, constraints,
|
|
883
|
+
* annotations, and vocabulary keywords.
|
|
884
|
+
*/
|
|
885
|
+
readonly extensions?: readonly ExtensionDefinition_2[];
|
|
886
|
+
/** Constraint surface configuration — controls which field types,
|
|
887
|
+
* layouts, UI features, and field/control options are allowed. */
|
|
888
|
+
readonly constraints?: ConstraintConfig;
|
|
889
|
+
/**
|
|
890
|
+
* Metadata inference and naming policy. Controls how apiName,
|
|
891
|
+
* displayName, and plural forms are derived when not authored.
|
|
892
|
+
*/
|
|
893
|
+
readonly metadata?: MetadataPolicyInput_2;
|
|
894
|
+
/**
|
|
895
|
+
* Vendor prefix for extension-emitted JSON Schema keywords.
|
|
896
|
+
* Must start with "x-".
|
|
897
|
+
* @defaultValue "x-formspec"
|
|
898
|
+
*/
|
|
899
|
+
readonly vendorPrefix?: string;
|
|
900
|
+
/**
|
|
901
|
+
* JSON Schema representation for static enums.
|
|
902
|
+
* - "enum": flat { "enum": ["a", "b"] }
|
|
903
|
+
* - "oneOf": { "oneOf": [{ "const": "a" }, ...] }
|
|
904
|
+
* @defaultValue "enum"
|
|
905
|
+
*/
|
|
906
|
+
readonly enumSerialization?: "enum" | "oneOf";
|
|
907
|
+
/**
|
|
908
|
+
* Per-package configuration overrides for monorepos.
|
|
909
|
+
* Keys are glob patterns matched against file paths relative to
|
|
910
|
+
* the config file's directory. Values merge with root settings.
|
|
911
|
+
*/
|
|
912
|
+
readonly packages?: Readonly<Record<string, FormSpecPackageOverride>>;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* Per-package overrides that merge with the root config.
|
|
917
|
+
* Only settings that genuinely vary per package are overridable.
|
|
918
|
+
*
|
|
919
|
+
* @public
|
|
920
|
+
*/
|
|
921
|
+
declare interface FormSpecPackageOverride {
|
|
922
|
+
/** Override constraint surface for this package. */
|
|
923
|
+
readonly constraints?: ConstraintConfig;
|
|
924
|
+
/** Override enum serialization for this package. */
|
|
925
|
+
readonly enumSerialization?: "enum" | "oneOf";
|
|
926
|
+
/** Override metadata policy for this package. */
|
|
927
|
+
readonly metadata?: MetadataPolicyInput_2;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
/**
|
|
931
|
+
* Extension properties for custom FormSpec constraint tags.
|
|
932
|
+
*
|
|
933
|
+
* @public
|
|
934
|
+
*/
|
|
935
|
+
export declare type FormSpecSchemaExtensions = Record<`x-formspec-${string}`, unknown>;
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
* Options for generating schemas from a decorated class.
|
|
939
|
+
*
|
|
940
|
+
* @public
|
|
941
|
+
*/
|
|
942
|
+
export declare interface GenerateFromClassOptions extends StaticSchemaGenerationOptions {
|
|
943
|
+
/** Path to the TypeScript source file */
|
|
944
|
+
filePath: string;
|
|
945
|
+
/** Class name to analyze */
|
|
946
|
+
className: string;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* Result of generating schemas from a decorated class.
|
|
951
|
+
*
|
|
952
|
+
* @public
|
|
953
|
+
*/
|
|
954
|
+
export declare interface GenerateFromClassResult {
|
|
955
|
+
/** JSON Schema 2020-12 for validation */
|
|
956
|
+
jsonSchema: JsonSchema2020;
|
|
957
|
+
/** JSON Forms UI Schema for rendering */
|
|
958
|
+
uiSchema: UISchema;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Generates a JSON Schema 2020-12 from a FormSpec.
|
|
963
|
+
*
|
|
964
|
+
* All generation routes through the canonical IR. The chain DSL is first
|
|
965
|
+
* canonicalized to a FormIR, then the IR-based generator produces the schema.
|
|
966
|
+
*
|
|
967
|
+
* @example
|
|
968
|
+
* ```typescript
|
|
969
|
+
* const form = formspec(
|
|
970
|
+
* field.text("name", { label: "Name", required: true }),
|
|
971
|
+
* field.number("age", { min: 0 }),
|
|
972
|
+
* );
|
|
973
|
+
*
|
|
974
|
+
* const schema = generateJsonSchema(form);
|
|
975
|
+
* // {
|
|
976
|
+
* // $schema: "https://json-schema.org/draft/2020-12/schema",
|
|
977
|
+
* // type: "object",
|
|
978
|
+
* // properties: {
|
|
979
|
+
* // name: { type: "string", title: "Name" },
|
|
980
|
+
* // age: { type: "number", minimum: 0 }
|
|
981
|
+
* // },
|
|
982
|
+
* // required: ["name"]
|
|
983
|
+
* // }
|
|
984
|
+
* ```
|
|
985
|
+
*
|
|
986
|
+
* @param form - The FormSpec to convert
|
|
987
|
+
* @returns A JSON Schema 2020-12 object
|
|
988
|
+
*
|
|
989
|
+
* @public
|
|
990
|
+
*/
|
|
991
|
+
export declare function generateJsonSchema<E extends readonly FormElement[]>(form: FormSpec<E>, options?: GenerateJsonSchemaOptions): JsonSchema2020;
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* Options for generating JSON Schema from a Chain DSL form.
|
|
995
|
+
*
|
|
996
|
+
* @public
|
|
997
|
+
*/
|
|
998
|
+
export declare interface GenerateJsonSchemaOptions {
|
|
999
|
+
/**
|
|
1000
|
+
* Vendor prefix for emitted extension keywords.
|
|
1001
|
+
* @defaultValue "x-formspec"
|
|
1002
|
+
*/
|
|
1003
|
+
readonly vendorPrefix?: string | undefined;
|
|
1004
|
+
/**
|
|
1005
|
+
* JSON Schema representation to use for static enums.
|
|
1006
|
+
* @defaultValue "enum"
|
|
1007
|
+
*/
|
|
1008
|
+
readonly enumSerialization?: "enum" | "oneOf";
|
|
1009
|
+
/** Metadata resolution policy for chain DSL generation. */
|
|
1010
|
+
readonly metadata?: MetadataPolicyInput | undefined;
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
/**
|
|
1014
|
+
* Generates JSON Schema and UI Schema from a named TypeScript
|
|
1015
|
+
* type — a decorated class, an interface with TSDoc tags, or a type alias.
|
|
1016
|
+
*
|
|
1017
|
+
* This is the recommended entry point. It automatically detects whether
|
|
1018
|
+
* the name resolves to a class, interface, or type alias and uses the
|
|
1019
|
+
* appropriate IR analysis pipeline.
|
|
1020
|
+
*
|
|
1021
|
+
* @example
|
|
1022
|
+
* ```typescript
|
|
1023
|
+
* const result = generateSchemas({
|
|
1024
|
+
* filePath: "./src/config.ts",
|
|
1025
|
+
* typeName: "DiscountConfig",
|
|
1026
|
+
* errorReporting: "throw",
|
|
1027
|
+
* });
|
|
1028
|
+
* ```
|
|
1029
|
+
*/
|
|
1030
|
+
/**
|
|
1031
|
+
* Generates JSON Schema and UI Schema from a named type and throws when
|
|
1032
|
+
* generation reports error-severity diagnostics.
|
|
1033
|
+
*
|
|
1034
|
+
* @param options - File path, type name, and explicit throw-on-error reporting
|
|
1035
|
+
* @returns Generated JSON Schema and UI Schema
|
|
1036
|
+
*
|
|
1037
|
+
* @public
|
|
1038
|
+
*/
|
|
1039
|
+
export declare function generateSchemas(options: GenerateSchemasOptions & {
|
|
1040
|
+
readonly errorReporting: "throw";
|
|
1041
|
+
}): GenerateFromClassResult;
|
|
1042
|
+
|
|
1043
|
+
/**
|
|
1044
|
+
* Generates JSON Schema and UI Schema from a named type and returns structured
|
|
1045
|
+
* diagnostics instead of throwing on validation or analysis failures.
|
|
1046
|
+
*
|
|
1047
|
+
* @param options - File path, type name, and explicit diagnostics reporting
|
|
1048
|
+
* @returns Structured generation result with diagnostics
|
|
1049
|
+
*
|
|
1050
|
+
* @public
|
|
1051
|
+
*/
|
|
1052
|
+
export declare function generateSchemas(options: GenerateSchemasOptions & {
|
|
1053
|
+
readonly errorReporting: "diagnostics";
|
|
1054
|
+
}): DetailedClassSchemasResult;
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* Generates JSON Schema and UI Schema from a named type.
|
|
1058
|
+
*
|
|
1059
|
+
* @deprecated Pass `errorReporting` explicitly. Omitting it defaults to `"throw"` only for backward compatibility.
|
|
1060
|
+
* @param options - File path and type name
|
|
1061
|
+
* @returns Generated JSON Schema and UI Schema
|
|
1062
|
+
*
|
|
1063
|
+
* @public
|
|
1064
|
+
*/
|
|
1065
|
+
export declare function generateSchemas(options: StaticSchemaGenerationOptions & {
|
|
1066
|
+
readonly filePath: string;
|
|
1067
|
+
readonly typeName: string;
|
|
1068
|
+
}): GenerateFromClassResult;
|
|
1069
|
+
|
|
1070
|
+
/**
|
|
1071
|
+
* Generates schemas for many targets and returns per-target diagnostics instead
|
|
1072
|
+
* of failing on the first problem.
|
|
1073
|
+
*
|
|
1074
|
+
* @public
|
|
1075
|
+
*/
|
|
1076
|
+
export declare function generateSchemasBatch(options: GenerateSchemasBatchOptions): readonly DetailedSchemaGenerationTargetResult[];
|
|
1077
|
+
|
|
1078
|
+
/**
|
|
1079
|
+
* Generates schemas for many targets from an existing TypeScript program and
|
|
1080
|
+
* returns per-target diagnostics instead of failing on the first problem.
|
|
1081
|
+
*
|
|
1082
|
+
* @public
|
|
1083
|
+
*/
|
|
1084
|
+
export declare function generateSchemasBatchFromProgram(options: GenerateSchemasBatchFromProgramOptions): readonly DetailedSchemaGenerationTargetResult[];
|
|
1085
|
+
|
|
1086
|
+
/**
|
|
1087
|
+
* Batch options for non-throwing schema generation using an existing program.
|
|
1088
|
+
*
|
|
1089
|
+
* @public
|
|
1090
|
+
*/
|
|
1091
|
+
export declare interface GenerateSchemasBatchFromProgramOptions extends StaticSchemaGenerationOptions {
|
|
1092
|
+
/** Existing TypeScript program supplied by the caller. */
|
|
1093
|
+
readonly program: ts.Program;
|
|
1094
|
+
/** Targets to analyze and generate. */
|
|
1095
|
+
readonly targets: readonly SchemaGenerationTarget[];
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
/**
|
|
1099
|
+
* Batch options for non-throwing schema generation.
|
|
1100
|
+
*
|
|
1101
|
+
* @public
|
|
1102
|
+
*/
|
|
1103
|
+
export declare interface GenerateSchemasBatchOptions extends StaticSchemaGenerationOptions {
|
|
1104
|
+
/** Targets to analyze and generate. */
|
|
1105
|
+
readonly targets: readonly SchemaGenerationTarget[];
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
/**
|
|
1109
|
+
* Generates JSON Schema and UI Schema from a named type and returns structured
|
|
1110
|
+
* diagnostics instead of throwing on validation or analysis failures.
|
|
1111
|
+
* @deprecated Use `generateSchemas({ ...options, errorReporting: "diagnostics" })` instead.
|
|
1112
|
+
*
|
|
1113
|
+
* @public
|
|
1114
|
+
*/
|
|
1115
|
+
export declare function generateSchemasDetailed(options: StaticSchemaGenerationOptions & {
|
|
1116
|
+
readonly filePath: string;
|
|
1117
|
+
readonly typeName: string;
|
|
1118
|
+
}): DetailedClassSchemasResult;
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* Generates JSON Schema and UI Schema from a decorated TypeScript class.
|
|
1122
|
+
*
|
|
1123
|
+
* This is a high-level entry point that handles the entire pipeline:
|
|
1124
|
+
* creating a TypeScript program, finding the class, analyzing it to IR,
|
|
1125
|
+
* and generating schemas — all in one call.
|
|
1126
|
+
*
|
|
1127
|
+
* @example
|
|
1128
|
+
* ```typescript
|
|
1129
|
+
* const result = generateSchemasFromClass({
|
|
1130
|
+
* filePath: "./src/forms.ts",
|
|
1131
|
+
* className: "UserForm",
|
|
1132
|
+
* });
|
|
1133
|
+
* console.log(result.jsonSchema);
|
|
1134
|
+
* ```
|
|
1135
|
+
*
|
|
1136
|
+
* @param options - File path, class name, and optional compiler options
|
|
1137
|
+
* @returns Generated JSON Schema and UI Schema
|
|
1138
|
+
*
|
|
1139
|
+
* @public
|
|
1140
|
+
*/
|
|
1141
|
+
export declare function generateSchemasFromClass(options: GenerateFromClassOptions): GenerateFromClassResult;
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
* Generates schemas from a resolved declaration using the supported public
|
|
1145
|
+
* static-build workflow.
|
|
1146
|
+
*
|
|
1147
|
+
* Named declarations reuse the same analyzer semantics as FormSpec's existing
|
|
1148
|
+
* top-level generation APIs. Non-object type aliases fall back to the generic
|
|
1149
|
+
* resolved-type entry point.
|
|
1150
|
+
*
|
|
1151
|
+
* @public
|
|
1152
|
+
*/
|
|
1153
|
+
export declare function generateSchemasFromDeclaration(options: GenerateSchemasFromDeclarationOptions): DiscoveredTypeSchemas;
|
|
1154
|
+
|
|
1155
|
+
/**
|
|
1156
|
+
* Options for generating schemas from a resolved declaration.
|
|
1157
|
+
*
|
|
1158
|
+
* @public
|
|
1159
|
+
*/
|
|
1160
|
+
export declare interface GenerateSchemasFromDeclarationOptions extends StaticSchemaGenerationOptions {
|
|
1161
|
+
/** Supported build context used for checker access and related analysis. */
|
|
1162
|
+
readonly context: StaticBuildContext;
|
|
1163
|
+
/** Declaration to turn into schemas. */
|
|
1164
|
+
readonly declaration: SchemaSourceDeclaration;
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
/**
|
|
1168
|
+
* Generates schemas for a method or function parameter type.
|
|
1169
|
+
*
|
|
1170
|
+
* @public
|
|
1171
|
+
*/
|
|
1172
|
+
export declare function generateSchemasFromParameter(options: GenerateSchemasFromParameterOptions): DiscoveredTypeSchemas;
|
|
1173
|
+
|
|
1174
|
+
/**
|
|
1175
|
+
* Options for generating schemas from a method or function parameter type.
|
|
1176
|
+
*
|
|
1177
|
+
* @public
|
|
1178
|
+
*/
|
|
1179
|
+
export declare interface GenerateSchemasFromParameterOptions extends StaticSchemaGenerationOptions {
|
|
1180
|
+
/** Supported build context used for checker access and related analysis. */
|
|
1181
|
+
readonly context: StaticBuildContext;
|
|
1182
|
+
/** Parameter declaration whose type should be converted into schemas. */
|
|
1183
|
+
readonly parameter: ts.ParameterDeclaration;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
/**
|
|
1187
|
+
* Generates JSON Schema and UI Schema from a named type within an existing
|
|
1188
|
+
* TypeScript program supplied by the caller.
|
|
1189
|
+
*
|
|
1190
|
+
* This low-level entry point lets downstream tooling reuse a host-owned
|
|
1191
|
+
* `Program` for both FormSpec extraction and other TypeScript analysis.
|
|
1192
|
+
*/
|
|
1193
|
+
/**
|
|
1194
|
+
* Generates JSON Schema and UI Schema from a named type within an existing
|
|
1195
|
+
* TypeScript program and throws when generation reports error-severity diagnostics.
|
|
1196
|
+
*
|
|
1197
|
+
* @param options - Host program, file path, type name, and explicit throw-on-error reporting
|
|
1198
|
+
* @returns Generated JSON Schema and UI Schema
|
|
1199
|
+
*
|
|
1200
|
+
* @public
|
|
1201
|
+
*/
|
|
1202
|
+
export declare function generateSchemasFromProgram(options: GenerateSchemasFromProgramOptions & {
|
|
1203
|
+
readonly errorReporting: "throw";
|
|
1204
|
+
}): GenerateFromClassResult;
|
|
1205
|
+
|
|
1206
|
+
/**
|
|
1207
|
+
* Generates JSON Schema and UI Schema from a named type within an existing
|
|
1208
|
+
* TypeScript program and returns structured diagnostics instead of throwing on
|
|
1209
|
+
* validation or analysis failures.
|
|
1210
|
+
*
|
|
1211
|
+
* @param options - Host program, file path, type name, and explicit diagnostics reporting
|
|
1212
|
+
* @returns Structured generation result with diagnostics
|
|
1213
|
+
*
|
|
1214
|
+
* @public
|
|
1215
|
+
*/
|
|
1216
|
+
export declare function generateSchemasFromProgram(options: GenerateSchemasFromProgramOptions & {
|
|
1217
|
+
readonly errorReporting: "diagnostics";
|
|
1218
|
+
}): DetailedClassSchemasResult;
|
|
1219
|
+
|
|
1220
|
+
/**
|
|
1221
|
+
* Generates JSON Schema and UI Schema from a named type within an existing
|
|
1222
|
+
* TypeScript program.
|
|
1223
|
+
*
|
|
1224
|
+
* @deprecated Pass `errorReporting` explicitly. Omitting it defaults to `"throw"` only for backward compatibility.
|
|
1225
|
+
* @param options - Host program, file path, and type name
|
|
1226
|
+
* @returns Generated JSON Schema and UI Schema
|
|
1227
|
+
*
|
|
1228
|
+
* @public
|
|
1229
|
+
*/
|
|
1230
|
+
export declare function generateSchemasFromProgram(options: StaticSchemaGenerationOptions & {
|
|
1231
|
+
readonly program: ts.Program;
|
|
1232
|
+
readonly filePath: string;
|
|
1233
|
+
readonly typeName: string;
|
|
1234
|
+
}): GenerateFromClassResult;
|
|
1235
|
+
|
|
1236
|
+
/**
|
|
1237
|
+
* Generates JSON Schema and UI Schema from a named type within an existing
|
|
1238
|
+
* TypeScript program and returns structured diagnostics instead of throwing on
|
|
1239
|
+
* validation or analysis failures.
|
|
1240
|
+
* @deprecated Use `generateSchemasFromProgram({ ...options, errorReporting: "diagnostics" })` instead.
|
|
1241
|
+
*
|
|
1242
|
+
* @public
|
|
1243
|
+
*/
|
|
1244
|
+
export declare function generateSchemasFromProgramDetailed(options: StaticSchemaGenerationOptions & {
|
|
1245
|
+
readonly program: ts.Program;
|
|
1246
|
+
readonly filePath: string;
|
|
1247
|
+
readonly typeName: string;
|
|
1248
|
+
}): DetailedClassSchemasResult;
|
|
1249
|
+
|
|
1250
|
+
/**
|
|
1251
|
+
* Options for generating schemas from a named type inside an existing TypeScript program.
|
|
1252
|
+
*
|
|
1253
|
+
* @public
|
|
1254
|
+
*/
|
|
1255
|
+
export declare interface GenerateSchemasFromProgramOptions extends StaticSchemaGenerationOptions {
|
|
1256
|
+
/** Existing TypeScript program supplied by the caller. */
|
|
1257
|
+
readonly program: ts.Program;
|
|
1258
|
+
/** Path to the TypeScript source file */
|
|
1259
|
+
readonly filePath: string;
|
|
1260
|
+
/** Name of the exported class, interface, or type alias to analyze */
|
|
1261
|
+
readonly typeName: string;
|
|
1262
|
+
/**
|
|
1263
|
+
* Controls whether error-severity diagnostics throw or are returned in the result.
|
|
1264
|
+
*/
|
|
1265
|
+
readonly errorReporting: "throw" | "diagnostics";
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
/**
|
|
1269
|
+
* Generates schemas for a method or function return type.
|
|
1270
|
+
*
|
|
1271
|
+
* Awaited `Promise<T>`-style return types are unwrapped before generation.
|
|
1272
|
+
*
|
|
1273
|
+
* @public
|
|
1274
|
+
*/
|
|
1275
|
+
export declare function generateSchemasFromReturnType(options: GenerateSchemasFromReturnTypeOptions): DiscoveredTypeSchemas;
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* Options for generating schemas from a method or function return type.
|
|
1279
|
+
*
|
|
1280
|
+
* @public
|
|
1281
|
+
*/
|
|
1282
|
+
export declare interface GenerateSchemasFromReturnTypeOptions extends StaticSchemaGenerationOptions {
|
|
1283
|
+
/** Supported build context used for checker access and related analysis. */
|
|
1284
|
+
readonly context: StaticBuildContext;
|
|
1285
|
+
/** Signature declaration whose return type should be converted into schemas. */
|
|
1286
|
+
readonly declaration: ts.SignatureDeclaration;
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
/**
|
|
1290
|
+
* Generates schemas from a resolved TypeScript type.
|
|
1291
|
+
*
|
|
1292
|
+
* This is the advanced public entry point for build tooling that already uses
|
|
1293
|
+
* the TypeScript compiler API to discover types before handing them to
|
|
1294
|
+
* FormSpec.
|
|
1295
|
+
*
|
|
1296
|
+
* @public
|
|
1297
|
+
*/
|
|
1298
|
+
export declare function generateSchemasFromType(options: GenerateSchemasFromTypeOptions): DiscoveredTypeSchemas;
|
|
1299
|
+
|
|
1300
|
+
/**
|
|
1301
|
+
* Options for generating schemas from a resolved TypeScript type.
|
|
1302
|
+
*
|
|
1303
|
+
* @public
|
|
1304
|
+
*/
|
|
1305
|
+
export declare interface GenerateSchemasFromTypeOptions extends StaticSchemaGenerationOptions {
|
|
1306
|
+
/** Supported build context used for checker access and related analysis. */
|
|
1307
|
+
readonly context: StaticBuildContext;
|
|
1308
|
+
/** TypeScript type to turn into schemas. */
|
|
1309
|
+
readonly type: ts.Type;
|
|
1310
|
+
/**
|
|
1311
|
+
* Optional source node associated with the type.
|
|
1312
|
+
*
|
|
1313
|
+
* When provided, FormSpec uses it as the source location for provenance and
|
|
1314
|
+
* inline-type analysis.
|
|
1315
|
+
*/
|
|
1316
|
+
readonly sourceNode?: ts.Node | undefined;
|
|
1317
|
+
/** Optional logical name used for anonymous roots. */
|
|
1318
|
+
readonly name?: string | undefined;
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
/**
|
|
1322
|
+
* Options for generating schemas from a named type (class, interface, or type alias).
|
|
1323
|
+
*
|
|
1324
|
+
* @public
|
|
1325
|
+
*/
|
|
1326
|
+
export declare interface GenerateSchemasOptions extends StaticSchemaGenerationOptions {
|
|
1327
|
+
/** Path to the TypeScript source file */
|
|
1328
|
+
readonly filePath: string;
|
|
1329
|
+
/** Name of the exported class, interface, or type alias to analyze */
|
|
1330
|
+
readonly typeName: string;
|
|
1331
|
+
/**
|
|
1332
|
+
* Controls whether error-severity diagnostics throw or are returned in the result.
|
|
1333
|
+
*/
|
|
1334
|
+
readonly errorReporting: "throw" | "diagnostics";
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
/**
|
|
1338
|
+
* Generates a JSON Forms UI Schema from a FormSpec.
|
|
1339
|
+
*
|
|
1340
|
+
* All generation routes through the canonical IR. The chain DSL is first
|
|
1341
|
+
* canonicalized to a FormIR, then the IR-based generator produces the schema.
|
|
1342
|
+
*
|
|
1343
|
+
* @example
|
|
1344
|
+
* ```typescript
|
|
1345
|
+
* const form = formspec(
|
|
1346
|
+
* group("Customer",
|
|
1347
|
+
* field.text("name", { label: "Name" }),
|
|
1348
|
+
* ),
|
|
1349
|
+
* when("status", "draft",
|
|
1350
|
+
* field.text("notes", { label: "Notes" }),
|
|
1351
|
+
* ),
|
|
1352
|
+
* );
|
|
1353
|
+
*
|
|
1354
|
+
* const uiSchema = generateUiSchema(form);
|
|
1355
|
+
* // {
|
|
1356
|
+
* // type: "VerticalLayout",
|
|
1357
|
+
* // elements: [
|
|
1358
|
+
* // {
|
|
1359
|
+
* // type: "Group",
|
|
1360
|
+
* // label: "Customer",
|
|
1361
|
+
* // elements: [
|
|
1362
|
+
* // { type: "Control", scope: "#/properties/name", label: "Name" }
|
|
1363
|
+
* // ]
|
|
1364
|
+
* // },
|
|
1365
|
+
* // {
|
|
1366
|
+
* // type: "Control",
|
|
1367
|
+
* // scope: "#/properties/notes",
|
|
1368
|
+
* // label: "Notes",
|
|
1369
|
+
* // rule: {
|
|
1370
|
+
* // effect: "SHOW",
|
|
1371
|
+
* // condition: { scope: "#/properties/status", schema: { const: "draft" } }
|
|
1372
|
+
* // }
|
|
1373
|
+
* // }
|
|
1374
|
+
* // ]
|
|
1375
|
+
* // }
|
|
1376
|
+
* ```
|
|
1377
|
+
*
|
|
1378
|
+
* @param form - The FormSpec to convert
|
|
1379
|
+
* @returns A JSON Forms UI Schema
|
|
1380
|
+
*
|
|
1381
|
+
* @public
|
|
1382
|
+
*/
|
|
1383
|
+
export declare function generateUiSchema<E extends readonly FormElement[]>(form: FormSpec<E>, options?: GenerateUiSchemaOptions): UISchema;
|
|
1384
|
+
|
|
1385
|
+
/**
|
|
1386
|
+
* Options for generating a UI Schema from a Chain DSL form.
|
|
1387
|
+
*
|
|
1388
|
+
* @public
|
|
1389
|
+
*/
|
|
1390
|
+
export declare interface GenerateUiSchemaOptions {
|
|
1391
|
+
/** Metadata resolution policy for chain DSL UI generation. */
|
|
1392
|
+
readonly metadata?: MetadataPolicyInput | undefined;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
export { Group }
|
|
1396
|
+
|
|
1397
|
+
/**
|
|
1398
|
+
* A group element with a label.
|
|
1399
|
+
*
|
|
1400
|
+
* @public
|
|
1401
|
+
*/
|
|
1402
|
+
export declare interface GroupLayout {
|
|
1403
|
+
/** Discriminator identifying a labeled group container. */
|
|
1404
|
+
readonly type: "Group";
|
|
1405
|
+
/** Group label shown by compatible renderers. */
|
|
1406
|
+
readonly label: string;
|
|
1407
|
+
/** Child elements rendered inside the group. */
|
|
1408
|
+
readonly elements: UISchemaElement[];
|
|
1409
|
+
/** Optional rule controlling visibility or enablement. */
|
|
1410
|
+
readonly rule?: Rule | undefined;
|
|
1411
|
+
/** Renderer-specific group options. */
|
|
1412
|
+
readonly options?: Record<string, unknown> | undefined;
|
|
1413
|
+
/** Additional renderer-specific extension properties. */
|
|
1414
|
+
readonly [k: string]: unknown;
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
/**
|
|
1418
|
+
* A horizontal layout element.
|
|
1419
|
+
*
|
|
1420
|
+
* @public
|
|
1421
|
+
*/
|
|
1422
|
+
export declare interface HorizontalLayout {
|
|
1423
|
+
/** Discriminator identifying a horizontal layout container. */
|
|
1424
|
+
readonly type: "HorizontalLayout";
|
|
1425
|
+
/** Child elements rendered side by side. */
|
|
1426
|
+
readonly elements: UISchemaElement[];
|
|
1427
|
+
/** Optional rule controlling visibility or enablement. */
|
|
1428
|
+
readonly rule?: Rule | undefined;
|
|
1429
|
+
/** Renderer-specific layout options. */
|
|
1430
|
+
readonly options?: Record<string, unknown> | undefined;
|
|
1431
|
+
/** Additional renderer-specific extension properties. */
|
|
1432
|
+
readonly [k: string]: unknown;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
/**
|
|
1436
|
+
* A JSON Schema 2020-12 document, sub-schema, or keyword collection.
|
|
1437
|
+
*
|
|
1438
|
+
* This interface covers the subset of JSON Schema 2020-12 that this generator
|
|
1439
|
+
* emits, plus an index signature for custom `x-formspec-*` extension keywords.
|
|
1440
|
+
*
|
|
1441
|
+
* @public
|
|
1442
|
+
*/
|
|
1443
|
+
export declare interface JsonSchema2020 {
|
|
1444
|
+
/** Declared JSON Schema dialect URI for the document root. */
|
|
1445
|
+
$schema?: string;
|
|
1446
|
+
/** Reference to another schema location. */
|
|
1447
|
+
$ref?: string;
|
|
1448
|
+
/** Named reusable schema definitions keyed by definition name. */
|
|
1449
|
+
$defs?: Record<string, JsonSchema2020>;
|
|
1450
|
+
/** JSON Schema type keyword for the current node. */
|
|
1451
|
+
type?: string;
|
|
1452
|
+
/** Object properties keyed by property name. */
|
|
1453
|
+
properties?: Record<string, JsonSchema2020>;
|
|
1454
|
+
/** Property names that must be present on object values. */
|
|
1455
|
+
required?: string[];
|
|
1456
|
+
/** Item schema applied to array elements. */
|
|
1457
|
+
items?: JsonSchema2020;
|
|
1458
|
+
/** Whether, or how, additional object properties are allowed. */
|
|
1459
|
+
additionalProperties?: boolean | JsonSchema2020;
|
|
1460
|
+
/** Closed set of allowed scalar values. */
|
|
1461
|
+
enum?: readonly (string | number)[];
|
|
1462
|
+
/** Literal value the instance must equal. */
|
|
1463
|
+
const?: unknown;
|
|
1464
|
+
/** Schemas that must all validate successfully. */
|
|
1465
|
+
allOf?: readonly JsonSchema2020[];
|
|
1466
|
+
/** Schemas of which exactly one should validate successfully. */
|
|
1467
|
+
oneOf?: readonly JsonSchema2020[];
|
|
1468
|
+
/** Schemas of which at least one may validate successfully. */
|
|
1469
|
+
anyOf?: readonly JsonSchema2020[];
|
|
1470
|
+
/** Inclusive numeric lower bound. */
|
|
1471
|
+
minimum?: number;
|
|
1472
|
+
/** Inclusive numeric upper bound. */
|
|
1473
|
+
maximum?: number;
|
|
1474
|
+
/** Exclusive numeric lower bound. */
|
|
1475
|
+
exclusiveMinimum?: number;
|
|
1476
|
+
/** Exclusive numeric upper bound. */
|
|
1477
|
+
exclusiveMaximum?: number;
|
|
1478
|
+
/** Required numeric step interval. */
|
|
1479
|
+
multipleOf?: number;
|
|
1480
|
+
/** Inclusive minimum string length. */
|
|
1481
|
+
minLength?: number;
|
|
1482
|
+
/** Inclusive maximum string length. */
|
|
1483
|
+
maxLength?: number;
|
|
1484
|
+
/** Inclusive minimum array length. */
|
|
1485
|
+
minItems?: number;
|
|
1486
|
+
/** Inclusive maximum array length. */
|
|
1487
|
+
maxItems?: number;
|
|
1488
|
+
/** Regular expression pattern applied to string values. */
|
|
1489
|
+
pattern?: string;
|
|
1490
|
+
/** Whether array elements must be unique. */
|
|
1491
|
+
uniqueItems?: boolean;
|
|
1492
|
+
/** Format hint for downstream validators and tooling. */
|
|
1493
|
+
format?: string;
|
|
1494
|
+
/** Human-readable title for the schema node. */
|
|
1495
|
+
title?: string;
|
|
1496
|
+
/** Human-readable description for the schema node. */
|
|
1497
|
+
description?: string;
|
|
1498
|
+
/** Default value suggested for the schema node. */
|
|
1499
|
+
default?: unknown;
|
|
1500
|
+
/** Whether the schema node is deprecated. */
|
|
1501
|
+
deprecated?: boolean;
|
|
1502
|
+
/** Additional vendor-prefixed extension keywords. */
|
|
1503
|
+
[key: `x-${string}`]: unknown;
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
/**
|
|
1507
|
+
* A JSON Schema definition (legacy subset used by Zod validator and types.ts).
|
|
1508
|
+
*
|
|
1509
|
+
* @public
|
|
1510
|
+
*/
|
|
1511
|
+
export declare interface JSONSchema7 {
|
|
1512
|
+
/** Declared JSON Schema dialect URI for the document root. */
|
|
1513
|
+
$schema?: string;
|
|
1514
|
+
/** Stable identifier for the schema document or sub-schema. */
|
|
1515
|
+
$id?: string;
|
|
1516
|
+
/** Reference to another schema location. */
|
|
1517
|
+
$ref?: string;
|
|
1518
|
+
/** Human-readable title for the schema node. */
|
|
1519
|
+
title?: string;
|
|
1520
|
+
/** Human-readable description for the schema node. */
|
|
1521
|
+
description?: string;
|
|
1522
|
+
/** Whether the schema node is deprecated. */
|
|
1523
|
+
deprecated?: boolean;
|
|
1524
|
+
/** JSON Schema type keyword for the current node. */
|
|
1525
|
+
type?: JSONSchemaType | JSONSchemaType[];
|
|
1526
|
+
/** Inclusive minimum string length. */
|
|
1527
|
+
minLength?: number;
|
|
1528
|
+
/** Inclusive maximum string length. */
|
|
1529
|
+
maxLength?: number;
|
|
1530
|
+
/** Regular expression pattern applied to string values. */
|
|
1531
|
+
pattern?: string;
|
|
1532
|
+
/** Inclusive numeric lower bound. */
|
|
1533
|
+
minimum?: number;
|
|
1534
|
+
/** Inclusive numeric upper bound. */
|
|
1535
|
+
maximum?: number;
|
|
1536
|
+
/** Exclusive numeric lower bound. */
|
|
1537
|
+
exclusiveMinimum?: number;
|
|
1538
|
+
/** Exclusive numeric upper bound. */
|
|
1539
|
+
exclusiveMaximum?: number;
|
|
1540
|
+
/** Closed set of allowed scalar values. */
|
|
1541
|
+
enum?: readonly (string | number | boolean | null)[];
|
|
1542
|
+
/** Literal value the instance must equal. */
|
|
1543
|
+
const?: string | number | boolean | null;
|
|
1544
|
+
/** Object properties keyed by property name. */
|
|
1545
|
+
properties?: Record<string, JSONSchema7>;
|
|
1546
|
+
/** Property names that must be present on object values. */
|
|
1547
|
+
required?: string[];
|
|
1548
|
+
/** Whether, or how, additional object properties are allowed. */
|
|
1549
|
+
additionalProperties?: boolean | JSONSchema7;
|
|
1550
|
+
/** Item schema or tuple schemas applied to array elements. */
|
|
1551
|
+
items?: JSONSchema7 | JSONSchema7[];
|
|
1552
|
+
/** Inclusive minimum array length. */
|
|
1553
|
+
minItems?: number;
|
|
1554
|
+
/** Inclusive maximum array length. */
|
|
1555
|
+
maxItems?: number;
|
|
1556
|
+
/** Schemas that must all validate successfully. */
|
|
1557
|
+
allOf?: JSONSchema7[];
|
|
1558
|
+
/** Schemas of which at least one may validate successfully. */
|
|
1559
|
+
anyOf?: JSONSchema7[];
|
|
1560
|
+
/** Schemas of which exactly one should validate successfully. */
|
|
1561
|
+
oneOf?: JSONSchema7[];
|
|
1562
|
+
/** Schema that must not validate successfully. */
|
|
1563
|
+
not?: JSONSchema7;
|
|
1564
|
+
/** Conditional branch predicate schema. */
|
|
1565
|
+
if?: JSONSchema7;
|
|
1566
|
+
/** Schema applied when the `if` branch matches. */
|
|
1567
|
+
then?: JSONSchema7;
|
|
1568
|
+
/** Schema applied when the `if` branch does not match. */
|
|
1569
|
+
else?: JSONSchema7;
|
|
1570
|
+
/** Format hint for downstream validators and tooling. */
|
|
1571
|
+
format?: string;
|
|
1572
|
+
/** Default value suggested for the schema node. */
|
|
1573
|
+
default?: unknown;
|
|
1574
|
+
/**
|
|
1575
|
+
* Data source key for dynamic enum fields.
|
|
1576
|
+
* Indicates that options should be fetched from a registered resolver.
|
|
1577
|
+
*/
|
|
1578
|
+
"x-formspec-source"?: string;
|
|
1579
|
+
/**
|
|
1580
|
+
* Field names whose values are needed to fetch dynamic enum options.
|
|
1581
|
+
* Used for dependent/cascading dropdowns.
|
|
1582
|
+
*/
|
|
1583
|
+
"x-formspec-params"?: readonly string[];
|
|
1584
|
+
/**
|
|
1585
|
+
* Schema source identifier for dynamic schema fields.
|
|
1586
|
+
* Indicates that the schema should be loaded dynamically at runtime.
|
|
1587
|
+
*/
|
|
1588
|
+
"x-formspec-schemaSource"?: string;
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
/**
|
|
1592
|
+
* Zod schema for the legacy JSON Schema 7 subset used by `@formspec/build`.
|
|
1593
|
+
*
|
|
1594
|
+
* @public
|
|
1595
|
+
*/
|
|
1596
|
+
export declare const jsonSchema7Schema: z.ZodType<JSONSchema7>;
|
|
1597
|
+
|
|
1598
|
+
/**
|
|
1599
|
+
* JSON Schema type definitions.
|
|
1600
|
+
*
|
|
1601
|
+
* These types are a subset of JSON Schema sufficient for form generation.
|
|
1602
|
+
*/
|
|
1603
|
+
/**
|
|
1604
|
+
* JSON Schema primitive types.
|
|
1605
|
+
*
|
|
1606
|
+
* @public
|
|
1607
|
+
*/
|
|
1608
|
+
export declare type JSONSchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
|
|
1609
|
+
|
|
1610
|
+
/**
|
|
1611
|
+
* A Label element for displaying static text.
|
|
1612
|
+
*
|
|
1613
|
+
* @public
|
|
1614
|
+
*/
|
|
1615
|
+
export declare interface LabelElement {
|
|
1616
|
+
/** Discriminator identifying a static text label element. */
|
|
1617
|
+
readonly type: "Label";
|
|
1618
|
+
/** Static text content rendered by the label element. */
|
|
1619
|
+
readonly text: string;
|
|
1620
|
+
/** Optional rule controlling visibility or enablement. */
|
|
1621
|
+
readonly rule?: Rule | undefined;
|
|
1622
|
+
/** Renderer-specific label options. */
|
|
1623
|
+
readonly options?: Record<string, unknown> | undefined;
|
|
1624
|
+
/** Additional renderer-specific extension properties. */
|
|
1625
|
+
readonly [k: string]: unknown;
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
/**
|
|
1629
|
+
* Layout and structure constraints - control grouping, conditionals, nesting.
|
|
1630
|
+
*
|
|
1631
|
+
* @public
|
|
1632
|
+
*/
|
|
1633
|
+
declare interface LayoutConstraints {
|
|
1634
|
+
/** group() - visual grouping of fields */
|
|
1635
|
+
group?: Severity;
|
|
1636
|
+
/** when() - conditional field visibility */
|
|
1637
|
+
conditionals?: Severity;
|
|
1638
|
+
/** Maximum nesting depth for objects/arrays (0 = flat only) */
|
|
1639
|
+
maxNestingDepth?: number;
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
/**
|
|
1643
|
+
* JSONForms layout type constraints.
|
|
1644
|
+
*
|
|
1645
|
+
* @public
|
|
1646
|
+
*/
|
|
1647
|
+
declare interface LayoutTypeConstraints {
|
|
1648
|
+
/** VerticalLayout - stack elements vertically */
|
|
1649
|
+
VerticalLayout?: Severity;
|
|
1650
|
+
/** HorizontalLayout - arrange elements horizontally */
|
|
1651
|
+
HorizontalLayout?: Severity;
|
|
1652
|
+
/** Group - visual grouping with label */
|
|
1653
|
+
Group?: Severity;
|
|
1654
|
+
/** Categorization - tabbed/wizard interface */
|
|
1655
|
+
Categorization?: Severity;
|
|
1656
|
+
/** Category - individual tab/step in Categorization */
|
|
1657
|
+
Category?: Severity;
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
/**
|
|
1661
|
+
* Authoring surfaces that can contribute metadata.
|
|
1662
|
+
*
|
|
1663
|
+
* @public
|
|
1664
|
+
*/
|
|
1665
|
+
declare type MetadataAuthoringSurface = "tsdoc" | "chain-dsl";
|
|
1666
|
+
|
|
1667
|
+
/**
|
|
1668
|
+
* Declaration categories that metadata policy can target.
|
|
1669
|
+
*
|
|
1670
|
+
* @public
|
|
1671
|
+
*/
|
|
1672
|
+
declare type MetadataDeclarationKind = "type" | "field" | "method";
|
|
1673
|
+
|
|
1674
|
+
/**
|
|
1675
|
+
* Build-facing context passed to metadata inference callbacks.
|
|
1676
|
+
*
|
|
1677
|
+
* `buildContext` is intentionally opaque so browser/runtime packages do not
|
|
1678
|
+
* need to depend on TypeScript compiler types.
|
|
1679
|
+
*
|
|
1680
|
+
* @public
|
|
1681
|
+
*/
|
|
1682
|
+
declare interface MetadataInferenceContext {
|
|
1683
|
+
/** Authoring surface the metadata is being resolved for. */
|
|
1684
|
+
readonly surface: MetadataAuthoringSurface;
|
|
1685
|
+
/** Declaration kind currently being resolved. */
|
|
1686
|
+
readonly declarationKind: MetadataDeclarationKind;
|
|
1687
|
+
/** Logical identifier before any metadata policy is applied. */
|
|
1688
|
+
readonly logicalName: string;
|
|
1689
|
+
/** Optional build-only context supplied by the resolver. */
|
|
1690
|
+
readonly buildContext?: unknown;
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
/**
|
|
1694
|
+
* Callback used to infer a scalar metadata value.
|
|
1695
|
+
*
|
|
1696
|
+
* @public
|
|
1697
|
+
*/
|
|
1698
|
+
declare type MetadataInferenceFn = (context: MetadataInferenceContext) => string;
|
|
1699
|
+
|
|
1700
|
+
/**
|
|
1701
|
+
* Context passed to pluralization callbacks.
|
|
1702
|
+
*
|
|
1703
|
+
* @public
|
|
1704
|
+
*/
|
|
1705
|
+
declare interface MetadataPluralizationContext extends MetadataInferenceContext {
|
|
1706
|
+
/** Singular value that pluralization should derive from. */
|
|
1707
|
+
readonly singular: string;
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
/**
|
|
1711
|
+
* Pluralization disabled.
|
|
1712
|
+
*
|
|
1713
|
+
* @public
|
|
1714
|
+
*/
|
|
1715
|
+
declare interface MetadataPluralizationDisabledPolicyInput {
|
|
1716
|
+
/** Disables automatic plural-value generation. */
|
|
1717
|
+
readonly mode?: "disabled" | undefined;
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
/**
|
|
1721
|
+
* Callback used to derive plural metadata from a singular value.
|
|
1722
|
+
*
|
|
1723
|
+
* @public
|
|
1724
|
+
*/
|
|
1725
|
+
declare type MetadataPluralizationFn = (context: MetadataPluralizationContext) => string;
|
|
1726
|
+
|
|
1727
|
+
/**
|
|
1728
|
+
* Pluralization may be inferred when absent.
|
|
1729
|
+
*
|
|
1730
|
+
* @public
|
|
1731
|
+
*/
|
|
1732
|
+
declare interface MetadataPluralizationInferIfMissingPolicyInput {
|
|
1733
|
+
/** Infers plural values whenever no explicit plural is present. */
|
|
1734
|
+
readonly mode: "infer-if-missing";
|
|
1735
|
+
/** Callback that derives a plural form from the resolved singular value. */
|
|
1736
|
+
readonly inflect: MetadataPluralizationFn;
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
/**
|
|
1740
|
+
* Pluralization policy input.
|
|
1741
|
+
*
|
|
1742
|
+
* @public
|
|
1743
|
+
*/
|
|
1744
|
+
declare type MetadataPluralizationPolicyInput = MetadataPluralizationDisabledPolicyInput | MetadataPluralizationRequireExplicitPolicyInput | MetadataPluralizationInferIfMissingPolicyInput;
|
|
1745
|
+
|
|
1746
|
+
/**
|
|
1747
|
+
* Pluralization must be authored explicitly.
|
|
1748
|
+
*
|
|
1749
|
+
* @public
|
|
1750
|
+
*/
|
|
1751
|
+
declare interface MetadataPluralizationRequireExplicitPolicyInput {
|
|
1752
|
+
/** Requires plural values to be authored directly. */
|
|
1753
|
+
readonly mode: "require-explicit";
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
/**
|
|
1757
|
+
* User-facing metadata policy configuration.
|
|
1758
|
+
*
|
|
1759
|
+
* @public
|
|
1760
|
+
*/
|
|
1761
|
+
declare interface MetadataPolicyInput_2 {
|
|
1762
|
+
/** Policy applied to named types and the analyzed root declaration. */
|
|
1763
|
+
readonly type?: DeclarationMetadataPolicyInput | undefined;
|
|
1764
|
+
/** Policy applied to fields and object properties. */
|
|
1765
|
+
readonly field?: DeclarationMetadataPolicyInput | undefined;
|
|
1766
|
+
/** Policy applied to callable/method declarations. */
|
|
1767
|
+
readonly method?: DeclarationMetadataPolicyInput | undefined;
|
|
1768
|
+
/** Policy applied to enum-member display names during build-time IR resolution. */
|
|
1769
|
+
readonly enumMember?: EnumMemberMetadataPolicyInput | undefined;
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
/**
|
|
1773
|
+
* Supported qualifier registration for an extensible metadata slot.
|
|
1774
|
+
*
|
|
1775
|
+
* @public
|
|
1776
|
+
*/
|
|
1777
|
+
declare interface MetadataQualifierRegistration {
|
|
1778
|
+
/** Qualifier text without the leading colon. */
|
|
1779
|
+
readonly qualifier: string;
|
|
1780
|
+
/**
|
|
1781
|
+
* Optional source qualifier to use as the base input for this qualifier's
|
|
1782
|
+
* inference hook. Defaults to the slot's bare/default value when omitted.
|
|
1783
|
+
*/
|
|
1784
|
+
readonly sourceQualifier?: string | undefined;
|
|
1785
|
+
/** Optional inference hook for this qualified value. */
|
|
1786
|
+
readonly inferValue?: MetadataSlotInferenceFn | undefined;
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
/**
|
|
1790
|
+
* Stable slot identifier for extensible metadata analysis.
|
|
1791
|
+
*
|
|
1792
|
+
* @public
|
|
1793
|
+
*/
|
|
1794
|
+
declare type MetadataSlotId = string;
|
|
1795
|
+
|
|
1796
|
+
/**
|
|
1797
|
+
* Context passed to extensible metadata inference hooks.
|
|
1798
|
+
*
|
|
1799
|
+
* @public
|
|
1800
|
+
*/
|
|
1801
|
+
declare interface MetadataSlotInferenceContext extends MetadataInferenceContext {
|
|
1802
|
+
/** Stable logical slot identifier. */
|
|
1803
|
+
readonly slotId: MetadataSlotId;
|
|
1804
|
+
/** Tag name associated with the slot, without the `@` prefix. */
|
|
1805
|
+
readonly tagName: string;
|
|
1806
|
+
/** Optional qualifier being inferred (for example `plural`). */
|
|
1807
|
+
readonly qualifier?: string | undefined;
|
|
1808
|
+
/** Resolved bare/default value used as the base input for derived qualifiers. */
|
|
1809
|
+
readonly baseValue?: string | undefined;
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
/**
|
|
1813
|
+
* Callback used to infer an extensible metadata slot value.
|
|
1814
|
+
*
|
|
1815
|
+
* @public
|
|
1816
|
+
*/
|
|
1817
|
+
declare type MetadataSlotInferenceFn = (context: MetadataSlotInferenceContext) => string;
|
|
1818
|
+
|
|
1819
|
+
/**
|
|
1820
|
+
* Extensible metadata slot definition shared across build- and lint-time analysis.
|
|
1821
|
+
*
|
|
1822
|
+
* @public
|
|
1823
|
+
*/
|
|
1824
|
+
declare interface MetadataSlotRegistration {
|
|
1825
|
+
/** Stable logical slot identifier. */
|
|
1826
|
+
readonly slotId: MetadataSlotId;
|
|
1827
|
+
/** Tag name associated with this slot, without the `@` prefix. */
|
|
1828
|
+
readonly tagName: string;
|
|
1829
|
+
/** Declaration kinds where the slot is meaningful. */
|
|
1830
|
+
readonly declarationKinds: readonly MetadataDeclarationKind[];
|
|
1831
|
+
/** Whether a bare tag without a qualifier is supported. Defaults to true. */
|
|
1832
|
+
readonly allowBare?: boolean | undefined;
|
|
1833
|
+
/** Supported qualifiers for this slot. */
|
|
1834
|
+
readonly qualifiers?: readonly MetadataQualifierRegistration[] | undefined;
|
|
1835
|
+
/** Optional inference hook for the bare/default slot value. */
|
|
1836
|
+
readonly inferValue?: MetadataSlotInferenceFn | undefined;
|
|
1837
|
+
/**
|
|
1838
|
+
* Optional applicability hook for declaration-specific rules beyond
|
|
1839
|
+
* declaration kind. `buildContext` may carry compiler objects.
|
|
1840
|
+
*/
|
|
1841
|
+
readonly isApplicable?: ((context: MetadataInferenceContext) => boolean) | undefined;
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
/**
|
|
1845
|
+
* Supported declaration kinds for standalone metadata resolution.
|
|
1846
|
+
*
|
|
1847
|
+
* This helper is intentionally limited to named type declarations,
|
|
1848
|
+
* methods/functions, and object-like properties. It does not currently expose
|
|
1849
|
+
* parameter or variable metadata resolution on the public build surface.
|
|
1850
|
+
*
|
|
1851
|
+
* @public
|
|
1852
|
+
*/
|
|
1853
|
+
export declare type MetadataSourceDeclaration = SchemaSourceDeclaration | ts.MethodDeclaration | ts.FunctionDeclaration | ts.PropertyDeclaration | ts.PropertySignature;
|
|
1854
|
+
|
|
1855
|
+
/**
|
|
1856
|
+
* Scalar metadata disabled unless provided explicitly elsewhere.
|
|
1857
|
+
*
|
|
1858
|
+
* @public
|
|
1859
|
+
*/
|
|
1860
|
+
declare interface MetadataValueDisabledPolicyInput {
|
|
1861
|
+
/** Disables inference for this scalar metadata value. */
|
|
1862
|
+
readonly mode?: "disabled" | undefined;
|
|
1863
|
+
/** Optional policy controlling plural forms of this scalar value. */
|
|
1864
|
+
readonly pluralization?: MetadataPluralizationPolicyInput | undefined;
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
/**
|
|
1868
|
+
* Scalar metadata may be inferred when missing.
|
|
1869
|
+
*
|
|
1870
|
+
* @public
|
|
1871
|
+
*/
|
|
1872
|
+
declare interface MetadataValueInferIfMissingPolicyInput {
|
|
1873
|
+
/** Infers this scalar metadata value when it is not authored explicitly. */
|
|
1874
|
+
readonly mode: "infer-if-missing";
|
|
1875
|
+
/** Callback used to infer the missing singular value. */
|
|
1876
|
+
readonly infer: MetadataInferenceFn;
|
|
1877
|
+
/** Optional policy controlling plural forms of this scalar value. */
|
|
1878
|
+
readonly pluralization?: MetadataPluralizationPolicyInput | undefined;
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
/**
|
|
1882
|
+
* Scalar metadata policy input.
|
|
1883
|
+
*
|
|
1884
|
+
* @public
|
|
1885
|
+
*/
|
|
1886
|
+
declare type MetadataValuePolicyInput = MetadataValueDisabledPolicyInput | MetadataValueRequireExplicitPolicyInput | MetadataValueInferIfMissingPolicyInput;
|
|
1887
|
+
|
|
1888
|
+
/**
|
|
1889
|
+
* Scalar metadata must be authored explicitly.
|
|
1890
|
+
*
|
|
1891
|
+
* @public
|
|
1892
|
+
*/
|
|
1893
|
+
declare interface MetadataValueRequireExplicitPolicyInput {
|
|
1894
|
+
/** Requires this scalar metadata value to be authored directly. */
|
|
1895
|
+
readonly mode: "require-explicit";
|
|
1896
|
+
/** Optional policy controlling plural forms of this scalar value. */
|
|
1897
|
+
readonly pluralization?: MetadataPluralizationPolicyInput | undefined;
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
/**
|
|
1901
|
+
* Result of generating schemas from a mixed-authoring composition.
|
|
1902
|
+
*
|
|
1903
|
+
* @public
|
|
1904
|
+
*/
|
|
1905
|
+
export declare interface MixedAuthoringSchemas {
|
|
1906
|
+
/** JSON Schema 2020-12 for validation. */
|
|
1907
|
+
readonly jsonSchema: JsonSchema2020;
|
|
1908
|
+
/** JSON Forms UI Schema for rendering. */
|
|
1909
|
+
readonly uiSchema: UISchema;
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
/**
|
|
1913
|
+
* Mutable extension registry used internally by the build pipeline.
|
|
1914
|
+
*
|
|
1915
|
+
* Extends {@link ExtensionRegistry} with `setSymbolMap`, which must be called
|
|
1916
|
+
* after the TypeScript program is created. Consumer code should accept only
|
|
1917
|
+
* the read-only {@link ExtensionRegistry} interface.
|
|
1918
|
+
*
|
|
1919
|
+
* @public
|
|
1920
|
+
*/
|
|
1921
|
+
export declare interface MutableExtensionRegistry extends ExtensionRegistry {
|
|
1922
|
+
/**
|
|
1923
|
+
* Sets the symbol map built from config AST analysis.
|
|
1924
|
+
*
|
|
1925
|
+
* Called after the TypeScript program is created and the config file is analyzed.
|
|
1926
|
+
* Prior to this call, {@link ExtensionRegistry.findTypeBySymbol} always returns
|
|
1927
|
+
* `undefined`.
|
|
1928
|
+
*
|
|
1929
|
+
* @param map - A map from canonical `ts.Symbol` to the matching registry entry.
|
|
1930
|
+
*/
|
|
1931
|
+
setSymbolMap(map: Map<ts.Symbol, ExtensionTypeLookupResult>): void;
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
export { NumberField }
|
|
1935
|
+
|
|
1936
|
+
export { ObjectField }
|
|
1937
|
+
|
|
1938
|
+
/**
|
|
1939
|
+
* Resolves metadata from a declaration using FormSpec's configured metadata
|
|
1940
|
+
* policy for the matching declaration kind.
|
|
1941
|
+
*
|
|
1942
|
+
* @public
|
|
1943
|
+
*/
|
|
1944
|
+
export declare function resolveDeclarationMetadata(options: ResolveDeclarationMetadataOptions): ResolvedMetadata | undefined;
|
|
1945
|
+
|
|
1946
|
+
/**
|
|
1947
|
+
* Options for resolving metadata from a declaration against the active
|
|
1948
|
+
* metadata policy.
|
|
1949
|
+
*
|
|
1950
|
+
* @public
|
|
1951
|
+
*/
|
|
1952
|
+
export declare interface ResolveDeclarationMetadataOptions extends StaticSchemaGenerationOptions {
|
|
1953
|
+
/** Supported build context used for checker access and related analysis. */
|
|
1954
|
+
readonly context: StaticBuildContext;
|
|
1955
|
+
/** Declaration whose metadata should be resolved. */
|
|
1956
|
+
readonly declaration: MetadataSourceDeclaration;
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
/**
|
|
1960
|
+
* Resolves an export from the context source file, following aliases and re-exports.
|
|
1961
|
+
*
|
|
1962
|
+
* @param context - Static build context created for the entry source file
|
|
1963
|
+
* @param exportName - Export name to resolve. Defaults to `"default"`.
|
|
1964
|
+
* @returns Resolved symbol for the export, or `null` when it cannot be found
|
|
1965
|
+
*
|
|
1966
|
+
* @public
|
|
1967
|
+
*/
|
|
1968
|
+
export declare function resolveModuleExport(context: StaticBuildContext, exportName?: string): ts.Symbol | null;
|
|
1969
|
+
|
|
1970
|
+
/**
|
|
1971
|
+
* Resolves the declaration behind an export from the context source file,
|
|
1972
|
+
* following aliases and re-exports. This helper is intentionally limited to
|
|
1973
|
+
* declaration kinds accepted by declaration-driven schema generation.
|
|
1974
|
+
*
|
|
1975
|
+
* @param context - Static build context created for the entry source file
|
|
1976
|
+
* @param exportName - Export name to resolve. Defaults to `"default"`.
|
|
1977
|
+
* @returns Resolved class, interface, or type-alias declaration for the export,
|
|
1978
|
+
* or `null` when the export does not resolve to one of those schema-source kinds
|
|
1979
|
+
*
|
|
1980
|
+
* @public
|
|
1981
|
+
*/
|
|
1982
|
+
export declare function resolveModuleExportDeclaration(context: StaticBuildContext, exportName?: string): ts.ClassDeclaration | ts.InterfaceDeclaration | ts.TypeAliasDeclaration | null;
|
|
1983
|
+
|
|
1984
|
+
/**
|
|
1985
|
+
* Rule for conditional element visibility/enablement.
|
|
1986
|
+
*
|
|
1987
|
+
* @public
|
|
1988
|
+
*/
|
|
1989
|
+
export declare interface Rule {
|
|
1990
|
+
/** UI effect to apply when the rule condition matches. */
|
|
1991
|
+
readonly effect: RuleEffect;
|
|
1992
|
+
/** Predicate that controls when the UI effect applies. */
|
|
1993
|
+
readonly condition: SchemaBasedCondition;
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
/**
|
|
1997
|
+
* JSON Schema subset used in rule conditions.
|
|
1998
|
+
*
|
|
1999
|
+
* @public
|
|
2000
|
+
*/
|
|
2001
|
+
export declare interface RuleConditionSchema {
|
|
2002
|
+
/** Literal value the condition schema must equal. */
|
|
2003
|
+
const?: unknown;
|
|
2004
|
+
/** Allowed values for the condition schema. */
|
|
2005
|
+
enum?: readonly unknown[];
|
|
2006
|
+
/** JSON Schema type required by the condition schema. */
|
|
2007
|
+
type?: string;
|
|
2008
|
+
/** Negated branch of the condition schema. */
|
|
2009
|
+
not?: RuleConditionSchema;
|
|
2010
|
+
/** Inclusive numeric lower bound in the condition schema. */
|
|
2011
|
+
minimum?: number;
|
|
2012
|
+
/** Inclusive numeric upper bound in the condition schema. */
|
|
2013
|
+
maximum?: number;
|
|
2014
|
+
/** Exclusive numeric lower bound in the condition schema. */
|
|
2015
|
+
exclusiveMinimum?: number;
|
|
2016
|
+
/** Exclusive numeric upper bound in the condition schema. */
|
|
2017
|
+
exclusiveMaximum?: number;
|
|
2018
|
+
/** Inclusive minimum string length in the condition schema. */
|
|
2019
|
+
minLength?: number;
|
|
2020
|
+
/** Nested property conditions keyed by property name. */
|
|
2021
|
+
properties?: Record<string, RuleConditionSchema>;
|
|
2022
|
+
/** Property names that must be present for the condition to match. */
|
|
2023
|
+
required?: string[];
|
|
2024
|
+
/** Schemas that must all match for the condition to succeed. */
|
|
2025
|
+
allOf?: RuleConditionSchema[];
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
/**
|
|
2029
|
+
* JSONForms rule constraints.
|
|
2030
|
+
*
|
|
2031
|
+
* @public
|
|
2032
|
+
*/
|
|
2033
|
+
declare interface RuleConstraints {
|
|
2034
|
+
/** Whether rules are enabled at all */
|
|
2035
|
+
enabled?: Severity;
|
|
2036
|
+
/** Fine-grained control over rule effects */
|
|
2037
|
+
effects?: RuleEffectConstraints;
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
/**
|
|
2041
|
+
* JSON Forms UI Schema type definitions.
|
|
2042
|
+
*
|
|
2043
|
+
* These are the consumer-facing TypeScript shapes. Runtime validation remains
|
|
2044
|
+
* defined separately in `./schema.ts`.
|
|
2045
|
+
*
|
|
2046
|
+
* See: https://jsonforms.io/docs/uischema/
|
|
2047
|
+
*/
|
|
2048
|
+
/**
|
|
2049
|
+
* Rule effect types for conditional visibility.
|
|
2050
|
+
*
|
|
2051
|
+
* @public
|
|
2052
|
+
*/
|
|
2053
|
+
export declare type RuleEffect = "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
|
|
2054
|
+
|
|
2055
|
+
/**
|
|
2056
|
+
* JSONForms rule effect constraints.
|
|
2057
|
+
*
|
|
2058
|
+
* @public
|
|
2059
|
+
*/
|
|
2060
|
+
declare interface RuleEffectConstraints {
|
|
2061
|
+
/** SHOW - show element when condition is true */
|
|
2062
|
+
SHOW?: Severity;
|
|
2063
|
+
/** HIDE - hide element when condition is true */
|
|
2064
|
+
HIDE?: Severity;
|
|
2065
|
+
/** ENABLE - enable element when condition is true */
|
|
2066
|
+
ENABLE?: Severity;
|
|
2067
|
+
/** DISABLE - disable element when condition is true */
|
|
2068
|
+
DISABLE?: Severity;
|
|
2069
|
+
}
|
|
2070
|
+
|
|
2071
|
+
/**
|
|
2072
|
+
* Condition for a rule.
|
|
2073
|
+
*
|
|
2074
|
+
* @public
|
|
2075
|
+
*/
|
|
2076
|
+
export declare interface SchemaBasedCondition {
|
|
2077
|
+
/** JSON Pointer scope the rule evaluates against. */
|
|
2078
|
+
readonly scope: string;
|
|
2079
|
+
/** JSON Schema fragment evaluated at the scoped location. */
|
|
2080
|
+
readonly schema: RuleConditionSchema;
|
|
2081
|
+
}
|
|
2082
|
+
|
|
2083
|
+
/**
|
|
2084
|
+
* A batch target for non-throwing schema generation.
|
|
2085
|
+
*
|
|
2086
|
+
* @public
|
|
2087
|
+
*/
|
|
2088
|
+
export declare interface SchemaGenerationTarget {
|
|
2089
|
+
/** Path to the TypeScript source file. */
|
|
2090
|
+
readonly filePath: string;
|
|
2091
|
+
/** Name of the exported class, interface, or type alias to analyze. */
|
|
2092
|
+
readonly typeName: string;
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2095
|
+
/**
|
|
2096
|
+
* Supported declaration kinds for declaration-driven schema generation.
|
|
2097
|
+
*
|
|
2098
|
+
* @public
|
|
2099
|
+
*/
|
|
2100
|
+
export declare type SchemaSourceDeclaration = ts.ClassDeclaration | ts.InterfaceDeclaration | ts.TypeAliasDeclaration;
|
|
2101
|
+
|
|
2102
|
+
/**
|
|
2103
|
+
* Severity level for constraint violations.
|
|
2104
|
+
* - "error": Violation fails validation
|
|
2105
|
+
* - "warn": Violation emits warning but passes
|
|
2106
|
+
* - "off": Feature is allowed (no violation)
|
|
2107
|
+
*
|
|
2108
|
+
* @public
|
|
2109
|
+
*/
|
|
2110
|
+
declare type Severity = "error" | "warn" | "off";
|
|
2111
|
+
|
|
2112
|
+
/**
|
|
2113
|
+
* Supported compiler context for static build-time analysis workflows.
|
|
2114
|
+
*
|
|
2115
|
+
* This context gives consumers access to the TypeScript program, checker, and
|
|
2116
|
+
* source file used to discover declarations before invoking FormSpec schema
|
|
2117
|
+
* generation helpers.
|
|
2118
|
+
*
|
|
2119
|
+
* @public
|
|
2120
|
+
*/
|
|
2121
|
+
export declare interface StaticBuildContext {
|
|
2122
|
+
/** Host-owned or FormSpec-created TypeScript program. */
|
|
2123
|
+
readonly program: ts.Program;
|
|
2124
|
+
/** TypeScript checker for symbol and type analysis. */
|
|
2125
|
+
readonly checker: ts.TypeChecker;
|
|
2126
|
+
/** Source file used as the entry module for export resolution. */
|
|
2127
|
+
readonly sourceFile: ts.SourceFile;
|
|
2128
|
+
}
|
|
2129
|
+
|
|
2130
|
+
export { StaticEnumField }
|
|
2131
|
+
|
|
2132
|
+
/**
|
|
2133
|
+
* Shared options for schema generation flows that support custom extensions.
|
|
2134
|
+
*
|
|
2135
|
+
* @public
|
|
2136
|
+
*/
|
|
2137
|
+
export declare interface StaticSchemaGenerationOptions {
|
|
2138
|
+
/**
|
|
2139
|
+
* FormSpec project configuration. When provided, resolves `extensionRegistry`,
|
|
2140
|
+
* `vendorPrefix`, `enumSerialization`, and `metadata` from the config object.
|
|
2141
|
+
* Direct options take precedence over config values.
|
|
2142
|
+
*/
|
|
2143
|
+
readonly config?: FormSpecConfig | undefined;
|
|
2144
|
+
/**
|
|
2145
|
+
* Registry used to resolve custom types, constraints, and annotations.
|
|
2146
|
+
* @deprecated Provide a `FormSpecConfig` via the `config` option instead.
|
|
2147
|
+
*/
|
|
2148
|
+
readonly extensionRegistry?: ExtensionRegistry | undefined;
|
|
2149
|
+
/**
|
|
2150
|
+
* Vendor prefix for emitted extension keywords.
|
|
2151
|
+
* @defaultValue "x-formspec"
|
|
2152
|
+
* @deprecated Provide a `FormSpecConfig` via the `config` option instead.
|
|
2153
|
+
*/
|
|
2154
|
+
readonly vendorPrefix?: string | undefined;
|
|
2155
|
+
/**
|
|
2156
|
+
* JSON Schema representation to use for static enums.
|
|
2157
|
+
* @defaultValue "enum"
|
|
2158
|
+
* @deprecated Provide a `FormSpecConfig` via the `config` option instead.
|
|
2159
|
+
*/
|
|
2160
|
+
readonly enumSerialization?: "enum" | "oneOf";
|
|
2161
|
+
/**
|
|
2162
|
+
* Metadata resolution policy for static schema generation.
|
|
2163
|
+
* @deprecated Provide a `FormSpecConfig` via the `config` option instead.
|
|
2164
|
+
*/
|
|
2165
|
+
readonly metadata?: MetadataPolicyInput | undefined;
|
|
2166
|
+
/** Discriminator-specific schema generation behavior. */
|
|
2167
|
+
readonly discriminator?: DiscriminatorResolutionOptions | undefined;
|
|
2168
|
+
/**
|
|
2169
|
+
* Absolute path to the FormSpec config file (e.g., `formspec.config.ts`).
|
|
2170
|
+
*
|
|
2171
|
+
* When provided alongside a `config` that includes extensions, the build
|
|
2172
|
+
* pipeline includes the config file in the TypeScript program and extracts
|
|
2173
|
+
* `defineCustomType<T>()` type parameters. This enables symbol-based custom
|
|
2174
|
+
* type detection — the most precise resolution path, immune to import aliases
|
|
2175
|
+
* and name collisions.
|
|
2176
|
+
*
|
|
2177
|
+
* Obtain this from `loadFormSpecConfig()`:
|
|
2178
|
+
* ```typescript
|
|
2179
|
+
* const { config, configPath } = await loadFormSpecConfig();
|
|
2180
|
+
* await generateSchemas({ filePath, typeName, config, configPath, errorReporting: "throw" });
|
|
2181
|
+
* ```
|
|
2182
|
+
*/
|
|
2183
|
+
readonly configPath?: string | undefined;
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
export { TextField }
|
|
2187
|
+
|
|
2188
|
+
/**
|
|
2189
|
+
* Root UI Schema (always a layout — not a Control, Category, or Label).
|
|
2190
|
+
*
|
|
2191
|
+
* @public
|
|
2192
|
+
*/
|
|
2193
|
+
export declare type UISchema = VerticalLayout | HorizontalLayout | GroupLayout | Categorization;
|
|
2194
|
+
|
|
2195
|
+
/**
|
|
2196
|
+
* UI Schema feature constraints - control JSONForms-specific features.
|
|
2197
|
+
*
|
|
2198
|
+
* @public
|
|
2199
|
+
*/
|
|
2200
|
+
declare interface UISchemaConstraints {
|
|
2201
|
+
/** Layout type constraints */
|
|
2202
|
+
layouts?: LayoutTypeConstraints;
|
|
2203
|
+
/** Rule (conditional) constraints */
|
|
2204
|
+
rules?: RuleConstraints;
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
/**
|
|
2208
|
+
* Union of all UI Schema element types.
|
|
2209
|
+
*
|
|
2210
|
+
* @public
|
|
2211
|
+
*/
|
|
2212
|
+
export declare type UISchemaElement = ControlElement | VerticalLayout | HorizontalLayout | GroupLayout | Categorization | Category | LabelElement;
|
|
2213
|
+
|
|
2214
|
+
/**
|
|
2215
|
+
* Base interface for all UI Schema elements.
|
|
2216
|
+
*
|
|
2217
|
+
* This is a manually maintained interface representing the common shape
|
|
2218
|
+
* shared by all element types. It is kept as an interface (rather than
|
|
2219
|
+
* derived from Zod) because it is the base of a discriminated union, not
|
|
2220
|
+
* a union member itself.
|
|
2221
|
+
*
|
|
2222
|
+
* @public
|
|
2223
|
+
*/
|
|
2224
|
+
export declare interface UISchemaElementBase {
|
|
2225
|
+
/** Discriminator for the concrete JSON Forms element type. */
|
|
2226
|
+
type: UISchemaElementType;
|
|
2227
|
+
/** Optional rule controlling visibility or enablement. */
|
|
2228
|
+
rule?: Rule;
|
|
2229
|
+
/** Renderer-specific options shared by UI schema elements. */
|
|
2230
|
+
options?: Record<string, unknown>;
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2233
|
+
/**
|
|
2234
|
+
* UI Schema element types.
|
|
2235
|
+
*
|
|
2236
|
+
* @public
|
|
2237
|
+
*/
|
|
2238
|
+
export declare type UISchemaElementType = "Control" | "VerticalLayout" | "HorizontalLayout" | "Group" | "Categorization" | "Category" | "Label";
|
|
2239
|
+
|
|
2240
|
+
/**
|
|
2241
|
+
* Zod schema for the root UI Schema (layout types only).
|
|
2242
|
+
*
|
|
2243
|
+
* @public
|
|
2244
|
+
*/
|
|
2245
|
+
export declare const uiSchemaSchema: z.ZodType<UISchema>;
|
|
2246
|
+
|
|
2247
|
+
/**
|
|
2248
|
+
* Options for validating canonical FormIR.
|
|
2249
|
+
*
|
|
2250
|
+
* @public
|
|
2251
|
+
*/
|
|
2252
|
+
export declare interface ValidateIROptions {
|
|
2253
|
+
/** Vendor prefix used when resolving extension-backed keywords. */
|
|
2254
|
+
readonly vendorPrefix?: string;
|
|
2255
|
+
/** Extension registry used to resolve custom constraints and types. */
|
|
2256
|
+
readonly extensionRegistry?: ExtensionRegistry;
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
/**
|
|
2260
|
+
* A machine-readable validation diagnostic returned by static schema analysis.
|
|
2261
|
+
*
|
|
2262
|
+
* @public
|
|
2263
|
+
*/
|
|
2264
|
+
export declare interface ValidationDiagnostic {
|
|
2265
|
+
/** Stable machine-readable diagnostic code. */
|
|
2266
|
+
readonly code: string;
|
|
2267
|
+
/** Human-readable explanation of the validation problem. */
|
|
2268
|
+
readonly message: string;
|
|
2269
|
+
/** Severity of the reported validation problem. */
|
|
2270
|
+
readonly severity: ValidationDiagnosticSeverity;
|
|
2271
|
+
/** Primary source location associated with the diagnostic. */
|
|
2272
|
+
readonly primaryLocation: ValidationDiagnosticLocation;
|
|
2273
|
+
/** Related source locations that add context to the diagnostic. */
|
|
2274
|
+
readonly relatedLocations: readonly ValidationDiagnosticLocation[];
|
|
2275
|
+
}
|
|
2276
|
+
|
|
2277
|
+
/**
|
|
2278
|
+
* Public source-location shape attached to validation diagnostics.
|
|
2279
|
+
*
|
|
2280
|
+
* This mirrors the provenance information surfaced by the shared analysis
|
|
2281
|
+
* layer without exposing `@formspec/core/internals` through the public API.
|
|
2282
|
+
*
|
|
2283
|
+
* @public
|
|
2284
|
+
*/
|
|
2285
|
+
export declare interface ValidationDiagnosticLocation {
|
|
2286
|
+
/** Authoring surface that produced the diagnostic location. */
|
|
2287
|
+
readonly surface: "tsdoc" | "chain-dsl" | "extension" | "inferred";
|
|
2288
|
+
/** Absolute path to the source file. */
|
|
2289
|
+
readonly file: string;
|
|
2290
|
+
/** 1-based line number in the source file. */
|
|
2291
|
+
readonly line: number;
|
|
2292
|
+
/** 0-based column number in the source file. */
|
|
2293
|
+
readonly column: number;
|
|
2294
|
+
/** Optional span length in characters. */
|
|
2295
|
+
readonly length?: number;
|
|
2296
|
+
/** Optional tag or construct associated with the location. */
|
|
2297
|
+
readonly tagName?: string;
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
/**
|
|
2301
|
+
* Supported severity levels returned by static build validation.
|
|
2302
|
+
*
|
|
2303
|
+
* @public
|
|
2304
|
+
*/
|
|
2305
|
+
export declare type ValidationDiagnosticSeverity = "error" | "warning";
|
|
2306
|
+
|
|
2307
|
+
/**
|
|
2308
|
+
* Result of validating canonical FormIR before schema emission.
|
|
2309
|
+
*
|
|
2310
|
+
* @public
|
|
2311
|
+
*/
|
|
2312
|
+
export declare interface ValidationResult {
|
|
2313
|
+
/** Diagnostics produced during validation. */
|
|
2314
|
+
readonly diagnostics: readonly ValidationDiagnostic[];
|
|
2315
|
+
/** Whether any error-severity diagnostics were produced. */
|
|
2316
|
+
readonly valid: boolean;
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2319
|
+
/**
|
|
2320
|
+
* A vertical layout element.
|
|
2321
|
+
*
|
|
2322
|
+
* @public
|
|
2323
|
+
*/
|
|
2324
|
+
export declare interface VerticalLayout {
|
|
2325
|
+
/** Discriminator identifying a vertical layout container. */
|
|
2326
|
+
readonly type: "VerticalLayout";
|
|
2327
|
+
/** Child elements rendered in vertical order. */
|
|
2328
|
+
readonly elements: UISchemaElement[];
|
|
2329
|
+
/** Optional rule controlling visibility or enablement. */
|
|
2330
|
+
readonly rule?: Rule | undefined;
|
|
2331
|
+
/** Renderer-specific layout options. */
|
|
2332
|
+
readonly options?: Record<string, unknown> | undefined;
|
|
2333
|
+
/** Additional renderer-specific extension properties. */
|
|
2334
|
+
readonly [k: string]: unknown;
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2337
|
+
/**
|
|
2338
|
+
* Registration for a vocabulary keyword to include in a JSON Schema `$vocabulary` declaration.
|
|
2339
|
+
*
|
|
2340
|
+
* @public
|
|
2341
|
+
*/
|
|
2342
|
+
declare interface VocabularyKeywordRegistration {
|
|
2343
|
+
/** The keyword name (without vendor prefix). */
|
|
2344
|
+
readonly keyword: string;
|
|
2345
|
+
/** JSON Schema that describes the valid values for this keyword. */
|
|
2346
|
+
readonly schema: ExtensionPayloadValue;
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2349
|
+
/**
|
|
2350
|
+
* Builds and writes both JSON Schema and UI Schema files to disk.
|
|
2351
|
+
*
|
|
2352
|
+
* This is a convenience function for build-time schema generation.
|
|
2353
|
+
* It creates the output directory if it doesn't exist.
|
|
2354
|
+
*
|
|
2355
|
+
* @example
|
|
2356
|
+
* ```typescript
|
|
2357
|
+
* import { formspec, field } from "formspec";
|
|
2358
|
+
* import { writeSchemas } from "@formspec/build";
|
|
2359
|
+
*
|
|
2360
|
+
* const ProductForm = formspec(
|
|
2361
|
+
* field.text("name", { required: true }),
|
|
2362
|
+
* field.enum("status", ["draft", "active"]),
|
|
2363
|
+
* );
|
|
2364
|
+
*
|
|
2365
|
+
* // Write schemas to ./generated/product-schema.json and ./generated/product-uischema.json
|
|
2366
|
+
* const { jsonSchemaPath, uiSchemaPath } = writeSchemas(ProductForm, {
|
|
2367
|
+
* outDir: "./generated",
|
|
2368
|
+
* name: "product",
|
|
2369
|
+
* });
|
|
2370
|
+
*
|
|
2371
|
+
* console.log(`Generated: ${jsonSchemaPath}, ${uiSchemaPath}`);
|
|
2372
|
+
* ```
|
|
2373
|
+
*
|
|
2374
|
+
* @param form - The FormSpec to build schemas from
|
|
2375
|
+
* @param options - Output options (directory, file name, indentation)
|
|
2376
|
+
* @returns Object containing paths to the generated files
|
|
2377
|
+
*
|
|
2378
|
+
* @public
|
|
2379
|
+
*/
|
|
2380
|
+
export declare function writeSchemas<E extends readonly FormElement[]>(form: FormSpec<E>, options: WriteSchemasOptions): WriteSchemasResult;
|
|
2381
|
+
|
|
2382
|
+
/**
|
|
2383
|
+
* Options for writing schemas to disk.
|
|
2384
|
+
*
|
|
2385
|
+
* @public
|
|
2386
|
+
*/
|
|
2387
|
+
export declare interface WriteSchemasOptions extends GenerateJsonSchemaOptions {
|
|
2388
|
+
/** Output directory for the schema files */
|
|
2389
|
+
readonly outDir: string;
|
|
2390
|
+
/** Base name for the output files (without extension). Defaults to "schema" */
|
|
2391
|
+
readonly name?: string;
|
|
2392
|
+
/** Number of spaces for JSON indentation. Defaults to 2 */
|
|
2393
|
+
readonly indent?: number;
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
/**
|
|
2397
|
+
* Result of writing schemas to disk.
|
|
2398
|
+
*
|
|
2399
|
+
* @public
|
|
2400
|
+
*/
|
|
2401
|
+
export declare interface WriteSchemasResult {
|
|
2402
|
+
/** Path to the generated JSON Schema file */
|
|
2403
|
+
readonly jsonSchemaPath: string;
|
|
2404
|
+
/** Path to the generated UI Schema file */
|
|
2405
|
+
readonly uiSchemaPath: string;
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
export { }
|