@adobe/helix-google-support 3.1.38 → 3.2.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 +21 -0
- package/package.json +4 -4
- package/src/GoogleClient.js +14 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## [3.2.1](https://github.com/adobe/helix-google-support/compare/v3.2.0...v3.2.1) (2024-09-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency @adobe/helix-onedrive-support to v11.5.18 ([f398408](https://github.com/adobe/helix-google-support/commit/f398408a7895f451068141ffad8237fccdc01df3))
|
|
7
|
+
|
|
8
|
+
# [3.2.0](https://github.com/adobe/helix-google-support/compare/v3.1.39...v3.2.0) (2024-09-26)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* 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))
|
|
14
|
+
|
|
15
|
+
## [3.1.39](https://github.com/adobe/helix-google-support/compare/v3.1.38...v3.1.39) (2024-09-24)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **deps:** update adobe fixes ([76232d5](https://github.com/adobe/helix-google-support/commit/76232d56fb3864beb69d5bf8706187be094b2ad1))
|
|
21
|
+
|
|
1
22
|
## [3.1.38](https://github.com/adobe/helix-google-support/compare/v3.1.37...v3.1.38) (2024-09-22)
|
|
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
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "Helix Google Support",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"reporter-options": "configFile=.mocha-multi.json"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@adobe/helix-onedrive-support": "11.5.
|
|
34
|
+
"@adobe/helix-onedrive-support": "11.5.18",
|
|
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.
|
|
40
|
+
"@adobe/helix-shared-tokencache": "1.4.34",
|
|
41
41
|
"@semantic-release/changelog": "6.0.3",
|
|
42
42
|
"@semantic-release/git": "10.0.1",
|
|
43
43
|
"c8": "10.1.2",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"mocha": "10.7.3",
|
|
51
51
|
"mocha-multi-reporters": "1.5.1",
|
|
52
52
|
"nock": "13.5.5",
|
|
53
|
-
"semantic-release": "24.1.
|
|
53
|
+
"semantic-release": "24.1.2"
|
|
54
54
|
},
|
|
55
55
|
"lint-staged": {
|
|
56
56
|
"*.js": "eslint",
|
package/src/GoogleClient.js
CHANGED
|
@@ -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
|
|
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(
|
|
212
|
+
const { data } = await drive.files.list(params, googleApiOpts);
|
|
211
213
|
if (data.nextPageToken) {
|
|
212
|
-
|
|
214
|
+
params.pageToken = data.nextPageToken;
|
|
213
215
|
} else {
|
|
214
|
-
|
|
216
|
+
params.pageToken = null;
|
|
215
217
|
}
|
|
216
|
-
log.debug(`fetched ${data.files.length} items below ${parentId}. nextPageToken=${
|
|
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 (
|
|
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) {
|