@sqrzro/server 4.0.0-alpha.63 → 4.0.0-alpha.64

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 (252) hide show
  1. package/dist/csv/generate-csv-blob.d.ts +3 -0
  2. package/dist/csv/generate-csv-blob.d.ts.map +1 -0
  3. package/dist/csv/generate-csv-blob.js +5 -0
  4. package/dist/csv/generate-csv.d.ts +3 -0
  5. package/dist/csv/generate-csv.d.ts.map +1 -0
  6. package/dist/csv/generate-csv.js +5 -0
  7. package/dist/csv/index.d.ts +4 -7
  8. package/dist/csv/index.d.ts.map +1 -0
  9. package/dist/csv/index.js +3 -2
  10. package/dist/csv/parse-csv.d.ts +3 -0
  11. package/dist/csv/parse-csv.d.ts.map +1 -0
  12. package/dist/csv/parse-csv.js +13 -0
  13. package/dist/database/create-repository.d.ts +41 -0
  14. package/dist/database/create-repository.d.ts.map +1 -0
  15. package/dist/database/create-repository.js +207 -0
  16. package/dist/database/db.d.ts +6 -0
  17. package/dist/database/db.d.ts.map +1 -0
  18. package/dist/database/db.js +7 -0
  19. package/dist/database/index.d.ts +5 -99
  20. package/dist/database/index.d.ts.map +1 -0
  21. package/dist/database/index.js +2 -2
  22. package/dist/database/interfaces.d.ts +52 -0
  23. package/dist/database/interfaces.d.ts.map +1 -0
  24. package/dist/database/interfaces.js +1 -0
  25. package/dist/forms/ValidationError.d.ts +12 -0
  26. package/dist/forms/ValidationError.d.ts.map +1 -0
  27. package/dist/forms/ValidationError.js +15 -0
  28. package/dist/forms/create-rule.d.ts +8 -0
  29. package/dist/forms/create-rule.d.ts.map +1 -0
  30. package/dist/forms/create-rule.js +4 -0
  31. package/dist/forms/files/put-file.d.ts +3 -0
  32. package/dist/forms/files/put-file.d.ts.map +1 -0
  33. package/dist/forms/files/put-file.js +9 -0
  34. package/dist/forms/files/upload-file.d.ts +4 -0
  35. package/dist/forms/files/upload-file.d.ts.map +1 -0
  36. package/dist/forms/files/upload-file.js +14 -0
  37. package/dist/forms/index.d.ts +13 -67
  38. package/dist/forms/index.d.ts.map +1 -0
  39. package/dist/forms/index.js +11 -2
  40. package/dist/forms/preprocesses/alpha.d.ts +3 -0
  41. package/dist/forms/preprocesses/alpha.d.ts.map +1 -0
  42. package/dist/forms/preprocesses/alpha.js +7 -0
  43. package/dist/forms/preprocesses/alphanumeric.d.ts +3 -0
  44. package/dist/forms/preprocesses/alphanumeric.d.ts.map +1 -0
  45. package/dist/forms/preprocesses/alphanumeric.js +7 -0
  46. package/dist/forms/preprocesses/lowercase.d.ts +1 -0
  47. package/dist/forms/preprocesses/lowercase.d.ts.map +1 -0
  48. package/dist/forms/preprocesses/lowercase.js +1 -0
  49. package/dist/forms/preprocesses/numeric.d.ts +1 -0
  50. package/dist/forms/preprocesses/numeric.d.ts.map +1 -0
  51. package/dist/forms/preprocesses/numeric.js +1 -0
  52. package/dist/forms/preprocesses/uppercase.d.ts +1 -0
  53. package/dist/forms/preprocesses/uppercase.d.ts.map +1 -0
  54. package/dist/forms/preprocesses/uppercase.js +1 -0
  55. package/dist/forms/refiner/get-not-exists-refiner.d.ts +9 -0
  56. package/dist/forms/refiner/get-not-exists-refiner.d.ts.map +1 -0
  57. package/dist/forms/refiner/get-not-exists-refiner.js +13 -0
  58. package/dist/forms/rules/get-csv-rule.d.ts +4 -0
  59. package/dist/forms/rules/get-csv-rule.d.ts.map +1 -0
  60. package/dist/forms/rules/get-csv-rule.js +8 -0
  61. package/dist/forms/rules/get-phone-rule.d.ts +9 -0
  62. package/dist/forms/rules/get-phone-rule.d.ts.map +1 -0
  63. package/dist/forms/rules/get-phone-rule.js +15 -0
  64. package/dist/forms/submit-form.d.ts +19 -0
  65. package/dist/forms/submit-form.d.ts.map +1 -0
  66. package/dist/forms/submit-form.js +33 -0
  67. package/dist/forms/transformers/get-exists-transformer.d.ts +3 -0
  68. package/dist/forms/transformers/get-exists-transformer.d.ts.map +1 -0
  69. package/dist/forms/transformers/get-exists-transformer.js +9 -0
  70. package/dist/forms/utility/clean-data.d.ts +3 -0
  71. package/dist/forms/utility/clean-data.d.ts.map +1 -0
  72. package/dist/forms/utility/clean-data.js +18 -0
  73. package/dist/forms/utility/handle-redirect.d.ts +3 -0
  74. package/dist/forms/utility/handle-redirect.d.ts.map +1 -0
  75. package/dist/forms/utility/handle-redirect.js +7 -0
  76. package/dist/forms/utility/interfaces.d.ts +12 -0
  77. package/dist/forms/utility/interfaces.d.ts.map +1 -0
  78. package/dist/forms/utility/interfaces.js +1 -0
  79. package/dist/forms/utility/transform-errors.d.ts +4 -0
  80. package/dist/forms/utility/transform-errors.d.ts.map +1 -0
  81. package/dist/forms/utility/transform-errors.js +7 -0
  82. package/dist/forms/utility/transform-file-path.d.ts +3 -0
  83. package/dist/forms/utility/transform-file-path.d.ts.map +1 -0
  84. package/dist/forms/utility/transform-file-path.js +9 -0
  85. package/dist/forms/utility/transform-issue.d.ts +6 -0
  86. package/dist/forms/utility/transform-issue.d.ts.map +1 -0
  87. package/dist/forms/utility/transform-issue.js +17 -0
  88. package/dist/forms/validate-schema.d.ts +4 -0
  89. package/dist/forms/validate-schema.d.ts.map +1 -0
  90. package/dist/forms/validate-schema.js +20 -0
  91. package/dist/forms/validators/get-exists-validator.d.ts +5 -0
  92. package/dist/forms/validators/get-exists-validator.d.ts.map +1 -0
  93. package/dist/forms/validators/get-exists-validator.js +10 -0
  94. package/dist/forms/validators/get-not-exists-validator.d.ts +5 -0
  95. package/dist/forms/validators/get-not-exists-validator.d.ts.map +1 -0
  96. package/dist/forms/validators/get-not-exists-validator.js +10 -0
  97. package/dist/index.d.ts +3 -0
  98. package/dist/index.d.ts.map +1 -0
  99. package/dist/index.js +1 -0
  100. package/dist/json/index.d.ts +3 -7
  101. package/dist/json/index.d.ts.map +1 -0
  102. package/dist/json/index.js +2 -2
  103. package/dist/json/validate-json-response.d.ts +4 -0
  104. package/dist/json/validate-json-response.d.ts.map +1 -0
  105. package/dist/json/validate-json-response.js +7 -0
  106. package/dist/json/validate-json.d.ts +4 -0
  107. package/dist/json/validate-json.d.ts.map +1 -0
  108. package/dist/json/validate-json.js +4 -0
  109. package/dist/logs/LogRepository.d.ts +1 -0
  110. package/dist/logs/LogRepository.d.ts.map +1 -0
  111. package/dist/logs/LogRepository.js +1 -0
  112. package/dist/logs/index.d.ts +1 -0
  113. package/dist/logs/index.d.ts.map +1 -0
  114. package/dist/logs/index.js +1 -0
  115. package/dist/logs/log.d.ts +1 -0
  116. package/dist/logs/log.d.ts.map +1 -0
  117. package/dist/logs/log.js +1 -0
  118. package/dist/logs/utility/interfaces.d.ts +1 -0
  119. package/dist/logs/utility/interfaces.d.ts.map +1 -0
  120. package/dist/logs/utility/interfaces.js +1 -0
  121. package/dist/logs/utility/schema.d.ts +1 -0
  122. package/dist/logs/utility/schema.d.ts.map +1 -0
  123. package/dist/logs/utility/schema.js +1 -0
  124. package/dist/mail/create-mail.d.ts +4 -0
  125. package/dist/mail/create-mail.d.ts.map +1 -0
  126. package/dist/mail/create-mail.js +4 -0
  127. package/dist/mail/drivers/mailgun/index.d.ts +4 -0
  128. package/dist/mail/drivers/mailgun/index.d.ts.map +1 -0
  129. package/dist/mail/drivers/mailgun/index.js +24 -0
  130. package/dist/mail/drivers/mailgun/transform-mailgun-domain.d.ts +3 -0
  131. package/dist/mail/drivers/mailgun/transform-mailgun-domain.d.ts.map +1 -0
  132. package/dist/mail/drivers/mailgun/transform-mailgun-domain.js +4 -0
  133. package/dist/mail/drivers/mailtrap/index.d.ts +4 -0
  134. package/dist/mail/drivers/mailtrap/index.d.ts.map +1 -0
  135. package/dist/mail/drivers/mailtrap/index.js +31 -0
  136. package/dist/mail/drivers/mailtrap/transform-mailtrap-recipients.d.ts +5 -0
  137. package/dist/mail/drivers/mailtrap/transform-mailtrap-recipients.d.ts.map +1 -0
  138. package/dist/mail/drivers/mailtrap/transform-mailtrap-recipients.js +7 -0
  139. package/dist/mail/drivers/mandrill/index.d.ts +4 -0
  140. package/dist/mail/drivers/mandrill/index.d.ts.map +1 -0
  141. package/dist/mail/drivers/mandrill/index.js +34 -0
  142. package/dist/mail/drivers/mandrill/transform-mandrill-recipients.d.ts +6 -0
  143. package/dist/mail/drivers/mandrill/transform-mandrill-recipients.d.ts.map +1 -0
  144. package/dist/mail/drivers/mandrill/transform-mandrill-recipients.js +14 -0
  145. package/dist/mail/drivers/sendgrid/index.d.ts +4 -0
  146. package/dist/mail/drivers/sendgrid/index.d.ts.map +1 -0
  147. package/dist/mail/drivers/sendgrid/index.js +23 -0
  148. package/dist/mail/drivers/sendgrid/transform-sendgrid-recipients.d.ts +5 -0
  149. package/dist/mail/drivers/sendgrid/transform-sendgrid-recipients.d.ts.map +1 -0
  150. package/dist/mail/drivers/sendgrid/transform-sendgrid-recipients.js +7 -0
  151. package/dist/mail/get-mail.d.ts +7 -0
  152. package/dist/mail/get-mail.d.ts.map +1 -0
  153. package/dist/mail/get-mail.js +12 -0
  154. package/dist/mail/index.d.ts +5 -25
  155. package/dist/mail/index.d.ts.map +1 -0
  156. package/dist/mail/index.js +3 -3
  157. package/dist/mail/send-mail.d.ts +4 -0
  158. package/dist/mail/send-mail.d.ts.map +1 -0
  159. package/dist/mail/send-mail.js +45 -0
  160. package/dist/mail/utility/get-sender-details.d.ts +4 -0
  161. package/dist/mail/utility/get-sender-details.d.ts.map +1 -0
  162. package/dist/mail/utility/get-sender-details.js +15 -0
  163. package/dist/mail/utility/interfaces.d.ts +34 -0
  164. package/dist/mail/utility/interfaces.d.ts.map +1 -0
  165. package/dist/mail/utility/interfaces.js +1 -0
  166. package/dist/mail/utility/render-mail.d.ts +3 -0
  167. package/dist/mail/utility/render-mail.d.ts.map +1 -0
  168. package/dist/mail/utility/render-mail.js +20 -0
  169. package/dist/proxy/handle-proxy.d.ts +5 -0
  170. package/dist/proxy/handle-proxy.d.ts.map +1 -0
  171. package/dist/proxy/handle-proxy.js +17 -0
  172. package/dist/proxy/index.d.ts +3 -10
  173. package/dist/proxy/index.d.ts.map +1 -0
  174. package/dist/proxy/index.js +1 -2
  175. package/dist/proxy/utility/interfaces.d.ts +6 -0
  176. package/dist/proxy/utility/interfaces.d.ts.map +1 -0
  177. package/dist/proxy/utility/interfaces.js +1 -0
  178. package/dist/queue/add-to-queue.d.ts +3 -0
  179. package/dist/queue/add-to-queue.d.ts.map +1 -0
  180. package/dist/queue/add-to-queue.js +2 -0
  181. package/dist/queue/drivers/mail-queue-driver.d.ts +1 -0
  182. package/dist/queue/drivers/mail-queue-driver.d.ts.map +1 -0
  183. package/dist/queue/drivers/mail-queue-driver.js +1 -0
  184. package/dist/queue/handle-queue.d.ts +4 -0
  185. package/dist/queue/handle-queue.d.ts.map +1 -0
  186. package/dist/queue/handle-queue.js +2 -0
  187. package/dist/queue/index.d.ts +3 -0
  188. package/dist/queue/index.d.ts.map +1 -0
  189. package/dist/queue/index.js +2 -0
  190. package/dist/queue/utility/interfaces.d.ts +1 -0
  191. package/dist/queue/utility/interfaces.d.ts.map +1 -0
  192. package/dist/queue/utility/interfaces.js +1 -0
  193. package/dist/storage/index.d.ts +2 -2
  194. package/dist/storage/index.d.ts.map +1 -0
  195. package/dist/storage/index.js +66 -2
  196. package/dist/storage/utility/get-client.d.ts +10 -0
  197. package/dist/storage/utility/get-client.d.ts.map +1 -0
  198. package/dist/storage/utility/get-client.js +22 -0
  199. package/dist/storage/utility/get-ttl.d.ts +3 -0
  200. package/dist/storage/utility/get-ttl.d.ts.map +1 -0
  201. package/dist/storage/utility/get-ttl.js +15 -0
  202. package/dist/storage/utility/is-localhost.d.ts +8 -0
  203. package/dist/storage/utility/is-localhost.d.ts.map +1 -0
  204. package/dist/storage/utility/is-localhost.js +9 -0
  205. package/dist/storage/utility/make-key.d.ts +3 -0
  206. package/dist/storage/utility/make-key.d.ts.map +1 -0
  207. package/dist/storage/utility/make-key.js +4 -0
  208. package/dist/utility/db.d.ts +5 -0
  209. package/dist/utility/db.d.ts.map +1 -0
  210. package/dist/utility/db.js +2 -0
  211. package/dist/utility/ensure-id-from-params.d.ts +3 -0
  212. package/dist/utility/ensure-id-from-params.d.ts.map +1 -0
  213. package/dist/utility/ensure-id-from-params.js +7 -0
  214. package/dist/utility/ensure-id.d.ts +3 -0
  215. package/dist/utility/ensure-id.d.ts.map +1 -0
  216. package/dist/utility/ensure-id.js +9 -0
  217. package/dist/utility/generate-id.d.ts +3 -0
  218. package/dist/utility/generate-id.d.ts.map +1 -0
  219. package/dist/utility/generate-id.js +12 -0
  220. package/dist/utility/get-id-from-params.d.ts +3 -0
  221. package/dist/utility/get-id-from-params.d.ts.map +1 -0
  222. package/dist/utility/get-id-from-params.js +18 -0
  223. package/dist/utility/guard-id.d.ts +4 -0
  224. package/dist/utility/guard-id.d.ts.map +1 -0
  225. package/dist/utility/guard-id.js +11 -0
  226. package/dist/utility/index.d.ts +7 -14
  227. package/dist/utility/index.d.ts.map +1 -0
  228. package/dist/utility/index.js +6 -2
  229. package/dist/{interfaces-DTUqy5Oj.d.ts → utility/interfaces.d.ts} +4 -5
  230. package/dist/utility/interfaces.d.ts.map +1 -0
  231. package/dist/utility/interfaces.js +1 -0
  232. package/dist/utility/syslog.d.ts +3 -0
  233. package/dist/utility/syslog.d.ts.map +1 -0
  234. package/dist/utility/syslog.js +16 -0
  235. package/package.json +11 -11
  236. package/dist/chunk-2ZLU4AUD.js +0 -2
  237. package/dist/chunk-2ZLU4AUD.js.map +0 -1
  238. package/dist/chunk-6GDOIHTS.js +0 -2
  239. package/dist/chunk-6GDOIHTS.js.map +0 -1
  240. package/dist/chunk-BA3BC4CD.js +0 -2
  241. package/dist/chunk-BA3BC4CD.js.map +0 -1
  242. package/dist/chunk-UCMLSO7F.js +0 -3
  243. package/dist/chunk-UCMLSO7F.js.map +0 -1
  244. package/dist/csv/index.js.map +0 -1
  245. package/dist/database/index.js.map +0 -1
  246. package/dist/forms/index.js.map +0 -1
  247. package/dist/interfaces-cnzok1wV.d.ts +0 -13
  248. package/dist/json/index.js.map +0 -1
  249. package/dist/mail/index.js.map +0 -1
  250. package/dist/proxy/index.js.map +0 -1
  251. package/dist/storage/index.js.map +0 -1
  252. package/dist/utility/index.js.map +0 -1
