@leapdev/app-platform 0.1.0-beta.3 → 0.1.0-beta.31

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.
Files changed (105) hide show
  1. package/package.json +4 -2
  2. package/src/index.d.ts +34 -6
  3. package/src/index.js +39 -7
  4. package/src/lib/app-platform.d.ts +40 -2
  5. package/src/lib/app-platform.js +264 -29
  6. package/src/lib/domains/leap-document-data/index.d.ts +8 -0
  7. package/src/lib/domains/leap-document-data/index.js +11 -0
  8. package/src/lib/domains/leap-document-data/leap-document-data.model.d.ts +7 -0
  9. package/src/lib/domains/leap-document-data/leap-document-data.model.js +11 -0
  10. package/src/lib/domains/leap-document-data/leap-document-data.normalizer.d.ts +19 -0
  11. package/src/lib/domains/leap-document-data/leap-document-data.normalizer.js +101 -0
  12. package/src/lib/domains/leap-document-data/leap-document-data.service.d.ts +90 -0
  13. package/src/lib/domains/leap-document-data/leap-document-data.service.js +156 -0
  14. package/src/lib/environment/environment.dictionary.js +0 -1
  15. package/src/lib/environment/environment.js +0 -1
  16. package/src/lib/environment/index.js +0 -1
  17. package/src/lib/environment/leap/env.dev.au.config.js +0 -1
  18. package/src/lib/environment/leap/env.live.au.config.js +0 -1
  19. package/src/lib/environment/leap/env.live.ca.config.js +0 -1
  20. package/src/lib/environment/leap/env.live.nz.config.js +0 -1
  21. package/src/lib/environment/leap/env.live.uk.config.js +0 -1
  22. package/src/lib/environment/leap/env.live.us.config.js +0 -1
  23. package/src/lib/environment/leap/env.liveb.au.config.js +0 -1
  24. package/src/lib/environment/leap/env.test.au.config.js +0 -1
  25. package/src/lib/environment/leap/env.test.ca.config.js +0 -1
  26. package/src/lib/environment/leap/env.test.nz.config.js +0 -1
  27. package/src/lib/environment/leap/env.test.uk.config.js +0 -1
  28. package/src/lib/environment/leap/env.test.us.config.js +0 -1
  29. package/src/lib/functions/helpers.d.ts +1 -0
  30. package/src/lib/functions/helpers.js +7 -4
  31. package/src/lib/functions/xml.js +0 -1
  32. package/src/lib/models/calc-api.model.js +0 -1
  33. package/src/lib/models/constants/index.d.ts +2 -0
  34. package/src/lib/models/constants/index.js +2 -1
  35. package/src/lib/models/index.js +0 -1
  36. package/src/lib/models/leap-events.model.d.ts +1 -0
  37. package/src/lib/models/leap-events.model.js +1 -1
  38. package/src/lib/models/leap.model.d.ts +19 -0
  39. package/src/lib/models/leap.model.js +8 -2
  40. package/src/lib/models/signalr.model.d.ts +1 -0
  41. package/src/lib/models/signalr.model.js +0 -1
  42. package/src/lib/ports/adapters/excel-custom-xml-part.adapter.d.ts +15 -0
  43. package/src/lib/ports/adapters/excel-custom-xml-part.adapter.js +113 -0
  44. package/src/lib/ports/adapters/in-memory-custom-xml-part.adapter.d.ts +22 -0
  45. package/src/lib/ports/adapters/in-memory-custom-xml-part.adapter.js +52 -0
  46. package/src/lib/ports/adapters/word-custom-xml-part.adapter.d.ts +16 -0
  47. package/src/lib/ports/adapters/word-custom-xml-part.adapter.js +118 -0
  48. package/src/lib/ports/custom-xml-part.port.d.ts +44 -0
  49. package/src/lib/ports/custom-xml-part.port.js +2 -0
  50. package/src/lib/ports/index.d.ts +7 -0
  51. package/src/lib/ports/index.js +10 -0
  52. package/src/lib/services/auth/auth.service.js +0 -1
  53. package/src/lib/services/calc-api/calc-api-service.interface.d.ts +1 -3
  54. package/src/lib/services/calc-api/calc-api-service.interface.js +0 -1
  55. package/src/lib/services/calc-api/calc-word.service.d.ts +2 -4
  56. package/src/lib/services/calc-api/calc-word.service.js +0 -37
  57. package/src/lib/services/calc-api/promise-helper.function.js +1 -2
  58. package/src/lib/services/custom-xml-part.service.d.ts +1 -1
  59. package/src/lib/services/custom-xml-part.service.js +5 -3
  60. package/src/lib/services/document/document.service.d.ts +5 -0
  61. package/src/lib/services/document/document.service.js +25 -1
  62. package/src/lib/services/excel-custom-xml-part.service.d.ts +14 -0
  63. package/src/lib/services/excel-custom-xml-part.service.js +193 -0
  64. package/src/lib/services/index.js +0 -1
  65. package/src/lib/services/leap-events.service.js +3 -4
  66. package/src/lib/services/logger/logger.service.js +0 -1
  67. package/src/lib/services/signalr/signalr.service.d.ts +11 -0
  68. package/src/lib/services/signalr/signalr.service.js +102 -56
  69. package/src/types.d.ts +4 -0
  70. package/src/types.js +10 -0
  71. package/src/index.js.map +0 -1
  72. package/src/lib/app-platform.js.map +0 -1
  73. package/src/lib/environment/environment.dictionary.js.map +0 -1
  74. package/src/lib/environment/environment.js.map +0 -1
  75. package/src/lib/environment/index.js.map +0 -1
  76. package/src/lib/environment/leap/env.dev.au.config.js.map +0 -1
  77. package/src/lib/environment/leap/env.live.au.config.js.map +0 -1
  78. package/src/lib/environment/leap/env.live.ca.config.js.map +0 -1
  79. package/src/lib/environment/leap/env.live.nz.config.js.map +0 -1
  80. package/src/lib/environment/leap/env.live.uk.config.js.map +0 -1
  81. package/src/lib/environment/leap/env.live.us.config.js.map +0 -1
  82. package/src/lib/environment/leap/env.liveb.au.config.js.map +0 -1
  83. package/src/lib/environment/leap/env.test.au.config.js.map +0 -1
  84. package/src/lib/environment/leap/env.test.ca.config.js.map +0 -1
  85. package/src/lib/environment/leap/env.test.nz.config.js.map +0 -1
  86. package/src/lib/environment/leap/env.test.uk.config.js.map +0 -1
  87. package/src/lib/environment/leap/env.test.us.config.js.map +0 -1
  88. package/src/lib/functions/helpers.js.map +0 -1
  89. package/src/lib/functions/xml.js.map +0 -1
  90. package/src/lib/models/calc-api.model.js.map +0 -1
  91. package/src/lib/models/constants/index.js.map +0 -1
  92. package/src/lib/models/index.js.map +0 -1
  93. package/src/lib/models/leap-events.model.js.map +0 -1
  94. package/src/lib/models/leap.model.js.map +0 -1
  95. package/src/lib/models/signalr.model.js.map +0 -1
  96. package/src/lib/services/auth/auth.service.js.map +0 -1
  97. package/src/lib/services/calc-api/calc-api-service.interface.js.map +0 -1
  98. package/src/lib/services/calc-api/calc-word.service.js.map +0 -1
  99. package/src/lib/services/calc-api/promise-helper.function.js.map +0 -1
  100. package/src/lib/services/custom-xml-part.service.js.map +0 -1
  101. package/src/lib/services/document/document.service.js.map +0 -1
  102. package/src/lib/services/index.js.map +0 -1
  103. package/src/lib/services/leap-events.service.js.map +0 -1
  104. package/src/lib/services/logger/logger.service.js.map +0 -1
  105. package/src/lib/services/signalr/signalr.service.js.map +0 -1
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "@leapdev/app-platform",
3
- "version": "0.1.0-beta.3",
3
+ "version": "0.1.0-beta.31",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.0",
6
6
  "vkbeautify": "^0.99.3",
