@livechat/developer-studio-api 3.1.27 → 3.1.29
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/index.d.mts +171 -40
- package/dist/index.d.ts +171 -40
- package/dist/index.js +210 -99
- package/dist/index.mjs +209 -98
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -76,6 +76,7 @@ __export(src_exports, {
|
|
|
76
76
|
BigCommerceEventNames: () => BigCommerceEventNames,
|
|
77
77
|
BigCommerceWebhookScopes: () => BigCommerceWebhookScopes,
|
|
78
78
|
DpsApiError: () => DpsApiError,
|
|
79
|
+
HubSpotWebhookEventTypes: () => HubSpotWebhookEventTypes,
|
|
79
80
|
HubspotApiError: () => HubspotApiError,
|
|
80
81
|
HubspotEventNames: () => HubspotEventNames,
|
|
81
82
|
IntegrationModes: () => IntegrationModes,
|
|
@@ -143,7 +144,6 @@ __export(src_exports, {
|
|
|
143
144
|
getVercelClientConfig: () => getVercelClientConfig,
|
|
144
145
|
githubClientInstance: () => githubClientInstance,
|
|
145
146
|
hubspotClientInstance: () => hubspotClientInstance,
|
|
146
|
-
hubspotClientUrl: () => hubspotClientUrl,
|
|
147
147
|
hubspotEventsZods: () => hubspotEventsZods,
|
|
148
148
|
initApi: () => initApi,
|
|
149
149
|
initBigCommerceClient: () => initBigCommerceClient,
|
|
@@ -2158,9 +2158,13 @@ var textPlatformWorkflowsApi = {
|
|
|
2158
2158
|
return __async(this, null, function* () {
|
|
2159
2159
|
yield textClientInstance.delete(
|
|
2160
2160
|
`/workflow_platform/workflows/${encodeURIComponent(payload.name)}`,
|
|
2161
|
-
getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
2161
|
+
__spreadProps(__spreadValues({}, getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
2162
2162
|
ensureAuthorizationToken: true
|
|
2163
|
-
}))
|
|
2163
|
+
}))), {
|
|
2164
|
+
data: {
|
|
2165
|
+
third_party_headers: payload.third_party_headers
|
|
2166
|
+
}
|
|
2167
|
+
})
|
|
2164
2168
|
);
|
|
2165
2169
|
});
|
|
2166
2170
|
},
|
|
@@ -3221,9 +3225,184 @@ var shopifyApi = {
|
|
|
3221
3225
|
}
|
|
3222
3226
|
};
|
|
3223
3227
|
|
|
3224
|
-
// src/apis/integrations/hubspot/
|
|
3228
|
+
// src/apis/integrations/hubspot/instance.ts
|
|
3225
3229
|
var import_axios18 = __toESM(require("axios"));
|
|
3230
|
+
var HubspotApiError = class extends ApiErrorBase {
|
|
3231
|
+
constructor() {
|
|
3232
|
+
super(...arguments);
|
|
3233
|
+
this.name = "hubspot";
|
|
3234
|
+
}
|
|
3235
|
+
};
|
|
3236
|
+
var hubspotClientInstance = import_axios18.default.create({
|
|
3237
|
+
baseURL: `https://api.hubapi.com`,
|
|
3238
|
+
headers: {
|
|
3239
|
+
"Content-Type": "application/json"
|
|
3240
|
+
}
|
|
3241
|
+
});
|
|
3242
|
+
hubspotClientInstance.interceptors.response.use(
|
|
3243
|
+
(r) => r,
|
|
3244
|
+
(error) => {
|
|
3245
|
+
var _a, _b, _c, _d;
|
|
3246
|
+
if (import_axios18.default.isAxiosError(error)) {
|
|
3247
|
+
if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
|
|
3248
|
+
throw new UnauthorizeApiError("hubspot");
|
|
3249
|
+
}
|
|
3250
|
+
}
|
|
3251
|
+
return Promise.reject(
|
|
3252
|
+
new HubspotApiError(
|
|
3253
|
+
error.message,
|
|
3254
|
+
(_b = error.response) == null ? void 0 : _b.data,
|
|
3255
|
+
(_d = (_c = error.response) == null ? void 0 : _c.status) != null ? _d : 400
|
|
3256
|
+
)
|
|
3257
|
+
);
|
|
3258
|
+
}
|
|
3259
|
+
);
|
|
3260
|
+
function getHubspotClientAuthorization(req) {
|
|
3261
|
+
if (req.headers instanceof Headers) {
|
|
3262
|
+
return {
|
|
3263
|
+
token: req.headers.get("x-adapter-hubspot-token")
|
|
3264
|
+
};
|
|
3265
|
+
}
|
|
3266
|
+
return {
|
|
3267
|
+
token: req.headers["x-adapter-hubspot-token"]
|
|
3268
|
+
};
|
|
3269
|
+
}
|
|
3270
|
+
function getHubspotClientConfig(options = {}) {
|
|
3271
|
+
var _a;
|
|
3272
|
+
const currentHeaders = hubspotClientInstance.defaults.headers;
|
|
3273
|
+
const config = {
|
|
3274
|
+
authorization: (_a = options.token ? `Bearer ${options.token}` : void 0) != null ? _a : currentHeaders.Authorization
|
|
3275
|
+
};
|
|
3276
|
+
if (options.ensureAuthorizationToken && !config.authorization) {
|
|
3277
|
+
throw new UnauthorizeApiError("hubspot");
|
|
3278
|
+
}
|
|
3279
|
+
return {
|
|
3280
|
+
headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
|
|
3281
|
+
};
|
|
3282
|
+
}
|
|
3283
|
+
function initHubspotClient(token) {
|
|
3284
|
+
if (token) {
|
|
3285
|
+
updateHubspotClient(token);
|
|
3286
|
+
}
|
|
3287
|
+
}
|
|
3288
|
+
function updateHubspotClient(token) {
|
|
3289
|
+
const defaults = hubspotClientInstance.defaults;
|
|
3290
|
+
const headers = defaults.headers;
|
|
3291
|
+
if (token) {
|
|
3292
|
+
headers.Authorization = `Bearer ${token}`;
|
|
3293
|
+
} else {
|
|
3294
|
+
delete headers.Authorization;
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
|
|
3298
|
+
// src/apis/integrations/hubspot/webhooks/api.ts
|
|
3299
|
+
var hubspotWebhooksApi = {
|
|
3300
|
+
settings: {
|
|
3301
|
+
get(appId, authorization) {
|
|
3302
|
+
return __async(this, null, function* () {
|
|
3303
|
+
const params = new URLSearchParams(
|
|
3304
|
+
(authorization == null ? void 0 : authorization.apiKey) ? {
|
|
3305
|
+
hapikey: authorization.apiKey
|
|
3306
|
+
} : {}
|
|
3307
|
+
);
|
|
3308
|
+
return hubspotClientInstance.get(
|
|
3309
|
+
`/webhooks/v1/${encodeURIComponent(
|
|
3310
|
+
appId
|
|
3311
|
+
)}/settings?${params.toString()}`
|
|
3312
|
+
// getHubspotClientConfig({
|
|
3313
|
+
// ...authorization,
|
|
3314
|
+
// ensureAuthorizationToken: true,
|
|
3315
|
+
// })
|
|
3316
|
+
).catch((e) => {
|
|
3317
|
+
console.log(e);
|
|
3318
|
+
throw e;
|
|
3319
|
+
});
|
|
3320
|
+
});
|
|
3321
|
+
},
|
|
3322
|
+
update(appId, payload, authorization) {
|
|
3323
|
+
return __async(this, null, function* () {
|
|
3324
|
+
const params = new URLSearchParams(
|
|
3325
|
+
(authorization == null ? void 0 : authorization.apiKey) ? {
|
|
3326
|
+
hapikey: authorization.apiKey
|
|
3327
|
+
} : {}
|
|
3328
|
+
);
|
|
3329
|
+
return hubspotClientInstance.put(
|
|
3330
|
+
`/webhooks/v1/${encodeURIComponent(
|
|
3331
|
+
appId
|
|
3332
|
+
)}/settings?${params.toString()}`,
|
|
3333
|
+
payload
|
|
3334
|
+
// getHubspotClientConfig({
|
|
3335
|
+
// ...authorization,
|
|
3336
|
+
// ensureAuthorizationToken: true,
|
|
3337
|
+
// })
|
|
3338
|
+
);
|
|
3339
|
+
});
|
|
3340
|
+
}
|
|
3341
|
+
},
|
|
3342
|
+
subscriptions: {
|
|
3343
|
+
list(appId, authorization) {
|
|
3344
|
+
return __async(this, null, function* () {
|
|
3345
|
+
const params = new URLSearchParams(
|
|
3346
|
+
(authorization == null ? void 0 : authorization.apiKey) ? {
|
|
3347
|
+
hapikey: authorization.apiKey
|
|
3348
|
+
} : {}
|
|
3349
|
+
);
|
|
3350
|
+
return hubspotClientInstance.get(
|
|
3351
|
+
`/webhooks/v3/${encodeURIComponent(
|
|
3352
|
+
appId
|
|
3353
|
+
)}/subscriptions?${params.toString()}`
|
|
3354
|
+
// getHubspotClientConfig({
|
|
3355
|
+
// ...authorization,
|
|
3356
|
+
// ensureAuthorizationToken: true,
|
|
3357
|
+
// })
|
|
3358
|
+
);
|
|
3359
|
+
});
|
|
3360
|
+
},
|
|
3361
|
+
register(appId, payload, authorization) {
|
|
3362
|
+
return __async(this, null, function* () {
|
|
3363
|
+
const params = new URLSearchParams(
|
|
3364
|
+
(authorization == null ? void 0 : authorization.apiKey) ? {
|
|
3365
|
+
hapikey: authorization.apiKey
|
|
3366
|
+
} : {}
|
|
3367
|
+
);
|
|
3368
|
+
return hubspotClientInstance.post(
|
|
3369
|
+
`/webhooks/v3/${encodeURIComponent(
|
|
3370
|
+
appId
|
|
3371
|
+
)}/subscriptions?${params.toString()}`,
|
|
3372
|
+
payload
|
|
3373
|
+
// getHubspotClientConfig({
|
|
3374
|
+
// ...authorization,
|
|
3375
|
+
// ensureAuthorizationToken: true,
|
|
3376
|
+
// })
|
|
3377
|
+
);
|
|
3378
|
+
});
|
|
3379
|
+
},
|
|
3380
|
+
unregister(appId, subscriptionId, authorization) {
|
|
3381
|
+
return __async(this, null, function* () {
|
|
3382
|
+
const params = new URLSearchParams(
|
|
3383
|
+
(authorization == null ? void 0 : authorization.apiKey) ? {
|
|
3384
|
+
hapikey: authorization.apiKey
|
|
3385
|
+
} : {}
|
|
3386
|
+
);
|
|
3387
|
+
return hubspotClientInstance.delete(
|
|
3388
|
+
`/webhooks/v3/${encodeURIComponent(
|
|
3389
|
+
appId
|
|
3390
|
+
)}/subscriptions/${encodeURIComponent(
|
|
3391
|
+
subscriptionId
|
|
3392
|
+
)}?${params.toString()}`
|
|
3393
|
+
// getHubspotClientConfig({
|
|
3394
|
+
// ...authorization,
|
|
3395
|
+
// ensureAuthorizationToken: true,
|
|
3396
|
+
// })
|
|
3397
|
+
);
|
|
3398
|
+
});
|
|
3399
|
+
}
|
|
3400
|
+
}
|
|
3401
|
+
};
|
|
3402
|
+
|
|
3403
|
+
// src/apis/integrations/hubspot/api.ts
|
|
3226
3404
|
var hubspotApi = {
|
|
3405
|
+
webhooks: hubspotWebhooksApi,
|
|
3227
3406
|
getToken(code, clientId, clientSecret, redirectUri) {
|
|
3228
3407
|
return __async(this, null, function* () {
|
|
3229
3408
|
var _a;
|
|
@@ -3234,8 +3413,8 @@ var hubspotApi = {
|
|
|
3234
3413
|
redirect_uri: redirectUri,
|
|
3235
3414
|
grant_type: "authorization_code"
|
|
3236
3415
|
});
|
|
3237
|
-
const tokenResponse = yield
|
|
3238
|
-
"
|
|
3416
|
+
const tokenResponse = yield hubspotClientInstance.post(
|
|
3417
|
+
"/oauth/v1/token",
|
|
3239
3418
|
data,
|
|
3240
3419
|
{
|
|
3241
3420
|
headers: {
|
|
@@ -3251,22 +3430,10 @@ var hubspotApi = {
|
|
|
3251
3430
|
};
|
|
3252
3431
|
});
|
|
3253
3432
|
},
|
|
3254
|
-
|
|
3255
|
-
return __async(this,
|
|
3256
|
-
const {
|
|
3257
|
-
|
|
3258
|
-
} = yield import_axios18.default.get(
|
|
3259
|
-
"https://login.mailchimp.com/oauth2/metadata",
|
|
3260
|
-
{
|
|
3261
|
-
headers: {
|
|
3262
|
-
"Content-Type": "application/json",
|
|
3263
|
-
Authorization: `OAuth ${token}`
|
|
3264
|
-
}
|
|
3265
|
-
}
|
|
3266
|
-
);
|
|
3267
|
-
return {
|
|
3268
|
-
server
|
|
3269
|
-
};
|
|
3433
|
+
getTokenInfo(token) {
|
|
3434
|
+
return __async(this, null, function* () {
|
|
3435
|
+
const { data: tokenInfo } = yield hubspotClientInstance.get(`/oauth/v1/access-tokens/${token}`);
|
|
3436
|
+
return tokenInfo;
|
|
3270
3437
|
});
|
|
3271
3438
|
}
|
|
3272
3439
|
};
|
|
@@ -6744,75 +6911,12 @@ var WorkflowDefinitionTaskType = {
|
|
|
6744
6911
|
trigger: "TRIGGER"
|
|
6745
6912
|
};
|
|
6746
6913
|
|
|
6747
|
-
// src/apis/integrations/hubspot/
|
|
6748
|
-
var
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
}
|
|
6754
|
-
};
|
|
6755
|
-
var hubspotClientUrl = `https://api.hubapi.com`;
|
|
6756
|
-
var hubspotClientInstance = import_axios24.default.create({
|
|
6757
|
-
headers: {
|
|
6758
|
-
"Content-Type": "application/json"
|
|
6759
|
-
}
|
|
6760
|
-
});
|
|
6761
|
-
hubspotClientInstance.interceptors.response.use(
|
|
6762
|
-
(r) => r,
|
|
6763
|
-
(error) => {
|
|
6764
|
-
var _a, _b, _c, _d;
|
|
6765
|
-
if (import_axios24.default.isAxiosError(error)) {
|
|
6766
|
-
if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
|
|
6767
|
-
throw new UnauthorizeApiError("hubspot");
|
|
6768
|
-
}
|
|
6769
|
-
}
|
|
6770
|
-
return Promise.reject(
|
|
6771
|
-
new HubspotApiError(
|
|
6772
|
-
error.message,
|
|
6773
|
-
(_b = error.response) == null ? void 0 : _b.data,
|
|
6774
|
-
(_d = (_c = error.response) == null ? void 0 : _c.status) != null ? _d : 400
|
|
6775
|
-
)
|
|
6776
|
-
);
|
|
6777
|
-
}
|
|
6778
|
-
);
|
|
6779
|
-
function getHubspotClientAuthorization(req) {
|
|
6780
|
-
if (req.headers instanceof Headers) {
|
|
6781
|
-
return {
|
|
6782
|
-
token: req.headers.get("x-adapter-hubspot-token")
|
|
6783
|
-
};
|
|
6784
|
-
}
|
|
6785
|
-
return {
|
|
6786
|
-
token: req.headers["x-adapter-hubspot-token"]
|
|
6787
|
-
};
|
|
6788
|
-
}
|
|
6789
|
-
function getHubspotClientConfig(options = {}) {
|
|
6790
|
-
var _a;
|
|
6791
|
-
const currentHeaders = hubspotClientInstance.defaults.headers;
|
|
6792
|
-
const config = {
|
|
6793
|
-
authorization: (_a = options.token ? `Bearer ${options.token}` : void 0) != null ? _a : currentHeaders.Authorization
|
|
6794
|
-
};
|
|
6795
|
-
if (options.ensureAuthorizationToken && !config.authorization) {
|
|
6796
|
-
throw new UnauthorizeApiError("hubspot");
|
|
6797
|
-
}
|
|
6798
|
-
return {
|
|
6799
|
-
headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
|
|
6800
|
-
};
|
|
6801
|
-
}
|
|
6802
|
-
function initHubspotClient(token) {
|
|
6803
|
-
if (token) {
|
|
6804
|
-
updateHubspotClient(token);
|
|
6805
|
-
}
|
|
6806
|
-
}
|
|
6807
|
-
function updateHubspotClient(token) {
|
|
6808
|
-
const defaults = hubspotClientInstance.defaults;
|
|
6809
|
-
const headers = defaults.headers;
|
|
6810
|
-
if (token) {
|
|
6811
|
-
headers.Authorization = `Bearer ${token}`;
|
|
6812
|
-
} else {
|
|
6813
|
-
delete headers.Authorization;
|
|
6814
|
-
}
|
|
6815
|
-
}
|
|
6914
|
+
// src/apis/integrations/hubspot/webhooks/_contracts/dtos/webhooks.ts
|
|
6915
|
+
var HubSpotWebhookEventTypes = /* @__PURE__ */ ((HubSpotWebhookEventTypes2) => {
|
|
6916
|
+
HubSpotWebhookEventTypes2["ContactCreation"] = "contact.creation";
|
|
6917
|
+
HubSpotWebhookEventTypes2["ContactDeletion"] = "contact.deletion";
|
|
6918
|
+
return HubSpotWebhookEventTypes2;
|
|
6919
|
+
})(HubSpotWebhookEventTypes || {});
|
|
6816
6920
|
|
|
6817
6921
|
// src/apis/integrations/bigcommerce/webhooks/_contracts/dtos/webhooks.ts
|
|
6818
6922
|
var BigCommerceWebhookScopes = /* @__PURE__ */ ((BigCommerceWebhookScopes2) => {
|
|
@@ -6822,8 +6926,8 @@ var BigCommerceWebhookScopes = /* @__PURE__ */ ((BigCommerceWebhookScopes2) => {
|
|
|
6822
6926
|
})(BigCommerceWebhookScopes || {});
|
|
6823
6927
|
|
|
6824
6928
|
// src/apis/platform/billing/instance.ts
|
|
6825
|
-
var
|
|
6826
|
-
var platformBillingClientInstance =
|
|
6929
|
+
var import_axios24 = __toESM(require("axios"));
|
|
6930
|
+
var platformBillingClientInstance = import_axios24.default.create({
|
|
6827
6931
|
baseURL: "https://billing.labs.livechatinc.com"
|
|
6828
6932
|
});
|
|
6829
6933
|
function getPlatformBillingClientAuthorization(req) {
|
|
@@ -7109,7 +7213,8 @@ var import_zod4 = require("zod");
|
|
|
7109
7213
|
|
|
7110
7214
|
// src/apis/platform/adapter/integrations/hubspot/_contracts/dtos/events.ts
|
|
7111
7215
|
var HubspotEventNames = /* @__PURE__ */ ((HubspotEventNames2) => {
|
|
7112
|
-
HubspotEventNames2["
|
|
7216
|
+
HubspotEventNames2["ContactCreated"] = "contact_created";
|
|
7217
|
+
HubspotEventNames2["ContactDeleted"] = "contact_deleted";
|
|
7113
7218
|
return HubspotEventNames2;
|
|
7114
7219
|
})(HubspotEventNames || {});
|
|
7115
7220
|
|
|
@@ -7118,12 +7223,18 @@ var hubspotEventsZods = {
|
|
|
7118
7223
|
provider: import_zod4.z.literal("hubspot"),
|
|
7119
7224
|
eventName: import_zod4.z.nativeEnum(HubspotEventNames),
|
|
7120
7225
|
events: {
|
|
7121
|
-
|
|
7122
|
-
name: import_zod4.z.literal("
|
|
7226
|
+
contactCreated: import_zod4.z.object({
|
|
7227
|
+
name: import_zod4.z.literal("contact_created" /* ContactCreated */)
|
|
7228
|
+
}),
|
|
7229
|
+
contactDeleted: import_zod4.z.object({
|
|
7230
|
+
name: import_zod4.z.literal("contact_deleted" /* ContactDeleted */)
|
|
7123
7231
|
})
|
|
7124
7232
|
},
|
|
7125
7233
|
get event() {
|
|
7126
|
-
return import_zod4.z.discriminatedUnion("name", [
|
|
7234
|
+
return import_zod4.z.discriminatedUnion("name", [
|
|
7235
|
+
this.events.contactCreated,
|
|
7236
|
+
this.events.contactDeleted
|
|
7237
|
+
]);
|
|
7127
7238
|
},
|
|
7128
7239
|
get source() {
|
|
7129
7240
|
return import_zod4.z.object({
|
|
@@ -7143,7 +7254,7 @@ var hubspotEventsZods = {
|
|
|
7143
7254
|
return import_zod4.z.object({
|
|
7144
7255
|
provider: this.provider,
|
|
7145
7256
|
event: this.event,
|
|
7146
|
-
|
|
7257
|
+
callback: import_zod4.z.string()
|
|
7147
7258
|
});
|
|
7148
7259
|
},
|
|
7149
7260
|
get unsubscribe() {
|
|
@@ -7686,6 +7797,7 @@ function getIntegrationFlowUrl(name, flow, trigger, context, state, config) {
|
|
|
7686
7797
|
BigCommerceEventNames,
|
|
7687
7798
|
BigCommerceWebhookScopes,
|
|
7688
7799
|
DpsApiError,
|
|
7800
|
+
HubSpotWebhookEventTypes,
|
|
7689
7801
|
HubspotApiError,
|
|
7690
7802
|
HubspotEventNames,
|
|
7691
7803
|
IntegrationModes,
|
|
@@ -7753,7 +7865,6 @@ function getIntegrationFlowUrl(name, flow, trigger, context, state, config) {
|
|
|
7753
7865
|
getVercelClientConfig,
|
|
7754
7866
|
githubClientInstance,
|
|
7755
7867
|
hubspotClientInstance,
|
|
7756
|
-
hubspotClientUrl,
|
|
7757
7868
|
hubspotEventsZods,
|
|
7758
7869
|
initApi,
|
|
7759
7870
|
initBigCommerceClient,
|