@automate.ax/integration-contracts 0.124.0 → 0.125.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.
@@ -593,9 +593,9 @@ export declare const VERCEL_ADDITIONAL_EVENT_SCHEMAS: {
593
593
  ownerId: z.ZodString;
594
594
  projectId: z.ZodString;
595
595
  state: z.ZodEnum<{
596
+ ABORTED: "ABORTED";
596
597
  ACTIVE: "ACTIVE";
597
598
  COMPLETE: "COMPLETE";
598
- ABORTED: "ABORTED";
599
599
  }>;
600
600
  writtenBy: z.ZodString;
601
601
  }, z.core.$catchall<z.ZodJSONSchema>>>>;
@@ -620,9 +620,9 @@ export declare const VERCEL_ADDITIONAL_EVENT_SCHEMAS: {
620
620
  ownerId: z.ZodString;
621
621
  projectId: z.ZodString;
622
622
  state: z.ZodEnum<{
623
+ ABORTED: "ABORTED";
623
624
  ACTIVE: "ACTIVE";
624
625
  COMPLETE: "COMPLETE";
625
- ABORTED: "ABORTED";
626
626
  }>;
627
627
  writtenBy: z.ZodString;
628
628
  }, z.core.$catchall<z.ZodJSONSchema>>;
@@ -657,9 +657,9 @@ export declare const VERCEL_ADDITIONAL_EVENT_SCHEMAS: {
657
657
  ownerId: z.ZodString;
658
658
  projectId: z.ZodString;
659
659
  state: z.ZodEnum<{
660
+ ABORTED: "ABORTED";
660
661
  ACTIVE: "ACTIVE";
661
662
  COMPLETE: "COMPLETE";
662
- ABORTED: "ABORTED";
663
663
  }>;
664
664
  writtenBy: z.ZodString;
665
665
  }, z.core.$catchall<z.ZodJSONSchema>>>>;
@@ -684,9 +684,9 @@ export declare const VERCEL_ADDITIONAL_EVENT_SCHEMAS: {
684
684
  ownerId: z.ZodString;
685
685
  projectId: z.ZodString;
686
686
  state: z.ZodEnum<{
687
+ ABORTED: "ABORTED";
687
688
  ACTIVE: "ACTIVE";
688
689
  COMPLETE: "COMPLETE";
689
- ABORTED: "ABORTED";
690
690
  }>;
691
691
  writtenBy: z.ZodString;
692
692
  }, z.core.$catchall<z.ZodJSONSchema>>;
@@ -721,9 +721,9 @@ export declare const VERCEL_ADDITIONAL_EVENT_SCHEMAS: {
721
721
  ownerId: z.ZodString;
722
722
  projectId: z.ZodString;
723
723
  state: z.ZodEnum<{
724
+ ABORTED: "ABORTED";
724
725
  ACTIVE: "ACTIVE";
725
726
  COMPLETE: "COMPLETE";
726
- ABORTED: "ABORTED";
727
727
  }>;
728
728
  writtenBy: z.ZodString;
729
729
  }, z.core.$catchall<z.ZodJSONSchema>>>>;
@@ -748,9 +748,9 @@ export declare const VERCEL_ADDITIONAL_EVENT_SCHEMAS: {
748
748
  ownerId: z.ZodString;
749
749
  projectId: z.ZodString;
750
750
  state: z.ZodEnum<{
751
+ ABORTED: "ABORTED";
751
752
  ACTIVE: "ACTIVE";
752
753
  COMPLETE: "COMPLETE";
753
- ABORTED: "ABORTED";
754
754
  }>;
755
755
  writtenBy: z.ZodString;
756
756
  }, z.core.$catchall<z.ZodJSONSchema>>;