@@ -0,0 +1,7 @@
1
+ import validateJson from './validate-json';
2
+ async function validateJsonResponse(query, schema) {
3
+ const response = await query;
4
+ const data = await response.json();
5
+ return validateJson(data, schema);
6
+ }
7
+ export default validateJsonResponse;
@@ -0,0 +1,4 @@
1
+ import type { z } from 'zod';
2
+ declare function validateJson<T extends z.ZodType>(data: unknown, schema: T): z.infer<T>;
3
+ export default validateJson;
4
+ //# sourceMappingURL=validate-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-json.d.ts","sourceRoot":"","sources":["../../src/json/validate-json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,iBAAS,YAAY,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAE/E;eAEc,YAAY"}
@@ -0,0 +1,4 @@
1
+ function validateJson(data, schema) {
2
+ return schema.parse(data);
3
+ }
4
+ export default validateJson;
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=LogRepository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LogRepository.d.ts","sourceRoot":"","sources":["../../src/logs/LogRepository.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logs/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/logs/log.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/logs/utility/interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/logs/utility/schema.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,4 @@
1
+ import type { MailObject } from './utility/interfaces';
2
+ declare function createMail<T extends object>(subject: string | ((data: T) => Promise<string> | string), template: (data: T) => Promise<React.ReactElement> | React.ReactElement): MailObject<T>;
3
+ export default createMail;
4
+ //# sourceMappingURL=create-mail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-mail.d.ts","sourceRoot":"","sources":["../../src/mail/create-mail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,iBAAS,UAAU,CAAC,CAAC,SAAS,MAAM,EAChC,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,EACzD,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,YAAY,GACxE,UAAU,CAAC,CAAC,CAAC,CAEf;eAEc,UAAU"}
@@ -0,0 +1,4 @@
1
+ function createMail(subject, template) {
2
+ return { subject, template };
3
+ }
4
+ export default createMail;
@@ -0,0 +1,4 @@
1
+ import type { SendableMailObject } from '../../utility/interfaces';
2
+ declare function sendMailgunMail(sendObject: SendableMailObject): Promise<boolean>;
3
+ export default sendMailgunMail;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mail/drivers/mailgun/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAMnE,iBAAe,eAAe,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAqB/E;eAEc,eAAe"}
@@ -0,0 +1,24 @@
1
+ import formData from 'form-data';
2
+ import Mailgun from 'mailgun.js';
3
+ import transformMailgunDomain from './transform-mailgun-domain';
4
+ const mg = new Mailgun(formData);
5
+ async function sendMailgunMail(sendObject) {
6
+ if (!process.env.MAIL_API_KEY) {
7
+ throw new Error('Could not send mail via Mailgun. Mail API key has not been set.');
8
+ }
9
+ const client = mg.client({
10
+ key: process.env.MAIL_API_KEY,
11
+ url: 'https://api.eu.mailgun.net/',
12
+ username: 'api',
13
+ });
14
+ const response = await client.messages.create(transformMailgunDomain(sendObject.from.email), {
15
+ bcc: sendObject.bcc,
16
+ cc: sendObject.cc,
17
+ from: sendObject.from.raw,
18
+ html: sendObject.html,
19
+ subject: sendObject.subject,
20
+ to: sendObject.to,
21
+ });
22
+ return response.status === 200;
23
+ }
24
+ export default sendMailgunMail;
@@ -0,0 +1,3 @@
1
+ declare function transformMailgunDomain(email: string): string;
2
+ export default transformMailgunDomain;
3
+ //# sourceMappingURL=transform-mailgun-domain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-mailgun-domain.d.ts","sourceRoot":"","sources":["../../../../src/mail/drivers/mailgun/transform-mailgun-domain.ts"],"names":[],"mappings":"AAAA,iBAAS,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErD;eAEc,sBAAsB"}
@@ -0,0 +1,4 @@
1
+ function transformMailgunDomain(email) {
2
+ return email.split('@')[1];
3
+ }
4
+ export default transformMailgunDomain;
@@ -0,0 +1,4 @@
1
+ import type { SendableMailObject } from '../../utility/interfaces';
2
+ declare function sendMailtrapMail(sendObject: SendableMailObject): Promise<boolean>;
3
+ export default sendMailtrapMail;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mail/drivers/mailtrap/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAInE,iBAAe,gBAAgB,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAiChF;eAEc,gBAAgB"}
@@ -0,0 +1,31 @@
1
+ import { pick } from '@sqrzro/utility';
2
+ import transformMailtrapRecipients from './transform-mailtrap-recipients';
3
+ async function sendMailtrapMail(sendObject) {
4
+ if (!process.env.MAIL_API_KEY) {
5
+ throw new Error('Could not send mail via Mailtrap. Mail API key has not been set.');
6
+ }
7
+ /*
8
+ * The account id and api key are both in the MAIL_API_KEY variable, separated by a `.`. We need
9
+ * to split them.
10
+ */
11
+ const [id, key] = process.env.MAIL_API_KEY.split('.');
12
+ const response = await fetch(`https://sandbox.api.mailtrap.io/api/send/${id}`, {
13
+ method: 'POST',
14
+ headers: { 'Api-Token': key, 'Content-Type': 'application/json' },
15
+ body: JSON.stringify({
16
+ attachments: sendObject.attachments,
17
+ bcc: transformMailtrapRecipients(sendObject.bcc),
18
+ cc: transformMailtrapRecipients(sendObject.cc),
19
+ from: pick(sendObject.from, ['email', 'name']),
20
+ html: sendObject.html,
21
+ subject: sendObject.subject,
22
+ to: transformMailtrapRecipients(sendObject.to),
23
+ }),
24
+ });
25
+ const json = (await response.json());
26
+ if (json.errors) {
27
+ throw new Error(`Could not send mail via Mailtrap. ${json.errors[0]}.`);
28
+ }
29
+ return true;
30
+ }
31
+ export default sendMailtrapMail;
@@ -0,0 +1,5 @@
1
+ declare function transformMailtrapRecipients(emails?: string[] | string): {
2
+ email: string;
3
+ }[];
4
+ export default transformMailtrapRecipients;
5
+ //# sourceMappingURL=transform-mailtrap-recipients.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-mailtrap-recipients.d.ts","sourceRoot":"","sources":["../../../../src/mail/drivers/mailtrap/transform-mailtrap-recipients.ts"],"names":[],"mappings":"AAAA,iBAAS,2BAA2B,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,CAKpF;eAEc,2BAA2B"}
@@ -0,0 +1,7 @@
1
+ function transformMailtrapRecipients(emails) {
2
+ if (!emails) {
3
+ return [];
4
+ }
5
+ return Array.isArray(emails) ? emails.map((email) => ({ email })) : [{ email: emails }];
6
+ }
7
+ export default transformMailtrapRecipients;
@@ -0,0 +1,4 @@
1
+ import type { SendableMailObject } from '../../utility/interfaces';
2
+ declare function sendMandrillMail(sendObject: SendableMailObject): Promise<boolean>;
3
+ export default sendMandrillMail;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mail/drivers/mandrill/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAQnE,iBAAe,gBAAgB,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAoChF;eAEc,gBAAgB"}
@@ -0,0 +1,34 @@
1
+ import transformMandrillRecipients from './transform-mandrill-recipients';
2
+ async function sendMandrillMail(sendObject) {
3
+ if (!process.env.MAIL_API_KEY) {
4
+ throw new Error('Could not send mail via Mandrill. Mail API key has not been set.');
5
+ }
6
+ const attachments = sendObject.attachments?.map((attachment) => ({
7
+ content: attachment.content,
8
+ name: attachment.filename,
9
+ type: attachment.type,
10
+ }));
11
+ /* eslint-disable camelcase */
12
+ const message = {
13
+ attachments,
14
+ from_email: sendObject.from.email,
15
+ from_name: sendObject.from.name,
16
+ html: sendObject.html,
17
+ subject: sendObject.subject,
18
+ preserve_recipients: true,
19
+ to: transformMandrillRecipients(sendObject.to, sendObject.cc, sendObject.bcc),
20
+ };
21
+ /* eslint-enable camelcase */
22
+ const response = await fetch('https://mandrillapp.com/api/1.0/messages/send', {
23
+ method: 'POST',
24
+ body: JSON.stringify({
25
+ key: process.env.MAIL_API_KEY,
26
+ message,
27
+ }),
28
+ });
29
+ const json = (await response.json());
30
+ return Array.isArray(json)
31
+ ? json.every((item) => item.status === 'sent')
32
+ : json.status === 'sent';
33
+ }
34
+ export default sendMandrillMail;
@@ -0,0 +1,6 @@
1
+ declare function transformMandrillRecipients(to: string[] | string, cc?: string[] | string, bcc?: string[] | string): {
2
+ email: string;
3
+ type: 'bcc' | 'cc' | 'to';
4
+ }[];
5
+ export default transformMandrillRecipients;
6
+ //# sourceMappingURL=transform-mandrill-recipients.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-mandrill-recipients.d.ts","sourceRoot":"","sources":["../../../../src/mail/drivers/mandrill/transform-mandrill-recipients.ts"],"names":[],"mappings":"AAUA,iBAAS,2BAA2B,CAChC,EAAE,EAAE,MAAM,EAAE,GAAG,MAAM,EACrB,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EACtB,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,GACxB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI,CAAA;CAAE,EAAE,CAMhD;eAEc,2BAA2B"}
@@ -0,0 +1,14 @@
1
+ function transformMandrillRecipientGroup(group, type) {
2
+ if (Array.isArray(group)) {
3
+ return group.map((email) => ({ email, type }));
4
+ }
5
+ return [{ email: group, type }];
6
+ }
7
+ function transformMandrillRecipients(to, cc, bcc) {
8
+ return [
9
+ ...transformMandrillRecipientGroup(to, 'to'),
10
+ ...transformMandrillRecipientGroup(cc || [], 'cc'),
11
+ ...transformMandrillRecipientGroup(bcc || [], 'bcc'),
12
+ ];
13
+ }
14
+ export default transformMandrillRecipients;
@@ -0,0 +1,4 @@
1
+ import type { SendableMailObject } from '../../utility/interfaces';
2
+ declare function sendSendgridMail(sendObject: SendableMailObject): Promise<boolean>;
3
+ export default sendSendgridMail;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mail/drivers/sendgrid/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAInE,iBAAe,gBAAgB,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAsBhF;eAEc,gBAAgB"}
@@ -0,0 +1,23 @@
1
+ import sgMail from '@sendgrid/mail';
2
+ import { pick } from '@sqrzro/utility';
3
+ import transformSendgridRecipients from './transform-sendgrid-recipients';
4
+ async function sendSendgridMail(sendObject) {
5
+ if (!process.env.MAIL_API_KEY) {
6
+ throw new Error('Could not send mail via Sendgrid. Mail API key has not been set.');
7
+ }
8
+ sgMail.setApiKey(process.env.MAIL_API_KEY);
9
+ const response = await sgMail.send({
10
+ attachments: sendObject.attachments,
11
+ bcc: transformSendgridRecipients(sendObject.bcc),
12
+ cc: transformSendgridRecipients(sendObject.cc),
13
+ from: pick(sendObject.from, ['email', 'name']),
14
+ html: sendObject.html,
15
+ to: transformSendgridRecipients(sendObject.to),
16
+ subject: sendObject.subject,
17
+ });
18
+ if (!response[0].statusCode.toString().startsWith('2')) {
19
+ throw new Error(`Could not send mail via Sendgrid. ${JSON.stringify(response)}`);
20
+ }
21
+ return true;
22
+ }
23
+ export default sendSendgridMail;
@@ -0,0 +1,5 @@
1
+ declare function transformSendgridRecipients(emails?: string[] | string): {
2
+ email: string;
3
+ }[];
4
+ export default transformSendgridRecipients;
5
+ //# sourceMappingURL=transform-sendgrid-recipients.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-sendgrid-recipients.d.ts","sourceRoot":"","sources":["../../../../src/mail/drivers/sendgrid/transform-sendgrid-recipients.ts"],"names":[],"mappings":"AAAA,iBAAS,2BAA2B,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,CAKpF;eAEc,2BAA2B"}
@@ -0,0 +1,7 @@
1
+ function transformSendgridRecipients(emails) {
2
+ if (!emails) {
3
+ return [];
4
+ }
5
+ return Array.isArray(emails) ? emails.map((email) => ({ email })) : [{ email: emails }];
6
+ }
7
+ export default transformSendgridRecipients;
@@ -0,0 +1,7 @@
1
+ import type { MailObject } from './utility/interfaces';
2
+ declare function getMail<T extends object>(mail: MailObject<T>, data: T): Promise<{
3
+ subject: string;
4
+ html: string;
5
+ }>;
6
+ export default getMail;
7
+ //# sourceMappingURL=get-mail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-mail.d.ts","sourceRoot":"","sources":["../../src/mail/get-mail.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,iBAAe,OAAO,CAAC,CAAC,SAAS,MAAM,EACnC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,EACnB,IAAI,EAAE,CAAC,GACR,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAY5C;eAEc,OAAO"}
@@ -0,0 +1,12 @@
1
+ import renderMail from './utility/render-mail';
2
+ async function getMail(mail, data) {
3
+ const { subject, template } = mail;
4
+ const subjectText = typeof subject === 'function' ? await subject(data) : subject;
5
+ const element = await template(data);
6
+ const html = await renderMail(element);
7
+ return {
8
+ html,
9
+ subject: subjectText,
10
+ };
11
+ }
12
+ export default getMail;
@@ -1,25 +1,5 @@
1
- interface MailObject<T extends object> {
2
- subject: string | ((data: T) => Promise<string> | string);
3
- template: (data: T) => Promise<React.ReactElement> | React.ReactElement;
4
- }
5
- interface MailOptions {
6
- attachments?: {
7
- content: string;
8
- filename: string;
9
- type: string;
10
- }[];
11
- bcc?: string[] | string;
12
- cc?: string[] | string;
13
- from?: string | null;
14
- }
15
-
16
- declare function createMail<T extends object>(subject: string | ((data: T) => Promise<string> | string), template: (data: T) => Promise<React.ReactElement> | React.ReactElement): MailObject<T>;
17
-
18
- declare function getMail<T extends object>(mail: MailObject<T>, data: T): Promise<{
19
- subject: string;
20
- html: string;
21
- }>;
22
-
23
- declare function sendMail<T extends object>(to: string[] | string, mail: MailObject<T>, data?: T, options?: MailOptions): Promise<boolean>;
24
-
25
- export { type MailObject, createMail, getMail, sendMail };
1
+ export type { MailObject } from './utility/interfaces';
2
+ export { default as createMail } from './create-mail';
3
+ export { default as getMail } from './get-mail';
4
+ export { default as sendMail } from './send-mail';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mail/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC"}
@@ -1,3 +1,3 @@
1
- import _ from'stream';import x from'form-data';import N from'mailgun.js';import {pick}from'@sqrzro/utility';import R from'@sendgrid/mail';function P(t,e){return {subject:t,template:e}}var S=P;async function D(t){let e=(await import('react-dom/server')).default;return new Promise(r=>{let n=new _.Writable,i="";function o(m,M,p){i+=m.toString(),p();}n._write=o;let{pipe:s}=e.renderToPipeableStream(t,{onShellReady:()=>{s(n),r(i);}});})}var g=D;async function L(t,e){let{subject:r,template:n}=t,i=typeof r=="function"?await r(e):r,o=await n(e);return {html:await g(o),subject:i}}var f=L;function T(t){return t.split("@")[1]}var A=T;var O=new N(x);async function j(t){if(!process.env.MAIL_API_KEY)throw new Error("Could not send mail via Mailgun. Mail API key has not been set.");return (await O.client({key:process.env.MAIL_API_KEY,url:"https://api.eu.mailgun.net/",username:"api"}).messages.create(A(t.from.email),{bcc:t.bcc,cc:t.cc,from:t.from.raw,html:t.html,subject:t.subject,to:t.to})).status===200}var y=j;function C(t){return t?Array.isArray(t)?t.map(e=>({email:e})):[{email:t}]:[]}var l=C;async function U(t){if(!process.env.MAIL_API_KEY)throw new Error("Could not send mail via Mailtrap. Mail API key has not been set.");let[e,r]=process.env.MAIL_API_KEY.split("."),i=await(await fetch(`https://sandbox.api.mailtrap.io/api/send/${e}`,{method:"POST",headers:{"Api-Token":r,"Content-Type":"application/json"},body:JSON.stringify({attachments:t.attachments,bcc:l(t.bcc),cc:l(t.cc),from:pick(t.from,["email","name"]),html:t.html,subject:t.subject,to:l(t.to)})})).json();if(i.errors)throw new Error(`Could not send mail via Mailtrap. ${i.errors[0]}.`);return true}var b=U;function u(t,e){return Array.isArray(t)?t.map(r=>({email:r,type:e})):[{email:t,type:e}]}function K(t,e,r){return [...u(t,"to"),...u(e||[],"cc"),...u(r||[],"bcc")]}var I=K;async function V(t){if(!process.env.MAIL_API_KEY)throw new Error("Could not send mail via Mandrill. Mail API key has not been set.");let r={attachments:t.attachments?.map(o=>({content:o.content,name:o.filename,type:o.type})),from_email:t.from.email,from_name:t.from.name,html:t.html,subject:t.subject,preserve_recipients:true,to:I(t.to,t.cc,t.bcc)},i=await(await fetch("https://mandrillapp.com/api/1.0/messages/send",{method:"POST",body:JSON.stringify({key:process.env.MAIL_API_KEY,message:r})})).json();return Array.isArray(i)?i.every(o=>o.status==="sent"):i.status==="sent"}var h=V;function Y(t){return t?Array.isArray(t)?t.map(e=>({email:e})):[{email:t}]:[]}var c=Y;async function G(t){if(!process.env.MAIL_API_KEY)throw new Error("Could not send mail via Sendgrid. Mail API key has not been set.");R.setApiKey(process.env.MAIL_API_KEY);let e=await R.send({attachments:t.attachments,bcc:c(t.bcc),cc:c(t.cc),from:pick(t.from,["email","name"]),html:t.html,to:c(t.to),subject:t.subject});if(!e[0].statusCode.toString().startsWith("2"))throw new Error(`Could not send mail via Sendgrid. ${JSON.stringify(e)}`);return true}var E=G;function B(t){if(!t&&!process.env.MAIL_FROM)throw new Error("Mail from address has not been set as an environment variable, or provided in options.");let e=/^(?<name>[^<]+)<(?<email>[^>]+)>$/u.exec(t||process.env.MAIL_FROM||"");if(!e?.groups?.name||!e?.groups?.email)throw new Error('Mail from address is not the correct format. It should be "Name <email>".');return {email:e.groups.email.trim(),name:e.groups.name.trim(),raw:`${e.groups.name.trim()} <${e.groups.email.trim()}>`}}var v=B;var F=["MAILTRAP"],J=["MAILGUN","MAILTRAP","MANDRILL","SENDGRID"],W="MAILTRAP",q="SENDGRID",w={MAILGUN:y,MAILTRAP:b,MANDRILL:h,SENDGRID:E};async function z(t,e,r,n){let i=v(n?.from),{subject:o,html:s}=await f(e,r||{}),m={attachments:n?.attachments,bcc:n?.bcc,cc:n?.cc,from:i,html:s,subject:o,to:t},M=process.env.MAIL_ENABLE_PRODUCTION==="true"?J:F,p=process.env.MAIL_ENABLE_PRODUCTION==="true"?q:W,a=process.env.MAIL_DRIVER?process.env.MAIL_DRIVER.toUpperCase():p;if(!M.includes(a)||!w[a])throw new Error(`Mail driver ${a} is not supported. If you're in a production environment, you might need to set the MAIL_ENABLE_PRODUCTION environment variable to access this driver.`);let d=w[a];if(!d)throw new Error(`Mail driver ${a} is not supported.`);return d(m)}var H=z;
2
- export{S as createMail,f as getMail,H as sendMail};//# sourceMappingURL=index.js.map
3
- //# sourceMappingURL=index.js.map
1
+ export { default as createMail } from './create-mail';
2
+ export { default as getMail } from './get-mail';
3
+ export { default as sendMail } from './send-mail';
@@ -0,0 +1,4 @@
1
+ import type { MailObject, MailOptions } from './utility/interfaces';
2
+ declare function sendMail<T extends object>(to: string[] | string, mail: MailObject<T>, data?: T, options?: MailOptions): Promise<boolean>;
3
+ export default sendMail;
4
+ //# sourceMappingURL=send-mail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-mail.d.ts","sourceRoot":"","sources":["../../src/mail/send-mail.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAc,UAAU,EAAE,WAAW,EAAsB,MAAM,sBAAsB,CAAC;AAepG,iBAAe,QAAQ,CAAC,CAAC,SAAS,MAAM,EACpC,EAAE,EAAE,MAAM,EAAE,GAAG,MAAM,EACrB,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,EACnB,IAAI,CAAC,EAAE,CAAC,EACR,OAAO,CAAC,EAAE,WAAW,GACtB,OAAO,CAAC,OAAO,CAAC,CAuClB;eAEc,QAAQ"}
@@ -0,0 +1,45 @@
1
+ import sendMailgunMail from './drivers/mailgun';
2
+ import sendMailtrapMail from './drivers/mailtrap';
3
+ import sendMandrillMail from './drivers/mandrill';
4
+ import sendSendgridMail from './drivers/sendgrid';
5
+ import getMail from './get-mail';
6
+ import getSenderDetails from './utility/get-sender-details';
7
+ const DEVELOPMENT_DRIVERS = ['MAILTRAP'];
8
+ const PRODUCTION_DRIVERS = ['MAILGUN', 'MAILTRAP', 'MANDRILL', 'SENDGRID'];
9
+ const DEFAULT_DEVELOPMENT_DRIVER = 'MAILTRAP';
10
+ const DEFAULT_PRODUCTION_DRIVER = 'SENDGRID';
11
+ const driverMap = {
12
+ MAILGUN: sendMailgunMail,
13
+ MAILTRAP: sendMailtrapMail,
14
+ MANDRILL: sendMandrillMail,
15
+ SENDGRID: sendSendgridMail,
16
+ };
17
+ async function sendMail(to, mail, data, options) {
18
+ const from = getSenderDetails(options?.from);
19
+ const { subject, html } = await getMail(mail, data || {});
20
+ const sendObject = {
21
+ attachments: options?.attachments,
22
+ bcc: options?.bcc,
23
+ cc: options?.cc,
24
+ from,
25
+ html,
26
+ subject,
27
+ to,
28
+ };
29
+ const allowedDriverAliases = process.env.MAIL_ENABLE_PRODUCTION === 'true' ? PRODUCTION_DRIVERS : DEVELOPMENT_DRIVERS;
30
+ const defaultDriverAlias = process.env.MAIL_ENABLE_PRODUCTION === 'true'
31
+ ? DEFAULT_PRODUCTION_DRIVER
32
+ : DEFAULT_DEVELOPMENT_DRIVER;
33
+ const driverAlias = process.env.MAIL_DRIVER
34
+ ? process.env.MAIL_DRIVER.toUpperCase()
35
+ : defaultDriverAlias;
36
+ if (!allowedDriverAliases.includes(driverAlias) || !driverMap[driverAlias]) {
37
+ throw new Error(`Mail driver ${driverAlias} is not supported. If you're in a production environment, you might need to set the MAIL_ENABLE_PRODUCTION environment variable to access this driver.`);
38
+ }
39
+ const driver = driverMap[driverAlias];
40
+ if (!driver) {
41
+ throw new Error(`Mail driver ${driverAlias} is not supported.`);
42
+ }
43
+ return driver(sendObject);
44
+ }
45
+ export default sendMail;
@@ -0,0 +1,4 @@
1
+ import type { SenderObject } from './interfaces';
2
+ declare function getSenderDetails(from?: string | null): SenderObject;
3
+ export default getSenderDetails;
4
+ //# sourceMappingURL=get-sender-details.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-sender-details.d.ts","sourceRoot":"","sources":["../../../src/mail/utility/get-sender-details.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,iBAAS,gBAAgB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,YAAY,CAoB5D;eAEc,gBAAgB"}
@@ -0,0 +1,15 @@
1
+ function getSenderDetails(from) {
2
+ if (!from && !process.env.MAIL_FROM) {
3
+ throw new Error('Mail from address has not been set as an environment variable, or provided in options.');
4
+ }
5
+ const matches = /^(?<name>[^<]+)<(?<email>[^>]+)>$/u.exec(from || process.env.MAIL_FROM || '');
6
+ if (!matches?.groups?.name || !matches?.groups?.email) {
7
+ throw new Error('Mail from address is not the correct format. It should be "Name <email>".');
8
+ }
9
+ return {
10
+ email: matches.groups.email.trim(),
11
+ name: matches.groups.name.trim(),
12
+ raw: `${matches.groups.name.trim()} <${matches.groups.email.trim()}>`,
13
+ };
14
+ }
15
+ export default getSenderDetails;
@@ -0,0 +1,34 @@
1
+ export interface SenderObject {
2
+ email: string;
3
+ name: string;
4
+ raw: string;
5
+ }
6
+ export interface MailObject<T extends object> {
7
+ subject: string | ((data: T) => Promise<string> | string);
8
+ template: (data: T) => Promise<React.ReactElement> | React.ReactElement;
9
+ }
10
+ export interface MailOptions {
11
+ attachments?: {
12
+ content: string;
13
+ filename: string;
14
+ type: string;
15
+ }[];
16
+ bcc?: string[] | string;
17
+ cc?: string[] | string;
18
+ from?: string | null;
19
+ }
20
+ export interface SendableMailObject {
21
+ attachments?: {
22
+ content: string;
23
+ filename: string;
24
+ type: string;
25
+ }[];
26
+ bcc?: string[] | string;
27
+ cc?: string[] | string;
28
+ from: SenderObject;
29
+ html: string;
30
+ subject: string;
31
+ to: string[] | string;
32
+ }
33
+ export type MailDriver = (sendObject: SendableMailObject) => Promise<boolean>;
34
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/mail/utility/interfaces.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,MAAM;IACxC,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;IAC1D,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC;CAC3E;AAED,MAAM,WAAW,WAAW;IACxB,WAAW,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACpE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IACxB,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IAC/B,WAAW,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACpE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IACxB,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IACvB,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,UAAU,GAAG,CAAC,UAAU,EAAE,kBAAkB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ declare function renderMail(element: React.ReactElement): Promise<string>;
2
+ export default renderMail;
3
+ //# sourceMappingURL=render-mail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-mail.d.ts","sourceRoot":"","sources":["../../../src/mail/utility/render-mail.ts"],"names":[],"mappings":"AAEA,iBAAe,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAyBtE;eAEc,UAAU"}
@@ -0,0 +1,20 @@
1
+ import stream from 'node:stream';
2
+ async function renderMail(element) {
3
+ const ReactDOMServer = (await import('react-dom/server')).default;
4
+ return new Promise((resolve) => {
5
+ const ws = new stream.Writable();
6
+ let content = '';
7
+ function write(chunk, enc, next) {
8
+ content += chunk.toString();
9
+ next();
10
+ }
11
+ ws._write = write; // eslint-disable-line no-underscore-dangle
12
+ const { pipe } = ReactDOMServer.renderToPipeableStream(element, {
13
+ onShellReady: () => {
14
+ pipe(ws);
15
+ resolve(content);
16
+ },
17
+ });
18
+ });
19
+ }
20
+ export default renderMail;
@@ -0,0 +1,5 @@
1
+ import type { NextRequest } from 'next/server';
2
+ import type { ProxyFunction } from './utility/interfaces';
3
+ declare function handleProxy(request: NextRequest, functions: ProxyFunction[]): Promise<Response>;
4
+ export default handleProxy;
5
+ //# sourceMappingURL=handle-proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-proxy.d.ts","sourceRoot":"","sources":["../../src/proxy/handle-proxy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,iBAAe,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAgB9F;eAEc,WAAW"}
@@ -0,0 +1,17 @@
1
+ import { NextResponse } from 'next/server';
2
+ async function handleProxy(request, functions) {
3
+ for (const func of functions) {
4
+ const result = await func(request);
5
+ if (result?.redirect) {
6
+ const { redirect } = result;
7
+ if (typeof redirect === 'number') {
8
+ return new Response(null, { status: redirect });
9
+ }
10
+ else {
11
+ return NextResponse.redirect(new URL(redirect, request.url));
12
+ }
13
+ }
14
+ }
15
+ return NextResponse.next();
16
+ }
17
+ export default handleProxy;
@@ -1,10 +1,3 @@
1
- import { NextRequest } from 'next/server';
2
-
3
- interface ProxyRedirect {
4
- redirect: string | number | null;
5
- }
6
- type ProxyFunction = (request: NextRequest) => Promise<ProxyRedirect | null>;
7
-
8
- declare function handleProxy(request: NextRequest, functions: ProxyFunction[]): Promise<Response>;
9
-
10
- export { type ProxyFunction, type ProxyRedirect, handleProxy };
1
+ export type * from './utility/interfaces';
2
+ export { default as handleProxy } from './handle-proxy';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/proxy/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,sBAAsB,CAAC;AAE1C,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC"}