@activepieces/piece-sendpulse 0.1.5 → 0.1.7

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 (49) hide show
  1. package/package.json +7 -12
  2. package/src/index.js +13 -56
  3. package/src/index.d.ts +0 -5
  4. package/src/index.d.ts.map +0 -1
  5. package/src/index.js.map +0 -1
  6. package/src/lib/actions/add-subscriber.d.ts +0 -13
  7. package/src/lib/actions/add-subscriber.d.ts.map +0 -1
  8. package/src/lib/actions/add-subscriber.js +0 -84
  9. package/src/lib/actions/add-subscriber.js.map +0 -1
  10. package/src/lib/actions/change-variable-for-subscriber.d.ts +0 -16
  11. package/src/lib/actions/change-variable-for-subscriber.d.ts.map +0 -1
  12. package/src/lib/actions/change-variable-for-subscriber.js +0 -146
  13. package/src/lib/actions/change-variable-for-subscriber.js.map +0 -1
  14. package/src/lib/actions/delete-contact.d.ts +0 -7
  15. package/src/lib/actions/delete-contact.d.ts.map +0 -1
  16. package/src/lib/actions/delete-contact.js +0 -51
  17. package/src/lib/actions/delete-contact.js.map +0 -1
  18. package/src/lib/actions/unsubscribe-user.d.ts +0 -11
  19. package/src/lib/actions/unsubscribe-user.d.ts.map +0 -1
  20. package/src/lib/actions/unsubscribe-user.js +0 -66
  21. package/src/lib/actions/unsubscribe-user.js.map +0 -1
  22. package/src/lib/actions/update-subscriber.d.ts +0 -13
  23. package/src/lib/actions/update-subscriber.d.ts.map +0 -1
  24. package/src/lib/actions/update-subscriber.js +0 -102
  25. package/src/lib/actions/update-subscriber.js.map +0 -1
  26. package/src/lib/common/auth.d.ts +0 -5
  27. package/src/lib/common/auth.d.ts.map +0 -1
  28. package/src/lib/common/auth.js +0 -38
  29. package/src/lib/common/auth.js.map +0 -1
  30. package/src/lib/common/client.d.ts +0 -14
  31. package/src/lib/common/client.d.ts.map +0 -1
  32. package/src/lib/common/client.js +0 -63
  33. package/src/lib/common/client.js.map +0 -1
  34. package/src/lib/common/props.d.ts +0 -5
  35. package/src/lib/common/props.d.ts.map +0 -1
  36. package/src/lib/common/props.js +0 -54
  37. package/src/lib/common/props.js.map +0 -1
  38. package/src/lib/triggers/new-subscriber.d.ts +0 -35
  39. package/src/lib/triggers/new-subscriber.d.ts.map +0 -1
  40. package/src/lib/triggers/new-subscriber.js +0 -120
  41. package/src/lib/triggers/new-subscriber.js.map +0 -1
  42. package/src/lib/triggers/new-unsubscriber.d.ts +0 -35
  43. package/src/lib/triggers/new-unsubscriber.d.ts.map +0 -1
  44. package/src/lib/triggers/new-unsubscriber.js +0 -124
  45. package/src/lib/triggers/new-unsubscriber.js.map +0 -1
  46. package/src/lib/triggers/updated-subscriber.d.ts +0 -35
  47. package/src/lib/triggers/updated-subscriber.d.ts.map +0 -1
  48. package/src/lib/triggers/updated-subscriber.js +0 -145
  49. package/src/lib/triggers/updated-subscriber.js.map +0 -1
