@unboundcx/sdk 4.13.140 → 4.13.141
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.
|
|
3
|
+
"version": "4.13.141",
|
|
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/permissions.js
CHANGED
|
@@ -541,6 +541,27 @@ export class PermissionsService {
|
|
|
541
541
|
);
|
|
542
542
|
}
|
|
543
543
|
|
|
544
|
+
/**
|
|
545
|
+
* Account-wide defaults for any settings-catalog key (settingsAccountDefaults
|
|
546
|
+
* table) — a generic tier below systemDefault and above nothing; resolver
|
|
547
|
+
* order is user override -> group -> account default -> systemDefault.
|
|
548
|
+
* @returns {Promise<Object>} { [key]: value }
|
|
549
|
+
*/
|
|
550
|
+
async getAccountSettingDefaults() {
|
|
551
|
+
return internalRequest(this.sdk, '/permissions/settings/accountDefaults', 'GET');
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/** Set one account-wide default for a settings-catalog key. */
|
|
555
|
+
async setAccountSettingDefault(key, value) {
|
|
556
|
+
key = String(key);
|
|
557
|
+
this.sdk.validateParams({ key }, { key: { type: 'string', required: true } });
|
|
558
|
+
return internalRequest(this.sdk,
|
|
559
|
+
`/permissions/settings/accountDefaults/${key}`,
|
|
560
|
+
'PUT',
|
|
561
|
+
{ body: { value } },
|
|
562
|
+
);
|
|
563
|
+
}
|
|
564
|
+
|
|
544
565
|
/**
|
|
545
566
|
* Per-user, per-account JSON app state (UI state such as saved tab-sets).
|
|
546
567
|
* Distinct from settings: free-form JSON, not catalog-validated.
|
|
@@ -163,4 +163,181 @@ export class QueueService {
|
|
|
163
163
|
{ body: { routingSteps } },
|
|
164
164
|
);
|
|
165
165
|
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* List a queue's alert rules (queueAlertRules table). Each rule fires
|
|
169
|
+
* when its trigger metric crosses `threshold` by `comparator` and
|
|
170
|
+
* stays there for `sustainSeconds` (proactive-alerts-plan.md §13/D1-D7).
|
|
171
|
+
*
|
|
172
|
+
* @param {string} queueId - The queue ID (required)
|
|
173
|
+
* @returns {Promise<Object>} result
|
|
174
|
+
* @returns {Object[]} result.alertRules - Rules for the queue
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* const { alertRules } = await sdk.taskRouter.queues.alerts.list('queue123');
|
|
178
|
+
*/
|
|
179
|
+
async alertsList(queueId) {
|
|
180
|
+
this.sdk.validateParams(
|
|
181
|
+
{ queueId },
|
|
182
|
+
{ queueId: { type: 'string', required: true } },
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
return await internalRequest(
|
|
186
|
+
this.sdk,
|
|
187
|
+
`/taskRouter/queues/${queueId}/alertRules`,
|
|
188
|
+
'GET',
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Create a new alert rule on a queue.
|
|
194
|
+
*
|
|
195
|
+
* @param {string} queueId - The queue ID (required)
|
|
196
|
+
* @param {Object} rule - The rule to create
|
|
197
|
+
* @param {string} rule.channel - 'phoneCall' | 'chat' | 'email' | 'sms' | 'fax' | 'other' | 'whatsApp' | 'rcs' | 'all'
|
|
198
|
+
* @param {string} rule.trigger - 'pendingTasks' | 'longestWait' | 'serviceLevel' | 'availableAgents' | 'abandonmentRate' | 'abandonCount' | 'occupancy' | 'overflowMaxWait' | 'overflowNoAgents' | 'overflowCapacity' | 'overflowClosed'
|
|
199
|
+
* @param {string} [rule.comparator] - 'gte' | 'lte' (defaults per trigger: serviceLevel/availableAgents -> lte, else gte)
|
|
200
|
+
* @param {number} rule.threshold
|
|
201
|
+
* @param {number} [rule.hysteresisValue]
|
|
202
|
+
* @param {number} [rule.windowMinutes] - Required 1-60 iff trigger is 'abandonCount'
|
|
203
|
+
* @param {number} [rule.sustainSeconds]
|
|
204
|
+
* @param {number} [rule.cooldownSeconds]
|
|
205
|
+
* @param {number} [rule.dailyCap]
|
|
206
|
+
* @param {string} [rule.scheduleId]
|
|
207
|
+
* @param {boolean} [rule.sendRecovery]
|
|
208
|
+
* @param {number} [rule.escalateAfterSeconds]
|
|
209
|
+
* @param {Object[]} rule.actions - `[{type:'email'|'sms'|'notification', userIds:[], teamIds:[]} | {type:'chat', channelId?, userIds?} | {type:'workflow', workflowId}]`
|
|
210
|
+
* @param {Object[]} [rule.escalateActions] - Same shape as `actions`
|
|
211
|
+
* @param {boolean} [rule.isEnabled]
|
|
212
|
+
* @returns {Promise<Object>} result
|
|
213
|
+
* @returns {Object} result.alertRule - The created rule
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* await sdk.taskRouter.queues.alerts.create('queue123', {
|
|
217
|
+
* channel: 'phoneCall',
|
|
218
|
+
* trigger: 'longestWait',
|
|
219
|
+
* threshold: 60,
|
|
220
|
+
* sustainSeconds: 60,
|
|
221
|
+
* actions: [{ type: 'notification', userIds: ['user1'], teamIds: [] }],
|
|
222
|
+
* });
|
|
223
|
+
*/
|
|
224
|
+
async alertsCreate(queueId, rule) {
|
|
225
|
+
this.sdk.validateParams(
|
|
226
|
+
{ queueId, rule },
|
|
227
|
+
{
|
|
228
|
+
queueId: { type: 'string', required: true },
|
|
229
|
+
rule: { type: 'object', required: true },
|
|
230
|
+
},
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
return await internalRequest(
|
|
234
|
+
this.sdk,
|
|
235
|
+
`/taskRouter/queues/${queueId}/alertRules`,
|
|
236
|
+
'POST',
|
|
237
|
+
{ body: rule },
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Patch an existing alert rule.
|
|
243
|
+
*
|
|
244
|
+
* @param {string} queueId - The queue ID (required)
|
|
245
|
+
* @param {string} ruleId - The alert rule ID (required)
|
|
246
|
+
* @param {Object} patch - Partial fields to update (same shape as `create`'s `rule`)
|
|
247
|
+
* @returns {Promise<Object>} result
|
|
248
|
+
* @returns {Object} result.alertRule - The updated rule
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* await sdk.taskRouter.queues.alerts.update('queue123', 'rule1', { threshold: 90 });
|
|
252
|
+
*/
|
|
253
|
+
async alertsUpdate(queueId, ruleId, patch) {
|
|
254
|
+
this.sdk.validateParams(
|
|
255
|
+
{ queueId, ruleId, patch },
|
|
256
|
+
{
|
|
257
|
+
queueId: { type: 'string', required: true },
|
|
258
|
+
ruleId: { type: 'string', required: true },
|
|
259
|
+
patch: { type: 'object', required: true },
|
|
260
|
+
},
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
return await internalRequest(
|
|
264
|
+
this.sdk,
|
|
265
|
+
`/taskRouter/queues/${queueId}/alertRules/${ruleId}`,
|
|
266
|
+
'PATCH',
|
|
267
|
+
{ body: patch },
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Delete an alert rule.
|
|
273
|
+
*
|
|
274
|
+
* @param {string} queueId - The queue ID (required)
|
|
275
|
+
* @param {string} ruleId - The alert rule ID (required)
|
|
276
|
+
* @returns {Promise<Object>} result
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* await sdk.taskRouter.queues.alerts.remove('queue123', 'rule1');
|
|
280
|
+
*/
|
|
281
|
+
async alertsRemove(queueId, ruleId) {
|
|
282
|
+
this.sdk.validateParams(
|
|
283
|
+
{ queueId, ruleId },
|
|
284
|
+
{
|
|
285
|
+
queueId: { type: 'string', required: true },
|
|
286
|
+
ruleId: { type: 'string', required: true },
|
|
287
|
+
},
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
return await internalRequest(
|
|
291
|
+
this.sdk,
|
|
292
|
+
`/taskRouter/queues/${queueId}/alertRules/${ruleId}`,
|
|
293
|
+
'DELETE',
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* List a queue's alert event history (queueAlertEvents table): fired,
|
|
299
|
+
* escalated, cleared, and suppressed events.
|
|
300
|
+
*
|
|
301
|
+
* @param {string} queueId - The queue ID (required)
|
|
302
|
+
* @param {Object} [options]
|
|
303
|
+
* @param {number} [options.limit] - Max rows to return (default 50)
|
|
304
|
+
* @param {string} [options.before] - ISO timestamp cursor; only events before this time
|
|
305
|
+
* @returns {Promise<Object>} result
|
|
306
|
+
* @returns {Object[]} result.alertEvents
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* const { alertEvents } = await sdk.taskRouter.queues.alerts.history('queue123', { limit: 20 });
|
|
310
|
+
*/
|
|
311
|
+
async alertsHistory(queueId, { limit, before } = {}) {
|
|
312
|
+
this.sdk.validateParams(
|
|
313
|
+
{ queueId },
|
|
314
|
+
{ queueId: { type: 'string', required: true } },
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
const query = {};
|
|
318
|
+
if (limit !== undefined) query.limit = limit;
|
|
319
|
+
if (before !== undefined) query.before = before;
|
|
320
|
+
|
|
321
|
+
return await internalRequest(
|
|
322
|
+
this.sdk,
|
|
323
|
+
`/taskRouter/queues/${queueId}/alertEvents`,
|
|
324
|
+
'GET',
|
|
325
|
+
{ query },
|
|
326
|
+
);
|
|
327
|
+
}
|
|
166
328
|
}
|
|
329
|
+
|
|
330
|
+
// Exposes alert-rule methods as `sdk.taskRouter.queues.alerts.*` while
|
|
331
|
+
// keeping them implemented as plain methods on QueueService above (so they
|
|
332
|
+
// share `this.sdk`/validateParams without a second internalRequest wiring).
|
|
333
|
+
Object.defineProperty(QueueService.prototype, 'alerts', {
|
|
334
|
+
get() {
|
|
335
|
+
return {
|
|
336
|
+
list: (queueId) => this.alertsList(queueId),
|
|
337
|
+
create: (queueId, rule) => this.alertsCreate(queueId, rule),
|
|
338
|
+
update: (queueId, ruleId, patch) => this.alertsUpdate(queueId, ruleId, patch),
|
|
339
|
+
remove: (queueId, ruleId) => this.alertsRemove(queueId, ruleId),
|
|
340
|
+
history: (queueId, options) => this.alertsHistory(queueId, options),
|
|
341
|
+
};
|
|
342
|
+
},
|
|
343
|
+
});
|