@mymehq/sdk 3.6.0 → 3.7.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/dist/index.d.ts +13 -4
- package/dist/index.js +14 -14
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -489,17 +489,26 @@ declare class MymeError extends Error {
|
|
|
489
489
|
readonly details?: Record<string, unknown>;
|
|
490
490
|
constructor(code: string, message: string, status: number, details?: Record<string, unknown>, cause?: unknown);
|
|
491
491
|
}
|
|
492
|
+
/**
|
|
493
|
+
* Status-coded subclasses preserve the server-supplied `code` so callers
|
|
494
|
+
* can branch on specific codes (`bulk_cap_exceeded`, `edge_not_found`,
|
|
495
|
+
* `reset_disabled`, …) while still matching `instanceof NotFoundError`
|
|
496
|
+
* etc. for generic handling. The status family (4xx bucket) is
|
|
497
|
+
* communicated by the class; the specific code is communicated by the
|
|
498
|
+
* `code` field. When the server omits a code, the canonical value for
|
|
499
|
+
* the status family is used as a fallback.
|
|
500
|
+
*/
|
|
492
501
|
declare class NotFoundError extends MymeError {
|
|
493
|
-
constructor(message: string, details?: Record<string, unknown
|
|
502
|
+
constructor(message: string, details?: Record<string, unknown>, code?: string);
|
|
494
503
|
}
|
|
495
504
|
declare class ValidationError extends MymeError {
|
|
496
|
-
constructor(message: string, details?: Record<string, unknown
|
|
505
|
+
constructor(message: string, details?: Record<string, unknown>, code?: string);
|
|
497
506
|
}
|
|
498
507
|
declare class UnauthorizedError extends MymeError {
|
|
499
|
-
constructor(message: string, details?: Record<string, unknown
|
|
508
|
+
constructor(message: string, details?: Record<string, unknown>, code?: string);
|
|
500
509
|
}
|
|
501
510
|
declare class ForbiddenError extends MymeError {
|
|
502
|
-
constructor(message: string, details?: Record<string, unknown
|
|
511
|
+
constructor(message: string, details?: Record<string, unknown>, code?: string);
|
|
503
512
|
}
|
|
504
513
|
declare class ConflictError extends MymeError {
|
|
505
514
|
readonly current: ConflictSnapshot;
|
package/dist/index.js
CHANGED
|
@@ -12,26 +12,26 @@ var MymeError = class extends Error {
|
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
var NotFoundError = class extends MymeError {
|
|
15
|
-
constructor(message, details) {
|
|
16
|
-
super("not_found", message, 404, details);
|
|
15
|
+
constructor(message, details, code) {
|
|
16
|
+
super(code ?? "not_found", message, 404, details);
|
|
17
17
|
this.name = "NotFoundError";
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
var ValidationError = class extends MymeError {
|
|
21
|
-
constructor(message, details) {
|
|
22
|
-
super("validation_error", message, 400, details);
|
|
21
|
+
constructor(message, details, code) {
|
|
22
|
+
super(code ?? "validation_error", message, 400, details);
|
|
23
23
|
this.name = "ValidationError";
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
var UnauthorizedError = class extends MymeError {
|
|
27
|
-
constructor(message, details) {
|
|
28
|
-
super("unauthorized", message, 401, details);
|
|
27
|
+
constructor(message, details, code) {
|
|
28
|
+
super(code ?? "unauthorized", message, 401, details);
|
|
29
29
|
this.name = "UnauthorizedError";
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
var ForbiddenError = class extends MymeError {
|
|
33
|
-
constructor(message, details) {
|
|
34
|
-
super("forbidden", message, 403, details);
|
|
33
|
+
constructor(message, details, code) {
|
|
34
|
+
super(code ?? "forbidden", message, 403, details);
|
|
35
35
|
this.name = "ForbiddenError";
|
|
36
36
|
}
|
|
37
37
|
};
|
|
@@ -167,18 +167,18 @@ var HttpTransport = class {
|
|
|
167
167
|
const errObj = parsed?.error;
|
|
168
168
|
const message = errObj?.message ?? `HTTP ${String(status)}`;
|
|
169
169
|
const details = errObj?.details;
|
|
170
|
-
const
|
|
170
|
+
const serverCode = errObj?.code;
|
|
171
171
|
switch (status) {
|
|
172
172
|
case 400:
|
|
173
|
-
throw new ValidationError(message, details);
|
|
173
|
+
throw new ValidationError(message, details, serverCode);
|
|
174
174
|
case 401:
|
|
175
|
-
throw new UnauthorizedError(message, details);
|
|
175
|
+
throw new UnauthorizedError(message, details, serverCode);
|
|
176
176
|
case 403:
|
|
177
|
-
throw new ForbiddenError(message, details);
|
|
177
|
+
throw new ForbiddenError(message, details, serverCode);
|
|
178
178
|
case 404:
|
|
179
|
-
throw new NotFoundError(message, details);
|
|
179
|
+
throw new NotFoundError(message, details, serverCode);
|
|
180
180
|
default:
|
|
181
|
-
throw new MymeError(
|
|
181
|
+
throw new MymeError(serverCode ?? "unknown", message, status, details);
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
};
|