@automate.ax/catalog 0.75.0 → 0.76.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/authoring.d.ts +1 -0
- package/dist/authoring.js +1 -0
- package/dist/triggers/airtable.js +1 -2
- package/dist/triggers/asana.js +1 -2
- package/dist/triggers/brevo.js +1 -2
- package/dist/triggers/core-dashboard.d.ts +374 -0
- package/dist/triggers/core-dashboard.js +202 -0
- package/dist/triggers/core-http.d.ts +30 -0
- package/dist/triggers/core-http.js +43 -0
- package/dist/triggers/core-invocation.d.ts +9 -0
- package/dist/triggers/core-invocation.js +15 -0
- package/dist/triggers/core-mailhook.d.ts +35 -0
- package/dist/triggers/core-mailhook.js +63 -0
- package/dist/triggers/core-schedule.d.ts +9 -0
- package/dist/triggers/core-schedule.js +17 -0
- package/dist/triggers/core.d.ts +15 -426
- package/dist/triggers/core.js +16 -346
- package/dist/triggers/github.js +4 -5
- package/dist/triggers/google.js +4 -5
- package/dist/triggers/index.d.ts +20 -20
- package/dist/triggers/index.js +2 -1
- package/dist/triggers/linear.js +1 -2
- package/dist/triggers/microsoft.js +3 -4
- package/dist/triggers/name.d.ts +13 -0
- package/dist/triggers/name.js +31 -0
- package/dist/triggers/resend.js +1 -2
- package/dist/triggers/slack.js +3 -4
- package/dist/triggers/trello.js +1 -2
- package/dist/triggers/vercel.js +5 -6
- package/dist/triggers/whatsapp.js +1 -2
- package/package.json +118 -5
- package/src/authoring.ts +8 -0
- package/src/triggers/airtable.ts +1 -2
- package/src/triggers/asana.ts +1 -2
- package/src/triggers/brevo.ts +1 -2
- package/src/triggers/core-dashboard.ts +361 -0
- package/src/triggers/core-http.ts +69 -0
- package/src/triggers/core-invocation.ts +18 -0
- package/src/triggers/core-mailhook.ts +83 -0
- package/src/triggers/core-schedule.ts +21 -0
- package/src/triggers/core.ts +38 -544
- package/src/triggers/github.ts +4 -5
- package/src/triggers/google.ts +4 -5
- package/src/triggers/index.ts +2 -1
- package/src/triggers/linear.ts +1 -2
- package/src/triggers/microsoft.ts +3 -4
- package/src/triggers/name.ts +37 -0
- package/src/triggers/resend.ts +1 -2
- package/src/triggers/slack.ts +3 -4
- package/src/triggers/trello.ts +1 -2
- package/src/triggers/vercel.ts +5 -6
- package/src/triggers/whatsapp.ts +1 -2
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { TriggerDefinition } from "../types"
|
|
2
|
+
import * as z from "zod/mini"
|
|
3
|
+
|
|
4
|
+
const HTTP_PRESENTATION_CONFIG_SCHEMA = z.object({
|
|
5
|
+
scope: z.prefault(z.enum(["trigger", "automation", "project"]), "trigger"),
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
export const httpRequestTriggerDefinition = {
|
|
9
|
+
getPrimary: ({
|
|
10
|
+
appOrigin,
|
|
11
|
+
automationId,
|
|
12
|
+
config,
|
|
13
|
+
hookSlot,
|
|
14
|
+
projectId,
|
|
15
|
+
scopePath,
|
|
16
|
+
}) => ({
|
|
17
|
+
copyable: true,
|
|
18
|
+
value: getHttpTriggerEndpoint({
|
|
19
|
+
appOrigin,
|
|
20
|
+
automationId,
|
|
21
|
+
hookSlot,
|
|
22
|
+
projectId,
|
|
23
|
+
scope: HTTP_PRESENTATION_CONFIG_SCHEMA.parse(config).scope,
|
|
24
|
+
scopePath,
|
|
25
|
+
}),
|
|
26
|
+
}),
|
|
27
|
+
icon: "webhook",
|
|
28
|
+
name: "HTTP request",
|
|
29
|
+
type: "http.request",
|
|
30
|
+
} as const satisfies TriggerDefinition
|
|
31
|
+
|
|
32
|
+
export type HttpTriggerScope = "trigger" | "automation" | "project"
|
|
33
|
+
|
|
34
|
+
export interface HttpTriggerEndpointOptions {
|
|
35
|
+
appOrigin: string
|
|
36
|
+
automationId: string
|
|
37
|
+
hookSlot: number
|
|
38
|
+
projectId: string
|
|
39
|
+
scope: HttpTriggerScope
|
|
40
|
+
scopePath?: readonly number[]
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Returns the public URL for one deployed HTTP trigger.
|
|
45
|
+
*
|
|
46
|
+
* @param options - Public origin and trigger identity.
|
|
47
|
+
*/
|
|
48
|
+
export function getHttpTriggerEndpoint(options: HttpTriggerEndpointOptions) {
|
|
49
|
+
return new URL(
|
|
50
|
+
`/x/${getHttpTriggerEndpointKey(options)}/`,
|
|
51
|
+
options.appOrigin,
|
|
52
|
+
).toString()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Returns the durable endpoint identity for one configured HTTP scope.
|
|
57
|
+
*
|
|
58
|
+
* @param options - Trigger and owning resource identity.
|
|
59
|
+
*/
|
|
60
|
+
export function getHttpTriggerEndpointKey(
|
|
61
|
+
options: Omit<HttpTriggerEndpointOptions, "appOrigin">,
|
|
62
|
+
) {
|
|
63
|
+
if (options.scope === "project") return options.projectId
|
|
64
|
+
if (options.scope === "automation") return options.automationId
|
|
65
|
+
return `${options.automationId}:${[
|
|
66
|
+
...(options.scopePath ?? []),
|
|
67
|
+
options.hookSlot,
|
|
68
|
+
].join(".")}`
|
|
69
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { TriggerDefinition } from "../types"
|
|
2
|
+
import * as z from "zod/mini"
|
|
3
|
+
|
|
4
|
+
const INVOCATION_PRESENTATION_CONFIG_SCHEMA = z.object({
|
|
5
|
+
entrypoint: z.string(),
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
export const automationInvokedTriggerDefinition = {
|
|
9
|
+
getDetails: ({ config }) => [
|
|
10
|
+
{
|
|
11
|
+
label: "Entrypoint",
|
|
12
|
+
value: INVOCATION_PRESENTATION_CONFIG_SCHEMA.parse(config).entrypoint,
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
icon: "automation",
|
|
16
|
+
name: "Invocation",
|
|
17
|
+
type: "automation.invoked",
|
|
18
|
+
} as const satisfies TriggerDefinition
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { TriggerDefinition } from "../types"
|
|
2
|
+
import type { HttpTriggerScope } from "./core-http"
|
|
3
|
+
import * as z from "zod/mini"
|
|
4
|
+
|
|
5
|
+
const MAX_EMAIL_LOCAL_PART_BYTES = 64
|
|
6
|
+
const EMAIL_SCHEMA = z.email()
|
|
7
|
+
const MAILHOOK_PRESENTATION_CONFIG_SCHEMA = z.object({
|
|
8
|
+
scope: z.prefault(z.enum(["trigger", "automation", "project"]), "trigger"),
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
export const PLATFORM_EMAIL_DOMAIN = "automations.automate.ax"
|
|
12
|
+
|
|
13
|
+
export const mailhookEmailReceivedTriggerDefinition = {
|
|
14
|
+
getPrimary: ({ automationId, config, hookSlot, projectId, scopePath }) => ({
|
|
15
|
+
copyable: true,
|
|
16
|
+
value: getMailhookAddress({
|
|
17
|
+
automationId,
|
|
18
|
+
hookSlot,
|
|
19
|
+
projectId,
|
|
20
|
+
scope: MAILHOOK_PRESENTATION_CONFIG_SCHEMA.parse(config).scope,
|
|
21
|
+
scopePath,
|
|
22
|
+
}),
|
|
23
|
+
}),
|
|
24
|
+
icon: "webhook",
|
|
25
|
+
name: "Mailhook",
|
|
26
|
+
type: "mailhook.email.received",
|
|
27
|
+
} as const satisfies TriggerDefinition
|
|
28
|
+
|
|
29
|
+
export type MailhookScope = HttpTriggerScope
|
|
30
|
+
|
|
31
|
+
export interface MailhookAddressOptions {
|
|
32
|
+
automationId: string
|
|
33
|
+
hookSlot: number
|
|
34
|
+
plusPath?: string
|
|
35
|
+
projectId: string
|
|
36
|
+
scope: MailhookScope
|
|
37
|
+
scopePath?: readonly number[]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns the unique inbound address for one deployed mailhook.
|
|
42
|
+
*
|
|
43
|
+
* Add `+suffix` before the `@` to carry a routing value into the event.
|
|
44
|
+
*
|
|
45
|
+
* @param options - Mailhook identity and sharing scope.
|
|
46
|
+
* @throws When the generated local part exceeds the email size limit.
|
|
47
|
+
*/
|
|
48
|
+
export function getMailhookAddress(options: MailhookAddressOptions) {
|
|
49
|
+
const localPart = `${getMailhookAddressKey(options)}${options.plusPath ? `+${options.plusPath}` : ""}`
|
|
50
|
+
if (new TextEncoder().encode(localPart).length > MAX_EMAIL_LOCAL_PART_BYTES) {
|
|
51
|
+
throw new RangeError("Mailhook address local part exceeds 64 bytes.")
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return EMAIL_SCHEMA.parse(`${localPart}@${PLATFORM_EMAIL_DOMAIN}`)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Returns the local-part router key for one configured mailhook scope.
|
|
59
|
+
*
|
|
60
|
+
* @param options - Mailhook identity and sharing scope.
|
|
61
|
+
*/
|
|
62
|
+
export function getMailhookAddressKey(options: MailhookAddressOptions) {
|
|
63
|
+
if (options.scope === "project") return `p${typeIdSuffix(options.projectId)}`
|
|
64
|
+
if (options.scope === "automation") {
|
|
65
|
+
return `a${typeIdSuffix(options.automationId)}`
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return `a${typeIdSuffix(options.automationId)}.${[
|
|
69
|
+
...(options.scopePath ?? []),
|
|
70
|
+
options.hookSlot,
|
|
71
|
+
]
|
|
72
|
+
.map((segment) => segment.toString(36))
|
|
73
|
+
.join(".")}`
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Removes the redundant TypeID prefix from an address router.
|
|
78
|
+
*
|
|
79
|
+
* @param id - Project or automation TypeID.
|
|
80
|
+
*/
|
|
81
|
+
function typeIdSuffix(id: string) {
|
|
82
|
+
return id.includes("_") ? id.slice(id.indexOf("_") + 1) : id
|
|
83
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TriggerDefinition } from "../types"
|
|
2
|
+
import * as z from "zod/mini"
|
|
3
|
+
|
|
4
|
+
const CRON_PRESENTATION_CONFIG_SCHEMA = z.object({
|
|
5
|
+
schedule: z.string(),
|
|
6
|
+
timeZone: z.prefault(z.string(), "UTC"),
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
export const cronTickTriggerDefinition = {
|
|
10
|
+
getDetails: ({ config }) => {
|
|
11
|
+
const parsedConfig = CRON_PRESENTATION_CONFIG_SCHEMA.parse(config)
|
|
12
|
+
|
|
13
|
+
return [
|
|
14
|
+
{ label: "Schedule", value: parsedConfig.schedule },
|
|
15
|
+
{ label: "Time zone", value: parsedConfig.timeZone },
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
icon: "schedule",
|
|
19
|
+
name: "Cron schedule",
|
|
20
|
+
type: "cron.tick",
|
|
21
|
+
} as const satisfies TriggerDefinition
|