@automate.ax/integration-contracts 0.87.7 → 0.88.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/close/api.d.ts +54 -0
- package/dist/close/api.js +191 -0
- package/dist/close/events.d.ts +3216 -0
- package/dist/close/events.js +575 -0
- package/dist/close/index.d.ts +3 -0
- package/dist/close/index.js +3 -0
- package/dist/close/schemas.d.ts +1900 -0
- package/dist/close/schemas.js +950 -0
- package/dist/github/resources.d.ts +242 -242
- package/dist/google-calendar/schemas.d.ts +3 -3
- package/dist/google-forms/event-schemas.d.ts +4 -4
- package/dist/google-forms/google-forms.d.ts +4 -4
- package/dist/google-forms/index.d.ts +4 -4
- package/dist/google-forms/schemas.d.ts +14 -14
- package/dist/linear/schemas.d.ts +24 -24
- package/dist/triggers.d.ts +2 -1
- package/dist/whatsapp/index.d.ts +6 -6
- package/dist/whatsapp/schemas.d.ts +11 -11
- package/package.json +8 -2
- package/src/close/api.ts +240 -0
- package/src/close/events.ts +755 -0
- package/src/close/index.ts +3 -0
- package/src/close/schemas.ts +995 -0
- package/src/triggers.ts +2 -0
|
@@ -0,0 +1,950 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { CLOSE_OBJECT_SCHEMA, CLOSE_VALUE_SCHEMA } from "./api.js";
|
|
3
|
+
export const CLOSE_DATE_SCHEMA = z
|
|
4
|
+
.union([
|
|
5
|
+
z.date(),
|
|
6
|
+
z.string().refine((value) => !Number.isNaN(Date.parse(value)), {
|
|
7
|
+
message: "Expected a Close date or datetime.",
|
|
8
|
+
}),
|
|
9
|
+
])
|
|
10
|
+
.transform((value) => (value instanceof Date ? value : new Date(value)));
|
|
11
|
+
const DATE_SCHEMA = CLOSE_DATE_SCHEMA;
|
|
12
|
+
const NULLABLE_DATE_SCHEMA = DATE_SCHEMA.nullable();
|
|
13
|
+
export const CLOSE_ADDRESS_SCHEMA = z.object({
|
|
14
|
+
address1: z.string().nullable(),
|
|
15
|
+
address2: z.string().nullable(),
|
|
16
|
+
city: z.string().nullable(),
|
|
17
|
+
country: z.string().nullable(),
|
|
18
|
+
label: z.string().nullable(),
|
|
19
|
+
state: z.string().nullable(),
|
|
20
|
+
tzIds: z.string().array().optional(),
|
|
21
|
+
zipcode: z.string().nullable(),
|
|
22
|
+
});
|
|
23
|
+
export const CLOSE_CONTACT_EMAIL_SCHEMA = z.object({
|
|
24
|
+
email: z.email(),
|
|
25
|
+
isUnsubscribed: z.boolean().prefault(false),
|
|
26
|
+
type: z.string(),
|
|
27
|
+
});
|
|
28
|
+
export const CLOSE_CONTACT_PHONE_SCHEMA = z.object({
|
|
29
|
+
country: z.string().nullable().optional(),
|
|
30
|
+
outboundSmsBlocked: z.boolean().optional(),
|
|
31
|
+
phone: z.string(),
|
|
32
|
+
phoneFormatted: z.string().optional(),
|
|
33
|
+
tzIds: z.string().array().optional(),
|
|
34
|
+
type: z.string(),
|
|
35
|
+
});
|
|
36
|
+
export const CLOSE_CONTACT_URL_SCHEMA = z.object({
|
|
37
|
+
type: z.string(),
|
|
38
|
+
url: z.string(),
|
|
39
|
+
});
|
|
40
|
+
export const CLOSE_LEAD_SCHEMA = z.object({
|
|
41
|
+
addresses: CLOSE_ADDRESS_SCHEMA.array().prefault([]),
|
|
42
|
+
contactIds: z.string().array(),
|
|
43
|
+
createdAt: DATE_SCHEMA,
|
|
44
|
+
createdBy: z.string().nullable(),
|
|
45
|
+
customFields: z.record(z.string(), z.json()).prefault({}),
|
|
46
|
+
description: z.string().nullable(),
|
|
47
|
+
displayName: z.string().optional(),
|
|
48
|
+
htmlUrl: z.url(),
|
|
49
|
+
id: z.string(),
|
|
50
|
+
name: z.string().nullable(),
|
|
51
|
+
organizationId: z.string(),
|
|
52
|
+
source: z.string().nullable().optional(),
|
|
53
|
+
statusId: z.string(),
|
|
54
|
+
statusLabel: z.string().optional(),
|
|
55
|
+
updatedAt: DATE_SCHEMA,
|
|
56
|
+
updatedBy: z.string().nullable(),
|
|
57
|
+
url: z.string().nullable(),
|
|
58
|
+
});
|
|
59
|
+
export const CLOSE_CONTACT_SCHEMA = z.object({
|
|
60
|
+
createdAt: DATE_SCHEMA,
|
|
61
|
+
createdBy: z.string().nullable(),
|
|
62
|
+
customFields: z.record(z.string(), z.json()).prefault({}),
|
|
63
|
+
displayName: z.string(),
|
|
64
|
+
emails: CLOSE_CONTACT_EMAIL_SCHEMA.array().prefault([]),
|
|
65
|
+
id: z.string(),
|
|
66
|
+
leadId: z.string().nullable(),
|
|
67
|
+
name: z.string().nullable(),
|
|
68
|
+
organizationId: z.string(),
|
|
69
|
+
phones: CLOSE_CONTACT_PHONE_SCHEMA.array().prefault([]),
|
|
70
|
+
title: z.string().nullable(),
|
|
71
|
+
updatedAt: DATE_SCHEMA,
|
|
72
|
+
updatedBy: z.string().nullable(),
|
|
73
|
+
urls: CLOSE_CONTACT_URL_SCHEMA.array().prefault([]),
|
|
74
|
+
});
|
|
75
|
+
export const CLOSE_OPPORTUNITY_STATUS_TYPE_SCHEMA = z.enum([
|
|
76
|
+
"active",
|
|
77
|
+
"lost",
|
|
78
|
+
"won",
|
|
79
|
+
]);
|
|
80
|
+
export const CLOSE_ATTACHMENT_SCHEMA = z.object({
|
|
81
|
+
contentType: z.string().nullable(),
|
|
82
|
+
filename: z.string().nullable(),
|
|
83
|
+
size: z.number().int().nullable(),
|
|
84
|
+
thumbnailUrl: z.url().nullable().optional(),
|
|
85
|
+
url: z.url(),
|
|
86
|
+
});
|
|
87
|
+
const CLOSE_OPPORTUNITY_SUGGESTED_ACTION_SCHEMA = z.discriminatedUnion("action", [
|
|
88
|
+
z.object({
|
|
89
|
+
action: z.literal("change_status"),
|
|
90
|
+
details: z.object({ statusId: z.string() }).nullable(),
|
|
91
|
+
justification: z.string(),
|
|
92
|
+
}),
|
|
93
|
+
z.object({
|
|
94
|
+
action: z.literal("adjust_close_date"),
|
|
95
|
+
details: z.object({ closeDate: DATE_SCHEMA }).nullable(),
|
|
96
|
+
justification: z.string(),
|
|
97
|
+
}),
|
|
98
|
+
z.object({
|
|
99
|
+
action: z.literal("follow_up_email"),
|
|
100
|
+
details: z
|
|
101
|
+
.object({
|
|
102
|
+
contactId: z.string(),
|
|
103
|
+
messageDraft: z.string(),
|
|
104
|
+
subjectDraft: z.string(),
|
|
105
|
+
})
|
|
106
|
+
.nullable(),
|
|
107
|
+
justification: z.string(),
|
|
108
|
+
}),
|
|
109
|
+
z.object({
|
|
110
|
+
action: z.literal("follow_up_sms"),
|
|
111
|
+
details: z
|
|
112
|
+
.object({ contactId: z.string(), messageDraft: z.string() })
|
|
113
|
+
.nullable(),
|
|
114
|
+
justification: z.string(),
|
|
115
|
+
}),
|
|
116
|
+
z.object({
|
|
117
|
+
action: z.literal("follow_up_call"),
|
|
118
|
+
details: z
|
|
119
|
+
.object({ callPlan: z.string(), contactId: z.string() })
|
|
120
|
+
.nullable(),
|
|
121
|
+
justification: z.string(),
|
|
122
|
+
}),
|
|
123
|
+
]);
|
|
124
|
+
export const CLOSE_OPPORTUNITY_SCHEMA = z.object({
|
|
125
|
+
annualizedExpectedValue: z.number().int().nullable(),
|
|
126
|
+
annualizedValue: z.number().int().nullable(),
|
|
127
|
+
attachments: CLOSE_ATTACHMENT_SCHEMA.array().optional(),
|
|
128
|
+
commentSummary: z
|
|
129
|
+
.object({ commentCount: z.number().int(), threadId: z.string() })
|
|
130
|
+
.nullable()
|
|
131
|
+
.optional(),
|
|
132
|
+
confidence: z.number().int().min(0).max(100),
|
|
133
|
+
contactId: z.string().nullable(),
|
|
134
|
+
contactName: z.string().nullable().optional(),
|
|
135
|
+
createdAt: DATE_SCHEMA,
|
|
136
|
+
createdBy: z.string().nullable(),
|
|
137
|
+
createdByName: z.string().nullable().optional(),
|
|
138
|
+
customFields: z.record(z.string(), z.json()).prefault({}),
|
|
139
|
+
dateLost: NULLABLE_DATE_SCHEMA,
|
|
140
|
+
dateWon: NULLABLE_DATE_SCHEMA,
|
|
141
|
+
expectedValue: z.number().int().nullable(),
|
|
142
|
+
id: z.string(),
|
|
143
|
+
integrationLinks: z
|
|
144
|
+
.object({ name: z.string(), url: z.url() })
|
|
145
|
+
.array()
|
|
146
|
+
.optional(),
|
|
147
|
+
isStalled: z.boolean().optional(),
|
|
148
|
+
leadId: z.string(),
|
|
149
|
+
leadName: z.string().nullable().optional(),
|
|
150
|
+
leadPrimaryEmail: CLOSE_CONTACT_EMAIL_SCHEMA.nullable().optional(),
|
|
151
|
+
leadPrimaryPhone: CLOSE_CONTACT_PHONE_SCHEMA.array().nullable().optional(),
|
|
152
|
+
note: z.string().nullable(),
|
|
153
|
+
noteHtml: z.string().nullable(),
|
|
154
|
+
organizationId: z.string(),
|
|
155
|
+
pipelineId: z.string().nullable().optional(),
|
|
156
|
+
pipelineName: z.string().nullable().optional(),
|
|
157
|
+
stallStatus: z
|
|
158
|
+
.object({
|
|
159
|
+
communicationIssue: z.enum([
|
|
160
|
+
"no_issue",
|
|
161
|
+
"cant_get_in_touch",
|
|
162
|
+
"no_communication_attempts",
|
|
163
|
+
]),
|
|
164
|
+
nextAction: z.object({
|
|
165
|
+
action: z.enum([
|
|
166
|
+
"mark_as_lost",
|
|
167
|
+
"change_status",
|
|
168
|
+
"follow_up",
|
|
169
|
+
"adjust_close_date",
|
|
170
|
+
"ask_someone_else_to_reach_out",
|
|
171
|
+
"change_communication_method",
|
|
172
|
+
]),
|
|
173
|
+
justification: z.string(),
|
|
174
|
+
}),
|
|
175
|
+
})
|
|
176
|
+
.nullable()
|
|
177
|
+
.optional(),
|
|
178
|
+
statusId: z.string(),
|
|
179
|
+
statusDisplayName: z.string().optional(),
|
|
180
|
+
statusLabel: z.string().optional(),
|
|
181
|
+
statusType: CLOSE_OPPORTUNITY_STATUS_TYPE_SCHEMA.optional(),
|
|
182
|
+
suggestedAction: CLOSE_OPPORTUNITY_SUGGESTED_ACTION_SCHEMA.nullable().optional(),
|
|
183
|
+
updatedAt: DATE_SCHEMA,
|
|
184
|
+
updatedBy: z.string().nullable(),
|
|
185
|
+
updatedByName: z.string().nullable().optional(),
|
|
186
|
+
userId: z.string(),
|
|
187
|
+
userName: z.string().nullable().optional(),
|
|
188
|
+
value: z.number().int().nullable(),
|
|
189
|
+
valueCurrency: z.string().nullable().optional(),
|
|
190
|
+
valueFormatted: z.string().nullable().optional(),
|
|
191
|
+
valuePeriod: z.enum(["annual", "monthly", "one_time"]),
|
|
192
|
+
});
|
|
193
|
+
export const CLOSE_OPPORTUNITY_PAGE_SCHEMA = z.object({
|
|
194
|
+
countByValuePeriod: z.record(z.string(), z.number().int().nonnegative()),
|
|
195
|
+
data: CLOSE_OPPORTUNITY_SCHEMA.array(),
|
|
196
|
+
expectedValueAnnual: z.number().int(),
|
|
197
|
+
expectedValueAnnualFormatted: z.string(),
|
|
198
|
+
expectedValueAnnualized: z.number().int(),
|
|
199
|
+
expectedValueAnnualizedFormatted: z.string(),
|
|
200
|
+
expectedValueMonthly: z.number().int(),
|
|
201
|
+
expectedValueMonthlyFormatted: z.string(),
|
|
202
|
+
expectedValueOneTime: z.number().int(),
|
|
203
|
+
expectedValueOneTimeFormatted: z.string(),
|
|
204
|
+
hasMore: z.boolean(),
|
|
205
|
+
totalResults: z.number().int().nonnegative(),
|
|
206
|
+
totalValueAnnual: z.number().int(),
|
|
207
|
+
totalValueAnnualFormatted: z.string(),
|
|
208
|
+
totalValueAnnualized: z.number().int(),
|
|
209
|
+
totalValueAnnualizedFormatted: z.string(),
|
|
210
|
+
totalValueMonthly: z.number().int(),
|
|
211
|
+
totalValueMonthlyFormatted: z.string(),
|
|
212
|
+
totalValueOneTime: z.number().int(),
|
|
213
|
+
totalValueOneTimeFormatted: z.string(),
|
|
214
|
+
});
|
|
215
|
+
const CLOSE_TASK_FIELDS = {
|
|
216
|
+
assignedTo: z.string().nullable(),
|
|
217
|
+
assignedToName: z.string().nullable().optional(),
|
|
218
|
+
contactId: z.string().nullable(),
|
|
219
|
+
contactName: z.string().nullable().optional(),
|
|
220
|
+
createdAt: DATE_SCHEMA,
|
|
221
|
+
createdBy: z.string().nullable(),
|
|
222
|
+
createdByName: z.string().nullable().optional(),
|
|
223
|
+
date: NULLABLE_DATE_SCHEMA,
|
|
224
|
+
dueDate: NULLABLE_DATE_SCHEMA.optional(),
|
|
225
|
+
id: z.string(),
|
|
226
|
+
isComplete: z.boolean(),
|
|
227
|
+
isDateless: z.boolean().optional(),
|
|
228
|
+
leadId: z.string().nullable(),
|
|
229
|
+
leadName: z.string().nullable().optional(),
|
|
230
|
+
objectId: z.string().nullable().optional(),
|
|
231
|
+
objectType: z.string().nullable().optional(),
|
|
232
|
+
organizationId: z.string(),
|
|
233
|
+
priority: z.enum(["high", "medium"]).nullable().optional(),
|
|
234
|
+
text: z.string().nullable().optional(),
|
|
235
|
+
updatedAt: DATE_SCHEMA,
|
|
236
|
+
updatedBy: z.string().nullable(),
|
|
237
|
+
updatedByName: z.string().nullable().optional(),
|
|
238
|
+
view: z.enum(["archive", "future", "inbox"]).optional(),
|
|
239
|
+
};
|
|
240
|
+
const CLOSE_TASK_PHONE_FIELDS = {
|
|
241
|
+
localPhone: z.string().nullable().optional(),
|
|
242
|
+
phone: z.string().nullable().optional(),
|
|
243
|
+
phoneFormatted: z.string().nullable().optional(),
|
|
244
|
+
phoneNumberDescription: z.string().nullable().optional(),
|
|
245
|
+
};
|
|
246
|
+
export const CLOSE_TASK_SCHEMA = z.discriminatedUnion("type", [
|
|
247
|
+
z.object({ ...CLOSE_TASK_FIELDS, type: z.literal("lead") }),
|
|
248
|
+
z.object({
|
|
249
|
+
...CLOSE_TASK_FIELDS,
|
|
250
|
+
...CLOSE_TASK_PHONE_FIELDS,
|
|
251
|
+
type: z.literal("missed_call"),
|
|
252
|
+
}),
|
|
253
|
+
z.object({
|
|
254
|
+
...CLOSE_TASK_FIELDS,
|
|
255
|
+
...CLOSE_TASK_PHONE_FIELDS,
|
|
256
|
+
type: z.literal("voicemail"),
|
|
257
|
+
voicemailDuration: z.number().int().nonnegative().optional(),
|
|
258
|
+
voicemailUrl: z.url().optional(),
|
|
259
|
+
}),
|
|
260
|
+
z.object({
|
|
261
|
+
...CLOSE_TASK_FIELDS,
|
|
262
|
+
bodyPreview: z.string().nullable().optional(),
|
|
263
|
+
emails: z.string().array().optional(),
|
|
264
|
+
subject: z.string().nullable().optional(),
|
|
265
|
+
type: z.literal("incoming_email"),
|
|
266
|
+
}),
|
|
267
|
+
z.object({
|
|
268
|
+
...CLOSE_TASK_FIELDS,
|
|
269
|
+
bodyPreview: z.string().nullable().optional(),
|
|
270
|
+
emailId: z.string().optional(),
|
|
271
|
+
subject: z.string().nullable().optional(),
|
|
272
|
+
type: z.literal("email_followup"),
|
|
273
|
+
}),
|
|
274
|
+
z.object({
|
|
275
|
+
...CLOSE_TASK_FIELDS,
|
|
276
|
+
...CLOSE_TASK_PHONE_FIELDS,
|
|
277
|
+
recordingUrl: z.url().nullable().optional(),
|
|
278
|
+
type: z.literal("answered_detached_call"),
|
|
279
|
+
}),
|
|
280
|
+
z.object({
|
|
281
|
+
...CLOSE_TASK_FIELDS,
|
|
282
|
+
opportunityNote: z.string().nullable().optional(),
|
|
283
|
+
opportunityValue: z.number().int().nullable().optional(),
|
|
284
|
+
opportunityValueCurrency: z.string().nullable().optional(),
|
|
285
|
+
opportunityValueFormatted: z.string().nullable().optional(),
|
|
286
|
+
opportunityValuePeriod: z
|
|
287
|
+
.enum(["annual", "monthly", "one_time"])
|
|
288
|
+
.nullable()
|
|
289
|
+
.optional(),
|
|
290
|
+
type: z.literal("opportunity_due"),
|
|
291
|
+
}),
|
|
292
|
+
z.object({
|
|
293
|
+
...CLOSE_TASK_FIELDS,
|
|
294
|
+
attachments: z
|
|
295
|
+
.object({
|
|
296
|
+
contentType: z.string(),
|
|
297
|
+
filename: z.string(),
|
|
298
|
+
mediaId: z.string(),
|
|
299
|
+
size: z.number().int().nonnegative(),
|
|
300
|
+
thumbnailUrl: z.url().nullable().optional(),
|
|
301
|
+
url: z.url(),
|
|
302
|
+
})
|
|
303
|
+
.array()
|
|
304
|
+
.optional(),
|
|
305
|
+
localPhone: z.string().nullable().optional(),
|
|
306
|
+
remotePhone: z.string().nullable().optional(),
|
|
307
|
+
remotePhoneDescription: z.string().nullable().optional(),
|
|
308
|
+
remotePhoneFormatted: z.string().nullable().optional(),
|
|
309
|
+
type: z.literal("incoming_sms"),
|
|
310
|
+
}),
|
|
311
|
+
z.object({
|
|
312
|
+
...CLOSE_TASK_FIELDS,
|
|
313
|
+
agentConfigId: z.string().nullable().optional(),
|
|
314
|
+
deduplicationKey: z.string().nullable().optional(),
|
|
315
|
+
isPrimaryLeadNotification: z.boolean().optional(),
|
|
316
|
+
resolution: z.string().nullable().optional(),
|
|
317
|
+
sequenceId: z.string().nullable().optional(),
|
|
318
|
+
sequenceSubscriptionId: z.string().nullable().optional(),
|
|
319
|
+
stepId: z.string().nullable().optional(),
|
|
320
|
+
type: z.literal("outgoing_call"),
|
|
321
|
+
}),
|
|
322
|
+
]);
|
|
323
|
+
const CLOSE_CREATION_SOURCE_SCHEMA = z.enum([
|
|
324
|
+
"ui",
|
|
325
|
+
"api",
|
|
326
|
+
"import",
|
|
327
|
+
"clipper",
|
|
328
|
+
"email",
|
|
329
|
+
"suggestion",
|
|
330
|
+
"segment-integration",
|
|
331
|
+
"customerio-integration",
|
|
332
|
+
"calendly-integration",
|
|
333
|
+
"ai",
|
|
334
|
+
"whatsapp",
|
|
335
|
+
"webform",
|
|
336
|
+
]);
|
|
337
|
+
export const CLOSE_NOTE_SCHEMA = z.object({
|
|
338
|
+
activityAt: NULLABLE_DATE_SCHEMA,
|
|
339
|
+
attachments: CLOSE_ATTACHMENT_SCHEMA.array(),
|
|
340
|
+
contactId: z.string().nullable(),
|
|
341
|
+
createdAt: DATE_SCHEMA,
|
|
342
|
+
createdBy: z.string().nullable(),
|
|
343
|
+
id: z.string(),
|
|
344
|
+
leadId: z.string().nullable(),
|
|
345
|
+
note: z.string(),
|
|
346
|
+
noteHtml: z.string(),
|
|
347
|
+
noteMentions: z.string().array(),
|
|
348
|
+
organizationId: z.string(),
|
|
349
|
+
pinned: z.boolean(),
|
|
350
|
+
pinnedAt: NULLABLE_DATE_SCHEMA,
|
|
351
|
+
source: CLOSE_CREATION_SOURCE_SCHEMA.nullable(),
|
|
352
|
+
title: z.string().nullable(),
|
|
353
|
+
type: z.literal("Note"),
|
|
354
|
+
updatedAt: DATE_SCHEMA,
|
|
355
|
+
updatedBy: z.string().nullable(),
|
|
356
|
+
userId: z.string().nullable(),
|
|
357
|
+
users: z.string().array(),
|
|
358
|
+
});
|
|
359
|
+
const CLOSE_ACTIVITY_FIELDS = {
|
|
360
|
+
activityAt: NULLABLE_DATE_SCHEMA.optional(),
|
|
361
|
+
contactId: z.string().nullable().optional(),
|
|
362
|
+
createdAt: DATE_SCHEMA,
|
|
363
|
+
createdBy: z.string().nullable(),
|
|
364
|
+
createdByName: z.string().nullable().optional(),
|
|
365
|
+
id: z.string(),
|
|
366
|
+
leadId: z.string().nullable(),
|
|
367
|
+
organizationId: z.string(),
|
|
368
|
+
source: z.string().nullable().optional(),
|
|
369
|
+
updatedAt: DATE_SCHEMA,
|
|
370
|
+
updatedBy: z.string().nullable(),
|
|
371
|
+
updatedByName: z.string().nullable().optional(),
|
|
372
|
+
userId: z.string().nullable().optional(),
|
|
373
|
+
userName: z.string().nullable().optional(),
|
|
374
|
+
users: z.string().array().prefault([]),
|
|
375
|
+
};
|
|
376
|
+
const CLOSE_EXACT_ACTIVITY_FIELDS = {
|
|
377
|
+
...CLOSE_ACTIVITY_FIELDS,
|
|
378
|
+
activityAt: NULLABLE_DATE_SCHEMA,
|
|
379
|
+
contactId: z.string().nullable(),
|
|
380
|
+
userId: z.string().nullable(),
|
|
381
|
+
};
|
|
382
|
+
const CLOSE_TASK_COMPLETED_ACTIVITY_FIELDS = {
|
|
383
|
+
...CLOSE_ACTIVITY_FIELDS,
|
|
384
|
+
activityAt: NULLABLE_DATE_SCHEMA,
|
|
385
|
+
userId: z.string().nullable(),
|
|
386
|
+
};
|
|
387
|
+
export const CLOSE_CALL_SCHEMA = z
|
|
388
|
+
.object({
|
|
389
|
+
...CLOSE_ACTIVITY_FIELDS,
|
|
390
|
+
activityAt: NULLABLE_DATE_SCHEMA,
|
|
391
|
+
callMethod: z.string().nullable().optional(),
|
|
392
|
+
contactId: z.string().nullable(),
|
|
393
|
+
cost: z.string().nullable().optional(),
|
|
394
|
+
dialerId: z.string().nullable().optional(),
|
|
395
|
+
dialerSavedSearchId: z.string().nullable().optional(),
|
|
396
|
+
direction: z.enum(["inbound", "outbound"]),
|
|
397
|
+
disposition: z.string().nullable().optional(),
|
|
398
|
+
duration: z.number().int().nonnegative().nullable(),
|
|
399
|
+
localCountryIso: z.string().nullable().optional(),
|
|
400
|
+
localPhone: z.string().nullable().optional(),
|
|
401
|
+
localPhoneFormatted: z.string().nullable().optional(),
|
|
402
|
+
note: z.string().nullable(),
|
|
403
|
+
noteHtml: z.string().nullable(),
|
|
404
|
+
outcomeId: z.string().nullable(),
|
|
405
|
+
phone: z.string().nullable(),
|
|
406
|
+
recordingUrl: z.url().nullable(),
|
|
407
|
+
remoteCountryIso: z.string().nullable().optional(),
|
|
408
|
+
remotePhone: z.string().nullable().optional(),
|
|
409
|
+
remotePhoneFormatted: z.string().nullable().optional(),
|
|
410
|
+
source: z.enum(["Close.io", "External"]),
|
|
411
|
+
status: z.enum([
|
|
412
|
+
"busy",
|
|
413
|
+
"cancel",
|
|
414
|
+
"completed",
|
|
415
|
+
"created",
|
|
416
|
+
"failed",
|
|
417
|
+
"in-progress",
|
|
418
|
+
"no-answer",
|
|
419
|
+
"timeout",
|
|
420
|
+
]),
|
|
421
|
+
type: z.literal("Call"),
|
|
422
|
+
userId: z.string().nullable(),
|
|
423
|
+
voicemailDuration: z.number().int().nonnegative().nullable().optional(),
|
|
424
|
+
voicemailUrl: z.url().nullable().optional(),
|
|
425
|
+
})
|
|
426
|
+
.catchall(CLOSE_VALUE_SCHEMA);
|
|
427
|
+
export const CLOSE_EMAIL_SCHEMA = z
|
|
428
|
+
.object({
|
|
429
|
+
...CLOSE_ACTIVITY_FIELDS,
|
|
430
|
+
activityAt: NULLABLE_DATE_SCHEMA,
|
|
431
|
+
attachments: CLOSE_ATTACHMENT_SCHEMA.array().nullable().optional(),
|
|
432
|
+
bcc: z.string().array().prefault([]),
|
|
433
|
+
bodyHtml: z.string().nullable(),
|
|
434
|
+
bodyText: z.string().nullable(),
|
|
435
|
+
bulkEmailActionId: z.string().nullable(),
|
|
436
|
+
cc: z.string().array().prefault([]),
|
|
437
|
+
contactId: z.string().nullable(),
|
|
438
|
+
dateScheduled: NULLABLE_DATE_SCHEMA,
|
|
439
|
+
dateSent: NULLABLE_DATE_SCHEMA,
|
|
440
|
+
direction: z.enum(["incoming", "outgoing"]).nullable(),
|
|
441
|
+
emailAccountId: z.string().nullable().optional(),
|
|
442
|
+
followupSequenceAddCcBcc: z.boolean(),
|
|
443
|
+
followupSequenceDelay: z.number().int().nullable(),
|
|
444
|
+
hasReply: z.boolean(),
|
|
445
|
+
inReplyToId: z.string().nullable(),
|
|
446
|
+
messageIds: z.string().array().prefault([]),
|
|
447
|
+
needSmtpCredentials: z.boolean(),
|
|
448
|
+
opens: z
|
|
449
|
+
.object({
|
|
450
|
+
ipAddress: z.string().nullable(),
|
|
451
|
+
openedAt: DATE_SCHEMA,
|
|
452
|
+
openedBy: z.string().nullable(),
|
|
453
|
+
userAgent: z.string().nullable(),
|
|
454
|
+
})
|
|
455
|
+
.array()
|
|
456
|
+
.nullable()
|
|
457
|
+
.optional(),
|
|
458
|
+
opensSummary: z.string().nullable(),
|
|
459
|
+
references: z.string().array().prefault([]),
|
|
460
|
+
sendAsId: z.string().nullable(),
|
|
461
|
+
sendAttempts: z
|
|
462
|
+
.record(z.string(), z.string())
|
|
463
|
+
.array()
|
|
464
|
+
.nullable()
|
|
465
|
+
.optional(),
|
|
466
|
+
sender: z.string().nullable(),
|
|
467
|
+
sequenceId: z.string().nullable().optional(),
|
|
468
|
+
sequenceName: z.string().nullable().optional(),
|
|
469
|
+
sequenceSubscriptionId: z.string().nullable().optional(),
|
|
470
|
+
status: z.enum(["draft", "error", "inbox", "outbox", "scheduled", "sent"]),
|
|
471
|
+
subject: z.string().nullable(),
|
|
472
|
+
templateId: z.string().nullable(),
|
|
473
|
+
threadId: z.string().nullable(),
|
|
474
|
+
to: z.string().array().prefault([]),
|
|
475
|
+
type: z.literal("Email"),
|
|
476
|
+
userId: z.string().nullable(),
|
|
477
|
+
})
|
|
478
|
+
.catchall(CLOSE_VALUE_SCHEMA);
|
|
479
|
+
export const CLOSE_SMS_SCHEMA = z
|
|
480
|
+
.object({
|
|
481
|
+
...CLOSE_ACTIVITY_FIELDS,
|
|
482
|
+
activityAt: NULLABLE_DATE_SCHEMA,
|
|
483
|
+
attachments: CLOSE_ATTACHMENT_SCHEMA.array().nullable().optional(),
|
|
484
|
+
contactId: z.string().nullable(),
|
|
485
|
+
cost: z.string().nullable(),
|
|
486
|
+
dateScheduled: NULLABLE_DATE_SCHEMA,
|
|
487
|
+
dateSent: NULLABLE_DATE_SCHEMA,
|
|
488
|
+
direction: z.enum(["inbound", "outbound"]),
|
|
489
|
+
errorMessage: z.string().nullable(),
|
|
490
|
+
localCountryIso: z.string().nullable(),
|
|
491
|
+
localPhone: z.string().nullable(),
|
|
492
|
+
localPhoneFormatted: z.string().nullable(),
|
|
493
|
+
remoteCountryIso: z.string().nullable(),
|
|
494
|
+
remotePhone: z.string().nullable(),
|
|
495
|
+
remotePhoneFormatted: z.string().nullable(),
|
|
496
|
+
source: z.enum(["Close.io", "External"]),
|
|
497
|
+
status: z.enum(["draft", "error", "inbox", "outbox", "scheduled", "sent"]),
|
|
498
|
+
templateId: z.string().nullable(),
|
|
499
|
+
text: z.string().nullable(),
|
|
500
|
+
type: z.literal("SMS"),
|
|
501
|
+
userId: z.string().nullable(),
|
|
502
|
+
})
|
|
503
|
+
.catchall(CLOSE_VALUE_SCHEMA);
|
|
504
|
+
export const CLOSE_MEETING_SCHEMA = z
|
|
505
|
+
.object({
|
|
506
|
+
...CLOSE_ACTIVITY_FIELDS,
|
|
507
|
+
actualDuration: z.number().int().nonnegative().nullable(),
|
|
508
|
+
attachedCallIds: z.string().array().prefault([]),
|
|
509
|
+
attendees: CLOSE_OBJECT_SCHEMA.array().prefault([]),
|
|
510
|
+
calendarEventLink: z.url().nullable(),
|
|
511
|
+
calendarEventUids: z.string().array().prefault([]),
|
|
512
|
+
conferenceLinks: CLOSE_OBJECT_SCHEMA.array().prefault([]),
|
|
513
|
+
connectedAccountId: z.string().nullable(),
|
|
514
|
+
duration: z.number().int().nonnegative(),
|
|
515
|
+
endsAt: DATE_SCHEMA,
|
|
516
|
+
integrations: CLOSE_OBJECT_SCHEMA.array().prefault([]),
|
|
517
|
+
isRecurring: z.boolean(),
|
|
518
|
+
location: z.string().nullable(),
|
|
519
|
+
note: z.string().nullable(),
|
|
520
|
+
outcomeId: z.string().nullable(),
|
|
521
|
+
providerCalendarEventId: z.string().nullable(),
|
|
522
|
+
providerCalendarIds: z.string().array().prefault([]),
|
|
523
|
+
providerCalendarType: z.enum(["google", "microsoft"]).nullable(),
|
|
524
|
+
source: z.enum(["calendar", "manual"]),
|
|
525
|
+
startsAt: DATE_SCHEMA,
|
|
526
|
+
status: z
|
|
527
|
+
.enum([
|
|
528
|
+
"upcoming",
|
|
529
|
+
"in-progress",
|
|
530
|
+
"completed",
|
|
531
|
+
"canceled",
|
|
532
|
+
"declined-by-org",
|
|
533
|
+
"declined-by-lead",
|
|
534
|
+
])
|
|
535
|
+
.nullable(),
|
|
536
|
+
summary: z.object({ html: z.string(), text: z.string() }).nullable(),
|
|
537
|
+
title: z.string().nullable(),
|
|
538
|
+
type: z.literal("Meeting"),
|
|
539
|
+
})
|
|
540
|
+
.catchall(CLOSE_VALUE_SCHEMA);
|
|
541
|
+
const CLOSE_COMMENT_SUMMARY_SCHEMA = z.object({
|
|
542
|
+
commentCount: z.number().int(),
|
|
543
|
+
threadId: z.string(),
|
|
544
|
+
});
|
|
545
|
+
const CLOSE_CREATED_ACTIVITY_SCHEMA = z.object({
|
|
546
|
+
...CLOSE_EXACT_ACTIVITY_FIELDS,
|
|
547
|
+
importId: z.string().nullable(),
|
|
548
|
+
source: CLOSE_CREATION_SOURCE_SCHEMA.nullable(),
|
|
549
|
+
type: z.literal("Created"),
|
|
550
|
+
});
|
|
551
|
+
const CLOSE_CUSTOM_ACTIVITY_SCHEMA = z
|
|
552
|
+
.object({
|
|
553
|
+
...CLOSE_EXACT_ACTIVITY_FIELDS,
|
|
554
|
+
commentSummary: CLOSE_COMMENT_SUMMARY_SCHEMA.nullable().optional(),
|
|
555
|
+
customActivityTypeId: z.string(),
|
|
556
|
+
customFields: z.record(z.string(), z.json()).prefault({}),
|
|
557
|
+
lastPublishedAt: NULLABLE_DATE_SCHEMA,
|
|
558
|
+
mentions: z.string().array(),
|
|
559
|
+
mentionsUpdatedAt: NULLABLE_DATE_SCHEMA,
|
|
560
|
+
pinned: z.boolean(),
|
|
561
|
+
pinnedAt: NULLABLE_DATE_SCHEMA,
|
|
562
|
+
source: CLOSE_CREATION_SOURCE_SCHEMA.nullable(),
|
|
563
|
+
status: z.enum(["draft", "published"]),
|
|
564
|
+
type: z.literal("CustomActivity"),
|
|
565
|
+
})
|
|
566
|
+
.catchall(CLOSE_VALUE_SCHEMA);
|
|
567
|
+
const CLOSE_EMAIL_IDENTITY_SCHEMA = z.object({
|
|
568
|
+
email: z.string(),
|
|
569
|
+
name: z.string(),
|
|
570
|
+
});
|
|
571
|
+
const CLOSE_EMAIL_ENVELOPE_SCHEMA = z.object({
|
|
572
|
+
bcc: CLOSE_EMAIL_IDENTITY_SCHEMA.array(),
|
|
573
|
+
cc: CLOSE_EMAIL_IDENTITY_SCHEMA.array(),
|
|
574
|
+
date: z.string().nullable(),
|
|
575
|
+
from: CLOSE_EMAIL_IDENTITY_SCHEMA.array(),
|
|
576
|
+
inReplyTo: z.string().nullable(),
|
|
577
|
+
isAutoreply: z.boolean(),
|
|
578
|
+
messageId: z.string().nullable(),
|
|
579
|
+
replyTo: CLOSE_EMAIL_IDENTITY_SCHEMA.array(),
|
|
580
|
+
sender: CLOSE_EMAIL_IDENTITY_SCHEMA.array(),
|
|
581
|
+
subject: z.string().nullable(),
|
|
582
|
+
to: CLOSE_EMAIL_IDENTITY_SCHEMA.array(),
|
|
583
|
+
});
|
|
584
|
+
const CLOSE_EMAIL_PREVIEW_SCHEMA = z.object({
|
|
585
|
+
bcc: z.string().array(),
|
|
586
|
+
bodyPreview: z.string().nullable(),
|
|
587
|
+
cc: z.string().array(),
|
|
588
|
+
createdAt: DATE_SCHEMA,
|
|
589
|
+
dateSent: NULLABLE_DATE_SCHEMA,
|
|
590
|
+
direction: z.enum(["incoming", "outgoing"]),
|
|
591
|
+
envelope: CLOSE_EMAIL_ENVELOPE_SCHEMA.nullable(),
|
|
592
|
+
hasAttachments: z.boolean().nullable(),
|
|
593
|
+
id: z.string().nullable(),
|
|
594
|
+
opensSummary: z.string().nullable(),
|
|
595
|
+
sendAsId: z.string().nullable(),
|
|
596
|
+
sender: z.string().nullable(),
|
|
597
|
+
status: z.enum(["draft", "error", "inbox", "outbox", "scheduled", "sent"]),
|
|
598
|
+
subject: z.string().nullable(),
|
|
599
|
+
to: z.string().array(),
|
|
600
|
+
updatedAt: DATE_SCHEMA,
|
|
601
|
+
userId: z.string().nullable(),
|
|
602
|
+
});
|
|
603
|
+
const CLOSE_EMAIL_IN_THREAD_SCHEMA = CLOSE_EMAIL_SCHEMA.extend({
|
|
604
|
+
bodyHtml: z.string().nullable().optional(),
|
|
605
|
+
bodyText: z.string().nullable().optional(),
|
|
606
|
+
});
|
|
607
|
+
const CLOSE_EMAIL_THREAD_SCHEMA = z.object({
|
|
608
|
+
...CLOSE_EXACT_ACTIVITY_FIELDS,
|
|
609
|
+
emails: CLOSE_EMAIL_IN_THREAD_SCHEMA.array().optional(),
|
|
610
|
+
importance: z
|
|
611
|
+
.discriminatedUnion("type", [
|
|
612
|
+
z.object({
|
|
613
|
+
reason: z.enum([
|
|
614
|
+
"manual",
|
|
615
|
+
"contains-manual-message",
|
|
616
|
+
"most-recent-communication",
|
|
617
|
+
"has-response",
|
|
618
|
+
"whitelisted",
|
|
619
|
+
"by-default",
|
|
620
|
+
"unset-initial-default",
|
|
621
|
+
]),
|
|
622
|
+
type: z.literal("important"),
|
|
623
|
+
}),
|
|
624
|
+
z.object({
|
|
625
|
+
reason: z.enum([
|
|
626
|
+
"manual",
|
|
627
|
+
"scheduling-emails",
|
|
628
|
+
"automated-outbound",
|
|
629
|
+
"marketing-or-transactional",
|
|
630
|
+
"by-default",
|
|
631
|
+
]),
|
|
632
|
+
type: z.literal("not_important"),
|
|
633
|
+
}),
|
|
634
|
+
])
|
|
635
|
+
.optional(),
|
|
636
|
+
latestEmails: CLOSE_EMAIL_PREVIEW_SCHEMA.array().optional(),
|
|
637
|
+
latestNormalizedSubject: z.string().nullable(),
|
|
638
|
+
nEmails: z.number().int().nullable(),
|
|
639
|
+
participants: CLOSE_EMAIL_IDENTITY_SCHEMA.array().optional(),
|
|
640
|
+
summary: z
|
|
641
|
+
.object({
|
|
642
|
+
expiredAt: NULLABLE_DATE_SCHEMA,
|
|
643
|
+
feedback: z
|
|
644
|
+
.object({
|
|
645
|
+
detail: z.string().nullable(),
|
|
646
|
+
givenAt: DATE_SCHEMA,
|
|
647
|
+
rating: z.enum(["positive", "negative"]),
|
|
648
|
+
})
|
|
649
|
+
.optional(),
|
|
650
|
+
generatedAt: NULLABLE_DATE_SCHEMA,
|
|
651
|
+
status: z.enum(["pending", "success", "failure", "expired"]),
|
|
652
|
+
summaryHtml: z.string().nullable(),
|
|
653
|
+
summaryText: z.string().nullable(),
|
|
654
|
+
updatedAt: DATE_SCHEMA,
|
|
655
|
+
})
|
|
656
|
+
.nullable()
|
|
657
|
+
.optional(),
|
|
658
|
+
type: z.literal("EmailThread"),
|
|
659
|
+
});
|
|
660
|
+
const CLOSE_FORM_SUBMISSION_SCHEMA = z.object({
|
|
661
|
+
...CLOSE_EXACT_ACTIVITY_FIELDS,
|
|
662
|
+
formConfigurationId: z.string(),
|
|
663
|
+
formId: z.string(),
|
|
664
|
+
formName: z.string().nullable().optional(),
|
|
665
|
+
ipAddress: z.string().nullable(),
|
|
666
|
+
origin: z.string().nullable(),
|
|
667
|
+
sourceUrl: z.string().nullable(),
|
|
668
|
+
sourceUrlNormalized: z.string().nullable(),
|
|
669
|
+
type: z.literal("FormSubmission"),
|
|
670
|
+
values: z.record(z.string(), z.union([z.string(), z.boolean(), z.null()])),
|
|
671
|
+
valuesByName: z.record(z.string(), z.union([z.string(), z.boolean(), z.null()])),
|
|
672
|
+
});
|
|
673
|
+
const CLOSE_IMPORT_UPDATE_SCHEMA = z.object({
|
|
674
|
+
...CLOSE_EXACT_ACTIVITY_FIELDS,
|
|
675
|
+
importId: z.string().nullable(),
|
|
676
|
+
reverted: z.boolean(),
|
|
677
|
+
type: z.literal("ImportUpdate"),
|
|
678
|
+
});
|
|
679
|
+
const CLOSE_LEAD_MERGE_SCHEMA = z.object({
|
|
680
|
+
...CLOSE_EXACT_ACTIVITY_FIELDS,
|
|
681
|
+
destinationDisplayName: z.string().nullable(),
|
|
682
|
+
destinationLeadId: z.string(),
|
|
683
|
+
errorMessage: z.string().nullable(),
|
|
684
|
+
mergeStatus: z.enum(["pending", "in_progress", "completed", "errored"]),
|
|
685
|
+
sourceDisplayName: z.string().nullable(),
|
|
686
|
+
sourceLeadId: z.string(),
|
|
687
|
+
type: z.literal("LeadMerge"),
|
|
688
|
+
});
|
|
689
|
+
const CLOSE_LEAD_STATUS_CHANGE_SCHEMA = z.object({
|
|
690
|
+
...CLOSE_EXACT_ACTIVITY_FIELDS,
|
|
691
|
+
newStatusId: z.string(),
|
|
692
|
+
newStatusLabel: z.string().optional(),
|
|
693
|
+
oldStatusId: z.string(),
|
|
694
|
+
oldStatusLabel: z.string().optional(),
|
|
695
|
+
pausedSubscriptions: z
|
|
696
|
+
.object({
|
|
697
|
+
contactId: z.string().nullable(),
|
|
698
|
+
contactName: z.string().nullable(),
|
|
699
|
+
id: z.string(),
|
|
700
|
+
sequenceId: z.string(),
|
|
701
|
+
sequenceName: z.string(),
|
|
702
|
+
sequenceStatus: z.string(),
|
|
703
|
+
})
|
|
704
|
+
.array()
|
|
705
|
+
.optional(),
|
|
706
|
+
type: z.literal("LeadStatusChange"),
|
|
707
|
+
});
|
|
708
|
+
const CLOSE_OPPORTUNITY_STATUS_CHANGE_SCHEMA = z.object({
|
|
709
|
+
...CLOSE_EXACT_ACTIVITY_FIELDS,
|
|
710
|
+
newPipelineId: z.string().optional(),
|
|
711
|
+
newPipelineName: z.string().optional(),
|
|
712
|
+
newStatusId: z.string(),
|
|
713
|
+
newStatusLabel: z.string().optional(),
|
|
714
|
+
newStatusType: CLOSE_OPPORTUNITY_STATUS_TYPE_SCHEMA.optional(),
|
|
715
|
+
oldPipelineId: z.string().optional(),
|
|
716
|
+
oldPipelineName: z.string().optional(),
|
|
717
|
+
oldStatusId: z.string(),
|
|
718
|
+
oldStatusLabel: z.string().optional(),
|
|
719
|
+
oldStatusType: CLOSE_OPPORTUNITY_STATUS_TYPE_SCHEMA.optional(),
|
|
720
|
+
opportunityConfidence: z.number().int().nullable().optional(),
|
|
721
|
+
opportunityDateWon: NULLABLE_DATE_SCHEMA.optional(),
|
|
722
|
+
opportunityId: z.string().nullable(),
|
|
723
|
+
opportunityValue: z.number().int().nullable().optional(),
|
|
724
|
+
opportunityValueCurrency: z.string().nullable().optional(),
|
|
725
|
+
opportunityValueFormatted: z.string().nullable().optional(),
|
|
726
|
+
opportunityValuePeriod: z
|
|
727
|
+
.enum(["annual", "monthly", "one_time"])
|
|
728
|
+
.nullable()
|
|
729
|
+
.optional(),
|
|
730
|
+
type: z.literal("OpportunityStatusChange"),
|
|
731
|
+
});
|
|
732
|
+
const CLOSE_TASK_COMPLETED_ACTIVITY_SCHEMA = z.object({
|
|
733
|
+
...CLOSE_TASK_COMPLETED_ACTIVITY_FIELDS,
|
|
734
|
+
commentSummary: CLOSE_COMMENT_SUMMARY_SCHEMA.nullable().optional(),
|
|
735
|
+
sequenceId: z.string().nullable().optional(),
|
|
736
|
+
sequenceName: z.string().nullable().optional(),
|
|
737
|
+
sequenceSubscriptionId: z.string().nullable().optional(),
|
|
738
|
+
taskAssignedTo: z.string().nullable().optional(),
|
|
739
|
+
taskAssignedToName: z.string().nullable().optional(),
|
|
740
|
+
taskId: z.string().nullable(),
|
|
741
|
+
taskText: z.string().nullable(),
|
|
742
|
+
type: z.literal("TaskCompleted"),
|
|
743
|
+
});
|
|
744
|
+
const CLOSE_WHATSAPP_MESSAGE_SCHEMA = z.object({
|
|
745
|
+
...CLOSE_EXACT_ACTIVITY_FIELDS,
|
|
746
|
+
attachments: CLOSE_ATTACHMENT_SCHEMA.array().optional(),
|
|
747
|
+
direction: z.enum(["incoming", "outgoing"]),
|
|
748
|
+
externalWhatsappMessageId: z.string(),
|
|
749
|
+
integrationLink: z.string().nullable(),
|
|
750
|
+
integrationName: z.string().nullable(),
|
|
751
|
+
localPhone: z.string(),
|
|
752
|
+
localPhoneFormatted: z.string(),
|
|
753
|
+
messageHtml: z.string(),
|
|
754
|
+
messageMarkdown: z.string(),
|
|
755
|
+
remotePhone: z.string(),
|
|
756
|
+
remotePhoneFormatted: z.string(),
|
|
757
|
+
responseToId: z.string().nullable(),
|
|
758
|
+
sequenceId: z.string().nullable().optional(),
|
|
759
|
+
sequenceName: z.string().nullable().optional(),
|
|
760
|
+
sequenceSubscriptionId: z.string().nullable().optional(),
|
|
761
|
+
source: CLOSE_CREATION_SOURCE_SCHEMA,
|
|
762
|
+
text: z.string(),
|
|
763
|
+
type: z.literal("WhatsAppMessage"),
|
|
764
|
+
});
|
|
765
|
+
const CLOSE_ACTIVITY_LIST_CREATED_SCHEMA = CLOSE_CREATED_ACTIVITY_SCHEMA.extend({
|
|
766
|
+
importId: z.string().nullable().optional(),
|
|
767
|
+
});
|
|
768
|
+
const CLOSE_ACTIVITY_LIST_EMAIL_SCHEMA = CLOSE_EMAIL_SCHEMA.extend({
|
|
769
|
+
bulkEmailActionId: z.string().nullable().optional(),
|
|
770
|
+
dateSent: NULLABLE_DATE_SCHEMA.optional(),
|
|
771
|
+
hasReply: z.boolean().optional(),
|
|
772
|
+
inReplyToId: z.string().nullable().optional(),
|
|
773
|
+
needSmtpCredentials: z.boolean().optional(),
|
|
774
|
+
opensSummary: z.string().nullable().optional(),
|
|
775
|
+
sendAsId: z.string().nullable().optional(),
|
|
776
|
+
threadId: z.string().nullable().optional(),
|
|
777
|
+
});
|
|
778
|
+
const CLOSE_ACTIVITY_LIST_NOTE_SCHEMA = CLOSE_NOTE_SCHEMA.extend({
|
|
779
|
+
attachments: CLOSE_ATTACHMENT_SCHEMA.array().optional(),
|
|
780
|
+
noteHtml: z.string().optional(),
|
|
781
|
+
pinned: z.boolean().optional(),
|
|
782
|
+
pinnedAt: NULLABLE_DATE_SCHEMA.optional(),
|
|
783
|
+
source: z.string().nullable().optional(),
|
|
784
|
+
title: z.string().nullable().optional(),
|
|
785
|
+
});
|
|
786
|
+
export const CLOSE_ACTIVITY_SCHEMA = z.discriminatedUnion("type", [
|
|
787
|
+
CLOSE_CALL_SCHEMA,
|
|
788
|
+
CLOSE_ACTIVITY_LIST_EMAIL_SCHEMA,
|
|
789
|
+
CLOSE_MEETING_SCHEMA,
|
|
790
|
+
CLOSE_ACTIVITY_LIST_NOTE_SCHEMA,
|
|
791
|
+
CLOSE_SMS_SCHEMA,
|
|
792
|
+
CLOSE_ACTIVITY_LIST_CREATED_SCHEMA,
|
|
793
|
+
CLOSE_CUSTOM_ACTIVITY_SCHEMA,
|
|
794
|
+
CLOSE_EMAIL_THREAD_SCHEMA,
|
|
795
|
+
CLOSE_FORM_SUBMISSION_SCHEMA,
|
|
796
|
+
CLOSE_IMPORT_UPDATE_SCHEMA,
|
|
797
|
+
CLOSE_LEAD_MERGE_SCHEMA,
|
|
798
|
+
CLOSE_LEAD_STATUS_CHANGE_SCHEMA,
|
|
799
|
+
CLOSE_OPPORTUNITY_STATUS_CHANGE_SCHEMA,
|
|
800
|
+
CLOSE_TASK_COMPLETED_ACTIVITY_SCHEMA,
|
|
801
|
+
CLOSE_WHATSAPP_MESSAGE_SCHEMA,
|
|
802
|
+
]);
|
|
803
|
+
export const CLOSE_COMMENT_SCHEMA = z.object({
|
|
804
|
+
body: z.string(),
|
|
805
|
+
createdAt: DATE_SCHEMA,
|
|
806
|
+
createdBy: z.string(),
|
|
807
|
+
id: z.string(),
|
|
808
|
+
leadId: z.string(),
|
|
809
|
+
mentions: z.string().array().prefault([]),
|
|
810
|
+
organizationId: z.string(),
|
|
811
|
+
removedAt: NULLABLE_DATE_SCHEMA,
|
|
812
|
+
removedBy: z.string().nullable(),
|
|
813
|
+
threadId: z.string(),
|
|
814
|
+
updatedAt: DATE_SCHEMA,
|
|
815
|
+
updatedBy: z.string(),
|
|
816
|
+
});
|
|
817
|
+
const CLOSE_SEQUENCE_SCHEDULE_SCHEMA = z.object({
|
|
818
|
+
ranges: z
|
|
819
|
+
.object({
|
|
820
|
+
end: z.string(),
|
|
821
|
+
start: z.string(),
|
|
822
|
+
weekday: z.number().int(),
|
|
823
|
+
})
|
|
824
|
+
.array(),
|
|
825
|
+
});
|
|
826
|
+
const CLOSE_SEQUENCE_STEP_SCHEMA = z.object({
|
|
827
|
+
createdAt: DATE_SCHEMA,
|
|
828
|
+
createdById: z.string(),
|
|
829
|
+
delay: z.number().int().nonnegative(),
|
|
830
|
+
emailTemplateId: z.string().nullable().optional(),
|
|
831
|
+
id: z.string(),
|
|
832
|
+
required: z.boolean(),
|
|
833
|
+
stepAllowedDelay: z.number().int().nonnegative().nullable().optional(),
|
|
834
|
+
stepType: z.enum(["call", "email"]).optional(),
|
|
835
|
+
threading: z.literal("old_thread").nullable().optional(),
|
|
836
|
+
updatedAt: DATE_SCHEMA,
|
|
837
|
+
updatedById: z.string(),
|
|
838
|
+
});
|
|
839
|
+
export const CLOSE_SEQUENCE_SCHEMA = z.object({
|
|
840
|
+
createdAt: DATE_SCHEMA,
|
|
841
|
+
createdById: z.string(),
|
|
842
|
+
id: z.string(),
|
|
843
|
+
name: z.string(),
|
|
844
|
+
organizationId: z.string(),
|
|
845
|
+
schedule: CLOSE_SEQUENCE_SCHEDULE_SCHEMA.nullable(),
|
|
846
|
+
status: z.string(),
|
|
847
|
+
steps: CLOSE_SEQUENCE_STEP_SCHEMA.array(),
|
|
848
|
+
subscriptionCountsByStatus: z
|
|
849
|
+
.object({
|
|
850
|
+
active: z.number().int().nonnegative(),
|
|
851
|
+
error: z.number().int().nonnegative(),
|
|
852
|
+
finished: z.number().int().nonnegative(),
|
|
853
|
+
goal: z.number().int().nonnegative(),
|
|
854
|
+
paused: z.number().int().nonnegative(),
|
|
855
|
+
})
|
|
856
|
+
.optional(),
|
|
857
|
+
timezone: z.string(),
|
|
858
|
+
updatedAt: DATE_SCHEMA,
|
|
859
|
+
updatedById: z.string(),
|
|
860
|
+
});
|
|
861
|
+
export const CLOSE_SEQUENCE_SUBSCRIPTION_SCHEMA = z.object({
|
|
862
|
+
callsAssignedTo: z.string().array().prefault([]),
|
|
863
|
+
contactEmail: z.email().nullable(),
|
|
864
|
+
contactId: z.string().nullable(),
|
|
865
|
+
createdAt: DATE_SCHEMA,
|
|
866
|
+
createdById: z.string(),
|
|
867
|
+
id: z.string(),
|
|
868
|
+
leadId: z.string(),
|
|
869
|
+
organizationId: z.string(),
|
|
870
|
+
senderAccountId: z.string().nullable(),
|
|
871
|
+
senderEmail: z.email().nullable(),
|
|
872
|
+
senderName: z.string().nullable(),
|
|
873
|
+
sequenceId: z.string(),
|
|
874
|
+
startDate: NULLABLE_DATE_SCHEMA,
|
|
875
|
+
status: z.enum(["active", "error", "finished", "goal", "paused"]),
|
|
876
|
+
statusReason: z.string().nullable(),
|
|
877
|
+
updatedAt: DATE_SCHEMA,
|
|
878
|
+
updatedById: z.string(),
|
|
879
|
+
});
|
|
880
|
+
export const CLOSE_USER_SCHEMA = z
|
|
881
|
+
.object({
|
|
882
|
+
createdAt: DATE_SCHEMA,
|
|
883
|
+
email: z.email(),
|
|
884
|
+
firstName: z.string(),
|
|
885
|
+
id: z.string(),
|
|
886
|
+
image: z.url().nullable().optional(),
|
|
887
|
+
lastName: z.string(),
|
|
888
|
+
organizationIds: z.string().array().optional(),
|
|
889
|
+
organizations: z
|
|
890
|
+
.union([z.string(), z.object({ id: z.string() })])
|
|
891
|
+
.array()
|
|
892
|
+
.prefault([]),
|
|
893
|
+
updatedAt: DATE_SCHEMA,
|
|
894
|
+
})
|
|
895
|
+
.transform(({ organizationIds, organizations, ...user }) => ({
|
|
896
|
+
...user,
|
|
897
|
+
organizationIds: organizationIds ??
|
|
898
|
+
organizations.map((organization) => typeof organization === "string" ? organization : organization.id),
|
|
899
|
+
}));
|
|
900
|
+
export const CLOSE_LEAD_STATUS_SCHEMA = z.object({
|
|
901
|
+
color: z
|
|
902
|
+
.enum([
|
|
903
|
+
"blue",
|
|
904
|
+
"gray",
|
|
905
|
+
"green",
|
|
906
|
+
"magenta",
|
|
907
|
+
"orange",
|
|
908
|
+
"purple",
|
|
909
|
+
"teal",
|
|
910
|
+
"yellow",
|
|
911
|
+
])
|
|
912
|
+
.nullable(),
|
|
913
|
+
id: z.string(),
|
|
914
|
+
label: z.string(),
|
|
915
|
+
organizationId: z.string(),
|
|
916
|
+
});
|
|
917
|
+
export const CLOSE_OPPORTUNITY_STATUS_SCHEMA = z.object({
|
|
918
|
+
id: z.string(),
|
|
919
|
+
label: z.string(),
|
|
920
|
+
organizationId: z.string(),
|
|
921
|
+
pipelineId: z.string().optional(),
|
|
922
|
+
type: CLOSE_OPPORTUNITY_STATUS_TYPE_SCHEMA,
|
|
923
|
+
});
|
|
924
|
+
export const CLOSE_PIPELINE_SCHEMA = z.object({
|
|
925
|
+
createdAt: DATE_SCHEMA,
|
|
926
|
+
createdBy: z.string().nullable(),
|
|
927
|
+
id: z.string(),
|
|
928
|
+
name: z.string(),
|
|
929
|
+
organizationId: z.string(),
|
|
930
|
+
statuses: z
|
|
931
|
+
.object({
|
|
932
|
+
id: z.string(),
|
|
933
|
+
label: z.string(),
|
|
934
|
+
type: CLOSE_OPPORTUNITY_STATUS_TYPE_SCHEMA,
|
|
935
|
+
})
|
|
936
|
+
.array(),
|
|
937
|
+
updatedAt: DATE_SCHEMA,
|
|
938
|
+
updatedBy: z.string().nullable(),
|
|
939
|
+
});
|
|
940
|
+
/**
|
|
941
|
+
* Creates a schema for a paginated Close collection response.
|
|
942
|
+
*
|
|
943
|
+
* @param schema - Schema for one collection item.
|
|
944
|
+
*/
|
|
945
|
+
export function closePageSchema(schema) {
|
|
946
|
+
return z.object({
|
|
947
|
+
data: schema.array(),
|
|
948
|
+
hasMore: z.boolean().prefault(false),
|
|
949
|
+
});
|
|
950
|
+
}
|