@yydb/light-db 0.0.17 → 0.1.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/dist/api/index.d.ts +4 -9
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +3 -6
- package/dist/api/index.js.map +1 -1
- package/dist/api/types.d.ts +71 -42
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/types.js +5 -3
- package/dist/api/types.js.map +1 -1
- package/dist/api/wasm-database.d.ts +134 -27
- package/dist/api/wasm-database.d.ts.map +1 -1
- package/dist/api/wasm-database.js +172 -28
- package/dist/api/wasm-database.js.map +1 -1
- package/dist/index.d.ts +14 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -11
- package/dist/index.js.map +1 -1
- package/dist/shared/micro.d.ts +86 -0
- package/dist/shared/micro.d.ts.map +1 -0
- package/dist/shared/micro.js +194 -0
- package/dist/shared/micro.js.map +1 -0
- package/dist/shared/udf-types.d.ts +31 -0
- package/dist/shared/udf-types.d.ts.map +1 -0
- package/dist/shared/udf-types.js +12 -0
- package/dist/shared/udf-types.js.map +1 -0
- package/package.json +5 -7
- package/readme.md +60 -63
- package/dist/api/database.d.ts +0 -101
- package/dist/api/database.d.ts.map +0 -1
- package/dist/api/database.js +0 -149
- package/dist/api/database.js.map +0 -1
- package/dist/api/schema.d.ts +0 -33
- package/dist/api/schema.d.ts.map +0 -1
- package/dist/api/schema.js +0 -80
- package/dist/api/schema.js.map +0 -1
- package/dist/api/transaction.d.ts +0 -26
- package/dist/api/transaction.d.ts.map +0 -1
- package/dist/api/transaction.js +0 -52
- package/dist/api/transaction.js.map +0 -1
- package/dist/codec/binary.d.ts +0 -196
- package/dist/codec/binary.d.ts.map +0 -1
- package/dist/codec/binary.js +0 -342
- package/dist/codec/binary.js.map +0 -1
- package/dist/codec/checksum.d.ts +0 -21
- package/dist/codec/checksum.d.ts.map +0 -1
- package/dist/codec/checksum.js +0 -46
- package/dist/codec/checksum.js.map +0 -1
- package/dist/codec/index.d.ts +0 -12
- package/dist/codec/index.d.ts.map +0 -1
- package/dist/codec/index.js +0 -10
- package/dist/codec/index.js.map +0 -1
- package/dist/codec/page.d.ts +0 -114
- package/dist/codec/page.d.ts.map +0 -1
- package/dist/codec/page.js +0 -225
- package/dist/codec/page.js.map +0 -1
- package/dist/codec/record.d.ts +0 -62
- package/dist/codec/record.d.ts.map +0 -1
- package/dist/codec/record.js +0 -82
- package/dist/codec/record.js.map +0 -1
- package/dist/core/broadcast.d.ts +0 -39
- package/dist/core/broadcast.d.ts.map +0 -1
- package/dist/core/broadcast.js +0 -54
- package/dist/core/broadcast.js.map +0 -1
- package/dist/core/checkpoint.d.ts +0 -23
- package/dist/core/checkpoint.d.ts.map +0 -1
- package/dist/core/checkpoint.js +0 -49
- package/dist/core/checkpoint.js.map +0 -1
- package/dist/core/engine.d.ts +0 -142
- package/dist/core/engine.d.ts.map +0 -1
- package/dist/core/engine.js +0 -304
- package/dist/core/engine.js.map +0 -1
- package/dist/core/index.d.ts +0 -17
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -13
- package/dist/core/index.js.map +0 -1
- package/dist/core/lease.d.ts +0 -32
- package/dist/core/lease.d.ts.map +0 -1
- package/dist/core/lease.js +0 -81
- package/dist/core/lease.js.map +0 -1
- package/dist/core/records.d.ts +0 -49
- package/dist/core/records.d.ts.map +0 -1
- package/dist/core/records.js +0 -70
- package/dist/core/records.js.map +0 -1
- package/dist/core/recovery.d.ts +0 -43
- package/dist/core/recovery.d.ts.map +0 -1
- package/dist/core/recovery.js +0 -99
- package/dist/core/recovery.js.map +0 -1
- package/dist/core/wal.d.ts +0 -50
- package/dist/core/wal.d.ts.map +0 -1
- package/dist/core/wal.js +0 -114
- package/dist/core/wal.js.map +0 -1
- package/dist/storage/StorageAdapter.d.ts +0 -97
- package/dist/storage/StorageAdapter.d.ts.map +0 -1
- package/dist/storage/StorageAdapter.js +0 -9
- package/dist/storage/StorageAdapter.js.map +0 -1
- package/dist/storage/index.d.ts +0 -11
- package/dist/storage/index.d.ts.map +0 -1
- package/dist/storage/index.js +0 -10
- package/dist/storage/index.js.map +0 -1
- package/dist/storage/indexeddb/IndexedDbStorageAdapter.d.ts +0 -140
- package/dist/storage/indexeddb/IndexedDbStorageAdapter.d.ts.map +0 -1
- package/dist/storage/indexeddb/IndexedDbStorageAdapter.js +0 -403
- package/dist/storage/indexeddb/IndexedDbStorageAdapter.js.map +0 -1
- package/dist/storage/memory/MemoryStorageAdapter.d.ts +0 -76
- package/dist/storage/memory/MemoryStorageAdapter.d.ts.map +0 -1
- package/dist/storage/memory/MemoryStorageAdapter.js +0 -212
- package/dist/storage/memory/MemoryStorageAdapter.js.map +0 -1
- package/dist/storage/opfs/OpfsStorageAdapter.d.ts +0 -141
- package/dist/storage/opfs/OpfsStorageAdapter.d.ts.map +0 -1
- package/dist/storage/opfs/OpfsStorageAdapter.js +0 -400
- package/dist/storage/opfs/OpfsStorageAdapter.js.map +0 -1
package/dist/api/index.d.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* api 层导出
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* 唯一的生产路径:{@link Database}(WASM-backed,委托给
|
|
5
|
+
* `@yydb/yydb-unknown-wasm32` 的 Rust 语义核心)。
|
|
6
6
|
*/
|
|
7
|
-
export { Database } from './database';
|
|
8
|
-
export type {
|
|
9
|
-
export { WasmDatabase, TransactionHandle, openLightDatabase } from './wasm-database';
|
|
10
|
-
export { Transaction } from './transaction';
|
|
11
|
-
export type { TransactionState } from './transaction';
|
|
12
|
-
export { SCHEMA_KEY, RESERVED_KEY_PREFIX, documentVersion, parseSchemaDocument, encodeSchema, decodeSchema } from './schema';
|
|
13
|
-
export type { LightDatabase, LightDatabaseOptions } from './types';
|
|
7
|
+
export { Database, TransactionHandle, openLightDatabase } from './wasm-database';
|
|
8
|
+
export type { BatchChange, LightDatabase, MigrateOptions, OpenOptions, ScanOptions, ScanRow, SchemaVersion, } from './types';
|
|
14
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEjF,YAAY,EACR,WAAW,EACX,aAAa,EACb,cAAc,EACd,WAAW,EACX,WAAW,EACX,OAAO,EACP,aAAa,GAChB,MAAM,SAAS,CAAC"}
|
package/dist/api/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* api 层导出
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* 唯一的生产路径:{@link Database}(WASM-backed,委托给
|
|
5
|
+
* `@yydb/yydb-unknown-wasm32` 的 Rust 语义核心)。
|
|
6
6
|
*/
|
|
7
|
-
export { Database } from './database';
|
|
8
|
-
export { WasmDatabase, TransactionHandle, openLightDatabase } from './wasm-database';
|
|
9
|
-
export { Transaction } from './transaction';
|
|
10
|
-
export { SCHEMA_KEY, RESERVED_KEY_PREFIX, documentVersion, parseSchemaDocument, encodeSchema, decodeSchema } from './schema';
|
|
7
|
+
export { Database, TransactionHandle, openLightDatabase } from './wasm-database';
|
|
11
8
|
//# sourceMappingURL=index.js.map
|
package/dist/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/api/types.d.ts
CHANGED
|
@@ -1,61 +1,90 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Browser database authoring-surface types.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* These are the stable contract for `@yydb/light-db`:
|
|
5
|
+
* - Binary values are always `Uint8Array` — never `Buffer`.
|
|
6
|
+
* - No local file paths, file handles, or Node-exclusive types leak through.
|
|
7
|
+
* - Aligned with the Node-side `@yydb/yydb` method names and return semantics.
|
|
6
8
|
*/
|
|
7
|
-
|
|
8
|
-
import type { CheckpointResult, StorageEngineStats } from '../core/engine';
|
|
9
|
-
import type { StorageAdapterFactory } from '../storage/StorageAdapter';
|
|
10
|
-
/** Schema 版本与文档,与 `@yydb/yydb` 同构 */
|
|
9
|
+
/** Schema version and document (aligned with `@yydb/yydb`). */
|
|
11
10
|
export interface SchemaVersion {
|
|
12
|
-
/** Schema 版本 */
|
|
13
11
|
version: number;
|
|
14
|
-
/** Schema 文档全文 */
|
|
15
12
|
document: string;
|
|
16
13
|
}
|
|
17
|
-
/**
|
|
18
|
-
export interface
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
/** One row from {@link Database.scan}. */
|
|
15
|
+
export interface ScanRow {
|
|
16
|
+
key: string;
|
|
17
|
+
value: Uint8Array;
|
|
18
|
+
}
|
|
19
|
+
/** Options for {@link Database.scan}. */
|
|
20
|
+
export interface ScanOptions {
|
|
21
|
+
/** Include this prefix in every returned key; default `""` returns everything. */
|
|
22
|
+
prefix?: string;
|
|
23
|
+
/** Exclusive continuation cursor from a previous scan's last row; default `null` starts fresh. */
|
|
24
|
+
after?: string | null;
|
|
25
|
+
/** Max rows returned per call; default `1000`. */
|
|
26
|
+
limit?: number;
|
|
27
|
+
}
|
|
28
|
+
/** One change in {@link Database.batch}. Use `null` to delete. */
|
|
29
|
+
export interface BatchChange {
|
|
30
|
+
key: string;
|
|
31
|
+
value: Uint8Array | string | null;
|
|
32
|
+
}
|
|
33
|
+
/** Options for {@link Database.migrateSchema}. */
|
|
34
|
+
export interface MigrateOptions {
|
|
35
|
+
/** Rename entries — `fromType`/`toType` updates a type name; `type`/`fromField`/`toField` updates one field. */
|
|
36
|
+
renames?: ReadonlyArray<{
|
|
37
|
+
fromType: string;
|
|
38
|
+
toType: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: string;
|
|
41
|
+
fromField: string;
|
|
42
|
+
toField: string;
|
|
43
|
+
}>;
|
|
44
|
+
}
|
|
45
|
+
/** Options for opening the WASM-backed {@link Database}. */
|
|
46
|
+
export interface OpenOptions {
|
|
47
|
+
/** Use an in-memory session (test only; default is OPFS persistent). */
|
|
48
|
+
memory?: boolean;
|
|
29
49
|
}
|
|
30
50
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
51
|
+
* Light database contract — aligned with the Node-side `@yydb/yydb`.
|
|
52
|
+
* Only the WASM-backed {@link Database} implements this in production;
|
|
53
|
+
* the formerly pure-TS backend has been removed.
|
|
34
54
|
*/
|
|
35
55
|
export interface LightDatabase {
|
|
36
|
-
/**
|
|
56
|
+
/** Database name (OPFS path / namespace). */
|
|
37
57
|
readonly name: string;
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
/**
|
|
58
|
+
/** Engine version string. */
|
|
59
|
+
serverVersion(): string;
|
|
60
|
+
/** Basic diagnostics — session info from the engine. */
|
|
61
|
+
info(): string;
|
|
62
|
+
/** Published schema metadata, or `null` before the first schema. */
|
|
63
|
+
getSchema(): Promise<SchemaVersion | null>;
|
|
64
|
+
/**
|
|
65
|
+
* Validate and publish a VOS schema document. Accepts raw `.vos`
|
|
66
|
+
* source or `@voml/vos` descriptors (e.g. `v.table()`, `v.class()`).
|
|
67
|
+
*/
|
|
68
|
+
ensureSchema(...input: [string] | object[]): Promise<void>;
|
|
69
|
+
/** Read one record, or `null`. */
|
|
43
70
|
get(key: string): Promise<Uint8Array | null>;
|
|
44
|
-
/**
|
|
45
|
-
put(key: string, value: Uint8Array): Promise<void>;
|
|
46
|
-
/**
|
|
47
|
-
delete(key: string): Promise<
|
|
48
|
-
/**
|
|
71
|
+
/** Insert or replace one record. */
|
|
72
|
+
put(key: string, value: Uint8Array | string): Promise<void>;
|
|
73
|
+
/** Delete one record. Silently succeeds when absent. */
|
|
74
|
+
delete(key: string): Promise<void>;
|
|
75
|
+
/** Fold the WAL into the main storage. */
|
|
76
|
+
checkpoint(): Promise<void>;
|
|
77
|
+
/** Begin an explicit transaction. */
|
|
49
78
|
begin(): Promise<void>;
|
|
50
|
-
/**
|
|
79
|
+
/** Commit the current transaction. */
|
|
51
80
|
commit(): Promise<void>;
|
|
52
|
-
/**
|
|
81
|
+
/** Roll back the current transaction. */
|
|
53
82
|
rollback(): Promise<void>;
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
/**
|
|
83
|
+
/** Execute a VOS read pipeline. */
|
|
84
|
+
query<T = Record<string, unknown>>(source: string): Promise<T[]>;
|
|
85
|
+
/** Execute a VOS write program. */
|
|
86
|
+
execute(source: string): Promise<void>;
|
|
87
|
+
/** Close the session. Idempotent. */
|
|
59
88
|
close(): Promise<void>;
|
|
60
89
|
}
|
|
61
90
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/api/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"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db`:
|
|
5
|
+
* - Binary values are always `Uint8Array` — never `Buffer`.
|
|
6
|
+
* - No local file paths, file handles, or Node-exclusive types leak through.
|
|
7
|
+
* - Aligned with the Node-side `@yydb/yydb` method names and return semantics.
|
|
6
8
|
*/
|
|
7
9
|
export {};
|
|
8
10
|
//# sourceMappingURL=types.js.map
|
package/dist/api/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -1,10 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WASM-backed Database — the production path for `@yydb/light-db`.
|
|
3
|
+
*
|
|
4
|
+
* Delegates to `@yydb/yydb-unknown-wasm32`, which ships a Rust semantic
|
|
5
|
+
* core compiled to WebAssembly. This gives browser users the same VOS
|
|
6
|
+
* schema validation, transaction semantics, OPFS persistence and UDF
|
|
7
|
+
* execution as the Node-side `@yydb/yydb`.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* // Node
|
|
11
|
+
* import { Database } from '@yydb/yydb';
|
|
12
|
+
* const db = await Database.open('app.yydb');
|
|
13
|
+
*
|
|
14
|
+
* // Browser
|
|
15
|
+
* import { Database } from '@yydb/light-db';
|
|
16
|
+
* const db = await Database.open('app');
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
1
19
|
import { type WasmSession } from '@yydb/yydb-unknown-wasm32';
|
|
2
20
|
import { type EmittableItem } from '@voml/vos';
|
|
3
|
-
import
|
|
4
|
-
|
|
21
|
+
import { type DefinedMicro, type MicroHandle } from '../shared/micro.js';
|
|
22
|
+
import type { BatchChange, LightDatabase, MigrateOptions, OpenOptions, ScanOptions, ScanRow, SchemaVersion } from './types.js';
|
|
23
|
+
import type { InferUdfArgs, InferUdfReturn, UdfScalarDescriptor } from '../shared/udf-types.js';
|
|
24
|
+
/**
|
|
25
|
+
* Transaction-local handle passed to {@link Database.transaction} callbacks.
|
|
26
|
+
* All methods forward to the underlying WASM session; commit/rollback are
|
|
27
|
+
* owned by {@link Database.transaction}.
|
|
28
|
+
*/
|
|
5
29
|
export declare class TransactionHandle {
|
|
6
30
|
private readonly session;
|
|
7
31
|
constructor(session: WasmSession);
|
|
32
|
+
/** Parse a WASM envelope, converting `{ ok: false, error }` to a thrown error. */
|
|
8
33
|
private parseResult;
|
|
9
34
|
get(key: string): Promise<Uint8Array | null>;
|
|
10
35
|
put(key: string, value: Uint8Array | string): Promise<void>;
|
|
@@ -16,49 +41,131 @@ export declare class TransactionHandle {
|
|
|
16
41
|
execute(source: string): Promise<void>;
|
|
17
42
|
}
|
|
18
43
|
/**
|
|
19
|
-
* Browser
|
|
44
|
+
* Browser-local YYDB handle.
|
|
20
45
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
46
|
+
* This is the main {@link Database} export of `@yydb/light-db`. It owns a
|
|
47
|
+
* Rust-backed WASM session (memory or OPFS) and exposes the same user API
|
|
48
|
+
* as the Node-side `@yydb/yydb`.
|
|
23
49
|
*/
|
|
24
|
-
export declare class
|
|
25
|
-
/**
|
|
50
|
+
export declare class Database implements LightDatabase {
|
|
51
|
+
/** Database name (OPFS path). */
|
|
26
52
|
readonly name: string;
|
|
27
53
|
private readonly session;
|
|
54
|
+
private readonly registry;
|
|
28
55
|
private constructor();
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Initialize WASM and open a session (in-memory or OPFS persistent).
|
|
58
|
+
*
|
|
59
|
+
* @param name Database name. Persistent sessions use it as the OPFS path.
|
|
60
|
+
* @param options Open options — pass `{ memory: true }` for a transient session.
|
|
61
|
+
*/
|
|
62
|
+
static open(name: string, options?: OpenOptions): Promise<Database>;
|
|
63
|
+
/** Parse a WASM envelope, converting `{ ok: false, error }` to a thrown error. */
|
|
32
64
|
private parseResult;
|
|
33
|
-
/**
|
|
65
|
+
/** Engine version string (same as `@yydb/yydb` semver). */
|
|
66
|
+
serverVersion(): string;
|
|
67
|
+
/** Basic diagnostics: session info from the WASM core. */
|
|
68
|
+
info(): string;
|
|
69
|
+
/** Published schema metadata, or `null` before the first schema. */
|
|
34
70
|
getSchema(): Promise<SchemaVersion | null>;
|
|
35
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* Validate and publish a VOS schema document.
|
|
73
|
+
*
|
|
74
|
+
* Accepts either a raw `.vos` source string, or `@voml/vos` descriptors
|
|
75
|
+
* (`v.table()`, `v.class()`). When descriptors are supplied, they are
|
|
76
|
+
* rendered to source via `emitSource` before being handed to the Rust
|
|
77
|
+
* core for validation.
|
|
78
|
+
*/
|
|
36
79
|
ensureSchema(...input: [string] | EmittableItem[]): Promise<void>;
|
|
37
|
-
/**
|
|
80
|
+
/** Read one record, or `null`. */
|
|
38
81
|
get(key: string): Promise<Uint8Array | null>;
|
|
39
|
-
/**
|
|
82
|
+
/** Insert or replace one record. */
|
|
40
83
|
put(key: string, value: Uint8Array | string): Promise<void>;
|
|
41
|
-
/**
|
|
84
|
+
/** Delete one record. Silently succeeds when the key is absent. */
|
|
42
85
|
delete(key: string): Promise<void>;
|
|
43
|
-
/**
|
|
86
|
+
/** List key/value pairs in lexical order. */
|
|
44
87
|
scan(options?: ScanOptions): Promise<ScanRow[]>;
|
|
45
|
-
/**
|
|
88
|
+
/** Atomically write or delete many keys in one call. */
|
|
46
89
|
batch(changes: readonly BatchChange[]): Promise<void>;
|
|
47
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* Compare-and-swap: replace or delete `key` only when its current value
|
|
92
|
+
* exactly equals `expected`. Both may be `null` (meaning absent / delete).
|
|
93
|
+
*/
|
|
48
94
|
compareExchange(key: string, expected: Uint8Array | string | null, replacement: Uint8Array | string | null): Promise<boolean>;
|
|
49
|
-
/**
|
|
95
|
+
/** Fold the WAL into the main storage. */
|
|
96
|
+
checkpoint(): Promise<void>;
|
|
97
|
+
/** Begin an explicit transaction. Balanced with {@link commit} or {@link rollback}. */
|
|
98
|
+
begin(): Promise<void>;
|
|
99
|
+
/** Commit the current transaction. */
|
|
100
|
+
commit(): Promise<void>;
|
|
101
|
+
/** Roll back the current transaction. */
|
|
102
|
+
rollback(): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Run `fn` inside an explicit transaction. Commits on normal return,
|
|
105
|
+
* rolls back on throw. Nested calls are not supported.
|
|
106
|
+
*/
|
|
50
107
|
transaction<T>(fn: (tx: TransactionHandle) => Promise<T>): Promise<T>;
|
|
51
|
-
/**
|
|
108
|
+
/** Execute a VOS read pipeline and return typed rows. */
|
|
52
109
|
query<T = Record<string, unknown>>(source: string): Promise<T[]>;
|
|
53
|
-
/**
|
|
110
|
+
/** Execute a VOS write program. */
|
|
54
111
|
execute(source: string): Promise<void>;
|
|
55
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* Publish a new schema version, migrating existing records when their
|
|
114
|
+
* shape no longer matches. Accepts raw `.vos` source or descriptors.
|
|
115
|
+
*/
|
|
56
116
|
migrateSchema(documentOrSource: string | EmittableItem, ...rest: (EmittableItem | MigrateOptions)[]): Promise<void>;
|
|
57
|
-
/**
|
|
58
|
-
|
|
59
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Override the host micro invoker.
|
|
119
|
+
*
|
|
120
|
+
* The constructor wires this to the per-session {@link MicroSessionRegistry}
|
|
121
|
+
* so that high-level {@link registerMicro} + {@link callScalar} works out of
|
|
122
|
+
* the box. Call this only if you need to replace the default resolution
|
|
123
|
+
* logic (e.g. to inject a mock invoker in tests).
|
|
124
|
+
*/
|
|
125
|
+
overrideMicroHostInvoker(invoker: (payload: {
|
|
126
|
+
hostId: number;
|
|
127
|
+
handleVersion: number;
|
|
128
|
+
functionId: string;
|
|
129
|
+
args: readonly unknown[];
|
|
130
|
+
}) => unknown): void;
|
|
131
|
+
/**
|
|
132
|
+
* Build a typed session-local micro definition without registering it.
|
|
133
|
+
*
|
|
134
|
+
* Same signature as the Node-side `@yydb/yydb`; this is a thin alias
|
|
135
|
+
* over the shared `defineMicro` helper so author code stays portable.
|
|
136
|
+
*/
|
|
137
|
+
defineMicro<TArgs extends readonly UdfScalarDescriptor[], TReturn extends UdfScalarDescriptor>(input: {
|
|
138
|
+
readonly name: string;
|
|
139
|
+
readonly version: number;
|
|
140
|
+
readonly args: TArgs;
|
|
141
|
+
readonly returns: TReturn;
|
|
142
|
+
readonly effect: 'pure';
|
|
143
|
+
readonly deterministic: boolean;
|
|
144
|
+
readonly mode?: 'scalar';
|
|
145
|
+
readonly fn: (...args: InferUdfArgs<TArgs>) => InferUdfReturn<TReturn>;
|
|
146
|
+
}): DefinedMicro<TArgs, TReturn>;
|
|
147
|
+
/**
|
|
148
|
+
* Install a session-local host micro into both the JS registry and the
|
|
149
|
+
* WASM core. Host micros never persist across sessions.
|
|
150
|
+
*
|
|
151
|
+
* Uses the high-level JSON bridge (`registerMicroJson`) so we never
|
|
152
|
+
* encode wire bodies in TS; Rust owns the protocol.
|
|
153
|
+
*/
|
|
154
|
+
registerMicro<TArgs extends readonly UdfScalarDescriptor[], TReturn extends UdfScalarDescriptor>(definition: DefinedMicro<TArgs, TReturn>): Promise<MicroHandle>;
|
|
155
|
+
/**
|
|
156
|
+
* Invoke a registered scalar UDF via the WASM core.
|
|
157
|
+
*
|
|
158
|
+
* Uses the high-level JSON bridge (`callScalarJson`) — args are encoded
|
|
159
|
+
* as plain JSON scalars (`number`, `string`, `boolean`, `null`).
|
|
160
|
+
*/
|
|
161
|
+
callScalar(name: string, version: number, args: readonly (string | number | boolean | null)[]): Promise<string | number | boolean | null>;
|
|
162
|
+
/**
|
|
163
|
+
* Close the session. Idempotent — further calls fail.
|
|
164
|
+
*
|
|
165
|
+
* On persistent (OPFS) sessions this triggers a final snapshot publish.
|
|
166
|
+
*/
|
|
60
167
|
close(): Promise<void>;
|
|
61
168
|
}
|
|
62
|
-
/**
|
|
63
|
-
export declare function openLightDatabase(name: string, options?: OpenOptions): Promise<
|
|
169
|
+
/** Open a browser database — convenience alias for {@link Database.open}. */
|
|
170
|
+
export declare function openLightDatabase(name: string, options?: OpenOptions): Promise<Database>;
|
|
64
171
|
//# sourceMappingURL=wasm-database.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasm-database.d.ts","sourceRoot":"","sources":["../../src/api/wasm-database.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"wasm-database.d.ts","sourceRoot":"","sources":["../../src/api/wasm-database.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAKH,KAAK,WAAW,EACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAE3D,OAAO,EAKH,KAAK,YAAY,EACjB,KAAK,WAAW,EACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACR,WAAW,EACX,aAAa,EACb,cAAc,EACd,WAAW,EACX,WAAW,EACX,OAAO,EACP,aAAa,EAChB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EACR,YAAY,EACZ,cAAc,EACd,mBAAmB,EACtB,MAAM,wBAAwB,CAAC;AAiBhC;;;;GAIG;AACH,qBAAa,iBAAiB;IACd,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,WAAW;IAEjD,kFAAkF;IAClF,OAAO,CAAC,WAAW;IASb,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAQ5C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK3D,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlC,IAAI,CAAC,OAAO,GA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