@segment/action-destinations 3.267.1-staging-376209a3a → 3.267.1-staging-56c8f3280

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.
Files changed (117) hide show
  1. package/dist/destinations/engage/utils/track.d.ts +10 -10
  2. package/dist/destinations/engage-messaging-sendgrid/index.d.ts +4 -3
  3. package/dist/destinations/engage-messaging-sendgrid/index.js +68 -16
  4. package/dist/destinations/engage-messaging-sendgrid/index.js.map +1 -1
  5. package/dist/destinations/{engage/sendgrid/previewApiLookup/api-lookups.d.ts → engage-messaging-sendgrid/previewApiLookup/apiLookups.d.ts} +3 -2
  6. package/dist/destinations/{engage/sendgrid/previewApiLookup/api-lookups.js → engage-messaging-sendgrid/previewApiLookup/apiLookups.js} +52 -37
  7. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/apiLookups.js.map +1 -0
  8. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/generated-types.d.ts +16 -0
  9. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/generated-types.js.map +1 -0
  10. package/dist/destinations/{responsys/asyncMergePetRecords → engage-messaging-sendgrid/previewApiLookup}/index.d.ts +2 -2
  11. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/index.js +29 -0
  12. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/index.js.map +1 -0
  13. package/dist/destinations/engage-messaging-sendgrid/sendEmail/SendEmailPerformer.d.ts +43 -0
  14. package/dist/destinations/engage-messaging-sendgrid/sendEmail/SendEmailPerformer.js +419 -0
  15. package/dist/destinations/engage-messaging-sendgrid/sendEmail/SendEmailPerformer.js.map +1 -0
  16. package/dist/destinations/engage-messaging-sendgrid/sendEmail/UnlayerResponse.d.ts +12 -0
  17. package/dist/destinations/{engage/sendgrid/Profile.js → engage-messaging-sendgrid/sendEmail/UnlayerResponse.js} +1 -1
  18. package/dist/destinations/engage-messaging-sendgrid/sendEmail/UnlayerResponse.js.map +1 -0
  19. package/dist/destinations/engage-messaging-sendgrid/sendEmail/generated-types.d.ts +56 -0
  20. package/dist/destinations/engage-messaging-sendgrid/sendEmail/generated-types.js.map +1 -0
  21. package/dist/destinations/{responsys/asyncMergeProfileListMembers → engage-messaging-sendgrid/sendEmail}/index.d.ts +2 -2
  22. package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.js +258 -0
  23. package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.js.map +1 -0
  24. package/dist/destinations/engage-messaging-sendgrid/sendEmail/insertEmailPreviewText.d.ts +1 -0
  25. package/dist/destinations/engage-messaging-sendgrid/sendEmail/insertEmailPreviewText.js +23 -0
  26. package/dist/destinations/engage-messaging-sendgrid/sendEmail/insertEmailPreviewText.js.map +1 -0
  27. package/dist/destinations/engage-messaging-sendgrid/sendEmail/isRestrictedDomain.d.ts +1 -0
  28. package/dist/destinations/engage-messaging-sendgrid/sendEmail/isRestrictedDomain.js +14 -0
  29. package/dist/destinations/engage-messaging-sendgrid/sendEmail/isRestrictedDomain.js.map +1 -0
  30. package/dist/destinations/engage-messaging-twilio/index.d.ts +4 -3
  31. package/dist/destinations/engage-messaging-twilio/index.js +169 -15
  32. package/dist/destinations/engage-messaging-twilio/index.js.map +1 -1
  33. package/dist/destinations/engage-messaging-twilio/sendMobilePush/PushSender.d.ts +29 -0
  34. package/dist/destinations/engage-messaging-twilio/sendMobilePush/PushSender.js +169 -0
  35. package/dist/destinations/engage-messaging-twilio/sendMobilePush/PushSender.js.map +1 -0
  36. package/dist/destinations/engage-messaging-twilio/sendMobilePush/generated-types.d.ts +39 -0
  37. package/dist/destinations/engage-messaging-twilio/sendMobilePush/generated-types.js +3 -0
  38. package/dist/destinations/engage-messaging-twilio/sendMobilePush/generated-types.js.map +1 -0
  39. package/dist/destinations/engage-messaging-twilio/sendMobilePush/index.d.ts +5 -0
  40. package/dist/destinations/engage-messaging-twilio/sendMobilePush/index.js +251 -0
  41. package/dist/destinations/engage-messaging-twilio/sendMobilePush/index.js.map +1 -0
  42. package/dist/destinations/engage-messaging-twilio/sendSms/SmsMessageSender.d.ts +9 -0
  43. package/dist/destinations/engage-messaging-twilio/sendSms/SmsMessageSender.js +72 -0
  44. package/dist/destinations/engage-messaging-twilio/sendSms/SmsMessageSender.js.map +1 -0
  45. package/dist/destinations/engage-messaging-twilio/sendSms/generated-types.d.ts +27 -0
  46. package/dist/destinations/engage-messaging-twilio/sendSms/generated-types.js +3 -0
  47. package/dist/destinations/engage-messaging-twilio/sendSms/generated-types.js.map +1 -0
  48. package/dist/destinations/engage-messaging-twilio/sendSms/index.d.ts +5 -0
  49. package/dist/destinations/engage-messaging-twilio/sendSms/index.js +163 -0
  50. package/dist/destinations/engage-messaging-twilio/sendSms/index.js.map +1 -0
  51. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/WhatsAppMessageSender.d.ts +9 -0
  52. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/WhatsAppMessageSender.js +89 -0
  53. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/WhatsAppMessageSender.js.map +1 -0
  54. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/generated-types.d.ts +25 -0
  55. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/generated-types.js +3 -0
  56. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/generated-types.js.map +1 -0
  57. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.d.ts +5 -0
  58. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.js +137 -0
  59. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.js.map +1 -0
  60. package/dist/destinations/engage-messaging-twilio/utils/PhoneMessageSender.d.ts +16 -0
  61. package/dist/destinations/engage-messaging-twilio/utils/PhoneMessageSender.js +71 -0
  62. package/dist/destinations/engage-messaging-twilio/utils/PhoneMessageSender.js.map +1 -0
  63. package/dist/destinations/engage-messaging-twilio/utils/TwilioMessageSender.d.ts +16 -0
  64. package/dist/destinations/engage-messaging-twilio/utils/TwilioMessageSender.js +115 -0
  65. package/dist/destinations/engage-messaging-twilio/utils/TwilioMessageSender.js.map +1 -0
  66. package/dist/destinations/engage-messaging-twilio/utils/index.d.ts +2 -0
  67. package/dist/destinations/engage-messaging-twilio/utils/index.js +15 -0
  68. package/dist/destinations/engage-messaging-twilio/utils/index.js.map +1 -0
  69. package/dist/destinations/engage-messaging-twilio/utils/types.d.ts +23 -0
  70. package/dist/destinations/engage-messaging-twilio/utils/types.js.map +1 -0
  71. package/package.json +2 -2
  72. package/dist/destinations/dynamic-yield-audiences/syncAudience/types.d.ts +0 -22
  73. package/dist/destinations/dynamic-yield-audiences/syncAudience/types.js.map +0 -1
  74. package/dist/destinations/dynamic-yield-audiences/types.d.ts +0 -8
  75. package/dist/destinations/dynamic-yield-audiences/types.js +0 -12
  76. package/dist/destinations/dynamic-yield-audiences/types.js.map +0 -1
  77. package/dist/destinations/engage/sendgrid/Profile.d.ts +0 -6
  78. package/dist/destinations/engage/sendgrid/Profile.js.map +0 -1
  79. package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.js.map +0 -1
  80. package/dist/destinations/mixpanel/utils.d.ts +0 -13
  81. package/dist/destinations/mixpanel/utils.js +0 -117
  82. package/dist/destinations/mixpanel/utils.js.map +0 -1
  83. package/dist/destinations/responsys/asyncMergePetRecords/generated-types.d.ts +0 -14
  84. package/dist/destinations/responsys/asyncMergePetRecords/generated-types.js.map +0 -1
  85. package/dist/destinations/responsys/asyncMergePetRecords/index.js +0 -113
  86. package/dist/destinations/responsys/asyncMergePetRecords/index.js.map +0 -1
  87. package/dist/destinations/responsys/asyncMergeProfileListMembers/generated-types.d.ts +0 -20
  88. package/dist/destinations/responsys/asyncMergeProfileListMembers/generated-types.js.map +0 -1
  89. package/dist/destinations/responsys/asyncMergeProfileListMembers/index.js +0 -174
  90. package/dist/destinations/responsys/asyncMergeProfileListMembers/index.js.map +0 -1
  91. package/dist/destinations/responsys/rsp-operations.d.ts +0 -14
  92. package/dist/destinations/responsys/rsp-operations.js +0 -33
  93. package/dist/destinations/responsys/rsp-operations.js.map +0 -1
  94. package/dist/destinations/responsys/rsp-properties.d.ts +0 -4
  95. package/dist/destinations/responsys/rsp-properties.js +0 -27
  96. package/dist/destinations/responsys/rsp-properties.js.map +0 -1
  97. package/dist/destinations/snap-conversions-api/_tests_/capiV2tests.d.ts +0 -1
  98. package/dist/destinations/snap-conversions-api/_tests_/capiV2tests.js +0 -381
  99. package/dist/destinations/snap-conversions-api/_tests_/capiV2tests.js.map +0 -1
  100. package/dist/destinations/snap-conversions-api/_tests_/capiV3tests.d.ts +0 -1
  101. package/dist/destinations/snap-conversions-api/_tests_/capiV3tests.js +0 -581
  102. package/dist/destinations/snap-conversions-api/_tests_/capiV3tests.js.map +0 -1
  103. package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-v2.d.ts +0 -4
  104. package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-v2.js +0 -97
  105. package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-v2.js.map +0 -1
  106. package/dist/destinations/snap-conversions-api/snap-capi-properties.d.ts +0 -30
  107. package/dist/destinations/snap-conversions-api/snap-capi-properties.js +0 -316
  108. package/dist/destinations/snap-conversions-api/snap-capi-properties.js.map +0 -1
  109. package/dist/destinations/tiktok-conversions/reportWebEvent/formatter.d.ts +0 -3
  110. package/dist/destinations/tiktok-conversions/reportWebEvent/formatter.js +0 -34
  111. package/dist/destinations/tiktok-conversions/reportWebEvent/formatter.js.map +0 -1
  112. package/dist/destinations/tiktok-offline-conversions/reportOfflineEvent/formatter.d.ts +0 -3
  113. package/dist/destinations/tiktok-offline-conversions/reportOfflineEvent/formatter.js +0 -43
  114. package/dist/destinations/tiktok-offline-conversions/reportOfflineEvent/formatter.js.map +0 -1
  115. /package/dist/destinations/{responsys/asyncMergePetRecords → engage-messaging-sendgrid/previewApiLookup}/generated-types.js +0 -0
  116. /package/dist/destinations/{responsys/asyncMergeProfileListMembers → engage-messaging-sendgrid/sendEmail}/generated-types.js +0 -0
  117. /package/dist/destinations/{dynamic-yield-audiences/syncAudience → engage-messaging-twilio/utils}/types.js +0 -0
