@hartl-services/medusa-base 0.4.0 → 1.0.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 (235) hide show
  1. package/.medusa/server/src/admin/index.js +1517 -87
  2. package/.medusa/server/src/admin/index.mjs +1518 -88
  3. package/.medusa/server/src/api/admin/email/messages/[id]/resends/route.js +24 -0
  4. package/.medusa/server/src/api/admin/email/messages/[id]/route.js +12 -0
  5. package/.medusa/server/src/api/admin/email/messages/route.js +12 -0
  6. package/.medusa/server/src/api/admin/email/terms-versions/[id]/download/route.js +16 -0
  7. package/.medusa/server/src/api/admin/email/terms-versions/route.js +47 -0
  8. package/.medusa/server/src/api/admin/orders/[id]/documents/[document_id]/download/route.js +21 -0
  9. package/.medusa/server/src/api/admin/orders/[id]/documents/[document_id]/regenerate/route.js +38 -0
  10. package/.medusa/server/src/api/admin/orders/[id]/documents/regenerate/route.js +32 -0
  11. package/.medusa/server/src/api/admin/orders/[id]/documents/route.js +36 -0
  12. package/.medusa/server/src/api/admin/orders/[id]/packing-lists/[fulfillment_id]/download/route.js +24 -0
  13. package/.medusa/server/src/api/admin/orders/[id]/packing-lists/[fulfillment_id]/retry/route.js +44 -0
  14. package/.medusa/server/src/api/admin/orders/[id]/packing-lists/route.js +82 -0
  15. package/.medusa/server/src/api/document-download-response.js +16 -0
  16. package/.medusa/server/src/api/document-response.js +23 -0
  17. package/.medusa/server/src/api/files/[asset]/route.js +24 -0
  18. package/.medusa/server/src/api/files/file-response.js +43 -0
  19. package/.medusa/server/src/api/files/gateway-options.js +31 -0
  20. package/.medusa/server/src/api/files/private/[token]/route.js +29 -0
  21. package/.medusa/server/src/api/files/upload/[token]/route.js +66 -0
  22. package/.medusa/server/src/api/middlewares.js +168 -1
  23. package/.medusa/server/src/api/packing-list-response.js +22 -0
  24. package/.medusa/server/src/api/route.js +27 -0
  25. package/.medusa/server/src/api/store/documents/[id]/download/route.js +21 -0
  26. package/.medusa/server/src/api/store/documents/[id]/route.js +15 -0
  27. package/.medusa/server/src/api/store/documents/route.js +11 -0
  28. package/.medusa/server/src/api/terms-download-response.js +12 -0
  29. package/.medusa/server/src/documents/config/index.js +18 -0
  30. package/.medusa/server/src/documents/paths/documents.js +6 -0
  31. package/.medusa/server/src/documents/paths/index.js +18 -0
  32. package/.medusa/server/src/documents/plugin-features.js +24 -0
  33. package/.medusa/server/src/documents/schemas/documents.js +18 -0
  34. package/.medusa/server/src/documents/schemas/index.js +18 -0
  35. package/.medusa/server/src/documents/scripts/verify-documents-file-storage.js +55 -0
  36. package/.medusa/server/src/documents/templates/financial-document.js +142 -0
  37. package/.medusa/server/src/documents/templates/format.js +31 -0
  38. package/.medusa/server/src/documents/templates/html-factory.js +40 -0
  39. package/.medusa/server/src/documents/templates/html-utils.js +13 -0
  40. package/.medusa/server/src/documents/templates/layout.js +97 -0
  41. package/.medusa/server/src/documents/templates/packing-list.js +50 -0
  42. package/.medusa/server/src/documents/types/admin-api.js +3 -0
  43. package/.medusa/server/src/documents/types/document-summary.js +3 -0
  44. package/.medusa/server/src/documents/types/documents.js +3 -0
  45. package/.medusa/server/src/documents/types/html-factory.js +6 -0
  46. package/.medusa/server/src/documents/types/index.js +22 -0
  47. package/.medusa/server/src/documents/types/store-api.js +3 -0
  48. package/.medusa/server/src/documents/utils/document-merchant.js +22 -0
  49. package/.medusa/server/src/documents/utils/html-to-pdf.js +61 -0
  50. package/.medusa/server/src/documents/utils/private-file-storage.js +64 -0
  51. package/.medusa/server/src/documents/utils/resolve-services.js +7 -0
  52. package/.medusa/server/src/email/application/handle-invite-event.js +312 -0
  53. package/.medusa/server/src/email/application/handle-password-reset-event.js +354 -0
  54. package/.medusa/server/src/email/config/index.js +84 -0
  55. package/.medusa/server/src/email/config/notification-module.js +20 -0
  56. package/.medusa/server/src/email/domain/business-keys.js +50 -0
  57. package/.medusa/server/src/email/domain/documents-fact-fingerprint.js +7 -0
  58. package/.medusa/server/src/email/domain/event-schemas.js +36 -0
  59. package/.medusa/server/src/email/domain/failure-classification.js +53 -0
  60. package/.medusa/server/src/email/plugin-features.js +31 -0
  61. package/.medusa/server/src/email/rendering/default-templates.js +91 -0
  62. package/.medusa/server/src/email/rendering/render-email.js +37 -0
  63. package/.medusa/server/src/email/rendering/resolve-shop-configuration.js +48 -0
  64. package/.medusa/server/src/email/types/email-kinds.js +18 -0
  65. package/.medusa/server/src/email/types/index.js +21 -0
  66. package/.medusa/server/src/email/types/shop-configuration.js +3 -0
  67. package/.medusa/server/src/email/types/smtp-configuration.js +3 -0
  68. package/.medusa/server/src/email/types/template-data.js +79 -0
  69. package/.medusa/server/src/files/config/index.js +256 -0
  70. package/.medusa/server/src/files/gateway/index.js +115 -0
  71. package/.medusa/server/src/files/types/index.js +6 -0
  72. package/.medusa/server/src/files/types/public.js +6 -0
  73. package/.medusa/server/src/jobs/document-fact-publication-reconciliation.js +18 -0
  74. package/.medusa/server/src/jobs/document-resolution-reconciliation.js +20 -0
  75. package/.medusa/server/src/jobs/packing-list-reconciliation.js +49 -0
  76. package/.medusa/server/src/jobs/reconcile-email-attempts.js +63 -0
  77. package/.medusa/server/src/jobs/reconcile-pending-email-messages.js +41 -0
  78. package/.medusa/server/src/jobs/retry-email-messages.js +27 -0
  79. package/.medusa/server/src/migration-scripts/dismiss-orphaned-cart-promotion-links.js +26 -0
  80. package/.medusa/server/src/modules/documents/domain/cancellation-snapshot.js +97 -0
  81. package/.medusa/server/src/modules/documents/domain/document-number.js +36 -0
  82. package/.medusa/server/src/modules/documents/domain/document-resolution.js +24 -0
  83. package/.medusa/server/src/modules/documents/domain/issuance-rules.js +37 -0
  84. package/.medusa/server/src/modules/documents/domain/merchant.js +86 -0
  85. package/.medusa/server/src/modules/documents/domain/options.js +40 -0
  86. package/.medusa/server/src/modules/documents/domain/packing-list.js +90 -0
  87. package/.medusa/server/src/modules/documents/domain/snapshot-normalization.js +17 -0
  88. package/.medusa/server/src/modules/documents/domain/tax-breakdown.js +66 -0
  89. package/.medusa/server/src/modules/documents/index.js +15 -0
  90. package/.medusa/server/src/modules/documents/loaders/assert-private-file-storage.js +20 -0
  91. package/.medusa/server/src/modules/documents/migrations/Migration20260827061749.js +75 -0
  92. package/.medusa/server/src/modules/documents/migrations/Migration20260830111207.js +28 -0
  93. package/.medusa/server/src/modules/documents/models/document-artifact.js +25 -0
  94. package/.medusa/server/src/modules/documents/models/document-number-sequence.js +29 -0
  95. package/.medusa/server/src/modules/documents/models/document.js +82 -0
  96. package/.medusa/server/src/modules/documents/models/order-cancellation-resolution.js +51 -0
  97. package/.medusa/server/src/modules/documents/models/packing-list-revision.js +36 -0
  98. package/.medusa/server/src/modules/documents/models/packing-list.js +27 -0
  99. package/.medusa/server/src/modules/documents/models/refund-document-resolution.js +66 -0
  100. package/.medusa/server/src/modules/documents/models/shipment-invoice-assignment.js +51 -0
  101. package/.medusa/server/src/modules/documents/models/shipment-invoice-coordinator.js +44 -0
  102. package/.medusa/server/src/modules/documents/service.js +1701 -0
  103. package/.medusa/server/src/modules/email/domain/attachment.js +25 -0
  104. package/.medusa/server/src/modules/email/domain/message-state.js +69 -0
  105. package/.medusa/server/src/modules/email/index.js +13 -0
  106. package/.medusa/server/src/modules/email/migrations/Migration20260826173422.js +32 -0
  107. package/.medusa/server/src/modules/email/migrations/Migration20260827172945.js +16 -0
  108. package/.medusa/server/src/modules/email/migrations/Migration20260827194804.js +22 -0
  109. package/.medusa/server/src/modules/email/migrations/Migration20260906195205.js +16 -0
  110. package/.medusa/server/src/modules/email/models/email-attempt.js +56 -0
  111. package/.medusa/server/src/modules/email/models/email-message.js +71 -0
  112. package/.medusa/server/src/modules/email/models/email-terms-version.js +37 -0
  113. package/.medusa/server/src/modules/email/service.js +1285 -0
  114. package/.medusa/server/src/providers/s3-cache/cache/atomic-write.js +25 -0
  115. package/.medusa/server/src/providers/s3-cache/cache/cache-manager.js +115 -0
  116. package/.medusa/server/src/providers/s3-cache/cache/keyed-lock.js +28 -0
  117. package/.medusa/server/src/providers/s3-cache/index.js +8 -0
  118. package/.medusa/server/src/providers/s3-cache/object-key.js +53 -0
  119. package/.medusa/server/src/providers/s3-cache/s3-cache-file.js +229 -0
  120. package/.medusa/server/src/providers/s3-cache/s3-object-store.js +86 -0
  121. package/.medusa/server/src/providers/smtp/index.js +8 -0
  122. package/.medusa/server/src/providers/smtp/service.js +236 -0
  123. package/.medusa/server/src/providers/smtp/types.js +11 -0
  124. package/.medusa/server/src/public/config.js +186 -0
  125. package/.medusa/server/src/public/gateway.js +19 -0
  126. package/.medusa/server/src/public/instrumentation.js +56 -0
  127. package/.medusa/server/src/public/shop-config.js +12 -0
  128. package/.medusa/server/src/public/shop-types.js +24 -0
  129. package/.medusa/server/src/shop-config/build-food-shop-config.js +248 -0
  130. package/.medusa/server/src/shop-config/options.js +71 -0
  131. package/.medusa/server/src/subscribers/affiliate-consignment-reminder-due.js +26 -0
  132. package/.medusa/server/src/subscribers/documents-order-canceled.js +24 -0
  133. package/.medusa/server/src/subscribers/documents-order-cancellation-ready.js +26 -0
  134. package/.medusa/server/src/subscribers/documents-refund-ready.js +24 -0
  135. package/.medusa/server/src/subscribers/documents-shipment-created.js +36 -0
  136. package/.medusa/server/src/subscribers/documents-shipment-invoice-assignment-decided.js +26 -0
  137. package/.medusa/server/src/subscribers/email-order-canceled.js +28 -0
  138. package/.medusa/server/src/subscribers/email-shipment-created.js +32 -0
  139. package/.medusa/server/src/subscribers/order-placed.js +27 -0
  140. package/.medusa/server/src/subscribers/packing-list-allocation-revised.js +32 -0
  141. package/.medusa/server/src/subscribers/packing-list-fulfillment-canceled.js +54 -0
  142. package/.medusa/server/src/subscribers/packing-list-fulfillment-created.js +31 -0
  143. package/.medusa/server/src/subscribers/password-reset.js +23 -0
  144. package/.medusa/server/src/subscribers/payment-refunded.js +38 -0
  145. package/.medusa/server/src/subscribers/return-received.js +27 -0
  146. package/.medusa/server/src/subscribers/return-requested.js +27 -0
  147. package/.medusa/server/src/subscribers/user-invite.js +23 -0
  148. package/.medusa/server/src/utils/cart-promotion-links.js +101 -0
  149. package/.medusa/server/src/workflows/documents/issue-cancellation-after-refund.js +246 -0
  150. package/.medusa/server/src/workflows/documents/issue-document.js +163 -0
  151. package/.medusa/server/src/workflows/documents/issue-invoice-after-shipment.js +521 -0
  152. package/.medusa/server/src/workflows/documents/issue-packing-list.js +384 -0
  153. package/.medusa/server/src/workflows/documents/publish-document-facts.js +53 -0
  154. package/.medusa/server/src/workflows/documents/reconcile-document-resolutions.js +48 -0
  155. package/.medusa/server/src/workflows/documents/reconcile-order-cancellation.js +92 -0
  156. package/.medusa/server/src/workflows/documents/regenerate-issued-document.js +61 -0
  157. package/.medusa/server/src/workflows/email/dispatch-email-message.js +299 -0
  158. package/.medusa/server/src/workflows/email/documents-required-facts.js +30 -0
  159. package/.medusa/server/src/workflows/email/prepare-affiliate-reminder-email.js +58 -0
  160. package/.medusa/server/src/workflows/email/prepare-order-canceled-email.js +64 -0
  161. package/.medusa/server/src/workflows/email/prepare-order-received-email.js +56 -0
  162. package/.medusa/server/src/workflows/email/prepare-refund-email.js +47 -0
  163. package/.medusa/server/src/workflows/email/prepare-return-email.js +75 -0
  164. package/.medusa/server/src/workflows/email/prepare-shipment-email.js +82 -0
  165. package/.medusa/server/src/workflows/email/retry-email-messages.js +31 -0
  166. package/.medusa/server/src/workflows/hooks/dismiss-deleted-promotion-cart-links.js +23 -0
  167. package/README.md +1619 -7
  168. package/dist/documents/config/index.d.ts +11 -0
  169. package/dist/documents/config/index.js +17 -0
  170. package/dist/documents/templates/financial-document.d.ts +3 -0
  171. package/dist/documents/templates/financial-document.js +141 -0
  172. package/dist/documents/templates/format.d.ts +16 -0
  173. package/dist/documents/templates/format.js +30 -0
  174. package/dist/documents/templates/html-factory.d.ts +11 -0
  175. package/dist/documents/templates/html-factory.js +39 -0
  176. package/dist/documents/templates/html-utils.d.ts +2 -0
  177. package/dist/documents/templates/html-utils.js +12 -0
  178. package/dist/documents/templates/layout.d.ts +17 -0
  179. package/dist/documents/templates/layout.js +96 -0
  180. package/dist/documents/templates/packing-list.d.ts +3 -0
  181. package/dist/documents/templates/packing-list.js +49 -0
  182. package/dist/documents/types/admin-api.d.ts +1 -0
  183. package/dist/documents/types/admin-api.js +2 -0
  184. package/dist/documents/types/document-summary.d.ts +1 -0
  185. package/dist/documents/types/document-summary.js +2 -0
  186. package/dist/documents/types/documents.d.ts +174 -0
  187. package/dist/documents/types/documents.js +2 -0
  188. package/dist/documents/types/html-factory.d.ts +7 -0
  189. package/dist/documents/types/html-factory.js +5 -0
  190. package/dist/documents/types/index.d.ts +5 -0
  191. package/dist/documents/types/index.js +21 -0
  192. package/dist/documents/types/store-api.d.ts +1 -0
  193. package/dist/documents/types/store-api.js +2 -0
  194. package/dist/email/config/index.d.ts +17 -0
  195. package/dist/email/config/index.js +83 -0
  196. package/dist/email/config/notification-module.d.ts +22 -0
  197. package/dist/email/config/notification-module.js +19 -0
  198. package/dist/email/types/email-kinds.d.ts +15 -0
  199. package/dist/email/types/email-kinds.js +17 -0
  200. package/dist/email/types/index.d.ts +4 -0
  201. package/dist/email/types/index.js +20 -0
  202. package/dist/email/types/shop-configuration.d.ts +43 -0
  203. package/dist/email/types/shop-configuration.js +2 -0
  204. package/dist/email/types/smtp-configuration.d.ts +9 -0
  205. package/dist/email/types/smtp-configuration.js +2 -0
  206. package/dist/email/types/template-data.d.ts +100 -0
  207. package/dist/email/types/template-data.js +78 -0
  208. package/dist/files/config/index.d.ts +32 -0
  209. package/dist/files/config/index.js +255 -0
  210. package/dist/files/gateway/index.d.ts +30 -0
  211. package/dist/files/gateway/index.js +114 -0
  212. package/dist/files/types/index.d.ts +2 -0
  213. package/dist/files/types/index.js +5 -0
  214. package/dist/files/types/public.d.ts +90 -0
  215. package/dist/files/types/public.js +5 -0
  216. package/dist/modules/documents/domain/merchant.d.ts +22 -0
  217. package/dist/modules/documents/domain/merchant.js +85 -0
  218. package/dist/modules/documents/domain/options.d.ts +34 -0
  219. package/dist/modules/documents/domain/options.js +39 -0
  220. package/dist/public/config.d.ts +59 -0
  221. package/dist/public/config.js +185 -0
  222. package/dist/public/gateway.d.ts +2 -0
  223. package/dist/public/gateway.js +18 -0
  224. package/dist/public/instrumentation.d.ts +12 -0
  225. package/dist/public/instrumentation.js +55 -0
  226. package/dist/public/shop-config.d.ts +8 -0
  227. package/dist/public/shop-config.js +11 -0
  228. package/dist/public/shop-types.d.ts +7 -0
  229. package/dist/public/shop-types.js +23 -0
  230. package/dist/public/types.d.ts +17 -1
  231. package/dist/shop-config/build-food-shop-config.d.ts +44 -0
  232. package/dist/shop-config/build-food-shop-config.js +247 -0
  233. package/dist/shop-config/options.d.ts +41 -0
  234. package/dist/shop-config/options.js +70 -0
  235. package/package.json +48 -5
