@jmlq/logger-plugin-fs 0.1.0-alpha.8 → 0.1.0-alpha.9
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 +6 -0
- package/dist/application/dto/index.d.ts +1 -3
- package/dist/application/dto/index.js +1 -3
- package/dist/application/dto/rotate-if-needed.request.d.ts +10 -0
- package/dist/application/factory/create-fs-datasource.factory.d.ts +14 -1
- package/dist/application/factory/create-fs-datasource.factory.js +45 -20
- package/dist/application/use-cases/append-log.use-case.d.ts +26 -8
- package/dist/application/use-cases/append-log.use-case.js +25 -12
- package/dist/application/use-cases/ensure-directory.use-case.d.ts +50 -3
- package/dist/application/use-cases/ensure-directory.use-case.js +44 -7
- package/dist/application/use-cases/find-logs-use-case.d.ts +17 -0
- package/dist/application/use-cases/find-logs-use-case.js +64 -0
- package/dist/application/use-cases/index.d.ts +1 -0
- package/dist/application/use-cases/index.js +1 -0
- package/dist/application/use-cases/persist-log.use-case.d.ts +86 -9
- package/dist/application/use-cases/persist-log.use-case.js +73 -15
- package/dist/application/use-cases/rotate-if-needed.use-case.d.ts +49 -11
- package/dist/application/use-cases/rotate-if-needed.use-case.js +41 -8
- package/dist/domain/model/index.d.ts +1 -0
- package/dist/{infrastructure/filesystem/value-objects → domain/model}/index.js +1 -1
- package/dist/domain/model/log-entry.model.d.ts +8 -0
- package/dist/domain/ports/file/file-path.port.d.ts +38 -0
- package/dist/domain/ports/file/file-rotator.port.d.ts +42 -0
- package/dist/{infrastructure/filesystem/ports → domain/ports/file}/index.d.ts +1 -0
- package/dist/{infrastructure/filesystem/ports → domain/ports/file}/index.js +1 -0
- package/dist/domain/ports/file/log-stream-writer.port.d.ts +70 -0
- package/dist/domain/ports/{fs-provider.port.d.ts → filesystem-provider.port.d.ts} +1 -1
- package/dist/domain/ports/index.d.ts +5 -4
- package/dist/domain/ports/index.js +5 -4
- package/dist/domain/ports/logs/find/index.d.ts +2 -0
- package/dist/domain/ports/logs/find/index.js +18 -0
- package/dist/domain/ports/logs/find/log-file-line-reader.port.d.ts +3 -0
- package/dist/domain/ports/logs/find/log-file-numerator.port.d.ts +3 -0
- package/dist/domain/ports/logs/index.d.ts +2 -0
- package/dist/domain/ports/logs/index.js +18 -0
- package/dist/domain/ports/logs/log-datasource.port.d.ts +10 -0
- package/dist/domain/ports/{clock.port.d.ts → system-clock.port.d.ts} +1 -1
- package/dist/domain/ports/system-clock.port.js +2 -0
- package/dist/domain/request/index.d.ts +2 -0
- package/dist/domain/request/index.js +18 -0
- package/dist/domain/request/log-filter.request.d.ts +9 -0
- package/dist/domain/request/log-filter.request.js +2 -0
- package/dist/domain/request/save-log.request.d.ts +7 -0
- package/dist/domain/request/save-log.request.js +2 -0
- package/dist/domain/response/index.d.ts +1 -0
- package/dist/{application/services → domain/response}/index.js +1 -1
- package/dist/domain/response/log.response.d.ts +8 -0
- package/dist/domain/response/log.response.js +2 -0
- package/dist/domain/types/fs-rotation-by.type.d.ts +8 -0
- package/dist/domain/types/fs-rotation-by.type.js +2 -0
- package/dist/domain/types/index.d.ts +1 -0
- package/dist/domain/types/index.js +17 -0
- package/dist/domain/value-objects/file-name-pattern.vo.d.ts +36 -0
- package/dist/domain/value-objects/file-name-pattern.vo.js +53 -0
- package/dist/domain/value-objects/file-path.vo.d.ts +73 -9
- package/dist/domain/value-objects/file-path.vo.js +54 -13
- package/dist/domain/value-objects/file-rotation-policy.vo.d.ts +51 -0
- package/dist/domain/value-objects/file-rotation-policy.vo.js +76 -0
- package/dist/domain/value-objects/file-size.vo.d.ts +61 -0
- package/dist/domain/value-objects/file-size.vo.js +57 -0
- package/dist/domain/value-objects/index.d.ts +3 -0
- package/dist/domain/value-objects/index.js +3 -0
- package/dist/domain/value-objects/log-level.vo.d.ts +8 -0
- package/dist/domain/value-objects/log-level.vo.js +13 -0
- package/dist/index.d.ts +3 -4
- package/dist/index.js +5 -11
- package/dist/infrastructure/adapters/file-rotator.adapter.d.ts +67 -8
- package/dist/infrastructure/adapters/file-rotator.adapter.js +133 -67
- package/dist/infrastructure/adapters/fileSystem-datasource.adapter.d.ts +26 -0
- package/dist/infrastructure/adapters/fileSystem-datasource.adapter.js +45 -0
- package/dist/infrastructure/adapters/filesystem-log-file-enumerator.adapter.d.ts +6 -0
- package/dist/infrastructure/adapters/filesystem-log-file-enumerator.adapter.js +54 -0
- package/dist/infrastructure/adapters/filesystem-log-file-line-reader.adapter.d.ts +4 -0
- package/dist/infrastructure/adapters/{fs-provider.adapter.js → filesystem-log-file-line-reader.adapter.js} +13 -37
- package/dist/infrastructure/adapters/filesystem-provider.adapter.d.ts +122 -0
- package/dist/infrastructure/adapters/filesystem-provider.adapter.js +182 -0
- package/dist/infrastructure/adapters/index.d.ts +7 -4
- package/dist/infrastructure/adapters/index.js +7 -4
- package/dist/infrastructure/adapters/log-stream-writer.adapter.d.ts +80 -0
- package/dist/infrastructure/adapters/log-stream-writer.adapter.js +163 -0
- package/dist/infrastructure/adapters/system-clock.adapter.d.ts +25 -0
- package/dist/infrastructure/adapters/system-clock.adapter.js +30 -0
- package/dist/infrastructure/adapters/system-file-path.adapter.d.ts +47 -0
- package/dist/infrastructure/adapters/system-file-path.adapter.js +141 -0
- package/dist/infrastructure/errors/file-operation.error.d.ts +28 -0
- package/dist/infrastructure/errors/file-operation.error.js +54 -0
- package/dist/infrastructure/errors/index.d.ts +1 -0
- package/dist/{shared → infrastructure}/errors/index.js +0 -2
- package/dist/infrastructure/errors/types/file-operation-error-options.type.d.ts +8 -0
- package/dist/infrastructure/errors/types/file-operation-error-options.type.js +2 -0
- package/dist/infrastructure/errors/types/file-operation.type.d.ts +1 -0
- package/dist/infrastructure/errors/types/file-operation.type.js +2 -0
- package/dist/infrastructure/errors/types/fs-error-scope.type.d.ts +1 -0
- package/dist/infrastructure/errors/types/fs-error-scope.type.js +2 -0
- package/dist/infrastructure/errors/types/index.d.ts +3 -0
- package/dist/infrastructure/errors/types/index.js +19 -0
- package/dist/infrastructure/filesystem/index.d.ts +0 -3
- package/dist/infrastructure/filesystem/index.js +0 -3
- package/dist/infrastructure/filesystem/types/filesystem-datasource-options.type.d.ts +2 -6
- package/dist/infrastructure/filesystem/types/filesystem-rotation.type.d.ts +2 -9
- package/dist/infrastructure/filesystem/types/index.d.ts +0 -1
- package/dist/infrastructure/filesystem/types/index.js +0 -1
- package/package.json +3 -5
- package/dist/application/dto/rotation-check.dto.d.ts +0 -5
- package/dist/application/dto/save-log.dto.d.ts +0 -4
- package/dist/application/dto/write-operation.dto.d.ts +0 -5
- package/dist/application/services/fs-datasource.service.d.ts +0 -11
- package/dist/application/services/fs-datasource.service.js +0 -19
- package/dist/application/services/index.d.ts +0 -1
- package/dist/domain/ports/file-path-adapter.port.d.ts +0 -33
- package/dist/domain/ports/stream-writer.port.d.ts +0 -42
- package/dist/infrastructure/adapters/fs-provider.adapter.d.ts +0 -17
- package/dist/infrastructure/adapters/fs-writer.adapter.d.ts +0 -13
- package/dist/infrastructure/adapters/fs-writer.adapter.js +0 -71
- package/dist/infrastructure/adapters/node-clock.adapter.d.ts +0 -4
- package/dist/infrastructure/adapters/node-clock.adapter.js +0 -9
- package/dist/infrastructure/adapters/node-file-path.adapter.d.ts +0 -16
- package/dist/infrastructure/adapters/node-file-path.adapter.js +0 -117
- package/dist/infrastructure/filesystem/polices/index.d.ts +0 -1
- package/dist/infrastructure/filesystem/polices/index.js +0 -5
- package/dist/infrastructure/filesystem/polices/rotation-policy.d.ts +0 -29
- package/dist/infrastructure/filesystem/polices/rotation-policy.js +0 -55
- package/dist/infrastructure/filesystem/ports/file-rotator.port.d.ts +0 -32
- package/dist/infrastructure/filesystem/types/filesystem-serializer.type.d.ts +0 -10
- package/dist/infrastructure/filesystem/value-objects/file-name-pattern.vo.d.ts +0 -22
- package/dist/infrastructure/filesystem/value-objects/file-name-pattern.vo.js +0 -37
- package/dist/infrastructure/filesystem/value-objects/index.d.ts +0 -1
- package/dist/shared/errors/file-operation.error.d.ts +0 -12
- package/dist/shared/errors/file-operation.error.js +0 -32
- package/dist/shared/errors/fs-plugin.error.d.ts +0 -4
- package/dist/shared/errors/fs-plugin.error.js +0 -11
- package/dist/shared/errors/index.d.ts +0 -3
- package/dist/shared/errors/rotation.error.d.ts +0 -10
- package/dist/shared/errors/rotation.error.js +0 -25
- /package/dist/application/dto/{rotation-check.dto.js → rotate-if-needed.request.js} +0 -0
- /package/dist/{application/dto/save-log.dto.js → domain/model/log-entry.model.js} +0 -0
- /package/dist/{application/dto/write-operation.dto.js → domain/ports/file/file-path.port.js} +0 -0
- /package/dist/{infrastructure/filesystem/ports → domain/ports/file}/file-rotator.port.js +0 -0
- /package/dist/domain/ports/{clock.port.js → file/log-stream-writer.port.js} +0 -0
- /package/dist/domain/ports/{file-path-adapter.port.js → filesystem-provider.port.js} +0 -0
- /package/dist/domain/ports/{fs-provider.port.js → logs/find/log-file-line-reader.port.js} +0 -0
- /package/dist/domain/ports/{stream-writer.port.js → logs/find/log-file-numerator.port.js} +0 -0
- /package/dist/{infrastructure/filesystem/types/filesystem-serializer.type.js → domain/ports/logs/log-datasource.port.js} +0 -0
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FilePath } from "../../domain/value-objects/file-path.vo";
|
|
2
|
-
import { IFilePathAdapterPort } from "../../domain/ports/file-path-adapter.port";
|
|
3
|
-
/**
|
|
4
|
-
* Adapter concreto basado en Node.js (`path`) que construye y transforma FilePath.
|
|
5
|
-
* Es infraestructura pura que implementa el port de dominio.
|
|
6
|
-
*/
|
|
7
|
-
export declare class NodeFilePathAdapter implements IFilePathAdapterPort {
|
|
8
|
-
fromRaw(inputPath: string): FilePath;
|
|
9
|
-
fromBasename(directory: string, basename: string, extension: string): FilePath;
|
|
10
|
-
withExtension(filePath: FilePath, newExtension: string): FilePath;
|
|
11
|
-
withBasename(filePath: FilePath, newBasename: string): FilePath;
|
|
12
|
-
join(filePath: FilePath, ...segments: string[]): FilePath;
|
|
13
|
-
resolve(filePath: FilePath, ...segments: string[]): FilePath;
|
|
14
|
-
relativeTo(basePath: string, filePath: FilePath): string;
|
|
15
|
-
private buildFromAbsolute;
|
|
16
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.NodeFilePathAdapter = void 0;
|
|
37
|
-
const path = __importStar(require("path"));
|
|
38
|
-
const file_path_vo_1 = require("../../domain/value-objects/file-path.vo");
|
|
39
|
-
/**
|
|
40
|
-
* Adapter concreto basado en Node.js (`path`) que construye y transforma FilePath.
|
|
41
|
-
* Es infraestructura pura que implementa el port de dominio.
|
|
42
|
-
*/
|
|
43
|
-
class NodeFilePathAdapter {
|
|
44
|
-
fromRaw(inputPath) {
|
|
45
|
-
if (!inputPath || typeof inputPath !== "string") {
|
|
46
|
-
throw new Error("NodeFilePathAdapter.fromRaw: inputPath must be a non-empty string");
|
|
47
|
-
}
|
|
48
|
-
const trimmed = inputPath.trim();
|
|
49
|
-
if (!trimmed) {
|
|
50
|
-
throw new Error("NodeFilePathAdapter.fromRaw: inputPath cannot be empty or whitespace");
|
|
51
|
-
}
|
|
52
|
-
const absolutePath = path.resolve(trimmed);
|
|
53
|
-
return this.buildFromAbsolute(absolutePath);
|
|
54
|
-
}
|
|
55
|
-
fromBasename(directory, basename, extension) {
|
|
56
|
-
if (!directory || !basename) {
|
|
57
|
-
throw new Error("NodeFilePathAdapter.fromBasename: directory and basename are required");
|
|
58
|
-
}
|
|
59
|
-
const ext = extension
|
|
60
|
-
? extension.startsWith(".")
|
|
61
|
-
? extension
|
|
62
|
-
: `.${extension}`
|
|
63
|
-
: "";
|
|
64
|
-
const fullPath = path.join(directory, basename + ext);
|
|
65
|
-
const absolutePath = path.resolve(fullPath);
|
|
66
|
-
return this.buildFromAbsolute(absolutePath);
|
|
67
|
-
}
|
|
68
|
-
withExtension(filePath, newExtension) {
|
|
69
|
-
const ext = newExtension.startsWith(".")
|
|
70
|
-
? newExtension
|
|
71
|
-
: `.${newExtension}`;
|
|
72
|
-
const filename = filePath.basename + ext;
|
|
73
|
-
const absolutePath = path.join(filePath.directory, filename);
|
|
74
|
-
return this.buildFromAbsolute(absolutePath);
|
|
75
|
-
}
|
|
76
|
-
withBasename(filePath, newBasename) {
|
|
77
|
-
if (!newBasename || !newBasename.trim()) {
|
|
78
|
-
throw new Error("NodeFilePathAdapter.withBasename: newBasename must be a non-empty string");
|
|
79
|
-
}
|
|
80
|
-
const filename = newBasename + filePath.extension;
|
|
81
|
-
const absolutePath = path.join(filePath.directory, filename);
|
|
82
|
-
return this.buildFromAbsolute(absolutePath);
|
|
83
|
-
}
|
|
84
|
-
join(filePath, ...segments) {
|
|
85
|
-
const absolutePath = path.join(filePath.absolutePath, ...segments);
|
|
86
|
-
return this.buildFromAbsolute(absolutePath);
|
|
87
|
-
}
|
|
88
|
-
resolve(filePath, ...segments) {
|
|
89
|
-
const absolutePath = path.resolve(filePath.absolutePath, ...segments);
|
|
90
|
-
return this.buildFromAbsolute(absolutePath);
|
|
91
|
-
}
|
|
92
|
-
relativeTo(basePath, filePath) {
|
|
93
|
-
if (!basePath || !basePath.trim()) {
|
|
94
|
-
throw new Error("NodeFilePathAdapter.relativeTo: basePath must be a non-empty string");
|
|
95
|
-
}
|
|
96
|
-
return path.relative(path.resolve(basePath.trim()), filePath.absolutePath);
|
|
97
|
-
}
|
|
98
|
-
// ────────────────────────────────────────────
|
|
99
|
-
// Helper privado: construye IFilePathProps
|
|
100
|
-
// ────────────────────────────────────────────
|
|
101
|
-
buildFromAbsolute(absolutePath) {
|
|
102
|
-
const normalized = path.resolve(absolutePath);
|
|
103
|
-
const directory = path.dirname(normalized);
|
|
104
|
-
const filename = path.basename(normalized);
|
|
105
|
-
const extension = path.extname(normalized);
|
|
106
|
-
const basename = path.basename(normalized, extension);
|
|
107
|
-
const props = {
|
|
108
|
-
absolutePath: normalized,
|
|
109
|
-
directory,
|
|
110
|
-
filename,
|
|
111
|
-
extension,
|
|
112
|
-
basename,
|
|
113
|
-
};
|
|
114
|
-
return new file_path_vo_1.FilePath(props);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
exports.NodeFilePathAdapter = NodeFilePathAdapter;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { RotationPolicy } from "./rotation-policy";
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RotationPolicy = void 0;
|
|
4
|
-
var rotation_policy_1 = require("./rotation-policy");
|
|
5
|
-
Object.defineProperty(exports, "RotationPolicy", { enumerable: true, get: function () { return rotation_policy_1.RotationPolicy; } });
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { FsRotationBy } from "..";
|
|
2
|
-
import { FileSize } from "../../../domain/value-objects/file-size.vo";
|
|
3
|
-
/**
|
|
4
|
-
* Es un Value Object de dominio que encapsula la política de rotación de logs
|
|
5
|
-
* by: cómo se rota → "none" | "day" | "size".
|
|
6
|
-
* maxSizeMB: umbral de tamaño (solo tiene sentido para "size").
|
|
7
|
-
* maxFiles: cuántos archivos rotados se mantienen (concepto típico en rotation).
|
|
8
|
-
*/
|
|
9
|
-
export declare class RotationPolicy {
|
|
10
|
-
private readonly _by;
|
|
11
|
-
private readonly _maxSize?;
|
|
12
|
-
private readonly _maxFiles?;
|
|
13
|
-
constructor(by: FsRotationBy, maxSizeMB?: number, maxFiles?: number);
|
|
14
|
-
get by(): FsRotationBy;
|
|
15
|
-
get maxSizeMB(): number | undefined;
|
|
16
|
-
get maxSize(): FileSize | undefined;
|
|
17
|
-
get maxFiles(): number | undefined;
|
|
18
|
-
/**
|
|
19
|
-
* Lógica de negocio mejorada usando FileSize value object
|
|
20
|
-
* @param currentSize Tamaño actual del archivo como FileSize
|
|
21
|
-
* @returns true si debe rotar por tamaño
|
|
22
|
-
*/
|
|
23
|
-
shouldRotateBySize(currentSize: FileSize): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Método de compatibilidad para tamaños en bytes
|
|
26
|
-
* Usar shouldRotateBySize(FileSize) en su lugar
|
|
27
|
-
*/
|
|
28
|
-
shouldRotateBySizeBytes(currentSizeBytes: number): boolean;
|
|
29
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RotationPolicy = void 0;
|
|
4
|
-
const file_size_vo_1 = require("../../../domain/value-objects/file-size.vo");
|
|
5
|
-
/**
|
|
6
|
-
* Es un Value Object de dominio que encapsula la política de rotación de logs
|
|
7
|
-
* by: cómo se rota → "none" | "day" | "size".
|
|
8
|
-
* maxSizeMB: umbral de tamaño (solo tiene sentido para "size").
|
|
9
|
-
* maxFiles: cuántos archivos rotados se mantienen (concepto típico en rotation).
|
|
10
|
-
*/
|
|
11
|
-
class RotationPolicy {
|
|
12
|
-
constructor(by, maxSizeMB, maxFiles) {
|
|
13
|
-
if (!["none", "day", "size"].includes(by)) {
|
|
14
|
-
throw new Error("RotationPolicy: invalid rotation strategy");
|
|
15
|
-
}
|
|
16
|
-
if (by === "size" && (maxSizeMB == null || maxSizeMB <= 0)) {
|
|
17
|
-
throw new Error("RotationPolicy: maxSizeMB must be positive for size rotation");
|
|
18
|
-
}
|
|
19
|
-
this._by = by;
|
|
20
|
-
this._maxSize = maxSizeMB ? file_size_vo_1.FileSize.fromMegabytes(maxSizeMB) : undefined;
|
|
21
|
-
this._maxFiles = maxFiles;
|
|
22
|
-
}
|
|
23
|
-
get by() {
|
|
24
|
-
return this._by;
|
|
25
|
-
}
|
|
26
|
-
get maxSizeMB() {
|
|
27
|
-
return this._maxSize?.megabytes;
|
|
28
|
-
}
|
|
29
|
-
get maxSize() {
|
|
30
|
-
return this._maxSize;
|
|
31
|
-
}
|
|
32
|
-
get maxFiles() {
|
|
33
|
-
return this._maxFiles;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Lógica de negocio mejorada usando FileSize value object
|
|
37
|
-
* @param currentSize Tamaño actual del archivo como FileSize
|
|
38
|
-
* @returns true si debe rotar por tamaño
|
|
39
|
-
*/
|
|
40
|
-
shouldRotateBySize(currentSize) {
|
|
41
|
-
if (this._by !== "size" || !this._maxSize) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
return (currentSize.isGreaterThan(this._maxSize) ||
|
|
45
|
-
currentSize.equals(this._maxSize));
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Método de compatibilidad para tamaños en bytes
|
|
49
|
-
* Usar shouldRotateBySize(FileSize) en su lugar
|
|
50
|
-
*/
|
|
51
|
-
shouldRotateBySizeBytes(currentSizeBytes) {
|
|
52
|
-
return this.shouldRotateBySize(new file_size_vo_1.FileSize(currentSizeBytes));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.RotationPolicy = RotationPolicy;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { FileSize, FilePath } from "../../../domain/value-objects";
|
|
2
|
-
import { RotationPolicy } from "../polices";
|
|
3
|
-
/**
|
|
4
|
-
* "Puente" entre dominio y filesystem
|
|
5
|
-
*/
|
|
6
|
-
export interface IFileRotatorPort {
|
|
7
|
-
/**
|
|
8
|
-
* Saber qué archivo de log está activo ahora
|
|
9
|
-
*/
|
|
10
|
-
getCurrentPath(): FilePath | null;
|
|
11
|
-
/**
|
|
12
|
-
* Calcular cómo se va a llamar el archivo según una fecha
|
|
13
|
-
* @param date Fecha para la que se quiere el path
|
|
14
|
-
*/
|
|
15
|
-
getExpectedPathForDate(date: Date): FilePath;
|
|
16
|
-
/**
|
|
17
|
-
* Consultar metadata del archivo usando FileSize value object
|
|
18
|
-
* @param filePath Ruta del archivo como FilePath
|
|
19
|
-
*/
|
|
20
|
-
getFileSize(filePath: FilePath): Promise<FileSize>;
|
|
21
|
-
/**
|
|
22
|
-
* Saber qué índice usar para el siguiente archivo rotado
|
|
23
|
-
* @param baseFilePath Ruta base del archivo como FilePath
|
|
24
|
-
*/
|
|
25
|
-
getNextRotationIndex(baseFilePath: FilePath): Promise<number>;
|
|
26
|
-
/**
|
|
27
|
-
* Decidir si corresponde rotar de acuerdo a una RotationPolicy y la fecha actual
|
|
28
|
-
* @param policy Política de rotación
|
|
29
|
-
* @param currentDate Fecha actual
|
|
30
|
-
*/
|
|
31
|
-
shouldRotate(policy: RotationPolicy, currentDate: Date): Promise<boolean>;
|
|
32
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Es una estrategia de serialización usada por el datasource de filesystem para convertir cualquier entrada (entry: unknown) en una cadena (string) antes de escribirla en el archivo.
|
|
3
|
-
*/
|
|
4
|
-
export interface IFsSerializer {
|
|
5
|
-
/**
|
|
6
|
-
* Serializa una entrada genérica a string
|
|
7
|
-
* @param entry Entrada a serializar
|
|
8
|
-
*/
|
|
9
|
-
serialize(entry: unknown): string;
|
|
10
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* representa el patrón de nombrado de archivos de log
|
|
3
|
-
*/
|
|
4
|
-
export declare class FileNamePattern {
|
|
5
|
-
private readonly _pattern;
|
|
6
|
-
constructor(pattern: string);
|
|
7
|
-
/**
|
|
8
|
-
* Retorna el valor inmutable
|
|
9
|
-
*/
|
|
10
|
-
get pattern(): string;
|
|
11
|
-
/**
|
|
12
|
-
* Indica si el patrón contiene tokens de fecha
|
|
13
|
-
* Útil para detectar si el nombre del archivo depende de fecha
|
|
14
|
-
* @returns true si el patrón contiene tokens de fecha, false en caso contrario
|
|
15
|
-
*/
|
|
16
|
-
hasDateTokens(): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Devuelve todos los tokens encerrados en llaves presentes en el patrón
|
|
19
|
-
* @returns Array de tokens encontrados en el patrón
|
|
20
|
-
*/
|
|
21
|
-
getTokens(): string[];
|
|
22
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FileNamePattern = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* representa el patrón de nombrado de archivos de log
|
|
6
|
-
*/
|
|
7
|
-
class FileNamePattern {
|
|
8
|
-
constructor(pattern) {
|
|
9
|
-
if (!pattern || typeof pattern !== "string") {
|
|
10
|
-
throw new Error("FileNamePattern: pattern must be a non-empty string");
|
|
11
|
-
}
|
|
12
|
-
this._pattern = pattern.trim();
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Retorna el valor inmutable
|
|
16
|
-
*/
|
|
17
|
-
get pattern() {
|
|
18
|
-
return this._pattern;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Indica si el patrón contiene tokens de fecha
|
|
22
|
-
* Útil para detectar si el nombre del archivo depende de fecha
|
|
23
|
-
* @returns true si el patrón contiene tokens de fecha, false en caso contrario
|
|
24
|
-
*/
|
|
25
|
-
hasDateTokens() {
|
|
26
|
-
return /\{(yyyy|MM|dd|HH|mm|ss)\}/.test(this._pattern);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Devuelve todos los tokens encerrados en llaves presentes en el patrón
|
|
30
|
-
* @returns Array de tokens encontrados en el patrón
|
|
31
|
-
*/
|
|
32
|
-
getTokens() {
|
|
33
|
-
const matches = this._pattern.match(/\{([^}]+)\}/g);
|
|
34
|
-
return matches ? matches.map((m) => m.slice(1, -1)) : [];
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.FileNamePattern = FileNamePattern;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./file-name-pattern.vo";
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare class FileOperationError extends Error {
|
|
2
|
-
readonly operation: string;
|
|
3
|
-
readonly filePath?: string | undefined;
|
|
4
|
-
readonly cause?: Error | undefined;
|
|
5
|
-
constructor(message: string, operation: string, filePath?: string | undefined, cause?: Error | undefined);
|
|
6
|
-
static create(operation: string, filePath: string, cause?: Error): FileOperationError;
|
|
7
|
-
static createForRead(filePath: string, cause?: Error): FileOperationError;
|
|
8
|
-
static createForWrite(filePath: string, cause?: Error): FileOperationError;
|
|
9
|
-
static createForDelete(filePath: string, cause?: Error): FileOperationError;
|
|
10
|
-
static createForMkdir(filePath: string, cause?: Error): FileOperationError;
|
|
11
|
-
static createForMove(filePath: string, cause?: Error): FileOperationError;
|
|
12
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FileOperationError = void 0;
|
|
4
|
-
class FileOperationError extends Error {
|
|
5
|
-
constructor(message, operation, filePath, cause) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.operation = operation;
|
|
8
|
-
this.filePath = filePath;
|
|
9
|
-
this.cause = cause;
|
|
10
|
-
this.name = "FileOperationError";
|
|
11
|
-
}
|
|
12
|
-
static create(operation, filePath, cause) {
|
|
13
|
-
const message = `Failed to ${operation} file: ${filePath}`;
|
|
14
|
-
return new FileOperationError(message, operation, filePath, cause);
|
|
15
|
-
}
|
|
16
|
-
static createForRead(filePath, cause) {
|
|
17
|
-
return FileOperationError.create("read", filePath, cause);
|
|
18
|
-
}
|
|
19
|
-
static createForWrite(filePath, cause) {
|
|
20
|
-
return FileOperationError.create("write", filePath, cause);
|
|
21
|
-
}
|
|
22
|
-
static createForDelete(filePath, cause) {
|
|
23
|
-
return FileOperationError.create("delete", filePath, cause);
|
|
24
|
-
}
|
|
25
|
-
static createForMkdir(filePath, cause) {
|
|
26
|
-
return FileOperationError.create("create directory", filePath, cause);
|
|
27
|
-
}
|
|
28
|
-
static createForMove(filePath, cause) {
|
|
29
|
-
return FileOperationError.create("move", filePath, cause);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.FileOperationError = FileOperationError;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FsPluginError = void 0;
|
|
4
|
-
class FsPluginError extends Error {
|
|
5
|
-
constructor(message, cause) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.cause = cause;
|
|
8
|
-
this.name = "FsPluginError";
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.FsPluginError = FsPluginError;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare class RotationError extends Error {
|
|
2
|
-
readonly rotationType: string;
|
|
3
|
-
readonly filePath?: string | undefined;
|
|
4
|
-
readonly cause?: Error | undefined;
|
|
5
|
-
constructor(message: string, rotationType: string, filePath?: string | undefined, cause?: Error | undefined);
|
|
6
|
-
static createForPolicyViolation(policy: string, reason: string): RotationError;
|
|
7
|
-
static createForFileRotation(filePath: string, cause?: Error): RotationError;
|
|
8
|
-
static createForSizeCheck(filePath: string, cause?: Error): RotationError;
|
|
9
|
-
static createForDateCheck(filePath: string, cause?: Error): RotationError;
|
|
10
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RotationError = void 0;
|
|
4
|
-
class RotationError extends Error {
|
|
5
|
-
constructor(message, rotationType, filePath, cause) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.rotationType = rotationType;
|
|
8
|
-
this.filePath = filePath;
|
|
9
|
-
this.cause = cause;
|
|
10
|
-
this.name = "RotationError";
|
|
11
|
-
}
|
|
12
|
-
static createForPolicyViolation(policy, reason) {
|
|
13
|
-
return new RotationError(`Rotation policy '${policy}' violation: ${reason}`, policy);
|
|
14
|
-
}
|
|
15
|
-
static createForFileRotation(filePath, cause) {
|
|
16
|
-
return new RotationError(`Failed to rotate file: ${filePath}`, "file", filePath, cause);
|
|
17
|
-
}
|
|
18
|
-
static createForSizeCheck(filePath, cause) {
|
|
19
|
-
return new RotationError(`Failed to check file size for rotation: ${filePath}`, "size-check", filePath, cause);
|
|
20
|
-
}
|
|
21
|
-
static createForDateCheck(filePath, cause) {
|
|
22
|
-
return new RotationError(`Failed to check file date for rotation: ${filePath}`, "date-check", filePath, cause);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.RotationError = RotationError;
|
|
File without changes
|
|
File without changes
|
/package/dist/{application/dto/write-operation.dto.js → domain/ports/file/file-path.port.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|