@automate.ax/catalog 0.62.0 → 0.63.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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/triggers/core.d.ts +113 -0
- package/dist/triggers/core.js +85 -0
- package/dist/triggers/index.d.ts +18 -1
- package/dist/triggers/index.js +1 -1
- package/package.json +1 -1
- package/src/index.ts +6 -0
- package/src/triggers/core.ts +163 -0
- package/src/triggers/index.ts +6 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { airtableService, anthropicService, apolloService, asanaService, brevoService, cerebrasService, cloudflareService, cohereService, deepinfraService, deepseekService, firecrawlService, fireworksService, getIntegrationService, githubService, googleGenaiService, googleService, groqService, huggingfaceService, integrationCatalog, linearService, microsoftService, millionverifierService, mistralService, openaiService, openrouterService, perplexityService, postgresService, resendService, scrapflyService, slackService, tidycalService, togetheraiService, trelloService, vercelAiGatewayService, vercelService, whatsappService, xaiService, type IntegrationServiceId, } from "./catalog.js";
|
|
2
2
|
export { defineIntegrationCatalog, defineIntegrationService, integrationScope, type IntegrationAccountConnectionOption, type IntegrationAccountRequirement, type IntegrationConnectionDefinition, type IntegrationFormField, type IntegrationScopeRequirement, type IntegrationServiceDefinition, type ScopeRequirementGroup, type TriggerDefinition, type TriggerPresentation, type TriggerPresentationContext, type TriggerPresentationDetail, type TriggerScopePresentation, type TriggerPresentationValue, } from "./types.js";
|
|
3
|
-
export { getHttpTriggerEndpoint, getHttpTriggerEndpointKey, getTriggerDefinition, getTriggerName, getTriggerPresentation, isTriggerVisible, triggerCatalog, triggerDefinitions, type HttpTriggerEndpointOptions, type HttpTriggerScope, type TriggerType, } from "./triggers/index.js";
|
|
3
|
+
export { getDashboardRunEndpoint, getDashboardRunEndpointKey, getHttpTriggerEndpoint, getHttpTriggerEndpointKey, DASHBOARD_RUN_CONFIG_SCHEMA, getTriggerDefinition, getTriggerName, getTriggerPresentation, isTriggerVisible, triggerCatalog, triggerDefinitions, type DashboardRunConfig, type DashboardRunEndpointOptions, type DashboardRunField, type HttpTriggerEndpointOptions, type HttpTriggerScope, type TriggerType, } from "./triggers/index.js";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { airtableService, anthropicService, apolloService, asanaService, brevoService, cerebrasService, cloudflareService, cohereService, deepinfraService, deepseekService, firecrawlService, fireworksService, getIntegrationService, githubService, googleGenaiService, googleService, groqService, huggingfaceService, integrationCatalog, linearService, microsoftService, millionverifierService, mistralService, openaiService, openrouterService, perplexityService, postgresService, resendService, scrapflyService, slackService, tidycalService, togetheraiService, trelloService, vercelAiGatewayService, vercelService, whatsappService, xaiService, } from "./catalog.js";
|
|
2
2
|
export { defineIntegrationCatalog, defineIntegrationService, integrationScope, } from "./types.js";
|
|
3
|
-
export { getHttpTriggerEndpoint, getHttpTriggerEndpointKey, getTriggerDefinition, getTriggerName, getTriggerPresentation, isTriggerVisible, triggerCatalog, triggerDefinitions, } from "./triggers/index.js";
|
|
3
|
+
export { getDashboardRunEndpoint, getDashboardRunEndpointKey, getHttpTriggerEndpoint, getHttpTriggerEndpointKey, DASHBOARD_RUN_CONFIG_SCHEMA, getTriggerDefinition, getTriggerName, getTriggerPresentation, isTriggerVisible, triggerCatalog, triggerDefinitions, } from "./triggers/index.js";
|
package/dist/triggers/core.d.ts
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
+
import * as z from "zod/mini";
|
|
2
|
+
export declare const DASHBOARD_RUN_CONFIG_SCHEMA: z.ZodMiniObject<{
|
|
3
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
4
|
+
fields: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
5
|
+
maxLength: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
|
|
6
|
+
minLength: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
|
|
7
|
+
placeholder: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
8
|
+
type: z.ZodMiniEnum<{
|
|
9
|
+
email: "email";
|
|
10
|
+
text: "text";
|
|
11
|
+
url: "url";
|
|
12
|
+
textarea: "textarea";
|
|
13
|
+
}>;
|
|
14
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
15
|
+
label: z.ZodMiniString<string>;
|
|
16
|
+
required: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
17
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
18
|
+
max: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
19
|
+
min: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
20
|
+
placeholder: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
21
|
+
step: z.ZodMiniPrefault<z.ZodMiniNumber<number>>;
|
|
22
|
+
type: z.ZodMiniLiteral<"number">;
|
|
23
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
24
|
+
label: z.ZodMiniString<string>;
|
|
25
|
+
required: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
26
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
27
|
+
options: z.ZodMiniArray<z.ZodMiniObject<{
|
|
28
|
+
label: z.ZodMiniString<string>;
|
|
29
|
+
value: z.ZodMiniString<string>;
|
|
30
|
+
}, z.core.$strip>>;
|
|
31
|
+
placeholder: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
32
|
+
type: z.ZodMiniLiteral<"select">;
|
|
33
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
34
|
+
label: z.ZodMiniString<string>;
|
|
35
|
+
required: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
36
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
37
|
+
type: z.ZodMiniLiteral<"checkbox">;
|
|
38
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
39
|
+
label: z.ZodMiniString<string>;
|
|
40
|
+
required: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
41
|
+
}, z.core.$strip>], "type">>;
|
|
42
|
+
submitLabel: z.ZodMiniPrefault<z.ZodMiniString<string>>;
|
|
43
|
+
title: z.ZodMiniString<string>;
|
|
44
|
+
}, z.core.$strip>;
|
|
1
45
|
export declare const coreTriggerDefinitions: {
|
|
2
46
|
readonly automationInvoked: {
|
|
3
47
|
readonly getDetails: ({ config }: import("..").TriggerPresentationContext) => {
|
|
@@ -26,7 +70,62 @@ export declare const coreTriggerDefinitions: {
|
|
|
26
70
|
readonly name: "HTTP request";
|
|
27
71
|
readonly type: "http.request";
|
|
28
72
|
};
|
|
73
|
+
readonly dashboardRun: {
|
|
74
|
+
readonly getDetails: ({ config }: import("..").TriggerPresentationContext) => {
|
|
75
|
+
label: string;
|
|
76
|
+
value: string;
|
|
77
|
+
}[];
|
|
78
|
+
readonly icon: "automation";
|
|
79
|
+
readonly name: "Dashboard run";
|
|
80
|
+
readonly type: "dashboard.run";
|
|
81
|
+
};
|
|
29
82
|
};
|
|
83
|
+
interface DashboardRunFieldBase {
|
|
84
|
+
/** Supporting text shown below the field. */
|
|
85
|
+
description?: string;
|
|
86
|
+
/** Visible field label. */
|
|
87
|
+
label: string;
|
|
88
|
+
/** Whether the form must contain a value. Defaults to true. */
|
|
89
|
+
required?: boolean;
|
|
90
|
+
}
|
|
91
|
+
export type DashboardRunField = (DashboardRunFieldBase & {
|
|
92
|
+
maxLength?: number;
|
|
93
|
+
minLength?: number;
|
|
94
|
+
placeholder?: string;
|
|
95
|
+
type: "email" | "text" | "textarea" | "url";
|
|
96
|
+
}) | (DashboardRunFieldBase & {
|
|
97
|
+
max?: number;
|
|
98
|
+
min?: number;
|
|
99
|
+
placeholder?: string;
|
|
100
|
+
/** Increment used by the number input. Defaults to 1. */
|
|
101
|
+
step?: number;
|
|
102
|
+
type: "number";
|
|
103
|
+
}) | (DashboardRunFieldBase & {
|
|
104
|
+
options: readonly {
|
|
105
|
+
label: string;
|
|
106
|
+
value: string;
|
|
107
|
+
}[];
|
|
108
|
+
placeholder?: string;
|
|
109
|
+
type: "select";
|
|
110
|
+
}) | (DashboardRunFieldBase & {
|
|
111
|
+
type: "checkbox";
|
|
112
|
+
});
|
|
113
|
+
export interface DashboardRunConfig<TFields extends Record<string, DashboardRunField> = Record<string, DashboardRunField>> {
|
|
114
|
+
/** Supporting text shown below the form title. */
|
|
115
|
+
description?: string;
|
|
116
|
+
/** Named fields rendered in declaration order. */
|
|
117
|
+
fields: TFields;
|
|
118
|
+
/** Submit button text. Defaults to "Run". */
|
|
119
|
+
submitLabel?: string;
|
|
120
|
+
/** Form heading. */
|
|
121
|
+
title: string;
|
|
122
|
+
}
|
|
123
|
+
export interface DashboardRunEndpointOptions {
|
|
124
|
+
appOrigin: string;
|
|
125
|
+
automationId: string;
|
|
126
|
+
hookSlot: number;
|
|
127
|
+
scopePath?: readonly number[];
|
|
128
|
+
}
|
|
30
129
|
export type HttpTriggerScope = "trigger" | "automation" | "project";
|
|
31
130
|
export interface HttpTriggerEndpointOptions {
|
|
32
131
|
appOrigin: string;
|
|
@@ -48,3 +147,17 @@ export declare function getHttpTriggerEndpoint(options: HttpTriggerEndpointOptio
|
|
|
48
147
|
* @param options - Trigger and owning resource identity.
|
|
49
148
|
*/
|
|
50
149
|
export declare function getHttpTriggerEndpointKey(options: Omit<HttpTriggerEndpointOptions, "appOrigin">): string;
|
|
150
|
+
/**
|
|
151
|
+
* Returns the organization-authenticated submission endpoint for one dashboard
|
|
152
|
+
* run.
|
|
153
|
+
*
|
|
154
|
+
* @param options - Public origin and trigger identity.
|
|
155
|
+
*/
|
|
156
|
+
export declare function getDashboardRunEndpoint(options: DashboardRunEndpointOptions): string;
|
|
157
|
+
/**
|
|
158
|
+
* Returns the durable endpoint identity for one dashboard run trigger.
|
|
159
|
+
*
|
|
160
|
+
* @param options - Trigger and owning automation identity.
|
|
161
|
+
*/
|
|
162
|
+
export declare function getDashboardRunEndpointKey(options: Omit<DashboardRunEndpointOptions, "appOrigin">): string;
|
|
163
|
+
export {};
|
package/dist/triggers/core.js
CHANGED
|
@@ -9,6 +9,60 @@ const HTTP_PRESENTATION_CONFIG_SCHEMA = z.object({
|
|
|
9
9
|
const INVOCATION_PRESENTATION_CONFIG_SCHEMA = z.object({
|
|
10
10
|
entrypoint: z.string(),
|
|
11
11
|
});
|
|
12
|
+
const FIELD_NAME_SCHEMA = z
|
|
13
|
+
.string()
|
|
14
|
+
.check(z.trim(), z.minLength(1), z.maxLength(100));
|
|
15
|
+
const FIELD_LABEL_SCHEMA = z
|
|
16
|
+
.string()
|
|
17
|
+
.check(z.trim(), z.minLength(1), z.maxLength(255));
|
|
18
|
+
const FIELD_DESCRIPTION_SCHEMA = z.string().check(z.maxLength(2_000));
|
|
19
|
+
const FIELD_LENGTH_SCHEMA = z.int().check(z.nonnegative());
|
|
20
|
+
const DASHBOARD_RUN_FIELD_BASE_SCHEMA = {
|
|
21
|
+
description: z.optional(FIELD_DESCRIPTION_SCHEMA),
|
|
22
|
+
label: FIELD_LABEL_SCHEMA,
|
|
23
|
+
required: z.prefault(z.boolean(), true),
|
|
24
|
+
};
|
|
25
|
+
const DASHBOARD_RUN_TEXT_FIELD_SCHEMA = z.object({
|
|
26
|
+
...DASHBOARD_RUN_FIELD_BASE_SCHEMA,
|
|
27
|
+
maxLength: z.optional(FIELD_LENGTH_SCHEMA),
|
|
28
|
+
minLength: z.optional(FIELD_LENGTH_SCHEMA),
|
|
29
|
+
placeholder: z.optional(z.string()),
|
|
30
|
+
type: z.enum(["email", "text", "textarea", "url"]),
|
|
31
|
+
});
|
|
32
|
+
const DASHBOARD_RUN_NUMBER_FIELD_SCHEMA = z.object({
|
|
33
|
+
...DASHBOARD_RUN_FIELD_BASE_SCHEMA,
|
|
34
|
+
max: z.optional(z.number()),
|
|
35
|
+
min: z.optional(z.number()),
|
|
36
|
+
placeholder: z.optional(z.string()),
|
|
37
|
+
step: z.prefault(z.number().check(z.positive()), 1),
|
|
38
|
+
type: z.literal("number"),
|
|
39
|
+
});
|
|
40
|
+
const DASHBOARD_RUN_SELECT_FIELD_SCHEMA = z.object({
|
|
41
|
+
...DASHBOARD_RUN_FIELD_BASE_SCHEMA,
|
|
42
|
+
options: z
|
|
43
|
+
.array(z.object({
|
|
44
|
+
label: FIELD_LABEL_SCHEMA,
|
|
45
|
+
value: FIELD_NAME_SCHEMA,
|
|
46
|
+
}))
|
|
47
|
+
.check(z.minLength(1)),
|
|
48
|
+
placeholder: z.optional(z.string()),
|
|
49
|
+
type: z.literal("select"),
|
|
50
|
+
});
|
|
51
|
+
const DASHBOARD_RUN_CHECKBOX_FIELD_SCHEMA = z.object({
|
|
52
|
+
...DASHBOARD_RUN_FIELD_BASE_SCHEMA,
|
|
53
|
+
type: z.literal("checkbox"),
|
|
54
|
+
});
|
|
55
|
+
export const DASHBOARD_RUN_CONFIG_SCHEMA = z.object({
|
|
56
|
+
description: z.optional(FIELD_DESCRIPTION_SCHEMA),
|
|
57
|
+
fields: z.record(FIELD_NAME_SCHEMA, z.discriminatedUnion("type", [
|
|
58
|
+
DASHBOARD_RUN_TEXT_FIELD_SCHEMA,
|
|
59
|
+
DASHBOARD_RUN_NUMBER_FIELD_SCHEMA,
|
|
60
|
+
DASHBOARD_RUN_SELECT_FIELD_SCHEMA,
|
|
61
|
+
DASHBOARD_RUN_CHECKBOX_FIELD_SCHEMA,
|
|
62
|
+
])),
|
|
63
|
+
submitLabel: z.prefault(z.string().check(z.trim(), z.minLength(1), z.maxLength(100)), "Run"),
|
|
64
|
+
title: z.string().check(z.trim(), z.minLength(1), z.maxLength(255)),
|
|
65
|
+
});
|
|
12
66
|
export const coreTriggerDefinitions = {
|
|
13
67
|
automationInvoked: {
|
|
14
68
|
getDetails: ({ config }) => [
|
|
@@ -49,6 +103,17 @@ export const coreTriggerDefinitions = {
|
|
|
49
103
|
name: "HTTP request",
|
|
50
104
|
type: "http.request",
|
|
51
105
|
},
|
|
106
|
+
dashboardRun: {
|
|
107
|
+
getDetails: ({ config }) => [
|
|
108
|
+
{
|
|
109
|
+
label: "Run form",
|
|
110
|
+
value: DASHBOARD_RUN_CONFIG_SCHEMA.parse(config).title,
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
icon: "automation",
|
|
114
|
+
name: "Dashboard run",
|
|
115
|
+
type: "dashboard.run",
|
|
116
|
+
},
|
|
52
117
|
};
|
|
53
118
|
/**
|
|
54
119
|
* Returns the public URL for one deployed HTTP trigger.
|
|
@@ -73,3 +138,23 @@ export function getHttpTriggerEndpointKey(options) {
|
|
|
73
138
|
options.hookSlot,
|
|
74
139
|
].join(".")}`;
|
|
75
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Returns the organization-authenticated submission endpoint for one dashboard
|
|
143
|
+
* run.
|
|
144
|
+
*
|
|
145
|
+
* @param options - Public origin and trigger identity.
|
|
146
|
+
*/
|
|
147
|
+
export function getDashboardRunEndpoint(options) {
|
|
148
|
+
return new URL(`/api/dashboard-runs/${getDashboardRunEndpointKey(options)}`, options.appOrigin).toString();
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Returns the durable endpoint identity for one dashboard run trigger.
|
|
152
|
+
*
|
|
153
|
+
* @param options - Trigger and owning automation identity.
|
|
154
|
+
*/
|
|
155
|
+
export function getDashboardRunEndpointKey(options) {
|
|
156
|
+
return `${options.automationId}:${[
|
|
157
|
+
...(options.scopePath ?? []),
|
|
158
|
+
options.hookSlot,
|
|
159
|
+
].join(".")}`;
|
|
160
|
+
}
|
package/dist/triggers/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TriggerDefinition, TriggerPresentation, TriggerPresentationContext, TriggerScopePresentation } from "../types.js";
|
|
2
|
-
export { getHttpTriggerEndpoint, getHttpTriggerEndpointKey, type HttpTriggerEndpointOptions, type HttpTriggerScope, } from "./core.js";
|
|
2
|
+
export { getDashboardRunEndpoint, getDashboardRunEndpointKey, getHttpTriggerEndpoint, getHttpTriggerEndpointKey, DASHBOARD_RUN_CONFIG_SCHEMA, type DashboardRunConfig, type DashboardRunEndpointOptions, type DashboardRunField, type HttpTriggerEndpointOptions, type HttpTriggerScope, } from "./core.js";
|
|
3
3
|
/** Plain shared definitions for every public trigger type. */
|
|
4
4
|
export declare const triggerDefinitions: {
|
|
5
5
|
readonly whatsappMessageDelivered: {
|
|
@@ -1075,6 +1075,15 @@ export declare const triggerDefinitions: {
|
|
|
1075
1075
|
readonly name: "HTTP request";
|
|
1076
1076
|
readonly type: "http.request";
|
|
1077
1077
|
};
|
|
1078
|
+
readonly dashboardRun: {
|
|
1079
|
+
readonly getDetails: ({ config }: TriggerPresentationContext) => {
|
|
1080
|
+
label: string;
|
|
1081
|
+
value: string;
|
|
1082
|
+
}[];
|
|
1083
|
+
readonly icon: "automation";
|
|
1084
|
+
readonly name: "Dashboard run";
|
|
1085
|
+
readonly type: "dashboard.run";
|
|
1086
|
+
};
|
|
1078
1087
|
readonly brevoTransactionalBlocked: {
|
|
1079
1088
|
readonly account: {
|
|
1080
1089
|
readonly connectionOptions: readonly [{
|
|
@@ -1555,6 +1564,14 @@ export declare const triggerCatalog: ({
|
|
|
1555
1564
|
};
|
|
1556
1565
|
icon: "webhook";
|
|
1557
1566
|
type: "http.request";
|
|
1567
|
+
} | {
|
|
1568
|
+
name: string;
|
|
1569
|
+
getDetails: ({ config }: TriggerPresentationContext) => {
|
|
1570
|
+
label: string;
|
|
1571
|
+
value: string;
|
|
1572
|
+
}[];
|
|
1573
|
+
icon: "automation";
|
|
1574
|
+
type: "dashboard.run";
|
|
1558
1575
|
} | {
|
|
1559
1576
|
name: string;
|
|
1560
1577
|
account: {
|
package/dist/triggers/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import { trelloTriggerDefinitions } from "./trello.js";
|
|
|
12
12
|
import { vercelTriggerDefinitions } from "./vercel.js";
|
|
13
13
|
import { whatsappTriggerDefinitions } from "./whatsapp.js";
|
|
14
14
|
import { getIntegrationService } from "../catalog.js";
|
|
15
|
-
export { getHttpTriggerEndpoint, getHttpTriggerEndpointKey, } from "./core.js";
|
|
15
|
+
export { getDashboardRunEndpoint, getDashboardRunEndpointKey, getHttpTriggerEndpoint, getHttpTriggerEndpointKey, DASHBOARD_RUN_CONFIG_SCHEMA, } from "./core.js";
|
|
16
16
|
/** Plain shared definitions for every public trigger type. */
|
|
17
17
|
export const triggerDefinitions = {
|
|
18
18
|
...airtableTriggerDefinitions,
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -57,14 +57,20 @@ export {
|
|
|
57
57
|
type TriggerPresentationValue,
|
|
58
58
|
} from "./types"
|
|
59
59
|
export {
|
|
60
|
+
getDashboardRunEndpoint,
|
|
61
|
+
getDashboardRunEndpointKey,
|
|
60
62
|
getHttpTriggerEndpoint,
|
|
61
63
|
getHttpTriggerEndpointKey,
|
|
64
|
+
DASHBOARD_RUN_CONFIG_SCHEMA,
|
|
62
65
|
getTriggerDefinition,
|
|
63
66
|
getTriggerName,
|
|
64
67
|
getTriggerPresentation,
|
|
65
68
|
isTriggerVisible,
|
|
66
69
|
triggerCatalog,
|
|
67
70
|
triggerDefinitions,
|
|
71
|
+
type DashboardRunConfig,
|
|
72
|
+
type DashboardRunEndpointOptions,
|
|
73
|
+
type DashboardRunField,
|
|
68
74
|
type HttpTriggerEndpointOptions,
|
|
69
75
|
type HttpTriggerScope,
|
|
70
76
|
type TriggerType,
|
package/src/triggers/core.ts
CHANGED
|
@@ -11,6 +11,69 @@ const HTTP_PRESENTATION_CONFIG_SCHEMA = z.object({
|
|
|
11
11
|
const INVOCATION_PRESENTATION_CONFIG_SCHEMA = z.object({
|
|
12
12
|
entrypoint: z.string(),
|
|
13
13
|
})
|
|
14
|
+
const FIELD_NAME_SCHEMA = z
|
|
15
|
+
.string()
|
|
16
|
+
.check(z.trim(), z.minLength(1), z.maxLength(100))
|
|
17
|
+
const FIELD_LABEL_SCHEMA = z
|
|
18
|
+
.string()
|
|
19
|
+
.check(z.trim(), z.minLength(1), z.maxLength(255))
|
|
20
|
+
const FIELD_DESCRIPTION_SCHEMA = z.string().check(z.maxLength(2_000))
|
|
21
|
+
const FIELD_LENGTH_SCHEMA = z.int().check(z.nonnegative())
|
|
22
|
+
const DASHBOARD_RUN_FIELD_BASE_SCHEMA = {
|
|
23
|
+
description: z.optional(FIELD_DESCRIPTION_SCHEMA),
|
|
24
|
+
label: FIELD_LABEL_SCHEMA,
|
|
25
|
+
required: z.prefault(z.boolean(), true),
|
|
26
|
+
}
|
|
27
|
+
const DASHBOARD_RUN_TEXT_FIELD_SCHEMA = z.object({
|
|
28
|
+
...DASHBOARD_RUN_FIELD_BASE_SCHEMA,
|
|
29
|
+
maxLength: z.optional(FIELD_LENGTH_SCHEMA),
|
|
30
|
+
minLength: z.optional(FIELD_LENGTH_SCHEMA),
|
|
31
|
+
placeholder: z.optional(z.string()),
|
|
32
|
+
type: z.enum(["email", "text", "textarea", "url"]),
|
|
33
|
+
})
|
|
34
|
+
const DASHBOARD_RUN_NUMBER_FIELD_SCHEMA = z.object({
|
|
35
|
+
...DASHBOARD_RUN_FIELD_BASE_SCHEMA,
|
|
36
|
+
max: z.optional(z.number()),
|
|
37
|
+
min: z.optional(z.number()),
|
|
38
|
+
placeholder: z.optional(z.string()),
|
|
39
|
+
step: z.prefault(z.number().check(z.positive()), 1),
|
|
40
|
+
type: z.literal("number"),
|
|
41
|
+
})
|
|
42
|
+
const DASHBOARD_RUN_SELECT_FIELD_SCHEMA = z.object({
|
|
43
|
+
...DASHBOARD_RUN_FIELD_BASE_SCHEMA,
|
|
44
|
+
options: z
|
|
45
|
+
.array(
|
|
46
|
+
z.object({
|
|
47
|
+
label: FIELD_LABEL_SCHEMA,
|
|
48
|
+
value: FIELD_NAME_SCHEMA,
|
|
49
|
+
}),
|
|
50
|
+
)
|
|
51
|
+
.check(z.minLength(1)),
|
|
52
|
+
placeholder: z.optional(z.string()),
|
|
53
|
+
type: z.literal("select"),
|
|
54
|
+
})
|
|
55
|
+
const DASHBOARD_RUN_CHECKBOX_FIELD_SCHEMA = z.object({
|
|
56
|
+
...DASHBOARD_RUN_FIELD_BASE_SCHEMA,
|
|
57
|
+
type: z.literal("checkbox"),
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
export const DASHBOARD_RUN_CONFIG_SCHEMA = z.object({
|
|
61
|
+
description: z.optional(FIELD_DESCRIPTION_SCHEMA),
|
|
62
|
+
fields: z.record(
|
|
63
|
+
FIELD_NAME_SCHEMA,
|
|
64
|
+
z.discriminatedUnion("type", [
|
|
65
|
+
DASHBOARD_RUN_TEXT_FIELD_SCHEMA,
|
|
66
|
+
DASHBOARD_RUN_NUMBER_FIELD_SCHEMA,
|
|
67
|
+
DASHBOARD_RUN_SELECT_FIELD_SCHEMA,
|
|
68
|
+
DASHBOARD_RUN_CHECKBOX_FIELD_SCHEMA,
|
|
69
|
+
]),
|
|
70
|
+
),
|
|
71
|
+
submitLabel: z.prefault(
|
|
72
|
+
z.string().check(z.trim(), z.minLength(1), z.maxLength(100)),
|
|
73
|
+
"Run",
|
|
74
|
+
),
|
|
75
|
+
title: z.string().check(z.trim(), z.minLength(1), z.maxLength(255)),
|
|
76
|
+
})
|
|
14
77
|
|
|
15
78
|
export const coreTriggerDefinitions = {
|
|
16
79
|
automationInvoked: {
|
|
@@ -60,8 +123,81 @@ export const coreTriggerDefinitions = {
|
|
|
60
123
|
name: "HTTP request",
|
|
61
124
|
type: "http.request",
|
|
62
125
|
},
|
|
126
|
+
dashboardRun: {
|
|
127
|
+
getDetails: ({ config }) => [
|
|
128
|
+
{
|
|
129
|
+
label: "Run form",
|
|
130
|
+
value: DASHBOARD_RUN_CONFIG_SCHEMA.parse(config).title,
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
icon: "automation",
|
|
134
|
+
name: "Dashboard run",
|
|
135
|
+
type: "dashboard.run",
|
|
136
|
+
},
|
|
63
137
|
} as const satisfies Record<string, TriggerDefinition>
|
|
64
138
|
|
|
139
|
+
interface DashboardRunFieldBase {
|
|
140
|
+
/** Supporting text shown below the field. */
|
|
141
|
+
description?: string
|
|
142
|
+
|
|
143
|
+
/** Visible field label. */
|
|
144
|
+
label: string
|
|
145
|
+
|
|
146
|
+
/** Whether the form must contain a value. Defaults to true. */
|
|
147
|
+
required?: boolean
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export type DashboardRunField =
|
|
151
|
+
| (DashboardRunFieldBase & {
|
|
152
|
+
maxLength?: number
|
|
153
|
+
minLength?: number
|
|
154
|
+
placeholder?: string
|
|
155
|
+
type: "email" | "text" | "textarea" | "url"
|
|
156
|
+
})
|
|
157
|
+
| (DashboardRunFieldBase & {
|
|
158
|
+
max?: number
|
|
159
|
+
min?: number
|
|
160
|
+
placeholder?: string
|
|
161
|
+
|
|
162
|
+
/** Increment used by the number input. Defaults to 1. */
|
|
163
|
+
step?: number
|
|
164
|
+
type: "number"
|
|
165
|
+
})
|
|
166
|
+
| (DashboardRunFieldBase & {
|
|
167
|
+
options: readonly { label: string; value: string }[]
|
|
168
|
+
placeholder?: string
|
|
169
|
+
type: "select"
|
|
170
|
+
})
|
|
171
|
+
| (DashboardRunFieldBase & {
|
|
172
|
+
type: "checkbox"
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
export interface DashboardRunConfig<
|
|
176
|
+
TFields extends Record<string, DashboardRunField> = Record<
|
|
177
|
+
string,
|
|
178
|
+
DashboardRunField
|
|
179
|
+
>,
|
|
180
|
+
> {
|
|
181
|
+
/** Supporting text shown below the form title. */
|
|
182
|
+
description?: string
|
|
183
|
+
|
|
184
|
+
/** Named fields rendered in declaration order. */
|
|
185
|
+
fields: TFields
|
|
186
|
+
|
|
187
|
+
/** Submit button text. Defaults to "Run". */
|
|
188
|
+
submitLabel?: string
|
|
189
|
+
|
|
190
|
+
/** Form heading. */
|
|
191
|
+
title: string
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface DashboardRunEndpointOptions {
|
|
195
|
+
appOrigin: string
|
|
196
|
+
automationId: string
|
|
197
|
+
hookSlot: number
|
|
198
|
+
scopePath?: readonly number[]
|
|
199
|
+
}
|
|
200
|
+
|
|
65
201
|
export type HttpTriggerScope = "trigger" | "automation" | "project"
|
|
66
202
|
|
|
67
203
|
export interface HttpTriggerEndpointOptions {
|
|
@@ -100,3 +236,30 @@ export function getHttpTriggerEndpointKey(
|
|
|
100
236
|
options.hookSlot,
|
|
101
237
|
].join(".")}`
|
|
102
238
|
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Returns the organization-authenticated submission endpoint for one dashboard
|
|
242
|
+
* run.
|
|
243
|
+
*
|
|
244
|
+
* @param options - Public origin and trigger identity.
|
|
245
|
+
*/
|
|
246
|
+
export function getDashboardRunEndpoint(options: DashboardRunEndpointOptions) {
|
|
247
|
+
return new URL(
|
|
248
|
+
`/api/dashboard-runs/${getDashboardRunEndpointKey(options)}`,
|
|
249
|
+
options.appOrigin,
|
|
250
|
+
).toString()
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Returns the durable endpoint identity for one dashboard run trigger.
|
|
255
|
+
*
|
|
256
|
+
* @param options - Trigger and owning automation identity.
|
|
257
|
+
*/
|
|
258
|
+
export function getDashboardRunEndpointKey(
|
|
259
|
+
options: Omit<DashboardRunEndpointOptions, "appOrigin">,
|
|
260
|
+
) {
|
|
261
|
+
return `${options.automationId}:${[
|
|
262
|
+
...(options.scopePath ?? []),
|
|
263
|
+
options.hookSlot,
|
|
264
|
+
].join(".")}`
|
|
265
|
+
}
|
package/src/triggers/index.ts
CHANGED
|
@@ -20,8 +20,14 @@ import type {
|
|
|
20
20
|
} from "../types"
|
|
21
21
|
|
|
22
22
|
export {
|
|
23
|
+
getDashboardRunEndpoint,
|
|
24
|
+
getDashboardRunEndpointKey,
|
|
23
25
|
getHttpTriggerEndpoint,
|
|
24
26
|
getHttpTriggerEndpointKey,
|
|
27
|
+
DASHBOARD_RUN_CONFIG_SCHEMA,
|
|
28
|
+
type DashboardRunConfig,
|
|
29
|
+
type DashboardRunEndpointOptions,
|
|
30
|
+
type DashboardRunField,
|
|
25
31
|
type HttpTriggerEndpointOptions,
|
|
26
32
|
type HttpTriggerScope,
|
|
27
33
|
} from "./core"
|