@segment/action-destinations 3.181.0 → 3.183.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.
Files changed (155) hide show
  1. package/dist/destinations/app-fit/config.d.ts +3 -0
  2. package/dist/destinations/app-fit/config.js +7 -0
  3. package/dist/destinations/app-fit/config.js.map +1 -0
  4. package/dist/destinations/app-fit/generated-types.d.ts +3 -0
  5. package/dist/destinations/app-fit/generated-types.js +3 -0
  6. package/dist/destinations/app-fit/generated-types.js.map +1 -0
  7. package/dist/destinations/app-fit/index.d.ts +4 -0
  8. package/dist/destinations/app-fit/index.js +39 -0
  9. package/dist/destinations/app-fit/index.js.map +1 -0
  10. package/dist/destinations/app-fit/track/generated-types.d.ts +13 -0
  11. package/dist/destinations/app-fit/track/generated-types.js +3 -0
  12. package/dist/destinations/app-fit/track/generated-types.js.map +1 -0
  13. package/dist/destinations/app-fit/track/index.d.ts +5 -0
  14. package/dist/destinations/app-fit/track/index.js +109 -0
  15. package/dist/destinations/app-fit/track/index.js.map +1 -0
  16. package/dist/destinations/engage-messaging-sendgrid/index.js +3 -1
  17. package/dist/destinations/engage-messaging-sendgrid/index.js.map +1 -1
  18. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/generated-types.d.ts +15 -0
  19. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/generated-types.js +3 -0
  20. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/generated-types.js.map +1 -0
  21. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/index.d.ts +5 -0
  22. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/index.js +28 -0
  23. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/index.js.map +1 -0
  24. package/dist/destinations/engage-messaging-sendgrid/sendEmail/generated-types.d.ts +12 -0
  25. package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.js +38 -12
  26. package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.js.map +1 -1
  27. package/dist/destinations/engage-messaging-sendgrid/utils/api-lookups.d.ts +20 -0
  28. package/dist/destinations/engage-messaging-sendgrid/utils/api-lookups.js +108 -0
  29. package/dist/destinations/engage-messaging-sendgrid/utils/api-lookups.js.map +1 -0
  30. package/dist/destinations/engage-messaging-sendgrid/utils/types.d.ts +6 -0
  31. package/dist/destinations/engage-messaging-sendgrid/utils/types.js +3 -0
  32. package/dist/destinations/engage-messaging-sendgrid/utils/types.js.map +1 -0
  33. package/dist/destinations/engage-messaging-twilio/operationTracking/GenericMethodDecorator.d.ts +1 -0
  34. package/dist/destinations/engage-messaging-twilio/operationTracking/GenericMethodDecorator.js +3 -0
  35. package/dist/destinations/engage-messaging-twilio/operationTracking/GenericMethodDecorator.js.map +1 -0
  36. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationDecorator.d.ts +46 -0
  37. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationDecorator.js +46 -0
  38. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationDecorator.js.map +1 -0
  39. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationDuration.d.ts +12 -0
  40. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationDuration.js +23 -0
  41. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationDuration.js.map +1 -0
  42. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationErrorHandler.d.ts +12 -0
  43. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationErrorHandler.js +35 -0
  44. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationErrorHandler.js.map +1 -0
  45. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationFinallyHooks.d.ts +10 -0
  46. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationFinallyHooks.js +29 -0
  47. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationFinallyHooks.js.map +1 -0
  48. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationLogger.d.ts +30 -0
  49. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationLogger.js +107 -0
  50. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationLogger.js.map +1 -0
  51. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationStats.d.ts +39 -0
  52. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationStats.js +130 -0
  53. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationStats.js.map +1 -0
  54. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationTracker.test.d.ts +1 -0
  55. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationTracker.test.js +377 -0
  56. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationTracker.test.js.map +1 -0
  57. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationTree.d.ts +23 -0
  58. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationTree.js +49 -0
  59. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationTree.js.map +1 -0
  60. package/dist/destinations/engage-messaging-twilio/operationTracking/TrackedError.d.ts +6 -0
  61. package/dist/destinations/engage-messaging-twilio/operationTracking/TrackedError.js +3 -0
  62. package/dist/destinations/engage-messaging-twilio/operationTracking/TrackedError.js.map +1 -0
  63. package/dist/destinations/engage-messaging-twilio/operationTracking/index.d.ts +10 -0
  64. package/dist/destinations/engage-messaging-twilio/operationTracking/index.js +23 -0
  65. package/dist/destinations/engage-messaging-twilio/operationTracking/index.js.map +1 -0
  66. package/dist/destinations/engage-messaging-twilio/operationTracking/wrapTryCatchFinallyPromisable.d.ts +21 -0
  67. package/dist/destinations/engage-messaging-twilio/operationTracking/wrapTryCatchFinallyPromisable.js +99 -0
  68. package/dist/destinations/engage-messaging-twilio/operationTracking/wrapTryCatchFinallyPromisable.js.map +1 -0
  69. package/dist/destinations/engage-messaging-twilio/sendMobilePush/generated-types.d.ts +1 -1
  70. package/dist/destinations/engage-messaging-twilio/sendMobilePush/index.js +7 -25
  71. package/dist/destinations/engage-messaging-twilio/sendMobilePush/index.js.map +1 -1
  72. package/dist/destinations/engage-messaging-twilio/sendMobilePush/push-sender.d.ts +1 -1
  73. package/dist/destinations/engage-messaging-twilio/sendMobilePush/push-sender.js +31 -25
  74. package/dist/destinations/engage-messaging-twilio/sendMobilePush/push-sender.js.map +1 -1
  75. package/dist/destinations/engage-messaging-twilio/sendSms/index.js +1 -1
  76. package/dist/destinations/engage-messaging-twilio/sendSms/index.js.map +1 -1
  77. package/dist/destinations/engage-messaging-twilio/sendSms/sms-sender.d.ts +1 -1
  78. package/dist/destinations/engage-messaging-twilio/sendSms/sms-sender.js +20 -10
  79. package/dist/destinations/engage-messaging-twilio/sendSms/sms-sender.js.map +1 -1
  80. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.js +1 -1
  81. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.js.map +1 -1
  82. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.d.ts +1 -1
  83. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.js +42 -36
  84. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.js.map +1 -1
  85. package/dist/destinations/engage-messaging-twilio/utils/IntegrationErrorWrapper.d.ts +12 -0
  86. package/dist/destinations/engage-messaging-twilio/utils/IntegrationErrorWrapper.js +31 -0
  87. package/dist/destinations/engage-messaging-twilio/utils/IntegrationErrorWrapper.js.map +1 -0
  88. package/dist/destinations/engage-messaging-twilio/utils/MessageLogger.d.ts +15 -0
  89. package/dist/destinations/engage-messaging-twilio/utils/MessageLogger.js +36 -0
  90. package/dist/destinations/engage-messaging-twilio/utils/MessageLogger.js.map +1 -0
  91. package/dist/destinations/engage-messaging-twilio/utils/MessageStats.d.ts +14 -0
  92. package/dist/destinations/engage-messaging-twilio/utils/MessageStats.js +78 -0
  93. package/dist/destinations/engage-messaging-twilio/utils/MessageStats.js.map +1 -0
  94. package/dist/destinations/engage-messaging-twilio/utils/index.d.ts +6 -0
  95. package/dist/destinations/engage-messaging-twilio/utils/index.js +19 -0
  96. package/dist/destinations/engage-messaging-twilio/utils/index.js.map +1 -0
  97. package/dist/destinations/engage-messaging-twilio/utils/isDestinationActionService.d.ts +1 -0
  98. package/dist/destinations/engage-messaging-twilio/utils/isDestinationActionService.js +8 -0
  99. package/dist/destinations/engage-messaging-twilio/utils/isDestinationActionService.js.map +1 -0
  100. package/dist/destinations/engage-messaging-twilio/utils/message-sender.d.ts +21 -54
  101. package/dist/destinations/engage-messaging-twilio/utils/message-sender.js +112 -225
  102. package/dist/destinations/engage-messaging-twilio/utils/message-sender.js.map +1 -1
  103. package/dist/destinations/engage-messaging-twilio/utils/phone-message.d.ts +7 -0
  104. package/dist/destinations/engage-messaging-twilio/utils/phone-message.js +30 -33
  105. package/dist/destinations/engage-messaging-twilio/utils/phone-message.js.map +1 -1
  106. package/dist/destinations/engage-messaging-twilio/utils/track.d.ts +45 -0
  107. package/dist/destinations/engage-messaging-twilio/utils/track.js +9 -0
  108. package/dist/destinations/engage-messaging-twilio/utils/track.js.map +1 -0
  109. package/dist/destinations/hubspot/generated-types.d.ts +1 -0
  110. package/dist/destinations/hubspot/index.js +7 -1
  111. package/dist/destinations/hubspot/index.js.map +1 -1
  112. package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.js +9 -1
  113. package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.js.map +1 -1
  114. package/dist/destinations/index.js +3 -0
  115. package/dist/destinations/index.js.map +1 -1
  116. package/dist/destinations/insider/trackEvent/index.js +1 -1
  117. package/dist/destinations/insider/trackEvent/index.js.map +1 -1
  118. package/dist/destinations/listrak/generated-types.d.ts +4 -0
  119. package/dist/destinations/listrak/generated-types.js +3 -0
  120. package/dist/destinations/listrak/generated-types.js.map +1 -0
  121. package/dist/destinations/listrak/index.d.ts +4 -0
  122. package/dist/destinations/listrak/index.js +55 -0
  123. package/dist/destinations/listrak/index.js.map +1 -0
  124. package/dist/destinations/listrak/updateEmailContactProfileFields/generated-types.d.ts +8 -0
  125. package/dist/destinations/listrak/updateEmailContactProfileFields/generated-types.js +3 -0
  126. package/dist/destinations/listrak/updateEmailContactProfileFields/generated-types.js.map +1 -0
  127. package/dist/destinations/listrak/updateEmailContactProfileFields/index.d.ts +13 -0
  128. package/dist/destinations/listrak/updateEmailContactProfileFields/index.js +77 -0
  129. package/dist/destinations/listrak/updateEmailContactProfileFields/index.js.map +1 -0
  130. package/dist/destinations/liveramp-audiences/audienceEntered/index.js +1 -1
  131. package/dist/destinations/liveramp-audiences/audienceEntered/index.js.map +1 -1
  132. package/dist/destinations/liveramp-audiences/audienceEntered/sftp.d.ts +2 -2
  133. package/dist/destinations/liveramp-audiences/audienceEntered/sftp.js +6 -2
  134. package/dist/destinations/liveramp-audiences/audienceEntered/sftp.js.map +1 -1
  135. package/dist/destinations/liveramp-audiences/index.js +1 -1
  136. package/dist/destinations/liveramp-audiences/index.js.map +1 -1
  137. package/dist/destinations/m3ter/auth.d.ts +7 -0
  138. package/dist/destinations/m3ter/auth.js +16 -0
  139. package/dist/destinations/m3ter/auth.js.map +1 -0
  140. package/dist/destinations/m3ter/constants.d.ts +4 -0
  141. package/dist/destinations/m3ter/constants.js +8 -0
  142. package/dist/destinations/m3ter/constants.js.map +1 -0
  143. package/dist/destinations/m3ter/generated-types.d.ts +5 -0
  144. package/dist/destinations/m3ter/generated-types.js +3 -0
  145. package/dist/destinations/m3ter/generated-types.js.map +1 -0
  146. package/dist/destinations/m3ter/index.d.ts +4 -0
  147. package/dist/destinations/m3ter/index.js +68 -0
  148. package/dist/destinations/m3ter/index.js.map +1 -0
  149. package/dist/destinations/m3ter/submitMeasurements/generated-types.d.ts +32 -0
  150. package/dist/destinations/m3ter/submitMeasurements/generated-types.js +3 -0
  151. package/dist/destinations/m3ter/submitMeasurements/generated-types.js.map +1 -0
  152. package/dist/destinations/m3ter/submitMeasurements/index.d.ts +5 -0
  153. package/dist/destinations/m3ter/submitMeasurements/index.js +116 -0
  154. package/dist/destinations/m3ter/submitMeasurements/index.js.map +1 -0
  155. package/package.json +4 -4
