Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

google-spreadsheet

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-spreadsheet - npm Package Compare versions

Comparing version 3.0.13 to 3.0.14

21

lib/GoogleSpreadsheet.js

@@ -34,3 +34,3 @@ const _ = require('lodash');

this.axios = Axios.create({
baseURL: `https://sheets.googleapis.com/v4/spreadsheets/${sheetId}`,
baseURL: `https://sheets.googleapis.com/v4/spreadsheets/${sheetId || ''}`,
// send arrays in params with duplicate keys - ie `?thing=1&thing=2` vs `?thing[]=1...`

@@ -63,2 +63,19 @@ // solution taken from https://github.com/axios/axios/issues/604

// CREATE NEW DOC ////////////////////////////////////////////////////////////////////////////////
async createNewSpreadsheetDocument(properties) {
// see updateProperties for more info about available properties
if (this.spreadsheetId) {
throw new Error('Only call `createNewSpreadsheetDocument()` on a GoogleSpreadsheet object that has no spreadsheetId set');
}
const response = await this.axios.post(this.url, {
properties,
});
this.spreadsheetId = response.data.spreadsheetId;
this.axios.defaults.baseURL += this.spreadsheetId;
this._rawProperties = response.data.properties;
_.each(response.data.sheets, (s) => this._updateOrCreateSheet(s));
}
// AUTH RELATED FUNCTIONS ////////////////////////////////////////////////////////////////////////

@@ -177,3 +194,3 @@ async useApiKey(key) {

_ensureInfoLoaded() {
if (!this._rawProperties) throw new Error('You must call `sheet.loadInfo()` before accessing this property');
if (!this._rawProperties) throw new Error('You must call `doc.loadInfo()` before accessing this property');
}

@@ -180,0 +197,0 @@

@@ -556,10 +556,29 @@ const _ = require('lodash');

async mergeCells() {
async mergeCells(range, mergeType = 'MERGE_ALL') {
// Request type = `mergeCells`
// https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#MergeCellsRequest
if (range.sheetId && range.sheetId !== this.sheetId) {
throw new Error('Leave sheet ID blank or set to matching ID of this sheet');
}
await this._makeSingleUpdateRequest('mergeCells', {
mergeType,
range: {
...range,
sheetId: this.sheetId,
},
});
}
async unmergeCells() {
async unmergeCells(range) {
// Request type = `unmergeCells`
// https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#UnmergeCellsRequest
if (range.sheetId && range.sheetId !== this.sheetId) {
throw new Error('Leave sheet ID blank or set to matching ID of this sheet');
}
await this._makeSingleUpdateRequest('unmergeCells', {
range: {
...range,
sheetId: this.sheetId,
},
});
}

@@ -566,0 +585,0 @@

4

package.json

@@ -5,3 +5,3 @@ {

"description": "Google Sheets API (v4) -- simple interface to read/write data and manage sheets",
"version": "3.0.13",
"version": "3.0.14",
"license": "Unlicense",

@@ -31,3 +31,3 @@ "keywords": [

"axios": "^0.19.2",
"google-auth-library": "^6.0.6",
"google-auth-library": "^6.1.3",
"lodash": "^4.17.20"

@@ -34,0 +34,0 @@ },

@@ -19,3 +19,3 @@ # google-spreadsheet

>
> Google is [phasing out their old v3 api](https://cloud.google.com/blog/products/g-suite/migrate-your-apps-use-latest-sheets-api), which the older version of this module used to use. Originally they were going to shut it down on March 3rd 2020, but have pushed that date back to September 30th.
> Google is [phasing out their old v3 api](https://cloud.google.com/blog/products/g-suite/migrate-your-apps-use-latest-sheets-api), which the older version of this module used to use. Originally they were going to shut it down on March 3rd 2020, but have pushed that date back to January 2021.

@@ -27,3 +27,3 @@

> 🌈 **Installation** - `npm i google-spreadsheet --save`
> 🌈 **Installation** - `npm i google-spreadsheet --save` or `yarn add google-spreadsheet`

@@ -33,2 +33,11 @@ ## Examples

!> NOTE - To keep the examples more concise, I'm calling await [at the top level](https://v8.dev/features/top-level-await) which is not allowed by default in most versions of node. If you need to call await in a script at the root level, you must instead wrap it in an async function like so:
```javascript
(async function() {
await someAsyncFunction();
}());
```
### The Basics

@@ -57,3 +66,3 @@ ```javascript

const sheet = doc.sheetsByIndex[0]; // or use doc.sheetsById[id]
const sheet = doc.sheetsByIndex[0]; // or use doc.sheetsById[id] or doc.sheetsByTitle[title]
console.log(sheet.title);

@@ -60,0 +69,0 @@ console.log(sheet.rowCount);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc