@unboundcx/sdk 4.13.38 → 4.13.40

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "4.13.38",
3
+ "version": "4.13.40",
4
4
  "description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/services/chat.js CHANGED
@@ -497,6 +497,49 @@ export class ChatService {
497
497
  );
498
498
  }
499
499
 
500
+ /**
501
+ * Send a message on a kind:'text' channel (sms-routing-plan.md §3.3.1).
502
+ * Plain body only — no ProseMirror `message`, no threads/cards. The API
503
+ * intercepts this route for text channels and sends the plain-text body
504
+ * as a real SMS/MMS via the same pipeline as sdk.messaging.sms.send
505
+ * (unless `internal` is set, which stays a regular chat message).
506
+ * @param {string} channelId
507
+ * @param {Object} params
508
+ * @param {string} [params.text] - Plain message text
509
+ * @param {string[]} [params.storageIds] - Image attachment storage ids
510
+ * @param {boolean} [params.internal] - Internal note; never sent as SMS
511
+ * @param {boolean} [params.force] - Force-send past a busy-conversation
512
+ * (409 TEXT_CONVERSATION_BUSY) collision
513
+ * @returns {Promise<Object>} Created message
514
+ */
515
+ async sendTextMessage(channelId, { text, storageIds, internal, force } = {}) {
516
+ this.sdk.validateParams(
517
+ { channelId, text, storageIds, internal, force },
518
+ {
519
+ channelId: { type: "string", required: true },
520
+ text: { type: "string", required: false },
521
+ storageIds: { type: "array", required: false },
522
+ internal: { type: "boolean", required: false },
523
+ force: { type: "boolean", required: false },
524
+ },
525
+ );
526
+
527
+ const body = {};
528
+ if (text !== undefined) body.text = text;
529
+ if (storageIds !== undefined) body.storageIds = storageIds;
530
+ if (internal !== undefined) body.internal = internal;
531
+ if (force !== undefined) body.force = force;
532
+
533
+ return internalRequest(
534
+ this.sdk,
535
+ `/chat/channels/${channelId}/messages`,
536
+ "POST",
537
+ {
538
+ body,
539
+ },
540
+ );
541
+ }
542
+
500
543
  /**
501
544
  * Edit a message body (ProseMirror JSON).
502
545
  * @param {string} id
@@ -844,7 +887,11 @@ export class ChatService {
844
887
  * reason"; channel must be a non-archived public/private channel.
845
888
  * @returns {Promise<Object>} `{allowReports, reportReasons, reportNotifications}`
846
889
  */
