@unboundcx/sdk 1.0.2 → 1.0.3

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.
@@ -39,12 +39,16 @@ export class WorkflowItemsService {
39
39
  const params = {
40
40
  body: {
41
41
  where: {
42
- id
43
- }
44
- }
45
- }
42
+ id,
43
+ },
44
+ },
45
+ };
46
46
 
47
- const result = await this.sdk._fetch('/object/workflowItems', 'DELETE', params);
47
+ const result = await this.sdk._fetch(
48
+ '/object/workflowItems',
49
+ 'DELETE',
50
+ params,
51
+ );
48
52
  return result;
49
53
  }
50
54
 
@@ -59,11 +63,15 @@ export class WorkflowItemsService {
59
63
  const params = {
60
64
  query: {
61
65
  expandDetails: true,
62
- workflowVersionId
66
+ workflowVersionId,
63
67
  },
64
- }
68
+ };
65
69
 
66
- const result = await this.sdk._fetch('/object/workflowItems', 'GET', params);
70
+ const result = await this.sdk._fetch(
71
+ '/object/workflowItems',
72
+ 'GET',
73
+ params,
74
+ );
67
75
  return result;
68
76
  }
69
77
 
@@ -78,7 +86,14 @@ export class WorkflowItemsService {
78
86
  return this.sdk.objects.byId(id);
79
87
  }
80
88
 
