@microsoft/connected-workbooks 1.0.0 → 2.1.16-beta

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 (46) hide show
  1. package/README.md +87 -57
  2. package/dist/GridParser.d.ts +6 -0
  3. package/dist/GridParser.js +55 -0
  4. package/dist/TableDataParserFactory.d.ts +4 -0
  5. package/dist/TableDataParserFactory.js +15 -0
  6. package/dist/constants.d.ts +121 -0
  7. package/dist/constants.js +131 -0
  8. package/dist/generators.d.ts +3 -0
  9. package/dist/generators.js +14 -0
  10. package/dist/index.d.ts +3 -1
  11. package/dist/index.js +7 -4
  12. package/dist/mashupDocumentParser.d.ts +7 -4
  13. package/dist/mashupDocumentParser.js +169 -72
  14. package/dist/types.d.ts +55 -0
  15. package/dist/types.js +29 -0
  16. package/dist/utils/arrayUtils.d.ts +16 -0
  17. package/dist/{arrayUtils.js → utils/arrayUtils.js} +12 -10
  18. package/dist/utils/constants.d.ts +121 -0
  19. package/dist/utils/constants.js +131 -0
  20. package/dist/utils/documentUtils.d.ts +15 -0
  21. package/dist/utils/documentUtils.js +101 -0
  22. package/dist/utils/htmlUtils.d.ts +1 -0
  23. package/dist/utils/htmlUtils.js +25 -0
  24. package/dist/utils/index.d.ts +6 -0
  25. package/dist/utils/index.js +20 -0
  26. package/dist/utils/mashupDocumentParser.d.ts +7 -0
  27. package/dist/utils/mashupDocumentParser.js +166 -0
  28. package/dist/utils/pqUtils.d.ts +15 -0
  29. package/dist/utils/pqUtils.js +101 -0
  30. package/dist/utils/tableUtils.d.ts +10 -0
  31. package/dist/utils/tableUtils.js +146 -0
  32. package/dist/utils/xmlInnerPartsUtils.d.ts +24 -0
  33. package/dist/utils/xmlInnerPartsUtils.js +198 -0
  34. package/dist/utils/xmlPartsUtils.d.ts +8 -0
  35. package/dist/utils/xmlPartsUtils.js +62 -0
  36. package/dist/workbookManager.d.ts +8 -13
  37. package/dist/workbookManager.js +78 -133
  38. package/dist/workbookTemplate.d.ts +2 -1
  39. package/dist/workbookTemplate.js +2 -2
  40. package/package.json +21 -8
  41. package/dist/arrayUtils.d.ts +0 -10
  42. package/dist/arrayUtils.js.map +0 -1
  43. package/dist/index.js.map +0 -1
  44. package/dist/mashupDocumentParser.js.map +0 -1
  45. package/dist/workbookManager.js.map +0 -1
  46. package/dist/workbookTemplate.js.map +0 -1
