@formspec/dsl 0.1.0-alpha.2 → 0.1.0-alpha.21
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 +61 -0
- package/dist/dsl.d.ts +665 -0
- package/dist/field.d.ts +15 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/index.cjs +446 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +411 -38
- package/dist/index.js.map +1 -1
- package/dist/inference.d.ts +122 -1
- package/dist/inference.d.ts.map +1 -1
- package/dist/predicate.d.ts +1 -0
- package/dist/predicate.d.ts.map +1 -1
- package/dist/structure.d.ts +10 -0
- package/dist/structure.d.ts.map +1 -1
- package/dist/validation.d.ts +10 -0
- package/dist/validation.d.ts.map +1 -1
- package/package.json +9 -6
- package/dist/__tests__/builders.test.js +0 -193
- package/dist/__tests__/builders.test.js.map +0 -1
- package/dist/__tests__/inference.test-d.js +0 -83
- package/dist/__tests__/inference.test-d.js.map +0 -1
- package/dist/__tests__/validation.test.js +0 -180
- package/dist/__tests__/validation.test.js.map +0 -1
- package/dist/field.js +0 -221
- package/dist/field.js.map +0 -1
- package/dist/inference.js +0 -8
- package/dist/inference.js.map +0 -1
- package/dist/predicate.js +0 -40
- package/dist/predicate.js.map +0 -1
- package/dist/structure.js +0 -129
- package/dist/structure.js.map +0 -1
- package/dist/validation.js +0 -186
- package/dist/validation.js.map +0 -1
package/dist/inference.d.ts
CHANGED
|
@@ -30,6 +30,8 @@ import type { TextField, NumberField, BooleanField, StaticEnumField, EnumOption,
|
|
|
30
30
|
* type T4 = InferFieldValue<ArrayField<"items", [TextField<"name">]>>; // { name: string }[]
|
|
31
31
|
* type T5 = InferFieldValue<ObjectField<"address", [TextField<"city">]>>; // { city: string }
|
|
32
32
|
* ```
|
|
33
|
+
*
|
|
34
|
+
* @public
|
|
33
35
|
*/
|
|
34
36
|
export type InferFieldValue<F> = F extends TextField<string> ? string : F extends NumberField<string> ? number : F extends BooleanField<string> ? boolean : F extends StaticEnumField<string, infer O extends readonly EnumOptionValue[]> ? O extends readonly EnumOption[] ? O[number]["id"] : O extends readonly string[] ? O[number] : never : F extends DynamicEnumField<string, infer Source> ? DataSourceValueType<Source> : F extends DynamicSchemaField<string> ? Record<string, unknown> : F extends ArrayField<string, infer Items extends readonly FormElement[]> ? InferSchema<Items>[] : F extends ObjectField<string, infer Properties extends readonly FormElement[]> ? InferSchema<Properties> : never;
|
|
35
37
|
/**
|
|
@@ -38,33 +40,140 @@ export type InferFieldValue<F> = F extends TextField<string> ? string : F extend
|
|
|
38
40
|
* - Field elements return themselves
|
|
39
41
|
* - Groups extract fields from all child elements
|
|
40
42
|
* - Conditionals extract fields from all child elements
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
41
45
|
*/
|
|
42
46
|
export type ExtractFields<E> = E extends AnyField ? E : E extends Group<infer Elements> ? ExtractFieldsFromArray<Elements> : E extends Conditional<string, unknown, infer Elements> ? ExtractFieldsFromArray<Elements> : never;
|
|
43
47
|
/**
|
|
44
48
|
* Extracts fields from an array of elements.
|
|
45
49
|
*
|
|
46
50
|
* Recursively processes each element and unions the results.
|
|
51
|
+
*
|
|
52
|
+
* @public
|
|
47
53
|
*/
|
|
48
54
|
export type ExtractFieldsFromArray<Elements> = Elements extends readonly [
|
|
49
55
|
infer First,
|
|
50
56
|
...infer Rest
|
|
51
57
|
] ? ExtractFields<First> | ExtractFieldsFromArray<Rest> : never;
|
|
58
|
+
/**
|
|
59
|
+
* Extracts fields that are NOT inside conditionals.
|
|
60
|
+
* These fields are always visible and should be required in the inferred schema.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* // Given a form with conditional and non-conditional fields:
|
|
65
|
+
* const form = formspec(
|
|
66
|
+
* field.text("name"), // non-conditional
|
|
67
|
+
* field.number("age"), // non-conditional
|
|
68
|
+
* when(is("type", "business"),
|
|
69
|
+
* field.text("company"), // conditional (skipped)
|
|
70
|
+
* ),
|
|
71
|
+
* );
|
|
72
|
+
*
|
|
73
|
+
* // ExtractNonConditionalFields extracts: TextField<"name"> | NumberField<"age">
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
export type ExtractNonConditionalFields<E> = E extends AnyField ? E : E extends Group<infer Elements> ? ExtractNonConditionalFieldsFromArray<Elements> : E extends Conditional<string, unknown, infer _Elements> ? never : never;
|
|
79
|
+
/**
|
|
80
|
+
* Extracts non-conditional fields from an array of elements.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* type Elements = readonly [TextField<"name">, NumberField<"age">];
|
|
85
|
+
* type Fields = ExtractNonConditionalFieldsFromArray<Elements>;
|
|
86
|
+
* // TextField<"name"> | NumberField<"age">
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @public
|
|
90
|
+
*/
|
|
91
|
+
export type ExtractNonConditionalFieldsFromArray<Elements> = Elements extends readonly [
|
|
92
|
+
infer First,
|
|
93
|
+
...infer Rest
|
|
94
|
+
] ? ExtractNonConditionalFields<First> | ExtractNonConditionalFieldsFromArray<Rest> : never;
|
|
95
|
+
/**
|
|
96
|
+
* Extracts fields that ARE inside conditionals.
|
|
97
|
+
* These fields may or may not be visible and should be optional in the inferred schema.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* // Given a form with conditional fields:
|
|
102
|
+
* const form = formspec(
|
|
103
|
+
* field.text("name"), // non-conditional (skipped)
|
|
104
|
+
* when(is("type", "business"),
|
|
105
|
+
* field.text("company"), // conditional (extracted)
|
|
106
|
+
* field.text("taxId"), // conditional (extracted)
|
|
107
|
+
* ),
|
|
108
|
+
* );
|
|
109
|
+
*
|
|
110
|
+
* // ExtractConditionalFields extracts: TextField<"company"> | TextField<"taxId">
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* @public
|
|
114
|
+
*/
|
|
115
|
+
export type ExtractConditionalFields<E> = E extends AnyField ? never : E extends Group<infer Elements> ? ExtractConditionalFieldsFromArray<Elements> : E extends Conditional<string, unknown, infer Elements> ? ExtractFieldsFromArray<Elements> : never;
|
|
116
|
+
/**
|
|
117
|
+
* Extracts conditional fields from an array of elements.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* type Elements = readonly [
|
|
122
|
+
* TextField<"name">,
|
|
123
|
+
* Conditional<"type", "business", readonly [TextField<"company">]>
|
|
124
|
+
* ];
|
|
125
|
+
* type Fields = ExtractConditionalFieldsFromArray<Elements>;
|
|
126
|
+
* // TextField<"company">
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* @public
|
|
130
|
+
*/
|
|
131
|
+
export type ExtractConditionalFieldsFromArray<Elements> = Elements extends readonly [
|
|
132
|
+
infer First,
|
|
133
|
+
...infer Rest
|
|
134
|
+
] ? ExtractConditionalFields<First> | ExtractConditionalFieldsFromArray<Rest> : never;
|
|
52
135
|
/**
|
|
53
136
|
* Builds a schema type from extracted fields.
|
|
54
137
|
*
|
|
55
138
|
* Maps field names to their inferred value types.
|
|
139
|
+
*
|
|
140
|
+
* @public
|
|
56
141
|
*/
|
|
57
142
|
export type BuildSchema<Fields> = {
|
|
58
143
|
[F in Fields as F extends {
|
|
59
144
|
name: infer N extends string;
|
|
60
145
|
} ? N : never]: F extends AnyField ? InferFieldValue<F> : never;
|
|
61
146
|
};
|
|
147
|
+
/**
|
|
148
|
+
* Utility type that flattens intersection types into a single object type.
|
|
149
|
+
*
|
|
150
|
+
* This improves TypeScript's display of inferred types and ensures
|
|
151
|
+
* structural equality checks work correctly.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* // Without FlattenIntersection:
|
|
156
|
+
* type Messy = { a: string } & { b: number };
|
|
157
|
+
* // Displays as: { a: string } & { b: number }
|
|
158
|
+
*
|
|
159
|
+
* // With FlattenIntersection:
|
|
160
|
+
* type Clean = FlattenIntersection<{ a: string } & { b: number }>;
|
|
161
|
+
* // Displays as: { a: string; b: number }
|
|
162
|
+
* ```
|
|
163
|
+
*
|
|
164
|
+
* @public
|
|
165
|
+
*/
|
|
166
|
+
export type FlattenIntersection<T> = {
|
|
167
|
+
[K in keyof T]: T[K];
|
|
168
|
+
} & {};
|
|
62
169
|
/**
|
|
63
170
|
* Infers the complete schema type from a form's elements.
|
|
64
171
|
*
|
|
65
172
|
* This is the main inference type that converts a form structure
|
|
66
173
|
* into its corresponding TypeScript schema type.
|
|
67
174
|
*
|
|
175
|
+
* Non-conditional fields are required, conditional fields are optional.
|
|
176
|
+
*
|
|
68
177
|
* @example
|
|
69
178
|
* ```typescript
|
|
70
179
|
* const form = formspec(
|
|
@@ -75,9 +184,19 @@ export type BuildSchema<Fields> = {
|
|
|
75
184
|
*
|
|
76
185
|
* type Schema = InferSchema<typeof form.elements>;
|
|
77
186
|
* // { name: string; age: number; status: "active" | "inactive" }
|
|
187
|
+
*
|
|
188
|
+
* // Conditional fields become optional:
|
|
189
|
+
* const formWithConditional = formspec(
|
|
190
|
+
* field.enum("type", ["a", "b"] as const),
|
|
191
|
+
* when(is("type", "a"), field.text("aField")),
|
|
192
|
+
* );
|
|
193
|
+
* type ConditionalSchema = InferSchema<typeof formWithConditional.elements>;
|
|
194
|
+
* // { type: "a" | "b"; aField?: string }
|
|
78
195
|
* ```
|
|
196
|
+
*
|
|
197
|
+
* @public
|
|
79
198
|
*/
|
|
80
|
-
export type InferSchema<Elements extends readonly FormElement[]> = BuildSchema<
|
|
199
|
+
export type InferSchema<Elements extends readonly FormElement[]> = FlattenIntersection<BuildSchema<ExtractNonConditionalFieldsFromArray<Elements>> & Partial<BuildSchema<ExtractConditionalFieldsFromArray<Elements>>>>;
|
|
81
200
|
/**
|
|
82
201
|
* Infers the schema type from a FormSpec.
|
|
83
202
|
*
|
|
@@ -88,6 +207,8 @@ export type InferSchema<Elements extends readonly FormElement[]> = BuildSchema<E
|
|
|
88
207
|
* const form = formspec(...);
|
|
89
208
|
* type Schema = InferFormSchema<typeof form>;
|
|
90
209
|
* ```
|
|
210
|
+
*
|
|
211
|
+
* @public
|
|
91
212
|
*/
|
|
92
213
|
export type InferFormSchema<F extends FormSpec<readonly FormElement[]>> = F extends FormSpec<infer Elements> ? InferSchema<Elements> : never;
|
|
93
214
|
//# sourceMappingURL=inference.d.ts.map
|
package/dist/inference.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../src/inference.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,eAAe,EACf,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,QAAQ,EACR,KAAK,EACL,WAAW,EACX,WAAW,EACX,QAAQ,EACR,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAExB
|
|
1
|
+
{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../src/inference.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,eAAe,EACf,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,QAAQ,EACR,KAAK,EACL,WAAW,EACX,WAAW,EACX,QAAQ,EACR,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAC3B,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,GACvB,MAAM,GACN,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,GAC3B,MAAM,GACN,CAAC,SAAS,YAAY,CAAC,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S,QAAQ,GACvF,eAAe,CAAC,CAAC,CAAC,GAClB,KAAK;CACV,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI;KAClC,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACrB,GAAG,EAAE,CAAC;AAEP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,MAAM,WAAW,CAAC,QAAQ,SAAS,SAAS,WAAW,EAAE,IAAI,mBAAmB,CACpF,WAAW,CAAC,oCAAoC,CAAC,QAAQ,CAAC,CAAC,GACzD,OAAO,CAAC,WAAW,CAAC,iCAAiC,CAAC,QAAQ,CAAC,CAAC,CAAC,CACpE,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,QAAQ,CAAC,SAAS,WAAW,EAAE,CAAC,IACpE,CAAC,SAAS,QAAQ,CAAC,MAAM,QAAQ,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC"}
|
package/dist/predicate.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ import type { EqualsPredicate } from "@formspec/core";
|
|
|
30
30
|
* @param field - The name of the field to check
|
|
31
31
|
* @param value - The value the field must equal
|
|
32
32
|
* @returns An EqualsPredicate for use with `when()`
|
|
33
|
+
* @public
|
|
33
34
|
*/
|
|
34
35
|
export declare function is<const K extends string, const V>(field: K, value: V): EqualsPredicate<K, V>;
|
|
35
36
|
//# sourceMappingURL=predicate.d.ts.map
|
package/dist/predicate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.d.ts","sourceRoot":"","sources":["../src/predicate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD
|
|
1
|
+
{"version":3,"file":"predicate.d.ts","sourceRoot":"","sources":["../src/predicate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,EAAE,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAM7F"}
|
package/dist/structure.d.ts
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
import type { FormElement, Group, Conditional, FormSpec, Predicate } from "@formspec/core";
|
|
10
10
|
/**
|
|
11
11
|
* Options for creating a form specification.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
12
14
|
*/
|
|
13
15
|
export interface FormSpecOptions {
|
|
14
16
|
/**
|
|
@@ -42,6 +44,8 @@ export interface FormSpecOptions {
|
|
|
42
44
|
* @param label - The group's display label
|
|
43
45
|
* @param elements - The form elements contained in this group
|
|
44
46
|
* @returns A Group descriptor
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
45
49
|
*/
|
|
46
50
|
export declare function group<const Elements extends readonly FormElement[]>(label: string, ...elements: Elements): Group<Elements>;
|
|
47
51
|
/**
|
|
@@ -63,6 +67,8 @@ export declare function group<const Elements extends readonly FormElement[]>(lab
|
|
|
63
67
|
* @param predicate - The condition to evaluate (use `is()` to create)
|
|
64
68
|
* @param elements - The form elements to show when condition is met
|
|
65
69
|
* @returns A Conditional descriptor
|
|
70
|
+
*
|
|
71
|
+
* @public
|
|
66
72
|
*/
|
|
67
73
|
export declare function when<const K extends string, const V, const Elements extends readonly FormElement[]>(predicate: Predicate<K, V>, ...elements: Elements): Conditional<K, V, Elements>;
|
|
68
74
|
/**
|
|
@@ -95,6 +101,8 @@ export declare function when<const K extends string, const V, const Elements ext
|
|
|
95
101
|
*
|
|
96
102
|
* @param elements - The top-level form elements
|
|
97
103
|
* @returns A FormSpec descriptor
|
|
104
|
+
*
|
|
105
|
+
* @public
|
|
98
106
|
*/
|
|
99
107
|
export declare function formspec<const Elements extends readonly FormElement[]>(...elements: Elements): FormSpec<Elements>;
|
|
100
108
|
/**
|
|
@@ -115,6 +123,8 @@ export declare function formspec<const Elements extends readonly FormElement[]>(
|
|
|
115
123
|
* @param options - Validation options
|
|
116
124
|
* @param elements - The top-level form elements
|
|
117
125
|
* @returns A FormSpec descriptor
|
|
126
|
+
*
|
|
127
|
+
* @public
|
|
118
128
|
*/
|
|
119
129
|
export declare function formspecWithValidation<const Elements extends readonly FormElement[]>(options: FormSpecOptions, ...elements: Elements): FormSpec<Elements>;
|
|
120
130
|
//# sourceMappingURL=structure.d.ts.map
|
package/dist/structure.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structure.d.ts","sourceRoot":"","sources":["../src/structure.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3F
|
|
1
|
+
{"version":3,"file":"structure.d.ts","sourceRoot":"","sources":["../src/structure.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3F;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;IAEtC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,KAAK,CAAC,KAAK,CAAC,QAAQ,SAAS,SAAS,WAAW,EAAE,EACjE,KAAK,EAAE,MAAM,EACb,GAAG,QAAQ,EAAE,QAAQ,GACpB,KAAK,CAAC,QAAQ,CAAC,CAEjB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,IAAI,CAClB,KAAK,CAAC,CAAC,SAAS,MAAM,EACtB,KAAK,CAAC,CAAC,EACP,KAAK,CAAC,QAAQ,SAAS,SAAS,WAAW,EAAE,EAC7C,SAAS,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,QAAQ,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAOhF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,QAAQ,CAAC,KAAK,CAAC,QAAQ,SAAS,SAAS,WAAW,EAAE,EACpE,GAAG,QAAQ,EAAE,QAAQ,GACpB,QAAQ,CAAC,QAAQ,CAAC,CAEpB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,CAAC,QAAQ,SAAS,SAAS,WAAW,EAAE,EAClF,OAAO,EAAE,eAAe,EACxB,GAAG,QAAQ,EAAE,QAAQ,GACpB,QAAQ,CAAC,QAAQ,CAAC,CAmBpB"}
|
package/dist/validation.d.ts
CHANGED
|
@@ -8,10 +8,14 @@
|
|
|
8
8
|
import type { FormElement } from "@formspec/core";
|
|
9
9
|
/**
|
|
10
10
|
* Validation issue severity levels.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
11
13
|
*/
|
|
12
14
|
export type ValidationSeverity = "error" | "warning";
|
|
13
15
|
/**
|
|
14
16
|
* A validation issue found in a form specification.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
15
19
|
*/
|
|
16
20
|
export interface ValidationIssue {
|
|
17
21
|
/** Severity of the issue */
|
|
@@ -23,6 +27,8 @@ export interface ValidationIssue {
|
|
|
23
27
|
}
|
|
24
28
|
/**
|
|
25
29
|
* Result of validating a form specification.
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
26
32
|
*/
|
|
27
33
|
export interface ValidationResult {
|
|
28
34
|
/** Whether the form is valid (no errors, warnings are ok) */
|
|
@@ -54,6 +60,8 @@ export interface ValidationResult {
|
|
|
54
60
|
*
|
|
55
61
|
* @param elements - The form elements to validate
|
|
56
62
|
* @returns Validation result with any issues found
|
|
63
|
+
*
|
|
64
|
+
* @public
|
|
57
65
|
*/
|
|
58
66
|
export declare function validateForm(elements: readonly FormElement[]): ValidationResult;
|
|
59
67
|
/**
|
|
@@ -61,6 +69,8 @@ export declare function validateForm(elements: readonly FormElement[]): Validati
|
|
|
61
69
|
*
|
|
62
70
|
* @param result - The validation result to log
|
|
63
71
|
* @param formName - Optional name for the form (for better error messages)
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
64
74
|
*/
|
|
65
75
|
export declare function logValidationIssues(result: ValidationResult, formName?: string): void;
|
|
66
76
|
//# sourceMappingURL=validation.d.ts.map
|
package/dist/validation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAA+C,MAAM,gBAAgB,CAAC;AAE/F;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,SAAS,CAAC;AAErD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,4BAA4B;IAC5B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,6DAA6D;IAC7D,KAAK,EAAE,OAAO,CAAC;IACf,sCAAsC;IACtC,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAyHD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,GAAG,gBAAgB,CAmC/E;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAiBrF"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formspec/dsl",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.21",
|
|
4
4
|
"description": "DSL functions for defining FormSpec forms",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/index.
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
7
8
|
"types": "./dist/dsl.d.ts",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
11
|
"types": "./dist/dsl.d.ts",
|
|
11
|
-
"import": "./dist/index.js"
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
12
14
|
}
|
|
13
15
|
},
|
|
14
16
|
"files": [
|
|
15
|
-
"dist"
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
16
19
|
],
|
|
17
20
|
"dependencies": {
|
|
18
|
-
"@formspec/core": "0.1.0-alpha.
|
|
21
|
+
"@formspec/core": "0.1.0-alpha.21"
|
|
19
22
|
},
|
|
20
23
|
"devDependencies": {
|
|
21
24
|
"tsd": "^0.31.0",
|
|
@@ -30,7 +33,7 @@
|
|
|
30
33
|
"keywords": [],
|
|
31
34
|
"license": "UNLICENSED",
|
|
32
35
|
"scripts": {
|
|
33
|
-
"build": "tsc",
|
|
36
|
+
"build": "tsup && tsc --emitDeclarationOnly && api-extractor run --local",
|
|
34
37
|
"clean": "rm -rf dist temp",
|
|
35
38
|
"typecheck": "tsc --noEmit",
|
|
36
39
|
"test": "vitest run",
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { field, group, when, is, formspec } from "../index.js";
|
|
3
|
-
describe("field builders", () => {
|
|
4
|
-
describe("field.text", () => {
|
|
5
|
-
it("should create a text field with required properties", () => {
|
|
6
|
-
const f = field.text("name");
|
|
7
|
-
expect(f._type).toBe("field");
|
|
8
|
-
expect(f._field).toBe("text");
|
|
9
|
-
expect(f.name).toBe("name");
|
|
10
|
-
});
|
|
11
|
-
it("should include optional config properties", () => {
|
|
12
|
-
const f = field.text("name", {
|
|
13
|
-
label: "Full Name",
|
|
14
|
-
placeholder: "Enter your name",
|
|
15
|
-
required: true,
|
|
16
|
-
});
|
|
17
|
-
expect(f.label).toBe("Full Name");
|
|
18
|
-
expect(f.placeholder).toBe("Enter your name");
|
|
19
|
-
expect(f.required).toBe(true);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
describe("field.number", () => {
|
|
23
|
-
it("should create a number field with required properties", () => {
|
|
24
|
-
const f = field.number("age");
|
|
25
|
-
expect(f._type).toBe("field");
|
|
26
|
-
expect(f._field).toBe("number");
|
|
27
|
-
expect(f.name).toBe("age");
|
|
28
|
-
});
|
|
29
|
-
it("should include min/max constraints", () => {
|
|
30
|
-
const f = field.number("age", { min: 0, max: 150 });
|
|
31
|
-
expect(f.min).toBe(0);
|
|
32
|
-
expect(f.max).toBe(150);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
describe("field.boolean", () => {
|
|
36
|
-
it("should create a boolean field", () => {
|
|
37
|
-
const f = field.boolean("active");
|
|
38
|
-
expect(f._type).toBe("field");
|
|
39
|
-
expect(f._field).toBe("boolean");
|
|
40
|
-
expect(f.name).toBe("active");
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
describe("field.enum", () => {
|
|
44
|
-
it("should create an enum field with options", () => {
|
|
45
|
-
const f = field.enum("status", ["draft", "sent", "paid"]);
|
|
46
|
-
expect(f._type).toBe("field");
|
|
47
|
-
expect(f._field).toBe("enum");
|
|
48
|
-
expect(f.name).toBe("status");
|
|
49
|
-
expect(f.options).toEqual(["draft", "sent", "paid"]);
|
|
50
|
-
});
|
|
51
|
-
it("should include optional config", () => {
|
|
52
|
-
const f = field.enum("status", ["draft", "sent"], {
|
|
53
|
-
label: "Status",
|
|
54
|
-
required: true,
|
|
55
|
-
});
|
|
56
|
-
expect(f.label).toBe("Status");
|
|
57
|
-
expect(f.required).toBe(true);
|
|
58
|
-
});
|
|
59
|
-
it("should create an enum field with object options", () => {
|
|
60
|
-
const f = field.enum("priority", [
|
|
61
|
-
{ id: "low", label: "Low Priority" },
|
|
62
|
-
{ id: "medium", label: "Medium Priority" },
|
|
63
|
-
{ id: "high", label: "High Priority" },
|
|
64
|
-
]);
|
|
65
|
-
expect(f._type).toBe("field");
|
|
66
|
-
expect(f._field).toBe("enum");
|
|
67
|
-
expect(f.name).toBe("priority");
|
|
68
|
-
expect(f.options).toEqual([
|
|
69
|
-
{ id: "low", label: "Low Priority" },
|
|
70
|
-
{ id: "medium", label: "Medium Priority" },
|
|
71
|
-
{ id: "high", label: "High Priority" },
|
|
72
|
-
]);
|
|
73
|
-
});
|
|
74
|
-
it("should include optional config with object options", () => {
|
|
75
|
-
const f = field.enum("priority", [
|
|
76
|
-
{ id: "low", label: "Low" },
|
|
77
|
-
{ id: "high", label: "High" },
|
|
78
|
-
], {
|
|
79
|
-
label: "Priority",
|
|
80
|
-
required: true,
|
|
81
|
-
});
|
|
82
|
-
expect(f.label).toBe("Priority");
|
|
83
|
-
expect(f.required).toBe(true);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
describe("field.dynamicEnum", () => {
|
|
87
|
-
it("should create a dynamic enum field with source", () => {
|
|
88
|
-
const f = field.dynamicEnum("country", "countries");
|
|
89
|
-
expect(f._type).toBe("field");
|
|
90
|
-
expect(f._field).toBe("dynamic_enum");
|
|
91
|
-
expect(f.name).toBe("country");
|
|
92
|
-
expect(f.source).toBe("countries");
|
|
93
|
-
});
|
|
94
|
-
it("should include params for dependent lookups", () => {
|
|
95
|
-
const f = field.dynamicEnum("city", "cities", {
|
|
96
|
-
params: ["country"],
|
|
97
|
-
});
|
|
98
|
-
expect(f.params).toEqual(["country"]);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
describe("field.dynamicSchema", () => {
|
|
102
|
-
it("should create a dynamic schema field", () => {
|
|
103
|
-
const f = field.dynamicSchema("extension", "payment-extension");
|
|
104
|
-
expect(f._type).toBe("field");
|
|
105
|
-
expect(f._field).toBe("dynamic_schema");
|
|
106
|
-
expect(f.name).toBe("extension");
|
|
107
|
-
expect(f.schemaSource).toBe("payment-extension");
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
describe("field.array", () => {
|
|
111
|
-
it("should create an array field with item schema", () => {
|
|
112
|
-
const f = field.array("addresses", field.text("street"), field.text("city"));
|
|
113
|
-
expect(f._type).toBe("field");
|
|
114
|
-
expect(f._field).toBe("array");
|
|
115
|
-
expect(f.name).toBe("addresses");
|
|
116
|
-
expect(f.items).toHaveLength(2);
|
|
117
|
-
expect(f.items[0]._field).toBe("text");
|
|
118
|
-
expect(f.items[1]._field).toBe("text");
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
describe("field.arrayWithConfig", () => {
|
|
122
|
-
it("should create an array field with config", () => {
|
|
123
|
-
const f = field.arrayWithConfig("items", { label: "Line Items", minItems: 1, maxItems: 10 }, field.text("description"));
|
|
124
|
-
expect(f.label).toBe("Line Items");
|
|
125
|
-
expect(f.minItems).toBe(1);
|
|
126
|
-
expect(f.maxItems).toBe(10);
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
describe("field.object", () => {
|
|
130
|
-
it("should create an object field with properties", () => {
|
|
131
|
-
const f = field.object("address", field.text("street"), field.text("city"), field.text("zip"));
|
|
132
|
-
expect(f._type).toBe("field");
|
|
133
|
-
expect(f._field).toBe("object");
|
|
134
|
-
expect(f.name).toBe("address");
|
|
135
|
-
expect(f.properties).toHaveLength(3);
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
describe("field.objectWithConfig", () => {
|
|
139
|
-
it("should create an object field with config", () => {
|
|
140
|
-
const f = field.objectWithConfig("billing", { label: "Billing Address", required: true }, field.text("street"));
|
|
141
|
-
expect(f.label).toBe("Billing Address");
|
|
142
|
-
expect(f.required).toBe(true);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
describe("structure builders", () => {
|
|
147
|
-
describe("group", () => {
|
|
148
|
-
it("should create a group with label and elements", () => {
|
|
149
|
-
const g = group("Customer Info", field.text("name"), field.text("email"));
|
|
150
|
-
expect(g._type).toBe("group");
|
|
151
|
-
expect(g.label).toBe("Customer Info");
|
|
152
|
-
expect(g.elements).toHaveLength(2);
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
describe("when", () => {
|
|
156
|
-
it("should create a conditional with predicate and elements", () => {
|
|
157
|
-
const c = when(is("country", "US"), field.text("state"));
|
|
158
|
-
expect(c._type).toBe("conditional");
|
|
159
|
-
expect(c.field).toBe("country");
|
|
160
|
-
expect(c.value).toBe("US");
|
|
161
|
-
expect(c.elements).toHaveLength(1);
|
|
162
|
-
});
|
|
163
|
-
it("should support non-string values", () => {
|
|
164
|
-
const c = when(is("active", true), field.text("notes"));
|
|
165
|
-
expect(c.value).toBe(true);
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
describe("formspec", () => {
|
|
169
|
-
it("should create a form spec with elements", () => {
|
|
170
|
-
const f = formspec(field.text("name"), field.number("age"));
|
|
171
|
-
expect(f.elements).toHaveLength(2);
|
|
172
|
-
});
|
|
173
|
-
it("should support nested structures", () => {
|
|
174
|
-
const f = formspec(group("Basic", field.text("name")), when(is("type", "business"), field.text("company")));
|
|
175
|
-
expect(f.elements).toHaveLength(2);
|
|
176
|
-
expect(f.elements[0]._type).toBe("group");
|
|
177
|
-
expect(f.elements[1]._type).toBe("conditional");
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
describe("complex compositions", () => {
|
|
182
|
-
it("should support deeply nested structures", () => {
|
|
183
|
-
const form = formspec(group("Customer", field.text("name", { required: true }), field.object("address", field.text("street"), field.text("city"))), when(is("type", "business"), group("Business Info", field.text("company"), field.array("contacts", field.text("name"), field.text("email")))));
|
|
184
|
-
expect(form.elements).toHaveLength(2);
|
|
185
|
-
const customerGroup = form.elements[0];
|
|
186
|
-
expect(customerGroup._type).toBe("group");
|
|
187
|
-
if (customerGroup._type === "group") {
|
|
188
|
-
expect(customerGroup.elements).toHaveLength(2);
|
|
189
|
-
expect(customerGroup.elements[1]._type).toBe("field");
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
//# sourceMappingURL=builders.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"builders.test.js","sourceRoot":"","sources":["../../src/__tests__/builders.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE/D,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,EAAE,CAAC,qDAAqD,EAAE,GAAG,EAAE;YAC7D,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAE7B,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC9B,MAAM,CAAC,CAAC,CAAC,MAAM,CA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CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAEtC,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACvC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1C,IAAI,aAAa,CAAC,KAAK,KAAK,OAAO,EAAE,CAAC;YACpC,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC/C,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type-level tests for inference utilities.
|
|
3
|
-
*
|
|
4
|
-
* These tests verify that the type inference works correctly at compile time.
|
|
5
|
-
* Run with: pnpm dlx tsd
|
|
6
|
-
*/
|
|
7
|
-
import { expectType, expectNotType } from "tsd";
|
|
8
|
-
import { field, group, when, is, formspec } from "../index.js";
|
|
9
|
-
// =============================================================================
|
|
10
|
-
// InferFieldValue tests
|
|
11
|
-
// =============================================================================
|
|
12
|
-
// TextField should infer to string
|
|
13
|
-
expectType({});
|
|
14
|
-
// NumberField should infer to number
|
|
15
|
-
expectType({});
|
|
16
|
-
// BooleanField should infer to boolean
|
|
17
|
-
expectType({});
|
|
18
|
-
// StaticEnumField should infer to union of options
|
|
19
|
-
expectType({});
|
|
20
|
-
expectType({});
|
|
21
|
-
expectType({});
|
|
22
|
-
expectType({});
|
|
23
|
-
// =============================================================================
|
|
24
|
-
// InferSchema tests - Basic fields
|
|
25
|
-
// =============================================================================
|
|
26
|
-
// Test single text field
|
|
27
|
-
const singleTextField = formspec(field.text("name"));
|
|
28
|
-
expectType({});
|
|
29
|
-
// Test multiple basic fields
|
|
30
|
-
const multipleFields = formspec(field.text("name"), field.number("age"), field.boolean("active"));
|
|
31
|
-
expectType({});
|
|
32
|
-
// =============================================================================
|
|
33
|
-
// InferSchema tests - Enum fields
|
|
34
|
-
// =============================================================================
|
|
35
|
-
// Test static enum field
|
|
36
|
-
const enumForm = formspec(field.enum("status", ["draft", "sent", "paid"]));
|
|
37
|
-
expectType({});
|
|
38
|
-
// Test static enum field with object options
|
|
39
|
-
const objectEnumForm = formspec(field.enum("priority", [
|
|
40
|
-
{ id: "low", label: "Low Priority" },
|
|
41
|
-
{ id: "high", label: "High Priority" },
|
|
42
|
-
]));
|
|
43
|
-
expectType({});
|
|
44
|
-
// =============================================================================
|
|
45
|
-
// InferSchema tests - Groups
|
|
46
|
-
// =============================================================================
|
|
47
|
-
// Test fields inside groups
|
|
48
|
-
const groupForm = formspec(group("Customer", field.text("name"), field.text("email")), field.number("amount"));
|
|
49
|
-
expectType({});
|
|
50
|
-
// =============================================================================
|
|
51
|
-
// InferSchema tests - Conditionals
|
|
52
|
-
// =============================================================================
|
|
53
|
-
// Test fields inside conditionals
|
|
54
|
-
const conditionalForm = formspec(field.enum("type", ["personal", "business"]), when(is("type", "business"), field.text("company")));
|
|
55
|
-
expectType({});
|
|
56
|
-
// =============================================================================
|
|
57
|
-
// InferSchema tests - Array fields
|
|
58
|
-
// =============================================================================
|
|
59
|
-
// Test array fields
|
|
60
|
-
const arrayForm = formspec(field.array("addresses", field.text("street"), field.text("city")));
|
|
61
|
-
expectType({});
|
|
62
|
-
// =============================================================================
|
|
63
|
-
// InferSchema tests - Object fields
|
|
64
|
-
// =============================================================================
|
|
65
|
-
// Test object fields
|
|
66
|
-
const objectForm = formspec(field.object("address", field.text("street"), field.text("city"), field.text("zip")));
|
|
67
|
-
expectType({});
|
|
68
|
-
// =============================================================================
|
|
69
|
-
// InferFormSchema tests
|
|
70
|
-
// =============================================================================
|
|
71
|
-
// Test InferFormSchema convenience type
|
|
72
|
-
const complexForm = formspec(field.text("name"), field.number("amount"), field.enum("status", ["active", "inactive"]));
|
|
73
|
-
expectType({});
|
|
74
|
-
// =============================================================================
|
|
75
|
-
// Negative tests - types should NOT match
|
|
76
|
-
// =============================================================================
|
|
77
|
-
// TextField should NOT infer to number
|
|
78
|
-
expectNotType({});
|
|
79
|
-
// NumberField should NOT infer to string
|
|
80
|
-
expectNotType({});
|
|
81
|
-
// Enum should NOT allow invalid values
|
|
82
|
-
expectNotType({});
|
|
83
|
-
//# sourceMappingURL=inference.test-d.js.map
|