@segment/action-destinations 3.416.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.
Files changed (94) hide show
  1. package/dist/destinations/attentive/fields.js +1 -15
  2. package/dist/destinations/attentive/fields.js.map +1 -1
  3. package/dist/destinations/attentive/functions.js +1 -1
  4. package/dist/destinations/attentive/functions.js.map +1 -1
  5. package/dist/destinations/attentive/types.d.ts +4 -1
  6. package/dist/destinations/batch/generated-types.d.ts +4 -0
  7. package/dist/destinations/batch/generated-types.js +3 -0
  8. package/dist/destinations/batch/generated-types.js.map +1 -0
  9. package/dist/destinations/batch/index.d.ts +4 -0
  10. package/dist/destinations/batch/index.js +64 -0
  11. package/dist/destinations/batch/index.js.map +1 -0
  12. package/dist/destinations/batch/updateProfile/constants.d.ts +2 -0
  13. package/dist/destinations/batch/updateProfile/constants.js +6 -0
  14. package/dist/destinations/batch/updateProfile/constants.js.map +1 -0
  15. package/dist/destinations/batch/updateProfile/generated-types.d.ts +22 -0
  16. package/dist/destinations/batch/updateProfile/generated-types.js +3 -0
  17. package/dist/destinations/batch/updateProfile/generated-types.js.map +1 -0
  18. package/dist/destinations/batch/updateProfile/index.d.ts +5 -0
  19. package/dist/destinations/batch/updateProfile/index.js +169 -0
  20. package/dist/destinations/batch/updateProfile/index.js.map +1 -0
  21. package/dist/destinations/batch/updateProfile/type.d.ts +31 -0
  22. package/dist/destinations/batch/updateProfile/type.js +3 -0
  23. package/dist/destinations/batch/updateProfile/type.js.map +1 -0
  24. package/dist/destinations/batch/updateProfile/utils.d.ts +6 -0
  25. package/dist/destinations/batch/updateProfile/utils.js +129 -0
  26. package/dist/destinations/batch/updateProfile/utils.js.map +1 -0
  27. package/dist/destinations/bing-ads-audiences/generated-types.d.ts +2 -0
  28. package/dist/destinations/bing-ads-audiences/generated-types.js +3 -0
  29. package/dist/destinations/bing-ads-audiences/generated-types.js.map +1 -0
  30. package/dist/destinations/bing-ads-audiences/index.d.ts +4 -0
  31. package/dist/destinations/bing-ads-audiences/index.js +34 -0
  32. package/dist/destinations/bing-ads-audiences/index.js.map +1 -0
  33. package/dist/destinations/bing-ads-audiences/syncAudiences/generated-types.d.ts +2 -0
  34. package/dist/destinations/bing-ads-audiences/syncAudiences/generated-types.js +3 -0
  35. package/dist/destinations/bing-ads-audiences/syncAudiences/generated-types.js.map +1 -0
  36. package/dist/destinations/bing-ads-audiences/syncAudiences/index.d.ts +5 -0
  37. package/dist/destinations/bing-ads-audiences/syncAudiences/index.js +15 -0
  38. package/dist/destinations/bing-ads-audiences/syncAudiences/index.js.map +1 -0
  39. package/dist/destinations/braze/index.js +1 -1
  40. package/dist/destinations/braze/index.js.map +1 -1
  41. package/dist/destinations/epsilon/sendEvent/fields.js +4 -2
  42. package/dist/destinations/epsilon/sendEvent/fields.js.map +1 -1
  43. package/dist/destinations/index.js +3 -0
  44. package/dist/destinations/index.js.map +1 -1
  45. package/dist/destinations/klaviyo/functions.d.ts +2 -2
  46. package/dist/destinations/klaviyo/functions.js +5 -4
  47. package/dist/destinations/klaviyo/functions.js.map +1 -1
  48. package/dist/destinations/klaviyo/subscribeProfile/generated-types.d.ts +1 -0
  49. package/dist/destinations/klaviyo/subscribeProfile/index.js +13 -7
  50. package/dist/destinations/klaviyo/subscribeProfile/index.js.map +1 -1
  51. package/dist/destinations/klaviyo/types.d.ts +1 -0
  52. package/dist/destinations/livelike-cloud/syncToUserGroup/generated-types.d.ts +1 -0
  53. package/dist/destinations/livelike-cloud/syncToUserGroup/index.js +7 -1
  54. package/dist/destinations/livelike-cloud/syncToUserGroup/index.js.map +1 -1
  55. package/dist/destinations/sftp/client.d.ts +9 -0
  56. package/dist/destinations/sftp/client.js +96 -0
  57. package/dist/destinations/sftp/client.js.map +1 -0
  58. package/dist/destinations/sftp/constants.d.ts +1 -0
  59. package/dist/destinations/sftp/constants.js +5 -0
  60. package/dist/destinations/sftp/constants.js.map +1 -0
  61. package/dist/destinations/sftp/fields.d.ts +3 -0
  62. package/dist/destinations/sftp/fields.js +260 -0
  63. package/dist/destinations/sftp/fields.js.map +1 -0
  64. package/dist/destinations/sftp/functions.d.ts +13 -0
  65. package/dist/destinations/sftp/functions.js +116 -0
  66. package/dist/destinations/sftp/functions.js.map +1 -0
  67. package/dist/destinations/sftp/generated-types.d.ts +8 -0
  68. package/dist/destinations/sftp/generated-types.js +3 -0
  69. package/dist/destinations/sftp/generated-types.js.map +1 -0
  70. package/dist/destinations/sftp/index.d.ts +4 -0
  71. package/dist/destinations/sftp/index.js +103 -0
  72. package/dist/destinations/sftp/index.js.map +1 -0
  73. package/dist/destinations/sftp/syncEvents/generated-types.d.ts +39 -0
  74. package/dist/destinations/sftp/syncEvents/generated-types.js +3 -0
  75. package/dist/destinations/sftp/syncEvents/generated-types.js.map +1 -0
  76. package/dist/destinations/sftp/syncEvents/index.d.ts +5 -0
  77. package/dist/destinations/sftp/syncEvents/index.js +22 -0
  78. package/dist/destinations/sftp/syncEvents/index.js.map +1 -0
  79. package/dist/destinations/sftp/syncModelToSFTP/generated-types.d.ts +12 -0
  80. package/dist/destinations/sftp/syncModelToSFTP/generated-types.js +3 -0
  81. package/dist/destinations/sftp/syncModelToSFTP/generated-types.js.map +1 -0
  82. package/dist/destinations/sftp/syncModelToSFTP/index.d.ts +5 -0
  83. package/dist/destinations/sftp/syncModelToSFTP/index.js +22 -0
  84. package/dist/destinations/sftp/syncModelToSFTP/index.js.map +1 -0
  85. package/dist/destinations/sftp/types.d.ts +40 -0
  86. package/dist/destinations/sftp/types.js +3 -0
  87. package/dist/destinations/sftp/types.js.map +1 -0
  88. package/dist/destinations/twilio-messaging/sendMessage/dynamic-fields.js +5 -0
  89. package/dist/destinations/twilio-messaging/sendMessage/dynamic-fields.js.map +1 -1
  90. package/dist/destinations/twilio-messaging/sendMessage/fields.js +11 -2
  91. package/dist/destinations/twilio-messaging/sendMessage/fields.js.map +1 -1
  92. package/dist/destinations/twilio-messaging/sendMessage/utils.js +4 -4
  93. package/dist/destinations/twilio-messaging/sendMessage/utils.js.map +1 -1
  94. package/package.json +2 -2
