@unboundcx/sdk 4.13.41 → 4.13.43

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.41",
3
+ "version": "4.13.43",
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",
@@ -18,11 +18,21 @@ export class DealRegistrationsService {
18
18
  * company/people/opportunity records (reusing matched records where
19
19
  * possible) and stamps the registration approved.
20
20
  * @param {string} id - dealRegistrations record id
21
+ * @param {Object} [options]
22
+ * @param {string} [options.notes] - shared with the partner (approval email + portal)
23
+ * @param {boolean} [options.force] - override a detected conflict; required
24
+ * when conflictStatus === 'conflict', otherwise the API answers 200
25
+ * with converted:false and leaves the registration pending.
21
26
  * @returns {Promise<Object>} { registration, converted }
22
27
  */
23
- async approve(id) {
28
+ async approve(id, { notes, force } = {}) {
24
29
  this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
25
- return internalRequest(this.sdk, `/deal-registrations/${id}/approve`, 'POST');
30
+ const body = {};
31
+ if (notes !== undefined) body.notes = notes;
32
+ if (force !== undefined) body.force = force;
33
+ return internalRequest(this.sdk, `/deal-registrations/${id}/approve`, 'POST', {
34
+ body,
35
+ });
26
36
  }
27
37
 
28
38
  /**
@@ -9,7 +9,16 @@ export class MetricsService {
9
9
  * Retrieves real-time metrics for task router queues, tasks, and workers.
10
10
  * This provides insights into queue performance, wait times, task counts, and worker activity.
11
11
  *
12
- * @param {Object} params - Metric parameters
12
+ * Accepts either `(params)` or `(accountId, params)` -- every client
13
+ * caller uses the former (e.g. `getCurrent({ queueId })`), and
14
+ * `accountId` is optional (the API route scopes by the authenticated
15
+ * account already). Sent as a query string, not a body: this hits
16
+ * `/taskRouter/metrics/current` over GET, and base.js's `_httpRequest`
17
+ * deletes `body` on any GET request, so a body-only payload here was
18
+ * silently discarded before ever reaching the server.
19
+ *
20
+ * @param {Object|string} [paramsOrAccountId] - Either the params object (preferred) or an accountId string
21
+ * @param {Object} [maybeParams] - Metric parameters, when the first argument is an accountId
13
22
  * @param {string} [params.period] - Time period for metrics calculation. Options: '5min', '15min', '30min', '1hour', '24hour'
14
23
  * @param {string} [params.queueId] - Specific queue ID to filter metrics. If not provided, returns metrics for all queues
15
24
  * @param {string} [params.metricType] - Type of metrics to retrieve: 'queue', 'task', 'worker', or 'all' (default: 'all')
@@ -71,7 +80,11 @@ export class MetricsService {
71
80
  * console.log(taskMetrics.metrics.task.created); // 150
72
81
  * console.log(taskMetrics.metrics.task.completed); // 142
73
82
  */
74
- async getCurrent(accountId, params = {}) {
83
+ async getCurrent(paramsOrAccountId, maybeParams) {
84
+ const isParamsFirst =
85
+ paramsOrAccountId !== null && typeof paramsOrAccountId === 'object';
86
+ const accountId = isParamsFirst ? undefined : paramsOrAccountId;
87
+ const params = (isParamsFirst ? paramsOrAccountId : maybeParams) || {};
75
88
  const { period, queueId, metricType, limit = 100 } = params;
76
89
 
77
90
  this.sdk.validateParams(
@@ -84,28 +97,28 @@ export class MetricsService {
84
97
  },
85
98
  );
86
99
 
87
- const requestParams = {
88
- body: {
89
- limit,
90
- },
91
- };
100
+ const query = { limit };
101
+
102
+ if (accountId !== undefined) {
103
+ query.accountId = accountId;
104
+ }
92
105
 
93
106
  if (period !== undefined) {
94
- requestParams.body.period = period;
107
+ query.period = period;
95
108
  }
96
109
 
97
110
  if (queueId !== undefined) {
98
- requestParams.body.queueId = queueId;
111
+ query.queueId = queueId;
99
112
  }
100
113
 
101
114
  if (metricType !== undefined) {
102
- requestParams.body.metricType = metricType;
115
+ query.metricType = metricType;
103
116
  }
104
117
 
105
- const result = await internalRequest(this.sdk,
118
+ const result = await internalRequest(this.sdk,
106
119
  '/taskRouter/metrics/current',
107
120
  'GET',
108
- requestParams,
121
+ { query },
109
122
  );
110
123
  return result;
111
124
  }
@@ -23,6 +23,7 @@ export class TaskService {
23
23
  * @param {boolean} [options.createEngagement=false] - Whether to automatically create an engagement session for this task
24
24
  * @param {string} [options.relatedObject] - Related object type for metadata tracking (automatically set if createEngagement is true)
25
25
  * @param {string} [options.relatedId] - Related object ID for metadata tracking (automatically set if createEngagement is true)
26
+ * @param {Object} [options.metadata] - Arbitrary metadata to attach to the task at creation (e.g. `{ textConversationId }`). Passed through as-is; whether it is persisted depends on the receiving endpoint honoring `metadata` in the request body.
26
27
  * @returns {Promise<Object>} Object containing the created task information
27
28
  * @returns {string} result.id - The unique identifier for the created task
28
29
  *
@@ -83,6 +84,7 @@ export class TaskService {
83
84
  cdrId,
84
85
  sipCallId,
85
86
  aiChatSessionId,
87
+ metadata,
86
88
  } = options;
87
89
 
88
90
  this.sdk.validateParams(
@@ -102,6 +104,7 @@ export class TaskService {
102
104
  relatedId,
103
105
  sipCallId,
104
106
  aiChatSessionId,
107
+ metadata,
105
108
  },
106
109
  {
107
110
  type: { type: 'string', required: true },
@@ -119,6 +122,7 @@ export class TaskService {
119
122
  relatedId: { type: 'string', required: false },
120
123
  sipCallId: { type: 'string', required: false },
121
124
  aiChatSessionId: { type: 'string', required: false },
125
+ metadata: { type: 'object', required: false },
122
126
  },
123
127
  );
124
128
 
@@ -181,6 +185,10 @@ export class TaskService {
181
185
  params.body.aiChatSessionId = aiChatSessionId;
182
186
  }
183
187
 
188
+ if (metadata !== undefined) {
189
+ params.body.metadata = metadata;
190
+ }
191
+
184
192
  const result = await internalRequest(this.sdk, '/taskRouter/tasks', 'POST', params);
185
193
  return result;
186
194
  }
package/services/text.js CHANGED
@@ -147,6 +147,42 @@ export class TextConversationsService {
147
147
  body: { to, userId, groupId, visibility, workflowId, workflowVersionId },
148
148
  });
149
149
  }
150
+
151
+ /**
152
+ * "SMS from an active call": check whether the current user may open the
153
+ * UC Chat text channel for a call's (our number, other party) pair.
154
+ * Never throws for an unavailable result -- check `available`/`reason`.
155
+ * @param {string} cdrId - cdr_acct id for the call (required)
156
+ * @returns {Promise<Object>} { available, reason, phoneNumberId, ourNumber, counterparty, conversationId, channelId, isMember }
157
+ */
158
+ async callThread(cdrId) {
159
+ this.sdk.validateParams(
160
+ { cdrId },
161
+ { cdrId: { type: 'string', required: true } },
162
+ );
163
+
164
+ return internalRequest(this.sdk, '/text/call-thread', 'GET', {
165
+ query: { cdrId },
166
+ });
167
+ }
168
+
169
+ /**
170
+ * Open (or join) the UC Chat text channel for a call's (our number,
171
+ * other party) pair, minting the conversation/channel if none is open
172
+ * yet. 403s if callThread(cdrId) would report `available: false`.
173
+ * @param {string} cdrId - cdr_acct id for the call (required)
174
+ * @returns {Promise<Object>} { channel, conversationId }
175
+ */
176
+ async openCallThread(cdrId) {
177
+ this.sdk.validateParams(
178
+ { cdrId },
179
+ { cdrId: { type: 'string', required: true } },
180
+ );
181
+
182
+ return internalRequest(this.sdk, '/text/call-thread', 'POST', {
183
+ body: { cdrId },
184
+ });
185
+ }
150
186
  }
151
187
 
152
188
  export class TextService {