@leapdev/app-platform 0.1.0-beta.4 → 0.1.0-beta.6

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 (142) hide show
  1. package/package.json +15 -15
  2. package/src/index.d.ts +25 -0
  3. package/src/index.js +42 -0
  4. package/src/index.js.map +1 -0
  5. package/src/lib/app-platform.d.ts +37 -0
  6. package/src/lib/app-platform.js +231 -0
  7. package/src/lib/app-platform.js.map +1 -0
  8. package/src/lib/environment/environment.d.ts +37 -0
  9. package/src/lib/environment/environment.dictionary.d.ts +4 -0
  10. package/src/lib/environment/environment.dictionary.js +30 -0
  11. package/src/lib/environment/environment.dictionary.js.map +1 -0
  12. package/src/lib/environment/environment.js +17 -0
  13. package/src/lib/environment/environment.js.map +1 -0
  14. package/src/lib/environment/{index.ts → index.d.ts} +2 -2
  15. package/src/lib/environment/index.js +9 -0
  16. package/src/lib/environment/index.js.map +1 -0
  17. package/src/lib/environment/leap/env.dev.au.config.d.ts +32 -0
  18. package/src/lib/environment/leap/env.dev.au.config.js +36 -0
  19. package/src/lib/environment/leap/env.dev.au.config.js.map +1 -0
  20. package/src/lib/environment/leap/env.live.au.config.d.ts +32 -0
  21. package/src/lib/environment/leap/env.live.au.config.js +36 -0
  22. package/src/lib/environment/leap/env.live.au.config.js.map +1 -0
  23. package/src/lib/environment/leap/env.live.ca.config.d.ts +32 -0
  24. package/src/lib/environment/leap/env.live.ca.config.js +36 -0
  25. package/src/lib/environment/leap/env.live.ca.config.js.map +1 -0
  26. package/src/lib/environment/leap/env.live.nz.config.d.ts +32 -0
  27. package/src/lib/environment/leap/env.live.nz.config.js +36 -0
  28. package/src/lib/environment/leap/env.live.nz.config.js.map +1 -0
  29. package/src/lib/environment/leap/env.live.uk.config.d.ts +32 -0
  30. package/src/lib/environment/leap/env.live.uk.config.js +36 -0
  31. package/src/lib/environment/leap/env.live.uk.config.js.map +1 -0
  32. package/src/lib/environment/leap/env.live.us.config.d.ts +32 -0
  33. package/src/lib/environment/leap/env.live.us.config.js +36 -0
  34. package/src/lib/environment/leap/env.live.us.config.js.map +1 -0
  35. package/src/lib/environment/leap/env.liveb.au.config.d.ts +32 -0
  36. package/src/lib/environment/leap/env.liveb.au.config.js +36 -0
  37. package/src/lib/environment/leap/env.liveb.au.config.js.map +1 -0
  38. package/src/lib/environment/leap/env.test.au.config.d.ts +32 -0
  39. package/src/lib/environment/leap/env.test.au.config.js +36 -0
  40. package/src/lib/environment/leap/env.test.au.config.js.map +1 -0
  41. package/src/lib/environment/leap/env.test.ca.config.d.ts +32 -0
  42. package/src/lib/environment/leap/env.test.ca.config.js +36 -0
  43. package/src/lib/environment/leap/env.test.ca.config.js.map +1 -0
  44. package/src/lib/environment/leap/env.test.nz.config.d.ts +32 -0
  45. package/src/lib/environment/leap/env.test.nz.config.js +36 -0
  46. package/src/lib/environment/leap/env.test.nz.config.js.map +1 -0
  47. package/src/lib/environment/leap/env.test.uk.config.d.ts +32 -0
  48. package/src/lib/environment/leap/env.test.uk.config.js +36 -0
  49. package/src/lib/environment/leap/env.test.uk.config.js.map +1 -0
  50. package/src/lib/environment/leap/env.test.us.config.d.ts +32 -0
  51. package/src/lib/environment/leap/env.test.us.config.js +36 -0
  52. package/src/lib/environment/leap/env.test.us.config.js.map +1 -0
  53. package/src/lib/functions/helpers.d.ts +5 -0
  54. package/src/lib/functions/helpers.js +95 -0
  55. package/src/lib/functions/helpers.js.map +1 -0
  56. package/src/lib/functions/xml.d.ts +2 -0
  57. package/src/lib/functions/xml.js +41 -0
  58. package/src/lib/functions/xml.js.map +1 -0
  59. package/src/lib/models/calc-api.model.d.ts +57 -0
  60. package/src/lib/models/calc-api.model.js +39 -0
  61. package/src/lib/models/calc-api.model.js.map +1 -0
  62. package/src/lib/models/constants/index.d.ts +28 -0
  63. package/src/lib/models/constants/index.js +32 -0
  64. package/src/lib/models/constants/index.js.map +1 -0
  65. package/src/lib/models/{index.ts → index.d.ts} +1 -1
  66. package/src/lib/models/index.js +5 -0
  67. package/src/lib/models/index.js.map +1 -0
  68. package/src/lib/models/leap-events.model.d.ts +56 -0
  69. package/src/lib/models/leap-events.model.js +71 -0
  70. package/src/lib/models/leap-events.model.js.map +1 -0
  71. package/src/lib/models/leap.model.d.ts +65 -0
  72. package/src/lib/models/leap.model.js +29 -0
  73. package/src/lib/models/leap.model.js.map +1 -0
  74. package/src/lib/models/signalr.model.d.ts +21 -0
  75. package/src/lib/models/signalr.model.js +3 -0
  76. package/src/lib/models/signalr.model.js.map +1 -0
  77. package/src/lib/services/auth/auth.service.d.ts +13 -0
  78. package/src/lib/services/auth/auth.service.js +185 -0
  79. package/src/lib/services/auth/auth.service.js.map +1 -0
  80. package/src/lib/services/calc-api/calc-api-service.interface.d.ts +4 -0
  81. package/src/lib/services/calc-api/calc-api-service.interface.js +3 -0
  82. package/src/lib/services/calc-api/calc-api-service.interface.js.map +1 -0
  83. package/src/lib/services/calc-api/calc-word.service.d.ts +10 -0
  84. package/src/lib/services/calc-api/calc-word.service.js +63 -0
  85. package/src/lib/services/calc-api/calc-word.service.js.map +1 -0
  86. package/src/lib/services/calc-api/promise-helper.function.d.ts +2 -0
  87. package/src/lib/services/calc-api/promise-helper.function.js +32 -0
  88. package/src/lib/services/calc-api/promise-helper.function.js.map +1 -0
  89. package/src/lib/services/custom-xml-part.service.d.ts +5 -0
  90. package/src/lib/services/custom-xml-part.service.js +269 -0
  91. package/src/lib/services/custom-xml-part.service.js.map +1 -0
  92. package/src/lib/services/document/document.service.d.ts +16 -0
  93. package/src/lib/services/document/document.service.js +32 -0
  94. package/src/lib/services/document/document.service.js.map +1 -0
  95. package/src/lib/services/{index.ts → index.d.ts} +5 -10
  96. package/src/lib/services/index.js +9 -0
  97. package/src/lib/services/index.js.map +1 -0
  98. package/src/lib/services/leap-events.service.d.ts +26 -0
  99. package/src/lib/services/leap-events.service.js +357 -0
  100. package/src/lib/services/leap-events.service.js.map +1 -0
  101. package/src/lib/services/logger/logger.service.d.ts +10 -0
  102. package/src/lib/services/logger/logger.service.js +39 -0
  103. package/src/lib/services/logger/logger.service.js.map +1 -0
  104. package/src/lib/services/signalr/signalr.service.d.ts +9 -0
  105. package/src/lib/services/signalr/signalr.service.js +93 -0
  106. package/src/lib/services/signalr/signalr.service.js.map +1 -0
  107. package/.eslintrc.json +0 -25
  108. package/project.json +0 -27
  109. package/src/index.ts +0 -44
  110. package/src/lib/app-platform.ts +0 -270
  111. package/src/lib/environment/environment.dictionary.ts +0 -28
  112. package/src/lib/environment/environment.ts +0 -44
  113. package/src/lib/environment/leap/env.dev.au.config.ts +0 -33
  114. package/src/lib/environment/leap/env.live.au.config.ts +0 -32
  115. package/src/lib/environment/leap/env.live.ca.config.ts +0 -32
  116. package/src/lib/environment/leap/env.live.nz.config.ts +0 -32
  117. package/src/lib/environment/leap/env.live.uk.config.ts +0 -32
  118. package/src/lib/environment/leap/env.live.us.config.ts +0 -32
  119. package/src/lib/environment/leap/env.liveb.au.config.ts +0 -32
  120. package/src/lib/environment/leap/env.test.au.config.ts +0 -33
  121. package/src/lib/environment/leap/env.test.ca.config.ts +0 -33
  122. package/src/lib/environment/leap/env.test.nz.config.ts +0 -33
  123. package/src/lib/environment/leap/env.test.uk.config.ts +0 -33
  124. package/src/lib/environment/leap/env.test.us.config.ts +0 -33
  125. package/src/lib/functions/helpers.ts +0 -100
  126. package/src/lib/functions/xml.ts +0 -41
  127. package/src/lib/models/calc-api.model.ts +0 -74
  128. package/src/lib/models/constants/index.ts +0 -29
  129. package/src/lib/models/leap-events.model.ts +0 -79
  130. package/src/lib/models/leap.model.ts +0 -78
  131. package/src/lib/models/signalr.model.ts +0 -22
  132. package/src/lib/services/auth/auth.service.ts +0 -219
  133. package/src/lib/services/calc-api/calc-api-service.interface.ts +0 -12
  134. package/src/lib/services/calc-api/calc-word.service.ts +0 -117
  135. package/src/lib/services/calc-api/promise-helper.function.ts +0 -26
  136. package/src/lib/services/custom-xml-part.service.ts +0 -340
  137. package/src/lib/services/document/document.service.ts +0 -33
  138. package/src/lib/services/leap-events.service.ts +0 -489
  139. package/src/lib/services/logger/logger.service.ts +0 -42
  140. package/src/lib/services/signalr/signalr.service.ts +0 -88
  141. package/tsconfig.json +0 -20
  142. package/tsconfig.lib.json +0 -12
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var _SignalRService_instances, _SignalRService_sessionId, _SignalRService_automationHubUrl, _SignalRService_connection, _SignalRService_createConnection;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.SignalRService = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const uuid_1 = require("uuid");
7
+ const signalR = tslib_1.__importStar(require("@microsoft/signalr"));
8
+ class SignalRService {
9
+ constructor() {
10
+ _SignalRService_instances.add(this);
11
+ _SignalRService_sessionId.set(this, void 0);
12
+ _SignalRService_automationHubUrl.set(this, void 0);
13
+ _SignalRService_connection.set(this, void 0);
14
+ tslib_1.__classPrivateFieldSet(this, _SignalRService_automationHubUrl, 'http://localhost:7214/automationHub', "f");
15
+ tslib_1.__classPrivateFieldSet(this, _SignalRService_sessionId, (0, uuid_1.v4)(), "f");
16
+ }
17
+ connectToSignalR() {
18
+ if (!tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
19
+ tslib_1.__classPrivateFieldGet(this, _SignalRService_instances, "m", _SignalRService_createConnection).call(this, tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f"));
20
+ return new Promise((resolve) => {
21
+ if (tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
22
+ tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")
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
+ });
31
+ }
32
+ else {
33
+ console.log('Unable to connect to signalR: no connection');
34
+ resolve('');
35
+ }
36
+ });
37
+ }
38
+ else {
39
+ return new Promise((resolve) => resolve(tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f")));
40
+ }
41
+ }
42
+ getInitData(params) {
43
+ if (tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
44
+ const { clientId } = params;
45
+ const requestId = (0, uuid_1.v4)();
46
+ const payload = {
47
+ source: 'automationCore',
48
+ sessionId: tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f"),
49
+ requestId,
50
+ action: "init_data",
51
+ payload: {
52
+ clientId
53
+ }
54
+ };
55
+ return new Promise(resolve => {
56
+ if (tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
57
+ tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f").invoke("ProcessMessage", payload, true).then(() => {
58
+ if (tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
59
+ tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f").on("ProcessMessage", (message) => {
60
+ if (message.sessionId === tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f") && message.requestId === requestId) {
61
+ resolve(message.payload);
62
+ }
63
+ });
64
+ }
65
+ }).catch((e) => {
66
+ console.log('SignalR sendMessage error', e);
67
+ return resolve(null);
68
+ });
69
+ }
70
+ });
71
+ }
72
+ else {
73
+ return new Promise(resolve => resolve(null));
74
+ }
75
+ }
76
+ }
77
+ exports.SignalRService = SignalRService;
78
+ _SignalRService_sessionId = new WeakMap(), _SignalRService_automationHubUrl = new WeakMap(), _SignalRService_connection = new WeakMap(), _SignalRService_instances = new WeakSet(), _SignalRService_createConnection = function _SignalRService_createConnection(sessionId) {
79
+ if (tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
80
+ return;
81
+ }
82
+ const url = `${tslib_1.__classPrivateFieldGet(this, _SignalRService_automationHubUrl, "f")}?sessionId=${sessionId}`;
83
+ try {
84
+ tslib_1.__classPrivateFieldSet(this, _SignalRService_connection, new signalR.HubConnectionBuilder()
85
+ .withUrl(url)
86
+ .withAutomaticReconnect()
87
+ .build(), "f");
88
+ }
89
+ catch (_) {
90
+ tslib_1.__classPrivateFieldSet(this, _SignalRService_connection, undefined, "f");
91
+ }
92
+ };
93
+ //# sourceMappingURL=signalr.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signalr.service.js","sourceRoot":"","sources":["../../../../../../../packages/app-platform/src/lib/services/signalr/signalr.service.ts"],"names":[],"mappings":"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"}
package/.eslintrc.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- "extends": ["../../.eslintrc.json"],
3
- "ignorePatterns": ["!**/*"],
4
- "overrides": [
5
- {
6
- "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7
- "rules": {}
8
- },
9
- {
10
- "files": ["*.ts", "*.tsx"],
11
- "rules": {}
12
- },
13
- {
14
- "files": ["*.js", "*.jsx"],
15
- "rules": {}
16
- },
17
- {
18
- "files": ["*.json"],
19
- "parser": "jsonc-eslint-parser",
20
- "rules": {
21
- "@nx/dependency-checks": "error"
22
- }
23
- }
24
- ]
25
- }
package/project.json DELETED
@@ -1,27 +0,0 @@
1
- {
2
- "name": "app-platform",
3
- "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
- "sourceRoot": "packages/app-platform/src",
5
- "projectType": "library",
6
- "targets": {
7
- "build": {
8
- "executor": "@nx/js:tsc",
9
- "outputs": ["{options.outputPath}"],
10
- "options": {
11
- "outputPath": "dist/packages/app-platform",
12
- "main": "packages/app-platform/src/index.ts",
13
- "tsConfig": "packages/app-platform/tsconfig.lib.json",
14
- "assets": ["packages/app-platform/*.md"]
15
- }
16
- },
17
- "publish": {
18
- "command": "node tools/scripts/publish.mjs app-platform {args.ver} {args.tag}",
19
- "dependsOn": ["build"]
20
- },
21
- "lint": {
22
- "executor": "@nx/eslint:lint",
23
- "outputs": ["{options.outputFile}"]
24
- }
25
- },
26
- "tags": []
27
- }
package/src/index.ts DELETED
@@ -1,44 +0,0 @@
1
- export * from './lib/environment';
2
- export * from './lib/models';
3
- export * from './lib/services';
4
-
5
- import { AppPlatform } from './lib/app-platform';
6
- import { EvaluatePathsRequest } from './lib/models';
7
-
8
- const appPlatform = new AppPlatform();
9
-
10
- export const initAppPlatform = () => {
11
- return appPlatform.init();
12
- };
13
-
14
- export const getDocumentData = () => {
15
- return appPlatform.getDocumentData();
16
- };
17
-
18
- export const evaluatePaths = (request: EvaluatePathsRequest) => {
19
- return appPlatform.evaluatePaths(request);
20
- };
21
-
22
- export const createDocument = (params: {
23
- precedentId: string;
24
- body: string;
25
- closeExisting?: boolean;
26
- }) => {
27
- return appPlatform.createDocument(params);
28
- };
29
-
30
- export const getLEAPTokenViaSignalR = (forceRefresh?: boolean) => {
31
- return appPlatform.getLEAPTokenViaSignalR(forceRefresh);
32
- };
33
-
34
- export const getLEAPUserViaSignalR = () => {
35
- return appPlatform.getLEAPUserViaSignalR();
36
- };
37
-
38
- export const getInitDataViaSignalR = () => {
39
- return appPlatform.getInitDataViaSignalR();
40
- };
41
-
42
- export const connectSignalR = (params: { clientId: string }) => {
43
- return appPlatform.connectToSignalR(params);
44
- };
@@ -1,270 +0,0 @@
1
- import { EvaluatePathsRequest, EvaluatePathsResponse } from './models';
2
- import { constants } from './models/constants';
3
- import {
4
- LeapEvent,
5
- LeapEventAction,
6
- LeapEventType,
7
- } from './models/leap-events.model';
8
- import { LeapDocumentData, LEAPUser } from './models/leap.model';
9
- import { SignalRInitData } from './models/signalr.model';
10
- import { CalcWordService, DocumentService, LoggerService } from './services';
11
- import { AuthService } from './services/auth/auth.service';
12
- import { timeout } from './services/calc-api/promise-helper.function';
13
- import { getDataByNamespace } from './services/custom-xml-part.service';
14
- import { LeapEventsService } from './services/leap-events.service';
15
- import { SignalRService } from './services/signalr/signalr.service';
16
-
17
- export class AppPlatform {
18
- private leapEventsService: LeapEventsService;
19
- private loggerService: LoggerService;
20
- private calcWordService: CalcWordService;
21
- private documentService: DocumentService;
22
- private signalRService: SignalRService;
23
- private _openViaLEAP: boolean = false;
24
- #authService: AuthService | null = null;
25
- #signalRInitData: SignalRInitData | null = null;
26
-
27
- constructor() {
28
- this.loggerService = new LoggerService(false);
29
- this.leapEventsService = new LeapEventsService();
30
- this.calcWordService = new CalcWordService(
31
- this.leapEventsService,
32
- this.loggerService
33
- );
34
- this.documentService = new DocumentService(
35
- this.leapEventsService,
36
- this.loggerService
37
- );
38
- this.signalRService = new SignalRService();
39
- }
40
-
41
- public async init(): Promise<{done: boolean; openViaLEAP: boolean}> {
42
- try {
43
- const data = await this.getWordCustomPart();
44
- if (data) {
45
- this._openViaLEAP = true;
46
- this.loggerService.log(
47
- `[INIT] Setup LEAP Events and set token in custom xml part`
48
- );
49
- await this.setupLeapEvents();
50
- await this.setTokenInCustomXml();
51
- return { done: true, openViaLEAP: true };
52
- } else {
53
- this.loggerService.log(`[INIT] Document not open via LEAP`);
54
- this._openViaLEAP = false;
55
- return { done: true, openViaLEAP: false };
56
- }
57
- } catch (_) {
58
- return { done: false, openViaLEAP: false };
59
- }
60
- }
61
-
62
- public async connectToSignalR(params: { clientId: string }): Promise<boolean> {
63
- const { clientId } = params;
64
- await this.signalRService.connectToSignalR();
65
- this.#signalRInitData = await this.signalRService.getInitData({ clientId });
66
- if (this.#signalRInitData) {
67
- const { code, codeChallenge, environment } = this.#signalRInitData;
68
- this.#authService = new AuthService({
69
- code,
70
- codeVerifier: codeChallenge,
71
- clientId,
72
- env: environment,
73
- });
74
- const done = await this.#authService.init();
75
- return done;
76
- } else {
77
- return false;
78
- }
79
- }
80
-
81
- public getLEAPTokenViaSignalR(forceRefresh?: boolean): Promise<string> {
82
- if (this.#authService) {
83
- return this.#authService.getRefreshedAccessToken(forceRefresh);
84
- } else {
85
- return new Promise((resolve) => resolve(''));
86
- }
87
- }
88
-
89
- public getLEAPUserViaSignalR(): Promise<LEAPUser | undefined> {
90
- if (this.#authService) {
91
- const user = this.#authService.getLEAPUser();
92
- return new Promise((resolve) => resolve(user));
93
- } else {
94
- return new Promise((resolve) => resolve(undefined));
95
- }
96
- }
97
-
98
- public getInitDataViaSignalR(): Promise<Omit<
99
- SignalRInitData,
100
- 'code' | 'codeChallenge'
101
- > | null> {
102
- return new Promise((resolve) => {
103
- if (this.#signalRInitData) {
104
- const data: Omit<SignalRInitData, 'code' | 'codeChallenge'> = {
105
- contentModeEnabled: this.#signalRInitData.contentModeEnabled,
106
- country: this.#signalRInitData.country,
107
- countryCode: this.#signalRInitData.countryCode,
108
- hostType: this.#signalRInitData.hostType,
109
- hostVersion: this.#signalRInitData.hostVersion,
110
- environment: this.#signalRInitData.environment,
111
- firmId: this.#signalRInitData.firmId,
112
- staffId: this.#signalRInitData.staffId,
113
- userId: this.#signalRInitData.userId,
114
- userName: this.#signalRInitData.userName,
115
- };
116
- resolve(data);
117
- } else {
118
- resolve(null);
119
- }
120
- });
121
- }
122
-
123
- public async getDocumentData(): Promise<LeapDocumentData | null> {
124
- try {
125
- if (!this._openViaLEAP) {
126
- this.loggerService.log(`[getDocumentData] Document not open via LEAP`);
127
- return null;
128
- }
129
- //todo don't use any in getDataByNamespace's response
130
- const data = await getDataByNamespace(
131
- constants.LeapDocumentDataNamespace
132
- );
133
- if (data) {
134
- return data as LeapDocumentData;
135
- }
136
- return null;
137
- } catch (error) {
138
- this.loggerService.error(`[ERROR] Get Document Data: ${error}`);
139
- return null;
140
- }
141
- }
142
-
143
- public async evaluatePaths(
144
- request: EvaluatePathsRequest
145
- ): Promise<Array<EvaluatePathsResponse> | null> {
146
- try {
147
- if (!this._openViaLEAP) {
148
- this.loggerService.log(`[evaluatePaths] Document not open via LEAP`);
149
- return null;
150
- }
151
- const data = await this.calcWordService.evaluatePaths(request);
152
- if (data) {
153
- return data;
154
- }
155
- return null;
156
- } catch (error) {
157
- this.loggerService.error(`[ERROR] Evaluate Paths: ${error}`);
158
- return null;
159
- }
160
- }
161
-
162
- public async createDocument(params: {
163
- precedentId: string;
164
- body: string;
165
- closeExisting?: boolean;
166
- }) {
167
- if (!this._openViaLEAP) {
168
- this.loggerService.log(`[createDocument] Document not open via LEAP`);
169
- return null;
170
- }
171
- return this.documentService.createDocument(params);
172
- }
173
-
174
- private async setupLeapEvents(): Promise<void> {
175
- try {
176
- await this.leapEventsService.addHandler(
177
- Office.EventType.NodeInserted,
178
- (result: Office.NodeInsertedEventArgs) => {
179
- this.leapEventsService.handleCustomXmlPartNodeEvent(
180
- Office.EventType.NodeInserted,
181
- result
182
- );
183
- }
184
- );
185
- } catch (error) {
186
- this.loggerService.error(`[SetupLeapEvents] Failed: ${error}`);
187
- }
188
- }
189
-
190
- private setTokenInCustomXml(): Promise<void> {
191
- let subscriptionId: string;
192
- return new Promise((resolve, reject) => {
193
- Promise.resolve(() => {
194
- this.loggerService.log(`[LEAP Event] WordApp_GetToken`);
195
- })
196
- .then(() => {
197
- const id = new Date().getTime().toString();
198
- return this.leapEventsService.addEvent({
199
- id,
200
- correlationId: null,
201
- eventType: LeapEventType.WordAppEvent,
202
- action: LeapEventAction.WordApp_GetToken,
203
- data: null,
204
- });
205
- })
206
- .then((event) => {
207
- this.loggerService.log('[LEAP Event] WordApp_GetToken request sent');
208
-
209
- // Subscribe
210
- const leapEventResponseHandlerPromise = new Promise<Array<any>>(
211
- (innerResolve, innerReject) => {
212
- subscriptionId = this.leapEventsService.subscribe(
213
- event.id,
214
- LeapEventType.WordAppEventResponse,
215
- LeapEventAction.WordApp_GetTokenResponse,
216
- (leapEvent: LeapEvent) =>
217
- this.leapEventsService.handleLeapEventResponse<Array<any>>(
218
- leapEvent,
219
- { resolve: innerResolve, reject: innerReject }
220
- )
221
- );
222
- }
223
- );
224
-
225
- return timeout(leapEventResponseHandlerPromise, 1000);
226
- })
227
- .then(() => {
228
- // Return result
229
- resolve();
230
- })
231
- .catch((error: any) => {
232
- this.loggerService.error(
233
- `[LEAP Event] WordApp_GetToken request failed: ${error}`
234
- );
235
- reject(error);
236
- })
237
- .then(() => {
238
- // Unsubscribe
239
- return this.leapEventsService.unsubscribe(subscriptionId);
240
- })
241
- .then((unsubscribeSuccess: boolean) => {
242
- if (unsubscribeSuccess === true) {
243
- this.loggerService.log(
244
- `[LEAP Event] WordApp_GetToken request successfully unsubscribed ${subscriptionId}`
245
- );
246
- } else {
247
- this.loggerService.warn(
248
- `[LEAP Event] WordApp_GetToken request failed to unsubscribe from ${subscriptionId}`
249
- );
250
- }
251
- });
252
- });
253
- }
254
-
255
- private async getWordCustomPart(): Promise<{ LEAP_GUID: string } | null> {
256
- try {
257
- const data = await getDataByNamespace(
258
- constants.LeapWordCustomPartNamespace,
259
- 0
260
- );
261
- if (data) {
262
- return data;
263
- }
264
- return null;
265
- } catch (error) {
266
- this.loggerService.error(`[ERROR] Get WordCustomPart: ${error}`);
267
- return null;
268
- }
269
- }
270
- }
@@ -1,28 +0,0 @@
1
- import { leap_dev_au } from './leap/env.dev.au.config';
2
- import { leap_test_au } from './leap/env.test.au.config';
3
- import { leap_live_au } from './leap/env.live.au.config';
4
- import { leap_liveb_au } from './leap/env.liveb.au.config';
5
- import { leap_test_nz } from './leap/env.test.nz.config';
6
- import { leap_live_nz } from './leap/env.live.nz.config';
7
- import { leap_test_us } from './leap/env.test.us.config';
8
- import { leap_live_us } from './leap/env.live.us.config';
9
- import { leap_test_ca } from './leap/env.test.ca.config';
10
- import { leap_live_ca } from './leap/env.live.ca.config';
11
- import { leap_test_uk } from './leap/env.test.uk.config';
12
- import { leap_live_uk } from './leap/env.live.uk.config';
13
- import { Environment } from './environment';
14
-
15
- export const environment_dictionary: { [key: string]: Environment } = {
16
- leap_dev_au,
17
- leap_test_au,
18
- leap_live_au,
19
- leap_liveb_au,
20
- leap_test_nz,
21
- leap_live_nz,
22
- leap_test_uk,
23
- leap_live_uk,
24
- leap_test_us,
25
- leap_live_us,
26
- leap_test_ca,
27
- leap_live_ca,
28
- };
@@ -1,44 +0,0 @@
1
- export abstract class Environment {
2
- abstract envName: string; // Default
3
- abstract brand: string;
4
- abstract region: string;
5
- abstract production: boolean;
6
- abstract imports: any[];
7
- abstract keys: {
8
- pnSubscribe: string;
9
- };
10
- abstract authApi: {
11
- baseUrl: string;
12
- clientId: string;
13
- redirectPath: string;
14
- };
15
- abstract automation: string;
16
- abstract docsApi: string;
17
- abstract schemaApi: string;
18
- abstract leapDesignApi: {
19
- baseUrl: string;
20
- projectId: string;
21
- };
22
- abstract calcApi: {
23
- remote: string;
24
- local?: string;
25
- };
26
- abstract docBuilderApi: {
27
- remote: string;
28
- local?: string;
29
- };
30
- abstract pubSubApi: string;
31
- abstract pubSubNotificationPublishKey: string;
32
- }
33
-
34
- export class LeapEnvironment {
35
- static config: Environment = {} as Environment;
36
-
37
- static getConfig(): Environment {
38
- return this.config;
39
- }
40
-
41
- static setConfig(newConfig: Environment): void {
42
- this.config = newConfig;
43
- }
44
- }
@@ -1,33 +0,0 @@
1
- export const leap_dev_au = {
2
- envName: 'dev',
3
- brand: 'LEAP',
4
- region: 'au',
5
- production: false,
6
- imports: [],
7
- keys: {
8
- pnSubscribe: 'sub-a456f002-0095-11e2-9638-9581afc33ebf',
9
- },
10
- authApi: {
11
- baseUrl: 'https://auth.dev.leap.services',
12
- clientId: 'OBIUNINUL9DBSR8F',
13
- redirectPath: 'index.html',
14
- },
15
- automation: 'https://office-automation-api-dev.leapaws.com.au',
16
- docsApi: 'https://api-docs-dev.leapaws.com.au',
17
- schemaApi: 'https://schema-api.dev.leap.services',
18
- leapDesignApi: {
19
- baseUrl: 'https://leapdesign.leapaws.com.au',
20
- projectId: 'Test',
21
- },
22
- calcApi: {
23
- remote: 'https://leapcalc.dev.leap.services',
24
- local: 'http://localhost:9091',
25
- },
26
- docBuilderApi: {
27
- remote: 'https://doc-builder-dev.leapaws.com.au',
28
- local: 'http://localhost:9092',
29
- },
30
- pubSubApi: 'https://leap-pubsub.dev.leapaws.com.au',
31
- pubSubNotificationPublishKey:
32
- 'AOG98zJZyz2akUiK2JID4xK-pvN8PfXz7NYYgwyA3gw5AzFuRMrvqw==',
33
- };
@@ -1,32 +0,0 @@
1
- export const leap_live_au = {
2
- envName: 'live',
3
- brand: 'LEAP',
4
- region: 'au',
5
- production: true,
6
- imports: [],
7
- keys: {
8
- pnSubscribe: 'sub-a456f002-0095-11e2-9638-9581afc33ebf',
9
- },
10
- authApi: {
11
- baseUrl: 'https://auth.leap.services',
12
- clientId: 'XKGMO3JQNSZOYDK2',
13
- redirectPath: 'index.html',
14
- },
15
- automation: 'https://office-automation-api-live.leapaws.com.au',
16
- docsApi: 'https://api-docs.leapaws.com.au',
17
- schemaApi: 'https://schema-api-au-live.leap.services',
18
- leapDesignApi: {
19
- baseUrl: 'https://leapdesign.leapaws.com.au',
20
- projectId: 'Live',
21
- },
22
- calcApi: {
23
- remote: 'https://leapcalc-au-live.leap.services',
24
- local: 'http://localhost:9091',
25
- },
26
- docBuilderApi: {
27
- remote: 'https://doc-builder.leapaws.com.au',
28
- local: 'http://localhost:9092',
29
- },
30
- pubSubApi: '',
31
- pubSubNotificationPublishKey: '',
32
- };
@@ -1,32 +0,0 @@
1
- export const leap_live_ca = {
2
- envName: 'live',
3
- brand: 'LEAP',
4
- region: 'ca',
5
- production: true,
6
- imports: [],
7
- keys: {
8
- pnSubscribe: 'sub-a456f002-0095-11e2-9638-9581afc33ebf',
9
- },
10
- authApi: {
11
- baseUrl: 'https://auth.leap.services',
12
- clientId: 'XKGMO3JQNSZOYDK2',
13
- redirectPath: 'index.html',
14
- },
15
- automation: 'https://office-automation-api.leapaws.ca',
16
- docsApi: 'https://api-docs.leapaws.ca',
17
- schemaApi: 'https://schema-api.ca.leap.services',
18
- leapDesignApi: {
19
- baseUrl: 'https://leapdesign.leapaws.ca',
20
- projectId: 'Live',
21
- },
22
- calcApi: {
23
- remote: 'https://leapcalc.ca.leap.services',
24
- local: 'http://localhost:9091',
25
- },
26
- docBuilderApi: {
27
- remote: 'https://doc-builder.leapaws.ca',
28
- local: 'http://localhost:9092',
29
- },
30
- pubSubApi: '',
31
- pubSubNotificationPublishKey: '',
32
- };
@@ -1,32 +0,0 @@
1
- export const leap_live_nz = {
2
- envName: 'live',
3
- brand: 'LEAP',
4
- region: 'au',
5
- production: true,
6
- imports: [],
7
- keys: {
8
- pnSubscribe: 'sub-a456f002-0095-11e2-9638-9581afc33ebf',
9
- },
10
- authApi: {
11
- baseUrl: 'https://auth.leap.services',
12
- clientId: 'XKGMO3JQNSZOYDK2',
13
- redirectPath: 'index.html',
14
- },
15
- automation: 'https://office-automation-api-live.leapaws.com.au',
16
- docsApi: 'https://api-docs.leapaws.com.au',
17
- schemaApi: 'https://schema-api-au-live.leap.services',
18
- leapDesignApi: {
19
- baseUrl: 'https://leapdesign.leapaws.com.au',
20
- projectId: 'Live',
21
- },
22
- calcApi: {
23
- remote: 'https://leapcalc-au-live.leap.services',
24
- local: 'http://localhost:9091',
25
- },
26
- docBuilderApi: {
27
- remote: 'https://doc-builder.leapaws.com.au',
28
- local: 'http://localhost:9092',
29
- },
30
- pubSubApi: '',
31
- pubSubNotificationPublishKey: '',
32
- };