@procedures/client 0.35.0 → 0.36.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/CHANGELOG.md +67 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/adapters/http/server/handler.d.ts.map +1 -1
- package/dist/adapters/http/server/handler.js +17 -3
- package/dist/adapters/http/server/handler.js.map +1 -1
- package/dist/adapters/port/transport.d.ts.map +1 -1
- package/dist/adapters/port/transport.js +2 -0
- package/dist/adapters/port/transport.js.map +1 -1
- package/dist/adapters/websocket/server/transport.d.ts.map +1 -1
- package/dist/adapters/websocket/server/transport.js +2 -0
- package/dist/adapters/websocket/server/transport.js.map +1 -1
- package/dist/adapters/websocket/shared/rpc.d.ts.map +1 -1
- package/dist/adapters/websocket/shared/rpc.js +14 -5
- package/dist/adapters/websocket/shared/rpc.js.map +1 -1
- package/dist/browser.d.ts +6 -4
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +4 -1
- package/dist/browser.js.map +1 -1
- package/dist/client/errors/index.d.ts +1 -1
- package/dist/client/errors/index.d.ts.map +1 -1
- package/dist/client/errors/index.js +1 -1
- package/dist/client/errors/index.js.map +1 -1
- package/dist/client/errors/registry.d.ts +10 -0
- package/dist/client/errors/registry.d.ts.map +1 -1
- package/dist/client/errors/registry.js +12 -0
- package/dist/client/errors/registry.js.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/events/bus.d.ts.map +1 -1
- package/dist/events/bus.js +5 -1
- package/dist/events/bus.js.map +1 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/publisher.d.ts +18 -2
- package/dist/events/publisher.d.ts.map +1 -1
- package/dist/events/publisher.js +142 -25
- package/dist/events/publisher.js.map +1 -1
- package/dist/events/recheck.d.ts +27 -5
- package/dist/events/recheck.d.ts.map +1 -1
- package/dist/events/recheck.js +11 -10
- package/dist/events/recheck.js.map +1 -1
- package/dist/procedures/collection/admission.d.ts +26 -7
- package/dist/procedures/collection/admission.d.ts.map +1 -1
- package/dist/procedures/collection/admission.js +39 -7
- package/dist/procedures/collection/admission.js.map +1 -1
- package/dist/procedures/collection/changes.d.ts +28 -4
- package/dist/procedures/collection/changes.d.ts.map +1 -1
- package/dist/procedures/collection/changes.js +50 -6
- package/dist/procedures/collection/changes.js.map +1 -1
- package/dist/procedures/collection/hint-filter.d.ts +143 -0
- package/dist/procedures/collection/hint-filter.d.ts.map +1 -0
- package/dist/procedures/collection/hint-filter.js +311 -0
- package/dist/procedures/collection/hint-filter.js.map +1 -0
- package/dist/procedures/collection/index.d.ts +2 -0
- package/dist/procedures/collection/index.d.ts.map +1 -1
- package/dist/procedures/collection/index.js +2 -0
- package/dist/procedures/collection/index.js.map +1 -1
- package/dist/procedures/collection/procedures.d.ts +2 -2
- package/dist/procedures/collection/procedures.d.ts.map +1 -1
- package/dist/procedures/collection/procedures.js +6 -4
- package/dist/procedures/collection/procedures.js.map +1 -1
- package/dist/procedures/index.d.ts +2 -2
- package/dist/procedures/index.d.ts.map +1 -1
- package/dist/procedures/index.js +3 -1
- package/dist/procedures/index.js.map +1 -1
- package/dist/server/error-policy.d.ts +96 -0
- package/dist/server/error-policy.d.ts.map +1 -0
- package/dist/server/error-policy.js +196 -0
- package/dist/server/error-policy.js.map +1 -0
- package/dist/server/error-response.d.ts +30 -0
- package/dist/server/error-response.d.ts.map +1 -0
- package/dist/server/error-response.js +90 -0
- package/dist/server/error-response.js.map +1 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/last-resort.d.ts +17 -0
- package/dist/server/last-resort.d.ts.map +1 -0
- package/dist/server/last-resort.js +19 -0
- package/dist/server/last-resort.js.map +1 -0
- package/dist/server/procedure-server.d.ts +3 -11
- package/dist/server/procedure-server.d.ts.map +1 -1
- package/dist/server/procedure-server.js +7 -42
- package/dist/server/procedure-server.js.map +1 -1
- package/dist/server/server.d.ts +43 -1
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +39 -2
- package/dist/server/server.js.map +1 -1
- package/dist/server/types.d.ts +12 -0
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/types.js.map +1 -1
- package/package.json +1 -1
- package/src/adapters/http/server/handler.ts +18 -3
- package/src/adapters/port/transport.ts +2 -0
- package/src/adapters/websocket/server/transport.ts +2 -0
- package/src/adapters/websocket/shared/rpc.ts +14 -5
- package/src/browser.ts +11 -0
- package/src/client/errors/index.ts +1 -0
- package/src/client/errors/registry.ts +13 -0
- package/src/client/index.ts +1 -0
- package/src/events/bus.ts +6 -1
- package/src/events/index.ts +1 -1
- package/src/events/publisher.ts +150 -26
- package/src/events/recheck.ts +38 -13
- package/src/procedures/collection/admission.ts +50 -9
- package/src/procedures/collection/changes.ts +68 -7
- package/src/procedures/collection/hint-filter.ts +376 -0
- package/src/procedures/collection/index.ts +3 -0
- package/src/procedures/collection/procedures.ts +8 -6
- package/src/procedures/index.ts +5 -0
- package/src/server/error-policy.ts +263 -0
- package/src/server/error-response.ts +91 -0
- package/src/server/index.ts +2 -0
- package/src/server/last-resort.ts +23 -0
- package/src/server/procedure-server.ts +8 -41
- package/src/server/server.ts +73 -3
- package/src/server/types.ts +13 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The error policy of a server (roadmap CLI-80): what an error tells the caller when it leaves
|
|
3
|
+
* the process.
|
|
4
|
+
*
|
|
5
|
+
* `Server.handle()` applies the policy to each response, so each face of the server (HTTP,
|
|
6
|
+
* WebSocket, MCP, a message port, the local face of a host) sends the same error. When
|
|
7
|
+
* `handle()` throws, or a face fails after it (for example, a value that JSON cannot encode), the
|
|
8
|
+
* last-resort catch of the face applies the same policy through `lastResortError`. A nested call
|
|
9
|
+
* of `ctx.client` does not go through `handle()`, so it keeps the real error.
|
|
10
|
+
*
|
|
11
|
+
* - `expose: "all"` (the default): each error goes to the caller as before.
|
|
12
|
+
* - `expose: "coded"`: an error with a known code (`isKnownErrorCode`, or a code of `codes`) goes
|
|
13
|
+
* to the caller as it is. Each other error goes to the caller as `INTERNAL_ERROR` with the
|
|
14
|
+
* message `"internal error"`, and the server logs it one time.
|
|
15
|
+
* - `map` runs first. Its result goes to the caller as it is. `undefined` gives the error to
|
|
16
|
+
* `expose`.
|
|
17
|
+
*
|
|
18
|
+
* The policy reads the real error of a response through the links of `error-response.ts`: the
|
|
19
|
+
* status object, and the request object with the code and the message of the status. A copy of
|
|
20
|
+
* the response or of its status keeps a link.
|
|
21
|
+
*/
|
|
22
|
+
import type { ProcedurePath } from "../procedures/types.js";
|
|
23
|
+
export { lastResortError } from "./last-resort.js";
|
|
24
|
+
import { type ServerRequest } from "./types.js";
|
|
25
|
+
/** The error that the caller gets: its code, its message and its retryable flag. A `ServerError` is one. */
|
|
26
|
+
export interface ExposedError {
|
|
27
|
+
/** The error code, for example `NOT_FOUND`, or a code of the application. */
|
|
28
|
+
readonly code: string;
|
|
29
|
+
/** The message that the caller gets. */
|
|
30
|
+
readonly message: string;
|
|
31
|
+
/**
|
|
32
|
+
* True when a retry of the same call can succeed. Without it, the error gets the flag of its
|
|
33
|
+
* code before the first item of a stream, and false after it (`retryableOf`).
|
|
34
|
+
*/
|
|
35
|
+
readonly retryable?: boolean | undefined;
|
|
36
|
+
/** The wait before a retry, in milliseconds, as on an error of a handler (`Retry-After` on HTTP). */
|
|
37
|
+
readonly retryAfterMs?: number | undefined;
|
|
38
|
+
}
|
|
39
|
+
/** The call of an error that leaves the server. */
|
|
40
|
+
export interface ErrorCall {
|
|
41
|
+
/** The path of the procedure. Empty when the face failed before it knew the call. */
|
|
42
|
+
readonly path: ProcedurePath;
|
|
43
|
+
/** The face that took the request (`http`, `websocket`, `port`, `mcp`), when the face tells it. */
|
|
44
|
+
readonly transport?: string | undefined;
|
|
45
|
+
}
|
|
46
|
+
/** The error policy of a server: the option `errors` (roadmap CLI-80). */
|
|
47
|
+
export interface ServerErrorPolicy {
|
|
48
|
+
/**
|
|
49
|
+
* Which errors go to the caller as they are:
|
|
50
|
+
* - `"all"` (the default): each error, with its code and its message, as before.
|
|
51
|
+
* - `"coded"`: only an error with a known code (`isKnownErrorCode`: `NOT_FOUND`, `FORBIDDEN`,
|
|
52
|
+
* `VALIDATION_ERROR`, `CONFLICT` and so on, or a code of `codes`), with its code, its
|
|
53
|
+
* message, its retryable flag and its metadata. Each other error goes to the caller as
|
|
54
|
+
* `INTERNAL_ERROR` with the message `"internal error"` and its real retryable flag, with
|
|
55
|
+
* only the metadata keys of `keepMetadata`. The codes `INTERNAL_ERROR`, `HANDLER_ERROR`, `UNKNOWN`,
|
|
56
|
+
* `OUTPUT_VALIDATION_ERROR` and `NO_OUTPUT` tell of a failure of the server, not of a
|
|
57
|
+
* refusal, so their message is hidden too. The server gives the real error to its `onError`
|
|
58
|
+
* logger one time, or to `console.error` without a logger.
|
|
59
|
+
*/
|
|
60
|
+
readonly expose?: "all" | "coded" | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* The codes of the application that also go to the caller as they are under `"coded"`, for
|
|
63
|
+
* example `["QUOTA_EXCEEDED"]`.
|
|
64
|
+
*/
|
|
65
|
+
readonly codes?: readonly string[] | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* The metadata keys that a hidden error response or a `map` result keeps from the response: an
|
|
68
|
+
* allowlist. Each other key goes, also a key that the server does not know (`issues`, a key of
|
|
69
|
+
* the application). The default is `DEFAULT_KEPT_METADATA`: the trace keys `traceparent` and
|
|
70
|
+
* `tracestate`.
|
|
71
|
+
*/
|
|
72
|
+
readonly keepMetadata?: readonly string[] | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* This function runs first, for each error that leaves the server. Its result goes to the
|
|
75
|
+
* caller as it is, also with a code of the application, and with the metadata of an error of a
|
|
76
|
+
* handler (`retryAfterMs`, the conflicts of a `VERSION_CONFLICT` error). `undefined` gives the
|
|
77
|
+
* error to `expose`. A function that throws gives `INTERNAL_ERROR`.
|
|
78
|
+
*/
|
|
79
|
+
readonly map?: ((error: unknown, call: ErrorCall) => ExposedError | undefined) | undefined;
|
|
80
|
+
}
|
|
81
|
+
/** The message of a hidden error. */
|
|
82
|
+
export declare const HIDDEN_ERROR_MESSAGE = "internal error";
|
|
83
|
+
/** The logger of the hidden errors: the hook `onError` of the server, or `console.error`. */
|
|
84
|
+
export type HiddenErrorLog = (error: unknown, request: ServerRequest<unknown> | undefined) => void;
|
|
85
|
+
/** True when the policy can change a response: `"coded"`, or a `map` function. */
|
|
86
|
+
export declare function policyActs(policy: ServerErrorPolicy | undefined): policy is ServerErrorPolicy;
|
|
87
|
+
/** The metadata keys that a hidden error response keeps by default: the trace keys (CLI-80). */
|
|
88
|
+
export declare const DEFAULT_KEPT_METADATA: readonly string[];
|
|
89
|
+
/**
|
|
90
|
+
* The error that a last-resort catch sends under a policy: when `handle()` throws, or when a face
|
|
91
|
+
* fails after it. `raw` is the error that the face sends without a policy. `map` runs first. Under
|
|
92
|
+
* `"coded"`, the code of `raw` decides, so `INTERNAL_ERROR` gives `"internal error"`, and the
|
|
93
|
+
* logger gets the real error one time.
|
|
94
|
+
*/
|
|
95
|
+
export declare function exposeError(policy: ServerErrorPolicy | undefined, error: unknown, call: ErrorCall, log: (error: unknown) => void, raw?: ExposedError): ExposedError;
|
|
96
|
+
//# sourceMappingURL=error-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-policy.d.ts","sourceRoot":"","sources":["../../src/server/error-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAO5D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAe,KAAK,aAAa,EAAuB,MAAM,YAAY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AAiB,GAAG,SAAS,GAAG,MAAM,IAAI,iBAAiB,CAE7F;AAmDD,gGAAgG;AAChG,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAAkC,CAAC;AAwEtF;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,EAAE,GAAG,GAAE,YAAgC,GAAG,YAAY,CAQtL"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The error policy of a server (roadmap CLI-80): what an error tells the caller when it leaves
|
|
3
|
+
* the process.
|
|
4
|
+
*
|
|
5
|
+
* `Server.handle()` applies the policy to each response, so each face of the server (HTTP,
|
|
6
|
+
* WebSocket, MCP, a message port, the local face of a host) sends the same error. When
|
|
7
|
+
* `handle()` throws, or a face fails after it (for example, a value that JSON cannot encode), the
|
|
8
|
+
* last-resort catch of the face applies the same policy through `lastResortError`. A nested call
|
|
9
|
+
* of `ctx.client` does not go through `handle()`, so it keeps the real error.
|
|
10
|
+
*
|
|
11
|
+
* - `expose: "all"` (the default): each error goes to the caller as before.
|
|
12
|
+
* - `expose: "coded"`: an error with a known code (`isKnownErrorCode`, or a code of `codes`) goes
|
|
13
|
+
* to the caller as it is. Each other error goes to the caller as `INTERNAL_ERROR` with the
|
|
14
|
+
* message `"internal error"`, and the server logs it one time.
|
|
15
|
+
* - `map` runs first. Its result goes to the caller as it is. `undefined` gives the error to
|
|
16
|
+
* `expose`.
|
|
17
|
+
*
|
|
18
|
+
* The policy reads the real error of a response through the links of `error-response.ts`: the
|
|
19
|
+
* status object, and the request object with the code and the message of the status. A copy of
|
|
20
|
+
* the response or of its status keeps a link.
|
|
21
|
+
*/
|
|
22
|
+
import { closableUnread } from "../procedures/invoke.js";
|
|
23
|
+
import { isKnownErrorCode } from "../client/errors/registry.js";
|
|
24
|
+
import { errorCodeOf } from "../protocol.js";
|
|
25
|
+
import { errorResponse, realErrorOf } from "./error-response.js";
|
|
26
|
+
import { methodToPath } from "./method.js";
|
|
27
|
+
import { rawErrorOf } from "./last-resort.js";
|
|
28
|
+
export { lastResortError } from "./last-resort.js";
|
|
29
|
+
import { ServerError } from "./types.js";
|
|
30
|
+
/** The message of a hidden error. */
|
|
31
|
+
export const HIDDEN_ERROR_MESSAGE = "internal error";
|
|
32
|
+
/** The codes that tell of a failure of the server, not of a refusal: `"coded"` hides their message. */
|
|
33
|
+
const FAILURE_CODES = new Set(["INTERNAL_ERROR", "HANDLER_ERROR", "UNKNOWN", "OUTPUT_VALIDATION_ERROR", "NO_OUTPUT"]);
|
|
34
|
+
/** The errors that a logger got: each path logs an error one time. */
|
|
35
|
+
const LOGGED = new WeakSet();
|
|
36
|
+
/**
|
|
37
|
+
* This function records that the logger of the server got this error, so the error policy does
|
|
38
|
+
* not log it again.
|
|
39
|
+
*
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
export function markLogged(error) {
|
|
43
|
+
if (typeof error === "object" && error !== null)
|
|
44
|
+
LOGGED.add(error);
|
|
45
|
+
}
|
|
46
|
+
/** This function gives an error to the logger, when the logger did not get it before. */
|
|
47
|
+
function logOnce(log, error, request) {
|
|
48
|
+
if (typeof error === "object" && error !== null && LOGGED.has(error))
|
|
49
|
+
return;
|
|
50
|
+
markLogged(error);
|
|
51
|
+
log(error, request);
|
|
52
|
+
}
|
|
53
|
+
/** True when the policy can change a response: `"coded"`, or a `map` function. */
|
|
54
|
+
export function policyActs(policy) {
|
|
55
|
+
return policy !== undefined && (policy.expose === "coded" || policy.map !== undefined);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The call of a request, for `map`.
|
|
59
|
+
*
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
|
+
export function callOf(request) {
|
|
63
|
+
if (request === undefined)
|
|
64
|
+
return { path: [] };
|
|
65
|
+
let path;
|
|
66
|
+
try {
|
|
67
|
+
path = methodToPath(request.method);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
path = [];
|
|
71
|
+
}
|
|
72
|
+
return request.transport !== undefined ? { path, transport: request.transport } : { path };
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The decision of the policy for one error. `code` is the code that the error has on the wire. A
|
|
76
|
+
* `map` result is final. `"coded"` keeps an error with a code of `codes`, or with a known code
|
|
77
|
+
* that is not a failure code.
|
|
78
|
+
*/
|
|
79
|
+
function decide(policy, error, code, call, logMapError) {
|
|
80
|
+
if (policy.map) {
|
|
81
|
+
let mapped;
|
|
82
|
+
try {
|
|
83
|
+
mapped = policy.map(error, call);
|
|
84
|
+
}
|
|
85
|
+
catch (mapError) {
|
|
86
|
+
logMapError(mapError);
|
|
87
|
+
return { kind: "hide" };
|
|
88
|
+
}
|
|
89
|
+
if (mapped !== undefined)
|
|
90
|
+
return { kind: "replace", error: mapped };
|
|
91
|
+
}
|
|
92
|
+
if (policy.expose !== "coded")
|
|
93
|
+
return { kind: "keep" };
|
|
94
|
+
if (policy.codes?.includes(code) === true)
|
|
95
|
+
return { kind: "keep" };
|
|
96
|
+
if (isKnownErrorCode(code) && !FAILURE_CODES.has(code))
|
|
97
|
+
return { kind: "keep" };
|
|
98
|
+
return { kind: "hide" };
|
|
99
|
+
}
|
|
100
|
+
/** A `map` result as an error: a result that is not an `Error` becomes one, with its fields. */
|
|
101
|
+
function errorOfResult(result) {
|
|
102
|
+
return result instanceof Error ? result : Object.assign(new Error(result.message), result);
|
|
103
|
+
}
|
|
104
|
+
/** The metadata keys that a hidden error response keeps by default: the trace keys (CLI-80). */
|
|
105
|
+
export const DEFAULT_KEPT_METADATA = ["traceparent", "tracestate"];
|
|
106
|
+
/** The metadata of a response with only the keys of the allowlist `keepMetadata` of the policy. */
|
|
107
|
+
function keptMetadata(policy, metadata) {
|
|
108
|
+
const keys = policy.keepMetadata ?? DEFAULT_KEPT_METADATA;
|
|
109
|
+
const kept = {};
|
|
110
|
+
for (const [key, value] of Object.entries(metadata ?? {}))
|
|
111
|
+
if (keys.includes(key))
|
|
112
|
+
kept[key] = value;
|
|
113
|
+
return kept;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* This function applies the error policy to a response that leaves the server: to an error
|
|
117
|
+
* status, and to the error that ends a stream.
|
|
118
|
+
*
|
|
119
|
+
* @internal
|
|
120
|
+
*/
|
|
121
|
+
export function exposedResponse(policy, request, response, log) {
|
|
122
|
+
const status = response.status;
|
|
123
|
+
if (status.type === "error") {
|
|
124
|
+
// A response that the server made without an error (a refusal of the token, a duplicate
|
|
125
|
+
// stream), or a status without the link, gives `map` a ServerError of its status
|
|
126
|
+
const link = realErrorOf(response, request);
|
|
127
|
+
const real = link.found ? link.error : new ServerError(status.message, status.code, status.retryable);
|
|
128
|
+
const decision = decide(policy, real, status.code, callOf(request), (mapError) => logOnce(log, mapError, request));
|
|
129
|
+
if (decision.kind === "keep")
|
|
130
|
+
return response;
|
|
131
|
+
const { stream: _stream, payload: _payload, ...rest } = response;
|
|
132
|
+
// Only the keys of the allowlist stay (the trace keys): an unknown key can tell of the error
|
|
133
|
+
const kept = keptMetadata(policy, response.metadata);
|
|
134
|
+
if (decision.kind === "replace") {
|
|
135
|
+
// The usual error response of the result: its wait and its conflicts go out too
|
|
136
|
+
const built = errorResponse(response.id, errorOfResult(decision.error));
|
|
137
|
+
return { ...rest, status: built.status, metadata: { ...kept, ...built.metadata } };
|
|
138
|
+
}
|
|
139
|
+
logOnce(log, real, request);
|
|
140
|
+
return {
|
|
141
|
+
...rest,
|
|
142
|
+
// The retryable flag tells nothing private: a transient failure stays retryable
|
|
143
|
+
status: { type: "error", code: "INTERNAL_ERROR", message: HIDDEN_ERROR_MESSAGE, retryable: status.retryable },
|
|
144
|
+
metadata: kept,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
if (response.stream === undefined)
|
|
148
|
+
return response;
|
|
149
|
+
return { ...response, stream: exposedStream(policy, request, response.stream, log) };
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* The items of a stream, with the error policy for the error that ends it. A kept error goes on
|
|
153
|
+
* unchanged. Another error goes on as an error of its exposed code and message.
|
|
154
|
+
*/
|
|
155
|
+
function exposedStream(policy, request, items, log) {
|
|
156
|
+
const exposed = (async function* () {
|
|
157
|
+
try {
|
|
158
|
+
yield* items;
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
const decision = decide(policy, error, errorCodeOf(error), callOf(request), (mapError) => logOnce(log, mapError, request));
|
|
162
|
+
if (decision.kind === "keep")
|
|
163
|
+
throw error;
|
|
164
|
+
if (decision.kind === "hide") {
|
|
165
|
+
logOnce(log, error, request);
|
|
166
|
+
// The real retryable flag of the error goes on. A last-resort catch that gets this error
|
|
167
|
+
// does not log it again.
|
|
168
|
+
const hidden = new ServerError(HIDDEN_ERROR_MESSAGE, "INTERNAL_ERROR", error?.retryable === true);
|
|
169
|
+
markLogged(hidden);
|
|
170
|
+
throw hidden;
|
|
171
|
+
}
|
|
172
|
+
// Without a flag, the face gives the flag of the code (before the first item) or false
|
|
173
|
+
throw errorOfResult(decision.error);
|
|
174
|
+
}
|
|
175
|
+
})();
|
|
176
|
+
return closableUnread(exposed, items);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* The error that a last-resort catch sends under a policy: when `handle()` throws, or when a face
|
|
180
|
+
* fails after it. `raw` is the error that the face sends without a policy. `map` runs first. Under
|
|
181
|
+
* `"coded"`, the code of `raw` decides, so `INTERNAL_ERROR` gives `"internal error"`, and the
|
|
182
|
+
* logger gets the real error one time.
|
|
183
|
+
*/
|
|
184
|
+
export function exposeError(policy, error, call, log, raw = rawErrorOf(error)) {
|
|
185
|
+
if (!policyActs(policy))
|
|
186
|
+
return raw;
|
|
187
|
+
const once = (logged) => log(logged);
|
|
188
|
+
const decision = decide(policy, error, raw.code, call, (mapError) => logOnce(once, mapError, undefined));
|
|
189
|
+
if (decision.kind === "keep")
|
|
190
|
+
return raw;
|
|
191
|
+
if (decision.kind === "replace")
|
|
192
|
+
return decision.error;
|
|
193
|
+
logOnce(once, error, undefined);
|
|
194
|
+
return { code: "INTERNAL_ERROR", message: HIDDEN_ERROR_MESSAGE, retryable: raw.retryable === true };
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=error-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-policy.js","sourceRoot":"","sources":["../../src/server/error-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,WAAW,EAA2C,MAAM,YAAY,CAAC;AA6DlF,qCAAqC;AACrC,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AAErD,uGAAuG;AACvG,MAAM,aAAa,GAAwB,IAAI,GAAG,CAAC,CAAC,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAAE,yBAAyB,EAAE,WAAW,CAAC,CAAC,CAAC;AAE3I,sEAAsE;AACtE,MAAM,MAAM,GAAG,IAAI,OAAO,EAAU,CAAC;AAErC;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,MAAM,CAAC,GAAG,CAAC,KA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AAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;AACtG,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The error response of the server, and the link from an error status to its real error (roadmap
|
|
3
|
+
* CLI-80).
|
|
4
|
+
*
|
|
5
|
+
* The error policy of a server (`error-policy.ts`) reads the real error of a response: the error
|
|
6
|
+
* object that a handler threw, of its own class. Two links lead to it, and neither is a field of
|
|
7
|
+
* the response, so the wire, a log of the response and a deep comparison never see them:
|
|
8
|
+
* - The status object of the error response. A copy of the response (`{ ...response, id }`) keeps
|
|
9
|
+
* the same status.
|
|
10
|
+
* - The request object of the call, with the code and the message of the status. A copy of the
|
|
11
|
+
* status (`{ ...response.status }`, for example in a middleware or a wrapper) keeps the code
|
|
12
|
+
* and the message, so the link holds. A status with another code or message is another error,
|
|
13
|
+
* and has no link.
|
|
14
|
+
* - Without a link (a middleware copied both the request and the status, or made a new error),
|
|
15
|
+
* the policy gives `map` a `ServerError` of the code, the message and the retryable flag of the
|
|
16
|
+
* status.
|
|
17
|
+
*/
|
|
18
|
+
import type { ServerResponse } from "./types.js";
|
|
19
|
+
/**
|
|
20
|
+
* The error response of a failed invocation. An invocation error keeps its code
|
|
21
|
+
* (VALIDATION_ERROR, NOT_EXPOSED, ABORTED and so on). An error of the handler keeps its own code
|
|
22
|
+
* when it is a string, as for a stream (`WIRE-PROTOCOL.md`). Without a code, it is HANDLER_ERROR.
|
|
23
|
+
* An error without a retryable flag gets the flag of its code in `ERROR_CODES`, or false (CLI-48).
|
|
24
|
+
* An in-band end before the first item of a stream gets the same default. After the first item,
|
|
25
|
+
* an in-band end without a flag gets false (`retryableOf`, CLI-58, CLI-68, `WIRE-PROTOCOL.md`,
|
|
26
|
+
* section "Error codes"). `request` is the request of the call: the link of the error policy to the
|
|
27
|
+
* real error (CLI-80).
|
|
28
|
+
*/
|
|
29
|
+
export declare function errorResponse(id: string, error: unknown, request?: object): ServerResponse<unknown>;
|
|
30
|
+
//# sourceMappingURL=error-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-response.d.ts","sourceRoot":"","sources":["../../src/server/error-response.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAkCjD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC,OAAO,CAAC,CAyBnG"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The error response of the server, and the link from an error status to its real error (roadmap
|
|
3
|
+
* CLI-80).
|
|
4
|
+
*
|
|
5
|
+
* The error policy of a server (`error-policy.ts`) reads the real error of a response: the error
|
|
6
|
+
* object that a handler threw, of its own class. Two links lead to it, and neither is a field of
|
|
7
|
+
* the response, so the wire, a log of the response and a deep comparison never see them:
|
|
8
|
+
* - The status object of the error response. A copy of the response (`{ ...response, id }`) keeps
|
|
9
|
+
* the same status.
|
|
10
|
+
* - The request object of the call, with the code and the message of the status. A copy of the
|
|
11
|
+
* status (`{ ...response.status }`, for example in a middleware or a wrapper) keeps the code
|
|
12
|
+
* and the message, so the link holds. A status with another code or message is another error,
|
|
13
|
+
* and has no link.
|
|
14
|
+
* - Without a link (a middleware copied both the request and the status, or made a new error),
|
|
15
|
+
* the policy gives `map` a `ServerError` of the code, the message and the retryable flag of the
|
|
16
|
+
* status.
|
|
17
|
+
*/
|
|
18
|
+
import { InvocationError } from "../procedures/invoke.js";
|
|
19
|
+
import { VERSION_CONFLICTS_METADATA_KEY, versionConflictsOf } from "../procedures/collection/precondition.js";
|
|
20
|
+
import { errorCodeOf, retryableOf } from "../protocol.js";
|
|
21
|
+
/** The real error of each error status that the server made from an error. */
|
|
22
|
+
const ERRORS_OF_STATUSES = new WeakMap();
|
|
23
|
+
/** The last real error of each request, with the code and the message of its status. */
|
|
24
|
+
const ERRORS_OF_REQUESTS = new WeakMap();
|
|
25
|
+
/**
|
|
26
|
+
* This function records the real error of an error response, for the error policy: by its status
|
|
27
|
+
* object, and by the request object of the call. The response does not change.
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export function withRealError(response, error, request) {
|
|
32
|
+
ERRORS_OF_STATUSES.set(response.status, error);
|
|
33
|
+
const status = response.status;
|
|
34
|
+
if (request !== undefined && status.type === "error")
|
|
35
|
+
ERRORS_OF_REQUESTS.set(request, { code: String(status.code), message: status.message, error });
|
|
36
|
+
return response;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The real error of an error status of a request, or `{ found: false }` when no link leads to it.
|
|
40
|
+
*
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
export function realErrorOf(response, request) {
|
|
44
|
+
const status = response.status;
|
|
45
|
+
if (ERRORS_OF_STATUSES.has(status))
|
|
46
|
+
return { found: true, error: ERRORS_OF_STATUSES.get(status) };
|
|
47
|
+
const recorded = request !== undefined ? ERRORS_OF_REQUESTS.get(request) : undefined;
|
|
48
|
+
if (recorded !== undefined && status.type === "error" && recorded.code === String(status.code) && recorded.message === status.message)
|
|
49
|
+
return { found: true, error: recorded.error };
|
|
50
|
+
return { found: false };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The error response of a failed invocation. An invocation error keeps its code
|
|
54
|
+
* (VALIDATION_ERROR, NOT_EXPOSED, ABORTED and so on). An error of the handler keeps its own code
|
|
55
|
+
* when it is a string, as for a stream (`WIRE-PROTOCOL.md`). Without a code, it is HANDLER_ERROR.
|
|
56
|
+
* An error without a retryable flag gets the flag of its code in `ERROR_CODES`, or false (CLI-48).
|
|
57
|
+
* An in-band end before the first item of a stream gets the same default. After the first item,
|
|
58
|
+
* an in-band end without a flag gets false (`retryableOf`, CLI-58, CLI-68, `WIRE-PROTOCOL.md`,
|
|
59
|
+
* section "Error codes"). `request` is the request of the call: the link of the error policy to the
|
|
60
|
+
* real error (CLI-80).
|
|
61
|
+
*/
|
|
62
|
+
export function errorResponse(id, error, request) {
|
|
63
|
+
// A refusal of the capability says why (CAPABILITIES-2026-10)
|
|
64
|
+
const reason = error instanceof InvocationError ? error.reason : undefined;
|
|
65
|
+
// An error can ask the client to wait before a retry: retryAfterMs, in milliseconds (R12)
|
|
66
|
+
const retryAfterMs = error?.retryAfterMs;
|
|
67
|
+
const metadata = reason ? { reason } : {};
|
|
68
|
+
if (typeof retryAfterMs === "number" && Number.isFinite(retryAfterMs) && retryAfterMs >= 0)
|
|
69
|
+
metadata["retry-after"] = retryAfterMs;
|
|
70
|
+
// A VERSION_CONFLICT error tells the current item of each conflict (roadmap CLI-16)
|
|
71
|
+
const conflicts = versionConflictsOf(error);
|
|
72
|
+
if (conflicts !== undefined)
|
|
73
|
+
metadata[VERSION_CONFLICTS_METADATA_KEY] = conflicts;
|
|
74
|
+
const code = errorCodeOf(error);
|
|
75
|
+
// The error policy of the server (CLI-80) reads the real error of the response
|
|
76
|
+
return withRealError({
|
|
77
|
+
id,
|
|
78
|
+
status: {
|
|
79
|
+
type: "error",
|
|
80
|
+
code,
|
|
81
|
+
message: error instanceof Error ? error.message : String(error),
|
|
82
|
+
// An error that says it is retryable stays retryable: before, every error lost the flag (deep
|
|
83
|
+
// dive TRN-7). Without a flag, the default of the code: UNAVAILABLE stays retryable, and
|
|
84
|
+
// keeps HTTP 503 (CLI-48). No item went out before this response.
|
|
85
|
+
retryable: retryableOf(error, 0),
|
|
86
|
+
},
|
|
87
|
+
metadata,
|
|
88
|
+
}, error, request);
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=error-response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-response.js","sourceRoot":"","sources":["../../src/server/error-response.ts"],"names":[],"mappings":"AAAA;;;;;;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CAAC,MAAM,CAAC,KAAK,CAAC;YAC/D,8FAA8F;YAC9F,yFAAyF;YACzF,kEAAkE;YAClE,SAAS,EAAE,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC;SACjC;QACD,QAAQ;KACT,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACrB,CAAC"}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -39,6 +39,8 @@
|
|
|
39
39
|
*/
|
|
40
40
|
export { Server } from "./server.js";
|
|
41
41
|
export type { ServerOptions } from "./server.js";
|
|
42
|
+
export type { ServerErrorPolicy, ExposedError, ErrorCall } from "./error-policy.js";
|
|
43
|
+
export { exposeError, lastResortError, HIDDEN_ERROR_MESSAGE, DEFAULT_KEPT_METADATA } from "./error-policy.js";
|
|
42
44
|
export { ProcedureServer, createProcedureServer, STREAM_METADATA_KEY, isUnboundedStream } from "./procedure-server.js";
|
|
43
45
|
export type { ProcedureServerOptions, RegisterProcedureOptions, StorageConfig, StopOptions, StopParts, StorageHandle, UseStorageOptions } from "./procedure-server.js";
|
|
44
46
|
export { pathToMethod, methodToPath, methodName } from "./method.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE9G,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACvH,YAAY,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACvK,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAErE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC3G,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,eAAe,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AACvG,YAAY,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC"}
|
package/dist/server/index.js
CHANGED
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
40
|
export { Server } from "./server.js";
|
|
41
|
+
export { exposeError, lastResortError, HIDDEN_ERROR_MESSAGE, DEFAULT_KEPT_METADATA } from "./error-policy.js";
|
|
41
42
|
export { ProcedureServer, createProcedureServer, STREAM_METADATA_KEY, isUnboundedStream } from "./procedure-server.js";
|
|
42
43
|
export { pathToMethod, methodToPath, methodName } from "./method.js";
|
|
43
44
|
// The escape of a segment with a dot, for a method name, a key and a topic (roadmap CLI-75)
|
package/dist/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAEvH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrE,4FAA4F;AAC5F,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC3G,OAAO,EACL,oBAAoB,EACpB,WAAW,GAiBZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE9G,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAEvH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrE,4FAA4F;AAC5F,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC3G,OAAO,EACL,oBAAoB,EACpB,WAAW,GAiBZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The last-resort catch of a face (roadmap CLI-80): when `handle()` throws, or the face fails after
|
|
3
|
+
* it. This module has no runtime import, so a face in a browser bundle (for example
|
|
4
|
+
* `PortTransport`) does not load the error policy and its imports. The policy itself runs in the
|
|
5
|
+
* server, through `RequestHandler.exposeError`.
|
|
6
|
+
*/
|
|
7
|
+
import type { ExposedError } from "./error-policy.js";
|
|
8
|
+
import type { RequestHandler, ServerRequest } from "./types.js";
|
|
9
|
+
/** The error that a last-resort catch sends without a policy: `INTERNAL_ERROR` with the message of the error. */
|
|
10
|
+
export declare function rawErrorOf(error: unknown): ExposedError;
|
|
11
|
+
/**
|
|
12
|
+
* The error that the last-resort catch of a face sends: the error policy of the handler
|
|
13
|
+
* (`RequestHandler.exposeError`, which `Server` has), or `raw` for a handler without one. `raw`
|
|
14
|
+
* is the error that the face sends without a policy.
|
|
15
|
+
*/
|
|
16
|
+
export declare function lastResortError(handler: RequestHandler, error: unknown, request: ServerRequest<unknown> | undefined, raw?: ExposedError): ExposedError;
|
|
17
|
+
//# sourceMappingURL=last-resort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"last-resort.d.ts","sourceRoot":"","sources":["../../src/server/last-resort.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhE,iHAAiH;AACjH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,SAAS,EAAE,GAAG,GAAE,YAAgC,GAAG,YAAY,CAEzK"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The last-resort catch of a face (roadmap CLI-80): when `handle()` throws, or the face fails after
|
|
3
|
+
* it. This module has no runtime import, so a face in a browser bundle (for example
|
|
4
|
+
* `PortTransport`) does not load the error policy and its imports. The policy itself runs in the
|
|
5
|
+
* server, through `RequestHandler.exposeError`.
|
|
6
|
+
*/
|
|
7
|
+
/** The error that a last-resort catch sends without a policy: `INTERNAL_ERROR` with the message of the error. */
|
|
8
|
+
export function rawErrorOf(error) {
|
|
9
|
+
return { code: "INTERNAL_ERROR", message: error instanceof Error ? error.message || "Internal server error" : String(error), retryable: false };
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The error that the last-resort catch of a face sends: the error policy of the handler
|
|
13
|
+
* (`RequestHandler.exposeError`, which `Server` has), or `raw` for a handler without one. `raw`
|
|
14
|
+
* is the error that the face sends without a policy.
|
|
15
|
+
*/
|
|
16
|
+
export function lastResortError(handler, error, request, raw = rawErrorOf(error)) {
|
|
17
|
+
return handler.exposeError ? handler.exposeError(error, request, raw) : raw;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=last-resort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"last-resort.js","sourceRoot":"","sources":["../../src/server/last-resort.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,iHAAiH;AACjH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,uBAAuB,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AAClJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,OAAuB,EAAE,KAAc,EAAE,OAA2C,EAAE,GAAG,GAAiB,UAAU,CAAC,KAAK,CAAC;IACzJ,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AAC9E,CAAC"}
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* Integrates with ProcedureRegistry and CollectionStorage backends.
|
|
6
6
|
*/
|
|
7
7
|
import { Server, type ServerOptions } from "./server.js";
|
|
8
|
-
import
|
|
8
|
+
import { errorResponse } from "./error-response.js";
|
|
9
|
+
export { errorResponse };
|
|
10
|
+
import type { Admission, AmbientCredentials, Credentials, Method, Principal, PrincipalOf, ServerHandler, ServerRequest } from "./types.js";
|
|
9
11
|
import type { AnyProcedure, ProcedurePath, RepositoryProvider, ProcedureModule } from "../procedures/types.js";
|
|
10
12
|
import { ProcedureRegistry } from "../procedures/registry.js";
|
|
11
13
|
import { type AdmitItem, type Interceptor, type Invocation } from "../procedures/invoke.js";
|
|
@@ -247,16 +249,6 @@ export interface StorageHandle {
|
|
|
247
249
|
/** This method closes the storage and removes its collections from the server. */
|
|
248
250
|
close(): Promise<void>;
|
|
249
251
|
}
|
|
250
|
-
/**
|
|
251
|
-
* The error response of a failed invocation. An invocation error keeps its code
|
|
252
|
-
* (VALIDATION_ERROR, NOT_EXPOSED, ABORTED and so on). An error of the handler keeps its own code
|
|
253
|
-
* when it is a string, as for a stream (`WIRE-PROTOCOL.md`). Without a code, it is HANDLER_ERROR.
|
|
254
|
-
* An error without a retryable flag gets the flag of its code in `ERROR_CODES`, or false (CLI-48).
|
|
255
|
-
* An in-band end before the first item of a stream gets the same default. After the first item,
|
|
256
|
-
* an in-band end without a flag gets false (`retryableOf`, CLI-58, CLI-68, `WIRE-PROTOCOL.md`,
|
|
257
|
-
* section "Error codes").
|
|
258
|
-
*/
|
|
259
|
-
export declare function errorResponse(id: string, error: unknown): ServerResponse<unknown>;
|
|
260
252
|
/**
|
|
261
253
|
* Server with procedure auto-registration and repository pattern.
|
|
262
254
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"procedure-server.d.ts","sourceRoot":"","sources":["../../src/server/procedure-server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAmB,aAAa,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"procedure-server.d.ts","sourceRoot":"","sources":["../../src/server/procedure-server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,CAAC;AACzB,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAmB,aAAa,EAAE,aAAa,EAAkB,MAAM,YAAY,CAAC;AAG5K,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,eAAe,EAChB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,iBAAiB,EAAsB,MAAM,2BAA2B,CAAC;AAElF,OAAO,EAAoD,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC9I,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,w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