@leapdev/app-platform 0.1.0-beta.26 → 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.26",
3
+ "version": "0.1.0-beta.27",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.0",
6
6
  "vkbeautify": "^0.99.3",
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: {
@@ -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(`[getDocumentData] Document not open via LEAP`);
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.openDocument(params);
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(`[getDocumentData] Document not open via LEAP`);
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,5 +1,5 @@
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");
@@ -16,108 +16,109 @@ class SignalRService {
16
16
  tslib_1.__classPrivateFieldSet(this, _SignalRService_sessionId, (0, uuid_1.v4)(), "f");
17
17
  }
18
18
  connectToSignalR() {
19
- if (!tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
20
- tslib_1.__classPrivateFieldGet(this, _SignalRService_instances, "m", _SignalRService_createConnection).call(this, tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f"));
21
- return new Promise((resolve) => {
22
- if (tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
23
- tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")
24
- .start()
25
- .then(() => {
26
- resolve(tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f"));
27
- })
28
- .catch((error) => {
29
- console.log('Unable to connect to signalR', error);
30
- resolve('');
31
- });
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"));
32
24
  }
33
- else {
25
+ if (!tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
34
26
  console.log('Unable to connect to signalR: no connection');
35
- resolve('');
27
+ return '';
36
28
  }
37
- });
38
- }
39
- else {
40
- return new Promise((resolve) => resolve(tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f")));
41
- }
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
+ });
42
40
  }
43
41
  getInitData(params) {
44
- const connection = tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f");
45
- if (!connection) {
46
- return Promise.resolve(null);
47
- }
48
42
  const { clientId } = params;
43
+ return tslib_1.__classPrivateFieldGet(this, _SignalRService_instances, "m", _SignalRService_sendMessageWithHandler).call(this, 'init_data', {
44
+ clientId,
45
+ });
46
+ }
47
+ openDocument(params) {
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 });
58
+ }
59
+ }
60
+ exports.SignalRService = SignalRService;
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
+ }
49
87
  const requestId = (0, uuid_1.v4)();
50
- const payload = {
88
+ const message = {
51
89
  source: 'automationCore',
52
90
  sessionId: tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f"),
53
91
  requestId,
54
- action: 'init_data',
55
- payload: {
56
- clientId,
57
- },
92
+ action,
93
+ payload,
58
94
  };
95
+ const connection = tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f");
59
96
  return new Promise((resolve) => {
60
97
  const cleanup = () => {
61
98
  clearTimeout(timeoutId);
62
- connection.off('ProcessMessage', handler);
99
+ connection.off('ProcessMessage', onMessage);
63
100
  };
64
- const handler = (message) => {
65
- if (message.sessionId === tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f") &&
66
- message.requestId === requestId) {
101
+ const onMessage = (response) => {
102
+ if (response.sessionId === tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f") &&
103
+ response.requestId === requestId) {
67
104
  cleanup();
68
- resolve(message.payload);
105
+ resolve(response.payload);
69
106
  }
70
107
  };
71
108
  const timeoutId = setTimeout(() => {
72
109
  cleanup();
73
- console.warn('[SignalR] init_data timed out waiting for ProcessMessage response');
110
+ console.warn(`[SignalR] ${action} timed out waiting for ProcessMessage response`);
74
111
  resolve(null);
75
112
  }, INIT_DATA_TIMEOUT_MS);
76
- // Register before invoke so a fast response cannot be missed.
77
- connection.on('ProcessMessage', handler);
78
- connection.invoke('ProcessMessage', payload, true)
79
- .catch((e) => {
113
+ connection.on('ProcessMessage', onMessage);
114
+ connection.invoke('ProcessMessage', message, true).catch((e) => {
80
115
  console.log('SignalR sendMessage error', e);
81
116
  cleanup();
82
117
  resolve(null);
83
118
  });
84
119
  });
85
- }
86
- openDocument(params) {
87
- if (tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
88
- const { documentId, matterId } = params;
89
- const requestId = (0, uuid_1.v4)();
90
- const payload = {
91
- source: 'automationCore',
92
- sessionId: tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f"),
93
- requestId,
94
- action: 'open_document',
95
- payload: {
96
- documentId,
97
- matterId,
98
- },
99
- };
100
- return new Promise((resolve) => {
101
- if (tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
102
- tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")
103
- .invoke('ProcessMessage', payload, true)
104
- .then(() => {
105
- resolve(true);
106
- })
107
- .catch((e) => {
108
- console.log('SignalR sendMessage error', e);
109
- return resolve(false);
110
- });
111
- }
112
- });
113
- }
114
- else {
115
- return new Promise((resolve) => resolve(false));
116
- }
117
- }
118
- }
119
- exports.SignalRService = SignalRService;
120
- _SignalRService_sessionId = new WeakMap(), _SignalRService_automationHubUrl = new WeakMap(), _SignalRService_connection = new WeakMap(), _SignalRService_instances = new WeakSet(), _SignalRService_createConnection = function _SignalRService_createConnection(sessionId) {
120
+ });
121
+ }, _SignalRService_createConnection = function _SignalRService_createConnection(sessionId) {
121
122
  if (tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
122
123
  return;
123
124
  }