7
7
  "xml2js": "^0.6.2",
8
8
  "os-browserify": "^0.3.0",
9
9
  "loglevel": "^1.6.3",
10
- "rxjs": "7.8.0"
10
+ "rxjs": "7.8.0",
11
+ "@microsoft/signalr": "^8.0.7",
12
+ "uuid": "^11.1.0"
11
13
  },
12
14
  "type": "commonjs",
13
15
  "main": "./src/index.js",
package/src/index.d.ts CHANGED
@@ -1,17 +1,31 @@
1
- export * from './lib/environment';
2
- export * from './lib/models';
3
- export * from './lib/services';
4
1
  import { EvaluatePathsRequest } from './lib/models';
5
- export declare const initAppPlatform: () => Promise<{
2
+ import { HostApplicationType, LeapDocumentData } from './lib/models/leap.model';
3
+ export * from './types';
4
+ export * from './lib/ports';
5
+ export * from './lib/domains/leap-document-data';
6
+ export declare const initAppPlatform: (hostApplicationType: HostApplicationType, skipLeapEventsSetup?: boolean) => Promise<{
6
7
  done: boolean;
7
8
  openViaLEAP: boolean;
8
9
  }>;
9
- export declare const getDocumentData: () => Promise<import("./lib/models/leap.model").LeapDocumentData | null>;
10
- export declare const evaluatePaths: (request: EvaluatePathsRequest) => Promise<import("./lib/models").EvaluatePathsResponse[] | null>;
10
+ export declare const setupLeapEventsAndSetToken: () => Promise<void>;
11
+ export declare const getHostInfo: (params: {
12
+ hostApplicationType: HostApplicationType;
13
+ clientId: string;
14
+ }) => Promise<{
15
+ hostType: string | null;
16
+ hostVersion: string | null;
17
+ }>;
18
+ export declare const getDocumentData: () => Promise<LeapDocumentData | null>;
19
+ export declare const updateDocumentData: (params: {
20
+ documentData: LeapDocumentData;
21
+ }) => Promise<boolean>;
22
+ export declare const getAddinData: () => Promise<unknown>;
23
+ export declare const evaluatePaths: (request: EvaluatePathsRequest) => Promise<import("./types").EvaluatePathsResponse[] | null>;
11
24
  export declare const createDocument: (params: {
12
25
  precedentId: string;
13
26
  body: string;
14
27
  closeExisting?: boolean;
28
+ additionalData?: unknown;
15
29
  }) => Promise<{
16
30
  precedentId: string;
17
31
  body: string;
@@ -23,3 +37,17 @@ export declare const getInitDataViaSignalR: () => Promise<Omit<import("./lib/mod
23
37
  export declare const connectSignalR: (params: {
24
38
  clientId: string;
25
39
  }) => Promise<boolean>;
40
+ export declare const openDocumentViaSignalR: (params: {
41
+ documentId: string;
42
+ matterId: string;
43
+ }) => Promise<boolean>;
44
+ export declare const openMatterViaSignalR: (params: {
45
+ matterId: string;
46
+ }) => Promise<boolean>;
47
+ export declare const setBookmarkViaSignalR: (params: {
48
+ matterId: string;
49
+ tables: unknown[];
50
+ }) => Promise<boolean>;
51
+ export declare const saveDocument: () => Promise<{
52
+ documentVersionId: string;
53
+ }>;
package/src/index.js CHANGED
@@ -1,20 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.connectSignalR = exports.getInitDataViaSignalR = exports.getLEAPUserViaSignalR = exports.getLEAPTokenViaSignalR = exports.createDocument = exports.evaluatePaths = exports.getDocumentData = 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
- tslib_1.__exportStar(require("./lib/environment"), exports);
6
- tslib_1.__exportStar(require("./lib/models"), exports);
7
- tslib_1.__exportStar(require("./lib/services"), exports);
8
5
  const app_platform_1 = require("./lib/app-platform");
6
+ tslib_1.__exportStar(require("./types"), exports);
7
+ // Export domain pattern: ports, adapters, and domain services
8
+ tslib_1.__exportStar(require("./lib/ports"), exports);
9
+ tslib_1.__exportStar(require("./lib/domains/leap-document-data"), exports);
9
10
  const appPlatform = new app_platform_1.AppPlatform();
10
- const initAppPlatform = () => {
11
- return appPlatform.init();
11
+ const initAppPlatform = (hostApplicationType, skipLeapEventsSetup = false) => {
12
+ return appPlatform.init(hostApplicationType, skipLeapEventsSetup);
12
13
  };
13
14
  exports.initAppPlatform = initAppPlatform;
15
+ const setupLeapEventsAndSetToken = () => {
16
+ return appPlatform.setupLeapEventsAndSetToken();
17
+ };
18
+ exports.setupLeapEventsAndSetToken = setupLeapEventsAndSetToken;
19
+ const getHostInfo = (params) => {
20
+ return appPlatform.getHostInfo(params);
21
+ };
22
+ exports.getHostInfo = getHostInfo;
14
23
  const getDocumentData = () => {
15
24
  return appPlatform.getDocumentData();
16
25
  };
17
26
  exports.getDocumentData = getDocumentData;
27
+ const updateDocumentData = (params) => {
28
+ return appPlatform.setDocumentData(params);
29
+ };
30
+ exports.updateDocumentData = updateDocumentData;
31
+ const getAddinData = () => {
32
+ return appPlatform.getAddinData();
33
+ };
34
+ exports.getAddinData = getAddinData;
18
35
  const evaluatePaths = (request) => {
19
36
  return appPlatform.evaluatePaths(request);
20
37
  };
@@ -39,4 +56,19 @@ const connectSignalR = (params) => {
39
56
  return appPlatform.connectToSignalR(params);
40
57
  };
41
58
  exports.connectSignalR = connectSignalR;
42
- //# sourceMappingURL=index.js.map
59
+ const openDocumentViaSignalR = (params) => {
60
+ return appPlatform.openDocumentViaSignalR(params);
61
+ };
62
+ exports.openDocumentViaSignalR = openDocumentViaSignalR;
63
+ const openMatterViaSignalR = (params) => {
64
+ return appPlatform.openMatterViaSignalR(params);
65
+ };
66
+ exports.openMatterViaSignalR = openMatterViaSignalR;
67
+ const setBookmarkViaSignalR = (params) => {
68
+ return appPlatform.setBookmarkViaSignalR(params);
69
+ };
70
+ exports.setBookmarkViaSignalR = setBookmarkViaSignalR;
71
+ const saveDocument = () => {
72
+ return appPlatform.saveDocument();
73
+ };
74
+ exports.saveDocument = saveDocument;
@@ -1,5 +1,5 @@
1
1
  import { EvaluatePathsRequest, EvaluatePathsResponse } from './models';
2
- import { LeapDocumentData, LEAPUser } from './models/leap.model';
2
+ import { HostApplicationType, LeapDocumentData, LEAPUser } from './models/leap.model';
3
3
  import { SignalRInitData } from './models/signalr.model';
4
4
  export declare class AppPlatform {
5
5
  #private;
@@ -10,28 +10,66 @@ export declare class AppPlatform {
10
10
  private signalRService;
11
11
  private _openViaLEAP;
12
12
  constructor();
13
- init(): Promise<{
13
+ /**
14
+ * Get the session-scoped LeapDocumentDataService.
15
+ * Throws if init() was not called with a valid host.
16
+ */
17
+ private getLeapDocumentDataService;
18
+ init(hostApplicationType: HostApplicationType, skipLeapEventsSetup: boolean, force?: boolean): Promise<{
14
19
  done: boolean;
15
20
  openViaLEAP: boolean;
16
21
  }>;
22
+ setupLeapEventsAndSetToken(): Promise<void>;
17
23
  connectToSignalR(params: {
18
24
  clientId: string;
19
25
  }): Promise<boolean>;
26
+ getHostInfo(params: {
27
+ hostApplicationType: HostApplicationType;
28
+ clientId: string;
29
+ }): Promise<{
30
+ hostType: string | null;
31
+ hostVersion: string | null;
32
+ }>;
20
33
  getLEAPTokenViaSignalR(forceRefresh?: boolean): Promise<string>;
21
34
  getLEAPUserViaSignalR(): Promise<LEAPUser | undefined>;
22
35
  getInitDataViaSignalR(): Promise<Omit<SignalRInitData, 'code' | 'codeChallenge'> | null>;
36
+ openDocumentViaSignalR(params: {
37
+ matterId: string;
38
+ documentId: string;
39
+ }): Promise<boolean>;
40
+ openMatterViaSignalR(params: {
41
+ matterId: string;
42
+ }): Promise<boolean>;
43
+ setBookmarkViaSignalR(params: {
44
+ matterId: string;
45
+ tables: unknown[];
46
+ }): Promise<boolean>;
23
47
  getDocumentData(): Promise<LeapDocumentData | null>;
48
+ /**
49
+ * @deprecated Use getDocumentData() instead. The host is now determined by init().
50
+ * This method will be removed in a future version.
51
+ */
52
+ getExcelDocumentData(): Promise<LeapDocumentData | null>;
53
+ setDocumentData(params: {
54
+ documentData: LeapDocumentData;
55
+ }): Promise<boolean>;
56
+ getAddinData(): Promise<unknown>;
24
57
  evaluatePaths(request: EvaluatePathsRequest): Promise<Array<EvaluatePathsResponse> | null>;
25
58
  createDocument(params: {
26
59
  precedentId: string;
27
60
  body: string;
28
61
  closeExisting?: boolean;
62
+ additionalData?: unknown;
29
63
  }): Promise<{
30
64
  precedentId: string;
31
65
  body: string;
32
66
  closeExisting?: boolean | undefined;
33
67
  } | null>;
68
+ saveDocument(): Promise<{
69
+ documentVersionId: string;
70
+ }>;
34
71
  private setupLeapEvents;
35
72
  private setTokenInCustomXml;
36
73
  private getWordCustomPart;
74
+ private isLeapWorkbook;
37
75
  }
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
- var _AppPlatform_authService, _AppPlatform_signalRInitData;
2
+ var _AppPlatform_leapDocumentDataService, _AppPlatform_authService, _AppPlatform_signalRInitData, _AppPlatform_initialized, _AppPlatform_connectedToSignalR, _AppPlatform_hostApplicationType;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.AppPlatform = void 0;
5
5
  const tslib_1 = require("tslib");
6
+ const helpers_1 = require("./functions/helpers");
7
+ const leap_document_data_1 = require("./domains/leap-document-data");
6
8
  const constants_1 = require("./models/constants");
7
9
  const leap_events_model_1 = require("./models/leap-events.model");
10
+ const leap_model_1 = require("./models/leap.model");
8
11
  const services_1 = require("./services");
9
12
  const auth_service_1 = require("./services/auth/auth.service");
10
13
  const promise_helper_function_1 = require("./services/calc-api/promise-helper.function");
@@ -13,55 +16,162 @@ const leap_events_service_1 = require("./services/leap-events.service");
13
16
  const signalr_service_1 = require("./services/signalr/signalr.service");
14
17
  class AppPlatform {
15
18
  constructor() {
19
+ _AppPlatform_leapDocumentDataService.set(this, null);
16
20
  this._openViaLEAP = false;
17
21
  _AppPlatform_authService.set(this, null);
18
22
  _AppPlatform_signalRInitData.set(this, null);
23
+ _AppPlatform_initialized.set(this, false);
24
+ _AppPlatform_connectedToSignalR.set(this, false);
25
+ _AppPlatform_hostApplicationType.set(this, null);
19
26
  this.loggerService = new services_1.LoggerService(false);
20
27
  this.leapEventsService = new leap_events_service_1.LeapEventsService();
21
28
  this.calcWordService = new services_1.CalcWordService(this.leapEventsService, this.loggerService);
22
29
  this.documentService = new services_1.DocumentService(this.leapEventsService, this.loggerService);
23
30
  this.signalRService = new signalr_service_1.SignalRService();
24
31
  }
25
- init() {
32
+ /**
33
+ * Get the session-scoped LeapDocumentDataService.
34
+ * Throws if init() was not called with a valid host.
35
+ */
36
+ getLeapDocumentDataService() {
37
+ if (!tslib_1.__classPrivateFieldGet(this, _AppPlatform_hostApplicationType, "f")) {
38
+ throw new Error('AppPlatform.init() must be called with a valid host before accessing document data. ' +
39
+ 'Call initAppPlatform(HostApplicationType) first.');
40
+ }
41
+ if (!tslib_1.__classPrivateFieldGet(this, _AppPlatform_leapDocumentDataService, "f")) {
42
+ tslib_1.__classPrivateFieldSet(this, _AppPlatform_leapDocumentDataService, new leap_document_data_1.LeapDocumentDataService(tslib_1.__classPrivateFieldGet(this, _AppPlatform_hostApplicationType, "f")), "f");
43
+ }
44
+ return tslib_1.__classPrivateFieldGet(this, _AppPlatform_leapDocumentDataService, "f");
45
+ }
46
+ init(hostApplicationType, skipLeapEventsSetup, force = false) {
26
47
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
27
48
  try {
28
- const data = yield this.getWordCustomPart();
29
- if (data) {
49
+ if (tslib_1.__classPrivateFieldGet(this, _AppPlatform_initialized, "f") && !force) {
50
+ return { done: true, openViaLEAP: this._openViaLEAP };
51
+ }
52
+ // Store host for session-scoped document data service
53
+ tslib_1.__classPrivateFieldSet(this, _AppPlatform_hostApplicationType, hostApplicationType, "f");
54
+ let openViaLEAP = false;
55
+ switch (hostApplicationType) {
56
+ case leap_model_1.HostApplicationType.MicrosoftWord:
57
+ this.loggerService.log(`[INIT] Microsoft Word`);
58
+ openViaLEAP = !!(yield this.getWordCustomPart());
59
+ break;
60
+ case leap_model_1.HostApplicationType.MicrosoftExcel:
61
+ this.loggerService.log(`[INIT] Microsoft Excel`);
62
+ openViaLEAP = yield this.isLeapWorkbook();
63
+ break;
64
+ }
65
+ if (openViaLEAP) {
30
66
  this._openViaLEAP = true;
31
- this.loggerService.log(`[INIT] Setup LEAP Events and set token in custom xml part`);
32
- yield this.setupLeapEvents();
33
- yield this.setTokenInCustomXml();
34
- return { done: true, openViaLEAP: true };
67
+ try {
68
+ if (hostApplicationType === leap_model_1.HostApplicationType.MicrosoftWord &&
69
+ !skipLeapEventsSetup) {
70
+ yield this.setupLeapEventsAndSetToken();
71
+ }
72
+ tslib_1.__classPrivateFieldSet(this, _AppPlatform_initialized, true, "f");
73
+ return { done: true, openViaLEAP: true };
74
+ }
75
+ catch (_) {
76
+ tslib_1.__classPrivateFieldSet(this, _AppPlatform_initialized, true, "f");
77
+ return { done: true, openViaLEAP: true };
78
+ }
35
79
  }
36
80
  else {
37
81
  this.loggerService.log(`[INIT] Document not open via LEAP`);
38
82
  this._openViaLEAP = false;
83
+ tslib_1.__classPrivateFieldSet(this, _AppPlatform_initialized, true, "f");
39
84
  return { done: true, openViaLEAP: false };
40
85
  }
41
86
  }
42
87
  catch (_) {
88
+ tslib_1.__classPrivateFieldSet(this, _AppPlatform_initialized, true, "f");
89
+ this._openViaLEAP = false;
43
90
  return { done: false, openViaLEAP: false };
44
91
  }
45
92
  });
46
93
  }
94
+ setupLeapEventsAndSetToken() {
95
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
96
+ this.loggerService.log(`[INIT] Setup LEAP Events and set token in custom xml part`);
97
+ yield this.setupLeapEvents();
98
+ yield this.setTokenInCustomXml();
99
+ });
100
+ }
47
101
  connectToSignalR(params) {
48
102
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
103
+ if (tslib_1.__classPrivateFieldGet(this, _AppPlatform_connectedToSignalR, "f")) {
104
+ return true;
105
+ }
49
106
  const { clientId } = params;
50
107
  yield this.signalRService.connectToSignalR();
51
108
  tslib_1.__classPrivateFieldSet(this, _AppPlatform_signalRInitData, yield this.signalRService.getInitData({ clientId }), "f");
52
109
  if (tslib_1.__classPrivateFieldGet(this, _AppPlatform_signalRInitData, "f")) {
53
110
  const { code, codeChallenge, environment } = tslib_1.__classPrivateFieldGet(this, _AppPlatform_signalRInitData, "f");
54
- tslib_1.__classPrivateFieldSet(this, _AppPlatform_authService, new auth_service_1.AuthService({
55
- code,
56
- codeVerifier: codeChallenge,
57
- clientId,
58
- env: environment,
59
- }), "f");
60
- const done = yield tslib_1.__classPrivateFieldGet(this, _AppPlatform_authService, "f").init();
61
- return done;
111
+ if (code && codeChallenge && clientId && environment) {
112
+ tslib_1.__classPrivateFieldSet(this, _AppPlatform_authService, new auth_service_1.AuthService({
113
+ code,
114
+ codeVerifier: codeChallenge,
115
+ clientId,
116
+ env: environment,
117
+ }), "f");
118
+ tslib_1.__classPrivateFieldSet(this, _AppPlatform_connectedToSignalR, yield tslib_1.__classPrivateFieldGet(this, _AppPlatform_authService, "f").init(), "f");
119
+ }
120
+ else {
121
+ tslib_1.__classPrivateFieldSet(this, _AppPlatform_connectedToSignalR, false, "f");
122
+ }
62
123
  }
63
124
  else {
64
- return false;
125
+ tslib_1.__classPrivateFieldSet(this, _AppPlatform_connectedToSignalR, false, "f");
126
+ }
127
+ return tslib_1.__classPrivateFieldGet(this, _AppPlatform_connectedToSignalR, "f");
128
+ });
129
+ }
130
+ getHostInfo(params) {
131
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
132
+ try {
133
+ // Use session-scoped document data service (host passed at init)
134
+ const documentData = yield this.getDocumentData();
135
+ if (documentData && documentData.hostType) {
136
+ return {
137
+ hostType: documentData.hostType,
138
+ hostVersion: null,
139
+ };
140
+ }
141
+ //* check host type in document data custom xml part
142
+ //* we connect signalr with client id and try to get init data like host type and version
143
+ //* when we provide client id, LD would try to issue an code and code challenge for auth
144
+ //* if it fails, it means client doesn't have a proper redirect uri (fourd)
145
+ const connectSignalRWithClientId = yield this.connectToSignalR({
146
+ clientId: params.clientId,
147
+ });
148
+ if (connectSignalRWithClientId) {
149
+ const documentDataBySignalR = yield this.getInitDataViaSignalR();
150
+ if (documentDataBySignalR) {
151
+ return {
152
+ hostType: documentDataBySignalR.hostType || 'desktop',
153
+ hostVersion: documentDataBySignalR.hostVersion || '2.6',
154
+ };
155
+ }
156
+ else {
157
+ return {
158
+ hostType: 'desktop',
159
+ hostVersion: '2.6',
160
+ };
161
+ }
162
+ }
163
+ //* if we can't connect to signalr and it's not open via Web, we would know host is 2.5
164
+ return {
165
+ hostType: 'desktop',
166
+ hostVersion: '2.5',
167
+ };
168
+ }
169
+ catch (error) {
170
+ console.error('Error getting host info:', error);
171
+ return {
172
+ hostType: null,
173
+ hostVersion: null,
174
+ };
65
175
  }
66
176
  });
67
177
  }
@@ -85,12 +195,19 @@ class AppPlatform {
85
195
  getInitDataViaSignalR() {
86
196
  return new Promise((resolve) => {
87
197
  if (tslib_1.__classPrivateFieldGet(this, _AppPlatform_signalRInitData, "f")) {
198
+ let hostVersion = tslib_1.__classPrivateFieldGet(this, _AppPlatform_signalRInitData, "f").hostVersion;
199
+ //* in LD 2.6.137, there is some edge cases that LD would still send 2.5.xxxx as version number
200
+ //* so we need to check if the version is 2.5.xxxx and if it is, we need to set the version to 2.6
201
+ if (!hostVersion || (0, helpers_1.isLD2_5)(hostVersion)) {
202
+ hostVersion = '2.6';
203
+ }
88
204
  const data = {
89
205
  contentModeEnabled: tslib_1.__classPrivateFieldGet(this, _AppPlatform_signalRInitData, "f").contentModeEnabled,
206
+ projectId: tslib_1.__classPrivateFieldGet(this, _AppPlatform_signalRInitData, "f").projectId,
90
207
  country: tslib_1.__classPrivateFieldGet(this, _AppPlatform_signalRInitData, "f").country,
91
208
  countryCode: tslib_1.__classPrivateFieldGet(this, _AppPlatform_signalRInitData, "f").countryCode,
92
209
  hostType: tslib_1.__classPrivateFieldGet(this, _AppPlatform_signalRInitData, "f").hostType,
93
- hostVersion: tslib_1.__classPrivateFieldGet(this, _AppPlatform_signalRInitData, "f").hostVersion,
210
+ hostVersion: hostVersion,
94
211
  environment: tslib_1.__classPrivateFieldGet(this, _AppPlatform_signalRInitData, "f").environment,
95
212
  firmId: tslib_1.__classPrivateFieldGet(this, _AppPlatform_signalRInitData, "f").firmId,
96
213
  staffId: tslib_1.__classPrivateFieldGet(this, _AppPlatform_signalRInitData, "f").staffId,
@@ -104,22 +221,107 @@ class AppPlatform {
104
221
  }
105
222
  });
106
223
  }
224
+ openDocumentViaSignalR(params) {
225
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
226
+ try {
227
+ const done = yield this.signalRService.openDocument(params);
228
+ return done;
229
+ }
230
+ catch (error) {
231
+ return false;
232
+ }
233
+ });
234
+ }
235
+ openMatterViaSignalR(params) {
236
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
237
+ try {
238
+ const done = yield this.signalRService.openMatter(params);
239
+ return done;
240
+ }
241
+ catch (error) {
242
+ return false;
243
+ }
244
+ });
245
+ }
246
+ setBookmarkViaSignalR(params) {
247
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
248
+ try {
249
+ if (!this._openViaLEAP) {
250
+ this.loggerService.log(`[setBookmarkViaSignalR] Document not open via LEAP`);
251
+ return false;
252
+ }
253
+ else {
254
+ const done = yield this.signalRService.setBookmark(params);
255
+ return done;
256
+ }
257
+ }
258
+ catch (error) {
259
+ return false;
260
+ }
261
+ });
262
+ }
107
263
  getDocumentData() {
108
264
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
109
265
  try {
266
+ const service = this.getLeapDocumentDataService();
267
+ return yield service.get();
268
+ }
269
+ catch (error) {
270
+ this.loggerService.error(`[ERROR] Get Document Data: ${error}`);
271
+ return null;
272
+ }
273
+ });
274
+ }
275
+ /**
276
+ * @deprecated Use getDocumentData() instead. The host is now determined by init().
277
+ * This method will be removed in a future version.
278
+ */
279
+ getExcelDocumentData() {
280
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
281
+ this.loggerService.warn('[DEPRECATED] getExcelDocumentData() is deprecated. Use getDocumentData() instead.');
282
+ return this.getDocumentData();
283
+ });
284
+ }
285
+ setDocumentData(params) {
286
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
287
+ try {
288
+ const { documentData } = params;
110
289
  if (!this._openViaLEAP) {
111
- this.loggerService.log(`[getDocumentData] Document not open via LEAP`);
290
+ this.loggerService.log(`[setDocumentData] Document not open via LEAP`);
291
+ return false;
292
+ }
293
+ const service = this.getLeapDocumentDataService();
294
+ yield service.set(documentData);
295
+ return true;
296
+ }
297
+ catch (error) {
298
+ this.loggerService.error(`[ERROR] Set Document Data: ${error}`);
299
+ return false;
300
+ }
301
+ });
302
+ }
303
+ getAddinData() {
304
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
305
+ try {
306
+ if (!this._openViaLEAP) {
307
+ this.loggerService.log(`[getAddinData] Document not open via LEAP`);
112
308
  return null;
113
309
  }
114
- //todo don't use any in getDataByNamespace's response
115
- const data = yield (0, custom_xml_part_service_1.getDataByNamespace)(constants_1.constants.LeapDocumentDataNamespace);
116
- if (data) {
117
- return data;
310
+ const addInData = yield (0, custom_xml_part_service_1.getDataByNamespace)(constants_1.constants.LeapOfficeAddInDataNamespace);
311
+ let data;
312
+ if (addInData && addInData.dataString) {
313
+ try {
314
+ const dataStringDecoded = (0, helpers_1.b64DecodeUnicode)(addInData.dataString) || '""';
315
+ data = JSON.parse(dataStringDecoded);
316
+ }
317
+ catch (_) {
318
+ return data;
319
+ }
118
320
  }
119
- return null;
321
+ return data;
120
322
  }
121
323
  catch (error) {
122
- this.loggerService.error(`[ERROR] Get Document Data: ${error}`);
324
+ this.loggerService.error(`[ERROR] Get Addin Data: ${error}`);
123
325
  return null;
124
326
  }
125
327
  });
