@unboundcx/sdk 4.13.0 → 4.13.1

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/index.js CHANGED
@@ -32,6 +32,7 @@ import { TaskRouterService } from './services/taskRouter.js';
32
32
  import { KnowledgeBaseService } from './services/knowledgeBase.js';
33
33
  import { FaxService } from './services/fax.js';
34
34
  import { DocumentsService } from './services/documents.js';
35
+ import { EsignService } from './services/esign.js';
35
36
  import { PermissionsService } from './services/permissions.js';
36
37
  import { TriggersService } from './services/triggers.js';
37
38
  import { RecentsService } from './services/recents.js';
@@ -112,6 +113,7 @@ class UnboundSDK extends BaseSDK {
112
113
  this.knowledgeBase = new KnowledgeBaseService(this);
113
114
  this.fax = new FaxService(this);
114
115
  this.documents = new DocumentsService(this);
116
+ this.esign = new EsignService(this);
115
117
  this.permissions = new PermissionsService(this);
116
118
  this.triggers = new TriggersService(this);
117
119
  this.recents = new RecentsService(this);
@@ -307,6 +309,7 @@ export { TaskRouterService } from './services/taskRouter.js';
307
309
  export { WorkerService } from './services/taskRouter/WorkerService.js';
308
310
  export { KnowledgeBaseService } from './services/knowledgeBase.js';
309
311
  export { FaxService } from './services/fax.js';
312
+ export { EsignService, EsignPublicService } from './services/esign.js';
310
313
  export { PermissionsService } from './services/permissions.js';
311
314
  export { RecentsService } from './services/recents.js';
312
315
  export { SearchService } from './services/search.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "4.13.0",
3
+ "version": "4.13.1",
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",
package/services/chat.js CHANGED
@@ -970,6 +970,89 @@ export class ChatService {
970
970
  });
971
971
  }
972
972
 
