@unboundcx/sdk 4.13.41 → 4.13.42

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.42",
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",
@@ -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
  }