@activepieces/piece-klaviyo 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/package.json +17 -0
- package/src/index.d.ts +2 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +53 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/add-profile-to-list.d.ts +5 -0
- package/src/lib/actions/add-profile-to-list.d.ts.map +1 -0
- package/src/lib/actions/add-profile-to-list.js +46 -0
- package/src/lib/actions/add-profile-to-list.js.map +1 -0
- package/src/lib/actions/create-list.d.ts +4 -0
- package/src/lib/actions/create-list.d.ts.map +1 -0
- package/src/lib/actions/create-list.js +44 -0
- package/src/lib/actions/create-list.js.map +1 -0
- package/src/lib/actions/create-profile.d.ts +25 -0
- package/src/lib/actions/create-profile.d.ts.map +1 -0
- package/src/lib/actions/create-profile.js +203 -0
- package/src/lib/actions/create-profile.js.map +1 -0
- package/src/lib/actions/find-list-by-name.d.ts +5 -0
- package/src/lib/actions/find-list-by-name.d.ts.map +1 -0
- package/src/lib/actions/find-list-by-name.js +69 -0
- package/src/lib/actions/find-list-by-name.js.map +1 -0
- package/src/lib/actions/find-profile-by-email-phone.d.ts +5 -0
- package/src/lib/actions/find-profile-by-email-phone.d.ts.map +1 -0
- package/src/lib/actions/find-profile-by-email-phone.js +91 -0
- package/src/lib/actions/find-profile-by-email-phone.js.map +1 -0
- package/src/lib/actions/find-tag-by-name.d.ts +4 -0
- package/src/lib/actions/find-tag-by-name.d.ts.map +1 -0
- package/src/lib/actions/find-tag-by-name.js +60 -0
- package/src/lib/actions/find-tag-by-name.js.map +1 -0
- package/src/lib/actions/remove-profile-from-list.d.ts +5 -0
- package/src/lib/actions/remove-profile-from-list.d.ts.map +1 -0
- package/src/lib/actions/remove-profile-from-list.js +46 -0
- package/src/lib/actions/remove-profile-from-list.js.map +1 -0
- package/src/lib/actions/subscribe-profile.d.ts +10 -0
- package/src/lib/actions/subscribe-profile.d.ts.map +1 -0
- package/src/lib/actions/subscribe-profile.js +120 -0
- package/src/lib/actions/subscribe-profile.js.map +1 -0
- package/src/lib/actions/unsubscribe-profile.d.ts +8 -0
- package/src/lib/actions/unsubscribe-profile.d.ts.map +1 -0
- package/src/lib/actions/unsubscribe-profile.js +104 -0
- package/src/lib/actions/unsubscribe-profile.js.map +1 -0
- package/src/lib/actions/update-profile.d.ts +27 -0
- package/src/lib/actions/update-profile.d.ts.map +1 -0
- package/src/lib/actions/update-profile.js +216 -0
- package/src/lib/actions/update-profile.js.map +1 -0
- package/src/lib/common/auth.d.ts +5 -0
- package/src/lib/common/auth.d.ts.map +1 -0
- package/src/lib/common/auth.js +76 -0
- package/src/lib/common/auth.js.map +1 -0
- package/src/lib/common/client.d.ts +6 -0
- package/src/lib/common/client.d.ts.map +1 -0
- package/src/lib/common/client.js +62 -0
- package/src/lib/common/client.js.map +1 -0
- package/src/lib/common/props.d.ts +5 -0
- package/src/lib/common/props.d.ts.map +1 -0
- package/src/lib/common/props.js +100 -0
- package/src/lib/common/props.js.map +1 -0
- package/src/lib/triggers/new-profile.d.ts +3 -0
- package/src/lib/triggers/new-profile.d.ts.map +1 -0
- package/src/lib/triggers/new-profile.js +144 -0
- package/src/lib/triggers/new-profile.js.map +1 -0
- package/src/lib/triggers/profile-added-to-list-segment.d.ts +19 -0
- package/src/lib/triggers/profile-added-to-list-segment.d.ts.map +1 -0
- package/src/lib/triggers/profile-added-to-list-segment.js +232 -0
- package/src/lib/triggers/profile-added-to-list-segment.js.map +1 -0
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@activepieces/piece-klaviyo",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "./src/index.js",
|
|
5
|
+
"types": "./src/index.d.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsc -p tsconfig.lib.json && cp package.json dist/",
|
|
8
|
+
"lint": "eslint 'src/**/*.ts'"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@activepieces/pieces-common": "0.12.0",
|
|
12
|
+
"@activepieces/pieces-framework": "0.26.0",
|
|
13
|
+
"@activepieces/shared": "0.45.0",
|
|
14
|
+
"dayjs": "1.11.9",
|
|
15
|
+
"tslib": "2.6.2"
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const klaviyo: import("@activepieces/pieces-framework").Piece<(import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>)[]>;
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAuBA,eAAO,MAAM,OAAO,uOA6BlB,CAAC"}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.klaviyo = 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 shared_1 = require("@activepieces/shared");
|
|
8
|
+
const auth_1 = require("./lib/common/auth");
|
|
9
|
+
const create_profile_1 = require("./lib/actions/create-profile");
|
|
10
|
+
const update_profile_1 = require("./lib/actions/update-profile");
|
|
11
|
+
const add_profile_to_list_1 = require("./lib/actions/add-profile-to-list");
|
|
12
|
+
const new_profile_1 = require("./lib/triggers/new-profile");
|
|
13
|
+
const create_list_1 = require("./lib/actions/create-list");
|
|
14
|
+
const find_list_by_name_1 = require("./lib/actions/find-list-by-name");
|
|
15
|
+
const find_profile_by_email_phone_1 = require("./lib/actions/find-profile-by-email-phone");
|
|
16
|
+
const find_tag_by_name_1 = require("./lib/actions/find-tag-by-name");
|
|
17
|
+
const remove_profile_from_list_1 = require("./lib/actions/remove-profile-from-list");
|
|
18
|
+
const subscribe_profile_1 = require("./lib/actions/subscribe-profile");
|
|
19
|
+
const unsubscribe_profile_1 = require("./lib/actions/unsubscribe-profile");
|
|
20
|
+
const profile_added_to_list_segment_1 = require("./lib/triggers/profile-added-to-list-segment");
|
|
21
|
+
exports.klaviyo = (0, pieces_framework_1.createPiece)({
|
|
22
|
+
displayName: 'Klaviyo',
|
|
23
|
+
auth: auth_1.klaviyoAuth,
|
|
24
|
+
minimumSupportedRelease: '0.36.1',
|
|
25
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/klaviyo.png',
|
|
26
|
+
categories: [shared_1.PieceCategory.MARKETING],
|
|
27
|
+
authors: ['Sanket6652'],
|
|
28
|
+
actions: [
|
|
29
|
+
create_profile_1.createProfile,
|
|
30
|
+
update_profile_1.updateProfile,
|
|
31
|
+
add_profile_to_list_1.addProfileToList,
|
|
32
|
+
create_list_1.createList,
|
|
33
|
+
find_list_by_name_1.findListByName,
|
|
34
|
+
find_profile_by_email_phone_1.findProfileByEmailPhone,
|
|
35
|
+
find_tag_by_name_1.findTagByName,
|
|
36
|
+
remove_profile_from_list_1.removeProfileFromList,
|
|
37
|
+
subscribe_profile_1.subscribeProfile,
|
|
38
|
+
unsubscribe_profile_1.unsubscribeProfile,
|
|
39
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
40
|
+
baseUrl: () => 'https://a.klaviyo.com/api',
|
|
41
|
+
auth: auth_1.klaviyoAuth,
|
|
42
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
return ({
|
|
44
|
+
Authorization: (0, auth_1.getAuthorizationHeader)(auth),
|
|
45
|
+
revision: '2025-04-15',
|
|
46
|
+
accept: 'application/vnd.api+json',
|
|
47
|
+
});
|
|
48
|
+
}),
|
|
49
|
+
}),
|
|
50
|
+
],
|
|
51
|
+
triggers: [new_profile_1.newProfileTrigger, profile_added_to_list_segment_1.profileAddedToListOrSegmentTrigger],
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAA6D;AAC7D,+DAAwE;AACxE,iDAAqD;AAErD,4CAI2B;AAC3B,iEAA6D;AAC7D,iEAA6D;AAE7D,2EAAqE;AACrE,4DAA+D;AAC/D,2DAAuD;AACvD,uEAAiE;AACjE,2FAAoF;AACpF,qEAA+D;AAC/D,qFAA+E;AAC/E,uEAAmE;AACnE,2EAAuE;AACvE,gGAAkG;AAErF,QAAA,OAAO,GAAG,IAAA,8BAAW,EAAC;IACjC,WAAW,EAAE,SAAS;IACtB,IAAI,EAAE,kBAAW;IACjB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,iDAAiD;IAC1D,UAAU,EAAE,CAAC,sBAAa,CAAC,SAAS,CAAC;IACrC,OAAO,EAAE,CAAC,YAAY,CAAC;IACvB,OAAO,EAAE;QACP,8BAAa;QACb,8BAAa;QACb,sCAAgB;QAChB,wBAAU;QACV,kCAAc;QACd,qDAAuB;QACvB,gCAAa;QACb,gDAAqB;QACrB,oCAAgB;QAChB,wCAAkB;QAClB,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,GAAG,EAAE,CAAC,2BAA2B;YAC1C,IAAI,EAAE,kBAAW;YACjB,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC5B,aAAa,EAAE,IAAA,6BAAsB,EAAC,IAAwB,CAAC;oBAC/D,QAAQ,EAAE,YAAY;oBACtB,MAAM,EAAE,0BAA0B;iBACnC,CAAC,CAAA;cAAA;SACH,CAAC;KACH;IACD,QAAQ,EAAE,CAAC,+BAAiB,EAAE,kEAAkC,CAAC;CAClE,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const addProfileToList: import("@activepieces/pieces-framework").IAction<(import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>)[], {
|
|
2
|
+
list_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>)[]>;
|
|
3
|
+
profile_id: import("@activepieces/pieces-framework").MultiSelectDropdownProperty<string, true, (import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>)[]>;
|
|
4
|
+
}>;
|
|
5
|
+
//# sourceMappingURL=add-profile-to-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-profile-to-list.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/add-profile-to-list.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gBAAgB;;;EA+C3B,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addProfileToList = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const props_1 = require("../common/props");
|
|
7
|
+
const auth_1 = require("../common/auth");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
10
|
+
exports.addProfileToList = (0, pieces_framework_1.createAction)({
|
|
11
|
+
auth: auth_1.klaviyoAuth,
|
|
12
|
+
name: 'addProfileToList',
|
|
13
|
+
displayName: 'Add Profile to List',
|
|
14
|
+
description: 'Add profiles to a specific list without changing subscription status.',
|
|
15
|
+
props: {
|
|
16
|
+
list_id: props_1.listIdDropdown,
|
|
17
|
+
profile_id: props_1.profileIdsMultiSelectDropdown,
|
|
18
|
+
},
|
|
19
|
+
run(_a) {
|
|
20
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
|
|
21
|
+
const { list_id, profile_id } = propsValue;
|
|
22
|
+
if (!profile_id || profile_id.length === 0) {
|
|
23
|
+
throw new Error('At least one profile is required');
|
|
24
|
+
}
|
|
25
|
+
if (profile_id.length > 1000) {
|
|
26
|
+
throw new Error('Maximum of 1000 profiles can be added to a list at once');
|
|
27
|
+
}
|
|
28
|
+
const body = {
|
|
29
|
+
data: profile_id.map((id) => ({
|
|
30
|
+
type: 'profile',
|
|
31
|
+
id,
|
|
32
|
+
})),
|
|
33
|
+
};
|
|
34
|
+
const response = yield (0, client_1.makeRequest)(auth, pieces_common_1.HttpMethod.POST, `/lists/${list_id}/relationships/profiles`, body);
|
|
35
|
+
if (!response || Object.keys(response).length === 0) {
|
|
36
|
+
return {
|
|
37
|
+
success: true,
|
|
38
|
+
message: `Successfully added ${profile_id.length} profile(s) to list`,
|
|
39
|
+
profiles_added: profile_id.length,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return response;
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=add-profile-to-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-profile-to-list.js","sourceRoot":"","sources":["../../../../src/lib/actions/add-profile-to-list.ts"],"names":[],"mappings":";;;;AAAA,qEAA8D;AAC9D,2CAAgF;AAChF,yCAA+D;AAC/D,6CAA+C;AAC/C,+DAAyD;AAE5C,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,qBAAqB;IAClC,WAAW,EACT,uEAAuE;IACzE,KAAK,EAAE;QACL,OAAO,EAAE,sBAAc;QACvB,UAAU,EAAE,qCAA6B;KAC1C;IACK,GAAG;qEAAC,EAAE,IAAI,EAAE,UAAU,EAAE;YAC5B,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,UAAU,CAAC;YAE3C,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC3C,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;YACtD,CAAC;YAED,IAAI,UAAU,CAAC,MAAM,GAAG,IAAI,EAAE,CAAC;gBAC7B,MAAM,IAAI,KAAK,CACb,yDAAyD,CAC1D,CAAC;YACJ,CAAC;YAED,MAAM,IAAI,GAAG;gBACX,IAAI,EAAG,UAAuB,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;oBAC1C,IAAI,EAAE,SAAS;oBACf,EAAE;iBACH,CAAC,CAAC;aACJ,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAW,EAChC,IAAwB,EACxB,0BAAU,CAAC,IAAI,EACf,UAAU,OAAO,yBAAyB,EAC1C,IAAI,CACL,CAAC;YAEF,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACpD,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,OAAO,EAAE,sBAAsB,UAAU,CAAC,MAAM,qBAAqB;oBACrE,cAAc,EAAE,UAAU,CAAC,MAAM;iBAClC,CAAC;YACJ,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const createList: import("@activepieces/pieces-framework").IAction<(import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>)[], {
|
|
2
|
+
name: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
}>;
|
|
4
|
+
//# sourceMappingURL=create-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-list.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/create-list.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU;;EAyCrB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createList = 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 client_1 = require("../common/client");
|
|
8
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
9
|
+
exports.createList = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: auth_1.klaviyoAuth,
|
|
11
|
+
name: 'createList',
|
|
12
|
+
displayName: 'Create List',
|
|
13
|
+
description: 'Create a new subscriber list.',
|
|
14
|
+
props: {
|
|
15
|
+
name: pieces_framework_1.Property.ShortText({
|
|
16
|
+
displayName: 'List Name',
|
|
17
|
+
description: 'Name for the new list',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
},
|
|
21
|
+
run(_a) {
|
|
22
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
|
|
23
|
+
const { name } = propsValue;
|
|
24
|
+
if (!name || name.trim().length === 0) {
|
|
25
|
+
throw new Error('List name cannot be empty');
|
|
26
|
+
}
|
|
27
|
+
const data = {
|
|
28
|
+
data: {
|
|
29
|
+
type: 'list',
|
|
30
|
+
attributes: {
|
|
31
|
+
name: name.trim(),
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
const response = yield (0, client_1.makeRequest)(auth, pieces_common_1.HttpMethod.POST, '/lists', data);
|
|
36
|
+
return {
|
|
37
|
+
success: true,
|
|
38
|
+
message: `List "${name}" created successfully`,
|
|
39
|
+
list: response.data,
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=create-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-list.js","sourceRoot":"","sources":["../../../../src/lib/actions/create-list.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,yCAA+D;AAC/D,6CAA+C;AAC/C,+DAAyD;AAE5C,QAAA,UAAU,GAAG,IAAA,+BAAY,EAAC;IACrC,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,+BAA+B;IAC5C,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,uBAAuB;YACpC,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG;qEAAC,EAAE,IAAI,EAAE,UAAU,EAAE;YAC5B,MAAM,EAAE,IAAI,EAAE,GAAG,UAAU,CAAC;YAE5B,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACtC,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;YAC/C,CAAC;YAED,MAAM,IAAI,GAAG;gBACX,IAAI,EAAE;oBACJ,IAAI,EAAE,MAAM;oBACZ,UAAU,EAAE;wBACV,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;qBAClB;iBACF;aACF,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAW,EAChC,IAAwB,EACxB,0BAAU,CAAC,IAAI,EACf,QAAQ,EACR,IAAI,CACL,CAAC;YAEF,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,SAAS,IAAI,wBAAwB;gBAC9C,IAAI,EAAE,QAAQ,CAAC,IAAI;aACpB,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const createProfile: import("@activepieces/pieces-framework").IAction<(import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>)[], {
|
|
2
|
+
email: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
3
|
+
phone_number: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
external_id: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
5
|
+
first_name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
6
|
+
last_name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
7
|
+
organization: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
locale: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
9
|
+
title: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
10
|
+
image: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
11
|
+
address1: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
12
|
+
address2: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
13
|
+
city: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
14
|
+
country: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
15
|
+
region: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
16
|
+
zip: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
17
|
+
timezone: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
18
|
+
ip: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
19
|
+
latitude: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
20
|
+
longitude: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
21
|
+
custom_properties: import("@activepieces/pieces-framework").ObjectProperty<false>;
|
|
22
|
+
include_subscriptions: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
23
|
+
include_predictive_analytics: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
24
|
+
}>;
|
|
25
|
+
//# sourceMappingURL=create-profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-profile.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/create-profile.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;EA4NxB,CAAC"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createProfile = 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 client_1 = require("../common/client");
|
|
8
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
9
|
+
exports.createProfile = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: auth_1.klaviyoAuth,
|
|
11
|
+
name: 'createProfile',
|
|
12
|
+
displayName: 'Create Profile',
|
|
13
|
+
description: 'Add new user profile with email/SMS subscription options',
|
|
14
|
+
props: {
|
|
15
|
+
email: pieces_framework_1.Property.ShortText({
|
|
16
|
+
displayName: 'Email',
|
|
17
|
+
description: 'Email address (recommended identifier)',
|
|
18
|
+
required: false,
|
|
19
|
+
}),
|
|
20
|
+
phone_number: pieces_framework_1.Property.ShortText({
|
|
21
|
+
displayName: 'Phone Number',
|
|
22
|
+
description: 'Phone number in E.164 format (e.g., +15005550006)',
|
|
23
|
+
required: false,
|
|
24
|
+
}),
|
|
25
|
+
external_id: pieces_framework_1.Property.ShortText({
|
|
26
|
+
displayName: 'External ID',
|
|
27
|
+
description: 'Unique identifier from external system',
|
|
28
|
+
required: false,
|
|
29
|
+
}),
|
|
30
|
+
first_name: pieces_framework_1.Property.ShortText({
|
|
31
|
+
displayName: 'First Name',
|
|
32
|
+
required: false,
|
|
33
|
+
}),
|
|
34
|
+
last_name: pieces_framework_1.Property.ShortText({
|
|
35
|
+
displayName: 'Last Name',
|
|
36
|
+
required: false,
|
|
37
|
+
}),
|
|
38
|
+
organization: pieces_framework_1.Property.ShortText({
|
|
39
|
+
displayName: 'Organization',
|
|
40
|
+
description: 'Company name',
|
|
41
|
+
required: false,
|
|
42
|
+
}),
|
|
43
|
+
locale: pieces_framework_1.Property.ShortText({
|
|
44
|
+
displayName: 'Locale',
|
|
45
|
+
description: 'Language tag (e.g., en-US)',
|
|
46
|
+
required: false,
|
|
47
|
+
}),
|
|
48
|
+
title: pieces_framework_1.Property.ShortText({
|
|
49
|
+
displayName: 'Job Title',
|
|
50
|
+
required: false,
|
|
51
|
+
}),
|
|
52
|
+
image: pieces_framework_1.Property.ShortText({
|
|
53
|
+
displayName: 'Image URL',
|
|
54
|
+
description: 'Profile image URL',
|
|
55
|
+
required: false,
|
|
56
|
+
}),
|
|
57
|
+
address1: pieces_framework_1.Property.ShortText({
|
|
58
|
+
displayName: 'Address 1',
|
|
59
|
+
description: 'Street address line 1',
|
|
60
|
+
required: false,
|
|
61
|
+
}),
|
|
62
|
+
address2: pieces_framework_1.Property.ShortText({
|
|
63
|
+
displayName: 'Address 2',
|
|
64
|
+
description: 'Street address line 2',
|
|
65
|
+
required: false,
|
|
66
|
+
}),
|
|
67
|
+
city: pieces_framework_1.Property.ShortText({
|
|
68
|
+
displayName: 'City',
|
|
69
|
+
required: false,
|
|
70
|
+
}),
|
|
71
|
+
country: pieces_framework_1.Property.ShortText({
|
|
72
|
+
displayName: 'Country',
|
|
73
|
+
required: false,
|
|
74
|
+
}),
|
|
75
|
+
region: pieces_framework_1.Property.ShortText({
|
|
76
|
+
displayName: 'Region/State',
|
|
77
|
+
required: false,
|
|
78
|
+
}),
|
|
79
|
+
zip: pieces_framework_1.Property.ShortText({
|
|
80
|
+
displayName: 'Zip Code',
|
|
81
|
+
required: false,
|
|
82
|
+
}),
|
|
83
|
+
timezone: pieces_framework_1.Property.ShortText({
|
|
84
|
+
displayName: 'Timezone',
|
|
85
|
+
description: 'IANA timezone (e.g., America/New_York)',
|
|
86
|
+
required: false,
|
|
87
|
+
}),
|
|
88
|
+
ip: pieces_framework_1.Property.ShortText({
|
|
89
|
+
displayName: 'IP Address',
|
|
90
|
+
required: false,
|
|
91
|
+
}),
|
|
92
|
+
latitude: pieces_framework_1.Property.Number({
|
|
93
|
+
displayName: 'Latitude',
|
|
94
|
+
description: 'Latitude coordinate (4 decimal places recommended)',
|
|
95
|
+
required: false,
|
|
96
|
+
}),
|
|
97
|
+
longitude: pieces_framework_1.Property.Number({
|
|
98
|
+
displayName: 'Longitude',
|
|
99
|
+
description: 'Longitude coordinate (4 decimal places recommended)',
|
|
100
|
+
required: false,
|
|
101
|
+
}),
|
|
102
|
+
custom_properties: pieces_framework_1.Property.Object({
|
|
103
|
+
displayName: 'Custom Properties',
|
|
104
|
+
description: 'Key-value pairs for segmentation and personalization',
|
|
105
|
+
required: false,
|
|
106
|
+
}),
|
|
107
|
+
include_subscriptions: pieces_framework_1.Property.Checkbox({
|
|
108
|
+
displayName: 'Include Subscriptions',
|
|
109
|
+
description: 'Return subscription data in response',
|
|
110
|
+
required: false,
|
|
111
|
+
defaultValue: false,
|
|
112
|
+
}),
|
|
113
|
+
include_predictive_analytics: pieces_framework_1.Property.Checkbox({
|
|
114
|
+
displayName: 'Include Predictive Analytics',
|
|
115
|
+
description: 'Return predictive analytics in response',
|
|
116
|
+
required: false,
|
|
117
|
+
defaultValue: false,
|
|
118
|
+
}),
|
|
119
|
+
},
|
|
120
|
+
run(_a) {
|
|
121
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
|
|
122
|
+
const { email, phone_number, external_id, first_name, last_name, organization, locale, title, image, address1, address2, city, country, region, zip, timezone, ip, latitude, longitude, custom_properties, include_subscriptions, include_predictive_analytics, } = propsValue;
|
|
123
|
+
if (!email && !phone_number && !external_id) {
|
|
124
|
+
throw new Error('At least one identifier is required: email, phone_number, or external_id');
|
|
125
|
+
}
|
|
126
|
+
const attributes = {};
|
|
127
|
+
if (email)
|
|
128
|
+
attributes['email'] = email;
|
|
129
|
+
if (phone_number)
|
|
130
|
+
attributes['phone_number'] = phone_number;
|
|
131
|
+
if (external_id)
|
|
132
|
+
attributes['external_id'] = external_id;
|
|
133
|
+
if (first_name)
|
|
134
|
+
attributes['first_name'] = first_name;
|
|
135
|
+
if (last_name)
|
|
136
|
+
attributes['last_name'] = last_name;
|
|
137
|
+
if (organization)
|
|
138
|
+
attributes['organization'] = organization;
|
|
139
|
+
if (locale)
|
|
140
|
+
attributes['locale'] = locale;
|
|
141
|
+
if (title)
|
|
142
|
+
attributes['title'] = title;
|
|
143
|
+
if (image)
|
|
144
|
+
attributes['image'] = image;
|
|
145
|
+
const hasLocationData = address1 ||
|
|
146
|
+
address2 ||
|
|
147
|
+
city ||
|
|
148
|
+
country ||
|
|
149
|
+
region ||
|
|
150
|
+
zip ||
|
|
151
|
+
timezone ||
|
|
152
|
+
ip ||
|
|
153
|
+
latitude ||
|
|
154
|
+
longitude;
|
|
155
|
+
if (hasLocationData) {
|
|
156
|
+
attributes['location'] = {};
|
|
157
|
+
if (address1)
|
|
158
|
+
attributes['location']['address1'] = address1;
|
|
159
|
+
if (address2)
|
|
160
|
+
attributes['location']['address2'] = address2;
|
|
161
|
+
if (city)
|
|
162
|
+
attributes['location']['city'] = city;
|
|
163
|
+
if (country)
|
|
164
|
+
attributes['location']['country'] = country;
|
|
165
|
+
if (region)
|
|
166
|
+
attributes['location']['region'] = region;
|
|
167
|
+
if (zip)
|
|
168
|
+
attributes['location']['zip'] = zip;
|
|
169
|
+
if (timezone)
|
|
170
|
+
attributes['location']['timezone'] = timezone;
|
|
171
|
+
if (ip)
|
|
172
|
+
attributes['location']['ip'] = ip;
|
|
173
|
+
if (latitude)
|
|
174
|
+
attributes['location']['latitude'] = latitude;
|
|
175
|
+
if (longitude)
|
|
176
|
+
attributes['location']['longitude'] = longitude;
|
|
177
|
+
}
|
|
178
|
+
if (custom_properties) {
|
|
179
|
+
attributes['properties'] = custom_properties;
|
|
180
|
+
}
|
|
181
|
+
const body = {
|
|
182
|
+
data: {
|
|
183
|
+
type: 'profile',
|
|
184
|
+
attributes,
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
const queryParams = new URLSearchParams();
|
|
188
|
+
const additionalFields = [];
|
|
189
|
+
if (include_subscriptions) {
|
|
190
|
+
additionalFields.push('subscriptions');
|
|
191
|
+
}
|
|
192
|
+
if (include_predictive_analytics) {
|
|
193
|
+
additionalFields.push('predictive_analytics');
|
|
194
|
+
}
|
|
195
|
+
if (additionalFields.length > 0) {
|
|
196
|
+
queryParams.append('additional-fields[profile]', additionalFields.join(','));
|
|
197
|
+
}
|
|
198
|
+
const endpoint = `/profiles${queryParams.toString() ? '?' + queryParams.toString() : ''}`;
|
|
199
|
+
return yield (0, client_1.makeRequest)(auth, pieces_common_1.HttpMethod.POST, endpoint, body);
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
//# sourceMappingURL=create-profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-profile.js","sourceRoot":"","sources":["../../../../src/lib/actions/create-profile.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,yCAA+D;AAC/D,6CAA+C;AAC/C,+DAAyD;AAE5C,QAAA,aAAa,GAAG,IAAA,+BAAY,EAAC;IACxC,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,gBAAgB;IAC7B,WAAW,EAAE,0DAA0D;IACvE,KAAK,EAAE;QACL,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,wCAAwC;YACrD,QAAQ,EAAE,KAAK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E,CAAC;gBACtB,UAAU,CAAC,YAAY,CAAC,GAAG,iBAAiB,CAAC;YAC/C,CAAC;YAED,MAAM,IAAI,GAAG;gBACX,IAAI,EAAE;oBACJ,IAAI,EAAE,SAAS;oBACf,UAAU;iBACX;aACF,CAAC;YAEF,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE,CAAC;YAC1C,MAAM,gBAAgB,GAAG,EAAE,CAAC;YAE5B,IAAI,qBAAqB,EAAE,CAAC;gBAC1B,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YACzC,CAAC;YACD,IAAI,4BAA4B,EAAE,CAAC;gBACjC,gBAAgB,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;YAChD,CAAC;YAED,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAChC,WAAW,CAAC,MAAM,CAChB,4BAA4B,EAC5B,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAC3B,CAAC;YACJ,CAAC;YAED,MAAM,QAAQ,GAAG,YACf,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAC1D,EAAE,CAAC;YAEH,OAAO,MAAM,IAAA,oBAAW,EACtB,IAAwB,EACxB,0BAAU,CAAC,IAAI,EACf,QAAQ,EACR,IAAI,CACL,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const findListByName: import("@activepieces/pieces-framework").IAction<(import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>)[], {
|
|
2
|
+
search_query: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
3
|
+
include_additional_data: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
4
|
+
}>;
|
|
5
|
+
//# sourceMappingURL=find-list-by-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-list-by-name.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/find-list-by-name.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,cAAc;;;EAyEzB,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findListByName = 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 client_1 = require("../common/client");
|
|
8
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
9
|
+
exports.findListByName = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: auth_1.klaviyoAuth,
|
|
11
|
+
name: 'findListByName',
|
|
12
|
+
displayName: 'Find List by Name',
|
|
13
|
+
description: 'Find lists by name with optional additional data',
|
|
14
|
+
props: {
|
|
15
|
+
search_query: pieces_framework_1.Property.LongText({
|
|
16
|
+
displayName: 'List Name(s)',
|
|
17
|
+
description: 'Enter list name',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
include_additional_data: pieces_framework_1.Property.Checkbox({
|
|
21
|
+
displayName: 'Include Additional Data',
|
|
22
|
+
description: 'Include related flow and tag information',
|
|
23
|
+
required: false,
|
|
24
|
+
defaultValue: false,
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
27
|
+
run(_a) {
|
|
28
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
|
|
29
|
+
const { search_query, include_additional_data } = propsValue;
|
|
30
|
+
if (!search_query || search_query.trim().length === 0) {
|
|
31
|
+
throw new Error('List name is required');
|
|
32
|
+
}
|
|
33
|
+
const trimmedQuery = search_query.trim();
|
|
34
|
+
let filter = '';
|
|
35
|
+
filter = `equals(name,"${trimmedQuery}")`;
|
|
36
|
+
const queryParams = new URLSearchParams();
|
|
37
|
+
queryParams.append('filter', filter);
|
|
38
|
+
queryParams.append('page[size]', '10');
|
|
39
|
+
queryParams.append('sort', 'name');
|
|
40
|
+
if (include_additional_data) {
|
|
41
|
+
queryParams.append('include', 'tags');
|
|
42
|
+
}
|
|
43
|
+
const response = yield (0, client_1.makeRequest)(auth, pieces_common_1.HttpMethod.GET, `/lists?${queryParams.toString()}`);
|
|
44
|
+
const lists = response.data || [];
|
|
45
|
+
if (lists.length === 0) {
|
|
46
|
+
return {
|
|
47
|
+
success: false,
|
|
48
|
+
message: `No lists found with ${trimmedQuery}`,
|
|
49
|
+
lists: [],
|
|
50
|
+
count: 0,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const formattedLists = lists.map((list) => ({
|
|
54
|
+
id: list.id,
|
|
55
|
+
name: list.attributes.name,
|
|
56
|
+
created: list.attributes.created,
|
|
57
|
+
updated: list.attributes.updated,
|
|
58
|
+
opt_in_process: list.attributes.opt_in_process,
|
|
59
|
+
}));
|
|
60
|
+
return {
|
|
61
|
+
success: true,
|
|
62
|
+
message: `Found ${lists.length} list(s) matching your search`,
|
|
63
|
+
lists: formattedLists,
|
|
64
|
+
rawresponse: response,
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=find-list-by-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-list-by-name.js","sourceRoot":"","sources":["../../../../src/lib/actions/find-list-by-name.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,yCAA+D;AAC/D,6CAA+C;AAC/C,+DAAyD;AAa5C,QAAA,cAAc,GAAG,IAAA,+BAAY,EAAC;IACzC,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,kDAAkD;IAC/D,KAAK,EAAE;QACL,YAAY,EAAE,2B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I,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACvB,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,OAAO,EAAE,uBAAuB,YAAY,EAAE;oBAC9C,KAAK,EAAE,EAAE;oBACT,KAAK,EAAE,CAAC;iBACT,CAAC;YACJ,CAAC;YAED,MAAM,cAAc,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBAC1C,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI;gBAC1B,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO;gBAChC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO;gBAChC,cAAc,EAAE,IAAI,CAAC,UAAU,CAAC,cAAc;aAC/C,CAAC,CAAC,CAAC;YAEJ,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,SAAS,KAAK,CAAC,MAAM,+BAA+B;gBAC7D,KAAK,EAAE,cAAc;gBACrB,WAAW,EAAE,QAAQ;aACtB,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const findProfileByEmailPhone: import("@activepieces/pieces-framework").IAction<(import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>)[], {
|
|
2
|
+
search_query: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
include_additional_data: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
4
|
+
}>;
|
|
5
|
+
//# sourceMappingURL=find-profile-by-email-phone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-profile-by-email-phone.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/find-profile-by-email-phone.ts"],"names":[],"mappings":"AA0BA,eAAO,MAAM,uBAAuB;;;EAwGlC,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findProfileByEmailPhone = 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 client_1 = require("../common/client");
|
|
8
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
9
|
+
exports.findProfileByEmailPhone = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: auth_1.klaviyoAuth,
|
|
11
|
+
name: 'findProfileByEmailPhone',
|
|
12
|
+
displayName: 'Find Profile by Email/Phone',
|
|
13
|
+
description: 'Find a profile using email or phone number.',
|
|
14
|
+
props: {
|
|
15
|
+
search_query: pieces_framework_1.Property.ShortText({
|
|
16
|
+
displayName: 'Email or Phone Number',
|
|
17
|
+
description: 'Enter an email address or phone number (E.164 format recommended)',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
include_additional_data: pieces_framework_1.Property.Checkbox({
|
|
21
|
+
displayName: 'Include Additional Data',
|
|
22
|
+
description: 'Include subscriptions and predictive analytics data',
|
|
23
|
+
required: false,
|
|
24
|
+
defaultValue: false,
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
27
|
+
run(_a) {
|
|
28
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
|
|
29
|
+
const { search_query, include_additional_data } = propsValue;
|
|
30
|
+
if (!search_query || search_query.trim().length === 0) {
|
|
31
|
+
throw new Error('Email or phone number is required');
|
|
32
|
+
}
|
|
33
|
+
const trimmedQuery = search_query.trim();
|
|
34
|
+
let filter = '';
|
|
35
|
+
const isEmail = trimmedQuery.includes('@');
|
|
36
|
+
if (isEmail) {
|
|
37
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
38
|
+
if (!emailRegex.test(trimmedQuery)) {
|
|
39
|
+
throw new Error('Please enter a valid email address');
|
|
40
|
+
}
|
|
41
|
+
filter = `equals(email,"${trimmedQuery}")`;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
const phoneRegex = /^[\+]?[1-9][\d\s\-\(\)\.]{7,15}$/;
|
|
45
|
+
if (!phoneRegex.test(trimmedQuery)) {
|
|
46
|
+
throw new Error('Please enter a valid phone number (E.164 format recommended, e.g., +1234567890)');
|
|
47
|
+
}
|
|
48
|
+
filter = `equals(phone_number,"${trimmedQuery}")`;
|
|
49
|
+
}
|
|
50
|
+
// Build query parameters
|
|
51
|
+
const queryParams = new URLSearchParams();
|
|
52
|
+
queryParams.append('filter', filter);
|
|
53
|
+
queryParams.append('page[size]', '50');
|
|
54
|
+
if (include_additional_data) {
|
|
55
|
+
queryParams.append('additional-fields[profile]', 'subscriptions,predictive_analytics');
|
|
56
|
+
}
|
|
57
|
+
const response = yield (0, client_1.makeRequest)(auth, pieces_common_1.HttpMethod.GET, `/profiles?${queryParams.toString()}`);
|
|
58
|
+
const profiles = response.data || [];
|
|
59
|
+
if (profiles.length === 0) {
|
|
60
|
+
return {
|
|
61
|
+
success: false,
|
|
62
|
+
message: `No profile found with ${isEmail ? 'email' : 'phone number'}: ${trimmedQuery}`,
|
|
63
|
+
profiles: [],
|
|
64
|
+
count: 0,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const formattedProfiles = profiles.map((profile) => ({
|
|
68
|
+
id: profile.id,
|
|
69
|
+
email: profile.attributes.email,
|
|
70
|
+
phone_number: profile.attributes.phone_number,
|
|
71
|
+
first_name: profile.attributes.first_name,
|
|
72
|
+
last_name: profile.attributes.last_name,
|
|
73
|
+
external_id: profile.attributes.external_id,
|
|
74
|
+
full_name: [profile.attributes.first_name, profile.attributes.last_name]
|
|
75
|
+
.filter(Boolean)
|
|
76
|
+
.join(' ') || null,
|
|
77
|
+
created: profile.attributes.created,
|
|
78
|
+
updated: profile.attributes.updated,
|
|
79
|
+
full_profile: profile.attributes,
|
|
80
|
+
}));
|
|
81
|
+
return {
|
|
82
|
+
success: true,
|
|
83
|
+
message: `Found ${profiles.length} profile(s) matching ${isEmail ? 'email' : 'phone number'}: ${trimmedQuery}`,
|
|
84
|
+
profiles: formattedProfiles,
|
|
85
|
+
count: profiles.length,
|
|
86
|
+
raw_response: response,
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=find-profile-by-email-phone.js.map
|