flatsql 1.3.0 → 1.4.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/dist/index.d.ts CHANGED
@@ -4,9 +4,8 @@ export * from './schema/index.js';
4
4
  export * from './core/index.js';
5
5
  export * from './cluster/index.js';
6
6
  export * from './flatbuffer-accessor.js';
7
- export * from './artifacts/index.js';
7
+ export * from './artifacts/types.js';
8
8
  export * from './response/index.js';
9
- export * from './standalone/index.js';
10
9
  export { FlatSQLDatabase, QueryResult, FlatBufferAccessor } from './core/database.js';
11
10
  export { TableStore, TableRecord } from './core/table-store.js';
12
11
  export { BTree } from './btree/btree.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AAGtC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AAKzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AAGpC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC"}
package/dist/index.js CHANGED
@@ -6,9 +6,12 @@ export * from './schema/index.js';
6
6
  export * from './core/index.js';
7
7
  export * from './cluster/index.js';
8
8
  export * from './flatbuffer-accessor.js';
9
- export * from './artifacts/index.js';
9
+ // Node-only surfaces (artifacts builder: node:sqlite/node:os; standalone
10
+ // runners: node:child_process/node:fs) live behind the 'flatsql/artifacts'
11
+ // and 'flatsql/standalone/wasmedge' subpath exports so the root entry stays
12
+ // loadable in a browser bundle. Only their type declarations are safe here.
13
+ export * from './artifacts/types.js';
10
14
  export * from './response/index.js';
11
- export * from './standalone/index.js';
12
15
  // Re-export main types for convenience
13
16
  export { FlatSQLDatabase } from './core/database.js';
14
17
  export { TableStore } from './core/table-store.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,sEAAsE;AAEtE,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;A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
1
1
  {
2
2
  "name": "flatsql",
3
- "version": "1.3.0",
3
+ "version": "1.4.5",
4
4
  "description": "SQL queries over raw FlatBuffer storage - zero conversion, real-time indexing, pure streaming",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,6 +22,14 @@
22
22
  "types": "./wasm/standalone.d.ts",
23
23
  "import": "./wasm/standalone.js"
24
24
  },
25
+ "./io": {
26
+ "types": "./wasm/flatsql-io.d.ts",
27
+ "import": "./wasm/flatsql-io.js"
28
+ },
29
+ "./artifacts": {
30
+ "types": "./dist/artifacts/index.d.ts",
31
+ "import": "./dist/artifacts/index.js"
32
+ },
25
33
  "./artifacts/standalone": {
26
34
  "types": "./dist/artifacts/standalone-builder.d.ts",
27
35
  "import": "./dist/artifacts/standalone-builder.js"
@@ -68,10 +76,11 @@
68
76
  "dev": "tsc --watch",
69
77
  "serve": "vite docs --port 8081",
70
78
  "check:nav": "node scripts/check-sdn-stack-nav.mjs flatsql docs/index.html",
79
+ "check:dist": "node scripts/check-dist-tracked.mjs",
71
80
  "bench": "node bench/flatsql-perf.mjs",
72
81
  "bench:perf": "node bench/flatsql-perf.mjs",
73
82
  "bench:perf:profile": "node bench/flatsql-perf.mjs --profile",
74
- "prepublishOnly": "npm run build && npm run test:wasi && npm run test:wasmedge && npm test -- --runInBand --runTestsByPath test/package-exports.test.ts test/wasm-generic-extractor.test.ts test/wasm-pointer.test.ts",
83
+ "prepublishOnly": "npm run build && npm run check:dist && npm run test:wasi && npm run test:wasmedge && npm test -- --runInBand --runTestsByPath test/package-exports.test.ts test/wasm-generic-extractor.test.ts test/wasm-pointer.test.ts",
75
84
  "emsdk:install": "bash scripts/install-emsdk.sh",
76
85
  "emsdk:env": "echo 'Run: source packages/emsdk/emsdk_env.sh'",
77
86
  "test:wasi": "node --experimental-wasm-exnref --experimental-vm-modules node_modules/jest/bin/jest.js --runTestsByPath test/wasi.test.ts test/standalone-wasm-imports.test.ts",
@@ -82,7 +91,9 @@
82
91
  "stress:sds:docker-smoke": "bash scripts/stress-docker.sh docker-smoke",
83
92
  "stress:sds:docker-fleet": "bash scripts/stress-docker.sh docker-fleet",
84
93
  "stress:sds:full-config": "bash scripts/stress-docker.sh full-config",
85
- "stress:sds:full": "bash scripts/stress-docker.sh full"
94
+ "stress:sds:full": "bash scripts/stress-docker.sh full",
95
+ "check:imports": "node scripts/check-wasm-imports.mjs",
96
+ "test:io": "node wasm/test-io-persistence.mjs"
86
97
  },