@@ -785,9 +785,9 @@ export declare const VERCEL_ADDITIONAL_EVENT_SCHEMAS: {
785
785
  ownerId: z.ZodString;
786
786
  projectId: z.ZodString;
787
787
  state: z.ZodEnum<{
788
+ ABORTED: "ABORTED";
788
789
  ACTIVE: "ACTIVE";
789
790
  COMPLETE: "COMPLETE";
790
- ABORTED: "ABORTED";
791
791
  }>;
792
792
  writtenBy: z.ZodString;
793
793
  }, z.core.$catchall<z.ZodJSONSchema>>>>;
@@ -812,9 +812,9 @@ export declare const VERCEL_ADDITIONAL_EVENT_SCHEMAS: {
812
812
  ownerId: z.ZodString;
813
813
  projectId: z.ZodString;
814
814
  state: z.ZodEnum<{
815
+ ABORTED: "ABORTED";
815
816
  ACTIVE: "ACTIVE";
816
817
  COMPLETE: "COMPLETE";
817
- ABORTED: "ABORTED";
818
818
  }>;
819
819
  writtenBy: z.ZodString;
820
820
  }, z.core.$catchall<z.ZodJSONSchema>>;
@@ -2218,9 +2218,9 @@ export declare const VERCEL_ROLLING_RELEASE_EVENT_SCHEMA: z.ZodDiscriminatedUnio
2218
2218
  ownerId: z.ZodString;
2219
2219
  projectId: z.ZodString;
2220
2220
  state: z.ZodEnum<{
2221
+ ABORTED: "ABORTED";
2221
2222
  ACTIVE: "ACTIVE";
2222
2223
  COMPLETE: "COMPLETE";
2223
- ABORTED: "ABORTED";
2224
2224
  }>;
2225
2225
  writtenBy: z.ZodString;
2226
2226
  }, z.core.$catchall<z.ZodJSONSchema>>>>;
@@ -2245,9 +2245,9 @@ export declare const VERCEL_ROLLING_RELEASE_EVENT_SCHEMA: z.ZodDiscriminatedUnio
2245
2245
  ownerId: z.ZodString;
2246
2246
  projectId: z.ZodString;
2247
2247
  state: z.ZodEnum<{
2248
+ ABORTED: "ABORTED";
2248
2249
  ACTIVE: "ACTIVE";
2249
2250
  COMPLETE: "COMPLETE";
2250
- ABORTED: "ABORTED";
2251
2251
  }>;
2252
2252
  writtenBy: z.ZodString;
2253
2253
  }, z.core.$catchall<z.ZodJSONSchema>>;
@@ -2281,9 +2281,9 @@ export declare const VERCEL_ROLLING_RELEASE_EVENT_SCHEMA: z.ZodDiscriminatedUnio
2281
2281
  ownerId: z.ZodString;
2282
2282
  projectId: z.ZodString;
2283
2283
  state: z.ZodEnum<{
2284
+ ABORTED: "ABORTED";
2284
2285
  ACTIVE: "ACTIVE";
2285
2286
  COMPLETE: "COMPLETE";
2286
- ABORTED: "ABORTED";
2287
2287
  }>;
2288
2288
  writtenBy: z.ZodString;
2289
2289
  }, z.core.$catchall<z.ZodJSONSchema>>>>;
@@ -2308,9 +2308,9 @@ export declare const VERCEL_ROLLING_RELEASE_EVENT_SCHEMA: z.ZodDiscriminatedUnio
2308
2308
  ownerId: z.ZodString;
2309
2309
  projectId: z.ZodString;
2310
2310
  state: z.ZodEnum<{
2311
+ ABORTED: "ABORTED";
2311
2312
  ACTIVE: "ACTIVE";
2312
2313
  COMPLETE: "COMPLETE";
2313
- ABORTED: "ABORTED";
2314
2314
  }>;
2315
2315
  writtenBy: z.ZodString;
2316
2316
  }, z.core.$catchall<z.ZodJSONSchema>>;
@@ -2344,9 +2344,9 @@ export declare const VERCEL_ROLLING_RELEASE_EVENT_SCHEMA: z.ZodDiscriminatedUnio
2344
2344
  ownerId: z.ZodString;
2345
2345
  projectId: z.ZodString;
