@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.
- package/README.md +73 -54
- package/base.js +24 -16
- package/index.js +27 -15
- package/package.json +2 -2
- package/services/ai.js +62 -16
- package/services/enroll.js +48 -11
- package/services/externalOAuth.js +11 -3
- package/services/generateId.js +1 -1
- package/services/googleCalendar.js +22 -6
- package/services/layouts.js +12 -8
- package/services/login.js +12 -3
- package/services/lookup.js +1 -1
- package/services/messaging.js +140 -52
- package/services/notes.js +2 -8
- package/services/objects.js +34 -28
- package/services/phoneNumbers.js +85 -53
- package/services/portals.js +19 -4
- package/services/recordTypes.js +14 -3
- package/services/sipEndpoints.js +10 -3
- package/services/storage.js +222 -11
- package/services/subscriptions.js +19 -11
- package/services/verification.js +11 -3
- package/services/video.js +55 -22
- package/services/voice.js +169 -32
- package/services/workflows.js +122 -54
- package/test-backwards-compatibility.js +82 -51
- package/test-complete-coverage.js +113 -73
- package/test-constructor-patterns.js +32 -11
|
@@ -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',
|
|
22
|
-
'
|
|
23
|
-
'
|
|
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',
|
|
27
|
-
'
|
|
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',
|
|
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
|
-
{
|
|
100
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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(
|
|
237
|
+
console.warn(
|
|
238
|
+
`โ ๏ธ Expected at least ${expectedPublicServices} public services, found ${publicServiceCount}`,
|
|
239
|
+
);
|
|
207
240
|
} else {
|
|
208
|
-
console.log(
|
|
241
|
+
console.log(
|
|
242
|
+
`โ
Public service count: ${publicServiceCount} (expected: ${expectedPublicServices}+)`,
|
|
243
|
+
);
|
|
209
244
|
}
|
|
210
|
-
|
|
245
|
+
|
|
211
246
|
if (internalServiceCount < expectedInternalServices) {
|
|
212
|
-
throw new Error(
|
|
247
|
+
throw new Error(
|
|
248
|
+
`โ Expected at least ${expectedInternalServices} internal services, found ${internalServiceCount}`,
|
|
249
|
+
);
|
|
213
250
|
} else {
|
|
214
|
-
console.log(
|
|
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(
|
|
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(
|
|
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',
|
|
97
|
-
'
|
|
98
|
-
'
|
|
99
|
-
'
|
|
100
|
-
'
|
|
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!');
|