@adobe/helix-google-support 1.2.2 → 1.3.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 +7 -0
- package/package.json +1 -1
- package/src/GoogleClient.js +25 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.3.0](https://github.com/adobe/helix-google-support/compare/v1.2.2...v1.3.0) (2022-04-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* handle getItemForPath() with no path ([#12](https://github.com/adobe/helix-google-support/issues/12)) ([0e1b60d](https://github.com/adobe/helix-google-support/commit/0e1b60d6612b3628193b9188eadc230de2894aff))
|
|
7
|
+
|
|
1
8
|
## [1.2.2](https://github.com/adobe/helix-google-support/compare/v1.2.1...v1.2.2) (2022-04-28)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/GoogleClient.js
CHANGED
|
@@ -312,6 +312,7 @@ export class GoogleClient {
|
|
|
312
312
|
fields: [
|
|
313
313
|
'name',
|
|
314
314
|
'parents',
|
|
315
|
+
'mimeType',
|
|
315
316
|
'modifiedTime',
|
|
316
317
|
].join(','),
|
|
317
318
|
}));
|
|
@@ -374,6 +375,30 @@ export class GoogleClient {
|
|
|
374
375
|
* @returns {Promise<DriveItemInfo>}
|
|
375
376
|
*/
|
|
376
377
|
async getItemFromPath(parentId, path) {
|
|
378
|
+
if (!path) {
|
|
379
|
+
try {
|
|
380
|
+
const { data } = (await this.drive.files.get({
|
|
381
|
+
fileId: parentId,
|
|
382
|
+
fields: [
|
|
383
|
+
'name',
|
|
384
|
+
'parents',
|
|
385
|
+
'mimeType',
|
|
386
|
+
'modifiedTime',
|
|
387
|
+
].join(','),
|
|
388
|
+
}));
|
|
389
|
+
|
|
390
|
+
return addLastModified({
|
|
391
|
+
id: parentId,
|
|
392
|
+
path: `/${data.name}`,
|
|
393
|
+
}, data);
|
|
394
|
+
} catch (e) {
|
|
395
|
+
if (e.response && e.response.status === 404) {
|
|
396
|
+
return null;
|
|
397
|
+
}
|
|
398
|
+
throw e;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
377
402
|
const segs = createPathSegments(path);
|
|
378
403
|
const items = await this.getDriveItemsFromSegments(parentId, segs, '');
|
|
379
404
|
const item = items?.[0];
|