@andrewohara/piece-pushcut 0.0.1

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.
Files changed (39) hide show
  1. package/README.md +7 -0
  2. package/activepieces-piece-pushcut-0.0.1.tgz +0 -0
  3. package/package.json +31 -0
  4. package/src/index.d.ts +1 -0
  5. package/src/index.js +36 -0
  6. package/src/index.js.map +1 -0
  7. package/src/lib/actions/create-subscription.d.ts +14 -0
  8. package/src/lib/actions/create-subscription.js +78 -0
  9. package/src/lib/actions/create-subscription.js.map +1 -0
  10. package/src/lib/actions/delete-subscription.d.ts +3 -0
  11. package/src/lib/actions/delete-subscription.js +32 -0
  12. package/src/lib/actions/delete-subscription.js.map +1 -0
  13. package/src/lib/actions/list-devices.d.ts +1 -0
  14. package/src/lib/actions/list-devices.js +26 -0
  15. package/src/lib/actions/list-devices.js.map +1 -0
  16. package/src/lib/actions/list-notifications.d.ts +1 -0
  17. package/src/lib/actions/list-notifications.js +29 -0
  18. package/src/lib/actions/list-notifications.js.map +1 -0
  19. package/src/lib/actions/list-subscriptions.d.ts +1 -0
  20. package/src/lib/actions/list-subscriptions.js +27 -0
  21. package/src/lib/actions/list-subscriptions.js.map +1 -0
  22. package/src/lib/actions/send-notification.d.ts +9 -0
  23. package/src/lib/actions/send-notification.js +138 -0
  24. package/src/lib/actions/send-notification.js.map +1 -0
  25. package/src/lib/actions/test-connection.d.ts +1 -0
  26. package/src/lib/actions/test-connection.js +35 -0
  27. package/src/lib/actions/test-connection.js.map +1 -0
  28. package/src/lib/common/api.d.ts +29 -0
  29. package/src/lib/common/api.js +107 -0
  30. package/src/lib/common/api.js.map +1 -0
  31. package/src/lib/common/auth.d.ts +2 -0
  32. package/src/lib/common/auth.js +20 -0
  33. package/src/lib/common/auth.js.map +1 -0
  34. package/src/lib/common/endpoints.d.ts +4 -0
  35. package/src/lib/common/endpoints.js +8 -0
  36. package/src/lib/common/endpoints.js.map +1 -0
  37. package/src/lib/triggers/pushcut-subscription-event.d.ts +18 -0
  38. package/src/lib/triggers/pushcut-subscription-event.js +81 -0
  39. package/src/lib/triggers/pushcut-subscription-event.js.map +1 -0
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # pieces-pushcut
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build pieces-pushcut` to build the library.
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@andrewohara/piece-pushcut",
3
+ "version": "0.0.1",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "type": "commonjs",
8
+ "main": "./src/index.js",
9
+ "types": "./src/index.d.ts",
10
+ "dependencies": {
11
+ "@sinclair/typebox": "0.34.11",
12
+ "ai": "^6.0.0",
13
+ "axios": "1.13.1",
14
+ "axios-retry": "4.4.1",
15
+ "deepmerge-ts": "7.1.0",
16
+ "form-data": "4.0.4",
17
+ "i18next": "23.13.0",
18
+ "mime-types": "2.1.35",
19
+ "nanoid": "3.3.8",
20
+ "semver": "7.6.0",
21
+ "socket.io-client": "4.8.1",
22
+ "tslib": "^2.3.0",
23
+ "zod": "4.1.13",
24
+ "@activepieces/pieces-common": "0.11.5",
25
+ "@activepieces/pieces-framework": "0.25.2",
26
+ "@activepieces/shared": "0.34.0"
27
+ },
28
+ "resolutions": {
29
+ "rollup": "npm:@rollup/wasm-node"
30
+ }
31
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const pushcut: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").SecretTextProperty<true>>;
package/src/index.js ADDED
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pushcut = void 0;
4
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
5
+ const shared_1 = require("@activepieces/shared");
6
+ const create_subscription_1 = require("./lib/actions/create-subscription");
7
+ const delete_subscription_1 = require("./lib/actions/delete-subscription");
8
+ const list_devices_1 = require("./lib/actions/list-devices");
9
+ const list_notifications_1 = require("./lib/actions/list-notifications");
10
+ const list_subscriptions_1 = require("./lib/actions/list-subscriptions");
11
+ const create_subscription_2 = require("./lib/actions/create-subscription");
12
+ const send_notification_1 = require("./lib/actions/send-notification");
13
+ const test_connection_1 = require("./lib/actions/test-connection");
14
+ const auth_1 = require("./lib/common/auth");
15
+ const pushcut_subscription_event_1 = require("./lib/triggers/pushcut-subscription-event");
16
+ exports.pushcut = (0, pieces_framework_1.createPiece)({
17
+ displayName: 'Pushcut',
18
+ description: 'Send Pushcut notifications and trigger iOS shortcuts from your workflows.',
19
+ auth: auth_1.pushcutAuth,
20
+ minimumSupportedRelease: '0.36.1',
21
+ logoUrl: 'https://cdn.activepieces.com/pieces/pushcut.png',
22
+ authors: ['activepieces'],
23
+ categories: [shared_1.PieceCategory.COMMUNICATION],
24
+ actions: [
25
+ send_notification_1.sendNotification,
26
+ list_devices_1.listDevices,
27
+ list_notifications_1.listNotifications,
28
+ list_subscriptions_1.listSubscriptions,
29
+ create_subscription_1.createSubscription,
30
+ delete_subscription_1.deleteSubscription,
31
+ create_subscription_2.registerIntegrationTrigger,
32
+ test_connection_1.testConnection,
33
+ ],
34
+ triggers: [pushcut_subscription_event_1.pushcutSubscriptionEvent],
35
+ });
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/pushcut/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAA6D;AAC7D,iDAAqD;AACrD,2EAAuE;AACvE,2EAAuE;AACvE,6DAAyD;AACzD,yEAAqE;AACrE,yEAAqE;AACrE,2EAA+E;AAC/E,uEAAmE;AACnE,mEAA+D;AAC/D,4CAAgD;AAChD,0FAAqF;AAExE,QAAA,OAAO,GAAG,IAAA,8BAAW,EAAC;IACjC,WAAW,EAAE,SAAS;IACtB,WAAW,EACT,2EAA2E;IAC7E,IAAI,EAAE,kBAAW;IACjB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,iDAAiD;IAC1D,OAAO,EAAE,CAAC,cAAc,CAAC;IACzB,UAAU,EAAE,CAAC,sBAAa,CAAC,aAAa,CAAC;IACzC,OAAO,EAAE;QACP,oCAAgB;QAChB,0BAAW;QACX,sCAAiB;QACjB,sCAAiB;QACjB,wCAAkB;QAClB,wCAAkB;QAClB,gDAA0B;QAC1B,gCAAc;KACf;IACD,QAAQ,EAAE,CAAC,qDAAwB,CAAC;CACrC,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ export declare const createSubscription: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ name: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ webhookUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ method: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
5
+ headers: import("@activepieces/pieces-framework").JsonProperty<false>;
6
+ bodyTemplate: import("@activepieces/pieces-framework").JsonProperty<false>;
7
+ }>;
8
+ export declare const registerIntegrationTrigger: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
9
+ name: import("@activepieces/pieces-framework").ShortTextProperty<true>;
10
+ webhookUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
11
+ method: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
12
+ headers: import("@activepieces/pieces-framework").JsonProperty<false>;
13
+ bodyTemplate: import("@activepieces/pieces-framework").JsonProperty<false>;
14
+ }>;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerIntegrationTrigger = exports.createSubscription = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ const auth_1 = require("../common/auth");
8
+ const api_1 = require("../common/api");
9
+ const endpoints_1 = require("../common/endpoints");
10
+ exports.createSubscription = (0, pieces_framework_1.createAction)({
11
+ auth: auth_1.pushcutAuth,
12
+ name: 'create_subscription',
13
+ displayName: 'Create Subscription',
14
+ description: 'Register an Activepieces webhook URL in Pushcut (subscription).',
15
+ props: {
16
+ name: pieces_framework_1.Property.ShortText({
17
+ displayName: 'Name',
18
+ description: 'Friendly name shown inside Pushcut.',
19
+ required: true,
20
+ }),
21
+ webhookUrl: pieces_framework_1.Property.ShortText({
22
+ displayName: 'Webhook URL',
23
+ description: 'Webhook URL Pushcut should call. Defaults to the Activepieces webhook URL when available.',
24
+ required: true,
25
+ }),
26
+ method: pieces_framework_1.Property.StaticDropdown({
27
+ displayName: 'Method',
28
+ required: true,
29
+ defaultValue: 'POST',
30
+ options: {
31
+ options: [
32
+ { label: 'POST', value: 'POST' },
33
+ { label: 'GET', value: 'GET' },
34
+ ],
35
+ },
36
+ }),
37
+ headers: pieces_framework_1.Property.Json({
38
+ displayName: 'Headers',
39
+ required: false,
40
+ }),
41
+ bodyTemplate: pieces_framework_1.Property.Json({
42
+ displayName: 'Body Template',
43
+ description: 'Optional fixed body payload Pushcut should send.',
44
+ required: false,
45
+ }),
46
+ },
47
+ run(context) {
48
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
49
+ const webhookUrl = context.propsValue.webhookUrl;
50
+ const response = yield (0, api_1.pushcutRequest)({
51
+ auth: context.auth,
52
+ method: pieces_common_1.HttpMethod.POST,
53
+ path: endpoints_1.PUSHCUT_ENDPOINTS.subscriptions,
54
+ body: (0, api_1.buildSubscriptionCreateBody)({
55
+ name: context.propsValue.name,
56
+ webhookUrl,
57
+ method: context.propsValue.method,
58
+ headers: context.propsValue.headers,
59
+ bodyTemplate: context.propsValue.bodyTemplate,
60
+ }),
61
+ });
62
+ return response.body;
63
+ });
64
+ },
65
+ });
66
+ exports.registerIntegrationTrigger = (0, pieces_framework_1.createAction)({
67
+ auth: auth_1.pushcutAuth,
68
+ name: 'register_integration_trigger',
69
+ displayName: 'Register Integration Trigger',
70
+ description: 'Deprecated. Use Create Subscription instead. Registers a webhook URL in Pushcut.',
71
+ props: exports.createSubscription.props,
72
+ run(context) {
73
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
74
+ return exports.createSubscription.run(context);
75
+ });
76
+ },
77
+ });
78
+ //# sourceMappingURL=create-subscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-subscription.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/pushcut/src/lib/actions/create-subscription.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAyD;AACzD,yCAA6C;AAC7C,uCAA4E;AAC5E,mDAAwD;AAE3C,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC7C,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,qBAAqB;IAClC,WAAW,EACT,iEAAiE;IACnE,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,qCAAqC;YAClD,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,aAAa;YAC1B,WAAW,EACT,2FAA2F;YAC7F,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,MAAM,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAC9B,WAAW,EAAE,QAAQ;YACrB,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,MAAM;YACpB,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;oBAChC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;iBAC/B;aACF;SACF,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,IAAI,CAAC;YACrB,WAAW,EAAE,SAAS;YACtB,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,YAAY,EAAE,2BAAQ,CAAC,IAAI,CAAC;YAC1B,WAAW,EAAE,eAAe;YAC5B,WAAW,EAAE,kDAAkD;YAC/D,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC;YAEjD,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAc,EAA0B;gBAC7D,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,IAAI,EAAE,6BAAiB,CAAC,aAAa;gBACrC,IAAI,EAAE,IAAA,iCAA2B,EAAC;oBAChC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,IAAI;oBAC7B,UAAU;oBACV,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM;oBACjC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO;oBACnC,YAAY,EAAE,OAAO,CAAC,UAAU,CAAC,YAAY;iBAC9C,CAAC;aACH,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;KAAA;CACF,CAAC,CAAC;AAEU,QAAA,0BAA0B,GAAG,IAAA,+BAAY,EAAC;IACrD,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,8BAA8B;IACpC,WAAW,EAAE,8BAA8B;IAC3C,WAAW,EACT,kFAAkF;IACpF,KAAK,EAAE,0BAAkB,CAAC,KAAK;IACzB,GAAG,CAAC,OAAO;;YACf,OAAO,0BAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const deleteSubscription: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ subscriptionId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ }>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteSubscription = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ const auth_1 = require("../common/auth");
8
+ const api_1 = require("../common/api");
9
+ const endpoints_1 = require("../common/endpoints");
10
+ exports.deleteSubscription = (0, pieces_framework_1.createAction)({
11
+ auth: auth_1.pushcutAuth,
12
+ name: 'delete_subscription',
13
+ displayName: 'Delete Subscription',
14
+ description: 'Delete a Pushcut subscription by id.',
15
+ props: {
16
+ subscriptionId: pieces_framework_1.Property.ShortText({
17
+ displayName: 'Subscription ID',
18
+ required: true,
19
+ }),
20
+ },
21
+ run(context) {
22
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
23
+ const response = yield (0, api_1.pushcutRequest)({
24
+ auth: context.auth,
25
+ method: pieces_common_1.HttpMethod.DELETE,
26
+ path: `${endpoints_1.PUSHCUT_ENDPOINTS.subscriptions}/${context.propsValue.subscriptionId}`,
27
+ });
28
+ return response.body;
29
+ });
30
+ },
31
+ });
32
+ //# sourceMappingURL=delete-subscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-subscription.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/pushcut/src/lib/actions/delete-subscription.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAyD;AACzD,yCAA6C;AAC7C,uCAA+C;AAC/C,mDAAwD;AAE3C,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC7C,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,qBAAqB;IAClC,WAAW,EAAE,sCAAsC;IACnD,KAAK,EAAE;QACL,cAAc,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACjC,WAAW,EAAE,iBAAiB;YAC9B,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAc,EAA0B;gBAC7D,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,MAAM,EAAE,0BAAU,CAAC,MAAM;gBACzB,IAAI,EAAE,GAAG,6BAAiB,CAAC,aAAa,IAAI,OAAO,CAAC,UAAU,CAAC,cAAc,EAAE;aAChF,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const listDevices: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {}>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listDevices = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const auth_1 = require("../common/auth");
7
+ const api_1 = require("../common/api");
8
+ exports.listDevices = (0, pieces_framework_1.createAction)({
9
+ auth: auth_1.pushcutAuth,
10
+ name: 'list_devices',
11
+ displayName: 'List Devices',
12
+ description: 'List Pushcut devices available for notifications.',
13
+ props: {},
14
+ run(context) {
15
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
16
+ var _a;
17
+ const response = yield (0, api_1.fetchPushcutDevices)(context.auth);
18
+ const body = response.body;
19
+ const devices = Array.isArray(body)
20
+ ? body
21
+ : (_a = body === null || body === void 0 ? void 0 : body.devices) !== null && _a !== void 0 ? _a : [];
22
+ return (0, api_1.normalizeOptions)(devices.map((device) => (0, api_1.mapDeviceToOption)(device)));
23
+ });
24
+ },
25
+ });
26
+ //# sourceMappingURL=list-devices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-devices.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/pushcut/src/lib/actions/list-devices.ts"],"names":[],"mappings":";;;;AAAA,qEAA8D;AAC9D,yCAA6C;AAC7C,uCAIuB;AAEV,QAAA,WAAW,GAAG,IAAA,+BAAY,EAAC;IACtC,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,mDAAmD;IAChE,KAAK,EAAE,EAAE;IACH,GAAG,CAAC,OAAO;;;YACf,MAAM,QAAQ,GAAG,MAAM,IAAA,yBAAmB,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAEzD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAe,CAAC;YACtC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;gBACjC,CAAC,CAAC,IAAI;gBACN,CAAC,CAAC,MAAC,IAAgC,aAAhC,IAAI,uBAAJ,IAAI,CAA8B,OAAO,mCAAI,EAAE,CAAC;YAErD,OAAO,IAAA,sBAAgB,EAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAA,uBAAiB,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC9E,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const listNotifications: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {}>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listNotifications = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const auth_1 = require("../common/auth");
7
+ const api_1 = require("../common/api");
8
+ exports.listNotifications = (0, pieces_framework_1.createAction)({
9
+ auth: auth_1.pushcutAuth,
10
+ name: 'list_notifications',
11
+ displayName: 'List Notifications',
12
+ description: 'List Pushcut notifications available to trigger.',
13
+ props: {},
14
+ run(context) {
15
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
16
+ var _a;
17
+ const response = yield (0, api_1.fetchPushcutNotifications)(context.auth);
18
+ if (response.status >= 400) {
19
+ throw new Error(`Pushcut API error (${response.status}): ${JSON.stringify(response.body)}`);
20
+ }
21
+ const body = response.body;
22
+ const notifications = Array.isArray(body)
23
+ ? body
24
+ : (_a = body === null || body === void 0 ? void 0 : body.notifications) !== null && _a !== void 0 ? _a : [];
25
+ return (0, api_1.normalizeOptions)(notifications.map((notification) => (0, api_1.mapNotificationToOption)(notification)));
26
+ });
27
+ },
28
+ });
29
+ //# sourceMappingURL=list-notifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-notifications.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/pushcut/src/lib/actions/list-notifications.ts"],"names":[],"mappings":";;;;AAAA,qEAA8D;AAC9D,yCAA6C;AAC7C,uCAIuB;AAEV,QAAA,iBAAiB,GAAG,IAAA,+BAAY,EAAC;IAC5C,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,oBAAoB;IACjC,WAAW,EAAE,kDAAkD;IAC/D,KAAK,EAAE,EAAE;IACH,GAAG,CAAC,OAAO;;;YACf,MAAM,QAAQ,GAAG,MAAM,IAAA,+BAAyB,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAE/D,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CACb,sBAAsB,QAAQ,CAAC,MAAM,MAAM,IAAI,CAAC,SAAS,CACvD,QAAQ,CAAC,IAAI,CACd,EAAE,CACJ,CAAC;YACJ,CAAC;YAED,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAe,CAAC;YACtC,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;gBACvC,CAAC,CAAC,IAAI;gBACN,CAAC,CAAC,MAAC,IAAsC,aAAtC,IAAI,uBAAJ,IAAI,CAAoC,aAAa,mCAAI,EAAE,CAAC;YAEjE,OAAO,IAAA,sBAAgB,EACrB,aAAa,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CACjC,IAAA,6BAAuB,EAAC,YAAY,CAAC,CACtC,CACF,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const listSubscriptions: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {}>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listSubscriptions = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ const auth_1 = require("../common/auth");
8
+ const api_1 = require("../common/api");
9
+ const endpoints_1 = require("../common/endpoints");
10
+ exports.listSubscriptions = (0, pieces_framework_1.createAction)({
11
+ auth: auth_1.pushcutAuth,
12
+ name: 'list_subscriptions',
13
+ displayName: 'List Subscriptions',
14
+ description: 'List Pushcut subscriptions registered for webhooks.',
15
+ props: {},
16
+ run(context) {
17
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
18
+ const response = yield (0, api_1.pushcutRequest)({
19
+ auth: context.auth,
20
+ method: pieces_common_1.HttpMethod.GET,
21
+ path: endpoints_1.PUSHCUT_ENDPOINTS.subscriptions,
22
+ });
23
+ return response.body;
24
+ });
25
+ },
26
+ });
27
+ //# sourceMappingURL=list-subscriptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-subscriptions.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/pushcut/src/lib/actions/list-subscriptions.ts"],"names":[],"mappings":";;;;AAAA,qEAA8D;AAC9D,+DAAyD;AACzD,yCAA6C;AAC7C,uCAA+C;AAC/C,mDAAwD;AAE3C,QAAA,iBAAiB,GAAG,IAAA,+BAAY,EAAC;IAC5C,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,oBAAoB;IACjC,WAAW,EAAE,qDAAqD;IAClE,KAAK,EAAE,EAAE;IACH,GAAG,CAAC,OAAO;;YACf,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAc,EAAY;gBAC/C,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,IAAI,EAAE,6BAAiB,CAAC,aAAa;aACtC,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare const sendNotification: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ notificationName: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
3
+ title: import("@activepieces/pieces-framework").ShortTextProperty<false>;
4
+ text: import("@activepieces/pieces-framework").LongTextProperty<false>;
5
+ input: import("@activepieces/pieces-framework").JsonProperty<false>;
6
+ devices: import("@activepieces/pieces-framework").MultiSelectDropdownProperty<string, false, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
7
+ delay: import("@activepieces/pieces-framework").ShortTextProperty<false>;
8
+ scheduleTimestamp: import("@activepieces/pieces-framework").NumberProperty<false>;
9
+ }>;
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendNotification = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ const auth_1 = require("../common/auth");
8
+ const api_1 = require("../common/api");
9
+ exports.sendNotification = (0, pieces_framework_1.createAction)({
10
+ auth: auth_1.pushcutAuth,
11
+ name: 'send_notification',
12
+ displayName: 'Send Notification',
13
+ description: 'Send a Pushcut notification to one or more devices.',
14
+ props: {
15
+ notificationName: pieces_framework_1.Property.Dropdown({
16
+ auth: auth_1.pushcutAuth,
17
+ displayName: 'Notification',
18
+ required: true,
19
+ refreshers: [],
20
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, searchValue }) {
21
+ var _b;
22
+ if (!auth) {
23
+ return {
24
+ disabled: true,
25
+ placeholder: 'Connect your Pushcut account first.',
26
+ options: [],
27
+ };
28
+ }
29
+ try {
30
+ const response = yield (0, api_1.fetchPushcutNotifications)(auth);
31
+ if (response.status >= 400) {
32
+ throw new Error(`Pushcut API error (${response.status}): ${JSON.stringify(response.body)}`);
33
+ }
34
+ const body = response.body;
35
+ const notifications = Array.isArray(body)
36
+ ? body
37
+ : (_b = body === null || body === void 0 ? void 0 : body.notifications) !== null && _b !== void 0 ? _b : [];
38
+ const options = (0, api_1.normalizeOptions)(notifications.map((notification) => (0, api_1.mapNotificationToOption)(notification)));
39
+ return (0, api_1.buildDropdownState)((0, api_1.withSearchValue)(options, searchValue), 'Select or type a notification name.');
40
+ }
41
+ catch (_c) {
42
+ return (0, api_1.buildDropdownState)((0, api_1.withSearchValue)([], searchValue), 'Enter a notification name.');
43
+ }
44
+ }),
45
+ }),
46
+ title: pieces_framework_1.Property.ShortText({
47
+ displayName: 'Title',
48
+ required: false,
49
+ }),
50
+ text: pieces_framework_1.Property.LongText({
51
+ displayName: 'Text',
52
+ required: false,
53
+ }),
54
+ input: pieces_framework_1.Property.Json({
55
+ displayName: 'Input',
56
+ required: false,
57
+ }),
58
+ devices: pieces_framework_1.Property.MultiSelectDropdown({
59
+ auth: auth_1.pushcutAuth,
60
+ displayName: 'Devices',
61
+ required: false,
62
+ refreshers: [],
63
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, searchValue }) {
64
+ var _b;
65
+ if (!auth) {
66
+ return {
67
+ disabled: true,
68
+ placeholder: 'Connect your Pushcut account first.',
69
+ options: [],
70
+ };
71
+ }
72
+ try {
73
+ const response = yield (0, api_1.fetchPushcutDevices)(auth);
74
+ if (response.status >= 400) {
75
+ throw new Error(`Pushcut API error (${response.status}): ${JSON.stringify(response.body)}`);
76
+ }
77
+ const body = response.body;
78
+ const devices = Array.isArray(body)
79
+ ? body
80
+ : (_b = body === null || body === void 0 ? void 0 : body.devices) !== null && _b !== void 0 ? _b : [];
81
+ const options = (0, api_1.normalizeOptions)(devices.map((device) => (0, api_1.mapDeviceToOption)(device)));
82
+ return (0, api_1.buildDropdownState)((0, api_1.withSearchValue)(options, searchValue), 'Select devices or type a device name.');
83
+ }
84
+ catch (_c) {
85
+ return (0, api_1.buildDropdownState)((0, api_1.withSearchValue)([], searchValue), 'Enter device names.');
86
+ }
87
+ }),
88
+ }),
89
+ delay: pieces_framework_1.Property.ShortText({
90
+ displayName: 'Delay',
91
+ description: 'Delay before sending, e.g. "10s", "5m", "1h 5m".',
92
+ required: false,
93
+ }),
94
+ scheduleTimestamp: pieces_framework_1.Property.Number({
95
+ displayName: 'Schedule Timestamp',
96
+ required: false,
97
+ description: 'Unix timestamp in milliseconds.',
98
+ }),
99
+ },
100
+ run(context) {
101
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
102
+ var _a;
103
+ const { notificationName, title, text, input, devices, delay, scheduleTimestamp, } = context.propsValue;
104
+ const legacyDelaySeconds = context.propsValue
105
+ .delaySeconds;
106
+ const resolvedDelay = (_a = (delay !== null && delay !== void 0 ? delay : (legacyDelaySeconds !== undefined ? `${legacyDelaySeconds}s` : undefined))) === null || _a === void 0 ? void 0 : _a.trim();
107
+ const body = {};
108
+ if (title)
109
+ body['title'] = title;
110
+ if (text)
111
+ body['text'] = text;
112
+ if (input !== undefined)
113
+ body['input'] = input;
114
+ if (devices && devices.length > 0)
115
+ body['devices'] = devices;
116
+ if (resolvedDelay && resolvedDelay.length > 0)
117
+ body['delay'] = resolvedDelay;
118
+ const scheduleTimestampNumber = Number(scheduleTimestamp);
119
+ if (!Number.isNaN(scheduleTimestampNumber)) {
120
+ body['scheduleTimestamp'] = scheduleTimestampNumber;
121
+ }
122
+ const response = yield pieces_common_1.httpClient.sendRequest({
123
+ method: pieces_common_1.HttpMethod.POST,
124
+ url: `${api_1.BASE_URL}/notifications/${encodeURIComponent(notificationName)}`,
125
+ headers: {
126
+ 'API-Key': (0, auth_1.getApiKey)(context.auth),
127
+ 'Content-Type': 'application/json',
128
+ },
129
+ body,
130
+ });
131
+ if (response.status >= 400) {
132
+ throw new Error(`Pushcut API error (${response.status}): ${JSON.stringify(response.body)}`);
133
+ }
134
+ return response.body;
135
+ });
136
+ },
137
+ });
138
+ //# sourceMappingURL=send-notification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-notification.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/pushcut/src/lib/actions/send-notification.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAqE;AACrE,yCAAwD;AACxD,uCASuB;AAEV,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,qDAAqD;IAClE,KAAK,EAAE;QACL,gBAAgB,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAClC,IAAI,EAAE,kBAAW;YACjB,WAAW,EAAE,cAAc;YAC3B,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,EAAE;YACd,OAAO,EAAE,KAA8B,EAAE,oDAAzB,EAAE,IAAI,EAAE,WAAW,EAAE;;gBACnC,IAAI,CAAC,IAAI,EAAE,CAAC;oBACV,OAAO;wBACL,QAAQ,EAAE,IAAI;wBACd,WAAW,EAAE,qCAAqC;wBAClD,OAAO,EAAE,EAAE;qBACZ,CAAC;gBACJ,CAAC;gBAED,IAAI,CAAC;oBACH,MAAM,QAAQ,GAAG,MAAM,IAAA,+BAAyB,EAAC,IAAI,CAAC,CAAC;oBACvD,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;wBAC3B,MAAM,IAAI,KAAK,CACb,sBAAsB,QAAQ,CAAC,MAAM,MAAM,IAAI,CAAC,SAAS,CACvD,QAAQ,CAAC,I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AM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC5C,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,GAAG,cAAQ,kBAAkB,kBAAkB,CAAC,gBAAgB,CAAC,EAAE;gBACxE,OAAO,EAAE;oBACP,SAAS,EAAE,IAAA,gBAAS,EAAC,OAAO,CAAC,IAAI,CAAC;oBAClC,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI;aACL,CAAC,CAAC;YAEH,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CACb,sBAAsB,QAAQ,CAAC,MAAM,MAAM,IAAI,CAAC,SAAS,CACvD,QAAQ,CAAC,IAAI,CACd,EAAE,CACJ,CAAC;YACJ,CAAC;YAED,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const testConnection: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {}>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.testConnection = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ const auth_1 = require("../common/auth");
8
+ const api_1 = require("../common/api");
9
+ const endpoints_1 = require("../common/endpoints");
10
+ exports.testConnection = (0, pieces_framework_1.createAction)({
11
+ auth: auth_1.pushcutAuth,
12
+ name: 'test_connection',
13
+ displayName: 'Test Connection',
14
+ description: 'Verify the Pushcut API key works.',
15
+ props: {},
16
+ run(context) {
17
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
18
+ var _a;
19
+ const response = yield (0, api_1.pushcutRequest)({
20
+ auth: context.auth,
21
+ method: pieces_common_1.HttpMethod.GET,
22
+ path: endpoints_1.PUSHCUT_ENDPOINTS.devices,
23
+ });
24
+ const body = response.body;
25
+ const devices = Array.isArray(body)
26
+ ? body
27
+ : (_a = body === null || body === void 0 ? void 0 : body.devices) !== null && _a !== void 0 ? _a : [];
28
+ return {
29
+ ok: true,
30
+ deviceCount: devices.length,
31
+ };
32
+ });
33
+ },
34
+ });
35
+ //# sourceMappingURL=test-connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-connection.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/pushcut/src/lib/actions/test-connection.ts"],"names":[],"mappings":";;;;AAAA,qEAA8D;AAC9D,+DAAyD;AACzD,yCAA6C;AAC7C,uCAA+C;AAC/C,mDAAwD;AAE3C,QAAA,cAAc,GAAG,IAAA,+BAAY,EAAC;IACzC,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,mCAAmC;IAChD,KAAK,EAAE,EAAE;IACH,GAAG,CAAC,OAAO;;;YACf,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAc,EAAY;gBAC/C,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,IAAI,EAAE,6BAAiB,CAAC,OAAO;aAChC,CAAC,CAAC;YAEH,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAe,CAAC;YACtC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;gBACjC,CAAC,CAAC,IAAI;gBACN,CAAC,CAAC,MAAC,IAAgC,aAAhC,IAAI,uBAAJ,IAAI,CAA8B,OAAO,mCAAI,EAAE,CAAC;YAErD,OAAO;gBACL,EAAE,EAAE,IAAI;gBACR,WAAW,EAAE,OAAO,CAAC,MAAM;aAC5B,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { HttpMethod } from '@activepieces/pieces-common';
2
+ import { DropdownOption, DropdownState } from '@activepieces/pieces-framework';
3
+ export declare const BASE_URL = "https://api.pushcut.io/v1";
4
+ export declare function mapNotificationToOption(n: any): {
5
+ label: string;
6
+ value: string;
7
+ } | null;
8
+ export declare function mapDeviceToOption(d: any): {
9
+ label: string;
10
+ value: string;
11
+ } | null;
12
+ export declare const normalizeOptions: (options: Array<DropdownOption<string> | null>) => DropdownOption<string>[];
13
+ export declare const withSearchValue: (options: DropdownOption<string>[], searchValue?: string) => DropdownOption<string>[];
14
+ export declare const buildDropdownState: (options: DropdownOption<string>[], placeholder?: string) => DropdownState<string>;
15
+ export declare const fetchPushcutNotifications: (auth: unknown) => Promise<import("@activepieces/pieces-common").HttpResponse<any>>;
16
+ export declare const fetchPushcutDevices: (auth: unknown) => Promise<import("@activepieces/pieces-common").HttpResponse<any>>;
17
+ export declare const pushcutRequest: <T>(params: {
18
+ auth: unknown;
19
+ method: HttpMethod;
20
+ path: string;
21
+ body?: unknown;
22
+ }) => Promise<import("@activepieces/pieces-common").HttpResponse<T>>;
23
+ export declare const buildSubscriptionCreateBody: (args: {
24
+ name: string;
25
+ webhookUrl: string;
26
+ method: string;
27
+ headers?: unknown;
28
+ bodyTemplate?: unknown;
29
+ }) => Record<string, unknown>;
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildSubscriptionCreateBody = exports.pushcutRequest = exports.fetchPushcutDevices = exports.fetchPushcutNotifications = exports.buildDropdownState = exports.withSearchValue = exports.normalizeOptions = exports.BASE_URL = void 0;
4
+ exports.mapNotificationToOption = mapNotificationToOption;
5
+ exports.mapDeviceToOption = mapDeviceToOption;
6
+ const tslib_1 = require("tslib");
7
+ const pieces_common_1 = require("@activepieces/pieces-common");
8
+ const auth_1 = require("./auth");
9
+ const endpoints_1 = require("./endpoints");
10
+ exports.BASE_URL = 'https://api.pushcut.io/v1';
11
+ function mapNotificationToOption(n) {
12
+ var _a, _b, _c;
13
+ const value = (_a = n === null || n === void 0 ? void 0 : n.name) !== null && _a !== void 0 ? _a : n === null || n === void 0 ? void 0 : n.id;
14
+ const label = (_c = (_b = n === null || n === void 0 ? void 0 : n.name) !== null && _b !== void 0 ? _b : n === null || n === void 0 ? void 0 : n.title) !== null && _c !== void 0 ? _c : n === null || n === void 0 ? void 0 : n.id;
15
+ return value ? { label: String(label), value: String(value) } : null;
16
+ }
17
+ function mapDeviceToOption(d) {
18
+ var _a, _b, _c, _d;
19
+ const value = (_a = d === null || d === void 0 ? void 0 : d.identifier) !== null && _a !== void 0 ? _a : d === null || d === void 0 ? void 0 : d.id;
20
+ const label = (_d = (_c = (_b = d === null || d === void 0 ? void 0 : d.name) !== null && _b !== void 0 ? _b : d === null || d === void 0 ? void 0 : d.title) !== null && _c !== void 0 ? _c : d === null || d === void 0 ? void 0 : d.identifier) !== null && _d !== void 0 ? _d : d === null || d === void 0 ? void 0 : d.id;
21
+ return value ? { label: String(label), value: String(value) } : null;
22
+ }
23
+ const normalizeOptions = (options) => {
24
+ const deduped = new Map();
25
+ for (const option of options) {
26
+ if (!option) {
27
+ continue;
28
+ }
29
+ if (!deduped.has(option.value)) {
30
+ deduped.set(option.value, option);
31
+ }
32
+ }
33
+ return Array.from(deduped.values()).sort((a, b) => a.label.localeCompare(b.label));
34
+ };
35
+ exports.normalizeOptions = normalizeOptions;
36
+ const withSearchValue = (options, searchValue) => {
37
+ if (!searchValue || searchValue.trim().length === 0) {
38
+ return options;
39
+ }
40
+ if (options.some((option) => option.value === searchValue)) {
41
+ return options;
42
+ }
43
+ return [{ label: searchValue, value: searchValue }, ...options];
44
+ };
45
+ exports.withSearchValue = withSearchValue;
46
+ const buildDropdownState = (options, placeholder) => {
47
+ return {
48
+ disabled: false,
49
+ placeholder,
50
+ options,
51
+ };
52
+ };
53
+ exports.buildDropdownState = buildDropdownState;
54
+ const fetchPushcutNotifications = (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
55
+ return yield pieces_common_1.httpClient.sendRequest({
56
+ method: pieces_common_1.HttpMethod.GET,
57
+ url: `${exports.BASE_URL}/notifications`,
58
+ headers: {
59
+ 'API-Key': (0, auth_1.getApiKey)(auth),
60
+ 'Content-Type': 'application/json',
61
+ },
62
+ });
63
+ });
64
+ exports.fetchPushcutNotifications = fetchPushcutNotifications;
65
+ const fetchPushcutDevices = (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
66
+ return yield pieces_common_1.httpClient.sendRequest({
67
+ method: pieces_common_1.HttpMethod.GET,
68
+ url: `${exports.BASE_URL}${endpoints_1.PUSHCUT_ENDPOINTS.devices}`,
69
+ headers: {
70
+ 'API-Key': (0, auth_1.getApiKey)(auth),
71
+ 'Content-Type': 'application/json',
72
+ },
73
+ });
74
+ });
75
+ exports.fetchPushcutDevices = fetchPushcutDevices;
76
+ const pushcutRequest = (params) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
77
+ const response = yield pieces_common_1.httpClient.sendRequest({
78
+ method: params.method,
79
+ url: `${exports.BASE_URL}${params.path}`,
80
+ headers: {
81
+ 'API-Key': (0, auth_1.getApiKey)(params.auth),
82
+ 'Content-Type': 'application/json',
83
+ },
84
+ body: params.body,
85
+ });
86
+ if (response.status >= 400) {
87
+ throw new Error(`Pushcut API error (${response.status}): ${JSON.stringify(response.body)}`);
88
+ }
89
+ return response;
90
+ });
91
+ exports.pushcutRequest = pushcutRequest;
92
+ const buildSubscriptionCreateBody = (args) => {
93
+ const body = {
94
+ name: args.name,
95
+ webhookUrl: args.webhookUrl,
96
+ method: args.method,
97
+ };
98
+ if (args.headers !== undefined) {
99
+ body['headers'] = args.headers;
100
+ }
101
+ if (args.bodyTemplate !== undefined) {
102
+ body['bodyTemplate'] = args.bodyTemplate;
103
+ }
104
+ return body;
105
+ };
106
+ exports.buildSubscriptionCreateBody = buildSubscriptionCreateBody;
107
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/pushcut/src/lib/common/api.ts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AQ,CAAC,MAAM,MAAM,IAAI,CAAC,SAAS,CACvD,QAAQ,CAAC,IAAI,CACd,EAAE,CACJ,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAA,CAAC;AAzBW,QAAA,cAAc,kBAyBzB;AAEK,MAAM,2BAA2B,GAAG,CAAC,IAM3C,EAAE,EAAE;IACH,MAAM,IAAI,GAA4B;QACpC,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,MAAM,EAAE,IAAI,CAAC,MAAM;KACpB,CAAC;IAEF,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAC/B,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC;IACjC,CAAC;IAED,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACpC,IAAI,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC;IAC3C,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAtBW,QAAA,2BAA2B,+BAsBtC"}
@@ -0,0 +1,2 @@
1
+ export declare const pushcutAuth: import("@activepieces/pieces-framework").SecretTextProperty<true>;
2
+ export declare const getApiKey: (auth: any) => string;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getApiKey = exports.pushcutAuth = void 0;
4
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
5
+ exports.pushcutAuth = pieces_framework_1.PieceAuth.SecretText({
6
+ displayName: 'Pushcut API Key',
7
+ required: true,
8
+ description: 'Your Pushcut Web API key (Pushcut app → Integrations/Web API).',
9
+ });
10
+ const getApiKey = (auth) => {
11
+ if (typeof auth === 'string')
12
+ return auth;
13
+ if (auth === null || auth === void 0 ? void 0 : auth.apiKey)
14
+ return auth.apiKey;
15
+ if (auth === null || auth === void 0 ? void 0 : auth.secret_text)
16
+ return auth.secret_text;
17
+ throw new Error('Missing Pushcut API key');
18
+ };
19
+ exports.getApiKey = getApiKey;
20
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/pushcut/src/lib/common/auth.ts"],"names":[],"mappings":";;;AAAA,qEAA2D;AAE9C,QAAA,WAAW,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC9C,WAAW,EAAE,iBAAiB;IAC9B,QAAQ,EAAE,IAAI;IACd,WAAW,EACT,gEAAgE;CACnE,CAAC,CAAC;AAEI,MAAM,SAAS,GAAG,CAAC,IAAS,EAAU,EAAE;IAC7C,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC1C,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM;QAAE,OAAO,IAAI,CAAC,MAAM,CAAC;IACrC,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW;QAAE,OAAO,IAAI,CAAC,WAAW,CAAC;IAC/C,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AAC7C,CAAC,CAAC;AALW,QAAA,SAAS,aAKpB"}
@@ -0,0 +1,4 @@
1
+ export declare const PUSHCUT_ENDPOINTS: {
2
+ devices: string;
3
+ subscriptions: string;
4
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PUSHCUT_ENDPOINTS = void 0;
4
+ exports.PUSHCUT_ENDPOINTS = {
5
+ devices: '/devices',
6
+ subscriptions: '/subscriptions',
7
+ };
8
+ //# sourceMappingURL=endpoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoints.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/pushcut/src/lib/common/endpoints.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG;IAC/B,OAAO,EAAE,UAAU;IACnB,aAAa,EAAE,gBAAgB;CAChC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { TriggerStrategy } from '@activepieces/pieces-framework';
2
+ export declare const pushcutSubscriptionEvent: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
3
+ name: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ headers: import("@activepieces/pieces-framework").JsonProperty<false>;
5
+ bodyTemplate: import("@activepieces/pieces-framework").JsonProperty<false>;
6
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
7
+ name: import("@activepieces/pieces-framework").ShortTextProperty<true>;
8
+ headers: import("@activepieces/pieces-framework").JsonProperty<false>;
9
+ bodyTemplate: import("@activepieces/pieces-framework").JsonProperty<false>;
10
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
11
+ name: import("@activepieces/pieces-framework").ShortTextProperty<true>;
12
+ headers: import("@activepieces/pieces-framework").JsonProperty<false>;
13
+ bodyTemplate: import("@activepieces/pieces-framework").JsonProperty<false>;
14
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
15
+ name: import("@activepieces/pieces-framework").ShortTextProperty<true>;
16
+ headers: import("@activepieces/pieces-framework").JsonProperty<false>;
17
+ bodyTemplate: import("@activepieces/pieces-framework").JsonProperty<false>;
18
+ }>;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pushcutSubscriptionEvent = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ const auth_1 = require("../common/auth");
8
+ const api_1 = require("../common/api");
9
+ const endpoints_1 = require("../common/endpoints");
10
+ const STORE_KEY = 'subscriptionId';
11
+ exports.pushcutSubscriptionEvent = (0, pieces_framework_1.createTrigger)({
12
+ auth: auth_1.pushcutAuth,
13
+ name: 'pushcut_subscription_event',
14
+ displayName: 'Pushcut Subscription Event',
15
+ description: 'Receive events from Pushcut subscriptions.',
16
+ props: {
17
+ name: pieces_framework_1.Property.ShortText({
18
+ displayName: 'Name',
19
+ required: true,
20
+ }),
21
+ headers: pieces_framework_1.Property.Json({
22
+ displayName: 'Headers',
23
+ required: false,
24
+ }),
25
+ bodyTemplate: pieces_framework_1.Property.Json({
26
+ displayName: 'Body Template',
27
+ required: false,
28
+ }),
29
+ },
30
+ sampleData: {},
31
+ type: pieces_framework_1.TriggerStrategy.WEBHOOK,
32
+ onEnable(context) {
33
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
34
+ var _a;
35
+ const response = yield (0, api_1.pushcutRequest)({
36
+ auth: context.auth,
37
+ method: pieces_common_1.HttpMethod.POST,
38
+ path: endpoints_1.PUSHCUT_ENDPOINTS.subscriptions,
39
+ body: (0, api_1.buildSubscriptionCreateBody)({
40
+ name: context.propsValue.name,
41
+ webhookUrl: context.webhookUrl,
42
+ method: 'POST',
43
+ headers: context.propsValue.headers,
44
+ bodyTemplate: context.propsValue.bodyTemplate,
45
+ }),
46
+ });
47
+ const responseBody = response.body;
48
+ const subscriptionId = (responseBody === null || responseBody === void 0 ? void 0 : responseBody['id']) ||
49
+ ((_a = responseBody === null || responseBody === void 0 ? void 0 : responseBody['subscription']) === null || _a === void 0 ? void 0 : _a.id);
50
+ if (!subscriptionId) {
51
+ throw new Error('Pushcut API error (missing subscription id).');
52
+ }
53
+ yield context.store.put(STORE_KEY, subscriptionId);
54
+ });
55
+ },
56
+ onDisable(context) {
57
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
58
+ const subscriptionId = yield context.store.get(STORE_KEY);
59
+ if (!subscriptionId) {
60
+ return;
61
+ }
62
+ yield (0, api_1.pushcutRequest)({
63
+ auth: context.auth,
64
+ method: pieces_common_1.HttpMethod.DELETE,
65
+ path: `${endpoints_1.PUSHCUT_ENDPOINTS.subscriptions}/${subscriptionId}`,
66
+ });
67
+ });
68
+ },
69
+ run(context) {
70
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
71
+ return [
72
+ {
73
+ body: context.payload.body,
74
+ headers: context.payload.headers,
75
+ queryParams: context.payload.queryParams,
76
+ },
77
+ ];
78
+ });
79
+ },
80
+ });
81
+ //# sourceMappingURL=pushcut-subscription-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pushcut-subscription-event.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/pushcut/src/lib/triggers/pushcut-subscription-event.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,+DAAyD;AACzD,yCAA6C;AAC7C,uCAA4E;AAC5E,mDAAwD;AAExD,MAAM,SAAS,GAAG,gBAAgB,CAAC;AAEtB,QAAA,wBAAwB,GAAG,IAAA,gCAAa,EAAC;IACpD,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,4BAA4B;IAClC,WAAW,EAAE,4BAA4B;IACzC,WAAW,EAAE,4CAA4C;IACzD,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,MAAM;YACnB,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,IAAI,CAAC;YACrB,WAAW,EAAE,SAAS;YACtB,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,YAAY,EAAE,2BAAQ,CAAC,IAAI,CAAC;YAC1B,WAAW,EAAE,eAAe;YAC5B,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACD,UAAU,EAAE,EAAE;IACd,IAAI,EAAE,kCAAe,CAAC,OAAO;IACvB,QAAQ,CAAC,OAAO;;;YACpB,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAc,EAA0B;gBAC7D,IAAI,EAAE,OAAO,CAAC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