@segment/action-destinations 3.34.1-alpha.0 → 3.34.1-alpha.1
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/personas-messaging-sendgrid/sendEmail/generated-types.d.ts +1 -1
- package/dist/destinations/slack/postToChannel/index.d.ts +1 -1
- package/dist/destinations/slack/postToChannel/index.js +9 -18
- package/dist/destinations/slack/postToChannel/index.js.map +1 -1
- package/dist/destinations/webhook/__test__/webhook.test.js +8 -51
- package/dist/destinations/webhook/__test__/webhook.test.js.map +1 -1
- package/dist/destinations/webhook/send/index.d.ts +1 -1
- package/dist/destinations/webhook/send/index.js +0 -11
- package/dist/destinations/webhook/send/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionDefinition } from '@segment/actions-core';
|
|
1
|
+
import type { ActionDefinition } from '@segment/actions-core';
|
|
2
2
|
import type { Settings } from '../generated-types';
|
|
3
3
|
import type { Payload } from './generated-types';
|
|
4
4
|
declare const action: ActionDefinition<Settings, Payload>;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const actions_core_1 = require("@segment/actions-core");
|
|
4
|
-
function isValidSlackUrl(webhookUrl) {
|
|
5
|
-
return /^https:\/\/[a-zA-Z0-9.-]+\.slack.com[/a-zA-Z0-9]+$/.test(webhookUrl);
|
|
6
|
-
}
|
|
7
3
|
const action = {
|
|
8
4
|
title: 'Post Message',
|
|
9
5
|
description: 'Post a message to the specified Slack workspace and channel when the associated trigger criteria are met.',
|
|
@@ -40,20 +36,15 @@ const action = {
|
|
|
40
36
|
}
|
|
41
37
|
},
|
|
42
38
|
perform: (request, { payload }) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
username: payload.username,
|
|
53
|
-
icon_url: payload.icon_url
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
39
|
+
return request(payload.url, {
|
|
40
|
+
method: 'post',
|
|
41
|
+
json: {
|
|
42
|
+
channel: payload.channel,
|
|
43
|
+
text: payload.text,
|
|
44
|
+
username: payload.username,
|
|
45
|
+
icon_url: payload.icon_url
|
|
46
|
+
}
|
|
47
|
+
});
|
|
57
48
|
}
|
|
58
49
|
};
|
|
59
50
|
exports.default = action;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/slack/postToChannel/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/slack/postToChannel/index.ts"],"names":[],"mappings":";;AAIA,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,cAAc;IACrB,WAAW,EACT,2GAA2G;IAC7G,MAAM,EAAE;QACN,GAAG,EAAE;YACH,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,4EAA4E;YACzF,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,KAAK;SACd;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,SAAS;YAChB,QAAQ,EAAE,IAAI;YACd,WAAW,EACT,kIAAkI;YACpI,IAAI,EAAE,MAAM;SACb;QACD,OAAO,EAAE;YACP,KAAK,EAAE,SAAS;YAChB,WAAW,EACT,uHAAuH;YACzH,IAAI,EAAE,QAAQ;SACf;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,MAAM;YACb,WAAW,EAAE,mCAAmC;YAChD,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,SAAS;SACnB;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,UAAU;YACjB,WAAW,EAAE,qDAAqD;YAClE,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,uCAAuC;SACjD;KACF;IAED,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAChC,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE;YAC1B,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,QAAQ,EAAE,OAAO,CAAC,QAAQ;aAC3B;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -11,18 +11,19 @@ const timestamp = new Date().toISOString();
|
|
|
11
11
|
describe('Webhook', () => {
|
|
12
12
|
describe('send', () => {
|
|
13
13
|
it('should work with default mapping', async () => {
|
|
14
|
-
const url = 'https://
|
|
14
|
+
const url = 'https://my.webhook.com';
|
|
15
|
+
const path = '/1234';
|
|
15
16
|
const event = actions_core_1.createTestEvent({
|
|
16
17
|
timestamp,
|
|
17
18
|
event: 'Test Event'
|
|
18
19
|
});
|
|
19
20
|
nock_1.default(url)
|
|
20
|
-
.post(
|
|
21
|
+
.post(path, event)
|
|
21
22
|
.reply(200);
|
|
22
23
|
const responses = await testDestination.testAction('send', {
|
|
23
24
|
event,
|
|
24
25
|
mapping: {
|
|
25
|
-
url
|
|
26
|
+
url: url + path
|
|
26
27
|
},
|
|
27
28
|
useDefaultMappings: true
|
|
28
29
|
});
|
|
@@ -30,17 +31,18 @@ describe('Webhook', () => {
|
|
|
30
31
|
expect(responses[0].status).toBe(200);
|
|
31
32
|
});
|
|
32
33
|
it('supports customizations', async () => {
|
|
33
|
-
const url = 'https://
|
|
34
|
+
const url = 'https://my.webhook.com';
|
|
35
|
+
const path = '/1234';
|
|
34
36
|
const event = actions_core_1.createTestEvent({
|
|
35
37
|
timestamp,
|
|
36
38
|
event: 'Test Event'
|
|
37
39
|
});
|
|
38
40
|
const data = { cool: true };
|
|
39
|
-
nock_1.default(url).put(
|
|
41
|
+
nock_1.default(url).put(path, data).reply(200);
|
|
40
42
|
const responses = await testDestination.testAction('send', {
|
|
41
43
|
event,
|
|
42
44
|
mapping: {
|
|
43
|
-
url,
|
|
45
|
+
url: url + path,
|
|
44
46
|
method: 'PUT',
|
|
45
47
|
data: { cool: true }
|
|
46
48
|
}
|
|
@@ -48,51 +50,6 @@ describe('Webhook', () => {
|
|
|
48
50
|
expect(responses.length).toBe(1);
|
|
49
51
|
expect(responses[0].status).toBe(200);
|
|
50
52
|
});
|
|
51
|
-
it('supports customizations', async () => {
|
|
52
|
-
const url = 'https://mme-e2e.segment.build';
|
|
53
|
-
const event = actions_core_1.createTestEvent({
|
|
54
|
-
timestamp,
|
|
55
|
-
event: 'Test Event'
|
|
56
|
-
});
|
|
57
|
-
const data = { cool: true };
|
|
58
|
-
nock_1.default(url).put('/', data).reply(200);
|
|
59
|
-
const responses = await testDestination.testAction('send', {
|
|
60
|
-
event,
|
|
61
|
-
mapping: {
|
|
62
|
-
url,
|
|
63
|
-
method: 'PUT',
|
|
64
|
-
data: { cool: true }
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
expect(responses.length).toBe(1);
|
|
68
|
-
expect(responses[0].status).toBe(200);
|
|
69
|
-
});
|
|
70
|
-
it('restricts usage to mme-e2e urls', async () => {
|
|
71
|
-
const url = 'https://api.acme.com/webhook';
|
|
72
|
-
const event = actions_core_1.createTestEvent({
|
|
73
|
-
timestamp,
|
|
74
|
-
event: 'Test Event'
|
|
75
|
-
});
|
|
76
|
-
const data = { cool: true };
|
|
77
|
-
nock_1.default(url).put('/', data).reply(200);
|
|
78
|
-
try {
|
|
79
|
-
await testDestination.testAction('send', {
|
|
80
|
-
event,
|
|
81
|
-
mapping: {
|
|
82
|
-
url,
|
|
83
|
-
method: 'PUT',
|
|
84
|
-
data: { cool: true }
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
fail('expected testAction to reject');
|
|
88
|
-
}
|
|
89
|
-
catch (err) {
|
|
90
|
-
const error = err;
|
|
91
|
-
expect(error.status).toBe(400);
|
|
92
|
-
expect(error.code).toBe('Bad Request');
|
|
93
|
-
expect(error.message).toBe("invalid url 'https://api.acme.com/webhook'");
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
53
|
});
|
|
97
54
|
});
|
|
98
55
|
//# sourceMappingURL=webhook.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.test.js","sourceRoot":"","sources":["../../../../src/destinations/webhook/__test__/webhook.test.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;AACvB,
|
|
1
|
+
{"version":3,"file":"webhook.test.js","sourceRoot":"","sources":["../../../../src/destinations/webhook/__test__/webhook.test.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;AACvB,wDAA8E;AAC9E,qDAA8B;AAE9B,MAAM,eAAe,GAAG,oCAAqB,CAAC,eAAO,CAAC,CAAA;AACtD,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;AAE1C,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;QACpB,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;YAChD,MAAM,GAAG,GAAG,wBAAwB,CAAA;YACpC,MAAM,IAAI,GAAG,OAAO,CAAA;YACpB,MAAM,KAAK,GAAG,8BAAe,CAAC;gBAC5B,SAAS;gBACT,KAAK,EAAE,YAAY;aACpB,CAAC,CAAA;YAEF,cAAI,CAAC,GAAG,CAAC;iBACN,IAAI,CAAC,IAAI,EAAE,KAAY,CAAC;iBACxB,KAAK,CAAC,GAAG,CAAC,CAAA;YAEb,MAAM,SAAS,GAAG,MAAM,eAAe,CAAC,UAAU,CAAC,MAAM,EAAE;gBACzD,KAAK;gBACL,OAAO,EAAE;oBACP,GAAG,EAAE,GAAG,GAAG,IAAI;iBAChB;gBACD,kBAAkB,EAAE,IAAI;aACzB,CAAC,CAAA;YAEF,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YAChC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACvC,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,yBAAyB,EAAE,KAAK,IAAI,EAAE;YACvC,MAAM,GAAG,GAAG,wBAAwB,CAAA;YACpC,MAAM,IAAI,GAAG,OAAO,CAAA;YAEpB,MAAM,KAAK,GAAG,8BAAe,CAAC;gBAC5B,SAAS;gBACT,KAAK,EAAE,YAAY;aACpB,CAAC,CAAA;YACF,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;YAE3B,cAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YAEpC,MAAM,SAAS,GAAG,MAAM,eAAe,CAAC,UAAU,CAAC,MAAM,EAAE;gBACzD,KAAK;gBACL,OAAO,EAAE;oBACP,GAAG,EAAE,GAAG,GAAG,IAAI;oBACf,MAAM,EAAE,KAAK;oBACb,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;iBACrB;aACF,CAAC,CAAA;YAEF,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YAChC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACvC,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionDefinition } from '@segment/actions-core';
|
|
1
|
+
import type { ActionDefinition } from '@segment/actions-core';
|
|
2
2
|
import type { Settings } from '../generated-types';
|
|
3
3
|
import type { Payload } from './generated-types';
|
|
4
4
|
declare const action: ActionDefinition<Settings, Payload>;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const actions_core_1 = require("@segment/actions-core");
|
|
4
|
-
const MME_E2E_URLS = [
|
|
5
|
-
'https://mme-e2e.segment.com',
|
|
6
|
-
'https://mme-e2e.segment.build'
|
|
7
|
-
];
|
|
8
3
|
const action = {
|
|
9
4
|
title: 'Send',
|
|
10
5
|
description: 'Send an HTTP request.',
|
|
@@ -38,9 +33,6 @@ const action = {
|
|
|
38
33
|
}
|
|
39
34
|
},
|
|
40
35
|
perform: (request, { payload }) => {
|
|
41
|
-
if (!MME_E2E_URLS.includes(payload.url)) {
|
|
42
|
-
throw new actions_core_1.IntegrationError(`invalid url '${payload.url}'`, 'Bad Request', 400);
|
|
43
|
-
}
|
|
44
36
|
return request(payload.url, {
|
|
45
37
|
method: payload.method,
|
|
46
38
|
json: payload.data
|
|
@@ -48,9 +40,6 @@ const action = {
|
|
|
48
40
|
},
|
|
49
41
|
performBatch: (request, { payload }) => {
|
|
50
42
|
const { url, method } = payload[0];
|
|
51
|
-
if (!MME_E2E_URLS.includes(url)) {
|
|
52
|
-
throw new actions_core_1.IntegrationError(`invalid url '${url}'`, 'Bad Request', 400);
|
|
53
|
-
}
|
|
54
43
|
return request(url, {
|
|
55
44
|
method: method,
|
|
56
45
|
json: payload.map(({ data }) => data)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/webhook/send/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/webhook/send/index.ts"],"names":[],"mappings":";;AAMA,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,MAAM;IACb,WAAW,EAAE,uBAAuB;IACpC,MAAM,EAAE;QACN,GAAG,EAAE;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AAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;SACtC,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segment/action-destinations",
|
|
3
3
|
"description": "Destination Actions engine and definitions.",
|
|
4
|
-
"version": "3.34.1-alpha.
|
|
4
|
+
"version": "3.34.1-alpha.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/segmentio/action-destinations",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"<rootDir>/test/setup-after-env.ts"
|
|
61
61
|
]
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "fa545985f6f04472c4a9b79f019e3bc74d84fc5e"
|
|
64
64
|
}
|