@zyno-io/ts-server-foundation 26.802.804 → 26.802.1639
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/src/app/base.js +1 -1
- package/dist/src/devconsole/server.d.ts.map +1 -1
- package/dist/src/devconsole/server.js +1 -2
- package/dist/src/devconsole/server.js.map +1 -1
- package/dist/src/di/module.js +1 -1
- package/dist/src/http/request.js +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/services/mesh-client/mesh-srpc-server.js +1 -1
- package/dist/src/srpc/SrpcByteStream.d.ts +2 -0
- package/dist/src/srpc/SrpcByteStream.d.ts.map +1 -1
- package/dist/src/srpc/SrpcByteStream.js +19 -0
- package/dist/src/srpc/SrpcByteStream.js.map +1 -1
- package/dist/src/srpc/SrpcClient.d.ts +4 -1
- package/dist/src/srpc/SrpcClient.d.ts.map +1 -1
- package/dist/src/srpc/SrpcClient.js +202 -76
- package/dist/src/srpc/SrpcClient.js.map +1 -1
- package/dist/src/srpc/SrpcServer.d.ts +5 -1
- package/dist/src/srpc/SrpcServer.d.ts.map +1 -1
- package/dist/src/srpc/SrpcServer.js +293 -139
- package/dist/src/srpc/SrpcServer.js.map +1 -1
- package/dist/src/srpc/index.js +1 -1
- package/dist/src/srpc/types.d.ts +13 -2
- package/dist/src/srpc/types.d.ts.map +1 -1
- package/dist/src/srpc/types.js +32 -1
- package/dist/src/srpc/types.js.map +1 -1
- package/docs/content/srpc.md +18 -6
- package/package.json +1 -1
package/dist/src/srpc/types.js
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.__tsfTypeAliases = exports.SrpcStreamClosedError = exports.SrpcBackpressureError = exports.SrpcMeshAuthenticationError = exports.SrpcMeshProtocolError = exports.SrpcIndeterminateDeliveryError = exports.SrpcOwnerUnavailableError = exports.SrpcStaleConnectionError = exports.SrpcClientNotFoundError = exports.SrpcError = void 0;
|
|
4
|
+
exports.isValidSrpcTrace = isValidSrpcTrace;
|
|
4
5
|
exports.serializeSrpcError = serializeSrpcError;
|
|
6
|
+
exports.srpcMessageTypes = srpcMessageTypes;
|
|
5
7
|
exports.isSrpcMessageHandlerClass = isSrpcMessageHandlerClass;
|
|
6
8
|
exports.encodeSrpcMessage = encodeSrpcMessage;
|
|
7
9
|
const tslib_1 = require("tslib");
|
|
8
10
|
const _a = tslib_1.__importStar(require("@zyno-io/ts-server-foundation/type-metadata-runtime"));
|
|
9
11
|
const __tsf_metadata_type = _a.createCompactMetadataRegistryV1("[1,[{\"kind\":6},{\"kind\":8},{\"kind\":2}]]", []);
|
|
12
|
+
const SrpcTraceIdPattern = /^[0-9a-f]{32}$/i;
|
|
13
|
+
const SrpcSpanIdPattern = /^[0-9a-f]{16}$/i;
|
|
14
|
+
/** Ensures untrusted envelope tracing data is safe to pass to OpenTelemetry. */
|
|
15
|
+
function isValidSrpcTrace(trace) {
|
|
16
|
+
return (trace != null &&
|
|
17
|
+
typeof trace.traceId === 'string' &&
|
|
18
|
+
SrpcTraceIdPattern.test(trace.traceId) &&
|
|
19
|
+
!/^0{32}$/i.test(trace.traceId) &&
|
|
20
|
+
typeof trace.spanId === 'string' &&
|
|
21
|
+
SrpcSpanIdPattern.test(trace.spanId) &&
|
|
22
|
+
!/^0{16}$/i.test(trace.spanId) &&
|
|
23
|
+
Number.isInteger(trace.traceFlags) &&
|
|
24
|
+
trace.traceFlags >= 0 &&
|
|
25
|
+
trace.traceFlags <= 0xff);
|
|
26
|
+
}
|
|
10
27
|
let _SrpcErrorMetadata_1;
|
|
11
28
|
class SrpcError extends Error {
|
|
12
29
|
isUserError;
|
|
@@ -30,6 +47,20 @@ function serializeSrpcError(error) {
|
|
|
30
47
|
...(userError === undefined ? {} : { userError })
|
|
31
48
|
};
|
|
32
49
|
}
|
|
50
|
+
const SrpcEnvelopeFields = new Set(['requestId', 'reply', 'error', 'userError', 'trace', 'pingPong', 'byteStreamOperation']);
|
|
51
|
+
/** Returns the application-level message fields carried by an sRPC envelope. */
|
|
52
|
+
function srpcMessageTypes(message) {
|
|
53
|
+
if (message.pingPong)
|
|
54
|
+
return ['pingPong'];
|
|
55
|
+
if (message.byteStreamOperation)
|
|
56
|
+
return ['byteStreamOperation'];
|
|
57
|
+
if (message.error !== undefined)
|
|
58
|
+
return ['error'];
|
|
59
|
+
const types = Object.entries(message)
|
|
60
|
+
.filter(([key, value]) => !SrpcEnvelopeFields.has(key) && value !== undefined)
|
|
61
|
+
.map(([key]) => key);
|
|
62
|
+
return types.length ? types : [message.reply ? 'reply' : 'unknown'];
|
|
63
|
+
}
|
|
33
64
|
let _SrpcClientNotFoundErrorMetadata_1;
|
|
34
65
|
class SrpcClientNotFoundError extends Error {
|
|
35
66
|
constructor(clientId) {
|
|
@@ -126,5 +157,5 @@ function encodeSrpcMessage(codec, message) {
|
|
|
126
157
|
const bytes = 'finish' in encoded ? encoded.finish() : encoded;
|
|
127
158
|
return Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes);
|
|
128
159
|
}
|
|
129
|
-
exports.__tsfTypeAliases = _a.decodeCompactMetadataV1("[1,{\"BaseMessage\":{\"kind\":18,\"typeName\":\"BaseMessage\",\"types\":[{\"kind\":20,\"name\":\"requestId\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"reply\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"error\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"userError\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"trace\",\"type\":{\"kind\":12,\"types\":[{\"kind\":18,\"types\":[{\"kind\":20,\"name\":\"traceId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"spanId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"traceFlags\",\"type\":{\"kind\":7},\"optional\":false}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"pingPong\",\"type\":{\"kind\":12,\"types\":[{\"kind\":17},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"byteStreamOperation\",\"type\":{\"kind\":12,\"types\":[{\"kind\":18,\"types\":[{\"kind\":20,\"name\":\"streamId\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"write\",\"type\":{\"kind\":12,\"types\":[{\"kind\":18,\"types\":[{\"kind\":20,\"name\":\"chunk\",\"type\":{\"kind\":16,\"typeName\":\"Uint8Array\",\"classType\":{\"$tsf\":0}},\"optional\":false}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"finish\",\"type\":{\"kind\":12,\"types\":[{\"kind\":17},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"destroy\",\"type\":{\"kind\":12,\"types\":[{\"kind\":18,\"types\":[{\"kind\":20,\"name\":\"error\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true}]},{\"kind\":4}]},\"optional\":true}]},{\"kind\":4}]},\"optional\":true}]},\"IQueuedRequest\":{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]},\"ISrpcLogger\":{\"kind\":18,\"typeName\":\"ISrpcLogger\",\"types\":[]},\"ISrpcMessageHandler\":{\"kind\":18,\"typeName\":\"ISrpcMessageHandler\",\"types\":[{\"kind\":20,\"name\":\"handle\",\"type\":{\"kind\":2,\"typeName\":\"SrpcMessageHandlerFn\",\"typeArguments\":[{\"kind\":2,\"typeName\":\"C\"},{\"kind\":2,\"typeName\":\"I\"},{\"kind\":2,\"typeName\":\"O\"}]},\"optional\":false}],\"typeParameters\":[\"C\",\"I\",\"O\"]},\"ISrpcServerOptions\":{\"kind\":18,\"typeName\":\"ISrpcServerOptions\",\"types\":[{\"kind\":20,\"name\":\"logger\",\"type\":{\"kind\":18,\"typeName\":\"ISrpcLogger\",\"types\":[]},\"optional\":false},{\"kind\":20,\"name\":\"clientMessage\",\"type\":{\"kind\":18,\"typeName\":\"SrpcMessageFns\",\"types\":[]},\"optional\":false},{\"kind\":20,\"name\":\"serverMessage\",\"type\":{\"kind\":18,\"typeName\":\"SrpcMessageFns\",\"types\":[]},\"optional\":false},{\"kind\":20,\"name\":\"wsPath\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"defaultUnspecifiedProtocolVersion\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":1},{\"kind\":10,\"literal\":2}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"debug\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"logLevel\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"info\"},{\"kind\":10,\"literal\":\"debug\"},{\"kind\":10,\"literal\":false}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"httpServer\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"Server\",\"classType\":{\"$tsfImport\":[1,\"node:http\",\"Server\"]}},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"lateReplyTombstoneTtlMs\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxPendingClientRequests\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxPendingClientRequestBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxInFlightClientRequests\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxInFlightClientRequestBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxBufferedBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxMessageBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxPendingServerRequests\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxPendingServerRequestBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxPendingHandshakes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxActiveStreams\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxClientIdBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxClientMetadataBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxAuthReplayPrincipals\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"authAudience\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true}],\"typeParameters\":[\"TClientOutput\",\"TServerOutput\"]},\"SrpcConnection\":{\"kind\":18,\"typeName\":\"SrpcConnection\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"readonly id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"readonly clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"readonly meta\",\"type\":{\"kind\":2,\"typeName\":\"T\"},\"optional\":false},{\"kind\":20,\"name\":\"readonly connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"readonly connected\",\"type\":{\"kind\":8},\"optional\":false}],\"typeParameters\":[\"T\"]},\"SrpcDisconnectCause\":{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"disconnect\"},{\"kind\":10,\"literal\":\"conflict\"},{\"kind\":10,\"literal\":\"supersede\"},{\"kind\":10,\"literal\":\"timeout\"},{\"kind\":10,\"literal\":\"badArg\"}],\"typeName\":\"SrpcDisconnectCause\"},\"SrpcMessageFns\":{\"kind\":18,\"typeName\":\"SrpcMessageFns\",\"types\":[],\"typeParameters\":[\"T\"]},\"SrpcMeta\":{\"kind\":17,\"typeName\":\"SrpcMeta\"},\"SrpcStream\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":2}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":1},{\"kind\":10,\"literal\":2}]},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":4},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":2,\"typeName\":\"T\"},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}],\"typeParameters\":[\"T\"]}}]", [() => (typeof Uint8Array !== "undefined" ? Uint8Array : (typeof exports !== "undefined" ? exports.Uint8Array : undefined)), require, () => (typeof WebSocket !== "undefined" ? WebSocket : (typeof exports !== "undefined" ? exports.WebSocket : undefined)), () => (typeof Map !== "undefined" ? Map : (typeof exports !== "undefined" ? exports.Map : undefined)), () => (typeof ReadonlySet !== "undefined" ? ReadonlySet : (typeof exports !== "undefined" ? exports.ReadonlySet : undefined))], __tsf_metadata_type);
|
|
160
|
+
exports.__tsfTypeAliases = _a.decodeCompactMetadataV1("[1,{\"BaseMessage\":{\"kind\":18,\"typeName\":\"BaseMessage\",\"types\":[{\"kind\":20,\"name\":\"requestId\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"reply\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"error\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"userError\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"trace\",\"type\":{\"kind\":12,\"types\":[{\"kind\":18,\"types\":[{\"kind\":20,\"name\":\"traceId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"spanId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"traceFlags\",\"type\":{\"kind\":7},\"optional\":false}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"pingPong\",\"type\":{\"kind\":12,\"types\":[{\"kind\":17},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"byteStreamOperation\",\"type\":{\"kind\":12,\"types\":[{\"kind\":18,\"types\":[{\"kind\":20,\"name\":\"streamId\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"write\",\"type\":{\"kind\":12,\"types\":[{\"kind\":18,\"types\":[{\"kind\":20,\"name\":\"chunk\",\"type\":{\"kind\":16,\"typeName\":\"Uint8Array\",\"classType\":{\"$tsf\":0}},\"optional\":false}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"finish\",\"type\":{\"kind\":12,\"types\":[{\"kind\":17},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"destroy\",\"type\":{\"kind\":12,\"types\":[{\"kind\":18,\"types\":[{\"kind\":20,\"name\":\"error\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true}]},{\"kind\":4}]},\"optional\":true}]},{\"kind\":4}]},\"optional\":true}]},\"IQueuedRequest\":{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]},\"ISrpcLogger\":{\"kind\":18,\"typeName\":\"ISrpcLogger\",\"types\":[]},\"ISrpcMessageHandler\":{\"kind\":18,\"typeName\":\"ISrpcMessageHandler\",\"types\":[{\"kind\":20,\"name\":\"handle\",\"type\":{\"kind\":2,\"typeName\":\"SrpcMessageHandlerFn\",\"typeArguments\":[{\"kind\":2,\"typeName\":\"C\"},{\"kind\":2,\"typeName\":\"I\"},{\"kind\":2,\"typeName\":\"O\"}]},\"optional\":false}],\"typeParameters\":[\"C\",\"I\",\"O\"]},\"ISrpcServerOptions\":{\"kind\":18,\"typeName\":\"ISrpcServerOptions\",\"types\":[{\"kind\":20,\"name\":\"logger\",\"type\":{\"kind\":18,\"typeName\":\"ISrpcLogger\",\"types\":[]},\"optional\":false},{\"kind\":20,\"name\":\"clientMessage\",\"type\":{\"kind\":18,\"typeName\":\"SrpcMessageFns\",\"types\":[]},\"optional\":false},{\"kind\":20,\"name\":\"serverMessage\",\"type\":{\"kind\":18,\"typeName\":\"SrpcMessageFns\",\"types\":[]},\"optional\":false},{\"kind\":20,\"name\":\"wsPath\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"defaultUnspecifiedProtocolVersion\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":1},{\"kind\":10,\"literal\":2}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"logTraffic\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":18,\"typeName\":\"SrpcTrafficLoggingOptions\",\"types\":[{\"kind\":20,\"name\":\"bodies\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true}]}],\"typeName\":\"SrpcTrafficLogging\"},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"httpServer\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"Server\",\"classType\":{\"$tsfImport\":[1,\"node:http\",\"Server\"]}},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"lateReplyTombstoneTtlMs\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxPendingClientRequests\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxPendingClientRequestBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxInFlightClientRequests\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxInFlightClientRequestBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxBufferedBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxMessageBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxPendingServerRequests\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxPendingServerRequestBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxPendingHandshakes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxActiveStreams\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxClientIdBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxClientMetadataBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxAuthReplayPrincipals\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"authAudience\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true}],\"typeParameters\":[\"TClientOutput\",\"TServerOutput\"]},\"SrpcConnection\":{\"kind\":18,\"typeName\":\"SrpcConnection\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"readonly id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"readonly clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"readonly meta\",\"type\":{\"kind\":2,\"typeName\":\"T\"},\"optional\":false},{\"kind\":20,\"name\":\"readonly connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"readonly connected\",\"type\":{\"kind\":8},\"optional\":false}],\"typeParameters\":[\"T\"]},\"SrpcDisconnectCause\":{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"disconnect\"},{\"kind\":10,\"literal\":\"conflict\"},{\"kind\":10,\"literal\":\"supersede\"},{\"kind\":10,\"literal\":\"timeout\"},{\"kind\":10,\"literal\":\"badArg\"}],\"typeName\":\"SrpcDisconnectCause\"},\"SrpcMessageFns\":{\"kind\":18,\"typeName\":\"SrpcMessageFns\",\"types\":[],\"typeParameters\":[\"T\"]},\"SrpcMeta\":{\"kind\":17,\"typeName\":\"SrpcMeta\"},\"SrpcStream\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":2}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":1},{\"kind\":10,\"literal\":2}]},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":4},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":2,\"typeName\":\"T\"},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}],\"typeParameters\":[\"T\"]},\"SrpcTrafficLogging\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":18,\"typeName\":\"SrpcTrafficLoggingOptions\",\"types\":[{\"kind\":20,\"name\":\"bodies\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true}]}],\"typeName\":\"SrpcTrafficLogging\"},\"SrpcTrafficLoggingOptions\":{\"kind\":18,\"typeName\":\"SrpcTrafficLoggingOptions\",\"types\":[{\"kind\":20,\"name\":\"bodies\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true}]}}]", [() => (typeof Uint8Array !== "undefined" ? Uint8Array : (typeof exports !== "undefined" ? exports.Uint8Array : undefined)), require, () => (typeof WebSocket !== "undefined" ? WebSocket : (typeof exports !== "undefined" ? exports.WebSocket : undefined)), () => (typeof Map !== "undefined" ? Map : (typeof exports !== "undefined" ? exports.Map : undefined)), () => (typeof ReadonlySet !== "undefined" ? ReadonlySet : (typeof exports !== "undefined" ? exports.ReadonlySet : undefined))], __tsf_metadata_type);
|
|
130
161
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/srpc/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/srpc/types.ts"],"names":[],"mappings":";;;;;;;;;;;AAqCA,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AAC7C,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAE5C,gFAAgF;AAChF,0BAAiC,KAA2B;IACxD,OAAO,CACH,KAAK,IAAI,IAAI;QACb,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;QACjC,kB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,CAAC;IAC/D,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC"}
|
package/docs/content/srpc.md
CHANGED
|
@@ -130,8 +130,6 @@ Server options:
|
|
|
130
130
|
| `clientMessage` | Generated codec for client-to-server envelope messages. |
|
|
131
131
|
| `serverMessage` | Generated codec for server-to-client envelope messages. |
|
|
132
132
|
| `wsPath` | WebSocket path. |
|
|
133
|
-
| `debug` | Compatibility option; currently declared but not read. |
|
|
134
|
-
| `logLevel` | `info`, `debug`, or `false`. |
|
|
135
133
|
| `httpServer` | Optional Node HTTP server for direct upgrade registration. |
|
|
136
134
|
|
|
137
135
|
Handlers may also be zero-argument classes with a `handle(stream, data)` method. A new class instance is created for each request; SRPC does not resolve handler classes through application DI.
|
|
@@ -289,6 +287,24 @@ const stop = registerSrpcObserver(entry => {
|
|
|
289
287
|
|
|
290
288
|
Observers receive connection entries with `{ type, stream, at }`, disconnection entries with `{ type, stream, cause, at }`, and message entries with `{ type, stream, direction, data, at }`. Message direction is relative to the server. Ping, byte-stream, request, and reply envelopes are observable. Observer exceptions are isolated from SRPC behavior. Call the returned function to unregister the observer.
|
|
291
289
|
|
|
290
|
+
## Traffic Logging
|
|
291
|
+
|
|
292
|
+
Set `logTraffic: true` on an `SrpcServer` or `SrpcClient` to log every inbound and outbound envelope at info level with its direction and message type. To also log the decoded body, opt in explicitly:
|
|
293
|
+
|
|
294
|
+
```ts
|
|
295
|
+
logTraffic: {
|
|
296
|
+
bodies: true;
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Traffic bodies can contain application data, so enable body logging only where that data is appropriate for the configured log sink and retention policy.
|
|
301
|
+
|
|
302
|
+
## Observability
|
|
303
|
+
|
|
304
|
+
SRPC propagates the envelope `trace` context in both directions. Server and client invocation spans are named `srpc:invokeClient` and `srpc:invokeServer`; request handlers continue those traces as `srpc:handleClientRequest` and `srpc:handleServerRequest`.
|
|
305
|
+
|
|
306
|
+
Logs emitted while invoking or handling a request include an `srpc` context with the client and stream IDs, request ID, request type, and trace ID when present. Connection, handshake, protocol, and byte-stream diagnostics use the same structured identifiers without logging application payloads. Configure verbosity on the supplied logger, or use [Traffic Logging](#traffic-logging) when message bodies are appropriate for the log sink.
|
|
307
|
+
|
|
292
308
|
## Errors And Timeouts
|
|
293
309
|
|
|
294
310
|
Throw `new SrpcError(message, true)` from either a server handler or a
|
|
@@ -311,7 +327,3 @@ and byte-stream frames as well as inbound frames. A definitive WebSocket send
|
|
|
311
327
|
throw or callback error also revokes before closing. Normal graceful
|
|
312
328
|
disconnects retain their ordinary close-event semantics and carry the supplied
|
|
313
329
|
bounded close reason.
|
|
314
|
-
|
|
315
|
-
## Telemetry Boundary
|
|
316
|
-
|
|
317
|
-
The shared envelope reserves a `trace` object with `traceId`, `spanId`, and `traceFlags`, but the current SRPC client and server do not automatically populate, continue, or export spans from that field. Applications that need cross-SRPC trace propagation must place trace context in their message contract and wrap handlers with `withRemoteSpan()` explicitly. HTTP/WebSocket connection establishment can still be observed by the installed HTTP instrumentation.
|