Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import app from "../../google_sheets.app.mjs";

export default {
key: "google_sheets-insert-dimension",
name: "Insert Dimension",
description: "Insert a dimension into a spreadsheet. [See the documentation](https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request#InsertDimensionRequest)",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
type: "action",
props: {
app,
drive: {
propDefinition: [
app,
"watchedDrive",
],
},
sheetId: {
propDefinition: [
app,
"sheetID",
(c) => ({
driveId: app.methods.getDriveId(c.drive),
}),
],
},
dimension: {
type: "string",
label: "Dimension",
description: "The dimension to insert",
options: [
{
label: "Operates on the rows of a sheet",
value: "ROWS",
},
{
label: "Operates on the columns of a sheet",
value: "COLUMNS",
},
],
},
startIndex: {
type: "integer",
label: "Start Index",
description: "The start (inclusive) of the span, or not set if unbounded",
optional: true,
},
endIndex: {
type: "integer",
label: "End Index",
description: "The end (exclusive) of the span",
},
inheritFromBefore: {
type: "boolean",
label: "Inherit From Before",
description: `Whether dimension properties should be extended from the dimensions before or after the newly inserted dimensions. True to inherit from the dimensions before (in which case the start index must be greater than 0), and false to inherit from the dimensions after.
For example, if row index 0 has red background and row index 1 has a green background, then inserting 2 rows at index 1 can inherit either the green or red background. If **inheritFromBefore** is true, the two new rows will be red (because the row before the insertion point was red), whereas if **inheritFromBefore** is false, the two new rows will be green (because the row after the insertion point was green).`,
default: false,
},
},
async run({ $ }) {
const response = await this.app.insertDimension( this.sheetId, {
range: {
dimension: this.dimension,
startIndex: this.startIndex,
endIndex: this.endIndex,
},
inheritFromBefore: this.inheritFromBefore,
});
$.export("$summary", "Successfully inserted dimension request");
return response;
},
};
74 changes: 74 additions & 0 deletions components/google_sheets/actions/move-dimension/move-dimension.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import app from "../../google_sheets.app.mjs";

export default {
key: "google_sheets-move-dimension",
name: "Move Dimension",
description: "Move a dimension in a spreadsheet. [See the documentation](https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request#MoveDimensionRequest)",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
type: "action",
props: {
app,
drive: {
propDefinition: [
app,
"watchedDrive",
],
},
sheetId: {
propDefinition: [
app,
"sheetID",
(c) => ({
driveId: app.methods.getDriveId(c.drive),
}),
],
},
dimension: {
type: "string",
label: "Dimension",
description: "The dimension to insert",
options: [
{
label: "Operates on the rows of a sheet",
value: "ROWS",
},
{
label: "Operates on the columns of a sheet",
value: "COLUMNS",
},
],
},
startIndex: {
type: "integer",
label: "Start Index",
description: "The start (inclusive) of the span",
},
endIndex: {
type: "integer",
label: "End Index",
description: "The end (exclusive) of the span",
},
destinationIndex: {
type: "integer",
label: "Destination Index",
description: "The zero-based start index of where to move the source data to, based on the coordinates *before* the source data is removed from the grid. Existing data will be shifted down or right (depending on the dimension) to make room for the moved dimensions. The source dimensions are removed from the grid, so the the data may end up in a different index than specified. For example, given `A1..A5` of `0, 1, 2, 3, 4` and wanting to move `\"1\"` and `\"2\"` to between `\"3\"` and `\"4\"`, the source would be `ROWS [1..3)`,and the destination index would be `\"4\"` (the zero-based index of row 5). The end result would be `A1..A5` of `0, 3, 1, 2, 4`",
},
},
async run({ $ }) {
const response = await this.app.moveDimension( this.sheetId, {
source: {
dimension: this.dimension,
startIndex: this.startIndex,
endIndex: this.endIndex,
},
destinationIndex: this.destinationIndex,
});
$.export("$summary", "Successfully moved dimension");
return response;
},
};
50 changes: 45 additions & 5 deletions components/google_sheets/google_sheets.app.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { axios } from "@pipedream/platform";
import sheets from "@googleapis/sheets";
import googleDrive from "@pipedream/google_drive";
import { axios } from "@pipedream/platform";
import get from "lodash/get.js";
import isArray from "lodash/isArray.js";
import isEmpty from "lodash/isEmpty.js";
import isString from "lodash/isString.js";
import {
INSERT_DATA_OPTION, VALUE_INPUT_OPTION,
} from "./common/constants.mjs";
import isArray from "lodash/isArray.js";
import get from "lodash/get.js";
import isString from "lodash/isString.js";
import isEmpty from "lodash/isEmpty.js";

export default {
...googleDrive,
Expand Down Expand Up @@ -44,12 +44,12 @@
label: "Row Values",
description: "Provide an array of arrays",
},
rowsDescription: {

Check warning on line 47 in components/google_sheets/google_sheets.app.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop rowsDescription must have a description. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 47 in components/google_sheets/google_sheets.app.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop rowsDescription must have a label. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "neutral",
content: "Each nested array should represent a row, with each element of the nested array representing a cell/column value (e.g., passing `[[\"Foo\",1,2],[\"Bar\",3,4]]` will insert two rows of data with three columns each). The most common pattern is to reference an array of arrays exported by a previous step (e.g., `{{steps.foo.$return_value}}`). You may also enter or construct a string that will `JSON.parse()` to an array of arrays.",
},
headersDisplay: {

Check warning on line 52 in components/google_sheets/google_sheets.app.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop headersDisplay must have a description. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 52 in components/google_sheets/google_sheets.app.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop headersDisplay must have a label. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: "",
Expand Down Expand Up @@ -419,6 +419,46 @@
const sheets = this.sheets();
return (await sheets.spreadsheets.sheets.copyTo(request)).data;
},
/**
* https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/insertDimension
*
* Inserts a dimension and returns the properties of the newly inserted dimension.
* @returns {object} Contains an instance of DimensionProperties.
* @param {string} spreadsheetId - ID of the spreadsheet in which to insert a dimension.
* @param {object} data - An object containing information about the dimension to insert.
*/
async insertDimension(spreadsheetId, data = {}) {
return (await this.batchUpdate({
spreadsheetId,
requestBody: {
requests: [
{
insertDimension: data,
},
],
},
})).replies[0];
},
/**
* https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/moveDimension
*
* Moves a dimension and returns the properties of the newly moved dimension.
* @returns {object} Contains an instance of DimensionProperties.
* @param {string} spreadsheetId - ID of the spreadsheet in which to move a dimension.
* @param {object} data - An object containing information about the dimension to move.
*/
async moveDimension(spreadsheetId, data = {}) {
return (await this.batchUpdate({
spreadsheetId,
requestBody: {
requests: [
{
moveDimension: data,
},
],
},
})).replies[0];
},
/**
* https://developers.google.com/drive/api/v3/reference/files/copy
*
Expand Down
2 changes: 1 addition & 1 deletion components/google_sheets/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/google_sheets",
"version": "0.9.3",
"version": "0.10.0",
"description": "Pipedream Google_sheets Components",
"main": "google_sheets.app.mjs",
"keywords": [
Expand Down
Loading