@leapdev/app-platform 0.1.0-beta.20 → 0.1.0-beta.22
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 +1 -1
- package/src/index.d.ts +3 -2
- package/src/index.js +2 -2
- package/src/lib/app-platform.d.ts +5 -2
- package/src/lib/app-platform.js +60 -10
- package/src/lib/models/leap.model.d.ts +7 -1
- package/src/lib/models/leap.model.js +8 -1
- package/src/lib/services/excel-custom-xml-part.service.d.ts +14 -0
- package/src/lib/services/excel-custom-xml-part.service.js +193 -0
- package/src/types.d.ts +2 -2
- package/src/types.js +2 -1
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { EvaluatePathsRequest } from './lib/models';
|
|
2
|
-
import { LeapDocumentData } from './lib/models/leap.model';
|
|
2
|
+
import { HostApplicationType, LeapDocumentData } from './lib/models/leap.model';
|
|
3
3
|
export * from './types';
|
|
4
|
-
export declare const initAppPlatform: (skipLeapEventsSetup?: boolean) => Promise<{
|
|
4
|
+
export declare const initAppPlatform: (hostApplicationType: HostApplicationType, skipLeapEventsSetup?: boolean) => Promise<{
|
|
5
5
|
done: boolean;
|
|
6
6
|
openViaLEAP: boolean;
|
|
7
7
|
}>;
|
|
8
8
|
export declare const getHostInfo: (params: {
|
|
9
|
+
hostApplicationType: HostApplicationType;
|
|
9
10
|
clientId: string;
|
|
10
11
|
}) => Promise<{
|
|
11
12
|
hostType: string | null;
|
package/src/index.js
CHANGED
|
@@ -5,8 +5,8 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const app_platform_1 = require("./lib/app-platform");
|
|
6
6
|
tslib_1.__exportStar(require("./types"), exports);
|
|
7
7
|
const appPlatform = new app_platform_1.AppPlatform();
|
|
8
|
-
const initAppPlatform = (skipLeapEventsSetup = false) => {
|
|
9
|
-
return appPlatform.init(skipLeapEventsSetup);
|
|
8
|
+
const initAppPlatform = (hostApplicationType, skipLeapEventsSetup = false) => {
|
|
9
|
+
return appPlatform.init(hostApplicationType, skipLeapEventsSetup);
|
|
10
10
|
};
|
|
11
11
|
exports.initAppPlatform = initAppPlatform;
|
|
12
12
|
const getHostInfo = (params) => {
|
|
@@ -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,7 +10,7 @@ export declare class AppPlatform {
|
|
|
10
10
|
private signalRService;
|
|
11
11
|
private _openViaLEAP;
|
|
12
12
|
constructor();
|
|
13
|
-
init(skipLeapEventsSetup: boolean, force?: boolean): Promise<{
|
|
13
|
+
init(hostApplicationType: HostApplicationType, skipLeapEventsSetup: boolean, force?: boolean): Promise<{
|
|
14
14
|
done: boolean;
|
|
15
15
|
openViaLEAP: boolean;
|
|
16
16
|
}>;
|
|
@@ -18,6 +18,7 @@ export declare class AppPlatform {
|
|
|
18
18
|
clientId: string;
|
|
19
19
|
}): Promise<boolean>;
|
|
20
20
|
getHostInfo(params: {
|
|
21
|
+
hostApplicationType: HostApplicationType;
|
|
21
22
|
clientId: string;
|
|
22
23
|
}): Promise<{
|
|
23
24
|
hostType: string | null;
|
|
@@ -31,6 +32,7 @@ export declare class AppPlatform {
|
|
|
31
32
|
documentId: string;
|
|
32
33
|
}): Promise<boolean>;
|
|
33
34
|
getDocumentData(): Promise<LeapDocumentData | null>;
|
|
35
|
+
getExcelDocumentData(): Promise<LeapDocumentData | null>;
|
|
34
36
|
setDocumentData(params: {
|
|
35
37
|
documentData: LeapDocumentData;
|
|
36
38
|
}): Promise<boolean>;
|
|
@@ -52,4 +54,5 @@ export declare class AppPlatform {
|
|
|
52
54
|
private setupLeapEvents;
|
|
53
55
|
private setTokenInCustomXml;
|
|
54
56
|
private getWordCustomPart;
|
|
57
|
+
private isLeapWorkbook;
|
|
55
58
|
}
|
package/src/lib/app-platform.js
CHANGED
|
@@ -6,10 +6,12 @@ const tslib_1 = require("tslib");
|
|
|
6
6
|
const helpers_1 = require("./functions/helpers");
|
|
7
7
|
const constants_1 = require("./models/constants");
|
|
8
8
|
const leap_events_model_1 = require("./models/leap-events.model");
|
|
9
|
+
const leap_model_1 = require("./models/leap.model");
|
|
9
10
|
const services_1 = require("./services");
|
|
10
11
|
const auth_service_1 = require("./services/auth/auth.service");
|
|
11
12
|
const promise_helper_function_1 = require("./services/calc-api/promise-helper.function");
|
|
12
13
|
const custom_xml_part_service_1 = require("./services/custom-xml-part.service");
|
|
14
|
+
const excel_custom_xml_part_service_1 = require("./services/excel-custom-xml-part.service");
|
|
13
15
|
const leap_events_service_1 = require("./services/leap-events.service");
|
|
14
16
|
const signalr_service_1 = require("./services/signalr/signalr.service");
|
|
15
17
|
class AppPlatform {
|
|
@@ -25,22 +27,39 @@ class AppPlatform {
|
|
|
25
27
|
this.documentService = new services_1.DocumentService(this.leapEventsService, this.loggerService);
|
|
26
28
|
this.signalRService = new signalr_service_1.SignalRService();
|
|
27
29
|
}
|
|
28
|
-
init(skipLeapEventsSetup, force = false) {
|
|
30
|
+
init(hostApplicationType, skipLeapEventsSetup, force = false) {
|
|
29
31
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
30
32
|
try {
|
|
31
33
|
if (tslib_1.__classPrivateFieldGet(this, _AppPlatform_initialized, "f") && !force) {
|
|
32
34
|
return { done: true, openViaLEAP: this._openViaLEAP };
|
|
33
35
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
let openViaLEAP = false;
|
|
37
|
+
switch (hostApplicationType) {
|
|
38
|
+
case leap_model_1.HostApplicationType.MicrosoftWord:
|
|
39
|
+
this.loggerService.log(`[INIT] Microsoft Word`);
|
|
40
|
+
openViaLEAP = !!(yield this.getWordCustomPart());
|
|
41
|
+
break;
|
|
42
|
+
case leap_model_1.HostApplicationType.MicrosoftExcel:
|
|
43
|
+
this.loggerService.log(`[INIT] Microsoft Excel`);
|
|
44
|
+
openViaLEAP = yield this.isLeapWorkbook();
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
if (openViaLEAP) {
|
|
36
48
|
this._openViaLEAP = true;
|
|
37
49
|
this.loggerService.log(`[INIT] Setup LEAP Events and set token in custom xml part`);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
50
|
+
try {
|
|
51
|
+
if (hostApplicationType === leap_model_1.HostApplicationType.MicrosoftWord &&
|
|
52
|
+
!skipLeapEventsSetup) {
|
|
53
|
+
yield this.setupLeapEvents();
|
|
54
|
+
yield this.setTokenInCustomXml();
|
|
55
|
+
}
|
|
56
|
+
tslib_1.__classPrivateFieldSet(this, _AppPlatform_initialized, true, "f");
|
|
57
|
+
return { done: true, openViaLEAP: true };
|
|
58
|
+
}
|
|
59
|
+
catch (_) {
|
|
60
|
+
tslib_1.__classPrivateFieldSet(this, _AppPlatform_initialized, true, "f");
|
|
61
|
+
return { done: true, openViaLEAP: true };
|
|
41
62
|
}
|
|
42
|
-
tslib_1.__classPrivateFieldSet(this, _AppPlatform_initialized, true, "f");
|
|
43
|
-
return { done: true, openViaLEAP: true };
|
|
44
63
|
}
|
|
45
64
|
else {
|
|
46
65
|
this.loggerService.log(`[INIT] Document not open via LEAP`);
|
|
@@ -88,14 +107,24 @@ class AppPlatform {
|
|
|
88
107
|
getHostInfo(params) {
|
|
89
108
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
90
109
|
try {
|
|
91
|
-
|
|
92
|
-
|
|
110
|
+
let documentData = null;
|
|
111
|
+
switch (params.hostApplicationType) {
|
|
112
|
+
case leap_model_1.HostApplicationType.MicrosoftWord: {
|
|
113
|
+
documentData = yield this.getDocumentData();
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
case leap_model_1.HostApplicationType.MicrosoftExcel: {
|
|
117
|
+
documentData = yield this.getExcelDocumentData();
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
93
121
|
if (documentData && documentData.hostType) {
|
|
94
122
|
return {
|
|
95
123
|
hostType: documentData.hostType,
|
|
96
124
|
hostVersion: null,
|
|
97
125
|
};
|
|
98
126
|
}
|
|
127
|
+
//* check host type in document data custom xml part
|
|
99
128
|
//* we connect signalr with client id and try to get init data like host type and version
|
|
100
129
|
//* when we provide client id, LD would try to issue an code and code challenge for auth
|
|
101
130
|
//* if it fails, it means client doesn't have a proper redirect uri (fourd)
|
|
@@ -210,6 +239,18 @@ class AppPlatform {
|
|
|
210
239
|
}
|
|
211
240
|
});
|
|
212
241
|
}
|
|
242
|
+
getExcelDocumentData() {
|
|
243
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
244
|
+
try {
|
|
245
|
+
const data = yield (0, excel_custom_xml_part_service_1.getDataByNamespace)(constants_1.constants.LeapDocumentDataNamespace);
|
|
246
|
+
return data;
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
this.loggerService.error(`[ERROR] Get Excel Document Data: ${error}`);
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
}
|
|
213
254
|
setDocumentData(params) {
|
|
214
255
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
215
256
|
try {
|
|
@@ -385,6 +426,15 @@ class AppPlatform {
|
|
|
385
426
|
}
|
|
386
427
|
});
|
|
387
428
|
}
|
|
429
|
+
isLeapWorkbook() {
|
|
430
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
431
|
+
return yield Excel.run((context) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
432
|
+
const leapUniqueCode = context.workbook.names.getItemOrNullObject('LEAPUniqueCode');
|
|
433
|
+
yield context.sync();
|
|
434
|
+
return !leapUniqueCode.isNullObject;
|
|
435
|
+
}));
|
|
436
|
+
});
|
|
437
|
+
}
|
|
388
438
|
}
|
|
389
439
|
exports.AppPlatform = AppPlatform;
|
|
390
440
|
_AppPlatform_authService = new WeakMap(), _AppPlatform_signalRInitData = new WeakMap(), _AppPlatform_initialized = new WeakMap(), _AppPlatform_connectedToSignalR = new WeakMap();
|
|
@@ -23,7 +23,7 @@ export declare class LeapDocumentData {
|
|
|
23
23
|
wordStyleId?: string | undefined;
|
|
24
24
|
appliedWordStyleVersionId?: string | undefined;
|
|
25
25
|
officeAddInUrl?: string | undefined;
|
|
26
|
-
hostType:
|
|
26
|
+
hostType: 'web' | undefined;
|
|
27
27
|
isCoauthoringDocument: boolean | undefined;
|
|
28
28
|
sessionId: string | undefined;
|
|
29
29
|
transactionId?: string;
|
|
@@ -69,3 +69,9 @@ export type LEAPUser = {
|
|
|
69
69
|
countryCode: number;
|
|
70
70
|
region: string;
|
|
71
71
|
};
|
|
72
|
+
export declare enum HostApplicationType {
|
|
73
|
+
UnknownApplication = 0,
|
|
74
|
+
MicrosoftExcel = 1,
|
|
75
|
+
MicrosoftWord = 2,
|
|
76
|
+
MicrosoftOutlook = 3
|
|
77
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LeapTemplateData = exports.LeapModelData = exports.LeapRegion = exports.PreviewMode = exports.LeapDocumentData = void 0;
|
|
3
|
+
exports.HostApplicationType = exports.LeapTemplateData = exports.LeapModelData = exports.LeapRegion = exports.PreviewMode = exports.LeapDocumentData = void 0;
|
|
4
4
|
class LeapDocumentData {
|
|
5
5
|
constructor(init) {
|
|
6
6
|
if (init) {
|
|
@@ -26,3 +26,10 @@ exports.LeapModelData = LeapModelData;
|
|
|
26
26
|
class LeapTemplateData {
|
|
27
27
|
}
|
|
28
28
|
exports.LeapTemplateData = LeapTemplateData;
|
|
29
|
+
var HostApplicationType;
|
|
30
|
+
(function (HostApplicationType) {
|
|
31
|
+
HostApplicationType[HostApplicationType["UnknownApplication"] = 0] = "UnknownApplication";
|
|
32
|
+
HostApplicationType[HostApplicationType["MicrosoftExcel"] = 1] = "MicrosoftExcel";
|
|
33
|
+
HostApplicationType[HostApplicationType["MicrosoftWord"] = 2] = "MicrosoftWord";
|
|
34
|
+
HostApplicationType[HostApplicationType["MicrosoftOutlook"] = 3] = "MicrosoftOutlook";
|
|
35
|
+
})(HostApplicationType || (exports.HostApplicationType = HostApplicationType = {}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const getDataByNamespace: (namespace: string, retries?: number) => Promise<unknown>;
|
|
2
|
+
export declare const updateXmlDataByNamespace: (namespace: string, data: string, rootTagName: string) => Promise<boolean>;
|
|
3
|
+
/**
|
|
4
|
+
* @remarks This function is not supported in Excel.
|
|
5
|
+
*/
|
|
6
|
+
export declare const addHandlerForCustomXmlPart: (namespace: string, eventType: Office.EventType, handler: unknown) => Promise<void | null>;
|
|
7
|
+
/**
|
|
8
|
+
* @remarks This function is not supported in Excel.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getChildNodes: (node: Office.CustomXmlNode, xPath?: string) => Promise<Array<Office.CustomXmlNode>>;
|
|
11
|
+
/**
|
|
12
|
+
* @remarks This function is not supported in Excel.
|
|
13
|
+
*/
|
|
14
|
+
export declare const getNodeText: (node: Office.CustomXmlNode | null) => Promise<string>;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/// <reference types="office-js" />
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getNodeText = exports.getChildNodes = exports.addHandlerForCustomXmlPart = exports.updateXmlDataByNamespace = exports.getDataByNamespace = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const xml_1 = require("../functions/xml");
|
|
7
|
+
const retryTimes = 5;
|
|
8
|
+
const getCustomXmlPartsByNamespace = (context, namespace) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
9
|
+
if (context.workbook) {
|
|
10
|
+
const customXmlParts = context.workbook.customXmlParts;
|
|
11
|
+
const customXmlCollection = customXmlParts.getByNamespace(namespace);
|
|
12
|
+
customXmlCollection.load('items');
|
|
13
|
+
yield context.sync();
|
|
14
|
+
return customXmlCollection;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const getCustomXmlPartByNamespace = (context, namespace) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
try {
|
|
22
|
+
const customXmlCollection = yield getCustomXmlPartsByNamespace(context, namespace);
|
|
23
|
+
if (customXmlCollection != null && customXmlCollection.items.length > 0) {
|
|
24
|
+
return customXmlCollection.items[0];
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
console.error(error, `[CustomXmlPartService] (getCustomXmlPartByNamespace) Failed to get custom XML part by namespace`);
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const getCustomXmlPartData = (context, partOrNamespace) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
try {
|
|
35
|
+
let customXmlPart;
|
|
36
|
+
if (typeof partOrNamespace === 'string' || partOrNamespace instanceof String) {
|
|
37
|
+
customXmlPart = yield getCustomXmlPartByNamespace(context, partOrNamespace);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
customXmlPart = partOrNamespace;
|
|
41
|
+
}
|
|
42
|
+
if (customXmlPart != null) {
|
|
43
|
+
const xmlResult = customXmlPart.getXml();
|
|
44
|
+
yield context.sync();
|
|
45
|
+
const xmlString = xmlResult.value;
|
|
46
|
+
return (0, xml_1.toObj)(xmlString);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.error(error, `[CustomXmlPartService] (getCustomXmlPartData) Failed to get custom XML part data`);
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const updateCustomXmlPart = (context, customXmlPart, xml, rootTagName) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
+
rootTagName = rootTagName || '';
|
|
59
|
+
const xmlResult = customXmlPart.getXml();
|
|
60
|
+
yield context.sync();
|
|
61
|
+
const currentXml = xmlResult.value;
|
|
62
|
+
if (currentXml.includes(rootTagName)) {
|
|
63
|
+
try {
|
|
64
|
+
customXmlPart.setXml(xml);
|
|
65
|
+
yield context.sync();
|
|
66
|
+
console.log('[CustomXmlPartService] updateCustomXmlPart succeeded');
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
console.error(error, '[CustomXmlPartService] updateCustomXmlPart failed');
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
console.log(`Could not find ${rootTagName} in the custom XML part`);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
const addCustomXmlPart = (context, objOrXml, options = { rootTagName: '' }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
+
if (context.workbook) {
|
|
79
|
+
const xml = typeof objOrXml === 'string' || objOrXml instanceof String
|
|
80
|
+
? objOrXml
|
|
81
|
+
: (0, xml_1.toXml)(objOrXml, options.rootTagName, options);
|
|
82
|
+
const customXmlParts = context.workbook.customXmlParts;
|
|
83
|
+
customXmlParts.add(xml);
|
|
84
|
+
yield context.sync();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
const updateCustomXmlPartData = (context, partOrNamespace, objOrXml, options = { rootTagName: '' }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
+
try {
|
|
89
|
+
let customXmlPart;
|
|
90
|
+
if (typeof partOrNamespace === 'string' ||
|
|
91
|
+
partOrNamespace instanceof String) {
|
|
92
|
+
customXmlPart = yield getCustomXmlPartByNamespace(context, partOrNamespace);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
customXmlPart = partOrNamespace;
|
|
96
|
+
}
|
|
97
|
+
let xml;
|
|
98
|
+
if (typeof objOrXml === 'string' || objOrXml instanceof String) {
|
|
99
|
+
xml = objOrXml;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
xml = (0, xml_1.toXml)(objOrXml, options.rootTagName, options);
|
|
103
|
+
}
|
|
104
|
+
if (customXmlPart != null) {
|
|
105
|
+
yield updateCustomXmlPart(context, customXmlPart, xml, options.rootTagName);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
yield addCustomXmlPart(context, xml, options);
|
|
109
|
+
}
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
console.error(error, `[CustomXmlPartService] (updateCustomXmlPartData) Failed to update ` +
|
|
114
|
+
`${typeof partOrNamespace === 'string' ? partOrNamespace : ''} custom XML part`);
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
const retryUpdateCustomXmlPartData = (namespace, data, options, retries = retryTimes) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
119
|
+
const { rootTagName } = options;
|
|
120
|
+
try {
|
|
121
|
+
console.log(`[CustomXmlPartService] Updating ${namespace} tag ${rootTagName}`);
|
|
122
|
+
yield Excel.run((context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
123
|
+
yield updateCustomXmlPartData(context, namespace, data, options);
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
if (retries > 0) {
|
|
128
|
+
console.log(`[CustomXmlPartService] Update ${namespace} tag ${rootTagName} failed - Retrying ${retryTimes - retries + 1}...`);
|
|
129
|
+
yield new Promise((resolve) => setTimeout(resolve, 2000));
|
|
130
|
+
yield retryUpdateCustomXmlPartData(namespace, data, options, retries - 1);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
const getDataByNamespace = (namespace, retries = 6) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
138
|
+
try {
|
|
139
|
+
return yield Excel.run((context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
140
|
+
return yield getCustomXmlPartData(context, namespace);
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
if (retries > 0) {
|
|
145
|
+
console.log(`[CustomXmlPartService] Get data from ${namespace} failed - Retrying ${retryTimes - retries + 1}...`);
|
|
146
|
+
yield new Promise((resolve) => setTimeout(resolve, 2000));
|
|
147
|
+
return yield (0, exports.getDataByNamespace)(namespace, retries - 1);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
throw new Error(`Unable to get custom XML part using namespace ${namespace}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
exports.getDataByNamespace = getDataByNamespace;
|
|
155
|
+
const updateXmlDataByNamespace = (namespace, data, rootTagName) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
156
|
+
const options = { rootTagName };
|
|
157
|
+
yield retryUpdateCustomXmlPartData(namespace, data, options);
|
|
158
|
+
return true;
|
|
159
|
+
});
|
|
160
|
+
exports.updateXmlDataByNamespace = updateXmlDataByNamespace;
|
|
161
|
+
/**
|
|
162
|
+
* @remarks This function is not supported in Excel.
|
|
163
|
+
*/
|
|
164
|
+
const addHandlerForCustomXmlPart = (
|
|
165
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
166
|
+
namespace,
|
|
167
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
168
|
+
eventType,
|
|
169
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
170
|
+
handler) => {
|
|
171
|
+
throw new Error('addHandlerForCustomXmlPart is not supported in Excel.');
|
|
172
|
+
};
|
|
173
|
+
exports.addHandlerForCustomXmlPart = addHandlerForCustomXmlPart;
|
|
174
|
+
/**
|
|
175
|
+
* @remarks This function is not supported in Excel.
|
|
176
|
+
*/
|
|
177
|
+
const getChildNodes = (
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
179
|
+
node,
|
|
180
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
181
|
+
xPath = '*') => {
|
|
182
|
+
throw new Error('getChildNodes is not supported in Excel.');
|
|
183
|
+
};
|
|
184
|
+
exports.getChildNodes = getChildNodes;
|
|
185
|
+
/**
|
|
186
|
+
* @remarks This function is not supported in Excel.
|
|
187
|
+
*/
|
|
188
|
+
const getNodeText = (
|
|
189
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
190
|
+
node) => {
|
|
191
|
+
throw new Error('getNodeText is not supported in Excel.');
|
|
192
|
+
};
|
|
193
|
+
exports.getNodeText = getNodeText;
|
package/src/types.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { EvaluatePathsRequest, EvaluatePathsResponse } from './lib/models';
|
|
2
|
-
import { LeapDocumentData } from './lib/models/leap.model';
|
|
3
|
-
export { EvaluatePathsRequest, EvaluatePathsResponse, LeapDocumentData };
|
|
2
|
+
import { LeapDocumentData, HostApplicationType } from './lib/models/leap.model';
|
|
3
|
+
export { EvaluatePathsRequest, EvaluatePathsResponse, LeapDocumentData, HostApplicationType, };
|
package/src/types.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LeapDocumentData = exports.EvaluatePathsResponse = exports.EvaluatePathsRequest = void 0;
|
|
3
|
+
exports.HostApplicationType = exports.LeapDocumentData = exports.EvaluatePathsResponse = exports.EvaluatePathsRequest = void 0;
|
|
4
4
|
const models_1 = require("./lib/models");
|
|
5
5
|
Object.defineProperty(exports, "EvaluatePathsRequest", { enumerable: true, get: function () { return models_1.EvaluatePathsRequest; } });
|
|
6
6
|
Object.defineProperty(exports, "EvaluatePathsResponse", { enumerable: true, get: function () { return models_1.EvaluatePathsResponse; } });
|
|
7
7
|
const leap_model_1 = require("./lib/models/leap.model");
|
|
8
8
|
Object.defineProperty(exports, "LeapDocumentData", { enumerable: true, get: function () { return leap_model_1.LeapDocumentData; } });
|
|
9
|
+
Object.defineProperty(exports, "HostApplicationType", { enumerable: true, get: function () { return leap_model_1.HostApplicationType; } });
|