Skip to content

Commit 9a2abb5

Browse files
committed
[Components] retool - new components
1 parent 852838a commit 9a2abb5

File tree

9 files changed

+260
-19
lines changed

9 files changed

+260
-19
lines changed

components/retool/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import app from "../../retool.app.mjs";
2+
3+
export default {
4+
key: "retool-create-organization-user-attribute",
5+
name: "Create Organization User Attribute",
6+
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).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
name: {
12+
type: "string",
13+
label: "Attribute Name",
14+
description: "The name of the user attribute. Must be alphanumeric and without spaces.",
15+
},
16+
label: {
17+
type: "string",
18+
label: "Attribute Label",
19+
description: "A short description of the user attribute",
20+
},
21+
dataType: {
22+
type: "string",
23+
label: "Data Type",
24+
description: "The data type of the attribute",
25+
options: [
26+
"string",
27+
"json",
28+
"number",
29+
],
30+
},
31+
defaultValue: {
32+
type: "string",
33+
label: "Default Value",
34+
description: "A default value to apply to users that don't have an attribute set",
35+
optional: true,
36+
},
37+
},
38+
methods: {
39+
createOrgUserAttribute(args = {}) {
40+
return this.app.post({
41+
path: "/user_attributes",
42+
...args,
43+
});
44+
},
45+
},
46+
async run({ $ }) {
47+
const {
48+
createOrgUserAttribute,
49+
name,
50+
label,
51+
dataType,
52+
defaultValue,
53+
} = this;
54+
55+
const response = await createOrgUserAttribute({
56+
$,
57+
data: {
58+
name,
59+
label,
60+
dataType,
61+
defaultValue,
62+
},
63+
});
64+
$.export("$summary", `Successfully created organization user attribute with ID \`${response.data.id}\``);
65+
return response;
66+
},
67+
};
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import app from "../../retool.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "retool-create-user",
6+
name: "Create User",
7+
description: "Creates a new user. [See the documentation](https://docs.retool.com/reference/api/v2#tag/Users/paths/~1users/post).",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
email: {
13+
type: "string",
14+
label: "Email",
15+
description: "The email of the user to be created.",
16+
},
17+
firstName: {
18+
type: "string",
19+
label: "First Name",
20+
description: "The first name of the user.",
21+
},
22+
lastName: {
23+
type: "string",
24+
label: "Last Name",
25+
description: "The last name of the user.",
26+
},
27+
active: {
28+
type: "boolean",
29+
label: "Active",
30+
description: "Whether the user should be active. Defaults to `true` if not provided.",
31+
optional: true,
32+
},
33+
metadata: {
34+
type: "object",
35+
label: "Metadata",
36+
description: "Additional metadata to associate with the user.",
37+
optional: true,
38+
},
39+
userType: {
40+
type: "string",
41+
label: "User Type",
42+
description: "The type of the user.",
43+
optional: true,
44+
options: [
45+
"default",
46+
"mobile",
47+
"embed",
48+
],
49+
},
50+
},
51+
methods: {
52+
createUser(args = {}) {
53+
return this.app.post({
54+
versionPath: constants.VERSION_PATH.V2,
55+
path: "/users",
56+
...args,
57+
});
58+
},
59+
},
60+
async run({ $ }) {
61+
const {
62+
createUser,
63+
email,
64+
firstName,
65+
lastName,
66+
active,
67+
metadata,
68+
userType,
69+
} = this;
70+
71+
const response = await createUser({
72+
$,
73+
data: {
74+
email,
75+
first_name: firstName,
76+
last_name: lastName,
77+
active,
78+
metadata,
79+
user_type: userType,
80+
},
81+
});
82+
83+
$.export("$summary", `Successfully created user with ID \`${response.data.id}\`.`);
84+
return response;
85+
},
86+
};
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import app from "../../retool.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "retool-trigger-workflow",
6+
name: "Trigger Workflow",
7+
description: "Trigger a workflow. [See the documentation](https://docs.retool.com/workflows/guides/webhooks#send-a-webhook-event).",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
workflowId: {
13+
type: "string",
14+
label: "Workflow ID",
15+
description: "The unique identifier for the workflow you want to trigger.",
16+
},
17+
apiKey: {
18+
type: "string",
19+
label: "API Key",
20+
description: "The API key of the workflow you want to trigger. You can find it in the webhook settings of the workflow.",
21+
},
22+
data: {
23+
type: "object",
24+
label: "Input Parameters",
25+
description: "The input parameters to pass to the workflow, if any.",
26+
optional: true,
27+
},
28+
},
29+
methods: {
30+
triggerWorkflow({
31+
workflowId, apiKey, ...args
32+
}) {
33+
return this.app.post({
34+
versionPath: constants.VERSION_PATH.V2,
35+
path: `/workflows/${workflowId}/startTrigger`,
36+
headers: {
37+
"Content-Type": "application/json",
38+
"X-Workflow-Api-Key": apiKey,
39+
},
40+
...args,
41+
});
42+
},
43+
},
44+
async run({ $ }) {
45+
const {
46+
triggerWorkflow,
47+
workflowId,
48+
apiKey,
49+
data,
50+
} = this;
51+
52+
const response = await triggerWorkflow({
53+
$,
54+
workflowId,
55+
apiKey,
56+
data,
57+
});
58+
$.export("$summary", "Successfully triggered workflow");
59+
return response;
60+
},
61+
};

components/retool/app/retool.app.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const BASE_URL = "https://api.retool.com";
2+
const VERSION_PATH = {
3+
V1: "/v1",
4+
V2: "/api/v2",
5+
};
6+
7+
export default {
8+
BASE_URL,
9+
VERSION_PATH,
10+
};

components/retool/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/retool",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Retool Components",
55
"main": "dist/app/retool.app.mjs",
66
"keywords": [

components/retool/retool.app.mjs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
4+
export default {
5+
type: "app",
6+
app: "retool",
7+
methods: {
8+
getUrl(path, versionPath = constants.VERSION_PATH.V2) {
9+
return `${constants.BASE_URL}${versionPath}${path}`;
10+
},
11+
getHeaders(headers) {
12+
return {
13+
Authorization: `Bearer ${this.$auth.access_token}`,
14+
Accept: "application/json",
15+
...headers,
16+
};
17+
},
18+
_makeRequest({
19+
$ = this, path, headers, versionPath, ...args
20+
} = {}) {
21+
return axios($, {
22+
...args,
23+
debug: true,
24+
url: this.getUrl(path, versionPath),
25+
headers: this.getHeaders(headers),
26+
});
27+
},
28+
post(args = {}) {
29+
return this._makeRequest({
30+
method: "POST",
31+
...args,
32+
});
33+
},
34+
},
35+
};

pnpm-lock.yaml

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)