@segment/action-destinations 3.232.0 → 3.233.0
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/dist/destinations/klaviyo/addProfileToList/generated-types.d.ts +1 -0
- package/dist/destinations/klaviyo/addProfileToList/index.js +8 -1
- package/dist/destinations/klaviyo/addProfileToList/index.js.map +1 -1
- package/dist/destinations/klaviyo/functions.d.ts +2 -2
- package/dist/destinations/klaviyo/functions.js +26 -24
- package/dist/destinations/klaviyo/functions.js.map +1 -1
- package/dist/destinations/klaviyo/properties.d.ts +1 -0
- package/dist/destinations/klaviyo/properties.js +7 -1
- package/dist/destinations/klaviyo/properties.js.map +1 -1
- package/dist/destinations/klaviyo/removeProfileFromList/generated-types.d.ts +1 -0
- package/dist/destinations/klaviyo/removeProfileFromList/index.js +14 -6
- package/dist/destinations/klaviyo/removeProfileFromList/index.js.map +1 -1
- package/dist/destinations/klaviyo/types.d.ts +7 -0
- package/package.json +2 -2
|
@@ -10,7 +10,8 @@ const action = {
|
|
|
10
10
|
fields: {
|
|
11
11
|
email: { ...properties_1.email },
|
|
12
12
|
list_id: { ...properties_1.list_id },
|
|
13
|
-
external_id: { ...properties_1.external_id }
|
|
13
|
+
external_id: { ...properties_1.external_id },
|
|
14
|
+
enable_batching: { ...properties_1.enable_batching }
|
|
14
15
|
},
|
|
15
16
|
perform: async (request, { payload }) => {
|
|
16
17
|
const { email, list_id, external_id } = payload;
|
|
@@ -19,6 +20,12 @@ const action = {
|
|
|
19
20
|
}
|
|
20
21
|
const profileId = await functions_1.createProfile(request, email, external_id);
|
|
21
22
|
return await functions_1.addProfileToList(request, profileId, list_id);
|
|
23
|
+
},
|
|
24
|
+
performBatch: async (request, { payload }) => {
|
|
25
|
+
payload = payload.filter((profile) => profile.email || profile.external_id);
|
|
26
|
+
const listId = payload[0]?.list_id;
|
|
27
|
+
const importJobPayload = functions_1.createImportJobPayload(payload, listId);
|
|
28
|
+
return functions_1.sendImportJobRequest(request, importJobPayload);
|
|
22
29
|
}
|
|
23
30
|
};
|
|
24
31
|
exports.default = action;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/klaviyo/addProfileToList/index.ts"],"names":[],"mappings":";;AAAA,wDAAgF;AAGhF,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/klaviyo/addProfileToList/index.ts"],"names":[],"mappings":";;AAAA,wDAAgF;AAGhF,4CAA4G;AAC5G,8CAA4E;AAE5E,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,qBAAqB;IAC5B,WAAW,EAAE,qBAAqB;IAClC,mBAAmB,EAAE,4BAA4B;IACjD,MAAM,EAAE;QACN,KAAK,EAAE,EAAE,GAAG,kBAAK,EAAE;QACnB,OAAO,EAAE,EAAE,GAAG,oBAAO,EAAE;QACvB,WAAW,EAAE,EAAE,GAAG,wBAAW,EAAE;QAC/B,eAAe,EAAE,EAAE,GAAG,4BAAe,EAAE;KACxC;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACtC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,CAAA;QAC/C,IAAI,CAAC,KAAK,IAAI,CAAC,WAAW,EAAE;YAC1B,MAAM,IAAI,qCAAsB,CAAC,yCAAyC,CAAC,CAAA;SAC5E;QACD,MAAM,SAAS,GAAG,MAAM,yBAAa,CAAC,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC,CAAA;QAClE,OAAO,MAAM,4BAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;IAC5D,CAAC;IACD,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAE3C,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,WAAW,CAAC,CAAA;QAC3E,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAA;QAClC,MAAM,gBAAgB,GAAG,kCAAsB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;QAChE,OAAO,gCAAoB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;IACxD,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -3,8 +3,7 @@ import { ImportJobPayload } from './types';
|
|
|
3
3
|
import { Payload } from './upsertProfile/generated-types';
|
|
4
4
|
export declare function getListIdDynamicData(request: RequestClient): Promise<DynamicFieldResponse>;
|
|
5
5
|
export declare function addProfileToList(request: RequestClient, id: string, list_id: string | undefined): Promise<import("@segment/actions-core").ModifiedResponse<unknown>>;
|
|
6
|
-
export declare function removeProfileFromList(request: RequestClient,
|
|
7
|
-
export declare function getProfile(request: RequestClient, email: string | undefined, external_id: string | undefined): Promise<any>;
|
|
6
|
+
export declare function removeProfileFromList(request: RequestClient, ids: string[], list_id: string): Promise<import("@segment/actions-core").ModifiedResponse<unknown>>;
|
|
8
7
|
export declare function createProfile(request: RequestClient, email: string | undefined, external_id: string | undefined): Promise<any>;
|
|
9
8
|
export declare function buildHeaders(authKey: string): {
|
|
10
9
|
Authorization: string;
|
|
@@ -18,3 +17,4 @@ export declare const createImportJobPayload: (profiles: Payload[], listId?: stri
|
|
|
18
17
|
export declare const sendImportJobRequest: (request: RequestClient, importJobPayload: {
|
|
19
18
|
data: ImportJobPayload;
|
|
20
19
|
}) => Promise<import("@segment/actions-core").ModifiedResponse<unknown>>;
|
|
20
|
+
export declare function getProfiles(request: RequestClient, emails: string[] | undefined, external_ids: string[] | undefined): Promise<string[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getProfiles = exports.sendImportJobRequest = exports.createImportJobPayload = exports.buildHeaders = exports.createProfile = exports.removeProfileFromList = exports.addProfileToList = exports.getListIdDynamicData = void 0;
|
|
4
4
|
const config_1 = require("./config");
|
|
5
5
|
async function getListIdDynamicData(request) {
|
|
6
6
|
try {
|
|
@@ -42,36 +42,17 @@ async function addProfileToList(request, id, list_id) {
|
|
|
42
42
|
return list;
|
|
43
43
|
}
|
|
44
44
|
exports.addProfileToList = addProfileToList;
|
|
45
|
-
async function removeProfileFromList(request,
|
|
45
|
+
async function removeProfileFromList(request, ids, list_id) {
|
|
46
46
|
const listData = {
|
|
47
|
-
data:
|
|
48
|
-
{
|
|
49
|
-
type: 'profile',
|
|
50
|
-
id: id
|
|
51
|
-
}
|
|
52
|
-
]
|
|
47
|
+
data: ids.map((id) => ({ type: 'profile', id }))
|
|
53
48
|
};
|
|
54
|
-
const
|
|
49
|
+
const response = await request(`${config_1.API_URL}/lists/${list_id}/relationships/profiles/`, {
|
|
55
50
|
method: 'DELETE',
|
|
56
51
|
json: listData
|
|
57
52
|
});
|
|
58
|
-
return
|
|
53
|
+
return response;
|
|
59
54
|
}
|
|
60
55
|
exports.removeProfileFromList = removeProfileFromList;
|
|
61
|
-
async function getProfile(request, email, external_id) {
|
|
62
|
-
let filter;
|
|
63
|
-
if (external_id) {
|
|
64
|
-
filter = `external_id,"${external_id}"`;
|
|
65
|
-
}
|
|
66
|
-
if (email) {
|
|
67
|
-
filter = `email,"${email}"`;
|
|
68
|
-
}
|
|
69
|
-
const profile = await request(`${config_1.API_URL}/profiles/?filter=equals(${filter})`, {
|
|
70
|
-
method: 'GET'
|
|
71
|
-
});
|
|
72
|
-
return profile.json();
|
|
73
|
-
}
|
|
74
|
-
exports.getProfile = getProfile;
|
|
75
56
|
async function createProfile(request, email, external_id) {
|
|
76
57
|
try {
|
|
77
58
|
const profileData = {
|
|
@@ -141,4 +122,25 @@ const sendImportJobRequest = async (request, importJobPayload) => {
|
|
|
141
122
|
});
|
|
142
123
|
};
|
|
143
124
|
exports.sendImportJobRequest = sendImportJobRequest;
|
|
125
|
+
async function getProfiles(request, emails, external_ids) {
|
|
126
|
+
const profileIds = [];
|
|
127
|
+
if (external_ids?.length) {
|
|
128
|
+
const filterId = `external_id,["${external_ids.join('","')}"]`;
|
|
129
|
+
const response = await request(`${config_1.API_URL}/profiles/?filter=any(${filterId})`, {
|
|
130
|
+
method: 'GET'
|
|
131
|
+
});
|
|
132
|
+
const data = await response.json();
|
|
133
|
+
profileIds.push(...data.data.map((profile) => profile.id));
|
|
134
|
+
}
|
|
135
|
+
if (emails?.length) {
|
|
136
|
+
const filterEmail = `email,["${emails.join('","')}"]`;
|
|
137
|
+
const response = await request(`${config_1.API_URL}/profiles/?filter=any(${filterEmail})`, {
|
|
138
|
+
method: 'GET'
|
|
139
|
+
});
|
|
140
|
+
const data = await response.json();
|
|
141
|
+
profileIds.push(...data.data.map((profile) => profile.id));
|
|
142
|
+
}
|
|
143
|
+
return Array.from(new Set(profileIds));
|
|
144
|
+
}
|
|
145
|
+
exports.getProfiles = getProfiles;
|
|
144
146
|
//# sourceMappingURL=functions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/destinations/klaviyo/functions.ts"],"names":[],"mappings":";;;AACA,qCAAiD;
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/destinations/klaviyo/functions.ts"],"names":[],"mappings":";;;AACA,qCAAiD;AAY1C,KAAK,UAAU,oBAAoB,CAAC,OAAsB;IAC/D,IAAI;QACF,MAAM,MAAM,GAAmB,MAAM,OAAO,CAAC,GAAG,gBAAO,SAAS,EAAE;YAChE,MAAM,EAAE,KAAK;SACd,CAAC,CAAA;QACF,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAkD,EAAE,EAAE;YACzG,OAAO,EAAE,KAAK,EAAE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,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAA;QACrD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,gBAAO,yBAAyB,WAAW,GAAG,EAAE;YAChF,MAAM,EAAE,KAAK;SACd,CAAC,CAAA;QACF,MAAM,IAAI,GAAuB,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QACtD,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAA;KACpE;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAA;AACxC,CAAC;AA1BD,kCA0BC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.external_id = exports.email = exports.list_id = void 0;
|
|
3
|
+
exports.enable_batching = exports.external_id = exports.email = exports.list_id = void 0;
|
|
4
4
|
exports.list_id = {
|
|
5
5
|
label: 'List Id',
|
|
6
6
|
description: `'Insert the ID of the default list that you'd like to subscribe users to when you call .identify().'`,
|
|
@@ -25,4 +25,10 @@ exports.external_id = {
|
|
|
25
25
|
description: `A unique identifier used by customers to associate Klaviyo profiles with profiles in an external system. One of External ID and Email required.`,
|
|
26
26
|
type: 'string'
|
|
27
27
|
};
|
|
28
|
+
exports.enable_batching = {
|
|
29
|
+
type: 'boolean',
|
|
30
|
+
label: 'Batch Data to Klaviyo',
|
|
31
|
+
description: 'When enabled, the action will use the klaviyo batch API.',
|
|
32
|
+
default: true
|
|
33
|
+
};
|
|
28
34
|
//# sourceMappingURL=properties.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"properties.js","sourceRoot":"","sources":["../../../src/destinations/klaviyo/properties.ts"],"names":[],"mappings":";;;AAEa,QAAA,OAAO,GAAe;IACjC,KAAK,EAAE,SAAS;IAChB,WAAW,EAAE,sGAAsG;IACnH,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE;QACP,OAAO,EAAE,yCAAyC;KACnD;IACD,aAAa,EAAE,IAAI;IACnB,QAAQ,EAAE,IAAI;CACf,CAAA;AAEY,QAAA,KAAK,GAAe;IAC/B,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,qCAAqC;IAClD,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE;QACP,OAAO,EAAE,wBAAwB;KAClC;IACD,QAAQ,EAAE,IAAI;CACf,CAAA;AAEY,QAAA,WAAW,GAAe;IACrC,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,iJAAiJ;IAC9J,IAAI,EAAE,QAAQ;CACf,CAAA"}
|
|
1
|
+
{"version":3,"file":"properties.js","sourceRoot":"","sources":["../../../src/destinations/klaviyo/properties.ts"],"names":[],"mappings":";;;AAEa,QAAA,OAAO,GAAe;IACjC,KAAK,EAAE,SAAS;IAChB,WAAW,EAAE,sGAAsG;IACnH,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE;QACP,OAAO,EAAE,yCAAyC;KACnD;IACD,aAAa,EAAE,IAAI;IACnB,QAAQ,EAAE,IAAI;CACf,CAAA;AAEY,QAAA,KAAK,GAAe;IAC/B,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,qCAAqC;IAClD,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE;QACP,OAAO,EAAE,wBAAwB;KAClC;IACD,QAAQ,EAAE,IAAI;CACf,CAAA;AAEY,QAAA,WAAW,GAAe;IACrC,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,iJAAiJ;IAC9J,IAAI,EAAE,QAAQ;CACf,CAAA;AAEY,QAAA,eAAe,GAAe;IACzC,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,uBAAuB;IAC9B,WAAW,EAAE,0DAA0D;IACvE,OAAO,EAAE,IAAI;CACd,CAAA"}
|
|
@@ -10,18 +10,26 @@ const action = {
|
|
|
10
10
|
fields: {
|
|
11
11
|
email: { ...properties_1.email },
|
|
12
12
|
external_id: { ...properties_1.external_id },
|
|
13
|
-
list_id: { ...properties_1.list_id }
|
|
13
|
+
list_id: { ...properties_1.list_id },
|
|
14
|
+
enable_batching: { ...properties_1.enable_batching }
|
|
14
15
|
},
|
|
15
16
|
perform: async (request, { payload }) => {
|
|
16
17
|
const { email, list_id, external_id } = payload;
|
|
17
18
|
if (!email && !external_id) {
|
|
18
19
|
throw new actions_core_1.PayloadValidationError('Missing Email or External Id');
|
|
19
20
|
}
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
const profileIds = await functions_1.getProfiles(request, email ? [email] : undefined, external_id ? [external_id] : undefined);
|
|
22
|
+
return await functions_1.removeProfileFromList(request, profileIds, list_id);
|
|
23
|
+
},
|
|
24
|
+
performBatch: async (request, { payload }) => {
|
|
25
|
+
const filteredPayload = payload.filter((profile) => profile.email || profile.external_id);
|
|
26
|
+
const listId = filteredPayload[0]?.list_id;
|
|
27
|
+
const emails = filteredPayload.map((profile) => profile.email).filter((email) => email);
|
|
28
|
+
const externalIds = filteredPayload
|
|
29
|
+
.map((profile) => profile.external_id)
|
|
30
|
+
.filter((external_id) => external_id);
|
|
31
|
+
const profileIds = await functions_1.getProfiles(request, emails, externalIds);
|
|
32
|
+
return await functions_1.removeProfileFromList(request, profileIds, listId);
|
|
25
33
|
}
|
|
26
34
|
};
|
|
27
35
|
exports.default = action;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/klaviyo/removeProfileFromList/index.ts"],"names":[],"mappings":";;AAAA,wDAAgF;AAIhF,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/klaviyo/removeProfileFromList/index.ts"],"names":[],"mappings":";;AAAA,wDAAgF;AAIhF,4CAAiE;AACjE,8CAA4E;AAE5E,MAAM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AC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAa,CAAA;QACnG,MAAM,WAAW,GAAG,eAAe;aAChC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC;aACrC,MAAM,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAa,CAAA;QAEnD,MAAM,UAAU,GAAG,MAAM,uBAAW,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAA;QAClE,OAAO,MAAM,iCAAqB,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,CAAA;IACjE,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segment/action-destinations",
|
|
3
3
|
"description": "Destination Actions engine and definitions.",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.233.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/segmentio/action-destinations",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"__tests__/__helpers__/"
|
|
86
86
|
]
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "418550fb74af1c8117995e49b87bf90803b9133a"
|
|
89
89
|
}
|