@lambdaorm/base 3.5.0 → 3.7.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.
Files changed (86) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/package.json +2 -1
  3. package/query/domain/query.d.ts +3 -0
  4. package/query/domain/query.d.ts.map +1 -1
  5. package/schema/application/index.d.ts +3 -0
  6. package/schema/application/index.d.ts.map +1 -1
  7. package/schema/application/index.js +3 -0
  8. package/schema/application/index.js.map +1 -1
  9. package/schema/application/services/nodeCode.d.ts +28 -0
  10. package/schema/application/services/nodeCode.d.ts.map +1 -0
  11. package/schema/application/services/nodeCode.js +168 -0
  12. package/schema/application/services/nodeCode.js.map +1 -0
  13. package/schema/application/services/observabilityConfigService.d.ts +59 -0
  14. package/schema/application/services/observabilityConfigService.d.ts.map +1 -0
  15. package/schema/application/services/observabilityConfigService.js +120 -0
  16. package/schema/application/services/observabilityConfigService.js.map +1 -0
  17. package/schema/application/services/observabilityValidator.d.ts +36 -0
  18. package/schema/application/services/observabilityValidator.d.ts.map +1 -0
  19. package/schema/application/services/observabilityValidator.js +194 -0
  20. package/schema/application/services/observabilityValidator.js.map +1 -0
  21. package/schema/application/services/schemaService.d.ts.map +1 -1
  22. package/schema/application/services/schemaService.js +4 -1
  23. package/schema/application/services/schemaService.js.map +1 -1
  24. package/schema/application/useCases/load.d.ts +4 -1
  25. package/schema/application/useCases/load.d.ts.map +1 -1
  26. package/schema/application/useCases/load.js +15 -1
  27. package/schema/application/useCases/load.js.map +1 -1
  28. package/schema/domain/schema.d.ts +76 -0
  29. package/schema/domain/schema.d.ts.map +1 -1
  30. package/schema/infrastructure/stateBuilder.js +1 -1
  31. package/schema/infrastructure/stateBuilder.js.map +1 -1
  32. package/shared/domain/ports/logger.d.ts +60 -3
  33. package/shared/domain/ports/logger.d.ts.map +1 -1
  34. package/shared/domain/ports/logger.js +143 -7
  35. package/shared/domain/ports/logger.js.map +1 -1
  36. package/shared/domain/schemaChange.d.ts +57 -0
  37. package/shared/domain/schemaChange.d.ts.map +1 -0
  38. package/shared/domain/schemaChange.js +5 -0
  39. package/shared/domain/schemaChange.js.map +1 -0
  40. package/shared/index.d.ts +5 -1
  41. package/shared/index.d.ts.map +1 -1
  42. package/shared/index.js +5 -1
  43. package/shared/index.js.map +1 -1
  44. package/shared/infrastructure/consoleLogger.d.ts +3 -4
  45. package/shared/infrastructure/consoleLogger.d.ts.map +1 -1
  46. package/shared/infrastructure/consoleLogger.js +4 -19
  47. package/shared/infrastructure/consoleLogger.js.map +1 -1
  48. package/shared/infrastructure/helper.d.ts +1 -1
  49. package/shared/infrastructure/helper.d.ts.map +1 -1
  50. package/shared/infrastructure/helper.js.map +1 -1
  51. package/shared/infrastructure/logAdapters/compositeLogAdapter.d.ts +12 -0
  52. package/shared/infrastructure/logAdapters/compositeLogAdapter.d.ts.map +1 -0
  53. package/shared/infrastructure/logAdapters/compositeLogAdapter.js +32 -0
  54. package/shared/infrastructure/logAdapters/compositeLogAdapter.js.map +1 -0
  55. package/shared/infrastructure/logAdapters/consoleLogAdapter.d.ts +15 -0
  56. package/shared/infrastructure/logAdapters/consoleLogAdapter.d.ts.map +1 -0
  57. package/shared/infrastructure/logAdapters/consoleLogAdapter.js +22 -0
  58. package/shared/infrastructure/logAdapters/consoleLogAdapter.js.map +1 -0
  59. package/shared/infrastructure/logAdapters/fileLogAdapter.d.ts +31 -0
  60. package/shared/infrastructure/logAdapters/fileLogAdapter.d.ts.map +1 -0
  61. package/shared/infrastructure/logAdapters/fileLogAdapter.js +78 -0
  62. package/shared/infrastructure/logAdapters/fileLogAdapter.js.map +1 -0
  63. package/shared/infrastructure/logAdapters/index.d.ts +6 -0
  64. package/shared/infrastructure/logAdapters/index.d.ts.map +1 -0
  65. package/shared/infrastructure/logAdapters/index.js +22 -0
  66. package/shared/infrastructure/logAdapters/index.js.map +1 -0
  67. package/shared/infrastructure/logAdapters/openTelemetryLogAdapter.d.ts +22 -0
  68. package/shared/infrastructure/logAdapters/openTelemetryLogAdapter.d.ts.map +1 -0
  69. package/shared/infrastructure/logAdapters/openTelemetryLogAdapter.js +71 -0
  70. package/shared/infrastructure/logAdapters/openTelemetryLogAdapter.js.map +1 -0
  71. package/shared/infrastructure/logAdapters/winstonLogAdapter.d.ts +10 -0
  72. package/shared/infrastructure/logAdapters/winstonLogAdapter.d.ts.map +1 -0
  73. package/shared/infrastructure/logAdapters/winstonLogAdapter.js +37 -0
  74. package/shared/infrastructure/logAdapters/winstonLogAdapter.js.map +1 -0
  75. package/shared/infrastructure/loggerBuilder.d.ts +13 -1
  76. package/shared/infrastructure/loggerBuilder.d.ts.map +1 -1
  77. package/shared/infrastructure/loggerBuilder.js +39 -4
  78. package/shared/infrastructure/loggerBuilder.js.map +1 -1
  79. package/shared/infrastructure/ulid.d.ts +3 -0
  80. package/shared/infrastructure/ulid.d.ts.map +1 -0
  81. package/shared/infrastructure/ulid.js +29 -0
  82. package/shared/infrastructure/ulid.js.map +1 -0
  83. package/shared/infrastructure/winstonLogger.d.ts +3 -5
  84. package/shared/infrastructure/winstonLogger.d.ts.map +1 -1
  85. package/shared/infrastructure/winstonLogger.js +4 -35
  86. package/shared/infrastructure/winstonLogger.js.map +1 -1
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FileLogAdapter = exports.FILE_LOG_MAX_BYTES = void 0;
7
+ const fs_1 = require("fs");
8
+ const path_1 = __importDefault(require("path"));
9
+ exports.FILE_LOG_MAX_BYTES = 10 * 1024 * 1024;
10
+ /**
11
+ * JSON per line in a file. The writes are queued so they keep their order. With logs/changes.jsonl and the event
12
+ * schema.change it is the history of the schema.
13
+ */
14
+ class FileLogAdapter {
15
+ constructor(options) {
16
+ this.queue = Promise.resolve();
17
+ this.dirReady = false;
18
+ this.rotations = 0;
19
+ this.path = options.path;
20
+ this.events = options.events && options.events.length > 0 ? options.events : undefined;
21
+ this.maxBytes = options.maxBytes ?? exports.FILE_LOG_MAX_BYTES;
22
+ this.level = options.level;
23
+ }
24
+ write(record) {
25
+ if (this.events && (!record.event || !this.events.includes(record.event))) {
26
+ return Promise.resolve();
27
+ }
28
+ const line = JSON.stringify(record) + '\n';
29
+ const next = this.queue.then(() => this.append(line));
30
+ // the queue goes on even if a write fails; the caller gets the error
31
+ this.queue = next.catch(() => undefined);
32
+ return next;
33
+ }
34
+ flush() {
35
+ return this.queue;
36
+ }
37
+ close() {
38
+ return this.queue;
39
+ }
40
+ async append(line) {
41
+ if (!this.dirReady) {
42
+ await fs_1.promises.mkdir(path_1.default.dirname(this.path), { recursive: true });
43
+ this.dirReady = true;
44
+ }
45
+ await this.rotate(Buffer.byteLength(line));
46
+ await fs_1.promises.appendFile(this.path, line, 'utf8');
47
+ }
48
+ async rotate(bytes) {
49
+ if (this.maxBytes <= 0) {
50
+ return;
51
+ }
52
+ let size;
53
+ try {
54
+ size = (await fs_1.promises.stat(this.path)).size;
55
+ }
56
+ catch {
57
+ return;
58
+ }
59
+ if (size === 0 || size + bytes <= this.maxBytes) {
60
+ return;
61
+ }
62
+ const ext = path_1.default.extname(this.path);
63
+ // the date sorts them; the process and a counter keep two rotations of the same millisecond apart
64
+ const stamp = new Date().toISOString().replace(/[:.]/g, '-');
65
+ const rotated = path_1.default.join(path_1.default.dirname(this.path), `${path_1.default.basename(this.path, ext)}.${stamp}-${process.pid}-${++this.rotations}${ext}`);
66
+ try {
67
+ await fs_1.promises.rename(this.path, rotated);
68
+ }
69
+ catch (error) {
70
+ // another process rotated it first
71
+ if (error?.code !== 'ENOENT') {
72
+ throw error;
73
+ }
74
+ }
75
+ }
76
+ }
77
+ exports.FileLogAdapter = FileLogAdapter;
78
+ //# sourceMappingURL=fileLogAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileLogAdapter.js","sourceRoot":"","sources":["../../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5D,MAAM,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,cAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,KAAK,IAAI,OAAO,CAAC,GAAG,IAAI,EAAE,IAAI,CAAC,SAAS,GAAG,GAAG,EAAE,CAAC,CAAA;QACxI,IAAI,CAAC;YACJ,MAAM,aAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QACpC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACrB,mCAAmC;YACnC,IAAI,KAAK,EAAE,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC9B,MAAM,KAAK,CAAA;YACZ,CAAC;QACF,CAAC;IACF,CAAC;CACD;AAtED,wCAsEC"}
@@ -0,0 +1,6 @@
1
+ export * from './consoleLogAdapter';
2
+ export * from './compositeLogAdapter';
3
+ export * from './fileLogAdapter';
4
+ export * from './openTelemetryLogAdapter';
5
+ export * from './winstonLogAdapter';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/shared/infrastructure/logAdapters/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,2BAA2B,CAAA;AACzC,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./consoleLogAdapter"), exports);
18
+ __exportStar(require("./compositeLogAdapter"), exports);
19
+ __exportStar(require("./fileLogAdapter"), exports);
20
+ __exportStar(require("./openTelemetryLogAdapter"), exports);
21
+ __exportStar(require("./winstonLogAdapter"), exports);
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/shared/infrastructure/logAdapters/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAmC;AACnC,wDAAqC;AACrC,mDAAgC;AAChC,4DAAyC;AACzC,sDAAmC"}
@@ -0,0 +1,22 @@
1
+ import { LogAdapter, LogLevel, LogRecord } from '../../domain/ports/logger';
2
+ export interface OpenTelemetryLogAdapterOptions {
3
+ /** the instrumentation scope (default @lambdaorm/base) */
4
+ name?: string;
5
+ version?: string;
6
+ level?: LogLevel;
7
+ }
8
+ /**
9
+ * Each record as a LogRecord of OpenTelemetry, through the global LoggerProvider: without an SDK it does nothing.
10
+ * The active context goes with it, which links the log with its trace.
11
+ */
12
+ export declare class OpenTelemetryLogAdapter implements LogAdapter {
13
+ readonly level?: LogLevel;
14
+ private readonly name;
15
+ private readonly version?;
16
+ private logger?;
17
+ constructor(options?: OpenTelemetryLogAdapterOptions);
18
+ write(record: LogRecord): void;
19
+ /** primitives and lists of primitives go as they are; an object (a change's before, after or diff) goes as JSON */
20
+ private toAttribute;
21
+ }
22
+ //# sourceMappingURL=openTelemetryLogAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openTelemetryLogAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/lib/shared/infrastructure/logAdapters/openTelemetryLogAdapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAS3E,MAAM,WAAW,8BAA8B;IAC9C,0DAA0D;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,QAAQ,CAAA;CAChB;AAED;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,UAAU;IACzD,SAAgB,KAAK,CAAC,EAAE,QAAQ,CAAA;IAChC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAQ;IAC7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAQ;IACjC,OAAO,CAAC,MAAM,CAAC,CAAY;gBAEd,OAAO,GAAE,8BAAmC;IAMlD,KAAK,CAAE,MAAM,EAAE,SAAS,GAAG,IAAI;IA6BtC,mHAAmH;IACnH,OAAO,CAAC,WAAW;CAkBnB"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OpenTelemetryLogAdapter = void 0;
4
+ const api_1 = require("@opentelemetry/api");
5
+ const logger_1 = require("../../domain/ports/logger");
6
+ const SEVERITY = {
7
+ [logger_1.LogLevel.DEBUG]: api_1.SeverityNumber.DEBUG,
8
+ [logger_1.LogLevel.INFO]: api_1.SeverityNumber.INFO,
9
+ [logger_1.LogLevel.WARN]: api_1.SeverityNumber.WARN,
10
+ [logger_1.LogLevel.ERROR]: api_1.SeverityNumber.ERROR
11
+ };
12
+ /**
13
+ * Each record as a LogRecord of OpenTelemetry, through the global LoggerProvider: without an SDK it does nothing.
14
+ * The active context goes with it, which links the log with its trace.
15
+ */
16
+ class OpenTelemetryLogAdapter {
17
+ constructor(options = {}) {
18
+ this.name = options.name ?? '@lambdaorm/base';
19
+ this.version = options.version;
20
+ this.level = options.level;
21
+ }
22
+ write(record) {
23
+ // the provider is taken on the first write, so an SDK registered after the adapter is used
24
+ if (!this.logger) {
25
+ this.logger = api_1.logs.getLogger(this.name, this.version);
26
+ }
27
+ const attributes = {};
28
+ for (const [key, value] of Object.entries(record.attributes ?? {})) {
29
+ const attribute = this.toAttribute(value);
30
+ if (attribute !== undefined) {
31
+ attributes[key] = attribute;
32
+ }
33
+ }
34
+ if (record.error) {
35
+ attributes['exception.type'] = record.error.type;
36
+ attributes['exception.message'] = record.error.message;
37
+ if (record.error.stack) {
38
+ attributes['exception.stacktrace'] = record.error.stack;
39
+ }
40
+ }
41
+ this.logger.emit({
42
+ eventName: record.event,
43
+ timestamp: new Date(record.time),
44
+ severityNumber: SEVERITY[record.level],
45
+ severityText: record.level.toUpperCase(),
46
+ body: record.message,
47
+ attributes
48
+ });
49
+ }
50
+ /** primitives and lists of primitives go as they are; an object (a change's before, after or diff) goes as JSON */
51
+ toAttribute(value) {
52
+ if (value === undefined || value === null) {
53
+ return undefined;
54
+ }
55
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
56
+ return value;
57
+ }
58
+ if (value instanceof Date) {
59
+ return value.toISOString();
60
+ }
61
+ if (Array.isArray(value) && value.every(p => typeof p === 'string')) {
62
+ return value;
63
+ }
64
+ if (Array.isArray(value) && value.every(p => typeof p === 'number')) {
65
+ return value;
66
+ }
67
+ return JSON.stringify(value);
68
+ }
69
+ }
70
+ exports.OpenTelemetryLogAdapter = OpenTelemetryLogAdapter;
71
+ //# sourceMappingURL=openTelemetryLogAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openTelemetryLogAdapter.js","sourceRoot":"","sources":["../../../../../src/lib/shared/infrastructure/logAdapters/openTelemetryLogAdapter.ts"],"names":[],"mappings":";;;AAAA,4CAA2G;AAC3G,sDAA2E;AAE3E,MAAM,QAAQ,GAAqC;IAClD,CAAC,iBAAQ,CAAC,KAAK,CAAC,EAAE,oBAAc,CAAC,KAAK;IACtC,CAAC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;IAC7B,CAAC;CACD;AA5DD,0DA4DC"}
@@ -0,0 +1,10 @@
1
+ import { LogAdapter, LogLevel, LogRecord } from '../../domain/ports/logger';
2
+ /** The winston logger of before: console, error.log and combined.log. */
3
+ export declare class WinstonLogAdapter implements LogAdapter {
4
+ readonly level?: LogLevel | undefined;
5
+ private readonly logger;
6
+ constructor(level?: LogLevel | undefined);
7
+ write(record: LogRecord): void;
8
+ close(): Promise<void>;
9
+ }
10
+ //# sourceMappingURL=winstonLogAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"winstonLogAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/lib/shared/infrastructure/logAdapters/winstonLogAdapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAG3E,yEAAyE;AACzE,qBAAa,iBAAkB,YAAW,UAAU;aAGtB,KAAK,CAAC,EAAE,QAAQ;IAF7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAK;gBAEC,KAAK,CAAC,EAAE,QAAQ,YAAA;IAuBtC,KAAK,CAAE,MAAM,EAAE,SAAS,GAAG,IAAI;IAKzB,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC;CAGpC"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.WinstonLogAdapter = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const { transports, createLogger, format } = require('winston');
9
+ /** The winston logger of before: console, error.log and combined.log. */
10
+ class WinstonLogAdapter {
11
+ constructor(level) {
12
+ this.level = level;
13
+ this.logger = createLogger({
14
+ level: 'debug',
15
+ format: format.combine(format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss.SSS' }), format.colorize(), format.printf(({ level, message, label, timestamp }) => `${timestamp} ${label || '-'} ${level}: ${message}`)),
16
+ defaultMeta: { service: 'user-service' },
17
+ transports: [
18
+ new transports.Console({ timestamp: true }),
19
+ // in the current folder when the logger is built (winston opens them later)
20
+ new transports.File({ filename: path_1.default.resolve('error.log'), level: 'error', timestamp: true }),
21
+ new transports.File({ filename: path_1.default.resolve('combined.log'), timestamp: true })
22
+ ]
23
+ });
24
+ if (process.env.NODE_ENV !== 'production') {
25
+ this.logger.add(new transports.Console({ format: format.simple() }));
26
+ }
27
+ }
28
+ write(record) {
29
+ const message = record.event && record.attributes ? `${record.message} ${JSON.stringify(record.attributes)}` : record.message;
30
+ this.logger.log(record.level, message);
31
+ }
32
+ async close() {
33
+ this.logger.close();
34
+ }
35
+ }
36
+ exports.WinstonLogAdapter = WinstonLogAdapter;
37
+ //# sourceMappingURL=winstonLogAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"winstonLogAdapter.js","sourceRoot":"","sources":["../../../../../src/lib/shared/infrastructure/logAdapters/winstonLogAdapter.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AAEvB,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;AAE/D,yEAAyE;AACzE,MAAa,iBAAiB;IAG7B,YAA6B,KAAgB;QAAhB,UAAK,GAAL,KAAK,CAAW;QAC5C,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC;YAC1B,KAAK,EAAE,OAAO;YACd,MAAM,EAAE,MAAM,CAAC,OAAO,CACrB,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,yBAAyB,EAAE,CAAC,EACvD,MAAM,CAAC,QAAQ,EAAE,EACjB,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAyE,EAAE,EAAE,CAC7H,GAAG,SAAS,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,KAAK,OAAO,EAAE,CACnD,CACD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4
+ /** the folder where the file adapters write (infrastructure.paths.logs; default logs) */
5
+ logsPath?: string;
6
+ /** attribute names to redact, besides the default ones */
7
+ secrets?: string[];
8
+ }
2
9
  export declare class LoggerBuilder {
3
- build(name?: string): Logger;
10
+ /**
11
+ * build() and build('winston') work as before. With the logs of infrastructure.observability (better, the
12
+ * resolved ones of ObservabilityConfigService, where OTEL_* override) it builds the logger with its adapters.
13
+ */
14
+ build(config?: string | LogsConfig, options?: LoggerBuildOptions): Logger;
15
+ private adapter;
4
16
  }
