@unboundcx/sdk 4.13.144 → 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 -244
  27. package/services/journeys/JourneyTypesService.js +0 -53
  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,244 +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
- * Journey member surface -- `sdk.journeys.members.*`. Custom non-CRUD
13
- * endpoints (member grid, enrol, bulk actions, fix, events) mounted at
14
- * `/journeys/:id/members*`; NOT generic-object CRUD (journeyMembers is
15
- * registered isCreateable=0/isEditable=0 -- reads via `sdk.objects.query`
16
- * for grids/filters are fine, writes only through these methods).
17
- *
18
- * @see app1-api src/services/journeys/routes.js
19
- */
20
- export class JourneyMembersService {
21
- constructor(sdk) {
22
- this.sdk = sdk;
23
- }
24
-
25
- /**
26
- * Server-paged member grid for one journey.
27
- * @param {string} journeyId
28
- * @param {Object} [opts]
29
- * @param {number} [opts.page]
30
- * @param {number} [opts.pageSize]
31
- * @param {string} [opts.sort]
32
- * @param {string} [opts.sortDir]
33
- * @param {string[]} [opts.status]
34
- * @param {string} [opts.stepKey]
35
- * @param {string} [opts.ownerUserId]
36
- * @param {string} [opts.statusReason]
37
- * @param {string} [opts.search]
38
- * @param {boolean} [opts.isTest] true = test-run members only, false = exclude them; omit = no filter
39
- * @param {'company'} [opts.groupBy] server-grouped mode: { groups: [{ companyId, companyName, counts, members }] }
40
- * @returns {Promise<Object>} Paged member rows
41
- */
42
- async list(journeyId, opts = {}) {
43
- this.sdk.validateParams(
44
- { journeyId },
45
- { journeyId: { type: 'string', required: true } },
46
- );
47
- const { status, ...rest } = opts;
48
- const query = pickDefined({
49
- ...rest,
50
- status: Array.isArray(status) ? status.join(',') : status,
51
- });
52
- return await internalRequest(
53
- this.sdk,
54
- `/journeys/${journeyId}/members`,
55
- 'GET',
56
- { query },
57
- );
58
- }
59
-
60
- /**
61
- * URL for the CSV export of the members grid (P6) — same filter / sort
62
- * params as `list`. The browser downloads it directly (cookie auth); Node
63
- * callers fetch it with their own token.
64
- *
65
- * @param {string} journeyId
66
- * @param {Object} [opts] same keys as `list` (status, stepKey, ownerUserId, statusReason, search, sort, sortDir)
67
- * @returns {string} absolute URL
68
- */
69
- exportCsvUrl(journeyId, opts = {}) {
70
- this.sdk.validateParams(
71
- { journeyId },
72
- { journeyId: { type: 'string', required: true } },
73
- );
74
- const { status, ...rest } = opts;
75
- const query = pickDefined({
76
- ...rest,
77
- status: Array.isArray(status) ? status.join(',') : status,
78
- });
79
- const qs = new URLSearchParams(query).toString();
80
- return `${this.sdk.baseURL}/journeys/${journeyId}/members/export.csv${qs ? `?${qs}` : ''}`;
81
- }
82
-
83
- /**
84
- * @param {string} journeyId
85
- * @param {string} memberId
86
- * @returns {Promise<Object>} Single member row
87
- */
88
- async get(journeyId, memberId) {
89
- this.sdk.validateParams(
90
- { journeyId, memberId },
91
- {
92
- journeyId: { type: 'string', required: true },
93
- memberId: { type: 'string', required: true },
94
- },
95
- );
96
- return await internalRequest(
97
- this.sdk,
98
- `/journeys/${journeyId}/members/${memberId}`,
99
- 'GET',
100
- {},
101
- );
102
- }
103
-
104
- /**
105
- * Enrol people into a journey. Pass `dryRun: true` to get the pre-enrol
106
- * summary without writing anything.
107
- *
108
- * @param {string} journeyId
109
- * @param {Object} body
110
- * @param {string[]} [body.peopleIds] - Either peopleIds or filter is required
111
- * @param {Object} [body.filter]
112
- * @param {Object} [body.overrides] - Per-member channel overrides
113
- * @param {string} [body.ownerUserId]
114
- * @param {string} [body.source]
115
- * @param {boolean} [body.dryRun]
116
- * @param {string} [body.primaryChannel]
117
- * @param {string} [body.workflowVersionId]
118
- * @returns {Promise<Object>} dryRun: {ready, noChannel, notOptedIn,
119
- * suppressed, alreadyEnrolled, firstSendAt, outcomes}; real: enrol results
120
- */
121
- async enroll(journeyId, body = {}) {
122
- this.sdk.validateParams(
123
- { journeyId },
124
- { journeyId: { type: 'string', required: true } },
125
- );
126
- return await internalRequest(
127
- this.sdk,
128
- `/journeys/${journeyId}/members/enroll`,
129
- 'POST',
130
- { body: pickDefined(body) },
131
- );
132
- }
133
-
134
- /**
135
- * Apply a bulk action to selected member ids, or to everything matching
136
- * a filter under the caller's visibility.
137
- *
138
- * @param {string} journeyId
139
- * @param {Object} body
140
- * @param {'pause'|'resume'|'remove'|'reassign'|'changeChannel'} body.action
141
- * @param {string[]} [body.ids] - Either ids or filter is required
142
- * @param {Object} [body.filter] - e.g. `{ ownerUserId }` to target every
143
- * member currently owned by one rep (P5 "reassign-all-owned-by" is this
144
- * `action:'reassign'` + `filter:{ownerUserId}` combination -- no
145
- * dedicated endpoint/method was added).
146
- * @param {string} [body.reason]
147
- * @param {string} [body.ownerUserId] - New owner for `action:'reassign'`
148
- * @param {Object} [body.channels]
149
- * @returns {Promise<Object>} { results }
150
- */
151
- async actions(journeyId, body = {}) {
152
- this.sdk.validateParams(
153
- { journeyId, action: body?.action },
154
- {
155
- journeyId: { type: 'string', required: true },
156
- action: { type: 'string', required: true },
157
- },
158
- );
159
- return await internalRequest(
160
- this.sdk,
161
- `/journeys/${journeyId}/members/actions`,
162
- 'POST',
163
- { body: pickDefined(body) },
164
- );
165
- }
166
-
167
- /**
168
- * Fix a member's channel address and resume or remove it.
169
- *
170
- * @param {string} journeyId
171
- * @param {string} memberId
172
- * @param {Object} body
173
- * @param {string} [body.emailAddress]
174
- * @param {string} [body.phoneNumber]
175
- * @param {string} [body.smsNumber]
176
- * @param {'resume'|'remove'} body.then
177
- * @param {string} [body.reason]
178
- * @returns {Promise<Object>} Updated member
179
- */
180
- async fix(journeyId, memberId, body = {}) {
181
- this.sdk.validateParams(
182
- { journeyId, memberId, then: body?.then },
183
- {
184
- journeyId: { type: 'string', required: true },
185
- memberId: { type: 'string', required: true },
186
- then: { type: 'string', required: true },
187
- },
188
- );
189
- return await internalRequest(
190
- this.sdk,
191
- `/journeys/${journeyId}/members/${memberId}/fix`,
192
- 'POST',
193
- { body: pickDefined(body) },
194
- );
195
- }
196
-
197
- /**
198
- * @param {string} journeyId
199
- * @param {string} memberId
200
- * @returns {Promise<Array>} journeyMemberEvents rows, in order
201
- */
202
- async events(journeyId, memberId) {
203
- this.sdk.validateParams(
204
- { journeyId, memberId },
205
- {
206
- journeyId: { type: 'string', required: true },
207
- memberId: { type: 'string', required: true },
208
- },
209
- );
210
- return await internalRequest(
211
- this.sdk,
212
- `/journeys/${journeyId}/members/${memberId}/events`,
213
- 'GET',
214
- {},
215
- );
216
- }
217
-
218
- /**
219
- * Context-aware AI draft for a human touch-task step (record, step
220
- * intent, prior conversation) -- journeys-plan.md §9 P5. Not the final
221
- * send content; the rep edits/sends from the task itself.
222
- *
223
- * @param {string} memberId
224
- * @param {Object} body
225
- * @param {string} [body.stepKey]
226
- * @param {'email'|'sms'} body.channel
227
- * @returns {Promise<{data: {draft: string, channel: string, stepKey: string}}>}
228
- */
229
- async draft(memberId, body = {}) {
230
- this.sdk.validateParams(
231
- { memberId, channel: body?.channel },
232
- {
233
- memberId: { type: 'string', required: true },
234
- channel: { type: 'string', required: true },
235
- },
236
- );
237
- return await internalRequest(
238
- this.sdk,
239
- `/journeys/members/${memberId}/draft`,
240
- 'POST',
241
- { body: pickDefined(body) },
242
- );
243
- }
244
- }
@@ -1,53 +0,0 @@
1
- import { internalRequest } from '../../base.js';
2
-
3
- /**
4
- * `sdk.journeys.types.*` -- journeyTypes generic-object CRUD. `queueId`
5
- * stays empty until P5.
6
- */
7
- export class JourneyTypesService {
8
- constructor(sdk) {
9
- this.sdk = sdk;
10
- }
11
-
12
- async list(opts = {}) {
13
- return await this.sdk.objects.query({ object: 'journeyTypes', ...opts });
14
- }
15
-
16
- async get(id) {
17
- this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
18
- return await this.sdk.objects.byId({ id });
19
- }
20
-
21
- /**
22
- * @param {Object} body
23
- * @param {string} body.name
24
- * @returns {Promise<Object>} Created journeyType
25
- */
26
- async create(body) {
27
- this.sdk.validateParams(
28
- { name: body?.name },
29
- { name: { type: 'string', required: true } },
30
- );
31
- return await this.sdk.objects.create({ object: 'journeyTypes', body });
32
- }
33
-
34
- async update(id, update) {
35
- this.sdk.validateParams(
36
- { id, update },
37
- {
38
- id: { type: 'string', required: true },
39
- update: { type: 'object', required: true },
40
- },
41
- );
42
- return await this.sdk.objects.updateById({
43
- object: 'journeyTypes',
44
- id,
45
- update,
46
- });
47
- }
48
-
49
- async remove(id) {
50
- this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
51
- return await this.sdk.objects.deleteById({ object: 'journeyTypes', id });
52
- }
53
- }
@@ -1,74 +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
- * @typedef {Object} JourneyWorklistTask
13
- * @property {string} id
14
- * @property {'journey'} type
15
- * @property {'worklist'} deliveryMode
16
- * @property {string|null} dueAt
17
- * @property {string} journeyMemberId
18
- * @property {string} journeyId
19
- * @property {string} journeyStepKey
20
- * @property {'email'|'sms'|'call'|'other'} journeyStepChannel
21
- * @property {string|null} preferredWorkerId - Owner, or null for a pool task
22
- * @property {string|null} engagementSessionId
23
- */
24
-
25
- /**
26
- * Sales work list -- `sdk.journeys.worklist.*` (journeys-plan.md §9, P5).
27
- * Cross-journey view of a sales rep's (or the pool's) open touch tasks
28
- * (`tasks.type='journey'`), plus upcoming members from
29
- * `journeyMembers.nextActionAt`. Requires `users_acct.salesEnabled` for
30
- * `takeNext` (`list` stays open to ordinary object-read permission, per
31
- * the P5 contract).
32
- *
33
- * @see app1-api src/services/journeys/controllers/worklist.js
34
- */
35
- export class JourneyWorklistService {
36
- constructor(sdk) {
37
- this.sdk = sdk;
38
- }
39
-
40
- /**
41
- * @param {Object} [opts]
42
- * @param {'due'|'overdue'|'upcoming'} [opts.bucket]
43
- * @param {string} [opts.stepType]
44
- * @param {string} [opts.journeyId]
45
- * @param {number} [opts.page]
46
- * @param {number} [opts.pageSize]
47
- * @returns {Promise<{data: JourneyWorklistTask[]}>}
48
- */
49
- async list(opts = {}) {
50
- return await internalRequest(this.sdk, '/journeys/worklist', 'GET', {
51
- query: pickDefined(opts),
52
- });
53
- }
54
-
55
- /**
56
- * Takes the next due task for the caller (owner-or-pool), via the same
57
- * `transitionTask` path as a manual take (`PUT /tasks/:id
58
- * {status:'connected', workerId}`) -- not a separate silent-assign path.
59
- *
60
- * @param {Object} [filter]
61
- * @param {string} [filter.stepType]
62
- * @param {string} [filter.journeyId]
63
- * @param {string} [filter.taskId] take this exact task (validated server-side: worklist, pending, owner-or-pool)
64
- * @returns {Promise<{data: JourneyWorklistTask|null}>} null when nothing is due
65
- */
66
- async takeNext(filter = {}) {
67
- return await internalRequest(
68
- this.sdk,
69
- '/journeys/worklist/take-next',
70
- 'POST',
71
- { body: pickDefined(filter) },
72
- );
73
- }
74
- }