@segment/action-destinations 3.409.0 → 3.411.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/aampe/constants.d.ts +3 -0
- package/dist/destinations/aampe/constants.js +7 -0
- package/dist/destinations/aampe/constants.js.map +1 -0
- package/dist/destinations/aampe/fields.d.ts +8 -0
- package/dist/destinations/aampe/fields.js +71 -0
- package/dist/destinations/aampe/fields.js.map +1 -0
- package/dist/destinations/aampe/generated-types.d.ts +4 -0
- package/dist/destinations/aampe/generated-types.js +3 -0
- package/dist/destinations/aampe/generated-types.js.map +1 -0
- package/dist/destinations/aampe/index.d.ts +4 -0
- package/dist/destinations/aampe/index.js +66 -0
- package/dist/destinations/aampe/index.js.map +1 -0
- package/dist/destinations/aampe/sendEvent/generated-types.d.ts +10 -0
- package/dist/destinations/aampe/sendEvent/generated-types.js +3 -0
- package/dist/destinations/aampe/sendEvent/generated-types.js.map +1 -0
- package/dist/destinations/aampe/sendEvent/index.d.ts +5 -0
- package/dist/destinations/aampe/sendEvent/index.js +33 -0
- package/dist/destinations/aampe/sendEvent/index.js.map +1 -0
- package/dist/destinations/aampe/types.d.ts +11 -0
- package/dist/destinations/aampe/types.js +3 -0
- package/dist/destinations/aampe/types.js.map +1 -0
- package/dist/destinations/aampe/upsertUserProfile/generated-types.d.ts +12 -0
- package/dist/destinations/aampe/upsertUserProfile/generated-types.js +3 -0
- package/dist/destinations/aampe/upsertUserProfile/generated-types.js.map +1 -0
- package/dist/destinations/aampe/upsertUserProfile/index.d.ts +5 -0
- package/dist/destinations/aampe/upsertUserProfile/index.js +40 -0
- package/dist/destinations/aampe/upsertUserProfile/index.js.map +1 -0
- package/dist/destinations/amazon-amc/syncAudiencesToDSP/index.js +4 -3
- package/dist/destinations/amazon-amc/syncAudiencesToDSP/index.js.map +1 -1
- package/dist/destinations/amazon-conversions-api/trackConversion/fields.js +81 -45
- package/dist/destinations/amazon-conversions-api/trackConversion/fields.js.map +1 -1
- package/dist/destinations/amazon-conversions-api/trackConversion/generated-types.d.ts +15 -6
- package/dist/destinations/amazon-conversions-api/trackConversion/utils.js +13 -4
- package/dist/destinations/amazon-conversions-api/trackConversion/utils.js.map +1 -1
- package/dist/destinations/amazon-conversions-api/types.d.ts +0 -3
- package/dist/destinations/amazon-conversions-api/types.js.map +1 -1
- package/dist/destinations/attentive/customEvents/index.js +1 -1
- package/dist/destinations/attentive/customEvents/index.js.map +1 -1
- package/dist/destinations/attentive/index.js +2 -2
- package/dist/destinations/braze-cohorts/api/index.js +6 -1
- package/dist/destinations/braze-cohorts/api/index.js.map +1 -1
- package/dist/destinations/braze-cohorts/syncAudiences/index.js +65 -6
- package/dist/destinations/braze-cohorts/syncAudiences/index.js.map +1 -1
- package/dist/destinations/eagleeye-audiences/triggerBehavioralAction/index.js +2 -2
- package/dist/destinations/eagleeye-audiences/triggerBehavioralAction/index.js.map +1 -1
- package/dist/destinations/index.js +1 -0
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/singlestore/generated-types.d.ts +2 -2
- package/dist/destinations/singlestore/index.js +46 -58
- package/dist/destinations/singlestore/index.js.map +1 -1
- package/dist/destinations/singlestore/send/generated-types.d.ts +17 -2
- package/dist/destinations/singlestore/send/index.js +120 -62
- package/dist/destinations/singlestore/send/index.js.map +1 -1
- package/dist/destinations/singlestore/send/utils.d.ts +5 -0
- package/dist/destinations/singlestore/send/utils.js +64 -0
- package/dist/destinations/singlestore/send/utils.js.map +1 -0
- package/dist/destinations/singlestore/types.d.ts +23 -37
- package/dist/destinations/twilio-messaging/sendMessage/utils.js +20 -14
- package/dist/destinations/twilio-messaging/sendMessage/utils.js.map +1 -1
- package/package.json +2 -2
- package/dist/destinations/singlestore/const.d.ts +0 -5
- package/dist/destinations/singlestore/const.js +0 -17
- package/dist/destinations/singlestore/const.js.map +0 -1
- package/dist/destinations/singlestore/util.d.ts +0 -10
- package/dist/destinations/singlestore/util.js +0 -88
- package/dist/destinations/singlestore/util.js.map +0 -1
|
@@ -1,81 +1,139 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const const_1 = require("../const");
|
|
5
|
-
const kafkajs_1 = require("kafkajs");
|
|
6
|
-
const util_1 = require("../util");
|
|
3
|
+
const utils_1 = require("./utils");
|
|
7
4
|
const action = {
|
|
8
5
|
title: 'Send Data',
|
|
9
|
-
description: 'Send data to
|
|
6
|
+
description: 'Send data to SingleStore.',
|
|
10
7
|
defaultSubscription: 'type = "track" or type = "screen" or type = "identify" or type = "page" or type = "group" or type = "alias"',
|
|
11
8
|
fields: {
|
|
12
|
-
|
|
13
|
-
label: '
|
|
14
|
-
description: '
|
|
9
|
+
messageid: {
|
|
10
|
+
label: 'Message ID',
|
|
11
|
+
description: 'A unique identifier for the message.',
|
|
15
12
|
type: 'string',
|
|
16
13
|
required: true,
|
|
17
|
-
|
|
14
|
+
default: {
|
|
15
|
+
'@path': '$.messageId'
|
|
16
|
+
}
|
|
18
17
|
},
|
|
19
|
-
|
|
20
|
-
label: '
|
|
21
|
-
description: 'The
|
|
22
|
-
type: '
|
|
18
|
+
timestamp: {
|
|
19
|
+
label: 'Timestamp',
|
|
20
|
+
description: 'The timestamp of the event.',
|
|
21
|
+
type: 'string',
|
|
23
22
|
required: true,
|
|
24
23
|
default: {
|
|
25
|
-
'@path': '$.'
|
|
24
|
+
'@path': '$.timestamp'
|
|
26
25
|
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
26
|
+
},
|
|
27
|
+
type: {
|
|
28
|
+
label: 'Type',
|
|
29
|
+
description: 'The type of the event (e.g., "track", "identify", "page", "screen", "group", "alias").',
|
|
30
|
+
type: 'string',
|
|
31
|
+
required: true,
|
|
32
|
+
choices: [
|
|
33
|
+
{ label: 'Track', value: 'track' },
|
|
34
|
+
{ label: 'Identify', value: 'identify' },
|
|
35
|
+
{ label: 'Page', value: 'page' },
|
|
36
|
+
{ label: 'Screen', value: 'screen' },
|
|
37
|
+
{ label: 'Group', value: 'group' },
|
|
38
|
+
{ label: 'Alias', value: 'alias' }
|
|
39
|
+
],
|
|
40
|
+
default: {
|
|
41
|
+
'@path': '$.type'
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
event: {
|
|
45
|
+
label: 'Event',
|
|
46
|
+
description: 'The name of the event. Only required for "track" events.',
|
|
47
|
+
type: 'string',
|
|
48
|
+
required: {
|
|
49
|
+
conditions: [{ fieldKey: 'type', operator: 'is', value: 'track' }]
|
|
50
|
+
},
|
|
51
|
+
default: {
|
|
52
|
+
'@path': '$.event'
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
name: {
|
|
56
|
+
label: 'Name',
|
|
57
|
+
description: 'The name of the page or screen.',
|
|
58
|
+
type: 'string',
|
|
59
|
+
default: {
|
|
60
|
+
'@path': '$.name'
|
|
43
61
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
};
|
|
62
|
+
},
|
|
63
|
+
properties: {
|
|
64
|
+
label: 'Properties',
|
|
65
|
+
description: 'The properties of the track, page or screen event.',
|
|
66
|
+
type: 'object',
|
|
67
|
+
default: {
|
|
68
|
+
'@path': '$.properties'
|
|
53
69
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
70
|
+
},
|
|
71
|
+
userId: {
|
|
72
|
+
label: 'User ID',
|
|
73
|
+
description: 'The user ID associated with the event.',
|
|
74
|
+
type: 'string',
|
|
75
|
+
default: {
|
|
76
|
+
'@path': '$.userId'
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
anonymousId: {
|
|
80
|
+
label: 'Anonymous ID',
|
|
81
|
+
description: 'The anonymous ID associated with the event.',
|
|
82
|
+
type: 'string',
|
|
83
|
+
default: {
|
|
84
|
+
'@path': '$.anonymousId'
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
groupId: {
|
|
88
|
+
label: 'Group ID',
|
|
89
|
+
description: 'The group ID associated with the event.',
|
|
90
|
+
type: 'string',
|
|
91
|
+
default: {
|
|
92
|
+
'@path': '$.groupId'
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
traits: {
|
|
96
|
+
label: 'Traits',
|
|
97
|
+
description: 'The traits of the user associated with the event.',
|
|
98
|
+
type: 'object',
|
|
99
|
+
default: {
|
|
100
|
+
'@if': {
|
|
101
|
+
exists: { '@path': '$.context.traits' },
|
|
102
|
+
then: { '@path': '$.context.traits' },
|
|
103
|
+
else: { '@path': '$.traits' }
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
context: {
|
|
108
|
+
label: 'Context',
|
|
109
|
+
description: 'The context of the event. Contains user environment information.',
|
|
110
|
+
type: 'object',
|
|
111
|
+
default: {
|
|
112
|
+
'@path': '$.context'
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
max_batch_size: {
|
|
116
|
+
label: 'Max Batch Size',
|
|
117
|
+
description: 'The maximum number of rows to include in a batch.',
|
|
118
|
+
type: 'number',
|
|
119
|
+
required: true,
|
|
120
|
+
default: 100,
|
|
121
|
+
minimum: 1,
|
|
122
|
+
maximum: 1000
|
|
123
|
+
},
|
|
124
|
+
enable_batching: {
|
|
125
|
+
type: 'boolean',
|
|
126
|
+
label: 'Enable Batching',
|
|
127
|
+
description: 'Batch events to SingleStore',
|
|
128
|
+
default: true,
|
|
129
|
+
unsafe_hidden: true
|
|
62
130
|
}
|
|
63
131
|
},
|
|
64
|
-
perform: async (
|
|
65
|
-
(0,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const producer = new kafkajs_1.Kafka(kafkaConfig).producer({
|
|
70
|
-
createPartitioner: kafkajs_1.Partitioners.DefaultPartitioner
|
|
71
|
-
});
|
|
72
|
-
await producer.connect();
|
|
73
|
-
await producer.send(producerRecord);
|
|
74
|
-
await producer.disconnect();
|
|
75
|
-
}
|
|
76
|
-
catch (error) {
|
|
77
|
-
throw new actions_core_1.IntegrationError(`Kafka Connection Error: ${error.message}`, 'KAFKA_CONNECTION_ERROR', 400);
|
|
78
|
-
}
|
|
132
|
+
perform: async (request, { payload, settings }) => {
|
|
133
|
+
return await (0, utils_1.send)(request, [payload], settings);
|
|
134
|
+
},
|
|
135
|
+
performBatch: async (request, { payload, settings }) => {
|
|
136
|
+
return await (0, utils_1.send)(request, payload, settings);
|
|
79
137
|
}
|
|
80
138
|
};
|
|
81
139
|
exports.default = action;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/singlestore/send/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/singlestore/send/index.ts"],"names":[],"mappings":";;AAGA,mCAA8B;AAE9B,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,WAAW;IAClB,WAAW,EAAE,2BAA2B;IACxC,mBAAmB,EACjB,6GAA6G;IAC/G,MAAM,EAAE;QACN,SAAS,EAAE;YACT,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,sCAAsC;YACnD,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,aAAa;aACvB;SACF;QACD,SAAS,EAAE;YACT,KAAK,EAAE,WAAW;YAClB,WAAW,EAAE,6BAA6B;YAC1C,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,OAA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AM,IAAA,YAAI,EAAC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAA;IACjD,CAAC;IACD,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QACrD,OAAO,MAAM,IAAA,YAAI,EAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;IAC/C,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RequestClient } from '@segment/actions-core';
|
|
2
|
+
import { Payload } from './generated-types';
|
|
3
|
+
import { Settings } from '../generated-types';
|
|
4
|
+
import { ExecJSONResponse } from '../types';
|
|
5
|
+
export declare function send(request: RequestClient, payloads: Payload[], settings: Settings): Promise<ExecJSONResponse>;
|
|
@@ -0,0 +1,64 @@
|
|
|
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.send = send;
|
|
7
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
8
|
+
const btoa_lite_1 = __importDefault(require("btoa-lite"));
|
|
9
|
+
async function send(request, payloads, settings) {
|
|
10
|
+
const { host, port, username, password, dbName, tableName } = settings;
|
|
11
|
+
const url = `https://${host}:${port}/api/v2/exec`;
|
|
12
|
+
const encodedCredentials = (0, btoa_lite_1.default)(`${username}:${password}`);
|
|
13
|
+
const columns = [
|
|
14
|
+
'messageId',
|
|
15
|
+
'timestamp',
|
|
16
|
+
'type',
|
|
17
|
+
'event',
|
|
18
|
+
'name',
|
|
19
|
+
'properties',
|
|
20
|
+
'userId',
|
|
21
|
+
'anonymousId',
|
|
22
|
+
'groupId',
|
|
23
|
+
'traits',
|
|
24
|
+
'context'
|
|
25
|
+
];
|
|
26
|
+
const sqlValuesClause = payloads.map(() => `(${columns.map(() => '?').join(', ')})`).join(', ');
|
|
27
|
+
const sql = `INSERT INTO \`${tableName.replace(/`/g, '``')}\` (${columns.join(', ')}) VALUES ${sqlValuesClause}`;
|
|
28
|
+
function toUTCDateTime(timestamp) {
|
|
29
|
+
return timestamp.replace('T', ' ').replace('Z', '');
|
|
30
|
+
}
|
|
31
|
+
const argsTuples = payloads.map((item) => [
|
|
32
|
+
item.messageid,
|
|
33
|
+
toUTCDateTime(item.timestamp),
|
|
34
|
+
item.type,
|
|
35
|
+
item.event ?? null,
|
|
36
|
+
item.name ?? null,
|
|
37
|
+
item.properties ?? null,
|
|
38
|
+
item.userId ?? null,
|
|
39
|
+
item.anonymousId ?? null,
|
|
40
|
+
item.groupId ?? null,
|
|
41
|
+
item.traits ?? null,
|
|
42
|
+
item.context ?? null
|
|
43
|
+
]);
|
|
44
|
+
const args = argsTuples.flat();
|
|
45
|
+
const requestData = {
|
|
46
|
+
sql,
|
|
47
|
+
database: dbName,
|
|
48
|
+
args
|
|
49
|
+
};
|
|
50
|
+
const response = await request(url, {
|
|
51
|
+
method: 'POST',
|
|
52
|
+
headers: {
|
|
53
|
+
'Content-Type': 'application/json',
|
|
54
|
+
Authorization: `Basic ${encodedCredentials}`
|
|
55
|
+
},
|
|
56
|
+
json: requestData,
|
|
57
|
+
throwHttpErrors: false
|
|
58
|
+
});
|
|
59
|
+
if (response.status !== 200 || response.ok === false) {
|
|
60
|
+
throw new actions_core_1.IntegrationError(`Failed to insert data: ${(await response.text()) || 'Unknown error'}`, response.statusText, response.status);
|
|
61
|
+
}
|
|
62
|
+
return response;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/destinations/singlestore/send/utils.ts"],"names":[],"mappings":";;;;;AAMA,oBAqEC;AA3ED,wDAAuE;AAIvE,0DAA4B;AAErB,KAAK,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;
|
|
25
|
-
kafkaPassword: string;
|
|
26
|
-
kafkaTopic: string;
|
|
27
|
-
}
|
|
28
|
-
export interface MaybeTimeoutError {
|
|
29
|
-
response: {
|
|
30
|
-
data: {
|
|
31
|
-
error: {
|
|
32
|
-
message: string;
|
|
33
|
-
code: string;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
}
|
|
1
|
+
export type ExecJSONRequest = {
|
|
2
|
+
sql: string;
|
|
3
|
+
database: string;
|
|
4
|
+
args?: FlattenedArgs;
|
|
5
|
+
};
|
|
6
|
+
export type ExecJSONResponse = {
|
|
7
|
+
ok?: boolean;
|
|
8
|
+
error?: string;
|
|
9
|
+
};
|
|
10
|
+
export type FlatArgsTuple = [
|
|
11
|
+
string,
|
|
12
|
+
string,
|
|
13
|
+
string,
|
|
14
|
+
string | null,
|
|
15
|
+
string | null,
|
|
16
|
+
Record<string, unknown> | null,
|
|
17
|
+
string | null,
|
|
18
|
+
string | null,
|
|
19
|
+
string | null,
|
|
20
|
+
Record<string, unknown> | null,
|
|
21
|
+
Record<string, unknown> | null
|
|
22
|
+
];
|
|
23
|
+
export type FlattenedArgs = FlatArgsTuple[number][];
|
|
@@ -7,7 +7,7 @@ const actions_core_1 = require("@segment/actions-core");
|
|
|
7
7
|
const constants_1 = require("./constants");
|
|
8
8
|
async function send(request, payload, settings) {
|
|
9
9
|
let { toPhoneNumber, fromPhoneNumber, messagingServiceSid, contentSid } = payload;
|
|
10
|
-
const { channel, senderType, contentVariables, validityPeriod, sendAt, inlineMediaUrls, inlineBody } = payload;
|
|
10
|
+
const { channel, senderType, contentVariables, validityPeriod, sendAt, inlineMediaUrls, inlineBody, contentTemplateType } = payload;
|
|
11
11
|
const getTo = () => {
|
|
12
12
|
switch (channel) {
|
|
13
13
|
case 'SMS':
|
|
@@ -57,24 +57,30 @@ async function send(request, payload, settings) {
|
|
|
57
57
|
throw new actions_core_1.PayloadValidationError('Unsupported Sender Type');
|
|
58
58
|
};
|
|
59
59
|
const getContent = () => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
throw new actions_core_1.PayloadValidationError("Content SID should start with 'HX' followed by 32 hexadecimal characters.");
|
|
64
|
-
}
|
|
65
|
-
const contentTemplate = {
|
|
66
|
-
ContentSid: contentSid
|
|
60
|
+
if (contentTemplateType === constants_1.ALL_CONTENT_TYPES.INLINE.friendly_name) {
|
|
61
|
+
return {
|
|
62
|
+
Body: inlineBody || ''
|
|
67
63
|
};
|
|
68
|
-
if (Object.keys(contentVariables ?? {}).length > 0) {
|
|
69
|
-
contentTemplate.ContentVariables = JSON.stringify(contentVariables);
|
|
70
|
-
}
|
|
71
|
-
return contentTemplate;
|
|
72
64
|
}
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
contentSid = parseFieldValue(contentSid);
|
|
66
|
+
if (!contentSid) {
|
|
67
|
+
throw new actions_core_1.PayloadValidationError("'Content Template SID' field value is required when sending a content template message.");
|
|
68
|
+
}
|
|
69
|
+
if (!constants_1.CONTENT_SID_REGEX.test(contentSid)) {
|
|
70
|
+
throw new actions_core_1.PayloadValidationError("'Content Template SID' field value should start with 'HX' followed by 32 hexadecimal characters.");
|
|
71
|
+
}
|
|
72
|
+
const contentTemplate = {
|
|
73
|
+
ContentSid: contentSid
|
|
75
74
|
};
|
|
75
|
+
if (Object.keys(contentVariables ?? {}).length > 0) {
|
|
76
|
+
contentTemplate.ContentVariables = JSON.stringify(contentVariables);
|
|
77
|
+
}
|
|
78
|
+
return contentTemplate;
|
|
76
79
|
};
|
|
77
80
|
const getInlineMediaUrls = () => {
|
|
81
|
+
if (contentTemplateType !== constants_1.ALL_CONTENT_TYPES.INLINE.friendly_name) {
|
|
82
|
+
return {};
|
|
83
|
+
}
|
|
78
84
|
if (!inlineMediaUrls || inlineMediaUrls.length === 0) {
|
|
79
85
|
return {};
|
|
80
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/destinations/twilio-messaging/sendMessage/utils.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/destinations/twilio-messaging/sendMessage/utils.ts"],"names":[],"mappings":";;AAiBA,oBAkJC;AAED,0CAMC;AAiBD,gDAEC;AA9LD,wDAA6E;AAG7E,2CAWoB;AAGb,KAAK,UAAU,IAAI,CAAC,OAAsB,EAAE,OAAgB,EAAE,QAAkB;IACrF,IAAI,EAAE,aAAa,EAAE,eAAe,EAAE,mBAAmB,EAAE,UAAU,EAAE,GAAG,OAAO,CAAA;IAEjF,MAAM,EACJ,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,MAAM,EACN,eAAe,EACf,UAAU,EACV,mBAAmB,EACpB,GAAG,OAAO,CAAA;IAEX,MAAM,KAAK,GAAG,GAAW,EAAE;QACzB,QAAQ,OAAO,EAAE,CAAC;YAChB,KAAK,KAAK,CAAC;YACX,KAAK,KAAK,CAAC;YACX,KAAK,KAAK,CAAC,CAAC,CAAC;gBACX,aAAa,GAAG,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;gBAC3C,IAAI,CAAC,CAAC,sBAAU,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,mCAAuB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC;oBACrF,MAAM,IAAI,qCAAsB,CAC9B,kFAAkF,CACnF,CAAA;gBACH,CAAC;gBACD,OAAO,aAAa,CAAA;YACtB,CAAC;YACD,KAAK,UAAU,CAAC,CAAC,CAAC;gBAChB,aAAa,GAAG,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;gBAC3C,IAAI,CAAC,sBAAU,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;oBACpC,MAAM,IAAI,qCAAsB,CAAC,2DAA2D,CAAC,CAAA;gBAC/F,CAAC;gBACD,OAAO,YAAY,aAAa,EAAE,CAAA;YACpC,CAAC;Y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ACX,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,MAAM,KAAK,GAAG,uBAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACrC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;AACjC,CAAC;AAED,SAAS,MAAM,CAAC,aAA4B;IAC1C,MAAM,cAAc,GAAG,IAAI,eAAe,EAAE,CAAA;IAE5C,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACrD,IAAI,GAAG,KAAK,UAAU,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/C,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACpB,cAAc,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;YACxC,CAAC,CAAC,CAAA;QACJ,CAAC;aAAM,CAAC;YACN,cAAc,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;QAC3C,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,cAAc,CAAC,QAAQ,EAAE,CAAA;AAClC,CAAC;AACD,SAAgB,kBAAkB,CAAC,UAAkB;IACnD,OAAO,qBAAqB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;AAC/C,CAAC"}
|
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.
|
|
4
|
+
"version": "3.411.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/segmentio/action-destinations",
|
|
@@ -90,5 +90,5 @@
|
|
|
90
90
|
"__tests__/__helpers__/"
|
|
91
91
|
]
|
|
92
92
|
},
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "819fa9f73654004583ac965c0264ee3a3f818b93"
|
|
94
94
|
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare const createUrl = "https://xl8i974eyd.execute-api.us-east-1.amazonaws.com/prod/?action=create";
|
|
2
|
-
export declare const getDatabaseURL = "https://xl8i974eyd.execute-api.us-east-1.amazonaws.com/prod/?action=get";
|
|
3
|
-
export declare const CLIENT_ID = "singlestore_segment_destination";
|
|
4
|
-
export declare const STAGE_BROKERS: string[];
|
|
5
|
-
export declare const PROD_BROKERS: string[];
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PROD_BROKERS = exports.STAGE_BROKERS = exports.CLIENT_ID = exports.getDatabaseURL = exports.createUrl = void 0;
|
|
4
|
-
exports.createUrl = 'https://xl8i974eyd.execute-api.us-east-1.amazonaws.com/prod/?action=create';
|
|
5
|
-
exports.getDatabaseURL = 'https://xl8i974eyd.execute-api.us-east-1.amazonaws.com/prod/?action=get';
|
|
6
|
-
exports.CLIENT_ID = 'singlestore_segment_destination';
|
|
7
|
-
exports.STAGE_BROKERS = [
|
|
8
|
-
'b-3-public.singlestoretestcluste.rj6efu.c20.kafka.us-east-1.amazonaws.com:9196',
|
|
9
|
-
'b-2-public.singlestoretestcluste.rj6efu.c20.kafka.us-east-1.amazonaws.com:9196',
|
|
10
|
-
'b-1-public.singlestoretestcluste.rj6efu.c20.kafka.us-east-1.amazonaws.com:9196'
|
|
11
|
-
];
|
|
12
|
-
exports.PROD_BROKERS = [
|
|
13
|
-
'b-3-public.singlestoretestcluste.rj6efu.c20.kafka.us-east-1.amazonaws.com:9196',
|
|
14
|
-
'b-2-public.singlestoretestcluste.rj6efu.c20.kafka.us-east-1.amazonaws.com:9196',
|
|
15
|
-
'b-1-public.singlestoretestcluste.rj6efu.c20.kafka.us-east-1.amazonaws.com:9196'
|
|
16
|
-
];
|
|
17
|
-
//# sourceMappingURL=const.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../src/destinations/singlestore/const.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,4EAA4E,CAAA;AAExF,QAAA,cAAc,GAAG,yEAAyE,CAAA;AAE1F,QAAA,SAAS,GAAG,iCAAiC,CAAA;AAE7C,QAAA,aAAa,GAAG;IAC3B,gFAAgF;IAChF,gFAAgF;IAChF,gFAAgF;CACjF,CAAA;AAEY,QAAA,YAAY,GAAG;IAC1B,gFAAgF;IAChF,gFAAgF;IAChF,gFAAgF;CACjF,CAAA"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Settings } from './generated-types';
|
|
2
|
-
import { KafkaConfig, ProducerRecord } from 'kafkajs';
|
|
3
|
-
export declare const checkChamber: () => void;
|
|
4
|
-
export declare const encryptText: (inputData: string) => string;
|
|
5
|
-
export declare const destinationId: (settings: Settings) => string;
|
|
6
|
-
export declare const getKafkaConfiguration: (settings: Settings) => {
|
|
7
|
-
kafkaConfig: KafkaConfig;
|
|
8
|
-
kafkaTopic: string;
|
|
9
|
-
};
|
|
10
|
-
export declare const getProducerRecord: (kafkaTopic: string, message: unknown) => ProducerRecord;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getProducerRecord = exports.getKafkaConfiguration = exports.destinationId = exports.encryptText = exports.checkChamber = void 0;
|
|
27
|
-
const crypto = __importStar(require("crypto"));
|
|
28
|
-
const const_1 = require("./const");
|
|
29
|
-
const actions_core_1 = require("@segment/actions-core");
|
|
30
|
-
const crypto_1 = require("crypto");
|
|
31
|
-
const checkChamber = () => {
|
|
32
|
-
if (!process.env.ACTIONS_SINGLE_STORE_ENCRYPTION_KEY) {
|
|
33
|
-
throw new actions_core_1.IntegrationError('Missing SingleStore ENCRYPTION_KEY', 'MISSING_REQUIRED_FIELD', 400);
|
|
34
|
-
}
|
|
35
|
-
if (!process.env.ACTIONS_SINGLE_STORE_X_SECURITY_KEY) {
|
|
36
|
-
throw new actions_core_1.IntegrationError('Missing SingleStore X_SECURITY_KEY', 'MISSING_REQUIRED_FIELD', 400);
|
|
37
|
-
}
|
|
38
|
-
if (!process.env.ACTIONS_SINGLE_STORE_IV) {
|
|
39
|
-
throw new actions_core_1.IntegrationError('Missing SingleStore IV', 'MISSING_REQUIRED_FIELD', 400);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
exports.checkChamber = checkChamber;
|
|
43
|
-
const encryptText = (inputData) => {
|
|
44
|
-
const keyBuffer = Buffer.from(process.env.ACTIONS_SINGLE_STORE_ENCRYPTION_KEY, 'hex');
|
|
45
|
-
const ivBuffer = Buffer.from(process.env.ACTIONS_SINGLE_STORE_IV, 'hex');
|
|
46
|
-
const cipher = crypto.createCipheriv('aes-256-cbc', keyBuffer, ivBuffer);
|
|
47
|
-
let encryptedData = cipher.update(inputData, 'utf8', 'hex');
|
|
48
|
-
encryptedData += cipher.final('hex');
|
|
49
|
-
return encryptedData;
|
|
50
|
-
};
|
|
51
|
-
exports.encryptText = encryptText;
|
|
52
|
-
const databaseUri = (settings) => {
|
|
53
|
-
return `${settings.username}@${settings.host}:${settings.port}/${settings.dbName}`;
|
|
54
|
-
};
|
|
55
|
-
const destinationId = (settings) => {
|
|
56
|
-
return (0, crypto_1.createHash)('sha256').update(databaseUri(settings)).digest('hex');
|
|
57
|
-
};
|
|
58
|
-
exports.destinationId = destinationId;
|
|
59
|
-
const getKafkaConfiguration = (settings) => {
|
|
60
|
-
const destination_id = (0, exports.destinationId)(settings);
|
|
61
|
-
const kafkaTopic = (0, crypto_1.createHash)('sha256').update(destination_id).digest('hex');
|
|
62
|
-
const kafkaUsername = (0, crypto_1.createHash)('sha256').update(`${destination_id}_user`).digest('hex');
|
|
63
|
-
const kafkaPassword = (0, exports.encryptText)(kafkaUsername);
|
|
64
|
-
const kafkaConfig = {
|
|
65
|
-
clientId: const_1.CLIENT_ID,
|
|
66
|
-
brokers: settings.environment === 'Prod' ? const_1.PROD_BROKERS : const_1.STAGE_BROKERS,
|
|
67
|
-
sasl: {
|
|
68
|
-
username: kafkaUsername,
|
|
69
|
-
password: kafkaPassword,
|
|
70
|
-
mechanism: 'scram-sha-512'
|
|
71
|
-
},
|
|
72
|
-
ssl: true
|
|
73
|
-
};
|
|
74
|
-
return { kafkaConfig, kafkaTopic };
|
|
75
|
-
};
|
|
76
|
-
exports.getKafkaConfiguration = getKafkaConfiguration;
|
|
77
|
-
const getProducerRecord = (kafkaTopic, message) => {
|
|
78
|
-
return {
|
|
79
|
-
topic: kafkaTopic,
|
|
80
|
-
messages: [
|
|
81
|
-
{
|
|
82
|
-
value: JSON.stringify(message)
|
|
83
|
-
}
|
|
84
|
-
]
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
exports.getProducerRecord = getProducerRecord;
|
|
88
|
-
//# sourceMappingURL=util.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../src/destinations/singlestore/util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgC;AAChC,mCAAgE;AAChE,wDAAwD;AAGxD,mCAAmC;AAG5B,MAAM,YAAY,GAAG,GAAS,EAAE;IACrC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,mCAAmC,EAAE,CAAC;QACrD,MAAM,IAAI,+BAAgB,CAAC,oCAAoC,EAAE,wBAAwB,EAAE,GAAG,CAAC,CAAA;IACjG,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,mCAAmC,EAAE,CAAC;QACrD,MAAM,IAAI,+BAAgB,CAAC,oCAAoC,EAAE,wBAAwB,EAAE,GAAG,CAAC,CAAA;IACjG,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,CAAC;QACzC,MAAM,IAAI,+BAAgB,CAAC,wBAAwB,EAAE,wBAAwB,EAAE,GAAG,CAAC,CAAA;IACrF,CAAC;AACH,CAAC,CAAA;AAZY,QAAA,YAAY,gBAYxB;AAEM,MAAM,WAAW,GAAG,CAAC,SAAiB,EAAU,EAAE;IACvD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,mCAA6C,EAAE,KAAK,CAAC,CAAA;IAC/F,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAiC,EAAE,KAAK,CAAC,CAA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