@@ -0,0 +1,7 @@
1
+ import type { DocumentRenderInput } from "./documents";
2
+ /**
3
+ * The only project-specific document extension point. PDF rendering and file
4
+ * storage stay inside the plugin; projects control semantic markup and CSS.
5
+ */
6
+ export type DocumentHtmlFactory = (input: DocumentRenderInput) => string | Promise<string>;
7
+ export declare const defineDocumentHtmlFactory: (factory: DocumentHtmlFactory) => DocumentHtmlFactory;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defineDocumentHtmlFactory = void 0;
4
+ const defineDocumentHtmlFactory = (factory) => factory;
5
+ exports.defineDocumentHtmlFactory = defineDocumentHtmlFactory;
@@ -0,0 +1,5 @@
1
+ export * from "./admin-api";
2
+ export * from "./documents";
3
+ export * from "./document-summary";
4
+ export * from "./html-factory";
5
+ export * from "./store-api";
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./admin-api"), exports);
18
+ __exportStar(require("./documents"), exports);
19
+ __exportStar(require("./document-summary"), exports);
20
+ __exportStar(require("./html-factory"), exports);
21
+ __exportStar(require("./store-api"), exports);
@@ -0,0 +1 @@
1
+ export type * from "@hartl-services/medusa-food-supplements-contracts/types/documents-store";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,17 @@
1
+ import type { ResolvedSmtpConfiguration, ShopEmailConfiguration } from "../types";
2
+ export { createSmtpNotificationModuleConfig } from "./notification-module";
3
+ export declare const defineShopEmailConfiguration: <Configuration extends ShopEmailConfiguration>(configuration: Configuration) => Configuration;
4
+ export type { ResolvedSmtpConfiguration, ShopEmailConfiguration, } from "../types";
5
+ export declare const SMTP_ENVIRONMENT_VARIABLES: readonly ["SMTP_HOST", "SMTP_PORT", "SMTP_SECURE", "SMTP_USER", "SMTP_PASSWORD", "SMTP_FROM", "SMTP_REQUIRE_TLS"];
6
+ /**
7
+ * `medusa build` loads the configuration without deployment secrets. These
8
+ * placeholders only satisfy the required-variable checks of a build; they
9
+ * never reach a running server.
10
+ */
11
+ export declare const SMTP_BUILD_PLACEHOLDERS: Readonly<Record<string, string>>;
12
+ /**
13
+ * Validates the SMTP environment values and returns the transport
14
+ * configuration. `allowInsecure` permits plain SMTP for development, tests
15
+ * and builds; otherwise `SMTP_SECURE` or `SMTP_REQUIRE_TLS` must be `true`.
16
+ */
17
+ export declare const resolveSmtp: (values: Readonly<Record<(typeof SMTP_ENVIRONMENT_VARIABLES)[number], string>>, allowInsecure: boolean) => ResolvedSmtpConfiguration;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveSmtp = exports.SMTP_BUILD_PLACEHOLDERS = exports.SMTP_ENVIRONMENT_VARIABLES = exports.defineShopEmailConfiguration = exports.createSmtpNotificationModuleConfig = void 0;
4
+ var notification_module_1 = require("./notification-module");
5
+ Object.defineProperty(exports, "createSmtpNotificationModuleConfig", { enumerable: true, get: function () { return notification_module_1.createSmtpNotificationModuleConfig; } });
6
+ const defineShopEmailConfiguration = (configuration) => configuration;
7
+ exports.defineShopEmailConfiguration = defineShopEmailConfiguration;
8
+ exports.SMTP_ENVIRONMENT_VARIABLES = [
9
+ "SMTP_HOST",
10
+ "SMTP_PORT",
11
+ "SMTP_SECURE",
12
+ "SMTP_USER",
13
+ "SMTP_PASSWORD",
14
+ "SMTP_FROM",
15
+ "SMTP_REQUIRE_TLS",
16
+ ];
17
+ /**
18
+ * `medusa build` loads the configuration without deployment secrets. These
19
+ * placeholders only satisfy the required-variable checks of a build; they
20
+ * never reach a running server.
21
+ */
22
+ exports.SMTP_BUILD_PLACEHOLDERS = {
23
+ SMTP_FROM: "no-reply@smtp.build.invalid",
24
+ SMTP_HOST: "smtp.build.invalid",
25
+ SMTP_PASSWORD: "build-password",
26
+ SMTP_PORT: "2525",
27
+ SMTP_REQUIRE_TLS: "false",
28
+ SMTP_SECURE: "false",
29
+ SMTP_USER: "build-user",
30
+ };
31
+ const optionalValue = (values, name) => {
32
+ const value = values[name]?.trim();
33
+ return value ? value : undefined;
34
+ };
35
+ const integerValue = (values, name, minimum, maximum) => {
36
+ const value = optionalValue(values, name);
37
+ if (value === undefined) {
38
+ return undefined;
39
+ }
40
+ const parsed = Number(value);
41
+ if (!Number.isInteger(parsed) || parsed < minimum || parsed > maximum) {
42
+ throw new TypeError(`${name} must be an integer from ${minimum} through ${maximum}.`);
43
+ }
44
+ return parsed;
45
+ };
46
+ const booleanValue = (values, name, defaultValue) => {
47
+ const value = optionalValue(values, name);
48
+ if (value === undefined) {
49
+ return defaultValue;
50
+ }
51
+ if (value !== "true" && value !== "false") {
52
+ throw new TypeError(`${name} must be either "true" or "false".`);
53
+ }
54
+ return value === "true";
55
+ };
56
+ /**
57
+ * Validates the SMTP environment values and returns the transport
58
+ * configuration. `allowInsecure` permits plain SMTP for development, tests
59
+ * and builds; otherwise `SMTP_SECURE` or `SMTP_REQUIRE_TLS` must be `true`.
60
+ */
61
+ const resolveSmtp = (values, allowInsecure) => {
62
+ const port = integerValue(values, "SMTP_PORT", 1, 65535);
63
+ if (port === undefined) {
64
+ throw new TypeError("SMTP_PORT is required.");
65
+ }
66
+ if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(values.SMTP_FROM)) {
67
+ throw new TypeError("SMTP_FROM must be a valid email address.");
68
+ }
69
+ const smtp = {
70
+ from: values.SMTP_FROM,
71
+ host: values.SMTP_HOST,
72
+ password: values.SMTP_PASSWORD,
73
+ port,
74
+ requireTls: booleanValue(values, "SMTP_REQUIRE_TLS", false),
75
+ secure: booleanValue(values, "SMTP_SECURE", false),
76
+ user: values.SMTP_USER,
77
+ };
78
+ if (!smtp.secure && !smtp.requireTls && !allowInsecure) {
79
+ throw new TypeError("SMTP must use SMTP_SECURE=true or SMTP_REQUIRE_TLS=true outside development and test.");
80
+ }
81
+ return smtp;
82
+ };
83
+ exports.resolveSmtp = resolveSmtp;
@@ -0,0 +1,22 @@
1
+ import type { ResolvedSmtpConfiguration } from "../types";
2
+ export declare const createSmtpNotificationModuleConfig: (smtp: ResolvedSmtpConfiguration) => {
3
+ resolve: string;
4
+ options: {
5
+ providers: {
6
+ id: string;
7
+ options: {
8
+ channels: string[];
9
+ smtp: Readonly<{
10
+ from: string;
11
+ host: string;
12
+ password: string;
13
+ port: number;
14
+ requireTls: boolean;
15
+ secure: boolean;
16
+ user: string;
17
+ }>;
18
+ };
19
+ resolve: string;
20
+ }[];
21
+ };
22
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSmtpNotificationModuleConfig = void 0;
4
+ const createSmtpNotificationModuleConfig = (smtp) => ({
5
+ resolve: "@medusajs/medusa/notification",
6
+ options: {
7
+ providers: [
8
+ {
9
+ id: "smtp",
10
+ options: {
11
+ channels: ["email"],
12
+ smtp,
13
+ },
14
+ resolve: "@hartl-services/medusa-base/providers/smtp",
15
+ },
16
+ ],
17
+ },
18
+ });
19
+ exports.createSmtpNotificationModuleConfig = createSmtpNotificationModuleConfig;
@@ -0,0 +1,15 @@
1
+ import { z } from "@medusajs/framework/zod";
2
+ export declare const EMAIL_KINDS: readonly ["order.received", "order.received.admin", "order.shipped", "order.canceled", "order.return_requested", "order.return_received", "order.refunded", "auth.password_reset", "affiliate.consignment_report_due", "user.invite"];
3
+ export declare const EmailKindSchema: z.ZodEnum<{
4
+ "order.received": "order.received";
5
+ "order.received.admin": "order.received.admin";
6
+ "order.shipped": "order.shipped";
7
+ "order.canceled": "order.canceled";
8
+ "order.return_requested": "order.return_requested";
9
+ "order.return_received": "order.return_received";
10
+ "order.refunded": "order.refunded";
11
+ "auth.password_reset": "auth.password_reset";
12
+ "affiliate.consignment_report_due": "affiliate.consignment_report_due";
13
+ "user.invite": "user.invite";
14
+ }>;
15
+ export type EmailKind = (typeof EMAIL_KINDS)[number];
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmailKindSchema = exports.EMAIL_KINDS = void 0;
4
+ const zod_1 = require("@medusajs/framework/zod");
5
+ exports.EMAIL_KINDS = [
6
+ "order.received",
7
+ "order.received.admin",
8
+ "order.shipped",
9
+ "order.canceled",
10
+ "order.return_requested",
11
+ "order.return_received",
12
+ "order.refunded",
13
+ "auth.password_reset",
14
+ "affiliate.consignment_report_due",
15
+ "user.invite",
16
+ ];
17
+ exports.EmailKindSchema = zod_1.z.enum(exports.EMAIL_KINDS);
@@ -0,0 +1,4 @@
1
+ export * from "./email-kinds";
2
+ export * from "./shop-configuration";
3
+ export * from "./smtp-configuration";
4
+ export * from "./template-data";
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./email-kinds"), exports);
18
+ __exportStar(require("./shop-configuration"), exports);
19
+ __exportStar(require("./smtp-configuration"), exports);
20
+ __exportStar(require("./template-data"), exports);
@@ -0,0 +1,43 @@
1
+ import type { EmailKind } from "./email-kinds";
2
+ import type { EmailRenderDataMap } from "./template-data";
3
+ export type EmailTemplateContent = Readonly<{
4
+ bodyHtml: string;
5
+ subject: string;
6
+ text: string;
7
+ }>;
8
+ export type EmailLayout = (input: Readonly<{
9
+ bodyHtml: string;
10
+ preheader: string;
11
+ subject: string;
12
+ }>) => string;
13
+ export type EmailRendererMap = {
14
+ readonly [Kind in EmailKind]: (data: EmailRenderDataMap[Kind]) => EmailTemplateContent;
15
+ };
16
+ /**
17
+ * What a shop configures. `layout` and `renderers` are optional overrides of
18
+ * the plugin's neutral German defaults (branded with `displayName`); a
19
+ * partial `renderers` map replaces only the listed kinds.
20
+ */
21
+ export type ShopEmailConfiguration = Readonly<{
22
+ affiliatePortalUrl: string;
23
+ displayName: string;
24
+ inviteUrl: (input: Readonly<{
25
+ token: string;
26
+ }>) => string;
27
+ layout?: EmailLayout;
28
+ orderNotificationEmail: string;
29
+ passwordResetUrl: (input: Readonly<{
30
+ locale: string | null;
31
+ }>) => string;
32
+ renderers?: Partial<EmailRendererMap>;
33
+ }>;
34
+ /** A `ShopEmailConfiguration` with the defaults merged in; used internally. */
35
+ export type ResolvedShopEmailConfiguration = Readonly<Omit<ShopEmailConfiguration, "layout" | "renderers"> & {
36
+ layout: EmailLayout;
37
+ renderers: EmailRendererMap;
38
+ }>;
39
+ /** The `email` namespace of the base plugin options. */
40
+ export type EmailPluginOptions = Readonly<{
41
+ jwtSecret: string;
42
+ shop: ShopEmailConfiguration;
43
+ }>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ export type ResolvedSmtpConfiguration = Readonly<{
2
+ from: string;
3
+ host: string;
4
+ password: string;
5
+ port: number;
6
+ requireTls: boolean;
7
+ secure: boolean;
8
+ user: string;
9
+ }>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,100 @@
1
+ import { z } from "@medusajs/framework/zod";
2
+ import type { EmailKind } from "./email-kinds";
3
+ export declare const EmailPersistedDataSchemas: {
4
+ readonly "order.received": z.ZodObject<{
5
+ order_id: z.ZodString;
6
+ }, z.core.$strict>;
7
+ readonly "order.received.admin": z.ZodObject<{
8
+ order_id: z.ZodString;
9
+ }, z.core.$strict>;
10
+ readonly "order.shipped": z.ZodObject<{
11
+ order_id: z.ZodString;
12
+ fulfillment_id: z.ZodString;
13
+ documents_fact_fingerprint: z.ZodOptional<z.ZodString>;
14
+ }, z.core.$strict>;
15
+ readonly "order.canceled": z.ZodObject<{
16
+ order_id: z.ZodString;
17
+ documents_fact_fingerprint: z.ZodOptional<z.ZodString>;
18
+ }, z.core.$strict>;
19
+ readonly "order.return_requested": z.ZodObject<{
20
+ order_id: z.ZodString;
21
+ return_id: z.ZodString;
22
+ }, z.core.$strict>;
23
+ readonly "order.return_received": z.ZodObject<{
24
+ order_id: z.ZodString;
25
+ return_id: z.ZodString;
26
+ }, z.core.$strict>;
27
+ readonly "order.refunded": z.ZodObject<{
28
+ order_id: z.ZodString;
29
+ refund_id: z.ZodString;
30
+ documents_fact_fingerprint: z.ZodOptional<z.ZodString>;
31
+ }, z.core.$strict>;
32
+ readonly "auth.password_reset": z.ZodObject<{
33
+ locale: z.ZodNullable<z.ZodString>;
34
+ }, z.core.$strict>;
35
+ readonly "affiliate.consignment_report_due": z.ZodObject<{
36
+ affiliate_display_name: z.ZodString;
37
+ period_start: z.ZodString;
38
+ due_date: z.ZodString;
39
+ locale: z.ZodNullable<z.ZodString>;
40
+ }, z.core.$strict>;
41
+ readonly "user.invite": z.ZodObject<{}, z.core.$strict>;
42
+ };
43
+ export declare const EmailRenderDataSchemas: {
44
+ readonly "auth.password_reset": z.ZodObject<{
45
+ locale: z.ZodNullable<z.ZodString>;
46
+ reset_url: z.ZodString;
47
+ }, z.core.$strict>;
48
+ readonly "user.invite": z.ZodObject<{
49
+ invite_url: z.ZodString;
50
+ }, z.core.$strict>;
51
+ readonly "order.received": z.ZodObject<{
52
+ order_id: z.ZodString;
53
+ }, z.core.$strict>;
54
+ readonly "order.received.admin": z.ZodObject<{
55
+ order_id: z.ZodString;
56
+ }, z.core.$strict>;
57
+ readonly "order.shipped": z.ZodObject<{
58
+ order_id: z.ZodString;
59
+ fulfillment_id: z.ZodString;
60
+ documents_fact_fingerprint: z.ZodOptional<z.ZodString>;
61
+ }, z.core.$strict>;
62
+ readonly "order.canceled": z.ZodObject<{
63
+ order_id: z.ZodString;
64
+ documents_fact_fingerprint: z.ZodOptional<z.ZodString>;
65
+ }, z.core.$strict>;
66
+ readonly "order.return_requested": z.ZodObject<{
67
+ order_id: z.ZodString;
68
+ return_id: z.ZodString;
69
+ }, z.core.$strict>;
70
+ readonly "order.return_received": z.ZodObject<{
71
+ order_id: z.ZodString;
72
+ return_id: z.ZodString;
73
+ }, z.core.$strict>;
74
+ readonly "order.refunded": z.ZodObject<{
75
+ order_id: z.ZodString;
76
+ refund_id: z.ZodString;
77
+ documents_fact_fingerprint: z.ZodOptional<z.ZodString>;
78
+ }, z.core.$strict>;
79
+ readonly "affiliate.consignment_report_due": z.ZodObject<{
80
+ affiliate_display_name: z.ZodString;
81
+ period_start: z.ZodString;
82
+ due_date: z.ZodString;
83
+ locale: z.ZodNullable<z.ZodString>;
84
+ }, z.core.$strict>;
85
+ };
86
+ export type EmailPersistedDataMap = {
87
+ readonly [Kind in EmailKind]: Readonly<z.infer<(typeof EmailPersistedDataSchemas)[Kind]>>;
88
+ };
89
+ type EmptyRenderContext = Readonly<Record<never, never>>;
90
+ export type EmailEphemeralRenderContextMap = {
91
+ readonly [Kind in EmailKind]: Kind extends "auth.password_reset" ? Readonly<{
92
+ reset_url: string;
93
+ }> : Kind extends "user.invite" ? Readonly<{
94
+ invite_url: string;
95
+ }> : EmptyRenderContext;
96
+ };
97
+ export type EmailRenderDataMap = {
98
+ readonly [Kind in EmailKind]: Readonly<z.infer<(typeof EmailRenderDataSchemas)[Kind]> & EmailEphemeralRenderContextMap[Kind]>;
99
+ };
100
+ export {};
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmailRenderDataSchemas = exports.EmailPersistedDataSchemas = void 0;
4
+ const zod_1 = require("@medusajs/framework/zod");
5
+ const affiliate_1 = require("@hartl-services/medusa-food-supplements-contracts/schemas/affiliate");
6
+ const NonEmptyStringSchema = zod_1.z.string().trim().min(1);
7
+ const NullableLocaleSchema = NonEmptyStringSchema.max(35).nullable();
8
+ const DocumentsFactFingerprintSchema = zod_1.z
9
+ .string()
10
+ .regex(/^[a-f0-9]{64}$/)
11
+ .optional();
12
+ exports.EmailPersistedDataSchemas = {
13
+ "order.received": zod_1.z
14
+ .object({
15
+ order_id: NonEmptyStringSchema,
16
+ })
17
+ .strict(),
18
+ "order.received.admin": zod_1.z
19
+ .object({
20
+ order_id: NonEmptyStringSchema,
21
+ })
22
+ .strict(),
23
+ "order.shipped": zod_1.z
24
+ .object({
25
+ order_id: NonEmptyStringSchema,
26
+ fulfillment_id: NonEmptyStringSchema,
27
+ documents_fact_fingerprint: DocumentsFactFingerprintSchema,
28
+ })
29
+ .strict(),
30
+ "order.canceled": zod_1.z
31
+ .object({
32
+ order_id: NonEmptyStringSchema,
33
+ documents_fact_fingerprint: DocumentsFactFingerprintSchema,
34
+ })
35
+ .strict(),
36
+ "order.return_requested": zod_1.z
37
+ .object({
38
+ order_id: NonEmptyStringSchema,
39
+ return_id: NonEmptyStringSchema,
40
+ })
41
+ .strict(),
42
+ "order.return_received": zod_1.z
43
+ .object({
44
+ order_id: NonEmptyStringSchema,
45
+ return_id: NonEmptyStringSchema,
46
+ })
47
+ .strict(),
48
+ "order.refunded": zod_1.z
49
+ .object({
50
+ order_id: NonEmptyStringSchema,
51
+ refund_id: NonEmptyStringSchema,
52
+ documents_fact_fingerprint: DocumentsFactFingerprintSchema,
53
+ })
54
+ .strict(),
55
+ "auth.password_reset": zod_1.z
56
+ .object({
57
+ locale: NullableLocaleSchema,
58
+ })
59
+ .strict(),
60
+ "affiliate.consignment_report_due": zod_1.z
61
+ .object({
62
+ affiliate_display_name: NonEmptyStringSchema,
63
+ period_start: affiliate_1.CalendarMonthSchema,
64
+ due_date: affiliate_1.CalendarDateSchema,
65
+ locale: NullableLocaleSchema,
66
+ })
67
+ .strict(),
68
+ "user.invite": zod_1.z.object({}).strict(),
69
+ };
70
+ exports.EmailRenderDataSchemas = {
71
+ ...exports.EmailPersistedDataSchemas,
72
+ "auth.password_reset": exports.EmailPersistedDataSchemas["auth.password_reset"].extend({
73
+ reset_url: zod_1.z.string().url(),
74
+ }),
75
+ "user.invite": exports.EmailPersistedDataSchemas["user.invite"].extend({
76
+ invite_url: zod_1.z.string().url(),
77
+ }),
78
+ };
@@ -0,0 +1,32 @@
1
+ import { type FileGatewayOptions, type FileModuleConfiguration, type S3CacheFileModuleConfigOptions, type S3CacheOptions, type S3CacheOptionsCache, type S3CacheStorageConfiguration, type ValidatedS3CacheProviderOptions } from "../types";
2
+ export declare const validateS3CacheProviderOptions: (input: {
3
+ cache?: S3CacheOptionsCache;
4
+ gateway?: FileGatewayOptions;
5
+ s3?: S3CacheOptions;
6
+ }) => ValidatedS3CacheProviderOptions;
7
+ export declare const createS3CacheFileModuleConfig: (options?: S3CacheFileModuleConfigOptions) => FileModuleConfiguration;
8
+ /**
9
+ * Validates the options once and returns both parts S3 Cache Storage needs:
10
+ * the File Module with the S3 provider (under `modules`) and the `gateway`
11
+ * part of the base plugin's `files` option that serves its `/files` routes.
12
+ * Both carry the same signing secret, so every URL the provider signs is one
13
+ * the routes accept.
14
+ */
15
+ export declare const createS3CacheStorageConfig: (options: Omit<S3CacheFileModuleConfigOptions, "enabled" | "local">) => S3CacheStorageConfiguration;
16
+ /**
17
+ * `medusa build` loads the configuration without deployment secrets. These
18
+ * placeholders only satisfy the required-variable checks of a build; they
19
+ * never reach a running server.
20
+ */
21
+ export declare const S3_BUILD_PLACEHOLDERS: Readonly<Record<string, string>>;
22
+ /**
23
+ * Static S3 credentials are optional (the AWS credential chain applies
24
+ * otherwise) but must be complete when present. They are never read during
25
+ * a build.
26
+ */
27
+ export declare const resolveS3Credentials: (environment: NodeJS.ProcessEnv, phase: "build" | "runtime") => {
28
+ readonly accessKeyId: string;
29
+ readonly secretAccessKey: string;
30
+ readonly sessionToken?: string;
31
+ } | undefined;
32
+ export declare const resolveExpirationStrategy: (environment: NodeJS.ProcessEnv, defaultValue: "absolute" | "sliding") => "absolute" | "sliding";