@livechat/developer-studio-api 3.1.1 → 3.1.3

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,
@@ -251,7 +254,7 @@ var ApiClient = class {
251
254
  return __async(this, null, function* () {
252
255
  return this.fetch(url, customConfig, __spreadProps(__spreadValues({}, customOptions), {
253
256
  method: "POST",
254
- body: JSON.stringify(body)
257
+ body: body instanceof URLSearchParams ? body : JSON.stringify(body)
255
258
  }));
256
259
  });
257
260
  }
@@ -259,7 +262,7 @@ var ApiClient = class {
259
262
  return __async(this, null, function* () {
260
263
  return this.fetch(url, customConfig, __spreadProps(__spreadValues({}, customOptions), {
261
264
  method: "PATCH",
262
- body: JSON.stringify(body)
265
+ body: body instanceof URLSearchParams ? body : JSON.stringify(body)
263
266
  }));
264
267
  });
265
268
  }
@@ -267,7 +270,7 @@ var ApiClient = class {
267
270
  return __async(this, null, function* () {
268
271
  return this.fetch(url, customConfig, __spreadProps(__spreadValues({}, customOptions), {
269
272
  method: "PUT",
270
- body: JSON.stringify(body)
273
+ body: body instanceof URLSearchParams ? body : JSON.stringify(body)
271
274
  }));
272
275
  });
273
276
  }
@@ -275,7 +278,7 @@ var ApiClient = class {
275
278
  return __async(this, null, function* () {
276
279
  return this.fetch(url, config, __spreadProps(__spreadValues({}, options), {
277
280
  method: "DELETE",
278
- body: JSON.stringify(body)
281
+ body: body instanceof URLSearchParams ? body : JSON.stringify(body)
279
282
  }));
280
283
  });
281
284
  }
@@ -6176,25 +6179,23 @@ function initPlatformBillingClient(baseUrl, token) {
6176
6179
  var import_zod4 = require("zod");
6177
6180
 
6178
6181
  // src/apis/platform/adapter/integrations/shopify/_contracts/dtos/events.ts
6179
- var ShopifyEvents = /* @__PURE__ */ ((ShopifyEvents2) => {
6180
- ShopifyEvents2["OrdersCreate"] = "orders/create";
6181
- return ShopifyEvents2;
6182
- })(ShopifyEvents || {});
6182
+ var ShopifyEventNames = /* @__PURE__ */ ((ShopifyEventNames2) => {
6183
+ ShopifyEventNames2["OrderCreated"] = "order_created";
6184
+ return ShopifyEventNames2;
6185
+ })(ShopifyEventNames || {});
6183
6186
 
6184
6187
  // src/apis/platform/adapter/integrations/shopify/_contracts/requests/events.ts
6185
6188
  var import_zod = require("zod");
6186
6189
  var shopifyEventsZods = {
6187
- event: import_zod.z.nativeEnum(ShopifyEvents),
6188
- get body() {
6189
- return import_zod.z.object({
6190
- event: this.event
6191
- });
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
+ })
6192
6196
  },
6193
- get provider() {
6194
- return import_zod.z.object({
6195
- provider: import_zod.z.literal("shopify"),
6196
- event: this.event
6197
- });
6197
+ get event() {
6198
+ return import_zod.z.discriminatedUnion("name", [this.events.orderCreated]);
6198
6199
  },
6199
6200
  get source() {
6200
6201
  return import_zod.z.object({
@@ -6203,14 +6204,32 @@ var shopifyEventsZods = {
6203
6204
  });
6204
6205
  },
6205
6206
  get subscribe() {
6206
- return this.source.and(this.body).and(
6207
+ return this.source.and(
6207
6208
  import_zod.z.object({
6209
+ event: this.event,
6208
6210
  callback: import_zod.z.string()
6209
6211
  })
6210
6212
  );
6211
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
+ },
6212
6221
  get unsubscribe() {
6213
- 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
+ });
6214
6233
  }
6215
6234
  };
6216
6235
 
@@ -6218,27 +6237,29 @@ var shopifyEventsZods = {
6218
6237
  var import_zod2 = require("zod");
6219
6238
 
6220
6239
  // src/apis/platform/adapter/integrations/mailchimp/_contracts/dtos/events.ts
6221
- var MailchimpEvents = /* @__PURE__ */ ((MailchimpEvents2) => {
6222
- MailchimpEvents2["Subscribe"] = "subscribe";
6223
- MailchimpEvents2["Unsubscribe"] = "unsubscribe";
6224
- return MailchimpEvents2;
6225
- })(MailchimpEvents || {});
6240
+ var MailchimpEventNames = /* @__PURE__ */ ((MailchimpEventNames2) => {
6241
+ MailchimpEventNames2["Subscribed"] = "subscribed";
6242
+ MailchimpEventNames2["Unsubscribed"] = "unsubscribed";
6243
+ return MailchimpEventNames2;
6244
+ })(MailchimpEventNames || {});
6226
6245
 
6227
6246
  // src/apis/platform/adapter/integrations/mailchimp/_contracts/requests/events.ts
6228
6247
  var mailchimpEventsZods = {
6229
- event: import_zod2.z.nativeEnum(MailchimpEvents),
6230
- get body() {
6231
- return import_zod2.z.object({
6232
- event: this.event,
6233
- listId: import_zod2.z.string()
6234
- });
6235
- },
6236
- get provider() {
6237
- return import_zod2.z.object({
6238
- provider: import_zod2.z.literal("mailchimp"),
6239
- event: this.event,
6240
- listId: import_zod2.z.string()
6241
- });
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
+ ]);
6242
6263
  },