@@ -1,41 +1,19 @@
1
1
  "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
9
  exports.WhatsAppMessageSender = void 0;
4
10
  const liquidjs_1 = require("liquidjs");
5
11
  const actions_core_1 = require("@segment/actions-core");
6
12
  const google_libphonenumber_1 = require("google-libphonenumber");
7
- const phone_message_1 = require("../utils/phone-message");
13
+ const utils_1 = require("../utils");
8
14
  const phoneUtil = google_libphonenumber_1.PhoneNumberUtil.getInstance();
9
15
  const Liquid = new liquidjs_1.Liquid();
10
- class WhatsAppMessageSender extends phone_message_1.PhoneMessage {
11
- constructor() {
12
- super(...arguments);
13
- this.getVariables = async () => {
14
- try {
15
- if (!this.payload.traitEnrichment && this.payload.contentVariables)
16
- return JSON.stringify(this.payload.contentVariables) ?? null;
17
- if (!this.payload.contentVariables || !this.payload.traits)
18
- return null;
19
- const profile = {
20
- profile: {
21
- traits: this.payload.traits
22
- }
23
- };
24
- const mapping = {};
25
- for (const [key, val] of Object.entries(this.payload.contentVariables)) {
26
- const parsed = await Liquid.parseAndRender(val, profile);
27
- if (parsed?.length) {
28
- mapping[key] = parsed;
29
- }
30
- }
31
- return JSON.stringify(mapping);
32
- }
33
- catch (error) {
34
- this.logError(`Failed to parse template with content variables - ${this.settings.spaceId} - [${error}]`);
35
- throw new actions_core_1.IntegrationError(`Unable to parse templating in content variables`, `Content variables templating parse failure`, 400);
36
- }
37
- };
38
- }
16
+ class WhatsAppMessageSender extends utils_1.PhoneMessage {
39
17
  getChannelType() {
40
18
  return 'whatsapp';
41
19
  }
@@ -46,14 +24,11 @@ class WhatsAppMessageSender extends phone_message_1.PhoneMessage {
46
24
  parsedPhone = phoneUtil.format(parsedPhone, google_libphonenumber_1.PhoneNumberFormat.E164);
47
25
  parsedPhone = `whatsapp:${parsedPhone}`;
48
26
  }
49
- catch (error) {
50
- this.tags.push('type:invalid_phone_e164');
51
- this.logError(`invalid phone number - ${this.settings.spaceId} - [${error}]`);
52
- this.stats('incr', 'error', 1);
53
- throw new actions_core_1.IntegrationError('The string supplied did not seem to be a phone number. Phone number must be able to be formatted to e164 for whatsapp.', `INVALID_PHONE`, 400);
27
+ catch (e) {
28
+ const underlyingError = e;
29
+ throw new actions_core_1.IntegrationError('Phone number must be able to be formatted to e164 for whatsapp. ' + underlyingError.message, `INVALID_PHONE`, 400);
54
30
  }
55
31
  if (!this.payload.contentSid) {
56
- this.logError(`A valid WhatsApp Content SID was not provided - ${this.settings.spaceId}`);
57
32
  throw new actions_core_1.IntegrationError('A valid whatsApp Content SID was not provided.', `INVALID_CONTENT_SID`, 400);
58
33
  }
59
34
  const params = {
@@ -66,6 +41,37 @@ class WhatsAppMessageSender extends phone_message_1.PhoneMessage {
66
41
  params['ContentVariables'] = contentVariables;
67
42
  return new URLSearchParams(params);
68
43
  }
44
+ async getVariables() {
45
+ if (!this.payload.traitEnrichment && this.payload.contentVariables)
46
+ return JSON.stringify(this.payload.contentVariables) ?? null;
47
+ if (!this.payload.contentVariables || !this.payload.traits)
48
+ return null;
49
+ const profile = {
50
+ profile: {
51
+ traits: this.payload.traits
52
+ }
53
+ };
54
+ const mapping = {};
55
+ for (const [key, val] of Object.entries(this.payload.contentVariables)) {
56
+ const parsed = await Liquid.parseAndRender(val, profile);
57
+ if (parsed?.length) {
58
+ mapping[key] = parsed;
59
+ }
60
+ }
61
+ return JSON.stringify(mapping);
62
+ }
69
63
  }
64
+ __decorate([
65
+ utils_1.track()
66
+ ], WhatsAppMessageSender.prototype, "getBody", null);
67
+ __decorate([
68
+ utils_1.track({
69
+ wrapIntegrationError: () => [
70
+ `Unable to parse templating in content variables`,
71
+ `Content variables templating parse failure`,
72
+ 400
73
+ ]
74
+ })
75
+ ], WhatsAppMessageSender.prototype, "getVariables", null);
70
76
  exports.WhatsAppMessageSender = WhatsAppMessageSender;
71
77
  //# sourceMappingURL=whatsapp-sender.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"whatsapp-sender.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.ts"],"names":[],"mappings":";;;AACA,uCAA6C;AAE7C,wDAAwD;AACxD,iEAA0E;AAC1E,0DAAqD;AAErD,MAAM,SAAS,GAAG,uCAAe,CAAC,WAAW,EAAE,CAAA;AAC/C,MAAM,MAAM,GAAG,IAAI,iBAAQ,EAAE,CAAA;AAE7B,MAAa,qBAAsB,SAAQ,4BAAqB;IAAhE;;QA2CU,iBAAY,GAAG,KAAK,IAA4B,EAAE;YACxD,IAAI;gBAIF,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,IAAI,IAAI,CAAC,OAAO,CAAC,gBAAgB;oBAChE,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,IAAI,CAAA;gBAC9D,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM;oBAAE,OAAO,IAAI,CAAA;gBAEvE,MAAM,OAAO,GAAG;oBACd,OAAO,EAAE;wBACP,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;qBAC5B;iBACF,CAAA;gBAED,MAAM,OAAO,GAA2B,EAAE,CAAA;gBAC1C,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE;oBACtE,MAAM,MAAM,GAAG,MAAM,MAAM,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,CAAC,OAAO,EAAE,CAAC,CAAA;YACzF,MAAM,IAAI,+BAAgB,CAAC,gDAAgD,EAAE,qBAAqB,EAAE,GAAG,CAAC,CAAA;SACzG;QAED,MAAM,MAAM,GAA2B;YACrC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU;YACnC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;YACvB,EAAE,EAAE,WAAW;SAChB,CAAA;QACD,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAA;QAElD,IAAI,gBAAgB;YAAE,MAAM,CAAC,kBAAkB,CAAC,GAAG,gBAAgB,CAAA;QAEnE,OAAO,IAAI,eAAe,CAAC,MAAM,CAAC,CAAA;IACpC,CAAC;CAmCF;AA5ED,sDA4EC"}
1
+ {"version":3,"file":"whatsapp-sender.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.ts"],"names":[],"mappings":";;;;;;;;;AACA,uCAA6C;AAE7C,wDAAwD;AACxD,iEAA0E;AAC1E,oCAA8C;AAE9C,MAAM,SAAS,GAAG,uCAAe,CAAC,WAAW,EAAE,CAAA;AAC/C,MAAM,MAAM,GAAG,IAAI,iBAAQ,EAAE,CAAA;AAE7B,MAAa,qBAAsB,SAAQ,oBAAqB;IAC9D,cAAc;QACZ,OAAO,UAAU,CAAA;IACnB,CAAC;IAGD,KAAK,CAAC,OAAO,CAAC,KAAa;QACzB,IAAI,WAAW,CAAA;QAEf,IAAI;YAIF,WAAW,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;YAC1C,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,yCAAiB,CAAC,IAAI,CAAC,CAAA;YACnE,WAAW,GAAG,YAAY,WAAW,EAAE,CAAA;SACxC;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,eAAe,GAAG,CAAU,CAAA;YAClC,MAAM,IAAI,+BAA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AAO,CAAC,CAAA;YAClE,IAAI,MAAM,EAAE,MAAM,EAAE;gBAClB,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAA;aACtB;SACF;QAED,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;IAChC,CAAC;CACF;AAlEC;IADC,aAAK,EAAE;oDAkCP;AASD;IAPC,aAAK,CAAC;QACL,oBAAoB,EAAE,GAAG,EAAE,CAAC;YAC1B,iDAAiD;YACjD,4CAA4C;YAC5C,GAAG;SACJ;KACF,CAAC;yDAwBD;AAvEH,sDAwEC"}
@@ -0,0 +1,12 @@
1
+ import { IntegrationError } from '@segment/actions-core';
2
+ import { TryCatchFinallyContext, TryCatchFinallyHook } from '../operationTracking';
3
+ export declare type IntegrationErrorWrapperContext<TContext extends TryCatchFinallyContext = TryCatchFinallyContext> = TContext & {
4
+ decoratorArgs?: {
5
+ wrapIntegrationError?: (ctx: TContext) => IntegrationError | ConstructorParameters<typeof IntegrationError>;
6
+ };
7
+ };
8
+ export declare class IntegrationErrorWrapper {
9
+ static getTryCatchFinallyHook(_ctx: IntegrationErrorWrapperContext): TryCatchFinallyHook<IntegrationErrorWrapperContext>;
10
+ static onCatch(ctx: IntegrationErrorWrapperContext): void;
11
+ static wrap<TContext extends TryCatchFinallyContext>(error: unknown, getWrapper: () => IntegrationError | ConstructorParameters<typeof IntegrationError>, ctx?: TContext): import("../operationTracking").TrackedError<TryCatchFinallyContext<(this: any, ...args: any[]) => any>> | undefined;
12
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IntegrationErrorWrapper = void 0;
4
+ const actions_core_1 = require("@segment/actions-core");
5
+ const operationTracking_1 = require("../operationTracking");
6
+ class IntegrationErrorWrapper {
7
+ static getTryCatchFinallyHook(_ctx) {
8
+ return this;
9
+ }
10
+ static onCatch(ctx) {
11
+ const getWrapper = ctx.decoratorArgs?.wrapIntegrationError;
12
+ if (!getWrapper)
13
+ return;
14
+ ctx.error = this.wrap(ctx.error, () => getWrapper(ctx), ctx);
15
+ }
16
+ static wrap(error, getWrapper, ctx) {
17
+ return operationTracking_1.OperationErrorHandler.wrap(error, () => {
18
+ if (error instanceof actions_core_1.IntegrationError)
19
+ return error;
20
+ const wrapper = getWrapper();
21
+ const resultError = (Array.isArray(wrapper) ? new actions_core_1.IntegrationError(...wrapper) : wrapper);
22
+ const responseErrorStatus = resultError.response?.data?.status;
23
+ if (responseErrorStatus) {
24
+ resultError.status = responseErrorStatus;
25
+ }
26
+ return resultError;
27
+ }, ctx);
28
+ }
29
+ }
30
+ exports.IntegrationErrorWrapper = IntegrationErrorWrapper;
31
+ //# sourceMappingURL=IntegrationErrorWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IntegrationErrorWrapper.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/utils/IntegrationErrorWrapper.ts"],"names":[],"mappings":";;;AAAA,wDAAwD;AACxD,4DAAyG;AAczG,MAAa,uBAAuB;IAClC,MAAM,CAAC,sBAAsB,CAC3B,IAAoC;QAEpC,OAAO,IAAI,CAAA;IACb,CAAC;IACD,MAAM,CAAC,OAAO,CAAC,GAAmC;QAChD,MAAM,UAAU,GAAG,GAAG,CAAC,aAAa,EAAE,oBAAoB,CAAA;QAC1D,IAAI,CAAC,UAAU;YAAE,OAAM;QACvB,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA;IAC9D,CAAC;IAED,MAAM,CAAC,IAAI,CACT,KAAc,EACd,UAAmF,EACnF,GAAc;QAEd,OAAO,yCAAqB,CAAC,IAAI,CAC/B,KAAK,EACL,GAAG,EAAE;YACH,IAAI,KAAK,YAAY,+BAAgB;gBAAE,OAAO,KAAK,CAAA;YACnD,MAAM,OAAO,GAAG,UAAU,EAAE,CAAA;YAC5B,MAAM,WAAW,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,+BAAgB,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAmB,CAAA;YAG3G,MAAM,mBAAmB,GAAG,WAAW,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAA;YAC9D,IAAI,mBAAmB,EAAE;gBACvB,WAAW,CAAC,MAAM,GAAG,mBAAmB,CAAA;aACzC;YACD,OAAO,WAAW,CAAA;QACpB,CAAC,EACD,GAAG,CACJ,CAAA;IACH,CAAC;CACF;AAlCD,0DAkCC"}
@@ -0,0 +1,15 @@
1
+ import { Logger } from '@segment/actions-core/destination-kit';
2
+ import { OperationLogger, OperationLoggerContext, TryCatchFinallyHook } from '../operationTracking';
3
+ import { MessageSender } from './message-sender';
4
+ export declare const FLAGON_NAME_LOG_INFO = "engage-messaging-log-info";
5
+ export declare const FLAGON_NAME_LOG_ERROR = "engage-messaging-log-error";
6
+ export declare class MessageLogger extends OperationLogger {
7
+ messageSender: MessageSender<any>;
8
+ static getTryCatchFinallyHook(_ctx: OperationLoggerContext): TryCatchFinallyHook<OperationLoggerContext>;
9
+ constructor(messageSender: MessageSender<any>);
10
+ readonly channelType: string;
11
+ get loggerClient(): Logger | undefined;
12
+ readonly logDetails: Record<string, unknown>;
13
+ logInfo(msg: string, metadata?: object): void;
14
+ logError(msg: string, metadata?: object): void;
15
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessageLogger = exports.FLAGON_NAME_LOG_ERROR = exports.FLAGON_NAME_LOG_INFO = void 0;
4
+ const operationTracking_1 = require("../operationTracking");
5
+ exports.FLAGON_NAME_LOG_INFO = 'engage-messaging-log-info';
6
+ exports.FLAGON_NAME_LOG_ERROR = 'engage-messaging-log-error';
7
+ class MessageLogger extends operationTracking_1.OperationLogger {
8
+ constructor(messageSender) {
9
+ super();
10
+ this.messageSender = messageSender;
11
+ this.logDetails = {};
12
+ this.channelType = this.messageSender.getChannelType().toUpperCase();
13
+ }
14
+ static getTryCatchFinallyHook(_ctx) {
15
+ const msgSender = _ctx.funcThis;
16
+ return msgSender?.logger;
17
+ }
18
+ get loggerClient() {
19
+ return this.messageSender.executeInput.logger;
20
+ }
21
+ logInfo(msg, metadata) {
22
+ const msgs = [msg, ...(metadata ? [JSON.stringify(metadata)] : [])];
23
+ if (!this.messageSender.isFeatureActive(exports.FLAGON_NAME_LOG_INFO, () => false))
24
+ return;
25
+ const [firstMsg, ...rest] = msgs;
26
+ this.loggerClient?.info(`TE Messaging: ${this.channelType} ${firstMsg}`, ...rest, JSON.stringify({ ...this.logDetails, ...metadata }));
27
+ }
28
+ logError(msg, metadata) {
29
+ if (!this.messageSender.isFeatureActive(exports.FLAGON_NAME_LOG_ERROR, () => false))
30
+ return;
31
+ const msgPrefix = `TE Messaging: ${this.channelType}`;
32
+ this.loggerClient?.error(`${msgPrefix} ${msg}`, JSON.stringify({ ...this.logDetails, ...metadata }));
33
+ }
34
+ }
35
+ exports.MessageLogger = MessageLogger;
36
+ //# sourceMappingURL=MessageLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessageLogger.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/utils/MessageLogger.ts"],"names":[],"mappings":";;;AAGA,4DAAmG;AAGtF,QAAA,oBAAoB,GAAG,2BAA2B,CAAA;AAClD,QAAA,qBAAqB,GAAG,4BAA4B,CAAA;AAEjE,MAAa,aAAc,SAAQ,mCAAe;IAMhD,YAAmB,aAAiC;QAClD,KAAK,EAAE,CAAA;QADU,kBAAa,GAAb,aAAa,CAAoB;QAQ3C,eAAU,GAA4B,EAAE,CAAA;QAN/C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC,WAAW,EAAE,CAAA;IACtE,CAAC;IARD,MAAM,CAAC,sBAAsB,CAA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,0 +1,14 @@
1
+ import { StatsClient, StatsContext } from '@segment/actions-core/destination-kit';
2
+ import { StatsArgs, OperationStats, OperationStatsContext, TryCatchFinallyHook, TrackedError } from '../operationTracking';
3
+ import { MessageSender } from './message-sender';
4
+ export declare class MessageStats extends OperationStats {
5
+ messageSender: MessageSender<any>;
6
+ static getTryCatchFinallyHook(_ctx: OperationStatsContext): TryCatchFinallyHook<OperationStatsContext>;
7
+ constructor(messageSender: MessageSender<any>);
8
+ onTry(ctx: OperationStatsContext): () => void;
9
+ protected get statsClient(): StatsClient | undefined;
10
+ readonly tags: StatsContext['tags'];
11
+ stats(statsArgs: StatsArgs): void;
12
+ extractTagsFromError(error: TrackedError, ctx: OperationStatsContext): string[];
13
+ getOperationNameTag(ctx: OperationStatsContext): string | undefined;
14
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessageStats = void 0;
4
+ const operationTracking_1 = require("../operationTracking");
5
+ class MessageStats extends operationTracking_1.OperationStats {
6
+ constructor(messageSender) {
7
+ super();
8
+ this.messageSender = messageSender;
9
+ }
10
+ static getTryCatchFinallyHook(_ctx) {
11
+ const msgSender = _ctx.funcThis;
12
+ return msgSender?.statsClient;
13
+ }
14
+ onTry(ctx) {
15
+ const res = super.onTry(ctx);
16
+ ctx.sharedContext.tags.push(`space_id:${this.messageSender.settings.spaceId}`, `projectid:${this.messageSender.settings.sourceId}`, `region:${this.messageSender.settings.region}`, `channel:${this.messageSender.getChannelType()}`);
17
+ const parentOperation = ctx.parent;
18
+ if (parentOperation) {
19
+ const operation_path = this.getOperationNameTag(parentOperation);
20
+ if (operation_path)
21
+ ctx.tags.push('operation_path:' + operation_path);
22
+ }
23
+ return res;
24
+ }
25
+ get statsClient() {
26
+ return this.messageSender.executeInput.statsContext?.statsClient;
27
+ }
28
+ stats(statsArgs) {
29
+ if (!this.statsClient)
30
+ return;
31
+ const { method: statsMethod, metric, value, tags } = statsArgs;
32
+ let statsFunc = this.statsClient?.[statsMethod || 'incr'].bind(this.statsClient);
33
+ if (!statsFunc)
34
+ switch (statsMethod ||
35
+ 'incr') {
36
+ case 'incr':
37
+ statsFunc = this.statsClient?.incr.bind(this.statsClient);
38
+ break;
39
+ break;
40
+ case 'histogram':
41
+ statsFunc = this.statsClient?.histogram.bind(this.statsClient);
42
+ break;
43
+ break;
44
+ case 'set':
45
+ statsFunc = this.statsClient?.set.bind(this.statsClient);
46
+ break;
47
+ break;
48
+ default:
49
+ break;
50
+ }
51
+ statsFunc?.(`actions_personas_messaging_twilio.${metric}`, typeof value === 'undefined' ? 1 : value, [
52
+ ...(this.messageSender.executeInput.statsContext?.tags || []),
53
+ ...(tags ?? [])
54
+ ]);
55
+ }
56
+ extractTagsFromError(error, ctx) {
57
+ const res = super.extractTagsFromError(error, ctx);
58
+ const respError = error;
59
+ const error_code = respError?.response?.data?.code || respError?.code;
60
+ if (error_code)
61
+ res.push(`error_code:${error_code}`);
62
+ const error_status = respError?.response?.data?.status || respError?.status;
63
+ if (error_status)
64
+ res.push(`error_status:${error_status}`);
65
+ if (error.underlyingError) {
66
+ const underlyingErrorTags = this.extractTagsFromError(error.underlyingError, ctx);
67
+ res.push(...underlyingErrorTags.map((t) => `underlying_${t}`));
68
+ }
69
+ return res;
70
+ }
71
+ getOperationNameTag(ctx) {
72
+ if (!ctx)
73
+ return undefined;
74
+ return this.messageSender.logger.getOperationName(ctx, true, '::');
75
+ }
76
+ }
77
+ exports.MessageStats = MessageStats;
78
+ //# sourceMappingURL=MessageStats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessageStats.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/utils/MessageStats.ts"],"names":[],"mappings":";;;AAEA,4DAM6B;AAK7B,MAAa,YAAa,SAAQ,kCAAc;IAM9C,YAAmB,aAAiC;QAClD,KAAK,EAAE,CAAA;QADU,kBAAa,GAAb,aAAa,CAAoB;IAEpD,CAAC;IAPD,MAAM,CAA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AAC,gBAAgB,YAAY,EAAE,CAAC,CAAA;QAE1D,IAAI,KAAK,CAAC,eAAe,EAAE;YACzB,MAAM,mBAAmB,GAAG,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,eAAsB,EAAE,GAAG,CAAC,CAAA;YACxF,GAAG,CAAC,IAAI,CAAC,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAA;SAC/D;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;IAOD,mBAAmB,CAAC,GAA0B;QAC5C,IAAI,CAAC,GAAG;YAAE,OAAO,SAAS,CAAA;QAE1B,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IACpE,CAAC;CACF;AA5FD,oCA4FC"}
@@ -0,0 +1,6 @@
1
+ export * from './message-sender';
2
+ export * from './phone-message';
3
+ export * from './MessageLogger';
4
+ export * from './MessageStats';
5
+ export * from './track';
6
+ export * from './isDestinationActionService';
@@ -0,0 +1,19 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./message-sender"), exports);
14
+ __exportStar(require("./phone-message"), exports);
15
+ __exportStar(require("./MessageLogger"), exports);
16
+ __exportStar(require("./MessageStats"), exports);
17
+ __exportStar(require("./track"), exports);
18
+ __exportStar(require("./isDestinationActionService"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAgC;AAChC,kDAA+B;AAC/B,kDAA+B;AAC/B,iDAA8B;AAC9B,0CAAuB;AACvB,+DAA4C"}
@@ -0,0 +1 @@
1
+ export declare function isDestinationActionService(): boolean;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isDestinationActionService = void 0;
4
+ function isDestinationActionService() {
5
+ return (process.env.DESTINATIONS_ACTION_SERVICE === 'true' || process.env.SERVICE_NAME === 'destination-actions-service');
6
+ }
7
+ exports.isDestinationActionService = isDestinationActionService;
8
+ //# sourceMappingURL=isDestinationActionService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isDestinationActionService.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/utils/isDestinationActionService.ts"],"names":[],"mappings":";;;AAAA,SAAgB,0BAA0B;IAExC,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,2BAA2B,KAAK,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,6BAA6B,CACjH,CAAA;AACH,CAAC;AALD,gEAKC"}
@@ -1,76 +1,43 @@
1
1
  import type { Settings } from '../generated-types';
2
2
  import type { Payload as SmsPayload } from '../sendSms/generated-types';
3
3
  import type { Payload as WhatsappPayload } from '../sendWhatsApp/generated-types';
4
- import { RequestOptions } from '@segment/actions-core';
5
- import { Logger, StatsClient, StatsContext } from '@segment/actions-core/destination-kit';
4
+ import { IntegrationError, RequestOptions } from '@segment/actions-core';
6
5
  import { ExecuteInput } from '@segment/actions-core';
7
6
  import { ContentTemplateTypes, Profile } from './types';
8
- export declare type RequestFn = (url: string, options?: RequestOptions) => Promise<Response>;
9
- declare type StatsMethod = keyof Pick<StatsClient, 'incr' | 'histogram' | 'set'>;
10
- export declare const FLAGON_NAME_LOG_INFO = "engage-messaging-log-info";
11
- export declare const FLAGON_NAME_LOG_ERROR = "engage-messaging-log-error";
7
+ import { OperationContext } from './track';
8
+ import { MessageLogger } from './MessageLogger';
9
+ import { MessageStats } from './MessageStats';
12
10
  export declare abstract class MessageSender<MessagePayload extends SmsPayload | WhatsappPayload> {
13
- readonly request: RequestFn;
11
+ readonly requestRaw: RequestFn;
14
12
  readonly executeInput: ExecuteInput<Settings, MessagePayload>;
15
- readonly logDetails: Record<string, unknown>;
13
+ readonly logger: MessageLogger;
14
+ readonly statsClient: MessageStats;
15
+ readonly currentOperation: OperationContext | undefined;
16
16
  static readonly nonSendableStatuses: string[];
17
17
  static readonly sendableStatuses: string[];
18
18
  protected readonly supportedTemplateTypes: string[];
19
19
  readonly payload: MessagePayload;
20
20
  readonly settings: Settings;
21
- readonly statsClient: StatsClient | undefined;
22
- readonly tags: StatsContext['tags'];
23
- readonly logger: Logger | undefined;
24
- constructor(request: RequestFn, executeInput: ExecuteInput<Settings, MessagePayload>, logDetails?: Record<string, unknown>);
21
+ constructor(requestRaw: RequestFn, executeInput: ExecuteInput<Settings, MessagePayload>);
22
+ request(url: string, options: RequestOptions): Promise<Response>;
25
23
  abstract getChannelType(): string;
26
24
  abstract doSend(): Promise<Response | Response[] | object[] | undefined>;
27
- send(): Promise<Response | object[] | Response[] | undefined>;
25
+ perform(): Promise<Response | object[] | Response[] | undefined>;
28
26
  parseContent<R extends Record<string, string | string[] | undefined>>(content: R, profile: Profile): Promise<R>;
29
27
  redactPii(pii: string | undefined): string | undefined;
30
28
  isFeatureActive(featureName: string, getDefault?: () => boolean): boolean | undefined;
31
- logInfo(...msgs: string[]): void;
32
- logError(error?: any, ...msgs: string[]): void;
33
- stats<TStatsMethod extends StatsMethod>(args: StatsArgs<TStatsMethod>): void;
34
- stats<TStatsMethod extends StatsMethod>(statsMethod: TStatsMethod, metric: string, value: number, extraTags?: string[]): void;
35
- statsIncrement(metric: string, value?: number, extraTags?: string[]): void;
36
- statsHistogram(metric: string, value: number, extraTags?: string[]): void;
37
- statsSet(metric: string, value: number, extraTags?: string[]): void;
38
- logWrap<R = void>(fn: () => R, args: {
39
- operationName: string;
40
- stats?: {
41
- onStart?: () => StatsArgs[] | undefined;
42
- onEnd?: (args: {
43
- result?: Awaited<R>;
44
- error?: unknown;
45
- duration: number;
46
- }) => StatsArgs[] | undefined;
47
- };
48
- }): R;
29
+ logInfo(msg: string, metadata?: object): void;
30
+ logError(msg: string, metadata?: object): void;
31
+ logOnError(logMessage: string | ((ctx: OperationContext) => string)): void;
32
+ statsIncr(metric: string, value?: number, tags?: string[]): void;
33
+ statsHistogram(metric: string, value: number, tags?: string[]): void;
34
+ statsSet(metric: string, value: number, tags?: string[]): void;
35
+ get logDetails(): Record<string, unknown>;
36
+ get tags(): string[];
49
37
  beforeSend(): void;
50
38
  getContentTemplateTypes(): Promise<ContentTemplateTypes>;
51
39
  private extractTemplateTypes;
52
40
  getWebhookUrlWithParams(externalIdType?: string, externalIdValue?: string, defaultConnectionOverrides?: string): string | null;
53
- getRethrowableError(error: unknown, apiName?: string): unknown;
54
- rethrowError(error: unknown, apiName?: string): void;
41
+ rethrowIntegrationError(error: unknown, getWrapper: () => IntegrationError | ConstructorParameters<typeof IntegrationError>): never;
55
42
  }
56
- export declare function wrapPromisable<T>(fn: () => T, args: {
57
- onStart?(): void;
58
- onSuccess?(res: Awaited<T>): void;
59
- onCatch?(error: unknown): Awaited<T>;
60
- onFinally?(res: {
61
- result: Awaited<T>;
62
- } | {
63
- error: unknown;
64
- }): void;
65
- }): T;
66
- declare type Awaited<T> = T extends null | undefined ? T : T extends object & {
67
- then(onfulfilled: infer F, ...args: infer _): any;
68
- } ? F extends (value: infer V, ...args: infer _) => any ? Awaited<V> : never : T;
69
- declare type StatsArgs<TStatsMethod extends StatsMethod = StatsMethod> = {
70
- method?: TStatsMethod;
71
- metric: string;
72
- value?: number;
73
- extraTags?: string[];
74
- };
75
- export declare function isDestinationActionService(): boolean;
76
- export {};
43
+ export declare type RequestFn = (url: string, options?: RequestOptions) => Promise<Response>;