Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
17a793c
template for actions
andrewjschuang Jan 4, 2022
39e83d5
add create doc action
andrewjschuang Jan 4, 2022
dcc41ea
add copy doc action
andrewjschuang Jan 5, 2022
2107e8d
remove timezone parameter
andrewjschuang Jan 5, 2022
090b0d7
change props to prop definitions
andrewjschuang Jan 5, 2022
7b8d94e
add list docs action
andrewjschuang Jan 5, 2022
9288c0d
refactor prop names and properties
andrewjschuang Jan 5, 2022
0b2d53d
add pagination in list docs
andrewjschuang Jan 5, 2022
438ede0
move optional and default props to coda source
andrewjschuang Jan 5, 2022
76277fe
add source doc id list options
andrewjschuang Jan 5, 2022
8f4e812
refactor new remove empty key values method
andrewjschuang Jan 6, 2022
29c4368
add list tables action
andrewjschuang Jan 5, 2022
6425661
add list columns
andrewjschuang Jan 6, 2022
0cc9e44
add create rows
andrewjschuang Jan 6, 2022
60054cc
add find row
andrewjschuang Jan 7, 2022
9524ffb
add update row
andrewjschuang Jan 7, 2022
2ecea32
add upsert rows
andrewjschuang Jan 6, 2022
68133e0
refactor to initial action versions
andrewjschuang Jan 7, 2022
9bbda82
style action keys as in docs
andrewjschuang Jan 7, 2022
182acad
refactor props
andrewjschuang Jan 7, 2022
ef9939e
refactor descriptions
andrewjschuang Jan 7, 2022
9ab2009
remove authKeys
andrewjschuang Jan 7, 2022
669ab9b
review js docs
andrewjschuang Jan 7, 2022
de1e25d
refactor create doc method
andrewjschuang Jan 7, 2022
edd7fbd
descriptions review and rewriting
andrewjschuang Jan 7, 2022
4c6bc17
create _makeRequest method
andrewjschuang Jan 7, 2022
a6d22b1
always paginate when listing docs
andrewjschuang Jan 7, 2022
ae695ca
change to pipedream axios
andrewjschuang Jan 7, 2022
93af8b8
fix some prop descriptions
andrewjschuang Jan 7, 2022
03c4ea6
refactor columnId prop
andrewjschuang Jan 7, 2022
f9c1f95
unneeded _removeEmptyKeyValues method
andrewjschuang Jan 7, 2022
ca7f801
add summary export for actions
andrewjschuang Jan 10, 2022
0b2692d
better id/value options viewing
andrewjschuang Jan 10, 2022
6dc5090
create default rows prop
andrewjschuang Jan 10, 2022
741f519
add coda error handling messages
andrewjschuang Jan 10, 2022
f844157
fix labels and descriptions in actions
andrewjschuang Feb 24, 2022
ac40e03
remove doc id async options prop input
andrewjschuang Feb 24, 2022
6b5ae56
pass $ to axios
andrewjschuang Feb 24, 2022
a555635
change options label to just name
andrewjschuang Feb 24, 2022
31cba3a
update row action with additional props as column values
andrewjschuang Feb 24, 2022
046c22a
find row query using column id
andrewjschuang Feb 24, 2022
073ca63
find row optional column id and query
andrewjschuang Feb 24, 2022
25033c5
add async options pagination
andrewjschuang Feb 24, 2022
6eccb7a
change limit prop to max in list docs actions
andrewjschuang Feb 25, 2022
140e7e3
add pagination to actions
andrewjschuang Feb 25, 2022
62c4f8d
add page counter to context
andrewjschuang Mar 8, 2022
2e9e5a2
fix return list directly in actions
andrewjschuang Mar 8, 2022
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
45 changes: 45 additions & 0 deletions components/coda/actions/copy-doc/copy-doc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import coda from "../../coda.app.mjs";

export default {
key: "coda-copy-doc",
name: "Copy Doc",
description: "Creates a copy of the specified doc. [See docs](https://coda.io/developers/apis/v1#operation/createDoc)",
version: "0.0.1",
type: "action",
props: {
coda,
docId: {
propDefinition: [
coda,
"docId",
],
label: "Source Doc ID",
description: "The doc from which to create a copy",
},
title: {
propDefinition: [
coda,
"title",
],
description: "Title of the newly copied doc. Defaults to `\"Copy of <originalTitle>\"`",
},
folderId: {
propDefinition: [
coda,
"folderId",
],
description: "The folder within which to copy this doc",
},
},
async run({ $ }) {
let data = {
title: this.title,
folderId: this.folderId,
sourceDoc: this.docId,
};

let response = await this.coda.createDoc($, data);
$.export("$summary", `Copied to new doc "${response.name}" in folderId: "${response.folderId}" and workspaceId: "${response.workspaceId}"`);
return response;
},
};
35 changes: 35 additions & 0 deletions components/coda/actions/create-doc/create-doc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import coda from "../../coda.app.mjs";

