@activepieces/piece-sendpulse 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 +7 -0
- package/package.json +38 -0
- package/src/index.d.ts +4 -0
- package/src/index.js +56 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/add-subscriber.d.ts +9 -0
- package/src/lib/actions/add-subscriber.js +82 -0
- package/src/lib/actions/add-subscriber.js.map +1 -0
- package/src/lib/actions/change-variable-for-subscriber.d.ts +9 -0
- package/src/lib/actions/change-variable-for-subscriber.js +143 -0
- package/src/lib/actions/change-variable-for-subscriber.js.map +1 -0
- package/src/lib/actions/delete-contact.d.ts +6 -0
- package/src/lib/actions/delete-contact.js +49 -0
- package/src/lib/actions/delete-contact.js.map +1 -0
- package/src/lib/actions/unsubscribe-user.d.ts +7 -0
- package/src/lib/actions/unsubscribe-user.js +64 -0
- package/src/lib/actions/unsubscribe-user.js.map +1 -0
- package/src/lib/actions/update-subscriber.d.ts +9 -0
- package/src/lib/actions/update-subscriber.js +100 -0
- package/src/lib/actions/update-subscriber.js.map +1 -0
- package/src/lib/common/auth.d.ts +4 -0
- package/src/lib/common/auth.js +38 -0
- package/src/lib/common/auth.js.map +1 -0
- package/src/lib/common/client.d.ts +13 -0
- package/src/lib/common/client.js +63 -0
- package/src/lib/common/client.js.map +1 -0
- package/src/lib/common/props.d.ts +1 -0
- package/src/lib/common/props.js +52 -0
- package/src/lib/common/props.js.map +1 -0
- package/src/lib/triggers/new-subscriber.d.ts +17 -0
- package/src/lib/triggers/new-subscriber.js +117 -0
- package/src/lib/triggers/new-subscriber.js.map +1 -0
- package/src/lib/triggers/new-unsubscriber.d.ts +17 -0
- package/src/lib/triggers/new-unsubscriber.js +121 -0
- package/src/lib/triggers/new-unsubscriber.js.map +1 -0
- package/src/lib/triggers/updated-subscriber.d.ts +17 -0
- package/src/lib/triggers/updated-subscriber.js +142 -0
- package/src/lib/triggers/updated-subscriber.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@activepieces/piece-sendpulse",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"main": "./src/index.js",
|
|
6
|
+
"types": "./src/index.d.ts",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@ai-sdk/anthropic": "1.2.12",
|
|
9
|
+
"@ai-sdk/google": "1.2.19",
|
|
10
|
+
"@ai-sdk/openai": "1.3.22",
|
|
11
|
+
"@ai-sdk/replicate": "0.2.8",
|
|
12
|
+
"@sinclair/typebox": "0.34.11",
|
|
13
|
+
"ai": "4.3.16",
|
|
14
|
+
"axios": "1.8.3",
|
|
15
|
+
"axios-retry": "4.4.1",
|
|
16
|
+
"deepmerge-ts": "7.1.0",
|
|
17
|
+
"fast-glob": "3.3.3",
|
|
18
|
+
"mime-types": "2.1.35",
|
|
19
|
+
"nanoid": "3.3.8",
|
|
20
|
+
"semver": "7.6.0",
|
|
21
|
+
"tslib": "^2.3.0",
|
|
22
|
+
"zod": "3.25.76",
|
|
23
|
+
"@activepieces/pieces-common": "0.6.0",
|
|
24
|
+
"@activepieces/pieces-framework": "0.15.0",
|
|
25
|
+
"@activepieces/shared": "0.17.2"
|
|
26
|
+
},
|
|
27
|
+
"overrides": {
|
|
28
|
+
"@tryfabric/martian": {
|
|
29
|
+
"@notionhq/client": "$@notionhq/client"
|
|
30
|
+
},
|
|
31
|
+
"vite": {
|
|
32
|
+
"rollup": "npm:@rollup/wasm-node"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"resolutions": {
|
|
36
|
+
"rollup": "npm:@rollup/wasm-node"
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const sendpulse: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
4
|
+
}>>;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendpulse = 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("./lib/common/auth");
|
|
8
|
+
const client_1 = require("./lib/common/client");
|
|
9
|
+
const new_subscriber_1 = require("./lib/triggers/new-subscriber");
|
|
10
|
+
const new_unsubscriber_1 = require("./lib/triggers/new-unsubscriber");
|
|
11
|
+
const updated_subscriber_1 = require("./lib/triggers/updated-subscriber");
|
|
12
|
+
const add_subscriber_1 = require("./lib/actions/add-subscriber");
|
|
13
|
+
const change_variable_for_subscriber_1 = require("./lib/actions/change-variable-for-subscriber");
|
|
14
|
+
const delete_contact_1 = require("./lib/actions/delete-contact");
|
|
15
|
+
const unsubscribe_user_1 = require("./lib/actions/unsubscribe-user");
|
|
16
|
+
const update_subscriber_1 = require("./lib/actions/update-subscriber");
|
|
17
|
+
exports.sendpulse = (0, pieces_framework_1.createPiece)({
|
|
18
|
+
displayName: 'SendPulse',
|
|
19
|
+
auth: auth_1.sendpulseAuth,
|
|
20
|
+
minimumSupportedRelease: '0.36.1',
|
|
21
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/sendpulse.png',
|
|
22
|
+
authors: ['aryel780', 'onyedikachi-david'],
|
|
23
|
+
actions: [
|
|
24
|
+
add_subscriber_1.addSubscriberAction,
|
|
25
|
+
change_variable_for_subscriber_1.changeVariableForSubscriberAction,
|
|
26
|
+
delete_contact_1.deleteContactAction,
|
|
27
|
+
unsubscribe_user_1.unsubscribeUserAction,
|
|
28
|
+
update_subscriber_1.updateSubscriberAction,
|
|
29
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
30
|
+
auth: auth_1.sendpulseAuth,
|
|
31
|
+
baseUrl: () => 'https://api.sendpulse.com',
|
|
32
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
const typedAuth = auth;
|
|
34
|
+
const token = yield (0, client_1.sendpulseApiCall)({
|
|
35
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
36
|
+
auth: typedAuth,
|
|
37
|
+
resourceUri: '/oauth/access_token',
|
|
38
|
+
body: {
|
|
39
|
+
grant_type: 'client_credentials',
|
|
40
|
+
client_id: typedAuth.clientId,
|
|
41
|
+
client_secret: typedAuth.clientSecret,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
Authorization: `Bearer ${token.access_token}`,
|
|
46
|
+
};
|
|
47
|
+
}),
|
|
48
|
+
}),
|
|
49
|
+
],
|
|
50
|
+
triggers: [
|
|
51
|
+
new_subscriber_1.newSubscriberTrigger,
|
|
52
|
+
new_unsubscriber_1.newUnsubscriberTrigger,
|
|
53
|
+
updated_subscriber_1.updatedSubscriberTrigger
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/sendpulse/src/index.ts"],"names":[],"mappings":";;;;AAAA,+DAGqC;AACrC,qEAA6D;AAC7D,4CAAkD;AAClD,gDAAuD;AACvD,kEAAqE;AACrE,sEAAyE;AACzE,0EAA6E;AAC7E,iEAAmE;AACnE,iGAAiG;AACjG,iEAAmE;AACnE,qEAAuE;AACvE,uEAAyE;AAE5D,QAAA,SAAS,GAAG,IAAA,8BAAW,EAAC;IACnC,WAAW,EAAE,WAAW;IACxB,IAAI,EAAE,oBAAa;IACnB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,mDAAmD;IAC5D,OAAO,EAAE,CAAC,UAAU,EAAE,mBAAmB,CAAC;IAC1C,OAAO,EAAE;QACP,oCAAmB;QACnB,kEAAiC;QACjC,oCAAmB;QACnB,wCAAqB;QACrB,0CAAsB;QACtB,IAAA,yCAAyB,EAAC;YACxB,IAAI,EAAE,oBAAa;YACnB,OAAO,EAAE,GAAG,EAAE,CAAC,2BAA2B;YAC1C,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAC1B,MAAM,SAAS,GAAG,IAAkD,CAAC;gBACrE,MAAM,KAAK,GAAG,MAAM,IAAA,yBAAgB,EAA2B;oBAC7D,MAAM,EAAE,0BAAU,CAAC,IAAI;oBACvB,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,qBAAqB;oBAClC,IAAI,EAAE;wBACJ,UAAU,EAAE,oBAAoB;wBAChC,SAAS,EAAE,SAAS,CAAC,QAAQ;wBAC7B,aAAa,EAAE,SAAS,CAAC,YAAY;qBACtC;iBACF,CAAC,CAAC;gBAEH,OAAO;oBACL,aAAa,EAAE,UAAU,KAAK,CAAC,YAAY,EAAE;iBAC9C,CAAC;YACJ,CAAC,CAAA;SACF,CAAC;KACH;IACD,QAAQ,EAAE;QACR,qCAAoB;QACpB,yCAAsB;QACtB,6CAAwB;KACzB;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const addSubscriberAction: 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>;
|
|
6
|
+
email: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
7
|
+
variables: import("@activepieces/pieces-framework").ObjectProperty<false>;
|
|
8
|
+
tags: import("@activepieces/pieces-framework").ArrayProperty<false>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addSubscriberAction = 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.addSubscriberAction = (0, pieces_framework_1.createAction)({
|
|
11
|
+
auth: auth_1.sendpulseAuth,
|
|
12
|
+
name: 'add-subscriber',
|
|
13
|
+
displayName: 'Add Subscriber',
|
|
14
|
+
description: 'Add subscriber to mailing list',
|
|
15
|
+
props: {
|
|
16
|
+
mailingListId: props_1.mailingListDropdown,
|
|
17
|
+
email: pieces_framework_1.Property.ShortText({
|
|
18
|
+
displayName: 'Email Address',
|
|
19
|
+
description: 'Subscriber email address',
|
|
20
|
+
required: true,
|
|
21
|
+
}),
|
|
22
|
+
variables: pieces_framework_1.Property.Object({
|
|
23
|
+
displayName: 'Variables',
|
|
24
|
+
description: 'Optional subscriber variables (e.g., name, phone)',
|
|
25
|
+
required: false,
|
|
26
|
+
}),
|
|
27
|
+
tags: pieces_framework_1.Property.Array({
|
|
28
|
+
displayName: 'Tag IDs',
|
|
29
|
+
description: 'Optional tag IDs to assign',
|
|
30
|
+
required: false,
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
run(context) {
|
|
34
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const { mailingListId, email, variables, tags } = context.propsValue;
|
|
36
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
37
|
+
if (!emailRegex.test(email)) {
|
|
38
|
+
throw new Error(`Invalid email format: ${email}`);
|
|
39
|
+
}
|
|
40
|
+
const emailObject = { email };
|
|
41
|
+
if (variables && Object.keys(variables).length > 0) {
|
|
42
|
+
emailObject.variables = variables;
|
|
43
|
+
}
|
|
44
|
+
const requestBody = {
|
|
45
|
+
emails: [emailObject],
|
|
46
|
+
};
|
|
47
|
+
if (tags && tags.length > 0) {
|
|
48
|
+
const tagNumbers = tags.map((tag) => {
|
|
49
|
+
const num = Number(tag);
|
|
50
|
+
if (isNaN(num)) {
|
|
51
|
+
throw new Error(`Invalid tag ID: ${tag}. Tag IDs must be numbers.`);
|
|
52
|
+
}
|
|
53
|
+
return num;
|
|
54
|
+
});
|
|
55
|
+
requestBody.tags = tagNumbers;
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const result = yield (0, client_1.sendpulseApiCall)({
|
|
59
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
60
|
+
auth: context.auth,
|
|
61
|
+
resourceUri: `/addressbooks/${mailingListId}/emails`,
|
|
62
|
+
body: requestBody,
|
|
63
|
+
});
|
|
64
|
+
if (result.result === true) {
|
|
65
|
+
return {
|
|
66
|
+
success: true,
|
|
67
|
+
message: 'Subscriber added successfully',
|
|
68
|
+
email,
|
|
69
|
+
variables: variables || {},
|
|
70
|
+
mailingListId,
|
|
71
|
+
tags: requestBody.tags || [],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
throw new Error('SendPulse API returned failure');
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
throw new Error(`Failed to add subscriber: ${error.message || 'Unknown error'}`);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
//# sourceMappingURL=add-subscriber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-subscriber.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/sendpulse/src/lib/actions/add-subscriber.ts"],"names":[],"mappings":";;;;AAAA,+DAA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@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>;
|
|
6
|
+
email: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
7
|
+
variableName: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
8
|
+
variableValue: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,143 @@
|
|
|
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
|
+
displayName: 'Variable Name',
|
|
12
|
+
description: 'Select variable to update',
|
|
13
|
+
required: true,
|
|
14
|
+
refreshers: ['mailingListId'],
|
|
15
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, mailingListId }) {
|
|
16
|
+
if (!auth || !mailingListId) {
|
|
17
|
+
return {
|
|
18
|
+
disabled: true,
|
|
19
|
+
options: [],
|
|
20
|
+
placeholder: 'Please select a mailing list first',
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const variables = yield (0, client_1.sendpulseApiCall)({
|
|
25
|
+
auth: auth,
|
|
26
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
27
|
+
resourceUri: `/addressbooks/${mailingListId}/variables`,
|
|
28
|
+
});
|
|
29
|
+
if (!variables.length) {
|
|
30
|
+
return {
|
|
31
|
+
disabled: true,
|
|
32
|
+
options: [],
|
|
33
|
+
placeholder: 'No variables found in this mailing list',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
disabled: false,
|
|
38
|
+
options: variables
|
|
39
|
+
.filter(variable => variable.name !== 'email')
|
|
40
|
+
.map((variable) => ({
|
|
41
|
+
label: `${variable.name} (${variable.type})`,
|
|
42
|
+
value: variable.name,
|
|
43
|
+
})),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
return {
|
|
48
|
+
disabled: true,
|
|
49
|
+
options: [],
|
|
50
|
+
placeholder: `Failed to load variables: ${error.message}`,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}),
|
|
54
|
+
});
|
|
55
|
+
exports.changeVariableForSubscriberAction = (0, pieces_framework_1.createAction)({
|
|
56
|
+
auth: auth_1.sendpulseAuth,
|
|
57
|
+
name: 'change-variable-for-subscriber',
|
|
58
|
+
displayName: 'Change Variable for Subscriber',
|
|
59
|
+
description: 'Update subscriber variable',
|
|
60
|
+
props: {
|
|
61
|
+
mailingListId: props_1.mailingListDropdown,
|
|
62
|
+
email: pieces_framework_1.Property.ShortText({
|
|
63
|
+
displayName: 'Email Address',
|
|
64
|
+
description: 'Subscriber email address',
|
|
65
|
+
required: true,
|
|
66
|
+
}),
|
|
67
|
+
variableName: variableDropdown,
|
|
68
|
+
variableValue: pieces_framework_1.Property.ShortText({
|
|
69
|
+
displayName: 'Variable Value',
|
|
70
|
+
description: 'New value for the variable',
|
|
71
|
+
required: true,
|
|
72
|
+
}),
|
|
73
|
+
},
|
|
74
|
+
run(context) {
|
|
75
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
const { mailingListId, email, variableName, variableValue } = context.propsValue;
|
|
77
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
78
|
+
if (!emailRegex.test(email)) {
|
|
79
|
+
throw new Error(`Invalid email format: ${email}`);
|
|
80
|
+
}
|
|
81
|
+
let variableType = null;
|
|
82
|
+
try {
|
|
83
|
+
const variables = yield (0, client_1.sendpulseApiCall)({
|
|
84
|
+
auth: context.auth,
|
|
85
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
86
|
+
resourceUri: `/addressbooks/${mailingListId}/variables`,
|
|
87
|
+
});
|
|
88
|
+
const variable = variables.find(v => v.name === variableName);
|
|
89
|
+
if (variable) {
|
|
90
|
+
variableType = variable.type;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
// Continue without type validation if variable fetch fails
|
|
95
|
+
}
|
|
96
|
+
if (variableType) {
|
|
97
|
+
if (variableType === 'number' && isNaN(Number(variableValue))) {
|
|
98
|
+
throw new Error(`Variable "${variableName}" expects a number, but got: ${variableValue}`);
|
|
99
|
+
}
|
|
100
|
+
if (variableType === 'date') {
|
|
101
|
+
const dateRegex = /^\d{4}-\d{2}-\d{2}$/;
|
|
102
|
+
if (!dateRegex.test(variableValue) && !Date.parse(variableValue)) {
|
|
103
|
+
throw new Error(`Variable "${variableName}" expects a date format (YYYY-MM-DD), but got: ${variableValue}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const body = {
|
|
108
|
+
email,
|
|
109
|
+
variables: [
|
|
110
|
+
{
|
|
111
|
+
name: variableName,
|
|
112
|
+
value: variableValue,
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
try {
|
|
117
|
+
const result = yield (0, client_1.sendpulseApiCall)({
|
|
118
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
119
|
+
auth: context.auth,
|
|
120
|
+
resourceUri: `/addressbooks/${mailingListId}/emails/variable`,
|
|
121
|
+
body,
|
|
122
|
+
});
|
|
123
|
+
if (result.result) {
|
|
124
|
+
return {
|
|
125
|
+
success: true,
|
|
126
|
+
message: `Variable "${variableName}" updated for ${email}`,
|
|
127
|
+
email,
|
|
128
|
+
variableName,
|
|
129
|
+
variableValue,
|
|
130
|
+
variableType,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
throw new Error('SendPulse API returned failure');
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
throw new Error(`Failed to update variable: ${error.message || 'Unknown error'}`);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
//# sourceMappingURL=change-variable-for-subscriber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"change-variable-for-subscriber.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/sendpulse/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,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,EAAE;QACrC,IAAI,CAAC,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YAC5B,OAAO;gBACL,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,oCAAoC;aAClD,CAAC;QACJ,CAAC;QAED,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,IAAA,yBAAgB,EAAsB;gBAC5D,IAAI,EAAE,IAAW;gBACjB,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,WAAW,EAAE,iBAAiB,aAAa,YAAY;aACxD,CAAC,CAAC;YAEH,IAAI,C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,aAAa,YAAY,kDAAkD,aAAa,EAAE,CAAC,CAAC;oBAC9G,CAAC;gBACH,CAAC;YACH,CAAC;YAED,MAAM,IAAI,GAAG;gBACX,KAAK;gBACL,SAAS,EAAE;oBACT;wBACE,IAAI,EAAE,YAAY;wBAClB,KAAK,EAAE,aAAa;qBACrB;iBACF;aACF,CAAC;YAEF,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,IAAA,yBAAgB,EAAsB;oBACzD,MAAM,EAAE,0BAAU,CAAC,IAAI;oBACvB,IAAI,EAAE,OAAO,CAAC,IAAI;oBAClB,WAAW,EAAE,iBAAiB,aAAa,kBAAkB;oBAC7D,IAAI;iBACL,CAAC,CAAC;gBAEH,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;oBAClB,OAAO;wBACL,OAAO,EAAE,IAAI;wBACb,OAAO,EAAE,aAAa,YAAY,iBAAiB,KAAK,EAAE;wBAC1D,KAAK;wBACL,YAAY;wBACZ,aAAa;wBACb,YAAY;qBACb,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;gBACpD,CAAC;YACH,CAAC;YAAC,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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
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
|
+
}>;
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
props: {
|
|
15
|
+
email: pieces_framework_1.Property.ShortText({
|
|
16
|
+
displayName: 'Email Address',
|
|
17
|
+
description: 'Email address to delete from all mailing lists',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
},
|
|
21
|
+
run(context) {
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const { email } = context.propsValue;
|
|
24
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
25
|
+
if (!emailRegex.test(email)) {
|
|
26
|
+
throw new Error(`Invalid email format: ${email}`);
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const result = yield (0, client_1.sendpulseApiCall)({
|
|
30
|
+
method: pieces_common_1.HttpMethod.DELETE,
|
|
31
|
+
auth: context.auth,
|
|
32
|
+
resourceUri: `/emails/${encodeURIComponent(email)}`,
|
|
33
|
+
});
|
|
34
|
+
if (result.result) {
|
|
35
|
+
return {
|
|
36
|
+
success: true,
|
|
37
|
+
message: `Contact ${email} deleted from all mailing lists`,
|
|
38
|
+
email,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
throw new Error('SendPulse API returned failure');
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
throw new Error(`Failed to delete contact: ${error.message || 'Unknown error'}`);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=delete-contact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-contact.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/sendpulse/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,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;oBAClB,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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
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>;
|
|
6
|
+
emails: import("@activepieces/pieces-framework").ArrayProperty<true>;
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
props: {
|
|
16
|
+
mailingListId: props_1.mailingListDropdown,
|
|
17
|
+
emails: pieces_framework_1.Property.Array({
|
|
18
|
+
displayName: 'Email Addresses',
|
|
19
|
+
description: 'Email addresses to unsubscribe (max 100)',
|
|
20
|
+
required: true,
|
|
21
|
+
}),
|
|
22
|
+
},
|
|
23
|
+
run(context) {
|
|
24
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const { mailingListId, emails } = context.propsValue;
|
|
26
|
+
if (emails.length === 0) {
|
|
27
|
+
throw new Error('At least one email address is required');
|
|
28
|
+
}
|
|
29
|
+
if (emails.length > 100) {
|
|
30
|
+
throw new Error('Maximum 100 email addresses allowed per request');
|
|
31
|
+
}
|
|
32
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
33
|
+
const invalidEmails = emails.filter(email => !emailRegex.test(email));
|
|
34
|
+
if (invalidEmails.length > 0) {
|
|
35
|
+
throw new Error(`Invalid email format(s): ${invalidEmails.join(', ')}`);
|
|
36
|
+
}
|
|
37
|
+
const body = { emails };
|
|
38
|
+
try {
|
|
39
|
+
const result = yield (0, client_1.sendpulseApiCall)({
|
|
40
|
+
method: pieces_common_1.HttpMethod.DELETE,
|
|
41
|
+
auth: context.auth,
|
|
42
|
+
resourceUri: `/addressbooks/${mailingListId}/emails`,
|
|
43
|
+
body,
|
|
44
|
+
});
|
|
45
|
+
if (result.result) {
|
|
46
|
+
return {
|
|
47
|
+
success: true,
|
|
48
|
+
message: `${emails.length} subscriber(s) unsubscribed successfully`,
|
|
49
|
+
unsubscribed: emails,
|
|
50
|
+
mailingListId,
|
|
51
|
+
count: emails.length,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
throw new Error('Unsubscription failed - API returned failure');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
throw new Error(`Failed to unsubscribe users: ${error.message || 'Unknown error'}`);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=unsubscribe-user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unsubscribe-user.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/sendpulse/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,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;oBAClB,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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
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>;
|
|
6
|
+
email: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
7
|
+
phone: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
variables: import("@activepieces/pieces-framework").ObjectProperty<false>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
props: {
|
|
16
|
+
mailingListId: props_1.mailingListDropdown,
|
|
17
|
+
email: pieces_framework_1.Property.ShortText({
|
|
18
|
+
displayName: 'Email Address',
|
|
19
|
+
description: 'Email address of the subscriber to update',
|
|
20
|
+
required: true,
|
|
21
|
+
}),
|
|
22
|
+
phone: pieces_framework_1.Property.ShortText({
|
|
23
|
+
displayName: 'Phone Number',
|
|
24
|
+
description: 'New phone number (optional)',
|
|
25
|
+
required: false,
|
|
26
|
+
}),
|
|
27
|
+
variables: pieces_framework_1.Property.Object({
|
|
28
|
+
displayName: 'Variables',
|
|
29
|
+
description: 'Subscriber variables to update (e.g., name, custom fields)',
|
|
30
|
+
required: false,
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
run(context) {
|
|
34
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const { mailingListId, email, phone, variables } = context.propsValue;
|
|
36
|
+
const results = [];
|
|
37
|
+
let hasUpdates = false;
|
|
38
|
+
if (phone) {
|
|
39
|
+
try {
|
|
40
|
+
const phoneResult = yield (0, client_1.sendpulseApiCall)({
|
|
41
|
+
method: pieces_common_1.HttpMethod.PUT,
|
|
42
|
+
auth: context.auth,
|
|
43
|
+
resourceUri: `/addressbooks/${mailingListId}/phone`,
|
|
44
|
+
body: { email, phone },
|
|
45
|
+
});
|
|
46
|
+
if (phoneResult.result) {
|
|
47
|
+
results.push({ type: 'phone', success: true, value: phone });
|
|
48
|
+
hasUpdates = true;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
results.push({ type: 'phone', success: false, error: 'API returned failure' });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
results.push({ type: 'phone', success: false, error: error.message });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (variables && Object.keys(variables).length > 0) {
|
|
59
|
+
const variableUpdates = Object.entries(variables).map(([name, value]) => ({
|
|
60
|
+
name,
|
|
61
|
+
value: String(value),
|
|
62
|
+
}));
|
|
63
|
+
try {
|
|
64
|
+
const variableResult = yield (0, client_1.sendpulseApiCall)({
|
|
65
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
66
|
+
auth: context.auth,
|
|
67
|
+
resourceUri: `/addressbooks/${mailingListId}/emails/variable`,
|
|
68
|
+
body: { email, variables: variableUpdates },
|
|
69
|
+
});
|
|
70
|
+
if (variableResult.result) {
|
|
71
|
+
results.push({ type: 'variables', success: true, count: variableUpdates.length });
|
|
72
|
+
hasUpdates = true;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
results.push({ type: 'variables', success: false, error: 'API returned failure' });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
results.push({ type: 'variables', success: false, error: error.message });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (!hasUpdates && !phone && (!variables || Object.keys(variables).length === 0)) {
|
|
83
|
+
throw new Error('No updates provided. Please specify phone number or variables to update.');
|
|
84
|
+
}
|
|
85
|
+
const successfulUpdates = results.filter(r => r.success);
|
|
86
|
+
const failedUpdates = results.filter(r => !r.success);
|
|
87
|
+
if (successfulUpdates.length === 0) {
|
|
88
|
+
throw new Error(`All updates failed: ${failedUpdates.map(f => f.error).join(', ')}`);
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
success: true,
|
|
92
|
+
message: `Subscriber ${email} updated successfully`,
|
|
93
|
+
email,
|
|
94
|
+
updates: results,
|
|
95
|
+
hasFailures: failedUpdates.length > 0,
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
//# sourceMappingURL=update-subscriber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-subscriber.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/sendpulse/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,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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