@pipedream/pushcut 0.0.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # Overview
2
+
3
+ The Pushcut API enables the automation of iOS notifications with custom actions, triggering events based on various conditions. On Pipedream, you can harness this functionality to create intricate workflows, combining Pushcut notifications with a multitude of services to act based on data from APIs, schedules, or other apps. Think of Pushcut as a bridge between the real world and your digital tasks, letting you know when to act and offering shortcuts to execute specific automations directly from your iOS devices.
4
+
5
+ # Example Use Cases
6
+
7
+ - **Dynamic Notification for Calendar Events**: Send custom notifications for upcoming calendar events. By integrating with Google Calendar on Pipedream, you can schedule a workflow that fetches events and uses Pushcut to notify you with action buttons to check details or postpone events.
8
+
9
+ - **Smart Home Alerts**: Combine Pushcut with IoT platforms like SmartThings. Set up a Pipedream workflow that listens for sensor triggers in your home—like motion or door openings—and then sends a Pushcut notification to your device with options to toggle devices or set modes.
10
+
11
+ - **GitHub Repo Updates**: Stay on top of changes to your GitHub repositories. With a Pipedream workflow, get Pushcut notifications whenever there's a new commit, issue, or pull request. You can add action buttons to open the GitHub app, directly view the changes, or even run a CI/CD pipeline.
@@ -0,0 +1,49 @@
1
+ import pushcut from "../../pushcut.app.mjs";
2
+
3
+ export default {
4
+ key: "pushcut-execute-homekit-scene",
5
+ name: "Execute Homekit Scene",
6
+ description: "Schedules an Automation Server action request for a homekit scene. [See the documentation](https://www.pushcut.io/webapi)",
7
+ version: "0.0.2",
8
+ annotations: {
9
+ destructiveHint: false,
10
+ openWorldHint: true,
11
+ readOnlyHint: false,
12
+ },
13
+ type: "action",
14
+ props: {
15
+ pushcut,
16
+ homekit: {
17
+ propDefinition: [
18
+ pushcut,
19
+ "homekitScene",
20
+ ],
21
+ },
22
+ timeout: {
23
+ propDefinition: [
24
+ pushcut,
25
+ "timeout",
26
+ ],
27
+ },
28
+ delay: {
29
+ propDefinition: [
30
+ pushcut,
31
+ "delay",
32
+ ],
33
+ },
34
+ },
35
+ async run({ $ }) {
36
+ const response = await this.pushcut.executeAction({
37
+ data: {
38
+ homekit: this.homekit,
39
+ timeout: this.timeout,
40
+ delay: this.delay,
41
+ },
42
+ $,
43
+ });
44
+
45
+ $.export("$summary", `Successfully executed homekit ${this.homekit}.`);
46
+
47
+ return response;
48
+ },
49
+ };
@@ -0,0 +1,49 @@
1
+ import pushcut from "../../pushcut.app.mjs";
2
+
3
+ export default {
4
+ key: "pushcut-execute-shortcut",
5
+ name: "Execute Shortcut",
6
+ description: "Schedules an Automation Server action request for a shortcut. [See the documentation](https://www.pushcut.io/webapi)",
7
+ version: "0.0.2",
8
+ annotations: {
9
+ destructiveHint: false,
10
+ openWorldHint: true,
11
+ readOnlyHint: false,
12
+ },
13
+ type: "action",
14
+ props: {
15
+ pushcut,
16
+ shortcut: {
17
+ propDefinition: [
18
+ pushcut,
19
+ "shortcut",
20
+ ],
21
+ },
22
+ timeout: {
23
+ propDefinition: [
24
+ pushcut,
25
+ "timeout",
26
+ ],
27
+ },
28
+ delay: {
29
+ propDefinition: [
30
+ pushcut,
31
+ "delay",
32
+ ],
33
+ },
34
+ },
35
+ async run({ $ }) {
36
+ const response = await this.pushcut.executeAction({
37
+ data: {
38
+ shortcut: this.shortcut,
39
+ timeout: this.timeout,
40
+ delay: this.delay,
41
+ },
42
+ $,
43
+ });
44
+
45
+ $.export("$summary", `Successfully executed shortcut ${this.shortcut}.`);
46
+
47
+ return response;
48
+ },
49
+ };
@@ -0,0 +1,26 @@
1
+ import pushcut from "../../pushcut.app.mjs";
2
+
3
+ export default {
4
+ key: "pushcut-list-homekit-scene-options",
5
+ name: "List Homekit Scene Options",
6
+ description: "Retrieves available options for the Homekit Scene field.",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ pushcut,
16
+ },
17
+ async run({ $ }) {
18
+ const options = await pushcut.propDefinitions.homekitScene.options.call(this.pushcut, {});
19
+ $.export("$summary", `Successfully retrieved ${options.length} option${
20
+ options.length === 1
21
+ ? ""
22
+ : "s"
23
+ }`);
24
+ return options;
25
+ },
26
+ };
@@ -0,0 +1,26 @@
1
+ import pushcut from "../../pushcut.app.mjs";
2
+
3
+ export default {
4
+ key: "pushcut-list-notification-options",
5
+ name: "List Notification Options",
6
+ description: "Retrieves available options for the Notification field.",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ pushcut,
16
+ },
17
+ async run({ $ }) {
18
+ const options = await pushcut.propDefinitions.notification.options.call(this.pushcut, {});
19
+ $.export("$summary", `Successfully retrieved ${options.length} option${
20
+ options.length === 1
21
+ ? ""
22
+ : "s"
23
+ }`);
24
+ return options;
25
+ },
26
+ };
@@ -0,0 +1,26 @@
1
+ import pushcut from "../../pushcut.app.mjs";
2
+
3
+ export default {
4
+ key: "pushcut-list-shortcut-options",
5
+ name: "List Shortcut Options",
6
+ description: "Retrieves available options for the Shortcut field.",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ pushcut,
16
+ },
17
+ async run({ $ }) {
18
+ const options = await pushcut.propDefinitions.shortcut.options.call(this.pushcut, {});
19
+ $.export("$summary", `Successfully retrieved ${options.length} option${
20
+ options.length === 1
21
+ ? ""
22
+ : "s"
23
+ }`);
24
+ return options;
25
+ },
26
+ };
@@ -0,0 +1,35 @@
1
+ import pushcut from "../../pushcut.app.mjs";
2
+
3
+ export default {
4
+ key: "pushcut-send-notification",
5
+ name: "Send Notification",
6
+ description: "Sends a smart notification to your devices. [See the documentation](https://www.pushcut.io/webapi)",
7
+ version: "0.0.2",
8
+ annotations: {
9
+ destructiveHint: false,
10
+ openWorldHint: true,
11
+ readOnlyHint: false,
12
+ },
13
+ type: "action",
14
+ props: {
15
+ pushcut,
16
+ notification: {
17
+ propDefinition: [
18
+ pushcut,
19
+ "notification",
20
+ ],
21
+ },
22
+ },
23
+ async run({ $ }) {
24
+ const response = await this.pushcut.sendNotification({
25
+ notification: this.notification,
26
+ $,
27
+ });
28
+
29
+ if (response.id) {
30
+ $.export("$summary", `Successfully sent notification with ID ${response.id}.`);
31
+ }
32
+
33
+ return response;
34
+ },
35
+ };
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@pipedream/pushcut",
3
- "version": "0.0.1",
3
+ "version": "0.2.0",
4
4
  "description": "Pipedream Pushcut Components",
