@automate.ax/integration-contracts 0.99.4 → 0.101.1

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.
@@ -153,8 +153,8 @@ export declare const WHATSAPP_WEBHOOK_SCHEMA: z.ZodObject<{
153
153
  }, z.core.$strip>>;
154
154
  recipient_id: z.ZodString;
155
155
  status: z.ZodEnum<{
156
- delivered: "delivered";
157
156
  failed: "failed";
157
+ delivered: "delivered";
158
158
  sent: "sent";
159
159
  read: "read";
160
160
  played: "played";
@@ -373,8 +373,8 @@ export declare const WHATSAPP_MESSAGE_STATUS_EVENT_SCHEMA: z.ZodObject<{
373
373
  }, z.core.$strip>>;
374
374
  recipient_id: z.ZodString;
375
375
  status: z.ZodEnum<{
376
- delivered: "delivered";
377
376
  failed: "failed";
377
+ delivered: "delivered";
378
378
  sent: "sent";
379
379
  read: "read";
380
380
  played: "played";
@@ -383,8 +383,8 @@ export declare const WHATSAPP_MESSAGE_STATUS_EVENT_SCHEMA: z.ZodObject<{
383
383
  }, z.core.$strip>;
384
384
  recipientId: z.ZodString;
385
385
  status: z.ZodEnum<{
386
- delivered: "delivered";
387
386
  failed: "failed";
387
+ delivered: "delivered";
388
388
  sent: "sent";
389
389
  read: "read";
390
390
  played: "played";
@@ -871,7 +871,7 @@ export declare function normalizeWhatsAppWebhook(input: unknown): {
871
871
  providerEvent: {
872
872
  id: string;
873
873
  recipient_id: string;
874
- status: "delivered" | "failed" | "sent" | "read" | "played";
874
+ status: "failed" | "delivered" | "sent" | "read" | "played";
875
875
  timestamp: string;
876
876
  biz_opaque_callback_data?: string | undefined;
877
877
  conversation?: {
@@ -900,7 +900,7 @@ export declare function normalizeWhatsAppWebhook(input: unknown): {
900
900
  } | undefined;
901
901
  };
902
902
  recipientId: string;
903
- status: "delivered" | "failed" | "sent" | "read" | "played";
903
+ status: "failed" | "delivered" | "sent" | "read" | "played";
904
904
  timestamp: string;
905
905
  callbackData?: string | undefined;
906
906
  conversation?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automate.ax/integration-contracts",
3
- "version": "0.99.4",
3
+ "version": "0.101.1",
4
4
  "description": "Shared integration payload contracts and provider primitives for Automate.ax.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -19,6 +19,7 @@
19
19
  "zshy": {
20
20
  "exports": {
21
21
  "./airtable": "./src/airtable/index.ts",
22
+ "./automate": "./src/automate/index.ts",
22
23
  "./asana": "./src/asana/index.ts",
23
24
  "./brevo": "./src/brevo/index.ts",
24
25
  "./convex": "./src/convex/index.ts",
@@ -48,7 +49,7 @@
48
49
  }
49
50
  },
50
51
  "dependencies": {
51
- "@automate.ax/codec": "0.99.4",
52
+ "@automate.ax/codec": "0.101.1",
52
53
  "@cfworker/json-schema": "^4.1.1",
53
54
  "@googleapis/calendar": "^15.0.0",
54
55
  "@googleapis/forms": "^6.0.1",
@@ -104,6 +105,11 @@
104
105
  "types": "./dist/airtable/index.d.ts",
105
106
  "default": "./dist/airtable/index.js"
106
107
  },
108
+ "./automate": {
109
+ "bun": "./src/automate/index.ts",
110
+ "types": "./dist/automate/index.d.ts",
111
+ "default": "./dist/automate/index.js"
112
+ },
107
113
  "./asana": {
108
114
  "bun": "./src/asana/index.ts",
109
115
  "types": "./dist/asana/index.d.ts",
@@ -0,0 +1,129 @@
1
+ import * as z from "zod"
2
+
3
+ const AUTOMATE_DEPLOYMENT_STATUS_SCHEMA = z.enum([
4
+ "planning",
5
+ "awaiting_authorization",
6
+ "configuring",
7
+ "publishing",
8
+ "succeeded",
9
+ "failed",
10
+ "cancelled",
11
+ ])
12
+
13
+ const RESOURCE_REFERENCE_SCHEMA = z.object({
14
+ id: z.string().min(1),
15
+ name: z.string().min(1),
16
+ })
17
+
18
+ export const AUTOMATE_AUTOMATION_TRIGGER_CONFIG_SCHEMA = z.object({
19
+ automationId: z.string().min(1),
20
+ })
21
+
22
+ export const AUTOMATE_DEPLOYMENT_TRIGGER_CONFIG_SCHEMA = z.object({
23
+ projectId: z.string().min(1),
24
+ })
25
+
26
+ export const AUTOMATE_AUTOMATION_STATE_EVENT_SCHEMA = z.object({
27
+ automation: z.object({
28
+ description: z.string(),
29
+ id: z.string().min(1),
30
+ identityKey: z.string().min(1),
31
+ }),
32
+ enabled: z.boolean(),
33
+ organization: RESOURCE_REFERENCE_SCHEMA,
34
+ previousEnabled: z.boolean(),
35
+ project: RESOURCE_REFERENCE_SCHEMA,
36
+ transitionedAt: z.date(),
37
+ })
38
+
39
+ export const AUTOMATE_AUTOMATION_ENABLED_EVENT_SCHEMA =
40
+ AUTOMATE_AUTOMATION_STATE_EVENT_SCHEMA.extend({
41
+ enabled: z.literal(true),
42
+ previousEnabled: z.literal(false),
43
+ })
44
+
45
+ export const AUTOMATE_AUTOMATION_DISABLED_EVENT_SCHEMA =
46
+ AUTOMATE_AUTOMATION_STATE_EVENT_SCHEMA.extend({
47
+ enabled: z.literal(false),
48
+ previousEnabled: z.literal(true),
49
+ })
50
+
51
+ export const AUTOMATE_DEPLOYMENT_EVENT_SCHEMA = z.object({
52
+ deployment: z.object({
53
+ completedAt: z.date().nullable(),
54
+ createdAt: z.date(),
55
+ id: z.string().min(1),
56
+ }),
57
+ failure: z.object({ message: z.string() }).nullable(),
58
+ organization: RESOURCE_REFERENCE_SCHEMA,
59
+ previousStatus: AUTOMATE_DEPLOYMENT_STATUS_SCHEMA.nullable(),
60
+ project: RESOURCE_REFERENCE_SCHEMA,
61
+ status: AUTOMATE_DEPLOYMENT_STATUS_SCHEMA,
62
+ transitionedAt: z.date(),
63
+ })
64
+
65
+ const AUTOMATE_TERMINAL_DEPLOYMENT_EVENT_SCHEMA =
66
+ AUTOMATE_DEPLOYMENT_EVENT_SCHEMA.extend({
67
+ deployment: AUTOMATE_DEPLOYMENT_EVENT_SCHEMA.shape.deployment.extend({
68
+ completedAt: z.date(),
69
+ }),
70
+ })
71
+
72
+ export const AUTOMATE_DEPLOYMENT_AWAITING_AUTHORIZATION_EVENT_SCHEMA =
73
+ AUTOMATE_DEPLOYMENT_EVENT_SCHEMA.extend({
74
+ failure: z.null(),
75
+ status: z.literal("awaiting_authorization"),
76
+ })
77
+
78
+ export const AUTOMATE_DEPLOYMENT_CANCELLED_EVENT_SCHEMA =
79
+ AUTOMATE_TERMINAL_DEPLOYMENT_EVENT_SCHEMA.extend({
80
+ failure: z.null(),
81
+ status: z.literal("cancelled"),
82
+ })
83
+
84
+ export const AUTOMATE_DEPLOYMENT_FAILED_EVENT_SCHEMA =
85
+ AUTOMATE_TERMINAL_DEPLOYMENT_EVENT_SCHEMA.extend({
86
+ failure: z.object({ message: z.string() }),
87
+ status: z.literal("failed"),
88
+ })
89
+
90
+ export const AUTOMATE_DEPLOYMENT_SUCCEEDED_EVENT_SCHEMA =
91
+ AUTOMATE_TERMINAL_DEPLOYMENT_EVENT_SCHEMA.extend({
92
+ failure: z.null(),
93
+ status: z.literal("succeeded"),
94
+ })
95
+
96
+ export const automateTriggerContracts = {
97
+ "automate.automation.disabled": {
98
+ configSchema: AUTOMATE_AUTOMATION_TRIGGER_CONFIG_SCHEMA,
99
+ eventSchema: AUTOMATE_AUTOMATION_DISABLED_EVENT_SCHEMA,
100
+ },
101
+ "automate.automation.enabled": {
102
+ configSchema: AUTOMATE_AUTOMATION_TRIGGER_CONFIG_SCHEMA,
103
+ eventSchema: AUTOMATE_AUTOMATION_ENABLED_EVENT_SCHEMA,
104
+ },
105
+ "automate.automation.stateChanged": {
106
+ configSchema: AUTOMATE_AUTOMATION_TRIGGER_CONFIG_SCHEMA,
107
+ eventSchema: AUTOMATE_AUTOMATION_STATE_EVENT_SCHEMA,
108
+ },
109
+ "automate.deployment.awaitingAuthorization": {
110
+ configSchema: AUTOMATE_DEPLOYMENT_TRIGGER_CONFIG_SCHEMA,
111
+ eventSchema: AUTOMATE_DEPLOYMENT_AWAITING_AUTHORIZATION_EVENT_SCHEMA,
112
+ },
113
+ "automate.deployment.cancelled": {
114
+ configSchema: AUTOMATE_DEPLOYMENT_TRIGGER_CONFIG_SCHEMA,
115
+ eventSchema: AUTOMATE_DEPLOYMENT_CANCELLED_EVENT_SCHEMA,
116
+ },
117
+ "automate.deployment.event": {
118
+ configSchema: AUTOMATE_DEPLOYMENT_TRIGGER_CONFIG_SCHEMA,
119
+ eventSchema: AUTOMATE_DEPLOYMENT_EVENT_SCHEMA,
120
+ },
121
+ "automate.deployment.failed": {
122
+ configSchema: AUTOMATE_DEPLOYMENT_TRIGGER_CONFIG_SCHEMA,
123
+ eventSchema: AUTOMATE_DEPLOYMENT_FAILED_EVENT_SCHEMA,
124
+ },
125
+ "automate.deployment.succeeded": {
126
+ configSchema: AUTOMATE_DEPLOYMENT_TRIGGER_CONFIG_SCHEMA,
127
+ eventSchema: AUTOMATE_DEPLOYMENT_SUCCEEDED_EVENT_SCHEMA,
128
+ },
129
+ } as const
@@ -233,6 +233,10 @@ export const CLOSE_TRIGGER_CONFIG_SCHEMA = z.object({})
233
233
  // resource. Close's documented opportunity-won webhook is one such payload.
234
234
  const CLOSE_CALL_EVENT_DATA_SCHEMA = CLOSE_CALL_SCHEMA.partial()
235
235
  const CLOSE_COMMENT_EVENT_DATA_SCHEMA = CLOSE_COMMENT_SCHEMA.partial()
236
+ const CLOSE_COMMENT_UPDATED_EVENT_DATA_SCHEMA =
237
+ CLOSE_COMMENT_EVENT_DATA_SCHEMA.extend({
238
+ body: z.string().nullable().optional(),
239
+ })
236
240
  const CLOSE_CONTACT_EVENT_DATA_SCHEMA = CLOSE_CONTACT_SCHEMA.partial()
237
241
  const CLOSE_EMAIL_EVENT_DATA_SCHEMA = CLOSE_EMAIL_SCHEMA.partial()
238
242
  const CLOSE_LEAD_EVENT_DATA_SCHEMA = CLOSE_LEAD_SCHEMA.partial()
@@ -241,6 +245,13 @@ const CLOSE_OPPORTUNITY_EVENT_DATA_SCHEMA = CLOSE_OPPORTUNITY_SCHEMA.partial()
241
245
  const CLOSE_SEQUENCE_SUBSCRIPTION_EVENT_DATA_SCHEMA =
242
246
  CLOSE_SEQUENCE_SUBSCRIPTION_SCHEMA.partial()
243
247
  const CLOSE_SMS_EVENT_DATA_SCHEMA = CLOSE_SMS_SCHEMA.partial()
248
+ const CLOSE_DELETED_EVENT_DATA_SCHEMA = z.union([
249
+ z.null(),
250
+ z
251
+ .object({})
252
+ .strict()
253
+ .transform(() => null),
254
+ ])
244
255
  const CLOSE_TASK_EVENT_DATA_SCHEMA = z.union([
245
256
  CLOSE_TASK_SCHEMA.options[0].partial(),
246
257
  CLOSE_TASK_SCHEMA.options[1].partial(),
@@ -273,7 +284,7 @@ const SEMANTIC_EVENTS = {
273
284
  "close.comment.updated": [
274
285
  "comment",
275
286
  "updated",
276
- CLOSE_COMMENT_EVENT_DATA_SCHEMA,
287
+ CLOSE_COMMENT_UPDATED_EVENT_DATA_SCHEMA,
277
288
  ],
278
289
  "close.contact.created": [
279
290
  "contact",
@@ -449,18 +460,26 @@ export const closeTriggerContracts = {
449
460
  "created",
450
461
  CLOSE_COMMENT_EVENT_DATA_SCHEMA,
451
462
  ),
452
- "close.comment.deleted": semanticContract("comment", "deleted", z.null()),
463
+ "close.comment.deleted": semanticContract(
464
+ "comment",
465
+ "deleted",
466
+ CLOSE_DELETED_EVENT_DATA_SCHEMA,
467
+ ),
453
468
  "close.comment.updated": semanticContract(
454
469
  "comment",
455
470
  "updated",
456
- CLOSE_COMMENT_EVENT_DATA_SCHEMA,
471
+ CLOSE_COMMENT_UPDATED_EVENT_DATA_SCHEMA,
457
472
  ),
458
473
  "close.contact.created": semanticContract(
459
474
  "contact",
460
475
  "created",
461
476
  CLOSE_CONTACT_EVENT_DATA_SCHEMA,
462
477
  ),
463
- "close.contact.deleted": semanticContract("contact", "deleted", z.null()),
478
+ "close.contact.deleted": semanticContract(
479
+ "contact",
480
+ "deleted",
481
+ CLOSE_DELETED_EVENT_DATA_SCHEMA,
482
+ ),
464
483
  "close.contact.updated": semanticContract(
465
484
  "contact",
466
485
  "updated",
@@ -481,7 +500,11 @@ export const closeTriggerContracts = {
481
500
  "created",
482
501
  CLOSE_LEAD_EVENT_DATA_SCHEMA,
483
502
  ),
484
- "close.lead.deleted": semanticContract("lead", "deleted", z.null()),
503
+ "close.lead.deleted": semanticContract(
504
+ "lead",
505
+ "deleted",
506
+ CLOSE_DELETED_EVENT_DATA_SCHEMA,
507
+ ),
485
508
  "close.lead.merged": semanticContract(
486
509
  "lead",
487
510
  "merged",
@@ -520,7 +543,7 @@ export const closeTriggerContracts = {
520
543
  "close.opportunity.deleted": semanticContract(
521
544
  "opportunity",
522
545
  "deleted",
523
- z.null(),
546
+ CLOSE_DELETED_EVENT_DATA_SCHEMA,
524
547
  ),
525
548
  "close.opportunity.lost": semanticContract(
526
549
  "opportunity",
@@ -545,7 +568,7 @@ export const closeTriggerContracts = {
545
568
  "close.sequenceSubscription.deleted": semanticContract(
546
569
  "sequence_subscription",
547
570
  "deleted",
548
- z.null(),
571
+ CLOSE_DELETED_EVENT_DATA_SCHEMA,
549
572
  ),
550
573
  "close.sequenceSubscription.errored": semanticContract(
551
574
  "sequence_subscription",
@@ -592,7 +615,10 @@ export const closeTriggerContracts = {
592
615
  CLOSE_TASK_EVENT_DATA_SCHEMA,
593
616
  ),
594
617
  "close.task.created": taskContract("created", CLOSE_TASK_EVENT_DATA_SCHEMA),
595
- "close.task.deleted": taskContract("deleted", z.null()),
618
+ "close.task.deleted": taskContract(
619
+ "deleted",
620
+ CLOSE_DELETED_EVENT_DATA_SCHEMA,
621
+ ),
596
622
  "close.task.updated": taskContract("updated", CLOSE_TASK_EVENT_DATA_SCHEMA),
597
623
  } as const satisfies Record<
598
624
  string,
@@ -252,7 +252,7 @@ const CLOSE_TASK_FIELDS = {
252
252
  updatedAt: DATE_SCHEMA,
253
253
  updatedBy: z.string().nullable(),
254
254
  updatedByName: z.string().nullable().optional(),
255
- view: z.enum(["archive", "future", "inbox"]).optional(),
255
+ view: z.enum(["archive", "future", "inbox"]).nullable().optional(),
256
256
  }
257
257
 
258
258
  const CLOSE_TASK_PHONE_FIELDS = {
@@ -135,11 +135,11 @@ export const RESEND_EMAIL_SCHEMA = RESEND_EMAIL_WIRE_SCHEMA.transform(
135
135
 
136
136
  export const RESEND_ATTACHMENT_WIRE_SCHEMA = z.object({
137
137
  content_disposition: z.enum(["attachment", "inline"]).nullable(),
138
- content_id: z.string(),
138
+ content_id: z.string().optional(),
139
139
  content_type: z.string(),
140
140
  download_url: z.url(),
141
141
  expires_at: z.string(),
142
- filename: z.string().nullable(),
142
+ filename: z.string().nullable().optional(),
143
143
  id: z.string(),
144
144
  size: z.number().int().nonnegative(),
145
145
  })
@@ -151,14 +151,16 @@ export const RESEND_ATTACHMENT_SCHEMA = RESEND_ATTACHMENT_WIRE_SCHEMA.transform(
151
151
  content_type: contentType,
152
152
  download_url: downloadUrl,
153
153
  expires_at: expiresAt,
154
+ filename,
154
155
  ...attachment
155
156
  }) => ({
156
157
  ...attachment,
157
158
  contentDisposition,
158
- contentId,
159
+ ...(contentId === undefined ? {} : { contentId }),
159
160
  contentType,
160
161
  downloadUrl,
161
162
  expiresAt,
163
+ ...(filename === undefined ? {} : { filename }),
162
164
  }),
163
165
  )
164
166
 
package/src/triggers.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { airtableTriggerContracts } from "./airtable"
2
+ import type { automateTriggerContracts } from "./automate"
2
3
  import type { asanaTriggerContracts } from "./asana"
3
4
  import type { brevoTriggerContracts } from "./brevo"
4
5
  import type { convexTriggerContracts } from "./convex"
@@ -22,6 +23,7 @@ import type { whatsappTriggerContracts } from "./whatsapp"
22
23
  import type { z } from "zod"
23
24
 
24
25
  export type TriggerContractMap = typeof airtableTriggerContracts &
26
+ typeof automateTriggerContracts &
25
27
  typeof asanaTriggerContracts &
26
28
  typeof brevoTriggerContracts &
27
29
  typeof convexTriggerContracts &