Skip to content

New Components - bubble #14235

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
30 changes: 30 additions & 0 deletions components/bubble/actions/create-thing/create-thing.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import bubble from "../../bubble.app.mjs";
import { axios } from "@pipedream/platform";

Check failure on line 2 in components/bubble/actions/create-thing/create-thing.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'axios' is defined but never used

export default {
key: "bubble-create-thing",
name: "Create Thing",
description: "Creates a new thing in the Bubble database. [See the documentation](https://manual.bubble.io/core-resources/api/the-bubble-api/the-data-api/data-api-requests#create-a-thing)",
version: "0.0.{{ts}}",
type: "action",
props: {
bubble,
thingAttributes: {
propDefinition: [
bubble,
"thingAttributes",
],
type: "object",
label: "Thing Attributes",
description: "The attributes for the new thing to create in the Bubble database",
},
},
async run({ $ }) {
const response = await this.bubble.createNewThing({
thingAttributes: this.thingAttributes,
});

$.export("$summary", `Successfully created thing with ID: ${response.id}`);
return response;
},
};
32 changes: 32 additions & 0 deletions components/bubble/actions/find-thing/find-thing.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import bubble from "../../bubble.app.mjs";

export default {
key: "bubble-find-thing",
name: "Find Thing",
description: "Searches for a thing in the Bubble database. [See the documentation](https://manual.bubble.io/core-resources/api/the-bubble-api/the-data-api/data-api-requests)",
version: "0.0.{{ts}}",
type: "action",
props: {
bubble,
searchQuery: {
type: "string",
label: "Search Query",
description: "The query to search for a thing in the Bubble database",
},
searchParameters: {
type: "object",
label: "Search Parameters",
description: "Optional parameters to refine the search results",
optional: true,
},
},
async run({ $ }) {
const response = await this.bubble.searchForThings({
searchQuery: this.searchQuery,
searchParameters: this.searchParameters,
});

$.export("$summary", `Successfully searched for things with query "${this.searchQuery}"`);
return response;
},
};
43 changes: 43 additions & 0 deletions components/bubble/actions/modify-thing/modify-thing.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import bubble from "../../bubble.app.mjs";
import { axios } from "@pipedream/platform";

Check failure on line 2 in components/bubble/actions/modify-thing/modify-thing.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'axios' is defined but never used

export default {
key: "bubble-modify-thing",
name: "Modify Thing",
description: "Modifies an existing thing in the Bubble database by providing the thing's ID. [See the documentation](https://manual.bubble.io/core-resources/api/the-bubble-api/the-data-api/data-api-requests)",
version: "0.0.{{ts}}",
type: "action",
props: {
bubble,
thingId: {
propDefinition: [
bubble,
"thingId",
],
},
attributeToModify: {
propDefinition: [
bubble,
"attributeToModify",
],
optional: true,
},
newValue: {
propDefinition: [
bubble,
"newValue",
],
optional: true,
},
},
async run({ $ }) {
const response = await this.bubble.modifyThingById({
thingId: this.thingId,
attributeToModify: this.attributeToModify,
newValue: this.newValue,
});

$.export("$summary", `Successfully modified the thing with ID ${this.thingId}`);
return response;
},
};
128 changes: 124 additions & 4 deletions components/bubble/bubble.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,131 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "bubble",
propDefinitions: {},
propDefinitions: {
workflowId: {
type: "string",
label: "Workflow ID",
description: "The ID for the Bubble workflow to monitor",
},
thingId: {
type: "string",
label: "Thing ID",
description: "The unique ID of the thing in the Bubble database to modify",
},
attributeToModify: {
type: "string",
label: "Attribute to Modify",
description: "The name of the attribute of the thing to change",
optional: true,
},
newValue: {
type: "any",
label: "New Value",
description: "The new value for the specified attribute",
optional: true,
},
searchQuery: {
type: "string",
label: "Search Query",
description: "The query to search for a thing in the Bubble database",
},
searchParameters: {
type: "object",
label: "Search Parameters",
description: "Optional parameters to refine the search results",
optional: true,
},
thingAttributes: {
type: "object",
label: "Thing Attributes",
description: "The attributes for the new thing to create in the Bubble database",
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return `https://${this.$auth.appname}.bubbleapps.io/api/1.1/obj`;
},

async _makeRequest(opts = {}) {
const {
$ = this, method = "GET", path = "/", headers, ...otherOpts
} = opts;
return axios($, {
...otherOpts,
method,
url: this._baseUrl() + path,
headers: {
...headers,
"Content-Type": "application/json",
"Authorization": `Bearer ${this.$auth.api_token}`,
},
});
},

async listenForWorkflow(opts = {}) {
const {
workflowId, ...otherOpts

Check failure on line 69 in components/bubble/bubble.app.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'otherOpts' is assigned a value but never used
} = opts;
if (!workflowId) {
throw new Error("Workflow ID is required to listen for workflows.");
}
// Implement logic to listen for the workflow and emit an event
},

async modifyThingById(opts = {}) {
const {
thingId, attributeToModify, newValue, ...otherOpts
} = opts;
if (!thingId) {
throw new Error("A Thing ID is required to modify a thing.");
}
const data = attributeToModify
? {
[attributeToModify]: newValue,
}
: {};
return this._makeRequest({
method: "PATCH",
path: `/${thingId}`,
data,
...otherOpts,
});
},

async searchForThings(opts = {}) {
const {
searchQuery, searchParameters, ...otherOpts
} = opts;
if (!searchQuery) {
throw new Error("A search query is required to search for a thing.");
}
const params = {
q: searchQuery,
...searchParameters,
};
return this._makeRequest({
method: "GET",
path: "/search",
params,
...otherOpts,
});
},

async createNewThing(opts = {}) {
const {
thingAttributes, ...otherOpts
} = opts;
if (!thingAttributes || typeof thingAttributes !== "object") {
throw new Error("Thing attributes must be provided to create a new thing.");
}
return this._makeRequest({
method: "POST",
data: thingAttributes,
...otherOpts,
});
},
},
version: "0.0.{{ts}}",
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import bubble from "../../bubble.app.mjs";
import { axios } from "@pipedream/platform";

Check failure on line 2 in components/bubble/sources/new-workflow-trigger-event-instant/new-workflow-trigger-event-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'axios' is defined but never used

export default {
key: "bubble-new-workflow-trigger-event-instant",
name: "New Workflow Trigger Event",
description: "Emits new event when a Bubble workflow that incorporates the plugin action is initiated. [See the documentation](https://manual.bubble.io/core-resources/api/the-bubble-api/the-data-api/data-api-requests)",
version: "0.0.{{ts}}",
type: "source",
dedupe: "unique",
props: {
bubble,
db: "$.service.db",
workflowId: {
propDefinition: [
bubble,
"workflowId",
],
},
timer: {
type: "$.interface.timer",
default: {
intervalSeconds: 60,
},
},
},
hooks: {
async deploy() {
await this.emitEvents();
},
async activate() {
// Setup webhook or other necessary activation logic if required
},
async deactivate() {
// Clean up webhook or other deactivation steps if required
},
},
methods: {
async emitEvents() {
const events = await this.bubble.listenForWorkflow({
workflowId: this.workflowId,
});

for (const event of events.reverse()) {
this.$emit(event, {
summary: `New workflow event for ${event.workflow_id}`,
ts: new Date(event.timestamp).getTime(),
});
}
},
},
async run() {
await this.emitEvents();
},
};
Loading