@adobe/helix-onedrive-support 5.0.1 → 5.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.
@@ -1,8 +1,8 @@
1
1
  version: 2.1
2
2
  executors:
3
- node12:
3
+ :
4
4
  docker:
5
- - image: circleci/node:12
5
+ - image: circleci/node:14
6
6
  environment:
7
7
  NPM_CONFIG_PREFIX: ~/.npm-global
8
8
 
@@ -29,7 +29,7 @@ commands:
29
29
 
30
30
  jobs:
31
31
  build:
32
- executor: node12
32
+ executor: node14
33
33
 
34
34
  steps:
35
35
  - setup
@@ -10,10 +10,10 @@ jobs:
10
10
  if: "!contains(github.event.head_commit.message, '[skip ci]')"
11
11
  steps:
12
12
  - uses: actions/checkout@v2
13
- - name: Use Node.js 12.x
13
+ - name: Use Node.js 14.x
14
14
  uses: actions/setup-node@v2
15
15
  with:
16
- node-version: '12.x'
16
+ node-version: '14.x'
17
17
  - run: npm install
18
18
  - run: npm test
19
19
  - run: npm run semantic-release
package/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ ## [5.1.1](https://github.com/adobe/helix-onedrive-support/compare/v5.1.0...v5.1.1) (2021-09-22)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * better error report ([#191](https://github.com/adobe/helix-onedrive-support/issues/191)) ([a63bb4f](https://github.com/adobe/helix-onedrive-support/commit/a63bb4f2819d7764885a5a1ad99923ba172f6d93)), closes [#190](https://github.com/adobe/helix-onedrive-support/issues/190)
7
+
8
+ # [5.1.0](https://github.com/adobe/helix-onedrive-support/compare/v5.0.3...v5.1.0) (2021-08-31)
9
+
10
+
11
+ ### Features
12
+
13
+ * add option to disable share link cache (for testing) ([#186](https://github.com/adobe/helix-onedrive-support/issues/186)) ([a8e6af2](https://github.com/adobe/helix-onedrive-support/commit/a8e6af229f70014e12772e4a2c19d657ba68fdde))
14
+
15
+ ## [5.0.3](https://github.com/adobe/helix-onedrive-support/compare/v5.0.2...v5.0.3) (2021-08-18)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **deps:** update dependency @adobe/helix-fetch to v2.4.2 ([#182](https://github.com/adobe/helix-onedrive-support/issues/182)) ([485fba1](https://github.com/adobe/helix-onedrive-support/commit/485fba1e0ecf5a660a14e4bd0448f752346d4b7b))
21
+
22
+ ## [5.0.2](https://github.com/adobe/helix-onedrive-support/compare/v5.0.1...v5.0.2) (2021-07-30)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **deps:** update dependency @adobe/helix-fetch to v2.4.1 ([#177](https://github.com/adobe/helix-onedrive-support/issues/177)) ([0317917](https://github.com/adobe/helix-onedrive-support/commit/031791711665fd1beac391a94dba3145c48d90ca))
28
+
1
29
  ## [5.0.1](https://github.com/adobe/helix-onedrive-support/compare/v5.0.0...v5.0.1) (2021-06-11)
2
30
 
3
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-onedrive-support",
3
- "version": "5.0.1",
3
+ "version": "5.1.1",
4
4
  "description": "Helix OneDrive Support",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -23,28 +23,28 @@
23
23
  },
24
24
  "homepage": "https://github.com/adobe/helix-onedrive-support#readme",
25
25
  "dependencies": {
26
- "@adobe/helix-fetch": "2.3.0",
26
+ "@adobe/helix-fetch": "2.4.2",
27
27
  "adal-node": "https://github.com/adobe-rnd/azure-activedirectory-library-for-nodejs.git#adobe"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@adobe/eslint-config-helix": "1.1.5",
31
- "@semantic-release/changelog": "5.0.1",
32
- "@semantic-release/git": "9.0.0",
33
- "ajv": "8.5.0",
34
- "codecov": "3.8.2",
31
+ "@semantic-release/changelog": "6.0.0",
32
+ "@semantic-release/git": "10.0.0",
33
+ "ajv": "8.6.3",
34
+ "codecov": "3.8.3",
35
35
  "commitizen": "4.2.4",
36
36
  "cz-conventional-changelog": "3.3.0",
37
37
  "dotenv": "10.0.0",
38
- "eslint": "7.28.0",
38
+ "eslint": "7.32.0",
39
39
  "eslint-plugin-header": "3.1.1",
40
- "eslint-plugin-import": "2.23.4",
40
+ "eslint-plugin-import": "2.24.2",
41
41
  "jsdoc-to-markdown": "7.0.1",
42
42
  "junit-report-builder": "3.0.0",
43
- "lint-staged": "11.0.0",
44
- "mocha": "9.0.0",
45
- "nock": "13.1.0",
43
+ "lint-staged": "11.1.2",
44
+ "mocha": "9.1.1",
45
+ "nock": "13.1.3",
46
46
  "nyc": "15.1.0",
47
- "semantic-release": "17.4.3"
47
+ "semantic-release": "18.0.0"
48
48
  },
49
49
  "lint-staged": {
50
50
  "*.js": "eslint"
package/src/OneDrive.d.ts CHANGED
@@ -27,6 +27,23 @@ export declare interface OneDriveOptions {
27
27
  tenant?: string;
28
28
  username?: string;
29
29
  password?: string;
30
+
31
+ /**
32
+ * Uses a local auth cache for access tokens.
33
+ */
34
+ localAuthCache?: boolean,
35
+
36
+ /**
37
+ * Disables the cache for the share link lookup.
38
+ * @default process.env.HELIX_ONEDRIVE_NO_SHARE_LINK_CACHE
39
+ */
40
+ noShareLinkCache?: boolean;
41
+
42
+ /**
43
+ * Map to use for the share link lookup cache. If empty, a module-global cache will be used.
44
+ * Note that the cache is only used, if the `noShareLinkCache` flag is `falsy`
45
+ */
46
+ shareLinkCache?: Map<string, DriveItem>,
30
47
  }
31
48
 
32
49
  export declare interface GraphResult {
@@ -120,8 +137,8 @@ export declare class OneDrive extends EventEmitter {
120
137
 
121
138
  acquireToken(redirectUri: string, code: string): Promise<TokenResponse>;
122
139
 
123
- dispose() : Promise;
124
-
140
+ dispose() : Promise<void>;
141
+
125
142
  doFetch(relUrl: string, rawResponseBody: boolean = false, options: object = {}): Promise<object|Buffer>
126
143
 
127
144
  me(): Promise<GraphResult>;
package/src/OneDrive.js CHANGED
@@ -47,7 +47,7 @@ const MAX_SUBSCRIPTION_EXPIRATION_TIME = 4230 * 60 * 1000;
47
47
  * @type {Map<string, *>}
48
48
  * @private
49
49
  */
50
- const shareItemCache = new Map();
50
+ const globalShareLinkCache = new Map();
51
51
 
52
52
  /**
53
53
  * Helper class that facilitates accessing one drive.
@@ -75,6 +75,10 @@ class OneDrive extends EventEmitter {
75
75
  this._log = opts.log || console;
76
76
  this.tenant = opts.tenant || AZ_DEFAULT_TENANT;
77
77
 
78
+ if (!opts.noShareLinkCache && !process.env.HELIX_ONEDRIVE_NO_SHARE_LINK_CACHE) {
79
+ this.shareLinkCache = opts.shareLinkCache || globalShareLinkCache;
80
+ }
81
+
78
82
  if (!this.clientId) {
79
83
  throw new Error('Missing clientId.');
80
84
  }
@@ -288,7 +292,7 @@ class OneDrive extends EventEmitter {
288
292
  if (err.statusCode === 404) {
289
293
  this.log.warn(`${relUrl} : ${err.statusCode} - ${err.message}`);
290
294
  } else {
291
- this.log.error(`${relUrl} : ${err.statusCode} - ${err.message} - ${err.details}`);
295
+ this.log.error(`${relUrl} : ${err.statusCode} - ${err.message}`, err.details);
292
296
  }
293
297
  throw err;
294
298
  }
@@ -349,10 +353,14 @@ class OneDrive extends EventEmitter {
349
353
  if (driveItem) {
350
354
  return driveItem;
351
355
  }
352
- driveItem = shareItemCache.get(sharingUrl);
356
+ if (this.shareLinkCache) {
357
+ driveItem = this.shareLinkCache.get(sharingUrl);
358
+ }
353
359
  if (!driveItem) {
354
360
  driveItem = await this.resolveShareLink(sharingUrl);
355
- shareItemCache.set(sharingUrl, driveItem);
361
+ if (this.shareLinkCache) {
362
+ this.shareLinkCache.set(sharingUrl, driveItem);
363
+ }
356
364
  }
357
365
  return driveItem;
358
366
  }
@@ -43,6 +43,10 @@ class StatusCodeError extends Error {
43
43
  * @returns {StatusCodeError} status code error
44
44
  */
45
45
  static fromErrorResponse(errorBody, statusCode) {
46
+ if (errorBody.error && errorBody.error.message) {
47
+ // eslint-disable-next-line no-param-reassign
48
+ errorBody = errorBody.error;
49
+ }
46
50
  return new StatusCodeError(errorBody.message, statusCode, errorBody);
47
51
  }
48
52