81
- async create({ workflowVersionId, category, type, description, position, settings }) {
89
+ async create({
90
+ workflowVersionId,
91
+ category,
92
+ type,
93
+ description,
94
+ position,
95
+ settings,
96
+ }) {
82
97
  this.sdk.validateParams(
83
98
  { workflowVersionId, category, type },
84
99
  {
@@ -100,27 +115,31 @@ export class WorkflowItemsService {
100
115
  position,
101
116
  settings,
102
117
  },
103
- }
118
+ };
104
119
 
105
- const result = await this.sdk._fetch('/object/workflowItems', 'POST', params);
120
+ const result = await this.sdk._fetch(
121
+ '/object/workflowItems',
122
+ 'POST',
123
+ params,
124
+ );
106
125
  return result;
107
126
  }
108
127
 
109
- async update({
110
- id,
111
- description,
112
- label,
113
- labelBgColor,
114
- labelTextColor,
115
- descriptionBgColor,
116
- descriptionTextColor,
117
- icon,
118
- iconBgColor,
119
- iconTextColor,
120
- ports,
121
- connections,
122
- position,
123
- settings
128
+ async update({
129
+ id,
130
+ description,
131
+ label,
132
+ labelBgColor,
133
+ labelTextColor,
134
+ descriptionBgColor,
135
+ descriptionTextColor,
136
+ icon,
137
+ iconBgColor,
138
+ iconTextColor,
139
+ ports,
140
+ connections,
141
+ position,
142
+ settings,
124
143
  }) {
125
144
  this.sdk.validateParams(
126
145
  { id },
@@ -138,7 +157,7 @@ export class WorkflowItemsService {
138
157
  ports: { type: 'array', required: false },
139
158
  connections: { type: 'object', required: false },
140
159
  position: { type: 'object', required: false },
141
- settings: { type: 'object', required: false }
160
+ settings: { type: 'object', required: false },
142
161
  },
143
162
  );
144
163
 
@@ -146,9 +165,12 @@ export class WorkflowItemsService {
146
165
  if (description !== undefined) updateData.description = description;
147
166
  if (label !== undefined) updateData.label = label;
148
167
  if (labelBgColor !== undefined) updateData.labelBgColor = labelBgColor;
149
- if (labelTextColor !== undefined) updateData.labelTextColor = labelTextColor;
150
- if (descriptionBgColor !== undefined) updateData.descriptionBgColor = descriptionBgColor;
151
- if (descriptionTextColor !== undefined) updateData.descriptionTextColor = descriptionTextColor;
168
+ if (labelTextColor !== undefined)
169
+ updateData.labelTextColor = labelTextColor;
170
+ if (descriptionBgColor !== undefined)
171
+ updateData.descriptionBgColor = descriptionBgColor;
172
+ if (descriptionTextColor !== undefined)
173
+ updateData.descriptionTextColor = descriptionTextColor;
152
174
  if (icon !== undefined) updateData.icon = icon;
153
175
  if (iconBgColor !== undefined) updateData.iconBgColor = iconBgColor;
154
176
  if (iconTextColor !== undefined) updateData.iconTextColor = iconTextColor;
@@ -159,13 +181,17 @@ export class WorkflowItemsService {
159
181
  const params = {
160
182
  body: {
161
183
  where: {
162
- id
184
+ id,
163
185
  },
164
- update: updateData
186
+ update: updateData,
165
187
  },
166
- }
188
+ };
167
189
 
168
- const result = await this.sdk._fetch('/object/workflowItems', 'PUT', params);
190
+ const result = await this.sdk._fetch(
191
+ '/object/workflowItems',
192
+ 'PUT',
193
+ params,
194
+ );
169
195
  return result;
170
196
  }
171
197
  }
@@ -175,9 +201,19 @@ export class WorkflowConnectionsService {
175
201
  this.sdk = sdk;
176
202
  }
177
203
 
178
- async delete(workflowItemId, workflowItemPortId, inWorkflowItemId, inWorkflowItemPortId) {
204
+ async delete(
205
+ workflowItemId,
206
+ workflowItemPortId,
207
+ inWorkflowItemId,
208
+ inWorkflowItemPortId,
209
+ ) {
179
210
  this.sdk.validateParams(
180
- { workflowItemId, workflowItemPortId, inWorkflowItemId, inWorkflowItemPortId },
211
+ {
212
+ workflowItemId,
213
+ workflowItemPortId,
214
+ inWorkflowItemId,
215
+ inWorkflowItemPortId,
216
+ },
181
217
  {
182
218
  workflowItemId: { type: 'string', required: true },
183
219
  workflowItemPortId: { type: 'string', required: true },
@@ -192,18 +228,32 @@ export class WorkflowConnectionsService {
192
228
  workflowItemId,
193
229
  workflowItemPortId,
194
230
  inWorkflowItemId,
195
- inWorkflowItemPortId
196
- }
197
- }
198
- }
231
+ inWorkflowItemPortId,
232
+ },
233
+ },
234
+ };
199
235
 
200
- const result = await this.sdk._fetch('/object/workflowItemConnections', 'DELETE', params);
236
+ const result = await this.sdk._fetch(
237
+ '/object/workflowItemConnections',
238
+ 'DELETE',
239
+ params,
240
+ );
201
241
  return result;
202
242
  }
203
243
 
204
- async create({ workflowItemPortId, workflowItemId, inWorkflowItemId, inWorkflowItemPortId }) {
244
+ async create({
245
+ workflowItemPortId,
246
+ workflowItemId,
247
+ inWorkflowItemId,
248
+ inWorkflowItemPortId,
249
+ }) {
205
250
  this.sdk.validateParams(
206
- { workflowItemPortId, workflowItemId, inWorkflowItemId, inWorkflowItemPortId },
251
+ {
252
+ workflowItemPortId,
253
+ workflowItemId,
254
+ inWorkflowItemId,
255
+ inWorkflowItemPortId,
256
+ },
207
257
  {
208
258
  workflowItemPortId: { type: 'string', required: true },
209
259
  workflowItemId: { type: 'string', required: true },
@@ -214,14 +264,18 @@ export class WorkflowConnectionsService {
214
264
 
215
265
  const params = {
216
266
  body: {
217
- workflowItemPortId,
218
- workflowItemId,
219
- inWorkflowItemId,
220
- inWorkflowItemPortId
267
+ workflowItemPortId,
268
+ workflowItemId,
269
+ inWorkflowItemId,
270
+ inWorkflowItemPortId,
221
271
  },
222
- }
272
+ };
223
273
 
224
- const result = await this.sdk._fetch('/object/workflowItemConnections', 'POST', params);
274
+ const result = await this.sdk._fetch(
275
+ '/object/workflowItemConnections',
276
+ 'POST',
277
+ params,
278
+ );
225
279
  return result;
226
280
  }
227
281
  }
@@ -244,7 +298,11 @@ export class WorkflowSessionsService {
244
298
  body: sessionData,
245
299
  };
246
300
 
247
- const result = await this.sdk._fetch(`/workflows/${workflowId}/sessions`, 'POST', params);
301
+ const result = await this.sdk._fetch(
302
+ `/workflows/${workflowId}/sessions`,
303
+ 'POST',
304
+ params,
305
+ );
248
306
  return result;
249
307
  }
250
308
 
@@ -256,7 +314,10 @@ export class WorkflowSessionsService {
256
314
  },
257
315
  );
258
316
 
259
- const result = await this.sdk._fetch(`/workflows/sessions/${sessionId}`, 'GET');
317
+ const result = await this.sdk._fetch(
318
+ `/workflows/sessions/${sessionId}`,
319
+ 'GET',
320
+ );
260
321
  return result;
261
322
  }
262
323
 
@@ -273,7 +334,11 @@ export class WorkflowSessionsService {
273
334
  body: updateData,
274
335
  };
275
336
 
276
- const result = await this.sdk._fetch(`/workflows/sessions/${sessionId}`, 'PUT', params);
337
+ const result = await this.sdk._fetch(
338
+ `/workflows/sessions/${sessionId}`,
339
+ 'PUT',
340
+ params,
341
+ );
277
342
  return result;
