@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
package/README.md CHANGED
@@ -1,84 +1,114 @@
1
1
  # Connected Workbooks
2
+ [![Build Status](https://obilshield.visualstudio.com/ConnectedWorkbooks/_apis/build/status/microsoft.connected-workbooks?branchName=main)](https://obilshield.visualstudio.com/ConnectedWorkbooks/_build/latest?definitionId=14&branchName=main)
3
+ [![License](https://img.shields.io/github/license/microsoft/connected-workbooks)](https://github.com/microsoft/connected-workbooks/blob/master/LICENSE)
4
+ [![Snyk Vulnerabilities](https://img.shields.io/snyk/vulnerabilities/github/microsoft/connected-workbooks)](https://snyk.io/test/github/microsoft/connected-workbooks)
2
5
 
3
- ## Using this project
6
+ A pure JS library, Microsoft backed, that provides xlsx workbook generation capabilities, allowing for:
7
+ 1. Fundemental **"Export to Excel"** capabilities for tabular data (landing in a table in Excel).
8
+ 2. Advanced capabilities of **"Export a Power Query connected workbook"**:
9
+ - Can refresh your data on open and/or on demand.
10
+ - Allows for initial data population.
11
+ - Supports more advanced scenarios where you provide branded/custom workbooks, and load your data into PivotTables or PivotCharts.
4
12
 
5
- Use this project in your to generate workbooks with Power Query in them, mainly targeting 'Export to Excel' features you have in your application.
13
+ Connected Workbooks allows you to avoid "data dumps" in CSV form, providing a richer experience with Tables and/or connected Queries for when your business application supports it.
6
14
 
7
- ### Basic Usage - using a predefined template:
15
+ [Learn about Power Query here](https://powerquery.microsoft.com/en-us/)
8
16
 
9
- The library comes with a workbook template built in, that loads a query named 'Query1' to a Query Table on the grid.
17
+ ## Where is this library used? here are some examples:
10
18
 
19
+ |<img src="https://github.com/microsoft/connected-workbooks/assets/7674478/b7a0c989-7ba4-4da8-851e-04650d8b600e" alt="Kusto" width="32"/>| <img src="https://github.com/microsoft/connected-workbooks/assets/7674478/76d22d23-5f2b-465f-992d-f1c71396904c" alt="LogAnalytics" width="32"/> | <img src="https://github.com/microsoft/connected-workbooks/assets/7674478/436b4f53-bf25-4c45-aae5-55ee1b1feafc" alt="Datamart" width="32"/> | <img src="https://github.com/microsoft/connected-workbooks/assets/7674478/3965f684-b461-42fe-9c62-e3059c0286eb" alt="VivaSales" width="32"/> |
20
+ |--------------------------------- |------------------- |-------------- |---------------- |
21
+ | **Azure Data Explorer** | **Log Analytics** | **Datamart** | **Viva Sales** |
22
+
23
+ ## How do I use it? here are some examples:
24
+
25
+ ### 1. Export a table directly from an Html page:
11
26
  ```typescript
12
- let workbookManager = new WorkbookManager();
13
- let blob = await workbookManager.generateSingleQueryWorkbook({
14
- queryMashup: query,
15
- refreshOnOpen: refreshOnOpen,
16
- });
27
+ import { workbookManager } from '@microsoft/connected-workbooks';
17
28
 
18
- Download(blob, filename);
29
+ const blob = await workbookManager.generateTableWorkbookFromHtml(document.querySelector('table') as HTMLTableElement);
30
+ workbookManager.downloadWorkbook(blob, "MyTable.xlsx");
19
31
  ```
32
+ ### 2. Export a table from raw data:
33
+ ```typescript
34
+ import { workbookManager } from '@microsoft/connected-workbooks';
35
+
36
+ const grid = {
37
+ "header": [
38
+ { "name": "Product", "type": DataTypes.autodetect },
39
+ { "name": "Price", "type": DataTypes.autodetect },
40
+ { "name": "InStock", "type": DataTypes.autodetect },
41
+ { "name": "Category", "type": DataTypes.autodetect },
42
+ { "name": "Date", "type": DataTypes.autodetect }
43
+ ],
44
+ "gridData": [
45
+ ["Widget A", 19.99, true, "Electronics", "10/26/2024"],
46
+ ["Gizmo B", 9.99, true, "Accessories", "10/26/2024"],
47
+ ["Bubala", 14.99, false, "Accessories", "10/22/2023"],
48
+ ["Thingamajig C", 50, false, "Tools", "5/12/2023"],
49
+ ["Doohickey D", 50.01, true, "Home", "8/12/2023"]
50
+ ]
51
+ };
52
+ const blob = await workbookManager.generateTableWorkbookFromGrid(grid);
53
+ workbookManager.downloadWorkbook(blob, "MyTable.xlsx");
54
+ ```
55
+ <img width="281" alt="image" src="https://github.com/microsoft/connected-workbooks/assets/7674478/b91e5d69-8444-4a19-a4b0-3fd721e5576f">
20
56
 
21
- While a typical download method would be:
22
-
57
+ ### 3. Control Document Properties:
23
58
  ```typescript
24
- function Download(file: Blob, filename: string) {
25
- if (window.navigator.msSaveOrOpenBlob)
26
- // IE10+
27
- window.navigator.msSaveOrOpenBlob(file, filename);
28
- else {
29
- // Others
30
- var a = document.createElement("a"),
31
- url = URL.createObjectURL(file);
32
- a.href = url;
33
- a.download = filename;
34
- document.body.appendChild(a);
35
- a.click();
36
- setTimeout(function () {
37
- document.body.removeChild(a);
38
- window.URL.revokeObjectURL(url);
39
- }, 0);
40
- }
41
- }
59
+ const blob = await workbookManager.generateTableWorkbookFromHtml(
60
+ document.querySelector('table') as HTMLTableElement,
61
+ {createdBy: 'John Doe', lastModifiedBy: 'Jane Doe', description: 'This is a sample table'});
62
+
63
+ workbookManager.downloadWorkbook(blob, "MyTable.xlsx");
42
64
  ```
65
+ ![image](https://github.com/microsoft/connected-workbooks/assets/7674478/c267c9eb-6367-419d-832d-5a835c7683f9)
43
66
 
67
+ ### 4. Export a Power Query connected workbook:
68
+ ```typescript
69
+ import { workbookManager } from '@microsoft/connected-workbooks';
70
+
71
+ const blob = await workbookManager.generateSingleQueryWorkbook({
72
+ queryMashup: 'let \
73
+ Source = {1..10} \
74
+ in \
75
+ Source',
76
+ refreshOnOpen: true});
77
+ workbookManager.downloadWorkbook(blob, "MyConnectedWorkbook.xlsx");
78
+ });
79
+ ```
80
+ ![image](https://github.com/microsoft/connected-workbooks/assets/7674478/57bd986c-6309-4963-8d86-911ccf496c3f)
81
+ (after refreshing on open)
44
82
  ### Advanced Usage - bring your own template:
45
83
 
46
- You can use the library with your own template, for that (currently) there should be a single query named **Query1** loaded to a **Query Table**, **Pivot Table**, or **Pivot Chart** in the template workbook, and pass it as a **File** to the templateWorkbook parameter of the API:
84
+ You can use the library with your own workbook as a template!
47
85
 
48
86
  ```typescript
49
- let workbookManager = new WorkbookManager();
50
- let blob = await workbookManager.generateSingleQueryWorkbook(
51
- {
52
- queryMashup: query,
53
- refreshOnOpen: refreshOnOpen,
54
- },
55
- templateFile
56
- );
57
-
58
- Download(blob, filename);
87
+ const blob = await workbookManager.generateSingleQueryWorkbook(
88
+ { queryMashup: query, refreshOnOpen: true },
89
+ undefined /* optional gridData */,
90
+ templateFile);
91
+ workbookManager.downloadWorkbook(blob, "MyBrandedWorkbook.xlsx");
59
92
  ```
93
+ ![image](https://github.com/microsoft/connected-workbooks/assets/7674478/e5377946-4348-4229-9b88-1910ff7ee025)
60
94
 
61
- A common way to get the template workbook with React via user interaction:
95
+ Template requirements:
62
96
 
63
- ```typescript
64
- const [templateFile, setTemplateFile] = useState<File | null>(null);
97
+ Have a single query named **Query1** loaded to a **Query Table**, **Pivot Table**, or a **Pivot Chart**.
65
98
 
66
- ...
67
99
 
68
- <input
69
- onChange={(e) => {
70
- if (e?.target?.files?.item(0) == null) return;
71
- setTemplateFile(e!.target!.files!.item(0));
72
- }}
73
- type="file"
74
- id="file"
75
- accept=".xlsx"
76
- style={{ display: "none" }}
77
- />
100
+ ⭐ Recommendation - have your product template baked and tested in your own product code, instead of your user providing it.
78
101
 
79
- ```
102
+ ⭐ For user templates - a common way to get the template workbook with React via user interaction:
80
103
 
81
- Though expecation is that you have your product template baked and tested in your own product code, and not have the user provide it.
104
+ ```typescript
105
+ const [templateFile, setTemplateFile] = useState<File | null>(null);
106
+ ...
107
+ <input type="file" id="file" accept=".xlsx" style={{ display: "none" }} onChange={(e) => {
108
+ if (e?.target?.files?.item(0) == null) return;
109
+ setTemplateFile(e!.target!.files!.item(0));
110
+ }}/>
111
+ ```
82
112
 
83
113
  ## Contributing
84
114
 
@@ -0,0 +1,6 @@
1
+ import { Grid, TableData, TableDataParser } from "./types";
2
+ export default class GridParser implements TableDataParser {
3
+ parseToTableData(initialDataGrid: Grid): TableData | undefined;
4
+ private parseGridRows;
5
+ private validateGridHeader;
6
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const constants_1 = require("./utils/constants");
4
+ const types_1 = require("./types");
5
+ class GridParser {
6
+ parseToTableData(initialDataGrid) {
7
+ if (!initialDataGrid) {
8
+ return undefined;
9
+ }
10
+ this.validateGridHeader(initialDataGrid);
11
+ const rows = this.parseGridRows(initialDataGrid, initialDataGrid.header);
12
+ return { columnMetadata: initialDataGrid.header, rows: rows };
13
+ }
14
+ parseGridRows(initialDataGrid, columnMetadata) {
15
+ const gridData = initialDataGrid.gridData;
16
+ if (!gridData) {
17
+ throw new Error(constants_1.gridNotFoundErr);
18
+ }
19
+ const rows = [];
20
+ for (const rowData of gridData) {
21
+ const row = [];
22
+ let colIndex = 0;
23
+ for (const prop in rowData) {
24
+ const dataType = columnMetadata[colIndex].type;
25
+ const cellValue = rowData[prop];
26
+ if (dataType == types_1.DataTypes.number) {
27
+ if (isNaN(Number(cellValue))) {
28
+ throw new Error(constants_1.invalidValueInColumnErr);
29
+ }
30
+ }
31
+ else if (dataType == types_1.DataTypes.boolean) {
32
+ if (cellValue != "1" && cellValue != "0") {
33
+ throw new Error(constants_1.invalidValueInColumnErr);
34
+ }
35
+ }
36
+ row.push(rowData[prop].toString());
37
+ colIndex++;
38
+ }
39
+ rows.push(row);
40
+ }
41
+ return rows;
42
+ }
43
+ validateGridHeader(data) {
44
+ const headerData = data.header;
45
+ if (!headerData) {
46
+ throw new Error(constants_1.headerNotFoundErr);
47
+ }
48
+ for (const prop in headerData) {
49
+ if (!(headerData[prop].type in types_1.DataTypes)) {
50
+ throw new Error(constants_1.invalidDataTypeErr);
51
+ }
52
+ }
53
+ }
54
+ }
55
+ exports.default = GridParser;
@@ -0,0 +1,4 @@
1
+ import { TableDataParser } from "./types";
2
+ export default class TableDataParserFactory {
3
+ static createParser(data: any): TableDataParser;
4
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const GridParser_1 = __importDefault(require("./GridParser"));
7
+ class TableDataParserFactory {
8
+ static createParser(data) {
9
+ if (data) {
10
+ return new GridParser_1.default();
11
+ }
12
+ throw new Error("Unsupported data type");
13
+ }
14
+ }
15
+ exports.default = TableDataParserFactory;
@@ -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
+ };
@@ -0,0 +1,3 @@
1
+ export declare const generateMashupXMLTemplate: (base64: string) => string;
2
+ export declare const generateSingleQueryMashup: (queryName: string, query: string) => string;
3
+ export declare const generateCustomXmlFilePath: (i: number) => string;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT license.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.generateCustomXmlFilePath = exports.generateSingleQueryMashup = exports.generateMashupXMLTemplate = void 0;
6
+ const generateMashupXMLTemplate = (base64) => `<?xml version="1.0" encoding="utf-16"?><DataMashup xmlns="http://schemas.microsoft.com/DataMashup">${base64}</DataMashup>`;
7
+ exports.generateMashupXMLTemplate = generateMashupXMLTemplate;
8
+ const generateSingleQueryMashup = (queryName, query) => `section Section1;
9
+
10
+ shared ${queryName} =
11
+ ${query};`;
12
+ exports.generateSingleQueryMashup = generateSingleQueryMashup;
13
+ const generateCustomXmlFilePath = (i) => `customXml/item${i}.xml`;
14
+ exports.generateCustomXmlFilePath = generateCustomXmlFilePath;
package/dist/index.d.ts CHANGED
@@ -1 +1,3 @@
1
- export { WorkbookManager, QueryInfo } from "./workbookManager";
1
+ export { default as workbookManager } from "./workbookManager";
2
+ export { DataTypes } from "./types";
3
+ export type { QueryInfo } from "./types";
package/dist/index.js CHANGED
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT license.
4
+ var __importDefault = (this && this.__importDefault) || function (mod) {
5
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6
+ };
4
7
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.QueryInfo = exports.WorkbookManager = void 0;
8
+ exports.DataTypes = exports.workbookManager = void 0;
6
9
  var workbookManager_1 = require("./workbookManager");
7
- Object.defineProperty(exports, "WorkbookManager", { enumerable: true, get: function () { return workbookManager_1.WorkbookManager; } });
8
- Object.defineProperty(exports, "QueryInfo", { enumerable: true, get: function () { return workbookManager_1.QueryInfo; } });
9
- //# sourceMappingURL=index.js.map
10
+ Object.defineProperty(exports, "workbookManager", { enumerable: true, get: function () { return __importDefault(workbookManager_1).default; } });
11
+ var types_1 = require("./types");
12
+ Object.defineProperty(exports, "DataTypes", { enumerable: true, get: function () { return types_1.DataTypes; } });
@@ -1,4 +1,7 @@
1
- export default class MashupHandler {
2
- ReplaceSingleQuery(base64str: string, query: string): Promise<string>;
3
- private editSingleQueryPackage;
4
- }
1
+ export default class MashupHandler {
2
+ ReplaceSingleQuery(base64Str: string, queryName: string, queryMashupDoc: string): Promise<string>;
3
+ private getPackageComponents;
4
+ private editSingleQueryPackage;
5
+ private setSection1m;
6
+ private editSingleQueryMetadata;
7
+ }