@unboundcx/sdk 4.13.146-security.0 → 4.13.146-security.2

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 (41) hide show
  1. package/README.md +0 -7
  2. package/index.js +31 -1
  3. package/lib/journeyLayout.js +132 -0
  4. package/package.json +5 -2
  5. package/services/journeys/JourneyDraftService.js +92 -0
  6. package/services/journeys/JourneyGoalsService.js +57 -0
  7. package/services/journeys/JourneyMembersService.js +246 -0
  8. package/services/journeys/JourneyTypesService.js +59 -0
  9. package/services/journeys/JourneyWorklistService.js +74 -0
  10. package/services/journeys/JourneysService.js +392 -0
  11. package/services/layouts.js +13 -4
  12. package/services/licenses.js +21 -0
  13. package/services/messageTemplates.js +109 -2
  14. package/services/messaging/EmailTemplatesService.js +10 -2
  15. package/services/messaging/SmsService.js +0 -3
  16. package/services/messaging.js +0 -2
  17. package/services/objects.js +12 -39
  18. package/services/operatorPanels.js +226 -0
  19. package/services/parking.js +121 -0
  20. package/services/permissions.js +21 -0
  21. package/services/phoneNumbers/carrier.js +60 -0
  22. package/services/phoneNumbers/cnam.js +42 -0
  23. package/services/phoneNumbers/index.js +27 -0
  24. package/services/phoneNumbers/order.js +88 -0
  25. package/services/phoneNumbers/porting-activity.js +289 -0
  26. package/services/phoneNumbers/porting-orders.js +318 -0
  27. package/services/phoneNumbers/search.js +181 -0
  28. package/services/phoneNumbers/update.js +94 -0
  29. package/services/phoneNumbers.js +2 -1037
  30. package/services/recents.js +16 -0
  31. package/services/schedules/SchedulesService.js +232 -0
  32. package/services/schedules/TimeOffService.js +131 -0
  33. package/services/skills.js +207 -0
  34. package/services/taskRouter/MetricsService.js +3 -0
  35. package/services/taskRouter/QueueService.js +343 -0
  36. package/services/taskRouter/TaskRouterService.js +2 -0
  37. package/services/taskRouter/TaskService.js +70 -10
  38. package/services/voice.js +47 -25
  39. package/services/voicemailDrops.js +268 -0
  40. package/services/workflowTemplates/WorkflowTemplatesService.js +68 -0
  41. package/services/messaging/SmsTemplatesService.js +0 -125