973
+ /**
974
+ * Admin: hide a reported message from user-facing chat (reversible).
975
+ * Content stays visible to admins. Creates/updates the permanent
976
+ * moderation case for the message.
977
+ * @param {string} id
978
+ * @returns {Promise<Object>} the hidden message, plus `caseId`
979
+ */
980
+ async adminHideMessage(id) {
981
+ this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
982
+ return internalRequest(this.sdk, `/chat/admin/messages/${id}/hide`, "POST");
983
+ }
984
+
985
+ /**
986
+ * Admin: apply the final disposition to a hidden (or never-hidden)
987
+ * message — restore it, delete it (stays hidden, content retained
988
+ * subject to retention), or purge it (content expunged everywhere now).
989
+ * Also closes every open report on the message.
990
+ * @param {string} id
991
+ * @param {Object} params
992
+ * @param {'restore'|'delete'|'purge'} params.action
993
+ * @param {string} params.reason Free text, at least 3 characters
994
+ * @param {string} [params.description] Required (>= 3 chars) for `purge` —
995
+ * describes what the content was, since the content itself is removed
996
+ * @returns {Promise<Object>} the updated message, plus `caseId`/`caseAction`
997
+ */
998
+ async adminDispositionMessage(id, { action, reason, description } = {}) {
999
+ this.sdk.validateParams(
1000
+ { id, action, reason, description },
1001
+ {
1002
+ id: { type: "string", required: true },
1003
+ action: { type: "string", required: true },
1004
+ reason: { type: "string", required: true },
1005
+ description: { type: "string", required: false },
1006
+ },
1007
+ );
1008
+ const body = { action, reason };
1009
+ if (description !== undefined) body.description = description;
1010
+ return internalRequest(
1011
+ this.sdk,
1012
+ `/chat/admin/messages/${id}/disposition`,
1013
+ "POST",
1014
+ { body },
1015
+ );
1016
+ }
1017
+
1018
+ /**
1019
+ * Admin: list moderation cases (permanent hide/disposition history).
1020
+ * @param {Object} [params]
1021
+ * @param {'open'|'closed'|'all'} [params.status]
1022
+ * @param {string} [params.authorId]
1023
+ * @param {string} [params.nextId] Pagination cursor (case id)
1024
+ * @param {number} [params.limit]
1025
+ * @returns {Promise<Object>} `{results, hasMore, nextId}`
1026
+ */
1027
+ async adminListCases({ status, authorId, nextId, limit } = {}) {
1028
+ this.sdk.validateParams(
1029
+ { status, authorId, nextId, limit },
1030
+ {
1031
+ status: { type: "string", required: false },
1032
+ authorId: { type: "string", required: false },
1033
+ nextId: { type: "string", required: false },
1034
+ limit: { type: "number", required: false },
1035
+ },
1036
+ );
1037
+ const query = {};
1038
+ if (status !== undefined) query.status = status;
1039
+ if (authorId !== undefined) query.authorId = authorId;
1040
+ if (nextId !== undefined) query.nextId = nextId;
1041
+ if (limit !== undefined) query.limit = limit;
1042
+ return internalRequest(this.sdk, "/chat/admin/cases", "GET", { query });
1043
+ }
1044
+
1045
+ /**
1046
+ * Admin: get one moderation case — hydrated with its message (content
1047
+ * per the usual rules) and reports.
1048
+ * @param {string} id
1049
+ * @returns {Promise<Object>}
1050
+ */
1051
+ async adminGetCase(id) {
1052
+ this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
1053
+ return internalRequest(this.sdk, `/chat/admin/cases/${id}`, "GET");
1054
+ }
1055
+
973
1056
  /**
974
1057
  * Admin: audit log of review actions.
975
1058
  * @returns {Promise<Object>}
@@ -186,6 +186,7 @@ export class DocumentsService {
186
186
  * @param {string} [params.versionId]
187
187
  * @param {Object} [params.options]
188
188
  * @param {string} [params.options.filename]
189
+ * @param {boolean} [params.options.includeRecipientFieldMap] - Persist recipient field geometry for esign
189
190
  * @param {Object} [params.source]
190
191
  * @param {string} [params.source.type]
191
192
  * @param {string} [params.source.id]
@@ -0,0 +1,436 @@
1
+ import { internalRequest } from '../base.js';
2
+
3
+ /**
4
+ * Public (tokenized) signing session. `sdk.esign.public.*`.
5
+ * No tenant cookie; tenant is resolved from Host. All methods force HTTP
6
+ * so Present (Socket.IO SDK) does not NATS a Host-less request.
7
+ */
8
+ export class EsignPublicService {
9
+ constructor(sdk) {
10
+ this.sdk = sdk;
11
+ }
12
+
13
+ /**
14
+ * This-signer summary + disclosure (no co-signer emails).
15
+ * @param {Object} params
16
+ * @param {string} params.token - Raw signing token
17
+ * @returns {Promise<Object>}
18
+ */
19
+ async get({ token }) {
20
+ this.sdk.validateParams(
21
+ { token },
22
+ { token: { type: 'string', required: true } },
23
+ );
24
+ return internalRequest(this.sdk, `/esign/public/${token}`, 'GET', {}, true);
25
+ }
26
+
27
+ /**
28
+ * Composed working (or sealed) PDF for this signer.
29
+ * @param {Object} [params]
30
+ * @param {string} params.token
31
+ * @param {string} [params.kind] - `working` (default) or `sealed`
32
+ * @returns {Promise<*>} Raw PDF response
33
+ */
34
+ async getPdf({ token, kind } = {}) {
35
+ this.sdk.validateParams(
36
+ { token },
37
+ {
38
+ token: { type: 'string', required: true },
39
+ kind: { type: 'string', required: false },
40
+ },
41
+ );
42
+ const params = { returnRawResponse: true };
43
+ if (kind !== undefined) params.query = { kind };
44
+ return internalRequest(
45
+ this.sdk,
46
+ `/esign/public/${token}/pdf`,
47
+ 'GET',
48
+ params,
49
+ true,
50
+ );
51
+ }
52
+
53
+ /**
54
+ * Record consent. Must precede complete.
55
+ * @param {Object} params
56
+ * @param {string} params.token
57
+ * @param {boolean} params.accepted - Must be true
58
+ * @param {string} params.disclosureSha256
59
+ * @returns {Promise<Object>}
60
+ */
61
+ async consent({ token, accepted, disclosureSha256 }) {
62
+ this.sdk.validateParams(
63
+ { token, accepted, disclosureSha256 },
64
+ {
65
+ token: { type: 'string', required: true },
66
+ accepted: { type: 'boolean', required: true },
67
+ disclosureSha256: { type: 'string', required: true },
68
+ },
69
+ );
70
+ return internalRequest(
71
+ this.sdk,
72
+ `/esign/public/${token}/consent`,
73
+ 'POST',
74
+ { body: { accepted, disclosureSha256 } },
75
+ true,
76
+ );
77
+ }
78
+
79
+ /**
80
+ * Draft-save field values (not stamped).
81
+ * @param {Object} params
82
+ * @param {string} params.token
83
+ * @param {Object} params.values
84
+ * @returns {Promise<Object>}
85
+ */
86
+ async save({ token, values }) {
87
+ this.sdk.validateParams(
88
+ { token, values },
89
+ {
90
+ token: { type: 'string', required: true },
91
+ values: { type: 'object', required: true },
92
+ },
93
+ );
94
+ return internalRequest(
95
+ this.sdk,
96
+ `/esign/public/${token}/save`,
97
+ 'POST',
98
+ { body: { values } },
99
+ true,
100
+ );
101
+ }
102
+
103
+ /**
104
+ * Complete this recipient (stamp + maybe seal).
105
+ * @param {Object} params
106
+ * @param {string} params.token
107
+ * @param {Object} [params.values]
108
+ * @param {string} [params.method]
109
+ * @param {string} [params.adoptedName]
110
+ * @param {string} [params.imagePngBase64]
111
+ * @returns {Promise<Object>}
112
+ */
113
+ async complete({ token, values, method, adoptedName, imagePngBase64 }) {
114
+ this.sdk.validateParams(
115
+ { token },
116
+ {
117
+ token: { type: 'string', required: true },
118
+ values: { type: 'object', required: false },
119
+ method: { type: 'string', required: false },
120
+ adoptedName: { type: 'string', required: false },
121
+ imagePngBase64: { type: 'string', required: false },
122
+ },
123
+ );
124
+ const body = {};
125
+ if (values !== undefined) body.values = values;
126
+ if (method !== undefined) body.method = method;
127
+ if (adoptedName !== undefined) body.adoptedName = adoptedName;
128
+ if (imagePngBase64 !== undefined) body.imagePngBase64 = imagePngBase64;
129
+ return internalRequest(
130
+ this.sdk,
131
+ `/esign/public/${token}/complete`,
132
+ 'POST',
133
+ { body },
134
+ true,
135
+ );
136
+ }
137
+
138
+ /** Alias of {@link EsignPublicService#complete}. */
139
+ async sign(args) {
140
+ return this.complete(args);
141
+ }
142
+
143
+ /**
144
+ * Decline the package.
145
+ * @param {Object} params
146
+ * @param {string} params.token
147
+ * @param {string} [params.reason]
148
+ * @returns {Promise<Object>}
149
+ */
150
+ async decline({ token, reason }) {
151
+ this.sdk.validateParams(
152
+ { token },
153
+ {
154
+ token: { type: 'string', required: true },
155
+ reason: { type: 'string', required: false },
156
+ },
157
+ );
158
+ const body = {};
159
+ if (reason !== undefined) body.reason = reason;
160
+ return internalRequest(
161
+ this.sdk,
162
+ `/esign/public/${token}/decline`,
163
+ 'POST',
164
+ { body },
165
+ true,
166
+ );
167
+ }
168
+ }
169
+
170
+ /**
171
+ * Authenticated signing packages. `sdk.esign.*`.
172
+ */
173
+ export class EsignService {
174
+ constructor(sdk) {
175
+ this.sdk = sdk;
176
+ this.public = new EsignPublicService(sdk);
177
+ }
178
+
179
+ /**
180
+ * Create a draft package from a generated document.
181
+ * Field boxes come from the document's recipient field map, not the client.
182
+ * @param {Object} body
183
+ * @param {string} body.generatedDocumentId
184
+ * @param {string} body.name
185
+ * @param {Object[]} body.recipients
186
+ * @param {string} [body.routing] - `parallel` or `sequential`
187
+ * @param {Object[]} [body.links]
188
+ * @param {string} [body.expiresAt]
189
+ * @param {boolean} [body.allowDrawn]
190
+ * @param {string} [body.postSignRedirectUrl]
191
+ * @returns {Promise<Object>}
192
+ */
193
+ async createPackage({
194
+ generatedDocumentId,
195
+ name,
196
+ routing,
197
+ recipients,
198
+ links,
199
+ expiresAt,
200
+ allowDrawn,
201
+ postSignRedirectUrl,
202
+ } = {}) {
203
+ this.sdk.validateParams(
204
+ { generatedDocumentId, name, recipients },
205
+ {
206
+ generatedDocumentId: { type: 'string', required: true },
207
+ name: { type: 'string', required: true },
208
+ recipients: { type: 'array', required: true },
209
+ routing: { type: 'string', required: false },
210
+ links: { type: 'array', required: false },
211
+ expiresAt: { type: 'string', required: false },
212
+ allowDrawn: { type: 'boolean', required: false },
213
+ postSignRedirectUrl: { type: 'string', required: false },
214
+ },
215
+ );
216
+
217
+ const body = { generatedDocumentId, name, recipients };
218
+ if (routing !== undefined) body.routing = routing;
219
+ if (links !== undefined) body.links = links;
220
+ if (expiresAt !== undefined) body.expiresAt = expiresAt;
221
+ if (allowDrawn !== undefined) body.allowDrawn = allowDrawn;
222
+ if (postSignRedirectUrl !== undefined) {
223
+ body.postSignRedirectUrl = postSignRedirectUrl;
224
+ }
225
+
226
+ return internalRequest(this.sdk, '/esign/packages', 'POST', { body });
227
+ }
228
+
229
+ /**
230
+ * List packages. Missing tables → 503 `EsignNotProvisioned`.
231
+ * Gate probe: `listPackages({ limit: 1 })`.
232
+ * @param {Object} [query]
233
+ * @param {string} [query.recordId] - Requires `objectName`
234
+ * @param {string} [query.objectName] - Requires `recordId`
235
+ * @param {string} [query.status]
236
+ * @param {number} [query.limit]
237
+ * @returns {Promise<{results: Object[]}>}
238
+ */
239
+ async listPackages({ recordId, objectName, status, limit } = {}) {
240
+ const query = {};
241
+ if (recordId) query.recordId = recordId;
242
+ if (objectName) query.objectName = objectName;
243
+ if (status) query.status = status;
244
+ if (limit) query.limit = limit;
245
+ return internalRequest(this.sdk, '/esign/packages', 'GET', { query });
246
+ }
247
+
248
+ /**
249
+ * Package with signers, links, events (last 200).
250
+ * @param {string} id
251
+ * @returns {Promise<Object>}
252
+ */
253
+ async getPackage(id) {
254
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
255
+ return internalRequest(this.sdk, `/esign/packages/${id}`, 'GET');
256
+ }
257
+
258
+ /**
259
+ * Patch a draft package.
260
+ * @param {string} id
261
+ * @param {Object} [body]
262
+ * @param {string} [body.name]
263
+ * @param {Object[]} [body.recipients]
264
+ * @param {string} [body.routing]
265
+ * @param {Object[]} [body.links]
266
+ * @param {string} [body.expiresAt]
267
+ * @param {boolean} [body.allowDrawn]
268
+ * @param {string} [body.postSignRedirectUrl]
269
+ * @returns {Promise<Object>}
270
+ */
271
+ async updatePackage(
272
+ id,
273
+ {
274
+ name,
275
+ recipients,
276
+ routing,
277
+ links,
278
+ expiresAt,
279
+ allowDrawn,
280
+ postSignRedirectUrl,
281
+ } = {},
282
+ ) {
283
+ this.sdk.validateParams(
284
+ { id },
285
+ {
286
+ id: { type: 'string', required: true },
287
+ name: { type: 'string', required: false },
288
+ recipients: { type: 'array', required: false },
289
+ routing: { type: 'string', required: false },
290
+ links: { type: 'array', required: false },
291
+ expiresAt: { type: 'string', required: false },
292
+ allowDrawn: { type: 'boolean', required: false },
293
+ postSignRedirectUrl: { type: 'string', required: false },
294
+ },
295
+ );
296
+
297
+ const body = {};
298
+ if (name !== undefined) body.name = name;
299
+ if (recipients !== undefined) body.recipients = recipients;
300
+ if (routing !== undefined) body.routing = routing;
301
+ if (links !== undefined) body.links = links;
302
+ if (expiresAt !== undefined) body.expiresAt = expiresAt;
303
+ if (allowDrawn !== undefined) body.allowDrawn = allowDrawn;
304
+ if (postSignRedirectUrl !== undefined) {
305
+ body.postSignRedirectUrl = postSignRedirectUrl;
306
+ }
307
+
308
+ return internalRequest(this.sdk, `/esign/packages/${id}`, 'PATCH', {
309
+ body,
310
+ });
311
+ }
312
+
313
+ /**
314
+ * Freeze disclosure, issue tokens, email recipients.
315
+ * @param {string} id
316
+ * @returns {Promise<Object>}
317
+ */
318
+ async send(id) {
319
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
320
+ return internalRequest(this.sdk, `/esign/packages/${id}/send`, 'POST', {
321
+ body: {},
322
+ });
323
+ }
324
+
325
+ /**
326
+ * Mint a present token (no email). `{ url, expiresAt }`.
327
+ * @param {string} id
328
+ * @param {Object} params
329
+ * @param {string} params.signerId
330
+ * @returns {Promise<Object>}
331
+ */
332
+ async present(id, { signerId }) {
333
+ this.sdk.validateParams(
334
+ { id, signerId },
335
+ {
336
+ id: { type: 'string', required: true },
337
+ signerId: { type: 'string', required: true },
338
+ },
339
+ );
340
+ return internalRequest(this.sdk, `/esign/packages/${id}/present`, 'POST', {
341
+ body: { signerId },
342
+ });
343
+ }
344
+
345
+ /**
346
+ * Resend the signing email. Optional `signerId` targets one recipient.
347
+ * @param {string} id
348
+ * @param {Object} [params]
349
+ * @param {string} [params.signerId]
350
+ * @returns {Promise<Object>}
351
+ */
352
+ async remind(id, { signerId } = {}) {
353
+ this.sdk.validateParams(
354
+ { id },
355
+ {
356
+ id: { type: 'string', required: true },
357
+ signerId: { type: 'string', required: false },
358
+ },
359
+ );
360
+ const body = {};
361
+ if (signerId !== undefined) body.signerId = signerId;
362
+ return internalRequest(this.sdk, `/esign/packages/${id}/remind`, 'POST', {
363
+ body,
364
+ });
365
+ }
366
+
367
+ /**
368
+ * Void an in-flight package.
369
+ * @param {string} id
370
+ * @param {Object} [params]
371
+ * @param {string} [params.reason]
372
+ * @returns {Promise<Object>}
373
+ */
374
+ async void(id, { reason } = {}) {
375
+ this.sdk.validateParams(
376
+ { id },
377
+ {
378
+ id: { type: 'string', required: true },
379
+ reason: { type: 'string', required: false },
380
+ },
381
+ );
382
+ const body = {};
383
+ if (reason !== undefined) body.reason = reason;
384
+ return internalRequest(this.sdk, `/esign/packages/${id}/void`, 'POST', {
385
+ body,
386
+ });
387
+ }
388
+
389
+ /**
390
+ * Idempotent seal repair.
391
+ * @param {string} id
392
+ * @returns {Promise<Object>}
393
+ */
394
+ async seal(id) {
395
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
396
+ return internalRequest(this.sdk, `/esign/packages/${id}/seal`, 'POST', {
397
+ body: {},
398
+ });
399
+ }
400
+
401
+ /**
402
+ * Evidence JSON pack.
403
+ * @param {string} id
404
+ * @returns {Promise<Object>}
405
+ */
406
+ async getEvidence(id) {
407
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
408
+ return internalRequest(this.sdk, `/esign/packages/${id}/evidence`, 'GET');
409
+ }
410
+
411
+ /**
412
+ * Package PDF. HTTP-only (binary).
413
+ * @param {string} id
414
+ * @param {Object} [params]
415
+ * @param {string} [params.kind] - `unsigned` | `working` | `sealed` | `certificate`
416
+ * @returns {Promise<*>} Raw PDF response
417
+ */
418
+ async getPdf(id, { kind } = {}) {
419
+ this.sdk.validateParams(
420
+ { id },
421
+ {
422
+ id: { type: 'string', required: true },
423
+ kind: { type: 'string', required: false },
424
+ },
425
+ );
426
+ const params = { returnRawResponse: true };
427
+ if (kind !== undefined) params.query = { kind };
428
+ return internalRequest(
429
+ this.sdk,
430
+ `/esign/packages/${id}/pdf`,
431
+ 'GET',
432
+ params,
433
+ true,
434
+ );
435
+ }
436
+ }