@liorandb/core 1.0.19 → 1.1.1
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/chunk-2FSI7HX7.js +1689 -0
- package/dist/index.d.ts +24 -11
- package/dist/index.js +5 -1725
- package/dist/queue-YILKSUEI.js +179 -0
- package/package.json +1 -1
- package/src/LioranManager.ts +99 -44
- package/src/core/checkpoint.ts +86 -34
- package/src/core/collection.ts +39 -8
- package/src/core/compaction.ts +53 -38
- package/src/core/database.ts +83 -38
- package/src/core/wal.ts +113 -29
- package/src/ipc/index.ts +41 -19
- package/src/ipc/pool.ts +136 -0
- package/src/ipc/queue.ts +85 -31
- package/src/ipc/worker.ts +72 -0
- package/src/ipc/client.ts +0 -85
- package/src/ipc/server.ts +0 -147
- package/src/ipc/socketPath.ts +0 -10
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,9 @@ interface Migration<T = any> {
|
|
|
29
29
|
interface UpdateOptions$1 {
|
|
30
30
|
upsert?: boolean;
|
|
31
31
|
}
|
|
32
|
+
interface CollectionOptions$1 {
|
|
33
|
+
readonly?: boolean;
|
|
34
|
+
}
|
|
32
35
|
declare class Collection<T = any> {
|
|
33
36
|
dir: string;
|
|
34
37
|
db: ClassicLevel<string, string>;
|
|
@@ -37,7 +40,9 @@ declare class Collection<T = any> {
|
|
|
37
40
|
private schemaVersion;
|
|
38
41
|
private migrations;
|
|
39
42
|
private indexes;
|
|
40
|
-
|
|
43
|
+
private readonlyMode;
|
|
44
|
+
constructor(dir: string, schema?: ZodSchema<T>, schemaVersion?: number, options?: CollectionOptions$1);
|
|
45
|
+
private assertWritable;
|
|
41
46
|
setSchema(schema: ZodSchema<T>, version: number): void;
|
|
42
47
|
addMigration(migration: Migration<T>): void;
|
|
43
48
|
private validate;
|
|
@@ -90,9 +95,14 @@ declare class WALManager {
|
|
|
90
95
|
private currentGen;
|
|
91
96
|
private lsn;
|
|
92
97
|
private fd;
|
|
93
|
-
|
|
98
|
+
private readonlyMode;
|
|
99
|
+
constructor(baseDir: string, options?: {
|
|
100
|
+
readonly?: boolean;
|
|
101
|
+
});
|
|
94
102
|
private walPath;
|
|
95
103
|
private detectLastGeneration;
|
|
104
|
+
private recoverLSNFromExistingLogs;
|
|
105
|
+
private getSortedWalFiles;
|
|
96
106
|
private open;
|
|
97
107
|
private rotate;
|
|
98
108
|
append(record: Omit<WALRecord, "lsn">): Promise<number>;
|
|
@@ -100,6 +110,7 @@ declare class WALManager {
|
|
|
100
110
|
cleanup(beforeGen: number): Promise<void>;
|
|
101
111
|
getCurrentLSN(): number;
|
|
102
112
|
getCurrentGen(): number;
|
|
113
|
+
isReadonly(): boolean;
|
|
103
114
|
}
|
|
104
115
|
|
|
105
116
|
type TXOp = {
|
|
@@ -127,9 +138,13 @@ declare class LioranDB {
|
|
|
127
138
|
private static TX_SEQ;
|
|
128
139
|
wal: WALManager;
|
|
129
140
|
private checkpoint;
|
|
141
|
+
private readonly readonlyMode;
|
|
130
142
|
constructor(basePath: string, dbName: string, manager: LioranManager);
|
|
143
|
+
isReadonly(): boolean;
|
|
144
|
+
private assertWritable;
|
|
131
145
|
private initialize;
|
|
132
146
|
private recoverFromWAL;
|
|
147
|
+
advanceCheckpoint(lsn: number): void;
|
|
133
148
|
private loadMeta;
|
|
134
149
|
private saveMeta;
|
|
135
150
|
getSchemaVersion(): string;
|
|
@@ -149,6 +164,7 @@ declare class LioranDB {
|
|
|
149
164
|
interface LioranManagerOptions$1 {
|
|
150
165
|
rootPath?: string;
|
|
151
166
|
encryptionKey?: string | Buffer;
|
|
167
|
+
ipc?: "primary" | "client" | "readonly";
|
|
152
168
|
}
|
|
153
169
|
declare class LioranManager {
|
|
154
170
|
rootPath: string;
|
|
@@ -156,20 +172,17 @@ declare class LioranManager {
|
|
|
156
172
|
private closed;
|
|
157
173
|
private mode;
|
|
158
174
|
private lockFd?;
|
|
159
|
-
private ipcServer?;
|
|
160
175
|
constructor(options?: LioranManagerOptions$1);
|
|
176
|
+
isPrimary(): boolean;
|
|
177
|
+
isClient(): boolean;
|
|
178
|
+
isReadOnly(): boolean;
|
|
179
|
+
private getQueue;
|
|
161
180
|
private isProcessAlive;
|
|
162
181
|
private tryAcquireLock;
|
|
163
182
|
db(name: string): Promise<LioranDB>;
|
|
164
183
|
openDatabase(name: string): Promise<LioranDB>;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
*/
|
|
168
|
-
snapshot(snapshotPath: string): Promise<unknown>;
|
|
169
|
-
/**
|
|
170
|
-
* Restore TAR snapshot safely
|
|
171
|
-
*/
|
|
172
|
-
restore(snapshotPath: string): Promise<unknown>;
|
|
184
|
+
snapshot(snapshotPath: string): Promise<any>;
|
|
185
|
+
restore(snapshotPath: string): Promise<any>;
|
|
173
186
|
closeAll(): Promise<void>;
|
|
174
187
|
close(): Promise<void>;
|
|
175
188
|
private _registerShutdownHooks;
|