@segment/action-destinations 3.233.0-streams.1 → 3.233.0-streams.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/engage/utils/Profile.d.ts +6 -0
- package/dist/destinations/engage/utils/Profile.js +3 -0
- package/dist/destinations/engage/utils/Profile.js.map +1 -0
- package/dist/destinations/engage/utils/apiLookups.d.ts +22 -0
- package/dist/destinations/engage/utils/apiLookups.js +189 -0
- package/dist/destinations/engage/utils/apiLookups.js.map +1 -0
- package/dist/destinations/engage/utils/track.d.ts +10 -10
- package/dist/destinations/liveramp-audiences/audienceEnteredS3/index.js +1 -4
- package/dist/destinations/liveramp-audiences/audienceEnteredSftp/index.js +16 -3
- package/dist/destinations/liveramp-audiences/audienceEnteredSftp/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Profile.js","sourceRoot":"","sources":["../../../../src/destinations/engage/utils/Profile.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { InputField } from '@segment/actions-core';
|
|
2
|
+
import { RequestClient } from '@segment/actions-core';
|
|
3
|
+
import { Logger, StatsClient, DataFeedCache } from '@segment/actions-core/destination-kit';
|
|
4
|
+
import type { Settings } from '../sendgrid/generated-types';
|
|
5
|
+
import { Profile } from './Profile';
|
|
6
|
+
export declare type ApiLookupConfig = {
|
|
7
|
+
id?: string | undefined;
|
|
8
|
+
name: string;
|
|
9
|
+
url: string;
|
|
10
|
+
method: string;
|
|
11
|
+
cacheTtl: number;
|
|
12
|
+
body?: string | undefined;
|
|
13
|
+
headers?: object | undefined;
|
|
14
|
+
responseType: string;
|
|
15
|
+
shouldRetryOnRetryableError?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare const getRequestId: ({ method, url, body, headers }: ApiLookupConfig) => string;
|
|
18
|
+
export declare const getCachedResponse: ({ responseType }: ApiLookupConfig, requestId: string, dataFeedCache: DataFeedCache, datafeedTags: string[]) => Promise<any>;
|
|
19
|
+
export declare const performApiLookup: (request: RequestClient, apiLookupConfig: ApiLookupConfig, profile: Profile, statsClient: StatsClient | undefined, tags: string[], settings: Settings, logger?: Logger | undefined, dataFeedCache?: DataFeedCache | undefined) => Promise<any>;
|
|
20
|
+
export declare const apiLookupActionFields: Record<string, InputField>;
|
|
21
|
+
export declare const apiLookupLiquidKey = "datafeeds";
|
|
22
|
+
export declare const FLAGON_NAME_DATA_FEEDS = "is-datafeeds-enabled";
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FLAGON_NAME_DATA_FEEDS = exports.apiLookupLiquidKey = exports.apiLookupActionFields = exports.performApiLookup = exports.getCachedResponse = exports.getRequestId = void 0;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
6
|
+
const liquidjs_1 = require("liquidjs");
|
|
7
|
+
const Liquid = new liquidjs_1.Liquid();
|
|
8
|
+
const renderLiquidFields = async ({ url, body }, profile, datafeedTags, logDataFeedError) => {
|
|
9
|
+
let renderedUrl;
|
|
10
|
+
let renderedBody;
|
|
11
|
+
try {
|
|
12
|
+
renderedUrl = await Liquid.parseAndRender(url, { profile });
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
logDataFeedError('URL liquid render failuere', error);
|
|
16
|
+
datafeedTags.push('error:true', 'reason:rendering_failure', 'rendering:url');
|
|
17
|
+
throw new actions_core_1.IntegrationError('Unable to parse data feed url', 'DATA_FEED_RENDERING_ERROR', 400);
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
renderedBody = body ? await Liquid.parseAndRender(body, { profile }) : undefined;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
logDataFeedError('Body liquid render failure', error);
|
|
24
|
+
datafeedTags.push('error:true', 'reason:rendering_failure', 'rendering:body');
|
|
25
|
+
throw new actions_core_1.IntegrationError('Unable to parse email api lookup body', 'DATA_FEED_RENDERING_ERROR', 400);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
renderedUrl,
|
|
29
|
+
renderedBody
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const getRequestId = ({ method, url, body, headers }) => {
|
|
33
|
+
const requestHash = crypto_1.createHash('sha256');
|
|
34
|
+
requestHash.update(`${method}${url}${body}${JSON.stringify(headers)}`);
|
|
35
|
+
const requestId = requestHash.digest('hex');
|
|
36
|
+
return requestId;
|
|
37
|
+
};
|
|
38
|
+
exports.getRequestId = getRequestId;
|
|
39
|
+
const getCachedResponse = async ({ responseType }, requestId, dataFeedCache, datafeedTags) => {
|
|
40
|
+
const cachedResponse = await dataFeedCache.getRequestResponse(requestId);
|
|
41
|
+
if (!cachedResponse) {
|
|
42
|
+
datafeedTags.push('cache_hit:false');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
datafeedTags.push('cache_hit:true');
|
|
46
|
+
if (responseType === 'json') {
|
|
47
|
+
return JSON.parse(cachedResponse);
|
|
48
|
+
}
|
|
49
|
+
return cachedResponse;
|
|
50
|
+
};
|
|
51
|
+
exports.getCachedResponse = getCachedResponse;
|
|
52
|
+
const performApiLookup = async (request, apiLookupConfig, profile, statsClient, tags, settings, logger, dataFeedCache) => {
|
|
53
|
+
const { id, method, headers, cacheTtl, name, shouldRetryOnRetryableError = true } = apiLookupConfig;
|
|
54
|
+
const datafeedTags = [
|
|
55
|
+
...tags,
|
|
56
|
+
`datafeed_id:${id}`,
|
|
57
|
+
`datafeed_name:${name}`,
|
|
58
|
+
`space_id:${settings.spaceId}`,
|
|
59
|
+
`cache_ttl_greater_than_0:${cacheTtl > 0}`,
|
|
60
|
+
`retry_enabled:${shouldRetryOnRetryableError}`
|
|
61
|
+
];
|
|
62
|
+
const logDataFeedError = (message, error) => {
|
|
63
|
+
logger?.error(`TE Messaging: Data feed error - message: ${message} - data feed name: ${name} - data feed id: ${id} - space id: ${settings.spaceId} - raw error: ${error}`);
|
|
64
|
+
};
|
|
65
|
+
try {
|
|
66
|
+
const { renderedUrl, renderedBody } = await renderLiquidFields(apiLookupConfig, profile, datafeedTags, logDataFeedError);
|
|
67
|
+
const requestId = exports.getRequestId({ ...apiLookupConfig, url: renderedUrl, body: renderedBody });
|
|
68
|
+
if (cacheTtl > 0 && !dataFeedCache) {
|
|
69
|
+
logDataFeedError('Data feed cache not available and cache needed');
|
|
70
|
+
datafeedTags.push('cache_set:false');
|
|
71
|
+
throw new actions_core_1.IntegrationError('Data feed cache not available and cache needed', 'DATA_FEED_CACHE_NOT_AVAILABLE', 400);
|
|
72
|
+
}
|
|
73
|
+
if (cacheTtl > 0 && dataFeedCache) {
|
|
74
|
+
const cachedResponse = await exports.getCachedResponse(apiLookupConfig, requestId, dataFeedCache, datafeedTags);
|
|
75
|
+
if (cachedResponse) {
|
|
76
|
+
datafeedTags.push('error:false');
|
|
77
|
+
return cachedResponse;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
let data;
|
|
81
|
+
try {
|
|
82
|
+
const res = await request(renderedUrl, {
|
|
83
|
+
headers: headers ?? undefined,
|
|
84
|
+
timeout: 3000,
|
|
85
|
+
method: method,
|
|
86
|
+
body: renderedBody,
|
|
87
|
+
skipResponseCloning: true
|
|
88
|
+
});
|
|
89
|
+
data = await res.data;
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
const respError = error.response;
|
|
93
|
+
logDataFeedError('Data feed call failure', error);
|
|
94
|
+
datafeedTags.push(`error:true`, `error_status:${respError?.status}`, 'reason:api_call_failure');
|
|
95
|
+
if (shouldRetryOnRetryableError) {
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
return {};
|
|
99
|
+
}
|
|
100
|
+
if (cacheTtl > 0 && dataFeedCache) {
|
|
101
|
+
const dataString = JSON.stringify(data);
|
|
102
|
+
const size = Buffer.byteLength(dataString, 'utf-8');
|
|
103
|
+
if (size > dataFeedCache.maxResponseSizeBytes) {
|
|
104
|
+
datafeedTags.push('error:true', 'reason:response_size_too_big');
|
|
105
|
+
logDataFeedError('Data feed response size too big too cache and caching needed, failing send');
|
|
106
|
+
throw new actions_core_1.IntegrationError('Data feed response size too big too cache and caching needed, failing send', 'DATA_FEED_RESPONSE_TOO_BIG', 400);
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
await dataFeedCache.setRequestResponse(requestId, dataString, cacheTtl / 1000);
|
|
110
|
+
datafeedTags.push('cache_set:true');
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
logDataFeedError('Data feed cache set failure', error);
|
|
114
|
+
datafeedTags.push('error:true', 'reason:cache_set_failure', 'cache_set:false');
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
datafeedTags.push('error:false');
|
|
119
|
+
return data;
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
const isErrorCapturedInTags = datafeedTags.find((str) => str.includes('error:true'));
|
|
123
|
+
if (!isErrorCapturedInTags) {
|
|
124
|
+
datafeedTags.push('error:true', 'reason:unknown');
|
|
125
|
+
}
|
|
126
|
+
tags.push('reason:datafeed_failure');
|
|
127
|
+
logDataFeedError('Unexpected data feed error', error);
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
statsClient?.incr('datafeed_execution', 1, datafeedTags);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
exports.performApiLookup = performApiLookup;
|
|
135
|
+
exports.apiLookupActionFields = {
|
|
136
|
+
id: {
|
|
137
|
+
label: 'ID',
|
|
138
|
+
description: 'The id of the API lookup for use in logging & observability',
|
|
139
|
+
type: 'string'
|
|
140
|
+
},
|
|
141
|
+
name: {
|
|
142
|
+
label: 'Name',
|
|
143
|
+
description: 'The name of the API lookup referenced in liquid syntax',
|
|
144
|
+
type: 'string',
|
|
145
|
+
required: true
|
|
146
|
+
},
|
|
147
|
+
url: {
|
|
148
|
+
label: 'URL',
|
|
149
|
+
description: 'The URL endpoint to call',
|
|
150
|
+
type: 'string',
|
|
151
|
+
required: true
|
|
152
|
+
},
|
|
153
|
+
method: {
|
|
154
|
+
label: 'Request Method',
|
|
155
|
+
description: 'The request method, e.g. GET/POST/etc.',
|
|
156
|
+
type: 'string',
|
|
157
|
+
required: true
|
|
158
|
+
},
|
|
159
|
+
cacheTtl: {
|
|
160
|
+
label: 'Cache TTL',
|
|
161
|
+
description: 'The cache TTL in ms',
|
|
162
|
+
type: 'integer',
|
|
163
|
+
required: true
|
|
164
|
+
},
|
|
165
|
+
body: {
|
|
166
|
+
label: 'Request Body',
|
|
167
|
+
description: 'The request body for use with POST/PUT/PATCH requests',
|
|
168
|
+
type: 'string'
|
|
169
|
+
},
|
|
170
|
+
headers: {
|
|
171
|
+
label: 'Request Headers',
|
|
172
|
+
description: 'Headers in JSON to be sent with the request',
|
|
173
|
+
type: 'object'
|
|
174
|
+
},
|
|
175
|
+
responseType: {
|
|
176
|
+
label: 'Response Type',
|
|
177
|
+
description: 'The response type of the request. Currently only supporting JSON.',
|
|
178
|
+
type: 'string',
|
|
179
|
+
required: true
|
|
180
|
+
},
|
|
181
|
+
shouldRetryOnRetryableError: {
|
|
182
|
+
label: 'Should Retry',
|
|
183
|
+
description: 'Whether the message should be retried (if the error code is retryable) when the data feed fails or if it should be sent with empty data instead',
|
|
184
|
+
type: 'boolean'
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
exports.apiLookupLiquidKey = 'datafeeds';
|
|
188
|
+
exports.FLAGON_NAME_DATA_FEEDS = 'is-datafeeds-enabled';
|
|
189
|
+
//# sourceMappingURL=apiLookups.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiLookups.js","sourceRoot":"","sources":["../../../../src/destinations/engage/utils/apiLookups.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;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P,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE,6CAA6C;QAC1D,IAAI,EAAE,QAAQ;KACf;IACD,YAAY,EAAE;QACZ,KAAK,EAAE,eAAe;QACtB,WAAW,EAAE,mEAAmE;QAChF,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;KACf;IACD,2BAA2B,EAAE;QAC3B,KAAK,EAAE,cAAc;QACrB,WAAW,EACT,iJAAiJ;QACnJ,IAAI,EAAE,SAAS;KAChB;CACF,CAAA;AAEY,QAAA,kBAAkB,GAAG,WAAW,CAAA;AAEhC,QAAA,sBAAsB,GAAG,sBAAsB,CAAA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ContextFromDecorator } from './operationTracking';
|
|
2
2
|
export declare const track: ((decoratorArgs?: ({
|
|
3
|
+
shouldStats?: ((args: import("./operationTracking").OperationStatsEventArgs) => boolean | void) | undefined;
|
|
4
|
+
} & {
|
|
3
5
|
onError?: ((ctx: import("./operationTracking").OperationErrorHandlerContext<import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>>) => void) | undefined;
|
|
4
6
|
} & {
|
|
5
7
|
onTry?: ((ctx: import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>) => void) | undefined;
|
|
6
8
|
onFinally?: ((ctx: import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>) => void) | undefined;
|
|
7
9
|
} & import("./operationTracking").OperationLoggerDecoratorArgs & {
|
|
8
|
-
shouldStats?: ((args: import("./operationTracking").OperationStatsEventArgs) => boolean | void) | undefined;
|
|
9
|
-
} & {
|
|
10
10
|
wrapIntegrationError?: ((ctx: import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>) => import("@segment/actions-core/*").IntegrationError | [message: string, code: string, status: number]) | undefined;
|
|
11
11
|
}) | undefined) => import("./operationTracking").GenericMethodDecorator<(this: any, ...args: any[]) => any>) & {
|
|
12
12
|
getCurrentOperation(classInstance: any): (import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any> & {
|
|
@@ -15,6 +15,14 @@ export declare const track: ((decoratorArgs?: ({
|
|
|
15
15
|
}) | undefined;
|
|
16
16
|
} & {
|
|
17
17
|
_contextType: import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any> & {
|
|
18
|
+
tags: string[];
|
|
19
|
+
sharedContext: {
|
|
20
|
+
tags: string[];
|
|
21
|
+
};
|
|
22
|
+
decoratorArgs?: {
|
|
23
|
+
shouldStats?: ((args: import("./operationTracking").OperationStatsEventArgs) => boolean | void) | undefined;
|
|
24
|
+
} | undefined;
|
|
25
|
+
} & {
|
|
18
26
|
decoratorArgs?: {
|
|
19
27
|
onError?: ((ctx: import("./operationTracking").OperationErrorHandlerContext<import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>>) => void) | undefined;
|
|
20
28
|
} | undefined;
|
|
@@ -35,14 +43,6 @@ export declare const track: ((decoratorArgs?: ({
|
|
|
35
43
|
logMetadata?: Record<string, unknown> | undefined;
|
|
36
44
|
decoratorArgs?: import("./operationTracking").OperationLoggerDecoratorArgs | undefined;
|
|
37
45
|
sharedContext: import("./operationTracking").OperationLoggerSharedContext;
|
|
38
|
-
} & {
|
|
39
|
-
tags: string[];
|
|
40
|
-
sharedContext: {
|
|
41
|
-
tags: string[];
|
|
42
|
-
};
|
|
43
|
-
decoratorArgs?: {
|
|
44
|
-
shouldStats?: ((args: import("./operationTracking").OperationStatsEventArgs) => boolean | void) | undefined;
|
|
45
|
-
} | undefined;
|
|
46
46
|
} & {
|
|
47
47
|
decoratorArgs?: {
|
|
48
48
|
wrapIntegrationError?: ((ctx: import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>) => import("@segment/actions-core/*").IntegrationError | [message: string, code: string, status: number]) | undefined;
|
|
@@ -111,15 +111,12 @@ const action = {
|
|
|
111
111
|
if (!opts.headers || !opts.method || !opts.host || !opts.path) {
|
|
112
112
|
throw new actions_core_1.InvalidAuthenticationError('Unable to generate signature header for AWS S3 request.');
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
const res = await request(`https://${opts.host}/${opts.path}`, {
|
|
114
|
+
return await request(`https://${opts.host}/${opts.path}`, {
|
|
116
115
|
headers: opts.headers,
|
|
117
116
|
method: 'PUT',
|
|
118
117
|
timeout: 120000,
|
|
119
118
|
body: opts.body
|
|
120
119
|
});
|
|
121
|
-
console.timeEnd('s3');
|
|
122
|
-
return res;
|
|
123
120
|
}
|
|
124
121
|
};
|
|
125
122
|
async function processData(input) {
|
|
@@ -101,8 +101,21 @@ const action = {
|
|
|
101
101
|
});
|
|
102
102
|
},
|
|
103
103
|
async performBatchStream(_request, { payload }) {
|
|
104
|
+
const samplePayload = await new Promise((resolve, reject) => {
|
|
105
|
+
payload
|
|
106
|
+
.once('data', (data) => {
|
|
107
|
+
payload.pause();
|
|
108
|
+
payload.unshift(data);
|
|
109
|
+
resolve(data[0]);
|
|
110
|
+
})
|
|
111
|
+
.on('error', (err) => {
|
|
112
|
+
reject(err);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
const fileName = samplePayload.filename;
|
|
116
|
+
const filePath = `/tmp/${fileName}`;
|
|
104
117
|
const csv = new operations_1.ObjectToCSVTransformer();
|
|
105
|
-
const fileStream = fs_1.default.createWriteStream(
|
|
118
|
+
const fileStream = fs_1.default.createWriteStream(filePath);
|
|
106
119
|
await promises_1.pipeline(payload, csv, fileStream);
|
|
107
120
|
const sftpClient = new sftp_1.Client();
|
|
108
121
|
await sftpClient.connect({
|
|
@@ -111,8 +124,8 @@ const action = {
|
|
|
111
124
|
username: csv.sftp.sftpUsername,
|
|
112
125
|
password: csv.sftp.sftpPassword
|
|
113
126
|
});
|
|
114
|
-
await sftpClient.fastPut(
|
|
115
|
-
fs_1.default.unlinkSync(
|
|
127
|
+
await sftpClient.fastPut(filePath, `/uploads/varada_test/${fileName}`);
|
|
128
|
+
fs_1.default.unlinkSync(filePath);
|
|
116
129
|
}
|
|
117
130
|
};
|
|
118
131
|
async function processData(input) {
|
|
@@ -1 +1 @@
|
|
|
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,WAAW,EAAE,mEAAmE;YAChF,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,eAAe,EAAE,eAAe;SACjC;QACD,wBAAwB,EAAE;YACxB,KAAK,EAAE,0BAA0B;YACjC,WAAW,EAAE,0KAA0K;YACvL,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,eAAe,EAAE,eAAe;SAC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+
{"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,WAAW,EAAE,mEAAmE;YAChF,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,eAAe,EAAE,eAAe;SACjC;QACD,wBAAwB,EAAE;YACxB,KAAK,EAAE,0BAA0B;YACjC,WAAW,EAAE,0KAA0K;YACvL,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,eAAe,EAAE,eAAe;SACjC;QACD,SAAS,EAAE;YACT,KAAK,EAAE,WAAW;YAClB,WAAW,EAAE,0DAA0D;YACvE,I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AAQ,CAAC,MAAM,EAAE,CACtI,CAAA;KACF;IAED,mBAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;IAE/B,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,yBAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAE/D,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,2CAA8B,CAAC,KAAK,IAAI,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"}
|
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.233.0-streams.
|
|
4
|
+
"version": "3.233.0-streams.2",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/segmentio/action-destinations",
|