@automate.ax/integration-contracts 0.115.5 → 0.116.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/millionverifier/api.d.ts +62 -0
- package/dist/millionverifier/api.js +114 -0
- package/dist/millionverifier/events.d.ts +126 -0
- package/dist/millionverifier/events.js +103 -0
- package/dist/millionverifier/index.d.ts +77 -0
- package/dist/millionverifier/index.js +17 -0
- package/dist/millionverifier/schemas.d.ts +226 -0
- package/dist/millionverifier/schemas.js +188 -0
- package/dist/triggers.d.ts +2 -1
- package/package.json +8 -2
- package/src/millionverifier/api.ts +151 -0
- package/src/millionverifier/events.ts +110 -0
- package/src/millionverifier/index.ts +33 -0
- package/src/millionverifier/schemas.ts +207 -0
- package/src/triggers.ts +2 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
|
|
3
|
+
const FILE_ID_WIRE_SCHEMA = z.union([z.string(), z.number()]).transform(String)
|
|
4
|
+
|
|
5
|
+
export const MILLIONVERIFIER_NO_CREDIT_EVENT_SCHEMA = z.object({
|
|
6
|
+
reason: z.literal("noCredit"),
|
|
7
|
+
})
|
|
8
|
+
export const MILLIONVERIFIER_LOW_CREDIT_EVENT_SCHEMA = z.object({
|
|
9
|
+
credits: z.number().int().nonnegative(),
|
|
10
|
+
reason: z.literal("lowCredit"),
|
|
11
|
+
})
|
|
12
|
+
export const MILLIONVERIFIER_FILE_READY_EVENT_SCHEMA = z.object({
|
|
13
|
+
file: z.object({
|
|
14
|
+
catchAll: z.number().int().nonnegative(),
|
|
15
|
+
disposable: z.number().int().nonnegative(),
|
|
16
|
+
fileId: z.string(),
|
|
17
|
+
fileName: z.string(),
|
|
18
|
+
invalid: z.number().int().nonnegative(),
|
|
19
|
+
ok: z.number().int().nonnegative(),
|
|
20
|
+
totalRows: z.number().int().nonnegative(),
|
|
21
|
+
uniqueEmails: z.number().int().nonnegative(),
|
|
22
|
+
unknown: z.number().int().nonnegative(),
|
|
23
|
+
}),
|
|
24
|
+
reason: z.literal("fileReady"),
|
|
25
|
+
})
|
|
26
|
+
export const MILLIONVERIFIER_FILE_DELETION_SCHEDULED_EVENT_SCHEMA = z.object({
|
|
27
|
+
file: z.object({
|
|
28
|
+
deletesIn: z.string().min(1),
|
|
29
|
+
fileId: z.string(),
|
|
30
|
+
fileName: z.string(),
|
|
31
|
+
}),
|
|
32
|
+
reason: z.literal("fileDeletionScheduled"),
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
export const MILLIONVERIFIER_EVENT_SCHEMA = z.discriminatedUnion("reason", [
|
|
36
|
+
MILLIONVERIFIER_NO_CREDIT_EVENT_SCHEMA,
|
|
37
|
+
MILLIONVERIFIER_LOW_CREDIT_EVENT_SCHEMA,
|
|
38
|
+
MILLIONVERIFIER_FILE_READY_EVENT_SCHEMA,
|
|
39
|
+
MILLIONVERIFIER_FILE_DELETION_SCHEDULED_EVENT_SCHEMA,
|
|
40
|
+
])
|
|
41
|
+
|
|
42
|
+
export const MILLIONVERIFIER_WEBHOOK_WIRE_SCHEMA = z.discriminatedUnion(
|
|
43
|
+
"reason",
|
|
44
|
+
[
|
|
45
|
+
z.looseObject({ reason: z.literal("no_credit") }),
|
|
46
|
+
z.looseObject({
|
|
47
|
+
credits: z.number().int().nonnegative(),
|
|
48
|
+
reason: z.literal("low_credit"),
|
|
49
|
+
}),
|
|
50
|
+
z.looseObject({
|
|
51
|
+
file: z.looseObject({
|
|
52
|
+
catch_all: z.number().int().nonnegative(),
|
|
53
|
+
disposable: z.number().int().nonnegative(),
|
|
54
|
+
file_id: FILE_ID_WIRE_SCHEMA,
|
|
55
|
+
file_name: z.string(),
|
|
56
|
+
invalid: z.number().int().nonnegative(),
|
|
57
|
+
ok: z.number().int().nonnegative(),
|
|
58
|
+
total_rows: z.number().int().nonnegative(),
|
|
59
|
+
unique_emails: z.number().int().nonnegative(),
|
|
60
|
+
unknown: z.number().int().nonnegative(),
|
|
61
|
+
}),
|
|
62
|
+
reason: z.literal("file_ready"),
|
|
63
|
+
}),
|
|
64
|
+
z.looseObject({
|
|
65
|
+
file: z.looseObject({
|
|
66
|
+
file_delete: z.string().min(1),
|
|
67
|
+
file_id: FILE_ID_WIRE_SCHEMA,
|
|
68
|
+
file_name: z.string(),
|
|
69
|
+
}),
|
|
70
|
+
reason: z.literal("file_delete"),
|
|
71
|
+
}),
|
|
72
|
+
],
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Normalizes one documented MillionVerifier notification payload.
|
|
77
|
+
*
|
|
78
|
+
* @param value - Untrusted provider callback payload.
|
|
79
|
+
*/
|
|
80
|
+
export function normalizeMillionVerifierEvent(value: unknown) {
|
|
81
|
+
const event = MILLIONVERIFIER_WEBHOOK_WIRE_SCHEMA.parse(value)
|
|
82
|
+
if (event.reason === "no_credit") return { reason: "noCredit" as const }
|
|
83
|
+
if (event.reason === "low_credit") {
|
|
84
|
+
return { credits: event.credits, reason: "lowCredit" as const }
|
|
85
|
+
}
|
|
86
|
+
if (event.reason === "file_delete") {
|
|
87
|
+
return {
|
|
88
|
+
file: {
|
|
89
|
+
deletesIn: event.file.file_delete,
|
|
90
|
+
fileId: event.file.file_id,
|
|
91
|
+
fileName: event.file.file_name,
|
|
92
|
+
},
|
|
93
|
+
reason: "fileDeletionScheduled" as const,
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
file: {
|
|
98
|
+
catchAll: event.file.catch_all,
|
|
99
|
+
disposable: event.file.disposable,
|
|
100
|
+
fileId: event.file.file_id,
|
|
101
|
+
fileName: event.file.file_name,
|
|
102
|
+
invalid: event.file.invalid,
|
|
103
|
+
ok: event.file.ok,
|
|
104
|
+
totalRows: event.file.total_rows,
|
|
105
|
+
uniqueEmails: event.file.unique_emails,
|
|
106
|
+
unknown: event.file.unknown,
|
|
107
|
+
},
|
|
108
|
+
reason: "fileReady" as const,
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export * from "./api"
|
|
2
|
+
export * from "./events"
|
|
3
|
+
export * from "./schemas"
|
|
4
|
+
|
|
5
|
+
import * as z from "zod"
|
|
6
|
+
import {
|
|
7
|
+
MILLIONVERIFIER_EVENT_SCHEMA,
|
|
8
|
+
MILLIONVERIFIER_FILE_DELETION_SCHEDULED_EVENT_SCHEMA,
|
|
9
|
+
MILLIONVERIFIER_FILE_READY_EVENT_SCHEMA,
|
|
10
|
+
MILLIONVERIFIER_LOW_CREDIT_EVENT_SCHEMA,
|
|
11
|
+
MILLIONVERIFIER_NO_CREDIT_EVENT_SCHEMA,
|
|
12
|
+
} from "./events"
|
|
13
|
+
|
|
14
|
+
export const MILLIONVERIFIER_TRIGGER_CONFIG_SCHEMA = z.object({})
|
|
15
|
+
|
|
16
|
+
const contract = <TSchema extends z.ZodType>(eventSchema: TSchema) => ({
|
|
17
|
+
configSchema: MILLIONVERIFIER_TRIGGER_CONFIG_SCHEMA,
|
|
18
|
+
eventSchema,
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
export const millionVerifierTriggerContracts = {
|
|
22
|
+
"millionverifier.event": contract(MILLIONVERIFIER_EVENT_SCHEMA),
|
|
23
|
+
"millionverifier.noCredit": contract(MILLIONVERIFIER_NO_CREDIT_EVENT_SCHEMA),
|
|
24
|
+
"millionverifier.lowCredit": contract(
|
|
25
|
+
MILLIONVERIFIER_LOW_CREDIT_EVENT_SCHEMA,
|
|
26
|
+
),
|
|
27
|
+
"millionverifier.fileReady": contract(
|
|
28
|
+
MILLIONVERIFIER_FILE_READY_EVENT_SCHEMA,
|
|
29
|
+
),
|
|
30
|
+
"millionverifier.fileDeletionScheduled": contract(
|
|
31
|
+
MILLIONVERIFIER_FILE_DELETION_SCHEDULED_EVENT_SCHEMA,
|
|
32
|
+
),
|
|
33
|
+
} as const
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
|
|
3
|
+
export const MILLIONVERIFIER_FILE_ID_SCHEMA = z
|
|
4
|
+
.union([z.string().regex(/^\d+$/), z.number().int().positive()])
|
|
5
|
+
.transform(String)
|
|
6
|
+
|
|
7
|
+
export const MILLIONVERIFIER_FILE_STATUS_SCHEMA = z.enum([
|
|
8
|
+
"inProgress",
|
|
9
|
+
"error",
|
|
10
|
+
"finished",
|
|
11
|
+
"canceled",
|
|
12
|
+
"paused",
|
|
13
|
+
"inQueueToStart",
|
|
14
|
+
])
|
|
15
|
+
|
|
16
|
+
export const MILLIONVERIFIER_FILE_SCHEMA = z.object({
|
|
17
|
+
catchAll: z.number().int().nonnegative(),
|
|
18
|
+
createdAt: z.string(),
|
|
19
|
+
creditsRequired: z.number().int().nonnegative(),
|
|
20
|
+
disposable: z.number().int().nonnegative(),
|
|
21
|
+
error: z.string(),
|
|
22
|
+
estimatedTimeSeconds: z.number().int().nonnegative(),
|
|
23
|
+
fileId: z.string(),
|
|
24
|
+
fileName: z.string(),
|
|
25
|
+
invalid: z.number().int().nonnegative(),
|
|
26
|
+
ok: z.number().int().nonnegative(),
|
|
27
|
+
percent: z.number().int().min(0).max(100),
|
|
28
|
+
reverify: z.number().int().nonnegative(),
|
|
29
|
+
status: MILLIONVERIFIER_FILE_STATUS_SCHEMA,
|
|
30
|
+
totalRows: z.number().int().nonnegative(),
|
|
31
|
+
uniqueEmails: z.number().int().nonnegative(),
|
|
32
|
+
unknown: z.number().int().nonnegative(),
|
|
33
|
+
unverified: z.number().int().nonnegative(),
|
|
34
|
+
updatedAt: z.string(),
|
|
35
|
+
verified: z.number().int().nonnegative(),
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
export const MILLIONVERIFIER_EMAIL_RESULT_SCHEMA = z.enum([
|
|
39
|
+
"unverified",
|
|
40
|
+
"ok",
|
|
41
|
+
"catchAll",
|
|
42
|
+
"unknown",
|
|
43
|
+
"error",
|
|
44
|
+
"disposable",
|
|
45
|
+
"invalid",
|
|
46
|
+
])
|
|
47
|
+
|
|
48
|
+
export const MILLIONVERIFIER_EMAIL_VERIFICATION_SCHEMA = z.object({
|
|
49
|
+
credits: z.number().int().nonnegative(),
|
|
50
|
+
didYouMean: z.string(),
|
|
51
|
+
email: z.string(),
|
|
52
|
+
error: z.string(),
|
|
53
|
+
executionTimeMilliseconds: z.number().int().nonnegative(),
|
|
54
|
+
free: z.boolean(),
|
|
55
|
+
liveMode: z.boolean(),
|
|
56
|
+
quality: z.enum(["good", "bad", "risky"]).optional(),
|
|
57
|
+
result: MILLIONVERIFIER_EMAIL_RESULT_SCHEMA,
|
|
58
|
+
resultCode: z.number().int().min(0).max(6),
|
|
59
|
+
role: z.boolean(),
|
|
60
|
+
subresult: z.string(),
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
export const MILLIONVERIFIER_CREDITS_SCHEMA = z.object({
|
|
64
|
+
bulkCredits: z.number().int().nonnegative(),
|
|
65
|
+
credits: z.number().int().nonnegative(),
|
|
66
|
+
plan: z.number().int(),
|
|
67
|
+
renewingCredits: z.number().int().nonnegative(),
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
const PROVIDER_FILE_STATUS_SCHEMA = z.enum([
|
|
71
|
+
"in_progress",
|
|
72
|
+
"error",
|
|
73
|
+
"finished",
|
|
74
|
+
"canceled",
|
|
75
|
+
"paused",
|
|
76
|
+
"in_queue_to_start",
|
|
77
|
+
])
|
|
78
|
+
|
|
79
|
+
export const MILLIONVERIFIER_FILE_WIRE_SCHEMA = z
|
|
80
|
+
.looseObject({
|
|
81
|
+
catch_all: z.number().int().nonnegative(),
|
|
82
|
+
createdate: z.string(),
|
|
83
|
+
credit: z.number().int().nonnegative(),
|
|
84
|
+
disposable: z.number().int().nonnegative(),
|
|
85
|
+
error: z.string(),
|
|
86
|
+
estimated_time_sec: z.number().int().nonnegative(),
|
|
87
|
+
file_id: z.union([z.string(), z.number()]).transform(String),
|
|
88
|
+
file_name: z.string(),
|
|
89
|
+
invalid: z.number().int().nonnegative(),
|
|
90
|
+
ok: z.number().int().nonnegative(),
|
|
91
|
+
percent: z.number().int().min(0).max(100),
|
|
92
|
+
reverify: z.number().int().nonnegative(),
|
|
93
|
+
status: PROVIDER_FILE_STATUS_SCHEMA,
|
|
94
|
+
total_rows: z.number().int().nonnegative(),
|
|
95
|
+
unique_emails: z.number().int().nonnegative(),
|
|
96
|
+
unknown: z.number().int().nonnegative(),
|
|
97
|
+
unverified: z.number().int().nonnegative(),
|
|
98
|
+
updated_at: z.string(),
|
|
99
|
+
verified: z.number().int().nonnegative(),
|
|
100
|
+
})
|
|
101
|
+
.transform((file) =>
|
|
102
|
+
MILLIONVERIFIER_FILE_SCHEMA.parse({
|
|
103
|
+
catchAll: file.catch_all,
|
|
104
|
+
createdAt: file.createdate,
|
|
105
|
+
creditsRequired: file.credit,
|
|
106
|
+
disposable: file.disposable,
|
|
107
|
+
error: file.error,
|
|
108
|
+
estimatedTimeSeconds: file.estimated_time_sec,
|
|
109
|
+
fileId: file.file_id,
|
|
110
|
+
fileName: file.file_name,
|
|
111
|
+
invalid: file.invalid,
|
|
112
|
+
ok: file.ok,
|
|
113
|
+
percent: file.percent,
|
|
114
|
+
reverify: file.reverify,
|
|
115
|
+
status: fromProviderFileStatus(file.status),
|
|
116
|
+
totalRows: file.total_rows,
|
|
117
|
+
uniqueEmails: file.unique_emails,
|
|
118
|
+
unknown: file.unknown,
|
|
119
|
+
unverified: file.unverified,
|
|
120
|
+
updatedAt: file.updated_at,
|
|
121
|
+
verified: file.verified,
|
|
122
|
+
}),
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
export const MILLIONVERIFIER_EMAIL_VERIFICATION_WIRE_SCHEMA = z
|
|
126
|
+
.looseObject({
|
|
127
|
+
credits: z.number().int().nonnegative(),
|
|
128
|
+
didyoumean: z.string(),
|
|
129
|
+
email: z.string(),
|
|
130
|
+
error: z.string(),
|
|
131
|
+
executiontime: z.number().int().nonnegative(),
|
|
132
|
+
free: z.boolean(),
|
|
133
|
+
livemode: z.boolean(),
|
|
134
|
+
quality: z.enum(["", "good", "bad", "risky"]).optional(),
|
|
135
|
+
result: z.enum([
|
|
136
|
+
"",
|
|
137
|
+
"unverified",
|
|
138
|
+
"ok",
|
|
139
|
+
"catch_all",
|
|
140
|
+
"unknown",
|
|
141
|
+
"error",
|
|
142
|
+
"disposable",
|
|
143
|
+
"invalid",
|
|
144
|
+
]),
|
|
145
|
+
resultcode: z.number().int().min(0).max(6),
|
|
146
|
+
role: z.boolean(),
|
|
147
|
+
subresult: z.string(),
|
|
148
|
+
})
|
|
149
|
+
.transform((result) =>
|
|
150
|
+
MILLIONVERIFIER_EMAIL_VERIFICATION_SCHEMA.parse({
|
|
151
|
+
credits: result.credits,
|
|
152
|
+
didYouMean: result.didyoumean,
|
|
153
|
+
email: result.email,
|
|
154
|
+
error: result.error,
|
|
155
|
+
executionTimeMilliseconds: result.executiontime,
|
|
156
|
+
free: result.free,
|
|
157
|
+
liveMode: result.livemode,
|
|
158
|
+
quality: result.quality || undefined,
|
|
159
|
+
result:
|
|
160
|
+
result.result === "catch_all" ? "catchAll" : result.result || "error",
|
|
161
|
+
resultCode: result.resultcode,
|
|
162
|
+
role: result.role,
|
|
163
|
+
subresult: result.subresult,
|
|
164
|
+
}),
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
export const MILLIONVERIFIER_CREDITS_WIRE_SCHEMA = z
|
|
168
|
+
.looseObject({
|
|
169
|
+
bulk_credits: z.number().int().nonnegative(),
|
|
170
|
+
credits: z.number().int().nonnegative(),
|
|
171
|
+
plan: z.number().int(),
|
|
172
|
+
renewing_credits: z.number().int().nonnegative(),
|
|
173
|
+
})
|
|
174
|
+
.transform((credits) =>
|
|
175
|
+
MILLIONVERIFIER_CREDITS_SCHEMA.parse({
|
|
176
|
+
bulkCredits: credits.bulk_credits,
|
|
177
|
+
credits: credits.credits,
|
|
178
|
+
plan: credits.plan,
|
|
179
|
+
renewingCredits: credits.renewing_credits,
|
|
180
|
+
}),
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Maps a provider file status to the public camelCase discriminator.
|
|
185
|
+
*
|
|
186
|
+
* @param status - Provider file status.
|
|
187
|
+
*/
|
|
188
|
+
function fromProviderFileStatus(
|
|
189
|
+
status: z.output<typeof PROVIDER_FILE_STATUS_SCHEMA>,
|
|
190
|
+
) {
|
|
191
|
+
if (status === "in_progress") return "inProgress"
|
|
192
|
+
if (status === "in_queue_to_start") return "inQueueToStart"
|
|
193
|
+
return status
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Maps a public file status to MillionVerifier's query value.
|
|
198
|
+
*
|
|
199
|
+
* @param status - Public file status.
|
|
200
|
+
*/
|
|
201
|
+
export function toMillionVerifierFileStatus(
|
|
202
|
+
status: z.output<typeof MILLIONVERIFIER_FILE_STATUS_SCHEMA>,
|
|
203
|
+
) {
|
|
204
|
+
if (status === "inProgress") return "in_progress"
|
|
205
|
+
if (status === "inQueueToStart") return "in_queue_to_start"
|
|
206
|
+
return status
|
|
207
|
+
}
|
package/src/triggers.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { googleFormsTriggerContracts } from "./google-forms"
|
|
|
12
12
|
import type { googleMeetTriggerContracts } from "./google-meet"
|
|
13
13
|
import type { googleSheetsTriggerContracts } from "./google-sheets"
|
|
14
14
|
import type { linearTriggerContracts } from "./linear"
|
|
15
|
+
import type { millionVerifierTriggerContracts } from "./millionverifier"
|
|
15
16
|
import type { notionTriggerContracts } from "./notion"
|
|
16
17
|
import type { outlookTriggerContracts } from "./outlook"
|
|
17
18
|
import type { resendTriggerContracts } from "./resend"
|
|
@@ -38,6 +39,7 @@ export type TriggerContractMap = typeof airtableTriggerContracts &
|
|
|
38
39
|
typeof googleMeetTriggerContracts &
|
|
39
40
|
typeof googleSheetsTriggerContracts &
|
|
40
41
|
typeof linearTriggerContracts &
|
|
42
|
+
typeof millionVerifierTriggerContracts &
|
|
41
43
|
typeof notionTriggerContracts &
|
|
42
44
|
typeof outlookTriggerContracts &
|
|
43
45
|
typeof resendTriggerContracts &
|