@automate.ax/catalog 0.153.1 → 0.154.0

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.
@@ -1,277 +1,5 @@
1
1
  import * as z from "zod/mini";
2
- export declare const DASHBOARD_RUN_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>], "type">, z.ZodMiniTransform<{
93
- label: string;
94
- required: boolean;
95
- type: "email" | "text" | "url" | "phone" | "textarea";
96
- name: string;
97
- defaultValue?: string | undefined;
98
- maxLength?: number | undefined;
99
- minLength?: number | undefined;
100
- placeholder?: string | undefined;
101
- description?: string | undefined;
102
- } | {
103
- label: string;
104
- required: boolean;
105
- step: number;
106
- type: "number";
107
- name: string;
108
- defaultValue?: number | undefined;
109
- max?: number | undefined;
110
- min?: number | undefined;
111
- placeholder?: string | undefined;
112
- description?: string | undefined;
113
- } | {
114
- label: string;
115
- required: boolean;
116
- step: number;
117
- type: "date";
118
- name: string;
119
- defaultValue?: string | undefined;
120
- max?: string | undefined;
121
- min?: string | undefined;
122
- description?: string | undefined;
123
- } | {
124
- label: string;
125
- required: boolean;
126
- step: number;
127
- type: "datetime";
128
- name: string;
129
- defaultValue?: string | undefined;
130
- max?: string | undefined;
131
- min?: string | undefined;
132
- description?: string | undefined;
133
- } | {
134
- label: string;
135
- type: "select";
136
- options: {
137
- label: string;
138
- value: string;
139
- }[];
140
- required: boolean;
141
- name: string;
142
- defaultValue?: string | undefined;
143
- placeholder?: string | undefined;
144
- description?: string | undefined;
145
- } | {
146
- label: string;
147
- type: "radio";
148
- options: {
149
- label: string;
150
- value: string;
151
- }[];
152
- required: boolean;
153
- name: string;
154
- defaultValue?: string | undefined;
155
- placeholder?: string | undefined;
156
- description?: string | undefined;
157
- } | {
158
- label: string;
159
- options: {
160
- label: string;
161
- value: string;
162
- }[];
163
- required: boolean;
164
- type: "multi-select";
165
- name: string;
166
- defaultValue?: string[] | undefined;
167
- placeholder?: string | undefined;
168
- description?: string | undefined;
169
- } | {
170
- label: string;
171
- defaultValue: boolean;
172
- required: boolean;
173
- type: "checkbox";
174
- name: string;
175
- description?: string | undefined;
176
- }, {
177
- required: boolean;
178
- type: "email" | "text" | "url" | "phone" | "textarea";
179
- name: string;
180
- defaultValue?: string | undefined;
181
- maxLength?: number | undefined;
182
- minLength?: number | undefined;
183
- placeholder?: string | undefined;
184
- description?: string | undefined;
185
- label?: string | undefined;
186
- } | {
187
- required: boolean;
188
- step: number;
189
- type: "number";
190
- name: string;
191
- defaultValue?: number | undefined;
192
- max?: number | undefined;
193
- min?: number | undefined;
194
- placeholder?: string | undefined;
195
- description?: string | undefined;
196
- label?: string | undefined;
197
- } | {
198
- required: boolean;
199
- step: number;
200
- type: "date";
201
- name: string;
202
- defaultValue?: string | undefined;
203
- max?: string | undefined;
204
- min?: string | undefined;
205
- description?: string | undefined;
206
- label?: string | undefined;
207
- } | {
208
- required: boolean;
209
- step: number;
210
- type: "datetime";
211
- name: string;
212
- defaultValue?: string | undefined;
213
- max?: string | undefined;
214
- min?: string | undefined;
215
- description?: string | undefined;
216
- label?: string | undefined;
217
- } | {
218
- type: "select";
219
- options: {
220
- label: string;
221
- value: string;
222
- }[];
223
- required: boolean;
224
- name: string;
225
- defaultValue?: string | undefined;
226
- placeholder?: string | undefined;
227
- description?: string | undefined;
228
- label?: string | undefined;
229
- } | {
230
- type: "radio";
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
- options: {
243
- label: string;
244
- value: string;
245
- }[];
246
- required: boolean;
247
- type: "multi-select";
248
- name: string;
249
- defaultValue?: string[] | undefined;
250
- placeholder?: string | undefined;
251
- description?: string | undefined;
252
- label?: string | undefined;
253
- } | {
254
- defaultValue: boolean;
255
- required: boolean;
256
- type: "checkbox";
257
- name: string;
258
- description?: string | undefined;
259
- label?: string | undefined;
260
- }>>>;
261
- export type DashboardRunFieldValue = boolean | number | string | readonly string[] | null;
262
- /**
263
- * Returns the configured fallback for a field without an assigned value.
264
- *
265
- * @param field - Field whose fallback should be resolved.
266
- */
267
- export declare function getDashboardRunFieldDefaultValue(field: DashboardRunField): string | number | boolean | readonly string[] | null | undefined;
268
- /**
269
- * Checks one decoded value against a dashboard field declaration.
270
- *
271
- * @param field - Field declaration whose constraints apply.
272
- * @param value - Decoded value to validate.
273
- */
274
- export declare function isDashboardRunFieldValueValid(field: DashboardRunField, value: unknown): boolean;
2
+ import { type FormField } from "../form-fields.js";
275
3
  export declare const DASHBOARD_RUN_CONFIG_SCHEMA: z.ZodMiniObject<{
276
4
  description: z.ZodMiniOptional<z.ZodMiniString<string>>;
277
5
  fields: z.ZodMiniPrefault<z.ZodMiniArray<z.ZodMiniPipe<z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
@@ -364,6 +92,12 @@ export declare const DASHBOARD_RUN_CONFIG_SCHEMA: z.ZodMiniObject<{
364
92
  description: z.ZodMiniOptional<z.ZodMiniString<string>>;
365
93
  label: z.ZodMiniOptional<z.ZodMiniString<string>>;
366
94
  name: z.ZodMiniString<string>;
95
+ }, z.core.$strip>, z.ZodMiniObject<{
96
+ required: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
97
+ type: z.ZodMiniLiteral<"file">;
98
+ description: z.ZodMiniOptional<z.ZodMiniString<string>>;
99
+ label: z.ZodMiniOptional<z.ZodMiniString<string>>;
100
+ name: z.ZodMiniString<string>;
367
101
  }, z.core.$strip>], "type">, z.ZodMiniTransform<{
368
102
  label: string;
369
103
  required: boolean;
@@ -448,6 +182,12 @@ export declare const DASHBOARD_RUN_CONFIG_SCHEMA: z.ZodMiniObject<{
448
182
  type: "checkbox";
449
183
  name: string;
450
184
  description?: string | undefined;
185
+ } | {
186
+ label: string;
187
+ required: boolean;
188
+ type: "file";
189
+ name: string;
190
+ description?: string | undefined;
451
191
  }, {
452
192
  required: boolean;
453
193
  type: "email" | "text" | "url" | "phone" | "textarea";
@@ -532,6 +272,12 @@ export declare const DASHBOARD_RUN_CONFIG_SCHEMA: z.ZodMiniObject<{
532
272
  name: string;
533
273
  description?: string | undefined;
534
274
  label?: string | undefined;
275
+ } | {
276
+ required: boolean;
277
+ type: "file";
278
+ name: string;
279
+ description?: string | undefined;
280
+ label?: string | undefined;
535
281
  }>>>>;
536
282
  submitLabel: z.ZodMiniPrefault<z.ZodMiniString<string>>;
537
283
  title: z.ZodMiniString<string>;
@@ -545,77 +291,7 @@ export declare const dashboardRunTriggerDefinition: {
545
291
  readonly name: "Dashboard run";
546
292
  readonly type: "dashboard.run";
547
293
  };
548
- interface DashboardRunFieldBase {
549
- /** Supporting text shown below the field. */
550
- description?: string;
551
- /** Visible field label. Inferred from `name` when omitted. */
552
- label?: string;
553
- /** Property name used in submitted trigger data. */
554
- name: string;
555
- /** Whether the form must contain a value. Defaults to true. */
556
- required?: boolean;
557
- }
558
- export type DashboardRunField = (DashboardRunFieldBase & {
559
- defaultValue?: string;
560
- maxLength?: number;
561
- minLength?: number;
562
- placeholder?: string;
563
- type: "email" | "phone" | "text" | "textarea" | "url";
564
- }) | (DashboardRunFieldBase & {
565
- defaultValue?: number;
566
- max?: number;
567
- min?: number;
568
- placeholder?: string;
569
- /** Increment used by the number input. Defaults to 1. */
570
- step?: number;
571
- type: "number";
572
- }) | (DashboardRunFieldBase & {
573
- /** Initial local date in `YYYY-MM-DD` format. */
574
- defaultValue?: string;
575
- max?: string;
576
- min?: string;
577
- /** Allowed increment in days. Defaults to 1. */
578
- step?: number;
579
- type: "date";
580
- }) | (DashboardRunFieldBase & {
581
- /** Initial local date and time in `YYYY-MM-DDTHH:mm` format. */
582
- defaultValue?: string;
583
- max?: string;
584
- min?: string;
585
- /** Allowed increment in seconds. Defaults to 60. */
586
- step?: number;
587
- type: "datetime";
588
- }) | (DashboardRunFieldBase & {
589
- defaultValue?: string;
590
- options: readonly {
591
- label: string;
592
- value: string;
593
- }[];
594
- placeholder?: string;
595
- type: "select";
596
- }) | (DashboardRunFieldBase & {
597
- defaultValue?: string;
598
- options: readonly {
599
- label: string;
600
- value: string;
601
- }[];
602
- type: "radio";
603
- }) | (DashboardRunFieldBase & {
604
- defaultValue?: readonly string[];
605
- options: readonly {
606
- label: string;
607
- value: string;
608
- }[];
609
- placeholder?: string;
610
- type: "multi-select";
611
- }) | (DashboardRunFieldBase & {
612
- /** Initial checked state. Defaults to false. */
613
- defaultValue?: boolean;
614
- /** Whether the checkbox must be checked. Defaults to false. */
615
- required?: boolean;
616
- type: "checkbox";
617
- });
618
- export interface DashboardRunConfig<TFields extends readonly DashboardRunField[] = readonly DashboardRunField[]> {
294
+ export interface DashboardRunConfig<TFields extends readonly FormField[] = readonly FormField[]> {
619
295
  /** Supporting text shown below the form title. */
620
296
  description?: string;
621
297
  /** Ordered fields. Omit to run immediately. */
@@ -644,4 +320,3 @@ export declare function getDashboardRunEndpoint(options: DashboardRunEndpointOpt
644
320
  * @param options - Trigger and owning automation identity.
645
321
  */
646
322
  export declare function getDashboardRunEndpointKey(options: Omit<DashboardRunEndpointOptions, "appOrigin">): string;
647
- export {};
@@ -1,188 +1,8 @@
1
- import { sentenceCase } from "./name.js";
2
1
  import * as z from "zod/mini";
3
- const EMAIL_SCHEMA = z.email();
4
- const URL_SCHEMA = z.url();
5
- const DATE_SCHEMA = z.iso.date();
6
- const DATETIME_SCHEMA = z.iso.datetime({ local: true });
7
- const FIELD_NAME_SCHEMA = z
8
- .string()
9
- .check(z.trim(), z.minLength(1), z.maxLength(100));
10
- const FIELD_LABEL_SCHEMA = z
11
- .string()
12
- .check(z.trim(), z.minLength(1), z.maxLength(255));
13
- const FIELD_DESCRIPTION_SCHEMA = z.string().check(z.maxLength(2_000));
14
- const FIELD_LENGTH_SCHEMA = z.int().check(z.nonnegative());
15
- const DASHBOARD_RUN_FIELD_BASE_SCHEMA = {
16
- description: z.optional(FIELD_DESCRIPTION_SCHEMA),
17
- label: z.optional(FIELD_LABEL_SCHEMA),
18
- name: FIELD_NAME_SCHEMA,
19
- };
20
- const DASHBOARD_RUN_TEXT_FIELD_SCHEMA = z.object({
21
- ...DASHBOARD_RUN_FIELD_BASE_SCHEMA,
22
- defaultValue: z.optional(z.string()),
23
- maxLength: z.optional(FIELD_LENGTH_SCHEMA),
24
- minLength: z.optional(FIELD_LENGTH_SCHEMA),
25
- placeholder: z.optional(z.string()),
26
- required: z.prefault(z.boolean(), true),
27
- type: z.enum(["email", "phone", "text", "textarea", "url"]),
28
- });
29
- const DASHBOARD_RUN_NUMBER_FIELD_SCHEMA = z.object({
30
- ...DASHBOARD_RUN_FIELD_BASE_SCHEMA,
31
- defaultValue: z.optional(z.number()),
32
- max: z.optional(z.number()),
33
- min: z.optional(z.number()),
34
- placeholder: z.optional(z.string()),
35
- required: z.prefault(z.boolean(), true),
36
- step: z.prefault(z.number().check(z.positive()), 1),
37
- type: z.literal("number"),
38
- });
39
- const DASHBOARD_RUN_DATE_FIELD_SCHEMA = z.object({
40
- ...DASHBOARD_RUN_FIELD_BASE_SCHEMA,
41
- defaultValue: z.optional(z.iso.date()),
42
- max: z.optional(z.iso.date()),
43
- min: z.optional(z.iso.date()),
44
- required: z.prefault(z.boolean(), true),
45
- step: z.prefault(z.int().check(z.positive()), 1),
46
- type: z.literal("date"),
47
- });
48
- const DASHBOARD_RUN_DATETIME_FIELD_SCHEMA = z.object({
49
- ...DASHBOARD_RUN_FIELD_BASE_SCHEMA,
50
- defaultValue: z.optional(z.iso.datetime({ local: true })),
51
- max: z.optional(z.iso.datetime({ local: true })),
52
- min: z.optional(z.iso.datetime({ local: true })),
53
- required: z.prefault(z.boolean(), true),
54
- step: z.prefault(z.number().check(z.positive()), 60),
55
- type: z.literal("datetime"),
56
- });
57
- const DASHBOARD_RUN_CHOICE_FIELD_SCHEMA = {
58
- ...DASHBOARD_RUN_FIELD_BASE_SCHEMA,
59
- defaultValue: z.optional(FIELD_NAME_SCHEMA),
60
- options: z
61
- .array(z.object({
62
- label: FIELD_LABEL_SCHEMA,
63
- value: FIELD_NAME_SCHEMA,
64
- }))
65
- .check(z.minLength(1)),
66
- placeholder: z.optional(z.string()),
67
- required: z.prefault(z.boolean(), true),
68
- };
69
- const DASHBOARD_RUN_SELECT_FIELD_SCHEMA = z.object({
70
- ...DASHBOARD_RUN_CHOICE_FIELD_SCHEMA,
71
- type: z.literal("select"),
72
- });
73
- const DASHBOARD_RUN_RADIO_FIELD_SCHEMA = z.object({
74
- ...DASHBOARD_RUN_CHOICE_FIELD_SCHEMA,
75
- type: z.literal("radio"),
76
- });
77
- const DASHBOARD_RUN_MULTI_SELECT_FIELD_SCHEMA = z.object({
78
- ...DASHBOARD_RUN_FIELD_BASE_SCHEMA,
79
- defaultValue: z.optional(z.array(FIELD_NAME_SCHEMA)),
80
- options: z
81
- .array(z.object({
82
- label: FIELD_LABEL_SCHEMA,
83
- value: FIELD_NAME_SCHEMA,
84
- }))
85
- .check(z.minLength(1)),
86
- placeholder: z.optional(z.string()),
87
- required: z.prefault(z.boolean(), true),
88
- type: z.literal("multi-select"),
89
- });
90
- const DASHBOARD_RUN_CHECKBOX_FIELD_SCHEMA = z.object({
91
- ...DASHBOARD_RUN_FIELD_BASE_SCHEMA,
92
- defaultValue: z.prefault(z.boolean(), false),
93
- required: z.prefault(z.boolean(), false),
94
- type: z.literal("checkbox"),
95
- });
96
- const DASHBOARD_RUN_FIELD_SCHEMA = z.pipe(z.discriminatedUnion("type", [
97
- DASHBOARD_RUN_TEXT_FIELD_SCHEMA,
98
- DASHBOARD_RUN_NUMBER_FIELD_SCHEMA,
99
- DASHBOARD_RUN_DATE_FIELD_SCHEMA,
100
- DASHBOARD_RUN_DATETIME_FIELD_SCHEMA,
101
- DASHBOARD_RUN_SELECT_FIELD_SCHEMA,
102
- DASHBOARD_RUN_RADIO_FIELD_SCHEMA,
103
- DASHBOARD_RUN_MULTI_SELECT_FIELD_SCHEMA,
104
- DASHBOARD_RUN_CHECKBOX_FIELD_SCHEMA,
105
- ]), z.transform((field) => ({
106
- ...field,
107
- label: field.label ??
108
- `${sentenceCase(field.name)}${field.type === "checkbox" ? "?" : ""}`,
109
- })));
110
- export const DASHBOARD_RUN_FIELDS_SCHEMA = z
111
- .array(DASHBOARD_RUN_FIELD_SCHEMA)
112
- .check(z.refine((fields) => new Set(fields.map((field) => field.name)).size === fields.length, "Dashboard run field names must be unique."), z.refine((fields) => fields.every(isDashboardRunFieldDefaultValid), "Dashboard run field defaults must satisfy their field constraints."));
113
- /**
114
- * Returns the configured fallback for a field without an assigned value.
115
- *
116
- * @param field - Field whose fallback should be resolved.
117
- */
118
- export function getDashboardRunFieldDefaultValue(field) {
119
- if (field.defaultValue !== undefined)
120
- return field.defaultValue;
121
- if (field.type === "checkbox")
122
- return false;
123
- if (field.type === "multi-select")
124
- return [];
125
- if (field.type === "number")
126
- return field.required === false ? null : undefined;
127
- return field.required === false ? "" : undefined;
128
- }
129
- /**
130
- * Checks one decoded value against a dashboard field declaration.
131
- *
132
- * @param field - Field declaration whose constraints apply.
133
- * @param value - Decoded value to validate.
134
- */
135
- export function isDashboardRunFieldValueValid(field, value) {
136
- if (field.type === "checkbox") {
137
- return typeof value === "boolean" && (field.required === false || value);
138
- }
139
- if (field.type === "multi-select") {
140
- return (Array.isArray(value) &&
141
- (field.required === false || value.length > 0) &&
142
- value.every((entry) => typeof entry === "string" &&
143
- field.options.some((option) => option.value === entry)));
144
- }
145
- if (field.type === "number") {
146
- if (value === null)
147
- return field.required === false;
148
- return (typeof value === "number" &&
149
- Number.isFinite(value) &&
150
- (field.min === undefined || value >= field.min) &&
151
- (field.max === undefined || value <= field.max) &&
152
- !isDashboardRunStepMismatch(value, field.min ?? field.defaultValue ?? 0, field.step ?? 1));
153
- }
154
- if (typeof value !== "string")
155
- return false;
156
- if (field.type === "radio" || field.type === "select") {
157
- return ((field.required === false && value === "") ||
158
- field.options.some((option) => option.value === value));
159
- }
160
- if (field.type === "date" || field.type === "datetime") {
161
- if (field.required === false && value === "")
162
- return true;
163
- const parsed = parseDashboardRunDateValue(field.type, value);
164
- return ((field.type === "date" ? DATE_SCHEMA : DATETIME_SCHEMA).safeParse(value)
165
- .success &&
166
- Number.isFinite(parsed) &&
167
- (field.min === undefined ||
168
- parsed >= parseDashboardRunDateValue(field.type, field.min)) &&
169
- (field.max === undefined ||
170
- parsed <= parseDashboardRunDateValue(field.type, field.max)) &&
171
- !isDashboardRunStepMismatch(parsed, parseDashboardRunDateValue(field.type, field.min ??
172
- field.defaultValue ??
173
- (field.type === "date" ? "1970-01-01" : "1970-01-01T00:00")), (field.step ?? (field.type === "date" ? 1 : 60)) *
174
- (field.type === "date" ? 86_400_000 : 1_000)));
175
- }
176
- const normalized = value.trim();
177
- return ((normalized.length > 0 || field.required === false) &&
178
- (field.minLength === undefined || normalized.length >= field.minLength) &&
179
- (field.maxLength === undefined || normalized.length <= field.maxLength) &&
180
- (field.type !== "email" || EMAIL_SCHEMA.safeParse(normalized).success) &&
181
- (field.type !== "url" || URL_SCHEMA.safeParse(normalized).success));
182
- }
2
+ import { FORM_FIELDS_SCHEMA } from "../form-fields.js";
183
3
  export const DASHBOARD_RUN_CONFIG_SCHEMA = z.object({
184
- description: z.optional(FIELD_DESCRIPTION_SCHEMA),
185
- fields: z.prefault(DASHBOARD_RUN_FIELDS_SCHEMA, []),
4
+ description: z.optional(z.string().check(z.maxLength(2_000))),
5
+ fields: z.prefault(FORM_FIELDS_SCHEMA, []),
186
6
  submitLabel: z.prefault(z.string().check(z.trim(), z.minLength(1), z.maxLength(100)), "Run"),
187
7
  title: z.string().check(z.trim(), z.minLength(1), z.maxLength(255)),
188
8
  });
@@ -217,60 +37,3 @@ export function getDashboardRunEndpointKey(options) {
217
37
  options.hookSlot,
218
38
  ].join(".")}`;
219
39
  }
220
- /**
221
- * Checks a configured default against the same constraints as submitted data.
222
- *
223
- * @param field - Field definition to validate.
224
- */
225
- function isDashboardRunFieldDefaultValid(field) {
226
- if (field.type === "checkbox" || field.defaultValue === undefined)
227
- return true;
228
- if (field.type === "multi-select") {
229
- if (field.required !== false && field.defaultValue.length === 0)
230
- return false;
231
- return field.defaultValue.every((value) => field.options.some((option) => option.value === value));
232
- }
233
- if (field.type === "radio" || field.type === "select") {
234
- return field.options.some((option) => option.value === field.defaultValue);
235
- }
236
- if (field.type === "number") {
237
- return ((field.min === undefined || field.defaultValue >= field.min) &&
238
- (field.max === undefined || field.defaultValue <= field.max) &&
239
- !isDashboardRunStepMismatch(field.defaultValue, field.min ?? field.defaultValue, field.step ?? 1));
240
- }
241
- if (field.type === "date" || field.type === "datetime") {
242
- const defaultValue = parseDashboardRunDateValue(field.type, field.defaultValue);
243
- return ((field.min === undefined ||
244
- defaultValue >= parseDashboardRunDateValue(field.type, field.min)) &&
245
- (field.max === undefined ||
246
- defaultValue <= parseDashboardRunDateValue(field.type, field.max)) &&
247
- !isDashboardRunStepMismatch(defaultValue, parseDashboardRunDateValue(field.type, field.min ?? field.defaultValue), (field.step ?? (field.type === "date" ? 1 : 60)) *
248
- (field.type === "date" ? 86_400_000 : 1_000)));
249
- }
250
- const defaultValue = field.defaultValue.trim();
251
- return ((defaultValue.length > 0 || field.required === false) &&
252
- (field.minLength === undefined || defaultValue.length >= field.minLength) &&
253
- (field.maxLength === undefined || defaultValue.length <= field.maxLength) &&
254
- (field.type !== "email" || EMAIL_SCHEMA.safeParse(defaultValue).success) &&
255
- (field.type !== "url" || URL_SCHEMA.safeParse(defaultValue).success));
256
- }
257
- /**
258
- * Checks whether a value falls outside an allowed step interval.
259
- *
260
- * @param value - Configured default value.
261
- * @param base - Value from which step intervals begin.
262
- * @param step - Allowed interval size.
263
- */
264
- function isDashboardRunStepMismatch(value, base, step) {
265
- const intervals = (value - base) / step;
266
- return Math.abs(intervals - Math.round(intervals)) > 1e-9;
267
- }
268
- /**
269
- * Converts a validated local date or date-time string to a UTC number.
270
- *
271
- * @param type - Temporal field type.
272
- * @param value - Local ISO value to convert.
273
- */
274
- function parseDashboardRunDateValue(type, value) {
275
- return Date.parse(type === "date" ? `${value}T00:00:00Z` : `${value}Z`);
276
- }
@@ -1,4 +1,4 @@
1
- export { DASHBOARD_RUN_CONFIG_SCHEMA, DASHBOARD_RUN_FIELDS_SCHEMA, dashboardRunTriggerDefinition, getDashboardRunEndpoint, getDashboardRunEndpointKey, getDashboardRunFieldDefaultValue, isDashboardRunFieldValueValid, type DashboardRunConfig, type DashboardRunEndpointOptions, type DashboardRunField, type DashboardRunFieldValue, } from "./core-dashboard.js";
1
+ export { DASHBOARD_RUN_CONFIG_SCHEMA, dashboardRunTriggerDefinition, getDashboardRunEndpoint, getDashboardRunEndpointKey, type DashboardRunConfig, type DashboardRunEndpointOptions, } from "./core-dashboard.js";
2
2
  export { getHttpTriggerEndpoint, getHttpTriggerEndpointKey, httpRequestTriggerDefinition, type HttpTriggerEndpointOptions, type HttpTriggerScope, } from "./core-http.js";
3
3
  export { automationInvokedTriggerDefinition } from "./core-invocation.js";
4
4
  export { getMailhookAddress, getMailhookAddressKey, mailhookEmailReceivedTriggerDefinition, PLATFORM_EMAIL_DOMAIN, type MailhookAddressOptions, type MailhookScope, } from "./core-mailhook.js";
@@ -3,7 +3,7 @@ import { httpRequestTriggerDefinition } from "./core-http.js";
3
3
  import { automationInvokedTriggerDefinition } from "./core-invocation.js";
4
4
  import { mailhookEmailReceivedTriggerDefinition } from "./core-mailhook.js";
5
5
  import { cronTickTriggerDefinition } from "./core-schedule.js";
6
- export { DASHBOARD_RUN_CONFIG_SCHEMA, DASHBOARD_RUN_FIELDS_SCHEMA, dashboardRunTriggerDefinition, getDashboardRunEndpoint, getDashboardRunEndpointKey, getDashboardRunFieldDefaultValue, isDashboardRunFieldValueValid, } from "./core-dashboard.js";
6
+ export { DASHBOARD_RUN_CONFIG_SCHEMA, dashboardRunTriggerDefinition, getDashboardRunEndpoint, getDashboardRunEndpointKey, } from "./core-dashboard.js";
7
7
  export { getHttpTriggerEndpoint, getHttpTriggerEndpointKey, httpRequestTriggerDefinition, } from "./core-http.js";
8
8
  export { automationInvokedTriggerDefinition } from "./core-invocation.js";
9
9
  export { getMailhookAddress, getMailhookAddressKey, mailhookEmailReceivedTriggerDefinition, PLATFORM_EMAIL_DOMAIN, } from "./core-mailhook.js";
@@ -1,5 +1,5 @@
1
1
  import type { TriggerDefinition, TriggerPresentation, TriggerPresentationContext, TriggerScopePresentation } from "../types.js";
2
- export { getDashboardRunEndpoint, getDashboardRunEndpointKey, getHttpTriggerEndpoint, getHttpTriggerEndpointKey, getMailhookAddress, getMailhookAddressKey, PLATFORM_EMAIL_DOMAIN, DASHBOARD_RUN_CONFIG_SCHEMA, DASHBOARD_RUN_FIELDS_SCHEMA, getDashboardRunFieldDefaultValue, isDashboardRunFieldValueValid, type DashboardRunConfig, type DashboardRunEndpointOptions, type DashboardRunField, type DashboardRunFieldValue, type HttpTriggerEndpointOptions, type HttpTriggerScope, type MailhookAddressOptions, type MailhookScope, } from "./core.js";
2
+ export { getDashboardRunEndpoint, getDashboardRunEndpointKey, getHttpTriggerEndpoint, getHttpTriggerEndpointKey, getMailhookAddress, getMailhookAddressKey, PLATFORM_EMAIL_DOMAIN, DASHBOARD_RUN_CONFIG_SCHEMA, type DashboardRunConfig, type DashboardRunEndpointOptions, type HttpTriggerEndpointOptions, type HttpTriggerScope, type MailhookAddressOptions, type MailhookScope, } from "./core.js";
3
3
  /** Plain shared definitions for every public trigger type. */
4
4
  export declare const triggerDefinitions: {
5
5
  readonly whatsappMessageDelivered: {
@@ -35,7 +35,7 @@ import { webflowTriggerDefinitions } from "./webflow.js";
35
35
  import { whatsappTriggerDefinitions } from "./whatsapp.js";
36
36
  import { sentenceCase } from "./name.js";
37
37
  import { getIntegrationService } from "../catalog.js";
38
- export { getDashboardRunEndpoint, getDashboardRunEndpointKey, getHttpTriggerEndpoint, getHttpTriggerEndpointKey, getMailhookAddress, getMailhookAddressKey, PLATFORM_EMAIL_DOMAIN, DASHBOARD_RUN_CONFIG_SCHEMA, DASHBOARD_RUN_FIELDS_SCHEMA, getDashboardRunFieldDefaultValue, isDashboardRunFieldValueValid, } from "./core.js";
38
+ export { getDashboardRunEndpoint, getDashboardRunEndpointKey, getHttpTriggerEndpoint, getHttpTriggerEndpointKey, getMailhookAddress, getMailhookAddressKey, PLATFORM_EMAIL_DOMAIN, DASHBOARD_RUN_CONFIG_SCHEMA, } from "./core.js";
39
39
  /** Plain shared definitions for every public trigger type. */
40
40
  export const triggerDefinitions = {
41
41
  ...anthropicTriggerDefinitions,