@microsoft/connected-workbooks 3.0.0 → 3.1.1-beta.1
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/README.md +17 -4
- package/dist/generators.js +7 -12
- package/dist/index.js +4 -30
- package/dist/main.js +464 -0
- package/dist/src/types.d.ts +54 -0
- package/dist/src/utils/documentUtils.js +2 -1
- package/dist/src/utils/index.d.ts +8 -0
- package/dist/src/utils/mashupDocumentParser.js +5 -5
- package/dist/src/utils/pqUtils.js +4 -3
- package/dist/src/utils/tableUtils.js +9 -8
- package/dist/src/utils/xmlInnerPartsUtils.js +18 -17
- package/dist/tests/mocks/index.d.ts +3 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +6 -9
- package/dist/utils/arrayUtils.js +28 -26
- package/dist/utils/constants.js +68 -68
- package/dist/utils/documentUtils.js +88 -52
- package/dist/utils/gridUtils.js +27 -29
- package/dist/utils/htmlUtils.js +8 -10
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.js +8 -22
- package/dist/utils/mashupDocumentParser.js +128 -108
- package/dist/utils/pqUtils.js +143 -71
- package/dist/utils/tableUtils.js +140 -101
- package/dist/utils/xmlInnerPartsUtils.js +228 -172
- package/dist/utils/xmlPartsUtils.js +116 -55
- package/dist/workbookManager.d.ts +1 -0
- package/dist/workbookManager.js +168 -72
- package/dist/workbookTemplate.js +2 -5
- package/package.json +2 -1
- package/dist/gridParser.js +0 -58
- package/dist/gridUtils.js +0 -58
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface QueryInfo {
|
|
2
|
+
refreshOnOpen: boolean;
|
|
3
|
+
queryMashup: string;
|
|
4
|
+
queryName?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface DocProps {
|
|
7
|
+
title?: string | null;
|
|
8
|
+
subject?: string | null;
|
|
9
|
+
keywords?: string | null;
|
|
10
|
+
createdBy?: string | null;
|
|
11
|
+
description?: string | null;
|
|
12
|
+
lastModifiedBy?: string | null;
|
|
13
|
+
category?: string | null;
|
|
14
|
+
revision?: string | null;
|
|
15
|
+
}
|
|
16
|
+
export interface Metadata {
|
|
17
|
+
queryName: string;
|
|
18
|
+
}
|
|
19
|
+
export interface TableData {
|
|
20
|
+
columnNames: string[];
|
|
21
|
+
rows: string[][];
|
|
22
|
+
}
|
|
23
|
+
export interface Grid {
|
|
24
|
+
data: (string | number | boolean)[][];
|
|
25
|
+
config?: GridConfig;
|
|
26
|
+
}
|
|
27
|
+
export interface GridConfig {
|
|
28
|
+
promoteHeaders?: boolean;
|
|
29
|
+
adjustColumnNames?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface FileConfigs {
|
|
32
|
+
templateFile?: File;
|
|
33
|
+
docProps?: DocProps;
|
|
34
|
+
}
|
|
35
|
+
export declare enum DataTypes {
|
|
36
|
+
null = 0,
|
|
37
|
+
string = 1,
|
|
38
|
+
number = 2,
|
|
39
|
+
boolean = 3
|
|
40
|
+
}
|
|
41
|
+
export declare enum DocPropsModifiableElements {
|
|
42
|
+
title = "dc:title",
|
|
43
|
+
subject = "dc:subject",
|
|
44
|
+
keywords = "cp:keywords",
|
|
45
|
+
createdBy = "dc:creator",
|
|
46
|
+
description = "dc:description",
|
|
47
|
+
lastModifiedBy = "cp:lastModifiedBy",
|
|
48
|
+
category = "cp:category",
|
|
49
|
+
revision = "cp:revision"
|
|
50
|
+
}
|
|
51
|
+
export declare enum DocPropsAutoUpdatedElements {
|
|
52
|
+
created = "dcterms:created",
|
|
53
|
+
modified = "dcterms:modified"
|
|
54
|
+
}
|
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
const xmldom_1 = require("xmldom");
|
|
14
15
|
const constants_1 = require("./constants");
|
|
15
16
|
const types_1 = require("../types");
|
|
16
17
|
const createOrUpdateProperty = (doc, parent, property, value) => {
|
|
@@ -36,7 +37,7 @@ const getDocPropsProperties = (zip) => __awaiter(void 0, void 0, void 0, functio
|
|
|
36
37
|
if (docPropsCoreXmlString === undefined) {
|
|
37
38
|
throw new Error("DocProps core.xml was not found in template");
|
|
38
39
|
}
|
|
39
|
-
const parser = new DOMParser();
|
|
40
|
+
const parser = new xmldom_1.DOMParser();
|
|
40
41
|
const doc = parser.parseFromString(docPropsCoreXmlString, constants_1.xmlTextResultType);
|
|
41
42
|
const properties = doc.getElementsByTagName(constants_1.docPropsRootElement).item(0);
|
|
42
43
|
if (properties === null) {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as pqUtils } from "./pqUtils";
|
|
2
|
+
export { default as arrayUtils } from "./arrayUtils";
|
|
3
|
+
export { default as documentUtils } from "./documentUtils";
|
|
4
|
+
export { default as xmlPartsUtils } from "./xmlPartsUtils";
|
|
5
|
+
export { default as xmlInnerPartsUtils } from "./xmlInnerPartsUtils";
|
|
6
|
+
export { default as tableUtils } from "./tableUtils";
|
|
7
|
+
export { default as htmlUtils } from "./htmlUtils";
|
|
8
|
+
export { default as gridUtils } from "./gridUtils";
|
|
@@ -40,6 +40,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
40
40
|
exports.editSingleQueryMetadata = exports.getPackageComponents = exports.replaceSingleQuery = void 0;
|
|
41
41
|
const base64 = __importStar(require("base64-js"));
|
|
42
42
|
const jszip_1 = __importDefault(require("jszip"));
|
|
43
|
+
const xmldom_1 = require("xmldom");
|
|
43
44
|
const constants_1 = require("./constants");
|
|
44
45
|
const _1 = require(".");
|
|
45
46
|
const replaceSingleQuery = (base64Str, queryName, queryMashupDoc) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -99,15 +100,15 @@ const editSingleQueryMetadata = (metadataArray, metadata) => {
|
|
|
99
100
|
//parse metdataXml
|
|
100
101
|
const textDecoder = new TextDecoder();
|
|
101
102
|
const metadataString = textDecoder.decode(metadataXml);
|
|
102
|
-
const parser = new DOMParser();
|
|
103
|
-
const serializer = new XMLSerializer();
|
|
103
|
+
const parser = new xmldom_1.DOMParser();
|
|
104
|
+
const serializer = new xmldom_1.XMLSerializer();
|
|
104
105
|
const parsedMetadata = parser.parseFromString(metadataString, constants_1.xmlTextResultType);
|
|
105
106
|
// Update InfoPaths to new QueryName
|
|
106
107
|
const itemPaths = parsedMetadata.getElementsByTagName(constants_1.element.itemPath);
|
|
107
108
|
if (itemPaths && itemPaths.length) {
|
|
108
109
|
for (let i = 0; i < itemPaths.length; i++) {
|
|
109
110
|
const itemPath = itemPaths[i];
|
|
110
|
-
const content = itemPath.
|
|
111
|
+
const content = itemPath.textContent;
|
|
111
112
|
if (content.includes(constants_1.section1PathPrefix)) {
|
|
112
113
|
const strArr = content.split(constants_1.divider);
|
|
113
114
|
strArr[1] = encodeURIComponent(metadata.queryName);
|
|
@@ -120,8 +121,7 @@ const editSingleQueryMetadata = (metadataArray, metadata) => {
|
|
|
120
121
|
if (entries && entries.length) {
|
|
121
122
|
for (let i = 0; i < entries.length; i++) {
|
|
122
123
|
const entry = entries[i];
|
|
123
|
-
const
|
|
124
|
-
const entryAttributesArr = [...entryAttributes];
|
|
124
|
+
const entryAttributesArr = Array.from(entry.attributes);
|
|
125
125
|
const entryProp = entryAttributesArr.find((prop) => {
|
|
126
126
|
return (prop === null || prop === void 0 ? void 0 : prop.name) === constants_1.elementAttributes.type;
|
|
127
127
|
});
|
|
@@ -14,6 +14,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
const constants_1 = require("./constants");
|
|
15
15
|
const generators_1 = require("../generators");
|
|
16
16
|
const buffer_1 = require("buffer");
|
|
17
|
+
const xmldom_1 = require("xmldom");
|
|
17
18
|
const getBase64 = (zip) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
19
|
const mashup = yield getDataMashupFile(zip);
|
|
19
20
|
return mashup.value;
|
|
@@ -40,7 +41,7 @@ const getDataMashupFile = (zip) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
40
41
|
});
|
|
41
42
|
const getCustomXmlFile = (zip, url, encoding = "utf16le") => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
43
|
var _a, _b;
|
|
43
|
-
const parser = new DOMParser();
|
|
44
|
+
const parser = new xmldom_1.DOMParser();
|
|
44
45
|
const itemsArray = yield zip.file(/customXml\/item\d.xml/);
|
|
45
46
|
if (!itemsArray || itemsArray.length === 0) {
|
|
46
47
|
throw new Error("No customXml files were found!");
|
|
@@ -48,7 +49,7 @@ const getCustomXmlFile = (zip, url, encoding = "utf16le") => __awaiter(void 0, v
|
|
|
48
49
|
let found = false;
|
|
49
50
|
let path;
|
|
50
51
|
let xmlString;
|
|
51
|
-
let value;
|
|
52
|
+
let value = null;
|
|
52
53
|
for (let i = 1; i <= itemsArray.length; i++) {
|
|
53
54
|
path = (0, generators_1.generateCustomXmlFilePath)(i);
|
|
54
55
|
const xmlValue = yield ((_a = zip.file(path)) === null || _a === void 0 ? void 0 : _a.async("uint8array"));
|
|
@@ -61,7 +62,7 @@ const getCustomXmlFile = (zip, url, encoding = "utf16le") => __awaiter(void 0, v
|
|
|
61
62
|
const doc = parser.parseFromString(xmlString, "text/xml");
|
|
62
63
|
found = ((_b = doc === null || doc === void 0 ? void 0 : doc.documentElement) === null || _b === void 0 ? void 0 : _b.namespaceURI) === url;
|
|
63
64
|
if (found) {
|
|
64
|
-
value = doc.documentElement.
|
|
65
|
+
value = doc.documentElement.textContent;
|
|
65
66
|
break;
|
|
66
67
|
}
|
|
67
68
|
}
|
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const xmldom_1 = require("xmldom");
|
|
17
18
|
const constants_1 = require("./constants");
|
|
18
19
|
const documentUtils_1 = __importDefault(require("./documentUtils"));
|
|
19
20
|
const uuid_1 = require("uuid");
|
|
@@ -51,8 +52,8 @@ const updateTableInitialDataIfNeeded = (zip, tableData, updateQueryTable) => __a
|
|
|
51
52
|
zip.file(constants_1.tableXmlPath, newTable);
|
|
52
53
|
});
|
|
53
54
|
const updateTablesInitialData = (tableXmlString, tableData, updateQueryTable = false) => {
|
|
54
|
-
const parser = new DOMParser();
|
|
55
|
-
const serializer = new XMLSerializer();
|
|
55
|
+
const parser = new xmldom_1.DOMParser();
|
|
56
|
+
const serializer = new xmldom_1.XMLSerializer();
|
|
56
57
|
const tableDoc = parser.parseFromString(tableXmlString, constants_1.xmlTextResultType);
|
|
57
58
|
const tableColumns = tableDoc.getElementsByTagName(constants_1.element.tableColumns)[0];
|
|
58
59
|
tableColumns.textContent = "";
|
|
@@ -77,8 +78,8 @@ const updateTablesInitialData = (tableXmlString, tableData, updateQueryTable = f
|
|
|
77
78
|
return serializer.serializeToString(tableDoc);
|
|
78
79
|
};
|
|
79
80
|
const updateWorkbookInitialData = (workbookXmlString, tableData) => {
|
|
80
|
-
const newParser = new DOMParser();
|
|
81
|
-
const newSerializer = new XMLSerializer();
|
|
81
|
+
const newParser = new xmldom_1.DOMParser();
|
|
82
|
+
const newSerializer = new xmldom_1.XMLSerializer();
|
|
82
83
|
const workbookDoc = newParser.parseFromString(workbookXmlString, constants_1.xmlTextResultType);
|
|
83
84
|
const definedName = workbookDoc.getElementsByTagName(constants_1.element.definedName)[0];
|
|
84
85
|
definedName.textContent =
|
|
@@ -86,8 +87,8 @@ const updateWorkbookInitialData = (workbookXmlString, tableData) => {
|
|
|
86
87
|
return newSerializer.serializeToString(workbookDoc);
|
|
87
88
|
};
|
|
88
89
|
const updateQueryTablesInitialData = (queryTableXmlString, tableData) => {
|
|
89
|
-
const parser = new DOMParser();
|
|
90
|
-
const serializer = new XMLSerializer();
|
|
90
|
+
const parser = new xmldom_1.DOMParser();
|
|
91
|
+
const serializer = new xmldom_1.XMLSerializer();
|
|
91
92
|
const queryTableDoc = parser.parseFromString(queryTableXmlString, constants_1.xmlTextResultType);
|
|
92
93
|
const queryTableFields = queryTableDoc.getElementsByTagName(constants_1.element.queryTableFields)[0];
|
|
93
94
|
queryTableFields.textContent = "";
|
|
@@ -103,8 +104,8 @@ const updateQueryTablesInitialData = (queryTableXmlString, tableData) => {
|
|
|
103
104
|
return serializer.serializeToString(queryTableDoc);
|
|
104
105
|
};
|
|
105
106
|
const updateSheetsInitialData = (sheetsXmlString, tableData) => {
|
|
106
|
-
const parser = new DOMParser();
|
|
107
|
-
const serializer = new XMLSerializer();
|
|
107
|
+
const parser = new xmldom_1.DOMParser();
|
|
108
|
+
const serializer = new xmldom_1.XMLSerializer();
|
|
108
109
|
const sheetsDoc = parser.parseFromString(sheetsXmlString, constants_1.xmlTextResultType);
|
|
109
110
|
const sheetData = sheetsDoc.getElementsByTagName(constants_1.element.sheetData)[0];
|
|
110
111
|
sheetData.textContent = "";
|
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const xmldom_1 = require("xmldom");
|
|
17
18
|
const types_1 = require("../types");
|
|
18
19
|
const constants_1 = require("./constants");
|
|
19
20
|
const documentUtils_1 = __importDefault(require("./documentUtils"));
|
|
@@ -35,7 +36,7 @@ const updateDocProps = (zip, docProps = {}) => __awaiter(void 0, void 0, void 0,
|
|
|
35
36
|
.forEach((kvp) => {
|
|
36
37
|
documentUtils_1.default.createOrUpdateProperty(doc, properties, kvp.name, kvp.value);
|
|
37
38
|
});
|
|
38
|
-
const serializer = new XMLSerializer();
|
|
39
|
+
const serializer = new xmldom_1.XMLSerializer();
|
|
39
40
|
const newDoc = serializer.serializeToString(doc);
|
|
40
41
|
zip.file(constants_1.docPropsCoreXmlPath, newDoc);
|
|
41
42
|
});
|
|
@@ -48,7 +49,7 @@ const clearLabelInfo = (zip) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
48
49
|
if (relsString === undefined) {
|
|
49
50
|
throw new Error(constants_1.relsNotFoundErr);
|
|
50
51
|
}
|
|
51
|
-
const parser = new DOMParser();
|
|
52
|
+
const parser = new xmldom_1.DOMParser();
|
|
52
53
|
const doc = parser.parseFromString(relsString, constants_1.xmlTextResultType);
|
|
53
54
|
const relationships = doc.querySelector("Relationships");
|
|
54
55
|
if (relationships === null) {
|
|
@@ -61,25 +62,25 @@ const clearLabelInfo = (zip) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
61
62
|
(_b = relationships.querySelector('Relationship[Target="xl/workbook.xml"]')) === null || _b === void 0 ? void 0 : _b.setAttribute("Id", "rId1");
|
|
62
63
|
(_c = relationships.querySelector('Relationship[Target="docProps/core.xml"]')) === null || _c === void 0 ? void 0 : _c.setAttribute("Id", "rId2");
|
|
63
64
|
(_d = relationships.querySelector('Relationship[Target="docProps/app.xml"]')) === null || _d === void 0 ? void 0 : _d.setAttribute("Id", "rId3");
|
|
64
|
-
const serializer = new XMLSerializer();
|
|
65
|
+
const serializer = new xmldom_1.XMLSerializer();
|
|
65
66
|
const newDoc = serializer.serializeToString(doc);
|
|
66
67
|
zip.file(constants_1.relsXmlPath, newDoc);
|
|
67
68
|
});
|
|
68
69
|
const updateConnections = (connectionsXmlString, queryName, refreshOnOpen) => {
|
|
69
70
|
var _a, _b, _c;
|
|
70
|
-
const parser = new DOMParser();
|
|
71
|
-
const serializer = new XMLSerializer();
|
|
71
|
+
const parser = new xmldom_1.DOMParser();
|
|
72
|
+
const serializer = new xmldom_1.XMLSerializer();
|
|
72
73
|
const refreshOnLoadValue = refreshOnOpen ? constants_1.trueValue : constants_1.falseValue;
|
|
73
74
|
const connectionsDoc = parser.parseFromString(connectionsXmlString, constants_1.xmlTextResultType);
|
|
74
75
|
const connectionsProperties = connectionsDoc.getElementsByTagName(constants_1.element.databaseProperties);
|
|
75
76
|
const dbPr = connectionsProperties[0];
|
|
76
77
|
dbPr.setAttribute(constants_1.elementAttributes.refreshOnLoad, refreshOnLoadValue);
|
|
77
78
|
// Update query details to match queryName
|
|
78
|
-
(_a = dbPr.
|
|
79
|
-
(_b = dbPr.
|
|
79
|
+
(_a = dbPr.parentNode) === null || _a === void 0 ? void 0 : _a.setAttribute(constants_1.elementAttributes.name, constants_1.elementAttributesValues.connectionName(queryName));
|
|
80
|
+
(_b = dbPr.parentNode) === null || _b === void 0 ? void 0 : _b.setAttribute(constants_1.elementAttributes.description, constants_1.elementAttributesValues.connectionDescription(queryName));
|
|
80
81
|
dbPr.setAttribute(constants_1.elementAttributes.connection, constants_1.elementAttributesValues.connection(queryName));
|
|
81
82
|
dbPr.setAttribute(constants_1.elementAttributes.command, constants_1.elementAttributesValues.connectionCommand(queryName));
|
|
82
|
-
const connectionId = (_c = dbPr.
|
|
83
|
+
const connectionId = (_c = dbPr.parentNode) === null || _c === void 0 ? void 0 : _c.getAttribute(constants_1.elementAttributes.id);
|
|
83
84
|
const connectionXmlFileString = serializer.serializeToString(connectionsDoc);
|
|
84
85
|
if (connectionId === null) {
|
|
85
86
|
throw new Error(constants_1.connectionsNotFoundErr);
|
|
@@ -87,8 +88,8 @@ const updateConnections = (connectionsXmlString, queryName, refreshOnOpen) => {
|
|
|
87
88
|
return { connectionId, connectionXmlFileString };
|
|
88
89
|
};
|
|
89
90
|
const updateSharedStrings = (sharedStringsXmlString, queryName) => {
|
|
90
|
-
const parser = new DOMParser();
|
|
91
|
-
const serializer = new XMLSerializer();
|
|
91
|
+
const parser = new xmldom_1.DOMParser();
|
|
92
|
+
const serializer = new xmldom_1.XMLSerializer();
|
|
92
93
|
const sharedStringsDoc = parser.parseFromString(sharedStringsXmlString, constants_1.xmlTextResultType);
|
|
93
94
|
const sharedStringsTable = sharedStringsDoc.getElementsByTagName(constants_1.element.sharedStringTable)[0];
|
|
94
95
|
if (!sharedStringsTable) {
|
|
@@ -99,7 +100,7 @@ const updateSharedStrings = (sharedStringsXmlString, queryName) => {
|
|
|
99
100
|
let sharedStringIndex = textElementCollection.length;
|
|
100
101
|
if (textElementCollection && textElementCollection.length) {
|
|
101
102
|
for (let i = 0; i < textElementCollection.length; i++) {
|
|
102
|
-
if (textElementCollection[i].
|
|
103
|
+
if (textElementCollection[i].textContent === queryName) {
|
|
103
104
|
textElement = textElementCollection[i];
|
|
104
105
|
sharedStringIndex = i + 1;
|
|
105
106
|
break;
|
|
@@ -127,8 +128,8 @@ const updateSharedStrings = (sharedStringsXmlString, queryName) => {
|
|
|
127
128
|
return { sharedStringIndex, newSharedStrings };
|
|
128
129
|
};
|
|
129
130
|
const updateWorksheet = (sheetsXmlString, sharedStringIndex) => {
|
|
130
|
-
const parser = new DOMParser();
|
|
131
|
-
const serializer = new XMLSerializer();
|
|
131
|
+
const parser = new xmldom_1.DOMParser();
|
|
132
|
+
const serializer = new xmldom_1.XMLSerializer();
|
|
132
133
|
const sheetsDoc = parser.parseFromString(sheetsXmlString, constants_1.xmlTextResultType);
|
|
133
134
|
sheetsDoc.getElementsByTagName(constants_1.element.cellValue)[0].innerHTML = sharedStringIndex.toString();
|
|
134
135
|
const newSheet = serializer.serializeToString(sheetsDoc);
|
|
@@ -187,8 +188,8 @@ const updatePivotTablesandQueryTables = (zip, queryName, refreshOnOpen, connecti
|
|
|
187
188
|
const updateQueryTable = (tableXmlString, connectionId, refreshOnOpen) => {
|
|
188
189
|
const refreshOnLoadValue = refreshOnOpen ? constants_1.trueValue : constants_1.falseValue;
|
|
189
190
|
let isQueryTableUpdated = false;
|
|
190
|
-
const parser = new DOMParser();
|
|
191
|
-
const serializer = new XMLSerializer();
|
|
191
|
+
const parser = new xmldom_1.DOMParser();
|
|
192
|
+
const serializer = new xmldom_1.XMLSerializer();
|
|
192
193
|
const queryTableDoc = parser.parseFromString(tableXmlString, constants_1.xmlTextResultType);
|
|
193
194
|
const queryTable = queryTableDoc.getElementsByTagName(constants_1.element.queryTable)[0];
|
|
194
195
|
let newQueryTable = constants_1.emptyValue;
|
|
@@ -202,8 +203,8 @@ const updateQueryTable = (tableXmlString, connectionId, refreshOnOpen) => {
|
|
|
202
203
|
const updatePivotTable = (tableXmlString, connectionId, refreshOnOpen) => {
|
|
203
204
|
const refreshOnLoadValue = refreshOnOpen ? constants_1.trueValue : constants_1.falseValue;
|
|
204
205
|
let isPivotTableUpdated = false;
|
|
205
|
-
const parser = new DOMParser();
|
|
206
|
-
const serializer = new XMLSerializer();
|
|
206
|
+
const parser = new xmldom_1.DOMParser();
|
|
207
|
+
const serializer = new xmldom_1.XMLSerializer();
|
|
207
208
|
const pivotCacheDoc = parser.parseFromString(tableXmlString, constants_1.xmlTextResultType);
|
|
208
209
|
let cacheSource = pivotCacheDoc.getElementsByTagName(constants_1.element.cacheSource)[0];
|
|
209
210
|
let newPivotTable = constants_1.emptyValue;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { simpleQueryMock, section1mSimpleQueryMock, section1mBlankQueryMock, section1mNewQueryNameSimpleMock, section1mNewQueryNameBlankMock, } from "./section1mSimpleQueryMock";
|
|
2
|
+
export { pqEmptySingleQueryBase64, item1Path, item2Path, relationshipInfo } from "./PqMock";
|
|
3
|
+
export { connectedWorkbookXmlMock, sharedStringsXmlMock, pqMetadataXmlMockPart1, pqMetadataXmlMockPart2, existingSharedStringsXmlMock, sheetsXmlMock, workbookXmlMock, queryTableMock, addZeroSheetsXmlMock, } from "./xmlMocks";
|
package/dist/types.d.ts
CHANGED
package/dist/types.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright (c) Microsoft Corporation.
|
|
3
2
|
// Licensed under the MIT license.
|
|
4
|
-
|
|
5
|
-
exports.DocPropsAutoUpdatedElements = exports.DocPropsModifiableElements = exports.DataTypes = void 0;
|
|
6
|
-
var DataTypes;
|
|
3
|
+
export var DataTypes;
|
|
7
4
|
(function (DataTypes) {
|
|
8
5
|
DataTypes[DataTypes["null"] = 0] = "null";
|
|
9
6
|
DataTypes[DataTypes["string"] = 1] = "string";
|
|
10
7
|
DataTypes[DataTypes["number"] = 2] = "number";
|
|
11
8
|
DataTypes[DataTypes["boolean"] = 3] = "boolean";
|
|
12
|
-
})(DataTypes
|
|
13
|
-
var DocPropsModifiableElements;
|
|
9
|
+
})(DataTypes || (DataTypes = {}));
|
|
10
|
+
export var DocPropsModifiableElements;
|
|
14
11
|
(function (DocPropsModifiableElements) {
|
|
15
12
|
DocPropsModifiableElements["title"] = "dc:title";
|
|
16
13
|
DocPropsModifiableElements["subject"] = "dc:subject";
|
|
@@ -20,9 +17,9 @@ var DocPropsModifiableElements;
|
|
|
20
17
|
DocPropsModifiableElements["lastModifiedBy"] = "cp:lastModifiedBy";
|
|
21
18
|
DocPropsModifiableElements["category"] = "cp:category";
|
|
22
19
|
DocPropsModifiableElements["revision"] = "cp:revision";
|
|
23
|
-
})(DocPropsModifiableElements
|
|
24
|
-
var DocPropsAutoUpdatedElements;
|
|
20
|
+
})(DocPropsModifiableElements || (DocPropsModifiableElements = {}));
|
|
21
|
+
export var DocPropsAutoUpdatedElements;
|
|
25
22
|
(function (DocPropsAutoUpdatedElements) {
|
|
26
23
|
DocPropsAutoUpdatedElements["created"] = "dcterms:created";
|
|
27
24
|
DocPropsAutoUpdatedElements["modified"] = "dcterms:modified";
|
|
28
|
-
})(DocPropsAutoUpdatedElements
|
|
25
|
+
})(DocPropsAutoUpdatedElements || (DocPropsAutoUpdatedElements = {}));
|
package/dist/utils/arrayUtils.js
CHANGED
|
@@ -1,46 +1,48 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright (c) Microsoft Corporation.
|
|
3
2
|
// Licensed under the MIT license.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class ArrayReader {
|
|
7
|
-
constructor(array) {
|
|
3
|
+
var ArrayReader = /** @class */ (function () {
|
|
4
|
+
function ArrayReader(array) {
|
|
8
5
|
this._array = array;
|
|
9
6
|
this._position = 0;
|
|
10
7
|
}
|
|
11
|
-
getInt32() {
|
|
12
|
-
|
|
8
|
+
ArrayReader.prototype.getInt32 = function () {
|
|
9
|
+
var retVal = new DataView(this._array, this._position, 4).getInt32(0, true);
|
|
13
10
|
this._position += 4;
|
|
14
11
|
return retVal;
|
|
15
|
-
}
|
|
16
|
-
getBytes(bytes) {
|
|
17
|
-
|
|
12
|
+
};
|
|
13
|
+
ArrayReader.prototype.getBytes = function (bytes) {
|
|
14
|
+
var retVal = this._array.slice(this._position, bytes ? bytes + this._position : bytes);
|
|
18
15
|
this._position += retVal.byteLength;
|
|
19
16
|
return new Uint8Array(retVal);
|
|
20
|
-
}
|
|
21
|
-
reset() {
|
|
17
|
+
};
|
|
18
|
+
ArrayReader.prototype.reset = function () {
|
|
22
19
|
this._position = 0;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
};
|
|
21
|
+
return ArrayReader;
|
|
22
|
+
}());
|
|
23
|
+
export { ArrayReader };
|
|
26
24
|
function getInt32Buffer(val) {
|
|
27
|
-
|
|
25
|
+
var packageSizeBuffer = new ArrayBuffer(4);
|
|
28
26
|
new DataView(packageSizeBuffer).setInt32(0, val, true);
|
|
29
27
|
return new Uint8Array(packageSizeBuffer);
|
|
30
28
|
}
|
|
31
|
-
function concatArrays(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
function concatArrays() {
|
|
30
|
+
var args = [];
|
|
31
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
32
|
+
args[_i] = arguments[_i];
|
|
33
|
+
}
|
|
34
|
+
var size = 0;
|
|
35
|
+
args.forEach(function (arr) { return (size += arr.byteLength); });
|
|
36
|
+
var retVal = new Uint8Array(size);
|
|
37
|
+
var position = 0;
|
|
38
|
+
args.forEach(function (arr) {
|
|
37
39
|
retVal.set(arr, position);
|
|
38
40
|
position += arr.byteLength;
|
|
39
41
|
});
|
|
40
42
|
return retVal;
|
|
41
43
|
}
|
|
42
|
-
|
|
43
|
-
ArrayReader,
|
|
44
|
-
getInt32Buffer,
|
|
45
|
-
concatArrays,
|
|
44
|
+
export default {
|
|
45
|
+
ArrayReader: ArrayReader,
|
|
46
|
+
getInt32Buffer: getInt32Buffer,
|
|
47
|
+
concatArrays: concatArrays,
|
|
46
48
|
};
|
package/dist/utils/constants.js
CHANGED
|
@@ -1,63 +1,58 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright (c) Microsoft Corporation.
|
|
3
2
|
// Licensed under the MIT license.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
exports.trueStr = "true";
|
|
58
|
-
exports.falseStr = "false";
|
|
59
|
-
exports.BOM = "\ufeff";
|
|
60
|
-
exports.element = {
|
|
3
|
+
export var connectionsXmlPath = "xl/connections.xml";
|
|
4
|
+
export var sharedStringsXmlPath = "xl/sharedStrings.xml";
|
|
5
|
+
export var sheetsXmlPath = "xl/worksheets/sheet1.xml";
|
|
6
|
+
export var tableXmlPath = "xl/tables/table1.xml";
|
|
7
|
+
export var queryTableXmlPath = "xl/queryTables/queryTable1.xml";
|
|
8
|
+
export var workbookXmlPath = "xl/workbook.xml";
|
|
9
|
+
export var queryTablesPath = "xl/queryTables/";
|
|
10
|
+
export var pivotCachesPath = "xl/pivotCache/";
|
|
11
|
+
export var section1mPath = "Formulas/Section1.m";
|
|
12
|
+
export var docPropsCoreXmlPath = "docProps/core.xml";
|
|
13
|
+
export var relsXmlPath = "_rels/.rels";
|
|
14
|
+
export var docMetadataXmlPath = "docMetadata";
|
|
15
|
+
export var docPropsRootElement = "cp:coreProperties";
|
|
16
|
+
export var sharedStringsNotFoundErr = "SharedStrings were not found in template";
|
|
17
|
+
export var connectionsNotFoundErr = "Connections were not found in template";
|
|
18
|
+
export var sheetsNotFoundErr = "Sheets were not found in template";
|
|
19
|
+
export var base64NotFoundErr = "Base64 was not found in template";
|
|
20
|
+
export var emptyQueryMashupErr = "Query mashup is empty";
|
|
21
|
+
export var queryNameNotFoundErr = "Query name was not found";
|
|
22
|
+
export var queryAndPivotTableNotFoundErr = "No such query found in Query Table or Pivot Table found in given template";
|
|
23
|
+
export var queryConnectionNotFoundErr = "No connection found for query";
|
|
24
|
+
export var formulaSectionNotFoundErr = "Formula section wasn't found in template";
|
|
25
|
+
export var templateWithInitialDataErr = "Cannot use a template file with initial data";
|
|
26
|
+
export var queryTableNotFoundErr = "Query table wasn't found in template";
|
|
27
|
+
export var tableNotFoundErr = "Table wasn't found in template";
|
|
28
|
+
export var invalidValueInColumnErr = "Invalid cell value in column";
|
|
29
|
+
export var headerNotFoundErr = "Invalid JSON file, header is missing";
|
|
30
|
+
export var invalidDataTypeErr = "Invalid JSON file, invalid data type";
|
|
31
|
+
export var QueryNameMaxLengthErr = "Query names are limited to 80 characters";
|
|
32
|
+
export var QueryNameInvalidCharsErr = 'Query names cannot contain periods or quotation marks. (. ")';
|
|
33
|
+
export var EmptyQueryNameErr = "Query name cannot be empty";
|
|
34
|
+
export var stylesNotFoundErr = "Styles were not found in template";
|
|
35
|
+
export var InvalidColumnNameErr = "Invalid column name";
|
|
36
|
+
export var promotedHeadersCannotBeUsedWithoutAdjustingColumnNamesErr = "Headers cannot be promoted without adjusting column names";
|
|
37
|
+
export var unexpectedErr = "Unexpected error";
|
|
38
|
+
export var arrayIsntMxNErr = "Array isn't MxN";
|
|
39
|
+
export var relsNotFoundErr = ".rels were not found in template";
|
|
40
|
+
export var blobFileType = "blob";
|
|
41
|
+
export var uint8ArrayType = "uint8array";
|
|
42
|
+
export var application = "application/xlsx";
|
|
43
|
+
export var textResultType = "text";
|
|
44
|
+
export var xmlTextResultType = "text/xml";
|
|
45
|
+
export var pivotCachesPathPrefix = "pivotCacheDefinition";
|
|
46
|
+
export var trueValue = "1";
|
|
47
|
+
export var falseValue = "0";
|
|
48
|
+
export var emptyValue = "";
|
|
49
|
+
export var section1PathPrefix = "Section1/";
|
|
50
|
+
export var divider = "/";
|
|
51
|
+
export var maxQueryLength = 80;
|
|
52
|
+
export var trueStr = "true";
|
|
53
|
+
export var falseStr = "false";
|
|
54
|
+
export var BOM = "\ufeff";
|
|
55
|
+
export var element = {
|
|
61
56
|
sharedStringTable: "sst",
|
|
62
57
|
text: "t",
|
|
63
58
|
sharedStringItem: "si",
|
|
@@ -86,7 +81,7 @@ exports.element = {
|
|
|
86
81
|
selection: "selection",
|
|
87
82
|
kindCell: "c",
|
|
88
83
|
};
|
|
89
|
-
|
|
84
|
+
export var elementAttributes = {
|
|
90
85
|
connection: "connection",
|
|
91
86
|
command: "command",
|
|
92
87
|
refreshOnLoad: "refreshOnLoad",
|
|
@@ -116,25 +111,26 @@ exports.elementAttributes = {
|
|
|
116
111
|
spans: "spans",
|
|
117
112
|
x14acDyDescent: "x14ac:dyDescent",
|
|
118
113
|
xr3uid: "xr3:uid",
|
|
114
|
+
space: "xml:space",
|
|
119
115
|
};
|
|
120
|
-
|
|
116
|
+
export var dataTypeKind = {
|
|
121
117
|
string: "str",
|
|
122
118
|
number: "1",
|
|
123
119
|
boolean: "b",
|
|
124
120
|
};
|
|
125
|
-
|
|
126
|
-
connectionName: (queryName)
|
|
127
|
-
connectionDescription: (queryName)
|
|
128
|
-
connection: (queryName)
|
|
129
|
-
connectionCommand: (queryName)
|
|
130
|
-
tableResultType: ()
|
|
121
|
+
export var elementAttributesValues = {
|
|
122
|
+
connectionName: function (queryName) { return "Query - ".concat(queryName); },
|
|
123
|
+
connectionDescription: function (queryName) { return "Connection to the '".concat(queryName, "' query in the workbook."); },
|
|
124
|
+
connection: function (queryName) { return "Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=\"".concat(queryName, "\";"); },
|
|
125
|
+
connectionCommand: function (queryName) { return "SELECT * FROM [".concat(queryName, "]"); },
|
|
126
|
+
tableResultType: function () { return "sTable"; },
|
|
131
127
|
};
|
|
132
|
-
|
|
128
|
+
export var defaults = {
|
|
133
129
|
queryName: "Query1",
|
|
134
130
|
sheetName: "Sheet1",
|
|
135
131
|
columnName: "Column",
|
|
136
132
|
};
|
|
137
|
-
|
|
133
|
+
export var URLS = {
|
|
138
134
|
PQ: [
|
|
139
135
|
"http://schemas.microsoft.com/DataMashup",
|
|
140
136
|
"http://schemas.microsoft.com/DataExplorer",
|
|
@@ -143,3 +139,7 @@ exports.URLS = {
|
|
|
143
139
|
],
|
|
144
140
|
CONNECTED_WORKBOOK: "http://schemas.microsoft.com/ConnectedWorkbook",
|
|
145
141
|
};
|
|
142
|
+
// Content-Type header to indicate that the content is an Excel document
|
|
143
|
+
export var headers = {
|
|
144
|
+
"Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
145
|
+
};
|