@plures/pluresdb 1.5.1 → 1.6.10

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.
Files changed (35) hide show
  1. package/README.md +174 -290
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/local-first/unified-api.d.ts +110 -0
  4. package/dist/local-first/unified-api.d.ts.map +1 -0
  5. package/dist/local-first/unified-api.js +348 -0
  6. package/dist/local-first/unified-api.js.map +1 -0
  7. package/dist/node-index.d.ts +2 -0
  8. package/dist/node-index.d.ts.map +1 -1
  9. package/dist/node-index.js +4 -1
  10. package/dist/node-index.js.map +1 -1
  11. package/dist/util/debug.d.ts +3 -0
  12. package/dist/util/debug.d.ts.map +1 -0
  13. package/dist/util/debug.js +34 -0
  14. package/dist/util/debug.js.map +1 -0
  15. package/examples/browser-demo/README.md +204 -0
  16. package/examples/browser-demo/index.html +466 -0
  17. package/examples/browser-wasm-integration.md +411 -0
  18. package/examples/ipc-demo/README.md +127 -0
  19. package/examples/local-first-usage.ts +138 -0
  20. package/examples/native-ipc-integration.md +526 -0
  21. package/examples/tauri-demo/README.md +240 -0
  22. package/examples/tauri-integration.md +260 -0
  23. package/legacy/http/api-server.ts +131 -0
  24. package/legacy/index.ts +3 -0
  25. package/legacy/local-first/unified-api.ts +449 -0
  26. package/legacy/node-index.ts +4 -0
  27. package/legacy/plugins/README.md +181 -0
  28. package/legacy/plugins/example-embedding-plugin.ts +56 -0
  29. package/legacy/plugins/plugin-system.ts +315 -0
  30. package/legacy/tests/unit/local-first-api.test.ts +65 -0
  31. package/legacy/tests/unit/plugin-system.test.ts +388 -0
  32. package/legacy/util/debug.ts +14 -1
  33. package/package.json +8 -2
  34. package/scripts/release-check.js +34 -0
  35. package/scripts/validate-npm-publish.js +228 -0