6243
6264
  get source() {
6244
6265
  return import_zod2.z.object({
@@ -6247,39 +6268,100 @@ var mailchimpEventsZods = {
6247
6268
  });
6248
6269
  },
6249
6270
  get subscribe() {
6250
- return this.source.and(this.body).and(
6271
+ return this.source.and(
6251
6272
  import_zod2.z.object({
6273
+ event: this.event,
6274
+ listId: import_zod2.z.string(),
6252
6275
  callback: import_zod2.z.string()
6253
6276
  })
6254
6277
  );
6255
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
+ },
6256
6287
  get unsubscribe() {
6257
- 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
+ });
6258
6301
  }
6259
6302
  };
6260
6303
 
6261
6304
  // src/apis/platform/adapter/integrations/text/_contracts/dtos/events.ts
6262
- var TextLivechatEvents = /* @__PURE__ */ ((TextLivechatEvents2) => {
6263
- TextLivechatEvents2["IncomingChat"] = "incoming_chat";
6264
- TextLivechatEvents2["IncomingEvent"] = "incoming_event";
6265
- TextLivechatEvents2["IncomingCustomer"] = "incoming_customer";
6266
- return TextLivechatEvents2;
6267
- })(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 || {});
6268
6316
 
6269
6317
  // src/apis/platform/adapter/integrations/text/_contracts/requests/events.ts
6270
6318
  var import_zod3 = require("zod");
6271
6319
  var textLivechatEventsZods = {
6272
- event: import_zod3.z.nativeEnum(TextLivechatEvents),
6273
- get body() {
6274
- return import_zod3.z.object({
6275
- event: this.event
6276
- });
6277
- },
6278
- get provider() {
6279
- return import_zod3.z.object({
6280
- provider: import_zod3.z.literal("text-livechat"),
6281
- event: this.event
6282
- });
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
+ ]);
6283
6365
  },
6284
6366
  get source() {
6285
6367
  return import_zod3.z.object({
@@ -6288,14 +6370,32 @@ var textLivechatEventsZods = {
6288
6370
  });
6289
6371
  },
6290
6372
  get subscribe() {
6291
- return this.source.and(this.body).and(
6373
+ return this.source.and(
6292
6374
  import_zod3.z.object({
6375
+ event: this.event,
6293
6376
  callback: import_zod3.z.string()
6294
6377
  })
6295
6378
  );
6296
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
+ },
6297
6387
  get unsubscribe() {
6298
- 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
+ });
6299
6399
  }
6300
6400
  };
6301
6401
 
@@ -6303,29 +6403,59 @@ var textLivechatEventsZods = {
6303
6403
  var integrationEventsZods = {
6304
6404
  sourceName: import_zod4.z.enum(["apps", "workflows"]),
6305
6405
  providerName: import_zod4.z.enum(["text-livechat", "mailchimp", "shopify"]),
6406
+ get event() {
6407
+ return textLivechatEventsZods.event.or(shopifyEventsZods.event).or(mailchimpEventsZods.event);
6408
+ },
6306
6409
  get source() {
6307
6410
  return import_zod4.z.object({
6308
6411
  sourceName: this.sourceName,
6309
6412
  sourceKey: import_zod4.z.string()
6310
6413
  });
6311
6414
  },
6312
- provider: import_zod4.z.discriminatedUnion("provider", [
6313
- textLivechatEventsZods.provider,
6314
- mailchimpEventsZods.provider,
6315
- shopifyEventsZods.provider
6316
- ]),
6317
6415
  get subscribe() {
6318
- return this.source.and(this.provider).and(
6319
- import_zod4.z.object({
6320
- callback: import_zod4.z.string()
6321
- })
6416
+ return this.source.and(
6417
+ import_zod4.z.discriminatedUnion("provider", [
6418
+ textLivechatEventsZods.subscribeContent,
6419
+ shopifyEventsZods.subscribeContent,
6420
+ mailchimpEventsZods.subscribeContent
6421
+ ])
6322
6422
  );
6323
6423
  },
6324
6424
  get unsubscribe() {
6325
- 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
+ );
6326
6432
  }
6327
6433
  };
6328
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
+
6329
6459
  // src/apis/platform/adapter/integrations/mailchimp/api.ts
6330
6460
  var platformAdapterMailchimpApi = {
6331
6461
  events: {
@@ -6629,12 +6759,15 @@ function getIntegrationFlowUrl(provider, flow, data, context, config) {
6629
6759
  DpsApiError,
6630
6760
  LivechatApiError,
6631
6761
  MailchimpApiError,
6632
- MailchimpEvents,
6762
+ MailchimpEventNames,
6633
6763
  ShopifyApiError,
6634
- ShopifyEvents,
6635
- TextLivechatEvents,
6764
+ ShopifyEventNames,
6765
+ TextLivechatEventNames,
6636
6766
  UnauthorizeAccountsApiError,
6637
6767
  UnauthorizeApiError,
6768
+ WebhookActions,
6769
+ WebhookEvents,
6770
+ WebhookSystemMessages,
6638
6771
  WorkflowDefinitionTaskType,
6639
6772
  allAppTemplates,
6640
6773
  api,