@segment/action-destinations 3.33.1-alpha.7 → 3.33.3-alpha.10
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/salesforce/generated-types.d.ts +1 -0
- package/dist/destinations/salesforce/index.js +9 -3
- package/dist/destinations/salesforce/index.js.map +1 -1
- package/dist/destinations/salesforce/lead/generated-types.d.ts +11 -2
- package/dist/destinations/salesforce/lead/index.d.ts +1 -1
- package/dist/destinations/salesforce/lead/index.js +61 -21
- package/dist/destinations/salesforce/lead/index.js.map +1 -1
- package/dist/destinations/salesforce/sf-operations.d.ts +19 -0
- package/dist/destinations/salesforce/sf-operations.js +101 -0
- package/dist/destinations/salesforce/sf-operations.js.map +1 -0
- package/dist/destinations/salesforce/sf-properties.d.ts +9 -0
- package/dist/destinations/salesforce/sf-properties.js +29 -0
- package/dist/destinations/salesforce/sf-properties.js.map +1 -0
- package/dist/destinations/slack/postToChannel/index.d.ts +1 -1
- package/dist/destinations/slack/postToChannel/index.js +18 -9
- package/dist/destinations/slack/postToChannel/index.js.map +1 -1
- package/dist/destinations/webhook/__test__/webhook.test.js +51 -8
- 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 +11 -0
- package/dist/destinations/webhook/send/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -10,7 +10,14 @@ const destination = {
|
|
|
10
10
|
mode: 'cloud',
|
|
11
11
|
authentication: {
|
|
12
12
|
scheme: 'oauth2',
|
|
13
|
-
fields: {
|
|
13
|
+
fields: {
|
|
14
|
+
instanceUrl: {
|
|
15
|
+
label: 'Instance URL',
|
|
16
|
+
description: 'Base Url of the request. For local testing only. refreshAccessToken will eventually be able to fetch this value via Oauth',
|
|
17
|
+
type: 'string',
|
|
18
|
+
required: true
|
|
19
|
+
}
|
|
20
|
+
},
|
|
14
21
|
refreshAccessToken: async (request, { auth }) => {
|
|
15
22
|
const res = await request('https://login.salesforce.com/services/oauth2/token', {
|
|
16
23
|
method: 'POST',
|
|
@@ -21,8 +28,7 @@ const destination = {
|
|
|
21
28
|
grant_type: 'refresh_token'
|
|
22
29
|
})
|
|
23
30
|
});
|
|
24
|
-
|
|
25
|
-
return { accessToken: res.data.access_token };
|
|
31
|
+
return { accessToken: res.data.accessToken };
|
|
26
32
|
}
|
|
27
33
|
},
|
|
28
34
|
extendRequest({ auth }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/salesforce/index.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/salesforce/index.ts"],"names":[],"mappings":";;;;;AAEA,kDAAyB;AAKzB,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,sBAAsB;IAC5B,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,WAAW,EAAE;gBACX,KAAK,EAAE,cAAc;gBACrB,WAAW,EACT,2HAA2H;gBAC7H,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;aACf;SACF;QACD,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;YAE9C,MAAM,GAAG,GAAG,MAAM,OAAO,CACvB,oDAAoD,EACpD;gBACE,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,IAAI,eAAe,CAAC;oBACxB,aAAa,EAAE,IAAI,CAAC,YAAY;oBAChC,SAAS,EAAE,IAAI,CAAC,QAAQ;oBACxB,aAAa,EAAE,IAAI,CAAC,YAAY;oBAChC,UAAU,EAAE,eAAe;iBAC5B,CAAC;aACH,CACF,CAAA;YACD,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAA;QAC9C,CAAC;KACF;IACD,aAAa,CAAC,EAAE,IAAI,EAAE;QACpB,OAAO;YACL,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,IAAI,EAAE,WAAW,EAAE;aAC7C;SACF,CAAA;IACH,CAAC;IAED,OAAO,EAAE;QACP,IAAI,EAAJ,cAAI;KACL;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
export interface Payload {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
operation: string;
|
|
3
|
+
traits?: {
|
|
4
|
+
[k: string]: unknown;
|
|
5
|
+
};
|
|
4
6
|
company?: string;
|
|
5
7
|
last_name?: string;
|
|
8
|
+
first_name?: string;
|
|
9
|
+
email?: string;
|
|
10
|
+
city?: string;
|
|
11
|
+
postal_code?: string;
|
|
12
|
+
country?: string;
|
|
13
|
+
street?: string;
|
|
14
|
+
state?: string;
|
|
6
15
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { 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,22 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
6
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
7
|
+
const sf_properties_1 = require("../sf-properties");
|
|
8
|
+
const sf_operations_1 = __importDefault(require("../sf-operations"));
|
|
4
9
|
const action = {
|
|
5
10
|
title: 'Lead',
|
|
6
11
|
description: 'Lead action',
|
|
7
12
|
fields: {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
description: 'CRUD',
|
|
11
|
-
type: 'string',
|
|
12
|
-
choices: [{ label: 'Create', value: 'create' }],
|
|
13
|
-
dynamic: true
|
|
14
|
-
},
|
|
15
|
-
external_id_value: {
|
|
16
|
-
label: 'External ID Value',
|
|
17
|
-
description: 'External ID Value',
|
|
18
|
-
type: 'string'
|
|
19
|
-
},
|
|
13
|
+
operation: sf_properties_1.operation,
|
|
14
|
+
traits: sf_properties_1.traits,
|
|
20
15
|
company: {
|
|
21
16
|
label: 'Company',
|
|
22
17
|
description: 'Company',
|
|
@@ -24,18 +19,63 @@ const action = {
|
|
|
24
19
|
},
|
|
25
20
|
last_name: {
|
|
26
21
|
label: 'Last Name',
|
|
27
|
-
description: '',
|
|
22
|
+
description: 'Last Name',
|
|
23
|
+
type: 'string'
|
|
24
|
+
},
|
|
25
|
+
first_name: {
|
|
26
|
+
label: 'First Name',
|
|
27
|
+
description: 'First Name',
|
|
28
|
+
type: 'string'
|
|
29
|
+
},
|
|
30
|
+
email: {
|
|
31
|
+
label: 'Email',
|
|
32
|
+
description: 'Email',
|
|
33
|
+
type: 'string'
|
|
34
|
+
},
|
|
35
|
+
city: {
|
|
36
|
+
label: 'City',
|
|
37
|
+
description: 'City',
|
|
38
|
+
type: 'string'
|
|
39
|
+
},
|
|
40
|
+
postal_code: {
|
|
41
|
+
label: 'Postal Code',
|
|
42
|
+
description: 'Postal Code',
|
|
43
|
+
type: 'string'
|
|
44
|
+
},
|
|
45
|
+
country: {
|
|
46
|
+
label: 'Country',
|
|
47
|
+
description: 'Country',
|
|
48
|
+
type: 'string'
|
|
49
|
+
},
|
|
50
|
+
street: {
|
|
51
|
+
label: 'Street',
|
|
52
|
+
description: 'Street',
|
|
53
|
+
type: 'string'
|
|
54
|
+
},
|
|
55
|
+
state: {
|
|
56
|
+
label: 'State',
|
|
57
|
+
description: 'State',
|
|
28
58
|
type: 'string'
|
|
29
59
|
}
|
|
30
60
|
},
|
|
31
|
-
perform: (request, { payload }) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
Company: payload.company
|
|
61
|
+
perform: async (request, { settings, payload }) => {
|
|
62
|
+
const sf = new sf_operations_1.default(settings.instanceUrl, request);
|
|
63
|
+
if (payload.operation === 'create') {
|
|
64
|
+
if (!payload.company || !payload.last_name) {
|
|
65
|
+
throw new actions_core_1.IntegrationError('Missing company or last_name value', 'Misconfigured required field', 400);
|
|
37
66
|
}
|
|
38
|
-
|
|
67
|
+
return await sf.createRecord(payload, 'Lead');
|
|
68
|
+
}
|
|
69
|
+
sf_properties_1.validateLookup(payload);
|
|
70
|
+
if (payload.operation === 'update') {
|
|
71
|
+
return await sf.updateRecord(payload, 'Lead');
|
|
72
|
+
}
|
|
73
|
+
if (payload.operation === 'upsert') {
|
|
74
|
+
if (!payload.company || !payload.last_name) {
|
|
75
|
+
throw new actions_core_1.IntegrationError('Missing company or last_name value', 'Misconfigured required field', 400);
|
|
76
|
+
}
|
|
77
|
+
return await sf.upsertRecord(payload, 'Lead');
|
|
78
|
+
}
|
|
39
79
|
}
|
|
40
80
|
};
|
|
41
81
|
exports.default = action;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/salesforce/lead/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/salesforce/lead/index.ts"],"names":[],"mappings":";;;;;AAAA,wDAA0E;AAG1E,oDAAoE;AACpE,qEAAyC;AAEzC,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,MAAM;IACb,WAAW,EAAE,aAAa;IAC1B,MAAM,EAAE;QACN,SAAS,EAAE,yBAAS;QACpB,MAAM,EAAE,sBAAM;QACd,OAAO,EAAE;YACP,KAAK,EAAE,SAAS;YAChB,WAAW,EAAE,SAAS;YACtB,IAAI,EAAE,QAAQ;SACf;QACD,SAAS,EAAE;YACT,KAAK,EAAE,WAAW;YAClB,WAAW,EAAE,WAAW;YACxB,IAAI,EAAE,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MAAM,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;SAC9C;QAED,IAAI,OAAO,CAAC,SAAS,KAAK,QAAQ,EAAE;YAClC,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;gBAC1C,MAAM,IAAI,+BAAgB,CAAC,oCAAoC,EAAE,8BAA8B,EAAE,GAAG,CAAC,CAAA;aACtG;YACD,OAAO,MAAM,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;SAC9C;IACH,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RequestClient } from '@segment/actions-core';
|
|
2
|
+
export declare const API_VERSION = "v53.0";
|
|
3
|
+
interface Payload {
|
|
4
|
+
traits?: {
|
|
5
|
+
[k: string]: unknown;
|
|
6
|
+
} | undefined;
|
|
7
|
+
}
|
|
8
|
+
export default class Salesforce {
|
|
9
|
+
instanceUrl: string;
|
|
10
|
+
request: RequestClient;
|
|
11
|
+
constructor(instanceUrl: string, request: RequestClient);
|
|
12
|
+
createRecord: (payload: any, sobject: string) => Promise<import("@segment/actions-core").ModifiedResponse<unknown>>;
|
|
13
|
+
updateRecord: (payload: Payload, sobject: string) => Promise<import("@segment/actions-core").ModifiedResponse<unknown>>;
|
|
14
|
+
upsertRecord: (payload: Payload, sobject: string) => Promise<import("@segment/actions-core").ModifiedResponse<unknown>>;
|
|
15
|
+
private baseUpdate;
|
|
16
|
+
private buildQuery;
|
|
17
|
+
private lookupTraits;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.API_VERSION = void 0;
|
|
4
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
5
|
+
exports.API_VERSION = 'v53.0';
|
|
6
|
+
class Salesforce {
|
|
7
|
+
constructor(instanceUrl, request) {
|
|
8
|
+
this.createRecord = async (payload, sobject) => {
|
|
9
|
+
return this.request(`${this.instanceUrl}/services/data/${exports.API_VERSION}/sobjects/${sobject}`, {
|
|
10
|
+
method: 'post',
|
|
11
|
+
json: {
|
|
12
|
+
LastName: payload.last_name,
|
|
13
|
+
Company: payload.company,
|
|
14
|
+
FirstName: payload.first_name,
|
|
15
|
+
State: payload.state,
|
|
16
|
+
Street: payload.street,
|
|
17
|
+
Country: payload.country,
|
|
18
|
+
PostalCode: payload.postal_code,
|
|
19
|
+
City: payload.city,
|
|
20
|
+
Email: payload.email
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
this.updateRecord = async (payload, sobject) => {
|
|
25
|
+
if (payload.traits === undefined || Object.keys(payload.traits).length === 0) {
|
|
26
|
+
throw new actions_core_1.IntegrationError('Undefined Traits when using update operation', 'Undefined Traits', 400);
|
|
27
|
+
}
|
|
28
|
+
if (Object.keys(payload.traits).includes('Id') && payload.traits['Id']) {
|
|
29
|
+
return await this.baseUpdate(payload.traits['Id'], sobject, payload);
|
|
30
|
+
}
|
|
31
|
+
const [recordId, err] = await this.lookupTraits(payload.traits, sobject);
|
|
32
|
+
if (err !== undefined) {
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
return await this.baseUpdate(recordId, sobject, payload);
|
|
36
|
+
};
|
|
37
|
+
this.upsertRecord = async (payload, sobject) => {
|
|
38
|
+
if (payload.traits === undefined || payload.traits === {}) {
|
|
39
|
+
throw new actions_core_1.IntegrationError('Undefined Traits when using upsert operation', 'Undefined Traits', 400);
|
|
40
|
+
}
|
|
41
|
+
const [recordId, err] = await this.lookupTraits(payload.traits, sobject);
|
|
42
|
+
if (err === undefined) {
|
|
43
|
+
return await this.baseUpdate(recordId, sobject, payload);
|
|
44
|
+
}
|
|
45
|
+
return await this.createRecord(payload, sobject);
|
|
46
|
+
};
|
|
47
|
+
this.baseUpdate = async (recordId, sobject, payload) => {
|
|
48
|
+
return this.request(`${this.instanceUrl}/services/data/${exports.API_VERSION}/sobjects/${sobject}/${recordId}`, {
|
|
49
|
+
method: 'patch',
|
|
50
|
+
json: {
|
|
51
|
+
LastName: payload.last_name,
|
|
52
|
+
Company: payload.company,
|
|
53
|
+
FirstName: payload.first_name,
|
|
54
|
+
State: payload.state,
|
|
55
|
+
Street: payload.street,
|
|
56
|
+
Country: payload.country,
|
|
57
|
+
PostalCode: payload.postal_code,
|
|
58
|
+
City: payload.city,
|
|
59
|
+
Email: payload.email
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
this.buildQuery = (traits, sobject) => {
|
|
64
|
+
let soql = `?q=SELECT Id FROM ${sobject} WHERE `;
|
|
65
|
+
const entries = Object.entries(traits);
|
|
66
|
+
let i = 0;
|
|
67
|
+
for (const [key, value] of entries) {
|
|
68
|
+
let token = `${key} = '${value}'`;
|
|
69
|
+
if (i < entries.length - 1) {
|
|
70
|
+
token += ' OR ';
|
|
71
|
+
}
|
|
72
|
+
soql += token;
|
|
73
|
+
i += 1;
|
|
74
|
+
}
|
|
75
|
+
return soql;
|
|
76
|
+
};
|
|
77
|
+
this.lookupTraits = async (traits, sobject) => {
|
|
78
|
+
const SOQLQuery = this.buildQuery(traits, sobject);
|
|
79
|
+
console.log('soql', SOQLQuery);
|
|
80
|
+
const res = await this.request(`${this.instanceUrl}/services/data/${exports.API_VERSION}/query/${SOQLQuery}`, { method: 'get' });
|
|
81
|
+
console.log('res', res);
|
|
82
|
+
if (!res || !res.data || res.data.totalSize === undefined) {
|
|
83
|
+
return ['', new actions_core_1.IntegrationError('Response missing expected fields', 'Bad Response', 400)];
|
|
84
|
+
}
|
|
85
|
+
if (res.data.totalSize === 0) {
|
|
86
|
+
return ['', new actions_core_1.IntegrationError('No record found with given traits', 'Record Not Found', 404)];
|
|
87
|
+
}
|
|
88
|
+
if (res.data.totalSize > 1) {
|
|
89
|
+
return ['', new actions_core_1.IntegrationError('Multiple records returned with given traits', 'Multiple Records Found', 300)];
|
|
90
|
+
}
|
|
91
|
+
if (!res.data.records || !res.data.records[0] || !res.data.records[0].Id) {
|
|
92
|
+
return ['', new actions_core_1.IntegrationError('Response missing expected fields', 'Bad Response', 400)];
|
|
93
|
+
}
|
|
94
|
+
return [res.data.records[0].Id, undefined];
|
|
95
|
+
};
|
|
96
|
+
this.instanceUrl = instanceUrl;
|
|
97
|
+
this.request = request;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.default = Salesforce;
|
|
101
|
+
//# sourceMappingURL=sf-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sf-operations.js","sourceRoot":"","sources":["../../../src/destinations/salesforce/sf-operations.ts"],"names":[],"mappings":";;;AAAA,wDAAuE;AAE1D,QAAA,WAAW,GAAG,OAAO,CAAA;AAgBlC,MAAqB,UAAU;IAI7B,YAAY,WAAmB,EAAE,OAAsB;QAKvD,iBAAY,GAAG,KAAK,EAAE,OAAY,EAAE,OAAe,EAAE,EAAE;YACrD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,WAAW,kBAAkB,mBAAW,aAAa,OAAO,EAAE,EAAE;gBAC1F,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE;oBACJ,QAAQ,EAAE,OAAO,CAAC,SAAS;oBAC3B,OAAO,EAAE,OAAO,CAAC,OAAO;oBACxB,SAAS,EAAE,OAAO,CAAC,UAAU;oBAC7B,KAAK,EAAE,OAAO,CAAC,KAAK;oBACpB,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,OAAO,EAAE,OAAO,CAAC,OAAO;oBACxB,UAAU,EAAE,OAAO,CAAC,WAAW;oBAC/B,IAAI,EAAE,OAAO,CAAC,IAAI;oBAClB,KAAK,EAAE,OAAO,CAAC,KAAK;iBACrB;aACF,CAAC,CAAA;QACJ,CAAC,CAAA;QAED,iBAAY,GAAG,KAAK,EAAE,OAAgB,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CAAC,EAAE,EAAE,IAAI,+BAAgB,CAAC,kCAAkC,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC,CAAA;aAC3F;YAED,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC,CAAA;QAC5C,CAAC,CAAA;QArHC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;CAoHF;AA3HD,6BA2HC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InputField } from '@segment/actions-core/src/destination-kit/types';
|
|
2
|
+
export declare const operation: InputField;
|
|
3
|
+
export declare const traits: InputField;
|
|
4
|
+
interface Payload {
|
|
5
|
+
operation?: string;
|
|
6
|
+
traits?: object;
|
|
7
|
+
}
|
|
8
|
+
export declare const validateLookup: (payload: Payload) => void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateLookup = exports.traits = exports.operation = void 0;
|
|
4
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
5
|
+
exports.operation = {
|
|
6
|
+
label: 'Operation',
|
|
7
|
+
description: 'Operation',
|
|
8
|
+
type: 'string',
|
|
9
|
+
required: true,
|
|
10
|
+
choices: [
|
|
11
|
+
{ label: 'Create', value: 'create' },
|
|
12
|
+
{ label: 'Update', value: 'update' },
|
|
13
|
+
{ label: 'Upsert', value: 'upsert' }
|
|
14
|
+
]
|
|
15
|
+
};
|
|
16
|
+
exports.traits = {
|
|
17
|
+
label: 'Traits',
|
|
18
|
+
description: 'Traits',
|
|
19
|
+
type: 'object'
|
|
20
|
+
};
|
|
21
|
+
const validateLookup = (payload) => {
|
|
22
|
+
if (payload.operation === 'update' || payload.operation === 'upsert') {
|
|
23
|
+
if (!payload.traits) {
|
|
24
|
+
throw new actions_core_1.IntegrationError('Undefined lookup traits for update or upsert operation', 'Misconfigured Required Field', 400);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.validateLookup = validateLookup;
|
|
29
|
+
//# sourceMappingURL=sf-properties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sf-properties.js","sourceRoot":"","sources":["../../../src/destinations/salesforce/sf-properties.ts"],"names":[],"mappings":";;;AACA,wDAAwD;AAE3C,QAAA,SAAS,GAAe;IACnC,KAAK,EAAE,WAAW;IAClB,WAAW,EAAE,WAAW;IACxB,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE;QACP,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;QACpC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;QACpC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;KACrC;CACF,CAAA;AAEY,QAAA,MAAM,GAAe;IAChC,KAAK,EAAE,QAAQ;IACf,WAAW,EAAE,QAAQ;IACrB,IAAI,EAAE,QAAQ;CACf,CAAA;AAOM,MAAM,cAAc,GAAG,CAAC,OAAgB,EAAE,EAAE;IACjD,IAAI,OAAO,CAAC,SAAS,KAAK,QAAQ,IAAI,OAAO,CAAC,SAAS,KAAK,QAAQ,EAAE;QACpE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACnB,MAAM,IAAI,+BAAgB,CACxB,wDAAwD,EACxD,8BAA8B,EAC9B,GAAG,CACJ,CAAA;SACF;KACF;AACH,CAAC,CAAA;AAVY,QAAA,cAAc,kBAU1B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { 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,5 +1,9 @@
|
|
|
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
|
+
}
|
|
3
7
|
const action = {
|
|
4
8
|
title: 'Post Message',
|
|
5
9
|
description: 'Post a message to the specified Slack workspace and channel when the associated trigger criteria are met.',
|
|
@@ -36,15 +40,20 @@ const action = {
|
|
|
36
40
|
}
|
|
37
41
|
},
|
|
38
42
|
perform: (request, { payload }) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
if (!isValidSlackUrl(payload.url)) {
|
|
44
|
+
throw new actions_core_1.IntegrationError('Invalid Slack URL', 'Bad Request', 400);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return request(payload.url, {
|
|
48
|
+
method: 'post',
|
|
49
|
+
json: {
|
|
50
|
+
channel: payload.channel,
|
|
51
|
+
text: payload.text,
|
|
52
|
+
username: payload.username,
|
|
53
|
+
icon_url: payload.icon_url
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
48
57
|
}
|
|
49
58
|
};
|
|
50
59
|
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":";;AAAA,wDAA0E;AAI1E,SAAS,eAAe,CAAC,UAAkB;IACzC,OAAO,oDAAoD,CAAC,IAAI,CAAC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;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -11,19 +11,18 @@ 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://
|
|
15
|
-
const path = '/1234';
|
|
14
|
+
const url = 'https://mme-e2e.segment.com';
|
|
16
15
|
const event = actions_core_1.createTestEvent({
|
|
17
16
|
timestamp,
|
|
18
17
|
event: 'Test Event'
|
|
19
18
|
});
|
|
20
19
|
nock_1.default(url)
|
|
21
|
-
.post(
|
|
20
|
+
.post('/', event)
|
|
22
21
|
.reply(200);
|
|
23
22
|
const responses = await testDestination.testAction('send', {
|
|
24
23
|
event,
|
|
25
24
|
mapping: {
|
|
26
|
-
url
|
|
25
|
+
url
|
|
27
26
|
},
|
|
28
27
|
useDefaultMappings: true
|
|
29
28
|
});
|
|
@@ -31,18 +30,17 @@ describe('Webhook', () => {
|
|
|
31
30
|
expect(responses[0].status).toBe(200);
|
|
32
31
|
});
|
|
33
32
|
it('supports customizations', async () => {
|
|
34
|
-
const url = 'https://
|
|
35
|
-
const path = '/1234';
|
|
33
|
+
const url = 'https://mme-e2e.segment.build';
|
|
36
34
|
const event = actions_core_1.createTestEvent({
|
|
37
35
|
timestamp,
|
|
38
36
|
event: 'Test Event'
|
|
39
37
|
});
|
|
40
38
|
const data = { cool: true };
|
|
41
|
-
nock_1.default(url).put(
|
|
39
|
+
nock_1.default(url).put('/', data).reply(200);
|
|
42
40
|
const responses = await testDestination.testAction('send', {
|
|
43
41
|
event,
|
|
44
42
|
mapping: {
|
|
45
|
-
url
|
|
43
|
+
url,
|
|
46
44
|
method: 'PUT',
|
|
47
45
|
data: { cool: true }
|
|
48
46
|
}
|
|
@@ -50,6 +48,51 @@ describe('Webhook', () => {
|
|
|
50
48
|
expect(responses.length).toBe(1);
|
|
51
49
|
expect(responses[0].status).toBe(200);
|
|
52
50
|
});
|
|
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
|
+
});
|
|
53
96
|
});
|
|
54
97
|
});
|
|
55
98
|
//# 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,wDAAgG;AAChG,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,6BAA6B,CAAA;YACzC,MAAM,KAAK,GAAG,8BAAe,CAAC;gBAC5B,SAAS;gBACT,KAAK,EAAE,YAAY;aACpB,CAAC,CAAA;YAEF,cAAI,CAAC,GAAG,CAAC;iBACN,IAAI,CAAC,GAAG,EAAE,KAAY,CAAC;iBACvB,KAAK,CAAC,GAAG,CAAC,CAAA;YAEb,MAAM,SAAS,GAAG,MAAM,eAAe,CAAC,UAAU,CAAC,MAAM,EAAE;gBACzD,KAAK;gBACL,OAAO,EAAE;oBACP,GAAG;iBACJ;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,+BAA+B,CAAA;YAE3C,MAAM,KAAK,GAAG,8BAAe,CAAC;gBAC5B,SAAS;gBACT,KAAK,EAAE,YAAY;aACpB,CAAC,CAAA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AAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACvC,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;YAC/C,MAAM,GAAG,GAAG,8BAA8B,CAAA;YAC1C,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,GAAG,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YAEnC,IAAI;gBACF,MAAM,eAAe,CAAC,UAAU,CAAC,MAAM,EAAE;oBACvC,KAAK;oBACL,OAAO,EAAE;wBACP,GAAG;wBACH,MAAM,EAAE,KAAK;wBACb,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;qBACrB;iBACF,CAAC,CAAA;gBACF,IAAI,CAAC,+BAA+B,CAAC,CAAA;aACtC;YAAC,OAAO,GAAG,EAAE;gBACZ,MAAM,KAAK,GAAG,GAAuB,CAAA;gBACrC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBAC9B,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;gBACtC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAA;aACzE;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { 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,5 +1,10 @@
|
|
|
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
|
+
];
|
|
3
8
|
const action = {
|
|
4
9
|
title: 'Send',
|
|
5
10
|
description: 'Send an HTTP request.',
|
|
@@ -33,6 +38,9 @@ const action = {
|
|
|
33
38
|
}
|
|
34
39
|
},
|
|
35
40
|
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
|
+
}
|
|
36
44
|
return request(payload.url, {
|
|
37
45
|
method: payload.method,
|
|
38
46
|
json: payload.data
|
|
@@ -40,6 +48,9 @@ const action = {
|
|
|
40
48
|
},
|
|
41
49
|
performBatch: (request, { payload }) => {
|
|
42
50
|
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
|
+
}
|
|
43
54
|
return request(url, {
|
|
44
55
|
method: method,
|
|
45
56
|
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":";;AAAA,wDAA0E;AAM1E,MAAM,YAAY,GAAG;IACnB,6BAA6B;IAC7B,+BAA+B;CAChC,CAAA;AAED,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,MAAM;IACb,WA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,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAErC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;QAElC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YAC/B,MAAM,IAAI,+BAAgB,CAAC,gBAAgB,GAAG,GAAG,EAAE,aAAa,EAAE,GAAG,CAAC,CAAA;SACvE;QAED,OAAO,OAAO,CAAC,GAAG,EAAE;YAClB,MAAM,EAAE,MAAuB;YAC/B,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,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.33.
|
|
4
|
+
"version": "3.33.3-alpha.10",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/segmentio/action-destinations",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@amplitude/ua-parser-js": "^0.7.25",
|
|
41
|
-
"@segment/actions-core": "^3.21.2-alpha.
|
|
41
|
+
"@segment/actions-core": "^3.21.2-alpha.10",
|
|
42
42
|
"dayjs": "^1.10.7",
|
|
43
43
|
"lodash": "^4.17.21",
|
|
44
44
|
"mustache": "^4.2.0"
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"<rootDir>/test/setup-after-env.ts"
|
|
59
59
|
]
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "398cfff04ed43bc1824303e0d013e2fc86b04f3b"
|
|
62
62
|
}
|