@dereekb/nestjs 12.7.0 → 13.0.1

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 (230) hide show
  1. package/LICENSE +1 -1
  2. package/index.cjs.default.js +1 -0
  3. package/index.cjs.js +310 -0
  4. package/index.cjs.mjs +2 -0
  5. package/index.d.ts +1 -0
  6. package/index.esm.js +288 -0
  7. package/mailgun/index.cjs.default.js +1 -0
  8. package/mailgun/index.cjs.js +639 -0
  9. package/mailgun/index.cjs.mjs +2 -0
  10. package/mailgun/index.d.ts +1 -0
  11. package/mailgun/index.esm.js +626 -0
  12. package/mailgun/package.json +24 -4
  13. package/mailgun/src/lib/mailgun.d.ts +2 -2
  14. package/mailgun/src/lib/mailgun.type.d.ts +1 -1
  15. package/mailgun/src/lib/mailgun.util.d.ts +22 -17
  16. package/openai/index.cjs.default.js +1 -0
  17. package/openai/index.cjs.js +343 -0
  18. package/openai/index.cjs.mjs +2 -0
  19. package/openai/index.d.ts +1 -0
  20. package/openai/index.esm.js +326 -0
  21. package/openai/package.json +24 -6
  22. package/openai/src/lib/index.d.ts +0 -1
  23. package/openai/src/lib/webhook/webhook.openai.controller.d.ts +1 -1
  24. package/openai/src/lib/webhook/webhook.openai.d.ts +2 -2
  25. package/openai/src/lib/webhook/webhook.openai.service.d.ts +1 -1
  26. package/package.json +43 -36
  27. package/stripe/index.cjs.default.js +1 -0
  28. package/stripe/index.cjs.js +253 -0
  29. package/stripe/index.cjs.mjs +2 -0
  30. package/stripe/index.d.ts +1 -0
  31. package/stripe/index.esm.js +245 -0
  32. package/stripe/package.json +24 -6
  33. package/stripe/src/lib/index.d.ts +1 -1
  34. package/stripe/src/lib/stripe.module.d.ts +2 -2
  35. package/stripe/src/lib/webhook/webhook.stripe.controller.d.ts +1 -1
  36. package/typeform/index.cjs.default.js +1 -0
  37. package/typeform/index.cjs.js +395 -0
  38. package/typeform/index.cjs.mjs +2 -0
  39. package/typeform/index.d.ts +1 -0
  40. package/typeform/index.esm.js +380 -0
  41. package/typeform/package.json +24 -6
  42. package/typeform/src/lib/index.d.ts +0 -1
  43. package/typeform/src/lib/webhook/webhook.typeform.controller.d.ts +1 -1
  44. package/vapiai/index.cjs.default.js +1 -0
  45. package/vapiai/index.cjs.js +319 -0
  46. package/vapiai/index.cjs.mjs +2 -0
  47. package/vapiai/index.d.ts +1 -0
  48. package/vapiai/index.esm.js +310 -0
  49. package/vapiai/package.json +24 -6
  50. package/vapiai/src/lib/index.d.ts +0 -1
  51. package/vapiai/src/lib/vapiai.type.d.ts +3 -1
  52. package/vapiai/src/lib/webhook/webhook.vapiai.controller.d.ts +1 -1
  53. package/vapiai/src/lib/webhook/webhook.vapiai.d.ts +1 -9
  54. package/vapiai/src/lib/webhook/webhook.vapiai.types.d.ts +6 -34
  55. package/CHANGELOG.md +0 -2001
  56. package/mailgun/LICENSE +0 -21
  57. package/mailgun/src/index.js +0 -5
  58. package/mailgun/src/index.js.map +0 -1
  59. package/mailgun/src/lib/index.js +0 -10
  60. package/mailgun/src/lib/index.js.map +0 -1
  61. package/mailgun/src/lib/mailgun.api.js +0 -37
  62. package/mailgun/src/lib/mailgun.api.js.map +0 -1
  63. package/mailgun/src/lib/mailgun.config.js +0 -45
  64. package/mailgun/src/lib/mailgun.config.js.map +0 -1
  65. package/mailgun/src/lib/mailgun.js +0 -205
  66. package/mailgun/src/lib/mailgun.js.map +0 -1
  67. package/mailgun/src/lib/mailgun.service.js +0 -53
  68. package/mailgun/src/lib/mailgun.service.js.map +0 -1
  69. package/mailgun/src/lib/mailgun.service.module.js +0 -84
  70. package/mailgun/src/lib/mailgun.service.module.js.map +0 -1
  71. package/mailgun/src/lib/mailgun.type.js +0 -3
  72. package/mailgun/src/lib/mailgun.type.js.map +0 -1
  73. package/mailgun/src/lib/mailgun.util.js +0 -206
  74. package/mailgun/src/lib/mailgun.util.js.map +0 -1
  75. package/openai/LICENSE +0 -21
  76. package/openai/src/index.js +0 -5
  77. package/openai/src/index.js.map +0 -1
  78. package/openai/src/lib/index.js +0 -11
  79. package/openai/src/lib/index.js.map +0 -1
  80. package/openai/src/lib/openai.api.js +0 -22
  81. package/openai/src/lib/openai.api.js.map +0 -1
  82. package/openai/src/lib/openai.config.js +0 -29
  83. package/openai/src/lib/openai.config.js.map +0 -1
  84. package/openai/src/lib/openai.module.js +0 -41
  85. package/openai/src/lib/openai.module.js.map +0 -1
  86. package/openai/src/lib/openai.type.js +0 -3
  87. package/openai/src/lib/openai.type.js.map +0 -1
  88. package/openai/src/lib/openai.util.js +0 -48
  89. package/openai/src/lib/openai.util.js.map +0 -1
  90. package/openai/src/lib/webhook/index.js +0 -10
  91. package/openai/src/lib/webhook/index.js.map +0 -1
  92. package/openai/src/lib/webhook/webhook.openai.config.js +0 -17
  93. package/openai/src/lib/webhook/webhook.openai.config.js.map +0 -1
  94. package/openai/src/lib/webhook/webhook.openai.controller.js +0 -30
  95. package/openai/src/lib/webhook/webhook.openai.controller.js.map +0 -1
  96. package/openai/src/lib/webhook/webhook.openai.js +0 -41
  97. package/openai/src/lib/webhook/webhook.openai.js.map +0 -1
  98. package/openai/src/lib/webhook/webhook.openai.module.js +0 -39
  99. package/openai/src/lib/webhook/webhook.openai.module.js.map +0 -1
  100. package/openai/src/lib/webhook/webhook.openai.service.js +0 -48
  101. package/openai/src/lib/webhook/webhook.openai.service.js.map +0 -1
  102. package/openai/src/lib/webhook/webhook.openai.verify.js +0 -37
  103. package/openai/src/lib/webhook/webhook.openai.verify.js.map +0 -1
  104. package/src/index.js +0 -5
  105. package/src/index.js.map +0 -1
  106. package/src/lib/decorators/index.js +0 -6
  107. package/src/lib/decorators/index.js.map +0 -1
  108. package/src/lib/decorators/local.decorator.js +0 -17
  109. package/src/lib/decorators/local.decorator.js.map +0 -1
  110. package/src/lib/decorators/rawbody.js +0 -44
  111. package/src/lib/decorators/rawbody.js.map +0 -1
  112. package/src/lib/index.js +0 -7
  113. package/src/lib/index.js.map +0 -1
  114. package/src/lib/middlewares/index.js +0 -7
  115. package/src/lib/middlewares/index.js.map +0 -1
  116. package/src/lib/middlewares/json.middleware.js +0 -16
  117. package/src/lib/middlewares/json.middleware.js.map +0 -1
  118. package/src/lib/middlewares/rawbody.middleware.js +0 -16
  119. package/src/lib/middlewares/rawbody.middleware.js.map +0 -1
  120. package/src/lib/middlewares/webhook.js +0 -51
  121. package/src/lib/middlewares/webhook.js.map +0 -1
  122. package/src/lib/module/client/client.config.js +0 -13
  123. package/src/lib/module/client/client.config.js.map +0 -1
  124. package/src/lib/module/client/client.js +0 -8
  125. package/src/lib/module/client/client.js.map +0 -1
  126. package/src/lib/module/client/client.module.js +0 -36
  127. package/src/lib/module/client/client.module.js.map +0 -1
  128. package/src/lib/module/client/client.service.js +0 -30
  129. package/src/lib/module/client/client.service.js.map +0 -1
  130. package/src/lib/module/client/index.js +0 -8
  131. package/src/lib/module/client/index.js.map +0 -1
  132. package/src/lib/module/env/env.config.js +0 -14
  133. package/src/lib/module/env/env.config.js.map +0 -1
  134. package/src/lib/module/env/env.js +0 -10
  135. package/src/lib/module/env/env.js.map +0 -1
  136. package/src/lib/module/env/env.nest.js +0 -16
  137. package/src/lib/module/env/env.nest.js.map +0 -1
  138. package/src/lib/module/env/env.service.js +0 -33
  139. package/src/lib/module/env/env.service.js.map +0 -1
  140. package/src/lib/module/env/index.js +0 -8
  141. package/src/lib/module/env/index.js.map +0 -1
  142. package/src/lib/module/index.js +0 -7
  143. package/src/lib/module/index.js.map +0 -1
  144. package/src/lib/module/module.js +0 -26
  145. package/src/lib/module/module.js.map +0 -1
  146. package/stripe/LICENSE +0 -21
  147. package/stripe/src/index.js +0 -5
  148. package/stripe/src/index.js.map +0 -1
  149. package/stripe/src/lib/index.js +0 -8
  150. package/stripe/src/lib/index.js.map +0 -1
  151. package/stripe/src/lib/stripe.api.js +0 -40
  152. package/stripe/src/lib/stripe.api.js.map +0 -1
  153. package/stripe/src/lib/stripe.config.js +0 -19
  154. package/stripe/src/lib/stripe.config.js.map +0 -1
  155. package/stripe/src/lib/stripe.module.js +0 -41
  156. package/stripe/src/lib/stripe.module.js.map +0 -1
  157. package/stripe/src/lib/stripe.type.js +0 -4
  158. package/stripe/src/lib/stripe.type.js.map +0 -1
  159. package/stripe/src/lib/webhook/index.js +0 -8
  160. package/stripe/src/lib/webhook/index.js.map +0 -1
  161. package/stripe/src/lib/webhook/webhook.stripe.controller.js +0 -30
  162. package/stripe/src/lib/webhook/webhook.stripe.controller.js.map +0 -1
  163. package/stripe/src/lib/webhook/webhook.stripe.js +0 -67
  164. package/stripe/src/lib/webhook/webhook.stripe.js.map +0 -1
  165. package/stripe/src/lib/webhook/webhook.stripe.module.js +0 -20
  166. package/stripe/src/lib/webhook/webhook.stripe.module.js.map +0 -1
  167. package/stripe/src/lib/webhook/webhook.stripe.service.js +0 -36
  168. package/stripe/src/lib/webhook/webhook.stripe.service.js.map +0 -1
  169. package/typeform/LICENSE +0 -21
  170. package/typeform/src/index.js +0 -5
  171. package/typeform/src/index.js.map +0 -1
  172. package/typeform/src/lib/index.js +0 -11
  173. package/typeform/src/lib/index.js.map +0 -1
  174. package/typeform/src/lib/typeform.api.js +0 -22
  175. package/typeform/src/lib/typeform.api.js.map +0 -1
  176. package/typeform/src/lib/typeform.config.js +0 -21
  177. package/typeform/src/lib/typeform.config.js.map +0 -1
  178. package/typeform/src/lib/typeform.module.js +0 -39
  179. package/typeform/src/lib/typeform.module.js.map +0 -1
  180. package/typeform/src/lib/typeform.type.js +0 -3
  181. package/typeform/src/lib/typeform.type.js.map +0 -1
  182. package/typeform/src/lib/typeform.util.js +0 -26
  183. package/typeform/src/lib/typeform.util.js.map +0 -1
  184. package/typeform/src/lib/webhook/index.js +0 -12
  185. package/typeform/src/lib/webhook/index.js.map +0 -1
  186. package/typeform/src/lib/webhook/webhook.typeform.config.js +0 -17
  187. package/typeform/src/lib/webhook/webhook.typeform.config.js.map +0 -1
  188. package/typeform/src/lib/webhook/webhook.typeform.controller.js +0 -30
  189. package/typeform/src/lib/webhook/webhook.typeform.controller.js.map +0 -1
  190. package/typeform/src/lib/webhook/webhook.typeform.form.js +0 -113
  191. package/typeform/src/lib/webhook/webhook.typeform.form.js.map +0 -1
  192. package/typeform/src/lib/webhook/webhook.typeform.js +0 -27
  193. package/typeform/src/lib/webhook/webhook.typeform.js.map +0 -1
  194. package/typeform/src/lib/webhook/webhook.typeform.module.js +0 -38
  195. package/typeform/src/lib/webhook/webhook.typeform.module.js.map +0 -1
  196. package/typeform/src/lib/webhook/webhook.typeform.service.js +0 -45
  197. package/typeform/src/lib/webhook/webhook.typeform.service.js.map +0 -1
  198. package/typeform/src/lib/webhook/webhook.typeform.type.js +0 -3
  199. package/typeform/src/lib/webhook/webhook.typeform.type.js.map +0 -1
  200. package/typeform/src/lib/webhook/webhook.typeform.verify.js +0 -28
  201. package/typeform/src/lib/webhook/webhook.typeform.verify.js.map +0 -1
  202. package/vapiai/LICENSE +0 -21
  203. package/vapiai/src/index.js +0 -5
  204. package/vapiai/src/index.js.map +0 -1
  205. package/vapiai/src/lib/index.js +0 -10
  206. package/vapiai/src/lib/index.js.map +0 -1
  207. package/vapiai/src/lib/vapiai.api.js +0 -32
  208. package/vapiai/src/lib/vapiai.api.js.map +0 -1
  209. package/vapiai/src/lib/vapiai.config.js +0 -17
  210. package/vapiai/src/lib/vapiai.config.js.map +0 -1
  211. package/vapiai/src/lib/vapiai.module.js +0 -38
  212. package/vapiai/src/lib/vapiai.module.js.map +0 -1
  213. package/vapiai/src/lib/vapiai.type.js +0 -3
  214. package/vapiai/src/lib/vapiai.type.js.map +0 -1
  215. package/vapiai/src/lib/webhook/index.js +0 -10
  216. package/vapiai/src/lib/webhook/index.js.map +0 -1
  217. package/vapiai/src/lib/webhook/webhook.vapi.config.js +0 -20
  218. package/vapiai/src/lib/webhook/webhook.vapi.config.js.map +0 -1
  219. package/vapiai/src/lib/webhook/webhook.vapiai.controller.js +0 -38
  220. package/vapiai/src/lib/webhook/webhook.vapiai.controller.js.map +0 -1
  221. package/vapiai/src/lib/webhook/webhook.vapiai.js +0 -42
  222. package/vapiai/src/lib/webhook/webhook.vapiai.js.map +0 -1
  223. package/vapiai/src/lib/webhook/webhook.vapiai.module.js +0 -41
  224. package/vapiai/src/lib/webhook/webhook.vapiai.module.js.map +0 -1
  225. package/vapiai/src/lib/webhook/webhook.vapiai.service.js +0 -52
  226. package/vapiai/src/lib/webhook/webhook.vapiai.service.js.map +0 -1
  227. package/vapiai/src/lib/webhook/webhook.vapiai.types.js +0 -25
  228. package/vapiai/src/lib/webhook/webhook.vapiai.types.js.map +0 -1
  229. package/vapiai/src/lib/webhook/webhook.vapiai.verify.js +0 -49
  230. package/vapiai/src/lib/webhook/webhook.vapiai.verify.js.map +0 -1
