@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.
- package/README.md +7 -0
- package/base.js +74 -3
- package/index.js +7 -31
- package/lib/refreshInterceptor.js +127 -0
- package/package.json +2 -5
- package/services/layouts.js +4 -13
- package/services/licenses.js +330 -0
- package/services/login.js +21 -0
- package/services/messageTemplates.js +2 -109
- package/services/messaging/EmailTemplatesService.js +2 -10
- package/services/messaging/SmsService.js +3 -0
- package/services/messaging/SmsTemplatesService.js +125 -0
- package/services/messaging.js +2 -0
- package/services/oauth.js +159 -0
- package/services/objects.js +39 -12
- package/services/permissions.js +0 -21
- package/services/phoneNumbers.js +1037 -2
- package/services/recents.js +0 -16
- package/services/taskRouter/MetricsService.js +0 -3
- package/services/taskRouter/TaskRouterService.js +0 -2
- package/services/taskRouter/TaskService.js +10 -70
- package/services/voice.js +25 -47
- package/lib/journeyLayout.js +0 -132
- package/services/journeys/JourneyDraftService.js +0 -92
- package/services/journeys/JourneyGoalsService.js +0 -57
- package/services/journeys/JourneyMembersService.js +0 -246
- package/services/journeys/JourneyTypesService.js +0 -59
- package/services/journeys/JourneyWorklistService.js +0 -74
- package/services/journeys/JourneysService.js +0 -392
- package/services/operatorPanels.js +0 -226
- package/services/parking.js +0 -121
- package/services/phoneNumbers/carrier.js +0 -60
- package/services/phoneNumbers/cnam.js +0 -42
- package/services/phoneNumbers/index.js +0 -27
- package/services/phoneNumbers/order.js +0 -88
- package/services/phoneNumbers/porting-activity.js +0 -289
- package/services/phoneNumbers/porting-orders.js +0 -318
- package/services/phoneNumbers/search.js +0 -181
- package/services/phoneNumbers/update.js +0 -94
- package/services/schedules/SchedulesService.js +0 -232
- package/services/schedules/TimeOffService.js +0 -131
- package/services/skills.js +0 -207
- package/services/taskRouter/QueueService.js +0 -343
- package/services/voicemailDrops.js +0 -268
- package/services/workflowTemplates/WorkflowTemplatesService.js +0 -68
|
@@ -1,246 +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] active | paused | needsAttention | waiting (owner at capacity) | completed | converted | exited | removed
|
|
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] - used with ownerMode 'user'
|
|
114
|
-
* @param {'journeyDefault'|'recordOwner'|'user'|'pool'} [body.ownerMode] - journey/type default | each person's people.ownerId | one explicit user for all | no owner
|
|
115
|
-
* @param {{mode:'pool'}|{mode:'user', ownerUserId:string}} [body.ownerFallback] - with ownerMode 'recordOwner': what people WITHOUT a record owner get (default pool)
|
|
116
|
-
* @param {string} [body.source]
|
|
117
|
-
* @param {boolean} [body.dryRun]
|
|
118
|
-
* @param {string} [body.primaryChannel]
|
|
119
|
-
* @param {string} [body.workflowVersionId]
|
|
120
|
-
* @returns {Promise<Object>} dryRun: {ready, noChannel, notOptedIn,
|
|
121
|
-
* suppressed, alreadyEnrolled, firstSendAt, outcomes}; real: enrol results
|
|
122
|
-
*/
|
|
123
|
-
async enroll(journeyId, body = {}) {
|
|
124
|
-
this.sdk.validateParams(
|
|
125
|
-
{ journeyId },
|
|
126
|
-
{ journeyId: { type: 'string', required: true } },
|
|
127
|
-
);
|
|
128
|
-
return await internalRequest(
|
|
129
|
-
this.sdk,
|
|
130
|
-
`/journeys/${journeyId}/members/enroll`,
|
|
131
|
-
'POST',
|
|
132
|
-
{ body: pickDefined(body) },
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Apply a bulk action to selected member ids, or to everything matching
|
|
138
|
-
* a filter under the caller's visibility.
|
|
139
|
-
*
|
|
140
|
-
* @param {string} journeyId
|
|
141
|
-
* @param {Object} body
|
|
142
|
-
* @param {'pause'|'resume'|'remove'|'reassign'|'changeChannel'} body.action
|
|
143
|
-
* @param {string[]} [body.ids] - Either ids or filter is required
|
|
144
|
-
* @param {Object} [body.filter] - e.g. `{ ownerUserId }` to target every
|
|
145
|
-
* member currently owned by one rep (P5 "reassign-all-owned-by" is this
|
|
146
|
-
* `action:'reassign'` + `filter:{ownerUserId}` combination -- no
|
|
147
|
-
* dedicated endpoint/method was added).
|
|
148
|
-
* @param {string} [body.reason]
|
|
149
|
-
* @param {string} [body.ownerUserId] - New owner for `action:'reassign'`
|
|
150
|
-
* @param {Object} [body.channels]
|
|
151
|
-
* @returns {Promise<Object>} { results }
|
|
152
|
-
*/
|
|
153
|
-
async actions(journeyId, body = {}) {
|
|
154
|
-
this.sdk.validateParams(
|
|
155
|
-
{ journeyId, action: body?.action },
|
|
156
|
-
{
|
|
157
|
-
journeyId: { type: 'string', required: true },
|
|
158
|
-
action: { type: 'string', required: true },
|
|
159
|
-
},
|
|
160
|
-
);
|
|
161
|
-
return await internalRequest(
|
|
162
|
-
this.sdk,
|
|
163
|
-
`/journeys/${journeyId}/members/actions`,
|
|
164
|
-
'POST',
|
|
165
|
-
{ body: pickDefined(body) },
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Fix a member's channel address and resume or remove it.
|
|
171
|
-
*
|
|
172
|
-
* @param {string} journeyId
|
|
173
|
-
* @param {string} memberId
|
|
174
|
-
* @param {Object} body
|
|
175
|
-
* @param {string} [body.emailAddress]
|
|
176
|
-
* @param {string} [body.phoneNumber]
|
|
177
|
-
* @param {string} [body.smsNumber]
|
|
178
|
-
* @param {'resume'|'remove'} body.then
|
|
179
|
-
* @param {string} [body.reason]
|
|
180
|
-
* @returns {Promise<Object>} Updated member
|
|
181
|
-
*/
|
|
182
|
-
async fix(journeyId, memberId, body = {}) {
|
|
183
|
-
this.sdk.validateParams(
|
|
184
|
-
{ journeyId, memberId, then: body?.then },
|
|
185
|
-
{
|
|
186
|
-
journeyId: { type: 'string', required: true },
|
|
187
|
-
memberId: { type: 'string', required: true },
|
|
188
|
-
then: { type: 'string', required: true },
|
|
189
|
-
},
|
|
190
|
-
);
|
|
191
|
-
return await internalRequest(
|
|
192
|
-
this.sdk,
|
|
193
|
-
`/journeys/${journeyId}/members/${memberId}/fix`,
|
|
194
|
-
'POST',
|
|
195
|
-
{ body: pickDefined(body) },
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* @param {string} journeyId
|
|
201
|
-
* @param {string} memberId
|
|
202
|
-
* @returns {Promise<Array>} journeyMemberEvents rows, in order
|
|
203
|
-
*/
|
|
204
|
-
async events(journeyId, memberId) {
|
|
205
|
-
this.sdk.validateParams(
|
|
206
|
-
{ journeyId, memberId },
|
|
207
|
-
{
|
|
208
|
-
journeyId: { type: 'string', required: true },
|
|
209
|
-
memberId: { type: 'string', required: true },
|
|
210
|
-
},
|
|
211
|
-
);
|
|
212
|
-
return await internalRequest(
|
|
213
|
-
this.sdk,
|
|
214
|
-
`/journeys/${journeyId}/members/${memberId}/events`,
|
|
215
|
-
'GET',
|
|
216
|
-
{},
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Context-aware AI draft for a human touch-task step (record, step
|
|
222
|
-
* intent, prior conversation) -- journeys-plan.md §9 P5. Not the final
|
|
223
|
-
* send content; the rep edits/sends from the task itself.
|
|
224
|
-
*
|
|
225
|
-
* @param {string} memberId
|
|
226
|
-
* @param {Object} body
|
|
227
|
-
* @param {string} [body.stepKey]
|
|
228
|
-
* @param {'email'|'sms'} body.channel
|
|
229
|
-
* @returns {Promise<{data: {draft: string, channel: string, stepKey: string}}>}
|
|
230
|
-
*/
|
|
231
|
-
async draft(memberId, body = {}) {
|
|
232
|
-
this.sdk.validateParams(
|
|
233
|
-
{ memberId, channel: body?.channel },
|
|
234
|
-
{
|
|
235
|
-
memberId: { type: 'string', required: true },
|
|
236
|
-
channel: { type: 'string', required: true },
|
|
237
|
-
},
|
|
238
|
-
);
|
|
239
|
-
return await internalRequest(
|
|
240
|
-
this.sdk,
|
|
241
|
-
`/journeys/members/${memberId}/draft`,
|
|
242
|
-
'POST',
|
|
243
|
-
{ body: pickDefined(body) },
|
|
244
|
-
);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
@@ -1,59 +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
|
-
* @param {'firstTouchClaims'|'perTouch'} [body.poolClaimMode] - first rep to take a pool touch owns the member for the rest of the cadence (default) | no auto-claim
|
|
25
|
-
* @param {'never'|'ifEmpty'|'always'} [body.syncPersonOwner] - whether a member owner assignment also writes people.ownerId (default 'ifEmpty')
|
|
26
|
-
* @param {'person'|'company'} [body.ownerScope] - 'company': claims/reassigns fan out to every open member of the same company in this type (default 'person')
|
|
27
|
-
* @param {'reassign'|'needsAttention'} [body.ownerMissingPolicy] - owner deactivated / lost salesEnabled / left the queue: auto-reassign (backup user → round-robin → pool, default) or park with statusReason 'ownerMissing'
|
|
28
|
-
* @param {number|null} [body.maxActiveMembersPerOwner] - cap of active+needsAttention members per owner across the type; members over the cap wait (status 'waiting', statusReason 'ownerCapacity') and are admitted by people.score DESC, enteredAt ASC. null = unlimited
|
|
29
|
-
* All five are type defaults; a journey may override each with the same field (null = use type default).
|
|
30
|
-
* @returns {Promise<Object>} Created journeyType
|
|
31
|
-
*/
|
|
32
|
-
async create(body) {
|
|
33
|
-
this.sdk.validateParams(
|
|
34
|
-
{ name: body?.name },
|
|
35
|
-
{ name: { type: 'string', required: true } },
|
|
36
|
-
);
|
|
37
|
-
return await this.sdk.objects.create({ object: 'journeyTypes', body });
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async update(id, update) {
|
|
41
|
-
this.sdk.validateParams(
|
|
42
|
-
{ id, update },
|
|
43
|
-
{
|
|
44
|
-
id: { type: 'string', required: true },
|
|
45
|
-
update: { type: 'object', required: true },
|
|
46
|
-
},
|
|
47
|
-
);
|
|
48
|
-
return await this.sdk.objects.updateById({
|
|
49
|
-
object: 'journeyTypes',
|
|
50
|
-
id,
|
|
51
|
-
update,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async remove(id) {
|
|
56
|
-
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
57
|
-
return await this.sdk.objects.deleteById({ object: 'journeyTypes', id });
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -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
|
-
}
|