@nmtjs/http-client 0.14.2 → 0.14.4

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/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { ClientMessageType } from '@nmtjs/protocol';
2
- import type { BaseProtocol, ProtocolBaseClientCallOptions, ProtocolBaseTransformer, ProtocolClientCall, ProtocolSendMetadata, ProtocolTransport, ProtocolTransportEventMap } from '@nmtjs/protocol/client';
3
- import { EventEmitter, ProtocolTransportStatus } from '@nmtjs/protocol/client';
2
+ import type { BaseProtocol, ProtocolBaseClientCallOptions, ProtocolBaseTransformer, ProtocolClientCall, ProtocolSendMetadata } from '@nmtjs/protocol/client';
3
+ import { ProtocolTransport, ProtocolTransportStatus } from '@nmtjs/protocol/client';
4
4
  export type HttpClientTransportOptions = {
5
5
  /**
6
6
  * The origin of the server
@@ -9,10 +9,10 @@ export type HttpClientTransportOptions = {
9
9
  origin: string;
10
10
  debug?: boolean;
11
11
  };
12
- export declare class HttpClientTransport extends EventEmitter<ProtocolTransportEventMap> implements ProtocolTransport {
12
+ export declare class HttpClientTransport extends ProtocolTransport<HttpClientTransportOptions> {
13
13
  #private;
14
14
  protected readonly protocol: BaseProtocol;
15
- private readonly options;
15
+ protected readonly options: HttpClientTransportOptions;
16
16
  status: ProtocolTransportStatus;
17
17
  constructor(protocol: BaseProtocol, options: HttpClientTransportOptions);
18
18
  call(procedure: string, payload: any, options: ProtocolBaseClientCallOptions, transformer: ProtocolBaseTransformer): Promise<ProtocolClientCall>;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ClientError } from '@nmtjs/client';
2
2
  import { ErrorCode, ProtocolBlob } from '@nmtjs/protocol';
3
- import { EventEmitter, ProtocolServerBlobStream, ProtocolTransportStatus, } from '@nmtjs/protocol/client';
4
- export class HttpClientTransport extends EventEmitter {
3
+ import { ProtocolServerBlobStream, ProtocolTransport, ProtocolTransportStatus, } from '@nmtjs/protocol/client';
4
+ export class HttpClientTransport extends ProtocolTransport {
5
5
  protocol;
6
6
  options;
7
7
  #auth = null;
@@ -25,7 +25,9 @@ export class HttpClientTransport extends EventEmitter {
25
25
  method: 'POST',
26
26
  headers,
27
27
  credentials: 'include',
28
- body: isBlob ? payload.source : transformer.encodeRPC(procedure, payload),
28
+ body: isBlob
29
+ ? payload.source
30
+ : this.protocol.format.encode(transformer.encodeRPC(procedure, payload)),
29
31
  signal: call.signal,
30
32
  // @ts-expect-error
31
33
  duplex: 'half',
@@ -37,7 +39,7 @@ export class HttpClientTransport extends EventEmitter {
37
39
  if (isBlob) {
38
40
  const contentLength = response.headers.get('content-length');
39
41
  const size = contentLength
40
- ? Number.parseInt(contentLength) || undefined
42
+ ? Number.parseInt(contentLength, 10) || undefined
41
43
  : undefined;
42
44
  const type = response.headers.get('content-type') || 'application/octet-stream';
43
45
  const stream = new ProtocolServerBlobStream(-1, { size, type });
package/package.json CHANGED
@@ -9,21 +9,21 @@
9
9
  }
10
10
  },
11
11
  "dependencies": {
12
- "@nmtjs/client": "0.14.2",
13
- "@nmtjs/protocol": "0.14.2",
14
- "@nmtjs/common": "0.14.2"
12
+ "@nmtjs/client": "0.14.4",
13
+ "@nmtjs/common": "0.14.4",
14
+ "@nmtjs/protocol": "0.14.4"
15
15
  },
16
16
  "peerDependencies": {
17
- "@nmtjs/client": "0.14.2",
18
- "@nmtjs/common": "0.14.2",
19
- "@nmtjs/protocol": "0.14.2"
17
+ "@nmtjs/common": "0.14.4",
18
+ "@nmtjs/client": "0.14.4",
19
+ "@nmtjs/protocol": "0.14.4"
20
20
  },
21
21
  "files": [
22
22
  "dist",
23
23
  "LICENSE.md",
24
24
  "README.md"
25
25
  ],
26
- "version": "0.14.2",
26
+ "version": "0.14.4",
27
27
  "scripts": {
28
28
  "build": "tsc",
29
29
  "type-check": "tsc --noEmit"