@x1a0f3n9/dsh-session-persistence-jsonl 0.1.5-alpha.2

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.
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Windows durable namespace helpers for the JSONL backend.
3
+ *
4
+ * POSIX publishes a newly-created log by creating a directory entry and then
5
+ * fsyncing the parent directory. Windows does not expose that parent-directory
6
+ * fsync contract through Node, so the Windows path uses the native durable
7
+ * namespace primitive instead: create a staging object in the target directory
8
+ * and publish it with `MoveFileExW(..., MOVEFILE_WRITE_THROUGH)` without
9
+ * replacement or cross-volume copy fallback.
10
+ *
11
+ * @module dsh-session-persistence-jsonl/win32
12
+ */
13
+ /**
14
+ * Publish `existing` at `replacement` with Windows write-through rename
15
+ * semantics. The destination must not already exist; the move must stay within
16
+ * the volume (no copy fallback flag is set).
17
+ * @param existing - the synced staging path to move.
18
+ * @param replacement - the final path, which must not already exist.
19
+ */
20
+ export declare function publishNewFileWin32(existing: string, replacement: string): Promise<void>;
21
+ /**
22
+ * Acquire the session write lock as a named kernel semaphore (count 1) whose
23
+ * name is derived from the canonical lock path. A kernel object never touches
24
+ * the filesystem, so readers, searches, and directory removal proceed freely
25
+ * while the lock is held; a second acquirer's zero-timeout wait times out
26
+ * (`EBUSY`); and when the last handle closes — including on any process
27
+ * death — the object is destroyed, so a successor's create starts fresh.
28
+ * @param path - the lock file path the name is derived from (case-folded:
29
+ * Windows paths are case-insensitive).
30
+ * @returns the open semaphore handle, released via {@link releaseLockHandleWin32}.
31
+ */
32
+ export declare function acquireLockHandleWin32(path: string): Promise<number>;
33
+ /**
34
+ * Release a lock from {@link acquireLockHandleWin32}: restore the semaphore
35
+ * count and close the handle (the object dies with its last handle).
36
+ * @param handle - the open semaphore handle.
37
+ */
38
+ export declare function releaseLockHandleWin32(handle: number): Promise<void>;
39
+ /**
40
+ * Create `target` and its missing ancestors with durable Windows namespace
41
+ * publication. Each missing directory is first created as a random staging
42
+ * sibling, then moved to its final name with `MOVEFILE_WRITE_THROUGH`; races
43
+ * with another creator are accepted only after verifying the winner is a
44
+ * directory.
45
+ * @param target - the absolute directory path to create durably when absent.
46
+ */
47
+ export declare function ensureDurableDirectoryWin32(target: string): Promise<void>;
48
+ //# sourceMappingURL=win32.d.ts.map
@@ -0,0 +1,3 @@
1
+ /** Worker entry for current-generation physical and logical verification. */
2
+ export {};
3
+ //# sourceMappingURL=worker.d.ts.map
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Node-private synchronous Zstandard frame decoder optimization.
3
+ * @module dsh-session-persistence-jsonl/zstd-private-decoder
4
+ */
5
+ import type { ZstdFrameDecoder, ZstdFrameRange } from './zstd.ts';
6
+ /**
7
+ * Synchronous multi-frame decoder backed by one Node Zstd stream handle. Node
8
+ * exposes synchronous decoding only as a one-shot API, so this adapter uses
9
+ * the stream's private handle contract to reuse its native context and output
10
+ * chunks across frames.
11
+ */
12
+ export declare class NodePrivateZstdFrameDecoder implements ZstdFrameDecoder {
13
+ private readonly stream;
14
+ private readonly errorKey;
15
+ private readonly output;
16
+ private decoderError?;
17
+ private started;
18
+ private closed;
19
+ private constructor();
20
+ /**
21
+ * Create the optimized decoder when this Node release exposes the expected
22
+ * private stream shape.
23
+ * @returns a shared decoder, or `undefined` when callers must use the public fallback.
24
+ */
25
+ static create(): NodePrivateZstdFrameDecoder | undefined;
26
+ /** @inheritdoc */
27
+ decode(source: Buffer, frames: readonly ZstdFrameRange[]): Generator<Buffer, void, void>;
28
+ /** Decode one frame; its returned scratch view remains valid until the next call. */
29
+ private decodeFrame;
30
+ /** @inheritdoc */
31
+ close(): void;
32
+ }
33
+ //# sourceMappingURL=zstd-private-decoder.d.ts.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Public-API synchronous Zstandard frame decoder fallback.
3
+ * @module dsh-session-persistence-jsonl/zstd-public-decoder
4
+ */
5
+ import type { ZstdFrameDecoder, ZstdFrameRange } from './zstd.ts';
6
+ /** Multi-frame adapter built exclusively from Node's supported one-shot API. */
7
+ export declare class PublicZstdFrameDecoder implements ZstdFrameDecoder {
8
+ private started;
9
+ private closed;
10
+ /** @inheritdoc */
11
+ decode(source: Buffer, frames: readonly ZstdFrameRange[]): Generator<Buffer, void, void>;
12
+ /** @inheritdoc */
13
+ close(): void;
14
+ }
15
+ //# sourceMappingURL=zstd-public-decoder.d.ts.map
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Zstandard frame primitives for the JSONL persistence backend. The backend
3
+ * owns a concatenated-frame container so it can append and recover batches
4
+ * without exposing compression mechanics through the persistence seam.
5
+ * @module dsh-session-persistence-jsonl/zstd
6
+ */
7
+ /** Byte range occupied by one structurally complete Zstandard frame. */
8
+ export interface ZstdFrameRange {
9
+ /** Inclusive frame start. */
10
+ start: number;
11
+ /** Exclusive frame end. */
12
+ end: number;
13
+ }
14
+ /** Structural scan result for a concatenated Zstandard stream. */
15
+ export interface ZstdFrameScan {
16
+ /** Complete frames in file order. */
17
+ frames: ZstdFrameRange[];
18
+ /** Start of an incomplete final frame, when EOF interrupts one. */
19
+ tornStart?: number;
20
+ }
21
+ /**
22
+ * Locate complete frames without decompressing their blocks. Invalid complete
23
+ * structure rejects; EOF inside the final frame returns its start for repair.
24
+ * @param buffer - complete bytes currently present in the session artifact.
25
+ * @param maxFrames - optional complete-frame limit for metadata-only readers.
26
+ * @returns complete frame ranges and an optional incomplete-final-frame start.
27
+ */
28
+ export declare function scanZstdFrames(buffer: Buffer, maxFrames?: number): ZstdFrameScan;
29
+ /**
30
+ * Compress one independently decodable, checksummed Zstandard frame.
31
+ * @param input - JSONL bytes for a header or durable event batch.
32
+ * @returns the complete encoded frame.
33
+ */
34
+ export declare function compressZstdFrame(input: Buffer | string): Promise<Buffer>;
35
+ /**
36
+ * Decompress one complete frame and validate its checksum.
37
+ * @param input - one structurally complete Zstandard frame.
38
+ * @returns the frame plaintext.
39
+ */
40
+ export declare function decompressZstdFrame(input: Buffer): Promise<Buffer>;
41
+ /** Common lifecycle for interchangeable synchronous multi-frame decoders. */
42
+ export interface ZstdFrameDecoder {
43
+ /**
44
+ * Decode and checksum complete frames in source order. Each yielded buffer
45
+ * remains valid only until the iterator advances to the next frame.
46
+ * @param source - concatenated Zstandard frame bytes.
47
+ * @param frames - structurally complete ranges within `source`.
48
+ * @returns one plaintext buffer per frame.
49
+ */
50
+ decode(source: Buffer, frames: readonly ZstdFrameRange[]): Generator<Buffer, void, void>;
51
+ /** Release decoder-owned resources; repeated calls are harmless. */
52
+ close(): void;
53
+ }
54
+ /**
55
+ * Select the shared private decoder when the running Node 22/24/26 shape is
56
+ * compatible, otherwise preserve correctness with the public one-shot API.
57
+ * @returns a synchronous decoder with an implementation-independent lifecycle.
58
+ */
59
+ export declare function createZstdFrameDecoder(): ZstdFrameDecoder;
60
+ /**
61
+ * Recover available plaintext from a structurally incomplete final frame.
62
+ * `ZSTD_e_flush` deliberately suppresses final-frame and checksum completion;
63
+ * callers must establish the torn frame boundary before using this helper.
64
+ * @param input - available bytes from a known incomplete Zstandard frame.
65
+ * @returns plaintext produced from the available input.
66
+ */
67
+ export declare function decompressZstdPrefix(input: Buffer): Promise<Buffer>;
68
+ //# sourceMappingURL=zstd.d.ts.map