@webpieces/core-util 0.4.762 → 0.4.763

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.
Files changed (56) hide show
  1. package/README.md +2 -2
  2. package/package.json +1 -1
  3. package/src/errors/ApiError.d.ts +43 -49
  4. package/src/errors/ApiError.js +54 -59
  5. package/src/errors/ApiError.js.map +1 -1
  6. package/src/errors/ApiErrorCodec.d.ts +11 -6
  7. package/src/errors/ApiErrorCodec.js +93 -87
  8. package/src/errors/ApiErrorCodec.js.map +1 -1
  9. package/src/errors/AuthErrorSubtypes.d.ts +9 -0
  10. package/src/errors/AuthErrorSubtypes.js +13 -0
  11. package/src/errors/AuthErrorSubtypes.js.map +1 -0
  12. package/src/errors/index.d.ts +3 -1
  13. package/src/errors/index.js +24 -15
  14. package/src/errors/index.js.map +1 -1
  15. package/src/http/{TimeoutError.d.ts → ApiCallTimeoutError.d.ts} +1 -1
  16. package/src/http/{TimeoutError.js → ApiCallTimeoutError.js} +5 -5
  17. package/src/http/ApiCallTimeoutError.js.map +1 -0
  18. package/src/http/{HttpErrorStatus.d.ts → ApiErrorHttpStatus.d.ts} +2 -1
  19. package/src/http/ApiErrorHttpStatus.js +43 -0
  20. package/src/http/ApiErrorHttpStatus.js.map +1 -0
  21. package/src/http/CallDeadline.js +2 -2
  22. package/src/http/CallDeadline.js.map +1 -1
  23. package/src/http/ErrorTranslators.d.ts +5 -3
  24. package/src/http/ErrorTranslators.js.map +1 -1
  25. package/src/http/HttpResponseDto.d.ts +1 -1
  26. package/src/http/HttpResponseDto.js +2 -2
  27. package/src/http/HttpResponseDto.js.map +1 -1
  28. package/src/http/WebpiecesDefaultFailureClassifier.d.ts +6 -6
  29. package/src/http/WebpiecesDefaultFailureClassifier.js +12 -12
  30. package/src/http/WebpiecesDefaultFailureClassifier.js.map +1 -1
  31. package/src/http/decorators.d.ts +1 -1
  32. package/src/http/decorators.js +1 -1
  33. package/src/http/decorators.js.map +1 -1
  34. package/src/http/networkReject.d.ts +2 -2
  35. package/src/http/networkReject.js +5 -5
  36. package/src/http/networkReject.js.map +1 -1
  37. package/src/index.d.ts +5 -4
  38. package/src/index.js +23 -38
  39. package/src/index.js.map +1 -1
  40. package/src/ipc/IpcConnection.js +14 -14
  41. package/src/ipc/IpcConnection.js.map +1 -1
  42. package/src/ipc/IpcDecorators.js +9 -9
  43. package/src/ipc/IpcDecorators.js.map +1 -1
  44. package/src/ipc/IpcIdentity.js +1 -1
  45. package/src/ipc/IpcIdentity.js.map +1 -1
  46. package/src/ipc/IpcProtocol.js +5 -5
  47. package/src/ipc/IpcProtocol.js.map +1 -1
  48. package/src/ipc/index.d.ts +1 -1
  49. package/src/ipc/index.js +3 -3
  50. package/src/ipc/index.js.map +1 -1
  51. package/src/http/HttpErrorStatus.js +0 -38
  52. package/src/http/HttpErrorStatus.js.map +0 -1
  53. package/src/http/TimeoutError.js.map +0 -1
  54. package/src/http/errors.d.ts +0 -56
  55. package/src/http/errors.js +0 -95
  56. package/src/http/errors.js.map +0 -1
package/README.md CHANGED
@@ -4,9 +4,9 @@ Utility functions for WebPieces applications. Works in both browser and Node.js
4
4
 
5
5
  ## Portable API errors and IPC
6
6
 
