@hakodb/client 0.7.4 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hakodb/client",
3
- "version": "0.7.4",
3
+ "version": "0.7.5",
4
4
  "description": "High-level HakoDB JavaScript/TypeScript client for Node.js and Bun",
5
5
  "repository": {
6
6
  "type": "git",
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 },
@@ -943,6 +949,9 @@ async function createBunBindings(libPath: string): Promise<NativeBindings> {
943
949
  pipelineExecute: (e, p) => ptrToStringAndFree(symbols.hk_pipeline_execute(e, p)),
944
950
  pipelineExecuteToHandles: (e, p) => symbols.hk_pipeline_execute_to_handles(e, p),
945
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)),
946
955
  configSetPageCacheCapacity: (c, n) => symbols.hk_config_set_page_cache_capacity(c, n),
947
956
  configSetSyncExcluded: (c, json) => symbols.hk_config_set_sync_excluded(c, toC(json)),
948
957
  configSetLazyCollections: (c, json) => symbols.hk_config_set_lazy_collections(c, toC(json)),
@@ -1275,6 +1284,9 @@ async function createNodeBindings(libPath: string): Promise<NativeBindings> {
1275
1284
  // 0.16.5 parity: F8 schemas, F5 versioned/tx, F7 explain, F3 predicates,
1276
1285
  // F4 pipelines, config knobs, quiescence, lazy walks and borrowed reads.
1277
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)'),
1278
1290
  hk_config_set_page_cache_capacity: lib.func('void hk_config_set_page_cache_capacity(HK_Config* config, size_t capacity)'),
1279
1291
  hk_config_set_sync_excluded: lib.func('int hk_config_set_sync_excluded(HK_Config* config, const char* collections_json)'),
1280
1292
  hk_config_set_lazy_collections: lib.func('int hk_config_set_lazy_collections(HK_Config* config, const char* collections_json)'),
@@ -1608,6 +1620,9 @@ async function createNodeBindings(libPath: string): Promise<NativeBindings> {
1608
1620
  pipelineExecute: (e, p) => ptrToStringAndFree(fn.hk_pipeline_execute(e, p)),
1609
1621
  pipelineExecuteToHandles: (e, p) => fn.hk_pipeline_execute_to_handles(e, p),
1610
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)),
1611
1626
  configSetPageCacheCapacity: (c, n) => fn.hk_config_set_page_cache_capacity(c, n),
1612
1627
  configSetSyncExcluded: (c, json) => fn.hk_config_set_sync_excluded(c, json),
1613
1628
  configSetLazyCollections: (c, json) => fn.hk_config_set_lazy_collections(c, json),