@livechat/developer-studio-api 5.11.2 → 6.0.0

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.
@@ -3199,6 +3199,14 @@ var slackApi = {
3199
3199
  }
3200
3200
  };
3201
3201
 
3202
+ // src/apis/integrations/text/ai-agent/contracts.ts
3203
+ var RegenerateIntentRejectionError = class extends ApiErrorBase {
3204
+ constructor() {
3205
+ super(...arguments);
3206
+ this.name = "text";
3207
+ }
3208
+ };
3209
+
3202
3210
  // src/apis/integrations/text/ai-agent/api.ts
3203
3211
  var textAiAgentApi = {
3204
3212
  generateResponses(payload, authorization) {
@@ -3212,6 +3220,40 @@ var textAiAgentApi = {
3212
3220
  );
3213
3221
  return response;
3214
3222
  });
3223
+ },
3224
+ regenerateIntent(payload, authorization) {
3225
+ return __async(this, null, function* () {
3226
+ const getRejection = (error) => {
3227
+ var _a;
3228
+ const isTextApiError = error instanceof TextApiError;
3229
+ if (!isTextApiError) {
3230
+ return void 0;
3231
+ }
3232
+ const data = error.data;
3233
+ const { message, suggestion } = (_a = data == null ? void 0 : data.innerError) != null ? _a : {};
3234
+ if (typeof message === "string" && typeof suggestion === "string") {
3235
+ return { message, suggestion };
3236
+ }
3237
+ return void 0;
3238
+ };
3239
+ return textClientInstance.post(
3240
+ "/nlp-gateway/v2/agents/skills/regenerate-intent",
3241
+ payload,
3242
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
3243
+ ensureAuthorizationToken: true
3244
+ }))
3245
+ ).then(({ data }) => data).catch((error) => {
3246
+ const rejection = getRejection(error);
3247
+ if (rejection) {
3248
+ throw new RegenerateIntentRejectionError(
3249
+ rejection.message,
3250
+ rejection,
3251
+ error.code
3252
+ );
3253
+ }
3254
+ throw error;
3255
+ });
3256
+ });
3215
3257
  }
3216
3258
  };
3217
3259
 
@@ -8527,30 +8569,31 @@ var segmentMembershipDataZod = customerMetadataZod.extend({
8527
8569
  membership_last_updated_at: z.string(),
8528
8570
  segment_fields: z.object({
8529
8571
  email: z.string().optional(),
8530
- customer_properties: z.record(z.unknown()).optional()
8531
- }).passthrough().optional()
8532
- }).passthrough();
8572
+ customer_properties: z.record(z.string(), z.unknown()).optional()
8573
+ }).loose().optional()
8574
+ }).loose();
8533
8575
  var cdpCustomerEventMessageZod = z.discriminatedUnion("type", [
8534
8576
  z.object({
8535
8577
  id: z.string(),
8536
8578
  type: z.literal("customer_email_set" /* EmailSet */),
8537
8579
  data: customerMetadataZod.extend({
8538
8580
  email: z.string()
8539
- }).passthrough()
8581
+ }).loose()
8540
8582
  }),
8541
8583
  z.object({
8542
8584
  id: z.string(),
8543
8585
  type: z.literal("customer_properties_values_updated" /* PropertiesValuesUpdated */),
8544
8586
  data: customerMetadataZod.extend({
8545
8587
  customer_properties: z.record(
8588
+ z.string(),
8546
8589
  z.object({
8547
8590
  value: z.unknown(),
8548
8591
  last_updated_at: z.string(),
8549
8592
  last_updated_agent_account_id: z.string().optional(),
8550
8593
  last_updated_agent_client_id: z.string().optional()
8551
- }).passthrough()
8594
+ }).loose()
8552
8595
  )
8553
- }).passthrough()
8596
+ }).loose()
8554
8597
  }),
