@microsoft/connected-workbooks 2.1.16-beta → 2.1.25
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 +83 -15
- package/dist/generators.js +1 -1
- package/dist/gridParser.js +58 -0
- package/dist/gridUtils.js +58 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.js +26 -6
- package/dist/src/generators.js +14 -0
- package/dist/src/types.js +28 -0
- package/dist/src/utils/arrayUtils.js +46 -0
- package/dist/{constants.js → src/utils/constants.js} +139 -131
- package/dist/src/utils/documentUtils.js +102 -0
- package/dist/src/utils/gridUtils.js +103 -0
- package/dist/src/utils/htmlUtils.js +19 -0
- package/dist/src/utils/index.js +24 -0
- package/dist/src/utils/mashupDocumentParser.js +145 -0
- package/dist/src/utils/pqUtils.js +100 -0
- package/dist/src/utils/tableUtils.js +143 -0
- package/dist/src/utils/xmlInnerPartsUtils.js +200 -0
- package/dist/src/utils/xmlPartsUtils.js +64 -0
- package/dist/src/workbookTemplate.js +7 -0
- package/dist/tests/arrayUtils.test.js +65 -0
- package/dist/tests/documentUtils.test.js +35 -0
- package/dist/tests/gridUtils.test.js +168 -0
- package/dist/tests/htmlUtils.test.js +109 -0
- package/dist/tests/mashupDocumentParser.test.js +59 -0
- package/dist/tests/mocks/PqMock.js +7 -0
- package/dist/tests/mocks/index.js +24 -0
- package/dist/tests/mocks/section1mSimpleQueryMock.js +18 -0
- package/dist/tests/mocks/xmlMocks.js +12 -0
- package/dist/tests/tableUtils.test.js +63 -0
- package/dist/tests/workbookQueryTemplate.test.js +64 -0
- package/dist/tests/workbookTableTemplate.test.js +54 -0
- package/dist/tests/xmlInnerPartsUtils.test.js +51 -0
- package/dist/types.d.ts +10 -11
- package/dist/types.js +0 -1
- package/dist/utils/constants.js +15 -5
- package/dist/utils/documentUtils.js +10 -9
- package/dist/utils/gridUtils.js +103 -0
- package/dist/utils/htmlUtils.js +5 -11
- package/dist/utils/index.js +5 -1
- package/dist/utils/mashupDocumentParser.js +102 -123
- package/dist/utils/pqUtils.js +9 -10
- package/dist/utils/tableUtils.js +31 -34
- package/dist/utils/xmlInnerPartsUtils.js +11 -9
- package/dist/utils/xmlPartsUtils.js +7 -5
- package/dist/workbookManager.d.ts +5 -8
- package/dist/workbookManager.js +17 -31
- package/dist/workbookTemplate.js +3 -5
- package/package.json +22 -7
- package/dist/GridParser.d.ts +0 -6
- package/dist/GridParser.js +0 -55
- package/dist/TableDataParserFactory.d.ts +0 -4
- package/dist/TableDataParserFactory.js +0 -15
- package/dist/constants.d.ts +0 -121
- package/dist/generators.d.ts +0 -3
- package/dist/mashupDocumentParser.d.ts +0 -7
- package/dist/mashupDocumentParser.js +0 -169
- package/dist/utils/arrayUtils.d.ts +0 -16
- package/dist/utils/constants.d.ts +0 -121
- package/dist/utils/documentUtils.d.ts +0 -15
- package/dist/utils/htmlUtils.d.ts +0 -1
- package/dist/utils/index.d.ts +0 -6
- package/dist/utils/mashupDocumentParser.d.ts +0 -7
- package/dist/utils/pqUtils.d.ts +0 -15
- package/dist/utils/tableUtils.d.ts +0 -10
- package/dist/utils/xmlInnerPartsUtils.d.ts +0 -24
- package/dist/utils/xmlPartsUtils.d.ts +0 -8
- package/dist/workbookTemplate.d.ts +0 -4
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# Connected Workbooks
|
|
2
2
|
[](https://obilshield.visualstudio.com/ConnectedWorkbooks/_build/latest?definitionId=14&branchName=main)
|
|
3
3
|
[](https://github.com/microsoft/connected-workbooks/blob/master/LICENSE)
|
|
4
|
-
[](https://snyk.io/test/github/microsoft/connected-workbooks)
|
|
5
4
|
|
|
6
5
|
A pure JS library, Microsoft backed, that provides xlsx workbook generation capabilities, allowing for:
|
|
7
6
|
1. Fundemental **"Export to Excel"** capabilities for tabular data (landing in a table in Excel).
|
|
@@ -24,24 +23,20 @@ Connected Workbooks allows you to avoid "data dumps" in CSV form, providing a ri
|
|
|
24
23
|
|
|
25
24
|
### 1. Export a table directly from an Html page:
|
|
26
25
|
```typescript
|
|
27
|
-
import
|
|
26
|
+
import workbookManager from '@microsoft/connected-workbooks';
|
|
28
27
|
|
|
29
28
|
const blob = await workbookManager.generateTableWorkbookFromHtml(document.querySelector('table') as HTMLTableElement);
|
|
30
29
|
workbookManager.downloadWorkbook(blob, "MyTable.xlsx");
|
|
31
30
|
```
|
|
31
|
+
|
|
32
32
|
### 2. Export a table from raw data:
|
|
33
33
|
```typescript
|
|
34
|
-
import
|
|
34
|
+
import workbookManager from '@microsoft/connected-workbooks';
|
|
35
35
|
|
|
36
36
|
const grid = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
{ "name": "InStock", "type": DataTypes.autodetect },
|
|
41
|
-
{ "name": "Category", "type": DataTypes.autodetect },
|
|
42
|
-
{ "name": "Date", "type": DataTypes.autodetect }
|
|
43
|
-
],
|
|
44
|
-
"gridData": [
|
|
37
|
+
config: { promoteHeaders:true, adjustColumnNames:true }
|
|
38
|
+
data: [
|
|
39
|
+
["Product", "Price", "InStock", "Category", "Date"],
|
|
45
40
|
["Widget A", 19.99, true, "Electronics", "10/26/2024"],
|
|
46
41
|
["Gizmo B", 9.99, true, "Accessories", "10/26/2024"],
|
|
47
42
|
["Bubala", 14.99, false, "Accessories", "10/22/2023"],
|
|
@@ -60,13 +55,13 @@ workbookManager.downloadWorkbook(blob, "MyTable.xlsx");
|
|
|
60
55
|
document.querySelector('table') as HTMLTableElement,
|
|
61
56
|
{createdBy: 'John Doe', lastModifiedBy: 'Jane Doe', description: 'This is a sample table'});
|
|
62
57
|
|
|
63
|
-
|
|
58
|
+
workbookManager.downloadWorkbook(blob, "MyTable.xlsx");
|
|
64
59
|
```
|
|
65
60
|

|
|
66
61
|
|
|
67
62
|
### 4. Export a Power Query connected workbook:
|
|
68
63
|
```typescript
|
|
69
|
-
import
|
|
64
|
+
import workbookManager from '@microsoft/connected-workbooks';
|
|
70
65
|
|
|
71
66
|
const blob = await workbookManager.generateSingleQueryWorkbook({
|
|
72
67
|
queryMashup: 'let \
|
|
@@ -75,9 +70,9 @@ const blob = await workbookManager.generateSingleQueryWorkbook({
|
|
|
75
70
|
Source',
|
|
76
71
|
refreshOnOpen: true});
|
|
77
72
|
workbookManager.downloadWorkbook(blob, "MyConnectedWorkbook.xlsx");
|
|
78
|
-
});
|
|
79
73
|
```
|
|
80
74
|

|
|
75
|
+
|
|
81
76
|
(after refreshing on open)
|
|
82
77
|
### Advanced Usage - bring your own template:
|
|
83
78
|
|
|
@@ -86,7 +81,7 @@ You can use the library with your own workbook as a template!
|
|
|
86
81
|
```typescript
|
|
87
82
|
const blob = await workbookManager.generateSingleQueryWorkbook(
|
|
88
83
|
{ queryMashup: query, refreshOnOpen: true },
|
|
89
|
-
undefined /* optional
|
|
84
|
+
undefined /* optional Grid */,
|
|
90
85
|
templateFile);
|
|
91
86
|
workbookManager.downloadWorkbook(blob, "MyBrandedWorkbook.xlsx");
|
|
92
87
|
```
|
|
@@ -109,6 +104,79 @@ const [templateFile, setTemplateFile] = useState<File | null>(null);
|
|
|
109
104
|
setTemplateFile(e!.target!.files!.item(0));
|
|
110
105
|
}}/>
|
|
111
106
|
```
|
|
107
|
+
### API
|
|
108
|
+
The library exposes a workbookManager, which generates a workbook via several APIs:
|
|
109
|
+
|
|
110
|
+
#### 1. Generate a Power Query connected workbook
|
|
111
|
+
```typescript
|
|
112
|
+
async function `generateSingleQueryWorkbook`: `Promise<Blob>`
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
|Parameter | Type | Required | Description |
|
|
116
|
+
|--- |--- |--- |--- |
|
|
117
|
+
|query | [QueryInfo](#queryinfo) | __required__ | Power Query mashup |
|
|
118
|
+
| grid | [Grid](#grid) | optional | Initial grid data |
|
|
119
|
+
| fileConfigs | [FileConfigs](#fileconfigs) | optional | Custom file configurations |
|
|
120
|
+
|
|
121
|
+
#### 2. Generate a table workbook from a Html page
|
|
122
|
+
```typescript
|
|
123
|
+
async function `generateTableWorkbookFromHtml`: `Promise<Blob>`
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
|Parameter | Type | Required | Description |
|
|
127
|
+
|--- |--- |--- |--- |
|
|
128
|
+
| htmlTable | HTMLTableElement | __required__ | Initial data loaded to workbook |
|
|
129
|
+
| docProps | [DocProps](#docprops) | optional | Custom workbook properties |
|
|
130
|
+
|
|
131
|
+
#### 3. Generate a table workbook with raw data
|
|
132
|
+
```typescript
|
|
133
|
+
async function `generateTableWorkbookFromGrid`: `Promise<Blob>`
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
|Parameter | Type | Required | Description |
|
|
137
|
+
|--- |--- |--- |--- |
|
|
138
|
+
| grid | [Grid](#grid) | __required__ | Initial data loaded to workbook |
|
|
139
|
+
| docProps | [DocProps](#docprops) | optional | Custom workbook properties |
|
|
140
|
+
</br>
|
|
141
|
+
|
|
142
|
+
### Types
|
|
143
|
+
|
|
144
|
+
#### QueryInfo
|
|
145
|
+
|Parameter | Type | Required | Description |
|
|
146
|
+
|---|---|---|---|
|
|
147
|
+
| queryMashup | string | __required__ | Mashup string
|
|
148
|
+
| refreshOnOpen | boolean | __required__ | Should workbook data refresh upon open
|
|
149
|
+
| queryName | string | optional | Query name, defaults to "Query1"
|
|
150
|
+
|
|
151
|
+
#### Grid
|
|
152
|
+
|Parameter | Type | Required | Description |
|
|
153
|
+
|---|---|---|---|
|
|
154
|
+
| data | (string \| number \| boolean)[][] | __required__ | Grid data
|
|
155
|
+
| config | GridConfig | optional | customizations to Grid handling (see GridConfig)
|
|
156
|
+
|
|
157
|
+
#### GridConfig
|
|
158
|
+
|Parameter | Type | Required | Description |
|
|
159
|
+
|---|---|---|---|
|
|
160
|
+
| promoteHeaders | boolean | optional | Should first row of gridData be used as the header, defaults to false - generating "Column1", "Column2"...
|
|
161
|
+
| adjustColumnNames | boolean | optional | Should column names be adjusted to be valid Excel names (Fix duplicates for example), defaults to true
|
|
162
|
+
|
|
163
|
+
#### FileConfigs
|
|
164
|
+
|Parameter | Type | Required | Description |
|
|
165
|
+
|---|---|---|---|
|
|
166
|
+
| templateFile | File | optional | Custom Excel workbook |
|
|
167
|
+
| docProps | [DocProps](#docprops) | optional | Custom workbook properties |
|
|
168
|
+
|
|
169
|
+
#### DocProps
|
|
170
|
+
|Parameter | Type | Required
|
|
171
|
+
|---|---|---|
|
|
172
|
+
| title | string | optional
|
|
173
|
+
| subject | string | optional
|
|
174
|
+
| keywords | string | optional
|
|
175
|
+
| createdBy | string | optional
|
|
176
|
+
| description | string | optional
|
|
177
|
+
| lastModifiedBy | string | optional
|
|
178
|
+
| category | string | optional
|
|
179
|
+
| revision | number | optional
|
|
112
180
|
|
|
113
181
|
## Contributing
|
|
114
182
|
|
package/dist/generators.js
CHANGED
|
@@ -7,7 +7,7 @@ const generateMashupXMLTemplate = (base64) => `<?xml version="1.0" encoding="utf
|
|
|
7
7
|
exports.generateMashupXMLTemplate = generateMashupXMLTemplate;
|
|
8
8
|
const generateSingleQueryMashup = (queryName, query) => `section Section1;
|
|
9
9
|
|
|
10
|
-
shared ${queryName} =
|
|
10
|
+
shared #"${queryName}" =
|
|
11
11
|
${query};`;
|
|
12
12
|
exports.generateSingleQueryMashup = generateSingleQueryMashup;
|
|
13
13
|
const generateCustomXmlFilePath = (i) => `customXml/item${i}.xml`;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.parseToTableData = void 0;
|
|
6
|
+
const constants_1 = require("./utils/constants");
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
const parseToTableData = (grid) => {
|
|
9
|
+
if (!grid) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
const columnNames = generateColumnNames(grid);
|
|
13
|
+
const rows = parseGridRows(grid);
|
|
14
|
+
return { columnNames: columnNames, rows: rows };
|
|
15
|
+
};
|
|
16
|
+
exports.parseToTableData = parseToTableData;
|
|
17
|
+
const parseGridRows = (grid) => {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
const gridData = grid.data;
|
|
20
|
+
if (!gridData) {
|
|
21
|
+
throw new Error(constants_1.gridNotFoundErr);
|
|
22
|
+
}
|
|
23
|
+
const rows = [];
|
|
24
|
+
if (!((_a = grid.config) === null || _a === void 0 ? void 0 : _a.promoteHeaders)) {
|
|
25
|
+
const row = [];
|
|
26
|
+
for (const prop in gridData[0]) {
|
|
27
|
+
const cellValue = gridData[0][prop];
|
|
28
|
+
row.push(cellValue.toString());
|
|
29
|
+
}
|
|
30
|
+
rows.push(row);
|
|
31
|
+
}
|
|
32
|
+
for (let i = 1; i < gridData.length; i++) {
|
|
33
|
+
const rowData = gridData[i];
|
|
34
|
+
const row = [];
|
|
35
|
+
for (const prop in rowData) {
|
|
36
|
+
const cellValue = rowData[prop];
|
|
37
|
+
row.push((_b = cellValue === null || cellValue === void 0 ? void 0 : cellValue.toString()) !== null && _b !== void 0 ? _b : "");
|
|
38
|
+
}
|
|
39
|
+
rows.push(row);
|
|
40
|
+
}
|
|
41
|
+
return rows;
|
|
42
|
+
};
|
|
43
|
+
const generateColumnNames = (grid) => {
|
|
44
|
+
var _a;
|
|
45
|
+
const columnNames = [];
|
|
46
|
+
if (!((_a = grid.config) === null || _a === void 0 ? void 0 : _a.promoteHeaders)) {
|
|
47
|
+
for (let i = 0; i < grid.data[0].length; i++) {
|
|
48
|
+
columnNames.push(`${constants_1.defaults.columnName} ${i + 1}`);
|
|
49
|
+
}
|
|
50
|
+
return columnNames;
|
|
51
|
+
}
|
|
52
|
+
// We are adjusting column names by default.
|
|
53
|
+
if (!grid.config || grid.config.adjustColumnNames === undefined || grid.config.adjustColumnNames) {
|
|
54
|
+
return utils_1.tableUtils.getAdjustedColumnNames(grid.data[0]);
|
|
55
|
+
}
|
|
56
|
+
// Get column names and failed if it's not a legal name.
|
|
57
|
+
return utils_1.tableUtils.getRawColumnNames(grid.data[0]);
|
|
58
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.parseToTableData = void 0;
|
|
6
|
+
const constants_1 = require("./utils/constants");
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
const parseToTableData = (grid) => {
|
|
9
|
+
if (!grid) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
const columnNames = generateColumnNames(grid);
|
|
13
|
+
const rows = parseGridRows(grid);
|
|
14
|
+
return { columnNames: columnNames, rows: rows };
|
|
15
|
+
};
|
|
16
|
+
exports.parseToTableData = parseToTableData;
|
|
17
|
+
const parseGridRows = (grid) => {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
const gridData = grid.data;
|
|
20
|
+
if (!gridData) {
|
|
21
|
+
throw new Error(constants_1.gridNotFoundErr);
|
|
22
|
+
}
|
|
23
|
+
const rows = [];
|
|
24
|
+
if (!((_a = grid.config) === null || _a === void 0 ? void 0 : _a.promoteHeaders)) {
|
|
25
|
+
const row = [];
|
|
26
|
+
for (const prop in gridData[0]) {
|
|
27
|
+
const cellValue = gridData[0][prop];
|
|
28
|
+
row.push(cellValue.toString());
|
|
29
|
+
}
|
|
30
|
+
rows.push(row);
|
|
31
|
+
}
|
|
32
|
+
for (let i = 1; i < gridData.length; i++) {
|
|
33
|
+
const rowData = gridData[i];
|
|
34
|
+
const row = [];
|
|
35
|
+
for (const prop in rowData) {
|
|
36
|
+
const cellValue = rowData[prop];
|
|
37
|
+
row.push((_b = cellValue === null || cellValue === void 0 ? void 0 : cellValue.toString()) !== null && _b !== void 0 ? _b : "");
|
|
38
|
+
}
|
|
39
|
+
rows.push(row);
|
|
40
|
+
}
|
|
41
|
+
return rows;
|
|
42
|
+
};
|
|
43
|
+
const generateColumnNames = (grid) => {
|
|
44
|
+
var _a;
|
|
45
|
+
const columnNames = [];
|
|
46
|
+
if (!((_a = grid.config) === null || _a === void 0 ? void 0 : _a.promoteHeaders)) {
|
|
47
|
+
for (let i = 0; i < grid.data[0].length; i++) {
|
|
48
|
+
columnNames.push(`${constants_1.defaults.columnName} ${i + 1}`);
|
|
49
|
+
}
|
|
50
|
+
return columnNames;
|
|
51
|
+
}
|
|
52
|
+
// We are adjusting column names by default.
|
|
53
|
+
if (!grid.config || grid.config.adjustColumnNames === undefined || grid.config.adjustColumnNames) {
|
|
54
|
+
return utils_1.tableUtils.getAdjustedColumnNames(grid.data[0]);
|
|
55
|
+
}
|
|
56
|
+
// Get column names and failed if it's not a legal name.
|
|
57
|
+
return utils_1.tableUtils.getRawColumnNames(grid.data[0]);
|
|
58
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import * as workbookManager from "./workbookManager";
|
|
2
|
+
import { DataTypes } from "./types";
|
|
3
|
+
import type { QueryInfo, FileConfigs, Grid, DocProps } from "./types";
|
|
4
|
+
export { DataTypes };
|
|
5
|
+
export type { QueryInfo, FileConfigs, Grid, DocProps };
|
|
6
|
+
export default workbookManager;
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) Microsoft Corporation.
|
|
3
3
|
// Licensed under the MIT license.
|
|
4
|
-
var
|
|
5
|
-
|
|
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;
|
|
6
26
|
};
|
|
7
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.DataTypes =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var types_1 = require("./types");
|
|
28
|
+
exports.DataTypes = void 0;
|
|
29
|
+
const workbookManager = __importStar(require("./workbookManager"));
|
|
30
|
+
const types_1 = require("./types");
|
|
12
31
|
Object.defineProperty(exports, "DataTypes", { enumerable: true, get: function () { return types_1.DataTypes; } });
|
|
32
|
+
exports.default = workbookManager;
|
|
@@ -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;
|
|
@@ -0,0 +1,28 @@
|
|
|
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["null"] = 0] = "null";
|
|
9
|
+
DataTypes[DataTypes["string"] = 1] = "string";
|
|
10
|
+
DataTypes[DataTypes["number"] = 2] = "number";
|
|
11
|
+
DataTypes[DataTypes["boolean"] = 3] = "boolean";
|
|
12
|
+
})(DataTypes = exports.DataTypes || (exports.DataTypes = {}));
|
|
13
|
+
var DocPropsModifiableElements;
|
|
14
|
+
(function (DocPropsModifiableElements) {
|
|
15
|
+
DocPropsModifiableElements["title"] = "dc:title";
|
|
16
|
+
DocPropsModifiableElements["subject"] = "dc:subject";
|
|
17
|
+
DocPropsModifiableElements["keywords"] = "cp:keywords";
|
|
18
|
+
DocPropsModifiableElements["createdBy"] = "dc:creator";
|
|
19
|
+
DocPropsModifiableElements["description"] = "dc:description";
|
|
20
|
+
DocPropsModifiableElements["lastModifiedBy"] = "cp:lastModifiedBy";
|
|
21
|
+
DocPropsModifiableElements["category"] = "cp:category";
|
|
22
|
+
DocPropsModifiableElements["revision"] = "cp:revision";
|
|
23
|
+
})(DocPropsModifiableElements = exports.DocPropsModifiableElements || (exports.DocPropsModifiableElements = {}));
|
|
24
|
+
var DocPropsAutoUpdatedElements;
|
|
25
|
+
(function (DocPropsAutoUpdatedElements) {
|
|
26
|
+
DocPropsAutoUpdatedElements["created"] = "dcterms:created";
|
|
27
|
+
DocPropsAutoUpdatedElements["modified"] = "dcterms:modified";
|
|
28
|
+
})(DocPropsAutoUpdatedElements = exports.DocPropsAutoUpdatedElements || (exports.DocPropsAutoUpdatedElements = {}));
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.ArrayReader = void 0;
|
|
6
|
+
class ArrayReader {
|
|
7
|
+
constructor(array) {
|
|
8
|
+
this._array = array;
|
|
9
|
+
this._position = 0;
|
|
10
|
+
}
|
|
11
|
+
getInt32() {
|
|
12
|
+
const retVal = new DataView(this._array, this._position, 4).getInt32(0, true);
|
|
13
|
+
this._position += 4;
|
|
14
|
+
return retVal;
|
|
15
|
+
}
|
|
16
|
+
getBytes(bytes) {
|
|
17
|
+
const retVal = this._array.slice(this._position, bytes ? bytes + this._position : bytes);
|
|
18
|
+
this._position += retVal.byteLength;
|
|
19
|
+
return new Uint8Array(retVal);
|
|
20
|
+
}
|
|
21
|
+
reset() {
|
|
22
|
+
this._position = 0;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.ArrayReader = ArrayReader;
|
|
26
|
+
function getInt32Buffer(val) {
|
|
27
|
+
const packageSizeBuffer = new ArrayBuffer(4);
|
|
28
|
+
new DataView(packageSizeBuffer).setInt32(0, val, true);
|
|
29
|
+
return new Uint8Array(packageSizeBuffer);
|
|
30
|
+
}
|
|
31
|
+
function concatArrays(...args) {
|
|
32
|
+
let size = 0;
|
|
33
|
+
args.forEach((arr) => (size += arr.byteLength));
|
|
34
|
+
const retVal = new Uint8Array(size);
|
|
35
|
+
let position = 0;
|
|
36
|
+
args.forEach((arr) => {
|
|
37
|
+
retVal.set(arr, position);
|
|
38
|
+
position += arr.byteLength;
|
|
39
|
+
});
|
|
40
|
+
return retVal;
|
|
41
|
+
}
|
|
42
|
+
exports.default = {
|
|
43
|
+
ArrayReader,
|
|
44
|
+
getInt32Buffer,
|
|
45
|
+
concatArrays,
|
|
46
|
+
};
|