@signalhouse-sms/sdk 1.17.0 → 1.18.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 +3 -0
- package/package.json +1 -1
- package/skills/VENDORED.json +2 -2
- package/src/SignalHouseSDK.js +28 -3
- package/src/domains/Agents.js +7 -0
- package/src/domains/Billing.js +1 -0
- package/src/domains/Campaigns.js +2 -2
- package/types/SignalHouseSDK.d.ts +3 -0
- package/types/domains/Agents.d.ts +7 -0
- package/types/domains/Billing.d.ts +1 -0
- package/types/domains/Campaigns.d.ts +4 -4
package/README.md
CHANGED
|
@@ -45,6 +45,9 @@ const token = await sdk.auth.login({
|
|
|
45
45
|
console.log(token);
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
+
Error handling
|
|
49
|
+
API errors are returned, not thrown: `{ success: false, error, status }`. Non-2xx responses carry `details` when the API returns one. Connector tokens get 429 `CONNECTOR_CAP_EXCEEDED` (`details.code`, with `cap`, `limit` and `retryAfterSeconds`) or 503 `CONNECTOR_CAP_UNAVAILABLE` (with `retryAfterSeconds`). Wait `details.retryAfterSeconds` before retrying.
|
|
50
|
+
|
|
48
51
|
Features
|
|
49
52
|
Full support for Signal House API v2
|
|
50
53
|
Integrated Axios with standardized returns
|
package/package.json
CHANGED
package/skills/VENDORED.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"source": "agent-skills",
|
|
3
|
-
"ref": "v0.
|
|
3
|
+
"ref": "v0.4.0",
|
|
4
4
|
"skills": [
|
|
5
5
|
"signalhouse-10dlc",
|
|
6
6
|
"signalhouse-advisor",
|
|
@@ -17,6 +17,6 @@
|
|
|
17
17
|
"signalhouse-numbers/SKILL.md": "f996be53809ea2f90e49b32452f162eeff5369056e1f63e422b8fdb46d2896ff",
|
|
18
18
|
"signalhouse-setup/SKILL.md": "ca87a6d71f3f82614b83ad283971385fc55c13c097b76595b1b85def235373ec",
|
|
19
19
|
"signalhouse-sms/SKILL.md": "ec7ed8985ad590b0ab5d40c9ddb003eb8cbc566a1309ac5e330f570e0404ec42",
|
|
20
|
-
"signalhouse-webhooks/SKILL.md": "
|
|
20
|
+
"signalhouse-webhooks/SKILL.md": "4806f0cff0c05dee490103e1ba42de784bc270b3111da4d285784ea1ecbbed94"
|
|
21
21
|
}
|
|
22
22
|
}
|
package/src/SignalHouseSDK.js
CHANGED
|
@@ -20,10 +20,31 @@ const REQUEST_TIMEOUT_MS = 30000;
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* The envelope every domain method resolves to. Non-2xx responses never reject; check `success` first.
|
|
23
|
+
* An error envelope carries `details` when the API error body has one, for example `details.code` and
|
|
24
|
+
* `details.retryAfterSeconds` on a connector cap response.
|
|
23
25
|
* @template T
|
|
24
|
-
* @typedef {{ success: true, data: T, status: number } | { success: false, error: string|Object, status: number|null }} SdkResponse
|
|
26
|
+
* @typedef {{ success: true, data: T, status: number } | { success: false, error: string|Object, status: number|null, details?: Object|Array }} SdkResponse
|
|
25
27
|
*/
|
|
26
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Decodes a binary error body (ArrayBuffer, Buffer/typed array or Blob from a binary responseType request) as JSON so
|
|
31
|
+
* its `details` can be read. Non-binary bodies are returned unchanged.
|
|
32
|
+
* @async
|
|
33
|
+
* @param {*} data - The axios error response body.
|
|
34
|
+
* @returns {Promise<*>} - The parsed JSON body, the original body when it is not binary, or null when it is not JSON.
|
|
35
|
+
*/
|
|
36
|
+
async function parseBinaryErrorBody(data) {
|
|
37
|
+
let text;
|
|
38
|
+
if (data instanceof ArrayBuffer || ArrayBuffer.isView(data)) text = new TextDecoder().decode(data);
|
|
39
|
+
else if (typeof Blob !== "undefined" && data instanceof Blob) text = await data.text();
|
|
40
|
+
else return data;
|
|
41
|
+
try {
|
|
42
|
+
return JSON.parse(text);
|
|
43
|
+
} catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
27
48
|
// Main SDK Class (SignalHouseSDK.js)
|
|
28
49
|
import { Auth } from "./domains/Auth.js";
|
|
29
50
|
import { Billing } from "./domains/Billing.js";
|
|
@@ -147,7 +168,7 @@ export class SignalHouseSDK {
|
|
|
147
168
|
|
|
148
169
|
// Non-2xx responses, plus timeouts and network failures (no `error.response` at all) - those
|
|
149
170
|
// get a clear message here rather than surfacing axios's internal error.message verbatim.
|
|
150
|
-
(error) => {
|
|
171
|
+
async (error) => {
|
|
151
172
|
if (!error.response) {
|
|
152
173
|
const isTimeout = error.code === "ECONNABORTED" || /timeout/i.test(error.message || "");
|
|
153
174
|
return {
|
|
@@ -156,11 +177,15 @@ export class SignalHouseSDK {
|
|
|
156
177
|
status: null,
|
|
157
178
|
};
|
|
158
179
|
}
|
|
159
|
-
|
|
180
|
+
const data = error.response.data;
|
|
181
|
+
const result = {
|
|
160
182
|
success: false,
|
|
161
183
|
error: error.response?.data?.message || error.response?.data || error.message || 500,
|
|
162
184
|
status: error.response?.status || error.response?.data || null,
|
|
163
185
|
};
|
|
186
|
+
const body = await parseBinaryErrorBody(data);
|
|
187
|
+
if (body && typeof body === "object" && "details" in body) result.details = body.details;
|
|
188
|
+
return result;
|
|
164
189
|
},
|
|
165
190
|
);
|
|
166
191
|
|
package/src/domains/Agents.js
CHANGED
|
@@ -400,6 +400,13 @@ export class Agents {
|
|
|
400
400
|
* `status` records HOW it ended and cannot be recovered afterwards, so pass the one that
|
|
401
401
|
* actually happened. Ending an already-ended conversation is a no-op, so a retry after a
|
|
402
402
|
* dropped connection cannot overwrite it.
|
|
403
|
+
*
|
|
404
|
+
* The end fires the AI_AGENT_CONVERSATION_ENDED webhook once, with the transcript; a retry fires
|
|
405
|
+
* nothing. `metadata.endReason` is passed on as the webhook's `endReason`.
|
|
406
|
+
*
|
|
407
|
+
* Voice conversations can't be ended here (403): the voice service ends each one when its call ends,
|
|
408
|
+
* because its length sets the call's AI Voice Agent charge. `metadata.agentSeconds` and
|
|
409
|
+
* `metadata.durationSeconds` are reserved for the voice service and are ignored if sent.
|
|
403
410
|
* @async
|
|
404
411
|
* @roles api, admin, developer, billing, user
|
|
405
412
|
* @param {Object} params - The parameters for ending a conversation.
|
package/src/domains/Billing.js
CHANGED
|
@@ -252,6 +252,7 @@ export class Billing {
|
|
|
252
252
|
/**
|
|
253
253
|
* Get the fee schedule for a specific group.
|
|
254
254
|
* When the group is on a custom volume-tiered plan, the response also includes volumePricing: tiers, the current period's dates, count and minimum, ramp, and current rate (rates in microdollars per segment).
|
|
255
|
+
* aiAgentPerMinute is the rate for an AI voice agent's time on a call, in microdollars per minute prorated per second, charged on top of the call's own rate.
|
|
255
256
|
* @async
|
|
256
257
|
* @roles api, admin, developer, billing, user
|
|
257
258
|
* @param {Object} params - The parameters for getting the fees
|
package/src/domains/Campaigns.js
CHANGED
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
* @typedef {Object} CreateTollFreeCampaignData
|
|
106
106
|
* @property {string} brandId - The ID of the Toll-Free brand associated with the campaign (required, at least 7 characters)
|
|
107
107
|
* @property {TollFreeCampaignDetails} tollFree - The Toll-Free campaign details (required)
|
|
108
|
-
* @property {string} [privacyPolicyLink] - A URL linking to the privacy policy (at most 2048 characters). Required when the brand's `tollFree.requiresPrivacyPolicy` is true and the brand
|
|
109
|
-
* @property {string} [termsAndConditionsLink] - A URL linking to the terms and conditions (at most 2048 characters). Required when the brand's `tollFree.requiresTermsAndConditions` is true and the brand
|
|
108
|
+
* @property {string} [privacyPolicyLink] - A URL linking to the privacy policy (at most 2048 characters). Required when the brand's `tollFree.requiresPrivacyPolicy` is true and neither the brand nor the referenced Toll-Free landing page (`tollFree.landingId`) supplies one; optional otherwise. Precedence: campaign, brand, landing page.
|
|
109
|
+
* @property {string} [termsAndConditionsLink] - A URL linking to the terms and conditions (at most 2048 characters). Required when the brand's `tollFree.requiresTermsAndConditions` is true and neither the brand nor the referenced Toll-Free landing page supplies one; optional otherwise.
|
|
110
110
|
* @property {string} [tag] - A tag for the campaign (optional, at most 255 characters)
|
|
111
111
|
* @property {boolean} [autoRenewal=true] - Whether the campaign should auto-renew (optional, defaults to true)
|
|
112
112
|
* @property {Array<string>} phoneNumbers - The Toll-Free numbers to assign to the campaign (required, 1 up to the brand's tollFree.maxNumbersPerCampaign and at most 5, each at least 10 digits and digits only). The numbers must be on the brand's toll-free carrier, or the campaign is refused. Numbers are locked to the campaign once assigned and cannot be moved or added afterward.
|
|
@@ -88,6 +88,8 @@ export type SignalHouseSDKConfig = {
|
|
|
88
88
|
};
|
|
89
89
|
/**
|
|
90
90
|
* The envelope every domain method resolves to. Non-2xx responses never reject; check `success` first.
|
|
91
|
+
* An error envelope carries `details` when the API error body has one, for example `details.code` and
|
|
92
|
+
* `details.retryAfterSeconds` on a connector cap response.
|
|
91
93
|
*/
|
|
92
94
|
export type SdkResponse<T> = {
|
|
93
95
|
success: true;
|
|
@@ -97,6 +99,7 @@ export type SdkResponse<T> = {
|
|
|
97
99
|
success: false;
|
|
98
100
|
error: string | any;
|
|
99
101
|
status: number | null;
|
|
102
|
+
details?: any | any[];
|
|
100
103
|
};
|
|
101
104
|
import { Auth } from "./domains/Auth.js";
|
|
102
105
|
import { Billing } from "./domains/Billing.js";
|
|
@@ -376,6 +376,13 @@ export class Agents {
|
|
|
376
376
|
* `status` records HOW it ended and cannot be recovered afterwards, so pass the one that
|
|
377
377
|
* actually happened. Ending an already-ended conversation is a no-op, so a retry after a
|
|
378
378
|
* dropped connection cannot overwrite it.
|
|
379
|
+
*
|
|
380
|
+
* The end fires the AI_AGENT_CONVERSATION_ENDED webhook once, with the transcript; a retry fires
|
|
381
|
+
* nothing. `metadata.endReason` is passed on as the webhook's `endReason`.
|
|
382
|
+
*
|
|
383
|
+
* Voice conversations can't be ended here (403): the voice service ends each one when its call ends,
|
|
384
|
+
* because its length sets the call's AI Voice Agent charge. `metadata.agentSeconds` and
|
|
385
|
+
* `metadata.durationSeconds` are reserved for the voice service and are ignored if sent.
|
|
379
386
|
* @async
|
|
380
387
|
* @roles api, admin, developer, billing, user
|
|
381
388
|
* @param {Object} params - The parameters for ending a conversation.
|
|
@@ -261,6 +261,7 @@ export class Billing {
|
|
|
261
261
|
/**
|
|
262
262
|
* Get the fee schedule for a specific group.
|
|
263
263
|
* When the group is on a custom volume-tiered plan, the response also includes volumePricing: tiers, the current period's dates, count and minimum, ramp, and current rate (rates in microdollars per segment).
|
|
264
|
+
* aiAgentPerMinute is the rate for an AI voice agent's time on a call, in microdollars per minute prorated per second, charged on top of the call's own rate.
|
|
264
265
|
* @async
|
|
265
266
|
* @roles api, admin, developer, billing, user
|
|
266
267
|
* @param {Object} params - The parameters for getting the fees
|
|
@@ -100,8 +100,8 @@
|
|
|
100
100
|
* @typedef {Object} CreateTollFreeCampaignData
|
|
101
101
|
* @property {string} brandId - The ID of the Toll-Free brand associated with the campaign (required, at least 7 characters)
|
|
102
102
|
* @property {TollFreeCampaignDetails} tollFree - The Toll-Free campaign details (required)
|
|
103
|
-
* @property {string} [privacyPolicyLink] - A URL linking to the privacy policy (at most 2048 characters). Required when the brand's `tollFree.requiresPrivacyPolicy` is true and the brand
|
|
104
|
-
* @property {string} [termsAndConditionsLink] - A URL linking to the terms and conditions (at most 2048 characters). Required when the brand's `tollFree.requiresTermsAndConditions` is true and the brand
|
|
103
|
+
* @property {string} [privacyPolicyLink] - A URL linking to the privacy policy (at most 2048 characters). Required when the brand's `tollFree.requiresPrivacyPolicy` is true and neither the brand nor the referenced Toll-Free landing page (`tollFree.landingId`) supplies one; optional otherwise. Precedence: campaign, brand, landing page.
|
|
104
|
+
* @property {string} [termsAndConditionsLink] - A URL linking to the terms and conditions (at most 2048 characters). Required when the brand's `tollFree.requiresTermsAndConditions` is true and neither the brand nor the referenced Toll-Free landing page supplies one; optional otherwise.
|
|
105
105
|
* @property {string} [tag] - A tag for the campaign (optional, at most 255 characters)
|
|
106
106
|
* @property {boolean} [autoRenewal=true] - Whether the campaign should auto-renew (optional, defaults to true)
|
|
107
107
|
* @property {Array<string>} phoneNumbers - The Toll-Free numbers to assign to the campaign (required, 1 up to the brand's tollFree.maxNumbersPerCampaign and at most 5, each at least 10 digits and digits only). The numbers must be on the brand's toll-free carrier, or the campaign is refused. Numbers are locked to the campaign once assigned and cannot be moved or added afterward.
|
|
@@ -965,11 +965,11 @@ export type CreateTollFreeCampaignData = {
|
|
|
965
965
|
*/
|
|
966
966
|
tollFree: TollFreeCampaignDetails;
|
|
967
967
|
/**
|
|
968
|
-
* - A URL linking to the privacy policy (at most 2048 characters). Required when the brand's `tollFree.requiresPrivacyPolicy` is true and the brand
|
|
968
|
+
* - A URL linking to the privacy policy (at most 2048 characters). Required when the brand's `tollFree.requiresPrivacyPolicy` is true and neither the brand nor the referenced Toll-Free landing page (`tollFree.landingId`) supplies one; optional otherwise. Precedence: campaign, brand, landing page.
|
|
969
969
|
*/
|
|
970
970
|
privacyPolicyLink?: string;
|
|
971
971
|
/**
|
|
972
|
-
* - A URL linking to the terms and conditions (at most 2048 characters). Required when the brand's `tollFree.requiresTermsAndConditions` is true and the brand
|
|
972
|
+
* - A URL linking to the terms and conditions (at most 2048 characters). Required when the brand's `tollFree.requiresTermsAndConditions` is true and neither the brand nor the referenced Toll-Free landing page supplies one; optional otherwise.
|
|
973
973
|
*/
|
|
974
974
|
termsAndConditionsLink?: string;
|
|
975
975
|
/**
|