@@ -0,0 +1,626 @@
1
+ import { isTestNodeEnv, ServerEnvironmentService } from '@dereekb/nestjs';
2
+ import { MAP_IDENTITY, asArray, forEachKeyValue, objectIsEmpty, addToSet, overrideInObject, KeyValueTypleValueFilter, forEachInIterable, makeValuesGroupMap, filterMaybeArrayValues } from '@dereekb/util';
3
+ import { Injectable, Inject, Module } from '@nestjs/common';
4
+ import Mailgun from 'mailgun.js';
5
+ import FormData from 'form-data';
6
+ import { ConfigService, ConfigModule } from '@nestjs/config';
7
+
8
+ const DEFAULT_RECIPIENT_VARIABLE_PREFIX = 'recipient-';
9
+ const MAILGUN_REPLY_TO_EMAIL_HEADER_DATA_VARIABLE_KEY = `h:Reply-To`;
10
+ /**
11
+ * The maximum number of recipients allowed in a single batch send request.
12
+ */
13
+ const MAX_BATCH_SEND_RECIPIENTS = 1000;
14
+ /**
15
+ * Converts a MailgunTemplateEmailRequest to a MailgunMessageData.
16
+ *
17
+ * @param config
18
+ * @returns
19
+ */
20
+ function convertMailgunTemplateEmailRequestToMailgunMessageData(config) {
21
+ const { request, defaultSender, isTestingEnvironment: testEnvironment, recipientVariablePrefix: inputRecipientVariablePrefix = DEFAULT_RECIPIENT_VARIABLE_PREFIX, addRecipientVariablePrefixToAllMergedGlobalVariables: inputAddRecipientVariablePrefixToAllMergedGlobalVariables = true, addCopyOfMergedRecipientVariablesWithoutPrefixToGlobalVariables: inputAddCopyOfMergedRecipientVariablesWithoutPrefixToGlobalVariables = false, addCopyOfTemplateVariablesWithRecipientVariablePrefix: inputAddCopyOfTemplateVariablesWithRecipientVariablePrefix = false } = config;
22
+ const { recipientVariablesConfig } = request;
23
+ const recipientVariablePrefix = recipientVariablesConfig?.recipientVariablePrefix ?? inputRecipientVariablePrefix;
24
+ const addRecipientVariablePrefixToAllMergedGlobalVariables = recipientVariablesConfig?.addRecipientVariablePrefixToAllMergedGlobalVariables ?? inputAddRecipientVariablePrefixToAllMergedGlobalVariables;
25
+ const addCopyOfMergedRecipientVariablesWithoutPrefixToGlobalVariables = recipientVariablesConfig?.addCopyOfMergedRecipientVariablesWithoutPrefixToGlobalVariables ?? inputAddCopyOfMergedRecipientVariablesWithoutPrefixToGlobalVariables;
26
+ const addCopyOfTemplateVariablesWithRecipientVariablePrefix = recipientVariablesConfig?.addCopyOfTemplateVariablesWithRecipientVariablePrefix ?? inputAddCopyOfTemplateVariablesWithRecipientVariablePrefix;
27
+ const finalizeRecipientVariables = request.finalizeRecipientVariables ?? MAP_IDENTITY;
28
+ const allowBatchSending = request.batchSend ?? true;
29
+ const mergeRecipientVariablesIntoGlobalVariable = !allowBatchSending;
30
+ function mapEmailToLowercase(x) {
31
+ return { ...x, email: x.email.toLowerCase() };
32
+ }
33
+ const toInput = asArray(request.to).map(mapEmailToLowercase);
34
+ const ccInput = request.cc ? asArray(request.cc).map(mapEmailToLowercase) : undefined;
35
+ const bccInput = request.bcc ? asArray(request.bcc).map(mapEmailToLowercase) : undefined;
36
+ const from = request.from ? convertMailgunRecipientToString(request.from) : defaultSender;
37
+ const to = convertMailgunRecipientsToStrings(toInput);
38
+ const cc = ccInput?.length ? convertMailgunRecipientsToStrings(ccInput) : undefined;
39
+ const bcc = bccInput?.length ? convertMailgunRecipientsToStrings(bccInput) : undefined;
40
+ // throw an error if batchSend is not defined and cc or bcc is defined
41
+ if (request.batchSend == null && (ccInput || bccInput)) {
42
+ throw new Error('convertMailgunTemplateEmailRequestToMailgunMessageData(): batchSend must be false when either "cc" or "bcc" is defined.');
43
+ }
44
+ if (allowBatchSending && to.length > MAX_BATCH_SEND_RECIPIENTS) {
45
+ throw new Error(`convertMailgunTemplateEmailRequestToMailgunMessageData(): Can only batch send to a maximum of ${MAX_BATCH_SEND_RECIPIENTS} recipients.`);
46
+ }
47
+ const data = {
48
+ from,
49
+ to,
50
+ cc,
51
+ bcc,
52
+ subject: request.subject,
53
+ template: request.template,
54
+ ...request.messageData
55
+ };
56
+ if (request.replyTo != null) {
57
+ data[MAILGUN_REPLY_TO_EMAIL_HEADER_DATA_VARIABLE_KEY] = convertMailgunRecipientToString(request.replyTo);
58
+ }
59
+ if (request.testEmail === true || ((testEnvironment ?? isTestNodeEnv()) && request.testEmail !== false)) {
60
+ data['o:testmode'] = true;
61
+ }
62
+ if (request.templateVariables) {
63
+ forEachKeyValue(request.templateVariables, {
64
+ forEach: (x) => {
65
+ const [key, value] = x;
66
+ const encodedValue = encodeMailgunTemplateVariableValue(value);
67
+ if (encodedValue != null) {
68
+ data[`v:${key}`] = encodedValue;
69
+ if (recipientVariablePrefix && addCopyOfTemplateVariablesWithRecipientVariablePrefix) {
70
+ data[`v:${recipientVariablePrefix}${key}`] = encodedValue;
71
+ }
72
+ }
73
+ }
74
+ });
75
+ }
76
+ const hasUserVariables = Boolean(data['recipient-variables']) || toInput.findIndex((x) => x.userVariables != null) !== -1;
77
+ if (hasUserVariables) {
78
+ let recipientVariables = {};
79
+ const allRecipientVariableKeys = new Set();
80
+ toInput.forEach(({ email, userVariables }) => {
81
+ if (userVariables != null && !objectIsEmpty(userVariables)) {
82
+ recipientVariables[email] = userVariables;
83
+ addToSet(allRecipientVariableKeys, Object.keys(userVariables));
84
+ }
85
+ });
86
+ if (data['recipient-variables']) {
87
+ const decoded = JSON.parse(data['recipient-variables']);
88
+ forEachKeyValue(decoded, {
89
+ forEach: (x) => {
90
+ const [recipientEmail, userVariables] = x;
91
+ const email = recipientEmail.toLowerCase();
92
+ if (recipientVariables[email] != null) {
93
+ overrideInObject(recipientVariables[email], { from: [userVariables], filter: { valueFilter: KeyValueTypleValueFilter.UNDEFINED } });
94
+ }
95
+ else {
96
+ recipientVariables[email] = userVariables;
97
+ }
98
+ addToSet(allRecipientVariableKeys, Object.keys(userVariables));
99
+ }
100
+ });
101
+ }
102
+ // Finalize the recipient variables before they are re-encoded back to JSON
103
+ recipientVariables =
104
+ finalizeRecipientVariables(recipientVariables, {
105
+ messageData: data,
106
+ config
107
+ }) ?? recipientVariables;
108
+ if (mergeRecipientVariablesIntoGlobalVariable) {
109
+ const addRecipientPrefixVariable = recipientVariablePrefix && addRecipientVariablePrefixToAllMergedGlobalVariables;
110
+ // iterate all recipient variables and merge them into the global variables
111
+ forEachKeyValue(recipientVariables, {
112
+ forEach: (x) => {
113
+ const [email, userVariables] = x;
114
+ forEachKeyValue(userVariables, {
115
+ forEach: (y) => {
116
+ const [key, value] = y;
117
+ const encodedValue = encodeMailgunTemplateVariableValue(value);
118
+ if (encodedValue != null) {
119
+ if (addRecipientPrefixVariable) {
120
+ // also add the variable using the recipient variable prefix
121
+ const recipientVariableKey = `${recipientVariablePrefix}${key}`;
122
+ data[`v:${recipientVariableKey}`] = encodedValue;
123
+ }
124
+ // add if not adding the prefix variable, or if it was requested
125
+ if (!addRecipientPrefixVariable || addCopyOfMergedRecipientVariablesWithoutPrefixToGlobalVariables) {
126
+ data[`v:${key}`] = encodedValue;
127
+ }
128
+ }
129
+ }
130
+ });
131
+ }
132
+ });
133
+ }
134
+ else {
135
+ // set back on the data object
136
+ data['recipient-variables'] = JSON.stringify(recipientVariables);
137
+ // add all recipient variable to the other variables so they can be used easily/directly in templates as variables too.
138
+ // https://documentation.mailgun.com/en/latest/user_manual.html#attaching-data-to-messages
139
+ if (recipientVariablePrefix) {
140
+ forEachInIterable(allRecipientVariableKeys, (key) => {
141
+ const recipientVariableKey = `${recipientVariablePrefix}${key}`;
142
+ // v:recipient-id=%recipient.id%
143
+ data[`v:${recipientVariableKey}`] = `%recipient.${key}%`;
144
+ });
145
+ }
146
+ }
147
+ }
148
+ // double check and remove the recipient variables if we merged them into the global variables
149
+ if (mergeRecipientVariablesIntoGlobalVariable) {
150
+ delete data['recipient-variables'];
151
+ }
152
+ const inputAttachments = request.attachments;
153
+ if (inputAttachments) {
154
+ if (data.attachment) {
155
+ throw new Error(`Cannot specify attachments in both messageData and in the request's attachments field.`);
156
+ }
157
+ data.attachment = inputAttachments;
158
+ }
159
+ return data;
160
+ }
161
+ function convertMailgunRecipientsToStrings(recipients) {
162
+ return recipients.map((x) => convertMailgunRecipientToString(x));
163
+ }
164
+ function convertMailgunRecipientToString(recipient) {
165
+ let address = recipient.email;
166
+ if (recipient.name) {
167
+ address = `${recipient.name} <${address}>`;
168
+ }
169
+ return address;
170
+ }
171
+ /**
172
+ * Encodes a value to a string for use as a Mailgun template variable. Throws an error if the value is not supported.
173
+ *
174
+ * @param value The value to encode.
175
+ * @returns The encoded value, or undefined if the value is null or undefined.
176
+ */
177
+ function encodeMailgunTemplateVariableValue(value) {
178
+ let encodedValue;
179
+ switch (typeof value) {
180
+ case 'object':
181
+ if (value) {
182
+ if (value instanceof Date) {
183
+ encodedValue = value.toISOString();
184
+ }
185
+ else {
186
+ encodedValue = JSON.stringify(value);
187
+ }
188
+ }
189
+ break;
190
+ case 'bigint':
191
+ case 'boolean':
192
+ case 'number':
193
+ case 'string':
194
+ encodedValue = String(value); // encoded as a string value
195
+ break;
196
+ default:
197
+ if (value) {
198
+ throw new Error(`Invalid value "${value}" passed to encodeMailgunTemplateVariableValue().`);
199
+ }
200
+ }
201
+ return encodedValue;
202
+ }
203
+
204
+ /******************************************************************************
205
+ Copyright (c) Microsoft Corporation.
206
+
207
+ Permission to use, copy, modify, and/or distribute this software for any
208
+ purpose with or without fee is hereby granted.
209
+
210
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
211
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
212
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
213
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
214
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
215
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
216
+ PERFORMANCE OF THIS SOFTWARE.
217
+ ***************************************************************************** */
218
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
219
+
220
+
221
+ function __decorate(decorators, target, key, desc) {
222
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
223
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
224
+ 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;
225
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
226
+ }
227
+
228
+ function __param(paramIndex, decorator) {
229
+ return function (target, key) { decorator(target, key, paramIndex); }
230
+ }
231
+
232
+ function __metadata(metadataKey, metadataValue) {
233
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
234
+ }
235
+
236
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
237
+ var e = new Error(message);
238
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
239
+ };
240
+
241
+ class MailgunServiceConfig {
242
+ // Mailgun Config
243
+ mailgun;
244
+ /**
245
+ * Base URL to the client.
246
+ */
247
+ clientUrl;
248
+ /**
249
+ * Main domain to send emails from.
250
+ */
251
+ domain;
252
+ /**
253
+ * Mailgun sender string.
254
+ */
255
+ sender;
256
+ /**
257
+ * Additional messages config
258
+ */
259
+ messages;
260
+ static assertValidConfig(config) {
261
+ if (!config.mailgun.username) {
262
+ throw new Error('No mailgun username specified.');
263
+ }
264
+ else if (!config.mailgun.key) {
265
+ throw new Error('No mailgun key specified.');
266
+ }
267
+ else if (!config.domain) {
268
+ throw new Error('No mailgun domain specified.');
269
+ }
270
+ else if (!config.clientUrl) {
271
+ throw new Error('No client url specified.');
272
+ }
273
+ else if (!config.sender) {
274
+ throw new Error('No mailgun sender specified.');
275
+ }
276
+ else if (!config.messages) {
277
+ throw new Error('No mailgun messages config specified.');
278
+ }
279
+ }
280
+ }
281
+
282
+ let MailgunApi = class MailgunApi {
283
+ config;
284
+ client;
285
+ constructor(config) {
286
+ this.config = config;
287
+ this.client = new Mailgun(FormData).client({
288
+ ...config.mailgun
289
+ });
290
+ }
291
+ get messages() {
292
+ return this.client.messages;
293
+ }
294
+ get clientUrl() {
295
+ return this.config.clientUrl;
296
+ }
297
+ get domain() {
298
+ return this.config.domain;
299
+ }
300
+ get sender() {
301
+ return this.config.sender;
302
+ }
303
+ };
304
+ MailgunApi = __decorate([
305
+ Injectable(),
306
+ __param(0, Inject(MailgunServiceConfig)),
307
+ __metadata("design:paramtypes", [MailgunServiceConfig])
308
+ ], MailgunApi);
309
+
310
+ let MailgunService = class MailgunService {
311
+ _mailgunApi;
312
+ _serverEnvironmentService;
313
+ constructor(mailgunApi, serverEnvironmentService) {
314
+ this._mailgunApi = mailgunApi;
315
+ this._serverEnvironmentService = serverEnvironmentService;
316
+ }
317
+ get mailgunApi() {
318
+ return this._mailgunApi;
319
+ }
320
+ get serverEnvironmentService() {
321
+ return this._serverEnvironmentService;
322
+ }
323
+ async sendTemplateEmail(request) {
324
+ const domain = this.mailgunApi.domain;
325
+ const sender = this.mailgunApi.sender;
326
+ const isTestingEnvironment = this.serverEnvironmentService.isTestingEnv;
327
+ const { recipientVariablePrefix } = this.mailgunApi.config.messages;
328
+ const data = convertMailgunTemplateEmailRequestToMailgunMessageData({ request, defaultSender: sender, recipientVariablePrefix, isTestingEnvironment });
329
+ let result;
330
+ const shouldSend = !isTestingEnvironment || request.sendTestEmails || this.mailgunApi.config.messages.sendTestEmails;
331
+ if (shouldSend) {
332
+ try {
333
+ result = await this.mailgunApi.messages.create(domain, data);
334
+ }
335
+ catch (e) {
336
+ console.error('Failed sending email: ', e);
337
+ throw e;
338
+ }
339
+ }
340
+ else {
341
+ result = {
342
+ status: 200,
343
+ message: 'Success. Env prevented sending email.'
344
+ };
345
+ }
346
+ return result;
347
+ }
348
+ };
349
+ MailgunService = __decorate([
350
+ Injectable(),
351
+ __param(0, Inject(MailgunApi)),
352
+ __param(1, Inject(ServerEnvironmentService)),
353
+ __metadata("design:paramtypes", [MailgunApi, ServerEnvironmentService])
354
+ ], MailgunService);
355
+
356
+ function mailgunServiceConfigFactory(configService, serverEnvironmentService) {
357
+ const isTestingEnv = serverEnvironmentService.isTestingEnv;
358
+ const useSandbox = configService.get('USE_MAILGUN_SANDBOX') === 'true' || isTestingEnv;
359
+ const sendTestEmails = configService.get('MAILGUN_SEND_TEST_EMAILS') === 'true';
360
+ let key = configService.get('MAILGUN_API_KEY');
361
+ let domain = configService.get('MAILGUN_DOMAIN');
362
+ if (useSandbox) {
363
+ key = configService.get('MAILGUN_SANDBOX_API_KEY');
364
+ domain = configService.get('MAILGUN_SANDBOX_DOMAIN');
365
+ if (!key || !domain) {
366
+ throw new Error('USE_MAILGUN_SANDBOX is set to "true" (or current environment is a testing environment), but no environment variables for the sandbox (MAILGUN_SANDBOX_API_KEY, MAILGUN_SANDBOX_DOMAIN) are provided.');
367
+ }
368
+ else if (!serverEnvironmentService.isTestingEnv) {
369
+ console.log('Using Mailgun Sandbox Domain: ', domain);
370
+ }
371
+ }
372
+ else if (!serverEnvironmentService.isTestingEnv) {
373
+ console.log('Using Mailgun Production Domain: ', domain);
374
+ }
375
+ const name = configService.get('MAILGUN_SENDER_NAME');
376
+ const email = configService.get('MAILGUN_SENDER_EMAIL');
377
+ const url = configService.get('MAILGUN_API_URL');
378
+ const recipientVariablePrefix = configService.get('MAILGUN_MESSAGES_RECIPIENT_VARIABLE_PREFIX') ?? undefined;
379
+ if (!email) {
380
+ throw new Error('MAILGUN_SENDER_EMAIL is required but was not configured.');
381
+ }
382
+ else if (!key) {
383
+ throw new Error('MAILGUN_API_KEY (or MAILGUN_SANDBOX_API_KEY for tests) is required but was not configured.');
384
+ }
385
+ else if (!domain) {
386
+ throw new Error('MAILGUN_DOMAIN (or MAILGUN_SANDBOX_DOMAIN for tests) is required but was not configured.');
387
+ }
388
+ const clientUrl = configService.get('CLIENT_APP_URL') ?? domain;
389
+ const config = {
390
+ mailgun: {
391
+ username: configService.get('MAILGUN_USERNAME') ?? 'api',
392
+ key,
393
+ url
394
+ },
395
+ domain,
396
+ clientUrl,
397
+ sender: convertMailgunRecipientToString({
398
+ name,
399
+ email
400
+ }),
401
+ messages: {
402
+ sendTestEmails,
403
+ recipientVariablePrefix
404
+ }
405
+ };
406
+ MailgunServiceConfig.assertValidConfig(config);
407
+ return config;
408
+ }
409
+ let MailgunServiceModule = class MailgunServiceModule {
410
+ };
411
+ MailgunServiceModule = __decorate([
412
+ Module({
413
+ imports: [ConfigModule],
414
+ providers: [
415
+ {
416
+ provide: MailgunServiceConfig,
417
+ inject: [ConfigService, ServerEnvironmentService],
418
+ useFactory: mailgunServiceConfigFactory
419
+ },
420
+ MailgunApi,
421
+ MailgunService
422
+ ],
423
+ exports: [MailgunApi, MailgunService]
424
+ })
425
+ ], MailgunServiceModule);
426
+
427
+ /**
428
+ * The default template subject to use when batch sending emails.
429
+ *
430
+ * This pulls the subject from each recipient's user variables.
431
+ */
432
+ const MAILGUN_BATCH_SEND_RECIPIENT_SUBJECT_TEMPLATE = `%recipient.subject%`;
433
+ /**
434
+ * Creates a composite key from the from/replyTo email addresses used to group MailgunRecipientBatchSendTarget values.
435
+ */
436
+ function mailgunRecipientBatchSendTargetFromReplyToBatchGroupKey(recipient) {
437
+ const fromEmail = (recipient.from?.email ?? '').toLowerCase();
438
+ const replyToEmail = (recipient.replyTo?.email ?? '').toLowerCase();
439
+ return `f:${fromEmail}|r:${replyToEmail}`;
440
+ }
441
+ /**
442
+ * Creates a ExpandMailgunRecipientBatchSendTargetRequestFactory from the input config.
443
+ *
444
+ * @param config
445
+ * @returns
446
+ */
447
+ function expandMailgunRecipientBatchSendTargetRequestFactory(config) {
448
+ const { request: inputBaseRequest, useSubjectFromRecipientUserVariables, allowSingleRecipientBatchSendRequests, recipientVariablesConfig, mailgunRecipientBatchSendTargetEntityKeyRecipientLookup, overrideCarbonCopyVariablesWithCarbonCopyKeyRecipients } = config;
449
+ const defaultSubject = inputBaseRequest.subject;
450
+ if (!defaultSubject && !useSubjectFromRecipientUserVariables) {
451
+ throw new Error('defaultSubject must be set when "useSubjectFromRecipientUserVariables" is false');
452
+ }
453
+ /**
454
+ * Returns the carbon copy recipients, based on the input.
455
+ *
456
+ * Will return undefined if the array would be empty.
457
+ *
458
+ * @param input
459
+ * @returns
460
+ */
461
+ function determineCarbonCopyRecipients(input) {
462
+ const { baseRequestCarbonCopyRecipients, carbonCopyRecipients, carbonCopyRecipientsKeys } = input;
463
+ let cc = carbonCopyRecipients ? asArray(carbonCopyRecipients) : baseRequestCarbonCopyRecipients;
464
+ const resolvedCc = mailgunRecipientBatchSendTargetEntityKeyRecipientLookup?.getRecipientsForKeys(carbonCopyRecipientsKeys);
465
+ if (resolvedCc?.length) {
466
+ if (overrideCarbonCopyVariablesWithCarbonCopyKeyRecipients) {
467
+ cc = resolvedCc;
468
+ }
469
+ else {
470
+ cc = [...(cc ?? []), ...resolvedCc];
471
+ }
472
+ }
473
+ return cc?.length ? cc : undefined;
474
+ }
475
+ const baseRequestCc = determineCarbonCopyRecipients({
476
+ carbonCopyRecipients: inputBaseRequest.cc,
477
+ carbonCopyRecipientsKeys: inputBaseRequest.ccKeys
478
+ });
479
+ const baseRequestBcc = determineCarbonCopyRecipients({
480
+ carbonCopyRecipients: inputBaseRequest.bcc,
481
+ carbonCopyRecipientsKeys: inputBaseRequest.bccKeys
482
+ });
483
+ const baseRequestFrom = inputBaseRequest.from ?? mailgunRecipientBatchSendTargetEntityKeyRecipientLookup?.getRecipientOrDefaultForKey(inputBaseRequest.fromKey);
484
+ const baseRequestReplyTo = inputBaseRequest.replyTo ?? mailgunRecipientBatchSendTargetEntityKeyRecipientLookup?.getRecipientOrDefaultForKey(inputBaseRequest.replyToKey);
485
+ const baseRequest = {
486
+ ...inputBaseRequest,
487
+ from: baseRequestFrom,
488
+ replyTo: baseRequestReplyTo,
489
+ cc: baseRequestCc,
490
+ bcc: baseRequestBcc
491
+ };
492
+ delete baseRequest.fromKey;
493
+ delete baseRequest.replyToKey;
494
+ delete baseRequest.ccKeys;
495
+ delete baseRequest.bccKeys;
496
+ const configAllowBatchSend = baseRequest.batchSend !== false;
497
+ return (inputRecipients) => {
498
+ // Process recipients to resolve keys
499
+ const recipients = inputRecipients.map((recipient) => {
500
+ let from = recipient.from;
501
+ let replyTo = recipient.replyTo;
502
+ if (mailgunRecipientBatchSendTargetEntityKeyRecipientLookup) {
503
+ // try the fromKey, otherwise use the baseRequest.from
504
+ if (!from) {
505
+ from = mailgunRecipientBatchSendTargetEntityKeyRecipientLookup.getRecipientOrDefaultForKey(recipient.fromKey, baseRequest.from);
506
+ }
507
+ // try the replyToKey, otherwise use the baseRequest.replyTo
508
+ if (!replyTo) {
509
+ replyTo = mailgunRecipientBatchSendTargetEntityKeyRecipientLookup.getRecipientOrDefaultForKey(recipient.replyToKey, baseRequest.replyTo);
510
+ }
511
+ }
512
+ else {
513
+ // use defaults from base request
514
+ if (!from) {
515
+ from = baseRequest.from;
516
+ }
517
+ if (!replyTo) {
518
+ replyTo = baseRequest.replyTo;
519
+ }
520
+ }
521
+ const cc = determineCarbonCopyRecipients({
522
+ baseRequestCarbonCopyRecipients: baseRequestCc,
523
+ carbonCopyRecipients: recipient.cc,
524
+ carbonCopyRecipientsKeys: recipient.ccKeys
525
+ });
526
+ const bcc = determineCarbonCopyRecipients({
527
+ baseRequestCarbonCopyRecipients: baseRequestBcc,
528
+ carbonCopyRecipients: recipient.bcc,
529
+ carbonCopyRecipientsKeys: recipient.bccKeys
530
+ });
531
+ const result = {
532
+ ...recipient,
533
+ from,
534
+ replyTo,
535
+ cc,
536
+ bcc
537
+ };
538
+ return result;
539
+ });
540
+ const allowBatchSend = configAllowBatchSend && (allowSingleRecipientBatchSendRequests || recipients.length > 1);
541
+ const nonBatchSendRequests = [];
542
+ const batchSendRequestRecipients = [];
543
+ recipients.forEach((recipient) => {
544
+ const recipientHasCarbonCopy = Boolean(recipient.cc?.length || recipient.bcc?.length);
545
+ if (allowBatchSend && !recipientHasCarbonCopy) {
546
+ // add to batch send recipients
547
+ batchSendRequestRecipients.push(recipient);
548
+ }
549
+ else {
550
+ // add to non-batch send requests
551
+ // use the subject from the recipient's user variables if available as a default
552
+ const cc = recipient.cc;
553
+ const bcc = recipient.bcc;
554
+ const subject = (useSubjectFromRecipientUserVariables ? recipient.userVariables?.['subject'] : undefined) ?? defaultSubject ?? recipient.userVariables?.['subject'];
555
+ const request = {
556
+ ...baseRequest,
557
+ from: recipient.from ?? baseRequest.from,
558
+ replyTo: recipient.replyTo ?? baseRequest.replyTo,
559
+ recipientVariablesConfig: baseRequest.recipientVariablesConfig ?? recipientVariablesConfig,
560
+ to: recipient,
561
+ cc,
562
+ bcc,
563
+ subject,
564
+ batchSend: false // explicitly disable batch send for non-batch requests
565
+ };
566
+ nonBatchSendRequests.push(request);
567
+ }
568
+ });
569
+ // create batch send request(s)
570
+ const batchSendRequests = [];
571
+ if (batchSendRequestRecipients.length > 0) {
572
+ const subject = useSubjectFromRecipientUserVariables ? MAILGUN_BATCH_SEND_RECIPIENT_SUBJECT_TEMPLATE : defaultSubject;
573
+ // Group recipients by their from/replyTo values
574
+ const batchSendRecipientGroups = makeValuesGroupMap(batchSendRequestRecipients, mailgunRecipientBatchSendTargetFromReplyToBatchGroupKey);
575
+ batchSendRecipientGroups.forEach((groupRecipients) => {
576
+ // All recipients in this group should share the same from/replyTo values
577
+ const firstRecipient = groupRecipients[0];
578
+ const batchRequest = {
579
+ ...baseRequest,
580
+ from: firstRecipient.from,
581
+ replyTo: firstRecipient.replyTo,
582
+ recipientVariablesConfig: baseRequest.recipientVariablesConfig ?? recipientVariablesConfig,
583
+ to: groupRecipients,
584
+ subject,
585
+ batchSend: true
586
+ };
587
+ batchSendRequests.push(batchRequest);
588
+ });
589
+ }
590
+ return filterMaybeArrayValues([...batchSendRequests, ...nonBatchSendRequests]);
591
+ };
592
+ }
593
+ /**
594
+ * Creates a MailgunRecipientBatchSendTargetEntityKeyRecipientLookup given the input configuration.
595
+ *
596
+ * @param config The configuration for the lookup.
597
+ * @returns The lookup.
598
+ */
599
+ function mailgunRecipientBatchSendTargetEntityKeyRecipientLookup(config) {
600
+ const { recipientsMap } = config;
601
+ function getRecipientOrDefaultForKey(input, defaultRecipient) {
602
+ let result = defaultRecipient;
603
+ if (input) {
604
+ result = recipientsMap.get(input) ?? defaultRecipient;
605
+ }
606
+ return result;
607
+ }
608
+ function getRecipientsForKeys(input) {
609
+ let result = undefined;
610
+ if (input) {
611
+ const keysArray = asArray(input);
612
+ const recipients = filterMaybeArrayValues(keysArray.map((key) => recipientsMap.get(key)));
613
+ if (recipients.length > 0) {
614
+ result = recipients;
615
+ }
616
+ }
617
+ return result;
618
+ }
619
+ return {
620
+ recipientsMap,
621
+ getRecipientOrDefaultForKey,
622
+ getRecipientsForKeys
623
+ };
624
+ }
625
+
626
+ export { DEFAULT_RECIPIENT_VARIABLE_PREFIX, MAILGUN_BATCH_SEND_RECIPIENT_SUBJECT_TEMPLATE, MAILGUN_REPLY_TO_EMAIL_HEADER_DATA_VARIABLE_KEY, MAX_BATCH_SEND_RECIPIENTS, MailgunApi, MailgunService, MailgunServiceModule, convertMailgunRecipientToString, convertMailgunRecipientsToStrings, convertMailgunTemplateEmailRequestToMailgunMessageData, encodeMailgunTemplateVariableValue, expandMailgunRecipientBatchSendTargetRequestFactory, mailgunRecipientBatchSendTargetEntityKeyRecipientLookup, mailgunRecipientBatchSendTargetFromReplyToBatchGroupKey, mailgunServiceConfigFactory };
@@ -1,7 +1,27 @@
1
1
  {
2
2
  "name": "@dereekb/nestjs/mailgun",
3
- "version": "12.7.0",
4
- "type": "commonjs",
5
- "types": "./src/index.d.ts",
6
- "main": "./src/index.js"
3
+ "version": "13.0.1",
4
+ "peerDependencies": {
5
+ "@dereekb/date": "13.0.1",
6
+ "@dereekb/model": "13.0.1",
7
+ "@dereekb/nestjs": "13.0.1",
8
+ "@dereekb/rxjs": "13.0.1",
9
+ "@dereekb/util": "13.0.1",
10
+ "@nestjs/common": "^11.0.0",
11
+ "@nestjs/config": "^4.0.0",
12
+ "form-data": "^4.0.0",
13
+ "mailgun.js": "^12.0.0"
14
+ },
15
+ "exports": {
16
+ "./package.json": "./package.json",
17
+ ".": {
18
+ "module": "./index.esm.js",
19
+ "types": "./index.d.ts",
20
+ "import": "./index.cjs.mjs",
21
+ "default": "./index.cjs.js"
22
+ }
23
+ },
24
+ "module": "./index.esm.js",
25
+ "main": "./index.cjs.js",
26
+ "types": "./index.d.ts"
7
27
  }
