@webiny/api-mailer 6.4.12-beta.6 → 6.4.12-beta.8
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/domain/errors.d.ts +1 -1
- package/domain/errors.js +2 -2
- package/domain/errors.js.map +1 -1
- package/features/GetSettings/GetSettingsUseCase.d.ts +9 -2
- package/features/GetSettings/GetSettingsUseCase.js +9 -2
- package/features/GetSettings/GetSettingsUseCase.js.map +1 -1
- package/features/GetSettings/abstractions.d.ts +2 -1
- package/features/GetSettings/abstractions.js.map +1 -1
- package/features/SmtpTransport/SmtpMailTransport.d.ts +8 -7
- package/package.json +18 -18
package/domain/errors.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare class SettingsValidationError extends BaseError<{
|
|
|
14
14
|
}
|
|
15
15
|
export declare class SettingsNotAuthorized extends BaseError {
|
|
16
16
|
readonly code: "Mailer/Settings/NotAuthorized";
|
|
17
|
-
constructor();
|
|
17
|
+
constructor(message?: string);
|
|
18
18
|
}
|
|
19
19
|
export declare class SettingsPersistenceError extends BaseError<{
|
|
20
20
|
error: Error;
|
package/domain/errors.js
CHANGED
|
@@ -20,9 +20,9 @@ class SettingsValidationError extends BaseError {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
class SettingsNotAuthorized extends BaseError {
|
|
23
|
-
constructor(){
|
|
23
|
+
constructor(message = "Not allowed to update the mailer settings."){
|
|
24
24
|
super({
|
|
25
|
-
message
|
|
25
|
+
message
|
|
26
26
|
}), this.code = "Mailer/Settings/NotAuthorized";
|
|
27
27
|
}
|
|
28
28
|
}
|
package/domain/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain/errors.js","sources":["../../src/domain/errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\nimport type { ZodError } from \"zod\";\n\nexport class MailValidationError extends BaseError<{ errors: ZodError[\"issues\"] }> {\n override readonly code = \"Mailer/SendMail/Validation\" as const;\n\n constructor(errors: ZodError[\"issues\"]) {\n super({\n message: \"Email params are invalid.\",\n data: {\n errors\n }\n });\n }\n}\n\nexport class SettingsValidationError extends BaseError<{ errors: ZodError[\"issues\"] }> {\n override readonly code = \"Mailer/Settings/Validation\" as const;\n\n constructor(errors: ZodError[\"issues\"]) {\n super({\n message: \"Settings validation failed.\",\n data: {\n errors\n }\n });\n }\n}\n\nexport class SettingsNotAuthorized extends BaseError {\n override readonly code = \"Mailer/Settings/NotAuthorized\" as const;\n\n constructor(
|
|
1
|
+
{"version":3,"file":"domain/errors.js","sources":["../../src/domain/errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\nimport type { ZodError } from \"zod\";\n\nexport class MailValidationError extends BaseError<{ errors: ZodError[\"issues\"] }> {\n override readonly code = \"Mailer/SendMail/Validation\" as const;\n\n constructor(errors: ZodError[\"issues\"]) {\n super({\n message: \"Email params are invalid.\",\n data: {\n errors\n }\n });\n }\n}\n\nexport class SettingsValidationError extends BaseError<{ errors: ZodError[\"issues\"] }> {\n override readonly code = \"Mailer/Settings/Validation\" as const;\n\n constructor(errors: ZodError[\"issues\"]) {\n super({\n message: \"Settings validation failed.\",\n data: {\n errors\n }\n });\n }\n}\n\nexport class SettingsNotAuthorized extends BaseError {\n override readonly code = \"Mailer/Settings/NotAuthorized\" as const;\n\n constructor(message = \"Not allowed to update the mailer settings.\") {\n super({ message });\n }\n}\n\nexport class SettingsPersistenceError extends BaseError<{ error: Error }> {\n override readonly code = \"Mailer/Settings/Persistence\" as const;\n\n constructor(error: Error) {\n super({\n message: \"Failed to persist settings.\",\n data: {\n error\n }\n });\n }\n}\n\nexport class SettingsLockedByCode extends BaseError {\n override readonly code = \"Mailer/Settings/LockedByCode\" as const;\n\n constructor() {\n super({\n message: \"Mailer settings are managed by code and cannot be saved via the API.\"\n });\n }\n}\n"],"names":["MailValidationError","BaseError","errors","SettingsValidationError","SettingsNotAuthorized","message","SettingsPersistenceError","error","SettingsLockedByCode"],"mappings":";AAGO,MAAMA,4BAA4BC;IAGrC,YAAYC,MAA0B,CAAE;QACpC,KAAK,CAAC;YACF,SAAS;YACT,MAAM;gBACFA;YACJ;QACJ,SARc,IAAI,GAAG;IASzB;AACJ;AAEO,MAAMC,gCAAgCF;IAGzC,YAAYC,MAA0B,CAAE;QACpC,KAAK,CAAC;YACF,SAAS;YACT,MAAM;gBACFA;YACJ;QACJ,SARc,IAAI,GAAG;IASzB;AACJ;AAEO,MAAME,8BAA8BH;IAGvC,YAAYI,UAAU,4CAA4C,CAAE;QAChE,KAAK,CAAC;YAAEA;QAAQ,SAHF,IAAI,GAAG;IAIzB;AACJ;AAEO,MAAMC,iCAAiCL;IAG1C,YAAYM,KAAY,CAAE;QACtB,KAAK,CAAC;YACF,SAAS;YACT,MAAM;gBACFA;YACJ;QACJ,SARc,IAAI,GAAG;IASzB;AACJ;AAEO,MAAMC,6BAA6BP;IAGtC,aAAc;QACV,KAAK,CAAC;YACF,SAAS;QACb,SALc,IAAI,GAAG;IAMzB;AACJ"}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
3
|
+
import { SettingsNotAuthorized } from "../../domain/errors.js";
|
|
2
4
|
import { GetSettingsUseCase, GetSettingsRepository, type ISettingsWithSource } from "./abstractions.js";
|
|
5
|
+
/**
|
|
6
|
+
* Settings for the GraphQL API. Internal callers (e.g. MailerService) read them through
|
|
7
|
+
* GetSettingsRepository.
|
|
8
|
+
*/
|
|
3
9
|
declare class GetSettingsUseCaseImpl implements GetSettingsUseCase.Interface {
|
|
10
|
+
private identityContext;
|
|
4
11
|
private repository;
|
|
5
|
-
constructor(repository: GetSettingsRepository.Interface);
|
|
6
|
-
execute(transportName: string): Promise<Result<ISettingsWithSource>>;
|
|
12
|
+
constructor(identityContext: IdentityContext.Interface, repository: GetSettingsRepository.Interface);
|
|
13
|
+
execute(transportName: string): Promise<Result<ISettingsWithSource, SettingsNotAuthorized>>;
|
|
7
14
|
}
|
|
8
15
|
export declare const GetSettingsUseCaseImplementation: typeof GetSettingsUseCaseImpl & {
|
|
9
16
|
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetSettingsUseCase>;
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
3
|
+
import { SettingsNotAuthorized } from "../../domain/errors.js";
|
|
1
4
|
import { GetSettingsRepository, GetSettingsUseCase } from "./abstractions.js";
|
|
2
5
|
class GetSettingsUseCaseImpl {
|
|
3
|
-
constructor(repository){
|
|
6
|
+
constructor(identityContext, repository){
|
|
7
|
+
this.identityContext = identityContext;
|
|
4
8
|
this.repository = repository;
|
|
5
9
|
}
|
|
6
|
-
execute(transportName) {
|
|
10
|
+
async execute(transportName) {
|
|
11
|
+
const permission = await this.identityContext.getPermission("mailer.settings");
|
|
12
|
+
if (!permission) return Result.fail(new SettingsNotAuthorized("Not allowed to read the mailer settings."));
|
|
7
13
|
return this.repository.get(transportName);
|
|
8
14
|
}
|
|
9
15
|
}
|
|
10
16
|
const GetSettingsUseCaseImplementation = GetSettingsUseCase.createImplementation({
|
|
11
17
|
implementation: GetSettingsUseCaseImpl,
|
|
12
18
|
dependencies: [
|
|
19
|
+
IdentityContext,
|
|
13
20
|
GetSettingsRepository
|
|
14
21
|
]
|
|
15
22
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/GetSettings/GetSettingsUseCase.js","sources":["../../../src/features/GetSettings/GetSettingsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n GetSettingsUseCase,\n GetSettingsRepository,\n type ISettingsWithSource\n} from \"./abstractions.js\";\n\nclass GetSettingsUseCaseImpl implements GetSettingsUseCase.Interface {\n constructor(private repository: GetSettingsRepository.Interface) {}\n\n execute(transportName: string): Promise<Result<ISettingsWithSource>> {\n return this.repository.get(transportName);\n }\n}\n\nexport const GetSettingsUseCaseImplementation = GetSettingsUseCase.createImplementation({\n implementation: GetSettingsUseCaseImpl,\n dependencies: [GetSettingsRepository]\n});\n"],"names":["GetSettingsUseCaseImpl","repository","transportName","GetSettingsUseCaseImplementation","GetSettingsUseCase","GetSettingsRepository"],"mappings":"
|
|
1
|
+
{"version":3,"file":"features/GetSettings/GetSettingsUseCase.js","sources":["../../../src/features/GetSettings/GetSettingsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { SettingsNotAuthorized } from \"~/domain/errors.js\";\nimport {\n GetSettingsUseCase,\n GetSettingsRepository,\n type ISettingsWithSource\n} from \"./abstractions.js\";\n\n/**\n * Settings for the GraphQL API. Internal callers (e.g. MailerService) read them through\n * GetSettingsRepository.\n */\nclass GetSettingsUseCaseImpl implements GetSettingsUseCase.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private repository: GetSettingsRepository.Interface\n ) {}\n\n async execute(\n transportName: string\n ): Promise<Result<ISettingsWithSource, SettingsNotAuthorized>> {\n const permission = await this.identityContext.getPermission(\"mailer.settings\");\n if (!permission) {\n return Result.fail(\n new SettingsNotAuthorized(\"Not allowed to read the mailer settings.\")\n );\n }\n\n return this.repository.get(transportName);\n }\n}\n\nexport const GetSettingsUseCaseImplementation = GetSettingsUseCase.createImplementation({\n implementation: GetSettingsUseCaseImpl,\n dependencies: [IdentityContext, GetSettingsRepository]\n});\n"],"names":["GetSettingsUseCaseImpl","identityContext","repository","transportName","permission","Result","SettingsNotAuthorized","GetSettingsUseCaseImplementation","GetSettingsUseCase","IdentityContext","GetSettingsRepository"],"mappings":";;;;AAaA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,UAA2C,CACrD;aAFUD,eAAe,GAAfA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,QACFC,aAAqB,EACsC;QAC3D,MAAMC,aAAa,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC;QAC5D,IAAI,CAACA,YACD,OAAOC,OAAO,IAAI,CACd,IAAIC,sBAAsB;QAIlC,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAACH;IAC/B;AACJ;AAEO,MAAMI,mCAAmCC,mBAAmB,oBAAoB,CAAC;IACpF,gBAAgBR;IAChB,cAAc;QAACS;QAAiBC;KAAsB;AAC1D"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SettingsNotAuthorized } from "../../domain/errors.js";
|
|
1
2
|
import { Result } from "@webiny/feature/api";
|
|
2
3
|
import type { TransportSettings } from "../../types.js";
|
|
3
4
|
export type MailerSettingsSource = "code" | "storage" | null;
|
|
@@ -14,7 +15,7 @@ export declare namespace GetSettingsRepository {
|
|
|
14
15
|
type Return = Promise<Result<ISettingsWithSource>>;
|
|
15
16
|
}
|
|
16
17
|
export interface IGetSettingsUseCase {
|
|
17
|
-
execute(transportName: string): Promise<Result<ISettingsWithSource>>;
|
|
18
|
+
execute(transportName: string): Promise<Result<ISettingsWithSource, SettingsNotAuthorized>>;
|
|
18
19
|
}
|
|
19
20
|
export declare const GetSettingsUseCase: import("@webiny/di").Abstraction<IGetSettingsUseCase>;
|
|
20
21
|
export declare namespace GetSettingsUseCase {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/GetSettings/abstractions.js","sources":["../../../src/features/GetSettings/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { TransportSettings } from \"~/types.js\";\n\nexport type MailerSettingsSource = \"code\" | \"storage\" | null;\n\nexport interface ISettingsWithSource {\n settings: TransportSettings | null;\n source: MailerSettingsSource;\n}\n\nexport interface IGetSettingsRepository {\n get(transportName: string): Promise<Result<ISettingsWithSource>>;\n}\n\nexport const GetSettingsRepository =\n createAbstraction<IGetSettingsRepository>(\"GetSettingsRepository\");\n\nexport namespace GetSettingsRepository {\n export type Interface = IGetSettingsRepository;\n export type Return = Promise<Result<ISettingsWithSource>>;\n}\n\nexport interface IGetSettingsUseCase {\n execute(transportName: string): Promise<Result<ISettingsWithSource>>;\n}\n\nexport const GetSettingsUseCase = createAbstraction<IGetSettingsUseCase>(\"GetSettingsUseCase\");\n\nexport namespace GetSettingsUseCase {\n export type Interface = IGetSettingsUseCase;\n}\n"],"names":["GetSettingsRepository","createAbstraction","GetSettingsUseCase"],"mappings":";
|
|
1
|
+
{"version":3,"file":"features/GetSettings/abstractions.js","sources":["../../../src/features/GetSettings/abstractions.ts"],"sourcesContent":["import type { SettingsNotAuthorized } from \"~/domain/errors.js\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { TransportSettings } from \"~/types.js\";\n\nexport type MailerSettingsSource = \"code\" | \"storage\" | null;\n\nexport interface ISettingsWithSource {\n settings: TransportSettings | null;\n source: MailerSettingsSource;\n}\n\nexport interface IGetSettingsRepository {\n get(transportName: string): Promise<Result<ISettingsWithSource>>;\n}\n\nexport const GetSettingsRepository =\n createAbstraction<IGetSettingsRepository>(\"GetSettingsRepository\");\n\nexport namespace GetSettingsRepository {\n export type Interface = IGetSettingsRepository;\n export type Return = Promise<Result<ISettingsWithSource>>;\n}\n\nexport interface IGetSettingsUseCase {\n execute(transportName: string): Promise<Result<ISettingsWithSource, SettingsNotAuthorized>>;\n}\n\nexport const GetSettingsUseCase = createAbstraction<IGetSettingsUseCase>(\"GetSettingsUseCase\");\n\nexport namespace GetSettingsUseCase {\n export type Interface = IGetSettingsUseCase;\n}\n"],"names":["GetSettingsRepository","createAbstraction","GetSettingsUseCase"],"mappings":";AAgBO,MAAMA,wBACTC,kBAA0C;AAWvC,MAAMC,qBAAqBD,kBAAuC"}
|
|
@@ -5,7 +5,7 @@ export declare class SmtpMailTransport implements MailTransport.Interface {
|
|
|
5
5
|
private readonly transporter;
|
|
6
6
|
constructor(config: SMTPTransport.Options);
|
|
7
7
|
send(params: MailTransport.SendParams): Promise<{
|
|
8
|
-
result: string
|
|
8
|
+
result: string;
|
|
9
9
|
error: null;
|
|
10
10
|
} | {
|
|
11
11
|
result: null;
|
|
@@ -13,19 +13,20 @@ export declare class SmtpMailTransport implements MailTransport.Interface {
|
|
|
13
13
|
message: string;
|
|
14
14
|
code: string;
|
|
15
15
|
data: {
|
|
16
|
-
[key: string]:
|
|
16
|
+
[key: string]: any;
|
|
17
17
|
envelope: import("nodemailer/lib/mime-node").MimeNodeEnvelope;
|
|
18
18
|
messageId: string;
|
|
19
19
|
accepted: string[];
|
|
20
20
|
rejected: string[];
|
|
21
|
+
response: string;
|
|
22
|
+
envelopeTime: number;
|
|
23
|
+
messageTime: number;
|
|
24
|
+
messageSize: number;
|
|
25
|
+
serverMessageId?: string | undefined;
|
|
21
26
|
ehlo?: string[] | undefined;
|
|
22
27
|
rejectedErrors?: import("nodemailer").NodemailerError[] | undefined;
|
|
23
|
-
envelopeTime?: number | undefined;
|
|
24
|
-
messageTime?: number | undefined;
|
|
25
|
-
messageSize?: number | undefined;
|
|
26
|
-
response?: string | undefined;
|
|
27
28
|
pending?: string[] | undefined;
|
|
28
|
-
message?:
|
|
29
|
+
message?: any;
|
|
29
30
|
};
|
|
30
31
|
};
|
|
31
32
|
} | {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-mailer",
|
|
3
|
-
"version": "6.4.12-beta.
|
|
3
|
+
"version": "6.4.12-beta.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -18,29 +18,29 @@
|
|
|
18
18
|
"description": "The API to send e-mails.",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@webiny/api": "6.4.12-beta.
|
|
22
|
-
"@webiny/api-headless-cms": "6.4.12-beta.
|
|
23
|
-
"@webiny/feature": "6.4.12-beta.
|
|
24
|
-
"@webiny/handler-graphql": "6.4.12-beta.
|
|
25
|
-
"@webiny/plugins": "6.4.12-beta.
|
|
21
|
+
"@webiny/api": "6.4.12-beta.8",
|
|
22
|
+
"@webiny/api-headless-cms": "6.4.12-beta.8",
|
|
23
|
+
"@webiny/feature": "6.4.12-beta.8",
|
|
24
|
+
"@webiny/handler-graphql": "6.4.12-beta.8",
|
|
25
|
+
"@webiny/plugins": "6.4.12-beta.8",
|
|
26
26
|
"email-addresses": "5.0.0",
|
|
27
|
-
"nodemailer": "10.0
|
|
28
|
-
"zod": "4.6.
|
|
27
|
+
"nodemailer": "10.5.0",
|
|
28
|
+
"zod": "4.6.7"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/nodemailer": "8.0.2",
|
|
32
|
-
"@webiny/api-core": "6.4.12-beta.
|
|
33
|
-
"@webiny/build-tools": "6.4.12-beta.
|
|
34
|
-
"@webiny/db-dynamodb": "6.4.12-beta.
|
|
35
|
-
"@webiny/handler": "6.4.12-beta.
|
|
36
|
-
"@webiny/handler-aws": "6.4.12-beta.
|
|
37
|
-
"@webiny/handler-db": "6.4.12-beta.
|
|
38
|
-
"@webiny/project-utils": "6.4.12-beta.
|
|
39
|
-
"graphql": "16.
|
|
32
|
+
"@webiny/api-core": "6.4.12-beta.8",
|
|
33
|
+
"@webiny/build-tools": "6.4.12-beta.8",
|
|
34
|
+
"@webiny/db-dynamodb": "6.4.12-beta.8",
|
|
35
|
+
"@webiny/handler": "6.4.12-beta.8",
|
|
36
|
+
"@webiny/handler-aws": "6.4.12-beta.8",
|
|
37
|
+
"@webiny/handler-db": "6.4.12-beta.8",
|
|
38
|
+
"@webiny/project-utils": "6.4.12-beta.8",
|
|
39
|
+
"graphql": "16.15.0",
|
|
40
40
|
"jest-dynalite": "3.6.1",
|
|
41
|
-
"rimraf": "6.1.
|
|
41
|
+
"rimraf": "6.1.4",
|
|
42
42
|
"typescript": "6.0.3",
|
|
43
|
-
"vitest": "5.0
|
|
43
|
+
"vitest": "5.1.0"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|