@automate.ax/catalog 0.153.2 → 0.154.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalog.d.ts +4 -4
- package/dist/catalog.js +2 -2
- package/dist/form-fields.d.ts +434 -0
- package/dist/form-fields.js +341 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/triggers/core-dashboard.d.ts +20 -345
- package/dist/triggers/core-dashboard.js +3 -240
- package/dist/triggers/core.d.ts +1 -1
- package/dist/triggers/core.js +1 -1
- package/dist/triggers/index.d.ts +1 -1
- package/dist/triggers/index.js +1 -1
- package/package.json +1 -1
- package/src/catalog.ts +3 -2
- package/src/form-fields.ts +513 -0
- package/src/index.ts +13 -5
- package/src/triggers/core-dashboard.ts +4 -395
- package/src/triggers/core.ts +0 -5
- package/src/triggers/index.ts +0 -5
package/dist/catalog.d.ts
CHANGED
|
@@ -230,14 +230,14 @@ export declare const cloudflareService: {
|
|
|
230
230
|
readonly input: "password";
|
|
231
231
|
readonly label: "API token";
|
|
232
232
|
readonly name: "apiKey";
|
|
233
|
-
readonly placeholder: "
|
|
233
|
+
readonly placeholder: "Token with Account Settings Read";
|
|
234
234
|
readonly required: true;
|
|
235
235
|
}];
|
|
236
236
|
readonly id: "api-token";
|
|
237
237
|
readonly name: "API token";
|
|
238
238
|
readonly type: "form";
|
|
239
239
|
}];
|
|
240
|
-
readonly description: "Connect
|
|
240
|
+
readonly description: "Connect with OAuth or an API token that includes Account Settings Read.";
|
|
241
241
|
readonly id: "cloudflare";
|
|
242
242
|
readonly name: "Cloudflare";
|
|
243
243
|
readonly preferredConnectionMethodId: "oauth";
|
|
@@ -1521,14 +1521,14 @@ export declare const integrationCatalog: readonly [{
|
|
|
1521
1521
|
readonly input: "password";
|
|
1522
1522
|
readonly label: "API token";
|
|
1523
1523
|
readonly name: "apiKey";
|
|
1524
|
-
readonly placeholder: "
|
|
1524
|
+
readonly placeholder: "Token with Account Settings Read";
|
|
1525
1525
|
readonly required: true;
|
|
1526
1526
|
}];
|
|
1527
1527
|
readonly id: "api-token";
|
|
1528
1528
|
readonly name: "API token";
|
|
1529
1529
|
readonly type: "form";
|
|
1530
1530
|
}];
|
|
1531
|
-
readonly description: "Connect
|
|
1531
|
+
readonly description: "Connect with OAuth or an API token that includes Account Settings Read.";
|
|
1532
1532
|
readonly id: "cloudflare";
|
|
1533
1533
|
readonly name: "Cloudflare";
|
|
1534
1534
|
readonly preferredConnectionMethodId: "oauth";
|
package/dist/catalog.js
CHANGED
|
@@ -187,7 +187,7 @@ export const cloudflareService = defineIntegrationService({
|
|
|
187
187
|
input: "password",
|
|
188
188
|
label: "API token",
|
|
189
189
|
name: "apiKey",
|
|
190
|
-
placeholder: "
|
|
190
|
+
placeholder: "Token with Account Settings Read",
|
|
191
191
|
required: true,
|
|
192
192
|
},
|
|
193
193
|
],
|
|
@@ -196,7 +196,7 @@ export const cloudflareService = defineIntegrationService({
|
|
|
196
196
|
type: "form",
|
|
197
197
|
},
|
|
198
198
|
],
|
|
199
|
-
description: "Connect
|
|
199
|
+
description: "Connect with OAuth or an API token that includes Account Settings Read.",
|
|
200
200
|
id: "cloudflare",
|
|
201
201
|
name: "Cloudflare",
|
|
202
202
|
preferredConnectionMethodId: "oauth",
|
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import * as z from "zod/mini";
|
|
2
|
+
export declare const FORM_FIELDS_SCHEMA: z.ZodMiniArray<z.ZodMiniPipe<z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
3
|
+
defaultValue: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
4
|
+
maxLength: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
|
|
5
|
+
minLength: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
|
|
6
|
+
placeholder: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
7
|
+
required: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
8
|
+
type: z.ZodMiniEnum<{
|
|
9
|
+
email: "email";
|
|
10
|
+
text: "text";
|
|
11
|
+
url: "url";
|
|
12
|
+
phone: "phone";
|
|
13
|
+
textarea: "textarea";
|
|
14
|
+
}>;
|
|
15
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
16
|
+
label: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
17
|
+
name: z.ZodMiniString<string>;
|
|
18
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
19
|
+
defaultValue: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
20
|
+
max: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
21
|
+
min: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
22
|
+
placeholder: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
23
|
+
required: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
24
|
+
step: z.ZodMiniPrefault<z.ZodMiniNumber<number>>;
|
|
25
|
+
type: z.ZodMiniLiteral<"number">;
|
|
26
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
27
|
+
label: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
28
|
+
name: z.ZodMiniString<string>;
|
|
29
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
30
|
+
defaultValue: z.ZodMiniOptional<z.iso.ZodMiniISODate>;
|
|
31
|
+
max: z.ZodMiniOptional<z.iso.ZodMiniISODate>;
|
|
32
|
+
min: z.ZodMiniOptional<z.iso.ZodMiniISODate>;
|
|
33
|
+
required: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
34
|
+
step: z.ZodMiniPrefault<z.ZodMiniNumberFormat>;
|
|
35
|
+
type: z.ZodMiniLiteral<"date">;
|
|
36
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
37
|
+
label: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
38
|
+
name: z.ZodMiniString<string>;
|
|
39
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
40
|
+
defaultValue: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
|
|
41
|
+
max: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
|
|
42
|
+
min: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
|
|
43
|
+
required: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
44
|
+
step: z.ZodMiniPrefault<z.ZodMiniNumber<number>>;
|
|
45
|
+
type: z.ZodMiniLiteral<"datetime">;
|
|
46
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
47
|
+
label: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
48
|
+
name: z.ZodMiniString<string>;
|
|
49
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
50
|
+
type: z.ZodMiniLiteral<"select">;
|
|
51
|
+
defaultValue: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
52
|
+
options: z.ZodMiniArray<z.ZodMiniObject<{
|
|
53
|
+
label: z.ZodMiniString<string>;
|
|
54
|
+
value: z.ZodMiniString<string>;
|
|
55
|
+
}, z.core.$strip>>;
|
|
56
|
+
placeholder: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
57
|
+
required: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
58
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
59
|
+
label: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
60
|
+
name: z.ZodMiniString<string>;
|
|
61
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
62
|
+
type: z.ZodMiniLiteral<"radio">;
|
|
63
|
+
defaultValue: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
64
|
+
options: z.ZodMiniArray<z.ZodMiniObject<{
|
|
65
|
+
label: z.ZodMiniString<string>;
|
|
66
|
+
value: z.ZodMiniString<string>;
|
|
67
|
+
}, z.core.$strip>>;
|
|
68
|
+
placeholder: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
69
|
+
required: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
70
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
71
|
+
label: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
72
|
+
name: z.ZodMiniString<string>;
|
|
73
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
74
|
+
defaultValue: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
75
|
+
options: z.ZodMiniArray<z.ZodMiniObject<{
|
|
76
|
+
label: z.ZodMiniString<string>;
|
|
77
|
+
value: z.ZodMiniString<string>;
|
|
78
|
+
}, z.core.$strip>>;
|
|
79
|
+
placeholder: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
80
|
+
required: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
81
|
+
type: z.ZodMiniLiteral<"multi-select">;
|
|
82
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
83
|
+
label: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
84
|
+
name: z.ZodMiniString<string>;
|
|
85
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
86
|
+
defaultValue: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
87
|
+
required: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
88
|
+
type: z.ZodMiniLiteral<"checkbox">;
|
|
89
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
90
|
+
label: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
91
|
+
name: z.ZodMiniString<string>;
|
|
92
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
93
|
+
required: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
94
|
+
type: z.ZodMiniLiteral<"file">;
|
|
95
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
96
|
+
label: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
97
|
+
name: z.ZodMiniString<string>;
|
|
98
|
+
}, z.core.$strip>], "type">, z.ZodMiniTransform<{
|
|
99
|
+
label: string;
|
|
100
|
+
required: boolean;
|
|
101
|
+
type: "email" | "text" | "url" | "phone" | "textarea";
|
|
102
|
+
name: string;
|
|
103
|
+
defaultValue?: string | undefined;
|
|
104
|
+
maxLength?: number | undefined;
|
|
105
|
+
minLength?: number | undefined;
|
|
106
|
+
placeholder?: string | undefined;
|
|
107
|
+
description?: string | undefined;
|
|
108
|
+
} | {
|
|
109
|
+
label: string;
|
|
110
|
+
required: boolean;
|
|
111
|
+
step: number;
|
|
112
|
+
type: "number";
|
|
113
|
+
name: string;
|
|
114
|
+
defaultValue?: number | undefined;
|
|
115
|
+
max?: number | undefined;
|
|
116
|
+
min?: number | undefined;
|
|
117
|
+
placeholder?: string | undefined;
|
|
118
|
+
description?: string | undefined;
|
|
119
|
+
} | {
|
|
120
|
+
label: string;
|
|
121
|
+
required: boolean;
|
|
122
|
+
step: number;
|
|
123
|
+
type: "date";
|
|
124
|
+
name: string;
|
|
125
|
+
defaultValue?: string | undefined;
|
|
126
|
+
max?: string | undefined;
|
|
127
|
+
min?: string | undefined;
|
|
128
|
+
description?: string | undefined;
|
|
129
|
+
} | {
|
|
130
|
+
label: string;
|
|
131
|
+
required: boolean;
|
|
132
|
+
step: number;
|
|
133
|
+
type: "datetime";
|
|
134
|
+
name: string;
|
|
135
|
+
defaultValue?: string | undefined;
|
|
136
|
+
max?: string | undefined;
|
|
137
|
+
min?: string | undefined;
|
|
138
|
+
description?: string | undefined;
|
|
139
|
+
} | {
|
|
140
|
+
label: string;
|
|
141
|
+
type: "select";
|
|
142
|
+
options: {
|
|
143
|
+
label: string;
|
|
144
|
+
value: string;
|
|
145
|
+
}[];
|
|
146
|
+
required: boolean;
|
|
147
|
+
name: string;
|
|
148
|
+
defaultValue?: string | undefined;
|
|
149
|
+
placeholder?: string | undefined;
|
|
150
|
+
description?: string | undefined;
|
|
151
|
+
} | {
|
|
152
|
+
label: string;
|
|
153
|
+
type: "radio";
|
|
154
|
+
options: {
|
|
155
|
+
label: string;
|
|
156
|
+
value: string;
|
|
157
|
+
}[];
|
|
158
|
+
required: boolean;
|
|
159
|
+
name: string;
|
|
160
|
+
defaultValue?: string | undefined;
|
|
161
|
+
placeholder?: string | undefined;
|
|
162
|
+
description?: string | undefined;
|
|
163
|
+
} | {
|
|
164
|
+
label: string;
|
|
165
|
+
options: {
|
|
166
|
+
label: string;
|
|
167
|
+
value: string;
|
|
168
|
+
}[];
|
|
169
|
+
required: boolean;
|
|
170
|
+
type: "multi-select";
|
|
171
|
+
name: string;
|
|
172
|
+
defaultValue?: string[] | undefined;
|
|
173
|
+
placeholder?: string | undefined;
|
|
174
|
+
description?: string | undefined;
|
|
175
|
+
} | {
|
|
176
|
+
label: string;
|
|
177
|
+
defaultValue: boolean;
|
|
178
|
+
required: boolean;
|
|
179
|
+
type: "checkbox";
|
|
180
|
+
name: string;
|
|
181
|
+
description?: string | undefined;
|
|
182
|
+
} | {
|
|
183
|
+
label: string;
|
|
184
|
+
required: boolean;
|
|
185
|
+
type: "file";
|
|
186
|
+
name: string;
|
|
187
|
+
description?: string | undefined;
|
|
188
|
+
}, {
|
|
189
|
+
required: boolean;
|
|
190
|
+
type: "email" | "text" | "url" | "phone" | "textarea";
|
|
191
|
+
name: string;
|
|
192
|
+
defaultValue?: string | undefined;
|
|
193
|
+
maxLength?: number | undefined;
|
|
194
|
+
minLength?: number | undefined;
|
|
195
|
+
placeholder?: string | undefined;
|
|
196
|
+
description?: string | undefined;
|
|
197
|
+
label?: string | undefined;
|
|
198
|
+
} | {
|
|
199
|
+
required: boolean;
|
|
200
|
+
step: number;
|
|
201
|
+
type: "number";
|
|
202
|
+
name: string;
|
|
203
|
+
defaultValue?: number | undefined;
|
|
204
|
+
max?: number | undefined;
|
|
205
|
+
min?: number | undefined;
|
|
206
|
+
placeholder?: string | undefined;
|
|
207
|
+
description?: string | undefined;
|
|
208
|
+
label?: string | undefined;
|
|
209
|
+
} | {
|
|
210
|
+
required: boolean;
|
|
211
|
+
step: number;
|
|
212
|
+
type: "date";
|
|
213
|
+
name: string;
|
|
214
|
+
defaultValue?: string | undefined;
|
|
215
|
+
max?: string | undefined;
|
|
216
|
+
min?: string | undefined;
|
|
217
|
+
description?: string | undefined;
|
|
218
|
+
label?: string | undefined;
|
|
219
|
+
} | {
|
|
220
|
+
required: boolean;
|
|
221
|
+
step: number;
|
|
222
|
+
type: "datetime";
|
|
223
|
+
name: string;
|
|
224
|
+
defaultValue?: string | undefined;
|
|
225
|
+
max?: string | undefined;
|
|
226
|
+
min?: string | undefined;
|
|
227
|
+
description?: string | undefined;
|
|
228
|
+
label?: string | undefined;
|
|
229
|
+
} | {
|
|
230
|
+
type: "select";
|
|
231
|
+
options: {
|
|
232
|
+
label: string;
|
|
233
|
+
value: string;
|
|
234
|
+
}[];
|
|
235
|
+
required: boolean;
|
|
236
|
+
name: string;
|
|
237
|
+
defaultValue?: string | undefined;
|
|
238
|
+
placeholder?: string | undefined;
|
|
239
|
+
description?: string | undefined;
|
|
240
|
+
label?: string | undefined;
|
|
241
|
+
} | {
|
|
242
|
+
type: "radio";
|
|
243
|
+
options: {
|
|
244
|
+
label: string;
|
|
245
|
+
value: string;
|
|
246
|
+
}[];
|
|
247
|
+
required: boolean;
|
|
248
|
+
name: string;
|
|
249
|
+
defaultValue?: string | undefined;
|
|
250
|
+
placeholder?: string | undefined;
|
|
251
|
+
description?: string | undefined;
|
|
252
|
+
label?: string | undefined;
|
|
253
|
+
} | {
|
|
254
|
+
options: {
|
|
255
|
+
label: string;
|
|
256
|
+
value: string;
|
|
257
|
+
}[];
|
|
258
|
+
required: boolean;
|
|
259
|
+
type: "multi-select";
|
|
260
|
+
name: string;
|
|
261
|
+
defaultValue?: string[] | undefined;
|
|
262
|
+
placeholder?: string | undefined;
|
|
263
|
+
description?: string | undefined;
|
|
264
|
+
label?: string | undefined;
|
|
265
|
+
} | {
|
|
266
|
+
defaultValue: boolean;
|
|
267
|
+
required: boolean;
|
|
268
|
+
type: "checkbox";
|
|
269
|
+
name: string;
|
|
270
|
+
description?: string | undefined;
|
|
271
|
+
label?: string | undefined;
|
|
272
|
+
} | {
|
|
273
|
+
required: boolean;
|
|
274
|
+
type: "file";
|
|
275
|
+
name: string;
|
|
276
|
+
description?: string | undefined;
|
|
277
|
+
label?: string | undefined;
|
|
278
|
+
}>>>;
|
|
279
|
+
export type FormFieldValue = File | boolean | number | string | string[] | null;
|
|
280
|
+
/**
|
|
281
|
+
* Returns the configured fallback for a field without an assigned value.
|
|
282
|
+
*
|
|
283
|
+
* @param field - Field whose fallback should be resolved.
|
|
284
|
+
*/
|
|
285
|
+
export declare function getFormFieldDefaultValue(field: FormField): string | number | boolean | readonly string[] | null | undefined;
|
|
286
|
+
/**
|
|
287
|
+
* Checks one decoded value against a dashboard field declaration.
|
|
288
|
+
*
|
|
289
|
+
* @param field - Field declaration whose constraints apply.
|
|
290
|
+
* @param value - Decoded value to validate.
|
|
291
|
+
*/
|
|
292
|
+
export declare function isFormFieldValueValid(field: FormField, value: unknown): value is FormFieldValue;
|
|
293
|
+
/**
|
|
294
|
+
* Builds the shared validator for decoded field values.
|
|
295
|
+
*
|
|
296
|
+
* @param field - Field declaration whose constraints apply.
|
|
297
|
+
*/
|
|
298
|
+
export declare function getFormFieldValueSchema(field: FormField): z.ZodMiniCustom<FormFieldValue, FormFieldValue>;
|
|
299
|
+
/**
|
|
300
|
+
* Normalizes controlled or prompted values before validation.
|
|
301
|
+
*
|
|
302
|
+
* @param field - Field declaration.
|
|
303
|
+
* @param value - Raw control value.
|
|
304
|
+
*/
|
|
305
|
+
export declare function normalizeFormFieldValue(field: FormField, value: unknown): unknown;
|
|
306
|
+
/**
|
|
307
|
+
* Reads and validates one submitted field, preserving uploaded File values.
|
|
308
|
+
*
|
|
309
|
+
* @param field - Field declaration.
|
|
310
|
+
* @param data - Submitted form data.
|
|
311
|
+
* @param name - Form name, including any UI namespace.
|
|
312
|
+
*/
|
|
313
|
+
export declare function readFormFieldValue(field: FormField, data: FormData, name?: string): z.core.util.SafeParseResult<FormFieldValue>;
|
|
314
|
+
/**
|
|
315
|
+
* Validates configured form fields and ignores unconfigured entries.
|
|
316
|
+
*
|
|
317
|
+
* @param fields - Ordered field declarations.
|
|
318
|
+
* @param data - Submitted form data.
|
|
319
|
+
*/
|
|
320
|
+
export declare function parseFormFields(fields: readonly FormField[], data: FormData): {
|
|
321
|
+
issues: {
|
|
322
|
+
field: string;
|
|
323
|
+
message: string;
|
|
324
|
+
}[];
|
|
325
|
+
success: false;
|
|
326
|
+
data?: undefined;
|
|
327
|
+
} | {
|
|
328
|
+
data: {
|
|
329
|
+
[k: string]: FormFieldValue;
|
|
330
|
+
};
|
|
331
|
+
success: true;
|
|
332
|
+
issues?: undefined;
|
|
333
|
+
};
|
|
334
|
+
interface FormFieldBase {
|
|
335
|
+
/** Supporting text shown below the field. */
|
|
336
|
+
description?: string;
|
|
337
|
+
/** Visible field label. Inferred from `name` when omitted. */
|
|
338
|
+
label?: string;
|
|
339
|
+
/** Property name used in submitted trigger data. */
|
|
340
|
+
name: string;
|
|
341
|
+
/** Whether the form must contain a value. Defaults to true. */
|
|
342
|
+
required?: boolean;
|
|
343
|
+
}
|
|
344
|
+
export type FormField = (FormFieldBase & {
|
|
345
|
+
type: "file";
|
|
346
|
+
}) | (FormFieldBase & {
|
|
347
|
+
defaultValue?: string;
|
|
348
|
+
maxLength?: number;
|
|
349
|
+
minLength?: number;
|
|
350
|
+
placeholder?: string;
|
|
351
|
+
type: "email" | "phone" | "text" | "textarea" | "url";
|
|
352
|
+
}) | (FormFieldBase & {
|
|
353
|
+
defaultValue?: number;
|
|
354
|
+
max?: number;
|
|
355
|
+
min?: number;
|
|
356
|
+
placeholder?: string;
|
|
357
|
+
/** Increment used by the number input. Defaults to 1. */
|
|
358
|
+
step?: number;
|
|
359
|
+
type: "number";
|
|
360
|
+
}) | (FormFieldBase & {
|
|
361
|
+
/** Initial local date in `YYYY-MM-DD` format. */
|
|
362
|
+
defaultValue?: string;
|
|
363
|
+
max?: string;
|
|
364
|
+
min?: string;
|
|
365
|
+
/** Allowed increment in days. Defaults to 1. */
|
|
366
|
+
step?: number;
|
|
367
|
+
type: "date";
|
|
368
|
+
}) | (FormFieldBase & {
|
|
369
|
+
/** Initial local date and time in `YYYY-MM-DDTHH:mm` format. */
|
|
370
|
+
defaultValue?: string;
|
|
371
|
+
max?: string;
|
|
372
|
+
min?: string;
|
|
373
|
+
/** Allowed increment in seconds. Defaults to 60. */
|
|
374
|
+
step?: number;
|
|
375
|
+
type: "datetime";
|
|
376
|
+
}) | (FormFieldBase & {
|
|
377
|
+
defaultValue?: string;
|
|
378
|
+
options: readonly {
|
|
379
|
+
label: string;
|
|
380
|
+
value: string;
|
|
381
|
+
}[];
|
|
382
|
+
placeholder?: string;
|
|
383
|
+
type: "select";
|
|
384
|
+
}) | (FormFieldBase & {
|
|
385
|
+
defaultValue?: string;
|
|
386
|
+
options: readonly {
|
|
387
|
+
label: string;
|
|
388
|
+
value: string;
|
|
389
|
+
}[];
|
|
390
|
+
type: "radio";
|
|
391
|
+
}) | (FormFieldBase & {
|
|
392
|
+
defaultValue?: readonly string[];
|
|
393
|
+
options: readonly {
|
|
394
|
+
label: string;
|
|
395
|
+
value: string;
|
|
396
|
+
}[];
|
|
397
|
+
placeholder?: string;
|
|
398
|
+
type: "multi-select";
|
|
399
|
+
}) | (FormFieldBase & {
|
|
400
|
+
/** Initial checked state. Defaults to false. */
|
|
401
|
+
defaultValue?: boolean;
|
|
402
|
+
/** Whether the checkbox must be checked. Defaults to false. */
|
|
403
|
+
required?: boolean;
|
|
404
|
+
type: "checkbox";
|
|
405
|
+
});
|
|
406
|
+
/** Resolves one field declaration to its author-facing value type. */
|
|
407
|
+
type FormFieldValueFor<TField extends FormField> = TField extends {
|
|
408
|
+
type: "file";
|
|
409
|
+
} ? TField extends {
|
|
410
|
+
required: false;
|
|
411
|
+
} ? File | null : File : TField extends {
|
|
412
|
+
type: "checkbox";
|
|
413
|
+
} ? boolean : TField extends {
|
|
414
|
+
options: readonly (infer TOption)[];
|
|
415
|
+
type: "multi-select";
|
|
416
|
+
} ? [TOption] extends [{
|
|
417
|
+
value: infer TValue extends string;
|
|
418
|
+
}] ? TValue[] : string[] : TField extends {
|
|
419
|
+
required: false;
|
|
420
|
+
type: "number";
|
|
421
|
+
} ? number | null : TField extends {
|
|
422
|
+
type: "number";
|
|
423
|
+
} ? number : TField extends {
|
|
424
|
+
options: readonly (infer TOption)[];
|
|
425
|
+
type: "radio" | "select";
|
|
426
|
+
} ? TOption extends {
|
|
427
|
+
value: infer TValue extends string;
|
|
428
|
+
} ? TField extends {
|
|
429
|
+
required: false;
|
|
430
|
+
} ? TValue | "" : TValue : string : string;
|
|
431
|
+
export type FormFieldValues<TFields extends readonly FormField[]> = {
|
|
432
|
+
readonly [TField in TFields[number] as TField["name"]]: FormFieldValueFor<TField>;
|
|
433
|
+
};
|
|
434
|
+
export {};
|