@sochdb/sochdb 0.4.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/LICENSE +201 -0
- package/README.md +3349 -0
- package/_bin/aarch64-apple-darwin/libsochdb_storage.dylib +0 -0
- package/_bin/aarch64-apple-darwin/sochdb-bulk +0 -0
- package/_bin/aarch64-apple-darwin/sochdb-grpc-server +0 -0
- package/_bin/aarch64-apple-darwin/sochdb-server +0 -0
- package/_bin/x86_64-pc-windows-msvc/sochdb-bulk.exe +0 -0
- package/_bin/x86_64-pc-windows-msvc/sochdb-grpc-server.exe +0 -0
- package/_bin/x86_64-pc-windows-msvc/sochdb_storage.dll +0 -0
- package/_bin/x86_64-unknown-linux-gnu/libsochdb_storage.so +0 -0
- package/_bin/x86_64-unknown-linux-gnu/sochdb-bulk +0 -0
- package/_bin/x86_64-unknown-linux-gnu/sochdb-grpc-server +0 -0
- package/_bin/x86_64-unknown-linux-gnu/sochdb-server +0 -0
- package/bin/sochdb-bulk.js +80 -0
- package/bin/sochdb-grpc-server.js +80 -0
- package/bin/sochdb-server.js +84 -0
- package/dist/cjs/analytics.js +196 -0
- package/dist/cjs/database.js +929 -0
- package/dist/cjs/embedded/database.js +236 -0
- package/dist/cjs/embedded/ffi/bindings.js +113 -0
- package/dist/cjs/embedded/ffi/library-finder.js +135 -0
- package/dist/cjs/embedded/index.js +14 -0
- package/dist/cjs/embedded/transaction.js +172 -0
- package/dist/cjs/errors.js +71 -0
- package/dist/cjs/format.js +176 -0
- package/dist/cjs/grpc-client.js +328 -0
- package/dist/cjs/index.js +75 -0
- package/dist/cjs/ipc-client.js +504 -0
- package/dist/cjs/query.js +154 -0
- package/dist/cjs/server-manager.js +295 -0
- package/dist/cjs/sql-engine.js +874 -0
- package/dist/esm/analytics.js +196 -0
- package/dist/esm/database.js +931 -0
- package/dist/esm/embedded/database.js +239 -0
- package/dist/esm/embedded/ffi/bindings.js +142 -0
- package/dist/esm/embedded/ffi/library-finder.js +135 -0
- package/dist/esm/embedded/index.js +14 -0
- package/dist/esm/embedded/transaction.js +176 -0
- package/dist/esm/errors.js +71 -0
- package/dist/esm/format.js +179 -0
- package/dist/esm/grpc-client.js +333 -0
- package/dist/esm/index.js +75 -0
- package/dist/esm/ipc-client.js +505 -0
- package/dist/esm/query.js +159 -0
- package/dist/esm/server-manager.js +295 -0
- package/dist/esm/sql-engine.js +875 -0
- package/dist/types/analytics.d.ts +66 -0
- package/dist/types/analytics.d.ts.map +1 -0
- package/dist/types/database.d.ts +523 -0
- package/dist/types/database.d.ts.map +1 -0
- package/dist/types/embedded/database.d.ts +105 -0
- package/dist/types/embedded/database.d.ts.map +1 -0
- package/dist/types/embedded/ffi/bindings.d.ts +24 -0
- package/dist/types/embedded/ffi/bindings.d.ts.map +1 -0
- package/dist/types/embedded/ffi/library-finder.d.ts +17 -0
- package/dist/types/embedded/ffi/library-finder.d.ts.map +1 -0
- package/dist/types/embedded/index.d.ts +9 -0
- package/dist/types/embedded/index.d.ts.map +1 -0
- package/dist/types/embedded/transaction.d.ts +21 -0
- package/dist/types/embedded/transaction.d.ts.map +1 -0
- package/dist/types/errors.d.ts +36 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/format.d.ts +117 -0
- package/dist/types/format.d.ts.map +1 -0
- package/dist/types/grpc-client.d.ts +120 -0
- package/dist/types/grpc-client.d.ts.map +1 -0
- package/dist/types/index.d.ts +50 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/ipc-client.d.ts +177 -0
- package/dist/types/ipc-client.d.ts.map +1 -0
- package/dist/types/query.d.ts +85 -0
- package/dist/types/query.d.ts.map +1 -0
- package/dist/types/server-manager.d.ts +29 -0
- package/dist/types/server-manager.d.ts.map +1 -0
- package/dist/types/sql-engine.d.ts +100 -0
- package/dist/types/sql-engine.d.ts.map +1 -0
- package/package.json +90 -0
- package/scripts/postinstall.js +50 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embedded Database - FFI Mode
|
|
3
|
+
*
|
|
4
|
+
* Direct FFI access to SochDB native library.
|
|
5
|
+
* No server required - similar to Python SDK's Database class.
|
|
6
|
+
*/
|
|
7
|
+
import { NativeBindings } from './ffi/bindings';
|
|
8
|
+
import { EmbeddedTransaction } from './transaction';
|
|
9
|
+
export interface EmbeddedDatabaseConfig {
|
|
10
|
+
walEnabled?: boolean;
|
|
11
|
+
syncMode?: 'full' | 'normal' | 'off';
|
|
12
|
+
memtableSizeBytes?: number;
|
|
13
|
+
groupCommit?: boolean;
|
|
14
|
+
indexPolicy?: 'write_optimized' | 'balanced' | 'scan_optimized' | 'append_only';
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Embedded Database using direct FFI
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { EmbeddedDatabase } from '@sushanth/sochdb';
|
|
22
|
+
*
|
|
23
|
+
* const db = await EmbeddedDatabase.open('./mydb');
|
|
24
|
+
* await db.put(Buffer.from('key'), Buffer.from('value'));
|
|
25
|
+
* const value = await db.get(Buffer.from('key'));
|
|
26
|
+
* await db.close();
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare class EmbeddedDatabase {
|
|
30
|
+
private handle;
|
|
31
|
+
private bindings;
|
|
32
|
+
private closed;
|
|
33
|
+
private path;
|
|
34
|
+
private constructor();
|
|
35
|
+
/**
|
|
36
|
+
* Open a database at the specified path
|
|
37
|
+
*
|
|
38
|
+
* @param path - Path to database directory
|
|
39
|
+
* @param config - Optional configuration
|
|
40
|
+
* @returns EmbeddedDatabase instance
|
|
41
|
+
*/
|
|
42
|
+
static open(path: string, config?: EmbeddedDatabaseConfig): EmbeddedDatabase;
|
|
43
|
+
/**
|
|
44
|
+
* Put a key-value pair (auto-transaction)
|
|
45
|
+
*/
|
|
46
|
+
put(key: Buffer, value: Buffer): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Get a value by key (auto-transaction)
|
|
49
|
+
*/
|
|
50
|
+
get(key: Buffer): Promise<Buffer | null>;
|
|
51
|
+
/**
|
|
52
|
+
* Delete a key (auto-transaction)
|
|
53
|
+
*/
|
|
54
|
+
delete(key: Buffer): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Put value at path (auto-transaction)
|
|
57
|
+
*/
|
|
58
|
+
putPath(path: string, value: Buffer): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Get value at path (auto-transaction)
|
|
61
|
+
*/
|
|
62
|
+
getPath(path: string): Promise<Buffer | null>;
|
|
63
|
+
/**
|
|
64
|
+
* Scan keys with prefix
|
|
65
|
+
*/
|
|
66
|
+
scanPrefix(prefix: Buffer): AsyncGenerator<[Buffer, Buffer]>;
|
|
67
|
+
/**
|
|
68
|
+
* Begin a transaction
|
|
69
|
+
*/
|
|
70
|
+
transaction(): EmbeddedTransaction;
|
|
71
|
+
/**
|
|
72
|
+
* Execute operations within a transaction (with auto-commit/abort)
|
|
73
|
+
*/
|
|
74
|
+
withTransaction<T>(fn: (txn: EmbeddedTransaction) => Promise<T>): Promise<T>;
|
|
75
|
+
/**
|
|
76
|
+
* Force a checkpoint
|
|
77
|
+
*/
|
|
78
|
+
checkpoint(): Promise<bigint>;
|
|
79
|
+
/**
|
|
80
|
+
* Get storage statistics
|
|
81
|
+
*/
|
|
82
|
+
stats(): Promise<{
|
|
83
|
+
memtableSizeBytes: bigint;
|
|
84
|
+
walSizeBytes: bigint;
|
|
85
|
+
activeTransactions: number;
|
|
86
|
+
minActiveSnapshot: bigint;
|
|
87
|
+
lastCheckpointLsn: bigint;
|
|
88
|
+
}>;
|
|
89
|
+
/**
|
|
90
|
+
* Close the database
|
|
91
|
+
*/
|
|
92
|
+
close(): void;
|
|
93
|
+
private ensureOpen;
|
|
94
|
+
/**
|
|
95
|
+
* Get internal handle (for transactions)
|
|
96
|
+
* @internal
|
|
97
|
+
*/
|
|
98
|
+
getHandle(): any;
|
|
99
|
+
/**
|
|
100
|
+
* Get bindings instance (for transactions)
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
getBindings(): NativeBindings;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=database.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../src/embedded/database.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD,MAAM,WAAW,sBAAsB;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACrC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,iBAAiB,GAAG,UAAU,GAAG,gBAAgB,GAAG,aAAa,CAAC;CACnF;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,gBAAgB;IACzB,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,IAAI,CAAS;IAErB,OAAO;IAMP;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,sBAAsB,GAAG,gBAAgB;IA4B5E;;OAEG;IACG,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAapD;;OAEG;IACG,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAc9C;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAaxC;;OAEG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAazD;;OAEG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAcnD;;OAEG;IACI,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAenE;;OAEG;IACH,WAAW,IAAI,mBAAmB;IAOlC;;OAEG;IACG,eAAe,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAYlF;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAMnC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC;QACnB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,YAAY,EAAE,MAAM,CAAC;QACrB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,iBAAiB,EAAE,MAAM,CAAC;QAC1B,iBAAiB,EAAE,MAAM,CAAC;KAC7B,CAAC;IAiBF;;OAEG;IACH,KAAK,IAAI,IAAI;IAOb,OAAO,CAAC,UAAU;IAMlB;;;OAGG;IACH,SAAS,IAAI,GAAG;IAIhB;;;OAGG;IACH,WAAW,IAAI,cAAc;CAGhC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare class NativeBindings {
|
|
2
|
+
private static instance;
|
|
3
|
+
private lib;
|
|
4
|
+
sochdb_open: any;
|
|
5
|
+
sochdb_open_with_config: any;
|
|
6
|
+
sochdb_close: any;
|
|
7
|
+
sochdb_begin_txn: any;
|
|
8
|
+
sochdb_commit: any;
|
|
9
|
+
sochdb_abort: any;
|
|
10
|
+
sochdb_put: any;
|
|
11
|
+
sochdb_get: any;
|
|
12
|
+
sochdb_delete: any;
|
|
13
|
+
sochdb_put_path: any;
|
|
14
|
+
sochdb_get_path: any;
|
|
15
|
+
sochdb_scan_prefix: any;
|
|
16
|
+
sochdb_iterator_next: any;
|
|
17
|
+
sochdb_iterator_close: any;
|
|
18
|
+
sochdb_stats: any;
|
|
19
|
+
sochdb_checkpoint: any;
|
|
20
|
+
sochdb_free_bytes: any;
|
|
21
|
+
private constructor();
|
|
22
|
+
static getInstance(): NativeBindings;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=bindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings.d.ts","sourceRoot":"","sources":["../../../../src/embedded/ffi/bindings.ts"],"names":[],"mappings":"AAsCA,qBAAa,cAAc;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAiB;IACxC,OAAO,CAAC,GAAG,CAAM;IAGV,WAAW,EAAE,GAAG,CAAC;IACjB,uBAAuB,EAAE,GAAG,CAAC;IAC7B,YAAY,EAAE,GAAG,CAAC;IAGlB,gBAAgB,EAAE,GAAG,CAAC;IACtB,aAAa,EAAE,GAAG,CAAC;IACnB,YAAY,EAAE,GAAG,CAAC;IAIlB,UAAU,EAAE,GAAG,CAAC;IAEhB,UAAU,EAAE,GAAG,CAAC;IAEhB,aAAa,EAAE,GAAG,CAAC;IAGnB,eAAe,EAAE,GAAG,CAAC;IACrB,eAAe,EAAE,GAAG,CAAC;IAGrB,kBAAkB,EAAE,GAAG,CAAC;IACxB,oBAAoB,EAAE,GAAG,CAAC;IAC1B,qBAAqB,EAAE,GAAG,CAAC;IAG3B,YAAY,EAAE,GAAG,CAAC;IAClB,iBAAiB,EAAE,GAAG,CAAC;IAGvB,iBAAiB,EAAE,GAAG,CAAC;IAE9B,OAAO;WA2CO,WAAW,IAAI,cAAc;CAM9C"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FFI Library Finder
|
|
3
|
+
*
|
|
4
|
+
* Locates the SochDB native library for the current platform.
|
|
5
|
+
* Search order matches Python SDK for consistency.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Find the SochDB native library
|
|
9
|
+
*
|
|
10
|
+
* Search order:
|
|
11
|
+
* 1. SOCHDB_LIB_PATH environment variable
|
|
12
|
+
* 2. Bundled library in package (_bin/{target}/)
|
|
13
|
+
* 3. Development build (../target/release, ../target/debug)
|
|
14
|
+
* 4. System paths
|
|
15
|
+
*/
|
|
16
|
+
export declare function findLibrary(): string;
|
|
17
|
+
//# sourceMappingURL=library-finder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library-finder.d.ts","sourceRoot":"","sources":["../../../../src/embedded/ffi/library-finder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyCH;;;;;;;;GAQG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAyDpC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embedded Mode - FFI Support
|
|
3
|
+
*
|
|
4
|
+
* Direct FFI bindings to SochDB native library.
|
|
5
|
+
* No server required.
|
|
6
|
+
*/
|
|
7
|
+
export { EmbeddedDatabase, EmbeddedDatabaseConfig } from './database';
|
|
8
|
+
export { EmbeddedTransaction } from './transaction';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/embedded/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { EmbeddedDatabase } from './database';
|
|
2
|
+
export declare class EmbeddedTransaction {
|
|
3
|
+
private db;
|
|
4
|
+
private dbHandle;
|
|
5
|
+
private txnHandle;
|
|
6
|
+
private bindings;
|
|
7
|
+
private committed;
|
|
8
|
+
private aborted;
|
|
9
|
+
constructor(db: EmbeddedDatabase, dbHandle: any, txnHandle: any);
|
|
10
|
+
put(key: Buffer, value: Buffer): Promise<void>;
|
|
11
|
+
get(key: Buffer): Promise<Buffer | null>;
|
|
12
|
+
delete(key: Buffer): Promise<void>;
|
|
13
|
+
putPath(path: string, value: Buffer): Promise<void>;
|
|
14
|
+
getPath(path: string): Promise<Buffer | null>;
|
|
15
|
+
scanPrefix(prefix: Buffer): AsyncGenerator<[Buffer, Buffer]>;
|
|
16
|
+
commit(): Promise<void>;
|
|
17
|
+
abort(): Promise<void>;
|
|
18
|
+
private isActive;
|
|
19
|
+
private ensureActive;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/embedded/transaction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAG9C,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,EAAE,CAAmB;IAC7B,OAAO,CAAC,QAAQ,CAAM;IACtB,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAS;gBAEZ,EAAE,EAAE,gBAAgB,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG;IAOzD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ9C,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IA2BxC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQlC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQnD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAuB5C,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IA6C7D,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAYvB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAO5B,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,YAAY;CAKvB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SochDB Error Classes
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Base error class for all SochDB errors.
|
|
8
|
+
*/
|
|
9
|
+
export declare class SochDBError extends Error {
|
|
10
|
+
constructor(message: string);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Error thrown when connection to the database fails.
|
|
14
|
+
*/
|
|
15
|
+
export declare class ConnectionError extends SochDBError {
|
|
16
|
+
constructor(message: string);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Error thrown when a transaction operation fails.
|
|
20
|
+
*/
|
|
21
|
+
export declare class TransactionError extends SochDBError {
|
|
22
|
+
constructor(message: string);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Error thrown when there's a protocol error in IPC communication.
|
|
26
|
+
*/
|
|
27
|
+
export declare class ProtocolError extends SochDBError {
|
|
28
|
+
constructor(message: string);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Error thrown when a database operation fails.
|
|
32
|
+
*/
|
|
33
|
+
export declare class DatabaseError extends SochDBError {
|
|
34
|
+
constructor(message: string);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAK5B;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,WAAW;gBAClC,OAAO,EAAE,MAAM;CAK5B;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,WAAW;gBACnC,OAAO,EAAE,MAAM;CAK5B;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;gBAChC,OAAO,EAAE,MAAM;CAK5B;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;gBAChC,OAAO,EAAE,MAAM;CAK5B"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 Sushanth (https://github.com/sushanthpy)
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Unified Output Format Semantics
|
|
18
|
+
*
|
|
19
|
+
* Provides format enums for query results and LLM context packaging.
|
|
20
|
+
* This mirrors the Rust sochdb-client format module for consistency.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Error when format conversion fails.
|
|
24
|
+
*/
|
|
25
|
+
export declare class FormatConversionError extends Error {
|
|
26
|
+
fromFormat: string;
|
|
27
|
+
toFormat: string;
|
|
28
|
+
reason: string;
|
|
29
|
+
constructor(fromFormat: string, toFormat: string, reason: string);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Output format for query results sent to clients.
|
|
33
|
+
*
|
|
34
|
+
* These formats are optimized for transmission efficiency and
|
|
35
|
+
* client-side processing.
|
|
36
|
+
*/
|
|
37
|
+
export declare enum WireFormat {
|
|
38
|
+
/**
|
|
39
|
+
* TOON format (default, 40-66% fewer tokens than JSON).
|
|
40
|
+
* Optimized for LLM consumption.
|
|
41
|
+
*/
|
|
42
|
+
TOON = "toon",
|
|
43
|
+
/**
|
|
44
|
+
* Standard JSON for compatibility.
|
|
45
|
+
*/
|
|
46
|
+
JSON = "json",
|
|
47
|
+
/**
|
|
48
|
+
* Raw columnar format for analytics.
|
|
49
|
+
* More efficient for large result sets with projection pushdown.
|
|
50
|
+
*/
|
|
51
|
+
COLUMNAR = "columnar"
|
|
52
|
+
}
|
|
53
|
+
export declare namespace WireFormat {
|
|
54
|
+
/**
|
|
55
|
+
* Parse format from string.
|
|
56
|
+
*/
|
|
57
|
+
function fromString(s: string): WireFormat;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Output format for LLM context packaging.
|
|
61
|
+
*
|
|
62
|
+
* These formats are optimized for readability and token efficiency
|
|
63
|
+
* when constructing prompts for language models.
|
|
64
|
+
*/
|
|
65
|
+
export declare enum ContextFormat {
|
|
66
|
+
/**
|
|
67
|
+
* TOON format (default, token-efficient).
|
|
68
|
+
* Structured data with minimal syntax overhead.
|
|
69
|
+
*/
|
|
70
|
+
TOON = "toon",
|
|
71
|
+
/**
|
|
72
|
+
* JSON format.
|
|
73
|
+
* Widely understood by LLMs, good for structured data.
|
|
74
|
+
*/
|
|
75
|
+
JSON = "json",
|
|
76
|
+
/**
|
|
77
|
+
* Markdown format.
|
|
78
|
+
* Best for human-readable context with formatting.
|
|
79
|
+
*/
|
|
80
|
+
MARKDOWN = "markdown"
|
|
81
|
+
}
|
|
82
|
+
export declare namespace ContextFormat {
|
|
83
|
+
/**
|
|
84
|
+
* Parse format from string.
|
|
85
|
+
*/
|
|
86
|
+
function fromString(s: string): ContextFormat;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Canonical storage format (server-side only).
|
|
90
|
+
*
|
|
91
|
+
* This is the format used for internal storage and is optimized
|
|
92
|
+
* for storage efficiency and query performance.
|
|
93
|
+
*/
|
|
94
|
+
export declare enum CanonicalFormat {
|
|
95
|
+
/**
|
|
96
|
+
* TOON canonical format.
|
|
97
|
+
*/
|
|
98
|
+
TOON = "toon"
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Helper to check format capabilities and conversions.
|
|
102
|
+
*/
|
|
103
|
+
export declare class FormatCapabilities {
|
|
104
|
+
/**
|
|
105
|
+
* Convert WireFormat to ContextFormat if compatible.
|
|
106
|
+
*/
|
|
107
|
+
static wireToContext(wire: WireFormat): ContextFormat | null;
|
|
108
|
+
/**
|
|
109
|
+
* Convert ContextFormat to WireFormat if compatible.
|
|
110
|
+
*/
|
|
111
|
+
static contextToWire(ctx: ContextFormat): WireFormat | null;
|
|
112
|
+
/**
|
|
113
|
+
* Check if format supports round-trip: decode(encode(x)) = x.
|
|
114
|
+
*/
|
|
115
|
+
static supportsRoundTrip(fmt: WireFormat): boolean;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;GAKG;AAEH;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAErC,UAAU,EAAE,MAAM;IAClB,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,MAAM;gBAFd,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM;CAKxB;AAED;;;;;GAKG;AACH,oBAAY,UAAU;IACpB;;;OAGG;IACH,IAAI,SAAS;IAEb;;OAEG;IACH,IAAI,SAAS;IAEb;;;OAGG;IACH,QAAQ,aAAa;CACtB;AAED,yBAAiB,UAAU,CAAC;IAC1B;;OAEG;IACH,SAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CAiBhD;CACF;AAED;;;;;GAKG;AACH,oBAAY,aAAa;IACvB;;;OAGG;IACH,IAAI,SAAS;IAEb;;;OAGG;IACH,IAAI,SAAS;IAEb;;;OAGG;IACH,QAAQ,aAAa;CACtB;AAED,yBAAiB,aAAa,CAAC;IAC7B;;OAEG;IACH,SAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,aAAa,CAiBnD;CACF;AAED;;;;;GAKG;AACH,oBAAY,eAAe;IACzB;;OAEG;IACH,IAAI,SAAS;CACd;AAED;;GAEG;AACH,qBAAa,kBAAkB;IAC7B;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,aAAa,GAAG,IAAI;IAW5D;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,aAAa,GAAG,UAAU,GAAG,IAAI;IAW3D;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO;CAGnD"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SochDB gRPC Client - Thin SDK Wrapper
|
|
3
|
+
*
|
|
4
|
+
* This module provides a thin gRPC client wrapper for the SochDB server.
|
|
5
|
+
* All business logic runs on the server (Thick Server / Thin Client architecture).
|
|
6
|
+
*
|
|
7
|
+
* The client is approximately ~250 lines of code, delegating all operations to the server.
|
|
8
|
+
*/
|
|
9
|
+
export interface SearchResult {
|
|
10
|
+
id: number;
|
|
11
|
+
distance: number;
|
|
12
|
+
}
|
|
13
|
+
export interface Document {
|
|
14
|
+
id: string;
|
|
15
|
+
content: string;
|
|
16
|
+
embedding: number[];
|
|
17
|
+
metadata: Record<string, string>;
|
|
18
|
+
}
|
|
19
|
+
export interface GraphNode {
|
|
20
|
+
id: string;
|
|
21
|
+
nodeType: string;
|
|
22
|
+
properties: Record<string, string>;
|
|
23
|
+
}
|
|
24
|
+
export interface GraphEdge {
|
|
25
|
+
fromId: string;
|
|
26
|
+
edgeType: string;
|
|
27
|
+
toId: string;
|
|
28
|
+
properties: Record<string, string>;
|
|
29
|
+
}
|
|
30
|
+
export interface SochDBClientOptions {
|
|
31
|
+
address?: string;
|
|
32
|
+
secure?: boolean;
|
|
33
|
+
protoPath?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Thin gRPC client for SochDB.
|
|
37
|
+
*
|
|
38
|
+
* All operations are delegated to the SochDB gRPC server.
|
|
39
|
+
* This client provides a TypeScript interface over the gRPC protocol.
|
|
40
|
+
*
|
|
41
|
+
* Usage:
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const client = new SochDBClient({ address: 'localhost:50051' });
|
|
44
|
+
*
|
|
45
|
+
* // Create collection
|
|
46
|
+
* await client.createCollection('docs', { dimension: 384 });
|
|
47
|
+
*
|
|
48
|
+
* // Add documents
|
|
49
|
+
* await client.addDocuments('docs', [
|
|
50
|
+
* { id: '1', content: 'Hello', embedding: [...] }
|
|
51
|
+
* ]);
|
|
52
|
+
*
|
|
53
|
+
* // Search
|
|
54
|
+
* const results = await client.search('docs', queryVector, 5);
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare class SochDBClient {
|
|
58
|
+
private address;
|
|
59
|
+
private credentials;
|
|
60
|
+
private stubs;
|
|
61
|
+
private protoPath;
|
|
62
|
+
private packageDefinition;
|
|
63
|
+
private proto;
|
|
64
|
+
constructor(options?: SochDBClientOptions);
|
|
65
|
+
private getStub;
|
|
66
|
+
private promisify;
|
|
67
|
+
/**
|
|
68
|
+
* Close all gRPC connections.
|
|
69
|
+
*/
|
|
70
|
+
close(): void;
|
|
71
|
+
createIndex(name: string, dimension: number, options?: {
|
|
72
|
+
metric?: string;
|
|
73
|
+
m?: number;
|
|
74
|
+
efConstruction?: number;
|
|
75
|
+
}): Promise<boolean>;
|
|
76
|
+
insertVectors(indexName: string, ids: number[], vectors: number[][]): Promise<number>;
|
|
77
|
+
search(indexName: string, query: number[], k?: number, ef?: number): Promise<SearchResult[]>;
|
|
78
|
+
createCollection(name: string, options: {
|
|
79
|
+
dimension: number;
|
|
80
|
+
namespace?: string;
|
|
81
|
+
metric?: string;
|
|
82
|
+
}): Promise<boolean>;
|
|
83
|
+
addDocuments(collectionName: string, documents: Array<{
|
|
84
|
+
id?: string;
|
|
85
|
+
content?: string;
|
|
86
|
+
embedding?: number[];
|
|
87
|
+
metadata?: Record<string, string>;
|
|
88
|
+
}>, namespace?: string): Promise<string[]>;
|
|
89
|
+
searchCollection(collectionName: string, query: number[], k?: number, options?: {
|
|
90
|
+
namespace?: string;
|
|
91
|
+
filter?: Record<string, string>;
|
|
92
|
+
}): Promise<Document[]>;
|
|
93
|
+
addNode(nodeId: string, nodeType: string, properties?: Record<string, string>, namespace?: string): Promise<boolean>;
|
|
94
|
+
addEdge(fromId: string, edgeType: string, toId: string, properties?: Record<string, string>, namespace?: string): Promise<boolean>;
|
|
95
|
+
traverse(startNode: string, options?: {
|
|
96
|
+
maxDepth?: number;
|
|
97
|
+
order?: 'bfs' | 'dfs';
|
|
98
|
+
namespace?: string;
|
|
99
|
+
}): Promise<{
|
|
100
|
+
nodes: GraphNode[];
|
|
101
|
+
edges: GraphEdge[];
|
|
102
|
+
}>;
|
|
103
|
+
cacheGet(cacheName: string, queryEmbedding: number[], threshold?: number): Promise<string | null>;
|
|
104
|
+
cachePut(cacheName: string, key: string, value: string, keyEmbedding: number[], ttlSeconds?: number): Promise<boolean>;
|
|
105
|
+
startTrace(name: string): Promise<{
|
|
106
|
+
traceId: string;
|
|
107
|
+
rootSpanId: string;
|
|
108
|
+
}>;
|
|
109
|
+
startSpan(traceId: string, parentSpanId: string, name: string): Promise<string>;
|
|
110
|
+
endSpan(traceId: string, spanId: string, status?: 'ok' | 'error' | 'unset'): Promise<number>;
|
|
111
|
+
get(key: Buffer, namespace?: string): Promise<Buffer | null>;
|
|
112
|
+
put(key: Buffer, value: Buffer, namespace?: string, ttlSeconds?: number): Promise<boolean>;
|
|
113
|
+
delete(key: Buffer, namespace?: string): Promise<boolean>;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Connect to SochDB gRPC server.
|
|
117
|
+
*/
|
|
118
|
+
export declare function connect(address?: string, options?: Omit<SochDBClientOptions, 'address'>): SochDBClient;
|
|
119
|
+
export declare const GrpcClient: typeof SochDBClient;
|
|
120
|
+
//# sourceMappingURL=grpc-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grpc-client.d.ts","sourceRoot":"","sources":["../../src/grpc-client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,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
*
|
|
6
|
+
* Architecture: Flexible Deployment
|
|
7
|
+
* ==================================
|
|
8
|
+
* This SDK supports BOTH modes:
|
|
9
|
+
*
|
|
10
|
+
* 1. Embedded Mode (FFI) - For single-process apps:
|
|
11
|
+
* - Direct FFI bindings to Rust libraries
|
|
12
|
+
* - No server required - just npm install and run
|
|
13
|
+
* - Best for: Local development, simple apps
|
|
14
|
+
*
|
|
15
|
+
* 2. Server Mode (gRPC/IPC) - For distributed systems:
|
|
16
|
+
* - Thin client connecting to sochdb-grpc server
|
|
17
|
+
* - Best for: Production, multi-language, scalability
|
|
18
|
+
*
|
|
19
|
+
* @example Embedded Mode
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { Database } from '@sochdb/sochdb';
|
|
22
|
+
*
|
|
23
|
+
* // Direct FFI - no server needed
|
|
24
|
+
* const db = await Database.open('./mydb');
|
|
25
|
+
* await db.put(Buffer.from('key'), Buffer.from('value'));
|
|
26
|
+
* await db.close();
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example Server Mode
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { SochDBClient } from '@sochdb/sochdb';
|
|
32
|
+
*
|
|
33
|
+
* // Connect to server
|
|
34
|
+
* const client = new SochDBClient({ address: 'localhost:50051' });
|
|
35
|
+
* await client.putKv('key', Buffer.from('value'));
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare const VERSION = "0.4.0";
|
|
39
|
+
export { EmbeddedDatabase, EmbeddedDatabaseConfig } from './embedded';
|
|
40
|
+
export { EmbeddedTransaction } from './embedded';
|
|
41
|
+
export { EmbeddedDatabase as Database } from './embedded';
|
|
42
|
+
export { SochDBClient } from './grpc-client';
|
|
43
|
+
export type { SearchResult, Document, GraphNode, GraphEdge, } from './grpc-client';
|
|
44
|
+
export { IpcClient } from './ipc-client';
|
|
45
|
+
export { WireFormat, ContextFormat, CanonicalFormat, FormatCapabilities, FormatConversionError, } from './format';
|
|
46
|
+
export { Query } from './query';
|
|
47
|
+
export type { QueryResult } from './query';
|
|
48
|
+
export { SochDBError, ConnectionError, TransactionError, ProtocolError, DatabaseError, } from './errors';
|
|
49
|
+
export { SochDBClient as GrpcClient } from './grpc-client';
|
|
50
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAGH,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGjD,OAAO,EAAE,gBAAgB,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG1D,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,YAAY,EACV,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,SAAS,GACV,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EACL,UAAU,EACV,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EACL,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,aAAa,GACd,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,YAAY,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC"}
|