@adobe/helix-onedrive-support 8.2.3 → 8.2.4
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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/OneDriveMock.js +27 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [8.2.4](https://github.com/adobe/helix-onedrive-support/compare/v8.2.3...v8.2.4) (2022-08-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* add proper table in mock's addTable ([#292](https://github.com/adobe/helix-onedrive-support/issues/292)) ([6c470ef](https://github.com/adobe/helix-onedrive-support/commit/6c470efa4e923440458e9459aab2e1c57346ba06))
|
|
7
|
+
|
|
1
8
|
## [8.2.3](https://github.com/adobe/helix-onedrive-support/compare/v8.2.2...v8.2.3) (2022-08-07)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/OneDriveMock.js
CHANGED
|
@@ -53,24 +53,44 @@ function handleNamedItems(sheet, segs, method, body) {
|
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Handle the `table` operation on a workbook / worksheet
|
|
56
|
-
* @param {object}
|
|
56
|
+
* @param {object} container The mock data
|
|
57
57
|
* @param {string[]} segs Array of path segments
|
|
58
58
|
* @param {string} method Request method
|
|
59
59
|
* @param {object} body Request body
|
|
60
60
|
* @returns {object} The response value
|
|
61
61
|
*/
|
|
62
|
-
function handleTable(
|
|
62
|
+
function handleTable(container, segs, method, body) {
|
|
63
63
|
const first = segs.shift();
|
|
64
64
|
if (!first) {
|
|
65
|
-
return { value:
|
|
65
|
+
return { value: container.tables.map((table) => ({ name: table.name })) };
|
|
66
66
|
}
|
|
67
67
|
if (first === 'add') {
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
let sheet = container;
|
|
69
|
+
|
|
70
|
+
const { address } = body;
|
|
71
|
+
const sep = address.indexOf('!');
|
|
72
|
+
if (sep !== -1) {
|
|
73
|
+
sheet = container.sheets.find((s) => s.name === address.substring(0, sep));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const { values } = sheet.usedRange;
|
|
77
|
+
const headerNames = [];
|
|
78
|
+
const rows = [];
|
|
79
|
+
|
|
80
|
+
if (body.hasHeaders) {
|
|
81
|
+
headerNames.push(...values[0]);
|
|
82
|
+
rows.push(...values.slice(1));
|
|
83
|
+
} else {
|
|
84
|
+
rows.push(...values);
|
|
85
|
+
}
|
|
86
|
+
const len = container.tables.push({
|
|
87
|
+
name: `Table${container.tables.length + 1}`,
|
|
88
|
+
headerNames,
|
|
89
|
+
rows,
|
|
70
90
|
});
|
|
71
|
-
return
|
|
91
|
+
return container.tables[len - 1];
|
|
72
92
|
}
|
|
73
|
-
const table =
|
|
93
|
+
const table = container.tables.find((t) => t.name === first);
|
|
74
94
|
if (!table) {
|
|
75
95
|
throw new StatusCodeError(first, 404);
|
|
76
96
|
}
|