@livechat/developer-studio-api 3.1.18 → 3.1.20
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 +196 -5
- package/dist/index.d.ts +196 -5
- package/dist/index.js +218 -20
- package/dist/index.mjs +209 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -73,6 +73,8 @@ __export(src_exports, {
|
|
|
73
73
|
ApiClient: () => ApiClient,
|
|
74
74
|
ApiErrorBase: () => ApiErrorBase,
|
|
75
75
|
DpsApiError: () => DpsApiError,
|
|
76
|
+
HubspotApiError: () => HubspotApiError,
|
|
77
|
+
HubspotEventNames: () => HubspotEventNames,
|
|
76
78
|
LivechatApiError: () => LivechatApiError,
|
|
77
79
|
MailchimpApiError: () => MailchimpApiError,
|
|
78
80
|
MailchimpEventNames: () => MailchimpEventNames,
|
|
@@ -97,6 +99,8 @@ __export(src_exports, {
|
|
|
97
99
|
getEmptyAppAutoReview: () => getEmptyAppAutoReview,
|
|
98
100
|
getGitHubClientAuthorization: () => getGitHubClientAuthorization,
|
|
99
101
|
getGithubClientConfig: () => getGithubClientConfig,
|
|
102
|
+
getHubspotClientAuthorization: () => getHubspotClientAuthorization,
|
|
103
|
+
getHubspotClientConfig: () => getHubspotClientConfig,
|
|
100
104
|
getIntegrationFlowUrl: () => getIntegrationFlowUrl,
|
|
101
105
|
getLiveChatClientAuthorization: () => getLiveChatClientAuthorization,
|
|
102
106
|
getLiveChatClientConfig: () => getLiveChatClientConfig,
|
|
@@ -127,8 +131,12 @@ __export(src_exports, {
|
|
|
127
131
|
getVercelClientAuthorization: () => getVercelClientAuthorization,
|
|
128
132
|
getVercelClientConfig: () => getVercelClientConfig,
|
|
129
133
|
githubClientInstance: () => githubClientInstance,
|
|
134
|
+
hubspotClientInstance: () => hubspotClientInstance,
|
|
135
|
+
hubspotClientUrl: () => hubspotClientUrl,
|
|
136
|
+
hubspotEventsZods: () => hubspotEventsZods,
|
|
130
137
|
initApi: () => initApi,
|
|
131
138
|
initGithubClient: () => initGithubClient,
|
|
139
|
+
initHubspotClient: () => initHubspotClient,
|
|
132
140
|
initLiveChatClient: () => initLiveChatClient,
|
|
133
141
|
initMailchimpClient: () => initMailchimpClient,
|
|
134
142
|
initNeonClient: () => initNeonClient,
|
|
@@ -157,6 +165,7 @@ __export(src_exports, {
|
|
|
157
165
|
textClientInstance: () => textClientInstance,
|
|
158
166
|
textLivechatEventsZods: () => textLivechatEventsZods,
|
|
159
167
|
updateGithubClient: () => updateGithubClient,
|
|
168
|
+
updateHubspotClient: () => updateHubspotClient,
|
|
160
169
|
updateMailchimpClient: () => updateMailchimpClient,
|
|
161
170
|
updateNeonClient: () => updateNeonClient,
|
|
162
171
|
updateNetlifyClient: () => updateNetlifyClient,
|
|
@@ -2938,7 +2947,7 @@ function getMailchimpClientConfig(options = {}) {
|
|
|
2938
2947
|
}
|
|
2939
2948
|
function initMailchimpClient(token, server) {
|
|
2940
2949
|
if (token && server) {
|
|
2941
|
-
updateMailchimpClient(token);
|
|
2950
|
+
updateMailchimpClient(token, server);
|
|
2942
2951
|
}
|
|
2943
2952
|
}
|
|
2944
2953
|
function updateMailchimpClient(token, server) {
|
|
@@ -3199,6 +3208,56 @@ var shopifyApi = {
|
|
|
3199
3208
|
}
|
|
3200
3209
|
};
|
|
3201
3210
|
|
|
3211
|
+
// src/apis/integrations/hubspot/api.ts
|
|
3212
|
+
var import_axios18 = __toESM(require("axios"));
|
|
3213
|
+
var hubspotApi = {
|
|
3214
|
+
getToken(code, clientId, clientSecret, redirectUri) {
|
|
3215
|
+
return __async(this, null, function* () {
|
|
3216
|
+
var _a;
|
|
3217
|
+
const data = new URLSearchParams({
|
|
3218
|
+
code,
|
|
3219
|
+
client_id: clientId,
|
|
3220
|
+
client_secret: clientSecret,
|
|
3221
|
+
redirect_uri: redirectUri,
|
|
3222
|
+
grant_type: "authorization_code"
|
|
3223
|
+
});
|
|
3224
|
+
const tokenResponse = yield import_axios18.default.post(
|
|
3225
|
+
"https://api.hubapi.com/oauth/v1/token",
|
|
3226
|
+
data,
|
|
3227
|
+
{
|
|
3228
|
+
headers: {
|
|
3229
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
3230
|
+
}
|
|
3231
|
+
}
|
|
3232
|
+
);
|
|
3233
|
+
const params = new URLSearchParams(
|
|
3234
|
+
tokenResponse.data
|
|
3235
|
+
);
|
|
3236
|
+
return {
|
|
3237
|
+
token: (_a = params.get("access_token")) != null ? _a : ""
|
|
3238
|
+
};
|
|
3239
|
+
});
|
|
3240
|
+
},
|
|
3241
|
+
getMetadata(_0) {
|
|
3242
|
+
return __async(this, arguments, function* ({ token }) {
|
|
3243
|
+
const {
|
|
3244
|
+
data: { dc: server }
|
|
3245
|
+
} = yield import_axios18.default.get(
|
|
3246
|
+
"https://login.mailchimp.com/oauth2/metadata",
|
|
3247
|
+
{
|
|
3248
|
+
headers: {
|
|
3249
|
+
"Content-Type": "application/json",
|
|
3250
|
+
Authorization: `OAuth ${token}`
|
|
3251
|
+
}
|
|
3252
|
+
}
|
|
3253
|
+
);
|
|
3254
|
+
return {
|
|
3255
|
+
server
|
|
3256
|
+
};
|
|
3257
|
+
});
|
|
3258
|
+
}
|
|
3259
|
+
};
|
|
3260
|
+
|
|
3202
3261
|
// src/apis/integrations/api.ts
|
|
3203
3262
|
var integrationsApi = {
|
|
3204
3263
|
github: gitHubApi,
|
|
@@ -3208,11 +3267,12 @@ var integrationsApi = {
|
|
|
3208
3267
|
shopify: shopifyApi,
|
|
3209
3268
|
neon: neonApi,
|
|
3210
3269
|
planetscale: planetscaleApi,
|
|
3270
|
+
hubspot: hubspotApi,
|
|
3211
3271
|
text: textApi
|
|
3212
3272
|
};
|
|
3213
3273
|
|
|
3214
3274
|
// src/apis/products/livechat/instance.ts
|
|
3215
|
-
var
|
|
3275
|
+
var import_axios19 = __toESM(require("axios"));
|
|
3216
3276
|
var REGION = {
|
|
3217
3277
|
FRA: "fra",
|
|
3218
3278
|
DAL: "dal",
|
|
@@ -3232,7 +3292,7 @@ var LivechatApiError = class extends ApiErrorBase {
|
|
|
3232
3292
|
this.name = "livechat";
|
|
3233
3293
|
}
|
|
3234
3294
|
};
|
|
3235
|
-
var livechatClientInstance =
|
|
3295
|
+
var livechatClientInstance = import_axios19.default.create({
|
|
3236
3296
|
baseURL: "https://api.labs.livechatinc.com"
|
|
3237
3297
|
});
|
|
3238
3298
|
livechatClientInstance.interceptors.response.use(
|
|
@@ -4127,14 +4187,14 @@ var platformAccountsApi = {
|
|
|
4127
4187
|
};
|
|
4128
4188
|
|
|
4129
4189
|
// src/apis/platform/dps/instance.ts
|
|
4130
|
-
var
|
|
4190
|
+
var import_axios20 = __toESM(require("axios"));
|
|
4131
4191
|
var DpsApiError = class extends ApiErrorBase {
|
|
4132
4192
|
constructor() {
|
|
4133
4193
|
super(...arguments);
|
|
4134
4194
|
this.name = "dps";
|
|
4135
4195
|
}
|
|
4136
4196
|
};
|
|
4137
|
-
var platformDpsClientInstance =
|
|
4197
|
+
var platformDpsClientInstance = import_axios20.default.create({
|
|
4138
4198
|
baseURL: "https://dev-platform.labs.livechatinc.com"
|
|
4139
4199
|
});
|
|
4140
4200
|
platformDpsClientInstance.interceptors.response.use(
|
|
@@ -4330,7 +4390,7 @@ var appTemplates = {
|
|
|
4330
4390
|
target: "nextjs"
|
|
4331
4391
|
},
|
|
4332
4392
|
deployment: {
|
|
4333
|
-
provider: "
|
|
4393
|
+
provider: "vercel",
|
|
4334
4394
|
url: ""
|
|
4335
4395
|
},
|
|
4336
4396
|
storage: {
|
|
@@ -5737,7 +5797,7 @@ var platformDpsApi = {
|
|
|
5737
5797
|
};
|
|
5738
5798
|
|
|
5739
5799
|
// src/apis/platform/adapter/instance.ts
|
|
5740
|
-
var
|
|
5800
|
+
var import_axios21 = __toESM(require("axios"));
|
|
5741
5801
|
var REGION2 = {
|
|
5742
5802
|
FRA: "fra",
|
|
5743
5803
|
DAL: "dal",
|
|
@@ -5767,7 +5827,7 @@ var AdapterApiError = class _AdapterApiError extends ApiErrorBase {
|
|
|
5767
5827
|
);
|
|
5768
5828
|
}
|
|
5769
5829
|
};
|
|
5770
|
-
var platformAdapterClientInstance =
|
|
5830
|
+
var platformAdapterClientInstance = import_axios21.default.create({
|
|
5771
5831
|
baseURL: "https://platform.labs.text.com/console-adapter/api",
|
|
5772
5832
|
headers: {
|
|
5773
5833
|
"Content-Type": "application/json"
|
|
@@ -6487,9 +6547,79 @@ var WorkflowDefinitionTaskType = {
|
|
|
6487
6547
|
addTrigger: "ADD_TRIGGER"
|
|
6488
6548
|
};
|
|
6489
6549
|
|
|
6550
|
+
// src/apis/integrations/hubspot/instance.ts
|
|
6551
|
+
var import_axios22 = __toESM(require("axios"));
|
|
6552
|
+
var HubspotApiError = class extends ApiErrorBase {
|
|
6553
|
+
constructor() {
|
|
6554
|
+
super(...arguments);
|
|
6555
|
+
this.name = "hubspot";
|
|
6556
|
+
}
|
|
6557
|
+
};
|
|
6558
|
+
var hubspotClientUrl = `https://api.hubapi.com`;
|
|
6559
|
+
var hubspotClientInstance = import_axios22.default.create({
|
|
6560
|
+
headers: {
|
|
6561
|
+
"Content-Type": "application/json"
|
|
6562
|
+
}
|
|
6563
|
+
});
|
|
6564
|
+
hubspotClientInstance.interceptors.response.use(
|
|
6565
|
+
(r) => r,
|
|
6566
|
+
(error) => {
|
|
6567
|
+
var _a, _b, _c, _d;
|
|
6568
|
+
if (import_axios22.default.isAxiosError(error)) {
|
|
6569
|
+
if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
|
|
6570
|
+
throw new UnauthorizeApiError("hubspot");
|
|
6571
|
+
}
|
|
6572
|
+
}
|
|
6573
|
+
return Promise.reject(
|
|
6574
|
+
new HubspotApiError(
|
|
6575
|
+
error.message,
|
|
6576
|
+
(_b = error.response) == null ? void 0 : _b.data,
|
|
6577
|
+
(_d = (_c = error.response) == null ? void 0 : _c.status) != null ? _d : 400
|
|
6578
|
+
)
|
|
6579
|
+
);
|
|
6580
|
+
}
|
|
6581
|
+
);
|
|
6582
|
+
function getHubspotClientAuthorization(req) {
|
|
6583
|
+
if (req.headers instanceof Headers) {
|
|
6584
|
+
return {
|
|
6585
|
+
token: req.headers.get("x-adapter-hubspot-token")
|
|
6586
|
+
};
|
|
6587
|
+
}
|
|
6588
|
+
return {
|
|
6589
|
+
token: req.headers["x-adapter-hubspot-token"]
|
|
6590
|
+
};
|
|
6591
|
+
}
|
|
6592
|
+
function getHubspotClientConfig(options = {}) {
|
|
6593
|
+
var _a;
|
|
6594
|
+
const currentHeaders = hubspotClientInstance.defaults.headers;
|
|
6595
|
+
const config = {
|
|
6596
|
+
authorization: (_a = options.token ? `Bearer ${options.token}` : void 0) != null ? _a : currentHeaders.Authorization
|
|
6597
|
+
};
|
|
6598
|
+
if (options.ensureAuthorizationToken && !config.authorization) {
|
|
6599
|
+
throw new UnauthorizeApiError("hubspot");
|
|
6600
|
+
}
|
|
6601
|
+
return {
|
|
6602
|
+
headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
|
|
6603
|
+
};
|
|
6604
|
+
}
|
|
6605
|
+
function initHubspotClient(token) {
|
|
6606
|
+
if (token) {
|
|
6607
|
+
updateHubspotClient(token);
|
|
6608
|
+
}
|
|
6609
|
+
}
|
|
6610
|
+
function updateHubspotClient(token) {
|
|
6611
|
+
const defaults = hubspotClientInstance.defaults;
|
|
6612
|
+
const headers = defaults.headers;
|
|
6613
|
+
if (token) {
|
|
6614
|
+
headers.Authorization = `Bearer ${token}`;
|
|
6615
|
+
} else {
|
|
6616
|
+
delete headers.Authorization;
|
|
6617
|
+
}
|
|
6618
|
+
}
|
|
6619
|
+
|
|
6490
6620
|
// src/apis/platform/billing/instance.ts
|
|
6491
|
-
var
|
|
6492
|
-
var platformBillingClientInstance =
|
|
6621
|
+
var import_axios23 = __toESM(require("axios"));
|
|
6622
|
+
var platformBillingClientInstance = import_axios23.default.create({
|
|
6493
6623
|
baseURL: "https://billing.labs.livechatinc.com"
|
|
6494
6624
|
});
|
|
6495
6625
|
function getPlatformBillingClientAuthorization(req) {
|
|
@@ -6530,7 +6660,7 @@ function initPlatformBillingClient(baseUrl, token) {
|
|
|
6530
6660
|
}
|
|
6531
6661
|
|
|
6532
6662
|
// src/apis/platform/adapter/integrations/_contracts/requests/events.ts
|
|
6533
|
-
var
|
|
6663
|
+
var import_zod5 = require("zod");
|
|
6534
6664
|
|
|
6535
6665
|
// src/apis/platform/adapter/integrations/shopify/_contracts/dtos/events.ts
|
|
6536
6666
|
var ShopifyEventNames = /* @__PURE__ */ ((ShopifyEventNames2) => {
|
|
@@ -6749,34 +6879,93 @@ var textLivechatEventsZods = {
|
|
|
6749
6879
|
}
|
|
6750
6880
|
};
|
|
6751
6881
|
|
|
6882
|
+
// src/apis/platform/adapter/integrations/hubspot/_contracts/requests/events.ts
|
|
6883
|
+
var import_zod4 = require("zod");
|
|
6884
|
+
|
|
6885
|
+
// src/apis/platform/adapter/integrations/hubspot/_contracts/dtos/events.ts
|
|
6886
|
+
var HubspotEventNames = /* @__PURE__ */ ((HubspotEventNames2) => {
|
|
6887
|
+
HubspotEventNames2["SomeEvent"] = "some_event";
|
|
6888
|
+
return HubspotEventNames2;
|
|
6889
|
+
})(HubspotEventNames || {});
|
|
6890
|
+
|
|
6891
|
+
// src/apis/platform/adapter/integrations/hubspot/_contracts/requests/events.ts
|
|
6892
|
+
var hubspotEventsZods = {
|
|
6893
|
+
provider: import_zod4.z.literal("hubspot"),
|
|
6894
|
+
eventName: import_zod4.z.nativeEnum(HubspotEventNames),
|
|
6895
|
+
events: {
|
|
6896
|
+
someEvent: import_zod4.z.object({
|
|
6897
|
+
name: import_zod4.z.literal("some_event" /* SomeEvent */)
|
|
6898
|
+
})
|
|
6899
|
+
},
|
|
6900
|
+
get event() {
|
|
6901
|
+
return import_zod4.z.discriminatedUnion("name", [this.events.someEvent]);
|
|
6902
|
+
},
|
|
6903
|
+
get source() {
|
|
6904
|
+
return import_zod4.z.object({
|
|
6905
|
+
sourceName: import_zod4.z.enum(["apps", "workflows"]),
|
|
6906
|
+
sourceKey: import_zod4.z.string()
|
|
6907
|
+
});
|
|
6908
|
+
},
|
|
6909
|
+
get subscribe() {
|
|
6910
|
+
return this.source.and(
|
|
6911
|
+
import_zod4.z.object({
|
|
6912
|
+
event: this.event,
|
|
6913
|
+
callback: import_zod4.z.string()
|
|
6914
|
+
})
|
|
6915
|
+
);
|
|
6916
|
+
},
|
|
6917
|
+
get subscribeContent() {
|
|
6918
|
+
return import_zod4.z.object({
|
|
6919
|
+
provider: this.provider,
|
|
6920
|
+
event: this.event,
|
|
6921
|
+
listId: import_zod4.z.string()
|
|
6922
|
+
});
|
|
6923
|
+
},
|
|
6924
|
+
get unsubscribe() {
|
|
6925
|
+
return this.source.and(
|
|
6926
|
+
import_zod4.z.object({
|
|
6927
|
+
event: this.eventName
|
|
6928
|
+
})
|
|
6929
|
+
);
|
|
6930
|
+
},
|
|
6931
|
+
get unsubscribeContent() {
|
|
6932
|
+
return import_zod4.z.object({
|
|
6933
|
+
provider: this.provider,
|
|
6934
|
+
event: this.eventName
|
|
6935
|
+
});
|
|
6936
|
+
}
|
|
6937
|
+
};
|
|
6938
|
+
|
|
6752
6939
|
// src/apis/platform/adapter/integrations/_contracts/requests/events.ts
|
|
6753
6940
|
var integrationEventsZods = {
|
|
6754
|
-
sourceName:
|
|
6755
|
-
providerName:
|
|
6941
|
+
sourceName: import_zod5.z.enum(["apps", "workflows"]),
|
|
6942
|
+
providerName: import_zod5.z.enum(["text-livechat", "mailchimp", "shopify", "hubspot"]),
|
|
6756
6943
|
get event() {
|
|
6757
|
-
return textLivechatEventsZods.event.or(shopifyEventsZods.event).or(mailchimpEventsZods.event);
|
|
6944
|
+
return textLivechatEventsZods.event.or(shopifyEventsZods.event).or(mailchimpEventsZods.event).or(hubspotEventsZods.event);
|
|
6758
6945
|
},
|
|
6759
6946
|
get source() {
|
|
6760
|
-
return
|
|
6947
|
+
return import_zod5.z.object({
|
|
6761
6948
|
sourceName: this.sourceName,
|
|
6762
|
-
sourceKey:
|
|
6949
|
+
sourceKey: import_zod5.z.string()
|
|
6763
6950
|
});
|
|
6764
6951
|
},
|
|
6765
6952
|
get subscribe() {
|
|
6766
6953
|
return this.source.and(
|
|
6767
|
-
|
|
6954
|
+
import_zod5.z.discriminatedUnion("provider", [
|
|
6768
6955
|
textLivechatEventsZods.subscribeContent,
|
|
6769
6956
|
shopifyEventsZods.subscribeContent,
|
|
6770
|
-
mailchimpEventsZods.subscribeContent
|
|
6957
|
+
mailchimpEventsZods.subscribeContent,
|
|
6958
|
+
hubspotEventsZods.subscribeContent
|
|
6771
6959
|
])
|
|
6772
6960
|
);
|
|
6773
6961
|
},
|
|
6774
6962
|
get unsubscribe() {
|
|
6775
6963
|
return this.source.and(
|
|
6776
|
-
|
|
6964
|
+
import_zod5.z.discriminatedUnion("provider", [
|
|
6777
6965
|
textLivechatEventsZods.unsubscribeContent,
|
|
6778
6966
|
shopifyEventsZods.unsubscribeContent,
|
|
6779
|
-
mailchimpEventsZods.unsubscribeContent
|
|
6967
|
+
mailchimpEventsZods.unsubscribeContent,
|
|
6968
|
+
hubspotEventsZods.unsubscribeContent
|
|
6780
6969
|
])
|
|
6781
6970
|
);
|
|
6782
6971
|
}
|
|
@@ -7106,6 +7295,8 @@ function getIntegrationFlowUrl(provider, flow, data, context, config) {
|
|
|
7106
7295
|
ApiClient,
|
|
7107
7296
|
ApiErrorBase,
|
|
7108
7297
|
DpsApiError,
|
|
7298
|
+
HubspotApiError,
|
|
7299
|
+
HubspotEventNames,
|
|
7109
7300
|
LivechatApiError,
|
|
7110
7301
|
MailchimpApiError,
|
|
7111
7302
|
MailchimpEventNames,
|
|
@@ -7130,6 +7321,8 @@ function getIntegrationFlowUrl(provider, flow, data, context, config) {
|
|
|
7130
7321
|
getEmptyAppAutoReview,
|
|
7131
7322
|
getGitHubClientAuthorization,
|
|
7132
7323
|
getGithubClientConfig,
|
|
7324
|
+
getHubspotClientAuthorization,
|
|
7325
|
+
getHubspotClientConfig,
|
|
7133
7326
|
getIntegrationFlowUrl,
|
|
7134
7327
|
getLiveChatClientAuthorization,
|
|
7135
7328
|
getLiveChatClientConfig,
|
|
@@ -7160,8 +7353,12 @@ function getIntegrationFlowUrl(provider, flow, data, context, config) {
|
|
|
7160
7353
|
getVercelClientAuthorization,
|
|
7161
7354
|
getVercelClientConfig,
|
|
7162
7355
|
githubClientInstance,
|
|
7356
|
+
hubspotClientInstance,
|
|
7357
|
+
hubspotClientUrl,
|
|
7358
|
+
hubspotEventsZods,
|
|
7163
7359
|
initApi,
|
|
7164
7360
|
initGithubClient,
|
|
7361
|
+
initHubspotClient,
|
|
7165
7362
|
initLiveChatClient,
|
|
7166
7363
|
initMailchimpClient,
|
|
7167
7364
|
initNeonClient,
|
|
@@ -7190,6 +7387,7 @@ function getIntegrationFlowUrl(provider, flow, data, context, config) {
|
|
|
7190
7387
|
textClientInstance,
|
|
7191
7388
|
textLivechatEventsZods,
|
|
7192
7389
|
updateGithubClient,
|
|
7390
|
+
updateHubspotClient,
|
|
7193
7391
|
updateMailchimpClient,
|
|
7194
7392
|
updateNeonClient,
|
|
7195
7393
|
updateNetlifyClient,
|