@shipstatic/types 0.9.7 → 0.9.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.
- package/dist/index.d.ts +4 -4
- package/dist/index.js +8 -8
- package/package.json +1 -1
- package/src/index.ts +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -397,7 +397,7 @@ export declare class ShipError extends Error {
|
|
|
397
397
|
static validation(message: string, details?: unknown): ShipError;
|
|
398
398
|
static notFound(resource: string, id?: string): ShipError;
|
|
399
399
|
static forbidden(message: string, details?: unknown): ShipError;
|
|
400
|
-
static rateLimit(message?: string): ShipError;
|
|
400
|
+
static rateLimit(message?: string, details?: unknown): ShipError;
|
|
401
401
|
/**
|
|
402
402
|
* Construct an Authentication (401) error.
|
|
403
403
|
*
|
|
@@ -412,12 +412,12 @@ export declare class ShipError extends Error {
|
|
|
412
412
|
* `internal`. Other `details` keys round-trip normally.
|
|
413
413
|
*/
|
|
414
414
|
static authentication(message?: string, details?: unknown): ShipError;
|
|
415
|
-
static business(message: string, status?: number): ShipError;
|
|
415
|
+
static business(message: string, status?: number, details?: unknown): ShipError;
|
|
416
416
|
static network(message: string, details?: unknown): ShipError;
|
|
417
|
-
static cancelled(message: string): ShipError;
|
|
417
|
+
static cancelled(message: string, details?: unknown): ShipError;
|
|
418
418
|
static file(message: string, details?: unknown): ShipError;
|
|
419
419
|
static config(message: string, details?: unknown): ShipError;
|
|
420
|
-
static api(message: string, status?: number): ShipError;
|
|
420
|
+
static api(message: string, status?: number, details?: unknown): ShipError;
|
|
421
421
|
isClientError(): boolean;
|
|
422
422
|
isNetworkError(): boolean;
|
|
423
423
|
isAuthError(): boolean;
|
package/dist/index.js
CHANGED
|
@@ -247,8 +247,8 @@ export class ShipError extends Error {
|
|
|
247
247
|
static forbidden(message, details) {
|
|
248
248
|
return new ShipError(ErrorType.Forbidden, message, 403, details);
|
|
249
249
|
}
|
|
250
|
-
static rateLimit(message = "Too many requests") {
|
|
251
|
-
return new ShipError(ErrorType.RateLimit, message, 429);
|
|
250
|
+
static rateLimit(message = "Too many requests", details) {
|
|
251
|
+
return new ShipError(ErrorType.RateLimit, message, 429, details);
|
|
252
252
|
}
|
|
253
253
|
/**
|
|
254
254
|
* Construct an Authentication (401) error.
|
|
@@ -266,14 +266,14 @@ export class ShipError extends Error {
|
|
|
266
266
|
static authentication(message = "Authentication required", details) {
|
|
267
267
|
return new ShipError(ErrorType.Authentication, message, 401, details);
|
|
268
268
|
}
|
|
269
|
-
static business(message, status = 400) {
|
|
270
|
-
return new ShipError(ErrorType.Business, message, status);
|
|
269
|
+
static business(message, status = 400, details) {
|
|
270
|
+
return new ShipError(ErrorType.Business, message, status, details);
|
|
271
271
|
}
|
|
272
272
|
static network(message, details) {
|
|
273
273
|
return new ShipError(ErrorType.Network, message, undefined, details);
|
|
274
274
|
}
|
|
275
|
-
static cancelled(message) {
|
|
276
|
-
return new ShipError(ErrorType.Cancelled, message);
|
|
275
|
+
static cancelled(message, details) {
|
|
276
|
+
return new ShipError(ErrorType.Cancelled, message, undefined, details);
|
|
277
277
|
}
|
|
278
278
|
static file(message, details) {
|
|
279
279
|
return new ShipError(ErrorType.File, message, undefined, details);
|
|
@@ -281,8 +281,8 @@ export class ShipError extends Error {
|
|
|
281
281
|
static config(message, details) {
|
|
282
282
|
return new ShipError(ErrorType.Config, message, undefined, details);
|
|
283
283
|
}
|
|
284
|
-
static api(message, status = 500) {
|
|
285
|
-
return new ShipError(ErrorType.Api, message, status);
|
|
284
|
+
static api(message, status = 500, details) {
|
|
285
|
+
return new ShipError(ErrorType.Api, message, status, details);
|
|
286
286
|
}
|
|
287
287
|
// Semantic-category type guards. For specific-type checks, use
|
|
288
288
|
// `error.type === ErrorType.X` directly or the generic `isType(t)`.
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -574,8 +574,8 @@ export class ShipError extends Error {
|
|
|
574
574
|
return new ShipError(ErrorType.Forbidden, message, 403, details);
|
|
575
575
|
}
|
|
576
576
|
|
|
577
|
-
static rateLimit(message: string = "Too many requests"): ShipError {
|
|
578
|
-
return new ShipError(ErrorType.RateLimit, message, 429);
|
|
577
|
+
static rateLimit(message: string = "Too many requests", details?: unknown): ShipError {
|
|
578
|
+
return new ShipError(ErrorType.RateLimit, message, 429, details);
|
|
579
579
|
}
|
|
580
580
|
|
|
581
581
|
/**
|
|
@@ -595,16 +595,16 @@ export class ShipError extends Error {
|
|
|
595
595
|
return new ShipError(ErrorType.Authentication, message, 401, details);
|
|
596
596
|
}
|
|
597
597
|
|
|
598
|
-
static business(message: string, status: number = 400): ShipError {
|
|
599
|
-
return new ShipError(ErrorType.Business, message, status);
|
|
598
|
+
static business(message: string, status: number = 400, details?: unknown): ShipError {
|
|
599
|
+
return new ShipError(ErrorType.Business, message, status, details);
|
|
600
600
|
}
|
|
601
601
|
|
|
602
602
|
static network(message: string, details?: unknown): ShipError {
|
|
603
603
|
return new ShipError(ErrorType.Network, message, undefined, details);
|
|
604
604
|
}
|
|
605
605
|
|
|
606
|
-
static cancelled(message: string): ShipError {
|
|
607
|
-
return new ShipError(ErrorType.Cancelled, message);
|
|
606
|
+
static cancelled(message: string, details?: unknown): ShipError {
|
|
607
|
+
return new ShipError(ErrorType.Cancelled, message, undefined, details);
|
|
608
608
|
}
|
|
609
609
|
|
|
610
610
|
static file(message: string, details?: unknown): ShipError {
|
|
@@ -615,8 +615,8 @@ export class ShipError extends Error {
|
|
|
615
615
|
return new ShipError(ErrorType.Config, message, undefined, details);
|
|
616
616
|
}
|
|
617
617
|
|
|
618
|
-
static api(message: string, status: number = 500): ShipError {
|
|
619
|
-
return new ShipError(ErrorType.Api, message, status);
|
|
618
|
+
static api(message: string, status: number = 500, details?: unknown): ShipError {
|
|
619
|
+
return new ShipError(ErrorType.Api, message, status, details);
|
|
620
620
|
}
|
|
621
621
|
|
|
622
622
|
// Semantic-category type guards. For specific-type checks, use
|