@nmtjs/protocol 0.14.3 → 0.14.5
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/client/stream.d.ts +6 -3
- package/dist/client/stream.js +3 -0
- package/dist/common/blob.d.ts +2 -2
- package/dist/server/format.d.ts +1 -1
- package/dist/server/format.js +1 -1
- package/dist/server/protocol.d.ts +14 -5
- package/dist/server/protocol.js +3 -1
- package/dist/server/transport.d.ts +2 -2
- package/dist/server/types.d.ts +6 -6
- package/dist/server/utils.d.ts +2 -2
- package/package.json +7 -7
package/dist/client/stream.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { ProtocolBlobMetadata } from '../common/blob.ts';
|
|
2
|
-
|
|
1
|
+
import type { ProtocolBlobInterface, ProtocolBlobMetadata } from '../common/blob.ts';
|
|
2
|
+
import { BlobKey } from '../common/blob.ts';
|
|
3
|
+
export declare class ProtocolClientBlobStream extends TransformStream<any, ArrayBuffer> implements ProtocolBlobInterface {
|
|
3
4
|
#private;
|
|
4
5
|
readonly source: ReadableStream;
|
|
5
6
|
readonly id: number;
|
|
6
7
|
readonly metadata: ProtocolBlobMetadata;
|
|
8
|
+
readonly [BlobKey] = true;
|
|
7
9
|
constructor(source: ReadableStream, id: number, metadata: ProtocolBlobMetadata);
|
|
8
10
|
read(size: number): Promise<ArrayBuffer | null>;
|
|
9
11
|
abort(error?: Error): void;
|
|
@@ -21,8 +23,9 @@ export declare class ProtocolServerStream<T = any> extends TransformStream<any,
|
|
|
21
23
|
end(): Promise<void>;
|
|
22
24
|
abort(error?: Error): Promise<void>;
|
|
23
25
|
}
|
|
24
|
-
export declare class ProtocolServerBlobStream extends ProtocolServerStream<ArrayBuffer> {
|
|
26
|
+
export declare class ProtocolServerBlobStream extends ProtocolServerStream<ArrayBuffer> implements ProtocolBlobInterface {
|
|
25
27
|
readonly id: number;
|
|
26
28
|
readonly metadata: ProtocolBlobMetadata;
|
|
29
|
+
readonly [BlobKey] = true;
|
|
27
30
|
constructor(id: number, metadata: ProtocolBlobMetadata, options?: Transformer<any, ArrayBuffer>);
|
|
28
31
|
}
|
package/dist/client/stream.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { defer } from '@nmtjs/common';
|
|
2
2
|
import { concat, encodeText } from "../common/binary.js";
|
|
3
|
+
import { BlobKey } from "../common/blob.js";
|
|
3
4
|
export class ProtocolClientBlobStream extends TransformStream {
|
|
4
5
|
source;
|
|
5
6
|
id;
|
|
6
7
|
metadata;
|
|
8
|
+
[BlobKey] = true;
|
|
7
9
|
#queue;
|
|
8
10
|
#reader;
|
|
9
11
|
constructor(source, id, metadata) {
|
|
@@ -87,6 +89,7 @@ export class ProtocolServerStream extends TransformStream {
|
|
|
87
89
|
export class ProtocolServerBlobStream extends ProtocolServerStream {
|
|
88
90
|
id;
|
|
89
91
|
metadata;
|
|
92
|
+
[BlobKey] = true;
|
|
90
93
|
constructor(id, metadata, options) {
|
|
91
94
|
super(options);
|
|
92
95
|
this.id = id;
|
package/dist/common/blob.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ export declare const BlobKey: unique symbol;
|
|
|
2
2
|
export type BlobKey = typeof BlobKey;
|
|
3
3
|
export type ProtocolBlobMetadata = {
|
|
4
4
|
type: string;
|
|
5
|
-
size?: number;
|
|
6
|
-
filename?: string;
|
|
5
|
+
size?: number | undefined;
|
|
6
|
+
filename?: string | undefined;
|
|
7
7
|
};
|
|
8
8
|
export interface ProtocolBlobInterface {
|
|
9
9
|
readonly metadata: ProtocolBlobMetadata;
|
package/dist/server/format.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare abstract class BaseServerFormat implements BaseServerDecoder, Bas
|
|
|
30
30
|
abstract decodeRPC(buffer: ArrayBuffer, context: DecodeRPCContext<ProtocolClientStream>): ProtocolRPC;
|
|
31
31
|
}
|
|
32
32
|
export declare const parseContentTypes: (types: string) => string[];
|
|
33
|
-
export declare class
|
|
33
|
+
export declare class ProtocolFormat {
|
|
34
34
|
decoders: Map<Pattern, BaseServerDecoder>;
|
|
35
35
|
encoders: Map<Pattern, BaseServerEncoder>;
|
|
36
36
|
constructor(formats: BaseServerFormat[]);
|
package/dist/server/format.js
CHANGED
|
@@ -4,7 +4,7 @@ import type { ProtocolBlob, ProtocolBlobMetadata } from '../common/blob.ts';
|
|
|
4
4
|
import type { ProtocolRPC } from '../common/types.ts';
|
|
5
5
|
import type { ProtocolApi, ProtocolApiCallOptions } from './api.ts';
|
|
6
6
|
import type { ConnectionOptions } from './connection.ts';
|
|
7
|
-
import type {
|
|
7
|
+
import type { ProtocolFormat } from './format.ts';
|
|
8
8
|
import type { ProtocolRegistry } from './registry.ts';
|
|
9
9
|
import type { Transport } from './transport.ts';
|
|
10
10
|
import type { ResolveFormatParams } from './utils.ts';
|
|
@@ -31,7 +31,7 @@ export declare class ProtocolConnections {
|
|
|
31
31
|
constructor(application: {
|
|
32
32
|
logger: Logger;
|
|
33
33
|
registry: ProtocolRegistry;
|
|
34
|
-
format:
|
|
34
|
+
format: ProtocolFormat;
|
|
35
35
|
container: Container;
|
|
36
36
|
});
|
|
37
37
|
get(connectionId: string): {
|
|
@@ -74,18 +74,27 @@ export declare class Protocol {
|
|
|
74
74
|
#private;
|
|
75
75
|
protected readonly application: {
|
|
76
76
|
logger: Logger;
|
|
77
|
-
format:
|
|
77
|
+
format: ProtocolFormat;
|
|
78
78
|
container: Container;
|
|
79
79
|
registry: ProtocolRegistry;
|
|
80
80
|
api: ProtocolApi;
|
|
81
81
|
};
|
|
82
|
+
protected readonly options?: {
|
|
83
|
+
persistConnections?: {
|
|
84
|
+
timeout: number;
|
|
85
|
+
};
|
|
86
|
+
} | undefined;
|
|
82
87
|
constructor(application: {
|
|
83
88
|
logger: Logger;
|
|
84
|
-
format:
|
|
89
|
+
format: ProtocolFormat;
|
|
85
90
|
container: Container;
|
|
86
91
|
registry: ProtocolRegistry;
|
|
87
92
|
api: ProtocolApi;
|
|
88
|
-
}
|
|
93
|
+
}, options?: {
|
|
94
|
+
persistConnections?: {
|
|
95
|
+
timeout: number;
|
|
96
|
+
};
|
|
97
|
+
} | undefined);
|
|
89
98
|
call(options: ProtocolApiCallOptions): Promise<import("./api.ts").ProtocolApiCallResult>;
|
|
90
99
|
rpc(connectionId: string, rpc: ProtocolRPC, params?: ProtocolRPCOptions): Promise<void>;
|
|
91
100
|
rpcRaw(connectionId: string, buffer: ArrayBuffer, params?: ProtocolRPCOptions): Promise<void>;
|
package/dist/server/protocol.js
CHANGED
|
@@ -158,11 +158,13 @@ export class ProtocolServerStreams {
|
|
|
158
158
|
}
|
|
159
159
|
export class Protocol {
|
|
160
160
|
application;
|
|
161
|
+
options;
|
|
161
162
|
#connections;
|
|
162
163
|
#clientStreams;
|
|
163
164
|
#serverStreams;
|
|
164
|
-
constructor(application) {
|
|
165
|
+
constructor(application, options) {
|
|
165
166
|
this.application = application;
|
|
167
|
+
this.options = options;
|
|
166
168
|
this.#connections = new ProtocolConnections(this.application);
|
|
167
169
|
this.#clientStreams = new ProtocolClientStreams(this.#connections);
|
|
168
170
|
this.#serverStreams = new ProtocolServerStreams(this.#connections);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BasePlugin, PluginContext } from '@nmtjs/core';
|
|
2
2
|
import type { ServerMessageType } from '../common/enums.ts';
|
|
3
3
|
import type { Connection } from './connection.ts';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ProtocolFormat } from './format.ts';
|
|
5
5
|
import type { Protocol } from './protocol.ts';
|
|
6
6
|
import type { ProtocolRegistry } from './registry.ts';
|
|
7
7
|
import type { ProtocolSendMetadata } from './types.ts';
|
|
@@ -14,7 +14,7 @@ export interface Transport<T = unknown> {
|
|
|
14
14
|
export interface TransportPluginContext extends PluginContext {
|
|
15
15
|
protocol: Protocol;
|
|
16
16
|
registry: ProtocolRegistry;
|
|
17
|
-
format:
|
|
17
|
+
format: ProtocolFormat;
|
|
18
18
|
}
|
|
19
19
|
export interface TransportPlugin<Type = unknown, Options = unknown> extends BasePlugin<Transport<Type>, Options, TransportPluginContext> {
|
|
20
20
|
[kTransportPlugin]: any;
|
package/dist/server/types.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PlainType } from '@nmtjs/type/_plain';
|
|
2
|
+
import type { ProtocolBlobInterface } from '../common/blob.ts';
|
|
2
3
|
import type { ProtocolClientStream } from './stream.ts';
|
|
3
|
-
export type InputType<T> = T extends ProtocolBlobInterface ? ProtocolClientStream : T extends
|
|
4
|
-
[
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
[K in keyof T]: OutputType<T[K]>;
|
|
4
|
+
export type InputType<T> = T extends ProtocolBlobInterface ? ProtocolClientStream : T extends {
|
|
5
|
+
[PlainType]?: true;
|
|
6
|
+
} ? {
|
|
7
|
+
[K in keyof Omit<T, PlainType>]: InputType<T[K]>;
|
|
8
8
|
} : T;
|
|
9
9
|
export type ProtocolSendMetadata = {
|
|
10
10
|
streamId?: number;
|
package/dist/server/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ProtocolFormat } from './format.ts';
|
|
2
2
|
export type ResolveFormatParams = {
|
|
3
3
|
contentType?: string | null;
|
|
4
4
|
acceptType?: string | null;
|
|
@@ -9,7 +9,7 @@ export declare class UnsupportedContentTypeError extends UnsupportedFormatError
|
|
|
9
9
|
}
|
|
10
10
|
export declare class UnsupportedAcceptTypeError extends UnsupportedFormatError {
|
|
11
11
|
}
|
|
12
|
-
export declare const getFormat: (format:
|
|
12
|
+
export declare const getFormat: (format: ProtocolFormat, { acceptType, contentType }: ResolveFormatParams) => {
|
|
13
13
|
encoder: import("./format.ts").BaseServerEncoder;
|
|
14
14
|
decoder: import("./format.ts").BaseServerDecoder;
|
|
15
15
|
};
|
package/package.json
CHANGED
|
@@ -19,21 +19,21 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@nmtjs/common": "0.14.
|
|
23
|
-
"@nmtjs/type": "0.14.
|
|
24
|
-
"@nmtjs/core": "0.14.
|
|
22
|
+
"@nmtjs/common": "0.14.5",
|
|
23
|
+
"@nmtjs/type": "0.14.5",
|
|
24
|
+
"@nmtjs/core": "0.14.5"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@nmtjs/
|
|
28
|
-
"@nmtjs/
|
|
29
|
-
"@nmtjs/core": "0.14.
|
|
27
|
+
"@nmtjs/common": "0.14.5",
|
|
28
|
+
"@nmtjs/type": "0.14.5",
|
|
29
|
+
"@nmtjs/core": "0.14.5"
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
33
33
|
"LICENSE.md",
|
|
34
34
|
"README.md"
|
|
35
35
|
],
|
|
36
|
-
"version": "0.14.
|
|
36
|
+
"version": "0.14.5",
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "tsc",
|
|
39
39
|
"type-check": "tsc --noEmit"
|