export default {
key: "coda-create-doc",
name: "Create Doc",
description: "Creates a new doc. [See docs](https://coda.io/developers/apis/v1#operation/createDoc)",
version: "0.0.1",
type: "action",
props: {
coda,
title: {
propDefinition: [
coda,
"title",
],
},
folderId: {
propDefinition: [
coda,
"folderId",
],
description: "The folder within which to create this doc",
},
},
async run({ $ }) {
let data = {
title: this.title,
folderId: this.folderId,
};

let response = await this.coda.createDoc($, data);
$.export("$summary", `Created doc "${response.name}" in folderId: "${response.folderId}" and workspaceId: "${response.workspaceId}"`);
return response;
},
};
71 changes: 71 additions & 0 deletions components/coda/actions/create-rows/create-rows.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import coda from "../../coda.app.mjs";

export default {
key: "coda-create-rows",
name: "Create Rows",
description: "Insert a row in a selected table. [See docs](https://coda.io/developers/apis/v1#operation/upsertRows)",
version: "0.0.1",
type: "action",
props: {
coda,
docId: {
propDefinition: [
coda,
"docId",
],
},
tableId: {
propDefinition: [
coda,
"tableId",
(c) => ({
docId: c.docId,
}),
],
reloadProps: true,
},
disableParsing: {
propDefinition: [
coda,
"disableParsing",
],
},
},
async additionalProps() {
const props = {};
const { items } = await this.coda.listColumns(this, this.docId, this.tableId);
for (const item of items) {
props[`col_${item.id}`] = {
type: "string",
label: `Column: ${item.name}`,
description: "Leave blank to ignore this column",
optional: true,
};
}
return props;
},
async run({ $ }) {
const params = {
disableParsing: this.disableParsing,
};

const data = {
rows: [
{
cells: this.coda.createRowCells(this),
},
],
};

const response = await this.coda.createRows(
$,
this.docId,
this.tableId,
data,
params,
);

$.export("$summary", "Created row successfully");
return response;
},
};
124 changes: 124 additions & 0 deletions components/coda/actions/find-row/find-row.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import coda from "../../coda.app.mjs";

export default {
key: "coda-find-row",
name: "Find Row",
description: "Searches for a row in the selected table using a column match search. [See docs](https://coda.io/developers/apis/v1#operation/listRows)",
version: "0.0.1",
type: "action",
props: {
coda,
docId: {
propDefinition: [
coda,
"docId",
],
},
tableId: {
propDefinition: [
coda,
"tableId",
(c) => ({
docId: c.docId,
}),
],
},
columnId: {
propDefinition: [
coda,
"columnId",
(c) => ({
docId: c.docId,
tableId: c.tableId,
}),
],
description: "ID of the column. This field is required if querying",
optional: true,
},
query: {
propDefinition: [
coda,
"query",
],
description: "Query used to filter returned rows",
optional: true,
},
sortBy: {
propDefinition: [
coda,
"sortBy",
],
description: "Specifies the sort order of the rows returned. If left unspecified, rows are returned by creation time ascending",
options: [
"createdAt",
"natural",
"updatedAt",
],
},
visibleOnly: {
propDefinition: [
coda,
"visibleOnly",
],
},
useColumnNames: {
type: "boolean",
label: "Use Column Names",
description: "Use column names instead of column IDs in the returned output",
optional: true,
},
valueFormat: {
type: "string",
label: "Value Format",
description: "The format that individual cell values are returned as",
optional: true,
options: [
"simple",
"simpleWithArrays",
"rich",
],
},
max: {
propDefinition: [
coda,
"max",
],
},
},
async run({ $ }) {
let params = {
sortBy: this.sortBy,
visibleOnly: this.visibleOnly,
useColumnNames: this.useColumnNames,
valueFormat: this.valueFormat,
};

if (this.columnId && this.query) {
params.query = `${this.columnId}:"${this.query}"`;
}

let items = [];
let response;
do {
response = await this.coda.findRow(
$,
this.docId,
this.tableId,
params,
);
items.push(...response.items);
params.pageToken = response.nextPageToken;
} while (params.pageToken && items.length < this.max);

if (items.length > this.max) items.length = this.max;

if (items.length > 0) {
$.export("$summary", `Found ${items.length} rows`);
} else {
$.export("$summary", `No rows found with the search query: ${this.query}`);
}
return {
items,
};
},
};
63 changes: 63 additions & 0 deletions components/coda/actions/list-columns/list-columns.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import coda from "../../coda.app.mjs";

export default {
key: "coda-list-columns",
name: "List Columns",
description: "Lists columns in a table. [See docs](https://coda.io/developers/apis/v1#operation/listColumns)",
version: "0.0.1",
type: "action",
props: {
coda,
docId: {
propDefinition: [
coda,
"docId",
],
},
tableId: {
propDefinition: [
coda,
"tableId",
(c) => ({
docId: c.docId,
}),
],
},
visibleOnly: {
propDefinition: [
coda,
"visibleOnly",
],
},
max: {
propDefinition: [
coda,
"max",
],
},
},
async run({ $ }) {
let params = {
visibleOnly: this.visibleOnly,
};

let items = [];
let response;
do {
response = await this.coda.listColumns(
$,
this.docId,
this.tableId,
params,
);
items.push(...response.items);
params.pageToken = response.nextPageToken;
} while (params.pageToken && items.length < this.max);

if (items.length > this.max) items.length = this.max;

$.export("$summary", `Retrieved ${items.length} column(s)`);

return items;
},
};
Loading