5
17
  //# sourceMappingURL=loggerBuilder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loggerBuilder.d.ts","sourceRoot":"","sources":["../../../../src/lib/shared/infrastructure/loggerBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAI/C,qBAAa,aAAa;IAClB,KAAK,CAAE,IAAI,CAAC,EAAC,MAAM,GAAG,MAAM;CAMnC"}
1
+ {"version":3,"file":"loggerBuilder.d.ts","sourceRoot":"","sources":["../../../../src/lib/shared/infrastructure/loggerBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,MAAM,EAAwB,MAAM,wBAAwB,CAAA;AACjF,OAAO,EAAoB,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAKlE,MAAM,WAAW,kBAAkB;IAClC,yFAAyF;IACzF,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CAClB;AAED,qBAAa,aAAa;IACzB;;;OAGG;IACI,KAAK,CAAE,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,EAAE,OAAO,GAAE,kBAAuB,GAAG,MAAM;IASrF,OAAO,CAAC,OAAO;CAuBf"}
@@ -1,14 +1,49 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.LoggerBuilder = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const logger_1 = require("../domain/ports/logger");
4
9
  const consoleLogger_1 = require("./consoleLogger");
5
10
  const winstonLogger_1 = require("./winstonLogger");
11
+ const logAdapters_1 = require("./logAdapters");
6
12
  class LoggerBuilder {
7
- build(name) {
8
- if (name === 'winston') {
9
- return new winstonLogger_1.WinstonLogger();
13
+ /**
14
+ * build() and build('winston') work as before. With the logs of infrastructure.observability (better, the
15
+ * resolved ones of ObservabilityConfigService, where OTEL_* override) it builds the logger with its adapters.
16
+ */
17
+ build(config, options = {}) {
18
+ if (config === undefined || config === null || typeof config === 'string') {
19
+ return config === 'winston' ? new winstonLogger_1.WinstonLogger() : new consoleLogger_1.ConsoleLogger();
20
+ }
21
+ const adapters = (config.adapters && config.adapters.length > 0 ? config.adapters : [{ type: 'console' }])
22
+ .map(p => this.adapter(p, options));
23
+ return new logger_1.Logger(adapters, { level: (0, logger_1.toLogLevel)(config.level), secrets: options.secrets });
24
+ }
25
+ adapter(config, options) {
26
+ const level = config.level ? (0, logger_1.toLogLevel)(config.level) : undefined;
27
+ switch (config.type) {
28
+ case 'file':
29
+ if (!config.path) {
30
+ throw new Error('a file log adapter needs a path');
31
+ }
32
+ return new logAdapters_1.FileLogAdapter({
33
+ path: path_1.default.isAbsolute(config.path) ? config.path : path_1.default.join(options.logsPath ?? 'logs', config.path),
34
+ events: config.events,
35
+ maxBytes: config.maxBytes,
36
+ level
37
+ });
38
+ case 'opentelemetry':
39
+ return new logAdapters_1.OpenTelemetryLogAdapter({ level });
40
+ case 'winston':
41
+ return new logAdapters_1.WinstonLogAdapter(level);
42
+ case 'console':
43
+ return new logAdapters_1.ConsoleLogAdapter({ format: config.format, level });
44
+ default:
45
+ throw new Error(`the log adapter "${config.type}" is unknown`);
10
46
  }
11
- return new consoleLogger_1.ConsoleLogger();
12
47
  }
13
48
  }
14
49
  exports.LoggerBuilder = LoggerBuilder;
@@ -1 +1 @@
1
- {"version":3,"file":"loggerBuilder.js","sourceRoot":"","sources":["../../../../src/lib/shared/infrastructure/loggerBuilder.ts"],"names":[],"mappings":";;;AACA,mDAA+C;AAC/C,mDAA+C;AAE/C,MAAa,aAAa;IAClB,KAAK,CAAE,IAAY;QACzB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,IAAI,6BAAa,EAAE,CAAA;QAC3B,CAAC;QACD,OAAO,IAAI,6BAAa,EAAE,CAAA;IAC3B,CAAC;CACD;AAPD,sCAOC"}
1
+ {"version":3,"file":"loggerBuilder.js","sourceRoot":"","sources":["../../../../src/lib/shared/infrastructure/loggerBuilder.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,mDAAiF;AAEjF,mDAA+C;AAC/C,mDAA+C;AAC/C,+CAA6G;AAS7G,MAAa,aAAa;IACzB;;;OAGG;IACI,KAAK,CAAE,MAA4B,EAAE,UAA8B,EAAE;QAC3E,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC3E,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,6BAAa,EAAE,CAAC,CAAC,CAAC,IAAI,6BAAa,EAAE,CAAA;QACxE,CAAC;QACD,MAAM,QAAQ,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAsB,CAAC,CAAC;aAC5H,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAA;QACpC,OAAO,IAAI,eAAM,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAA,mBAAU,EAAC,MAAM,CAAC,KAAK,CAAC,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sortable by time */
2
+ export declare const ulid: (time?: number) => string;
3
+ //# sourceMappingURL=ulid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ulid.d.ts","sourceRoot":"","sources":["../../../../src/lib/shared/infrastructure/ulid.ts"],"names":[],"mappings":"AAIA,yHAAyH;AACzH,eAAO,MAAM,IAAI,GAAI,OAAM,MAAmB,KAAG,MAoBhD,CAAA"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ulid = void 0;
4
+ const crypto_1 = require("crypto");
5
+ const CROCKFORD = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
6
+ /** A ULID (https://github.com/ulid/spec): 48 bits of time in ms and 80 random bits, in 26 characters sortable by time */
7
+ const ulid = (time = Date.now()) => {
8
+ let text = '';
9
+ let rest = time;
10
+ for (let i = 0; i < 10; i++) {
11
+ text = CROCKFORD[rest % 32] + text;
12
+ rest = Math.floor(rest / 32);
13
+ }
14
+ const random = (0, crypto_1.randomBytes)(10);
15
+ let bits = 0;
16
+ let value = 0;
17
+ for (const byte of random) {
18
+ value = (value << 8) | byte;
19
+ bits += 8;
20
+ while (bits >= 5) {
21
+ bits -= 5;
22
+ text += CROCKFORD[(value >> bits) & 31];
23
+ }
24
+ value &= (1 << bits) - 1;
25
+ }
26
+ return text;
27
+ };
28
+ exports.ulid = ulid;
29
+ //# sourceMappingURL=ulid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ulid.js","sourceRoot":"","sources":["../../../../src/lib/shared/infrastructure/ulid.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AAEpC,MAAM,SAAS,GAAG,kCAAkC,CAAA;AAEpD,yHAAyH;AAClH,MAAM,IAAI,GAAG,CAAC,OAAe,IAAI,CAAC,GAAG,EAAE,EAAU,EAAE;IACzD,IAAI,IAAI,GAAG,EAAE,CAAA;IACb,IAAI,IAAI,GAAG,IAAI,CAAA;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7B,IAAI,GAAG,SAAS,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,IAAI,CAAA;QAClC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,CAAA;IAC7B,CAAC;IACD,MAAM,MAAM,GAAG,IAAA,oBAAW,EAAC,EAAE,CAAC,CAAA;IAC9B,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;QAC3B,KAAK,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,IAAI,CAAA;QAC3B,IAAI,IAAI,CAAC,CAAA;QACT,OAAO,IAAI,IAAI,CAAC,EAAE,CAAC;YAClB,IAAI,IAAI,CAAC,CAAA;YACT,IAAI,IAAI,SAAS,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;QACxC,CAAC;QACD,KAAK,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;IACD,OAAO,IAAI,CAAA;AACZ,CAAC,CAAA;AApBY,QAAA,IAAI,QAoBhB"}
@@ -1,8 +1,6 @@
1
- import { Logger } from '../domain/ports/logger';
1
+ import { Logger, LoggerOptions } from '../domain/ports/logger';
2
+ /** The logger of before with winston: console, error.log and combined.log. */
2
3
  export declare class WinstonLogger extends Logger {
3
- private readonly logger;
4
- constructor();
5
- protected info(message: string): Promise<void>;
6
- protected error(message: string | any): Promise<void>;
4
+ constructor(options?: LoggerOptions);
7
5
  }
8
6
  //# sourceMappingURL=winstonLogger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"winstonLogger.d.ts","sourceRoot":"","sources":["../../../../src/lib/shared/infrastructure/winstonLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAG/C,qBAAa,aAAc,SAAQ,MAAM;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAK;;cAyBH,IAAI,CAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;cAIrC,KAAK,CAAE,OAAO,EAAE,MAAM,GAAC,GAAG,GAAE,OAAO,CAAC,IAAI,CAAC;CAWlE"}
1
+ {"version":3,"file":"winstonLogger.d.ts","sourceRoot":"","sources":["../../../../src/lib/shared/infrastructure/winstonLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAG9D,8EAA8E;AAC9E,qBAAa,aAAc,SAAQ,MAAM;gBAC3B,OAAO,GAAE,aAAkB;CAGxC"}
@@ -2,42 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WinstonLogger = void 0;
4
4
  const logger_1 = require("../domain/ports/logger");
5
- const { transports, createLogger, format } = require('winston');
5
+ const winstonLogAdapter_1 = require("./logAdapters/winstonLogAdapter");
6
+ /** The logger of before with winston: console, error.log and combined.log. */
6
7
  class WinstonLogger extends logger_1.Logger {
7
- constructor() {
8
- super();
9
- this.logger = createLogger({
10
- level: 'info',
11
- format: format.combine(format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss.SSS' }),
12
- // utilFormatter(), // <-- this is what changed
13
- format.colorize(), format.printf(({ level, message, label, timestamp }) => `${timestamp} ${label || '-'} ${level}: ${message}`)),
14
- defaultMeta: { service: 'user-service' },
15
- transports: [
16
- new transports.Console({ timestamp: true }),
17
- new transports.File({ filename: 'error.log', level: 'error', timestamp: true }),
18
- new transports.File({ filename: 'combined.log', timestamp: true })
19
- ]
20
- });
21
- if (process.env.NODE_ENV !== 'production') {
22
- this.logger.add(new transports.Console({ format: format.simple() }));
23
- }
24
- }
25
- async info(message) {
26
- this.logger.info(message);
27
- }
28
- async error(message) {
29
- if (typeof message === 'string') {
30
- this.logger('error', message);
31
- }
32
- else if (message instanceof Error) {
33
- this.logger('error', message.message);
34
- }
35
- else if (message instanceof Object) {
36
- this.logger('error', JSON.stringify(message));
37
- }
38
- else {
39
- this.logger('error', message.toISOString());
40
- }
8
+ constructor(options = {}) {
9
+ super([new winstonLogAdapter_1.WinstonLogAdapter()], options);
41
10
  }
42
11
  }
43
12
  exports.WinstonLogger = WinstonLogger;
@@ -1 +1 @@
1
- {"version":3,"file":"winstonLogger.js","sourceRoot":"","sources":["../../../../src/lib/shared/infrastructure/winstonLogger.ts"],"names":[],"mappings":";;;AAAA,mDAA+C;AAC/C,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;AAE/D,MAAa,aAAc,SAAQ,eAAM;IAExC;QACC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC;YAC1B,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,MAAM,CAAC,OAAO,CACrB,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,yBAAyB,EAAE,CAAC;YACvD,+CAA+C;YAC/C,MAAM,CAAC,QAAQ,EAAE,EACjB,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAyE,EAAE,EAAE,CAC7H,GAAG,SAAS,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,KAAK,OAAO,EAAE,CACnD,CACD;YACD,WAAW,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE;YACxC,UAAU,EAAE;gBACX,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;gBAC3C,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;gBAC/E,IAAI,UAAU,CAAC,IAAI,C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