Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 0 additions & 3 deletions components/google_appsheet/.gitignore

This file was deleted.

19 changes: 19 additions & 0 deletions components/google_appsheet/actions/add-row/add-row.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import common from "../common/base.mjs";

export default {
...common,
key: "google_appsheet-add-row",
name: "Add Row",
description: "Adds a new row to a specific table in the AppSheet app. [See the documentation](https://support.google.com/appsheet/answer/10104797?hl=en&ref_topic=10105767&sjid=1665780.0.1444403316-SA#)",
version: "0.0.1",
type: "action",
methods: {
...common.methods,
getAction() {
return "Add";
},
getSummary() {
return "Added a new row successfully";
},
},
};
47 changes: 47 additions & 0 deletions components/google_appsheet/actions/common/base.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { parseObject } from "../../common/utils.mjs";
import appsheet from "../../google_appsheet.app.mjs";

export default {
props: {
appsheet,
tableName: {
propDefinition: [
appsheet,
"tableName",
],
},
row: {
propDefinition: [
appsheet,
"row",
],
},
},
methods: {
getData() {
return {};
},
},
async run({ $ }) {
const dataRow = parseObject(this.row);
const rows = dataRow
? [
dataRow,
]
: [];

const response = await this.appsheet.post({
$,
tableName: this.tableName,
data: {
Action: this.getAction(),
Rows: rows,
...this.getData(),
},
});
console.log("response: ", response);

$.export("$summary", this.getSummary(response));
return response;
},
};
35 changes: 35 additions & 0 deletions components/google_appsheet/actions/delete-row/delete-row.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import common from "../common/base.mjs";

export default {
...common,
key: "google_appsheet-delete-row",
name: "Delete Row",
description: "Deletes a specific row from a table in the AppSheet app. [See the documentation](https://support.google.com/appsheet/answer/10105399?hl=en&ref_topic=10105767&sjid=1665780.0.1444403316-SA)",
version: "0.0.1",
type: "action",
props: {
...common.props,
alert: {

Check warning on line 12 in components/google_appsheet/actions/delete-row/delete-row.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

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

Check warning on line 12 in components/google_appsheet/actions/delete-row/delete-row.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a description. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: "The `Row` value may contain field values of the key field values of the record to be deleted.",
},
row: {
propDefinition: [
common.props.appsheet,
"row",
],
description: "The `Row` value may contain field values of the key field values of the record to be deleted.",
optional: true,
},
},
methods: {
...common.methods,
getAction() {
return "Delete";
},
getSummary(response) {
return `${response.Rows.length} successfully delete!`;
},
},
};
45 changes: 45 additions & 0 deletions components/google_appsheet/actions/get-rows/get-rows.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import common from "../common/base.mjs";

export default {
...common,
key: "google_appsheet-get-rows",
name: "Get Rows",
description: "Read existing records in a table in the AppSheet app. [See the documentation](https://support.google.com/appsheet/answer/10104797?hl=en&ref_topic=10105767&sjid=1665780.0.1444403316-SA#)",
version: "0.0.1",
type: "action",
props: {
...common.props,
selector: {
type: "string",
label: "Selector",
description: "You can specify an expression to select and format the rows returned. **Example: Filter(TableName, [Column] = \"Value\")** [See the documentation](https://support.google.com/appsheet/answer/10105770?hl=en&ref_topic=10105767&sjid=3242006823758562345-NC)",
optional: true,
},
row: {
propDefinition: [
common.props.appsheet,
"row",
],
description: "You can also filter the results using the `Row` value. The `Row` value may contain field values of the key field values of the record to be retrieved. **Example:** `{ \"First Name\": \"John\" }`",
optional: true,
},
},
methods: {
...common.methods,
getAction() {
return "Find";
},
getData() {
return this.selector
? {
Properties: {
Selector: this.selector,
},
}
: {};
},
getSummary(response) {
return `Successfully retrieved ${ response.length || 0} rows`;
},
},
};
29 changes: 29 additions & 0 deletions components/google_appsheet/actions/update-row/update-row.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import common from "../common/base.mjs";

export default {
...common,
key: "google_appsheet-update-row",
name: "Update Row",
description: "Updates an existing row in a specific table in the AppSheet app. [See the documentation](https://support.google.com/appsheet/answer/10105002?hl=en&ref_topic=10105767&sjid=1665780.0.1444403316-SA)",
version: "0.0.1",
type: "action",
props: {
...common.props,
alert: {

Check warning on line 12 in components/google_appsheet/actions/update-row/update-row.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

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

Check warning on line 12 in components/google_appsheet/actions/update-row/update-row.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a description. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: `The \`Row\` value must include the key field values of the record to be updated.
\nThe \`Row\` value may contain one or more field values of other fields to be updated in the record.
\nIf a field's name is omitted, that field's value is not changed. If the field can be assigned a string value and the field value you specify is "" then the field's value will be cleared.`,
},
},
methods: {
...common.methods,
getAction() {
return "Edit";
},
getSummary(response) {
return `${response.Rows.length} successfully updated!`;
},
},
};
13 changes: 0 additions & 13 deletions components/google_appsheet/app/google_appsheet.app.ts

This file was deleted.

24 changes: 24 additions & 0 deletions components/google_appsheet/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export const parseObject = (obj) => {
if (!obj) return undefined;

if (Array.isArray(obj)) {
return obj.map((item) => {
if (typeof item === "string") {
try {
return JSON.parse(item);
} catch (e) {
return item;
}
}
return item;
});
}
if (typeof obj === "string") {
try {
return JSON.parse(obj);
} catch (e) {
return obj;
}
}
return obj;
};
43 changes: 43 additions & 0 deletions components/google_appsheet/google_appsheet.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "google_appsheet",
propDefinitions: {
tableName: {
type: "string",
label: "Table Name",
description: "Name of the table. **Select Data > Tables** and expand the table details to view the table name.",
},
row: {
type: "object",
label: "Row",
description: "JSON object representing the row data",
},
},
methods: {
_baseUrl(tableName) {
return `https://api.appsheet.com/api/v2/apps/${this.$auth.app_id}/tables/${encodeURIComponent(tableName)}/Action`;
},
_headers() {
return {
"ApplicationAccessKey": `${this.$auth.api_key}`,
};
},
_makeRequest({
$ = this, tableName, ...opts
}) {
return axios($, {
url: this._baseUrl(tableName),
headers: this._headers(),
...opts,
});
},
post(opts = {}) {
return this._makeRequest({
method: "POST",
...opts,
});
},
},
};
10 changes: 5 additions & 5 deletions components/google_appsheet/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "@pipedream/google_appsheet",
"version": "0.0.3",
"version": "0.1.0",
"description": "Pipedream Google Appsheet Components",
"main": "dist/app/google_appsheet.app.mjs",
"main": "google_appsheet.app.mjs",
"keywords": [
"pipedream",
"google_appsheet"
],
"files": [
"dist"
],
"homepage": "https://pipedream.com/apps/google_appsheet",
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
8 changes: 7 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading