@formspec/build 0.1.0-alpha.10 → 0.1.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -15
- package/dist/__tests__/chain-dsl-canonicalizer.test.d.ts +2 -0
- package/dist/__tests__/chain-dsl-canonicalizer.test.d.ts.map +1 -0
- package/dist/__tests__/constraint-validator.test.d.ts +2 -0
- package/dist/__tests__/constraint-validator.test.d.ts.map +1 -0
- package/dist/__tests__/extension-api.test.d.ts +2 -0
- package/dist/__tests__/extension-api.test.d.ts.map +1 -0
- package/dist/__tests__/fixtures/example-a-builtins.d.ts +18 -0
- package/dist/__tests__/fixtures/example-a-builtins.d.ts.map +1 -1
- package/dist/__tests__/ir-analyzer.test.d.ts +11 -0
- package/dist/__tests__/ir-analyzer.test.d.ts.map +1 -0
- package/dist/__tests__/ir-jsdoc-constraints.test.d.ts +12 -0
- package/dist/__tests__/ir-jsdoc-constraints.test.d.ts.map +1 -0
- package/dist/__tests__/ir-json-schema-generator.test.d.ts +11 -0
- package/dist/__tests__/ir-json-schema-generator.test.d.ts.map +1 -0
- package/dist/__tests__/ir-ui-schema-generator.test.d.ts +2 -0
- package/dist/__tests__/ir-ui-schema-generator.test.d.ts.map +1 -0
- package/dist/__tests__/jsdoc-constraints.test.d.ts +4 -4
- package/dist/__tests__/parity/fixtures/address/chain-dsl.d.ts +9 -0
- package/dist/__tests__/parity/fixtures/address/chain-dsl.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/address/expected-ir.d.ts +9 -0
- package/dist/__tests__/parity/fixtures/address/expected-ir.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/address/tsdoc.d.ts +19 -0
- package/dist/__tests__/parity/fixtures/address/tsdoc.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/product-config/chain-dsl.d.ts +13 -0
- package/dist/__tests__/parity/fixtures/product-config/chain-dsl.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/product-config/expected-ir.d.ts +9 -0
- package/dist/__tests__/parity/fixtures/product-config/expected-ir.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/product-config/tsdoc.d.ts +28 -0
- package/dist/__tests__/parity/fixtures/product-config/tsdoc.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/user-registration/chain-dsl.d.ts +12 -0
- package/dist/__tests__/parity/fixtures/user-registration/chain-dsl.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/user-registration/expected-ir.d.ts +9 -0
- package/dist/__tests__/parity/fixtures/user-registration/expected-ir.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/user-registration/tsdoc.d.ts +19 -0
- package/dist/__tests__/parity/fixtures/user-registration/tsdoc.d.ts.map +1 -0
- package/dist/__tests__/parity/parity.test.d.ts +14 -0
- package/dist/__tests__/parity/parity.test.d.ts.map +1 -0
- package/dist/__tests__/parity/utils.d.ts +139 -0
- package/dist/__tests__/parity/utils.d.ts.map +1 -0
- package/dist/analyzer/class-analyzer.d.ts +54 -99
- package/dist/analyzer/class-analyzer.d.ts.map +1 -1
- package/dist/analyzer/jsdoc-constraints.d.ts +78 -30
- package/dist/analyzer/jsdoc-constraints.d.ts.map +1 -1
- package/dist/analyzer/tsdoc-parser.d.ts +61 -0
- package/dist/analyzer/tsdoc-parser.d.ts.map +1 -0
- package/dist/browser.cjs +1200 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.ts +12 -6
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +1147 -44
- package/dist/browser.js.map +1 -1
- package/dist/build.d.ts +385 -160
- package/dist/canonicalize/chain-dsl-canonicalizer.d.ts +18 -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 +34 -0
- package/dist/canonicalize/tsdoc-canonicalizer.d.ts.map +1 -0
- package/dist/cli.cjs +2028 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.js +1978 -101
- 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 +55 -0
- package/dist/extensions/registry.d.ts.map +1 -0
- package/dist/generators/class-schema.d.ts +28 -47
- package/dist/generators/class-schema.d.ts.map +1 -1
- package/dist/generators/method-schema.d.ts +6 -8
- package/dist/generators/method-schema.d.ts.map +1 -1
- package/dist/index.cjs +1832 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1779 -114
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +2125 -0
- package/dist/internals.cjs.map +1 -0
- package/dist/internals.d.ts +12 -2
- package/dist/internals.d.ts.map +1 -1
- package/dist/internals.js +2084 -21
- package/dist/internals.js.map +1 -1
- package/dist/json-schema/generator.d.ts +10 -5
- package/dist/json-schema/generator.d.ts.map +1 -1
- package/dist/json-schema/ir-generator.d.ts +84 -0
- package/dist/json-schema/ir-generator.d.ts.map +1 -0
- package/dist/json-schema/schema.d.ts +16 -0
- package/dist/json-schema/schema.d.ts.map +1 -0
- package/dist/json-schema/types.d.ts +5 -6
- package/dist/json-schema/types.d.ts.map +1 -1
- package/dist/ui-schema/generator.d.ts +5 -0
- package/dist/ui-schema/generator.d.ts.map +1 -1
- package/dist/ui-schema/ir-generator.d.ts +53 -0
- package/dist/ui-schema/ir-generator.d.ts.map +1 -0
- package/dist/ui-schema/schema.d.ts +357 -0
- package/dist/ui-schema/schema.d.ts.map +1 -0
- package/dist/ui-schema/types.d.ts +8 -73
- package/dist/ui-schema/types.d.ts.map +1 -1
- package/dist/validate/constraint-validator.d.ts +66 -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 +15 -9
- package/dist/__tests__/analyzer-edge-cases.test.d.ts +0 -13
- package/dist/__tests__/analyzer-edge-cases.test.d.ts.map +0 -1
- package/dist/__tests__/analyzer-edge-cases.test.js +0 -376
- package/dist/__tests__/analyzer-edge-cases.test.js.map +0 -1
- package/dist/__tests__/analyzer.test.d.ts +0 -5
- package/dist/__tests__/analyzer.test.d.ts.map +0 -1
- package/dist/__tests__/analyzer.test.js +0 -190
- package/dist/__tests__/analyzer.test.js.map +0 -1
- package/dist/__tests__/cli.test.js +0 -178
- package/dist/__tests__/cli.test.js.map +0 -1
- package/dist/__tests__/codegen.test.d.ts +0 -5
- package/dist/__tests__/codegen.test.d.ts.map +0 -1
- package/dist/__tests__/codegen.test.js +0 -506
- package/dist/__tests__/codegen.test.js.map +0 -1
- package/dist/__tests__/decorator-pipeline.test.d.ts +0 -11
- package/dist/__tests__/decorator-pipeline.test.d.ts.map +0 -1
- package/dist/__tests__/decorator-pipeline.test.js +0 -460
- package/dist/__tests__/decorator-pipeline.test.js.map +0 -1
- package/dist/__tests__/edge-cases.test.js +0 -215
- package/dist/__tests__/edge-cases.test.js.map +0 -1
- package/dist/__tests__/fixtures/edge-cases.js +0 -137
- package/dist/__tests__/fixtures/edge-cases.js.map +0 -1
- package/dist/__tests__/fixtures/example-a-builtins.js +0 -100
- package/dist/__tests__/fixtures/example-a-builtins.js.map +0 -1
- package/dist/__tests__/fixtures/example-b-decorators.d.ts +0 -5
- package/dist/__tests__/fixtures/example-b-decorators.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-b-decorators.js +0 -5
- package/dist/__tests__/fixtures/example-b-decorators.js.map +0 -1
- package/dist/__tests__/fixtures/example-b-extended.d.ts +0 -5
- package/dist/__tests__/fixtures/example-b-extended.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-b-extended.js +0 -60
- package/dist/__tests__/fixtures/example-b-extended.js.map +0 -1
- package/dist/__tests__/fixtures/example-c-custom.d.ts +0 -5
- package/dist/__tests__/fixtures/example-c-custom.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-c-custom.js +0 -61
- package/dist/__tests__/fixtures/example-c-custom.js.map +0 -1
- package/dist/__tests__/fixtures/example-c-decorators.d.ts +0 -5
- package/dist/__tests__/fixtures/example-c-decorators.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-c-decorators.js +0 -4
- package/dist/__tests__/fixtures/example-c-decorators.js.map +0 -1
- package/dist/__tests__/fixtures/example-d-mixed-decorators.d.ts +0 -6
- package/dist/__tests__/fixtures/example-d-mixed-decorators.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-d-mixed-decorators.js +0 -75
- package/dist/__tests__/fixtures/example-d-mixed-decorators.js.map +0 -1
- package/dist/__tests__/fixtures/example-e-decorators.d.ts +0 -11
- package/dist/__tests__/fixtures/example-e-decorators.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-e-decorators.js +0 -10
- package/dist/__tests__/fixtures/example-e-decorators.js.map +0 -1
- package/dist/__tests__/fixtures/example-e-no-namespace.d.ts +0 -5
- package/dist/__tests__/fixtures/example-e-no-namespace.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-e-no-namespace.js +0 -61
- package/dist/__tests__/fixtures/example-e-no-namespace.js.map +0 -1
- package/dist/__tests__/fixtures/example-interface-types.js +0 -8
- package/dist/__tests__/fixtures/example-interface-types.js.map +0 -1
- package/dist/__tests__/fixtures/example-jsdoc-constraints.d.ts +0 -16
- package/dist/__tests__/fixtures/example-jsdoc-constraints.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-jsdoc-constraints.js +0 -98
- package/dist/__tests__/fixtures/example-jsdoc-constraints.js.map +0 -1
- package/dist/__tests__/fixtures/example-nested-class.d.ts +0 -45
- package/dist/__tests__/fixtures/example-nested-class.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-nested-class.js +0 -248
- package/dist/__tests__/fixtures/example-nested-class.js.map +0 -1
- package/dist/__tests__/fixtures/sample-forms.js +0 -78
- package/dist/__tests__/fixtures/sample-forms.js.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.js +0 -161
- package/dist/__tests__/integration.test.js.map +0 -1
- package/dist/__tests__/interface-types.test.d.ts +0 -11
- package/dist/__tests__/interface-types.test.d.ts.map +0 -1
- package/dist/__tests__/interface-types.test.js +0 -404
- package/dist/__tests__/interface-types.test.js.map +0 -1
- package/dist/__tests__/jsdoc-constraints.test.js +0 -465
- package/dist/__tests__/jsdoc-constraints.test.js.map +0 -1
- package/dist/__tests__/write-schemas.test.js +0 -198
- package/dist/__tests__/write-schemas.test.js.map +0 -1
- package/dist/analyzer/class-analyzer.js +0 -377
- package/dist/analyzer/class-analyzer.js.map +0 -1
- package/dist/analyzer/decorator-extractor.d.ts +0 -78
- package/dist/analyzer/decorator-extractor.d.ts.map +0 -1
- package/dist/analyzer/decorator-extractor.js +0 -336
- package/dist/analyzer/decorator-extractor.js.map +0 -1
- package/dist/analyzer/jsdoc-constraints.js +0 -153
- package/dist/analyzer/jsdoc-constraints.js.map +0 -1
- package/dist/analyzer/program.js +0 -114
- package/dist/analyzer/program.js.map +0 -1
- package/dist/analyzer/type-converter.d.ts +0 -75
- package/dist/analyzer/type-converter.d.ts.map +0 -1
- package/dist/analyzer/type-converter.js +0 -474
- package/dist/analyzer/type-converter.js.map +0 -1
- package/dist/codegen/index.d.ts +0 -75
- package/dist/codegen/index.d.ts.map +0 -1
- package/dist/codegen/index.js +0 -597
- package/dist/codegen/index.js.map +0 -1
- package/dist/generators/class-schema.js +0 -140
- package/dist/generators/class-schema.js.map +0 -1
- package/dist/generators/method-schema.js +0 -108
- package/dist/generators/method-schema.js.map +0 -1
- package/dist/json-schema/generator.js +0 -166
- package/dist/json-schema/generator.js.map +0 -1
- package/dist/json-schema/types.js +0 -33
- package/dist/json-schema/types.js.map +0 -1
- package/dist/ui-schema/generator.js +0 -148
- 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
package/dist/build.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* `@formspec/build` - Build tools for FormSpec
|
|
3
3
|
*
|
|
4
4
|
* This package provides generators to compile FormSpec forms into:
|
|
5
|
-
* - JSON Schema (for validation)
|
|
5
|
+
* - JSON Schema 2020-12 (for validation)
|
|
6
6
|
* - JSON Forms UI Schema (for rendering)
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
import type { FormElement } from '@formspec/core';
|
|
27
27
|
import type { FormSpec } from '@formspec/core';
|
|
28
|
+
import { z } from 'zod';
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* Builds both JSON Schema and UI Schema from a FormSpec.
|
|
@@ -59,105 +60,156 @@ export declare function buildFormSchemas<E extends readonly FormElement[]>(form:
|
|
|
59
60
|
* Result of building form schemas.
|
|
60
61
|
*/
|
|
61
62
|
export declare interface BuildResult {
|
|
62
|
-
/** JSON Schema for validation */
|
|
63
|
-
readonly jsonSchema:
|
|
63
|
+
/** JSON Schema 2020-12 for validation */
|
|
64
|
+
readonly jsonSchema: JsonSchema2020;
|
|
64
65
|
/** JSON Forms UI Schema for rendering */
|
|
65
66
|
readonly uiSchema: UISchema;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
/**
|
|
69
|
-
*
|
|
70
|
+
* A Categorization element (tab-based layout).
|
|
70
71
|
*/
|
|
71
|
-
export declare interface
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
export declare interface Categorization {
|
|
73
|
+
type: "Categorization";
|
|
74
|
+
elements: Category[];
|
|
75
|
+
label?: string | undefined;
|
|
76
|
+
rule?: Rule | undefined;
|
|
77
|
+
options?: Record<string, unknown> | undefined;
|
|
78
|
+
[k: string]: unknown;
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
export declare const categorizationSchema: z.ZodType<Categorization>;
|
|
82
|
+
|
|
80
83
|
/**
|
|
81
|
-
*
|
|
84
|
+
* A Category element, used inside a Categorization layout.
|
|
82
85
|
*/
|
|
83
|
-
export declare interface
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
export declare interface Category {
|
|
87
|
+
type: "Category";
|
|
88
|
+
label: string;
|
|
89
|
+
elements: UISchemaElement[];
|
|
90
|
+
rule?: Rule | undefined;
|
|
91
|
+
options?: Record<string, unknown> | undefined;
|
|
92
|
+
[k: string]: unknown;
|
|
90
93
|
}
|
|
91
94
|
|
|
95
|
+
export declare const categorySchema: z.ZodType<Category>;
|
|
96
|
+
|
|
92
97
|
/**
|
|
93
|
-
*
|
|
98
|
+
* Generated schemas for a class.
|
|
94
99
|
*/
|
|
95
|
-
export declare interface
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
export declare interface ClassSchemas {
|
|
101
|
+
/** JSON Schema 2020-12 for validation */
|
|
102
|
+
jsonSchema: JsonSchema2020;
|
|
103
|
+
/** JSON Forms UI Schema for rendering */
|
|
104
|
+
uiSchema: UISchema;
|
|
99
105
|
}
|
|
100
106
|
|
|
101
107
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* Used to track which classes need type metadata patches and where
|
|
105
|
-
* they are located in the source tree.
|
|
108
|
+
* A Control element that binds to a JSON Schema property.
|
|
106
109
|
*/
|
|
107
|
-
export declare
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
110
|
+
export declare type ControlElement = z.infer<typeof controlSchema>;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Zod schema for a Control element.
|
|
114
|
+
*/
|
|
115
|
+
export declare const controlSchema: z.ZodObject<{
|
|
116
|
+
type: z.ZodLiteral<"Control">;
|
|
117
|
+
scope: z.ZodString;
|
|
118
|
+
label: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodLiteral<false>]>>;
|
|
119
|
+
rule: z.ZodOptional<z.ZodObject<{
|
|
120
|
+
effect: z.ZodEnum<["SHOW", "HIDE", "ENABLE", "DISABLE"]>;
|
|
121
|
+
condition: z.ZodObject<{
|
|
122
|
+
scope: z.ZodString;
|
|
123
|
+
schema: z.ZodType<RuleConditionSchema, z.ZodTypeDef, RuleConditionSchema>;
|
|
124
|
+
}, "strict", z.ZodTypeAny, {
|
|
125
|
+
schema: RuleConditionSchema;
|
|
126
|
+
scope: string;
|
|
127
|
+
}, {
|
|
128
|
+
schema: RuleConditionSchema;
|
|
129
|
+
scope: string;
|
|
130
|
+
}>;
|
|
131
|
+
}, "strict", z.ZodTypeAny, {
|
|
132
|
+
effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
|
|
133
|
+
condition: {
|
|
134
|
+
schema: RuleConditionSchema;
|
|
135
|
+
scope: string;
|
|
136
|
+
};
|
|
137
|
+
}, {
|
|
138
|
+
effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
|
|
139
|
+
condition: {
|
|
140
|
+
schema: RuleConditionSchema;
|
|
141
|
+
scope: string;
|
|
142
|
+
};
|
|
143
|
+
}>>;
|
|
144
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
145
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
146
|
+
type: z.ZodLiteral<"Control">;
|
|
147
|
+
scope: z.ZodString;
|
|
148
|
+
label: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodLiteral<false>]>>;
|
|
149
|
+
rule: z.ZodOptional<z.ZodObject<{
|
|
150
|
+
effect: z.ZodEnum<["SHOW", "HIDE", "ENABLE", "DISABLE"]>;
|
|
151
|
+
condition: z.ZodObject<{
|
|
152
|
+
scope: z.ZodString;
|
|
153
|
+
schema: z.ZodType<RuleConditionSchema, z.ZodTypeDef, RuleConditionSchema>;
|
|
154
|
+
}, "strict", z.ZodTypeAny, {
|
|
155
|
+
schema: RuleConditionSchema;
|
|
156
|
+
scope: string;
|
|
157
|
+
}, {
|
|
158
|
+
schema: RuleConditionSchema;
|
|
159
|
+
scope: string;
|
|
160
|
+
}>;
|
|
161
|
+
}, "strict", z.ZodTypeAny, {
|
|
162
|
+
effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
|
|
163
|
+
condition: {
|
|
164
|
+
schema: RuleConditionSchema;
|
|
165
|
+
scope: string;
|
|
166
|
+
};
|
|
167
|
+
}, {
|
|
168
|
+
effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
|
|
169
|
+
condition: {
|
|
170
|
+
schema: RuleConditionSchema;
|
|
171
|
+
scope: string;
|
|
172
|
+
};
|
|
173
|
+
}>>;
|
|
174
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
175
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
176
|
+
type: z.ZodLiteral<"Control">;
|
|
177
|
+
scope: z.ZodString;
|
|
178
|
+
label: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodLiteral<false>]>>;
|
|
179
|
+
rule: z.ZodOptional<z.ZodObject<{
|
|
180
|
+
effect: z.ZodEnum<["SHOW", "HIDE", "ENABLE", "DISABLE"]>;
|
|
181
|
+
condition: z.ZodObject<{
|
|
182
|
+
scope: z.ZodString;
|
|
183
|
+
schema: z.ZodType<RuleConditionSchema, z.ZodTypeDef, RuleConditionSchema>;
|
|
184
|
+
}, "strict", z.ZodTypeAny, {
|
|
185
|
+
schema: RuleConditionSchema;
|
|
186
|
+
scope: string;
|
|
187
|
+
}, {
|
|
188
|
+
schema: RuleConditionSchema;
|
|
189
|
+
scope: string;
|
|
190
|
+
}>;
|
|
191
|
+
}, "strict", z.ZodTypeAny, {
|
|
192
|
+
effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
|
|
193
|
+
condition: {
|
|
194
|
+
schema: RuleConditionSchema;
|
|
195
|
+
scope: string;
|
|
196
|
+
};
|
|
197
|
+
}, {
|
|
198
|
+
effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
|
|
199
|
+
condition: {
|
|
200
|
+
schema: RuleConditionSchema;
|
|
201
|
+
scope: string;
|
|
202
|
+
};
|
|
203
|
+
}>>;
|
|
204
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
205
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
117
206
|
|
|
118
207
|
/** JSON Schema with FormSpec extension properties for arbitrary x-formspec-* keys. */
|
|
119
208
|
export declare type ExtendedJSONSchema7 = JSONSchema7 & FormSpecSchemaExtensions;
|
|
120
209
|
|
|
121
|
-
/**
|
|
122
|
-
* Finds all decorated classes in the given source files.
|
|
123
|
-
*/
|
|
124
|
-
export declare function findDecoratedClasses(files: string[], baseDir: string): DecoratedClassInfo[];
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* FormSpec field definition (simplified for output).
|
|
128
|
-
*/
|
|
129
|
-
export declare interface FormSpecField {
|
|
130
|
-
_field: string;
|
|
131
|
-
id: string;
|
|
132
|
-
label?: string;
|
|
133
|
-
placeholder?: string;
|
|
134
|
-
description?: string;
|
|
135
|
-
required?: boolean;
|
|
136
|
-
min?: number;
|
|
137
|
-
max?: number;
|
|
138
|
-
step?: number;
|
|
139
|
-
minLength?: number;
|
|
140
|
-
maxLength?: number;
|
|
141
|
-
minItems?: number;
|
|
142
|
-
maxItems?: number;
|
|
143
|
-
pattern?: string;
|
|
144
|
-
options?: (string | {
|
|
145
|
-
id: string;
|
|
146
|
-
label: string;
|
|
147
|
-
})[];
|
|
148
|
-
showWhen?: object;
|
|
149
|
-
group?: string;
|
|
150
|
-
fields?: FormSpecField[];
|
|
151
|
-
}
|
|
152
|
-
|
|
153
210
|
/** Extension properties for custom FormSpec decorators. */
|
|
154
211
|
export declare type FormSpecSchemaExtensions = Record<`x-formspec-${string}`, unknown>;
|
|
155
212
|
|
|
156
|
-
/**
|
|
157
|
-
* Generates the codegen output file content.
|
|
158
|
-
*/
|
|
159
|
-
export declare function generateCodegenOutput(classes: DecoratedClassInfo[], outputPath: string, baseDir: string): string;
|
|
160
|
-
|
|
161
213
|
/**
|
|
162
214
|
* Options for generating schemas from a decorated class.
|
|
163
215
|
*/
|
|
@@ -172,16 +224,17 @@ export declare interface GenerateFromClassOptions {
|
|
|
172
224
|
* Result of generating schemas from a decorated class.
|
|
173
225
|
*/
|
|
174
226
|
export declare interface GenerateFromClassResult {
|
|
175
|
-
/** JSON Schema for validation */
|
|
176
|
-
jsonSchema:
|
|
177
|
-
/**
|
|
178
|
-
uiSchema:
|
|
179
|
-
elements: FormSpecField[];
|
|
180
|
-
};
|
|
227
|
+
/** JSON Schema 2020-12 for validation */
|
|
228
|
+
jsonSchema: JsonSchema2020;
|
|
229
|
+
/** JSON Forms UI Schema for rendering */
|
|
230
|
+
uiSchema: UISchema;
|
|
181
231
|
}
|
|
182
232
|
|
|
183
233
|
/**
|
|
184
|
-
* Generates a JSON Schema from a FormSpec.
|
|
234
|
+
* Generates a JSON Schema 2020-12 from a FormSpec.
|
|
235
|
+
*
|
|
236
|
+
* All generation routes through the canonical IR. The chain DSL is first
|
|
237
|
+
* canonicalized to a FormIR, then the IR-based generator produces the schema.
|
|
185
238
|
*
|
|
186
239
|
* @example
|
|
187
240
|
* ```typescript
|
|
@@ -192,7 +245,7 @@ export declare interface GenerateFromClassResult {
|
|
|
192
245
|
*
|
|
193
246
|
* const schema = generateJsonSchema(form);
|
|
194
247
|
* // {
|
|
195
|
-
* // $schema: "https://json-schema.org/draft-
|
|
248
|
+
* // $schema: "https://json-schema.org/draft/2020-12/schema",
|
|
196
249
|
* // type: "object",
|
|
197
250
|
* // properties: {
|
|
198
251
|
* // name: { type: "string", title: "Name" },
|
|
@@ -203,25 +256,20 @@ export declare interface GenerateFromClassResult {
|
|
|
203
256
|
* ```
|
|
204
257
|
*
|
|
205
258
|
* @param form - The FormSpec to convert
|
|
206
|
-
* @returns A JSON Schema object
|
|
259
|
+
* @returns A JSON Schema 2020-12 object
|
|
207
260
|
*/
|
|
208
|
-
export declare function generateJsonSchema<E extends readonly FormElement[]>(form: FormSpec<E>):
|
|
261
|
+
export declare function generateJsonSchema<E extends readonly FormElement[]>(form: FormSpec<E>): JsonSchema2020;
|
|
209
262
|
|
|
210
263
|
/**
|
|
211
|
-
* Generates JSON Schema and
|
|
264
|
+
* Generates JSON Schema and UI Schema from a named TypeScript
|
|
212
265
|
* type — a decorated class, an interface with TSDoc tags, or a type alias.
|
|
213
266
|
*
|
|
214
267
|
* This is the recommended entry point. It automatically detects whether
|
|
215
268
|
* the name resolves to a class, interface, or type alias and uses the
|
|
216
|
-
* appropriate analysis pipeline
|
|
217
|
-
*
|
|
218
|
-
* - **Classes**: extracts decorators and JSDoc constraints
|
|
219
|
-
* - **Interfaces**: extracts TSDoc tags (`@Field_displayName`, `@Minimum`, etc.)
|
|
220
|
-
* - **Type aliases**: object literal bodies analyzed like interfaces
|
|
269
|
+
* appropriate IR analysis pipeline.
|
|
221
270
|
*
|
|
222
271
|
* @example
|
|
223
272
|
* ```typescript
|
|
224
|
-
* // Works with both classes and interfaces — caller doesn't need to know
|
|
225
273
|
* const result = generateSchemas({
|
|
226
274
|
* filePath: "./src/config.ts",
|
|
227
275
|
* typeName: "DiscountConfig",
|
|
@@ -229,15 +277,15 @@ export declare function generateJsonSchema<E extends readonly FormElement[]>(for
|
|
|
229
277
|
* ```
|
|
230
278
|
*
|
|
231
279
|
* @param options - File path and type name
|
|
232
|
-
* @returns Generated JSON Schema and
|
|
280
|
+
* @returns Generated JSON Schema and UI Schema
|
|
233
281
|
*/
|
|
234
282
|
export declare function generateSchemas(options: GenerateSchemasOptions): GenerateFromClassResult;
|
|
235
283
|
|
|
236
284
|
/**
|
|
237
|
-
* Generates JSON Schema and
|
|
285
|
+
* Generates JSON Schema and UI Schema from a decorated TypeScript class.
|
|
238
286
|
*
|
|
239
287
|
* This is a high-level entry point that handles the entire pipeline:
|
|
240
|
-
* creating a TypeScript program, finding the class, analyzing it,
|
|
288
|
+
* creating a TypeScript program, finding the class, analyzing it to IR,
|
|
241
289
|
* and generating schemas — all in one call.
|
|
242
290
|
*
|
|
243
291
|
* @example
|
|
@@ -250,7 +298,7 @@ export declare function generateSchemas(options: GenerateSchemasOptions): Genera
|
|
|
250
298
|
* ```
|
|
251
299
|
*
|
|
252
300
|
* @param options - File path, class name, and optional compiler options
|
|
253
|
-
* @returns Generated JSON Schema and
|
|
301
|
+
* @returns Generated JSON Schema and UI Schema
|
|
254
302
|
*/
|
|
255
303
|
export declare function generateSchemasFromClass(options: GenerateFromClassOptions): GenerateFromClassResult;
|
|
256
304
|
|
|
@@ -267,6 +315,9 @@ export declare interface GenerateSchemasOptions {
|
|
|
267
315
|
/**
|
|
268
316
|
* Generates a JSON Forms UI Schema from a FormSpec.
|
|
269
317
|
*
|
|
318
|
+
* All generation routes through the canonical IR. The chain DSL is first
|
|
319
|
+
* canonicalized to a FormIR, then the IR-based generator produces the schema.
|
|
320
|
+
*
|
|
270
321
|
* @example
|
|
271
322
|
* ```typescript
|
|
272
323
|
* const form = formspec(
|
|
@@ -310,34 +361,80 @@ export declare function generateUiSchema<E extends readonly FormElement[]>(form:
|
|
|
310
361
|
/**
|
|
311
362
|
* Reads a FormSpec extension property from a JSON Schema node.
|
|
312
363
|
*
|
|
313
|
-
*
|
|
314
|
-
* including nested schemas typed as `JSONSchema7`.
|
|
364
|
+
* Accepts any schema object — `JSONSchema7`, `JsonSchema2020`, `ExtendedJSONSchema7`, etc.
|
|
315
365
|
*
|
|
316
366
|
* @param schema - Any JSON Schema node
|
|
317
367
|
* @param key - Extension key (must start with `x-formspec-`)
|
|
318
368
|
* @returns The extension value, or `undefined` if not present
|
|
319
369
|
*/
|
|
320
|
-
export declare function getSchemaExtension(schema:
|
|
370
|
+
export declare function getSchemaExtension(schema: object, key: `x-formspec-${string}`): unknown;
|
|
321
371
|
|
|
322
372
|
/**
|
|
323
373
|
* A group element with a label.
|
|
324
374
|
*/
|
|
325
|
-
export declare interface GroupLayout
|
|
375
|
+
export declare interface GroupLayout {
|
|
326
376
|
type: "Group";
|
|
327
377
|
label: string;
|
|
328
378
|
elements: UISchemaElement[];
|
|
379
|
+
rule?: Rule | undefined;
|
|
380
|
+
options?: Record<string, unknown> | undefined;
|
|
381
|
+
[k: string]: unknown;
|
|
329
382
|
}
|
|
330
383
|
|
|
384
|
+
export declare const groupLayoutSchema: z.ZodType<GroupLayout>;
|
|
385
|
+
|
|
331
386
|
/**
|
|
332
387
|
* A horizontal layout element.
|
|
333
388
|
*/
|
|
334
|
-
export declare interface HorizontalLayout
|
|
389
|
+
export declare interface HorizontalLayout {
|
|
335
390
|
type: "HorizontalLayout";
|
|
336
391
|
elements: UISchemaElement[];
|
|
392
|
+
rule?: Rule | undefined;
|
|
393
|
+
options?: Record<string, unknown> | undefined;
|
|
394
|
+
[k: string]: unknown;
|
|
337
395
|
}
|
|
338
396
|
|
|
397
|
+
export declare const horizontalLayoutSchema: z.ZodType<HorizontalLayout>;
|
|
398
|
+
|
|
339
399
|
/**
|
|
340
|
-
* A JSON Schema
|
|
400
|
+
* A JSON Schema 2020-12 document, sub-schema, or keyword collection.
|
|
401
|
+
*
|
|
402
|
+
* This interface covers the subset of JSON Schema 2020-12 that this generator
|
|
403
|
+
* emits, plus an index signature for custom `x-formspec-*` extension keywords.
|
|
404
|
+
*/
|
|
405
|
+
export declare interface JsonSchema2020 {
|
|
406
|
+
$schema?: string;
|
|
407
|
+
$ref?: string;
|
|
408
|
+
$defs?: Record<string, JsonSchema2020>;
|
|
409
|
+
type?: string;
|
|
410
|
+
properties?: Record<string, JsonSchema2020>;
|
|
411
|
+
required?: string[];
|
|
412
|
+
items?: JsonSchema2020;
|
|
413
|
+
additionalProperties?: boolean;
|
|
414
|
+
enum?: readonly (string | number)[];
|
|
415
|
+
const?: string | number | boolean | null;
|
|
416
|
+
oneOf?: readonly JsonSchema2020[];
|
|
417
|
+
anyOf?: readonly JsonSchema2020[];
|
|
418
|
+
minimum?: number;
|
|
419
|
+
maximum?: number;
|
|
420
|
+
exclusiveMinimum?: number;
|
|
421
|
+
exclusiveMaximum?: number;
|
|
422
|
+
multipleOf?: number;
|
|
423
|
+
minLength?: number;
|
|
424
|
+
maxLength?: number;
|
|
425
|
+
minItems?: number;
|
|
426
|
+
maxItems?: number;
|
|
427
|
+
pattern?: string;
|
|
428
|
+
uniqueItems?: boolean;
|
|
429
|
+
title?: string;
|
|
430
|
+
description?: string;
|
|
431
|
+
default?: unknown;
|
|
432
|
+
deprecated?: boolean;
|
|
433
|
+
[key: `x-${string}`]: unknown;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* A JSON Schema definition (legacy subset used by Zod validator and types.ts).
|
|
341
438
|
*/
|
|
342
439
|
export declare interface JSONSchema7 {
|
|
343
440
|
$schema?: string;
|
|
@@ -388,8 +485,10 @@ export declare interface JSONSchema7 {
|
|
|
388
485
|
"x-formspec-schemaSource"?: string;
|
|
389
486
|
}
|
|
390
487
|
|
|
488
|
+
export declare const jsonSchema7Schema: z.ZodType<JSONSchema7>;
|
|
489
|
+
|
|
391
490
|
/**
|
|
392
|
-
* JSON Schema
|
|
491
|
+
* JSON Schema type definitions.
|
|
393
492
|
*
|
|
394
493
|
* These types are a subset of JSON Schema sufficient for form generation.
|
|
395
494
|
*/
|
|
@@ -398,44 +497,190 @@ export declare interface JSONSchema7 {
|
|
|
398
497
|
*/
|
|
399
498
|
export declare type JSONSchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
|
|
400
499
|
|
|
500
|
+
/**
|
|
501
|
+
* Zod schema for JSON Schema primitive type strings.
|
|
502
|
+
*/
|
|
503
|
+
export declare const jsonSchemaTypeSchema: z.ZodEnum<["string", "number", "integer", "boolean", "object", "array", "null"]>;
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* A Label element for displaying static text.
|
|
507
|
+
*/
|
|
508
|
+
export declare type LabelElement = z.infer<typeof labelElementSchema>;
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Zod schema for a Label element.
|
|
512
|
+
*/
|
|
513
|
+
export declare const labelElementSchema: z.ZodObject<{
|
|
514
|
+
type: z.ZodLiteral<"Label">;
|
|
515
|
+
text: z.ZodString;
|
|
516
|
+
rule: z.ZodOptional<z.ZodObject<{
|
|
517
|
+
effect: z.ZodEnum<["SHOW", "HIDE", "ENABLE", "DISABLE"]>;
|
|
518
|
+
condition: z.ZodObject<{
|
|
519
|
+
scope: z.ZodString;
|
|
520
|
+
schema: z.ZodType<RuleConditionSchema, z.ZodTypeDef, RuleConditionSchema>;
|
|
521
|
+
}, "strict", z.ZodTypeAny, {
|
|
522
|
+
schema: RuleConditionSchema;
|
|
523
|
+
scope: string;
|
|
524
|
+
}, {
|
|
525
|
+
schema: RuleConditionSchema;
|
|
526
|
+
scope: string;
|
|
527
|
+
}>;
|
|
528
|
+
}, "strict", z.ZodTypeAny, {
|
|
529
|
+
effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
|
|
530
|
+
condition: {
|
|
531
|
+
schema: RuleConditionSchema;
|
|
532
|
+
scope: string;
|
|
533
|
+
};
|
|
534
|
+
}, {
|
|
535
|
+
effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
|
|
536
|
+
condition: {
|
|
537
|
+
schema: RuleConditionSchema;
|
|
538
|
+
scope: string;
|
|
539
|
+
};
|
|
540
|
+
}>>;
|
|
541
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
542
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
543
|
+
type: z.ZodLiteral<"Label">;
|
|
544
|
+
text: z.ZodString;
|
|
545
|
+
rule: z.ZodOptional<z.ZodObject<{
|
|
546
|
+
effect: z.ZodEnum<["SHOW", "HIDE", "ENABLE", "DISABLE"]>;
|
|
547
|
+
condition: z.ZodObject<{
|
|
548
|
+
scope: z.ZodString;
|
|
549
|
+
schema: z.ZodType<RuleConditionSchema, z.ZodTypeDef, RuleConditionSchema>;
|
|
550
|
+
}, "strict", z.ZodTypeAny, {
|
|
551
|
+
schema: RuleConditionSchema;
|
|
552
|
+
scope: string;
|
|
553
|
+
}, {
|
|
554
|
+
schema: RuleConditionSchema;
|
|
555
|
+
scope: string;
|
|
556
|
+
}>;
|
|
557
|
+
}, "strict", z.ZodTypeAny, {
|
|
558
|
+
effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
|
|
559
|
+
condition: {
|
|
560
|
+
schema: RuleConditionSchema;
|
|
561
|
+
scope: string;
|
|
562
|
+
};
|
|
563
|
+
}, {
|
|
564
|
+
effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
|
|
565
|
+
condition: {
|
|
566
|
+
schema: RuleConditionSchema;
|
|
567
|
+
scope: string;
|
|
568
|
+
};
|
|
569
|
+
}>>;
|
|
570
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
571
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
572
|
+
type: z.ZodLiteral<"Label">;
|
|
573
|
+
text: z.ZodString;
|
|
574
|
+
rule: z.ZodOptional<z.ZodObject<{
|
|
575
|
+
effect: z.ZodEnum<["SHOW", "HIDE", "ENABLE", "DISABLE"]>;
|
|
576
|
+
condition: z.ZodObject<{
|
|
577
|
+
scope: z.ZodString;
|
|
578
|
+
schema: z.ZodType<RuleConditionSchema, z.ZodTypeDef, RuleConditionSchema>;
|
|
579
|
+
}, "strict", z.ZodTypeAny, {
|
|
580
|
+
schema: RuleConditionSchema;
|
|
581
|
+
scope: string;
|
|
582
|
+
}, {
|
|
583
|
+
schema: RuleConditionSchema;
|
|
584
|
+
scope: string;
|
|
585
|
+
}>;
|
|
586
|
+
}, "strict", z.ZodTypeAny, {
|
|
587
|
+
effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
|
|
588
|
+
condition: {
|
|
589
|
+
schema: RuleConditionSchema;
|
|
590
|
+
scope: string;
|
|
591
|
+
};
|
|
592
|
+
}, {
|
|
593
|
+
effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
|
|
594
|
+
condition: {
|
|
595
|
+
schema: RuleConditionSchema;
|
|
596
|
+
scope: string;
|
|
597
|
+
};
|
|
598
|
+
}>>;
|
|
599
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
600
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
601
|
+
|
|
401
602
|
/**
|
|
402
603
|
* Rule for conditional element visibility/enablement.
|
|
403
604
|
*/
|
|
404
|
-
export declare
|
|
405
|
-
effect: RuleEffect;
|
|
406
|
-
condition: SchemaBasedCondition;
|
|
407
|
-
}
|
|
605
|
+
export declare type Rule = z.infer<typeof ruleSchema>;
|
|
408
606
|
|
|
409
607
|
/**
|
|
410
|
-
* JSON Schema subset
|
|
608
|
+
* JSON Schema subset used in rule conditions.
|
|
411
609
|
*/
|
|
412
610
|
export declare interface RuleConditionSchema {
|
|
413
611
|
const?: unknown;
|
|
414
612
|
enum?: readonly unknown[];
|
|
415
613
|
type?: string;
|
|
614
|
+
not?: RuleConditionSchema;
|
|
416
615
|
minimum?: number;
|
|
417
616
|
maximum?: number;
|
|
617
|
+
exclusiveMinimum?: number;
|
|
618
|
+
exclusiveMaximum?: number;
|
|
619
|
+
minLength?: number;
|
|
418
620
|
properties?: Record<string, RuleConditionSchema>;
|
|
621
|
+
required?: string[];
|
|
419
622
|
allOf?: RuleConditionSchema[];
|
|
420
623
|
}
|
|
421
624
|
|
|
625
|
+
export declare const ruleConditionSchema: z.ZodType<RuleConditionSchema>;
|
|
626
|
+
|
|
422
627
|
/**
|
|
423
628
|
* Rule effect types for conditional visibility.
|
|
424
629
|
*/
|
|
425
|
-
export declare type RuleEffect =
|
|
630
|
+
export declare type RuleEffect = z.infer<typeof ruleEffectSchema>;
|
|
426
631
|
|
|
427
632
|
/**
|
|
428
|
-
*
|
|
633
|
+
* Zod schema for rule effect values.
|
|
429
634
|
*/
|
|
430
|
-
export declare
|
|
635
|
+
export declare const ruleEffectSchema: z.ZodEnum<["SHOW", "HIDE", "ENABLE", "DISABLE"]>;
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Zod schema for a UI Schema rule.
|
|
639
|
+
*/
|
|
640
|
+
export declare const ruleSchema: z.ZodObject<{
|
|
641
|
+
effect: z.ZodEnum<["SHOW", "HIDE", "ENABLE", "DISABLE"]>;
|
|
642
|
+
condition: z.ZodObject<{
|
|
643
|
+
scope: z.ZodString;
|
|
644
|
+
schema: z.ZodType<RuleConditionSchema, z.ZodTypeDef, RuleConditionSchema>;
|
|
645
|
+
}, "strict", z.ZodTypeAny, {
|
|
646
|
+
schema: RuleConditionSchema;
|
|
647
|
+
scope: string;
|
|
648
|
+
}, {
|
|
649
|
+
schema: RuleConditionSchema;
|
|
650
|
+
scope: string;
|
|
651
|
+
}>;
|
|
652
|
+
}, "strict", z.ZodTypeAny, {
|
|
653
|
+
effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
|
|
654
|
+
condition: {
|
|
655
|
+
schema: RuleConditionSchema;
|
|
656
|
+
scope: string;
|
|
657
|
+
};
|
|
658
|
+
}, {
|
|
659
|
+
effect: "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
|
|
660
|
+
condition: {
|
|
661
|
+
schema: RuleConditionSchema;
|
|
662
|
+
scope: string;
|
|
663
|
+
};
|
|
664
|
+
}>;
|
|
431
665
|
|
|
432
666
|
/**
|
|
433
667
|
* Condition for a rule.
|
|
434
668
|
*/
|
|
435
|
-
export declare
|
|
669
|
+
export declare type SchemaBasedCondition = z.infer<typeof schemaBasedConditionSchema>;
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Zod schema for a schema-based rule condition.
|
|
673
|
+
*/
|
|
674
|
+
export declare const schemaBasedConditionSchema: z.ZodObject<{
|
|
675
|
+
scope: z.ZodString;
|
|
676
|
+
schema: z.ZodType<RuleConditionSchema, z.ZodTypeDef, RuleConditionSchema>;
|
|
677
|
+
}, "strict", z.ZodTypeAny, {
|
|
678
|
+
schema: RuleConditionSchema;
|
|
436
679
|
scope: string;
|
|
680
|
+
}, {
|
|
437
681
|
schema: RuleConditionSchema;
|
|
438
|
-
|
|
682
|
+
scope: string;
|
|
683
|
+
}>;
|
|
439
684
|
|
|
440
685
|
/**
|
|
441
686
|
* Sets a FormSpec extension property on a JSON Schema node.
|
|
@@ -448,56 +693,25 @@ export declare interface SchemaBasedCondition {
|
|
|
448
693
|
* @param key - Extension key (must start with `x-formspec-`)
|
|
449
694
|
* @param value - Extension value
|
|
450
695
|
*/
|
|
451
|
-
export declare function setSchemaExtension(schema:
|
|
696
|
+
export declare function setSchemaExtension(schema: object, key: `x-formspec-${string}`, value: unknown): void;
|
|
452
697
|
|
|
453
698
|
/**
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
* Generates a TypeScript file that patches decorated classes with
|
|
457
|
-
* their extracted type metadata, enabling runtime schema generation
|
|
458
|
-
* as an alternative to a TypeScript transformer.
|
|
459
|
-
*
|
|
460
|
-
* Usage:
|
|
461
|
-
* formspec codegen ./src/forms.ts -o ./src/__formspec_types__.ts
|
|
462
|
-
*
|
|
463
|
-
* Then in your code:
|
|
464
|
-
* import './__formspec_types__'; // Patches all decorated classes
|
|
465
|
-
* import { UserFormSchema, getUserFormFormSpec } from './__formspec_types__';
|
|
466
|
-
* const spec = getUserFormFormSpec();
|
|
467
|
-
*/
|
|
468
|
-
/**
|
|
469
|
-
* Type metadata format used by `@formspec/decorators`.
|
|
470
|
-
*
|
|
471
|
-
* Represents the runtime type information for a field that TypeScript
|
|
472
|
-
* normally erases at compile time.
|
|
699
|
+
* Root UI Schema (always a layout — not a Control, Category, or Label).
|
|
473
700
|
*/
|
|
474
|
-
export declare
|
|
475
|
-
/** Base type: "string", "number", "boolean", "enum", "array", "object", "unknown" */
|
|
476
|
-
type: string;
|
|
477
|
-
/** For enum types, the possible literal values */
|
|
478
|
-
values?: unknown[];
|
|
479
|
-
/** For array types, metadata about the array element type */
|
|
480
|
-
itemType?: TypeMetadata;
|
|
481
|
-
/** For object types, metadata about each property */
|
|
482
|
-
properties?: Record<string, TypeMetadata>;
|
|
483
|
-
/** Whether the field accepts null */
|
|
484
|
-
nullable?: boolean;
|
|
485
|
-
/** Whether the field is optional (T | undefined or ?: modifier) */
|
|
486
|
-
optional?: boolean;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
/**
|
|
490
|
-
* Root UI Schema (always a layout).
|
|
491
|
-
*/
|
|
492
|
-
export declare type UISchema = VerticalLayout | HorizontalLayout | GroupLayout;
|
|
701
|
+
export declare type UISchema = VerticalLayout | HorizontalLayout | GroupLayout | Categorization;
|
|
493
702
|
|
|
494
703
|
/**
|
|
495
704
|
* Union of all UI Schema element types.
|
|
496
705
|
*/
|
|
497
|
-
export declare type UISchemaElement = ControlElement | VerticalLayout | HorizontalLayout | GroupLayout;
|
|
706
|
+
export declare type UISchemaElement = ControlElement | VerticalLayout | HorizontalLayout | GroupLayout | Categorization | Category | LabelElement;
|
|
498
707
|
|
|
499
708
|
/**
|
|
500
709
|
* Base interface for all UI Schema elements.
|
|
710
|
+
*
|
|
711
|
+
* This is a manually maintained interface representing the common shape
|
|
712
|
+
* shared by all element types. It is kept as an interface (rather than
|
|
713
|
+
* derived from Zod) because it is the base of a discriminated union, not
|
|
714
|
+
* a union member itself.
|
|
501
715
|
*/
|
|
502
716
|
export declare interface UISchemaElementBase {
|
|
503
717
|
type: UISchemaElementType;
|
|
@@ -505,25 +719,36 @@ export declare interface UISchemaElementBase {
|
|
|
505
719
|
options?: Record<string, unknown>;
|
|
506
720
|
}
|
|
507
721
|
|
|
722
|
+
export declare const uiSchemaElementSchema: z.ZodType<UISchemaElement>;
|
|
723
|
+
|
|
508
724
|
/**
|
|
509
|
-
*
|
|
510
|
-
*
|
|
511
|
-
* These types define the UI layout structure for JSON Forms.
|
|
512
|
-
* See: https://jsonforms.io/docs/uischema/
|
|
725
|
+
* UI Schema element types.
|
|
513
726
|
*/
|
|
727
|
+
export declare type UISchemaElementType = z.infer<typeof uiSchemaElementTypeSchema>;
|
|
728
|
+
|
|
514
729
|
/**
|
|
515
|
-
* UI Schema element
|
|
730
|
+
* Zod schema for UI Schema element type strings.
|
|
731
|
+
*/
|
|
732
|
+
export declare const uiSchemaElementTypeSchema: z.ZodEnum<["Control", "VerticalLayout", "HorizontalLayout", "Group", "Categorization", "Category", "Label"]>;
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Zod schema for the root UI Schema (layout types only).
|
|
516
736
|
*/
|
|
517
|
-
export declare
|
|
737
|
+
export declare const uiSchemaSchema: z.ZodType<UISchema>;
|
|
518
738
|
|
|
519
739
|
/**
|
|
520
740
|
* A vertical layout element.
|
|
521
741
|
*/
|
|
522
|
-
export declare interface VerticalLayout
|
|
742
|
+
export declare interface VerticalLayout {
|
|
523
743
|
type: "VerticalLayout";
|
|
524
744
|
elements: UISchemaElement[];
|
|
745
|
+
rule?: Rule | undefined;
|
|
746
|
+
options?: Record<string, unknown> | undefined;
|
|
747
|
+
[k: string]: unknown;
|
|
525
748
|
}
|
|
526
749
|
|
|
750
|
+
export declare const verticalLayoutSchema: z.ZodType<VerticalLayout>;
|
|
751
|
+
|
|
527
752
|
/**
|
|
528
753
|
* Builds and writes both JSON Schema and UI Schema files to disk.
|
|
529
754
|
*
|