@livechat/developer-studio-api 3.0.53 → 3.0.55

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.mjs CHANGED
@@ -1234,15 +1234,17 @@ import axios6 from "axios";
1234
1234
  var textClientInstance = axios6.create({
1235
1235
  baseURL: "https://api.labs.text.com"
1236
1236
  });
1237
- function getTextClientAuthorization(req) {
1237
+ function getTextClientAuthorization(req, useIntegration) {
1238
1238
  if (req.headers instanceof Headers) {
1239
1239
  return {
1240
- token: req.headers.get("x-adapter-platform-token"),
1240
+ token: req.headers.get(
1241
+ useIntegration ? "x-adapter-text-token" : "x-adapter-platform-token"
1242
+ ),
1241
1243
  tokenType: "Bearer"
1242
1244
  };
1243
1245
  }
1244
1246
  return {
1245
- token: req.headers["x-adapter-platform-token"],
1247
+ token: req.headers[useIntegration ? "x-adapter-text-token" : "x-adapter-platform-token"],
1246
1248
  tokenType: "Bearer"
1247
1249
  };
1248
1250
  }
@@ -2593,7 +2595,7 @@ function getShopifyClientAuthorization(req) {
2593
2595
  token: req.headers["x-adapter-shopify-token"]
2594
2596
  };
2595
2597
  }
2596
- function getShopifyClientConfig(options) {
2598
+ function getShopifyClientConfig(options = {}) {
2597
2599
  var _a, _b;
2598
2600
  const currentBaseUrl = shopifyClientInstance.defaults.baseURL;
2599
2601
  const currentHeaders = shopifyClientInstance.defaults.headers;
@@ -5282,6 +5284,9 @@ function getPlatformAdapterClientAuthorization(req) {
5282
5284
  shopify: {
5283
5285
  token: req.headers.get("x-adapter-shopify-token"),
5284
5286
  shop: req.headers.get("x-adapter-shopify-shop")
5287
+ },
5288
+ text: {
5289
+ token: req.headers.get("x-adapter-text-token")
5285
5290
  }
5286
5291
  };
5287
5292
  }
@@ -5312,11 +5317,14 @@ function getPlatformAdapterClientAuthorization(req) {
5312
5317
  shopify: {
5313
5318
  token: req.headers["x-adapter-shopify-token"],
5314
5319
  shop: req.headers["x-adapter-shopify-shop"]
5320
+ },
5321
+ text: {
5322
+ token: req.headers["x-adapter-text-token"]
5315
5323
  }
5316
5324
  };
5317
5325
  }
