@hszrdm/core 1.0.3 → 1.2.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 (192) hide show
  1. package/.medusa/server/src/admin/index.js +4375 -2368
  2. package/.medusa/server/src/admin/index.mjs +4376 -2369
  3. package/.medusa/server/src/api/admin/ai-translations/apply/route.d.ts +11 -0
  4. package/.medusa/server/src/api/admin/ai-translations/apply/route.js +102 -0
  5. package/.medusa/server/src/api/admin/ai-translations/preview/route.d.ts +10 -0
  6. package/.medusa/server/src/api/admin/ai-translations/preview/route.js +141 -0
  7. package/.medusa/server/src/api/admin/ai-translations/route.d.ts +2 -0
  8. package/.medusa/server/src/api/admin/ai-translations/route.js +19 -0
  9. package/.medusa/server/src/api/admin/cms/entries/[id]/route.d.ts +6 -0
  10. package/.medusa/server/src/api/admin/cms/entries/[id]/route.js +78 -0
  11. package/.medusa/server/src/api/admin/cms/entries/route.d.ts +5 -0
  12. package/.medusa/server/src/api/admin/cms/entries/route.js +77 -0
  13. package/.medusa/server/src/api/admin/cms/taxonomy/[id]/route.d.ts +5 -0
  14. package/.medusa/server/src/api/admin/cms/taxonomy/[id]/route.js +50 -0
  15. package/.medusa/server/src/api/admin/cms/taxonomy/route.d.ts +5 -0
  16. package/.medusa/server/src/api/admin/cms/taxonomy/route.js +60 -0
  17. package/.medusa/server/src/api/admin/core/status/route.d.ts +2 -0
  18. package/.medusa/server/src/api/admin/core/status/route.js +11 -0
  19. package/.medusa/server/src/api/admin/featured-products/[id]/route.d.ts +7 -0
  20. package/.medusa/server/src/api/admin/featured-products/[id]/route.js +54 -0
  21. package/.medusa/server/src/api/admin/leads/[id]/route.d.ts +9 -0
  22. package/.medusa/server/src/api/admin/leads/[id]/route.js +64 -0
  23. package/.medusa/server/src/api/admin/leads/route.d.ts +2 -0
  24. package/.medusa/server/src/api/admin/leads/route.js +26 -0
  25. package/.medusa/server/src/api/admin/newsletter/subscribers/export/route.d.ts +2 -0
  26. package/.medusa/server/src/api/admin/newsletter/subscribers/export/route.js +74 -0
  27. package/.medusa/server/src/api/admin/newsletter/subscribers/route.d.ts +2 -0
  28. package/.medusa/server/src/api/admin/newsletter/subscribers/route.js +57 -0
  29. package/.medusa/server/src/api/admin/product-reviews/[id]/route.d.ts +7 -0
  30. package/.medusa/server/src/api/admin/product-reviews/[id]/route.js +40 -0
  31. package/.medusa/server/src/api/admin/product-reviews/route.d.ts +2 -0
  32. package/.medusa/server/src/api/admin/product-reviews/route.js +31 -0
  33. package/.medusa/server/src/api/admin/quote-requests/[id]/draft-order/route.d.ts +8 -0
  34. package/.medusa/server/src/api/admin/quote-requests/[id]/draft-order/route.js +160 -0
  35. package/.medusa/server/src/api/admin/quote-requests/[id]/order/route.d.ts +2 -0
  36. package/.medusa/server/src/api/admin/quote-requests/[id]/order/route.js +54 -0
  37. package/.medusa/server/src/api/admin/quote-requests/[id]/route.d.ts +5 -0
  38. package/.medusa/server/src/api/admin/quote-requests/[id]/route.js +80 -0
  39. package/.medusa/server/src/api/admin/quote-requests/route.d.ts +2 -0
  40. package/.medusa/server/src/api/admin/quote-requests/route.js +19 -0
  41. package/.medusa/server/src/api/middlewares.js +19 -6
  42. package/.medusa/server/src/api/store/account/wishlist/[productId]/route.d.ts +2 -0
  43. package/.medusa/server/src/api/store/account/wishlist/[productId]/route.js +18 -0
  44. package/.medusa/server/src/api/store/account/wishlist/merge/route.d.ts +6 -0
  45. package/.medusa/server/src/api/store/account/wishlist/merge/route.js +51 -0
  46. package/.medusa/server/src/api/store/account/wishlist/route.d.ts +7 -0
  47. package/.medusa/server/src/api/store/account/wishlist/route.js +76 -0
  48. package/.medusa/server/src/api/store/cms/config/route.d.ts +2 -0
  49. package/.medusa/server/src/api/store/cms/config/route.js +17 -0
  50. package/.medusa/server/src/api/store/cms/entries/[slug]/route.d.ts +2 -0
  51. package/.medusa/server/src/api/store/cms/entries/[slug]/route.js +62 -0
  52. package/.medusa/server/src/api/store/cms/entries/route.d.ts +2 -0
  53. package/.medusa/server/src/api/store/cms/entries/route.js +87 -0
  54. package/.medusa/server/src/api/store/cms/taxonomy/route.d.ts +2 -0
  55. package/.medusa/server/src/api/store/cms/taxonomy/route.js +44 -0
  56. package/.medusa/server/src/api/store/core/pricing/variants/[id]/route.d.ts +2 -0
  57. package/.medusa/server/src/api/store/core/pricing/variants/[id]/route.js +152 -0
  58. package/.medusa/server/src/api/store/featured-products/route.d.ts +2 -0
  59. package/.medusa/server/src/api/store/featured-products/route.js +38 -0
  60. package/.medusa/server/src/api/store/leads/config/route.d.ts +2 -0
  61. package/.medusa/server/src/api/store/leads/config/route.js +21 -0
  62. package/.medusa/server/src/api/store/leads/route.d.ts +4 -0
  63. package/.medusa/server/src/api/store/leads/route.js +176 -0
  64. package/.medusa/server/src/api/store/newsletter/config/route.d.ts +2 -0
  65. package/.medusa/server/src/api/store/newsletter/config/route.js +14 -0
  66. package/.medusa/server/src/api/store/newsletter/confirm/route.d.ts +4 -0
  67. package/.medusa/server/src/api/store/newsletter/confirm/route.js +52 -0
  68. package/.medusa/server/src/api/store/newsletter/route.d.ts +4 -0
  69. package/.medusa/server/src/api/store/newsletter/route.js +172 -0
  70. package/.medusa/server/src/api/store/newsletter/unsubscribe/route.d.ts +4 -0
  71. package/.medusa/server/src/api/store/newsletter/unsubscribe/route.js +54 -0
  72. package/.medusa/server/src/api/store/products/[id]/reviews/route.d.ts +8 -0
  73. package/.medusa/server/src/api/store/products/[id]/reviews/route.js +174 -0
  74. package/.medusa/server/src/api/store/quote-requests/config/route.d.ts +2 -0
  75. package/.medusa/server/src/api/store/quote-requests/config/route.js +13 -0
  76. package/.medusa/server/src/api/store/quote-requests/route.d.ts +5 -0
  77. package/.medusa/server/src/api/store/quote-requests/route.js +214 -0
  78. package/.medusa/server/src/api/store/seo/route.js +42 -10
  79. package/.medusa/server/src/api/store/seo/structured-data/route.js +3 -2
  80. package/.medusa/server/src/config.js +7 -1
  81. package/.medusa/server/src/core/admin-analytics-dashboard.d.ts +1 -0
  82. package/.medusa/server/src/core/admin-analytics-dashboard.js +15 -3
  83. package/.medusa/server/src/core/ai-translation.d.ts +26 -0
  84. package/.medusa/server/src/core/ai-translation.js +173 -0
  85. package/.medusa/server/src/core/featured-products.d.ts +19 -0
  86. package/.medusa/server/src/core/featured-products.js +45 -0
  87. package/.medusa/server/src/core/pricing-tiers.d.ts +25 -0
  88. package/.medusa/server/src/core/pricing-tiers.js +88 -0
  89. package/.medusa/server/src/core/release-info.d.ts +10 -0
  90. package/.medusa/server/src/core/release-info.js +22 -0
  91. package/.medusa/server/src/core/version.d.ts +4 -4
  92. package/.medusa/server/src/core/version.js +3 -3
  93. package/.medusa/server/src/lib/modules/arukereso/config.js +2 -2
  94. package/.medusa/server/src/lib/modules/google-merchant/config.d.ts +2 -0
  95. package/.medusa/server/src/lib/modules/google-merchant/config.js +9 -2
  96. package/.medusa/server/src/lib/modules/google-merchant/feed.d.ts +1 -0
  97. package/.medusa/server/src/lib/modules/google-merchant/feed.js +4 -2
  98. package/.medusa/server/src/localized-config.d.ts +9 -0
  99. package/.medusa/server/src/localized-config.js +14 -0
  100. package/.medusa/server/src/modules/cms/config.d.ts +11 -0
  101. package/.medusa/server/src/modules/cms/config.js +65 -0
  102. package/.medusa/server/src/modules/cms/content-types.d.ts +24 -0
  103. package/.medusa/server/src/modules/cms/content-types.js +27 -0
  104. package/.medusa/server/src/modules/cms/index.d.ts +9 -0
  105. package/.medusa/server/src/modules/cms/index.js +32 -0
  106. package/.medusa/server/src/modules/cms/migrations/Migration20261029170000.d.ts +5 -0
  107. package/.medusa/server/src/modules/cms/migrations/Migration20261029170000.js +27 -0
  108. package/.medusa/server/src/modules/cms/migrations/Migration20261029190000.d.ts +5 -0
  109. package/.medusa/server/src/modules/cms/migrations/Migration20261029190000.js +52 -0
  110. package/.medusa/server/src/modules/cms/models/cms.d.ts +67 -0
  111. package/.medusa/server/src/modules/cms/models/cms.js +64 -0
  112. package/.medusa/server/src/modules/cms/service.d.ts +82 -0
  113. package/.medusa/server/src/modules/cms/service.js +9 -0
  114. package/.medusa/server/src/modules/cms/utils.d.ts +67 -0
  115. package/.medusa/server/src/modules/cms/utils.js +190 -0
  116. package/.medusa/server/src/modules/integration-settings/arukereso-registration.js +2 -2
  117. package/.medusa/server/src/modules/integration-settings/google-merchant-registration.js +6 -2
  118. package/.medusa/server/src/modules/lead/config.d.ts +37 -0
  119. package/.medusa/server/src/modules/lead/config.js +147 -0
  120. package/.medusa/server/src/modules/lead/email.d.ts +17 -0
  121. package/.medusa/server/src/modules/lead/email.js +68 -0
  122. package/.medusa/server/src/modules/lead/index.d.ts +9 -0
  123. package/.medusa/server/src/modules/lead/index.js +27 -0
  124. package/.medusa/server/src/modules/lead/migrations/Migration20261029163000.d.ts +5 -0
  125. package/.medusa/server/src/modules/lead/migrations/Migration20261029163000.js +19 -0
  126. package/.medusa/server/src/modules/lead/models/lead.d.ts +26 -0
  127. package/.medusa/server/src/modules/lead/models/lead.js +53 -0
  128. package/.medusa/server/src/modules/lead/service.d.ts +29 -0
  129. package/.medusa/server/src/modules/lead/service.js +11 -0
  130. package/.medusa/server/src/modules/lead/spam.d.ts +24 -0
  131. package/.medusa/server/src/modules/lead/spam.js +114 -0
  132. package/.medusa/server/src/modules/newsletter/config.d.ts +14 -0
  133. package/.medusa/server/src/modules/newsletter/config.js +51 -0
  134. package/.medusa/server/src/modules/newsletter/email.d.ts +9 -0
  135. package/.medusa/server/src/modules/newsletter/email.js +38 -0
  136. package/.medusa/server/src/modules/newsletter/events.d.ts +10 -0
  137. package/.medusa/server/src/modules/newsletter/events.js +34 -0
  138. package/.medusa/server/src/modules/newsletter/index.d.ts +10 -0
  139. package/.medusa/server/src/modules/newsletter/index.js +33 -0
  140. package/.medusa/server/src/modules/newsletter/migrations/Migration20261030130000.d.ts +5 -0
  141. package/.medusa/server/src/modules/newsletter/migrations/Migration20261030130000.js +18 -0
  142. package/.medusa/server/src/modules/newsletter/models/newsletter-subscriber.d.ts +21 -0
  143. package/.medusa/server/src/modules/newsletter/models/newsletter-subscriber.js +35 -0
  144. package/.medusa/server/src/modules/newsletter/service.d.ts +24 -0
  145. package/.medusa/server/src/modules/newsletter/service.js +11 -0
  146. package/.medusa/server/src/modules/newsletter/token.d.ts +10 -0
  147. package/.medusa/server/src/modules/newsletter/token.js +97 -0
  148. package/.medusa/server/src/modules/product-review/config.d.ts +5 -0
  149. package/.medusa/server/src/modules/product-review/config.js +10 -0
  150. package/.medusa/server/src/modules/product-review/index.d.ts +7 -0
  151. package/.medusa/server/src/modules/product-review/index.js +18 -0
  152. package/.medusa/server/src/modules/product-review/migrations/Migration20261030160100.d.ts +5 -0
  153. package/.medusa/server/src/modules/product-review/migrations/Migration20261030160100.js +18 -0
  154. package/.medusa/server/src/modules/product-review/models/product-review.d.ts +16 -0
  155. package/.medusa/server/src/modules/product-review/models/product-review.js +26 -0
  156. package/.medusa/server/src/modules/product-review/service.d.ts +25 -0
  157. package/.medusa/server/src/modules/product-review/service.js +12 -0
  158. package/.medusa/server/src/modules/quote-request/config.d.ts +14 -0
  159. package/.medusa/server/src/modules/quote-request/config.js +52 -0
  160. package/.medusa/server/src/modules/quote-request/email.d.ts +17 -0
  161. package/.medusa/server/src/modules/quote-request/email.js +133 -0
  162. package/.medusa/server/src/modules/quote-request/index.d.ts +8 -0
  163. package/.medusa/server/src/modules/quote-request/index.js +23 -0
  164. package/.medusa/server/src/modules/quote-request/migrations/Migration20261029160000.d.ts +5 -0
  165. package/.medusa/server/src/modules/quote-request/migrations/Migration20261029160000.js +20 -0
  166. package/.medusa/server/src/modules/quote-request/models/quote-request.d.ts +24 -0
  167. package/.medusa/server/src/modules/quote-request/models/quote-request.js +54 -0
  168. package/.medusa/server/src/modules/quote-request/service.d.ts +32 -0
  169. package/.medusa/server/src/modules/quote-request/service.js +12 -0
  170. package/.medusa/server/src/modules/seo/models/seo-page.js +5 -5
  171. package/.medusa/server/src/modules/seo/sitemap.js +44 -10
  172. package/.medusa/server/src/modules/seo/structured-data.d.ts +1 -1
  173. package/.medusa/server/src/modules/seo/structured-data.js +41 -25
  174. package/.medusa/server/src/modules/seo/technical.d.ts +7 -2
  175. package/.medusa/server/src/modules/seo/technical.js +45 -6
  176. package/.medusa/server/src/modules/seo/types.d.ts +2 -0
  177. package/.medusa/server/src/modules/wishlist/index.d.ts +5 -0
  178. package/.medusa/server/src/modules/wishlist/index.js +14 -0
  179. package/.medusa/server/src/modules/wishlist/migrations/Migration20261030160000.d.ts +5 -0
  180. package/.medusa/server/src/modules/wishlist/migrations/Migration20261030160000.js +17 -0
  181. package/.medusa/server/src/modules/wishlist/models/wishlist-item.d.ts +6 -0
  182. package/.medusa/server/src/modules/wishlist/models/wishlist-item.js +14 -0
  183. package/.medusa/server/src/modules/wishlist/service.d.ts +15 -0
  184. package/.medusa/server/src/modules/wishlist/service.js +12 -0
  185. package/.medusa/server/src/scripts/ensure-locales.d.ts +2 -0
  186. package/.medusa/server/src/scripts/ensure-locales.js +34 -0
  187. package/.medusa/server/src/scripts/ensure-shipping.d.ts +3 -0
  188. package/.medusa/server/src/scripts/ensure-shipping.js +211 -0
  189. package/.medusa/server/src/scripts/verify-bootstrap.js +19 -2
  190. package/.medusa/server/src/subscribers/quote-request-order-placed.d.ts +7 -0
  191. package/.medusa/server/src/subscribers/quote-request-order-placed.js +27 -0
  192. package/package.json +3 -2
