hyperdb-wasm 0.0.26845-dev.wasm.g5b622080 → 0.0.26861-dev.wasm.g004c5a60
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.d.ts +61 -36
- package/dist/browser.d.ts +3 -1
- package/dist/browser.js +305 -236
- package/dist/browser_external_directory.d.ts +43 -0
- package/dist/browser_worker.js +693 -92
- package/dist/client.d.ts +6 -12
- package/dist/hyperdb-wasm.cjs +1 -1
- package/dist/hyperdb-wasm.js +1 -1
- package/dist/hyperdb-wasm.wasm.br +0 -0
- package/dist/index.d.ts +20 -2
- package/dist/index.node.d.ts +5 -3
- package/dist/node.d.ts +2 -1
- package/dist/node.js +12352 -315
- package/dist/node_external_directory.d.ts +41 -0
- package/dist/node_worker.js +869 -89
- package/dist/protocol.d.ts +30 -38
- package/dist/raw.browser.js +211 -87
- package/dist/raw.d.ts +2 -1
- package/dist/raw.node.js +205 -86
- package/dist/wasm_bindings.d.ts +64 -9
- package/dist/worker_setup.d.ts +22 -0
- package/examples/browser-attached-databases.html +5 -5
- package/examples/browser.html +1 -1
- package/examples/node-attached-databases.mjs +17 -16
- package/examples/node.mjs +11 -9
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -2,28 +2,22 @@ import { DataType, Table } from 'apache-arrow';
|
|
|
2
2
|
import type { AsyncRecordBatchStreamReader, TypeMap } from 'apache-arrow';
|
|
3
3
|
import type { HyperDBEngineClient } from './client.js';
|
|
4
4
|
import type { BrowserClientOptions } from './browser.js';
|
|
5
|
-
import type { WasmResult } from './protocol.js';
|
|
5
|
+
import type { MountSource, WasmResult } from './protocol.js';
|
|
6
|
+
import type { HyperDBErrorSource } from './protocol.js';
|
|
6
7
|
export interface HyperDBClient {
|
|
7
8
|
ready(): Promise<void>;
|
|
8
9
|
initialize(settings: string): Promise<WasmResult>;
|
|
9
10
|
connect(): Promise<WasmResult>;
|
|
10
11
|
disconnect(connection: number): Promise<WasmResult>;
|
|
11
|
-
createDatabase(databaseName: string, persistent: boolean): Promise<WasmResult>;
|
|
12
|
-
openDatabase(databaseName: string): Promise<WasmResult>;
|
|
13
|
-
listDatabases(): Promise<WasmResult>;
|
|
14
|
-
checkpointDatabase(databaseName: string): Promise<WasmResult>;
|
|
15
|
-
dropDatabase(databaseName: string): Promise<WasmResult>;
|
|
16
|
-
attachDatabase(connection: number, databaseName: string, alias: string): Promise<WasmResult>;
|
|
17
|
-
detachDatabase(connection: number, alias: string): Promise<WasmResult>;
|
|
18
12
|
startQuery(connection: number, sql: string): Promise<WasmResult>;
|
|
19
13
|
insertArrowIPCFromPath(connection: number, path: string, name: string, schema: string | null, create: boolean, internal?: boolean): Promise<WasmResult>;
|
|
20
14
|
createTemporaryFile(bytes: Uint8Array): Promise<WasmResult>;
|
|
21
15
|
removeFile(path: string): Promise<WasmResult>;
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
mount(source: MountSource, path: string, mode: MountAccessMode): Promise<WasmResult>;
|
|
17
|
+
unmount(path: string): Promise<WasmResult>;
|
|
24
18
|
pollQuery(query: number): Promise<WasmResult>;
|
|
25
19
|
cancelQuery(query: number): Promise<WasmResult>;
|
|
26
|
-
|
|
20
|
+
finishQuery(query: number): Promise<WasmResult>;
|
|
27
21
|
shutdown(): Promise<WasmResult>;
|
|
28
22
|
terminate(): Promise<void>;
|
|
29
23
|
}
|
|
@@ -32,14 +26,16 @@ export interface ArrowInsertOptions {
|
|
|
32
26
|
readonly schema?: string;
|
|
33
27
|
readonly create?: boolean;
|
|
34
28
|
}
|
|
35
|
-
export
|
|
36
|
-
|
|
29
|
+
export type MountAccessMode = 'read' | 'readwrite';
|
|
30
|
+
export interface MountOptions {
|
|
31
|
+
readonly path: string;
|
|
32
|
+
readonly mode?: MountAccessMode;
|
|
37
33
|
}
|
|
38
|
-
export interface
|
|
39
|
-
readonly
|
|
40
|
-
|
|
41
|
-
readonly size: number;
|
|
34
|
+
export interface MountedResource {
|
|
35
|
+
readonly path: string;
|
|
36
|
+
close(): Promise<void>;
|
|
42
37
|
}
|
|
38
|
+
export declare function validateMountPath(path: unknown): asserts path is string;
|
|
43
39
|
export type HyperDBSettingValue = string | number | boolean | null | readonly HyperDBSettingValue[] | {
|
|
44
40
|
readonly [key: string]: HyperDBSettingValue;
|
|
45
41
|
};
|
|
@@ -48,31 +44,62 @@ export interface HyperDBCreateOptions {
|
|
|
48
44
|
readonly settings?: HyperDBSettings;
|
|
49
45
|
}
|
|
50
46
|
export type BrowserCreateOptions = BrowserClientOptions & HyperDBCreateOptions;
|
|
51
|
-
export
|
|
52
|
-
readonly
|
|
53
|
-
|
|
47
|
+
export type QueryMetricValue = null | boolean | number | string | readonly QueryMetricValue[] | {
|
|
48
|
+
readonly [key: string]: QueryMetricValue;
|
|
49
|
+
};
|
|
50
|
+
export type QueryMetrics = Readonly<Record<string, QueryMetricValue>>;
|
|
51
|
+
export interface QueryTimings {
|
|
52
|
+
readonly elapsedSeconds: number | null;
|
|
53
|
+
readonly parsingSeconds: number | null;
|
|
54
|
+
readonly compilationSeconds: number | null;
|
|
55
|
+
readonly executionSeconds: number | null;
|
|
56
|
+
readonly commitSeconds: number | null;
|
|
57
|
+
readonly timeToScheduleSeconds: number | null;
|
|
58
|
+
readonly timeToFirstResultSeconds: number | null;
|
|
59
|
+
readonly cancellationSeconds: number | null;
|
|
60
|
+
}
|
|
61
|
+
export interface QueryInfo {
|
|
62
|
+
readonly status: 'succeeded' | 'failed' | 'canceled';
|
|
63
|
+
readonly started: boolean;
|
|
64
|
+
readonly statementKind: string | null;
|
|
65
|
+
readonly producesRows: boolean;
|
|
66
|
+
readonly rowCount: bigint | null;
|
|
67
|
+
readonly columnCount: number | null;
|
|
68
|
+
readonly cancellationRequestedByUser: boolean;
|
|
69
|
+
readonly queryPlan: Readonly<Record<string, unknown>> | null;
|
|
70
|
+
readonly dependencies: readonly string[];
|
|
71
|
+
readonly timings: QueryTimings;
|
|
72
|
+
readonly preExecutionMetrics: QueryMetrics | null;
|
|
73
|
+
readonly executionMetrics: QueryMetrics | null;
|
|
74
|
+
}
|
|
75
|
+
export interface QueryResult<Result> {
|
|
76
|
+
readonly result: Result;
|
|
77
|
+
readonly info: Promise<QueryInfo>;
|
|
78
|
+
}
|
|
79
|
+
export declare class HyperDBError extends Error {
|
|
80
|
+
readonly sqlState: string;
|
|
81
|
+
readonly errorSource: HyperDBErrorSource;
|
|
82
|
+
readonly detail: string;
|
|
83
|
+
readonly hint: string;
|
|
84
|
+
constructor(message: string, sqlState: string, errorSource: HyperDBErrorSource, detail?: string, hint?: string);
|
|
54
85
|
}
|
|
55
86
|
declare function initializeHyperDB(client: HyperDBClient, settings: HyperDBSettings | undefined): Promise<void>;
|
|
56
87
|
export declare class HyperDB {
|
|
57
|
-
|
|
88
|
+
protected readonly client: HyperDBClient;
|
|
58
89
|
private terminated;
|
|
59
90
|
private termination;
|
|
60
91
|
private activeDatabaseOperations;
|
|
61
92
|
private readonly connections;
|
|
93
|
+
private readonly mountedResources;
|
|
62
94
|
constructor(client: HyperDBClient);
|
|
63
95
|
static create(options?: BrowserCreateOptions): Promise<HyperDB>;
|
|
64
96
|
ready(): Promise<void>;
|
|
65
97
|
connect(): Promise<HyperDBConnection>;
|
|
66
|
-
|
|
67
|
-
openDatabase(databaseName: string): Promise<void>;
|
|
68
|
-
listDatabases(): Promise<DatabaseMetadata[]>;
|
|
69
|
-
registerExternalFile(name: string, url: string, size: number): Promise<string>;
|
|
70
|
-
removeExternalFile(path: string): Promise<void>;
|
|
71
|
-
checkpointDatabase(databaseName: string): Promise<void>;
|
|
72
|
-
dropDatabase(databaseName: string): Promise<void>;
|
|
98
|
+
protected mountSource(source: MountSource, path: string, mode: MountAccessMode, cleanup?: () => void): Promise<MountedResource>;
|
|
73
99
|
terminate(): Promise<void>;
|
|
74
100
|
private ensureRunning;
|
|
75
|
-
|
|
101
|
+
protected runDatabaseOperation<Result>(operation: () => Promise<Result>): Promise<Result>;
|
|
102
|
+
private unmount;
|
|
76
103
|
}
|
|
77
104
|
export declare class HyperDBConnection {
|
|
78
105
|
private readonly client;
|
|
@@ -83,21 +110,19 @@ export declare class HyperDBConnection {
|
|
|
83
110
|
private closing;
|
|
84
111
|
constructor(client: HyperDBClient, connection: number, onClose?: () => void);
|
|
85
112
|
close(): Promise<void>;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
sendIPC(sql: string): AsyncIterable<Uint8Array>;
|
|
89
|
-
queryIPC(sql: string): Promise<Uint8Array>;
|
|
113
|
+
sendIPC(sql: string): QueryResult<AsyncIterable<Uint8Array>>;
|
|
114
|
+
queryIPC(sql: string): QueryResult<Promise<Uint8Array>>;
|
|
90
115
|
send<T extends TypeMap = {
|
|
91
116
|
[key: string]: DataType;
|
|
92
|
-
}>(sql: string): Promise<AsyncRecordBatchStreamReader<T
|
|
117
|
+
}>(sql: string): QueryResult<Promise<AsyncRecordBatchStreamReader<T>>>;
|
|
93
118
|
query<T extends TypeMap = {
|
|
94
119
|
[key: string]: DataType;
|
|
95
|
-
}>(sql: string): Promise<Table<T
|
|
120
|
+
}>(sql: string): QueryResult<Promise<Table<T>>>;
|
|
96
121
|
insertArrowTable(table: Table, options: ArrowInsertOptions): Promise<void>;
|
|
97
122
|
insertArrowIPCFromPath(path: string, options: ArrowInsertOptions): Promise<void>;
|
|
98
123
|
private insertArrowIPCFromPathInternal;
|
|
99
124
|
private ensureAvailable;
|
|
100
|
-
private
|
|
125
|
+
private finishQuery;
|
|
101
126
|
closeForTermination(): Promise<void>;
|
|
102
127
|
}
|
|
103
128
|
export type { HyperDBEngineClient };
|
package/dist/browser.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export interface BrowserClientOptions {
|
|
|
11
11
|
readonly workerUrl?: string | URL;
|
|
12
12
|
readonly engineUrl?: string | URL;
|
|
13
13
|
readonly wasmUrl?: string | URL;
|
|
14
|
+
/** OPFS-relative directory mounted as the durable filesystem root. */
|
|
15
|
+
readonly storagePath?: string;
|
|
14
16
|
readonly onSetupProgress?: (progress: SetupProgress) => void;
|
|
15
17
|
}
|
|
16
18
|
type BrowserEnvironment = {
|
|
@@ -36,6 +38,6 @@ export declare class BrowserWorker implements WorkerTransport {
|
|
|
36
38
|
onClose(): () => void;
|
|
37
39
|
terminate(): void;
|
|
38
40
|
}
|
|
39
|
-
export declare function resolveBrowserWorkerUrl(workerUrl: string | URL, engineUrl: string | URL, wasmUrl?: string | URL): URL;
|
|
41
|
+
export declare function resolveBrowserWorkerUrl(workerUrl: string | URL, engineUrl: string | URL, wasmUrl?: string | URL, storagePath?: string): URL;
|
|
40
42
|
export declare function createBrowserClient(options?: BrowserClientOptions): HyperDBEngineClient;
|
|
41
43
|
export {};
|