5318
5326
  function getPlatformAdapterClientConfig(options = {}) {
5319
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E;
5327
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H;
5320
5328
  const currentHeaders = platformAdapterClientInstance.defaults.headers;
5321
5329
  const headers = {
5322
5330
  platform: {
@@ -5334,38 +5342,42 @@ function getPlatformAdapterClientConfig(options = {}) {
5334
5342
  mailchimp: (_p = currentHeaders["x-adapter-mailchimp-token"]) != null ? _p : (_o = options.mailchimp) == null ? void 0 : _o.token,
5335
5343
  mailchimpServer: (_r = currentHeaders["x-adapter-mailchimp-server"]) != null ? _r : (_q = options.mailchimp) == null ? void 0 : _q.server,
5336
5344
  shopify: (_t = currentHeaders["x-adapter-shopify-token"]) != null ? _t : (_s = options.shopify) == null ? void 0 : _s.token,
5337
- shopifyShop: (_v = currentHeaders["x-adapter-shopify-shop"]) != null ? _v : (_u = options.shopify) == null ? void 0 : _u.shop
5345
+ shopifyShop: (_v = currentHeaders["x-adapter-shopify-shop"]) != null ? _v : (_u = options.shopify) == null ? void 0 : _u.shop,
5346
+ text: (_x = currentHeaders["x-adapter-text-token"]) != null ? _x : (_w = options.text) == null ? void 0 : _w.token
5338
5347
  }
5339
5348
  };
5340
5349
  if (currentHeaders["x-adapter-platform-token"]) {
5341
- currentHeaders["X-Region"] = (_w = getRegion2(currentHeaders["x-adapter-platform-token"])) != null ? _w : void 0;
5350
+ currentHeaders["X-Region"] = (_y = getRegion2(currentHeaders["x-adapter-platform-token"])) != null ? _y : void 0;
5342
5351
  }
5343
- if (((_x = options.ensureAuthorizationToken) == null ? void 0 : _x.platform) && !headers.platform.token) {
5352
+ if (((_z = options.ensureAuthorizationToken) == null ? void 0 : _z.platform) && !headers.platform.token) {
5344
5353
  throw new UnauthorizeApiError("accounts");
5345
5354
  }
5346
- if (((_y = options.ensureAuthorizationToken) == null ? void 0 : _y.github) && (!headers.integrations.github.app || !headers.integrations.github.oauth)) {
5355
+ if (((_A = options.ensureAuthorizationToken) == null ? void 0 : _A.github) && (!headers.integrations.github.app || !headers.integrations.github.oauth)) {
5347
5356
  throw new UnauthorizeApiError("github");
5348
5357
  }
5349
- if (((_z = options.ensureAuthorizationToken) == null ? void 0 : _z.vercel) && !headers.integrations.vercel) {
5358
+ if (((_B = options.ensureAuthorizationToken) == null ? void 0 : _B.vercel) && !headers.integrations.vercel) {
5350
5359
  throw new UnauthorizeApiError("vercel");
5351
5360
  }
5352
- if (((_A = options.ensureAuthorizationToken) == null ? void 0 : _A.netlify) && !headers.integrations.netlify) {
5361
+ if (((_C = options.ensureAuthorizationToken) == null ? void 0 : _C.netlify) && !headers.integrations.netlify) {
5353
5362
  throw new UnauthorizeApiError("netlify");
5354
5363
  }
5355
- if (((_B = options.ensureAuthorizationToken) == null ? void 0 : _B.planetscale) && !headers.integrations.planetscale) {
5364
+ if (((_D = options.ensureAuthorizationToken) == null ? void 0 : _D.planetscale) && !headers.integrations.planetscale) {
5356
5365
  throw new UnauthorizeApiError("planetscale");
5357
5366
  }
5358
- if (((_C = options.ensureAuthorizationToken) == null ? void 0 : _C.neon) && !headers.integrations.neon) {
5367
+ if (((_E = options.ensureAuthorizationToken) == null ? void 0 : _E.neon) && !headers.integrations.neon) {
5359
5368
  throw new UnauthorizeApiError("neon");
5360
5369
  }
5361
- if (((_D = options.ensureAuthorizationToken) == null ? void 0 : _D.mailchimp) && (!headers.integrations.mailchimp || !headers.integrations.mailchimpServer)) {
5370
+ if (((_F = options.ensureAuthorizationToken) == null ? void 0 : _F.mailchimp) && (!headers.integrations.mailchimp || !headers.integrations.mailchimpServer)) {
5362
5371
  throw new UnauthorizeApiError("mailchimp");
5363
5372
  }
5364
- if (((_E = options.ensureAuthorizationToken) == null ? void 0 : _E.shopify) && (!headers.integrations.shopify || !headers.integrations.shopifyShop)) {
5373
+ if (((_G = options.ensureAuthorizationToken) == null ? void 0 : _G.shopify) && (!headers.integrations.shopify || !headers.integrations.shopifyShop)) {
5365
5374
  throw new UnauthorizeApiError("shopify");
5366
5375
  }
5376
+ if (((_H = options.ensureAuthorizationToken) == null ? void 0 : _H.text) && !headers.integrations.text) {
5377
+ throw new UnauthorizeApiError("text");
5378
+ }
5367
5379
  return {
5368
- headers: __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, headers.platform.token ? { "x-adapter-platform-token": headers.platform.token } : {}), headers.integrations.github.app ? { "x-adapter-github-app-token": headers.integrations.github.app } : {}), headers.integrations.github.oauth ? { "x-adapter-github-oauth-token": headers.integrations.github.oauth } : {}), headers.integrations.netlify ? { "x-adapter-netlify-token": headers.integrations.netlify } : {}), headers.integrations.vercel ? { "x-adapter-vercel-token": headers.integrations.vercel } : {}), headers.integrations.planetscale ? { "x-adapter-planetscale-token": headers.integrations.planetscale } : {}), headers.integrations.neon ? { "x-adapter-neon-token": headers.integrations.neon } : {}), headers.integrations.mailchimp ? { "x-adapter-mailchimp-token": headers.integrations.mailchimp } : {}), headers.integrations.mailchimpServer ? { "x-adapter-mailchimp-server": headers.integrations.mailchimpServer } : {}), headers.integrations.shopify ? { "x-adapter-shopify-token": headers.integrations.shopify } : {}), headers.integrations.shopifyShop ? { "x-adapter-shopify-shop": headers.integrations.shopifyShop } : {})
5380
+ headers: __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, headers.platform.token ? { "x-adapter-platform-token": headers.platform.token } : {}), headers.integrations.github.app ? { "x-adapter-github-app-token": headers.integrations.github.app } : {}), headers.integrations.github.oauth ? { "x-adapter-github-oauth-token": headers.integrations.github.oauth } : {}), headers.integrations.netlify ? { "x-adapter-netlify-token": headers.integrations.netlify } : {}), headers.integrations.vercel ? { "x-adapter-vercel-token": headers.integrations.vercel } : {}), headers.integrations.planetscale ? { "x-adapter-planetscale-token": headers.integrations.planetscale } : {}), headers.integrations.neon ? { "x-adapter-neon-token": headers.integrations.neon } : {}), headers.integrations.mailchimp ? { "x-adapter-mailchimp-token": headers.integrations.mailchimp } : {}), headers.integrations.mailchimpServer ? { "x-adapter-mailchimp-server": headers.integrations.mailchimpServer } : {}), headers.integrations.shopify ? { "x-adapter-shopify-token": headers.integrations.shopify } : {}), headers.integrations.shopifyShop ? { "x-adapter-shopify-shop": headers.integrations.shopifyShop } : {}), headers.integrations.text ? { "x-adapter-text-token": headers.integrations.text } : {})
5369
5381
  };