@@ -1,72 +1,169 @@
1
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT license.
4
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
- if (k2 === undefined) k2 = k;
6
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
7
- }) : (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- o[k2] = m[k];
10
- }));
11
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
12
- Object.defineProperty(o, "default", { enumerable: true, value: v });
13
- }) : function(o, v) {
14
- o["default"] = v;
15
- });
16
- var __importStar = (this && this.__importStar) || function (mod) {
17
- if (mod && mod.__esModule) return mod;
18
- var result = {};
19
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
20
- __setModuleDefault(result, mod);
21
- return result;
22
- };
23
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
24
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
25
- return new (P || (P = Promise))(function (resolve, reject) {
26
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
27
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
28
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
29
- step((generator = generator.apply(thisArg, _arguments || [])).next());
30
- });
31
- };
32
- var __importDefault = (this && this.__importDefault) || function (mod) {
33
- return (mod && mod.__esModule) ? mod : { "default": mod };
34
- };
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- const jszip_1 = __importDefault(require("jszip"));
37
- const base64 = __importStar(require("byte-base64"));
38
- const arrayUtils_1 = require("./arrayUtils");
39
- class MashupHandler {
40
- ReplaceSingleQuery(base64str, query) {
41
- return __awaiter(this, void 0, void 0, function* () {
42
- let buffer = base64.base64ToBytes(base64str).buffer;
43
- let mashupArray = new arrayUtils_1.ArrayReader(buffer);
44
- let startArray = mashupArray.getBytes(4);
45
- let packageSize = mashupArray.getInt32();
46
- let packageOPC = mashupArray.getBytes(packageSize);
47
- let endBuffer = mashupArray.getBytes();
48
- let newPackageBuffer = yield this.editSingleQueryPackage(packageOPC, "Query1", query);
49
- let packageSizeBuffer = arrayUtils_1.getInt32Buffer(newPackageBuffer.byteLength);
50
- let newMashup = arrayUtils_1.concatArrays(startArray, packageSizeBuffer, newPackageBuffer, endBuffer);
51
- return base64.bytesToBase64(newMashup);
52
- });
53
- }
54
- editSingleQueryPackage(packageOPC, queryName, query) {
55
- var _a;
56
- return __awaiter(this, void 0, void 0, function* () {
57
- let packageZip = yield jszip_1.default.loadAsync(packageOPC);
58
- let section1m = yield ((_a = packageZip.file("Formulas/Section1.m")) === null || _a === void 0 ? void 0 : _a.async("text"));
59
- if (section1m === undefined) {
60
- throw new Error("Formula section wasn't found in template");
61
- }
62
- let newSection1m = `section Section1;
63
-
64
- shared ${queryName} =
65
- ${query};`;
66
- packageZip.file("Formulas/Section1.m", newSection1m, { compression: "" });
67
- return yield packageZip.generateAsync({ type: "uint8array" });
68
- });
69
- }
70
- }
71
- exports.default = MashupHandler;
72
- //# sourceMappingURL=mashupDocumentParser.js.map
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT license.
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || function (mod) {
21
+ if (mod && mod.__esModule) return mod;
22
+ var result = {};
23
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
+ __setModuleDefault(result, mod);
25
+ return result;
26
+ };
27
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
28
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
29
+ return new (P || (P = Promise))(function (resolve, reject) {
30
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
31
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
32
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
33
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
34
+ });
35
+ };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ const base64 = __importStar(require("base64-js"));
41
+ const jszip_1 = __importDefault(require("jszip"));
42
+ const constants_1 = require("./constants");
43
+ const utils_1 = require("./utils");
44
+ class MashupHandler {
45
+ constructor() {
46
+ this.setSection1m = (queryMashupDoc, zip) => {
47
+ var _a;
48
+ if (!((_a = zip.file(constants_1.section1mPath)) === null || _a === void 0 ? void 0 : _a.async(constants_1.textResultType))) {
49
+ throw new Error(constants_1.formulaSectionNotFoundErr);
50
+ }
51
+ const newSection1m = queryMashupDoc;
52
+ zip.file(constants_1.section1mPath, newSection1m, {
53
+ compression: constants_1.emptyValue,
54
+ });
55
+ };
56
+ this.editSingleQueryMetadata = (metadataArray, metadata) => {
57
+ var _a;
58
+ //extract metadataXml
59
+ const mashupArray = new utils_1.arrayUtils.ArrayReader(metadataArray.buffer);
60
+ const metadataVersion = mashupArray.getBytes(4);
61
+ const metadataXmlSize = mashupArray.getInt32();
62
+ const metadataXml = mashupArray.getBytes(metadataXmlSize);
63
+ const endBuffer = mashupArray.getBytes();
64
+ //parse metdataXml
65
+ const textDecoder = new TextDecoder();
66
+ const metadataString = textDecoder.decode(metadataXml);
67
+ const parser = new DOMParser();
68
+ const serializer = new XMLSerializer();
69
+ const parsedMetadata = parser.parseFromString(metadataString, constants_1.xmlTextResultType);
70
+ // Update InfoPaths to new QueryName
71
+ const itemPaths = parsedMetadata.getElementsByTagName(constants_1.element.itemPath);
72
+ if (itemPaths && itemPaths.length) {
73
+ for (let i = 0; i < itemPaths.length; i++) {
74
+ const itemPath = itemPaths[i];
75
+ const content = itemPath.innerHTML;
76
+ if (content.includes(constants_1.section1PathPrefix)) {
77
+ const strArr = content.split(constants_1.divider);
78
+ strArr[1] = metadata.queryName;
79
+ const newContent = strArr.join(constants_1.divider);
80
+ itemPath.textContent = newContent;
81
+ }
82
+ }
83
+ }
84
+ const entries = parsedMetadata.getElementsByTagName(constants_1.element.entry);
85
+ if (entries && entries.length) {
86
+ for (let i = 0; i < entries.length; i++) {
87
+ const entry = entries[i];
88
+ const entryAttributes = entry.attributes;
89
+ const entryAttributesArr = [...entryAttributes];
90
+ const entryProp = entryAttributesArr.find((prop) => {
91
+ return (prop === null || prop === void 0 ? void 0 : prop.name) === constants_1.elementAttributes.type;
92
+ });
93
+ if ((entryProp === null || entryProp === void 0 ? void 0 : entryProp.nodeValue) == constants_1.elementAttributes.relationshipInfo) {
94
+ const newValue = (_a = entry.getAttribute(constants_1.elementAttributes.value)) === null || _a === void 0 ? void 0 : _a.replace(/Query1/g, metadata.queryName);
95
+ if (newValue) {
96
+ entry.setAttribute(constants_1.elementAttributes.value, newValue);
97
+ }
98
+ }
99
+ if ((entryProp === null || entryProp === void 0 ? void 0 : entryProp.nodeValue) == constants_1.elementAttributes.resultType) {
100
+ entry.setAttribute(constants_1.elementAttributes.value, constants_1.elementAttributesValues.tableResultType());
101
+ }
102
+ if ((entryProp === null || entryProp === void 0 ? void 0 : entryProp.nodeValue) == constants_1.elementAttributes.fillColumnNames) {
103
+ const oldValue = entry.getAttribute(constants_1.elementAttributes.value);
104
+ if (oldValue) {
105
+ entry.setAttribute(constants_1.elementAttributes.value, oldValue.replace(constants_1.defaults.queryName, metadata.queryName));
106
+ }
107
+ }
108
+ if ((entryProp === null || entryProp === void 0 ? void 0 : entryProp.nodeValue) == constants_1.elementAttributes.fillTarget) {
109
+ const oldValue = entry.getAttribute(constants_1.elementAttributes.value);
110
+ if (oldValue) {
111
+ entry.setAttribute(constants_1.elementAttributes.value, oldValue.replace(constants_1.defaults.queryName, metadata.queryName));
112
+ }
113
+ }
114
+ if ((entryProp === null || entryProp === void 0 ? void 0 : entryProp.nodeValue) == constants_1.elementAttributes.fillLastUpdated) {
115
+ const nowTime = new Date().toISOString();
116
+ entry.setAttribute(constants_1.elementAttributes.value, (constants_1.elementAttributes.day + nowTime).replace(/Z/, '0000Z'));
117
+ }
118
+ }
119
+ }
120
+ // Convert new metadataXml to Uint8Array
121
+ const newMetadataString = serializer.serializeToString(parsedMetadata);
122
+ const encoder = new TextEncoder();
123
+ const newMetadataXml = encoder.encode(newMetadataString);
124
+ const newMetadataXmlSize = utils_1.arrayUtils.getInt32Buffer(newMetadataXml.byteLength);
125
+ const newMetadataArray = utils_1.arrayUtils.concatArrays(metadataVersion, newMetadataXmlSize, newMetadataXml, endBuffer);
126
+ return newMetadataArray;
127
+ };
128
+ }
129
+ ReplaceSingleQuery(base64Str, queryName, queryMashupDoc) {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ const { version, packageOPC, permissionsSize, permissions, metadata, endBuffer } = this.getPackageComponents(base64Str);
132
+ const newPackageBuffer = yield this.editSingleQueryPackage(packageOPC, queryMashupDoc);
133
+ const packageSizeBuffer = utils_1.arrayUtils.getInt32Buffer(newPackageBuffer.byteLength);
134
+ const permissionsSizeBuffer = utils_1.arrayUtils.getInt32Buffer(permissionsSize);
135
+ const newMetadataBuffer = this.editSingleQueryMetadata(metadata, { queryName });
136
+ const metadataSizeBuffer = utils_1.arrayUtils.getInt32Buffer(newMetadataBuffer.byteLength);
137
+ const newMashup = utils_1.arrayUtils.concatArrays(version, packageSizeBuffer, newPackageBuffer, permissionsSizeBuffer, permissions, metadataSizeBuffer, newMetadataBuffer, endBuffer);
138
+ return base64.fromByteArray(newMashup);
139
+ });
140
+ }
141
+ getPackageComponents(base64Str) {
142
+ const buffer = base64.toByteArray(base64Str).buffer;
143
+ const mashupArray = new utils_1.arrayUtils.ArrayReader(buffer);
144
+ const version = mashupArray.getBytes(4);
145
+ const packageSize = mashupArray.getInt32();
146
+ const packageOPC = mashupArray.getBytes(packageSize);
147
+ const permissionsSize = mashupArray.getInt32();
148
+ const permissions = mashupArray.getBytes(permissionsSize);
149
+ const metadataSize = mashupArray.getInt32();
150
+ const metadata = mashupArray.getBytes(metadataSize);
151
+ const endBuffer = mashupArray.getBytes();
152
+ return {
153
+ version,
154
+ packageOPC,
155
+ permissionsSize,
156
+ permissions,
157
+ metadata,
158
+ endBuffer
159
+ };
160
+ }
161
+ editSingleQueryPackage(packageOPC, queryMashupDoc) {
162
+ return __awaiter(this, void 0, void 0, function* () {
163
+ const packageZip = yield jszip_1.default.loadAsync(packageOPC);
164
+ this.setSection1m(queryMashupDoc, packageZip);
165
+ return yield packageZip.generateAsync({ type: constants_1.uint8ArrayType });
166
+ });
167
+ }
168
+ }
169
+ exports.default = MashupHandler;
@@ -0,0 +1,55 @@
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
+ columnMetadata: ColumnMetadata[];
21
+ rows: string[][];
22
+ columnwidth?: number;
23
+ }
24
+ export interface ColumnMetadata {
25
+ name: string;
26
+ type: DataTypes;
27
+ }
28
+ export interface Grid {
29
+ header: ColumnMetadata[];
30
+ gridData: (string | number | boolean)[][];
31
+ }
32
+ export interface TableDataParser {
33
+ parseToTableData: (grid: any) => TableData | undefined;
34
+ }
35
+ export declare enum DataTypes {
36
+ autodetect = -1,
37
+ null = 0,
38
+ string = 1,
39
+ number = 2,
40
+ boolean = 3
41
+ }
42
+ export declare enum DocPropsModifiableElements {
43
+ title = "dc:title",
44
+ subject = "dc:subject",
45
+ keywords = "cp:keywords",
46
+ createdBy = "dc:creator",
47
+ description = "dc:description",
48
+ lastModifiedBy = "cp:lastModifiedBy",
49
+ category = "cp:category",
50
+ revision = "cp:revision"
51
+ }
52
+ export declare enum DocPropsAutoUpdatedElements {
53
+ created = "dcterms:created",
54
+ modified = "dcterms:modified"
55
+ }
package/dist/types.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT license.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.DocPropsAutoUpdatedElements = exports.DocPropsModifiableElements = exports.DataTypes = void 0;
6
+ var DataTypes;
7
+ (function (DataTypes) {
8
+ DataTypes[DataTypes["autodetect"] = -1] = "autodetect";
9
+ DataTypes[DataTypes["null"] = 0] = "null";
10
+ DataTypes[DataTypes["string"] = 1] = "string";
11
+ DataTypes[DataTypes["number"] = 2] = "number";
12
+ DataTypes[DataTypes["boolean"] = 3] = "boolean";
13
+ })(DataTypes = exports.DataTypes || (exports.DataTypes = {}));
14
+ var DocPropsModifiableElements;
15
+ (function (DocPropsModifiableElements) {
16
+ DocPropsModifiableElements["title"] = "dc:title";
17
+ DocPropsModifiableElements["subject"] = "dc:subject";
18
+ DocPropsModifiableElements["keywords"] = "cp:keywords";
19
+ DocPropsModifiableElements["createdBy"] = "dc:creator";
20
+ DocPropsModifiableElements["description"] = "dc:description";
21
+ DocPropsModifiableElements["lastModifiedBy"] = "cp:lastModifiedBy";
22
+ DocPropsModifiableElements["category"] = "cp:category";
23
+ DocPropsModifiableElements["revision"] = "cp:revision";
24
+ })(DocPropsModifiableElements = exports.DocPropsModifiableElements || (exports.DocPropsModifiableElements = {}));
25
+ var DocPropsAutoUpdatedElements;
26
+ (function (DocPropsAutoUpdatedElements) {
27
+ DocPropsAutoUpdatedElements["created"] = "dcterms:created";
28
+ DocPropsAutoUpdatedElements["modified"] = "dcterms:modified";
29
+ })(DocPropsAutoUpdatedElements = exports.DocPropsAutoUpdatedElements || (exports.DocPropsAutoUpdatedElements = {}));
@@ -0,0 +1,16 @@
1
+ export declare class ArrayReader {
2
+ private _array;
3
+ private _position;
4
+ constructor(array: ArrayBuffer);
5
+ getInt32(): number;
6
+ getBytes(bytes?: number): Uint8Array;
7
+ reset(): void;
8
+ }
9
+ declare function getInt32Buffer(val: number): Uint8Array;
10
+ declare function concatArrays(...args: Uint8Array[]): Uint8Array;
11
+ declare const _default: {
12
+ ArrayReader: typeof ArrayReader;
13
+ getInt32Buffer: typeof getInt32Buffer;
14
+ concatArrays: typeof concatArrays;
15
+ };
16
+ export default _default;
@@ -2,19 +2,19 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT license.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.concatArrays = exports.getInt32Buffer = exports.ArrayReader = void 0;
5
+ exports.ArrayReader = void 0;
6
6
  class ArrayReader {
7
7
  constructor(array) {
8
8
  this._array = array;
9
9
  this._position = 0;
10
10
  }
11
11
  getInt32() {
12
- let retVal = new DataView(this._array, this._position, 4).getInt32(0, true);
12
+ const retVal = new DataView(this._array, this._position, 4).getInt32(0, true);
13
13
  this._position += 4;
14
14
  return retVal;
15
15
  }
16
16
  getBytes(bytes) {
17
- let retVal = this._array.slice(this._position, (bytes ? bytes + this._position : bytes));
17
+ const retVal = this._array.slice(this._position, bytes ? bytes + this._position : bytes);
18
18
  this._position += retVal.byteLength;
19
19
  return new Uint8Array(retVal);
20
20
  }
@@ -24,21 +24,23 @@ class ArrayReader {
24
24
  }
25
25
  exports.ArrayReader = ArrayReader;
26
26
  function getInt32Buffer(val) {
27
- let packageSizeBuffer = new ArrayBuffer(4);
27
+ const packageSizeBuffer = new ArrayBuffer(4);
28
28
  new DataView(packageSizeBuffer).setInt32(0, val, true);
29
29
  return new Uint8Array(packageSizeBuffer);
30
30
  }
31
- exports.getInt32Buffer = getInt32Buffer;
32
31
  function concatArrays(...args) {
33
32
  let size = 0;
34
- args.forEach(arr => size += arr.byteLength);
35
- let retVal = new Uint8Array(size);
33
+ args.forEach((arr) => (size += arr.byteLength));
34
+ const retVal = new Uint8Array(size);
36
35
  let position = 0;
37
- args.forEach(arr => {
36
+ args.forEach((arr) => {
38
37
  retVal.set(arr, position);
39
38
  position += arr.byteLength;
40
39
  });
41
40
  return retVal;
42
41
  }
43
- exports.concatArrays = concatArrays;
44
- //# sourceMappingURL=arrayUtils.js.map
42
+ exports.default = {
43
+ ArrayReader,
44
+ getInt32Buffer,
45
+ concatArrays,
46
+ };
@@ -0,0 +1,121 @@
1
+ export declare const connectionsXmlPath = "xl/connections.xml";
2
+ export declare const sharedStringsXmlPath = "xl/sharedStrings.xml";
3
+ export declare const sheetsXmlPath = "xl/worksheets/sheet1.xml";
4
+ export declare const tableXmlPath = "xl/tables/table1.xml";
5
+ export declare const queryTableXmlPath = "xl/queryTables/queryTable1.xml";
6
+ export declare const workbookXmlPath = "xl/workbook.xml";
7
+ export declare const queryTablesPath = "xl/queryTables/";
8
+ export declare const pivotCachesPath = "xl/pivotCache/";
9
+ export declare const section1mPath = "Formulas/Section1.m";
10
+ export declare const docPropsCoreXmlPath = "docProps/core.xml";
11
+ export declare const docPropsRootElement = "cp:coreProperties";
12
+ export declare const sharedStringsNotFoundErr = "SharedStrings were not found in template";
13
+ export declare const connectionsNotFoundErr = "Connections were not found in template";
14
+ export declare const sheetsNotFoundErr = "Sheets were not found in template";
15
+ export declare const base64NotFoundErr = "Base64 was not found in template";
16
+ export declare const emptyQueryMashupErr = "Query mashup is empty";
17
+ export declare const queryNameNotFoundErr = "Query name was not found";
18
+ export declare const queryAndPivotTableNotFoundErr = "No such query found in Query Table or Pivot Table found in given template";
19
+ export declare const queryConnectionNotFoundErr = "No connection found for query";
20
+ export declare const formulaSectionNotFoundErr = "Formula section wasn't found in template";
21
+ export declare const templateWithInitialDataErr = "Cannot receive template file with initial data";
22
+ export declare const queryTableNotFoundErr = "Query table wasn't found in template";
23
+ export declare const tableNotFoundErr = "Table wasn't found in template";
24
+ export declare const gridNotFoundErr = "Invalid JSON file, grid data is missing";
25
+ export declare const invalidValueInColumnErr = "Invalid cell value in column";
26
+ export declare const headerNotFoundErr = "Invalid JSON file, header is missing";
27
+ export declare const invalidDataTypeErr = "Invalid JSON file, invalid data type";
28
+ export declare const QueryNameMaxLengthErr = "Query names are limited to 80 characters";
29
+ export declare const EmptyQueryNameErr = "Query name cannot be empty";
30
+ export declare const stylesNotFoundErr = "Styles were not found in template";
31
+ export declare const blobFileType = "blob";
32
+ export declare const uint8ArrayType = "uint8array";
33
+ export declare const application = "application/xlsx";
34
+ export declare const textResultType = "text";
35
+ export declare const xmlTextResultType = "text/xml";
36
+ export declare const pivotCachesPathPrefix = "pivotCacheDefinition";
37
+ export declare const trueValue = "1";
38
+ export declare const falseValue = "0";
39
+ export declare const emptyValue = "";
40
+ export declare const section1PathPrefix = "Section1/";
41
+ export declare const divider = "/";
42
+ export declare const maxQueryLength = 80;
43
+ export declare const trueStr = "true";
44
+ export declare const falseStr = "false";
45
+ export declare const element: {
46
+ sharedStringTable: string;
47
+ text: string;
48
+ sharedStringItem: string;
49
+ cellValue: string;
50
+ databaseProperties: string;
51
+ queryTable: string;
52
+ cacheSource: string;
53
+ item: string;
54
+ items: string;
55
+ itemPath: string;
56
+ itemType: string;
57
+ itemLocation: string;
58
+ entry: string;
59
+ stableEntries: string;
60
+ tableColumns: string;
61
+ tableColumn: string;
62
+ table: string;
63
+ autoFilter: string;
64
+ definedName: string;
65
+ queryTableFields: string;
66
+ queryTableField: string;
67
+ queryTableRefresh: string;
68
+ sheetData: string;
69
+ row: string;
70
+ dimension: string;
71
+ kindCell: string;
72
+ };
73
+ export declare const elementAttributes: {
74
+ connection: string;
75
+ command: string;
76
+ refreshOnLoad: string;
77
+ count: string;
78
+ uniqueCount: string;
79
+ queryTable: string;
80
+ connectionId: string;
81
+ cacheSource: string;
82
+ name: string;
83
+ description: string;
84
+ id: string;
85
+ type: string;
86
+ value: string;
87
+ relationshipInfo: string;
88
+ resultType: string;
89
+ fillColumnNames: string;
90
+ fillTarget: string;
91
+ fillLastUpdated: string;
92
+ day: string;
93
+ uniqueName: string;
94
+ queryTableFieldId: string;
95
+ reference: string;
96
+ tableColumnId: string;
97
+ nextId: string;
98
+ row: string;
99
+ spans: string;
100
+ x14acDyDescent: string;
101
+ xr3uid: string;
102
+ };
103
+ export declare const dataTypeKind: {
104
+ string: string;
105
+ number: string;
106
+ boolean: string;
107
+ };
108
+ export declare const elementAttributesValues: {
109
+ connectionName: (queryName: string) => string;
110
+ connectionDescription: (queryName: string) => string;
111
+ connection: (queryName: string) => string;
112
+ connectionCommand: (queryName: string) => string;
113
+ tableResultType: () => string;
114
+ };
115
+ export declare const defaults: {
116
+ queryName: string;
117
+ };
118
+ export declare const URLS: {
119
+ PQ: string[];
120
+ CONNECTED_WORKBOOK: string;
121
+ };
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT license.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.URLS = exports.defaults = exports.elementAttributesValues = exports.dataTypeKind = exports.elementAttributes = exports.element = exports.falseStr = exports.trueStr = exports.maxQueryLength = exports.divider = exports.section1PathPrefix = exports.emptyValue = exports.falseValue = exports.trueValue = exports.pivotCachesPathPrefix = exports.xmlTextResultType = exports.textResultType = exports.application = exports.uint8ArrayType = exports.blobFileType = exports.stylesNotFoundErr = exports.EmptyQueryNameErr = exports.QueryNameMaxLengthErr = exports.invalidDataTypeErr = exports.headerNotFoundErr = exports.invalidValueInColumnErr = exports.gridNotFoundErr = exports.tableNotFoundErr = exports.queryTableNotFoundErr = exports.templateWithInitialDataErr = exports.formulaSectionNotFoundErr = exports.queryConnectionNotFoundErr = exports.queryAndPivotTableNotFoundErr = exports.queryNameNotFoundErr = exports.emptyQueryMashupErr = exports.base64NotFoundErr = exports.sheetsNotFoundErr = exports.connectionsNotFoundErr = exports.sharedStringsNotFoundErr = exports.docPropsRootElement = exports.docPropsCoreXmlPath = exports.section1mPath = exports.pivotCachesPath = exports.queryTablesPath = exports.workbookXmlPath = exports.queryTableXmlPath = exports.tableXmlPath = exports.sheetsXmlPath = exports.sharedStringsXmlPath = exports.connectionsXmlPath = void 0;
6
+ exports.connectionsXmlPath = "xl/connections.xml";
7
+ exports.sharedStringsXmlPath = "xl/sharedStrings.xml";
8
+ exports.sheetsXmlPath = "xl/worksheets/sheet1.xml";
9
+ exports.tableXmlPath = "xl/tables/table1.xml";
10
+ exports.queryTableXmlPath = "xl/queryTables/queryTable1.xml";
11
+ exports.workbookXmlPath = "xl/workbook.xml";
12
+ exports.queryTablesPath = "xl/queryTables/";
13
+ exports.pivotCachesPath = "xl/pivotCache/";
14
+ exports.section1mPath = "Formulas/Section1.m";
15
+ exports.docPropsCoreXmlPath = "docProps/core.xml";
16
+ exports.docPropsRootElement = "cp:coreProperties";
17
+ exports.sharedStringsNotFoundErr = "SharedStrings were not found in template";
18
+ exports.connectionsNotFoundErr = "Connections were not found in template";
19
+ exports.sheetsNotFoundErr = "Sheets were not found in template";
20
+ exports.base64NotFoundErr = "Base64 was not found in template";
21
+ exports.emptyQueryMashupErr = "Query mashup is empty";
22
+ exports.queryNameNotFoundErr = "Query name was not found";
23
+ exports.queryAndPivotTableNotFoundErr = "No such query found in Query Table or Pivot Table found in given template";
24
+ exports.queryConnectionNotFoundErr = "No connection found for query";
25
+ exports.formulaSectionNotFoundErr = "Formula section wasn't found in template";
26
+ exports.templateWithInitialDataErr = "Cannot receive template file with initial data";
27
+ exports.queryTableNotFoundErr = "Query table wasn't found in template";
28
+ exports.tableNotFoundErr = "Table wasn't found in template";
29
+ exports.gridNotFoundErr = "Invalid JSON file, grid data is missing";
30
+ exports.invalidValueInColumnErr = "Invalid cell value in column";
31
+ exports.headerNotFoundErr = "Invalid JSON file, header is missing";
32
+ exports.invalidDataTypeErr = "Invalid JSON file, invalid data type";
33
+ exports.QueryNameMaxLengthErr = "Query names are limited to 80 characters";
34
+ exports.EmptyQueryNameErr = "Query name cannot be empty";
35
+ exports.stylesNotFoundErr = "Styles were not found in template";
36
+ exports.blobFileType = "blob";
37
+ exports.uint8ArrayType = "uint8array";
38
+ exports.application = "application/xlsx";
39
+ exports.textResultType = "text";
40
+ exports.xmlTextResultType = "text/xml";
41
+ exports.pivotCachesPathPrefix = "pivotCacheDefinition";
42
+ exports.trueValue = "1";
43
+ exports.falseValue = "0";
44
+ exports.emptyValue = "";
45
+ exports.section1PathPrefix = "Section1/";
46
+ exports.divider = "/";
47
+ exports.maxQueryLength = 80;
48
+ exports.trueStr = "true";
49
+ exports.falseStr = "false";
50
+ exports.element = {
51
+ sharedStringTable: "sst",
52
+ text: "t",
53
+ sharedStringItem: "si",
54
+ cellValue: "v",
55
+ databaseProperties: "dbPr",
56
+ queryTable: "queryTable",
57
+ cacheSource: "cacheSource",
58
+ item: "Item",
59
+ items: "Items",
60
+ itemPath: "ItemPath",
61
+ itemType: "ItemType",
62
+ itemLocation: "ItemLocation",
63
+ entry: "Entry",
64
+ stableEntries: "StableEntries",
65
+ tableColumns: "tableColumns",
66
+ tableColumn: "tableColumn",
67
+ table: "table",
68
+ autoFilter: "autoFilter",
69
+ definedName: "definedName",
70
+ queryTableFields: "queryTableFields",
71
+ queryTableField: "queryTableField",
72
+ queryTableRefresh: "queryTableRefresh",
73
+ sheetData: "sheetData",
74
+ row: "row",
75
+ dimension: "dimension",
76
+ kindCell: "c"
77
+ };
78
+ exports.elementAttributes = {
79
+ connection: "connection",
80
+ command: "command",
81
+ refreshOnLoad: "refreshOnLoad",
82
+ count: "count",
83
+ uniqueCount: "uniqueCount",
84
+ queryTable: "queryTable",
85
+ connectionId: "connectionId",
86
+ cacheSource: "cacheSource",
87
+ name: "name",
88
+ description: "description",
89
+ id: "id",
90
+ type: "Type",
91
+ value: "Value",
92
+ relationshipInfo: "RelationshipInfoContainer",
93
+ resultType: "ResultType",
94
+ fillColumnNames: "FillColumnNames",
95
+ fillTarget: "FillTarget",
96
+ fillLastUpdated: "FillLastUpdated",
97
+ day: "d",
98
+ uniqueName: "uniqueName",
99
+ queryTableFieldId: "queryTableFieldId",
100
+ reference: "ref",
101
+ tableColumnId: "tableColumnId",
102
+ nextId: "nextId",
103
+ row: "r",
104
+ spans: "spans",
105
+ x14acDyDescent: "x14ac:dyDescent",
106
+ xr3uid: "xr3:uid",
107
+ };
108
+ exports.dataTypeKind = {
109
+ string: "str",
110
+ number: "1",
111
+ boolean: "b",
112
+ };
113
+ exports.elementAttributesValues = {
114
+ connectionName: (queryName) => `Query - ${queryName}`,
115
+ connectionDescription: (queryName) => `Connection to the '${queryName}' query in the workbook.`,
116
+ connection: (queryName) => `Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=${queryName};`,
117
+ connectionCommand: (queryName) => `SELECT * FROM [${queryName}]`,
118
+ tableResultType: () => "sTable"
119
+ };
120
+ exports.defaults = {
121
+ queryName: "Query1",
122
+ };
123
+ exports.URLS = {
124
+ PQ: [
125
+ "http://schemas.microsoft.com/DataMashup",
126
+ "http://schemas.microsoft.com/DataExplorer",
127
+ "http://schemas.microsoft.com/DataMashup/Temp",
128
+ "http://schemas.microsoft.com/DataExplorer/Temp",
129
+ ],
130
+ CONNECTED_WORKBOOK: "http://schemas.microsoft.com/ConnectedWorkbook",
131
+ };