@@ -145,11 +347,36 @@ class AppPlatform {
145
347
  }
146
348
  createDocument(params) {
147
349
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
350
+ const { precedentId, body, closeExisting, additionalData } = params;
351
+ const documentData = yield this.getDocumentData();
352
+ const promptId = documentData && documentData.precedentId ? documentData.precedentId : '';
148
353
  if (!this._openViaLEAP) {
149
354
  this.loggerService.log(`[createDocument] Document not open via LEAP`);
150
355
  return null;
151
356
  }
152
- return this.documentService.createDocument(params);
357
+ let additionalAddinData = '';
358
+ if (additionalData) {
359
+ try {
360
+ additionalAddinData =
361
+ (0, helpers_1.b64EncodeUnicode)(JSON.stringify(additionalData)) || '';
362
+ }
363
+ catch (_) {
364
+ additionalAddinData = '';
365
+ }
366
+ }
367
+ const data = {
368
+ precedentId,
369
+ body,
370
+ promptId,
371
+ closeExisting,
372
+ additionalAddinData,
373
+ };
374
+ return this.documentService.createDocument(data);
375
+ });
376
+ }
377
+ saveDocument() {
378
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
379
+ return this.documentService.saveDocument();
153
380
  });
154
381
  }
155
382
  setupLeapEvents() {
@@ -213,7 +440,7 @@ class AppPlatform {
213
440
  getWordCustomPart() {
214
441
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
215
442
  try {
216
- const data = yield (0, custom_xml_part_service_1.getDataByNamespace)(constants_1.constants.LeapWordCustomPartNamespace, 0);
443
+ const data = yield (0, custom_xml_part_service_1.getDataByNamespace)(constants_1.constants.LeapWordCustomPartNamespace, 3);
217
444
  if (data) {
218
445
  return data;
219
446
  }
@@ -225,7 +452,15 @@ class AppPlatform {
225
452
  }
226
453
  });
227
454
  }
455
+ isLeapWorkbook() {
456
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
457
+ return yield Excel.run((context) => tslib_1.__awaiter(this, void 0, void 0, function* () {
458
+ const leapUniqueCode = context.workbook.names.getItemOrNullObject('LEAPUniqueCode');
459
+ yield context.sync();
460
+ return !leapUniqueCode.isNullObject;
461
+ }));
462
+ });
463
+ }
228
464
  }
