@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
package/README.md CHANGED
@@ -297,13 +297,6 @@ await api.messaging.email.send({
297
297
  htmlBody: '<h1>Hello World!</h1>',
298
298
  });
299
299
 
300
- // Templates
301
- await api.messaging.sms.templates.create({
302
- name: 'welcome',
303
- message: 'Welcome {{name}}!',
304
- variables: { name: 'string' },
305
- });
306
-
307
300
  // Campaign Management
308
301
  await api.messaging.campaigns.tollFree.create({
309
302
  companyName: 'Acme Corp',
package/index.js CHANGED
@@ -23,6 +23,11 @@ import { DealRegistrationsService } from './services/dealRegistrations.js';
23
23
  import { SipEndpointsService } from './services/sipEndpoints.js';
24
24
  import { RingGroupsService } from './services/ringGroups.js';
25
25
  import { LineGroupsService } from './services/lineGroups.js';
26
+ import { ParkingService } from './services/parking.js';
27
+ import { OperatorPanelsService } from './services/operatorPanels.js';
28
+ import { SchedulesService } from './services/schedules/SchedulesService.js';
29
+ import { JourneysService } from './services/journeys/JourneysService.js';
30
+ import { WorkflowTemplatesService } from './services/workflowTemplates/WorkflowTemplatesService.js';
26
31
  import { EmergencyService } from './services/emergency.js';
27
32
  import { WebchatService } from './services/webchat.js';
28
33
  import { CobrowseService } from './services/cobrowse.js';
@@ -36,6 +41,7 @@ import { RecordTypesService } from './services/recordTypes.js';
36
41
  import { GenerateIdService } from './services/generateId.js';
37
42
  import { EngagementMetricsService } from './services/engagementMetrics.js';
38
43
  import { TaskRouterService } from './services/taskRouter.js';
44
+ import { SkillsService } from './services/skills.js';
39
45
  import { KnowledgeBaseService } from './services/knowledgeBase.js';
40
46
  import { FaxService } from './services/fax.js';
41
47
  import { DocumentsService } from './services/documents.js';
@@ -56,6 +62,7 @@ import {
56
62
  DataImportService,
57
63
  DataExportService,
58
64
  } from './services/dataImport.js';
65
+ import { VoicemailDropsService } from './services/voicemailDrops.js';
59
66
 
60
67
  class UnboundSDK extends BaseSDK {
61
68
  constructor(options = {}) {
@@ -127,6 +134,11 @@ class UnboundSDK extends BaseSDK {
127
134
  this.sipEndpoints = new SipEndpointsService(this);
128
135
  this.ringGroups = new RingGroupsService(this);
129
136
  this.lineGroups = new LineGroupsService(this);
137
+ this.parking = new ParkingService(this);
138
+ this.operatorPanels = new OperatorPanelsService(this);
139
+ this.schedules = new SchedulesService(this);
140
+ this.journeys = new JourneysService(this);
141
+ this.workflowTemplates = new WorkflowTemplatesService(this);
130
142
  this.emergency = new EmergencyService(this);
131
143
  this.webchat = new WebchatService(this);
132
144
  this.cobrowse = new CobrowseService(this);
@@ -140,6 +152,7 @@ class UnboundSDK extends BaseSDK {
140
152
  this.generateId = new GenerateIdService(this);
141
153
  this.engagementMetrics = new EngagementMetricsService(this);
142
154
  this.taskRouter = new TaskRouterService(this);
155
+ this.skills = new SkillsService(this);
143
156
  this.text = new TextService(this);
144
157
  this.knowledgeBase = new KnowledgeBaseService(this);
145
158
  this.fax = new FaxService(this);
@@ -158,6 +171,7 @@ class UnboundSDK extends BaseSDK {
158
171
  this.developerApis = new DeveloperApisService(this);
159
172
  this.dataImport = new DataImportService(this);
160
173
  this.dataExport = new DataExportService(this);
174
+ this.voicemailDrops = new VoicemailDropsService(this);
161
175
 
162
176
  // Add additional services that might be missing
163
177
  this._initializeAdditionalServices();
@@ -332,10 +346,21 @@ export { DealRegistrationsService } from './services/dealRegistrations.js';
332
346
  export { SipEndpointsService } from './services/sipEndpoints.js';
333
347
  export { RingGroupsService } from './services/ringGroups.js';
334
348
  export { LineGroupsService } from './services/lineGroups.js';
349
+ export { ParkingService } from './services/parking.js';
350
+ export { SchedulesService } from './services/schedules/SchedulesService.js';
351
+ export { TimeOffService } from './services/schedules/TimeOffService.js';
352
+ export { JourneysService } from './services/journeys/JourneysService.js';
353
+ export { JourneyMembersService } from './services/journeys/JourneyMembersService.js';
354
+ export { JourneyDraftService } from './services/journeys/JourneysService.js';
355
+ export { JourneyWorklistService } from './services/journeys/JourneyWorklistService.js';
356
+ export { WorkflowTemplatesService } from './services/workflowTemplates/WorkflowTemplatesService.js';
335
357
  export { EmergencyService } from './services/emergency.js';
336
358
  export { WebchatService, WebchatWidgetsService } from './services/webchat.js';
337
359
  export { CobrowseService, CobrowseVisitorService } from './services/cobrowse.js';
338
- export { MessageTemplatesService } from './services/messageTemplates.js';
360
+ export {
361
+ MessageTemplatesService,
362
+ MessageTemplateVersionsService,
363
+ } from './services/messageTemplates.js';
339
364
  export { WebchatVisitorService } from './services/webchat/VisitorService.js';
340
365
  export { ExternalOAuthService } from './services/externalOAuth.js';
341
366
  export { GoogleCalendarService } from './services/googleCalendar.js';
@@ -370,4 +395,9 @@ export {
370
395
  DataImportService,
371
396
  DataExportService,
372
397
  } from './services/dataImport.js';
398
+ export {
399
+ VoicemailDropsService,
400
+ VoicemailDropTypesService,
401
+ } from './services/voicemailDrops.js';
373
402
  export { BaseSDK } from './base.js';
403
+ export { layoutJourney, MAX_LANES as JOURNEY_LAYOUT_MAX_LANES } from './lib/journeyLayout.js';
@@ -0,0 +1,132 @@
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "4.13.146-security.0",
3
+ "version": "4.13.146-security.2",
4
4
  "description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -40,11 +40,11 @@
40
40
  "*.js",
41
41
  "services/**/*.js",
42
42
  "transports/**/*.js",
43
- "lib/**/*.js",
44
43
  "types/**/*.d.ts",
45
44
  "proto/**/*.proto",
46
45
  "schemas/**/*.js",
47
46
  "schemas/**/*.md",
47
+ "lib/**/*.js",
48
48
  "README.md",
49
49
  "LICENSE"
50
50
  ],
@@ -64,6 +64,9 @@
64
64
  },
65
65
  "./schemas/*": {
66
66
  "import": "./schemas/*.js"
67
+ },
68
+ "./lib/*": {
69
+ "import": "./lib/*.js"
67
70
  }
68
71
  },
69
72
  "scripts": {
@@ -0,0 +1,92 @@
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
+ }
@@ -0,0 +1,57 @@
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
+ }
@@ -0,0 +1,246 @@
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
+ }