@adobe/helix-onedrive-support 7.0.0 → 7.1.1
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 +22 -0
- package/package.json +4 -4
- package/src/OneDrive.d.ts +5 -2
- package/src/OneDrive.js +35 -11
- package/src/OneDriveMock.js +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## [7.1.1](https://github.com/adobe/helix-onedrive-support/compare/v7.1.0...v7.1.1) (2022-04-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency @adobe/helix-fetch to v3.0.8 ([0035641](https://github.com/adobe/helix-onedrive-support/commit/0035641545b9c4a0deef5de7f3e1bab0f961b0ff))
|
|
7
|
+
|
|
8
|
+
# [7.1.0](https://github.com/adobe/helix-onedrive-support/compare/v7.0.1...v7.1.0) (2022-04-01)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* 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)
|
|
14
|
+
|
|
15
|
+
## [7.0.1](https://github.com/adobe/helix-onedrive-support/compare/v7.0.0...v7.0.1) (2022-03-23)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* detect *-my.sharepoint.com links ([#256](https://github.com/adobe/helix-onedrive-support/issues/256)) ([001f57d](https://github.com/adobe/helix-onedrive-support/commit/001f57d7d73fd760df86c5a18ac5f27bcf9f0cf5))
|
|
21
|
+
* trigger release ([c8826a3](https://github.com/adobe/helix-onedrive-support/commit/c8826a38c69279593338b34918b2c305912225b1))
|
|
22
|
+
|
|
1
23
|
# [7.0.0](https://github.com/adobe/helix-onedrive-support/compare/v6.2.2...v7.0.0) (2022-03-23)
|
|
2
24
|
|
|
3
25
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-onedrive-support",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.1.1",
|
|
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.8",
|
|
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,12 +31,12 @@
|
|
|
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.12.0",
|
|
40
40
|
"eslint-plugin-header": "3.1.1",
|
|
41
41
|
"eslint-plugin-import": "2.25.4",
|
|
42
42
|
"jsdoc-to-markdown": "7.1.1",
|
package/src/OneDrive.d.ts
CHANGED
|
@@ -194,6 +194,8 @@ export declare class OneDrive extends EventEmitter {
|
|
|
194
194
|
|
|
195
195
|
me(): Promise<GraphResult>;
|
|
196
196
|
|
|
197
|
+
initTenantFromShareLink(sharingUrl: string|URL): Promise<void>;
|
|
198
|
+
|
|
197
199
|
resolveShareLink(sharingUrl: string|URL): Promise<GraphResult>;
|
|
198
200
|
|
|
199
201
|
/**
|
|
@@ -225,16 +227,17 @@ export declare class OneDrive extends EventEmitter {
|
|
|
225
227
|
* - replace all non-alphanumeric characters with a dash
|
|
226
228
|
* - remove all consecutive dashes
|
|
227
229
|
* - remove all leading and trailing dashes
|
|
228
|
-
* - 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
|
|
229
231
|
*
|
|
230
232
|
* The result is an array of drive items that match the given path. They are ordered by the edit
|
|
231
233
|
* distance to the original name and then alphanumerically.
|
|
232
234
|
*
|
|
233
235
|
* @param folderItem
|
|
234
236
|
* @param relPath
|
|
237
|
+
* @param ignoreExtension
|
|
235
238
|
* @returns {Promise<DriveItem[]>}
|
|
236
239
|
*/
|
|
237
|
-
fuzzyGetDriveItem(folderItem: DriveItem, relPath?: string): Promise<DriveItem[]>;
|
|
240
|
+
fuzzyGetDriveItem(folderItem: DriveItem, relPath?: string, ignoreExtension?: boolean): Promise<DriveItem[]>;
|
|
238
241
|
|
|
239
242
|
downloadDriveItem(driveItem: DriveItem): Promise<GraphResult>;
|
|
240
243
|
|
package/src/OneDrive.js
CHANGED
|
@@ -155,7 +155,14 @@ class OneDrive extends EventEmitter {
|
|
|
155
155
|
return;
|
|
156
156
|
}
|
|
157
157
|
const { log } = this;
|
|
158
|
-
const
|
|
158
|
+
const url = sharingUrl instanceof URL
|
|
159
|
+
? sharingUrl
|
|
160
|
+
: new URL(sharingUrl);
|
|
161
|
+
let [tenantHost] = url.hostname.split('.');
|
|
162
|
+
// special case: `xxxx-my.sharepoint.com`
|
|
163
|
+
if (url.hostname.endsWith('-my.sharepoint.com')) {
|
|
164
|
+
tenantHost = tenantHost.substring(0, tenantHost.length - 3);
|
|
165
|
+
}
|
|
159
166
|
|
|
160
167
|
if (this.tenantCache) {
|
|
161
168
|
this.tenant = this.tenantCache.get(tenantHost);
|
|
@@ -495,22 +502,39 @@ class OneDrive extends EventEmitter {
|
|
|
495
502
|
* - convert to lower case
|
|
496
503
|
* - replace all non-alphanumeric characters with a dash
|
|
497
504
|
* - remove all consecutive dashes
|
|
498
|
-
* - 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
|
|
499
506
|
*
|
|
500
507
|
* The result is an array of drive items that match the given path. They are ordered by the edit
|
|
501
508
|
* distance to the original name and then alphanumerically.
|
|
502
509
|
*
|
|
503
510
|
* @param {DriveItem} folderItem
|
|
504
|
-
* @param {string} relPath
|
|
511
|
+
* @param {string} [relPath = '']
|
|
512
|
+
* @param {boolean} [ignoreExtension = false]
|
|
505
513
|
* @returns {Promise<DriveItem[]>}
|
|
506
514
|
*/
|
|
507
|
-
async fuzzyGetDriveItem(folderItem, relPath = '') {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
const ret = await this.getDriveItem(folderItem, '', false);
|
|
511
|
-
// todo: add extra extension
|
|
512
|
-
return [ret.value];
|
|
515
|
+
async fuzzyGetDriveItem(folderItem, relPath = '', ignoreExtension = false) {
|
|
516
|
+
if (relPath && !relPath.startsWith('/')) {
|
|
517
|
+
throw new Error('relPath must be empty or start with /');
|
|
513
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
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
const idx = relPath.lastIndexOf('/');
|
|
514
538
|
const folderRelPath = relPath.substring(0, idx);
|
|
515
539
|
const name = relPath.substring(idx + 1);
|
|
516
540
|
const [baseName, ext] = splitByExtension(name);
|
|
@@ -534,7 +558,7 @@ class OneDrive extends EventEmitter {
|
|
|
534
558
|
}
|
|
535
559
|
} while (query.$skiptoken);
|
|
536
560
|
|
|
537
|
-
this.log.
|
|
561
|
+
this.log.info(`loaded ${fileList.length} children from /drives/${folderItem.parentReference.driveId}/items/${folderItem.id}:${relPath}`);
|
|
538
562
|
const items = fileList.filter((item) => {
|
|
539
563
|
if (!item.file) {
|
|
540
564
|
return false;
|
|
@@ -543,7 +567,7 @@ class OneDrive extends EventEmitter {
|
|
|
543
567
|
// remember extension
|
|
544
568
|
// eslint-disable-next-line no-param-reassign
|
|
545
569
|
item.extension = itemExt;
|
|
546
|
-
if (ext && ext !== itemExt) {
|
|
570
|
+
if (ext && ext !== itemExt && !ignoreExtension) {
|
|
547
571
|
// only match extension if given via relPath
|
|
548
572
|
return false;
|
|
549
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
|
}
|