@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.
@@ -2,8 +2,8 @@
2
2
 
3
3
  /*
4
4
  * Complete API Coverage Test
5
- *
6
- * This script tests that ALL API endpoints are covered in both
5
+ *
6
+ * This script tests that ALL API endpoints are covered in both
7
7
  * the public SDK and internal SDK extensions.
8
8
  */
9
9
 
@@ -12,30 +12,46 @@ import InternalSDK from '../sdk-internal/index.js';
12
12
 
13
13
  async function testPublicSDKCompleteness() {
14
14
  console.log('๐Ÿงช Testing complete public SDK coverage...');
15
-
15
+
16
16
  const api = new SDK('test-namespace');
17
-
17
+
18
18
  // Test all expected public services
19
19
  const publicServices = [
20
20
  // Core services
21
- 'login', 'objects', 'messaging', 'video', 'voice', 'ai',
22
- 'lookup', 'layouts', 'subscriptions', 'workflows', 'notes',
23
- 'storage', 'verification', 'portals', 'sipEndpoints',
24
-
21
+ 'login',
22
+ 'objects',
23
+ 'messaging',
24
+ 'video',
25
+ 'voice',
26
+ 'ai',
27
+ 'lookup',
28
+ 'layouts',
29
+ 'subscriptions',
30
+ 'workflows',
31
+ 'notes',
32
+ 'storage',
33
+ 'verification',
34
+ 'portals',
35
+ 'sipEndpoints',
36
+
25
37
  // Additional services found in analysis
26
- 'externalOAuth', 'googleCalendar', 'enroll', 'phoneNumbers',
27
- 'recordTypes', 'generateId'
38
+ 'externalOAuth',
39
+ 'googleCalendar',
40
+ 'enroll',
41
+ 'phoneNumbers',
42
+ 'recordTypes',
43
+ 'generateId',
28
44
  ];
29
-
45
+
30
46
  console.log(`๐Ÿ“Š Checking ${publicServices.length} public services...`);
31
-
47
+
32
48
  for (const service of publicServices) {
33
49
  if (!api[service]) {
34
50
  throw new Error(`โŒ Public service '${service}' missing from SDK`);
35
51
  }
36
52
  console.log(`โœ… ${service}`);
37
53
  }
38
-
54
+
39
55
  // Test nested services
40
56
  const nestedServices = [
41
57
  { path: 'messaging.sms', description: 'SMS messaging' },
@@ -49,13 +65,13 @@ async function testPublicSDKCompleteness() {
49
65
  { path: 'phoneNumbers.carrier', description: 'Phone number carrier ops' },
50
66
  { path: 'recordTypes.user', description: 'User record type defaults' },
51
67
  ];
52
-
68
+
53
69
  console.log(`๐Ÿ“Š Checking ${nestedServices.length} nested services...`);
54
-
70
+
55
71
  for (const { path, description } of nestedServices) {
56
72
  const pathParts = path.split('.');
57
73
  let obj = api;
58
-
74
+
59
75
  for (const part of pathParts) {
60
76
  if (!obj[part]) {
61
77
  throw new Error(`โŒ Nested service '${path}' (${description}) missing`);
@@ -64,67 +80,81 @@ async function testPublicSDKCompleteness() {
64
80
  }
65
81
  console.log(`โœ… ${path} - ${description}`);
66
82
  }
67
-
83
+
68
84
  console.log('โœ… All public services verified!');
69
85
  }
70
86
 
71
87
  async function testInternalSDKCompleteness() {
72
88
  console.log('๐Ÿงช Testing complete internal SDK coverage...');
73
-
89
+
74
90
  const api = new SDK('test-namespace');
75
91
  api.use(InternalSDK);
76
-
92
+
77
93
  // Verify buildMasterAuth is available
78
94
  if (typeof api.buildMasterAuth !== 'function') {
79
95
  throw new Error('โŒ buildMasterAuth method not available on SDK');
80
96
  }
81
97
  console.log('โœ… buildMasterAuth method available');
82
-
98
+
83
99
  // Test all internal services
84
100
  const internalServices = [
85
- 'sip', 'email', 'programmableVoice', 'servers', 'socket'
101
+ 'sip',
102
+ 'email',
103
+ 'programmableVoice',
104
+ 'servers',
105
+ 'socket',
86
106
  ];
87
-
107
+
88
108
  console.log(`๐Ÿ“Š Checking ${internalServices.length} internal services...`);
89
-
109
+
90
110
  for (const service of internalServices) {
91
111
  if (!api.internal[service]) {
92
112
  throw new Error(`โŒ Internal service '${service}' missing from SDK`);
93
113
  }
94
114
  console.log(`โœ… internal.${service}`);
95
115
  }
96
-
116
+
97
117
  // Test nested internal services
98
118
  const nestedInternalServices = [
99
- { path: 'internal.programmableVoice.voiceChannel', description: 'Voice channel management' },
100
- { path: 'internal.programmableVoice.transcription', description: 'Transcription services' },
119
+ {
120
+ path: 'internal.programmableVoice.voiceChannel',
121
+ description: 'Voice channel management',
122
+ },
123
+ {
124
+ path: 'internal.programmableVoice.transcription',
125
+ description: 'Transcription services',
126
+ },
101
127
  { path: 'internal.servers.aws', description: 'AWS server management' },
102
128
  ];
103
-
104
- console.log(`๐Ÿ“Š Checking ${nestedInternalServices.length} nested internal services...`);
105
-
129
+
130
+ console.log(
131
+ `๐Ÿ“Š Checking ${nestedInternalServices.length} nested internal services...`,
132
+ );
133
+
106
134
  for (const { path, description } of nestedInternalServices) {
107
135
  const pathParts = path.split('.');
108
136
  let obj = api;
109
-
137
+
110
138
  for (const part of pathParts) {
111
139
  if (!obj[part]) {
112
- throw new Error(`โŒ Nested internal service '${path}' (${description}) missing`);
140
+ throw new Error(
141
+ `โŒ Nested internal service '${path}' (${description}) missing`,
142
+ );
113
143
  }
114
144
  obj = obj[part];
115
145
  }
116
146
  console.log(`โœ… ${path} - ${description}`);
117
147
  }
118
-
148
+
119
149
  console.log('โœ… All internal services verified!');
120
150
  }
121
151
 
122
152
  async function testMethodAvailability() {
123
153
  console.log('๐Ÿงช Testing method availability across services...');
124
-
154
+
125
155
  const api = new SDK('test-namespace');
126
156
  api.use(InternalSDK);
127
-
157
+
128
158
  // Sample of critical methods that should be available
129
159
  const criticalMethods = [
130
160
  // Public API methods
@@ -139,102 +169,112 @@ async function testMethodAvailability() {
139
169
  { path: 'phoneNumbers.order', desc: 'Phone number ordering' },
140
170
  { path: 'recordTypes.create', desc: 'Record type creation' },
141
171
  { path: 'generateId.createId', desc: 'ID generation' },
142
-
143
- // Internal API methods
172
+
173
+ // Internal API methods
144
174
  { path: 'internal.sip.router', desc: 'SIP routing' },
145
175
  { path: 'internal.email.incrementOpen', desc: 'Email tracking' },
146
176
  { path: 'internal.programmableVoice.setVariable', desc: 'Voice variables' },
147
177
  { path: 'internal.servers.create', desc: 'Server creation' },
148
178
  { path: 'internal.socket.createConnection', desc: 'Socket connections' },
149
179
  ];
150
-
180
+
151
181
  console.log(`๐Ÿ“Š Checking ${criticalMethods.length} critical methods...`);
152
-
182
+
153
183
  for (const { path, desc } of criticalMethods) {
154
184
  const pathParts = path.split('.');
155
185
  let obj = api;
156
-
186
+
157
187
  for (const part of pathParts) {
158
188
  if (!obj[part]) {
159
189
  throw new Error(`โŒ Method '${path}' (${desc}) not found`);
160
190
  }
161
191
  obj = obj[part];
162
192
  }
163
-
193
+
164
194
  if (typeof obj !== 'function') {
165
195
  throw new Error(`โŒ '${path}' (${desc}) is not a function`);
166
196
  }
167
-
197
+
168
198
  console.log(`โœ… ${path} - ${desc}`);
169
199
  }
170
-
200
+
171
201
  console.log('โœ… All critical methods verified!');
172
202
  }
173
203
 
174
204
  async function testServiceCounts() {
175
205
  console.log('๐Ÿงช Testing service counts...');
176
-
206
+
177
207
  const api = new SDK('test-namespace');
178
208
  api.use(InternalSDK);
179
-
209
+
180
210
  // Count public services
181
- const publicServiceCount = Object.keys(api).filter(key =>
182
- typeof api[key] === 'object' &&
183
- api[key] !== null &&
184
- key !== 'internal' &&
185
- !key.startsWith('_') &&
186
- key !== 'namespace' &&
187
- key !== 'baseURL' &&
188
- key !== 'callId' &&
189
- key !== 'token' &&
190
- key !== 'fwRequestId' &&
191
- key !== 'environment' &&
192
- key !== 'transports'
211
+ const publicServiceCount = Object.keys(api).filter(
212
+ (key) =>
213
+ typeof api[key] === 'object' &&
214
+ api[key] !== null &&
215
+ key !== 'internal' &&
216
+ !key.startsWith('_') &&
217
+ key !== 'namespace' &&
218
+ key !== 'baseURL' &&
219
+ key !== 'callId' &&
220
+ key !== 'token' &&
221
+ key !== 'fwRequestId' &&
222
+ key !== 'environment' &&
223
+ key !== 'transports',
193
224
  ).length;
194
-
225
+
195
226
  // Count internal services
196
227
  const internalServiceCount = Object.keys(api.internal || {}).length;
197
-
228
+
198
229
  console.log(`๐Ÿ“Š Public services: ${publicServiceCount}`);
199
230
  console.log(`๐Ÿ“Š Internal services: ${internalServiceCount}`);
200
-
231
+
201
232
  // Expected counts based on our implementation
202
233
  const expectedPublicServices = 21; // Updated count
203
234
  const expectedInternalServices = 5;
204
-
235
+
205
236
  if (publicServiceCount < expectedPublicServices) {
206
- console.warn(`โš ๏ธ Expected at least ${expectedPublicServices} public services, found ${publicServiceCount}`);
237
+ console.warn(
238
+ `โš ๏ธ Expected at least ${expectedPublicServices} public services, found ${publicServiceCount}`,
239
+ );
207
240
  } else {
208
- console.log(`โœ… Public service count: ${publicServiceCount} (expected: ${expectedPublicServices}+)`);
241
+ console.log(
242
+ `โœ… Public service count: ${publicServiceCount} (expected: ${expectedPublicServices}+)`,
243
+ );
209
244
  }
210
-
245
+
211
246
  if (internalServiceCount < expectedInternalServices) {
212
- throw new Error(`โŒ Expected at least ${expectedInternalServices} internal services, found ${internalServiceCount}`);
247
+ throw new Error(
248
+ `โŒ Expected at least ${expectedInternalServices} internal services, found ${internalServiceCount}`,
249
+ );
213
250
  } else {
214
- console.log(`โœ… Internal service count: ${internalServiceCount} (expected: ${expectedInternalServices})`);
251
+ console.log(
252
+ `โœ… Internal service count: ${internalServiceCount} (expected: ${expectedInternalServices})`,
253
+ );
215
254
  }
216
255
  }
217
256
 
218
257
  async function runAllTests() {
219
258
  console.log('๐Ÿš€ Starting complete API coverage tests...\n');
220
-
259
+
221
260
  try {
222
261
  await testPublicSDKCompleteness();
223
262
  console.log('');
224
-
263
+
225
264
  await testInternalSDKCompleteness();
226
265
  console.log('');
227
-
266
+
228
267
  await testMethodAvailability();
229
268
  console.log('');
230
-
269
+
231
270
  await testServiceCounts();
232
271
  console.log('');
233
-
272
+
234
273
  console.log('๐ŸŽ‰ ALL API COVERAGE TESTS PASSED!');
235
- console.log('โœ… The new modular SDK covers all public and internal API endpoints');
274
+ console.log(
275
+ 'โœ… The new modular SDK covers all public and internal API endpoints',
276
+ );
236
277
  console.log('โœ… Ready for production deployment');
237
-
238
278
  } catch (error) {
239
279
  console.error('๐Ÿ’ฅ Test failed:', error.message);
240
280
  process.exit(1);
@@ -244,4 +284,4 @@ async function runAllTests() {
244
284
  // Run tests if this file is executed directly
245
285
  if (import.meta.url === `file://${process.argv[1]}`) {
246
286
  runAllTests();
247
- }
287
+ }
@@ -12,7 +12,12 @@ console.log('Testing SDK Constructor Patterns...\n');
12
12
  // Test 1: Legacy positional parameters (backwards compatibility)
13
13
  console.log('โœ… Testing legacy positional parameters:');
14
14
  try {
15
- const legacySDK = new SDK('test-namespace', 'call-123', 'jwt-token', 'request-456');
15
+ const legacySDK = new SDK(
16
+ 'test-namespace',
17
+ 'call-123',
18
+ 'jwt-token',
19
+ 'request-456',
20
+ );
16
21
  console.log(` - namespace: ${legacySDK.namespace}`);
17
22
  console.log(` - callId: ${legacySDK.callId}`);
18
23
  console.log(` - token: ${legacySDK.token}`);
@@ -31,7 +36,7 @@ try {
31
36
  token: 'jwt-token',
32
37
  fwRequestId: 'request-456',
33
38
  url: 'api.example.com',
34
- socketStore: null
39
+ socketStore: null,
35
40
  });
36
41
  console.log(` - namespace: ${modernSDK.namespace}`);
37
42
  console.log(` - callId: ${modernSDK.callId}`);
@@ -47,7 +52,7 @@ console.log('โœ… Testing partial object parameters:');
47
52
  try {
48
53
  const partialSDK = new SDK({
49
54
  namespace: 'test-namespace',
50
- token: 'jwt-token'
55
+ token: 'jwt-token',
51
56
  // callId and fwRequestId are optional
52
57
  });
53
58
  console.log(` - namespace: ${partialSDK.namespace}`);
@@ -78,7 +83,7 @@ try {
78
83
  const { createSDK } = await import('./index.js');
79
84
  const factorySDK = createSDK({
80
85
  namespace: 'factory-test',
81
- token: 'factory-token'
86
+ token: 'factory-token',
82
87
  });
83
88
  console.log(` - namespace: ${factorySDK.namespace}`);
84
89
  console.log(` - token: ${factorySDK.token}`);
@@ -93,14 +98,30 @@ console.log('๐ŸŽ‰ All constructor pattern tests completed!');
93
98
  console.log('\nโœ… Verifying services are available:');
94
99
  const testSDK = new SDK({ namespace: 'test' });
95
100
  const services = [
96
- 'login', 'objects', 'messaging', 'video', 'voice', 'ai',
97
- 'lookup', 'layouts', 'subscriptions', 'workflows', 'notes',
98
- 'storage', 'verification', 'portals', 'sipEndpoints',
99
- 'externalOAuth', 'googleCalendar', 'enroll', 'phoneNumbers',
100
- 'recordTypes', 'generateId'
101
+ 'login',
102
+ 'objects',
103
+ 'messaging',
104
+ 'video',
105
+ 'voice',
106
+ 'ai',
107
+ 'lookup',
108
+ 'layouts',
109
+ 'subscriptions',
110
+ 'workflows',
111
+ 'notes',
112
+ 'storage',
113
+ 'verification',
114
+ 'portals',
115
+ 'sipEndpoints',
116
+ 'externalOAuth',
117
+ 'googleCalendar',
118
+ 'enroll',
119
+ 'phoneNumbers',
120
+ 'recordTypes',
121
+ 'generateId',
101
122
  ];
102
123
 
103
- services.forEach(service => {
124
+ services.forEach((service) => {
104
125
  if (testSDK[service]) {
105
126
  console.log(` โœ… ${service}`);
106
127
  } else {
@@ -108,4 +129,4 @@ services.forEach(service => {
108
129
  }
109
130
  });
110
131
 
111
- console.log('\n๐Ÿš€ Constructor pattern upgrade complete!');
132
+ console.log('\n๐Ÿš€ Constructor pattern upgrade complete!');