@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.
Files changed (52) hide show
  1. package/dist/authoring.d.ts +1 -0
  2. package/dist/authoring.js +1 -0
  3. package/dist/triggers/airtable.js +1 -2
  4. package/dist/triggers/asana.js +1 -2
  5. package/dist/triggers/brevo.js +1 -2
  6. package/dist/triggers/core-dashboard.d.ts +374 -0
  7. package/dist/triggers/core-dashboard.js +202 -0
  8. package/dist/triggers/core-http.d.ts +30 -0
  9. package/dist/triggers/core-http.js +43 -0
  10. package/dist/triggers/core-invocation.d.ts +9 -0
  11. package/dist/triggers/core-invocation.js +15 -0
  12. package/dist/triggers/core-mailhook.d.ts +35 -0
  13. package/dist/triggers/core-mailhook.js +63 -0
  14. package/dist/triggers/core-schedule.d.ts +9 -0
  15. package/dist/triggers/core-schedule.js +17 -0
  16. package/dist/triggers/core.d.ts +15 -426
  17. package/dist/triggers/core.js +16 -346
  18. package/dist/triggers/github.js +4 -5
  19. package/dist/triggers/google.js +4 -5
  20. package/dist/triggers/index.d.ts +20 -20
  21. package/dist/triggers/index.js +2 -1
  22. package/dist/triggers/linear.js +1 -2
  23. package/dist/triggers/microsoft.js +3 -4
  24. package/dist/triggers/name.d.ts +13 -0
  25. package/dist/triggers/name.js +31 -0
  26. package/dist/triggers/resend.js +1 -2
  27. package/dist/triggers/slack.js +3 -4
  28. package/dist/triggers/trello.js +1 -2
  29. package/dist/triggers/vercel.js +5 -6
  30. package/dist/triggers/whatsapp.js +1 -2
  31. package/package.json +118 -5
  32. package/src/authoring.ts +8 -0
  33. package/src/triggers/airtable.ts +1 -2
  34. package/src/triggers/asana.ts +1 -2
  35. package/src/triggers/brevo.ts +1 -2
  36. package/src/triggers/core-dashboard.ts +361 -0
  37. package/src/triggers/core-http.ts +69 -0
  38. package/src/triggers/core-invocation.ts +18 -0
  39. package/src/triggers/core-mailhook.ts +83 -0
  40. package/src/triggers/core-schedule.ts +21 -0
  41. package/src/triggers/core.ts +38 -544
  42. package/src/triggers/github.ts +4 -5
  43. package/src/triggers/google.ts +4 -5
  44. package/src/triggers/index.ts +2 -1
  45. package/src/triggers/linear.ts +1 -2
  46. package/src/triggers/microsoft.ts +3 -4
  47. package/src/triggers/name.ts +37 -0
  48. package/src/triggers/resend.ts +1 -2
  49. package/src/triggers/slack.ts +3 -4
  50. package/src/triggers/trello.ts +1 -2
  51. package/src/triggers/vercel.ts +5 -6
  52. 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