Skip to content

Commit 7ff91a1

Browse files
committed
domo init
1 parent 993149f commit 7ff91a1

File tree

7 files changed

+682
-3
lines changed

7 files changed

+682
-3
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import domo from "../../domo.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "domo-add-data-to-dataset",
6+
name: "Add Data to Dataset",
7+
description: "Adds new rows of data to an existing Domo dataset. [See the documentation]()",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
domo,
12+
datasetId: {
13+
propDefinition: [
14+
domo,
15+
"datasetId",
16+
],
17+
},
18+
data: {
19+
propDefinition: [
20+
domo,
21+
"data",
22+
],
23+
},
24+
},
25+
async run({ $ }) {
26+
const response = await this.domo.addDatasetRows({
27+
datasetId: this.datasetId,
28+
data: this.data,
29+
});
30+
$.export("$summary", `Added ${this.data.length} rows to dataset ${this.datasetId}`);
31+
return response;
32+
},
33+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import domo from "../../domo.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "domo-update-card-description",
6+
name: "Update Card Description",
7+
description: "Updates the description of an existing card in Domo. [See the documentation]()",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
domo,
12+
updateCardId: {
13+
propDefinition: [
14+
domo,
15+
"updateCardId",
16+
],
17+
},
18+
newDescription: {
19+
propDefinition: [
20+
domo,
21+
"newDescription",
22+
],
23+
},
24+
},
25+
async run({ $ }) {
26+
const response = await this.domo.updateCardDescription({
27+
cardId: this.updateCardId,
28+
newDescription: this.newDescription,
29+
});
30+
$.export("$summary", `Successfully updated description for card ID ${this.updateCardId}`);
31+
return response;
32+
},
33+
};

components/domo/domo.app.mjs

