@nmtjs/protocol 0.15.0-beta.37 → 0.15.0-beta.39
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/LICENSE.md +1 -1
- package/README.md +1 -1
- package/dist/client/format.d.ts +18 -13
- package/dist/client/format.js +1 -0
- package/dist/client/format.js.map +1 -0
- package/dist/client/index.d.ts +4 -1
- package/dist/client/index.js +7 -4
- package/dist/client/index.js.map +1 -0
- package/dist/client/protocol.d.ts +102 -138
- package/dist/client/protocol.js +7 -336
- package/dist/client/protocol.js.map +1 -0
- package/dist/client/stream.d.ts +34 -19
- package/dist/client/stream.js +138 -46
- package/dist/client/stream.js.map +1 -0
- package/dist/client/versions/v1.d.ts +108 -0
- package/dist/client/versions/v1.js +128 -0
- package/dist/client/versions/v1.js.map +1 -0
- package/dist/common/binary.d.ts +5 -6
- package/dist/common/binary.js +22 -9
- package/dist/common/binary.js.map +1 -0
- package/dist/common/blob.d.ts +14 -8
- package/dist/common/blob.js +55 -30
- package/dist/common/blob.js.map +1 -0
- package/dist/common/constants.d.ts +2 -0
- package/dist/common/constants.js +2 -0
- package/dist/common/constants.js.map +1 -0
- package/dist/common/enums.d.ts +17 -7
- package/dist/common/enums.js +34 -14
- package/dist/common/enums.js.map +1 -0
- package/dist/common/index.d.ts +2 -0
- package/dist/common/index.js +7 -4
- package/dist/common/index.js.map +1 -0
- package/dist/common/types.d.ts +5 -24
- package/dist/common/types.js +1 -0
- package/dist/common/types.js.map +1 -0
- package/dist/common/utils.d.ts +2 -0
- package/dist/common/utils.js +7 -0
- package/dist/common/utils.js.map +1 -0
- package/dist/server/format.d.ts +17 -23
- package/dist/server/format.js +13 -8
- package/dist/server/format.js.map +1 -0
- package/dist/server/index.d.ts +4 -6
- package/dist/server/index.js +9 -11
- package/dist/server/index.js.map +1 -0
- package/dist/server/protocol.d.ts +88 -114
- package/dist/server/protocol.js +5 -354
- package/dist/server/protocol.js.map +1 -0
- package/dist/server/stream.d.ts +5 -0
- package/dist/server/stream.js +31 -2
- package/dist/server/stream.js.map +1 -0
- package/dist/server/types.d.ts +29 -8
- package/dist/server/types.js +1 -0
- package/dist/server/types.js.map +1 -0
- package/dist/server/utils.d.ts +3 -6
- package/dist/server/utils.js +5 -4
- package/dist/server/utils.js.map +1 -0
- package/dist/server/versions/v1.d.ts +77 -0
- package/dist/server/versions/v1.js +119 -0
- package/dist/server/versions/v1.js.map +1 -0
- package/package.json +18 -24
- package/src/client/format.ts +49 -0
- package/src/client/index.ts +8 -0
- package/src/client/protocol.ts +107 -0
- package/src/client/stream.ts +222 -0
- package/src/client/versions/v1.ts +205 -0
- package/src/common/binary.ts +70 -0
- package/src/common/blob.ts +94 -0
- package/src/common/constants.ts +2 -0
- package/src/common/enums.ts +62 -0
- package/src/common/index.ts +6 -0
- package/src/common/types.ts +18 -0
- package/src/common/utils.ts +12 -0
- package/src/server/format.ts +117 -0
- package/src/server/index.ts +10 -0
- package/src/server/protocol.ts +97 -0
- package/src/server/stream.ts +72 -0
- package/src/server/types.ts +42 -0
- package/src/server/utils.ts +22 -0
- package/src/server/versions/v1.ts +198 -0
- package/dist/client/events.d.ts +0 -15
- package/dist/client/events.js +0 -28
- package/dist/server/api.d.ts +0 -33
- package/dist/server/api.js +0 -7
- package/dist/server/connection.d.ts +0 -25
- package/dist/server/connection.js +0 -22
- package/dist/server/constants.d.ts +0 -4
- package/dist/server/constants.js +0 -2
- package/dist/server/injectables.d.ts +0 -14
- package/dist/server/injectables.js +0 -22
- package/dist/server/registry.d.ts +0 -3
- package/dist/server/registry.js +0 -3
- package/dist/server/transport.d.ts +0 -23
- package/dist/server/transport.js +0 -3
package/dist/common/types.d.ts
CHANGED
|
@@ -1,33 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ProtocolBlob, ProtocolBlobMetadata } from './blob.ts';
|
|
1
|
+
import type { ProtocolBlobMetadata } from './blob.ts';
|
|
3
2
|
type Stream = any;
|
|
4
3
|
export interface BaseProtocolError {
|
|
5
4
|
code: string;
|
|
6
5
|
message: string;
|
|
7
6
|
data?: any;
|
|
8
7
|
}
|
|
9
|
-
export type
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
payload: any;
|
|
13
|
-
};
|
|
14
|
-
export type ProtocolRPCResponse<T = Stream> = OneOf<[
|
|
15
|
-
{
|
|
16
|
-
callId: number;
|
|
17
|
-
error: BaseProtocolError;
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
callId: number;
|
|
21
|
-
result: any;
|
|
22
|
-
streams: Record<number, T>;
|
|
23
|
-
}
|
|
24
|
-
]>;
|
|
25
|
-
export interface EncodeRPCContext<T = Stream> {
|
|
26
|
-
getStream: (id: number) => T;
|
|
27
|
-
addStream: (blob: ProtocolBlob) => T;
|
|
28
|
-
}
|
|
8
|
+
export type ProtocolRPCPayload = unknown;
|
|
9
|
+
export type ProtocolRPCResponse = unknown;
|
|
10
|
+
export type EncodeRPCStreams = Record<number, ProtocolBlobMetadata>;
|
|
29
11
|
export interface DecodeRPCContext<T = Stream> {
|
|
30
|
-
|
|
31
|
-
addStream: (id: number, callId: number, metadata: ProtocolBlobMetadata) => T;
|
|
12
|
+
addStream: (id: number, metadata: ProtocolBlobMetadata) => T;
|
|
32
13
|
}
|
|
33
14
|
export {};
|
package/dist/common/types.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/common/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,KAAU,EACE,EAAE,CAAC;IACf,OAAO,CACL,KAAK;QACL,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC;QAC1D,QAAQ,IAAI,KAAK,CAClB,CAAA;AAAA,CACF,CAAA"}
|
package/dist/server/format.d.ts
CHANGED
|
@@ -1,39 +1,33 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { DecodeRPCContext,
|
|
4
|
-
import type { ProtocolClientStream
|
|
1
|
+
import type { Pattern } from '@nmtjs/common';
|
|
2
|
+
import type { ProtocolBlobMetadata } from '../common/blob.ts';
|
|
3
|
+
import type { DecodeRPCContext, EncodeRPCStreams, ProtocolRPCPayload } from '../common/types.ts';
|
|
4
|
+
import type { ProtocolClientStream } from './stream.ts';
|
|
5
5
|
export interface BaseServerDecoder {
|
|
6
6
|
accept: Pattern[];
|
|
7
|
-
decode(buffer:
|
|
8
|
-
decodeRPC(buffer:
|
|
7
|
+
decode(buffer: ArrayBufferView): unknown;
|
|
8
|
+
decodeRPC(buffer: ArrayBufferView, context: DecodeRPCContext<() => ProtocolClientStream>): ProtocolRPCPayload;
|
|
9
9
|
}
|
|
10
10
|
export interface BaseServerEncoder {
|
|
11
11
|
contentType: string;
|
|
12
|
-
encode(data:
|
|
13
|
-
encodeRPC(
|
|
14
|
-
|
|
15
|
-
callId: number;
|
|
16
|
-
error: any;
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
callId: number;
|
|
20
|
-
result: any;
|
|
21
|
-
}
|
|
22
|
-
]>, context: EncodeRPCContext<ProtocolServerStream>): ArrayBuffer;
|
|
12
|
+
encode(data: unknown): ArrayBufferView;
|
|
13
|
+
encodeRPC(data: unknown, streams: EncodeRPCStreams): ArrayBufferView;
|
|
14
|
+
encodeBlob(streamId: number, metadata: ProtocolBlobMetadata): unknown;
|
|
23
15
|
}
|
|
24
16
|
export declare abstract class BaseServerFormat implements BaseServerDecoder, BaseServerEncoder {
|
|
25
17
|
abstract accept: Pattern[];
|
|
26
18
|
abstract contentType: string;
|
|
27
|
-
abstract encode(data:
|
|
28
|
-
abstract encodeRPC(
|
|
29
|
-
abstract
|
|
30
|
-
abstract
|
|
19
|
+
abstract encode(data: unknown): ArrayBufferView;
|
|
20
|
+
abstract encodeRPC(data: unknown, streams: EncodeRPCStreams): ArrayBufferView;
|
|
21
|
+
abstract encodeBlob(streamId: number, metadata: ProtocolBlobMetadata): unknown;
|
|
22
|
+
abstract decode(buffer: ArrayBufferView): any;
|
|
23
|
+
abstract decodeRPC(buffer: ArrayBufferView, context: DecodeRPCContext<() => ProtocolClientStream>): ProtocolRPCPayload;
|
|
31
24
|
}
|
|
32
25
|
export declare const parseContentTypes: (types: string) => string[];
|
|
33
|
-
export declare class
|
|
26
|
+
export declare class ProtocolFormats {
|
|
34
27
|
decoders: Map<Pattern, BaseServerDecoder>;
|
|
35
28
|
encoders: Map<Pattern, BaseServerEncoder>;
|
|
36
|
-
|
|
29
|
+
default: BaseServerFormat;
|
|
30
|
+
constructor(formats: [BaseServerFormat, ...BaseServerFormat[]]);
|
|
37
31
|
supportsDecoder(contentType: string, throwIfUnsupported?: boolean): BaseServerDecoder | null;
|
|
38
32
|
supportsEncoder(contentType: string, throwIfUnsupported?: boolean): BaseServerEncoder | null;
|
|
39
33
|
private supports;
|
package/dist/server/format.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import { match } from '@nmtjs/
|
|
1
|
+
import { match } from '@nmtjs/common';
|
|
2
2
|
export class BaseServerFormat {
|
|
3
3
|
}
|
|
4
4
|
export const parseContentTypes = (types) => {
|
|
5
|
-
|
|
5
|
+
const normalized = types.trim();
|
|
6
|
+
if (normalized === '*/*')
|
|
6
7
|
return ['*/*'];
|
|
7
|
-
return
|
|
8
|
+
return normalized
|
|
8
9
|
.split(',')
|
|
10
|
+
.map((t) => t.trim())
|
|
9
11
|
.map((t) => {
|
|
10
|
-
const [
|
|
12
|
+
const [rawType, ...rest] = t.split(';');
|
|
11
13
|
const params = new Map(rest.map((p) => p
|
|
12
14
|
.trim()
|
|
13
15
|
.split('=')
|
|
14
16
|
.slice(0, 2)
|
|
15
|
-
.map((
|
|
17
|
+
.map((part) => part.trim())));
|
|
16
18
|
return {
|
|
17
|
-
type,
|
|
19
|
+
type: rawType.trim(),
|
|
18
20
|
q: params.has('q') ? Number.parseFloat(params.get('q')) : 1,
|
|
19
21
|
};
|
|
20
22
|
})
|
|
@@ -23,14 +25,16 @@ export const parseContentTypes = (types) => {
|
|
|
23
25
|
return 1;
|
|
24
26
|
if (b.type === '*/*')
|
|
25
27
|
return -1;
|
|
26
|
-
return b.q - a.q
|
|
28
|
+
return b.q - a.q;
|
|
27
29
|
})
|
|
28
30
|
.map((t) => t.type);
|
|
29
31
|
};
|
|
30
|
-
export class
|
|
32
|
+
export class ProtocolFormats {
|
|
31
33
|
decoders = new Map();
|
|
32
34
|
encoders = new Map();
|
|
35
|
+
default;
|
|
33
36
|
constructor(formats) {
|
|
37
|
+
this.default = formats[0];
|
|
34
38
|
for (const format of formats) {
|
|
35
39
|
this.encoders.set(format.contentType, format);
|
|
36
40
|
for (const acceptType of format.accept) {
|
|
@@ -58,3 +62,4 @@ export class ProtocolFormat {
|
|
|
58
62
|
return null;
|
|
59
63
|
}
|
|
60
64
|
}
|
|
65
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/server/format.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AA0BrC,MAAM,OAAgB,gBAAgB;CAcrC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC;IAClD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;IAC/B,IAAI,UAAU,KAAK,KAAK;QAAE,OAAO,CAAC,KAAK,CAAC,CAAA;IACxC,OAAO,UAAU;SACd,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACp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
-
export * from './api.ts';
|
|
2
|
-
export * from './connection.ts';
|
|
3
|
-
export * from './constants.ts';
|
|
4
1
|
export * from './format.ts';
|
|
5
|
-
export * from './injectables.ts';
|
|
6
2
|
export * from './protocol.ts';
|
|
7
|
-
export * from './registry.ts';
|
|
8
3
|
export * from './stream.ts';
|
|
9
|
-
export * from './transport.ts';
|
|
10
4
|
export * from './types.ts';
|
|
11
5
|
export * from './utils.ts';
|
|
6
|
+
import { ProtocolVersion1 } from './versions/v1.ts';
|
|
7
|
+
export declare const versions: {
|
|
8
|
+
1: ProtocolVersion1;
|
|
9
|
+
};
|
package/dist/server/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
export * from "./types.js";
|
|
11
|
-
export * from "./utils.js";
|
|
1
|
+
export * from './format.js';
|
|
2
|
+
export * from './protocol.js';
|
|
3
|
+
export * from './stream.js';
|
|
4
|
+
export * from './types.js';
|
|
5
|
+
export * from './utils.js';
|
|
6
|
+
import { ProtocolVersion } from '../common/enums.js';
|
|
7
|
+
import { ProtocolVersion1 } from './versions/v1.js';
|
|
8
|
+
export const versions = { [ProtocolVersion.v1]: new ProtocolVersion1() };
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEnD,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC,EAAE,IAAI,gBAAgB,EAAE,EAAE,CAAA"}
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
import type { ProtocolApi, ProtocolApiCallOptions } from './api.ts';
|
|
6
|
-
import type { ConnectionOptions } from './connection.ts';
|
|
7
|
-
import type { ProtocolFormat } from './format.ts';
|
|
8
|
-
import type { ProtocolRegistry } from './registry.ts';
|
|
9
|
-
import type { Transport } from './transport.ts';
|
|
10
|
-
import type { ResolveFormatParams } from './utils.ts';
|
|
11
|
-
import { Connection, ConnectionContext } from './connection.ts';
|
|
12
|
-
import { ProtocolClientStream, ProtocolServerStream } from './stream.ts';
|
|
13
|
-
export declare class ProtocolError extends Error {
|
|
1
|
+
import type { ClientMessageType, ProtocolVersion, ServerMessageType } from '../common/enums.ts';
|
|
2
|
+
import type { BaseProtocolError, EncodeRPCStreams } from '../common/types.ts';
|
|
3
|
+
import type { MessageContext } from './types.ts';
|
|
4
|
+
export declare class ProtocolError extends Error implements BaseProtocolError {
|
|
14
5
|
code: string;
|
|
15
6
|
data?: any;
|
|
16
7
|
constructor(code: string, message?: string, data?: any);
|
|
@@ -22,107 +13,90 @@ export declare class ProtocolError extends Error {
|
|
|
22
13
|
data: any;
|
|
23
14
|
};
|
|
24
15
|
}
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
format: ProtocolFormat;
|
|
35
|
-
container: Container;
|
|
36
|
-
});
|
|
37
|
-
get(connectionId: string): {
|
|
38
|
-
connection: Connection;
|
|
39
|
-
context: ConnectionContext;
|
|
40
|
-
transport: ProtocolConnectionTransport;
|
|
41
|
-
};
|
|
42
|
-
add<T>(transport: ProtocolConnectionTransport, options: ConnectionOptions<T>, params: ResolveFormatParams): Promise<{
|
|
43
|
-
connection: Connection<T>;
|
|
44
|
-
context: ConnectionContext;
|
|
45
|
-
}>;
|
|
46
|
-
remove(connectionId: string): Promise<void>;
|
|
47
|
-
initialize(connection: Connection): Promise<void>;
|
|
48
|
-
}
|
|
49
|
-
export declare class ProtocolClientStreams {
|
|
50
|
-
private readonly connections;
|
|
51
|
-
constructor(connections: ProtocolConnections);
|
|
52
|
-
get(connectionId: string, streamId: number): ProtocolClientStream;
|
|
53
|
-
remove(connectionId: string, streamId: number): void;
|
|
54
|
-
add(connectionId: string, streamId: number, metadata: ProtocolBlobMetadata, read: Callback): ProtocolClientStream;
|
|
55
|
-
push(connectionId: string, streamId: number, chunk: ArrayBuffer): void;
|
|
56
|
-
end(connectionId: string, streamId: number): void;
|
|
57
|
-
abort(connectionId: string, streamId: number, error?: Error): void;
|
|
58
|
-
}
|
|
59
|
-
export declare class ProtocolServerStreams {
|
|
60
|
-
private readonly connections;
|
|
61
|
-
constructor(connections: ProtocolConnections);
|
|
62
|
-
get(connectionId: string, streamId: number): ProtocolServerStream;
|
|
63
|
-
add(connectionId: string, streamId: number, blob: ProtocolBlob): ProtocolServerStream;
|
|
64
|
-
remove(connectionId: string, streamId: number): void;
|
|
65
|
-
pull(connectionId: string, streamId: number): void;
|
|
66
|
-
abort(connectionId: string, streamId: number, error?: Error): void;
|
|
16
|
+
export declare abstract class ProtocolVersionInterface {
|
|
17
|
+
abstract version: ProtocolVersion;
|
|
18
|
+
abstract decodeMessage(context: MessageContext, buffer: ArrayBufferView): {
|
|
19
|
+
[K in keyof ClientMessageTypePayload]: {
|
|
20
|
+
type: K;
|
|
21
|
+
} & ClientMessageTypePayload[K];
|
|
22
|
+
}[keyof ClientMessageTypePayload];
|
|
23
|
+
abstract encodeMessage<T extends ServerMessageType = ServerMessageType>(context: MessageContext, messageType: T, payload: ServerMessageTypePayload[T]): ArrayBufferView;
|
|
24
|
+
protected encode(...chunks: (ArrayBuffer | ArrayBufferView)[]): ArrayBufferView;
|
|
67
25
|
}
|
|
68
|
-
export type
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
26
|
+
export type ServerMessageTypePayload = {
|
|
27
|
+
[ServerMessageType.RpcResponse]: {
|
|
28
|
+
callId: number;
|
|
29
|
+
result: any;
|
|
30
|
+
streams: EncodeRPCStreams;
|
|
31
|
+
error: any | null;
|
|
32
|
+
};
|
|
33
|
+
[ServerMessageType.RpcStreamAbort]: {
|
|
34
|
+
callId: number;
|
|
35
|
+
reason?: string;
|
|
36
|
+
};
|
|
37
|
+
[ServerMessageType.RpcStreamEnd]: {
|
|
38
|
+
callId: number;
|
|
39
|
+
};
|
|
40
|
+
[ServerMessageType.RpcStreamChunk]: {
|
|
41
|
+
callId: number;
|
|
42
|
+
chunk: ArrayBufferView;
|
|
43
|
+
};
|
|
44
|
+
[ServerMessageType.RpcStreamResponse]: {
|
|
45
|
+
callId: number;
|
|
46
|
+
};
|
|
47
|
+
[ServerMessageType.ClientStreamAbort]: {
|
|
48
|
+
streamId: number;
|
|
49
|
+
reason?: string;
|
|
50
|
+
};
|
|
51
|
+
[ServerMessageType.ClientStreamPull]: {
|
|
52
|
+
streamId: number;
|
|
53
|
+
size: number;
|
|
54
|
+
};
|
|
55
|
+
[ServerMessageType.ServerStreamAbort]: {
|
|
56
|
+
streamId: number;
|
|
57
|
+
reason?: string;
|
|
58
|
+
};
|
|
59
|
+
[ServerMessageType.ServerStreamEnd]: {
|
|
60
|
+
streamId: number;
|
|
61
|
+
};
|
|
62
|
+
[ServerMessageType.ServerStreamPush]: {
|
|
63
|
+
streamId: number;
|
|
64
|
+
chunk: ArrayBufferView;
|
|
65
|
+
};
|
|
72
66
|
};
|
|
73
|
-
export
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
api: ProtocolApi;
|
|
81
|
-
};
|
|
82
|
-
protected readonly options?: {
|
|
83
|
-
persistConnections?: {
|
|
84
|
-
timeout: number;
|
|
85
|
-
};
|
|
86
|
-
} | undefined;
|
|
87
|
-
constructor(application: {
|
|
88
|
-
logger: Logger;
|
|
89
|
-
format: ProtocolFormat;
|
|
90
|
-
container: Container;
|
|
91
|
-
registry: ProtocolRegistry;
|
|
92
|
-
api: ProtocolApi;
|
|
93
|
-
}, options?: {
|
|
94
|
-
persistConnections?: {
|
|
95
|
-
timeout: number;
|
|
67
|
+
export type ClientMessageTypePayload = {
|
|
68
|
+
[ClientMessageType.Rpc]: {
|
|
69
|
+
rpc: {
|
|
70
|
+
callId: number;
|
|
71
|
+
procedure: string;
|
|
72
|
+
payload: unknown;
|
|
73
|
+
streams?: EncodeRPCStreams;
|
|
96
74
|
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
removeServerStream(connectionId: string, streamId: number): void;
|
|
126
|
-
pullServerStream(connectionId: string, streamId: number): void;
|
|
127
|
-
abortServerStream(connectionId: string, streamId: number, error?: Error): void;
|
|
128
|
-
}
|
|
75
|
+
};
|
|
76
|
+
[ClientMessageType.RpcPull]: {
|
|
77
|
+
callId: number;
|
|
78
|
+
};
|
|
79
|
+
[ClientMessageType.RpcAbort]: {
|
|
80
|
+
callId: number;
|
|
81
|
+
reason?: string;
|
|
82
|
+
};
|
|
83
|
+
[ClientMessageType.ClientStreamPush]: {
|
|
84
|
+
streamId: number;
|
|
85
|
+
chunk: ArrayBufferView;
|
|
86
|
+
};
|
|
87
|
+
[ClientMessageType.ClientStreamEnd]: {
|
|
88
|
+
streamId: number;
|
|
89
|
+
};
|
|
90
|
+
[ClientMessageType.ClientStreamAbort]: {
|
|
91
|
+
streamId: number;
|
|
92
|
+
reason?: string;
|
|
93
|
+
};
|
|
94
|
+
[ClientMessageType.ServerStreamPull]: {
|
|
95
|
+
streamId: number;
|
|
96
|
+
size: number;
|
|
97
|
+
};
|
|
98
|
+
[ClientMessageType.ServerStreamAbort]: {
|
|
99
|
+
streamId: number;
|
|
100
|
+
reason?: string;
|
|
101
|
+
};
|
|
102
|
+
};
|