@unboundcx/sdk 2.8.6 → 2.8.8

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.
@@ -110,10 +110,21 @@ export class PhoneNumbersService {
110
110
  voiceAppMetaData,
111
111
  voiceRecordTypeId,
112
112
  messagingRecordTypeId,
113
+ recordCalls,
113
114
  },
114
115
  ) {
115
116
  this.sdk.validateParams(
116
- { id },
117
+ {
118
+ id,
119
+ messagingWebHookUrl,
120
+ voiceWebHookUrl,
121
+ voiceAppExternalUrl,
122
+ voiceAppExternalMethod,
123
+ voiceApp,
124
+ voiceRecordTypeId,
125
+ messagingRecordTypeId,
126
+ recordCalls,
127
+ },
117
128
  {
118
129
  id: { type: 'string', required: true },
119
130
  name: { type: 'string', required: false },
@@ -122,9 +133,9 @@ export class PhoneNumbersService {
122
133
  voiceAppExternalUrl: { type: 'string', required: false },
123
134
  voiceAppExternalMethod: { type: 'string', required: false },
124
135
  voiceApp: { type: 'string', required: false },
125
- voiceAppMetaData: { type: 'object', required: false },
126
136
  voiceRecordTypeId: { type: 'string', required: false },
127
137
  messagingRecordTypeId: { type: 'string', required: false },
138
+ recordCalls: { type: 'boolean', required: false },
128
139
  },
129
140
  );
130
141
 
@@ -142,6 +153,7 @@ export class PhoneNumbersService {
142
153
  if (voiceRecordTypeId) updateData.voiceRecordTypeId = voiceRecordTypeId;
143
154
  if (messagingRecordTypeId)
144
155
  updateData.messagingRecordTypeId = messagingRecordTypeId;
156
+ if (recordCalls !== undefined) updateData.recordCalls = recordCalls;
145
157
 
146
158
  const params = {
147
159
  body: updateData,
@@ -187,10 +199,83 @@ export class PhoneNumbersService {
187
199
  return result;
188
200
  }
189
201
 
190
- async getRoutingOptions() {
202
+ /**
203
+ * Get routing options for phone numbers or extensions
204
+ *
205
+ * Supports multiple query modes:
206
+ * 1. Get list of valid app types with metadata (appType: 'list')
207
+ * 2. Get all application types (default)
208
+ * 3. Get details for a specific application type
209
+ * 4. Get versions for a specific workflow
210
+ *
211
+ * @param {Object} [options] - Query options
212
+ * @param {string} [options.mode] - Context mode: 'phoneNumbers' (default) or 'extensions'
213
+ * @param {string} [options.type] - Filter by routing type: 'voice' or 'messaging'
214
+ * @param {string} [options.appType] - 'list' for metadata, or specific app type: 'workflows', 'extensions', 'voiceApps', 'users'
215
+ * @param {string} [options.workflowId] - Get versions for a specific workflow ID
216
+ * @param {string} [options.search] - Search/filter by name
217
+ * @returns {Promise<Object>} Routing options based on query parameters
218
+ * @example
219
+ * // Get metadata about available app types
220
+ * const metadata = await sdk.phoneNumbers.getRoutingOptions({ appType: 'list' });
221
+ * // Returns: { types: [{ key: 'voiceApps', label: 'Voice Applications', description: '...', ... }] }
222
+ *
223
+ * // Get all application types for phone numbers (default)
224
+ * const all = await sdk.phoneNumbers.getRoutingOptions();
225
+ * // Returns: { voiceApps: [...], workflows: [...], extensions: [...], webhooks: [...] }
226
+ *
227
+ * // Get routing options for extensions
228
+ * const extensionOptions = await sdk.phoneNumbers.getRoutingOptions({ mode: 'extensions' });
229
+ * // Returns: { voiceApps: [...], workflows: [...], users: [...] }
230
+ *
231
+ * // Get only voice routing options
232
+ * const voice = await sdk.phoneNumbers.getRoutingOptions({ type: 'voice' });
233
+ *
234
+ * // Get all workflows with their versions
235
+ * const workflows = await sdk.phoneNumbers.getRoutingOptions({ appType: 'workflows' });
236
+ *
237
+ * // Get all users (for extension routing)
238
+ * const users = await sdk.phoneNumbers.getRoutingOptions({ mode: 'extensions', appType: 'users' });
239
+ *
240
+ * // Get versions for a specific workflow
241
+ * const versions = await sdk.phoneNumbers.getRoutingOptions({ workflowId: 'wf_123' });
242
+ *
243
+ * // Search workflows by name
244
+ * const filtered = await sdk.phoneNumbers.getRoutingOptions({ appType: 'workflows', search: 'customer' });
245
+ */
246
+ async getRoutingOptions({ mode, type, appType, workflowId, search } = {}) {
247
+ const validationSchema = {};
248
+ const args = arguments[0] || {};
249
+
250
+ if ('mode' in args)
251
+ validationSchema.mode = { type: 'string', required: false };
252
+ if ('type' in args)
253
+ validationSchema.type = { type: 'string', required: false };
254
+ if ('appType' in args)
255
+ validationSchema.appType = { type: 'string', required: false };
256
+ if ('workflowId' in args)
257
+ validationSchema.workflowId = { type: 'string', required: false };
258
+ if ('search' in args)
259
+ validationSchema.search = { type: 'string', required: false };
260
+
261
+ if (Object.keys(validationSchema).length > 0) {
262
+ this.sdk.validateParams(args, validationSchema);
263
+ }
264
+
265
+ const params = {
266
+ query: {
267
+ mode,
268
+ type,
269
+ appType,
270
+ workflowId,
271
+ search,
272
+ },
273
+ };
274
+
191
275
  const result = await this.sdk._fetch(
192
276
  '/phoneNumbers/routing-options',
193
277
  'GET',
278
+ params,
194
279
  );
195
280
  return result;
196
281
  }
@@ -3,6 +3,28 @@ export class PortalsService {
3
3
  this.sdk = sdk;
4
4
  }
5
5
 
6
+ /**
7
+ * Creates a new portal for the authenticated account.
8
+ *
9
+ * @param {object} params
10
+ * @param {string} params.name - Display name of the portal.
11
+ * @param {string} params.domain - Custom domain for the portal (e.g. `portal.example.com`).
12
+ * A CNAME DNS record pointing to the platform's portal host is required.
13
+ * @param {object} [params.settings] - Optional portal configuration settings.
14
+ * @param {boolean} [params.isPublic] - Whether the portal is publicly accessible without
15
+ * authentication. Defaults to private if omitted.
16
+ * @param {string} [params.customCss] - Optional custom CSS injected into the portal.
17
+ * @param {string} [params.customJs] - Optional custom JavaScript injected into the portal.
18
+ * @param {string} [params.favicon] - Optional URL or asset reference for the portal favicon.
19
+ * @param {string} [params.logo] - Optional URL or asset reference for the portal logo.
20
+ * @returns {Promise<{
21
+ * id: string,
22
+ * accountId: string,
23
+ * name: string,
24
+ * domain: string,
25
+ * dns: Array<{ type: string, name: string, value: string, description: string }>
26
+ * }>} The newly created portal, including DNS records needed to configure the custom domain.
27
+ */
6
28
  async create({
7
29
  name,
8
30
  domain,
@@ -43,6 +65,29 @@ export class PortalsService {
43
65
  return result;
44
66
  }
45
67
 
68
+ /**
69
+ * Updates an existing portal's properties.
70
+ *
71
+ * Only the fields provided will be updated; omitted fields are left unchanged.
72
+ *
73
+ * @param {string} portalId - The ID of the portal to update.
74
+ * @param {object} updates
75
+ * @param {string} [updates.name] - New display name for the portal.
76
+ * @param {string} [updates.domain] - New custom domain for the portal.
77
+ * @param {object} [updates.settings] - Updated portal configuration settings.
78
+ * @param {boolean} [updates.isPublic] - Updated public accessibility flag.
79
+ * @param {string} [updates.customCss] - Updated custom CSS for the portal.
80
+ * @param {string} [updates.customJs] - Updated custom JavaScript for the portal.
81
+ * @param {string} [updates.favicon] - Updated favicon URL or asset reference.
82
+ * @param {string} [updates.logo] - Updated logo URL or asset reference.
83
+ * @returns {Promise<{
84
+ * id: string,
85
+ * updatedBy: string,
86
+ * updatedAt: string,
87
+ * name?: string,
88
+ * domain?: string
89
+ * }>} The updated portal fields along with audit metadata.
90
+ */
46
91
  async update(
47
92
  portalId,
48
93
  { name, domain, settings, isPublic, customCss, customJs, favicon, logo },
@@ -80,6 +125,12 @@ export class PortalsService {
80
125
  return result;
81
126
  }
82
127
 
128
+ /**
129
+ * Deletes a portal by ID.
130
+ *
131
+ * @param {string} portalId - The ID of the portal to delete.
132
+ * @returns {Promise<{ message: string }>} Confirmation message on success.
133
+ */
83
134
  async delete(portalId) {
84
135
  this.sdk.validateParams(
85
136
  { portalId },
@@ -92,6 +143,12 @@ export class PortalsService {
92
143
  return result;
93
144
  }
94
145
 
146
+ /**
147
+ * Retrieves a portal by ID.
148
+ *
149
+ * @param {string} portalId - The ID of the portal to retrieve.
150
+ * @returns {Promise<object>} The full portal record.
151
+ */
95
152
  async get(portalId) {
96
153
  this.sdk.validateParams(
97
154
  { portalId },
@@ -104,6 +161,17 @@ export class PortalsService {
104
161
  return result;
105
162
  }
106
163
 
164
+ /**
165
+ * Retrieves public portal information by domain.
166
+ *
167
+ * This is an unauthenticated endpoint used by portal front-ends to look up
168
+ * their own configuration based on the domain they are served from.
169
+ *
170
+ * @param {string} domain - The custom domain of the portal to look up
171
+ * (e.g. `portal.example.com`).
172
+ * @returns {Promise<{ id: string, name: string, domain: string }>}
173
+ * The public-facing portal fields. Sensitive account data is excluded.
174
+ */
107
175
  async getPublic(domain) {
108
176
  this.sdk.validateParams(
109
177
  { domain },
@@ -120,11 +188,32 @@ export class PortalsService {
120
188
  return result;
121
189
  }
122
190
 
191
+ /**
192
+ * Lists all portals belonging to the authenticated account.
193
+ *
194
+ * @returns {Promise<{ portals: object[] }>} An object containing an array of portal records.
195
+ */
123
196
  async list() {
124
197
  const result = await this.sdk._fetch('/portals', 'GET');
125
198
  return result;
126
199
  }
127
200
 
201
+ /**
202
+ * Verifies that a portal's custom domain has the correct DNS configuration.
203
+ *
204
+ * Checks that the domain has a valid CNAME record pointing to the platform's
205
+ * portal host. Use the `dns` records returned from `create()` to know the
206
+ * expected target value.
207
+ *
208
+ * @param {string} portalId - The ID of the portal whose DNS should be verified.
209
+ * @returns {Promise<{
210
+ * portalId: string,
211
+ * domain: string,
212
+ * expectedTarget: string,
213
+ * dns: object
214
+ * }>} The DNS verification result, including the expected CNAME target and
215
+ * the actual resolution details.
216
+ */
128
217
  async verifyDns(portalId) {
129
218
  this.sdk.validateParams(
130
219
  { portalId },
@@ -3,23 +3,45 @@ export class SipEndpointsService {
3
3
  this.sdk = sdk;
4
4
  }
5
5
 
6
- async create({ recordTypeId, type, userId, name }) {
6
+ /**
7
+ * Create a new SIP endpoint
8
+ * @param {Object} options - The endpoint configuration
9
+ * @param {string} options.recordTypeId - Record type ID for permissions
10
+ * @param {string} options.userId - User ID to associate with this endpoint
11
+ * @param {string} options.type - Endpoint type: 'webRtc' or 'ipPhone'
12
+ * @param {string} options.name - Endpoint name
13
+ * @param {string} options.macAddress - MAC address for ipPhone type
14
+ * @param {Object} options - Additional provisioning fields (timezone, vlanId, etc.)
15
+ * @returns {Promise<Object>} Created endpoint
16
+ */
17
+ async create(options) {
18
+ const {
19
+ recordTypeId,
20
+ userId,
21
+ type,
22
+ name,
23
+ macAddress,
24
+ useSecureCalling,
25
+ ...provisioningFields
26
+ } = options;
27
+
7
28
  this.sdk.validateParams(
8
- { recordTypeId, type, userId, name },
29
+ { type, useSecureCalling },
9
30
  {
10
- recordTypeId: { type: 'string', required: false },
11
31
  type: { type: 'string', required: true },
12
- userId: { type: 'string', required: false },
13
- name: { type: 'string', required: false },
32
+ useSecureCalling: { type: 'boolean', required: false },
14
33
  },
15
34
  );
16
35
 
17
36
  const params = {
18
37
  body: {
19
38
  recordTypeId,
20
- type,
21
39
  userId,
40
+ type,
41
+ useSecureCalling,
22
42
  name,
43
+ macAddress,
44
+ ...provisioningFields, // Include all provisioning fields
23
45
  },
24
46
  };
25
47
 
@@ -27,23 +49,53 @@ export class SipEndpointsService {
27
49
  return result;
28
50
  }
29
51
 
52
+ /**
53
+ * Get the authenticated user's WebRTC endpoint details
54
+ * @returns {Promise<Object>} WebRTC endpoint configuration
55
+ */
30
56
  async getWebRtcDetails() {
31
- const params = {};
32
- const result = await this.sdk._fetch('/sipEndpoints', 'GET', params, true);
57
+ const result = await this.sdk._fetch('/sipEndpoints/webrtc', 'GET');
33
58
  return result;
34
59
  }
35
60
 
36
- async getUsersWebRtc() {
37
- const result = await this.sdk._fetch('/sipEndpoints/users/webrtc', 'GET');
38
- return result;
39
- }
61
+ /**
62
+ * Update a SIP endpoint
63
+ * @param {string} endpointId - The endpoint ID
64
+ * @param {Object} options - The fields to update
65
+ * @param {string} options.name - Endpoint name
66
+ * @param {string} options.userId - User ID to associate with this endpoint
67
+ * * @param {string} options.useSecureCalling - provision with TLS / secure calling
68
+ * @param {string} options.macAddress - MAC address
69
+ * @param {boolean} options.useIceAccelerator - Enable/disable ICE accelerator
70
+ * @param {Object} options - Additional provisioning fields (timezone, vlanId, etc.)
71
+ * @returns {Promise<Object>} Updated endpoint
72
+ */
73
+ async update(endpointId, options) {
74
+ this.sdk.validateParams(
75
+ { endpointId },
76
+ {
77
+ endpointId: { type: 'string', required: true },
78
+ },
79
+ );
40
80
 
41
- async list() {
42
- const result = await this.sdk._fetch('/sipEndpoints/list', 'GET');
81
+ const params = {
82
+ body: { ...options }, // Pass all options through
83
+ };
84
+
85
+ const result = await this.sdk._fetch(
86
+ `/sipEndpoints/${endpointId}`,
87
+ 'PUT',
88
+ params,
89
+ );
43
90
  return result;
44
91
  }
45
92
 
46
- async get(endpointId) {
93
+ /**
94
+ * Delete a SIP endpoint
95
+ * @param {string} endpointId - The endpoint ID
96
+ * @returns {Promise<Object>} Deletion result
97
+ */
98
+ async delete(endpointId) {
47
99
  this.sdk.validateParams(
48
100
  { endpointId },
49
101
  {
@@ -51,39 +103,59 @@ export class SipEndpointsService {
51
103
  },
52
104
  );
53
105
 
54
- const result = await this.sdk._fetch(`/sipEndpoints/${endpointId}`, 'GET');
106
+ const result = await this.sdk._fetch(
107
+ `/sipEndpoints/${endpointId}`,
108
+ 'DELETE',
109
+ );
55
110
  return result;
56
111
  }
57
112
 
58
- async update(endpointId, { displayName, description, enabled }) {
113
+ /**
114
+ * Reboot a SIP endpoint (forces re-registration)
115
+ * @param {string} endpointId - The endpoint ID
116
+ * @returns {Promise<Object>} Reboot result
117
+ */
118
+ async reboot(endpointId) {
59
119
  this.sdk.validateParams(
60
120
  { endpointId },
61
121
  {
62
122
  endpointId: { type: 'string', required: true },
63
- displayName: { type: 'string', required: false },
64
- description: { type: 'string', required: false },
65
- enabled: { type: 'boolean', required: false },
66
123
  },
67
124
  );
68
125
 
69
- const updateData = {};
70
- if (displayName) updateData.displayName = displayName;
71
- if (description) updateData.description = description;
72
- if (enabled !== undefined) updateData.enabled = enabled;
126
+ const result = await this.sdk._fetch(
127
+ `/sipEndpoints/${endpointId}/reboot`,
128
+ 'POST',
129
+ );
130
+ return result;
131
+ }
73
132
 
74
- const params = {
75
- body: updateData,
76
- };
133
+ /**
134
+ * Change the access secret for a SIP endpoint
135
+ * @param {string} endpointId - The endpoint ID
136
+ * @returns {Promise<Object>} New endpoint credentials
137
+ */
138
+ async changeAccessSecret(endpointId) {
139
+ this.sdk.validateParams(
140
+ { endpointId },
141
+ {
142
+ endpointId: { type: 'string', required: true },
143
+ },
144
+ );
77
145
 
78
146
  const result = await this.sdk._fetch(
79
- `/sipEndpoints/${endpointId}`,
80
- 'PUT',
81
- params,
147
+ `/sipEndpoints/${endpointId}/secret`,
148
+ 'POST',
82
149
  );
83
150
  return result;
84
151
  }
85
152
 
86
- async delete(endpointId) {
153
+ /**
154
+ * Change the provisioning secret for a SIP endpoint
155
+ * @param {string} endpointId - The endpoint ID
156
+ * @returns {Promise<Object>} New endpoint credentials
157
+ */
158
+ async changeProvisioningSecret(endpointId) {
87
159
  this.sdk.validateParams(
88
160
  { endpointId },
89
161
  {
@@ -92,8 +164,8 @@ export class SipEndpointsService {
92
164
  );
93
165
 
94
166
  const result = await this.sdk._fetch(
95
- `/sipEndpoints/${endpointId}`,
96
- 'DELETE',
167
+ `/sipEndpoints/${endpointId}/secret/provisioning`,
168
+ 'POST',
97
169
  );
98
170
  return result;
99
171
  }