@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.
- 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 -244
- package/services/journeys/JourneyTypesService.js +0 -53
- 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
package/services/recents.js
CHANGED
|
@@ -24,8 +24,6 @@ export class RecentsService {
|
|
|
24
24
|
* @param {boolean} [params.hasRecording] - Calls/meetings with a recording.
|
|
25
25
|
* @param {boolean} [params.hasTranscription] - Calls/meetings/voicemail
|
|
26
26
|
* with a transcript.
|
|
27
|
-
* @param {string} [params.voicemailBoxId] - Review this mailbox. Omit
|
|
28
|
-
* to list the current user's own voicemail.
|
|
29
27
|
* @returns {Promise<{items: Object[], nextCursor: string|null}>}
|
|
30
28
|
*/
|
|
31
29
|
async list({
|
|
@@ -40,7 +38,6 @@ export class RecentsService {
|
|
|
40
38
|
missed,
|
|
41
39
|
hasRecording,
|
|
42
40
|
hasTranscription,
|
|
43
|
-
voicemailBoxId,
|
|
44
41
|
} = {}) {
|
|
45
42
|
this.sdk.validateParams(
|
|
46
43
|
{
|
|
@@ -54,7 +51,6 @@ export class RecentsService {
|
|
|
54
51
|
missed,
|
|
55
52
|
hasRecording,
|
|
56
53
|
hasTranscription,
|
|
57
|
-
voicemailBoxId,
|
|
58
54
|
},
|
|
59
55
|
{
|
|
60
56
|
limit: { type: 'number', required: false },
|
|
@@ -67,7 +63,6 @@ export class RecentsService {
|
|
|
67
63
|
missed: { type: 'boolean', required: false },
|
|
68
64
|
hasRecording: { type: 'boolean', required: false },
|
|
69
65
|
hasTranscription: { type: 'boolean', required: false },
|
|
70
|
-
voicemailBoxId: { type: 'string', required: false },
|
|
71
66
|
},
|
|
72
67
|
);
|
|
73
68
|
|
|
@@ -95,7 +90,6 @@ export class RecentsService {
|
|
|
95
90
|
if (hasTranscription !== undefined) {
|
|
96
91
|
query.hasTranscription = hasTranscription;
|
|
97
92
|
}
|
|
98
|
-
if (voicemailBoxId !== undefined) query.voicemailBoxId = voicemailBoxId;
|
|
99
93
|
|
|
100
94
|
const params = { query };
|
|
101
95
|
|
|
@@ -135,16 +129,6 @@ export class RecentsService {
|
|
|
135
129
|
return result;
|
|
136
130
|
}
|
|
137
131
|
|
|
138
|
-
/**
|
|
139
|
-
* Mailboxes the current user can review: their own, then any personal
|
|
140
|
-
* boxes shared with them. Each row includes that box's unread count.
|
|
141
|
-
*
|
|
142
|
-
* @returns {Promise<{boxes: Object[]}>}
|
|
143
|
-
*/
|
|
144
|
-
async voicemailBoxes() {
|
|
145
|
-
return await internalRequest(this.sdk, '/recents/voicemailBoxes', 'GET');
|
|
146
|
-
}
|
|
147
|
-
|
|
148
132
|
/**
|
|
149
133
|
* Fetch recents stats (calls/talk time/missed/unread voicemail/meetings) for
|
|
150
134
|
* the current user.
|
|
@@ -60,9 +60,6 @@ export class MetricsService {
|
|
|
60
60
|
* limit: 50
|
|
61
61
|
* });
|
|
62
62
|
* console.log(queueMetrics.metrics.queue.avgWaitTime); // 45.3
|
|
63
|
-
* // Sales queues (queueType='sales') additionally carry metrics.sales:
|
|
64
|
-
* // { dueNow, overdue, takenOnTimePct, timeToActionMedianSeconds,
|
|
65
|
-
* // touchesCompletedToday, conversionsToday } (omitted for other queues)
|
|
66
63
|
*
|
|
67
64
|
* @example
|
|
68
65
|
* // Get worker metrics for last hour
|
|
@@ -5,7 +5,6 @@ import { CCService } from './CCService.js';
|
|
|
5
5
|
import { OfferService } from './OfferService.js';
|
|
6
6
|
import { ParticipantService } from './ParticipantService.js';
|
|
7
7
|
import { CcBotsService } from './CcBotsService.js';
|
|
8
|
-
import { QueueService } from './QueueService.js';
|
|
9
8
|
|
|
10
9
|
export class TaskRouterService {
|
|
11
10
|
constructor(sdk) {
|
|
@@ -17,6 +16,5 @@ export class TaskRouterService {
|
|
|
17
16
|
this.offer = new OfferService(sdk);
|
|
18
17
|
this.participants = new ParticipantService(sdk);
|
|
19
18
|
this.ccBots = new CcBotsService(sdk);
|
|
20
|
-
this.queues = new QueueService(sdk);
|
|
21
19
|
}
|
|
22
20
|
}
|
|
@@ -741,10 +741,6 @@ export class TaskService {
|
|
|
741
741
|
*
|
|
742
742
|
* @param {Object} options - Parameters
|
|
743
743
|
* @param {string} options.taskId - The task ID to move to wrap-up (required)
|
|
744
|
-
* @param {boolean} [options.skipSipHangup] - Skip hanging up the worker's SIP leg (e.g. a voicemail
|
|
745
|
-
* drop already released the leg; see voicemail-drop-plan.md §4.2.4)
|
|
746
|
-
* @param {string} [options.dispositionId] - Disposition to pre-fill/stamp for this wrap-up
|
|
747
|
-
* @param {Object} [options.metadata] - Extra context to carry into wrap-up (e.g. voicemail drop id/duration)
|
|
748
744
|
* @returns {Promise<Object>} Object containing the task ID and new status
|
|
749
745
|
* @returns {string} result.taskId - The task ID that was modified
|
|
750
746
|
* @returns {string} result.status - The new status ('wrapUp')
|
|
@@ -758,37 +754,24 @@ export class TaskService {
|
|
|
758
754
|
* // Move a held task to wrap-up
|
|
759
755
|
* const result = await sdk.taskRouter.task.wrapUp({ taskId: 'task456' });
|
|
760
756
|
* console.log(result.taskId); // "task456"
|
|
761
|
-
*
|
|
762
|
-
* @example
|
|
763
|
-
* // Voicemail drop: leg already released, pre-fill disposition
|
|
764
|
-
* const result = await sdk.taskRouter.task.wrapUp({
|
|
765
|
-
* taskId: 'task789',
|
|
766
|
-
* skipSipHangup: true,
|
|
767
|
-
* dispositionId: 'disp_leftVoicemail',
|
|
768
|
-
* metadata: { voicemailDropId: 'vmd_123', durationMs: 23000 },
|
|
769
|
-
* });
|
|
770
757
|
*/
|
|
771
758
|
async wrapUp(options = {}) {
|
|
772
|
-
const { taskId
|
|
759
|
+
const { taskId } = options;
|
|
773
760
|
|
|
774
761
|
this.sdk.validateParams(
|
|
775
|
-
{ taskId
|
|
762
|
+
{ taskId },
|
|
776
763
|
{
|
|
777
764
|
taskId: { type: 'string', required: true },
|
|
778
|
-
skipSipHangup: { type: 'boolean', required: false },
|
|
779
|
-
dispositionId: { type: 'string', required: false },
|
|
780
|
-
metadata: { type: 'object', required: false },
|
|
781
765
|
},
|
|
782
766
|
);
|
|
783
767
|
|
|
784
|
-
const
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
const params = { body };
|
|
768
|
+
const params = {
|
|
769
|
+
body: {
|
|
770
|
+
taskId,
|
|
771
|
+
},
|
|
772
|
+
};
|
|
790
773
|
|
|
791
|
-
const result = await internalRequest(this.sdk,
|
|
774
|
+
const result = await internalRequest(this.sdk,
|
|
792
775
|
'/taskRouter/tasks/wrapUp',
|
|
793
776
|
'PUT',
|
|
794
777
|
params,
|
|
@@ -1146,7 +1129,6 @@ export class TaskService {
|
|
|
1146
1129
|
* @param {string} options.taskId
|
|
1147
1130
|
* @param {string} [options.html]
|
|
1148
1131
|
* @param {string} [options.text]
|
|
1149
|
-
* @param {string} [options.subject] - explicit subject (journey touch tasks / first email on a task); thread replies omit it and inherit
|
|
1150
1132
|
* @param {string|string[]} [options.extraTo]
|
|
1151
1133
|
* @param {string|string[]} [options.extraCc]
|
|
1152
1134
|
* @param {string|string[]} [options.extraBcc]
|
|
@@ -1159,7 +1141,6 @@ export class TaskService {
|
|
|
1159
1141
|
taskId,
|
|
1160
1142
|
html,
|
|
1161
1143
|
text,
|
|
1162
|
-
subject,
|
|
1163
1144
|
extraTo,
|
|
1164
1145
|
extraCc,
|
|
1165
1146
|
extraBcc,
|
|
@@ -1176,7 +1157,6 @@ export class TaskService {
|
|
|
1176
1157
|
const body = {};
|
|
1177
1158
|
if (html !== undefined) body.html = html;
|
|
1178
1159
|
if (text !== undefined) body.text = text;
|
|
1179
|
-
if (subject !== undefined) body.subject = subject;
|
|
1180
1160
|
if (extraTo !== undefined) body.extraTo = extraTo;
|
|
1181
1161
|
if (extraCc !== undefined) body.extraCc = extraCc;
|
|
1182
1162
|
if (extraBcc !== undefined) body.extraBcc = extraBcc;
|
|
@@ -1269,7 +1249,6 @@ export class TaskService {
|
|
|
1269
1249
|
* @param {string} [options.note] - Optional note for the receiving agent
|
|
1270
1250
|
* @param {string} [options.reasonCode] - Transfer reason code — e.g. 'wrong_department', 'customer_requested', 'out_of_scope', 'policy_never_bot', 'language', 'other'. Required when the caller's worker is a bot.
|
|
1271
1251
|
* @param {string} [options.reason] - One-sentence transfer reason. Required when the caller's worker is a bot.
|
|
1272
|
-
* @param {number} [options.priorityAdjust] - Amount to add to (or, negative, subtract from) the task's priority on the new task created in the target queue.
|
|
1273
1252
|
* @returns {Promise<Object>} { taskId, newTaskId }
|
|
1274
1253
|
*
|
|
1275
1254
|
* @example
|
|
@@ -1282,18 +1261,16 @@ export class TaskService {
|
|
|
1282
1261
|
* });
|
|
1283
1262
|
*/
|
|
1284
1263
|
async transfer(options = {}) {
|
|
1285
|
-
const { taskId, target, note, reasonCode, reason
|
|
1286
|
-
options;
|
|
1264
|
+
const { taskId, target, note, reasonCode, reason } = options;
|
|
1287
1265
|
|
|
1288
1266
|
this.sdk.validateParams(
|
|
1289
|
-
{ taskId, target, note, reasonCode, reason
|
|
1267
|
+
{ taskId, target, note, reasonCode, reason },
|
|
1290
1268
|
{
|
|
1291
1269
|
taskId: { type: 'string', required: true },
|
|
1292
1270
|
target: { type: 'object', required: true },
|
|
1293
1271
|
note: { type: 'string', required: false },
|
|
1294
1272
|
reasonCode: { type: 'string', required: false },
|
|
1295
1273
|
reason: { type: 'string', required: false },
|
|
1296
|
-
priorityAdjust: { type: 'number', required: false },
|
|
1297
1274
|
},
|
|
1298
1275
|
);
|
|
1299
1276
|
|
|
@@ -1301,8 +1278,6 @@ export class TaskService {
|
|
|
1301
1278
|
if (note !== undefined) params.body.note = note;
|
|
1302
1279
|
if (reasonCode !== undefined) params.body.reasonCode = reasonCode;
|
|
1303
1280
|
if (reason !== undefined) params.body.reason = reason;
|
|
1304
|
-
if (priorityAdjust !== undefined)
|
|
1305
|
-
params.body.priorityAdjust = priorityAdjust;
|
|
1306
1281
|
|
|
1307
1282
|
return await internalRequest(
|
|
1308
1283
|
this.sdk,
|
|
@@ -1312,41 +1287,6 @@ export class TaskService {
|
|
|
1312
1287
|
);
|
|
1313
1288
|
}
|
|
1314
1289
|
|
|
1315
|
-
/**
|
|
1316
|
-
* Advisory preview of where a transfer would land right now — calls the
|
|
1317
|
-
* same resolver the real transfer uses, so a UI can show "sent to Queue
|
|
1318
|
-
* Y" before the transfer completes. Never guaranteed to land there under
|
|
1319
|
-
* load; the real transfer re-resolves at claim time.
|
|
1320
|
-
*
|
|
1321
|
-
* @param {string} taskId - The task ID to preview a transfer destination for (required)
|
|
1322
|
-
* @param {Object} options - Parameters
|
|
1323
|
-
* @param {string} options.queueId - Candidate destination queue ID (required)
|
|
1324
|
-
* @returns {Promise<Object>} Resolved destination, shaped by the same logic `transfer` itself uses for this queue/task type.
|
|
1325
|
-
*
|
|
1326
|
-
* @example
|
|
1327
|
-
* const preview = await sdk.taskRouter.task.resolveTransferDestination('task123', {
|
|
1328
|
-
* queueId: 'billingQueue1',
|
|
1329
|
-
* });
|
|
1330
|
-
*/
|
|
1331
|
-
async resolveTransferDestination(taskId, options = {}) {
|
|
1332
|
-
const { queueId } = options;
|
|
1333
|
-
|
|
1334
|
-
this.sdk.validateParams(
|
|
1335
|
-
{ taskId, queueId },
|
|
1336
|
-
{
|
|
1337
|
-
taskId: { type: 'string', required: true },
|
|
1338
|
-
queueId: { type: 'string', required: true },
|
|
1339
|
-
},
|
|
1340
|
-
);
|
|
1341
|
-
|
|
1342
|
-
return await internalRequest(
|
|
1343
|
-
this.sdk,
|
|
1344
|
-
`/taskRouter/tasks/${taskId}/resolveTransferDestination`,
|
|
1345
|
-
'POST',
|
|
1346
|
-
{ body: { queueId } },
|
|
1347
|
-
);
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1350
1290
|
/**
|
|
1351
1291
|
* Get the voice transcript for a task, keyed by the media-manager
|
|
1352
1292
|
* bridgeId (not sipCallId) so it works across requeue/transfer.
|
package/services/voice.js
CHANGED
|
@@ -353,62 +353,40 @@ export class VoiceService {
|
|
|
353
353
|
return this.transcribe(voiceChannelId, 'stop', direction);
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
*/
|
|
365
|
-
async transferCall({ callId, to }) {
|
|
356
|
+
async transfer({
|
|
357
|
+
channels,
|
|
358
|
+
to,
|
|
359
|
+
callerIdName,
|
|
360
|
+
callerIdNumber,
|
|
361
|
+
timeout,
|
|
362
|
+
voiceApp,
|
|
363
|
+
}) {
|
|
366
364
|
this.sdk.validateParams(
|
|
367
|
-
{
|
|
365
|
+
{ channels },
|
|
368
366
|
{
|
|
369
|
-
|
|
370
|
-
to: { type: 'string', required:
|
|
367
|
+
channels: { type: 'array', required: true },
|
|
368
|
+
to: { type: 'string', required: false },
|
|
369
|
+
callerIdName: { type: 'string', required: false },
|
|
370
|
+
callerIdNumber: { type: 'string', required: false },
|
|
371
|
+
timeout: { type: 'number', required: false },
|
|
372
|
+
voiceApp: { type: 'object', required: false },
|
|
371
373
|
},
|
|
372
374
|
);
|
|
373
375
|
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
);
|
|
380
|
-
return result;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* Drop a pre-recorded/TTS voicemail message on an active outbound call and
|
|
385
|
-
* release the leg immediately (voicemail-drop-plan.md §4.2, §5).
|
|
386
|
-
*
|
|
387
|
-
* @param {Object} options
|
|
388
|
-
* @param {string} options.callId - The call ID to drop the message on (required)
|
|
389
|
-
* @param {string} options.dropId - The voicemail drop message id to play (required)
|
|
390
|
-
* @returns {Promise<Object>} result.status
|
|
391
|
-
*
|
|
392
|
-
* @example
|
|
393
|
-
* const result = await sdk.voice.voicemailDrop({ callId: 'call123', dropId: 'vmd_456' });
|
|
394
|
-
*/
|
|
395
|
-
async voicemailDrop({ callId, dropId }) {
|
|
396
|
-
this.sdk.validateParams(
|
|
397
|
-
{ callId, dropId },
|
|
398
|
-
{
|
|
399
|
-
callId: { type: 'string', required: true },
|
|
400
|
-
dropId: { type: 'string', required: true },
|
|
401
|
-
},
|
|
402
|
-
);
|
|
376
|
+
const bodyData = { channels };
|
|
377
|
+
if (to) bodyData.to = to;
|
|
378
|
+
if (callerIdName) bodyData.callerIdName = callerIdName;
|
|
379
|
+
if (callerIdNumber) bodyData.callerIdNumber = callerIdNumber;
|
|
380
|
+
if (timeout !== undefined) bodyData.timeout = timeout;
|
|
381
|
+
if (voiceApp) bodyData.voiceApp = voiceApp;
|
|
403
382
|
|
|
404
383
|
const params = {
|
|
405
|
-
body:
|
|
384
|
+
body: bodyData,
|
|
406
385
|
};
|
|
407
386
|
|
|
408
|
-
const result = await internalRequest(
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
'PUT',
|
|
387
|
+
const result = await internalRequest(this.sdk,
|
|
388
|
+
'/voice/calls/transfer',
|
|
389
|
+
'POST',
|
|
412
390
|
params,
|
|
413
391
|
);
|
|
414
392
|
return result;
|
package/lib/journeyLayout.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
// Shared journey step-list layout (journeys-plan.md §7.3). Pure function,
|
|
2
|
-
// no DOM/Svelte — consumed by the API compiler (positions written into
|
|
3
|
-
// workflowItems.position) and the client's step-list / read-only canvas
|
|
4
|
-
// preview, so geometry never drifts between the two.
|
|
5
|
-
//
|
|
6
|
-
// Node width = max(240, pad + portCount * portWidth) so a step with more
|
|
7
|
-
// outcome ports (e.g. journeySms with several expected-reply rows) renders
|
|
8
|
-
// wide enough for all of them. Main path sits in column 0, top to bottom in
|
|
9
|
-
// doc order. A side path (one outcome's target.kind === 'side') renders as
|
|
10
|
-
// a linear vertical stack in the next column to the right, in outcome
|
|
11
|
-
// order; the row the branch step occupies grows tall enough to hold the
|
|
12
|
-
// tallest concurrent side path. Forward jumps (an outcome's target.kind ===
|
|
13
|
-
// 'step' pointing at a later main-path step) get a lane in a left-gutter
|
|
14
|
-
// reserved for wire routing, bounded by MAX_LANES — the same bound
|
|
15
|
-
// app1-client's wireLayout.js uses for the advanced canvas, kept in sync
|
|
16
|
-
// here as a literal with this comment rather than a cross-package import.
|
|
17
|
-
export const MAX_LANES = 6;
|
|
18
|
-
|
|
19
|
-
const DEFAULTS = {
|
|
20
|
-
portWidth: 56,
|
|
21
|
-
pad: 48,
|
|
22
|
-
nodeHeight: 90,
|
|
23
|
-
rowGap: 40,
|
|
24
|
-
colGap: 80,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
function portCount(step) {
|
|
28
|
-
return Math.max(1, (step?.outcomes || []).length);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function widthForStep(step, { pad, portWidth }) {
|
|
32
|
-
return Math.max(240, pad + portCount(step) * portWidth);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Depth-first walk collecting every step (main + nested side-path steps) so
|
|
36
|
-
// widths can be computed for all of them in one pass.
|
|
37
|
-
function collectAllSteps(steps, opts, widths, acc = []) {
|
|
38
|
-
for (const step of steps || []) {
|
|
39
|
-
if (!step?.stepKey) continue;
|
|
40
|
-
acc.push(step);
|
|
41
|
-
widths[step.stepKey] = widthForStep(step, opts);
|
|
42
|
-
for (const outcome of step.outcomes || []) {
|
|
43
|
-
if (outcome?.target?.kind === 'side' && Array.isArray(outcome.target.steps)) {
|
|
44
|
-
collectAllSteps(outcome.target.steps, opts, widths, acc);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return acc;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function layoutJourney(doc, opts = {}) {
|
|
52
|
-
const options = { ...DEFAULTS, ...opts };
|
|
53
|
-
const { pad, nodeHeight, rowGap, colGap } = options;
|
|
54
|
-
const steps = Array.isArray(doc?.steps) ? doc.steps : [];
|
|
55
|
-
|
|
56
|
-
const widths = {};
|
|
57
|
-
const positions = {};
|
|
58
|
-
const lanes = {};
|
|
59
|
-
|
|
60
|
-
collectAllSteps(steps, options, widths);
|
|
61
|
-
|
|
62
|
-
const mainIndex = new Map();
|
|
63
|
-
steps.forEach((step, i) => mainIndex.set(step.stepKey, i));
|
|
64
|
-
|
|
65
|
-
// --- positions: main path column 0, side paths to the right ---
|
|
66
|
-
const colWidths = [];
|
|
67
|
-
colWidths[0] = Math.max(240, ...steps.map((s) => widths[s.stepKey] || 240));
|
|
68
|
-
|
|
69
|
-
let y = pad;
|
|
70
|
-
for (const step of steps) {
|
|
71
|
-
positions[step.stepKey] = { x: pad, y };
|
|
72
|
-
let rowHeight = nodeHeight;
|
|
73
|
-
let col = 1;
|
|
74
|
-
|
|
75
|
-
for (const outcome of step.outcomes || []) {
|
|
76
|
-
if (outcome?.target?.kind === 'side' && Array.isArray(outcome.target.steps)) {
|
|
77
|
-
const sideSteps = outcome.target.steps.filter((s) => s?.stepKey);
|
|
78
|
-
if (!sideSteps.length) {
|
|
79
|
-
col += 1;
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
colWidths[col] = Math.max(
|
|
83
|
-
colWidths[col] || 240,
|
|
84
|
-
...sideSteps.map((s) => widths[s.stepKey] || 240),
|
|
85
|
-
);
|
|
86
|
-
const xOffset =
|
|
87
|
-
pad + colWidths.slice(0, col).reduce((sum, w) => sum + w + colGap, 0);
|
|
88
|
-
let sideY = y;
|
|
89
|
-
sideSteps.forEach((sideStep) => {
|
|
90
|
-
positions[sideStep.stepKey] = { x: xOffset, y: sideY };
|
|
91
|
-
sideY += nodeHeight + rowGap;
|
|
92
|
-
});
|
|
93
|
-
const sideHeight =
|
|
94
|
-
sideSteps.length * nodeHeight + (sideSteps.length - 1) * rowGap;
|
|
95
|
-
rowHeight = Math.max(rowHeight, sideHeight);
|
|
96
|
-
col += 1;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
y += rowHeight + rowGap;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// --- lanes: forward-jump wires (target.kind === 'step', later index) ---
|
|
104
|
-
const forwardJumps = [];
|
|
105
|
-
steps.forEach((step, i) => {
|
|
106
|
-
for (const outcome of step.outcomes || []) {
|
|
107
|
-
if (outcome?.target?.kind === 'step') {
|
|
108
|
-
const j = mainIndex.get(outcome.target.stepKey);
|
|
109
|
-
if (j != null && j > i) {
|
|
110
|
-
forwardJumps.push({ from: i, to: j, stepKey: step.stepKey, port: outcome.port });
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
forwardJumps.sort((a, b) => a.from - b.from || a.to - b.to);
|
|
116
|
-
|
|
117
|
-
const laneEndsAt = [];
|
|
118
|
-
for (const jump of forwardJumps) {
|
|
119
|
-
let lane = laneEndsAt.findIndex(
|
|
120
|
-
(endsAt) => endsAt === undefined || endsAt <= jump.from,
|
|
121
|
-
);
|
|
122
|
-
if (lane === -1) {
|
|
123
|
-
lane = Math.min(laneEndsAt.length, MAX_LANES - 1);
|
|
124
|
-
}
|
|
125
|
-
laneEndsAt[lane] = jump.to;
|
|
126
|
-
lanes[`${jump.stepKey}:${jump.port}`] = lane;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return { positions, widths, lanes };
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export default { layoutJourney, MAX_LANES };
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { internalRequest } from '../../base.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Simple-builder draft surface -- `sdk.journeys.draft.*` (journeys-plan.md
|
|
5
|
-
* §7.3/§7.4, P4 compile area). Custom routes mounted at
|
|
6
|
-
* `/journeys/:id/draft*`, `/journeys/:id/publish-check`,
|
|
7
|
-
* `/journeys/:id/convert-to-advanced`.
|
|
8
|
-
*
|
|
9
|
-
* @see app1-api src/services/journeys/routes.js
|
|
10
|
-
* @see app1-api src/services/journeys/controllers/compile.js
|
|
11
|
-
*/
|
|
12
|
-
export class JourneyDraftService {
|
|
13
|
-
constructor(sdk) {
|
|
14
|
-
this.sdk = sdk;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @param {string} journeyId
|
|
19
|
-
* @returns {Promise<Object>} { version, doc, builderMode }
|
|
20
|
-
*/
|
|
21
|
-
async get(journeyId) {
|
|
22
|
-
this.sdk.validateParams(
|
|
23
|
-
{ journeyId },
|
|
24
|
-
{ journeyId: { type: 'string', required: true } },
|
|
25
|
-
);
|
|
26
|
-
return await internalRequest(
|
|
27
|
-
this.sdk,
|
|
28
|
-
`/journeys/${journeyId}/draft`,
|
|
29
|
-
'GET',
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Compile the simple-builder step doc into workflowItems/ports/
|
|
35
|
-
* connections/positions in one transaction. 409s if the journey's
|
|
36
|
-
* `builderMode` is `'advanced'` (doc is ignored once converted).
|
|
37
|
-
*
|
|
38
|
-
* @param {string} journeyId
|
|
39
|
-
* @param {Object} doc - journeyDoc shape (journeys-plan.md §7.2)
|
|
40
|
-
* @returns {Promise<Object>} { doc (with dayOffset), itemsByStepKey }
|
|
41
|
-
*/
|
|
42
|
-
async saveSteps(journeyId, doc) {
|
|
43
|
-
this.sdk.validateParams(
|
|
44
|
-
{ journeyId, doc },
|
|
45
|
-
{
|
|
46
|
-
journeyId: { type: 'string', required: true },
|
|
47
|
-
doc: { type: 'object', required: true },
|
|
48
|
-
},
|
|
49
|
-
);
|
|
50
|
-
return await internalRequest(
|
|
51
|
-
this.sdk,
|
|
52
|
-
`/journeys/${journeyId}/draft/steps`,
|
|
53
|
-
'PUT',
|
|
54
|
-
{ body: { doc } },
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* One-way: `simple` -> `advanced` only. Once advanced, the journeyDoc is
|
|
60
|
-
* ignored and compile is unavailable (`saveSteps` 409s).
|
|
61
|
-
*
|
|
62
|
-
* @param {string} journeyId
|
|
63
|
-
* @returns {Promise<Object>} Updated journey
|
|
64
|
-
*/
|
|
65
|
-
async convertToAdvanced(journeyId) {
|
|
66
|
-
this.sdk.validateParams(
|
|
67
|
-
{ journeyId },
|
|
68
|
-
{ journeyId: { type: 'string', required: true } },
|
|
69
|
-
);
|
|
70
|
-
return await internalRequest(
|
|
71
|
-
this.sdk,
|
|
72
|
-
`/journeys/${journeyId}/convert-to-advanced`,
|
|
73
|
-
'POST',
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @param {string} journeyId
|
|
79
|
-
* @returns {Promise<Object>} { blocking, warnings }
|
|
80
|
-
*/
|
|
81
|
-
async publishCheck(journeyId) {
|
|
82
|
-
this.sdk.validateParams(
|
|
83
|
-
{ journeyId },
|
|
84
|
-
{ journeyId: { type: 'string', required: true } },
|
|
85
|
-
);
|
|
86
|
-
return await internalRequest(
|
|
87
|
-
this.sdk,
|
|
88
|
-
`/journeys/${journeyId}/publish-check`,
|
|
89
|
-
'GET',
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { internalRequest } from '../../base.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* `sdk.journeys.goals.*` -- journeyGoals generic-object CRUD (no `get`;
|
|
5
|
-
* goals are listed/edited inline on the journey, matching the plan's CRUD
|
|
6
|
-
* surface for this object).
|
|
7
|
-
*/
|
|
8
|
-
export class JourneyGoalsService {
|
|
9
|
-
constructor(sdk) {
|
|
10
|
-
this.sdk = sdk;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @param {Object} [opts] - sdk.objects.query opts; pass `where: { journeyId }` to scope
|
|
15
|
-
* @returns {Promise<Object>} Query result
|
|
16
|
-
*/
|
|
17
|
-
async list(opts = {}) {
|
|
18
|
-
return await this.sdk.objects.query({ object: 'journeyGoals', ...opts });
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @param {Object} body
|
|
23
|
-
* @param {string} body.journeyId
|
|
24
|
-
* @param {string} body.goalType
|
|
25
|
-
* @returns {Promise<Object>} Created journeyGoal
|
|
26
|
-
*/
|
|
27
|
-
async create(body) {
|
|
28
|
-
this.sdk.validateParams(
|
|
29
|
-
{ journeyId: body?.journeyId, goalType: body?.goalType },
|
|
30
|
-
{
|
|
31
|
-
journeyId: { type: 'string', required: true },
|
|
32
|
-
goalType: { type: 'string', required: true },
|
|
33
|
-
},
|
|
34
|
-
);
|
|
35
|
-
return await this.sdk.objects.create({ object: 'journeyGoals', body });
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async update(id, update) {
|
|
39
|
-
this.sdk.validateParams(
|
|
40
|
-
{ id, update },
|
|
41
|
-
{
|
|
42
|
-
id: { type: 'string', required: true },
|
|
43
|
-
update: { type: 'object', required: true },
|
|
44
|
-
},
|
|
45
|
-
);
|
|
46
|
-
return await this.sdk.objects.updateById({
|
|
47
|
-
object: 'journeyGoals',
|
|
48
|
-
id,
|
|
49
|
-
update,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async remove(id) {
|
|
54
|
-
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
55
|
-
return await this.sdk.objects.deleteById({ object: 'journeyGoals', id });
|
|
56
|
-
}
|
|
57
|
-
}
|