@segment/action-destinations 3.267.1-staging.1 → 3.268.0-staging-4cdde7a9f
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/amazon-ads/generated-types.d.ts +9 -0
- package/dist/destinations/amazon-ads/index.d.ts +2 -2
- package/dist/destinations/amazon-ads/index.js +172 -6
- package/dist/destinations/amazon-ads/index.js.map +1 -1
- package/dist/destinations/amazon-ads/syncAudiences/generated-types.d.ts +13 -0
- package/dist/destinations/amazon-ads/syncAudiences/index.js +201 -7
- package/dist/destinations/amazon-ads/syncAudiences/index.js.map +1 -1
- package/dist/destinations/amazon-ads/types.d.ts +25 -0
- package/dist/destinations/amazon-ads/utils.d.ts +31 -0
- package/dist/destinations/amazon-ads/utils.js +18 -0
- package/dist/destinations/amazon-ads/utils.js.map +1 -0
- package/dist/destinations/amplitude/user-agent.d.ts +1 -0
- package/dist/destinations/amplitude/user-agent.js +2 -1
- package/dist/destinations/amplitude/user-agent.js.map +1 -1
- package/dist/destinations/contentstack/constants.d.ts +3 -0
- package/dist/destinations/contentstack/constants.js +7 -0
- package/dist/destinations/contentstack/constants.js.map +1 -0
- package/dist/destinations/contentstack/customAttributesSync/generated-types.d.ts +6 -0
- package/dist/destinations/contentstack/customAttributesSync/generated-types.js +3 -0
- package/dist/destinations/contentstack/customAttributesSync/generated-types.js.map +1 -0
- package/dist/destinations/contentstack/customAttributesSync/index.d.ts +5 -0
- package/dist/destinations/contentstack/customAttributesSync/index.js +45 -0
- package/dist/destinations/contentstack/customAttributesSync/index.js.map +1 -0
- package/dist/destinations/contentstack/customAttributesSync/types.d.ts +14 -0
- package/dist/destinations/contentstack/customAttributesSync/types.js +3 -0
- package/dist/destinations/contentstack/customAttributesSync/types.js.map +1 -0
- package/dist/destinations/contentstack/customAttributesSync/utils.d.ts +4 -0
- package/dist/destinations/contentstack/customAttributesSync/utils.js +21 -0
- package/dist/destinations/contentstack/customAttributesSync/utils.js.map +1 -0
- package/dist/destinations/contentstack/generated-types.d.ts +4 -0
- package/dist/destinations/contentstack/generated-types.js +3 -0
- package/dist/destinations/contentstack/generated-types.js.map +1 -0
- package/dist/destinations/contentstack/index.d.ts +4 -0
- package/dist/destinations/contentstack/index.js +58 -0
- package/dist/destinations/contentstack/index.js.map +1 -0
- package/dist/destinations/contentstack/types.d.ts +12 -0
- package/dist/destinations/contentstack/types.js +3 -0
- package/dist/destinations/contentstack/types.js.map +1 -0
- package/dist/destinations/engage/utils/track.d.ts +17 -17
- package/dist/destinations/engage-messaging-sendgrid/index.d.ts +4 -3
- package/dist/destinations/engage-messaging-sendgrid/index.js +68 -16
- package/dist/destinations/engage-messaging-sendgrid/index.js.map +1 -1
- package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/apiLookups.d.ts +22 -0
- package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/apiLookups.js +189 -0
- package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/apiLookups.js.map +1 -0
- package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/generated-types.d.ts +16 -0
- package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/generated-types.js +3 -0
- package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/generated-types.js.map +1 -0
- package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/index.d.ts +5 -0
- package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/index.js +29 -0
- package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/index.js.map +1 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/SendEmailPerformer.d.ts +43 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/SendEmailPerformer.js +419 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/SendEmailPerformer.js.map +1 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/UnlayerResponse.d.ts +12 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/UnlayerResponse.js +3 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/UnlayerResponse.js.map +1 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/generated-types.d.ts +56 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/generated-types.js +3 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/generated-types.js.map +1 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.d.ts +5 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.js +258 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.js.map +1 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/insertEmailPreviewText.d.ts +1 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/insertEmailPreviewText.js +23 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/insertEmailPreviewText.js.map +1 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/isRestrictedDomain.d.ts +1 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/isRestrictedDomain.js +14 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/isRestrictedDomain.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/index.d.ts +4 -3
- package/dist/destinations/engage-messaging-twilio/index.js +169 -15
- package/dist/destinations/engage-messaging-twilio/index.js.map +1 -1
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/PushSender.d.ts +29 -0
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/PushSender.js +169 -0
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/PushSender.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/generated-types.d.ts +39 -0
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/generated-types.js +3 -0
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/generated-types.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/index.d.ts +5 -0
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/index.js +251 -0
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/index.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/sendSms/SmsMessageSender.d.ts +9 -0
- package/dist/destinations/engage-messaging-twilio/sendSms/SmsMessageSender.js +72 -0
- package/dist/destinations/engage-messaging-twilio/sendSms/SmsMessageSender.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/sendSms/generated-types.d.ts +27 -0
- package/dist/destinations/engage-messaging-twilio/sendSms/generated-types.js +3 -0
- package/dist/destinations/engage-messaging-twilio/sendSms/generated-types.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/sendSms/index.d.ts +5 -0
- package/dist/destinations/engage-messaging-twilio/sendSms/index.js +163 -0
- package/dist/destinations/engage-messaging-twilio/sendSms/index.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/WhatsAppMessageSender.d.ts +9 -0
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/WhatsAppMessageSender.js +89 -0
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/WhatsAppMessageSender.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/generated-types.d.ts +25 -0
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/generated-types.js +3 -0
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/generated-types.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.d.ts +5 -0
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.js +137 -0
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/utils/PhoneMessageSender.d.ts +16 -0
- package/dist/destinations/engage-messaging-twilio/utils/PhoneMessageSender.js +71 -0
- package/dist/destinations/engage-messaging-twilio/utils/PhoneMessageSender.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/utils/TwilioMessageSender.d.ts +16 -0
- package/dist/destinations/engage-messaging-twilio/utils/TwilioMessageSender.js +115 -0
- package/dist/destinations/engage-messaging-twilio/utils/TwilioMessageSender.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/utils/index.d.ts +2 -0
- package/dist/destinations/engage-messaging-twilio/utils/index.js +15 -0
- package/dist/destinations/engage-messaging-twilio/utils/index.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/utils/types.d.ts +23 -0
- package/dist/destinations/engage-messaging-twilio/utils/types.js +3 -0
- package/dist/destinations/engage-messaging-twilio/utils/types.js.map +1 -0
- package/dist/destinations/facebook-conversions-api/fb-capi-properties.js +3 -1
- package/dist/destinations/facebook-conversions-api/fb-capi-properties.js.map +1 -1
- package/dist/destinations/index.js +2 -0
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/insider/index.js +5 -1
- package/dist/destinations/insider/index.js.map +1 -1
- package/dist/destinations/klaviyo/functions.d.ts +18 -1
- package/dist/destinations/klaviyo/functions.js +75 -2
- package/dist/destinations/klaviyo/functions.js.map +1 -1
- package/dist/destinations/klaviyo/types.d.ts +4 -0
- package/dist/destinations/klaviyo/types.js.map +1 -1
- package/dist/destinations/klaviyo/upsertProfile/generated-types.d.ts +1 -0
- package/dist/destinations/klaviyo/upsertProfile/index.js +15 -7
- package/dist/destinations/klaviyo/upsertProfile/index.js.map +1 -1
- package/dist/destinations/mixpanel/mixpanel-properties.js +1 -0
- package/dist/destinations/mixpanel/mixpanel-properties.js.map +1 -1
- package/dist/destinations/moloco-rmp/common/convert.js +29 -17
- package/dist/destinations/moloco-rmp/common/convert.js.map +1 -1
- package/dist/destinations/ripe/group/generated-types.d.ts +3 -0
- package/dist/destinations/ripe/group/index.js +9 -1
- package/dist/destinations/ripe/group/index.js.map +1 -1
- package/dist/destinations/ripe/identify/generated-types.d.ts +3 -1
- package/dist/destinations/ripe/identify/index.js +7 -9
- package/dist/destinations/ripe/identify/index.js.map +1 -1
- package/dist/destinations/ripe/page/generated-types.d.ts +3 -1
- package/dist/destinations/ripe/page/index.js +7 -7
- package/dist/destinations/ripe/page/index.js.map +1 -1
- package/dist/destinations/ripe/track/generated-types.d.ts +3 -1
- package/dist/destinations/ripe/track/index.js +8 -10
- package/dist/destinations/ripe/track/index.js.map +1 -1
- package/dist/destinations/salesforce/account/index.js +21 -5
- package/dist/destinations/salesforce/account/index.js.map +1 -1
- package/dist/destinations/salesforce/cases/index.js +21 -5
- package/dist/destinations/salesforce/cases/index.js.map +1 -1
- package/dist/destinations/salesforce/contact/index.js +21 -5
- package/dist/destinations/salesforce/contact/index.js.map +1 -1
- package/dist/destinations/salesforce/customObject/index.js +22 -6
- package/dist/destinations/salesforce/customObject/index.js.map +1 -1
- package/dist/destinations/salesforce/generated-types.d.ts +3 -0
- package/dist/destinations/salesforce/index.d.ts +1 -1
- package/dist/destinations/salesforce/index.js +20 -0
- package/dist/destinations/salesforce/index.js.map +1 -1
- package/dist/destinations/salesforce/lead/index.js +21 -5
- package/dist/destinations/salesforce/lead/index.js.map +1 -1
- package/dist/destinations/salesforce/opportunity/index.js +21 -5
- package/dist/destinations/salesforce/opportunity/index.js.map +1 -1
- package/dist/destinations/salesforce/sf-operations.d.ts +4 -1
- package/dist/destinations/salesforce/sf-operations.js +47 -1
- package/dist/destinations/salesforce/sf-operations.js.map +1 -1
- package/dist/destinations/the-trade-desk-crm/index.js +6 -1
- package/dist/destinations/the-trade-desk-crm/index.js.map +1 -1
- package/dist/destinations/trubrics/generated-types.d.ts +4 -0
- package/dist/destinations/trubrics/generated-types.js +3 -0
- package/dist/destinations/trubrics/generated-types.js.map +1 -0
- package/dist/destinations/trubrics/index.d.ts +4 -0
- package/dist/destinations/trubrics/index.js +34 -0
- package/dist/destinations/trubrics/index.js.map +1 -0
- package/dist/destinations/trubrics/track/generated-types.d.ts +15 -0
- package/dist/destinations/trubrics/track/generated-types.js +3 -0
- package/dist/destinations/trubrics/track/generated-types.js.map +1 -0
- package/dist/destinations/trubrics/track/index.d.ts +5 -0
- package/dist/destinations/trubrics/track/index.js +83 -0
- package/dist/destinations/trubrics/track/index.js.map +1 -0
- package/dist/destinations/usermotion/group/generated-types.d.ts +2 -1
- package/dist/destinations/usermotion/group/index.js +17 -14
- package/dist/destinations/usermotion/group/index.js.map +1 -1
- package/dist/destinations/usermotion/identify/index.js +2 -2
- package/dist/destinations/usermotion/identify/index.js.map +1 -1
- package/dist/destinations/usermotion/index.js +5 -1
- package/dist/destinations/usermotion/index.js.map +1 -1
- package/dist/destinations/usermotion/track/generated-types.d.ts +4 -2
- package/dist/destinations/usermotion/track/index.js +12 -16
- package/dist/destinations/usermotion/track/index.js.map +1 -1
- package/dist/destinations/xtremepush/identify/index.js +2 -2
- package/dist/destinations/xtremepush/identify/index.js.map +1 -1
- package/dist/destinations/xtremepush/index.js.map +1 -1
- package/dist/destinations/xtremepush/track/index.js +2 -2
- package/dist/destinations/xtremepush/track/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/contentstack/customAttributesSync/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("./utils");
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const action = {
|
|
6
|
+
title: 'Custom Attributes Sync',
|
|
7
|
+
description: 'Sync Custom Attributes to your Contentstack Experience.',
|
|
8
|
+
defaultSubscription: 'type = "identify"',
|
|
9
|
+
fields: {
|
|
10
|
+
traits: {
|
|
11
|
+
type: 'object',
|
|
12
|
+
default: { '@path': '$.traits' },
|
|
13
|
+
label: 'User traits',
|
|
14
|
+
description: 'User Profile traits to send to Contentstack',
|
|
15
|
+
required: true
|
|
16
|
+
},
|
|
17
|
+
userId: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
default: { '@path': '$.userId' },
|
|
20
|
+
label: 'User ID',
|
|
21
|
+
description: 'ID for the user',
|
|
22
|
+
required: false
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
perform: async (request, { payload }) => {
|
|
26
|
+
const personalizeAttributesData = (await utils_1.fetchAllAttributes(request)).map((attribute) => attribute?.key);
|
|
27
|
+
const attributesToCreate = Object.keys(payload.traits || {}).filter((trait) => !personalizeAttributesData.includes(trait));
|
|
28
|
+
if (attributesToCreate?.length) {
|
|
29
|
+
const firstAttributeRes = await utils_1.createCustomAttrbute(request, attributesToCreate[0]);
|
|
30
|
+
if (firstAttributeRes.status === 401)
|
|
31
|
+
return firstAttributeRes;
|
|
32
|
+
const otherAttributes = attributesToCreate.slice(1);
|
|
33
|
+
await Promise.allSettled(otherAttributes.map((trait) => utils_1.createCustomAttrbute(request, trait)));
|
|
34
|
+
return request(`${constants_1.PERSONALIZE_EDGE_API_URL}/user-attributes`, {
|
|
35
|
+
method: 'patch',
|
|
36
|
+
json: payload.traits,
|
|
37
|
+
headers: {
|
|
38
|
+
'x-cs-eclipse-user-uid': payload.userId ?? ''
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.default = action;
|
|
45
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/contentstack/customAttributesSync/index.ts"],"names":[],"mappings":";;AAGA,mCAAkE;AAElE,4CAAuD;AAEvD,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,wBAAwB;IAC/B,WAAW,EAAE,yDAAyD;IACtE,mBAAmB,EAAE,mBAAmB;IACxC,MAAM,EAAE;QACN,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;YAChC,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,6CAA6C;YAC1D,QAAQ,EAAE,IAAI;SACf;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;YA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PersonalizeAttributes {
|
|
2
|
+
_id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
key: string;
|
|
5
|
+
description: string;
|
|
6
|
+
project?: string;
|
|
7
|
+
createdBy?: string;
|
|
8
|
+
updatedBy?: string;
|
|
9
|
+
createdAt?: string;
|
|
10
|
+
updatedAt?: string;
|
|
11
|
+
uid?: string;
|
|
12
|
+
createdByUserName?: string;
|
|
13
|
+
updatedByUserName?: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/destinations/contentstack/customAttributesSync/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RequestClient } from '@segment/actions-core';
|
|
2
|
+
import { PersonalizeAttributes } from './types';
|
|
3
|
+
export declare const createCustomAttrbute: (request: RequestClient, name: string) => Promise<import("@segment/actions-core").ModifiedResponse<unknown>>;
|
|
4
|
+
export declare const fetchAllAttributes: (request: RequestClient) => Promise<PersonalizeAttributes[]>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchAllAttributes = exports.createCustomAttrbute = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const createCustomAttrbute = async (request, name) => request(`${constants_1.PERSONALIZE_API_BASE_URL}/attributes`, {
|
|
6
|
+
method: 'post',
|
|
7
|
+
json: {
|
|
8
|
+
name,
|
|
9
|
+
key: name,
|
|
10
|
+
description: `Segment ${name}`
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
exports.createCustomAttrbute = createCustomAttrbute;
|
|
14
|
+
const fetchAllAttributes = async (request) => {
|
|
15
|
+
const res = await request(`${constants_1.PERSONALIZE_API_BASE_URL}/attributes`, {
|
|
16
|
+
method: 'get'
|
|
17
|
+
});
|
|
18
|
+
return res.data;
|
|
19
|
+
};
|
|
20
|
+
exports.fetchAllAttributes = fetchAllAttributes;
|
|
21
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/destinations/contentstack/customAttributesSync/utils.ts"],"names":[],"mappings":";;;AAEA,4CAAuD;AAEhD,MAAM,oBAAoB,GAAG,KAAK,EAAE,OAAsB,EAAE,IAAY,EAAE,EAAE,CACjF,OAAO,CAAC,GAAG,oCAAwB,aAAa,EAAE;IAChD,MAAM,EAAE,MAAM;IACd,IAAI,EAAE;QACJ,IAAI;QACJ,GAAG,EAAE,IAAI;QACT,WAAW,EAAE,WAAW,IAAI,EAAE;KAC/B;CACF,CAAC,CAAA;AARS,QAAA,oBAAoB,wBAQ7B;AAEG,MAAM,kBAAkB,GAAG,KAAK,EAAE,OAAsB,EAAE,EAAE;IACjE,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,GAAG,oCAAwB,aAAa,EAAE;QAClE,MAAM,EAAE,KAAK;KACd,CAAC,CAAA;IAEF,OAAO,GAAG,CAAC,IAA+B,CAAA;AAC5C,CAAC,CAAA;AANY,QAAA,kBAAkB,sBAM9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/destinations/contentstack/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,58 @@
|
|
|
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 constants_1 = require("./constants");
|
|
7
|
+
const customAttributesSync_1 = __importDefault(require("./customAttributesSync"));
|
|
8
|
+
const destination = {
|
|
9
|
+
name: 'Contentstack',
|
|
10
|
+
slug: 'actions-contentstack',
|
|
11
|
+
mode: 'cloud',
|
|
12
|
+
authentication: {
|
|
13
|
+
scheme: 'oauth-managed',
|
|
14
|
+
fields: {
|
|
15
|
+
orgId: {
|
|
16
|
+
label: 'Organization ID',
|
|
17
|
+
type: 'string',
|
|
18
|
+
required: true,
|
|
19
|
+
description: "Your organization ID to which Segment's data should be synced."
|
|
20
|
+
},
|
|
21
|
+
personalizeProjectId: {
|
|
22
|
+
label: 'Personalize project ID',
|
|
23
|
+
type: 'string',
|
|
24
|
+
required: true,
|
|
25
|
+
description: "Your Personalize project ID to which Segment's data should be synced."
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
refreshAccessToken: async (request, { auth }) => {
|
|
29
|
+
const res = await request(constants_1.ACCESS_TOKEN_URL, {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
headers: {
|
|
32
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
33
|
+
},
|
|
34
|
+
body: new URLSearchParams({
|
|
35
|
+
grant_type: 'refresh_token',
|
|
36
|
+
client_id: auth.clientId,
|
|
37
|
+
client_secret: auth.clientSecret,
|
|
38
|
+
refresh_token: auth.refreshToken
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
return { accessToken: res?.data?.access_token, refreshToken: res?.data?.refresh_token };
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
extendRequest({ auth, settings }) {
|
|
45
|
+
return {
|
|
46
|
+
headers: {
|
|
47
|
+
Authorization: `Bearer ${auth?.accessToken}`,
|
|
48
|
+
organization_uid: settings.orgId,
|
|
49
|
+
'x-project-uid': settings.personalizeProjectId
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
actions: {
|
|
54
|
+
customAttributesSync: customAttributesSync_1.default
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
exports.default = destination;
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/contentstack/index.ts"],"names":[],"mapp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C;SACF,CAAA;IACH,CAAC;IACD,OAAO,EAAE;QACP,oBAAoB,EAApB,8BAAoB;KACrB;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface RefreshTokenResponse {
|
|
2
|
+
access_token: string;
|
|
3
|
+
refresh_token: string;
|
|
4
|
+
token_type?: string;
|
|
5
|
+
expires_in?: number;
|
|
6
|
+
location?: string;
|
|
7
|
+
region?: string;
|
|
8
|
+
organization_uid?: string;
|
|
9
|
+
authorization_type?: string;
|
|
10
|
+
user_uid?: string;
|
|
11
|
+
stack_api_key?: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/destinations/contentstack/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ContextFromDecorator } from './operationTracking';
|
|
2
2
|
export declare const track: ((decoratorArgs?: ({
|
|
3
|
+
shouldStats?: ((args: import("./operationTracking").OperationStatsEventArgs) => boolean | void) | undefined;
|
|
4
|
+
} & {
|
|
3
5
|
onError?: ((ctx: import("./operationTracking").OperationErrorHandlerContext<import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>>) => void) | undefined;
|
|
4
|
-
} &
|
|
6
|
+
} & {
|
|
5
7
|
onTry?: ((ctx: import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>) => void) | undefined;
|
|
6
8
|
onFinally?: ((ctx: import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>) => void) | undefined;
|
|
7
|
-
} & {
|
|
8
|
-
shouldStats?: ((args: import("./operationTracking").OperationStatsEventArgs) => boolean | void) | undefined;
|
|
9
|
-
} & {
|
|
9
|
+
} & import("./operationTracking").OperationLoggerDecoratorArgs & {
|
|
10
10
|
wrapIntegrationError?: ((ctx: import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>) => import("@segment/actions-core/*").IntegrationError | [message: string, code: string, status: number]) | undefined;
|
|
11
11
|
}) | undefined) => import("./operationTracking").GenericMethodDecorator<(this: any, ...args: any[]) => any>) & {
|
|
12
12
|
getCurrentOperation(classInstance: any): (import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any> & {
|
|
@@ -15,8 +15,13 @@ export declare const track: ((decoratorArgs?: ({
|
|
|
15
15
|
}) | undefined;
|
|
16
16
|
} & {
|
|
17
17
|
_contextType: import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any> & {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
tags: string[];
|
|
19
|
+
sharedContext: {
|
|
20
|
+
tags: string[];
|
|
21
|
+
};
|
|
22
|
+
decoratorArgs?: {
|
|
23
|
+
shouldStats?: ((args: import("./operationTracking").OperationStatsEventArgs) => boolean | void) | undefined;
|
|
24
|
+
} | undefined;
|
|
20
25
|
} & {
|
|
21
26
|
decoratorArgs?: {
|
|
22
27
|
onError?: ((ctx: import("./operationTracking").OperationErrorHandlerContext<import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>>) => void) | undefined;
|
|
@@ -25,10 +30,8 @@ export declare const track: ((decoratorArgs?: ({
|
|
|
25
30
|
parent?: (import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any> & any) | undefined;
|
|
26
31
|
sharedContext: {};
|
|
27
32
|
} & {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
decoratorArgs?: import("./operationTracking").OperationLoggerDecoratorArgs | undefined;
|
|
31
|
-
sharedContext: import("./operationTracking").OperationLoggerSharedContext;
|
|
33
|
+
start?: number | undefined;
|
|
34
|
+
duration?: number | undefined;
|
|
32
35
|
} & {
|
|
33
36
|
onFinally: (() => void)[];
|
|
34
37
|
decoratorArgs?: {
|
|
@@ -36,13 +39,10 @@ export declare const track: ((decoratorArgs?: ({
|
|
|
36
39
|
onFinally?: ((ctx: import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>) => void) | undefined;
|
|
37
40
|
} | undefined;
|
|
38
41
|
} & {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
decoratorArgs?: {
|
|
44
|
-
shouldStats?: ((args: import("./operationTracking").OperationStatsEventArgs) => boolean | void) | undefined;
|
|
45
|
-
} | undefined;
|
|
42
|
+
logs: string[];
|
|
43
|
+
logMetadata?: Record<string, unknown> | undefined;
|
|
44
|
+
decoratorArgs?: import("./operationTracking").OperationLoggerDecoratorArgs | undefined;
|
|
45
|
+
sharedContext: import("./operationTracking").OperationLoggerSharedContext;
|
|
46
46
|
} & {
|
|
47
47
|
decoratorArgs?: {
|
|
48
48
|
wrapIntegrationError?: ((ctx: import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>) => import("@segment/actions-core/*").IntegrationError | [message: string, code: string, status: number]) | undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
import type { DestinationDefinition } from '@segment/actions-core';
|
|
2
|
+
import type { Settings } from './generated-types';
|
|
3
|
+
export declare const destinationDefinition: DestinationDefinition<Settings>;
|
|
4
|
+
export default destinationDefinition;
|
|
@@ -1,19 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
-
};
|
|
15
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
exports.destinationDefinition = void 0;
|
|
4
|
+
const sendEmail_1 = require("./sendEmail");
|
|
5
|
+
const previewApiLookup_1 = require("./previewApiLookup");
|
|
6
|
+
exports.destinationDefinition = {
|
|
7
|
+
name: 'Engage Messaging SendGrid',
|
|
8
|
+
slug: 'actions-personas-messaging-sendgrid',
|
|
9
|
+
mode: 'cloud',
|
|
10
|
+
description: 'This is an Engage specific action to send an email',
|
|
11
|
+
authentication: {
|
|
12
|
+
scheme: 'custom',
|
|
13
|
+
fields: {
|
|
14
|
+
unlayerApiKey: {
|
|
15
|
+
label: 'Unlayer API Key',
|
|
16
|
+
type: 'password',
|
|
17
|
+
description: 'The API key for your Unlayer account'
|
|
18
|
+
},
|
|
19
|
+
sendGridApiKey: {
|
|
20
|
+
label: 'API Key',
|
|
21
|
+
type: 'password',
|
|
22
|
+
description: 'The Api Key for your SendGrid account',
|
|
23
|
+
required: true
|
|
24
|
+
},
|
|
25
|
+
profileApiEnvironment: {
|
|
26
|
+
label: 'Profile API Environment',
|
|
27
|
+
description: 'Profile API Environment',
|
|
28
|
+
type: 'string',
|
|
29
|
+
required: true
|
|
30
|
+
},
|
|
31
|
+
profileApiAccessToken: {
|
|
32
|
+
label: 'Profile API Access Token',
|
|
33
|
+
description: 'Profile API Access Token',
|
|
34
|
+
type: 'password',
|
|
35
|
+
required: true
|
|
36
|
+
},
|
|
37
|
+
spaceId: {
|
|
38
|
+
label: 'Space ID',
|
|
39
|
+
description: 'Space ID',
|
|
40
|
+
type: 'string',
|
|
41
|
+
required: true
|
|
42
|
+
},
|
|
43
|
+
sourceId: {
|
|
44
|
+
label: 'Source ID',
|
|
45
|
+
description: 'Source ID',
|
|
46
|
+
type: 'string',
|
|
47
|
+
required: true
|
|
48
|
+
},
|
|
49
|
+
region: {
|
|
50
|
+
label: 'Region',
|
|
51
|
+
description: 'The region where the email is originating from',
|
|
52
|
+
type: 'string',
|
|
53
|
+
choices: [
|
|
54
|
+
{ value: 'us-west-2', label: 'US West 2' },
|
|
55
|
+
{ value: 'eu-west-1', label: 'EU West 1' }
|
|
56
|
+
],
|
|
57
|
+
default: 'us-west-2',
|
|
58
|
+
required: false
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
testAuthentication: (request) => {
|
|
62
|
+
return request('https://api.sendgrid.com/v3/mail_settings');
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
actions: {
|
|
66
|
+
sendEmail: sendEmail_1.actionDefinition,
|
|
67
|
+
previewApiLookup: previewApiLookup_1.actionDefinition
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
exports.default = exports.destinationDefinition;
|
|
19
71
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/engage-messaging-sendgrid/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/engage-messaging-sendgrid/index.ts"],"names":[],"mappings":";;;AAEA,2CAA2D;AAC3D,yDAAyE;AAE5D,QAAA,qBAAqB,GAAoC;IACpE,IAAI,EAAE,2BAA2B;IACjC,IAAI,EAAE,qCAAqC;IAC3C,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,oDAAoD;IACjE,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,aAAa,EAAE;gBACb,KAAK,EAAE,iBAAiB;gBACxB,IAAI,EAAE,UAAU;gBAChB,WAAW,EAAE,sCAAsC;aACpD;YACD,cAAc,EAAE;gBACd,KAAK,EAAE,SAAS;gBAChB,IAAI,EAAE,UAAU;gBAChB,WAAW,EAAE,uCAAuC;gBACpD,QAAQ,EAAE,IAAI;aACf;YACD,qBAAqB,EAAE;gBACrB,KAAK,EAAE,yBAAyB;gBAChC,WAAW,EAAE,yBAAyB;gBACtC,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;aACf;YACD,qBAAqB,EAAE;gBACrB,KAAK,EAAE,0BAA0B;gBACjC,WAAW,EAAE,0BAA0B;gBACvC,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,IAAI;aACf;YACD,OAAO,EAAE;gBACP,KAAK,EAAE,UAAU;gBACjB,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;aACf;YACD,QAAQ,EAAE;gBACR,KAAK,EAAE,WAAW;gBAClB,WAAW,EAAE,WAAW;gBACxB,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;aACf;YACD,MAAM,EAAE;gBACN,KAAK,EAAE,QAAQ;gBACf,WAAW,EAAE,gDAAgD;gBAC7D,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE;oBAC1C,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE;iBAC3C;gBACD,OAAO,EAAE,WAAW;gBACpB,QAAQ,EAAE,KAAK;aAChB;SACF;QACD,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE;YAC9B,OAAO,OAAO,CAAC,2CAA2C,CAAC,CAAA;QAC7D,CAAC;KACF;IACD,OAAO,EAAE;QACP,SAAS,EAAT,4BAAS;QACT,gBAAgB,EAAhB,mCAAgB;KACjB;CACF,CAAA;AAED,kBAAe,6BAAqB,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { InputField } from '@segment/actions-core';
|
|
2
|
+
import { RequestClient } from '@segment/actions-core';
|
|
3
|
+
import { Logger, StatsClient, DataFeedCache } from '@segment/actions-core/destination-kit';
|
|
4
|
+
import type { Settings } from '../generated-types';
|
|
5
|
+
import { Profile } from '@segment/actions-shared';
|
|
6
|
+
export declare type ApiLookupConfig = {
|
|
7
|
+
id?: string | undefined;
|
|
8
|
+
name: string;
|
|
9
|
+
url: string;
|
|
10
|
+
method: string;
|
|
11
|
+
cacheTtl: number;
|
|
12
|
+
body?: string | undefined;
|
|
13
|
+
headers?: object | undefined;
|
|
14
|
+
responseType: string;
|
|
15
|
+
shouldRetryOnRetryableError?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare const getRequestId: ({ method, url, body, headers }: ApiLookupConfig) => string;
|
|
18
|
+
export declare const getCachedResponse: ({ responseType }: ApiLookupConfig, requestId: string, dataFeedCache: DataFeedCache, datafeedTags: string[]) => Promise<any>;
|
|
19
|
+
export declare const performApiLookup: (request: RequestClient, apiLookupConfig: ApiLookupConfig, profile: Profile, statsClient: StatsClient | undefined, tags: string[], settings: Settings, logger?: Logger | undefined, dataFeedCache?: DataFeedCache | undefined) => Promise<any>;
|
|
20
|
+
export declare const apiLookupActionFields: Record<string, InputField>;
|
|
21
|
+
export declare const apiLookupLiquidKey = "datafeeds";
|
|
22
|
+
export declare const FLAGON_NAME_DATA_FEEDS = "is-datafeeds-enabled";
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FLAGON_NAME_DATA_FEEDS = exports.apiLookupLiquidKey = exports.apiLookupActionFields = exports.performApiLookup = exports.getCachedResponse = exports.getRequestId = void 0;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
6
|
+
const liquidjs_1 = require("liquidjs");
|
|
7
|
+
const Liquid = new liquidjs_1.Liquid();
|
|
8
|
+
const renderLiquidFields = async ({ url, body }, profile, datafeedTags, logDataFeedError) => {
|
|
9
|
+
let renderedUrl;
|
|
10
|
+
let renderedBody;
|
|
11
|
+
try {
|
|
12
|
+
renderedUrl = await Liquid.parseAndRender(url, { profile });
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
logDataFeedError('URL liquid render failuere', error);
|
|
16
|
+
datafeedTags.push('error:true', 'reason:rendering_failure', 'rendering:url');
|
|
17
|
+
throw new actions_core_1.IntegrationError('Unable to parse data feed url', 'DATA_FEED_RENDERING_ERROR', 400);
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
renderedBody = body ? await Liquid.parseAndRender(body, { profile }) : undefined;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
logDataFeedError('Body liquid render failure', error);
|
|
24
|
+
datafeedTags.push('error:true', 'reason:rendering_failure', 'rendering:body');
|
|
25
|
+
throw new actions_core_1.IntegrationError('Unable to parse email api lookup body', 'DATA_FEED_RENDERING_ERROR', 400);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
renderedUrl,
|
|
29
|
+
renderedBody
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const getRequestId = ({ method, url, body, headers }) => {
|
|
33
|
+
const requestHash = crypto_1.createHash('sha256');
|
|
34
|
+
requestHash.update(`${method}${url}${body}${JSON.stringify(headers)}`);
|
|
35
|
+
const requestId = requestHash.digest('hex');
|
|
36
|
+
return requestId;
|
|
37
|
+
};
|
|
38
|
+
exports.getRequestId = getRequestId;
|
|
39
|
+
const getCachedResponse = async ({ responseType }, requestId, dataFeedCache, datafeedTags) => {
|
|
40
|
+
const cachedResponse = await dataFeedCache.getRequestResponse(requestId);
|
|
41
|
+
if (!cachedResponse) {
|
|
42
|
+
datafeedTags.push('cache_hit:false');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
datafeedTags.push('cache_hit:true');
|
|
46
|
+
if (responseType === 'json') {
|
|
47
|
+
return JSON.parse(cachedResponse);
|
|
48
|
+
}
|
|
49
|
+
return cachedResponse;
|
|
50
|
+
};
|
|
51
|
+
exports.getCachedResponse = getCachedResponse;
|
|
52
|
+
const performApiLookup = async (request, apiLookupConfig, profile, statsClient, tags, settings, logger, dataFeedCache) => {
|
|
53
|
+
const { id, method, headers, cacheTtl, name, shouldRetryOnRetryableError = true } = apiLookupConfig;
|
|
54
|
+
const datafeedTags = [
|
|
55
|
+
...tags,
|
|
56
|
+
`datafeed_id:${id}`,
|
|
57
|
+
`datafeed_name:${name}`,
|
|
58
|
+
`space_id:${settings.spaceId}`,
|
|
59
|
+
`cache_ttl_greater_than_0:${cacheTtl > 0}`,
|
|
60
|
+
`retry_enabled:${shouldRetryOnRetryableError}`
|
|
61
|
+
];
|
|
62
|
+
const logDataFeedError = (message, error) => {
|
|
63
|
+
logger?.error(`TE Messaging: Data feed error - message: ${message} - data feed name: ${name} - data feed id: ${id} - space id: ${settings.spaceId} - raw error: ${error}`);
|
|
64
|
+
};
|
|
65
|
+
try {
|
|
66
|
+
const { renderedUrl, renderedBody } = await renderLiquidFields(apiLookupConfig, profile, datafeedTags, logDataFeedError);
|
|
67
|
+
const requestId = exports.getRequestId({ ...apiLookupConfig, url: renderedUrl, body: renderedBody });
|
|
68
|
+
if (cacheTtl > 0 && !dataFeedCache) {
|
|
69
|
+
logDataFeedError('Data feed cache not available and cache needed');
|
|
70
|
+
datafeedTags.push('cache_set:false');
|
|
71
|
+
throw new actions_core_1.IntegrationError('Data feed cache not available and cache needed', 'DATA_FEED_CACHE_NOT_AVAILABLE', 400);
|
|
72
|
+
}
|
|
73
|
+
if (cacheTtl > 0 && dataFeedCache) {
|
|
74
|
+
const cachedResponse = await exports.getCachedResponse(apiLookupConfig, requestId, dataFeedCache, datafeedTags);
|
|
75
|
+
if (cachedResponse) {
|
|
76
|
+
datafeedTags.push('error:false');
|
|
77
|
+
return cachedResponse;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
let data;
|
|
81
|
+
try {
|
|
82
|
+
const res = await request(renderedUrl, {
|
|
83
|
+
headers: headers ?? undefined,
|
|
84
|
+
timeout: 3000,
|
|
85
|
+
method: method,
|
|
86
|
+
body: renderedBody,
|
|
87
|
+
skipResponseCloning: true
|
|
88
|
+
});
|
|
89
|
+
data = await res.data;
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
const respError = error.response;
|
|
93
|
+
logDataFeedError('Data feed call failure', error);
|
|
94
|
+
datafeedTags.push(`error:true`, `error_status:${respError?.status}`, 'reason:api_call_failure');
|
|
95
|
+
if (shouldRetryOnRetryableError) {
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
return {};
|
|
99
|
+
}
|
|
100
|
+
if (cacheTtl > 0 && dataFeedCache) {
|
|
101
|
+
const dataString = JSON.stringify(data);
|
|
102
|
+
const size = Buffer.byteLength(dataString, 'utf-8');
|
|
103
|
+
if (size > dataFeedCache.maxResponseSizeBytes) {
|
|
104
|
+
datafeedTags.push('error:true', 'reason:response_size_too_big');
|
|
105
|
+
logDataFeedError('Data feed response size too big too cache and caching needed, failing send');
|
|
106
|
+
throw new actions_core_1.IntegrationError('Data feed response size too big too cache and caching needed, failing send', 'DATA_FEED_RESPONSE_TOO_BIG', 400);
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
await dataFeedCache.setRequestResponse(requestId, dataString, cacheTtl / 1000);
|
|
110
|
+
datafeedTags.push('cache_set:true');
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
logDataFeedError('Data feed cache set failure', error);
|
|
114
|
+
datafeedTags.push('error:true', 'reason:cache_set_failure', 'cache_set:false');
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
datafeedTags.push('error:false');
|
|
119
|
+
return data;
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
const isErrorCapturedInTags = datafeedTags.find((str) => str.includes('error:true'));
|
|
123
|
+
if (!isErrorCapturedInTags) {
|
|
124
|
+
datafeedTags.push('error:true', 'reason:unknown');
|
|
125
|
+
}
|
|
126
|
+
tags.push('reason:datafeed_failure');
|
|
127
|
+
logDataFeedError('Unexpected data feed error', error);
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
statsClient?.incr('datafeed_execution', 1, datafeedTags);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
exports.performApiLookup = performApiLookup;
|
|
135
|
+
exports.apiLookupActionFields = {
|
|
136
|
+
id: {
|
|
137
|
+
label: 'ID',
|
|
138
|
+
description: 'The id of the API lookup for use in logging & observability',
|
|
139
|
+
type: 'string'
|
|
140
|
+
},
|
|
141
|
+
name: {
|
|
142
|
+
label: 'Name',
|
|
143
|
+
description: 'The name of the API lookup referenced in liquid syntax',
|
|
144
|
+
type: 'string',
|
|
145
|
+
required: true
|
|
146
|
+
},
|
|
147
|
+
url: {
|
|
148
|
+
label: 'URL',
|
|
149
|
+
description: 'The URL endpoint to call',
|
|
150
|
+
type: 'string',
|
|
151
|
+
required: true
|
|
152
|
+
},
|
|
153
|
+
method: {
|
|
154
|
+
label: 'Request Method',
|
|
155
|
+
description: 'The request method, e.g. GET/POST/etc.',
|
|
156
|
+
type: 'string',
|
|
157
|
+
required: true
|
|
158
|
+
},
|
|
159
|
+
cacheTtl: {
|
|
160
|
+
label: 'Cache TTL',
|
|
161
|
+
description: 'The cache TTL in ms',
|
|
162
|
+
type: 'integer',
|
|
163
|
+
required: true
|
|
164
|
+
},
|
|
165
|
+
body: {
|
|
166
|
+
label: 'Request Body',
|
|
167
|
+
description: 'The request body for use with POST/PUT/PATCH requests',
|
|
168
|
+
type: 'string'
|
|
169
|
+
},
|
|
170
|
+
headers: {
|
|
171
|
+
label: 'Request Headers',
|
|
172
|
+
description: 'Headers in JSON to be sent with the request',
|
|
173
|
+
type: 'object'
|
|
174
|
+
},
|
|
175
|
+
responseType: {
|
|
176
|
+
label: 'Response Type',
|
|
177
|
+
description: 'The response type of the request. Currently only supporting JSON.',
|
|
178
|
+
type: 'string',
|
|
179
|
+
required: true
|
|
180
|
+
},
|
|
181
|
+
shouldRetryOnRetryableError: {
|
|
182
|
+
label: 'Should Retry',
|
|
183
|
+
description: 'Whether the message should be retried (if the error code is retryable) when the data feed fails or if it should be sent with empty data instead',
|
|
184
|
+
type: 'boolean'
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
exports.apiLookupLiquidKey = 'datafeeds';
|
|
188
|
+
exports.FLAGON_NAME_DATA_FEEDS = 'is-datafeeds-enabled';
|
|
189
|
+
//# sourceMappingURL=apiLookups.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiLookups.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-sendgrid/previewApiLookup/apiLookups.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,wDAAwD;AAKxD,uCAA6C;AAG7C,MAAM,MAAM,GAAG,IAAI,iBAAQ,EAAE,CAAA;AAkB7B,MAAM,kBAAkB,GAAG,KAAK,EAC9B,EAAE,GAAG,EAAE,IAAI,EAAyC,EACpD,OAAgB,EAChB,YAAsB,EACtB,gBAAkC,EAClC,EAAE;IACF,IAAI,WAAmB,CAAA;IACvB,IAAI,YAAgC,CAAA;IACpC,IAAI;QACF,WAAW,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;KAC5D;IAAC,OAAO,KAAK,EAAE;QACd,gBAAgB,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAA;QACrD,YAAY,CAAC,IAAI,CAAC,YAAY,EAAE,0BAA0B,EAAE,eAAe,CAAC,CAAA;QAC5E,MAAM,IAAI,+BAAgB,CAAC,+BAA+B,EAAE,2BAA2B,EAAE,GAAG,CAAC,CAAA;KAC9F;IACD,IAAI;QACF,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;KACjF;IAAC,OAAO,KAAK,EAAE;QACd,gBAAgB,CAAC,4BAA4B,E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