core-3nweb-client-lib 0.24.3 → 0.24.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/build/core-ipc/common-caps.d.ts +1 -0
- package/build/core-ipc/common-caps.js +11 -1
- package/build/core-ipc/generic.d.ts +1 -0
- package/build/core-ipc/generic.js +24 -3
- package/build/ipc-via-protobuf/connector-clients-side.d.ts +3 -1
- package/build/ipc-via-protobuf/connector-clients-side.js +16 -3
- package/build/ipc-via-protobuf/connector.d.ts +3 -2
- package/build/ipc-via-protobuf/connector.js +6 -5
- package/build/ipc-via-protobuf/storage-cap.d.ts +1 -0
- package/build/ipc-via-protobuf/storage-cap.js +10 -2
- package/package.json +1 -1
|
@@ -3,4 +3,5 @@ import { ClientCAPsWraps, CAPsExposures, TypeDifference } from "./generic";
|
|
|
3
3
|
declare type W3N = web3n.caps.common.W3N;
|
|
4
4
|
export declare function exposeW3N<T extends W3N>(coreSide: ExposedServices, w3n: T, extraCAPs?: CAPsExposures<TypeDifference<T, W3N>>): void;
|
|
5
5
|
export declare function makeW3Nclient<T extends W3N>(clientSide: Caller, extraCAPs?: ClientCAPsWraps<TypeDifference<T, W3N>>): T;
|
|
6
|
+
export declare function promiseW3Nclient<T extends W3N>(clientSide: Caller, extraCAPs?: ClientCAPsWraps<TypeDifference<T, W3N>>): Promise<T>;
|
|
6
7
|
export {};
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.makeW3Nclient = exports.exposeW3N = void 0;
|
|
19
|
+
exports.promiseW3Nclient = exports.makeW3Nclient = exports.exposeW3N = void 0;
|
|
20
20
|
const connector_1 = require("../ipc-via-protobuf/connector");
|
|
21
21
|
const log_cap_1 = require("../ipc-via-protobuf/log-cap");
|
|
22
22
|
const asmail_cap_1 = require("../ipc-via-protobuf/asmail-cap");
|
|
@@ -46,4 +46,14 @@ function makeW3Nclient(clientSide, extraCAPs) {
|
|
|
46
46
|
return generic_1.makeClientSide(clientSide, mainCAPs, extraCAPs);
|
|
47
47
|
}
|
|
48
48
|
exports.makeW3Nclient = makeW3Nclient;
|
|
49
|
+
function promiseW3Nclient(clientSide, extraCAPs) {
|
|
50
|
+
const mainCAPs = {
|
|
51
|
+
log: log_cap_1.makeLogCaller,
|
|
52
|
+
mail: asmail_cap_1.makeASMailCaller,
|
|
53
|
+
mailerid: mailerid_1.makeMailerIdCaller,
|
|
54
|
+
storage: storage_cap_1.promiseStorageCaller,
|
|
55
|
+
};
|
|
56
|
+
return generic_1.promiseClientSide(clientSide, mainCAPs, extraCAPs);
|
|
57
|
+
}
|
|
58
|
+
exports.promiseW3Nclient = promiseW3Nclient;
|
|
49
59
|
Object.freeze(exports);
|
|
@@ -11,3 +11,4 @@ export declare type ClientCAPsWraps<T> = {
|
|
|
11
11
|
[cap in keyof Required<T>]: MakeCapClient;
|
|
12
12
|
};
|
|
13
13
|
export declare function makeClientSide<T extends W3N, W3N extends object>(clientSide: Caller, mainCAPs: ClientCAPsWraps<W3N>, extraCAPs: ClientCAPsWraps<TypeDifference<T, W3N>> | undefined): T;
|
|
14
|
+
export declare function promiseClientSide<T extends W3N, W3N extends object>(clientSide: Caller, mainCAPs: ClientCAPsWraps<W3N>, extraCAPs: ClientCAPsWraps<TypeDifference<T, W3N>> | undefined): Promise<T>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2021 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2021 - 2022 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.makeClientSide = exports.exposeCAPs = void 0;
|
|
19
|
+
exports.promiseClientSide = exports.makeClientSide = exports.exposeCAPs = void 0;
|
|
20
20
|
const connector_1 = require("../ipc-via-protobuf/connector");
|
|
21
21
|
const assert_1 = require("../lib-common/assert");
|
|
22
22
|
function exposeCAPs(coreSide, w3n, mainCAPs, extraCAPs) {
|
|
@@ -40,6 +40,7 @@ function addCAPsInExposure(expW3N, coreSide, w3n, capExposures) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
function makeClientSide(clientSide, mainCAPs, extraCAPs) {
|
|
43
|
+
assert_1.assert(!!clientSide.listObj);
|
|
43
44
|
const objPath = [connector_1.W3N_NAME];
|
|
44
45
|
const lstOfCAPs = clientSide.listObj(objPath);
|
|
45
46
|
const w3n = {};
|
|
@@ -51,7 +52,6 @@ function makeClientSide(clientSide, mainCAPs, extraCAPs) {
|
|
|
51
52
|
w3n[cap] = makeCap(clientSide, capObjPath);
|
|
52
53
|
}
|
|
53
54
|
else if (extraCAPs) {
|
|
54
|
-
assert_1.assert(!!exposeCAPs);
|
|
55
55
|
const makeCap = extraCAPs[cap];
|
|
56
56
|
assert_1.assert(typeof makeCap === 'function');
|
|
57
57
|
w3n[cap] = makeCap(clientSide, capObjPath);
|
|
@@ -60,4 +60,25 @@ function makeClientSide(clientSide, mainCAPs, extraCAPs) {
|
|
|
60
60
|
return w3n;
|
|
61
61
|
}
|
|
62
62
|
exports.makeClientSide = makeClientSide;
|
|
63
|
+
async function promiseClientSide(clientSide, mainCAPs, extraCAPs) {
|
|
64
|
+
assert_1.assert(!!clientSide.listObjAsync);
|
|
65
|
+
const objPath = [connector_1.W3N_NAME];
|
|
66
|
+
const lstOfCAPs = (await clientSide.listObjAsync(objPath));
|
|
67
|
+
const w3n = {};
|
|
68
|
+
for (const cap of lstOfCAPs) {
|
|
69
|
+
const capObjPath = objPath.concat(cap);
|
|
70
|
+
if (mainCAPs[cap]) {
|
|
71
|
+
const makeCap = mainCAPs[cap];
|
|
72
|
+
assert_1.assert(typeof makeCap === 'function');
|
|
73
|
+
w3n[cap] = await makeCap(clientSide, capObjPath);
|
|
74
|
+
}
|
|
75
|
+
else if (extraCAPs) {
|
|
76
|
+
const makeCap = extraCAPs[cap];
|
|
77
|
+
assert_1.assert(typeof makeCap === 'function');
|
|
78
|
+
w3n[cap] = await makeCap(clientSide, capObjPath);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return w3n;
|
|
82
|
+
}
|
|
83
|
+
exports.promiseClientSide = promiseClientSide;
|
|
63
84
|
Object.freeze(exports);
|
|
@@ -4,12 +4,13 @@ import { ClientsSide, EnvelopeBody, Envelope, IPCException, Caller } from "./con
|
|
|
4
4
|
export declare class ClientsSideImpl implements ClientsSide {
|
|
5
5
|
private readonly sendMsg;
|
|
6
6
|
private readonly syncReqToListObj;
|
|
7
|
+
private readonly asyncReqToListObj;
|
|
7
8
|
private readonly fnCalls;
|
|
8
9
|
private fnCallCounter;
|
|
9
10
|
private readonly weakRefs;
|
|
10
11
|
private readonly srvRefs;
|
|
11
12
|
private isStopped;
|
|
12
|
-
constructor(sendMsg: (msg: Envelope) => void, syncReqToListObj:
|
|
13
|
+
constructor(sendMsg: (msg: Envelope) => void, syncReqToListObj: Caller['listObj'], asyncReqToListObj: Caller['listObjAsync']);
|
|
13
14
|
stop(exc: IPCException): void;
|
|
14
15
|
private sendCallCancellation;
|
|
15
16
|
processInterimCallReply(fnCallNum: number, body: EnvelopeBody): void;
|
|
@@ -25,4 +26,5 @@ export declare class ClientsSideImpl implements ClientsSide {
|
|
|
25
26
|
private sendObjDropMsg;
|
|
26
27
|
srvRefOf(clientObj: any): ObjectReference<any>;
|
|
27
28
|
listObj(path: string[]): string[];
|
|
29
|
+
listObjAsync(path: string[]): Promise<string[]>;
|
|
28
30
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2020 -
|
|
3
|
+
Copyright (C) 2020 - 2022 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -24,14 +24,19 @@ const connector_1 = require("./connector");
|
|
|
24
24
|
// XXX can have an optimized use of WeakRef and FinalizationRegistry, when
|
|
25
25
|
// these are available.
|
|
26
26
|
class ClientsSideImpl {
|
|
27
|
-
constructor(sendMsg, syncReqToListObj) {
|
|
27
|
+
constructor(sendMsg, syncReqToListObj, asyncReqToListObj) {
|
|
28
28
|
this.sendMsg = sendMsg;
|
|
29
29
|
this.syncReqToListObj = syncReqToListObj;
|
|
30
|
+
this.asyncReqToListObj = asyncReqToListObj;
|
|
30
31
|
this.fnCalls = new Map();
|
|
31
32
|
this.fnCallCounter = 1;
|
|
32
33
|
this.weakRefs = new Set();
|
|
33
34
|
this.srvRefs = new WeakMap();
|
|
34
35
|
this.isStopped = false;
|
|
36
|
+
if ((this.asyncReqToListObj && this.syncReqToListObj)
|
|
37
|
+
|| (!this.asyncReqToListObj && !this.syncReqToListObj)) {
|
|
38
|
+
throw new Error(`Expect either sync or async obj listing function.`);
|
|
39
|
+
}
|
|
35
40
|
Object.seal(this);
|
|
36
41
|
}
|
|
37
42
|
stop(exc) {
|
|
@@ -126,7 +131,9 @@ class ClientsSideImpl {
|
|
|
126
131
|
}
|
|
127
132
|
caller() {
|
|
128
133
|
const callerWrap = {
|
|
129
|
-
listObj: this.listObj.bind(this),
|
|
134
|
+
listObj: (this.syncReqToListObj ? this.listObj.bind(this) : undefined),
|
|
135
|
+
listObjAsync: (this.asyncReqToListObj ?
|
|
136
|
+
this.listObjAsync.bind(this) : undefined),
|
|
130
137
|
registerClientDrop: this.registerClientDrop.bind(this),
|
|
131
138
|
srvRefOf: this.srvRefOf.bind(this),
|
|
132
139
|
startObservableCall: this.startObservableCall.bind(this),
|
|
@@ -201,6 +208,12 @@ class ClientsSideImpl {
|
|
|
201
208
|
}
|
|
202
209
|
return this.syncReqToListObj(path);
|
|
203
210
|
}
|
|
211
|
+
listObjAsync(path) {
|
|
212
|
+
if (this.isStopped) {
|
|
213
|
+
throw connector_1.makeIPCException({ 'ipcNotConnected': true });
|
|
214
|
+
}
|
|
215
|
+
return this.asyncReqToListObj(path);
|
|
216
|
+
}
|
|
204
217
|
}
|
|
205
218
|
exports.ClientsSideImpl = ClientsSideImpl;
|
|
206
219
|
Object.freeze(ClientsSideImpl.prototype);
|
|
@@ -21,7 +21,8 @@ export interface Caller {
|
|
|
21
21
|
startObservableCall(path: string[], req: EnvelopeBody, obs: Subject<EnvelopeBody>): () => void;
|
|
22
22
|
registerClientDrop(o: any, srvRef: ObjectReference<any>): void;
|
|
23
23
|
srvRefOf(clientObj: any): ObjectReference<any>;
|
|
24
|
-
listObj(path: string[])
|
|
24
|
+
listObj?: (path: string[]) => string[];
|
|
25
|
+
listObjAsync?: (path: string[]) => Promise<string[]>;
|
|
25
26
|
}
|
|
26
27
|
export interface ClientsSide {
|
|
27
28
|
caller(): Caller;
|
|
@@ -35,7 +36,7 @@ export declare class ObjectsConnector {
|
|
|
35
36
|
private messagingProc;
|
|
36
37
|
private readonly services;
|
|
37
38
|
private readonly clients;
|
|
38
|
-
constructor(msgSink: Observer<Envelope>, msgSrc: Observable<Envelope>, sides: 'clients' | 'services' | 'clients-and-services',
|
|
39
|
+
constructor(msgSink: Observer<Envelope>, msgSrc: Observable<Envelope>, sides: 'clients' | 'services' | 'clients-and-services', listObj?: Caller['listObj'], listObjAsync?: Caller['listObjAsync']);
|
|
39
40
|
get caller(): Caller;
|
|
40
41
|
get exposedServices(): ExposedServices;
|
|
41
42
|
private stop;
|
|
@@ -27,12 +27,12 @@ function makeServicesSide(sendMsg) {
|
|
|
27
27
|
const srvClassFn = require('./connector-services-side').ServicesSideImpl;
|
|
28
28
|
return new srvClassFn(sendMsg);
|
|
29
29
|
}
|
|
30
|
-
function makeClientsSide(sendMsg, syncReqToListObj) {
|
|
30
|
+
function makeClientsSide(sendMsg, syncReqToListObj, asyncReqToListObj) {
|
|
31
31
|
const classFn = require('./connector-clients-side').ClientsSideImpl;
|
|
32
32
|
return new classFn(sendMsg, syncReqToListObj);
|
|
33
33
|
}
|
|
34
34
|
class ObjectsConnector {
|
|
35
|
-
constructor(msgSink, msgSrc, sides,
|
|
35
|
+
constructor(msgSink, msgSrc, sides, listObj, listObjAsync) {
|
|
36
36
|
this.msgSink = msgSink;
|
|
37
37
|
this.messagingProc = undefined;
|
|
38
38
|
this.messagingProc = msgSrc.subscribe({
|
|
@@ -49,10 +49,11 @@ class ObjectsConnector {
|
|
|
49
49
|
this.services = (((sides === 'services') || (sides === 'clients-and-services')) ?
|
|
50
50
|
makeServicesSide(sendMsg) : undefined);
|
|
51
51
|
if ((sides === 'clients') || (sides === 'clients-and-services')) {
|
|
52
|
-
if (!
|
|
53
|
-
|
|
52
|
+
if ((!listObj && !listObjAsync)
|
|
53
|
+
|| (listObj && listObjAsync)) {
|
|
54
|
+
throw new Error(`Client side needs either listObj, or listObjAsync argument`);
|
|
54
55
|
}
|
|
55
|
-
this.clients = makeClientsSide(sendMsg,
|
|
56
|
+
this.clients = makeClientsSide(sendMsg, listObj, listObjAsync);
|
|
56
57
|
}
|
|
57
58
|
else {
|
|
58
59
|
this.clients = undefined;
|
|
@@ -2,4 +2,5 @@ import { ExposedObj, Caller, ExposedServices } from './connector';
|
|
|
2
2
|
declare type Storage = web3n.storage.Service;
|
|
3
3
|
export declare function exposeStorageCAP(cap: Storage, expServices: ExposedServices): ExposedObj<Storage>;
|
|
4
4
|
export declare function makeStorageCaller(caller: Caller, objPath: string[]): Storage;
|
|
5
|
+
export declare function promiseStorageCaller(caller: Caller, objPath: string[]): Promise<Storage>;
|
|
5
6
|
export {};
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.makeStorageCaller = exports.exposeStorageCAP = void 0;
|
|
19
|
+
exports.promiseStorageCaller = exports.makeStorageCaller = exports.exposeStorageCAP = void 0;
|
|
20
20
|
const protobuf_msg_1 = require("./protobuf-msg");
|
|
21
21
|
const fs_1 = require("./fs");
|
|
22
22
|
const protobuf_type_1 = require("../lib-client/protobuf-type");
|
|
@@ -37,6 +37,15 @@ function exposeStorageCAP(cap, expServices) {
|
|
|
37
37
|
exports.exposeStorageCAP = exposeStorageCAP;
|
|
38
38
|
function makeStorageCaller(caller, objPath) {
|
|
39
39
|
const lstStorageCAP = caller.listObj(objPath);
|
|
40
|
+
return instantiateStorageCaller(caller, lstStorageCAP, objPath);
|
|
41
|
+
}
|
|
42
|
+
exports.makeStorageCaller = makeStorageCaller;
|
|
43
|
+
async function promiseStorageCaller(caller, objPath) {
|
|
44
|
+
const lstStorageCAP = (await caller.listObjAsync(objPath));
|
|
45
|
+
return instantiateStorageCaller(caller, lstStorageCAP, objPath);
|
|
46
|
+
}
|
|
47
|
+
exports.promiseStorageCaller = promiseStorageCaller;
|
|
48
|
+
function instantiateStorageCaller(caller, lstStorageCAP, objPath) {
|
|
40
49
|
const sysFS = lstStorageCAP.includes('getSysFS');
|
|
41
50
|
const userFS = lstStorageCAP.includes('getUserFS');
|
|
42
51
|
const storage = {
|
|
@@ -51,7 +60,6 @@ function makeStorageCaller(caller, objPath) {
|
|
|
51
60
|
}
|
|
52
61
|
return storage;
|
|
53
62
|
}
|
|
54
|
-
exports.makeStorageCaller = makeStorageCaller;
|
|
55
63
|
var getAppLocalFS;
|
|
56
64
|
(function (getAppLocalFS) {
|
|
57
65
|
const requestType = protobuf_type_1.ProtoType.for(storage_proto_1.storage.GetAppLocalFSRequestBody);
|