5370
5382
  }
5371
5383
  var getPlatformAdapterClientDefaultConfig = (authorization) => getPlatformAdapterClientConfig(__spreadProps(__spreadValues({}, authorization), {
@@ -5388,7 +5400,7 @@ function initPlatformAdapterClient(baseUrl, tokens) {
5388
5400
  }
5389
5401
  }
5390
5402
  function updatePlatformAdapterClient(tokens) {
5391
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
5403
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
5392
5404
  const headers = platformAdapterClientInstance.defaults.headers;
5393
5405
  if ((_a = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _a.token) {
5394
5406
  headers["x-adapter-platform-token"] = tokens.platform.token;
@@ -5423,6 +5435,9 @@ function updatePlatformAdapterClient(tokens) {
5423
5435
  if ((_k = tokens == null ? void 0 : tokens.shopify) == null ? void 0 : _k.token) {
5424
5436
  headers["x-adapter-shopify-token"] = tokens.shopify.token;
5425
5437
  }
5438
+ if ((_l = tokens == null ? void 0 : tokens.text) == null ? void 0 : _l.token) {
5439
+ headers["x-adapter-text-token"] = tokens.text.token;
5440
+ }
5426
5441
  }
5427
5442
 
5428
5443
  // src/apis/platform/adapter/app/blocks/authorization/api.ts
@@ -5952,6 +5967,182 @@ function initPlatformBillingClient(baseUrl, token) {
5952
5967
  }
5953
5968
  }
5954
5969
 
5970
+ // src/apis/platform/adapter/integrations/_contracts/requests/events.ts
5971
+ import { z as z4 } from "zod";
5972
+
5973
+ // src/apis/platform/adapter/integrations/shopify/_contracts/dtos/events.ts
5974
+ var ShopifyEvents = /* @__PURE__ */ ((ShopifyEvents2) => {
5975
+ ShopifyEvents2["OrdersCreate"] = "orders/create";
5976
+ return ShopifyEvents2;
5977
+ })(ShopifyEvents || {});
5978
+
5979
+ // src/apis/platform/adapter/integrations/shopify/_contracts/requests/events.ts
5980
+ import { z } from "zod";
5981
+ var shopifyEventsZods = {
5982
+ event: z.nativeEnum(ShopifyEvents),
5983
+ get body() {
5984
+ return z.object({
5985
+ event: this.event
5986
+ });
5987
+ },
5988
+ get provider() {
5989
+ return z.object({
5990
+ provider: z.literal("shopify"),
5991
+ event: this.event
5992
+ });
5993
+ },
5994
+ get source() {
5995
+ return z.object({
5996
+ sourceName: z.enum(["apps", "workflows"]),
5997
+ sourceKey: z.string()
5998
+ });
5999
+ },
6000
+ get subscribe() {
6001
+ return this.source.and(this.body).and(
6002
+ z.object({
6003
+ callback: z.string()
6004
+ })
6005
+ );
6006
+ },
6007
+ get unsubscribe() {
6008
+ return this.source.and(this.body);
6009
+ }
6010
+ };
6011
+
6012
+ // src/apis/platform/adapter/integrations/mailchimp/_contracts/requests/events.ts
6013
+ import { z as z2 } from "zod";
6014
+
6015
+ // src/apis/platform/adapter/integrations/mailchimp/_contracts/dtos/events.ts
6016
+ var MailchimpEvents = /* @__PURE__ */ ((MailchimpEvents2) => {
6017
+ MailchimpEvents2["Subscribe"] = "subscribe";
6018
+ MailchimpEvents2["Unsubscribe"] = "unsubscribe";
6019
+ return MailchimpEvents2;
6020
+ })(MailchimpEvents || {});
6021
+
6022
+ // src/apis/platform/adapter/integrations/mailchimp/_contracts/requests/events.ts
6023
+ var mailchimpEventsZods = {
6024
+ event: z2.nativeEnum(MailchimpEvents),
6025
+ get body() {
6026
+ return z2.object({
6027
+ event: this.event,
6028
+ listId: z2.string()
6029
+ });
6030
+ },
6031
+ get provider() {
6032
+ return z2.object({
6033
+ provider: z2.literal("mailchimp"),
6034
+ event: this.event,
6035
+ listId: z2.string()
6036
+ });
6037
+ },
6038
+ get source() {
6039
+ return z2.object({
6040
+ sourceName: z2.enum(["apps", "workflows"]),
6041
+ sourceKey: z2.string()
6042
+ });
6043
+ },
6044
+ get subscribe() {
6045
+ return this.source.and(this.body).and(
6046
+ z2.object({
6047
+ callback: z2.string()
6048
+ })
6049
+ );
6050
+ },
6051
+ get unsubscribe() {
6052
+ return this.source.and(this.body);
6053
+ }
6054
+ };
6055
+
6056
+ // src/apis/platform/adapter/integrations/text/_contracts/dtos/events.ts
6057
+ var TextLivechatEvents = /* @__PURE__ */ ((TextLivechatEvents2) => {
6058
+ TextLivechatEvents2["IncomingChat"] = "incoming_chat";
6059
+ return TextLivechatEvents2;
6060
+ })(TextLivechatEvents || {});
6061
+
6062
+ // src/apis/platform/adapter/integrations/text/_contracts/requests/events.ts
6063
+ import { z as z3 } from "zod";
6064
+ var textLivechatEventsZods = {
6065
+ event: z3.nativeEnum(TextLivechatEvents),
6066
+ get body() {
6067
+ return z3.object({
6068
+ event: this.event
6069
+ });
6070
+ },
6071
+ get provider() {
6072
+ return z3.object({
6073
+ provider: z3.literal("text-livechat"),
6074
+ event: this.event
6075
+ });
6076
+ },
6077
+ get source() {
6078
+ return z3.object({
6079
+ sourceName: z3.enum(["apps", "workflows"]),
6080
+ sourceKey: z3.string()
6081
+ });
6082
+ },
6083
+ get subscribe() {
6084
+ return this.source.and(this.body).and(
6085
+ z3.object({
6086
+ callback: z3.string()
6087
+ })
6088
+ );
6089
+ },
6090
+ get unsubscribe() {
6091
+ return this.source.and(this.body);
6092
+ }
6093
+ };
6094
+
6095
+ // src/apis/platform/adapter/integrations/_contracts/requests/events.ts
6096
+ var integrationEventsZods = {
6097
+ sourceName: z4.enum(["apps", "workflows"]),
6098
+ providerName: z4.enum(["text-livechat", "mailchimp", "shopify"]),
6099
+ get source() {
6100
+ return z4.object({
6101
+ sourceName: this.sourceName,
6102
+ sourceKey: z4.string()
6103
+ });
6104
+ },
6105
+ provider: z4.discriminatedUnion("provider", [
6106
+ textLivechatEventsZods.provider,
6107
+ mailchimpEventsZods.provider,
6108
+ shopifyEventsZods.provider
6109
+ ]),
6110
+ get subscribe() {
6111
+ return this.source.and(this.provider).and(
6112
+ z4.object({
6113
+ callback: z4.string()
6114
+ })
6115
+ );
6116
+ },
6117
+ get unsubscribe() {
6118
+ return this.source.and(this.provider);
6119
+ }
6120
+ };
6121
+
6122
+ // src/apis/platform/adapter/integrations/mailchimp/api.ts
6123
+ var platformAdapterMailchimpApi = {
6124
+ events: {
6125
+ subscribe(payload, authorization) {
6126
+ return __async(this, null, function* () {
6127
+ yield platformAdapterClientInstance.post(
6128
+ `/integrations/mailchimp/events/subscribe`,
6129
+ payload,
6130
+ getMailchimpClientConfig(authorization)
6131
+ );
6132
+ });
6133
+ },
6134
+ unsubscribe(payload, authorization) {
6135
+ return __async(this, null, function* () {
6136
+ yield platformAdapterClientInstance.post(
6137
+ `/integrations/mailchimp/events/unsubscribe`,
6138
+ payload,
6139
+ getMailchimpClientConfig(authorization)
6140
+ );
6141
+ });
6142
+ }
6143
+ }
6144
+ };
6145
+
5955
6146
  // src/apis/platform/adapter/integrations/neon/api.ts
5956
6147
  var platformAdapterNeonProxyApi = {
5957
6148
  user(authorization) {
@@ -5989,15 +6180,66 @@ var platformAdapterNeonProxyApi = {
5989
6180
  }
5990
6181
  };
5991
6182
 
6183
+ // src/apis/platform/adapter/integrations/shopify/api.ts
6184
+ var platformAdapterShopifyApi = {
6185
+ events: {
6186
+ subscribe(payload, authorization) {
6187
+ return __async(this, null, function* () {
6188
+ yield platformAdapterClientInstance.post(
6189
+ `/integrations/shopify/events/subscribe`,
6190
+ payload,
6191
+ getShopifyClientConfig(authorization)
6192
+ );
6193
+ });
6194
+ },
6195
+ unsubscribe(payload, authorization) {
6196
+ return __async(this, null, function* () {
6197
+ yield platformAdapterClientInstance.post(
6198
+ `/integrations/shopify/events/unsubscribe`,
6199
+ payload,
6200
+ getShopifyClientConfig(authorization)
6201
+ );
6202
+ });
6203
+ }
6204
+ }
6205
+ };
6206
+
6207
+ // src/apis/platform/adapter/integrations/text/api.ts
6208
+ var platformAdapterTextApi = {
6209
+ events: {
6210
+ subscribe(payload, authorization) {
6211
+ return __async(this, null, function* () {
6212
+ yield platformAdapterClientInstance.post(
6213
+ `/integrations/text/events/subscribe`,
6214
+ payload,
6215
+ getTextClientConfig(authorization)
6216
+ );
6217
+ });
6218
+ },
6219
+ unsubscribe(payload, authorization) {
6220
+ return __async(this, null, function* () {
6221
+ yield platformAdapterClientInstance.post(
6222
+ `/integrations/text/events/unsubscribe`,
6223
+ payload,
6224
+ getTextClientConfig(authorization)
6225
+ );
6226
+ });
6227
+ }
6228
+ }
6229
+ };
6230
+
5992
6231
  // src/apis/platform/adapter/integrations/api.ts
5993
- var platformAdapterIntegrationsProxyApi = {
5994
- neon: platformAdapterNeonProxyApi
6232
+ var platformAdapterIntegrationsApi = {
6233
+ neon: platformAdapterNeonProxyApi,
6234
+ text: platformAdapterTextApi,
6235
+ mailchimp: platformAdapterMailchimpApi,
6236
+ shopify: platformAdapterShopifyApi
5995
6237
  };
5996
6238
 
5997
6239
  // src/apis/platform/adapter/api.ts
5998
6240
  var platformAdapterApi = {
5999
6241
  app: platformAdapterAppApi,
6000
- proxy: platformAdapterIntegrationsProxyApi,
6242
+ integrations: platformAdapterIntegrationsApi,
6001
6243
  log(payload, authorization) {
6002
6244
  return __async(this, null, function* () {
6003
6245
  return platformAdapterClientInstance.post(
@@ -6178,7 +6420,10 @@ export {
6178
6420
  DpsApiError,
6179
6421
  LivechatApiError,
6180
6422
  MailchimpApiError,
6423
+ MailchimpEvents,
6181
6424
  ShopifyApiError,
6425
+ ShopifyEvents,
6426
+ TextLivechatEvents,
6182
6427
  UnauthorizeApiError,
6183
6428
  WorkflowDefinitionTaskType,
6184
6429
  allAppTemplates,
@@ -6237,8 +6482,10 @@ export {
6237
6482
  initShopifyClient,
6238
6483
  initTextClient,
6239
6484
  initVercelClient,
6485
+ integrationEventsZods,
6240
6486
  livechatClientInstance,
6241
6487
  mailchimpClientInstance,
6488
+ mailchimpEventsZods,
6242
6489
  neonClientInstance,
6243
6490
  netlifyClientInstance,
6244
6491
  planetScaleClientInstance,
@@ -6247,7 +6494,9 @@ export {
6247
6494
  platformBillingClientInstance,
6248
6495
  platformDpsClientInstance,
6249
6496
  shopifyClientInstance,
6497
+ shopifyEventsZods,
6250
6498
  textClientInstance,
6499
+ textLivechatEventsZods,
6251
6500
  updateGithubClient,
6252
6501
  updateMailchimpClient,
6253
6502
  updateNeonClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livechat/developer-studio-api",
3
- "version": "3.0.53",
3
+ "version": "3.0.55",
4
4
  "description": "This project is API for LiveChat Developer Studio.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -13,7 +13,8 @@
13
13
  "dependencies": {
14
14
  "@shopify/shopify-api": "^11.0.0",
15
15
  "axios": "1.6.5",
16
- "shopify-api-node": "^3.13.1"
16
+ "shopify-api-node": "^3.13.1",
17
+ "zod": "^3.23.8"
17
18
  },
18
19
  "devDependencies": {
19
20
  "@types/node": "^17.0.12",