@nuancelabs/js-sdk 0.9.0 → 0.10.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/index.d.ts +12 -0
- package/index.js +18 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -376,6 +376,18 @@ export declare interface CreateNuanceConversationOptions {
|
|
|
376
376
|
}
|
|
377
377
|
|
|
378
378
|
|
|
379
|
+
/**
|
|
380
|
+
* Raised by {@link Conversation.connect} when the server refuses a guest's new
|
|
381
|
+
* session because a guest limit is used up. `reason` says which: `used` (this
|
|
382
|
+
* guest has had its conversations), `device` (so has this browser) or `network`
|
|
383
|
+
* (so has this network today). The message is the server's, written for the
|
|
384
|
+
* person.
|
|
385
|
+
*/
|
|
386
|
+
export declare class GuestLimitError extends Error {
|
|
387
|
+
readonly reason: string;
|
|
388
|
+
constructor(reason: string, message: string);
|
|
389
|
+
}
|
|
390
|
+
|
|
379
391
|
/**
|
|
380
392
|
* Raised by {@link Conversation.connect} when the server refuses a new session
|
|
381
393
|
* because the account has not completed onboarding or accepted the current
|
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@ function isRecord(value) {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
// src/core/sdk-version.ts
|
|
7
|
-
var SDK_HEADER = `js/${"0.
|
|
7
|
+
var SDK_HEADER = `js/${"0.10.0"}`;
|
|
8
8
|
|
|
9
9
|
// src/utils.ts
|
|
10
10
|
function normalizeHost(host) {
|
|
@@ -108,6 +108,16 @@ class ActiveSessionError extends Error {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
// src/core/guest-limit-error.ts
|
|
112
|
+
class GuestLimitError extends Error {
|
|
113
|
+
reason;
|
|
114
|
+
constructor(reason, message) {
|
|
115
|
+
super(message);
|
|
116
|
+
this.name = "GuestLimitError";
|
|
117
|
+
this.reason = reason;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
111
121
|
// src/core/legal-required-error.ts
|
|
112
122
|
class LegalRequiredError extends Error {
|
|
113
123
|
constructor() {
|
|
@@ -2211,6 +2221,9 @@ function isMaintenanceBody(body) {
|
|
|
2211
2221
|
function isBusyBody(body) {
|
|
2212
2222
|
return isRecord(body) && body.code === "busy";
|
|
2213
2223
|
}
|
|
2224
|
+
function isGuestLimitBody(body) {
|
|
2225
|
+
return isRecord(body) && body.code === "guest_limit";
|
|
2226
|
+
}
|
|
2214
2227
|
function isCurfewBody(body) {
|
|
2215
2228
|
return isRecord(body) && body.code === "policy_curfew";
|
|
2216
2229
|
}
|
|
@@ -2325,6 +2338,9 @@ class NuanceConversation {
|
|
|
2325
2338
|
if (error instanceof ApiError && error.status === 503 && isMaintenanceBody(error.body)) {
|
|
2326
2339
|
throw new MaintenanceError(typeof error.body.detail === "string" ? error.body.detail : "The service is under maintenance");
|
|
2327
2340
|
}
|
|
2341
|
+
if (error instanceof ApiError && error.status === 429 && isGuestLimitBody(error.body)) {
|
|
2342
|
+
throw new GuestLimitError(typeof error.body.reason === "string" ? error.body.reason : "used", typeof error.body.detail === "string" ? error.body.detail : "You've had your free conversation");
|
|
2343
|
+
}
|
|
2328
2344
|
if (error instanceof ApiError && error.status === 403 && isCurfewBody(error.body)) {
|
|
2329
2345
|
throw new PolicyCurfewError(typeof error.body.retry_after_seconds === "number" ? error.body.retry_after_seconds : null);
|
|
2330
2346
|
}
|
|
@@ -2795,6 +2811,7 @@ export {
|
|
|
2795
2811
|
MediaAccessError,
|
|
2796
2812
|
MaintenanceError,
|
|
2797
2813
|
LegalRequiredError,
|
|
2814
|
+
GuestLimitError,
|
|
2798
2815
|
ConversationState,
|
|
2799
2816
|
ActiveSessionError
|
|
2800
2817
|
};
|