@signalhousellc/sdk 1.5.0 → 1.6.0
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 +5 -56
- package/index.d.ts +1 -0
- package/index.js +2 -0
- package/package.json +32 -34
- package/voice-browser.d.ts +1 -0
- package/voice-browser.js +2 -0
- package/warn.js +7 -0
- package/webhooks.d.ts +1 -0
- package/webhooks.js +2 -0
- package/scripts/install-skills.mjs +0 -329
- package/skills/VENDORED.json +0 -22
- package/skills/signalhouse-10dlc/SKILL.md +0 -172
- package/skills/signalhouse-10dlc/examples/brightsmile-onboarding.md +0 -62
- package/skills/signalhouse-10dlc/references/tcr-rejection-causes.md +0 -104
- package/skills/signalhouse-advisor/SKILL.md +0 -84
- package/skills/signalhouse-numbers/SKILL.md +0 -82
- package/skills/signalhouse-setup/SKILL.md +0 -121
- package/skills/signalhouse-sms/SKILL.md +0 -81
- package/skills/signalhouse-webhooks/SKILL.md +0 -148
- package/src/SignalHouseSDK.js +0 -201
- package/src/domains/Agents.js +0 -987
- package/src/domains/Auth.js +0 -225
- package/src/domains/Billing.js +0 -264
- package/src/domains/Brands.js +0 -508
- package/src/domains/Campaigns.js +0 -691
- package/src/domains/Dnc.js +0 -168
- package/src/domains/Groups.js +0 -187
- package/src/domains/Landings.js +0 -237
- package/src/domains/Messages.js +0 -609
- package/src/domains/Notifications.js +0 -62
- package/src/domains/Numbers.js +0 -572
- package/src/domains/Onboarding.js +0 -128
- package/src/domains/Registrations.js +0 -246
- package/src/domains/Shortlinks.js +0 -80
- package/src/domains/Subgroups.js +0 -136
- package/src/domains/Subscriptions.js +0 -146
- package/src/domains/Templates.js +0 -403
- package/src/domains/Tickets.js +0 -100
- package/src/domains/Users.js +0 -228
- package/src/domains/Voice.js +0 -41
- package/src/domains/Webhooks.js +0 -125
- package/src/domains/voice/Analytics.js +0 -82
- package/src/domains/voice/CallLogs.js +0 -111
- package/src/domains/voice/Calls.js +0 -118
- package/src/domains/voice/GlobalVoiceSettings.js +0 -54
- package/src/domains/voice/NumberRoutes.js +0 -82
- package/src/domains/voice/ProgrammableVoiceProfiles.js +0 -191
- package/src/domains/voice/SipProfiles.js +0 -203
- package/src/domains/voice/SipTrunks.js +0 -203
- package/src/domains/voice/Tokens.js +0 -96
- package/src/domains/voice/browser/Call.js +0 -366
- package/src/domains/voice/browser/Device.js +0 -484
- package/src/domains/voice/browser/index.js +0 -17
- package/src/webhooks/verifySignature.js +0 -66
package/src/domains/Users.js
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
/** @typedef {import('../SignalHouseSDK.js').RequestOptions} RequestOptions */
|
|
2
|
-
/**
|
|
3
|
-
* @template T
|
|
4
|
-
* @typedef {import('../SignalHouseSDK.js').SdkResponse<T>} SdkResponse
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {Object} CreateUserData
|
|
9
|
-
* @property {string} groupId - The ID of the group to which the user belongs (must start with "G" and be at least 8 characters long)
|
|
10
|
-
* @property {string} role - The role of the user (admin, developer, billing, user)
|
|
11
|
-
* @property {string} password - The password for the user (must be at least 8 characters long)
|
|
12
|
-
* @property {string} email - The email address of the user (must be a valid email format)
|
|
13
|
-
* @property {string} [firstName] - The first name of the user (optional)
|
|
14
|
-
* @property {string} [lastName] - The last name of the user (optional)
|
|
15
|
-
* @property {string} [companyName] - The company name associated with the user (optional)
|
|
16
|
-
* @property {string} [phone] - The phone number of the user (optional)
|
|
17
|
-
* @property {string} [profileImageLink] - A URL to the user's profile image (optional, must be a valid URL format if provided)
|
|
18
|
-
* @property {string} [addressLine1] - The first line of the user's address (optional)
|
|
19
|
-
* @property {string} [addressLine2] - The second line of the user's address (optional)
|
|
20
|
-
* @property {string} [city] - The city of the user's address (optional)
|
|
21
|
-
* @property {string} [state] - The state of the user's address (optional)
|
|
22
|
-
* @property {string} [country] - The country of the user's address (optional)
|
|
23
|
-
* @property {string} [postalCode] - The postal code of the user's address (optional)
|
|
24
|
-
* @property {string} [signupSource] - The source from which the user signed up (optional)
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @typedef {Object} CreateServiceUserData
|
|
29
|
-
* @property {string} groupId - The ID of the group to which the service user belongs (required for customer API keys)
|
|
30
|
-
* @property {string} name - The name of the service user (required)
|
|
31
|
-
* @property {string} role - The role of the service user: "api" for a customer API key (required)
|
|
32
|
-
* @property {string[]} [allowedIps] - Only accept this API key from these IPv4/IPv6 addresses or CIDR ranges (max 100). Omit or pass [] for no IP restriction. Customer API keys only.
|
|
33
|
-
* @property {string[]} [allowedCountries] - Only accept this API key from these countries, as ISO 3166-1 alpha-2 codes such as "US" (max 250). Omit or pass [] for no country restriction. Customer API keys only.
|
|
34
|
-
* @property {string[]} [allowedDestinationCountries] - Only let this API key send messages to these countries, as ISO 3166-1 alpha-2 codes such as "US" (max 250). Sends to any other country are rejected with a 403 DESTINATION_COUNTRY_NOT_ALLOWED. Omit or pass [] for any country. Customer API keys only.
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @typedef {Object} UpdateUserData
|
|
39
|
-
* @property {string} [role] - The role of the user (admin, developer, billing, user)
|
|
40
|
-
* @property {string} [email] - The email address of the user (must be a valid email format if provided)
|
|
41
|
-
* @property {string} [firstName] - The first name of the user (optional)
|
|
42
|
-
* @property {string} [lastName] - The last name of the user (optional)
|
|
43
|
-
* @property {string} [companyName] - The company name associated with the user (optional)
|
|
44
|
-
* @property {string} [phone] - The phone number of the user (optional)
|
|
45
|
-
* @property {string} [profileImageLink] - A URL to the user's profile image (optional, must be a valid URL format if provided)
|
|
46
|
-
* @property {string} [addressLine1] - The first line of the user's address (optional)
|
|
47
|
-
* @property {string} [addressLine2] - The second line of the user's address (optional)
|
|
48
|
-
* @property {string} [city] - The city of the user's address (optional)
|
|
49
|
-
* @property {string} [state] - The state of the user's address (optional)
|
|
50
|
-
* @property {string} [country] - The country of the user's address (optional)
|
|
51
|
-
* @property {string} [postalCode] - The postal code of the user's address (optional)
|
|
52
|
-
* @property {string} [status] - The status of the user (e.g., "active", "inactive")
|
|
53
|
-
* @property {string[]} [allowedIps] - Customer API keys only: replace the key's allowed IPv4/IPv6 addresses or CIDR ranges ([] removes the restriction). Requires an interactive admin or developer session; an API key cannot change its own restrictions.
|
|
54
|
-
* @property {string[]} [allowedCountries] - Customer API keys only: replace the key's allowed ISO 3166-1 alpha-2 country codes ([] removes the restriction). Requires an interactive admin or developer session.
|
|
55
|
-
* @property {string[]} [allowedDestinationCountries] - Customer API keys only: replace the countries the key may send messages to ([] allows any country). Requires an interactive admin or developer session.
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
export class Users {
|
|
59
|
-
constructor(client, enableAdmin) {
|
|
60
|
-
this.client = client;
|
|
61
|
-
this.enableAdmin = enableAdmin;
|
|
62
|
-
|
|
63
|
-
if (enableAdmin) {
|
|
64
|
-
this.admin = {
|
|
65
|
-
/**
|
|
66
|
-
* Get a list of users with optional filters.
|
|
67
|
-
* @roles signalhouse
|
|
68
|
-
* @param {Object} params - The parameters for getting users
|
|
69
|
-
* @param {string} [params.email] - Filter users by email (partial match)
|
|
70
|
-
* @param {string} [params.userType] - Filter users by type (user, service)
|
|
71
|
-
* @param {number} [params.page] - Page number for pagination
|
|
72
|
-
* @param {number} [params.limit] - Items per page
|
|
73
|
-
* @param {string} [params.search] - Search users by email (case-insensitive)
|
|
74
|
-
* @param {string} [params.sortBy] - Field to sort by (createdAt, email, activeGroupId, companyName, status, _id)
|
|
75
|
-
* @param {string} [params.sortOrder] - Sort direction (asc, desc)
|
|
76
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
77
|
-
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to the list of users
|
|
78
|
-
*/
|
|
79
|
-
getUsers: async ({ email, userType, page, limit, search, sortBy, sortOrder, options = {} }) => {
|
|
80
|
-
const filters = { email, userType, page, limit, search, sortBy, sortOrder };
|
|
81
|
-
const queryString = this.client._getQueryString(filters);
|
|
82
|
-
return this.client(`/user${queryString}`, { method: "GET", ...options });
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Create a new internal user (admin or service user) with the specified data.
|
|
87
|
-
* @roles signalhouse
|
|
88
|
-
* @param {Object} params - The parameters for creating an internal user
|
|
89
|
-
* @param {CreateServiceUserData} params.data - The data for the new internal user
|
|
90
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
91
|
-
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to the created internal user
|
|
92
|
-
*/
|
|
93
|
-
createInternalUser: async ({ data, options = {} }) => {
|
|
94
|
-
this.client._require({ data: data });
|
|
95
|
-
return this.client(`/user/signalhouse`, { method: "POST", body: data, ...options });
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Get a list of users with optional filters
|
|
103
|
-
* @async
|
|
104
|
-
* @roles api, admin, self
|
|
105
|
-
* @param {Object} params - The parameters for getting users
|
|
106
|
-
* @param {string} [params.id] - Filter by user ID
|
|
107
|
-
* @param {string} [params.groupId] - Filter by group ID
|
|
108
|
-
* @param {string} [params.userType] - Filter by user type (user, service)
|
|
109
|
-
* @param {number} [params.page] - Page number for pagination
|
|
110
|
-
* @param {number} [params.limit] - Items per page
|
|
111
|
-
* @param {string} [params.search] - Search users by email (case-insensitive)
|
|
112
|
-
* @param {string} [params.sortBy] - Field to sort by (createdAt, email, activeGroupId, companyName, status, _id)
|
|
113
|
-
* @param {string} [params.sortOrder] - Sort direction (asc, desc)
|
|
114
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
115
|
-
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to the list of users
|
|
116
|
-
*/
|
|
117
|
-
async getUsers({ id, groupId, userType, page, limit, search, sortBy, sortOrder, options = {} }) {
|
|
118
|
-
const filters = { id, groupId, userType, page, limit, search, sortBy, sortOrder };
|
|
119
|
-
const queryString = this.client._getQueryString(filters);
|
|
120
|
-
return this.client(`/user${queryString}`, { method: "GET", ...options });
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Create a new user with the specified user data
|
|
125
|
-
* @async
|
|
126
|
-
* @roles api, admin
|
|
127
|
-
* @param {Object} params - The parameters for creating a user (see CreateUserData typedef for details)
|
|
128
|
-
* @param {CreateUserData} params.data - The data for the new user
|
|
129
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
130
|
-
* @throws {Error} Throws an error if required fields in the data parameter are missing
|
|
131
|
-
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to the created user
|
|
132
|
-
*/
|
|
133
|
-
async createUser({ data, options = {} }) {
|
|
134
|
-
this.client._require({ data: data });
|
|
135
|
-
return this.client(`/user`, { method: "POST", body: data, ...options });
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Create a new service user with the specified user data. Used for creating API keys and other non-human users.
|
|
140
|
-
* @async
|
|
141
|
-
* @roles admin, developer
|
|
142
|
-
* @param {Object} params - The parameters for creating a service user (see CreateServiceUserData typedef for details)
|
|
143
|
-
* @param {CreateServiceUserData} params.data - The data for the new service user
|
|
144
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
145
|
-
* @throws {Error} Throws an error if required fields in the data parameter are missing
|
|
146
|
-
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to the created service user
|
|
147
|
-
*/
|
|
148
|
-
async createServiceUser({ data, options = {} }) {
|
|
149
|
-
this.client._require({ data: data });
|
|
150
|
-
return this.client(`/user/serviceuser`, { method: "POST", body: data, ...options });
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Update an existing user's information with the specified user data
|
|
155
|
-
* @async
|
|
156
|
-
* @roles api, admin, self
|
|
157
|
-
* @param {Object} params - The parameters for updating a user (see UpdateUserData typedef for details)
|
|
158
|
-
* @param {string} params.id - The ID of the user to update
|
|
159
|
-
* @param {UpdateUserData} params.data - The data to update for the user
|
|
160
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
161
|
-
* @throws {Error} Throws an error if required fields in the data parameter are missing
|
|
162
|
-
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to the updated user
|
|
163
|
-
*/
|
|
164
|
-
async updateUser({ id, data, options = {} }) {
|
|
165
|
-
this.client._require({ id, data: data });
|
|
166
|
-
const safeId = encodeURIComponent(id);
|
|
167
|
-
return this.client(`/user/${safeId}`, { method: "PUT", body: data, ...options });
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Delete a user by their ID (mark as inactive)
|
|
172
|
-
* @async
|
|
173
|
-
* @roles api, admin
|
|
174
|
-
* @param {Object} params - The parameters for deleting a user
|
|
175
|
-
* @param {string} params.id - The ID of the user to delete
|
|
176
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
177
|
-
* @throws {Error} Throws an error if the id parameter is missing
|
|
178
|
-
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to the deleted user
|
|
179
|
-
*/
|
|
180
|
-
async deleteUser({ id, options = {} }) {
|
|
181
|
-
this.client._require({ id });
|
|
182
|
-
const safeId = encodeURIComponent(id);
|
|
183
|
-
return this.client(`/user/${safeId}`, { method: "DELETE", ...options });
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Accept the Terms of Service for the authenticated caller (self-service).
|
|
188
|
-
* @async
|
|
189
|
-
* @roles api, admin, developer, billing, user
|
|
190
|
-
* @param {Object} [params]
|
|
191
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
192
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server ({ acceptedTermsOfService: true })
|
|
193
|
-
*/
|
|
194
|
-
async acceptTermsOfService({ options = {} } = {}) {
|
|
195
|
-
return this.client(`/user/accept-terms`, { method: "PUT", body: { acceptedTermsOfService: true }, ...options });
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Get notification preferences for a user
|
|
200
|
-
* @async
|
|
201
|
-
* @roles api, admin, self
|
|
202
|
-
* @param {Object} params
|
|
203
|
-
* @param {string} params.id - The ID of the user
|
|
204
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
205
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server
|
|
206
|
-
*/
|
|
207
|
-
async getNotificationPreferences({ id, options = {} }) {
|
|
208
|
-
this.client._require({ id });
|
|
209
|
-
const safeId = encodeURIComponent(id);
|
|
210
|
-
return this.client(`/user/${safeId}/notification-preferences`, { method: "GET", ...options });
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Update notification preferences for a user
|
|
215
|
-
* @async
|
|
216
|
-
* @roles api, admin, self
|
|
217
|
-
* @param {Object} params
|
|
218
|
-
* @param {string} params.id - The ID of the user
|
|
219
|
-
* @param {Array<{name: string, web: boolean, email: boolean}>} params.notificationPreferences - Array of notification preference objects
|
|
220
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
221
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server
|
|
222
|
-
*/
|
|
223
|
-
async updateNotificationPreferences({ id, notificationPreferences, options = {} }) {
|
|
224
|
-
this.client._require({ id, notificationPreferences });
|
|
225
|
-
const safeId = encodeURIComponent(id);
|
|
226
|
-
return this.client(`/user/${safeId}/notification-preferences`, { method: "PUT", body: { notificationPreferences }, ...options });
|
|
227
|
-
}
|
|
228
|
-
}
|
package/src/domains/Voice.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { SipTrunks } from "./voice/SipTrunks.js";
|
|
2
|
-
import { SipProfiles } from "./voice/SipProfiles.js";
|
|
3
|
-
import { ProgrammableVoiceProfiles } from "./voice/ProgrammableVoiceProfiles.js";
|
|
4
|
-
import { NumberRoutes } from "./voice/NumberRoutes.js";
|
|
5
|
-
import { Calls } from "./voice/Calls.js";
|
|
6
|
-
import { CallLogs } from "./voice/CallLogs.js";
|
|
7
|
-
import { GlobalVoiceSettings } from "./voice/GlobalVoiceSettings.js";
|
|
8
|
-
import { Tokens } from "./voice/Tokens.js";
|
|
9
|
-
import { Analytics } from "./voice/Analytics.js";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Voice domain — wraps the voice-backend service (mounted under /voice on the
|
|
13
|
-
* platform host). Groups all voice-service sub-resources under a single
|
|
14
|
-
* namespace, accessed via `sdk.voice.*`.
|
|
15
|
-
*
|
|
16
|
-
* Sub-resources:
|
|
17
|
-
* - `sdk.voice.sipTrunks` — SIP trunk (peer-to-peer connections to PBX/carrier).
|
|
18
|
-
* - `sdk.voice.sipProfiles` — SIP profile / endpoint (single registerable UA).
|
|
19
|
-
* - `sdk.voice.programmableVoiceProfiles` — Programmable Voice Profile (route a set of numbers through Signal House).
|
|
20
|
-
* - `sdk.voice.numberRoutes` — Per-number inbound route (overrides the profile and subgroup settings).
|
|
21
|
-
* - `sdk.voice.calls` — Twilio-compat programmatic call control (create/hangup/etc.).
|
|
22
|
-
* - `sdk.voice.callLogs` — Account-scoped call history: list/get + presigned recording.
|
|
23
|
-
* - `sdk.voice.globalVoiceSettings` — Account-wide voice defaults (accepted regions, max spend, E911).
|
|
24
|
-
* - `sdk.voice.tokens` — Mint ephemeral SIP credentials for the browser voice SDK.
|
|
25
|
-
* - `sdk.voice.analytics` — Aggregated call analytics (summary tiles + byDate/byNumber/byCarrier breakdowns).
|
|
26
|
-
*/
|
|
27
|
-
export class Voice {
|
|
28
|
-
constructor(client, enableAdmin) {
|
|
29
|
-
this.client = client;
|
|
30
|
-
this.enableAdmin = enableAdmin;
|
|
31
|
-
this.sipTrunks = new SipTrunks(client, enableAdmin);
|
|
32
|
-
this.sipProfiles = new SipProfiles(client, enableAdmin);
|
|
33
|
-
this.programmableVoiceProfiles = new ProgrammableVoiceProfiles(client, enableAdmin);
|
|
34
|
-
this.numberRoutes = new NumberRoutes(client, enableAdmin);
|
|
35
|
-
this.calls = new Calls(client, enableAdmin);
|
|
36
|
-
this.callLogs = new CallLogs(client, enableAdmin);
|
|
37
|
-
this.globalVoiceSettings = new GlobalVoiceSettings(client, enableAdmin);
|
|
38
|
-
this.tokens = new Tokens(client, enableAdmin);
|
|
39
|
-
this.analytics = new Analytics(client, enableAdmin);
|
|
40
|
-
}
|
|
41
|
-
}
|
package/src/domains/Webhooks.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/** @typedef {import('../SignalHouseSDK.js').RequestOptions} RequestOptions */
|
|
2
|
-
/**
|
|
3
|
-
* @template T
|
|
4
|
-
* @typedef {import('../SignalHouseSDK.js').SdkResponse<T>} SdkResponse
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export class Webhooks {
|
|
8
|
-
constructor(client, enableAdmin) {
|
|
9
|
-
this.client = client;
|
|
10
|
-
this.enableAdmin = enableAdmin;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Get a list of webhooks with optional filters. Each returned endpoint carries `hasSigningSecret`
|
|
15
|
-
* (boolean) instead of the signing secret itself — the plaintext secret is only ever returned once,
|
|
16
|
-
* from `createWebhook`, and is never exposed again on any read (SHGHL-2944).
|
|
17
|
-
* @async
|
|
18
|
-
* @roles api, admin, developer
|
|
19
|
-
* @param {Object} params - The parameters for getting webhooks
|
|
20
|
-
* @param {string} [params.id] - Filter by webhook ID
|
|
21
|
-
* @param {string} [params.groupId] - Filter by associated group ID
|
|
22
|
-
* @param {string} [params.endpointType] - Filter by endpoint type (Global, Number)
|
|
23
|
-
* @param {string} [params.phoneNumber] - Filter by associated phone number (for SMS webhooks)
|
|
24
|
-
* @param {number} [params.page] - The page number for pagination
|
|
25
|
-
* @param {number} [params.limit] - The number of items per page for pagination
|
|
26
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
27
|
-
* @returns {Promise<SdkResponse<Array>>} The response from the server
|
|
28
|
-
*/
|
|
29
|
-
async getWebhooks({ id, groupId, endpointType, phoneNumber, page, limit, options = {} }) {
|
|
30
|
-
const filters = { id, groupId, endpointType, phoneNumber, page, limit };
|
|
31
|
-
const queryString = this.client._getQueryString(filters);
|
|
32
|
-
return this.client(`/webhook${queryString}`, { method: "GET", ...options });
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Create a new webhook with the specified data. The response includes a `signingSecret` — a
|
|
37
|
-
* plaintext HMAC-SHA256 secret used to sign every delivery to this endpoint, sent as the
|
|
38
|
-
* `X-SignalHouse-Signature` header alongside `X-SignalHouse-Timestamp` (the signed string is
|
|
39
|
-
* `${timestamp}.${rawRequestBody}`) and `X-SignalHouse-Delivery-Id` (stable across retries of the
|
|
40
|
-
* same event, for receiver-side dedup), plus `X-SignalHouse-Signature-V1` (`t=<ms>,v1=<hex>[,v1=<hex>]`,
|
|
41
|
-
* every currently valid signature). Store this secret now: it is never returned again by any read
|
|
42
|
-
* (SHGHL-2944). If it's lost, call `rotateWebhookSecret`. Verify deliveries with
|
|
43
|
-
* `verifyWebhookSignature` from `@signalhousellc/sdk/webhooks` (Node only). `webhookData.authType` is one of
|
|
44
|
-
* `NONE` (default), `BASIC`, `API_KEY`, `OAUTH2` or `HMAC`; `HMAC` (SHGHL-3595) sends no credentials, so the
|
|
45
|
-
* receiver authenticates by the signature alone, and must be sent without `credentials` or `apiHeaderPrefix`.
|
|
46
|
-
* `webhookData.eventSettings` (SHGHL-3884) holds per-event options keyed by event name:
|
|
47
|
-
* `NUMBER_HEALTH_BELOW_THRESHOLD` and `CAMPAIGN_HEALTH_BELOW_THRESHOLD` each take `{ threshold }`, the 7-day
|
|
48
|
-
* health score (1.5–10, in 0.5 steps) below which the event fires; a subscribed health event without one is
|
|
49
|
-
* stored with the default, 6.
|
|
50
|
-
* @async
|
|
51
|
-
* @roles api, admin, developer
|
|
52
|
-
* @param {Object} params - The parameters for creating a webhook
|
|
53
|
-
* @param {Object} params.webhookData - The data for the new webhook
|
|
54
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
55
|
-
* @throws {Error} Throws an error if the webhookData parameter is missing or if required fields in webhookData are missing
|
|
56
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server, including the plaintext `signingSecret` (this one time only)
|
|
57
|
-
*/
|
|
58
|
-
async createWebhook({ webhookData, options = {} }) {
|
|
59
|
-
this.client._require({ webhookData: webhookData });
|
|
60
|
-
return this.client(`/webhook`, { method: "POST", body: webhookData, ...options });
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Update an existing webhook with the specified data. `updateData` may include `name`, `url`,
|
|
65
|
-
* `subscribedEvents` and (SHGHL-3486) `authType`, `apiHeaderPrefix` and `credentials` (`{ key, secret? }`)
|
|
66
|
-
* to change the endpoint's own credentials in place: credentials are required when switching to an auth
|
|
67
|
-
* type that needs them, and omitted credentials keep the stored ones. Switching to `NONE` or `HMAC` clears
|
|
68
|
-
* the stored credentials; `HMAC` is rejected for an endpoint with no signing secret (call
|
|
69
|
-
* `rotateWebhookSecret` first). `updateData.eventSettings` changes per-event options by event name
|
|
70
|
-
* (`{ NUMBER_HEALTH_BELOW_THRESHOLD: { threshold } }`, `{ CAMPAIGN_HEALTH_BELOW_THRESHOLD: { threshold } }`,
|
|
71
|
-
* 1.5–10 in 0.5 steps); events you omit keep their stored settings. Like every read of a webhook, the
|
|
72
|
-
* response carries `hasSigningSecret` and `hasCredentials` (booleans), never a secret or credential.
|
|
73
|
-
* @async
|
|
74
|
-
* @roles api, admin, developer
|
|
75
|
-
* @param {Object} params - The parameters for updating a webhook
|
|
76
|
-
* @param {string} params.id - The ID of the webhook to update
|
|
77
|
-
* @param {Object} params.updateData - The data for the webhook to be updated, including fields such as endpoint URL and event types
|
|
78
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
79
|
-
* @throws {Error} Throws an error if the id or updateData parameter is missing
|
|
80
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server
|
|
81
|
-
*/
|
|
82
|
-
async updateWebhook({ id, updateData, options = {} }) {
|
|
83
|
-
this.client._require({ id, updateData });
|
|
84
|
-
const safeId = encodeURIComponent(id);
|
|
85
|
-
return this.client(`/webhook/${safeId}`, { method: "PUT", body: updateData, ...options });
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Rotate a webhook's signing secret, or give a webhook created before signing existed its first one
|
|
90
|
-
* (SHGHL-3486). The response includes the new plaintext `signingSecret`, returned this one time only.
|
|
91
|
-
* The replaced secret keeps working for `graceSeconds` (default 86400, max 604800, 0 = stop now):
|
|
92
|
-
* during that window each delivery's `X-SignalHouse-Signature-V1` header carries a signature for both,
|
|
93
|
-
* and `previousSecretExpiresAt` in the response says when the old one stops. Not available to OAuth
|
|
94
|
-
* connector tokens.
|
|
95
|
-
* @async
|
|
96
|
-
* @roles api, admin, developer
|
|
97
|
-
* @param {Object} params - The parameters for rotating the secret
|
|
98
|
-
* @param {string} params.id - The ID of the webhook
|
|
99
|
-
* @param {number} [params.graceSeconds] - How long the replaced secret stays valid
|
|
100
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
101
|
-
* @throws {Error} Throws an error if the id parameter is missing
|
|
102
|
-
* @returns {Promise<SdkResponse<any>>} The webhook, including the new plaintext `signingSecret` (this one time only)
|
|
103
|
-
*/
|
|
104
|
-
async rotateWebhookSecret({ id, graceSeconds, options = {} }) {
|
|
105
|
-
this.client._require({ id });
|
|
106
|
-
const safeId = encodeURIComponent(id);
|
|
107
|
-
return this.client(`/webhook/${safeId}/rotate-secret`, { method: "POST", body: graceSeconds === undefined ? {} : { graceSeconds }, ...options });
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Delete a webhook by its ID (mark as inactive)
|
|
112
|
-
* @async
|
|
113
|
-
* @roles api, admin, developer
|
|
114
|
-
* @param {Object} params - The parameters for deleting a webhook
|
|
115
|
-
* @param {string} params.id - The ID of the webhook to delete
|
|
116
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
117
|
-
* @throws {Error} Throws an error if the id parameter is missing
|
|
118
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server
|
|
119
|
-
*/
|
|
120
|
-
async deleteWebhook({ id, options = {} }) {
|
|
121
|
-
this.client._require({ id });
|
|
122
|
-
const safeId = encodeURIComponent(id);
|
|
123
|
-
return this.client(`/webhook/${safeId}`, { method: "DELETE", ...options });
|
|
124
|
-
}
|
|
125
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/** @typedef {import('../../SignalHouseSDK.js').RequestOptions} RequestOptions */
|
|
2
|
-
/**
|
|
3
|
-
* @template T
|
|
4
|
-
* @typedef {import('../../SignalHouseSDK.js').SdkResponse<T>} SdkResponse
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {Object} VoiceAnalyticsFilters
|
|
9
|
-
* @property {string} [dateFrom] - ISO-8601 lower bound on call start time.
|
|
10
|
-
* @property {string} [dateTo] - ISO-8601 upper bound on call start time.
|
|
11
|
-
* @property {"day"|"week"|"month"} [groupBy] - Bucket size for the byDate breakdown (default "day").
|
|
12
|
-
* @property {"INBOUND"|"OUTBOUND"} [direction] - Restrict the breakdowns to one direction. Summary tiles always cover both.
|
|
13
|
-
* @property {string} [callSource] - Comma-separated CallLog.callSource list (SIP_TRUNK, PROGRAMMABLE_VOICE, AI_VOICE, WEBRTC, VOICEMAIL, CONFERENCE, PSTN).
|
|
14
|
-
* @property {string} [subgroupId] - Filter by owning subgroup.
|
|
15
|
-
* @property {string} [number] - Substring match against either leg (from OR to).
|
|
16
|
-
* @property {string} [carrier] - Filter by carrier.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @typedef {Object} VoiceDirectionSummary
|
|
21
|
-
* @property {number} totalCalls
|
|
22
|
-
* @property {number} successfulCalls
|
|
23
|
-
* @property {number} successRate - Percentage (0–100).
|
|
24
|
-
* @property {number} avgCallsPerDay
|
|
25
|
-
* @property {number|null} avgCallDurationSeconds
|
|
26
|
-
* @property {number} totalCallMinutes
|
|
27
|
-
* @property {number} answerRate - Percentage (ASR / answer seizure rate).
|
|
28
|
-
* @property {number} abandonmentRate - Percentage (CANCELED before answer).
|
|
29
|
-
* @property {number} failedCalls
|
|
30
|
-
* @property {number} failureRate - Percentage.
|
|
31
|
-
* @property {number} pctUnder6s - Percentage of answered calls under 6 seconds.
|
|
32
|
-
* @property {number|null} avgRingDurationSeconds - Average answer_time − start_time.
|
|
33
|
-
* @property {number|null} sentimentScore - Positive-sentiment percentage.
|
|
34
|
-
* @property {"Positive"|"Negative"|"Neutral"|null} sentimentLabel
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @typedef {Object} VoiceBreakdownBucket
|
|
39
|
-
* @property {string} key - The date / number / carrier this bucket aggregates.
|
|
40
|
-
* @property {number} total
|
|
41
|
-
* @property {number} completed
|
|
42
|
-
* @property {number} failed
|
|
43
|
-
* @property {number} noAnswer
|
|
44
|
-
* @property {number} busy
|
|
45
|
-
* @property {number} canceled
|
|
46
|
-
* @property {number} inProgress
|
|
47
|
-
* @property {number} totalDurationSeconds
|
|
48
|
-
* @property {number|null} avgSentimentScore
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Voice Analytics — aggregated call metrics for the portal Voice Analytics view
|
|
53
|
-
* (voice-backend `GET /voice/stats/voice-analytics`). Returns per-direction
|
|
54
|
-
* summary tiles (both directions) plus byDate / byNumber / byCarrier status
|
|
55
|
-
* breakdowns for charts. Distinct from `voice.callLogs`, which is the raw call
|
|
56
|
-
* history. Accessed via `sdk.voice.analytics`.
|
|
57
|
-
*/
|
|
58
|
-
export class Analytics {
|
|
59
|
-
constructor(client, enableAdmin) {
|
|
60
|
-
this.client = client;
|
|
61
|
-
this.enableAdmin = enableAdmin;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Get aggregated voice analytics for the current account.
|
|
66
|
-
* @async
|
|
67
|
-
* @roles api, admin, developer, billing, user
|
|
68
|
-
* @param {Object} [params] - Request parameters.
|
|
69
|
-
* @param {VoiceAnalyticsFilters} [params.filters] - Optional filters. Summary tiles honor every filter except `direction`; breakdowns honor all filters.
|
|
70
|
-
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
71
|
-
* @returns {Promise<SdkResponse<any>>} `{ success, range, outbound: VoiceDirectionSummary, inbound: VoiceDirectionSummary, byDate: VoiceBreakdownBucket[], byNumber: VoiceBreakdownBucket[], byCarrier: VoiceBreakdownBucket[], byChannel: VoiceBreakdownBucket[] }` (byChannel = per-callSource breakdown).
|
|
72
|
-
*/
|
|
73
|
-
async get({ filters = {}, options = {} } = {}) {
|
|
74
|
-
const query = new URLSearchParams();
|
|
75
|
-
for (const [k, v] of Object.entries(filters)) {
|
|
76
|
-
if (v !== undefined && v !== null && v !== "") query.set(k, String(v));
|
|
77
|
-
}
|
|
78
|
-
const qs = query.toString();
|
|
79
|
-
const path = qs ? `/voice/stats/voice-analytics?${qs}` : `/voice/stats/voice-analytics`;
|
|
80
|
-
return this.client(path, { method: "GET", ...options });
|
|
81
|
-
}
|
|
82
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/** @typedef {import('../../SignalHouseSDK.js').RequestOptions} RequestOptions */
|
|
2
|
-
/**
|
|
3
|
-
* @template T
|
|
4
|
-
* @typedef {import('../../SignalHouseSDK.js').SdkResponse<T>} SdkResponse
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {Object} ListCallLogsFilters
|
|
9
|
-
* @property {number} [page] - 1-indexed page (default 1).
|
|
10
|
-
* @property {number} [limit] - Page size (default 20, max 1000).
|
|
11
|
-
* @property {"INBOUND"|"OUTBOUND"|"INTERNAL"} [direction] - Filter by direction.
|
|
12
|
-
* @property {"QUEUED"|"RINGING"|"IN_PROGRESS"|"COMPLETED"|"FAILED"|"BUSY"|"NO_ANSWER"|"CANCELED"} [status] - Filter by status.
|
|
13
|
-
* @property {"SIP_TRUNK"|"PROGRAMMABLE_VOICE"|"AI_VOICE"|"WEBRTC"|"VOICEMAIL"|"CONFERENCE"|"PSTN"} [callSource] - Filter by how the call was handled.
|
|
14
|
-
* @property {string} [subgroupId] - Filter by owning subgroup.
|
|
15
|
-
* @property {string} [sipTrunkId] - Filter by SIP trunk id.
|
|
16
|
-
* @property {string} [programmableVoiceProfileId] - Filter by Programmable Voice Profile id.
|
|
17
|
-
* @property {string} [from] - Filter by caller number (contains).
|
|
18
|
-
* @property {string} [to] - Filter by called number (contains).
|
|
19
|
-
* @property {string} [q] - Free-text search over callId / from / to.
|
|
20
|
-
* @property {"positive"|"negative"|"neutral"} [sentiment] - Filter by sentiment.
|
|
21
|
-
* @property {boolean} [voicemail] - When true, return only voicemails (metadata.voicemail=true).
|
|
22
|
-
* @property {boolean} [hasRecording] - When true, only calls that have a recording (callRecordingUrl set).
|
|
23
|
-
* @property {boolean} [excludeVoicemail] - When true, exclude voicemails (used by the Call Recordings view).
|
|
24
|
-
* @property {string} [dateFrom] - ISO-8601 lower bound on start time.
|
|
25
|
-
* @property {string} [dateTo] - ISO-8601 upper bound on start time.
|
|
26
|
-
* @property {string} [sort] - Sort field (default startTime).
|
|
27
|
-
* @property {"asc"|"desc"} [order] - Sort order (default desc).
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Call Logs — the account-scoped voice call history (voice-backend
|
|
32
|
-
* `/voice/api/v1/call-logs`). Distinct from `voice.calls`, which is the
|
|
33
|
-
* Twilio-compatible programmatic call-control surface; this is the richer log
|
|
34
|
-
* read surface with cost, recording, and voice-config attribution used by the
|
|
35
|
-
* portal Call Logs view. Accessed via `sdk.voice.callLogs`.
|
|
36
|
-
*/
|
|
37
|
-
export class CallLogs {
|
|
38
|
-
constructor(client, enableAdmin) {
|
|
39
|
-
this.client = client;
|
|
40
|
-
this.enableAdmin = enableAdmin;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* List call logs for the current account, paginated and filterable.
|
|
45
|
-
* @async
|
|
46
|
-
* @roles api, admin, developer, billing, user
|
|
47
|
-
* @param {Object} [params] - Request parameters.
|
|
48
|
-
* @param {ListCallLogsFilters} [params.filters] - Optional filters.
|
|
49
|
-
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
50
|
-
* @returns {Promise<SdkResponse<any>>} `{ success, data: [...call logs], meta: { total, page, limit, totalPages } }`.
|
|
51
|
-
*/
|
|
52
|
-
async list({ filters = {}, options = {} } = {}) {
|
|
53
|
-
const query = new URLSearchParams();
|
|
54
|
-
for (const [k, v] of Object.entries(filters)) {
|
|
55
|
-
if (v !== undefined && v !== null && v !== "") query.set(k, String(v));
|
|
56
|
-
}
|
|
57
|
-
const qs = query.toString();
|
|
58
|
-
const path = qs ? `/voice/api/v1/call-logs?${qs}` : `/voice/api/v1/call-logs`;
|
|
59
|
-
return this.client(path, { method: "GET", ...options });
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Get a single call log by its UUID or callId.
|
|
64
|
-
* @async
|
|
65
|
-
* @roles api, admin, developer, billing, user
|
|
66
|
-
* @param {Object} params - Request parameters.
|
|
67
|
-
* @param {string} params.id - The call log UUID or callId.
|
|
68
|
-
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
69
|
-
* @throws {Error} If id is missing.
|
|
70
|
-
* @returns {Promise<SdkResponse<any>>} `{ success, data: { ...call log } }`.
|
|
71
|
-
*/
|
|
72
|
-
async get({ id, options = {} }) {
|
|
73
|
-
this.client._require({ id });
|
|
74
|
-
const safeId = encodeURIComponent(id);
|
|
75
|
-
return this.client(`/voice/api/v1/call-logs/${safeId}`, { method: "GET", ...options });
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Get a short-TTL presigned playback URL for a call's recording. Account-scoped
|
|
80
|
-
* — only the owning account can presign. 404 if the call has no recording.
|
|
81
|
-
* @async
|
|
82
|
-
* @roles api, admin, developer, billing, user
|
|
83
|
-
* @param {Object} params - Request parameters.
|
|
84
|
-
* @param {string} params.id - The call log UUID or callId.
|
|
85
|
-
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
86
|
-
* @throws {Error} If id is missing.
|
|
87
|
-
* @returns {Promise<SdkResponse<any>>} `{ success, data: { callId, url, expiresIn } }`.
|
|
88
|
-
*/
|
|
89
|
-
async getRecording({ id, options = {} }) {
|
|
90
|
-
this.client._require({ id });
|
|
91
|
-
const safeId = encodeURIComponent(id);
|
|
92
|
-
return this.client(`/voice/api/v1/call-logs/${safeId}/recording`, { method: "GET", ...options });
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Mark a voicemail (a call log with a recording) read or unread. Account-scoped.
|
|
97
|
-
* @async
|
|
98
|
-
* @roles api, admin, developer
|
|
99
|
-
* @param {Object} params - Request parameters.
|
|
100
|
-
* @param {string} params.id - The call log UUID or callId.
|
|
101
|
-
* @param {boolean} [params.read=true] - true = read, false = unread.
|
|
102
|
-
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
103
|
-
* @throws {Error} If id is missing.
|
|
104
|
-
* @returns {Promise<SdkResponse<any>>} `{ success, data: { id, voicemailReadAt } }`.
|
|
105
|
-
*/
|
|
106
|
-
async markVoicemailRead({ id, read = true, options = {} }) {
|
|
107
|
-
this.client._require({ id });
|
|
108
|
-
const safeId = encodeURIComponent(id);
|
|
109
|
-
return this.client(`/voice/api/v1/call-logs/${safeId}/voicemail-read`, { method: "PATCH", body: { read }, ...options });
|
|
110
|
-
}
|
|
111
|
-
}
|