Skip to content

Commit ce9fef1

Browse files
committed
init
1 parent 4bd5d9e commit ce9fef1

File tree

6 files changed

+366
-5
lines changed

6 files changed

+366
-5
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import mural from "../../mural.app.mjs";
2+
3+
export default {
4+
key: "mural-create-mural",
5+
name: "Create Mural",
6+
description: "Create a new mural within a specified workspace.",
7+
version: "0.0.{{ts}}",
8+
type: "action",
9+
props: {
10+
mural,
11+
workspaceId: mural.propDefinitions.workspaceId,
12+
name: mural.propDefinitions.name,
13+
description: {
14+
...mural.propDefinitions.description,
15+
optional: true,
16+
},
17+
templateId: {
18+
...mural.propDefinitions.templateId,
19+
optional: true,
20+
},
21+
},
22+
async run({ $ }) {
23+
const response = await this.mural.createMural({
24+
data: {
25+
workspaceId: this.workspaceId,
26+
name: this.name,
27+
description: this.description,
28+
templateId: this.templateId,
29+
},
30+
});
31+
$.export("$summary", `Successfully created mural ${this.name}`);
32+
return response;
33+
},
34+
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import mural from "../../mural.app.mjs";
2+
3+
export default {
4+
key: "mural-create-sticky",
5+
name: "Create Sticky",
6+
description: "Create a new sticky note within a given mural. [See the documentation](https://developers.mural.co/public/docs/mural-api)",
7+
version: "0.0.{{ts}}",
8+
type: "action",
9+
props: {
10+
mural,
11+
muralId: {
12+
propDefinition: [
13+
mural,
14+
"muralId",
15+
],
16+
},
17+
content: {
18+
propDefinition: [
19+
mural,
20+
"stickyContent",
21+
],
22+
},
23+
color: {
24+
propDefinition: [
25+
mural,
26+
"color",
27+
],
28+
optional: true,
29+
},
30+
position: {
31+
propDefinition: [
32+
mural,
33+
"position",
34+
],
35+
optional: true,
36+
},
37+
},
38+
async run({ $ }) {
39+
const response = await this.mural.createSticky({
40+
data: {
41+
muralId: this.muralId,
42+
content: this.content,
43+
color: this.color,
44+
position: this.position,
45+
},
46+
});
47+
$.export("$summary", `Successfully created sticky note with ID: ${response.id}`);
48+
return response;
49+
},
50+
};

components/mural/mural.app.mjs

Lines changed: 101 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,107 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "mural",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
muralId: {
8+
type: "string",
9+
label: "Mural ID",
10+
description: "The ID of the Mural.",
11+
required: true,
12+
},
13+
stickyId: {
14+
type: "string",
15+
label: "Sticky ID",
16+
description: "The ID of the Sticky Note.",
17+
required: true,
18+
},
19+
stickyContent: {
20+
type: "string",
21+
label: "Sticky Content",
22+
description: "The content of the Sticky Note.",
23+
optional: true,
24+
},
25+
userId: {
26+
type: "string",
27+
label: "User ID",
28+
description: "The ID of the User.",
29+
required: true,
30+
},
31+
muralTitle: {
32+
type: "string",
33+
label: "Mural Title",
34+
description: "The title of the Mural.",
35+
optional: true,
36+
},
37+
workspaceId: {
38+
type: "string",
39+
label: "Workspace ID",
40+
description: "The ID of the Workspace.",
41+
required: true,
42+
},
43+
name: {
44+
type: "string",
45+
label: "Name",
46+
description: "The name of the Mural.",
47+
required: true,
48+
},
49+
description: {
50+
type: "string",
51+
label: "Description",
52+
description: "A short description of the Mural.",
53+
optional: true,
54+
},
55+
templateId: {
56+
type: "string",
57+
label: "Template ID",
58+
description: "The ID of a pre-existing design.",
59+
optional: true,
60+
},
61+
color: {
62+
type: "string",
63+
label: "Color",
64+
description: "The color of the Sticky Note.",
65+
optional: true,
66+
},
67+
position: {
68+
type: "string",
69+
label: "Position",
70+
description: "The position of the Sticky Note.",
71+
optional: true,
72+
},
73+
},
574
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
75+
_baseUrl() {
76+
return "https://app.mural.co/api/public";
77+
},
78+
async _makeRequest(opts = {}) {
79+
const {
80+
$ = this, method = "GET", path, headers, ...otherOpts
81+
} = opts;
82+
return axios($, {
83+
...otherOpts,
84+
method,
85+
url: this._baseUrl() + path,
86+
headers: {
87+
...headers,
88+
Authorization: `Bearer ${this.$auth.oauth_access_token}`,
89+
},
90+
});
91+
},
92+
async createMural(opts = {}) {
93+
return this._makeRequest({
94+
method: "POST",
95+
path: "/v1/murals",
96+
...opts,
97+
});
98+
},
99+
async createSticky(opts = {}) {
100+
return this._makeRequest({
101+
method: "POST",
102+
path: "/v1/murals/sticky",
103+
...opts,
104+
});
9105
},
10106
},
11-
};
107+
};
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import mural from "../../mural.app.mjs";
2+
3+
export default {
4+
key: "mural-new-area",
5+
name: "New Area Created",
6+
description: "Emits an event when a new area is created in the user's mural",
7+
version: "0.0.{{ts}}",
8+
type: "source",
9+
dedupe: "unique",
10+
props: {
11+
mural,
12+
muralId: {
13+
propDefinition: [
14+
mural,
15+
"muralId",
16+
],
17+
},
18+
db: "$.service.db",
19+
timer: {
20+
type: "$.interface.timer",
21+
default: {
22+
intervalSeconds: 60 * 15, // 15 minutes
23+
},
24+
},
25+
},
26+
methods: {
27+
_getLastEvent() {
28+
return this.db.get("lastEvent") || null;
29+
},
30+
_setLastEvent(lastEvent) {
31+
this.db.set("lastEvent", lastEvent);
32+
},
33+
},
34+
async run() {
35+
const lastEvent = this._getLastEvent();
36+
const newEvent = await this.mural.getArea(this.muralId);
37+
if (!lastEvent || new Date(newEvent.created_at) > new Date(lastEvent.created_at)) {
38+
this.$emit(newEvent, {
39+
id: newEvent.id,
40+
summary: `New area created: ${newEvent.name}`,
41+
ts: Date.parse(newEvent.created_at),
42+
});
43+
this._setLastEvent(newEvent);
44+
}
45+
},
46+
};
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import mural from "../../mural.app.mjs";
2+
3+
export default {
4+
key: "mural-new-mural",
5+
name: "New Mural",
6+
description: "Emit new event when a new mural is created.",
7+
version: "0.0.{{ts}}",
8+
type: "source",
9+
dedupe: "unique",
10+
props: {
11+
mural: {
12+
type: "app",
13+
app: "mural",
14+
},
15+
muralId: {
16+
propDefinition: [
17+
mural,
18+
"muralId",
19+
],
20+
},
21+
userId: {
22+
propDefinition: [
23+
mural,
24+
"userId",
25+
],
26+
},
27+
muralTitle: {
28+
propDefinition: [
29+
mural,
30+
"muralTitle",
31+
],
32+
optional: true,
33+
},
34+
timer: {
35+
type: "$.interface.timer",
36+
default: {
37+
intervalSeconds: 60 * 15, // 15 minutes
38+
},
39+
},
40+
},
41+
methods: {
42+
...mural.methods,
43+
generateMeta(mural) {
44+
const {
45+
id, name, createdAt,
46+
} = mural;
47+
return {
48+
id,
49+
summary: name,
50+
ts: Date.parse(createdAt),
51+
};
52+
},
53+
},
54+
async run() {
55+
const murals = await this.mural._makeRequest({
56+
path: `/v1/murals/${this.muralId}`,
57+
});
58+
for (const mural of murals) {
59+
if (mural.id === this.muralId && mural.createdBy === this.userId) {
60+
this.$emit(mural, this.generateMeta(mural));
61+
}
62+
}
63+
},
64+
};
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import mural from "../../mural.app.mjs";
2+
3+
export default {
4+
key: "mural-new-sticky",
5+
name: "New Sticky Note Created",
6+
description: "Emits an event each time a new sticky note is created in a specified mural",
7+
version: "0.0.{{ts}}",
8+
type: "source",
9+
dedupe: "unique",
10+
props: {
11+
mural: {
12+
type: "app",
13+
app: "mural",
14+
},
15+
muralId: {
16+
propDefinition: [
17+
mural,
18+
"muralId",
19+
],
20+
},
21+
stickyId: {
22+
propDefinition: [
23+
mural,
24+
"stickyId",
25+
],
26+
},
27+
stickyContent: {
28+
propDefinition: [
29+
mural,
30+
"stickyContent",
31+
],
32+
optional: true,
33+
},
34+
db: "$.service.db",
35+
timer: {
36+
type: "$.interface.timer",
37+
default: {
38+
intervalSeconds: 60 * 15, // 15 minutes
39+
},
40+
},
41+
},
42+
methods: {
43+
_getSticky() {
44+
return this.db.get("sticky") ?? {
45+
id: this.stickyId,
46+
};
47+
},
48+
_setSticky(sticky) {
49+
this.db.set("sticky", sticky);
50+
},
51+
},
52+
async run() {
53+
// get the sticky
54+
const sticky = await this.mural.createSticky({
55+
muralId: this.muralId,
56+
stickyId: this.stickyId,
57+
content: this.stickyContent,
58+
});
59+
60+
// check if the sticky is new
61+
const lastSticky = this._getSticky();
62+
if (sticky.id !== lastSticky.id) {
63+
this.$emit(sticky, {
64+
id: sticky.id,
65+
summary: `New Sticky: ${sticky.content}`,
66+
ts: Date.now(),
67+
});
68+
this._setSticky(sticky);
69+
}
70+
},
71+
};

0 commit comments

Comments
 (0)