Skip to content

Commit

Permalink
Merge pull request #944 from OpenFn/release/gsheets
Browse files Browse the repository at this point in the history
Release: googlesheets
  • Loading branch information
josephjclark authored Jan 27, 2025
2 parents 328e483 + 813cafe commit 0d12173
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/googlesheets/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @openfn/language-googlesheets

## 3.0.9

### Patch Changes

- `update()` and `append()` will exit early with a gentle warning if an empty
array is passed. This allows a no-op update to be error free.

## 3.0.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/googlesheets/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-googlesheets",
"version": "3.0.8",
"version": "3.0.9",
"description": "A Google Sheets Language Pack for OpenFn",
"homepage": "https://docs.openfn.org",
"repository": {
Expand Down
10 changes: 10 additions & 0 deletions packages/googlesheets/src/Adaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ export function appendValues(params, callback = s => s) {
const [resolvedParams] = expandReferences(state, params);
const { spreadsheetId, range, values } = resolvedParams;

if (!values || values.length === 0) {
console.log('Warning: empty values array');
return state;
}

return new Promise((resolve, reject) => {
client.spreadsheets.values.append(
{
Expand Down Expand Up @@ -163,6 +168,11 @@ export function batchUpdateValues(params, callback = s => s) {
values,
} = resolvedParams;

if (!values || values.length === 0) {
console.log('Warning: empty values array');
return state;
}

const resource = {
data: [
{
Expand Down
32 changes: 32 additions & 0 deletions packages/googlesheets/test/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect } from 'chai';

import { execute } from '../src';
import { appendValues, batchUpdateValues } from '../src';

describe('execute', () => {
it('executes each operation in sequence', done => {
Expand Down Expand Up @@ -36,3 +37,34 @@ describe('execute', () => {
});
});
});


describe('append', () =>{
it('should return early if the values array is undefined or nullish', async() => {
const state = {
data: [],
}

const result = await appendValues({
spreadsheetId: '123-456-789',
range: 'Sheet!A1:E1',
values: state.values,
})(state);
expect(result).to.eql(state);
});
});

describe('batchUpdateValues', () =>{
it('should return early if the values array is undefined or nullish', async() => {
const state = {
data: [],
}

const result = await batchUpdateValues({
spreadsheetId: '123-456-789',
range: 'Sheet!A1:E1',
values: state.values,
})(state);
expect(result).to.eql(state);
});
});

0 comments on commit 0d12173

Please sign in to comment.