@nwire/errors 0.8.0 → 0.9.1
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/errors.d.ts +20 -15
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +29 -20
- package/dist/errors.js.map +1 -1
- package/package.json +5 -2
package/dist/errors.d.ts
CHANGED
|
@@ -1,31 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@nwire/errors` — typed domain errors.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* The canonical error definitions now live in `@nwire/handler` as
|
|
5
|
+
* `defineError(...)` singletons (`Unauthorized`, `Forbidden`, `NotFound`,
|
|
6
|
+
* `Conflict`, `Gone`, `BadRequest`). Transports detect them via
|
|
7
|
+
* `instanceof NwireError`.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* The class-shaped errors below extend `NwireError` so transports
|
|
10
|
+
* recognize them as the same kind. They are retained for compatibility
|
|
11
|
+
* with code written against `new NotFoundError(...)` style; new code
|
|
12
|
+
* should import the singletons from `@nwire/handler`.
|
|
10
13
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
import { NwireError } from "@nwire/handler";
|
|
15
|
+
export { defineError, NwireError, isNwireError, Unauthorized, Forbidden, NotFound, Conflict, Gone, BadRequest, } from "@nwire/handler";
|
|
16
|
+
/** @deprecated Use `NotFound({ resource, id })` from `@nwire/handler`. */
|
|
17
|
+
export declare class NotFoundError extends NwireError {
|
|
13
18
|
constructor(entity: string, id?: string);
|
|
14
19
|
}
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
/** @deprecated Use `defineError({ code: "VALIDATION_ERROR", status: 422, summary })` from `@nwire/handler`. */
|
|
21
|
+
export declare class ValidationError extends NwireError {
|
|
17
22
|
constructor(message: string);
|
|
18
23
|
}
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
/** @deprecated Use `Conflict({ ... })` from `@nwire/handler`. */
|
|
25
|
+
export declare class ConflictError extends NwireError {
|
|
21
26
|
constructor(message: string);
|
|
22
27
|
}
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
/** @deprecated Use `Forbidden({ ... })` from `@nwire/handler`. */
|
|
29
|
+
export declare class ForbiddenError extends NwireError {
|
|
25
30
|
constructor(message: string);
|
|
26
31
|
}
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
/** @deprecated Use `Unauthorized({ ... })` from `@nwire/handler`. */
|
|
33
|
+
export declare class UnauthorizedError extends NwireError {
|
|
29
34
|
constructor(message: string);
|
|
30
35
|
}
|
|
31
36
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EACL,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,UAAU,GACX,MAAM,gBAAgB,CAAC;AAExB,0EAA0E;AAC1E,qBAAa,aAAc,SAAQ,UAAU;gBAC/B,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM;CAWxC;AAED,+GAA+G;AAC/G,qBAAa,eAAgB,SAAQ,UAAU;gBACjC,OAAO,EAAE,MAAM;CAI5B;AAED,iEAAiE;AACjE,qBAAa,aAAc,SAAQ,UAAU;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAED,kEAAkE;AAClE,qBAAa,cAAe,SAAQ,UAAU;gBAChC,OAAO,EAAE,MAAM;CAI5B;AAED,qEAAqE;AACrE,qBAAa,iBAAkB,SAAQ,UAAU;gBACnC,OAAO,EAAE,MAAM;CAI5B"}
|
package/dist/errors.js
CHANGED
|
@@ -1,45 +1,54 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@nwire/errors` — typed domain errors.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* The canonical error definitions now live in `@nwire/handler` as
|
|
5
|
+
* `defineError(...)` singletons (`Unauthorized`, `Forbidden`, `NotFound`,
|
|
6
|
+
* `Conflict`, `Gone`, `BadRequest`). Transports detect them via
|
|
7
|
+
* `instanceof NwireError`.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* The class-shaped errors below extend `NwireError` so transports
|
|
10
|
+
* recognize them as the same kind. They are retained for compatibility
|
|
11
|
+
* with code written against `new NotFoundError(...)` style; new code
|
|
12
|
+
* should import the singletons from `@nwire/handler`.
|
|
10
13
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
import { NwireError } from "@nwire/handler";
|
|
15
|
+
export { defineError, NwireError, isNwireError, Unauthorized, Forbidden, NotFound, Conflict, Gone, BadRequest, } from "@nwire/handler";
|
|
16
|
+
/** @deprecated Use `NotFound({ resource, id })` from `@nwire/handler`. */
|
|
17
|
+
export class NotFoundError extends NwireError {
|
|
13
18
|
constructor(entity, id) {
|
|
14
|
-
super(
|
|
19
|
+
super({
|
|
20
|
+
code: "NOT_FOUND",
|
|
21
|
+
status: 404,
|
|
22
|
+
summary: id ? `${entity} not found: ${id}` : `${entity} not found`,
|
|
23
|
+
}, id ? { entity, id } : { entity });
|
|
15
24
|
this.name = "NotFoundError";
|
|
16
25
|
}
|
|
17
26
|
}
|
|
18
|
-
|
|
19
|
-
|
|
27
|
+
/** @deprecated Use `defineError({ code: "VALIDATION_ERROR", status: 422, summary })` from `@nwire/handler`. */
|
|
28
|
+
export class ValidationError extends NwireError {
|
|
20
29
|
constructor(message) {
|
|
21
|
-
super(message);
|
|
30
|
+
super({ code: "VALIDATION_ERROR", status: 422, summary: message });
|
|
22
31
|
this.name = "ValidationError";
|
|
23
32
|
}
|
|
24
33
|
}
|
|
25
|
-
|
|
26
|
-
|
|
34
|
+
/** @deprecated Use `Conflict({ ... })` from `@nwire/handler`. */
|
|
35
|
+
export class ConflictError extends NwireError {
|
|
27
36
|
constructor(message) {
|
|
28
|
-
super(message);
|
|
37
|
+
super({ code: "CONFLICT", status: 409, summary: message });
|
|
29
38
|
this.name = "ConflictError";
|
|
30
39
|
}
|
|
31
40
|
}
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
/** @deprecated Use `Forbidden({ ... })` from `@nwire/handler`. */
|
|
42
|
+
export class ForbiddenError extends NwireError {
|
|
34
43
|
constructor(message) {
|
|
35
|
-
super(message);
|
|
44
|
+
super({ code: "FORBIDDEN", status: 403, summary: message });
|
|
36
45
|
this.name = "ForbiddenError";
|
|
37
46
|
}
|
|
38
47
|
}
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
/** @deprecated Use `Unauthorized({ ... })` from `@nwire/handler`. */
|
|
49
|
+
export class UnauthorizedError extends NwireError {
|
|
41
50
|
constructor(message) {
|
|
42
|
-
super(message);
|
|
51
|
+
super({ code: "UNAUTHORIZED", status: 401, summary: message });
|
|
43
52
|
this.name = "UnauthorizedError";
|
|
44
53
|
}
|
|
45
54
|
}
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EACL,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,IAAI,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AQ,UAAU;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QAC/D,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nwire/errors",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.9.1",
|
|
4
|
+
"description": "Compatibility shim around @nwire/handler error definitions. New code should import the canonical singletons (Unauthorized, Forbidden, NotFound, Conflict, Gone, BadRequest) directly from @nwire/handler.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
"publishConfig": {
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@nwire/handler": "0.9.1"
|
|
25
|
+
},
|
|
23
26
|
"devDependencies": {
|
|
24
27
|
"@types/node": "^22.19.9",
|
|
25
28
|
"typescript": "^5.9.3"
|