@@ -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
9
  } & import("./operationTracking").OperationLoggerDecoratorArgs & {
8
- shouldStats?: ((args: import("./operationTracking").OperationStatsEventArgs) => boolean | void) | undefined;
9
- } & {
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,6 +15,14 @@ export declare const track: ((decoratorArgs?: ({
15
15
  }) | undefined;
16
16
  } & {
17
17
  _contextType: import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any> & {
18
+ tags: string[];
19
+ sharedContext: {
20
+ tags: string[];
21
+ };
22
+ decoratorArgs?: {
23
+ shouldStats?: ((args: import("./operationTracking").OperationStatsEventArgs) => boolean | void) | undefined;
24
+ } | undefined;
25
+ } & {
18
26
  decoratorArgs?: {
19
27
  onError?: ((ctx: import("./operationTracking").OperationErrorHandlerContext<import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>>) => void) | undefined;
20
28
  } | undefined;
@@ -35,14 +43,6 @@ export declare const track: ((decoratorArgs?: ({
35
43
  logMetadata?: Record<string, unknown> | undefined;
36
44
  decoratorArgs?: import("./operationTracking").OperationLoggerDecoratorArgs | undefined;
37
45
  sharedContext: import("./operationTracking").OperationLoggerSharedContext;
38
- } & {
39
- tags: string[];
40
- sharedContext: {
41
- tags: string[];
42
- };
43
- decoratorArgs?: {
44
- shouldStats?: ((args: import("./operationTracking").OperationStatsEventArgs) => boolean | void) | undefined;
45
- } | undefined;
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 destination from '../engage/sendgrid';
2
- export default destination;
3
- export * from '../engage/sendgrid';
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
- const sendgrid_1 = __importDefault(require("../engage/sendgrid"));
17
- exports.default = sendgrid_1.default;
18
- __exportStar(require("../engage/sendgrid"), exports);
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":";;;;;;;;;;;;;;;AAOA,kEAA4C;AAC5C,kBAAe,kBAAW,CAAA;AAC1B,qDAAkC"}
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"}
@@ -2,7 +2,7 @@ import { InputField } from '@segment/actions-core';
2
2
  import { RequestClient } from '@segment/actions-core';
3
3
  import { Logger, StatsClient, DataFeedCache } from '@segment/actions-core/destination-kit';
4
4
  import type { Settings } from '../generated-types';
5
- import { Profile } from '../Profile';
5
+ import { Profile } from '@segment/actions-shared';
6
6
  export declare type ApiLookupConfig = {
7
7
  id?: string | undefined;
8
8
  name: string;
@@ -12,10 +12,11 @@ export declare type ApiLookupConfig = {
12
12
  body?: string | undefined;
13
13
  headers?: object | undefined;
14
14
  responseType: string;
15
+ shouldRetryOnRetryableError?: boolean;
15
16
  };
16
17
  export declare const getRequestId: ({ method, url, body, headers }: ApiLookupConfig) => string;
17
18
  export declare const getCachedResponse: ({ responseType }: ApiLookupConfig, requestId: string, dataFeedCache: DataFeedCache, datafeedTags: string[]) => Promise<any>;
18
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>;
19
20
  export declare const apiLookupActionFields: Record<string, InputField>;
20
- export declare const apiLookupLiquidKey = "lookups";
21
+ export declare const apiLookupLiquidKey = "datafeeds";
21
22
  export declare const FLAGON_NAME_DATA_FEEDS = "is-datafeeds-enabled";
@@ -5,25 +5,24 @@ const crypto_1 = require("crypto");
5
5
  const actions_core_1 = require("@segment/actions-core");
6
6
  const liquidjs_1 = require("liquidjs");
7
7
  const Liquid = new liquidjs_1.Liquid();
8
- const maxResponseSizeBytes = 1000000;
9
- const renderLiquidFields = async ({ id, url, body }, profile, datafeedTags, settings, logger) => {
8
+ const renderLiquidFields = async ({ url, body }, profile, datafeedTags, logDataFeedError) => {
10
9
  let renderedUrl;
11
10
  let renderedBody;
12
11
  try {
13
12
  renderedUrl = await Liquid.parseAndRender(url, { profile });
14
13
  }
15
14
  catch (error) {
16
- logger?.error(`TE Messaging: Email datafeed url parse failure - api lookup id: ${id} - ${settings.spaceId} - [${error}]`);
17
- datafeedTags.push('error:true', `error_message:${error?.message}`, 'reason:rendering_failure', 'rendering:url');
18
- throw new actions_core_1.IntegrationError('Unable to parse email api lookup url', 'api lookup url parse failure', 400);
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);
19
18
  }
20
19
  try {
21
20
  renderedBody = body ? await Liquid.parseAndRender(body, { profile }) : undefined;
22
21
  }
23
22
  catch (error) {
24
- logger?.error(`TE Messaging: Email datafeed body parse failure - api lookup id: ${id} - ${settings.spaceId} - [${error}]`);
25
- datafeedTags.push('error:true', `error_message:${error?.message}`, 'reason:rendering_failure', 'rendering:body');
26
- throw new actions_core_1.IntegrationError('Unable to parse email api lookup body', 'api lookup body parse failure', 400);
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);
27
26
  }
28
27
  return {
29
28
  renderedUrl,
@@ -38,7 +37,7 @@ const getRequestId = ({ method, url, body, headers }) => {
38
37
  };
39
38
  exports.getRequestId = getRequestId;
40
39
  const getCachedResponse = async ({ responseType }, requestId, dataFeedCache, datafeedTags) => {
41
- const cachedResponse = await dataFeedCache?.getRequestResponse(requestId);
40
+ const cachedResponse = await dataFeedCache.getRequestResponse(requestId);
42
41
  if (!cachedResponse) {
43
42
  datafeedTags.push('cache_hit:false');
44
43
  return;
@@ -51,17 +50,26 @@ const getCachedResponse = async ({ responseType }, requestId, dataFeedCache, dat
51
50
  };
52
51
  exports.getCachedResponse = getCachedResponse;
53
52
  const performApiLookup = async (request, apiLookupConfig, profile, statsClient, tags, settings, logger, dataFeedCache) => {
54
- const { id, method, headers, cacheTtl, name } = apiLookupConfig;
53
+ const { id, method, headers, cacheTtl, name, shouldRetryOnRetryableError = true } = apiLookupConfig;
55
54
  const datafeedTags = [
56
55
  ...tags,
57
56
  `datafeed_id:${id}`,
58
57
  `datafeed_name:${name}`,
59
58
  `space_id:${settings.spaceId}`,
60
- `cache_ttl_greater_than_0:${cacheTtl > 0}`
59
+ `cache_ttl_greater_than_0:${cacheTtl > 0}`,
60
+ `retry_enabled:${shouldRetryOnRetryableError}`
61
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
+ };
62
65
  try {
63
- const { renderedUrl, renderedBody } = await renderLiquidFields(apiLookupConfig, profile, datafeedTags, settings, logger);
66
+ const { renderedUrl, renderedBody } = await renderLiquidFields(apiLookupConfig, profile, datafeedTags, logDataFeedError);
64
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
+ }
65
73
  if (cacheTtl > 0 && dataFeedCache) {
66
74
  const cachedResponse = await exports.getCachedResponse(apiLookupConfig, requestId, dataFeedCache, datafeedTags);
67
75
  if (cachedResponse) {
@@ -82,43 +90,45 @@ const performApiLookup = async (request, apiLookupConfig, profile, statsClient,
82
90
  }
83
91
  catch (error) {
84
92
  const respError = error.response;
85
- logger?.error(`TE Messaging: Email api lookup failure - api lookup id: ${id} - ${settings.spaceId} - [${error}]`);
86
- datafeedTags.push(`error:true`, `error_message:${error.message}`, `error_status:${respError?.status}`, 'reason:api_call_failure');
87
- throw error;
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 {};
88
99
  }
89
- const dataString = JSON.stringify(data);
90
- const size = Buffer.byteLength(dataString, 'utf-8');
91
- datafeedTags.push(`response_size_greater_than_mb:${size > maxResponseSizeBytes}`);
92
- if (cacheTtl > 0) {
93
- if (size <= maxResponseSizeBytes) {
94
- try {
95
- await dataFeedCache?.setRequestResponse(requestId, dataString, cacheTtl / 1000);
96
- datafeedTags.push('cache_set:true');
97
- }
98
- catch (err) {
99
- logger?.error(`TE Messaging: Email api lookup cache set failure - api lookup id: ${id} - ${settings.spaceId} - [${err}]`);
100
- datafeedTags.push('cache_set:false');
101
- datafeedTags.push('error:true', 'reason:cache_set_failure', `error_message:${err?.message}`);
102
- throw err;
103
- }
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');
104
111
  }
105
- else {
106
- datafeedTags.push('cache_set:false');
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;
107
116
  }
108
117
  }
118
+ datafeedTags.push('error:false');
109
119
  return data;
110
120
  }
111
121
  catch (error) {
112
122
  const isErrorCapturedInTags = datafeedTags.find((str) => str.includes('error:true'));
113
123
  if (!isErrorCapturedInTags) {
114
- datafeedTags.push('error:true', `error_message:${error?.message}`, 'reason:unknown');
124
+ datafeedTags.push('error:true', 'reason:unknown');
115
125
  }
116
126
  tags.push('reason:datafeed_failure');
117
- logger?.error(`TE Messaging: Email api lookup failure - api lookup id: ${id} - ${settings.spaceId} - [${error}]`);
127
+ logDataFeedError('Unexpected data feed error', error);
118
128
  throw error;
119
129
  }
120
130
  finally {
121
- statsClient?.incr('datafeed-execution', 1, datafeedTags);
131
+ statsClient?.incr('datafeed_execution', 1, datafeedTags);
122
132
  }
123
133
  };
124
134
  exports.performApiLookup = performApiLookup;
@@ -167,8 +177,13 @@ exports.apiLookupActionFields = {
167
177
  description: 'The response type of the request. Currently only supporting JSON.',
168
178
  type: 'string',
169
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'
170
185
  }
171
186
  };
172
- exports.apiLookupLiquidKey = 'lookups';
187
+ exports.apiLookupLiquidKey = 'datafeeds';
173
188
  exports.FLAGON_NAME_DATA_FEEDS = 'is-datafeeds-enabled';
174
- //# sourceMappingURL=api-lookups.js.map
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":[],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KACf;IACD,OAAO,EAAE;QACP,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE,6CAA6C;QAC1D,IAAI,EAAE,QAAQ;KACf;IACD,YAAY,EAAE;QACZ,KAAK,EAAE,eAAe;QACtB,WAAW,EAAE,mEAAmE;QAChF,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;KACf;IACD,2BAA2B,EAAE;QAC3B,KAAK,EAAE,cAAc;QACrB,WAAW,EACT,iJAAiJ;QACnJ,IAAI,EAAE,SAAS;KAChB;CACF,CAAA;AAEY,QAAA,kBAAkB,GAAG,WAAW,CAAA;AAEhC,QAAA,sBAAsB,GAAG,sBAAsB,CAAA"}
@@ -0,0 +1,16 @@
1
+ export interface Payload {
2
+ id?: string;
3
+ name: string;
4
+ url: string;
5
+ method: string;
6
+ cacheTtl: number;
7
+ body?: string;
8
+ headers?: {
9
+ [k: string]: unknown;
10
+ };
11
+ responseType: string;
12
+ shouldRetryOnRetryableError?: boolean;
13
+ traits?: {
14
+ [k: string]: unknown;
15
+ };
16
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-sendgrid/previewApiLookup/generated-types.ts"],"names":[],"mappings":""}
@@ -1,5 +1,5 @@
1
1
  import { ActionDefinition } from '@segment/actions-core';
2
2
  import type { Settings } from '../generated-types';
3
3
  import type { Payload } from './generated-types';
4
- declare const action: ActionDefinition<Settings, Payload>;
5
- export default action;
4
+ export declare const actionDefinition: ActionDefinition<Settings, Payload>;
5
+ export default actionDefinition;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.actionDefinition = void 0;
4
+ const apiLookups_1 = require("./apiLookups");
5
+ exports.actionDefinition = {
6
+ title: 'Perform a single API lookup',
7
+ description: 'Perform a single API lookup and return the response',
8
+ fields: {
9
+ ...apiLookups_1.apiLookupActionFields,
10
+ traits: {
11
+ label: 'Traits',
12
+ description: "A user profile's traits",
13
+ type: 'object',
14
+ required: false
15
+ }
16
+ },
17
+ perform: async (request, { settings, payload, statsContext, logger }) => {
18
+ const statsClient = statsContext?.statsClient;
19
+ const tags = statsContext?.tags ?? [];
20
+ const { traits = {}, ...apiLookupConfig } = payload;
21
+ const profile = { traits: traits };
22
+ const data = await apiLookups_1.performApiLookup(request, apiLookupConfig, profile, statsClient, tags, settings, logger);
23
+ return {
24
+ data
25
+ };
26
+ }
27
+ };
28
+ exports.default = exports.actionDefinition;
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-sendgrid/previewApiLookup/index.ts"],"names":[],"mappings":";;;AAGA,6CAAsE;AAGzD,QAAA,gBAAgB,GAAwC;IACnE,KAAK,EAAE,6BAA6B;IACpC,WAAW,EAAE,qDAAqD;IAClE,MAAM,EAAE;QACN,GAAG,kCAAqB;QACxB,MAAM,EAAE;YACN,KAAK,EAAE,QAAQ;YACf,WAAW,EAAE,yBAAyB;YACtC,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;SAChB;KACF;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE;QACtE,MAAM,WAAW,GAAG,YAAY,EAAE,WAAW,CAAA;QAC7C,MAAM,IAAI,GAAG,YAAY,EAAE,IAAI,IAAI,EAAE,CAAA;QACrC,MAAM,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,eAAe,EAAE,GAAG,OAAO,CAAA;QACnD,MAAM,OAAO,GAAY,EAAE,MAAM,EAAE,MAAgC,EAAE,CAAA;QACrE,MAAM,IAAI,GAAG,MAAM,6BAAgB,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;QAC3G,OAAO;YACL,IAAI;SACL,CAAA;IACH,CAAC;CACF,CAAA;AAED,kBAAe,wBAAgB,CAAA"}
@@ -0,0 +1,43 @@
1
+ import { ExtId, MessageSendPerformer, OperationContext, ResponseError, Profile } from '@segment/actions-shared';
2
+ import type { Settings } from '../generated-types';
3
+ import type { Payload } from './generated-types';
4
+ import { Liquid as LiquidJs } from 'liquidjs';
5
+ import { ApiLookupConfig, apiLookupLiquidKey } from '../previewApiLookup/apiLookups';
6
+ export declare const EXTERNAL_ID_KEY = "email";
7
+ export declare const Liquid: LiquidJs;
8
+ export declare class SendEmailPerformer extends MessageSendPerformer<Settings, Payload> {
9
+ getIntegrationStatsName(): string;
10
+ getChannelType(): string;
11
+ getDefaultSettingsRegion(): string;
12
+ isSupportedExternalId(externalId: ExtId<Payload>): boolean;
13
+ isExternalIdSubscribed(extId: ExtId<Payload>): boolean | undefined;
14
+ getRecepients(): ExtId<Payload>[];
15
+ parseTemplating(content: string, liquidData: {
16
+ profile: Profile;
17
+ [apiLookupLiquidKey]?: Record<string, unknown>;
18
+ }, contentType: string): Promise<any>;
19
+ sendToRecepient(emailProfile: ExtId<Payload>): Promise<import("@segment/actions-core").ModifiedResponse<unknown> | undefined>;
20
+ getBodyTemplateFromS3(bodyUrl: string): Promise<string>;
21
+ getBodyHtml(profile: Profile, apiLookupData: Record<string, unknown>, emailProfile: {
22
+ id?: string | undefined;
23
+ type?: string | undefined;
24
+ subscriptionStatus?: string | undefined;
25
+ unsubscribeLink?: string | undefined;
26
+ preferencesLink?: string | undefined;
27
+ groups?: {
28
+ id?: string | undefined;
29
+ isSubscribed?: boolean | undefined;
30
+ groupUnsubscribeLink?: string | undefined;
31
+ }[] | undefined;
32
+ }): Promise<string>;
33
+ generateEmailHtml(design: string): Promise<string>;
34
+ performApiLookups(this: SendEmailPerformer, apiLookups: ApiLookupConfig[] | undefined, profile: Profile): Promise<Record<string, unknown>>;
35
+ validateLinkAndLog(link: string): void;
36
+ insertUnsubscribeLinks(html: string, emailProfile: EmailProfile): string;
37
+ onResponse(args: {
38
+ response?: Response;
39
+ error?: ResponseError;
40
+ operation: OperationContext;
41
+ }): void;
42
+ }
43
+ export declare type EmailProfile = ExtId<Payload>;