@feltdb/core 0.6.9 → 0.6.11
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/cli/application-lifecycle.js +112 -0
- package/dist/cli/application.js +10 -0
- package/dist/cli/commands.js +407 -119
- package/dist/cli/development-session.js +54 -0
- package/dist/cli/index.js +1 -1
- package/dist/cli/workspace-integration.js +146 -20
- package/dist/collection.d.ts +110 -2
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +228 -3
- package/dist/create/cli.js +4 -2
- package/dist/create/create.js +42 -6
- package/dist/create/frameworks.js +18 -0
- package/dist/create/package-versions.js +1 -1
- package/dist/create/server-source/crates/feltdb/src/bin/feltdb_node.rs +408 -178
- package/dist/create/server-source/crates/feltdb/src/lib.rs +49 -5
- package/dist/create/server-source/crates/feltdb/src/multi_operation_transaction.rs +659 -0
- package/dist/create/server-source/crates/feltdb/src/p1_application_atomicity.rs +285 -0
- package/dist/create/server-source/crates/feltdb/src/p1_atomicity_acceptance.rs +582 -0
- package/dist/create/server-source/crates/feltdb-server/src/main.rs +141 -0
- package/dist/create/workspace-initialization.js +4 -5
- package/dist/db.d.ts +63 -1
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +145 -4
- package/dist/development-runtime-bridge.d.ts +60 -0
- package/dist/development-runtime-bridge.d.ts.map +1 -0
- package/dist/development-runtime-bridge.js +171 -0
- package/dist/embedded-transaction.d.ts +77 -0
- package/dist/embedded-transaction.d.ts.map +1 -0
- package/dist/embedded-transaction.js +102 -0
- package/dist/feltdb.d.ts +49 -1
- package/dist/feltdb.d.ts.map +1 -1
- package/dist/file-db.d.ts +33 -0
- package/dist/file-db.d.ts.map +1 -1
- package/dist/file-db.js +128 -4
- package/dist/freshness.d.ts +119 -0
- package/dist/freshness.d.ts.map +1 -0
- package/dist/freshness.js +115 -0
- package/dist/http-db.d.ts +48 -0
- package/dist/http-db.d.ts.map +1 -1
- package/dist/http-db.js +77 -1
- package/dist/index-backend.d.ts +8 -0
- package/dist/index-backend.d.ts.map +1 -1
- package/dist/index-backend.js +13 -0
- package/dist/index-core.d.ts +80 -0
- package/dist/index-core.d.ts.map +1 -0
- package/dist/index-core.js +74 -0
- package/dist/index-manager.d.ts +11 -0
- package/dist/index-manager.d.ts.map +1 -1
- package/dist/index-manager.js +30 -13
- package/dist/index-types.d.ts +17 -0
- package/dist/index-types.d.ts.map +1 -1
- package/dist/index.browser.d.ts +14 -0
- package/dist/index.browser.d.ts.map +1 -0
- package/dist/index.browser.js +13 -0
- package/dist/index.d.ts +8 -59
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -54
- package/dist/indexeddb-db.d.ts +32 -0
- package/dist/indexeddb-db.d.ts.map +1 -1
- package/dist/indexeddb-db.js +151 -1
- package/dist/memory-db.d.ts +26 -0
- package/dist/memory-db.d.ts.map +1 -1
- package/dist/memory-db.js +86 -0
- package/dist/runtime-registry.d.ts +32 -0
- package/dist/runtime-registry.d.ts.map +1 -0
- package/dist/runtime-registry.js +38 -0
- package/dist/studio/app.d.ts +2 -1
- package/dist/studio/app.d.ts.map +1 -1
- package/dist/studio/components/StateExplorer.d.ts +2 -1
- package/dist/studio/components/StateExplorer.d.ts.map +1 -1
- package/dist/studio/components/index.js +1 -1
- package/dist/studio/{components-9kDSWiGL.js → components-C5p2TfIU.js} +25 -14
- package/dist/studio/index.js +234 -160
- package/dist/studio-app/assets/{feltdb_wasm-B4wq4mqp.js → feltdb_wasm-CJv3wHzi.js} +1 -1
- package/dist/studio-app/assets/feltdb_wasm_bg-C8TG8r2n.wasm +0 -0
- package/dist/studio-app/assets/index-DospFFYE.js +28 -0
- package/dist/studio-app/index.html +1 -1
- package/dist/transaction.d.ts +98 -0
- package/dist/transaction.d.ts.map +1 -0
- package/dist/transaction.js +86 -0
- package/dist/wasm/feltdb_wasm_bg.wasm +0 -0
- package/dist/workspace/browser.d.ts +22 -0
- package/dist/workspace/browser.d.ts.map +1 -0
- package/dist/workspace/browser.js +17 -0
- package/dist/workspace/development-node.d.ts +16 -0
- package/dist/workspace/development-node.d.ts.map +1 -1
- package/dist/workspace/development-node.js +85 -1
- package/dist/workspace/git-identity.d.ts +35 -0
- package/dist/workspace/git-identity.d.ts.map +1 -0
- package/dist/workspace/git-identity.js +81 -0
- package/dist/workspace/index.d.ts +12 -2
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +7 -1
- package/dist/workspace/investigation-analysis.d.ts +47 -0
- package/dist/workspace/investigation-analysis.d.ts.map +1 -0
- package/dist/workspace/investigation-analysis.js +181 -0
- package/dist/workspace/investigation-lifecycle-manager.d.ts +88 -0
- package/dist/workspace/investigation-lifecycle-manager.d.ts.map +1 -0
- package/dist/workspace/investigation-lifecycle-manager.js +259 -0
- package/dist/workspace/investigation-supervisor.d.ts +100 -0
- package/dist/workspace/investigation-supervisor.d.ts.map +1 -0
- package/dist/workspace/investigation-supervisor.js +238 -0
- package/dist/workspace/runtime-investigation.d.ts +5 -1
- package/dist/workspace/runtime-investigation.d.ts.map +1 -1
- package/dist/workspace/runtime-investigation.js +50 -21
- package/dist/workspace/runtime-observation.d.ts +82 -0
- package/dist/workspace/runtime-observation.d.ts.map +1 -0
- package/dist/workspace/runtime-observation.js +170 -0
- package/dist/workspace/runtime-observer.d.ts +57 -0
- package/dist/workspace/runtime-observer.d.ts.map +1 -0
- package/dist/workspace/runtime-observer.js +272 -0
- package/dist/workspace/workspace-connection.d.ts.map +1 -1
- package/dist/workspace/workspace-connection.js +14 -5
- package/dist/workspace/workspace-identity.d.ts +1 -1
- package/dist/workspace/workspace-identity.d.ts.map +1 -1
- package/dist/workspace/workspace-identity.js +4 -4
- package/dist/workspace/workspace-types.d.ts +208 -0
- package/dist/workspace/workspace-types.d.ts.map +1 -1
- package/package.json +12 -4
- package/dist/create/server-source/crates/feltdb/src/phase_1c_three_node.rs +0 -523
- package/dist/studio-app/assets/feltdb_wasm_bg-Ceyi7l21.wasm +0 -0
- package/dist/studio-app/assets/index-BF45M757.js +0 -28
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { spawn } from 'child_process';
|
|
3
|
+
import { applicationIsRunning } from './application.js';
|
|
4
|
+
export function resolveApplicationLifecycle(config) {
|
|
5
|
+
const lifecycle = config.application?.lifecycle;
|
|
6
|
+
if (lifecycle === undefined)
|
|
7
|
+
return 'attached';
|
|
8
|
+
if (lifecycle !== 'managed' && lifecycle !== 'attached') {
|
|
9
|
+
throw new Error(`Invalid application.lifecycle "${lifecycle}"; expected managed or attached`);
|
|
10
|
+
}
|
|
11
|
+
return lifecycle;
|
|
12
|
+
}
|
|
13
|
+
function commandTokens(source) {
|
|
14
|
+
const tokens = [];
|
|
15
|
+
let token = '';
|
|
16
|
+
let quote = '';
|
|
17
|
+
for (let index = 0; index < source.length; index += 1) {
|
|
18
|
+
const character = source[index];
|
|
19
|
+
if (quote) {
|
|
20
|
+
if (character === quote)
|
|
21
|
+
quote = '';
|
|
22
|
+
else if (character === '\\' && quote === '"' && index + 1 < source.length)
|
|
23
|
+
token += source[++index];
|
|
24
|
+
else
|
|
25
|
+
token += character;
|
|
26
|
+
}
|
|
27
|
+
else if (character === '"' || character === "'")
|
|
28
|
+
quote = character;
|
|
29
|
+
else if (/\s/.test(character)) {
|
|
30
|
+
if (token) {
|
|
31
|
+
tokens.push(token);
|
|
32
|
+
token = '';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else
|
|
36
|
+
token += character;
|
|
37
|
+
}
|
|
38
|
+
if (quote)
|
|
39
|
+
throw new Error(`Cannot run managed application command with an unclosed quote: ${source}`);
|
|
40
|
+
if (token)
|
|
41
|
+
tokens.push(token);
|
|
42
|
+
return tokens;
|
|
43
|
+
}
|
|
44
|
+
export function resolveManagedApplicationCommand(project) {
|
|
45
|
+
const source = project.devScript?.trim();
|
|
46
|
+
if (!source)
|
|
47
|
+
throw new Error('Managed application lifecycle requires package.json.scripts.dev');
|
|
48
|
+
const tokens = commandTokens(source);
|
|
49
|
+
const environment = {};
|
|
50
|
+
while (tokens[0] && /^[A-Za-z_][A-Za-z0-9_]*=/.test(tokens[0])) {
|
|
51
|
+
const assignment = tokens.shift();
|
|
52
|
+
const separator = assignment.indexOf('=');
|
|
53
|
+
environment[assignment.slice(0, separator)] = assignment.slice(separator + 1);
|
|
54
|
+
}
|
|
55
|
+
const executable = tokens.shift();
|
|
56
|
+
if (!executable)
|
|
57
|
+
throw new Error(`Managed application command is empty: ${source}`);
|
|
58
|
+
if (executable === 'feltdb' || (executable === 'npm' && tokens[0] === 'run')) {
|
|
59
|
+
throw new Error(`Refusing recursive managed application command: ${source}`);
|
|
60
|
+
}
|
|
61
|
+
if (/[|&;<>`]/.test(source)) {
|
|
62
|
+
throw new Error(`Managed application command must be directly executable without shell operators: ${source}`);
|
|
63
|
+
}
|
|
64
|
+
return { source, executable, args: tokens, environment };
|
|
65
|
+
}
|
|
66
|
+
export function startManagedApplication(options) {
|
|
67
|
+
const command = resolveManagedApplicationCommand(options.project);
|
|
68
|
+
const localBin = path.join(options.projectDir, 'node_modules', '.bin');
|
|
69
|
+
const inherited = options.environment ?? process.env;
|
|
70
|
+
const child = spawn(command.executable, command.args, {
|
|
71
|
+
cwd: options.projectDir,
|
|
72
|
+
stdio: 'inherit',
|
|
73
|
+
shell: false,
|
|
74
|
+
env: {
|
|
75
|
+
...inherited,
|
|
76
|
+
...command.environment,
|
|
77
|
+
PATH: `${localBin}${path.delimiter}${inherited.PATH || ''}`,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
const exited = new Promise((resolve, reject) => {
|
|
81
|
+
child.once('error', reject);
|
|
82
|
+
child.once('exit', (code, signal) => resolve({ code, signal }));
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
command: command.source,
|
|
86
|
+
child,
|
|
87
|
+
exited,
|
|
88
|
+
async stop() {
|
|
89
|
+
if (child.exitCode !== null || child.signalCode !== null)
|
|
90
|
+
return;
|
|
91
|
+
child.kill('SIGTERM');
|
|
92
|
+
await Promise.race([exited.catch(() => undefined), new Promise(resolve => setTimeout(resolve, 2000))]);
|
|
93
|
+
if (child.exitCode === null && child.signalCode === null)
|
|
94
|
+
child.kill('SIGKILL');
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export async function waitForManagedApplication(options) {
|
|
99
|
+
const startedAt = Date.now();
|
|
100
|
+
while (Date.now() - startedAt < options.timeoutMs) {
|
|
101
|
+
if (await applicationIsRunning(options.expectedUrl, Math.min(500, options.timeoutMs)))
|
|
102
|
+
return;
|
|
103
|
+
const exit = await Promise.race([
|
|
104
|
+
options.application.exited,
|
|
105
|
+
new Promise(resolve => setTimeout(() => resolve(null), 100)),
|
|
106
|
+
]);
|
|
107
|
+
if (exit) {
|
|
108
|
+
throw new Error(`Managed application exited before readiness (command: ${options.application.command}; expected URL: ${options.expectedUrl}; workspace: ${options.workspaceId}; project: ${options.projectDir}; exit: ${exit.code ?? exit.signal})`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
throw new Error(`Managed application readiness timed out after ${options.timeoutMs}ms (command: ${options.application.command}; expected URL: ${options.expectedUrl}; workspace: ${options.workspaceId}; project: ${options.projectDir})`);
|
|
112
|
+
}
|
package/dist/cli/application.js
CHANGED
|
@@ -44,12 +44,22 @@ export function detectApplication(root) {
|
|
|
44
44
|
const dependencies = { ...manifest.dependencies, ...manifest.devDependencies };
|
|
45
45
|
const framework = FRAMEWORKS.find(candidate => candidate.packages.some(name => name in dependencies) || (script ? candidate.pattern.test(script) : false));
|
|
46
46
|
const feltConfigFile = path.join(root, 'feltdb.config.json');
|
|
47
|
+
const flowFile = path.join(root, 'feltdb.flow');
|
|
47
48
|
const feltConfig = fs.existsSync(feltConfigFile) ? readJson(feltConfigFile, 'Cannot inspect application: malformed feltdb.config.json') : {};
|
|
49
|
+
const feltDBSignals = [];
|
|
50
|
+
if ('@feltdb/core' in dependencies)
|
|
51
|
+
feltDBSignals.push('dependency');
|
|
52
|
+
if (fs.existsSync(feltConfigFile))
|
|
53
|
+
feltDBSignals.push('config');
|
|
54
|
+
if (fs.existsSync(flowFile))
|
|
55
|
+
feltDBSignals.push('flow');
|
|
48
56
|
const configuredUrl = typeof feltConfig.appUrl === 'string' ? feltConfig.appUrl
|
|
49
57
|
: typeof feltConfig.applicationUrl === 'string' ? feltConfig.applicationUrl : undefined;
|
|
50
58
|
return {
|
|
51
59
|
packageManager: packageManagerAt(root, typeof manifest.packageManager === 'string' ? manifest.packageManager : undefined),
|
|
52
60
|
framework: framework?.name || (script ? 'Custom' : 'Unknown'),
|
|
61
|
+
feltDBEnabled: feltDBSignals.length > 0,
|
|
62
|
+
feltDBSignals,
|
|
53
63
|
devScript: script,
|
|
54
64
|
configuredPort: scriptPort(script),
|
|
55
65
|
configuredUrl,
|