@adobe/helix-onedrive-support 7.0.1 → 7.1.2
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 +21 -0
- package/package.json +5 -5
- package/src/OneDrive.d.ts +3 -2
- package/src/OneDrive.js +27 -10
- package/src/OneDriveMock.js +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## [7.1.2](https://github.com/adobe/helix-onedrive-support/compare/v7.1.1...v7.1.2) (2022-04-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency @adobe/helix-fetch to v3.0.9 ([#262](https://github.com/adobe/helix-onedrive-support/issues/262)) ([62cca57](https://github.com/adobe/helix-onedrive-support/commit/62cca577cf8288b673b38f0f778961efd45f1772))
|
|
7
|
+
|
|
8
|
+
## [7.1.1](https://github.com/adobe/helix-onedrive-support/compare/v7.1.0...v7.1.1) (2022-04-02)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **deps:** update dependency @adobe/helix-fetch to v3.0.8 ([0035641](https://github.com/adobe/helix-onedrive-support/commit/0035641545b9c4a0deef5de7f3e1bab0f961b0ff))
|
|
14
|
+
|
|
15
|
+
# [7.1.0](https://github.com/adobe/helix-onedrive-support/compare/v7.0.1...v7.1.0) (2022-04-01)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* speed up fuzzyItem lookup ([#259](https://github.com/adobe/helix-onedrive-support/issues/259)) ([5963fa6](https://github.com/adobe/helix-onedrive-support/commit/5963fa6389329d0cf737f64724688593b9291923)), closes [#258](https://github.com/adobe/helix-onedrive-support/issues/258)
|
|
21
|
+
|
|
1
22
|
## [7.0.1](https://github.com/adobe/helix-onedrive-support/compare/v7.0.0...v7.0.1) (2022-03-23)
|
|
2
23
|
|
|
3
24
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-onedrive-support",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.1.2",
|
|
4
4
|
"description": "Helix OneDrive Support",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/adobe/helix-onedrive-support#readme",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@adobe/helix-fetch": "3.0.
|
|
26
|
+
"@adobe/helix-fetch": "3.0.9",
|
|
27
27
|
"adal-node": "https://github.com/adobe-rnd/azure-activedirectory-library-for-nodejs.git#adobe",
|
|
28
28
|
"jose": "4.6.0"
|
|
29
29
|
},
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
"@adobe/eslint-config-helix": "1.3.2",
|
|
32
32
|
"@semantic-release/changelog": "6.0.1",
|
|
33
33
|
"@semantic-release/git": "10.0.1",
|
|
34
|
-
"ajv": "8.
|
|
34
|
+
"ajv": "8.11.0",
|
|
35
35
|
"codecov": "3.8.3",
|
|
36
36
|
"commitizen": "4.2.4",
|
|
37
37
|
"cz-conventional-changelog": "3.3.0",
|
|
38
38
|
"dotenv": "16.0.0",
|
|
39
|
-
"eslint": "8.
|
|
39
|
+
"eslint": "8.13.0",
|
|
40
40
|
"eslint-plugin-header": "3.1.1",
|
|
41
|
-
"eslint-plugin-import": "2.
|
|
41
|
+
"eslint-plugin-import": "2.26.0",
|
|
42
42
|
"jsdoc-to-markdown": "7.1.1",
|
|
43
43
|
"junit-report-builder": "3.0.0",
|
|
44
44
|
"lint-staged": "12.3.7",
|
package/src/OneDrive.d.ts
CHANGED
|
@@ -227,16 +227,17 @@ export declare class OneDrive extends EventEmitter {
|
|
|
227
227
|
* - replace all non-alphanumeric characters with a dash
|
|
228
228
|
* - remove all consecutive dashes
|
|
229
229
|
* - remove all leading and trailing dashes
|
|
230
|
-
* - extensions are ignored, if the given path doesn't have one
|
|
230
|
+
* - extensions are ignored, if the given path doesn't have one or if ignoreExtension is true
|
|
231
231
|
*
|
|
232
232
|
* The result is an array of drive items that match the given path. They are ordered by the edit
|
|
233
233
|
* distance to the original name and then alphanumerically.
|
|
234
234
|
*
|
|
235
235
|
* @param folderItem
|
|
236
236
|
* @param relPath
|
|
237
|
+
* @param ignoreExtension
|
|
237
238
|
* @returns {Promise<DriveItem[]>}
|
|
238
239
|
*/
|
|
239
|
-
fuzzyGetDriveItem(folderItem: DriveItem, relPath?: string): Promise<DriveItem[]>;
|
|
240
|
+
fuzzyGetDriveItem(folderItem: DriveItem, relPath?: string, ignoreExtension?: boolean): Promise<DriveItem[]>;
|
|
240
241
|
|
|
241
242
|
downloadDriveItem(driveItem: DriveItem): Promise<GraphResult>;
|
|
242
243
|
|
package/src/OneDrive.js
CHANGED
|
@@ -502,22 +502,39 @@ class OneDrive extends EventEmitter {
|
|
|
502
502
|
* - convert to lower case
|
|
503
503
|
* - replace all non-alphanumeric characters with a dash
|
|
504
504
|
* - remove all consecutive dashes
|
|
505
|
-
* - extensions are ignored, if the given path doesn't have one
|
|
505
|
+
* - extensions are ignored, if the given path doesn't have one or if ignoreExtension is true
|
|
506
506
|
*
|
|
507
507
|
* The result is an array of drive items that match the given path. They are ordered by the edit
|
|
508
508
|
* distance to the original name and then alphanumerically.
|
|
509
509
|
*
|
|
510
510
|
* @param {DriveItem} folderItem
|
|
511
|
-
* @param {string} relPath
|
|
511
|
+
* @param {string} [relPath = '']
|
|
512
|
+
* @param {boolean} [ignoreExtension = false]
|
|
512
513
|
* @returns {Promise<DriveItem[]>}
|
|
513
514
|
*/
|
|
514
|
-
async fuzzyGetDriveItem(folderItem, relPath = '') {
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
515
|
+
async fuzzyGetDriveItem(folderItem, relPath = '', ignoreExtension = false) {
|
|
516
|
+
if (relPath && !relPath.startsWith('/')) {
|
|
517
|
+
throw new Error('relPath must be empty or start with /');
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// first try to get item directly
|
|
521
|
+
try {
|
|
522
|
+
const ret = await this.getDriveItem(folderItem, relPath, false);
|
|
523
|
+
if (relPath) {
|
|
524
|
+
// eslint-disable-next-line prefer-destructuring
|
|
525
|
+
ret.extension = splitByExtension(relPath)[1];
|
|
526
|
+
}
|
|
527
|
+
this.log.info(`fetched drive item directly: /drives/${folderItem.parentReference.driveId}/items/${folderItem.id}:${relPath}`);
|
|
528
|
+
return [ret];
|
|
529
|
+
} catch (e) {
|
|
530
|
+
this.log.info(`fetched drive item directly failed: /drives/${folderItem.parentReference.driveId}/items/${folderItem.id}:${relPath} (${e.statusCode})`);
|
|
531
|
+
// if no 404 or no relPath, propagate error
|
|
532
|
+
if (e.statusCode !== 404 || !relPath) {
|
|
533
|
+
throw e;
|
|
534
|
+
}
|
|
520
535
|
}
|
|
536
|
+
|
|
537
|
+
const idx = relPath.lastIndexOf('/');
|
|
521
538
|
const folderRelPath = relPath.substring(0, idx);
|
|
522
539
|
const name = relPath.substring(idx + 1);
|
|
523
540
|
const [baseName, ext] = splitByExtension(name);
|
|
@@ -541,7 +558,7 @@ class OneDrive extends EventEmitter {
|
|
|
541
558
|
}
|
|
542
559
|
} while (query.$skiptoken);
|
|
543
560
|
|
|
544
|
-
this.log.
|
|
561
|
+
this.log.info(`loaded ${fileList.length} children from /drives/${folderItem.parentReference.driveId}/items/${folderItem.id}:${relPath}`);
|
|
545
562
|
const items = fileList.filter((item) => {
|
|
546
563
|
if (!item.file) {
|
|
547
564
|
return false;
|
|
@@ -550,7 +567,7 @@ class OneDrive extends EventEmitter {
|
|
|
550
567
|
// remember extension
|
|
551
568
|
// eslint-disable-next-line no-param-reassign
|
|
552
569
|
item.extension = itemExt;
|
|
553
|
-
if (ext && ext !== itemExt) {
|
|
570
|
+
if (ext && ext !== itemExt && !ignoreExtension) {
|
|
554
571
|
// only match extension if given via relPath
|
|
555
572
|
return false;
|
|
556
573
|
}
|
package/src/OneDriveMock.js
CHANGED
|
@@ -239,6 +239,9 @@ class OneDriveMock extends OneDrive {
|
|
|
239
239
|
const url = new URL(`https://dummy.org${uri}`);
|
|
240
240
|
if (url.pathname in this.driveItems) {
|
|
241
241
|
const result = this.driveItems[url.pathname];
|
|
242
|
+
if (result instanceof Error) {
|
|
243
|
+
throw result;
|
|
244
|
+
}
|
|
242
245
|
if (!Array.isArray(result.value)) {
|
|
243
246
|
return result;
|
|
244
247
|
}
|