@delofarag/crm-utils 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/README.md +151 -0
- package/dist/BaseCrm.d.ts +37 -0
- package/dist/BaseCrm.d.ts.map +1 -0
- package/dist/BaseCrm.js +3 -0
- package/dist/BaseCrm.js.map +1 -0
- package/dist/CRM.d.ts +37 -0
- package/dist/CRM.d.ts.map +1 -0
- package/dist/CRM.js +3 -0
- package/dist/CRM.js.map +1 -0
- package/dist/CrmConnection.d.ts +4 -0
- package/dist/CrmConnection.d.ts.map +1 -0
- package/dist/CrmConnection.js +3 -0
- package/dist/CrmConnection.js.map +1 -0
- package/dist/crms/hubspot/hubspot.d.ts +183 -0
- package/dist/crms/hubspot/hubspot.d.ts.map +1 -0
- package/dist/crms/hubspot/hubspot.js +349 -0
- package/dist/crms/hubspot/hubspot.js.map +1 -0
- package/dist/crms/hubspot/types.d.ts +52 -0
- package/dist/crms/hubspot/types.d.ts.map +1 -0
- package/dist/crms/hubspot/types.js +18 -0
- package/dist/crms/hubspot/types.js.map +1 -0
- package/dist/crms/hubspot.d.ts +108 -0
- package/dist/crms/hubspot.d.ts.map +1 -0
- package/dist/crms/hubspot.js +254 -0
- package/dist/crms/hubspot.js.map +1 -0
- package/dist/getCRM.d.ts +15 -0
- package/dist/getCRM.d.ts.map +1 -0
- package/dist/getCRM.js +13 -0
- package/dist/getCRM.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/oauth-helpers.d.ts +5 -0
- package/dist/oauth-helpers.d.ts.map +1 -0
- package/dist/oauth-helpers.js +21 -0
- package/dist/oauth-helpers.js.map +1 -0
- package/dist/types.d.ts +24 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +26 -0
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import CRM from "../../CRM";
|
|
2
|
+
import CrmConnection from "../../CrmConnection";
|
|
3
|
+
import { buildQueryString, postFormUrlEncoded, randomState, toExpiresAt } from "../../oauth-helpers";
|
|
4
|
+
import { HubspotAccessTokenMetadataSchema, HubspotTokenResponseSchema } from "./types";
|
|
5
|
+
const HUBSPOT_AUTHORIZE = "https://app.hubspot.com/oauth/authorize";
|
|
6
|
+
const HUBSPOT_TOKEN = "https://api.hubapi.com/oauth/v1/token";
|
|
7
|
+
const HUBSPOT_API = "https://api.hubapi.com";
|
|
8
|
+
export class HubspotConnection extends CrmConnection {
|
|
9
|
+
provider = "hubspot";
|
|
10
|
+
clientId;
|
|
11
|
+
redirectUri;
|
|
12
|
+
constructor(args) {
|
|
13
|
+
super();
|
|
14
|
+
this.clientId = args.clientId;
|
|
15
|
+
this.redirectUri = args.redirectUri;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* OAuth-Start: Authorize-URL + state.
|
|
19
|
+
*
|
|
20
|
+
* frontend && server
|
|
21
|
+
*/
|
|
22
|
+
async buildAuthUrl(args) {
|
|
23
|
+
const state = randomState();
|
|
24
|
+
const qs = buildQueryString({
|
|
25
|
+
client_id: this.clientId,
|
|
26
|
+
redirect_uri: this.redirectUri,
|
|
27
|
+
scope: args.scopes.join(" "),
|
|
28
|
+
state,
|
|
29
|
+
});
|
|
30
|
+
const authorizeUrl = `${HUBSPOT_AUTHORIZE}?${qs}`;
|
|
31
|
+
if (args.supabase_id) {
|
|
32
|
+
const tokenStore = {
|
|
33
|
+
state,
|
|
34
|
+
provider: this.provider,
|
|
35
|
+
id: args.supabase_id,
|
|
36
|
+
token_last_refreshed_at: new Date(),
|
|
37
|
+
};
|
|
38
|
+
return { authorizeUrl, tokenStore, state };
|
|
39
|
+
}
|
|
40
|
+
return { authorizeUrl, state };
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Callback: code → Tokens.
|
|
44
|
+
*
|
|
45
|
+
* server-only
|
|
46
|
+
*/
|
|
47
|
+
async codeToTokens(clientSecret, args) {
|
|
48
|
+
const res = await postFormUrlEncoded(HUBSPOT_TOKEN, {
|
|
49
|
+
grant_type: "authorization_code",
|
|
50
|
+
client_id: this.clientId,
|
|
51
|
+
client_secret: clientSecret,
|
|
52
|
+
redirect_uri: this.redirectUri,
|
|
53
|
+
code: args.code,
|
|
54
|
+
});
|
|
55
|
+
const text = await res.text();
|
|
56
|
+
if (!res.ok) {
|
|
57
|
+
throw new Error(`HubSpot token exchange failed: ${res.status} ${text}`);
|
|
58
|
+
}
|
|
59
|
+
const parsedRaw = HubspotTokenResponseSchema.safeParse(JSON.parse(text));
|
|
60
|
+
if (!parsedRaw.success) {
|
|
61
|
+
throw new Error(`HubSpot token exchange returned unexpected JSON: ${parsedRaw.error.message}`);
|
|
62
|
+
}
|
|
63
|
+
const raw = parsedRaw.data;
|
|
64
|
+
const token_expires_at = toExpiresAt(raw.expires_in);
|
|
65
|
+
let portalId;
|
|
66
|
+
let meta;
|
|
67
|
+
if (raw.access_token) {
|
|
68
|
+
try {
|
|
69
|
+
meta = await this.fetchAccessTokenMetadata(raw.access_token);
|
|
70
|
+
portalId = meta.hub_id;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
portalId = undefined;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (args.supabase_id) {
|
|
77
|
+
const tokenStore = {
|
|
78
|
+
provider: this.provider,
|
|
79
|
+
id: args.supabase_id,
|
|
80
|
+
access_token: raw.access_token,
|
|
81
|
+
refresh_token: raw.refresh_token ?? null,
|
|
82
|
+
token_expires_at,
|
|
83
|
+
token_last_refreshed_at: new Date(),
|
|
84
|
+
provider_account_id: portalId != null ? String(portalId) : undefined,
|
|
85
|
+
};
|
|
86
|
+
return { raw, tokenStore, portalId };
|
|
87
|
+
}
|
|
88
|
+
return { raw, portalId };
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Refresh: refresh_token → new access_token.
|
|
92
|
+
*
|
|
93
|
+
* server-only
|
|
94
|
+
*/
|
|
95
|
+
async refreshAccessToken(clientSecret, args) {
|
|
96
|
+
const res = await postFormUrlEncoded(HUBSPOT_TOKEN, {
|
|
97
|
+
grant_type: "refresh_token",
|
|
98
|
+
client_id: this.clientId,
|
|
99
|
+
client_secret: clientSecret,
|
|
100
|
+
refresh_token: args.refreshToken,
|
|
101
|
+
});
|
|
102
|
+
const text = await res.text();
|
|
103
|
+
if (!res.ok) {
|
|
104
|
+
throw new Error(`HubSpot refresh failed: ${res.status} ${text}`);
|
|
105
|
+
}
|
|
106
|
+
const parsedRaw = HubspotTokenResponseSchema.safeParse(JSON.parse(text));
|
|
107
|
+
if (!parsedRaw.success) {
|
|
108
|
+
throw new Error(`HubSpot refresh returned unexpected JSON: ${parsedRaw.error.message}`);
|
|
109
|
+
}
|
|
110
|
+
const raw = parsedRaw.data;
|
|
111
|
+
const token_expires_at = toExpiresAt(raw.expires_in);
|
|
112
|
+
const tokenStore = {
|
|
113
|
+
provider: this.provider,
|
|
114
|
+
access_token: raw.access_token,
|
|
115
|
+
refresh_token: raw.refresh_token ?? args.refreshToken,
|
|
116
|
+
token_expires_at,
|
|
117
|
+
token_last_refreshed_at: new Date(),
|
|
118
|
+
};
|
|
119
|
+
return { raw, tokenStore };
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* HubSpot: GET /oauth/v1/access-tokens/{token} — u.a. hub_id (Portal).
|
|
123
|
+
*
|
|
124
|
+
* frontend && server
|
|
125
|
+
*/
|
|
126
|
+
async fetchAccessTokenMetadata(accessToken) {
|
|
127
|
+
const r = await fetch(`${HUBSPOT_API}/oauth/v1/access-tokens/${encodeURIComponent(accessToken)}`);
|
|
128
|
+
const text = await r.text();
|
|
129
|
+
if (!r.ok) {
|
|
130
|
+
throw new Error(`HubSpot access-token metadata failed: ${r.status} ${text}`);
|
|
131
|
+
}
|
|
132
|
+
const parsedMeta = HubspotAccessTokenMetadataSchema.safeParse(JSON.parse(text));
|
|
133
|
+
if (!parsedMeta.success) {
|
|
134
|
+
throw new Error(`HubSpot access-token metadata returned unexpected JSON: ${parsedMeta.error.message}`);
|
|
135
|
+
}
|
|
136
|
+
return parsedMeta.data;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Hilfe: gültigen Access Token — entweder aus tokenStore oder nach Refresh.
|
|
140
|
+
*
|
|
141
|
+
* server-only
|
|
142
|
+
*/
|
|
143
|
+
async getValidAccessToken(clientSecret, args) {
|
|
144
|
+
const skew = args.skewMs ?? 60_000;
|
|
145
|
+
const exp = args.expiresAt instanceof Date
|
|
146
|
+
? args.expiresAt.getTime()
|
|
147
|
+
: args.expiresAt
|
|
148
|
+
? new Date(args.expiresAt).getTime()
|
|
149
|
+
: null;
|
|
150
|
+
if (args.accessToken && (exp == null || !Number.isFinite(exp) || exp > Date.now() + skew)) {
|
|
151
|
+
return args.accessToken;
|
|
152
|
+
}
|
|
153
|
+
if (!args.refreshToken) {
|
|
154
|
+
throw new Error("HubSpot: no valid access token and no refresh token");
|
|
155
|
+
}
|
|
156
|
+
const { tokenStore } = await this.refreshAccessToken(clientSecret, {
|
|
157
|
+
refreshToken: args.refreshToken,
|
|
158
|
+
});
|
|
159
|
+
if (!tokenStore.access_token) {
|
|
160
|
+
throw new Error("HubSpot refresh returned no access_token");
|
|
161
|
+
}
|
|
162
|
+
return tokenStore.access_token;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Kleiner HTTP-Wrapper für HubSpot:
|
|
167
|
+
* - setzt `Authorization: Bearer <token>`
|
|
168
|
+
* - JSON encoden/decoden
|
|
169
|
+
* - wirft bei non-2xx einen Error mit Response-Text
|
|
170
|
+
*
|
|
171
|
+
* frontend && server (aber: accessToken ist ein Secret → in der Praxis meistens server-only)
|
|
172
|
+
*/
|
|
173
|
+
async function hubspotFetchJson(path, options) {
|
|
174
|
+
const method = options.method ?? "GET";
|
|
175
|
+
const headers = {
|
|
176
|
+
Authorization: `Bearer ${options.accessToken}`,
|
|
177
|
+
Accept: "application/json",
|
|
178
|
+
};
|
|
179
|
+
let body;
|
|
180
|
+
if (options.body !== undefined) {
|
|
181
|
+
headers["Content-Type"] = "application/json";
|
|
182
|
+
body = JSON.stringify(options.body);
|
|
183
|
+
}
|
|
184
|
+
const r = await fetch(`${HUBSPOT_API}${path}`, { method, headers, body });
|
|
185
|
+
const text = await r.text();
|
|
186
|
+
if (!r.ok) {
|
|
187
|
+
throw new Error(`HubSpot API ${method} ${path}: ${r.status} ${text}`);
|
|
188
|
+
}
|
|
189
|
+
return text ? JSON.parse(text) : null;
|
|
190
|
+
}
|
|
191
|
+
export class Hubspot extends CRM {
|
|
192
|
+
provider = "hubspot";
|
|
193
|
+
connection;
|
|
194
|
+
constructor({ clientId, redirectUri }) {
|
|
195
|
+
super();
|
|
196
|
+
this.connection = new HubspotConnection({ clientId, redirectUri });
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Holt eine Seite von HubSpot Contacts.
|
|
200
|
+
*
|
|
201
|
+
* - `limit`: wie viele Contacts du pro Request willst (Pagination Page Size)
|
|
202
|
+
* - `after`: Cursor für die nächste Seite (kommt typischerweise aus `paging.next.after`)
|
|
203
|
+
*
|
|
204
|
+
* Typical use: UI-Liste anzeigen oder initial Candidates laden.
|
|
205
|
+
*
|
|
206
|
+
* server-only (weil `accessToken` ein Secret ist)
|
|
207
|
+
*/
|
|
208
|
+
async getContacts(options) {
|
|
209
|
+
const limit = options.limit ?? 10;
|
|
210
|
+
const params = new URLSearchParams({ limit: String(limit) });
|
|
211
|
+
if (options.after) {
|
|
212
|
+
params.set("after", options.after);
|
|
213
|
+
}
|
|
214
|
+
return hubspotFetchJson(`/crm/v3/objects/contacts?${params.toString()}`, {
|
|
215
|
+
accessToken: options.accessToken,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Holt eine Seite von HubSpot Companies.
|
|
220
|
+
*
|
|
221
|
+
* - `limit`: wie viele Companies pro Request
|
|
222
|
+
* - `after`: Cursor für die nächste Seite
|
|
223
|
+
*
|
|
224
|
+
* server-only (weil `accessToken` ein Secret ist)
|
|
225
|
+
*/
|
|
226
|
+
async getCompanies(options) {
|
|
227
|
+
const limit = options.limit ?? 10;
|
|
228
|
+
const params = new URLSearchParams({ limit: String(limit) });
|
|
229
|
+
if (options.after) {
|
|
230
|
+
params.set("after", options.after);
|
|
231
|
+
}
|
|
232
|
+
return hubspotFetchJson(`/crm/v3/objects/companies?${params.toString()}`, {
|
|
233
|
+
accessToken: options.accessToken,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Erstellt einen neuen Contact.
|
|
238
|
+
*
|
|
239
|
+
* `properties` sind HubSpot-Property-Namen → Values. Beispiel: `{ email: \"a@b.com\", firstname: \"Max\" }`.
|
|
240
|
+
*
|
|
241
|
+
* server-only (weil `accessToken` ein Secret ist)
|
|
242
|
+
*/
|
|
243
|
+
async createContact(options) {
|
|
244
|
+
return hubspotFetchJson("/crm/v3/objects/contacts", {
|
|
245
|
+
accessToken: options.accessToken,
|
|
246
|
+
method: "POST",
|
|
247
|
+
body: { properties: options.properties },
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Updated einen bestehenden Contact (PATCH).
|
|
252
|
+
*
|
|
253
|
+
* - `id`: HubSpot Contact ID
|
|
254
|
+
* - `properties`: Partial Update (nur die Felder, die du ändern willst)
|
|
255
|
+
*
|
|
256
|
+
* Typical use: nach AI-Screening `status`, `ai_score`, `ai_summary` etc. zurückschreiben.
|
|
257
|
+
*
|
|
258
|
+
* server-only (weil `accessToken` ein Secret ist)
|
|
259
|
+
*/
|
|
260
|
+
async updateContact(options) {
|
|
261
|
+
return hubspotFetchJson(`/crm/v3/objects/contacts/${encodeURIComponent(options.id)}`, {
|
|
262
|
+
accessToken: options.accessToken,
|
|
263
|
+
method: "PATCH",
|
|
264
|
+
body: { properties: options.properties },
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Erstellt eine Note (Timeline/History Eintrag) und hängt sie an ein Objekt (Contact/Company/Deal).
|
|
269
|
+
*
|
|
270
|
+
* Notes sind super, um Ergebnisse „auditierbar“ abzulegen (was hat die AI gemacht / was kam beim Call raus),
|
|
271
|
+
* ohne dass du zig neue Custom Properties brauchst.
|
|
272
|
+
*
|
|
273
|
+
* - `body`: Text/HTML Inhalt der Note (HubSpot Property: `hs_note_body`)
|
|
274
|
+
* - `associateToObjectType`: z.B. `contact`, `company`, `deal`
|
|
275
|
+
* - `associateToId`: ID des Ziel-Objekts in HubSpot
|
|
276
|
+
*
|
|
277
|
+
* server-only (weil `accessToken` ein Secret ist)
|
|
278
|
+
*/
|
|
279
|
+
async createNote(options) {
|
|
280
|
+
return hubspotFetchJson("/crm/v3/objects/notes", {
|
|
281
|
+
accessToken: options.accessToken,
|
|
282
|
+
method: "POST",
|
|
283
|
+
body: {
|
|
284
|
+
properties: { hs_note_body: options.body },
|
|
285
|
+
associations: [
|
|
286
|
+
{
|
|
287
|
+
to: { id: options.associateToId },
|
|
288
|
+
types: [
|
|
289
|
+
{
|
|
290
|
+
associationCategory: "HUBSPOT_DEFINED",
|
|
291
|
+
associationTypeId: noteAssociationTypeId(options.associateToObjectType),
|
|
292
|
+
},
|
|
293
|
+
],
|
|
294
|
+
},
|
|
295
|
+
],
|
|
296
|
+
},
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Generische Suche über HubSpot-Objekte (contacts/companies/deals/custom objects).
|
|
301
|
+
*
|
|
302
|
+
* Im Gegensatz zu `getContacts()` (nur Listen) kannst du hier **Filter** angeben.
|
|
303
|
+
*
|
|
304
|
+
* - `objectType`: z.B. `contacts`, `companies`, `deals`
|
|
305
|
+
* - `filterGroups`: HubSpot Search-Filter (Raw-Shape; du gibst das HubSpot-Format direkt rein)
|
|
306
|
+
* - `properties`: welche Properties du zurückhaben willst
|
|
307
|
+
* - `limit`/`after`: Pagination
|
|
308
|
+
*
|
|
309
|
+
* Typical use: „gib mir alle Kandidaten mit status = X“ ohne alles zu laden.
|
|
310
|
+
*
|
|
311
|
+
* server-only (weil `accessToken` ein Secret ist)
|
|
312
|
+
*/
|
|
313
|
+
async searchRecords(options) {
|
|
314
|
+
const limit = options.limit ?? 10;
|
|
315
|
+
const body = { limit };
|
|
316
|
+
if (options.filterGroups) {
|
|
317
|
+
body.filterGroups = options.filterGroups;
|
|
318
|
+
}
|
|
319
|
+
if (options.properties) {
|
|
320
|
+
body.properties = options.properties;
|
|
321
|
+
}
|
|
322
|
+
if (options.after) {
|
|
323
|
+
body.after = options.after;
|
|
324
|
+
}
|
|
325
|
+
return hubspotFetchJson(`/crm/v3/objects/${encodeURIComponent(options.objectType)}/search`, {
|
|
326
|
+
accessToken: options.accessToken,
|
|
327
|
+
method: "POST",
|
|
328
|
+
body,
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* HubSpot association type ids (HUBSPOT_DEFINED) — notes to common objects.
|
|
334
|
+
* @see https://developers.hubspot.com/docs/api/crm/associations
|
|
335
|
+
*/
|
|
336
|
+
function noteAssociationTypeId(associateToObjectType) {
|
|
337
|
+
const t = associateToObjectType.toLowerCase();
|
|
338
|
+
if (t === "contacts" || t === "contact") {
|
|
339
|
+
return 202;
|
|
340
|
+
}
|
|
341
|
+
if (t === "companies" || t === "company") {
|
|
342
|
+
return 190;
|
|
343
|
+
}
|
|
344
|
+
if (t === "deals" || t === "deal") {
|
|
345
|
+
return 214;
|
|
346
|
+
}
|
|
347
|
+
throw new Error(`HubSpot: unsupported note association object type: ${associateToObjectType}`);
|
|
348
|
+
}
|
|
349
|
+
//# sourceMappingURL=hubspot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hubspot.js","sourceRoot":"","sources":["../../../src/crms/hubspot/hubspot.ts"],"names":[],"m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IAC7C,IAAI,CAAC,KAAK,UAAU,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO,GAAG,CAAA;IACd,CAAC;IACD,IAAI,CAAC,KAAK,WAAW,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;QACvC,OAAO,GAAG,CAAA;IACd,CAAC;IACD,IAAI,CAAC,KAAK,OAAO,IAAI,CAAC,KAAK,MAAM,EAAE,CAAC;QAChC,OAAO,GAAG,CAAA;IACd,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,sDAAsD,qBAAqB,EAAE,CAAC,CAAA;AAClG,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const HubspotTokenResponseSchema: z.ZodObject<{
|
|
3
|
+
access_token: z.ZodString;
|
|
4
|
+
refresh_token: z.ZodOptional<z.ZodString>;
|
|
5
|
+
expires_in: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
token_type: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
access_token: string;
|
|
9
|
+
refresh_token?: string | undefined;
|
|
10
|
+
expires_in?: number | undefined;
|
|
11
|
+
token_type?: string | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
access_token: string;
|
|
14
|
+
refresh_token?: string | undefined;
|
|
15
|
+
expires_in?: number | undefined;
|
|
16
|
+
token_type?: string | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
export type HubspotTokenResponse = z.infer<typeof HubspotTokenResponseSchema>;
|
|
19
|
+
export declare const HubspotAccessTokenMetadataSchema: z.ZodObject<{
|
|
20
|
+
hub_id: z.ZodOptional<z.ZodNumber>;
|
|
21
|
+
user_id: z.ZodOptional<z.ZodNumber>;
|
|
22
|
+
app_id: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
hub_domain: z.ZodOptional<z.ZodString>;
|
|
24
|
+
scopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
25
|
+
token: z.ZodOptional<z.ZodString>;
|
|
26
|
+
user: z.ZodOptional<z.ZodString>;
|
|
27
|
+
hub_id_string: z.ZodOptional<z.ZodString>;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
hub_id?: number | undefined;
|
|
30
|
+
user_id?: number | undefined;
|
|
31
|
+
app_id?: number | undefined;
|
|
32
|
+
hub_domain?: string | undefined;
|
|
33
|
+
scopes?: string[] | undefined;
|
|
34
|
+
token?: string | undefined;
|
|
35
|
+
user?: string | undefined;
|
|
36
|
+
hub_id_string?: string | undefined;
|
|
37
|
+
}, {
|
|
38
|
+
hub_id?: number | undefined;
|
|
39
|
+
user_id?: number | undefined;
|
|
40
|
+
app_id?: number | undefined;
|
|
41
|
+
hub_domain?: string | undefined;
|
|
42
|
+
scopes?: string[] | undefined;
|
|
43
|
+
token?: string | undefined;
|
|
44
|
+
user?: string | undefined;
|
|
45
|
+
hub_id_string?: string | undefined;
|
|
46
|
+
}>;
|
|
47
|
+
export type HubspotAccessTokenMetadata = z.infer<typeof HubspotAccessTokenMetadataSchema>;
|
|
48
|
+
export type HubspotInit = {
|
|
49
|
+
clientId: string;
|
|
50
|
+
redirectUri: string;
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/crms/hubspot/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;EAKrC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAE7E,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS3C,CAAA;AAEF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAA;AAEzF,MAAM,MAAM,WAAW,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;CACtB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const HubspotTokenResponseSchema = z.object({
|
|
3
|
+
access_token: z.string(),
|
|
4
|
+
refresh_token: z.string().optional(),
|
|
5
|
+
expires_in: z.number().optional(),
|
|
6
|
+
token_type: z.string().optional(),
|
|
7
|
+
});
|
|
8
|
+
export const HubspotAccessTokenMetadataSchema = z.object({
|
|
9
|
+
hub_id: z.number().optional(),
|
|
10
|
+
user_id: z.number().optional(),
|
|
11
|
+
app_id: z.number().optional(),
|
|
12
|
+
hub_domain: z.string().optional(),
|
|
13
|
+
scopes: z.array(z.string()).optional(),
|
|
14
|
+
token: z.string().optional(),
|
|
15
|
+
user: z.string().optional(),
|
|
16
|
+
hub_id_string: z.string().optional(),
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/crms/hubspot/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;IACxB,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACpC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACpC,CAAC,CAAA;AAIF,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC;IACrD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACtC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACvC,CAAC,CAAA"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import CRM from "../CRM";
|
|
2
|
+
import CrmConnection from "../CrmConnection";
|
|
3
|
+
import type { HubspotAccessTokenMetadata, HubspotTokenResponse, TokenStore } from "../types";
|
|
4
|
+
export declare class HubspotConnection extends CrmConnection {
|
|
5
|
+
readonly provider: "hubspot";
|
|
6
|
+
/**
|
|
7
|
+
* OAuth-Start: Authorize-URL + state. Optional onPersistState für DB (z.B. Pending-Row).
|
|
8
|
+
*/
|
|
9
|
+
buildAuthorizeUrl(args: {
|
|
10
|
+
clientId: string;
|
|
11
|
+
redirectUri: string;
|
|
12
|
+
scopes: string[];
|
|
13
|
+
state?: string;
|
|
14
|
+
workspace_id?: string;
|
|
15
|
+
supabase_user_id?: string;
|
|
16
|
+
connected_by_user_id?: string;
|
|
17
|
+
onPersistState?: (data: TokenStore) => void | Promise<void>;
|
|
18
|
+
}): Promise<{
|
|
19
|
+
authorizeUrl: string;
|
|
20
|
+
state: string;
|
|
21
|
+
tokenStore: TokenStore;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Callback: code → Tokens. Optional onPersistTokens nach erfolgreichem Exchange.
|
|
25
|
+
*/
|
|
26
|
+
exchangeAuthorizationCode(args: {
|
|
27
|
+
code: string;
|
|
28
|
+
clientId: string;
|
|
29
|
+
clientSecret: string;
|
|
30
|
+
redirectUri: string;
|
|
31
|
+
workspace_id?: string;
|
|
32
|
+
supabase_user_id?: string;
|
|
33
|
+
connected_by_user_id?: string;
|
|
34
|
+
onPersistTokens?: (data: TokenStore) => void | Promise<void>;
|
|
35
|
+
}): Promise<{
|
|
36
|
+
raw: HubspotTokenResponse;
|
|
37
|
+
tokenStore: TokenStore;
|
|
38
|
+
portalId: number | undefined;
|
|
39
|
+
}>;
|
|
40
|
+
refreshAccessToken(args: {
|
|
41
|
+
refreshToken: string;
|
|
42
|
+
clientId: string;
|
|
43
|
+
clientSecret: string;
|
|
44
|
+
workspace_id?: string;
|
|
45
|
+
onPersistTokens?: (data: TokenStore) => void | Promise<void>;
|
|
46
|
+
}): Promise<{
|
|
47
|
+
raw: HubspotTokenResponse;
|
|
48
|
+
tokenStore: TokenStore;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* HubSpot: GET /oauth/v1/access-tokens/{token} — u.a. hub_id (Portal).
|
|
52
|
+
*/
|
|
53
|
+
fetchAccessTokenMetadata(accessToken: string): Promise<HubspotAccessTokenMetadata>;
|
|
54
|
+
/**
|
|
55
|
+
* Hilfe: gültigen Access Token — entweder aus tokenStore oder nach Refresh.
|
|
56
|
+
* Optional onPersistTokens wenn refresht.
|
|
57
|
+
*/
|
|
58
|
+
getValidAccessToken(args: {
|
|
59
|
+
accessToken?: string | undefined;
|
|
60
|
+
expiresAt?: Date | string | null;
|
|
61
|
+
refreshToken?: string | null;
|
|
62
|
+
clientId: string;
|
|
63
|
+
clientSecret: string;
|
|
64
|
+
workspace_id?: string;
|
|
65
|
+
skewMs?: number;
|
|
66
|
+
onPersistTokens?: (data: TokenStore) => void | Promise<void>;
|
|
67
|
+
}): Promise<string>;
|
|
68
|
+
}
|
|
69
|
+
export declare class Hubspot extends CRM {
|
|
70
|
+
readonly provider: "hubspot";
|
|
71
|
+
connection: HubspotConnection;
|
|
72
|
+
constructor();
|
|
73
|
+
getContacts(options: {
|
|
74
|
+
accessToken: string;
|
|
75
|
+
limit?: number;
|
|
76
|
+
after?: string;
|
|
77
|
+
}): Promise<unknown>;
|
|
78
|
+
getCompanies(options: {
|
|
79
|
+
accessToken: string;
|
|
80
|
+
limit?: number;
|
|
81
|
+
after?: string;
|
|
82
|
+
}): Promise<unknown>;
|
|
83
|
+
createContact(options: {
|
|
84
|
+
accessToken: string;
|
|
85
|
+
properties: Record<string, string | number | boolean | null>;
|
|
86
|
+
}): Promise<unknown>;
|
|
87
|
+
updateContact(options: {
|
|
88
|
+
accessToken: string;
|
|
89
|
+
id: string;
|
|
90
|
+
properties: Record<string, string | number | boolean | null>;
|
|
91
|
+
}): Promise<unknown>;
|
|
92
|
+
createNote(options: {
|
|
93
|
+
accessToken: string;
|
|
94
|
+
body: string;
|
|
95
|
+
associateToObjectType: string;
|
|
96
|
+
associateToId: string;
|
|
97
|
+
}): Promise<unknown>;
|
|
98
|
+
searchRecords(options: {
|
|
99
|
+
accessToken: string;
|
|
100
|
+
objectType: string;
|
|
101
|
+
filterGroups?: unknown[];
|
|
102
|
+
properties?: string[];
|
|
103
|
+
limit?: number;
|
|
104
|
+
after?: string;
|
|
105
|
+
}): Promise<unknown>;
|
|
106
|
+
}
|
|
107
|
+
export declare const hubspot: Hubspot;
|
|
108
|
+
//# sourceMappingURL=hubspot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hubspot.d.ts","sourceRoot":"","sources":["../../src/crms/hubspot.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,QAAQ,CAAA;AACxB,OAAO,aAAa,MAAM,kBAAkB,CAAA;AAE5C,OAAO,KAAK,EACR,0BAA0B,EAC1B,oBAAoB,EACpB,UAAU,EACb,MAAM,UAAU,CAAA;AAMjB,qBAAa,iBAAkB,SAAQ,aAAa;IAChD,QA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