847
- async adminPutSettings({ allowReports, reportReasons, reportNotifications } = {}) {
890
+ async adminPutSettings({
891
+ allowReports,
892
+ reportReasons,
893
+ reportNotifications,
894
+ } = {}) {
848
895
  this.sdk.validateParams(
849
896
  { allowReports, reportReasons, reportNotifications },
850
897
  {
@@ -1145,7 +1192,10 @@ export class ChatService {
1145
1192
  * @param {'open'|'in_review'} [params.status]
1146
1193
  * @returns {Promise<Object>}
1147
1194
  */
1148
- async adminUpdateCase(id, { title, category, description, ownerId, status } = {}) {
1195
+ async adminUpdateCase(
1196
+ id,
1197
+ { title, category, description, ownerId, status } = {},
1198
+ ) {
1149
1199
  this.sdk.validateParams(
1150
1200
  { id, title, category, description, ownerId, status },
1151
1201
  {
@@ -21,6 +21,8 @@ export class SmsService {
21
21
  * to attach this message to, so it surfaces on that record's feed
22
22
  * @param {string} [params.engagementSessionId] - Engagement to attach this message to
23
23
  * @param {string} [params.taskId] - Task the message was sent under (multi-channel-per-task attribution)
24
+ * @param {boolean} [params.force] - Force-send past a busy-conversation
25
+ * (409 TEXT_CONVERSATION_BUSY) collision
24
26
  * @returns {Promise<Object>} Message details
25
27
  */
26
28
  async send({
@@ -34,6 +36,7 @@ export class SmsService {
34
36
  relatedId,
35
37
  engagementSessionId,
36
38
  taskId,
39
+ force,
37
40
  }) {
38
41
  const messageData = {};
39
42
  if (from) messageData.from = from;
@@ -45,6 +48,7 @@ export class SmsService {
45
48
  if (relatedId) messageData.relatedId = relatedId;
46
49
  if (engagementSessionId) messageData.engagementSessionId = engagementSessionId;
47
50
  if (taskId) messageData.taskId = taskId;
51
+ if (force !== undefined) messageData.force = force;
48
52
 
49
53
  this.sdk.validateParams(
50
54
  { to, ...messageData },
@@ -59,6 +63,7 @@ export class SmsService {
59
63
  relatedId: { type: 'string', required: false },
60
64
  engagementSessionId: { type: 'string', required: false },
61
65
  taskId: { type: 'string', required: false },
66
+ force: { type: 'boolean', required: false },
62
67
  },
63
68
  );
64
69
 
@@ -108,4 +113,26 @@ export class SmsService {
108
113
  );
109
114
  return result;
110
115
  }
116
+
117
+ /**
118
+ * Re-send a failed message as a new row, linked back via retryOfId
119
+ * (sms-routing-plan.md §5.1, contract C2).
120
+ * @param {string} id - The failed message's id (required)
121
+ * @returns {Promise<Object>} The new message's { id, status }
122
+ */
123
+ async retry(id) {
124
+ this.sdk.validateParams(
125
+ { id },
126
+ {
127
+ id: { type: 'string', required: true },
128
+ },
129
+ );
130
+
131
+ const result = await internalRequest(
132
+ this.sdk,
133
+ `/messaging/sms/${id}/retry`,
134
+ 'POST',
135
+ );
136
+ return result;
137
+ }
111
138
  }
package/services/text.js CHANGED
@@ -46,6 +46,57 @@ export class TextConversationsService {
46
46
  query: { phoneNumberId, counterparty },
47
47
  });
48
48
  }
49
+
50
+ /**
51
+ * Join a UC-Chat-owned conversation's text channel (sms-routing-plan.md
52
+ * §3.3, contract C5) -- private channels aren't joinable via
53
+ * sdk.chat.channels.join (public-only); public-visibility text channels
54
+ * still require `messaging:sms:send`, which this route enforces.
55
+ * @param {string} id - textConversations id (required)
56
+ * @returns {Promise<Object>} { channel, membership }
57
+ */
58
+ async join(id) {
59
+ this.sdk.validateParams(
60
+ { id },
61
+ { id: { type: 'string', required: true } },
62
+ );
63
+
64
+ return internalRequest(this.sdk, `/text/conversations/${id}/join`, 'POST');
65
+ }
66
+
67
+ /**
68
+ * Escalate a UC-Chat-owned ('user') conversation to a queue or a
69
+ * workflow (sms-routing-plan.md §3.3/§3.4 "Send to queue" / "Send to
70
+ * workflow"). Pass exactly one of queueId or workflowId/workflowVersionId.
71
+ * @param {string} id - textConversations id (required)
72
+ * @param {Object} options - Parameters
73
+ * @param {string} [options.queueId] - Escalate to a queue (new task)
74
+ * @param {string} [options.workflowId] - Escalate to a workflow's current version
75
+ * @param {string} [options.workflowVersionId] - Escalate to a pinned workflow version
76
+ * @returns {Promise<Object>} The updated conversation row
77
+ */
78
+ async escalate(id, options = {}) {
79
+ const { queueId, workflowId, workflowVersionId } = options;
80
+
81
+ this.sdk.validateParams(
82
+ { id, queueId, workflowId, workflowVersionId },
83
+ {
84
+ id: { type: 'string', required: true },
85
+ queueId: { type: 'string', required: false },
86
+ workflowId: { type: 'string', required: false },
87
+ workflowVersionId: { type: 'string', required: false },
88
+ },
89
+ );
90
+ if (!queueId && !workflowId && !workflowVersionId) {
91
+ throw new Error(
92
+ 'escalate requires queueId or workflowId/workflowVersionId',
93
+ );
94
+ }
95
+
96
+ return internalRequest(this.sdk, `/text/conversations/${id}/escalate`, 'POST', {
97
+ body: { queueId, workflowId, workflowVersionId },
98
+ });
99
+ }
49
100
  }
50
101
 
51
102
  export class TextService {