@unboundcx/sdk 4.1.2 → 4.2.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/README.md CHANGED
@@ -176,6 +176,72 @@ await api.objects.describe('contacts'); // Get schema
176
176
  await api.objects.list(); // List all object types
177
177
  ```
178
178
 
179
+ #### Live Queries (`api.objects.liveQuery`)
180
+
181
+ Real-time, server-evaluated subscriptions over App1 Database objects. The
182
+ server matches every mutation against your filter and pushes only relevant
183
+ events — no client-side polling or firehose filtering.
184
+
185
+ ```javascript
186
+ const handle = await api.objects.liveQuery({
187
+ socket, // an authed socket.io-client instance (required until the SDK ships its own transport)
188
+ object: 'contacts',
189
+ filter: { companyId: 'company-123' }, // bare value = equals; 'op::term' strings for other operators
190
+ onEvent: (frame) => {
191
+ // frame.type: 'enter' | 'change' | 'leave' | 'refresh' | 'resync' | 'revoked'
192
+ // 'enter' -> frame.record (full row now matches your filter)
193
+ // 'change' -> frame.changedFields ONLY (patch, never the full row)
194
+ // 'leave' -> frame.recordId no longer matches (or was deleted)
195
+ // 'refresh'/'resync' -> re-run your query (coarse mode or gap recovery)
196
+ },
197
+ onStateChange: (state) => {}, // 'active' | 'resubscribing' | 'revoked'
198
+ });
199
+
200
+ handle.unsubscribe(); // always tear down when done
201
+ ```
202
+
203
+ Notes: the resolved `handle.mode` is `'fine'` (row-level events) or
204
+ `'coarse'` (debounced refresh hints — used when the filter isn't
205
+ row-evaluable). Heartbeats, reconnect-resubscribe, and sequence-gap resync
206
+ are handled internally. Server caps: 25 subscriptions per socket, 500 per
207
+ account.
208
+
209
+ **UOQL form** — pass a `uoql` string instead of `object`/`filter`/`fields`/
210
+ `recordTypeId` (mutually exclusive; the SDK throws synchronously if both, or
211
+ neither, are given). The server parses and classifies the query for you:
212
+
213
+ ```javascript
214
+ // Simple single-object query with a flat WHERE -> classifies FINE, same
215
+ // row-level 'enter'/'change'/'leave' events as the object/filter form above.
216
+ const handle = await api.objects.liveQuery({
217
+ socket,
218
+ uoql: "SELECT id, name, status FROM contacts WHERE companyId = 'company-123'",
219
+ onEvent: (frame) => {},
220
+ });
221
+
222
+ // Relationship paths / aggregates -> classifies COARSE: you only get
223
+ // debounced 'refresh' hints (no row-level frames), so re-run the query
224
+ // yourself each time onEvent fires with frame.type === 'refresh'.
225
+ // (UOQL expresses joins as dot-notation relationship paths, not JOIN syntax.)
226
+ const relatedUoql =
227
+ "SELECT name, companyId.name FROM contacts WHERE companyId.industry = 'tech'";
228
+ const relatedHandle = await api.objects.liveQuery({
229
+ socket,
230
+ uoql: relatedUoql,
231
+ onEvent: async (frame) => {
232
+ if (frame.type === 'refresh' || frame.type === 'resync') {
233
+ const results = await api.objects.queryV2({ query: relatedUoql });
234
+ }
235
+ },
236
+ });
237
+
238
+ relatedHandle.unsubscribe();
239
+ ```
240
+
241
+ Resubscribe-on-reconnect re-sends the same `uoql` string verbatim, so the
242
+ server re-classifies it fresh each time (mode can't drift out from under a
243
+ long-lived handle).
244
+
179
245
  #### Messaging (`api.messaging`)
180
246
 
181
247
  ```javascript
package/index.js CHANGED
@@ -27,6 +27,7 @@ import { EngagementMetricsService } from './services/engagementMetrics.js';
27
27
  import { TaskRouterService } from './services/taskRouter.js';
28
28
  import { KnowledgeBaseService } from './services/knowledgeBase.js';
29
29
  import { FaxService } from './services/fax.js';
30
+ import { PermissionsService } from './services/permissions.js';
30
31
 
31
32
  class UnboundSDK extends BaseSDK {
32
33
  constructor(options = {}) {
@@ -95,6 +96,7 @@ class UnboundSDK extends BaseSDK {
95
96
  this.taskRouter = new TaskRouterService(this);
96
97
  this.knowledgeBase = new KnowledgeBaseService(this);
97
98
  this.fax = new FaxService(this);
99
+ this.permissions = new PermissionsService(this);
98
100
 
99
101
  // Add additional services that might be missing
100
102
  this._initializeAdditionalServices();
@@ -274,4 +276,5 @@ export { TaskRouterService } from './services/taskRouter.js';
274
276
  export { WorkerService } from './services/taskRouter/WorkerService.js';
275
277
  export { KnowledgeBaseService } from './services/knowledgeBase.js';
276
278
  export { FaxService } from './services/fax.js';
279
+ export { PermissionsService } from './services/permissions.js';
277
280
  export { BaseSDK } from './base.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "4.1.2",
3
+ "version": "4.2.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",
@@ -42,6 +42,8 @@
42
42
  "transports/**/*.js",
43
43
  "types/**/*.d.ts",
44
44
  "proto/**/*.proto",
45
+ "schemas/**/*.js",
46
+ "schemas/**/*.md",
45
47
  "README.md",
46
48
  "LICENSE"
47
49
  ],
@@ -55,19 +57,28 @@
55
57
  },
56
58
  "./services/*": {
57
59
  "import": "./services/*.js"
60
+ },
61
+ "./schemas/layouts": {
62
+ "import": "./schemas/layouts/index.js"
63
+ },
64
+ "./schemas/*": {
65
+ "import": "./schemas/*.js"
58
66
  }
59
67
  },
60
68
  "scripts": {
61
69
  "build": "echo 'Build complete - ESM modules ready'",
62
70
  "test": "node --test 'test/*.test.js'",
63
71
  "lint": "echo 'Linting would run here'",
72
+ "docs:layouts": "node scripts/generate-layout-schema-docs.js",
64
73
  "prepublishOnly": "npm run build"
65
74
  },
66
- "dependencies": {},
75
+ "dependencies": {
76
+ "zod": "^3.23.8"
77
+ },
67
78
  "optionalDependencies": {
68
- "mime-types": "^2.1.35",
69
79
  "@grpc/grpc-js": "^1.14.1",
70
- "@grpc/proto-loader": "^0.7.15"
80
+ "@grpc/proto-loader": "^0.7.15",
81
+ "mime-types": "^2.1.35"
71
82
  },
72
83
  "peerDependencies": {
73
84
  "socket.io-client": "^4.0.0"
@@ -77,7 +88,9 @@
77
88
  "optional": true
78
89
  }
79
90
  },
80
- "devDependencies": {},
91
+ "devDependencies": {
92
+ "zod-to-json-schema": "^3.23.0"
93
+ },
81
94
  "browserslist": [
82
95
  "defaults",
83
96
  "not IE 11",