@adobe/helix-google-support 3.1.37 → 3.2.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,24 @@
1
+ # [3.2.0](https://github.com/adobe/helix-google-support/compare/v3.1.39...v3.2.0) (2024-09-26)
2
+
3
+
4
+ ### Features
5
+
6
+ * allow passing other options to Google API ([#429](https://github.com/adobe/helix-google-support/issues/429)) ([b87724e](https://github.com/adobe/helix-google-support/commit/b87724e41faa9841fe56700bfa0648da54132a52))
7
+
8
+ ## [3.1.39](https://github.com/adobe/helix-google-support/compare/v3.1.38...v3.1.39) (2024-09-24)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update adobe fixes ([76232d5](https://github.com/adobe/helix-google-support/commit/76232d56fb3864beb69d5bf8706187be094b2ad1))
14
+
15
+ ## [3.1.38](https://github.com/adobe/helix-google-support/compare/v3.1.37...v3.1.38) (2024-09-22)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **deps:** update dependency @adobe/helix-onedrive-support to v11.5.16 ([3d5a109](https://github.com/adobe/helix-google-support/commit/3d5a1095db92e158166db74957ead746c6e3fd03))
21
+
1
22
  ## [3.1.37](https://github.com/adobe/helix-google-support/compare/v3.1.36...v3.1.37) (2024-09-14)
2
23
 
3
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-google-support",
3
- "version": "3.1.37",
3
+ "version": "3.2.0",
4
4
  "description": "Helix Google Support",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -31,21 +31,21 @@
31
31
  "reporter-options": "configFile=.mocha-multi.json"
32
32
  },
33
33
  "dependencies": {
34
- "@adobe/helix-onedrive-support": "11.5.15",
34
+ "@adobe/helix-onedrive-support": "11.5.17",
35
35
  "googleapis": "144.0.0",
36
36
  "lru-cache": "11.0.1"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@adobe/eslint-config-helix": "2.0.7",
40
- "@adobe/helix-shared-tokencache": "1.4.31",
40
+ "@adobe/helix-shared-tokencache": "1.4.33",
41
41
  "@semantic-release/changelog": "6.0.3",
42
42
  "@semantic-release/git": "10.0.1",
43
43
  "c8": "10.1.2",
44
- "eslint": "8.57.0",
44
+ "eslint": "8.57.1",
45
45
  "eslint-plugin-header": "3.1.1",
46
46
  "eslint-plugin-import": "2.30.0",
47
47
  "husky": "9.1.6",
48
- "junit-report-builder": "5.0.0",
48
+ "junit-report-builder": "5.1.1",
49
49
  "lint-staged": "15.2.10",
50
50
  "mocha": "10.7.3",
51
51
  "mocha-multi-reporters": "1.5.1",
@@ -130,6 +130,8 @@ export class GoogleClient {
130
130
  version: 'v3',
131
131
  auth: this.auth,
132
132
  });
133
+
134
+ this.googleApiOpts = opts.googleApiOpts;
133
135
  }
134
136
 
135
137
  async init() {
@@ -177,7 +179,7 @@ export class GoogleClient {
177
179
  * @returns {Promise<DriveItemInfo[]>|null}
178
180
  */
179
181
  async getUncachedItemsFromSegments(parentId, pathSegments, parentPath, type) {
180
- const { log, drive } = this;
182
+ const { log, drive, googleApiOpts } = this;
181
183
  const name = pathSegments.shift();
182
184
  const [baseName, ext] = splitByExtension(name);
183
185
  const sanitizedName = sanitizeName(baseName);
@@ -193,7 +195,7 @@ export class GoogleClient {
193
195
  : 'and mimeType != \'application/vnd.google-apps.folder\'';
194
196
  }
195
197
 
196
- const opts = {
198
+ const params = {
197
199
  q: [
198
200
  `'${parentId}' in parents`,
199
201
  'and trashed=false',
@@ -207,13 +209,13 @@ export class GoogleClient {
207
209
 
208
210
  do {
209
211
  // eslint-disable-next-line no-await-in-loop
210
- const { data } = await drive.files.list(opts);
212
+ const { data } = await drive.files.list(params, googleApiOpts);
211
213
  if (data.nextPageToken) {
212
- opts.pageToken = data.nextPageToken;
214
+ params.pageToken = data.nextPageToken;
213
215
  } else {
214
- opts.pageToken = null;
216
+ params.pageToken = null;
215
217
  }
216
- log.debug(`fetched ${data.files.length} items below ${parentId}. nextPageToken=${opts.pageToken ? '****' : 'null'}`);
218
+ log.debug(`fetched ${data.files.length} items below ${parentId}. nextPageToken=${params.pageToken ? '****' : 'null'}`);
217
219
 
218
220
  // find fuzzy match
219
221
  data.files.forEach((item) => {
@@ -235,7 +237,7 @@ export class GoogleClient {
235
237
  item.fuzzyDistance = editDistance(baseName, itemName);
236
238
  items.push(item);
237
239
  });
238
- } while (opts.pageToken);
240
+ } while (params.pageToken);
239
241
 
240
242
  // sort items by edit distance first and 2nd by item name
241
243
  items.sort((i0, i1) => {
@@ -338,7 +340,7 @@ export class GoogleClient {
338
340
  * @returns {Promise<DriveItemInfo[]>}
339
341
  */
340
342
  async getItems(fileId, roots) {
341
- const { log } = this;
343
+ const { log, googleApiOpts } = this;
342
344
  log.debug(`getItems(${fileId})`);
343
345
  const { data } = (await this.drive.files.get({
344
346
  fileId,
@@ -349,7 +351,7 @@ export class GoogleClient {
349
351
  'modifiedTime',
350
352
  ].join(','),
351
353
  supportsAllDrives: true,
352
- }));
354
+ }, googleApiOpts));
353
355
 
354
356
  const root = roots[fileId];
355
357
  if (root) {
@@ -455,7 +457,7 @@ export class GoogleClient {
455
457
  'modifiedTime',
456
458
  ].join(','),
457
459
  supportsAllDrives: true,
458
- }));
460
+ }, this.googleApiOpts));
459
461
  return addFields({
460
462
  id: fileId,
461
463
  path: `/${data.name}`,
@@ -479,7 +481,7 @@ export class GoogleClient {
479
481
  fileId,
480
482
  alt: 'media',
481
483
  supportsAllDrives: true,
482
- }, { responseType: 'arraybuffer' });
484
+ }, { ...(this.googleApiOpts || {}), responseType: 'arraybuffer' });
483
485
  return Buffer.from(res.data);
484
486
  } catch (e) {
485
487
  if (e.response && e.response.status === 404) {
@@ -604,7 +606,7 @@ export class GoogleClient {
604
606
 
605
607
  const response = await this.drive.files.create({
606
608
  requestBody,
607
- });
609
+ }, this.googleApiOpts);
608
610
 
609
611
  return response.data;
610
612
  } catch (e) {