278
343
  }
279
344
 
@@ -285,7 +350,10 @@ export class WorkflowSessionsService {
285
350
  },
286
351
  );
287
352
 
288
- const result = await this.sdk._fetch(`/workflows/sessions/${sessionId}`, 'DELETE');
353
+ const result = await this.sdk._fetch(
354
+ `/workflows/sessions/${sessionId}`,
355
+ 'DELETE',
356
+ );
289
357
  return result;
290
358
  }
291
- }
359
+ }
@@ -2,7 +2,7 @@
2
2
 
3
3
  /*
4
4
  * Backwards Compatibility Test
5
- *
5
+ *
6
6
  * This script tests that the new modular SDK is backwards compatible
7
7
  * with the existing monolithic SDK usage patterns.
8
8
  */
@@ -11,178 +11,209 @@ import SDK from './index.js';
11
11
 
12
12
  async function testBasicSDKFunctionality() {
13
13
  console.log('🧪 Testing basic SDK functionality...');
14
-
14
+
15
15
  // Test SDK initialization (same as original)
16
- const api = new SDK('test-namespace', 'call-123', 'fake-jwt-token', 'request-456');
17
-
16
+ const api = new SDK(
17
+ 'test-namespace',
18
+ 'call-123',
19
+ 'fake-jwt-token',
20
+ 'request-456',
21
+ );
22
+
18
23
  // Verify all main services are available
19
24
  const expectedServices = [
20
- 'login', 'objects', 'messaging', 'video', 'voice', 'ai', 'lookup',
21
- 'layouts', 'subscriptions', 'workflows', 'notes', 'storage',
22
- 'verification', 'portals', 'sipEndpoints', 'externalOAuth',
23
- 'googleCalendar', 'enroll'
25
+ 'login',
26
+ 'objects',
27
+ 'messaging',
28
+ 'video',
29
+ 'voice',
30
+ 'ai',
31
+ 'lookup',
32
+ 'layouts',
33
+ 'subscriptions',
34
+ 'workflows',
35
+ 'notes',
36
+ 'storage',
37
+ 'verification',
38
+ 'portals',
39
+ 'sipEndpoints',
40
+ 'externalOAuth',
41
+ 'googleCalendar',
42
+ 'enroll',
24
43
  ];
25
-
44
+
26
45
  for (const service of expectedServices) {
27
46
  if (!api[service]) {
28
47
  throw new Error(`❌ Service '${service}' not found on SDK instance`);
29
48
  }
30
49
  console.log(`✅ Service '${service}' is available`);
31
50
  }
32
-
51
+
33
52
  // Test nested services
34
53
  if (!api.messaging.sms) {
35
54
  throw new Error('❌ messaging.sms not found');
36
55
  }
37
56
  console.log('✅ messaging.sms is available');
38
-
57
+
39
58
  if (!api.messaging.email) {
40
59
  throw new Error('❌ messaging.email not found');
41
60
  }
42
61
  console.log('✅ messaging.email is available');
43
-
62
+
44
63
  if (!api.ai.generative) {
45
64
  throw new Error('❌ ai.generative not found');
46
65
  }
47
66
  console.log('✅ ai.generative is available');
48
-
67
+
49
68
  if (!api.workflows.items) {
50
69
  throw new Error('❌ workflows.items not found');
51
70
  }
52
71
  console.log('✅ workflows.items is available');
53
-
72
+
54
73
  console.log('✅ All services are properly available');
55
74
  }
56
75
 
57
76
  function testSDKMethods() {
58
77
  console.log('🧪 Testing SDK method signatures...');
59
-
78
+
60
79
  const api = new SDK('test-namespace');
61
-
80
+
62
81
  // Test that all expected methods exist with correct signatures
63
82
  const methodTests = [
64
83
  // Login service
65
84
  { path: 'login.login', params: ['username', 'password'] },
66
85
  { path: 'login.logout', params: [] },
67
86
  { path: 'login.validate', params: [] },
68
-
69
- // Objects service
87
+
88
+ // Objects service
70
89
  { path: 'objects.byId', params: ['id', 'query'] },
71
90
  { path: 'objects.query', params: ['object', 'query'] },
72
91
  { path: 'objects.create', params: ['object', 'body'] },
73
92
  { path: 'objects.updateById', params: ['object', 'id', 'update'] },
74
-
93
+
75
94
  // Messaging service
76
95
  { path: 'messaging.sms.send', params: [{}] },
77
96
  { path: 'messaging.email.send', params: [{}] },
78
-
97
+
79
98
  // Video service
80
99
  { path: 'video.createRoom', params: [{}] },
81
100
  { path: 'video.joinRoom', params: ['room', 'password', 'email'] },
82
-
101
+
83
102
  // AI service
84
103
  { path: 'ai.generative.chat', params: [{}] },
85
104
  { path: 'ai.tts.create', params: [{}] },
86
105
  ];
87
-
106
+
88
107
  for (const test of methodTests) {
89
108
  const pathParts = test.path.split('.');
90
109
  let obj = api;
91
-
110
+
92
111
  for (const part of pathParts) {
93
112
  if (!obj[part]) {
94
113
  throw new Error(`❌ Method '${test.path}' not found`);
95
114
  }
96
115
  obj = obj[part];
97
116
  }
98
-
117
+
99
118
  if (typeof obj !== 'function') {
100
119
  throw new Error(`❌ '${test.path}' is not a function`);
101
120
  }
102
-
121
+
103
122
  console.log(`✅ Method '${test.path}' exists and is a function`);
104
123
  }
105
124
  }
