@adobe/helix-google-support 3.3.0 → 3.3.2

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,17 @@
1
+ ## [3.3.2](https://github.com/adobe/helix-google-support/compare/v3.3.1...v3.3.2) (2025-06-17)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency googleapis-common to v8 ([#492](https://github.com/adobe/helix-google-support/issues/492)) ([75c0148](https://github.com/adobe/helix-google-support/commit/75c01485a9fa8593015fb2f85d583a855ee5e281))
7
+
8
+ ## [3.3.1](https://github.com/adobe/helix-google-support/compare/v3.3.0...v3.3.1) (2025-06-16)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * make `googleapis` import exact ([bde5ec1](https://github.com/adobe/helix-google-support/commit/bde5ec16538ba2634ac77dab716a2d8e0b99af41))
14
+
1
15
  # [3.3.0](https://github.com/adobe/helix-google-support/compare/v3.2.17...v3.3.0) (2025-06-16)
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.0",
3
+ "version": "3.3.2",
4
4
  "description": "Helix Google Support",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -35,14 +35,14 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@adobe/helix-shared-string": "^2.1.0",
38
- "googleapis": "^149.0.0",
39
- "googleapis-common": "7.2.0",
38
+ "googleapis": "150.0.1",
39
+ "googleapis-common": "8.0.0",
40
40
  "lru-cache": "^11.0.2"
41
41
  },
42
42
  "devDependencies": {
43
- "@adobe/eslint-config-helix": "3.0.3",
43
+ "@adobe/eslint-config-helix": "3.0.4",
44
44
  "@adobe/helix-shared-tokencache": "1.5.0",
45
- "@eslint/config-helpers": "0.2.2",
45
+ "@eslint/config-helpers": "0.2.3",
46
46
  "@semantic-release/changelog": "6.0.3",
47
47
  "@semantic-release/git": "10.0.1",
48
48
  "c8": "10.1.3",
@@ -51,7 +51,7 @@
51
51
  "eslint-plugin-import": "2.31.0",
52
52
  "husky": "9.1.7",
53
53
  "junit-report-builder": "5.1.1",
54
- "lint-staged": "16.1.0",
54
+ "lint-staged": "16.1.2",
55
55
  "mocha": "11.6.0",
56
56
  "mocha-multi-reporters": "1.5.1",
57
57
  "mocha-suppress-logs": "0.5.1",
@@ -64,6 +64,20 @@ function getCacheKey(parentId, pathSegments, type = 'file') {
64
64
  return `${parentId}:${pathSegments.join('/')}:${type}`;
65
65
  }
66
66
 
67
+ /**
68
+ * Replaces a generic error message `Request failed with status code ...` with
69
+ * a more descriptive one found in the response itself.
70
+ *
71
+ * @param {Error} e error
72
+ * @returns processed error
73
+ */
74
+ function processError(e) {
75
+ if (/^Request failed with status code /.test(e.message) && e.response?.data?.error?.message) {
76
+ e.message = e.response.data.error.message;
77
+ }
78
+ return e;
79
+ }
80
+
67
81
  /**
68
82
  * Google auth client
69
83
  */
@@ -393,12 +407,13 @@ export class GoogleClient {
393
407
  try {
394
408
  return await this.getItems(fileId, roots);
395
409
  } catch (e) {
396
- if (e.response && e.response.status === 404) {
410
+ const err = processError(e);
411
+ if (err.response && err.response.status === 404) {
397
412
  log.info(`unable to get items for ${fileId}. Not found`);
398
413
  return [];
399
414
  }
400
- log.warn(`unable to get items for ${fileId}. ${e}`);
401
- throw e;
415
+ log.warn(`unable to get items for ${fileId}. ${err}`);
416
+ throw err;
402
417
  }
403
418
  }
404
419
 
@@ -463,10 +478,11 @@ export class GoogleClient {
463
478
  path: `/${data.name}`,
464
479
  }, data);
465
480
  } catch (e) {
466
- if (e.response && e.response.status === 404) {
481
+ const err = processError(e);
482
+ if (err.response && err.response.status === 404) {
467
483
  return null;
468
484
  }
469
- throw e;
485
+ throw err;
470
486
  }
471
487
  }
472
488
 
@@ -484,15 +500,16 @@ export class GoogleClient {
484
500
  }, { ...(this.googleApiOpts || {}), responseType: 'arraybuffer' });
485
501
  return Buffer.from(res.data);
486
502
  } catch (e) {
487
- if (e.response && e.response.status === 404) {
503
+ const err = processError(e);
504
+ if (err.response && err.response.status === 404) {
488
505
  throw new StatusCodeError(`Not Found: ${fileId}`, 404);
489
506
  }
490
507
  // convert message to string
491
508
  /* c8 ignore next 3 */
492
- if (e.message instanceof ArrayBuffer) {
493
- e.message = Buffer.from(e.message).toString('utf-8');
509
+ if (err.message instanceof ArrayBuffer) {
510
+ err.message = Buffer.from(err.message).toString('utf-8');
494
511
  }
495
- throw e;
512
+ throw err;
496
513
  }
497
514
  }
498
515
 
@@ -516,6 +533,7 @@ export class GoogleClient {
516
533
  return await this.getFile(item.id);
517
534
  } catch (e) {
518
535
  if (e.statusCode === 404) {
536
+ // this is a StatusCodeError we threw ourselves in `getFile`
519
537
  if (noRetry) {
520
538
  return null;
521
539
  }
@@ -542,10 +560,11 @@ export class GoogleClient {
542
560
  const res = await docs.documents.get({ documentId });
543
561
  return res.data;
544
562
  } catch (e) {
545
- if (e.response && e.response.status === 404) {
563
+ const err = processError(e);
564
+ if (err.response && err.response.status === 404) {
546
565
  throw new StatusCodeError(`Not Found: ${documentId}`, 404);
547
566
  }
548
- throw e;
567
+ throw err;
549
568
  }
550
569
  }
551
570
 
@@ -568,6 +587,7 @@ export class GoogleClient {
568
587
  return await this.getDocument(item.id);
569
588
  } catch (e) {
570
589
  if (e.statusCode === 404) {
590
+ // this is a StatusCodeError we threw ourselves in `getDocument`
571
591
  if (noRetry) {
572
592
  return null;
573
593
  }
@@ -611,7 +631,7 @@ export class GoogleClient {
611
631
  return response.data;
612
632
  } catch (e) {
613
633
  this.log.info(`Error creating file ${name}`);
614
- throw e;
634
+ throw processError(e);
615
635
  }
616
636
  }
617
637
 
@@ -682,9 +702,9 @@ export class GoogleClient {
682
702
  });
683
703
  }
684
704
  return sheetId;
685
- } catch (error) {
686
- this.log.info(`Error in updating sheet: ${error.message}`);
687
- throw error;
705
+ } catch (e) {
706
+ this.log.info(`Error in updating sheet: ${e.message}`);
707
+ throw processError(e);
688
708
  }
689
709
  }
690
710
 
@@ -721,9 +741,9 @@ export class GoogleClient {
721
741
  ],
722
742
  },
723
743
  });
724
- } catch (error) {
725
- this.log.info(`Error deleting sheet from spreadsheet: ${error.message}`);
726
- throw error;
744
+ } catch (e) {
745
+ this.log.info(`Error deleting sheet from spreadsheet: ${e.message}`);
746
+ throw processError(e);
727
747
  }
728
748
  }
729
749
  }