@hakodb/client 0.7.3 → 0.7.5
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/package.json +1 -1
- package/scripts/check_ffi_parity.py +29 -1
- package/src/client.ts +22 -1
- package/src/native.ts +18 -0
package/package.json
CHANGED
|
@@ -41,20 +41,48 @@ def bound_symbols(path: Path) -> set[str]:
|
|
|
41
41
|
return found - {"hk_socket_sync_"}
|
|
42
42
|
|
|
43
43
|
|
|
44
|
+
def backend_sections(text: str):
|
|
45
|
+
bun = text[text.index("async function createBunBindings"):text.index("async function createNodeBindings")]
|
|
46
|
+
node = text[text.index("async function createNodeBindings"):text.index("export async function loadNativeBindings")]
|
|
47
|
+
return bun, node
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def backend_missing(text: str) -> dict:
|
|
51
|
+
bun, node = backend_sections(text)
|
|
52
|
+
bun_declared = set(re.findall(r"\b(hk_[a-z0-9_]+):\s*\{", bun))
|
|
53
|
+
bun_used = set(re.findall(r"symbols\.(hk_[a-z0-9_]+)", bun))
|
|
54
|
+
node_declared = set(re.findall(r"\b(hk_[a-z0-9_]+):\s*lib\.func", node))
|
|
55
|
+
node_declared |= set(re.findall(r"lib\.func\('[^']*\b(hk_[a-z0-9_]+)\(", node))
|
|
56
|
+
node_used = set(re.findall(r"\bfn\.(hk_[a-z0-9_]+)", node))
|
|
57
|
+
return {
|
|
58
|
+
"bun": sorted(bun_used - bun_declared),
|
|
59
|
+
"node": sorted(node_used - node_declared),
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
44
63
|
def main() -> int:
|
|
45
64
|
if not HEADER.exists() or not BINDINGS.exists():
|
|
46
65
|
print(f"missing input: header={HEADER} bindings={BINDINGS}", file=sys.stderr)
|
|
47
66
|
return 2
|
|
67
|
+
text = BINDINGS.read_text(encoding="utf-8")
|
|
48
68
|
header = header_functions(HEADER)
|
|
49
69
|
bound = bound_symbols(BINDINGS)
|
|
50
70
|
missing = sorted(header - bound - ALLOW_UNBOUND)
|
|
51
71
|
stale = sorted(bound - header)
|
|
72
|
+
backend = backend_missing(text)
|
|
52
73
|
print(f"header functions: {len(header)}, bound symbols: {len(bound)}")
|
|
74
|
+
failed = False
|
|
53
75
|
if missing:
|
|
54
76
|
print("unbound and not allowlisted:", ", ".join(missing), file=sys.stderr)
|
|
77
|
+
failed = True
|
|
55
78
|
if stale:
|
|
56
79
|
print("bound symbols absent from header:", ", ".join(stale), file=sys.stderr)
|
|
57
|
-
|
|
80
|
+
failed = True
|
|
81
|
+
for name, symbols in backend.items():
|
|
82
|
+
if symbols:
|
|
83
|
+
print(f"{name} wrappers using undeclared symbols:", ", ".join(symbols), file=sys.stderr)
|
|
84
|
+
failed = True
|
|
85
|
+
if failed:
|
|
58
86
|
return 1
|
|
59
87
|
print("FFI binding parity: OK")
|
|
60
88
|
return 0
|
package/src/client.ts
CHANGED
|
@@ -213,6 +213,12 @@ export class HakoConfig {
|
|
|
213
213
|
return this;
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
+
/** Explicit trigger mode; changing the interval never changes it for you. */
|
|
217
|
+
setCommitTriggerMode(mode: 'legacy' | 'strict-time'): this {
|
|
218
|
+
this._native.configSetCommitTriggerMode(this._handle, mode === 'strict-time' ? 1 : 0);
|
|
219
|
+
return this;
|
|
220
|
+
}
|
|
221
|
+
|
|
216
222
|
setPageCacheCapacity(capacity: number): this {
|
|
217
223
|
this._native.configSetPageCacheCapacity(this._handle, capacity);
|
|
218
224
|
return this;
|
|
@@ -903,6 +909,20 @@ export class HakoClient {
|
|
|
903
909
|
return json ? JSON.parse(json) : [];
|
|
904
910
|
}
|
|
905
911
|
|
|
912
|
+
/** Effective live config from the engine; safe to store in reports. */
|
|
913
|
+
async effectiveConfig(): Promise<Record<string, unknown>> {
|
|
914
|
+
this.assertOpen();
|
|
915
|
+
const json = this.native.engineEffectiveConfig(this.engine);
|
|
916
|
+
if (!json) throw new Error(`effectiveConfig failed: ${this.native.lastError()}`);
|
|
917
|
+
return JSON.parse(json) as Record<string, unknown>;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
/** Live trigger-mode switch; the interval value is untouched. */
|
|
921
|
+
setCommitTriggerMode(mode: 'legacy' | 'strict-time'): void {
|
|
922
|
+
this.assertOpen();
|
|
923
|
+
this.native.engineSetCommitTriggerMode(this.engine, mode === 'strict-time' ? 1 : 0);
|
|
924
|
+
}
|
|
925
|
+
|
|
906
926
|
nativeBindings(): NativeBindings { return this.native; }
|
|
907
927
|
engineHandle(): unknown { return this.engine; }
|
|
908
928
|
|
|
@@ -1459,6 +1479,8 @@ return this;
|
|
|
1459
1479
|
}
|
|
1460
1480
|
}
|
|
1461
1481
|
|
|
1482
|
+
// Cursor anchors need ORDER BY to be set first in the C ABI.
|
|
1483
|
+
if (this.order) ensureOk(native.queryOrderBy(handle, this.order.field, this.order.ascending), native, 'queryOrderBy');
|
|
1462
1484
|
if (this._startAtSnapshot?._nativeHandle) {
|
|
1463
1485
|
ensureOk(native.queryStartAt(handle, this._startAtSnapshot._nativeHandle), native, 'queryStartAt');
|
|
1464
1486
|
}
|
|
@@ -1481,7 +1503,6 @@ return this;
|
|
|
1481
1503
|
ensureOk(native.queryWhereTraverse(handle, t.startCol, t.startId, t.direction, t.edge, t.maxDepth), native, 'queryWhereTraverse');
|
|
1482
1504
|
}
|
|
1483
1505
|
|
|
1484
|
-
if (this.order) ensureOk(native.queryOrderBy(handle, this.order.field, this.order.ascending), native, 'queryOrderBy');
|
|
1485
1506
|
if (this.queryLimit !== undefined) ensureOk(native.queryLimit(handle, this.queryLimit), native, 'queryLimit');
|
|
1486
1507
|
if (this.queryOffset !== undefined) ensureOk(native.queryOffset(handle, this.queryOffset), native, 'queryOffset');
|
|
1487
1508
|
for (const field of this.projection) ensureOk(native.querySelectField(handle, field), native, 'querySelectField');
|
package/src/native.ts
CHANGED
|
@@ -302,6 +302,9 @@ export interface NativeBindings {
|
|
|
302
302
|
|
|
303
303
|
// Config additions (0.12-0.16 core knobs).
|
|
304
304
|
configSetGroupCommitIntervalMs(config: Handle, ms: number | bigint): void;
|
|
305
|
+
configSetCommitTriggerMode(config: Handle, mode: number): void;
|
|
306
|
+
engineSetCommitTriggerMode(engine: Handle, mode: number): void;
|
|
307
|
+
engineEffectiveConfig(engine: Handle): string | null;
|
|
305
308
|
configSetPageCacheCapacity(config: Handle, capacity: number): void;
|
|
306
309
|
configSetSyncExcluded(config: Handle, collectionsJson: string): number;
|
|
307
310
|
configSetLazyCollections(config: Handle, collectionsJson: string): number;
|
|
@@ -579,6 +582,9 @@ async function createBunBindings(libPath: string): Promise<NativeBindings> {
|
|
|
579
582
|
// 0.16.5 parity: F8 schemas, F5 versioned/tx, F7 explain, F3 predicates,
|
|
580
583
|
// F4 pipelines, config knobs, quiescence, lazy walks and borrowed reads.
|
|
581
584
|
hk_config_set_group_commit_interval_ms: { args: [FFIType.ptr, FFIType.u64], returns: FFIType.void },
|
|
585
|
+
hk_config_set_commit_trigger_mode: { args: [FFIType.ptr, FFIType.u32], returns: FFIType.void },
|
|
586
|
+
hk_engine_set_commit_trigger_mode: { args: [FFIType.ptr, FFIType.u32], returns: FFIType.void },
|
|
587
|
+
hk_engine_effective_config: { args: [FFIType.ptr], returns: FFIType.ptr },
|
|
582
588
|
hk_config_set_page_cache_capacity: { args: [FFIType.ptr, FFIType.usize], returns: FFIType.void },
|
|
583
589
|
hk_config_set_sync_excluded: { args: [FFIType.ptr, FFIType.cstring], returns: FFIType.i32 },
|
|
584
590
|
hk_config_set_lazy_collections: { args: [FFIType.ptr, FFIType.cstring], returns: FFIType.i32 },
|
|
@@ -617,6 +623,7 @@ async function createBunBindings(libPath: string): Promise<NativeBindings> {
|
|
|
617
623
|
hk_cursor_walk_view: { args: [FFIType.ptr, FFIType.ptr, FFIType.function, FFIType.ptr], returns: FFIType.i64 },
|
|
618
624
|
hk_rawdoc_bytes: { args: [FFIType.ptr, FFIType.ptr], returns: FFIType.ptr },
|
|
619
625
|
hk_rawdoc_id: { args: [FFIType.ptr, FFIType.ptr], returns: FFIType.ptr },
|
|
626
|
+
hk_view_free: { args: [FFIType.ptr], returns: FFIType.void },
|
|
620
627
|
hk_view_get: { args: [FFIType.ptr, FFIType.cstring, FFIType.cstring], returns: FFIType.ptr },
|
|
621
628
|
hk_view_get_int: { args: [FFIType.ptr, FFIType.cstring, FFIType.ptr], returns: FFIType.bool },
|
|
622
629
|
hk_view_get_float: { args: [FFIType.ptr, FFIType.cstring, FFIType.ptr], returns: FFIType.bool },
|
|
@@ -625,6 +632,8 @@ async function createBunBindings(libPath: string): Promise<NativeBindings> {
|
|
|
625
632
|
hk_view_has_field: { args: [FFIType.ptr, FFIType.cstring], returns: FFIType.bool },
|
|
626
633
|
hk_view_get_str: { args: [FFIType.ptr, FFIType.cstring, FFIType.ptr], returns: FFIType.ptr },
|
|
627
634
|
hk_view_get_bytes: { args: [FFIType.ptr, FFIType.cstring, FFIType.ptr], returns: FFIType.ptr },
|
|
635
|
+
hk_view_to_doc: { args: [FFIType.ptr, FFIType.cstring], returns: FFIType.ptr },
|
|
636
|
+
hk_engine_list_collections: { args: [FFIType.ptr], returns: FFIType.ptr },
|
|
628
637
|
hk_engine_get_json: { args: [FFIType.ptr, FFIType.cstring, FFIType.cstring], returns: FFIType.ptr },
|
|
629
638
|
hk_query_execute_json: { args: [FFIType.ptr, FFIType.ptr], returns: FFIType.ptr },
|
|
630
639
|
hk_cursor_walk_json: { args: [FFIType.ptr, FFIType.ptr, FFIType.function, FFIType.ptr], returns: FFIType.i64 },
|
|
@@ -940,6 +949,9 @@ async function createBunBindings(libPath: string): Promise<NativeBindings> {
|
|
|
940
949
|
pipelineExecute: (e, p) => ptrToStringAndFree(symbols.hk_pipeline_execute(e, p)),
|
|
941
950
|
pipelineExecuteToHandles: (e, p) => symbols.hk_pipeline_execute_to_handles(e, p),
|
|
942
951
|
configSetGroupCommitIntervalMs: (c, ms) => symbols.hk_config_set_group_commit_interval_ms(c, BigInt(ms)),
|
|
952
|
+
configSetCommitTriggerMode: (c, mode) => symbols.hk_config_set_commit_trigger_mode(c, mode),
|
|
953
|
+
engineSetCommitTriggerMode: (e, mode) => symbols.hk_engine_set_commit_trigger_mode(e, mode),
|
|
954
|
+
engineEffectiveConfig: (e) => ptrToStringAndFree(symbols.hk_engine_effective_config(e)),
|
|
943
955
|
configSetPageCacheCapacity: (c, n) => symbols.hk_config_set_page_cache_capacity(c, n),
|
|
944
956
|
configSetSyncExcluded: (c, json) => symbols.hk_config_set_sync_excluded(c, toC(json)),
|
|
945
957
|
configSetLazyCollections: (c, json) => symbols.hk_config_set_lazy_collections(c, toC(json)),
|
|
@@ -1272,6 +1284,9 @@ async function createNodeBindings(libPath: string): Promise<NativeBindings> {
|
|
|
1272
1284
|
// 0.16.5 parity: F8 schemas, F5 versioned/tx, F7 explain, F3 predicates,
|
|
1273
1285
|
// F4 pipelines, config knobs, quiescence, lazy walks and borrowed reads.
|
|
1274
1286
|
hk_config_set_group_commit_interval_ms: lib.func('void hk_config_set_group_commit_interval_ms(HK_Config* config, uint64_t ms)'),
|
|
1287
|
+
hk_config_set_commit_trigger_mode: lib.func('void hk_config_set_commit_trigger_mode(HK_Config* config, uint32_t mode)'),
|
|
1288
|
+
hk_engine_set_commit_trigger_mode: lib.func('void hk_engine_set_commit_trigger_mode(HK_Engine* engine, uint32_t mode)'),
|
|
1289
|
+
hk_engine_effective_config: lib.func('HeapStr hk_engine_effective_config(HK_Engine* engine)'),
|
|
1275
1290
|
hk_config_set_page_cache_capacity: lib.func('void hk_config_set_page_cache_capacity(HK_Config* config, size_t capacity)'),
|
|
1276
1291
|
hk_config_set_sync_excluded: lib.func('int hk_config_set_sync_excluded(HK_Config* config, const char* collections_json)'),
|
|
1277
1292
|
hk_config_set_lazy_collections: lib.func('int hk_config_set_lazy_collections(HK_Config* config, const char* collections_json)'),
|
|
@@ -1605,6 +1620,9 @@ async function createNodeBindings(libPath: string): Promise<NativeBindings> {
|
|
|
1605
1620
|
pipelineExecute: (e, p) => ptrToStringAndFree(fn.hk_pipeline_execute(e, p)),
|
|
1606
1621
|
pipelineExecuteToHandles: (e, p) => fn.hk_pipeline_execute_to_handles(e, p),
|
|
1607
1622
|
configSetGroupCommitIntervalMs: (c, ms) => fn.hk_config_set_group_commit_interval_ms(c, ms),
|
|
1623
|
+
configSetCommitTriggerMode: (c, mode) => fn.hk_config_set_commit_trigger_mode(c, mode),
|
|
1624
|
+
engineSetCommitTriggerMode: (e, mode) => fn.hk_engine_set_commit_trigger_mode(e, mode),
|
|
1625
|
+
engineEffectiveConfig: (e) => ptrToStringAndFree(fn.hk_engine_effective_config(e)),
|
|
1608
1626
|
configSetPageCacheCapacity: (c, n) => fn.hk_config_set_page_cache_capacity(c, n),
|
|
1609
1627
|
configSetSyncExcluded: (c, json) => fn.hk_config_set_sync_excluded(c, json),
|
|
1610
1628
|
configSetLazyCollections: (c, json) => fn.hk_config_set_lazy_collections(c, json),
|