Lines changed: 214 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,223 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "domo",
4-
propDefinitions: {},
6+
version: "0.0.{{ts}}",
7+
propDefinitions: {
8+
// Emit new event when a new dataset is added
9+
datasetOwner: {
10+
type: "string",
11+
label: "Dataset Owner",
12+
description: "Filter datasets by owner.",
13+
optional: true,
14+
},
15+
datasetTags: {
16+
type: "string[]",
17+
label: "Dataset Tags",
18+
description: "Filter datasets by tags.",
19+
optional: true,
20+
},
21+
// Emit new event when data within a specific card is updated
22+
cardId: {
23+
type: "string",
24+
label: "Card ID",
25+
description: "The ID of the card to monitor for data updates.",
26+
},
27+
thresholds: {
28+
type: "string[]",
29+
label: "Thresholds",
30+
description: "Conditions or thresholds for data updates, in JSON format.",
31+
optional: true,
32+
},
33+
conditions: {
34+
type: "string[]",
35+
label: "Conditions",
36+
description: "Conditions for data updates, in JSON format.",
37+
optional: true,
38+
},
39+
projectId: {
40+
type: "string",
41+
label: "Project ID",
42+
description: "The ID of the project.",
43+
optional: true,
44+
async options() {
45+
const projects = await this.listProjects();
46+
return projects.map((project) => ({
47+
label: project.name,
48+
value: project.id,
49+
}));
50+
},
51+
},
52+
listId: {
53+
type: "string",
54+
label: "List ID",
55+
description: "The ID of the list.",
56+
optional: true,
57+
async options() {
58+
if (!this.projectId) {
59+
return [];
60+
}
61+
const lists = await this.listLists({
62+
projectId: this.projectId,
63+
});
64+
return lists.map((list) => ({
65+
label: list.name,
66+
value: list.id,
67+
}));
68+
},
69+
},
70+
// Emit new event when an alert is triggered
71+
alertTypes: {
72+
type: "string[]",
73+
label: "Alert Types",
74+
description: "Filter alerts by specific types.",
75+
optional: true,
76+
},
77+
relatedDatasets: {
78+
type: "string[]",
79+
label: "Related Datasets",
80+
description: "Filter alerts by related datasets.",
81+
optional: true,
82+
},
83+
// Add new rows of data to an existing dataset
84+
datasetId: {
85+
type: "string",
86+
label: "Dataset ID",
87+
description: "The ID of the dataset to add data to.",
88+
},
89+
data: {
90+
type: "string[]",
91+
label: "Data",
92+
description:
93+
"The data to add to the dataset, as JSON strings representing objects or arrays.",
94+
},
95+
// Update the description of an existing card
96+
updateCardId: {
97+
type: "string",
98+
label: "Card ID",
99+
description: "The ID of the card to update.",
100+
},
101+
newDescription: {
102+
type: "string",
103+
label: "New Description",
104+
description: "The new description for the card.",
105+
},
106+
},
5107
methods: {
6-
// this.$auth contains connected account data
108+
// Existing method
7109
authKeys() {
8110
console.log(Object.keys(this.$auth));
9111
},
112+
_baseUrl() {
113+
return "https://api.domo.com";
114+
},
115+
async _makeRequest(opts = {}) {
116+
const {
117+
$, method = "GET", path = "/", headers = {}, data, params, ...otherOpts
118+
} = opts;
119+
return axios($, {
120+
method,
121+
url: this._baseUrl() + path,
122+
headers: {
123+
...headers,
124+
"Authorization": `Bearer ${this.$auth.oauth_access_token}`,
125+
"Content-Type": "application/json",
126+
},
127+
data: data || undefined,
128+
params: params || undefined,
129+
...otherOpts,
130+
});
131+
},
132+
// Method to list all projects
133+
async listProjects(opts = {}) {
134+
return this._makeRequest({
135+
method: "GET",
136+
path: "/v1/projects",
137+
...opts,
138+
});
139+
},
140+
// Method to list all lists within a project
141+
async listLists({
142+
projectId, ...opts
143+
}) {
144+
return this._makeRequest({
145+
method: "GET",
146+
path: `/v1/projects/${projectId}/lists`,
147+
...opts,
148+
});
149+
},
150+
// Method to add new rows to a dataset
151+
async addDatasetRows({
152+
datasetId, data, ...opts
153+
}) {
154+
const parsedData = data.map((row) => JSON.parse(row));
155+
return this._makeRequest({
156+
method: "POST",
157+
path: `/v1/datasets/${datasetId}/data`,
158+
data: parsedData,
159+
...opts,
160+
});
161+
},
162+
// Method to update card description
163+
async updateCardDescription({
164+
cardId, newDescription, ...opts
165+
}) {
166+
return this._makeRequest({
167+
method: "PUT",
168+
path: `/v1/cards/${cardId}`,
169+
data: {
170+
description: newDescription,
171+
},
172+
...opts,
173+
});
174+
},
175+
// Method to list alerts
176+
async listAlerts(opts = {}) {
177+
return this._makeRequest({
178+
method: "GET",
179+
path: "/v1/alerts",
180+
...opts,
181+
});
182+
},
183+
// Method to get alert details
184+
async getAlertDetails({
185+
alertId, ...opts
186+
}) {
187+
return this._makeRequest({
188+
method: "GET",
189+
path: `/v1/alerts/${alertId}`,
190+
...opts,
191+
});
192+
},
193+
// Method to get card data
194+
async getCardData({
195+
cardId, ...opts
196+
}) {
197+
return this._makeRequest({
198+
method: "GET",
199+
path: `/v1/cards/${cardId}/data`,
200+
...opts,
201+
});
202+
},
203+
// Pagination method
204+
async paginate(fn, ...opts) {
205+
let results = [];
206+
let response;
207+
let offset = 0;
208+
const limit = 100;
209+
210+
do {
211+
response = await fn({
212+
offset,
213+
limit,
214+
...opts,
215+
});
216+
results = results.concat(response);
217+
offset += limit;
218+
} while (response.length === limit);
219+
220+
return results;
221+
},
10222
},
11223
};

components/domo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"publishConfig": {
1313
"access": "public"
1414
}
15-
}
15+
}

0 commit comments

Comments
 (0)