@webiny/api-mailer 0.0.0-unstable.df7a8bb475 → 0.0.0-unstable.e1999482d0
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 +23 -0
- package/MailerFeature.js.map +1 -0
- package/constants.d.ts +1 -1
- package/constants.js +2 -1
- package/constants.js.map +1 -1
- package/domain/MailTransport/abstractions.d.ts +8 -3
- package/domain/MailTransport/abstractions.js +3 -2
- package/domain/MailTransport/abstractions.js.map +1 -1
- package/domain/MailerService/abstractions.d.ts +4 -2
- package/domain/MailerService/abstractions.js +2 -1
- package/domain/MailerService/abstractions.js.map +1 -1
- package/domain/MailerService/errors.d.ts +4 -0
- package/domain/MailerService/errors.js +29 -24
- package/domain/MailerService/errors.js.map +1 -1
- package/domain/TransportSettings/abstractions.d.ts +47 -0
- package/domain/TransportSettings/abstractions.js +5 -0
- package/domain/TransportSettings/abstractions.js.map +1 -0
- package/domain/TransportSettings/findDefinition.d.ts +6 -0
- package/domain/TransportSettings/findDefinition.js +13 -0
- package/domain/TransportSettings/findDefinition.js.map +1 -0
- package/domain/errors.d.ts +23 -5
- package/domain/errors.js +68 -40
- package/domain/errors.js.map +1 -1
- package/exports/api/mailer.d.ts +6 -0
- package/exports/api/mailer.js +6 -0
- package/features/GetSettings/GetSettingsRepository.d.ts +7 -5
- package/features/GetSettings/GetSettingsRepository.js +43 -30
- package/features/GetSettings/GetSettingsRepository.js.map +1 -1
- package/features/GetSettings/GetSettingsUseCase.d.ts +11 -4
- package/features/GetSettings/GetSettingsUseCase.js +38 -10
- package/features/GetSettings/GetSettingsUseCase.js.map +1 -1
- package/features/GetSettings/abstractions.d.ts +20 -6
- package/features/GetSettings/abstractions.js +3 -2
- package/features/GetSettings/abstractions.js.map +1 -1
- package/features/GetSettings/feature.d.ts +4 -1
- package/features/GetSettings/feature.js +7 -6
- package/features/GetSettings/feature.js.map +1 -1
- package/features/GetSettings/index.d.ts +2 -1
- package/features/GetSettings/index.js +1 -3
- package/features/IsMailerConfigured/IsMailerConfiguredUseCase.d.ts +11 -0
- package/features/IsMailerConfigured/IsMailerConfiguredUseCase.js +19 -0
- package/features/IsMailerConfigured/IsMailerConfiguredUseCase.js.map +1 -0
- package/features/IsMailerConfigured/abstractions.d.ts +18 -0
- package/features/IsMailerConfigured/abstractions.js +5 -0
- package/features/IsMailerConfigured/abstractions.js.map +1 -0
- package/features/IsMailerConfigured/feature.d.ts +4 -0
- package/features/IsMailerConfigured/feature.js +11 -0
- package/features/IsMailerConfigured/feature.js.map +1 -0
- package/features/IsMailerConfigured/index.d.ts +1 -0
- package/features/IsMailerConfigured/index.js +1 -0
- package/features/MailerService/MailerService.d.ts +3 -4
- package/features/MailerService/MailerService.js +42 -41
- package/features/MailerService/MailerService.js.map +1 -1
- package/features/MailerService/feature.d.ts +4 -1
- package/features/MailerService/feature.js +6 -5
- package/features/MailerService/feature.js.map +1 -1
- package/features/SaveSettings/SaveSettingsRepository.d.ts +4 -3
- package/features/SaveSettings/SaveSettingsRepository.js +58 -48
- package/features/SaveSettings/SaveSettingsRepository.js.map +1 -1
- package/features/SaveSettings/SaveSettingsUseCase.d.ts +6 -4
- package/features/SaveSettings/SaveSettingsUseCase.js +49 -42
- package/features/SaveSettings/SaveSettingsUseCase.js.map +1 -1
- package/features/SaveSettings/abstractions.d.ts +22 -21
- package/features/SaveSettings/abstractions.js +5 -8
- package/features/SaveSettings/abstractions.js.map +1 -1
- package/features/SaveSettings/events.d.ts +3 -3
- package/features/SaveSettings/events.js +17 -12
- package/features/SaveSettings/events.js.map +1 -1
- package/features/SaveSettings/feature.d.ts +4 -1
- package/features/SaveSettings/feature.js +7 -6
- package/features/SaveSettings/feature.js.map +1 -1
- package/features/SaveSettings/index.d.ts +2 -1
- package/features/SaveSettings/index.js +1 -3
- package/features/SendMail/SendMailUseCase.d.ts +2 -2
- package/features/SendMail/SendMailUseCase.js +44 -48
- package/features/SendMail/SendMailUseCase.js.map +1 -1
- package/features/SendMail/abstractions.d.ts +7 -7
- package/features/SendMail/abstractions.js +5 -8
- package/features/SendMail/abstractions.js.map +1 -1
- package/features/SendMail/events.d.ts +4 -4
- package/features/SendMail/events.js +24 -17
- package/features/SendMail/events.js.map +1 -1
- package/features/SendMail/feature.d.ts +4 -1
- package/features/SendMail/feature.js +6 -5
- package/features/SendMail/feature.js.map +1 -1
- package/features/SendMail/index.d.ts +1 -0
- package/features/SendMail/index.js +1 -0
- package/features/SendTestMail/SendTestMailUseCase.d.ts +13 -0
- package/features/SendTestMail/SendTestMailUseCase.js +40 -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/graphql/MailerSchemaFactory.d.ts +10 -0
- package/graphql/MailerSchemaFactory.js +135 -0
- package/graphql/MailerSchemaFactory.js.map +1 -0
- package/index.d.ts +11 -2
- package/index.js +8 -26
- package/package.json +25 -33
- package/types.d.ts +0 -8
- package/types.js +0 -3
- package/utils/isMailboxAddress.d.ts +6 -0
- package/utils/isMailboxAddress.js +5 -0
- package/utils/isMailboxAddress.js.map +1 -0
- package/domain/Encryption/abstractions.d.ts +0 -8
- package/domain/Encryption/abstractions.js +0 -4
- package/domain/Encryption/abstractions.js.map +0 -1
- package/features/DummyTransport/DummyMailTransport.d.ts +0 -9
- package/features/DummyTransport/DummyMailTransport.js +0 -12
- package/features/DummyTransport/DummyMailTransport.js.map +0 -1
- package/features/DummyTransport/DummyMailTransportFactory.d.ts +0 -8
- package/features/DummyTransport/DummyMailTransportFactory.js +0 -13
- package/features/DummyTransport/DummyMailTransportFactory.js.map +0 -1
- package/features/DummyTransport/feature.d.ts +0 -1
- package/features/DummyTransport/feature.js +0 -10
- package/features/DummyTransport/feature.js.map +0 -1
- package/features/Encryption/PasswordEncryption.d.ts +0 -9
- package/features/Encryption/PasswordEncryption.js +0 -23
- package/features/Encryption/PasswordEncryption.js.map +0 -1
- package/features/Encryption/feature.d.ts +0 -1
- package/features/Encryption/feature.js +0 -10
- package/features/Encryption/feature.js.map +0 -1
- package/features/Encryption/utils/password.d.ts +0 -7
- package/features/Encryption/utils/password.js +0 -56
- package/features/Encryption/utils/password.js.map +0 -1
- package/features/Encryption/utils/secret.d.ts +0 -1
- package/features/Encryption/utils/secret.js +0 -11
- package/features/Encryption/utils/secret.js.map +0 -1
- package/features/GetSettings/index.js.map +0 -1
- package/features/MailerService/TransportFactory.d.ts +0 -2
- package/features/MailerService/TransportFactory.js +0 -31
- package/features/MailerService/TransportFactory.js.map +0 -1
- package/features/SaveSettings/index.js.map +0 -1
- package/features/SaveSettings/validation.d.ts +0 -23
- package/features/SaveSettings/validation.js +0 -19
- package/features/SaveSettings/validation.js.map +0 -1
- package/features/SmtpTransport/SmtpConfig.d.ts +0 -6
- package/features/SmtpTransport/SmtpConfig.js +0 -29
- package/features/SmtpTransport/SmtpConfig.js.map +0 -1
- package/features/SmtpTransport/SmtpMailTransport.d.ts +0 -18
- package/features/SmtpTransport/SmtpMailTransport.js +0 -61
- package/features/SmtpTransport/SmtpMailTransport.js.map +0 -1
- package/features/SmtpTransport/SmtpMailTransportFactory.d.ts +0 -9
- package/features/SmtpTransport/SmtpMailTransportFactory.js +0 -14
- package/features/SmtpTransport/SmtpMailTransportFactory.js.map +0 -1
- package/features/SmtpTransport/feature.d.ts +0 -1
- package/features/SmtpTransport/feature.js +0 -10
- package/features/SmtpTransport/feature.js.map +0 -1
- package/graphql/settings.d.ts +0 -3
- package/graphql/settings.js +0 -115
- package/graphql/settings.js.map +0 -1
- package/index.js.map +0 -1
- package/types.js.map +0 -1
|
@@ -1,57 +1,67 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
|
-
import { Encryption } from "
|
|
2
|
+
import { Encryption } from "@webiny/api-core/features/encryption/index.js";
|
|
3
|
+
import { KeyNotFoundError, KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
|
|
3
4
|
import { SaveSettingsRepository } from "./abstractions.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
const
|
|
5
|
+
import { getStorageKey, withDefaults, withoutSecrets } from "../../domain/TransportSettings/findDefinition.js";
|
|
6
|
+
import { SettingsPersistenceError, SettingsValidationError } from "../../domain/errors.js";
|
|
7
|
+
const isSet = (value)=>null != value;
|
|
8
|
+
const secretRequiredMessage = (secret, fields)=>{
|
|
9
|
+
const name = secret.charAt(0).toUpperCase() + secret.slice(1);
|
|
10
|
+
const list = fields.length > 1 ? `${fields.slice(0, -1).join(", ")} or ${fields[fields.length - 1]}` : fields.join("");
|
|
11
|
+
return `${name} is required when changing the ${list} settings.`;
|
|
12
|
+
};
|
|
8
13
|
class SaveSettingsRepositoryImpl {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
async execute(input) {
|
|
14
|
-
// Check if settings exist
|
|
15
|
-
const existingResult = await this.keyValueStore.get(MAILER_TRANSPORT_SETTINGS);
|
|
16
|
-
const existingSettings = existingResult.isOk() ? existingResult.value : null;
|
|
17
|
-
const transportSettings = existingSettings ?? {};
|
|
18
|
-
|
|
19
|
-
// If updating and no password provided, keep the existing password
|
|
20
|
-
let passwordToStore = input.password || "";
|
|
21
|
-
if (!input.password && existingSettings) {
|
|
22
|
-
passwordToStore = await this.encryption.decrypt(transportSettings.password || "");
|
|
14
|
+
constructor(keyValueStore, encryption){
|
|
15
|
+
this.keyValueStore = keyValueStore;
|
|
16
|
+
this.encryption = encryption;
|
|
23
17
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
18
|
+
async execute(definition, input) {
|
|
19
|
+
const storageKey = getStorageKey(definition);
|
|
20
|
+
const secrets = definition.secrets ?? [];
|
|
21
|
+
const existingResult = await this.keyValueStore.get(storageKey);
|
|
22
|
+
if (existingResult.isFail() && !(existingResult.error instanceof KeyNotFoundError)) return Result.fail(new SettingsPersistenceError(existingResult.error));
|
|
23
|
+
const stored = existingResult.isOk() ? existingResult.value : null;
|
|
24
|
+
const merged = {
|
|
25
|
+
...stored
|
|
26
|
+
};
|
|
27
|
+
for (const [key, value] of Object.entries(input))if (isSet(value) && !secrets.includes(key)) merged[key] = value;
|
|
28
|
+
const storedWithDefaults = withDefaults(definition, {
|
|
29
|
+
...stored
|
|
30
|
+
});
|
|
31
|
+
const mergedWithDefaults = withDefaults(definition, merged);
|
|
32
|
+
const boundFieldChanged = (definition.secretsBoundTo ?? []).some((field)=>mergedWithDefaults[field] !== storedWithDefaults[field]);
|
|
33
|
+
const data = {
|
|
34
|
+
...mergedWithDefaults
|
|
35
|
+
};
|
|
36
|
+
for (const secret of secrets){
|
|
37
|
+
let plain = input[secret] ? String(input[secret]) : "";
|
|
38
|
+
if (!plain && stored?.[secret]) {
|
|
39
|
+
if (boundFieldChanged) return Result.fail(new SettingsValidationError([
|
|
40
|
+
{
|
|
41
|
+
code: "custom",
|
|
42
|
+
path: [
|
|
43
|
+
secret
|
|
44
|
+
],
|
|
45
|
+
input: void 0,
|
|
46
|
+
message: secretRequiredMessage(secret, definition.secretsBoundTo ?? [])
|
|
47
|
+
}
|
|
48
|
+
]));
|
|
49
|
+
plain = await this.encryption.decrypt(String(stored[secret]));
|
|
50
|
+
}
|
|
51
|
+
data[secret] = await this.encryption.encrypt(plain);
|
|
52
|
+
}
|
|
53
|
+
const result = await this.keyValueStore.set(storageKey, data);
|
|
54
|
+
if (result.isFail()) return Result.fail(new SettingsPersistenceError(result.error));
|
|
55
|
+
return Result.ok(withoutSecrets(definition, data));
|
|
42
56
|
}
|
|
43
|
-
|
|
44
|
-
// Return without encrypted password
|
|
45
|
-
const returnSettings = {
|
|
46
|
-
...data,
|
|
47
|
-
password: "" // Don't return password
|
|
48
|
-
};
|
|
49
|
-
return Result.ok(returnSettings);
|
|
50
|
-
}
|
|
51
57
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
const SaveSettingsRepositoryImplementation = SaveSettingsRepository.createImplementation({
|
|
59
|
+
implementation: SaveSettingsRepositoryImpl,
|
|
60
|
+
dependencies: [
|
|
61
|
+
KeyValueStore,
|
|
62
|
+
Encryption
|
|
63
|
+
]
|
|
55
64
|
});
|
|
65
|
+
export { SaveSettingsRepositoryImplementation };
|
|
56
66
|
|
|
57
67
|
//# sourceMappingURL=SaveSettingsRepository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/SaveSettings/SaveSettingsRepository.js","sources":["../../../src/features/SaveSettings/SaveSettingsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { Encryption } from \"@webiny/api-core/features/encryption/index.js\";\nimport { KeyValueStore } from \"@webiny/api-core/features/keyValueStore/index.js\";\nimport { KeyNotFoundError } from \"@webiny/api-core/features/keyValueStore/index.js\";\nimport { SaveSettingsRepository } from \"./abstractions.js\";\nimport type { TransportSettingsDefinition } from \"~/domain/TransportSettings/abstractions.js\";\nimport {\n getStorageKey,\n withDefaults,\n withoutSecrets\n} from \"~/domain/TransportSettings/findDefinition.js\";\nimport { SettingsPersistenceError, SettingsValidationError } from \"~/domain/errors.js\";\n\nconst isSet = (value: unknown) => value !== undefined && value !== null;\n\n// \"Password is required when changing the host, port, secure or user settings.\"\nconst secretRequiredMessage = (secret: string, fields: string[]) => {\n const name = secret.charAt(0).toUpperCase() + secret.slice(1);\n const list =\n fields.length > 1\n ? `${fields.slice(0, -1).join(\", \")} or ${fields[fields.length - 1]}`\n : fields.join(\"\");\n return `${name} is required when changing the ${list} settings.`;\n};\n\nclass SaveSettingsRepositoryImpl implements SaveSettingsRepository.Interface {\n constructor(\n private keyValueStore: KeyValueStore.Interface,\n private encryption: Encryption.Interface\n ) {}\n\n async execute(\n definition: TransportSettingsDefinition.Interface,\n input: TransportSettingsDefinition.Values\n ): SaveSettingsRepository.Return {\n const storageKey = getStorageKey(definition);\n const secrets = definition.secrets ?? [];\n\n const existingResult =\n await this.keyValueStore.get<TransportSettingsDefinition.Values>(storageKey);\n /*\n * Only a missing key means \"nothing saved yet\". Any other read failure would have the save\n * below replace the stored secrets and fields with blanks.\n */\n if (existingResult.isFail() && !(existingResult.error instanceof KeyNotFoundError)) {\n return Result.fail(new SettingsPersistenceError(existingResult.error));\n }\n const stored = existingResult.isOk() ? existingResult.value : null;\n\n // A field left out (or sent as null) keeps its stored value.\n const merged: TransportSettingsDefinition.Values = { ...stored };\n for (const [key, value] of Object.entries(input)) {\n if (isSet(value) && !secrets.includes(key)) {\n merged[key] = value;\n }\n }\n\n const storedWithDefaults = withDefaults(definition, { ...stored });\n const mergedWithDefaults = withDefaults(definition, merged);\n const boundFieldChanged = (definition.secretsBoundTo ?? []).some(\n field => mergedWithDefaults[field] !== storedWithDefaults[field]\n );\n\n const data: TransportSettingsDefinition.Values = { ...mergedWithDefaults };\n for (const secret of secrets) {\n let plain = input[secret] ? String(input[secret]) : \"\";\n if (!plain && stored?.[secret]) {\n /**\n * Security: re-using a stored secret is only safe while it is sent to the same\n * server and account. Otherwise a settings editor could point the transport at a\n * host they control and receive it, so it must be entered again.\n */\n if (boundFieldChanged) {\n return Result.fail(\n new SettingsValidationError([\n {\n code: \"custom\",\n path: [secret],\n input: undefined,\n message: secretRequiredMessage(\n secret,\n definition.secretsBoundTo ?? []\n )\n }\n ])\n );\n }\n plain = await this.encryption.decrypt(String(stored[secret]));\n }\n data[secret] = await this.encryption.encrypt(plain);\n }\n\n const result = await this.keyValueStore.set(storageKey, data);\n if (result.isFail()) {\n return Result.fail(new SettingsPersistenceError(result.error));\n }\n\n return Result.ok(withoutSecrets(definition, data));\n }\n}\n\nexport const SaveSettingsRepositoryImplementation = SaveSettingsRepository.createImplementation({\n implementation: SaveSettingsRepositoryImpl,\n dependencies: [KeyValueStore, Encryption]\n});\n"],"names":["isSet","value","secretRequiredMessage","secret","fields","name","list","SaveSettingsRepositoryImpl","keyValueStore","encryption","definition","input","storageKey","getStorageKey","secrets","existingResult","KeyNotFoundError","Result","SettingsPersistenceError","stored","merged","key","Object","storedWithDefaults","withDefaults","mergedWithDefaults","boundFieldChanged","field","data","plain","String","SettingsValidationError","undefined","result","withoutSecrets","SaveSettingsRepositoryImplementation","SaveSettingsRepository","KeyValueStore","Encryption"],"mappings":";;;;;;AAaA,MAAMA,QAAQ,CAACC,QAAmBA,QAAAA;AAGlC,MAAMC,wBAAwB,CAACC,QAAgBC;IAC3C,MAAMC,OAAOF,OAAO,MAAM,CAAC,GAAG,WAAW,KAAKA,OAAO,KAAK,CAAC;IAC3D,MAAMG,OACFF,OAAO,MAAM,GAAG,IACV,GAAGA,OAAO,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM,IAAI,EAAEA,MAAM,CAACA,OAAO,MAAM,GAAG,EAAE,EAAE,GACnEA,OAAO,IAAI,CAAC;IACtB,OAAO,GAAGC,KAAK,+BAA+B,EAAEC,KAAK,UAAU,CAAC;AACpE;AAEA,MAAMC;IACF,YACYC,aAAsC,EACtCC,UAAgC,CAC1C;aAFUD,aAAa,GAAbA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,QACFC,UAAiD,EACjDC,KAAyC,EACZ;QAC7B,MAAMC,aAAaC,cAAcH;QACjC,MAAMI,UAAUJ,WAAW,OAAO,IAAI,EAAE;QAExC,MAAMK,iBACF,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAAqCH;QAKrE,IAAIG,eAAe,MAAM,MAAM,CAAEA,CAAAA,eAAe,KAAK,YAAYC,gBAAe,GAC5E,OAAOC,OAAO,IAAI,CAAC,IAAIC,yBAAyBH,eAAe,KAAK;QAExE,MAAMI,SAASJ,eAAe,IAAI,KAAKA,eAAe,KAAK,GAAG;QAG9D,MAAMK,SAA6C;YAAE,GAAGD,MAAM;QAAC;QAC/D,KAAK,MAAM,CAACE,KAAKpB,MAAM,IAAIqB,OAAO,OAAO,CAACX,OACtC,IAAIX,MAAMC,UAAU,CAACa,QAAQ,QAAQ,CAACO,MAClCD,MAAM,CAACC,IAAI,GAAGpB;QAItB,MAAMsB,qBAAqBC,aAAad,YAAY;YAAE,GAAGS,MAAM;QAAC;QAChE,MAAMM,qBAAqBD,aAAad,YAAYU;QACpD,MAAMM,oBAAqBhB,AAAAA,CAAAA,WAAW,cAAc,IAAI,EAAC,EAAG,IAAI,CAC5DiB,CAAAA,QAASF,kBAAkB,CAACE,MAAM,KAAKJ,kBAAkB,CAACI,MAAM;QAGpE,MAAMC,OAA2C;YAAE,GAAGH,kBAAkB;QAAC;QACzE,KAAK,MAAMtB,UAAUW,QAAS;YAC1B,IAAIe,QAAQlB,KAAK,CAACR,OAAO,GAAG2B,OAAOnB,KAAK,CAACR,OAAO,IAAI;YACpD,IAAI,CAAC0B,SAASV,QAAQ,CAAChB,OAAO,EAAE;gBAM5B,IAAIuB,mBACA,OAAOT,OAAO,IAAI,CACd,IAAIc,wBAAwB;oBACxB;wBACI,MAAM;wBACN,MAAM;4BAAC5B;yBAAO;wBACd,OAAO6B;wBACP,SAAS9B,sBACLC,QACAO,WAAW,cAAc,IAAI,EAAE;oBAEvC;iBACH;gBAGTmB,QAAQ,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACC,OAAOX,MAAM,CAAChB,OAAO;YAC/D;YACAyB,IAAI,CAACzB,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC0B;QACjD;QAEA,MAAMI,SAAS,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAACrB,YAAYgB;QACxD,IAAIK,OAAO,MAAM,IACb,OAAOhB,OAAO,IAAI,CAAC,IAAIC,yBAAyBe,OAAO,KAAK;QAGhE,OAAOhB,OAAO,EAAE,CAACiB,eAAexB,YAAYkB;IAChD;AACJ;AAEO,MAAMO,uCAAuCC,uBAAuB,oBAAoB,CAAC;IAC5F,gBAAgB7B;IAChB,cAAc;QAAC8B;QAAeC;KAAW;AAC7C"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { EventPublisher
|
|
2
|
-
import { SaveSettingsUseCase, SaveSettingsRepository, type SaveSettingsInput } from "./abstractions.js";
|
|
1
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
2
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
3
|
+
import { SaveSettingsUseCase, SaveSettingsRepository } from "./abstractions.js";
|
|
4
|
+
import { TransportSettingsDefinition } from "../../domain/TransportSettings/abstractions.js";
|
|
4
5
|
declare class SaveSettingsUseCaseImpl implements SaveSettingsUseCase.Interface {
|
|
5
6
|
private identityContext;
|
|
6
7
|
private eventPublisher;
|
|
7
8
|
private repository;
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
private definitions;
|
|
10
|
+
constructor(identityContext: IdentityContext.Interface, eventPublisher: EventPublisher.Interface, repository: SaveSettingsRepository.Interface, definitions: TransportSettingsDefinition.Interface[]);
|
|
11
|
+
execute(transport: string, input: TransportSettingsDefinition.Values): SaveSettingsUseCase.Return;
|
|
10
12
|
}
|
|
11
13
|
export declare const SaveSettingsUseCaseImplementation: typeof SaveSettingsUseCaseImpl & {
|
|
12
14
|
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ISaveSettings>;
|
|
@@ -1,51 +1,58 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
|
-
import { EventPublisher } from "@webiny/api-core/features/
|
|
3
|
-
import { SaveSettingsUseCase, SaveSettingsRepository } from "./abstractions.js";
|
|
4
|
-
import { MailerSettingsBeforeSaveEvent, MailerSettingsAfterSaveEvent } from "./events.js";
|
|
5
|
-
import { saveValidation } from "./validation.js";
|
|
6
|
-
import { SettingsValidationError, SettingsPersistenceError, SettingsNotAuthorized } from "../../domain/errors.js";
|
|
2
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
7
3
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
4
|
+
import { SaveSettingsRepository, SaveSettingsUseCase } from "./abstractions.js";
|
|
5
|
+
import { MailerSettingsAfterSaveEvent, MailerSettingsBeforeSaveEvent } from "./events.js";
|
|
6
|
+
import { TransportSettingsDefinition } from "../../domain/TransportSettings/abstractions.js";
|
|
7
|
+
import { findDefinition, withoutSecrets } from "../../domain/TransportSettings/findDefinition.js";
|
|
8
|
+
import { SettingsLockedByCode, SettingsNotAuthorized, SettingsPersistenceError, SettingsValidationError, UnknownTransportSettings } from "../../domain/errors.js";
|
|
9
|
+
import { MAILER_SETTINGS_PERMISSION } from "../../constants.js";
|
|
8
10
|
class SaveSettingsUseCaseImpl {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
async execute(input) {
|
|
15
|
-
const permission = await this.identityContext.getPermission("mailer.settings");
|
|
16
|
-
if (!permission) {
|
|
17
|
-
return Result.fail(new SettingsNotAuthorized());
|
|
11
|
+
constructor(identityContext, eventPublisher, repository, definitions){
|
|
12
|
+
this.identityContext = identityContext;
|
|
13
|
+
this.eventPublisher = eventPublisher;
|
|
14
|
+
this.repository = repository;
|
|
15
|
+
this.definitions = definitions;
|
|
18
16
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
async execute(transport, input) {
|
|
18
|
+
const permission = await this.identityContext.getPermission(MAILER_SETTINGS_PERMISSION);
|
|
19
|
+
if (!permission) return Result.fail(new SettingsNotAuthorized());
|
|
20
|
+
const definition = findDefinition(this.definitions, transport);
|
|
21
|
+
if (!definition) return Result.fail(new UnknownTransportSettings(transport));
|
|
22
|
+
const validationResult = definition.schema.safeParse(input);
|
|
23
|
+
if (!validationResult.success) return Result.fail(new SettingsValidationError(validationResult.error.issues));
|
|
24
|
+
const values = validationResult.data;
|
|
25
|
+
if ((definition.getCodeSettings?.() ?? null) !== null) return Result.fail(new SettingsLockedByCode());
|
|
26
|
+
await this.eventPublisher.publish(new MailerSettingsBeforeSaveEvent({
|
|
27
|
+
transport,
|
|
28
|
+
input: withoutSecrets(definition, values)
|
|
29
|
+
}));
|
|
30
|
+
const result = await this.repository.execute(definition, values);
|
|
31
|
+
if (result.isFail()) {
|
|
32
|
+
if (result.error instanceof SettingsValidationError) return Result.fail(result.error);
|
|
33
|
+
return Result.fail(new SettingsPersistenceError(result.error));
|
|
34
|
+
}
|
|
35
|
+
await this.eventPublisher.publish(new MailerSettingsAfterSaveEvent({
|
|
36
|
+
transport,
|
|
37
|
+
settings: result.value
|
|
38
|
+
}));
|
|
39
|
+
return result;
|
|
24
40
|
}
|
|
25
|
-
|
|
26
|
-
// Publish before save event
|
|
27
|
-
const beforeSaveEvent = new MailerSettingsBeforeSaveEvent({
|
|
28
|
-
input
|
|
29
|
-
});
|
|
30
|
-
await this.eventPublisher.publish(beforeSaveEvent);
|
|
31
|
-
|
|
32
|
-
// Save settings
|
|
33
|
-
const result = await this.repository.execute(input);
|
|
34
|
-
if (result.isFail()) {
|
|
35
|
-
return Result.fail(new SettingsPersistenceError(result.error));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Publish after save event
|
|
39
|
-
const afterSaveEvent = new MailerSettingsAfterSaveEvent({
|
|
40
|
-
settings: result.value
|
|
41
|
-
});
|
|
42
|
-
await this.eventPublisher.publish(afterSaveEvent);
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
45
41
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
const SaveSettingsUseCaseImplementation = SaveSettingsUseCase.createImplementation({
|
|
43
|
+
implementation: SaveSettingsUseCaseImpl,
|
|
44
|
+
dependencies: [
|
|
45
|
+
IdentityContext,
|
|
46
|
+
EventPublisher,
|
|
47
|
+
SaveSettingsRepository,
|
|
48
|
+
[
|
|
49
|
+
TransportSettingsDefinition,
|
|
50
|
+
{
|
|
51
|
+
multiple: true
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
]
|
|
49
55
|
});
|
|
56
|
+
export { SaveSettingsUseCaseImplementation };
|
|
50
57
|
|
|
51
58
|
//# sourceMappingURL=SaveSettingsUseCase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/SaveSettings/SaveSettingsUseCase.js","sources":["../../../src/features/SaveSettings/SaveSettingsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { SaveSettingsUseCase, SaveSettingsRepository } from \"./abstractions.js\";\nimport { MailerSettingsBeforeSaveEvent, MailerSettingsAfterSaveEvent } from \"./events.js\";\nimport { TransportSettingsDefinition } from \"~/domain/TransportSettings/abstractions.js\";\nimport { findDefinition, withoutSecrets } from \"~/domain/TransportSettings/findDefinition.js\";\nimport {\n SettingsLockedByCode,\n SettingsNotAuthorized,\n SettingsPersistenceError,\n SettingsValidationError,\n UnknownTransportSettings\n} from \"~/domain/errors.js\";\nimport { MAILER_SETTINGS_PERMISSION } from \"~/constants.js\";\n\nclass SaveSettingsUseCaseImpl implements SaveSettingsUseCase.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private eventPublisher: EventPublisher.Interface,\n private repository: SaveSettingsRepository.Interface,\n private definitions: TransportSettingsDefinition.Interface[]\n ) {}\n\n async execute(\n transport: string,\n input: TransportSettingsDefinition.Values\n ): SaveSettingsUseCase.Return {\n const permission = await this.identityContext.getPermission(MAILER_SETTINGS_PERMISSION);\n if (!permission) {\n return Result.fail(new SettingsNotAuthorized());\n }\n\n const definition = findDefinition(this.definitions, transport);\n if (!definition) {\n return Result.fail(new UnknownTransportSettings(transport));\n }\n\n const validationResult = definition.schema.safeParse(input);\n if (!validationResult.success) {\n return Result.fail(new SettingsValidationError(validationResult.error.issues));\n }\n const values = validationResult.data as TransportSettingsDefinition.Values;\n\n // Settings set in code win over stored ones, so saving would change nothing.\n if ((definition.getCodeSettings?.() ?? null) !== null) {\n return Result.fail(new SettingsLockedByCode());\n }\n\n await this.eventPublisher.publish(\n new MailerSettingsBeforeSaveEvent({\n transport,\n input: withoutSecrets(definition, values)\n })\n );\n\n const result = await this.repository.execute(definition, values);\n if (result.isFail()) {\n if (result.error instanceof SettingsValidationError) {\n return Result.fail(result.error);\n }\n return Result.fail(new SettingsPersistenceError(result.error));\n }\n\n await this.eventPublisher.publish(\n new MailerSettingsAfterSaveEvent({ transport, settings: result.value })\n );\n\n return result;\n }\n}\n\nexport const SaveSettingsUseCaseImplementation = SaveSettingsUseCase.createImplementation({\n implementation: SaveSettingsUseCaseImpl,\n dependencies: [\n IdentityContext,\n EventPublisher,\n SaveSettingsRepository,\n [TransportSettingsDefinition, { multiple: true }]\n ]\n});\n"],"names":["SaveSettingsUseCaseImpl","identityContext","eventPublisher","repository","definitions","transport","input","permission","MAILER_SETTINGS_PERMISSION","Result","SettingsNotAuthorized","definition","findDefinition","UnknownTransportSettings","validationResult","SettingsValidationError","values","SettingsLockedByCode","MailerSettingsBeforeSaveEvent","withoutSecrets","result","SettingsPersistenceError","MailerSettingsAfterSaveEvent","SaveSettingsUseCaseImplementation","SaveSettingsUseCase","IdentityContext","EventPublisher","SaveSettingsRepository","TransportSettingsDefinition"],"mappings":";;;;;;;;;AAgBA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,cAAwC,EACxCC,UAA4C,EAC5CC,WAAoD,CAC9D;aAJUH,eAAe,GAAfA;aACAC,cAAc,GAAdA;aACAC,UAAU,GAAVA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,QACFC,SAAiB,EACjBC,KAAyC,EACf;QAC1B,MAAMC,aAAa,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAACC;QAC5D,IAAI,CAACD,YACD,OAAOE,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,aAAaC,eAAe,IAAI,CAAC,WAAW,EAAEP;QACpD,IAAI,CAACM,YACD,OAAOF,OAAO,IAAI,CAAC,IAAII,yBAAyBR;QAGpD,MAAMS,mBAAmBH,WAAW,MAAM,CAAC,SAAS,CAACL;QACrD,IAAI,CAACQ,iBAAiB,OAAO,EACzB,OAAOL,OAAO,IAAI,CAAC,IAAIM,wBAAwBD,iBAAiB,KAAK,CAAC,MAAM;QAEhF,MAAME,SAASF,iBAAiB,IAAI;QAGpC,IAAKH,AAAAA,CAAAA,WAAW,eAAe,QAAQ,IAAG,MAAO,MAC7C,OAAOF,OAAO,IAAI,CAAC,IAAIQ;QAG3B,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIC,8BAA8B;YAC9Bb;YACA,OAAOc,eAAeR,YAAYK;QACtC;QAGJ,MAAMI,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACT,YAAYK;QACzD,IAAII,OAAO,MAAM,IAAI;YACjB,IAAIA,OAAO,KAAK,YAAYL,yBACxB,OAAON,OAAO,IAAI,CAACW,OAAO,KAAK;YAEnC,OAAOX,OAAO,IAAI,CAAC,IAAIY,yBAAyBD,OAAO,KAAK;QAChE;QAEA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIE,6BAA6B;YAAEjB;YAAW,UAAUe,OAAO,KAAK;QAAC;QAGzE,OAAOA;IACX;AACJ;AAEO,MAAMG,oCAAoCC,oBAAoB,oBAAoB,CAAC;IACtF,gBAAgBxB;IAChB,cAAc;QACVyB;QACAC;QACAC;QACA;YAACC;YAA6B;gBAAE,UAAU;YAAK;SAAE;KACpD;AACL"}
|
|
@@ -1,52 +1,53 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
|
-
import type { DomainEvent, IEventHandler } from "@webiny/api-core/features/
|
|
3
|
-
import type {
|
|
4
|
-
import { SettingsValidationError, SettingsPersistenceError, SettingsNotAuthorized } from "../../domain/errors.js";
|
|
5
|
-
export interface SaveSettingsInput {
|
|
6
|
-
host: string;
|
|
7
|
-
port?: number;
|
|
8
|
-
user: string;
|
|
9
|
-
password?: string;
|
|
10
|
-
from: string;
|
|
11
|
-
replyTo?: string;
|
|
12
|
-
}
|
|
2
|
+
import type { DomainEvent, IEventHandler } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
|
+
import type { TransportSettingsDefinition } from "../../domain/TransportSettings/abstractions.js";
|
|
4
|
+
import type { SettingsValidationError, SettingsPersistenceError, SettingsNotAuthorized, SettingsLockedByCode, UnknownTransportSettings } from "../../domain/errors.js";
|
|
13
5
|
export interface ISaveSettingsErrors {
|
|
14
6
|
validation: SettingsValidationError;
|
|
15
7
|
persistence: SettingsPersistenceError;
|
|
16
8
|
notAuthorized: SettingsNotAuthorized;
|
|
9
|
+
lockedByCode: SettingsLockedByCode;
|
|
10
|
+
unknownTransport: UnknownTransportSettings;
|
|
17
11
|
}
|
|
18
12
|
type SaveSettingsError = ISaveSettingsErrors[keyof ISaveSettingsErrors];
|
|
13
|
+
/**
|
|
14
|
+
* Everything the save path returns or publishes leaves the transport's secrets out. Only
|
|
15
|
+
* `GetSettingsRepository.get` returns them, for the transport itself.
|
|
16
|
+
*/
|
|
17
|
+
export type SavedTransportSettings = TransportSettingsDefinition.Values;
|
|
19
18
|
export interface ISaveSettingsRepository {
|
|
20
|
-
execute(input:
|
|
19
|
+
execute(definition: TransportSettingsDefinition.Interface, input: TransportSettingsDefinition.Values): Promise<Result<SavedTransportSettings, SaveSettingsError>>;
|
|
21
20
|
}
|
|
22
21
|
export declare const SaveSettingsRepository: import("@webiny/di").Abstraction<ISaveSettingsRepository>;
|
|
23
22
|
export declare namespace SaveSettingsRepository {
|
|
24
23
|
type Interface = ISaveSettingsRepository;
|
|
25
|
-
type Return = Promise<Result<
|
|
24
|
+
type Return = Promise<Result<SavedTransportSettings, SaveSettingsError>>;
|
|
26
25
|
type Error = SaveSettingsError;
|
|
27
26
|
}
|
|
28
27
|
export interface ISaveSettings {
|
|
29
|
-
execute(input:
|
|
28
|
+
execute(transport: string, input: TransportSettingsDefinition.Values): Promise<Result<SavedTransportSettings, SaveSettingsError>>;
|
|
30
29
|
}
|
|
31
30
|
export declare const SaveSettingsUseCase: import("@webiny/di").Abstraction<ISaveSettings>;
|
|
32
31
|
export declare namespace SaveSettingsUseCase {
|
|
33
32
|
type Interface = ISaveSettings;
|
|
34
|
-
type Return = Promise<Result<
|
|
33
|
+
type Return = Promise<Result<SavedTransportSettings, SaveSettingsError>>;
|
|
35
34
|
type Error = SaveSettingsError;
|
|
36
35
|
}
|
|
37
36
|
export interface MailerSettingsBeforeSavePayload {
|
|
38
|
-
|
|
37
|
+
transport: string;
|
|
38
|
+
input: TransportSettingsDefinition.Values;
|
|
39
39
|
}
|
|
40
40
|
export interface MailerSettingsAfterSavePayload {
|
|
41
|
-
|
|
41
|
+
transport: string;
|
|
42
|
+
settings: SavedTransportSettings;
|
|
42
43
|
}
|
|
43
|
-
export declare const
|
|
44
|
-
export declare namespace
|
|
44
|
+
export declare const MailerSettingsBeforeSaveEventHandler: import("@webiny/di").Abstraction<IEventHandler<DomainEvent<MailerSettingsBeforeSavePayload>>>;
|
|
45
|
+
export declare namespace MailerSettingsBeforeSaveEventHandler {
|
|
45
46
|
type Interface = IEventHandler<DomainEvent<MailerSettingsBeforeSavePayload>>;
|
|
46
47
|
type Event = DomainEvent<MailerSettingsBeforeSavePayload>;
|
|
47
48
|
}
|
|
48
|
-
export declare const
|
|
49
|
-
export declare namespace
|
|
49
|
+
export declare const MailerSettingsAfterSaveEventHandler: import("@webiny/di").Abstraction<IEventHandler<DomainEvent<MailerSettingsAfterSavePayload>>>;
|
|
50
|
+
export declare namespace MailerSettingsAfterSaveEventHandler {
|
|
50
51
|
type Interface = IEventHandler<DomainEvent<MailerSettingsAfterSavePayload>>;
|
|
51
52
|
type Event = DomainEvent<MailerSettingsAfterSavePayload>;
|
|
52
53
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// Event Handler Abstractions
|
|
8
|
-
export const MailerSettingsBeforeSaveHandler = createAbstraction("MailerSettingsBeforeSaveHandler");
|
|
9
|
-
export const MailerSettingsAfterSaveHandler = createAbstraction("MailerSettingsAfterSaveHandler");
|
|
2
|
+
const SaveSettingsRepository = createAbstraction("SaveSettingsRepository");
|
|
3
|
+
const SaveSettingsUseCase = createAbstraction("SaveSettingsUseCase");
|
|
4
|
+
const MailerSettingsBeforeSaveEventHandler = createAbstraction("MailerSettingsBeforeSaveEventHandler");
|
|
5
|
+
const MailerSettingsAfterSaveEventHandler = createAbstraction("MailerSettingsAfterSaveEventHandler");
|
|
6
|
+
export { MailerSettingsAfterSaveEventHandler, MailerSettingsBeforeSaveEventHandler, SaveSettingsRepository, SaveSettingsUseCase };
|
|
10
7
|
|
|
11
8
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/SaveSettings/abstractions.js","sources":["../../../src/features/SaveSettings/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { DomainEvent, IEventHandler } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { TransportSettingsDefinition } from \"~/domain/TransportSettings/abstractions.js\";\nimport type {\n SettingsValidationError,\n SettingsPersistenceError,\n SettingsNotAuthorized,\n SettingsLockedByCode,\n UnknownTransportSettings\n} from \"~/domain/errors.js\";\n\nexport interface ISaveSettingsErrors {\n validation: SettingsValidationError;\n persistence: SettingsPersistenceError;\n notAuthorized: SettingsNotAuthorized;\n lockedByCode: SettingsLockedByCode;\n unknownTransport: UnknownTransportSettings;\n}\n\ntype SaveSettingsError = ISaveSettingsErrors[keyof ISaveSettingsErrors];\n\n/**\n * Everything the save path returns or publishes leaves the transport's secrets out. Only\n * `GetSettingsRepository.get` returns them, for the transport itself.\n */\nexport type SavedTransportSettings = TransportSettingsDefinition.Values;\n\nexport interface ISaveSettingsRepository {\n execute(\n definition: TransportSettingsDefinition.Interface,\n input: TransportSettingsDefinition.Values\n ): Promise<Result<SavedTransportSettings, SaveSettingsError>>;\n}\n\nexport const SaveSettingsRepository =\n createAbstraction<ISaveSettingsRepository>(\"SaveSettingsRepository\");\n\nexport namespace SaveSettingsRepository {\n export type Interface = ISaveSettingsRepository;\n export type Return = Promise<Result<SavedTransportSettings, SaveSettingsError>>;\n export type Error = SaveSettingsError;\n}\n\nexport interface ISaveSettings {\n execute(\n transport: string,\n input: TransportSettingsDefinition.Values\n ): Promise<Result<SavedTransportSettings, SaveSettingsError>>;\n}\n\nexport const SaveSettingsUseCase = createAbstraction<ISaveSettings>(\"SaveSettingsUseCase\");\n\nexport namespace SaveSettingsUseCase {\n export type Interface = ISaveSettings;\n export type Return = Promise<Result<SavedTransportSettings, SaveSettingsError>>;\n export type Error = SaveSettingsError;\n}\n\n// Domain events. Both payloads leave the transport's secrets out, so subscribers (audit logs,\n// telemetry) can't persist them.\nexport interface MailerSettingsBeforeSavePayload {\n transport: string;\n input: TransportSettingsDefinition.Values;\n}\n\nexport interface MailerSettingsAfterSavePayload {\n transport: string;\n settings: SavedTransportSettings;\n}\n\nexport const MailerSettingsBeforeSaveEventHandler = createAbstraction<\n IEventHandler<DomainEvent<MailerSettingsBeforeSavePayload>>\n>(\"MailerSettingsBeforeSaveEventHandler\");\n\nexport namespace MailerSettingsBeforeSaveEventHandler {\n export type Interface = IEventHandler<DomainEvent<MailerSettingsBeforeSavePayload>>;\n export type Event = DomainEvent<MailerSettingsBeforeSavePayload>;\n}\n\nexport const MailerSettingsAfterSaveEventHandler = createAbstraction<\n IEventHandler<DomainEvent<MailerSettingsAfterSavePayload>>\n>(\"MailerSettingsAfterSaveEventHandler\");\n\nexport namespace MailerSettingsAfterSaveEventHandler {\n export type Interface = IEventHandler<DomainEvent<MailerSettingsAfterSavePayload>>;\n export type Event = DomainEvent<MailerSettingsAfterSavePayload>;\n}\n"],"names":["SaveSettingsRepository","createAbstraction","SaveSettingsUseCase","MailerSettingsBeforeSaveEventHandler","MailerSettingsAfterSaveEventHandler"],"mappings":";AAmCO,MAAMA,yBACTC,kBAA2C;AAexC,MAAMC,sBAAsBD,kBAAiC;AAoB7D,MAAME,uCAAuCF,kBAElD;AAOK,MAAMG,sCAAsCH,kBAEjD"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { DomainEvent } from "@webiny/api-core/features/
|
|
1
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
2
2
|
import type { MailerSettingsBeforeSavePayload, MailerSettingsAfterSavePayload } from "./abstractions.js";
|
|
3
3
|
export declare class MailerSettingsBeforeSaveEvent extends DomainEvent<MailerSettingsBeforeSavePayload> {
|
|
4
4
|
eventType: "mailer.settings.beforeSave";
|
|
5
|
-
getHandlerAbstraction(): import("@webiny/di").Abstraction<import("@webiny/api-core/features/
|
|
5
|
+
getHandlerAbstraction(): import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<DomainEvent<MailerSettingsBeforeSavePayload>>>;
|
|
6
6
|
}
|
|
7
7
|
export declare class MailerSettingsAfterSaveEvent extends DomainEvent<MailerSettingsAfterSavePayload> {
|
|
8
8
|
eventType: "mailer.settings.afterSave";
|
|
9
|
-
getHandlerAbstraction(): import("@webiny/di").Abstraction<import("@webiny/api-core/features/
|
|
9
|
+
getHandlerAbstraction(): import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<DomainEvent<MailerSettingsAfterSavePayload>>>;
|
|
10
10
|
}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import { DomainEvent } from "@webiny/api-core/features/
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
2
|
+
import { MailerSettingsAfterSaveEventHandler, MailerSettingsBeforeSaveEventHandler } from "./abstractions.js";
|
|
3
|
+
class MailerSettingsBeforeSaveEvent extends DomainEvent {
|
|
4
|
+
getHandlerAbstraction() {
|
|
5
|
+
return MailerSettingsBeforeSaveEventHandler;
|
|
6
|
+
}
|
|
7
|
+
constructor(...args){
|
|
8
|
+
super(...args), this.eventType = "mailer.settings.beforeSave";
|
|
9
|
+
}
|
|
8
10
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
class MailerSettingsAfterSaveEvent extends DomainEvent {
|
|
12
|
+
getHandlerAbstraction() {
|
|
13
|
+
return MailerSettingsAfterSaveEventHandler;
|
|
14
|
+
}
|
|
15
|
+
constructor(...args){
|
|
16
|
+
super(...args), this.eventType = "mailer.settings.afterSave";
|
|
17
|
+
}
|
|
14
18
|
}
|
|
19
|
+
export { MailerSettingsAfterSaveEvent, MailerSettingsBeforeSaveEvent };
|
|
15
20
|
|
|
16
21
|
//# sourceMappingURL=events.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/SaveSettings/events.js","sources":["../../../src/features/SaveSettings/events.ts"],"sourcesContent":["import { DomainEvent } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport {\n MailerSettingsBeforeSaveEventHandler,\n MailerSettingsAfterSaveEventHandler\n} from \"./abstractions.js\";\nimport type {\n MailerSettingsBeforeSavePayload,\n MailerSettingsAfterSavePayload\n} from \"./abstractions.js\";\n\nexport class MailerSettingsBeforeSaveEvent extends DomainEvent<MailerSettingsBeforeSavePayload> {\n eventType = \"mailer.settings.beforeSave\" as const;\n\n getHandlerAbstraction() {\n return MailerSettingsBeforeSaveEventHandler;\n }\n}\n\nexport class MailerSettingsAfterSaveEvent extends DomainEvent<MailerSettingsAfterSavePayload> {\n eventType = \"mailer.settings.afterSave\" as const;\n\n getHandlerAbstraction() {\n return MailerSettingsAfterSaveEventHandler;\n }\n}\n"],"names":["MailerSettingsBeforeSaveEvent","DomainEvent","MailerSettingsBeforeSaveEventHandler","MailerSettingsAfterSaveEvent","MailerSettingsAfterSaveEventHandler"],"mappings":";;AAUO,MAAMA,sCAAsCC;IAG/C,wBAAwB;QACpB,OAAOC;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMC,qCAAqCF;IAG9C,wBAAwB;QACpB,OAAOG;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { SaveSettingsRepositoryImplementation } from "./SaveSettingsRepository.js";
|
|
3
3
|
import { SaveSettingsUseCaseImplementation } from "./SaveSettingsUseCase.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const SaveSettingsFeature = createFeature({
|
|
5
|
+
name: "Mailer/SaveSettings",
|
|
6
|
+
register (container) {
|
|
7
|
+
container.register(SaveSettingsRepositoryImplementation).inSingletonScope();
|
|
8
|
+
container.register(SaveSettingsUseCaseImplementation);
|
|
9
|
+
}
|
|
10
10
|
});
|
|
11
|
+
export { SaveSettingsFeature };
|
|
11
12
|
|
|
12
13
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/SaveSettings/feature.js","sources":["../../../src/features/SaveSettings/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { SaveSettingsRepositoryImplementation } from \"./SaveSettingsRepository.js\";\nimport { SaveSettingsUseCaseImplementation } from \"./SaveSettingsUseCase.js\";\n\nexport const SaveSettingsFeature = createFeature({\n name: \"Mailer/SaveSettings\",\n register(container) {\n container.register(SaveSettingsRepositoryImplementation).inSingletonScope();\n container.register(SaveSettingsUseCaseImplementation);\n }\n});\n"],"names":["SaveSettingsFeature","createFeature","container","SaveSettingsRepositoryImplementation","SaveSettingsUseCaseImplementation"],"mappings":";;;AAIO,MAAMA,sBAAsBC,cAAc;IAC7C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,sCAAsC,gBAAgB;QACzED,UAAU,QAAQ,CAACE;IACvB;AACJ"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { SaveSettingsUseCase,
|
|
1
|
+
export { SaveSettingsUseCase, SaveSettingsRepository, MailerSettingsAfterSaveEventHandler, MailerSettingsBeforeSaveEventHandler } from "./abstractions.js";
|
|
2
|
+
export type { SavedTransportSettings, MailerSettingsBeforeSavePayload, MailerSettingsAfterSavePayload } from "./abstractions.js";
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { MailerSettingsAfterSaveEventHandler, MailerSettingsBeforeSaveEventHandler, SaveSettingsRepository, SaveSettingsUseCase } from "./abstractions.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventPublisher as EventPublisherAbstraction } from "@webiny/api-core/features/
|
|
1
|
+
import { EventPublisher as EventPublisherAbstraction } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
2
2
|
import { SendMailUseCase } from "./abstractions.js";
|
|
3
3
|
import { MailerService } from "../../domain/MailerService/abstractions.js";
|
|
4
4
|
import type { TransportSendData } from "../../types.js";
|
|
@@ -8,7 +8,7 @@ declare class SendMailUseCaseImpl implements SendMailUseCase.Interface {
|
|
|
8
8
|
private mailerService;
|
|
9
9
|
private eventPublisher;
|
|
10
10
|
constructor(mailerService: MailerService.Interface, eventPublisher: EventPublisherAbstraction.Interface);
|
|
11
|
-
execute(data: TransportSendData): Promise<Result<never, MailValidationError> | Result<import("~/types.js").TransportSendResponse<any>, import("../../domain/MailerService/errors.js").NoTransportAvailableError | import("../../domain/MailerService/errors.js").
|
|
11
|
+
execute(data: TransportSendData): Promise<Result<never, MailValidationError> | Result<import("~/types.js").TransportSendResponse<any>, import("../../domain/MailerService/errors.js").NoTransportAvailableError | import("../../domain/MailerService/errors.js").TransportCreateError | import("../../domain/MailerService/errors.js").TransportSendError>>;
|
|
12
12
|
}
|
|
13
13
|
export declare const SendMailUseCaseImplementation: typeof SendMailUseCaseImpl & {
|
|
14
14
|
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ISendMailUseCase>;
|