@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
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateProfile = 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.updateProfile = (0, pieces_framework_1.createAction)({
|
|
11
|
+
auth: auth_1.klaviyoAuth,
|
|
12
|
+
name: 'updateProfile',
|
|
13
|
+
displayName: 'Update Profile',
|
|
14
|
+
description: 'Update existing profile data and preferences.',
|
|
15
|
+
props: {
|
|
16
|
+
profile_id: props_1.profileIdDropdown,
|
|
17
|
+
email: pieces_framework_1.Property.ShortText({
|
|
18
|
+
displayName: 'Email',
|
|
19
|
+
description: "Individual's email address",
|
|
20
|
+
required: false,
|
|
21
|
+
}),
|
|
22
|
+
phone_number: pieces_framework_1.Property.ShortText({
|
|
23
|
+
displayName: 'Phone Number',
|
|
24
|
+
description: 'Phone number in E.164 format (e.g., +15005550006)',
|
|
25
|
+
required: false,
|
|
26
|
+
}),
|
|
27
|
+
external_id: pieces_framework_1.Property.ShortText({
|
|
28
|
+
displayName: 'External ID',
|
|
29
|
+
description: 'Unique identifier from external system (e.g., POS system)',
|
|
30
|
+
required: false,
|
|
31
|
+
}),
|
|
32
|
+
anonymous_id: pieces_framework_1.Property.ShortText({
|
|
33
|
+
displayName: 'Anonymous ID',
|
|
34
|
+
description: 'Anonymous identifier for the profile',
|
|
35
|
+
required: false,
|
|
36
|
+
}),
|
|
37
|
+
first_name: pieces_framework_1.Property.ShortText({
|
|
38
|
+
displayName: 'First Name',
|
|
39
|
+
description: "Individual's first name",
|
|
40
|
+
required: false,
|
|
41
|
+
}),
|
|
42
|
+
last_name: pieces_framework_1.Property.ShortText({
|
|
43
|
+
displayName: 'Last Name',
|
|
44
|
+
description: "Individual's last name",
|
|
45
|
+
required: false,
|
|
46
|
+
}),
|
|
47
|
+
organization: pieces_framework_1.Property.ShortText({
|
|
48
|
+
displayName: 'Organization',
|
|
49
|
+
description: 'Company or organization name',
|
|
50
|
+
required: false,
|
|
51
|
+
}),
|
|
52
|
+
locale: pieces_framework_1.Property.ShortText({
|
|
53
|
+
displayName: 'Locale',
|
|
54
|
+
description: 'Locale in IETF BCP 47 format (e.g., en-US)',
|
|
55
|
+
required: false,
|
|
56
|
+
}),
|
|
57
|
+
title: pieces_framework_1.Property.ShortText({
|
|
58
|
+
displayName: 'Title',
|
|
59
|
+
description: "Individual's job title",
|
|
60
|
+
required: false,
|
|
61
|
+
}),
|
|
62
|
+
image: pieces_framework_1.Property.ShortText({
|
|
63
|
+
displayName: 'Image URL',
|
|
64
|
+
description: 'URL pointing to profile image location',
|
|
65
|
+
required: false,
|
|
66
|
+
}),
|
|
67
|
+
// Location fields
|
|
68
|
+
address1: pieces_framework_1.Property.ShortText({
|
|
69
|
+
displayName: 'Address 1',
|
|
70
|
+
description: 'First line of street address',
|
|
71
|
+
required: false,
|
|
72
|
+
}),
|
|
73
|
+
address2: pieces_framework_1.Property.ShortText({
|
|
74
|
+
displayName: 'Address 2',
|
|
75
|
+
description: 'Second line of street address',
|
|
76
|
+
required: false,
|
|
77
|
+
}),
|
|
78
|
+
city: pieces_framework_1.Property.ShortText({
|
|
79
|
+
displayName: 'City',
|
|
80
|
+
description: 'City name',
|
|
81
|
+
required: false,
|
|
82
|
+
}),
|
|
83
|
+
country: props_1.countryCode,
|
|
84
|
+
region: pieces_framework_1.Property.ShortText({
|
|
85
|
+
displayName: 'Region',
|
|
86
|
+
description: 'Region within country (state/province)',
|
|
87
|
+
required: false,
|
|
88
|
+
}),
|
|
89
|
+
zip: pieces_framework_1.Property.ShortText({
|
|
90
|
+
displayName: 'Zip Code',
|
|
91
|
+
description: 'Postal/zip code',
|
|
92
|
+
required: false,
|
|
93
|
+
}),
|
|
94
|
+
timezone: pieces_framework_1.Property.ShortText({
|
|
95
|
+
displayName: 'Timezone',
|
|
96
|
+
description: 'IANA timezone (e.g., America/New_York)',
|
|
97
|
+
required: false,
|
|
98
|
+
}),
|
|
99
|
+
ip: pieces_framework_1.Property.ShortText({
|
|
100
|
+
displayName: 'IP Address',
|
|
101
|
+
description: 'IP address of the profile',
|
|
102
|
+
required: false,
|
|
103
|
+
}),
|
|
104
|
+
latitude: pieces_framework_1.Property.Number({
|
|
105
|
+
displayName: 'Latitude',
|
|
106
|
+
description: 'Latitude coordinate (4 decimal places recommended)',
|
|
107
|
+
required: false,
|
|
108
|
+
}),
|
|
109
|
+
longitude: pieces_framework_1.Property.Number({
|
|
110
|
+
displayName: 'Longitude',
|
|
111
|
+
description: 'Longitude coordinate (4 decimal places recommended)',
|
|
112
|
+
required: false,
|
|
113
|
+
}),
|
|
114
|
+
custom_properties: pieces_framework_1.Property.Object({
|
|
115
|
+
displayName: 'Custom Properties',
|
|
116
|
+
description: 'Key/value pairs for custom profile properties',
|
|
117
|
+
required: false,
|
|
118
|
+
}),
|
|
119
|
+
include_subscriptions: pieces_framework_1.Property.Checkbox({
|
|
120
|
+
displayName: 'Include Subscriptions',
|
|
121
|
+
description: 'Include subscription data in response',
|
|
122
|
+
required: false,
|
|
123
|
+
defaultValue: false,
|
|
124
|
+
}),
|
|
125
|
+
include_predictive_analytics: pieces_framework_1.Property.Checkbox({
|
|
126
|
+
displayName: 'Include Predictive Analytics',
|
|
127
|
+
description: 'Include predictive analytics data in response',
|
|
128
|
+
required: false,
|
|
129
|
+
defaultValue: false,
|
|
130
|
+
}),
|
|
131
|
+
},
|
|
132
|
+
run(_a) {
|
|
133
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
|
|
134
|
+
const { profile_id, email, phone_number, external_id, anonymous_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;
|
|
135
|
+
const attributes = {};
|
|
136
|
+
if (email !== undefined)
|
|
137
|
+
attributes['email'] = email;
|
|
138
|
+
if (phone_number !== undefined)
|
|
139
|
+
attributes['phone_number'] = phone_number;
|
|
140
|
+
if (external_id !== undefined)
|
|
141
|
+
attributes['external_id'] = external_id;
|
|
142
|
+
if (anonymous_id !== undefined)
|
|
143
|
+
attributes['anonymous_id'] = anonymous_id;
|
|
144
|
+
if (first_name !== undefined)
|
|
145
|
+
attributes['first_name'] = first_name;
|
|
146
|
+
if (last_name !== undefined)
|
|
147
|
+
attributes['last_name'] = last_name;
|
|
148
|
+
if (organization !== undefined)
|
|
149
|
+
attributes['organization'] = organization;
|
|
150
|
+
if (locale !== undefined)
|
|
151
|
+
attributes['locale'] = locale;
|
|
152
|
+
if (title !== undefined)
|
|
153
|
+
attributes['title'] = title;
|
|
154
|
+
if (image !== undefined)
|
|
155
|
+
attributes['image'] = image;
|
|
156
|
+
const hasLocationData = address1 !== undefined ||
|
|
157
|
+
address2 !== undefined ||
|
|
158
|
+
city !== undefined ||
|
|
159
|
+
country !== undefined ||
|
|
160
|
+
region !== undefined ||
|
|
161
|
+
zip !== undefined ||
|
|
162
|
+
timezone !== undefined ||
|
|
163
|
+
ip !== undefined ||
|
|
164
|
+
latitude !== undefined ||
|
|
165
|
+
longitude !== undefined;
|
|
166
|
+
if (hasLocationData) {
|
|
167
|
+
const location = {};
|
|
168
|
+
if (address1 !== undefined)
|
|
169
|
+
location['address1'] = address1;
|
|
170
|
+
if (address2 !== undefined)
|
|
171
|
+
location['address2'] = address2;
|
|
172
|
+
if (city !== undefined)
|
|
173
|
+
location['city'] = city;
|
|
174
|
+
if (country !== undefined)
|
|
175
|
+
location['country'] = country;
|
|
176
|
+
if (region !== undefined)
|
|
177
|
+
location['region'] = region;
|
|
178
|
+
if (zip !== undefined)
|
|
179
|
+
location['zip'] = zip;
|
|
180
|
+
if (timezone !== undefined)
|
|
181
|
+
location['timezone'] = timezone;
|
|
182
|
+
if (ip !== undefined)
|
|
183
|
+
location['ip'] = ip;
|
|
184
|
+
if (latitude !== undefined)
|
|
185
|
+
location['latitude'] = latitude;
|
|
186
|
+
if (longitude !== undefined)
|
|
187
|
+
location['longitude'] = longitude;
|
|
188
|
+
attributes['location'] = location;
|
|
189
|
+
}
|
|
190
|
+
if (custom_properties !== undefined) {
|
|
191
|
+
attributes['properties'] = custom_properties;
|
|
192
|
+
}
|
|
193
|
+
const body = {
|
|
194
|
+
data: {
|
|
195
|
+
type: 'profile',
|
|
196
|
+
id: profile_id,
|
|
197
|
+
attributes,
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
const queryParams = [];
|
|
201
|
+
const additionalFields = [];
|
|
202
|
+
if (include_subscriptions) {
|
|
203
|
+
additionalFields.push('subscriptions');
|
|
204
|
+
}
|
|
205
|
+
if (include_predictive_analytics) {
|
|
206
|
+
additionalFields.push('predictive_analytics');
|
|
207
|
+
}
|
|
208
|
+
if (additionalFields.length > 0) {
|
|
209
|
+
queryParams.push(`additional-fields[profile]=${additionalFields.join(',')}`);
|
|
210
|
+
}
|
|
211
|
+
const queryString = queryParams.length > 0 ? `?${queryParams.join('&')}` : '';
|
|
212
|
+
return yield (0, client_1.makeRequest)(auth, pieces_common_1.HttpMethod.PATCH, `/profiles/${profile_id}${queryString}`, body);
|
|
213
|
+
});
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
//# sourceMappingURL=update-profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-profile.js","sourceRoot":"","sources":["../../../../src/lib/actions/update-profile.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,2CAAiE;AACjE,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,+CAA+C;IAC5D,KAAK,EAAE;QACL,UAAU,EAAE,yBAAiB;QAC7B,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,4BAA4B;YACzC,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,YAAY,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC/B,WAAW,EAAE,cAAc;Y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ChB,aAAa,UAAU,GAAG,WAAW,EAAE,EACvC,IAAI,CACL,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AppConnectionValueForAuthProperty } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const klaviyoAuth: (import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>)[];
|
|
3
|
+
export type KlaviyoAuthValue = AppConnectionValueForAuthProperty<typeof klaviyoAuth>;
|
|
4
|
+
export declare function getAuthorizationHeader(auth: KlaviyoAuthValue): string;
|
|
5
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EAGlC,MAAM,gCAAgC,CAAC;AAIxC,eAAO,MAAM,WAAW,uLA4DvB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,iCAAiC,CAC9D,OAAO,WAAW,CACnB,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAKrE"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.klaviyoAuth = void 0;
|
|
4
|
+
exports.getAuthorizationHeader = getAuthorizationHeader;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
8
|
+
const shared_1 = require("@activepieces/shared");
|
|
9
|
+
exports.klaviyoAuth = [
|
|
10
|
+
pieces_framework_1.PieceAuth.SecretText({
|
|
11
|
+
displayName: 'Private API Key',
|
|
12
|
+
description: `Authenticate using your Klaviyo Private API Key.\n\n**Steps:**\n1. Log in to Klaviyo → go to **Settings → API Keys**\n2. Click **Create Private API Key**\n3. Give it a name and select the required scopes\n4. Copy the key (starts with \`pk_\`) and paste it below`,
|
|
13
|
+
required: true,
|
|
14
|
+
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
15
|
+
try {
|
|
16
|
+
yield pieces_common_1.httpClient.sendRequest({
|
|
17
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
18
|
+
url: 'https://a.klaviyo.com/api/accounts',
|
|
19
|
+
headers: {
|
|
20
|
+
Authorization: `Klaviyo-API-Key ${auth}`,
|
|
21
|
+
revision: '2025-04-15',
|
|
22
|
+
accept: 'application/vnd.api+json',
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
return { valid: true };
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
return {
|
|
29
|
+
valid: false,
|
|
30
|
+
error: 'Invalid Private API Key. Check your key in Klaviyo → Settings → API Keys.',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}),
|
|
34
|
+
}),
|
|
35
|
+
pieces_framework_1.PieceAuth.OAuth2({
|
|
36
|
+
description: `
|
|
37
|
+
To connect via OAuth2, follow the [Klaviyo OAuth setup guide](https://developers.klaviyo.com/en/docs/set_up_oauth) to register your app, then set the **Redirect URI** to {{redirectUrl}} and enable the following **scopes** in your app settings:
|
|
38
|
+
- profiles:read
|
|
39
|
+
- profiles:write
|
|
40
|
+
- lists:read
|
|
41
|
+
- lists:write
|
|
42
|
+
- tags:read
|
|
43
|
+
- segments:read
|
|
44
|
+
- events:read
|
|
45
|
+
- events:write
|
|
46
|
+
- subscriptions:read
|
|
47
|
+
- subscriptions:write
|
|
48
|
+
- accounts:read`,
|
|
49
|
+
authUrl: 'https://www.klaviyo.com/oauth/authorize',
|
|
50
|
+
tokenUrl: 'https://a.klaviyo.com/oauth/token',
|
|
51
|
+
required: true,
|
|
52
|
+
scope: [
|
|
53
|
+
'profiles:read',
|
|
54
|
+
'profiles:write',
|
|
55
|
+
'lists:read',
|
|
56
|
+
'lists:write',
|
|
57
|
+
'tags:read',
|
|
58
|
+
'segments:read',
|
|
59
|
+
'events:read',
|
|
60
|
+
'events:write',
|
|
61
|
+
'subscriptions:read',
|
|
62
|
+
'subscriptions:write',
|
|
63
|
+
'accounts:read',
|
|
64
|
+
],
|
|
65
|
+
pkce: true,
|
|
66
|
+
pkceMethod: 'S256',
|
|
67
|
+
authorizationMethod: pieces_framework_1.OAuth2AuthorizationMethod.HEADER,
|
|
68
|
+
}),
|
|
69
|
+
];
|
|
70
|
+
function getAuthorizationHeader(auth) {
|
|
71
|
+
if (auth.type === shared_1.AppConnectionType.SECRET_TEXT) {
|
|
72
|
+
return `Klaviyo-API-Key ${auth.secret_text}`;
|
|
73
|
+
}
|
|
74
|
+
return `Bearer ${auth.access_token}`;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../src/lib/common/auth.ts"],"names":[],"mappings":";;;AA0EA,wDAKC;;AA/ED,qEAIwC;AACxC,+DAAqE;AACrE,iDAAyD;AAE5C,QAAA,WAAW,GAAG;IACzB,4BAAS,CAAC,UAAU,CAAC;QACnB,WAAW,EAAE,iBAAiB;QAC9B,WAAW,EAAE,uQAAuQ;QACpR,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;YACvB,IAAI,CAAC;gBACH,MAAM,0BAAU,CAAC,WAAW,CAAC;oBAC3B,MAAM,EAAE,0BAAU,CAAC,GAAG;oBACtB,GAAG,EAAE,oCAAoC;oBACzC,OAAO,EAAE;wBACP,aAAa,EAAE,mBAAmB,IAAI,EAAE;wBACxC,QAAQ,EAAE,YAAY;wBACtB,MAAM,EAAE,0BAA0B;qBACnC;iBACF,CAAC,CAAC;gBACH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YACzB,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO;oBACL,KAAK,EAAE,KAAK;oBACZ,KAAK,EACH,2EAA2E;iBAC9E,CAAC;YACJ,CAAC;QACH,CAAC,CAAA;KACF,CAAC;IACF,4BAAS,CAAC,MAAM,CAAC;QACf,WAAW,EAAE;;;;;;;;;;;;kBAYC;QACd,OAAO,EAAE,yCAAyC;QAClD,QAAQ,EAAE,mCAAmC;QAC7C,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE;YACL,eAAe;YACf,gBAAgB;YAChB,YAAY;YACZ,aAAa;YACb,WAAW;YACX,eAAe;YACf,aAAa;YACb,cAAc;YACd,oBAAoB;YACpB,qBAAqB;YACrB,eAAe;SAChB;QACD,IAAI,EAAE,IAAI;QACV,UAAU,EAAE,MAAM;QAClB,mBAAmB,EAAE,4CAAyB,CAAC,MAAM;KACtD,CAAC;CACH,CAAC;AAMF,SAAgB,sBAAsB,CAAC,IAAsB;IAC3D,IAAI,IAAI,CAAC,IAAI,KAAK,0BAAiB,CAAC,WAAW,EAAE,CAAC;QAChD,OAAO,mBAAmB,IAAI,CAAC,WAAW,EAAE,CAAC;IAC/C,CAAC;IACD,OAAO,UAAU,IAAI,CAAC,YAAY,EAAE,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { HttpMethod } from '@activepieces/pieces-common';
|
|
2
|
+
import { KlaviyoAuthValue } from './auth';
|
|
3
|
+
export declare function fetchProfilesByIds(auth: KlaviyoAuthValue, ids: string[]): Promise<Map<string, Record<string, unknown>>>;
|
|
4
|
+
export declare const BASE_URL = "https://a.klaviyo.com/api";
|
|
5
|
+
export declare function makeRequest(auth: KlaviyoAuthValue, method: HttpMethod, path: string, body?: unknown): Promise<any>;
|
|
6
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAA0B,MAAM,QAAQ,CAAC;AAElE,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,gBAAgB,EACtB,GAAG,EAAE,MAAM,EAAE,GACZ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAiB/C;AAED,eAAO,MAAM,QAAQ,8BAA8B,CAAC;AAEpD,wBAAsB,WAAW,CAC/B,IAAI,EAAE,gBAAgB,EACtB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,gBAwCf"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BASE_URL = void 0;
|
|
4
|
+
exports.fetchProfilesByIds = fetchProfilesByIds;
|
|
5
|
+
exports.makeRequest = makeRequest;
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
8
|
+
const auth_1 = require("./auth");
|
|
9
|
+
function fetchProfilesByIds(auth, ids) {
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
var _a;
|
|
12
|
+
const CHUNK_SIZE = 100;
|
|
13
|
+
const profileMap = new Map();
|
|
14
|
+
for (let i = 0; i < ids.length; i += CHUNK_SIZE) {
|
|
15
|
+
const chunk = ids.slice(i, i + CHUNK_SIZE);
|
|
16
|
+
const params = new URLSearchParams();
|
|
17
|
+
params.set('filter', `any(id,${JSON.stringify(chunk)})`);
|
|
18
|
+
params.set('page[size]', String(CHUNK_SIZE));
|
|
19
|
+
const response = yield makeRequest(auth, pieces_common_1.HttpMethod.GET, `/profiles?${params.toString()}`);
|
|
20
|
+
for (const profile of (_a = response.data) !== null && _a !== void 0 ? _a : []) {
|
|
21
|
+
profileMap.set(profile.id, profile.attributes);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return profileMap;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.BASE_URL = `https://a.klaviyo.com/api`;
|
|
28
|
+
function makeRequest(auth, method, path, body) {
|
|
29
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
31
|
+
try {
|
|
32
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
33
|
+
method,
|
|
34
|
+
url: `${exports.BASE_URL}${path}`,
|
|
35
|
+
headers: {
|
|
36
|
+
Authorization: (0, auth_1.getAuthorizationHeader)(auth),
|
|
37
|
+
accept: 'application/vnd.api+json',
|
|
38
|
+
'content-type': 'application/vnd.api+json',
|
|
39
|
+
revision: '2025-04-15',
|
|
40
|
+
},
|
|
41
|
+
body,
|
|
42
|
+
});
|
|
43
|
+
return response.body;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401 || ((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) === 403) {
|
|
47
|
+
throw new Error('Authentication failed. Please check your API key or access token.');
|
|
48
|
+
}
|
|
49
|
+
if (((_c = error.response) === null || _c === void 0 ? void 0 : _c.status) === 429) {
|
|
50
|
+
throw new Error('Rate limit exceeded. Please wait and try again.');
|
|
51
|
+
}
|
|
52
|
+
if (((_d = error.response) === null || _d === void 0 ? void 0 : _d.status) >= 400 && ((_e = error.response) === null || _e === void 0 ? void 0 : _e.status) < 500) {
|
|
53
|
+
throw new Error(`Client error: ${((_g = (_f = error.response) === null || _f === void 0 ? void 0 : _f.body) === null || _g === void 0 ? void 0 : _g.message) || JSON.stringify((_h = error.response) === null || _h === void 0 ? void 0 : _h.body)}`);
|
|
54
|
+
}
|
|
55
|
+
if (((_j = error.response) === null || _j === void 0 ? void 0 : _j.status) >= 500) {
|
|
56
|
+
throw new Error('Server error from Klaviyo API. Please try again later.');
|
|
57
|
+
}
|
|
58
|
+
throw new Error(`Unexpected error: ${error.message || String(error)}`);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/lib/common/client.ts"],"names":[],"mappings":";;;AAGA,gDAoBC;AAID,kCA4CC;;AAvED,+DAAqE;AACrE,iCAAkE;AAElE,SAAsB,kBAAkB,CACtC,IAAsB,EACtB,GAAa;;;QAEb,MAAM,UAAU,GAAG,GAAG,CAAC;QACvB,MAAM,UAAU,GAAG,IAAI,GAAG,EAAmC,CAAC;QAE9D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,UAAU,EAAE,CAAC;YAChD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC;YAC3C,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;YACrC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAU,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACzD,MAAM,CAAC,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;YAE7C,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,IAAI,EAAE,0BAAU,CAAC,GAAG,EAAE,aAAa,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAC3F,KAAK,MAAM,OAAO,IAAI,MAAC,QAAQ,CAAC,IAAc,mCAAI,EAAE,EAAE,CAAC;gBACrD,UAAU,CAAC,GAAG,CAAC,OA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I,IAAI,CAAC,SAAS,CAAC,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAI,CACtE,EAAE,CACH,CAAC;YACJ,CAAC;YAED,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,KAAI,GAAG,EAAE,CAAC;gBAClC,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;YAC5E,CAAC;YAED,MAAM,IAAI,KAAK,CAAC,qBAAqB,KAAK,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const profileIdDropdown: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>)[]>;
|
|
2
|
+
export declare const profileIdsMultiSelectDropdown: import("@activepieces/pieces-framework").MultiSelectDropdownProperty<string, true, (import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>)[]>;
|
|
3
|
+
export declare const listIdDropdown: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>)[]>;
|
|
4
|
+
export declare const countryCode: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
5
|
+
//# sourceMappingURL=props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/props.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,iBAAiB,gQAmC5B,CAAC;AAEH,eAAO,MAAM,6BAA6B,2QAqCxC,CAAC;AAEH,eAAO,MAAM,cAAc,gQAiCzB,CAAC;AAEH,eAAO,MAAM,WAAW,mEAKtB,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.countryCode = exports.listIdDropdown = exports.profileIdsMultiSelectDropdown = exports.profileIdDropdown = 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 auth_1 = require("./auth");
|
|
8
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
9
|
+
exports.profileIdDropdown = pieces_framework_1.Property.Dropdown({
|
|
10
|
+
displayName: 'Profile Id',
|
|
11
|
+
required: true,
|
|
12
|
+
auth: auth_1.klaviyoAuth,
|
|
13
|
+
refreshers: ['auth'],
|
|
14
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
15
|
+
if (!auth) {
|
|
16
|
+
return {
|
|
17
|
+
disabled: true,
|
|
18
|
+
placeholder: 'Connect your account',
|
|
19
|
+
options: [],
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const profiles = yield (0, client_1.makeRequest)(auth, pieces_common_1.HttpMethod.GET, '/profiles', {});
|
|
23
|
+
const options = profiles.data.map((field) => {
|
|
24
|
+
const firstName = field.attributes.first_name || '';
|
|
25
|
+
const lastName = field.attributes.last_name || '';
|
|
26
|
+
const label = [firstName, lastName].filter(Boolean).join(' ');
|
|
27
|
+
return {
|
|
28
|
+
label: label || field.attributes.email || field.id,
|
|
29
|
+
value: field.id,
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
disabled: false,
|
|
34
|
+
options: options,
|
|
35
|
+
};
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
exports.profileIdsMultiSelectDropdown = pieces_framework_1.Property.MultiSelectDropdown({
|
|
39
|
+
displayName: 'Profile Ids',
|
|
40
|
+
description: 'Select one or more Klaviyo profiles',
|
|
41
|
+
required: true,
|
|
42
|
+
auth: auth_1.klaviyoAuth,
|
|
43
|
+
refreshers: ['auth', 'list_id'],
|
|
44
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, list_id }) {
|
|
45
|
+
if (!auth || !list_id) {
|
|
46
|
+
return {
|
|
47
|
+
disabled: true,
|
|
48
|
+
placeholder: 'Connect your account',
|
|
49
|
+
options: [],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const profiles = yield (0, client_1.makeRequest)(auth, pieces_common_1.HttpMethod.GET, `/lists/${list_id}/profiles`);
|
|
53
|
+
const options = profiles.data.map((field) => {
|
|
54
|
+
const firstName = field.attributes.first_name || '';
|
|
55
|
+
const lastName = field.attributes.last_name || '';
|
|
56
|
+
const email = field.attributes.email || '';
|
|
57
|
+
const label = [firstName, lastName].filter(Boolean).join(' ') +
|
|
58
|
+
(email ? ` (${email})` : '');
|
|
59
|
+
return {
|
|
60
|
+
label: label || field.id,
|
|
61
|
+
value: field.id,
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
options,
|
|
66
|
+
};
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
69
|
+
exports.listIdDropdown = pieces_framework_1.Property.Dropdown({
|
|
70
|
+
displayName: 'List Id',
|
|
71
|
+
required: true,
|
|
72
|
+
auth: auth_1.klaviyoAuth,
|
|
73
|
+
refreshers: ['auth'],
|
|
74
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
75
|
+
if (!auth) {
|
|
76
|
+
return {
|
|
77
|
+
disabled: true,
|
|
78
|
+
placeholder: 'Connect your account',
|
|
79
|
+
options: [],
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const list = yield (0, client_1.makeRequest)(auth, pieces_common_1.HttpMethod.GET, '/lists', {});
|
|
83
|
+
const options = list.data.map((field) => {
|
|
84
|
+
return {
|
|
85
|
+
label: field.attributes.name || field.id,
|
|
86
|
+
value: field.id,
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
return {
|
|
90
|
+
disabled: false,
|
|
91
|
+
options: options,
|
|
92
|
+
};
|
|
93
|
+
}),
|
|
94
|
+
});
|
|
95
|
+
exports.countryCode = pieces_framework_1.Property.ShortText({
|
|
96
|
+
displayName: 'Country Code',
|
|
97
|
+
description: 'Enter 2-letter ISO country code. Popular: US, GB, CA, DE, FR, AU, JP, CN, IN, BR',
|
|
98
|
+
required: false,
|
|
99
|
+
});
|
|
100
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../../src/lib/common/props.ts"],"names":[],"mappings":";;;;AAAA,qEAA0D;AAC1D,qCAAuC;AACvC,iCAAuD;AACvD,+DAAyD;AAkB5C,QAAA,iBAAiB,GAAG,2BAAQ,CAAC,QAAQ,CAAC;IACjD,WAAW,EAAE,YAAY;IACzB,QAAQ,EAAE,IAAI;IACd,IAAI,EAAE,kBAAW;IACjB,UAAU,EAAE,CAAC,MAAM,CAAC;IACpB,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACtB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO;gBACL,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,sBAAsB;gBACnC,OAAO,EAAE,EAAE;aACZ,CAAC;QACJ,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAW,EAChC,IAAwB,EACxB,0BAAU,CAAC,GAAG,EACd,WAAW,EACX,EAAE,CACH,CAAC;QAEF,MAAM,OAAO,GAAI,QAAQ,CAAC,IAAyB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YAChE,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,UAAU,IAAI,EAAE,CAAC;YACpD,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CA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;YACf,OAAO,EAAE,OAAO;SACjB,CAAC;IACJ,CAAC,CAAA;CACF,CAAC,CAAC;AAEU,QAAA,WAAW,GAAG,2BAAQ,CAAC,SAAS,CAAC;IAC5C,WAAW,EAAE,cAAc;IAC3B,WAAW,EACT,kFAAkF;IACpF,QAAQ,EAAE,KAAK;CAChB,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const newProfileTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, (import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>)[], {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, (import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>)[], {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, (import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>)[], {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, (import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>)[], {}>;
|
|
3
|
+
//# sourceMappingURL=new-profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-profile.d.ts","sourceRoot":"","sources":["../../../../src/lib/triggers/new-profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAChB,MAAM,gCAAgC,CAAC;AAmHxC,eAAO,MAAM,iBAAiB,kiCA+D5B,CAAC"}
|