Skip to content

[Components] retool - new components #16702

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
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 0 additions & 3 deletions components/retool/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import app from "../../retool.app.mjs";

export default {
key: "retool-create-organization-user-attribute",
name: "Create Organization User Attribute",
description: "Create a new user attribute for the organization. [See the documentation](https://docs.retool.com/reference/api/v2#tag/User-Attributes/paths/~1user_attributes/post).",
version: "0.0.1",
type: "action",
props: {
app,
name: {
type: "string",
label: "Attribute Name",
description: "The name of the user attribute. Must be alphanumeric and without spaces.",
},
label: {
type: "string",
label: "Attribute Label",
description: "A short description of the user attribute",
},
dataType: {
type: "string",
label: "Data Type",
description: "The data type of the attribute",
options: [
"string",
"json",
"number",
],
},
defaultValue: {
type: "string",
label: "Default Value",
description: "A default value to apply to users that don't have an attribute set",
optional: true,
},
},
methods: {
createOrgUserAttribute(args = {}) {
return this.app.post({
path: "/user_attributes",
...args,
});
},
},
async run({ $ }) {
const {
createOrgUserAttribute,
name,
label,
dataType,
defaultValue,
} = this;

const response = await createOrgUserAttribute({
$,
data: {
name,
label,
dataType,
defaultValue,
},
});
$.export("$summary", `Successfully created organization user attribute with ID \`${response.data.id}\``);
return response;
},
};
86 changes: 86 additions & 0 deletions components/retool/actions/create-user/create-user.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import app from "../../retool.app.mjs";
import constants from "../../common/constants.mjs";

export default {
key: "retool-create-user",
name: "Create User",
description: "Creates a new user. [See the documentation](https://docs.retool.com/reference/api/v2#tag/Users/paths/~1users/post).",
version: "0.0.1",
type: "action",
props: {
app,
email: {
type: "string",
label: "Email",
description: "The email of the user to be created.",
},
firstName: {
type: "string",
label: "First Name",
description: "The first name of the user.",
},
lastName: {
type: "string",
label: "Last Name",
description: "The last name of the user.",
},
active: {
type: "boolean",
label: "Active",
description: "Whether the user should be active. Defaults to `true` if not provided.",
optional: true,
},
metadata: {
type: "object",
label: "Metadata",
description: "Additional metadata to associate with the user.",
optional: true,
},
userType: {
type: "string",
label: "User Type",
description: "The type of the user.",
optional: true,
options: [
"default",
"mobile",
"embed",
],
},
},
methods: {
createUser(args = {}) {
return this.app.post({
versionPath: constants.VERSION_PATH.V2,
path: "/users",
...args,
});
},
},
async run({ $ }) {
const {
createUser,
email,
firstName,
lastName,
active,
metadata,
userType,
} = this;

const response = await createUser({
$,
data: {
email,
first_name: firstName,
last_name: lastName,
active,
metadata,
user_type: userType,
},
});

$.export("$summary", `Successfully created user with ID \`${response.data.id}\`.`);
return response;
},
};
61 changes: 61 additions & 0 deletions components/retool/actions/trigger-workflow/trigger-workflow.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import app from "../../retool.app.mjs";
import constants from "../../common/constants.mjs";

export default {
key: "retool-trigger-workflow",
name: "Trigger Workflow",
description: "Trigger a workflow. [See the documentation](https://docs.retool.com/workflows/guides/webhooks#send-a-webhook-event).",
version: "0.0.1",
type: "action",
props: {
app,
workflowId: {
type: "string",
label: "Workflow ID",
description: "The unique identifier for the workflow you want to trigger.",
},
apiKey: {
type: "string",
label: "API Key",
description: "The API key of the workflow you want to trigger. You can find it in the webhook settings of the workflow.",
},
data: {
type: "object",
label: "Input Parameters",
description: "The input parameters to pass to the workflow, if any.",
optional: true,
},
},
methods: {
triggerWorkflow({
workflowId, apiKey, ...args
}) {
return this.app.post({
versionPath: constants.VERSION_PATH.V2,
path: `/workflows/${workflowId}/startTrigger`,
headers: {
"Content-Type": "application/json",
"X-Workflow-Api-Key": apiKey,
},
...args,
});
},
},
async run({ $ }) {
const {
triggerWorkflow,
workflowId,
apiKey,
data,
} = this;

const response = await triggerWorkflow({
$,
workflowId,
apiKey,
data,
});
$.export("$summary", "Successfully triggered workflow");
return response;
},
};
13 changes: 0 additions & 13 deletions components/retool/app/retool.app.ts

This file was deleted.

10 changes: 10 additions & 0 deletions components/retool/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const BASE_URL = "https://api.retool.com";
const VERSION_PATH = {
V1: "/v1",
V2: "/api/v2",
};

export default {
BASE_URL,
VERSION_PATH,
};
2 changes: 1 addition & 1 deletion components/retool/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/retool",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Retool Components",
"main": "dist/app/retool.app.mjs",
"keywords": [
Expand Down
35 changes: 35 additions & 0 deletions components/retool/retool.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "retool",
methods: {
getUrl(path, versionPath = constants.VERSION_PATH.V2) {
return `${constants.BASE_URL}${versionPath}${path}`;
},
getHeaders(headers) {
return {
Authorization: `Bearer ${this.$auth.access_token}`,
Accept: "application/json",
...headers,
};
},
_makeRequest({
$ = this, path, headers, versionPath, ...args
} = {}) {
return axios($, {
...args,
debug: true,
url: this.getUrl(path, versionPath),
headers: this.getHeaders(headers),
});
},
post(args = {}) {
return this._makeRequest({
method: "POST",
...args,
});
},
},
};
2 changes: 0 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading