@segment/action-destinations 3.227.4-staging.1 → 3.227.4-staging.2
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/linkedin-conversions/api/api.test.d.ts +1 -0
- package/dist/destinations/linkedin-conversions/api/api.test.js +220 -0
- package/dist/destinations/linkedin-conversions/api/api.test.js.map +1 -0
- package/dist/destinations/marketo-static-lists/addToList/generated-types.d.ts +5 -0
- package/dist/destinations/marketo-static-lists/addToList/index.js +16 -4
- package/dist/destinations/marketo-static-lists/addToList/index.js.map +1 -1
- package/dist/destinations/marketo-static-lists/constants.d.ts +41 -2
- package/dist/destinations/marketo-static-lists/constants.js +11 -2
- package/dist/destinations/marketo-static-lists/constants.js.map +1 -1
- package/dist/destinations/marketo-static-lists/functions.d.ts +7 -0
- package/dist/destinations/marketo-static-lists/functions.js +71 -0
- package/dist/destinations/marketo-static-lists/functions.js.map +1 -0
- package/dist/destinations/marketo-static-lists/index.js +38 -22
- package/dist/destinations/marketo-static-lists/index.js.map +1 -1
- package/dist/destinations/marketo-static-lists/properties.d.ts +6 -0
- package/dist/destinations/marketo-static-lists/properties.js +49 -0
- package/dist/destinations/marketo-static-lists/properties.js.map +1 -0
- package/dist/destinations/marketo-static-lists/removeFromList/generated-types.d.ts +5 -0
- package/dist/destinations/marketo-static-lists/removeFromList/index.js +17 -5
- package/dist/destinations/marketo-static-lists/removeFromList/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const nock_1 = __importDefault(require("nock"));
|
|
7
|
+
const create_request_client_1 = __importDefault(require("../../../../../core/src/create-request-client"));
|
|
8
|
+
const api_1 = require("../api");
|
|
9
|
+
const constants_1 = require("../constants");
|
|
10
|
+
const requestClient = create_request_client_1.default();
|
|
11
|
+
describe('LinkedIn Conversions', () => {
|
|
12
|
+
describe('dynamicFields', () => {
|
|
13
|
+
const linkedIn = new api_1.LinkedInConversions(requestClient);
|
|
14
|
+
it('should fetch a list of ad accounts, with their names', async () => {
|
|
15
|
+
nock_1.default(`${constants_1.BASE_URL}`)
|
|
16
|
+
.get(`/adAccountUsers`)
|
|
17
|
+
.query({ q: 'authenticatedUser' })
|
|
18
|
+
.reply(200, {
|
|
19
|
+
elements: [
|
|
20
|
+
{
|
|
21
|
+
account: 'urn:li:sponsoredAccount:516413367',
|
|
22
|
+
changeAuditStamps: {
|
|
23
|
+
created: {
|
|
24
|
+
actor: 'urn:li:unknown:0',
|
|
25
|
+
time: 1500331577000
|
|
26
|
+
},
|
|
27
|
+
lastModified: {
|
|
28
|
+
actor: 'urn:li:unknown:0',
|
|
29
|
+
time: 1505328748000
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
role: 'ACCOUNT_BILLING_ADMIN',
|
|
33
|
+
user: 'urn:li:person:K1RwyVNukt',
|
|
34
|
+
version: {
|
|
35
|
+
versionTag: '89'
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
account: 'urn:li:sponsoredAccount:516880883',
|
|
40
|
+
changeAuditStamps: {
|
|
41
|
+
created: {
|
|
42
|
+
actor: 'urn:li:unknown:0',
|
|
43
|
+
time: 1505326590000
|
|
44
|
+
},
|
|
45
|
+
lastModified: {
|
|
46
|
+
actor: 'urn:li:unknown:0',
|
|
47
|
+
time: 1505326615000
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
role: 'ACCOUNT_BILLING_ADMIN',
|
|
51
|
+
user: 'urn:li:person:K1RwyVNukt',
|
|
52
|
+
version: {
|
|
53
|
+
versionTag: '3'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
paging: {
|
|
58
|
+
count: 2,
|
|
59
|
+
links: [],
|
|
60
|
+
start: 0,
|
|
61
|
+
total: 2
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const getAdAccountsRes = await linkedIn.getAdAccounts();
|
|
65
|
+
expect(getAdAccountsRes).toEqual({
|
|
66
|
+
choices: [
|
|
67
|
+
{
|
|
68
|
+
label: 'ACCOUNT_BILLING_ADMIN',
|
|
69
|
+
value: 'urn:li:sponsoredAccount:516413367'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
label: 'ACCOUNT_BILLING_ADMIN',
|
|
73
|
+
value: 'urn:li:sponsoredAccount:516880883'
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
it('should fetch a list of conversion rules', async () => {
|
|
79
|
+
const payload = {
|
|
80
|
+
adAccountId: '123456'
|
|
81
|
+
};
|
|
82
|
+
nock_1.default(`${constants_1.BASE_URL}`)
|
|
83
|
+
.get(`/conversions`)
|
|
84
|
+
.query({ q: 'account', account: payload.adAccountId })
|
|
85
|
+
.reply(200, {
|
|
86
|
+
elements: [
|
|
87
|
+
{
|
|
88
|
+
postClickAttributionWindowSize: 30,
|
|
89
|
+
viewThroughAttributionWindowSize: 7,
|
|
90
|
+
created: 1563230311551,
|
|
91
|
+
type: 'LEAD',
|
|
92
|
+
enabled: true,
|
|
93
|
+
name: 'Conversion API Segment 2',
|
|
94
|
+
lastModified: 1563230311551,
|
|
95
|
+
id: 104012,
|
|
96
|
+
attributionType: 'LAST_TOUCH_BY_CAMPAIGN',
|
|
97
|
+
conversionMethod: 'CONVERSIONS_API',
|
|
98
|
+
account: 'urn:li:sponsoredAccount:51234560'
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
postClickAttributionWindowSize: 30,
|
|
102
|
+
viewThroughAttributionWindowSize: 7,
|
|
103
|
+
created: 1563230255308,
|
|
104
|
+
type: 'PURCHASE',
|
|
105
|
+
enabled: true,
|
|
106
|
+
name: 'Conversion API Segment 3',
|
|
107
|
+
lastModified: 1563230265652,
|
|
108
|
+
id: 104004,
|
|
109
|
+
attributionType: 'LAST_TOUCH_BY_CAMPAIGN',
|
|
110
|
+
conversionMethod: 'CONVERSIONS_API',
|
|
111
|
+
account: 'urn:li:sponsoredAccount:51234560'
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
});
|
|
115
|
+
const getConversionRulesListRes = await linkedIn.getConversionRulesList(payload.adAccountId);
|
|
116
|
+
expect(getConversionRulesListRes).toEqual({
|
|
117
|
+
choices: [
|
|
118
|
+
{
|
|
119
|
+
label: 'Conversion API Segment 2',
|
|
120
|
+
value: 104012
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
label: 'Conversion API Segment 3',
|
|
124
|
+
value: 104004
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
it('should fetch a list of campaigns', async () => {
|
|
130
|
+
const payload = {
|
|
131
|
+
adAccountId: '123456'
|
|
132
|
+
};
|
|
133
|
+
nock_1.default(`${constants_1.BASE_URL}`)
|
|
134
|
+
.get(`/adAccounts/${payload.adAccountId}/adCampaigns?q=search&search=(status:(values:List(ACTIVE)))`)
|
|
135
|
+
.reply(200, {
|
|
136
|
+
paging: {
|
|
137
|
+
start: 0,
|
|
138
|
+
count: 10,
|
|
139
|
+
links: [],
|
|
140
|
+
total: 1
|
|
141
|
+
},
|
|
142
|
+
elements: [
|
|
143
|
+
{
|
|
144
|
+
test: false,
|
|
145
|
+
storyDeliveryEnabled: false,
|
|
146
|
+
format: 'TEXT_AD',
|
|
147
|
+
targetingCriteria: {
|
|
148
|
+
include: {
|
|
149
|
+
and: [
|
|
150
|
+
{
|
|
151
|
+
or: {
|
|
152
|
+
'urn:li:adTargetingFacet:locations': ['urn:li:geo:90000084']
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
or: {
|
|
157
|
+
'urn:li:adTargetingFacet:interfaceLocales': ['urn:li:locale:en_US']
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
servingStatuses: ['ACCOUNT_SERVING_HOLD'],
|
|
164
|
+
locale: {
|
|
165
|
+
country: 'US',
|
|
166
|
+
language: 'en'
|
|
167
|
+
},
|
|
168
|
+
type: 'TEXT_AD',
|
|
169
|
+
version: {
|
|
170
|
+
versionTag: '11'
|
|
171
|
+
},
|
|
172
|
+
objectiveType: 'WEBSITE_TRAFFIC',
|
|
173
|
+
associatedEntity: 'urn:li:organization:2425698',
|
|
174
|
+
optimizationTargetType: 'NONE',
|
|
175
|
+
runSchedule: {
|
|
176
|
+
start: 1498178362345
|
|
177
|
+
},
|
|
178
|
+
changeAuditStamps: {
|
|
179
|
+
created: {
|
|
180
|
+
actor: 'urn:li:unknown:0',
|
|
181
|
+
time: 1498178304000
|
|
182
|
+
},
|
|
183
|
+
lastModified: {
|
|
184
|
+
actor: 'urn:li:unknown:0',
|
|
185
|
+
time: 1698494362000
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
campaignGroup: 'urn:li:sponsoredCampaignGroup:600360846',
|
|
189
|
+
dailyBudget: {
|
|
190
|
+
currencyCode: 'USD',
|
|
191
|
+
amount: '25'
|
|
192
|
+
},
|
|
193
|
+
costType: 'CPC',
|
|
194
|
+
creativeSelection: 'OPTIMIZED',
|
|
195
|
+
unitCost: {
|
|
196
|
+
currencyCode: 'USD',
|
|
197
|
+
amount: '8.19'
|
|
198
|
+
},
|
|
199
|
+
name: 'Test',
|
|
200
|
+
offsiteDeliveryEnabled: false,
|
|
201
|
+
id: 125868226,
|
|
202
|
+
audienceExpansionEnabled: true,
|
|
203
|
+
account: 'urn:li:sponsoredAccount:507525021',
|
|
204
|
+
status: 'ACTIVE'
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
});
|
|
208
|
+
const getCampaignsListRes = await linkedIn.getCampaignsList(payload.adAccountId);
|
|
209
|
+
expect(getCampaignsListRes).toEqual({
|
|
210
|
+
choices: [
|
|
211
|
+
{
|
|
212
|
+
label: 'Test',
|
|
213
|
+
value: 125868226
|
|
214
|
+
}
|
|
215
|
+
]
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
//# sourceMappingURL=api.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.test.js","sourceRoot":"","sources":["../../../../src/destinations/linkedin-conversions/api/api.test.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;AACvB,0GAA+E;AAC/E,gCAA4C;AAC5C,4CAAuC;AAEvC,MAAM,aAAa,GAAG,+BAAmB,EAAE,CAAA;AAE3C,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;QAC7B,MAAM,QAAQ,GAAwB,IAAI,yBAAmB,CAAC,aAAa,CAAC,CAAA;QAE5E,EAAE,CAAC,sDAAsD,EAAE,KAAK,IAAI,EAAE;YACpE,cAAI,CAAC,GAAG,oBAAQ,EAAE,CAAC;iBAChB,GAAG,CAAC,iBAAiB,CAAC;iBACtB,KAAK,CAAC,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC;iBACjC,KAAK,CAAC,GAAG,EAAE;gBACV,QAAQ,EAAE;oBACR;wBACE,OAAO,EAAE,mCAAmC;wBAC5C,iBAAiB,EAAE;4BACjB,OAAO,EAAE;gCACP,KAAK,EAAE,kBAAkB;gCACzB,IAAI,EAAE,aAAa;6BACpB;4BACD,YAAY,EAAE;gCACZ,KAAK,EAAE,kBAAkB;gCACzB,IAAI,EAAE,aAAa;6BACpB;yBACF;wBACD,IAAI,EAAE,uBAAuB;wBAC7B,IAAI,EAAE,0BAA0B;wBAChC,OAAO,EAAE;4BACP,UAAU,EAAE,IAAI;yBACjB;qBACF;oBACD;wBACE,OAAO,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CAAC,CAAA;YAEJ,MAAM,mBAAmB,GAAG,MAAM,QAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;YAChF,MAAM,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAAC;gBAClC,OAAO,EAAE;oBACP;wBACE,KAAK,EAAE,MAAM;wBACb,KAAK,EAAE,SAAS;qBACjB;iBACF;aACF,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const properties_1 = require("../properties");
|
|
4
|
+
const functions_1 = require("../functions");
|
|
3
5
|
const action = {
|
|
4
6
|
title: 'Add to List',
|
|
5
|
-
description: 'Add users
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
description: 'Add users from an Engage Audience to a list in Marketo.',
|
|
8
|
+
defaultSubscription: 'event = "Audience Entered"',
|
|
9
|
+
fields: {
|
|
10
|
+
external_id: { ...properties_1.external_id },
|
|
11
|
+
email: { ...properties_1.email },
|
|
12
|
+
enable_batching: { ...properties_1.enable_batching },
|
|
13
|
+
batch_size: { ...properties_1.batch_size },
|
|
14
|
+
event_name: { ...properties_1.event_name }
|
|
15
|
+
},
|
|
16
|
+
perform: async (request, { settings, payload }) => {
|
|
17
|
+
return functions_1.addToList(request, settings, [payload]);
|
|
18
|
+
},
|
|
19
|
+
performBatch: async (request, { settings, payload }) => {
|
|
20
|
+
return functions_1.addToList(request, settings, payload);
|
|
9
21
|
}
|
|
10
22
|
};
|
|
11
23
|
exports.default = action;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/marketo-static-lists/addToList/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/marketo-static-lists/addToList/index.ts"],"names":[],"mappings":";;AAGA,8CAA2F;AAC3F,4CAAwC;AAExC,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,yDAAyD;IACtE,mBAAmB,EAAE,4BAA4B;IACjD,MAAM,EAAE;QACN,WAAW,EAAE,EAAE,GAAG,wBAAW,EAAE;QAC/B,KAAK,EAAE,EAAE,GAAG,kBAAK,EAAE;QACnB,eAAe,EAAE,EAAE,GAAG,4BAAe,EAAE;QACvC,UAAU,EAAE,EAAE,GAAG,uBAAU,EAAE;QAC7B,UAAU,EAAE,EAAE,GAAG,uBAAU,EAAE;KAC9B;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QAChD,OAAO,qBAAS,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IAChD,CAAC;IACD,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QACrD,OAAO,qBAAS,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC9C,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import { RequestClient } from '@segment/actions-core
|
|
1
|
+
import { RequestClient } from '@segment/actions-core';
|
|
2
2
|
import { Settings } from './generated-types';
|
|
3
|
+
export declare const GET_FOLDER_ENDPOINT: string;
|
|
4
|
+
export declare const CREATE_LIST_ENDPOINT: string;
|
|
5
|
+
export declare const GET_LIST_ENDPOINT: string;
|
|
6
|
+
export declare const BULK_IMPORT_ENDPOINT: string;
|
|
7
|
+
export declare const GET_LEADS_ENDPOINT: string;
|
|
8
|
+
export declare const REMOVE_USERS_ENDPOINT: string;
|
|
9
|
+
export declare const CSV_LIMIT = 10000000;
|
|
3
10
|
export interface RefreshTokenResponse {
|
|
4
11
|
access_token: string;
|
|
5
12
|
}
|
|
6
|
-
|
|
13
|
+
interface MarketoResponse {
|
|
14
|
+
requestId: string;
|
|
7
15
|
success: boolean;
|
|
8
16
|
errors: [
|
|
9
17
|
{
|
|
@@ -11,6 +19,8 @@ export interface MarketoResonse {
|
|
|
11
19
|
message: string;
|
|
12
20
|
}
|
|
13
21
|
];
|
|
22
|
+
}
|
|
23
|
+
export interface MarketoListResponse extends MarketoResponse {
|
|
14
24
|
result: [
|
|
15
25
|
{
|
|
16
26
|
name: string;
|
|
@@ -18,4 +28,33 @@ export interface MarketoResonse {
|
|
|
18
28
|
}
|
|
19
29
|
];
|
|
20
30
|
}
|
|
31
|
+
export interface MarketoBulkImportResponse extends MarketoResponse {
|
|
32
|
+
result: [
|
|
33
|
+
{
|
|
34
|
+
batchId: number;
|
|
35
|
+
importId: string;
|
|
36
|
+
status: string;
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
export interface MarketoGetLeadsResponse extends MarketoResponse {
|
|
41
|
+
result: [MarketoLeads];
|
|
42
|
+
}
|
|
43
|
+
export interface MarketoDeleteLeadsResponse extends MarketoResponse {
|
|
44
|
+
result: [
|
|
45
|
+
{
|
|
46
|
+
id: number;
|
|
47
|
+
status: string;
|
|
48
|
+
}
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
export interface MarketoLeads {
|
|
52
|
+
id: number;
|
|
53
|
+
firstName: string;
|
|
54
|
+
lastName: string;
|
|
55
|
+
email: string;
|
|
56
|
+
updatedAt: string;
|
|
57
|
+
createdAt: string;
|
|
58
|
+
}
|
|
21
59
|
export declare function getAccessToken(request: RequestClient, settings: Settings): Promise<string>;
|
|
60
|
+
export {};
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAccessToken = void 0;
|
|
3
|
+
exports.getAccessToken = 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 = void 0;
|
|
4
|
+
const API_VERSION = 'v1';
|
|
5
|
+
const OAUTH_ENDPOINT = 'identity/oauth/token';
|
|
6
|
+
exports.GET_FOLDER_ENDPOINT = `/rest/asset/${API_VERSION}/folder/byName.json?name=folderName`;
|
|
7
|
+
exports.CREATE_LIST_ENDPOINT = `/rest/asset/${API_VERSION}/staticLists.json?folder=folderId&name=listName`;
|
|
8
|
+
exports.GET_LIST_ENDPOINT = `/rest/asset/${API_VERSION}/staticList/listId.json`;
|
|
9
|
+
exports.BULK_IMPORT_ENDPOINT = `/bulk/${API_VERSION}/leads.json?format=csv&listId=externalId`;
|
|
10
|
+
exports.GET_LEADS_ENDPOINT = `/rest/${API_VERSION}/leads.json?filterType=email&filterValues=emailsToFilter`;
|
|
11
|
+
exports.REMOVE_USERS_ENDPOINT = `/rest/${API_VERSION}/lists/listId/leads.json?id=idsToDelete`;
|
|
12
|
+
exports.CSV_LIMIT = 10000000;
|
|
4
13
|
async function getAccessToken(request, settings) {
|
|
5
|
-
const res = await request(`${settings.api_endpoint}
|
|
14
|
+
const res = await request(`${settings.api_endpoint}/${OAUTH_ENDPOINT}`, {
|
|
6
15
|
method: 'POST',
|
|
7
16
|
body: new URLSearchParams({
|
|
8
17
|
client_id: settings.client_id,
|
|
@@ -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":";;;AAGA,MAAM,WAAW,GAAG,IAAI,CAAA;AACxB,MAAM,cAAc,GAAG,sBAAsB,CAAA;AAChC,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,0CAA0C,CAAA;AACrF,QAAA,kBAAkB,GAAG,SAAS,WAAW,0DAA0D,CAAA;AACnG,QAAA,qBAAqB,GAAG,SAAS,WAAW,yCAAyC,CAAA;AAErF,QAAA,SAAS,GAAG,QAAQ,CAAA;AAyD1B,KAAK,UAAU,cAAc,CAAC,OAAsB,EAAE,QAAkB;IAC7E,MAAM,GAAG,GAAG,MAAM,OAAO,CAAuB,GAAG,QAAQ,CAAC,YAAY,IAAI,cAAc,EAAE,EAAE;QAC5F,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,eAAe,CAAC;YACxB,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,aAAa,EAAE,QAAQ,CAAC,aAAa;YACrC,UAAU,EAAE,oBAAoB;SACjC,CAAC;KACH,CAAC,CAAA;IAEF,OAAO,GAAG,CAAC,IAAI,CAAC,YAAY,CAAA;AAC9B,CAAC;AAXD,wCAWC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RequestClient } from '@segment/actions-core';
|
|
2
|
+
import { Settings } from './generated-types';
|
|
3
|
+
import { Payload as AddToListPayload } from './addToList/generated-types';
|
|
4
|
+
import { Payload as RemoveFromListPayload } from './removeFromList/generated-types';
|
|
5
|
+
import { MarketoBulkImportResponse, MarketoDeleteLeadsResponse } from './constants';
|
|
6
|
+
export declare function addToList(request: RequestClient, settings: Settings, payloads: AddToListPayload[]): Promise<MarketoBulkImportResponse>;
|
|
7
|
+
export declare function removeFromList(request: RequestClient, settings: Settings, payloads: RemoveFromListPayload[]): Promise<MarketoDeleteLeadsResponse>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeFromList = exports.addToList = void 0;
|
|
4
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
async function addToList(request, settings, payloads) {
|
|
7
|
+
const csvData = extractCSV(payloads);
|
|
8
|
+
const csvSize = Buffer.byteLength(csvData, 'utf8');
|
|
9
|
+
if (csvSize > constants_1.CSV_LIMIT) {
|
|
10
|
+
throw new actions_core_1.IntegrationError(`CSV data size exceeds limit of ${constants_1.CSV_LIMIT} bytes`, 'INVALID_REQUEST_DATA', 400);
|
|
11
|
+
}
|
|
12
|
+
const url = settings.api_endpoint + constants_1.BULK_IMPORT_ENDPOINT.replace('externalId', payloads[0].external_id);
|
|
13
|
+
const response = await request(url, {
|
|
14
|
+
method: 'POST',
|
|
15
|
+
headers: {
|
|
16
|
+
'Content-Type': 'multipart/form-data; boundary=--SEGMENT-DATA--'
|
|
17
|
+
},
|
|
18
|
+
body: createFormData(csvData)
|
|
19
|
+
});
|
|
20
|
+
if (!response.data.success) {
|
|
21
|
+
throw new actions_core_1.IntegrationError(response.data.errors[0].message, 'INVALID_RESPONSE', 400);
|
|
22
|
+
}
|
|
23
|
+
return response.data;
|
|
24
|
+
}
|
|
25
|
+
exports.addToList = addToList;
|
|
26
|
+
async function removeFromList(request, settings, payloads) {
|
|
27
|
+
const emailsToRemove = extractEmails(payloads);
|
|
28
|
+
const getLeadsUrl = settings.api_endpoint + constants_1.GET_LEADS_ENDPOINT.replace('emailsToFilter', encodeURIComponent(emailsToRemove));
|
|
29
|
+
const getLeadsResponse = await request(getLeadsUrl, {
|
|
30
|
+
method: 'GET',
|
|
31
|
+
headers: {
|
|
32
|
+
'Content-Type': 'application/json'
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
if (!getLeadsResponse.data.success) {
|
|
36
|
+
throw new actions_core_1.IntegrationError(getLeadsResponse.data.errors[0].message, 'INVALID_RESPONSE', 400);
|
|
37
|
+
}
|
|
38
|
+
const leadIds = extractLeadIds(getLeadsResponse.data.result);
|
|
39
|
+
const deleteLeadsUrl = settings.api_endpoint +
|
|
40
|
+
constants_1.REMOVE_USERS_ENDPOINT.replace('listId', payloads[0].external_id).replace('idsToDelete', leadIds);
|
|
41
|
+
const deleteLeadsResponse = await request(deleteLeadsUrl, {
|
|
42
|
+
method: 'DELETE',
|
|
43
|
+
headers: {
|
|
44
|
+
'Content-Type': 'application/json'
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
if (!deleteLeadsResponse.data.success) {
|
|
48
|
+
throw new actions_core_1.IntegrationError(getLeadsResponse.data.errors[0].message, 'INVALID_RESPONSE', 400);
|
|
49
|
+
}
|
|
50
|
+
return deleteLeadsResponse.data;
|
|
51
|
+
}
|
|
52
|
+
exports.removeFromList = removeFromList;
|
|
53
|
+
function extractCSV(payloads) {
|
|
54
|
+
const header = 'Email\n';
|
|
55
|
+
const csvData = payloads.map((payload) => `${payload.email}`).join('\n');
|
|
56
|
+
return header + csvData;
|
|
57
|
+
}
|
|
58
|
+
function createFormData(csvData) {
|
|
59
|
+
const boundary = '--SEGMENT-DATA--';
|
|
60
|
+
const formData = `--${boundary}\r\nContent-Disposition: form-data; name="file"; filename="leads.csv"\r\nContent-Type: text/csv\r\n\r\n${csvData}\r\n--${boundary}--\r\n`;
|
|
61
|
+
return formData;
|
|
62
|
+
}
|
|
63
|
+
function extractEmails(payloads) {
|
|
64
|
+
const emails = payloads.map((payload) => `${payload.email}`).join(',');
|
|
65
|
+
return emails;
|
|
66
|
+
}
|
|
67
|
+
function extractLeadIds(leads) {
|
|
68
|
+
const ids = leads.map((lead) => `${lead.id}`).join(',');
|
|
69
|
+
return ids;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/destinations/marketo-static-lists/functions.ts"],"names":[],"mappings":";;;AAAA,wDAAuE;AAIvE,2CASo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AS,cAAc,CAAC,OAAe;IACrC,MAAM,QAAQ,GAAG,kBAAkB,CAAA;IACnC,MAAM,QAAQ,GAAG,KAAK,QAAQ,0GAA0G,OAAO,SAAS,QAAQ,QAAQ,CAAA;IACxK,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,SAAS,aAAa,CAAC,QAA4B;IACjD,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACtE,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAS,cAAc,CAAC,KAAqB;IAC3C,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACvD,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -57,53 +57,69 @@ const destination = {
|
|
|
57
57
|
full_audience_sync: false
|
|
58
58
|
},
|
|
59
59
|
async createAudience(request, createAudienceInput) {
|
|
60
|
-
const
|
|
60
|
+
const audienceName = createAudienceInput.audienceName;
|
|
61
61
|
const folder = createAudienceInput.settings.folder_name;
|
|
62
62
|
const endpoint = createAudienceInput.settings.api_endpoint;
|
|
63
63
|
const statsClient = createAudienceInput?.statsContext?.statsClient;
|
|
64
64
|
const statsTags = createAudienceInput?.statsContext?.tags;
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
if (!audienceName) {
|
|
66
|
+
throw new actions_core_1.IntegrationError('Missing audience name value', 'MISSING_REQUIRED_FIELD', 400);
|
|
67
|
+
}
|
|
68
|
+
const accessToken = await constants_1.getAccessToken(request, createAudienceInput.settings);
|
|
69
|
+
const getFolderUrl = endpoint + constants_1.GET_FOLDER_ENDPOINT.replace('folderName', encodeURIComponent(folder));
|
|
70
|
+
const getFolderResponse = await request(getFolderUrl, {
|
|
71
|
+
method: 'GET',
|
|
72
|
+
headers: {
|
|
73
|
+
authorization: `Bearer ${accessToken}`
|
|
74
|
+
}
|
|
67
75
|
});
|
|
68
|
-
if (!
|
|
76
|
+
if (!getFolderResponse.data.success && getFolderResponse.data.errors) {
|
|
69
77
|
statsClient?.incr('createAudience.error', 1, statsTags);
|
|
70
|
-
throw new actions_core_1.IntegrationError(`${
|
|
78
|
+
throw new actions_core_1.IntegrationError(`${getFolderResponse.data.errors[0].message}`, 'INVALID_RESPONSE', 400);
|
|
71
79
|
}
|
|
72
|
-
if (!
|
|
80
|
+
if (!getFolderResponse.data.result) {
|
|
73
81
|
statsClient?.incr('createAudience.error', 1, statsTags);
|
|
74
82
|
throw new actions_core_1.IntegrationError(`A folder with the name ${folder} not found`, 'INVALID_REQUEST_DATA', 400);
|
|
75
83
|
}
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
|
|
84
|
+
const folderId = getFolderResponse.data.result[0].id.toString();
|
|
85
|
+
const createListUrl = endpoint +
|
|
86
|
+
constants_1.CREATE_LIST_ENDPOINT.replace('folderId', folderId).replace('listName', encodeURIComponent(audienceName));
|
|
87
|
+
const createListResponse = await request(createListUrl, {
|
|
88
|
+
method: 'POST',
|
|
89
|
+
headers: {
|
|
90
|
+
authorization: `Bearer ${accessToken}`
|
|
91
|
+
}
|
|
79
92
|
});
|
|
80
|
-
if (!
|
|
93
|
+
if (!createListResponse.data.success && createListResponse.data.errors) {
|
|
81
94
|
statsClient?.incr('createAudience.error', 1, statsTags);
|
|
82
|
-
throw new actions_core_1.IntegrationError(`${
|
|
83
|
-
}
|
|
84
|
-
const external_id = create_list_response.data.result[0].id.toString();
|
|
85
|
-
if (external_id) {
|
|
86
|
-
statsClient?.incr('createAudience.success', 1, statsTags);
|
|
95
|
+
throw new actions_core_1.IntegrationError(`${createListResponse.data.errors[0].message}`, 'INVALID_RESPONSE', 400);
|
|
87
96
|
}
|
|
97
|
+
const externalId = createListResponse.data.result[0].id.toString();
|
|
98
|
+
statsClient?.incr('createAudience.success', 1, statsTags);
|
|
88
99
|
return {
|
|
89
|
-
externalId:
|
|
100
|
+
externalId: externalId
|
|
90
101
|
};
|
|
91
102
|
},
|
|
92
103
|
async getAudience(request, getAudienceInput) {
|
|
93
104
|
const endpoint = getAudienceInput.settings.api_endpoint;
|
|
94
|
-
const
|
|
105
|
+
const listId = getAudienceInput.externalId;
|
|
95
106
|
const statsClient = getAudienceInput?.statsContext?.statsClient;
|
|
96
107
|
const statsTags = getAudienceInput?.statsContext?.tags;
|
|
97
|
-
const
|
|
98
|
-
|
|
108
|
+
const accessToken = await constants_1.getAccessToken(request, getAudienceInput.settings);
|
|
109
|
+
const getListUrl = endpoint + constants_1.GET_LIST_ENDPOINT.replace('listId', listId);
|
|
110
|
+
const getListResponse = await request(getListUrl, {
|
|
111
|
+
method: 'GET',
|
|
112
|
+
headers: {
|
|
113
|
+
authorization: `Bearer ${accessToken}`
|
|
114
|
+
}
|
|
99
115
|
});
|
|
100
|
-
if (!
|
|
116
|
+
if (!getListResponse.data.success && getListResponse.data.errors) {
|
|
101
117
|
statsClient?.incr('getAudience.error', 1, statsTags);
|
|
102
|
-
throw new actions_core_1.IntegrationError(`${
|
|
118
|
+
throw new actions_core_1.IntegrationError(`${getListResponse.data.errors[0].message}`, 'INVALID_RESPONSE', 400);
|
|
103
119
|
}
|
|
104
120
|
statsClient?.incr('getAudience.success', 1, statsTags);
|
|
105
121
|
return {
|
|
106
|
-
externalId:
|
|
122
|
+
externalId: listId
|
|
107
123
|
};
|
|
108
124
|
}
|
|
109
125
|
},
|
|
@@ -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":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D,MAAM,MAAM,GAAG,gBAAgB,CAAC,UAAU,CAAA;YAC1C,MAAM,WAAW,GAAG,gBAAgB,EAAE,YAAY,EAAE,WAAW,CAAA;YAC/D,MAAM,SAAS,GAAG,gBAAgB,EAAE,YAAY,EAAE,IAAI,CAAA;YAGtD,MAAM,WAAW,GAAG,MAAM,0BAAc,CAAC,OAAO,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAA;YAE5E,MAAM,UAAU,GAAG,QAAQ,GAAG,6BAAiB,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;YAEzE,MAAM,eAAe,GAAG,MAAM,OAAO,CAAsB,UAAU,EAAE;gBACrE,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE;oBACP,aAAa,EAAE,UAAU,WAAW,EAAE;iBACvC;aACF,CAAC,CAAA;YAEF,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE;gBAChE,WAAW,EAAE,IAAI,CAAC,mBAAmB,EAAE,CAAC,EAAE,SAAS,CAAC,CAAA;gBACpD,MAAM,IAAI,+BAAgB,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,kBAAkB,EAAE,GAAG,CAAC,CAAA;aACjG;YAED,WAAW,EAAE,IAAI,CAAC,qBAAqB,EAAE,CAAC,EAAE,SAAS,CAAC,CAAA;YAEtD,OAAO;gBACL,UAAU,EAAE,MAAM;aACnB,CAAA;QACH,CAAC;KACF;IACD,OAAO,EAAE;QACP,SAAS,EAAT,mBAAS;QACT,cAAc,EAAd,wBAAc;KACf;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { InputField } from '@segment/actions-core/destination-kit/types';
|
|
2
|
+
export declare const external_id: InputField;
|
|
3
|
+
export declare const email: InputField;
|
|
4
|
+
export declare const enable_batching: InputField;
|
|
5
|
+
export declare const batch_size: InputField;
|
|
6
|
+
export declare const event_name: InputField;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.event_name = exports.batch_size = exports.enable_batching = exports.email = exports.external_id = void 0;
|
|
4
|
+
exports.external_id = {
|
|
5
|
+
label: 'External ID',
|
|
6
|
+
description: 'The ID of the Static List that users will be synced to.',
|
|
7
|
+
type: 'string',
|
|
8
|
+
default: {
|
|
9
|
+
'@path': '$.context.personas.external_audience_id'
|
|
10
|
+
},
|
|
11
|
+
unsafe_hidden: true,
|
|
12
|
+
required: true
|
|
13
|
+
};
|
|
14
|
+
exports.email = {
|
|
15
|
+
label: 'Email',
|
|
16
|
+
description: `The user's email address to send to Marketo.`,
|
|
17
|
+
type: 'string',
|
|
18
|
+
default: {
|
|
19
|
+
'@path': '$.context.traits.email'
|
|
20
|
+
},
|
|
21
|
+
readOnly: true,
|
|
22
|
+
required: true
|
|
23
|
+
};
|
|
24
|
+
exports.enable_batching = {
|
|
25
|
+
label: 'Enable Batching',
|
|
26
|
+
description: 'Enable batching of requests.',
|
|
27
|
+
type: 'boolean',
|
|
28
|
+
default: true,
|
|
29
|
+
unsafe_hidden: true,
|
|
30
|
+
required: true
|
|
31
|
+
};
|
|
32
|
+
exports.batch_size = {
|
|
33
|
+
label: 'Batch Size',
|
|
34
|
+
description: 'Maximum number of events to include in each batch. Actual batch sizes may be lower.',
|
|
35
|
+
type: 'number',
|
|
36
|
+
default: 300000,
|
|
37
|
+
required: true
|
|
38
|
+
};
|
|
39
|
+
exports.event_name = {
|
|
40
|
+
label: 'Event Name',
|
|
41
|
+
description: 'The name of the current Segment event.',
|
|
42
|
+
type: 'string',
|
|
43
|
+
default: {
|
|
44
|
+
'@path': '$.event'
|
|
45
|
+
},
|
|
46
|
+
readOnly: true,
|
|
47
|
+
required: true
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=properties.js.map
|
|
@@ -0,0 +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;IACnB,QAAQ,EAAE,IAAI;CACf,CAAA;AAEY,QAAA,KAAK,GAAe;IAC/B,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,8CAA8C;IAC3D,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE;QACP,OAAO,EAAE,wBAAwB;KAClC;IACD,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,IAAI;CACf,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;IAEf,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"}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const properties_1 = require("../properties");
|
|
4
|
+
const functions_1 = require("../functions");
|
|
3
5
|
const action = {
|
|
4
|
-
title: 'Remove
|
|
5
|
-
description: 'Remove users from a list',
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
title: 'Remove From List',
|
|
7
|
+
description: 'Remove users from a list in Marketo.',
|
|
8
|
+
defaultSubscription: 'event = "Audience Exited"',
|
|
9
|
+
fields: {
|
|
10
|
+
external_id: { ...properties_1.external_id },
|
|
11
|
+
email: { ...properties_1.email },
|
|
12
|
+
enable_batching: { ...properties_1.enable_batching },
|
|
13
|
+
batch_size: { ...properties_1.batch_size },
|
|
14
|
+
event_name: { ...properties_1.event_name }
|
|
15
|
+
},
|
|
16
|
+
perform: async (request, { settings, payload }) => {
|
|
17
|
+
return functions_1.removeFromList(request, settings, [payload]);
|
|
18
|
+
},
|
|
19
|
+
performBatch: async (request, { settings, payload }) => {
|
|
20
|
+
return functions_1.removeFromList(request, settings, payload);
|
|
9
21
|
}
|
|
10
22
|
};
|
|
11
23
|
exports.default = action;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/marketo-static-lists/removeFromList/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/marketo-static-lists/removeFromList/index.ts"],"names":[],"mappings":";;AAGA,8CAA2F;AAC3F,4CAA6C;AAE7C,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,kBAAkB;IACzB,WAAW,EAAE,sCAAsC;IACnD,mBAAmB,EAAE,2BAA2B;IAChD,MAAM,EAAE;QACN,WAAW,EAAE,EAAE,GAAG,wBAAW,EAAE;QAC/B,KAAK,EAAE,EAAE,GAAG,kBAAK,EAAE;QACnB,eAAe,EAAE,EAAE,GAAG,4BAAe,EAAE;QACvC,UAAU,EAAE,EAAE,GAAG,uBAAU,EAAE;QAC7B,UAAU,EAAE,EAAE,GAAG,uBAAU,EAAE;KAC9B;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QAChD,OAAO,0BAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IACrD,CAAC;IACD,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QACrD,OAAO,0BAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;IACnD,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.227.4-staging.
|
|
4
|
+
"version": "3.227.4-staging.2",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/segmentio/action-destinations",
|