@plures/pluresdb 1.4.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/LICENSE +72 -0
- package/README.md +450 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/better-sqlite3-shared.d.ts +12 -0
- package/dist/better-sqlite3-shared.d.ts.map +1 -0
- package/dist/better-sqlite3-shared.js +143 -0
- package/dist/better-sqlite3-shared.js.map +1 -0
- package/dist/better-sqlite3.d.ts +4 -0
- package/dist/better-sqlite3.d.ts.map +1 -0
- package/dist/better-sqlite3.js +8 -0
- package/dist/better-sqlite3.js.map +1 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +258 -0
- package/dist/cli.js.map +1 -0
- package/dist/node-index.d.ts +148 -0
- package/dist/node-index.d.ts.map +1 -0
- package/dist/node-index.js +665 -0
- package/dist/node-index.js.map +1 -0
- package/dist/node-wrapper.d.ts +44 -0
- package/dist/node-wrapper.d.ts.map +1 -0
- package/dist/node-wrapper.js +296 -0
- package/dist/node-wrapper.js.map +1 -0
- package/dist/types/index.d.ts +28 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/node-types.d.ts +71 -0
- package/dist/types/node-types.d.ts.map +1 -0
- package/dist/types/node-types.js +6 -0
- package/dist/types/node-types.js.map +1 -0
- package/dist/vscode/extension.d.ts +81 -0
- package/dist/vscode/extension.d.ts.map +1 -0
- package/dist/vscode/extension.js +309 -0
- package/dist/vscode/extension.js.map +1 -0
- package/examples/basic-usage.d.ts +2 -0
- package/examples/basic-usage.d.ts.map +1 -0
- package/examples/basic-usage.js +26 -0
- package/examples/basic-usage.js.map +1 -0
- package/examples/basic-usage.ts +29 -0
- package/examples/vscode-extension-example/README.md +95 -0
- package/examples/vscode-extension-example/package.json +49 -0
- package/examples/vscode-extension-example/src/extension.ts +172 -0
- package/examples/vscode-extension-example/tsconfig.json +12 -0
- package/examples/vscode-extension-integration.d.ts +31 -0
- package/examples/vscode-extension-integration.d.ts.map +1 -0
- package/examples/vscode-extension-integration.js +319 -0
- package/examples/vscode-extension-integration.js.map +1 -0
- package/examples/vscode-extension-integration.ts +41 -0
- package/legacy/benchmarks/memory-benchmarks.ts +350 -0
- package/legacy/benchmarks/run-benchmarks.ts +315 -0
- package/legacy/better-sqlite3-shared.ts +157 -0
- package/legacy/better-sqlite3.ts +4 -0
- package/legacy/cli.ts +241 -0
- package/legacy/config.ts +50 -0
- package/legacy/core/crdt.ts +107 -0
- package/legacy/core/database.ts +529 -0
- package/legacy/healthcheck.ts +162 -0
- package/legacy/http/api-server.ts +438 -0
- package/legacy/index.ts +28 -0
- package/legacy/logic/rules.ts +46 -0
- package/legacy/main.rs +3 -0
- package/legacy/main.ts +197 -0
- package/legacy/network/websocket-server.ts +115 -0
- package/legacy/node-index.ts +823 -0
- package/legacy/node-wrapper.ts +329 -0
- package/legacy/sqlite-compat.ts +633 -0
- package/legacy/sqlite3-compat.ts +55 -0
- package/legacy/storage/kv-storage.ts +73 -0
- package/legacy/tests/core.test.ts +305 -0
- package/legacy/tests/fixtures/performance-data.json +71 -0
- package/legacy/tests/fixtures/test-data.json +129 -0
- package/legacy/tests/integration/api-server.test.ts +334 -0
- package/legacy/tests/integration/mesh-network.test.ts +303 -0
- package/legacy/tests/logic.test.ts +34 -0
- package/legacy/tests/performance/load.test.ts +290 -0
- package/legacy/tests/security/input-validation.test.ts +286 -0
- package/legacy/tests/unit/core.test.ts +226 -0
- package/legacy/tests/unit/subscriptions.test.ts +135 -0
- package/legacy/tests/unit/vector-search.test.ts +173 -0
- package/legacy/tests/vscode_extension_test.ts +281 -0
- package/legacy/types/index.ts +32 -0
- package/legacy/types/node-types.ts +80 -0
- package/legacy/util/debug.ts +14 -0
- package/legacy/vector/index.ts +59 -0
- package/legacy/vscode/extension.ts +387 -0
- package/package.json +127 -0
- package/scripts/compiled-crud-verify.ts +30 -0
- package/scripts/dogfood.ts +297 -0
- package/scripts/postinstall.js +156 -0
- package/scripts/release-check.js +190 -0
- package/scripts/run-tests.ts +178 -0
- package/scripts/setup-libclang.ps1 +209 -0
- package/scripts/update-changelog.js +214 -0
- package/web/README.md +27 -0
- package/web/svelte/package.json +31 -0
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import { PluresNode, SQLiteCompatibleAPI } from "../node-index";
|
|
3
|
+
import type { PluresDBConfig } from "../types/node-types";
|
|
4
|
+
|
|
5
|
+
type DisposableLike = { dispose(): void };
|
|
6
|
+
|
|
7
|
+
type InputBoxOptions = {
|
|
8
|
+
prompt: string;
|
|
9
|
+
placeHolder?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type TextDocumentInit = {
|
|
13
|
+
content: string;
|
|
14
|
+
language: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type UriLike = { toString(): string } | string;
|
|
18
|
+
|
|
19
|
+
export type VSCodeWindow = {
|
|
20
|
+
showInformationMessage(message: string): void | Promise<unknown>;
|
|
21
|
+
showErrorMessage(message: string): void | Promise<unknown>;
|
|
22
|
+
showInputBox(options: InputBoxOptions): Promise<string | undefined>;
|
|
23
|
+
showTextDocument(document: unknown): Promise<unknown>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type VSCodeCommands = {
|
|
27
|
+
registerCommand(
|
|
28
|
+
command: string,
|
|
29
|
+
callback: (...args: unknown[]) => unknown,
|
|
30
|
+
): DisposableLike;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type VSCodeWorkspace = {
|
|
34
|
+
openTextDocument(init: TextDocumentInit): Promise<unknown>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type VSCodeEnv = {
|
|
38
|
+
openExternal(target: UriLike): Promise<unknown> | unknown;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type VSCodeUri = {
|
|
42
|
+
parse(target: string): UriLike;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type VSCodeAPI = {
|
|
46
|
+
window: VSCodeWindow;
|
|
47
|
+
commands: VSCodeCommands;
|
|
48
|
+
workspace: VSCodeWorkspace;
|
|
49
|
+
env: VSCodeEnv;
|
|
50
|
+
Uri: VSCodeUri;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type ExtensionContextLike = {
|
|
54
|
+
subscriptions: DisposableLike[];
|
|
55
|
+
globalStorageUri: { fsPath: string };
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type ExtensionOptions = {
|
|
59
|
+
config?: PluresDBConfig;
|
|
60
|
+
commandPrefix?: string;
|
|
61
|
+
pluresInstance?: PluresNode;
|
|
62
|
+
sqliteInstance?: SQLiteCompatibleAPI;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
type CommandFactory = () => Promise<void> | void;
|
|
66
|
+
|
|
67
|
+
const DEFAULT_CONFIG: PluresDBConfig = {
|
|
68
|
+
port: 34567,
|
|
69
|
+
host: "localhost",
|
|
70
|
+
webPort: 34568,
|
|
71
|
+
logLevel: "info",
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export class PluresVSCodeExtension {
|
|
75
|
+
private readonly vscode: VSCodeAPI;
|
|
76
|
+
private readonly context: ExtensionContextLike;
|
|
77
|
+
private readonly plures: PluresNode;
|
|
78
|
+
private readonly sqlite: SQLiteCompatibleAPI;
|
|
79
|
+
private readonly commandPrefix: string;
|
|
80
|
+
private readonly disposables: DisposableLike[] = [];
|
|
81
|
+
private activated = false;
|
|
82
|
+
|
|
83
|
+
constructor(
|
|
84
|
+
vscodeApi: VSCodeAPI,
|
|
85
|
+
context: ExtensionContextLike,
|
|
86
|
+
options: ExtensionOptions = {},
|
|
87
|
+
) {
|
|
88
|
+
this.vscode = vscodeApi;
|
|
89
|
+
this.context = context;
|
|
90
|
+
this.commandPrefix = options.commandPrefix ?? "pluresdb";
|
|
91
|
+
|
|
92
|
+
const mergedConfig: PluresDBConfig = {
|
|
93
|
+
...DEFAULT_CONFIG,
|
|
94
|
+
dataDir: path.join(context.globalStorageUri.fsPath, "pluresdb"),
|
|
95
|
+
...options.config,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
this.plures = options.pluresInstance ??
|
|
99
|
+
new PluresNode({ config: mergedConfig, autoStart: false });
|
|
100
|
+
this.sqlite = options.sqliteInstance ??
|
|
101
|
+
new SQLiteCompatibleAPI({ config: mergedConfig, autoStart: false });
|
|
102
|
+
|
|
103
|
+
this.setupEventHandlers();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async activate(): Promise<void> {
|
|
107
|
+
if (this.activated) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
try {
|
|
112
|
+
await this.plures.start();
|
|
113
|
+
await this.sqlite.start();
|
|
114
|
+
this.registerCommands();
|
|
115
|
+
await this.setupDatabase();
|
|
116
|
+
this.activated = true;
|
|
117
|
+
await this.safeInfo("PluresDB extension activated");
|
|
118
|
+
} catch (error) {
|
|
119
|
+
await this.safeError(
|
|
120
|
+
`Failed to activate PluresDB: ${this.errorMessage(error)}`,
|
|
121
|
+
);
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async deactivate(): Promise<void> {
|
|
127
|
+
if (!this.activated) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
try {
|
|
132
|
+
await this.sqlite.stop();
|
|
133
|
+
await this.plures.stop();
|
|
134
|
+
} finally {
|
|
135
|
+
this.disposeAll();
|
|
136
|
+
this.activated = false;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
getWebUrl(): string {
|
|
141
|
+
return this.plures.getWebUrl();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async storeSetting(key: string, value: unknown) {
|
|
145
|
+
return this.sqlite.put(`settings:${key}`, value);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async getSetting(key: string) {
|
|
149
|
+
return this.sqlite.getValue(`settings:${key}`);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async storeDocument(
|
|
153
|
+
id: string,
|
|
154
|
+
content: string,
|
|
155
|
+
language: string,
|
|
156
|
+
filePath: string,
|
|
157
|
+
) {
|
|
158
|
+
return this.sqlite.put(`documents:${id}`, {
|
|
159
|
+
content,
|
|
160
|
+
language,
|
|
161
|
+
filePath,
|
|
162
|
+
updatedAt: new Date().toISOString(),
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async searchDocuments(query: string, limit = 20) {
|
|
167
|
+
return this.sqlite.vectorSearch(query, limit);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async executeSQL(sql: string, params: unknown[] = []) {
|
|
171
|
+
return this.sqlite.all(sql, params);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
private setupEventHandlers() {
|
|
175
|
+
this.plures.on("started", () => {
|
|
176
|
+
this.safeInfo("PluresDB database started");
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
this.plures.on("stopped", () => {
|
|
180
|
+
this.safeInfo("PluresDB database stopped");
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
this.plures.on("error", (error: unknown) => {
|
|
184
|
+
this.safeError(`PluresDB error: ${this.errorMessage(error)}`);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
this.plures.on("stderr", (output: string) => {
|
|
188
|
+
const trimmed = output.trim();
|
|
189
|
+
if (trimmed.length > 0) {
|
|
190
|
+
this.safeError(trimmed);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
this.plures.on("stdout", (output: string) => {
|
|
195
|
+
const trimmed = output.trim();
|
|
196
|
+
if (trimmed.length > 0) {
|
|
197
|
+
this.safeInfo(trimmed);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
private registerCommands() {
|
|
203
|
+
const register = (name: string, factory: CommandFactory) => {
|
|
204
|
+
const disposable = this.vscode.commands.registerCommand(
|
|
205
|
+
`${this.commandPrefix}.${name}`,
|
|
206
|
+
() => factory(),
|
|
207
|
+
);
|
|
208
|
+
this.context.subscriptions.push(disposable);
|
|
209
|
+
this.disposables.push(disposable);
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
register("openWebUI", async () => {
|
|
213
|
+
const webUrl = this.getWebUrl();
|
|
214
|
+
await this.vscode.env.openExternal(this.vscode.Uri.parse(webUrl));
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
register("executeQuery", async () => {
|
|
218
|
+
const sql = await this.vscode.window.showInputBox({
|
|
219
|
+
prompt: "Enter SQL query",
|
|
220
|
+
placeHolder: "SELECT * FROM users",
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
if (!sql) return;
|
|
224
|
+
|
|
225
|
+
try {
|
|
226
|
+
const result = await this.sqlite.all(sql);
|
|
227
|
+
const doc = await this.vscode.workspace.openTextDocument({
|
|
228
|
+
content: JSON.stringify(result, null, 2),
|
|
229
|
+
language: "json",
|
|
230
|
+
});
|
|
231
|
+
await this.vscode.window.showTextDocument(doc);
|
|
232
|
+
} catch (error) {
|
|
233
|
+
await this.safeError(`Query failed: ${this.errorMessage(error)}`);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
register("vectorSearch", async () => {
|
|
238
|
+
const query = await this.vscode.window.showInputBox({
|
|
239
|
+
prompt: "Enter search query",
|
|
240
|
+
placeHolder: "machine learning",
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
if (!query) return;
|
|
244
|
+
|
|
245
|
+
try {
|
|
246
|
+
const results = await this.sqlite.vectorSearch(query, 10);
|
|
247
|
+
const doc = await this.vscode.workspace.openTextDocument({
|
|
248
|
+
content: JSON.stringify(results, null, 2),
|
|
249
|
+
language: "json",
|
|
250
|
+
});
|
|
251
|
+
await this.vscode.window.showTextDocument(doc);
|
|
252
|
+
} catch (error) {
|
|
253
|
+
await this.safeError(
|
|
254
|
+
`Vector search failed: ${this.errorMessage(error)}`,
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
register("storeData", async () => {
|
|
260
|
+
const key = await this.vscode.window.showInputBox({
|
|
261
|
+
prompt: "Enter key",
|
|
262
|
+
placeHolder: "user:123",
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
if (!key) return;
|
|
266
|
+
|
|
267
|
+
const json = await this.vscode.window.showInputBox({
|
|
268
|
+
prompt: "Enter value (JSON)",
|
|
269
|
+
placeHolder: '{"name": "Ada", "email": "ada@example.com"}',
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
if (!json) return;
|
|
273
|
+
|
|
274
|
+
try {
|
|
275
|
+
const value = JSON.parse(json);
|
|
276
|
+
await this.sqlite.put(key, value);
|
|
277
|
+
await this.safeInfo(`Stored data for key: ${key}`);
|
|
278
|
+
} catch (error) {
|
|
279
|
+
await this.safeError(
|
|
280
|
+
`Failed to store data: ${this.errorMessage(error)}`,
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
register("retrieveData", async () => {
|
|
286
|
+
const key = await this.vscode.window.showInputBox({
|
|
287
|
+
prompt: "Enter key to retrieve",
|
|
288
|
+
placeHolder: "user:123",
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
if (!key) return;
|
|
292
|
+
|
|
293
|
+
try {
|
|
294
|
+
const value = await this.sqlite.getValue(key);
|
|
295
|
+
if (value) {
|
|
296
|
+
const doc = await this.vscode.workspace.openTextDocument({
|
|
297
|
+
content: JSON.stringify(value, null, 2),
|
|
298
|
+
language: "json",
|
|
299
|
+
});
|
|
300
|
+
await this.vscode.window.showTextDocument(doc);
|
|
301
|
+
} else {
|
|
302
|
+
await this.safeInfo("Key not found");
|
|
303
|
+
}
|
|
304
|
+
} catch (error) {
|
|
305
|
+
await this.safeError(
|
|
306
|
+
`Failed to retrieve data: ${this.errorMessage(error)}`,
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
private async setupDatabase() {
|
|
313
|
+
const statements = [
|
|
314
|
+
`CREATE TABLE IF NOT EXISTS settings (
|
|
315
|
+
key TEXT PRIMARY KEY,
|
|
316
|
+
value TEXT,
|
|
317
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
318
|
+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
319
|
+
)`,
|
|
320
|
+
`CREATE TABLE IF NOT EXISTS documents (
|
|
321
|
+
id TEXT PRIMARY KEY,
|
|
322
|
+
content TEXT,
|
|
323
|
+
language TEXT,
|
|
324
|
+
file_path TEXT,
|
|
325
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
326
|
+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
327
|
+
)`,
|
|
328
|
+
`CREATE TABLE IF NOT EXISTS search_history (
|
|
329
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
330
|
+
query TEXT,
|
|
331
|
+
results_count INTEGER,
|
|
332
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
333
|
+
)`,
|
|
334
|
+
];
|
|
335
|
+
|
|
336
|
+
for (const sql of statements) {
|
|
337
|
+
try {
|
|
338
|
+
await this.sqlite.exec(sql);
|
|
339
|
+
} catch (error) {
|
|
340
|
+
await this.safeError(
|
|
341
|
+
`Failed to initialize database: ${this.errorMessage(error)}`,
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
private disposeAll() {
|
|
348
|
+
for (const disposable of this.disposables.splice(0)) {
|
|
349
|
+
try {
|
|
350
|
+
disposable.dispose();
|
|
351
|
+
} catch (_error) {
|
|
352
|
+
// ignore
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
private async safeInfo(message: string) {
|
|
358
|
+
try {
|
|
359
|
+
await this.vscode.window.showInformationMessage(message);
|
|
360
|
+
} catch (_error) {
|
|
361
|
+
// ignore message failures in headless tests
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
private async safeError(message: string) {
|
|
366
|
+
try {
|
|
367
|
+
await this.vscode.window.showErrorMessage(message);
|
|
368
|
+
} catch (_error) {
|
|
369
|
+
// ignore message failures in headless tests
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
private errorMessage(error: unknown): string {
|
|
374
|
+
if (error instanceof Error) {
|
|
375
|
+
return error.message;
|
|
376
|
+
}
|
|
377
|
+
return String(error);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export function createPluresExtension(
|
|
382
|
+
vscodeApi: VSCodeAPI,
|
|
383
|
+
context: ExtensionContextLike,
|
|
384
|
+
options: ExtensionOptions = {},
|
|
385
|
+
) {
|
|
386
|
+
return new PluresVSCodeExtension(vscodeApi, context, options);
|
|
387
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@plures/pluresdb",
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "P2P Graph Database with SQLite Compatibility - Local-first, offline-first database for modern applications",
|
|
5
|
+
"main": "dist/node-index.js",
|
|
6
|
+
"types": "dist/node-index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/node-index.d.ts",
|
|
10
|
+
"require": "./dist/node-index.js",
|
|
11
|
+
"default": "./dist/node-index.js"
|
|
12
|
+
},
|
|
13
|
+
"./node": {
|
|
14
|
+
"types": "./dist/node-index.d.ts",
|
|
15
|
+
"require": "./dist/node-index.js",
|
|
16
|
+
"default": "./dist/node-index.js"
|
|
17
|
+
},
|
|
18
|
+
"./better-sqlite3": {
|
|
19
|
+
"types": "./dist/better-sqlite3.d.ts",
|
|
20
|
+
"require": "./dist/better-sqlite3.js",
|
|
21
|
+
"default": "./dist/better-sqlite3.js"
|
|
22
|
+
},
|
|
23
|
+
"./vscode": {
|
|
24
|
+
"types": "./dist/vscode/extension.d.ts",
|
|
25
|
+
"require": "./dist/vscode/extension.js",
|
|
26
|
+
"default": "./dist/vscode/extension.js"
|
|
27
|
+
},
|
|
28
|
+
"./cli": {
|
|
29
|
+
"types": "./dist/cli.d.ts",
|
|
30
|
+
"require": "./dist/cli.js",
|
|
31
|
+
"default": "./dist/cli.js"
|
|
32
|
+
},
|
|
33
|
+
"./types": {
|
|
34
|
+
"types": "./dist/types/node-types.d.ts",
|
|
35
|
+
"require": "./dist/types/node-types.js",
|
|
36
|
+
"default": "./dist/types/node-types.js"
|
|
37
|
+
},
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
40
|
+
"bin": {
|
|
41
|
+
"pluresdb": "dist/cli.js"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "npm run build:lib && npm run build:web",
|
|
45
|
+
"build:lib": "tsc -p tsconfig.json",
|
|
46
|
+
"build:web": "cd web/svelte && npm install && npm run build",
|
|
47
|
+
"dev": "deno run -A --unstable-kv --watch src/main.ts serve --port 34567",
|
|
48
|
+
"start": "node dist/cli.js serve",
|
|
49
|
+
"test": "deno test -A --unstable-kv",
|
|
50
|
+
"test:azure:relay": "deno test --allow-net --allow-env azure/tests/relay-tests.ts",
|
|
51
|
+
"test:azure:full": "npm run test:azure:relay",
|
|
52
|
+
"lint": "eslint . --ext .js,.ts,.tsx",
|
|
53
|
+
"fmt:check": "prettier --check .",
|
|
54
|
+
"fmt": "prettier --write .",
|
|
55
|
+
"verify": "npm run build:lib && npm test",
|
|
56
|
+
"prepare": "npm run build:lib",
|
|
57
|
+
"prepublishOnly": "npm run verify && npm run build:web",
|
|
58
|
+
"postinstall": "node scripts/postinstall.js",
|
|
59
|
+
"release-check": "node scripts/release-check.js",
|
|
60
|
+
"update-changelog": "node scripts/update-changelog.js"
|
|
61
|
+
},
|
|
62
|
+
"keywords": [
|
|
63
|
+
"database",
|
|
64
|
+
"graph-database",
|
|
65
|
+
"p2p",
|
|
66
|
+
"sqlite",
|
|
67
|
+
"local-first",
|
|
68
|
+
"offline-first",
|
|
69
|
+
"crdt",
|
|
70
|
+
"vector-search",
|
|
71
|
+
"deno",
|
|
72
|
+
"typescript",
|
|
73
|
+
"vscode",
|
|
74
|
+
"extension",
|
|
75
|
+
"embedded",
|
|
76
|
+
"sync",
|
|
77
|
+
"encryption"
|
|
78
|
+
],
|
|
79
|
+
"author": "Plures Organization",
|
|
80
|
+
"license": "AGPL-3.0",
|
|
81
|
+
"homepage": "https://github.com/plures/pluresdb#readme",
|
|
82
|
+
"repository": {
|
|
83
|
+
"type": "git",
|
|
84
|
+
"url": "git+https://github.com/plures/pluresdb.git"
|
|
85
|
+
},
|
|
86
|
+
"bugs": {
|
|
87
|
+
"url": "https://github.com/plures/pluresdb/issues"
|
|
88
|
+
},
|
|
89
|
+
"engines": {
|
|
90
|
+
"node": ">=18.0.0",
|
|
91
|
+
"npm": ">=8.0.0"
|
|
92
|
+
},
|
|
93
|
+
"files": [
|
|
94
|
+
"dist/",
|
|
95
|
+
"web/svelte/dist/",
|
|
96
|
+
"legacy/",
|
|
97
|
+
"examples/",
|
|
98
|
+
"scripts/",
|
|
99
|
+
"README.md",
|
|
100
|
+
"LICENSE",
|
|
101
|
+
"package.json"
|
|
102
|
+
],
|
|
103
|
+
"dependencies": {
|
|
104
|
+
"cors": "^2.8.5",
|
|
105
|
+
"express": "^5.1.0",
|
|
106
|
+
"ws": "^8.18.3"
|
|
107
|
+
},
|
|
108
|
+
"devDependencies": {
|
|
109
|
+
"@types/cors": "^2.8.19",
|
|
110
|
+
"@types/express": "^5.0.0",
|
|
111
|
+
"@types/node": "^22.10.0",
|
|
112
|
+
"@types/vscode": "^1.104.0",
|
|
113
|
+
"@types/ws": "^8.18.1",
|
|
114
|
+
"@typescript-eslint/eslint-plugin": "^8.46.4",
|
|
115
|
+
"@typescript-eslint/parser": "^8.46.4",
|
|
116
|
+
"eslint": "^9.39.1",
|
|
117
|
+
"eslint-config-prettier": "^10.1.8",
|
|
118
|
+
"eslint-plugin-import": "^2.32.0",
|
|
119
|
+
"prettier": "^3.6.2",
|
|
120
|
+
"prettier-plugin-svelte": "^3.4.0",
|
|
121
|
+
"typescript": "^5.9.3"
|
|
122
|
+
},
|
|
123
|
+
"publishConfig": {
|
|
124
|
+
"access": "public",
|
|
125
|
+
"registry": "https://registry.npmjs.org/"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { GunDB } from "../src/core/database.ts";
|
|
2
|
+
|
|
3
|
+
const serverUrl = Deno.env.get("SERVER_URL") ?? "ws://localhost:34567";
|
|
4
|
+
|
|
5
|
+
const clientA = new GunDB();
|
|
6
|
+
const clientB = new GunDB();
|
|
7
|
+
|
|
8
|
+
const kvA = await Deno.makeTempFile({ prefix: "kv_", suffix: ".sqlite" });
|
|
9
|
+
const kvB = await Deno.makeTempFile({ prefix: "kv_", suffix: ".sqlite" });
|
|
10
|
+
|
|
11
|
+
await clientA.ready(kvA);
|
|
12
|
+
await clientB.ready(kvB);
|
|
13
|
+
|
|
14
|
+
clientA.connect(serverUrl);
|
|
15
|
+
clientB.connect(serverUrl);
|
|
16
|
+
|
|
17
|
+
const id = `bin:crud:${crypto.randomUUID()}`;
|
|
18
|
+
|
|
19
|
+
const receivedOnB = new Promise<void>((resolve) =>
|
|
20
|
+
clientB.on(id, (n) => n && resolve())
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
await clientA.put(id, { text: "compiled works" } as Record<string, unknown>);
|
|
24
|
+
|
|
25
|
+
await receivedOnB;
|
|
26
|
+
|
|
27
|
+
await clientA.close();
|
|
28
|
+
await clientB.close();
|
|
29
|
+
|
|
30
|
+
console.log("COMPILED-CRUD-OK", id);
|