@lesomnus/grpc-dgram 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,331 @@
1
+ import { a as MethodDesc, h as Metadata, n as CallOptions } from "./desc-BMF2FBqk.mjs";
2
+ //#region src/timing.d.ts
3
+ interface Timing {
4
+ callMs?: number;
5
+ livenessMs?: number;
6
+ retransmitMs?: number;
7
+ tombstoneMs?: number;
8
+ holdMs?: number;
9
+ }
10
+ interface ResolvedTiming {
11
+ callMs: number;
12
+ livenessMs: number;
13
+ retransmitMs: number;
14
+ tombstoneMs: number;
15
+ holdMs: number;
16
+ probeMs: number;
17
+ tickMs: number;
18
+ }
19
+ //#endregion
20
+ //#region src/limits.d.ts
21
+ declare enum DropPolicy {
22
+ Newest = 0,
23
+ Oldest = 1
24
+ }
25
+ interface RxBufferConfig {
26
+ size?: number;
27
+ policy?: DropPolicy;
28
+ }
29
+ interface ResolvedRxConfig {
30
+ size: number;
31
+ policy: DropPolicy;
32
+ }
33
+ interface Limits {
34
+ maxTombstones?: number;
35
+ maxTombstoneBytes?: number;
36
+ maxDeadPeers?: number;
37
+ maxPendingResets?: number;
38
+ maxLiveCalls?: number;
39
+ maxRepliesPerRTI?: number;
40
+ }
41
+ //#endregion
42
+ //#region src/status.d.ts
43
+ declare enum Code {
44
+ OK = 0,
45
+ CANCELLED = 1,
46
+ UNKNOWN = 2,
47
+ INVALID_ARGUMENT = 3,
48
+ DEADLINE_EXCEEDED = 4,
49
+ NOT_FOUND = 5,
50
+ ALREADY_EXISTS = 6,
51
+ PERMISSION_DENIED = 7,
52
+ RESOURCE_EXHAUSTED = 8,
53
+ FAILED_PRECONDITION = 9,
54
+ ABORTED = 10,
55
+ OUT_OF_RANGE = 11,
56
+ UNIMPLEMENTED = 12,
57
+ INTERNAL = 13,
58
+ UNAVAILABLE = 14,
59
+ DATA_LOSS = 15,
60
+ UNAUTHENTICATED = 16
61
+ }
62
+ declare class StatusError extends Error {
63
+ readonly code: Code;
64
+ readonly desc: string;
65
+ constructor(code: Code, desc: string);
66
+ }
67
+ declare function statusError(code: Code, desc: string): StatusError;
68
+ declare class MessageTooLargeError extends Error {
69
+ constructor(message?: string);
70
+ }
71
+ declare function isMessageTooLarge(err: unknown): boolean;
72
+ declare function toStatusError(err: unknown): StatusError;
73
+ declare function abortCause(signal: AbortSignal): StatusError;
74
+ //#endregion
75
+ //#region src/wire.d.ts
76
+ declare const FlagOpen = 1;
77
+ declare const FlagClose = 2;
78
+ declare const FlagReset = 4;
79
+ declare const FlagPing = 8;
80
+ declare const FlagWindow = 16;
81
+ declare const FlagCompressed = 32;
82
+ declare const SHAPE_MASK: number;
83
+ interface Any {
84
+ typeUrl: string;
85
+ value: Uint8Array;
86
+ }
87
+ interface Frame {
88
+ epoch: number;
89
+ sid: number;
90
+ seq: number;
91
+ flags: number;
92
+ method: string;
93
+ codec: string;
94
+ timeoutMs?: number;
95
+ payload?: Uint8Array;
96
+ code?: number;
97
+ desc: string;
98
+ header?: Metadata;
99
+ trailer?: Metadata;
100
+ peerEpoch: number;
101
+ window: number;
102
+ compressor: string;
103
+ details?: Any[];
104
+ }
105
+ declare function frame(init?: Partial<Frame>): Frame;
106
+ declare const isOpen: (f: Frame) => boolean;
107
+ declare const isClose: (f: Frame) => boolean;
108
+ declare const isReset: (f: Frame) => boolean;
109
+ declare const isPing: (f: Frame) => boolean;
110
+ declare const isWindow: (f: Frame) => boolean;
111
+ declare const isCompressed: (f: Frame) => boolean;
112
+ declare const shapeOf: (f: Frame) => number;
113
+ declare const hasUnknownFlags: (f: Frame) => boolean;
114
+ declare function legalShape(shape: number): boolean;
115
+ declare const isTerminal: (f: Frame) => boolean;
116
+ declare const isHalfClose: (f: Frame) => boolean;
117
+ declare const isData: (f: Frame) => boolean;
118
+ declare const isHeaderFrame: (f: Frame) => boolean;
119
+ declare function frameStatus(f: Frame): StatusError;
120
+ declare function setFrameError(f: Frame, err: unknown): void;
121
+ declare function resetFor(f: Frame): Frame;
122
+ declare function encodeFrame(f: Frame): Uint8Array;
123
+ declare function decodeFrame(data: Uint8Array): Frame;
124
+ declare function encodeEnvelop(frames: readonly Frame[]): Uint8Array;
125
+ declare function decodeEnvelop(data: Uint8Array): Frame[];
126
+ //#endregion
127
+ //#region src/seam.d.ts
128
+ interface FrameContext {
129
+ peer?: unknown;
130
+ reliable?: boolean;
131
+ signal?: AbortSignal;
132
+ }
133
+ interface FrameHandler {
134
+ handle(frame: Frame, ctx?: FrameContext): void | Promise<void>;
135
+ }
136
+ interface TransportInfo {
137
+ reliable(): boolean;
138
+ }
139
+ interface ConnAttacher {
140
+ attachConn(conn: Conn): void;
141
+ }
142
+ declare function hasTransportInfo(tx: FrameHandler): tx is FrameHandler & TransportInfo;
143
+ declare function hasConnAttacher(tx: FrameHandler): tx is FrameHandler & ConnAttacher;
144
+ declare function unpack(frames: readonly Frame[], h: FrameHandler, ctx?: FrameContext): Promise<void>;
145
+ //#endregion
146
+ //#region src/util.d.ts
147
+ declare const W_INIT = 32;
148
+ declare const DEFAULT_STALL_MS = 30000;
149
+ declare const DEFAULT_MAX_RECV_MSG_SIZE: number;
150
+ declare const DEFAULT_MAX_SEND_MSG_SIZE = 2147483647;
151
+ interface Compressor {
152
+ compress(data: Uint8Array): Uint8Array | Promise<Uint8Array>;
153
+ decompress(data: Uint8Array, maxBytes: number): Uint8Array | Promise<Uint8Array>;
154
+ }
155
+ declare function getCompressor(name: string): Compressor | undefined;
156
+ //#endregion
157
+ //#region src/conn.d.ts
158
+ declare class EndOfStreamError extends Error {
159
+ constructor();
160
+ }
161
+ interface FlowTiming extends Timing {
162
+ stallMs?: number;
163
+ }
164
+ interface CallConfig<Req = unknown, Res = unknown> extends CallOptions<Req, Res> {
165
+ compressor?: string;
166
+ maxRecvMsgSize?: number;
167
+ maxSendMsgSize?: number;
168
+ }
169
+ interface ConnOptions {
170
+ reliable?: boolean;
171
+ timing?: FlowTiming;
172
+ rxBuffer?: RxBufferConfig;
173
+ limits?: Limits;
174
+ compressor?: string;
175
+ maxRecvMsgSize?: number;
176
+ maxSendMsgSize?: number;
177
+ compressors?: Record<string, Compressor>;
178
+ defaultCallOptions?: CallConfig;
179
+ }
180
+ interface CallInfo {
181
+ compressorName: string;
182
+ compressor: Compressor | undefined;
183
+ maxRecv: number;
184
+ maxSend: number;
185
+ stallMs: number;
186
+ }
187
+ type DetailedStatusError = StatusError & {
188
+ details?: readonly Any[];
189
+ };
190
+ declare function statusDetails(err: unknown): readonly Any[] | undefined;
191
+ declare class Conn {
192
+ readonly epoch: number;
193
+ private readonly tx;
194
+ private readonly mode;
195
+ private readonly rxCfg;
196
+ private readonly limits;
197
+ private readonly defaults;
198
+ private readonly compressor;
199
+ private readonly compressors;
200
+ private readonly maxRecv;
201
+ private readonly maxSend;
202
+ private readonly stallMs;
203
+ private readonly ss;
204
+ private readonly tombs;
205
+ private readonly resetAt;
206
+ private sidNext;
207
+ private exhausted;
208
+ private closed;
209
+ private lastRx;
210
+ private lastTx;
211
+ private lastPing;
212
+ private readonly sw;
213
+ constructor(tx: FrameHandler, opts?: ConnOptions);
214
+ get reliable(): boolean;
215
+ handle(f: Frame, ctx?: FrameContext): Promise<void>;
216
+ close(err?: unknown): void;
217
+ invoke<Req, Res>(desc: MethodDesc<Req, Res>, req: Req, opts?: CallConfig<Req, Res>): Promise<Res>;
218
+ newStream<Req, Res>(desc: MethodDesc<Req, Res>, opts?: CallConfig<Req, Res>): ClientStream<Req, Res>;
219
+ private resolveCall;
220
+ private createStream;
221
+ /** @internal */
222
+ get timing(): ResolvedTiming;
223
+ /** @internal */
224
+ get isReliable(): boolean;
225
+ /** @internal */
226
+ get streamRxCfg(): ResolvedRxConfig;
227
+ /** @internal */
228
+ transmit(f: Frame): Promise<void>;
229
+ /** @internal */
230
+ noteRx(): void;
231
+ /** @internal */
232
+ retire(s: ClientStream<unknown, unknown>): void;
233
+ private clearTombAbort;
234
+ private sendReset;
235
+ private failAll;
236
+ /** @internal */
237
+ kickSweep(): void;
238
+ private hasWork;
239
+ private sweep;
240
+ }
241
+ declare class ClientStream<Req, Res> {
242
+ readonly sid: number;
243
+ private readonly conn;
244
+ private readonly desc;
245
+ private readonly reqCodec;
246
+ private readonly resCodec;
247
+ private readonly codecName;
248
+ private readonly openHdr;
249
+ private readonly ci;
250
+ private readonly flowTx;
251
+ private readonly flowRx;
252
+ private readonly rxSize;
253
+ private readonly callerSignal;
254
+ private signalDispose;
255
+ private deadlineTimer;
256
+ private deadlineFired;
257
+ private readonly timeoutCause;
258
+ /** @internal */
259
+ deadlineAt: number | undefined;
260
+ private readonly txSeq;
261
+ private txOpened;
262
+ private txClosed;
263
+ /** @internal */
264
+ abortFrame: Frame | undefined;
265
+ private retxOpen;
266
+ private retxClose;
267
+ private retxAt;
268
+ private retxIval;
269
+ private lastRx;
270
+ private lastTx;
271
+ private lastProbe;
272
+ private readonly rxWin;
273
+ private srvEpoch;
274
+ private srvEpochSet;
275
+ private readonly rxq;
276
+ private readonly rxPolicy;
277
+ private rxDropped;
278
+ private rxHeader;
279
+ private trailerMd;
280
+ private readonly hdrLatch;
281
+ private readonly done;
282
+ private term;
283
+ private termErr;
284
+ private termPayloadDelivered;
285
+ /** @internal */
286
+ constructor(conn: Conn, desc: MethodDesc<Req, Res>, sid: number, opts: CallConfig<Req, Res>, ci: CallInfo, timeoutCause: StatusError | undefined);
287
+ /** @internal */
288
+ arm(opts: CallOptions<Req, Res>): void;
289
+ /** @internal */
290
+ handleRx(f: Frame, ctx: FrameContext): Promise<void>;
291
+ private grantWindow;
292
+ private recvInto;
293
+ private latchHeader;
294
+ private noteValidatedRx;
295
+ private openFrame;
296
+ private nextFrame;
297
+ /** @internal */
298
+ sendOpen(): Promise<void>;
299
+ /** @internal */
300
+ sendRaw(m: Req): Promise<void>;
301
+ private undoRefused;
302
+ send(m: Req): Promise<void>;
303
+ closeSend(): void;
304
+ recv(): Promise<Res | undefined>;
305
+ private recvBuffered;
306
+ private terminalRecv;
307
+ [Symbol.asyncIterator](): AsyncIterator<Res>;
308
+ header(): Promise<Metadata | undefined>;
309
+ trailer(): Metadata | undefined;
310
+ latchedHeader(): Metadata | undefined;
311
+ cancel(): void;
312
+ private abortFromCtx;
313
+ private sendAbort;
314
+ private finishTerm;
315
+ /** @internal */
316
+ finishLocal(err: StatusError): void;
317
+ /** @internal */
318
+ abandon(): void;
319
+ /** @internal */
320
+ finishReset(): void;
321
+ private release;
322
+ /** @internal */
323
+ transmit(f: Frame): Promise<void>;
324
+ private scheduleRetx;
325
+ /** @internal */
326
+ sweepRetx(now: number, capMs: number): Frame[];
327
+ /** @internal */
328
+ probeDue(now: number, probeMs: number): Frame | undefined;
329
+ }
330
+ //#endregion
331
+ export { StatusError as $, decodeEnvelop as A, isHalfClose as B, FlagCompressed as C, FlagWindow as D, FlagReset as E, frameStatus as F, isTerminal as G, isOpen as H, hasUnknownFlags as I, resetFor as J, isWindow as K, isClose as L, encodeEnvelop as M, encodeFrame as N, Frame as O, frame as P, MessageTooLargeError as Q, isCompressed as R, FlagClose as S, FlagPing as T, isPing as U, isHeaderFrame as V, isReset as W, shapeOf as X, setFrameError as Y, Code as Z, TransportInfo as _, EndOfStreamError as a, Limits as at, unpack as b, Compressor as c, Timing as ct, DEFAULT_STALL_MS as d, abortCause as et, W_INIT as f, FrameHandler as g, FrameContext as h, DetailedStatusError as i, DropPolicy as it, decodeFrame as j, SHAPE_MASK as k, DEFAULT_MAX_RECV_MSG_SIZE as l, ConnAttacher as m, Conn as n, statusError as nt, FlowTiming as o, RxBufferConfig as ot, getCompressor as p, legalShape as q, ConnOptions as r, toStatusError as rt, statusDetails as s, ResolvedTiming as st, ClientStream as t, isMessageTooLarge as tt, DEFAULT_MAX_SEND_MSG_SIZE as u, hasConnAttacher as v, FlagOpen as w, Any as x, hasTransportInfo as y, isData as z };
@@ -0,0 +1,72 @@
1
+ //#region src/metadata.d.ts
2
+ type Metadata = Record<string, string[]>;
3
+ declare const isBinaryKey: (key: string) => boolean;
4
+ declare function metadataJoin(a: Metadata | undefined, b: Metadata | undefined): Metadata | undefined;
5
+ declare function cloneMetadata(md: Metadata): Metadata;
6
+ declare function encodeBase64(bytes: Uint8Array): string;
7
+ declare function decodeBase64(s: string): Uint8Array;
8
+ declare function validateMetadata(md: Metadata | undefined): void;
9
+ declare function validateMetadataPair(key: string, values: readonly string[]): void;
10
+ //#endregion
11
+ //#region src/desc.d.ts
12
+ interface PayloadCodec<T> {
13
+ marshal(value: T): Uint8Array;
14
+ unmarshal(data: Uint8Array): T;
15
+ }
16
+ interface MethodDesc<Req = unknown, Res = unknown> {
17
+ readonly path: string;
18
+ readonly clientStreams: boolean;
19
+ readonly serverStreams: boolean;
20
+ readonly request: PayloadCodec<Req>;
21
+ readonly response: PayloadCodec<Res>;
22
+ readonly requestSchema?: unknown;
23
+ readonly responseSchema?: unknown;
24
+ }
25
+ type UnaryDesc<Req, Res> = MethodDesc<Req, Res> & {
26
+ clientStreams: false;
27
+ serverStreams: false;
28
+ };
29
+ type ServerStreamingDesc<Req, Res> = MethodDesc<Req, Res> & {
30
+ clientStreams: false;
31
+ serverStreams: true;
32
+ };
33
+ type ClientStreamingDesc<Req, Res> = MethodDesc<Req, Res> & {
34
+ clientStreams: true;
35
+ serverStreams: false;
36
+ };
37
+ type BidiDesc<Req, Res> = MethodDesc<Req, Res> & {
38
+ clientStreams: true;
39
+ serverStreams: true;
40
+ };
41
+ type DescInit<Req, Res> = {
42
+ request: PayloadCodec<Req>;
43
+ response: PayloadCodec<Res>;
44
+ requestSchema?: unknown;
45
+ responseSchema?: unknown;
46
+ };
47
+ declare function unaryMethod<Req, Res>(path: string, init: DescInit<Req, Res>): UnaryDesc<Req, Res>;
48
+ declare function serverStreamingMethod<Req, Res>(path: string, init: DescInit<Req, Res>): ServerStreamingDesc<Req, Res>;
49
+ declare function clientStreamingMethod<Req, Res>(path: string, init: DescInit<Req, Res>): ClientStreamingDesc<Req, Res>;
50
+ declare function bidiMethod<Req, Res>(path: string, init: DescInit<Req, Res>): BidiDesc<Req, Res>;
51
+ declare function isUnary(desc: MethodDesc<unknown, unknown>): boolean;
52
+ interface NamedCodec {
53
+ resolve(desc: MethodDesc<unknown, unknown>): {
54
+ request: PayloadCodec<unknown>;
55
+ response: PayloadCodec<unknown>;
56
+ };
57
+ }
58
+ interface ForcedCodec<Req = unknown, Res = unknown> {
59
+ name: string;
60
+ request: PayloadCodec<Req>;
61
+ response: PayloadCodec<Res>;
62
+ }
63
+ interface CallOptions<Req = unknown, Res = unknown> {
64
+ signal?: AbortSignal;
65
+ timeoutMs?: number;
66
+ metadata?: Metadata;
67
+ codec?: ForcedCodec<Req, Res>;
68
+ onHeader?: (md: Metadata | undefined) => void;
69
+ onTrailer?: (md: Metadata | undefined) => void;
70
+ }
71
+ //#endregion
72
+ export { validateMetadataPair as S, decodeBase64 as _, MethodDesc as a, metadataJoin as b, ServerStreamingDesc as c, clientStreamingMethod as d, isUnary as f, cloneMetadata as g, Metadata as h, ForcedCodec as i, UnaryDesc as l, unaryMethod as m, CallOptions as n, NamedCodec as o, serverStreamingMethod as p, ClientStreamingDesc as r, PayloadCodec as s, BidiDesc as t, bidiMethod as u, encodeBase64 as v, validateMetadata as x, isBinaryKey as y };
@@ -0,0 +1,27 @@
1
+ import { $ as StatusError, A as decodeEnvelop, B as isHalfClose, C as FlagCompressed, D as FlagWindow, E as FlagReset, F as frameStatus, G as isTerminal, H as isOpen, I as hasUnknownFlags, J as resetFor, K as isWindow, L as isClose, M as encodeEnvelop, N as encodeFrame, O as Frame, P as frame, Q as MessageTooLargeError, R as isCompressed, S as FlagClose, T as FlagPing, U as isPing, V as isHeaderFrame, W as isReset, X as shapeOf, Y as setFrameError, Z as Code, _ as TransportInfo, a as EndOfStreamError, at as Limits, b as unpack, c as Compressor, ct as Timing, d as DEFAULT_STALL_MS, et as abortCause, f as W_INIT, g as FrameHandler, h as FrameContext, i as DetailedStatusError, it as DropPolicy, j as decodeFrame, k as SHAPE_MASK, l as DEFAULT_MAX_RECV_MSG_SIZE, m as ConnAttacher, n as Conn, nt as statusError, o as FlowTiming, ot as RxBufferConfig, p as getCompressor, q as legalShape, r as ConnOptions, rt as toStatusError, s as statusDetails, t as ClientStream, tt as isMessageTooLarge, u as DEFAULT_MAX_SEND_MSG_SIZE, v as hasConnAttacher, w as FlagOpen, x as Any, y as hasTransportInfo, z as isData } from "./conn-DTWG9vIx.mjs";
2
+ import { S as validateMetadataPair, _ as decodeBase64, a as MethodDesc, b as metadataJoin, c as ServerStreamingDesc, d as clientStreamingMethod, f as isUnary, g as cloneMetadata, h as Metadata, i as ForcedCodec, l as UnaryDesc, m as unaryMethod, n as CallOptions, o as NamedCodec, p as serverStreamingMethod, r as ClientStreamingDesc, s as PayloadCodec, t as BidiDesc, u as bidiMethod, v as encodeBase64, x as validateMetadata, y as isBinaryKey } from "./desc-BMF2FBqk.mjs";
3
+ import { a as ServerOptions, c as ServerWriter, i as ServerContext, l as UnaryHandler, n as ClientStreamingHandler, o as ServerReader, r as Server, s as ServerStreamingHandler, t as BidiHandler } from "./server-xIr1mwqq.mjs";
4
+ //#region src/seq.d.ts
5
+ declare const W_FWD = 4096;
6
+ declare const K_LOUD = 3;
7
+ declare class TxSeq {
8
+ private v;
9
+ next(): number;
10
+ undo(seq: number): void;
11
+ }
12
+ declare enum RxVerdict {
13
+ Accept = 0,
14
+ Dup = 1,
15
+ Beyond = 2,
16
+ DataLoss = 3,
17
+ ProtocolError = 4
18
+ }
19
+ declare class RxWindow {
20
+ l: number;
21
+ strict: boolean;
22
+ private beyondN;
23
+ private beyondLast;
24
+ check(seq: number): RxVerdict;
25
+ }
26
+ //#endregion
27
+ export { type Any, type BidiDesc, type BidiHandler, type CallOptions, ClientStream, type ClientStreamingDesc, type ClientStreamingHandler, Code, type Compressor, Conn, type ConnAttacher, type ConnOptions, DEFAULT_MAX_RECV_MSG_SIZE, DEFAULT_MAX_SEND_MSG_SIZE, DEFAULT_STALL_MS, type DetailedStatusError, DropPolicy, EndOfStreamError, FlagClose, FlagCompressed, FlagOpen, FlagPing, FlagReset, FlagWindow, type FlowTiming, type ForcedCodec, type Frame, type FrameContext, type FrameHandler, K_LOUD, type Limits, MessageTooLargeError, type Metadata, type MethodDesc, type NamedCodec, type PayloadCodec, type RxBufferConfig, RxVerdict, RxWindow, SHAPE_MASK, Server, type ServerContext, type ServerOptions, type ServerReader, type ServerStreamingDesc, type ServerStreamingHandler, type ServerWriter, StatusError, type Timing, type TransportInfo, TxSeq, type UnaryDesc, type UnaryHandler, W_FWD, W_INIT, abortCause, bidiMethod, clientStreamingMethod, cloneMetadata, decodeBase64, decodeEnvelop, decodeFrame, encodeBase64, encodeEnvelop, encodeFrame, frame, frameStatus, getCompressor, hasConnAttacher, hasTransportInfo, hasUnknownFlags, isBinaryKey, isClose, isCompressed, isData, isHalfClose, isHeaderFrame, isMessageTooLarge, isOpen, isPing, isReset, isTerminal, isUnary, isWindow, legalShape, metadataJoin, resetFor, serverStreamingMethod, setFrameError, shapeOf, statusDetails, statusError, toStatusError, unaryMethod, unpack, validateMetadata, validateMetadataPair };