@unboundcx/sdk-internal 2.3.0 → 2.3.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/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable indent */
2
2
  /* eslint-disable prettier/prettier */
3
3
 
4
+ import { internalRequest } from './utils/sdkRequest.js';
4
5
  import { InternalSipService } from './services/sip.js';
5
6
  import { InternalEmailService } from './services/email.js';
6
7
  import { InternalProgrammableVoiceService } from './services/programmableVoice.js';
@@ -12,6 +13,7 @@ import { InternalPhoneNumbersService } from './services/phoneNumbers.js';
12
13
  import { InternalVideoService } from './services/video.js';
13
14
  import { InternalVoicemailService } from './services/voicemail.js';
14
15
  import { InternalVoiceService } from './services/voice.js';
16
+ import { InternalTaskRouterService } from './services/taskRouter.js';
15
17
  import { buildObjectEventV2 } from './utils/buildObjectEventV2.js';
16
18
 
17
19
  export class InternalSDK {
@@ -31,6 +33,7 @@ export class InternalSDK {
31
33
  this.video = new InternalVideoService(sdk);
32
34
  this.voicemail = new InternalVoicemailService(sdk);
33
35
  this.voice = new InternalVoiceService(sdk);
36
+ this.taskRouter = new InternalTaskRouterService(sdk);
34
37
 
35
38
  // Proxy all base SDK properties and methods
36
39
  this._proxyBaseSDK();
@@ -129,9 +132,26 @@ export class InternalSDK {
129
132
  const params = { body };
130
133
  if (timeoutMs) params.timeoutMs = timeoutMs;
131
134
 
132
- const result = await this.sdk._fetch(path, 'POST', params);
135
+ const result = await internalRequest(this.sdk, path, 'POST', params);
133
136
  return result;
134
137
  }
138
+
139
+ /**
140
+ * Compile a UOQL string via app1-api internal analyze.
141
+ * POST /internal/objects/uoql/analyze
142
+ */
143
+ async analyzeUoql({ uoql, accountId }) {
144
+ this.sdk.validateParams(
145
+ { uoql, accountId },
146
+ {
147
+ uoql: { type: 'string', required: true },
148
+ accountId: { type: 'string', required: true },
149
+ },
150
+ );
151
+ return internalRequest(this.sdk, '/internal/objects/uoql/analyze', 'POST', {
152
+ body: { uoql, accountId },
153
+ });
154
+ }
135
155
  }
136
156
 
137
157
  // Extension pattern for the main SDK
@@ -164,4 +184,5 @@ export { InternalPhoneNumbersService } from './services/phoneNumbers.js';
164
184
  export { InternalVideoService } from './services/video.js';
165
185
  export { InternalVoicemailService } from './services/voicemail.js';
166
186
  export { InternalVoiceService } from './services/voice.js';
187
+ export { InternalTaskRouterService } from './services/taskRouter.js';
167
188
  export { buildObjectEventV2 } from './utils/buildObjectEventV2.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk-internal",
3
- "version": "2.3.0",
3
+ "version": "2.3.3",
4
4
  "description": "Internal SDK extension for Unbound - Provides access to internal APIs and administrative functions",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,3 +1,4 @@
1
+ import { internalRequest } from '../utils/sdkRequest.js';
1
2
  export class InternalBrandingService {
2
3
  constructor(sdk) {
3
4
  this.sdk = sdk;
@@ -14,7 +15,7 @@ export class InternalBrandingService {
14
15
  * @returns {Promise<{ trustedDomains: string[] }>}
15
16
  */
16
17
  async listTrustedDomains() {
17
- const result = await this.sdk._fetch(
18
+ const result = await internalRequest(this.sdk,
18
19
  '/internal/branding/trustedDomains',
19
20
  'GET',
20
21
  {},
package/services/email.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { internalRequest } from '../utils/sdkRequest.js';
1
2
  export class InternalEmailService {
2
3
  constructor(sdk) {
3
4
  this.sdk = sdk;
@@ -11,7 +12,7 @@ export class InternalEmailService {
11
12
  },
12
13
  );
13
14
 
14
- const result = await this.sdk._fetch(
15
+ const result = await internalRequest(this.sdk,
15
16
  `/internal/email/open/${emailId}`,
16
17
  'POST',
17
18
  );
@@ -31,7 +32,7 @@ export class InternalEmailService {
31
32
  body: { trackingCookie },
32
33
  };
33
34
 
34
- const result = await this.sdk._fetch(
35
+ const result = await internalRequest(this.sdk,
35
36
  `/internal/email/click/${linkId}`,
36
37
  'POST',
37
38
  params,
@@ -52,7 +53,7 @@ export class InternalEmailService {
52
53
  body: { to },
53
54
  };
54
55
 
55
- const result = await this.sdk._fetch(
56
+ const result = await internalRequest(this.sdk,
56
57
  `/internal/email/unsubscribe/${emailId}`,
57
58
  'POST',
58
59
  params,
@@ -1,3 +1,4 @@
1
+ import { internalRequest } from '../utils/sdkRequest.js';
1
2
  export class InternalMasterAuthService {
2
3
  constructor(sdk) {
3
4
  this.sdk = sdk;
@@ -25,7 +26,7 @@ export class InternalMasterAuthService {
25
26
  },
26
27
  };
27
28
 
28
- const result = await this.sdk._fetch(
29
+ const result = await internalRequest(this.sdk,
29
30
  '/internal/masterAuth/',
30
31
  'POST',
31
32
  params,
@@ -58,7 +59,7 @@ export class InternalMasterAuthService {
58
59
  const body = { service };
59
60
  if (expiresIn !== undefined) body.expiresIn = expiresIn;
60
61
 
61
- const result = await this.sdk._fetch(
62
+ const result = await internalRequest(this.sdk,
62
63
  '/internal/masterAuth/internal-token',
63
64
  'POST',
64
65
  { body },
@@ -1,3 +1,4 @@
1
+ import { internalRequest } from '../utils/sdkRequest.js';
1
2
  export class InternalPhoneNumbersService {
2
3
  constructor(sdk) {
3
4
  this.sdk = sdk;
@@ -19,7 +20,7 @@ export class InternalPhoneNumbersService {
19
20
  },
20
21
  );
21
22
 
22
- const result = await this.sdk._fetch(
23
+ const result = await internalRequest(this.sdk,
23
24
  '/internal/phoneNumbers/inventory',
24
25
  'POST',
25
26
  {
@@ -1,3 +1,4 @@
1
+ import { internalRequest } from '../utils/sdkRequest.js';
1
2
  export class InternalProgrammableVoiceService {
2
3
  constructor(sdk) {
3
4
  this.sdk = sdk;
@@ -17,7 +18,7 @@ export class InternalProgrammableVoiceService {
17
18
  body: streamData,
18
19
  };
19
20
 
20
- const result = await this.sdk._fetch(
21
+ const result = await internalRequest(this.sdk,
21
22
  '/internal/programmableVoice/streamProxy',
22
23
  'POST',
23
24
  params,
@@ -37,7 +38,7 @@ export class InternalProgrammableVoiceService {
37
38
  body: webhookData,
38
39
  };
39
40
 
40
- const result = await this.sdk._fetch(
41
+ const result = await internalRequest(this.sdk,
41
42
  '/internal/programmableVoice/proxy',
42
43
  'POST',
43
44
  params,
@@ -69,7 +70,7 @@ export class InternalProgrammableVoiceService {
69
70
  },
70
71
  };
71
72
 
72
- const result = await this.sdk._fetch(
73
+ const result = await internalRequest(this.sdk,
73
74
  '/internal/programmableVoice/setVariable',
74
75
  'POST',
75
76
  params,
@@ -99,7 +100,7 @@ export class InternalProgrammableVoiceService {
99
100
  },
100
101
  };
101
102
 
102
- const result = await this.sdk._fetch(
103
+ const result = await internalRequest(this.sdk,
103
104
  '/internal/programmableVoice/getVariable',
104
105
  'POST',
105
106
  params,
@@ -151,7 +152,7 @@ export class InternalProgrammableVoiceService {
151
152
  body: meetingData,
152
153
  };
153
154
 
154
- const result = await this.sdk._fetch(
155
+ const result = await internalRequest(this.sdk,
155
156
  '/internal/programmableVoice/joinMeetingRoom',
156
157
  'POST',
157
158
  params,
@@ -172,7 +173,7 @@ export class InternalProgrammableVoiceService {
172
173
  body: sessionData,
173
174
  };
174
175
 
175
- const result = await this.sdk._fetch(
176
+ const result = await internalRequest(this.sdk,
176
177
  `/internal/programmableVoice/${location}`,
177
178
  'POST',
178
179
  params,
@@ -248,7 +249,7 @@ export class VoiceChannelService {
248
249
  },
249
250
  };
250
251
 
251
- const result = await this.sdk._fetch(
252
+ const result = await internalRequest(this.sdk,
252
253
  '/internal/programmableVoice/voiceChannel',
253
254
  'POST',
254
255
  params,
@@ -322,7 +323,7 @@ export class VoiceChannelService {
322
323
  },
323
324
  };
324
325
 
325
- const result = await this.sdk._fetch(
326
+ const result = await internalRequest(this.sdk,
326
327
  '/internal/programmableVoice/voiceChannel',
327
328
  'PUT',
328
329
  params,
@@ -375,7 +376,7 @@ export class TranscriptionService {
375
376
  body: transcriptionData,
376
377
  };
377
378
 
378
- const result = await this.sdk._fetch(
379
+ const result = await internalRequest(this.sdk,
379
380
  '/internal/programmableVoice/transcription/',
380
381
  'POST',
381
382
  params,
@@ -396,7 +397,7 @@ export class TranscriptionService {
396
397
  body: completionData,
397
398
  };
398
399
 
399
- const result = await this.sdk._fetch(
400
+ const result = await internalRequest(this.sdk,
400
401
  `/internal/programmableVoice/transcription/${id}`,
401
402
  'PUT',
402
403
  params,
@@ -417,7 +418,7 @@ export class TranscriptionService {
417
418
  body: messageData,
418
419
  };
419
420
 
420
- const result = await this.sdk._fetch(
421
+ const result = await internalRequest(this.sdk,
421
422
  `/internal/programmableVoice/transcription/${id}`,
422
423
  'POST',
423
424
  params,
@@ -1,3 +1,4 @@
1
+ import { internalRequest } from '../utils/sdkRequest.js';
1
2
  export class InternalServersService {
2
3
  constructor(sdk) {
3
4
  this.sdk = sdk;
@@ -59,7 +60,7 @@ export class InternalServersService {
59
60
  body: serverData,
60
61
  };
61
62
 
62
- const result = await this.sdk._fetch('/internal/servers/', 'POST', params);
63
+ const result = await internalRequest(this.sdk, '/internal/servers/', 'POST', params);
63
64
  return result;
64
65
  }
65
66
 
@@ -100,7 +101,7 @@ export class InternalServersService {
100
101
  body: updateData,
101
102
  };
102
103
 
103
- const result = await this.sdk._fetch(
104
+ const result = await internalRequest(this.sdk,
104
105
  `/internal/servers/${id}`,
105
106
  'PUT',
106
107
  params,
@@ -116,7 +117,7 @@ export class InternalServersService {
116
117
  },
117
118
  );
118
119
 
119
- const result = await this.sdk._fetch(`/internal/servers/${id}`, 'DELETE');
120
+ const result = await internalRequest(this.sdk, `/internal/servers/${id}`, 'DELETE');
120
121
  return result;
121
122
  }
122
123
 
@@ -128,7 +129,7 @@ export class InternalServersService {
128
129
  },
129
130
  );
130
131
 
131
- const result = await this.sdk._fetch(
132
+ const result = await internalRequest(this.sdk,
132
133
  `/internal/servers/${id}/shutdownCheck`,
133
134
  'GET',
134
135
  );
@@ -153,7 +154,7 @@ export class AwsServersService {
153
154
  body: assignmentData,
154
155
  };
155
156
 
156
- const result = await this.sdk._fetch(
157
+ const result = await internalRequest(this.sdk,
157
158
  '/internal/servers/aws/assignElasticIp',
158
159
  'POST',
159
160
  params,
package/services/sip.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { internalRequest } from '../utils/sdkRequest.js';
1
2
  export class InternalSipService {
2
3
  constructor(sdk) {
3
4
  this.sdk = sdk;
@@ -19,7 +20,7 @@ export class InternalSipService {
19
20
  const options = {
20
21
  body: { to, from, callId, auth, peerDirection, contact },
21
22
  };
22
- const result = await this.sdk._fetch(
23
+ const result = await internalRequest(this.sdk,
23
24
  `/internal/sip/router/${to}?from=${from}&callId=${callId}`,
24
25
  'POST',
25
26
  options,
@@ -39,7 +40,7 @@ export class InternalSipService {
39
40
  );
40
41
 
41
42
  const options = {};
42
- const result = await this.sdk._fetch(
43
+ const result = await internalRequest(this.sdk,
43
44
  `/internal/sip/server/${type}?regionCode=${regionCode}&callId=${callId}`,
44
45
  'GET',
45
46
  options,
@@ -54,7 +55,7 @@ export class InternalSipService {
54
55
  ...params,
55
56
  },
56
57
  };
57
- const result = await this.sdk._fetch(`/internal/sip/log`, 'POST', options);
58
+ const result = await internalRequest(this.sdk, `/internal/sip/log`, 'POST', options);
58
59
  return result;
59
60
  }
60
61
 
@@ -130,7 +131,7 @@ export class InternalSipService {
130
131
  },
131
132
  };
132
133
 
133
- const result = await this.sdk._fetch(
134
+ const result = await internalRequest(this.sdk,
134
135
  `/internal/sip/register`,
135
136
  'POST',
136
137
  options,
@@ -155,7 +156,7 @@ export class InternalSipService {
155
156
  accountId,
156
157
  },
157
158
  };
158
- const result = await this.sdk._fetch(
159
+ const result = await internalRequest(this.sdk,
159
160
  `/internal/sip/register/`,
160
161
  'DELETE',
161
162
  options,
@@ -232,7 +233,7 @@ export class InternalSipService {
232
233
  connectionType,
233
234
  },
234
235
  };
235
- const result = await this.sdk._fetch(
236
+ const result = await internalRequest(this.sdk,
236
237
  `/internal/sip/register/validate`,
237
238
  'POST',
238
239
  options,
@@ -1,3 +1,4 @@
1
+ import { internalRequest } from '../utils/sdkRequest.js';
1
2
  export class InternalSocketService {
2
3
  constructor(sdk) {
3
4
  this.sdk = sdk;
@@ -43,7 +44,7 @@ export class InternalSocketService {
43
44
  body: connectionData,
44
45
  };
45
46
 
46
- const result = await this.sdk._fetch(
47
+ const result = await internalRequest(this.sdk,
47
48
  '/internal/socket/connection',
48
49
  'POST',
49
50
  params,
@@ -73,7 +74,7 @@ export class InternalSocketService {
73
74
  body: updateData,
74
75
  };
75
76
 
76
- const result = await this.sdk._fetch(
77
+ const result = await internalRequest(this.sdk,
77
78
  `/internal/socket/connection/${id}`,
78
79
  'PUT',
79
80
  params,
@@ -89,7 +90,7 @@ export class InternalSocketService {
89
90
  },
90
91
  );
91
92
 
92
- const result = await this.sdk._fetch(
93
+ const result = await internalRequest(this.sdk,
93
94
  `/internal/socket/connection/${id}`,
94
95
  'DELETE',
95
96
  );
@@ -108,7 +109,7 @@ export class InternalSocketService {
108
109
  body: { serverId },
109
110
  };
110
111
 
111
- const result = await this.sdk._fetch(
112
+ const result = await internalRequest(this.sdk,
112
113
  '/internal/socket/connection/byServerId',
113
114
  'DELETE',
114
115
  params,
@@ -0,0 +1,38 @@
1
+ import { internalRequest } from '../utils/sdkRequest.js';
2
+ export class InternalTaskRouterService {
3
+ constructor(sdk) {
4
+ this.sdk = sdk;
5
+ }
6
+
7
+ /**
8
+ * Report that a task-linked call's caller hung up before the task ever
9
+ * reached 'connected' (still 'pending' in queue, or 'assigned' and
10
+ * ringing a worker who hasn't answered). No-ops server-side if the task
11
+ * already progressed past pending/assigned — safe to call unconditionally
12
+ * on every hangup of a task-linked call. Matches
13
+ * app1-api/src/services/INTERNAL/taskRouter/controllers/abandonTask.js.
14
+ *
15
+ * POST /internal/taskRouter/abandon
16
+ * Body: { taskId, accountId, reason? }
17
+ */
18
+ async abandon({ taskId, accountId, reason }) {
19
+ this.sdk.validateParams(
20
+ { taskId, accountId },
21
+ {
22
+ taskId: { type: 'string', required: true },
23
+ accountId: { type: 'string', required: true },
24
+ },
25
+ );
26
+
27
+ const body = { taskId, accountId };
28
+ if (reason) body.reason = reason;
29
+
30
+ const result = await internalRequest(
31
+ this.sdk,
32
+ '/internal/taskRouter/abandon',
33
+ 'POST',
34
+ { body },
35
+ );
36
+ return result;
37
+ }
38
+ }
package/services/video.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { internalRequest } from '../utils/sdkRequest.js';
1
2
  export class InternalVideoService {
2
3
  constructor(sdk) {
3
4
  this.sdk = sdk;
@@ -30,7 +31,7 @@ export class InternalVideoService {
30
31
  body,
31
32
  };
32
33
 
33
- const result = await this.sdk._fetch(
34
+ const result = await internalRequest(this.sdk,
34
35
  '/internal/video/meetJoin',
35
36
  'POST',
36
37
  params,
@@ -59,7 +60,7 @@ export class InternalVideoService {
59
60
  body: { sipCallId, accountId },
60
61
  };
61
62
 
62
- const result = await this.sdk._fetch(
63
+ const result = await internalRequest(this.sdk,
63
64
  '/internal/video/meetCallEnded',
64
65
  'POST',
65
66
  params,
@@ -101,11 +102,29 @@ export class InternalVideoService {
101
102
  body: payload,
102
103
  };
103
104
 
104
- const result = await this.sdk._fetch(
105
+ const result = await internalRequest(this.sdk,
105
106
  '/internal/video/meetOutboundStatus',
106
107
  'POST',
107
108
  params,
108
109
  );
109
110
  return result;
110
111
  }
112
+
113
+ /**
114
+ * Notify app1-api that a video session closed.
115
+ * POST /internal/video/:roomId/close
116
+ * Body: { reason }
117
+ */
118
+ async closeRoom(roomId, { reason } = {}) {
119
+ this.sdk.validateParams(
120
+ { roomId },
121
+ { roomId: { type: 'string', required: true } },
122
+ );
123
+ return internalRequest(
124
+ this.sdk,
125
+ `/internal/video/${roomId}/close`,
126
+ 'POST',
127
+ { body: { reason } },
128
+ );
129
+ }
111
130
  }
package/services/voice.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { internalRequest } from '../utils/sdkRequest.js';
1
2
  export class InternalVoiceService {
2
3
  constructor(sdk) {
3
4
  this.sdk = sdk;
@@ -29,7 +30,7 @@ export class InternalVoiceService {
29
30
  body: { accountId, events },
30
31
  };
31
32
 
32
- const result = await this.sdk._fetch(
33
+ const result = await internalRequest(this.sdk,
33
34
  '/internal/voice/cdrEvents',
34
35
  'POST',
35
36
  params,
@@ -1,3 +1,4 @@
1
+ import { internalRequest } from '../utils/sdkRequest.js';
1
2
  export class InternalVoicemailService {
2
3
  constructor(sdk) {
3
4
  this.sdk = sdk;
@@ -37,7 +38,7 @@ export class InternalVoicemailService {
37
38
  },
38
39
  };
39
40
 
40
- const result = await this.sdk._fetch(
41
+ const result = await internalRequest(this.sdk,
41
42
  '/internal/voicemail/transcription',
42
43
  'POST',
43
44
  params,
@@ -0,0 +1,10 @@
1
+ const SDK_REQUEST = Symbol.for('unbound.sdk.request');
2
+
3
+ /** Calls the public SDK instance request. Not an HTTP client. */
4
+ export function internalRequest(sdk, endpoint, method, params, forceFetch) {
5
+ const run = sdk?.[SDK_REQUEST];
6
+ if (typeof run !== 'function') {
7
+ throw new Error('SDK request is not initialized');
8
+ }
9
+ return run(endpoint, method, params, forceFetch);
10
+ }