@codee-sh/medusa-plugin-notification-emails 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/.medusa/server/emails-previews/contact-form.js +22 -0
  2. package/.medusa/server/emails-previews/order-completed.js +44 -0
  3. package/.medusa/server/emails-previews/order-placed.js +43 -0
  4. package/.medusa/server/src/admin/index.js +10002 -0
  5. package/.medusa/server/src/admin/index.mjs +10001 -0
  6. package/.medusa/server/src/admin/lib/sdk.js +15 -0
  7. package/.medusa/server/src/api/admin/notification-plugin/events/route.js +20 -0
  8. package/.medusa/server/src/api/admin/notification-plugin/notifications/route.js +31 -0
  9. package/.medusa/server/src/api/admin/notification-plugin/render-template/route.js +26 -0
  10. package/.medusa/server/src/api/middlewares.js +42 -0
  11. package/.medusa/server/src/hooks/api/events.js +27 -0
  12. package/.medusa/server/src/hooks/api/notifications.js +42 -0
  13. package/.medusa/server/src/hooks/api/orders.js +50 -0
  14. package/.medusa/server/src/hooks/api/preview.js +33 -0
  15. package/.medusa/server/src/subscribers/order-completed.js +99 -0
  16. package/.medusa/server/src/subscribers/order-placed.js +97 -0
  17. package/.medusa/server/src/subscribers/payment-captured.js +86 -0
  18. package/.medusa/server/src/templates/emails/contact-form/index.js +19 -0
  19. package/.medusa/server/src/templates/emails/contact-form/template.js +28 -0
  20. package/.medusa/server/src/templates/emails/contact-form/translations/en.json +16 -0
  21. package/.medusa/server/src/templates/emails/contact-form/translations/index.js +15 -0
  22. package/.medusa/server/src/templates/emails/contact-form/translations/pl.json +12 -0
  23. package/.medusa/server/src/templates/emails/contact-form/types.js +3 -0
  24. package/.medusa/server/src/templates/emails/index.js +98 -0
  25. package/.medusa/server/src/templates/emails/order-completed/index.js +19 -0
  26. package/.medusa/server/src/templates/emails/order-completed/template.js +36 -0
  27. package/.medusa/server/src/templates/emails/order-completed/translations/en.json +25 -0
  28. package/.medusa/server/src/templates/emails/order-completed/translations/index.js +15 -0
  29. package/.medusa/server/src/templates/emails/order-completed/translations/pl.json +25 -0
  30. package/.medusa/server/src/templates/emails/order-completed/types.js +3 -0
  31. package/.medusa/server/src/templates/emails/order-placed/index.js +19 -0
  32. package/.medusa/server/src/templates/emails/order-placed/template.js +36 -0
  33. package/.medusa/server/src/templates/emails/order-placed/translations/en.json +24 -0
  34. package/.medusa/server/src/templates/emails/order-placed/translations/index.js +15 -0
  35. package/.medusa/server/src/templates/emails/order-placed/translations/pl.json +24 -0
  36. package/.medusa/server/src/templates/emails/order-placed/types.js +3 -0
  37. package/.medusa/server/src/templates/emails/types.js +9 -0
  38. package/.medusa/server/src/templates/shared/i18n/index.js +6 -0
  39. package/.medusa/server/src/templates/shared/i18n/languages.js +187 -0
  40. package/.medusa/server/src/templates/shared/i18n/types.js +3 -0
  41. package/.medusa/server/src/templates/shared/i18n/utils.js +186 -0
  42. package/.medusa/server/src/templates/shared/theme/index.js +6 -0
  43. package/.medusa/server/src/templates/shared/theme/presets/default/index.js +36 -0
  44. package/.medusa/server/src/templates/shared/utils/index.js +24 -0
  45. package/.medusa/server/src/utils/addresses.js +67 -0
  46. package/.medusa/server/src/utils/data/countries.js +1763 -0
  47. package/.medusa/server/src/utils/data/country-states.js +1283 -0
  48. package/.medusa/server/src/utils/data/currencies.js +748 -0
  49. package/.medusa/server/src/utils/date.js +26 -0
  50. package/.medusa/server/src/utils/index.js +21 -0
  51. package/.medusa/server/src/utils/money-amount-helpers.js +68 -0
  52. package/.medusa/server/src/utils/payment.js +21 -0
  53. package/.medusa/server/src/utils/plugins.js +20 -0
  54. package/README.md +114 -0
  55. package/package.json +86 -0
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatDate = formatDate;
4
+ const date_fns_1 = require("date-fns");
5
+ const locale_1 = require("date-fns/locale");
6
+ const localeMap = {
7
+ pl: locale_1.pl,
8
+ en: locale_1.enUS,
9
+ "en-US": locale_1.enUS,
10
+ de: locale_1.de,
11
+ };
12
+ function getDateLocale(localeCode = "pl") {
13
+ return localeMap[localeCode] || locale_1.pl;
14
+ }
15
+ function formatDate({ date, includeTime = false, localeCode = "pl", }) {
16
+ const ensuredDate = new Date(date);
17
+ if (isNaN(ensuredDate.getTime())) {
18
+ return "";
19
+ }
20
+ const locale = getDateLocale(localeCode);
21
+ const timeFormat = includeTime ? "p" : "";
22
+ return (0, date_fns_1.format)(ensuredDate, `PP ${timeFormat}`, {
23
+ locale,
24
+ });
25
+ }
26
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0ZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy91dGlscy9kYXRlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBZUEsZ0NBcUJDO0FBcENELHVDQUFpQztBQUNqQyw0Q0FBOEM7QUFHOUMsTUFBTSxTQUFTLEdBQTJCO0lBQ3hDLEVBQUUsRUFBRixXQUFFO0lBQ0YsRUFBRSxFQUFFLGFBQUk7SUFDUixPQUFPLEVBQUUsYUFBSTtJQUNiLEVBQUUsRUFBRixXQUFFO0NBQ0gsQ0FBQTtBQUVELFNBQVMsYUFBYSxDQUFDLGFBQXFCLElBQUk7SUFDOUMsT0FBTyxTQUFTLENBQUMsVUFBVSxDQUFDLElBQUksV0FBRSxDQUFBO0FBQ3BDLENBQUM7QUFFRCxTQUFnQixVQUFVLENBQUMsRUFDekIsSUFBSSxFQUNKLFdBQVcsR0FBRyxLQUFLLEVBQ25CLFVBQVUsR0FBRyxJQUFJLEdBS2xCO0lBQ0MsTUFBTSxXQUFXLEdBQUcsSUFBSSxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUE7SUFFbEMsSUFBSSxLQUFLLENBQUMsV0FBVyxDQUFDLE9BQU8sRUFBRSxDQUFDLEVBQUUsQ0FBQztRQUNqQyxPQUFPLEVBQUUsQ0FBQTtJQUNYLENBQUM7SUFFRCxNQUFNLE1BQU0sR0FBRyxhQUFhLENBQUMsVUFBVSxDQUFDLENBQUE7SUFDeEMsTUFBTSxVQUFVLEdBQUcsV0FBVyxDQUFDLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQTtJQUV6QyxPQUFPLElBQUEsaUJBQU0sRUFBQyxXQUFXLEVBQUUsTUFBTSxVQUFVLEVBQUUsRUFBRTtRQUM3QyxNQUFNO0tBQ1AsQ0FBQyxDQUFBO0FBQ0osQ0FBQyJ9
@@ -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("./date"), exports);
18
+ __exportStar(require("./addresses"), exports);
19
+ __exportStar(require("./money-amount-helpers"), exports);
20
+ __exportStar(require("./payment"), exports);
21
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvdXRpbHMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLHlDQUF1QjtBQUN2Qiw4Q0FBNEI7QUFDNUIseURBQXVDO0FBQ3ZDLDRDQUEwQiJ9
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAmountLessThenRoundingError = exports.getStylizedAmount = exports.getNativeSymbol = exports.getLocaleAmount = exports.getDecimalDigits = void 0;
4
+ const currencies_1 = require("./data/currencies");
5
+ const getDecimalDigits = (currency) => {
6
+ return currencies_1.currencies[currency.toUpperCase()]?.decimal_digits ?? 0;
7
+ };
8
+ exports.getDecimalDigits = getDecimalDigits;
9
+ /**
10
+ * Returns a formatted amount based on the currency code using the browser's locale
11
+ * @param amount - The amount to format
12
+ * @param currencyCode - The currency code to format the amount in
13
+ * @returns - The formatted amount
14
+ *
15
+ * @example
16
+ * getFormattedAmount(10, "usd") // '$10.00' if the browser's locale is en-US
17
+ * getFormattedAmount(10, "usd") // '10,00 $' if the browser's locale is fr-FR
18
+ */
19
+ const getLocaleAmount = (amount, currencyCode) => {
20
+ const formatter = new Intl.NumberFormat([], {
21
+ style: "currency",
22
+ currencyDisplay: "narrowSymbol",
23
+ currency: currencyCode,
24
+ });
25
+ return formatter.format(amount);
26
+ };
27
+ exports.getLocaleAmount = getLocaleAmount;
28
+ const getNativeSymbol = (currencyCode) => {
29
+ const formatted = new Intl.NumberFormat([], {
30
+ style: "currency",
31
+ currency: currencyCode,
32
+ currencyDisplay: "narrowSymbol",
33
+ }).format(0);
34
+ return formatted.replace(/\d/g, "").replace(/[.,]/g, "").trim();
35
+ };
36
+ exports.getNativeSymbol = getNativeSymbol;
37
+ /**
38
+ * In some cases we want to display the amount with the currency code and symbol,
39
+ * in the format of "symbol amount currencyCode". This breaks from the
40
+ * user's locale and is only used in cases where we want to display the
41
+ * currency code and symbol explicitly, e.g. for totals.
42
+ */
43
+ const getStylizedAmount = (amount, currencyCode) => {
44
+ const symbol = (0, exports.getNativeSymbol)(currencyCode);
45
+ const decimalDigits = (0, exports.getDecimalDigits)(currencyCode);
46
+ const lessThanRoundingPrecission = (0, exports.isAmountLessThenRoundingError)(amount, currencyCode);
47
+ const total = amount.toLocaleString(undefined, {
48
+ minimumFractionDigits: decimalDigits,
49
+ maximumFractionDigits: decimalDigits,
50
+ signDisplay: lessThanRoundingPrecission ? "exceptZero" : "auto",
51
+ });
52
+ return `${symbol} ${total} ${currencyCode.toUpperCase()}`;
53
+ };
54
+ exports.getStylizedAmount = getStylizedAmount;
55
+ /**
56
+ * Returns true if the amount is less than the rounding error for the currency
57
+ * @param amount - The amount to check
58
+ * @param currencyCode - The currency code to check the amount in
59
+ * @returns - True if the amount is less than the rounding error, false otherwise
60
+ *
61
+ * For example returns true if amount is < 0.005 for a USD | EUR etc.
62
+ */
63
+ const isAmountLessThenRoundingError = (amount, currencyCode) => {
64
+ const decimalDigits = (0, exports.getDecimalDigits)(currencyCode);
65
+ return Math.abs(amount) < 1 / 10 ** decimalDigits / 2;
66
+ };
67
+ exports.isAmountLessThenRoundingError = isAmountLessThenRoundingError;
68
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9uZXktYW1vdW50LWhlbHBlcnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvdXRpbHMvbW9uZXktYW1vdW50LWhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsa0RBQThDO0FBRXZDLE1BQU0sZ0JBQWdCLEdBQUcsQ0FBQyxRQUFnQixFQUFFLEVBQUU7SUFDbkQsT0FBTyx1QkFBVSxDQUFDLFFBQVEsQ0FBQyxXQUFXLEVBQUUsQ0FBQyxFQUFFLGNBQWMsSUFBSSxDQUFDLENBQUE7QUFDaEUsQ0FBQyxDQUFBO0FBRlksUUFBQSxnQkFBZ0Isb0JBRTVCO0FBRUQ7Ozs7Ozs7OztHQVNHO0FBQ0ksTUFBTSxlQUFlLEdBQUcsQ0FBQyxNQUFjLEVBQUUsWUFBb0IsRUFBRSxFQUFFO0lBQ3RFLE1BQU0sU0FBUyxHQUFHLElBQUksSUFBSSxDQUFDLFlBQVksQ0FBQyxFQUFFLEVBQUU7UUFDMUMsS0FBSyxFQUFFLFVBQVU7UUFDakIsZUFBZSxFQUFFLGNBQWM7UUFDL0IsUUFBUSxFQUFFLFlBQVk7S0FDdkIsQ0FBQyxDQUFBO0lBRUYsT0FBTyxTQUFTLENBQUMsTUFBTSxDQUFDLE1BQU0sQ0FBQyxDQUFBO0FBQ2pDLENBQUMsQ0FBQTtBQVJZLFFBQUEsZUFBZSxtQkFRM0I7QUFFTSxNQUFNLGVBQWUsR0FBRyxDQUFDLFlBQW9CLEVBQUUsRUFBRTtJQUN0RCxNQUFNLFNBQVMsR0FBRyxJQUFJLElBQUksQ0FBQyxZQUFZLENBQUMsRUFBRSxFQUFFO1FBQzFDLEtBQUssRUFBRSxVQUFVO1FBQ2pCLFFBQVEsRUFBRSxZQUFZO1FBQ3RCLGVBQWUsRUFBRSxjQUFjO0tBQ2hDLENBQUMsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUE7SUFFWixPQUFPLFNBQVMsQ0FBQyxPQUFPLENBQUMsS0FBSyxFQUFFLEVBQUUsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxPQUFPLEVBQUUsRUFBRSxDQUFDLENBQUMsSUFBSSxFQUFFLENBQUE7QUFDakUsQ0FBQyxDQUFBO0FBUlksUUFBQSxlQUFlLG1CQVEzQjtBQUVEOzs7OztHQUtHO0FBQ0ksTUFBTSxpQkFBaUIsR0FBRyxDQUFDLE1BQWMsRUFBRSxZQUFvQixFQUFFLEVBQUU7SUFDeEUsTUFBTSxNQUFNLEdBQUcsSUFBQSx1QkFBZSxFQUFDLFlBQVksQ0FBQyxDQUFBO0lBQzVDLE1BQU0sYUFBYSxHQUFHLElBQUEsd0JBQWdCLEVBQUMsWUFBWSxDQUFDLENBQUE7SUFFcEQsTUFBTSwwQkFBMEIsR0FBRyxJQUFBLHFDQUE2QixFQUM5RCxNQUFNLEVBQ04sWUFBWSxDQUNiLENBQUE7SUFFRCxNQUFNLEtBQUssR0FBRyxNQUFNLENBQUMsY0FBYyxDQUFDLFNBQVMsRUFBRTtRQUM3QyxxQkFBcUIsRUFBRSxhQUFhO1FBQ3BDLHFCQUFxQixFQUFFLGFBQWE7UUFDcEMsV0FBVyxFQUFFLDBCQUEwQixDQUFDLENBQUMsQ0FBQyxZQUFZLENBQUMsQ0FBQyxDQUFDLE1BQU07S0FDaEUsQ0FBQyxDQUFBO0lBRUYsT0FBTyxHQUFHLE1BQU0sSUFBSSxLQUFLLElBQUksWUFBWSxDQUFDLFdBQVcsRUFBRSxFQUFFLENBQUE7QUFDM0QsQ0FBQyxDQUFBO0FBaEJZLFFBQUEsaUJBQWlCLHFCQWdCN0I7QUFFRDs7Ozs7OztHQU9HO0FBQ0ksTUFBTSw2QkFBNkIsR0FBRyxDQUMzQyxNQUFjLEVBQ2QsWUFBb0IsRUFDcEIsRUFBRTtJQUNGLE1BQU0sYUFBYSxHQUFHLElBQUEsd0JBQWdCLEVBQUMsWUFBWSxDQUFDLENBQUE7SUFDcEQsT0FBTyxJQUFJLENBQUMsR0FBRyxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsR0FBRyxFQUFFLElBQUksYUFBYSxHQUFHLENBQUMsQ0FBQTtBQUN2RCxDQUFDLENBQUE7QUFOWSxRQUFBLDZCQUE2QixpQ0FNekMifQ==
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTotalPending = exports.getTotalCaptured = void 0;
4
+ const getTotalCaptured = (paymentCollections) => paymentCollections.reduce((acc, paymentCollection) => {
5
+ acc =
6
+ acc +
7
+ (paymentCollection.captured_amount -
8
+ paymentCollection.refunded_amount);
9
+ return acc;
10
+ }, 0);
11
+ exports.getTotalCaptured = getTotalCaptured;
12
+ const getTotalPending = (paymentCollections) => paymentCollections
13
+ .filter((pc) => pc.status !== "canceled")
14
+ .reduce((acc, paymentCollection) => {
15
+ acc +=
16
+ paymentCollection.amount -
17
+ paymentCollection.captured_amount;
18
+ return acc;
19
+ }, 0);
20
+ exports.getTotalPending = getTotalPending;
21
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGF5bWVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy91dGlscy9wYXltZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUVPLE1BQU0sZ0JBQWdCLEdBQUcsQ0FDOUIsa0JBQTRDLEVBQzVDLEVBQUUsQ0FDRixrQkFBa0IsQ0FBQyxNQUFNLENBQUMsQ0FBQyxHQUFHLEVBQUUsaUJBQWlCLEVBQUUsRUFBRTtJQUNuRCxHQUFHO1FBQ0QsR0FBRztZQUNILENBQUUsaUJBQWlCLENBQUMsZUFBMEI7Z0JBQzNDLGlCQUFpQixDQUFDLGVBQTBCLENBQUMsQ0FBQTtJQUNsRCxPQUFPLEdBQUcsQ0FBQTtBQUNaLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQTtBQVRNLFFBQUEsZ0JBQWdCLG9CQVN0QjtBQUVBLE1BQU0sZUFBZSxHQUFHLENBQUMsa0JBQTRDLEVBQUUsRUFBRSxDQUM5RSxrQkFBa0I7S0FDZixNQUFNLENBQUMsQ0FBQyxFQUFFLEVBQUUsRUFBRSxDQUFDLEVBQUUsQ0FBQyxNQUFNLEtBQUssVUFBVSxDQUFDO0tBQ3hDLE1BQU0sQ0FBQyxDQUFDLEdBQUcsRUFBRSxpQkFBaUIsRUFBRSxFQUFFO0lBQ2pDLEdBQUc7UUFDQSxpQkFBaUIsQ0FBQyxNQUFpQjtZQUNuQyxpQkFBaUIsQ0FBQyxlQUEwQixDQUFBO0lBRS9DLE9BQU8sR0FBRyxDQUFBO0FBQ1osQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFBO0FBVEksUUFBQSxlQUFlLG1CQVNuQiJ9
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPluginOptions = getPluginOptions;
4
+ const utils_1 = require("@medusajs/framework/utils");
5
+ function getPluginOptions(container, pluginName) {
6
+ try {
7
+ const configModule = container.resolve(utils_1.ContainerRegistrationKeys.CONFIG_MODULE);
8
+ const plugin = configModule.plugins?.find((p) => {
9
+ if (typeof p === "string") {
10
+ return p === pluginName;
11
+ }
12
+ return p.resolve === pluginName;
13
+ });
14
+ return typeof plugin === "object" ? plugin.options : undefined;
15
+ }
16
+ catch (error) {
17
+ throw error;
18
+ }
19
+ }
20
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy91dGlscy9wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBR0EsNENBYUM7QUFoQkQscURBQXFFO0FBR3JFLFNBQWdCLGdCQUFnQixDQUFDLFNBQTBCLEVBQUUsVUFBa0I7SUFDN0UsSUFBSSxDQUFDO1FBQ0gsTUFBTSxZQUFZLEdBQUcsU0FBUyxDQUFDLE9BQU8sQ0FBQyxpQ0FBeUIsQ0FBQyxhQUFhLENBQUMsQ0FBQTtRQUMvRSxNQUFNLE1BQU0sR0FBRyxZQUFZLENBQUMsT0FBTyxFQUFFLElBQUksQ0FBQyxDQUFDLENBQUMsRUFBRSxFQUFFO1lBQzlDLElBQUksT0FBTyxDQUFDLEtBQUssUUFBUSxFQUFFLENBQUM7Z0JBQzFCLE9BQU8sQ0FBQyxLQUFLLFVBQVUsQ0FBQTtZQUN6QixDQUFDO1lBQ0QsT0FBTyxDQUFDLENBQUMsT0FBTyxLQUFLLFVBQVUsQ0FBQTtRQUNqQyxDQUFDLENBQUMsQ0FBQTtRQUNGLE9BQU8sT0FBTyxNQUFNLEtBQUssUUFBUSxDQUFDLENBQUMsQ0FBQyxNQUFNLENBQUMsT0FBTyxDQUFDLENBQUMsQ0FBQyxTQUFTLENBQUE7SUFDaEUsQ0FBQztJQUFDLE9BQU8sS0FBSyxFQUFFLENBQUM7UUFDZixNQUFNLEtBQUssQ0FBQTtJQUNiLENBQUM7QUFDSCxDQUFDIn0=
package/README.md ADDED
@@ -0,0 +1,114 @@
1
+ # @codee-sh/medusa-plugin-notification
2
+
3
+ A comprehensive notification plugin for Medusa v2 that provides a flexible email template system with internationalization support, custom translations, and seamless integration with Medusa's notification module.
4
+
5
+ ## Features
6
+
7
+ - **Email Templates**: Pre-built, customizable email templates built with [React Email](https://react.email) for common use cases
8
+ - **React Email Integration**: Templates are built using React Email components, providing modern, responsive email design
9
+ - **Internationalization**: Built-in support for multiple locales (Polish, English)
10
+ - **Customizable**: Override translations and customize templates without modifying core files
11
+ - **Integration**: Integrates with Medusa's notification module
12
+ - **Admin Panel**: Preview and test templates directly from Medusa Admin
13
+ - **Type-Safe**: Full TypeScript support with exported types
14
+ - **HTML & Plain Text**: Automatically generates both HTML and plain text versions of emails
15
+
16
+ ## Compatibility
17
+
18
+ - **Medusa Version**: `>= 2.8.8`
19
+ - **Node Version**: `>= 20`
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ npm install @codee-sh/medusa-plugin-notification
25
+ # or
26
+ yarn add @codee-sh/medusa-plugin-notification
27
+ ```
28
+
29
+ ## Quick Start
30
+
31
+ ### 1. Register the Plugin
32
+
33
+ Add to your `medusa-config.ts`:
34
+
35
+ ```typescript
36
+ module.exports = defineConfig({
37
+ plugins: [
38
+ "@codee-sh/medusa-plugin-notification"
39
+ ]
40
+ })
41
+ ```
42
+
43
+ ### 2. Configure Notification Provider
44
+
45
+ Set up a notification provider - see [Configuration Documentation](./docs/configuration.md) for details.
46
+
47
+ ### 3. Use Templates
48
+
49
+ The plugin includes built-in subscribers that automatically send email notifications for various events. You can also use templates directly in your code:
50
+
51
+ ```typescript
52
+ import { renderTemplate, TEMPLATES_NAMES } from "@codee-sh/medusa-plugin-notification/templates/emails"
53
+
54
+ const { html, text, subject } = await renderTemplate(
55
+ TEMPLATES_NAMES.ORDER_PLACED,
56
+ templateData,
57
+ { locale: "pl" }
58
+ )
59
+ ```
60
+
61
+ **Note**: `renderTemplate` is an async function that returns both HTML and plain text versions of the email, generated using React Email.
62
+
63
+ See [Templates Documentation](./docs/templates.md) for detailed usage examples.
64
+
65
+ ## Available Templates
66
+
67
+ - **[Order Placed](./docs/templates/order-placed.md)** (`order-placed`) - Order confirmation email template
68
+ - **[Order Completed](./docs/templates/order-completed.md)** (`order-completed`) - Order completion notification template
69
+ - **[Contact Form](./docs/templates/contact-form.md)** (`contact-form`) - Contact form submission email template
70
+
71
+ See [Templates Documentation](./docs/templates.md) for general template information.
72
+
73
+ ## Built-in Subscribers
74
+
75
+ The plugin includes automatic email notifications for the following events:
76
+
77
+ - **`order.placed`** - Sends order confirmation email when an order is placed
78
+ - **`order.completed`** - Sends order completion notification when an order is completed
79
+
80
+ These subscribers automatically:
81
+ - Fetch order data from Medusa
82
+ - Render email templates using React Email
83
+ - Send notifications via Medusa's notification module
84
+ - Respect custom translations configured in plugin options
85
+
86
+ See [Configuration Documentation](./docs/configuration.md) for details on customizing subscriber behavior.
87
+
88
+ ## Admin Panel
89
+
90
+ Access the template preview in Medusa Admin at `/app/notifications/render`. See [Admin Panel Documentation](./docs/admin.md) for details.
91
+
92
+ ## Documentation
93
+
94
+ - [Templates](./docs/templates.md) - Using templates and creating custom subscribers
95
+ - [Translations](./docs/translations.md) - Internationalization and custom translations
96
+ - [Configuration](./docs/configuration.md) - Plugin configuration options
97
+ - [Admin Panel](./docs/admin.md) - Admin interface usage
98
+ - [Creating Custom Templates](./docs/contributing/creating-templates.md) - Guide for contributing new templates
99
+
100
+ ## Exports
101
+
102
+ The plugin exports the following:
103
+
104
+ - `@codee-sh/medusa-plugin-notification/templates/emails` - Template rendering functions
105
+ - `@codee-sh/medusa-plugin-notification/templates/emails/types` - Template types and constants
106
+ - `@codee-sh/medusa-plugin-notification/utils` - Utility functions
107
+
108
+ ## License
109
+
110
+ MIT
111
+
112
+ ## Author
113
+
114
+ Codee Team - [https://codee.dev](https://codee.dev)
package/package.json ADDED
@@ -0,0 +1,86 @@
1
+ {
2
+ "name": "@codee-sh/medusa-plugin-notification-emails",
3
+ "version": "0.0.1",
4
+ "description": "Medusa plugin for notifications emails.",
5
+ "author": "Codee Team (https://codee.dev)",
6
+ "license": "MIT",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "files": [
11
+ ".medusa/server"
12
+ ],
13
+ "exports": {
14
+ "./package.json": "./package.json",
15
+ "./workflows": "./.medusa/server/src/workflows/index.js",
16
+ "./.medusa/server/src/modules/*": "./.medusa/server/src/modules/*/index.js",
17
+ "./modules/*": "./.medusa/server/src/modules/*/index.js",
18
+ "./providers/*": "./.medusa/server/src/providers/*/index.js",
19
+ "./templates/emails": "./.medusa/server/src/templates/emails/index.js",
20
+ "./templates/emails/*": "./.medusa/server/src/templates/emails/*/index.js",
21
+ "./templates/emails/types": "./.medusa/server/src/templates/emails/types.js",
22
+ "./utils": "./.medusa/server/src/utils/index.js",
23
+ "./*": "./.medusa/server/src/*.js",
24
+ "./admin": {
25
+ "import": "./.medusa/server/src/admin/index.mjs",
26
+ "require": "./.medusa/server/src/admin/index.js",
27
+ "default": "./.medusa/server/src/admin/index.js"
28
+ }
29
+ },
30
+ "keywords": [
31
+ "medusa",
32
+ "plugin",
33
+ "medusa-plugin-notification-emails",
34
+ "medusa-plugin",
35
+ "medusa-v2"
36
+ ],
37
+ "scripts": {
38
+ "build": "medusa plugin:build",
39
+ "dev": "medusa plugin:develop",
40
+ "prepublishOnly": "medusa plugin:build",
41
+ "publish-local": "npx medusa plugin:publish",
42
+ "publish-package": "dotenv npm publish --access public",
43
+ "email:dev": "email dev --dir emails-previews"
44
+ },
45
+ "dependencies": {
46
+ "@react-email/components": "^0.3.3",
47
+ "@react-email/preview-server": "^4.2.5",
48
+ "@react-email/render": "^1.1.4",
49
+ "react-email": "^4.2.5"
50
+ },
51
+ "devDependencies": {
52
+ "@medusajs/admin-sdk": "2.8.8",
53
+ "@medusajs/cli": "2.8.8",
54
+ "@medusajs/framework": "2.8.8",
55
+ "@medusajs/icons": "2.8.8",
56
+ "@medusajs/medusa": "2.8.8",
57
+ "@medusajs/test-utils": "2.8.8",
58
+ "@medusajs/ui": "^4.0.9",
59
+ "@mikro-orm/core": "6.4.3",
60
+ "@mikro-orm/knex": "6.4.3",
61
+ "@mikro-orm/migrations": "6.4.3",
62
+ "@mikro-orm/postgresql": "6.4.3",
63
+ "@react-email/components": "^0.3.3",
64
+ "@react-email/preview-server": "^4.2.5",
65
+ "@react-email/render": "^1.1.4",
66
+ "@swc/core": "1.5.7",
67
+ "@types/node": "^20.0.0",
68
+ "@types/react": "^18.3.2",
69
+ "@types/react-dom": "^18.2.25",
70
+ "react-i18next": "^15.0.0",
71
+ "awilix": "^8.0.1",
72
+ "dotenv": "^17.2.3",
73
+ "prop-types": "^15.8.1",
74
+ "react": "^18.2.0",
75
+ "react-dom": "^18.2.0",
76
+ "react-email": "^4.2.5",
77
+ "ts-node": "^10.9.2",
78
+ "typescript": "^5.6.2",
79
+ "vite": "^5.2.11",
80
+ "yalc": "^1.0.0-pre.53"
81
+ },
82
+ "engines": {
83
+ "node": ">=20"
84
+ },
85
+ "packageManager": "yarn@3.2.3+sha512.f26f951f67de0c6a33ee381e5ff364709c87e70eb5e65c694e4facde3512f1fa80b8679e6ba31ce7d340fbb46f08dd683af9457e240f25a204be7427940d767e"
86
+ }