@nmtjs/client 0.14.5 → 0.15.0-beta.10
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/clients/runtime.d.ts +20 -0
- package/dist/clients/runtime.js +81 -0
- package/dist/clients/runtime.js.map +1 -0
- package/dist/clients/static.d.ts +13 -0
- package/dist/clients/static.js +27 -0
- package/dist/clients/static.js.map +1 -0
- package/dist/core.d.ts +71 -0
- package/dist/core.js +426 -0
- package/dist/core.js.map +1 -0
- package/dist/events.d.ts +16 -0
- package/dist/events.js +34 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/streams.d.ts +26 -0
- package/dist/streams.js +101 -0
- package/dist/streams.js.map +1 -0
- package/dist/transformers.d.ts +4 -0
- package/dist/transformers.js +9 -0
- package/dist/transformers.js.map +1 -0
- package/dist/transport.d.ts +53 -0
- package/dist/transport.js +2 -0
- package/dist/transport.js.map +1 -0
- package/dist/types.d.ts +41 -30
- package/dist/types.js +2 -1
- package/dist/types.js.map +1 -0
- package/package.json +17 -25
- package/src/clients/runtime.ts +133 -0
- package/src/clients/static.ts +77 -0
- package/src/core.ts +648 -0
- package/src/events.ts +70 -0
- package/src/index.ts +5 -0
- package/src/streams.ts +131 -0
- package/src/transformers.ts +8 -0
- package/src/transport.ts +71 -0
- package/src/types.ts +145 -0
- package/dist/common.d.ts +0 -38
- package/dist/common.js +0 -60
- package/dist/runtime.d.ts +0 -21
- package/dist/runtime.js +0 -105
- package/dist/static.d.ts +0 -9
- package/dist/static.js +0 -27
package/dist/static.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ProtocolBaseTransformer } from '@nmtjs/protocol/client';
|
|
2
|
-
import { BaseClient } from "./common.js";
|
|
3
|
-
export class StaticClient extends BaseClient {
|
|
4
|
-
transformer;
|
|
5
|
-
constructor(...args) {
|
|
6
|
-
super(...args);
|
|
7
|
-
this.transformer = new ProtocolBaseTransformer();
|
|
8
|
-
this.callers = this.createProxy(Object.create(null));
|
|
9
|
-
}
|
|
10
|
-
createProxy(target, path = []) {
|
|
11
|
-
return new Proxy(target, {
|
|
12
|
-
get: (obj, prop) => {
|
|
13
|
-
// `await client.call.something` or `await client.call.something.nested`
|
|
14
|
-
// without explicitly calling a function implicitly calls .then() on a target
|
|
15
|
-
// FIXME: this basically makes "then" a reserved word for static Client
|
|
16
|
-
if (prop === 'then')
|
|
17
|
-
return obj;
|
|
18
|
-
const newPath = [...path, String(prop)];
|
|
19
|
-
const caller = (payload, options) => this._call(newPath.join('/'), payload, {
|
|
20
|
-
...options,
|
|
21
|
-
timeout: options?.timeout ?? this.options.timeout,
|
|
22
|
-
});
|
|
23
|
-
return this.createProxy(caller, newPath);
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|