@activepieces/piece-poper 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.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # pieces-poper
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build pieces-poper` to build the library.
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@activepieces/piece-poper",
3
+ "version": "0.0.1",
4
+ "dependencies": {
5
+ "@sinclair/typebox": "0.26.8",
6
+ "axios": "1.6.7",
7
+ "dayjs": "1.11.9",
8
+ "is-base64": "1.1.0",
9
+ "lodash": "4.17.21",
10
+ "nanoid": "3.3.6",
11
+ "semver": "7.6.0",
12
+ "@activepieces/pieces-common": "0.2.12",
13
+ "@activepieces/pieces-framework": "0.7.29",
14
+ "@activepieces/shared": "0.10.104",
15
+ "tslib": "1.14.1"
16
+ },
17
+ "main": "./src/index.js",
18
+ "type": "commonjs"
19
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare const poperAuth: import("@activepieces/pieces-framework").SecretTextProperty<true>;
2
+ export declare const poper: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").SecretTextProperty<true>>;
package/src/index.js ADDED
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.poper = exports.poperAuth = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const new_lead_1 = require("./lib/triggers/new-lead");
7
+ const pieces_common_1 = require("@activepieces/pieces-common");
8
+ const shared_1 = require("@activepieces/shared");
9
+ exports.poperAuth = pieces_framework_1.PieceAuth.SecretText({
10
+ displayName: 'API Key',
11
+ description: 'Use the Poper API key to authenticate the piece. You can find your API key in the Poper settings.',
12
+ required: true,
13
+ validate: ({ auth }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
14
+ const request = {
15
+ method: pieces_common_1.HttpMethod.POST,
16
+ url: 'https://api.poper.ai/general/v1/ping',
17
+ headers: {
18
+ 'Content-Type': 'application/x-www-form-urlencoded',
19
+ },
20
+ body: {
21
+ api_key: auth,
22
+ },
23
+ };
24
+ try {
25
+ const res = yield pieces_common_1.httpClient.sendRequest(request);
26
+ if (res.status === 200) {
27
+ return {
28
+ valid: true,
29
+ };
30
+ }
31
+ return {
32
+ valid: false,
33
+ error: 'API Key is invalid',
34
+ };
35
+ }
36
+ catch (e) {
37
+ return {
38
+ valid: false,
39
+ error: 'API Key is invalid',
40
+ };
41
+ }
42
+ }),
43
+ });
44
+ exports.poper = (0, pieces_framework_1.createPiece)({
45
+ displayName: 'Poper',
46
+ auth: exports.poperAuth,
47
+ minimumSupportedRelease: '0.20.0',
48
+ categories: [shared_1.PieceCategory.MARKETING],
49
+ description: 'AI Driven Pop-up Builder that can convert visitors into customers,increase subscriber count, and skyrocket sales.',
50
+ logoUrl: 'https://cdn.activepieces.com/pieces/poper.png',
51
+ authors: ['thirstycode'],
52
+ actions: [],
53
+ triggers: [new_lead_1.newLead],
54
+ });
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/poper/src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,sDAAkD;AAClD,+DAAkF;AAClF,iDAAqD;AAExC,QAAA,SAAS,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC7C,WAAW,EAAE,SAAS;IACtB,WAAW,EACV,mGAAmG;IACpG,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,CAAO,EAAE,IAAI,EAAE,EAAE,EAAE;QAC5B,MAAM,OAAO,GAAgB;YAC5B,MAAM,EAAE,0BAAU,CAAC,IAAI;YACvB,GAAG,EAAE,sCAAsC;YAC3C,OAAO,EAAE;gBACR,cAAc,EAAE,mCAAmC;aACnD;YACD,IAAI,EAAE;gBACL,OAAO,EAAE,IAAI;aACb;SACD,CAAC;QAEF,IAAI,CAAC;YACJ,MAAM,GAAG,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YAElD,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBACxB,OAAO;oBACN,KAAK,EAAE,IAAI;iBACX,CAAC;YACH,CAAC;YAED,OAAO;gBACN,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,oBAAoB;aAC3B,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,OAAO;gBACN,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,oBAAoB;aAC3B,CAAC;QACH,CAAC;IACF,CAAC,CAAA;CACD,CAAC,CAAC;AAEU,QAAA,KAAK,GAAG,IAAA,8BAAW,EAAC;IAChC,WAAW,EAAE,OAAO;IACpB,IAAI,EAAE,iBAAS;IACf,uBAAuB,EAAE,QAAQ;IACjC,UAAU,EAAE,CAAC,sBAAa,CAAC,SAAS,CAAC;IACrC,WAAW,EACV,mHAAmH;IACpH,OAAO,EAAE,+CAA+C;IACxD,OAAO,EAAE,CAAC,aAAa,CAAC;IACxB,OAAO,EAAE,EAAE;IACX,QAAQ,EAAE,CAAC,kBAAO,CAAC;CACnB,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { TriggerStrategy, DropdownProperty } from '@activepieces/pieces-framework';
2
+ export declare const newLead: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
3
+ popup_id: DropdownProperty<string, false> | DropdownProperty<string, true>;
4
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
5
+ popup_id: DropdownProperty<string, false> | DropdownProperty<string, true>;
6
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
7
+ popup_id: DropdownProperty<string, false> | DropdownProperty<string, true>;
8
+ }>;
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.newLead = 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 __1 = require("./../../");
8
+ const pieces_framework_2 = require("@activepieces/pieces-framework");
9
+ const buildEmptyList = ({ placeholder }) => {
10
+ return {
11
+ disabled: true,
12
+ options: [],
13
+ placeholder,
14
+ };
15
+ };
16
+ const popupsDropdown = pieces_framework_2.Property.Dropdown({
17
+ displayName: 'Popup Name',
18
+ refreshers: [],
19
+ description: "Select the popup name to trigger the action",
20
+ required: true,
21
+ options: ({ auth }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
22
+ if (!auth) {
23
+ return buildEmptyList({
24
+ placeholder: 'Please select an authentication',
25
+ });
26
+ }
27
+ const request = {
28
+ method: pieces_common_1.HttpMethod.POST,
29
+ url: 'https://api.poper.ai/general/v1/popup/list',
30
+ headers: {
31
+ "Content-Type": "application/x-www-form-urlencoded",
32
+ },
33
+ body: {
34
+ api_key: auth,
35
+ }
36
+ };
37
+ try {
38
+ const res = yield pieces_common_1.httpClient.sendRequest(request);
39
+ if (res.status === 200) {
40
+ const popups = res.body.popups;
41
+ if (popups.length === 0) {
42
+ return buildEmptyList({
43
+ placeholder: 'No popups found! Please create a popup.',
44
+ });
45
+ }
46
+ const options = popups.map((p) => ({
47
+ label: p.name,
48
+ value: p.id,
49
+ }));
50
+ return {
51
+ disabled: false,
52
+ options,
53
+ };
54
+ }
55
+ return buildEmptyList({
56
+ placeholder: 'Not authorized.',
57
+ });
58
+ }
59
+ catch (e) {
60
+ return buildEmptyList({
61
+ placeholder: 'Not authorized.',
62
+ });
63
+ }
64
+ }),
65
+ });
66
+ // replace auth with piece auth variable
67
+ const polling = {
68
+ strategy: pieces_common_1.DedupeStrategy.LAST_ITEM,
69
+ items: ({ auth, propsValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
70
+ // implement the logic to fetch the items
71
+ const request = {
72
+ method: pieces_common_1.HttpMethod.POST,
73
+ url: 'https://api.poper.ai/general/v1/popup/responses',
74
+ headers: {
75
+ "Content-Type": "application/x-www-form-urlencoded",
76
+ },
77
+ body: {
78
+ api_key: auth,
79
+ popup_id: propsValue.popup_id,
80
+ }
81
+ };
82
+ try {
83
+ const res = yield pieces_common_1.httpClient.sendRequest(request);
84
+ if (res.status === 200) {
85
+ const responses = res.body.responses;
86
+ if (responses.length === 0) {
87
+ return [];
88
+ }
89
+ return responses.map((response) => ({
90
+ id: response.id,
91
+ data: response,
92
+ }));
93
+ }
94
+ return [];
95
+ }
96
+ catch (e) {
97
+ return [];
98
+ }
99
+ }),
100
+ };
101
+ exports.newLead = (0, pieces_framework_1.createTrigger)({
102
+ auth: __1.poperAuth,
103
+ name: 'newLead',
104
+ displayName: 'New Lead',
105
+ description: 'Triggers when a new lead is obtained from popup',
106
+ props: {
107
+ popup_id: popupsDropdown,
108
+ },
109
+ sampleData: {},
110
+ type: pieces_framework_1.TriggerStrategy.POLLING,
111
+ test(context) {
112
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
113
+ const { store, auth, propsValue } = context;
114
+ return yield pieces_common_1.pollingHelper.test(polling, { store, auth, propsValue });
115
+ });
116
+ },
117
+ onEnable(context) {
118
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
119
+ const { store, auth, propsValue } = context;
120
+ yield pieces_common_1.pollingHelper.onEnable(polling, { store, auth, propsValue });
121
+ });
122
+ },
123
+ onDisable(context) {
124
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
125
+ const { store, auth, propsValue } = context;
126
+ yield pieces_common_1.pollingHelper.onDisable(polling, { store, auth, propsValue });
127
+ });
128
+ },
129
+ run(context) {
130
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
131
+ const { store, auth, propsValue } = context;
132
+ return yield pieces_common_1.pollingHelper.poll(polling, { store, auth, propsValue });
133
+ });
134
+ },
135
+ });
136
+ //# sourceMappingURL=new-lead.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-lead.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/poper/src/lib/triggers/new-lead.ts"],"names":[],"mappings":";;;;AACA,qEAA2I;AAC3I,+DAA0H;AAC1H,gCAAqC;AAErC,qEAA0D;AAE1D,MAAM,cAAc,GAAG,CAAC,EAAE,WAAW,EAA2B,EAAE,EAAE;IAClE,OAAO;QACL,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,EAAE;QACX,WAAW;KACZ,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,2BAAQ,CAAC,QAAQ,CAAS;IAC/C,WAAW,EAAE,YAAY;IACzB,UAAU,EAAE,EAAE;IACd,WAAW,EAAE,6CAA6C;IAC1D,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,CAAO,EAAE,IAAI,EAAE,EAAE,EAAE;QAC1B,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,cAAc,CAAC;gBACpB,WAAW,EAAE,iCAAiC;aAC/C,CAAC,CAAC;QACL,CAAC;QAED,MAAM,OAAO,GAAgB;YACzB,MAAM,EAAE,0BAAU,CAAC,IAAI;YACvB,GAAG,EAAE,4CAA4C;YACjD,OAAO,EAAE;gBACP,cAAc,EAAE,mCAAmC;aACpD;YACD,IAAI,EAAE;gBACJ,OAAO,EAAE,IAAI;aACd;SACF,CAAC;QAEF,IAAG,CAAC;YAEE,MAAM,GAAG,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YAElD,IAAG,GAAG,CAAC,MAAM,KAAK,GAAG,EAAC,CAAC;gBACnB,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;gBAC/B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,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