pp-command-bus 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +522 -0
- package/dist/command-bus/command-bus.spec.d.ts +1 -0
- package/dist/command-bus/command-bus.spec.js +398 -0
- package/dist/command-bus/command-bus.spec.js.map +1 -0
- package/dist/command-bus/command.d.ts +24 -0
- package/dist/command-bus/command.js +53 -0
- package/dist/command-bus/command.js.map +1 -0
- package/dist/command-bus/config/command-bus-config.d.ts +40 -0
- package/dist/command-bus/config/command-bus-config.js +59 -0
- package/dist/command-bus/config/command-bus-config.js.map +1 -0
- package/dist/command-bus/config/command-bus-config.spec.d.ts +1 -0
- package/dist/command-bus/config/command-bus-config.spec.js +162 -0
- package/dist/command-bus/config/command-bus-config.spec.js.map +1 -0
- package/dist/command-bus/config/index.d.ts +1 -0
- package/dist/command-bus/config/index.js +9 -0
- package/dist/command-bus/config/index.js.map +1 -0
- package/dist/command-bus/index.d.ts +79 -0
- package/dist/command-bus/index.js +169 -0
- package/dist/command-bus/index.js.map +1 -0
- package/dist/command-bus/job/index.d.ts +6 -0
- package/dist/command-bus/job/index.js +15 -0
- package/dist/command-bus/job/index.js.map +1 -0
- package/dist/command-bus/job/job-options-builder.d.ts +24 -0
- package/dist/command-bus/job/job-options-builder.js +68 -0
- package/dist/command-bus/job/job-options-builder.js.map +1 -0
- package/dist/command-bus/job/job-options-builder.spec.d.ts +1 -0
- package/dist/command-bus/job/job-options-builder.spec.js +163 -0
- package/dist/command-bus/job/job-options-builder.spec.js.map +1 -0
- package/dist/command-bus/job/job-processor.d.ts +33 -0
- package/dist/command-bus/job/job-processor.js +195 -0
- package/dist/command-bus/job/job-processor.js.map +1 -0
- package/dist/command-bus/job/job-processor.spec.d.ts +1 -0
- package/dist/command-bus/job/job-processor.spec.js +352 -0
- package/dist/command-bus/job/job-processor.spec.js.map +1 -0
- package/dist/command-bus/logging/command-logger.d.ts +21 -0
- package/dist/command-bus/logging/command-logger.js +79 -0
- package/dist/command-bus/logging/command-logger.js.map +1 -0
- package/dist/command-bus/logging/command-logger.spec.d.ts +1 -0
- package/dist/command-bus/logging/command-logger.spec.js +245 -0
- package/dist/command-bus/logging/command-logger.spec.js.map +1 -0
- package/dist/command-bus/logging/index.d.ts +5 -0
- package/dist/command-bus/logging/index.js +13 -0
- package/dist/command-bus/logging/index.js.map +1 -0
- package/dist/command-bus/queue/index.d.ts +5 -0
- package/dist/command-bus/queue/index.js +13 -0
- package/dist/command-bus/queue/index.js.map +1 -0
- package/dist/command-bus/queue/queue-manager.d.ts +24 -0
- package/dist/command-bus/queue/queue-manager.js +60 -0
- package/dist/command-bus/queue/queue-manager.js.map +1 -0
- package/dist/command-bus/queue/queue-manager.spec.d.ts +1 -0
- package/dist/command-bus/queue/queue-manager.spec.js +219 -0
- package/dist/command-bus/queue/queue-manager.spec.js.map +1 -0
- package/dist/command-bus/rpc/index.d.ts +5 -0
- package/dist/command-bus/rpc/index.js +13 -0
- package/dist/command-bus/rpc/index.js.map +1 -0
- package/dist/command-bus/rpc/rpc-coordinator.d.ts +45 -0
- package/dist/command-bus/rpc/rpc-coordinator.js +189 -0
- package/dist/command-bus/rpc/rpc-coordinator.js.map +1 -0
- package/dist/command-bus/rpc/rpc-coordinator.spec.d.ts +1 -0
- package/dist/command-bus/rpc/rpc-coordinator.spec.js +286 -0
- package/dist/command-bus/rpc/rpc-coordinator.spec.js.map +1 -0
- package/dist/command-bus/types/index.d.ts +57 -0
- package/dist/command-bus/types/index.js +3 -0
- package/dist/command-bus/types/index.js.map +1 -0
- package/dist/command-bus/worker/index.d.ts +5 -0
- package/dist/command-bus/worker/index.js +13 -0
- package/dist/command-bus/worker/index.js.map +1 -0
- package/dist/command-bus/worker/worker-orchestrator.d.ts +46 -0
- package/dist/command-bus/worker/worker-orchestrator.js +160 -0
- package/dist/command-bus/worker/worker-orchestrator.js.map +1 -0
- package/dist/command-bus/worker/worker-orchestrator.spec.d.ts +1 -0
- package/dist/command-bus/worker/worker-orchestrator.spec.js +293 -0
- package/dist/command-bus/worker/worker-orchestrator.spec.js.map +1 -0
- package/dist/examples/rpc.demo.d.ts +2 -0
- package/dist/examples/rpc.demo.js +235 -0
- package/dist/examples/rpc.demo.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/pp-command-bus-1.0.0.tgz +0 -0
- package/dist/shared/config/base-config.d.ts +43 -0
- package/dist/shared/config/base-config.js +100 -0
- package/dist/shared/config/base-config.js.map +1 -0
- package/dist/shared/config/base-config.spec.d.ts +1 -0
- package/dist/shared/config/base-config.spec.js +118 -0
- package/dist/shared/config/base-config.spec.js.map +1 -0
- package/dist/shared/config/index.d.ts +1 -0
- package/dist/shared/config/index.js +9 -0
- package/dist/shared/config/index.js.map +1 -0
- package/dist/shared/logging/index.d.ts +2 -0
- package/dist/shared/logging/index.js +8 -0
- package/dist/shared/logging/index.js.map +1 -0
- package/dist/shared/logging/log-level.d.ts +36 -0
- package/dist/shared/logging/log-level.js +53 -0
- package/dist/shared/logging/log-level.js.map +1 -0
- package/dist/shared/logging/logger.d.ts +42 -0
- package/dist/shared/logging/logger.js +63 -0
- package/dist/shared/logging/logger.js.map +1 -0
- package/dist/shared/logging/logger.spec.d.ts +1 -0
- package/dist/shared/logging/logger.spec.js +89 -0
- package/dist/shared/logging/logger.spec.js.map +1 -0
- package/dist/shared/types.d.ts +26 -0
- package/dist/shared/types.js +6 -0
- package/dist/shared/types.js.map +1 -0
- package/package.json +93 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogLevel = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Poziomy logowania dla wbudowanego loggera
|
|
6
|
+
*/
|
|
7
|
+
class LogLevel {
|
|
8
|
+
constructor(name, value) {
|
|
9
|
+
this.name = name;
|
|
10
|
+
this.value = value;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Sprawdza czy dany poziom jest aktywny przy obecnym poziomie logowania
|
|
14
|
+
*/
|
|
15
|
+
isActive(currentLevel) {
|
|
16
|
+
return this.value >= currentLevel.value;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Konwertuje string na LogLevel
|
|
20
|
+
*/
|
|
21
|
+
static fromString(level) {
|
|
22
|
+
switch (level.toLowerCase()) {
|
|
23
|
+
case 'debug':
|
|
24
|
+
return LogLevel.DEBUG;
|
|
25
|
+
case 'log':
|
|
26
|
+
return LogLevel.LOG;
|
|
27
|
+
case 'warn':
|
|
28
|
+
return LogLevel.WARN;
|
|
29
|
+
case 'error':
|
|
30
|
+
return LogLevel.ERROR;
|
|
31
|
+
default:
|
|
32
|
+
return LogLevel.LOG; // domyślnie LOG
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.LogLevel = LogLevel;
|
|
37
|
+
/**
|
|
38
|
+
* DEBUG - najniższy poziom, szczegółowe informacje diagnostyczne
|
|
39
|
+
*/
|
|
40
|
+
LogLevel.DEBUG = new LogLevel('debug', 0);
|
|
41
|
+
/**
|
|
42
|
+
* LOG - standardowe logi informacyjne
|
|
43
|
+
*/
|
|
44
|
+
LogLevel.LOG = new LogLevel('log', 1);
|
|
45
|
+
/**
|
|
46
|
+
* WARN - ostrzeżenia, potencjalne problemy
|
|
47
|
+
*/
|
|
48
|
+
LogLevel.WARN = new LogLevel('warn', 2);
|
|
49
|
+
/**
|
|
50
|
+
* ERROR - błędy wymagające uwagi
|
|
51
|
+
*/
|
|
52
|
+
LogLevel.ERROR = new LogLevel('error', 3);
|
|
53
|
+
//# sourceMappingURL=log-level.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-level.js","sourceRoot":"","sources":["../../../src/shared/logging/log-level.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,QAAQ;IAqBnB,YACkB,IAAY,EACZ,KAAa;QADb,SAAI,GAAJ,IAAI,CAAQ;QACZ,UAAK,GAAL,KAAK,CAAQ;IAC5B,CAAC;IAEJ;;OAEG;IACH,QAAQ,CAAC,YAAsB;QAC7B,OAAO,IAAI,CAAC,KAAK,IAAI,YAAY,CAAC,KAAK,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,KAAa;QAC7B,QAAQ,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YAC5B,KAAK,OAAO;gBACV,OAAO,QAAQ,CAAC,KAAK,CAAC;YACxB,KAAK,KAAK;gBACR,OAAO,QAAQ,CAAC,GAAG,CAAC;YACtB,KAAK,MAAM;gBACT,OAAO,QAAQ,CAAC,IAAI,CAAC;YACvB,KAAK,OAAO;gBACV,OAAO,QAAQ,CAAC,KAAK,CAAC;YACxB;gBACE,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,gBAAgB;QACzC,CAAC;IACH,CAAC;;AAjDH,4BAkDC;AAjDC;;GAEG;AACa,cAAK,GAAG,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAEjD;;GAEG;AACa,YAAG,GAAG,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;AAE7C;;GAEG;AACa,aAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAE/C;;GAEG;AACa,cAAK,GAAG,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ILogger } from '../types';
|
|
2
|
+
import { type LogLevelType } from './log-level';
|
|
3
|
+
/**
|
|
4
|
+
* Wbudowany logger z obsługą poziomów logowania.
|
|
5
|
+
*
|
|
6
|
+
* Logger filtruje wiadomości na podstawie skonfigurowanego poziomu.
|
|
7
|
+
* Domyślny poziom 'log' oznacza że logowane są: log, warn, error (bez debug).
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const logger = new Logger(console, 'log');
|
|
12
|
+
* logger.debug('To nie zostanie wylogowane');
|
|
13
|
+
* logger.log('To zostanie wylogowane');
|
|
14
|
+
* logger.warn('To zostanie wylogowane');
|
|
15
|
+
* logger.error('To zostanie wylogowane');
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare class Logger implements ILogger {
|
|
19
|
+
private readonly implementation;
|
|
20
|
+
private readonly level;
|
|
21
|
+
/**
|
|
22
|
+
* @param implementation - Implementacja loggera (np. console)
|
|
23
|
+
* @param logLevel - Poziom logowania (domyślnie 'log')
|
|
24
|
+
*/
|
|
25
|
+
constructor(implementation: ILogger, logLevel?: LogLevelType);
|
|
26
|
+
/**
|
|
27
|
+
* Loguje wiadomość na poziomie DEBUG
|
|
28
|
+
*/
|
|
29
|
+
debug(message: string, ...args: unknown[]): void;
|
|
30
|
+
/**
|
|
31
|
+
* Loguje wiadomość na poziomie LOG (informacyjnym)
|
|
32
|
+
*/
|
|
33
|
+
log(message: string, ...args: unknown[]): void;
|
|
34
|
+
/**
|
|
35
|
+
* Loguje ostrzeżenie na poziomie WARN
|
|
36
|
+
*/
|
|
37
|
+
warn(message: string, ...args: unknown[]): void;
|
|
38
|
+
/**
|
|
39
|
+
* Loguje błąd na poziomie ERROR
|
|
40
|
+
*/
|
|
41
|
+
error(message: string, ...args: unknown[]): void;
|
|
42
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Logger = void 0;
|
|
4
|
+
const log_level_1 = require("./log-level");
|
|
5
|
+
/**
|
|
6
|
+
* Wbudowany logger z obsługą poziomów logowania.
|
|
7
|
+
*
|
|
8
|
+
* Logger filtruje wiadomości na podstawie skonfigurowanego poziomu.
|
|
9
|
+
* Domyślny poziom 'log' oznacza że logowane są: log, warn, error (bez debug).
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const logger = new Logger(console, 'log');
|
|
14
|
+
* logger.debug('To nie zostanie wylogowane');
|
|
15
|
+
* logger.log('To zostanie wylogowane');
|
|
16
|
+
* logger.warn('To zostanie wylogowane');
|
|
17
|
+
* logger.error('To zostanie wylogowane');
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
class Logger {
|
|
21
|
+
/**
|
|
22
|
+
* @param implementation - Implementacja loggera (np. console)
|
|
23
|
+
* @param logLevel - Poziom logowania (domyślnie 'log')
|
|
24
|
+
*/
|
|
25
|
+
constructor(implementation, logLevel = 'log') {
|
|
26
|
+
this.implementation = implementation;
|
|
27
|
+
this.level = log_level_1.LogLevel.fromString(logLevel);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Loguje wiadomość na poziomie DEBUG
|
|
31
|
+
*/
|
|
32
|
+
debug(message, ...args) {
|
|
33
|
+
if (log_level_1.LogLevel.DEBUG.isActive(this.level)) {
|
|
34
|
+
this.implementation.debug(message, ...args);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Loguje wiadomość na poziomie LOG (informacyjnym)
|
|
39
|
+
*/
|
|
40
|
+
log(message, ...args) {
|
|
41
|
+
if (log_level_1.LogLevel.LOG.isActive(this.level)) {
|
|
42
|
+
this.implementation.log(message, ...args);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Loguje ostrzeżenie na poziomie WARN
|
|
47
|
+
*/
|
|
48
|
+
warn(message, ...args) {
|
|
49
|
+
if (log_level_1.LogLevel.WARN.isActive(this.level)) {
|
|
50
|
+
this.implementation.warn(message, ...args);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Loguje błąd na poziomie ERROR
|
|
55
|
+
*/
|
|
56
|
+
error(message, ...args) {
|
|
57
|
+
if (log_level_1.LogLevel.ERROR.isActive(this.level)) {
|
|
58
|
+
this.implementation.error(message, ...args);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.Logger = Logger;
|
|
63
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/shared/logging/logger.ts"],"names":[],"mappings":";;;AACA,2CAA0D;AAE1D;;;;;;;;;;;;;;GAcG;AACH,MAAa,MAAM;IAGjB;;;OAGG;IACH,YACmB,cAAuB,EACxC,WAAyB,KAAK;QADb,mBAAc,GAAd,cAAc,CAAS;QAGxC,IAAI,CAAC,KAAK,GAAG,oBAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAe,EAAE,GAAG,IAAe;QACvC,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACxC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,OAAe,EAAE,GAAG,IAAe;QACrC,IAAI,oBAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACtC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,OAAe,EAAE,GAAG,IAAe;QACtC,IAAI,oBAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACvC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAe,EAAE,GAAG,IAAe;QACvC,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACxC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;CACF;AAjDD,wBAiDC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const logger_1 = require("./logger");
|
|
4
|
+
describe('Logger', () => {
|
|
5
|
+
let mockImplementation;
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
mockImplementation = {
|
|
8
|
+
debug: jest.fn(),
|
|
9
|
+
log: jest.fn(),
|
|
10
|
+
warn: jest.fn(),
|
|
11
|
+
error: jest.fn(),
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
describe('poziom logowania DEBUG', () => {
|
|
15
|
+
it('powinien logować wszystkie poziomy', () => {
|
|
16
|
+
const logger = new logger_1.Logger(mockImplementation, 'debug');
|
|
17
|
+
logger.debug('debug message');
|
|
18
|
+
logger.log('log message');
|
|
19
|
+
logger.warn('warn message');
|
|
20
|
+
logger.error('error message');
|
|
21
|
+
expect(mockImplementation.debug).toHaveBeenCalledWith('debug message');
|
|
22
|
+
expect(mockImplementation.log).toHaveBeenCalledWith('log message');
|
|
23
|
+
expect(mockImplementation.warn).toHaveBeenCalledWith('warn message');
|
|
24
|
+
expect(mockImplementation.error).toHaveBeenCalledWith('error message');
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe('poziom logowania LOG (domyślny)', () => {
|
|
28
|
+
it('powinien logować log, warn i error (bez debug)', () => {
|
|
29
|
+
const logger = new logger_1.Logger(mockImplementation, 'log');
|
|
30
|
+
logger.debug('debug message');
|
|
31
|
+
logger.log('log message');
|
|
32
|
+
logger.warn('warn message');
|
|
33
|
+
logger.error('error message');
|
|
34
|
+
expect(mockImplementation.debug).not.toHaveBeenCalled();
|
|
35
|
+
expect(mockImplementation.log).toHaveBeenCalledWith('log message');
|
|
36
|
+
expect(mockImplementation.warn).toHaveBeenCalledWith('warn message');
|
|
37
|
+
expect(mockImplementation.error).toHaveBeenCalledWith('error message');
|
|
38
|
+
});
|
|
39
|
+
it('powinien używać poziomu LOG jako domyślnego', () => {
|
|
40
|
+
const logger = new logger_1.Logger(mockImplementation);
|
|
41
|
+
logger.debug('debug message');
|
|
42
|
+
logger.log('log message');
|
|
43
|
+
expect(mockImplementation.debug).not.toHaveBeenCalled();
|
|
44
|
+
expect(mockImplementation.log).toHaveBeenCalledWith('log message');
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
describe('poziom logowania WARN', () => {
|
|
48
|
+
it('powinien logować warn i error (bez debug i log)', () => {
|
|
49
|
+
const logger = new logger_1.Logger(mockImplementation, 'warn');
|
|
50
|
+
logger.debug('debug message');
|
|
51
|
+
logger.log('log message');
|
|
52
|
+
logger.warn('warn message');
|
|
53
|
+
logger.error('error message');
|
|
54
|
+
expect(mockImplementation.debug).not.toHaveBeenCalled();
|
|
55
|
+
expect(mockImplementation.log).not.toHaveBeenCalled();
|
|
56
|
+
expect(mockImplementation.warn).toHaveBeenCalledWith('warn message');
|
|
57
|
+
expect(mockImplementation.error).toHaveBeenCalledWith('error message');
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
describe('poziom logowania ERROR', () => {
|
|
61
|
+
it('powinien logować tylko error', () => {
|
|
62
|
+
const logger = new logger_1.Logger(mockImplementation, 'error');
|
|
63
|
+
logger.debug('debug message');
|
|
64
|
+
logger.log('log message');
|
|
65
|
+
logger.warn('warn message');
|
|
66
|
+
logger.error('error message');
|
|
67
|
+
expect(mockImplementation.debug).not.toHaveBeenCalled();
|
|
68
|
+
expect(mockImplementation.log).not.toHaveBeenCalled();
|
|
69
|
+
expect(mockImplementation.warn).not.toHaveBeenCalled();
|
|
70
|
+
expect(mockImplementation.error).toHaveBeenCalledWith('error message');
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
describe('przekazywanie dodatkowych argumentów', () => {
|
|
74
|
+
it('powinien przekazywać wszystkie argumenty do implementacji', () => {
|
|
75
|
+
const logger = new logger_1.Logger(mockImplementation, 'log');
|
|
76
|
+
const metadata = { userId: '123', timestamp: Date.now() };
|
|
77
|
+
logger.log('message with metadata', metadata);
|
|
78
|
+
expect(mockImplementation.log).toHaveBeenCalledWith('message with metadata', metadata);
|
|
79
|
+
});
|
|
80
|
+
it('powinien przekazywać wiele argumentów', () => {
|
|
81
|
+
const logger = new logger_1.Logger(mockImplementation, 'error');
|
|
82
|
+
logger.error('error message', 'arg1', 'arg2', { key: 'value' });
|
|
83
|
+
expect(mockImplementation.error).toHaveBeenCalledWith('error message', 'arg1', 'arg2', {
|
|
84
|
+
key: 'value',
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
//# sourceMappingURL=logger.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.spec.js","sourceRoot":"","sources":["../../../src/shared/logging/logger.spec.ts"],"names":[],"mappings":";;AAAA,qCAAkC;AAGlC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,IAAI,kBAA2B,CAAC;IAEhC,UAAU,CAAC,GAAG,EAAE;QACd,kBAAkB,GAAG;YACnB,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE;YAChB,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;YACd,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;YACf,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE;SACjB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;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,CAAC,CAAC;QACzF,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;YAC/C,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;YAEvD,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;YAEhE,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,oBAAoB,CAAC,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE;gBACrF,GAAG,EAAE,OAAO;aACb,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Współdzielone typy dla EventBus i CommandBus
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Typ dla funkcji synchronicznych
|
|
6
|
+
*/
|
|
7
|
+
export type TCallable<TArgs extends unknown[] = unknown[], TReturn = unknown> = (...args: TArgs) => TReturn;
|
|
8
|
+
/**
|
|
9
|
+
* Typ dla funkcji asynchronicznych
|
|
10
|
+
*/
|
|
11
|
+
export type TCallableAsync<TArgs extends unknown[] = unknown[], TReturn = unknown> = (...args: TArgs) => Promise<TReturn>;
|
|
12
|
+
/**
|
|
13
|
+
* Typ dla słownika/mapy obiektów
|
|
14
|
+
*/
|
|
15
|
+
export type TDict<T> = {
|
|
16
|
+
[key: string]: T;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Typ dla loggera - minimalny zestaw wymaganych metod
|
|
20
|
+
*/
|
|
21
|
+
export interface ILogger {
|
|
22
|
+
log: (message: string, ...args: unknown[]) => void;
|
|
23
|
+
error: (message: string, ...args: unknown[]) => void;
|
|
24
|
+
warn: (message: string, ...args: unknown[]) => void;
|
|
25
|
+
debug: (message: string, ...args: unknown[]) => void;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pp-command-bus",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Distributed Command Bus library supporting RPC and job queuing with BullMQ for Redis/DragonflyDB",
|
|
5
|
+
"homepage": "https://gitlab.polskiepolisy.pl/lib/pp-command-bus",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://gitlab.polskiepolisy.pl/lib/pp-command-bus.git"
|
|
9
|
+
},
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://gitlab.polskiepolisy.pl/lib/pp-command-bus/issues"
|
|
12
|
+
},
|
|
13
|
+
"main": "dist/index.js",
|
|
14
|
+
"types": "dist/index.d.ts",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"prepare": "husky",
|
|
17
|
+
"lint": "eslint src --ext .ts",
|
|
18
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
19
|
+
"format": "prettier --write \"src/**/*.{ts,js,json}\"",
|
|
20
|
+
"format:check": "prettier --check \"src/**/*.{ts,js,json}\"",
|
|
21
|
+
"test": "jest",
|
|
22
|
+
"test:coverage": "jest --coverage",
|
|
23
|
+
"build": "tsc --build",
|
|
24
|
+
"semantic-release": "semantic-release",
|
|
25
|
+
"semantic-release:dry-run": "semantic-release --dry-run",
|
|
26
|
+
"demo:rpc": "node ./dist/examples/rpc.demo.js"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"command-bus",
|
|
30
|
+
"cqrs",
|
|
31
|
+
"rpc",
|
|
32
|
+
"bullmq",
|
|
33
|
+
"dragonfly",
|
|
34
|
+
"redis",
|
|
35
|
+
"distributed",
|
|
36
|
+
"typescript",
|
|
37
|
+
"job-queue"
|
|
38
|
+
],
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"README.md",
|
|
42
|
+
"LICENSE"
|
|
43
|
+
],
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public",
|
|
46
|
+
"registry": "https://registry.npmjs.org/"
|
|
47
|
+
},
|
|
48
|
+
"author": "Mariusz Lejkowski",
|
|
49
|
+
"maintainers": [
|
|
50
|
+
{
|
|
51
|
+
"name": "Mariusz Lejkowski",
|
|
52
|
+
"email": "m.lejkowski@polskiepolisy.pl"
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"license": "MIT",
|
|
56
|
+
"jest": {
|
|
57
|
+
"preset": "ts-jest",
|
|
58
|
+
"testEnvironment": "node",
|
|
59
|
+
"roots": [
|
|
60
|
+
"src"
|
|
61
|
+
],
|
|
62
|
+
"silent": false,
|
|
63
|
+
"verbose": false,
|
|
64
|
+
"testTimeout": 60000,
|
|
65
|
+
"setupFilesAfterEnv": [
|
|
66
|
+
"<rootDir>/jest.setup.js"
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@commitlint/cli": "^20.1.0",
|
|
71
|
+
"@commitlint/config-conventional": "^20.0.0",
|
|
72
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
73
|
+
"@semantic-release/git": "^10.0.1",
|
|
74
|
+
"@semantic-release/gitlab": "^13.2.9",
|
|
75
|
+
"@types/jest": "^30.0.0",
|
|
76
|
+
"@types/node": "^24.6.1",
|
|
77
|
+
"@typescript-eslint/eslint-plugin": "^8.45.0",
|
|
78
|
+
"@typescript-eslint/parser": "^8.45.0",
|
|
79
|
+
"eslint": "^9.36.0",
|
|
80
|
+
"eslint-config-prettier": "^10.1.8",
|
|
81
|
+
"husky": "^9.1.7",
|
|
82
|
+
"jest": "^30.2.0",
|
|
83
|
+
"prettier": "^3.6.2",
|
|
84
|
+
"semantic-release": "^24.2.9",
|
|
85
|
+
"ts-jest": "^29.4.4",
|
|
86
|
+
"ts-node": "^10.9.2",
|
|
87
|
+
"typescript": "^5.9.3"
|
|
88
|
+
},
|
|
89
|
+
"dependencies": {
|
|
90
|
+
"bullmq": "^5.59.0",
|
|
91
|
+
"ioredis": "^5.8.0"
|
|
92
|
+
}
|
|
93
|
+
}
|