-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Coda new actions #2013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
andrewjschuang
merged 47 commits into
PipedreamHQ:master
from
andrewjschuang:coda-new-actions
Mar 18, 2022
Merged
Coda new actions #2013
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
17a793c
template for actions
andrewjschuang 39e83d5
add create doc action
andrewjschuang dcc41ea
add copy doc action
andrewjschuang 2107e8d
remove timezone parameter
andrewjschuang 090b0d7
change props to prop definitions
andrewjschuang 7b8d94e
add list docs action
andrewjschuang 9288c0d
refactor prop names and properties
andrewjschuang 0b2d53d
add pagination in list docs
andrewjschuang 438ede0
move optional and default props to coda source
andrewjschuang 76277fe
add source doc id list options
andrewjschuang 8f4e812
refactor new remove empty key values method
andrewjschuang 29c4368
add list tables action
andrewjschuang 6425661
add list columns
andrewjschuang 0cc9e44
add create rows
andrewjschuang 60054cc
add find row
andrewjschuang 9524ffb
add update row
andrewjschuang 2ecea32
add upsert rows
andrewjschuang 68133e0
refactor to initial action versions
andrewjschuang 9bbda82
style action keys as in docs
andrewjschuang 182acad
refactor props
andrewjschuang ef9939e
refactor descriptions
andrewjschuang 9ab2009
remove authKeys
andrewjschuang 669ab9b
review js docs
andrewjschuang de1e25d
refactor create doc method
andrewjschuang edd7fbd
descriptions review and rewriting
andrewjschuang 4c6bc17
create _makeRequest method
andrewjschuang a6d22b1
always paginate when listing docs
andrewjschuang ae695ca
change to pipedream axios
andrewjschuang 93af8b8
fix some prop descriptions
andrewjschuang 03c4ea6
refactor columnId prop
andrewjschuang f9c1f95
unneeded _removeEmptyKeyValues method
andrewjschuang ca7f801
add summary export for actions
andrewjschuang 0b2692d
better id/value options viewing
andrewjschuang 6dc5090
create default rows prop
andrewjschuang 741f519
add coda error handling messages
andrewjschuang f844157
fix labels and descriptions in actions
andrewjschuang ac40e03
remove doc id async options prop input
andrewjschuang 6b5ae56
pass $ to axios
andrewjschuang a555635
change options label to just name
andrewjschuang 31cba3a
update row action with additional props as column values
andrewjschuang 046c22a
find row query using column id
andrewjschuang 073ca63
find row optional column id and query
andrewjschuang 25033c5
add async options pagination
andrewjschuang 6eccb7a
change limit prop to max in list docs actions
andrewjschuang 140e7e3
add pagination to actions
andrewjschuang 62c4f8d
add page counter to context
andrewjschuang 2e9e5a2
fix return list directly in actions
andrewjschuang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: { | ||
andrewjschuang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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, | ||
| }; | ||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.