@jmlq/logger-plugin-fs 0.1.0-alpha.5 → 0.1.0-alpha.7

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 (119) hide show
  1. package/README.md +167 -153
  2. package/architecture.md +426 -0
  3. package/dist/application/dto/index.d.ts +2 -0
  4. package/dist/application/dto/index.js +2 -0
  5. package/dist/application/dto/rotation-check.dto.d.ts +5 -0
  6. package/dist/application/dto/save-log.dto.d.ts +3 -3
  7. package/dist/application/dto/write-operation.dto.d.ts +5 -0
  8. package/dist/application/factory/create-fs-datasource.factory.d.ts +3 -0
  9. package/dist/application/factory/create-fs-datasource.factory.js +26 -0
  10. package/dist/application/factory/index.d.ts +1 -0
  11. package/dist/{presentation → application}/factory/index.js +1 -1
  12. package/dist/application/services/fs-datasource.service.d.ts +7 -5
  13. package/dist/application/services/fs-datasource.service.js +6 -9
  14. package/dist/application/use-cases/append-log.use-case.d.ts +12 -0
  15. package/dist/application/use-cases/append-log.use-case.js +26 -0
  16. package/dist/application/use-cases/ensure-directory.use-case.d.ts +11 -0
  17. package/dist/application/use-cases/ensure-directory.use-case.js +27 -0
  18. package/dist/application/use-cases/index.d.ts +4 -3
  19. package/dist/application/use-cases/index.js +4 -3
  20. package/dist/application/use-cases/persist-log.use-case.d.ts +19 -0
  21. package/dist/application/use-cases/persist-log.use-case.js +47 -0
  22. package/dist/application/use-cases/rotate-if-needed.use-case.d.ts +17 -0
  23. package/dist/application/use-cases/rotate-if-needed.use-case.js +28 -0
  24. package/dist/domain/ports/clock.port.d.ts +8 -0
  25. package/dist/domain/ports/file-path-adapter.port.d.ts +33 -0
  26. package/dist/domain/ports/fs-provider.port.d.ts +61 -0
  27. package/dist/domain/ports/fs-provider.port.js +2 -0
  28. package/dist/domain/ports/index.d.ts +4 -0
  29. package/dist/domain/{contracts → ports}/index.js +3 -3
  30. package/dist/domain/ports/stream-writer.port.d.ts +42 -0
  31. package/dist/domain/ports/stream-writer.port.js +2 -0
  32. package/dist/domain/value-objects/file-path.vo.d.ts +27 -0
  33. package/dist/domain/value-objects/file-path.vo.js +59 -0
  34. package/dist/domain/value-objects/file-size.vo.d.ts +14 -0
  35. package/dist/domain/value-objects/file-size.vo.js +57 -0
  36. package/dist/domain/value-objects/index.d.ts +2 -2
  37. package/dist/domain/value-objects/index.js +2 -2
  38. package/dist/index.d.ts +4 -3
  39. package/dist/index.js +14 -5
  40. package/dist/infrastructure/adapters/file-rotator.adapter.d.ts +20 -0
  41. package/dist/infrastructure/adapters/file-rotator.adapter.js +105 -0
  42. package/dist/infrastructure/adapters/fs-provider.adapter.d.ts +17 -0
  43. package/dist/infrastructure/{fs/fs-provider.js → adapters/fs-provider.adapter.js} +41 -19
  44. package/dist/infrastructure/adapters/fs-writer.adapter.d.ts +13 -0
  45. package/dist/infrastructure/adapters/fs-writer.adapter.js +71 -0
  46. package/dist/infrastructure/{fs → adapters}/index.d.ts +2 -2
  47. package/dist/infrastructure/{fs → adapters}/index.js +2 -2
  48. package/dist/infrastructure/adapters/node-clock.adapter.d.ts +4 -0
  49. package/dist/infrastructure/{fs → adapters}/node-clock.adapter.js +0 -1
  50. package/dist/infrastructure/adapters/node-file-path.adapter.d.ts +16 -0
  51. package/dist/infrastructure/adapters/node-file-path.adapter.js +117 -0
  52. package/dist/infrastructure/filesystem/index.d.ts +4 -0
  53. package/dist/infrastructure/filesystem/index.js +20 -0
  54. package/dist/infrastructure/filesystem/polices/index.d.ts +1 -0
  55. package/dist/infrastructure/filesystem/polices/index.js +5 -0
  56. package/dist/infrastructure/filesystem/polices/rotation-policy.d.ts +29 -0
  57. package/dist/infrastructure/filesystem/polices/rotation-policy.js +55 -0
  58. package/dist/infrastructure/filesystem/ports/file-rotator.port.d.ts +32 -0
  59. package/dist/infrastructure/filesystem/ports/file-rotator.port.js +2 -0
  60. package/dist/infrastructure/filesystem/ports/index.d.ts +1 -0
  61. package/dist/infrastructure/{datasources → filesystem/ports}/index.js +1 -1
  62. package/dist/infrastructure/filesystem/types/filesystem-datasource-options.type.d.ts +49 -0
  63. package/dist/infrastructure/filesystem/types/filesystem-datasource-options.type.js +2 -0
  64. package/dist/infrastructure/filesystem/types/filesystem-rotation.type.d.ts +19 -0
  65. package/dist/infrastructure/filesystem/types/filesystem-rotation.type.js +2 -0
  66. package/dist/infrastructure/filesystem/types/filesystem-serializer.type.d.ts +10 -0
  67. package/dist/infrastructure/filesystem/types/filesystem-serializer.type.js +2 -0
  68. package/dist/infrastructure/filesystem/types/index.d.ts +3 -0
  69. package/dist/infrastructure/filesystem/types/index.js +19 -0
  70. package/dist/infrastructure/filesystem/value-objects/file-name-pattern.vo.d.ts +22 -0
  71. package/dist/infrastructure/filesystem/value-objects/file-name-pattern.vo.js +37 -0
  72. package/dist/infrastructure/filesystem/value-objects/index.d.ts +1 -0
  73. package/dist/{domain/types → infrastructure/filesystem/value-objects}/index.js +1 -1
  74. package/dist/shared/errors/file-operation.error.d.ts +12 -0
  75. package/dist/shared/errors/file-operation.error.js +32 -0
  76. package/dist/shared/errors/fs-plugin.error.d.ts +4 -0
  77. package/dist/shared/errors/fs-plugin.error.js +11 -0
  78. package/dist/shared/errors/index.d.ts +3 -0
  79. package/dist/shared/errors/index.js +19 -0
  80. package/dist/shared/errors/rotation.error.d.ts +10 -0
  81. package/dist/shared/errors/rotation.error.js +25 -0
  82. package/install.md +520 -0
  83. package/package.json +39 -21
  84. package/dist/application/use-cases/append-log.usecase.d.ts +0 -7
  85. package/dist/application/use-cases/append-log.usecase.js +0 -19
  86. package/dist/application/use-cases/persist-log.usecase.d.ts +0 -23
  87. package/dist/application/use-cases/persist-log.usecase.js +0 -74
  88. package/dist/application/use-cases/rotate-if-needed.usecase.d.ts +0 -10
  89. package/dist/application/use-cases/rotate-if-needed.usecase.js +0 -39
  90. package/dist/domain/contracts/clock.contract.d.ts +0 -3
  91. package/dist/domain/contracts/file-rotator.contract.d.ts +0 -7
  92. package/dist/domain/contracts/index.d.ts +0 -4
  93. package/dist/domain/contracts/serializer.contract.d.ts +0 -3
  94. package/dist/domain/contracts/stream-writer.port.d.ts +0 -6
  95. package/dist/domain/types/index.d.ts +0 -1
  96. package/dist/domain/types/options.type.d.ts +0 -11
  97. package/dist/domain/types/options.type.js +0 -5
  98. package/dist/domain/value-objects/file-name-pattern.vo.d.ts +0 -4
  99. package/dist/domain/value-objects/file-name-pattern.vo.js +0 -14
  100. package/dist/domain/value-objects/rotation-policy.vo.d.ts +0 -7
  101. package/dist/domain/value-objects/rotation-policy.vo.js +0 -20
  102. package/dist/infrastructure/datasources/fs.datasource.d.ts +0 -17
  103. package/dist/infrastructure/datasources/fs.datasource.js +0 -84
  104. package/dist/infrastructure/datasources/index.d.ts +0 -1
  105. package/dist/infrastructure/fs/file-rotator.adapter.d.ts +0 -22
  106. package/dist/infrastructure/fs/file-rotator.adapter.js +0 -51
  107. package/dist/infrastructure/fs/fs-provider.d.ts +0 -15
  108. package/dist/infrastructure/fs/fs-writer.adapter.d.ts +0 -10
  109. package/dist/infrastructure/fs/fs-writer.adapter.js +0 -26
  110. package/dist/infrastructure/fs/node-clock.adapter.d.ts +0 -4
  111. package/dist/infrastructure/fs/path-utils.d.ts +0 -6
  112. package/dist/infrastructure/fs/path-utils.js +0 -26
  113. package/dist/presentation/factory/create-fs-datasource.d.ts +0 -15
  114. package/dist/presentation/factory/create-fs-datasource.js +0 -39
  115. package/dist/presentation/factory/index.d.ts +0 -1
  116. /package/dist/{domain/contracts/clock.contract.js → application/dto/rotation-check.dto.js} +0 -0
  117. /package/dist/{domain/contracts/file-rotator.contract.js → application/dto/write-operation.dto.js} +0 -0
  118. /package/dist/domain/{contracts/serializer.contract.js → ports/clock.port.js} +0 -0
  119. /package/dist/domain/{contracts/stream-writer.port.js → ports/file-path-adapter.port.js} +0 -0
