@superdurable/connector-hubspot 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +27 -2
- package/dex-connector.json +426 -0
- package/dist/chunk-HHRHOJKC.js +340 -0
- package/dist/connection-pqfXajbM.d.ts +291 -0
- package/dist/index.d.ts +443 -0
- package/dist/index.js +1184 -0
- package/dist/mock.d.ts +118 -0
- package/dist/mock.js +284 -0
- package/package.json +63 -4
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
// src/generated/models.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { SecretString } from "@superdurable/connectors-sdk";
|
|
4
|
+
var goTimeJSONPattern = /^(\d{4})-(\d{2})-(\d{2})T(\d{1,2}):(\d{2}):(\d{2})(?:[.,](\d+))?(Z|([+-])(\d{2}):(\d{2}))$/;
|
|
5
|
+
function isGoTimeJSON(value) {
|
|
6
|
+
const match = goTimeJSONPattern.exec(value);
|
|
7
|
+
if (!match) return false;
|
|
8
|
+
const [, yearText, monthText, dayText, hourText, minuteText, secondText, , zone, , zoneHourText, zoneMinuteText] = match;
|
|
9
|
+
const year = Number(yearText);
|
|
10
|
+
const month = Number(monthText);
|
|
11
|
+
const day = Number(dayText);
|
|
12
|
+
const isLeap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
13
|
+
const monthDays = [31, isLeap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
14
|
+
return month >= 1 && month <= 12 && day >= 1 && day <= monthDays[month - 1] && Number(hourText) <= 23 && Number(minuteText) <= 59 && Number(secondText) <= 59 && (zone === "Z" || Number(zoneHourText) <= 24 && Number(zoneMinuteText) <= 60);
|
|
15
|
+
}
|
|
16
|
+
function canonicalGoTimeJSON(value) {
|
|
17
|
+
const match = goTimeJSONPattern.exec(value);
|
|
18
|
+
const [, year, month, day, hour, minute, second, fraction, zone, sign, zoneHour, zoneMinute] = match;
|
|
19
|
+
const clock = year + "-" + month + "-" + day + "T" + hour.padStart(2, "0") + ":" + minute + ":" + second;
|
|
20
|
+
const digits = (fraction ?? "").slice(0, 9).replace(/0+$/, "");
|
|
21
|
+
const offsetMinutes = zone === "Z" ? 0 : (Number(zoneHour) * 60 + Number(zoneMinute)) * (sign === "+" ? 1 : -1);
|
|
22
|
+
if (Math.abs(offsetMinutes) >= 1440) return value;
|
|
23
|
+
const offset = offsetMinutes === 0 ? "Z" : (offsetMinutes > 0 ? "+" : "-") + String(Math.floor(Math.abs(offsetMinutes) / 60)).padStart(2, "0") + ":" + String(Math.abs(offsetMinutes) % 60).padStart(2, "0");
|
|
24
|
+
return clock + (digits ? "." + digits : "") + offset;
|
|
25
|
+
}
|
|
26
|
+
var GoTimeJSONSchema = z.string().refine(isGoTimeJSON, "invalid Go time.Time JSON timestamp").transform(canonicalGoTimeJSON);
|
|
27
|
+
var ConfigSchema = z.object({
|
|
28
|
+
"endpoint": z.string().optional(),
|
|
29
|
+
"maxResponseBytes": z.number().int().optional(),
|
|
30
|
+
"pollIntervalMs": z.number().int().optional()
|
|
31
|
+
});
|
|
32
|
+
function decodeCredentials(value) {
|
|
33
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("credential fields are invalid");
|
|
34
|
+
const fields = value;
|
|
35
|
+
const allowed = /* @__PURE__ */ new Set(["auth_method", "access_token", "oauth_client_id", "oauth_client_secret", "refresh_token"]);
|
|
36
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new TypeError("stored credential does not match the connector credential fields");
|
|
37
|
+
if (fields["access_token"] != null && !(typeof fields["access_token"] === "string")) throw new TypeError("credential access_token has an invalid type");
|
|
38
|
+
if (fields["oauth_client_id"] != null && !(typeof fields["oauth_client_id"] === "string")) throw new TypeError("credential oauth_client_id has an invalid type");
|
|
39
|
+
if (fields["oauth_client_secret"] != null && !(typeof fields["oauth_client_secret"] === "string")) throw new TypeError("credential oauth_client_secret has an invalid type");
|
|
40
|
+
if (fields["refresh_token"] != null && !(typeof fields["refresh_token"] === "string")) throw new TypeError("credential refresh_token has an invalid type");
|
|
41
|
+
const selectedMethod = fields["auth_method"] ?? "";
|
|
42
|
+
if (typeof selectedMethod !== "string") throw new TypeError("credential auth_method is invalid");
|
|
43
|
+
const method = selectedMethod || "private-app-token";
|
|
44
|
+
const credentials = { authMethodId: method };
|
|
45
|
+
if (method === "private-app-token") {
|
|
46
|
+
if (!fields["access_token"]) throw new TypeError("credential access_token is required");
|
|
47
|
+
if (fields["access_token"]) credentials.accessToken = new SecretString(fields["access_token"]);
|
|
48
|
+
} else if (method === "hubspot-oauth") {
|
|
49
|
+
if (!fields["oauth_client_id"]) throw new TypeError("credential oauth_client_id is required");
|
|
50
|
+
if (fields["oauth_client_id"]) credentials.oauthClientId = fields["oauth_client_id"];
|
|
51
|
+
if (!fields["oauth_client_secret"]) throw new TypeError("credential oauth_client_secret is required");
|
|
52
|
+
if (fields["oauth_client_secret"]) credentials.oauthClientSecret = new SecretString(fields["oauth_client_secret"]);
|
|
53
|
+
if (!fields["access_token"]) throw new TypeError("credential access_token is required");
|
|
54
|
+
if (fields["access_token"]) credentials.accessToken = new SecretString(fields["access_token"]);
|
|
55
|
+
if (!fields["refresh_token"]) throw new TypeError("credential refresh_token is required");
|
|
56
|
+
if (fields["refresh_token"]) credentials.refreshToken = new SecretString(fields["refresh_token"]);
|
|
57
|
+
} else {
|
|
58
|
+
throw new TypeError("credential auth_method is invalid");
|
|
59
|
+
}
|
|
60
|
+
return credentials;
|
|
61
|
+
}
|
|
62
|
+
function decodeSharedCredentials(value) {
|
|
63
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("credential fields are invalid");
|
|
64
|
+
const fields = value;
|
|
65
|
+
const allowed = /* @__PURE__ */ new Set(["auth_method", "access_token", "oauth_client_id", "oauth_client_secret", "refresh_token"]);
|
|
66
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new TypeError("stored credential does not match the connector credential fields");
|
|
67
|
+
if (fields["access_token"] != null && !(typeof fields["access_token"] === "string")) throw new TypeError("credential access_token has an invalid type");
|
|
68
|
+
if (fields["oauth_client_id"] != null && !(typeof fields["oauth_client_id"] === "string")) throw new TypeError("credential oauth_client_id has an invalid type");
|
|
69
|
+
if (fields["oauth_client_secret"] != null && !(typeof fields["oauth_client_secret"] === "string")) throw new TypeError("credential oauth_client_secret has an invalid type");
|
|
70
|
+
if (fields["refresh_token"] != null && !(typeof fields["refresh_token"] === "string")) throw new TypeError("credential refresh_token has an invalid type");
|
|
71
|
+
const selectedMethod = fields["auth_method"] ?? "";
|
|
72
|
+
if (typeof selectedMethod !== "string") throw new TypeError("credential auth_method is invalid");
|
|
73
|
+
const method = selectedMethod || "private-app-token";
|
|
74
|
+
const credentials = { authMethodId: method };
|
|
75
|
+
if (method === "private-app-token") {
|
|
76
|
+
if (!fields["access_token"]) throw new TypeError("credential access_token is required");
|
|
77
|
+
if (fields["access_token"]) credentials.accessToken = new SecretString(fields["access_token"]);
|
|
78
|
+
} else if (method === "hubspot-oauth") {
|
|
79
|
+
if (!fields["oauth_client_id"]) throw new TypeError("credential oauth_client_id is required");
|
|
80
|
+
if (fields["oauth_client_id"]) credentials.oauthClientId = fields["oauth_client_id"];
|
|
81
|
+
if (fields["oauth_client_secret"]) credentials.oauthClientSecret = new SecretString(fields["oauth_client_secret"]);
|
|
82
|
+
if (!fields["access_token"]) throw new TypeError("credential access_token is required");
|
|
83
|
+
if (fields["access_token"]) credentials.accessToken = new SecretString(fields["access_token"]);
|
|
84
|
+
if (fields["refresh_token"]) credentials.refreshToken = new SecretString(fields["refresh_token"]);
|
|
85
|
+
} else {
|
|
86
|
+
throw new TypeError("credential auth_method is invalid");
|
|
87
|
+
}
|
|
88
|
+
return credentials;
|
|
89
|
+
}
|
|
90
|
+
var SearchFilterSchema = z.strictObject({
|
|
91
|
+
"propertyName": z.string(),
|
|
92
|
+
"operator": z.string(),
|
|
93
|
+
"value": z.string().optional(),
|
|
94
|
+
"highValue": z.string().optional(),
|
|
95
|
+
"values": z.array(z.string()).optional()
|
|
96
|
+
});
|
|
97
|
+
var SearchFilterGroupSchema = z.strictObject({
|
|
98
|
+
"filters": z.array(SearchFilterSchema).nullable()
|
|
99
|
+
});
|
|
100
|
+
var SearchSortSchema = z.strictObject({
|
|
101
|
+
"propertyName": z.string(),
|
|
102
|
+
"direction": z.string()
|
|
103
|
+
});
|
|
104
|
+
var SearchObjectsInputSchema = z.strictObject({
|
|
105
|
+
"objectType": z.string(),
|
|
106
|
+
"filterGroups": z.array(SearchFilterGroupSchema).optional(),
|
|
107
|
+
"query": z.string().optional(),
|
|
108
|
+
"sort": SearchSortSchema.optional(),
|
|
109
|
+
"properties": z.array(z.string()).optional(),
|
|
110
|
+
"limit": z.number().int().optional(),
|
|
111
|
+
"after": z.string().optional()
|
|
112
|
+
});
|
|
113
|
+
var CRMObjectSchema = z.strictObject({
|
|
114
|
+
"objectType": z.string(),
|
|
115
|
+
"id": z.string(),
|
|
116
|
+
"properties": z.record(z.string(), z.string()).optional(),
|
|
117
|
+
"createdAt": GoTimeJSONSchema.optional(),
|
|
118
|
+
"updatedAt": GoTimeJSONSchema.optional(),
|
|
119
|
+
"archived": z.boolean(),
|
|
120
|
+
"url": z.string().optional()
|
|
121
|
+
});
|
|
122
|
+
var ObjectPageSchema = z.strictObject({
|
|
123
|
+
"objectType": z.string(),
|
|
124
|
+
"total": z.number().int(),
|
|
125
|
+
"objects": z.array(CRMObjectSchema).nullable(),
|
|
126
|
+
"nextAfter": z.string().optional()
|
|
127
|
+
});
|
|
128
|
+
var GetObjectInputSchema = z.strictObject({
|
|
129
|
+
"objectType": z.string(),
|
|
130
|
+
"objectId": z.string(),
|
|
131
|
+
"properties": z.array(z.string()).optional()
|
|
132
|
+
});
|
|
133
|
+
var UpsertObjectInputSchema = z.strictObject({
|
|
134
|
+
"objectType": z.string(),
|
|
135
|
+
"idProperty": z.string(),
|
|
136
|
+
"idValue": z.string(),
|
|
137
|
+
"properties": z.record(z.string(), z.string()).optional()
|
|
138
|
+
});
|
|
139
|
+
var UpsertedObjectSchema = z.strictObject({
|
|
140
|
+
"object": CRMObjectSchema,
|
|
141
|
+
"created": z.boolean()
|
|
142
|
+
});
|
|
143
|
+
var UpdateObjectInputSchema = z.strictObject({
|
|
144
|
+
"objectType": z.string(),
|
|
145
|
+
"objectId": z.string(),
|
|
146
|
+
"properties": z.record(z.string(), z.string()).nullable()
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// src/generated/definitions.ts
|
|
150
|
+
var ConnectorID = "hubspot";
|
|
151
|
+
var ProviderID = "hubspot";
|
|
152
|
+
var SearchObjectsBranch = {
|
|
153
|
+
Searched: "searched",
|
|
154
|
+
ProviderRejected: "providerRejected",
|
|
155
|
+
InvalidResponse: "invalidResponse",
|
|
156
|
+
Defect: "defect"
|
|
157
|
+
};
|
|
158
|
+
var SearchObjectsBranchSearched = SearchObjectsBranch.Searched;
|
|
159
|
+
var SearchObjectsBranchProviderRejected = SearchObjectsBranch.ProviderRejected;
|
|
160
|
+
var SearchObjectsBranchInvalidResponse = SearchObjectsBranch.InvalidResponse;
|
|
161
|
+
var SearchObjectsBranchDefect = SearchObjectsBranch.Defect;
|
|
162
|
+
var SearchObjectsDefinition = {
|
|
163
|
+
operation: { connectorId: ConnectorID, operationId: "searchObjects" },
|
|
164
|
+
branches: [
|
|
165
|
+
{ id: "searched", description: "HubSpot returned one bounded page of matching records; the page may be empty." },
|
|
166
|
+
{ id: "providerRejected", description: "HubSpot conclusively rejected the search, such as an unknown property, a missing scope, a rejected token, or an exhausted daily limit.", optional: true },
|
|
167
|
+
{ id: "invalidResponse", description: "HubSpot returned an invalid or oversized search response.", optional: true },
|
|
168
|
+
{ id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
|
|
169
|
+
],
|
|
170
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
171
|
+
};
|
|
172
|
+
var SearchObjectsMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
173
|
+
var GetObjectBranch = {
|
|
174
|
+
Found: "found",
|
|
175
|
+
NotFound: "notFound",
|
|
176
|
+
ProviderRejected: "providerRejected",
|
|
177
|
+
InvalidResponse: "invalidResponse",
|
|
178
|
+
Defect: "defect"
|
|
179
|
+
};
|
|
180
|
+
var GetObjectBranchFound = GetObjectBranch.Found;
|
|
181
|
+
var GetObjectBranchNotFound = GetObjectBranch.NotFound;
|
|
182
|
+
var GetObjectBranchProviderRejected = GetObjectBranch.ProviderRejected;
|
|
183
|
+
var GetObjectBranchInvalidResponse = GetObjectBranch.InvalidResponse;
|
|
184
|
+
var GetObjectBranchDefect = GetObjectBranch.Defect;
|
|
185
|
+
var GetObjectDefinition = {
|
|
186
|
+
operation: { connectorId: ConnectorID, operationId: "getObject" },
|
|
187
|
+
branches: [
|
|
188
|
+
{ id: "found", description: "The record exists and was returned." },
|
|
189
|
+
{ id: "notFound", description: "No unarchived record of that object type has the record ID.", optional: true },
|
|
190
|
+
{ id: "providerRejected", description: "HubSpot conclusively rejected the read, such as an unknown property, a missing scope, a rejected token, or an exhausted daily limit.", optional: true },
|
|
191
|
+
{ id: "invalidResponse", description: "HubSpot returned an invalid or oversized record response.", optional: true },
|
|
192
|
+
{ id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
|
|
193
|
+
],
|
|
194
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
195
|
+
};
|
|
196
|
+
var GetObjectMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
197
|
+
var UpsertObjectBranch = {
|
|
198
|
+
Upserted: "upserted",
|
|
199
|
+
Conflict: "conflict",
|
|
200
|
+
ProviderRejected: "providerRejected",
|
|
201
|
+
InvalidResponse: "invalidResponse",
|
|
202
|
+
Defect: "defect"
|
|
203
|
+
};
|
|
204
|
+
var UpsertObjectBranchUpserted = UpsertObjectBranch.Upserted;
|
|
205
|
+
var UpsertObjectBranchConflict = UpsertObjectBranch.Conflict;
|
|
206
|
+
var UpsertObjectBranchProviderRejected = UpsertObjectBranch.ProviderRejected;
|
|
207
|
+
var UpsertObjectBranchInvalidResponse = UpsertObjectBranch.InvalidResponse;
|
|
208
|
+
var UpsertObjectBranchDefect = UpsertObjectBranch.Defect;
|
|
209
|
+
var UpsertObjectDefinition = {
|
|
210
|
+
operation: { connectorId: ConnectorID, operationId: "upsertObject" },
|
|
211
|
+
branches: [
|
|
212
|
+
{ id: "upserted", description: "HubSpot created the record or updated the record that owns the unique value." },
|
|
213
|
+
{ id: "conflict", description: "The properties conflict with another record, such as an email that another contact already owns.", optional: true },
|
|
214
|
+
{ id: "providerRejected", description: "HubSpot conclusively rejected the upsert, such as an invalid property value, a property that is not unique, a missing scope, a rejected token, or an exhausted daily limit.", optional: true },
|
|
215
|
+
{ id: "invalidResponse", description: "HubSpot applied or rejected the upsert but returned an invalid or oversized response.", optional: true },
|
|
216
|
+
{ id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
|
|
217
|
+
],
|
|
218
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" },
|
|
219
|
+
repeatOnUnknown: "limited",
|
|
220
|
+
maxSends: 3
|
|
221
|
+
};
|
|
222
|
+
var UpsertObjectMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
|
|
223
|
+
var UpdateObjectBranch = {
|
|
224
|
+
Updated: "updated",
|
|
225
|
+
NotFound: "notFound",
|
|
226
|
+
Conflict: "conflict",
|
|
227
|
+
ProviderRejected: "providerRejected",
|
|
228
|
+
InvalidResponse: "invalidResponse",
|
|
229
|
+
Defect: "defect"
|
|
230
|
+
};
|
|
231
|
+
var UpdateObjectBranchUpdated = UpdateObjectBranch.Updated;
|
|
232
|
+
var UpdateObjectBranchNotFound = UpdateObjectBranch.NotFound;
|
|
233
|
+
var UpdateObjectBranchConflict = UpdateObjectBranch.Conflict;
|
|
234
|
+
var UpdateObjectBranchProviderRejected = UpdateObjectBranch.ProviderRejected;
|
|
235
|
+
var UpdateObjectBranchInvalidResponse = UpdateObjectBranch.InvalidResponse;
|
|
236
|
+
var UpdateObjectBranchDefect = UpdateObjectBranch.Defect;
|
|
237
|
+
var UpdateObjectDefinition = {
|
|
238
|
+
operation: { connectorId: ConnectorID, operationId: "updateObject" },
|
|
239
|
+
branches: [
|
|
240
|
+
{ id: "updated", description: "HubSpot updated the record and returned it." },
|
|
241
|
+
{ id: "notFound", description: "No unarchived record of that object type has the record ID.", optional: true },
|
|
242
|
+
{ id: "conflict", description: "The properties conflict with another record, such as an email that another contact already owns.", optional: true },
|
|
243
|
+
{ id: "providerRejected", description: "HubSpot conclusively rejected the update, such as an invalid property value, a missing scope, a rejected token, or an exhausted daily limit.", optional: true },
|
|
244
|
+
{ id: "invalidResponse", description: "HubSpot applied or rejected the update but returned an invalid or oversized response.", optional: true },
|
|
245
|
+
{ id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
|
|
246
|
+
],
|
|
247
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" },
|
|
248
|
+
repeatOnUnknown: "limited",
|
|
249
|
+
maxSends: 3
|
|
250
|
+
};
|
|
251
|
+
var UpdateObjectMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
|
|
252
|
+
|
|
253
|
+
// src/generated/connection.ts
|
|
254
|
+
import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
|
|
255
|
+
import { newRefreshingCredentialProvider } from "@superdurable/connectors-sdk/projectconfig";
|
|
256
|
+
var Connection = class {
|
|
257
|
+
/** Stable provider and connection name. */
|
|
258
|
+
reference;
|
|
259
|
+
/** Bound provider operations. */
|
|
260
|
+
operations;
|
|
261
|
+
/** Validate a reference and bind operations. */
|
|
262
|
+
constructor(reference, operations) {
|
|
263
|
+
this.reference = ConnectionRefSchema.parse(reference);
|
|
264
|
+
if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
|
|
265
|
+
if (!operations) throw new TypeError("connector operations are required");
|
|
266
|
+
this.operations = operations;
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
function newConnection(client, reference) {
|
|
270
|
+
if (!client) throw new TypeError("connector client is required");
|
|
271
|
+
return new Connection(reference, client);
|
|
272
|
+
}
|
|
273
|
+
function newConnectionWithOperations(operations, reference) {
|
|
274
|
+
return new Connection(reference, operations);
|
|
275
|
+
}
|
|
276
|
+
function newProjectConnection(project, connectionName, createClient) {
|
|
277
|
+
if (!project) throw new TypeError("loaded project is required");
|
|
278
|
+
const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
|
|
279
|
+
const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
|
|
280
|
+
if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
|
|
281
|
+
return newConnection(createClient(project, connectionName), reference);
|
|
282
|
+
}
|
|
283
|
+
function newProjectCredentialProvider(project, connectionName, decode, encode, decodeShared) {
|
|
284
|
+
return newRefreshingCredentialProvider(project.connections, { connectorId: ConnectorID, connectionName }, decode, encode, decodeShared);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export {
|
|
288
|
+
ConfigSchema,
|
|
289
|
+
decodeCredentials,
|
|
290
|
+
decodeSharedCredentials,
|
|
291
|
+
SearchFilterSchema,
|
|
292
|
+
SearchFilterGroupSchema,
|
|
293
|
+
SearchSortSchema,
|
|
294
|
+
SearchObjectsInputSchema,
|
|
295
|
+
CRMObjectSchema,
|
|
296
|
+
ObjectPageSchema,
|
|
297
|
+
GetObjectInputSchema,
|
|
298
|
+
UpsertObjectInputSchema,
|
|
299
|
+
UpsertedObjectSchema,
|
|
300
|
+
UpdateObjectInputSchema,
|
|
301
|
+
ConnectorID,
|
|
302
|
+
ProviderID,
|
|
303
|
+
SearchObjectsBranch,
|
|
304
|
+
SearchObjectsBranchSearched,
|
|
305
|
+
SearchObjectsBranchProviderRejected,
|
|
306
|
+
SearchObjectsBranchInvalidResponse,
|
|
307
|
+
SearchObjectsBranchDefect,
|
|
308
|
+
SearchObjectsDefinition,
|
|
309
|
+
SearchObjectsMetadata,
|
|
310
|
+
GetObjectBranch,
|
|
311
|
+
GetObjectBranchFound,
|
|
312
|
+
GetObjectBranchNotFound,
|
|
313
|
+
GetObjectBranchProviderRejected,
|
|
314
|
+
GetObjectBranchInvalidResponse,
|
|
315
|
+
GetObjectBranchDefect,
|
|
316
|
+
GetObjectDefinition,
|
|
317
|
+
GetObjectMetadata,
|
|
318
|
+
UpsertObjectBranch,
|
|
319
|
+
UpsertObjectBranchUpserted,
|
|
320
|
+
UpsertObjectBranchConflict,
|
|
321
|
+
UpsertObjectBranchProviderRejected,
|
|
322
|
+
UpsertObjectBranchInvalidResponse,
|
|
323
|
+
UpsertObjectBranchDefect,
|
|
324
|
+
UpsertObjectDefinition,
|
|
325
|
+
UpsertObjectMetadata,
|
|
326
|
+
UpdateObjectBranch,
|
|
327
|
+
UpdateObjectBranchUpdated,
|
|
328
|
+
UpdateObjectBranchNotFound,
|
|
329
|
+
UpdateObjectBranchConflict,
|
|
330
|
+
UpdateObjectBranchProviderRejected,
|
|
331
|
+
UpdateObjectBranchInvalidResponse,
|
|
332
|
+
UpdateObjectBranchDefect,
|
|
333
|
+
UpdateObjectDefinition,
|
|
334
|
+
UpdateObjectMetadata,
|
|
335
|
+
Connection,
|
|
336
|
+
newConnection,
|
|
337
|
+
newConnectionWithOperations,
|
|
338
|
+
newProjectConnection,
|
|
339
|
+
newProjectCredentialProvider
|
|
340
|
+
};
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { RefreshingCredentialProvider, SecretString, Query, Mutation, ConnectionRef } from '@superdurable/connectors-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/** Connector configuration; omitted fields use manifest defaults. */
|
|
5
|
+
interface Config {
|
|
6
|
+
/** HubSpot API base URL; leave blank for HubSpot's public API host, which serves every data center. Enter an absolute HTTPS URL only for an explicitly supported compatible gateway, or a loopback HTTP URL for a local test server. */
|
|
7
|
+
endpoint?: string;
|
|
8
|
+
/** Maximum complete HubSpot API response in bytes; enter a positive integer only to change the safety limit. Oversized responses select invalidResponse. */
|
|
9
|
+
maxResponseBytes?: number;
|
|
10
|
+
/** Delay between crmObjectChanged Trigger polls of HubSpot CRM search, as a Go duration of at least 5s such as 15s or 2m; leave it blank for the default interval. Shorter intervals deliver changes sooner and use more of the account's search limit of five requests per second and its daily API limit. Runtime value in milliseconds. */
|
|
11
|
+
pollIntervalMs?: number;
|
|
12
|
+
}
|
|
13
|
+
/** Runtime schema for manifest configuration. */
|
|
14
|
+
declare const ConfigSchema: z.ZodObject<{
|
|
15
|
+
endpoint: z.ZodOptional<z.ZodString>;
|
|
16
|
+
maxResponseBytes: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
pollIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
/** Private connector credentials resolved by the host. */
|
|
20
|
+
interface Credentials {
|
|
21
|
+
/** Selected authorization method. */
|
|
22
|
+
authMethodId?: string;
|
|
23
|
+
/** Secret 30-minute access token produced automatically by HubSpot OAuth and refreshed before it expires; never paste a token here. */
|
|
24
|
+
accessToken: SecretString;
|
|
25
|
+
/** Non-secret OAuth client ID copied from https://app.hubspot.com under Development > Legacy apps > the public app > Auth, or from a project app's Auth settings; it has the UUID shape aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee, and blank means authorization and refresh cannot start. */
|
|
26
|
+
oauthClientId?: string;
|
|
27
|
+
/** Secret OAuth client secret copied from the same Auth page; Dex Web stores it as a secret and sends it only to HubSpot's token endpoint, and blank means authorization and refresh cannot start. */
|
|
28
|
+
oauthClientSecret?: SecretString;
|
|
29
|
+
/** Secret long-lived refresh token produced by HubSpot OAuth; Dex stores any replacement HubSpot returns, and a blank or rejected token means you must authorize again. */
|
|
30
|
+
refreshToken?: SecretString;
|
|
31
|
+
}
|
|
32
|
+
/** Decode private credential fields for the selected authorization method. */
|
|
33
|
+
declare function decodeCredentials(value: unknown): Credentials;
|
|
34
|
+
/** Decode shared credential fields for the selected authorization method. */
|
|
35
|
+
declare function decodeSharedCredentials(value: unknown): Credentials;
|
|
36
|
+
/** Host-owned source of private connector credentials. */
|
|
37
|
+
type CredentialSource = RefreshingCredentialProvider<Credentials>;
|
|
38
|
+
/** SearchFilter is one typed CRM search condition. */
|
|
39
|
+
interface SearchFilter {
|
|
40
|
+
/** PropertyName is an internal property name such as email, or an
|
|
41
|
+
* association pseudo-property such as associations.contact. */
|
|
42
|
+
"propertyName": string;
|
|
43
|
+
/** Operator selects the comparison. */
|
|
44
|
+
"operator": "BETWEEN" | "CONTAINS_TOKEN" | "EQ" | "GT" | "GTE" | "HAS_PROPERTY" | "IN" | "LT" | "LTE" | "NEQ" | "NOT_CONTAINS_TOKEN" | "NOT_HAS_PROPERTY" | "NOT_IN" | (string & {});
|
|
45
|
+
/** Value is the comparison value for EQ, NEQ, LT, LTE, GT, GTE, BETWEEN,
|
|
46
|
+
* CONTAINS_TOKEN, and NOT_CONTAINS_TOKEN. Dates are Unix milliseconds. */
|
|
47
|
+
"value"?: string | undefined;
|
|
48
|
+
/** HighValue is the inclusive upper bound for BETWEEN. */
|
|
49
|
+
"highValue"?: string | undefined;
|
|
50
|
+
/** Values lists the candidates for IN and NOT_IN. HubSpot requires lowercase
|
|
51
|
+
* values when the property is a string property. */
|
|
52
|
+
"values"?: Array<string> | undefined;
|
|
53
|
+
}
|
|
54
|
+
/** SearchFilterGroup AND-s its filters. A search OR-s its groups. */
|
|
55
|
+
interface SearchFilterGroup {
|
|
56
|
+
/** Filters are the conditions that must all match. */
|
|
57
|
+
"filters": Array<SearchFilter> | null;
|
|
58
|
+
}
|
|
59
|
+
/** SearchSort orders search results by one property. */
|
|
60
|
+
interface SearchSort {
|
|
61
|
+
/** PropertyName is the internal property name to sort by. */
|
|
62
|
+
"propertyName": string;
|
|
63
|
+
/** Direction is ascending or descending. */
|
|
64
|
+
"direction": "ASCENDING" | "DESCENDING" | (string & {});
|
|
65
|
+
}
|
|
66
|
+
/** SearchObjectsInput selects one bounded page of matching records. */
|
|
67
|
+
interface SearchObjectsInput {
|
|
68
|
+
/** ObjectType is the object type to search. */
|
|
69
|
+
"objectType": "companies" | "contacts" | "deals" | (string & {});
|
|
70
|
+
/** FilterGroups are OR-ed; empty matches every record. HubSpot allows five
|
|
71
|
+
* groups, six filters per group, and eighteen filters in total. */
|
|
72
|
+
"filterGroups"?: Array<SearchFilterGroup> | undefined;
|
|
73
|
+
/** Query optionally searches the object's default text properties. */
|
|
74
|
+
"query"?: string | undefined;
|
|
75
|
+
/** Sort optionally orders results; without it HubSpot returns oldest records first. */
|
|
76
|
+
"sort"?: SearchSort | undefined;
|
|
77
|
+
/** Properties lists the property values to return; empty returns HubSpot's
|
|
78
|
+
* default properties for the object type. */
|
|
79
|
+
"properties"?: Array<string> | undefined;
|
|
80
|
+
/** Limit is the page size from 1 through 200; zero uses 10. */
|
|
81
|
+
"limit"?: number | undefined;
|
|
82
|
+
/** After is the NextAfter cursor of the previous page; empty starts at the
|
|
83
|
+
* first result. Paging cannot pass HubSpot's 10,000th result. */
|
|
84
|
+
"after"?: string | undefined;
|
|
85
|
+
}
|
|
86
|
+
/** CRMObject is one HubSpot CRM record. */
|
|
87
|
+
interface CRMObject {
|
|
88
|
+
/** ObjectType is the record's object type. */
|
|
89
|
+
"objectType": "companies" | "contacts" | "deals" | (string & {});
|
|
90
|
+
/** ID is HubSpot's record ID (hs_object_id), a decimal string. */
|
|
91
|
+
"id": string;
|
|
92
|
+
/** Properties holds the returned property values keyed by internal property
|
|
93
|
+
* name. HubSpot returns every value as a string; a property without a value
|
|
94
|
+
* is absent. */
|
|
95
|
+
"properties"?: {
|
|
96
|
+
[key: string]: string;
|
|
97
|
+
} | undefined;
|
|
98
|
+
/** CreatedAt is when HubSpot created the record, when reported. */
|
|
99
|
+
"createdAt"?: string | undefined;
|
|
100
|
+
/** UpdatedAt is when HubSpot last modified the record, when reported. */
|
|
101
|
+
"updatedAt"?: string | undefined;
|
|
102
|
+
/** Archived reports whether the record is archived. */
|
|
103
|
+
"archived": boolean;
|
|
104
|
+
/** URL is the HubSpot app link to the record when HubSpot returns one. */
|
|
105
|
+
"url"?: string | undefined;
|
|
106
|
+
}
|
|
107
|
+
/** ObjectPage is one page of CRM search results. */
|
|
108
|
+
interface ObjectPage {
|
|
109
|
+
/** ObjectType is the searched object type. */
|
|
110
|
+
"objectType": "companies" | "contacts" | "deals" | (string & {});
|
|
111
|
+
/** Total is HubSpot's count of all matching records. */
|
|
112
|
+
"total": number;
|
|
113
|
+
/** Objects are the records on this page, possibly none. */
|
|
114
|
+
"objects": Array<CRMObject> | null;
|
|
115
|
+
/** NextAfter is the cursor for the next page, empty on the last page. */
|
|
116
|
+
"nextAfter"?: string | undefined;
|
|
117
|
+
}
|
|
118
|
+
/** GetObjectInput identifies one record. */
|
|
119
|
+
interface GetObjectInput {
|
|
120
|
+
/** ObjectType is the record's object type. */
|
|
121
|
+
"objectType": "companies" | "contacts" | "deals" | (string & {});
|
|
122
|
+
/** ObjectID is HubSpot's decimal record ID. */
|
|
123
|
+
"objectId": string;
|
|
124
|
+
/** Properties lists the property values to return; empty returns HubSpot's
|
|
125
|
+
* default properties for the object type. */
|
|
126
|
+
"properties"?: Array<string> | undefined;
|
|
127
|
+
}
|
|
128
|
+
/** UpsertObjectInput creates or updates one record identified by a unique property value. */
|
|
129
|
+
interface UpsertObjectInput {
|
|
130
|
+
/** ObjectType is the record's object type. */
|
|
131
|
+
"objectType": "companies" | "contacts" | "deals" | (string & {});
|
|
132
|
+
/** IDProperty is a unique identifier property: email for contacts, or a
|
|
133
|
+
* custom property created with unique values for any object type. */
|
|
134
|
+
"idProperty": string;
|
|
135
|
+
/** IDValue is the unique value that identifies the record, such as the email address. */
|
|
136
|
+
"idValue": string;
|
|
137
|
+
/** Properties are the values to set, keyed by internal property name. An
|
|
138
|
+
* empty string clears a value. */
|
|
139
|
+
"properties"?: {
|
|
140
|
+
[key: string]: string;
|
|
141
|
+
} | undefined;
|
|
142
|
+
}
|
|
143
|
+
/** UpsertedObject is the record an upsert created or updated. */
|
|
144
|
+
interface UpsertedObject {
|
|
145
|
+
/** Object is the record with the values HubSpot returned. */
|
|
146
|
+
"object": CRMObject;
|
|
147
|
+
/** Created reports whether the dispatch HubSpot answered created the record.
|
|
148
|
+
* After a Dex retry or a repeated dispatch it can be false even though an
|
|
149
|
+
* earlier dispatch of the same Step created the record. */
|
|
150
|
+
"created": boolean;
|
|
151
|
+
}
|
|
152
|
+
/** UpdateObjectInput replaces property values on one record. */
|
|
153
|
+
interface UpdateObjectInput {
|
|
154
|
+
/** ObjectType is the record's object type. */
|
|
155
|
+
"objectType": "companies" | "contacts" | "deals" | (string & {});
|
|
156
|
+
/** ObjectID is HubSpot's decimal record ID. */
|
|
157
|
+
"objectId": string;
|
|
158
|
+
/** Properties are the values to set, keyed by internal property name. At
|
|
159
|
+
* least one is required, and an empty string clears a value. */
|
|
160
|
+
"properties": {
|
|
161
|
+
[key: string]: string;
|
|
162
|
+
} | null;
|
|
163
|
+
}
|
|
164
|
+
/** Runtime validator for SearchFilter. */
|
|
165
|
+
declare const SearchFilterSchema: z.ZodObject<{
|
|
166
|
+
propertyName: z.ZodString;
|
|
167
|
+
operator: z.ZodString;
|
|
168
|
+
value: z.ZodOptional<z.ZodString>;
|
|
169
|
+
highValue: z.ZodOptional<z.ZodString>;
|
|
170
|
+
values: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
171
|
+
}, z.core.$strict>;
|
|
172
|
+
/** Runtime validator for SearchFilterGroup. */
|
|
173
|
+
declare const SearchFilterGroupSchema: z.ZodObject<{
|
|
174
|
+
filters: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
175
|
+
propertyName: z.ZodString;
|
|
176
|
+
operator: z.ZodString;
|
|
177
|
+
value: z.ZodOptional<z.ZodString>;
|
|
178
|
+
highValue: z.ZodOptional<z.ZodString>;
|
|
179
|
+
values: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
180
|
+
}, z.core.$strict>>>;
|
|
181
|
+
}, z.core.$strict>;
|
|
182
|
+
/** Runtime validator for SearchSort. */
|
|
183
|
+
declare const SearchSortSchema: z.ZodObject<{
|
|
184
|
+
propertyName: z.ZodString;
|
|
185
|
+
direction: z.ZodString;
|
|
186
|
+
}, z.core.$strict>;
|
|
187
|
+
/** Runtime validator for SearchObjectsInput. */
|
|
188
|
+
declare const SearchObjectsInputSchema: z.ZodObject<{
|
|
189
|
+
objectType: z.ZodString;
|
|
190
|
+
filterGroups: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
191
|
+
filters: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
192
|
+
propertyName: z.ZodString;
|
|
193
|
+
operator: z.ZodString;
|
|
194
|
+
value: z.ZodOptional<z.ZodString>;
|
|
195
|
+
highValue: z.ZodOptional<z.ZodString>;
|
|
196
|
+
values: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
197
|
+
}, z.core.$strict>>>;
|
|
198
|
+
}, z.core.$strict>>>;
|
|
199
|
+
query: z.ZodOptional<z.ZodString>;
|
|
200
|
+
sort: z.ZodOptional<z.ZodObject<{
|
|
201
|
+
propertyName: z.ZodString;
|
|
202
|
+
direction: z.ZodString;
|
|
203
|
+
}, z.core.$strict>>;
|
|
204
|
+
properties: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
205
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
206
|
+
after: z.ZodOptional<z.ZodString>;
|
|
207
|
+
}, z.core.$strict>;
|
|
208
|
+
/** Runtime validator for CRMObject. */
|
|
209
|
+
declare const CRMObjectSchema: z.ZodObject<{
|
|
210
|
+
objectType: z.ZodString;
|
|
211
|
+
id: z.ZodString;
|
|
212
|
+
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
213
|
+
createdAt: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
214
|
+
updatedAt: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
215
|
+
archived: z.ZodBoolean;
|
|
216
|
+
url: z.ZodOptional<z.ZodString>;
|
|
217
|
+
}, z.core.$strict>;
|
|
218
|
+
/** Runtime validator for ObjectPage. */
|
|
219
|
+
declare const ObjectPageSchema: z.ZodObject<{
|
|
220
|
+
objectType: z.ZodString;
|
|
221
|
+
total: z.ZodNumber;
|
|
222
|
+
objects: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
223
|
+
objectType: z.ZodString;
|
|
224
|
+
id: z.ZodString;
|
|
225
|
+
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
226
|
+
createdAt: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
227
|
+
updatedAt: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
228
|
+
archived: z.ZodBoolean;
|
|
229
|
+
url: z.ZodOptional<z.ZodString>;
|
|
230
|
+
}, z.core.$strict>>>;
|
|
231
|
+
nextAfter: z.ZodOptional<z.ZodString>;
|
|
232
|
+
}, z.core.$strict>;
|
|
233
|
+
/** Runtime validator for GetObjectInput. */
|
|
234
|
+
declare const GetObjectInputSchema: z.ZodObject<{
|
|
235
|
+
objectType: z.ZodString;
|
|
236
|
+
objectId: z.ZodString;
|
|
237
|
+
properties: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
238
|
+
}, z.core.$strict>;
|
|
239
|
+
/** Runtime validator for UpsertObjectInput. */
|
|
240
|
+
declare const UpsertObjectInputSchema: z.ZodObject<{
|
|
241
|
+
objectType: z.ZodString;
|
|
242
|
+
idProperty: z.ZodString;
|
|
243
|
+
idValue: z.ZodString;
|
|
244
|
+
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
245
|
+
}, z.core.$strict>;
|
|
246
|
+
/** Runtime validator for UpsertedObject. */
|
|
247
|
+
declare const UpsertedObjectSchema: z.ZodObject<{
|
|
248
|
+
object: z.ZodObject<{
|
|
249
|
+
objectType: z.ZodString;
|
|
250
|
+
id: z.ZodString;
|
|
251
|
+
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
252
|
+
createdAt: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
253
|
+
updatedAt: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
254
|
+
archived: z.ZodBoolean;
|
|
255
|
+
url: z.ZodOptional<z.ZodString>;
|
|
256
|
+
}, z.core.$strict>;
|
|
257
|
+
created: z.ZodBoolean;
|
|
258
|
+
}, z.core.$strict>;
|
|
259
|
+
/** Runtime validator for UpdateObjectInput. */
|
|
260
|
+
declare const UpdateObjectInputSchema: z.ZodObject<{
|
|
261
|
+
objectType: z.ZodString;
|
|
262
|
+
objectId: z.ZodString;
|
|
263
|
+
properties: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
264
|
+
}, z.core.$strict>;
|
|
265
|
+
|
|
266
|
+
/** Typed operations supplied by a client or mock. */
|
|
267
|
+
interface Operations {
|
|
268
|
+
/** Invoke searchObjects through this connection. */
|
|
269
|
+
searchObjects(): Query<SearchObjectsInput, ObjectPage>;
|
|
270
|
+
/** Invoke getObject through this connection. */
|
|
271
|
+
getObject(): Query<GetObjectInput, CRMObject>;
|
|
272
|
+
/** Invoke upsertObject through this connection. */
|
|
273
|
+
upsertObject(): Mutation<UpsertObjectInput, UpsertedObject>;
|
|
274
|
+
/** Invoke updateObject through this connection. */
|
|
275
|
+
updateObject(): Mutation<UpdateObjectInput, CRMObject>;
|
|
276
|
+
}
|
|
277
|
+
/** Named connector connection kept outside Flow state. */
|
|
278
|
+
declare class Connection<BoundOperations = Operations> {
|
|
279
|
+
/** Stable provider and connection name. */
|
|
280
|
+
readonly reference: ConnectionRef;
|
|
281
|
+
/** Bound provider operations. */
|
|
282
|
+
readonly operations: BoundOperations;
|
|
283
|
+
/** Validate a reference and bind operations. */
|
|
284
|
+
constructor(reference: ConnectionRef, operations: BoundOperations);
|
|
285
|
+
}
|
|
286
|
+
/** Bind a client to a named connection. */
|
|
287
|
+
declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
|
|
288
|
+
/** Bind scripted operations to a named connection. */
|
|
289
|
+
declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
|
|
290
|
+
|
|
291
|
+
export { type CRMObject as C, type GetObjectInput as G, type ObjectPage as O, type SearchObjectsInput as S, type UpdateObjectInput as U, Connection as a, type UpsertObjectInput as b, type UpsertedObject as c, type Config as d, type CredentialSource as e, type Operations as f, CRMObjectSchema as g, ConfigSchema as h, type Credentials as i, GetObjectInputSchema as j, ObjectPageSchema as k, type SearchFilter as l, type SearchFilterGroup as m, SearchFilterGroupSchema as n, SearchFilterSchema as o, SearchObjectsInputSchema as p, type SearchSort as q, SearchSortSchema as r, UpdateObjectInputSchema as s, UpsertObjectInputSchema as t, UpsertedObjectSchema as u, decodeCredentials as v, decodeSharedCredentials as w, newConnection as x, newConnectionWithOperations as y };
|