@@ -0,0 +1,26 @@
1
+ export declare const LEAD_STATUSES: readonly ["new", "contacted", "qualified", "won", "lost", "spam", "closed"];
2
+ declare const Lead: import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
3
+ id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
4
+ form_key: import("@medusajs/framework/utils").TextProperty;
5
+ status: import("@medusajs/framework/utils").EnumProperty<["new", "contacted", "qualified", "won", "lost", "spam", "closed"]>;
6
+ name: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
7
+ email: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
8
+ phone: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
9
+ company: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
10
+ message: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
11
+ fields: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
12
+ source: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
13
+ page_url: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
14
+ referrer: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
15
+ utm: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
16
+ customer_id: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
17
+ admin_note: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
18
+ privacy_consent_at: import("@medusajs/framework/utils").NullableModifier<Date, import("@medusajs/framework/utils").DateTimeProperty>;
19
+ privacy_policy_version: import("@medusajs/framework/utils").TextProperty;
20
+ privacy_policy_url: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
21
+ privacy_policy_label: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
22
+ request_fingerprint: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
23
+ spam_score: import("@medusajs/framework/utils").NumberProperty;
24
+ spam_reasons: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
25
+ }>, "lead">;
26
+ export default Lead;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LEAD_STATUSES = void 0;
4
+ const utils_1 = require("@medusajs/framework/utils");
5
+ exports.LEAD_STATUSES = [
6
+ "new",
7
+ "contacted",
8
+ "qualified",
9
+ "won",
10
+ "lost",
11
+ "spam",
12
+ "closed",
13
+ ];
14
+ const Lead = utils_1.model.define("lead", {
15
+ id: utils_1.model.id().primaryKey(),
16
+ form_key: utils_1.model.text(),
17
+ status: utils_1.model.enum([
18
+ "new",
19
+ "contacted",
20
+ "qualified",
21
+ "won",
22
+ "lost",
23
+ "spam",
24
+ "closed",
25
+ ]),
26
+ name: utils_1.model.text().nullable(),
27
+ email: utils_1.model.text().nullable(),
28
+ phone: utils_1.model.text().nullable(),
29
+ company: utils_1.model.text().nullable(),
30
+ message: utils_1.model.text().nullable(),
31
+ fields: utils_1.model.json().nullable(),
32
+ source: utils_1.model.text().nullable(),
33
+ page_url: utils_1.model.text().nullable(),
34
+ referrer: utils_1.model.text().nullable(),
35
+ utm: utils_1.model.json().nullable(),
36
+ customer_id: utils_1.model.text().nullable(),
37
+ admin_note: utils_1.model.text().nullable(),
38
+ privacy_consent_at: utils_1.model.dateTime().nullable(),
39
+ privacy_policy_version: utils_1.model.text(),
40
+ privacy_policy_url: utils_1.model.text().nullable(),
41
+ privacy_policy_label: utils_1.model.text().nullable(),
42
+ request_fingerprint: utils_1.model.text().nullable(),
43
+ spam_score: utils_1.model.number().default(0),
44
+ spam_reasons: utils_1.model.json().nullable(),
45
+ }).indexes([
46
+ { on: ["status", "created_at"] },
47
+ { on: ["form_key", "created_at"] },
48
+ { on: ["email", "created_at"] },
49
+ { on: ["customer_id"] },
50
+ { on: ["request_fingerprint", "created_at"] },
51
+ ]);
52
+ exports.default = Lead;
53
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGVhZC5qcyIs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tJQUNsQyxFQUFFLEVBQUUsRUFBRSxDQUFDLE9BQU8sRUFBRSxZQUFZLENBQUMsRUFBRTtJQUMvQixFQUFFLEVBQUUsRUFBRSxDQUFDLGFBQWEsQ0FBQyxFQUFFO0lBQ3ZCLEVBQUUsRUFBRSxFQUFFLENBQUMscUJBQXFCLEVBQUUsWUFBWSxDQUFDLEVBQUU7Q0FDOUMsQ0FBQyxDQUFBO0FBRUYsa0JBQWUsSUFBSSxDQUFBIn0=
@@ -0,0 +1,29 @@
1
+ declare const LeadService_base: import("@medusajs/framework/utils").MedusaServiceReturnType<import("@medusajs/framework/utils").ModelConfigurationsToConfigTemplate<{
2
+ readonly Lead: import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
3
+ id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
4
+ form_key: import("@medusajs/framework/utils").TextProperty;
5
+ status: import("@medusajs/framework/utils").EnumProperty<["new", "contacted", "qualified", "won", "lost", "spam", "closed"]>;
6
+ name: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
7
+ email: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
8
+ phone: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
9
+ company: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
10
+ message: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
11
+ fields: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
12
+ source: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
13
+ page_url: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
14
+ referrer: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
15
+ utm: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
16
+ customer_id: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
17
+ admin_note: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
18
+ privacy_consent_at: import("@medusajs/framework/utils").NullableModifier<Date, import("@medusajs/framework/utils").DateTimeProperty>;
19
+ privacy_policy_version: import("@medusajs/framework/utils").TextProperty;
20
+ privacy_policy_url: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
21
+ privacy_policy_label: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
22
+ request_fingerprint: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
23
+ spam_score: import("@medusajs/framework/utils").NumberProperty;
24
+ spam_reasons: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
25
+ }>, "lead">;
26
+ }>>;
27
+ declare class LeadService extends LeadService_base {
28
+ }
29
+ export default LeadService;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("@medusajs/framework/utils");
7
+ const lead_1 = __importDefault(require("./models/lead"));
8
+ class LeadService extends (0, utils_1.MedusaService)({ Lead: lead_1.default }) {
9
+ }
10
+ exports.default = LeadService;
11
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9tb2R1bGVzL2xlYWQvc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLHFEQUF5RDtBQUN6RCx5REFBZ0M7QUFFaEMsTUFBTSxXQUFZLFNBQVEsSUFBQSxxQkFBYSxFQUFDLEVBQUUsSUFBSSxFQUFKLGNBQUksRUFBRSxDQUFDO0NBQUc7QUFFcEQsa0JBQWUsV0FBVyxDQUFBIn0=
@@ -0,0 +1,24 @@
1
+ export type SpamAssessment = {
2
+ score: number;
3
+ reasons: string[];
4
+ spam: boolean;
5
+ };
6
+ type RateLimitInput = {
7
+ fingerprint: string | null;
8
+ email?: string | null;
9
+ max: number;
10
+ windowSeconds: number;
11
+ };
12
+ export declare function clientFingerprint(headers: Record<string, unknown>, secret?: string): string | null;
13
+ export declare function assessLeadSpam(input: {
14
+ honeypotValue?: unknown;
15
+ formStartedAt?: unknown;
16
+ now?: number;
17
+ }): SpamAssessment;
18
+ export declare function checkLeadRateLimit(input: RateLimitInput): Promise<boolean>;
19
+ export declare function verifyTurnstile(input: {
20
+ token?: string | null;
21
+ secretKey?: string | null;
22
+ remoteIp?: string | null;
23
+ }): Promise<boolean>;
24
+ export {};
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.clientFingerprint = clientFingerprint;
7
+ exports.assessLeadSpam = assessLeadSpam;
8
+ exports.checkLeadRateLimit = checkLeadRateLimit;
9
+ exports.verifyTurnstile = verifyTurnstile;
10
+ const node_crypto_1 = require("node:crypto");
11
+ const ioredis_1 = __importDefault(require("ioredis"));
12
+ const memoryCounters = new Map();
13
+ let redis;
14
+ function clientFingerprint(headers, secret = process.env.LEAD_SPAM_HASH_SECRET || process.env.COOKIE_SECRET || "hszrdm-lead") {
15
+ const raw = firstHeader(headers["cf-connecting-ip"]) || firstHeader(headers["x-forwarded-for"])?.split(",")[0]?.trim() || firstHeader(headers["x-real-ip"]);
16
+ if (!raw)
17
+ return null;
18
+ return (0, node_crypto_1.createHmac)("sha256", secret).update(raw).digest("hex");
19
+ }
20
+ function assessLeadSpam(input) {
21
+ const reasons = [];
22
+ let score = 0;
23
+ if (typeof input.honeypotValue === "string" && input.honeypotValue.trim()) {
24
+ score += 100;
25
+ reasons.push("honeypot");
26
+ }
27
+ const started = typeof input.formStartedAt === "string" || typeof input.formStartedAt === "number"
28
+ ? new Date(input.formStartedAt).getTime()
29
+ : NaN;
30
+ const now = input.now ?? Date.now();
31
+ if (Number.isFinite(started) && now - started >= 0 && now - started < 1500) {
32
+ score += 30;
33
+ reasons.push("too_fast");
34
+ }
35
+ return { score, reasons, spam: score >= 100 };
36
+ }
37
+ async function checkLeadRateLimit(input) {
38
+ const identities = [
39
+ input.fingerprint ? `ip:${input.fingerprint}` : null,
40
+ input.email ? `email:${(0, node_crypto_1.createHash)("sha256").update(input.email.trim().toLowerCase()).digest("hex")}` : null,
41
+ ].filter((value) => Boolean(value));
42
+ for (const identity of identities) {
43
+ const allowed = await increment(identity, input.max, input.windowSeconds);
44
+ if (!allowed)
45
+ return false;
46
+ }
47
+ return true;
48
+ }
49
+ async function verifyTurnstile(input) {
50
+ if (!input.secretKey)
51
+ return true;
52
+ if (!input.token)
53
+ return false;
54
+ const body = new URLSearchParams({ secret: input.secretKey, response: input.token });
55
+ if (input.remoteIp)
56
+ body.set("remoteip", input.remoteIp);
57
+ const response = await fetch("https://challenges.cloudflare.com/turnstile/v0/siteverify", {
58
+ method: "POST",
59
+ headers: { "content-type": "application/x-www-form-urlencoded" },
60
+ body,
61
+ signal: AbortSignal.timeout(8000),
62
+ });
63
+ if (!response.ok)
64
+ return false;
65
+ const payload = await response.json();
66
+ return payload.success === true;
67
+ }
68
+ function firstHeader(value) {
69
+ if (Array.isArray(value))
70
+ return value.length ? String(value[0]) : null;
71
+ if (typeof value === "string")
72
+ return value;
73
+ return null;
74
+ }
75
+ async function increment(identity, max, windowSeconds) {
76
+ const redisClient = getRedis();
77
+ const key = `hszrdm:lead-rate:${identity}`;
78
+ if (redisClient) {
79
+ try {
80
+ const count = await redisClient.incr(key);
81
+ if (count === 1)
82
+ await redisClient.expire(key, windowSeconds);
83
+ return count <= max;
84
+ }
85
+ catch {
86
+ // Fall back to the local process counter when Redis is unavailable.
87
+ }
88
+ }
89
+ const now = Date.now();
90
+ const current = memoryCounters.get(key);
91
+ if (!current || current.expiresAt <= now) {
92
+ memoryCounters.set(key, { count: 1, expiresAt: now + windowSeconds * 1000 });
93
+ return true;
94
+ }
95
+ current.count += 1;
96
+ return current.count <= max;
97
+ }
98
+ function getRedis() {
99
+ if (redis !== undefined)
100
+ return redis;
101
+ const url = process.env.REDIS_URL?.trim();
102
+ if (!url) {
103
+ redis = null;
104
+ return redis;
105
+ }
106
+ redis = new ioredis_1.default(url, {
107
+ lazyConnect: true,
108
+ maxRetriesPerRequest: 1,
109
+ enableOfflineQueue: false,
110
+ });
111
+ redis.connect().catch(() => undefined);
112
+ return redis;
113
+ }
114
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3BhbS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9tb2R1bGVzL2xlYWQvc3BhbS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQW1CQSw4Q0FJQztBQUVELHdDQW9CQztBQUVELGdEQVdDO0FBRUQsMENBa0JDO0FBOUVELDZDQUFvRDtBQUNwRCxzREFBMkI7QUFlM0IsTUFBTSxjQUFjLEdBQUcsSUFBSSxHQUFHLEVBQWdELENBQUE7QUFDOUUsSUFBSSxLQUErQixDQUFBO0FBRW5DLFNBQWdCLGlCQUFpQixDQUFDLE9BQWdDLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUMscUJBQXFC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2QsQ0FBQyJ9
@@ -0,0 +1,14 @@
1
+ export type NewsletterConfig = {
2
+ enabled: boolean;
3
+ doubleOptIn: boolean;
4
+ emailEnabled: boolean;
5
+ consentVersion: string;
6
+ consentUrl: string | null;
7
+ confirmationTtlHours: number;
8
+ storefrontUrl: string;
9
+ confirmPath: string;
10
+ unsubscribePath: string;
11
+ };
12
+ export declare function loadNewsletterConfig(): NewsletterConfig;
13
+ export declare function newsletterConfirmUrl(token: string, config?: NewsletterConfig): string;
14
+ export declare function newsletterUnsubscribeUrl(token: string, config?: NewsletterConfig): string;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadNewsletterConfig = loadNewsletterConfig;
4
+ exports.newsletterConfirmUrl = newsletterConfirmUrl;
5
+ exports.newsletterUnsubscribeUrl = newsletterUnsubscribeUrl;
6
+ function loadNewsletterConfig() {
7
+ return {
8
+ enabled: process.env.NEWSLETTER_ENABLED !== "false",
9
+ doubleOptIn: process.env.NEWSLETTER_DOUBLE_OPT_IN === "true",
10
+ emailEnabled: process.env.NEWSLETTER_EMAIL_ENABLED !== "false",
11
+ consentVersion: text(process.env.NEWSLETTER_CONSENT_VERSION) || "1",
12
+ consentUrl: nullable(process.env.NEWSLETTER_CONSENT_URL),
13
+ confirmationTtlHours: positiveNumber(process.env.NEWSLETTER_CONFIRM_TTL_HOURS, 72),
14
+ storefrontUrl: normalizeBaseUrl(process.env.STOREFRONT_URL || "http://localhost:3000"),
15
+ confirmPath: normalizePath(process.env.NEWSLETTER_CONFIRM_PATH || "/newsletter/confirm"),
16
+ unsubscribePath: normalizePath(process.env.NEWSLETTER_UNSUBSCRIBE_PATH || "/newsletter/unsubscribe"),
17
+ };
18
+ }
19
+ function newsletterConfirmUrl(token, config = loadNewsletterConfig()) {
20
+ return `${config.storefrontUrl}${config.confirmPath}?token=${encodeURIComponent(token)}`;
21
+ }
22
+ function newsletterUnsubscribeUrl(token, config = loadNewsletterConfig()) {
23
+ return `${config.storefrontUrl}${config.unsubscribePath}?token=${encodeURIComponent(token)}`;
24
+ }
25
+ function normalizeBaseUrl(value) {
26
+ try {
27
+ const url = new URL(value);
28
+ url.hash = "";
29
+ url.search = "";
30
+ return url.toString().replace(/\/$/, "");
31
+ }
32
+ catch {
33
+ return "http://localhost:3000";
34
+ }
35
+ }
36
+ function normalizePath(value) {
37
+ const raw = text(value) || "/";
38
+ return `/${raw.replace(/^\/+/, "")}`.replace(/\/+$/, "") || "/";
39
+ }
40
+ function positiveNumber(value, fallback) {
41
+ const parsed = Number(value);
42
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
43
+ }
44
+ function nullable(value) {
45
+ const result = text(value);
46
+ return result || null;
47
+ }
48
+ function text(value) {
49
+ return typeof value === "string" ? value.trim() : "";
50
+ }
51
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vc3JjL21vZHVsZXMvbmV3c2xldHRlci9jb25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFZQSxvREFZQztBQUVELG9EQUVDO0FBRUQsNERBRUM7QUFwQkQsU0FBZ0Isb0JBQW9CO0lBQ2xDLE9BQU87UUFDTCxPQUFPLEVBQUUsT0FBTyxDQUFDLEdBQUcsQ0FBQyxrQkFBa0IsS0FBSyxPQUFPO1FBQ25ELFdBQVcsRUFBRSxPQUFPLENBQUMsR0FBRyxDQUFDLHdCQUF3QixLQUFLLE1BQU07UUFDNUQsWUFBWSxFQUFFLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLEtBQUssT0FBTztRQUM5RCxjQUFjLEVBQUUsSUFBSSxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsMEJBQTBCLENBQUMsSUFBSSxHQUFHO1FBQ25FLFVBQVUsRUFBRSxRQUFRLEN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FQUFFLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQTtBQUN0RCxDQUFDIn0=
@@ -0,0 +1,9 @@
1
+ export declare function newsletterConfirmationEmail(input: {
2
+ brand: string;
3
+ confirmUrl: string;
4
+ unsubscribeUrl: string;
5
+ }): {
6
+ subject: string;
7
+ text: string;
8
+ html: string;
9
+ };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.newsletterConfirmationEmail = newsletterConfirmationEmail;
4
+ function newsletterConfirmationEmail(input) {
5
+ const subject = `Erősítsd meg a hírlevél-feliratkozást – ${input.brand}`;
6
+ const text = [
7
+ `Köszönjük, hogy feliratkoztál a ${input.brand} hírlevelére.`,
8
+ "",
9
+ "A feliratkozás megerősítéséhez nyisd meg ezt a linket:",
10
+ input.confirmUrl,
11
+ "",
12
+ "Ha nem te kezdeményezted a feliratkozást, nincs teendőd.",
13
+ "",
14
+ `Leiratkozás: ${input.unsubscribeUrl}`,
15
+ ].join("\n");
16
+ const html = `
17
+ <div style="font-family:Arial,sans-serif;line-height:1.6;max-width:640px;margin:0 auto">
18
+ <h2>${escapeHtml(input.brand)} hírlevél</h2>
19
+ <p>Köszönjük, hogy feliratkoztál.</p>
20
+ <p><a href="${escapeAttribute(input.confirmUrl)}" style="display:inline-block;padding:12px 18px;background:#111;color:#fff;text-decoration:none;border-radius:6px">Feliratkozás megerősítése</a></p>
21
+ <p style="color:#666;font-size:13px">Ha nem te kezdeményezted a feliratkozást, nincs teendőd.</p>
22
+ <p style="color:#666;font-size:13px"><a href="${escapeAttribute(input.unsubscribeUrl)}">Leiratkozás</a></p>
23
+ </div>`;
24
+ return { subject, text, html };
25
+ }
26
+ function escapeHtml(value) {
27
+ return value.replace(/[&<>"']/g, (char) => ({
28
+ "&": "&amp;",
29
+ "<": "&lt;",
30
+ ">": "&gt;",
31
+ '"': "&quot;",
32
+ "'": "&#39;",
33
+ })[char] || char);
34
+ }
35
+ function escapeAtt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1FBQ1osR0FBRyxFQUFFLE1BQU07UUFDWCxHQUFHLEVBQUUsTUFBTTtRQUNYLEdBQUcsRUFBRSxRQUFRO1FBQ2IsR0FBRyxFQUFFLE9BQU87S0FDYixDQUFDLENBQUMsSUFBSSxDQUFDLElBQUksSUFBSSxDQUFDLENBQUE7QUFDbkIsQ0FBQztBQUVELFNBQVMsZUFBZSxDQUFDLEtBQWE7SUFDcEMsT0FBTyxVQUFVLENBQUMsS0FBSyxDQUFDLENBQUE7QUFDMUIsQ0FBQyJ9
@@ -0,0 +1,10 @@
1
+ export declare const NEWSLETTER_EVENTS: {
2
+ readonly pending: "newsletter.subscription.pending";
3
+ readonly subscribed: "newsletter.subscription.subscribed";
4
+ readonly unsubscribed: "newsletter.subscription.unsubscribed";
5
+ };
6
+ type ResolveContainer = {
7
+ resolve: (key: string) => unknown;
8
+ };
9
+ export declare function emitNewsletterEvent(container: ResolveContainer, name: (typeof NEWSLETTER_EVENTS)[keyof typeof NEWSLETTER_EVENTS], subscriber: Record<string, any>): Promise<void>;
10
+ export {};
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NEWSLETTER_EVENTS = void 0;
4
+ exports.emitNewsletterEvent = emitNewsletterEvent;
5
+ const utils_1 = require("@medusajs/framework/utils");
6
+ exports.NEWSLETTER_EVENTS = {
7
+ pending: "newsletter.subscription.pending",
8
+ subscribed: "newsletter.subscription.subscribed",
9
+ unsubscribed: "newsletter.subscription.unsubscribed",
10
+ };
11
+ async function emitNewsletterEvent(container, name, subscriber) {
12
+ try {
13
+ const eventBus = container.resolve(utils_1.Modules.EVENT_BUS);
14
+ await eventBus.emit({
15
+ name,
16
+ data: {
17
+ id: subscriber.id,
18
+ email: subscriber.email,
19
+ status: subscriber.status,
20
+ source: subscriber.source || null,
21
+ consent_version: subscriber.consent_version,
22
+ consent_at: subscriber.consent_at || null,
23
+ subscribed_at: subscriber.subscribed_at || null,
24
+ unsubscribed_at: subscriber.unsubscribed_at || null,
25
+ utm: subscriber.utm || null,
26
+ },
27
+ });
28
+ }
29
+ catch {
30
+ // Provider synchronization is downstream work. A missing/unavailable event
31
+ // bus must not roll back the subscriber consent lifecycle itself.
32
+ }
33
+ }
34
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXZlbnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vc3JjL21vZHVsZXMvbmV3c2xldHRlci9ldmVudHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBZ0JBLGtEQXlCQztBQXpDRCxxREFBbUQ7QUFFdEMsUUFBQSxpQkFBaUIsR0FBRztJQUMvQixPQUFPLEVBQUUsaUNBQWlDO0lBQzFDLFVBQVUsRUFBRSxvQ0FBb0M7SUFDaEQsWUFBWSxFQUFFLHNDQUFzQztDQUM1QyxDQUFBO0FBVUgsS0FBSyxVQUFVLG1CQUFtQixDQUN2QyxTQUEyQixFQUMzQixJQUFnRSxFQUNoRSxVQUErQjtJQUUvQixJQUFJLENBQUM7UUFDSCxNQUFNLFFBQVEsR0FBRyxTQUFTLENBQUMsT0FBTyxDQUFDLGVBQU8sQ0FBQyxTQUFTLENBQWEsQ0FBQTtRQUNqRSxNQUFNLFFBQVEsQ0FBQyxJQUFJLENBQUM7WUFDbEIsSUFBSTtZQUNKLElBQUksRUFBRTtnQkFDSixFQUFFLEVBQUUsVUFBVSxDQUFDLEVBQUU7Z0JBQ2pCLEtBQUssRUFBRSxVQUFVLENBQUMsS0FBSztnQkFDdkIsTUFBTSxFQUFFLFVBQVUsQ0FBQyxNQUFNO2dCQUN6QixNQUFNLEVBQUUsVUFBVSxDQUFDLE1BQU0sSUFBSSxJQUFJO2dCQUNqQyxlQUFlLEVBQUUsVUFBVSxDQUFDLGVBQWU7Z0JBQzNDLFVBQVUsRUFBRSxVQUFVLENBQUMsVUFBVSxJQUFJLElBQUk7Z0JBQ3pDLGFBQWEsRUFBRSxVQUFVLENBQUMsYUFBYSxJQUFJLElBQUk7Z0JBQy9DLGVBQWUsRUFBRSxVQUFVLENBQUMsZUFBZSxJQUFJLElBQUk7Z0JBQ25ELEdBQUcsRUFBRSxVQUFVLENBQUMsR0FBRyxJQUFJLElBQUk7YUFDNUI7U0FDRixDQUFDLENBQUE7SUFDSixDQUFDO0lBQUMsTUFBTSxDQUFDO1FBQ1AsMkVBQTJFO1FBQzNFLGtFQUFrRTtJQUNwRSxDQUFDO0FBQ0gsQ0FBQyJ9
@@ -0,0 +1,10 @@
1
+ import NewsletterService from "./service";
2
+ export declare const NEWSLETTER_MODULE = "newsletter";
3
+ declare const _default: any;
4
+ export default _default;
5
+ export { NewsletterService };
6
+ export { NEWSLETTER_STATUSES } from "./models/newsletter-subscriber";
7
+ export { loadNewsletterConfig, newsletterConfirmUrl, newsletterUnsubscribeUrl, type NewsletterConfig, } from "./config";
8
+ export { createNewsletterToken, hashNewsletterToken, createNewsletterUnsubscribeToken, newsletterSubscriberIdFromUnsubscribeToken, verifyNewsletterUnsubscribeToken, normalizeNewsletterEmail, normalizeNewsletterUtm, } from "./token";
9
+ export { newsletterConfirmationEmail } from "./email";
10
+ export { NEWSLETTER_EVENTS, emitNewsletterEvent } from "./events";
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.emitNewsletterEvent = exports.NEWSLETTER_EVENTS = exports.newsletterConfirmationEmail = exports.normalizeNewsletterUtm = exports.normalizeNewsletterEmail = exports.verifyNewsletterUnsubscribeToken = exports.newsletterSubscriberIdFromUnsubscribeToken = exports.createNewsletterUnsubscribeToken = exports.hashNewsletterToken = exports.createNewsletterToken = exports.newsletterUnsubscribeUrl = exports.newsletterConfirmUrl = exports.loadNewsletterConfig = exports.NEWSLETTER_STATUSES = exports.NewsletterService = exports.NEWSLETTER_MODULE = void 0;
7
+ const utils_1 = require("@medusajs/framework/utils");
8
+ const service_1 = __importDefault(require("./service"));
9
+ exports.NewsletterService = service_1.default;
10
+ exports.NEWSLETTER_MODULE = "newsletter";
11
+ exports.default = (0, utils_1.Module)(exports.NEWSLETTER_MODULE, {
12
+ service: service_1.default,
13
+ });
14
+ var newsletter_subscriber_1 = require("./models/newsletter-subscriber");
15
+ Object.defineProperty(exports, "NEWSLETTER_STATUSES", { enumerable: true, get: function () { return newsletter_subscriber_1.NEWSLETTER_STATUSES; } });
16
+ var config_1 = require("./config");
17
+ Object.defineProperty(exports, "loadNewsletterConfig", { enumerable: true, get: function () { return config_1.loadNewsletterConfig; } });
18
+ Object.defineProperty(exports, "newsletterConfirmUrl", { enumerable: true, get: function () { return config_1.newsletterConfirmUrl; } });
19
+ Object.defineProperty(exports, "newsletterUnsubscribeUrl", { enumerable: true, get: function () { return config_1.newsletterUnsubscribeUrl; } });
20
+ var token_1 = require("./token");
21
+ Object.defineProperty(exports, "createNewsletterToken", { enumerable: true, get: function () { return token_1.createNewsletterToken; } });
22
+ Object.defineProperty(exports, "hashNewsletterToken", { enumerable: true, get: function () { return token_1.hashNewsletterToken; } });
23
+ Object.defineProperty(exports, "createNewsletterUnsubscribeToken", { enumerable: true, get: function () { return token_1.createNewsletterUnsubscribeToken; } });
24
+ Object.defineProperty(exports, "newsletterSubscriberIdFromUnsubscribeToken", { enumerable: true, get: function () { return token_1.newsletterSubscriberIdFromUnsubscribeToken; } });
25
+ Object.defineProperty(exports, "verifyNewsletterUnsubscribeToken", { enumerable: true, get: function () { return token_1.verifyNewsletterUnsubscribeToken; } });
26
+ Object.defineProperty(exports, "normalizeNewsletterEmail", { enumerable: true, get: function () { return token_1.normalizeNewsletterEmail; } });
27
+ Object.defineProperty(exports, "normalizeNewsletterUtm", { enumerable: true, get: function () { return token_1.normalizeNewsletterUtm; } });
28
+ var email_1 = require("./email");
29
+ Object.defineProperty(exports, "newsletterConfirmationEmail", { enumerable: true, get: function () { return email_1.newsletterConfirmationEmail; } });
30
+ var events_1 = require("./events");
31
+ Object.defineProperty(exports, "NEWSLETTER_EVENTS", { enumerable: true, get: function () { return events_1.NEWSLETTER_EVENTS; } });
32
+ Object.defineProperty(exports, "emitNewsletterEvent", { enumerable: true, get: function () { return events_1.emitNewsletterEvent; } });
33
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvbW9kdWxlcy9uZXdzbGV0dGVyL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBLHFEQUFrRDtBQUNsRCx3REFBeUM7QUFRaEMsNEJBUkYsaUJBQWlCLENBUUU7QUFOYixRQUFBLGlCQUFpQixHQUFHLFlBQVksQ0FBQTtBQUU3QyxrQkFBZSxJQUFBLGNBQU0sRUFBQyx5QkFBaUIsRUFBRTtJQUN2QyxPQUFPLEVBQUUsaUJBQWlCO0NBQzNCLENBQUMsQ0FBQTtBQUdGLHdFQUFvRTtBQUEzRCw0SEFBQSxtQkFBbUIsT0FBQTtBQUM1QixtQ0FLaUI7QUFKZiw4R0FBQSxvQkFBb0IsT0FBQTtBQUNwQiw4R0FBQSxvQkFBb0IsT0FBQTtBQUNwQixrSEFBQSx3QkFBd0IsT0FBQTtBQUcxQixpQ0FRZ0I7QUFQZCw4R0FBQSxxQkFBcUIsT0FBQTtBQUNyQiw0R0FBQSxtQkFBbUIsT0FBQTtBQUNuQix5SEFBQSxnQ0FBZ0MsT0FBQTtBQUNoQyxtSUFBQSwwQ0FBMEMsT0FBQTtBQUMxQyx5SEFBQSxnQ0FBZ0MsT0FBQTtBQUNoQyxpSEFBQSx3QkFBd0IsT0FBQTtBQUN4QiwrR0FBQSxzQkFBc0IsT0FBQTtBQUV4QixpQ0FBcUQ7QUFBNUMsb0hBQUEsMkJBQTJCLE9BQUE7QUFDcEMsbUNBQWlFO0FBQXhELDJHQUFBLGlCQUFpQixPQUFBO0FBQUUsNkdBQUEsbUJBQW1CLE9BQUEifQ==
@@ -0,0 +1,5 @@
1
+ import { Migration } from "@medusajs/framework/mikro-orm/migrations";
2
+ export declare class Migration20261030130000 extends Migration {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Migration20261030130000 = void 0;
4
+ const migrations_1 = require("@medusajs/framework/mikro-orm/migrations");
5
+ class Migration20261030130000 extends migrations_1.Migration {
6
+ async up() {
7
+ this.addSql(`create table if not exists "newsletter_subscriber" ("id" text not null, "email" text not null, "status" text check ("status" in ('pending','subscribed','unsubscribed')) not null, "source" text null, "page_url" text null, "utm" jsonb null, "consent_at" timestamptz not null, "consent_version" text not null, "consent_url" text null, "double_opt_in" boolean not null default false, "confirmation_token_hash" text null, "confirmation_sent_at" timestamptz null, "confirmation_expires_at" timestamptz null, "confirmed_at" timestamptz null, "subscribed_at" timestamptz null, "unsubscribed_at" timestamptz null, "metadata" jsonb null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "newsletter_subscriber_pkey" primary key ("id"));`);
8
+ this.addSql(`create unique index if not exists "IDX_newsletter_subscriber_email" on "newsletter_subscriber" ("email") where deleted_at is null;`);
9
+ this.addSql(`create index if not exists "IDX_newsletter_subscriber_status_created" on "newsletter_subscriber" ("status", "created_at") where deleted_at is null;`);
10
+ this.addSql(`create index if not exists "IDX_newsletter_subscriber_source_created" on "newsletter_subscriber" ("source", "created_at") where deleted_at is null;`);
11
+ this.addSql(`create unique index if not exists "IDX_newsletter_confirmation_token" on "newsletter_subscriber" ("confirmation_token_hash") where deleted_at is null and confirmation_token_hash is not null;`);
12
+ }
13
+ async down() {
14
+ this.addSql(`drop table if exists "newsletter_subscriber" cascade;`);
15
+ }
16
+ }
17
+ exports.Migration20261030130000 = Migration20261030130000;
18
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWlncmF0aW9uMjAyNjEwMzAxMzAwMDAuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvbW9kdWxlcy9uZXdzbGV0dGVyL21pZ3JhdGlvbnMvTWlncmF0aW9uMjAyNjEwMzAxMzAwMDAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEseUVBQW9FO0FBRXBFLE1BQWEsdUJBQXdCLFNBQVEsc0JBQVM7SUFDcEQsS0FBSyxDQUFDLEVBQUU7UUFDTixJQUFJLENBQUMsTUFBTSxDQUFDLG16QkFBbXpCLENBQUMsQ0FBQTtRQUNoMEIsSUFBSSxDQUFDLE1BQU0sQ0FBQyxvSUFBb0ksQ0FBQyxDQUFBO1FBQ2pKLElBQUksQ0FBQyxNQUFNLENBQUMscUpBQXFKLENBQUMsQ0FBQTtRQUNsSyxJQUFJLENBQUMsTUFBTSxDQUFDLHFKQUFxSixDQUFDLENBQUE7UUFDbEssSUFBSSxDQUFDLE1BQU0sQ0FBQyxnTUFBZ00sQ0FBQyxDQUFBO0lBQy9NLENBQUM7SUFFRCxLQUFLLENBQUMsSUFBSTtRQUNSLElBQUksQ0FBQyxNQUFNLENBQUMsdURBQXVELENBQUMsQ0FBQTtJQUN0RSxDQUFDO0NBQ0Y7QUFaRCwwREFZQyJ9
@@ -0,0 +1,21 @@
1
+ export declare const NEWSLETTER_STATUSES: readonly ["pending", "subscribed", "unsubscribed"];
2
+ declare const NewsletterSubscriber: import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
3
+ id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
4
+ email: import("@medusajs/framework/utils").TextProperty;
5
+ status: import("@medusajs/framework/utils").EnumProperty<["pending", "subscribed", "unsubscribed"]>;
6
+ source: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
7
+ page_url: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
8
+ utm: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
9
+ consent_at: import("@medusajs/framework/utils").DateTimeProperty;
10
+ consent_version: import("@medusajs/framework/utils").TextProperty;
11
+ consent_url: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
12
+ double_opt_in: import("@medusajs/framework/utils").BooleanProperty;
13
+ confirmation_token_hash: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
14
+ confirmation_sent_at: import("@medusajs/framework/utils").NullableModifier<Date, import("@medusajs/framework/utils").DateTimeProperty>;
15
+ confirmation_expires_at: import("@medusajs/framework/utils").NullableModifier<Date, import("@medusajs/framework/utils").DateTimeProperty>;
16
+ confirmed_at: import("@medusajs/framework/utils").NullableModifier<Date, import("@medusajs/framework/utils").DateTimeProperty>;
17
+ subscribed_at: import("@medusajs/framework/utils").NullableModifier<Date, import("@medusajs/framework/utils").DateTimeProperty>;
18
+ unsubscribed_at: import("@medusajs/framework/utils").NullableModifier<Date, import("@medusajs/framework/utils").DateTimeProperty>;
19
+ metadata: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
20
+ }>, "newsletter_subscriber">;
21
+ export default NewsletterSubscriber;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NEWSLETTER_STATUSES = void 0;
4
+ const utils_1 = require("@medusajs/framework/utils");
5
+ exports.NEWSLETTER_STATUSES = [
6
+ "pending",
7
+ "subscribed",
8
+ "unsubscribed",
9
+ ];
10
+ const NewsletterSubscriber = utils_1.model.define("newsletter_subscriber", {
11
+ id: utils_1.model.id().primaryKey(),
12
+ email: utils_1.model.text(),
13
+ status: utils_1.model.enum(["pending", "subscribed", "unsubscribed"]),
14
+ source: utils_1.model.text().nullable(),
15
+ page_url: utils_1.model.text().nullable(),
16
+ utm: utils_1.model.json().nullable(),
17
+ consent_at: utils_1.model.dateTime(),
18
+ consent_version: utils_1.model.text(),
19
+ consent_url: utils_1.model.text().nullable(),
20
+ double_opt_in: utils_1.model.boolean().default(false),
21
+ confirmation_token_hash: utils_1.model.text().nullable(),
22
+ confirmation_sent_at: utils_1.model.dateTime().nullable(),
23
+ confirmation_expires_at: utils_1.model.dateTime().nullable(),
24
+ confirmed_at: utils_1.model.dateTime().nullable(),
25
+ subscribed_at: utils_1.model.dateTime().nullable(),
26
+ unsubscribed_at: utils_1.model.dateTime().nullable(),
27
+ metadata: utils_1.model.json().nullable(),
28
+ }).indexes([
29
+ { on: ["email"], unique: true },
30
+ { on: ["status", "created_at"] },
31
+ { on: ["source", "created_at"] },
32
+ { on: ["confirmation_token_hash"], unique: true },
33
+ ]);
34
+ exports.default = NewsletterSubscriber;
35
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmV3c2xldHRlci1zdWJzY3JpYmVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vc3JjL21vZHVsZXMvbmV3c2xldHRlci9tb2RlbHMvbmV3c2xldHRlci1zdWJzY3JpYmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLHFEQUFpRDtBQUVwQyxRQUFBLG1CQUFtQixHQUFHO0lBQ2pDLFNBQVM7SUFDVCxZQUFZO0lBQ1osY0FBYztDQUNOLENBQUE7QUFFVixNQUFNLG9CQUFvQixHQUFHLGFBQUssQ0FBQyxNQ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BRTtJQUMxQyxlQUFlLEVBQUUsYUFBSyxDQUFDLFFBQVEsRUFBRSxDQUFDLFFBQVEsRUFBRTtJQUM1QyxRQUFRLEVBQUUsYUFBSyxDQUFDLElBQUksRUFBRSxDQUFDLFFBQVEsRUFBRTtDQUNsQyxDQUFDLENBQUMsT0FBTyxDQUFDO0lBQ1QsRUFBRSxFQUFFLEVBQUUsQ0FBQyxPQUFPLENBQUMsRUFBRSxNQUFNLEVBQUUsSUFBSSxFQUFFO0lBQy9CLEVBQUUsRUFBRSxFQUFFLENBQUMsUUFBUSxFQUFFLFlBQVksQ0FBQyxFQUFFO0lBQ2hDLEVBQUUsRUFBRSxFQUFFLENBQUMsUUFBUSxFQUFFLFlBQVksQ0FBQyxFQUFFO0lBQ2hDLEVBQUUsRUFBRSxFQUFFLENBQUMseUJBQXlCLENBQUMsRUFBRSxNQUFNLEVBQUUsSUFBSSxFQUFFO0NBQ2xELENBQUMsQ0FBQTtBQUVGLGtCQUFlLG9CQUFvQixDQUFBIn0=
@@ -0,0 +1,24 @@
1
+ declare const NewsletterService_base: import("@medusajs/framework/utils").MedusaServiceReturnType<import("@medusajs/framework/utils").ModelConfigurationsToConfigTemplate<{
2
+ readonly NewsletterSubscriber: import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
3
+ id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
4
+ email: import("@medusajs/framework/utils").TextProperty;
5
+ status: import("@medusajs/framework/utils").EnumProperty<["pending", "subscribed", "unsubscribed"]>;
6
+ source: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
7
+ page_url: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
8
+ utm: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
9
+ consent_at: import("@medusajs/framework/utils").DateTimeProperty;
10
+ consent_version: import("@medusajs/framework/utils").TextProperty;
11
+ consent_url: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
12
+ double_opt_in: import("@medusajs/framework/utils").BooleanProperty;
13
+ confirmation_token_hash: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
14
+ confirmation_sent_at: import("@medusajs/framework/utils").NullableModifier<Date, import("@medusajs/framework/utils").DateTimeProperty>;
15
+ confirmation_expires_at: import("@medusajs/framework/utils").NullableModifier<Date, import("@medusajs/framework/utils").DateTimeProperty>;
16
+ confirmed_at: import("@medusajs/framework/utils").NullableModifier<Date, import("@medusajs/framework/utils").DateTimeProperty>;
17
+ subscribed_at: import("@medusajs/framework/utils").NullableModifier<Date, import("@medusajs/framework/utils").DateTimeProperty>;
18
+ unsubscribed_at: import("@medusajs/framework/utils").NullableModifier<Date, import("@medusajs/framework/utils").DateTimeProperty>;
19
+ metadata: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
20
+ }>, "newsletter_subscriber">;
21
+ }>>;
22
+ declare class NewsletterService extends NewsletterService_base {
23
+ }
24
+ export default NewsletterService;