@trebired/logger 1.1.3 → 2.1.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/CHANGELOG.md +24 -0
- package/README.md +152 -3
- package/dist/browser/console_transport.d.ts +5 -0
- package/dist/browser/console_transport.d.ts.map +1 -0
- package/dist/browser/console_transport.js +51 -0
- package/dist/browser/console_transport.js.map +1 -0
- package/dist/browser/create_log.d.ts +4 -0
- package/dist/browser/create_log.d.ts.map +1 -0
- package/dist/browser/create_log.js +234 -0
- package/dist/browser/create_log.js.map +1 -0
- package/dist/browser/index.d.ts +4 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +3 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/react.d.ts +30 -0
- package/dist/browser/react.d.ts.map +1 -0
- package/dist/browser/react.js +44 -0
- package/dist/browser/react.js.map +1 -0
- package/dist/core/create_log.d.ts.map +1 -1
- package/dist/core/create_log.js +121 -145
- package/dist/core/create_log.js.map +1 -1
- package/dist/core/shared.d.ts +31 -0
- package/dist/core/shared.d.ts.map +1 -0
- package/dist/core/shared.js +144 -0
- package/dist/core/shared.js.map +1 -0
- package/dist/format/console.d.ts +2 -2
- package/dist/format/console.d.ts.map +1 -1
- package/dist/format/console.js +40 -21
- package/dist/format/console.js.map +1 -1
- package/dist/format/options.d.ts +4 -0
- package/dist/format/options.d.ts.map +1 -0
- package/dist/format/options.js +19 -0
- package/dist/format/options.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/storage/backend/index.d.ts +6 -0
- package/dist/storage/backend/index.d.ts.map +1 -0
- package/dist/storage/backend/index.js +19 -0
- package/dist/storage/backend/index.js.map +1 -0
- package/dist/storage/backend/js.d.ts +4 -0
- package/dist/storage/backend/js.d.ts.map +1 -0
- package/dist/storage/backend/js.js +179 -0
- package/dist/storage/backend/js.js.map +1 -0
- package/dist/storage/backend/native.d.ts +6 -0
- package/dist/storage/backend/native.d.ts.map +1 -0
- package/dist/storage/backend/native.js +89 -0
- package/dist/storage/backend/native.js.map +1 -0
- package/dist/storage/backend/types.d.ts +57 -0
- package/dist/storage/backend/types.d.ts.map +1 -0
- package/dist/storage/backend/types.js +2 -0
- package/dist/storage/backend/types.js.map +1 -0
- package/dist/storage/export.d.ts +5 -0
- package/dist/storage/export.d.ts.map +1 -0
- package/dist/storage/export.js +124 -0
- package/dist/storage/export.js.map +1 -0
- package/dist/storage/names.d.ts +6 -2
- package/dist/storage/names.d.ts.map +1 -1
- package/dist/storage/names.js +66 -31
- package/dist/storage/names.js.map +1 -1
- package/dist/storage/partitions/delete.d.ts +5 -0
- package/dist/storage/partitions/delete.d.ts.map +1 -0
- package/dist/storage/partitions/delete.js +121 -0
- package/dist/storage/partitions/delete.js.map +1 -0
- package/dist/storage/partitions/files.d.ts +12 -0
- package/dist/storage/partitions/files.d.ts.map +1 -0
- package/dist/storage/partitions/files.js +142 -0
- package/dist/storage/partitions/files.js.map +1 -0
- package/dist/storage/partitions/internal.d.ts +47 -0
- package/dist/storage/partitions/internal.d.ts.map +1 -0
- package/dist/storage/partitions/internal.js +35 -0
- package/dist/storage/partitions/internal.js.map +1 -0
- package/dist/storage/partitions/markers.d.ts +8 -0
- package/dist/storage/partitions/markers.d.ts.map +1 -0
- package/dist/storage/partitions/markers.js +88 -0
- package/dist/storage/partitions/markers.js.map +1 -0
- package/dist/storage/partitions/public.d.ts +11 -0
- package/dist/storage/partitions/public.d.ts.map +1 -0
- package/dist/storage/partitions/public.js +79 -0
- package/dist/storage/partitions/public.js.map +1 -0
- package/dist/storage/partitions/records.d.ts +9 -0
- package/dist/storage/partitions/records.d.ts.map +1 -0
- package/dist/storage/partitions/records.js +73 -0
- package/dist/storage/partitions/records.js.map +1 -0
- package/dist/storage/partitions/transforms.d.ts +6 -0
- package/dist/storage/partitions/transforms.d.ts.map +1 -0
- package/dist/storage/partitions/transforms.js +59 -0
- package/dist/storage/partitions/transforms.js.map +1 -0
- package/dist/storage/partitions.d.ts +4 -0
- package/dist/storage/partitions.d.ts.map +1 -0
- package/dist/storage/partitions.js +4 -0
- package/dist/storage/partitions.js.map +1 -0
- package/dist/storage/query.d.ts +3 -3
- package/dist/storage/query.d.ts.map +1 -1
- package/dist/storage/query.js +29 -31
- package/dist/storage/query.js.map +1 -1
- package/dist/storage/retention.d.ts.map +1 -1
- package/dist/storage/retention.js +2 -5
- package/dist/storage/retention.js.map +1 -1
- package/dist/storage/walk.d.ts.map +1 -1
- package/dist/storage/walk.js +3 -20
- package/dist/storage/walk.js.map +1 -1
- package/dist/storage/write.d.ts +1 -2
- package/dist/storage/write.d.ts.map +1 -1
- package/dist/storage/write.js +10 -12
- package/dist/storage/write.js.map +1 -1
- package/dist/stream/index.d.ts +11 -3
- package/dist/stream/index.d.ts.map +1 -1
- package/dist/stream/index.js +40 -4
- package/dist/stream/index.js.map +1 -1
- package/dist/types/browser.d.ts +54 -0
- package/dist/types/browser.d.ts.map +1 -0
- package/dist/types/browser.js +2 -0
- package/dist/types/browser.js.map +1 -0
- package/dist/types/common.d.ts +73 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +2 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/export.d.ts +53 -0
- package/dist/types/export.d.ts.map +1 -0
- package/dist/types/export.js +2 -0
- package/dist/types/export.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/partitions.d.ts +92 -0
- package/dist/types/partitions.d.ts.map +1 -0
- package/dist/types/partitions.js +2 -0
- package/dist/types/partitions.js.map +1 -0
- package/dist/types/query.d.ts +49 -0
- package/dist/types/query.d.ts.map +1 -0
- package/dist/types/query.js +2 -0
- package/dist/types/query.js.map +1 -0
- package/dist/types/server.d.ts +79 -0
- package/dist/types/server.d.ts.map +1 -0
- package/dist/types/server.js +2 -0
- package/dist/types/server.js.map +1 -0
- package/dist/types.d.ts +1 -168
- package/dist/types.d.ts.map +1 -1
- package/package.json +32 -2
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { PartitionInfo } from "../../types.js";
|
|
2
|
+
import type { WalkedLogFile } from "../names.js";
|
|
3
|
+
type PartitionMarker = {
|
|
4
|
+
name: string;
|
|
5
|
+
temporary: boolean;
|
|
6
|
+
created_at: string;
|
|
7
|
+
updated_at: string;
|
|
8
|
+
};
|
|
9
|
+
type PartitionRecord = {
|
|
10
|
+
dir: string;
|
|
11
|
+
name: string;
|
|
12
|
+
path: string;
|
|
13
|
+
marker: PartitionMarker;
|
|
14
|
+
};
|
|
15
|
+
type PartitionWriteOptions = {
|
|
16
|
+
temporary?: boolean;
|
|
17
|
+
preserveTemporary?: boolean;
|
|
18
|
+
createdAt?: string;
|
|
19
|
+
updatedAt?: string;
|
|
20
|
+
preserveCreatedAt?: boolean;
|
|
21
|
+
};
|
|
22
|
+
type PartitionTransformOptions = {
|
|
23
|
+
source: PartitionRecord;
|
|
24
|
+
targetDir: string;
|
|
25
|
+
targetName: string;
|
|
26
|
+
deleteSource: boolean;
|
|
27
|
+
targetTemporary: boolean;
|
|
28
|
+
preserveSourceCreatedAt: boolean;
|
|
29
|
+
};
|
|
30
|
+
type PartitionDeleteCandidate = {
|
|
31
|
+
info: PartitionInfo;
|
|
32
|
+
record: PartitionRecord;
|
|
33
|
+
};
|
|
34
|
+
type DeleteLogCandidate = {
|
|
35
|
+
file: WalkedLogFile;
|
|
36
|
+
bytes: number;
|
|
37
|
+
logs: number;
|
|
38
|
+
};
|
|
39
|
+
declare function resolveDir(input: string): string;
|
|
40
|
+
declare function partitionRootPath(dir: string, partition: string): string;
|
|
41
|
+
declare function pathExists(targetPath: string): Promise<boolean>;
|
|
42
|
+
declare function fileStamp(file: WalkedLogFile): string;
|
|
43
|
+
declare function partitionAgeReferenceMs(info: PartitionInfo): number;
|
|
44
|
+
declare function cutoffMsForDays(days: number | undefined): number | null;
|
|
45
|
+
export { cutoffMsForDays, fileStamp, partitionAgeReferenceMs, partitionRootPath, pathExists, resolveDir, };
|
|
46
|
+
export type { DeleteLogCandidate, PartitionDeleteCandidate, PartitionMarker, PartitionRecord, PartitionTransformOptions, PartitionWriteOptions, };
|
|
47
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/storage/partitions/internal.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC/B,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,OAAO,CAAC;IACzB,uBAAuB,EAAE,OAAO,CAAC;CAClC,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC9B,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,iBAAS,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGzC;AAED,iBAAS,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED,iBAAe,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO9D;AAED,iBAAS,SAAS,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAE9C;AAED,iBAAS,uBAAuB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAI5D;AAED,iBAAS,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAIhE;AAED,OAAO,EACL,eAAe,EACf,SAAS,EACT,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,UAAU,GACX,CAAC;AACF,YAAY,EACV,kBAAkB,EAClB,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,yBAAyB,EACzB,qBAAqB,GACtB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { toString } from "../../utils/values.js";
|
|
4
|
+
function resolveDir(input) {
|
|
5
|
+
const raw = toString(input).trim();
|
|
6
|
+
return raw ? path.resolve(raw) : "";
|
|
7
|
+
}
|
|
8
|
+
function partitionRootPath(dir, partition) {
|
|
9
|
+
return path.join(dir, partition);
|
|
10
|
+
}
|
|
11
|
+
async function pathExists(targetPath) {
|
|
12
|
+
try {
|
|
13
|
+
await fs.promises.access(targetPath);
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function fileStamp(file) {
|
|
21
|
+
return `${file.day}-${file.hour}`;
|
|
22
|
+
}
|
|
23
|
+
function partitionAgeReferenceMs(info) {
|
|
24
|
+
const reference = info.last_activity_at || info.updated_at || info.created_at;
|
|
25
|
+
const parsed = Date.parse(reference);
|
|
26
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
27
|
+
}
|
|
28
|
+
function cutoffMsForDays(days) {
|
|
29
|
+
const value = Number(days);
|
|
30
|
+
if (!Number.isFinite(value) || value <= 0)
|
|
31
|
+
return null;
|
|
32
|
+
return Date.now() - value * 24 * 60 * 60 * 1000;
|
|
33
|
+
}
|
|
34
|
+
export { cutoffMsForDays, fileStamp, partitionAgeReferenceMs, partitionRootPath, pathExists, resolveDir, };
|
|
35
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/storage/partitions/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AA6CjD,SAAS,UAAU,CAAC,KAAa;IAC/B,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IACnC,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACtC,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAW,EAAE,SAAiB;IACvD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;AACnC,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,UAAkB;IAC1C,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,IAAmB;IACpC,OAAO,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;AACpC,CAAC;AAED,SAAS,uBAAuB,CAAC,IAAmB;IAClD,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC;IAC9E,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACrC,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,eAAe,CAAC,IAAwB;IAC/C,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACvD,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAClD,CAAC;AAED,OAAO,EACL,eAAe,EACf,SAAS,EACT,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,UAAU,GACX,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type PartitionMarker, type PartitionWriteOptions } from "./internal.js";
|
|
2
|
+
declare function readPartitionMarkerFromRoot(rootDir: string, expectedName?: string): Promise<PartitionMarker | null>;
|
|
3
|
+
declare function readPartitionMarkerFromRootSync(rootDir: string, expectedName?: string): PartitionMarker | null;
|
|
4
|
+
declare function writePartitionMarker(rootDir: string, marker: PartitionMarker): Promise<void>;
|
|
5
|
+
declare function touchPartitionMarker(dir: string, partition: string, options?: PartitionWriteOptions): Promise<PartitionMarker>;
|
|
6
|
+
declare function touchPartitionMarkerSync(dir: string, partition: string, options?: PartitionWriteOptions): PartitionMarker;
|
|
7
|
+
export { readPartitionMarkerFromRoot, readPartitionMarkerFromRootSync, touchPartitionMarker, touchPartitionMarkerSync, writePartitionMarker, };
|
|
8
|
+
//# sourceMappingURL=markers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markers.d.ts","sourceRoot":"","sources":["../../../src/storage/partitions/markers.ts"],"names":[],"mappings":"AAKA,OAAO,EAAiC,KAAK,eAAe,EAAE,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAgBhH,iBAAe,2BAA2B,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAQlH;AAED,iBAAS,+BAA+B,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAQvG;AAkBD,iBAAe,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAG3F;AAOD,iBAAe,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,eAAe,CAAC,CASjI;AAED,iBAAS,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,qBAA0B,GAAG,eAAe,CAStH;AAED,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,EAC/B,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,GACrB,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { PARTITION_MARKER_FILE } from "../../constants.js";
|
|
4
|
+
import { sanitizePartitionName } from "../names.js";
|
|
5
|
+
import { partitionRootPath, resolveDir } from "./internal.js";
|
|
6
|
+
function isValidMarker(value, expectedName) {
|
|
7
|
+
if (!value || typeof value !== "object")
|
|
8
|
+
return false;
|
|
9
|
+
const marker = value;
|
|
10
|
+
if (String(marker.name || "") !== (expectedName || String(marker.name || "")))
|
|
11
|
+
return false;
|
|
12
|
+
if (typeof marker.temporary !== "boolean")
|
|
13
|
+
return false;
|
|
14
|
+
if (!String(marker.created_at || "").trim())
|
|
15
|
+
return false;
|
|
16
|
+
if (!String(marker.updated_at || "").trim())
|
|
17
|
+
return false;
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
function markerPath(rootDir) {
|
|
21
|
+
return path.join(rootDir, PARTITION_MARKER_FILE);
|
|
22
|
+
}
|
|
23
|
+
async function readPartitionMarkerFromRoot(rootDir, expectedName) {
|
|
24
|
+
try {
|
|
25
|
+
const text = await fs.promises.readFile(markerPath(rootDir), "utf8");
|
|
26
|
+
const parsed = JSON.parse(text);
|
|
27
|
+
return isValidMarker(parsed, expectedName) ? parsed : null;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function readPartitionMarkerFromRootSync(rootDir, expectedName) {
|
|
34
|
+
try {
|
|
35
|
+
const text = fs.readFileSync(markerPath(rootDir), "utf8");
|
|
36
|
+
const parsed = JSON.parse(text);
|
|
37
|
+
return isValidMarker(parsed, expectedName) ? parsed : null;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function nextMarker(existing, name, options = {}) {
|
|
44
|
+
const now = options.updatedAt || new Date().toISOString();
|
|
45
|
+
const created_at = options.createdAt
|
|
46
|
+
|| ((options.preserveCreatedAt !== false && existing?.created_at) ? existing.created_at : now);
|
|
47
|
+
const temporary = typeof options.temporary === "boolean"
|
|
48
|
+
? options.temporary
|
|
49
|
+
: (options.preserveTemporary !== false && existing ? existing.temporary : false);
|
|
50
|
+
return {
|
|
51
|
+
name,
|
|
52
|
+
temporary,
|
|
53
|
+
created_at,
|
|
54
|
+
updated_at: now,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
async function writePartitionMarker(rootDir, marker) {
|
|
58
|
+
await fs.promises.mkdir(rootDir, { recursive: true });
|
|
59
|
+
await fs.promises.writeFile(markerPath(rootDir), `${JSON.stringify(marker)}\n`, "utf8");
|
|
60
|
+
}
|
|
61
|
+
function writePartitionMarkerSync(rootDir, marker) {
|
|
62
|
+
fs.mkdirSync(rootDir, { recursive: true });
|
|
63
|
+
fs.writeFileSync(markerPath(rootDir), `${JSON.stringify(marker)}\n`, "utf8");
|
|
64
|
+
}
|
|
65
|
+
async function touchPartitionMarker(dir, partition, options = {}) {
|
|
66
|
+
const baseDir = resolveDir(dir);
|
|
67
|
+
if (!baseDir)
|
|
68
|
+
throw new Error("missing-log-dir");
|
|
69
|
+
const name = sanitizePartitionName(partition);
|
|
70
|
+
const rootDir = partitionRootPath(baseDir, name);
|
|
71
|
+
const existing = await readPartitionMarkerFromRoot(rootDir, name);
|
|
72
|
+
const marker = nextMarker(existing, name, options);
|
|
73
|
+
await writePartitionMarker(rootDir, marker);
|
|
74
|
+
return marker;
|
|
75
|
+
}
|
|
76
|
+
function touchPartitionMarkerSync(dir, partition, options = {}) {
|
|
77
|
+
const baseDir = resolveDir(dir);
|
|
78
|
+
if (!baseDir)
|
|
79
|
+
throw new Error("missing-log-dir");
|
|
80
|
+
const name = sanitizePartitionName(partition);
|
|
81
|
+
const rootDir = partitionRootPath(baseDir, name);
|
|
82
|
+
const existing = readPartitionMarkerFromRootSync(rootDir, name);
|
|
83
|
+
const marker = nextMarker(existing, name, options);
|
|
84
|
+
writePartitionMarkerSync(rootDir, marker);
|
|
85
|
+
return marker;
|
|
86
|
+
}
|
|
87
|
+
export { readPartitionMarkerFromRoot, readPartitionMarkerFromRootSync, touchPartitionMarker, touchPartitionMarkerSync, writePartitionMarker, };
|
|
88
|
+
//# sourceMappingURL=markers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markers.js","sourceRoot":"","sources":["../../../src/storage/partitions/markers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAoD,MAAM,eAAe,CAAC;AAEhH,SAAS,aAAa,CAAC,KAAc,EAAE,YAAqB;IAC1D,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,MAAM,MAAM,GAAG,KAAgC,CAAC;IAChD,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,KAAK,CAAC,YAAY,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5F,IAAI,OAAO,MAAM,CAAC,SAAS,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACxD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;QAAE,OAAO,KAAK,CAAC;IAC1D,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;QAAE,OAAO,KAAK,CAAC;IAC1D,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,UAAU,CAAC,OAAe;IACjC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC;AACnD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,GAAG,MAAM,2BAA2B,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClE,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACnD,MAAM,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC5C,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,wBAAwB,CAAC,GAAW,EAAE,SAAiB,EAAE,UAAiC,EAAE;IACnG,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAChC,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACjD,MAAM,QAAQ,GAAG,+BAA+B,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAChE,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACnD,wBAAwB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC1C,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,EAC/B,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,GACrB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CopyPartitionOptions, CreatePartitionOptions, DeletePartitionResult, MergePartitionOptions, MovePartitionOptions, PartitionInfo, RenamePartitionOptions } from "../../types.js";
|
|
2
|
+
declare function createPartition(dir: string, partition: string, options?: CreatePartitionOptions): Promise<PartitionInfo>;
|
|
3
|
+
declare function listPartitions(dir: string): Promise<PartitionInfo[]>;
|
|
4
|
+
declare function getPartitionInfo(dir: string, partition: string): Promise<PartitionInfo | null>;
|
|
5
|
+
declare function renamePartition(dir: string, options: RenamePartitionOptions): Promise<PartitionInfo>;
|
|
6
|
+
declare function movePartition(options: MovePartitionOptions): Promise<PartitionInfo>;
|
|
7
|
+
declare function copyPartition(options: CopyPartitionOptions): Promise<PartitionInfo>;
|
|
8
|
+
declare function mergePartition(dir: string, options: MergePartitionOptions): Promise<PartitionInfo>;
|
|
9
|
+
declare function deletePartition(dir: string, partition: string): Promise<DeletePartitionResult>;
|
|
10
|
+
export { copyPartition, createPartition, deletePartition, getPartitionInfo, listPartitions, mergePartition, movePartition, renamePartition, };
|
|
11
|
+
//# sourceMappingURL=public.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/storage/partitions/public.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AAQxB,iBAAe,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,GAAG,OAAO,CAAC,aAAa,CAAC,CAa3H;AAED,iBAAe,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAInE;AAED,iBAAe,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAG7F;AAED,iBAAe,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,aAAa,CAAC,CAUnG;AAED,iBAAe,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,CAWlF;AAED,iBAAe,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,CAalF;AAED,iBAAe,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,aAAa,CAAC,CAIjG;AAED,iBAAe,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAE7F;AAED,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,aAAa,EACb,eAAe,GAChB,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { sanitizePartitionName } from "../names.js";
|
|
2
|
+
import { deletePartitions } from "./delete.js";
|
|
3
|
+
import { writePartitionMarker } from "./markers.js";
|
|
4
|
+
import { collectPartitionRecords, getPartitionRecord, partitionInfoFromRecord, requirePartitionRecord } from "./records.js";
|
|
5
|
+
import { mergePartitionRecord, transformPartition } from "./transforms.js";
|
|
6
|
+
import { partitionRootPath, pathExists, resolveDir } from "./internal.js";
|
|
7
|
+
async function createPartition(dir, partition, options = {}) {
|
|
8
|
+
const baseDir = resolveDir(dir);
|
|
9
|
+
if (!baseDir)
|
|
10
|
+
throw new Error("missing-log-dir");
|
|
11
|
+
const name = sanitizePartitionName(partition);
|
|
12
|
+
const rootDir = partitionRootPath(baseDir, name);
|
|
13
|
+
if (await pathExists(rootDir))
|
|
14
|
+
throw new Error(`partition-already-exists: ${name}`);
|
|
15
|
+
await writePartitionMarker(rootDir, {
|
|
16
|
+
name,
|
|
17
|
+
temporary: options.temporary === true,
|
|
18
|
+
created_at: new Date().toISOString(),
|
|
19
|
+
updated_at: new Date().toISOString(),
|
|
20
|
+
});
|
|
21
|
+
return (await getPartitionInfo(baseDir, name));
|
|
22
|
+
}
|
|
23
|
+
async function listPartitions(dir) {
|
|
24
|
+
const records = await collectPartitionRecords(dir);
|
|
25
|
+
const items = await Promise.all(records.map((record) => partitionInfoFromRecord(record)));
|
|
26
|
+
return items.sort((a, b) => a.name.localeCompare(b.name));
|
|
27
|
+
}
|
|
28
|
+
async function getPartitionInfo(dir, partition) {
|
|
29
|
+
const record = await getPartitionRecord(dir, partition);
|
|
30
|
+
return record ? partitionInfoFromRecord(record) : null;
|
|
31
|
+
}
|
|
32
|
+
async function renamePartition(dir, options) {
|
|
33
|
+
const source = await requirePartitionRecord(dir, options.from);
|
|
34
|
+
return transformPartition({
|
|
35
|
+
source,
|
|
36
|
+
targetDir: source.dir,
|
|
37
|
+
targetName: sanitizePartitionName(options.to),
|
|
38
|
+
deleteSource: true,
|
|
39
|
+
targetTemporary: source.marker.temporary,
|
|
40
|
+
preserveSourceCreatedAt: true,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async function movePartition(options) {
|
|
44
|
+
const source = await requirePartitionRecord(options.fromDir, options.from);
|
|
45
|
+
const targetName = sanitizePartitionName(options.to || source.name);
|
|
46
|
+
return transformPartition({
|
|
47
|
+
source,
|
|
48
|
+
targetDir: resolveDir(options.toDir),
|
|
49
|
+
targetName,
|
|
50
|
+
deleteSource: true,
|
|
51
|
+
targetTemporary: source.marker.temporary,
|
|
52
|
+
preserveSourceCreatedAt: true,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async function copyPartition(options) {
|
|
56
|
+
const source = await requirePartitionRecord(options.fromDir, options.from);
|
|
57
|
+
const targetDir = resolveDir(options.toDir);
|
|
58
|
+
const targetName = sanitizePartitionName(options.to || source.name);
|
|
59
|
+
if (source.dir === targetDir && source.name === targetName)
|
|
60
|
+
throw new Error(`partition-already-exists: ${targetName}`);
|
|
61
|
+
return transformPartition({
|
|
62
|
+
source,
|
|
63
|
+
targetDir,
|
|
64
|
+
targetName,
|
|
65
|
+
deleteSource: false,
|
|
66
|
+
targetTemporary: source.marker.temporary,
|
|
67
|
+
preserveSourceCreatedAt: false,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async function mergePartition(dir, options) {
|
|
71
|
+
const source = await requirePartitionRecord(dir, options.from);
|
|
72
|
+
const target = await requirePartitionRecord(dir, options.to);
|
|
73
|
+
return mergePartitionRecord(source, target, target.marker.temporary);
|
|
74
|
+
}
|
|
75
|
+
async function deletePartition(dir, partition) {
|
|
76
|
+
return deletePartitions(dir, { partitions: [partition] });
|
|
77
|
+
}
|
|
78
|
+
export { copyPartition, createPartition, deletePartition, getPartitionInfo, listPartitions, mergePartition, movePartition, renamePartition, };
|
|
79
|
+
//# sourceMappingURL=public.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/storage/partitions/public.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAA+B,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC5H,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE1E,KAAK,UAAU,eAAe,CAAC,GAAW,EAAE,SAAiB,EAAE,UAAkC,EAAE;IACjG,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAChC,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACjD,IAAI,MAAM,UAAU,CAAC,OAAO,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,EAAE,CAAC,CAAC;IACpF,MAAM,oBAAoB,CAAC,OAAO,EAAE;QAClC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G,MAAM,sBAAsB,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IAC7D,OAAO,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AACvE,CAAC;AAED,KAAK,UAAU,eAAe,CAAC,GAAW,EAAE,SAAiB;IAC3D,OAAO,gBAAgB,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,aAAa,EACb,eAAe,GAChB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PartitionInfo } from "../../types.js";
|
|
2
|
+
import { type PartitionMarker, type PartitionRecord } from "./internal.js";
|
|
3
|
+
declare function collectPartitionRecords(dir: string): Promise<PartitionRecord[]>;
|
|
4
|
+
declare function getPartitionRecord(dir: string, partition: string): Promise<PartitionRecord | null>;
|
|
5
|
+
declare function requirePartitionRecord(dir: string, partition: string): Promise<PartitionRecord>;
|
|
6
|
+
declare function partitionInfoFromRecord(record: PartitionRecord): Promise<PartitionInfo>;
|
|
7
|
+
declare function partitionMarkerMap(dir: string): Promise<Map<string, PartitionMarker>>;
|
|
8
|
+
export { collectPartitionRecords, getPartitionRecord, partitionInfoFromRecord, partitionMarkerMap, requirePartitionRecord, };
|
|
9
|
+
//# sourceMappingURL=records.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../../src/storage/partitions/records.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAIpD,OAAO,EAAiC,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAE1G,iBAAe,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAsB9E;AAED,iBAAe,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAQjG;AAED,iBAAe,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAI9F;AAED,iBAAe,uBAAuB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC,CAmBtF;AAED,iBAAe,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAGpF;AAED,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,GACvB,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { getStorageBackend } from "../backend/index.js";
|
|
4
|
+
import { sanitizePartitionName } from "../names.js";
|
|
5
|
+
import { readPartitionMarkerFromRoot } from "./markers.js";
|
|
6
|
+
import { partitionRootPath, resolveDir } from "./internal.js";
|
|
7
|
+
async function collectPartitionRecords(dir) {
|
|
8
|
+
const baseDir = resolveDir(dir);
|
|
9
|
+
if (!baseDir)
|
|
10
|
+
return [];
|
|
11
|
+
let entries = [];
|
|
12
|
+
try {
|
|
13
|
+
entries = await fs.promises.readdir(baseDir, { withFileTypes: true });
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
const out = [];
|
|
19
|
+
for (const entry of entries) {
|
|
20
|
+
if (!entry.isDirectory())
|
|
21
|
+
continue;
|
|
22
|
+
const name = entry.name;
|
|
23
|
+
const rootDir = path.join(baseDir, name);
|
|
24
|
+
const marker = await readPartitionMarkerFromRoot(rootDir, name);
|
|
25
|
+
if (!marker)
|
|
26
|
+
continue;
|
|
27
|
+
out.push({ dir: baseDir, name, path: rootDir, marker });
|
|
28
|
+
}
|
|
29
|
+
out.sort((a, b) => a.name.localeCompare(b.name));
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
async function getPartitionRecord(dir, partition) {
|
|
33
|
+
const baseDir = resolveDir(dir);
|
|
34
|
+
if (!baseDir)
|
|
35
|
+
return null;
|
|
36
|
+
const name = sanitizePartitionName(partition);
|
|
37
|
+
const rootDir = partitionRootPath(baseDir, name);
|
|
38
|
+
const marker = await readPartitionMarkerFromRoot(rootDir, name);
|
|
39
|
+
if (!marker)
|
|
40
|
+
return null;
|
|
41
|
+
return { dir: baseDir, name, path: rootDir, marker };
|
|
42
|
+
}
|
|
43
|
+
async function requirePartitionRecord(dir, partition) {
|
|
44
|
+
const record = await getPartitionRecord(dir, partition);
|
|
45
|
+
if (!record)
|
|
46
|
+
throw new Error(`partition-not-found: ${partition}`);
|
|
47
|
+
return record;
|
|
48
|
+
}
|
|
49
|
+
async function partitionInfoFromRecord(record) {
|
|
50
|
+
const backend = getStorageBackend();
|
|
51
|
+
const snapshot = await backend.scanPartitions(record.dir, [record.name]);
|
|
52
|
+
const summary = snapshot.partitions[0];
|
|
53
|
+
return {
|
|
54
|
+
name: record.name,
|
|
55
|
+
path: record.path,
|
|
56
|
+
temporary: record.marker.temporary,
|
|
57
|
+
created_at: record.marker.created_at,
|
|
58
|
+
updated_at: record.marker.updated_at,
|
|
59
|
+
last_activity_at: summary?.lastActivityAt || null,
|
|
60
|
+
total: {
|
|
61
|
+
logs: summary?.total.logs || 0,
|
|
62
|
+
dirs: summary?.total.dirs || 0,
|
|
63
|
+
files: summary?.total.files || 0,
|
|
64
|
+
bytes: summary?.total.bytes || 0,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
async function partitionMarkerMap(dir) {
|
|
69
|
+
const records = await collectPartitionRecords(dir);
|
|
70
|
+
return new Map(records.map((record) => [record.name, record.marker]));
|
|
71
|
+
}
|
|
72
|
+
export { collectPartitionRecords, getPartitionRecord, partitionInfoFromRecord, partitionMarkerMap, requirePartitionRecord, };
|
|
73
|
+
//# sourceMappingURL=records.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.js","sourceRoot":"","sources":["../../../src/storage/partitions/records.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAA8C,MAAM,eAAe,CAAC;AAE1G,KAAK,UAAU,uBAAuB,CAAC,GAAW;IAChD,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAChC,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IACxB,IAAI,OAAO,GAAgB,EAAE,CAAC;IAC9B,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IACxE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,GAAG,GAAsB,EAAE,CAAC;IAClC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;YAAE,SAAS;QACnC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACxB,MAAM,OAAO,GAAG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 @@
|
|
|
1
|
+
import type { PartitionInfo } from "../../types.js";
|
|
2
|
+
import { type PartitionRecord, type PartitionTransformOptions } from "./internal.js";
|
|
3
|
+
declare function transformPartition(options: PartitionTransformOptions): Promise<PartitionInfo>;
|
|
4
|
+
declare function mergePartitionRecord(source: PartitionRecord, target: PartitionRecord, temporary: boolean): Promise<PartitionInfo>;
|
|
5
|
+
export { mergePartitionRecord, transformPartition };
|
|
6
|
+
//# sourceMappingURL=transforms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transforms.d.ts","sourceRoot":"","sources":["../../../src/storage/partitions/transforms.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAKpD,OAAO,EAA6C,KAAK,eAAe,EAAE,KAAK,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAEhI,iBAAe,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,aAAa,CAAC,CAmC5F;AAED,iBAAe,oBAAoB,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAWhI;AAED,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { sanitizePartitionName } from "../names.js";
|
|
4
|
+
import { writePartitionMarker } from "./markers.js";
|
|
5
|
+
import { getPartitionInfo } from "./public.js";
|
|
6
|
+
import { writePartitionFiles } from "./files.js";
|
|
7
|
+
import { partitionRootPath, pathExists, resolveDir } from "./internal.js";
|
|
8
|
+
async function transformPartition(options) {
|
|
9
|
+
const targetDir = resolveDir(options.targetDir);
|
|
10
|
+
if (!targetDir)
|
|
11
|
+
throw new Error("missing-log-dir");
|
|
12
|
+
const targetName = sanitizePartitionName(options.targetName);
|
|
13
|
+
const targetRoot = partitionRootPath(targetDir, targetName);
|
|
14
|
+
if (options.source.path === targetRoot) {
|
|
15
|
+
await writePartitionMarker(targetRoot, {
|
|
16
|
+
name: targetName,
|
|
17
|
+
temporary: options.targetTemporary,
|
|
18
|
+
created_at: options.source.marker.created_at,
|
|
19
|
+
updated_at: new Date().toISOString(),
|
|
20
|
+
});
|
|
21
|
+
return (await getPartitionInfo(targetDir, targetName));
|
|
22
|
+
}
|
|
23
|
+
if (await pathExists(targetRoot))
|
|
24
|
+
throw new Error(`partition-already-exists: ${targetName}`);
|
|
25
|
+
const tempRoot = path.join(targetDir, `.trebired-partition-build-${Date.now()}-${Math.random().toString(16).slice(2)}`);
|
|
26
|
+
try {
|
|
27
|
+
await fs.promises.mkdir(targetDir, { recursive: true });
|
|
28
|
+
await writePartitionFiles(options.source, tempRoot, targetName, false);
|
|
29
|
+
await writePartitionMarker(tempRoot, {
|
|
30
|
+
name: targetName,
|
|
31
|
+
temporary: options.targetTemporary,
|
|
32
|
+
created_at: options.preserveSourceCreatedAt ? options.source.marker.created_at : new Date().toISOString(),
|
|
33
|
+
updated_at: new Date().toISOString(),
|
|
34
|
+
});
|
|
35
|
+
await fs.promises.rename(tempRoot, targetRoot);
|
|
36
|
+
if (options.deleteSource)
|
|
37
|
+
await fs.promises.rm(options.source.path, { recursive: true, force: true });
|
|
38
|
+
return (await getPartitionInfo(targetDir, targetName));
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
await fs.promises.rm(tempRoot, { recursive: true, force: true }).catch(() => { });
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async function mergePartitionRecord(source, target, temporary) {
|
|
46
|
+
if (source.path === target.path)
|
|
47
|
+
throw new Error(`partition-merge-target-same-as-source: ${source.name}`);
|
|
48
|
+
await writePartitionFiles(source, target.path, target.name, true);
|
|
49
|
+
await writePartitionMarker(target.path, {
|
|
50
|
+
name: target.name,
|
|
51
|
+
temporary,
|
|
52
|
+
created_at: target.marker.created_at,
|
|
53
|
+
updated_at: new Date().toISOString(),
|
|
54
|
+
});
|
|
55
|
+
await fs.promises.rm(source.path, { recursive: true, force: true });
|
|
56
|
+
return (await getPartitionInfo(target.dir, target.name));
|
|
57
|
+
}
|
|
58
|
+
export { mergePartitionRecord, transformPartition };
|
|
59
|
+
//# sourceMappingURL=transforms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transforms.js","sourceRoot":"","sources":["../../../src/storage/partitions/transforms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,UAAU,EAAwD,MAAM,eAAe,CAAC;AAEhI,KAAK,UAAU,kBAAkB,CAAC,OAAkC;IAClE,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChD,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACnD,MAAM,UAAU,GAAG,qBAAqB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC7D,MAAM,UAAU,GAAG,iBAAiB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAE5D,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACvC,MAAM,oBAAoB,CAAC,UAAU,EAAE;YACrC,IAAI,EAAE,UAAU;YAChB,SAAS,EAAE,OAAO,CAAC,eAAe;YAClC,UAAU,EAAE,OAAO,CAAC,MAAM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@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { deleteLogs, deletePartitions } from "./partitions/delete.js";
|
|
2
|
+
export { copyPartition, createPartition, deletePartition, getPartitionInfo, listPartitions, mergePartition, movePartition, renamePartition, } from "./partitions/public.js";
|
|
3
|
+
export { readPartitionMarkerFromRoot, readPartitionMarkerFromRootSync, touchPartitionMarker, touchPartitionMarkerSync, } from "./partitions/markers.js";
|
|
4
|
+
//# sourceMappingURL=partitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"partitions.d.ts","sourceRoot":"","sources":["../../src/storage/partitions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,aAAa,EACb,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,EAC/B,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { deleteLogs, deletePartitions } from "./partitions/delete.js";
|
|
2
|
+
export { copyPartition, createPartition, deletePartition, getPartitionInfo, listPartitions, mergePartition, movePartition, renamePartition, } from "./partitions/public.js";
|
|
3
|
+
export { readPartitionMarkerFromRoot, readPartitionMarkerFromRootSync, touchPartitionMarker, touchPartitionMarkerSync, } from "./partitions/markers.js";
|
|
4
|
+
//# sourceMappingURL=partitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"partitions.js","sourceRoot":"","sources":["../../src/storage/partitions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,aAAa,EACb,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,EAC/B,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC"}
|
package/dist/storage/query.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { LogEntry, LogQueryOptions, LogQueryResult, LogQueryTotals } from "../types.js";
|
|
2
|
-
type
|
|
3
|
-
partition: string;
|
|
2
|
+
type PartitionSummaryState = {
|
|
3
|
+
partition: string | null;
|
|
4
4
|
total: LogQueryTotals;
|
|
5
5
|
};
|
|
6
6
|
declare function readLogRows(filePath: string, compressed: boolean): Promise<LogEntry[]>;
|
|
7
7
|
declare function sortByRecordedAtAsc(entries: LogEntry[]): LogEntry[];
|
|
8
|
-
declare function buildQueryResult(dir: string, logs: LogEntry[], options: LogQueryOptions | undefined, partition: string | null, total: LogQueryTotals, items: Map<string,
|
|
8
|
+
declare function buildQueryResult(dir: string, logs: LogEntry[], options: LogQueryOptions | undefined, partition: string | null, hasExplicitPartition: boolean, total: LogQueryTotals, items: Map<string, PartitionSummaryState>, counts: Map<string, number>): LogQueryResult;
|
|
9
9
|
declare function getLogsForDir(dir: string, options?: LogQueryOptions): Promise<LogQueryResult>;
|
|
10
10
|
export { buildQueryResult, getLogsForDir, readLogRows, sortByRecordedAtAsc };
|
|
11
11
|
//# sourceMappingURL=query.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/storage/query.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAGV,QAAQ,EACR,eAAe,EACf,cAAc,EACd,cAAc,EACf,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/storage/query.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAGV,QAAQ,EACR,eAAe,EACf,cAAc,EACd,cAAc,EACf,MAAM,aAAa,CAAC;AAKrB,KAAK,qBAAqB,GAAG;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,cAAc,CAAC;CACvB,CAAC;AAEF,iBAAe,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAkBrF;AAED,iBAAS,mBAAmB,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,QAAQ,EAAE,CAS5D;AA0CD,iBAAS,gBAAgB,CACvB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,QAAQ,EAAE,EAChB,OAAO,EAAE,eAAe,GAAG,SAAS,EACpC,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,oBAAoB,EAAE,OAAO,EAC7B,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,EACzC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC1B,cAAc,CA4BhB;AAiFD,iBAAe,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAiC5F;AAED,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC"}
|