@segment/action-destinations 3.256.0 → 3.258.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/marketo-static-lists/addToList/generated-types.d.ts +13 -4
- package/dist/destinations/marketo-static-lists/addToList/index.js +65 -4
- package/dist/destinations/marketo-static-lists/addToList/index.js.map +1 -1
- package/dist/destinations/marketo-static-lists/constants.d.ts +10 -3
- package/dist/destinations/marketo-static-lists/constants.js +2 -14
- package/dist/destinations/marketo-static-lists/constants.js.map +1 -1
- package/dist/destinations/marketo-static-lists/functions.d.ts +22 -2
- package/dist/destinations/marketo-static-lists/functions.js +91 -3
- package/dist/destinations/marketo-static-lists/functions.js.map +1 -1
- package/dist/destinations/marketo-static-lists/index.js +4 -42
- package/dist/destinations/marketo-static-lists/index.js.map +1 -1
- package/dist/destinations/marketo-static-lists/properties.js +2 -39
- package/dist/destinations/marketo-static-lists/properties.js.map +1 -1
- package/dist/destinations/marketo-static-lists/removeFromList/generated-types.d.ts +1 -1
- package/package.json +4 -4
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
export interface Payload {
|
|
2
|
-
external_id
|
|
2
|
+
external_id?: string;
|
|
3
3
|
lookup_field: string;
|
|
4
4
|
data: {
|
|
5
5
|
email?: string;
|
|
6
|
-
firstName?: string;
|
|
7
|
-
lastName?: string;
|
|
8
|
-
phone?: string;
|
|
9
6
|
[k: string]: unknown;
|
|
10
7
|
};
|
|
11
8
|
enable_batching: boolean;
|
|
12
9
|
batch_size: number;
|
|
13
10
|
event_name: string;
|
|
14
11
|
}
|
|
12
|
+
export interface HookBundle {
|
|
13
|
+
retlOnMappingSave: {
|
|
14
|
+
inputs?: {
|
|
15
|
+
list_id?: string;
|
|
16
|
+
list_name?: string;
|
|
17
|
+
};
|
|
18
|
+
outputs?: {
|
|
19
|
+
id?: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -14,13 +14,74 @@ const action = {
|
|
|
14
14
|
batch_size: { ...properties_1.batch_size },
|
|
15
15
|
event_name: { ...properties_1.event_name }
|
|
16
16
|
},
|
|
17
|
-
|
|
17
|
+
hooks: {
|
|
18
|
+
retlOnMappingSave: {
|
|
19
|
+
label: 'Connect to a static list in Marketo',
|
|
20
|
+
description: 'When saving this mapping, we will create a static list in Marketo using the fields you provided.',
|
|
21
|
+
inputFields: {
|
|
22
|
+
list_id: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
label: 'Existing List ID',
|
|
25
|
+
description: 'The ID of the Marketo Static List that users will be synced to. If defined, we will not create a new list.',
|
|
26
|
+
required: false
|
|
27
|
+
},
|
|
28
|
+
list_name: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
label: 'List Name',
|
|
31
|
+
description: 'The name of the Marketo Static List that you would like to create.',
|
|
32
|
+
required: false
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
outputTypes: {
|
|
36
|
+
id: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
label: 'ID',
|
|
39
|
+
description: 'The ID of the created Marketo Static List that users will be synced to.',
|
|
40
|
+
required: false
|
|
41
|
+
},
|
|
42
|
+
name: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
label: 'List Name',
|
|
45
|
+
description: 'The name of the created Marketo Static List that users will be synced to.',
|
|
46
|
+
required: false
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
performHook: async (request, { settings, hookInputs, statsContext }) => {
|
|
50
|
+
if (hookInputs.list_id) {
|
|
51
|
+
return functions_1.getList(request, settings, hookInputs.list_id);
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
const input = {
|
|
55
|
+
audienceName: hookInputs.list_name,
|
|
56
|
+
settings: settings
|
|
57
|
+
};
|
|
58
|
+
const listId = await functions_1.createList(request, input, statsContext);
|
|
59
|
+
return {
|
|
60
|
+
successMessage: `List '${hookInputs.list_name}' (id: ${listId}) created successfully!`,
|
|
61
|
+
savedData: {
|
|
62
|
+
id: listId,
|
|
63
|
+
name: hookInputs.list_name
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
return {
|
|
69
|
+
error: {
|
|
70
|
+
message: 'Failed to create list',
|
|
71
|
+
code: 'CREATE_LIST_FAILURE'
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
perform: async (request, { settings, payload, statsContext, hookOutputs }) => {
|
|
18
79
|
statsContext?.statsClient?.incr('addToAudience', 1, statsContext?.tags);
|
|
19
|
-
return functions_1.addToList(request, settings, [payload], statsContext);
|
|
80
|
+
return functions_1.addToList(request, settings, [payload], statsContext, hookOutputs?.retlOnMappingSave?.outputs);
|
|
20
81
|
},
|
|
21
|
-
performBatch: async (request, { settings, payload, statsContext }) => {
|
|
82
|
+
performBatch: async (request, { settings, payload, statsContext, hookOutputs }) => {
|
|
22
83
|
statsContext?.statsClient?.incr('addToAudience.batch', 1, statsContext?.tags);
|
|
23
|
-
return functions_1.addToList(request, settings, payload, statsContext);
|
|
84
|
+
return functions_1.addToList(request, settings, payload, statsContext, hookOutputs?.retlOnMappingSave?.outputs);
|
|
24
85
|
}
|
|
25
86
|
};
|
|
26
87
|
exports.default = action;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/marketo-static-lists/addToList/index.ts"],"names":[],"mappings":";;AAGA,8CAAwG;AACxG,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/marketo-static-lists/addToList/index.ts"],"names":[],"mappings":";;AAGA,8CAAwG;AACxG,4CAA6D;AAE7D,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,yDAAyD;IACtE,mBAAmB,EAAE,4BAA4B;IACjD,MAAM,EAAE;QACN,WAAW,EAA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|
1
|
+
export declare const OAUTH_ENDPOINT = "identity/oauth/token";
|
|
3
2
|
export declare const GET_FOLDER_ENDPOINT: string;
|
|
4
3
|
export declare const CREATE_LIST_ENDPOINT: string;
|
|
5
4
|
export declare const GET_LIST_ENDPOINT: string;
|
|
@@ -56,4 +55,12 @@ export interface MarketoLeads {
|
|
|
56
55
|
updatedAt: string;
|
|
57
56
|
createdAt: string;
|
|
58
57
|
}
|
|
59
|
-
export
|
|
58
|
+
export interface CreateListInput {
|
|
59
|
+
audienceName: string;
|
|
60
|
+
settings: {
|
|
61
|
+
client_id: string;
|
|
62
|
+
client_secret: string;
|
|
63
|
+
api_endpoint: string;
|
|
64
|
+
folder_name: string;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.CSV_LIMIT = exports.REMOVE_USERS_ENDPOINT = exports.GET_LEADS_ENDPOINT = exports.BULK_IMPORT_ENDPOINT = exports.GET_LIST_ENDPOINT = exports.CREATE_LIST_ENDPOINT = exports.GET_FOLDER_ENDPOINT = exports.OAUTH_ENDPOINT = void 0;
|
|
4
4
|
const API_VERSION = 'v1';
|
|
5
|
-
|
|
5
|
+
exports.OAUTH_ENDPOINT = 'identity/oauth/token';
|
|
6
6
|
exports.GET_FOLDER_ENDPOINT = `/rest/asset/${API_VERSION}/folder/byName.json?name=folderName`;
|
|
7
7
|
exports.CREATE_LIST_ENDPOINT = `/rest/asset/${API_VERSION}/staticLists.json?folder=folderId&name=listName`;
|
|
8
8
|
exports.GET_LIST_ENDPOINT = `/rest/asset/${API_VERSION}/staticList/listId.json`;
|
|
@@ -10,16 +10,4 @@ exports.BULK_IMPORT_ENDPOINT = `/bulk/${API_VERSION}/leads.json?format=csv&listI
|
|
|
10
10
|
exports.GET_LEADS_ENDPOINT = `/rest/${API_VERSION}/leads.json?filterType=field&filterValues=emailsToFilter`;
|
|
11
11
|
exports.REMOVE_USERS_ENDPOINT = `/rest/${API_VERSION}/lists/listId/leads.json?id=idsToDelete`;
|
|
12
12
|
exports.CSV_LIMIT = 10000000;
|
|
13
|
-
async function getAccessToken(request, settings) {
|
|
14
|
-
const res = await request(`${settings.api_endpoint}/${OAUTH_ENDPOINT}`, {
|
|
15
|
-
method: 'POST',
|
|
16
|
-
body: new URLSearchParams({
|
|
17
|
-
client_id: settings.client_id,
|
|
18
|
-
client_secret: settings.client_secret,
|
|
19
|
-
grant_type: 'client_credentials'
|
|
20
|
-
})
|
|
21
|
-
});
|
|
22
|
-
return res.data.access_token;
|
|
23
|
-
}
|
|
24
|
-
exports.getAccessToken = getAccessToken;
|
|
25
13
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/destinations/marketo-static-lists/constants.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/destinations/marketo-static-lists/constants.ts"],"names":[],"mappings":";;;AAAA,MAAM,WAAW,GAAG,IAAI,CAAA;AACX,QAAA,cAAc,GAAG,sBAAsB,CAAA;AACvC,QAAA,mBAAmB,GAAG,eAAe,WAAW,qCAAqC,CAAA;AACrF,QAAA,oBAAoB,GAAG,eAAe,WAAW,iDAAiD,CAAA;AAClG,QAAA,iBAAiB,GAAG,eAAe,WAAW,yBAAyB,CAAA;AACvE,QAAA,oBAAoB,GAAG,SAAS,WAAW,oEAAoE,CAAA;AAC/G,QAAA,kBAAkB,GAAG,SAAS,WAAW,0DAA0D,CAAA;AACnG,QAAA,qBAAqB,GAAG,SAAS,WAAW,yCAAyC,CAAA;AAErF,QAAA,SAAS,GAAG,QAAQ,CAAA"}
|
|
@@ -2,7 +2,27 @@ import { RequestClient, StatsContext } from '@segment/actions-core';
|
|
|
2
2
|
import { Settings } from './generated-types';
|
|
3
3
|
import { Payload as AddToListPayload } from './addToList/generated-types';
|
|
4
4
|
import { Payload as RemoveFromListPayload } from './removeFromList/generated-types';
|
|
5
|
-
import { MarketoBulkImportResponse, MarketoDeleteLeadsResponse } from './constants';
|
|
5
|
+
import { MarketoBulkImportResponse, MarketoDeleteLeadsResponse, CreateListInput } from './constants';
|
|
6
6
|
export declare function formatEndpoint(endpoint: string): string;
|
|
7
|
-
export declare function addToList(request: RequestClient, settings: Settings, payloads: AddToListPayload[], statsContext?: StatsContext
|
|
7
|
+
export declare function addToList(request: RequestClient, settings: Settings, payloads: AddToListPayload[], statsContext?: StatsContext, hookOutputs?: {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
}): Promise<MarketoBulkImportResponse>;
|
|
8
11
|
export declare function removeFromList(request: RequestClient, settings: Settings, payloads: RemoveFromListPayload[], statsContext?: StatsContext): Promise<MarketoDeleteLeadsResponse>;
|
|
12
|
+
export declare function getAccessToken(request: RequestClient, settings: Settings): Promise<string>;
|
|
13
|
+
export declare function getList(request: RequestClient, settings: Settings, id: string): Promise<{
|
|
14
|
+
error: {
|
|
15
|
+
message: string;
|
|
16
|
+
code: string;
|
|
17
|
+
};
|
|
18
|
+
successMessage?: undefined;
|
|
19
|
+
savedData?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
successMessage: string;
|
|
22
|
+
savedData: {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
26
|
+
error?: undefined;
|
|
27
|
+
}>;
|
|
28
|
+
export declare function createList(request: RequestClient, input: CreateListInput, statsContext?: StatsContext): Promise<string>;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeFromList = exports.addToList = exports.formatEndpoint = void 0;
|
|
3
|
+
exports.createList = exports.getList = exports.getAccessToken = exports.removeFromList = exports.addToList = exports.formatEndpoint = void 0;
|
|
4
4
|
const actions_core_1 = require("@segment/actions-core");
|
|
5
5
|
const constants_1 = require("./constants");
|
|
6
6
|
function formatEndpoint(endpoint) {
|
|
7
7
|
return endpoint.replace('/rest', '');
|
|
8
8
|
}
|
|
9
9
|
exports.formatEndpoint = formatEndpoint;
|
|
10
|
-
async function addToList(request, settings, payloads, statsContext) {
|
|
10
|
+
async function addToList(request, settings, payloads, statsContext, hookOutputs) {
|
|
11
|
+
const list_id = hookOutputs?.id ?? payloads[0].external_id;
|
|
12
|
+
if (!list_id) {
|
|
13
|
+
throw new actions_core_1.IntegrationError('No list ID found in payload', 'INVALID_REQUEST_DATA', 400);
|
|
14
|
+
}
|
|
11
15
|
const api_endpoint = formatEndpoint(settings.api_endpoint);
|
|
12
16
|
const csvData = formatData(payloads);
|
|
13
17
|
const csvSize = Buffer.byteLength(csvData, 'utf8');
|
|
@@ -16,7 +20,7 @@ async function addToList(request, settings, payloads, statsContext) {
|
|
|
16
20
|
throw new actions_core_1.IntegrationError(`CSV data size exceeds limit of ${constants_1.CSV_LIMIT} bytes`, 'INVALID_REQUEST_DATA', 400);
|
|
17
21
|
}
|
|
18
22
|
const url = api_endpoint +
|
|
19
|
-
constants_1.BULK_IMPORT_ENDPOINT.replace('externalId',
|
|
23
|
+
constants_1.BULK_IMPORT_ENDPOINT.replace('externalId', list_id).replace('fieldToLookup', payloads[0].lookup_field);
|
|
20
24
|
const response = await request(url, {
|
|
21
25
|
method: 'POST',
|
|
22
26
|
headers: {
|
|
@@ -33,6 +37,9 @@ async function addToList(request, settings, payloads, statsContext) {
|
|
|
33
37
|
}
|
|
34
38
|
exports.addToList = addToList;
|
|
35
39
|
async function removeFromList(request, settings, payloads, statsContext) {
|
|
40
|
+
if (!payloads[0].external_id) {
|
|
41
|
+
throw new actions_core_1.IntegrationError('No external_id found in payload', 'INVALID_REQUEST_DATA', 400);
|
|
42
|
+
}
|
|
36
43
|
const api_endpoint = formatEndpoint(settings.api_endpoint);
|
|
37
44
|
const usersToRemove = extractFilterData(payloads);
|
|
38
45
|
const getLeadsUrl = api_endpoint +
|
|
@@ -99,4 +106,85 @@ function parseErrorResponse(response) {
|
|
|
99
106
|
}
|
|
100
107
|
throw new actions_core_1.IntegrationError(response.errors[0].message, 'INVALID_RESPONSE', 400);
|
|
101
108
|
}
|
|
109
|
+
async function getAccessToken(request, settings) {
|
|
110
|
+
const api_endpoint = formatEndpoint(settings.api_endpoint);
|
|
111
|
+
const res = await request(`${api_endpoint}/${constants_1.OAUTH_ENDPOINT}`, {
|
|
112
|
+
method: 'POST',
|
|
113
|
+
body: new URLSearchParams({
|
|
114
|
+
client_id: settings.client_id,
|
|
115
|
+
client_secret: settings.client_secret,
|
|
116
|
+
grant_type: 'client_credentials'
|
|
117
|
+
})
|
|
118
|
+
});
|
|
119
|
+
return res.data.access_token;
|
|
120
|
+
}
|
|
121
|
+
exports.getAccessToken = getAccessToken;
|
|
122
|
+
async function getList(request, settings, id) {
|
|
123
|
+
const accessToken = await getAccessToken(request, settings);
|
|
124
|
+
const endpoint = formatEndpoint(settings.api_endpoint);
|
|
125
|
+
const getListUrl = endpoint + constants_1.GET_LIST_ENDPOINT.replace('listId', id);
|
|
126
|
+
const getListResponse = await request(getListUrl, {
|
|
127
|
+
method: 'GET',
|
|
128
|
+
headers: {
|
|
129
|
+
authorization: `Bearer ${accessToken}`
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
if (!getListResponse.data.success && getListResponse.data.errors) {
|
|
133
|
+
return {
|
|
134
|
+
error: {
|
|
135
|
+
message: getListResponse.data.errors[0].message,
|
|
136
|
+
code: 'LIST_ID_VERIFICATION_FAILURE'
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
successMessage: `Using existing list '${getListResponse.data.result[0].name}' (id: ${id})`,
|
|
142
|
+
savedData: {
|
|
143
|
+
id: id,
|
|
144
|
+
name: getListResponse.data.result[0].name
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
exports.getList = getList;
|
|
149
|
+
async function createList(request, input, statsContext) {
|
|
150
|
+
const statsClient = statsContext?.statsClient;
|
|
151
|
+
const statsTags = statsContext?.tags;
|
|
152
|
+
if (!input.audienceName) {
|
|
153
|
+
throw new actions_core_1.IntegrationError('Missing audience name value', 'MISSING_REQUIRED_FIELD', 400);
|
|
154
|
+
}
|
|
155
|
+
const endpoint = formatEndpoint(input.settings.api_endpoint);
|
|
156
|
+
const accessToken = await getAccessToken(request, input.settings);
|
|
157
|
+
const getFolderUrl = endpoint + constants_1.GET_FOLDER_ENDPOINT.replace('folderName', encodeURIComponent(input.settings.folder_name));
|
|
158
|
+
const getFolderResponse = await request(getFolderUrl, {
|
|
159
|
+
method: 'GET',
|
|
160
|
+
headers: {
|
|
161
|
+
authorization: `Bearer ${accessToken}`
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
if (!getFolderResponse.data.success && getFolderResponse.data.errors) {
|
|
165
|
+
statsClient?.incr('createAudience.error', 1, statsTags);
|
|
166
|
+
throw new actions_core_1.IntegrationError(`${getFolderResponse.data.errors[0].message}`, 'INVALID_RESPONSE', 400);
|
|
167
|
+
}
|
|
168
|
+
if (!getFolderResponse.data.result) {
|
|
169
|
+
statsClient?.incr('createAudience.error', 1, statsTags);
|
|
170
|
+
throw new actions_core_1.IntegrationError(`A folder with the name ${input.settings.folder_name} not found`, 'INVALID_REQUEST_DATA', 400);
|
|
171
|
+
}
|
|
172
|
+
const folderId = getFolderResponse.data.result[0].id.toString();
|
|
173
|
+
const createListUrl = endpoint +
|
|
174
|
+
constants_1.CREATE_LIST_ENDPOINT.replace('folderId', folderId).replace('listName', encodeURIComponent(input.audienceName));
|
|
175
|
+
const createListResponse = await request(createListUrl, {
|
|
176
|
+
method: 'POST',
|
|
177
|
+
headers: {
|
|
178
|
+
authorization: `Bearer ${accessToken}`
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
if (!createListResponse.data.success && createListResponse.data.errors) {
|
|
182
|
+
statsClient?.incr('createAudience.error', 1, statsTags);
|
|
183
|
+
throw new actions_core_1.IntegrationError(`${createListResponse.data.errors[0].message}`, 'INVALID_RESPONSE', 400);
|
|
184
|
+
}
|
|
185
|
+
const listId = createListResponse.data.result[0].id.toString();
|
|
186
|
+
statsClient?.incr('createAudience.success', 1, statsTags);
|
|
187
|
+
return listId;
|
|
188
|
+
}
|
|
189
|
+
exports.createList = createList;
|
|
102
190
|
//# sourceMappingURL=functions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/destinations/marketo-static-lists/functions.ts"],"names":[],"mappings":";;;AAAA,wDAAqG;AAIrG,
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/destinations/marketo-static-lists/functions.ts"],"names":[],"mappings":";;;AAAA,wDAAqG;AAIrG,2CAiBoB;AAIpB,SAAgB,cAAc,CAAC,QAAgB;IAC7C,OAAO,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;AACtC,CAAC;AAFD,wCAEC;AAEM,KAAK,UAAU,SAAS,CAC7B,OAAsB,EACtB,QAAkB,EAClB,QAA4B,EAC5B,YAA2B,EAC3B,WAA0C;IAG1C,MAAM,OAAO,GAAG,WAAW,EAAE,EAAE,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,CAAA;IAE1D,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,+BAAgB,CAAC,6BAA6B,EAAE,sBAAsB,EAAE,GAAG,CAAC,CAAA;KACvF;IAED,MAAM,YAAY,GAAG,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAA;IAE1D,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAA;IACpC,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAClD,IAAI,OAAO,GAAG,qBAAS,EAAE;QACvB,YAAY,EAAE,WAA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AC,EAAE,CAAC,QAAQ,EAAE,CAAA;IAE/D,MAAM,aAAa,GACjB,QAAQ;QACR,gCAAoB,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,kBAAkB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAA;IAGhH,MAAM,kBAAkB,GAAG,MAAM,OAAO,CAAsB,aAAa,EAAE;QAC3E,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,WAAW,EAAE;SACvC;KACF,CAAC,CAAA;IAEF,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE;QACtE,WAAW,EAAE,IAAI,CAAC,sBAAsB,EAAE,CAAC,EAAE,SAAS,CAAC,CAAA;QACvD,MAAM,IAAI,+BAAgB,CAAC,GAAG,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,kBAAkB,EAAE,GAAG,CAAC,CAAA;KACpG;IAED,MAAM,MAAM,GAAG,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAA;IAC9D,WAAW,EAAE,IAAI,CAAC,wBAAwB,EAAE,CAAC,EAAE,SAAS,CAAC,CAAA;IAEzD,OAAO,MAAM,CAAA;AACf,CAAC;AA/DD,gCA+DC"}
|
|
@@ -41,7 +41,7 @@ const destination = {
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
refreshAccessToken: async (request, { settings }) => {
|
|
44
|
-
return { accessToken: await
|
|
44
|
+
return { accessToken: await functions_1.getAccessToken(request, settings) };
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
extendRequest({ auth }) {
|
|
@@ -58,47 +58,9 @@ const destination = {
|
|
|
58
58
|
full_audience_sync: false
|
|
59
59
|
},
|
|
60
60
|
async createAudience(request, createAudienceInput) {
|
|
61
|
-
const
|
|
62
|
-
const folder = createAudienceInput.settings.folder_name;
|
|
63
|
-
const endpoint = functions_1.formatEndpoint(createAudienceInput.settings.api_endpoint);
|
|
64
|
-
const statsClient = createAudienceInput?.statsContext?.statsClient;
|
|
65
|
-
const statsTags = createAudienceInput?.statsContext?.tags;
|
|
66
|
-
if (!audienceName) {
|
|
67
|
-
throw new actions_core_1.IntegrationError('Missing audience name value', 'MISSING_REQUIRED_FIELD', 400);
|
|
68
|
-
}
|
|
69
|
-
const accessToken = await constants_1.getAccessToken(request, createAudienceInput.settings);
|
|
70
|
-
const getFolderUrl = endpoint + constants_1.GET_FOLDER_ENDPOINT.replace('folderName', encodeURIComponent(folder));
|
|
71
|
-
const getFolderResponse = await request(getFolderUrl, {
|
|
72
|
-
method: 'GET',
|
|
73
|
-
headers: {
|
|
74
|
-
authorization: `Bearer ${accessToken}`
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
if (!getFolderResponse.data.success && getFolderResponse.data.errors) {
|
|
78
|
-
statsClient?.incr('createAudience.error', 1, statsTags);
|
|
79
|
-
throw new actions_core_1.IntegrationError(`${getFolderResponse.data.errors[0].message}`, 'INVALID_RESPONSE', 400);
|
|
80
|
-
}
|
|
81
|
-
if (!getFolderResponse.data.result) {
|
|
82
|
-
statsClient?.incr('createAudience.error', 1, statsTags);
|
|
83
|
-
throw new actions_core_1.IntegrationError(`A folder with the name ${folder} not found`, 'INVALID_REQUEST_DATA', 400);
|
|
84
|
-
}
|
|
85
|
-
const folderId = getFolderResponse.data.result[0].id.toString();
|
|
86
|
-
const createListUrl = endpoint +
|
|
87
|
-
constants_1.CREATE_LIST_ENDPOINT.replace('folderId', folderId).replace('listName', encodeURIComponent(audienceName));
|
|
88
|
-
const createListResponse = await request(createListUrl, {
|
|
89
|
-
method: 'POST',
|
|
90
|
-
headers: {
|
|
91
|
-
authorization: `Bearer ${accessToken}`
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
if (!createListResponse.data.success && createListResponse.data.errors) {
|
|
95
|
-
statsClient?.incr('createAudience.error', 1, statsTags);
|
|
96
|
-
throw new actions_core_1.IntegrationError(`${createListResponse.data.errors[0].message}`, 'INVALID_RESPONSE', 400);
|
|
97
|
-
}
|
|
98
|
-
const externalId = createListResponse.data.result[0].id.toString();
|
|
99
|
-
statsClient?.incr('createAudience.success', 1, statsTags);
|
|
61
|
+
const listId = await functions_1.createList(request, createAudienceInput, createAudienceInput.statsContext);
|
|
100
62
|
return {
|
|
101
|
-
externalId:
|
|
63
|
+
externalId: listId
|
|
102
64
|
};
|
|
103
65
|
},
|
|
104
66
|
async getAudience(request, getAudienceInput) {
|
|
@@ -106,7 +68,7 @@ const destination = {
|
|
|
106
68
|
const listId = getAudienceInput.externalId;
|
|
107
69
|
const statsClient = getAudienceInput?.statsContext?.statsClient;
|
|
108
70
|
const statsTags = getAudienceInput?.statsContext?.tags;
|
|
109
|
-
const accessToken = await
|
|
71
|
+
const accessToken = await functions_1.getAccessToken(request, getAudienceInput.settings);
|
|
110
72
|
const getListUrl = endpoint + constants_1.GET_LIST_ENDPOINT.replace('listId', listId);
|
|
111
73
|
const getListResponse = await request(getListUrl, {
|
|
112
74
|
method: 'GET',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/marketo-static-lists/index.ts"],"names":[],"mappings":";;;;;AACA,wDAAwD;AAGxD,4DAAmC;AACnC,sEAA6C;AAC7C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/marketo-static-lists/index.ts"],"names":[],"mappings":";;;;;AACA,wDAAwD;AAGxD,4DAAmC;AACnC,sEAA6C;AAC7C,2CAAoE;AACpE,2CAAwE;AAExE,MAAM,WAAW,GAA4C;IAC3D,IAAI,EAAE,gCAAgC;IACtC,IAAI,EAAE,8BAA8B;IACpC,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,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{
|
|
9
9
|
'@path': '$.context.personas.external_audience_id'
|
|
10
10
|
},
|
|
11
|
-
unsafe_hidden: true
|
|
12
|
-
required: true
|
|
11
|
+
unsafe_hidden: true
|
|
13
12
|
};
|
|
14
13
|
exports.field_value = {
|
|
15
14
|
label: 'Field Value',
|
|
@@ -26,7 +25,7 @@ exports.field_value = {
|
|
|
26
25
|
};
|
|
27
26
|
exports.lookup_field = {
|
|
28
27
|
label: 'Lookup Field',
|
|
29
|
-
description: `The lead field to use for deduplication and filtering. This field must be apart of the
|
|
28
|
+
description: `The lead field to use for deduplication and filtering. This field must be apart of the Lead Info Fields below.`,
|
|
30
29
|
type: 'string',
|
|
31
30
|
choices: [
|
|
32
31
|
{ label: 'Email', value: 'email' },
|
|
@@ -53,21 +52,6 @@ exports.data = {
|
|
|
53
52
|
label: 'Email',
|
|
54
53
|
description: `The user's email address to send to Marketo.`,
|
|
55
54
|
type: 'string'
|
|
56
|
-
},
|
|
57
|
-
firstName: {
|
|
58
|
-
label: 'First Name',
|
|
59
|
-
description: `The user's first name.`,
|
|
60
|
-
type: 'string'
|
|
61
|
-
},
|
|
62
|
-
lastName: {
|
|
63
|
-
label: 'Last Name',
|
|
64
|
-
description: `The user's last name.`,
|
|
65
|
-
type: 'string'
|
|
66
|
-
},
|
|
67
|
-
phone: {
|
|
68
|
-
label: 'Phone Number',
|
|
69
|
-
description: `The user's phone number.`,
|
|
70
|
-
type: 'string'
|
|
71
55
|
}
|
|
72
56
|
},
|
|
73
57
|
default: {
|
|
@@ -77,27 +61,6 @@ exports.data = {
|
|
|
77
61
|
then: { '@path': '$.context.traits.email' },
|
|
78
62
|
else: { '@path': '$.properties.email' }
|
|
79
63
|
}
|
|
80
|
-
},
|
|
81
|
-
firstName: {
|
|
82
|
-
'@if': {
|
|
83
|
-
exists: { '@path': '$.context.traits.firstName' },
|
|
84
|
-
then: { '@path': '$.context.traits.firstName' },
|
|
85
|
-
else: { '@path': '$.properties.firstName' }
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
lastName: {
|
|
89
|
-
'@if': {
|
|
90
|
-
exists: { '@path': '$.context.traits.lastName' },
|
|
91
|
-
then: { '@path': '$.context.traits.lastName' },
|
|
92
|
-
else: { '@path': '$.properties.lastName' }
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
phone: {
|
|
96
|
-
'@if': {
|
|
97
|
-
exists: { '@path': '$.context.traits.phoneNumber' },
|
|
98
|
-
then: { '@path': '$.context.traits.phoneNumber' },
|
|
99
|
-
else: { '@path': '$.properties.phoneNumber' }
|
|
100
|
-
}
|
|
101
64
|
}
|
|
102
65
|
},
|
|
103
66
|
additionalProperties: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"properties.js","sourceRoot":"","sources":["../../../src/destinations/marketo-static-lists/properties.ts"],"names":[],"mappings":";;;AAEa,QAAA,WAAW,GAAe;IACrC,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,yDAAyD;IACtE,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE;QACP,OAAO,EAAE,yCAAyC;KACnD;IACD,aAAa,EAAE,IAAI;
|
|
1
|
+
{"version":3,"file":"properties.js","sourceRoot":"","sources":["../../../src/destinations/marketo-static-lists/properties.ts"],"names":[],"mappings":";;;AAEa,QAAA,WAAW,GAAe;IACrC,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,yDAAyD;IACtE,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE;QACP,OAAO,EAAE,yCAAyC;KACnD;IACD,aAAa,EAAE,IAAI;CACpB,CAAA;AAEY,QAAA,WAAW,GAAe;IACrC,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,8CAA8C;IAC3D,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE;QACP,KAAK,EAAE;YACL,MAAM,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;YAC7C,IAAI,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;YAC3C,IAAI,EAAE,EAA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AI,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;gBAC3C,IAAI,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;aACxC;SACF;KACF;IACD,oBAAoB,EAAE,IAAI;CAC3B,CAAA;AAEY,QAAA,eAAe,GAAe;IACzC,KAAK,EAAE,iBAAiB;IACxB,WAAW,EAAE,8BAA8B;IAC3C,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,IAAI;IACb,aAAa,EAAE,IAAI;IACnB,QAAQ,EAAE,IAAI;CACf,CAAA;AAEY,QAAA,UAAU,GAAe;IACpC,KAAK,EAAE,YAAY;IACnB,WAAW,EAAE,qFAAqF;IAClG,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,MAAM;IACf,aAAa,EAAE,IAAI;IACnB,QAAQ,EAAE,IAAI;CACf,CAAA;AAEY,QAAA,UAAU,GAAe;IACpC,KAAK,EAAE,YAAY;IACnB,WAAW,EAAE,wCAAwC;IACrD,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE;QACP,OAAO,EAAE,SAAS;KACnB;IACD,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,IAAI;CACf,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.258.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/segmentio/action-destinations",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"@bufbuild/protobuf": "^1.4.2",
|
|
44
44
|
"@bufbuild/protoc-gen-es": "^1.4.2",
|
|
45
45
|
"@segment/a1-notation": "^2.1.4",
|
|
46
|
-
"@segment/actions-core": "^3.
|
|
47
|
-
"@segment/actions-shared": "^1.
|
|
46
|
+
"@segment/actions-core": "^3.105.0",
|
|
47
|
+
"@segment/actions-shared": "^1.86.0",
|
|
48
48
|
"@types/node": "^18.11.15",
|
|
49
49
|
"ajv-formats": "^2.1.1",
|
|
50
50
|
"aws4": "^1.12.0",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"__tests__/__helpers__/"
|
|
87
87
|
]
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "d56403afbbbc1174f2873a030a8161525acd7df3"
|
|
90
90
|
}
|