5
- "main": "dist/app/pushcut.app.mjs",
5
+ "main": "pushcut.app.mjs",
6
6
  "keywords": [
7
7
  "pipedream",
8
8
  "pushcut"
9
9
  ],
10
- "files": [
11
- "dist"
12
- ],
13
10
  "homepage": "https://pipedream.com/apps/pushcut",
14
11
  "author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
15
12
  "publishConfig": {
16
13
  "access": "public"
14
+ },
15
+ "dependencies": {
16
+ "@pipedream/platform": "^1.6.8"
17
17
  }
18
18
  }
@@ -0,0 +1,103 @@
1
+ import { axios } from "@pipedream/platform";
2
+
3
+ export default {
4
+ type: "app",
5
+ app: "pushcut",
6
+ propDefinitions: {
7
+ notification: {
8
+ type: "string",
9
+ label: "Notification",
10
+ description: "Name of the notification",
11
+ async options() {
12
+ const notifications = await this.listNotifications();
13
+ return notifications?.map(({ id }) => id ) || [];
14
+ },
15
+ },
16
+ shortcut: {
17
+ type: "string",
18
+ label: "Shortcut",
19
+ description: "Name of the shortcut",
20
+ async options() {
21
+ const shortcuts = await this.listShortcuts();
22
+ return shortcuts?.map(({ id }) => id ) || [];
23
+ },
24
+ },
25
+ homekitScene: {
26
+ type: "string",
27
+ label: "Homekit Scene",
28
+ description: "Name of the homekit scene",
29
+ async options() {
30
+ const scenes = await this.listHomekitScenes();
31
+ return scenes?.map(({ id }) => id ) || [];
32
+ },
33
+ },
34
+ timeout: {
35
+ type: "string",
36
+ label: "Timeout",
37
+ description: "Timeout in seconds, or 'nowait'",
38
+ optional: true,
39
+ default: "nowait",
40
+ },
41
+ delay: {
42
+ type: "string",
43
+ label: "Delay",
44
+ description: "Duration in which this request should be executed. Eg: 10s, 15m, 6h",
45
+ optional: true,
46
+ },
47
+ },
48
+ methods: {
49
+ _baseUrl() {
50
+ return "https://api.pushcut.io/v1";
51
+ },
52
+ _headers() {
53
+ return {
54
+ "API-Key": `${this.$auth.api_key}`,
55
+ };
56
+ },
57
+ _makeRequest({
58
+ $ = this,
59
+ path,
60
+ ...args
61
+ }) {
62
+ return axios($, {
63
+ url: `${this._baseUrl()}${path}`,
64
+ headers: this._headers(),
65
+ ...args,
66
+ });
67
+ },
68
+ listNotifications(args = {}) {
69
+ return this._makeRequest({
70
+ path: "/notifications",
71
+ ...args,
72
+ });
73
+ },
74
+ listShortcuts(args = {}) {
75
+ return this._makeRequest({
76
+ path: "/shortcuts",
77
+ ...args,
78
+ });
79
+ },
80
+ listHomekitScenes(args = {}) {
81
+ return this._makeRequest({
82
+ path: "/scenes",
83
+ ...args,
84
+ });
85
+ },
86
+ executeAction(args = {}) {
87
+ return this._makeRequest({
88
+ path: "/execute",
89
+ method: "POST",
90
+ ...args,
91
+ });
92
+ },
93
+ sendNotification({
94
+ notification, ...args
95
+ }) {
96
+ return this._makeRequest({
97
+ path: `/notifications/${notification}`,
98
+ method: "POST",
99
+ ...args,
100
+ });
101
+ },
102
+ },
103
+ };
@@ -0,0 +1,47 @@
1
+ import pushcut from "../../pushcut.app.mjs";
2
+ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
3
+
4
+ export default {
5
+ key: "pushcut-action-created",
6
+ name: "New Action Created",
7
+ description: "Emit new event when a new action is created.",
8
+ version: "0.0.1",
9
+ type: "source",
10
+ dedupe: "unique",
11
+ props: {
12
+ pushcut,
13
+ timer: {
14
+ type: "$.interface.timer",
15
+ default: {
16
+ intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
17
+ },
18
+ },
19
+ actionType: {
20
+ type: "string",
21
+ label: "Type",
22
+ description: "Type of new action to watch for",
23
+ options: [
24
+ "shortcut",
25
+ "homekit",
26
+ ],
27
+ },
28
+ },
29
+ methods: {
30
+ generateMeta(action) {
31
+ return {
32
+ id: action.id,
33
+ summary: `${action.id}`,
34
+ ts: Date.now(),
35
+ };
36
+ },
37
+ },
38
+ async run() {
39
+ const actions = this.actionType === "shortcut"
40
+ ? await this.pushcut.listShortcuts()
41
+ : await this.pushcut.listHomekitScenes();
42
+ for (const action of actions) {
43
+ const meta = this.generateMeta(action);
44
+ this.$emit(action, meta);
45
+ }
46
+ },
47
+ };