@adobe/helix-google-support 3.0.50 → 3.1.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 +14 -0
- package/package.json +2 -2
- package/src/GoogleClient.d.ts +16 -8
- package/src/GoogleClient.js +42 -29
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [3.1.1](https://github.com/adobe/helix-google-support/compare/v3.1.0...v3.1.1) (2024-05-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency @adobe/helix-onedrive-support to v11.3.23 ([5ffa9cf](https://github.com/adobe/helix-google-support/commit/5ffa9cfdca3acae1625fe597fc09a16efd13e139))
|
|
7
|
+
|
|
8
|
+
# [3.1.0](https://github.com/adobe/helix-google-support/compare/v3.0.50...v3.1.0) (2024-05-14)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* add getUncachedItemFromId ([#361](https://github.com/adobe/helix-google-support/issues/361)) ([acc94f7](https://github.com/adobe/helix-google-support/commit/acc94f7a75c6c05766314784fb38d077ad962b52))
|
|
14
|
+
|
|
1
15
|
## [3.0.50](https://github.com/adobe/helix-google-support/compare/v3.0.49...v3.0.50) (2024-05-14)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-google-support",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Helix Google Support",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"reporter-options": "configFile=.mocha-multi.json"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@adobe/helix-onedrive-support": "11.3.
|
|
34
|
+
"@adobe/helix-onedrive-support": "11.3.23",
|
|
35
35
|
"googleapis": "137.1.0",
|
|
36
36
|
"lru-cache": "10.2.2"
|
|
37
37
|
},
|
package/src/GoogleClient.d.ts
CHANGED
|
@@ -120,6 +120,14 @@ declare class GoogleClient {
|
|
|
120
120
|
*/
|
|
121
121
|
getItemFromPath(parentId:string, path:string, type?:string):Promise<DriveItemInfo>;
|
|
122
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Returns the (uncached) item for the given id or {@code null} if the item cannot be found.
|
|
125
|
+
*
|
|
126
|
+
* @param {string} fileId file id
|
|
127
|
+
* @returns {Promise<DriveItemInfo>}
|
|
128
|
+
*/
|
|
129
|
+
getUncachedItemFromId(fileId:string):Promise<DriveItemInfo>;
|
|
130
|
+
|
|
123
131
|
/**
|
|
124
132
|
* Returns an (uncached) file directly via the google api
|
|
125
133
|
* @param {string} fileId
|
|
@@ -168,21 +176,21 @@ declare class GoogleClient {
|
|
|
168
176
|
|
|
169
177
|
|
|
170
178
|
/**
|
|
171
|
-
*
|
|
172
|
-
* @param {string} spreadsheetId
|
|
173
|
-
* @param {string} sheetName
|
|
174
|
-
* @param {object} worksheetData
|
|
175
|
-
*
|
|
179
|
+
*
|
|
180
|
+
* @param {string} spreadsheetId
|
|
181
|
+
* @param {string} sheetName
|
|
182
|
+
* @param {object} worksheetData
|
|
183
|
+
*
|
|
176
184
|
* @returns {Promise<string>} sheetId or {@code null}
|
|
177
185
|
*/
|
|
178
186
|
updateSheet(spreadsheetId:string, sheetName:string, worksheetData:object, create:boolean):Promise<string>;
|
|
179
187
|
|
|
180
188
|
|
|
181
189
|
/**
|
|
182
|
-
*
|
|
183
|
-
* @param spreadsheetId
|
|
190
|
+
*
|
|
191
|
+
* @param spreadsheetId
|
|
184
192
|
* @param sheetName sheetName to delete in the spreadsheet
|
|
185
|
-
*
|
|
193
|
+
*
|
|
186
194
|
* @returns {Promise<void>}
|
|
187
195
|
*/
|
|
188
196
|
deleteSheet(spreadsheetId:string, sheetName:string):Promise<void>;
|
package/src/GoogleClient.js
CHANGED
|
@@ -411,39 +411,22 @@ export class GoogleClient {
|
|
|
411
411
|
*/
|
|
412
412
|
async getItemFromPath(parentId, path, type) {
|
|
413
413
|
if (!path) {
|
|
414
|
-
|
|
415
|
-
|
|
414
|
+
let item = lru.get(parentId);
|
|
415
|
+
if (!item) {
|
|
416
|
+
item = await this.getUncachedItemFromId(parentId);
|
|
416
417
|
if (!item) {
|
|
417
|
-
const { data } = (await this.drive.files.get({
|
|
418
|
-
fileId: parentId,
|
|
419
|
-
fields: [
|
|
420
|
-
'name',
|
|
421
|
-
'parents',
|
|
422
|
-
'mimeType',
|
|
423
|
-
'modifiedTime',
|
|
424
|
-
].join(','),
|
|
425
|
-
supportsAllDrives: true,
|
|
426
|
-
}));
|
|
427
|
-
item = addFields({
|
|
428
|
-
id: parentId,
|
|
429
|
-
path: `/${data.name}`,
|
|
430
|
-
}, data);
|
|
431
|
-
// todo: extend caching to all items ?
|
|
432
|
-
Object.defineProperty(item, 'invalidate', {
|
|
433
|
-
enumerable: false,
|
|
434
|
-
value() {
|
|
435
|
-
lru.delete(parentId);
|
|
436
|
-
},
|
|
437
|
-
});
|
|
438
|
-
lru.set(parentId, item);
|
|
439
|
-
}
|
|
440
|
-
return item;
|
|
441
|
-
} catch (e) {
|
|
442
|
-
if (e.response && e.response.status === 404) {
|
|
443
418
|
return null;
|
|
444
419
|
}
|
|
445
|
-
|
|
420
|
+
// todo: extend caching to all items ?
|
|
421
|
+
Object.defineProperty(item, 'invalidate', {
|
|
422
|
+
enumerable: false,
|
|
423
|
+
value() {
|
|
424
|
+
lru.delete(parentId);
|
|
425
|
+
},
|
|
426
|
+
});
|
|
427
|
+
lru.set(parentId, item);
|
|
446
428
|
}
|
|
429
|
+
return item;
|
|
447
430
|
}
|
|
448
431
|
|
|
449
432
|
const segs = createPathSegments(path);
|
|
@@ -455,6 +438,36 @@ export class GoogleClient {
|
|
|
455
438
|
return item;
|
|
456
439
|
}
|
|
457
440
|
|
|
441
|
+
/**
|
|
442
|
+
* Returns the (uncached) item for the given id or {@code null} if the item cannot be found.
|
|
443
|
+
*
|
|
444
|
+
* @param {string} fileId file id
|
|
445
|
+
* @returns {Promise<DriveItemInfo>}
|
|
446
|
+
*/
|
|
447
|
+
async getUncachedItemFromId(fileId) {
|
|
448
|
+
try {
|
|
449
|
+
const { data } = (await this.drive.files.get({
|
|
450
|
+
fileId,
|
|
451
|
+
fields: [
|
|
452
|
+
'name',
|
|
453
|
+
'parents',
|
|
454
|
+
'mimeType',
|
|
455
|
+
'modifiedTime',
|
|
456
|
+
].join(','),
|
|
457
|
+
supportsAllDrives: true,
|
|
458
|
+
}));
|
|
459
|
+
return addFields({
|
|
460
|
+
id: fileId,
|
|
461
|
+
path: `/${data.name}`,
|
|
462
|
+
}, data);
|
|
463
|
+
} catch (e) {
|
|
464
|
+
if (e.response && e.response.status === 404) {
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
throw e;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
458
471
|
/**
|
|
459
472
|
* Returns an (uncached) file directly via the google api
|
|
460
473
|
* @param {string} fileId
|