@segment/action-destinations 3.415.0 → 3.417.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/destinations/attentive/fields.js +1 -15
- package/dist/destinations/attentive/fields.js.map +1 -1
- package/dist/destinations/attentive/functions.js +1 -1
- package/dist/destinations/attentive/functions.js.map +1 -1
- package/dist/destinations/attentive/types.d.ts +4 -1
- package/dist/destinations/batch/generated-types.d.ts +4 -0
- package/dist/destinations/batch/generated-types.js +3 -0
- package/dist/destinations/batch/generated-types.js.map +1 -0
- package/dist/destinations/batch/index.d.ts +4 -0
- package/dist/destinations/batch/index.js +64 -0
- package/dist/destinations/batch/index.js.map +1 -0
- package/dist/destinations/batch/updateProfile/constants.d.ts +2 -0
- package/dist/destinations/batch/updateProfile/constants.js +6 -0
- package/dist/destinations/batch/updateProfile/constants.js.map +1 -0
- package/dist/destinations/batch/updateProfile/generated-types.d.ts +22 -0
- package/dist/destinations/batch/updateProfile/generated-types.js +3 -0
- package/dist/destinations/batch/updateProfile/generated-types.js.map +1 -0
- package/dist/destinations/batch/updateProfile/index.d.ts +5 -0
- package/dist/destinations/batch/updateProfile/index.js +169 -0
- package/dist/destinations/batch/updateProfile/index.js.map +1 -0
- package/dist/destinations/batch/updateProfile/type.d.ts +31 -0
- package/dist/destinations/batch/updateProfile/type.js +3 -0
- package/dist/destinations/batch/updateProfile/type.js.map +1 -0
- package/dist/destinations/batch/updateProfile/utils.d.ts +6 -0
- package/dist/destinations/batch/updateProfile/utils.js +129 -0
- package/dist/destinations/batch/updateProfile/utils.js.map +1 -0
- package/dist/destinations/bing-ads-audiences/generated-types.d.ts +2 -0
- package/dist/destinations/bing-ads-audiences/generated-types.js +3 -0
- package/dist/destinations/bing-ads-audiences/generated-types.js.map +1 -0
- package/dist/destinations/bing-ads-audiences/index.d.ts +4 -0
- package/dist/destinations/bing-ads-audiences/index.js +34 -0
- package/dist/destinations/bing-ads-audiences/index.js.map +1 -0
- package/dist/destinations/bing-ads-audiences/syncAudiences/generated-types.d.ts +2 -0
- package/dist/destinations/bing-ads-audiences/syncAudiences/generated-types.js +3 -0
- package/dist/destinations/bing-ads-audiences/syncAudiences/generated-types.js.map +1 -0
- package/dist/destinations/bing-ads-audiences/syncAudiences/index.d.ts +5 -0
- package/dist/destinations/bing-ads-audiences/syncAudiences/index.js +15 -0
- package/dist/destinations/bing-ads-audiences/syncAudiences/index.js.map +1 -0
- package/dist/destinations/braze/index.js +1 -1
- package/dist/destinations/braze/index.js.map +1 -1
- package/dist/destinations/epsilon/sendEvent/fields.js +4 -2
- package/dist/destinations/epsilon/sendEvent/fields.js.map +1 -1
- package/dist/destinations/index.js +4 -0
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/klaviyo/functions.d.ts +2 -2
- package/dist/destinations/klaviyo/functions.js +5 -4
- package/dist/destinations/klaviyo/functions.js.map +1 -1
- package/dist/destinations/klaviyo/subscribeProfile/generated-types.d.ts +1 -0
- package/dist/destinations/klaviyo/subscribeProfile/index.js +13 -7
- package/dist/destinations/klaviyo/subscribeProfile/index.js.map +1 -1
- package/dist/destinations/klaviyo/types.d.ts +1 -0
- package/dist/destinations/livelike-cloud/{properties.js → constants.js} +1 -1
- package/dist/destinations/livelike-cloud/constants.js.map +1 -0
- package/dist/destinations/livelike-cloud/index.js +5 -3
- package/dist/destinations/livelike-cloud/index.js.map +1 -1
- package/dist/destinations/livelike-cloud/syncToUserGroup/generated-types.d.ts +17 -0
- package/dist/destinations/livelike-cloud/syncToUserGroup/generated-types.js +3 -0
- package/dist/destinations/livelike-cloud/syncToUserGroup/generated-types.js.map +1 -0
- package/dist/destinations/livelike-cloud/syncToUserGroup/index.d.ts +5 -0
- package/dist/destinations/livelike-cloud/syncToUserGroup/index.js +118 -0
- package/dist/destinations/livelike-cloud/syncToUserGroup/index.js.map +1 -0
- package/dist/destinations/livelike-cloud/syncToUserGroup/types.d.ts +11 -0
- package/dist/destinations/livelike-cloud/syncToUserGroup/types.js +3 -0
- package/dist/destinations/livelike-cloud/syncToUserGroup/types.js.map +1 -0
- package/dist/destinations/livelike-cloud/syncToUserGroup/utils.d.ts +4 -0
- package/dist/destinations/livelike-cloud/syncToUserGroup/utils.js +30 -0
- package/dist/destinations/livelike-cloud/syncToUserGroup/utils.js.map +1 -0
- package/dist/destinations/livelike-cloud/trackEvent/index.js +2 -2
- package/dist/destinations/livelike-cloud/trackEvent/index.js.map +1 -1
- package/dist/destinations/sftp/client.d.ts +9 -0
- package/dist/destinations/sftp/client.js +96 -0
- package/dist/destinations/sftp/client.js.map +1 -0
- package/dist/destinations/sftp/constants.d.ts +1 -0
- package/dist/destinations/sftp/constants.js +5 -0
- package/dist/destinations/sftp/constants.js.map +1 -0
- package/dist/destinations/sftp/fields.d.ts +3 -0
- package/dist/destinations/sftp/fields.js +260 -0
- package/dist/destinations/sftp/fields.js.map +1 -0
- package/dist/destinations/sftp/functions.d.ts +13 -0
- package/dist/destinations/sftp/functions.js +116 -0
- package/dist/destinations/sftp/functions.js.map +1 -0
- package/dist/destinations/sftp/generated-types.d.ts +8 -0
- package/dist/destinations/sftp/generated-types.js +3 -0
- package/dist/destinations/sftp/generated-types.js.map +1 -0
- package/dist/destinations/sftp/index.d.ts +4 -0
- package/dist/destinations/sftp/index.js +103 -0
- package/dist/destinations/sftp/index.js.map +1 -0
- package/dist/destinations/sftp/syncEvents/generated-types.d.ts +39 -0
- package/dist/destinations/sftp/syncEvents/generated-types.js +3 -0
- package/dist/destinations/sftp/syncEvents/generated-types.js.map +1 -0
- package/dist/destinations/sftp/syncEvents/index.d.ts +5 -0
- package/dist/destinations/sftp/syncEvents/index.js +22 -0
- package/dist/destinations/sftp/syncEvents/index.js.map +1 -0
- package/dist/destinations/sftp/syncModelToSFTP/generated-types.d.ts +12 -0
- package/dist/destinations/sftp/syncModelToSFTP/generated-types.js +3 -0
- package/dist/destinations/sftp/syncModelToSFTP/generated-types.js.map +1 -0
- package/dist/destinations/sftp/syncModelToSFTP/index.d.ts +5 -0
- package/dist/destinations/sftp/syncModelToSFTP/index.js +22 -0
- package/dist/destinations/sftp/syncModelToSFTP/index.js.map +1 -0
- package/dist/destinations/sftp/types.d.ts +40 -0
- package/dist/destinations/sftp/types.js +3 -0
- package/dist/destinations/sftp/types.js.map +1 -0
- package/dist/destinations/twilio-messaging/sendMessage/dynamic-fields.js +5 -0
- package/dist/destinations/twilio-messaging/sendMessage/dynamic-fields.js.map +1 -1
- package/dist/destinations/twilio-messaging/sendMessage/fields.js +11 -2
- package/dist/destinations/twilio-messaging/sendMessage/fields.js.map +1 -1
- package/dist/destinations/twilio-messaging/sendMessage/utils.js +4 -4
- package/dist/destinations/twilio-messaging/sendMessage/utils.js.map +1 -1
- package/package.json +2 -2
- package/dist/destinations/livelike-cloud/properties.js.map +0 -1
- /package/dist/destinations/livelike-cloud/{properties.d.ts → constants.d.ts} +0 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("./utils");
|
|
4
|
+
const action = {
|
|
5
|
+
title: 'Sync to User Group',
|
|
6
|
+
description: 'Sync Segment user data to a user group in LiveLike. Can be used to sync Engage Audience data to LiveLike User Groups.',
|
|
7
|
+
defaultSubscription: 'type = "identify"',
|
|
8
|
+
fields: {
|
|
9
|
+
audience_id: {
|
|
10
|
+
label: 'Segment Audience ID',
|
|
11
|
+
type: 'string',
|
|
12
|
+
required: true,
|
|
13
|
+
description: 'The unique identifier for the Segment Audience.',
|
|
14
|
+
default: {
|
|
15
|
+
'@path': '$.context.personas.computation_id'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
audience_name: {
|
|
19
|
+
label: 'Segment Audience Name',
|
|
20
|
+
type: 'string',
|
|
21
|
+
required: true,
|
|
22
|
+
description: 'The name of the Segment Audience.',
|
|
23
|
+
default: {
|
|
24
|
+
'@path': '$.context.personas.computation_key'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
action: {
|
|
28
|
+
label: 'Action',
|
|
29
|
+
type: 'boolean',
|
|
30
|
+
description: 'Set to true to add the user to the User Group, set to false to remove the user from the User Group. If connecting to an Engage Audience, leave this field empty.'
|
|
31
|
+
},
|
|
32
|
+
timestamp: {
|
|
33
|
+
label: 'Timestamp',
|
|
34
|
+
type: 'string',
|
|
35
|
+
description: 'The timestamp of the event.',
|
|
36
|
+
required: true,
|
|
37
|
+
default: { '@path': '$.timestamp' }
|
|
38
|
+
},
|
|
39
|
+
additional_user_traits: {
|
|
40
|
+
label: 'Additional user traits',
|
|
41
|
+
description: 'Used for trait values to send to Livelike.',
|
|
42
|
+
type: 'object',
|
|
43
|
+
defaultObjectUI: 'keyvalue:only',
|
|
44
|
+
additionalProperties: true,
|
|
45
|
+
properties: {
|
|
46
|
+
livelike_profile_id: {
|
|
47
|
+
label: 'LiveLike User Profile ID',
|
|
48
|
+
type: 'string',
|
|
49
|
+
description: 'The unique LiveLike user identifier.'
|
|
50
|
+
},
|
|
51
|
+
email: {
|
|
52
|
+
label: 'Email',
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'The email address of the user.'
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
default: {
|
|
58
|
+
livelike_profile_id: {
|
|
59
|
+
'@if': {
|
|
60
|
+
exists: { '@path': '$.traits.livelike_profile_id' },
|
|
61
|
+
then: { '@path': '$.traits.livelike_profile_id' },
|
|
62
|
+
else: { '@path': '$.properties.livelike_profile_id' }
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
email: {
|
|
66
|
+
'@if': {
|
|
67
|
+
exists: { '@path': '$.traits.email' },
|
|
68
|
+
then: { '@path': '$.traits.email' },
|
|
69
|
+
else: { '@path': '$.properties.email' }
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
traits_or_properties_hidden: {
|
|
75
|
+
label: 'Traits or Properties hidden',
|
|
76
|
+
description: 'Hidden field used to figure out if user is added or removed from an Engage Audience',
|
|
77
|
+
type: 'object',
|
|
78
|
+
unsafe_hidden: true,
|
|
79
|
+
default: {
|
|
80
|
+
'@if': {
|
|
81
|
+
exists: { '@path': '$.traits' },
|
|
82
|
+
then: { '@path': '$.traits' },
|
|
83
|
+
else: { '@path': '$.properties' }
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
user_id: {
|
|
88
|
+
label: 'User ID',
|
|
89
|
+
type: 'string',
|
|
90
|
+
description: 'A unique identifier for a user.',
|
|
91
|
+
default: {
|
|
92
|
+
'@path': '$.userId'
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
enable_batching: {
|
|
96
|
+
label: 'Enable Batching',
|
|
97
|
+
type: 'boolean',
|
|
98
|
+
description: 'Enable batching for this action. If enabled, the action will process records in batches.',
|
|
99
|
+
default: true
|
|
100
|
+
},
|
|
101
|
+
batch_size: {
|
|
102
|
+
label: 'Batch Size',
|
|
103
|
+
type: 'number',
|
|
104
|
+
description: 'The number of records to process in each batch. Default is 100.',
|
|
105
|
+
default: 100,
|
|
106
|
+
minimum: 1,
|
|
107
|
+
maximum: 500
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
perform: (request, { settings, payload }) => {
|
|
111
|
+
return (0, utils_1.processPayloads)(request, [payload], settings);
|
|
112
|
+
},
|
|
113
|
+
performBatch: (request, { settings, payload }) => {
|
|
114
|
+
return (0, utils_1.processPayloads)(request, payload, settings);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
exports.default = action;
|
|
118
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/livelike-cloud/syncToUserGroup/index.ts"],"names":[],"mappings":";;AAGA,mCAAyC;AAEzC,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,oBAAoB;IAC3B,WAAW,EACT,uHAAuH;IACzH,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E,OAAO,EAAE,EAAE,EAAE;QAC/C,OAAO,IAAA,uBAAe,EAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;IACpD,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/destinations/livelike-cloud/syncToUserGroup/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Payload } from './generated-types';
|
|
2
|
+
import { RequestClient } from '@segment/actions-core';
|
|
3
|
+
import { Settings } from '../generated-types';
|
|
4
|
+
export declare function processPayloads(request: RequestClient, payloads: Payload[], settings: Settings): Promise<import("@segment/actions-core").ModifiedResponse<unknown>>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processPayloads = processPayloads;
|
|
4
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
function processPayloads(request, payloads, settings) {
|
|
7
|
+
const json = payloads.map(processPayload);
|
|
8
|
+
const url = `${constants_1.apiBaseUrl}/applications/${settings.clientId}/segment-audience-sync/`;
|
|
9
|
+
return request(url, {
|
|
10
|
+
method: 'post',
|
|
11
|
+
json
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function processPayload(payload) {
|
|
15
|
+
const { audience_id, audience_name, action, timestamp, user_id, traits_or_properties_hidden, additional_user_traits } = payload;
|
|
16
|
+
const actionValue = typeof action === 'boolean' ? action : traits_or_properties_hidden?.[audience_name];
|
|
17
|
+
if (typeof actionValue !== 'boolean') {
|
|
18
|
+
throw new actions_core_1.PayloadValidationError('Action must be a boolean value (true for add, false for remove). If connecting to an Engage Audience, leave this field empty and ensure the audience_id and audience_name field mappings are left to their default values.');
|
|
19
|
+
}
|
|
20
|
+
const json = {
|
|
21
|
+
audience_id,
|
|
22
|
+
audience_name,
|
|
23
|
+
action: actionValue,
|
|
24
|
+
timestamp,
|
|
25
|
+
user_id,
|
|
26
|
+
...additional_user_traits ?? {}
|
|
27
|
+
};
|
|
28
|
+
return json;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/destinations/livelike-cloud/syncToUserGroup/utils.ts"],"names":[],"mappings":";;AAMA,0CAOC;AAXD,wDAA6E;AAE7E,4CAAyC;AAEzC,SAAgB,eAAe,CAAC,OAAsB,EAAE,QAAmB,EAAE,QAAkB;IAC3F,MAAM,IAAI,GAAoB,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;IAC1D,MAAM,GAAG,GAAG,GAAG,sBAAU,iBAAiB,QAAQ,CAAC,QAAQ,yBAAyB,CAAA;IACpF,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,MAAM,EAAE,MAAM;QACd,IAAI;KACL,CAAC,CAAA;AACN,CAAC;AAED,SAAS,cAAc,CAAC,OAAgB;IACpC,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAA;IAC/H,MAAM,WAAW,GAAG,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,2BAA2B,EAAE,CAAC,aAAa,CAAC,CAAA;IAEvG,IAAG,OAAO,WAAW,KAAK,SAAS,EAAE,CAAC;QACpC,MAAM,IAAI,qCAAsB,CAAC,4NAA4N,CAAC,CAAA;IAChQ,CAAC;IAED,MAAM,IAAI,GAAkB;QAC1B,WAAW;QACX,aAAa;QACb,MAAM,EAAE,WAAW;QACnB,SAAS;QACT,OAAO;QACP,GAAG,sBAAsB,IAAI,EAAE;KAChC,CAAA;IAED,OAAO,IAAI,CAAA;AACf,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const actions_core_1 = require("@segment/actions-core");
|
|
4
|
-
const
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
5
|
const processData = async (request, settings, payloads) => {
|
|
6
6
|
const events = payloads.map((payload) => {
|
|
7
7
|
if (!payload.livelike_profile_id && !payload.custom_id && !payload.segment_user_id) {
|
|
@@ -9,7 +9,7 @@ const processData = async (request, settings, payloads) => {
|
|
|
9
9
|
}
|
|
10
10
|
return payload;
|
|
11
11
|
});
|
|
12
|
-
return request(`${
|
|
12
|
+
return request(`${constants_1.apiBaseUrl}/applications/${settings.clientId}/segment-events/`, {
|
|
13
13
|
method: 'post',
|
|
14
14
|
json: {
|
|
15
15
|
events
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/livelike-cloud/trackEvent/index.ts"],"names":[],"mappings":";;AAAA,wDAAyF;AAEzF,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/livelike-cloud/trackEvent/index.ts"],"names":[],"mappings":";;AAAA,wDAAyF;AAEzF,4CAAyC;AAGzC,MAAM,WAAW,GAAG,KAAK,EAAE,OAAsB,EAAE,QAAkB,EAAE,QAAmB,EAAE,EAAE;IAC5F,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACtC,IAAI,CAAC,OAAO,CAAC,mBAAmB,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;YACnF,MAAM,IAAI,+BAAgB,CACxB,gEAAgE,EAChE,yBAAyB,EACzB,GAAG,CACJ,CAAA;QACH,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC,CAAC,CAAA;IAEF,OAAO,OAAO,CAAC,GAAG,s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AAO,EAAE,wBAAwB;aAClC;SACF;QAED,SAAS,EAAE;YACT,KAAK,EAAE,WAAW;YAClB,WAAW,EACT,qJAAqJ;YACvJ,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,aAAa;aACvB;SACF;QACD,UAAU,EAAE;YACV,KAAK,EAAE,kBAAkB;YACzB,WAAW,EAAE,0BAA0B;YACvC,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,cAAc;aACxB;SACF;KACF;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC1C,OAAO,WAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IAClD,CAAC;CAQF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Client from 'ssh2-sftp-client';
|
|
2
|
+
import { Settings } from './generated-types';
|
|
3
|
+
declare function uploadSFTP(settings: Settings, sftpFolderPath: string, filename: string, fileContent: Buffer): Promise<unknown>;
|
|
4
|
+
declare function executeSFTPOperation(sftp: Client, settings: Settings, sftpFolderPath: string, action: {
|
|
5
|
+
(sftp: Client): Promise<unknown>;
|
|
6
|
+
}): Promise<unknown>;
|
|
7
|
+
declare function normalizeSSHKey(key?: string): string;
|
|
8
|
+
declare function testSFTPConnection(settings: Settings): Promise<unknown>;
|
|
9
|
+
export { Client, executeSFTPOperation, normalizeSSHKey, testSFTPConnection, uploadSFTP };
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
exports.Client = void 0;
|
|
7
|
+
exports.executeSFTPOperation = executeSFTPOperation;
|
|
8
|
+
exports.normalizeSSHKey = normalizeSSHKey;
|
|
9
|
+
exports.testSFTPConnection = testSFTPConnection;
|
|
10
|
+
exports.uploadSFTP = uploadSFTP;
|
|
11
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const ssh2_sftp_client_1 = __importDefault(require("ssh2-sftp-client"));
|
|
14
|
+
exports.Client = ssh2_sftp_client_1.default;
|
|
15
|
+
const constants_1 = require("./constants");
|
|
16
|
+
var SFTPErrorCode;
|
|
17
|
+
(function (SFTPErrorCode) {
|
|
18
|
+
SFTPErrorCode[SFTPErrorCode["NO_SUCH_FILE"] = 2] = "NO_SUCH_FILE";
|
|
19
|
+
})(SFTPErrorCode || (SFTPErrorCode = {}));
|
|
20
|
+
async function uploadSFTP(settings, sftpFolderPath, filename, fileContent) {
|
|
21
|
+
const sftp = new ssh2_sftp_client_1.default();
|
|
22
|
+
return executeSFTPOperation(sftp, settings, sftpFolderPath, async (sftp) => {
|
|
23
|
+
const targetPath = path_1.default.join(sftpFolderPath, filename);
|
|
24
|
+
return sftp.put(fileContent, targetPath);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async function executeSFTPOperation(sftp, settings, sftpFolderPath, action) {
|
|
28
|
+
const connectionConfig = createConnectionConfig(settings);
|
|
29
|
+
await sftp.connect(connectionConfig);
|
|
30
|
+
let timeoutError;
|
|
31
|
+
const timeout = setTimeout(() => {
|
|
32
|
+
void sftp.end().catch((err) => {
|
|
33
|
+
console.error(err);
|
|
34
|
+
});
|
|
35
|
+
timeoutError = new actions_core_1.SelfTimeoutError(`Did not complete SFTP operation under allotted time: ${actions_core_1.DEFAULT_REQUEST_TIMEOUT}`);
|
|
36
|
+
}, actions_core_1.DEFAULT_REQUEST_TIMEOUT);
|
|
37
|
+
let retVal;
|
|
38
|
+
try {
|
|
39
|
+
retVal = await action(sftp);
|
|
40
|
+
if (timeoutError)
|
|
41
|
+
throw timeoutError;
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
const sftpError = e;
|
|
45
|
+
if (sftpError) {
|
|
46
|
+
if (sftpError.code === SFTPErrorCode.NO_SUCH_FILE) {
|
|
47
|
+
throw new actions_core_1.PayloadValidationError(`Could not find path: ${sftpFolderPath}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
throw e;
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
clearTimeout(timeout);
|
|
54
|
+
if (!timeoutError) {
|
|
55
|
+
await sftp.end();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return retVal;
|
|
59
|
+
}
|
|
60
|
+
function createConnectionConfig(settings) {
|
|
61
|
+
const { auth_type, sftp_ssh_key, sftp_password } = settings;
|
|
62
|
+
const credentialKey = auth_type === 'ssh_key' ? 'privateKey' : 'password';
|
|
63
|
+
const credentialValue = auth_type === 'ssh_key' ? normalizeSSHKey(sftp_ssh_key) : sftp_password;
|
|
64
|
+
return {
|
|
65
|
+
host: settings.sftp_host,
|
|
66
|
+
port: settings.sftp_port || constants_1.SFTP_DEFAULT_PORT,
|
|
67
|
+
username: settings.sftp_username,
|
|
68
|
+
[credentialKey]: credentialValue
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function normalizeSSHKey(key = '') {
|
|
72
|
+
if (!key)
|
|
73
|
+
return key;
|
|
74
|
+
const normalizedKey = key.trim().replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
75
|
+
const properFormat = /-----BEGIN [A-Z\s]+PRIVATE KEY-----\n[\s\S]*?\n-----END [A-Z\s]+PRIVATE KEY-----/;
|
|
76
|
+
const hasProperFormat = properFormat.test(normalizedKey);
|
|
77
|
+
if (hasProperFormat)
|
|
78
|
+
return normalizedKey;
|
|
79
|
+
const headerMatch = normalizedKey.match(/(-----BEGIN [A-Z\s]+PRIVATE KEY-----)/);
|
|
80
|
+
const footerMatch = normalizedKey.match(/(-----END [A-Z\s]+PRIVATE KEY-----)/);
|
|
81
|
+
if (headerMatch && footerMatch) {
|
|
82
|
+
const header = headerMatch[1];
|
|
83
|
+
const footer = footerMatch[1];
|
|
84
|
+
const keyContent = normalizedKey.replace(header, '').replace(footer, '').replace(/\s/g, '');
|
|
85
|
+
const formattedContent = keyContent.replace(/.{64}/g, '$&\n').replace(/\n$/, '');
|
|
86
|
+
return `${header}\n${formattedContent}\n${footer}`;
|
|
87
|
+
}
|
|
88
|
+
return normalizedKey;
|
|
89
|
+
}
|
|
90
|
+
async function testSFTPConnection(settings) {
|
|
91
|
+
const sftp = new ssh2_sftp_client_1.default();
|
|
92
|
+
return executeSFTPOperation(sftp, settings, '/', async (sftp) => {
|
|
93
|
+
return sftp.list('/');
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/destinations/sftp/client.ts"],"names":[],"mappings":";;;;;;AAsLiB,oDAAoB;AAAE,0CAAe;AAAE,gDAAkB;AAAE,gCAAU;AAtLtF,wDAAyG;AACzG,gDAAuB;AACvB,wEAAqC;AAoL5B,iBApLF,0BAAM,CAoLE;AAnLf,2CAA+C;AAI/C,IAAK,aAEJ;AAFD,WAAK,aAAa;IAChB,iEAAgB,CAAA;AAClB,CAAC,EAFI,aAAa,KAAb,aAAa,QAEjB;AAeD,KAAK,UAAU,UAAU,CAAC,QAAkB,EAAE,cAAsB,EAAE,QAAgB,EAAE,WAAmB;IACzG,MAAM,IAAI,GAAG,IAAI,0BAAM,EAAE,CAAA;IACzB,OAAO,oBAAoB,CAAC,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACzE,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAA;QACtD,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,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E,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;QAgB3F,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;QAGhF,OAAO,GAAG,MAAM,KAAK,gBAAgB,KAAK,MAAM,EAAE,CAAA;IACpD,CAAC;IAGD,OAAO,aAAa,CAAA;AACtB,CAAC;AAKD,KAAK,UAAU,kBAAkB,CAAC,QAAkB;IAClD,MAAM,IAAI,GAAG,IAAI,0BAAM,EAAE,CAAA;IACzB,OAAO,oBAAoB,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAG9D,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACvB,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SFTP_DEFAULT_PORT = 22;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/destinations/sftp/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG,EAAE,CAAA"}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.commonFields = exports.baseFields = void 0;
|
|
4
|
+
const batch_size_column_name = {
|
|
5
|
+
label: 'Batch Size Column Name',
|
|
6
|
+
description: 'Specify the column name to store the batch size when the event is sent to SFTP. Leave blank if no column is required',
|
|
7
|
+
type: 'string',
|
|
8
|
+
required: false,
|
|
9
|
+
disabledInputMethods: ['variable', 'function', 'enrichment'],
|
|
10
|
+
default: 'batch_size'
|
|
11
|
+
};
|
|
12
|
+
const audience_action_column_name = {
|
|
13
|
+
label: 'Audience Action Column Name',
|
|
14
|
+
description: 'Name of the column to contain the action for the audience. true if the user is in the audience, false if not.',
|
|
15
|
+
type: 'string',
|
|
16
|
+
required: false,
|
|
17
|
+
disabledInputMethods: ['variable', 'function', 'enrichment'],
|
|
18
|
+
default: 'audience_action'
|
|
19
|
+
};
|
|
20
|
+
const traits_or_props = {
|
|
21
|
+
label: 'Traits or Props - Hidden Field',
|
|
22
|
+
description: 'Hidden field used to retrieve Audience action value',
|
|
23
|
+
type: 'object',
|
|
24
|
+
required: false,
|
|
25
|
+
unsafe_hidden: true,
|
|
26
|
+
default: {
|
|
27
|
+
'@if': {
|
|
28
|
+
exists: { '@path': '$.properties' },
|
|
29
|
+
then: { '@path': '$.properties' },
|
|
30
|
+
else: { '@path': '$.traits' }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const computation_key = {
|
|
35
|
+
label: 'Audience_Key - Hidden Field',
|
|
36
|
+
description: 'Hidden field used to retrieve Audience Key',
|
|
37
|
+
type: 'string',
|
|
38
|
+
required: false,
|
|
39
|
+
unsafe_hidden: true,
|
|
40
|
+
default: { '@path': '$.context.personas.computation_key' }
|
|
41
|
+
};
|
|
42
|
+
const enable_batching = {
|
|
43
|
+
type: 'boolean',
|
|
44
|
+
label: 'Enable Batching',
|
|
45
|
+
description: 'Enable Batching Hidden Field',
|
|
46
|
+
unsafe_hidden: true,
|
|
47
|
+
required: true,
|
|
48
|
+
default: true
|
|
49
|
+
};
|
|
50
|
+
const batch_size = {
|
|
51
|
+
label: 'Batch Size',
|
|
52
|
+
description: 'Maximum number of events to include in each batch. Actual batch sizes may be lower.',
|
|
53
|
+
type: 'number',
|
|
54
|
+
required: true,
|
|
55
|
+
default: 100000,
|
|
56
|
+
minimum: 1,
|
|
57
|
+
maximum: 100000
|
|
58
|
+
};
|
|
59
|
+
const sftp_folder_path = {
|
|
60
|
+
label: 'Folder Path',
|
|
61
|
+
description: 'Path within the SFTP server to upload the files to. This path must exist and all subfolders must be pre-created.',
|
|
62
|
+
type: 'string',
|
|
63
|
+
required: true,
|
|
64
|
+
default: { '@template': '/' }
|
|
65
|
+
};
|
|
66
|
+
const filename_prefix = {
|
|
67
|
+
label: 'Filename prefix',
|
|
68
|
+
description: `Prefix to prepend to the name of the uploaded file. Timestamp will be appended to the filename.`,
|
|
69
|
+
type: 'string',
|
|
70
|
+
required: true
|
|
71
|
+
};
|
|
72
|
+
const delimiter = {
|
|
73
|
+
label: 'Delimiter',
|
|
74
|
+
description: `Character used to separate tokens in the resulting file.`,
|
|
75
|
+
type: 'string',
|
|
76
|
+
required: true,
|
|
77
|
+
disabledInputMethods: ['enrichment', 'function', 'variable'],
|
|
78
|
+
choices: [
|
|
79
|
+
{ label: 'comma', value: ',' },
|
|
80
|
+
{ label: 'pipe', value: '|' },
|
|
81
|
+
{ label: 'tab', value: 'tab' },
|
|
82
|
+
{ label: 'semicolon', value: ';' },
|
|
83
|
+
{ label: 'colon', value: ':' }
|
|
84
|
+
],
|
|
85
|
+
default: ','
|
|
86
|
+
};
|
|
87
|
+
const file_extension = {
|
|
88
|
+
label: 'File Extension',
|
|
89
|
+
description: `File extension for the uploaded file.`,
|
|
90
|
+
type: 'string',
|
|
91
|
+
required: true,
|
|
92
|
+
choices: [
|
|
93
|
+
{ label: 'csv', value: 'csv' },
|
|
94
|
+
{ label: 'txt', value: 'txt' },
|
|
95
|
+
{ label: 'tsv', value: 'tsv' },
|
|
96
|
+
{ label: 'psv', value: 'psv' }
|
|
97
|
+
],
|
|
98
|
+
default: 'csv'
|
|
99
|
+
};
|
|
100
|
+
const columnsWithDefaultMappings = {
|
|
101
|
+
label: 'Columns',
|
|
102
|
+
description: `Column headers to write to files sent to SFTP.`,
|
|
103
|
+
type: 'object',
|
|
104
|
+
defaultObjectUI: 'keyvalue',
|
|
105
|
+
required: true,
|
|
106
|
+
additionalProperties: true,
|
|
107
|
+
properties: {
|
|
108
|
+
event_name: {
|
|
109
|
+
label: 'Event Name',
|
|
110
|
+
description: 'Name of the event.',
|
|
111
|
+
type: 'string'
|
|
112
|
+
},
|
|
113
|
+
event_type: {
|
|
114
|
+
label: 'Event Type',
|
|
115
|
+
description: 'The type of event',
|
|
116
|
+
type: 'string'
|
|
117
|
+
},
|
|
118
|
+
user_id: {
|
|
119
|
+
label: 'User ID',
|
|
120
|
+
description: 'User ID',
|
|
121
|
+
type: 'string'
|
|
122
|
+
},
|
|
123
|
+
anonymous_id: {
|
|
124
|
+
label: 'Anonymous ID',
|
|
125
|
+
description: 'Anonymous ID',
|
|
126
|
+
type: 'string'
|
|
127
|
+
},
|
|
128
|
+
email: {
|
|
129
|
+
label: 'Email',
|
|
130
|
+
description: 'Email address',
|
|
131
|
+
type: 'string'
|
|
132
|
+
},
|
|
133
|
+
properties: {
|
|
134
|
+
label: 'Properties',
|
|
135
|
+
description: 'Properties of the event',
|
|
136
|
+
type: 'object'
|
|
137
|
+
},
|
|
138
|
+
traits: {
|
|
139
|
+
label: 'Traits',
|
|
140
|
+
description: 'User traits',
|
|
141
|
+
type: 'object'
|
|
142
|
+
},
|
|
143
|
+
context: {
|
|
144
|
+
label: 'Context',
|
|
145
|
+
description: 'Context of the event',
|
|
146
|
+
type: 'object'
|
|
147
|
+
},
|
|
148
|
+
timestamp: {
|
|
149
|
+
label: 'Timestamp',
|
|
150
|
+
description: 'Timestamp of the event',
|
|
151
|
+
type: 'string'
|
|
152
|
+
},
|
|
153
|
+
message_id: {
|
|
154
|
+
label: 'Message ID',
|
|
155
|
+
description: 'Name of column for the unique identifier for the message.',
|
|
156
|
+
type: 'string'
|
|
157
|
+
},
|
|
158
|
+
integrations: {
|
|
159
|
+
label: 'Integrations Object',
|
|
160
|
+
description: 'Name of column for the Integration Object. This contains JSON details of which destinations the event was synced to by Segment',
|
|
161
|
+
type: 'object'
|
|
162
|
+
},
|
|
163
|
+
audience_name: {
|
|
164
|
+
label: 'Audience Name',
|
|
165
|
+
description: 'Name of the audience',
|
|
166
|
+
type: 'string'
|
|
167
|
+
},
|
|
168
|
+
audience_id: {
|
|
169
|
+
label: 'Audience ID',
|
|
170
|
+
description: 'ID of the audience',
|
|
171
|
+
type: 'string'
|
|
172
|
+
},
|
|
173
|
+
audience_space_id: {
|
|
174
|
+
label: 'Audience Space ID',
|
|
175
|
+
description: 'ID of the Engage Space where the Audience was generated',
|
|
176
|
+
type: 'string'
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
default: {
|
|
180
|
+
event_name: {
|
|
181
|
+
'@path': '$.event'
|
|
182
|
+
},
|
|
183
|
+
event_type: {
|
|
184
|
+
'@path': '$.type'
|
|
185
|
+
},
|
|
186
|
+
user_id: {
|
|
187
|
+
'@path': '$.userId'
|
|
188
|
+
},
|
|
189
|
+
anonymous_id: {
|
|
190
|
+
'@path': '$.anonymousId'
|
|
191
|
+
},
|
|
192
|
+
email: {
|
|
193
|
+
'@if': {
|
|
194
|
+
exists: { '@path': '$.traits.email' },
|
|
195
|
+
then: { '@path': '$.traits.email' },
|
|
196
|
+
else: { '@path': '$.context.traits.email' }
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
properties: {
|
|
200
|
+
'@path': '$.properties'
|
|
201
|
+
},
|
|
202
|
+
traits: {
|
|
203
|
+
'@if': {
|
|
204
|
+
exists: { '@path': '$.traits' },
|
|
205
|
+
then: { '@path': '$.traits' },
|
|
206
|
+
else: { '@path': '$.context.traits' }
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
context: {
|
|
210
|
+
'@path': '$.context'
|
|
211
|
+
},
|
|
212
|
+
timestamp: {
|
|
213
|
+
'@path': '$.timestamp'
|
|
214
|
+
},
|
|
215
|
+
message_id: {
|
|
216
|
+
'@path': '$.messageId'
|
|
217
|
+
},
|
|
218
|
+
integrations: {
|
|
219
|
+
'@path': '$.integrations'
|
|
220
|
+
},
|
|
221
|
+
audience_name: {
|
|
222
|
+
'@path': '$.context.personas.computation_key'
|
|
223
|
+
},
|
|
224
|
+
audience_id: {
|
|
225
|
+
'@path': '$.context.personas.computation_id'
|
|
226
|
+
},
|
|
227
|
+
audience_space_id: {
|
|
228
|
+
'@path': '$.context.personas.space_id'
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
const columnsNoDefaultMappings = {
|
|
233
|
+
label: 'Columns',
|
|
234
|
+
description: `Column headers to write to files sent to SFTP.`,
|
|
235
|
+
type: 'object',
|
|
236
|
+
defaultObjectUI: 'keyvalue',
|
|
237
|
+
required: true,
|
|
238
|
+
additionalProperties: true
|
|
239
|
+
};
|
|
240
|
+
const audienceFields = {
|
|
241
|
+
audience_action_column_name,
|
|
242
|
+
traits_or_props,
|
|
243
|
+
computation_key
|
|
244
|
+
};
|
|
245
|
+
exports.baseFields = {
|
|
246
|
+
columns: columnsNoDefaultMappings,
|
|
247
|
+
filename_prefix,
|
|
248
|
+
file_extension,
|
|
249
|
+
delimiter,
|
|
250
|
+
sftp_folder_path,
|
|
251
|
+
enable_batching,
|
|
252
|
+
batch_size,
|
|
253
|
+
batch_size_column_name
|
|
254
|
+
};
|
|
255
|
+
exports.commonFields = {
|
|
256
|
+
...exports.baseFields,
|
|
257
|
+
columns: columnsWithDefaultMappings,
|
|
258
|
+
...audienceFields
|
|
259
|
+
};
|
|
260
|
+
//# sourceMappingURL=fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../src/destinations/sftp/fields.ts"],"names":[],"mappings":";;;AAEA,MAAM,sBAAsB,GAAe;IACzC,KAAK,EAAE,wBAAwB;IAC/B,WAAW,EACT,sHAAsH;IACxH,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,KAAK;IACf,oBAAoB,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC;IAC5D,OAAO,EAAE,YAAY;CACtB,CAAA;AACD,MAAM,2BAA2B,GAAe;IAC9C,KAAK,EAAE,6BAA6B;IACpC,WAAW,EACT,+GAA+G;IACjH,IAAI,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F,CAAA;AACD,MAAM,wBAAwB,GAAe;IAC3C,KAAK,EAAE,SAAS;IAChB,WAAW,EAAE,gDAAgD;IAC7D,IAAI,EAAE,QAAQ;IACd,eAAe,EAAE,UAAU;IAC3B,QAAQ,EAAE,IAAI;IACd,oBAAoB,EAAE,IAAI;CAC3B,CAAA;AACD,MAAM,cAAc,GAA+B;IACjD,2BAA2B;IAC3B,eAAe;IACf,eAAe;CAChB,CAAA;AACY,QAAA,UAAU,GAA+B;IACpD,OAAO,EAAE,wBAAwB;IACjC,eAAe;IACf,cAAc;IACd,SAAS;IACT,gBAAgB;IAChB,eAAe;IACf,UAAU;IACV,sBAAsB;CACvB,CAAA;AACY,QAAA,YAAY,GAA+B;IACtD,GAAG,kBAAU;IACb,OAAO,EAAE,0BAA0B;IACnC,GAAG,cAAc;CAClB,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MultiStatusResponse } from '@segment/actions-core';
|
|
2
|
+
import { Settings } from './generated-types';
|
|
3
|
+
import { Payload } from './syncEvents/generated-types';
|
|
4
|
+
import { ColumnHeader, RawMapping } from './types';
|
|
5
|
+
declare function send(payloads: Payload[], settings: Settings, rawMapping: RawMapping): Promise<MultiStatusResponse>;
|
|
6
|
+
declare function clean(delimiter: string, str?: string): string;
|
|
7
|
+
declare function createHeaders(rawMapping: RawMapping, delimiter: string, audienceActionColumnName?: string, batchSizeColumnName?: string): ColumnHeader[];
|
|
8
|
+
declare function createFilename(filename_prefix: string, file_extension: string): string;
|
|
9
|
+
declare function generateFile(payloads: Payload[], headers: ColumnHeader[], delimiter: string, rowsArray: string[], actionColName?: string, batchColName?: string): Buffer;
|
|
10
|
+
declare function processField(value: unknown | undefined): string;
|
|
11
|
+
declare function getAudienceAction(payload: Payload): boolean | undefined;
|
|
12
|
+
declare function enquoteIdentifier(identifier: string): string;
|
|
13
|
+
export { clean, createFilename, createHeaders, enquoteIdentifier, generateFile, getAudienceAction, processField, send };
|