@unboundcx/sdk 4.13.145 → 4.13.146-security.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.
Files changed (45) hide show
  1. package/README.md +7 -0
  2. package/base.js +74 -3
  3. package/index.js +7 -31
  4. package/lib/refreshInterceptor.js +127 -0
  5. package/package.json +2 -5
  6. package/services/layouts.js +4 -13
  7. package/services/licenses.js +330 -0
  8. package/services/login.js +21 -0
  9. package/services/messageTemplates.js +2 -109
  10. package/services/messaging/EmailTemplatesService.js +2 -10
  11. package/services/messaging/SmsService.js +3 -0
  12. package/services/messaging/SmsTemplatesService.js +125 -0
  13. package/services/messaging.js +2 -0
  14. package/services/oauth.js +159 -0
  15. package/services/objects.js +39 -12
  16. package/services/permissions.js +0 -21
  17. package/services/phoneNumbers.js +1037 -2
  18. package/services/recents.js +0 -16
  19. package/services/taskRouter/MetricsService.js +0 -3
  20. package/services/taskRouter/TaskRouterService.js +0 -2
  21. package/services/taskRouter/TaskService.js +10 -70
  22. package/services/voice.js +25 -47
  23. package/lib/journeyLayout.js +0 -132
  24. package/services/journeys/JourneyDraftService.js +0 -92
  25. package/services/journeys/JourneyGoalsService.js +0 -57
  26. package/services/journeys/JourneyMembersService.js +0 -246
  27. package/services/journeys/JourneyTypesService.js +0 -59
  28. package/services/journeys/JourneyWorklistService.js +0 -74
  29. package/services/journeys/JourneysService.js +0 -392
  30. package/services/operatorPanels.js +0 -226
  31. package/services/parking.js +0 -121
  32. package/services/phoneNumbers/carrier.js +0 -60
  33. package/services/phoneNumbers/cnam.js +0 -42
  34. package/services/phoneNumbers/index.js +0 -27
  35. package/services/phoneNumbers/order.js +0 -88
  36. package/services/phoneNumbers/porting-activity.js +0 -289
  37. package/services/phoneNumbers/porting-orders.js +0 -318
  38. package/services/phoneNumbers/search.js +0 -181
  39. package/services/phoneNumbers/update.js +0 -94
  40. package/services/schedules/SchedulesService.js +0 -232
  41. package/services/schedules/TimeOffService.js +0 -131
  42. package/services/skills.js +0 -207
  43. package/services/taskRouter/QueueService.js +0 -343
  44. package/services/voicemailDrops.js +0 -268
  45. package/services/workflowTemplates/WorkflowTemplatesService.js +0 -68
