@haex-space/vault-sdk 1.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 +1551 -0
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +455 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/index.mjs +430 -0
- package/dist/cli/index.mjs.map +1 -0
- package/dist/client-O_JEOzfx.d.mts +491 -0
- package/dist/client-O_JEOzfx.d.ts +491 -0
- package/dist/index.d.mts +124 -0
- package/dist/index.d.ts +124 -0
- package/dist/index.js +1429 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1409 -0
- package/dist/index.mjs.map +1 -0
- package/dist/node.d.mts +25 -0
- package/dist/node.d.ts +25 -0
- package/dist/node.js +28 -0
- package/dist/node.js.map +1 -0
- package/dist/node.mjs +25 -0
- package/dist/node.mjs.map +1 -0
- package/dist/nuxt.d.mts +19 -0
- package/dist/nuxt.d.ts +19 -0
- package/dist/nuxt.js +473 -0
- package/dist/nuxt.js.map +1 -0
- package/dist/nuxt.mjs +470 -0
- package/dist/nuxt.mjs.map +1 -0
- package/dist/react.d.mts +28 -0
- package/dist/react.d.ts +28 -0
- package/dist/react.js +1389 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +1386 -0
- package/dist/react.mjs.map +1 -0
- package/dist/runtime/nuxt.plugin.client.d.mts +43 -0
- package/dist/runtime/nuxt.plugin.client.d.ts +43 -0
- package/dist/runtime/nuxt.plugin.client.js +1137 -0
- package/dist/runtime/nuxt.plugin.client.js.map +1 -0
- package/dist/runtime/nuxt.plugin.client.mjs +1135 -0
- package/dist/runtime/nuxt.plugin.client.mjs.map +1 -0
- package/dist/runtime/nuxt.types.d.ts +15 -0
- package/dist/svelte.d.mts +48 -0
- package/dist/svelte.d.ts +48 -0
- package/dist/svelte.js +1398 -0
- package/dist/svelte.js.map +1 -0
- package/dist/svelte.mjs +1391 -0
- package/dist/svelte.mjs.map +1 -0
- package/dist/vite.d.mts +37 -0
- package/dist/vite.d.ts +37 -0
- package/dist/vite.js +346 -0
- package/dist/vite.js.map +1 -0
- package/dist/vite.mjs +341 -0
- package/dist/vite.mjs.map +1 -0
- package/dist/vue.d.mts +49 -0
- package/dist/vue.d.ts +49 -0
- package/dist/vue.js +1388 -0
- package/dist/vue.js.map +1 -0
- package/dist/vue.mjs +1385 -0
- package/dist/vue.mjs.map +1 -0
- package/package.json +121 -0
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
import { SqliteRemoteDatabase } from 'drizzle-orm/sqlite-proxy';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Central event name definitions for HaexHub extensions
|
|
5
|
+
*
|
|
6
|
+
* Event Naming Schema: haextension:{subject}:{predicate}
|
|
7
|
+
*
|
|
8
|
+
* IMPORTANT: Tauri event names can only contain:
|
|
9
|
+
* - Alphanumeric characters (a-z, A-Z, 0-9)
|
|
10
|
+
* - Hyphens (-)
|
|
11
|
+
* - Slashes (/)
|
|
12
|
+
* - Colons (:)
|
|
13
|
+
* - Underscores (_)
|
|
14
|
+
*
|
|
15
|
+
* NO dots (.) allowed!
|
|
16
|
+
*/
|
|
17
|
+
declare const HAEXTENSION_EVENTS: {
|
|
18
|
+
/** Context (theme, locale, platform) has changed */
|
|
19
|
+
readonly CONTEXT_CHANGED: "haextension:context:changed";
|
|
20
|
+
/** Search request from HaexHub */
|
|
21
|
+
readonly SEARCH_REQUEST: "haextension:search:request";
|
|
22
|
+
};
|
|
23
|
+
type HaextensionEvent = typeof HAEXTENSION_EVENTS[keyof typeof HAEXTENSION_EVENTS];
|
|
24
|
+
|
|
25
|
+
declare const DEFAULT_TIMEOUT = 30000;
|
|
26
|
+
declare const TABLE_SEPARATOR = "__";
|
|
27
|
+
interface HaexHubRequest {
|
|
28
|
+
method: string;
|
|
29
|
+
params: Record<string, unknown>;
|
|
30
|
+
timestamp: number;
|
|
31
|
+
}
|
|
32
|
+
interface HaexHubResponse<T = unknown> {
|
|
33
|
+
id: string;
|
|
34
|
+
result?: T;
|
|
35
|
+
error?: HaexHubError;
|
|
36
|
+
}
|
|
37
|
+
interface ExtensionInfo {
|
|
38
|
+
publicKey: string;
|
|
39
|
+
name: string;
|
|
40
|
+
version: string;
|
|
41
|
+
displayName?: string;
|
|
42
|
+
namespace?: string;
|
|
43
|
+
}
|
|
44
|
+
interface ApplicationContext {
|
|
45
|
+
theme: "light" | "dark" | "system";
|
|
46
|
+
locale: string;
|
|
47
|
+
platform: "linux" | "macos" | "ios" | "freebsd" | "dragonfly" | "netbsd" | "openbsd" | "solaris" | "android" | "windows" | undefined;
|
|
48
|
+
}
|
|
49
|
+
interface SearchQuery {
|
|
50
|
+
query: string;
|
|
51
|
+
filters?: Record<string, unknown>;
|
|
52
|
+
limit?: number;
|
|
53
|
+
}
|
|
54
|
+
interface SearchResult {
|
|
55
|
+
id: string;
|
|
56
|
+
title: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
type: string;
|
|
59
|
+
data?: Record<string, unknown>;
|
|
60
|
+
score?: number;
|
|
61
|
+
}
|
|
62
|
+
declare enum PermissionStatus {
|
|
63
|
+
GRANTED = "granted",
|
|
64
|
+
DENIED = "denied",
|
|
65
|
+
ASK = "ask"
|
|
66
|
+
}
|
|
67
|
+
interface PermissionResponse {
|
|
68
|
+
status: PermissionStatus;
|
|
69
|
+
permanent: boolean;
|
|
70
|
+
}
|
|
71
|
+
interface DatabasePermission {
|
|
72
|
+
extensionId: string;
|
|
73
|
+
resource: string;
|
|
74
|
+
operation: "read" | "write";
|
|
75
|
+
path: string;
|
|
76
|
+
}
|
|
77
|
+
interface DatabasePermissionRequest {
|
|
78
|
+
resource: string;
|
|
79
|
+
operation: "read" | "write";
|
|
80
|
+
reason?: string;
|
|
81
|
+
}
|
|
82
|
+
interface DatabaseQueryParams {
|
|
83
|
+
query: string;
|
|
84
|
+
params?: unknown[];
|
|
85
|
+
}
|
|
86
|
+
interface DatabaseQueryResult {
|
|
87
|
+
rows: unknown[];
|
|
88
|
+
columns?: string[];
|
|
89
|
+
rowsAffected: number;
|
|
90
|
+
lastInsertId?: number;
|
|
91
|
+
}
|
|
92
|
+
interface DatabaseExecuteParams {
|
|
93
|
+
statements: string[];
|
|
94
|
+
}
|
|
95
|
+
interface DatabaseTableInfo {
|
|
96
|
+
name: string;
|
|
97
|
+
columns: DatabaseColumnInfo[];
|
|
98
|
+
}
|
|
99
|
+
interface DatabaseColumnInfo {
|
|
100
|
+
name: string;
|
|
101
|
+
type: string;
|
|
102
|
+
notNull: boolean;
|
|
103
|
+
defaultValue?: unknown;
|
|
104
|
+
primaryKey: boolean;
|
|
105
|
+
}
|
|
106
|
+
interface HaexHubEvent {
|
|
107
|
+
type: string;
|
|
108
|
+
data: unknown;
|
|
109
|
+
timestamp: number;
|
|
110
|
+
}
|
|
111
|
+
interface ContextChangedEvent extends HaexHubEvent {
|
|
112
|
+
type: typeof HAEXTENSION_EVENTS.CONTEXT_CHANGED;
|
|
113
|
+
data: {
|
|
114
|
+
context: ApplicationContext;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
interface SearchRequestEvent extends HaexHubEvent {
|
|
118
|
+
type: typeof HAEXTENSION_EVENTS.SEARCH_REQUEST;
|
|
119
|
+
data: {
|
|
120
|
+
query: SearchQuery;
|
|
121
|
+
requestId: string;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
type EventCallback = (event: HaexHubEvent) => void;
|
|
125
|
+
interface ExtensionManifest {
|
|
126
|
+
name: string;
|
|
127
|
+
version: string;
|
|
128
|
+
author?: string | null;
|
|
129
|
+
entry?: string | null;
|
|
130
|
+
icon?: string | null;
|
|
131
|
+
publicKey: string;
|
|
132
|
+
signature: string;
|
|
133
|
+
permissions: {
|
|
134
|
+
database?: any[];
|
|
135
|
+
filesystem?: any[];
|
|
136
|
+
http?: any[];
|
|
137
|
+
shell?: any[];
|
|
138
|
+
};
|
|
139
|
+
homepage?: string | null;
|
|
140
|
+
description?: string | null;
|
|
141
|
+
singleInstance?: boolean | null;
|
|
142
|
+
displayMode?: "auto" | "window" | "iframe" | null;
|
|
143
|
+
}
|
|
144
|
+
interface HaexHubConfig {
|
|
145
|
+
debug?: boolean;
|
|
146
|
+
timeout?: number;
|
|
147
|
+
/** Extension manifest data (auto-injected by framework integrations) */
|
|
148
|
+
manifest?: ExtensionManifest;
|
|
149
|
+
}
|
|
150
|
+
interface WebRequestOptions {
|
|
151
|
+
method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
|
|
152
|
+
headers?: Record<string, string>;
|
|
153
|
+
body?: string | ArrayBuffer | Blob;
|
|
154
|
+
timeout?: number;
|
|
155
|
+
}
|
|
156
|
+
interface WebResponse {
|
|
157
|
+
status: number;
|
|
158
|
+
statusText: string;
|
|
159
|
+
headers: Record<string, string>;
|
|
160
|
+
body: ArrayBuffer;
|
|
161
|
+
url: string;
|
|
162
|
+
}
|
|
163
|
+
declare enum ErrorCode {
|
|
164
|
+
TIMEOUT = "TIMEOUT",
|
|
165
|
+
NOT_IN_IFRAME = "NOT_IN_IFRAME",
|
|
166
|
+
UNAUTHORIZED_ORIGIN = "UNAUTHORIZED_ORIGIN",
|
|
167
|
+
PERMISSION_DENIED = "PERMISSION_DENIED",
|
|
168
|
+
INVALID_PUBLIC_KEY = "INVALID_PUBLIC_KEY",
|
|
169
|
+
INVALID_EXTENSION_NAME = "INVALID_EXTENSION_NAME",
|
|
170
|
+
INVALID_TABLE_NAME = "INVALID_TABLE_NAME",
|
|
171
|
+
INVALID_PARAMS = "INVALID_PARAMS",
|
|
172
|
+
EXTENSION_NOT_INITIALIZED = "EXTENSION_NOT_INITIALIZED",
|
|
173
|
+
EXTENSION_INFO_UNAVAILABLE = "EXTENSION_INFO_UNAVAILABLE",
|
|
174
|
+
METHOD_NOT_FOUND = "METHOD_NOT_FOUND",
|
|
175
|
+
INTERNAL_ERROR = "INTERNAL_ERROR",
|
|
176
|
+
DATABASE_ERROR = "DATABASE_ERROR",
|
|
177
|
+
WEB_ERROR = "WEB_ERROR"
|
|
178
|
+
}
|
|
179
|
+
interface HaexHubError {
|
|
180
|
+
code: ErrorCode;
|
|
181
|
+
message: string;
|
|
182
|
+
details?: Record<string, unknown>;
|
|
183
|
+
}
|
|
184
|
+
declare class HaexHubError extends Error {
|
|
185
|
+
code: ErrorCode;
|
|
186
|
+
messageKey: string;
|
|
187
|
+
details?: Record<string, unknown> | undefined;
|
|
188
|
+
constructor(code: ErrorCode, messageKey: string, details?: Record<string, unknown> | undefined);
|
|
189
|
+
/**
|
|
190
|
+
* Get localized error message
|
|
191
|
+
* @param locale - Locale code (e.g., 'en', 'de')
|
|
192
|
+
* @param translations - Translation object
|
|
193
|
+
*/
|
|
194
|
+
getLocalizedMessage(locale?: string, translations?: Record<string, Record<string, string>>): string;
|
|
195
|
+
toJSON(): {
|
|
196
|
+
code: ErrorCode;
|
|
197
|
+
message: string;
|
|
198
|
+
details: Record<string, unknown> | undefined;
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
declare class StorageAPI {
|
|
203
|
+
private client;
|
|
204
|
+
constructor(client: HaexVaultClient);
|
|
205
|
+
getItem(key: string): Promise<string | null>;
|
|
206
|
+
setItem(key: string, value: string): Promise<void>;
|
|
207
|
+
removeItem(key: string): Promise<void>;
|
|
208
|
+
clear(): Promise<void>;
|
|
209
|
+
keys(): Promise<string[]>;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
declare class DatabaseAPI {
|
|
213
|
+
private client;
|
|
214
|
+
constructor(client: HaexVaultClient);
|
|
215
|
+
query<T>(query: string, params?: unknown[]): Promise<T[]>;
|
|
216
|
+
queryOne<T = unknown>(query: string, params?: unknown[]): Promise<T | null>;
|
|
217
|
+
execute(query: string, params?: unknown[]): Promise<DatabaseQueryResult>;
|
|
218
|
+
transaction(statements: string[]): Promise<void>;
|
|
219
|
+
createTable(tableName: string, columns: string): Promise<void>;
|
|
220
|
+
dropTable(tableName: string): Promise<void>;
|
|
221
|
+
/**
|
|
222
|
+
* Registers extension migrations with HaexVault for CRDT synchronization
|
|
223
|
+
* HaexVault will validate and execute these migrations, ensuring only
|
|
224
|
+
* tables with the correct prefix are manipulated
|
|
225
|
+
* @param extensionVersion - The version of the extension
|
|
226
|
+
* @param migrations - Array of migration objects with name and SQL content
|
|
227
|
+
* @returns Promise that resolves when migrations are registered
|
|
228
|
+
*/
|
|
229
|
+
registerMigrationsAsync(extensionVersion: string, migrations: Array<{
|
|
230
|
+
name: string;
|
|
231
|
+
sql: string;
|
|
232
|
+
}>): Promise<void>;
|
|
233
|
+
insert(tableName: string, data: Record<string, unknown>): Promise<number>;
|
|
234
|
+
update(tableName: string, data: Record<string, unknown>, where: string, whereParams?: unknown[]): Promise<number>;
|
|
235
|
+
delete(tableName: string, where: string, whereParams?: unknown[]): Promise<number>;
|
|
236
|
+
count(tableName: string, where?: string, whereParams?: unknown[]): Promise<number>;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
interface SaveFileOptions {
|
|
240
|
+
/**
|
|
241
|
+
* The default filename to suggest
|
|
242
|
+
*/
|
|
243
|
+
defaultPath?: string;
|
|
244
|
+
/**
|
|
245
|
+
* The title of the save dialog
|
|
246
|
+
*/
|
|
247
|
+
title?: string;
|
|
248
|
+
/**
|
|
249
|
+
* File filters for the dialog
|
|
250
|
+
*/
|
|
251
|
+
filters?: Array<{
|
|
252
|
+
name: string;
|
|
253
|
+
extensions: string[];
|
|
254
|
+
}>;
|
|
255
|
+
}
|
|
256
|
+
interface SaveFileResult {
|
|
257
|
+
/**
|
|
258
|
+
* The path where the file was saved
|
|
259
|
+
*/
|
|
260
|
+
path: string;
|
|
261
|
+
/**
|
|
262
|
+
* Whether the operation was successful
|
|
263
|
+
*/
|
|
264
|
+
success: boolean;
|
|
265
|
+
}
|
|
266
|
+
interface OpenFileOptions {
|
|
267
|
+
/**
|
|
268
|
+
* The filename for the temporary file
|
|
269
|
+
*/
|
|
270
|
+
fileName: string;
|
|
271
|
+
/**
|
|
272
|
+
* Optional MIME type for the file
|
|
273
|
+
*/
|
|
274
|
+
mimeType?: string;
|
|
275
|
+
}
|
|
276
|
+
interface OpenFileResult {
|
|
277
|
+
/**
|
|
278
|
+
* Whether the operation was successful
|
|
279
|
+
*/
|
|
280
|
+
success: boolean;
|
|
281
|
+
}
|
|
282
|
+
interface ShowImageOptions {
|
|
283
|
+
/**
|
|
284
|
+
* The data URL of the image (base64 encoded)
|
|
285
|
+
*/
|
|
286
|
+
dataUrl: string;
|
|
287
|
+
}
|
|
288
|
+
interface ShowImageResult {
|
|
289
|
+
/**
|
|
290
|
+
* Whether the operation was successful
|
|
291
|
+
*/
|
|
292
|
+
success: boolean;
|
|
293
|
+
}
|
|
294
|
+
declare class FilesystemAPI {
|
|
295
|
+
private client;
|
|
296
|
+
constructor(client: HaexVaultClient);
|
|
297
|
+
/**
|
|
298
|
+
* Opens a save file dialog and saves the provided data to the selected location
|
|
299
|
+
* @param data The file data as Uint8Array
|
|
300
|
+
* @param options Options for the save dialog
|
|
301
|
+
* @returns The path where the file was saved, or null if cancelled
|
|
302
|
+
*/
|
|
303
|
+
saveFileAsync(data: Uint8Array, options?: SaveFileOptions): Promise<SaveFileResult | null>;
|
|
304
|
+
/**
|
|
305
|
+
* Opens a file with the system's default viewer
|
|
306
|
+
* @param data The file data as Uint8Array
|
|
307
|
+
* @param options Options for opening the file
|
|
308
|
+
* @returns The result of the operation
|
|
309
|
+
*/
|
|
310
|
+
openFileAsync(data: Uint8Array, options: OpenFileOptions): Promise<OpenFileResult>;
|
|
311
|
+
/**
|
|
312
|
+
* Shows an image using a data URL (safe, read-only viewing)
|
|
313
|
+
* This is safe to use without special permissions as it only displays images
|
|
314
|
+
* and doesn't execute any code or open files with external applications
|
|
315
|
+
* @param options Options containing the data URL
|
|
316
|
+
* @returns The result of the operation
|
|
317
|
+
*/
|
|
318
|
+
showImageAsync(options: ShowImageOptions): Promise<ShowImageResult>;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
declare class WebAPI {
|
|
322
|
+
private client;
|
|
323
|
+
constructor(client: HaexVaultClient);
|
|
324
|
+
/**
|
|
325
|
+
* Performs a web request through the HaexHub host application
|
|
326
|
+
* @param url The URL to fetch
|
|
327
|
+
* @param options Request options (method, headers, body, timeout)
|
|
328
|
+
* @returns Promise resolving to the web response
|
|
329
|
+
*/
|
|
330
|
+
fetchAsync(url: string, options?: WebRequestOptions): Promise<WebResponse>;
|
|
331
|
+
/**
|
|
332
|
+
* Convenience method for JSON requests
|
|
333
|
+
*/
|
|
334
|
+
fetchJsonAsync<T = unknown>(url: string, options?: WebRequestOptions): Promise<T>;
|
|
335
|
+
/**
|
|
336
|
+
* Convenience method for text requests
|
|
337
|
+
*/
|
|
338
|
+
fetchTextAsync(url: string, options?: WebRequestOptions): Promise<string>;
|
|
339
|
+
/**
|
|
340
|
+
* Convenience method for blob requests
|
|
341
|
+
*/
|
|
342
|
+
fetchBlobAsync(url: string, options?: WebRequestOptions): Promise<Blob>;
|
|
343
|
+
/**
|
|
344
|
+
* Opens a URL in the user's default browser
|
|
345
|
+
* @param url The URL to open
|
|
346
|
+
*/
|
|
347
|
+
openAsync(url: string): Promise<void>;
|
|
348
|
+
private arrayBufferToBase64;
|
|
349
|
+
private blobToBase64;
|
|
350
|
+
private base64ToArrayBuffer;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
declare class PermissionsAPI {
|
|
354
|
+
private client;
|
|
355
|
+
constructor(client: HaexVaultClient);
|
|
356
|
+
/**
|
|
357
|
+
* Checks if the extension has permission for a database operation
|
|
358
|
+
* @param resource The database resource (table name or "*" for all tables)
|
|
359
|
+
* @param operation The operation type ("read" or "write")
|
|
360
|
+
* @returns Promise<boolean> indicating if permission is granted
|
|
361
|
+
*/
|
|
362
|
+
checkDatabaseAsync(resource: string, operation: "read" | "write"): Promise<boolean>;
|
|
363
|
+
/**
|
|
364
|
+
* Checks if the extension has permission for a web request
|
|
365
|
+
* @param url The URL to check (e.g., "https://example.com/path")
|
|
366
|
+
* @returns Promise<boolean> indicating if permission is granted
|
|
367
|
+
* @note Method/operation is not checked - permissions apply to all HTTP methods
|
|
368
|
+
*/
|
|
369
|
+
checkWebAsync(url: string): Promise<boolean>;
|
|
370
|
+
/**
|
|
371
|
+
* Checks if the extension has permission for a filesystem operation
|
|
372
|
+
* @param path The file or directory path
|
|
373
|
+
* @param operation The operation type ("read" or "write")
|
|
374
|
+
* @returns Promise<boolean> indicating if permission is granted
|
|
375
|
+
*/
|
|
376
|
+
checkFilesystemAsync(path: string, operation: "read" | "write"): Promise<boolean>;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
declare class HaexVaultClient {
|
|
380
|
+
private config;
|
|
381
|
+
private pendingRequests;
|
|
382
|
+
private eventListeners;
|
|
383
|
+
private messageHandler;
|
|
384
|
+
private initialized;
|
|
385
|
+
private requestCounter;
|
|
386
|
+
private _extensionInfo;
|
|
387
|
+
private _context;
|
|
388
|
+
private reactiveSubscribers;
|
|
389
|
+
private isNativeWindow;
|
|
390
|
+
private readyPromise;
|
|
391
|
+
private resolveReady;
|
|
392
|
+
private setupPromise;
|
|
393
|
+
private setupHook;
|
|
394
|
+
private _setupCompleted;
|
|
395
|
+
orm: SqliteRemoteDatabase<Record<string, unknown>> | null;
|
|
396
|
+
readonly storage: StorageAPI;
|
|
397
|
+
readonly database: DatabaseAPI;
|
|
398
|
+
readonly filesystem: FilesystemAPI;
|
|
399
|
+
readonly web: WebAPI;
|
|
400
|
+
readonly permissions: PermissionsAPI;
|
|
401
|
+
constructor(config?: HaexHubConfig);
|
|
402
|
+
/**
|
|
403
|
+
* Gibt ein Promise zurück, das aufgelöst wird, sobald der Client
|
|
404
|
+
* initialisiert ist und Extension-Infos empfangen hat.
|
|
405
|
+
*/
|
|
406
|
+
ready(): Promise<void>;
|
|
407
|
+
/**
|
|
408
|
+
* Gibt zurück, ob das Setup bereits abgeschlossen wurde.
|
|
409
|
+
*/
|
|
410
|
+
get setupCompleted(): boolean;
|
|
411
|
+
/**
|
|
412
|
+
* Registriert eine Setup-Funktion, die nach der Initialisierung ausgeführt wird.
|
|
413
|
+
* Diese Funktion sollte für Aufgaben wie Tabellenerstellung, Migrationen, etc. verwendet werden.
|
|
414
|
+
* @param setupFn Die Setup-Funktion, die ausgeführt werden soll
|
|
415
|
+
*/
|
|
416
|
+
onSetup(setupFn: () => Promise<void>): void;
|
|
417
|
+
/**
|
|
418
|
+
* Gibt ein Promise zurück, das aufgelöst wird, sobald der Client vollständig eingerichtet ist.
|
|
419
|
+
* Dies umfasst die Initialisierung UND das Setup (z.B. Tabellenerstellung).
|
|
420
|
+
* Falls kein Setup-Hook registriert wurde, entspricht dies ready().
|
|
421
|
+
*/
|
|
422
|
+
setupComplete(): Promise<void>;
|
|
423
|
+
private runSetupAsync;
|
|
424
|
+
/**
|
|
425
|
+
* Initialisiert die Drizzle-Datenbankinstanz.
|
|
426
|
+
* Muss nach der Definition des Schemas aufgerufen werden.
|
|
427
|
+
* @param schema Das Drizzle-Schemaobjekt (mit bereits geprefixten Tabellennamen).
|
|
428
|
+
* @returns Die typsichere Drizzle-Datenbankinstanz.
|
|
429
|
+
*/
|
|
430
|
+
initializeDatabase<T extends Record<string, unknown>>(schema: T): SqliteRemoteDatabase<T>;
|
|
431
|
+
get extensionInfo(): ExtensionInfo | null;
|
|
432
|
+
get context(): ApplicationContext | null;
|
|
433
|
+
subscribe(callback: () => void): () => void;
|
|
434
|
+
private notifySubscribers;
|
|
435
|
+
getDependencies(): Promise<ExtensionInfo[]>;
|
|
436
|
+
getTableName(tableName: string): string;
|
|
437
|
+
getDependencyTableName(publicKey: string, extensionName: string, tableName: string): string;
|
|
438
|
+
parseTableName(fullTableName: string): {
|
|
439
|
+
publicKey: string;
|
|
440
|
+
extensionName: string;
|
|
441
|
+
tableName: string;
|
|
442
|
+
} | null;
|
|
443
|
+
/**
|
|
444
|
+
* Execute a raw SQL query (SELECT)
|
|
445
|
+
* Returns rows as an array of objects
|
|
446
|
+
*/
|
|
447
|
+
query<T = Record<string, unknown>>(sql: string, params?: unknown[]): Promise<T[]>;
|
|
448
|
+
/**
|
|
449
|
+
* Alias for query() - more intuitive for SELECT statements
|
|
450
|
+
*/
|
|
451
|
+
select<T = Record<string, unknown>>(sql: string, params?: unknown[]): Promise<T[]>;
|
|
452
|
+
/**
|
|
453
|
+
* Execute a raw SQL statement (INSERT, UPDATE, DELETE, CREATE, etc.)
|
|
454
|
+
* Returns rowsAffected and lastInsertId
|
|
455
|
+
*/
|
|
456
|
+
execute(sql: string, params?: unknown[]): Promise<{
|
|
457
|
+
rowsAffected: number;
|
|
458
|
+
lastInsertId?: number;
|
|
459
|
+
}>;
|
|
460
|
+
/**
|
|
461
|
+
* Registers extension migrations with HaexVault for CRDT synchronization
|
|
462
|
+
* HaexVault will validate and execute these migrations
|
|
463
|
+
* @param extensionVersion - The version of the extension
|
|
464
|
+
* @param migrations - Array of migration objects with name and SQL content
|
|
465
|
+
* @returns Promise that resolves when migrations are registered
|
|
466
|
+
*/
|
|
467
|
+
registerMigrationsAsync(extensionVersion: string, migrations: Array<{
|
|
468
|
+
name: string;
|
|
469
|
+
sql: string;
|
|
470
|
+
}>): Promise<void>;
|
|
471
|
+
requestDatabasePermission(request: DatabasePermissionRequest): Promise<PermissionResponse>;
|
|
472
|
+
checkDatabasePermission(resource: string, operation: "read" | "write"): Promise<boolean>;
|
|
473
|
+
respondToSearch(requestId: string, results: SearchResult[]): Promise<void>;
|
|
474
|
+
request<T = unknown>(method: string, params?: Record<string, unknown>): Promise<T>;
|
|
475
|
+
private postMessage;
|
|
476
|
+
private invoke;
|
|
477
|
+
on(eventType: string, callback: EventCallback): void;
|
|
478
|
+
off(eventType: string, callback: EventCallback): void;
|
|
479
|
+
destroy(): void;
|
|
480
|
+
private init;
|
|
481
|
+
private handleMessage;
|
|
482
|
+
private handleEvent;
|
|
483
|
+
private emitEvent;
|
|
484
|
+
private generateRequestId;
|
|
485
|
+
private validatePublicKey;
|
|
486
|
+
private validateExtensionName;
|
|
487
|
+
private validateTableName;
|
|
488
|
+
private log;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
export { type ApplicationContext as A, type ContextChangedEvent as C, DatabaseAPI as D, type ExtensionInfo as E, FilesystemAPI as F, type HaexHubConfig as H, PermissionsAPI as P, StorageAPI as S, TABLE_SEPARATOR as T, WebAPI as W, HaexVaultClient as a, type HaexHubRequest as b, type HaexHubResponse as c, type HaexHubEvent as d, type EventCallback as e, type PermissionResponse as f, type DatabasePermission as g, type DatabasePermissionRequest as h, type DatabaseQueryParams as i, type DatabaseQueryResult as j, type DatabaseExecuteParams as k, type DatabaseTableInfo as l, type DatabaseColumnInfo as m, type SearchQuery as n, type SearchResult as o, type SearchRequestEvent as p, type WebRequestOptions as q, type WebResponse as r, PermissionStatus as s, ErrorCode as t, DEFAULT_TIMEOUT as u, HaexHubError as v, HAEXTENSION_EVENTS as w, type HaextensionEvent as x };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { H as HaexHubConfig, a as HaexVaultClient } from './client-O_JEOzfx.mjs';
|
|
2
|
+
export { A as ApplicationContext, C as ContextChangedEvent, u as DEFAULT_TIMEOUT, D as DatabaseAPI, m as DatabaseColumnInfo, k as DatabaseExecuteParams, g as DatabasePermission, h as DatabasePermissionRequest, i as DatabaseQueryParams, j as DatabaseQueryResult, l as DatabaseTableInfo, t as ErrorCode, e as EventCallback, E as ExtensionInfo, F as FilesystemAPI, w as HAEXTENSION_EVENTS, v as HaexHubError, d as HaexHubEvent, b as HaexHubRequest, c as HaexHubResponse, x as HaextensionEvent, f as PermissionResponse, s as PermissionStatus, P as PermissionsAPI, n as SearchQuery, p as SearchRequestEvent, o as SearchResult, T as TABLE_SEPARATOR, W as WebAPI, q as WebRequestOptions, r as WebResponse } from './client-O_JEOzfx.mjs';
|
|
3
|
+
export { HaextensionConfig } from './node.mjs';
|
|
4
|
+
import 'drizzle-orm/sqlite-proxy';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* localStorage Polyfill for HaexHub Extensions
|
|
8
|
+
*
|
|
9
|
+
* Provides an in-memory fallback when localStorage is blocked
|
|
10
|
+
* due to custom protocol restrictions (haex-extension://)
|
|
11
|
+
*/
|
|
12
|
+
declare function installLocalStoragePolyfill(): void;
|
|
13
|
+
/**
|
|
14
|
+
* sessionStorage Polyfill for HaexHub Extensions
|
|
15
|
+
*
|
|
16
|
+
* Provides a no-op implementation as session state doesn't work
|
|
17
|
+
* reliably in custom protocol contexts
|
|
18
|
+
*/
|
|
19
|
+
declare function installSessionStoragePolyfill(): void;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Cookie Polyfill for HaexHub Extensions
|
|
23
|
+
*
|
|
24
|
+
* Provides an in-memory cookie implementation when cookies are blocked
|
|
25
|
+
* due to custom protocol restrictions (haex-extension://)
|
|
26
|
+
*/
|
|
27
|
+
declare function installCookiePolyfill(): void;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* History API Polyfill for HaexHub Extensions
|
|
31
|
+
*
|
|
32
|
+
* Works around SecurityError when using pushState/replaceState
|
|
33
|
+
* in custom protocol contexts (haex-extension://)
|
|
34
|
+
*
|
|
35
|
+
* Falls back to hash-based routing when necessary
|
|
36
|
+
*/
|
|
37
|
+
declare function installHistoryPolyfill(): void;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Base Tag Polyfill
|
|
41
|
+
* Dynamically injects <base> tag for SPA routing in custom protocol
|
|
42
|
+
*/
|
|
43
|
+
declare global {
|
|
44
|
+
interface Window {
|
|
45
|
+
__HAEXHUB_BASE_TAG_INSTALLING__?: boolean;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Installs the base tag by extracting the base path from window.location
|
|
50
|
+
* Works with haex-extension:// protocol URLs
|
|
51
|
+
*/
|
|
52
|
+
declare function installBaseTag(): void;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* HaexHub Extension Polyfills
|
|
56
|
+
*
|
|
57
|
+
* Auto-initializing polyfills for localStorage, cookies, and history API
|
|
58
|
+
* that work around restrictions in custom protocol contexts (haex-extension://)
|
|
59
|
+
*
|
|
60
|
+
* These polyfills are automatically installed when you import the SDK:
|
|
61
|
+
*
|
|
62
|
+
* ```typescript
|
|
63
|
+
* import { createHaexVaultClient } from '@haex-space/vault-sdk';
|
|
64
|
+
* // Polyfills are active!
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* You can also install them manually:
|
|
68
|
+
*
|
|
69
|
+
* ```typescript
|
|
70
|
+
* import { installPolyfills } from '@haexhub/sdk/polyfills';
|
|
71
|
+
* installPolyfills();
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Install all HaexHub polyfills
|
|
77
|
+
*
|
|
78
|
+
* This function is called automatically when the SDK is imported.
|
|
79
|
+
* You usually don't need to call this manually.
|
|
80
|
+
*/
|
|
81
|
+
declare function installPolyfills(): void;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Central request method name definitions for HaexHub SDK
|
|
85
|
+
*
|
|
86
|
+
* Request Naming Schema: haextension:{subject}:{action}
|
|
87
|
+
*
|
|
88
|
+
* These are used for client.request() calls between extensions and HaexHub
|
|
89
|
+
*/
|
|
90
|
+
declare const HAEXTENSION_METHODS: {
|
|
91
|
+
readonly context: {
|
|
92
|
+
readonly get: "haextension:context:get";
|
|
93
|
+
};
|
|
94
|
+
readonly database: {
|
|
95
|
+
readonly query: "haextension:database:query";
|
|
96
|
+
readonly execute: "haextension:database:execute";
|
|
97
|
+
readonly transaction: "haextension:database:transaction";
|
|
98
|
+
readonly registerMigrations: "haextension:database:register-migrations";
|
|
99
|
+
};
|
|
100
|
+
readonly filesystem: {
|
|
101
|
+
readonly saveFile: "haextension:filesystem:save-file";
|
|
102
|
+
readonly openFile: "haextension:filesystem:open-file";
|
|
103
|
+
readonly showImage: "haextension:filesystem:show-image";
|
|
104
|
+
};
|
|
105
|
+
readonly storage: {
|
|
106
|
+
readonly getItem: "haextension:storage:get-item";
|
|
107
|
+
readonly setItem: "haextension:storage:set-item";
|
|
108
|
+
readonly removeItem: "haextension:storage:remove-item";
|
|
109
|
+
readonly clear: "haextension:storage:clear";
|
|
110
|
+
readonly keys: "haextension:storage:keys";
|
|
111
|
+
};
|
|
112
|
+
readonly web: {
|
|
113
|
+
readonly fetch: "haextension:web:fetch";
|
|
114
|
+
};
|
|
115
|
+
readonly application: {
|
|
116
|
+
readonly open: "haextension:application:open";
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
type DeepValues<T> = T extends object ? T[keyof T] extends string ? T[keyof T] : T[keyof T] extends object ? DeepValues<T[keyof T]> : never : never;
|
|
120
|
+
type HaextensionMethod = DeepValues<typeof HAEXTENSION_METHODS>;
|
|
121
|
+
|
|
122
|
+
declare function createHaexVaultClient(config?: HaexHubConfig): HaexVaultClient;
|
|
123
|
+
|
|
124
|
+
export { HAEXTENSION_METHODS, HaexHubConfig, HaexVaultClient, type HaextensionMethod, createHaexVaultClient, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill };
|