hyperdb-wasm 0.0.26845-dev.wasm.g5b622080 → 0.0.26862-dev.wasm.g89537caa
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 -32
- package/dist/browser.d.ts +3 -1
- package/dist/browser.js +250 -212
- package/dist/browser_external_directory.d.ts +30 -0
- package/dist/browser_worker.js +542 -85
- package/dist/client.d.ts +5 -10
- 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 +19 -2
- package/dist/index.node.d.ts +6 -4
- package/dist/node.d.ts +2 -1
- package/dist/node.js +12338 -315
- package/dist/node_external_directory.d.ts +30 -0
- package/dist/node_worker.js +698 -82
- package/dist/protocol.d.ts +27 -34
- package/dist/raw.browser.js +158 -82
- package/dist/raw.d.ts +1 -1
- package/dist/raw.node.js +152 -81
- package/dist/wasm_bindings.d.ts +44 -9
- package/dist/worker_setup.d.ts +18 -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
|
@@ -3,27 +3,23 @@ import type { AsyncRecordBatchStreamReader, TypeMap } from 'apache-arrow';
|
|
|
3
3
|
import type { HyperDBEngineClient } from './client.js';
|
|
4
4
|
import type { BrowserClientOptions } from './browser.js';
|
|
5
5
|
import type { 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>;
|
|
16
|
+
registerExternalFile(path: string): Promise<WasmResult>;
|
|
22
17
|
registerExternalFile(name: string, url: string, size: number): Promise<WasmResult>;
|
|
23
|
-
|
|
18
|
+
registerExternalDirectory(handle: unknown, mode: 'read' | 'readwrite'): Promise<WasmResult>;
|
|
19
|
+
removeExternalRegistration(path: string): Promise<WasmResult>;
|
|
24
20
|
pollQuery(query: number): Promise<WasmResult>;
|
|
25
21
|
cancelQuery(query: number): Promise<WasmResult>;
|
|
26
|
-
|
|
22
|
+
finishQuery(query: number): Promise<WasmResult>;
|
|
27
23
|
shutdown(): Promise<WasmResult>;
|
|
28
24
|
terminate(): Promise<void>;
|
|
29
25
|
}
|
|
@@ -32,14 +28,18 @@ export interface ArrowInsertOptions {
|
|
|
32
28
|
readonly schema?: string;
|
|
33
29
|
readonly create?: boolean;
|
|
34
30
|
}
|
|
35
|
-
export interface DatabaseCreateOptions {
|
|
36
|
-
readonly storage?: 'memory' | 'persistent';
|
|
37
|
-
}
|
|
38
31
|
export interface ExternalFileRegistration {
|
|
39
32
|
readonly name: string;
|
|
40
33
|
readonly url: string;
|
|
41
34
|
readonly size: number;
|
|
42
35
|
}
|
|
36
|
+
export type ExternalDirectoryMode = 'read' | 'readwrite';
|
|
37
|
+
export interface ExternalDirectoryRegistrationOptions {
|
|
38
|
+
readonly mode?: ExternalDirectoryMode;
|
|
39
|
+
}
|
|
40
|
+
type BrowserExternalFileArguments = readonly [name: string, url: string, size: number];
|
|
41
|
+
type NodeExternalFileArguments = readonly [path: string];
|
|
42
|
+
export type ExternalFileArguments = BrowserExternalFileArguments | NodeExternalFileArguments;
|
|
43
43
|
export type HyperDBSettingValue = string | number | boolean | null | readonly HyperDBSettingValue[] | {
|
|
44
44
|
readonly [key: string]: HyperDBSettingValue;
|
|
45
45
|
};
|
|
@@ -48,13 +48,48 @@ export interface HyperDBCreateOptions {
|
|
|
48
48
|
readonly settings?: HyperDBSettings;
|
|
49
49
|
}
|
|
50
50
|
export type BrowserCreateOptions = BrowserClientOptions & HyperDBCreateOptions;
|
|
51
|
-
export
|
|
52
|
-
readonly
|
|
53
|
-
|
|
51
|
+
export type QueryMetricValue = null | boolean | number | string | readonly QueryMetricValue[] | {
|
|
52
|
+
readonly [key: string]: QueryMetricValue;
|
|
53
|
+
};
|
|
54
|
+
export type QueryMetrics = Readonly<Record<string, QueryMetricValue>>;
|
|
55
|
+
export interface QueryTimings {
|
|
56
|
+
readonly elapsedSeconds: number | null;
|
|
57
|
+
readonly parsingSeconds: number | null;
|
|
58
|
+
readonly compilationSeconds: number | null;
|
|
59
|
+
readonly executionSeconds: number | null;
|
|
60
|
+
readonly commitSeconds: number | null;
|
|
61
|
+
readonly timeToScheduleSeconds: number | null;
|
|
62
|
+
readonly timeToFirstResultSeconds: number | null;
|
|
63
|
+
readonly cancellationSeconds: number | null;
|
|
64
|
+
}
|
|
65
|
+
export interface QueryInfo {
|
|
66
|
+
readonly status: 'succeeded' | 'failed' | 'canceled';
|
|
67
|
+
readonly started: boolean;
|
|
68
|
+
readonly statementKind: string | null;
|
|
69
|
+
readonly producesRows: boolean;
|
|
70
|
+
readonly rowCount: bigint | null;
|
|
71
|
+
readonly columnCount: number | null;
|
|
72
|
+
readonly cancellationRequestedByUser: boolean;
|
|
73
|
+
readonly queryPlan: Readonly<Record<string, unknown>> | null;
|
|
74
|
+
readonly dependencies: readonly string[];
|
|
75
|
+
readonly timings: QueryTimings;
|
|
76
|
+
readonly preExecutionMetrics: QueryMetrics | null;
|
|
77
|
+
readonly executionMetrics: QueryMetrics | null;
|
|
78
|
+
}
|
|
79
|
+
export interface QueryResult<Result> {
|
|
80
|
+
readonly result: Result;
|
|
81
|
+
readonly info: Promise<QueryInfo>;
|
|
82
|
+
}
|
|
83
|
+
export declare class HyperDBError extends Error {
|
|
84
|
+
readonly sqlState: string;
|
|
85
|
+
readonly errorSource: HyperDBErrorSource;
|
|
86
|
+
readonly detail: string;
|
|
87
|
+
readonly hint: string;
|
|
88
|
+
constructor(message: string, sqlState: string, errorSource: HyperDBErrorSource, detail?: string, hint?: string);
|
|
54
89
|
}
|
|
55
90
|
declare function initializeHyperDB(client: HyperDBClient, settings: HyperDBSettings | undefined): Promise<void>;
|
|
56
|
-
export declare class HyperDB {
|
|
57
|
-
|
|
91
|
+
export declare class HyperDB<ExternalFileArgs extends ExternalFileArguments = BrowserExternalFileArguments> {
|
|
92
|
+
protected readonly client: HyperDBClient;
|
|
58
93
|
private terminated;
|
|
59
94
|
private termination;
|
|
60
95
|
private activeDatabaseOperations;
|
|
@@ -63,16 +98,12 @@ export declare class HyperDB {
|
|
|
63
98
|
static create(options?: BrowserCreateOptions): Promise<HyperDB>;
|
|
64
99
|
ready(): Promise<void>;
|
|
65
100
|
connect(): Promise<HyperDBConnection>;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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>;
|
|
101
|
+
registerExternalFile(...args: ExternalFileArgs): Promise<string>;
|
|
102
|
+
removeExternalRegistration(path: string): Promise<void>;
|
|
103
|
+
protected registerExternalDirectorySource(source: unknown, mode: ExternalDirectoryMode): Promise<string>;
|
|
73
104
|
terminate(): Promise<void>;
|
|
74
105
|
private ensureRunning;
|
|
75
|
-
|
|
106
|
+
protected runDatabaseOperation<Result>(operation: () => Promise<Result>): Promise<Result>;
|
|
76
107
|
}
|
|
77
108
|
export declare class HyperDBConnection {
|
|
78
109
|
private readonly client;
|
|
@@ -83,21 +114,19 @@ export declare class HyperDBConnection {
|
|
|
83
114
|
private closing;
|
|
84
115
|
constructor(client: HyperDBClient, connection: number, onClose?: () => void);
|
|
85
116
|
close(): Promise<void>;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
sendIPC(sql: string): AsyncIterable<Uint8Array>;
|
|
89
|
-
queryIPC(sql: string): Promise<Uint8Array>;
|
|
117
|
+
sendIPC(sql: string): QueryResult<AsyncIterable<Uint8Array>>;
|
|
118
|
+
queryIPC(sql: string): QueryResult<Promise<Uint8Array>>;
|
|
90
119
|
send<T extends TypeMap = {
|
|
91
120
|
[key: string]: DataType;
|
|
92
|
-
}>(sql: string): Promise<AsyncRecordBatchStreamReader<T
|
|
121
|
+
}>(sql: string): QueryResult<Promise<AsyncRecordBatchStreamReader<T>>>;
|
|
93
122
|
query<T extends TypeMap = {
|
|
94
123
|
[key: string]: DataType;
|
|
95
|
-
}>(sql: string): Promise<Table<T
|
|
124
|
+
}>(sql: string): QueryResult<Promise<Table<T>>>;
|
|
96
125
|
insertArrowTable(table: Table, options: ArrowInsertOptions): Promise<void>;
|
|
97
126
|
insertArrowIPCFromPath(path: string, options: ArrowInsertOptions): Promise<void>;
|
|
98
127
|
private insertArrowIPCFromPathInternal;
|
|
99
128
|
private ensureAvailable;
|
|
100
|
-
private
|
|
129
|
+
private finishQuery;
|
|
101
130
|
closeForTermination(): Promise<void>;
|
|
102
131
|
}
|
|
103
132
|
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 {};
|