apeframework 0.0.0-dev.3 → 0.0.0-dev.5
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/README.md +0 -14
- package/api/Api.d.ts +28 -0
- package/api/Api.js +72 -0
- package/api/Api.ts +104 -0
- package/api/Endpoint.d.ts +12 -0
- package/api/Endpoint.ts +16 -0
- package/api/ErrorHandler.d.ts +3 -0
- package/api/ErrorHandler.ts +11 -0
- package/api/Handler.d.ts +3 -0
- package/api/Handler.ts +10 -0
- package/api/Method.d.ts +8 -0
- package/api/Method.js +11 -0
- package/api/Method.ts +11 -0
- package/api/Schema.d.ts +9 -0
- package/api/Schema.ts +13 -0
- package/cipher/Cipher.js +2 -2
- package/cipher/Cipher.ts +2 -2
- package/cipher/errors/{CipherDecryptError.d.ts → DecryptError.d.ts} +2 -2
- package/cipher/errors/{CipherDecryptError.js → DecryptError.js} +3 -3
- package/cipher/errors/{CipherDecryptError.ts → DecryptError.ts} +2 -2
- package/cipher/errors/SecretLengthError.d.ts +5 -0
- package/{jwt/errors/JwtSecretLengthError.js → cipher/errors/SecretLengthError.js} +3 -3
- package/{jwt/errors/JwtSecretLengthError.ts → cipher/errors/SecretLengthError.ts} +2 -2
- package/cipher/validateSecretLength.js +2 -2
- package/cipher/validateSecretLength.ts +2 -2
- package/cli/utils/print.d.ts +2 -0
- package/cli/utils/{write.js → print.js} +3 -3
- package/cli/utils/print.ts +7 -0
- package/cli/utils/printLn.d.ts +2 -0
- package/cli/utils/{writeLn.js → printLn.js} +3 -3
- package/cli/utils/{writeLn.ts → printLn.ts} +2 -2
- package/{env/errors/EnvFileReadError.d.ts → config/errors/FileReadError.d.ts} +2 -2
- package/{tls/errors/TlsFileReadError.js → config/errors/FileReadError.js} +3 -3
- package/{env/errors/EnvFileReadError.ts → config/errors/FileReadError.ts} +2 -2
- package/config/errors/PropertyNameError.d.ts +5 -0
- package/config/errors/{ConfigPropertyNameError.js → PropertyNameError.js} +3 -3
- package/config/errors/{ConfigPropertyNameError.ts → PropertyNameError.ts} +2 -2
- package/config/errors/PropertyParseError.d.ts +5 -0
- package/config/errors/PropertyParseError.js +10 -0
- package/config/errors/PropertyParseError.ts +11 -0
- package/config/parseProperty.js +2 -2
- package/config/parseProperty.ts +2 -2
- package/config/readFile.js +4 -4
- package/config/readFile.ts +4 -4
- package/config/validatePropertyName.js +2 -2
- package/config/validatePropertyName.ts +2 -2
- package/{tls/errors/TlsFileReadError.d.ts → env/errors/FileReadError.d.ts} +2 -2
- package/env/errors/{EnvFileReadError.js → FileReadError.js} +3 -3
- package/{tls/errors/TlsFileReadError.ts → env/errors/FileReadError.ts} +2 -2
- package/env/readFile.js +3 -3
- package/env/readFile.ts +3 -3
- package/jwt/Jwt.d.ts +0 -6
- package/jwt/Jwt.js +8 -34
- package/jwt/Jwt.ts +8 -51
- package/jwt/Payload.d.ts +7 -3
- package/jwt/Payload.ts +7 -3
- package/jwt/errors/SecretLengthError.d.ts +5 -0
- package/{cipher/errors/CipherSecretLengthError.js → jwt/errors/SecretLengthError.js} +3 -3
- package/{cipher/errors/CipherSecretLengthError.ts → jwt/errors/SecretLengthError.ts} +2 -2
- package/jwt/validateSecretLength.js +2 -2
- package/jwt/validateSecretLength.ts +2 -2
- package/logger/Level.d.ts +7 -6
- package/logger/Level.js +7 -6
- package/logger/Level.ts +7 -6
- package/logger/Logger.d.ts +9 -9
- package/logger/Logger.js +4 -0
- package/logger/Logger.ts +15 -9
- package/logger/Severity.d.ts +6 -7
- package/logger/Severity.js +6 -7
- package/logger/Severity.ts +6 -7
- package/logger/adapters/file/FileLogger.d.ts +5 -5
- package/logger/adapters/file/FileLogger.js +17 -17
- package/logger/adapters/file/FileLogger.ts +19 -19
- package/logger/adapters/noop/NoopLogger.d.ts +2 -2
- package/logger/adapters/noop/NoopLogger.js +2 -1
- package/logger/adapters/noop/NoopLogger.ts +2 -2
- package/logger/adapters/stdio/StdioLogger.d.ts +5 -5
- package/logger/adapters/stdio/StdioLogger.js +19 -17
- package/logger/adapters/stdio/StdioLogger.ts +21 -19
- package/mailer/Event.d.ts +4 -4
- package/mailer/Event.ts +4 -4
- package/mailer/{EventLocation.d.ts → Location.d.ts} +2 -2
- package/mailer/Location.js +2 -0
- package/mailer/{EventLocation.ts → Location.ts} +2 -2
- package/mailer/Mailer.d.ts +5 -4
- package/mailer/Mailer.js +48 -0
- package/mailer/Mailer.ts +63 -4
- package/mailer/Method.d.ts +5 -0
- package/mailer/Method.js +8 -0
- package/mailer/{EventMethod.ts → Method.ts} +2 -2
- package/mailer/adapters/noop/NoopMailer.d.ts +3 -3
- package/mailer/adapters/noop/NoopMailer.js +3 -2
- package/mailer/adapters/noop/NoopMailer.ts +3 -3
- package/mailer/adapters/smtp/SmtpMailer.d.ts +3 -3
- package/mailer/adapters/smtp/SmtpMailer.js +4 -2
- package/mailer/adapters/smtp/SmtpMailer.ts +5 -3
- package/mailer/errors/AddressEmailError.d.ts +5 -0
- package/mailer/errors/{MailerAddressEmailError.js → AddressEmailError.js} +3 -3
- package/mailer/errors/{MailerAddressEmailError.ts → AddressEmailError.ts} +2 -2
- package/mailer/errors/EventAttachmentUrlError.d.ts +5 -0
- package/mailer/errors/{MailerEventAttachmentUrlError.js → EventAttachmentUrlError.js} +3 -3
- package/mailer/errors/{MailerEventAttachmentUrlError.ts → EventAttachmentUrlError.ts} +2 -2
- package/mailer/errors/{MailerEventGeolocationError.d.ts → EventGeolocationError.d.ts} +2 -2
- package/mailer/errors/{MailerEventGeolocationError.js → EventGeolocationError.js} +3 -3
- package/mailer/errors/{MailerEventGeolocationError.ts → EventGeolocationError.ts} +2 -2
- package/mailer/errors/EventUrlError.d.ts +5 -0
- package/mailer/errors/{MailerEventUrlError.js → EventUrlError.js} +3 -3
- package/mailer/errors/{MailerEventUrlError.ts → EventUrlError.ts} +2 -2
- package/mailer/errors/{MailerListUrlError.d.ts → ListUrlError.d.ts} +2 -2
- package/mailer/errors/{MailerListUrlError.js → ListUrlError.js} +3 -3
- package/mailer/errors/{MailerListUrlError.ts → ListUrlError.ts} +2 -2
- package/mailer/validateAddressEmail.js +2 -2
- package/mailer/validateAddressEmail.ts +2 -2
- package/mailer/validateEventAttachmentUrl.js +2 -2
- package/mailer/validateEventAttachmentUrl.ts +2 -2
- package/mailer/validateEventGeolocation.js +2 -2
- package/mailer/validateEventGeolocation.ts +2 -2
- package/mailer/validateEventUrl.js +2 -2
- package/mailer/validateEventUrl.ts +2 -2
- package/mailer/validateListUrl.js +2 -2
- package/mailer/validateListUrl.ts +2 -2
- package/package.json +1 -5
- package/parser/errors/{ParserInputError.d.ts → ParseError.d.ts} +2 -2
- package/parser/errors/ParseError.js +10 -0
- package/parser/errors/ParseError.ts +11 -0
- package/parser/factories/unit/createUnitParser.js +3 -3
- package/parser/factories/unit/createUnitParser.ts +3 -3
- package/parser/parseBoolean.js +2 -2
- package/parser/parseBoolean.ts +2 -2
- package/parser/parseInteger.js +3 -3
- package/parser/parseInteger.ts +3 -3
- package/parser/parseNumber.js +3 -3
- package/parser/parseNumber.ts +3 -3
- package/parser/parseString.js +2 -2
- package/parser/parseString.ts +2 -2
- package/pwd/errors/{PwdHashRoundsError.d.ts → HashRoundsError.d.ts} +2 -2
- package/pwd/errors/{PwdHashRoundsError.js → HashRoundsError.js} +3 -3
- package/pwd/errors/{PwdHashRoundsError.ts → HashRoundsError.ts} +2 -2
- package/pwd/validateHashRounds.js +2 -2
- package/pwd/validateHashRounds.ts +2 -2
- package/{config/errors/ConfigFileReadError.d.ts → tls/errors/FileReadError.d.ts} +2 -2
- package/{config/errors/ConfigFileReadError.js → tls/errors/FileReadError.js} +3 -3
- package/{config/errors/ConfigFileReadError.ts → tls/errors/FileReadError.ts} +2 -2
- package/tls/readFile.js +3 -3
- package/tls/readFile.ts +3 -3
- package/cipher/errors/CipherSecretLengthError.d.ts +0 -5
- package/cli/utils/write.d.ts +0 -2
- package/cli/utils/write.ts +0 -7
- package/cli/utils/writeLn.d.ts +0 -2
- package/config/errors/ConfigParseError.d.ts +0 -5
- package/config/errors/ConfigParseError.js +0 -10
- package/config/errors/ConfigParseError.ts +0 -11
- package/config/errors/ConfigPropertyNameError.d.ts +0 -5
- package/db/ColumnBuilder.d.ts +0 -13
- package/db/ColumnBuilder.js +0 -42
- package/db/ColumnBuilder.ts +0 -61
- package/db/Database.d.ts +0 -19
- package/db/Database.js +0 -49
- package/db/Database.ts +0 -74
- package/db/Driver.d.ts +0 -30
- package/db/Driver.ts +0 -33
- package/db/NullConstraint.d.ts +0 -2
- package/db/NullConstraint.ts +0 -5
- package/db/ReferentialAction.d.ts +0 -2
- package/db/ReferentialAction.ts +0 -5
- package/db/TableBuilder.d.ts +0 -49
- package/db/TableBuilder.js +0 -234
- package/db/TableBuilder.ts +0 -367
- package/db/adapters/mysql/createMysqlDatabase.d.ts +0 -12
- package/db/adapters/mysql/createMysqlDatabase.js +0 -32
- package/db/adapters/mysql/createMysqlDatabase.ts +0 -39
- package/db/adapters/mysql/driver.d.ts +0 -3
- package/db/adapters/mysql/driver.js +0 -43
- package/db/adapters/mysql/driver.ts +0 -45
- package/db/adapters/mysql/typeCast.d.ts +0 -2
- package/db/adapters/mysql/typeCast.js +0 -17
- package/db/adapters/mysql/typeCast.ts +0 -18
- package/db/adapters/postgres/driver.d.ts +0 -3
- package/db/adapters/postgres/driver.js +0 -43
- package/db/adapters/postgres/driver.ts +0 -45
- package/db/adapters/sqlite/driver.d.ts +0 -3
- package/db/adapters/sqlite/driver.js +0 -43
- package/db/adapters/sqlite/driver.ts +0 -45
- package/db/errors/DbColumnLengthError.d.ts +0 -5
- package/db/errors/DbColumnLengthError.js +0 -10
- package/db/errors/DbColumnLengthError.ts +0 -11
- package/db/errors/DbColumnMaxLengthError.d.ts +0 -5
- package/db/errors/DbColumnMaxLengthError.js +0 -10
- package/db/errors/DbColumnMaxLengthError.ts +0 -11
- package/db/errors/DbColumnPrecisionError.d.ts +0 -5
- package/db/errors/DbColumnPrecisionError.js +0 -10
- package/db/errors/DbColumnPrecisionError.ts +0 -11
- package/db/errors/DbColumnScaleError.d.ts +0 -5
- package/db/errors/DbColumnScaleError.js +0 -10
- package/db/errors/DbColumnScaleError.ts +0 -11
- package/db/getConstraintName.d.ts +0 -2
- package/db/getConstraintName.js +0 -15
- package/db/getConstraintName.ts +0 -18
- package/db/getReferentialActionSql.d.ts +0 -3
- package/db/getReferentialActionSql.js +0 -12
- package/db/getReferentialActionSql.ts +0 -17
- package/db/setNullConstraint.d.ts +0 -4
- package/db/setNullConstraint.js +0 -9
- package/db/setNullConstraint.ts +0 -15
- package/db/validateColumnLength.d.ts +0 -2
- package/db/validateColumnLength.js +0 -10
- package/db/validateColumnLength.ts +0 -11
- package/db/validateColumnMaxLength.d.ts +0 -2
- package/db/validateColumnMaxLength.js +0 -10
- package/db/validateColumnMaxLength.ts +0 -11
- package/db/validateColumnPrecision.d.ts +0 -2
- package/db/validateColumnPrecision.js +0 -14
- package/db/validateColumnPrecision.ts +0 -15
- package/jwt/errors/JwtSecretLengthError.d.ts +0 -5
- package/mailer/EventMethod.d.ts +0 -5
- package/mailer/EventMethod.js +0 -8
- package/mailer/errors/MailerAddressEmailError.d.ts +0 -5
- package/mailer/errors/MailerEventAttachmentUrlError.d.ts +0 -5
- package/mailer/errors/MailerEventUrlError.d.ts +0 -5
- package/parser/errors/ParserInputError.js +0 -10
- package/parser/errors/ParserInputError.ts +0 -11
- /package/{db/Driver.js → api/Endpoint.js} +0 -0
- /package/{db/NullConstraint.js → api/ErrorHandler.js} +0 -0
- /package/{db/ReferentialAction.js → api/Handler.js} +0 -0
- /package/{mailer/EventLocation.js → api/Schema.js} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
declare class FileLogger
|
|
1
|
+
import { Level } from '../../Level';
|
|
2
|
+
import { Logger } from '../../Logger';
|
|
3
|
+
declare class FileLogger extends Logger {
|
|
4
4
|
private readonly logger;
|
|
5
5
|
private readonly context;
|
|
6
6
|
constructor(params: {
|
|
7
7
|
path: string;
|
|
8
|
-
|
|
8
|
+
level?: Level;
|
|
9
9
|
context?: object;
|
|
10
10
|
});
|
|
11
11
|
trace(message: string, data?: unknown): void;
|
|
@@ -15,6 +15,6 @@ declare class FileLogger implements Logger {
|
|
|
15
15
|
error(message: string, data?: unknown): void;
|
|
16
16
|
fatal(message: string, data?: unknown): void;
|
|
17
17
|
close(): Promise<void>;
|
|
18
|
-
private
|
|
18
|
+
private getPayload;
|
|
19
19
|
}
|
|
20
20
|
export { FileLogger, };
|
|
@@ -5,49 +5,49 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.FileLogger = void 0;
|
|
7
7
|
const pino_1 = __importDefault(require("pino"));
|
|
8
|
-
const
|
|
8
|
+
const Level_1 = require("../../Level");
|
|
9
|
+
const Logger_1 = require("../../Logger");
|
|
9
10
|
const initFile_1 = require("./initFile");
|
|
10
|
-
class FileLogger {
|
|
11
|
+
class FileLogger extends Logger_1.Logger {
|
|
11
12
|
logger;
|
|
12
13
|
context;
|
|
13
14
|
constructor(params) {
|
|
15
|
+
super();
|
|
14
16
|
(0, initFile_1.initFile)(params.path);
|
|
15
17
|
const stream = pino_1.default.destination(params.path);
|
|
16
18
|
this.logger = (0, pino_1.default)({
|
|
17
|
-
enabled: params.
|
|
18
|
-
level: params.
|
|
19
|
+
enabled: params.level !== Level_1.Level.OFF,
|
|
20
|
+
level: params.level ?? Level_1.Level.INFO,
|
|
19
21
|
messageKey: 'message',
|
|
20
22
|
formatters: {
|
|
21
23
|
level(label, number) {
|
|
22
24
|
return {
|
|
23
|
-
level:
|
|
24
|
-
severity:
|
|
25
|
+
level: label,
|
|
26
|
+
severity: number,
|
|
25
27
|
};
|
|
26
28
|
},
|
|
27
|
-
bindings: () => {
|
|
28
|
-
return {};
|
|
29
|
-
},
|
|
29
|
+
bindings: () => { return {}; },
|
|
30
30
|
},
|
|
31
31
|
}, stream);
|
|
32
32
|
this.context = params.context;
|
|
33
33
|
}
|
|
34
34
|
trace(message, data) {
|
|
35
|
-
this.logger.trace(this.
|
|
35
|
+
this.logger.trace(this.getPayload(message, data));
|
|
36
36
|
}
|
|
37
37
|
debug(message, data) {
|
|
38
|
-
this.logger.debug(this.
|
|
38
|
+
this.logger.debug(this.getPayload(message, data));
|
|
39
39
|
}
|
|
40
40
|
info(message, data) {
|
|
41
|
-
this.logger.info(this.
|
|
41
|
+
this.logger.info(this.getPayload(message, data));
|
|
42
42
|
}
|
|
43
43
|
warn(message, data) {
|
|
44
|
-
this.logger.warn(this.
|
|
44
|
+
this.logger.warn(this.getPayload(message, data));
|
|
45
45
|
}
|
|
46
46
|
error(message, data) {
|
|
47
|
-
this.logger.error(this.
|
|
47
|
+
this.logger.error(this.getPayload(message, data));
|
|
48
48
|
}
|
|
49
49
|
fatal(message, data) {
|
|
50
|
-
this.logger.fatal(this.
|
|
50
|
+
this.logger.fatal(this.getPayload(message, data));
|
|
51
51
|
}
|
|
52
52
|
async close() {
|
|
53
53
|
return new Promise((resolve, reject) => {
|
|
@@ -59,11 +59,11 @@ class FileLogger {
|
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
getPayload(message, data) {
|
|
63
63
|
return {
|
|
64
|
+
...this.context,
|
|
64
65
|
message,
|
|
65
66
|
data,
|
|
66
|
-
...this.context,
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
import pino from 'pino'
|
|
2
|
-
import {
|
|
2
|
+
import { Level } from '../../Level'
|
|
3
|
+
import { Logger } from '../../Logger'
|
|
3
4
|
import { initFile } from './initFile'
|
|
4
|
-
import type { Logger } from '../../Logger'
|
|
5
5
|
import type { Logger as PinoLogger } from 'pino'
|
|
6
6
|
|
|
7
|
-
class FileLogger
|
|
7
|
+
class FileLogger extends Logger {
|
|
8
8
|
private readonly logger: PinoLogger
|
|
9
9
|
|
|
10
10
|
private readonly context: object | undefined
|
|
11
11
|
|
|
12
12
|
public constructor(params: {
|
|
13
13
|
path: string,
|
|
14
|
-
|
|
14
|
+
level?: Level,
|
|
15
15
|
context?: object,
|
|
16
16
|
}) {
|
|
17
|
+
super()
|
|
18
|
+
|
|
17
19
|
initFile(params.path)
|
|
18
20
|
|
|
19
21
|
const stream = pino.destination(params.path)
|
|
20
22
|
|
|
21
23
|
this.logger = pino({
|
|
22
|
-
enabled: params.
|
|
23
|
-
level: params.
|
|
24
|
+
enabled: params.level !== Level.OFF,
|
|
25
|
+
level: params.level ?? Level.INFO,
|
|
24
26
|
messageKey: 'message',
|
|
25
27
|
formatters: {
|
|
26
28
|
level(label, number) {
|
|
27
29
|
return {
|
|
28
|
-
level:
|
|
29
|
-
severity:
|
|
30
|
+
level: label,
|
|
31
|
+
severity: number,
|
|
30
32
|
}
|
|
31
33
|
},
|
|
32
|
-
bindings: () => {
|
|
33
|
-
return {}
|
|
34
|
-
},
|
|
34
|
+
bindings: () => { return {} },
|
|
35
35
|
},
|
|
36
36
|
}, stream)
|
|
37
37
|
|
|
@@ -39,27 +39,27 @@ class FileLogger implements Logger {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
public trace(message: string, data?: unknown): void {
|
|
42
|
-
this.logger.trace(this.
|
|
42
|
+
this.logger.trace(this.getPayload(message, data))
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
public debug(message: string, data?: unknown): void {
|
|
46
|
-
this.logger.debug(this.
|
|
46
|
+
this.logger.debug(this.getPayload(message, data))
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
public info(message: string, data?: unknown): void {
|
|
50
|
-
this.logger.info(this.
|
|
50
|
+
this.logger.info(this.getPayload(message, data))
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
public warn(message: string, data?: unknown): void {
|
|
54
|
-
this.logger.warn(this.
|
|
54
|
+
this.logger.warn(this.getPayload(message, data))
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
public error(message: string, data?: unknown): void {
|
|
58
|
-
this.logger.error(this.
|
|
58
|
+
this.logger.error(this.getPayload(message, data))
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
public fatal(message: string, data?: unknown): void {
|
|
62
|
-
this.logger.fatal(this.
|
|
62
|
+
this.logger.fatal(this.getPayload(message, data))
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
public async close(): Promise<void> {
|
|
@@ -73,11 +73,11 @@ class FileLogger implements Logger {
|
|
|
73
73
|
})
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
private
|
|
76
|
+
private getPayload(message: string, data?: unknown): object {
|
|
77
77
|
return {
|
|
78
|
+
...this.context,
|
|
78
79
|
message,
|
|
79
80
|
data,
|
|
80
|
-
...this.context,
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
declare class StdioLogger
|
|
1
|
+
import { Level } from '../../Level';
|
|
2
|
+
import { Logger } from '../../Logger';
|
|
3
|
+
declare class StdioLogger extends Logger {
|
|
4
4
|
private readonly logger;
|
|
5
5
|
private readonly context;
|
|
6
6
|
constructor(params?: {
|
|
7
7
|
pretty?: boolean;
|
|
8
|
-
|
|
8
|
+
level?: Level;
|
|
9
9
|
context?: object;
|
|
10
10
|
});
|
|
11
11
|
trace(message: string, data?: unknown): void;
|
|
@@ -15,6 +15,6 @@ declare class StdioLogger implements Logger {
|
|
|
15
15
|
error(message: string, data?: unknown): void;
|
|
16
16
|
fatal(message: string, data?: unknown): void;
|
|
17
17
|
close(): Promise<void>;
|
|
18
|
-
private
|
|
18
|
+
private getPayload;
|
|
19
19
|
}
|
|
20
20
|
export { StdioLogger, };
|
|
@@ -6,49 +6,51 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.StdioLogger = void 0;
|
|
7
7
|
const pino_1 = __importDefault(require("pino"));
|
|
8
8
|
const pino_pretty_1 = __importDefault(require("pino-pretty"));
|
|
9
|
-
const
|
|
10
|
-
|
|
9
|
+
const Level_1 = require("../../Level");
|
|
10
|
+
const Logger_1 = require("../../Logger");
|
|
11
|
+
class StdioLogger extends Logger_1.Logger {
|
|
11
12
|
logger;
|
|
12
13
|
context;
|
|
13
14
|
constructor(params) {
|
|
15
|
+
super();
|
|
14
16
|
const stream = params?.pretty
|
|
15
17
|
? (0, pino_pretty_1.default)()
|
|
16
18
|
: pino_1.default.destination(process.stdout.fd);
|
|
17
19
|
this.logger = (0, pino_1.default)({
|
|
18
|
-
enabled: params?.
|
|
19
|
-
level: params?.
|
|
20
|
+
enabled: params?.level !== Level_1.Level.OFF,
|
|
21
|
+
level: params?.level ?? Level_1.Level.INFO,
|
|
20
22
|
messageKey: 'message',
|
|
21
23
|
formatters: {
|
|
22
24
|
level(label, number) {
|
|
23
25
|
return {
|
|
24
|
-
level:
|
|
25
|
-
...params?.pretty
|
|
26
|
+
level: label,
|
|
27
|
+
...params?.pretty
|
|
28
|
+
? {}
|
|
29
|
+
: { severity: number },
|
|
26
30
|
};
|
|
27
31
|
},
|
|
28
|
-
bindings: () => {
|
|
29
|
-
return {};
|
|
30
|
-
},
|
|
32
|
+
bindings: () => { return {}; },
|
|
31
33
|
},
|
|
32
34
|
}, stream);
|
|
33
35
|
this.context = params?.context;
|
|
34
36
|
}
|
|
35
37
|
trace(message, data) {
|
|
36
|
-
this.logger.trace(this.
|
|
38
|
+
this.logger.trace(this.getPayload(message, data));
|
|
37
39
|
}
|
|
38
40
|
debug(message, data) {
|
|
39
|
-
this.logger.debug(this.
|
|
41
|
+
this.logger.debug(this.getPayload(message, data));
|
|
40
42
|
}
|
|
41
43
|
info(message, data) {
|
|
42
|
-
this.logger.info(this.
|
|
44
|
+
this.logger.info(this.getPayload(message, data));
|
|
43
45
|
}
|
|
44
46
|
warn(message, data) {
|
|
45
|
-
this.logger.warn(this.
|
|
47
|
+
this.logger.warn(this.getPayload(message, data));
|
|
46
48
|
}
|
|
47
49
|
error(message, data) {
|
|
48
|
-
this.logger.error(this.
|
|
50
|
+
this.logger.error(this.getPayload(message, data));
|
|
49
51
|
}
|
|
50
52
|
fatal(message, data) {
|
|
51
|
-
this.logger.fatal(this.
|
|
53
|
+
this.logger.fatal(this.getPayload(message, data));
|
|
52
54
|
}
|
|
53
55
|
async close() {
|
|
54
56
|
return new Promise((resolve, reject) => {
|
|
@@ -60,11 +62,11 @@ class StdioLogger {
|
|
|
60
62
|
});
|
|
61
63
|
});
|
|
62
64
|
}
|
|
63
|
-
|
|
65
|
+
getPayload(message, data) {
|
|
64
66
|
return {
|
|
67
|
+
...this.context,
|
|
65
68
|
message,
|
|
66
69
|
data,
|
|
67
|
-
...this.context,
|
|
68
70
|
};
|
|
69
71
|
}
|
|
70
72
|
}
|
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
import pino from 'pino'
|
|
2
2
|
import pretty from 'pino-pretty'
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import { Level } from '../../Level'
|
|
4
|
+
import { Logger } from '../../Logger'
|
|
5
5
|
import type { Logger as PinoLogger } from 'pino'
|
|
6
6
|
|
|
7
|
-
class StdioLogger
|
|
7
|
+
class StdioLogger extends Logger {
|
|
8
8
|
private readonly logger: PinoLogger
|
|
9
9
|
|
|
10
10
|
private readonly context: object | undefined
|
|
11
11
|
|
|
12
12
|
public constructor(params?: {
|
|
13
13
|
pretty?: boolean,
|
|
14
|
-
|
|
14
|
+
level?: Level,
|
|
15
15
|
context?: object,
|
|
16
16
|
}) {
|
|
17
|
+
super()
|
|
18
|
+
|
|
17
19
|
const stream = params?.pretty
|
|
18
20
|
? pretty()
|
|
19
21
|
: pino.destination(process.stdout.fd)
|
|
20
22
|
|
|
21
23
|
this.logger = pino({
|
|
22
|
-
enabled: params?.
|
|
23
|
-
level: params?.
|
|
24
|
+
enabled: params?.level !== Level.OFF,
|
|
25
|
+
level: params?.level ?? Level.INFO,
|
|
24
26
|
messageKey: 'message',
|
|
25
27
|
formatters: {
|
|
26
28
|
level(label, number) {
|
|
27
29
|
return {
|
|
28
|
-
level:
|
|
29
|
-
...params?.pretty
|
|
30
|
+
level: label,
|
|
31
|
+
...params?.pretty
|
|
32
|
+
? {}
|
|
33
|
+
: { severity: number },
|
|
30
34
|
}
|
|
31
35
|
},
|
|
32
|
-
bindings: () => {
|
|
33
|
-
return {}
|
|
34
|
-
},
|
|
36
|
+
bindings: () => { return {} },
|
|
35
37
|
},
|
|
36
38
|
}, stream)
|
|
37
39
|
|
|
@@ -39,27 +41,27 @@ class StdioLogger implements Logger {
|
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
public trace(message: string, data?: unknown): void {
|
|
42
|
-
this.logger.trace(this.
|
|
44
|
+
this.logger.trace(this.getPayload(message, data))
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
public debug(message: string, data?: unknown): void {
|
|
46
|
-
this.logger.debug(this.
|
|
48
|
+
this.logger.debug(this.getPayload(message, data))
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
public info(message: string, data?: unknown): void {
|
|
50
|
-
this.logger.info(this.
|
|
52
|
+
this.logger.info(this.getPayload(message, data))
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
public warn(message: string, data?: unknown): void {
|
|
54
|
-
this.logger.warn(this.
|
|
56
|
+
this.logger.warn(this.getPayload(message, data))
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
public error(message: string, data?: unknown): void {
|
|
58
|
-
this.logger.error(this.
|
|
60
|
+
this.logger.error(this.getPayload(message, data))
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
public fatal(message: string, data?: unknown): void {
|
|
62
|
-
this.logger.fatal(this.
|
|
64
|
+
this.logger.fatal(this.getPayload(message, data))
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
public async close(): Promise<void> {
|
|
@@ -73,11 +75,11 @@ class StdioLogger implements Logger {
|
|
|
73
75
|
})
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
private
|
|
78
|
+
private getPayload(message: string, data?: unknown): object {
|
|
77
79
|
return {
|
|
80
|
+
...this.context,
|
|
78
81
|
message,
|
|
79
82
|
data,
|
|
80
|
-
...this.context,
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
85
|
}
|
package/mailer/Event.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Location } from './Location';
|
|
2
|
+
import type { Method } from './Method';
|
|
3
3
|
interface Event {
|
|
4
4
|
fileName?: string;
|
|
5
|
-
method:
|
|
5
|
+
method: Method;
|
|
6
6
|
id?: string;
|
|
7
7
|
start: Date;
|
|
8
8
|
end: Date;
|
|
@@ -10,7 +10,7 @@ interface Event {
|
|
|
10
10
|
name: string;
|
|
11
11
|
description?: string;
|
|
12
12
|
url?: string;
|
|
13
|
-
location?:
|
|
13
|
+
location?: Location;
|
|
14
14
|
attachments?: string[];
|
|
15
15
|
}
|
|
16
16
|
export { type Event, };
|
package/mailer/Event.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Location } from './Location'
|
|
2
|
+
import type { Method } from './Method'
|
|
3
3
|
|
|
4
4
|
interface Event {
|
|
5
5
|
fileName?: string,
|
|
6
|
-
method:
|
|
6
|
+
method: Method,
|
|
7
7
|
id?: string,
|
|
8
8
|
start: Date,
|
|
9
9
|
end: Date,
|
|
@@ -11,7 +11,7 @@ interface Event {
|
|
|
11
11
|
name: string,
|
|
12
12
|
description?: string,
|
|
13
13
|
url?: string,
|
|
14
|
-
location?:
|
|
14
|
+
location?: Location,
|
|
15
15
|
attachments?: string[],
|
|
16
16
|
}
|
|
17
17
|
|
package/mailer/Mailer.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Mail } from './Mail';
|
|
2
|
-
|
|
3
|
-
send
|
|
4
|
-
|
|
2
|
+
declare abstract class Mailer {
|
|
3
|
+
send(mail: Mail): Promise<string>;
|
|
4
|
+
abstract sendMail(mail: Mail): Promise<string>;
|
|
5
|
+
abstract close(): Promise<void>;
|
|
5
6
|
}
|
|
6
|
-
export {
|
|
7
|
+
export { Mailer, };
|
package/mailer/Mailer.js
CHANGED
|
@@ -1,2 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Mailer = void 0;
|
|
4
|
+
const validateAddressEmail_1 = require("./validateAddressEmail");
|
|
5
|
+
const validateEventAttachmentUrl_1 = require("./validateEventAttachmentUrl");
|
|
6
|
+
const validateEventGeolocation_1 = require("./validateEventGeolocation");
|
|
7
|
+
const validateEventUrl_1 = require("./validateEventUrl");
|
|
8
|
+
const validateListUrl_1 = require("./validateListUrl");
|
|
9
|
+
class Mailer {
|
|
10
|
+
async send(mail) {
|
|
11
|
+
(0, validateAddressEmail_1.validateAddressEmail)(mail.from.email);
|
|
12
|
+
if (mail.sender) {
|
|
13
|
+
(0, validateAddressEmail_1.validateAddressEmail)(mail.sender.email);
|
|
14
|
+
}
|
|
15
|
+
if (mail.replyTo) {
|
|
16
|
+
(0, validateAddressEmail_1.validateAddressEmail)(mail.replyTo.email);
|
|
17
|
+
}
|
|
18
|
+
mail.to.forEach((address) => {
|
|
19
|
+
(0, validateAddressEmail_1.validateAddressEmail)(address.email);
|
|
20
|
+
});
|
|
21
|
+
if (mail.cc) {
|
|
22
|
+
mail.cc.forEach((address) => {
|
|
23
|
+
(0, validateAddressEmail_1.validateAddressEmail)(address.email);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (mail.bcc) {
|
|
27
|
+
mail.bcc.forEach((address) => {
|
|
28
|
+
(0, validateAddressEmail_1.validateAddressEmail)(address.email);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (mail.event?.url) {
|
|
32
|
+
(0, validateEventUrl_1.validateEventUrl)(mail.event.url);
|
|
33
|
+
}
|
|
34
|
+
if (mail.event?.location?.geo) {
|
|
35
|
+
(0, validateEventGeolocation_1.validateEventGeolocation)(mail.event.location.geo.latitude, mail.event.location.geo.longitude);
|
|
36
|
+
}
|
|
37
|
+
if (mail.event?.attachments) {
|
|
38
|
+
mail.event.attachments.forEach((attachment) => {
|
|
39
|
+
(0, validateEventAttachmentUrl_1.validateEventAttachmentUrl)(attachment);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (mail.list) {
|
|
43
|
+
Object.entries(mail.list).forEach(([property, url]) => {
|
|
44
|
+
(0, validateListUrl_1.validateListUrl)(property, url);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return this.sendMail(mail);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.Mailer = Mailer;
|
package/mailer/Mailer.ts
CHANGED
|
@@ -1,10 +1,69 @@
|
|
|
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'
|
|
1
6
|
import type { Mail } from './Mail'
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
send
|
|
5
|
-
|
|
8
|
+
abstract class Mailer {
|
|
9
|
+
public async send(mail: Mail): Promise<string> {
|
|
10
|
+
validateAddressEmail(mail.from.email)
|
|
11
|
+
|
|
12
|
+
if (mail.sender) {
|
|
13
|
+
validateAddressEmail(mail.sender.email)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (mail.replyTo) {
|
|
17
|
+
validateAddressEmail(mail.replyTo.email)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
mail.to.forEach((address) => {
|
|
21
|
+
validateAddressEmail(address.email)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
if (mail.cc) {
|
|
25
|
+
mail.cc.forEach((address) => {
|
|
26
|
+
validateAddressEmail(address.email)
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (mail.bcc) {
|
|
31
|
+
mail.bcc.forEach((address) => {
|
|
32
|
+
validateAddressEmail(address.email)
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (mail.event?.url) {
|
|
37
|
+
validateEventUrl(mail.event.url)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (mail.event?.location?.geo) {
|
|
41
|
+
validateEventGeolocation(
|
|
42
|
+
mail.event.location.geo.latitude,
|
|
43
|
+
mail.event.location.geo.longitude,
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (mail.event?.attachments) {
|
|
48
|
+
mail.event.attachments.forEach((attachment) => {
|
|
49
|
+
validateEventAttachmentUrl(attachment)
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (mail.list) {
|
|
54
|
+
Object.entries(mail.list).forEach(([property, url]: [string, string]) => {
|
|
55
|
+
validateListUrl(property, url)
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return this.sendMail(mail)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public abstract sendMail(mail: Mail): Promise<string>
|
|
63
|
+
|
|
64
|
+
public abstract close(): Promise<void>
|
|
6
65
|
}
|
|
7
66
|
|
|
8
67
|
export {
|
|
9
|
-
|
|
68
|
+
Mailer,
|
|
10
69
|
}
|
package/mailer/Method.js
ADDED