@proteinjs/email-server 1.0.1 → 1.0.2
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 +11 -0
- package/dist/generated/index.d.ts +1 -1
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +1 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/src/EmailConfigs.d.ts +26 -1
- package/dist/src/EmailConfigs.d.ts.map +1 -1
- package/dist/src/EmailSender.js +2 -2
- package/dist/src/EmailSender.js.map +1 -1
- package/generated/index.ts +1 -1
- package/package.json +2 -2
- package/src/EmailConfigs.ts +27 -1
- package/src/EmailSender.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.0.2](https://github.com/proteinjs/notifications/compare/@proteinjs/email-server@1.0.1...@proteinjs/email-server@1.0.2) (2024-07-12)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* update location of config factory ([3bef859](https://github.com/proteinjs/notifications/commit/3bef8595ba48ed3b7b91376ca1ba9b8f1a1b8f18))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 1.0.1 (2024-07-12)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @proteinjs/email-server
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AAEpC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AAEpC,OAAO,uBAAuB,CAAC;AAC/B,OAAO,iBAAiB,CAAC;AACzB,OAAO,YAAY,CAAC;AAqBpB,cAAc,UAAU,CAAC"}
|
package/dist/generated/index.js
CHANGED
|
@@ -15,8 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
require("@proteinjs/util");
|
|
19
18
|
require("@proteinjs/reflection");
|
|
19
|
+
require("@proteinjs/util");
|
|
20
20
|
require("nodemailer");
|
|
21
21
|
/** Generate Source Graph */
|
|
22
22
|
var sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/email-server/DefaultPasswordResetEmailConfigFactory\",\"value\":{\"packageName\":\"@proteinjs/email-server\",\"name\":\"DefaultPasswordResetEmailConfigFactory\",\"filePath\":\"/home/runner/work/notifications/notifications/packages/email/server/src/EmailConfigs.ts\",\"qualifiedName\":\"@proteinjs/email-server/DefaultPasswordResetEmailConfigFactory\",\"properties\":[],\"methods\":[{\"name\":\"getConfig\",\"returnType\":{\"packageName\":\"@proteinjs/email-server\",\"name\":\"PasswordResetEmailConfig\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/email-server/PasswordResetEmailConfig\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":false,\"isOptional\":false,\"isAbstract\":true,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[]}],\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/reflection\",\"name\":\"Loadable\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/reflection/Loadable\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"sourceType\":3}},{\"v\":\"@proteinjs/reflection/Loadable\"},{\"v\":\"@proteinjs/email-server/DefaultEmailConfigFactory\",\"value\":{\"packageName\":\"@proteinjs/email-server\",\"name\":\"DefaultEmailConfigFactory\",\"filePath\":\"/home/runner/work/notifications/notifications/packages/email/server/src/EmailSender.ts\",\"qualifiedName\":\"@proteinjs/email-server/DefaultEmailConfigFactory\",\"properties\":[],\"methods\":[{\"name\":\"getEmailConfig\",\"returnType\":{\"packageName\":\"@proteinjs/email-server\",\"name\":\"EmailConfig\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/email-server/EmailConfig\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":false,\"isOptional\":false,\"isAbstract\":true,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[]}],\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/reflection\",\"name\":\"Loadable\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/reflection/Loadable\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"sourceType\":3}}],\"edges\":[{\"v\":\"@proteinjs/email-server/DefaultPasswordResetEmailConfigFactory\",\"w\":\"@proteinjs/reflection/Loadable\",\"value\":\"extends interface\"},{\"v\":\"@proteinjs/email-server/DefaultEmailConfigFactory\",\"w\":\"@proteinjs/reflection/Loadable\",\"value\":\"extends interface\"}]}";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;;;;;;;;;;;;;;AAEpC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;;;;;;;;;;;;;;AAEpC,iCAA+B;AAC/B,2BAAyB;AACzB,sBAAoB;AAGpB,4BAA4B;AAE5B,IAAM,WAAW,GAAG,k7EAAk7E,CAAC;AAGv8E,4BAA4B;AAG5B,IAAM,WAAW,GAAG,EACnB,CAAC;AAGF,kCAAkC;AAElC,oDAAyD;AACzD,6BAAgB,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAGjD,2CAAyB"}
|
|
@@ -2,8 +2,33 @@ import { Loadable } from '@proteinjs/reflection';
|
|
|
2
2
|
import Mail from 'nodemailer/lib/mailer';
|
|
3
3
|
export declare const getDefaultPasswordResetEmailConfigFactory: () => DefaultPasswordResetEmailConfigFactory;
|
|
4
4
|
export interface PasswordResetEmailConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Options to pass into the `EmailSender` object when building the email to be sent.
|
|
7
|
+
*
|
|
8
|
+
* @see https://nodemailer.com/message/ for all available options
|
|
9
|
+
*/
|
|
5
10
|
options?: Mail.Options;
|
|
6
|
-
|
|
11
|
+
/**
|
|
12
|
+
* A function that generates the email content (both text and HTML versions) for the password reset email.
|
|
13
|
+
*
|
|
14
|
+
* @param resetPathWithToken A partial URL path for resetting the password, including the reset token.
|
|
15
|
+
* This is in the format: 'login/reset-password?token=abc123def456'.
|
|
16
|
+
* Note: This is NOT a full URL. You need to prepend your application's base URL to create a complete, clickable link in the email content.
|
|
17
|
+
*
|
|
18
|
+
* @returns An object containing the email content:
|
|
19
|
+
* text: The plain text version of the email (required)
|
|
20
|
+
* html: The HTML version of the email (optional, used for styling)
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* getEmailContent: (resetPathWithToken) => {
|
|
24
|
+
* const fullResetUrl = `https://myapp.com/${resetPathWithToken}`;
|
|
25
|
+
* return {
|
|
26
|
+
* text: `Click here to reset your password: ${fullResetUrl}`,
|
|
27
|
+
* html: `<p>Click <a href="${fullResetUrl}">here</a> to reset your password.</p>`
|
|
28
|
+
* };
|
|
29
|
+
* }
|
|
30
|
+
*/
|
|
31
|
+
getEmailContent: (resetPathWithToken: string) => {
|
|
7
32
|
text: string;
|
|
8
33
|
html?: string;
|
|
9
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailConfigs.d.ts","sourceRoot":"","sources":["../../src/EmailConfigs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAoB,MAAM,uBAAuB,CAAC;AACnE,OAAO,IAAI,MAAM,uBAAuB,CAAC;AAEzC,eAAO,MAAM,yCAAyC,8CAGnD,CAAC;AAEJ,MAAM,WAAW,wBAAwB;IACvC,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"EmailConfigs.d.ts","sourceRoot":"","sources":["../../src/EmailConfigs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAoB,MAAM,uBAAuB,CAAC;AACnE,OAAO,IAAI,MAAM,uBAAuB,CAAC;AAEzC,eAAO,MAAM,yCAAyC,8CAGnD,CAAC;AAEJ,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC;IAEvB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,eAAe,EAAE,CAAC,kBAAkB,EAAE,MAAM,KAAK;QAC/C,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAED,MAAM,WAAW,sCAAuC,SAAQ,QAAQ;IACtE,SAAS,IAAI,wBAAwB,CAAC;CACvC"}
|
package/dist/src/EmailSender.js
CHANGED
|
@@ -68,9 +68,9 @@ var EmailSender = /** @class */ (function () {
|
|
|
68
68
|
}
|
|
69
69
|
EmailSender.prototype.getDefaultEmailConfig = function () {
|
|
70
70
|
if (!EmailSender.defaultEmailConfig) {
|
|
71
|
-
var defaultEmailConfigFactory = reflection_1.SourceRepository.get().object('@proteinjs/
|
|
71
|
+
var defaultEmailConfigFactory = reflection_1.SourceRepository.get().object('@proteinjs/email-server/DefaultEmailConfigFactory');
|
|
72
72
|
if (!defaultEmailConfigFactory) {
|
|
73
|
-
throw new Error("Unable to find a @proteinjs/
|
|
73
|
+
throw new Error("Unable to find a @proteinjs/email-server/DefaultEmailConfigFactory implementation. Either implement DefaultEmailConfigFactory or pass in an email config when instantiating EmailSender.");
|
|
74
74
|
}
|
|
75
75
|
EmailSender.defaultEmailConfig = defaultEmailConfigFactory.getEmailConfig();
|
|
76
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailSender.js","sourceRoot":"","sources":["../../src/EmailSender.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAoC;AACpC,wCAAyC;AACzC,oDAAmE;AAqBnE;IAOE,qBAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC7D,IAAI,CAAC,WAAW,GAAG,oBAAU,CAAC,eAAe,CAAC;YAC5C,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;YACtB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;YACtB,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;YAC1B,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;SACvB,CAAC,CAAC;QACH,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,IAAI,aAAM,CAAC,aAAa,CAAC,CAAC;IAC1C,CAAC;IAEO,2CAAqB,GAA7B;QACE,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAAE;YACnC,IAAM,yBAAyB,GAAG,6BAAgB,CAAC,GAAG,EAAE,CAAC,MAAM,CAC7D,
|
|
1
|
+
{"version":3,"file":"EmailSender.js","sourceRoot":"","sources":["../../src/EmailSender.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAoC;AACpC,wCAAyC;AACzC,oDAAmE;AAqBnE;IAOE,qBAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC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,sBAAsB,CAAC,CAAC;;;;;KAE3C;IACH,kBAAC;AAAD,CAAC,AAlDD,IAkDC;AAlDY,kCAAW;AAoDxB,SAAgB,iBAAiB,CAAC,MAAmB;IACnD,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC;AAFD,8CAEC"}
|
package/generated/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proteinjs/email-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Email server libraries",
|
|
5
5
|
"main": "./dist/generated/index.js",
|
|
6
6
|
"types": "./dist/generated/index.d.ts",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"ts-jest": "29.1.1",
|
|
42
42
|
"typescript": "5.2.2"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "3594c762d18c0404939eb6577265379bfab02e73"
|
|
45
45
|
}
|
package/src/EmailConfigs.ts
CHANGED
|
@@ -7,8 +7,34 @@ export const getDefaultPasswordResetEmailConfigFactory = () =>
|
|
|
7
7
|
);
|
|
8
8
|
|
|
9
9
|
export interface PasswordResetEmailConfig {
|
|
10
|
+
/**
|
|
11
|
+
* Options to pass into the `EmailSender` object when building the email to be sent.
|
|
12
|
+
*
|
|
13
|
+
* @see https://nodemailer.com/message/ for all available options
|
|
14
|
+
*/
|
|
10
15
|
options?: Mail.Options;
|
|
11
|
-
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A function that generates the email content (both text and HTML versions) for the password reset email.
|
|
19
|
+
*
|
|
20
|
+
* @param resetPathWithToken A partial URL path for resetting the password, including the reset token.
|
|
21
|
+
* This is in the format: 'login/reset-password?token=abc123def456'.
|
|
22
|
+
* Note: This is NOT a full URL. You need to prepend your application's base URL to create a complete, clickable link in the email content.
|
|
23
|
+
*
|
|
24
|
+
* @returns An object containing the email content:
|
|
25
|
+
* text: The plain text version of the email (required)
|
|
26
|
+
* html: The HTML version of the email (optional, used for styling)
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* getEmailContent: (resetPathWithToken) => {
|
|
30
|
+
* const fullResetUrl = `https://myapp.com/${resetPathWithToken}`;
|
|
31
|
+
* return {
|
|
32
|
+
* text: `Click here to reset your password: ${fullResetUrl}`,
|
|
33
|
+
* html: `<p>Click <a href="${fullResetUrl}">here</a> to reset your password.</p>`
|
|
34
|
+
* };
|
|
35
|
+
* }
|
|
36
|
+
*/
|
|
37
|
+
getEmailContent: (resetPathWithToken: string) => {
|
|
12
38
|
text: string;
|
|
13
39
|
html?: string;
|
|
14
40
|
};
|
package/src/EmailSender.ts
CHANGED
|
@@ -43,11 +43,11 @@ export class EmailSender {
|
|
|
43
43
|
private getDefaultEmailConfig(): EmailConfig {
|
|
44
44
|
if (!EmailSender.defaultEmailConfig) {
|
|
45
45
|
const defaultEmailConfigFactory = SourceRepository.get().object<DefaultEmailConfigFactory>(
|
|
46
|
-
'@proteinjs/
|
|
46
|
+
'@proteinjs/email-server/DefaultEmailConfigFactory'
|
|
47
47
|
);
|
|
48
48
|
if (!defaultEmailConfigFactory) {
|
|
49
49
|
throw new Error(
|
|
50
|
-
`Unable to find a @proteinjs/
|
|
50
|
+
`Unable to find a @proteinjs/email-server/DefaultEmailConfigFactory implementation. Either implement DefaultEmailConfigFactory or pass in an email config when instantiating EmailSender.`
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
53
|
|