@adobe/helix-google-support 1.5.9 → 2.0.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 CHANGED
@@ -1,3 +1,29 @@
1
+ ## [2.0.1](https://github.com/adobe/helix-google-support/compare/v2.0.0...v2.0.1) (2022-08-22)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency googleapis to v107 ([#64](https://github.com/adobe/helix-google-support/issues/64)) ([5c0b0bc](https://github.com/adobe/helix-google-support/commit/5c0b0bccd99be2f48950558d3eaf5d7f418ef81e))
7
+
8
+ # [2.0.0](https://github.com/adobe/helix-google-support/compare/v1.5.10...v2.0.0) (2022-08-22)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * getFile() should return Buffer ([bd50867](https://github.com/adobe/helix-google-support/commit/bd50867e9b19aaa4d609203d876e39af57f2868d))
14
+
15
+
16
+ ### BREAKING CHANGES
17
+
18
+ * getFile and getFileFromPath now return a Buffer
19
+
20
+ ## [1.5.10](https://github.com/adobe/helix-google-support/compare/v1.5.9...v1.5.10) (2022-08-13)
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * **deps:** update dependency @adobe/helix-onedrive-support to v8.2.5 ([f1e86ea](https://github.com/adobe/helix-google-support/commit/f1e86ea0bf832fbdec412e45cba353a7785808b6))
26
+
1
27
  ## [1.5.9](https://github.com/adobe/helix-google-support/compare/v1.5.8...v1.5.9) (2022-08-10)
2
28
 
3
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-google-support",
3
- "version": "1.5.9",
3
+ "version": "2.0.1",
4
4
  "description": "Helix Google Support",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -30,16 +30,16 @@
30
30
  "reporter-options": "configFile=.mocha-multi.json"
31
31
  },
32
32
  "dependencies": {
33
- "@adobe/helix-onedrive-support": "8.2.4",
34
- "googleapis": "105.0.0",
35
- "lru-cache": "7.13.2"
33
+ "@adobe/helix-onedrive-support": "8.2.5",
34
+ "googleapis": "107.0.0",
35
+ "lru-cache": "7.14.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@adobe/eslint-config-helix": "1.3.2",
39
39
  "@semantic-release/changelog": "6.0.1",
40
40
  "@semantic-release/git": "10.0.1",
41
41
  "c8": "7.12.0",
42
- "eslint": "8.21.0",
42
+ "eslint": "8.22.0",
43
43
  "eslint-plugin-header": "3.1.1",
44
44
  "eslint-plugin-import": "2.26.0",
45
45
  "husky": "8.0.1",
@@ -48,7 +48,7 @@
48
48
  "mocha": "10.0.0",
49
49
  "mocha-multi-reporters": "1.5.1",
50
50
  "nock": "13.2.9",
51
- "semantic-release": "19.0.3"
51
+ "semantic-release": "19.0.4"
52
52
  },
53
53
  "lint-staged": {
54
54
  "*.js": "eslint",
@@ -9,6 +9,8 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
+ import { Buffer } from 'node:buffer';
13
+
12
14
  declare interface ICachePlugin {}
13
15
 
14
16
  declare interface DriveItemInfo {}
@@ -121,9 +123,9 @@ declare class GoogleClient {
121
123
  /**
122
124
  * Returns an (uncached) file directly via the google api
123
125
  * @param {string} fileId
124
- * @returns {Promise<string>} file data
126
+ * @returns {Promise<Buffer>} file data
125
127
  */
126
- getFile(fileId:string):Promise<string>;
128
+ getFile(fileId:string):Promise<Buffer>;
127
129
 
128
130
  /**
129
131
  * Fetches the file data from the give path. If the file with the internal id could not be
@@ -133,9 +135,9 @@ declare class GoogleClient {
133
135
  * @param {string} path
134
136
  * @param {boolean} noRetry {@code true} to avoid retry
135
137
  * @param {string} [type] optional file mimetype filter.
136
- * @returns {Promise<string>|null} The data of the file or {@code null} if the file does not exist
138
+ * @returns {Promise<Buffer>|null} The data of the file or {@code null} if the file does not exist
137
139
  */
138
- getFileFromPath(parentId:string, path:string, noRetry:boolean, type?:string):Promise<string>;
140
+ getFileFromPath(parentId:string, path:string, noRetry:boolean, type?:string):Promise<Buffer>;
139
141
 
140
142
  /**
141
143
  * Returns an (uncached) document directly via the google docs api
@@ -443,19 +443,23 @@ export class GoogleClient {
443
443
  /**
444
444
  * Returns an (uncached) file directly via the google api
445
445
  * @param {string} fileId
446
- * @returns {Promise<string>} file data
446
+ * @returns {Promise<Buffer>} file data
447
447
  */
448
448
  async getFile(fileId) {
449
449
  try {
450
450
  const res = await this.drive.files.get({
451
451
  fileId,
452
452
  alt: 'media',
453
- });
454
- return res.data;
453
+ }, { responseType: 'arraybuffer' });
454
+ return Buffer.from(res.data);
455
455
  } catch (e) {
456
456
  if (e.response && e.response.status === 404) {
457
457
  throw new StatusCodeError(`Not Found: ${fileId}`, 404);
458
458
  }
459
+ // convert message to string
460
+ if (e.message instanceof ArrayBuffer) {
461
+ e.message = Buffer.from(e.message).toString('utf-8');
462
+ }
459
463
  throw e;
460
464
  }
461
465
  }
@@ -468,7 +472,7 @@ export class GoogleClient {
468
472
  * @param {string} path
469
473
  * @param {boolean} noRetry {@code true} to avoid retry
470
474
  * @param {string} [type] optional file mimetype
471
- * @returns {Promise<string>|null} The data of the file or {@code null} if the file does not exist
475
+ * @returns {Promise<Buffer>|null} The data of the file or {@code null} if the file does not exist
472
476
  */
473
477
  async getFileFromPath(parentId, path, noRetry, type) {
474
478
  const item = await this.getItemFromPath(parentId, path, type);