@adobe/helix-onedrive-support 10.3.6 → 10.4.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 CHANGED
@@ -1,3 +1,17 @@
1
+ # [10.4.0](https://github.com/adobe/helix-onedrive-support/compare/v10.3.7...v10.4.0) (2023-08-28)
2
+
3
+
4
+ ### Features
5
+
6
+ * add log fields for API call logging ([#425](https://github.com/adobe/helix-onedrive-support/issues/425)) ([36f88db](https://github.com/adobe/helix-onedrive-support/commit/36f88db697db73a7fc24da062f66d66aeab32bc0))
7
+
8
+ ## [10.3.7](https://github.com/adobe/helix-onedrive-support/compare/v10.3.6...v10.3.7) (2023-08-21)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update external major (major) ([#419](https://github.com/adobe/helix-onedrive-support/issues/419)) ([79dc6e6](https://github.com/adobe/helix-onedrive-support/commit/79dc6e6a59972b900c1a4de7de971a10c6afae82))
14
+
1
15
  ## [10.3.6](https://github.com/adobe/helix-onedrive-support/compare/v10.3.5...v10.3.6) (2023-08-21)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-onedrive-support",
3
- "version": "10.3.6",
3
+ "version": "10.4.0",
4
4
  "description": "Helix OneDrive Support",
5
5
  "main": "src/index.js",
6
6
  "exports": {
@@ -29,19 +29,19 @@
29
29
  "dependencies": {
30
30
  "@adobe/fetch": "4.0.13",
31
31
  "@adobe/helix-shared-tokencache": "1.3.5",
32
- "@azure/msal-node": "1.18.1",
32
+ "@azure/msal-node": "2.0.2",
33
33
  "jose": "4.14.4"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@adobe/eslint-config-helix": "2.0.3",
37
37
  "@semantic-release/changelog": "6.0.3",
38
38
  "@semantic-release/git": "10.0.1",
39
- "@aws-sdk/client-s3": "3.395.0",
39
+ "@aws-sdk/client-s3": "3.400.0",
40
40
  "ajv": "8.12.0",
41
41
  "c8": "8.0.1",
42
42
  "codecov": "3.8.3",
43
43
  "dotenv": "16.3.1",
44
- "eslint": "8.47.0",
44
+ "eslint": "8.48.0",
45
45
  "eslint-plugin-header": "3.1.1",
46
46
  "eslint-plugin-import": "2.28.1",
47
47
  "husky": "8.0.3",
@@ -49,12 +49,12 @@
49
49
  "jsdoc-to-markdown": "8.0.0",
50
50
  "jsdoc-tsimport-plugin": "1.0.5",
51
51
  "junit-report-builder": "3.0.1",
52
- "lint-staged": "13.3.0",
52
+ "lint-staged": "14.0.1",
53
53
  "mocha": "10.2.0",
54
54
  "mocha-multi-reporters": "1.5.1",
55
55
  "nock": "13.3.3",
56
56
  "npm": "9.8.1",
57
- "semantic-release": "21.0.7"
57
+ "semantic-release": "21.1.1"
58
58
  },
59
59
  "lint-staged": {
60
60
  "*.js": "eslint"
package/src/OneDrive.js CHANGED
@@ -125,14 +125,19 @@ export class OneDrive {
125
125
  opts.headers = {};
126
126
  }
127
127
  opts.headers.authorization = `Bearer ${accessToken}`;
128
+
129
+ const { log, auth: { logFields, tenant } } = this;
128
130
  const url = `https://graph.microsoft.com/v1.0${relUrl}`;
131
+ const method = opts.method || 'GET';
132
+
129
133
  try {
130
134
  const { fetch } = this.fetchContext;
131
135
  const resp = await fetch(url, opts);
132
- const rateLimit = RateLimit.fromHeaders(resp.headers);
136
+ log.info(`OneDrive API [tenant:${tenant}] ${logFields}: ${method} ${relUrl} ${resp.status}`);
133
137
 
138
+ const rateLimit = RateLimit.fromHeaders(resp.headers);
134
139
  if (rateLimit) {
135
- this.log.warn({ sharepointRateLimit: { tenant: this.auth.tenant, ...rateLimit.toJSON() } });
140
+ log.warn({ sharepointRateLimit: { tenant, ...rateLimit.toJSON() } });
136
141
  }
137
142
 
138
143
  if (!resp.ok) {
@@ -157,6 +162,7 @@ export class OneDrive {
157
162
  if (!(e instanceof StatusCodeError)) {
158
163
  err = StatusCodeError.fromError(e);
159
164
  }
165
+ log.info(`OneDrive API [tenant:${tenant}] ${logFields}: ${method} ${relUrl} ${e.statusCode}`);
160
166
  throw err;
161
167
  }
162
168
  }
@@ -28,6 +28,11 @@ export declare interface OneDriveAuthOptions {
28
28
  acquireMethod?: AcquireMethod;
29
29
  accessToken?: string;
30
30
 
31
+ /**
32
+ * Optional log fields, as key-value object.
33
+ */
34
+ logFields?: object;
35
+
31
36
  /**
32
37
  * use cache plugin instead for default (global) token cache.
33
38
  */
@@ -76,6 +76,8 @@ export class OneDriveAuth {
76
76
  this.scopes = opts.scopes || DEFAULT_SCOPES;
77
77
  this.onCode = opts.onCode;
78
78
  this.acquireMethod = opts.acquireMethod || '';
79
+ this.logFields = Object.entries(opts.logFields || {})
80
+ .map(([key, value]) => `[${key}:${value}]`).join(' ');
79
81
 
80
82
  const validAcquireMethods = Array.from(Object.values(AcquireMethod));
81
83
  if (this.acquireMethod && !validAcquireMethods.includes(this.acquireMethod)) {