@@ -1,6 +1,6 @@
1
1
  import { type ArrayOrValue, type EmailAddress, type EmailAddressDomain, type NameEmailPair, type EmailParticipantString, type Maybe } from '@dereekb/util';
2
- import { type APIResponse } from 'mailgun.js/Types/Common/ApiResponse';
3
- import { type CustomFileData, type MailgunMessageData, type MessagesSendResult } from 'mailgun.js/Types/Messages/Messages';
2
+ import { type CustomFileData, type MailgunMessageData, type MessagesSendResult } from 'node_modules/mailgun.js/Types/Types/Messages/Messages';
3
+ import { type APIResponse } from 'node_modules/mailgun.js/Types/Types/Common/ApiResponse';
4
4
  export type MailgunSenderDomainString = EmailAddressDomain;
5
5
  export type MailgunTemplateKey = string;
6
6
  /**
@@ -1,5 +1,5 @@
1
1
  import type Mailgun from 'mailgun.js';
2
- import { type MailgunClientOptions } from 'mailgun.js/Types/MailgunClient/MailgunClientOptions';
2
+ import { type MailgunClientOptions } from 'node_modules/mailgun.js/Types/Types/MailgunClient/MailgunClientOptions';
3
3
  export type MailgunOptions = MailgunClientOptions;
4
4
  export type MailgunClient = ReturnType<Mailgun['client']>;
5
5
  export type MailgunMessagesClient = ReturnType<Mailgun['client']>['messages'];