Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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/zoho_sheet/.gitignore

This file was deleted.

54 changes: 54 additions & 0 deletions components/zoho_sheet/actions/create-row/create-row.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { parseObject } from "../../common/utils.mjs";
import zohoSheet from "../../zoho_sheet.app.mjs";

export default {
key: "zoho_sheet-create-row",
name: "Create Row",
description: "Creates a new row in the specified worksheet. [See the documentation](https://www.zoho.com/sheet/help/api/v2/)",
version: "0.0.1",
type: "action",
props: {
zohoSheet,
workbookId: {
propDefinition: [
zohoSheet,
"workbookId",
],
},
worksheet: {
propDefinition: [
zohoSheet,
"worksheet",
({ workbookId }) => ({
workbookId,
}),
],
},
headerRow: {
type: "integer",
label: "Header Row",
description: "Default value is 1. This can be mentioned if the table header is not in the first row of the worksheet.",
optional: true,
},
data: {
propDefinition: [
zohoSheet,
"data",
],
},
},
async run({ $ }) {
const response = await this.zohoSheet.createRow({
$,
workbookId: this.workbookId,
data: {
worksheet_id: this.worksheet,
header_row: this.headerRow || 1,
json_data: JSON.stringify(parseObject(this.data)),
},
});

$.export("$summary", `Successfully created a row in the worksheet: ${response.sheet_name}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { ConfigurationError } from "@pipedream/platform";
import { parseObject } from "../../common/utils.mjs";
import zohoSheet from "../../zoho_sheet.app.mjs";

export default {
key: "zoho_sheet-search-delete-row",
name: "Search and Delete Row",
description: "Searches for a row based on provided criteria and deletes it. [See the documentation](https://www.zoho.com/sheet/help/api/v2/)",
version: "0.0.1",
type: "action",
props: {
zohoSheet,
workbookId: {
propDefinition: [
zohoSheet,
"workbookId",
],
},
worksheet: {
propDefinition: [
zohoSheet,
"worksheet",
({ workbookId }) => ({
workbookId,
}),
],
},
headerRow: {
propDefinition: [
zohoSheet,
"headerRow",
],
optional: true,
},
criteria: {
propDefinition: [
zohoSheet,
"criteria",
],
optional: true,
},
rowArray: {
type: "integer[]",
label: "Row Array",
description: "Array of row indexs, which needs to be deleted.",
optional: true,
},
firstMatchOnly: {
propDefinition: [
zohoSheet,
"firstMatchOnly",
],
},
isCaseSensitive: {
propDefinition: [
zohoSheet,
"isCaseSensitive",
],
},
deleteRows: {
type: "boolean",
label: "Delete Rows",
description: "If true it will delete the rows completely, otherwise the records are only erased by default.",
default: false,
},
},
async run({ $ }) {
if (!this.criteria && !this.rowArray) {
throw new ConfigurationError("You must provide at least **Criteria** or **Row Array** to process this request.");
}
const response = await this.zohoSheet.deleteRow({
$,
workbookId: this.workbookId,
data: {
worksheet_id: this.worksheet,
header_row: this.headerRow,
criteria: this.criteria,
row_array: JSON.stringify(parseObject(this.rowArray)),
first_match_only: this.firstMatchOnly,
is_case_sensitive: this.isCaseSensitive,
delete_rows: this.deleteRows,
},
});

$.export("$summary", `Row matching criteria deleted successfully from worksheet ${this.worksheet}`);
return response;
},
};
81 changes: 81 additions & 0 deletions components/zoho_sheet/actions/update-row/update-row.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { parseObject } from "../../common/utils.mjs";
import zohoSheet from "../../zoho_sheet.app.mjs";

export default {
key: "zoho_sheet-update-row",
name: "Update Row",
description: "Finds a specific row by its index and updates its content. [See the documentation](https://www.zoho.com/sheet/help/api/v2/)",
version: "0.0.1",
type: "action",
props: {
zohoSheet,
workbookId: {
propDefinition: [
zohoSheet,
"workbookId",
],
},
worksheet: {
propDefinition: [
zohoSheet,
"worksheet",
({ workbookId }) => ({
workbookId,
}),
],
},
headerRow: {
propDefinition: [
zohoSheet,
"headerRow",
],
optional: true,
},
criteria: {
propDefinition: [
zohoSheet,
"criteria",
],
description: "If criteria is not set all available rows will get updated. Mention the criteria as described above.",
optional: true,
},
firstMatchOnly: {
propDefinition: [
zohoSheet,
"firstMatchOnly",
],
description: "If true and if there are multiple records on the specified criteria, records will be updated for first match alone. Otherwise, all the matched records will be updated.",
},
isCaseSensitive: {
propDefinition: [
zohoSheet,
"isCaseSensitive",
],
},
data: {
propDefinition: [
zohoSheet,
"data",
],
type: "object",
description: "The JSON data that needs to be updated. Example:{\"Month\":\"May\",\"Amount\":50}",
},
},
async run({ $ }) {
const response = await this.zohoSheet.updateRow({
$,
workbookId: this.workbookId,
data: {
worksheet_id: this.worksheet,
header_row: this.headerRow,
criteria: this.criteria,
first_match_only: this.firstMatchOnly,
is_case_sensitive: this.isCaseSensitive,
data: JSON.stringify(parseObject(this.data)),
},
});

$.export("$summary", `Successfully updated ${response.no_of_affected_rows} row(s) in worksheet ${this.worksheet}`);
return response;
},
};
13 changes: 0 additions & 13 deletions components/zoho_sheet/app/zoho_sheet.app.ts

This file was deleted.

24 changes: 24 additions & 0 deletions components/zoho_sheet/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;
};
10 changes: 5 additions & 5 deletions components/zoho_sheet/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "@pipedream/zoho_sheet",
"version": "0.0.3",
"version": "0.1.0",
"description": "Pipedream Zoho Sheet Components",
"main": "dist/app/zoho_sheet.app.mjs",
"main": "zoho_sheet.app.mjs",
"keywords": [
"pipedream",
"zoho_sheet"
],
"files": [
"dist"
],
"homepage": "https://pipedream.com/apps/zoho_sheet",
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
50 changes: 50 additions & 0 deletions components/zoho_sheet/sources/common/base.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import zohoSheet from "../../zoho_sheet.app.mjs";

export default {
props: {
zohoSheet,
http: {
type: "$.interface.http",
customResponse: true,
},
db: "$.service.db",
serviceName: {
type: "string",
label: "Service Name",
description: "The name of the webhook.",
},
},
methods: {
getExtraData() {
return {};
},
},
hooks: {
async activate() {
await this.zohoSheet.createWebhook({
data: {
service_name: this.serviceName.replace(/\s/g, ""),
target_url: this.http.endpoint,
event: this.getEvent(),
...this.getExtraData(),
},
});
},
async deactivate() {
await this.zohoSheet.deleteWebhook({
data: {
target_url: this.http.endpoint,
...this.getExtraData(),
},
});
},
},
async run({ body }) {
const ts = Date.parse(new Date());
this.$emit(body, {
id: `${ts}`,
summary: this.getSummary(body),
ts: ts,
});
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import common from "../common/base.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "zoho_sheet-new-or-updated-row-instant",
name: "New or Updated Row (Instant)",
description: "Emit new event whenever a row is added or modified.",
version: "0.0.1",
type: "source",
dedupe: "unique",
props: {
...common.props,
workbookId: {
propDefinition: [
common.props.zohoSheet,
"workbookId",
],
},
worksheetId: {
propDefinition: [
common.props.zohoSheet,
"worksheet",
({ workbookId }) => ({
workbookId,
}),
],
withLabel: true,
},
alert: {
type: "alert",
alertType: "info",
content: "**New row** will be triggered only after the entire row is completed.",
},
},
methods: {
...common.methods,
getEvent() {
return "update_worksheet";
},
getExtraData() {
return {
resource_id: this.workbookId,
worksheet_id: this.worksheetId.value,
};
},
getSummary({ updated_rows }) {
return `Row ${updated_rows[0].row_type === "NEW"
? "created"
: "updated"} in worksheet ${this.worksheetId.label}`;
},
},
sampleEmit,
};
Loading
Loading