@@ -1,146 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.changeVariableForSubscriberAction = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_common_1 = require("@activepieces/pieces-common");
6
- const pieces_framework_1 = require("@activepieces/pieces-framework");
7
- const auth_1 = require("../common/auth");
8
- const client_1 = require("../common/client");
9
- const props_1 = require("../common/props");
10
- const variableDropdown = pieces_framework_1.Property.Dropdown({
11
- auth: auth_1.sendpulseAuth,
12
- displayName: 'Variable Name',
13
- description: 'Select variable to update',
14
- required: true,
15
- refreshers: ['mailingListId'],
16
- options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, mailingListId }) {
17
- if (!auth || !mailingListId) {
18
- return {
19
- disabled: true,
20
- options: [],
21
- placeholder: 'Please select a mailing list first',
22
- };
23
- }
24
- try {
25
- const variables = yield (0, client_1.sendpulseApiCall)({
26
- auth: auth,
27
- method: pieces_common_1.HttpMethod.GET,
28
- resourceUri: `/addressbooks/${mailingListId}/variables`,
29
- });
30
- if (!variables.length) {
31
- return {
32
- disabled: true,
33
- options: [],
34
- placeholder: 'No variables found in this mailing list',
35
- };
36
- }
37
- return {
38
- disabled: false,
39
- options: variables
40
- .filter(variable => variable.name !== 'email')
41
- .map((variable) => ({
42
- label: `${variable.name} (${variable.type})`,
43
- value: variable.name,
44
- })),
45
- };
46
- }
47
- catch (error) {
48
- return {
49
- disabled: true,
50
- options: [],
51
- placeholder: `Failed to load variables: ${error.message}`,
52
- };
53
- }
54
- }),
55
- });
56
- exports.changeVariableForSubscriberAction = (0, pieces_framework_1.createAction)({
57
- auth: auth_1.sendpulseAuth,
58
- name: 'change-variable-for-subscriber',
59
- displayName: 'Change Variable for Subscriber',
60
- description: 'Update subscriber variable',
61
- audience: 'both',
62
- aiMetadata: { description: 'Sets a single named variable (custom field) to a given value for one subscriber, identified by email, within a specific SendPulse mailing list. Use to overwrite a single field value; the variable must already exist on the list and its type (number/date) is validated against the value. Idempotent — repeating with the same value leaves the field unchanged.', idempotent: true },
63
- props: {
64
- mailingListId: props_1.mailingListDropdown,
65
- email: pieces_framework_1.Property.ShortText({
66
- displayName: 'Email Address',
67
- description: 'Subscriber email address',
68
- required: true,
69
- }),
70
- variableName: variableDropdown,
71
- variableValue: pieces_framework_1.Property.ShortText({
72
- displayName: 'Variable Value',
73
- description: 'New value for the variable',
74
- required: true,
75
- }),
76
- },
77
- run(context) {
78
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
79
- const { mailingListId, email, variableName, variableValue } = context.propsValue;
80
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
81
- if (!emailRegex.test(email)) {
82
- throw new Error(`Invalid email format: ${email}`);
83
- }
84
- let variableType = null;
85
- try {
86
- const variables = yield (0, client_1.sendpulseApiCall)({
87
- auth: context.auth.props,
88
- method: pieces_common_1.HttpMethod.GET,
89
- resourceUri: `/addressbooks/${mailingListId}/variables`,
90
- });
91
- const variable = variables.find(v => v.name === variableName);
92
- if (variable) {
93
- variableType = variable.type;
94
- }
95
- }
96
- catch (error) {
97
- // Continue without type validation if variable fetch fails
98
- }
99
- if (variableType) {
100
- if (variableType === 'number' && isNaN(Number(variableValue))) {
101
- throw new Error(`Variable "${variableName}" expects a number, but got: ${variableValue}`);
102
- }
103
- if (variableType === 'date') {
104
- const dateRegex = /^\d{4}-\d{2}-\d{2}$/;
105
- if (!dateRegex.test(variableValue) && !Date.parse(variableValue)) {
106
- throw new Error(`Variable "${variableName}" expects a date format (YYYY-MM-DD), but got: ${variableValue}`);
107
- }
108
- }
109
- }
110
- const body = {
111
- email,
112
- variables: [
113
- {
114
- name: variableName,
115
- value: variableValue,
116
- },
117
- ],
118
- };
119
- try {
120
- const result = yield (0, client_1.sendpulseApiCall)({
121
- method: pieces_common_1.HttpMethod.POST,
122
- auth: context.auth.props,
123
- resourceUri: `/addressbooks/${mailingListId}/emails/variable`,
124
- body,
125
- });
126
- if (result.result) {
127
- return {
128
- success: true,
129
- message: `Variable "${variableName}" updated for ${email}`,
130
- email,
131
- variableName,
132
- variableValue,
133
- variableType,
134
- };
135
- }
136
- else {
137
- throw new Error('SendPulse API returned failure');
138
- }
139
- }
140
- catch (error) {
141
- throw new Error(`Failed to update variable: ${error.message || 'Unknown error'}`);
142
- }
143
- });
144
- },
145
- });
146
- //# sourceMappingURL=change-variable-for-subscriber.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"change-variable-for-subscriber.js","sourceRoot":"","sources":["../../../../src/lib/actions/change-variable-for-subscriber.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAAwE;AACxE,yCAA+C;AAC/C,6CAAoD;AACpD,2CAAsD;AAOtD,MAAM,gBAAgB,GAAG,2BAAQ,CAAC,QAAQ,CAAC;IACzC,IAAI,EAAE,oBAAa;IACnB,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,2BAA2B;IACxC,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,CAAC,eAAe,CAAC;IAC7B,OAAO,EAAE,KAAgC,EAAE,oDAA3B,EAAE,IAAI,EAAE,aAAa,EAA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AC,OAAO,KAAU,EAAE,CAAC;gBACpB,MAAM,IAAI,KAAK,CAAC,8BAA8B,KAAK,CAAC,OAAO,IAAI,eAAe,EAAE,CAAC,CAAC;YACpF,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -1,7 +0,0 @@
1
- export declare const deleteContactAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
- clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
3
- clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
4
- }>, {
5
- email: import("@activepieces/pieces-framework").ShortTextProperty<true>;
6
- }>;
7
- //# sourceMappingURL=delete-contact.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"delete-contact.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/delete-contact.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,mBAAmB;;;;;EA2C9B,CAAC"}
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deleteContactAction = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_common_1 = require("@activepieces/pieces-common");
6
- const pieces_framework_1 = require("@activepieces/pieces-framework");
7
- const client_1 = require("../common/client");
8
- const auth_1 = require("../common/auth");
9
- exports.deleteContactAction = (0, pieces_framework_1.createAction)({
10
- auth: auth_1.sendpulseAuth,
11
- name: 'delete-contact',
12
- displayName: 'Delete Contact',
13
- description: 'Permanently delete contact from all mailing lists',
14
- audience: 'both',
15
- aiMetadata: { description: 'Permanently removes a contact, identified by email, from every SendPulse mailing list (address book) in the account at once. Use to fully purge a contact rather than unsubscribe from a single list. Destructive but idempotent — once deleted, repeating the call leaves the contact absent.', idempotent: true },
16
- props: {
17
- email: pieces_framework_1.Property.ShortText({
18
- displayName: 'Email Address',
19
- description: 'Email address to delete from all mailing lists',
20
- required: true,
21
- }),
22
- },
23
- run(context) {
24
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
25
- const { email } = context.propsValue;
26
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
27
- if (!emailRegex.test(email)) {
28
- throw new Error(`Invalid email format: ${email}`);
29
- }
30
- try {
31
- const result = yield (0, client_1.sendpulseApiCall)({
32
- method: pieces_common_1.HttpMethod.DELETE,
33
- auth: context.auth.props,
34
- resourceUri: `/emails/${encodeURIComponent(email)}`,
35
- });
36
- if (result.result) {
37
- return {
38
- success: true,
39
- message: `Contact ${email} deleted from all mailing lists`,
40
- email,
41
- };
42
- }
43
- throw new Error('SendPulse API returned failure');
44
- }
45
- catch (error) {
46
- throw new Error(`Failed to delete contact: ${error.message || 'Unknown error'}`);
47
- }
48
- });
49
- },
50
- });
51
- //# sourceMappingURL=delete-contact.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"delete-contact.js","sourceRoot":"","sources":["../../../../src/lib/actions/delete-contact.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAAwE;AACxE,6CAAoD;AACpD,yCAA+C;AAElC,QAAA,mBAAmB,GAAG,IAAA,+BAAY,EAAC;IAC9C,IAAI,EAAE,oBAAa;IACnB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,gBAAgB;IAC7B,WAAW,EAAE,mDAAmD;IAChE,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,EAAE,WAAW,EAAE,gSAAgS,EAAE,UAAU,EAAE,IAAI,EAAE;IAC/U,KAAK,EAAE;QACL,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,eAAe;YAC5B,WAAW,EAAE,gDAAgD;YAC7D,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IAEK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAErC,MAAM,UAAU,GAAG,4BAA4B,CAAC;YAChD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,yBAAyB,KAAK,EAAE,CAAC,CAAC;YACpD,CAAC;YAED,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,IAAA,yBAAgB,EAAsB;oBACzD,MAAM,EAAE,0BAAU,CAAC,MAAM;oBACzB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK;oBACxB,WAAW,EAAE,WAAW,kBAAkB,CAAC,KAAK,CAAC,EAAE;iBACpD,CAAC,CAAC;gBAEH,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;oBAClB,OAAO;wBACL,OAAO,EAAE,IAAI;wBACb,OAAO,EAAE,WAAW,KAAK,iCAAiC;wBAC1D,KAAK;qBACN,CAAC;gBACJ,CAAC;gBAED,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;YACpD,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,MAAM,IAAI,KAAK,CAAC,6BAA6B,KAAK,CAAC,OAAO,IAAI,eAAe,EAAE,CAAC,CAAC;YACnF,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -1,11 +0,0 @@
1
- export declare const unsubscribeUserAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
- clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
3
- clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
4
- }>, {
5
- mailingListId: import("@activepieces/pieces-framework").DropdownProperty<number, true, import("@activepieces/pieces-framework").CustomAuthProperty<{
6
- clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
7
- clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
8
- }>>;
9
- emails: import("@activepieces/pieces-framework").ArrayProperty<true>;
10
- }>;
11
- //# sourceMappingURL=unsubscribe-user.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unsubscribe-user.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/unsubscribe-user.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,qBAAqB;;;;;;;;;EA2DhC,CAAC"}
@@ -1,66 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unsubscribeUserAction = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_common_1 = require("@activepieces/pieces-common");
6
- const pieces_framework_1 = require("@activepieces/pieces-framework");
7
- const client_1 = require("../common/client");
8
- const auth_1 = require("../common/auth");
9
- const props_1 = require("../common/props");
10
- exports.unsubscribeUserAction = (0, pieces_framework_1.createAction)({
11
- auth: auth_1.sendpulseAuth,
12
- name: 'unsubscribe-user',
13
- displayName: 'Unsubscribe User',
14
- description: 'Remove subscribers from mailing list',
15
- audience: 'both',
16
- aiMetadata: { description: 'Unsubscribes one or more email addresses (up to 100 per call) from a single specified SendPulse mailing list, leaving them in other lists. Use to opt contacts out of one list rather than purge them account-wide. Idempotent — repeating leaves the same contacts unsubscribed from that list.', idempotent: true },
17
- props: {
18
- mailingListId: props_1.mailingListDropdown,
19
- emails: pieces_framework_1.Property.Array({
20
- displayName: 'Email Addresses',
21
- description: 'Email addresses to unsubscribe (max 100)',
22
- required: true,
23
- }),
24
- },
25
- run(context) {
26
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
27
- const { mailingListId, emails } = context.propsValue;
28
- if (emails.length === 0) {
29
- throw new Error('At least one email address is required');
30
- }
31
- if (emails.length > 100) {
32
- throw new Error('Maximum 100 email addresses allowed per request');
33
- }
34
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
35
- const invalidEmails = emails.filter(email => !emailRegex.test(email));
36
- if (invalidEmails.length > 0) {
37
- throw new Error(`Invalid email format(s): ${invalidEmails.join(', ')}`);
38
- }
39
- const body = { emails };
40
- try {
41
- const result = yield (0, client_1.sendpulseApiCall)({
42
- method: pieces_common_1.HttpMethod.DELETE,
43
- auth: context.auth.props,
44
- resourceUri: `/addressbooks/${mailingListId}/emails`,
45
- body,
46
- });
47
- if (result.result) {
48
- return {
49
- success: true,
50
- message: `${emails.length} subscriber(s) unsubscribed successfully`,
51
- unsubscribed: emails,
52
- mailingListId,
53
- count: emails.length,
54
- };
55
- }
56
- else {
57
- throw new Error('Unsubscription failed - API returned failure');
58
- }
59
- }
60
- catch (error) {
61
- throw new Error(`Failed to unsubscribe users: ${error.message || 'Unknown error'}`);
62
- }
63
- });
64
- },
65
- });
66
- //# sourceMappingURL=unsubscribe-user.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unsubscribe-user.js","sourceRoot":"","sources":["../../../../src/lib/actions/unsubscribe-user.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAAwE;AACxE,6CAAoD;AACpD,yCAA+C;AAC/C,2CAAsD;AAEzC,QAAA,qBAAqB,GAAG,IAAA,+BAAY,EAAC;IAChD,IAAI,EAAE,oBAAa;IACnB,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EAAE,sCAAsC;IACnD,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,EAAE,WAAW,EAAE,kSAAkS,EAAE,UAAU,EAAE,IAAI,EAAE;IACjV,KAAK,EAAE;QACL,aAAa,EAAE,2BAAmB;QAClC,MAAM,EAAE,2BAAQ,CAAC,KAAK,CAAC;YACrB,WAAW,EAAE,iBAAiB;YAC9B,WAAW,EAAE,0CAA0C;YACvD,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IAEK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAErD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;YAC5D,CAAC;YAED,IAAI,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;YACrE,CAAC;YAED,MAAM,UAAU,GAAG,4BAA4B,CAAC;YAChD,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,KAAe,CAAC,CAAC,CAAC;YAEhF,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC7B,MAAM,IAAI,KAAK,CAAC,4BAA4B,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC1E,CAAC;YAED,MAAM,IAAI,GAAG,EAAE,MAAM,EAAE,CAAC;YAExB,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,IAAA,yBAAgB,EAAsB;oBACzD,MAAM,EAAE,0BAAU,CAAC,MAAM;oBACzB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK;oBACxB,WAAW,EAAE,iBAAiB,aAAa,SAAS;oBACpD,IAAI;iBACL,CAAC,CAAC;gBAEH,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;oBAClB,OAAO;wBACL,OAAO,EAAE,IAAI;wBACb,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,0CAA0C;wBACnE,YAAY,EAAE,MAAM;wBACpB,aAAa;wBACb,KAAK,EAAE,MAAM,CAAC,MAAM;qBACrB,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;gBAClE,CAAC;YACH,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,MAAM,IAAI,KAAK,CAAC,gCAAgC,KAAK,CAAC,OAAO,IAAI,eAAe,EAAE,CAAC,CAAC;YACtF,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -1,13 +0,0 @@
1
- export declare const updateSubscriberAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
- clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
3
- clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
4
- }>, {
5
- mailingListId: import("@activepieces/pieces-framework").DropdownProperty<number, true, import("@activepieces/pieces-framework").CustomAuthProperty<{
6
- clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
7
- clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
8
- }>>;
9
- email: import("@activepieces/pieces-framework").ShortTextProperty<true>;
10
- phone: import("@activepieces/pieces-framework").ShortTextProperty<false>;
11
- variables: import("@activepieces/pieces-framework").ObjectProperty<false>;
12
- }>;
13
- //# sourceMappingURL=update-subscriber.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update-subscriber.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/update-subscriber.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,sBAAsB;;;;;;;;;;;EAgGjC,CAAC"}
@@ -1,102 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateSubscriberAction = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_common_1 = require("@activepieces/pieces-common");
6
- const pieces_framework_1 = require("@activepieces/pieces-framework");
7
- const client_1 = require("../common/client");
8
- const auth_1 = require("../common/auth");
9
- const props_1 = require("../common/props");
10
- exports.updateSubscriberAction = (0, pieces_framework_1.createAction)({
11
- auth: auth_1.sendpulseAuth,
12
- name: 'update-subscriber',
13
- displayName: 'Update Subscriber',
14
- description: 'Update subscriber details and variables',
15
- audience: 'both',
16
- aiMetadata: { description: "Updates an existing subscriber, identified by email, within a specific SendPulse mailing list by setting their phone number and/or one or more variables (custom fields) to new values. Use to overwrite a contact's details; at least one of phone or variables must be supplied. Idempotent — repeating with the same values leaves the contact unchanged.", idempotent: true },
17
- props: {
18
- mailingListId: props_1.mailingListDropdown,
19
- email: pieces_framework_1.Property.ShortText({
20
- displayName: 'Email Address',
21
- description: 'Email address of the subscriber to update',
22
- required: true,
23
- }),
24
- phone: pieces_framework_1.Property.ShortText({
25
- displayName: 'Phone Number',
26
- description: 'New phone number (optional)',
27
- required: false,
28
- }),
29
- variables: pieces_framework_1.Property.Object({
30
- displayName: 'Variables',
31
- description: 'Subscriber variables to update (e.g., name, custom fields)',
32
- required: false,
33
- }),
34
- },
35
- run(context) {
36
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
37
- const { mailingListId, email, phone, variables } = context.propsValue;
38
- const results = [];
39
- let hasUpdates = false;
40
- if (phone) {
41
- try {
42
- const phoneResult = yield (0, client_1.sendpulseApiCall)({
43
- method: pieces_common_1.HttpMethod.PUT,
44
- auth: context.auth.props,
45
- resourceUri: `/addressbooks/${mailingListId}/phone`,
46
- body: { email, phone },
47
- });
48
- if (phoneResult.result) {
49
- results.push({ type: 'phone', success: true, value: phone });
50
- hasUpdates = true;
51
- }
52
- else {
53
- results.push({ type: 'phone', success: false, error: 'API returned failure' });
54
- }
55
- }
56
- catch (error) {
57
- results.push({ type: 'phone', success: false, error: error.message });
58
- }
59
- }
60
- if (variables && Object.keys(variables).length > 0) {
61
- const variableUpdates = Object.entries(variables).map(([name, value]) => ({
62
- name,
63
- value: String(value),
64
- }));
65
- try {
66
- const variableResult = yield (0, client_1.sendpulseApiCall)({
67
- method: pieces_common_1.HttpMethod.POST,
68
- auth: context.auth.props,
69
- resourceUri: `/addressbooks/${mailingListId}/emails/variable`,
70
- body: { email, variables: variableUpdates },
71
- });
72
- if (variableResult.result) {
73
- results.push({ type: 'variables', success: true, count: variableUpdates.length });
74
- hasUpdates = true;
75
- }
76
- else {
77
- results.push({ type: 'variables', success: false, error: 'API returned failure' });
78
- }
79
- }
80
- catch (error) {
81
- results.push({ type: 'variables', success: false, error: error.message });
82
- }
83
- }
84
- if (!hasUpdates && !phone && (!variables || Object.keys(variables).length === 0)) {
85
- throw new Error('No updates provided. Please specify phone number or variables to update.');
86
- }
87
- const successfulUpdates = results.filter(r => r.success);
88
- const failedUpdates = results.filter(r => !r.success);
89
- if (successfulUpdates.length === 0) {
90
- throw new Error(`All updates failed: ${failedUpdates.map(f => f.error).join(', ')}`);
91
- }
92
- return {
93
- success: true,
94
- message: `Subscriber ${email} updated successfully`,
95
- email,
96
- updates: results,
97
- hasFailures: failedUpdates.length > 0,
98
- };
99
- });
100
- },
101
- });
102
- //# sourceMappingURL=update-subscriber.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update-subscriber.js","sourceRoot":"","sources":["../../../../src/lib/actions/update-subscriber.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAAwE;AACxE,6CAAoD;AACpD,yCAA+C;AAC/C,2CAAsD;AAEzC,QAAA,sBAAsB,GAAG,IAAA,+BAAY,EAAC;IACjD,IAAI,EAAE,oBAAa;IACnB,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,yCAAyC;IACtD,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,EAAE,WAAW,EAAE,8VAA8V,EAAE,UAAU,EAAE,IAAI,EAAE;IAC7Y,KAAK,EAAE;QACL,aAAa,EAAE,2BAAmB;QAClC,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,eAAe;YAC5B,WAAW,EAAE,2CAA2C;YACxD,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,6BAA6B;YAC1C,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACzB,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,4DAA4D;YACzE,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IAEK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAEtE,MAAM,OAAO,GAAU,EAAE,C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AC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YAEtD,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACnC,MAAM,IAAI,KAAK,CAAC,uBAAuB,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACvF,CAAC;YAED,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,cAAc,KAAK,uBAAuB;gBACnD,KAAK;gBACL,OAAO,EAAE,OAAO;gBAChB,WAAW,EAAE,aAAa,CAAC,MAAM,GAAG,CAAC;aACtC,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -1,5 +0,0 @@
1
- export declare const sendpulseAuth: import("@activepieces/pieces-framework").CustomAuthProperty<{
2
- clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
3
- clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
4
- }>;
5
- //# sourceMappingURL=auth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/auth.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa;;;EA4BxB,CAAC"}
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sendpulseAuth = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const client_1 = require("./client");
7
- const pieces_common_1 = require("@activepieces/pieces-common");
8
- exports.sendpulseAuth = pieces_framework_1.PieceAuth.CustomAuth({
9
- description: 'Enter your SendPulse client credentials',
10
- props: {
11
- clientId: pieces_framework_1.PieceAuth.SecretText({
12
- displayName: 'Client ID',
13
- required: true,
14
- }),
15
- clientSecret: pieces_framework_1.PieceAuth.SecretText({
16
- displayName: 'Client Secret',
17
- required: true,
18
- }),
19
- },
20
- validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
21
- try {
22
- yield (0, client_1.sendpulseApiCall)({
23
- method: pieces_common_1.HttpMethod.GET,
24
- resourceUri: '/addressbooks',
25
- auth,
26
- });
27
- return { valid: true };
28
- }
29
- catch (_b) {
30
- return {
31
- valid: false,
32
- error: 'Invalid Client ID or Client Secret',
33
- };
34
- }
35
- }),
36
- required: true,
37
- });
38
- //# sourceMappingURL=auth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../src/lib/common/auth.ts"],"names":[],"mappings":";;;;AAAA,qEAA2D;AAC3D,qCAA4C;AAC5C,+DAAyD;AAE5C,QAAA,aAAa,GAAG,4BAAS,CAAC,UAAU,CAAC;IAChD,WAAW,EAAE,yCAAyC;IACtD,KAAK,EAAE;QACL,QAAQ,EAAE,4BAAS,CAAC,UAAU,CAAC;YAC7B,WAAW,EAAE,WAAW;YACxB,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,YAAY,EAAE,4BAAS,CAAC,UAAU,CAAC;YACjC,WAAW,EAAE,eAAe;YAC5B,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACD,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,IAAI,CAAC;YACH,MAAM,IAAA,yBAAgB,EAAC;gBACrB,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,WAAW,EAAE,eAAe;gBAC5B,IAAI;aACL,CAAC,CAAC;YACH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACzB,CAAC;QAAC,WAAM,CAAC;YACP,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,oCAAoC;aAC5C,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;IACD,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC"}
@@ -1,14 +0,0 @@
1
- import { HttpMethod, HttpMessageBody } from '@activepieces/pieces-common';
2
- export type SendPulseAuthProps = {
3
- clientId: string;
4
- clientSecret: string;
5
- };
6
- export type SendPulseApiCallParams = {
7
- method: HttpMethod;
8
- resourceUri: string;
9
- query?: Record<string, string | number | string[] | undefined>;
10
- body?: any;
11
- auth: SendPulseAuthProps;
12
- };
13
- export declare function sendpulseApiCall<T extends HttpMessageBody>({ method, resourceUri, query, body, auth, }: SendPulseApiCallParams): Promise<T>;
14
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAEV,eAAe,EAEhB,MAAM,6BAA6B,CAAC;AAErC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AA+BF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,UAAU,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;IAC/D,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,IAAI,EAAE,kBAAkB,CAAC;CAC1B,CAAC;AAEF,wBAAsB,gBAAgB,CAAC,CAAC,SAAS,eAAe,EAAE,EAChE,MAAM,EACN,WAAW,EACX,KAAK,EACL,IAAI,EACJ,IAAI,GACL,EAAE,sBAAsB,GAAG,OAAO,CAAC,CAAC,CAAC,CAgCrC"}
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sendpulseApiCall = sendpulseApiCall;
4
- const tslib_1 = require("tslib");
5
- const pieces_common_1 = require("@activepieces/pieces-common");
6
- let cachedToken = null;
7
- let tokenExpiresAt = 0;
8
- function getAccessToken(auth) {
9
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
- if (cachedToken && Date.now() < tokenExpiresAt) {
11
- return cachedToken;
12
- }
13
- const response = yield pieces_common_1.httpClient.sendRequest({
14
- method: pieces_common_1.HttpMethod.POST,
15
- url: 'https://api.sendpulse.com/oauth/access_token',
16
- headers: {
17
- 'Content-Type': 'application/json',
18
- },
19
- body: {
20
- grant_type: 'client_credentials',
21
- client_id: auth.clientId,
22
- client_secret: auth.clientSecret,
23
- },
24
- });
25
- cachedToken = response.body.access_token;
26
- tokenExpiresAt = Date.now() + response.body.expires_in * 1000 - 30 * 1000;
27
- return cachedToken;
28
- });
29
- }
30
- function sendpulseApiCall(_a) {
31
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ method, resourceUri, query, body, auth, }) {
32
- var _b, _c, _d;
33
- const token = yield getAccessToken(auth);
34
- const queryParams = {};
35
- if (query) {
36
- for (const [key, value] of Object.entries(query)) {
37
- if (value !== null && value !== undefined) {
38
- queryParams[key] = String(value);
39
- }
40
- }
41
- }
42
- const request = {
43
- method,
44
- url: `https://api.sendpulse.com${resourceUri}`,
45
- headers: {
46
- Authorization: `Bearer ${token}`,
47
- 'Content-Type': 'application/json',
48
- },
49
- queryParams,
50
- body,
51
- };
52
- try {
53
- const response = yield pieces_common_1.httpClient.sendRequest(request);
54
- return response.body;
55
- }
56
- catch (error) {
57
- const statusCode = (_b = error.response) === null || _b === void 0 ? void 0 : _b.status;
58
- const errorMessage = ((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.message) || error.message || 'Unknown error';
59
- throw new Error(`SendPulse API Error (${statusCode || 'Unknown'}): ${errorMessage}`);
60
- }
61
- });
62
- }
63
- //# sourceMappingURL=client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/lib/common/client.ts"],"names":[],"mappings":";;AAkDA,4CAsCC;;AAxFD,+DAMqC;AAOrC,IAAI,WAAW,GAAkB,IAAI,CAAC;AACtC,I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AAM;YACN,GAAG,EAAE,4BAA4B,WAAW,EAAE;YAC9C,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,KAAK,EAAE;gBAChC,cAAc,EAAE,kBAAkB;aACnC;YACD,WAAW;YACX,IAAI;SACL,CAAC;QAEF,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAI,OAAO,CAAC,CAAC;YAC1D,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,UAAU,GAAG,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,CAAC;YAC1C,MAAM,YAAY,GAAG,CAAA,MAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAI,0CAAE,OAAO,KAAI,KAAK,CAAC,OAAO,IAAI,eAAe,CAAC;YAEvF,MAAM,IAAI,KAAK,CAAC,wBAAwB,UAAU,IAAI,SAAS,MAAM,YAAY,EAAE,CAAC,CAAC;QACvF,CAAC;IACH,CAAC;CAAA"}
@@ -1,5 +0,0 @@
1
- export declare const mailingListDropdown: import("@activepieces/pieces-framework").DropdownProperty<number, true, import("@activepieces/pieces-framework").CustomAuthProperty<{
2
- clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
3
- clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
4
- }>>;
5
- //# sourceMappingURL=props.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/props.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,mBAAmB;;;GA8C9B,CAAC"}