nedb-engine 8.8.8 → 9.0.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/README.md CHANGED
@@ -171,18 +171,25 @@ evaluator with no flag to set, the `nesql` CLI likewise.
171
171
  [![neSQL on crates.io](https://img.shields.io/crates/v/nesql?label=nesql%20·%20crates.io&color=a855f7)](https://crates.io/crates/nesql)
172
172
  [![neSQL on npm](https://img.shields.io/npm/v/nesql-engine?label=nesql-engine%20·%20npm&color=a855f7)](https://www.npmjs.com/package/nesql-engine)
173
173
 
174
- Those three badges read **0.0.1** next to an engine at 8.0.0, and that is
175
- deliberate rather than neglected. They are **reserved names**: each package loads,
176
- reports the vendored PostgreSQL release, and answers `is_release() == false`,
177
- because a package that imports cleanly and then lies is worse than one that is not
178
- published. The engine you actually install is `nedb-engine`. The
179
- [neSQL repository](https://github.com/Eth-Interchained/neSQL) holds the language —
180
- both halves of the grammar and the CLI's source, side by side.
174
+ The three neSQL packages are **real and version-aligned with the engine** the
175
+ badges above are live registry state, not placeholders. They split by delivery
176
+ path, not by function:
177
+
178
+ | package | registry | what it is |
179
+ |---|---|---|
180
+ | [`nesql`](https://crates.io/crates/nesql) | crates.io | **the real CLI crate** `cargo add nesql`, builds against the registry engine |
181
+ | [`nesql`](https://pypi.org/project/nesql/) | PyPI | the language reference (vendored-grammar facts, clause extensions) |
182
+ | [`nesql-engine`](https://www.npmjs.com/package/nesql-engine) | npm | the language reference |
183
+
184
+ The [neSQL repository](https://github.com/Eth-Interchained/neSQL) is the language's
185
+ home: the vendored PostgreSQL grammar with its licence intact, the CLI crate source,
186
+ the NQL grammar reference, and the NEDB specs. And because the CLI is also staged
187
+ into every platform build of the engine (below), **one install carries everything**:
181
188
 
182
189
  ### `nesql` — the CLI, and it speaks neSQL
183
190
 
184
- Ships inside `pip install nedb-engine` — no daemon, no port and answers both
185
- halves of the language through **one** `query` command:
191
+ Ships inside `pip install nedb-engine` — no daemon, no port, the compiled binary on
192
+ your PATH — and answers both halves of the language through **one** `query` command:
186
193
 
187
194
  ```console
188
195
  $ nesql --db ./store query "SELECT who, total FROM orders ORDER BY total DESC"
package/index.d.ts CHANGED
@@ -1,64 +1,64 @@
1
- // nedb-engine — public type surface.
2
- //
3
- // Runtime behavior (durable-mode auto-flush-on-exit) is added by the wrapper in
4
- // index.js; the type surface is exactly the generated native binding's.
5
- export * from './native';
6
-
7
- // ── wrap adapter family (wrap/*.js) ─────────────────────────────────────────
8
-
9
- /** Options accepted by every wrap_* constructor. */
10
- export interface WrapOptions {
11
- /** Logical database name (default "default"). */
12
- dbName?: string;
13
- /** HTTP nedbd server (v1 AOF, `--dag` v2, `--dag-v3` v3). Overrides embedded DAG. */
14
- nedbdUrl?: string;
15
- /** Bearer token for nedbd (NEDBD_TOKEN on the server). */
16
- nedbdToken?: string;
17
- /** Durable DAG store directory (embedded mode). */
18
- dagPath?: string;
19
- /** 64-hex TMK → AES-256-GCM at-rest encryption (embedded DAG mode). */
20
- dagTmk?: string;
21
- /** Explicit NedbCore class (testing / custom builds). */
22
- native?: unknown;
23
- }
24
-
25
- /** The `.nedb` attribute — full NEDB layer-2 API. */
26
- export interface NedbSurface {
27
- register(pattern: string, collection: string, opts?: {
28
- idExtractor?: (key: string) => string;
29
- valueParser?: (raw: unknown) => Record<string, unknown>;
30
- valueType?: 'string' | 'hash' | 'json';
31
- }): NedbSurface;
32
- backfill(opts?: { pattern?: string; collection?: string; batchSize?: number }): number;
33
- shadowWrites: boolean;
34
- readonly engineKind: 'dag-embedded' | 'nedbd-http' | 'aof-embedded';
35
-
36
- put(coll: string, id: string, doc: Record<string, unknown>): Record<string, unknown>;
37
- get(coll: string, id: string, asOf?: number): Record<string, unknown> | null;
38
- query(nql: string): Array<Record<string, unknown>>;
39
- createIndex(coll: string, field: string, kind?: string): void;
40
- delete(coll: string, id: string): void;
41
- link(frm: string, rel: string, to: string): void;
42
- unlink(frm: string, rel: string, to: string): void;
43
- neighbors(frm: string, rel: string, asOf?: number): string[];
44
- inbound(to: string, rel: string, asOf?: number): string[];
45
- verify(): boolean;
46
- readonly head: string;
47
- readonly seq: number;
48
- checkpoint(): string;
49
- /** DAG-native: latest node (null on non-DAG backends). */
50
- tip(): Record<string, unknown> | null;
51
- /** DAG-native: changefeed page, after_seq exclusive. */
52
- since(afterSeq: number | bigint, limit?: number): {
53
- nodes: Array<Record<string, unknown>>; from_seq: number; to_seq: number;
54
- head_seq: number; has_more: boolean;
55
- };
56
- /** DAG-native: replication readiness. */
57
- scanStatus(): { scan_complete: boolean; tip_seq: number; indexed_count: number; [k: string]: unknown };
58
- }
59
-
60
- export declare function wrapRedis<T extends object = object>(client: T, opts?: WrapOptions): T & { nedb: NedbSurface };
61
- export declare function wrapSqlite<T extends object = object>(conn: T, opts?: WrapOptions): T & { nedb: NedbSurface };
62
- export declare function wrapMysql<T extends object = object>(conn: T, opts?: WrapOptions): T & { nedb: NedbSurface };
63
- export declare function wrapPg<T extends object = object>(conn: T, opts?: WrapOptions): T & { nedb: NedbSurface };
64
- export declare function wrapMongo<T extends object = object>(client: T, opts?: WrapOptions): T & { nedb: NedbSurface };
1
+ // nedb-engine — public type surface.
2
+ //
3
+ // Runtime behavior (durable-mode auto-flush-on-exit) is added by the wrapper in
4
+ // index.js; the type surface is exactly the generated native binding's.
5
+ export * from './native';
6
+
7
+ // ── wrap adapter family (wrap/*.js) ─────────────────────────────────────────
8
+
9
+ /** Options accepted by every wrap_* constructor. */
10
+ export interface WrapOptions {
11
+ /** Logical database name (default "default"). */
12
+ dbName?: string;
13
+ /** HTTP nedbd server (v1 AOF, `--dag` v2, `--dag-v3` v3). Overrides embedded DAG. */
14
+ nedbdUrl?: string;
15
+ /** Bearer token for nedbd (NEDBD_TOKEN on the server). */
16
+ nedbdToken?: string;
17
+ /** Durable DAG store directory (embedded mode). */
18
+ dagPath?: string;
19
+ /** 64-hex TMK → AES-256-GCM at-rest encryption (embedded DAG mode). */
20
+ dagTmk?: string;
21
+ /** Explicit NedbCore class (testing / custom builds). */
22
+ native?: unknown;
23
+ }
24
+
25
+ /** The `.nedb` attribute — full NEDB layer-2 API. */
26
+ export interface NedbSurface {
27
+ register(pattern: string, collection: string, opts?: {
28
+ idExtractor?: (key: string) => string;
29
+ valueParser?: (raw: unknown) => Record<string, unknown>;
30
+ valueType?: 'string' | 'hash' | 'json';
31
+ }): NedbSurface;
32
+ backfill(opts?: { pattern?: string; collection?: string; batchSize?: number }): number;
33
+ shadowWrites: boolean;
34
+ readonly engineKind: 'dag-embedded' | 'nedbd-http' | 'aof-embedded';
35
+
36
+ put(coll: string, id: string, doc: Record<string, unknown>): Record<string, unknown>;
37
+ get(coll: string, id: string, asOf?: number): Record<string, unknown> | null;
38
+ query(nql: string): Array<Record<string, unknown>>;
39
+ createIndex(coll: string, field: string, kind?: string): void;
40
+ delete(coll: string, id: string): void;
41
+ link(frm: string, rel: string, to: string): void;
42
+ unlink(frm: string, rel: string, to: string): void;
43
+ neighbors(frm: string, rel: string, asOf?: number): string[];
44
+ inbound(to: string, rel: string, asOf?: number): string[];
45
+ verify(): boolean;
46
+ readonly head: string;
47
+ readonly seq: number;
48
+ checkpoint(): string;
49
+ /** DAG-native: latest node (null on non-DAG backends). */
50
+ tip(): Record<string, unknown> | null;
51
+ /** DAG-native: changefeed page, after_seq exclusive. */
52
+ since(afterSeq: number | bigint, limit?: number): {
53
+ nodes: Array<Record<string, unknown>>; from_seq: number; to_seq: number;
54
+ head_seq: number; has_more: boolean;
55
+ };
56
+ /** DAG-native: replication readiness. */
57
+ scanStatus(): { scan_complete: boolean; tip_seq: number; indexed_count: number; [k: string]: unknown };
58
+ }
59
+
60
+ export declare function wrapRedis<T extends object = object>(client: T, opts?: WrapOptions): T & { nedb: NedbSurface };
61
+ export declare function wrapSqlite<T extends object = object>(conn: T, opts?: WrapOptions): T & { nedb: NedbSurface };
62
+ export declare function wrapMysql<T extends object = object>(conn: T, opts?: WrapOptions): T & { nedb: NedbSurface };
63
+ export declare function wrapPg<T extends object = object>(conn: T, opts?: WrapOptions): T & { nedb: NedbSurface };
64
+ export declare function wrapMongo<T extends object = object>(client: T, opts?: WrapOptions): T & { nedb: NedbSurface };
package/index.js CHANGED
@@ -1,84 +1,84 @@
1
- // SPDX-FileCopyrightText: 2026 INTERCHAINED LLC
2
- // SPDX-License-Identifier: BUSL-1.1
3
- // NEDB · © 2026 INTERCHAINED LLC × Eth-Interchained × Vex (Claude Opus 5)
4
-
5
- 'use strict';
6
- // nedb-engine — durable-mode auto-flush-on-exit wrapper.
7
- //
8
- // The native addon (generated napi binding in ./native.js) exposes `NedbCore`.
9
- // A durable `NedbCore.open(path)` buffers writes in the engine's id-index WAL and
10
- // only makes them durable on `flush()`; a hard exit (Ctrl+C, `SIGTERM` from an
11
- // orchestrator, `pm2 stop`) that never runs an explicit flush would lose writes
12
- // staged since the last flush.
13
- //
14
- // We close that gap the libuv-cooperative way — `process.on('SIGINT'|'SIGTERM'
15
- // |'exit', () => db.flush())` — NOT a C-level signal handler inside the addon,
16
- // which would clobber libuv's own signal machinery. In-memory databases
17
- // (`new NedbCore()`) are never armed; there is nothing to flush.
18
- //
19
- // Escape hatch: set NEDB_NO_EXIT_FLUSH=1 to leave signal handling entirely to
20
- // the host app (it can still call `db.flush()` itself).
21
- //
22
- // © INTERCHAINED LLC × Vex (Interchained AI fleet: GLM · Claude · Opus · Fable · GPT-6)
23
- const native = require('./native.js');
24
-
25
- const Native = native.NedbCore;
26
-
27
- // The napi class defines `open` as a NON-writable, NON-configurable static, so the
28
- // 2.5.x wrapper's `NedbCore.open = …` threw ("Cannot assign to read only property")
29
- // — and CI's `napi build` was overwriting this file with the generated loader
30
- // anyway, so the published package never carried the wrapper at all. Both fixed
31
- // in 2.8.5: wrap by SUBCLASS (an own static on the subclass shadows the parent's),
32
- // build with `--js native.js` so this file survives, and gate the publish on
33
- // `NedbCore.__exitFlushWrapped` (see test/durability.test.mjs).
34
- let NedbCore = Native;
35
- if (Native && typeof Native.open === 'function' && !Native.__exitFlushWrapped) {
36
- // Durable handles opened in this process. Strong refs: a durable DB is meant to
37
- // live for the process, and we must be able to flush it on the way out.
38
- const live = new Set();
39
- let armed = false;
40
-
41
- const flushAll = () => {
42
- for (const db of live) {
43
- try {
44
- db.flush();
45
- } catch (_) {
46
- // Best-effort on shutdown — never throw out of an exit handler.
47
- }
48
- }
49
- };
50
-
51
- const arm = () => {
52
- if (armed || process.env.NEDB_NO_EXIT_FLUSH) return;
53
- armed = true;
54
- // 'exit' fires on normal termination; handlers must be synchronous, and
55
- // db.flush() is a synchronous native call — so this is safe and sufficient
56
- // for clean exits and uncaught-exception exits.
57
- process.on('exit', flushAll);
58
- // Registering a SIGINT/SIGTERM listener SUPPRESSES Node's default
59
- // termination, so once we listen we own the exit: flush, then terminate with
60
- // the conventional 128+signum status.
61
- const onSignal = (signum) => () => {
62
- flushAll();
63
- process.exit(128 + signum);
64
- };
65
- process.on('SIGINT', onSignal(2));
66
- process.on('SIGTERM', onSignal(15));
67
- };
68
-
69
- NedbCore = class NedbCore extends Native {
70
- static open(path) {
71
- const db = Native.open(path);
72
- live.add(db);
73
- arm();
74
- return db;
75
- }
76
- };
77
- // Mark so a re-require (or a wrapped re-export) never double-wraps.
78
- Object.defineProperty(NedbCore, '__exitFlushWrapped', { value: true, enumerable: false });
79
- }
80
-
81
- module.exports = { ...native, NedbCore };
82
- // Explicit named re-export so ESM `import { NedbCore } from 'nedb-engine'` (used
83
- // by the test suite) resolves the class through cjs-module-lexer.
84
- module.exports.NedbCore = NedbCore;
1
+ // SPDX-FileCopyrightText: 2026 INTERCHAINED LLC
2
+ // SPDX-License-Identifier: BUSL-1.1
3
+ // NEDB · © 2026 INTERCHAINED LLC × Eth-Interchained × Vex (Claude Opus 5)
4
+
5
+ 'use strict';
6
+ // nedb-engine — durable-mode auto-flush-on-exit wrapper.
7
+ //
8
+ // The native addon (generated napi binding in ./native.js) exposes `NedbCore`.
9
+ // A durable `NedbCore.open(path)` buffers writes in the engine's id-index WAL and
10
+ // only makes them durable on `flush()`; a hard exit (Ctrl+C, `SIGTERM` from an
11
+ // orchestrator, `pm2 stop`) that never runs an explicit flush would lose writes
12
+ // staged since the last flush.
13
+ //
14
+ // We close that gap the libuv-cooperative way — `process.on('SIGINT'|'SIGTERM'
15
+ // |'exit', () => db.flush())` — NOT a C-level signal handler inside the addon,
16
+ // which would clobber libuv's own signal machinery. In-memory databases
17
+ // (`new NedbCore()`) are never armed; there is nothing to flush.
18
+ //
19
+ // Escape hatch: set NEDB_NO_EXIT_FLUSH=1 to leave signal handling entirely to
20
+ // the host app (it can still call `db.flush()` itself).
21
+ //
22
+ // © INTERCHAINED LLC × Vex (Interchained AI fleet: GLM · Claude · Opus · Fable · GPT-6)
23
+ const native = require('./native.js');
24
+
25
+ const Native = native.NedbCore;
26
+
27
+ // The napi class defines `open` as a NON-writable, NON-configurable static, so the
28
+ // 2.5.x wrapper's `NedbCore.open = …` threw ("Cannot assign to read only property")
29
+ // — and CI's `napi build` was overwriting this file with the generated loader
30
+ // anyway, so the published package never carried the wrapper at all. Both fixed
31
+ // in 2.8.5: wrap by SUBCLASS (an own static on the subclass shadows the parent's),
32
+ // build with `--js native.js` so this file survives, and gate the publish on
33
+ // `NedbCore.__exitFlushWrapped` (see test/durability.test.mjs).
34
+ let NedbCore = Native;
35
+ if (Native && typeof Native.open === 'function' && !Native.__exitFlushWrapped) {
36
+ // Durable handles opened in this process. Strong refs: a durable DB is meant to
37
+ // live for the process, and we must be able to flush it on the way out.
38
+ const live = new Set();
39
+ let armed = false;
40
+
41
+ const flushAll = () => {
42
+ for (const db of live) {
43
+ try {
44
+ db.flush();
45
+ } catch (_) {
46
+ // Best-effort on shutdown — never throw out of an exit handler.
47
+ }
48
+ }
49
+ };
50
+
51
+ const arm = () => {
52
+ if (armed || process.env.NEDB_NO_EXIT_FLUSH) return;
53
+ armed = true;
54
+ // 'exit' fires on normal termination; handlers must be synchronous, and
55
+ // db.flush() is a synchronous native call — so this is safe and sufficient
56
+ // for clean exits and uncaught-exception exits.
57
+ process.on('exit', flushAll);
58
+ // Registering a SIGINT/SIGTERM listener SUPPRESSES Node's default
59
+ // termination, so once we listen we own the exit: flush, then terminate with
60
+ // the conventional 128+signum status.
61
+ const onSignal = (signum) => () => {
62
+ flushAll();
63
+ process.exit(128 + signum);
64
+ };
65
+ process.on('SIGINT', onSignal(2));
66
+ process.on('SIGTERM', onSignal(15));
67
+ };
68
+
69
+ NedbCore = class NedbCore extends Native {
70
+ static open(path) {
71
+ const db = Native.open(path);
72
+ live.add(db);
73
+ arm();
74
+ return db;
75
+ }
76
+ };
77
+ // Mark so a re-require (or a wrapped re-export) never double-wraps.
78
+ Object.defineProperty(NedbCore, '__exitFlushWrapped', { value: true, enumerable: false });
79
+ }
80
+
81
+ module.exports = { ...native, NedbCore };
82
+ // Explicit named re-export so ESM `import { NedbCore } from 'nedb-engine'` (used
83
+ // by the test suite) resolves the class through cjs-module-lexer.
84
+ module.exports.NedbCore = NedbCore;
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nedb-engine",
3
- "version": "8.8.8",
3
+ "version": "9.0.0",
4
4
  "description": "NEDB \u2014 hash-chained, time-traveling, bi-temporal embedded database with Rust native core. SQL, Redis, MongoDB adapters. Causal Write Provenance. RESP2 wire protocol.",
5
5
  "main": "index.js",
6
6
  "exports": {