@@ -0,0 +1,228 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Pre-publish Validation Script for NPM
5
+ *
6
+ * This script validates that the package is ready to be published to npm.
7
+ * It checks:
8
+ * 1. TypeScript compilation succeeds
9
+ * 2. Deno type checking passes
10
+ * 3. All tests pass
11
+ * 4. Required files exist in dist/
12
+ * 5. package.json is valid
13
+ */
14
+
15
+ const { execSync } = require("node:child_process");
16
+ const fs = require("node:fs");
17
+ const path = require("node:path");
18
+
19
+ const RED = "\x1b[31m";
20
+ const GREEN = "\x1b[32m";
21
+ const YELLOW = "\x1b[33m";
22
+ const RESET = "\x1b[0m";
23
+ const BOLD = "\x1b[1m";
24
+
25
+ // Configuration
26
+ const MAX_PACKAGE_SIZE_MB = 10;
27
+
28
+ function log(message, color = RESET) {
29
+ console.log(`${color}${message}${RESET}`);
30
+ }
31
+
32
+ function error(message) {
33
+ log(`✗ ${message}`, RED);
34
+ }
35
+
36
+ function success(message) {
37
+ log(`✓ ${message}`, GREEN);
38
+ }
39
+
40
+ function info(message) {
41
+ log(`ℹ ${message}`, YELLOW);
42
+ }
43
+
44
+ function title(message) {
45
+ log(`\n${BOLD}${message}${RESET}`);
46
+ }
47
+
48
+ function runCommand(command, description) {
49
+ try {
50
+ info(`Running: ${description}...`);
51
+ execSync(command, { stdio: "inherit", cwd: process.cwd() });
52
+ success(description);
53
+ return true;
54
+ } catch (err) {
55
+ error(`${description} failed`);
56
+ return false;
57
+ }
58
+ }
59
+
60
+ function checkFileExists(filePath, description) {
61
+ const fullPath = path.join(process.cwd(), filePath);
62
+ if (fs.existsSync(fullPath)) {
63
+ success(`${description}: ${filePath}`);
64
+ return true;
65
+ } else {
66
+ error(`${description} missing: ${filePath}`);
67
+ return false;
68
+ }
69
+ }
70
+
71
+ async function main() {
72
+ title("🚀 NPM Publish Validation");
73
+
74
+ let allChecksPassed = true;
75
+
76
+ // 1. Check package.json is valid
77
+ title("📦 Validating package.json...");
78
+ try {
79
+ const packageJson = JSON.parse(
80
+ fs.readFileSync(path.join(process.cwd(), "package.json"), "utf-8"),
81
+ );
82
+ if (!packageJson.name || !packageJson.version) {
83
+ error("package.json missing required fields (name or version)");
84
+ allChecksPassed = false;
85
+ } else {
86
+ success(
87
+ `Package: ${packageJson.name}@${packageJson.version}`,
88
+ );
89
+ }
90
+ } catch (err) {
91
+ error(`Invalid package.json: ${err.message}`);
92
+ allChecksPassed = false;
93
+ }
94
+
95
+ // 2. TypeScript compilation
96
+ title("🔨 Building TypeScript...");
97
+ if (!runCommand("npm run build:lib", "TypeScript compilation")) {
98
+ allChecksPassed = false;
99
+ }
100
+
101
+ // 3. Check required dist files exist
102
+ title("📁 Checking required files...");
103
+ const requiredFiles = [
104
+ "dist/node-index.js",
105
+ "dist/node-index.d.ts",
106
+ "dist/better-sqlite3.js",
107
+ "dist/better-sqlite3.d.ts",
108
+ "dist/cli.js",
109
+ "dist/cli.d.ts",
110
+ "dist/local-first/unified-api.js",
111
+ "dist/local-first/unified-api.d.ts",
112
+ "dist/vscode/extension.js",
113
+ "dist/vscode/extension.d.ts",
114
+ "dist/types/node-types.js",
115
+ "dist/types/node-types.d.ts",
116
+ ];
117
+
118
+ for (const file of requiredFiles) {
119
+ if (!checkFileExists(file, "Required file")) {
120
+ allChecksPassed = false;
121
+ }
122
+ }
123
+
124
+ // 4. Deno type checking
125
+ title("🦕 Deno type checking...");
126
+ const denoPath = process.env.DENO_PATH || "deno";
127
+ const denoCheckFiles = [
128
+ "legacy/local-first/unified-api.ts",
129
+ "legacy/node-index.ts",
130
+ "legacy/better-sqlite3.ts",
131
+ "legacy/cli.ts",
132
+ "legacy/vscode/extension.ts",
133
+ ];
134
+
135
+ // Check if Deno is available
136
+ let denoAvailable = false;
137
+ try {
138
+ execSync(`${denoPath} --version`, { stdio: "pipe" });
139
+ denoAvailable = true;
140
+ } catch (err) {
141
+ info("Deno not available - skipping Deno type checks");
142
+ }
143
+
144
+ if (denoAvailable) {
145
+ let denoChecksFailed = false;
146
+ for (const file of denoCheckFiles) {
147
+ if (
148
+ !runCommand(
149
+ `${denoPath} check --sloppy-imports ${file}`,
150
+ `Deno type check: ${file}`,
151
+ )
152
+ ) {
153
+ error(`Deno type check failed for ${file}`);
154
+ denoChecksFailed = true;
155
+ allChecksPassed = false;
156
+ // Continue checking other files to show all failures
157
+ }
158
+ }
159
+ if (!denoChecksFailed) {
160
+ success("All Deno type checks passed");
161
+ }
162
+ }
163
+
164
+ // 5. Run tests (if Deno is available)
165
+ title("🧪 Running tests...");
166
+ if (denoAvailable) {
167
+ // Set DENO_PATH environment variable so npm test can find deno
168
+ const testEnv = { ...process.env };
169
+ const denoPathEnv = process.env.DENO_PATH;
170
+ if (denoPathEnv && denoPathEnv.includes(path.sep)) {
171
+ // If DENO_PATH was provided as a path, make sure its directory is in PATH for npm test
172
+ const denoBinDir = path.dirname(denoPathEnv);
173
+ // Use path.delimiter for cross-platform compatibility (: on Unix, ; on Windows)
174
+ testEnv.PATH = `${denoBinDir}${path.delimiter}${process.env.PATH}`;
175
+ }
176
+
177
+ try {
178
+ execSync("npm test", { stdio: "inherit", cwd: process.cwd(), env: testEnv });
179
+ success("Deno tests");
180
+ } catch (err) {
181
+ error("Tests failed");
182
+ allChecksPassed = false;
183
+ }
184
+ } else {
185
+ info("Deno tests skipped (Deno not available)");
186
+ }
187
+
188
+ // 6. Check package size
189
+ title("📊 Package size check...");
190
+ try {
191
+ const output = execSync("npm pack --dry-run 2>&1", { encoding: "utf-8" });
192
+ const sizeMatch = output.match(/package size:\s+(\d+\.?\d*)\s*(\w+)/i);
193
+ if (sizeMatch) {
194
+ const size = parseFloat(sizeMatch[1]);
195
+ const unit = sizeMatch[2];
196
+ success(`Package size: ${size} ${unit}`);
197
+
198
+ // Warn if package is larger than configured threshold
199
+ if (unit.toLowerCase() === "mb" && size > MAX_PACKAGE_SIZE_MB) {
200
+ info(
201
+ `Warning: Package size is quite large (${size} ${unit}). Consider excluding unnecessary files.`,
202
+ );
203
+ }
204
+ }
205
+ } catch (err) {
206
+ info("Could not determine package size");
207
+ }
208
+
209
+ // Summary
210
+ title("📋 Validation Summary");
211
+ if (allChecksPassed) {
212
+ success("All critical checks passed! ✨");
213
+ log(
214
+ "\nThe package is ready to be published to npm.",
215
+ GREEN,
216
+ );
217
+ process.exit(0);
218
+ } else {
219
+ error("Some checks failed. Please fix the issues before publishing.");
220
+ process.exit(1);
221
+ }
222
+ }
223
+
224
+ main().catch((err) => {
225
+ error(`Validation failed with error: ${err.message}`);
226
+ console.error(err);
227
+ process.exit(1);
228
+ });