7
- React Native consumers use `@webpieces/core-util/errors` for canonical semantic errors (`UserError`, `NotFoundError`, and the other API categories) and `@webpieces/core-util/ipc` for shared contracts and connection types. These two subpaths are checked with public declaration fixtures, Metro Android/iOS bundles, and Hermes compilation; the broad root barrel is not certified for React Native.
7
+ React Native consumers use `@webpieces/core-util/errors` for canonical semantic errors (`ApiEndUserError`, `ApiNotFoundError`, and the other API categories) and `@webpieces/core-util/ipc` for shared contracts and connection types. These two subpaths are checked with public declaration fixtures, Metro Android/iOS bundles, and Hermes compilation; the broad root barrel is not certified for React Native.
8
8
 
9
- Use `@webpieces/ipc-bridge` for generated clients and typed receivers. HTTP preserves status 266 for `UserError`: monitoring succeeds, while generated clients throw it for GUI display. Old Http-prefixed names are deprecated aliases; neutral errors use standard `cause` and have no HTTP `.code`. See [the migration and verification guide](https://github.com/deanhiller/webpieces-ts/blob/main/docs/portable-ipc-and-errors.md).
9
+ Use `@webpieces/ipc-bridge` for generated clients and typed receivers. HTTP preserves status 266 for `ApiEndUserError`: monitoring succeeds, while generated clients throw it for GUI display. All API errors are transport-neutral, use standard `cause`, and have no HTTP `.code`. See [the taxonomy and verification guide](https://github.com/deanhiller/webpieces-ts/blob/main/docs/portable-ipc-and-errors.md).
10
10
 
11
11
  ## Installation
12
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/core-util",
3
- "version": "0.4.762",
3
+ "version": "0.4.763",
4
4
  "description": "Utility functions for WebPieces - works in browser and Node.js",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -1,70 +1,64 @@
1
- /** Portable semantic failures. HTTP status mapping belongs to the HTTP adapter. */
2
- export declare class ApiError extends Error {
3
- readonly kind: string;
1
+ export type ApiErrorKind = 'end-user' | 'bad-request' | 'unauthorized' | 'forbidden' | 'not-found' | 'endpoint-not-found' | 'request-timeout' | 'rate-limited' | 'implementation' | 'dependency' | 'unavailable' | 'dependency-timeout' | 'dependency-backoff' | 'connection';
2
+ /** Category for portable API failures. Concrete subclasses alone define protocol mappings. */
3
+ export declare abstract class ApiError extends Error {
4
+ abstract readonly kind: ApiErrorKind;
4
5
  subType?: string;
5
6
  constructor(message: string, cause?: Error);
6
7
  }
7
- /** NotFound failure, independent of transport. */
8
- export declare class NotFoundError extends ApiError {
9
- readonly kind: string;
8
+ export declare class ApiNotFoundError extends ApiError {
9
+ readonly kind: ApiErrorKind;
10
10
  }
11
- /** BadGateway failure, independent of transport. */
12
- export declare class BadGatewayError extends ApiError {
13
- readonly kind: string;
11
+ export declare class ApiDependencyError extends ApiError {
12
+ readonly kind: "dependency";
14
13
  }
15
- /** ServiceUnavailable failure, independent of transport. */
16
- export declare class ServiceUnavailableError extends ApiError {
17
- readonly kind: string;
14
+ export declare class ApiUnavailableError extends ApiError {
15
+ readonly kind: "unavailable";
18
16
  }
19
- /** GatewayTimeout failure, independent of transport. */
20
- export declare class GatewayTimeoutError extends ApiError {
21
- readonly kind: string;
17
+ export declare class ApiDependencyTimeoutError extends ApiError {
18
+ readonly kind: "dependency-timeout";
22
19
  }
23
- /** Internal failure, independent of transport. */
24
- export declare class InternalError extends ApiError {
25
- readonly kind: string;
20
+ /** A bug or invalid implementation state. Local errors become server errors only after a remote decode. */
21
+ export declare class ApiImplementationError extends ApiError {
22
+ readonly serverError: boolean;
23
+ readonly kind: "implementation";
24
+ constructor(message: string, cause?: Error, serverError?: boolean);
26
25
  }
27
- /** TooManyRequests failure, independent of transport. */
28
- export declare class TooManyRequestsError extends ApiError {
29
- readonly kind: string;
26
+ export declare class ApiRateLimitedError extends ApiError {
27
+ readonly kind: "rate-limited";
30
28
  }
31
- /** Forbidden failure, independent of transport. */
32
- export declare class ForbiddenError extends ApiError {
33
- readonly kind: string;
29
+ export declare class ApiForbiddenError extends ApiError {
30
+ readonly kind: "forbidden";
34
31
  }
35
- /** RequestTimeout failure, independent of transport. */
36
- export declare class RequestTimeoutError extends ApiError {
37
- readonly kind: string;
32
+ export declare class ApiRequestTimeoutError extends ApiError {
33
+ readonly kind: "request-timeout";
38
34
  }
39
- /** Offline failure, independent of transport. */
40
- export declare class OfflineError extends ApiError {
41
- readonly kind: string;
35
+ /** A caller-local connection failure. HTTP servers normalize this to ApiImplementationError. */
36
+ export declare class ApiConnectionError extends ApiError {
37
+ readonly kind: "connection";
42
38
  }
43
- /** The API endpoint is missing, distinct from an absent domain entity. */
44
- export declare class EndpointNotFoundError extends NotFoundError {
45
- readonly kind: string;
39
+ /** The API operation is missing, distinct from an absent domain entity. */
40
+ export declare class ApiEndpointNotFoundError extends ApiNotFoundError {
41
+ readonly kind: "endpoint-not-found";
46
42
  }
47
- /** Expected user mistake: successful protocol/monitoring outcome; GUI catches this error. */
48
- export declare class UserError extends ApiError {
43
+ /** Expected end-user mistake. Its message is deliberately caller-safe. */
44
+ export declare class ApiEndUserError extends ApiError {
49
45
  errorCode?: string | undefined;
50
- readonly kind: string;
46
+ readonly kind: "end-user";
51
47
  constructor(message: string, errorCode?: string | undefined, cause?: Error);
52
48
  }
53
- /** Invalid caller input with optional human-safe field feedback. */
54
- export declare class BadRequestError extends ApiError {
49
+ /** Invalid API caller input. message is diagnostic; callerMessage is safe to publish. */
50
+ export declare class ApiBadRequestError extends ApiError {
55
51
  field?: string | undefined;
56
- guiMessage?: string | undefined;
57
- readonly kind: string;
58
- constructor(message: string, field?: string | undefined, guiMessage?: string | undefined, cause?: Error);
52
+ callerMessage?: string | undefined;
53
+ readonly kind: "bad-request";
54
+ constructor(message: string, field?: string | undefined, callerMessage?: string | undefined, cause?: Error);
59
55
  }
60
- /** Authentication failure with a contract-defined reason. */
61
- export declare class UnauthorizedError extends ApiError {
62
- readonly kind: string;
56
+ export declare class ApiUnauthorizedError extends ApiError {
57
+ readonly kind: "unauthorized";
63
58
  constructor(message: string, subType?: string, cause?: Error);
64
59
  }
65
- /** Dependency failure with bounded retry advice. */
66
- export declare class VendorError extends ApiError {
67
- waitSeconds: number;
68
- readonly kind: string;
69
- constructor(message: string, waitSeconds?: number, cause?: Error);
60
+ export declare class ApiDependencyBackoffError extends ApiError {
61
+ retryAfterSeconds: number;
62
+ readonly kind: "dependency-backoff";
63
+ constructor(message: string, retryAfterSeconds?: number, cause?: Error);
70
64
  }
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VendorError = exports.UnauthorizedError = exports.BadRequestError = exports.UserError = exports.EndpointNotFoundError = exports.OfflineError = exports.RequestTimeoutError = exports.ForbiddenError = exports.TooManyRequestsError = exports.InternalError = exports.GatewayTimeoutError = exports.ServiceUnavailableError = exports.BadGatewayError = exports.NotFoundError = exports.ApiError = void 0;
4
- /** Portable semantic failures. HTTP status mapping belongs to the HTTP adapter. */
3
+ exports.ApiDependencyBackoffError = exports.ApiUnauthorizedError = exports.ApiBadRequestError = exports.ApiEndUserError = exports.ApiEndpointNotFoundError = exports.ApiConnectionError = exports.ApiRequestTimeoutError = exports.ApiForbiddenError = exports.ApiRateLimitedError = exports.ApiImplementationError = exports.ApiDependencyTimeoutError = exports.ApiUnavailableError = exports.ApiDependencyError = exports.ApiNotFoundError = exports.ApiError = void 0;
4
+ /** Category for portable API failures. Concrete subclasses alone define protocol mappings. */
5
5
  class ApiError extends Error {
6
- kind = 'internal';
7
6
  subType;
8
7
  constructor(message, cause) {
9
8
  super(message, { cause });
@@ -11,96 +10,92 @@ class ApiError extends Error {
11
10
  }
12
11
  }
13
12
  exports.ApiError = ApiError;
14
- /** NotFound failure, independent of transport. */
15
- class NotFoundError extends ApiError {
13
+ class ApiNotFoundError extends ApiError {
16
14
  kind = 'not-found';
17
15
  }
18
- exports.NotFoundError = NotFoundError;
19
- /** BadGateway failure, independent of transport. */
20
- class BadGatewayError extends ApiError {
21
- kind = 'bad-gateway';
16
+ exports.ApiNotFoundError = ApiNotFoundError;
17
+ class ApiDependencyError extends ApiError {
18
+ kind = 'dependency';
22
19
  }
23
- exports.BadGatewayError = BadGatewayError;
24
- /** ServiceUnavailable failure, independent of transport. */
25
- class ServiceUnavailableError extends ApiError {
26
- kind = 'service-unavailable';
20
+ exports.ApiDependencyError = ApiDependencyError;
21
+ class ApiUnavailableError extends ApiError {
22
+ kind = 'unavailable';
27
23
  }
28
- exports.ServiceUnavailableError = ServiceUnavailableError;
29
- /** GatewayTimeout failure, independent of transport. */
30
- class GatewayTimeoutError extends ApiError {
31
- kind = 'gateway-timeout';
24
+ exports.ApiUnavailableError = ApiUnavailableError;
25
+ class ApiDependencyTimeoutError extends ApiError {
26
+ kind = 'dependency-timeout';
32
27
  }
33
- exports.GatewayTimeoutError = GatewayTimeoutError;
34
- /** Internal failure, independent of transport. */
35
- class InternalError extends ApiError {
36
- kind = 'internal';
28
+ exports.ApiDependencyTimeoutError = ApiDependencyTimeoutError;
29
+ /** A bug or invalid implementation state. Local errors become server errors only after a remote decode. */
30
+ class ApiImplementationError extends ApiError {
31
+ serverError;
32
+ kind = 'implementation';
33
+ constructor(message, cause, serverError = false) {
34
+ super(message, cause);
35
+ this.serverError = serverError;
36
+ }
37
37
  }
38
- exports.InternalError = InternalError;
39
- /** TooManyRequests failure, independent of transport. */
40
- class TooManyRequestsError extends ApiError {
41
- kind = 'too-many-requests';
38
+ exports.ApiImplementationError = ApiImplementationError;
39
+ class ApiRateLimitedError extends ApiError {
40
+ kind = 'rate-limited';
42
41
  }
43
- exports.TooManyRequestsError = TooManyRequestsError;
44
- /** Forbidden failure, independent of transport. */
45
- class ForbiddenError extends ApiError {
42
+ exports.ApiRateLimitedError = ApiRateLimitedError;
43
+ class ApiForbiddenError extends ApiError {
46
44
  kind = 'forbidden';
47
45
  }
48
- exports.ForbiddenError = ForbiddenError;
49
- /** RequestTimeout failure, independent of transport. */
50
- class RequestTimeoutError extends ApiError {
46
+ exports.ApiForbiddenError = ApiForbiddenError;
47
+ class ApiRequestTimeoutError extends ApiError {
51
48
  kind = 'request-timeout';
52
49
  }
53
- exports.RequestTimeoutError = RequestTimeoutError;
54
- /** Offline failure, independent of transport. */
55
- class OfflineError extends ApiError {
56
- kind = 'offline';
50
+ exports.ApiRequestTimeoutError = ApiRequestTimeoutError;
51
+ /** A caller-local connection failure. HTTP servers normalize this to ApiImplementationError. */
52
+ class ApiConnectionError extends ApiError {
53
+ kind = 'connection';
57
54
  }
58
- exports.OfflineError = OfflineError;
59
- /** The API endpoint is missing, distinct from an absent domain entity. */
60
- class EndpointNotFoundError extends NotFoundError {
55
+ exports.ApiConnectionError = ApiConnectionError;
56
+ /** The API operation is missing, distinct from an absent domain entity. */
57
+ class ApiEndpointNotFoundError extends ApiNotFoundError {
61
58
  kind = 'endpoint-not-found';
62
59
  }
63
- exports.EndpointNotFoundError = EndpointNotFoundError;
64
- /** Expected user mistake: successful protocol/monitoring outcome; GUI catches this error. */
65
- class UserError extends ApiError {
60
+ exports.ApiEndpointNotFoundError = ApiEndpointNotFoundError;
61
+ /** Expected end-user mistake. Its message is deliberately caller-safe. */
62
+ class ApiEndUserError extends ApiError {
66
63
  errorCode;
67
- kind = 'user';
64
+ kind = 'end-user';
68
65
  constructor(message, errorCode, cause) {
69
66
  super(message, cause);
70
67
  this.errorCode = errorCode;
71
68
  this.subType = 'USER_ERROR';
72
69
  }
73
70
  }
74
- exports.UserError = UserError;
75
- /** Invalid caller input with optional human-safe field feedback. */
76
- class BadRequestError extends ApiError {
71
+ exports.ApiEndUserError = ApiEndUserError;
72
+ /** Invalid API caller input. message is diagnostic; callerMessage is safe to publish. */
73
+ class ApiBadRequestError extends ApiError {
77
74
  field;
78
- guiMessage;
75
+ callerMessage;
79
76
  kind = 'bad-request';
80
- constructor(message, field, guiMessage, cause) {
77
+ constructor(message, field, callerMessage, cause) {
81
78
  super(message, cause);
82
79
  this.field = field;
83
- this.guiMessage = guiMessage;
80
+ this.callerMessage = callerMessage;
84
81
  }
85
82
  }
86
- exports.BadRequestError = BadRequestError;
87
- /** Authentication failure with a contract-defined reason. */
88
- class UnauthorizedError extends ApiError {
83
+ exports.ApiBadRequestError = ApiBadRequestError;
84
+ class ApiUnauthorizedError extends ApiError {
89
85
  kind = 'unauthorized';
90
86
  constructor(message, subType, cause) {
91
87
  super(message, cause);
92
88
  this.subType = subType;
93
89
  }
94
90
  }
95
- exports.UnauthorizedError = UnauthorizedError;
96
- /** Dependency failure with bounded retry advice. */
97
- class VendorError extends ApiError {
98
- waitSeconds;
99
- kind = 'vendor';
100
- constructor(message, waitSeconds = 30, cause) {
91
+ exports.ApiUnauthorizedError = ApiUnauthorizedError;
92
+ class ApiDependencyBackoffError extends ApiError {
93
+ retryAfterSeconds;
94
+ kind = 'dependency-backoff';
95
+ constructor(message, retryAfterSeconds = 30, cause) {
101
96
  super(message, cause);
102
- this.waitSeconds = waitSeconds;
97
+ this.retryAfterSeconds = retryAfterSeconds;
103
98
  }
104
99
  }
105
- exports.VendorError = VendorError;
100
+ exports.ApiDependencyBackoffError = ApiDependencyBackoffError;
106
101
  //# sourceMappingURL=ApiError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ApiError.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/errors/ApiError.ts"],"names":[],"mappings":";;;AAAA,mFAAmF;AACnF,MAAa,QAAS,SAAQ,KAAK;IACtB,IAAI,GAAW,UAAU,CAAC;IAC5B,OAAO,CAAU;IACxB,YAAY,OAAe,EAAE,KAAa;QACtC,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAChC,CAAC;CACJ;AAPD,4BAOC;AAED,kDAAkD;AAClD,MAAa,aAAc,SAAQ,QAAQ;IAAqB,IAAI,GAAW,WAAW,CAAC;CAAE;AAA7F,sCAA6F;AAE7F,oDAAoD;AACpD,MAAa,eAAgB,SAAQ,QAAQ;IAAqB,IAAI,GAAW,aAAa,CAAC;CAAE;AAAjG,0CAAiG;AAEjG,4DAA4D;AAC5D,MAAa,uBAAwB,SAAQ,QAAQ;IAAqB,IAAI,GAAW,qBAAqB,CAAC;CAAE;AAAjH,0DAAiH;AAEjH,wDAAwD;AACxD,MAAa,mBAAoB,SAAQ,QAAQ;IAAqB,IAAI,GAAW,iBAAiB,CAAC;CAAE;AAAzG,kDAAyG;AAEzG,kDAAkD;AAClD,MAAa,aAAc,SAAQ,QAAQ;IAAqB,IAAI,GAAW,UAAU,CAAC;CAAE;AAA5F,sCAA4F;AAE5F,yDAAyD;AACzD,MAAa,oBAAqB,SAAQ,QAAQ;IAAqB,IAAI,GAAW,mBAAmB,CAAC;CAAE;AAA5G,oDAA4G;AAE5G,mDAAmD;AACnD,MAAa,cAAe,SAAQ,QAAQ;IAAqB,IAAI,GAAW,WAAW,CAAC;CAAE;AAA9F,wCAA8F;AAE9F,wDAAwD;AACxD,MAAa,mBAAoB,SAAQ,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EAAE,KAAK,CAAC,CAAC;QADU,gBAAW,GAAX,WAAW,CAAK;IAEpD,CAAC;CACJ;AALD,kCAKC","sourcesContent":["/** Portable semantic failures. HTTP status mapping belongs to the HTTP adapter. */\nexport class ApiError extends Error {\n readonly kind: string = 'internal';\n public subType?: string;\n constructor(message: string, cause?: Error) {\n super(message, { cause });\n this.name = new.target.name;\n }\n}\n\n/** NotFound failure, independent of transport. */\nexport class NotFoundError extends ApiError { override readonly kind: string = 'not-found'; }\n\n/** BadGateway failure, independent of transport. */\nexport class BadGatewayError extends ApiError { override readonly kind: string = 'bad-gateway'; }\n\n/** ServiceUnavailable failure, independent of transport. */\nexport class ServiceUnavailableError extends ApiError { override readonly kind: string = 'service-unavailable'; }\n\n/** GatewayTimeout failure, independent of transport. */\nexport class GatewayTimeoutError extends ApiError { override readonly kind: string = 'gateway-timeout'; }\n\n/** Internal failure, independent of transport. */\nexport class InternalError extends ApiError { override readonly kind: string = 'internal'; }\n\n/** TooManyRequests failure, independent of transport. */\nexport class TooManyRequestsError extends ApiError { override readonly kind: string = 'too-many-requests'; }\n\n/** Forbidden failure, independent of transport. */\nexport class ForbiddenError extends ApiError { override readonly kind: string = 'forbidden'; }\n\n/** RequestTimeout failure, independent of transport. */\nexport class RequestTimeoutError extends ApiError { override readonly kind: string = 'request-timeout'; }\n\n/** Offline failure, independent of transport. */\nexport class OfflineError extends ApiError { override readonly kind: string = 'offline'; }\n\n/** The API endpoint is missing, distinct from an absent domain entity. */\nexport class EndpointNotFoundError extends NotFoundError { override readonly kind: string = 'endpoint-not-found'; }\n/** Expected user mistake: successful protocol/monitoring outcome; GUI catches this error. */\nexport class UserError extends ApiError {\n override readonly kind: string = 'user';\n constructor(message: string, public errorCode?: string, cause?: Error) {\n super(message, cause);\n this.subType = 'USER_ERROR';\n }\n}\n/** Invalid caller input with optional human-safe field feedback. */\nexport class BadRequestError extends ApiError {\n override readonly kind: string = 'bad-request';\n constructor(message: string, public field?: string, public guiMessage?: string, cause?: Error) {\n super(message, cause);\n }\n}\n/** Authentication failure with a contract-defined reason. */\nexport class UnauthorizedError extends ApiError {\n override readonly kind: string = 'unauthorized';\n constructor(message: string, subType?: string, cause?: Error) {\n super(message, cause);\n this.subType = subType;\n }\n}\n/** Dependency failure with bounded retry advice. */\nexport class VendorError extends ApiError {\n override readonly kind: string = 'vendor';\n constructor(message: string, public waitSeconds = 30, cause?: Error) {\n super(message, cause);\n }\n}\n"]}
1
+ {"version":3,"file":"ApiError.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/errors/ApiError.ts"],"names":[],"mappings":";;;AAgBA,8FAA8F;AAC9F,MAAsB,QAAS,SAAQ,KAAK;IAEjC,OAAO,CAAU;IAExB,YAAY,OAAe,EAAE,KAAa;QACtC,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAChC,CAAC;CACJ;AARD,4BAQC;AAED,MAAa,gBAAiB,SAAQ,QAAQ;IACxB,IAAI,GAAiB,WAAW,CAAC;CACtD;AAFD,4CAEC;AACD,MAAa,kBAAmB,SAAQ,QAAQ;IAC1B,IAAI,GAAG,YAAqB,CAAC;CAClD;AAFD,gDAEC;AACD,MAAa,mBAAoB,SAAQ,QAAQ;IAC3B,IAAI,GAAG,aAAsB,CAAC;CACnD;AAFD,kDAEC;AACD,MAAa,yBAA0B,SAAQ,QAAQ;IACjC,IAAI,GAAG,oBAA6B,CAAC;CAC1D;AAFD,8DAEC;AAED,2GAA2G;AAC3G,MAAa,sBAAuB,SAAQ,QAAQ;IAM5B;IALF,IAAI,GAAG,gBAAyB,CAAC;IAEnD,YACI,OAAe,EACf,KAAa,EACG,cAAc,KAAK;QAEnC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAFN,gBAAW,GAAX,WAAW,CAAQ;IAGvC,CAAC;CACJ;AAVD,wDAUC;AAED,MAAa,mBAAoB,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,oDAOC;AAED,MAAa,yBAA0B,SAAQ,QAAQ;IAKxC;IAJO,IAAI,GAAG,oBAA6B,CAAC;IAEvD,YACI,OAAe,EACR,oBAAoB,EAAE,EAC7B,KAAa;QAEb,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAHf,sBAAiB,GAAjB,iBAAiB,CAAK;IAIjC,CAAC;CACJ;AAVD,8DAUC","sourcesContent":["export type ApiErrorKind =\n | 'end-user'\n | 'bad-request'\n | 'unauthorized'\n | 'forbidden'\n | 'not-found'\n | 'endpoint-not-found'\n | 'request-timeout'\n | 'rate-limited'\n | 'implementation'\n | 'dependency'\n | 'unavailable'\n | 'dependency-timeout'\n | 'dependency-backoff'\n | 'connection';\n\n/** Category for portable API failures. Concrete subclasses alone define protocol mappings. */\nexport abstract class ApiError extends Error {\n abstract readonly kind: ApiErrorKind;\n public subType?: string;\n\n constructor(message: string, cause?: Error) {\n super(message, { cause });\n this.name = new.target.name;\n }\n}\n\nexport class ApiNotFoundError extends ApiError {\n override readonly kind: ApiErrorKind = 'not-found';\n}\nexport class ApiDependencyError extends ApiError {\n override readonly kind = 'dependency' as const;\n}\nexport class ApiUnavailableError extends ApiError {\n override readonly kind = 'unavailable' as const;\n}\nexport class ApiDependencyTimeoutError extends ApiError {\n override readonly kind = 'dependency-timeout' as const;\n}\n\n/** A bug or invalid implementation state. Local errors become server errors only after a remote decode. */\nexport class ApiImplementationError extends ApiError {\n override readonly kind = 'implementation' as const;\n\n constructor(\n message: string,\n cause?: Error,\n public readonly serverError = false,\n ) {\n super(message, cause);\n }\n}\n\nexport class ApiRateLimitedError extends ApiError {\n override readonly kind = 'rate-limited' as const;\n}\nexport class ApiForbiddenError extends ApiError {\n override readonly kind = 'forbidden' as const;\n}\nexport class ApiRequestTimeoutError extends ApiError {\n override readonly kind = 'request-timeout' as const;\n}\n\n/** A caller-local connection failure. HTTP servers normalize this to ApiImplementationError. */\nexport class ApiConnectionError extends ApiError {\n override readonly kind = 'connection' as const;\n}\n\n/** The API operation is missing, distinct from an absent domain entity. */\nexport class ApiEndpointNotFoundError extends ApiNotFoundError {\n override readonly kind = 'endpoint-not-found' as const;\n}\n\n/** Expected end-user mistake. Its message is deliberately caller-safe. */\nexport class ApiEndUserError extends ApiError {\n override readonly kind = 'end-user' as const;\n\n constructor(\n message: string,\n public errorCode?: string,\n cause?: Error,\n ) {\n super(message, cause);\n this.subType = 'USER_ERROR';\n }\n}\n\n/** Invalid API caller input. message is diagnostic; callerMessage is safe to publish. */\nexport class ApiBadRequestError extends ApiError {\n override readonly kind = 'bad-request' as const;\n\n constructor(\n message: string,\n public field?: string,\n public callerMessage?: string,\n cause?: Error,\n ) {\n super(message, cause);\n }\n}\n\nexport class ApiUnauthorizedError extends ApiError {\n override readonly kind = 'unauthorized' as const;\n\n constructor(message: string, subType?: string, cause?: Error) {\n super(message, cause);\n this.subType = subType;\n }\n}\n\nexport class ApiDependencyBackoffError extends ApiError {\n override readonly kind = 'dependency-backoff' as const;\n\n constructor(\n message: string,\n public retryAfterSeconds = 30,\n cause?: Error,\n ) {\n super(message, cause);\n }\n}\n"]}
@@ -1,25 +1,30 @@
1
1
  import { ApiError } from './ApiError';
2
- /** Allowlisted error envelope shared by non-HTTP transports. Contains only bounded semantic causes, never stacks or arbitrary properties. */
2
+ /** Allowlisted transport-neutral envelope. It never contains stacks or arbitrary properties. */
3
3
  export declare class ApiErrorPayload {
4
4
  kind: string;
5
5
  message: string;
6
6
  cause?: ApiErrorPayload;
7
7
  subType?: string;
8
8
  field?: string;
9
- guiAlertMessage?: string;
9
+ callerMessage?: string;
10
10
  errorCode?: string;
11
- waitSeconds?: number;
12
- constructor(kind: string, message: string);
11
+ retryAfterSeconds?: number;
12
+ constructor(kind?: string, message?: string);
13
13
  }
14
- /** Bounded, safe, transport-neutral encoding. Unrecognized types become generic internal failures. */
14
+ /** Bounded safe codec shared by HTTP, IPC, and other remote adapters. */
15
15
  export declare class ApiErrorCodec {
16
16
  static encode(error: unknown): ApiErrorPayload;
17
17
  private static encodeDepth;
18
+ /** Decode a value received from another process. Implementation failures are marked remote. */
18
19
  static decode(value: unknown): ApiError;
20
+ /** Whether a body carries a recognized Webpieces semantic discriminator. */
21
+ static isPayload(value: unknown): boolean;
19
22
  private static decodeDepth;
20
23
  private static decodeOne;
21
- private static kind;
24
+ private static remoteImplementationError;
25
+ private static publicMessage;
22
26
  private static text;
23
27
  private static wait;
24
28
  private static message;
29
+ private static readonly kinds;
25
30
  }