@adobe/helix-google-support 1.2.0 → 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 +21 -0
- package/package.json +1 -1
- package/src/GoogleClient.js +28 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
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
|
+
|
|
8
|
+
## [1.2.2](https://github.com/adobe/helix-google-support/compare/v1.2.1...v1.2.2) (2022-04-28)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* include mimeType ([#11](https://github.com/adobe/helix-google-support/issues/11)) ([67ab999](https://github.com/adobe/helix-google-support/commit/67ab999a7fee111978a15c4393761e4b614ee2fc))
|
|
14
|
+
|
|
15
|
+
## [1.2.1](https://github.com/adobe/helix-google-support/compare/v1.2.0...v1.2.1) (2022-04-28)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* include mimeType ([#10](https://github.com/adobe/helix-google-support/issues/10)) ([993e24a](https://github.com/adobe/helix-google-support/commit/993e24acdd723402a6d85a8bf74e3b93df8c5d0e))
|
|
21
|
+
|
|
1
22
|
# [1.2.0](https://github.com/adobe/helix-google-support/compare/v1.1.0...v1.2.0) (2022-04-28)
|
|
2
23
|
|
|
3
24
|
|
package/package.json
CHANGED
package/src/GoogleClient.js
CHANGED
|
@@ -169,7 +169,7 @@ export class GoogleClient {
|
|
|
169
169
|
// folder if path continues, sheet otherwise
|
|
170
170
|
`and mimeType ${pathSegments.length ? '=' : '!='} 'application/vnd.google-apps.folder'`,
|
|
171
171
|
].join(' '),
|
|
172
|
-
fields: 'nextPageToken, files(id, name, modifiedTime)',
|
|
172
|
+
fields: 'nextPageToken, files(id, name, mimeType, modifiedTime)',
|
|
173
173
|
includeItemsFromAllDrives: true,
|
|
174
174
|
supportsAllDrives: true,
|
|
175
175
|
pageSize: 1000,
|
|
@@ -236,6 +236,7 @@ export class GoogleClient {
|
|
|
236
236
|
name,
|
|
237
237
|
path: itemPath,
|
|
238
238
|
id: item.id,
|
|
239
|
+
mimeType: item.mimeType,
|
|
239
240
|
}, item);
|
|
240
241
|
|
|
241
242
|
if (children.length) {
|
|
@@ -292,6 +293,7 @@ export class GoogleClient {
|
|
|
292
293
|
name: '',
|
|
293
294
|
path: '/',
|
|
294
295
|
id: parentId,
|
|
296
|
+
mimeType: 'application/vnd.google-apps.folder',
|
|
295
297
|
}];
|
|
296
298
|
}
|
|
297
299
|
|
|
@@ -310,6 +312,7 @@ export class GoogleClient {
|
|
|
310
312
|
fields: [
|
|
311
313
|
'name',
|
|
312
314
|
'parents',
|
|
315
|
+
'mimeType',
|
|
313
316
|
'modifiedTime',
|
|
314
317
|
].join(','),
|
|
315
318
|
}));
|
|
@@ -372,6 +375,30 @@ export class GoogleClient {
|
|
|
372
375
|
* @returns {Promise<DriveItemInfo>}
|
|
373
376
|
*/
|
|
374
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
|
+
|
|
375
402
|
const segs = createPathSegments(path);
|
|
376
403
|
const items = await this.getDriveItemsFromSegments(parentId, segs, '');
|
|
377
404
|
const item = items?.[0];
|