@livechat/developer-studio-api 3.1.27 → 3.1.28
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 +161 -38
- package/dist/index.d.ts +161 -38
- package/dist/index.js +204 -97
- package/dist/index.mjs +203 -96
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -3068,9 +3068,184 @@ var shopifyApi = {
|
|
|
3068
3068
|
}
|
|
3069
3069
|
};
|
|
3070
3070
|
|
|
3071
|
-
// src/apis/integrations/hubspot/
|
|
3071
|
+
// src/apis/integrations/hubspot/instance.ts
|
|
3072
3072
|
import axios16 from "axios";
|
|
3073
|
+
var HubspotApiError = class extends ApiErrorBase {
|
|
3074
|
+
constructor() {
|
|
3075
|
+
super(...arguments);
|
|
3076
|
+
this.name = "hubspot";
|
|
3077
|
+
}
|
|
3078
|
+
};
|
|
3079
|
+
var hubspotClientInstance = axios16.create({
|
|
3080
|
+
baseURL: `https://api.hubapi.com`,
|
|
3081
|
+
headers: {
|
|
3082
|
+
"Content-Type": "application/json"
|
|
3083
|
+
}
|
|
3084
|
+
});
|
|
3085
|
+
hubspotClientInstance.interceptors.response.use(
|
|
3086
|
+
(r) => r,
|
|
3087
|
+
(error) => {
|
|
3088
|
+
var _a, _b, _c, _d;
|
|
3089
|
+
if (axios16.isAxiosError(error)) {
|
|
3090
|
+
if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
|
|
3091
|
+
throw new UnauthorizeApiError("hubspot");
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3094
|
+
return Promise.reject(
|
|
3095
|
+
new HubspotApiError(
|
|
3096
|
+
error.message,
|
|
3097
|
+
(_b = error.response) == null ? void 0 : _b.data,
|
|
3098
|
+
(_d = (_c = error.response) == null ? void 0 : _c.status) != null ? _d : 400
|
|
3099
|
+
)
|
|
3100
|
+
);
|
|
3101
|
+
}
|
|
3102
|
+
);
|
|
3103
|
+
function getHubspotClientAuthorization(req) {
|
|
3104
|
+
if (req.headers instanceof Headers) {
|
|
3105
|
+
return {
|
|
3106
|
+
token: req.headers.get("x-adapter-hubspot-token")
|
|
3107
|
+
};
|
|
3108
|
+
}
|
|
3109
|
+
return {
|
|
3110
|
+
token: req.headers["x-adapter-hubspot-token"]
|
|
3111
|
+
};
|
|
3112
|
+
}
|
|
3113
|
+
function getHubspotClientConfig(options = {}) {
|
|
3114
|
+
var _a;
|
|
3115
|
+
const currentHeaders = hubspotClientInstance.defaults.headers;
|
|
3116
|
+
const config = {
|
|
3117
|
+
authorization: (_a = options.token ? `Bearer ${options.token}` : void 0) != null ? _a : currentHeaders.Authorization
|
|
3118
|
+
};
|
|
3119
|
+
if (options.ensureAuthorizationToken && !config.authorization) {
|
|
3120
|
+
throw new UnauthorizeApiError("hubspot");
|
|
3121
|
+
}
|
|
3122
|
+
return {
|
|
3123
|
+
headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
|
|
3124
|
+
};
|
|
3125
|
+
}
|
|
3126
|
+
function initHubspotClient(token) {
|
|
3127
|
+
if (token) {
|
|
3128
|
+
updateHubspotClient(token);
|
|
3129
|
+
}
|
|
3130
|
+
}
|
|
3131
|
+
function updateHubspotClient(token) {
|
|
3132
|
+
const defaults = hubspotClientInstance.defaults;
|
|
3133
|
+
const headers = defaults.headers;
|
|
3134
|
+
if (token) {
|
|
3135
|
+
headers.Authorization = `Bearer ${token}`;
|
|
3136
|
+
} else {
|
|
3137
|
+
delete headers.Authorization;
|
|
3138
|
+
}
|
|
3139
|
+
}
|
|
3140
|
+
|
|
3141
|
+
// src/apis/integrations/hubspot/webhooks/api.ts
|
|
3142
|
+
var hubspotWebhooksApi = {
|
|
3143
|
+
settings: {
|
|
3144
|
+
get(appId, authorization) {
|
|
3145
|
+
return __async(this, null, function* () {
|
|
3146
|
+
const params = new URLSearchParams(
|
|
3147
|
+
(authorization == null ? void 0 : authorization.apiKey) ? {
|
|
3148
|
+
hapikey: authorization.apiKey
|
|
3149
|
+
} : {}
|
|
3150
|
+
);
|
|
3151
|
+
return hubspotClientInstance.get(
|
|
3152
|
+
`/webhooks/v1/${encodeURIComponent(
|
|
3153
|
+
appId
|
|
3154
|
+
)}/settings?${params.toString()}`
|
|
3155
|
+
// getHubspotClientConfig({
|
|
3156
|
+
// ...authorization,
|
|
3157
|
+
// ensureAuthorizationToken: true,
|
|
3158
|
+
// })
|
|
3159
|
+
).catch((e) => {
|
|
3160
|
+
console.log(e);
|
|
3161
|
+
throw e;
|
|
3162
|
+
});
|
|
3163
|
+
});
|
|
3164
|
+
},
|
|
3165
|
+
update(appId, payload, authorization) {
|
|
3166
|
+
return __async(this, null, function* () {
|
|
3167
|
+
const params = new URLSearchParams(
|
|
3168
|
+
(authorization == null ? void 0 : authorization.apiKey) ? {
|
|
3169
|
+
hapikey: authorization.apiKey
|
|
3170
|
+
} : {}
|
|
3171
|
+
);
|
|
3172
|
+
return hubspotClientInstance.put(
|
|
3173
|
+
`/webhooks/v1/${encodeURIComponent(
|
|
3174
|
+
appId
|
|
3175
|
+
)}/settings?${params.toString()}`,
|
|
3176
|
+
payload
|
|
3177
|
+
// getHubspotClientConfig({
|
|
3178
|
+
// ...authorization,
|
|
3179
|
+
// ensureAuthorizationToken: true,
|
|
3180
|
+
// })
|
|
3181
|
+
);
|
|
3182
|
+
});
|
|
3183
|
+
}
|
|
3184
|
+
},
|
|
3185
|
+
subscriptions: {
|
|
3186
|
+
list(appId, authorization) {
|
|
3187
|
+
return __async(this, null, function* () {
|
|
3188
|
+
const params = new URLSearchParams(
|
|
3189
|
+
(authorization == null ? void 0 : authorization.apiKey) ? {
|
|
3190
|
+
hapikey: authorization.apiKey
|
|
3191
|
+
} : {}
|
|
3192
|
+
);
|
|
3193
|
+
return hubspotClientInstance.get(
|
|
3194
|
+
`/webhooks/v3/${encodeURIComponent(
|
|
3195
|
+
appId
|
|
3196
|
+
)}/subscriptions?${params.toString()}`
|
|
3197
|
+
// getHubspotClientConfig({
|
|
3198
|
+
// ...authorization,
|
|
3199
|
+
// ensureAuthorizationToken: true,
|
|
3200
|
+
// })
|
|
3201
|
+
);
|
|
3202
|
+
});
|
|
3203
|
+
},
|
|
3204
|
+
register(appId, payload, authorization) {
|
|
3205
|
+
return __async(this, null, function* () {
|
|
3206
|
+
const params = new URLSearchParams(
|
|
3207
|
+
(authorization == null ? void 0 : authorization.apiKey) ? {
|
|
3208
|
+
hapikey: authorization.apiKey
|
|
3209
|
+
} : {}
|
|
3210
|
+
);
|
|
3211
|
+
return hubspotClientInstance.post(
|
|
3212
|
+
`/webhooks/v3/${encodeURIComponent(
|
|
3213
|
+
appId
|
|
3214
|
+
)}/subscriptions?${params.toString()}`,
|
|
3215
|
+
payload
|
|
3216
|
+
// getHubspotClientConfig({
|
|
3217
|
+
// ...authorization,
|
|
3218
|
+
// ensureAuthorizationToken: true,
|
|
3219
|
+
// })
|
|
3220
|
+
);
|
|
3221
|
+
});
|
|
3222
|
+
},
|
|
3223
|
+
unregister(appId, subscriptionId, authorization) {
|
|
3224
|
+
return __async(this, null, function* () {
|
|
3225
|
+
const params = new URLSearchParams(
|
|
3226
|
+
(authorization == null ? void 0 : authorization.apiKey) ? {
|
|
3227
|
+
hapikey: authorization.apiKey
|
|
3228
|
+
} : {}
|
|
3229
|
+
);
|
|
3230
|
+
return hubspotClientInstance.delete(
|
|
3231
|
+
`/webhooks/v3/${encodeURIComponent(
|
|
3232
|
+
appId
|
|
3233
|
+
)}/subscriptions/${encodeURIComponent(
|
|
3234
|
+
subscriptionId
|
|
3235
|
+
)}?${params.toString()}`
|
|
3236
|
+
// getHubspotClientConfig({
|
|
3237
|
+
// ...authorization,
|
|
3238
|
+
// ensureAuthorizationToken: true,
|
|
3239
|
+
// })
|
|
3240
|
+
);
|
|
3241
|
+
});
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
3244
|
+
};
|
|
3245
|
+
|
|
3246
|
+
// src/apis/integrations/hubspot/api.ts
|
|
3073
3247
|
var hubspotApi = {
|
|
3248
|
+
webhooks: hubspotWebhooksApi,
|
|
3074
3249
|
getToken(code, clientId, clientSecret, redirectUri) {
|
|
3075
3250
|
return __async(this, null, function* () {
|
|
3076
3251
|
var _a;
|
|
@@ -3081,8 +3256,8 @@ var hubspotApi = {
|
|
|
3081
3256
|
redirect_uri: redirectUri,
|
|
3082
3257
|
grant_type: "authorization_code"
|
|
3083
3258
|
});
|
|
3084
|
-
const tokenResponse = yield
|
|
3085
|
-
"
|
|
3259
|
+
const tokenResponse = yield hubspotClientInstance.post(
|
|
3260
|
+
"/oauth/v1/token",
|
|
3086
3261
|
data,
|
|
3087
3262
|
{
|
|
3088
3263
|
headers: {
|
|
@@ -3098,22 +3273,10 @@ var hubspotApi = {
|
|
|
3098
3273
|
};
|
|
3099
3274
|
});
|
|
3100
3275
|
},
|
|
3101
|
-
|
|
3102
|
-
return __async(this,
|
|
3103
|
-
const {
|
|
3104
|
-
|
|
3105
|
-
} = yield axios16.get(
|
|
3106
|
-
"https://login.mailchimp.com/oauth2/metadata",
|
|
3107
|
-
{
|
|
3108
|
-
headers: {
|
|
3109
|
-
"Content-Type": "application/json",
|
|
3110
|
-
Authorization: `OAuth ${token}`
|
|
3111
|
-
}
|
|
3112
|
-
}
|
|
3113
|
-
);
|
|
3114
|
-
return {
|
|
3115
|
-
server
|
|
3116
|
-
};
|
|
3276
|
+
getTokenInfo(token) {
|
|
3277
|
+
return __async(this, null, function* () {
|
|
3278
|
+
const { data: tokenInfo } = yield hubspotClientInstance.get(`/oauth/v1/access-tokens/${token}`);
|
|
3279
|
+
return tokenInfo;
|
|
3117
3280
|
});
|
|
3118
3281
|
}
|
|
3119
3282
|
};
|
|
@@ -6591,75 +6754,12 @@ var WorkflowDefinitionTaskType = {
|
|
|
6591
6754
|
trigger: "TRIGGER"
|
|
6592
6755
|
};
|
|
6593
6756
|
|
|
6594
|
-
// src/apis/integrations/hubspot/
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
}
|
|
6601
|
-
};
|
|
6602
|
-
var hubspotClientUrl = `https://api.hubapi.com`;
|
|
6603
|
-
var hubspotClientInstance = axios22.create({
|
|
6604
|
-
headers: {
|
|
6605
|
-
"Content-Type": "application/json"
|
|
6606
|
-
}
|
|
6607
|
-
});
|
|
6608
|
-
hubspotClientInstance.interceptors.response.use(
|
|
6609
|
-
(r) => r,
|
|
6610
|
-
(error) => {
|
|
6611
|
-
var _a, _b, _c, _d;
|
|
6612
|
-
if (axios22.isAxiosError(error)) {
|
|
6613
|
-
if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
|
|
6614
|
-
throw new UnauthorizeApiError("hubspot");
|
|
6615
|
-
}
|
|
6616
|
-
}
|
|
6617
|
-
return Promise.reject(
|
|
6618
|
-
new HubspotApiError(
|
|
6619
|
-
error.message,
|
|
6620
|
-
(_b = error.response) == null ? void 0 : _b.data,
|
|
6621
|
-
(_d = (_c = error.response) == null ? void 0 : _c.status) != null ? _d : 400
|
|
6622
|
-
)
|
|
6623
|
-
);
|
|
6624
|
-
}
|
|
6625
|
-
);
|
|
6626
|
-
function getHubspotClientAuthorization(req) {
|
|
6627
|
-
if (req.headers instanceof Headers) {
|
|
6628
|
-
return {
|
|
6629
|
-
token: req.headers.get("x-adapter-hubspot-token")
|
|
6630
|
-
};
|
|
6631
|
-
}
|
|
6632
|
-
return {
|
|
6633
|
-
token: req.headers["x-adapter-hubspot-token"]
|
|
6634
|
-
};
|
|
6635
|
-
}
|
|
6636
|
-
function getHubspotClientConfig(options = {}) {
|
|
6637
|
-
var _a;
|
|
6638
|
-
const currentHeaders = hubspotClientInstance.defaults.headers;
|
|
6639
|
-
const config = {
|
|
6640
|
-
authorization: (_a = options.token ? `Bearer ${options.token}` : void 0) != null ? _a : currentHeaders.Authorization
|
|
6641
|
-
};
|
|
6642
|
-
if (options.ensureAuthorizationToken && !config.authorization) {
|
|
6643
|
-
throw new UnauthorizeApiError("hubspot");
|
|
6644
|
-
}
|
|
6645
|
-
return {
|
|
6646
|
-
headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
|
|
6647
|
-
};
|
|
6648
|
-
}
|
|
6649
|
-
function initHubspotClient(token) {
|
|
6650
|
-
if (token) {
|
|
6651
|
-
updateHubspotClient(token);
|
|
6652
|
-
}
|
|
6653
|
-
}
|
|
6654
|
-
function updateHubspotClient(token) {
|
|
6655
|
-
const defaults = hubspotClientInstance.defaults;
|
|
6656
|
-
const headers = defaults.headers;
|
|
6657
|
-
if (token) {
|
|
6658
|
-
headers.Authorization = `Bearer ${token}`;
|
|
6659
|
-
} else {
|
|
6660
|
-
delete headers.Authorization;
|
|
6661
|
-
}
|
|
6662
|
-
}
|
|
6757
|
+
// src/apis/integrations/hubspot/webhooks/_contracts/dtos/webhooks.ts
|
|
6758
|
+
var HubSpotWebhookEventTypes = /* @__PURE__ */ ((HubSpotWebhookEventTypes2) => {
|
|
6759
|
+
HubSpotWebhookEventTypes2["ContactCreation"] = "contact.creation";
|
|
6760
|
+
HubSpotWebhookEventTypes2["ContactDeletion"] = "contact.deletion";
|
|
6761
|
+
return HubSpotWebhookEventTypes2;
|
|
6762
|
+
})(HubSpotWebhookEventTypes || {});
|
|
6663
6763
|
|
|
6664
6764
|
// src/apis/integrations/bigcommerce/webhooks/_contracts/dtos/webhooks.ts
|
|
6665
6765
|
var BigCommerceWebhookScopes = /* @__PURE__ */ ((BigCommerceWebhookScopes2) => {
|
|
@@ -6669,8 +6769,8 @@ var BigCommerceWebhookScopes = /* @__PURE__ */ ((BigCommerceWebhookScopes2) => {
|
|
|
6669
6769
|
})(BigCommerceWebhookScopes || {});
|
|
6670
6770
|
|
|
6671
6771
|
// src/apis/platform/billing/instance.ts
|
|
6672
|
-
import
|
|
6673
|
-
var platformBillingClientInstance =
|
|
6772
|
+
import axios22 from "axios";
|
|
6773
|
+
var platformBillingClientInstance = axios22.create({
|
|
6674
6774
|
baseURL: "https://billing.labs.livechatinc.com"
|
|
6675
6775
|
});
|
|
6676
6776
|
function getPlatformBillingClientAuthorization(req) {
|
|
@@ -6956,7 +7056,8 @@ import { z as z4 } from "zod";
|
|
|
6956
7056
|
|
|
6957
7057
|
// src/apis/platform/adapter/integrations/hubspot/_contracts/dtos/events.ts
|
|
6958
7058
|
var HubspotEventNames = /* @__PURE__ */ ((HubspotEventNames2) => {
|
|
6959
|
-
HubspotEventNames2["
|
|
7059
|
+
HubspotEventNames2["ContactCreated"] = "contact_created";
|
|
7060
|
+
HubspotEventNames2["ContactDeleted"] = "contact_deleted";
|
|
6960
7061
|
return HubspotEventNames2;
|
|
6961
7062
|
})(HubspotEventNames || {});
|
|
6962
7063
|
|
|
@@ -6965,12 +7066,18 @@ var hubspotEventsZods = {
|
|
|
6965
7066
|
provider: z4.literal("hubspot"),
|
|
6966
7067
|
eventName: z4.nativeEnum(HubspotEventNames),
|
|
6967
7068
|
events: {
|
|
6968
|
-
|
|
6969
|
-
name: z4.literal("
|
|
7069
|
+
contactCreated: z4.object({
|
|
7070
|
+
name: z4.literal("contact_created" /* ContactCreated */)
|
|
7071
|
+
}),
|
|
7072
|
+
contactDeleted: z4.object({
|
|
7073
|
+
name: z4.literal("contact_deleted" /* ContactDeleted */)
|
|
6970
7074
|
})
|
|
6971
7075
|
},
|
|
6972
7076
|
get event() {
|
|
6973
|
-
return z4.discriminatedUnion("name", [
|
|
7077
|
+
return z4.discriminatedUnion("name", [
|
|
7078
|
+
this.events.contactCreated,
|
|
7079
|
+
this.events.contactDeleted
|
|
7080
|
+
]);
|
|
6974
7081
|
},
|
|
6975
7082
|
get source() {
|
|
6976
7083
|
return z4.object({
|
|
@@ -6990,7 +7097,7 @@ var hubspotEventsZods = {
|
|
|
6990
7097
|
return z4.object({
|
|
6991
7098
|
provider: this.provider,
|
|
6992
7099
|
event: this.event,
|
|
6993
|
-
|
|
7100
|
+
callback: z4.string()
|
|
6994
7101
|
});
|
|
6995
7102
|
},
|
|
6996
7103
|
get unsubscribe() {
|
|
@@ -7532,6 +7639,7 @@ export {
|
|
|
7532
7639
|
BigCommerceEventNames,
|
|
7533
7640
|
BigCommerceWebhookScopes,
|
|
7534
7641
|
DpsApiError,
|
|
7642
|
+
HubSpotWebhookEventTypes,
|
|
7535
7643
|
HubspotApiError,
|
|
7536
7644
|
HubspotEventNames,
|
|
7537
7645
|
IntegrationModes,
|
|
@@ -7599,7 +7707,6 @@ export {
|
|
|
7599
7707
|
getVercelClientConfig,
|
|
7600
7708
|
githubClientInstance,
|
|
7601
7709
|
hubspotClientInstance,
|
|
7602
|
-
hubspotClientUrl,
|
|
7603
7710
|
hubspotEventsZods,
|
|
7604
7711
|
initApi,
|
|
7605
7712
|
initBigCommerceClient,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livechat/developer-studio-api",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.28",
|
|
4
4
|
"description": "This project is API for LiveChat Developer Studio.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"@types/node": "^17.0.12",
|
|
21
21
|
"tsup": "^7.1.0",
|
|
22
22
|
"typescript": "^5.1.6",
|
|
23
|
+
"utils": "0.0.4",
|
|
23
24
|
"eslint-config-custom": "0.0.8",
|
|
24
|
-
"tsconfig": "0.0.1"
|
|
25
|
-
"utils": "0.0.4"
|
|
25
|
+
"tsconfig": "0.0.1"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "tsup",
|