@backloghq/opslog 0.5.1 → 0.6.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/dist/backend.d.ts +5 -0
- package/dist/backend.js +28 -2
- package/dist/types.d.ts +10 -0
- package/package.json +2 -2
package/dist/backend.d.ts
CHANGED
|
@@ -27,4 +27,9 @@ export declare class FsBackend implements StorageBackend {
|
|
|
27
27
|
acquireCompactionLock(): Promise<LockHandle>;
|
|
28
28
|
releaseCompactionLock(handle: LockHandle): Promise<void>;
|
|
29
29
|
getManifestVersion(): Promise<string | null>;
|
|
30
|
+
writeBlob(relativePath: string, content: Buffer): Promise<void>;
|
|
31
|
+
readBlob(relativePath: string): Promise<Buffer>;
|
|
32
|
+
listBlobs(prefix: string): Promise<string[]>;
|
|
33
|
+
deleteBlob(relativePath: string): Promise<void>;
|
|
34
|
+
deleteBlobDir(prefix: string): Promise<void>;
|
|
30
35
|
}
|
package/dist/backend.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { mkdir, open, readdir, stat, unlink, writeFile } from "node:fs/promises";
|
|
2
|
-
import { join } from "node:path";
|
|
1
|
+
import { mkdir, open, readdir, readFile, rm, stat, unlink, writeFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
3
|
import { appendOp, appendOps, readOps, truncateLastOp } from "./wal.js";
|
|
4
4
|
import { loadSnapshot, writeSnapshot } from "./snapshot.js";
|
|
5
5
|
import { readManifest, writeManifest } from "./manifest.js";
|
|
@@ -131,4 +131,30 @@ export class FsBackend {
|
|
|
131
131
|
return null;
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
+
// -- Blob storage --
|
|
135
|
+
async writeBlob(relativePath, content) {
|
|
136
|
+
const fullPath = join(this.dir, relativePath);
|
|
137
|
+
await mkdir(dirname(fullPath), { recursive: true });
|
|
138
|
+
await writeFile(fullPath, content);
|
|
139
|
+
}
|
|
140
|
+
async readBlob(relativePath) {
|
|
141
|
+
return readFile(join(this.dir, relativePath));
|
|
142
|
+
}
|
|
143
|
+
async listBlobs(prefix) {
|
|
144
|
+
try {
|
|
145
|
+
return await readdir(join(this.dir, prefix));
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
return [];
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async deleteBlob(relativePath) {
|
|
152
|
+
try {
|
|
153
|
+
await unlink(join(this.dir, relativePath));
|
|
154
|
+
}
|
|
155
|
+
catch { /* ignore if not found */ }
|
|
156
|
+
}
|
|
157
|
+
async deleteBlobDir(prefix) {
|
|
158
|
+
await rm(join(this.dir, prefix), { recursive: true, force: true });
|
|
159
|
+
}
|
|
134
160
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -102,4 +102,14 @@ export interface StorageBackend {
|
|
|
102
102
|
acquireCompactionLock(): Promise<LockHandle>;
|
|
103
103
|
releaseCompactionLock(handle: LockHandle): Promise<void>;
|
|
104
104
|
getManifestVersion(): Promise<string | null>;
|
|
105
|
+
/** Write a blob at a relative path. Creates directories as needed. */
|
|
106
|
+
writeBlob(relativePath: string, content: Buffer): Promise<void>;
|
|
107
|
+
/** Read a blob from a relative path. */
|
|
108
|
+
readBlob(relativePath: string): Promise<Buffer>;
|
|
109
|
+
/** List blob names under a prefix directory. */
|
|
110
|
+
listBlobs(prefix: string): Promise<string[]>;
|
|
111
|
+
/** Delete a single blob. */
|
|
112
|
+
deleteBlob(relativePath: string): Promise<void>;
|
|
113
|
+
/** Delete all blobs under a prefix directory. */
|
|
114
|
+
deleteBlobDir(prefix: string): Promise<void>;
|
|
105
115
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backloghq/opslog",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Embedded event-sourced document store. Append-only operation log with immutable snapshots, zero native dependencies.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"type": "module",
|
|
27
27
|
"engines": {
|
|
28
|
-
"node": ">=
|
|
28
|
+
"node": ">=22"
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
31
|
"dist/",
|