229
465
  exports.AppPlatform = AppPlatform;
230
- _AppPlatform_authService = new WeakMap(), _AppPlatform_signalRInitData = new WeakMap();
231
- //# sourceMappingURL=app-platform.js.map
466
+ _AppPlatform_leapDocumentDataService = new WeakMap(), _AppPlatform_authService = new WeakMap(), _AppPlatform_signalRInitData = new WeakMap(), _AppPlatform_initialized = new WeakMap(), _AppPlatform_connectedToSignalR = new WeakMap(), _AppPlatform_hostApplicationType = new WeakMap();
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Barrel export for the LeapDocumentData domain.
3
+ *
4
+ * Domain pattern: model, normalizer, service
5
+ */
6
+ export * from './leap-document-data.model';
7
+ export * from './leap-document-data.normalizer';
8
+ export * from './leap-document-data.service';
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ /**
5
+ * Barrel export for the LeapDocumentData domain.
6
+ *
7
+ * Domain pattern: model, normalizer, service
8
+ */
9
+ tslib_1.__exportStar(require("./leap-document-data.model"), exports);
10
+ tslib_1.__exportStar(require("./leap-document-data.normalizer"), exports);
11
+ tslib_1.__exportStar(require("./leap-document-data.service"), exports);
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Re-export the LeapDocumentData model from the main models directory.
3
+ *
4
+ * This maintains backward compatibility while establishing the domain pattern.
5
+ * Future domains should define their models here directly.
6
+ */
7
+ export { LeapDocumentData } from '../../models/leap.model';
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LeapDocumentData = void 0;
4
+ /**
5
+ * Re-export the LeapDocumentData model from the main models directory.
6
+ *
7
+ * This maintains backward compatibility while establishing the domain pattern.
8
+ * Future domains should define their models here directly.
9
+ */
10
+ var leap_model_1 = require("../../models/leap.model");
11
+ Object.defineProperty(exports, "LeapDocumentData", { enumerable: true, get: function () { return leap_model_1.LeapDocumentData; } });