@@ -0,0 +1,268 @@
1
+ import { internalRequest } from '../base.js';
2
+
3
+ /**
4
+ * Admin-managed voicemail drop types (voicemail-drop-plan.md §5). A type is
5
+ * the category a message belongs to (e.g. "Not home", "Left message");
6
+ * queues/journeys preselect by type.
7
+ */
8
+ export class VoicemailDropTypesService {
9
+ constructor(sdk) {
10
+ this.sdk = sdk;
11
+ }
12
+
13
+ /**
14
+ * List voicemail drop types.
15
+ * @param {Object} [params]
16
+ * @param {boolean} [params.includeInactive]
17
+ * @returns {Promise<{results: Object[]}>}
18
+ */
19
+ async list(params = {}) {
20
+ return internalRequest(this.sdk, '/voicemailDrops/types', 'GET', { query: { ...params } });
21
+ }
22
+
23
+ /**
24
+ * Get a single voicemail drop type.
25
+ * @param {string} id
26
+ * @returns {Promise<Object>}
27
+ */
28
+ async get(id) {
29
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
30
+ return internalRequest(this.sdk, `/voicemailDrops/types/${id}`, 'GET');
31
+ }
32
+
33
+ /**
34
+ * Create a voicemail drop type.
35
+ * @param {Object} options
36
+ * @param {string} options.name
37
+ * @param {string} [options.description]
38
+ * @param {boolean} [options.active]
39
+ * @returns {Promise<Object>}
40
+ */
41
+ async create(options = {}) {
42
+ this.sdk.validateParams(
43
+ { name: options.name },
44
+ { name: { type: 'string', required: true } },
45
+ );
46
+ return internalRequest(this.sdk, '/voicemailDrops/types', 'POST', {
47
+ body: { ...options },
48
+ });
49
+ }
50
+
51
+ /**
52
+ * Update a voicemail drop type.
53
+ * @param {string} id
54
+ * @param {Object} options
55
+ * @returns {Promise<Object>}
56
+ */
57
+ async update(id, options = {}) {
58
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
59
+ return internalRequest(this.sdk, `/voicemailDrops/types/${id}`, 'PUT', {
60
+ body: { ...options },
61
+ });
62
+ }
63
+
64
+ /**
65
+ * Remove (soft-delete) a voicemail drop type.
66
+ * @param {string} id
67
+ * @returns {Promise<{id: string, deleted: boolean}>}
68
+ */
69
+ async remove(id) {
70
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
71
+ return internalRequest(this.sdk, `/voicemailDrops/types/${id}`, 'DELETE');
72
+ }
73
+
74
+ /**
75
+ * Set which users/groups can see a voicemail drop type.
76
+ * @param {string} id
77
+ * @param {Object} options
78
+ * @param {string[]} [options.userIds]
79
+ * @param {string[]} [options.groupIds]
80
+ * @returns {Promise<Object>}
81
+ */
82
+ async setAccess(id, { userIds, groupIds } = {}) {
83
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
84
+ return internalRequest(this.sdk, `/voicemailDrops/types/${id}/access`, 'PUT', {
85
+ body: { userIds, groupIds },
86
+ });
87
+ }
88
+
89
+ /**
90
+ * List users who have recorded a voicemail drop message for this type.
91
+ * @param {string} id
92
+ * @returns {Promise<{results: Object[]}>}
93
+ */
94
+ async recordings(id) {
95
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
96
+ return internalRequest(this.sdk, `/voicemailDrops/types/${id}/recordings`, 'GET');
97
+ }
98
+ }
99
+
100
+ // Build a multipart body for a single audio file + scalar fields. Mirrors
101
+ // storage.js's node/browser FormData construction so this works in both
102
+ // environments without depending on StorageService internals.
103
+ function buildMultipart(file, fields) {
104
+ const isNode = typeof window === 'undefined';
105
+
106
+ if (!isNode) {
107
+ const formData = new FormData();
108
+ if (typeof Buffer !== 'undefined' && Buffer.isBuffer && Buffer.isBuffer(file)) {
109
+ formData.append('file', new Blob([file]), fields.fileName || 'file');
110
+ } else if (typeof File !== 'undefined' && file instanceof File) {
111
+ formData.append('file', file);
112
+ } else {
113
+ throw new Error('In browser environment, file must be a Buffer or File object');
114
+ }
115
+ for (const [name, value] of Object.entries(fields)) {
116
+ if (value === undefined || value === null) continue;
117
+ formData.append(name, typeof value === 'object' ? JSON.stringify(value) : String(value));
118
+ }
119
+ return { body: formData, headers: {} };
120
+ }
121
+
122
+ // Node: build the multipart buffer by hand.
123
+ const boundary = `----formdata-${Date.now()}-${Math.random().toString(36).slice(2)}`;
124
+ const CRLF = '\r\n';
125
+ const fileName = fields.fileName || 'file';
126
+ const parts = [];
127
+
128
+ parts.push(Buffer.from(
129
+ `--${boundary}${CRLF}Content-Disposition: form-data; name="file"; filename="${fileName}"${CRLF}` +
130
+ `Content-Type: application/octet-stream${CRLF}${CRLF}`,
131
+ 'utf8',
132
+ ));
133
+ parts.push(Buffer.isBuffer(file) ? file : Buffer.from(file));
134
+ parts.push(Buffer.from(CRLF, 'utf8'));
135
+
136
+ for (const [name, value] of Object.entries(fields)) {
137
+ if (value === undefined || value === null) continue;
138
+ const v = typeof value === 'object' ? JSON.stringify(value) : String(value);
139
+ parts.push(Buffer.from(
140
+ `--${boundary}${CRLF}Content-Disposition: form-data; name="${name}"${CRLF}${CRLF}${v}${CRLF}`,
141
+ 'utf8',
142
+ ));
143
+ }
144
+ parts.push(Buffer.from(`--${boundary}--${CRLF}`, 'utf8'));
145
+
146
+ return {
147
+ body: Buffer.concat(parts),
148
+ headers: { 'content-type': `multipart/form-data; boundary=${boundary}` },
149
+ };
150
+ }
151
+
152
+ /**
153
+ * Per-user voicemail drop messages (voicemail-drop-plan.md §5, §6). A
154
+ * message is either an uploaded/recorded file or TTS-generated, scoped to a
155
+ * type (or personal/untyped), with one default per type.
156
+ */
157
+ export class VoicemailDropsService {
158
+ constructor(sdk) {
159
+ this.sdk = sdk;
160
+ this.types = new VoicemailDropTypesService(sdk);
161
+ }
162
+
163
+ /**
164
+ * List the current user's own voicemail drop messages plus all active
165
+ * types, with `hasMessage` flagged per type.
166
+ * @returns {Promise<{messages: Object[], types: Object[]}>}
167
+ */
168
+ async listMine() {
169
+ return internalRequest(this.sdk, '/voicemailDrops/mine', 'GET');
170
+ }
171
+
172
+ /**
173
+ * Create a voicemail drop message — either an uploaded/recorded audio
174
+ * file (multipart, works in browser and Node) or a TTS message (plain
175
+ * JSON, no file needed).
176
+ * @param {Object} options
177
+ * @param {Object} [options.file] - Buffer or browser File; omit for TTS
178
+ * @param {string} options.name
179
+ * @param {string} [options.typeId]
180
+ * @param {string} [options.ttsText]
181
+ * @param {string} [options.ttsVoice]
182
+ * @param {boolean} [options.isDefault]
183
+ * @returns {Promise<Object>} the created row (status 'processing' until transcode completes)
184
+ */
185
+ async create({ file, name, typeId, ttsText, ttsVoice, isDefault, fileName } = {}) {
186
+ this.sdk.validateParams(
187
+ { name, typeId, ttsText, ttsVoice, isDefault, fileName },
188
+ {
189
+ name: { type: 'string', required: true },
190
+ typeId: { type: 'string', required: false },
191
+ ttsText: { type: 'string', required: false },
192
+ ttsVoice: { type: 'string', required: false },
193
+ isDefault: { type: 'boolean', required: false },
194
+ fileName: { type: 'string', required: false },
195
+ },
196
+ );
197
+
198
+ if (!file && !ttsText) {
199
+ throw new Error('create requires either file or ttsText');
200
+ }
201
+
202
+ if (file) {
203
+ const { body, headers } = buildMultipart(file, {
204
+ fileName,
205
+ name,
206
+ typeId,
207
+ isDefault,
208
+ });
209
+ return internalRequest(
210
+ this.sdk,
211
+ '/voicemailDrops',
212
+ 'POST',
213
+ { body, headers },
214
+ true,
215
+ );
216
+ }
217
+
218
+ return internalRequest(this.sdk, '/voicemailDrops', 'POST', {
219
+ body: { name, typeId, ttsText, ttsVoice, isDefault },
220
+ });
221
+ }
222
+
223
+ /**
224
+ * Update a voicemail drop message (rename, change type, set default).
225
+ * @param {string} id
226
+ * @param {Object} options
227
+ * @returns {Promise<Object>}
228
+ */
229
+ async update(id, options = {}) {
230
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
231
+ return internalRequest(this.sdk, `/voicemailDrops/${id}`, 'PUT', {
232
+ body: { ...options },
233
+ });
234
+ }
235
+
236
+ /**
237
+ * Remove (soft-delete) a voicemail drop message.
238
+ * @param {string} id
239
+ * @returns {Promise<{id: string, deleted: boolean}>}
240
+ */
241
+ async remove(id) {
242
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
243
+ return internalRequest(this.sdk, `/voicemailDrops/${id}`, 'DELETE');
244
+ }
245
+
246
+ /**
247
+ * Get a short-lived signed preview URL for a message's audio.
248
+ * @param {string} id
249
+ * @returns {Promise<{url: string}>}
250
+ */
251
+ async preview(id) {
252
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
253
+ return internalRequest(this.sdk, `/voicemailDrops/${id}/preview`, 'POST');
254
+ }
255
+
256
+ /**
257
+ * Admin: a user's message coverage per type.
258
+ * @param {string} userId
259
+ * @returns {Promise<{messages: Object[], types: Object[]}>}
260
+ */
261
+ async forUser(userId) {
262
+ this.sdk.validateParams(
263
+ { userId },
264
+ { userId: { type: 'string', required: true } },
265
+ );
266
+ return internalRequest(this.sdk, `/voicemailDrops/users/${userId}`, 'GET');
267
+ }
268
+ }
@@ -0,0 +1,68 @@
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
+ * Account-visible workflow template library -- `sdk.workflowTemplates.*`
13
+ * (journeys-plan.md §7.7, P4 templates area). `visibility`/access is
14
+ * service-only (accountId IS NULL for platform starters, or = caller);
15
+ * platform authoring (upsert) is INTERNAL-only (`/internal/journeys/
16
+ * templates`) with no customer-facing SDK surface -- there is no first-party
17
+ * INTERNAL SDK extension surface in this package to hang it on, so it is
18
+ * intentionally not wrapped here.
19
+ *
20
+ * @see app1-api src/services/journeys/routes.js (`/journeys/templates*`)
21
+ */
22
+ export class WorkflowTemplatesService {
23
+ constructor(sdk) {
24
+ this.sdk = sdk;
25
+ }
26
+
27
+ /**
28
+ * @param {Object} [params]
29
+ * @param {string} [params.workflowType] - defaults to 'journey' on the API
30
+ * @returns {Promise<Object[]>} Templates visible to the caller's account
31
+ */
32
+ async list({ workflowType } = {}) {
33
+ return await internalRequest(
34
+ this.sdk,
35
+ '/journeys/templates',
36
+ 'GET',
37
+ { query: pickDefined({ workflowType }) },
38
+ );
39
+ }
40
+
41
+ /**
42
+ * Installs a template into the caller's account as a new journey +
43
+ * workflow + draft version (+ journeyDoc when present) in one
44
+ * transaction, validated again at install time.
45
+ *
46
+ * @param {string} templateId
47
+ * @param {Object} params
48
+ * @param {string} params.journeyTypeId
49
+ * @param {Object} [params.answers] - answers to the template's `requirements`
50
+ * @param {string} [params.name] - override the template's default name
51
+ * @returns {Promise<Object>} New journey + workflow + draft version
52
+ */
53
+ async install(templateId, { journeyTypeId, answers, name } = {}) {
54
+ this.sdk.validateParams(
55
+ { templateId, journeyTypeId },
56
+ {
57
+ templateId: { type: 'string', required: true },
58
+ journeyTypeId: { type: 'string', required: true },
59
+ },
60
+ );
61
+ return await internalRequest(
62
+ this.sdk,
63
+ `/journeys/templates/${templateId}/install`,
64
+ 'POST',
65
+ { body: pickDefined({ journeyTypeId, answers, name }) },
66
+ );
67
+ }
68
+ }
@@ -1,125 +0,0 @@
1
- import { internalRequest } from '../../base.js';
2
- export class SmsTemplatesService {
3
- constructor(sdk) {
4
- this.sdk = sdk;
5
- }
6
-
7
- /**
8
- * Create SMS template
9
- * @param {Object} params - Template parameters
10
- * @param {string} params.name - Template name (required)
11
- * @param {string} params.message - Template message (required)
12
- * @param {Object} [params.variables] - Template variables
13
- * @returns {Promise<Object>} Created template details
14
- */
15
- async create({ name, message, variables }) {
16
- this.sdk.validateParams(
17
- { name, message },
18
- {
19
- name: { type: 'string', required: true },
20
- message: { type: 'string', required: true },
21
- variables: { type: 'object', required: false },
22
- },
23
- );
24
-
25
- const templateData = { name, message };
26
- if (variables) templateData.variables = variables;
27
-
28
- const options = {
29
- body: templateData,
30
- };
31
-
32
- const result = await internalRequest(this.sdk,
33
- '/messaging/sms/templates',
34
- 'POST',
35
- options,
36
- );
37
- return result;
38
- }
39
-
40
- /**
41
- * Update SMS template
42
- * @param {string} id - Template ID
43
- * @param {Object} params - Update parameters
44
- * @param {string} [params.name] - Template name
45
- * @param {string} [params.message] - Template message
46
- * @param {Object} [params.variables] - Template variables
47
- * @returns {Promise<Object>} Updated template details
48
- */
49
- async update(id, { name, message, variables }) {
50
- this.sdk.validateParams(
51
- { id },
52
- {
53
- id: { type: 'string', required: true },
54
- name: { type: 'string', required: false },
55
- message: { type: 'string', required: false },
56
- variables: { type: 'object', required: false },
57
- },
58
- );
59
-
60
- const updateData = {};
61
- if (name) updateData.name = name;
62
- if (message) updateData.message = message;
63
- if (variables) updateData.variables = variables;
64
-
65
- const options = {
66
- body: updateData,
67
- };
68
-
69
- const result = await internalRequest(this.sdk,
70
- `/messaging/sms/templates/${id}`,
71
- 'PUT',
72
- options,
73
- );
74
- return result;
75
- }
76
-
77
- /**
78
- * Delete SMS template
79
- * @param {string} id - Template ID
80
- * @returns {Promise<Object>} Deletion result
81
- */
82
- async delete(id) {
83
- this.sdk.validateParams(
84
- { id },
85
- {
86
- id: { type: 'string', required: true },
87
- },
88
- );
89
-
90
- const result = await internalRequest(this.sdk,
91
- `/messaging/sms/templates/${id}`,
92
- 'DELETE',
93
- );
94
- return result;
95
- }
96
-
97
- /**
98
- * Get SMS template by ID
99
- * @param {string} id - Template ID
100
- * @returns {Promise<Object>} Template details
101
- */
102
- async get(id) {
103
- this.sdk.validateParams(
104
- { id },
105
- {
106
- id: { type: 'string', required: true },
107
- },
108
- );
109
-
110
- const result = await internalRequest(this.sdk,
111
- `/messaging/sms/templates/${id}`,
112
- 'GET',
113
- );
114
- return result;
115
- }
116
-
117
- /**
118
- * List all SMS templates
119
- * @returns {Promise<Array>} List of templates
120
- */
121
- async list() {
122
- const result = await internalRequest(this.sdk, '/messaging/sms/templates', 'GET');
123
- return result;
124
- }
125
- }