@automate.ax/integration-contracts 0.145.2 → 0.146.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.
- package/dist/highlevel/api.d.ts +43 -0
- package/dist/highlevel/api.js +236 -0
- package/dist/highlevel/events.d.ts +1148 -0
- package/dist/highlevel/events.js +303 -0
- package/dist/highlevel/index.d.ts +6 -0
- package/dist/highlevel/index.js +4 -0
- package/dist/highlevel/openapi-operations.generated.json +10122 -0
- package/dist/highlevel/openapi-types.generated.d.ts +9158 -0
- package/dist/highlevel/openapi-types.generated.js +1 -0
- package/dist/highlevel/operation-manifest.d.ts +608 -0
- package/dist/highlevel/operation-manifest.js +98 -0
- package/dist/highlevel/schemas.d.ts +41 -0
- package/dist/highlevel/schemas.js +39 -0
- package/dist/highlevel/types.d.ts +41 -0
- package/dist/highlevel/types.js +1 -0
- package/dist/resend/action-schemas.d.ts +2 -2
- package/dist/triggers.d.ts +2 -1
- package/package.json +9 -2
- package/src/highlevel/api.ts +294 -0
- package/src/highlevel/events.ts +355 -0
- package/src/highlevel/index.ts +6 -0
- package/src/highlevel/openapi-operations.generated.json +10122 -0
- package/src/highlevel/openapi-types.generated.ts +9928 -0
- package/src/highlevel/operation-manifest.ts +740 -0
- package/src/highlevel/schemas.ts +85 -0
- package/src/highlevel/types.ts +91 -0
- package/src/triggers.ts +2 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/* oxlint-disable typescript/no-unsafe-type-assertion -- Object.keys and Object.fromEntries erase the exact generated webhook key correlation. */
|
|
2
|
+
import { encodableSchema } from "@automate.ax/codec";
|
|
3
|
+
import * as z from "zod";
|
|
4
|
+
export const HIGH_LEVEL_TRIGGER_CONFIG_SCHEMA = z.object({});
|
|
5
|
+
const BASE_EVENT_FIELDS = {
|
|
6
|
+
locationId: z.string().min(1),
|
|
7
|
+
timestamp: z.iso.datetime({ offset: true }),
|
|
8
|
+
webhookId: z.string().min(1),
|
|
9
|
+
};
|
|
10
|
+
const CONTACT_FIELDS = {
|
|
11
|
+
...BASE_EVENT_FIELDS,
|
|
12
|
+
address1: z.string().optional(),
|
|
13
|
+
assignedTo: z.string().optional(),
|
|
14
|
+
attachments: encodableSchema.array().optional(),
|
|
15
|
+
city: z.string().optional(),
|
|
16
|
+
companyName: z.string().optional(),
|
|
17
|
+
country: z.string().optional(),
|
|
18
|
+
customFields: encodableSchema.array().optional(),
|
|
19
|
+
dateAdded: z.string().optional(),
|
|
20
|
+
dateOfBirth: z.string().optional(),
|
|
21
|
+
dnd: z.boolean().optional(),
|
|
22
|
+
dndSettings: encodableSchema.optional(),
|
|
23
|
+
email: z.string().optional(),
|
|
24
|
+
firstName: z.string().optional(),
|
|
25
|
+
id: z.string().min(1),
|
|
26
|
+
lastName: z.string().optional(),
|
|
27
|
+
name: z.string().optional(),
|
|
28
|
+
phone: z.string().optional(),
|
|
29
|
+
postalCode: z.string().optional(),
|
|
30
|
+
source: z.string().optional(),
|
|
31
|
+
state: z.string().optional(),
|
|
32
|
+
tags: z.string().array().optional(),
|
|
33
|
+
website: z.string().optional(),
|
|
34
|
+
};
|
|
35
|
+
const OPPORTUNITY_FIELDS = {
|
|
36
|
+
...BASE_EVENT_FIELDS,
|
|
37
|
+
assignedTo: z.string().optional(),
|
|
38
|
+
contactId: z.string().optional(),
|
|
39
|
+
dateAdded: z.string().optional(),
|
|
40
|
+
id: z.string().min(1),
|
|
41
|
+
monetaryValue: z.number().optional(),
|
|
42
|
+
name: z.string().optional(),
|
|
43
|
+
pipelineId: z.string().optional(),
|
|
44
|
+
pipelineStageId: z.string().optional(),
|
|
45
|
+
source: z.string().optional(),
|
|
46
|
+
status: z.string().optional(),
|
|
47
|
+
};
|
|
48
|
+
const TASK_FIELDS = {
|
|
49
|
+
...BASE_EVENT_FIELDS,
|
|
50
|
+
assignedTo: z.string().optional(),
|
|
51
|
+
body: z.string().optional(),
|
|
52
|
+
contactId: z.string().optional(),
|
|
53
|
+
dateAdded: z.string().optional(),
|
|
54
|
+
dueDate: z.string().optional(),
|
|
55
|
+
id: z.string().min(1),
|
|
56
|
+
title: z.string().optional(),
|
|
57
|
+
};
|
|
58
|
+
const NOTE_FIELDS = {
|
|
59
|
+
...BASE_EVENT_FIELDS,
|
|
60
|
+
body: z.string().optional(),
|
|
61
|
+
contactId: z.string().optional(),
|
|
62
|
+
dateAdded: z.string().optional(),
|
|
63
|
+
id: z.string().min(1),
|
|
64
|
+
};
|
|
65
|
+
const MESSAGE_FIELDS = {
|
|
66
|
+
...BASE_EVENT_FIELDS,
|
|
67
|
+
attachments: encodableSchema.array().optional(),
|
|
68
|
+
bcc: z.union([z.string(), z.string().array()]).optional(),
|
|
69
|
+
bccList: z.string().array().optional(),
|
|
70
|
+
body: z.string().optional(),
|
|
71
|
+
callDuration: z.number().optional(),
|
|
72
|
+
callStatus: z.string().optional(),
|
|
73
|
+
cc: z.union([z.string(), z.string().array()]).optional(),
|
|
74
|
+
ccList: z.string().array().optional(),
|
|
75
|
+
chatWidgetId: z.string().optional(),
|
|
76
|
+
contactId: z.string().optional(),
|
|
77
|
+
contentType: z.string().optional(),
|
|
78
|
+
conversationId: z.string().optional(),
|
|
79
|
+
conversationProviderId: z.string().optional(),
|
|
80
|
+
dateAdded: z.string().optional(),
|
|
81
|
+
direction: z.string().optional(),
|
|
82
|
+
emailMessageId: z.string().optional(),
|
|
83
|
+
from: z.string().optional(),
|
|
84
|
+
messageId: z.string().optional(),
|
|
85
|
+
messageType: z.string().optional(),
|
|
86
|
+
messageTypeId: z.string().optional(),
|
|
87
|
+
messageTypeString: z.string().optional(),
|
|
88
|
+
provider: z.string().optional(),
|
|
89
|
+
source: z.string().optional(),
|
|
90
|
+
status: z.string().optional(),
|
|
91
|
+
subject: z.string().optional(),
|
|
92
|
+
threadId: z.string().optional(),
|
|
93
|
+
to: z.union([z.string(), z.string().array()]).optional(),
|
|
94
|
+
userId: z.string().optional(),
|
|
95
|
+
};
|
|
96
|
+
const USER_FIELDS = {
|
|
97
|
+
...BASE_EVENT_FIELDS,
|
|
98
|
+
companyId: z.string().optional(),
|
|
99
|
+
email: z.string().optional(),
|
|
100
|
+
extension: z.string().optional(),
|
|
101
|
+
firstName: z.string().optional(),
|
|
102
|
+
id: z.string().min(1),
|
|
103
|
+
lastName: z.string().optional(),
|
|
104
|
+
locations: z.string().array().optional(),
|
|
105
|
+
permissions: encodableSchema.optional(),
|
|
106
|
+
phone: z.string().optional(),
|
|
107
|
+
role: z.string().optional(),
|
|
108
|
+
scopes: z.string().array().optional(),
|
|
109
|
+
};
|
|
110
|
+
const APPOINTMENT_FIELDS = {
|
|
111
|
+
...BASE_EVENT_FIELDS,
|
|
112
|
+
appointment: z
|
|
113
|
+
.object({
|
|
114
|
+
address: z.string().optional(),
|
|
115
|
+
appointmentStatus: z.string().optional(),
|
|
116
|
+
assignedUserId: z.string().optional(),
|
|
117
|
+
calendarId: z.string().optional(),
|
|
118
|
+
contactId: z.string().optional(),
|
|
119
|
+
dateAdded: z.string().optional(),
|
|
120
|
+
dateUpdated: z.string().optional(),
|
|
121
|
+
endTime: z.string().optional(),
|
|
122
|
+
groupId: z.string().optional(),
|
|
123
|
+
id: z.string().min(1),
|
|
124
|
+
notes: z.string().optional(),
|
|
125
|
+
source: z.string().optional(),
|
|
126
|
+
startTime: z.string().optional(),
|
|
127
|
+
title: z.string().optional(),
|
|
128
|
+
users: z.string().array().optional(),
|
|
129
|
+
})
|
|
130
|
+
.catchall(encodableSchema),
|
|
131
|
+
};
|
|
132
|
+
export const HIGH_LEVEL_EVENT_SCHEMAS = {
|
|
133
|
+
AppointmentCreate: eventSchema("AppointmentCreate", APPOINTMENT_FIELDS),
|
|
134
|
+
AppointmentDelete: eventSchema("AppointmentDelete", APPOINTMENT_FIELDS),
|
|
135
|
+
AppointmentUpdate: eventSchema("AppointmentUpdate", APPOINTMENT_FIELDS),
|
|
136
|
+
CampaignStatusUpdate: eventSchema("CampaignStatusUpdate", {
|
|
137
|
+
...BASE_EVENT_FIELDS,
|
|
138
|
+
contactId: z.string().optional(),
|
|
139
|
+
dateAdded: z.string().optional(),
|
|
140
|
+
id: z.string().min(1),
|
|
141
|
+
replied: z.string().optional(),
|
|
142
|
+
status: z.string().optional(),
|
|
143
|
+
templateId: z.string().optional(),
|
|
144
|
+
}),
|
|
145
|
+
ContactCreate: eventSchema("ContactCreate", CONTACT_FIELDS),
|
|
146
|
+
ContactDelete: eventSchema("ContactDelete", CONTACT_FIELDS),
|
|
147
|
+
ContactDndUpdate: eventSchema("ContactDndUpdate", CONTACT_FIELDS),
|
|
148
|
+
ContactTagUpdate: eventSchema("ContactTagUpdate", CONTACT_FIELDS),
|
|
149
|
+
ContactUpdate: eventSchema("ContactUpdate", CONTACT_FIELDS),
|
|
150
|
+
ConversationUnreadUpdate: eventSchema("ConversationUnreadUpdate", {
|
|
151
|
+
...BASE_EVENT_FIELDS,
|
|
152
|
+
contactId: z.string().optional(),
|
|
153
|
+
deleted: z.boolean().optional(),
|
|
154
|
+
id: z.string().min(1),
|
|
155
|
+
inbox: z.boolean().optional(),
|
|
156
|
+
starred: z.boolean().optional(),
|
|
157
|
+
unreadCount: z.number().int().nonnegative().optional(),
|
|
158
|
+
}),
|
|
159
|
+
ConversationUpdate: eventSchema("ConversationUpdate", {
|
|
160
|
+
...BASE_EVENT_FIELDS,
|
|
161
|
+
companyId: z.string().optional(),
|
|
162
|
+
contactId: z.string().optional(),
|
|
163
|
+
newConversationId: z.string().min(1),
|
|
164
|
+
oldConversationId: z.string().min(1),
|
|
165
|
+
}),
|
|
166
|
+
InboundMessage: eventSchema("InboundMessage", MESSAGE_FIELDS),
|
|
167
|
+
LocationUpdate: eventSchema("LocationUpdate", {
|
|
168
|
+
companyId: z.string().optional(),
|
|
169
|
+
email: z.string().optional(),
|
|
170
|
+
id: z.string().min(1),
|
|
171
|
+
locationId: z.string().min(1).optional(),
|
|
172
|
+
name: z.string().optional(),
|
|
173
|
+
stripeProductId: z.string().optional(),
|
|
174
|
+
timestamp: BASE_EVENT_FIELDS.timestamp,
|
|
175
|
+
webhookId: BASE_EVENT_FIELDS.webhookId,
|
|
176
|
+
}),
|
|
177
|
+
NoteCreate: eventSchema("NoteCreate", NOTE_FIELDS),
|
|
178
|
+
NoteDelete: eventSchema("NoteDelete", NOTE_FIELDS),
|
|
179
|
+
NoteUpdate: eventSchema("NoteUpdate", NOTE_FIELDS),
|
|
180
|
+
OpportunityAssignedToUpdate: eventSchema("OpportunityAssignedToUpdate", OPPORTUNITY_FIELDS),
|
|
181
|
+
OpportunityCreate: eventSchema("OpportunityCreate", OPPORTUNITY_FIELDS),
|
|
182
|
+
OpportunityDelete: eventSchema("OpportunityDelete", OPPORTUNITY_FIELDS),
|
|
183
|
+
OpportunityMonetaryValueUpdate: eventSchema("OpportunityMonetaryValueUpdate", OPPORTUNITY_FIELDS),
|
|
184
|
+
OpportunityStageUpdate: eventSchema("OpportunityStageUpdate", OPPORTUNITY_FIELDS),
|
|
185
|
+
OpportunityStatusUpdate: eventSchema("OpportunityStatusUpdate", OPPORTUNITY_FIELDS),
|
|
186
|
+
OpportunityUpdate: eventSchema("OpportunityUpdate", OPPORTUNITY_FIELDS),
|
|
187
|
+
OutboundMessage: eventSchema("OutboundMessage", MESSAGE_FIELDS),
|
|
188
|
+
TaskComplete: eventSchema("TaskComplete", TASK_FIELDS),
|
|
189
|
+
TaskCreate: eventSchema("TaskCreate", TASK_FIELDS),
|
|
190
|
+
TaskDelete: eventSchema("TaskDelete", TASK_FIELDS),
|
|
191
|
+
UserCreate: eventSchema("UserCreate", USER_FIELDS),
|
|
192
|
+
UserDelete: eventSchema("UserDelete", USER_FIELDS),
|
|
193
|
+
UserUpdate: eventSchema("UserUpdate", USER_FIELDS),
|
|
194
|
+
};
|
|
195
|
+
export const HIGH_LEVEL_WEBHOOK_EVENT_TYPES = Object.keys(HIGH_LEVEL_EVENT_SCHEMAS);
|
|
196
|
+
export const HIGH_LEVEL_EVENT_SCHEMA = z.discriminatedUnion("type", [
|
|
197
|
+
HIGH_LEVEL_EVENT_SCHEMAS.AppointmentCreate,
|
|
198
|
+
HIGH_LEVEL_EVENT_SCHEMAS.AppointmentDelete,
|
|
199
|
+
HIGH_LEVEL_EVENT_SCHEMAS.AppointmentUpdate,
|
|
200
|
+
HIGH_LEVEL_EVENT_SCHEMAS.CampaignStatusUpdate,
|
|
201
|
+
HIGH_LEVEL_EVENT_SCHEMAS.ContactCreate,
|
|
202
|
+
HIGH_LEVEL_EVENT_SCHEMAS.ContactDelete,
|
|
203
|
+
HIGH_LEVEL_EVENT_SCHEMAS.ContactDndUpdate,
|
|
204
|
+
HIGH_LEVEL_EVENT_SCHEMAS.ContactTagUpdate,
|
|
205
|
+
HIGH_LEVEL_EVENT_SCHEMAS.ContactUpdate,
|
|
206
|
+
HIGH_LEVEL_EVENT_SCHEMAS.ConversationUnreadUpdate,
|
|
207
|
+
HIGH_LEVEL_EVENT_SCHEMAS.ConversationUpdate,
|
|
208
|
+
HIGH_LEVEL_EVENT_SCHEMAS.InboundMessage,
|
|
209
|
+
HIGH_LEVEL_EVENT_SCHEMAS.LocationUpdate,
|
|
210
|
+
HIGH_LEVEL_EVENT_SCHEMAS.NoteCreate,
|
|
211
|
+
HIGH_LEVEL_EVENT_SCHEMAS.NoteDelete,
|
|
212
|
+
HIGH_LEVEL_EVENT_SCHEMAS.NoteUpdate,
|
|
213
|
+
HIGH_LEVEL_EVENT_SCHEMAS.OpportunityAssignedToUpdate,
|
|
214
|
+
HIGH_LEVEL_EVENT_SCHEMAS.OpportunityCreate,
|
|
215
|
+
HIGH_LEVEL_EVENT_SCHEMAS.OpportunityDelete,
|
|
216
|
+
HIGH_LEVEL_EVENT_SCHEMAS.OpportunityMonetaryValueUpdate,
|
|
217
|
+
HIGH_LEVEL_EVENT_SCHEMAS.OpportunityStageUpdate,
|
|
218
|
+
HIGH_LEVEL_EVENT_SCHEMAS.OpportunityStatusUpdate,
|
|
219
|
+
HIGH_LEVEL_EVENT_SCHEMAS.OpportunityUpdate,
|
|
220
|
+
HIGH_LEVEL_EVENT_SCHEMAS.OutboundMessage,
|
|
221
|
+
HIGH_LEVEL_EVENT_SCHEMAS.TaskComplete,
|
|
222
|
+
HIGH_LEVEL_EVENT_SCHEMAS.TaskCreate,
|
|
223
|
+
HIGH_LEVEL_EVENT_SCHEMAS.TaskDelete,
|
|
224
|
+
HIGH_LEVEL_EVENT_SCHEMAS.UserCreate,
|
|
225
|
+
HIGH_LEVEL_EVENT_SCHEMAS.UserDelete,
|
|
226
|
+
HIGH_LEVEL_EVENT_SCHEMAS.UserUpdate,
|
|
227
|
+
]);
|
|
228
|
+
export const HIGH_LEVEL_APP_LIFECYCLE_EVENT_SCHEMA = z
|
|
229
|
+
.discriminatedUnion("type", [
|
|
230
|
+
eventSchema("INSTALL", {
|
|
231
|
+
appId: z.string().min(1),
|
|
232
|
+
companyId: z.string().min(1).optional(),
|
|
233
|
+
companyName: z.string().optional(),
|
|
234
|
+
isWhitelabelCompany: z.boolean().optional(),
|
|
235
|
+
locationId: z.string().min(1).optional(),
|
|
236
|
+
planId: z.string().optional(),
|
|
237
|
+
trial: encodableSchema.optional(),
|
|
238
|
+
userId: z.string().optional(),
|
|
239
|
+
whitelabelDetails: encodableSchema.optional(),
|
|
240
|
+
}),
|
|
241
|
+
eventSchema("UNINSTALL", {
|
|
242
|
+
appId: z.string().min(1),
|
|
243
|
+
companyId: z.string().min(1).optional(),
|
|
244
|
+
locationId: z.string().min(1).optional(),
|
|
245
|
+
}),
|
|
246
|
+
])
|
|
247
|
+
.refine((event) => event.locationId || event.companyId, {
|
|
248
|
+
message: "HighLevel app lifecycle events require a location or company ID.",
|
|
249
|
+
});
|
|
250
|
+
export const highLevelEventTypeMap = {
|
|
251
|
+
AppointmentCreate: "highlevel.appointment.created",
|
|
252
|
+
AppointmentDelete: "highlevel.appointment.deleted",
|
|
253
|
+
AppointmentUpdate: "highlevel.appointment.updated",
|
|
254
|
+
CampaignStatusUpdate: "highlevel.campaign.statusUpdated",
|
|
255
|
+
ContactCreate: "highlevel.contact.created",
|
|
256
|
+
ContactDelete: "highlevel.contact.deleted",
|
|
257
|
+
ContactDndUpdate: "highlevel.contact.dndUpdated",
|
|
258
|
+
ContactTagUpdate: "highlevel.contact.tagsUpdated",
|
|
259
|
+
ContactUpdate: "highlevel.contact.updated",
|
|
260
|
+
ConversationUnreadUpdate: "highlevel.conversation.unreadUpdated",
|
|
261
|
+
ConversationUpdate: "highlevel.conversation.updated",
|
|
262
|
+
InboundMessage: "highlevel.message.received",
|
|
263
|
+
LocationUpdate: "highlevel.location.updated",
|
|
264
|
+
NoteCreate: "highlevel.note.created",
|
|
265
|
+
NoteDelete: "highlevel.note.deleted",
|
|
266
|
+
NoteUpdate: "highlevel.note.updated",
|
|
267
|
+
OpportunityAssignedToUpdate: "highlevel.opportunity.assigneeUpdated",
|
|
268
|
+
OpportunityCreate: "highlevel.opportunity.created",
|
|
269
|
+
OpportunityDelete: "highlevel.opportunity.deleted",
|
|
270
|
+
OpportunityMonetaryValueUpdate: "highlevel.opportunity.valueUpdated",
|
|
271
|
+
OpportunityStageUpdate: "highlevel.opportunity.stageUpdated",
|
|
272
|
+
OpportunityStatusUpdate: "highlevel.opportunity.statusUpdated",
|
|
273
|
+
OpportunityUpdate: "highlevel.opportunity.updated",
|
|
274
|
+
OutboundMessage: "highlevel.message.sent",
|
|
275
|
+
TaskComplete: "highlevel.task.completed",
|
|
276
|
+
TaskCreate: "highlevel.task.created",
|
|
277
|
+
TaskDelete: "highlevel.task.deleted",
|
|
278
|
+
UserCreate: "highlevel.user.created",
|
|
279
|
+
UserDelete: "highlevel.user.deleted",
|
|
280
|
+
UserUpdate: "highlevel.user.updated",
|
|
281
|
+
};
|
|
282
|
+
export const highLevelTriggerContracts = {
|
|
283
|
+
"highlevel.event": {
|
|
284
|
+
configSchema: HIGH_LEVEL_TRIGGER_CONFIG_SCHEMA,
|
|
285
|
+
eventSchema: HIGH_LEVEL_EVENT_SCHEMA,
|
|
286
|
+
},
|
|
287
|
+
...Object.fromEntries(Object.entries(highLevelEventTypeMap).map(([providerType, eventType]) => [
|
|
288
|
+
eventType,
|
|
289
|
+
{
|
|
290
|
+
configSchema: HIGH_LEVEL_TRIGGER_CONFIG_SCHEMA,
|
|
291
|
+
eventSchema: HIGH_LEVEL_EVENT_SCHEMAS[providerType],
|
|
292
|
+
},
|
|
293
|
+
])),
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* Creates an extensible schema for one HighLevel webhook discriminator.
|
|
297
|
+
*
|
|
298
|
+
* @param type - Provider event discriminator.
|
|
299
|
+
* @param shape - Known fields for the event.
|
|
300
|
+
*/
|
|
301
|
+
function eventSchema(type, shape) {
|
|
302
|
+
return z.object({ ...shape, type: z.literal(type) }).catchall(encodableSchema);
|
|
303
|
+
}
|