@webiny/api-mailer 6.4.5 → 6.6.0-alpha.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.
- package/MailerFeature.d.ts +4 -0
- package/MailerFeature.js +25 -0
- package/MailerFeature.js.map +1 -0
- package/features/CodeMailerSettings/{CodeMailerSettingsImpl.js → CodeMailerSettings.js} +3 -3
- package/features/CodeMailerSettings/CodeMailerSettings.js.map +1 -0
- package/features/CodeMailerSettings/feature.js +1 -1
- package/features/CodeMailerSettings/feature.js.map +1 -1
- package/features/SaveSettings/validation.d.ts +2 -2
- package/features/SmtpTransport/SmtpMailTransport.d.ts +9 -9
- package/graphql/MailerSchemaFactory.d.ts +9 -0
- package/graphql/{settings.js → MailerSchemaFactory.js} +37 -24
- package/graphql/MailerSchemaFactory.js.map +1 -0
- package/index.d.ts +1 -2
- package/index.js +1 -22
- package/package.json +11 -15
- package/features/CodeMailerSettings/CodeMailerSettingsImpl.js.map +0 -1
- package/graphql/settings.d.ts +0 -3
- package/graphql/settings.js.map +0 -1
- package/index.js.map +0 -1
- /package/features/CodeMailerSettings/{CodeMailerSettingsImpl.d.ts → CodeMailerSettings.d.ts} +0 -0
package/MailerFeature.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { CodeMailerSettingsFeature } from "./features/CodeMailerSettings/feature.js";
|
|
3
|
+
import { DummyTransportFeature } from "./features/DummyTransport/feature.js";
|
|
4
|
+
import { SmtpTransportFeature } from "./features/SmtpTransport/feature.js";
|
|
5
|
+
import { GetSettingsFeature } from "./features/GetSettings/feature.js";
|
|
6
|
+
import { SaveSettingsFeature } from "./features/SaveSettings/feature.js";
|
|
7
|
+
import { MailerServiceFeature } from "./features/MailerService/feature.js";
|
|
8
|
+
import { SendMailFeature } from "./features/SendMail/feature.js";
|
|
9
|
+
import { MailerSchemaFactory } from "./graphql/MailerSchemaFactory.js";
|
|
10
|
+
const MailerFeature = createFeature({
|
|
11
|
+
name: "Mailer",
|
|
12
|
+
register (container) {
|
|
13
|
+
CodeMailerSettingsFeature.register(container);
|
|
14
|
+
DummyTransportFeature.register(container);
|
|
15
|
+
SmtpTransportFeature.register(container);
|
|
16
|
+
GetSettingsFeature.register(container);
|
|
17
|
+
SaveSettingsFeature.register(container);
|
|
18
|
+
MailerServiceFeature.register(container);
|
|
19
|
+
SendMailFeature.register(container);
|
|
20
|
+
container.register(MailerSchemaFactory);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
export { MailerFeature };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=MailerFeature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MailerFeature.js","sources":["../src/MailerFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { CodeMailerSettingsFeature } from \"~/features/CodeMailerSettings/feature.js\";\nimport { DummyTransportFeature } from \"~/features/DummyTransport/feature.js\";\nimport { SmtpTransportFeature } from \"~/features/SmtpTransport/feature.js\";\nimport { GetSettingsFeature } from \"~/features/GetSettings/feature.js\";\nimport { SaveSettingsFeature } from \"~/features/SaveSettings/feature.js\";\nimport { MailerServiceFeature } from \"~/features/MailerService/feature.js\";\nimport { SendMailFeature } from \"~/features/SendMail/feature.js\";\nimport { MailerSchemaFactory } from \"~/graphql/MailerSchemaFactory.js\";\n\nexport const MailerFeature = createFeature({\n name: \"Mailer\",\n register(container) {\n CodeMailerSettingsFeature.register(container);\n DummyTransportFeature.register(container);\n SmtpTransportFeature.register(container);\n GetSettingsFeature.register(container);\n SaveSettingsFeature.register(container);\n MailerServiceFeature.register(container);\n SendMailFeature.register(container);\n container.register(MailerSchemaFactory);\n }\n});\n"],"names":["MailerFeature","createFeature","container","CodeMailerSettingsFeature","DummyTransportFeature","SmtpTransportFeature","GetSettingsFeature","SaveSettingsFeature","MailerServiceFeature","SendMailFeature","MailerSchemaFactory"],"mappings":";;;;;;;;;AAUO,MAAMA,gBAAgBC,cAAc;IACvC,MAAM;IACN,UAASC,SAAS;QACdC,0BAA0B,QAAQ,CAACD;QACnCE,sBAAsB,QAAQ,CAACF;QAC/BG,qBAAqB,QAAQ,CAACH;QAC9BI,mBAAmB,QAAQ,CAACJ;QAC5BK,oBAAoB,QAAQ,CAACL;QAC7BM,qBAAqB,QAAQ,CAACN;QAC9BO,gBAAgB,QAAQ,CAACP;QACzBA,UAAU,QAAQ,CAACQ;IACvB;AACJ"}
|
|
@@ -12,12 +12,12 @@ class CodeMailerSettingsImpl {
|
|
|
12
12
|
return value ?? null;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
const
|
|
15
|
+
const CodeMailerSettings_CodeMailerSettings = CodeMailerSettings.createImplementation({
|
|
16
16
|
implementation: CodeMailerSettingsImpl,
|
|
17
17
|
dependencies: [
|
|
18
18
|
BuildParams
|
|
19
19
|
]
|
|
20
20
|
});
|
|
21
|
-
export {
|
|
21
|
+
export { CodeMailerSettings_CodeMailerSettings as CodeMailerSettings };
|
|
22
22
|
|
|
23
|
-
//# sourceMappingURL=
|
|
23
|
+
//# sourceMappingURL=CodeMailerSettings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/CodeMailerSettings/CodeMailerSettings.js","sources":["../../../src/features/CodeMailerSettings/CodeMailerSettings.ts"],"sourcesContent":["import { BuildParams } from \"@webiny/api-core/features/buildParams/index.js\";\nimport { CodeMailerSettings as Abstraction } from \"~/domain/CodeMailerSettings/abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\n\nconst SMTP_TRANSPORT_NAME = \"Mailer/SmtpTransport\";\nconst SMTP_BUILD_PARAM_KEY = \"Mailer.SmtpSettings\";\n\nclass CodeMailerSettingsImpl implements Abstraction.Interface {\n constructor(private buildParams: BuildParams.Interface) {}\n\n get(transportName: string): TransportSettings | null {\n if (transportName !== SMTP_TRANSPORT_NAME) {\n return null;\n }\n const value = this.buildParams.get<TransportSettings>(SMTP_BUILD_PARAM_KEY);\n return value ?? null;\n }\n}\n\nexport const CodeMailerSettings = Abstraction.createImplementation({\n implementation: CodeMailerSettingsImpl,\n dependencies: [BuildParams]\n});\n"],"names":["SMTP_TRANSPORT_NAME","SMTP_BUILD_PARAM_KEY","CodeMailerSettingsImpl","buildParams","transportName","value","CodeMailerSettings","Abstraction","BuildParams"],"mappings":";;AAIA,MAAMA,sBAAsB;AAC5B,MAAMC,uBAAuB;AAE7B,MAAMC;IACF,YAAoBC,WAAkC,CAAE;aAApCA,WAAW,GAAXA;IAAqC;IAEzD,IAAIC,aAAqB,EAA4B;QACjD,IAAIA,kBAAkBJ,qBAClB,OAAO;QAEX,MAAMK,QAAQ,IAAI,CAAC,WAAW,CAAC,GAAG,CAAoBJ;QACtD,OAAOI,SAAS;IACpB;AACJ;AAEO,MAAMC,wCAAqBC,mBAAAA,oBAAgC,CAAC;IAC/D,gBAAgBL;IAChB,cAAc;QAACM;KAAY;AAC/B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
|
-
import { CodeMailerSettings } from "./
|
|
2
|
+
import { CodeMailerSettings } from "./CodeMailerSettings.js";
|
|
3
3
|
const CodeMailerSettingsFeature = createFeature({
|
|
4
4
|
name: "Mailer/CodeMailerSettings",
|
|
5
5
|
register (container) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/CodeMailerSettings/feature.js","sources":["../../../src/features/CodeMailerSettings/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { CodeMailerSettings } from \"./
|
|
1
|
+
{"version":3,"file":"features/CodeMailerSettings/feature.js","sources":["../../../src/features/CodeMailerSettings/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { CodeMailerSettings } from \"./CodeMailerSettings.js\";\n\nexport const CodeMailerSettingsFeature = createFeature({\n name: \"Mailer/CodeMailerSettings\",\n register(container) {\n container.register(CodeMailerSettings).inSingletonScope();\n }\n});\n"],"names":["CodeMailerSettingsFeature","createFeature","container","CodeMailerSettings"],"mappings":";;AAGO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,oBAAoB,gBAAgB;IAC3D;AACJ"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import zod from "zod";
|
|
2
2
|
export declare const saveValidation: zod.ZodObject<{
|
|
3
|
-
secure: zod.ZodOptional<zod.ZodBoolean>;
|
|
4
|
-
password: zod.ZodPipe<zod.ZodOptional<zod.ZodOptional<zod.ZodNullable<zod.ZodString>>>, zod.ZodTransform<string | null, string | null | undefined>>;
|
|
5
3
|
from: zod.ZodString;
|
|
6
4
|
port: zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodNumber>>>;
|
|
7
5
|
replyTo: zod.ZodPreprocess<zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodString>>>>;
|
|
8
6
|
host: zod.ZodString;
|
|
9
7
|
user: zod.ZodString;
|
|
8
|
+
secure: zod.ZodOptional<zod.ZodBoolean>;
|
|
9
|
+
password: zod.ZodPipe<zod.ZodOptional<zod.ZodOptional<zod.ZodNullable<zod.ZodString>>>, zod.ZodTransform<string | null, string | null | undefined>>;
|
|
10
10
|
}, zod.core.$strip>;
|
|
@@ -27,21 +27,18 @@ export declare class SmtpMailTransport implements MailTransport.Interface {
|
|
|
27
27
|
message: any;
|
|
28
28
|
code: any;
|
|
29
29
|
data: {
|
|
30
|
-
|
|
31
|
-
response: any;
|
|
32
|
-
responseCode: any;
|
|
33
|
-
to: string[];
|
|
30
|
+
to?: string[];
|
|
34
31
|
cc?: string[];
|
|
35
|
-
bcc
|
|
32
|
+
bcc: string[];
|
|
36
33
|
from?: string;
|
|
37
34
|
subject: string;
|
|
38
35
|
text?: string;
|
|
39
36
|
html?: string;
|
|
40
37
|
replyTo?: string;
|
|
41
|
-
} | {
|
|
42
38
|
command: any;
|
|
43
39
|
response: any;
|
|
44
40
|
responseCode: any;
|
|
41
|
+
} | {
|
|
45
42
|
to?: string[];
|
|
46
43
|
cc: string[];
|
|
47
44
|
bcc?: string[];
|
|
@@ -50,18 +47,21 @@ export declare class SmtpMailTransport implements MailTransport.Interface {
|
|
|
50
47
|
text?: string;
|
|
51
48
|
html?: string;
|
|
52
49
|
replyTo?: string;
|
|
53
|
-
} | {
|
|
54
50
|
command: any;
|
|
55
51
|
response: any;
|
|
56
52
|
responseCode: any;
|
|
57
|
-
|
|
53
|
+
} | {
|
|
54
|
+
to: string[];
|
|
58
55
|
cc?: string[];
|
|
59
|
-
bcc
|
|
56
|
+
bcc?: string[];
|
|
60
57
|
from?: string;
|
|
61
58
|
subject: string;
|
|
62
59
|
text?: string;
|
|
63
60
|
html?: string;
|
|
64
61
|
replyTo?: string;
|
|
62
|
+
command: any;
|
|
63
|
+
response: any;
|
|
64
|
+
responseCode: any;
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
67
|
}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import type { IGraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js";
|
|
3
|
+
declare class MailerSchemaFactoryImpl implements GraphQLSchemaFactory.Interface {
|
|
4
|
+
execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder>;
|
|
5
|
+
}
|
|
6
|
+
export declare const MailerSchemaFactory: typeof MailerSchemaFactoryImpl & {
|
|
7
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-graphql/graphql/abstractions.public").IGraphQLSchemaFactory>;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import { ErrorResponse } from "@webiny/api-graphql/responses.js";
|
|
2
3
|
import { GetSettingsUseCase } from "../features/GetSettings/abstractions.js";
|
|
3
4
|
import { SaveSettingsUseCase } from "../features/SaveSettings/abstractions.js";
|
|
4
5
|
const SMTP_TRANSPORT_NAME = "Mailer/SmtpTransport";
|
|
5
|
-
const emptyResolver = ()=>({});
|
|
6
6
|
const toPublicSettings = (settings, source)=>{
|
|
7
7
|
if (!settings) return null;
|
|
8
8
|
const { password: _password, ...publicSettings } = settings;
|
|
@@ -11,8 +11,9 @@ const toPublicSettings = (settings, source)=>{
|
|
|
11
11
|
source
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
class MailerSchemaFactoryImpl {
|
|
15
|
+
async execute(builder) {
|
|
16
|
+
builder.addTypeDefs(`
|
|
16
17
|
type MailerTransportSettingsError {
|
|
17
18
|
message: String!
|
|
18
19
|
code: String
|
|
@@ -58,15 +59,22 @@ const createSettingsGraphQL = ()=>new GraphQLSchemaPlugin({
|
|
|
58
59
|
extend type Mutation {
|
|
59
60
|
mailer: MailerMutation
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
`);
|
|
63
|
+
builder.addResolver({
|
|
64
|
+
path: "Query.mailer",
|
|
65
|
+
resolver: ()=>async ()=>({})
|
|
66
|
+
});
|
|
67
|
+
builder.addResolver({
|
|
68
|
+
path: "Mutation.mailer",
|
|
69
|
+
resolver: ()=>async ()=>({})
|
|
70
|
+
});
|
|
71
|
+
builder.addResolver({
|
|
72
|
+
path: "MailerQuery.getSettings",
|
|
73
|
+
dependencies: [
|
|
74
|
+
GetSettingsUseCase
|
|
75
|
+
],
|
|
76
|
+
resolver: (getSettings)=>async ()=>{
|
|
68
77
|
try {
|
|
69
|
-
const getSettings = context.container.resolve(GetSettingsUseCase);
|
|
70
78
|
const result = await getSettings.execute(SMTP_TRANSPORT_NAME);
|
|
71
79
|
const { settings, source } = result.value;
|
|
72
80
|
return {
|
|
@@ -77,14 +85,14 @@ const createSettingsGraphQL = ()=>new GraphQLSchemaPlugin({
|
|
|
77
85
|
return new ErrorResponse(ex);
|
|
78
86
|
}
|
|
79
87
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
});
|
|
89
|
+
builder.addResolver({
|
|
90
|
+
path: "MailerMutation.saveSettings",
|
|
91
|
+
dependencies: [
|
|
92
|
+
SaveSettingsUseCase
|
|
93
|
+
],
|
|
94
|
+
resolver: (saveSettings)=>async ({ args })=>{
|
|
86
95
|
try {
|
|
87
|
-
const saveSettings = context.container.resolve(SaveSettingsUseCase);
|
|
88
96
|
const result = await saveSettings.execute(args.data);
|
|
89
97
|
if (result.isFail()) return new ErrorResponse(result.error);
|
|
90
98
|
return {
|
|
@@ -95,9 +103,14 @@ const createSettingsGraphQL = ()=>new GraphQLSchemaPlugin({
|
|
|
95
103
|
return new ErrorResponse(ex);
|
|
96
104
|
}
|
|
97
105
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
106
|
+
});
|
|
107
|
+
return builder;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const MailerSchemaFactory = GraphQLSchemaFactory.createImplementation({
|
|
111
|
+
implementation: MailerSchemaFactoryImpl,
|
|
112
|
+
dependencies: []
|
|
113
|
+
});
|
|
114
|
+
export { MailerSchemaFactory };
|
|
102
115
|
|
|
103
|
-
//# sourceMappingURL=
|
|
116
|
+
//# sourceMappingURL=MailerSchemaFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/MailerSchemaFactory.js","sources":["../../src/graphql/MailerSchemaFactory.ts"],"sourcesContent":["import { GraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { ErrorResponse } from \"@webiny/api-graphql/responses.js\";\nimport { GetSettingsUseCase } from \"~/features/GetSettings/abstractions.js\";\nimport { SaveSettingsUseCase } from \"~/features/SaveSettings/abstractions.js\";\nimport type { MailerSettingsSource } from \"~/features/GetSettings/abstractions.js\";\nimport type { SaveSettingsInput } from \"~/features/SaveSettings/abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\n\nconst SMTP_TRANSPORT_NAME = \"Mailer/SmtpTransport\";\n\n// Strip `password` before the settings leave the server and tack on `source`\n// so the admin UI can branch on code-vs-storage. Accepts both the full\n// `TransportSettings` (from getSettings) and the already-stripped\n// `Omit<TransportSettings, \"password\">` (from saveSettings) — defense in depth\n// even when the input type carries no password to begin with.\nconst toPublicSettings = (\n settings: TransportSettings | Omit<TransportSettings, \"password\"> | null,\n source: MailerSettingsSource\n): (Omit<TransportSettings, \"password\"> & { source: MailerSettingsSource }) | null => {\n if (!settings) {\n return null;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { password: _password, ...publicSettings } = settings as TransportSettings;\n return { ...publicSettings, source };\n};\n\nclass MailerSchemaFactoryImpl implements GraphQLSchemaFactory.Interface {\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n builder.addTypeDefs(`\n type MailerTransportSettingsError {\n message: String!\n code: String\n data: JSON\n }\n\n type MailerTransportSettings {\n host: String\n port: Number\n secure: Boolean\n user: String\n from: String\n replyTo: String\n source: String\n }\n\n type MailerTransportSettingsResponse {\n data: MailerTransportSettings\n error: MailerTransportSettingsError\n }\n\n type MailerQuery {\n getSettings: MailerTransportSettingsResponse!\n }\n\n input MailerTransportSettingsInput {\n host: String!\n port: Number\n secure: Boolean\n user: String!\n password: String\n from: String!\n replyTo: String\n }\n\n type MailerMutation {\n saveSettings(data: MailerTransportSettingsInput!): MailerTransportSettingsResponse!\n }\n\n extend type Query {\n mailer: MailerQuery\n }\n extend type Mutation {\n mailer: MailerMutation\n }\n `);\n\n builder.addResolver({\n path: \"Query.mailer\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"Mutation.mailer\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"MailerQuery.getSettings\",\n dependencies: [GetSettingsUseCase],\n resolver: (getSettings: GetSettingsUseCase.Interface) => async () => {\n try {\n const result = await getSettings.execute(SMTP_TRANSPORT_NAME);\n\n const { settings, source } = result.value;\n\n return {\n data: toPublicSettings(settings, source),\n error: null\n };\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n }\n });\n\n builder.addResolver<{ data: SaveSettingsInput }>({\n path: \"MailerMutation.saveSettings\",\n dependencies: [SaveSettingsUseCase],\n resolver:\n (saveSettings: SaveSettingsUseCase.Interface) =>\n async ({ args }) => {\n try {\n const result = await saveSettings.execute(args.data);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return {\n data: toPublicSettings(result.value, \"storage\"),\n error: null\n };\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n }\n });\n\n return builder;\n }\n}\n\nexport const MailerSchemaFactory = GraphQLSchemaFactory.createImplementation({\n implementation: MailerSchemaFactoryImpl,\n dependencies: []\n});\n"],"names":["SMTP_TRANSPORT_NAME","toPublicSettings","settings","source","_password","publicSettings","MailerSchemaFactoryImpl","builder","GetSettingsUseCase","getSettings","result","ex","ErrorResponse","SaveSettingsUseCase","saveSettings","args","MailerSchemaFactory","GraphQLSchemaFactory"],"mappings":";;;;AASA,MAAMA,sBAAsB;AAO5B,MAAMC,mBAAmB,CACrBC,UACAC;IAEA,IAAI,CAACD,UACD,OAAO;IAGX,MAAM,EAAE,UAAUE,SAAS,EAAE,GAAGC,gBAAgB,GAAGH;IACnD,OAAO;QAAE,GAAGG,cAAc;QAAEF;IAAO;AACvC;AAEA,MAAMG;IACF,MAAM,QAAQC,OAA8B,EAAkC;QAC1EA,QAAQ,WAAW,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA8CrB,CAAC;QAEDA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,UAAU,IAAM,UAAa,EAAC;QAClC;QAEAA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,UAAU,IAAM,UAAa,EAAC;QAClC;QAEAA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc;gBAACC;aAAmB;YAClC,UAAU,CAACC,cAA8C;oBACrD,IAAI;wBACA,MAAMC,SAAS,MAAMD,YAAY,OAAO,CAACT;wBAEzC,MAAM,EAAEE,QAAQ,EAAEC,MAAM,EAAE,GAAGO,OAAO,KAAK;wBAEzC,OAAO;4BACH,MAAMT,iBAAiBC,UAAUC;4BACjC,OAAO;wBACX;oBACJ,EAAE,OAAOQ,IAAI;wBACT,OAAO,IAAIC,cAAcD;oBAC7B;gBACJ;QACJ;QAEAJ,QAAQ,WAAW,CAA8B;YAC7C,MAAM;YACN,cAAc;gBAACM;aAAoB;YACnC,UACI,CAACC,eACD,OAAO,EAAEC,IAAI,EAAE;oBACX,IAAI;wBACA,MAAML,SAAS,MAAMI,aAAa,OAAO,CAACC,KAAK,IAAI;wBAEnD,IAAIL,OAAO,MAAM,IACb,OAAO,IAAIE,cAAcF,OAAO,KAAK;wBAGzC,OAAO;4BACH,MAAMT,iBAAiBS,OAAO,KAAK,EAAE;4BACrC,OAAO;wBACX;oBACJ,EAAE,OAAOC,IAAI;wBACT,OAAO,IAAIC,cAAcD;oBAC7B;gBACJ;QACR;QAEA,OAAOJ;IACX;AACJ;AAEO,MAAMS,sBAAsBC,qBAAqB,oBAAoB,CAAC;IACzE,gBAAgBX;IAChB,cAAc,EAAE;AACpB"}
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
+
export { MailerFeature } from "./MailerFeature.js";
|
|
1
2
|
export { MailerService } from "./domain/MailerService/abstractions.js";
|
|
2
3
|
export type { IMailerService, IMailerServiceErrors } from "./domain/MailerService/abstractions.js";
|
|
3
|
-
export declare const createMailerContext: () => import("@webiny/handler").RegisterExtensionPlugin<import("@webiny/handler/types.js").Context>;
|
|
4
|
-
export declare const createMailerGraphQL: () => import("@webiny/handler-graphql/index.js").GraphQLSchemaPlugin<import("@webiny/api/types.js").Context>;
|
package/index.js
CHANGED
|
@@ -1,23 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { GetSettingsFeature } from "./features/GetSettings/feature.js";
|
|
3
|
-
import { SaveSettingsFeature } from "./features/SaveSettings/feature.js";
|
|
4
|
-
import { DummyTransportFeature } from "./features/DummyTransport/feature.js";
|
|
5
|
-
import { SmtpTransportFeature } from "./features/SmtpTransport/feature.js";
|
|
6
|
-
import { MailerServiceFeature } from "./features/MailerService/feature.js";
|
|
7
|
-
import { SendMailFeature } from "./features/SendMail/feature.js";
|
|
8
|
-
import { createSettingsGraphQL } from "./graphql/settings.js";
|
|
9
|
-
import { createRegisterExtensionPlugin } from "@webiny/handler";
|
|
10
|
-
const createMailerContext = ()=>createRegisterExtensionPlugin((context)=>{
|
|
11
|
-
CodeMailerSettingsFeature.register(context.container);
|
|
12
|
-
DummyTransportFeature.register(context.container);
|
|
13
|
-
SmtpTransportFeature.register(context.container);
|
|
14
|
-
GetSettingsFeature.register(context.container);
|
|
15
|
-
SaveSettingsFeature.register(context.container);
|
|
16
|
-
MailerServiceFeature.register(context.container);
|
|
17
|
-
SendMailFeature.register(context.container);
|
|
18
|
-
});
|
|
19
|
-
const createMailerGraphQL = ()=>createSettingsGraphQL();
|
|
1
|
+
export { MailerFeature } from "./MailerFeature.js";
|
|
20
2
|
export { MailerService } from "./domain/MailerService/abstractions.js";
|
|
21
|
-
export { createMailerContext, createMailerGraphQL };
|
|
22
|
-
|
|
23
|
-
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-mailer",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.0-alpha.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -18,28 +18,24 @@
|
|
|
18
18
|
"description": "The API to send e-mails.",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@webiny/api": "6.
|
|
22
|
-
"@webiny/
|
|
23
|
-
"@webiny/
|
|
24
|
-
"@webiny/handler-graphql": "6.4.5",
|
|
25
|
-
"@webiny/plugins": "6.4.5",
|
|
21
|
+
"@webiny/api-graphql": "6.6.0-alpha.0",
|
|
22
|
+
"@webiny/feature": "6.6.0-alpha.0",
|
|
23
|
+
"@webiny/plugins": "6.6.0-alpha.0",
|
|
26
24
|
"email-addresses": "5.0.0",
|
|
27
25
|
"nodemailer": "9.0.3",
|
|
28
26
|
"zod": "4.4.3"
|
|
29
27
|
},
|
|
30
28
|
"devDependencies": {
|
|
31
29
|
"@types/nodemailer": "8.0.1",
|
|
32
|
-
"@webiny/api-core": "6.
|
|
33
|
-
"@webiny/build-tools": "6.
|
|
34
|
-
"@webiny/
|
|
35
|
-
"@webiny/handler": "6.
|
|
36
|
-
"@webiny/handler
|
|
37
|
-
"@webiny/
|
|
38
|
-
"@webiny/project-utils": "6.4.5",
|
|
30
|
+
"@webiny/api-core": "6.6.0-alpha.0",
|
|
31
|
+
"@webiny/build-tools": "6.6.0-alpha.0",
|
|
32
|
+
"@webiny/di": "1.0.2",
|
|
33
|
+
"@webiny/event-handler-core": "6.6.0-alpha.0",
|
|
34
|
+
"@webiny/handler": "6.6.0-alpha.0",
|
|
35
|
+
"@webiny/project-utils": "6.6.0-alpha.0",
|
|
39
36
|
"graphql": "16.14.2",
|
|
40
|
-
"jest-dynalite": "3.6.1",
|
|
41
37
|
"rimraf": "6.1.3",
|
|
42
|
-
"typescript": "
|
|
38
|
+
"typescript": "7.0.2",
|
|
43
39
|
"vitest": "4.1.10"
|
|
44
40
|
},
|
|
45
41
|
"publishConfig": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"features/CodeMailerSettings/CodeMailerSettingsImpl.js","sources":["../../../src/features/CodeMailerSettings/CodeMailerSettingsImpl.ts"],"sourcesContent":["import { BuildParams } from \"@webiny/api-core/features/buildParams/index.js\";\nimport { CodeMailerSettings as Abstraction } from \"~/domain/CodeMailerSettings/abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\n\nconst SMTP_TRANSPORT_NAME = \"Mailer/SmtpTransport\";\nconst SMTP_BUILD_PARAM_KEY = \"Mailer.SmtpSettings\";\n\nclass CodeMailerSettingsImpl implements Abstraction.Interface {\n constructor(private buildParams: BuildParams.Interface) {}\n\n get(transportName: string): TransportSettings | null {\n if (transportName !== SMTP_TRANSPORT_NAME) {\n return null;\n }\n const value = this.buildParams.get<TransportSettings>(SMTP_BUILD_PARAM_KEY);\n return value ?? null;\n }\n}\n\nexport const CodeMailerSettings = Abstraction.createImplementation({\n implementation: CodeMailerSettingsImpl,\n dependencies: [BuildParams]\n});\n"],"names":["SMTP_TRANSPORT_NAME","SMTP_BUILD_PARAM_KEY","CodeMailerSettingsImpl","buildParams","transportName","value","CodeMailerSettings","Abstraction","BuildParams"],"mappings":";;AAIA,MAAMA,sBAAsB;AAC5B,MAAMC,uBAAuB;AAE7B,MAAMC;IACF,YAAoBC,WAAkC,CAAE;aAApCA,WAAW,GAAXA;IAAqC;IAEzD,IAAIC,aAAqB,EAA4B;QACjD,IAAIA,kBAAkBJ,qBAClB,OAAO;QAEX,MAAMK,QAAQ,IAAI,CAAC,WAAW,CAAC,GAAG,CAAoBJ;QACtD,OAAOI,SAAS;IACpB;AACJ;AAEO,MAAMC,4CAAqBC,mBAAAA,oBAAgC,CAAC;IAC/D,gBAAgBL;IAChB,cAAc;QAACM;KAAY;AAC/B"}
|
package/graphql/settings.d.ts
DELETED
package/graphql/settings.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/settings.js","sources":["../../src/graphql/settings.ts"],"sourcesContent":["import { ErrorResponse, GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { GetSettingsUseCase } from \"~/features/GetSettings/abstractions.js\";\nimport { SaveSettingsUseCase } from \"~/features/SaveSettings/abstractions.js\";\nimport type { MailerSettingsSource } from \"~/features/GetSettings/abstractions.js\";\nimport type { Context } from \"@webiny/api/types.js\";\nimport type { TransportSettings } from \"~/types.js\";\n\nconst SMTP_TRANSPORT_NAME = \"Mailer/SmtpTransport\";\n\nconst emptyResolver = () => ({});\n\n// Strip `password` before the settings leave the server and tack on `source`\n// so the admin UI can branch on code-vs-storage. Accepts both the full\n// `TransportSettings` (from getSettings) and the already-stripped\n// `Omit<TransportSettings, \"password\">` (from saveSettings) — defense in depth\n// even when the input type carries no password to begin with.\nconst toPublicSettings = (\n settings: TransportSettings | Omit<TransportSettings, \"password\"> | null,\n source: MailerSettingsSource\n): (Omit<TransportSettings, \"password\"> & { source: MailerSettingsSource }) | null => {\n if (!settings) {\n return null;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { password: _password, ...publicSettings } = settings as TransportSettings;\n return { ...publicSettings, source };\n};\n\nexport const createSettingsGraphQL = () => {\n return new GraphQLSchemaPlugin<Context>({\n typeDefs: `\n type MailerTransportSettingsError {\n message: String!\n code: String\n data: JSON\n }\n\n type MailerTransportSettings {\n host: String\n port: Number\n secure: Boolean\n user: String\n from: String\n replyTo: String\n source: String\n }\n\n type MailerTransportSettingsResponse {\n data: MailerTransportSettings\n error: MailerTransportSettingsError\n }\n\n type MailerQuery {\n getSettings: MailerTransportSettingsResponse!\n }\n\n input MailerTransportSettingsInput {\n host: String!\n port: Number\n secure: Boolean\n user: String!\n password: String\n from: String!\n replyTo: String\n }\n\n type MailerMutation {\n saveSettings(data: MailerTransportSettingsInput!): MailerTransportSettingsResponse!\n }\n\n extend type Query {\n mailer: MailerQuery\n }\n extend type Mutation {\n mailer: MailerMutation\n }\n `,\n resolvers: {\n Query: {\n mailer: emptyResolver\n },\n MailerQuery: {\n getSettings: async (_, __, context) => {\n try {\n const getSettings = context.container.resolve(GetSettingsUseCase);\n const result = await getSettings.execute(SMTP_TRANSPORT_NAME);\n\n const { settings, source } = result.value;\n\n return {\n data: toPublicSettings(settings, source),\n error: null\n };\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n }\n },\n Mutation: {\n mailer: emptyResolver\n },\n MailerMutation: {\n saveSettings: async (_, args: any, context) => {\n try {\n const saveSettings = context.container.resolve(SaveSettingsUseCase);\n const result = await saveSettings.execute(args.data);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return {\n data: toPublicSettings(result.value, \"storage\"),\n error: null\n };\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n }\n }\n }\n });\n};\n"],"names":["SMTP_TRANSPORT_NAME","emptyResolver","toPublicSettings","settings","source","_password","publicSettings","createSettingsGraphQL","GraphQLSchemaPlugin","_","__","context","getSettings","GetSettingsUseCase","result","ex","ErrorResponse","args","saveSettings","SaveSettingsUseCase"],"mappings":";;;AAOA,MAAMA,sBAAsB;AAE5B,MAAMC,gBAAgB,IAAO,EAAC;AAO9B,MAAMC,mBAAmB,CACrBC,UACAC;IAEA,IAAI,CAACD,UACD,OAAO;IAGX,MAAM,EAAE,UAAUE,SAAS,EAAE,GAAGC,gBAAgB,GAAGH;IACnD,OAAO;QAAE,GAAGG,cAAc;QAAEF;IAAO;AACvC;AAEO,MAAMG,wBAAwB,IAC1B,IAAIC,oBAA6B;QACpC,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA8CX,CAAC;QACD,WAAW;YACP,OAAO;gBACH,QAAQP;YACZ;YACA,aAAa;gBACT,aAAa,OAAOQ,GAAGC,IAAIC;oBACvB,IAAI;wBACA,MAAMC,cAAcD,QAAQ,SAAS,CAAC,OAAO,CAACE;wBAC9C,MAAMC,SAAS,MAAMF,YAAY,OAAO,CAACZ;wBAEzC,MAAM,EAAEG,QAAQ,EAAEC,MAAM,EAAE,GAAGU,OAAO,KAAK;wBAEzC,OAAO;4BACH,MAAMZ,iBAAiBC,UAAUC;4BACjC,OAAO;wBACX;oBACJ,EAAE,OAAOW,IAAI;wBACT,OAAO,IAAIC,cAAcD;oBAC7B;gBACJ;YACJ;YACA,UAAU;gBACN,QAAQd;YACZ;YACA,gBAAgB;gBACZ,cAAc,OAAOQ,GAAGQ,MAAWN;oBAC/B,IAAI;wBACA,MAAMO,eAAeP,QAAQ,SAAS,CAAC,OAAO,CAACQ;wBAC/C,MAAML,SAAS,MAAMI,aAAa,OAAO,CAACD,KAAK,IAAI;wBAEnD,IAAIH,OAAO,MAAM,IACb,OAAO,IAAIE,cAAcF,OAAO,KAAK;wBAGzC,OAAO;4BACH,MAAMZ,iBAAiBY,OAAO,KAAK,EAAE;4BACrC,OAAO;wBACX;oBACJ,EAAE,OAAOC,IAAI;wBACT,OAAO,IAAIC,cAAcD;oBAC7B;gBACJ;YACJ;QACJ;IACJ"}
|
package/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { CodeMailerSettingsFeature } from \"~/features/CodeMailerSettings/feature.js\";\nimport { GetSettingsFeature } from \"~/features/GetSettings/feature.js\";\nimport { SaveSettingsFeature } from \"~/features/SaveSettings/feature.js\";\nimport { DummyTransportFeature } from \"~/features/DummyTransport/feature.js\";\nimport { SmtpTransportFeature } from \"~/features/SmtpTransport/feature.js\";\nimport { MailerServiceFeature } from \"~/features/MailerService/feature.js\";\nimport { SendMailFeature } from \"~/features/SendMail/feature.js\";\nimport { createSettingsGraphQL } from \"~/graphql/settings.js\";\nimport { createRegisterExtensionPlugin } from \"@webiny/handler\";\n\nexport { MailerService } from \"./domain/MailerService/abstractions.js\";\nexport type { IMailerService, IMailerServiceErrors } from \"./domain/MailerService/abstractions.js\";\n\nexport const createMailerContext = () => {\n return createRegisterExtensionPlugin(context => {\n // Register all features.\n CodeMailerSettingsFeature.register(context.container);\n DummyTransportFeature.register(context.container);\n SmtpTransportFeature.register(context.container);\n GetSettingsFeature.register(context.container);\n SaveSettingsFeature.register(context.container);\n MailerServiceFeature.register(context.container);\n SendMailFeature.register(context.container);\n });\n};\n\nexport const createMailerGraphQL = () => {\n return createSettingsGraphQL();\n};\n"],"names":["createMailerContext","createRegisterExtensionPlugin","context","CodeMailerSettingsFeature","DummyTransportFeature","SmtpTransportFeature","GetSettingsFeature","SaveSettingsFeature","MailerServiceFeature","SendMailFeature","createMailerGraphQL","createSettingsGraphQL"],"mappings":";;;;;;;;;AAaO,MAAMA,sBAAsB,IACxBC,8BAA8BC,CAAAA;QAEjCC,0BAA0B,QAAQ,CAACD,QAAQ,SAAS;QACpDE,sBAAsB,QAAQ,CAACF,QAAQ,SAAS;QAChDG,qBAAqB,QAAQ,CAACH,QAAQ,SAAS;QAC/CI,mBAAmB,QAAQ,CAACJ,QAAQ,SAAS;QAC7CK,oBAAoB,QAAQ,CAACL,QAAQ,SAAS;QAC9CM,qBAAqB,QAAQ,CAACN,QAAQ,SAAS;QAC/CO,gBAAgB,QAAQ,CAACP,QAAQ,SAAS;IAC9C;AAGG,MAAMQ,sBAAsB,IACxBC"}
|
/package/features/CodeMailerSettings/{CodeMailerSettingsImpl.d.ts → CodeMailerSettings.d.ts}
RENAMED
|
File without changes
|