@segment/action-destinations 3.113.1-alpha.8 → 3.114.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/google-enhanced-conversions/uploadConversionAdjustment/generated-types.d.ts +1 -1
- package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/index.js +5 -3
- package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/index.js.map +1 -1
- package/dist/destinations/index.js +1 -0
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/linkedin-audiences/api/index.d.ts +13 -0
- package/dist/destinations/linkedin-audiences/api/index.js +62 -0
- package/dist/destinations/linkedin-audiences/api/index.js.map +1 -0
- package/dist/destinations/linkedin-audiences/constants.d.ts +3 -0
- package/dist/destinations/linkedin-audiences/constants.js +7 -0
- package/dist/destinations/linkedin-audiences/constants.js.map +1 -0
- package/dist/destinations/linkedin-audiences/generated-types.d.ts +2 -0
- package/dist/destinations/linkedin-audiences/index.js +50 -21
- package/dist/destinations/linkedin-audiences/index.js.map +1 -1
- package/dist/destinations/linkedin-audiences/types.d.ts +28 -0
- package/dist/destinations/linkedin-audiences/types.js +11 -0
- package/dist/destinations/linkedin-audiences/types.js.map +1 -0
- package/dist/destinations/linkedin-audiences/updateAudience/generated-types.d.ts +0 -2
- package/dist/destinations/linkedin-audiences/updateAudience/index.js +29 -66
- package/dist/destinations/linkedin-audiences/updateAudience/index.js.map +1 -1
- package/dist/destinations/loops/createOrUpdateContact/generated-types.d.ts +8 -0
- package/dist/destinations/loops/{createContact → createOrUpdateContact}/generated-types.js +0 -0
- package/dist/destinations/loops/createOrUpdateContact/generated-types.js.map +1 -0
- package/dist/destinations/loops/{createContact → createOrUpdateContact}/index.d.ts +0 -0
- package/dist/destinations/loops/createOrUpdateContact/index.js +82 -0
- package/dist/destinations/loops/createOrUpdateContact/index.js.map +1 -0
- package/dist/destinations/loops/index.js +2 -2
- package/dist/destinations/loops/index.js.map +1 -1
- package/dist/destinations/salesforce-marketing-cloud/_tests_/apiEvent.test.d.ts +1 -0
- package/dist/destinations/salesforce-marketing-cloud/_tests_/apiEvent.test.js +84 -0
- package/dist/destinations/salesforce-marketing-cloud/_tests_/apiEvent.test.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/_tests_/contact.test.d.ts +1 -0
- package/dist/destinations/salesforce-marketing-cloud/_tests_/contact.test.js +59 -0
- package/dist/destinations/salesforce-marketing-cloud/_tests_/contact.test.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/_tests_/contactDataExtension.test.d.ts +1 -0
- package/dist/destinations/salesforce-marketing-cloud/_tests_/contactDataExtension.test.js +77 -0
- package/dist/destinations/salesforce-marketing-cloud/_tests_/contactDataExtension.test.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/_tests_/dataExtension.test.d.ts +1 -0
- package/dist/destinations/salesforce-marketing-cloud/_tests_/dataExtension.test.js +61 -0
- package/dist/destinations/salesforce-marketing-cloud/_tests_/dataExtension.test.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/apiEvent/generated-types.d.ts +7 -0
- package/dist/destinations/salesforce-marketing-cloud/apiEvent/generated-types.js +3 -0
- package/dist/destinations/salesforce-marketing-cloud/apiEvent/generated-types.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/apiEvent/index.d.ts +5 -0
- package/dist/destinations/salesforce-marketing-cloud/apiEvent/index.js +20 -0
- package/dist/destinations/salesforce-marketing-cloud/apiEvent/index.js.map +1 -0
- package/dist/destinations/{loops/createContact → salesforce-marketing-cloud/contact}/generated-types.d.ts +1 -1
- package/dist/destinations/salesforce-marketing-cloud/contact/generated-types.js +3 -0
- package/dist/destinations/salesforce-marketing-cloud/contact/generated-types.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/contact/index.d.ts +5 -0
- package/dist/destinations/salesforce-marketing-cloud/contact/index.js +22 -0
- package/dist/destinations/salesforce-marketing-cloud/contact/index.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/generated-types.d.ts +12 -0
- package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/generated-types.js +3 -0
- package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/generated-types.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/index.d.ts +5 -0
- package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/index.js +37 -0
- package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/index.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/dataExtension/generated-types.d.ts +11 -0
- package/dist/destinations/salesforce-marketing-cloud/dataExtension/generated-types.js +3 -0
- package/dist/destinations/salesforce-marketing-cloud/dataExtension/generated-types.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/dataExtension/index.d.ts +5 -0
- package/dist/destinations/salesforce-marketing-cloud/dataExtension/index.js +23 -0
- package/dist/destinations/salesforce-marketing-cloud/dataExtension/index.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/generated-types.d.ts +6 -0
- package/dist/destinations/salesforce-marketing-cloud/generated-types.js +3 -0
- package/dist/destinations/salesforce-marketing-cloud/generated-types.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/index.d.ts +4 -0
- package/dist/destinations/salesforce-marketing-cloud/index.js +71 -0
- package/dist/destinations/salesforce-marketing-cloud/index.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/sfmc-operations.d.ts +4 -0
- package/dist/destinations/salesforce-marketing-cloud/sfmc-operations.js +31 -0
- package/dist/destinations/salesforce-marketing-cloud/sfmc-operations.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/sfmc-properties.d.ts +10 -0
- package/dist/destinations/salesforce-marketing-cloud/sfmc-properties.js +59 -0
- package/dist/destinations/salesforce-marketing-cloud/sfmc-properties.js.map +1 -0
- package/dist/destinations/snap-conversions-api/reportConversionEvent/generated-types.d.ts +3 -0
- package/dist/destinations/snap-conversions-api/reportConversionEvent/index.js +4 -1
- package/dist/destinations/snap-conversions-api/reportConversionEvent/index.js.map +1 -1
- package/dist/destinations/snap-conversions-api/snap-capi-properties.d.ts +3 -0
- package/dist/destinations/snap-conversions-api/snap-capi-properties.js +21 -3
- package/dist/destinations/snap-conversions-api/snap-capi-properties.js.map +1 -1
- package/package.json +4 -4
- package/dist/destinations/linkedin-audiences/linkedin-properties.d.ts +0 -1
- package/dist/destinations/linkedin-audiences/linkedin-properties.js +0 -5
- package/dist/destinations/linkedin-audiences/linkedin-properties.js.map +0 -1
- package/dist/destinations/loops/createContact/generated-types.js.map +0 -1
- package/dist/destinations/loops/createContact/index.js +0 -33
- package/dist/destinations/loops/createContact/index.js.map +0 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const action = {
|
|
4
|
+
title: 'Create or update a contact',
|
|
5
|
+
description: 'Create or update a contact in Loops',
|
|
6
|
+
defaultSubscription: 'type = "identify"',
|
|
7
|
+
fields: {
|
|
8
|
+
email: {
|
|
9
|
+
label: 'Contact Email',
|
|
10
|
+
description: 'Email address for the contact.',
|
|
11
|
+
type: 'string',
|
|
12
|
+
format: 'email',
|
|
13
|
+
required: true,
|
|
14
|
+
default: {
|
|
15
|
+
'@if': {
|
|
16
|
+
exists: { '@path': '$.traits.email' },
|
|
17
|
+
then: { '@path': '$.traits.email' },
|
|
18
|
+
else: { '@path': '$.email' }
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
firstName: {
|
|
23
|
+
label: 'First Name',
|
|
24
|
+
description: "The contact's given name.",
|
|
25
|
+
type: 'string',
|
|
26
|
+
required: false,
|
|
27
|
+
default: { '@path': '$.traits.firstName' }
|
|
28
|
+
},
|
|
29
|
+
lastName: {
|
|
30
|
+
label: 'Last Name',
|
|
31
|
+
description: "The contact's surname.",
|
|
32
|
+
type: 'string',
|
|
33
|
+
required: false,
|
|
34
|
+
default: { '@path': '$.traits.lastName' }
|
|
35
|
+
},
|
|
36
|
+
source: {
|
|
37
|
+
label: 'Source',
|
|
38
|
+
description: "The contact's source.",
|
|
39
|
+
type: 'string',
|
|
40
|
+
required: false,
|
|
41
|
+
default: {
|
|
42
|
+
'@if': {
|
|
43
|
+
exists: { '@path': '$.traits.source' },
|
|
44
|
+
then: { '@path': '$.traits.source' },
|
|
45
|
+
else: 'Segment'
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
userGroup: {
|
|
50
|
+
label: 'User Group',
|
|
51
|
+
description: "The contact's user group.",
|
|
52
|
+
type: 'string',
|
|
53
|
+
required: false,
|
|
54
|
+
default: { '@path': '$.traits.lastName' }
|
|
55
|
+
},
|
|
56
|
+
userId: {
|
|
57
|
+
label: 'User ID',
|
|
58
|
+
description: 'User ID for the contact.',
|
|
59
|
+
type: 'string',
|
|
60
|
+
format: 'text',
|
|
61
|
+
required: true,
|
|
62
|
+
default: {
|
|
63
|
+
'@path': '$.userId'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
perform: (request, { payload }) => {
|
|
68
|
+
return request('https://app.loops.so/api/v1/contacts/update', {
|
|
69
|
+
method: 'put',
|
|
70
|
+
json: {
|
|
71
|
+
email: payload.email,
|
|
72
|
+
firstName: payload.firstName,
|
|
73
|
+
lastName: payload.lastName,
|
|
74
|
+
source: payload.source,
|
|
75
|
+
userGroup: payload.userGroup,
|
|
76
|
+
userId: payload.userId
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
exports.default = action;
|
|
82
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/loops/createOrUpdateContact/index.ts"],"names":[],"mappings":";;AAIA,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,4BAA4B;IACnC,WAAW,EAAE,qCAAqC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EAAE,SAAS;YAChB,WAAW,EAAE,0BAA0B;YACvC,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;KACF;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAChC,OAAO,OAAO,CAAC,6CAA6C,EAAE;YAC5D,MAAM,EAAE,KAAK;YACb,IAAI,EAAE;gBACJ,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;aACvB;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const createOrUpdateContact_1 = __importDefault(require("./createOrUpdateContact"));
|
|
7
7
|
const destination = {
|
|
8
8
|
name: 'Loops (Actions)',
|
|
9
9
|
slug: 'actions-loops',
|
|
@@ -28,7 +28,7 @@ const destination = {
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
actions: {
|
|
31
|
-
|
|
31
|
+
createOrUpdateContact: createOrUpdateContact_1.default
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
exports.default = destination;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/loops/index.ts"],"names":[],"mappings":";;;;;AAGA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/loops/index.ts"],"names":[],"mappings":";;;;;AAGA,oFAA2D;AAE3D,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,OAAO;IAEb,aAAa,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC9B,OAAO;YACL,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,QAAQ,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;SAC5F,CAAA;IACH,CAAC;IAED,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,MAAM,EAAE;gBACN,KAAK,EAAE,SAAS;gBAChB,WAAW,EAAE,oBAAoB;gBACjC,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;aACf;SACF;QACD,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE;YAC9B,OAAO,OAAO,CAAC,qCAAqC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;QAC1E,CAAC;KACF;IAED,OAAO,EAAE;QACP,qBAAqB,EAArB,+BAAqB;KACtB;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
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 nock_1 = __importDefault(require("nock"));
|
|
7
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
8
|
+
const index_1 = __importDefault(require("../index"));
|
|
9
|
+
const testDestination = actions_core_1.createTestIntegration(index_1.default);
|
|
10
|
+
const timestamp = '2022-05-12T15:21:15.449Z';
|
|
11
|
+
const settings = {
|
|
12
|
+
subdomain: 'test123',
|
|
13
|
+
client_id: 'test123',
|
|
14
|
+
client_secret: 'test123',
|
|
15
|
+
account_id: 'test123'
|
|
16
|
+
};
|
|
17
|
+
const event = actions_core_1.createTestEvent({
|
|
18
|
+
timestamp: timestamp,
|
|
19
|
+
userId: 'eric-15',
|
|
20
|
+
type: 'track',
|
|
21
|
+
properties: {
|
|
22
|
+
contactKey: 'ericForman15',
|
|
23
|
+
eventDefinitionKey: '123',
|
|
24
|
+
eventData: {
|
|
25
|
+
Email: 'eric.forman@test.com',
|
|
26
|
+
First_Name: 'Eric',
|
|
27
|
+
Last_Name: 'Forman'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const requestUrl = `https://${settings.subdomain}.rest.marketingcloudapis.com/interaction/v1/events`;
|
|
32
|
+
describe('Salesforce Marketing Cloud', () => {
|
|
33
|
+
describe('Send API Event Action', () => {
|
|
34
|
+
it('Send API Event', async () => {
|
|
35
|
+
nock_1.default(requestUrl).post('').reply(200, {});
|
|
36
|
+
const responses = await testDestination.testAction('apiEvent', {
|
|
37
|
+
event,
|
|
38
|
+
settings,
|
|
39
|
+
mapping: {
|
|
40
|
+
contactKey: { '@path': '$.properties.contactKey' },
|
|
41
|
+
eventDefinitionKey: { '@path': '$.properties.eventDefinitionKey' },
|
|
42
|
+
data: { '@path': '$.properties.eventData' }
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
expect(responses[0].status).toBe(200);
|
|
46
|
+
expect(responses[0].options.body).toMatchInlineSnapshot(`"{\\"contactKey\\":\\"ericForman15\\",\\"eventDefinitionKey\\":\\"123\\",\\"data\\":{\\"Email\\":\\"eric.forman@test.com\\",\\"First_Name\\":\\"Eric\\",\\"Last_Name\\":\\"Forman\\"}}"`);
|
|
47
|
+
});
|
|
48
|
+
it('Send API Event with Default', async () => {
|
|
49
|
+
nock_1.default(requestUrl).post('').reply(200, {});
|
|
50
|
+
const responses = await testDestination.testAction('apiEvent', {
|
|
51
|
+
event,
|
|
52
|
+
settings,
|
|
53
|
+
useDefaultMappings: true,
|
|
54
|
+
mapping: {
|
|
55
|
+
eventDefinitionKey: { '@path': '$.properties.eventDefinitionKey' },
|
|
56
|
+
data: { '@path': '$.properties.eventData' }
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
expect(responses[0].status).toBe(200);
|
|
60
|
+
expect(responses[0].options.body).toMatchInlineSnapshot(`"{\\"eventDefinitionKey\\":\\"123\\",\\"contactKey\\":\\"eric-15\\",\\"data\\":{\\"Email\\":\\"eric.forman@test.com\\",\\"First_Name\\":\\"Eric\\",\\"Last_Name\\":\\"Forman\\"}}"`);
|
|
61
|
+
});
|
|
62
|
+
it('Send API Event without Data', async () => {
|
|
63
|
+
nock_1.default(requestUrl).post('').reply(200, {});
|
|
64
|
+
const responses = await testDestination.testAction('apiEvent', {
|
|
65
|
+
event,
|
|
66
|
+
settings,
|
|
67
|
+
useDefaultMappings: true,
|
|
68
|
+
mapping: {
|
|
69
|
+
eventDefinitionKey: { '@path': '$.properties.eventDefinitionKey' }
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
expect(responses[0].status).toBe(200);
|
|
73
|
+
expect(responses[0].options.body).toMatchInlineSnapshot(`"{\\"eventDefinitionKey\\":\\"123\\",\\"contactKey\\":\\"eric-15\\"}"`);
|
|
74
|
+
});
|
|
75
|
+
it('Fail to send api event due to missing required fields -> contactKey & eventDefinitionKey', async () => {
|
|
76
|
+
nock_1.default(requestUrl).post('').reply(400, {});
|
|
77
|
+
await expect(testDestination.testAction('apiEvent', {
|
|
78
|
+
event,
|
|
79
|
+
settings
|
|
80
|
+
})).rejects.toThrowError(`The root value is missing the required field 'eventDefinitionKey'. The root value is missing the required field 'contactKey'.`);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=apiEvent.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ap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E;oBACP,kBAAkB,EAAE,EAAE,OAAO,EAAE,iCAAiC,EAAE;iBACnE;aACF,CAAC,CAAA;YACF,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACrC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,qBAAqB,CACrD,uEAAuE,CACxE,CAAA;QACH,CAAC,CAAC,CAAA;QACF,EAAE,CAAC,0FAA0F,EAAE,KAAK,IAAI,EAAE;YACxG,cAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;YACxC,MAAM,MAAM,CACV,eAAe,CAAC,UAAU,CAAC,UAAU,EAAE;gBACrC,KAAK;gBACL,QAAQ;aACT,CAAC,CACH,CAAC,OAAO,CAAC,YAAY,CACpB,+HAA+H,CAChI,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
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 nock_1 = __importDefault(require("nock"));
|
|
7
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
8
|
+
const index_1 = __importDefault(require("../index"));
|
|
9
|
+
const testDestination = actions_core_1.createTestIntegration(index_1.default);
|
|
10
|
+
const timestamp = '2022-05-12T15:21:15.449Z';
|
|
11
|
+
const settings = {
|
|
12
|
+
subdomain: 'test123',
|
|
13
|
+
client_id: 'test123',
|
|
14
|
+
client_secret: 'test123',
|
|
15
|
+
account_id: 'test123'
|
|
16
|
+
};
|
|
17
|
+
const event = actions_core_1.createTestEvent({
|
|
18
|
+
timestamp: timestamp,
|
|
19
|
+
userId: 'eric-15',
|
|
20
|
+
type: 'identify',
|
|
21
|
+
traits: {
|
|
22
|
+
contactKey: 'ericForman15'
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const requestUrl = `https://${settings.subdomain}.rest.marketingcloudapis.com/contacts/v1/contacts`;
|
|
26
|
+
describe('Salesforce Marketing Cloud', () => {
|
|
27
|
+
describe('Create Contact Action', () => {
|
|
28
|
+
it('Create a Contact', async () => {
|
|
29
|
+
nock_1.default(requestUrl).post('').reply(200, {});
|
|
30
|
+
const responses = await testDestination.testAction('contact', {
|
|
31
|
+
event,
|
|
32
|
+
settings,
|
|
33
|
+
mapping: {
|
|
34
|
+
contactKey: { '@path': '$.traits.contactKey' }
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
expect(responses[0].status).toBe(200);
|
|
38
|
+
expect(responses[0].options.body).toMatchInlineSnapshot(`"{\\"contactKey\\":\\"ericForman15\\",\\"attributeSets\\":[]}"`);
|
|
39
|
+
});
|
|
40
|
+
it('Create a Contact with Default', async () => {
|
|
41
|
+
nock_1.default(requestUrl).post('').reply(200, {});
|
|
42
|
+
const responses = await testDestination.testAction('contact', {
|
|
43
|
+
event,
|
|
44
|
+
settings,
|
|
45
|
+
useDefaultMappings: true
|
|
46
|
+
});
|
|
47
|
+
expect(responses[0].status).toBe(200);
|
|
48
|
+
expect(responses[0].options.body).toMatchInlineSnapshot(`"{\\"contactKey\\":\\"eric-15\\",\\"attributeSets\\":[]}"`);
|
|
49
|
+
});
|
|
50
|
+
it('Fail to create contact due to missing required field -> contactKey', async () => {
|
|
51
|
+
nock_1.default(requestUrl).post('').reply(400, {});
|
|
52
|
+
await expect(testDestination.testAction('contact', {
|
|
53
|
+
event,
|
|
54
|
+
settings
|
|
55
|
+
})).rejects.toThrowError(`The root value is missing the required field 'contactKey'.`);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=contact.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact.test.js","sourceRoot":"","sources":["../../../../src/destinations/salesforce-marketing-cloud/_tests_/contact.test.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;AACvB,wDAA8E;AAC9E,qDAAiC;AAGjC,MAAM,eAAe,GAAG,oCAAqB,CAAC,eAAU,CAAC,CAAA;AACzD,MAAM,SAAS,GAAG,0BAA0B,CAAA;AAC5C,MAAM,QAAQ,GAAa;IACzB,SAAS,EAAE,SAAS;IACpB,SAAS,EAAE,SAAS;IACpB,aAAa,EAAE,SAAS;IACxB,UAAU,EAAE,SAAS;CACtB,CAAA;AAED,MAAM,KAAK,GAAG,8BAAe,CAAC;IAC5B,SAAS,EAAE,SAAS;IACpB,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE;QACN,UAAU,EAAE,cAAc;KAC3B;CACF,CAAC,CAAA;AAEF,MAAM,UAAU,GAAG,WAAW,QAAQ,CAAC,SAAS,mDAAmD,CAAA;AACnG,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC1C,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;QACrC,EAAE,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;YAChC,cAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;YACxC,MAAM,SAAS,GAAG,MAAM,eAAe,CAAC,UAAU,CAAC,SAAS,EAAE;gBAC5D,KAAK;gBACL,QAAQ;gBACR,OAAO,EAAE;oBACP,UAAU,EAAE,EAAE,OAAO,EAAE,qBAAqB,EAAE;iBAC/C;aACF,CAAC,CAAA;YACF,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACrC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,qBAAqB,CACrD,gEAAgE,CACjE,CAAA;QACH,CAAC,CAAC,CAAA;QACF,EAAE,CAAC,+BAA+B,EAAE,KAAK,IAAI,EAAE;YAC7C,cAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;YACxC,MAAM,SAAS,GAAG,MAAM,eAAe,CAAC,UAAU,CAAC,SAAS,EAAE;gBAC5D,KAAK;gBACL,QAAQ;gBACR,kBAAkB,EAAE,IAAI;aACzB,CAAC,CAAA;YACF,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACrC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,qBAAqB,CACrD,2DAA2D,CAC5D,CAAA;QACH,CAAC,CAAC,CAAA;QACF,EAAE,CAAC,oEAAoE,EAAE,KAAK,IAAI,EAAE;YAClF,cAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;YACxC,MAAM,MAAM,CACV,eAAe,CAAC,UAAU,CAAC,SAAS,EAAE;gBACpC,KAAK;gBACL,QAAQ;aACT,CAAC,CACH,CAAC,OAAO,CAAC,YAAY,CAAC,4DAA4D,CAAC,CAAA;QACtF,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
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 nock_1 = __importDefault(require("nock"));
|
|
7
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
8
|
+
const index_1 = __importDefault(require("../index"));
|
|
9
|
+
const testDestination = actions_core_1.createTestIntegration(index_1.default);
|
|
10
|
+
const timestamp = '2022-05-12T15:21:15.449Z';
|
|
11
|
+
const settings = {
|
|
12
|
+
subdomain: 'test123',
|
|
13
|
+
client_id: 'test123',
|
|
14
|
+
client_secret: 'test123',
|
|
15
|
+
account_id: 'test123'
|
|
16
|
+
};
|
|
17
|
+
const event = actions_core_1.createTestEvent({
|
|
18
|
+
timestamp: timestamp,
|
|
19
|
+
userId: 'harry-1',
|
|
20
|
+
type: 'identify',
|
|
21
|
+
traits: {
|
|
22
|
+
key: 'dataExtension12',
|
|
23
|
+
keys: {
|
|
24
|
+
contactKey: 'harryStyles1',
|
|
25
|
+
id: 'HS1'
|
|
26
|
+
},
|
|
27
|
+
values: {
|
|
28
|
+
First_Name: 'Harry',
|
|
29
|
+
Last_Name: 'Styles'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const requestUrl = `https://${settings.subdomain}.rest.marketingcloudapis.com/hub/v1/dataevents/key:dataExtension12/rowset`;
|
|
34
|
+
describe('Salesforce Marketing Cloud', () => {
|
|
35
|
+
describe('Contact Data Extension Action', () => {
|
|
36
|
+
it('Add Contact to Data Extension', async () => {
|
|
37
|
+
nock_1.default(requestUrl).post('').reply(200, {});
|
|
38
|
+
const responses = await testDestination.testAction('contactDataExtension', {
|
|
39
|
+
event,
|
|
40
|
+
settings,
|
|
41
|
+
mapping: {
|
|
42
|
+
key: { '@path': '$.traits.key' },
|
|
43
|
+
keys: { '@path': '$.traits.keys' },
|
|
44
|
+
values: { '@path': '$.traits.values' }
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
expect(responses[0].status).toBe(200);
|
|
48
|
+
expect(responses[0].options.body).toMatchInlineSnapshot(`"[{\\"keys\\":{\\"contactKey\\":\\"harryStyles1\\",\\"id\\":\\"HS1\\"},\\"values\\":{\\"First_Name\\":\\"Harry\\",\\"Last_Name\\":\\"Styles\\"}}]"`);
|
|
49
|
+
});
|
|
50
|
+
it('Add Contact to Data Extension with default', async () => {
|
|
51
|
+
nock_1.default(requestUrl).post('').reply(200, {});
|
|
52
|
+
const responses = await testDestination.testAction('contactDataExtension', {
|
|
53
|
+
event,
|
|
54
|
+
settings,
|
|
55
|
+
useDefaultMappings: true,
|
|
56
|
+
mapping: {
|
|
57
|
+
key: { '@path': '$.traits.key' },
|
|
58
|
+
values: { '@path': '$.traits.values' }
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
expect(responses[0].status).toBe(200);
|
|
62
|
+
expect(responses[0].options.body).toMatchInlineSnapshot(`"[{\\"keys\\":{\\"contactKey\\":\\"harry-1\\"},\\"values\\":{\\"First_Name\\":\\"Harry\\",\\"Last_Name\\":\\"Styles\\"}}]"`);
|
|
63
|
+
});
|
|
64
|
+
it('Fail to add contact to data extension due to missing key and id', async () => {
|
|
65
|
+
nock_1.default(requestUrl).post('').reply(400, {});
|
|
66
|
+
await expect(testDestination.testAction('contactDataExtension', {
|
|
67
|
+
event,
|
|
68
|
+
settings,
|
|
69
|
+
mapping: {
|
|
70
|
+
keys: { '@path': '$.traits.keys' },
|
|
71
|
+
values: { '@path': '$.traits.values' }
|
|
72
|
+
}
|
|
73
|
+
})).rejects.toThrowError(`In order to send an event to a data extension either Data Extension ID or Data Extension Key must be defined.`);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=contactDataExtension.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contactDataExtension.test.js","sourceRoot":"","sources":["../../../../src/destinations/salesforce-marketing-cloud/_tests_/contactDataExtension.test.ts"],"names":[],"mappings":";;;;;AAAA,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ACH,CAAC,OAAO,CAAC,YAAY,CACpB,+GAA+G,CAChH,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
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 nock_1 = __importDefault(require("nock"));
|
|
7
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
8
|
+
const index_1 = __importDefault(require("../index"));
|
|
9
|
+
const testDestination = actions_core_1.createTestIntegration(index_1.default);
|
|
10
|
+
const timestamp = '2022-05-12T15:21:15.449Z';
|
|
11
|
+
const settings = {
|
|
12
|
+
subdomain: 'test123',
|
|
13
|
+
client_id: 'test123',
|
|
14
|
+
client_secret: 'test123',
|
|
15
|
+
account_id: 'test123'
|
|
16
|
+
};
|
|
17
|
+
const event = actions_core_1.createTestEvent({
|
|
18
|
+
timestamp: timestamp,
|
|
19
|
+
type: 'track',
|
|
20
|
+
userId: 'harry-1',
|
|
21
|
+
properties: {
|
|
22
|
+
id: '1234567890',
|
|
23
|
+
keys: {
|
|
24
|
+
id: 'HS1'
|
|
25
|
+
},
|
|
26
|
+
values: {
|
|
27
|
+
name: 'Harry Styles'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const requestUrl = `https://${settings.subdomain}.rest.marketingcloudapis.com/hub/v1/dataevents/1234567890/rowset`;
|
|
32
|
+
describe('Salesforce Marketing Cloud', () => {
|
|
33
|
+
describe('Data Extension Action', () => {
|
|
34
|
+
it('Add Event to Data Extension', async () => {
|
|
35
|
+
nock_1.default(requestUrl).post('').reply(200, {});
|
|
36
|
+
const responses = await testDestination.testAction('dataExtension', {
|
|
37
|
+
event,
|
|
38
|
+
settings,
|
|
39
|
+
mapping: {
|
|
40
|
+
id: { '@path': '$.properties.id' },
|
|
41
|
+
keys: { '@path': '$.properties.keys' },
|
|
42
|
+
values: { '@path': '$.properties.values' }
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
expect(responses[0].status).toBe(200);
|
|
46
|
+
expect(responses[0].options.body).toMatchInlineSnapshot(`"[{\\"keys\\":{\\"id\\":\\"HS1\\"},\\"values\\":{\\"name\\":\\"Harry Styles\\"}}]"`);
|
|
47
|
+
});
|
|
48
|
+
it('Fail to add event to data extension due to missing key and id', async () => {
|
|
49
|
+
nock_1.default(requestUrl).post('').reply(400, {});
|
|
50
|
+
await expect(testDestination.testAction('dataExtension', {
|
|
51
|
+
event,
|
|
52
|
+
settings,
|
|
53
|
+
mapping: {
|
|
54
|
+
keys: { '@path': '$.properties.keys' },
|
|
55
|
+
values: { '@path': '$.properties.values' }
|
|
56
|
+
}
|
|
57
|
+
})).rejects.toThrowError(`In order to send an event to a data extension either Data Extension ID or Data Extension Key must be defined.`);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=dataExtension.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataExtension.test.js","sourceRoot":"","sources":["../../../../src/destinations/salesforce-marketing-cloud/_tests_/dataExtension.test.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;AACvB,wDAA8E;AAC9E,qDAAiC;AAGjC,MAAM,eAAe,GAAG,oCAAqB,CAAC,eAAU,CAAC,CAAA;AACzD,MAAM,SAAS,GAAG,0BAA0B,CAAA;AAC5C,MAAM,QAAQ,GAAa;IACzB,SAAS,EAAE,SAAS;IACpB,SAAS,EAAE,SAAS;IACpB,aAAa,EAAE,SAAS;IACxB,UAAU,EAAE,SAAS;CACtB,CAAA;AAED,MAAM,KAAK,GAAG,8BAAe,CAAC;IAC5B,SAAS,EAAE,SAAS;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,UAAU,CAAC,eAAe,EAAE;gBAC1C,KAAK;gBACL,QAAQ;gBACR,OAAO,EAAE;oBACP,IAAI,EAAE,EAAE,OAAO,EAAE,mBAAmB,EAAE;oBACtC,MAAM,EAAE,EAAE,OAAO,EAAE,qBAAqB,EAAE;iBAC3C;aACF,CAAC,CACH,CAAC,OAAO,CAAC,YAAY,CACpB,+GAA+G,CAChH,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/salesforce-marketing-cloud/apiEvent/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const sfmc_properties_1 = require("../sfmc-properties");
|
|
4
|
+
const action = {
|
|
5
|
+
title: 'Send API Event',
|
|
6
|
+
description: 'Send events into an existing Event Definition in Salesforce Marketing Cloud.',
|
|
7
|
+
fields: {
|
|
8
|
+
eventDefinitionKey: sfmc_properties_1.eventDefinitionKey,
|
|
9
|
+
contactKey: sfmc_properties_1.contactKeyAPIEvent,
|
|
10
|
+
data: sfmc_properties_1.eventData
|
|
11
|
+
},
|
|
12
|
+
perform: (request, { settings, payload }) => {
|
|
13
|
+
return request(`https://${settings.subdomain}.rest.marketingcloudapis.com/interaction/v1/events`, {
|
|
14
|
+
method: 'POST',
|
|
15
|
+
json: payload
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.default = action;
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/salesforce-marketing-cloud/apiEvent/index.ts"],"names":[],"mappings":";;AAEA,wDAAsF;AAGtF,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,gBAAgB;IACvB,WAAW,EAAE,8EAA8E;IAC3F,MAAM,EAAE;QACN,kBAAkB,EAAE,oCAAkB;QACtC,UAAU,EAAE,oCAAkB;QAC9B,IAAI,EAAE,2BAAS;KAChB;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QAC1C,OAAO,OAAO,CAAC,WAAW,QAAQ,CAAC,SAAS,oDAAoD,EAAE;YAChG,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,OAAO;SACd,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/salesforce-marketing-cloud/contact/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const sfmc_properties_1 = require("../sfmc-properties");
|
|
4
|
+
const action = {
|
|
5
|
+
title: 'Create Contact',
|
|
6
|
+
description: 'Create contacts in Salesforce Marketing Cloud.',
|
|
7
|
+
defaultSubscription: 'type = "identify"',
|
|
8
|
+
fields: {
|
|
9
|
+
contactKey: { ...sfmc_properties_1.contactKey, required: true }
|
|
10
|
+
},
|
|
11
|
+
perform: (request, { settings, payload }) => {
|
|
12
|
+
return request(`https://${settings.subdomain}.rest.marketingcloudapis.com/contacts/v1/contacts`, {
|
|
13
|
+
method: 'POST',
|
|
14
|
+
json: {
|
|
15
|
+
contactKey: payload.contactKey,
|
|
16
|
+
attributeSets: []
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.default = action;
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/salesforce-marketing-cloud/contact/index.ts"],"names":[],"mappings":";;AAEA,wDAA+C;AAG/C,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,gBAAgB;IACvB,WAAW,EAAE,gDAAgD;IAC7D,mBAAmB,EAAE,mBAAmB;IACxC,MAAM,EAAE;QACN,UAAU,EAAE,EAAE,GAAG,4BAAU,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC9C;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QAC9C,OAAO,OAAO,CAAC,WAAW,QAAQ,CAAC,SAAS,mDAAmD,EAAE;YAC3F,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,aAAa,EAAE,EAAE;aAClB;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/generated-types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/salesforce-marketing-cloud/contactDataExtension/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const sfmc_properties_1 = require("../sfmc-properties");
|
|
4
|
+
const sfmc_operations_1 = require("../sfmc-operations");
|
|
5
|
+
const action = {
|
|
6
|
+
title: 'Contact Data Extension',
|
|
7
|
+
defaultSubscription: 'type = "identify"',
|
|
8
|
+
description: 'Upsert contact data as rows into an existing data extension in Salesforce Marketing Cloud.',
|
|
9
|
+
fields: {
|
|
10
|
+
key: sfmc_properties_1.key,
|
|
11
|
+
id: sfmc_properties_1.id,
|
|
12
|
+
keys: {
|
|
13
|
+
...sfmc_properties_1.keys,
|
|
14
|
+
properties: {
|
|
15
|
+
contactKey: {
|
|
16
|
+
label: 'Contact Key',
|
|
17
|
+
description: 'The unique identifier that you assign to a contact. Contact Key must be a Primary Key in the data extension that contains contact information.',
|
|
18
|
+
type: 'string',
|
|
19
|
+
required: true
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
default: {
|
|
23
|
+
contactKey: { '@path': '$.userId' }
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
values: sfmc_properties_1.values,
|
|
27
|
+
enable_batching: sfmc_properties_1.enable_batching
|
|
28
|
+
},
|
|
29
|
+
perform: async (request, { settings, payload }) => {
|
|
30
|
+
return sfmc_operations_1.upsertRows(request, settings.subdomain, [payload]);
|
|
31
|
+
},
|
|
32
|
+
performBatch: async (request, { settings, payload }) => {
|
|
33
|
+
return sfmc_operations_1.upsertRows(request, settings.subdomain, payload);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
exports.default = action;
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/salesforce-marketing-cloud/contactDataExtension/index.ts"],"names":[],"mappings":";;AAGA,wDAA2E;AAC3E,wDAA+C;AAE/C,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,wBAAwB;IAC/B,mBAAmB,EAAE,mBAAmB;IACxC,WAAW,EAAE,4FAA4F;IACzG,MAAM,EAAE;QACN,GAAG,EAAE,qBAAG;QACR,EAAE,EAAE,oBAAE;QACN,IAAI,EAAE;YACJ,GAAG,sBAAI;YACP,UAAU,EAAE;gBACV,UAAU,EAAE;oBACV,KAAK,EAAE,aAAa;oBACpB,WAAW,EACT,gJAAgJ;oBAClJ,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,IAAI;iBACf;aACF;YACD,OAAO,EAAE;gBACP,UAAU,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;aACpC;SACF;QACD,MAAM,EAAE,wBAAM;QACd,eAAe,EAAE,iCAAe;KACjC;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QAChD,OAAO,4BAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IAC3D,CAAC;IACD,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QACrD,OAAO,4BAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IACzD,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/salesforce-marketing-cloud/dataExtension/generated-types.ts"],"names":[],"mappings":""}
|