@replit/river 0.207.1 → 0.207.3
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/adapter-f2b6e211.d.ts +46 -0
- package/dist/{chunk-7LMZNSVC.js → chunk-B7REV3ZV.js} +6 -5
- package/dist/{chunk-7LMZNSVC.js.map → chunk-B7REV3ZV.js.map} +1 -1
- package/dist/{chunk-QMAVXV4Z.js → chunk-BO7MFCO6.js} +1136 -132
- package/dist/chunk-BO7MFCO6.js.map +1 -0
- package/dist/{chunk-BCCZA7SX.js → chunk-QGPYCXV4.js} +2 -2
- package/dist/{chunk-BCCZA7SX.js.map → chunk-QGPYCXV4.js.map} +1 -1
- package/dist/codec/index.cjs +157 -23
- package/dist/codec/index.cjs.map +1 -1
- package/dist/codec/index.d.cts +5 -1
- package/dist/codec/index.d.ts +5 -1
- package/dist/codec/index.js +6 -20
- package/dist/codec/index.js.map +1 -1
- package/dist/{connection-933c87b2.d.ts → connection-06d72f2e.d.ts} +3 -2
- package/dist/index-02554794.d.ts +37 -0
- package/dist/logging/index.d.cts +2 -1
- package/dist/logging/index.d.ts +2 -1
- package/dist/{message-ffacb98a.d.ts → message-01c3e85a.d.ts} +1 -35
- package/dist/router/index.cjs +1 -1
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +6 -5
- package/dist/router/index.d.ts +6 -5
- package/dist/router/index.js +1 -1
- package/dist/{services-4cd29829.d.ts → services-87887bc5.d.ts} +16 -11
- package/dist/testUtil/index.cjs +992 -829
- package/dist/testUtil/index.cjs.map +1 -1
- package/dist/testUtil/index.d.cts +4 -3
- package/dist/testUtil/index.d.ts +4 -3
- package/dist/testUtil/index.js +18 -13
- package/dist/testUtil/index.js.map +1 -1
- package/dist/transport/impls/ws/client.cjs +293 -193
- package/dist/transport/impls/ws/client.cjs.map +1 -1
- package/dist/transport/impls/ws/client.d.cts +5 -4
- package/dist/transport/impls/ws/client.d.ts +5 -4
- package/dist/transport/impls/ws/client.js +5 -7
- package/dist/transport/impls/ws/client.js.map +1 -1
- package/dist/transport/impls/ws/server.cjs +230 -117
- package/dist/transport/impls/ws/server.cjs.map +1 -1
- package/dist/transport/impls/ws/server.d.cts +5 -4
- package/dist/transport/impls/ws/server.d.ts +5 -4
- package/dist/transport/impls/ws/server.js +5 -7
- package/dist/transport/impls/ws/server.js.map +1 -1
- package/dist/transport/index.cjs +408 -259
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.d.cts +7 -6
- package/dist/transport/index.d.ts +7 -6
- package/dist/transport/index.js +4 -9
- package/package.json +1 -1
- package/dist/chunk-AJGIY2UB.js +0 -56
- package/dist/chunk-AJGIY2UB.js.map +0 -1
- package/dist/chunk-CRD3HDVN.js +0 -438
- package/dist/chunk-CRD3HDVN.js.map +0 -1
- package/dist/chunk-I27WBSMZ.js +0 -377
- package/dist/chunk-I27WBSMZ.js.map +0 -1
- package/dist/chunk-QMAVXV4Z.js.map +0 -1
- package/dist/types-3e5768ec.d.ts +0 -20
package/dist/codec/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var codec_exports = {};
|
|
22
22
|
__export(codec_exports, {
|
|
23
23
|
BinaryCodec: () => BinaryCodec,
|
|
24
|
+
CodecMessageAdapter: () => CodecMessageAdapter,
|
|
24
25
|
NaiveJsonCodec: () => NaiveJsonCodec
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(codec_exports);
|
|
@@ -32,15 +33,11 @@ var BinaryCodec = {
|
|
|
32
33
|
return (0, import_msgpack.encode)(obj, { ignoreUndefined: true });
|
|
33
34
|
},
|
|
34
35
|
fromBuffer: (buff) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
return res;
|
|
41
|
-
} catch {
|
|
42
|
-
return null;
|
|
36
|
+
const res = (0, import_msgpack.decode)(buff);
|
|
37
|
+
if (typeof res !== "object" || res === null) {
|
|
38
|
+
throw new Error("unpacked msg is not an object");
|
|
43
39
|
}
|
|
40
|
+
return res;
|
|
44
41
|
}
|
|
45
42
|
};
|
|
46
43
|
|
|
@@ -76,28 +73,165 @@ var NaiveJsonCodec = {
|
|
|
76
73
|
);
|
|
77
74
|
},
|
|
78
75
|
fromBuffer: (buff) => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return val;
|
|
87
|
-
}
|
|
76
|
+
const parsed = JSON.parse(
|
|
77
|
+
decoder.decode(buff),
|
|
78
|
+
function reviver(_key, val) {
|
|
79
|
+
if (val?.$t) {
|
|
80
|
+
return base64ToUint8Array(val.$t);
|
|
81
|
+
} else {
|
|
82
|
+
return val;
|
|
88
83
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
87
|
+
throw new Error("unpacked msg is not an object");
|
|
88
|
+
}
|
|
89
|
+
return parsed;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// codec/adapter.ts
|
|
94
|
+
var import_value = require("@sinclair/typebox/value");
|
|
95
|
+
|
|
96
|
+
// transport/message.ts
|
|
97
|
+
var import_typebox = require("@sinclair/typebox");
|
|
98
|
+
var TransportMessageSchema = (t) => import_typebox.Type.Object({
|
|
99
|
+
id: import_typebox.Type.String(),
|
|
100
|
+
from: import_typebox.Type.String(),
|
|
101
|
+
to: import_typebox.Type.String(),
|
|
102
|
+
seq: import_typebox.Type.Integer(),
|
|
103
|
+
ack: import_typebox.Type.Integer(),
|
|
104
|
+
serviceName: import_typebox.Type.Optional(import_typebox.Type.String()),
|
|
105
|
+
procedureName: import_typebox.Type.Optional(import_typebox.Type.String()),
|
|
106
|
+
streamId: import_typebox.Type.String(),
|
|
107
|
+
controlFlags: import_typebox.Type.Integer(),
|
|
108
|
+
tracing: import_typebox.Type.Optional(
|
|
109
|
+
import_typebox.Type.Object({
|
|
110
|
+
traceparent: import_typebox.Type.String(),
|
|
111
|
+
tracestate: import_typebox.Type.String()
|
|
112
|
+
})
|
|
113
|
+
),
|
|
114
|
+
payload: t
|
|
115
|
+
});
|
|
116
|
+
var ControlMessageAckSchema = import_typebox.Type.Object({
|
|
117
|
+
type: import_typebox.Type.Literal("ACK")
|
|
118
|
+
});
|
|
119
|
+
var ControlMessageCloseSchema = import_typebox.Type.Object({
|
|
120
|
+
type: import_typebox.Type.Literal("CLOSE")
|
|
121
|
+
});
|
|
122
|
+
var ControlMessageHandshakeRequestSchema = import_typebox.Type.Object({
|
|
123
|
+
type: import_typebox.Type.Literal("HANDSHAKE_REQ"),
|
|
124
|
+
protocolVersion: import_typebox.Type.String(),
|
|
125
|
+
sessionId: import_typebox.Type.String(),
|
|
126
|
+
/**
|
|
127
|
+
* Specifies what the server's expected session state (from the pov of the client). This can be
|
|
128
|
+
* used by the server to know whether this is a new or a reestablished connection, and whether it
|
|
129
|
+
* is compatible with what it already has.
|
|
130
|
+
*/
|
|
131
|
+
expectedSessionState: import_typebox.Type.Object({
|
|
132
|
+
// what the client expects the server to send next
|
|
133
|
+
nextExpectedSeq: import_typebox.Type.Integer(),
|
|
134
|
+
nextSentSeq: import_typebox.Type.Integer()
|
|
135
|
+
}),
|
|
136
|
+
metadata: import_typebox.Type.Optional(import_typebox.Type.Unknown())
|
|
137
|
+
});
|
|
138
|
+
var HandshakeErrorRetriableResponseCodes = import_typebox.Type.Union([
|
|
139
|
+
import_typebox.Type.Literal("SESSION_STATE_MISMATCH")
|
|
140
|
+
]);
|
|
141
|
+
var HandshakeErrorCustomHandlerFatalResponseCodes = import_typebox.Type.Union([
|
|
142
|
+
// The custom validation handler rejected the handler because the client is unsupported.
|
|
143
|
+
import_typebox.Type.Literal("REJECTED_UNSUPPORTED_CLIENT"),
|
|
144
|
+
// The custom validation handler rejected the handshake.
|
|
145
|
+
import_typebox.Type.Literal("REJECTED_BY_CUSTOM_HANDLER")
|
|
146
|
+
]);
|
|
147
|
+
var HandshakeErrorFatalResponseCodes = import_typebox.Type.Union([
|
|
148
|
+
HandshakeErrorCustomHandlerFatalResponseCodes,
|
|
149
|
+
// The ciient sent a handshake that doesn't comply with the extended handshake metadata.
|
|
150
|
+
import_typebox.Type.Literal("MALFORMED_HANDSHAKE_META"),
|
|
151
|
+
// The ciient sent a handshake that doesn't comply with ControlMessageHandshakeRequestSchema.
|
|
152
|
+
import_typebox.Type.Literal("MALFORMED_HANDSHAKE"),
|
|
153
|
+
// The client's protocol version does not match the server's.
|
|
154
|
+
import_typebox.Type.Literal("PROTOCOL_VERSION_MISMATCH")
|
|
155
|
+
]);
|
|
156
|
+
var HandshakeErrorResponseCodes = import_typebox.Type.Union([
|
|
157
|
+
HandshakeErrorRetriableResponseCodes,
|
|
158
|
+
HandshakeErrorFatalResponseCodes
|
|
159
|
+
]);
|
|
160
|
+
var ControlMessageHandshakeResponseSchema = import_typebox.Type.Object({
|
|
161
|
+
type: import_typebox.Type.Literal("HANDSHAKE_RESP"),
|
|
162
|
+
status: import_typebox.Type.Union([
|
|
163
|
+
import_typebox.Type.Object({
|
|
164
|
+
ok: import_typebox.Type.Literal(true),
|
|
165
|
+
sessionId: import_typebox.Type.String()
|
|
166
|
+
}),
|
|
167
|
+
import_typebox.Type.Object({
|
|
168
|
+
ok: import_typebox.Type.Literal(false),
|
|
169
|
+
reason: import_typebox.Type.String(),
|
|
170
|
+
code: HandshakeErrorResponseCodes
|
|
171
|
+
})
|
|
172
|
+
])
|
|
173
|
+
});
|
|
174
|
+
var ControlMessagePayloadSchema = import_typebox.Type.Union([
|
|
175
|
+
ControlMessageCloseSchema,
|
|
176
|
+
ControlMessageAckSchema,
|
|
177
|
+
ControlMessageHandshakeRequestSchema,
|
|
178
|
+
ControlMessageHandshakeResponseSchema
|
|
179
|
+
]);
|
|
180
|
+
var OpaqueTransportMessageSchema = TransportMessageSchema(
|
|
181
|
+
import_typebox.Type.Unknown()
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
// transport/stringifyError.ts
|
|
185
|
+
function coerceErrorString(err) {
|
|
186
|
+
if (err instanceof Error) {
|
|
187
|
+
return err.message || "unknown reason";
|
|
188
|
+
}
|
|
189
|
+
return `[coerced to error] ${String(err)}`;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// codec/adapter.ts
|
|
193
|
+
var CodecMessageAdapter = class {
|
|
194
|
+
constructor(codec) {
|
|
195
|
+
this.codec = codec;
|
|
196
|
+
}
|
|
197
|
+
toBuffer(msg) {
|
|
198
|
+
try {
|
|
199
|
+
return {
|
|
200
|
+
ok: true,
|
|
201
|
+
value: this.codec.toBuffer(msg)
|
|
202
|
+
};
|
|
203
|
+
} catch (e) {
|
|
204
|
+
return {
|
|
205
|
+
ok: false,
|
|
206
|
+
reason: coerceErrorString(e)
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
fromBuffer(buf) {
|
|
211
|
+
try {
|
|
212
|
+
const parsedMsg = this.codec.fromBuffer(buf);
|
|
213
|
+
if (!import_value.Value.Check(OpaqueTransportMessageSchema, parsedMsg)) {
|
|
214
|
+
return {
|
|
215
|
+
ok: false,
|
|
216
|
+
reason: "transport message schema mismatch"
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
return {
|
|
220
|
+
ok: true,
|
|
221
|
+
value: parsedMsg
|
|
222
|
+
};
|
|
223
|
+
} catch (e) {
|
|
224
|
+
return {
|
|
225
|
+
ok: false,
|
|
226
|
+
reason: coerceErrorString(e)
|
|
227
|
+
};
|
|
95
228
|
}
|
|
96
229
|
}
|
|
97
230
|
};
|
|
98
231
|
// Annotate the CommonJS export names for ESM import in node:
|
|
99
232
|
0 && (module.exports = {
|
|
100
233
|
BinaryCodec,
|
|
234
|
+
CodecMessageAdapter,
|
|
101
235
|
NaiveJsonCodec
|
|
102
236
|
});
|
|
103
237
|
//# sourceMappingURL=index.cjs.map
|
package/dist/codec/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../codec/index.ts","../../codec/binary.ts","../../codec/json.ts"],"sourcesContent":["export { BinaryCodec } from './binary';\nexport { NaiveJsonCodec } from './json';\nexport type { Codec } from './types';\n","import { decode, encode } from '@msgpack/msgpack';\nimport { Codec } from './types';\n\n/**\n * Binary codec, uses [msgpack](https://www.npmjs.com/package/@msgpack/msgpack) under the hood\n * @type {Codec}\n */\nexport const BinaryCodec: Codec = {\n toBuffer(obj) {\n return encode(obj, { ignoreUndefined: true });\n },\n fromBuffer: (buff: Uint8Array) => {\n try {\n const res = decode(buff);\n if (typeof res !== 'object') {\n return null;\n }\n\n return res;\n } catch {\n return null;\n }\n },\n};\n","import { Codec } from './types';\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\n// Convert Uint8Array to base64\nfunction uint8ArrayToBase64(uint8Array: Uint8Array) {\n let binary = '';\n uint8Array.forEach((byte) => {\n binary += String.fromCharCode(byte);\n });\n\n return btoa(binary);\n}\n\n// Convert base64 to Uint8Array\nfunction base64ToUint8Array(base64: string) {\n const binaryString = atob(base64);\n const uint8Array = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n uint8Array[i] = binaryString.charCodeAt(i);\n }\n\n return uint8Array;\n}\n\ninterface Base64EncodedValue {\n $t: string;\n}\n\n/**\n * Naive JSON codec implementation using JSON.stringify and JSON.parse.\n * @type {Codec}\n */\nexport const NaiveJsonCodec: Codec = {\n toBuffer: (obj: object) => {\n return encoder.encode(\n JSON.stringify(obj, function replacer<\n T extends object,\n >(this: T, key: keyof T) {\n const val = this[key];\n if (val instanceof Uint8Array) {\n return { $t: uint8ArrayToBase64(val) } satisfies Base64EncodedValue;\n } else {\n return val;\n }\n }),\n );\n },\n fromBuffer: (buff: Uint8Array) => {\n try {\n const parsed = JSON.parse(\n decoder.decode(buff),\n function reviver(_key, val: unknown) {\n if ((val as Base64EncodedValue | undefined)?.$t) {\n return base64ToUint8Array((val as Base64EncodedValue).$t);\n } else {\n return val;\n }\n },\n ) as unknown;\n\n if (typeof parsed === 'object') return parsed;\n\n return null;\n } catch {\n return null;\n }\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,qBAA+B;AAOxB,IAAM,cAAqB;AAAA,EAChC,SAAS,KAAK;AACZ,eAAO,uBAAO,KAAK,EAAE,iBAAiB,KAAK,CAAC;AAAA,EAC9C;AAAA,EACA,YAAY,CAAC,SAAqB;AAChC,QAAI;AACF,YAAM,UAAM,uBAAO,IAAI;AACvB,UAAI,OAAO,QAAQ,UAAU;AAC3B,eAAO;AAAA,MACT;AAEA,aAAO;AAAA,IACT,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AACF;;;ACrBA,IAAM,UAAU,IAAI,YAAY;AAChC,IAAM,UAAU,IAAI,YAAY;AAGhC,SAAS,mBAAmB,YAAwB;AAClD,MAAI,SAAS;AACb,aAAW,QAAQ,CAAC,SAAS;AAC3B,cAAU,OAAO,aAAa,IAAI;AAAA,EACpC,CAAC;AAED,SAAO,KAAK,MAAM;AACpB;AAGA,SAAS,mBAAmB,QAAgB;AAC1C,QAAM,eAAe,KAAK,MAAM;AAChC,QAAM,aAAa,IAAI,WAAW,aAAa,MAAM;AACrD,WAAS,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK;AAC5C,eAAW,CAAC,IAAI,aAAa,WAAW,CAAC;AAAA,EAC3C;AAEA,SAAO;AACT;AAUO,IAAM,iBAAwB;AAAA,EACnC,UAAU,CAAC,QAAgB;AACzB,WAAO,QAAQ;AAAA,MACb,KAAK,UAAU,KAAK,SAAS,SAElB,KAAc;AACvB,cAAM,MAAM,KAAK,GAAG;AACpB,YAAI,eAAe,YAAY;AAC7B,iBAAO,EAAE,IAAI,mBAAmB,GAAG,EAAE;AAAA,QACvC,OAAO;AACL,iBAAO;AAAA,QACT;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EACA,YAAY,CAAC,SAAqB;AAChC,QAAI;AACF,YAAM,SAAS,KAAK;AAAA,QAClB,QAAQ,OAAO,IAAI;AAAA,QACnB,SAAS,QAAQ,MAAM,KAAc;AACnC,cAAK,KAAwC,IAAI;AAC/C,mBAAO,mBAAoB,IAA2B,EAAE;AAAA,UAC1D,OAAO;AACL,mBAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAEA,UAAI,OAAO,WAAW;AAAU,eAAO;AAEvC,aAAO;AAAA,IACT,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../codec/index.ts","../../codec/binary.ts","../../codec/json.ts","../../codec/adapter.ts","../../transport/message.ts","../../transport/stringifyError.ts"],"sourcesContent":["export { BinaryCodec } from './binary';\nexport { NaiveJsonCodec } from './json';\nexport type { Codec } from './types';\nexport { CodecMessageAdapter } from './adapter';\n","import { decode, encode } from '@msgpack/msgpack';\nimport { Codec } from './types';\n\n/**\n * Binary codec, uses [msgpack](https://www.npmjs.com/package/@msgpack/msgpack) under the hood\n * @type {Codec}\n */\nexport const BinaryCodec: Codec = {\n toBuffer(obj) {\n return encode(obj, { ignoreUndefined: true });\n },\n fromBuffer: (buff: Uint8Array) => {\n const res = decode(buff);\n if (typeof res !== 'object' || res === null) {\n throw new Error('unpacked msg is not an object');\n }\n\n return res;\n },\n};\n","import { Codec } from './types';\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\n// Convert Uint8Array to base64\nfunction uint8ArrayToBase64(uint8Array: Uint8Array) {\n let binary = '';\n uint8Array.forEach((byte) => {\n binary += String.fromCharCode(byte);\n });\n\n return btoa(binary);\n}\n\n// Convert base64 to Uint8Array\nfunction base64ToUint8Array(base64: string) {\n const binaryString = atob(base64);\n const uint8Array = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n uint8Array[i] = binaryString.charCodeAt(i);\n }\n\n return uint8Array;\n}\n\ninterface Base64EncodedValue {\n $t: string;\n}\n\n/**\n * Naive JSON codec implementation using JSON.stringify and JSON.parse.\n * @type {Codec}\n */\nexport const NaiveJsonCodec: Codec = {\n toBuffer: (obj: object) => {\n return encoder.encode(\n JSON.stringify(obj, function replacer<\n T extends object,\n >(this: T, key: keyof T) {\n const val = this[key];\n if (val instanceof Uint8Array) {\n return { $t: uint8ArrayToBase64(val) } satisfies Base64EncodedValue;\n } else {\n return val;\n }\n }),\n );\n },\n fromBuffer: (buff: Uint8Array) => {\n const parsed = JSON.parse(\n decoder.decode(buff),\n function reviver(_key, val: unknown) {\n if ((val as Base64EncodedValue | undefined)?.$t) {\n return base64ToUint8Array((val as Base64EncodedValue).$t);\n } else {\n return val;\n }\n },\n ) as unknown;\n\n if (typeof parsed !== 'object' || parsed === null) {\n throw new Error('unpacked msg is not an object');\n }\n\n return parsed;\n },\n};\n","import { Value } from '@sinclair/typebox/value';\nimport {\n OpaqueTransportMessage,\n OpaqueTransportMessageSchema,\n} from '../transport';\nimport { Codec } from './types';\nimport { DeserializeResult, SerializeResult } from '../transport/results';\nimport { coerceErrorString } from '../transport/stringifyError';\n\n/**\n * Adapts a {@link Codec} to the {@link OpaqueTransportMessage} format,\n * accounting for fallibility of toBuffer and fromBuffer and wrapping\n * it with a Result type.\n */\nexport class CodecMessageAdapter {\n constructor(private readonly codec: Codec) {}\n\n toBuffer(msg: OpaqueTransportMessage): SerializeResult {\n try {\n return {\n ok: true,\n value: this.codec.toBuffer(msg),\n };\n } catch (e) {\n return {\n ok: false,\n reason: coerceErrorString(e),\n };\n }\n }\n\n fromBuffer(buf: Uint8Array): DeserializeResult {\n try {\n const parsedMsg = this.codec.fromBuffer(buf);\n if (!Value.Check(OpaqueTransportMessageSchema, parsedMsg)) {\n return {\n ok: false,\n reason: 'transport message schema mismatch',\n };\n }\n\n return {\n ok: true,\n value: parsedMsg,\n };\n } catch (e) {\n return {\n ok: false,\n reason: coerceErrorString(e),\n };\n }\n }\n}\n","import { Type, TSchema, Static } from '@sinclair/typebox';\nimport { PropagationContext } from '../tracing';\nimport { generateId } from './id';\nimport { ErrResult, ReaderErrorSchema } from '../router';\n\n/**\n * Control flags for transport messages.\n */\nexport const enum ControlFlags {\n /**\n * Used in heartbeat messages.\n */\n AckBit = 0b00001,\n /**\n * Used in stream open requests.\n */\n StreamOpenBit = 0b00010,\n /**\n * Used when a stream is cancelled due errors or to explicit cancellation\n */\n StreamCancelBit = 0b00100,\n /**\n * Used when writer closes the stream.\n */\n StreamClosedBit = 0b01000,\n}\n\n/**\n * Generic Typebox schema for a transport message.\n * @template T The type of the payload.\n * @param {T} t The payload schema.\n * @returns The transport message schema.\n */\nexport const TransportMessageSchema = <T extends TSchema>(t: T) =>\n Type.Object({\n id: Type.String(),\n from: Type.String(),\n to: Type.String(),\n seq: Type.Integer(),\n ack: Type.Integer(),\n serviceName: Type.Optional(Type.String()),\n procedureName: Type.Optional(Type.String()),\n streamId: Type.String(),\n controlFlags: Type.Integer(),\n tracing: Type.Optional(\n Type.Object({\n traceparent: Type.String(),\n tracestate: Type.String(),\n }),\n ),\n payload: t,\n });\n\n/**\n * Defines the schema for a transport acknowledgement message. This is never constructed manually\n * and is only used internally by the library for tracking inflight messages.\n * @returns The transport message schema.\n */\nexport const ControlMessageAckSchema = Type.Object({\n type: Type.Literal('ACK'),\n});\n\n/**\n * Defines the schema for a transport close message. This is never constructed manually and is only\n * used internally by the library for closing and cleaning up streams.\n */\nexport const ControlMessageCloseSchema = Type.Object({\n type: Type.Literal('CLOSE'),\n});\n\nexport type ProtocolVersion = 'v1.1' | 'v2.0';\nexport const currentProtocolVersion = 'v2.0' satisfies ProtocolVersion;\nexport const acceptedProtocolVersions = ['v1.1', currentProtocolVersion];\nexport function isAcceptedProtocolVersion(\n version: string,\n): version is ProtocolVersion {\n return acceptedProtocolVersions.includes(version);\n}\n\nexport const ControlMessageHandshakeRequestSchema = Type.Object({\n type: Type.Literal('HANDSHAKE_REQ'),\n protocolVersion: Type.String(),\n sessionId: Type.String(),\n /**\n * Specifies what the server's expected session state (from the pov of the client). This can be\n * used by the server to know whether this is a new or a reestablished connection, and whether it\n * is compatible with what it already has.\n */\n expectedSessionState: Type.Object({\n // what the client expects the server to send next\n nextExpectedSeq: Type.Integer(),\n nextSentSeq: Type.Integer(),\n }),\n\n metadata: Type.Optional(Type.Unknown()),\n});\n\nexport const HandshakeErrorRetriableResponseCodes = Type.Union([\n Type.Literal('SESSION_STATE_MISMATCH'),\n]);\n\nexport const HandshakeErrorCustomHandlerFatalResponseCodes = Type.Union([\n // The custom validation handler rejected the handler because the client is unsupported.\n Type.Literal('REJECTED_UNSUPPORTED_CLIENT'),\n // The custom validation handler rejected the handshake.\n Type.Literal('REJECTED_BY_CUSTOM_HANDLER'),\n]);\n\nexport const HandshakeErrorFatalResponseCodes = Type.Union([\n HandshakeErrorCustomHandlerFatalResponseCodes,\n // The ciient sent a handshake that doesn't comply with the extended handshake metadata.\n Type.Literal('MALFORMED_HANDSHAKE_META'),\n // The ciient sent a handshake that doesn't comply with ControlMessageHandshakeRequestSchema.\n Type.Literal('MALFORMED_HANDSHAKE'),\n // The client's protocol version does not match the server's.\n Type.Literal('PROTOCOL_VERSION_MISMATCH'),\n]);\n\nexport const HandshakeErrorResponseCodes = Type.Union([\n HandshakeErrorRetriableResponseCodes,\n HandshakeErrorFatalResponseCodes,\n]);\n\nexport const ControlMessageHandshakeResponseSchema = Type.Object({\n type: Type.Literal('HANDSHAKE_RESP'),\n status: Type.Union([\n Type.Object({\n ok: Type.Literal(true),\n sessionId: Type.String(),\n }),\n Type.Object({\n ok: Type.Literal(false),\n reason: Type.String(),\n code: HandshakeErrorResponseCodes,\n }),\n ]),\n});\n\nexport const ControlMessagePayloadSchema = Type.Union([\n ControlMessageCloseSchema,\n ControlMessageAckSchema,\n ControlMessageHandshakeRequestSchema,\n ControlMessageHandshakeResponseSchema,\n]);\n\n/**\n * Defines the schema for an opaque transport message that is agnostic to any\n * procedure/service.\n * @returns The transport message schema.\n */\nexport const OpaqueTransportMessageSchema = TransportMessageSchema(\n Type.Unknown(),\n);\n\n/**\n * Represents a transport message. This is the same type as {@link TransportMessageSchema} but\n * we can't statically infer generics from generic Typebox schemas so we have to define it again here.\n *\n * TypeScript can't enforce types when a bitmask is involved, so these are the semantics of\n * `controlFlags`:\n * * If `controlFlags & StreamOpenBit == StreamOpenBit`, `streamId` must be set to a unique value\n * (suggestion: use `nanoid`).\n * * If `controlFlags & StreamOpenBit == StreamOpenBit`, `serviceName` and `procedureName` must be set.\n * * If `controlFlags & StreamClosedBit == StreamClosedBit` and the kind is `stream` or `subscription`,\n * `payload` should be discarded (usually contains a control message).\n * * If `controlFlags & AckBit == AckBit`, the message is an explicit acknowledgement message and doesn't\n * contain any payload that is relevant to the application so should not be delivered.\n * @template Payload The type of the payload.\n */\nexport interface TransportMessage<Payload = unknown> {\n id: string;\n from: TransportClientId;\n to: TransportClientId;\n seq: number;\n ack: number;\n serviceName?: string;\n procedureName?: string;\n streamId: string;\n controlFlags: number;\n tracing?: PropagationContext;\n payload: Payload;\n}\n\nexport type PartialTransportMessage<Payload = unknown> = Omit<\n TransportMessage<Payload>,\n 'id' | 'from' | 'to' | 'seq' | 'ack'\n>;\n\nexport function handshakeRequestMessage({\n from,\n to,\n sessionId,\n expectedSessionState,\n metadata,\n tracing,\n}: {\n from: TransportClientId;\n to: TransportClientId;\n sessionId: string;\n expectedSessionState: Static<\n typeof ControlMessageHandshakeRequestSchema\n >['expectedSessionState'];\n metadata?: unknown;\n tracing?: PropagationContext;\n}): TransportMessage<Static<typeof ControlMessageHandshakeRequestSchema>> {\n return {\n id: generateId(),\n from,\n to,\n seq: 0,\n ack: 0,\n streamId: generateId(),\n controlFlags: 0,\n tracing,\n payload: {\n type: 'HANDSHAKE_REQ',\n protocolVersion: currentProtocolVersion,\n sessionId,\n expectedSessionState,\n metadata,\n } satisfies Static<typeof ControlMessageHandshakeRequestSchema>,\n };\n}\n\n/**\n * This is a reason that can be given during the handshake to indicate that the peer has the wrong\n * session state.\n */\nexport const SESSION_STATE_MISMATCH = 'session state mismatch';\n\nexport function handshakeResponseMessage({\n from,\n to,\n status,\n}: {\n from: TransportClientId;\n to: TransportClientId;\n status: Static<typeof ControlMessageHandshakeResponseSchema>['status'];\n}): TransportMessage<Static<typeof ControlMessageHandshakeResponseSchema>> {\n return {\n id: generateId(),\n from,\n to,\n seq: 0,\n ack: 0,\n streamId: generateId(),\n controlFlags: 0,\n payload: {\n type: 'HANDSHAKE_RESP',\n status,\n } satisfies Static<typeof ControlMessageHandshakeResponseSchema>,\n };\n}\n\nexport function closeStreamMessage(streamId: string): PartialTransportMessage {\n return {\n streamId,\n controlFlags: ControlFlags.StreamClosedBit,\n payload: {\n type: 'CLOSE' as const,\n } satisfies Static<typeof ControlMessagePayloadSchema>,\n };\n}\n\nexport function cancelMessage(\n streamId: string,\n payload: ErrResult<Static<typeof ReaderErrorSchema>>,\n) {\n return {\n streamId,\n controlFlags: ControlFlags.StreamCancelBit,\n payload,\n };\n}\n\n/**\n * A type alias for a transport message with an opaque payload.\n * @template T - The type of the opaque payload.\n */\nexport type OpaqueTransportMessage = TransportMessage;\nexport type TransportClientId = string;\n\n/**\n * Checks if the given control flag (usually found in msg.controlFlag) is an ack message.\n * @param controlFlag - The control flag to check.\n * @returns True if the control flag contains the AckBit, false otherwise.\n */\nexport function isAck(controlFlag: number): boolean {\n /* eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison */\n return (controlFlag & ControlFlags.AckBit) === ControlFlags.AckBit;\n}\n\n/**\n * Checks if the given control flag (usually found in msg.controlFlag) is a stream open message.\n * @param controlFlag - The control flag to check.\n * @returns True if the control flag contains the StreamOpenBit, false otherwise.\n */\nexport function isStreamOpen(controlFlag: number): boolean {\n return (\n /* eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison */\n (controlFlag & ControlFlags.StreamOpenBit) === ControlFlags.StreamOpenBit\n );\n}\n\n/**\n * Checks if the given control flag (usually found in msg.controlFlag) is a stream close message.\n * @param controlFlag - The control flag to check.\n * @returns True if the control flag contains the StreamCloseBit, false otherwise.\n */\nexport function isStreamClose(controlFlag: number): boolean {\n return (\n /* eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison */\n (controlFlag & ControlFlags.StreamClosedBit) ===\n ControlFlags.StreamClosedBit\n );\n}\n\n/**\n * Checks if the given control flag (usually found in msg.controlFlag) is an cancel message.\n * @param controlFlag - The control flag to check.\n * @returns True if the control flag contains the CancelBit, false otherwise\n */\nexport function isStreamCancel(controlFlag: number): boolean {\n return (\n /* eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison */\n (controlFlag & ControlFlags.StreamCancelBit) ===\n ControlFlags.StreamCancelBit\n );\n}\n","export function coerceErrorString(err: unknown): string {\n if (err instanceof Error) {\n return err.message || 'unknown reason';\n }\n\n return `[coerced to error] ${String(err)}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,qBAA+B;AAOxB,IAAM,cAAqB;AAAA,EAChC,SAAS,KAAK;AACZ,eAAO,uBAAO,KAAK,EAAE,iBAAiB,KAAK,CAAC;AAAA,EAC9C;AAAA,EACA,YAAY,CAAC,SAAqB;AAChC,UAAM,UAAM,uBAAO,IAAI;AACvB,QAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;AAC3C,YAAM,IAAI,MAAM,+BAA+B;AAAA,IACjD;AAEA,WAAO;AAAA,EACT;AACF;;;ACjBA,IAAM,UAAU,IAAI,YAAY;AAChC,IAAM,UAAU,IAAI,YAAY;AAGhC,SAAS,mBAAmB,YAAwB;AAClD,MAAI,SAAS;AACb,aAAW,QAAQ,CAAC,SAAS;AAC3B,cAAU,OAAO,aAAa,IAAI;AAAA,EACpC,CAA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,QACJ,OAAO;AAAA,MACT;AAAA,IACF,SAAS,GAAG;AACV,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,QAAQ,kBAAkB,CAAC;AAAA,MAC7B;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/codec/index.d.cts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { C as Codec } from '../
|
|
1
|
+
import { C as Codec } from '../adapter-f2b6e211.js';
|
|
2
|
+
export { a as CodecMessageAdapter } from '../adapter-f2b6e211.js';
|
|
3
|
+
import '../message-01c3e85a.js';
|
|
4
|
+
import '@sinclair/typebox';
|
|
5
|
+
import '@opentelemetry/api';
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* Binary codec, uses [msgpack](https://www.npmjs.com/package/@msgpack/msgpack) under the hood
|
package/dist/codec/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { C as Codec } from '../
|
|
1
|
+
import { C as Codec } from '../adapter-f2b6e211.js';
|
|
2
|
+
export { a as CodecMessageAdapter } from '../adapter-f2b6e211.js';
|
|
3
|
+
import '../message-01c3e85a.js';
|
|
4
|
+
import '@sinclair/typebox';
|
|
5
|
+
import '@opentelemetry/api';
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* Binary codec, uses [msgpack](https://www.npmjs.com/package/@msgpack/msgpack) under the hood
|
package/dist/codec/index.js
CHANGED
|
@@ -1,27 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
+
BinaryCodec,
|
|
3
|
+
CodecMessageAdapter,
|
|
2
4
|
NaiveJsonCodec
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { decode, encode } from "@msgpack/msgpack";
|
|
7
|
-
var BinaryCodec = {
|
|
8
|
-
toBuffer(obj) {
|
|
9
|
-
return encode(obj, { ignoreUndefined: true });
|
|
10
|
-
},
|
|
11
|
-
fromBuffer: (buff) => {
|
|
12
|
-
try {
|
|
13
|
-
const res = decode(buff);
|
|
14
|
-
if (typeof res !== "object") {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
return res;
|
|
18
|
-
} catch {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
};
|
|
5
|
+
} from "../chunk-BO7MFCO6.js";
|
|
6
|
+
import "../chunk-QGPYCXV4.js";
|
|
7
|
+
import "../chunk-CC7RN7GI.js";
|
|
23
8
|
export {
|
|
24
9
|
BinaryCodec,
|
|
10
|
+
CodecMessageAdapter,
|
|
25
11
|
NaiveJsonCodec
|
|
26
12
|
};
|
|
27
13
|
//# sourceMappingURL=index.js.map
|
package/dist/codec/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { T as Tags } from './index-02554794.js';
|
|
2
|
+
import { P as ProtocolVersion, O as OpaqueTransportMessage } from './message-01c3e85a.js';
|
|
3
|
+
import { b as Connection } from './services-87887bc5.js';
|
|
3
4
|
import { W as WsLike } from './wslike-e0b32dd5.js';
|
|
4
5
|
|
|
5
6
|
interface ConnectionInfoExtras extends Record<string, unknown> {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { P as ProtocolVersion, O as OpaqueTransportMessage } from './message-01c3e85a.js';
|
|
2
|
+
|
|
3
|
+
declare const LoggingLevels: {
|
|
4
|
+
readonly debug: -1;
|
|
5
|
+
readonly info: 0;
|
|
6
|
+
readonly warn: 1;
|
|
7
|
+
readonly error: 2;
|
|
8
|
+
};
|
|
9
|
+
type LoggingLevel = keyof typeof LoggingLevels;
|
|
10
|
+
type LogFn = (msg: string, ctx?: MessageMetadata, level?: LoggingLevel) => void;
|
|
11
|
+
type Logger = {
|
|
12
|
+
[key in LoggingLevel]: (msg: string, metadata?: MessageMetadata) => void;
|
|
13
|
+
};
|
|
14
|
+
type Tags = 'invariant-violation' | 'state-transition' | 'invalid-request' | 'unhealthy-session' | 'uncaught-handler-error';
|
|
15
|
+
type MessageMetadata = Partial<{
|
|
16
|
+
protocolVersion: ProtocolVersion;
|
|
17
|
+
clientId: string;
|
|
18
|
+
connectedTo: string;
|
|
19
|
+
sessionId: string;
|
|
20
|
+
connId: string;
|
|
21
|
+
transportMessage: Partial<OpaqueTransportMessage>;
|
|
22
|
+
validationErrors: Array<{
|
|
23
|
+
path: string;
|
|
24
|
+
message: string;
|
|
25
|
+
}>;
|
|
26
|
+
tags: Array<Tags>;
|
|
27
|
+
telemetry: {
|
|
28
|
+
traceId: string;
|
|
29
|
+
spanId: string;
|
|
30
|
+
};
|
|
31
|
+
extras?: Record<string, unknown>;
|
|
32
|
+
}>;
|
|
33
|
+
declare const stringLogger: LogFn;
|
|
34
|
+
declare const coloredStringLogger: LogFn;
|
|
35
|
+
declare const jsonLogger: LogFn;
|
|
36
|
+
|
|
37
|
+
export { Logger as L, MessageMetadata as M, Tags as T, LogFn as a, LoggingLevel as b, coloredStringLogger as c, jsonLogger as j, stringLogger as s };
|
package/dist/logging/index.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a as LogFn, L as Logger, M as MessageMetadata, c as coloredStringLogger, j as jsonLogger, s as stringLogger } from '../index-02554794.js';
|
|
2
|
+
import '../message-01c3e85a.js';
|
|
2
3
|
import '@sinclair/typebox';
|
|
3
4
|
import '@opentelemetry/api';
|
package/dist/logging/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a as LogFn, L as Logger, M as MessageMetadata, c as coloredStringLogger, j as jsonLogger, s as stringLogger } from '../index-02554794.js';
|
|
2
|
+
import '../message-01c3e85a.js';
|
|
2
3
|
import '@sinclair/typebox';
|
|
3
4
|
import '@opentelemetry/api';
|
|
@@ -2,40 +2,6 @@ import * as _sinclair_typebox from '@sinclair/typebox';
|
|
|
2
2
|
import { TSchema } from '@sinclair/typebox';
|
|
3
3
|
import { Span, Context } from '@opentelemetry/api';
|
|
4
4
|
|
|
5
|
-
declare const LoggingLevels: {
|
|
6
|
-
readonly debug: -1;
|
|
7
|
-
readonly info: 0;
|
|
8
|
-
readonly warn: 1;
|
|
9
|
-
readonly error: 2;
|
|
10
|
-
};
|
|
11
|
-
type LoggingLevel = keyof typeof LoggingLevels;
|
|
12
|
-
type LogFn = (msg: string, ctx?: MessageMetadata, level?: LoggingLevel) => void;
|
|
13
|
-
type Logger = {
|
|
14
|
-
[key in LoggingLevel]: (msg: string, metadata?: MessageMetadata) => void;
|
|
15
|
-
};
|
|
16
|
-
type Tags = 'invariant-violation' | 'state-transition' | 'invalid-request' | 'unhealthy-session' | 'uncaught-handler-error';
|
|
17
|
-
type MessageMetadata = Partial<{
|
|
18
|
-
protocolVersion: ProtocolVersion;
|
|
19
|
-
clientId: string;
|
|
20
|
-
connectedTo: string;
|
|
21
|
-
sessionId: string;
|
|
22
|
-
connId: string;
|
|
23
|
-
transportMessage: Partial<OpaqueTransportMessage>;
|
|
24
|
-
validationErrors: Array<{
|
|
25
|
-
path: string;
|
|
26
|
-
message: string;
|
|
27
|
-
}>;
|
|
28
|
-
tags: Array<Tags>;
|
|
29
|
-
telemetry: {
|
|
30
|
-
traceId: string;
|
|
31
|
-
spanId: string;
|
|
32
|
-
};
|
|
33
|
-
extras?: Record<string, unknown>;
|
|
34
|
-
}>;
|
|
35
|
-
declare const stringLogger: LogFn;
|
|
36
|
-
declare const coloredStringLogger: LogFn;
|
|
37
|
-
declare const jsonLogger: LogFn;
|
|
38
|
-
|
|
39
5
|
interface PropagationContext {
|
|
40
6
|
traceparent: string;
|
|
41
7
|
tracestate: string;
|
|
@@ -139,4 +105,4 @@ declare function isStreamOpen(controlFlag: number): boolean;
|
|
|
139
105
|
*/
|
|
140
106
|
declare function isStreamClose(controlFlag: number): boolean;
|
|
141
107
|
|
|
142
|
-
export { HandshakeErrorResponseCodes as H,
|
|
108
|
+
export { HandshakeErrorResponseCodes as H, OpaqueTransportMessage as O, ProtocolVersion as P, TransportClientId as T, PartialTransportMessage as a, TelemetryInfo as b, TransportMessage as c, HandshakeErrorCustomHandlerFatalResponseCodes as d, TransportMessageSchema as e, OpaqueTransportMessageSchema as f, isStreamClose as g, isStreamOpen as i };
|
package/dist/router/index.cjs
CHANGED
|
@@ -1873,7 +1873,7 @@ function createServerHandshakeOptions(schema, validate) {
|
|
|
1873
1873
|
}
|
|
1874
1874
|
|
|
1875
1875
|
// package.json
|
|
1876
|
-
var version = "0.207.
|
|
1876
|
+
var version = "0.207.3";
|
|
1877
1877
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1878
1878
|
0 && (module.exports = {
|
|
1879
1879
|
CANCEL_CODE,
|