pluresdb 1.0.1 → 1.3.1
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 +100 -5
- package/dist/.tsbuildinfo +1 -1
- 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.map +1 -1
- package/dist/cli.js +21 -16
- package/dist/cli.js.map +1 -1
- package/dist/node-index.d.ts +98 -2
- package/dist/node-index.d.ts.map +1 -1
- package/dist/node-index.js +312 -6
- package/dist/node-index.js.map +1 -1
- package/dist/node-wrapper.d.ts.map +1 -1
- package/dist/node-wrapper.js +5 -3
- package/dist/node-wrapper.js.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/node-types.d.ts +12 -0
- package/dist/types/node-types.d.ts.map +1 -1
- package/dist/types/node-types.js.map +1 -1
- package/dist/vscode/extension.d.ts.map +1 -1
- package/dist/vscode/extension.js +4 -4
- package/dist/vscode/extension.js.map +1 -1
- package/examples/basic-usage.d.ts +1 -1
- package/examples/vscode-extension-example/src/extension.ts +15 -6
- package/examples/vscode-extension-integration.d.ts +24 -17
- package/examples/vscode-extension-integration.js +140 -106
- package/examples/vscode-extension-integration.ts +1 -1
- package/{src → legacy}/benchmarks/memory-benchmarks.ts +85 -51
- package/{src → legacy}/benchmarks/run-benchmarks.ts +32 -10
- package/legacy/better-sqlite3-shared.ts +157 -0
- package/legacy/better-sqlite3.ts +4 -0
- package/{src → legacy}/cli.ts +14 -4
- package/{src → legacy}/config.ts +2 -1
- package/{src → legacy}/core/crdt.ts +4 -1
- package/{src → legacy}/core/database.ts +57 -22
- package/{src → legacy}/healthcheck.ts +11 -5
- package/{src → legacy}/http/api-server.ts +125 -21
- package/{src → legacy}/index.ts +2 -2
- package/{src → legacy}/logic/rules.ts +3 -1
- package/{src → legacy}/main.ts +11 -4
- package/legacy/node-index.ts +823 -0
- package/{src → legacy}/node-wrapper.ts +18 -9
- package/{src → legacy}/sqlite-compat.ts +63 -16
- package/{src → legacy}/sqlite3-compat.ts +2 -2
- package/{src → legacy}/storage/kv-storage.ts +3 -1
- package/{src → legacy}/tests/core.test.ts +37 -13
- package/{src → legacy}/tests/fixtures/test-data.json +6 -1
- package/{src → legacy}/tests/integration/api-server.test.ts +110 -8
- package/{src → legacy}/tests/integration/mesh-network.test.ts +8 -2
- package/{src → legacy}/tests/logic.test.ts +6 -2
- package/{src → legacy}/tests/performance/load.test.ts +4 -2
- package/{src → legacy}/tests/security/input-validation.test.ts +5 -1
- package/{src → legacy}/tests/unit/core.test.ts +13 -3
- package/{src → legacy}/tests/unit/subscriptions.test.ts +1 -1
- package/{src → legacy}/tests/vscode_extension_test.ts +39 -11
- package/{src → legacy}/types/node-types.ts +14 -0
- package/{src → legacy}/vscode/extension.ts +37 -14
- package/package.json +19 -9
- package/scripts/compiled-crud-verify.ts +3 -1
- package/scripts/dogfood.ts +55 -16
- package/scripts/postinstall.js +4 -3
- package/scripts/release-check.js +190 -0
- package/scripts/run-tests.ts +5 -2
- package/scripts/update-changelog.js +214 -0
- package/web/svelte/package.json +5 -5
- package/src/node-index.ts +0 -385
- /package/{src → legacy}/main.rs +0 -0
- /package/{src → legacy}/network/websocket-server.ts +0 -0
- /package/{src → legacy}/tests/fixtures/performance-data.json +0 -0
- /package/{src → legacy}/tests/unit/vector-search.test.ts +0 -0
- /package/{src → legacy}/types/index.ts +0 -0
- /package/{src → legacy}/util/debug.ts +0 -0
- /package/{src → legacy}/vector/index.ts +0 -0
package/scripts/run-tests.ts
CHANGED
|
@@ -95,7 +95,9 @@ class TestRunner {
|
|
|
95
95
|
console.log("\nDetailed Results:");
|
|
96
96
|
this.results.forEach((result) => {
|
|
97
97
|
const status = result.passed ? "✅" : "❌";
|
|
98
|
-
console.log(
|
|
98
|
+
console.log(
|
|
99
|
+
` ${status} ${result.suite} (${result.duration.toFixed(2)}ms)`,
|
|
100
|
+
);
|
|
99
101
|
});
|
|
100
102
|
|
|
101
103
|
if (passed < total) {
|
|
@@ -118,7 +120,8 @@ async function main() {
|
|
|
118
120
|
{
|
|
119
121
|
name: "Unit Tests",
|
|
120
122
|
command: "test -A --unstable-kv --parallel src/tests/unit/",
|
|
121
|
-
description:
|
|
123
|
+
description:
|
|
124
|
+
"Core functionality tests (CRUD, subscriptions, vector search)",
|
|
122
125
|
timeout: 30000,
|
|
123
126
|
},
|
|
124
127
|
{
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Updates CHANGELOG.md with commits since the last tag
|
|
5
|
+
* This script is meant to be run during CI before version bumping
|
|
6
|
+
*
|
|
7
|
+
* Usage: node scripts/update-changelog.js <version>
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const { execSync } = require('child_process');
|
|
11
|
+
const fs = require('fs');
|
|
12
|
+
const path = require('path');
|
|
13
|
+
|
|
14
|
+
function run(cmd) {
|
|
15
|
+
try {
|
|
16
|
+
return execSync(cmd, { encoding: 'utf8', stdio: 'pipe' }).trim();
|
|
17
|
+
} catch (e) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function getCommitsSinceLastTag() {
|
|
23
|
+
const lastTag = run('git describe --tags --abbrev=0 2>/dev/null');
|
|
24
|
+
if (!lastTag) {
|
|
25
|
+
console.log('No previous tags found, analyzing all commits');
|
|
26
|
+
const commits = run('git log --format="%s"');
|
|
27
|
+
return commits ? commits.split('\n').filter(Boolean) : [];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const range = `${lastTag}..HEAD`;
|
|
31
|
+
const commits = run(`git log --format="%s" ${range}`);
|
|
32
|
+
if (!commits) {
|
|
33
|
+
console.log('No commits since last tag');
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return commits.split('\n').filter(Boolean);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function categorizeCommits(commits) {
|
|
41
|
+
const categories = {
|
|
42
|
+
feat: [],
|
|
43
|
+
fix: [],
|
|
44
|
+
docs: [],
|
|
45
|
+
style: [],
|
|
46
|
+
refactor: [],
|
|
47
|
+
test: [],
|
|
48
|
+
chore: [],
|
|
49
|
+
perf: [],
|
|
50
|
+
ci: [],
|
|
51
|
+
build: [],
|
|
52
|
+
other: [],
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
commits.forEach((commit) => {
|
|
56
|
+
// Skip release commits
|
|
57
|
+
if (commit.match(/^chore\(release\):/)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const match = commit.match(/^(\w+)(\(.+\))?: (.+)/);
|
|
62
|
+
if (match) {
|
|
63
|
+
const [, type, , description] = match;
|
|
64
|
+
if (categories[type]) {
|
|
65
|
+
categories[type].push(description);
|
|
66
|
+
} else {
|
|
67
|
+
categories.other.push(commit);
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
categories.other.push(commit);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return categories;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function generateChangelogEntry(version, categories) {
|
|
78
|
+
const today = new Date().toISOString().split('T')[0];
|
|
79
|
+
let entry = `## [${version}] - ${today}\n\n`;
|
|
80
|
+
let hasContent = false;
|
|
81
|
+
|
|
82
|
+
if (categories.feat.length > 0) {
|
|
83
|
+
entry += '### Added\n\n';
|
|
84
|
+
categories.feat.forEach((item) => {
|
|
85
|
+
entry += `- ${item}\n`;
|
|
86
|
+
});
|
|
87
|
+
entry += '\n';
|
|
88
|
+
hasContent = true;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (categories.fix.length > 0) {
|
|
92
|
+
entry += '### Fixed\n\n';
|
|
93
|
+
categories.fix.forEach((item) => {
|
|
94
|
+
entry += `- ${item}\n`;
|
|
95
|
+
});
|
|
96
|
+
entry += '\n';
|
|
97
|
+
hasContent = true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (categories.refactor.length > 0 || categories.style.length > 0 || categories.perf.length > 0) {
|
|
101
|
+
entry += '### Changed\n\n';
|
|
102
|
+
[...categories.refactor, ...categories.style, ...categories.perf].forEach((item) => {
|
|
103
|
+
entry += `- ${item}\n`;
|
|
104
|
+
});
|
|
105
|
+
entry += '\n';
|
|
106
|
+
hasContent = true;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (categories.docs.length > 0) {
|
|
110
|
+
entry += '### Documentation\n\n';
|
|
111
|
+
categories.docs.forEach((item) => {
|
|
112
|
+
entry += `- ${item}\n`;
|
|
113
|
+
});
|
|
114
|
+
entry += '\n';
|
|
115
|
+
hasContent = true;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (categories.test.length > 0 || categories.chore.length > 0 || categories.ci.length > 0 || categories.build.length > 0) {
|
|
119
|
+
entry += '### Developer Experience\n\n';
|
|
120
|
+
[...categories.test, ...categories.chore, ...categories.ci, ...categories.build].forEach((item) => {
|
|
121
|
+
entry += `- ${item}\n`;
|
|
122
|
+
});
|
|
123
|
+
entry += '\n';
|
|
124
|
+
hasContent = true;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (categories.other.length > 0) {
|
|
128
|
+
entry += '### Other\n\n';
|
|
129
|
+
categories.other.forEach((item) => {
|
|
130
|
+
entry += `- ${item}\n`;
|
|
131
|
+
});
|
|
132
|
+
entry += '\n';
|
|
133
|
+
hasContent = true;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (!hasContent) {
|
|
137
|
+
entry += '- Maintenance and improvements\n\n';
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return entry;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function updateChangelog(newEntry) {
|
|
144
|
+
const changelogPath = path.join(process.cwd(), 'CHANGELOG.md');
|
|
145
|
+
|
|
146
|
+
if (!fs.existsSync(changelogPath)) {
|
|
147
|
+
console.log('CHANGELOG.md not found, creating new one');
|
|
148
|
+
const content = `# Changelog\n\nAll notable changes to this project will be documented in this file.\n\n${newEntry}`;
|
|
149
|
+
fs.writeFileSync(changelogPath, content);
|
|
150
|
+
console.log('Created CHANGELOG.md');
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const content = fs.readFileSync(changelogPath, 'utf8');
|
|
155
|
+
const lines = content.split('\n');
|
|
156
|
+
let insertIndex = -1;
|
|
157
|
+
|
|
158
|
+
// Find the position after the header and before the first version entry
|
|
159
|
+
for (let i = 0; i < lines.length; i++) {
|
|
160
|
+
if (lines[i].startsWith('## [') && !lines[i].includes('[Unreleased]')) {
|
|
161
|
+
insertIndex = i;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (insertIndex === -1) {
|
|
167
|
+
// No previous releases found, insert after any "Unreleased" section
|
|
168
|
+
for (let i = 0; i < lines.length; i++) {
|
|
169
|
+
if (lines[i].startsWith('## [Unreleased]')) {
|
|
170
|
+
// Skip the unreleased section
|
|
171
|
+
let j = i + 1;
|
|
172
|
+
while (j < lines.length && !lines[j].startsWith('##')) {
|
|
173
|
+
j++;
|
|
174
|
+
}
|
|
175
|
+
insertIndex = j;
|
|
176
|
+
break;
|
|
177
|
+
} else if (lines[i].startsWith('# ')) {
|
|
178
|
+
// Found the main header, insert after it
|
|
179
|
+
insertIndex = i + 2;
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (insertIndex === -1) {
|
|
186
|
+
// Last resort: append at the end
|
|
187
|
+
lines.push('', newEntry);
|
|
188
|
+
} else {
|
|
189
|
+
// Insert the new entry
|
|
190
|
+
lines.splice(insertIndex, 0, newEntry);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
fs.writeFileSync(changelogPath, lines.join('\n'));
|
|
194
|
+
console.log('✅ Updated CHANGELOG.md');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function main() {
|
|
198
|
+
const version = process.argv[2];
|
|
199
|
+
if (!version) {
|
|
200
|
+
console.error('Usage: node scripts/update-changelog.js <version>');
|
|
201
|
+
process.exit(1);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const commits = getCommitsSinceLastTag();
|
|
205
|
+
if (commits.length === 0) {
|
|
206
|
+
console.log('No commits to add to changelog, creating minimal entry');
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const categories = categorizeCommits(commits);
|
|
210
|
+
const entry = generateChangelogEntry(version, categories);
|
|
211
|
+
updateChangelog(entry);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
main();
|
package/web/svelte/package.json
CHANGED
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
"@codemirror/state": "^6.4.0",
|
|
16
16
|
"@codemirror/theme-one-dark": "^6.1.2",
|
|
17
17
|
"@codemirror/view": "^6.28.1",
|
|
18
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
18
|
+
"@sveltejs/vite-plugin-svelte": "^6.2.1",
|
|
19
19
|
"ajv": "^8.12.0",
|
|
20
|
-
"svelte": "^
|
|
21
|
-
"vite": "^
|
|
20
|
+
"svelte": "^5.17.3",
|
|
21
|
+
"vite": "^7.2.2"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@monaco-editor/loader": "^1.5.0",
|
|
25
|
-
"cytoscape": "^3.
|
|
25
|
+
"cytoscape": "^3.29.3",
|
|
26
26
|
"cytoscape-cola": "^2.5.1",
|
|
27
27
|
"cytoscape-cose-bilkent": "^4.1.0",
|
|
28
28
|
"cytoscape-dagre": "^2.5.0",
|
|
29
|
-
"monaco-editor": "^0.
|
|
29
|
+
"monaco-editor": "^0.49.0"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/src/node-index.ts
DELETED
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Node.js Entry Point for PluresDB
|
|
3
|
-
* This provides a clean API for VSCode extensions and other Node.js applications
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { EventEmitter } from "node:events";
|
|
7
|
-
import { spawn, ChildProcess } from "node:child_process";
|
|
8
|
-
import * as path from "node:path";
|
|
9
|
-
import * as fs from "node:fs";
|
|
10
|
-
import * as os from "node:os";
|
|
11
|
-
import process from "node:process";
|
|
12
|
-
import { PluresDBConfig, PluresDBOptions } from "./types/node-types";
|
|
13
|
-
|
|
14
|
-
const packageRoot =
|
|
15
|
-
typeof __dirname !== "undefined" ? path.resolve(__dirname, "..") : process.cwd();
|
|
16
|
-
|
|
17
|
-
export class PluresNode extends EventEmitter {
|
|
18
|
-
private process: ChildProcess | null = null;
|
|
19
|
-
private config: PluresDBConfig;
|
|
20
|
-
private denoPath: string;
|
|
21
|
-
private isRunning = false;
|
|
22
|
-
private apiUrl: string = "";
|
|
23
|
-
|
|
24
|
-
constructor(options: PluresDBOptions = {}) {
|
|
25
|
-
super();
|
|
26
|
-
|
|
27
|
-
this.config = {
|
|
28
|
-
port: 34567,
|
|
29
|
-
host: "localhost",
|
|
30
|
-
dataDir: path.join(os.homedir(), ".pluresdb"),
|
|
31
|
-
webPort: 34568,
|
|
32
|
-
logLevel: "info",
|
|
33
|
-
...options.config,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
this.denoPath = options.denoPath || this.findDenoPath();
|
|
37
|
-
|
|
38
|
-
if (options.autoStart !== false) {
|
|
39
|
-
this.start();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
private findDenoPath(): string {
|
|
44
|
-
// Try to find Deno in common locations
|
|
45
|
-
const possiblePaths = [
|
|
46
|
-
"deno", // In PATH
|
|
47
|
-
path.join(os.homedir(), ".deno", "bin", "deno"),
|
|
48
|
-
path.join(os.homedir(), ".local", "bin", "deno"),
|
|
49
|
-
"/usr/local/bin/deno",
|
|
50
|
-
"/opt/homebrew/bin/deno",
|
|
51
|
-
"C:\\Users\\" + os.userInfo().username + "\\.deno\\bin\\deno.exe",
|
|
52
|
-
"C:\\Program Files\\deno\\deno.exe",
|
|
53
|
-
];
|
|
54
|
-
|
|
55
|
-
for (const denoPath of possiblePaths) {
|
|
56
|
-
try {
|
|
57
|
-
if (fs.existsSync(denoPath) || this.isCommandAvailable(denoPath)) {
|
|
58
|
-
return denoPath;
|
|
59
|
-
}
|
|
60
|
-
} catch (error) {
|
|
61
|
-
// Continue to next path
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
throw new Error("Deno not found. Please install Deno from https://deno.land/");
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
private isCommandAvailable(command: string): boolean {
|
|
69
|
-
try {
|
|
70
|
-
require("child_process").execSync(`"${command}" --version`, { stdio: "ignore" });
|
|
71
|
-
return true;
|
|
72
|
-
} catch {
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
async start(): Promise<void> {
|
|
78
|
-
if (this.isRunning) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return new Promise((resolve, reject) => {
|
|
83
|
-
try {
|
|
84
|
-
// Ensure data directory exists
|
|
85
|
-
if (!fs.existsSync(this.config.dataDir!)) {
|
|
86
|
-
fs.mkdirSync(this.config.dataDir!, { recursive: true });
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const kvPath = path.join(this.config.dataDir!, "pluresdb.kv");
|
|
90
|
-
|
|
91
|
-
// Find the main.ts file
|
|
92
|
-
const mainTsPath = path.join(packageRoot, "src", "main.ts");
|
|
93
|
-
if (!fs.existsSync(mainTsPath)) {
|
|
94
|
-
throw new Error(
|
|
95
|
-
"PluresDB main.ts not found. Please ensure the package is properly installed.",
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Start the Deno process
|
|
100
|
-
const args = [
|
|
101
|
-
"run",
|
|
102
|
-
"-A",
|
|
103
|
-
"--unstable-kv",
|
|
104
|
-
"--no-lock",
|
|
105
|
-
mainTsPath,
|
|
106
|
-
"serve",
|
|
107
|
-
"--port",
|
|
108
|
-
this.config.port!.toString(),
|
|
109
|
-
"--host",
|
|
110
|
-
this.config.host!,
|
|
111
|
-
"--kv",
|
|
112
|
-
kvPath,
|
|
113
|
-
];
|
|
114
|
-
|
|
115
|
-
this.process = spawn(this.denoPath, args, {
|
|
116
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
117
|
-
cwd: packageRoot,
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
this.apiUrl = `http://${this.config.host}:${this.config.port}`;
|
|
121
|
-
|
|
122
|
-
// Handle process events
|
|
123
|
-
this.process.on("error", (error) => {
|
|
124
|
-
this.emit("error", error);
|
|
125
|
-
reject(error);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
this.process.on("exit", (code) => {
|
|
129
|
-
this.isRunning = false;
|
|
130
|
-
this.emit("exit", code);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
// Wait for server to start
|
|
134
|
-
this.waitForServer()
|
|
135
|
-
.then(() => {
|
|
136
|
-
this.isRunning = true;
|
|
137
|
-
this.emit("started");
|
|
138
|
-
resolve();
|
|
139
|
-
})
|
|
140
|
-
.catch(reject);
|
|
141
|
-
|
|
142
|
-
// Handle stdout/stderr
|
|
143
|
-
this.process.stdout?.on("data", (data) => {
|
|
144
|
-
const output = data.toString();
|
|
145
|
-
this.emit("stdout", output);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
this.process.stderr?.on("data", (data) => {
|
|
149
|
-
const output = data.toString();
|
|
150
|
-
this.emit("stderr", output);
|
|
151
|
-
});
|
|
152
|
-
} catch (error) {
|
|
153
|
-
reject(error);
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
private async waitForServer(timeout = 20000): Promise<void> {
|
|
159
|
-
const startTime = Date.now();
|
|
160
|
-
|
|
161
|
-
while (Date.now() - startTime < timeout) {
|
|
162
|
-
try {
|
|
163
|
-
const response = await fetch(`${this.apiUrl}/api/config`);
|
|
164
|
-
if (response.ok) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
} catch (error) {
|
|
168
|
-
// Server not ready yet
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
throw new Error("Server failed to start within timeout");
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
async stop(): Promise<void> {
|
|
178
|
-
if (!this.isRunning || !this.process) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return new Promise((resolve) => {
|
|
183
|
-
this.process!.kill("SIGTERM");
|
|
184
|
-
|
|
185
|
-
this.process!.on("exit", () => {
|
|
186
|
-
this.isRunning = false;
|
|
187
|
-
this.emit("stopped");
|
|
188
|
-
resolve();
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
// Force kill after 5 seconds
|
|
192
|
-
setTimeout(() => {
|
|
193
|
-
if (this.process && this.isRunning) {
|
|
194
|
-
this.process.kill("SIGKILL");
|
|
195
|
-
}
|
|
196
|
-
resolve();
|
|
197
|
-
}, 5000);
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
getApiUrl(): string {
|
|
202
|
-
return this.apiUrl;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
getWebUrl(): string {
|
|
206
|
-
return `http://${this.config.host}:${this.config.webPort}`;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
isServerRunning(): boolean {
|
|
210
|
-
return this.isRunning;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// SQLite-compatible API methods
|
|
214
|
-
async query(sql: string, params: any[] = []): Promise<any> {
|
|
215
|
-
const response = await fetch(`${this.apiUrl}/api/query`, {
|
|
216
|
-
method: "POST",
|
|
217
|
-
headers: { "Content-Type": "application/json" },
|
|
218
|
-
body: JSON.stringify({ sql, params }),
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
if (!response.ok) {
|
|
222
|
-
throw new Error(`Query failed: ${response.statusText}`);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return response.json();
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
async put(key: string, value: any): Promise<void> {
|
|
229
|
-
const response = await fetch(`${this.apiUrl}/api/data`, {
|
|
230
|
-
method: "PUT",
|
|
231
|
-
headers: { "Content-Type": "application/json" },
|
|
232
|
-
body: JSON.stringify({ key, value }),
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
if (!response.ok) {
|
|
236
|
-
throw new Error(`Put failed: ${response.statusText}`);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
async get(key: string): Promise<any> {
|
|
241
|
-
const response = await fetch(`${this.apiUrl}/api/data/${encodeURIComponent(key)}`);
|
|
242
|
-
|
|
243
|
-
if (!response.ok) {
|
|
244
|
-
if (response.status === 404) {
|
|
245
|
-
return null;
|
|
246
|
-
}
|
|
247
|
-
throw new Error(`Get failed: ${response.statusText}`);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
return response.json();
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
async delete(key: string): Promise<void> {
|
|
254
|
-
const response = await fetch(`${this.apiUrl}/api/data/${encodeURIComponent(key)}`, {
|
|
255
|
-
method: "DELETE",
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
if (!response.ok) {
|
|
259
|
-
throw new Error(`Delete failed: ${response.statusText}`);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
async vectorSearch(query: string, limit = 10): Promise<any[]> {
|
|
264
|
-
const response = await fetch(`${this.apiUrl}/api/vsearch`, {
|
|
265
|
-
method: "POST",
|
|
266
|
-
headers: { "Content-Type": "application/json" },
|
|
267
|
-
body: JSON.stringify({ query, limit }),
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
if (!response.ok) {
|
|
271
|
-
throw new Error(`Vector search failed: ${response.statusText}`);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
return response.json() as Promise<any[]>;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
async list(prefix?: string): Promise<string[]> {
|
|
278
|
-
const url = prefix
|
|
279
|
-
? `${this.apiUrl}/api/list?prefix=${encodeURIComponent(prefix)}`
|
|
280
|
-
: `${this.apiUrl}/api/list`;
|
|
281
|
-
const response = await fetch(url);
|
|
282
|
-
|
|
283
|
-
if (!response.ok) {
|
|
284
|
-
throw new Error(`List failed: ${response.statusText}`);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
return response.json() as Promise<string[]>;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
async getConfig(): Promise<any> {
|
|
291
|
-
const response = await fetch(`${this.apiUrl}/api/config`);
|
|
292
|
-
|
|
293
|
-
if (!response.ok) {
|
|
294
|
-
throw new Error(`Get config failed: ${response.statusText}`);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
return response.json();
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
async setConfig(config: any): Promise<void> {
|
|
301
|
-
const response = await fetch(`${this.apiUrl}/api/config`, {
|
|
302
|
-
method: "POST",
|
|
303
|
-
headers: { "Content-Type": "application/json" },
|
|
304
|
-
body: JSON.stringify(config),
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
if (!response.ok) {
|
|
308
|
-
throw new Error(`Set config failed: ${response.statusText}`);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// SQLite-compatible API for easy migration
|
|
314
|
-
export class SQLiteCompatibleAPI {
|
|
315
|
-
private plures: PluresNode;
|
|
316
|
-
|
|
317
|
-
constructor(options?: PluresDBOptions) {
|
|
318
|
-
this.plures = new PluresNode(options);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
async start() {
|
|
322
|
-
await this.plures.start();
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
async stop() {
|
|
326
|
-
await this.plures.stop();
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// SQLite-compatible methods
|
|
330
|
-
async run(sql: string, params: any[] = []) {
|
|
331
|
-
return this.plures.query(sql, params);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
async get(sql: string, params: any[] = []) {
|
|
335
|
-
const result = await this.plures.query(sql, params);
|
|
336
|
-
return result.rows?.[0] || null;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
async all(sql: string, params: any[] = []) {
|
|
340
|
-
const result = await this.plures.query(sql, params);
|
|
341
|
-
return result.rows || [];
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
async exec(sql: string) {
|
|
345
|
-
return this.plures.query(sql);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
// Additional PluresDB specific methods
|
|
349
|
-
async put(key: string, value: any) {
|
|
350
|
-
return this.plures.put(key, value);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
async getValue(key: string) {
|
|
354
|
-
return this.plures.get(key);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
async delete(key: string) {
|
|
358
|
-
return this.plures.delete(key);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
async vectorSearch(query: string, limit = 10) {
|
|
362
|
-
return this.plures.vectorSearch(query, limit);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
async list(prefix?: string) {
|
|
366
|
-
return this.plures.list(prefix);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
getApiUrl() {
|
|
370
|
-
return this.plures.getApiUrl();
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
getWebUrl() {
|
|
374
|
-
return this.plures.getWebUrl();
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
isRunning() {
|
|
378
|
-
return this.plures.isServerRunning();
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
// Export the main class and types
|
|
383
|
-
export { PluresNode as default };
|
|
384
|
-
export * from "./types/node-types";
|
|
385
|
-
export { PluresVSCodeExtension, createPluresExtension } from "./vscode/extension";
|
/package/{src → legacy}/main.rs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|