Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .changeset/new-things-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
'@openfn/language-googlesheets': major
---

Updated `appendValues()`, `batchUpdateValues()`, and `getValues()` to use positional arguments instead of a single params object.
Comment thread
hunterachieng marked this conversation as resolved.

### Migration Guide

**`appendValues`**

```js
// Before
appendValues({
spreadsheetId: '1abc...',
range: 'Sheet1!A1:E1',
values: [['a', 'b']],
});

// Now
appendValues(
'1abc...',
{ range: 'Sheet1!A1:E1', values: [['a', 'b']] },
);
```

**`batchUpdateValues`**

```js
// Before
batchUpdateValues({
spreadsheetId: '1abc...',
range: 'Sheet1!A1',
values: [['a']],
valueInputOption: 'RAW',
});

// Now
batchUpdateValues(
'1abc...',
[{ range: 'Sheet1!A1', values: [['a']] }],
{ valueInputOption: 'RAW' }
);
```

Callback parameter has been removed from `appendValues()`, `batchUpdateValues()`, and `getValues()` in favor of a promise-based API.

167 changes: 86 additions & 81 deletions packages/googlesheets/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
{
"name": "appendValues",
"params": [
"params",
"callback"
"spreadsheetId",
"data",
"options"
],
"docs": {
"description": "Add an array of rows to the spreadsheet.\nhttps://developers.google.com/sheets/api/samples/writing#append_values",
"description": "Append one or more rows to a spreadsheet range.\nhttps://developers.google.com/sheets/api/samples/writing#append_values",
"tags": [
{
"title": "public",
Expand All @@ -16,7 +17,7 @@
},
{
"title": "example",
"description": "appendValues({\n spreadsheetId: '1O-a4_RgPF_p8W3I6b5M9wobA3-CBW8hLClZfUik5sos',\n range: 'Sheet1!A1:E1',\n values: [\n ['From expression', '$15', '2', '3/15/2016'],\n ['Really now!', '$100', '1', '3/20/2016'],\n ],\n})"
"description": "appendValues(\n '1O-a4_RgPF_p8W3I6b5M9wobA3-CBW8hLClZfUik5sos',\n { range: 'Sheet1!A1:E1', values: [['From expression', '$15', '2', '3/15/2016'], ['Really now!', '$100', '1', '3/20/2016']] }\n)"
},
{
"title": "function",
Expand All @@ -25,57 +26,62 @@
},
{
"title": "param",
"description": "Data object to add to the spreadsheet.",
"description": "The spreadsheet ID.",
"type": {
"type": "NameExpression",
"name": "Object"
"name": "string"
},
"name": "params"
"name": "spreadsheetId"
},
{
"title": "param",
"description": "The spreadsheet ID.",
"description": "A single range/values object to append.",
"type": {
"type": "OptionalType",
"expression": {
"type": "NameExpression",
"name": "string"
}
"type": "RecordType",
"fields": [
{
"type": "FieldType",
"key": "range",
"value": {
"type": "NameExpression",
"name": "string"
}
},
{
"type": "FieldType",
"key": "values",
"value": {
"type": "NameExpression",
"name": "array"
}
}
]
},
"name": "params.spreadsheetId"
"name": "data"
},
{
"title": "param",
"description": "The range of values to update.",
"description": "Optional settings.",
"type": {
"type": "OptionalType",
"expression": {
"type": "NameExpression",
"name": "string"
"name": "Object"
}
},
"name": "params.range"
"name": "options"
},
{
"title": "param",
"description": "A 2d array of values to update.",
"description": "Defaults to 'USER_ENTERED'.",
"type": {
"type": "OptionalType",
"expression": {
"type": "NameExpression",
"name": "array"
"name": "string"
}
},
"name": "params.values"
},
{
"title": "param",
"description": "(Optional) Callback function",
"type": {
"type": "NameExpression",
"name": "function"
},
"name": "callback"
"name": "options.valueInputOption"
},
{
"title": "returns",
Expand All @@ -92,15 +98,22 @@
{
"name": "batchUpdateValues",
"params": [
"params",
"callback"
"spreadsheetId",
"data",
"options"
],
"docs": {
"description": "Batch update values in a Spreadsheet.",
"tags": [
{
"title": "example",
"description": "batchUpdateValues({\n spreadsheetId: '1O-a4_RgPF_p8W3I6b5M9wobA3-CBW8hLClZfUik5sos',\n range: 'Sheet1!A1:E1',\n values: [\n ['From expression', '$15', '2', '3/15/2016'],\n ['Really now!', '$100', '1', '3/20/2016'],\n ],\n})"
"description": "batchUpdateValues(\n '1O-a4_RgPF_p8W3I6b5M9wobA3-CBW8hLClZfUik5sos',\n [{ range: 'Sheet1!A1:E1', values: [['From expression', '$15'], ['Really now!', '$100']] }],\n { valueInputOption: 'RAW' }\n)",
"caption": "Update a single range"
},
{
"title": "example",
"description": "batchUpdateValues(\n '1O-a4_RgPF_p8W3I6b5M9wobA3-CBW8hLClZfUik5sos',\n [\n { range: 'Sheet1!A1', values: [['value1']] },\n { range: 'Sheet1!B5', values: [['value2']] },\n { range: 'Sheet1!D10:E11', values: [['a', 'b'], ['c', 'd']] },\n ],\n { valueInputOption: 'RAW' }\n)",
"caption": "Update multiple separate ranges"
},
{
"title": "function",
Expand All @@ -114,69 +127,71 @@
},
{
"title": "param",
"description": "Data object to add to the spreadsheet.",
"description": "The spreadsheet ID.",
"type": {
"type": "NameExpression",
"name": "Object"
"name": "string"
},
"name": "params"
"name": "spreadsheetId"
},
{
"title": "param",
"description": "The spreadsheet ID.",
"description": "Array of range/values objects to update.",
"type": {
"type": "OptionalType",
"type": "TypeApplication",
"expression": {
"type": "NameExpression",
"name": "string"
}
},
"name": "params.spreadsheetId"
},
{
"title": "param",
"description": "The range of values to update.",
"name": "Array"
},
"applications": [
{
"type": "RecordType",
"fields": [
{
"type": "FieldType",
"key": "range",
"value": {
"type": "NameExpression",
"name": "string"
}
},
{
"type": "FieldType",
"key": "values",
"value": {
"type": "NameExpression",
"name": "array"
}
}
]
}
]
},
"name": "data"
},
{
"title": "param",
"description": "Optional settings.",
"type": {
"type": "OptionalType",
"expression": {
"type": "NameExpression",
"name": "string"
"name": "Object"
}
},
"name": "params.range"
"name": "options"
},
{
"title": "param",
"description": "(Optional) Value update options. Defaults to 'USER_ENTERED'",
"description": "Defaults to 'USER_ENTERED'.",
"type": {
"type": "OptionalType",
"expression": {
"type": "NameExpression",
"name": "string"
}
},
"name": "params.valueInputOption"
},
{
"title": "param",
"description": "A 2d array of values to update.",
"type": {
"type": "OptionalType",
"expression": {
"type": "NameExpression",
"name": "array"
}
},
"name": "params.values"
},
{
"title": "param",
"description": "(Optional) callback function",
"type": {
"type": "NameExpression",
"name": "function"
},
"name": "callback"
"name": "options.valueInputOption"
},
{
"title": "returns",
Expand All @@ -194,8 +209,7 @@
"name": "getValues",
"params": [
"spreadsheetId",
"range",
"callback"
"range"
],
"docs": {
"description": "Gets cell values from a Spreadsheet.",
Expand Down Expand Up @@ -232,15 +246,6 @@
},
"name": "range"
},
{
"title": "param",
"description": "(Optional) callback function",
"type": {
"type": "NameExpression",
"name": "function"
},
"name": "callback"
},
{
"title": "returns",
"description": "spreadsheet information",
Expand Down
3 changes: 2 additions & 1 deletion packages/googlesheets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"chai": "4.3.6",
"deep-eql": "4.1.1",
"nock": "13.2.9",
"rimraf": "3.0.2"
"rimraf": "3.0.2",
"sinon": "^21.1.2"
},
"type": "module",
"types": "types/index.d.ts",
Expand Down
Loading
Loading