@automate.ax/integration-contracts 0.120.0 → 0.121.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/hubspot/api.d.ts +41 -0
- package/dist/hubspot/api.js +116 -0
- package/dist/hubspot/events.d.ts +4488 -0
- package/dist/hubspot/events.js +130 -0
- package/dist/hubspot/index.d.ts +3 -0
- package/dist/hubspot/index.js +3 -0
- package/dist/hubspot/schemas.d.ts +198 -0
- package/dist/hubspot/schemas.js +153 -0
- package/dist/linear/schemas.d.ts +3 -3
- package/dist/triggers.d.ts +2 -1
- package/dist/whatsapp/index.d.ts +2 -2
- package/dist/whatsapp/schemas.d.ts +5 -5
- package/package.json +8 -2
- package/src/hubspot/api.ts +147 -0
- package/src/hubspot/events.ts +193 -0
- package/src/hubspot/index.ts +3 -0
- package/src/hubspot/schemas.ts +189 -0
- package/src/triggers.ts +2 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
export const HUBSPOT_TRIGGER_CONFIG_SCHEMA = z.object({});
|
|
3
|
+
export const HUBSPOT_EVENT_ACTION_SCHEMA = z.enum([
|
|
4
|
+
"associationAdded",
|
|
5
|
+
"associationRemoved",
|
|
6
|
+
"created",
|
|
7
|
+
"deleted",
|
|
8
|
+
"merged",
|
|
9
|
+
"propertyChanged",
|
|
10
|
+
"restored",
|
|
11
|
+
]);
|
|
12
|
+
export const HUBSPOT_EVENT_OBJECT_SCHEMA = z.enum([
|
|
13
|
+
"company",
|
|
14
|
+
"contact",
|
|
15
|
+
"deal",
|
|
16
|
+
"ticket",
|
|
17
|
+
]);
|
|
18
|
+
const HUBSPOT_COMMON_EVENT_FIELDS = {
|
|
19
|
+
appId: z.number().int().positive().optional(),
|
|
20
|
+
attemptNumber: z.number().int().nonnegative(),
|
|
21
|
+
changeSource: z.string().optional(),
|
|
22
|
+
eventId: z.number().int(),
|
|
23
|
+
objectId: z.string(),
|
|
24
|
+
objectType: HUBSPOT_EVENT_OBJECT_SCHEMA,
|
|
25
|
+
occurredAt: z.date(),
|
|
26
|
+
portalId: z.number().int().positive(),
|
|
27
|
+
sourceId: z.string().optional(),
|
|
28
|
+
subscriptionId: z.number().int().positive(),
|
|
29
|
+
};
|
|
30
|
+
const HUBSPOT_ASSOCIATION_EVENT_FIELDS = {
|
|
31
|
+
associationCategory: z.string().optional(),
|
|
32
|
+
associationType: z.string(),
|
|
33
|
+
associationTypeId: z.number().int().positive().optional(),
|
|
34
|
+
fromObjectId: z.string(),
|
|
35
|
+
fromObjectTypeId: z.string().optional(),
|
|
36
|
+
isPrimaryAssociation: z.boolean().optional(),
|
|
37
|
+
toObjectId: z.string(),
|
|
38
|
+
toObjectTypeId: z.string().optional(),
|
|
39
|
+
};
|
|
40
|
+
export const HUBSPOT_CRM_EVENT_SCHEMA = z.discriminatedUnion("action", [
|
|
41
|
+
z.object({
|
|
42
|
+
...HUBSPOT_COMMON_EVENT_FIELDS,
|
|
43
|
+
...HUBSPOT_ASSOCIATION_EVENT_FIELDS,
|
|
44
|
+
action: z.literal("associationAdded"),
|
|
45
|
+
associationRemoved: z.literal(false),
|
|
46
|
+
}),
|
|
47
|
+
z.object({
|
|
48
|
+
...HUBSPOT_COMMON_EVENT_FIELDS,
|
|
49
|
+
...HUBSPOT_ASSOCIATION_EVENT_FIELDS,
|
|
50
|
+
action: z.literal("associationRemoved"),
|
|
51
|
+
associationRemoved: z.literal(true),
|
|
52
|
+
}),
|
|
53
|
+
z.object({ ...HUBSPOT_COMMON_EVENT_FIELDS, action: z.literal("created") }),
|
|
54
|
+
z.object({ ...HUBSPOT_COMMON_EVENT_FIELDS, action: z.literal("deleted") }),
|
|
55
|
+
z.object({
|
|
56
|
+
...HUBSPOT_COMMON_EVENT_FIELDS,
|
|
57
|
+
action: z.literal("merged"),
|
|
58
|
+
mergedObjectIds: z.string().array().min(1),
|
|
59
|
+
newObjectId: z.string(),
|
|
60
|
+
numberOfPropertiesMoved: z.number().int().nonnegative().optional(),
|
|
61
|
+
}),
|
|
62
|
+
z.object({
|
|
63
|
+
...HUBSPOT_COMMON_EVENT_FIELDS,
|
|
64
|
+
action: z.literal("propertyChanged"),
|
|
65
|
+
propertyName: z.string(),
|
|
66
|
+
propertyValue: z.string(),
|
|
67
|
+
}),
|
|
68
|
+
z.object({ ...HUBSPOT_COMMON_EVENT_FIELDS, action: z.literal("restored") }),
|
|
69
|
+
]);
|
|
70
|
+
/** Every broad and semantic HubSpot trigger contract. */
|
|
71
|
+
export const hubspotTriggerContracts = {
|
|
72
|
+
"hubspot.company.associationAdded": semanticContract("company", "associationAdded"),
|
|
73
|
+
"hubspot.company.associationRemoved": semanticContract("company", "associationRemoved"),
|
|
74
|
+
"hubspot.company.created": semanticContract("company", "created"),
|
|
75
|
+
"hubspot.company.deleted": semanticContract("company", "deleted"),
|
|
76
|
+
"hubspot.company.merged": semanticContract("company", "merged"),
|
|
77
|
+
"hubspot.company.propertyChanged": semanticContract("company", "propertyChanged"),
|
|
78
|
+
"hubspot.company.restored": semanticContract("company", "restored"),
|
|
79
|
+
"hubspot.contact.associationAdded": semanticContract("contact", "associationAdded"),
|
|
80
|
+
"hubspot.contact.associationRemoved": semanticContract("contact", "associationRemoved"),
|
|
81
|
+
"hubspot.contact.created": semanticContract("contact", "created"),
|
|
82
|
+
"hubspot.contact.deleted": semanticContract("contact", "deleted"),
|
|
83
|
+
"hubspot.contact.merged": semanticContract("contact", "merged"),
|
|
84
|
+
"hubspot.contact.propertyChanged": semanticContract("contact", "propertyChanged"),
|
|
85
|
+
"hubspot.contact.restored": semanticContract("contact", "restored"),
|
|
86
|
+
"hubspot.crm.event": {
|
|
87
|
+
configSchema: HUBSPOT_TRIGGER_CONFIG_SCHEMA,
|
|
88
|
+
eventSchema: HUBSPOT_CRM_EVENT_SCHEMA,
|
|
89
|
+
},
|
|
90
|
+
"hubspot.deal.associationAdded": semanticContract("deal", "associationAdded"),
|
|
91
|
+
"hubspot.deal.associationRemoved": semanticContract("deal", "associationRemoved"),
|
|
92
|
+
"hubspot.deal.created": semanticContract("deal", "created"),
|
|
93
|
+
"hubspot.deal.deleted": semanticContract("deal", "deleted"),
|
|
94
|
+
"hubspot.deal.merged": semanticContract("deal", "merged"),
|
|
95
|
+
"hubspot.deal.propertyChanged": semanticContract("deal", "propertyChanged"),
|
|
96
|
+
"hubspot.deal.restored": semanticContract("deal", "restored"),
|
|
97
|
+
"hubspot.ticket.associationAdded": semanticContract("ticket", "associationAdded"),
|
|
98
|
+
"hubspot.ticket.associationRemoved": semanticContract("ticket", "associationRemoved"),
|
|
99
|
+
"hubspot.ticket.created": semanticContract("ticket", "created"),
|
|
100
|
+
"hubspot.ticket.deleted": semanticContract("ticket", "deleted"),
|
|
101
|
+
"hubspot.ticket.merged": semanticContract("ticket", "merged"),
|
|
102
|
+
"hubspot.ticket.propertyChanged": semanticContract("ticket", "propertyChanged"),
|
|
103
|
+
"hubspot.ticket.restored": semanticContract("ticket", "restored"),
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Builds one semantic HubSpot lifecycle contract.
|
|
107
|
+
*
|
|
108
|
+
* @param objectType - Normalized CRM object type.
|
|
109
|
+
* @param action - Normalized CRM lifecycle action.
|
|
110
|
+
*/
|
|
111
|
+
function semanticContract(objectType, action) {
|
|
112
|
+
return {
|
|
113
|
+
configSchema: HUBSPOT_TRIGGER_CONFIG_SCHEMA,
|
|
114
|
+
eventSchema: HUBSPOT_CRM_EVENT_SCHEMA.and(z.object({
|
|
115
|
+
action: z.literal(action),
|
|
116
|
+
objectType: z.literal(objectType),
|
|
117
|
+
})),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Returns broad and semantic event types for one normalized callback.
|
|
122
|
+
*
|
|
123
|
+
* @param event - Normalized HubSpot CRM event.
|
|
124
|
+
*/
|
|
125
|
+
export function getHubSpotEventTypes(event) {
|
|
126
|
+
return [
|
|
127
|
+
`hubspot.${event.objectType}.${event.action}`,
|
|
128
|
+
"hubspot.crm.event",
|
|
129
|
+
];
|
|
130
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
export declare const HUBSPOT_CORE_OBJECT_TYPE_SCHEMA: z.ZodEnum<{
|
|
3
|
+
companies: "companies";
|
|
4
|
+
contacts: "contacts";
|
|
5
|
+
deals: "deals";
|
|
6
|
+
tickets: "tickets";
|
|
7
|
+
}>;
|
|
8
|
+
export declare const HUBSPOT_DATE_SCHEMA: z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>;
|
|
9
|
+
export declare const HUBSPOT_PROPERTY_VALUE_SCHEMA: z.ZodObject<{
|
|
10
|
+
name: z.ZodString;
|
|
11
|
+
value: z.ZodNullable<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
export declare const HUBSPOT_PROPERTY_VALUES_SCHEMA: z.ZodArray<z.ZodObject<{
|
|
14
|
+
name: z.ZodString;
|
|
15
|
+
value: z.ZodNullable<z.ZodString>;
|
|
16
|
+
}, z.core.$strip>>;
|
|
17
|
+
export declare const HUBSPOT_ASSOCIATION_TYPE_SCHEMA: z.ZodObject<{
|
|
18
|
+
associationCategory: z.ZodEnum<{
|
|
19
|
+
HUBSPOT_DEFINED: "HUBSPOT_DEFINED";
|
|
20
|
+
INTEGRATOR_DEFINED: "INTEGRATOR_DEFINED";
|
|
21
|
+
USER_DEFINED: "USER_DEFINED";
|
|
22
|
+
}>;
|
|
23
|
+
associationTypeId: z.ZodNumber;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export declare const HUBSPOT_ASSOCIATION_INPUT_SCHEMA: z.ZodObject<{
|
|
26
|
+
toRecordId: z.ZodString;
|
|
27
|
+
types: z.ZodArray<z.ZodObject<{
|
|
28
|
+
associationCategory: z.ZodEnum<{
|
|
29
|
+
HUBSPOT_DEFINED: "HUBSPOT_DEFINED";
|
|
30
|
+
INTEGRATOR_DEFINED: "INTEGRATOR_DEFINED";
|
|
31
|
+
USER_DEFINED: "USER_DEFINED";
|
|
32
|
+
}>;
|
|
33
|
+
associationTypeId: z.ZodNumber;
|
|
34
|
+
}, z.core.$strip>>;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
export declare const HUBSPOT_ASSOCIATED_RECORD_SCHEMA: z.ZodObject<{
|
|
37
|
+
id: z.ZodString;
|
|
38
|
+
type: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export declare const HUBSPOT_ASSOCIATION_RESULT_SCHEMA: z.ZodObject<{
|
|
41
|
+
objectType: z.ZodString;
|
|
42
|
+
records: z.ZodArray<z.ZodObject<{
|
|
43
|
+
id: z.ZodString;
|
|
44
|
+
type: z.ZodOptional<z.ZodString>;
|
|
45
|
+
}, z.core.$strip>>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
export declare const HUBSPOT_PROPERTY_HISTORY_VALUE_SCHEMA: z.ZodObject<{
|
|
48
|
+
sourceId: z.ZodOptional<z.ZodString>;
|
|
49
|
+
sourceType: z.ZodString;
|
|
50
|
+
timestamp: z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>;
|
|
51
|
+
updatedByUserId: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
value: z.ZodNullable<z.ZodString>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
export declare const HUBSPOT_PROPERTY_HISTORY_SCHEMA: z.ZodObject<{
|
|
55
|
+
name: z.ZodString;
|
|
56
|
+
values: z.ZodArray<z.ZodObject<{
|
|
57
|
+
sourceId: z.ZodOptional<z.ZodString>;
|
|
58
|
+
sourceType: z.ZodString;
|
|
59
|
+
timestamp: z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>;
|
|
60
|
+
updatedByUserId: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
value: z.ZodNullable<z.ZodString>;
|
|
62
|
+
}, z.core.$strip>>;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
export declare const HUBSPOT_RECORD_SCHEMA: z.ZodObject<{
|
|
65
|
+
archived: z.ZodBoolean;
|
|
66
|
+
archivedAt: z.ZodOptional<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>>;
|
|
67
|
+
associations: z.ZodPrefault<z.ZodArray<z.ZodObject<{
|
|
68
|
+
objectType: z.ZodString;
|
|
69
|
+
records: z.ZodArray<z.ZodObject<{
|
|
70
|
+
id: z.ZodString;
|
|
71
|
+
type: z.ZodOptional<z.ZodString>;
|
|
72
|
+
}, z.core.$strip>>;
|
|
73
|
+
}, z.core.$strip>>>;
|
|
74
|
+
createdAt: z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>;
|
|
75
|
+
id: z.ZodString;
|
|
76
|
+
properties: z.ZodArray<z.ZodObject<{
|
|
77
|
+
name: z.ZodString;
|
|
78
|
+
value: z.ZodNullable<z.ZodString>;
|
|
79
|
+
}, z.core.$strip>>;
|
|
80
|
+
propertiesWithHistory: z.ZodPrefault<z.ZodArray<z.ZodObject<{
|
|
81
|
+
name: z.ZodString;
|
|
82
|
+
values: z.ZodArray<z.ZodObject<{
|
|
83
|
+
sourceId: z.ZodOptional<z.ZodString>;
|
|
84
|
+
sourceType: z.ZodString;
|
|
85
|
+
timestamp: z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>;
|
|
86
|
+
updatedByUserId: z.ZodOptional<z.ZodNumber>;
|
|
87
|
+
value: z.ZodNullable<z.ZodString>;
|
|
88
|
+
}, z.core.$strip>>;
|
|
89
|
+
}, z.core.$strip>>>;
|
|
90
|
+
updatedAt: z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
export declare const HUBSPOT_PAGE_INFO_SCHEMA: z.ZodObject<{
|
|
93
|
+
after: z.ZodOptional<z.ZodString>;
|
|
94
|
+
}, z.core.$strip>;
|
|
95
|
+
export declare const HUBSPOT_RECORD_PAGE_SCHEMA: z.ZodObject<{
|
|
96
|
+
pageInfo: z.ZodObject<{
|
|
97
|
+
after: z.ZodOptional<z.ZodString>;
|
|
98
|
+
}, z.core.$strip>;
|
|
99
|
+
records: z.ZodArray<z.ZodObject<{
|
|
100
|
+
archived: z.ZodBoolean;
|
|
101
|
+
archivedAt: z.ZodOptional<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>>;
|
|
102
|
+
associations: z.ZodPrefault<z.ZodArray<z.ZodObject<{
|
|
103
|
+
objectType: z.ZodString;
|
|
104
|
+
records: z.ZodArray<z.ZodObject<{
|
|
105
|
+
id: z.ZodString;
|
|
106
|
+
type: z.ZodOptional<z.ZodString>;
|
|
107
|
+
}, z.core.$strip>>;
|
|
108
|
+
}, z.core.$strip>>>;
|
|
109
|
+
createdAt: z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>;
|
|
110
|
+
id: z.ZodString;
|
|
111
|
+
properties: z.ZodArray<z.ZodObject<{
|
|
112
|
+
name: z.ZodString;
|
|
113
|
+
value: z.ZodNullable<z.ZodString>;
|
|
114
|
+
}, z.core.$strip>>;
|
|
115
|
+
propertiesWithHistory: z.ZodPrefault<z.ZodArray<z.ZodObject<{
|
|
116
|
+
name: z.ZodString;
|
|
117
|
+
values: z.ZodArray<z.ZodObject<{
|
|
118
|
+
sourceId: z.ZodOptional<z.ZodString>;
|
|
119
|
+
sourceType: z.ZodString;
|
|
120
|
+
timestamp: z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>;
|
|
121
|
+
updatedByUserId: z.ZodOptional<z.ZodNumber>;
|
|
122
|
+
value: z.ZodNullable<z.ZodString>;
|
|
123
|
+
}, z.core.$strip>>;
|
|
124
|
+
}, z.core.$strip>>>;
|
|
125
|
+
updatedAt: z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>;
|
|
126
|
+
}, z.core.$strip>>;
|
|
127
|
+
total: z.ZodOptional<z.ZodNumber>;
|
|
128
|
+
}, z.core.$strip>;
|
|
129
|
+
export declare const HUBSPOT_PROVIDER_RECORD_SCHEMA: z.ZodObject<{
|
|
130
|
+
archived: z.ZodBoolean;
|
|
131
|
+
archivedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
132
|
+
associations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
133
|
+
results: z.ZodArray<z.ZodObject<{
|
|
134
|
+
id: z.ZodString;
|
|
135
|
+
type: z.ZodOptional<z.ZodString>;
|
|
136
|
+
}, z.core.$loose>>;
|
|
137
|
+
}, z.core.$loose>>>;
|
|
138
|
+
createdAt: z.ZodISODateTime;
|
|
139
|
+
id: z.ZodString;
|
|
140
|
+
properties: z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>;
|
|
141
|
+
propertiesWithHistory: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
|
|
142
|
+
sourceId: z.ZodOptional<z.ZodString>;
|
|
143
|
+
sourceType: z.ZodString;
|
|
144
|
+
timestamp: z.ZodISODateTime;
|
|
145
|
+
updatedByUserId: z.ZodOptional<z.ZodNumber>;
|
|
146
|
+
value: z.ZodNullable<z.ZodString>;
|
|
147
|
+
}, z.core.$loose>>>>;
|
|
148
|
+
updatedAt: z.ZodISODateTime;
|
|
149
|
+
}, z.core.$loose>;
|
|
150
|
+
export declare const HUBSPOT_PROVIDER_RECORD_PAGE_SCHEMA: z.ZodObject<{
|
|
151
|
+
paging: z.ZodOptional<z.ZodObject<{
|
|
152
|
+
next: z.ZodOptional<z.ZodObject<{
|
|
153
|
+
after: z.ZodString;
|
|
154
|
+
}, z.core.$loose>>;
|
|
155
|
+
}, z.core.$loose>>;
|
|
156
|
+
results: z.ZodArray<z.ZodObject<{
|
|
157
|
+
archived: z.ZodBoolean;
|
|
158
|
+
archivedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
159
|
+
associations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
160
|
+
results: z.ZodArray<z.ZodObject<{
|
|
161
|
+
id: z.ZodString;
|
|
162
|
+
type: z.ZodOptional<z.ZodString>;
|
|
163
|
+
}, z.core.$loose>>;
|
|
164
|
+
}, z.core.$loose>>>;
|
|
165
|
+
createdAt: z.ZodISODateTime;
|
|
166
|
+
id: z.ZodString;
|
|
167
|
+
properties: z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>;
|
|
168
|
+
propertiesWithHistory: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
|
|
169
|
+
sourceId: z.ZodOptional<z.ZodString>;
|
|
170
|
+
sourceType: z.ZodString;
|
|
171
|
+
timestamp: z.ZodISODateTime;
|
|
172
|
+
updatedByUserId: z.ZodOptional<z.ZodNumber>;
|
|
173
|
+
value: z.ZodNullable<z.ZodString>;
|
|
174
|
+
}, z.core.$loose>>>>;
|
|
175
|
+
updatedAt: z.ZodISODateTime;
|
|
176
|
+
}, z.core.$loose>>;
|
|
177
|
+
total: z.ZodOptional<z.ZodNumber>;
|
|
178
|
+
}, z.core.$loose>;
|
|
179
|
+
/**
|
|
180
|
+
* Converts HubSpot's dynamic property maps into structurally typed entries.
|
|
181
|
+
*
|
|
182
|
+
* @param record - Provider CRM record.
|
|
183
|
+
*/
|
|
184
|
+
export declare function toHubSpotRecord(record: z.output<typeof HUBSPOT_PROVIDER_RECORD_SCHEMA>): z.input<typeof HUBSPOT_RECORD_SCHEMA>;
|
|
185
|
+
/**
|
|
186
|
+
* Converts HubSpot's record-page envelope into public pagination.
|
|
187
|
+
*
|
|
188
|
+
* @param page - Provider record page.
|
|
189
|
+
*/
|
|
190
|
+
export declare function toHubSpotRecordPage(page: z.output<typeof HUBSPOT_PROVIDER_RECORD_PAGE_SCHEMA>): z.input<typeof HUBSPOT_RECORD_PAGE_SCHEMA>;
|
|
191
|
+
/**
|
|
192
|
+
* Converts typed property entries to HubSpot's provider property map.
|
|
193
|
+
*
|
|
194
|
+
* @param properties - Public property entries.
|
|
195
|
+
*/
|
|
196
|
+
export declare function toHubSpotProperties(properties: z.output<typeof HUBSPOT_PROPERTY_VALUES_SCHEMA>): {
|
|
197
|
+
[k: string]: string;
|
|
198
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
export const HUBSPOT_CORE_OBJECT_TYPE_SCHEMA = z.enum([
|
|
3
|
+
"companies",
|
|
4
|
+
"contacts",
|
|
5
|
+
"deals",
|
|
6
|
+
"tickets",
|
|
7
|
+
]);
|
|
8
|
+
export const HUBSPOT_DATE_SCHEMA = z.iso
|
|
9
|
+
.datetime({ offset: true })
|
|
10
|
+
.transform((value) => new Date(value));
|
|
11
|
+
export const HUBSPOT_PROPERTY_VALUE_SCHEMA = z.object({
|
|
12
|
+
/** HubSpot internal property name. */
|
|
13
|
+
name: z.string().trim().min(1),
|
|
14
|
+
/** Serialized property value. An empty string clears a writable property. */
|
|
15
|
+
value: z.string().nullable(),
|
|
16
|
+
});
|
|
17
|
+
export const HUBSPOT_PROPERTY_VALUES_SCHEMA = HUBSPOT_PROPERTY_VALUE_SCHEMA.array().superRefine((properties, context) => {
|
|
18
|
+
const seen = new Set();
|
|
19
|
+
for (const [index, property] of properties.entries()) {
|
|
20
|
+
if (seen.has(property.name)) {
|
|
21
|
+
context.addIssue({
|
|
22
|
+
code: "custom",
|
|
23
|
+
message: `Duplicate HubSpot property: ${property.name}`,
|
|
24
|
+
path: [index, "name"],
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
seen.add(property.name);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
export const HUBSPOT_ASSOCIATION_TYPE_SCHEMA = z.object({
|
|
31
|
+
associationCategory: z.enum([
|
|
32
|
+
"HUBSPOT_DEFINED",
|
|
33
|
+
"INTEGRATOR_DEFINED",
|
|
34
|
+
"USER_DEFINED",
|
|
35
|
+
]),
|
|
36
|
+
associationTypeId: z.number().int().positive(),
|
|
37
|
+
});
|
|
38
|
+
export const HUBSPOT_ASSOCIATION_INPUT_SCHEMA = z.object({
|
|
39
|
+
toRecordId: z.string().trim().min(1),
|
|
40
|
+
types: HUBSPOT_ASSOCIATION_TYPE_SCHEMA.array().min(1),
|
|
41
|
+
});
|
|
42
|
+
export const HUBSPOT_ASSOCIATED_RECORD_SCHEMA = z.object({
|
|
43
|
+
id: z.string(),
|
|
44
|
+
type: z.string().optional(),
|
|
45
|
+
});
|
|
46
|
+
export const HUBSPOT_ASSOCIATION_RESULT_SCHEMA = z.object({
|
|
47
|
+
objectType: z.string(),
|
|
48
|
+
records: HUBSPOT_ASSOCIATED_RECORD_SCHEMA.array(),
|
|
49
|
+
});
|
|
50
|
+
export const HUBSPOT_PROPERTY_HISTORY_VALUE_SCHEMA = z.object({
|
|
51
|
+
sourceId: z.string().optional(),
|
|
52
|
+
sourceType: z.string(),
|
|
53
|
+
timestamp: HUBSPOT_DATE_SCHEMA,
|
|
54
|
+
updatedByUserId: z.number().int().optional(),
|
|
55
|
+
value: z.string().nullable(),
|
|
56
|
+
});
|
|
57
|
+
export const HUBSPOT_PROPERTY_HISTORY_SCHEMA = z.object({
|
|
58
|
+
name: z.string(),
|
|
59
|
+
values: HUBSPOT_PROPERTY_HISTORY_VALUE_SCHEMA.array(),
|
|
60
|
+
});
|
|
61
|
+
export const HUBSPOT_RECORD_SCHEMA = z.object({
|
|
62
|
+
archived: z.boolean(),
|
|
63
|
+
archivedAt: HUBSPOT_DATE_SCHEMA.optional(),
|
|
64
|
+
associations: HUBSPOT_ASSOCIATION_RESULT_SCHEMA.array().prefault([]),
|
|
65
|
+
createdAt: HUBSPOT_DATE_SCHEMA,
|
|
66
|
+
id: z.string(),
|
|
67
|
+
properties: HUBSPOT_PROPERTY_VALUES_SCHEMA,
|
|
68
|
+
propertiesWithHistory: HUBSPOT_PROPERTY_HISTORY_SCHEMA.array().prefault([]),
|
|
69
|
+
updatedAt: HUBSPOT_DATE_SCHEMA,
|
|
70
|
+
});
|
|
71
|
+
export const HUBSPOT_PAGE_INFO_SCHEMA = z.object({
|
|
72
|
+
after: z.string().optional(),
|
|
73
|
+
});
|
|
74
|
+
export const HUBSPOT_RECORD_PAGE_SCHEMA = z.object({
|
|
75
|
+
pageInfo: HUBSPOT_PAGE_INFO_SCHEMA,
|
|
76
|
+
records: HUBSPOT_RECORD_SCHEMA.array(),
|
|
77
|
+
total: z.number().int().nonnegative().optional(),
|
|
78
|
+
});
|
|
79
|
+
const HUBSPOT_PROVIDER_HISTORY_VALUE_SCHEMA = z.looseObject({
|
|
80
|
+
sourceId: z.string().optional(),
|
|
81
|
+
sourceType: z.string(),
|
|
82
|
+
timestamp: z.iso.datetime({ offset: true }),
|
|
83
|
+
updatedByUserId: z.number().int().optional(),
|
|
84
|
+
value: z.string().nullable(),
|
|
85
|
+
});
|
|
86
|
+
export const HUBSPOT_PROVIDER_RECORD_SCHEMA = z.looseObject({
|
|
87
|
+
archived: z.boolean(),
|
|
88
|
+
archivedAt: z.iso.datetime({ offset: true }).optional(),
|
|
89
|
+
associations: z
|
|
90
|
+
.record(z.string(), z.looseObject({
|
|
91
|
+
results: z
|
|
92
|
+
.looseObject({ id: z.string(), type: z.string().optional() })
|
|
93
|
+
.array(),
|
|
94
|
+
}))
|
|
95
|
+
.optional(),
|
|
96
|
+
createdAt: z.iso.datetime({ offset: true }),
|
|
97
|
+
id: z.string(),
|
|
98
|
+
properties: z.record(z.string(), z.string().nullable()),
|
|
99
|
+
propertiesWithHistory: z
|
|
100
|
+
.record(z.string(), HUBSPOT_PROVIDER_HISTORY_VALUE_SCHEMA.array())
|
|
101
|
+
.optional(),
|
|
102
|
+
updatedAt: z.iso.datetime({ offset: true }),
|
|
103
|
+
});
|
|
104
|
+
export const HUBSPOT_PROVIDER_RECORD_PAGE_SCHEMA = z.looseObject({
|
|
105
|
+
paging: z
|
|
106
|
+
.looseObject({ next: z.looseObject({ after: z.string() }).optional() })
|
|
107
|
+
.optional(),
|
|
108
|
+
results: HUBSPOT_PROVIDER_RECORD_SCHEMA.array(),
|
|
109
|
+
total: z.number().int().nonnegative().optional(),
|
|
110
|
+
});
|
|
111
|
+
/**
|
|
112
|
+
* Converts HubSpot's dynamic property maps into structurally typed entries.
|
|
113
|
+
*
|
|
114
|
+
* @param record - Provider CRM record.
|
|
115
|
+
*/
|
|
116
|
+
export function toHubSpotRecord(record) {
|
|
117
|
+
return {
|
|
118
|
+
archived: record.archived,
|
|
119
|
+
...(record.archivedAt ? { archivedAt: record.archivedAt } : {}),
|
|
120
|
+
associations: Object.entries(record.associations ?? {}).map(([objectType, association]) => ({
|
|
121
|
+
objectType,
|
|
122
|
+
records: association.results,
|
|
123
|
+
})),
|
|
124
|
+
createdAt: record.createdAt,
|
|
125
|
+
id: record.id,
|
|
126
|
+
properties: Object.entries(record.properties).map(([name, value]) => ({
|
|
127
|
+
name,
|
|
128
|
+
value,
|
|
129
|
+
})),
|
|
130
|
+
propertiesWithHistory: Object.entries(record.propertiesWithHistory ?? {}).map(([name, values]) => ({ name, values })),
|
|
131
|
+
updatedAt: record.updatedAt,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Converts HubSpot's record-page envelope into public pagination.
|
|
136
|
+
*
|
|
137
|
+
* @param page - Provider record page.
|
|
138
|
+
*/
|
|
139
|
+
export function toHubSpotRecordPage(page) {
|
|
140
|
+
return {
|
|
141
|
+
pageInfo: { after: page.paging?.next?.after },
|
|
142
|
+
records: page.results.map(toHubSpotRecord),
|
|
143
|
+
...(page.total === undefined ? {} : { total: page.total }),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Converts typed property entries to HubSpot's provider property map.
|
|
148
|
+
*
|
|
149
|
+
* @param properties - Public property entries.
|
|
150
|
+
*/
|
|
151
|
+
export function toHubSpotProperties(properties) {
|
|
152
|
+
return Object.fromEntries(properties.map(({ name, value }) => [name, value ?? ""]));
|
|
153
|
+
}
|
package/dist/linear/schemas.d.ts
CHANGED
|
@@ -4314,8 +4314,8 @@ export declare const LINEAR_PROJECT_UPDATE_SCHEMA: z.ZodObject<{
|
|
|
4314
4314
|
}, z.core.$strip>;
|
|
4315
4315
|
export declare const LINEAR_PROJECT_MILESTONE_STATUS_SCHEMA: z.ZodEnum<{
|
|
4316
4316
|
done: "done";
|
|
4317
|
-
unstarted: "unstarted";
|
|
4318
4317
|
next: "next";
|
|
4318
|
+
unstarted: "unstarted";
|
|
4319
4319
|
overdue: "overdue";
|
|
4320
4320
|
}>;
|
|
4321
4321
|
export declare const LINEAR_PROJECT_MILESTONE_SCHEMA: z.ZodObject<{
|
|
@@ -4334,8 +4334,8 @@ export declare const LINEAR_PROJECT_MILESTONE_SCHEMA: z.ZodObject<{
|
|
|
4334
4334
|
sortOrder: z.ZodNumber;
|
|
4335
4335
|
status: z.ZodEnum<{
|
|
4336
4336
|
done: "done";
|
|
4337
|
-
unstarted: "unstarted";
|
|
4338
4337
|
next: "next";
|
|
4338
|
+
unstarted: "unstarted";
|
|
4339
4339
|
overdue: "overdue";
|
|
4340
4340
|
}>;
|
|
4341
4341
|
targetDate: z.ZodNullable<z.ZodISODate>;
|
|
@@ -4519,8 +4519,8 @@ export declare const LINEAR_PROVIDER_ISSUE_SCHEMA: z.ZodObject<{
|
|
|
4519
4519
|
id: z.ZodString;
|
|
4520
4520
|
name: z.ZodString;
|
|
4521
4521
|
}, z.core.$strip>>;
|
|
4522
|
-
identifier: z.ZodString;
|
|
4523
4522
|
archivedAt: z.ZodNullable<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>]>>;
|
|
4523
|
+
identifier: z.ZodString;
|
|
4524
4524
|
canceledAt: z.ZodNullable<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>]>>;
|
|
4525
4525
|
estimate: z.ZodNullable<z.ZodNumber>;
|
|
4526
4526
|
priorityLabel: z.ZodString;
|
package/dist/triggers.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { googleCalendarTriggerContracts } from "./google-calendar/index.js"
|
|
|
11
11
|
import type { googleFormsTriggerContracts } from "./google-forms/index.js";
|
|
12
12
|
import type { googleMeetTriggerContracts } from "./google-meet/index.js";
|
|
13
13
|
import type { googleSheetsTriggerContracts } from "./google-sheets/index.js";
|
|
14
|
+
import type { hubspotTriggerContracts } from "./hubspot/index.js";
|
|
14
15
|
import type { linearTriggerContracts } from "./linear/index.js";
|
|
15
16
|
import type { millionVerifierTriggerContracts } from "./millionverifier/index.js";
|
|
16
17
|
import type { notionTriggerContracts } from "./notion/index.js";
|
|
@@ -24,7 +25,7 @@ import type { vercelTriggerContracts } from "./vercel/index.js";
|
|
|
24
25
|
import type { webflowTriggerContracts } from "./webflow/index.js";
|
|
25
26
|
import type { whatsappTriggerContracts } from "./whatsapp/index.js";
|
|
26
27
|
import type { z } from "zod";
|
|
27
|
-
export type TriggerContractMap = typeof airtableTriggerContracts & typeof automateTriggerContracts & typeof asanaTriggerContracts & typeof brevoTriggerContracts & typeof convexTriggerContracts & typeof closeTriggerContracts & typeof cloudflareTriggerContracts & typeof githubTriggerContracts & typeof gmailTriggerContracts & typeof googleCalendarTriggerContracts & typeof googleFormsTriggerContracts & typeof googleMeetTriggerContracts & typeof googleSheetsTriggerContracts & typeof linearTriggerContracts & typeof millionVerifierTriggerContracts & typeof notionTriggerContracts & typeof outlookTriggerContracts & typeof resendTriggerContracts & typeof slackTriggerContracts & typeof stripeTriggerContracts & typeof teamsTriggerContracts & typeof trelloTriggerContracts & typeof vercelTriggerContracts & typeof webflowTriggerContracts & typeof whatsappTriggerContracts;
|
|
28
|
+
export type TriggerContractMap = typeof airtableTriggerContracts & typeof automateTriggerContracts & typeof asanaTriggerContracts & typeof brevoTriggerContracts & typeof convexTriggerContracts & typeof closeTriggerContracts & typeof cloudflareTriggerContracts & typeof githubTriggerContracts & typeof gmailTriggerContracts & typeof googleCalendarTriggerContracts & typeof googleFormsTriggerContracts & typeof googleMeetTriggerContracts & typeof googleSheetsTriggerContracts & typeof hubspotTriggerContracts & typeof linearTriggerContracts & typeof millionVerifierTriggerContracts & typeof notionTriggerContracts & typeof outlookTriggerContracts & typeof resendTriggerContracts & typeof slackTriggerContracts & typeof stripeTriggerContracts & typeof teamsTriggerContracts & typeof trelloTriggerContracts & typeof vercelTriggerContracts & typeof webflowTriggerContracts & typeof whatsappTriggerContracts;
|
|
28
29
|
export type IntegrationTriggerType = keyof TriggerContractMap;
|
|
29
30
|
/** Canonical authoring configuration for one integration trigger type. */
|
|
30
31
|
export type TriggerConfig<TType extends IntegrationTriggerType> = z.input<TriggerContractMap[TType]["configSchema"]> extends Record<string, never> ? object : z.input<TriggerContractMap[TType]["configSchema"]>;
|
package/dist/whatsapp/index.d.ts
CHANGED
|
@@ -330,10 +330,10 @@ export declare const whatsappTriggerContracts: {
|
|
|
330
330
|
video: "video";
|
|
331
331
|
location: "location";
|
|
332
332
|
system: "system";
|
|
333
|
+
contacts: "contacts";
|
|
333
334
|
order: "order";
|
|
334
335
|
reaction: "reaction";
|
|
335
336
|
button: "button";
|
|
336
|
-
contacts: "contacts";
|
|
337
337
|
interactive: "interactive";
|
|
338
338
|
sticker: "sticker";
|
|
339
339
|
unsupported: "unsupported";
|
|
@@ -425,10 +425,10 @@ export declare const whatsappTriggerContracts: {
|
|
|
425
425
|
video: "video";
|
|
426
426
|
location: "location";
|
|
427
427
|
system: "system";
|
|
428
|
+
contacts: "contacts";
|
|
428
429
|
order: "order";
|
|
429
430
|
reaction: "reaction";
|
|
430
431
|
button: "button";
|
|
431
|
-
contacts: "contacts";
|
|
432
432
|
interactive: "interactive";
|
|
433
433
|
sticker: "sticker";
|
|
434
434
|
unsupported: "unsupported";
|
|
@@ -96,10 +96,10 @@ export declare const WHATSAPP_WEBHOOK_SCHEMA: z.ZodObject<{
|
|
|
96
96
|
video: "video";
|
|
97
97
|
location: "location";
|
|
98
98
|
system: "system";
|
|
99
|
+
contacts: "contacts";
|
|
99
100
|
order: "order";
|
|
100
101
|
reaction: "reaction";
|
|
101
102
|
button: "button";
|
|
102
|
-
contacts: "contacts";
|
|
103
103
|
interactive: "interactive";
|
|
104
104
|
sticker: "sticker";
|
|
105
105
|
unsupported: "unsupported";
|
|
@@ -189,10 +189,10 @@ export declare const WHATSAPP_MESSAGE_RECEIVED_EVENT_SCHEMA: z.ZodObject<{
|
|
|
189
189
|
video: "video";
|
|
190
190
|
location: "location";
|
|
191
191
|
system: "system";
|
|
192
|
+
contacts: "contacts";
|
|
192
193
|
order: "order";
|
|
193
194
|
reaction: "reaction";
|
|
194
195
|
button: "button";
|
|
195
|
-
contacts: "contacts";
|
|
196
196
|
interactive: "interactive";
|
|
197
197
|
sticker: "sticker";
|
|
198
198
|
unsupported: "unsupported";
|
|
@@ -284,10 +284,10 @@ export declare const WHATSAPP_MESSAGE_RECEIVED_EVENT_SCHEMA: z.ZodObject<{
|
|
|
284
284
|
video: "video";
|
|
285
285
|
location: "location";
|
|
286
286
|
system: "system";
|
|
287
|
+
contacts: "contacts";
|
|
287
288
|
order: "order";
|
|
288
289
|
reaction: "reaction";
|
|
289
290
|
button: "button";
|
|
290
|
-
contacts: "contacts";
|
|
291
291
|
interactive: "interactive";
|
|
292
292
|
sticker: "sticker";
|
|
293
293
|
unsupported: "unsupported";
|
|
@@ -768,7 +768,7 @@ export declare function normalizeWhatsAppWebhook(input: unknown): {
|
|
|
768
768
|
message: {
|
|
769
769
|
id: string;
|
|
770
770
|
timestamp: string;
|
|
771
|
-
type: "unknown" | "text" | "audio" | "document" | "image" | "video" | "location" | "system" | "
|
|
771
|
+
type: "unknown" | "text" | "audio" | "document" | "image" | "video" | "location" | "system" | "contacts" | "order" | "reaction" | "button" | "interactive" | "sticker" | "unsupported";
|
|
772
772
|
content?: z.core.util.JSONType | undefined;
|
|
773
773
|
context?: {
|
|
774
774
|
messageId: string;
|
|
@@ -781,7 +781,7 @@ export declare function normalizeWhatsAppWebhook(input: unknown): {
|
|
|
781
781
|
from: string;
|
|
782
782
|
id: string;
|
|
783
783
|
timestamp: string;
|
|
784
|
-
type: "unknown" | "text" | "audio" | "document" | "image" | "video" | "location" | "system" | "
|
|
784
|
+
type: "unknown" | "text" | "audio" | "document" | "image" | "video" | "location" | "system" | "contacts" | "order" | "reaction" | "button" | "interactive" | "sticker" | "unsupported";
|
|
785
785
|
audio?: {
|
|
786
786
|
id: string;
|
|
787
787
|
mime_type?: string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automate.ax/integration-contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.121.0",
|
|
4
4
|
"description": "Shared integration payload contracts and provider primitives for Automate.ax.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"./google-meet": "./src/google-meet/index.ts",
|
|
32
32
|
"./google-sheets": "./src/google-sheets/index.ts",
|
|
33
33
|
"./github": "./src/github/index.ts",
|
|
34
|
+
"./hubspot": "./src/hubspot/index.ts",
|
|
34
35
|
"./jobnimbus": "./src/jobnimbus/index.ts",
|
|
35
36
|
"./linear": "./src/linear/index.ts",
|
|
36
37
|
"./millionverifier": "./src/millionverifier/index.ts",
|
|
@@ -53,7 +54,7 @@
|
|
|
53
54
|
}
|
|
54
55
|
},
|
|
55
56
|
"dependencies": {
|
|
56
|
-
"@automate.ax/codec": "0.
|
|
57
|
+
"@automate.ax/codec": "0.121.0",
|
|
57
58
|
"@cfworker/json-schema": "^4.1.1",
|
|
58
59
|
"@googleapis/calendar": "^15.0.0",
|
|
59
60
|
"@googleapis/forms": "^6.0.1",
|
|
@@ -169,6 +170,11 @@
|
|
|
169
170
|
"types": "./dist/github/index.d.ts",
|
|
170
171
|
"default": "./dist/github/index.js"
|
|
171
172
|
},
|
|
173
|
+
"./hubspot": {
|
|
174
|
+
"bun": "./src/hubspot/index.ts",
|
|
175
|
+
"types": "./dist/hubspot/index.d.ts",
|
|
176
|
+
"default": "./dist/hubspot/index.js"
|
|
177
|
+
},
|
|
172
178
|
"./jobnimbus": {
|
|
173
179
|
"bun": "./src/jobnimbus/index.ts",
|
|
174
180
|
"types": "./dist/jobnimbus/index.d.ts",
|