@livechat/developer-studio-api 3.1.0 → 3.1.2

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.js CHANGED
@@ -75,12 +75,15 @@ __export(src_exports, {
75
75
  DpsApiError: () => DpsApiError,
76
76
  LivechatApiError: () => LivechatApiError,
77
77
  MailchimpApiError: () => MailchimpApiError,
78
- MailchimpEvents: () => MailchimpEvents,
78
+ MailchimpEventNames: () => MailchimpEventNames,
79
79
  ShopifyApiError: () => ShopifyApiError,
80
- ShopifyEvents: () => ShopifyEvents,
81
- TextLivechatEvents: () => TextLivechatEvents,
80
+ ShopifyEventNames: () => ShopifyEventNames,
81
+ TextLivechatEventNames: () => TextLivechatEventNames,
82
82
  UnauthorizeAccountsApiError: () => UnauthorizeAccountsApiError,
83
83
  UnauthorizeApiError: () => UnauthorizeApiError,
84
+ WebhookActions: () => WebhookActions,
85
+ WebhookEvents: () => WebhookEvents,
86
+ WebhookSystemMessages: () => WebhookSystemMessages,
84
87
  WorkflowDefinitionTaskType: () => WorkflowDefinitionTaskType,
85
88
  allAppTemplates: () => allAppTemplates,
86
89
  api: () => api,
@@ -1445,17 +1448,15 @@ var import_axios8 = __toESM(require("axios"));
1445
1448
  var textClientInstance = import_axios8.default.create({
1446
1449
  baseURL: "https://api.labs.text.com"
1447
1450
  });
1448
- function getTextClientAuthorization(req, useIntegration) {
1451
+ function getTextClientAuthorization(req) {
1449
1452
  if (req.headers instanceof Headers) {
1450
1453
  return {
1451
- token: req.headers.get(
1452
- useIntegration ? "x-adapter-text-token" : "x-adapter-platform-token"
1453
- ),
1454
+ token: req.headers.get("x-adapter-text-token"),
1454
1455
  tokenType: "Bearer"
1455
1456
  };
1456
1457
  }
1457
1458
  return {
1458
- token: req.headers[useIntegration ? "x-adapter-text-token" : "x-adapter-platform-token"],
1459
+ token: req.headers["x-adapter-text-token"],
1459
1460
  tokenType: "Bearer"
1460
1461
  };
1461
1462
  }
@@ -6178,25 +6179,23 @@ function initPlatformBillingClient(baseUrl, token) {
6178
6179
  var import_zod4 = require("zod");
6179
6180
 
6180
6181
  // src/apis/platform/adapter/integrations/shopify/_contracts/dtos/events.ts
6181
- var ShopifyEvents = /* @__PURE__ */ ((ShopifyEvents2) => {
6182
- ShopifyEvents2["OrdersCreate"] = "orders/create";
6183
- return ShopifyEvents2;
6184
- })(ShopifyEvents || {});
6182
+ var ShopifyEventNames = /* @__PURE__ */ ((ShopifyEventNames2) => {
6183
+ ShopifyEventNames2["OrderCreated"] = "order_created";
6184
+ return ShopifyEventNames2;
6185
+ })(ShopifyEventNames || {});
6185
6186
 
6186
6187
  // src/apis/platform/adapter/integrations/shopify/_contracts/requests/events.ts
6187
6188
  var import_zod = require("zod");
6188
6189
  var shopifyEventsZods = {
6189
- event: import_zod.z.nativeEnum(ShopifyEvents),
6190
- get body() {
6191
- return import_zod.z.object({
6192
- event: this.event
6193
- });
6190
+ provider: import_zod.z.literal("shopify"),
6191
+ eventName: import_zod.z.nativeEnum(ShopifyEventNames),
6192
+ events: {
6193
+ orderCreated: import_zod.z.object({
6194
+ name: import_zod.z.literal("order_created" /* OrderCreated */)
6195
+ })
6194
6196
  },
6195
- get provider() {
6196
- return import_zod.z.object({
6197
- provider: import_zod.z.literal("shopify"),
6198
- event: this.event
6199
- });
6197
+ get event() {
6198
+ return import_zod.z.discriminatedUnion("name", [this.events.orderCreated]);
6200
6199
  },
6201
6200
  get source() {
6202
6201
  return import_zod.z.object({
@@ -6205,14 +6204,32 @@ var shopifyEventsZods = {
6205
6204
  });
6206
6205
  },
6207
6206
  get subscribe() {
6208
- return this.source.and(this.body).and(
6207
+ return this.source.and(
6209
6208
  import_zod.z.object({
6209
+ event: this.event,
6210
6210
  callback: import_zod.z.string()
6211
6211
  })
6212
6212
  );
6213
6213
  },
6214
+ get subscribeContent() {
6215
+ return import_zod.z.object({
6216
+ provider: this.provider,
6217
+ event: this.event,
6218
+ callback: import_zod.z.string()
6219
+ });
6220
+ },
6214
6221
  get unsubscribe() {
6215
- return this.source.and(this.body);
6222
+ return this.source.and(
6223
+ import_zod.z.object({
6224
+ event: this.eventName
6225
+ })
6226
+ );
6227
+ },
6228
+ get unsubscribeContent() {
6229
+ return import_zod.z.object({
6230
+ provider: this.provider,
6231
+ event: this.eventName
6232
+ });
6216
6233
  }
6217
6234
  };
6218
6235
 
@@ -6220,27 +6237,29 @@ var shopifyEventsZods = {
6220
6237
  var import_zod2 = require("zod");
6221
6238
 
6222
6239
  // src/apis/platform/adapter/integrations/mailchimp/_contracts/dtos/events.ts
6223
- var MailchimpEvents = /* @__PURE__ */ ((MailchimpEvents2) => {
6224
- MailchimpEvents2["Subscribe"] = "subscribe";
6225
- MailchimpEvents2["Unsubscribe"] = "unsubscribe";
6226
- return MailchimpEvents2;
6227
- })(MailchimpEvents || {});
6240
+ var MailchimpEventNames = /* @__PURE__ */ ((MailchimpEventNames2) => {
6241
+ MailchimpEventNames2["Subscribed"] = "subscribed";
6242
+ MailchimpEventNames2["Unsubscribed"] = "unsubscribed";
6243
+ return MailchimpEventNames2;
6244
+ })(MailchimpEventNames || {});
6228
6245
 
6229
6246
  // src/apis/platform/adapter/integrations/mailchimp/_contracts/requests/events.ts
6230
6247
  var mailchimpEventsZods = {
6231
- event: import_zod2.z.nativeEnum(MailchimpEvents),
6232
- get body() {
6233
- return import_zod2.z.object({
6234
- event: this.event,
6235
- listId: import_zod2.z.string()
6236
- });
6237
- },
6238
- get provider() {
6239
- return import_zod2.z.object({
6240
- provider: import_zod2.z.literal("mailchimp"),
6241
- event: this.event,
6242
- listId: import_zod2.z.string()
6243
- });
6248
+ provider: import_zod2.z.literal("mailchimp"),
6249
+ eventName: import_zod2.z.nativeEnum(MailchimpEventNames),
6250
+ events: {
6251
+ subscribed: import_zod2.z.object({
6252
+ name: import_zod2.z.literal("subscribed" /* Subscribed */)
6253
+ }),
6254
+ unsubscribed: import_zod2.z.object({
6255
+ name: import_zod2.z.literal("unsubscribed" /* Unsubscribed */)
6256
+ })
6257
+ },
6258
+ get event() {
6259
+ return import_zod2.z.discriminatedUnion("name", [
6260
+ this.events.subscribed,
6261
+ this.events.unsubscribed
6262
+ ]);
6244
6263
  },
6245
6264
  get source() {
6246
6265
  return import_zod2.z.object({
@@ -6249,39 +6268,100 @@ var mailchimpEventsZods = {
6249
6268
  });
6250
6269
  },
6251
6270
  get subscribe() {
6252
- return this.source.and(this.body).and(
6271
+ return this.source.and(
6253
6272
  import_zod2.z.object({
6273
+ event: this.event,
6274
+ listId: import_zod2.z.string(),
6254
6275
  callback: import_zod2.z.string()
6255
6276
  })
6256
6277
  );
6257
6278
  },
6279
+ get subscribeContent() {
6280
+ return import_zod2.z.object({
6281
+ provider: this.provider,
6282
+ event: this.event,
6283
+ callback: import_zod2.z.string(),
6284
+ listId: import_zod2.z.string()
6285
+ });
6286
+ },
6258
6287
  get unsubscribe() {
6259
- return this.source.and(this.body);
6288
+ return this.source.and(
6289
+ import_zod2.z.object({
6290
+ event: this.eventName,
6291
+ listId: import_zod2.z.string()
6292
+ })
6293
+ );
6294
+ },
6295
+ get unsubscribeContent() {
6296
+ return import_zod2.z.object({
6297
+ provider: this.provider,
6298
+ event: this.eventName,
6299
+ listId: import_zod2.z.string()
6300
+ });
6260
6301
  }
6261
6302
  };
6262
6303
 
6263
6304
  // src/apis/platform/adapter/integrations/text/_contracts/dtos/events.ts
6264
- var TextLivechatEvents = /* @__PURE__ */ ((TextLivechatEvents2) => {
6265
- TextLivechatEvents2["IncomingChat"] = "incoming_chat";
6266
- TextLivechatEvents2["IncomingEvent"] = "incoming_event";
6267
- TextLivechatEvents2["IncomingCustomer"] = "incoming_customer";
6268
- return TextLivechatEvents2;
6269
- })(TextLivechatEvents || {});
6305
+ var TextLivechatEventNames = /* @__PURE__ */ ((TextLivechatEventNames2) => {
6306
+ TextLivechatEventNames2["ChatStarted"] = "chat_started";
6307
+ TextLivechatEventNames2["ChatEnded"] = "chat_ended";
6308
+ TextLivechatEventNames2["ChatTransferred"] = "chat_transferred";
6309
+ TextLivechatEventNames2["ChatRated"] = "chat_rated";
6310
+ TextLivechatEventNames2["ChatCommented"] = "chat_commented";
6311
+ TextLivechatEventNames2["ChatMessage"] = "chat_message";
6312
+ TextLivechatEventNames2["UserAddedToChat"] = "user_added_to_chat";
6313
+ TextLivechatEventNames2["UserRemovedFromChat"] = "user_removed_from_chat";
6314
+ return TextLivechatEventNames2;
6315
+ })(TextLivechatEventNames || {});
6270
6316
 
6271
6317
  // src/apis/platform/adapter/integrations/text/_contracts/requests/events.ts
6272
6318
  var import_zod3 = require("zod");
6273
6319
  var textLivechatEventsZods = {
6274
- event: import_zod3.z.nativeEnum(TextLivechatEvents),
6275
- get body() {
6276
- return import_zod3.z.object({
6277
- event: this.event
6278
- });
6279
- },
6280
- get provider() {
6281
- return import_zod3.z.object({
6282
- provider: import_zod3.z.literal("text-livechat"),
6283
- event: this.event
6284
- });
6320
+ provider: import_zod3.z.literal("text-livechat"),
6321
+ eventName: import_zod3.z.nativeEnum(TextLivechatEventNames),
6322
+ events: {
6323
+ chatStarted: import_zod3.z.object({
6324
+ name: import_zod3.z.literal("chat_started" /* ChatStarted */)
6325
+ }),
6326
+ chatEnded: import_zod3.z.object({
6327
+ name: import_zod3.z.literal("chat_ended" /* ChatEnded */)
6328
+ }),
6329
+ chatTransferred: import_zod3.z.object({
6330
+ name: import_zod3.z.literal("chat_transferred" /* ChatTransferred */)
6331
+ }),
6332
+ chatRated: import_zod3.z.object({
6333
+ name: import_zod3.z.literal("chat_rated" /* ChatRated */)
6334
+ }),
6335
+ chatCommented: import_zod3.z.object({
6336
+ name: import_zod3.z.literal("chat_commented" /* ChatCommented */)
6337
+ }),
6338
+ chatMessage: import_zod3.z.object({
6339
+ name: import_zod3.z.literal("chat_message" /* ChatMessage */),
6340
+ params: import_zod3.z.object({
6341
+ filter: import_zod3.z.string().optional()
6342
+ }).optional()
6343
+ }),
6344
+ userAddedToChat: import_zod3.z.object({
6345
+ name: import_zod3.z.literal("user_added_to_chat" /* UserAddedToChat */),
6346
+ params: import_zod3.z.object({
6347
+ userType: import_zod3.z.enum(["agent", "customer"]).optional()
6348
+ }).optional()
6349
+ }),
6350
+ userRemovedFromChat: import_zod3.z.object({
6351
+ name: import_zod3.z.literal("user_removed_from_chat" /* UserRemovedFromChat */)
6352
+ })
6353
+ },
6354
+ get event() {
6355
+ return import_zod3.z.discriminatedUnion("name", [
6356
+ this.events.chatStarted,
6357
+ this.events.chatEnded,
6358
+ this.events.chatTransferred,
6359
+ this.events.chatRated,
6360
+ this.events.chatCommented,
6361
+ this.events.chatMessage,
6362
+ this.events.userAddedToChat,
6363
+ this.events.userRemovedFromChat
6364
+ ]);
6285
6365
  },
6286
6366
  get source() {
6287
6367
  return import_zod3.z.object({
@@ -6290,14 +6370,32 @@ var textLivechatEventsZods = {
6290
6370
  });
6291
6371
  },
6292
6372
  get subscribe() {
6293
- return this.source.and(this.body).and(
6373
+ return this.source.and(
6294
6374
  import_zod3.z.object({
6375
+ event: this.event,
6295
6376
  callback: import_zod3.z.string()
6296
6377
  })
6297
6378
  );
6298
6379
  },
6380
+ get subscribeContent() {
6381
+ return import_zod3.z.object({
6382
+ provider: this.provider,
6383
+ event: this.event,
6384
+ callback: import_zod3.z.string()
6385
+ });
6386
+ },
6299
6387
  get unsubscribe() {
6300
- return this.source.and(this.body);
6388
+ return this.source.and(
6389
+ import_zod3.z.object({
6390
+ event: this.eventName
6391
+ })
6392
+ );
6393
+ },
6394
+ get unsubscribeContent() {
6395
+ return import_zod3.z.object({
6396
+ provider: this.provider,
6397
+ event: this.eventName
6398
+ });
6301
6399
  }
6302
6400
  };
6303
6401
 
@@ -6305,29 +6403,59 @@ var textLivechatEventsZods = {
6305
6403
  var integrationEventsZods = {
6306
6404
  sourceName: import_zod4.z.enum(["apps", "workflows"]),
6307
6405
  providerName: import_zod4.z.enum(["text-livechat", "mailchimp", "shopify"]),
6406
+ get event() {
6407
+ return textLivechatEventsZods.event.or(shopifyEventsZods.event).or(mailchimpEventsZods.event);
6408
+ },
6308
6409
  get source() {
6309
6410
  return import_zod4.z.object({
6310
6411
  sourceName: this.sourceName,
6311
6412
  sourceKey: import_zod4.z.string()
6312
6413
  });
6313
6414
  },
6314
- provider: import_zod4.z.discriminatedUnion("provider", [
6315
- textLivechatEventsZods.provider,
6316
- mailchimpEventsZods.provider,
6317
- shopifyEventsZods.provider
6318
- ]),
6319
6415
  get subscribe() {
6320
- return this.source.and(this.provider).and(
6321
- import_zod4.z.object({
6322
- callback: import_zod4.z.string()
6323
- })
6416
+ return this.source.and(
6417
+ import_zod4.z.discriminatedUnion("provider", [
6418
+ textLivechatEventsZods.subscribeContent,
6419
+ shopifyEventsZods.subscribeContent,
6420
+ mailchimpEventsZods.subscribeContent
6421
+ ])
6324
6422
  );
6325
6423
  },
6326
6424
  get unsubscribe() {
6327
- return this.source.and(this.provider);
6425
+ return this.source.and(
6426
+ import_zod4.z.discriminatedUnion("provider", [
6427
+ textLivechatEventsZods.unsubscribeContent,
6428
+ shopifyEventsZods.unsubscribeContent,
6429
+ mailchimpEventsZods.unsubscribeContent
6430
+ ])
6431
+ );
6328
6432
  }
6329
6433
  };
6330
6434
 
6435
+ // src/apis/products/livechat/configuration/webhooks/_contracts/dtos/webhook.ts
6436
+ var WebhookActions = /* @__PURE__ */ ((WebhookActions2) => {
6437
+ WebhookActions2["IncomingChat"] = "incoming_chat";
6438
+ WebhookActions2["ChatDeactivated"] = "chat_deactivated";
6439
+ WebhookActions2["ChatAccessUpdated"] = "chat_access_updated";
6440
+ WebhookActions2["ChatTransferred"] = "chat_transferred";
6441
+ WebhookActions2["UserAddedToChat"] = "user_added_to_chat";
6442
+ WebhookActions2["UserRemovedFromChat"] = "user_removed_from_chat";
6443
+ WebhookActions2["IncomingEvent"] = "incoming_event";
6444
+ WebhookActions2["IncomingCustomer"] = "incoming_customer";
6445
+ return WebhookActions2;
6446
+ })(WebhookActions || {});
6447
+ var WebhookEvents = /* @__PURE__ */ ((WebhookEvents2) => {
6448
+ WebhookEvents2["Message"] = "message";
6449
+ WebhookEvents2["SystemMessage"] = "system_message";
6450
+ WebhookEvents2["Custom"] = "custom";
6451
+ return WebhookEvents2;
6452
+ })(WebhookEvents || {});
6453
+ var WebhookSystemMessages = /* @__PURE__ */ ((WebhookSystemMessages2) => {
6454
+ WebhookSystemMessages2["ChatRated"] = "rating.chat_rated";
6455
+ WebhookSystemMessages2["ChatCommented"] = "rating.chat_commented";
6456
+ return WebhookSystemMessages2;
6457
+ })(WebhookSystemMessages || {});
6458
+
6331
6459
  // src/apis/platform/adapter/integrations/mailchimp/api.ts
6332
6460
  var platformAdapterMailchimpApi = {
6333
6461
  events: {
@@ -6631,12 +6759,15 @@ function getIntegrationFlowUrl(provider, flow, data, context, config) {
6631
6759
  DpsApiError,
6632
6760
  LivechatApiError,
6633
6761
  MailchimpApiError,
6634
- MailchimpEvents,
6762
+ MailchimpEventNames,
6635
6763
  ShopifyApiError,
6636
- ShopifyEvents,
6637
- TextLivechatEvents,
6764
+ ShopifyEventNames,
6765
+ TextLivechatEventNames,
6638
6766
  UnauthorizeAccountsApiError,
6639
6767
  UnauthorizeApiError,
6768
+ WebhookActions,
6769
+ WebhookEvents,
6770
+ WebhookSystemMessages,
6640
6771
  WorkflowDefinitionTaskType,
6641
6772
  allAppTemplates,
6642
6773
  api,