8555
8598
  z.object({
8556
8599
  id: z.string(),
@@ -8823,9 +8866,9 @@ var integrationEventsCoreZods = {
8823
8866
  },
8824
8867
  get authorization() {
8825
8868
  return z6.object({
8826
- headers: z6.record(z6.string()).optional(),
8827
- query_params: z6.record(z6.string()).optional(),
8828
- data: z6.record(z6.string()).optional()
8869
+ headers: z6.record(z6.string(), z6.string()).optional(),
8870
+ query_params: z6.record(z6.string(), z6.string()).optional(),
8871
+ data: z6.record(z6.string(), z6.string()).optional()
8829
8872
  });
8830
8873
  },
8831
8874
  withCore(schema) {
@@ -8849,7 +8892,7 @@ var BigCommerceEventNames = /* @__PURE__ */ ((BigCommerceEventNames2) => {
8849
8892
  })(BigCommerceEventNames || {});
8850
8893
  var bigcommerceEventsZods = {
8851
8894
  provider: z7.literal("bigcommerce" /* BigCommerce */),
8852
- eventName: z7.nativeEnum(BigCommerceEventNames),
8895
+ eventName: z7.enum(BigCommerceEventNames),
8853
8896
  events: {
8854
8897
  cartCreated: integrationEventBase.extend({
8855
8898
  name: z7.literal("cart_created" /* CartCreated */)
@@ -8919,7 +8962,7 @@ var HubspotEventNames = /* @__PURE__ */ ((HubspotEventNames2) => {
8919
8962
  })(HubspotEventNames || {});
8920
8963
  var hubspotEventsZods = {
8921
8964
  provider: z8.literal("hubspot" /* HubSpot */),
8922
- eventName: z8.nativeEnum(HubspotEventNames),
8965
+ eventName: z8.enum(HubspotEventNames),
8923
8966
  events: {
8924
8967
  contactCreated: integrationEventBase.extend({
8925
8968
  name: z8.literal("contact_created" /* ContactCreated */)
@@ -8973,7 +9016,7 @@ var MailchimpEventNames = /* @__PURE__ */ ((MailchimpEventNames2) => {
8973
9016
  })(MailchimpEventNames || {});
8974
9017
  var mailchimpEventsZods = {
8975
9018
  provider: z9.literal("mailchimp" /* Mailchimp */),
8976
- eventName: z9.nativeEnum(MailchimpEventNames),
9019
+ eventName: z9.enum(MailchimpEventNames),
8977
9020
  events: {
8978
9021
  subscribed: integrationEventBase.extend({
8979
9022
  listId: z9.string(),
@@ -9031,7 +9074,7 @@ var ShopifyEventNames = /* @__PURE__ */ ((ShopifyEventNames2) => {
9031
9074
  })(ShopifyEventNames || {});
9032
9075
  var shopifyEventsZods = {
9033
9076
  provider: z10.literal("shopify" /* Shopify */),
9034
- eventName: z10.nativeEnum(ShopifyEventNames),
9077
+ eventName: z10.enum(ShopifyEventNames),
9035
9078
  events: {
9036
9079
  orderCreated: integrationEventBase.extend({
9037
9080
  name: z10.literal("order_created" /* OrderCreated */)
@@ -9082,7 +9125,7 @@ var SlackEventNames = /* @__PURE__ */ ((SlackEventNames2) => {
9082
9125
  })(SlackEventNames || {});
9083
9126
  var slackEventsZods = {
9084
9127
  provider: z11.literal("slack" /* Slack */),
9085
- eventName: z11.nativeEnum(SlackEventNames),
9128
+ eventName: z11.enum(SlackEventNames),
9086
9129
  events: {
9087
9130
  channelNewMessagePosted: integrationEventBase.extend({
9088
9131
  name: z11.literal("channel_new_message_posted" /* ChannelNewMessagePosted */),
@@ -9156,7 +9199,7 @@ var TextCustomerSegmentType = /* @__PURE__ */ ((TextCustomerSegmentType2) => {
9156
9199
  return TextCustomerSegmentType2;
9157
9200
  })(TextCustomerSegmentType || {});
9158
9201
  var textCustomerEventsZods = {
9159
- eventName: z12.nativeEnum(TextCustomerEventNames),
9202
+ eventName: z12.enum(TextCustomerEventNames),
9160
9203
  events: {
9161
9204
  emailSet: integrationEventBase.extend({
9162
9205
  name: z12.literal("customer_email_set" /* EmailSet */),
@@ -9173,11 +9216,11 @@ var textCustomerEventsZods = {
9173
9216
  }),
9174
9217
  segmentAdded: integrationEventBase.extend({
9175
9218
  name: z12.literal("segment_added" /* SegmentAdded */),
9176
- segment_type: z12.nativeEnum(TextCustomerSegmentType)
9219
+ segment_type: z12.enum(TextCustomerSegmentType)
9177
9220
  }),
9178
9221
  segmentRemoved: integrationEventBase.extend({
9179
9222
  name: z12.literal("segment_removed" /* SegmentRemoved */),
9180
- segment_type: z12.nativeEnum(TextCustomerSegmentType)
9223
+ segment_type: z12.enum(TextCustomerSegmentType)
9181
9224
  })
9182
9225
  },
9183
9226
  get event() {
@@ -9231,7 +9274,7 @@ var baseFiltersZod = z13.object({
9231
9274
  });
9232
9275
  var textHelpDeskEventsZods = {
9233
9276
  provider: z13.literal("text-helpdesk" /* HelpDesk */),
9234
- eventName: z13.nativeEnum(TextHelpDeskEventNames),
9277
+ eventName: z13.enum(TextHelpDeskEventNames),
9235
9278
  events: {
9236
9279
  ticketCreated: integrationEventBase.extend({
9237
9280
  name: z13.literal("ticket_created" /* TicketCreated */)
@@ -9242,15 +9285,15 @@ var textHelpDeskEventsZods = {
9242
9285
  ticketStatusChanged: integrationEventBase.extend({
9243
9286
  name: z13.literal("ticket_status_changed" /* TicketStatusChanged */),
9244
9287
  status: z13.object({
9245
- from: z13.array(z13.nativeEnum(TicketStatus)).optional(),
9246
- to: z13.array(z13.nativeEnum(TicketStatus)).optional()
9288
+ from: z13.array(z13.enum(TicketStatus)).optional(),
9289
+ to: z13.array(z13.enum(TicketStatus)).optional()
9247
9290
  }).optional()
9248
9291
  }).extend(baseFiltersZod.shape),
9249
9292
  ticketPriorityChanged: integrationEventBase.extend({
9250
9293
  name: z13.literal("ticket_priority_changed" /* TicketPriorityChanged */),
9251
9294
  priority: z13.object({
9252
- from: z13.array(z13.nativeEnum(TicketPriority)).optional(),
9253
- to: z13.array(z13.nativeEnum(TicketPriority)).optional()
9295
+ from: z13.array(z13.enum(TicketPriority)).optional(),
9296
+ to: z13.array(z13.enum(TicketPriority)).optional()
9254
9297
  }).optional()
9255
9298
  }).extend(baseFiltersZod.shape),
9256
9299
  ticketTagsChanged: integrationEventBase.extend({
@@ -9283,7 +9326,7 @@ var textHelpDeskEventsZods = {
9283
9326
  ticketMessageAdded: z13.discriminatedUnion("version", [
9284
9327
  z13.object({
9285
9328
  name: z13.literal("ticket_message_added" /* TicketMessageAdded */),
9286
- version: z13.undefined()
9329
+ version: z13.literal("v0").optional()
9287
9330
  }).extend(baseFiltersZod.shape),
9288
9331
  z13.object({
9289
9332
  name: z13.literal("ticket_message_added" /* TicketMessageAdded */),
@@ -9354,6 +9397,7 @@ var TextLivechatEventNames = /* @__PURE__ */ ((TextLivechatEventNames2) => {
9354
9397
  TextLivechatEventNames2["CustomerLeftChat"] = "customer_left_chat";
9355
9398
  TextLivechatEventNames2["ChatIdle"] = "chat_idle";
9356
9399
  TextLivechatEventNames2["ProductCardEvent"] = "product_card_event";
9400
+ TextLivechatEventNames2["RichMessagePostback"] = "rich_message_postback";
9357
9401
  TextLivechatEventNames2["FormFilled"] = "form_filled";
9358
9402
  TextLivechatEventNames2["CustomFormFilled"] = "custom_form_filled";
9359
9403
  return TextLivechatEventNames2;
@@ -9369,42 +9413,49 @@ var TextLivechatProductCardEventType = /* @__PURE__ */ ((TextLivechatProductCard
9369
9413
  TextLivechatProductCardEventType2["AddToCart"] = "add_to_cart";
9370
9414
  return TextLivechatProductCardEventType2;
9371
9415
  })(TextLivechatProductCardEventType || {});
9416
+ var livechatChatContext = z14.object({
9417
+ chat_id: z14.string().min(1).optional(),
9418
+ thread_id: z14.string().min(1).optional()
9419
+ });
9420
+ var livechatEventContext = z14.object({
9421
+ event_id: z14.string().min(1).optional()
9422
+ });
9372
9423
  var textLivechatEventsZods = {
9373
9424
  provider: z14.literal("text-livechat" /* LiveChat */),
9374
- eventName: z14.nativeEnum(TextLivechatEventNames),
9425
+ eventName: z14.enum(TextLivechatEventNames),
9375
9426
  events: {
9376
- chatStarted: integrationEventBase.extend({
9427
+ chatStarted: integrationEventBase.extend(livechatChatContext.shape).extend({
9377
9428
  name: z14.literal("chat_started" /* ChatStarted */),
9378
9429
  targetAgentId: z14.string().optional()
9379
9430
  }),
9380
- chatEnded: integrationEventBase.extend({
9431
+ chatEnded: integrationEventBase.extend(livechatChatContext.shape).extend({
9381
9432
  name: z14.literal("chat_ended" /* ChatEnded */)
9382
9433
  }),
9383
- chatTransferred: integrationEventBase.extend({
9434
+ chatTransferred: integrationEventBase.extend(livechatChatContext.shape).extend({
9384
9435
  name: z14.literal("chat_transferred" /* ChatTransferred */),
9385
9436
  targetGroups: z14.array(z14.number()).optional(),
9386
9437
  targetAgents: z14.array(z14.string()).optional()
9387
9438
  }),
9388
- chatTagged: integrationEventBase.extend({
9439
+ chatTagged: integrationEventBase.extend(livechatChatContext.shape).extend({
9389
9440
  name: z14.literal("chat_tagged" /* ChatTagged */),
9390
9441
  tag: z14.string().optional()
9391
9442
  }),
9392
- chatRated: integrationEventBase.extend({
9443
+ chatRated: integrationEventBase.extend(livechatEventContext.shape).extend(livechatChatContext.shape).extend({
9393
9444
  name: z14.literal("chat_rated" /* ChatRated */),
9394
9445
  rating: z14.enum(["good", "bad", "all"]).optional()
9395
9446
  }),
9396
- chatCommented: integrationEventBase.extend({
9447
+ chatCommented: integrationEventBase.extend(livechatEventContext.shape).extend(livechatChatContext.shape).extend({
9397
9448
  name: z14.literal("chat_commented" /* ChatCommented */)
9398
9449
  }),
9399
9450
  chatMessage: z14.discriminatedUnion("version", [
9400
- z14.object({
9451
+ integrationEventBase.extend(livechatEventContext.shape).extend(livechatChatContext.shape).extend({
9401
9452
  name: z14.literal("chat_message" /* ChatMessage */),
9402
- version: z14.undefined(),
9453
+ version: z14.literal("v0").optional(),
9403
9454
  filter: z14.string().optional(),
9404
9455
  caseInsensitive: z14.boolean().optional(),
9405
9456
  matchWholeWords: z14.boolean().optional()
9406
9457
  }),
9407
- z14.object({
9458
+ integrationEventBase.extend(livechatEventContext.shape).extend(livechatChatContext.shape).extend({
9408
9459
  name: z14.literal("chat_message" /* ChatMessage */),
9409
9460
  version: z14.enum(["v1", "v2"]),
9410
9461
  filters: z14.array(z14.string()),
@@ -9412,31 +9463,42 @@ var textLivechatEventsZods = {
9412
9463
  matchWholeWords: z14.boolean().optional()
9413
9464
  })
9414
9465
  ]),
9415
- userAddedToChat: integrationEventBase.extend({
9466
+ userAddedToChat: integrationEventBase.extend(livechatChatContext.shape).extend({
9416
9467
  name: z14.literal("user_added_to_chat" /* UserAddedToChat */),
9417
9468
  userType: z14.enum(["agent", "customer"]).optional(),
9418
9469
  targetAgentId: z14.string().optional()
9419
9470
  }),
9420
- userRemovedFromChat: integrationEventBase.extend({
9471
+ userRemovedFromChat: integrationEventBase.extend(livechatChatContext.shape).extend({
9421
9472
  name: z14.literal("user_removed_from_chat" /* UserRemovedFromChat */)
9422
9473
  }),
9423
- customerLeftChat: integrationEventBase.extend({
9474
+ customerLeftChat: integrationEventBase.extend(livechatEventContext.shape).extend(livechatChatContext.shape).extend({
9424
9475
  name: z14.literal("customer_left_chat" /* CustomerLeftChat */),
9425
- reasons: z14.array(z14.nativeEnum(CustomerLeftChatReason)).optional()
9476
+ reasons: z14.array(z14.enum(CustomerLeftChatReason)).optional()
9426
9477
  }),
9427
- chatIdle: integrationEventBase.extend({
9478
+ chatIdle: integrationEventBase.extend(livechatEventContext.shape).extend(livechatChatContext.shape).extend({
9428
9479
  name: z14.literal("chat_idle" /* ChatIdle */)
9429
9480
  }),
9430
- productCardEvent: integrationEventBase.extend({
9481
+ productCardEvent: integrationEventBase.extend(livechatEventContext.shape).extend(livechatChatContext.shape).extend({
9431
9482
  name: z14.literal("product_card_event" /* ProductCardEvent */),
9432
- type: z14.nativeEnum(TextLivechatProductCardEventType),
9483
+ type: z14.enum(TextLivechatProductCardEventType),
9433
9484
  product_id: z14.string().optional()
9434
9485
  }),
9435
- formFilled: integrationEventBase.extend({
9486
+ richMessagePostback: integrationEventBase.extend(livechatEventContext.shape).extend(livechatChatContext.shape).extend({
9487
+ name: z14.literal("rich_message_postback" /* RichMessagePostback */),
9488
+ postbacks: z14.union([
9489
+ z14.array(z14.string().min(1)),
9490
+ z14.record(z14.string().min(1), z14.string().min(1))
9491
+ ]).refine((input) => {
9492
+ const ids = Array.isArray(input) ? input : Object.values(input);
9493
+ return ids.length > 0 && new Set(ids).size === ids.length;
9494
+ }, "Postbacks must be nonempty and IDs must be unique"),
9495
+ user_ids: z14.array(z14.string().min(1)).min(1).optional()
9496
+ }),
9497
+ formFilled: integrationEventBase.extend(livechatEventContext.shape).extend(livechatChatContext.shape).extend({
9436
9498
  name: z14.literal("form_filled" /* FormFilled */),
9437
9499
  form_id: z14.string().optional()
9438
9500
  }),
9439
- customFormFilled: integrationEventBase.extend({
9501
+ customFormFilled: integrationEventBase.extend(livechatEventContext.shape).extend(livechatChatContext.shape).extend({
9440
9502
  name: z14.literal("custom_form_filled" /* CustomFormFilled */),
9441
9503
  form_id: z14.string().optional()
9442
9504
  })
@@ -9455,6 +9517,7 @@ var textLivechatEventsZods = {
9455
9517
  this.events.customerLeftChat,
9456
9518
  this.events.chatIdle,
9457
9519
  this.events.productCardEvent,
9520
+ this.events.richMessagePostback,
9458
9521
  this.events.formFilled,
9459
9522
  this.events.customFormFilled
9460
9523
  ]);
@@ -9867,6 +9930,8 @@ export {
9867
9930
  TextLivechatEventNames,
9868
9931
  CustomerLeftChatReason,
9869
9932
  TextLivechatProductCardEventType,
9933
+ livechatChatContext,
9934
+ livechatEventContext,
9870
9935
  textLivechatEventsZods,
9871
9936
  textEventsZods,
9872
9937
  integrationEventsZods,
@@ -9929,6 +9994,7 @@ export {
9929
9994
  textClientInstance,
9930
9995
  getTextClientConfig,
9931
9996
  initTextClient,
9997
+ RegenerateIntentRejectionError,
9932
9998
  TextBillingApiError,
9933
9999
  UnauthorizeTextBillingApiError,
9934
10000
  textBillingClientInstance,