apeframework 0.0.0-dev.20 → 0.0.0-dev.21
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/LICENSE +1 -1
- package/cipher/Algorithm.js +2 -4
- package/cipher/Cipher.js +9 -15
- package/cipher/errors/DecryptError.js +3 -6
- package/cipher/errors/SecretLengthError.js +3 -6
- package/cipher/validateSecretLength.js +7 -10
- package/cli/Args.js +1 -2
- package/cli/Command.js +1 -2
- package/cli/getArgs.js +3 -6
- package/cli/parseArgs.js +3 -9
- package/cli/utils/exit.js +1 -4
- package/cli/utils/formatList.js +3 -6
- package/cli/utils/formatTable.js +3 -6
- package/cli/utils/formatText.js +3 -6
- package/cli/utils/print.js +1 -4
- package/cli/utils/printLn.js +3 -6
- package/config/Config.js +1 -2
- package/config/Properties.js +1 -2
- package/config/errors/FileReadError.js +3 -6
- package/config/errors/PropertyNameError.js +3 -6
- package/config/errors/PropertyParseError.js +3 -6
- package/config/getConfig.js +8 -11
- package/config/getPropertyEnvVar.js +1 -4
- package/config/parseProperty.js +3 -6
- package/config/readFile.js +8 -14
- package/config/validatePropertyName.js +3 -6
- package/env/Env.js +1 -2
- package/env/errors/FileReadError.js +3 -6
- package/env/getEnv.js +3 -6
- package/env/readFile.js +8 -14
- package/error/BaseError.js +1 -4
- package/jwt/Algorithm.js +2 -4
- package/jwt/Jwt.js +6 -9
- package/jwt/Payload.js +1 -2
- package/jwt/errors/SecretLengthError.js +3 -6
- package/jwt/validateSecretLength.js +7 -10
- package/logger/Level.js +2 -4
- package/logger/Logger.js +1 -4
- package/logger/Severity.js +2 -4
- package/logger/adapters/file/FileLogger.js +11 -17
- package/logger/adapters/file/errors/FileInitError.js +3 -6
- package/logger/adapters/file/initFile.js +6 -12
- package/logger/adapters/noop/NoopLogger.js +3 -6
- package/logger/adapters/stdio/StdioLogger.js +11 -17
- package/mailer/Address.js +1 -2
- package/mailer/Attachment.js +1 -2
- package/mailer/Event.js +1 -2
- package/mailer/List.js +1 -2
- package/mailer/Location.js +1 -2
- package/mailer/Mail.js +1 -2
- package/mailer/Mailer.js +16 -19
- package/mailer/Method.js +2 -4
- package/mailer/adapters/noop/NoopMailer.js +5 -8
- package/mailer/adapters/smtp/SmtpMailer.js +19 -25
- package/mailer/adapters/smtp/getAddress.js +1 -4
- package/mailer/adapters/smtp/getAddresses.js +3 -6
- package/mailer/adapters/smtp/getAttachments.js +1 -4
- package/mailer/errors/AddressEmailError.js +3 -6
- package/mailer/errors/EventAttachmentUrlError.js +3 -6
- package/mailer/errors/EventGeolocationError.js +3 -6
- package/mailer/errors/EventUrlError.js +3 -6
- package/mailer/errors/ListUrlError.js +3 -6
- package/mailer/getIcalendar.js +3 -6
- package/mailer/validateAddressEmail.js +5 -8
- package/mailer/validateEventAttachmentUrl.js +5 -8
- package/mailer/validateEventGeolocation.js +5 -8
- package/mailer/validateEventUrl.js +5 -8
- package/mailer/validateListUrl.js +5 -8
- package/package.json +2 -4
- package/parser/Parser.js +1 -2
- package/parser/errors/ParseError.js +3 -6
- package/parser/factories/enum/createEnumParser.js +3 -6
- package/parser/factories/unit/Unit.js +1 -2
- package/parser/factories/unit/createUnitParser.js +8 -11
- package/parser/parseBoolean.js +3 -6
- package/parser/parseBytes.js +3 -6
- package/parser/parseInteger.js +6 -9
- package/parser/parseMilliseconds.js +3 -6
- package/parser/parseNumber.js +4 -7
- package/parser/parseString.js +3 -6
- package/pwd/Pwd.js +6 -12
- package/pwd/errors/HashRoundsError.js +3 -6
- package/pwd/validateHashRounds.js +3 -6
- package/server/ErrorHandler.js +1 -2
- package/server/Format.js +1 -2
- package/server/Handler.js +1 -2
- package/server/Method.js +2 -4
- package/server/OpenApiFormat.js +2 -4
- package/server/Route.js +1 -2
- package/server/Schema.js +1 -2
- package/server/Server.js +15 -21
- package/server/getAjv.js +5 -11
- package/tls/Tls.js +1 -2
- package/tls/errors/FileReadError.js +3 -6
- package/tls/getTls.js +5 -8
- package/tls/readFile.js +7 -13
- package/utils/getRandomHexString.js +3 -6
- package/utils/getTimestamp.js +1 -4
- package/utils/isValidEmail.js +1 -4
- package/utils/isValidGeolocation.js +1 -4
- package/utils/isValidHexString.js +1 -4
- package/utils/isValidIsoDate.js +1 -4
- package/utils/isValidJwtToken.js +1 -4
- package/utils/isValidUrl.js +1 -4
- package/utils/isValidUuid.js +1 -4
- package/utils/wait.js +1 -4
- package/cipher/Algorithm.ts +0 -9
- package/cipher/Cipher.ts +0 -46
- package/cipher/errors/DecryptError.ts +0 -11
- package/cipher/errors/SecretLengthError.ts +0 -11
- package/cipher/validateSecretLength.ts +0 -18
- package/cli/Args.ts +0 -8
- package/cli/Command.ts +0 -7
- package/cli/getArgs.ts +0 -10
- package/cli/parseArgs.ts +0 -34
- package/cli/utils/exit.ts +0 -7
- package/cli/utils/formatList.ts +0 -11
- package/cli/utils/formatTable.ts +0 -25
- package/cli/utils/formatText.ts +0 -9
- package/cli/utils/print.ts +0 -7
- package/cli/utils/printLn.ts +0 -9
- package/config/Config.ts +0 -5
- package/config/Properties.ts +0 -12
- package/config/errors/FileReadError.ts +0 -11
- package/config/errors/PropertyNameError.ts +0 -11
- package/config/errors/PropertyParseError.ts +0 -11
- package/config/getConfig.ts +0 -47
- package/config/getPropertyEnvVar.ts +0 -15
- package/config/parseProperty.ts +0 -47
- package/config/readFile.ts +0 -34
- package/config/validatePropertyName.ts +0 -13
- package/env/Env.ts +0 -5
- package/env/errors/FileReadError.ts +0 -11
- package/env/getEnv.ts +0 -24
- package/env/readFile.ts +0 -24
- package/error/BaseError.ts +0 -12
- package/jwt/Algorithm.ts +0 -9
- package/jwt/Jwt.ts +0 -49
- package/jwt/Payload.ts +0 -14
- package/jwt/errors/SecretLengthError.ts +0 -11
- package/jwt/validateSecretLength.ts +0 -18
- package/logger/Level.ts +0 -13
- package/logger/Logger.ts +0 -19
- package/logger/Severity.ts +0 -12
- package/logger/adapters/file/FileLogger.ts +0 -87
- package/logger/adapters/file/errors/FileInitError.ts +0 -11
- package/logger/adapters/file/initFile.ts +0 -18
- package/logger/adapters/noop/NoopLogger.ts +0 -21
- package/logger/adapters/stdio/StdioLogger.ts +0 -89
- package/mailer/Address.ts +0 -8
- package/mailer/Attachment.ts +0 -11
- package/mailer/Event.ts +0 -20
- package/mailer/List.ts +0 -10
- package/mailer/Location.ts +0 -12
- package/mailer/Mail.ts +0 -23
- package/mailer/Mailer.ts +0 -69
- package/mailer/Method.ts +0 -8
- package/mailer/adapters/noop/NoopMailer.ts +0 -15
- package/mailer/adapters/smtp/SmtpMailer.ts +0 -74
- package/mailer/adapters/smtp/getAddress.ts +0 -15
- package/mailer/adapters/smtp/getAddresses.ts +0 -17
- package/mailer/adapters/smtp/getAttachments.ts +0 -20
- package/mailer/errors/AddressEmailError.ts +0 -11
- package/mailer/errors/EventAttachmentUrlError.ts +0 -11
- package/mailer/errors/EventGeolocationError.ts +0 -11
- package/mailer/errors/EventUrlError.ts +0 -11
- package/mailer/errors/ListUrlError.ts +0 -11
- package/mailer/getIcalendar.ts +0 -39
- package/mailer/validateAddressEmail.ts +0 -12
- package/mailer/validateEventAttachmentUrl.ts +0 -12
- package/mailer/validateEventGeolocation.ts +0 -15
- package/mailer/validateEventUrl.ts +0 -12
- package/mailer/validateListUrl.ts +0 -12
- package/parser/Parser.ts +0 -5
- package/parser/errors/ParseError.ts +0 -11
- package/parser/factories/enum/createEnumParser.ts +0 -21
- package/parser/factories/unit/Unit.ts +0 -8
- package/parser/factories/unit/createUnitParser.ts +0 -50
- package/parser/parseBoolean.ts +0 -33
- package/parser/parseBytes.ts +0 -55
- package/parser/parseInteger.ts +0 -23
- package/parser/parseMilliseconds.ts +0 -31
- package/parser/parseNumber.ts +0 -22
- package/parser/parseString.ts +0 -16
- package/pwd/Pwd.ts +0 -31
- package/pwd/errors/HashRoundsError.ts +0 -11
- package/pwd/validateHashRounds.ts +0 -11
- package/server/ErrorHandler.ts +0 -11
- package/server/Format.ts +0 -15
- package/server/Handler.ts +0 -10
- package/server/Method.ts +0 -11
- package/server/OpenApiFormat.ts +0 -8
- package/server/Route.ts +0 -16
- package/server/Schema.ts +0 -13
- package/server/Server.ts +0 -134
- package/server/getAjv.ts +0 -26
- package/tls/Tls.ts +0 -10
- package/tls/errors/FileReadError.ts +0 -11
- package/tls/getTls.ts +0 -24
- package/tls/readFile.ts +0 -18
- package/utils/getRandomHexString.ts +0 -9
- package/utils/getTimestamp.ts +0 -7
- package/utils/isValidEmail.ts +0 -9
- package/utils/isValidGeolocation.ts +0 -10
- package/utils/isValidHexString.ts +0 -9
- package/utils/isValidIsoDate.ts +0 -9
- package/utils/isValidJwtToken.ts +0 -9
- package/utils/isValidUrl.ts +0 -21
- package/utils/isValidUuid.ts +0 -10
- package/utils/wait.ts +0 -9
package/logger/Severity.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Severity = void 0;
|
|
4
1
|
var Severity;
|
|
5
2
|
(function (Severity) {
|
|
6
3
|
Severity[Severity["TRACE"] = 10] = "TRACE";
|
|
@@ -9,4 +6,5 @@ var Severity;
|
|
|
9
6
|
Severity[Severity["WARN"] = 40] = "WARN";
|
|
10
7
|
Severity[Severity["ERROR"] = 50] = "ERROR";
|
|
11
8
|
Severity[Severity["FATAL"] = 60] = "FATAL";
|
|
12
|
-
})(Severity || (
|
|
9
|
+
})(Severity || (Severity = {}));
|
|
10
|
+
export { Severity, };
|
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
exports.FileLogger = void 0;
|
|
7
|
-
const pino_1 = __importDefault(require("pino"));
|
|
8
|
-
const Level_1 = require("../../Level");
|
|
9
|
-
const Logger_1 = require("../../Logger");
|
|
10
|
-
const initFile_1 = require("./initFile");
|
|
11
|
-
class FileLogger extends Logger_1.Logger {
|
|
1
|
+
import pino from 'pino';
|
|
2
|
+
import { Level } from '../../Level';
|
|
3
|
+
import { Logger } from '../../Logger';
|
|
4
|
+
import { initFile } from './initFile';
|
|
5
|
+
class FileLogger extends Logger {
|
|
12
6
|
logger;
|
|
13
7
|
context;
|
|
14
8
|
constructor(params) {
|
|
15
9
|
super();
|
|
16
|
-
|
|
17
|
-
const stream =
|
|
18
|
-
this.logger = (
|
|
19
|
-
enabled: params.level !==
|
|
20
|
-
level: params.level ??
|
|
10
|
+
initFile(params.path);
|
|
11
|
+
const stream = pino.destination(params.path);
|
|
12
|
+
this.logger = pino({
|
|
13
|
+
enabled: params.level !== Level.OFF,
|
|
14
|
+
level: params.level ?? Level.INFO,
|
|
21
15
|
messageKey: 'message',
|
|
22
16
|
formatters: {
|
|
23
17
|
level(label, number) {
|
|
@@ -67,4 +61,4 @@ class FileLogger extends Logger_1.Logger {
|
|
|
67
61
|
};
|
|
68
62
|
}
|
|
69
63
|
}
|
|
70
|
-
|
|
64
|
+
export { FileLogger, };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.FileInitError = void 0;
|
|
4
|
-
const BaseError_1 = require("../../../../error/BaseError");
|
|
5
|
-
class FileInitError extends BaseError_1.BaseError {
|
|
1
|
+
import { BaseError } from '../../../../error/BaseError';
|
|
2
|
+
class FileInitError extends BaseError {
|
|
6
3
|
constructor(path, message) {
|
|
7
4
|
super(`failed initializing file "${path}": ${message}`);
|
|
8
5
|
}
|
|
9
6
|
}
|
|
10
|
-
|
|
7
|
+
export { FileInitError, };
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.initFile = void 0;
|
|
7
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
-
const FileInitError_1 = require("./errors/FileInitError");
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import { FileInitError } from './errors/FileInitError';
|
|
9
3
|
const initFile = (path) => {
|
|
10
4
|
if (path === '') {
|
|
11
|
-
throw new
|
|
5
|
+
throw new FileInitError('', 'empty path');
|
|
12
6
|
}
|
|
13
7
|
try {
|
|
14
|
-
|
|
8
|
+
fs.ensureFileSync(path);
|
|
15
9
|
}
|
|
16
10
|
catch (error) {
|
|
17
|
-
throw new
|
|
11
|
+
throw new FileInitError(path, error.message);
|
|
18
12
|
}
|
|
19
13
|
};
|
|
20
|
-
|
|
14
|
+
export { initFile, };
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.NoopLogger = void 0;
|
|
4
|
-
const Logger_1 = require("../../Logger");
|
|
5
|
-
class NoopLogger extends Logger_1.Logger {
|
|
1
|
+
import { Logger } from '../../Logger';
|
|
2
|
+
class NoopLogger extends Logger {
|
|
6
3
|
trace() { }
|
|
7
4
|
debug() { }
|
|
8
5
|
info() { }
|
|
@@ -11,4 +8,4 @@ class NoopLogger extends Logger_1.Logger {
|
|
|
11
8
|
fatal() { }
|
|
12
9
|
async close() { }
|
|
13
10
|
}
|
|
14
|
-
|
|
11
|
+
export { NoopLogger, };
|
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
exports.StdioLogger = void 0;
|
|
7
|
-
const pino_1 = __importDefault(require("pino"));
|
|
8
|
-
const pino_pretty_1 = __importDefault(require("pino-pretty"));
|
|
9
|
-
const Level_1 = require("../../Level");
|
|
10
|
-
const Logger_1 = require("../../Logger");
|
|
11
|
-
class StdioLogger extends Logger_1.Logger {
|
|
1
|
+
import pino from 'pino';
|
|
2
|
+
import pretty from 'pino-pretty';
|
|
3
|
+
import { Level } from '../../Level';
|
|
4
|
+
import { Logger } from '../../Logger';
|
|
5
|
+
class StdioLogger extends Logger {
|
|
12
6
|
logger;
|
|
13
7
|
context;
|
|
14
8
|
constructor(params) {
|
|
15
9
|
super();
|
|
16
10
|
const stream = params?.pretty
|
|
17
|
-
? (
|
|
18
|
-
:
|
|
19
|
-
this.logger = (
|
|
20
|
-
enabled: params?.level !==
|
|
21
|
-
level: params?.level ??
|
|
11
|
+
? pretty()
|
|
12
|
+
: pino.destination(process.stdout.fd);
|
|
13
|
+
this.logger = pino({
|
|
14
|
+
enabled: params?.level !== Level.OFF,
|
|
15
|
+
level: params?.level ?? Level.INFO,
|
|
22
16
|
messageKey: 'message',
|
|
23
17
|
formatters: {
|
|
24
18
|
level(label, number) {
|
|
@@ -70,4 +64,4 @@ class StdioLogger extends Logger_1.Logger {
|
|
|
70
64
|
};
|
|
71
65
|
}
|
|
72
66
|
}
|
|
73
|
-
|
|
67
|
+
export { StdioLogger, };
|
package/mailer/Address.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/mailer/Attachment.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/mailer/Event.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/mailer/List.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/mailer/Location.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/mailer/Mail.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/mailer/Mailer.js
CHANGED
|
@@ -1,50 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const validateEventGeolocation_1 = require("./validateEventGeolocation");
|
|
7
|
-
const validateEventUrl_1 = require("./validateEventUrl");
|
|
8
|
-
const validateListUrl_1 = require("./validateListUrl");
|
|
1
|
+
import { validateAddressEmail } from './validateAddressEmail';
|
|
2
|
+
import { validateEventAttachmentUrl } from './validateEventAttachmentUrl';
|
|
3
|
+
import { validateEventGeolocation } from './validateEventGeolocation';
|
|
4
|
+
import { validateEventUrl } from './validateEventUrl';
|
|
5
|
+
import { validateListUrl } from './validateListUrl';
|
|
9
6
|
class Mailer {
|
|
10
7
|
async send(mail) {
|
|
11
|
-
|
|
8
|
+
validateAddressEmail(mail.from.email);
|
|
12
9
|
if (mail.sender) {
|
|
13
|
-
|
|
10
|
+
validateAddressEmail(mail.sender.email);
|
|
14
11
|
}
|
|
15
12
|
if (mail.replyTo) {
|
|
16
|
-
|
|
13
|
+
validateAddressEmail(mail.replyTo.email);
|
|
17
14
|
}
|
|
18
15
|
mail.to.forEach((address) => {
|
|
19
|
-
|
|
16
|
+
validateAddressEmail(address.email);
|
|
20
17
|
});
|
|
21
18
|
if (mail.cc) {
|
|
22
19
|
mail.cc.forEach((address) => {
|
|
23
|
-
|
|
20
|
+
validateAddressEmail(address.email);
|
|
24
21
|
});
|
|
25
22
|
}
|
|
26
23
|
if (mail.bcc) {
|
|
27
24
|
mail.bcc.forEach((address) => {
|
|
28
|
-
|
|
25
|
+
validateAddressEmail(address.email);
|
|
29
26
|
});
|
|
30
27
|
}
|
|
31
28
|
if (mail.event?.url) {
|
|
32
|
-
|
|
29
|
+
validateEventUrl(mail.event.url);
|
|
33
30
|
}
|
|
34
31
|
if (mail.event?.location?.geo) {
|
|
35
|
-
|
|
32
|
+
validateEventGeolocation(mail.event.location.geo.latitude, mail.event.location.geo.longitude);
|
|
36
33
|
}
|
|
37
34
|
if (mail.event?.attachments) {
|
|
38
35
|
mail.event.attachments.forEach((attachment) => {
|
|
39
|
-
|
|
36
|
+
validateEventAttachmentUrl(attachment);
|
|
40
37
|
});
|
|
41
38
|
}
|
|
42
39
|
if (mail.list) {
|
|
43
40
|
Object.entries(mail.list).forEach(([property, url]) => {
|
|
44
|
-
|
|
41
|
+
validateListUrl(property, url);
|
|
45
42
|
});
|
|
46
43
|
}
|
|
47
44
|
return this.sendMail(mail);
|
|
48
45
|
}
|
|
49
46
|
}
|
|
50
|
-
|
|
47
|
+
export { Mailer, };
|
package/mailer/Method.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Method = void 0;
|
|
4
1
|
var Method;
|
|
5
2
|
(function (Method) {
|
|
6
3
|
Method["PUBLISH"] = "PUBLISH";
|
|
7
4
|
Method["CANCEL"] = "CANCEL";
|
|
8
|
-
})(Method || (
|
|
5
|
+
})(Method || (Method = {}));
|
|
6
|
+
export { Method, };
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const crypto_1 = require("crypto");
|
|
5
|
-
const Mailer_1 = require("../../Mailer");
|
|
6
|
-
class NoopMailer extends Mailer_1.Mailer {
|
|
1
|
+
import { randomUUID } from 'crypto';
|
|
2
|
+
import { Mailer } from '../../Mailer';
|
|
3
|
+
class NoopMailer extends Mailer {
|
|
7
4
|
async sendMail(mail) {
|
|
8
|
-
return `${
|
|
5
|
+
return `${randomUUID()}@${mail.from.email.split('@')[1]}`;
|
|
9
6
|
}
|
|
10
7
|
async close() { }
|
|
11
8
|
}
|
|
12
|
-
|
|
9
|
+
export { NoopMailer, };
|
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const Mailer_1 = require("../../Mailer");
|
|
10
|
-
const getIcalendar_1 = require("../../getIcalendar");
|
|
11
|
-
const getAddress_1 = require("./getAddress");
|
|
12
|
-
const getAddresses_1 = require("./getAddresses");
|
|
13
|
-
const getAttachments_1 = require("./getAttachments");
|
|
14
|
-
class SmtpMailer extends Mailer_1.Mailer {
|
|
1
|
+
import nodemailer from 'nodemailer';
|
|
2
|
+
import { getTls } from '../../../tls/getTls';
|
|
3
|
+
import { Mailer } from '../../Mailer';
|
|
4
|
+
import { getIcalendar } from '../../getIcalendar';
|
|
5
|
+
import { getAddress } from './getAddress';
|
|
6
|
+
import { getAddresses } from './getAddresses';
|
|
7
|
+
import { getAttachments } from './getAttachments';
|
|
8
|
+
class SmtpMailer extends Mailer {
|
|
15
9
|
transporter;
|
|
16
10
|
constructor(params) {
|
|
17
11
|
super();
|
|
18
|
-
this.transporter =
|
|
12
|
+
this.transporter = nodemailer.createTransport({
|
|
19
13
|
host: params.host,
|
|
20
14
|
port: params.port,
|
|
21
15
|
secure: params.secure ?? false,
|
|
22
|
-
tls:
|
|
16
|
+
tls: getTls(params.tls),
|
|
23
17
|
auth: params.user || params.password
|
|
24
18
|
? {
|
|
25
19
|
user: params.user,
|
|
@@ -32,21 +26,21 @@ class SmtpMailer extends Mailer_1.Mailer {
|
|
|
32
26
|
}
|
|
33
27
|
async sendMail(mail) {
|
|
34
28
|
const result = await this.transporter.sendMail({
|
|
35
|
-
from:
|
|
36
|
-
sender:
|
|
37
|
-
replyTo:
|
|
38
|
-
to:
|
|
39
|
-
cc:
|
|
40
|
-
bcc:
|
|
29
|
+
from: getAddress(mail.from),
|
|
30
|
+
sender: getAddress(mail.sender),
|
|
31
|
+
replyTo: getAddress(mail.replyTo),
|
|
32
|
+
to: getAddresses(mail.to),
|
|
33
|
+
cc: getAddresses(mail.cc),
|
|
34
|
+
bcc: getAddresses(mail.bcc),
|
|
41
35
|
subject: mail.subject,
|
|
42
36
|
text: mail.text,
|
|
43
37
|
html: mail.html,
|
|
44
|
-
attachments:
|
|
38
|
+
attachments: getAttachments(mail.attachments),
|
|
45
39
|
icalEvent: mail.event
|
|
46
40
|
? {
|
|
47
41
|
filename: mail.event.fileName ?? 'event.ics',
|
|
48
42
|
method: mail.event.method,
|
|
49
|
-
content:
|
|
43
|
+
content: getIcalendar(mail.event),
|
|
50
44
|
}
|
|
51
45
|
: undefined,
|
|
52
46
|
list: { ...mail.list },
|
|
@@ -57,4 +51,4 @@ class SmtpMailer extends Mailer_1.Mailer {
|
|
|
57
51
|
this.transporter.close();
|
|
58
52
|
}
|
|
59
53
|
}
|
|
60
|
-
|
|
54
|
+
export { SmtpMailer, };
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAddress = void 0;
|
|
4
1
|
const getAddress = (address) => {
|
|
5
2
|
return address
|
|
6
3
|
? {
|
|
@@ -9,4 +6,4 @@ const getAddress = (address) => {
|
|
|
9
6
|
}
|
|
10
7
|
: undefined;
|
|
11
8
|
};
|
|
12
|
-
|
|
9
|
+
export { getAddress, };
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAddresses = void 0;
|
|
4
|
-
const getAddress_1 = require("./getAddress");
|
|
1
|
+
import { getAddress } from './getAddress';
|
|
5
2
|
const getAddresses = (addresses) => {
|
|
6
3
|
return addresses
|
|
7
4
|
? addresses
|
|
8
|
-
.map(
|
|
5
|
+
.map(getAddress)
|
|
9
6
|
.filter((address) => {
|
|
10
7
|
return address !== undefined;
|
|
11
8
|
})
|
|
12
9
|
: [];
|
|
13
10
|
};
|
|
14
|
-
|
|
11
|
+
export { getAddresses, };
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAttachments = void 0;
|
|
4
1
|
const getAttachments = (attachments) => {
|
|
5
2
|
return attachments
|
|
6
3
|
? attachments
|
|
@@ -14,4 +11,4 @@ const getAttachments = (attachments) => {
|
|
|
14
11
|
})
|
|
15
12
|
: [];
|
|
16
13
|
};
|
|
17
|
-
|
|
14
|
+
export { getAttachments, };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.AddressEmailError = void 0;
|
|
4
|
-
const BaseError_1 = require("../../error/BaseError");
|
|
5
|
-
class AddressEmailError extends BaseError_1.BaseError {
|
|
1
|
+
import { BaseError } from '../../error/BaseError';
|
|
2
|
+
class AddressEmailError extends BaseError {
|
|
6
3
|
constructor(email) {
|
|
7
4
|
super(`invalid address email "${email}"`);
|
|
8
5
|
}
|
|
9
6
|
}
|
|
10
|
-
|
|
7
|
+
export { AddressEmailError, };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.EventAttachmentUrlError = void 0;
|
|
4
|
-
const BaseError_1 = require("../../error/BaseError");
|
|
5
|
-
class EventAttachmentUrlError extends BaseError_1.BaseError {
|
|
1
|
+
import { BaseError } from '../../error/BaseError';
|
|
2
|
+
class EventAttachmentUrlError extends BaseError {
|
|
6
3
|
constructor(url) {
|
|
7
4
|
super(`invalid event attachment url "${url}"`);
|
|
8
5
|
}
|
|
9
6
|
}
|
|
10
|
-
|
|
7
|
+
export { EventAttachmentUrlError, };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.EventGeolocationError = void 0;
|
|
4
|
-
const BaseError_1 = require("../../error/BaseError");
|
|
5
|
-
class EventGeolocationError extends BaseError_1.BaseError {
|
|
1
|
+
import { BaseError } from '../../error/BaseError';
|
|
2
|
+
class EventGeolocationError extends BaseError {
|
|
6
3
|
constructor(latitude, longitude) {
|
|
7
4
|
super(`invalid event geolocation "${latitude}, ${longitude}"`);
|
|
8
5
|
}
|
|
9
6
|
}
|
|
10
|
-
|
|
7
|
+
export { EventGeolocationError, };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.EventUrlError = void 0;
|
|
4
|
-
const BaseError_1 = require("../../error/BaseError");
|
|
5
|
-
class EventUrlError extends BaseError_1.BaseError {
|
|
1
|
+
import { BaseError } from '../../error/BaseError';
|
|
2
|
+
class EventUrlError extends BaseError {
|
|
6
3
|
constructor(url) {
|
|
7
4
|
super(`invalid event url "${url}"`);
|
|
8
5
|
}
|
|
9
6
|
}
|
|
10
|
-
|
|
7
|
+
export { EventUrlError, };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ListUrlError = void 0;
|
|
4
|
-
const BaseError_1 = require("../../error/BaseError");
|
|
5
|
-
class ListUrlError extends BaseError_1.BaseError {
|
|
1
|
+
import { BaseError } from '../../error/BaseError';
|
|
2
|
+
class ListUrlError extends BaseError {
|
|
6
3
|
constructor(property, url) {
|
|
7
4
|
super(`invalid list ${property} url "${url}"`);
|
|
8
5
|
}
|
|
9
6
|
}
|
|
10
|
-
|
|
7
|
+
export { ListUrlError, };
|
package/mailer/getIcalendar.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getIcalendar = void 0;
|
|
4
|
-
const ical_generator_1 = require("ical-generator");
|
|
1
|
+
import { ICalCalendar } from 'ical-generator';
|
|
5
2
|
const getIcalendar = (event) => {
|
|
6
|
-
const calendar = new
|
|
3
|
+
const calendar = new ICalCalendar({
|
|
7
4
|
method: event.method,
|
|
8
5
|
events: [
|
|
9
6
|
{
|
|
@@ -32,4 +29,4 @@ const getIcalendar = (event) => {
|
|
|
32
29
|
});
|
|
33
30
|
return calendar.toString();
|
|
34
31
|
};
|
|
35
|
-
|
|
32
|
+
export { getIcalendar, };
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.validateAddressEmail = void 0;
|
|
4
|
-
const isValidEmail_1 = require("utils/isValidEmail");
|
|
5
|
-
const AddressEmailError_1 = require("./errors/AddressEmailError");
|
|
1
|
+
import { isValidEmail } from 'utils/isValidEmail';
|
|
2
|
+
import { AddressEmailError } from './errors/AddressEmailError';
|
|
6
3
|
const validateAddressEmail = (email) => {
|
|
7
|
-
if (!
|
|
8
|
-
throw new
|
|
4
|
+
if (!isValidEmail(email)) {
|
|
5
|
+
throw new AddressEmailError(email);
|
|
9
6
|
}
|
|
10
7
|
};
|
|
11
|
-
|
|
8
|
+
export { validateAddressEmail, };
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.validateEventAttachmentUrl = void 0;
|
|
4
|
-
const isValidUrl_1 = require("utils/isValidUrl");
|
|
5
|
-
const EventAttachmentUrlError_1 = require("./errors/EventAttachmentUrlError");
|
|
1
|
+
import { isValidUrl } from 'utils/isValidUrl';
|
|
2
|
+
import { EventAttachmentUrlError } from './errors/EventAttachmentUrlError';
|
|
6
3
|
const validateEventAttachmentUrl = (url) => {
|
|
7
|
-
if (!
|
|
8
|
-
throw new
|
|
4
|
+
if (!isValidUrl(url)) {
|
|
5
|
+
throw new EventAttachmentUrlError(url);
|
|
9
6
|
}
|
|
10
7
|
};
|
|
11
|
-
|
|
8
|
+
export { validateEventAttachmentUrl, };
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.validateEventGeolocation = void 0;
|
|
4
|
-
const isValidGeolocation_1 = require("utils/isValidGeolocation");
|
|
5
|
-
const EventGeolocationError_1 = require("./errors/EventGeolocationError");
|
|
1
|
+
import { isValidGeolocation } from 'utils/isValidGeolocation';
|
|
2
|
+
import { EventGeolocationError } from './errors/EventGeolocationError';
|
|
6
3
|
const validateEventGeolocation = (latitude, longitude) => {
|
|
7
|
-
if (!
|
|
8
|
-
throw new
|
|
4
|
+
if (!isValidGeolocation(latitude, longitude)) {
|
|
5
|
+
throw new EventGeolocationError(latitude, longitude);
|
|
9
6
|
}
|
|
10
7
|
};
|
|
11
|
-
|
|
8
|
+
export { validateEventGeolocation, };
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.validateEventUrl = void 0;
|
|
4
|
-
const isValidUrl_1 = require("utils/isValidUrl");
|
|
5
|
-
const EventUrlError_1 = require("./errors/EventUrlError");
|
|
1
|
+
import { isValidUrl } from 'utils/isValidUrl';
|
|
2
|
+
import { EventUrlError } from './errors/EventUrlError';
|
|
6
3
|
const validateEventUrl = (url) => {
|
|
7
|
-
if (!
|
|
8
|
-
throw new
|
|
4
|
+
if (!isValidUrl(url)) {
|
|
5
|
+
throw new EventUrlError(url);
|
|
9
6
|
}
|
|
10
7
|
};
|
|
11
|
-
|
|
8
|
+
export { validateEventUrl, };
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.validateListUrl = void 0;
|
|
4
|
-
const isValidUrl_1 = require("utils/isValidUrl");
|
|
5
|
-
const ListUrlError_1 = require("./errors/ListUrlError");
|
|
1
|
+
import { isValidUrl } from 'utils/isValidUrl';
|
|
2
|
+
import { ListUrlError } from './errors/ListUrlError';
|
|
6
3
|
const validateListUrl = (property, url) => {
|
|
7
|
-
if (!
|
|
8
|
-
throw new
|
|
4
|
+
if (!isValidUrl(url)) {
|
|
5
|
+
throw new ListUrlError(property, url);
|
|
9
6
|
}
|
|
10
7
|
};
|
|
11
|
-
|
|
8
|
+
export { validateListUrl, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apeframework",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.21",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Matthieu Symoens",
|
|
6
6
|
"description": "Node.js app framework",
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
"publishConfig": {
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
|
-
"
|
|
20
|
-
"types": "index.d.ts",
|
|
19
|
+
"type": "module",
|
|
21
20
|
"engines": {
|
|
22
21
|
"node": "^22"
|
|
23
22
|
},
|
|
@@ -48,7 +47,6 @@
|
|
|
48
47
|
},
|
|
49
48
|
"peerDependencies": {
|
|
50
49
|
"@types/node": "^22.10",
|
|
51
|
-
"ts-node": "^10.9",
|
|
52
50
|
"typescript": "^5.7"
|
|
53
51
|
}
|
|
54
52
|
}
|
package/parser/Parser.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ParseError = void 0;
|
|
4
|
-
const BaseError_1 = require("../../error/BaseError");
|
|
5
|
-
class ParseError extends BaseError_1.BaseError {
|
|
1
|
+
import { BaseError } from '../../error/BaseError';
|
|
2
|
+
class ParseError extends BaseError {
|
|
6
3
|
constructor(type) {
|
|
7
4
|
super(`failed parsing ${type}`);
|
|
8
5
|
}
|
|
9
6
|
}
|
|
10
|
-
|
|
7
|
+
export { ParseError, };
|