@webiny/api-mailer 0.0.0-unstable.3bc8100a7f → 0.0.0-unstable.3fddf667ea
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 +27 -0
- package/MailerFeature.js.map +1 -0
- package/README.md +10 -13
- package/constants.d.ts +4 -0
- package/constants.js +7 -0
- package/constants.js.map +1 -0
- package/domain/CodeMailerSettings/abstractions.d.ts +8 -0
- package/domain/CodeMailerSettings/abstractions.js +5 -0
- package/domain/CodeMailerSettings/abstractions.js.map +1 -0
- package/domain/MailTransport/abstractions.d.ts +36 -0
- package/domain/MailTransport/abstractions.js +7 -0
- package/domain/MailTransport/abstractions.js.map +1 -0
- package/domain/MailerService/abstractions.d.ts +19 -0
- package/domain/MailerService/abstractions.js +5 -0
- package/domain/MailerService/abstractions.js.map +1 -0
- package/domain/MailerService/errors.d.ts +20 -0
- package/domain/MailerService/errors.js +35 -0
- package/domain/MailerService/errors.js.map +1 -0
- package/domain/errors.d.ts +36 -0
- package/domain/errors.js +62 -0
- package/domain/errors.js.map +1 -0
- package/exports/api/mailer.d.ts +4 -0
- package/exports/api/mailer.js +4 -0
- package/features/CodeMailerSettings/CodeMailerSettings.d.ts +12 -0
- package/features/CodeMailerSettings/CodeMailerSettings.js +23 -0
- package/features/CodeMailerSettings/CodeMailerSettings.js.map +1 -0
- package/features/CodeMailerSettings/feature.d.ts +4 -0
- package/features/CodeMailerSettings/feature.js +11 -0
- package/features/CodeMailerSettings/feature.js.map +1 -0
- package/features/DummyTransport/DummyMailTransport.d.ts +9 -0
- package/features/DummyTransport/DummyMailTransport.js +15 -0
- package/features/DummyTransport/DummyMailTransport.js.map +1 -0
- package/features/DummyTransport/DummyMailTransportFactory.d.ts +10 -0
- package/features/DummyTransport/DummyMailTransportFactory.js +21 -0
- package/features/DummyTransport/DummyMailTransportFactory.js.map +1 -0
- package/features/DummyTransport/feature.d.ts +4 -0
- package/features/DummyTransport/feature.js +11 -0
- package/features/DummyTransport/feature.js.map +1 -0
- package/features/GetSettings/GetSettingsRepository.d.ts +16 -0
- package/features/GetSettings/GetSettingsRepository.js +56 -0
- package/features/GetSettings/GetSettingsRepository.js.map +1 -0
- package/features/GetSettings/GetSettingsUseCase.d.ts +11 -0
- package/features/GetSettings/GetSettingsUseCase.js +18 -0
- package/features/GetSettings/GetSettingsUseCase.js.map +1 -0
- package/features/GetSettings/abstractions.d.ts +22 -0
- package/features/GetSettings/abstractions.js +6 -0
- package/features/GetSettings/abstractions.js.map +1 -0
- package/features/GetSettings/feature.d.ts +4 -0
- package/features/GetSettings/feature.js +13 -0
- package/features/GetSettings/feature.js.map +1 -0
- package/features/GetSettings/index.d.ts +1 -0
- package/features/GetSettings/index.js +1 -0
- package/features/MailerService/MailTransportResolver.d.ts +13 -0
- package/features/MailerService/MailTransportResolver.js +37 -0
- package/features/MailerService/MailTransportResolver.js.map +1 -0
- package/features/MailerService/MailerService.d.ts +13 -0
- package/features/MailerService/MailerService.js +38 -0
- package/features/MailerService/MailerService.js.map +1 -0
- package/features/MailerService/feature.d.ts +4 -0
- package/features/MailerService/feature.js +13 -0
- package/features/MailerService/feature.js.map +1 -0
- package/features/SaveSettings/SaveSettingsRepository.d.ts +13 -0
- package/features/SaveSettings/SaveSettingsRepository.js +45 -0
- package/features/SaveSettings/SaveSettingsRepository.js.map +1 -0
- package/features/SaveSettings/SaveSettingsUseCase.d.ts +18 -0
- package/features/SaveSettings/SaveSettingsUseCase.js +57 -0
- package/features/SaveSettings/SaveSettingsUseCase.js.map +1 -0
- package/features/SaveSettings/abstractions.d.ts +62 -0
- package/features/SaveSettings/abstractions.js +8 -0
- package/features/SaveSettings/abstractions.js.map +1 -0
- package/features/SaveSettings/events.d.ts +10 -0
- package/features/SaveSettings/events.js +21 -0
- package/features/SaveSettings/events.js.map +1 -0
- package/features/SaveSettings/feature.d.ts +4 -0
- package/features/SaveSettings/feature.js +13 -0
- package/features/SaveSettings/feature.js.map +1 -0
- package/features/SaveSettings/index.d.ts +1 -0
- package/features/SaveSettings/index.js +1 -0
- package/features/SaveSettings/validation.d.ts +10 -0
- package/features/SaveSettings/validation.js +21 -0
- package/features/SaveSettings/validation.js.map +1 -0
- package/features/SendMail/SendMailUseCase.d.ts +16 -0
- package/features/SendMail/SendMailUseCase.js +58 -0
- package/features/SendMail/SendMailUseCase.js.map +1 -0
- package/features/SendMail/abstractions.d.ts +45 -0
- package/features/SendMail/abstractions.js +8 -0
- package/features/SendMail/abstractions.js.map +1 -0
- package/features/SendMail/events.d.ts +14 -0
- package/features/SendMail/events.js +29 -0
- package/features/SendMail/events.js.map +1 -0
- package/features/SendMail/feature.d.ts +4 -0
- package/features/SendMail/feature.js +11 -0
- package/features/SendMail/feature.js.map +1 -0
- package/features/SendMail/index.d.ts +1 -0
- package/features/SendMail/index.js +1 -0
- package/features/SendTestMail/SendTestMailUseCase.d.ts +15 -0
- package/features/SendTestMail/SendTestMailUseCase.js +43 -0
- package/features/SendTestMail/SendTestMailUseCase.js.map +1 -0
- package/features/SendTestMail/abstractions.d.ts +32 -0
- package/features/SendTestMail/abstractions.js +5 -0
- package/features/SendTestMail/abstractions.js.map +1 -0
- package/features/SendTestMail/feature.d.ts +4 -0
- package/features/SendTestMail/feature.js +11 -0
- package/features/SendTestMail/feature.js.map +1 -0
- package/features/SmtpTransport/SmtpConfig.d.ts +6 -0
- package/features/SmtpTransport/SmtpConfig.js +26 -0
- package/features/SmtpTransport/SmtpConfig.js.map +1 -0
- package/features/SmtpTransport/SmtpMailTransport.d.ts +77 -0
- package/features/SmtpTransport/SmtpMailTransport.js +60 -0
- package/features/SmtpTransport/SmtpMailTransport.js.map +1 -0
- package/features/SmtpTransport/SmtpMailTransportFactory.d.ts +11 -0
- package/features/SmtpTransport/SmtpMailTransportFactory.js +22 -0
- package/features/SmtpTransport/SmtpMailTransportFactory.js.map +1 -0
- package/features/SmtpTransport/feature.d.ts +4 -0
- package/features/SmtpTransport/feature.js +11 -0
- package/features/SmtpTransport/feature.js.map +1 -0
- package/graphql/MailerSchemaFactory.d.ts +10 -0
- package/graphql/MailerSchemaFactory.js +148 -0
- package/graphql/MailerSchemaFactory.js.map +1 -0
- package/index.d.ts +3 -5
- package/index.js +2 -83
- package/package.json +29 -34
- package/types.d.ts +1 -107
- package/types.js +0 -7
- package/utils/isMailboxAddress.d.ts +6 -0
- package/utils/isMailboxAddress.js +5 -0
- package/utils/isMailboxAddress.js.map +1 -0
- package/context.d.ts +0 -3
- package/context.js +0 -20
- package/context.js.map +0 -1
- package/crud/settings/hooks.d.ts +0 -5
- package/crud/settings/hooks.js +0 -42
- package/crud/settings/hooks.js.map +0 -1
- package/crud/settings/model.d.ts +0 -2
- package/crud/settings/model.js +0 -72
- package/crud/settings/model.js.map +0 -1
- package/crud/settings/password.d.ts +0 -7
- package/crud/settings/password.js +0 -55
- package/crud/settings/password.js.map +0 -1
- package/crud/settings/secret.d.ts +0 -1
- package/crud/settings/secret.js +0 -19
- package/crud/settings/secret.js.map +0 -1
- package/crud/settings/transform.d.ts +0 -13
- package/crud/settings/transform.js +0 -46
- package/crud/settings/transform.js.map +0 -1
- package/crud/settings/validation.d.ts +0 -45
- package/crud/settings/validation.js +0 -28
- package/crud/settings/validation.js.map +0 -1
- package/crud/settings.crud.d.ts +0 -5
- package/crud/settings.crud.js +0 -269
- package/crud/settings.crud.js.map +0 -1
- package/crud/transport/onTransportBeforeSend.d.ts +0 -7
- package/crud/transport/onTransportBeforeSend.js +0 -62
- package/crud/transport/onTransportBeforeSend.js.map +0 -1
- package/crud/transporter.crud.d.ts +0 -2
- package/crud/transporter.crud.js +0 -158
- package/crud/transporter.crud.js.map +0 -1
- package/graphql/index.d.ts +0 -1
- package/graphql/index.js +0 -13
- package/graphql/index.js.map +0 -1
- package/graphql/settings.d.ts +0 -3
- package/graphql/settings.js +0 -103
- package/graphql/settings.js.map +0 -1
- package/index.js.map +0 -1
- package/plugins/CreateTransportPlugin.d.ts +0 -17
- package/plugins/CreateTransportPlugin.js +0 -24
- package/plugins/CreateTransportPlugin.js.map +0 -1
- package/plugins/index.d.ts +0 -1
- package/plugins/index.js +0 -18
- package/plugins/index.js.map +0 -1
- package/transports/createDummyTransport.d.ts +0 -5
- package/transports/createDummyTransport.js +0 -25
- package/transports/createDummyTransport.js.map +0 -1
- package/transports/createSmtpTransport.d.ts +0 -13
- package/transports/createSmtpTransport.js +0 -94
- package/transports/createSmtpTransport.js.map +0 -1
- package/transports/index.d.ts +0 -2
- package/transports/index.js +0 -29
- package/transports/index.js.map +0 -1
- package/types.js.map +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
|
|
2
|
+
import { SmtpMailTransport } from "./SmtpMailTransport.js";
|
|
3
|
+
import { SmtpConfig } from "./SmtpConfig.js";
|
|
4
|
+
import { SMTP_TRANSPORT_NAME } from "../../constants.js";
|
|
5
|
+
class SmtpMailTransportFactoryImpl {
|
|
6
|
+
canUse(settings) {
|
|
7
|
+
return null !== settings;
|
|
8
|
+
}
|
|
9
|
+
async createTransport(settings) {
|
|
10
|
+
return new SmtpMailTransport(SmtpConfig.fromTransportSettings(settings), settings.from);
|
|
11
|
+
}
|
|
12
|
+
constructor(){
|
|
13
|
+
this.name = SMTP_TRANSPORT_NAME;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const SmtpMailTransportFactory = MailTransportFactory.createImplementation({
|
|
17
|
+
implementation: SmtpMailTransportFactoryImpl,
|
|
18
|
+
dependencies: []
|
|
19
|
+
});
|
|
20
|
+
export { SmtpMailTransportFactory };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=SmtpMailTransportFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/SmtpTransport/SmtpMailTransportFactory.js","sources":["../../../src/features/SmtpTransport/SmtpMailTransportFactory.ts"],"sourcesContent":["import { MailTransportFactory } from \"~/domain/MailTransport/abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\nimport { SmtpMailTransport } from \"~/features/SmtpTransport/SmtpMailTransport.js\";\nimport { SmtpConfig } from \"~/features/SmtpTransport/SmtpConfig.js\";\nimport { SMTP_TRANSPORT_NAME } from \"~/constants.js\";\n\nclass SmtpMailTransportFactoryImpl implements MailTransportFactory.Interface {\n public readonly name = SMTP_TRANSPORT_NAME;\n\n canUse(settings: TransportSettings | null): boolean {\n return settings !== null;\n }\n\n async createTransport(settings: TransportSettings): MailTransportFactory.Return {\n return new SmtpMailTransport(SmtpConfig.fromTransportSettings(settings), settings.from);\n }\n}\n\nexport const SmtpMailTransportFactory = MailTransportFactory.createImplementation({\n implementation: SmtpMailTransportFactoryImpl,\n dependencies: []\n});\n"],"names":["SmtpMailTransportFactoryImpl","settings","SmtpMailTransport","SmtpConfig","SMTP_TRANSPORT_NAME","SmtpMailTransportFactory","MailTransportFactory"],"mappings":";;;;AAMA,MAAMA;IAGF,OAAOC,QAAkC,EAAW;QAChD,OAAOA,AAAa,SAAbA;IACX;IAEA,MAAM,gBAAgBA,QAA2B,EAA+B;QAC5E,OAAO,IAAIC,kBAAkBC,WAAW,qBAAqB,CAACF,WAAWA,SAAS,IAAI;IAC1F;;aARgB,IAAI,GAAGG;;AAS3B;AAEO,MAAMC,2BAA2BC,qBAAqB,oBAAoB,CAAC;IAC9E,gBAAgBN;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { SmtpMailTransportFactory } from "./SmtpMailTransportFactory.js";
|
|
3
|
+
const SmtpTransportFeature = createFeature({
|
|
4
|
+
name: "SmtpTransport",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(SmtpMailTransportFactory).inSingletonScope();
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { SmtpTransportFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/SmtpTransport/feature.js","sources":["../../../src/features/SmtpTransport/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { SmtpMailTransportFactory } from \"./SmtpMailTransportFactory.js\";\n\nexport const SmtpTransportFeature = createFeature({\n name: \"SmtpTransport\",\n register(container) {\n container.register(SmtpMailTransportFactory).inSingletonScope();\n }\n});\n"],"names":["SmtpTransportFeature","createFeature","container","SmtpMailTransportFactory"],"mappings":";;AAGO,MAAMA,uBAAuBC,cAAc;IAC9C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,0BAA0B,gBAAgB;IACjE;AACJ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
getSchemaKey: () => string;
|
|
5
|
+
execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder>;
|
|
6
|
+
}
|
|
7
|
+
export declare const MailerSchemaFactory: typeof MailerSchemaFactoryImpl & {
|
|
8
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-graphql/graphql/abstractions.public").IGraphQLSchemaFactory>;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { GraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import { staticSchemaKey } from "@webiny/api-graphql/graphql/staticSchemaKey.js";
|
|
3
|
+
import { ErrorResponse } from "@webiny/api-graphql/responses.js";
|
|
4
|
+
import { GetSettingsUseCase } from "../features/GetSettings/abstractions.js";
|
|
5
|
+
import { SaveSettingsUseCase } from "../features/SaveSettings/abstractions.js";
|
|
6
|
+
import { SendTestMailUseCase } from "../features/SendTestMail/abstractions.js";
|
|
7
|
+
import { SMTP_TRANSPORT_NAME } from "../constants.js";
|
|
8
|
+
const toPublicSettings = (settings, source)=>{
|
|
9
|
+
if (!settings) return null;
|
|
10
|
+
const { password: _password, ...publicSettings } = settings;
|
|
11
|
+
return {
|
|
12
|
+
...publicSettings,
|
|
13
|
+
source
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
class MailerSchemaFactoryImpl {
|
|
17
|
+
async execute(builder) {
|
|
18
|
+
builder.addTypeDefs(`
|
|
19
|
+
type MailerTransportSettingsError {
|
|
20
|
+
message: String!
|
|
21
|
+
code: String
|
|
22
|
+
data: JSON
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type MailerTransportSettings {
|
|
26
|
+
host: String
|
|
27
|
+
port: Number
|
|
28
|
+
secure: Boolean
|
|
29
|
+
user: String
|
|
30
|
+
from: String
|
|
31
|
+
replyTo: String
|
|
32
|
+
source: String
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type MailerTransportSettingsResponse {
|
|
36
|
+
data: MailerTransportSettings
|
|
37
|
+
error: MailerTransportSettingsError
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type MailerQuery {
|
|
41
|
+
getSettings: MailerTransportSettingsResponse!
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
input MailerTransportSettingsInput {
|
|
45
|
+
host: String!
|
|
46
|
+
port: Number
|
|
47
|
+
secure: Boolean
|
|
48
|
+
user: String!
|
|
49
|
+
password: String
|
|
50
|
+
from: String!
|
|
51
|
+
replyTo: String
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
type MailerSendTestMailResponse {
|
|
55
|
+
data: Boolean
|
|
56
|
+
error: MailerTransportSettingsError
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
type MailerMutation {
|
|
60
|
+
saveSettings(data: MailerTransportSettingsInput!): MailerTransportSettingsResponse!
|
|
61
|
+
sendTestMail(to: String!): MailerSendTestMailResponse!
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
extend type Query {
|
|
65
|
+
mailer: MailerQuery
|
|
66
|
+
}
|
|
67
|
+
extend type Mutation {
|
|
68
|
+
mailer: MailerMutation
|
|
69
|
+
}
|
|
70
|
+
`);
|
|
71
|
+
builder.addResolver({
|
|
72
|
+
path: "Query.mailer",
|
|
73
|
+
resolver: ()=>async ()=>({})
|
|
74
|
+
});
|
|
75
|
+
builder.addResolver({
|
|
76
|
+
path: "Mutation.mailer",
|
|
77
|
+
resolver: ()=>async ()=>({})
|
|
78
|
+
});
|
|
79
|
+
builder.addResolver({
|
|
80
|
+
path: "MailerQuery.getSettings",
|
|
81
|
+
dependencies: [
|
|
82
|
+
GetSettingsUseCase
|
|
83
|
+
],
|
|
84
|
+
resolver: (getSettings)=>async ()=>{
|
|
85
|
+
try {
|
|
86
|
+
const result = await getSettings.execute(SMTP_TRANSPORT_NAME);
|
|
87
|
+
if (result.isFail()) return new ErrorResponse(result.error);
|
|
88
|
+
const { settings, source } = result.value;
|
|
89
|
+
return {
|
|
90
|
+
data: toPublicSettings(settings, source),
|
|
91
|
+
error: null
|
|
92
|
+
};
|
|
93
|
+
} catch (ex) {
|
|
94
|
+
return new ErrorResponse(ex);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
builder.addResolver({
|
|
99
|
+
path: "MailerMutation.saveSettings",
|
|
100
|
+
dependencies: [
|
|
101
|
+
SaveSettingsUseCase
|
|
102
|
+
],
|
|
103
|
+
resolver: (saveSettings)=>async ({ args })=>{
|
|
104
|
+
try {
|
|
105
|
+
const result = await saveSettings.execute(args.data);
|
|
106
|
+
if (result.isFail()) return new ErrorResponse(result.error);
|
|
107
|
+
return {
|
|
108
|
+
data: toPublicSettings(result.value, "storage"),
|
|
109
|
+
error: null
|
|
110
|
+
};
|
|
111
|
+
} catch (ex) {
|
|
112
|
+
return new ErrorResponse(ex);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
builder.addResolver({
|
|
117
|
+
path: "MailerMutation.sendTestMail",
|
|
118
|
+
dependencies: [
|
|
119
|
+
SendTestMailUseCase
|
|
120
|
+
],
|
|
121
|
+
resolver: (sendTestMail)=>async ({ args })=>{
|
|
122
|
+
try {
|
|
123
|
+
const result = await sendTestMail.execute({
|
|
124
|
+
to: args.to
|
|
125
|
+
});
|
|
126
|
+
if (result.isFail()) return new ErrorResponse(result.error);
|
|
127
|
+
return {
|
|
128
|
+
data: true,
|
|
129
|
+
error: null
|
|
130
|
+
};
|
|
131
|
+
} catch (ex) {
|
|
132
|
+
return new ErrorResponse(ex);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
return builder;
|
|
137
|
+
}
|
|
138
|
+
constructor(){
|
|
139
|
+
this.getSchemaKey = staticSchemaKey("api-mailer/MailerSchemaFactoryImpl");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const MailerSchemaFactory = GraphQLSchemaFactory.createImplementation({
|
|
143
|
+
implementation: MailerSchemaFactoryImpl,
|
|
144
|
+
dependencies: []
|
|
145
|
+
});
|
|
146
|
+
export { MailerSchemaFactory };
|
|
147
|
+
|
|
148
|
+
//# 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 { staticSchemaKey } from \"@webiny/api-graphql/graphql/staticSchemaKey.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 { SendTestMailUseCase } from \"~/features/SendTestMail/abstractions.js\";\nimport type { MailerSettingsSource } from \"~/features/GetSettings/abstractions.js\";\nimport type { SaveSettingsInput } from \"~/features/SaveSettings/abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\nimport { SMTP_TRANSPORT_NAME } from \"~/constants.js\";\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 public getSchemaKey = staticSchemaKey(\"api-mailer/MailerSchemaFactoryImpl\");\n\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 MailerSendTestMailResponse {\n data: Boolean\n error: MailerTransportSettingsError\n }\n\n type MailerMutation {\n saveSettings(data: MailerTransportSettingsInput!): MailerTransportSettingsResponse!\n sendTestMail(to: String!): MailerSendTestMailResponse!\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 if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\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 builder.addResolver<{ to: string }>({\n path: \"MailerMutation.sendTestMail\",\n dependencies: [SendTestMailUseCase],\n resolver:\n (sendTestMail: SendTestMailUseCase.Interface) =>\n async ({ args }) => {\n try {\n const result = await sendTestMail.execute({ to: args.to });\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return { data: true, error: null };\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":["toPublicSettings","settings","source","_password","publicSettings","MailerSchemaFactoryImpl","builder","GetSettingsUseCase","getSettings","result","SMTP_TRANSPORT_NAME","ErrorResponse","ex","SaveSettingsUseCase","saveSettings","args","SendTestMailUseCase","sendTestMail","staticSchemaKey","MailerSchemaFactory","GraphQLSchemaFactory"],"mappings":";;;;;;;AAiBA,MAAMA,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;IAGF,MAAM,QAAQC,OAA8B,EAAkC;QAC1EA,QAAQ,WAAW,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAoDrB,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,CAACE;wBAEzC,IAAID,OAAO,MAAM,IACb,OAAO,IAAIE,cAAcF,OAAO,KAAK;wBAGzC,MAAM,EAAER,QAAQ,EAAEC,MAAM,EAAE,GAAGO,OAAO,KAAK;wBAEzC,OAAO;4BACH,MAAMT,iBAAiBC,UAAUC;4BACjC,OAAO;wBACX;oBACJ,EAAE,OAAOU,IAAI;wBACT,OAAO,IAAID,cAAcC;oBAC7B;gBACJ;QACJ;QAEAN,QAAQ,WAAW,CAA8B;YAC7C,MAAM;YACN,cAAc;gBAACO;aAAoB;YACnC,UACI,CAACC,eACD,OAAO,EAAEC,IAAI,EAAE;oBACX,IAAI;wBACA,MAAMN,SAAS,MAAMK,aAAa,OAAO,CAACC,KAAK,IAAI;wBAEnD,IAAIN,OAAO,MAAM,IACb,OAAO,IAAIE,cAAcF,OAAO,KAAK;wBAGzC,OAAO;4BACH,MAAMT,iBAAiBS,OAAO,KAAK,EAAE;4BACrC,OAAO;wBACX;oBACJ,EAAE,OAAOG,IAAI;wBACT,OAAO,IAAID,cAAcC;oBAC7B;gBACJ;QACR;QAEAN,QAAQ,WAAW,CAAiB;YAChC,MAAM;YACN,cAAc;gBAACU;aAAoB;YACnC,UACI,CAACC,eACD,OAAO,EAAEF,IAAI,EAAE;oBACX,IAAI;wBACA,MAAMN,SAAS,MAAMQ,aAAa,OAAO,CAAC;4BAAE,IAAIF,KAAK,EAAE;wBAAC;wBAExD,IAAIN,OAAO,MAAM,IACb,OAAO,IAAIE,cAAcF,OAAO,KAAK;wBAGzC,OAAO;4BAAE,MAAM;4BAAM,OAAO;wBAAK;oBACrC,EAAE,OAAOG,IAAI;wBACT,OAAO,IAAID,cAAcC;oBAC7B;gBACJ;QACR;QAEA,OAAON;IACX;;aAtIO,YAAY,GAAGY,gBAAgB;;AAuI1C;AAEO,MAAMC,sBAAsBC,qBAAqB,oBAAoB,CAAC;IACzE,gBAAgBf;IAChB,cAAc,EAAE;AACpB"}
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export declare const createMailerContext: () => PluginCollection;
|
|
5
|
-
export declare const createMailerGraphQL: () => import("@webiny/handler-graphql").GraphQLSchemaPlugin<import("./types").MailerContext>[];
|
|
1
|
+
export { MailerFeature } from "./MailerFeature.js";
|
|
2
|
+
export { MailerService } from "./domain/MailerService/abstractions.js";
|
|
3
|
+
export type { IMailerService, IMailerServiceErrors } from "./domain/MailerService/abstractions.js";
|
package/index.js
CHANGED
|
@@ -1,83 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
createMailerContext: true,
|
|
8
|
-
createMailerGraphQL: true
|
|
9
|
-
};
|
|
10
|
-
exports.createMailerGraphQL = exports.createMailerContext = void 0;
|
|
11
|
-
var _context = require("./context");
|
|
12
|
-
var _createDummyTransport = require("./transports/createDummyTransport");
|
|
13
|
-
var _createSmtpTransport = require("./transports/createSmtpTransport");
|
|
14
|
-
var _plugins = require("./plugins");
|
|
15
|
-
Object.keys(_plugins).forEach(function (key) {
|
|
16
|
-
if (key === "default" || key === "__esModule") return;
|
|
17
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
18
|
-
if (key in exports && exports[key] === _plugins[key]) return;
|
|
19
|
-
Object.defineProperty(exports, key, {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () {
|
|
22
|
-
return _plugins[key];
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
var _model = require("./crud/settings/model");
|
|
27
|
-
var _graphql = require("./graphql");
|
|
28
|
-
var _transports = require("./transports");
|
|
29
|
-
Object.keys(_transports).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
32
|
-
if (key in exports && exports[key] === _transports[key]) return;
|
|
33
|
-
Object.defineProperty(exports, key, {
|
|
34
|
-
enumerable: true,
|
|
35
|
-
get: function () {
|
|
36
|
-
return _transports[key];
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
const createMailerContext = () => {
|
|
41
|
-
return [
|
|
42
|
-
/**
|
|
43
|
-
* Models to use via the CMS
|
|
44
|
-
*/
|
|
45
|
-
(0, _model.createSettingsModel)(),
|
|
46
|
-
/**
|
|
47
|
-
* If something is wrong with the smtp mailer, we will initialize the dummy one.
|
|
48
|
-
*/
|
|
49
|
-
(0, _plugins.createTransport)(async () => {
|
|
50
|
-
const plugin = await (0, _createDummyTransport.createDummyTransport)();
|
|
51
|
-
plugin.name = "mailer.dummy-default";
|
|
52
|
-
return plugin;
|
|
53
|
-
}),
|
|
54
|
-
/**
|
|
55
|
-
* Smtp mailer goes into the plugins after the dummy one because plugins are loaded in reverse.
|
|
56
|
-
*/
|
|
57
|
-
(0, _plugins.createTransport)(async ({
|
|
58
|
-
settings
|
|
59
|
-
}) => {
|
|
60
|
-
/**
|
|
61
|
-
* We need to map our settings to the required settings for the SMTP NodeMailer transport.
|
|
62
|
-
*/
|
|
63
|
-
const config = {
|
|
64
|
-
...(settings || {})
|
|
65
|
-
};
|
|
66
|
-
if (settings) {
|
|
67
|
-
config.auth = {
|
|
68
|
-
user: settings.user,
|
|
69
|
-
pass: settings.password
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
const plugin = await (0, _createSmtpTransport.createSmtpTransport)(config);
|
|
73
|
-
plugin.name = "mailer.smtp-default";
|
|
74
|
-
return plugin;
|
|
75
|
-
}), (0, _context.createMailerContext)()];
|
|
76
|
-
};
|
|
77
|
-
exports.createMailerContext = createMailerContext;
|
|
78
|
-
const createMailerGraphQL = () => {
|
|
79
|
-
return [...(0, _graphql.createGraphQL)()];
|
|
80
|
-
};
|
|
81
|
-
exports.createMailerGraphQL = createMailerGraphQL;
|
|
82
|
-
|
|
83
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { MailerFeature } from "./MailerFeature.js";
|
|
2
|
+
export { MailerService } from "./domain/MailerService/abstractions.js";
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-mailer",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.0.0-unstable.3fddf667ea",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
5
9
|
"repository": {
|
|
6
10
|
"type": "git",
|
|
7
11
|
"url": "https://github.com/webiny/webiny-js.git",
|
|
@@ -14,41 +18,32 @@
|
|
|
14
18
|
"description": "The API to send e-mails.",
|
|
15
19
|
"license": "MIT",
|
|
16
20
|
"dependencies": {
|
|
17
|
-
"@webiny/api": "0.0.0-unstable.
|
|
18
|
-
"@webiny/
|
|
19
|
-
"@webiny/
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"crypto-js": "4.2.0",
|
|
24
|
-
"lodash": "4.17.21",
|
|
25
|
-
"nodemailer": "6.9.16",
|
|
26
|
-
"zod": "3.23.8"
|
|
21
|
+
"@webiny/api-graphql": "0.0.0-unstable.3fddf667ea",
|
|
22
|
+
"@webiny/feature": "0.0.0-unstable.3fddf667ea",
|
|
23
|
+
"@webiny/plugins": "0.0.0-unstable.3fddf667ea",
|
|
24
|
+
"email-addresses": "5.0.0",
|
|
25
|
+
"nodemailer": "10.3.1",
|
|
26
|
+
"zod": "4.6.7"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@types/
|
|
30
|
-
"@
|
|
31
|
-
"@webiny/api-
|
|
32
|
-
"@webiny/
|
|
33
|
-
"@webiny/
|
|
34
|
-
"@webiny/
|
|
35
|
-
"@webiny/handler": "0.0.0-unstable.
|
|
36
|
-
"@webiny/handler
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"jest-dynalite": "3.6.1",
|
|
42
|
-
"rimraf": "6.0.1",
|
|
43
|
-
"typescript": "5.3.3"
|
|
29
|
+
"@types/nodemailer": "8.0.2",
|
|
30
|
+
"@webiny/api": "0.0.0-unstable.3fddf667ea",
|
|
31
|
+
"@webiny/api-core": "0.0.0-unstable.3fddf667ea",
|
|
32
|
+
"@webiny/build-tools": "0.0.0-unstable.3fddf667ea",
|
|
33
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.3fddf667ea",
|
|
34
|
+
"@webiny/di": "2.0.0",
|
|
35
|
+
"@webiny/event-handler-core": "0.0.0-unstable.3fddf667ea",
|
|
36
|
+
"@webiny/handler": "0.0.0-unstable.3fddf667ea",
|
|
37
|
+
"graphql": "16.14.2",
|
|
38
|
+
"rimraf": "6.1.3",
|
|
39
|
+
"typescript": "7.0.2",
|
|
40
|
+
"vitest": "5.0.5"
|
|
44
41
|
},
|
|
45
42
|
"publishConfig": {
|
|
46
|
-
"access": "public"
|
|
47
|
-
"directory": "dist"
|
|
48
|
-
},
|
|
49
|
-
"scripts": {
|
|
50
|
-
"build": "node ../cli/bin.js run build",
|
|
51
|
-
"watch": "node ../cli/bin.js run watch"
|
|
43
|
+
"access": "public"
|
|
52
44
|
},
|
|
53
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "8476da73b653c89cc1474d968baf55c1b0ae0e5f",
|
|
46
|
+
"webiny": {
|
|
47
|
+
"publishFrom": "dist"
|
|
48
|
+
}
|
|
54
49
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,106 +1,3 @@
|
|
|
1
|
-
import type { CmsContext } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import type { Topic } from "@webiny/pubsub/types";
|
|
3
|
-
export interface MailerTransporterContext<T extends Transport = Transport> {
|
|
4
|
-
onTransportBeforeSend: Topic<OnTransportBeforeSendParams>;
|
|
5
|
-
onTransportAfterSend: Topic<OnTransportAfterSendParams>;
|
|
6
|
-
onTransportError: Topic<OnTransportErrorParams>;
|
|
7
|
-
getTransport: () => Promise<T | null>;
|
|
8
|
-
sendMail: <D>(data: TransportSendData) => Promise<TransportSendResponse<D>>;
|
|
9
|
-
}
|
|
10
|
-
export interface MailerSettingsCreateParams {
|
|
11
|
-
input: Partial<TransportSettings>;
|
|
12
|
-
}
|
|
13
|
-
export interface MailerSettingsUpdateParams {
|
|
14
|
-
input: Partial<TransportSettings>;
|
|
15
|
-
original?: ExtendedTransportSettings | null;
|
|
16
|
-
}
|
|
17
|
-
export interface MailerSettingsSaveParams {
|
|
18
|
-
input: Partial<TransportSettings>;
|
|
19
|
-
}
|
|
20
|
-
export interface OnSettingsBeforeGetTopicParams {
|
|
21
|
-
tenant: string;
|
|
22
|
-
}
|
|
23
|
-
export interface OnSettingsAfterGetTopicParams {
|
|
24
|
-
tenant: string;
|
|
25
|
-
settings: TransportSettings | null;
|
|
26
|
-
}
|
|
27
|
-
export interface OnSettingsGetErrorTopicParams {
|
|
28
|
-
tenant: string;
|
|
29
|
-
error: Error;
|
|
30
|
-
}
|
|
31
|
-
export interface OnSettingsBeforeCreateTopicParams {
|
|
32
|
-
settings: TransportSettings;
|
|
33
|
-
}
|
|
34
|
-
export interface OnSettingsAfterCreateTopicParams {
|
|
35
|
-
settings: TransportSettings;
|
|
36
|
-
}
|
|
37
|
-
export interface OnSettingsCreateErrorTopicParams {
|
|
38
|
-
settings: TransportSettings;
|
|
39
|
-
error: Error;
|
|
40
|
-
}
|
|
41
|
-
export interface OnSettingsBeforeUpdateTopicParams {
|
|
42
|
-
settings: TransportSettings;
|
|
43
|
-
original: TransportSettings;
|
|
44
|
-
}
|
|
45
|
-
export interface OnSettingsAfterUpdateTopicParams {
|
|
46
|
-
original: TransportSettings;
|
|
47
|
-
settings: TransportSettings;
|
|
48
|
-
}
|
|
49
|
-
export interface OnSettingsUpdateErrorTopicParams {
|
|
50
|
-
original: TransportSettings;
|
|
51
|
-
settings: TransportSettings;
|
|
52
|
-
error: Error;
|
|
53
|
-
}
|
|
54
|
-
export interface ExtendedTransportSettings extends TransportSettings {
|
|
55
|
-
id: string;
|
|
56
|
-
}
|
|
57
|
-
export interface MailerSettingsContext {
|
|
58
|
-
getSettings: () => Promise<ExtendedTransportSettings | null>;
|
|
59
|
-
/**
|
|
60
|
-
* Method should not be used outside of mailer
|
|
61
|
-
* @internal
|
|
62
|
-
*/
|
|
63
|
-
createSettings: (params: MailerSettingsCreateParams) => Promise<TransportSettings>;
|
|
64
|
-
/**
|
|
65
|
-
* Method should not be used outside of mailer
|
|
66
|
-
* @internal
|
|
67
|
-
*/
|
|
68
|
-
updateSettings: (params: MailerSettingsUpdateParams) => Promise<TransportSettings>;
|
|
69
|
-
/**
|
|
70
|
-
* Use to store the settings data.
|
|
71
|
-
*/
|
|
72
|
-
saveSettings: (params: MailerSettingsSaveParams) => Promise<TransportSettings>;
|
|
73
|
-
/**
|
|
74
|
-
* Lifecycle events
|
|
75
|
-
*/
|
|
76
|
-
onSettingsBeforeGet: Topic<OnSettingsBeforeGetTopicParams>;
|
|
77
|
-
onSettingsAfterGet: Topic<OnSettingsAfterGetTopicParams>;
|
|
78
|
-
onSettingsGetError: Topic<OnSettingsGetErrorTopicParams>;
|
|
79
|
-
onSettingsBeforeCreate: Topic<OnSettingsBeforeCreateTopicParams>;
|
|
80
|
-
onSettingsAfterCreate: Topic<OnSettingsAfterCreateTopicParams>;
|
|
81
|
-
onSettingsCreateError: Topic<OnSettingsCreateErrorTopicParams>;
|
|
82
|
-
onSettingsBeforeUpdate: Topic<OnSettingsBeforeUpdateTopicParams>;
|
|
83
|
-
onSettingsAfterUpdate: Topic<OnSettingsAfterUpdateTopicParams>;
|
|
84
|
-
onSettingsUpdateError: Topic<OnSettingsUpdateErrorTopicParams>;
|
|
85
|
-
}
|
|
86
|
-
export interface MailerContextObject<T extends Transport = Transport> extends MailerTransporterContext<T>, MailerSettingsContext {
|
|
87
|
-
}
|
|
88
|
-
export interface MailerContext extends CmsContext {
|
|
89
|
-
mailer: MailerContextObject;
|
|
90
|
-
}
|
|
91
|
-
export interface OnTransportBeforeSendParams {
|
|
92
|
-
data: TransportSendData;
|
|
93
|
-
transport: Transport;
|
|
94
|
-
}
|
|
95
|
-
export interface OnTransportAfterSendParams {
|
|
96
|
-
data: TransportSendData;
|
|
97
|
-
transport: Transport;
|
|
98
|
-
}
|
|
99
|
-
export interface OnTransportErrorParams {
|
|
100
|
-
error: Error;
|
|
101
|
-
data: TransportSendData;
|
|
102
|
-
transport: Transport;
|
|
103
|
-
}
|
|
104
1
|
/**
|
|
105
2
|
* Interface to implement the actual mailer.
|
|
106
3
|
*/
|
|
@@ -134,13 +31,10 @@ interface BaseTransportSendData {
|
|
|
134
31
|
replyTo?: string;
|
|
135
32
|
}
|
|
136
33
|
export type TransportSendData = BaseTransportSendData & (TransportSendToData | TransportSendBccData | TransportSendCcData);
|
|
137
|
-
export interface Transport<T = any> {
|
|
138
|
-
name: string;
|
|
139
|
-
send: (params: TransportSendData) => Promise<TransportSendResponse<T>>;
|
|
140
|
-
}
|
|
141
34
|
export interface TransportSettings {
|
|
142
35
|
host: string;
|
|
143
36
|
port: number;
|
|
37
|
+
secure: boolean;
|
|
144
38
|
user: string;
|
|
145
39
|
password: string;
|
|
146
40
|
from: string;
|
package/types.js
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC 5322 mailbox validator. Accepts both addr-spec ("addr@domain") and
|
|
3
|
+
* name-addr ("Display Name <addr@domain>") forms — both are valid SMTP
|
|
4
|
+
* From / Reply-To inputs that nodemailer and most providers accept.
|
|
5
|
+
*/
|
|
6
|
+
export declare const isMailboxAddress: (value: string) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils/isMailboxAddress.js","sources":["../../src/utils/isMailboxAddress.ts"],"sourcesContent":["import emailAddresses from \"email-addresses\";\n\n/**\n * RFC 5322 mailbox validator. Accepts both addr-spec (\"addr@domain\") and\n * name-addr (\"Display Name <addr@domain>\") forms — both are valid SMTP\n * From / Reply-To inputs that nodemailer and most providers accept.\n */\nexport const isMailboxAddress = (value: string): boolean => {\n return emailAddresses.parseOneAddress(value) !== null;\n};\n"],"names":["isMailboxAddress","value","emailAddresses"],"mappings":";AAOO,MAAMA,mBAAmB,CAACC,QACtBC,AAA0C,SAA1CA,gBAAAA,eAA8B,CAACD"}
|
package/context.d.ts
DELETED
package/context.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createMailerContext = void 0;
|
|
7
|
-
var _api = require("@webiny/api");
|
|
8
|
-
var _transporter = require("./crud/transporter.crud");
|
|
9
|
-
var _settings = require("./crud/settings.crud");
|
|
10
|
-
const createMailerContext = () => {
|
|
11
|
-
return new _api.ContextPlugin(async context => {
|
|
12
|
-
context.mailer = {
|
|
13
|
-
...(await (0, _transporter.createTransporterCrud)(context)),
|
|
14
|
-
...(await (0, _settings.createSettingsCrud)(context))
|
|
15
|
-
};
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
exports.createMailerContext = createMailerContext;
|
|
19
|
-
|
|
20
|
-
//# sourceMappingURL=context.js.map
|
package/context.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_api","require","_transporter","_settings","createMailerContext","ContextPlugin","context","mailer","createTransporterCrud","createSettingsCrud","exports"],"sources":["context.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport type { MailerContext } from \"./types\";\nimport { createTransporterCrud } from \"~/crud/transporter.crud\";\nimport { createSettingsCrud } from \"~/crud/settings.crud\";\n\nexport const createMailerContext = () => {\n return new ContextPlugin<MailerContext>(async context => {\n context.mailer = {\n ...(await createTransporterCrud(context)),\n ...(await createSettingsCrud(context))\n };\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEO,MAAMG,mBAAmB,GAAGA,CAAA,KAAM;EACrC,OAAO,IAAIC,kBAAa,CAAgB,MAAMC,OAAO,IAAI;IACrDA,OAAO,CAACC,MAAM,GAAG;MACb,IAAI,MAAM,IAAAC,kCAAqB,EAACF,OAAO,CAAC,CAAC;MACzC,IAAI,MAAM,IAAAG,4BAAkB,EAACH,OAAO,CAAC;IACzC,CAAC;EACL,CAAC,CAAC;AACN,CAAC;AAACI,OAAA,CAAAN,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
package/crud/settings/hooks.d.ts
DELETED
package/crud/settings/hooks.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.attachPasswordObfuscatingHooks = void 0;
|
|
7
|
-
var _model = require("./model");
|
|
8
|
-
const obfuscatePassword = values => {
|
|
9
|
-
// eslint-disable-next-line
|
|
10
|
-
const {
|
|
11
|
-
password,
|
|
12
|
-
...rest
|
|
13
|
-
} = values;
|
|
14
|
-
return {
|
|
15
|
-
rest
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
const hook = async params => {
|
|
19
|
-
if (params.model.modelId !== _model.SETTINGS_MODEL_ID) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
delete params.input["password"];
|
|
23
|
-
params.entry.values = obfuscatePassword(params.entry.values);
|
|
24
|
-
if (typeof params.original !== "undefined") {
|
|
25
|
-
params.original.values = obfuscatePassword(params.original.values);
|
|
26
|
-
}
|
|
27
|
-
if (params.storageEntry) {
|
|
28
|
-
params.storageEntry.values = obfuscatePassword(params.storageEntry.values);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* We need to remove password from all error reporting and all returns.
|
|
33
|
-
*/
|
|
34
|
-
const attachPasswordObfuscatingHooks = context => {
|
|
35
|
-
context.cms.onEntryAfterCreate.subscribe(hook);
|
|
36
|
-
context.cms.onEntryCreateError.subscribe(hook);
|
|
37
|
-
context.cms.onEntryAfterUpdate.subscribe(hook);
|
|
38
|
-
context.cms.onEntryUpdateError.subscribe(hook);
|
|
39
|
-
};
|
|
40
|
-
exports.attachPasswordObfuscatingHooks = attachPasswordObfuscatingHooks;
|
|
41
|
-
|
|
42
|
-
//# sourceMappingURL=hooks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_model","require","obfuscatePassword","values","password","rest","hook","params","model","modelId","SETTINGS_MODEL_ID","input","entry","original","storageEntry","attachPasswordObfuscatingHooks","context","cms","onEntryAfterCreate","subscribe","onEntryCreateError","onEntryAfterUpdate","onEntryUpdateError","exports"],"sources":["hooks.ts"],"sourcesContent":["import type { MailerContext } from \"~/types\";\nimport type {\n OnEntryAfterCreateTopicParams,\n OnEntryAfterUpdateTopicParams,\n OnEntryCreateErrorTopicParams,\n OnEntryUpdateErrorTopicParams\n} from \"@webiny/api-headless-cms/types\";\nimport { SETTINGS_MODEL_ID } from \"~/crud/settings/model\";\n\nconst obfuscatePassword = (values: Record<string, any>) => {\n // eslint-disable-next-line\n const { password, ...rest } = values;\n\n return { rest };\n};\n\ntype Params = (\n | OnEntryAfterCreateTopicParams\n | OnEntryCreateErrorTopicParams\n | OnEntryAfterUpdateTopicParams\n | OnEntryUpdateErrorTopicParams\n) & {\n storageEntry?: any;\n original?: any;\n};\n\nconst hook = async (params: Params) => {\n if (params.model.modelId !== SETTINGS_MODEL_ID) {\n return;\n }\n delete params.input[\"password\"];\n params.entry.values = obfuscatePassword(params.entry.values);\n if (typeof params.original !== \"undefined\") {\n params.original.values = obfuscatePassword(params.original.values);\n }\n if (params.storageEntry) {\n params.storageEntry.values = obfuscatePassword(params.storageEntry.values);\n }\n};\n/**\n * We need to remove password from all error reporting and all returns.\n */\nexport const attachPasswordObfuscatingHooks = (context: MailerContext) => {\n context.cms.onEntryAfterCreate.subscribe(hook);\n context.cms.onEntryCreateError.subscribe(hook);\n context.cms.onEntryAfterUpdate.subscribe(hook);\n context.cms.onEntryUpdateError.subscribe(hook);\n};\n"],"mappings":";;;;;;AAOA,IAAAA,MAAA,GAAAC,OAAA;AAEA,MAAMC,iBAAiB,GAAIC,MAA2B,IAAK;EACvD;EACA,MAAM;IAAEC,QAAQ;IAAE,GAAGC;EAAK,CAAC,GAAGF,MAAM;EAEpC,OAAO;IAAEE;EAAK,CAAC;AACnB,CAAC;AAYD,MAAMC,IAAI,GAAG,MAAOC,MAAc,IAAK;EACnC,IAAIA,MAAM,CAACC,KAAK,CAACC,OAAO,KAAKC,wBAAiB,EAAE;IAC5C;EACJ;EACA,OAAOH,MAAM,CAACI,KAAK,CAAC,UAAU,CAAC;EAC/BJ,MAAM,CAACK,KAAK,CAACT,MAAM,GAAGD,iBAAiB,CAACK,MAAM,CAACK,KAAK,CAACT,MAAM,CAAC;EAC5D,IAAI,OAAOI,MAAM,CAACM,QAAQ,KAAK,WAAW,EAAE;IACxCN,MAAM,CAACM,QAAQ,CAACV,MAAM,GAAGD,iBAAiB,CAACK,MAAM,CAACM,QAAQ,CAACV,MAAM,CAAC;EACtE;EACA,IAAII,MAAM,CAACO,YAAY,EAAE;IACrBP,MAAM,CAACO,YAAY,CAACX,MAAM,GAAGD,iBAAiB,CAACK,MAAM,CAACO,YAAY,CAACX,MAAM,CAAC;EAC9E;AACJ,CAAC;AACD;AACA;AACA;AACO,MAAMY,8BAA8B,GAAIC,OAAsB,IAAK;EACtEA,OAAO,CAACC,GAAG,CAACC,kBAAkB,CAACC,SAAS,CAACb,IAAI,CAAC;EAC9CU,OAAO,CAACC,GAAG,CAACG,kBAAkB,CAACD,SAAS,CAACb,IAAI,CAAC;EAC9CU,OAAO,CAACC,GAAG,CAACI,kBAAkB,CAACF,SAAS,CAACb,IAAI,CAAC;EAC9CU,OAAO,CAACC,GAAG,CAACK,kBAAkB,CAACH,SAAS,CAACb,IAAI,CAAC;AAClD,CAAC;AAACiB,OAAA,CAAAR,8BAAA,GAAAA,8BAAA","ignoreList":[]}
|
package/crud/settings/model.d.ts
DELETED