2346
2346
  state: z.ZodEnum<{
2347
+ ABORTED: "ABORTED";
2347
2348
  ACTIVE: "ACTIVE";
2348
2349
  COMPLETE: "COMPLETE";
2349
- ABORTED: "ABORTED";
2350
2350
  }>;
2351
2351
  writtenBy: z.ZodString;
2352
2352
  }, z.core.$catchall<z.ZodJSONSchema>>>>;
@@ -2371,9 +2371,9 @@ export declare const VERCEL_ROLLING_RELEASE_EVENT_SCHEMA: z.ZodDiscriminatedUnio
2371
2371
  ownerId: z.ZodString;
2372
2372
  projectId: z.ZodString;
2373
2373
  state: z.ZodEnum<{
2374
+ ABORTED: "ABORTED";
2374
2375
  ACTIVE: "ACTIVE";
2375
2376
  COMPLETE: "COMPLETE";
2376
- ABORTED: "ABORTED";
2377
2377
  }>;
2378
2378
  writtenBy: z.ZodString;
2379
2379
  }, z.core.$catchall<z.ZodJSONSchema>>;
@@ -2407,9 +2407,9 @@ export declare const VERCEL_ROLLING_RELEASE_EVENT_SCHEMA: z.ZodDiscriminatedUnio
2407
2407
  ownerId: z.ZodString;
2408
2408
  projectId: z.ZodString;
2409
2409
  state: z.ZodEnum<{
2410
+ ABORTED: "ABORTED";
2410
2411
  ACTIVE: "ACTIVE";
2411
2412
  COMPLETE: "COMPLETE";
2412
- ABORTED: "ABORTED";
2413
2413
  }>;
2414
2414
  writtenBy: z.ZodString;
2415
2415
  }, z.core.$catchall<z.ZodJSONSchema>>>>;
@@ -2434,9 +2434,9 @@ export declare const VERCEL_ROLLING_RELEASE_EVENT_SCHEMA: z.ZodDiscriminatedUnio
2434
2434
  ownerId: z.ZodString;
2435
2435
  projectId: z.ZodString;
2436
2436
  state: z.ZodEnum<{
2437
+ ABORTED: "ABORTED";
2437
2438
  ACTIVE: "ACTIVE";
2438
2439
  COMPLETE: "COMPLETE";
2439
- ABORTED: "ABORTED";
2440
2440
  }>;
2441
2441
  writtenBy: z.ZodString;
2442
2442
  }, z.core.$catchall<z.ZodJSONSchema>>;
@@ -3445,9 +3445,9 @@ export declare const VERCEL_WEBHOOK_EVENT_SCHEMA: z.ZodDiscriminatedUnion<[z.Zod
3445
3445
  ownerId: z.ZodString;
3446
3446
  projectId: z.ZodString;
3447
3447
  state: z.ZodEnum<{
3448
+ ABORTED: "ABORTED";
3448
3449
  ACTIVE: "ACTIVE";
3449
3450
  COMPLETE: "COMPLETE";
3450
- ABORTED: "ABORTED";
3451
3451
  }>;
3452
3452
  writtenBy: z.ZodString;
3453
3453
  }, z.core.$catchall<z.ZodJSONSchema>>>>;
@@ -3472,9 +3472,9 @@ export declare const VERCEL_WEBHOOK_EVENT_SCHEMA: z.ZodDiscriminatedUnion<[z.Zod
3472
3472
  ownerId: z.ZodString;
3473
3473
  projectId: z.ZodString;
3474
3474
  state: z.ZodEnum<{
3475
+ ABORTED: "ABORTED";
3475
3476
  ACTIVE: "ACTIVE";
3476
3477
  COMPLETE: "COMPLETE";
3477
- ABORTED: "ABORTED";
3478
3478
  }>;
3479
3479
  writtenBy: z.ZodString;
3480
3480
  }, z.core.$catchall<z.ZodJSONSchema>>;