@@ -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,EAAE,UAAU,CAAC,CAAA;IAC1C,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,KAAK,UAAU,oBAAoB,CACjC,IAAY,EACZ,QAAkB,EAClB,cAAsB,EACtB,MAA4C;IAE5C,MAAM,gBAAgB,GAAG,sBAAsB,CAAC,QAAQ,CAAC,CAAA;IACzD,MAAM,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAEpC,IAAI,YAAY,CAAA;IAChB,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;QAC9B,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YAC5B,OAAO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AAA;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,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SFTP_DEFAULT_PORT = void 0;
4
+ exports.SFTP_DEFAULT_PORT = 22;
5
+ //# sourceMappingURL=constants.js.map
@@ -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,3 @@
1
+ import { InputField } from '@segment/actions-core';
2
+ export declare const baseFields: Record<string, InputField>;
3
+ export declare const commonFields: Record<string, InputField>;
@@ -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","sour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kBAAkB,EAAE;aACtC;SACF;QACD,OAAO,EAAE;YACP,OAAO,EAAE,WAAW;SACrB;QACD,SAAS,EAAE;YACT,OAAO,EAAE,aAAa;SACvB;QACD,UAAU,EAAE;YACV,OAAO,EAAE,aAAa;SACvB;QACD,YAAY,EAAE;YACZ,OAAO,EAAE,gBAAgB;SAC1B;QACD,aAAa,EAAE;YACb,OAAO,EAAE,oCAAoC;SAC9C;QACD,WAAW,EAAE;YACX,OAAO,EAAE,mCAAmC;SAC7C;QACD,iBAAiB,EAAE;YACjB,OAAO,EAAE,6BAA6B;SACvC;KACF;CACF,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 };
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clean = clean;
4
+ exports.createFilename = createFilename;
5
+ exports.createHeaders = createHeaders;
6
+ exports.enquoteIdentifier = enquoteIdentifier;
7
+ exports.generateFile = generateFile;
8
+ exports.getAudienceAction = getAudienceAction;
9
+ exports.processField = processField;
10
+ exports.send = send;
11
+ const actions_core_1 = require("@segment/actions-core");
12
+ const client_1 = require("./client");
13
+ async function send(payloads, settings, rawMapping) {
14
+ const { delimiter, audience_action_column_name, batch_size_column_name, filename_prefix, file_extension, sftp_folder_path } = payloads[0];
15
+ const headers = createHeaders(rawMapping, delimiter, audience_action_column_name, batch_size_column_name);
16
+ const rowsObservabilityArray = [];
17
+ const fileContent = generateFile(payloads, headers, delimiter, rowsObservabilityArray, audience_action_column_name, batch_size_column_name);
18
+ const filename = createFilename(filename_prefix, file_extension);
19
+ const msResponse = new actions_core_1.MultiStatusResponse();
20
+ try {
21
+ await (0, client_1.uploadSFTP)(settings, sftp_folder_path, filename, fileContent);
22
+ payloads.forEach((payload, index) => {
23
+ const row = rowsObservabilityArray[index] ?? '';
24
+ msResponse.setSuccessResponseAtIndex(index, {
25
+ status: 200,
26
+ sent: payload,
27
+ body: `Header row = ${headers.map((header) => header.cleanName) ?? 'Headers not found'}. Row content =${row ?? 'Row content not found'}`
28
+ });
29
+ });
30
+ }
31
+ catch (error) {
32
+ payloads.forEach((payload, index) => {
33
+ const row = rowsObservabilityArray[index] ?? '';
34
+ msResponse.setErrorResponseAtIndex(index, {
35
+ status: error?.status || 400,
36
+ errortype: error?.code || actions_core_1.ErrorCodes.BAD_REQUEST,
37
+ errormessage: error?.message ?? 'Failed to upload file to SFTP',
38
+ sent: payload,
39
+ body: `Header row = ${headers.map((header) => header.cleanName) ?? 'Headers not found'}. Row content =${row ?? 'Row content not found'}`
40
+ });
41
+ });
42
+ }
43
+ return msResponse;
44
+ }
45
+ function clean(delimiter, str = '') {
46
+ return delimiter === 'tab' ? str : str.replace(delimiter, '');
47
+ }
48
+ function createHeaders(rawMapping, delimiter, audienceActionColumnName, batchSizeColumnName) {
49
+ const createHeader = (columnName) => ({
50
+ cleanName: clean(delimiter, columnName),
51
+ originalName: columnName
52
+ });
53
+ const headers = [];
54
+ Object.entries(rawMapping.columns)
55
+ .filter(([_, value]) => value !== '')
56
+ .forEach(([column]) => {
57
+ headers.push(createHeader(column));
58
+ });
59
+ if (audienceActionColumnName)
60
+ headers.push(createHeader(audienceActionColumnName));
61
+ if (batchSizeColumnName)
62
+ headers.push(createHeader(batchSizeColumnName));
63
+ if (headers.length === 0) {
64
+ throw new actions_core_1.PayloadValidationError('No columns headers specified');
65
+ }
66
+ return headers;
67
+ }
68
+ function createFilename(filename_prefix, file_extension) {
69
+ const dateSuffix = new Date().toISOString().replace(/[:.]/g, '-');
70
+ switch (true) {
71
+ case filename_prefix.endsWith(`.${file_extension}`):
72
+ return filename_prefix.replace(`.${file_extension}`, `__${dateSuffix}.${file_extension}`);
73
+ case filename_prefix !== '':
74
+ return `${filename_prefix}__${dateSuffix}.${file_extension}`;
75
+ default:
76
+ return `${dateSuffix}.${file_extension}`;
77
+ }
78
+ }
79
+ function generateFile(payloads, headers, delimiter, rowsArray, actionColName, batchColName) {
80
+ const rows = payloads.map((payload, index) => {
81
+ const isLastRow = index === payloads.length - 1;
82
+ const row = headers.map((header) => {
83
+ switch (header.originalName) {
84
+ case actionColName:
85
+ return processField(getAudienceAction(payload));
86
+ case batchColName:
87
+ return processField(payloads.length);
88
+ default:
89
+ return processField(payload.columns[header.originalName]);
90
+ }
91
+ });
92
+ return Buffer.from(`${row.join(delimiter === 'tab' ? '\t' : delimiter)}${isLastRow ? '' : '\n'}`);
93
+ });
94
+ rowsArray.push(...rows.map((row) => row.toString()));
95
+ return Buffer.concat([
96
+ Buffer.from(`${headers.map((header) => header.cleanName).join(delimiter === 'tab' ? '\t' : delimiter)}\n`),
97
+ ...rows
98
+ ]);
99
+ }
100
+ function processField(value) {
101
+ return enquoteIdentifier(value === undefined || value === null
102
+ ? ''
103
+ : typeof value === 'object'
104
+ ? String(JSON.stringify(value))
105
+ : String(value));
106
+ }
107
+ function getAudienceAction(payload) {
108
+ if (!payload.traits_or_props || !payload.computation_key) {
109
+ return undefined;
110
+ }
111
+ return payload?.traits_or_props?.[payload.computation_key] ?? undefined;
112
+ }
113
+ function enquoteIdentifier(identifier) {
114
+ return `"${String(identifier).replace(/"/g, '""')}"`;
115
+ }
116
+ //# sourceMappingURL=functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/destinations/sftp/functions.ts"],"names":[],"mappings":";;AAoLS,sBAAK;AAAE,wCAAc;AAAE,sCAAa;AAAE,8CAAiB;AAAE,oCAAY;AAAE,8CAAiB;AAAE,oCAAY;AAAE,oBAAI;AApLrH,wDAA+G;AAC/G,qCAAqC;AAKrC,KAAK,UAAU,IAAI,CAAC,QAAmB,EAAE,QAAkB,EAAE,UAAsB;IACjF,MAAM,EACJ,SAAS,EACT,2BAA2B,EAC3B,sBAAsB,EACtB,eAAe,EACf,cAAc,EACd,gBAAgB,EACjB,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IAEf,MAAM,OAAO,GAAmB,aAAa,CAC3C,UAAU,EACV,SAAS,EACT,2BAA2B,EAC3B,sBAAsB,CACvB,CAAA;IACD,MAAM,sBAAsB,GAAa,EAAE,CAAA;IAC3C,MAAM,WAAW,GAAG,YAAY,CAC9B,QAAQ,EACR,OAAO,EACP,SAAS,EACT,sBAAsB,EACtB,2BAA2B,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,IAAI,EAAE,IAAI,CAAC,GAAG,CAAA;AACtD,CAAC"}
@@ -0,0 +1,8 @@
1
+ export interface Settings {
2
+ auth_type: string;
3
+ sftp_host: string;
4
+ sftp_port?: number;
5
+ sftp_username: string;
6
+ sftp_password?: string;
7
+ sftp_ssh_key?: string;
8
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/destinations/sftp/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { DestinationDefinition } from '@segment/actions-core';
2
+ import type { Settings } from './generated-types';
3
+ declare const destination: DestinationDefinition<Settings>;
4
+ export default destination;
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const client_1 = require("./client");
7
+ const constants_1 = require("./constants");
8
+ const syncEvents_1 = __importDefault(require("./syncEvents"));
9
+ const syncModelToSFTP_1 = __importDefault(require("./syncModelToSFTP"));
10
+ const destination = {
11
+ name: 'SFTP',
12
+ slug: 'actions-sftp',
13
+ mode: 'cloud',
14
+ description: 'Sync Segment events to SFTP',
15
+ authentication: {
16
+ scheme: 'custom',
17
+ fields: {
18
+ auth_type: {
19
+ label: 'Authentication Type',
20
+ description: 'The type of authentication to use for the SFTP connection',
21
+ type: 'string',
22
+ choices: [
23
+ { label: 'Username and Password', value: 'password' },
24
+ { label: 'Username and SSH Key', value: 'ssh_key' }
25
+ ],
26
+ default: 'password',
27
+ required: true
28
+ },
29
+ sftp_host: {
30
+ label: 'SFTP Host',
31
+ description: 'The hostname or IP address of the SFTP server',
32
+ type: 'string',
33
+ required: true
34
+ },
35
+ sftp_port: {
36
+ label: 'SFTP Port',
37
+ description: 'The port number for the SFTP connection',
38
+ type: 'number',
39
+ required: false,
40
+ default: constants_1.SFTP_DEFAULT_PORT
41
+ },
42
+ sftp_username: {
43
+ label: 'Username',
44
+ description: 'Username for establishing an SFTP connection',
45
+ type: 'string',
46
+ required: true
47
+ },
48
+ sftp_password: {
49
+ label: 'Password',
50
+ description: 'Password for establishing an SFTP connection',
51
+ type: 'password',
52
+ required: {
53
+ conditions: [
54
+ {
55
+ fieldKey: 'auth_type',
56
+ operator: 'is',
57
+ value: 'password'
58
+ }
59
+ ]
60
+ },
61
+ depends_on: {
62
+ conditions: [
63
+ {
64
+ fieldKey: 'auth_type',
65
+ operator: 'is',
66
+ value: 'password'
67
+ }
68
+ ]
69
+ }
70
+ },
71
+ sftp_ssh_key: {
72
+ label: 'SSH Key',
73
+ description: 'SSH Key for establishing an SFTP connection',
74
+ type: 'password',
75
+ required: {
76
+ conditions: [
77
+ {
78
+ fieldKey: 'auth_type',
79
+ operator: 'is',
80
+ value: 'ssh_key'
81
+ }
82
+ ]
83
+ },
84
+ depends_on: {
85
+ conditions: [
86
+ {
87
+ fieldKey: 'auth_type',
88
+ operator: 'is',
89
+ value: 'ssh_key'
90
+ }
91
+ ]
92
+ }
93
+ }
94
+ },
95
+ testAuthentication: async (_, { settings }) => await (0, client_1.testSFTPConnection)(settings)
96
+ },
97
+ actions: {
98
+ syncEvents: syncEvents_1.default,
99
+ syncModelToSFTP: syncModelToSFTP_1.default
100
+ }
101
+ };
102
+ exports.default = destination;
103
+ //# sourceMappingURL=index.js.map