@adobe/helix-onedrive-support 11.5.28 → 12.0.0
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 +19 -0
- package/package.json +4 -4
- package/src/OneDrive.js +2 -1
- package/src/index.d.ts +0 -1
- package/src/index.js +0 -1
- package/src/utils.js +0 -98
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# [12.0.0](https://github.com/adobe/helix-onedrive-support/compare/v11.5.29...v12.0.0) (2024-12-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* use string functions in @adobe/helix-shared-string ([629fa1d](https://github.com/adobe/helix-onedrive-support/commit/629fa1d4226f7430d56258785b51b3f6b9c2edc6))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* no longer export StatusCodeError
|
|
12
|
+
|
|
13
|
+
## [11.5.29](https://github.com/adobe/helix-onedrive-support/compare/v11.5.28...v11.5.29) (2024-12-05)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **deps:** update dependency @adobe/fetch to v4.1.10 ([#611](https://github.com/adobe/helix-onedrive-support/issues/611)) ([b0bd3c1](https://github.com/adobe/helix-onedrive-support/commit/b0bd3c1f5f8c698593166f42a6a1a2089d1c0066))
|
|
19
|
+
|
|
1
20
|
## [11.5.28](https://github.com/adobe/helix-onedrive-support/compare/v11.5.27...v11.5.28) (2024-12-03)
|
|
2
21
|
|
|
3
22
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-onedrive-support",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0",
|
|
4
4
|
"description": "Helix OneDrive Support",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"exports": {
|
|
7
|
-
".": "./src/index.js"
|
|
8
|
-
"./utils": "./src/utils.js"
|
|
7
|
+
".": "./src/index.js"
|
|
9
8
|
},
|
|
10
9
|
"type": "module",
|
|
11
10
|
"types": "src/index.d.ts",
|
|
@@ -28,7 +27,8 @@
|
|
|
28
27
|
},
|
|
29
28
|
"homepage": "https://github.com/adobe/helix-onedrive-support#readme",
|
|
30
29
|
"dependencies": {
|
|
31
|
-
"@adobe/fetch": "4.1.
|
|
30
|
+
"@adobe/fetch": "^4.1.10",
|
|
31
|
+
"@adobe/helix-shared-string": "2.1.0",
|
|
32
32
|
"@adobe/helix-shared-tokencache": "^1.4.19",
|
|
33
33
|
"@azure/msal-node": "2.16.2",
|
|
34
34
|
"jose": "5.9.6"
|
package/src/OneDrive.js
CHANGED
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
|
|
13
13
|
// eslint-disable-next-line max-classes-per-file
|
|
14
14
|
import { keepAliveNoCache } from '@adobe/fetch';
|
|
15
|
+
import { editDistance, sanitizeName, splitByExtension } from '@adobe/helix-shared-string';
|
|
16
|
+
|
|
15
17
|
import { Workbook } from './excel/Workbook.js';
|
|
16
18
|
import { StatusCodeError } from './StatusCodeError.js';
|
|
17
|
-
import { editDistance, sanitizeName, splitByExtension } from './utils.js';
|
|
18
19
|
import { SharePointSite } from './SharePointSite.js';
|
|
19
20
|
import { RateLimit } from './RateLimit.js';
|
|
20
21
|
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -13,7 +13,6 @@ export { OneDrive } from './OneDrive.js';
|
|
|
13
13
|
export { OneDriveAuth, AcquireMethod } from './OneDriveAuth.js';
|
|
14
14
|
|
|
15
15
|
export { OneDriveMock } from './OneDriveMock.js';
|
|
16
|
-
export { StatusCodeError } from './StatusCodeError.js';
|
|
17
16
|
|
|
18
17
|
export { NamedItemContainer } from './excel/NamedItemContainer.js';
|
|
19
18
|
export { Range } from './excel/Range.js';
|
package/src/utils.js
CHANGED
|
@@ -10,104 +10,6 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* Splits the given name at the last '.', returning the extension and the base name.
|
|
15
|
-
* @param {string} name Filename
|
|
16
|
-
* @returns {string[]} Returns an array containing the base name and extension.
|
|
17
|
-
*/
|
|
18
|
-
export function splitByExtension(name) {
|
|
19
|
-
const idx = name.lastIndexOf('.');
|
|
20
|
-
const baseName = idx > 0 && idx < name.length - 1 ? name.substring(0, idx) : name;
|
|
21
|
-
const ext = idx > 0 && idx < name.length - 1 ? name.substring(idx + 1).toLowerCase() : '';
|
|
22
|
-
return [baseName, ext];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Sanitizes the given string by :
|
|
27
|
-
* - convert to lower case
|
|
28
|
-
* - normalize all unicode characters
|
|
29
|
-
* - replace all non-alphanumeric characters with a dash
|
|
30
|
-
* - remove all consecutive dashes
|
|
31
|
-
* - remove all leading and trailing dashes
|
|
32
|
-
*
|
|
33
|
-
* @param {string} name
|
|
34
|
-
* @returns {string} sanitized name
|
|
35
|
-
*/
|
|
36
|
-
export function sanitizeName(name) {
|
|
37
|
-
return name
|
|
38
|
-
.toLowerCase()
|
|
39
|
-
.normalize('NFD')
|
|
40
|
-
.replace(/[\u0300-\u036f]/g, '')
|
|
41
|
-
.replace(/[^a-z0-9]+/g, '-')
|
|
42
|
-
.replace(/^-|-$/g, '');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Sanitizes the file path by:
|
|
47
|
-
* - convert to lower case
|
|
48
|
-
* - normalize all unicode characters
|
|
49
|
-
* - replace all non-alphanumeric characters with a dash
|
|
50
|
-
* - remove all consecutive dashes
|
|
51
|
-
* - remove all leading and trailing dashes
|
|
52
|
-
*
|
|
53
|
-
* Note that only the basename of the file path is sanitized. i.e. The ancestor path and the
|
|
54
|
-
* extension is not affected.
|
|
55
|
-
*
|
|
56
|
-
* @param {string} filepath the file path
|
|
57
|
-
* @param {object} opts Options
|
|
58
|
-
* @param {boolean} [opts.ignoreExtension] if {@code true} ignores the extension
|
|
59
|
-
* @returns {string} sanitized file path
|
|
60
|
-
*/
|
|
61
|
-
export function sanitizePath(filepath, opts = {}) {
|
|
62
|
-
const idx = filepath.lastIndexOf('/') + 1;
|
|
63
|
-
const extIdx = opts.ignoreExtension ? -1 : filepath.lastIndexOf('.');
|
|
64
|
-
const pfx = filepath.substring(0, idx);
|
|
65
|
-
const basename = extIdx < idx ? filepath.substring(idx) : filepath.substring(idx, extIdx);
|
|
66
|
-
const ext = extIdx < idx ? '' : filepath.substring(extIdx);
|
|
67
|
-
const name = sanitizeName(basename);
|
|
68
|
-
return `${pfx}${name}${ext}`;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Compute the edit distance using a recursive algorithm. since we only expect to have relative
|
|
73
|
-
* short filenames, the algorithm shouldn't be too expensive.
|
|
74
|
-
*
|
|
75
|
-
* @param {string} s0 Input string
|
|
76
|
-
* @param {string} s1 Input string
|
|
77
|
-
* @returns {number|*}
|
|
78
|
-
*/
|
|
79
|
-
export function editDistance(s0, s1) {
|
|
80
|
-
// make sure that s0 length is greater than s1 length
|
|
81
|
-
if (s0.length < s1.length) {
|
|
82
|
-
const t = s1;
|
|
83
|
-
// eslint-disable-next-line no-param-reassign
|
|
84
|
-
s1 = s0;
|
|
85
|
-
// eslint-disable-next-line no-param-reassign
|
|
86
|
-
s0 = t;
|
|
87
|
-
}
|
|
88
|
-
const l0 = s0.length;
|
|
89
|
-
const l1 = s1.length;
|
|
90
|
-
|
|
91
|
-
// init first row
|
|
92
|
-
const resultMatrix = [[]];
|
|
93
|
-
for (let c = 0; c < l1 + 1; c += 1) {
|
|
94
|
-
resultMatrix[0][c] = c;
|
|
95
|
-
}
|
|
96
|
-
// fill out the distance matrix and find the best path
|
|
97
|
-
for (let i = 1; i < l0 + 1; i += 1) {
|
|
98
|
-
resultMatrix[i] = [i];
|
|
99
|
-
for (let j = 1; j < l1 + 1; j += 1) {
|
|
100
|
-
const replaceCost = (s0.charAt(i - 1) === s1.charAt(j - 1)) ? 0 : 1;
|
|
101
|
-
resultMatrix[i][j] = Math.min(
|
|
102
|
-
resultMatrix[i - 1][j] + 1, // insert
|
|
103
|
-
resultMatrix[i][j - 1] + 1, // remove
|
|
104
|
-
resultMatrix[i - 1][j - 1] + replaceCost,
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return resultMatrix[l0][l1];
|
|
109
|
-
}
|
|
110
|
-
|
|
111
13
|
/**
|
|
112
14
|
* Trims the string at both ends and removes the zero width unicode chars:
|
|
113
15
|
*
|