@unboundcx/sdk 4.13.129 → 4.13.130

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "4.13.129",
3
+ "version": "4.13.130",
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",
@@ -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
+ }
@@ -55,6 +55,29 @@ export class JourneyMembersService {
55
55
  );
56
56
  }
57
57
 
58
+ /**
59
+ * URL for the CSV export of the members grid (P6) — same filter / sort
60
+ * params as `list`. The browser downloads it directly (cookie auth); Node
61
+ * callers fetch it with their own token.
62
+ *
63
+ * @param {string} journeyId
64
+ * @param {Object} [opts] same keys as `list` (status, stepKey, ownerUserId, statusReason, search, sort, sortDir)
65
+ * @returns {string} absolute URL
66
+ */
67
+ exportCsvUrl(journeyId, opts = {}) {
68
+ this.sdk.validateParams(
69
+ { journeyId },
70
+ { journeyId: { type: 'string', required: true } },
71
+ );
72
+ const { status, ...rest } = opts;
73
+ const query = pickDefined({
74
+ ...rest,
75
+ status: Array.isArray(status) ? status.join(',') : status,
76
+ });
77
+ const qs = new URLSearchParams(query).toString();
78
+ return `${this.sdk.baseURL}/journeys/${journeyId}/members/export.csv${qs ? `?${qs}` : ''}`;
79
+ }
80
+
58
81
  /**
59
82
  * @param {string} journeyId
60
83
  * @param {string} memberId
@@ -0,0 +1,53 @@
1
+ import { internalRequest } from '../../base.js';
2
+
3
+ /**
4
+ * `sdk.journeys.types.*` -- journeyTypes generic-object CRUD. `queueId`
5
+ * stays empty until P5.
6
+ */
7
+ export class JourneyTypesService {
8
+ constructor(sdk) {
9
+ this.sdk = sdk;
10
+ }
11
+
12
+ async list(opts = {}) {
13
+ return await this.sdk.objects.query({ object: 'journeyTypes', ...opts });
14
+ }
15
+
16
+ async get(id) {
17
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
18
+ return await this.sdk.objects.byId({ id });
19
+ }
20
+
21
+ /**
22
+ * @param {Object} body
23
+ * @param {string} body.name
24
+ * @returns {Promise<Object>} Created journeyType
25
+ */
26
+ async create(body) {
27
+ this.sdk.validateParams(
28
+ { name: body?.name },
29
+ { name: { type: 'string', required: true } },
30
+ );
31
+ return await this.sdk.objects.create({ object: 'journeyTypes', body });
32
+ }
33
+
34
+ async update(id, update) {
35
+ this.sdk.validateParams(
36
+ { id, update },
37
+ {
38
+ id: { type: 'string', required: true },
39
+ update: { type: 'object', required: true },
40
+ },
41
+ );
42
+ return await this.sdk.objects.updateById({
43
+ object: 'journeyTypes',
44
+ id,
45
+ update,
46
+ });
47
+ }
48
+
49
+ async remove(id) {
50
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
51
+ return await this.sdk.objects.deleteById({ object: 'journeyTypes', id });
52
+ }
53
+ }
@@ -60,6 +60,7 @@ export class JourneyWorklistService {
60
60
  * @param {Object} [filter]
61
61
  * @param {string} [filter.stepType]
62
62
  * @param {string} [filter.journeyId]
63
+ * @param {string} [filter.taskId] take this exact task (validated server-side: worklist, pending, owner-or-pool)
63
64
  * @returns {Promise<{data: JourneyWorklistTask|null}>} null when nothing is due
64
65
  */
65
66
  async takeNext(filter = {}) {
@@ -2,6 +2,8 @@ import { internalRequest } from '../../base.js';
2
2
  import { JourneyMembersService } from './JourneyMembersService.js';
3
3
  import { JourneyDraftService } from './JourneyDraftService.js';
4
4
  import { JourneyWorklistService } from './JourneyWorklistService.js';
5
+ import { JourneyTypesService } from './JourneyTypesService.js';
6
+ import { JourneyGoalsService } from './JourneyGoalsService.js';
5
7
 
6
8
  function pickDefined(fields) {
7
9
  const body = {};
@@ -140,6 +142,87 @@ export class JourneysService {
140
142
  );
141
143
  }
142
144
 
145
+ /**
146
+ * Per-step funnel (journeys-plan.md §9, P6): entered / outcome split /
147
+ * conversions from journeyMemberEvents. Test members are excluded.
148
+ *
149
+ * @param {string} journeyId
150
+ * @returns {Promise<Object>} { steps: [{ stepKey, type, title, entered, outcomes, conversions }] }
151
+ */
152
+ async funnel(journeyId) {
153
+ this.sdk.validateParams(
154
+ { journeyId },
155
+ { journeyId: { type: 'string', required: true } },
156
+ );
157
+ return await internalRequest(
158
+ this.sdk,
159
+ `/journeys/${journeyId}/funnel`,
160
+ 'GET',
161
+ {},
162
+ );
163
+ }
164
+
165
+ /**
166
+ * Journey-level metrics (P6): enrolled, active, needsAttention, repliedPct,
167
+ * convertedPct, bounced, optedOut, timeToConvertMedianSeconds, byStatus.
168
+ *
169
+ * @param {string} journeyId
170
+ * @returns {Promise<Object>}
171
+ */
172
+ async metrics(journeyId) {
173
+ this.sdk.validateParams(
174
+ { journeyId },
175
+ { journeyId: { type: 'string', required: true } },
176
+ );
177
+ return await internalRequest(
178
+ this.sdk,
179
+ `/journeys/${journeyId}/metrics`,
180
+ 'GET',
181
+ {},
182
+ );
183
+ }
184
+
185
+ /**
186
+ * Journey-wide activity feed (P6): journeyMemberEvents, newest first.
187
+ *
188
+ * @param {string} journeyId
189
+ * @param {Object} [opts]
190
+ * @param {string} [opts.stepKey]
191
+ * @param {string} [opts.memberId]
192
+ * @param {number} [opts.page]
193
+ * @param {number} [opts.pageSize]
194
+ * @returns {Promise<Object>} { rows, total }
195
+ */
196
+ async events(journeyId, opts = {}) {
197
+ this.sdk.validateParams(
198
+ { journeyId },
199
+ { journeyId: { type: 'string', required: true } },
200
+ );
201
+ return await internalRequest(
202
+ this.sdk,
203
+ `/journeys/${journeyId}/events`,
204
+ 'GET',
205
+ { query: pickDefined(opts) },
206
+ );
207
+ }
208
+
209
+ /**
210
+ * Rep metrics (P6): per owner — due, overdue, doneOnTime,
211
+ * timeToActionMedianSeconds — from touch tasks. Requires salesEnabled.
212
+ *
213
+ * @param {Object} [opts]
214
+ * @param {string} [opts.journeyTypeId]
215
+ * @param {string} [opts.journeyId]
216
+ * @param {string} [opts.from] ISO date-time
217
+ * @param {string} [opts.to] ISO date-time
218
+ * @returns {Promise<Object>} { reps: [{ userId, due, overdue, doneOnTime, timeToActionMedianSeconds }] }
219
+ */
220
+ async repsMetrics(opts = {}) {
221
+ return await internalRequest(this.sdk, '/journeys/reps/metrics', 'GET', {
222
+ query: pickDefined(opts),
223
+ });
224
+ }
225
+
143
226
  /**
144
227
  * No-send dry run: per step, the resolved channel (override -> primary),
145
228
  * rendered message, and landing date for a given person (journeys-plan.md
@@ -230,114 +313,6 @@ export class JourneysService {
230
313
  }
231
314
  }
232
315
 
233
- /**
234
- * `sdk.journeys.types.*` -- journeyTypes generic-object CRUD. `queueId`
235
- * stays empty until P5.
236
- */
237
- class JourneyTypesService {
238
- constructor(sdk) {
239
- this.sdk = sdk;
240
- }
241
-
242
- async list(opts = {}) {
243
- return await this.sdk.objects.query({ object: 'journeyTypes', ...opts });
244
- }
245
-
246
- async get(id) {
247
- this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
248
- return await this.sdk.objects.byId({ id });
249
- }
250
-
251
- /**
252
- * @param {Object} body
253
- * @param {string} body.name
254
- * @returns {Promise<Object>} Created journeyType
255
- */
256
- async create(body) {
257
- this.sdk.validateParams(
258
- { name: body?.name },
259
- { name: { type: 'string', required: true } },
260
- );
261
- return await this.sdk.objects.create({ object: 'journeyTypes', body });
262
- }
263
-
264
- async update(id, update) {
265
- this.sdk.validateParams(
266
- { id, update },
267
- {
268
- id: { type: 'string', required: true },
269
- update: { type: 'object', required: true },
270
- },
271
- );
272
- return await this.sdk.objects.updateById({
273
- object: 'journeyTypes',
274
- id,
275
- update,
276
- });
277
- }
278
-
279
- async remove(id) {
280
- this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
281
- return await this.sdk.objects.deleteById({ object: 'journeyTypes', id });
282
- }
283
- }
284
-
285
- /**
286
- * `sdk.journeys.goals.*` -- journeyGoals generic-object CRUD (no `get`;
287
- * goals are listed/edited inline on the journey, matching the plan's CRUD
288
- * surface for this object).
289
- */
290
- class JourneyGoalsService {
291
- constructor(sdk) {
292
- this.sdk = sdk;
293
- }
294
-
295
- /**
296
- * @param {Object} [opts] - sdk.objects.query opts; pass `where: { journeyId }` to scope
297
- * @returns {Promise<Object>} Query result
298
- */
299
- async list(opts = {}) {
300
- return await this.sdk.objects.query({ object: 'journeyGoals', ...opts });
301
- }
302
-
303
- /**
304
- * @param {Object} body
305
- * @param {string} body.journeyId
306
- * @param {string} body.goalType
307
- * @returns {Promise<Object>} Created journeyGoal
308
- */
309
- async create(body) {
310
- this.sdk.validateParams(
311
- { journeyId: body?.journeyId, goalType: body?.goalType },
312
- {
313
- journeyId: { type: 'string', required: true },
314
- goalType: { type: 'string', required: true },
315
- },
316
- );
317
- return await this.sdk.objects.create({ object: 'journeyGoals', body });
318
- }
319
-
320
- async update(id, update) {
321
- this.sdk.validateParams(
322
- { id, update },
323
- {
324
- id: { type: 'string', required: true },
325
- update: { type: 'object', required: true },
326
- },
327
- );
328
- return await this.sdk.objects.updateById({
329
- object: 'journeyGoals',
330
- id,
331
- update,
332
- });
333
- }
334
-
335
- async remove(id) {
336
- this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
337
- return await this.sdk.objects.deleteById({ object: 'journeyGoals', id });
338
- }
339
- }
340
-
341
316
  export {
342
317
  JourneyTypesService,
343
318
  JourneyGoalsService,