@unboundcx/sdk 4.8.2 → 4.8.4

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
@@ -31,6 +31,7 @@ import { DocumentsService } from './services/documents.js';
31
31
  import { PermissionsService } from './services/permissions.js';
32
32
  import { TriggersService } from './services/triggers.js';
33
33
  import { InboxService } from './services/inbox.js';
34
+ import { SearchService } from './services/search.js';
34
35
  import { DirectoryService } from './services/directory.js';
35
36
 
36
37
  class UnboundSDK extends BaseSDK {
@@ -104,6 +105,7 @@ class UnboundSDK extends BaseSDK {
104
105
  this.permissions = new PermissionsService(this);
105
106
  this.triggers = new TriggersService(this);
106
107
  this.inbox = new InboxService(this);
108
+ this.search = new SearchService(this);
107
109
  this.directory = new DirectoryService(this);
108
110
 
109
111
  // Add additional services that might be missing
@@ -286,5 +288,6 @@ export { KnowledgeBaseService } from './services/knowledgeBase.js';
286
288
  export { FaxService } from './services/fax.js';
287
289
  export { PermissionsService } from './services/permissions.js';
288
290
  export { InboxService } from './services/inbox.js';
291
+ export { SearchService } from './services/search.js';
289
292
  export { DirectoryService } from './services/directory.js';
290
293
  export { BaseSDK } from './base.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "4.8.2",
3
+ "version": "4.8.4",
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",
@@ -436,6 +436,58 @@ export class ObjectsService {
436
436
  return result;
437
437
  }
438
438
 
439
+ /**
440
+ * List saved list-views for an object (system + shared + own).
441
+ * @param {Object} params
442
+ * @param {string} params.objectName - Object the views belong to.
443
+ * @returns {Promise<{results: Object[]}>}
444
+ */
445
+ async listViews({ objectName }) {
446
+ this.sdk.validateParams(
447
+ { objectName },
448
+ { objectName: { type: 'string', required: true } },
449
+ );
450
+ return await this.sdk._fetch('/object/views', 'GET', {
451
+ query: { objectName },
452
+ });
453
+ }
454
+
455
+ /**
456
+ * Create a saved list-view.
457
+ * @param {Object} params
458
+ * @param {string} params.objectName
459
+ * @param {string} params.name
460
+ * @param {Array} params.filters
461
+ * @param {string} [params.visibility] - 'user' (default) or 'shared'.
462
+ * @returns {Promise<Object>}
463
+ */
464
+ async createView({ objectName, name, filters, visibility }) {
465
+ this.sdk.validateParams(
466
+ { objectName, name, filters },
467
+ {
468
+ objectName: { type: 'string', required: true },
469
+ name: { type: 'string', required: true },
470
+ filters: { type: 'array', required: true },
471
+ },
472
+ );
473
+ const body = { objectName, name, filters };
474
+ if (visibility !== undefined) body.visibility = visibility;
475
+ return await this.sdk._fetch('/object/views', 'POST', { body });
476
+ }
477
+
478
+ /**
479
+ * Delete a saved list-view by id.
480
+ * @param {string} viewId
481
+ * @returns {Promise<Object>}
482
+ */
483
+ async deleteView(viewId) {
484
+ this.sdk.validateParams(
485
+ { viewId },
486
+ { viewId: { type: 'string', required: true } },
487
+ );
488
+ return await this.sdk._fetch(`/object/views/${viewId}`, 'DELETE');
489
+ }
490
+
439
491
  async botSchema() {
440
492
  const result = await this.sdk._fetch(
441
493
  '/object/manage/bot-schema',
@@ -0,0 +1,48 @@
1
+ /**
2
+ * SearchService -- cross-entity fan-out search (WP6.1).
3
+ * Backed by GET /search on app1-api: parallel per-store LIKE/fulltext
4
+ * queries behind one stable interface (a dedicated index can replace the
5
+ * implementation later without changing this contract).
6
+ */
7
+ export class SearchService {
8
+ constructor(sdk) {
9
+ this.sdk = sdk;
10
+ }
11
+
12
+ /**
13
+ * Search across entities.
14
+ *
15
+ * @param {Object} params
16
+ * @param {string} params.q - Search term (min 2 chars).
17
+ * @param {number} [params.limit] - Max results per entity (default 5, cap 10).
18
+ * @param {string|string[]} [params.entities] - Subset of
19
+ * people|company|opportunities|users|workflows; omit for all.
20
+ * @returns {Promise<{query: string, results: Object}>} results keyed by
21
+ * entity, each an array of { id, objectName, title, subtitle, meta }.
22
+ */
23
+ async query({ q, limit, entities } = {}) {
24
+ this.sdk.validateParams(
25
+ { q, limit },
26
+ {
27
+ q: { type: 'string', required: true },
28
+ limit: { type: 'number', required: false },
29
+ },
30
+ );
31
+
32
+ if (
33
+ entities !== undefined &&
34
+ typeof entities !== 'string' &&
35
+ !Array.isArray(entities)
36
+ ) {
37
+ throw new Error('entities must be a string or an array of strings');
38
+ }
39
+
40
+ const query = { q };
41
+ if (limit !== undefined) query.limit = limit;
42
+ if (entities !== undefined) {
43
+ query.entities = Array.isArray(entities) ? entities.join(',') : entities;
44
+ }
45
+
46
+ return await this.sdk._fetch('/search', 'GET', { query });
47
+ }
48
+ }