@unboundcx/sdk 1.4.0 → 1.7.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/package.json +1 -1
- package/services/objects.js +246 -46
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
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/objects.js
CHANGED
|
@@ -3,15 +3,18 @@ export class ObjectsService {
|
|
|
3
3
|
this.sdk = sdk;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
async byId(id,
|
|
6
|
+
async byId({ id, expandDetails = false }) {
|
|
7
7
|
this.sdk.validateParams(
|
|
8
|
-
{ id,
|
|
8
|
+
{ id, expandDetails },
|
|
9
9
|
{
|
|
10
10
|
id: { type: 'string', required: true },
|
|
11
|
-
|
|
11
|
+
expandDetails: { type: 'boolean', required: false },
|
|
12
12
|
},
|
|
13
13
|
);
|
|
14
14
|
|
|
15
|
+
const query = {};
|
|
16
|
+
if (expandDetails) query.expandDetails = expandDetails;
|
|
17
|
+
|
|
15
18
|
const params = {
|
|
16
19
|
query,
|
|
17
20
|
};
|
|
@@ -20,28 +23,45 @@ export class ObjectsService {
|
|
|
20
23
|
return result;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
async query(
|
|
26
|
+
async query({
|
|
27
|
+
object,
|
|
28
|
+
select = null,
|
|
29
|
+
where = {},
|
|
30
|
+
limit = 100,
|
|
31
|
+
nextId = null,
|
|
32
|
+
previousId = null,
|
|
33
|
+
orderByDirection = 'DESC',
|
|
34
|
+
expandDetails = false,
|
|
35
|
+
}) {
|
|
24
36
|
this.sdk.validateParams(
|
|
25
|
-
{ object,
|
|
37
|
+
{ object, select, where, limit, nextId, previousId, orderByDirection, expandDetails },
|
|
26
38
|
{
|
|
27
39
|
object: { type: 'string', required: true },
|
|
28
|
-
|
|
40
|
+
select: { type: 'object', required: false }, // array or string
|
|
41
|
+
where: { type: 'object', required: false },
|
|
42
|
+
limit: { type: 'number', required: false },
|
|
43
|
+
nextId: { type: 'string', required: false },
|
|
44
|
+
previousId: { type: 'string', required: false },
|
|
45
|
+
orderByDirection: { type: 'string', required: false },
|
|
46
|
+
expandDetails: { type: 'boolean', required: false },
|
|
29
47
|
},
|
|
30
48
|
);
|
|
31
49
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
50
|
+
const query = { ...where };
|
|
51
|
+
if (select !== null) query.select = select;
|
|
52
|
+
if (limit !== 100) query.limit = limit;
|
|
53
|
+
if (nextId !== null) query.nextId = nextId;
|
|
54
|
+
if (previousId !== null) query.previousId = previousId;
|
|
55
|
+
if (orderByDirection !== 'DESC') query.orderByDirection = orderByDirection;
|
|
56
|
+
if (expandDetails) query.expandDetails = expandDetails;
|
|
35
57
|
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
params,
|
|
40
|
-
);
|
|
58
|
+
const params = { query };
|
|
59
|
+
|
|
60
|
+
const result = await this.sdk._fetch(`/object/query/${object}`, 'GET', params);
|
|
41
61
|
return result;
|
|
42
62
|
}
|
|
43
63
|
|
|
44
|
-
async updateById(object, id, update) {
|
|
64
|
+
async updateById({ object, id, update }) {
|
|
45
65
|
this.sdk.validateParams(
|
|
46
66
|
{ object, id, update },
|
|
47
67
|
{
|
|
@@ -64,7 +84,7 @@ export class ObjectsService {
|
|
|
64
84
|
return result;
|
|
65
85
|
}
|
|
66
86
|
|
|
67
|
-
async update(object, where, update) {
|
|
87
|
+
async update({ object, where, update }) {
|
|
68
88
|
this.sdk.validateParams(
|
|
69
89
|
{ object, where, update },
|
|
70
90
|
{
|
|
@@ -85,7 +105,7 @@ export class ObjectsService {
|
|
|
85
105
|
return result;
|
|
86
106
|
}
|
|
87
107
|
|
|
88
|
-
async create(object, body
|
|
108
|
+
async create({ object, body }) {
|
|
89
109
|
this.sdk.validateParams(
|
|
90
110
|
{ object, body },
|
|
91
111
|
{
|
|
@@ -102,7 +122,7 @@ export class ObjectsService {
|
|
|
102
122
|
return result;
|
|
103
123
|
}
|
|
104
124
|
|
|
105
|
-
async delete(object, where) {
|
|
125
|
+
async delete({ object, where }) {
|
|
106
126
|
this.sdk.validateParams(
|
|
107
127
|
{ object, where },
|
|
108
128
|
{
|
|
@@ -121,7 +141,7 @@ export class ObjectsService {
|
|
|
121
141
|
return result;
|
|
122
142
|
}
|
|
123
143
|
|
|
124
|
-
async deleteById(object, id) {
|
|
144
|
+
async deleteById({ object, id }) {
|
|
125
145
|
this.sdk.validateParams(
|
|
126
146
|
{ object, id },
|
|
127
147
|
{
|
|
@@ -168,28 +188,77 @@ export class ObjectsService {
|
|
|
168
188
|
}
|
|
169
189
|
|
|
170
190
|
// ExpandDetails methods
|
|
171
|
-
async createExpandDetail(
|
|
191
|
+
async createExpandDetail({
|
|
192
|
+
objectName,
|
|
193
|
+
fieldName,
|
|
194
|
+
targetObject,
|
|
195
|
+
lookupColumn,
|
|
196
|
+
expandFields,
|
|
197
|
+
keyField = null,
|
|
198
|
+
isActive = true,
|
|
199
|
+
isSystem = 0,
|
|
200
|
+
}) {
|
|
172
201
|
this.sdk.validateParams(
|
|
173
|
-
{
|
|
202
|
+
{ objectName, fieldName, targetObject, lookupColumn, expandFields, keyField, isActive, isSystem },
|
|
174
203
|
{
|
|
175
|
-
|
|
204
|
+
objectName: { type: 'string', required: true },
|
|
205
|
+
fieldName: { type: 'string', required: true },
|
|
206
|
+
targetObject: { type: 'string', required: true },
|
|
207
|
+
lookupColumn: { type: 'string', required: true },
|
|
208
|
+
expandFields: { type: 'object', required: true }, // array
|
|
209
|
+
keyField: { type: 'string', required: false },
|
|
210
|
+
isActive: { type: 'boolean', required: false },
|
|
211
|
+
isSystem: { type: 'number', required: false },
|
|
176
212
|
},
|
|
177
213
|
);
|
|
178
214
|
|
|
215
|
+
const body = {
|
|
216
|
+
objectName,
|
|
217
|
+
fieldName,
|
|
218
|
+
targetObject,
|
|
219
|
+
lookupColumn,
|
|
220
|
+
expandFields,
|
|
221
|
+
keyField,
|
|
222
|
+
isActive,
|
|
223
|
+
isSystem,
|
|
224
|
+
};
|
|
179
225
|
const params = { body };
|
|
180
226
|
|
|
181
227
|
const result = await this.sdk._fetch(`/object/expandDetails`, 'POST', params);
|
|
182
228
|
return result;
|
|
183
229
|
}
|
|
184
230
|
|
|
185
|
-
async getExpandDetails(
|
|
231
|
+
async getExpandDetails({
|
|
232
|
+
objectName = null,
|
|
233
|
+
fieldName = null,
|
|
234
|
+
targetObject = null,
|
|
235
|
+
isActive = null,
|
|
236
|
+
isSystem = null,
|
|
237
|
+
limit = 100,
|
|
238
|
+
offset = 0,
|
|
239
|
+
} = {}) {
|
|
186
240
|
this.sdk.validateParams(
|
|
187
|
-
{
|
|
241
|
+
{ objectName, fieldName, targetObject, isActive, isSystem, limit, offset },
|
|
188
242
|
{
|
|
189
|
-
|
|
243
|
+
objectName: { type: 'string', required: false },
|
|
244
|
+
fieldName: { type: 'string', required: false },
|
|
245
|
+
targetObject: { type: 'string', required: false },
|
|
246
|
+
isActive: { type: 'boolean', required: false },
|
|
247
|
+
isSystem: { type: 'boolean', required: false },
|
|
248
|
+
limit: { type: 'number', required: false },
|
|
249
|
+
offset: { type: 'number', required: false },
|
|
190
250
|
},
|
|
191
251
|
);
|
|
192
252
|
|
|
253
|
+
const query = {};
|
|
254
|
+
if (objectName !== null) query.objectName = objectName;
|
|
255
|
+
if (fieldName !== null) query.fieldName = fieldName;
|
|
256
|
+
if (targetObject !== null) query.targetObject = targetObject;
|
|
257
|
+
if (isActive !== null) query.isActive = isActive;
|
|
258
|
+
if (isSystem !== null) query.isSystem = isSystem;
|
|
259
|
+
if (limit !== 100) query.limit = limit;
|
|
260
|
+
if (offset !== 0) query.offset = offset;
|
|
261
|
+
|
|
193
262
|
const params = { query };
|
|
194
263
|
|
|
195
264
|
const result = await this.sdk._fetch(`/object/expandDetails`, 'GET', params);
|
|
@@ -208,15 +277,39 @@ export class ObjectsService {
|
|
|
208
277
|
return result;
|
|
209
278
|
}
|
|
210
279
|
|
|
211
|
-
async updateExpandDetail(
|
|
280
|
+
async updateExpandDetail({
|
|
281
|
+
id,
|
|
282
|
+
objectName = null,
|
|
283
|
+
fieldName = null,
|
|
284
|
+
targetObject = null,
|
|
285
|
+
lookupColumn = null,
|
|
286
|
+
expandFields = null,
|
|
287
|
+
keyField = null,
|
|
288
|
+
isActive = null,
|
|
289
|
+
}) {
|
|
212
290
|
this.sdk.validateParams(
|
|
213
|
-
{ id,
|
|
291
|
+
{ id, objectName, fieldName, targetObject, lookupColumn, expandFields, keyField, isActive },
|
|
214
292
|
{
|
|
215
293
|
id: { type: 'string', required: true },
|
|
216
|
-
|
|
294
|
+
objectName: { type: 'string', required: false },
|
|
295
|
+
fieldName: { type: 'string', required: false },
|
|
296
|
+
targetObject: { type: 'string', required: false },
|
|
297
|
+
lookupColumn: { type: 'string', required: false },
|
|
298
|
+
expandFields: { type: 'object', required: false }, // array
|
|
299
|
+
keyField: { type: 'string', required: false },
|
|
300
|
+
isActive: { type: 'boolean', required: false },
|
|
217
301
|
},
|
|
218
302
|
);
|
|
219
303
|
|
|
304
|
+
const body = {};
|
|
305
|
+
if (objectName !== null) body.objectName = objectName;
|
|
306
|
+
if (fieldName !== null) body.fieldName = fieldName;
|
|
307
|
+
if (targetObject !== null) body.targetObject = targetObject;
|
|
308
|
+
if (lookupColumn !== null) body.lookupColumn = lookupColumn;
|
|
309
|
+
if (expandFields !== null) body.expandFields = expandFields;
|
|
310
|
+
if (keyField !== null) body.keyField = keyField;
|
|
311
|
+
if (isActive !== null) body.isActive = isActive;
|
|
312
|
+
|
|
220
313
|
const params = { body };
|
|
221
314
|
|
|
222
315
|
const result = await this.sdk._fetch(`/object/expandDetails/${id}`, 'PUT', params);
|
|
@@ -236,28 +329,68 @@ export class ObjectsService {
|
|
|
236
329
|
}
|
|
237
330
|
|
|
238
331
|
// GeneratedColumns methods
|
|
239
|
-
async createGeneratedColumn(
|
|
332
|
+
async createGeneratedColumn({
|
|
333
|
+
objectName,
|
|
334
|
+
columnName,
|
|
335
|
+
value,
|
|
336
|
+
type = 'string',
|
|
337
|
+
isActive = true,
|
|
338
|
+
isSystem = 0,
|
|
339
|
+
}) {
|
|
240
340
|
this.sdk.validateParams(
|
|
241
|
-
{
|
|
341
|
+
{ objectName, columnName, value, type, isActive, isSystem },
|
|
242
342
|
{
|
|
243
|
-
|
|
343
|
+
objectName: { type: 'string', required: true },
|
|
344
|
+
columnName: { type: 'string', required: true },
|
|
345
|
+
value: { type: 'string', required: true },
|
|
346
|
+
type: { type: 'string', required: false },
|
|
347
|
+
isActive: { type: 'boolean', required: false },
|
|
348
|
+
isSystem: { type: 'number', required: false },
|
|
244
349
|
},
|
|
245
350
|
);
|
|
246
351
|
|
|
352
|
+
const body = {
|
|
353
|
+
objectName,
|
|
354
|
+
columnName,
|
|
355
|
+
value,
|
|
356
|
+
type,
|
|
357
|
+
isActive,
|
|
358
|
+
isSystem,
|
|
359
|
+
};
|
|
247
360
|
const params = { body };
|
|
248
361
|
|
|
249
362
|
const result = await this.sdk._fetch(`/object/generatedColumns`, 'POST', params);
|
|
250
363
|
return result;
|
|
251
364
|
}
|
|
252
365
|
|
|
253
|
-
async getGeneratedColumns(
|
|
366
|
+
async getGeneratedColumns({
|
|
367
|
+
objectName = null,
|
|
368
|
+
columnName = null,
|
|
369
|
+
isActive = null,
|
|
370
|
+
isSystem = null,
|
|
371
|
+
limit = 100,
|
|
372
|
+
offset = 0,
|
|
373
|
+
} = {}) {
|
|
254
374
|
this.sdk.validateParams(
|
|
255
|
-
{
|
|
375
|
+
{ objectName, columnName, isActive, isSystem, limit, offset },
|
|
256
376
|
{
|
|
257
|
-
|
|
377
|
+
objectName: { type: 'string', required: false },
|
|
378
|
+
columnName: { type: 'string', required: false },
|
|
379
|
+
isActive: { type: 'boolean', required: false },
|
|
380
|
+
isSystem: { type: 'boolean', required: false },
|
|
381
|
+
limit: { type: 'number', required: false },
|
|
382
|
+
offset: { type: 'number', required: false },
|
|
258
383
|
},
|
|
259
384
|
);
|
|
260
385
|
|
|
386
|
+
const query = {};
|
|
387
|
+
if (objectName !== null) query.objectName = objectName;
|
|
388
|
+
if (columnName !== null) query.columnName = columnName;
|
|
389
|
+
if (isActive !== null) query.isActive = isActive;
|
|
390
|
+
if (isSystem !== null) query.isSystem = isSystem;
|
|
391
|
+
if (limit !== 100) query.limit = limit;
|
|
392
|
+
if (offset !== 0) query.offset = offset;
|
|
393
|
+
|
|
261
394
|
const params = { query };
|
|
262
395
|
|
|
263
396
|
const result = await this.sdk._fetch(`/object/generatedColumns`, 'GET', params);
|
|
@@ -276,15 +409,33 @@ export class ObjectsService {
|
|
|
276
409
|
return result;
|
|
277
410
|
}
|
|
278
411
|
|
|
279
|
-
async updateGeneratedColumn(
|
|
412
|
+
async updateGeneratedColumn({
|
|
413
|
+
id,
|
|
414
|
+
objectName = null,
|
|
415
|
+
columnName = null,
|
|
416
|
+
value = null,
|
|
417
|
+
type = null,
|
|
418
|
+
isActive = null,
|
|
419
|
+
}) {
|
|
280
420
|
this.sdk.validateParams(
|
|
281
|
-
{ id,
|
|
421
|
+
{ id, objectName, columnName, value, type, isActive },
|
|
282
422
|
{
|
|
283
423
|
id: { type: 'string', required: true },
|
|
284
|
-
|
|
424
|
+
objectName: { type: 'string', required: false },
|
|
425
|
+
columnName: { type: 'string', required: false },
|
|
426
|
+
value: { type: 'string', required: false },
|
|
427
|
+
type: { type: 'string', required: false },
|
|
428
|
+
isActive: { type: 'boolean', required: false },
|
|
285
429
|
},
|
|
286
430
|
);
|
|
287
431
|
|
|
432
|
+
const body = {};
|
|
433
|
+
if (objectName !== null) body.objectName = objectName;
|
|
434
|
+
if (columnName !== null) body.columnName = columnName;
|
|
435
|
+
if (value !== null) body.value = value;
|
|
436
|
+
if (type !== null) body.type = type;
|
|
437
|
+
if (isActive !== null) body.isActive = isActive;
|
|
438
|
+
|
|
288
439
|
const params = { body };
|
|
289
440
|
|
|
290
441
|
const result = await this.sdk._fetch(`/object/generatedColumns/${id}`, 'PUT', params);
|
|
@@ -304,45 +455,94 @@ export class ObjectsService {
|
|
|
304
455
|
}
|
|
305
456
|
|
|
306
457
|
// Object Management methods
|
|
307
|
-
async createObject(
|
|
458
|
+
async createObject({ name }) {
|
|
308
459
|
this.sdk.validateParams(
|
|
309
|
-
{
|
|
460
|
+
{ name },
|
|
310
461
|
{
|
|
311
|
-
|
|
462
|
+
name: { type: 'string', required: true },
|
|
312
463
|
},
|
|
313
464
|
);
|
|
314
465
|
|
|
466
|
+
const body = { name };
|
|
315
467
|
const params = { body };
|
|
316
468
|
|
|
317
469
|
const result = await this.sdk._fetch(`/object/manage`, 'POST', params);
|
|
318
470
|
return result;
|
|
319
471
|
}
|
|
320
472
|
|
|
321
|
-
async createColumn(
|
|
473
|
+
async createColumn({
|
|
474
|
+
objectName,
|
|
475
|
+
columns = null,
|
|
476
|
+
name = null,
|
|
477
|
+
type = null,
|
|
478
|
+
length = null,
|
|
479
|
+
defaultValue = null,
|
|
480
|
+
isEncrypted = false,
|
|
481
|
+
isRequired = false,
|
|
482
|
+
}) {
|
|
322
483
|
this.sdk.validateParams(
|
|
323
|
-
{ objectName,
|
|
484
|
+
{ objectName, columns, name, type, length, defaultValue, isEncrypted, isRequired },
|
|
324
485
|
{
|
|
325
486
|
objectName: { type: 'string', required: true },
|
|
326
|
-
|
|
487
|
+
columns: { type: 'object', required: false }, // array
|
|
488
|
+
name: { type: 'string', required: false },
|
|
489
|
+
type: { type: 'string', required: false },
|
|
490
|
+
length: { type: 'number', required: false },
|
|
491
|
+
defaultValue: { type: 'string', required: false },
|
|
492
|
+
isEncrypted: { type: 'boolean', required: false },
|
|
493
|
+
isRequired: { type: 'boolean', required: false },
|
|
327
494
|
},
|
|
328
495
|
);
|
|
329
496
|
|
|
497
|
+
const body = {};
|
|
498
|
+
if (columns !== null) {
|
|
499
|
+
body.columns = columns;
|
|
500
|
+
} else if (name && type) {
|
|
501
|
+
body.name = name;
|
|
502
|
+
body.type = type;
|
|
503
|
+
if (length !== null) body.length = length;
|
|
504
|
+
if (defaultValue !== null) body.defaultValue = defaultValue;
|
|
505
|
+
body.isEncrypted = isEncrypted;
|
|
506
|
+
body.isRequired = isRequired;
|
|
507
|
+
} else {
|
|
508
|
+
throw new Error('Either columns array or individual column properties (name, type) must be provided');
|
|
509
|
+
}
|
|
510
|
+
|
|
330
511
|
const params = { body };
|
|
331
512
|
|
|
332
513
|
const result = await this.sdk._fetch(`/object/manage/${objectName}`, 'POST', params);
|
|
333
514
|
return result;
|
|
334
515
|
}
|
|
335
516
|
|
|
336
|
-
async modifyColumn(
|
|
517
|
+
async modifyColumn({
|
|
518
|
+
objectName,
|
|
519
|
+
columnName,
|
|
520
|
+
type = null,
|
|
521
|
+
length = null,
|
|
522
|
+
defaultValue = null,
|
|
523
|
+
isEncrypted = null,
|
|
524
|
+
isRequired = null,
|
|
525
|
+
}) {
|
|
337
526
|
this.sdk.validateParams(
|
|
338
|
-
{ objectName, columnName,
|
|
527
|
+
{ objectName, columnName, type, length, defaultValue, isEncrypted, isRequired },
|
|
339
528
|
{
|
|
340
529
|
objectName: { type: 'string', required: true },
|
|
341
530
|
columnName: { type: 'string', required: true },
|
|
342
|
-
|
|
531
|
+
type: { type: 'string', required: false },
|
|
532
|
+
length: { type: 'number', required: false },
|
|
533
|
+
defaultValue: { type: 'string', required: false },
|
|
534
|
+
isEncrypted: { type: 'boolean', required: false },
|
|
535
|
+
isRequired: { type: 'boolean', required: false },
|
|
343
536
|
},
|
|
344
537
|
);
|
|
345
538
|
|
|
539
|
+
const body = {};
|
|
540
|
+
if (type !== null) body.type = type;
|
|
541
|
+
if (length !== null) body.length = length;
|
|
542
|
+
if (defaultValue !== null) body.defaultValue = defaultValue;
|
|
543
|
+
if (isEncrypted !== null) body.isEncrypted = isEncrypted;
|
|
544
|
+
if (isRequired !== null) body.isRequired = isRequired;
|
|
545
|
+
|
|
346
546
|
const params = { body };
|
|
347
547
|
|
|
348
548
|
const result = await this.sdk._fetch(`/object/manage/${objectName}/${columnName}`, 'PUT', params);
|