-
Notifications
You must be signed in to change notification settings - Fork 5.5k
10769 components glide #19484
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
Open
luancazarine
wants to merge
3
commits into
master
Choose a base branch
from
10769-components-glide
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
10769 components glide #19484
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Some comments aren't visible on the classic Files Changed page.
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 { parseObject } from "../../common/utils.mjs"; | ||
| import glide from "../../glide.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "glide-add-rows", | ||
| name: "Add Rows to Table", | ||
| description: "Add new rows to a specified table. [See the documentation](https://apidocs.glideapps.com/api-reference/v2/tables/post-table-rows)", | ||
| version: "0.0.1", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| glide, | ||
| tableId: { | ||
| propDefinition: [ | ||
| glide, | ||
| "tableId", | ||
| ], | ||
| }, | ||
| rows: { | ||
| type: "string[]", | ||
| label: "Rows", | ||
| description: "Array of row objects to add. Each object should contain the column names as keys and their values.", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| let rowsData = parseObject(this.rows); | ||
| const response = await this.glide.addRows({ | ||
| $, | ||
| tableId: this.tableId, | ||
| data: rowsData, | ||
| }); | ||
|
|
||
| const addedCount = rowsData.length; | ||
| const plural = addedCount === 1 | ||
| ? "" | ||
| : "s"; | ||
| $.export("$summary", `Successfully added ${addedCount} row${plural}`); | ||
| 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,43 @@ | ||
| import glide from "../../glide.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "glide-delete-row", | ||
| name: "Delete Row", | ||
| description: "Delete an existing row from a table. [See the documentation](https://apidocs.glideapps.com/api-reference/v2/tables/delete-table-row)", | ||
| version: "0.0.1", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| type: "action", | ||
| props: { | ||
| glide, | ||
| tableId: { | ||
| propDefinition: [ | ||
| glide, | ||
| "tableId", | ||
| ], | ||
| }, | ||
| rowId: { | ||
| propDefinition: [ | ||
| glide, | ||
| "rowId", | ||
| ({ tableId }) => ({ | ||
| tableId, | ||
| }), | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.glide.deleteRow({ | ||
| $, | ||
| tableId: this.tableId, | ||
| rowId: this.rowId, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully deleted row ${this.rowId}`); | ||
| 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,59 @@ | ||
| import glide from "../../glide.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "glide-get-rows", | ||
| name: "Get Rows", | ||
| description: "Get rows from a specified table. [See the documentation](https://apidocs.glideapps.com/api-reference/v2/tables/get-table-rows)", | ||
| version: "0.0.1", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| glide, | ||
| tableId: { | ||
| propDefinition: [ | ||
| glide, | ||
| "tableId", | ||
| ], | ||
| }, | ||
| limit: { | ||
| type: "integer", | ||
| label: "Limit", | ||
| description: "Maximum number of rows to return", | ||
| optional: true, | ||
| default: 100, | ||
| }, | ||
| continuation: { | ||
| type: "string", | ||
| label: "Continuation Token", | ||
| description: "Token for pagination to get the next set of results", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const params = {}; | ||
| if (this.limit) { | ||
| params.limit = this.limit; | ||
| } | ||
| if (this.continuation) { | ||
| params.continuation = this.continuation; | ||
| } | ||
|
|
||
| const response = await this.glide.getRows({ | ||
| $, | ||
| tableId: this.tableId, | ||
| params, | ||
| }); | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const rowCount = response.data?.length || 0; | ||
| const plural = rowCount === 1 | ||
| ? "" | ||
| : "s"; | ||
| $.export("$summary", `Successfully retrieved ${rowCount} row${plural}`); | ||
| 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 glide from "../../glide.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "glide-list-tables", | ||
| name: "List Big Tables", | ||
| description: "List all Big Tables associated with your Glide team. [See the documentation](https://apidocs.glideapps.com/api-reference/v2/tables/get-tables)", | ||
| version: "0.0.1", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| glide, | ||
| alert: { | ||
|
Check warning on line 16 in components/glide/actions/list-tables/list-tables.mjs
|
||
| type: "alert", | ||
| alertType: "warning", | ||
| content: "This endpoint only retrieves `Big Table` tables. No other table types will be included in the response, even though they are part of your Glide team.", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.glide.listTables({ | ||
| $, | ||
| }); | ||
|
|
||
| const count = response.data.length || 0; | ||
| const plural = count === 1 | ||
| ? "" | ||
| : "s"; | ||
| $.export("$summary", `Successfully retrieved ${count} Big Table${plural}`); | ||
| 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,50 @@ | ||
| import { parseObject } from "../../common/utils.mjs"; | ||
| import glide from "../../glide.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "glide-update-row", | ||
| name: "Update Row", | ||
| description: "Update an existing row in a table. [See the documentation](https://apidocs.glideapps.com/api-reference/v2/tables/patch-update-row)", | ||
| version: "0.0.1", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| glide, | ||
| tableId: { | ||
| propDefinition: [ | ||
| glide, | ||
| "tableId", | ||
| ], | ||
| }, | ||
| rowId: { | ||
| propDefinition: [ | ||
| glide, | ||
| "rowId", | ||
| ({ tableId }) => ({ | ||
| tableId, | ||
| }), | ||
| ], | ||
| }, | ||
| rowData: { | ||
| type: "object", | ||
| label: "Row Data", | ||
| description: "Object containing the column names as keys and their new values.", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.glide.updateRow({ | ||
| $, | ||
| tableId: this.tableId, | ||
| rowId: this.rowId, | ||
| data: parseObject(this.rowData), | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully updated row ${this.rowId}`); | ||
| 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,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; | ||
| }; | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 |
|---|---|---|
| @@ -1,11 +1,94 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "glide", | ||
| propDefinitions: {}, | ||
| propDefinitions: { | ||
| tableId: { | ||
| type: "string", | ||
| label: "Table ID", | ||
| description: "The ID of the table", | ||
| async options() { | ||
| const { data } = await this.listTables(); | ||
| return data.map(({ | ||
| id: value, name: label, | ||
| }) => ({ | ||
| label, | ||
| value, | ||
| })); | ||
| }, | ||
| }, | ||
| rowId: { | ||
| type: "string", | ||
| label: "Row ID", | ||
| description: "The ID of the row", | ||
| async options({ tableId }) { | ||
| const { data } = await this.getRows({ | ||
| tableId, | ||
| }); | ||
| return data.map(({ $rowID }) => $rowID); | ||
| }, | ||
| }, | ||
| }, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| getBaseUrl() { | ||
| return "https://api.glideapps.com"; | ||
| }, | ||
| getHeaders() { | ||
| return { | ||
| "Content-Type": "application/json", | ||
| "Authorization": `Bearer ${this.$auth.secret_token}`, | ||
| }; | ||
| }, | ||
| makeRequest({ | ||
| $ = this, path, ...args | ||
| } = {}) { | ||
| return axios($, { | ||
| headers: this.getHeaders(), | ||
| url: `${this.getBaseUrl()}${path}`, | ||
| ...args, | ||
| }); | ||
| }, | ||
| listTables(args = {}) { | ||
| return this.makeRequest({ | ||
| path: "/tables", | ||
| ...args, | ||
| }); | ||
| }, | ||
| getRows({ | ||
| tableId, ...args | ||
| } = {}) { | ||
| return this.makeRequest({ | ||
| path: `/tables/${tableId}/rows`, | ||
| ...args, | ||
| }); | ||
| }, | ||
| addRows({ | ||
| tableId, ...args | ||
| } = {}) { | ||
| return this.makeRequest({ | ||
| method: "POST", | ||
| path: `/tables/${tableId}/rows`, | ||
| ...args, | ||
| }); | ||
| }, | ||
| updateRow({ | ||
| tableId, rowId, ...args | ||
| } = {}) { | ||
| return this.makeRequest({ | ||
| method: "PATCH", | ||
| path: `/tables/${tableId}/rows/${rowId}`, | ||
| ...args, | ||
| }); | ||
| }, | ||
| deleteRow({ | ||
| tableId, rowId, ...args | ||
| } = {}) { | ||
| return this.makeRequest({ | ||
| method: "DELETE", | ||
| path: `/tables/${tableId}/rows/${rowId}`, | ||
| ...args, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
| }; |
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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "@pipedream/glide", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream Glide Components", | ||
| "main": "glide.app.mjs", | ||
| "keywords": [ | ||
|
|
@@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.1.1" | ||
| } | ||
| } | ||
Oops, something went wrong.
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.