@@ -3508,9 +3508,9 @@ export declare const VERCEL_WEBHOOK_EVENT_SCHEMA: z.ZodDiscriminatedUnion<[z.Zod
3508
3508
  ownerId: z.ZodString;
3509
3509
  projectId: z.ZodString;
3510
3510
  state: z.ZodEnum<{
3511
+ ABORTED: "ABORTED";
3511
3512
  ACTIVE: "ACTIVE";
3512
3513
  COMPLETE: "COMPLETE";
3513
- ABORTED: "ABORTED";
3514
3514
  }>;
3515
3515
  writtenBy: z.ZodString;
3516
3516
  }, z.core.$catchall<z.ZodJSONSchema>>>>;
@@ -3535,9 +3535,9 @@ export declare const VERCEL_WEBHOOK_EVENT_SCHEMA: z.ZodDiscriminatedUnion<[z.Zod
3535
3535
  ownerId: z.ZodString;
3536
3536
  projectId: z.ZodString;
3537
3537
  state: z.ZodEnum<{
3538
+ ABORTED: "ABORTED";
3538
3539
  ACTIVE: "ACTIVE";
3539
3540
  COMPLETE: "COMPLETE";
3540
- ABORTED: "ABORTED";
3541
3541
  }>;
3542
3542
  writtenBy: z.ZodString;
3543
3543
  }, z.core.$catchall<z.ZodJSONSchema>>;
@@ -3571,9 +3571,9 @@ export declare const VERCEL_WEBHOOK_EVENT_SCHEMA: z.ZodDiscriminatedUnion<[z.Zod
3571
3571
  ownerId: z.ZodString;
3572
3572
  projectId: z.ZodString;
3573
3573
  state: z.ZodEnum<{
3574
+ ABORTED: "ABORTED";
3574
3575
  ACTIVE: "ACTIVE";
3575
3576
  COMPLETE: "COMPLETE";
3576
- ABORTED: "ABORTED";
3577
3577
  }>;
3578
3578
  writtenBy: z.ZodString;
3579
3579
  }, z.core.$catchall<z.ZodJSONSchema>>>>;
@@ -3598,9 +3598,9 @@ export declare const VERCEL_WEBHOOK_EVENT_SCHEMA: z.ZodDiscriminatedUnion<[z.Zod
3598
3598
  ownerId: z.ZodString;
3599
3599
  projectId: z.ZodString;
3600
3600
  state: z.ZodEnum<{
3601
+ ABORTED: "ABORTED";
3601
3602
  ACTIVE: "ACTIVE";
3602
3603
  COMPLETE: "COMPLETE";
3603
- ABORTED: "ABORTED";
3604
3604
  }>;
3605
3605
  writtenBy: z.ZodString;
3606
3606
  }, z.core.$catchall<z.ZodJSONSchema>>;
@@ -3634,9 +3634,9 @@ export declare const VERCEL_WEBHOOK_EVENT_SCHEMA: z.ZodDiscriminatedUnion<[z.Zod
3634
3634
  ownerId: z.ZodString;
3635
3635
  projectId: z.ZodString;
3636
3636
  state: z.ZodEnum<{
3637
+ ABORTED: "ABORTED";
3637
3638
  ACTIVE: "ACTIVE";
3638
3639
  COMPLETE: "COMPLETE";
3639
- ABORTED: "ABORTED";
3640
3640
  }>;
3641
3641
  writtenBy: z.ZodString;
3642
3642
  }, z.core.$catchall<z.ZodJSONSchema>>>>;
@@ -3661,9 +3661,9 @@ export declare const VERCEL_WEBHOOK_EVENT_SCHEMA: z.ZodDiscriminatedUnion<[z.Zod
3661
3661
  ownerId: z.ZodString;
3662
3662
  projectId: z.ZodString;
3663
3663
  state: z.ZodEnum<{
3664
+ ABORTED: "ABORTED";
3664
3665
  ACTIVE: "ACTIVE";
3665
3666
  COMPLETE: "COMPLETE";
3666
- ABORTED: "ABORTED";
3667
3667
  }>;
3668
3668
  writtenBy: z.ZodString;
3669
3669
  }, z.core.$catchall<z.ZodJSONSchema>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automate.ax/integration-contracts",
