@segment/action-destinations 3.229.1-test-bk-59928928.45 → 3.229.1-test-action-cli.12
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/absmartly/event.d.ts +3 -9
- package/dist/destinations/absmartly/event.js +9 -0
- package/dist/destinations/absmartly/event.js.map +1 -1
- package/dist/destinations/absmartly/exposure.d.ts +1 -1
- package/dist/destinations/absmartly/exposure.js +10 -26
- package/dist/destinations/absmartly/exposure.js.map +1 -1
- package/dist/destinations/absmartly/goal.d.ts +2 -1
- package/dist/destinations/absmartly/goal.js +18 -4
- package/dist/destinations/absmartly/goal.js.map +1 -1
- package/dist/destinations/absmartly/timestamp.d.ts +1 -1
- package/dist/destinations/absmartly/timestamp.js +0 -2
- package/dist/destinations/absmartly/timestamp.js.map +1 -1
- package/dist/destinations/absmartly/trackExposure/generated-types.d.ts +1 -0
- package/dist/destinations/absmartly/trackExposure/index.js +2 -7
- package/dist/destinations/absmartly/trackExposure/index.js.map +1 -1
- package/dist/destinations/absmartly/trackGoal/generated-types.d.ts +2 -0
- package/dist/destinations/absmartly/trackGoal/index.js +2 -7
- package/dist/destinations/absmartly/trackGoal/index.js.map +1 -1
- package/dist/destinations/blackbaud-raisers-edge-nxt/utils/index.d.ts +1 -1
- package/dist/destinations/devrev/createRevUser/index.js +1 -1
- package/dist/destinations/devrev/createRevUser/index.js.map +1 -1
- package/dist/destinations/devrev/mocks/index.d.ts +1 -1
- package/dist/destinations/devrev/mocks/index.js +1 -1
- package/dist/destinations/devrev/mocks/index.js.map +1 -1
- package/dist/destinations/display-video-360/addToAudience/generated-types.d.ts +0 -5
- package/dist/destinations/display-video-360/addToAudience/index.d.ts +2 -2
- package/dist/destinations/display-video-360/addToAudience/index.js +4 -19
- package/dist/destinations/display-video-360/addToAudience/index.js.map +1 -1
- package/dist/destinations/display-video-360/constants.d.ts +0 -2
- package/dist/destinations/display-video-360/constants.js +2 -4
- package/dist/destinations/display-video-360/constants.js.map +1 -1
- package/dist/destinations/display-video-360/generated-types.d.ts +1 -2
- package/dist/destinations/display-video-360/index.js +51 -57
- package/dist/destinations/display-video-360/index.js.map +1 -1
- package/dist/destinations/display-video-360/removeFromAudience/generated-types.d.ts +0 -5
- package/dist/destinations/display-video-360/removeFromAudience/index.d.ts +2 -2
- package/dist/destinations/display-video-360/removeFromAudience/index.js +3 -18
- package/dist/destinations/display-video-360/removeFromAudience/index.js.map +1 -1
- package/dist/destinations/engage/sendgrid/sendEmail/SendEmailPerformer.js +3 -6
- package/dist/destinations/engage/sendgrid/sendEmail/SendEmailPerformer.js.map +1 -1
- package/dist/destinations/engage/twilio/sendMobilePush/PushSender.js +1 -1
- package/dist/destinations/engage/twilio/sendMobilePush/PushSender.js.map +1 -1
- package/dist/destinations/engage/twilio/utils/PhoneMessageSender.js +1 -3
- package/dist/destinations/engage/twilio/utils/PhoneMessageSender.js.map +1 -1
- package/dist/destinations/engage/utils/track.d.ts +10 -10
- package/dist/destinations/google-enhanced-conversions/functions.d.ts +1 -1
- package/dist/destinations/google-enhanced-conversions/functions.js +1 -1
- package/dist/destinations/hyperengage/group/generated-types.d.ts +0 -1
- package/dist/destinations/hyperengage/group/index.js +2 -20
- package/dist/destinations/hyperengage/group/index.js.map +1 -1
- package/dist/destinations/hyperengage/identify/index.js +1 -7
- package/dist/destinations/hyperengage/identify/index.js.map +1 -1
- package/dist/destinations/hyperengage/track/generated-types.d.ts +1 -1
- package/dist/destinations/hyperengage/track/index.js +9 -9
- package/dist/destinations/hyperengage/track/index.js.map +1 -1
- package/dist/destinations/hyperengage/validateInput.js +2 -5
- package/dist/destinations/hyperengage/validateInput.js.map +1 -1
- package/dist/destinations/index.js +0 -1
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/insider/cartViewedEvent/generated-types.d.ts +0 -1
- package/dist/destinations/insider/cartViewedEvent/index.js +0 -1
- package/dist/destinations/insider/cartViewedEvent/index.js.map +1 -1
- package/dist/destinations/insider/checkoutEvent/generated-types.d.ts +0 -1
- package/dist/destinations/insider/checkoutEvent/index.js +0 -1
- package/dist/destinations/insider/checkoutEvent/index.js.map +1 -1
- package/dist/destinations/insider/insider-helpers.d.ts +0 -3
- package/dist/destinations/insider/insider-helpers.js +2 -7
- package/dist/destinations/insider/insider-helpers.js.map +1 -1
- package/dist/destinations/insider/insider-properties.d.ts +0 -1
- package/dist/destinations/insider/insider-properties.js +1 -7
- package/dist/destinations/insider/insider-properties.js.map +1 -1
- package/dist/destinations/insider/orderCompletedEvent/generated-types.d.ts +0 -1
- package/dist/destinations/insider/orderCompletedEvent/index.js +0 -1
- package/dist/destinations/insider/orderCompletedEvent/index.js.map +1 -1
- package/dist/destinations/insider/productAddedEvent/generated-types.d.ts +0 -1
- package/dist/destinations/insider/productAddedEvent/index.js +0 -1
- package/dist/destinations/insider/productAddedEvent/index.js.map +1 -1
- package/dist/destinations/insider/productListViewedEvent/generated-types.d.ts +0 -1
- package/dist/destinations/insider/productListViewedEvent/index.js +0 -1
- package/dist/destinations/insider/productListViewedEvent/index.js.map +1 -1
- package/dist/destinations/insider/productRemovedEvent/generated-types.d.ts +0 -1
- package/dist/destinations/insider/productRemovedEvent/index.js +0 -1
- package/dist/destinations/insider/productRemovedEvent/index.js.map +1 -1
- package/dist/destinations/insider/productViewedEvent/generated-types.d.ts +0 -1
- package/dist/destinations/insider/productViewedEvent/index.js +0 -1
- package/dist/destinations/insider/productViewedEvent/index.js.map +1 -1
- package/dist/destinations/insider/trackEvent/generated-types.d.ts +0 -1
- package/dist/destinations/insider/trackEvent/index.js +0 -1
- package/dist/destinations/insider/trackEvent/index.js.map +1 -1
- package/dist/destinations/insider/updateUserProfile/generated-types.d.ts +0 -1
- package/dist/destinations/insider/updateUserProfile/index.js +0 -2
- package/dist/destinations/insider/updateUserProfile/index.js.map +1 -1
- package/dist/destinations/insider/userRegisteredEvent/generated-types.d.ts +0 -1
- package/dist/destinations/insider/userRegisteredEvent/index.js +0 -1
- package/dist/destinations/insider/userRegisteredEvent/index.js.map +1 -1
- package/dist/destinations/insider-audiences/insider-helpers.js +0 -5
- package/dist/destinations/insider-audiences/insider-helpers.js.map +1 -1
- package/dist/destinations/insider-audiences/insiderAudiences/generated-types.d.ts +0 -1
- package/dist/destinations/insider-audiences/insiderAudiences/index.js +0 -6
- package/dist/destinations/insider-audiences/insiderAudiences/index.js.map +1 -1
- 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 +3 -19
- package/dist/destinations/klaviyo/functions.js +14 -107
- package/dist/destinations/klaviyo/functions.js.map +1 -1
- package/dist/destinations/klaviyo/index.d.ts +2 -2
- package/dist/destinations/klaviyo/index.js +7 -53
- package/dist/destinations/klaviyo/index.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 +0 -52
- package/dist/destinations/klaviyo/types.js.map +1 -1
- package/dist/destinations/klaviyo/upsertProfile/generated-types.d.ts +0 -1
- package/dist/destinations/klaviyo/upsertProfile/index.js +4 -29
- package/dist/destinations/klaviyo/upsertProfile/index.js.map +1 -1
- package/dist/destinations/linkedin-audiences/updateAudience/index.js +9 -15
- package/dist/destinations/linkedin-audiences/updateAudience/index.js.map +1 -1
- package/dist/destinations/linkedin-conversions/api/index.d.ts +2 -10
- package/dist/destinations/linkedin-conversions/api/index.js +1 -198
- package/dist/destinations/linkedin-conversions/api/index.js.map +1 -1
- package/dist/destinations/linkedin-conversions/constants.d.ts +0 -1
- package/dist/destinations/linkedin-conversions/constants.js +1 -7
- package/dist/destinations/linkedin-conversions/constants.js.map +1 -1
- package/dist/destinations/linkedin-conversions/index.js +1 -2
- package/dist/destinations/linkedin-conversions/index.js.map +1 -1
- package/dist/destinations/linkedin-conversions/streamConversion/generated-types.d.ts +0 -18
- package/dist/destinations/linkedin-conversions/streamConversion/index.js +51 -181
- package/dist/destinations/linkedin-conversions/streamConversion/index.js.map +1 -1
- package/dist/destinations/linkedin-conversions/types.d.ts +0 -64
- package/dist/destinations/liveramp-audiences/audienceEnteredS3/index.js +21 -4
- package/dist/destinations/liveramp-audiences/audienceEnteredS3/index.js.map +1 -1
- package/dist/destinations/liveramp-audiences/audienceEnteredS3/s3.d.ts +9 -0
- package/dist/destinations/liveramp-audiences/audienceEnteredS3/s3.js +23 -2
- package/dist/destinations/liveramp-audiences/audienceEnteredS3/s3.js.map +1 -1
- package/dist/destinations/liveramp-audiences/audienceEnteredSftp/index.js +20 -1
- package/dist/destinations/liveramp-audiences/audienceEnteredSftp/index.js.map +1 -1
- package/dist/destinations/liveramp-audiences/operations.d.ts +7 -1
- package/dist/destinations/liveramp-audiences/operations.js +71 -14
- package/dist/destinations/liveramp-audiences/operations.js.map +1 -1
- package/dist/destinations/snap-conversions-api/snap-capi-properties.js +2 -8
- package/dist/destinations/snap-conversions-api/snap-capi-properties.js.map +1 -1
- package/dist/destinations/tiktok-audiences/addToAudience/generated-types.d.ts +0 -2
- package/dist/destinations/tiktok-audiences/addToAudience/index.js +0 -2
- package/dist/destinations/tiktok-audiences/addToAudience/index.js.map +1 -1
- package/dist/destinations/tiktok-audiences/addUser/generated-types.d.ts +0 -2
- package/dist/destinations/tiktok-audiences/addUser/index.js +0 -2
- package/dist/destinations/tiktok-audiences/addUser/index.js.map +1 -1
- package/dist/destinations/tiktok-audiences/functions.js +2 -17
- package/dist/destinations/tiktok-audiences/functions.js.map +1 -1
- package/dist/destinations/tiktok-audiences/properties.d.ts +0 -2
- package/dist/destinations/tiktok-audiences/properties.js +7 -28
- package/dist/destinations/tiktok-audiences/properties.js.map +1 -1
- package/dist/destinations/tiktok-audiences/removeFromAudience/generated-types.d.ts +0 -2
- package/dist/destinations/tiktok-audiences/removeFromAudience/index.js +0 -2
- package/dist/destinations/tiktok-audiences/removeFromAudience/index.js.map +1 -1
- package/dist/destinations/tiktok-audiences/removeUser/generated-types.d.ts +0 -2
- package/dist/destinations/tiktok-audiences/removeUser/index.js +0 -2
- package/dist/destinations/tiktok-audiences/removeUser/index.js.map +1 -1
- package/dist/destinations/usermaven/request-params.js +3 -8
- package/dist/destinations/usermaven/request-params.js.map +1 -1
- package/dist/destinations/yahoo-audiences/generated-types.d.ts +2 -1
- package/dist/destinations/yahoo-audiences/index.js +21 -17
- package/dist/destinations/yahoo-audiences/index.js.map +1 -1
- package/dist/destinations/yahoo-audiences/updateSegment/generated-types.d.ts +1 -1
- package/dist/destinations/yahoo-audiences/updateSegment/index.js +23 -23
- package/dist/destinations/yahoo-audiences/updateSegment/index.js.map +1 -1
- package/dist/destinations/yahoo-audiences/utils-rt.js +5 -15
- package/dist/destinations/yahoo-audiences/utils-rt.js.map +1 -1
- package/dist/destinations/yahoo-audiences/utils-tax.js +2 -2
- package/dist/destinations/yahoo-audiences/utils-tax.js.map +1 -1
- package/package.json +4 -7
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const actions_core_1 = require("@segment/actions-core");
|
|
4
|
-
const api_1 = require("../api");
|
|
5
|
-
const constants_1 = require("../constants");
|
|
6
3
|
const action = {
|
|
7
4
|
title: 'Stream Conversion Event',
|
|
8
5
|
description: 'Directly streams conversion events to a specific conversion rule.',
|
|
9
|
-
|
|
6
|
+
fields: {
|
|
7
|
+
adAccountId: {
|
|
8
|
+
label: 'Ad Account',
|
|
9
|
+
description: 'A dynamic field dropdown which fetches all adAccounts.',
|
|
10
|
+
type: 'string',
|
|
11
|
+
required: true,
|
|
12
|
+
dynamic: true
|
|
13
|
+
}
|
|
14
|
+
},
|
|
10
15
|
hooks: {
|
|
11
16
|
onMappingSave: {
|
|
12
17
|
label: 'Create a Conversion Rule',
|
|
@@ -16,11 +21,7 @@ const action = {
|
|
|
16
21
|
type: 'string',
|
|
17
22
|
label: 'Existing Conversion Rule ID',
|
|
18
23
|
description: 'The ID of an existing conversion rule to stream events to. If defined, we will not create a new conversion rule.',
|
|
19
|
-
required: false
|
|
20
|
-
dynamic: async (request, { payload }) => {
|
|
21
|
-
const linkedIn = new api_1.LinkedInConversions(request);
|
|
22
|
-
return linkedIn.getConversionRulesList(payload.adAccountId);
|
|
23
|
-
}
|
|
24
|
+
required: false
|
|
24
25
|
},
|
|
25
26
|
name: {
|
|
26
27
|
type: 'string',
|
|
@@ -76,185 +77,54 @@ const action = {
|
|
|
76
77
|
}
|
|
77
78
|
},
|
|
78
79
|
performHook: async (request, { payload, hookInputs }) => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
type: 'string',
|
|
89
|
-
required: true,
|
|
90
|
-
dynamic: true
|
|
91
|
-
},
|
|
92
|
-
conversionHappenedAt: {
|
|
93
|
-
label: 'Timestamp',
|
|
94
|
-
description: 'Epoch timestamp in milliseconds at which the conversion event happened. If your source records conversion timestamps in second, insert 000 at the end to transform it to milliseconds.',
|
|
95
|
-
type: 'string',
|
|
96
|
-
required: true,
|
|
97
|
-
default: {
|
|
98
|
-
'@path': '$.timestamp'
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
conversionValue: {
|
|
102
|
-
label: 'Conversion Value',
|
|
103
|
-
description: 'The monetary value for this conversion. Example: {“currencyCode”: “USD”, “amount”: “50.0”}.',
|
|
104
|
-
type: 'object',
|
|
105
|
-
required: false,
|
|
106
|
-
properties: {
|
|
107
|
-
currencyCode: {
|
|
108
|
-
label: 'Currency Code',
|
|
109
|
-
type: 'string',
|
|
110
|
-
required: true,
|
|
111
|
-
description: 'ISO format'
|
|
112
|
-
},
|
|
113
|
-
amount: {
|
|
114
|
-
label: 'Amount',
|
|
115
|
-
type: 'string',
|
|
116
|
-
required: true,
|
|
117
|
-
description: 'Value of the conversion in decimal string. Can be dynamically set up or have a fixed value.'
|
|
80
|
+
if (hookInputs?.conversionRuleId) {
|
|
81
|
+
return {
|
|
82
|
+
successMessage: `Using existing Conversion Rule: ${hookInputs.conversionRuleId} `,
|
|
83
|
+
savedData: {
|
|
84
|
+
id: hookInputs.conversionRuleId,
|
|
85
|
+
name: hookInputs.name,
|
|
86
|
+
conversionType: hookInputs.conversionType
|
|
87
|
+
}
|
|
88
|
+
};
|
|
118
89
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
type: 'string',
|
|
141
|
-
required: true
|
|
142
|
-
},
|
|
143
|
-
idValue: {
|
|
144
|
-
label: 'ID Value',
|
|
145
|
-
description: 'The value of the identifier.',
|
|
146
|
-
type: 'string',
|
|
147
|
-
required: true
|
|
90
|
+
try {
|
|
91
|
+
const { data } = await request('https://api.linkedin.com/rest/conversions', {
|
|
92
|
+
method: 'post',
|
|
93
|
+
json: {
|
|
94
|
+
name: hookInputs?.name,
|
|
95
|
+
account: payload?.adAccountId,
|
|
96
|
+
conversionMethod: 'CONVERSIONS_API',
|
|
97
|
+
postClickAttributionWindowSize: 30,
|
|
98
|
+
viewThroughAttributionWindowSize: 7,
|
|
99
|
+
attributionType: hookInputs?.attribution_type,
|
|
100
|
+
type: hookInputs?.conversionType
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return {
|
|
104
|
+
successMessage: `Conversion rule ${data.id} created successfully!`,
|
|
105
|
+
savedData: {
|
|
106
|
+
id: data.id,
|
|
107
|
+
name: data.name,
|
|
108
|
+
conversionType: data.type
|
|
109
|
+
}
|
|
110
|
+
};
|
|
148
111
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
description: 'Object containing additional fields for user matching.',
|
|
154
|
-
type: 'object',
|
|
155
|
-
required: false,
|
|
156
|
-
properties: {
|
|
157
|
-
firstName: {
|
|
158
|
-
label: 'First Name',
|
|
159
|
-
type: 'string',
|
|
160
|
-
required: false
|
|
161
|
-
},
|
|
162
|
-
lastName: {
|
|
163
|
-
label: 'Last Name',
|
|
164
|
-
type: 'string',
|
|
165
|
-
required: false
|
|
166
|
-
},
|
|
167
|
-
companyName: {
|
|
168
|
-
label: 'Company Name',
|
|
169
|
-
type: 'string',
|
|
170
|
-
required: false
|
|
171
|
-
},
|
|
172
|
-
title: {
|
|
173
|
-
label: 'Title',
|
|
174
|
-
type: 'string',
|
|
175
|
-
required: false
|
|
176
|
-
},
|
|
177
|
-
countryCode: {
|
|
178
|
-
label: 'Country Code',
|
|
179
|
-
type: 'string',
|
|
180
|
-
required: false
|
|
112
|
+
catch (e) {
|
|
113
|
+
return {
|
|
114
|
+
errorMessage: `Failed to create conversion rule: ${e?.message ?? JSON.stringify(e)}`
|
|
115
|
+
};
|
|
181
116
|
}
|
|
182
117
|
}
|
|
183
|
-
},
|
|
184
|
-
campaignId: {
|
|
185
|
-
label: 'Campaign',
|
|
186
|
-
type: 'string',
|
|
187
|
-
required: true,
|
|
188
|
-
dynamic: true,
|
|
189
|
-
description: 'A dynamic field dropdown which fetches all active campaigns.'
|
|
190
118
|
}
|
|
191
119
|
},
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const linkedIn = new api_1.LinkedInConversions(request);
|
|
199
|
-
return linkedIn.getCampaignsList(payload.adAccountId);
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
perform: async (request, { payload, hookOutputs }) => {
|
|
203
|
-
const conversionTime = isNotEpochTimestampInMilliseconds(payload.conversionHappenedAt)
|
|
204
|
-
? convertToEpochMillis(payload.conversionHappenedAt)
|
|
205
|
-
: Number(payload.conversionHappenedAt);
|
|
206
|
-
validate(payload, conversionTime);
|
|
207
|
-
let conversionRuleId = '';
|
|
208
|
-
if (hookOutputs?.onMappingSave?.outputs?.id) {
|
|
209
|
-
conversionRuleId = hookOutputs?.onMappingSave.outputs?.id;
|
|
210
|
-
}
|
|
211
|
-
if (!conversionRuleId) {
|
|
212
|
-
throw new actions_core_1.PayloadValidationError('Conversion Rule ID is required.');
|
|
213
|
-
}
|
|
214
|
-
const linkedinApiClient = new api_1.LinkedInConversions(request, conversionRuleId);
|
|
215
|
-
try {
|
|
216
|
-
await linkedinApiClient.associateCampignToConversion(payload);
|
|
217
|
-
return linkedinApiClient.streamConversionEvent(payload, conversionTime);
|
|
218
|
-
}
|
|
219
|
-
catch (error) {
|
|
220
|
-
return error;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
function validate(payload, conversionTime) {
|
|
225
|
-
const ninetyDaysAgo = Date.now() - 90 * 24 * 60 * 60 * 1000;
|
|
226
|
-
if (conversionTime < ninetyDaysAgo) {
|
|
227
|
-
throw new actions_core_1.PayloadValidationError('Timestamp should be within the past 90 days.');
|
|
228
|
-
}
|
|
229
|
-
if (payload.userIds &&
|
|
230
|
-
Array.isArray(payload.userIds) &&
|
|
231
|
-
payload.userIds?.length === 0 &&
|
|
232
|
-
(!payload.userInfo || !(payload.userInfo.firstName && payload.userInfo.lastName))) {
|
|
233
|
-
throw new actions_core_1.PayloadValidationError('Either userIds array or userInfo with firstName and lastName should be present.');
|
|
234
|
-
}
|
|
235
|
-
else if (payload.userIds && payload.userIds.length !== 0) {
|
|
236
|
-
const isValidUserIds = payload.userIds.every((obj) => {
|
|
237
|
-
return constants_1.SUPPORTED_ID_TYPE.includes(obj.idType);
|
|
120
|
+
perform: (request, data) => {
|
|
121
|
+
return request('https://example.com', {
|
|
122
|
+
method: 'post',
|
|
123
|
+
json: {
|
|
124
|
+
conversion: data.hookOutputs?.onMappingSave?.id
|
|
125
|
+
}
|
|
238
126
|
});
|
|
239
|
-
if (!isValidUserIds) {
|
|
240
|
-
throw new actions_core_1.PayloadValidationError(`Invalid idType in userIds field. Allowed idType will be: ${constants_1.SUPPORTED_ID_TYPE}`);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
function isNotEpochTimestampInMilliseconds(timestamp) {
|
|
245
|
-
if (typeof timestamp === 'string' && !isNaN(Number(timestamp))) {
|
|
246
|
-
const convertedTimestamp = Number(timestamp);
|
|
247
|
-
const startDate = new Date('1970-01-01T00:00:00Z').getTime();
|
|
248
|
-
const endDate = new Date('2100-01-01T00:00:00Z').getTime();
|
|
249
|
-
if (Number.isSafeInteger(convertedTimestamp) && convertedTimestamp >= startDate && convertedTimestamp <= endDate) {
|
|
250
|
-
return false;
|
|
251
|
-
}
|
|
252
127
|
}
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
function convertToEpochMillis(timestamp) {
|
|
256
|
-
const date = new Date(timestamp);
|
|
257
|
-
return date.getTime();
|
|
258
|
-
}
|
|
128
|
+
};
|
|
259
129
|
exports.default = action;
|
|
260
130
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/linkedin-conversions/streamConversion/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/linkedin-conversions/streamConversion/index.ts"],"names":[],"mappings":";;AAcA,MAAM,MAAM,GAA+D;IACzE,KAAK,EAAE,yBAAyB;IAChC,WAAW,EAAE,mEAAmE;IAChF,MAAM,E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B,EAAE,EAAE;4BAClC,gCAAgC,EAAE,CAAC;4BACnC,eAAe,EAAE,UAAU,EAAE,gBAAgB;4BAC7C,IAAI,EAAE,UAAU,EAAE,cAAc;yBACjC;qBACF,CAAC,CAAA;oBAEF,OAAO;wBACL,cAAc,EAAE,mBAAmB,IAAI,CAAC,EAAE,wBAAwB;wBAClE,SAAS,EAAE;4BACT,EAAE,EAAE,IAAI,CAAC,EAAE;4BACX,IAAI,EAAE,IAAI,CAAC,IAAI;4BACf,cAAc,EAAE,IAAI,CAAC,IAAI;yBAC1B;qBACF,CAAA;iBACF;gBAAC,OAAO,CAAC,EAAE;oBACV,OAAO;wBACL,YAAY,EAAE,qCAAsC,CAAmB,EAAE,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;qBACxG,CAAA;iBACF;YACH,CAAC;SACF;KACF;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;QACzB,OAAO,OAAO,CAAC,qBAAqB,EAAE;YACpC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE,aAAa,EAAE,EAAE;aAChD;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -23,67 +23,3 @@ export declare class LinkedInRefreshTokenError extends HTTPError {
|
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
export interface GetAdAccountsAPIResponse {
|
|
27
|
-
paging: {
|
|
28
|
-
count: number;
|
|
29
|
-
links: Array<any>;
|
|
30
|
-
start: number;
|
|
31
|
-
total: number;
|
|
32
|
-
};
|
|
33
|
-
elements: [Accounts];
|
|
34
|
-
}
|
|
35
|
-
export interface Accounts {
|
|
36
|
-
account: string;
|
|
37
|
-
changeAuditStamps: object;
|
|
38
|
-
role: string;
|
|
39
|
-
user: string;
|
|
40
|
-
version: object;
|
|
41
|
-
}
|
|
42
|
-
export interface AccountsErrorInfo {
|
|
43
|
-
response: {
|
|
44
|
-
data: {
|
|
45
|
-
message?: string;
|
|
46
|
-
code?: string;
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
export interface GetConversionListAPIResponse {
|
|
51
|
-
paging: {
|
|
52
|
-
count: number;
|
|
53
|
-
links: Array<any>;
|
|
54
|
-
start: number;
|
|
55
|
-
total: number;
|
|
56
|
-
};
|
|
57
|
-
elements: [Conversions];
|
|
58
|
-
}
|
|
59
|
-
export interface Conversions {
|
|
60
|
-
name: string;
|
|
61
|
-
id: string;
|
|
62
|
-
}
|
|
63
|
-
export interface GetCampaignsListAPIResponse {
|
|
64
|
-
paging: {
|
|
65
|
-
count: number;
|
|
66
|
-
links: Array<any>;
|
|
67
|
-
start: number;
|
|
68
|
-
total: number;
|
|
69
|
-
};
|
|
70
|
-
elements: [Campaigns];
|
|
71
|
-
}
|
|
72
|
-
export interface Campaigns {
|
|
73
|
-
name: string;
|
|
74
|
-
id: string;
|
|
75
|
-
}
|
|
76
|
-
export interface ConversionRuleCreationResponse {
|
|
77
|
-
id: string;
|
|
78
|
-
name: string;
|
|
79
|
-
type: string;
|
|
80
|
-
}
|
|
81
|
-
export interface GetConversionRuleResponse {
|
|
82
|
-
conversionMethod?: string;
|
|
83
|
-
type?: string;
|
|
84
|
-
enabled?: boolean;
|
|
85
|
-
name?: string;
|
|
86
|
-
id?: string;
|
|
87
|
-
attributionType?: string;
|
|
88
|
-
account?: string;
|
|
89
|
-
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const actions_core_1 = require("@segment/actions-core");
|
|
4
7
|
const s3_1 = require("./s3");
|
|
5
8
|
const operations_1 = require("../operations");
|
|
6
|
-
const awsClient_1 = require("../awsClient");
|
|
7
9
|
const properties_1 = require("../properties");
|
|
10
|
+
const promises_1 = require("stream/promises");
|
|
11
|
+
const awsClient_1 = require("../awsClient");
|
|
12
|
+
const s3_2 = __importDefault(require("../../../lib/AWS/s3"));
|
|
8
13
|
const action = {
|
|
9
14
|
title: 'Audience Entered (S3)',
|
|
10
15
|
description: 'Uploads audience membership data to a file in S3 for LiveRamp ingestion.',
|
|
@@ -97,12 +102,24 @@ const action = {
|
|
|
97
102
|
features,
|
|
98
103
|
rawData
|
|
99
104
|
});
|
|
105
|
+
},
|
|
106
|
+
performBatchStream: async (request, { payload }) => {
|
|
107
|
+
const transformStream = new operations_1.ObjectToCSVTransformer({});
|
|
108
|
+
const writeToS3 = new s3_1.S3WriteStream();
|
|
109
|
+
await promises_1.pipeline(payload, transformStream, writeToS3);
|
|
110
|
+
const opts = await s3_2.default('varada-test-bucket', 'us-west-2', 'test.csv', 'PUT', writeToS3.buffer, 'AKIAQ3YSPSZ4UYWHGJRZ', 'NhLWuxz+G3zH1wlu7Os4Xx2pZwvWL4Si9j5yWwUh');
|
|
111
|
+
if (!opts.headers || !opts.method || !opts.host || !opts.path) {
|
|
112
|
+
throw new actions_core_1.InvalidAuthenticationError('Unable to generate signature header for AWS S3 request.');
|
|
113
|
+
}
|
|
114
|
+
return await request(`https://${opts.host}/${opts.path}`, {
|
|
115
|
+
headers: opts.headers,
|
|
116
|
+
method: 'PUT',
|
|
117
|
+
timeout: 30000,
|
|
118
|
+
body: opts.body
|
|
119
|
+
});
|
|
100
120
|
}
|
|
101
121
|
};
|
|
102
122
|
async function processData(input) {
|
|
103
|
-
if (input.payloads.length < properties_1.LIVERAMP_MIN_RECORD_COUNT) {
|
|
104
|
-
throw new actions_core_1.PayloadValidationError(`received payload count below LiveRamp's ingestion limits. expected: >=${properties_1.LIVERAMP_MIN_RECORD_COUNT} actual: ${input.payloads.length}`);
|
|
105
|
-
}
|
|
106
123
|
s3_1.validateS3(input.payloads[0]);
|
|
107
124
|
const { filename, fileContents } = operations_1.generateFile(input.payloads);
|
|
108
125
|
if (input.features && input.features[properties_1.LIVERAMP_LEGACY_FLOW_FLAG_NAME] === true) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/liveramp-audiences/audienceEnteredS3/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/liveramp-audiences/audienceEnteredS3/index.ts"],"names":[],"mappings":";;;;;AAAA,wDAAoF;AACpF,6BAA0D;AAC1D,8CAAoE;AACpE,8CAA8D;AAM9D,8CAA0C;AAC1C,4CAA6C;AAC7C,6DAA0D;AAE1D,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,uBAAuB;IAC9B,WAAW,EAAE,0EAA0E;IACvF,mBAAmB,EAAE,4BAA4B;IACjD,MAAM,EAAE;QACN,iBAAiB,EAAE;YACjB,KAAK,EAAE,mBAAmB;YAC1B,WAAW,EAAE,+DAA+D;YAC5E,IAAI,EAAE,QAAQ;SACf;QACD,iBAAiB,EAAE;YACjB,KAAK,EAAE,uBAAuB;YAC9B,WAAW,EAAE,+DAA+D;YAC5E,IAAI,EAAE,UAAU;SACjB;QACD,kBAAkB,EAAE;YAClB,KAAK,EAAE,iBAAiB;YACxB,WAAW,EAAE,4DAA4D;YACzE,IAAI,EAAE,QAAQ;SACf;QACD,aAAa,EAAE;YACb,KAAK,EAAE,sBAAsB;YAC7B,WAAW,EAAE,uCAAuC;YACpD,IAAI,EAAE,QAAQ;SACf;QACD,YAAY,EAAE;YACZ,KAAK,EAAE,cAAc;YACrB,WAAW,EACT,2IAA2I;YAC7I,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;SACjC;QACD,eAAe,EAAE;YACf,KAAK,EAAE,iBAAiB;YACxB,WAAW,EAAE,mEAAmE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,IAAI,KAAK,CAAC,QAAQ,CAAC,2CAA8B,CAAC,KAAK,IAAI,EAAE;QAI7E,OAAO,aAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;KAC1E;SAAM;QAIL,OAAO,0BAAc,CAAC,KAAK,CAAC,OAAO,EAAE;YACnC,iBAAiB,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,cAAc;YACvE,UAAU,EAAE,IAAI;YAChB,QAAQ;YACR,YAAY;YACZ,MAAM,EAAE;gBACN,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,kBAAkB;gBAClD,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,aAAa;gBACzC,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,iBAAiB;gBAClD,iBAAiB,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,iBAAiB;aACvD;SACF,CAAC,CAAA;KACH;AACH,CAAC;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ModifiedResponse, RequestOptions } from '@segment/actions-core';
|
|
3
3
|
import { Payload } from './generated-types';
|
|
4
|
+
import { Writable } from 'stream';
|
|
4
5
|
declare function validateS3(payload: Payload): void;
|
|
5
6
|
declare function uploadS3(payload: Payload, filename: string, fileContent: Buffer, request: <Data = unknown>(url: string, options?: RequestOptions) => Promise<ModifiedResponse<Data>>): Promise<ModifiedResponse<unknown>>;
|
|
7
|
+
export declare class S3WriteStream extends Writable {
|
|
8
|
+
buffer: Buffer;
|
|
9
|
+
constructor();
|
|
10
|
+
_construct(callback: (error?: Error) => void): void;
|
|
11
|
+
_write(chunk: any, _encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
12
|
+
_final(callback: (error?: Error) => void): void;
|
|
13
|
+
_destroy(_error: Error, callback: (error?: Error) => void): void;
|
|
14
|
+
}
|
|
6
15
|
export { validateS3, uploadS3 };
|
|
@@ -3,9 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.uploadS3 = exports.validateS3 = void 0;
|
|
6
|
+
exports.uploadS3 = exports.validateS3 = exports.S3WriteStream = void 0;
|
|
7
7
|
const s3_1 = __importDefault(require("../../../lib/AWS/s3"));
|
|
8
8
|
const actions_core_1 = require("@segment/actions-core");
|
|
9
|
+
const stream_1 = require("stream");
|
|
9
10
|
function validateS3(payload) {
|
|
10
11
|
if (!payload.s3_aws_access_key) {
|
|
11
12
|
throw new actions_core_1.InvalidAuthenticationError('Selected S3 upload mode, but missing AWS Access Key');
|
|
@@ -17,7 +18,7 @@ function validateS3(payload) {
|
|
|
17
18
|
throw new actions_core_1.InvalidAuthenticationError('Selected S3 upload mode, but missing AWS S3 bucket name');
|
|
18
19
|
}
|
|
19
20
|
if (!payload.s3_aws_region) {
|
|
20
|
-
throw new actions_core_1.InvalidAuthenticationError('Selected S3 upload mode, but missing AWS
|
|
21
|
+
throw new actions_core_1.InvalidAuthenticationError('Selected S3 upload mode, but missing AWS Region');
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
exports.validateS3 = validateS3;
|
|
@@ -34,4 +35,24 @@ async function uploadS3(payload, filename, fileContent, request) {
|
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
37
|
exports.uploadS3 = uploadS3;
|
|
38
|
+
class S3WriteStream extends stream_1.Writable {
|
|
39
|
+
constructor() {
|
|
40
|
+
super({ objectMode: false });
|
|
41
|
+
this.buffer = Buffer.from('');
|
|
42
|
+
}
|
|
43
|
+
_construct(callback) {
|
|
44
|
+
callback();
|
|
45
|
+
}
|
|
46
|
+
_write(chunk, _encoding, callback) {
|
|
47
|
+
this.buffer = Buffer.concat([this.buffer, chunk]);
|
|
48
|
+
callback();
|
|
49
|
+
}
|
|
50
|
+
_final(callback) {
|
|
51
|
+
callback();
|
|
52
|
+
}
|
|
53
|
+
_destroy(_error, callback) {
|
|
54
|
+
callback();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.S3WriteStream = S3WriteStream;
|
|
37
58
|
//# sourceMappingURL=s3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3.js","sourceRoot":"","sources":["../../../../src/destinations/liveramp-audiences/audienceEnteredS3/s3.ts"],"names":[],"mappings":";;;;;;AAAA,6DAA0D;AAC1D,wDAAoG;
|
|
1
|
+
{"version":3,"file":"s3.js","sourceRoot":"","sources":["../../../../src/destinations/liveramp-audiences/audienceEnteredS3/s3.ts"],"names":[],"mappings":";;;;;;AAAA,6DAA0D;AAC1D,wDAAoG;AAEpG,mCAAiC;AAEjC,SAAS,UAAU,CAAC,OAAgB;IAClC,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE;QAC9B,MAAM,IAAI,yCAA0B,CAAC,qDAAqD,CAAC,CAAA;KAC5F;IAED,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE;QAC9B,MAAM,IAAI,yCAA0B,CAAC,qDAAqD,CAAC,CAAA;KAC5F;IAED,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE;QAC/B,MAAM,IAAI,yCAA0B,CAAC,yDAAyD,CAAC,CAAA;KAChG;IAED,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE;QAC1B,MAAM,IAAI,yCAA0B,CAAC,iDAAiD,CAAC,CAAA;KACxF;AACH,CAAC;AAqDQ,gCAAU;AAnDnB,KAAK,UAAU,QAAQ,CACrB,OAAgB,EAChB,QAAgB,EAChB,WAAmB,EACnB,OAAmG;IAEnG,MAAM,MAAM,G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-1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const actions_core_1 = require("@segment/actions-core");
|
|
4
7
|
const sftp_1 = require("./sftp");
|
|
5
8
|
const operations_1 = require("../operations");
|
|
6
9
|
const awsClient_1 = require("../awsClient");
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
11
|
const properties_1 = require("../properties");
|
|
12
|
+
const promises_1 = require("stream/promises");
|
|
8
13
|
const action = {
|
|
9
14
|
title: 'Audience Entered (SFTP)',
|
|
10
15
|
description: 'Uploads audience membership data to a file through SFTP for LiveRamp ingestion.',
|
|
@@ -22,7 +27,7 @@ const action = {
|
|
|
22
27
|
},
|
|
23
28
|
sftp_folder_path: {
|
|
24
29
|
label: 'Folder Path',
|
|
25
|
-
description: 'Path within the LiveRamp SFTP server to
|
|
30
|
+
description: 'Path within the LiveRamp SFTP server to u pload the files to. This path must exist and all subfolders must be pre-created.',
|
|
26
31
|
type: 'string',
|
|
27
32
|
default: { '@template': '/uploads/' },
|
|
28
33
|
format: 'uri-reference'
|
|
@@ -94,6 +99,20 @@ const action = {
|
|
|
94
99
|
features,
|
|
95
100
|
rawData
|
|
96
101
|
});
|
|
102
|
+
},
|
|
103
|
+
async performBatchStream(_request, { payload }) {
|
|
104
|
+
const csv = new operations_1.ObjectToCSVTransformer();
|
|
105
|
+
const fileStream = fs_1.default.createWriteStream('test123.csv');
|
|
106
|
+
await promises_1.pipeline(payload, csv, fileStream);
|
|
107
|
+
const sftpClient = new sftp_1.Client();
|
|
108
|
+
await sftpClient.connect({
|
|
109
|
+
host: properties_1.LIVERAMP_SFTP_SERVER,
|
|
110
|
+
port: properties_1.LIVERAMP_SFTP_PORT,
|
|
111
|
+
username: 'segment-cdp-testing-',
|
|
112
|
+
password: 'zS20NRAJSA0HRyD!'
|
|
113
|
+
});
|
|
114
|
+
await sftpClient.fastPut('test123.csv', '/uploads/varada_test/test123.csv');
|
|
115
|
+
fs_1.default.unlinkSync('test123.csv');
|
|
97
116
|
}
|
|
98
117
|
};
|
|
99
118
|
async function processData(input) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/liveramp-audiences/audienceEnteredSftp/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/liveramp-audiences/audienceEnteredSftp/index.ts"],"names":[],"mappings":";;;;;AAAA,wDAAgF;AAChF,iCAAuE;AACvE,8CAAoE;AACpE,4CAA6C;AAC7C,4CAAmB;AACnB,8CAKsB;AAMtB,8CAA0C;AAE1C,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,yBAAyB;IAChC,WAAW,EAAE,iFAAiF;IAC9F,mBAAmB,EAAE,4BAA4B;IACjD,MAAM,EAAE;QACN,aAAa,EAAE;YACb,KAAK,EAAE,UAAU;YACjB,WAAW,EAAE,qEAAqE;YAClF,IAAI,EAAE,QAAQ;SACf;QACD,aAAa,EAAE;YACb,KAAK,EAAE,UAAU;YACjB,WAAW,EAAE,qEAAqE;YAClF,IAAI,EAAE,UAAU;SACjB;QACD,gBAAgB,EAAE;YAChB,KAAK,EAAE,aAAa;YACpB,WAAW,EACT,6HAA6H;YAC/H,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE;YACrC,MAAM,EAAE,eAAe;SACxB;QACD,YAAY,EAAE;YACZ,KAAK,EAAE,cAAc;YACrB,WAAW,EACT,2IAA2I;YAC7I,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;SACjC;QACD,eAAe,EAAE;YACf,KAAK,EAAE,iBAAiB;YACxB,WAA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AAI,EAAE;QAI7E,MAAM,UAAU,GAAG,IAAI,aAAU,EAAE,CAAA;QACnC,OAAO,iBAAU,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAA;KACzE;SAAM;QAIL,OAAO,0BAAc,CAAC,KAAK,CAAC,OAAO,EAAE;YACnC,iBAAiB,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,cAAc;YACvE,UAAU,EAAE,MAAM;YAClB,QAAQ;YACR,YAAY;YACZ,QAAQ,EAAE;gBACR,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,aAAa;gBAC7C,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,aAAa;gBAC7C,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,gBAAgB;aACnD;SACF,CAAC,CAAA;KACH;AACH,CAAC;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { RequestClient, ExecuteInput } from '@segment/actions-core';
|
|
3
3
|
import type { Payload as s3Payload } from './audienceEnteredS3/generated-types';
|
|
4
4
|
import type { Payload as sftpPayload } from './audienceEnteredSftp/generated-types';
|
|
5
|
+
import { Transform } from 'stream';
|
|
5
6
|
export declare type RawData = {
|
|
6
7
|
context?: {
|
|
7
8
|
personas?: {
|
|
@@ -20,10 +21,15 @@ export declare type ProcessDataInput<T extends s3Payload | sftpPayload> = {
|
|
|
20
21
|
export declare type ExecuteInputRaw<Settings, Payload, RawData, AudienceSettings = unknown> = ExecuteInput<Settings, Payload, AudienceSettings> & {
|
|
21
22
|
rawData?: RawData;
|
|
22
23
|
};
|
|
24
|
+
declare class ObjectToCSVTransformer extends Transform {
|
|
25
|
+
headerWritten: boolean;
|
|
26
|
+
constructor(options?: {});
|
|
27
|
+
_transform(payloads: s3Payload[] | sftpPayload[], _encoding: any, callback: (err?: Error) => void): void;
|
|
28
|
+
}
|
|
23
29
|
declare function generateFile(payloads: s3Payload[] | sftpPayload[]): {
|
|
24
30
|
filename: string;
|
|
25
31
|
fileContents: Buffer;
|
|
26
32
|
};
|
|
27
33
|
declare function enquoteIdentifier(identifier: string): string;
|
|
28
34
|
declare const normalize: (key: string, value: string) => string;
|
|
29
|
-
export { generateFile, enquoteIdentifier, normalize };
|
|
35
|
+
export { generateFile, enquoteIdentifier, normalize, ObjectToCSVTransformer };
|