@liorandb/core 1.1.0 → 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 +21 -11
- package/dist/index.js +5 -1828
- package/dist/queue-YILKSUEI.js +179 -0
- package/package.json +1 -1
- package/src/LioranManager.ts +99 -44
- package/src/core/collection.ts +39 -8
- package/src/core/database.ts +58 -33
- package/src/core/wal.ts +42 -13
- 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,7 +95,10 @@ 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;
|
|
96
104
|
private recoverLSNFromExistingLogs;
|
|
@@ -102,6 +110,7 @@ declare class WALManager {
|
|
|
102
110
|
cleanup(beforeGen: number): Promise<void>;
|
|
103
111
|
getCurrentLSN(): number;
|
|
104
112
|
getCurrentGen(): number;
|
|
113
|
+
isReadonly(): boolean;
|
|
105
114
|
}
|
|
106
115
|
|
|
107
116
|
type TXOp = {
|
|
@@ -129,7 +138,10 @@ declare class LioranDB {
|
|
|
129
138
|
private static TX_SEQ;
|
|
130
139
|
wal: WALManager;
|
|
131
140
|
private checkpoint;
|
|
141
|
+
private readonly readonlyMode;
|
|
132
142
|
constructor(basePath: string, dbName: string, manager: LioranManager);
|
|
143
|
+
isReadonly(): boolean;
|
|
144
|
+
private assertWritable;
|
|
133
145
|
private initialize;
|
|
134
146
|
private recoverFromWAL;
|
|
135
147
|
advanceCheckpoint(lsn: number): void;
|
|
@@ -152,6 +164,7 @@ declare class LioranDB {
|
|
|
152
164
|
interface LioranManagerOptions$1 {
|
|
153
165
|
rootPath?: string;
|
|
154
166
|
encryptionKey?: string | Buffer;
|
|
167
|
+
ipc?: "primary" | "client" | "readonly";
|
|
155
168
|
}
|
|
156
169
|
declare class LioranManager {
|
|
157
170
|
rootPath: string;
|
|
@@ -159,20 +172,17 @@ declare class LioranManager {
|
|
|
159
172
|
private closed;
|
|
160
173
|
private mode;
|
|
161
174
|
private lockFd?;
|
|
162
|
-
private ipcServer?;
|
|
163
175
|
constructor(options?: LioranManagerOptions$1);
|
|
176
|
+
isPrimary(): boolean;
|
|
177
|
+
isClient(): boolean;
|
|
178
|
+
isReadOnly(): boolean;
|
|
179
|
+
private getQueue;
|
|
164
180
|
private isProcessAlive;
|
|
165
181
|
private tryAcquireLock;
|
|
166
182
|
db(name: string): Promise<LioranDB>;
|
|
167
183
|
openDatabase(name: string): Promise<LioranDB>;
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
*/
|
|
171
|
-
snapshot(snapshotPath: string): Promise<unknown>;
|
|
172
|
-
/**
|
|
173
|
-
* Restore TAR snapshot safely
|
|
174
|
-
*/
|
|
175
|
-
restore(snapshotPath: string): Promise<unknown>;
|
|
184
|
+
snapshot(snapshotPath: string): Promise<any>;
|
|
185
|
+
restore(snapshotPath: string): Promise<any>;
|
|
176
186
|
closeAll(): Promise<void>;
|
|
177
187
|
close(): Promise<void>;
|
|
178
188
|
private _registerShutdownHooks;
|