-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Caspio - new components #19724
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
Merged
Caspio - new components #19724
Changes from all commits
Commits
Show all changes
4 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
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,71 @@ | ||
| import caspio from "../../caspio.app.mjs"; | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| key: "caspio-create-record", | ||
| name: "Create Record", | ||
| description: "Create a new record in the specified table. [See the documentation](https://demo.caspio.com/integrations/rest/swagger/index.html)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
| props: { | ||
| caspio, | ||
| table: { | ||
| propDefinition: [ | ||
| caspio, | ||
| "table", | ||
| ], | ||
| reloadProps: true, | ||
| }, | ||
| }, | ||
| async additionalProps() { | ||
| const props = {}; | ||
| const { Result: fields } = await this.caspio.listTableFields({ | ||
| table: this.table, | ||
| }); | ||
| for (const field of fields) { | ||
| if (!field.Editable) continue; | ||
| props[field.Name] = { | ||
| type: field.Type === "YES/NO" | ||
| ? "boolean" | ||
| : "string", | ||
| label: field.Name, | ||
| optional: true, | ||
| }; | ||
| } | ||
| return props; | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| caspio, | ||
| table, | ||
| ...data | ||
| } = this; | ||
|
|
||
| if (Object.keys(data).length === 0) { | ||
| throw new ConfigurationError("Must provide at least one field"); | ||
| } | ||
|
|
||
| const { Result: fields } = await this.caspio.listTableFields({ | ||
| table: this.table, | ||
| }); | ||
|
|
||
| for (const field of fields) { | ||
| if (field.Type === "NUMBER" && data[field.Name]) { | ||
| data[field.Name] = +data[field.Name]; | ||
| } | ||
| } | ||
|
|
||
| const response = await caspio.createRecord({ | ||
| $, | ||
| table, | ||
| data, | ||
| }); | ||
| $.export("$summary", `Successfully created record in table ${table}`); | ||
| 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 |
|---|---|---|
| @@ -1,11 +1,83 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "caspio", | ||
| propDefinitions: {}, | ||
| propDefinitions: { | ||
| table: { | ||
| type: "string", | ||
| label: "Table", | ||
| description: "The table to listen for events on", | ||
| async options() { | ||
| const { Result: tables } = await this.listTables(); | ||
| return tables?.map((table) => table) || []; | ||
| }, | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _domain() { | ||
| return this.$auth.domain.endsWith("/") | ||
| ? this.$auth.domain.slice(0, -1) | ||
| : this.$auth.domain; | ||
| }, | ||
| _baseUrl() { | ||
| return `${this._domain()}/integrations/rest/v3`; | ||
| }, | ||
| _makeRequest({ | ||
| $ = this, path, ...opts | ||
| }) { | ||
| return axios($, { | ||
| url: `${this._baseUrl()}${path}`, | ||
| headers: { | ||
| Authorization: `Bearer ${this.$auth.oauth_access_token}`, | ||
| }, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| listTables(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "/tables", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| listTableFields({ | ||
| table, ...opts | ||
| }) { | ||
| return this._makeRequest({ | ||
| path: `/tables/${table}/fields`, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| createRecord({ | ||
| table, ...opts | ||
| }) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: `/tables/${table}/records`, | ||
| ...opts, | ||
| }); | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| createWebhook(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "/outgoingWebhooks", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| createWebhookEvent({ | ||
| webhookId, ...opts | ||
| }) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: `/outgoingWebhooks/${webhookId}/events`, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| deleteWebhook(webhookId) { | ||
| return this._makeRequest({ | ||
| method: "DELETE", | ||
| path: `/outgoingWebhooks/${webhookId}`, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
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
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,78 @@ | ||
| import caspio from "../../caspio.app.mjs"; | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| props: { | ||
| caspio, | ||
| db: "$.service.db", | ||
| http: { | ||
| type: "$.interface.http", | ||
| customResponse: true, | ||
| }, | ||
| name: { | ||
| type: "string", | ||
| label: "Name", | ||
| description: "Meaningful label that identifies the webhook", | ||
| }, | ||
| table: { | ||
| propDefinition: [ | ||
| caspio, | ||
| "table", | ||
| ], | ||
| }, | ||
| }, | ||
| hooks: { | ||
| async activate() { | ||
| const { Id: webhookId } = await this.caspio.createWebhook({ | ||
| data: { | ||
| Name: this.name, | ||
| OutgoingUrls: [ | ||
| this.http.endpoint, | ||
| ], | ||
| }, | ||
| }); | ||
| this._setWebhookId(webhookId); | ||
|
|
||
| await this.caspio.createWebhookEvent({ | ||
| webhookId, | ||
| data: { | ||
| EventType: this.getEventType(), | ||
| ObjectName: this.table, | ||
| }, | ||
| }); | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| async deactivate() { | ||
| const webhookId = this._getWebhookId(); | ||
| if (!webhookId) { | ||
| return; | ||
| } | ||
| await this.caspio.deleteWebhook(webhookId); | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| methods: { | ||
| _setWebhookId(webhookId) { | ||
| this.db.set("webhookId", webhookId); | ||
| }, | ||
| _getWebhookId() { | ||
| return this.db.get("webhookId"); | ||
| }, | ||
| getEventType() { | ||
| throw new ConfigurationError("getEventType is not implemented"); | ||
| }, | ||
| generateMeta() { | ||
| throw new ConfigurationError("generateMeta is not implemented"); | ||
| }, | ||
| }, | ||
| async run({ body }) { | ||
| this.http.respond({ | ||
| status: 200, | ||
| }); | ||
|
|
||
| if (!body) { | ||
| return; | ||
| } | ||
|
|
||
| const meta = this.generateMeta(body); | ||
| this.$emit(body, meta); | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| }; | ||
26 changes: 26 additions & 0 deletions
26
components/caspio/sources/new-record-created/new-record-created.mjs
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,26 @@ | ||
| import common from "../common/base-webhook.mjs"; | ||
| import sampleEmit from "./test-event.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "caspio-new-record-created", | ||
| name: "New Record Created (Instant)", | ||
| description: "Emit new event when a new record in specified table is created", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| methods: { | ||
| ...common.methods, | ||
| getEventType() { | ||
| return "table.recordInsert"; | ||
| }, | ||
| generateMeta(body) { | ||
| return { | ||
| id: body.eventId, | ||
| summary: `New record created with PK_ID: ${body.data[0].PK_ID}`, | ||
| ts: Date.parse(body.eventDate), | ||
| }; | ||
| }, | ||
| }, | ||
| sampleEmit, | ||
| }; |
17 changes: 17 additions & 0 deletions
17
components/caspio/sources/new-record-created/test-event.mjs
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,17 @@ | ||
| export default { | ||
| "eventId": "p150qb", | ||
| "messageId": "bd79b323-ae75-4d7d-884e-4cf2902edb93", | ||
| "webhookId": "b5x49p", | ||
| "accountId": "", | ||
| "secret": "", | ||
| "eventDate": "2026-01-16T19:52:55", | ||
| "eventType": "table.recordInsert", | ||
| "objectName": "New_Table", | ||
| "data": [ | ||
| { | ||
| "PK_ID": 1, | ||
| "id": "1", | ||
| "name": "examplee" | ||
| } | ||
| ] | ||
| } |
26 changes: 26 additions & 0 deletions
26
components/caspio/sources/record-deleted/record-deleted.mjs
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,26 @@ | ||
| import common from "../common/base-webhook.mjs"; | ||
| import sampleEmit from "./test-event.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "caspio-record-deleted", | ||
| name: "Record Deleted (Instant)", | ||
| description: "Emit new event when a record in specified table is deleted", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| methods: { | ||
| ...common.methods, | ||
| getEventType() { | ||
| return "table.recordDelete"; | ||
| }, | ||
| generateMeta(body) { | ||
| return { | ||
| id: body.eventId, | ||
| summary: `Record deleted with PK_ID: ${body.data[0].PK_ID}`, | ||
| ts: Date.parse(body.eventDate), | ||
| }; | ||
| }, | ||
| }, | ||
| sampleEmit, | ||
| }; | ||
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,17 @@ | ||
| export default { | ||
| "eventId": "p0587p", | ||
| "messageId": "8ee72cd0-be50-4d6c-84aa-a7524bec6c85", | ||
| "webhookId": "k363j2", | ||
| "accountId": "", | ||
| "secret": "", | ||
| "eventDate": "2026-01-16T19:59:13", | ||
| "eventType": "table.recordDelete", | ||
| "objectName": "New_Table", | ||
| "data": [ | ||
| { | ||
| "PK_ID": 1, | ||
| "id": "1", | ||
| "name": "example" | ||
| } | ||
| ] | ||
| } |
26 changes: 26 additions & 0 deletions
26
components/caspio/sources/record-updated/record-updated.mjs
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,26 @@ | ||
| import common from "../common/base-webhook.mjs"; | ||
| import sampleEmit from "./test-event.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "caspio-record-updated", | ||
| name: "Record Updated (Instant)", | ||
| description: "Emit new event when a record in specified table is updated", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| methods: { | ||
| ...common.methods, | ||
| getEventType() { | ||
| return "table.recordUpdate"; | ||
| }, | ||
| generateMeta(body) { | ||
| return { | ||
| id: body.eventId, | ||
| summary: `Record updated with PK_ID: ${body.data[0].PK_ID}`, | ||
| ts: Date.parse(body.eventDate), | ||
| }; | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| }, | ||
| sampleEmit, | ||
| }; | ||
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,17 @@ | ||
| export default { | ||
| "eventId": "l9m8rk", | ||
| "messageId": "0f73df53-01f0-479b-853c-9bde29952e05", | ||
| "webhookId": "71a8dk", | ||
| "accountId": "", | ||
| "secret": "", | ||
| "eventDate": "2026-01-16T19:56:38", | ||
| "eventType": "table.recordUpdate", | ||
| "objectName": "New_Table", | ||
| "data": [ | ||
| { | ||
| "PK_ID": 1, | ||
| "id": "1", | ||
| "name": "example" | ||
| } | ||
| ] | ||
| } |
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.