@@ -1,232 +0,0 @@
1
- import { internalRequest } from '../../base.js';
2
- import { TimeOffService } from './TimeOffService.js';
3
-
4
- function pickDefined(fields) {
5
- const body = {};
6
- for (const [key, value] of Object.entries(fields)) {
7
- if (value !== undefined) body[key] = value;
8
- }
9
- return body;
10
- }
11
-
12
- // Resolve/open query params a caller may pass to narrow which schedule is
13
- // evaluated: a specific scheduleId (ignores assignment resolution), or a
14
- // queueId/userId to resolve via assignments (journeys-plan.md §5).
15
- function resolveQuery({ queueId, userId, scheduleId } = {}) {
16
- return pickDefined({ queueId, userId, scheduleId });
17
- }
18
-
19
- /**
20
- * Schedules (working hours, closures, assignments, time off) --
21
- * journeys-plan.md §5. CRUD, assignments, holiday sets, time off, and the
22
- * resolve/isOpen/nextOpen/simulate endpoints that evaluate a resolved
23
- * schedule. `sdk.schedules.*`.
24
- *
25
- * @see app1-api src/services/schedules/routes.js
26
- */
27
- export class SchedulesService {
28
- constructor(sdk) {
29
- this.sdk = sdk;
30
- this.timeOff = new TimeOffService(sdk);
31
- }
32
-
33
- /**
34
- * @returns {Promise<Array>} Schedules (summary rows, no nested windows/closures)
35
- */
36
- async list() {
37
- return await internalRequest(this.sdk, '/schedules', 'GET', {});
38
- }
39
-
40
- /**
41
- * @param {string} id
42
- * @returns {Promise<Object>} Schedule with nested windows, closures, usedBy
43
- */
44
- async get(id) {
45
- this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
46
- return await internalRequest(this.sdk, `/schedules/${id}`, 'GET', {});
47
- }
48
-
49
- /**
50
- * @param {Object} body
51
- * @param {string} body.name
52
- * @param {string} [body.timezone]
53
- * @param {boolean} [body.isAccountDefault]
54
- * @param {Array<Object>} [body.windows] - {dayOfWeek, startTime, endTime}
55
- * @param {Array<Object>} [body.closures] - {name, kind, config, partialDay?}
56
- * @returns {Promise<Object>} Created schedule (with nested windows/closures)
57
- */
58
- async create(body) {
59
- this.sdk.validateParams(
60
- { name: body?.name },
61
- { name: { type: 'string', required: true } },
62
- );
63
- return await internalRequest(this.sdk, '/schedules', 'POST', {
64
- body: pickDefined(body),
65
- });
66
- }
67
-
68
- /**
69
- * Full replace-on-update: passing `windows`/`closures` replaces the
70
- * schedule's entire set (not a merge/patch of individual rows).
71
- *
72
- * @param {string} id
73
- * @param {Object} body - name?, timezone?, isAccountDefault?, windows?, closures?
74
- * @returns {Promise<Object>} Updated schedule
75
- */
76
- async update(id, body) {
77
- this.sdk.validateParams(
78
- { id, body },
79
- {
80
- id: { type: 'string', required: true },
81
- body: { type: 'object', required: true },
82
- },
83
- );
84
- return await internalRequest(this.sdk, `/schedules/${id}`, 'PATCH', {
85
- body: pickDefined(body),
86
- });
87
- }
88
-
89
- /**
90
- * @param {string} id
91
- * @returns {Promise<Object>} { id, deleted: true } -- 409s while assigned
92
- */
93
- async remove(id) {
94
- this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
95
- return await internalRequest(this.sdk, `/schedules/${id}`, 'DELETE', {});
96
- }
97
-
98
- /**
99
- * Set (replace) the one active assignment for a target. A target has at
100
- * most one schedule at a time.
101
- *
102
- * @param {string} id - Schedule id
103
- * @param {Object} params
104
- * @param {'account'|'group'|'queue'|'user'} params.targetType
105
- * @param {string} [params.targetId] - Required unless targetType is 'account'
106
- * @returns {Promise<Object>} The assignment row
107
- */
108
- async setAssignment(id, { targetType, targetId } = {}) {
109
- this.sdk.validateParams(
110
- { id, targetType },
111
- {
112
- id: { type: 'string', required: true },
113
- targetType: { type: 'string', required: true },
114
- },
115
- );
116
- return await internalRequest(
117
- this.sdk,
118
- `/schedules/${id}/assignments`,
119
- 'POST',
120
- { body: pickDefined({ targetType, targetId }) },
121
- );
122
- }
123
-
124
- /**
125
- * @param {string} id - Schedule id
126
- * @param {string} assignmentId
127
- * @returns {Promise<Object>} { id, deleted: true }
128
- */
129
- async clearAssignment(id, assignmentId) {
130
- this.sdk.validateParams(
131
- { id, assignmentId },
132
- {
133
- id: { type: 'string', required: true },
134
- assignmentId: { type: 'string', required: true },
135
- },
136
- );
137
- return await internalRequest(
138
- this.sdk,
139
- `/schedules/${id}/assignments/${assignmentId}`,
140
- 'DELETE',
141
- {},
142
- );
143
- }
144
-
145
- /**
146
- * Every live assignment pointing at this schedule (account/group/queue/user).
147
- *
148
- * @param {string} id
149
- * @returns {Promise<Array>} Assignment rows
150
- */
151
- async usedBy(id) {
152
- this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
153
- return await internalRequest(this.sdk, `/schedules/${id}/usedBy`, 'GET', {});
154
- }
155
-
156
- /**
157
- * @returns {Promise<Array>} Holiday sets, one row per {country, key}
158
- */
159
- async listHolidaySets() {
160
- return await internalRequest(this.sdk, '/schedules/holidaySets', 'GET', {});
161
- }
162
-
163
- /**
164
- * Resolve the effective schedule for a target: user assignment -> queue
165
- * assignment -> account default, with additive closures. Pass
166
- * `scheduleId` to resolve a specific schedule directly (ignores
167
- * assignment resolution; used by "simulate" against the schedule being
168
- * edited).
169
- *
170
- * @param {Object} [params]
171
- * @param {string} [params.queueId]
172
- * @param {string} [params.userId]
173
- * @param {string} [params.scheduleId]
174
- * @returns {Promise<Object>} Resolved schedule { timezone, windows, closures, source, flagged }
175
- */
176
- async resolve(params = {}) {
177
- return await internalRequest(this.sdk, '/schedules/resolve', 'GET', {
178
- query: resolveQuery(params),
179
- });
180
- }
181
-
182
- /**
183
- * @param {Object} [params]
184
- * @param {string} [params.queueId]
185
- * @param {string} [params.userId]
186
- * @param {string} [params.scheduleId]
187
- * @param {string} [params.at] - ISO datetime; defaults to now
188
- * @returns {Promise<Object>} { open, flagged }
189
- */
190
- async isOpen(params = {}) {
191
- const { at, ...rest } = params;
192
- return await internalRequest(this.sdk, '/schedules/isOpen', 'GET', {
193
- query: pickDefined({ ...resolveQuery(rest), at }),
194
- });
195
- }
196
-
197
- /**
198
- * @param {Object} [params]
199
- * @param {string} [params.queueId]
200
- * @param {string} [params.userId]
201
- * @param {string} [params.scheduleId]
202
- * @param {string} [params.at] - ISO datetime; defaults to now
203
- * @returns {Promise<Object>} { nextOpen, flagged }
204
- */
205
- async nextOpen(params = {}) {
206
- const { at, ...rest } = params;
207
- return await internalRequest(this.sdk, '/schedules/nextOpen', 'GET', {
208
- query: pickDefined({ ...resolveQuery(rest), at }),
209
- });
210
- }
211
-
212
- /**
213
- * Simulate a resolved schedule: open/nextOpen at a point in time, plus
214
- * optional addBusinessTime (pass `amount`+`unit`) and/or an `open` check
215
- * across a `range` of ISO timestamps.
216
- *
217
- * @param {Object} [body]
218
- * @param {string} [body.queueId]
219
- * @param {string} [body.userId]
220
- * @param {string} [body.scheduleId]
221
- * @param {string} [body.at] - ISO datetime; defaults to now
222
- * @param {number} [body.amount]
223
- * @param {'minutes'|'hours'|'days'} [body.unit]
224
- * @param {string[]} [body.range] - ISO datetimes to check open/closed for
225
- * @returns {Promise<Object>} { resolved, open, nextOpen, addBusinessTime?, range? }
226
- */
227
- async simulate(body = {}) {
228
- return await internalRequest(this.sdk, '/schedules/simulate', 'POST', {
229
- body: pickDefined(body),
230
- });
231
- }
232
- }
@@ -1,131 +0,0 @@
1
- import { internalRequest } from '../../base.js';
2
-
3
- function pickDefined(fields) {
4
- const body = {};
5
- for (const [key, value] of Object.entries(fields)) {
6
- if (value !== undefined) body[key] = value;
7
- }
8
- return body;
9
- }
10
-
11
- /**
12
- * userTimeOff CRUD -- self + manager-for-direct-reports.
13
- * `sdk.schedules.timeOff.*` (journeys-plan.md §5).
14
- *
15
- * @see app1-api src/services/schedules/controllers/timeOff.js
16
- */
17
- export class TimeOffService {
18
- constructor(sdk) {
19
- this.sdk = sdk;
20
- }
21
-
22
- /**
23
- * List time off rows. Omit `userId` for your own rows; pass it to look
24
- * up a direct report's (manager-only, 403 otherwise).
25
- *
26
- * @param {Object} [params]
27
- * @param {string} [params.userId]
28
- * @returns {Promise<Array>} Time off rows
29
- */
30
- async list(params = {}) {
31
- const { userId } = params;
32
- const query = userId ? { userId } : {};
33
- return await internalRequest(this.sdk, '/schedules/timeOff', 'GET', {
34
- query,
35
- });
36
- }
37
-
38
- /**
39
- * Manager "Team time off" view -- every active direct report's rows.
40
- *
41
- * @returns {Promise<Array>} Time off rows for all direct reports
42
- */
43
- async listTeam() {
44
- return await internalRequest(
45
- this.sdk,
46
- '/schedules/timeOff/team',
47
- 'GET',
48
- {},
49
- );
50
- }
51
-
52
- /**
53
- * Create a time off row. `userId` defaults to the caller; a manager may
54
- * pass a direct report's userId.
55
- *
56
- * @param {Object} body
57
- * @param {string} [body.userId]
58
- * @param {string} body.startAt
59
- * @param {string} body.endAt
60
- * @param {string} [body.kind] - vacation|sick|other (default vacation)
61
- * @param {string} [body.note]
62
- * @param {string} [body.backupUserId]
63
- * @returns {Promise<Object>} Created row
64
- */
65
- async create(body) {
66
- this.sdk.validateParams(
67
- { startAt: body?.startAt, endAt: body?.endAt },
68
- {
69
- startAt: { type: 'string', required: true },
70
- endAt: { type: 'string', required: true },
71
- },
72
- );
73
- return await internalRequest(this.sdk, '/schedules/timeOff', 'POST', {
74
- body: pickDefined(body),
75
- });
76
- }
77
-
78
- /**
79
- * @param {string} id
80
- * @param {Object} body - startAt?, endAt?, kind?, note?, backupUserId?
81
- * @returns {Promise<Object>} Updated row
82
- */
83
- async update(id, body) {
84
- this.sdk.validateParams(
85
- { id, body },
86
- {
87
- id: { type: 'string', required: true },
88
- body: { type: 'object', required: true },
89
- },
90
- );
91
- return await internalRequest(
92
- this.sdk,
93
- `/schedules/timeOff/${id}`,
94
- 'PATCH',
95
- { body: pickDefined(body) },
96
- );
97
- }
98
-
99
- /**
100
- * @param {string} id
101
- * @returns {Promise<Object>} { id, deleted: true }
102
- */
103
- async remove(id) {
104
- this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
105
- return await internalRequest(
106
- this.sdk,
107
- `/schedules/timeOff/${id}`,
108
- 'DELETE',
109
- {},
110
- );
111
- }
112
-
113
- /**
114
- * @param {string} userId
115
- * @param {string} [at] - ISO datetime; defaults to now server-side
116
- * @returns {Promise<Object>} { away: boolean }
117
- */
118
- async isUserAway(userId, at) {
119
- this.sdk.validateParams(
120
- { userId },
121
- { userId: { type: 'string', required: true } },
122
- );
123
- const query = at ? { userId, at } : { userId };
124
- return await internalRequest(
125
- this.sdk,
126
- '/schedules/timeOff/isUserAway',
127
- 'GET',
128
- { query },
129
- );
130
- }
131
- }
@@ -1,207 +0,0 @@
1
- import { internalRequest } from '../base.js';
2
-
3
- // Skill-proficiency tiers (skill-proficiency-tiers-plan.md). Tier-set/sync
4
- // helpers that don't fit the generic sdk.objects.* shape (userSkills.tier
5
- // writes do go through sdk.objects.* for single-row create/update; this
6
- // service is the bulk/group/resync/suggestion surface).
7
- export class SkillsService {
8
- constructor(sdk) {
9
- this.sdk = sdk;
10
- }
11
-
12
- /**
13
- * Set one user's tier on one skill. Requires the user already have the
14
- * skill assigned (userSkills row must exist) -- this does not assign
15
- * the skill. Pushes the updated tier to the task-router worker
16
- * metadata (setSkillTiers) so routing sees it immediately.
17
- *
18
- * @param {string} userId
19
- * @param {string} skillId
20
- * @param {string} tier - 'expert' | 'proficient' | 'learning'
21
- * @returns {Promise<Object>} result
22
- * @returns {number} result.updated - 1 if a matching userSkills row was found, else 0
23
- *
24
- * @example
25
- * await sdk.skills.setUserTier('u123', 'sk456', 'proficient');
26
- */
27
- async setUserTier(userId, skillId, tier) {
28
- this.sdk.validateParams(
29
- { userId, skillId, tier },
30
- {
31
- userId: { type: 'string', required: true },
32
- skillId: { type: 'string', required: true },
33
- tier: { type: 'string', required: true },
34
- },
35
- );
36
-
37
- return await internalRequest(this.sdk, '/skills/tiers/set', 'POST', {
38
- body: { userId, skillId, tier },
39
- });
40
- }
41
-
42
- /**
43
- * Bulk-set a tier on one skill for a list of users. Only users who
44
- * already have the skill assigned are affected.
45
- *
46
- * @param {object} args
47
- * @param {string[]} args.userIds
48
- * @param {string} args.skillId
49
- * @param {string} args.tier - 'expert' | 'proficient' | 'learning'
50
- * @returns {Promise<Object>} result
51
- * @returns {number} result.updated - Count of userSkills rows changed
52
- *
53
- * @example
54
- * const { updated } = await sdk.skills.bulkSetTier({
55
- * userIds: ['u1', 'u2', 'u3'],
56
- * skillId: 'sk456',
57
- * tier: 'expert',
58
- * });
59
- */
60
- async bulkSetTier({ userIds, skillId, tier }) {
61
- this.sdk.validateParams(
62
- { userIds, skillId, tier },
63
- {
64
- userIds: { type: 'array', required: true },
65
- skillId: { type: 'string', required: true },
66
- tier: { type: 'string', required: true },
67
- },
68
- );
69
-
70
- return await internalRequest(
71
- this.sdk,
72
- '/skills/tiers/bulkSet',
73
- 'POST',
74
- { body: { userIds, skillId, tier } },
75
- );
76
- }
77
-
78
- /**
79
- * Bulk-set a tier on one skill for every currently-active member of a
80
- * group/team. Membership (groupMembers.removedAt IS NULL) is resolved
81
- * server-side at call time, so it can never be stale against the
82
- * caller's last page load.
83
- *
84
- * @param {object} args
85
- * @param {string} args.groupId
86
- * @param {string} args.skillId
87
- * @param {string} args.tier - 'expert' | 'proficient' | 'learning'
88
- * @returns {Promise<Object>} result
89
- * @returns {number} result.updated - Count of userSkills rows changed
90
- *
91
- * @example
92
- * await sdk.skills.bulkSetTierForGroup({
93
- * groupId: 'g789',
94
- * skillId: 'sk456',
95
- * tier: 'proficient',
96
- * });
97
- */
98
- async bulkSetTierForGroup({ groupId, skillId, tier }) {
99
- this.sdk.validateParams(
100
- { groupId, skillId, tier },
101
- {
102
- groupId: { type: 'string', required: true },
103
- skillId: { type: 'string', required: true },
104
- tier: { type: 'string', required: true },
105
- },
106
- );
107
-
108
- return await internalRequest(
109
- this.sdk,
110
- '/skills/tiers/bulkSetForGroup',
111
- 'POST',
112
- { body: { groupId, skillId, tier } },
113
- );
114
- }
115
-
116
- /**
117
- * Re-push every user-with-a-worker's effective skill tiers to
118
- * task-router worker metadata for the caller's account. Idempotent:
119
- * pushes real `userSkills.tier` values when `accounts.useSkillTiers` is
120
- * on, or `{}` (everyone defaults to Expert) when it's off. Used by the
121
- * account toggle handler and as a manual "Resync tiers" action.
122
- *
123
- * @returns {Promise<Object>} result
124
- * @returns {number} result.workers - Count of workers resynced
125
- *
126
- * @example
127
- * const { workers } = await sdk.skills.resyncTiers();
128
- */
129
- async resyncTiers() {
130
- return await internalRequest(this.sdk, '/skills/tiers/resync', 'POST', {
131
- body: {},
132
- });
133
- }
134
-
135
- /**
136
- * List pending suggested-tier rows for a user (userSkillSuggestions).
137
- *
138
- * @param {string} userId
139
- * @returns {Promise<Object>} result
140
- * @returns {Object[]} result.suggestions
141
- *
142
- * @example
143
- * const { suggestions } = await sdk.skills.getSuggestions('u123');
144
- */
145
- async getSuggestions(userId) {
146
- this.sdk.validateParams(
147
- { userId },
148
- { userId: { type: 'string', required: true } },
149
- );
150
-
151
- return await internalRequest(this.sdk, '/skills/suggestions', 'GET', {
152
- query: { userId },
153
- });
154
- }
155
-
156
- /**
157
- * Accept a suggested tier: sets userSkills.tier to the suggestion's
158
- * suggestedTier, pushes the change to the router, and marks the
159
- * suggestion row accepted.
160
- *
161
- * @param {string} id - Suggestion id (userSkillSuggestions.id)
162
- * @returns {Promise<Object>} result
163
- * @returns {string} result.id
164
- * @returns {string} result.tier - The tier now in effect
165
- * @returns {number} result.updated
166
- *
167
- * @example
168
- * await sdk.skills.acceptSuggestion('sugg123');
169
- */
170
- async acceptSuggestion(id) {
171
- this.sdk.validateParams(
172
- { id },
173
- { id: { type: 'string', required: true } },
174
- );
175
-
176
- return await internalRequest(
177
- this.sdk,
178
- `/skills/suggestions/${id}/accept`,
179
- 'POST',
180
- { body: {} },
181
- );
182
- }
183
-
184
- /**
185
- * Dismiss a suggested tier without changing userSkills.tier.
186
- *
187
- * @param {string} id - Suggestion id (userSkillSuggestions.id)
188
- * @returns {Promise<Object>} result
189
- * @returns {string} result.id
190
- *
191
- * @example
192
- * await sdk.skills.dismissSuggestion('sugg123');
193
- */
194
- async dismissSuggestion(id) {
195
- this.sdk.validateParams(
196
- { id },
197
- { id: { type: 'string', required: true } },
198
- );
199
-
200
- return await internalRequest(
201
- this.sdk,
202
- `/skills/suggestions/${id}/dismiss`,
203
- 'POST',
204
- { body: {} },
205
- );
206
- }
207
- }