medusa-plugin-ses 2.0.8 → 2.0.11
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.
- package/CHANGELOG.md +19 -0
- package/README.md +3 -7
- package/api/index.js +35 -38
- package/api/index.js.map +1 -0
- package/package.json +18 -27
- package/services/ses.js +983 -1528
- package/services/ses.js.map +1 -0
- package/subscribers/order.js +20 -31
- package/subscribers/order.js.map +1 -0
- package/subscribers/restock.js +24 -85
- package/subscribers/restock.js.map +1 -0
- package/subscribers/user.js +12 -42
- package/subscribers/user.js.map +1 -0
- package/tsconfig.json +29 -0
- package/tsconfig.spec.json +5 -0
- package/index.js +0 -50
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 2.0.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Minor: Switch to typexcript build process
|
|
8
|
+
- Minor: Move most peer depencies to dev dependencies
|
|
9
|
+
|
|
10
|
+
## 2.0.10
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Remove extraneous code from index.js
|
|
15
|
+
|
|
16
|
+
## 2.0.9
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 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.
|
|
21
|
+
|
|
3
22
|
## 2.0.8
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -15,11 +15,6 @@ If you are not familiar with Medusa, you can learn more on [the project web site
|
|
|
15
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
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
17
|
|
|
18
|
-
## Changes in 2.0.8
|
|
19
|
-
|
|
20
|
-
- The template path option can now be absolute or relative to the Medusa root folder
|
|
21
|
-
- No error will be thrown if html.hbs or text.hbs does not exist, so long as the other exists.
|
|
22
|
-
|
|
23
18
|
## Node v20
|
|
24
19
|
|
|
25
20
|
- If you are starting to test out Node v20, be sure you give runtime permission for fs reads due to the new Node permissions API. Otherwise, this plugin will not be able to read your email templates from the file system.
|
|
@@ -40,7 +35,7 @@ Enable in your medusa-config.js file similar to other plugins:
|
|
|
40
35
|
template_path: process.env.SES_TEMPLATE_PATH,
|
|
41
36
|
order_placed_template: 'order_placed',
|
|
42
37
|
order_shipped_template: 'order_shipped',
|
|
43
|
-
|
|
38
|
+
customer_password_reset_template: 'customer_password_reset',
|
|
44
39
|
gift_card_created_template: 'gift_card_created',
|
|
45
40
|
//order_canceled_template: 'order_canceled',
|
|
46
41
|
//order_refund_created_template: 'order_refund_created',
|
|
@@ -50,6 +45,7 @@ Enable in your medusa-config.js file similar to other plugins:
|
|
|
50
45
|
//swap_shipment_created_template: 'swap_shipment_created',
|
|
51
46
|
//swap_received_template: 'swap_received',
|
|
52
47
|
//claim_shipment_created_template: 'claim_shipment_created',
|
|
48
|
+
//user_password_reset_template: 'user_password_reset',
|
|
53
49
|
//medusa_restock_template: 'medusa_restock',
|
|
54
50
|
}
|
|
55
51
|
},
|
|
@@ -79,7 +75,7 @@ Also remember that if your AWS account is still in sandbox mode, you can only SE
|
|
|
79
75
|
|
|
80
76
|
## Templates
|
|
81
77
|
|
|
82
|
-
The
|
|
78
|
+
The templates used are stored locally. Create a 'data/templates' folder and include the entire path in the SES_TEMPLATE_PATH variable.
|
|
83
79
|
|
|
84
80
|
```bash
|
|
85
81
|
medusa-server // root directory
|
package/api/index.js
CHANGED
|
@@ -1,41 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
result: result
|
|
36
|
-
});
|
|
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 cors_1 = __importDefault(require("cors"));
|
|
7
|
+
const config_1 = __importDefault(require("@medusajs/medusa/dist/loaders/config"));
|
|
8
|
+
const express_1 = require("express");
|
|
9
|
+
const body_parser_1 = __importDefault(require("body-parser"));
|
|
10
|
+
const utils_1 = require("@medusajs/utils");
|
|
11
|
+
const zod_1 = require("zod");
|
|
12
|
+
const router = (0, express_1.Router)();
|
|
13
|
+
exports.default = (rootDirectory) => {
|
|
14
|
+
const config = (0, config_1.default)(rootDirectory);
|
|
15
|
+
const storeCorsOptions = { origin: config.projectConfig.store_cors.split(","), credentials: true, };
|
|
16
|
+
const adminCorsOptions = { origin: config.projectConfig.admin_cors.split(","), credentials: true, };
|
|
17
|
+
router.use(body_parser_1.default.json());
|
|
18
|
+
router.post("/ses/send", (0, cors_1.default)(storeCorsOptions), (req, res) => {
|
|
19
|
+
const sesService = req.scope.resolve("sesService");
|
|
20
|
+
const schema = zod_1.z.object({
|
|
21
|
+
template_id: zod_1.z.string().min(1),
|
|
22
|
+
from: zod_1.z.string().min(1),
|
|
23
|
+
to: zod_1.z.string().min(1),
|
|
24
|
+
data: zod_1.z.object({}).required().default({}),
|
|
25
|
+
});
|
|
26
|
+
const { success, error, data } = schema.safeParse(req.body);
|
|
27
|
+
if (!success) {
|
|
28
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, error);
|
|
29
|
+
}
|
|
30
|
+
sesService.sendEmail(data.template_id, data.from, data.to, data.data).then((result) => {
|
|
31
|
+
return res.json({
|
|
32
|
+
result
|
|
33
|
+
});
|
|
34
|
+
});
|
|
37
35
|
});
|
|
38
|
-
|
|
39
|
-
return router;
|
|
36
|
+
return router;
|
|
40
37
|
};
|
|
41
|
-
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
package/api/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/api/index.js"],"names":[],"mappings":";;;;;AAAA,gDAAuB;AACvB,kFAA+D;AAC/D,qCAAgC;AAChC,8DAAoC;AACpC,2CAA6C;AAC7C,6BAAsB;AAEtB,MAAM,MAAM,GAAG,IAAA,gBAAM,GAAE,CAAA;AAEvB,kBAAe,CAAC,aAAa,EAAE,EAAE;IAChC,MAAM,MAAM,GAAG,IAAA,gBAAY,EAAC,aAAa,CAAC,CAAA;IAC1C,MAAM,gBAAgB,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,IAAI,GAAG,CAAA;IACjG,MAAM,gBAAgB,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,IAAI,GAAG,CAAA;IAErG,MAAM,CAAC,GAAG,CAAC,qBAAU,CAAC,IAAI,EAAE,CAAC,CAAA;IAE7B,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,IAAA,cAAI,EAAC,gBAAgB,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC7D,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;QAElD,MAAM,MAAM,GAAG,OAAC,CAAC,MAAM,CAAC;YACvB,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,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;SACzC,CAAC,CAAA;QAEF,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAC3D,IAAI,CAAC,OAAO,EAAE;YACb,MAAM,IAAI,mBAAW,CAAC,mBAAW,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,CAAA;SAC5D;QAED,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YACrF,OAAO,GAAG,CAAC,IAAI,CAAC;gBACf,MAAM;aACN,CAAC,CAAA;QACH,CAAC,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACd,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "medusa-plugin-ses",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11",
|
|
4
4
|
"description": "AWS SES transactional emails using local handlebars templates",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -11,37 +11,28 @@
|
|
|
11
11
|
"author": "Lacey Pevey",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"client-sessions": "^0.8.0",
|
|
25
|
-
"cross-env": "^5.2.1",
|
|
26
|
-
"jest": "^25.5.2",
|
|
27
|
-
"medusa-core-utils": "^1.2.0",
|
|
28
|
-
"medusa-test-utils": "^1.1.40"
|
|
29
|
-
},
|
|
30
|
-
"scripts": {
|
|
31
|
-
"prepare": "cross-env NODE_ENV=production yarn run build",
|
|
32
|
-
"test": "jest --passWithNoTests src",
|
|
33
|
-
"build": "babel src --out-dir . --ignore '**/__tests__','**/__mocks__'",
|
|
34
|
-
"watch": "babel -w src --out-dir . --ignore '**/__tests__','**/__mocks__'"
|
|
14
|
+
"@medusajs/medusa": "^1.10.1",
|
|
15
|
+
"@medusajs/types": "^1.8.5",
|
|
16
|
+
"@medusajs/utils": "^1.8.4",
|
|
17
|
+
"body-parser": "^1.19.0",
|
|
18
|
+
"cors": "^2.8.5",
|
|
19
|
+
"cross-env": "^5.2.1",
|
|
20
|
+
"express": "^4.17.2",
|
|
21
|
+
"medusa-interfaces": "^1.3.7",
|
|
22
|
+
"typeorm": "^0.3.16",
|
|
23
|
+
"typescript": "^4.9.5"
|
|
35
24
|
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"prepare": "cross-env NODE_ENV=production yarn run build",
|
|
27
|
+
"test": "jest --passWithNoTests src",
|
|
28
|
+
"build": "tsc",
|
|
29
|
+
"watch": "tsc --watch"
|
|
30
|
+
},
|
|
36
31
|
"peerDependencies": {
|
|
37
|
-
"@medusajs/medusa": "^1.
|
|
38
|
-
"medusa-interfaces": "1.3.7"
|
|
32
|
+
"@medusajs/medusa": "^1.10.1"
|
|
39
33
|
},
|
|
40
34
|
"dependencies": {
|
|
41
35
|
"@aws-sdk/client-ses": "^3.241.0",
|
|
42
|
-
"@babel/plugin-transform-classes": "^7.9.5",
|
|
43
|
-
"body-parser": "^1.19.0",
|
|
44
|
-
"express": "^4.17.1",
|
|
45
36
|
"fs": "^0.0.1-security",
|
|
46
37
|
"handlebars": "^4.7.7",
|
|
47
38
|
"nodemailer": "^6.9.1",
|