@leapdev/app-platform 0.1.0-beta.25 → 0.1.0-beta.27
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leapdev/app-platform",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.27",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"tslib": "^2.3.0",
|
|
6
6
|
"vkbeautify": "^0.99.3",
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
"type": "commonjs",
|
|
15
15
|
"main": "./src/index.js",
|
|
16
16
|
"typings": "./src/index.d.ts"
|
|
17
|
-
}
|
|
17
|
+
}
|
package/src/index.d.ts
CHANGED
|
@@ -39,6 +39,13 @@ export declare const openDocumentViaSignalR: (params: {
|
|
|
39
39
|
documentId: string;
|
|
40
40
|
matterId: string;
|
|
41
41
|
}) => Promise<boolean>;
|
|
42
|
+
export declare const openMatterViaSignalR: (params: {
|
|
43
|
+
matterId: string;
|
|
44
|
+
}) => Promise<boolean>;
|
|
45
|
+
export declare const setBookmarkViaSignalR: (params: {
|
|
46
|
+
matterId: string;
|
|
47
|
+
tables: unknown[];
|
|
48
|
+
}) => Promise<boolean>;
|
|
42
49
|
export declare const saveDocument: () => Promise<{
|
|
43
50
|
documentVersionId: string;
|
|
44
51
|
}>;
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.saveDocument = exports.openDocumentViaSignalR = exports.connectSignalR = exports.getInitDataViaSignalR = exports.getLEAPUserViaSignalR = exports.getLEAPTokenViaSignalR = exports.createDocument = exports.evaluatePaths = exports.getAddinData = exports.updateDocumentData = exports.getDocumentData = exports.getHostInfo = exports.setupLeapEventsAndSetToken = exports.initAppPlatform = void 0;
|
|
3
|
+
exports.saveDocument = exports.setBookmarkViaSignalR = exports.openMatterViaSignalR = exports.openDocumentViaSignalR = exports.connectSignalR = exports.getInitDataViaSignalR = exports.getLEAPUserViaSignalR = exports.getLEAPTokenViaSignalR = exports.createDocument = exports.evaluatePaths = exports.getAddinData = exports.updateDocumentData = exports.getDocumentData = exports.getHostInfo = exports.setupLeapEventsAndSetToken = exports.initAppPlatform = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const app_platform_1 = require("./lib/app-platform");
|
|
6
6
|
tslib_1.__exportStar(require("./types"), exports);
|
|
@@ -57,6 +57,14 @@ const openDocumentViaSignalR = (params) => {
|
|
|
57
57
|
return appPlatform.openDocumentViaSignalR(params);
|
|
58
58
|
};
|
|
59
59
|
exports.openDocumentViaSignalR = openDocumentViaSignalR;
|
|
60
|
+
const openMatterViaSignalR = (params) => {
|
|
61
|
+
return appPlatform.openMatterViaSignalR(params);
|
|
62
|
+
};
|
|
63
|
+
exports.openMatterViaSignalR = openMatterViaSignalR;
|
|
64
|
+
const setBookmarkViaSignalR = (params) => {
|
|
65
|
+
return appPlatform.setBookmarkViaSignalR(params);
|
|
66
|
+
};
|
|
67
|
+
exports.setBookmarkViaSignalR = setBookmarkViaSignalR;
|
|
60
68
|
const saveDocument = () => {
|
|
61
69
|
return appPlatform.saveDocument();
|
|
62
70
|
};
|
|
@@ -32,6 +32,13 @@ export declare class AppPlatform {
|
|
|
32
32
|
matterId: string;
|
|
33
33
|
documentId: string;
|
|
34
34
|
}): Promise<boolean>;
|
|
35
|
+
openMatterViaSignalR(params: {
|
|
36
|
+
matterId: string;
|
|
37
|
+
}): Promise<boolean>;
|
|
38
|
+
setBookmarkViaSignalR(params: {
|
|
39
|
+
matterId: string;
|
|
40
|
+
tables: unknown[];
|
|
41
|
+
}): Promise<boolean>;
|
|
35
42
|
getDocumentData(): Promise<LeapDocumentData | null>;
|
|
36
43
|
getExcelDocumentData(): Promise<LeapDocumentData | null>;
|
|
37
44
|
setDocumentData(params: {
|
package/src/lib/app-platform.js
CHANGED
|
@@ -213,14 +213,36 @@ class AppPlatform {
|
|
|
213
213
|
});
|
|
214
214
|
}
|
|
215
215
|
openDocumentViaSignalR(params) {
|
|
216
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
217
|
+
try {
|
|
218
|
+
const done = yield this.signalRService.openDocument(params);
|
|
219
|
+
return done;
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
openMatterViaSignalR(params) {
|
|
227
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
228
|
+
try {
|
|
229
|
+
const done = yield this.signalRService.openMatter(params);
|
|
230
|
+
return done;
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
setBookmarkViaSignalR(params) {
|
|
216
238
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
217
239
|
try {
|
|
218
240
|
if (!this._openViaLEAP) {
|
|
219
|
-
this.loggerService.log(`[
|
|
241
|
+
this.loggerService.log(`[setBookmarkViaSignalR] Document not open via LEAP`);
|
|
220
242
|
return false;
|
|
221
243
|
}
|
|
222
244
|
else {
|
|
223
|
-
const done = yield this.signalRService.
|
|
245
|
+
const done = yield this.signalRService.setBookmark(params);
|
|
224
246
|
return done;
|
|
225
247
|
}
|
|
226
248
|
}
|
|
@@ -283,7 +305,7 @@ class AppPlatform {
|
|
|
283
305
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
284
306
|
try {
|
|
285
307
|
if (!this._openViaLEAP) {
|
|
286
|
-
this.loggerService.log(`[
|
|
308
|
+
this.loggerService.log(`[getAddinData] Document not open via LEAP`);
|
|
287
309
|
return null;
|
|
288
310
|
}
|
|
289
311
|
const addInData = yield (0, custom_xml_part_service_1.getDataByNamespace)(constants_1.constants.LeapOfficeAddInDataNamespace);
|
|
@@ -10,4 +10,11 @@ export declare class SignalRService {
|
|
|
10
10
|
documentId: string;
|
|
11
11
|
matterId: string;
|
|
12
12
|
}): Promise<boolean>;
|
|
13
|
+
openMatter(params: {
|
|
14
|
+
matterId: string;
|
|
15
|
+
}): Promise<boolean>;
|
|
16
|
+
setBookmark(params: {
|
|
17
|
+
matterId: string;
|
|
18
|
+
tables: unknown[];
|
|
19
|
+
}): Promise<boolean>;
|
|
13
20
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _SignalRService_instances, _SignalRService_sessionId, _SignalRService_automationHubUrl, _SignalRService_connection, _SignalRService_createConnection;
|
|
2
|
+
var _SignalRService_instances, _SignalRService_sessionId, _SignalRService_automationHubUrl, _SignalRService_connection, _SignalRService_sendMessage, _SignalRService_sendMessageWithHandler, _SignalRService_createConnection;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.SignalRService = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const signalR = tslib_1.__importStar(require("@microsoft/signalr"));
|
|
7
7
|
const uuid_1 = require("uuid");
|
|
8
|
+
const INIT_DATA_TIMEOUT_MS = 5000;
|
|
8
9
|
class SignalRService {
|
|
9
10
|
constructor() {
|
|
10
11
|
_SignalRService_instances.add(this);
|
|
@@ -15,105 +16,109 @@ class SignalRService {
|
|
|
15
16
|
tslib_1.__classPrivateFieldSet(this, _SignalRService_sessionId, (0, uuid_1.v4)(), "f");
|
|
16
17
|
}
|
|
17
18
|
connectToSignalR() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
|
|
22
|
-
tslib_1.__classPrivateFieldGet(this,
|
|
23
|
-
.start()
|
|
24
|
-
.then(() => {
|
|
25
|
-
resolve(tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f"));
|
|
26
|
-
})
|
|
27
|
-
.catch((error) => {
|
|
28
|
-
console.log('Unable to connect to signalR', error);
|
|
29
|
-
resolve('');
|
|
30
|
-
});
|
|
19
|
+
var _a;
|
|
20
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
try {
|
|
22
|
+
if (!tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
|
|
23
|
+
tslib_1.__classPrivateFieldGet(this, _SignalRService_instances, "m", _SignalRService_createConnection).call(this, tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f"));
|
|
31
24
|
}
|
|
32
|
-
|
|
25
|
+
if (!tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
|
|
33
26
|
console.log('Unable to connect to signalR: no connection');
|
|
34
|
-
|
|
27
|
+
return '';
|
|
35
28
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
if (tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f").state === signalR.HubConnectionState.Disconnected) {
|
|
30
|
+
yield tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f").start();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.log('Unable to connect to signalR', error);
|
|
35
|
+
}
|
|
36
|
+
return ((_a = tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) === null || _a === void 0 ? void 0 : _a.state) === signalR.HubConnectionState.Connected
|
|
37
|
+
? tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f")
|
|
38
|
+
: '';
|
|
39
|
+
});
|
|
41
40
|
}
|
|
42
|
-
// check if ld is open
|
|
43
41
|
getInitData(params) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
source: 'automationCore',
|
|
49
|
-
sessionId: tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f"),
|
|
50
|
-
requestId,
|
|
51
|
-
action: 'init_data',
|
|
52
|
-
payload: {
|
|
53
|
-
clientId,
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
return new Promise((resolve) => {
|
|
57
|
-
if (tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
|
|
58
|
-
tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")
|
|
59
|
-
.invoke('ProcessMessage', payload, true)
|
|
60
|
-
.then(() => {
|
|
61
|
-
if (tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
|
|
62
|
-
tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f").on('ProcessMessage', (message) => {
|
|
63
|
-
if (message.sessionId === tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f") &&
|
|
64
|
-
message.requestId === requestId) {
|
|
65
|
-
// do another action open matter
|
|
66
|
-
resolve(message.payload);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
.catch((e) => {
|
|
72
|
-
console.log('SignalR sendMessage error', e);
|
|
73
|
-
return resolve(null);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
return new Promise((resolve) => resolve(null));
|
|
80
|
-
}
|
|
42
|
+
const { clientId } = params;
|
|
43
|
+
return tslib_1.__classPrivateFieldGet(this, _SignalRService_instances, "m", _SignalRService_sendMessageWithHandler).call(this, 'init_data', {
|
|
44
|
+
clientId,
|
|
45
|
+
});
|
|
81
46
|
}
|
|
82
47
|
openDocument(params) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
matterId,
|
|
94
|
-
},
|
|
95
|
-
};
|
|
96
|
-
return new Promise((resolve) => {
|
|
97
|
-
if (tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
|
|
98
|
-
tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")
|
|
99
|
-
.invoke('ProcessMessage', payload, true)
|
|
100
|
-
.then(() => {
|
|
101
|
-
resolve(true);
|
|
102
|
-
})
|
|
103
|
-
.catch((e) => {
|
|
104
|
-
console.log('SignalR sendMessage error', e);
|
|
105
|
-
return resolve(false);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
return new Promise((resolve) => resolve(false));
|
|
112
|
-
}
|
|
48
|
+
const { documentId, matterId } = params;
|
|
49
|
+
return tslib_1.__classPrivateFieldGet(this, _SignalRService_instances, "m", _SignalRService_sendMessage).call(this, 'open_document', { documentId, matterId });
|
|
50
|
+
}
|
|
51
|
+
openMatter(params) {
|
|
52
|
+
const { matterId } = params;
|
|
53
|
+
return tslib_1.__classPrivateFieldGet(this, _SignalRService_instances, "m", _SignalRService_sendMessage).call(this, 'open_matter', { matterId });
|
|
54
|
+
}
|
|
55
|
+
setBookmark(params) {
|
|
56
|
+
const { matterId, tables } = params;
|
|
57
|
+
return tslib_1.__classPrivateFieldGet(this, _SignalRService_instances, "m", _SignalRService_sendMessage).call(this, 'set_bookmark', { matterId, tables });
|
|
113
58
|
}
|
|
114
59
|
}
|
|
115
60
|
exports.SignalRService = SignalRService;
|
|
116
|
-
_SignalRService_sessionId = new WeakMap(), _SignalRService_automationHubUrl = new WeakMap(), _SignalRService_connection = new WeakMap(), _SignalRService_instances = new WeakSet(),
|
|
61
|
+
_SignalRService_sessionId = new WeakMap(), _SignalRService_automationHubUrl = new WeakMap(), _SignalRService_connection = new WeakMap(), _SignalRService_instances = new WeakSet(), _SignalRService_sendMessage = function _SignalRService_sendMessage(action, payload) {
|
|
62
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
if (!(yield this.connectToSignalR()) || !tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
const message = {
|
|
67
|
+
source: 'automationCore',
|
|
68
|
+
sessionId: tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f"),
|
|
69
|
+
requestId: (0, uuid_1.v4)(),
|
|
70
|
+
action,
|
|
71
|
+
payload,
|
|
72
|
+
};
|
|
73
|
+
try {
|
|
74
|
+
yield tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f").invoke('ProcessMessage', message, true);
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
console.log('SignalR sendMessage error', e);
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}, _SignalRService_sendMessageWithHandler = function _SignalRService_sendMessageWithHandler(action, payload) {
|
|
83
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
if (!(yield this.connectToSignalR()) || !tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const requestId = (0, uuid_1.v4)();
|
|
88
|
+
const message = {
|
|
89
|
+
source: 'automationCore',
|
|
90
|
+
sessionId: tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f"),
|
|
91
|
+
requestId,
|
|
92
|
+
action,
|
|
93
|
+
payload,
|
|
94
|
+
};
|
|
95
|
+
const connection = tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f");
|
|
96
|
+
return new Promise((resolve) => {
|
|
97
|
+
const cleanup = () => {
|
|
98
|
+
clearTimeout(timeoutId);
|
|
99
|
+
connection.off('ProcessMessage', onMessage);
|
|
100
|
+
};
|
|
101
|
+
const onMessage = (response) => {
|
|
102
|
+
if (response.sessionId === tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f") &&
|
|
103
|
+
response.requestId === requestId) {
|
|
104
|
+
cleanup();
|
|
105
|
+
resolve(response.payload);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
const timeoutId = setTimeout(() => {
|
|
109
|
+
cleanup();
|
|
110
|
+
console.warn(`[SignalR] ${action} timed out waiting for ProcessMessage response`);
|
|
111
|
+
resolve(null);
|
|
112
|
+
}, INIT_DATA_TIMEOUT_MS);
|
|
113
|
+
connection.on('ProcessMessage', onMessage);
|
|
114
|
+
connection.invoke('ProcessMessage', message, true).catch((e) => {
|
|
115
|
+
console.log('SignalR sendMessage error', e);
|
|
116
|
+
cleanup();
|
|
117
|
+
resolve(null);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
}, _SignalRService_createConnection = function _SignalRService_createConnection(sessionId) {
|
|
117
122
|
if (tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
|
|
118
123
|
return;
|
|
119
124
|
}
|