medusa-plugin-ses 2.2.3 → 3.0.0-canary.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.
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ const widgetModule = { widgets: [] };
3
+ const routeModule = {
4
+ routes: []
5
+ };
6
+ const menuItemModule = {
7
+ menuItems: []
8
+ };
9
+ const formModule = { customFields: {} };
10
+ const displayModule = {
11
+ displays: {}
12
+ };
13
+ const i18nModule = { resources: {} };
14
+ const plugin = {
15
+ widgetModule,
16
+ routeModule,
17
+ menuItemModule,
18
+ formModule,
19
+ displayModule,
20
+ i18nModule
21
+ };
22
+ module.exports = plugin;
@@ -0,0 +1,23 @@
1
+ const widgetModule = { widgets: [] };
2
+ const routeModule = {
3
+ routes: []
4
+ };
5
+ const menuItemModule = {
6
+ menuItems: []
7
+ };
8
+ const formModule = { customFields: {} };
9
+ const displayModule = {
10
+ displays: {}
11
+ };
12
+ const i18nModule = { resources: {} };
13
+ const plugin = {
14
+ widgetModule,
15
+ routeModule,
16
+ menuItemModule,
17
+ formModule,
18
+ displayModule,
19
+ i18nModule
20
+ };
21
+ export {
22
+ plugin as default
23
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("@medusajs/framework/utils");
4
+ const providers_1 = require("../providers");
5
+ exports.default = (0, utils_1.ModuleProvider)(utils_1.Modules.NOTIFICATION, {
6
+ services: [providers_1.SesNotificationProvider]
7
+ });
8
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvbW9kdWxlcy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLHFEQUFtRTtBQUNuRSw0Q0FBc0Q7QUFFdEQsa0JBQWUsSUFBQSxzQkFBYyxFQUFDLGVBQU8sQ0FBQyxZQUFZLEVBQUU7SUFDbkQsUUFBUSxFQUFFLENBQUMsbUNBQXVCLENBQUM7Q0FDbkMsQ0FBQyxDQUFBIn0=
@@ -0,0 +1,95 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.SesNotificationProvider = void 0;
37
+ const utils_1 = require("@medusajs/framework/utils");
38
+ const client_sesv2_1 = require("@aws-sdk/client-sesv2");
39
+ const nodemailer = __importStar(require("nodemailer"));
40
+ const SesError = (type, message) => {
41
+ return new utils_1.MedusaError(type, `SES Notification Provider: ${message}`);
42
+ };
43
+ class SesNotificationProvider extends utils_1.AbstractNotificationProviderService {
44
+ constructor(container, options) {
45
+ super();
46
+ this.logger_ = container.logger;
47
+ this.options_ = options;
48
+ this.sesClient = new client_sesv2_1.SESv2Client({
49
+ ...this.options_.sesClientConfig,
50
+ apiVersion: '2010-12-01'
51
+ });
52
+ this.transporter = nodemailer.createTransport({
53
+ SES: { sesClient: this.sesClient, SendEmailCommand: client_sesv2_1.SendEmailCommand }
54
+ });
55
+ }
56
+ async send(notification) {
57
+ if (!notification) {
58
+ throw SesError('INVALID_ARGUMENT', `Notification is not defined`);
59
+ }
60
+ if (notification.channel !== 'email') {
61
+ throw SesError('INVALID_ARGUMENT', `Notification is for channel email, got ${notification.channel}`);
62
+ }
63
+ if (!notification.content) {
64
+ throw SesError('INVALID_DATA', `Notification has no content`);
65
+ }
66
+ let { subject, text, html } = notification.content;
67
+ const attachments = notification.attachments?.map(at => ({
68
+ cid: at.id,
69
+ filename: at.filename,
70
+ content: at.content,
71
+ contentType: at.content_type,
72
+ encoding: 'base64',
73
+ contentDisposition: at.disposition
74
+ })) ?? [];
75
+ let mailOptions = {
76
+ from: notification.from || this.options_.from,
77
+ to: notification.to,
78
+ subject,
79
+ text,
80
+ html,
81
+ attachments
82
+ };
83
+ try {
84
+ const response = await this.transporter.sendMail(mailOptions);
85
+ return { id: response.messageId };
86
+ }
87
+ catch (e) {
88
+ const message = e instanceof Error ? e.message : 'unknown';
89
+ throw SesError('UNEXPECTED_STATE', `Failed to send email: ${message}`);
90
+ }
91
+ }
92
+ }
93
+ exports.SesNotificationProvider = SesNotificationProvider;
94
+ SesNotificationProvider.identifier = 'ses';
95
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvcHJvdmlkZXJzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs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UFDLFFBQVEsQ0FBQyxXQUFXLENBQUMsQ0FBQTtZQUM3RCxPQUFPLEVBQUUsRUFBRSxFQUFFLFFBQVEsQ0FBQyxTQUFTLEVBQUUsQ0FBQTtRQUNsQyxDQUFDO1FBQUMsT0FBTyxDQUFVLEVBQUUsQ0FBQztZQUNyQixNQUFNLE9BQU8sR0FBRyxDQUFDLFlBQVksS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsT0FBTyxDQUFDLENBQUMsQ0FBQyxTQUFTLENBQUE7WUFDMUQsTUFBTSxRQUFRLENBQUMsa0JBQWtCLEVBQUUseUJBQXlCLE9BQU8sRUFBRSxDQUFDLENBQUE7UUFDdkUsQ0FBQztJQUNGLENBQUM7O0FBdkVGLDBEQXdFQztBQXZFTyxrQ0FBVSxHQUFHLEtBQUssQ0FBQSJ9
package/README.md CHANGED
@@ -1,170 +1 @@
1
- # medusa-plugin-ses
2
1
 
3
- Notifications plugin for Medusa ecommerce server that sends transactional emails via AWS SES (Simple Email Service).
4
-
5
- [Documentation](https://pevey.com/medusa-plugin-ses)
6
-
7
- If you are not familiar with Medusa, you can learn more on [the project web site](https://www.medusajs.com/).
8
-
9
- > Medusa is a set of commerce modules and tools that allow you to build rich, reliable, and performant commerce applications without reinventing core commerce logic. The modules can be customized and used to build advanced ecommerce stores, marketplaces, or any product that needs foundational commerce primitives. All modules are open-source and freely available on npm.
10
-
11
- ## Features
12
-
13
- - Templates are stored locally.
14
- - Templates are based on handlebars, so they are compatible with Sendgrid email templates
15
- - You can refer to the Medusa template reference to see all data fields that are available for each event: [Template Reference](https://docs.medusajs.com/plugins/notifications/sendgrid#template-reference)
16
- - An API endpoint that is useful for testing and that can be used with other (non-Medusa) portions of your storefront application is included. By default, the endpoint does nothing for security reasons. See configuration options below to enable it.
17
-
18
- ## Installation
19
-
20
- Inside your medusa backend root folder, type:
21
-
22
- ```bash
23
- yarn add medusa-plugin-ses
24
- ```
25
-
26
- Replace "yarn add" with the correct command for your package manager if you are using (for example) npm, pnpm, or bun.
27
-
28
- ## Configuration
29
-
30
- Enable in your medusa-config.js file similar to other plugins:
31
-
32
- ```bash
33
- {
34
- resolve: `medusa-plugin-ses`,
35
- options: {
36
- access_key_id: process.env.SES_ACCESS_KEY_ID,
37
- secret_access_key: process.env.SES_SECRET_ACCESS_KEY,
38
- region: process.env.SES_REGION,
39
- from: process.env.SES_FROM,
40
- enable_endpoint: process.env.SES_ENABLE_ENDPOINT,
41
- enable_sim_mode: process.env.SES_ENABLE_SIM_MODE,
42
- template_path: process.env.SES_TEMPLATE_PATH,
43
- partial_path: process.env.SES_PARTIAL_PATH,
44
- order_placed_template: 'order_placed',
45
- order_placed_cc: 'person1@example.com,person2@example.com', // string, email address separated by comma
46
- order_shipped_template: 'order_shipped',
47
- customer_password_reset_template: 'customer_password_reset',
48
- gift_card_created_template: 'gift_card_created',
49
- //order_canceled_template: 'order_canceled',
50
- //order_refund_created_template: 'order_refund_created',
51
- //order_return_requested_template: 'order_return_requested',
52
- //order_items_returned_template: 'order_items_returned',
53
- //swap_created_template: 'swap_created',
54
- //swap_shipment_created_template: 'swap_shipment_created',
55
- //swap_received_template: 'swap_received',
56
- //claim_shipment_created_template: 'claim_shipment_created',
57
- //user_password_reset_template: 'user_password_reset',
58
- //medusa_restock_template: 'medusa_restock',
59
- }
60
- },
61
- ```
62
-
63
- The credentials and region are pulled from env variables.
64
-
65
- ```bash
66
- SES_REGION=""
67
- SES_ACCESS_KEY_ID=""
68
- SES_SECRET_ACCESS_KEY=""
69
- SES_FROM="Cool Company <orders@example.com>"
70
- SES_TEMPLATE_PATH="data/templates"
71
- SES_PARTIAL_PATH="data/partials"
72
- SES_ENABLE_ENDPOINT=""
73
- SES_ENABLE_SIM_MODE=""
74
- ```
75
-
76
- - SES_REGION will be for example "us-east-1"
77
-
78
- - Obtain the access key id and secret access key by creating an IAM user with SES send permissions.
79
-
80
- - The SES_FROM email address must be a verified sender in your AWS account.
81
-
82
- - From version 2.0.8 and on, SES_TEMPLATE_PATH can be absolute (starting with '/', e.g., '/home/pevey/www/medusa/data/templates') or relative (e.g., 'data/templates')
83
-
84
- - Partials are optional and supported in plugin versions 2.1.0 or later. Any partials with the .hbs file extension that are located in the configured partials directory will be registered and available for use in templates. For more information about Handlebars partials and how to use them in your templates, see the [Handlebars documentation](https://handlebarsjs.com/guide/partials.html).
85
-
86
- - See the "Testing" section below for important info on enabling the endpoint and enabling simulation mode for the endpoint.
87
-
88
- Remember that the from email address must be a verified sender in your AWS console.
89
- Also remember that if your AWS account is still in sandbox mode, you can only SEND emails to verified sender email addresses.
90
-
91
- ## Templates
92
-
93
- The templates used are stored locally. Create a 'data/templates' folder and include the entire path in the SES_TEMPLATE_PATH variable.
94
-
95
- ```bash
96
- medusa-server // root directory
97
- |-data
98
- |-templates
99
- |-order_placed // or whatever you name your templates and specify in the config file
100
- |-subject.hbs
101
- |-html.hbs
102
- |-text.hbs
103
- |-gift_card_created
104
- |-subject.hbs
105
- |-html.hbs
106
- |-text.hbs
107
- |- etc
108
- ```
109
-
110
- When emails are sent, each of the three parts will be compiled.
111
-
112
- - Subject is required
113
- - Either html or text is required, but one or the other can be blank.
114
- - From version 2.0.8 on, if either the html.hbs or text.hbs does not exist, no error will be thrown so long as the other exists.
115
-
116
- ## Dynamic Usage
117
-
118
- You can resolve the service to send emails from your custom services or other resources. For example:
119
-
120
- ```js
121
- const sesService = scope.resolve("sesService")
122
-
123
- const sendOptions = {
124
- templateId: "d-123....",
125
- from: "ACME <acme@mail.com>",
126
- to: "customer@mail.com",
127
- data: {}
128
- }
129
-
130
- sesService.sendEmail(sendOptions)
131
- ```
132
-
133
- ## Testing
134
-
135
- This plugin adds an endpoint at http://[server]/ses/send
136
-
137
- By default, the endpoint will refuse to send any emails.
138
- This endpoint may be useful for testing purposes in a development environment or for use by related applications.
139
-
140
- There is NO SECURITY on the endpoint by default. Most people will NOT need to enable this endpoint.
141
- If you are certain that you want to enable it and that you know what you are doing,
142
- set the environment variable SES_ENABLE_ENDPOINT to the string you will use as your pass key when sending requests to the endpoint.
143
-
144
- To use the endpoint, POST a json req.body with: pass_key, template_id, from, to, and data to /ses/send.
145
-
146
- Example:
147
-
148
- ```bash
149
- SES_ENABLE_ENDPOINT="42"
150
- ```
151
-
152
- ```json
153
- {
154
- "template_id":"customer_password_reset",
155
- "from":"me@me.com",
156
- "to": "you@you.com",
157
- "data": {
158
- "customer": {
159
- "first_name": "Test"
160
- }
161
- },
162
- "pass_key": "42"
163
- }
164
- ```
165
-
166
- Setting the enable_sim_mode option to true will cause the endpoint to return information about whether the template was successfully compiled and the compiled result, but it will not actually send the email. This setting only applies to calls to the ses/send endpoint. It does not affect other calls to the notification service from within Medusa, which will still send emails as per usual.
167
-
168
- ## Acknowledgement
169
-
170
- This plugin borrows extensively from medusa-plugin-sendgrid by Oliver Juhl.
package/package.json CHANGED
@@ -1,44 +1,75 @@
1
1
  {
2
- "name": "medusa-plugin-ses",
3
- "version": "2.2.3",
4
- "description": "AWS SES transactional emails using local handlebars templates",
5
- "main": "index.js",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/pevey/medusa-plugin-ses"
9
- },
10
- "homepage:": "https://pevey.com/medusa-plugin-ses",
11
- "author": "Lacey Pevey",
12
- "license": "MIT",
13
- "devDependencies": {
14
- "body-parser": "^1.19.0",
15
- "cross-env": "^5.2.1",
16
- "express": "^4.17.2",
17
- "typeorm": "^0.3.16",
18
- "typescript": "^4.9.5"
19
- },
20
- "scripts": {
21
- "prepare": "cross-env NODE_ENV=production yarn run build",
22
- "test": "jest --passWithNoTests src",
23
- "build": "tsc",
24
- "watch": "tsc --watch"
25
- },
26
- "dependencies": {
27
- "@aws-sdk/client-ses": "^3.379.1",
28
- "handlebars": "^4.7.7",
29
- "nodemailer": "^6.9.3",
30
- "zod": "^3.21.4"
31
- },
32
- "keywords": [
33
- "medusa-plugin",
34
- "medusa-plugin-notification",
35
- "email",
36
- "react email",
37
- "handlebars email",
38
- "transactional email",
39
- "ses",
40
- "simple email service",
41
- "aws ses",
42
- "aws"
43
- ]
44
- }
2
+ "name": "medusa-plugin-ses",
3
+ "version": "3.0.0-canary.0",
4
+ "description": "AWS SES email notification provider for Medusa v2",
5
+ "author": "Lacey Pevey",
6
+ "license": "MIT",
7
+ "files": [
8
+ ".medusa/server"
9
+ ],
10
+ "exports": {
11
+ "./package.json": "./package.json",
12
+ "./.medusa/server/src/modules/*": "./.medusa/server/src/modules/*/index.js",
13
+ "./modules/*": "./.medusa/server/src/modules/*/index.js",
14
+ "./providers/*": "./.medusa/server/src/providers/*/index.js",
15
+ "./*": "./.medusa/server/src/*.js"
16
+ },
17
+ "keywords": [
18
+ "medusa",
19
+ "plugin",
20
+ "medusa-plugin-ses",
21
+ "medusa-plugin",
22
+ "medusa-v2",
23
+ "email notifications",
24
+ "aws ses",
25
+ "ses provider"
26
+ ],
27
+ "scripts": {
28
+ "prebuild": "node ./scripts/check-node-version.cjs",
29
+ "build": "medusa plugin:build",
30
+ "dev": "medusa plugin:develop",
31
+ "prepublishOnly": "node ./scripts/check-node-version.cjs && medusa plugin:build",
32
+ "test:integration:modules": "TEST_TYPE=integration:modules NODE_OPTIONS=--experimental-vm-modules jest --silent=false --runInBand --detectOpenHandles --forceExit",
33
+ "test:unit": "TEST_TYPE=unit NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --detectOpenHandles --forceExit"
34
+ },
35
+ "dependencies": {
36
+ "@aws-sdk/client-sesv2": "^3.1019.0",
37
+ "nodemailer": "^8.0.4"
38
+ },
39
+ "devDependencies": {
40
+ "@medusajs/admin-sdk": "2.12.4",
41
+ "@medusajs/cli": "2.12.4",
42
+ "@medusajs/framework": "2.12.4",
43
+ "@medusajs/icons": "2.12.4",
44
+ "@medusajs/medusa": "2.12.4",
45
+ "@medusajs/test-utils": "2.12.4",
46
+ "@medusajs/ui": "4.0.25",
47
+ "@swc/core": "^1.7.28",
48
+ "@swc/jest": "^0.2.39",
49
+ "@types/jest": "^30.0.0",
50
+ "@types/node": "^20.0.0",
51
+ "@types/nodemailer": "^8.0.0",
52
+ "@types/react": "^18.3.2",
53
+ "@types/react-dom": "^18.2.25",
54
+ "jest": "^29.7.0",
55
+ "prop-types": "^15.8.1",
56
+ "react": "^18.2.0",
57
+ "react-dom": "^18.2.0",
58
+ "ts-node": "^10.9.2",
59
+ "typescript": "^5.6.2",
60
+ "vite": "^5.2.11",
61
+ "yalc": "^1.0.0-pre.53"
62
+ },
63
+ "peerDependencies": {
64
+ "@medusajs/admin-sdk": "2.12.4",
65
+ "@medusajs/cli": "2.12.4",
66
+ "@medusajs/framework": "2.12.4",
67
+ "@medusajs/icons": "2.12.4",
68
+ "@medusajs/medusa": "2.12.4",
69
+ "@medusajs/test-utils": "2.12.4",
70
+ "@medusajs/ui": "4.0.25"
71
+ },
72
+ "engines": {
73
+ "node": ">=20 <25"
74
+ }
75
+ }
package/CHANGELOG.md DELETED
@@ -1,64 +0,0 @@
1
- # Change Log
2
-
3
- ## 2.2.3
4
-
5
- - Feat: The optional endpoint now uses a passkey. Please see the Readme.
6
- - Feat: The internal sesService.sendEmail(template_id, from, to, data) function is now available whether or not the endpoint is enabled. This allows you to use the email sending ability in custom services without having to expose the endpoint.
7
- - Fix: Remove unused package
8
-
9
- ## 2.1.1
10
-
11
- - Feat: Add ability to use partials
12
- - Feat: Add option to use optional endpoint in similation mode. If enabled, no emails will be sent. The plugin will attempt to compile the template and return the results. This is useful for template debugging.
13
-
14
- ## 2.1.1
15
-
16
- - Feat: Add ability to use partials
17
- - Feat: Add option to use optional endpoint in similation mode. If enabled, no emails will be sent. The plugin will attempt to compile the template and return the results. This is useful for template debugging.
18
-
19
- ## 2.0.17
20
-
21
- - Add option to cc email address(es) on notifications for order.placed events
22
- ```js
23
- order_placed_cc: 'person1@example.com,person2@example.com', // string, email address separated by comma
24
- ```
25
- - Bump all dependencies to latest
26
-
27
- ## 2.0.16
28
-
29
- - Clean up dependencies (again) to address the circular dep CJS issue. Be sure to yarn link all the peer deps if you want to make changes to the plugin locally.
30
-
31
- ## 2.0.15
32
-
33
- - Print useful MedusaError messages to console when steps fail to assist with debugging and configuration
34
-
35
- ## 2.0.14
36
-
37
- - Fixed import reference for helper functions from @medusajs/utils to medusa-core-utils
38
-
39
- ## 2.0.13
40
-
41
- - Fixed validation of 'data' object on the dev/test api endpoint that was causing valid data to be dropped
42
-
43
- ## 2.0.12
44
-
45
- - Minor: Removed unused dependency
46
-
47
- ## 2.0.11
48
-
49
- - Minor: Switch to typescript build process
50
- - Minor: Move most peer dependencies to dev dependencies
51
-
52
- ## 2.0.10
53
-
54
- - Remove extraneous code from index.js
55
-
56
- ## 2.0.9
57
-
58
- - The API endpoint will now return a more useful error when the templates are not found or compile errors are encountered rather than simply returning false.
59
-
60
- ## 2.0.8
61
-
62
- - Added CHANGELOG
63
- - The template path option can now be absolute or relative to the Medusa root folder
64
- - No error will be thrown if html.hbs or text.hbs does not exist, so long as the other exists.
package/DEVELOPING.md DELETED
@@ -1,6 +0,0 @@
1
- When developing and installing the package locally from a folder on your machine, you must link the following Medusa package dependencies in addition to the packages installed by default:
2
-
3
- "@medusajs/medusa": "^1.15.0"
4
- "@medusajs/utils": "1.9.7"
5
- "medusa-core-utils": "^1.2.0"
6
- "medusa-interfaces": "^1.3.7"
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Lacey Pevey
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/api/index.js DELETED
@@ -1,44 +0,0 @@
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 config_1 = __importDefault(require("@medusajs/medusa/dist/loaders/config"));
7
- const express_1 = require("express");
8
- const body_parser_1 = __importDefault(require("body-parser"));
9
- const utils_1 = require("@medusajs/utils");
10
- const zod_1 = require("zod");
11
- const router = (0, express_1.Router)();
12
- exports.default = (rootDirectory) => {
13
- const config = (0, config_1.default)(rootDirectory);
14
- const pluginConfig = config.plugins.find((p) => p.resolve === "medusa-plugin-ses");
15
- const passKey = pluginConfig?.options.enable_endpoint;
16
- router.use("/ses/send", body_parser_1.default.json());
17
- router.post("/ses/send", (req, res) => {
18
- if (!passKey) {
19
- res.sendStatus(404);
20
- }
21
- const schema = zod_1.z.object({
22
- pass_key: zod_1.z.string().min(1),
23
- template_id: zod_1.z.string().min(1),
24
- from: zod_1.z.string().min(1),
25
- to: zod_1.z.string().min(1),
26
- data: zod_1.z.object({}).passthrough(),
27
- });
28
- const { success, error, data } = schema.safeParse(req.body);
29
- if (!success) {
30
- throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, error);
31
- }
32
- if (passKey !== data.pass_key) {
33
- throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, 'Invalid passKey');
34
- }
35
- const sesService = req.scope.resolve("sesService");
36
- sesService.sendEmail(data.template_id, data.from, data.to, data.data).then((result) => {
37
- return res.json({
38
- result
39
- });
40
- });
41
- });
42
- return router;
43
- };
44
- //# sourceMappingURL=index.js.map
package/api/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/api/index.js"],"names":[],"mappings":";;;;;AAAA,kFAA+D;AAC/D,qCAAgC;AAChC,8DAAoC;AACpC,2CAA6C;AAC7C,6BAAuB;AAEvB,MAAM,MAAM,GAAG,IAAA,gBAAM,GAAE,CAAA;AAEvB,kBAAe,CAAC,aAAa,EAAE,EAAE;IAC9B,MAAM,MAAM,GAAG,IAAA,gBAAY,EAAC,aAAa,CAAC,CAAA;IAC1C,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,mBAAmB,CAAC,CAAA;IAClF,MAAM,OAAO,GAAG,YAAY,EAAE,OAAO,CAAC,eAAe,CAAA;IAErD,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,qBAAU,CAAC,IAAI,EAAE,CAAC,CAAA;IAC1C,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACnC,IAAI,CAAC,OAAO,EAAE;YACX,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;SACrB;QAED,MAAM,MAAM,GAAG,OAAC,CAAC,MAAM,CAAC;YACrB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;YAC3B,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;YAC9B,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;YACvB,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;YACrB,IAAI,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAA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