Skip to content

Commit 12db647

Browse files
authored
New Components - notiff_io (#16470)
* notiff_io init * [Components] notiff_io #16263 Actions - Create Notification * pnpm update
1 parent 7c98955 commit 12db647

File tree

8 files changed

+185
-14
lines changed

8 files changed

+185
-14
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import common from "../../../notiff_io/actions/create-notification/create-notification.mjs";
2+
import { adjustPropDefinitions } from "../../common/utils.mjs";
3+
import app from "../../notiff.app.mjs";
4+
5+
const props = adjustPropDefinitions(common.props, app);
6+
7+
export default {
8+
...common,
9+
key: "notiff-create-notification",
10+
name: "Create Notification",
11+
description: "Send a new notification to a user or system via notiff.io. [See the documentation](https://notiff.io/articles/welcome-to-notiff-getting-started-with-your-notification-center)",
12+
version: "0.0.1",
13+
type: "action",
14+
methods: {
15+
getNotificationSourceId() {
16+
return this.app.$auth.notification_source_id;
17+
},
18+
},
19+
props: {
20+
app,
21+
...props,
22+
},
23+
};

components/notiff/common/utils.mjs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
export function adjustPropDefinitions(props, app) {
2+
return Object.fromEntries(
3+
Object.entries(props).map(([
4+
key,
5+
prop,
6+
]) => {
7+
const {
8+
propDefinition, ...otherValues
9+
} = prop;
10+
if (propDefinition) {
11+
const [
12+
, ...otherDefs
13+
] = propDefinition;
14+
return [
15+
key,
16+
{
17+
propDefinition: [
18+
app,
19+
...otherDefs,
20+
],
21+
...otherValues,
22+
},
23+
];
24+
}
25+
return [
26+
key,
27+
otherValues.type === "app"
28+
? null
29+
: otherValues,
30+
];
31+
})
32+
.filter(([
33+
key,
34+
value,
35+
]) => key != "idNotificationSource" && (value)),
36+
);
37+
}

components/notiff/notiff.app.mjs

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
import notiffIo from "../notiff_io/notiff_io.app.mjs";
2+
13
export default {
4+
...notiffIo,
25
type: "app",
36
app: "notiff",
4-
propDefinitions: {},
57
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
8+
...notiffIo.methods,
9+
_headers() {
10+
return {
11+
"Content-Type": "application/json",
12+
};
913
},
1014
},
1115
};

components/notiff/package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/notiff",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Notiff Components",
55
"main": "notiff.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import app from "../../notiff_io.app.mjs";
2+
3+
export default {
4+
key: "notiff_io-create-notification",
5+
name: "Create Notification",
6+
description: "Send a new notification to a user or system via notiff.io. [See the documentation](https://notiff.io/articles/welcome-to-notiff-getting-started-with-your-notification-center)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
idNotificationSource: {
12+
type: "string",
13+
label: "ID Notification Source",
14+
description: "To get your Notification Source ID, sign in to Notiff, go to the Settings menu with the gear icon on the top right, click the \"Settings\" option. Copy your Notification Source ID from the list.",
15+
secret: true,
16+
},
17+
title: {
18+
propDefinition: [
19+
app,
20+
"title",
21+
],
22+
},
23+
description: {
24+
propDefinition: [
25+
app,
26+
"description",
27+
],
28+
},
29+
url: {
30+
propDefinition: [
31+
app,
32+
"url",
33+
],
34+
},
35+
},
36+
methods: {
37+
getNotificationSourceId() {
38+
return this.idNotificationSource;
39+
},
40+
},
41+
async run({ $ }) {
42+
const response = await this.app.createNotification({
43+
$,
44+
data: {
45+
id_notification_source: this.getNotificationSourceId(),
46+
title: this.title,
47+
description: this.description,
48+
url: this.url,
49+
},
50+
});
51+
52+
$.export("$summary", `Notification titled "${this.title}" created successfully!`);
53+
return response;
54+
},
55+
};
+42-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,49 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "notiff_io",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
title: {
8+
type: "string",
9+
label: "Title",
10+
description: "The title of the notification.",
11+
},
12+
description: {
13+
type: "string",
14+
label: "Description",
15+
description: "The content/description of the notification.",
16+
},
17+
url: {
18+
type: "string",
19+
label: "URL",
20+
description: "The URL associated with the notification.",
21+
},
22+
},
523
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
24+
_baseUrl() {
25+
return "https://notiff.io/api/1.1/wf";
26+
},
27+
_headers() {
28+
return {
29+
Authorization: `Bearer ${this.$auth.oauth_access_token}`,
30+
};
31+
},
32+
_makeRequest({
33+
$ = this, path, ...opts
34+
}) {
35+
return axios($, {
36+
url: this._baseUrl() + path,
37+
headers: this._headers(),
38+
...opts,
39+
});
40+
},
41+
createNotification(opts = {}) {
42+
return this._makeRequest({
43+
method: "POST",
44+
path: "/create_notification",
45+
...opts,
46+
});
947
},
1048
},
1149
};

components/notiff_io/package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/notiff_io",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Notiff (OAuth) Components",
55
"main": "notiff_io.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}

pnpm-lock.yaml

+10-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)