106
125
 
107
126
  function testSDKExtensibility() {
108
127
  console.log('🧪 Testing SDK extensibility...');
109
-
128
+
110
129
  const api = new SDK('test-namespace');
111
-
130
+
112
131
  // Test plugin system
113
132
  const testPlugin = {
114
133
  install: (sdk) => {
115
134
  sdk.testPluginFeature = () => 'plugin-working';
116
- }
135
+ },
117
136
  };
118
-
137
+
119
138
  api.use(testPlugin);
120
-
139
+
121
140
  if (!api.testPluginFeature) {
122
141
  throw new Error('❌ Plugin system not working');
123
142
  }
124
-
143
+
125
144
  if (api.testPluginFeature() !== 'plugin-working') {
126
145
  throw new Error('❌ Plugin not properly installed');
127
146
  }
128
-
147
+
129
148
  console.log('✅ Plugin system working correctly');
130
-
149
+
131
150
  // Test extension system
132
151
  class TestExtension {
133
152
  constructor(sdk) {
134
153
  this.testExtensionMethod = () => 'extension-working';
135
154
  }
136
155
  }
137
-
156
+
138
157
  api.extend(TestExtension);
139
-
158
+
140
159
  if (!api.testExtensionMethod) {
141
160
  throw new Error('❌ Extension system not working');
142
161
  }
143
-
162
+
144
163
  if (api.testExtensionMethod() !== 'extension-working') {
145
164
  throw new Error('❌ Extension not properly installed');
146
165
  }
147
-
166
+
148
167
  console.log('✅ Extension system working correctly');
149
168
  }
150
169
 
151
170
  function testClientServerCompatibility() {
152
171
  console.log('🧪 Testing client/server environment compatibility...');
153
-
172
+
154
173
  // Test server-side initialization
155
- const serverApi = new SDK('test-namespace', 'call-123', 'jwt-token', 'request-456');
156
-
174
+ const serverApi = new SDK(
175
+ 'test-namespace',
176
+ 'call-123',
177
+ 'jwt-token',
178
+ 'request-456',
179
+ );
180
+
157
181
  if (serverApi.environment !== 'node') {
158
- console.log('⚠️ Expected Node.js environment, this might be running in browser');
182
+ console.log(
183
+ '⚠️ Expected Node.js environment, this might be running in browser',
184
+ );
159
185
  }
160
-
186
+
161
187
  // Test client-side style initialization
162
- const clientApi = new SDK('test-namespace', null, null, null, 'api.example.com');
163
-
188
+ const clientApi = new SDK(
189
+ 'test-namespace',
190
+ null,
191
+ null,
192
+ null,
193
+ 'api.example.com',
194
+ );
195
+
164
196
  console.log('✅ Both server and client initialization patterns work');
165
197
  }
166
198
 
167
199
  async function runAllTests() {
168
200
  console.log('🚀 Starting backwards compatibility tests...\n');
169
-
201
+
170
202
  try {
171
203
  await testBasicSDKFunctionality();
172
204
  console.log('');
173
-
205
+
174
206
  testSDKMethods();
175
207
  console.log('');
176
-
208
+
177
209
  testSDKExtensibility();
178
210
  console.log('');
179
-
211
+
180
212
  testClientServerCompatibility();
181
213
  console.log('');
182
-
214
+
183
215
  console.log('🎉 All backwards compatibility tests passed!');
184
216
  console.log('✅ The new modular SDK is fully backwards compatible');
185
-
186
217
  } catch (error) {
187
218
  console.error('💥 Test failed:', error.message);
188
219
  process.exit(1);
@@ -192,4 +223,4 @@ async function runAllTests() {
192
223
  // Run tests if this file is executed directly
193
224
  if (import.meta.url === `file://${process.argv[1]}`) {
194
225
  runAllTests();
195
- }
226
+ }