@@ -1,15 +0,0 @@
1
- import { FsDatasourceService } from "../../application/services";
2
- import type { IFsSerializer } from "../../domain/contracts";
3
- export declare function createFsDatasource(input: {
4
- basePath: string;
5
- mkdir?: boolean;
6
- fileNamePattern?: string;
7
- rotation?: {
8
- by: "none" | "day" | "size";
9
- maxSizeMB?: number;
10
- maxFiles?: number;
11
- };
12
- serializer?: IFsSerializer;
13
- onRotate?: (oldPath: string, newPath: string) => void | Promise<void>;
14
- onError?: (err: unknown) => void | Promise<void>;
15
- }): FsDatasourceService;
@@ -1,39 +0,0 @@
1
- "use strict";
2
- // Ensambla el servicio de aplicación (que implementa ILogDatasource)
3
- // con los adaptadores de infraestructura. Aquí no hay lógica de negocio,
4
- // sólo wiring + defaults.
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createFsDatasource = createFsDatasource;
7
- const services_1 = require("../../application/services");
8
- const use_cases_1 = require("../../application/use-cases");
9
- const value_objects_1 = require("../../domain/value-objects");
10
- const fs_1 = require("../../infrastructure/fs");
11
- function createFsDatasource(input) {
12
- // 1) Defaults de VO y opciones
13
- const pattern = new value_objects_1.FileNamePattern(input.fileNamePattern ?? "app-{yyyy}{MM}{dd}.log");
14
- const rotation = input.rotation
15
- ? new value_objects_1.RotationPolicy(input.rotation.by, input.rotation.maxSizeMB, input.rotation.maxFiles)
16
- : new value_objects_1.RotationPolicy("day");
17
- const opts = {
18
- basePath: input.basePath,
19
- mkdir: !!input.mkdir,
20
- pattern,
21
- rotation,
22
- serializer: input.serializer ?? { serialize: (x) => JSON.stringify(x) },
23
- onRotate: input.onRotate,
24
- onError: input.onError,
25
- };
26
- // 2) Adapters de infraestructura
27
- const fs = (0, fs_1.createFsProvider)();
28
- const clock = new fs_1.NodeClockAdapter();
29
- const rotator = new fs_1.FileRotatorAdapter(fs, opts.basePath, clock, opts.pattern, !!opts.mkdir);
30
- // 3) Casos de uso (application)
31
- const rotateUC = new use_cases_1.RotateIfNeededUseCase(opts.rotation, rotator, clock);
32
- const appendUC = new use_cases_1.AppendLogUseCase(opts.serializer);
33
- // 4) Factory para abrir writers en el path que diga el rotator
34
- const openWriter = (path) => new fs_1.FsWriterAdapter(fs, path);
35
- // 5) Orquestador principal (application) que usará core: ILogDatasource
36
- const persistUC = new use_cases_1.PersistLogUseCase(rotateUC, appendUC, rotator, openWriter, opts.onRotate, opts.onError);
37
- // 6) Servicio que implementa ILogDatasource (core)
38
- return new services_1.FsDatasourceService(persistUC);
39
- }
@@ -1 +0,0 @@
1
- export * from "./create-fs-datasource";