3
- "version": "0.124.0",
3
+ "version": "0.125.0",
4
4
  "description": "Shared integration payload contracts and provider primitives for Automate.ax.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "zshy": {
20
20
  "exports": {
21
+ "./apify": "./src/apify/index.ts",
21
22
  "./airtable": "./src/airtable/index.ts",
22
23
  "./automate": "./src/automate/index.ts",
23
24
  "./asana": "./src/asana/index.ts",
@@ -55,7 +56,7 @@
55
56
  }
56
57
  },
57
58
  "dependencies": {
58
- "@automate.ax/codec": "0.124.0",
59
+ "@automate.ax/codec": "0.125.0",
59
60
  "@cfworker/json-schema": "^4.1.1",
60
61
  "@googleapis/calendar": "^15.0.0",
61
62
  "@googleapis/forms": "^6.0.1",
@@ -106,6 +107,11 @@
106
107
  "node": ">=24"
107
108
  },
108
109
  "exports": {
110
+ "./apify": {
111
+ "bun": "./src/apify/index.ts",
112
+ "types": "./dist/apify/index.d.ts",
113
+ "default": "./dist/apify/index.js"
114
+ },
109
115
  "./airtable": {
110
116
  "bun": "./src/airtable/index.ts",
111
117
  "types": "./dist/airtable/index.d.ts",
@@ -0,0 +1,210 @@
1
+ import * as z from "zod"
2
+ import {
3
+ APIFY_BUILD_SCHEMA,
4
+ APIFY_RUN_SCHEMA,
5
+ mapApifyBuild,
6
+ mapApifyRun,
7
+ } from "./schemas"
8
+
9
+ export * from "./schemas"
10
+
11
+ export const APIFY_RUN_EVENT_TYPES = [
12
+ "ACTOR.RUN.CREATED",
13
+ "ACTOR.RUN.SUCCEEDED",
14
+ "ACTOR.RUN.FAILED",
15
+ "ACTOR.RUN.ABORTED",
16
+ "ACTOR.RUN.TIMED_OUT",
17
+ "ACTOR.RUN.RESURRECTED",
18
+ ] as const
19
+
20
+ export const APIFY_BUILD_EVENT_TYPES = [
21
+ "ACTOR.BUILD.CREATED",
22
+ "ACTOR.BUILD.SUCCEEDED",
23
+ "ACTOR.BUILD.FAILED",
24
+ "ACTOR.BUILD.ABORTED",
25
+ "ACTOR.BUILD.TIMED_OUT",
26
+ ] as const
27
+
28
+ export const APIFY_EVENT_TYPES = [
29
+ ...APIFY_RUN_EVENT_TYPES,
30
+ ...APIFY_BUILD_EVENT_TYPES,
31
+ ] as const
32
+
33
+ export const APIFY_RUN_TRIGGER_CONFIG_SCHEMA = z.union([
34
+ z.object({
35
+ actorId: z.string().trim().min(1),
36
+ taskId: z.never().optional(),
37
+ }),
38
+ z.object({
39
+ actorId: z.never().optional(),
40
+ taskId: z.string().trim().min(1),
41
+ }),
42
+ ])
43
+
44
+ export const APIFY_BUILD_TRIGGER_CONFIG_SCHEMA = z.object({
45
+ actorId: z.string().trim().min(1),
46
+ })
47
+
48
+ const APIFY_WEBHOOK_EVENT_SCHEMA = z.looseObject({
49
+ createdAt: z.iso.datetime(),
50
+ eventData: z.looseObject({
51
+ actorBuildId: z.string().optional(),
52
+ actorId: z.string(),
53
+ actorRunId: z.string().optional(),
54
+ actorTaskId: z.string().nullable().optional(),
55
+ }),
56
+ eventType: z.enum(APIFY_EVENT_TYPES),
57
+ resource: z.unknown(),
58
+ userId: z.string(),
59
+ })
60
+
61
+ const APIFY_RUN_EVENT_SCHEMA = z.object({
62
+ createdAt: z.iso.datetime(),
63
+ eventData: z.object({
64
+ actorId: z.string(),
65
+ actorRunId: z.string(),
66
+ actorTaskId: z.string().nullable().optional(),
67
+ }),
68
+ eventType: z.enum(APIFY_RUN_EVENT_TYPES),
69
+ resource: APIFY_RUN_SCHEMA,
70
+ userId: z.string(),
71
+ })
72
+
73
+ const APIFY_BUILD_EVENT_SCHEMA = z.object({
74
+ createdAt: z.iso.datetime(),
75
+ eventData: z.object({
76
+ actorBuildId: z.string(),
77
+ actorId: z.string(),
78
+ }),
79
+ eventType: z.enum(APIFY_BUILD_EVENT_TYPES),
80
+ resource: APIFY_BUILD_SCHEMA,
81
+ userId: z.string(),
82
+ })
83
+
84
+ export const APIFY_EVENT_SCHEMA = z.union([
85
+ APIFY_RUN_EVENT_SCHEMA,
86
+ APIFY_BUILD_EVENT_SCHEMA,
87
+ ])
88
+
89
+ export type ApifyEvent = z.output<typeof APIFY_EVENT_SCHEMA>
90
+ export type ApifyRunEvent = z.output<typeof APIFY_RUN_EVENT_SCHEMA>
91
+ export type ApifyBuildEvent = z.output<typeof APIFY_BUILD_EVENT_SCHEMA>
92
+
93
+ /**
94
+ * Parses and normalizes the default Apify webhook payload.
95
+ *
96
+ * @param value - Untrusted provider payload.
97
+ */
98
+ export function parseApifyEvent(value: unknown): ApifyEvent {
99
+ const event = APIFY_WEBHOOK_EVENT_SCHEMA.parse(value)
100
+ if (isApifyRunEventType(event.eventType)) {
101
+ return APIFY_RUN_EVENT_SCHEMA.parse({
102
+ ...event,
103
+ eventData: {
104
+ actorId: event.eventData.actorId,
105
+ actorRunId: event.eventData.actorRunId,
106
+ actorTaskId: event.eventData.actorTaskId,
107
+ },
108
+ resource: mapApifyRun(event.resource),
109
+ })
110
+ }
111
+ return APIFY_BUILD_EVENT_SCHEMA.parse({
112
+ ...event,
113
+ eventData: {
114
+ actorBuildId: event.eventData.actorBuildId,
115
+ actorId: event.eventData.actorId,
116
+ },
117
+ resource: mapApifyBuild(event.resource),
118
+ })
119
+ }
120
+
121
+ /**
122
+ * Returns whether an Apify webhook type describes an Actor run.
123
+ *
124
+ * @param type - Provider webhook event type.
125
+ */
126
+ export function isApifyRunEventType(
127
+ type: (typeof APIFY_EVENT_TYPES)[number],
128
+ ): type is (typeof APIFY_RUN_EVENT_TYPES)[number] {
129
+ return (APIFY_RUN_EVENT_TYPES as readonly string[]).includes(type)
130
+ }
131
+
132
+ export const apifyRunEventTypeMap = {
133
+ "ACTOR.RUN.ABORTED": "apify.actorRun.aborted",
134
+ "ACTOR.RUN.CREATED": "apify.actorRun.created",
135
+ "ACTOR.RUN.FAILED": "apify.actorRun.failed",
136
+ "ACTOR.RUN.RESURRECTED": "apify.actorRun.resurrected",
137
+ "ACTOR.RUN.SUCCEEDED": "apify.actorRun.succeeded",
138
+ "ACTOR.RUN.TIMED_OUT": "apify.actorRun.timedOut",
139
+ } as const
140
+
141
+ export const apifyBuildEventTypeMap = {
142
+ "ACTOR.BUILD.ABORTED": "apify.actorBuild.aborted",
143
+ "ACTOR.BUILD.CREATED": "apify.actorBuild.created",
144
+ "ACTOR.BUILD.FAILED": "apify.actorBuild.failed",
145
+ "ACTOR.BUILD.SUCCEEDED": "apify.actorBuild.succeeded",
146
+ "ACTOR.BUILD.TIMED_OUT": "apify.actorBuild.timedOut",
147
+ } as const
148
+
149
+ export const apifyEventTypeMap = {
150
+ ...apifyRunEventTypeMap,
151
+ ...apifyBuildEventTypeMap,
152
+ } as const
153
+
154
+ /** Shared structural constraint for the heterogeneous Apify trigger map. */
155
+ type ApifyTriggerContract = {
156
+ readonly configSchema:
157
+ | typeof APIFY_BUILD_TRIGGER_CONFIG_SCHEMA
158
+ | typeof APIFY_RUN_TRIGGER_CONFIG_SCHEMA
159
+ readonly eventSchema: z.ZodType<ApifyEvent>
160
+ }
161
+
162
+ export const apifyTriggerContracts = {
163
+ "apify.actorBuild.aborted": buildContract("ACTOR.BUILD.ABORTED"),
164
+ "apify.actorBuild.created": buildContract("ACTOR.BUILD.CREATED"),
165
+ "apify.actorBuild.event": {
166
+ configSchema: APIFY_BUILD_TRIGGER_CONFIG_SCHEMA,
167
+ eventSchema: APIFY_BUILD_EVENT_SCHEMA,
168
+ },
169
+ "apify.actorBuild.failed": buildContract("ACTOR.BUILD.FAILED"),
170
+ "apify.actorBuild.succeeded": buildContract("ACTOR.BUILD.SUCCEEDED"),
171
+ "apify.actorBuild.timedOut": buildContract("ACTOR.BUILD.TIMED_OUT"),
172
+ "apify.actorRun.aborted": runContract("ACTOR.RUN.ABORTED"),
173
+ "apify.actorRun.created": runContract("ACTOR.RUN.CREATED"),
174
+ "apify.actorRun.event": {
175
+ configSchema: APIFY_RUN_TRIGGER_CONFIG_SCHEMA,
176
+ eventSchema: APIFY_RUN_EVENT_SCHEMA,
177
+ },
178
+ "apify.actorRun.failed": runContract("ACTOR.RUN.FAILED"),
179
+ "apify.actorRun.resurrected": runContract("ACTOR.RUN.RESURRECTED"),
180
+ "apify.actorRun.succeeded": runContract("ACTOR.RUN.SUCCEEDED"),
181
+ "apify.actorRun.timedOut": runContract("ACTOR.RUN.TIMED_OUT"),
182
+ } as const satisfies Record<string, ApifyTriggerContract>
183
+
184
+ /**
185
+ * Builds one Actor run trigger contract.
186
+ *
187
+ * @param type - Exact provider run event type.
188
+ */
189
+ function runContract(type: (typeof APIFY_RUN_EVENT_TYPES)[number]) {
190
+ return {
191
+ configSchema: APIFY_RUN_TRIGGER_CONFIG_SCHEMA,
192
+ eventSchema: APIFY_RUN_EVENT_SCHEMA.refine(
193
+ (event) => event.eventType === type,
194
+ ),
195
+ }
196
+ }
197
+
198
+ /**
199
+ * Builds one Actor build trigger contract.
200
+ *
201
+ * @param type - Exact provider build event type.
202
+ */
203
+ function buildContract(type: (typeof APIFY_BUILD_EVENT_TYPES)[number]) {
204
+ return {
205
+ configSchema: APIFY_BUILD_TRIGGER_CONFIG_SCHEMA,
206
+ eventSchema: APIFY_BUILD_EVENT_SCHEMA.refine(
207
+ (event) => event.eventType === type,
208
+ ),
209
+ }
210
+ }