core-3nweb-client-lib 0.31.0 → 0.31.2
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.
|
@@ -11,6 +11,7 @@ export interface TransformOpts {
|
|
|
11
11
|
packReply?: ((reply: any) => PassedDatum | undefined) | 'noop';
|
|
12
12
|
}
|
|
13
13
|
export declare function wrapReqReplySrvMethod<T extends object, M extends keyof T>(srv: T, method: M, transforms?: TransformOpts): ExposedFn;
|
|
14
|
-
export declare function wrapReqReplyFunc(srv: object
|
|
14
|
+
export declare function wrapReqReplyFunc(srv: object, func: HandleReqReplyCall, transforms?: TransformOpts): ExposedFn;
|
|
15
|
+
export declare function wrapReqReplyFunc(func: HandleReqReplyCall, transforms?: TransformOpts): ExposedFn;
|
|
15
16
|
export declare function wrapObservingFunc<TEvent>(srv: object | undefined, func: HandleObservingCall<TEvent>, transforms?: TransformOpts): ExposedFn;
|
|
16
17
|
export {};
|
|
@@ -24,12 +24,24 @@ const json_n_binary_1 = require("./json-n-binary");
|
|
|
24
24
|
function wrapReqReplySrvMethod(srv, method, transforms) {
|
|
25
25
|
return wrapReqReplyFunc(srv, srv[method], transforms);
|
|
26
26
|
}
|
|
27
|
-
function wrapReqReplyFunc(
|
|
27
|
+
function wrapReqReplyFunc(srvOrFn, funcOrTransforms, transforms) {
|
|
28
|
+
let srv;
|
|
29
|
+
let func;
|
|
30
|
+
if (typeof srvOrFn === 'function') {
|
|
31
|
+
srv = undefined;
|
|
32
|
+
func = srvOrFn;
|
|
33
|
+
transforms = funcOrTransforms;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
srv = srvOrFn;
|
|
37
|
+
func = funcOrTransforms;
|
|
38
|
+
}
|
|
28
39
|
return buf => {
|
|
29
40
|
const args = argsFromBuffer(buf, transforms);
|
|
30
|
-
|
|
41
|
+
let promise = (args ?
|
|
31
42
|
func.call(srv, ...args) :
|
|
32
|
-
func.call(srv))
|
|
43
|
+
func.call(srv));
|
|
44
|
+
promise = promise === null || promise === void 0 ? void 0 : promise.then(result => resultToBuffer(result, transforms));
|
|
33
45
|
return { promise };
|
|
34
46
|
};
|
|
35
47
|
}
|
|
@@ -22,7 +22,7 @@ const error_1 = require("../lib-common/exceptions/error");
|
|
|
22
22
|
const caller_side_wrap_1 = require("./json-ipc-wrapping/caller-side-wrap");
|
|
23
23
|
const service_side_wrap_1 = require("./json-ipc-wrapping/service-side-wrap");
|
|
24
24
|
function exposeLogger(fn) {
|
|
25
|
-
return (0, service_side_wrap_1.wrapReqReplyFunc)(
|
|
25
|
+
return (0, service_side_wrap_1.wrapReqReplyFunc)(fn);
|
|
26
26
|
}
|
|
27
27
|
function makeLogCaller(caller, path) {
|
|
28
28
|
const log = (0, caller_side_wrap_1.makeReqRepFuncCaller)(caller, path);
|