@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,392 +0,0 @@
|
|
|
1
|
-
import { internalRequest } from '../../base.js';
|
|
2
|
-
import { JourneyMembersService } from './JourneyMembersService.js';
|
|
3
|
-
import { JourneyDraftService } from './JourneyDraftService.js';
|
|
4
|
-
import { JourneyWorklistService } from './JourneyWorklistService.js';
|
|
5
|
-
import { JourneyTypesService } from './JourneyTypesService.js';
|
|
6
|
-
import { JourneyGoalsService } from './JourneyGoalsService.js';
|
|
7
|
-
|
|
8
|
-
function pickDefined(fields) {
|
|
9
|
-
const body = {};
|
|
10
|
-
for (const [key, value] of Object.entries(fields)) {
|
|
11
|
-
if (value !== undefined) body[key] = value;
|
|
12
|
-
}
|
|
13
|
-
return body;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Journeys (journeys-plan.md §2/§4) -- `sdk.journeys.*`.
|
|
18
|
-
*
|
|
19
|
-
* `journeyTypes`/`journeys`/`journeyGoals` are generic objects (registered
|
|
20
|
-
* isCreateable=1/isEditable=1/isDeletable=1, with customHandlers on the api
|
|
21
|
-
* side -- e.g. creating a journey also creates its companion workflow), so
|
|
22
|
-
* their CRUD here is a thin wrapper over `sdk.objects.*` the way
|
|
23
|
-
* `sdk.users.setStatus` wraps `sdk.objects.updateById` -- not a duplicate
|
|
24
|
-
* HTTP surface. `journeyMembers` (registered isCreateable=0/isEditable=0)
|
|
25
|
-
* and the member-grid/enrol/action/fix/events/stats endpoints are custom
|
|
26
|
-
* routes under `/journeys/`, covered by `members` and `stats`.
|
|
27
|
-
*
|
|
28
|
-
* P5 (journeys-plan.md §8, sales queues + human steps) added fields to
|
|
29
|
-
* several generic objects rather than new endpoints -- no dedicated SDK
|
|
30
|
-
* service exists for these, so they are documented here instead:
|
|
31
|
-
* - `sdk.objects` object `'queues'`: `queueType` ('support'|'sales',
|
|
32
|
-
* default 'support'), `deliveryMode` ('push'|'worklist', default
|
|
33
|
-
* 'push'). A sales queue is auto-created with a journey type
|
|
34
|
-
* (`queueType:'sales', deliveryMode:'worklist'`) and its id is set on
|
|
35
|
-
* `journeyTypes.queueId`.
|
|
36
|
-
* - `sdk.objects` object `'queueDispositions'`: `outcome`
|
|
37
|
-
* ('positive'|'neutral'|'negative'|null), `countsAsConversion`
|
|
38
|
-
* (boolean), `flagsBadContact` (boolean) -- drive a journey member's
|
|
39
|
-
* `converted` / `needsAttention:badContact` transitions when a touch
|
|
40
|
-
* task is given that disposition.
|
|
41
|
-
* - `sdk.objects` object `'users'` (`users_acct`): `salesEnabled`
|
|
42
|
-
* (boolean, default false) -- required (alongside normal object
|
|
43
|
-
* permissions) for journeys build/enrol/member-action/worklist-take
|
|
44
|
-
* endpoints; member-grid reads stay open to object-read permission.
|
|
45
|
-
* - Task rows (`sdk.taskRouter.task.*`, `sdk.journeys.worklist.*`) gain
|
|
46
|
-
* `deliveryMode` ('push'|'worklist'), `dueAt` (ISO datetime|null),
|
|
47
|
-
* `journeyMemberId`, `journeyId`, `journeyStepKey`, `journeyStepChannel`
|
|
48
|
-
* ('email'|'sms'|'call'|'other') on a journey touch task
|
|
49
|
-
* (`type:'journey'`). See `JourneyWorklistService`'s
|
|
50
|
-
* `JourneyWorklistTask` typedef for the full shape.
|
|
51
|
-
*
|
|
52
|
-
* @see app1-api src/services/journeys/routes.js
|
|
53
|
-
*/
|
|
54
|
-
export class JourneysService {
|
|
55
|
-
constructor(sdk) {
|
|
56
|
-
this.sdk = sdk;
|
|
57
|
-
this.members = new JourneyMembersService(sdk);
|
|
58
|
-
this.types = new JourneyTypesService(sdk);
|
|
59
|
-
this.goals = new JourneyGoalsService(sdk);
|
|
60
|
-
this.draft = new JourneyDraftService(sdk);
|
|
61
|
-
this.worklist = new JourneyWorklistService(sdk);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @param {Object} [opts] - sdk.objects.query opts (select, where, limit, nextId, …)
|
|
66
|
-
* @returns {Promise<Object>} Query result
|
|
67
|
-
*/
|
|
68
|
-
async list(opts = {}) {
|
|
69
|
-
return await this.sdk.objects.query({ object: 'journeys', ...opts });
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @param {string} id
|
|
74
|
-
* @returns {Promise<Object>} Journey record
|
|
75
|
-
*/
|
|
76
|
-
async get(id) {
|
|
77
|
-
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
78
|
-
return await this.sdk.objects.byId({ id });
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Creating a journey also creates its companion workflow
|
|
83
|
-
* (type='journey', builderMode='advanced' until P4) + a draft version.
|
|
84
|
-
*
|
|
85
|
-
* @param {Object} body
|
|
86
|
-
* @param {string} body.name
|
|
87
|
-
* @param {string} body.journeyTypeId
|
|
88
|
-
* @returns {Promise<Object>} Created journey, with workflowId/workflowVersionId
|
|
89
|
-
*/
|
|
90
|
-
async create(body) {
|
|
91
|
-
this.sdk.validateParams(
|
|
92
|
-
{ name: body?.name, journeyTypeId: body?.journeyTypeId },
|
|
93
|
-
{
|
|
94
|
-
name: { type: 'string', required: true },
|
|
95
|
-
journeyTypeId: { type: 'string', required: true },
|
|
96
|
-
},
|
|
97
|
-
);
|
|
98
|
-
return await this.sdk.objects.create({ object: 'journeys', body });
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* @param {string} id
|
|
103
|
-
* @param {Object} update
|
|
104
|
-
* @returns {Promise<Object>} Update result
|
|
105
|
-
*/
|
|
106
|
-
async update(id, update) {
|
|
107
|
-
this.sdk.validateParams(
|
|
108
|
-
{ id, update },
|
|
109
|
-
{
|
|
110
|
-
id: { type: 'string', required: true },
|
|
111
|
-
update: { type: 'object', required: true },
|
|
112
|
-
},
|
|
113
|
-
);
|
|
114
|
-
return await this.sdk.objects.updateById({ object: 'journeys', id, update });
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Delete ⇒ archive server-side (status: 'archived', never soft-deleted).
|
|
119
|
-
*
|
|
120
|
-
* @param {string} id
|
|
121
|
-
* @returns {Promise<Object>} { deleted: [id] }
|
|
122
|
-
*/
|
|
123
|
-
async archive(id) {
|
|
124
|
-
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
125
|
-
return await this.sdk.objects.deleteById({ object: 'journeys', id });
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* @param {string} journeyId
|
|
130
|
-
* @returns {Promise<Object>} { byStatus, needsAttentionByReason }
|
|
131
|
-
*/
|
|
132
|
-
async stats(journeyId) {
|
|
133
|
-
this.sdk.validateParams(
|
|
134
|
-
{ journeyId },
|
|
135
|
-
{ journeyId: { type: 'string', required: true } },
|
|
136
|
-
);
|
|
137
|
-
return await internalRequest(
|
|
138
|
-
this.sdk,
|
|
139
|
-
`/journeys/${journeyId}/stats`,
|
|
140
|
-
'GET',
|
|
141
|
-
{},
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Bulk equivalent of `stats()` for the Journeys list page -- one request
|
|
147
|
-
* instead of N. Journeys not found (or with no members) still get an
|
|
148
|
-
* entry, zeroed.
|
|
149
|
-
*
|
|
150
|
-
* @param {string[]} ids
|
|
151
|
-
* @returns {Promise<Object<string, {byStatus: Object, needsAttentionByReason: Object, total: number}>>}
|
|
152
|
-
*/
|
|
153
|
-
async listStats(ids) {
|
|
154
|
-
this.sdk.validateParams(
|
|
155
|
-
{ ids },
|
|
156
|
-
{ ids: { type: 'array', required: true } },
|
|
157
|
-
);
|
|
158
|
-
if (!ids.length) return {};
|
|
159
|
-
return await internalRequest(this.sdk, '/journeys/list-stats', 'GET', {
|
|
160
|
-
query: { ids: ids.join(',') },
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* REAL delete -- distinct from `archive()`. Only succeeds server-side
|
|
166
|
-
* when the journey is still a draft, or has zero members in any status;
|
|
167
|
-
* otherwise the API refuses with 409 `JOURNEY_HAS_MEMBERS` (archive it
|
|
168
|
-
* instead). Hard-deletes the journey row plus its companion workflow
|
|
169
|
-
* (and that workflow's versions/items/ports/connections) -- unlike
|
|
170
|
-
* `archive()`, this cannot be undone.
|
|
171
|
-
*
|
|
172
|
-
* @param {string} id
|
|
173
|
-
* @returns {Promise<Object>} { deleted: true, id, workflowId, memberCount }
|
|
174
|
-
*/
|
|
175
|
-
async remove(id) {
|
|
176
|
-
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
177
|
-
return await internalRequest(this.sdk, `/journeys/${id}`, 'DELETE', {});
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Diff of the current published journeyDoc vs the draft, by stepKey (P7).
|
|
182
|
-
*
|
|
183
|
-
* @param {string} id
|
|
184
|
-
* @returns {Promise<Object>} { oldVersionId, newVersionId, added, removed, changed }
|
|
185
|
-
*/
|
|
186
|
-
async publishDiff(id) {
|
|
187
|
-
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
188
|
-
return await internalRequest(
|
|
189
|
-
this.sdk,
|
|
190
|
-
`/journeys/${id}/publish-diff`,
|
|
191
|
-
'GET',
|
|
192
|
-
{},
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Publish the draft (runs publish-check; blocking items fail). Pass
|
|
198
|
-
* `{mode:'migrate', mapping}` to move open members on the old version to
|
|
199
|
-
* mapped landing steps at their next safe point (journeys-plan.md §7.5);
|
|
200
|
-
* omit for a plain publish (members stay on their version). Requires
|
|
201
|
-
* salesEnabled.
|
|
202
|
-
*
|
|
203
|
-
* @param {string} id
|
|
204
|
-
* @param {Object} [opts]
|
|
205
|
-
* @param {'migrate'|'leave'} [opts.mode]
|
|
206
|
-
* @param {Object<string,string>} [opts.mapping] removed stepKey -> landing stepKey | 'leave'
|
|
207
|
-
* @returns {Promise<Object>} { versionId, oldVersionId, migrationPlan }
|
|
208
|
-
*/
|
|
209
|
-
async publish(id, { mode, mapping } = {}) {
|
|
210
|
-
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
211
|
-
return await internalRequest(this.sdk, `/journeys/${id}/publish`, 'POST', {
|
|
212
|
-
body: { migrate: pickDefined({ mode, mapping }) },
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Per-step funnel (journeys-plan.md §9, P6): entered / outcome split /
|
|
218
|
-
* conversions from journeyMemberEvents. Test members are excluded.
|
|
219
|
-
*
|
|
220
|
-
* @param {string} journeyId
|
|
221
|
-
* @returns {Promise<Object>} { steps: [{ stepKey, type, title, entered, outcomes, conversions }] }
|
|
222
|
-
*/
|
|
223
|
-
async funnel(journeyId) {
|
|
224
|
-
this.sdk.validateParams(
|
|
225
|
-
{ journeyId },
|
|
226
|
-
{ journeyId: { type: 'string', required: true } },
|
|
227
|
-
);
|
|
228
|
-
return await internalRequest(
|
|
229
|
-
this.sdk,
|
|
230
|
-
`/journeys/${journeyId}/funnel`,
|
|
231
|
-
'GET',
|
|
232
|
-
{},
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Journey-level metrics (P6): enrolled, active, needsAttention, repliedPct,
|
|
238
|
-
* convertedPct, bounced, optedOut, timeToConvertMedianSeconds, byStatus.
|
|
239
|
-
*
|
|
240
|
-
* @param {string} journeyId
|
|
241
|
-
* @returns {Promise<Object>}
|
|
242
|
-
*/
|
|
243
|
-
async metrics(journeyId) {
|
|
244
|
-
this.sdk.validateParams(
|
|
245
|
-
{ journeyId },
|
|
246
|
-
{ journeyId: { type: 'string', required: true } },
|
|
247
|
-
);
|
|
248
|
-
return await internalRequest(
|
|
249
|
-
this.sdk,
|
|
250
|
-
`/journeys/${journeyId}/metrics`,
|
|
251
|
-
'GET',
|
|
252
|
-
{},
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Journey-wide activity feed (P6): journeyMemberEvents, newest first.
|
|
258
|
-
*
|
|
259
|
-
* @param {string} journeyId
|
|
260
|
-
* @param {Object} [opts]
|
|
261
|
-
* @param {string} [opts.stepKey]
|
|
262
|
-
* @param {string} [opts.memberId]
|
|
263
|
-
* @param {number} [opts.page]
|
|
264
|
-
* @param {number} [opts.pageSize]
|
|
265
|
-
* @returns {Promise<Object>} { rows, total }
|
|
266
|
-
*/
|
|
267
|
-
async events(journeyId, opts = {}) {
|
|
268
|
-
this.sdk.validateParams(
|
|
269
|
-
{ journeyId },
|
|
270
|
-
{ journeyId: { type: 'string', required: true } },
|
|
271
|
-
);
|
|
272
|
-
return await internalRequest(
|
|
273
|
-
this.sdk,
|
|
274
|
-
`/journeys/${journeyId}/events`,
|
|
275
|
-
'GET',
|
|
276
|
-
{ query: pickDefined(opts) },
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Rep metrics (P6): per owner — due, overdue, doneOnTime,
|
|
282
|
-
* timeToActionMedianSeconds — from touch tasks. Requires salesEnabled.
|
|
283
|
-
*
|
|
284
|
-
* @param {Object} [opts]
|
|
285
|
-
* @param {string} [opts.journeyTypeId]
|
|
286
|
-
* @param {string} [opts.journeyId]
|
|
287
|
-
* @param {string} [opts.from] ISO date-time
|
|
288
|
-
* @param {string} [opts.to] ISO date-time
|
|
289
|
-
* @returns {Promise<Object>} { reps: [{ userId, due, overdue, doneOnTime, timeToActionMedianSeconds }] }
|
|
290
|
-
*/
|
|
291
|
-
async repsMetrics(opts = {}) {
|
|
292
|
-
return await internalRequest(this.sdk, '/journeys/reps/metrics', 'GET', {
|
|
293
|
-
query: pickDefined(opts),
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* No-send dry run: per step, the resolved channel (override -> primary),
|
|
299
|
-
* rendered message, and landing date for a given person (journeys-plan.md
|
|
300
|
-
* §7.6, P4 templates area).
|
|
301
|
-
*
|
|
302
|
-
* @param {string} id
|
|
303
|
-
* @param {Object} params
|
|
304
|
-
* @param {string} params.peopleId
|
|
305
|
-
* @returns {Promise<Object>} { steps: [{ stepKey, channel, message, landingAt }] }
|
|
306
|
-
*/
|
|
307
|
-
async preview(id, { peopleId } = {}) {
|
|
308
|
-
this.sdk.validateParams(
|
|
309
|
-
{ id, peopleId },
|
|
310
|
-
{
|
|
311
|
-
id: { type: 'string', required: true },
|
|
312
|
-
peopleId: { type: 'string', required: true },
|
|
313
|
-
},
|
|
314
|
-
);
|
|
315
|
-
return await internalRequest(this.sdk, `/journeys/${id}/preview`, 'GET', {
|
|
316
|
-
query: { peopleId },
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* Enrols the caller as an `isTest` member: sends redirect to the caller's
|
|
322
|
-
* own email/number, waits compress to `TEST_RUN_WAIT_SECONDS`, and the
|
|
323
|
-
* member is excluded from stats/event counts.
|
|
324
|
-
*
|
|
325
|
-
* @param {string} id
|
|
326
|
-
* @param {Object} [params]
|
|
327
|
-
* @param {string} [params.peopleId]
|
|
328
|
-
* @param {string} [params.testEmail] - override destination
|
|
329
|
-
* @param {string} [params.testPhone] - override destination
|
|
330
|
-
* @returns {Promise<Object>} Enrolled test member
|
|
331
|
-
*/
|
|
332
|
-
async testRun(id, { peopleId, testEmail, testPhone } = {}) {
|
|
333
|
-
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
334
|
-
return await internalRequest(
|
|
335
|
-
this.sdk,
|
|
336
|
-
`/journeys/${id}/test-run`,
|
|
337
|
-
'POST',
|
|
338
|
-
{ body: pickDefined({ peopleId, testEmail, testPhone }) },
|
|
339
|
-
);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Export + install into the same account, keeping template refs
|
|
344
|
-
* (journeys-plan.md §7.7).
|
|
345
|
-
*
|
|
346
|
-
* @param {string} id
|
|
347
|
-
* @param {Object} [params]
|
|
348
|
-
* @param {string} [params.name]
|
|
349
|
-
* @returns {Promise<Object>} New journey + workflow + draft version
|
|
350
|
-
*/
|
|
351
|
-
async clone(id, { name } = {}) {
|
|
352
|
-
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
353
|
-
return await internalRequest(this.sdk, `/journeys/${id}/clone`, 'POST', {
|
|
354
|
-
body: pickDefined({ name }),
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Save this journey into the account's template library
|
|
360
|
-
* (`workflowTemplates`, journeys-plan.md §7.7).
|
|
361
|
-
*
|
|
362
|
-
* @param {string} id
|
|
363
|
-
* @param {Object} params
|
|
364
|
-
* @param {string} params.name
|
|
365
|
-
* @param {string} [params.summary]
|
|
366
|
-
* @param {string} [params.category]
|
|
367
|
-
* @param {'platform'|'account'} [params.visibility]
|
|
368
|
-
* @returns {Promise<Object>} Created workflowTemplates row
|
|
369
|
-
*/
|
|
370
|
-
async saveAsTemplate(id, { name, summary, category, visibility } = {}) {
|
|
371
|
-
this.sdk.validateParams(
|
|
372
|
-
{ id, name },
|
|
373
|
-
{
|
|
374
|
-
id: { type: 'string', required: true },
|
|
375
|
-
name: { type: 'string', required: true },
|
|
376
|
-
},
|
|
377
|
-
);
|
|
378
|
-
return await internalRequest(
|
|
379
|
-
this.sdk,
|
|
380
|
-
`/journeys/${id}/save-as-template`,
|
|
381
|
-
'POST',
|
|
382
|
-
{ body: pickDefined({ name, summary, category, visibility }) },
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
export {
|
|
388
|
-
JourneyTypesService,
|
|
389
|
-
JourneyGoalsService,
|
|
390
|
-
JourneyDraftService,
|
|
391
|
-
JourneyWorklistService,
|
|
392
|
-
};
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import { internalRequest } from '../base.js';
|
|
2
|
-
|
|
3
|
-
// Operator (receptionist) panels (plans/operator-panel-plan.md §4/§4.1).
|
|
4
|
-
export class OperatorPanelsService {
|
|
5
|
-
constructor(sdk) {
|
|
6
|
-
this.sdk = sdk;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Non-deleted panels the caller can see, each with `isMyDefault`, plus
|
|
11
|
-
* `prefs`.
|
|
12
|
-
*/
|
|
13
|
-
async listMine() {
|
|
14
|
-
return await internalRequest(this.sdk, '/operatorPanels/mine', 'GET', {});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @param {string} id - panel id
|
|
19
|
-
* @returns {Promise<Object>} render payload: ordered sections → items
|
|
20
|
-
*/
|
|
21
|
-
async getResolved(id) {
|
|
22
|
-
this.sdk.validateParams(
|
|
23
|
-
{ id },
|
|
24
|
-
{ id: { type: 'string', required: true } },
|
|
25
|
-
);
|
|
26
|
-
return await internalRequest(
|
|
27
|
-
this.sdk,
|
|
28
|
-
`/operatorPanels/${id}/resolved`,
|
|
29
|
-
'GET',
|
|
30
|
-
{},
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @param {Object} body - { defaultPanelId?, viewMode? }
|
|
36
|
-
*/
|
|
37
|
-
async setPrefs(body) {
|
|
38
|
-
this.sdk.validateParams(
|
|
39
|
-
{ body },
|
|
40
|
-
{ body: { type: 'object', required: true } },
|
|
41
|
-
);
|
|
42
|
-
return await internalRequest(this.sdk, '/operatorPanels/me/prefs', 'PUT', {
|
|
43
|
-
body,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @param {Object} params - { panelId }
|
|
49
|
-
*/
|
|
50
|
-
async listMessages({ panelId }) {
|
|
51
|
-
this.sdk.validateParams(
|
|
52
|
-
{ panelId },
|
|
53
|
-
{ panelId: { type: 'string', required: true } },
|
|
54
|
-
);
|
|
55
|
-
return await internalRequest(this.sdk, '/operatorPanels/messages', 'GET', {
|
|
56
|
-
query: { panelId },
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async list() {
|
|
61
|
-
return await internalRequest(this.sdk, '/operatorPanels', 'GET', {});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @param {Object} body - panel fields
|
|
66
|
-
*/
|
|
67
|
-
async create(body) {
|
|
68
|
-
this.sdk.validateParams(
|
|
69
|
-
{ body },
|
|
70
|
-
{ body: { type: 'object', required: true } },
|
|
71
|
-
);
|
|
72
|
-
return await internalRequest(this.sdk, '/operatorPanels', 'POST', {
|
|
73
|
-
body,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @param {string} id - panel id
|
|
79
|
-
* @param {Object} body - panel fields to update
|
|
80
|
-
*/
|
|
81
|
-
async update(id, body) {
|
|
82
|
-
this.sdk.validateParams(
|
|
83
|
-
{ id, body },
|
|
84
|
-
{
|
|
85
|
-
id: { type: 'string', required: true },
|
|
86
|
-
body: { type: 'object', required: true },
|
|
87
|
-
},
|
|
88
|
-
);
|
|
89
|
-
return await internalRequest(this.sdk, `/operatorPanels/${id}`, 'PUT', {
|
|
90
|
-
body,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* @param {string} id - panel id
|
|
96
|
-
*/
|
|
97
|
-
async remove(id) {
|
|
98
|
-
this.sdk.validateParams(
|
|
99
|
-
{ id },
|
|
100
|
-
{ id: { type: 'string', required: true } },
|
|
101
|
-
);
|
|
102
|
-
return await internalRequest(this.sdk, `/operatorPanels/${id}`, 'DELETE', {});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Replace a panel's full ordered item list.
|
|
107
|
-
*
|
|
108
|
-
* @param {string} id - panel id
|
|
109
|
-
* @param {Array<Object>} items
|
|
110
|
-
*/
|
|
111
|
-
async setItems(id, items) {
|
|
112
|
-
this.sdk.validateParams(
|
|
113
|
-
{ id, items },
|
|
114
|
-
{
|
|
115
|
-
id: { type: 'string', required: true },
|
|
116
|
-
items: { type: 'array', required: true },
|
|
117
|
-
},
|
|
118
|
-
);
|
|
119
|
-
return await internalRequest(
|
|
120
|
-
this.sdk,
|
|
121
|
-
`/operatorPanels/${id}/items`,
|
|
122
|
-
'PUT',
|
|
123
|
-
{ body: { items } },
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* @param {string} id - panel id
|
|
129
|
-
* @param {Array<{principalType: 'user'|'group', principalId: string}>} access
|
|
130
|
-
*/
|
|
131
|
-
async setAccess(id, access) {
|
|
132
|
-
this.sdk.validateParams(
|
|
133
|
-
{ id },
|
|
134
|
-
{ id: { type: 'string', required: true } },
|
|
135
|
-
);
|
|
136
|
-
return await internalRequest(
|
|
137
|
-
this.sdk,
|
|
138
|
-
`/operatorPanels/${id}/access`,
|
|
139
|
-
'PUT',
|
|
140
|
-
{ body: { access } },
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* @param {string} id - panel id
|
|
146
|
-
* @returns {Promise<{results: Array<{principalType: 'user'|'group', principalId: string, name: string|null}>}>}
|
|
147
|
-
*/
|
|
148
|
-
async getAccess(id) {
|
|
149
|
-
this.sdk.validateParams(
|
|
150
|
-
{ id },
|
|
151
|
-
{ id: { type: 'string', required: true } },
|
|
152
|
-
);
|
|
153
|
-
return await internalRequest(
|
|
154
|
-
this.sdk,
|
|
155
|
-
`/operatorPanels/${id}/access`,
|
|
156
|
-
'GET',
|
|
157
|
-
{},
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* @param {string} kind - users | groups | queues | ringGroups | workflows | records
|
|
163
|
-
* @param {string} [q] - search text
|
|
164
|
-
*/
|
|
165
|
-
async search(kind, q) {
|
|
166
|
-
this.sdk.validateParams(
|
|
167
|
-
{ kind },
|
|
168
|
-
{ kind: { type: 'string', required: true } },
|
|
169
|
-
);
|
|
170
|
-
return await internalRequest(
|
|
171
|
-
this.sdk,
|
|
172
|
-
`/operatorPanels/pickers/${kind}`,
|
|
173
|
-
'GET',
|
|
174
|
-
{ query: q ? { q } : {} },
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* @param {Object} body - message template fields
|
|
180
|
-
*/
|
|
181
|
-
async createMessage(body) {
|
|
182
|
-
this.sdk.validateParams(
|
|
183
|
-
{ body },
|
|
184
|
-
{ body: { type: 'object', required: true } },
|
|
185
|
-
);
|
|
186
|
-
return await internalRequest(this.sdk, '/operatorPanels/messages', 'POST', {
|
|
187
|
-
body,
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* @param {string} id - message id
|
|
193
|
-
* @param {Object} body - message fields to update
|
|
194
|
-
*/
|
|
195
|
-
async updateMessage(id, body) {
|
|
196
|
-
this.sdk.validateParams(
|
|
197
|
-
{ id, body },
|
|
198
|
-
{
|
|
199
|
-
id: { type: 'string', required: true },
|
|
200
|
-
body: { type: 'object', required: true },
|
|
201
|
-
},
|
|
202
|
-
);
|
|
203
|
-
return await internalRequest(
|
|
204
|
-
this.sdk,
|
|
205
|
-
`/operatorPanels/messages/${id}`,
|
|
206
|
-
'PUT',
|
|
207
|
-
{ body },
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* @param {string} id - message id
|
|
213
|
-
*/
|
|
214
|
-
async deleteMessage(id) {
|
|
215
|
-
this.sdk.validateParams(
|
|
216
|
-
{ id },
|
|
217
|
-
{ id: { type: 'string', required: true } },
|
|
218
|
-
);
|
|
219
|
-
return await internalRequest(
|
|
220
|
-
this.sdk,
|
|
221
|
-
`/operatorPanels/messages/${id}`,
|
|
222
|
-
'DELETE',
|
|
223
|
-
{},
|
|
224
|
-
);
|
|
225
|
-
}
|
|
226
|
-
}
|