87
98
  "repository": {
88
99
  "type": "git",
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Types for the FlatSQL host I/O contract (cpp/include/flatsql/flatsql_io.h).
3
+ *
4
+ * These live in the flatsql package on purpose: the seven-call shape is an ABI,
5
+ * and an ABI that each consumer re-declares locally is an ABI that drifts.
6
+ */
7
+
8
+ export declare const FLATSQL_IO_READ: number;
9
+ export declare const FLATSQL_IO_WRITE: number;
10
+ export declare const FLATSQL_IO_CREATE: number;
11
+ export declare const FLATSQL_IO_EXCL: number;
12
+ export declare const FLATSQL_IO_TRUNC: number;
13
+ export declare const FLATSQL_IO_DELETE_ON_CLOSE: number;
14
+ /** Namespace op: does the path exist? Returns a status, allocates no handle. */
15
+ export declare const FLATSQL_IO_PROBE: number;
16
+ /** Namespace op: remove the path. Returns a status, allocates no handle. */
17
+ export declare const FLATSQL_IO_UNLINK: number;
18
+
19
+ export declare const FLATSQL_IO_ERR_GENERIC: number;
20
+ export declare const FLATSQL_IO_ERR_NOENT: number;
21
+ export declare const FLATSQL_IO_ERR_ACCESS: number;
22
+ export declare const FLATSQL_IO_ERR_IO: number;
23
+ export declare const FLATSQL_IO_ERR_NOSPACE: number;
24
+ export declare const FLATSQL_IO_ERR_BADHANDLE: number;
25
+
26
+ export declare const DEFAULT_CHUNK_BYTES: number;
27
+
28
+ /**
29
+ * A backend answers the seven imports SYNCHRONOUSLY, because a wasm import is
30
+ * synchronous. Offsets and sizes are plain numbers (f64 on the wire — never
31
+ * i64, which emscripten legalizes differently in the two lanes).
32
+ */
33
+ export interface FlatSqlIoBackend {
34
+ /** Returns a handle, or a negative status. PROBE/UNLINK return a status. */
35
+ open(path: string, flags: number): number;
36
+ /** Bytes read; may be short at EOF. Never moves an implicit cursor. */
37
+ read(handle: number, dst: Uint8Array, offset: number): number;
38
+ /** Bytes written. Writing past EOF extends; the gap reads as zeroes. */
39
+ write(handle: number, src: Uint8Array, offset: number): number;
40
+ truncate(handle: number, size: number): number;
41
+ /**
42
+ * Durability barrier. On a synchronous backend bytes are durable at return;
43
+ * on an async store they become durable when the caller awaits flush().
44
+ */
45
+ sync(handle: number): number;
46
+ size(handle: number): number;
47
+ close(handle: number): number;
48
+
49
+ /** Pull a file into the synchronous cache BEFORE the engine opens it. */
50
+ hydrate(path: string): Promise<unknown>;
51
+ /** Persist dirty state. No-op on synchronous backends. */
52
+ flush(): Promise<void>;
53
+ /** Remove a file and every key backing it. */
54
+ drop(path: string): Promise<void>;
55
+
56
+ readonly kind?: string;
57
+ }
58
+
59
+ export interface FlatSqlIoChunkOptions {
60
+ /** Page-group size in bytes. */
61
+ chunkBytes?: number;
62
+ /** Key namespace inside the store. */
63
+ prefix?: string;
64
+ /** Paths already known to exist. */
65
+ knownPaths?: string[];
66
+ }
67
+
68
+ /** Flat key -> bytes store: the shape every browser persistence store has. */
69
+ export interface FlatSqlKeyValueStore {
70
+ readBytes(key: string): Promise<Uint8Array | null>;
71
+ writeBytes(key: string, bytes: Uint8Array): Promise<void>;
72
+ deleteKey(key: string): Promise<void>;
73
+ }
74
+
75
+ export declare function createMemoryBackend(
76
+ options?: { chunkBytes?: number },
77
+ ): FlatSqlIoBackend;
78
+
79
+ export declare function createNodeFsBackend(
80
+ fs: unknown,
81
+ options?: { root?: string },
82
+ ): FlatSqlIoBackend;
83
+
84
+ /**
85
+ * Give a flat key -> bytes store real pread/pwrite semantics by addressing
86
+ * fixed-size page groups. A flush costs O(dirty chunks), not O(file).
87
+ */
88
+ export declare function createChunkedStoreBackend(
89
+ store: FlatSqlKeyValueStore,
90
+ options?: FlatSqlIoChunkOptions,
91
+ ): FlatSqlIoBackend & { knownPaths(): string[]; chunkBytes: number };
92
+
93
+ /** Build the `env` import object for a directly-instantiated (WASI) module. */
94
+ export declare function createFlatSqlIoImports(
95
+ backend: FlatSqlIoBackend,
96
+ memoryRef: () => WebAssembly.Memory,
97
+ ): Record<string, (...args: number[]) => number>;