@automate.ax/integration-contracts 0.123.2 → 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.
- package/dist/apify/index.d.ts +1085 -0
- package/dist/apify/index.js +169 -0
- package/dist/apify/schemas.d.ts +100 -0
- package/dist/apify/schemas.js +203 -0
- package/dist/linear/schemas.d.ts +8 -8
- package/dist/notion/schemas.d.ts +33 -33
- package/dist/triggers.d.ts +2 -1
- package/dist/vercel/index.d.ts +16 -16
- package/dist/vercel/schemas.d.ts +24 -24
- package/package.json +8 -2
- package/src/apify/index.ts +210 -0
- package/src/apify/schemas.ts +214 -0
- package/src/triggers.ts +2 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
|
|
3
|
+
export const APIFY_JOB_STATUS_SCHEMA = z.enum([
|
|
4
|
+
"READY",
|
|
5
|
+
"RUNNING",
|
|
6
|
+
"SUCCEEDED",
|
|
7
|
+
"FAILED",
|
|
8
|
+
"TIMING-OUT",
|
|
9
|
+
"TIMED-OUT",
|
|
10
|
+
"ABORTING",
|
|
11
|
+
"ABORTED",
|
|
12
|
+
])
|
|
13
|
+
|
|
14
|
+
const APIFY_DATE_SCHEMA = z.union([z.date(), z.iso.datetime()])
|
|
15
|
+
const APIFY_RUN_META_SCHEMA = z.looseObject({
|
|
16
|
+
origin: z.string(),
|
|
17
|
+
scheduleId: z.string().nullable().optional(),
|
|
18
|
+
scheduledAt: APIFY_DATE_SCHEMA.nullable().optional(),
|
|
19
|
+
})
|
|
20
|
+
const APIFY_RUN_OPTIONS_SCHEMA = z.looseObject({
|
|
21
|
+
build: z.string(),
|
|
22
|
+
diskMbytes: z.number().int().nonnegative(),
|
|
23
|
+
maxItems: z.number().int().nonnegative().nullable().optional(),
|
|
24
|
+
maxTotalChargeUsd: z.number().nonnegative().nullable().optional(),
|
|
25
|
+
memoryMbytes: z.number().int().min(128).max(32_768),
|
|
26
|
+
timeoutSecs: z.number().int().nonnegative(),
|
|
27
|
+
})
|
|
28
|
+
const APIFY_RUN_STATS_SCHEMA = z.looseObject({
|
|
29
|
+
computeUnits: z.number().nonnegative().optional(),
|
|
30
|
+
durationMillis: z.number().int().nonnegative().optional(),
|
|
31
|
+
runTimeSecs: z.number().nonnegative().optional(),
|
|
32
|
+
})
|
|
33
|
+
const APIFY_BUILD_META_SCHEMA = z.looseObject({ origin: z.string() })
|
|
34
|
+
const APIFY_BUILD_OPTIONS_SCHEMA = z.looseObject({
|
|
35
|
+
betaPackages: z.boolean().optional(),
|
|
36
|
+
diskMbytes: z.number().int().nonnegative().optional(),
|
|
37
|
+
memoryMbytes: z.number().int().min(128).max(32_768).optional(),
|
|
38
|
+
useCache: z.boolean().optional(),
|
|
39
|
+
})
|
|
40
|
+
const APIFY_BUILD_STATS_SCHEMA = z.looseObject({
|
|
41
|
+
computeUnits: z.number().nonnegative(),
|
|
42
|
+
durationMillis: z.number().int().nonnegative(),
|
|
43
|
+
runTimeSecs: z.number().nonnegative(),
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const APIFY_RUN_WIRE_SCHEMA = z.looseObject({
|
|
47
|
+
actId: z.string(),
|
|
48
|
+
actorTaskId: z.string().nullable().optional(),
|
|
49
|
+
buildId: z.string(),
|
|
50
|
+
buildNumber: z.string().nullable().optional(),
|
|
51
|
+
defaultDatasetId: z.string(),
|
|
52
|
+
defaultKeyValueStoreId: z.string(),
|
|
53
|
+
defaultRequestQueueId: z.string(),
|
|
54
|
+
exitCode: z.number().int().nullable().optional(),
|
|
55
|
+
finishedAt: APIFY_DATE_SCHEMA.nullable().optional(),
|
|
56
|
+
id: z.string(),
|
|
57
|
+
meta: APIFY_RUN_META_SCHEMA,
|
|
58
|
+
options: APIFY_RUN_OPTIONS_SCHEMA.optional(),
|
|
59
|
+
startedAt: APIFY_DATE_SCHEMA,
|
|
60
|
+
stats: APIFY_RUN_STATS_SCHEMA.optional(),
|
|
61
|
+
status: APIFY_JOB_STATUS_SCHEMA,
|
|
62
|
+
statusMessage: z.string().nullable().optional(),
|
|
63
|
+
usageTotalUsd: z.number().nonnegative().nullable().optional(),
|
|
64
|
+
userId: z.string().optional(),
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
const APIFY_BUILD_WIRE_SCHEMA = z.looseObject({
|
|
68
|
+
actId: z.string(),
|
|
69
|
+
buildNumber: z.string(),
|
|
70
|
+
finishedAt: APIFY_DATE_SCHEMA.nullable().optional(),
|
|
71
|
+
id: z.string(),
|
|
72
|
+
meta: APIFY_BUILD_META_SCHEMA.optional(),
|
|
73
|
+
options: APIFY_BUILD_OPTIONS_SCHEMA.nullable().optional(),
|
|
74
|
+
startedAt: APIFY_DATE_SCHEMA,
|
|
75
|
+
stats: APIFY_BUILD_STATS_SCHEMA.nullable().optional(),
|
|
76
|
+
status: APIFY_JOB_STATUS_SCHEMA,
|
|
77
|
+
usageTotalUsd: z.number().nonnegative().nullable().optional(),
|
|
78
|
+
userId: z.string().optional(),
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
export const APIFY_RUN_SCHEMA = z.object({
|
|
82
|
+
actorId: z.string(),
|
|
83
|
+
actorTaskId: z.string().nullable().optional(),
|
|
84
|
+
buildId: z.string(),
|
|
85
|
+
buildNumber: z.string().nullable().optional(),
|
|
86
|
+
defaultDatasetId: z.string(),
|
|
87
|
+
defaultKeyValueStoreId: z.string(),
|
|
88
|
+
defaultRequestQueueId: z.string(),
|
|
89
|
+
exitCode: z.number().int().nullable().optional(),
|
|
90
|
+
finishedAt: z.iso.datetime().nullable().optional(),
|
|
91
|
+
id: z.string(),
|
|
92
|
+
meta: z.object({
|
|
93
|
+
origin: z.string(),
|
|
94
|
+
scheduleId: z.string().nullable().optional(),
|
|
95
|
+
scheduledAt: z.iso.datetime().nullable().optional(),
|
|
96
|
+
}),
|
|
97
|
+
options: z
|
|
98
|
+
.object({
|
|
99
|
+
build: z.string(),
|
|
100
|
+
diskMbytes: z.number().int().nonnegative(),
|
|
101
|
+
maxItems: z.number().int().nonnegative().nullable().optional(),
|
|
102
|
+
maxTotalChargeUsd: z.number().nonnegative().nullable().optional(),
|
|
103
|
+
memoryMbytes: z.number().int().min(128).max(32_768),
|
|
104
|
+
timeoutSecs: z.number().int().nonnegative(),
|
|
105
|
+
})
|
|
106
|
+
.optional(),
|
|
107
|
+
startedAt: z.iso.datetime(),
|
|
108
|
+
stats: z
|
|
109
|
+
.object({
|
|
110
|
+
computeUnits: z.number().nonnegative().optional(),
|
|
111
|
+
durationMillis: z.number().int().nonnegative().optional(),
|
|
112
|
+
runTimeSecs: z.number().nonnegative().optional(),
|
|
113
|
+
})
|
|
114
|
+
.optional(),
|
|
115
|
+
status: APIFY_JOB_STATUS_SCHEMA,
|
|
116
|
+
statusMessage: z.string().nullable().optional(),
|
|
117
|
+
usageTotalUsd: z.number().nonnegative().nullable().optional(),
|
|
118
|
+
userId: z.string().optional(),
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
export const APIFY_BUILD_SCHEMA = z.object({
|
|
122
|
+
actorId: z.string(),
|
|
123
|
+
buildNumber: z.string(),
|
|
124
|
+
finishedAt: z.iso.datetime().nullable().optional(),
|
|
125
|
+
id: z.string(),
|
|
126
|
+
meta: z.object({ origin: z.string() }).optional(),
|
|
127
|
+
options: z
|
|
128
|
+
.object({
|
|
129
|
+
betaPackages: z.boolean().optional(),
|
|
130
|
+
diskMbytes: z.number().int().nonnegative().optional(),
|
|
131
|
+
memoryMbytes: z.number().int().min(128).max(32_768).optional(),
|
|
132
|
+
useCache: z.boolean().optional(),
|
|
133
|
+
})
|
|
134
|
+
.nullable()
|
|
135
|
+
.optional(),
|
|
136
|
+
startedAt: z.iso.datetime(),
|
|
137
|
+
stats: z
|
|
138
|
+
.object({
|
|
139
|
+
computeUnits: z.number().nonnegative(),
|
|
140
|
+
durationMillis: z.number().int().nonnegative(),
|
|
141
|
+
runTimeSecs: z.number().nonnegative(),
|
|
142
|
+
})
|
|
143
|
+
.nullable()
|
|
144
|
+
.optional(),
|
|
145
|
+
status: APIFY_JOB_STATUS_SCHEMA,
|
|
146
|
+
usageTotalUsd: z.number().nonnegative().nullable().optional(),
|
|
147
|
+
userId: z.string().optional(),
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Converts an official Apify Actor run into the public camelCase contract.
|
|
152
|
+
*
|
|
153
|
+
* @param value - Official client or webhook run value.
|
|
154
|
+
*/
|
|
155
|
+
export function mapApifyRun(value: unknown): z.output<typeof APIFY_RUN_SCHEMA> {
|
|
156
|
+
const run = APIFY_RUN_WIRE_SCHEMA.parse(value)
|
|
157
|
+
return APIFY_RUN_SCHEMA.parse({
|
|
158
|
+
actorId: run.actId,
|
|
159
|
+
actorTaskId: run.actorTaskId,
|
|
160
|
+
buildId: run.buildId,
|
|
161
|
+
buildNumber: run.buildNumber,
|
|
162
|
+
defaultDatasetId: run.defaultDatasetId,
|
|
163
|
+
defaultKeyValueStoreId: run.defaultKeyValueStoreId,
|
|
164
|
+
defaultRequestQueueId: run.defaultRequestQueueId,
|
|
165
|
+
exitCode: run.exitCode,
|
|
166
|
+
finishedAt: toIsoDate(run.finishedAt),
|
|
167
|
+
id: run.id,
|
|
168
|
+
meta: {
|
|
169
|
+
origin: run.meta.origin,
|
|
170
|
+
scheduleId: run.meta.scheduleId,
|
|
171
|
+
scheduledAt: toIsoDate(run.meta.scheduledAt),
|
|
172
|
+
},
|
|
173
|
+
options: run.options,
|
|
174
|
+
startedAt: toIsoDate(run.startedAt),
|
|
175
|
+
stats: run.stats,
|
|
176
|
+
status: run.status,
|
|
177
|
+
statusMessage: run.statusMessage,
|
|
178
|
+
usageTotalUsd: run.usageTotalUsd,
|
|
179
|
+
userId: run.userId,
|
|
180
|
+
})
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Converts an official Apify Actor build into the public camelCase contract.
|
|
185
|
+
*
|
|
186
|
+
* @param value - Official client or webhook build value.
|
|
187
|
+
*/
|
|
188
|
+
export function mapApifyBuild(
|
|
189
|
+
value: unknown,
|
|
190
|
+
): z.output<typeof APIFY_BUILD_SCHEMA> {
|
|
191
|
+
const build = APIFY_BUILD_WIRE_SCHEMA.parse(value)
|
|
192
|
+
return APIFY_BUILD_SCHEMA.parse({
|
|
193
|
+
actorId: build.actId,
|
|
194
|
+
buildNumber: build.buildNumber,
|
|
195
|
+
finishedAt: toIsoDate(build.finishedAt),
|
|
196
|
+
id: build.id,
|
|
197
|
+
meta: build.meta,
|
|
198
|
+
options: build.options,
|
|
199
|
+
startedAt: toIsoDate(build.startedAt),
|
|
200
|
+
stats: build.stats,
|
|
201
|
+
status: build.status,
|
|
202
|
+
usageTotalUsd: build.usageTotalUsd,
|
|
203
|
+
userId: build.userId,
|
|
204
|
+
})
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Normalizes an optional provider date without changing nullability.
|
|
209
|
+
*
|
|
210
|
+
* @param value - Provider date value.
|
|
211
|
+
*/
|
|
212
|
+
function toIsoDate(value: Date | string | null | undefined) {
|
|
213
|
+
return value instanceof Date ? value.toISOString() : value
|
|
214
|
+
}
|
package/src/triggers.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { airtableTriggerContracts } from "./airtable"
|
|
2
|
+
import type { apifyTriggerContracts } from "./apify"
|
|
2
3
|
import type { automateTriggerContracts } from "./automate"
|
|
3
4
|
import type { asanaTriggerContracts } from "./asana"
|
|
4
5
|
import type { brevoTriggerContracts } from "./brevo"
|
|
@@ -28,6 +29,7 @@ import type { whatsappTriggerContracts } from "./whatsapp"
|
|
|
28
29
|
import type { z } from "zod"
|
|
29
30
|
|
|
30
31
|
export type TriggerContractMap = typeof airtableTriggerContracts &
|
|
32
|
+
typeof apifyTriggerContracts &
|
|
31
33
|
typeof automateTriggerContracts &
|
|
32
34
|
typeof asanaTriggerContracts &
|
|
33
35
|
typeof brevoTriggerContracts &
|