@fadhilp/stateql 0.5.0 → 0.5.2
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 +2 -2
- package/dist/src/adapters.js +8 -5
- package/dist/src/stateql.js +0 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ StateQL is built around durable handles:
|
|
|
12
12
|
rerunning the original SQL.
|
|
13
13
|
3. Use operation, plan, and transaction handles to inspect and control writes.
|
|
14
14
|
|
|
15
|
-
Requires Node.js 22.
|
|
15
|
+
Requires Node.js 22.16 or newer for the required `node:sqlite` APIs.
|
|
16
16
|
|
|
17
17
|
## Quick start
|
|
18
18
|
|
|
@@ -454,4 +454,4 @@ and keeping values out of their own logs and model-visible data.
|
|
|
454
454
|
For writes, credential resolution happens after StateQL atomically reserves the
|
|
455
455
|
operation for duplicate protection. A resolution failure keeps a non-executed
|
|
456
456
|
`failed` audit record, does not consume the idempotency key, and permits a safe
|
|
457
|
-
retry.
|
|
457
|
+
retry.
|
package/dist/src/adapters.js
CHANGED
|
@@ -53,6 +53,7 @@ class SQLiteAdapter {
|
|
|
53
53
|
pending = new Map();
|
|
54
54
|
nextId = 1;
|
|
55
55
|
closed = false;
|
|
56
|
+
closePromise;
|
|
56
57
|
constructor(source, readOnly, context) {
|
|
57
58
|
this.source = source;
|
|
58
59
|
this.readOnly = readOnly;
|
|
@@ -100,12 +101,12 @@ class SQLiteAdapter {
|
|
|
100
101
|
return this.call("inspect", [kind, table], false, false);
|
|
101
102
|
}
|
|
102
103
|
async close() {
|
|
103
|
-
if (this.
|
|
104
|
-
return;
|
|
104
|
+
if (this.closePromise)
|
|
105
|
+
return this.closePromise;
|
|
105
106
|
this.closed = true;
|
|
106
107
|
if (this.child.exitCode !== null || this.child.signalCode !== null)
|
|
107
108
|
return;
|
|
108
|
-
|
|
109
|
+
this.closePromise = new Promise((resolve) => {
|
|
109
110
|
const done = () => {
|
|
110
111
|
clearTimeout(timer);
|
|
111
112
|
resolve();
|
|
@@ -117,7 +118,6 @@ class SQLiteAdapter {
|
|
|
117
118
|
catch {
|
|
118
119
|
// Process already exited.
|
|
119
120
|
}
|
|
120
|
-
resolve();
|
|
121
121
|
}, 1_000);
|
|
122
122
|
timer.unref();
|
|
123
123
|
this.child.once("exit", done);
|
|
@@ -133,6 +133,7 @@ class SQLiteAdapter {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
});
|
|
136
|
+
return this.closePromise;
|
|
136
137
|
}
|
|
137
138
|
async call(operation, args, outcomeUnknown, batch) {
|
|
138
139
|
throwIfStopped(this.context, false);
|
|
@@ -148,7 +149,9 @@ class SQLiteAdapter {
|
|
|
148
149
|
readOnly: this.readOnly,
|
|
149
150
|
operation,
|
|
150
151
|
args,
|
|
151
|
-
|
|
152
|
+
// Let the client deadline terminate the worker before SQLite's
|
|
153
|
+
// lock timeout races it and reports a known, non-executed failure.
|
|
154
|
+
busyTimeoutMs: Math.min(5_000, remainingMilliseconds(this.context) + 250),
|
|
152
155
|
}, (error) => {
|
|
153
156
|
if (error)
|
|
154
157
|
reject(error);
|
package/dist/src/stateql.js
CHANGED
|
@@ -1800,7 +1800,6 @@ async function resolveCredentialBeforeDeadline(resolver, request, context) {
|
|
|
1800
1800
|
};
|
|
1801
1801
|
const abort = () => finish(() => reject(new CredentialResolutionError("cancelled")));
|
|
1802
1802
|
const timer = setTimeout(() => finish(() => reject(new CredentialResolutionError("timeout"))), remaining);
|
|
1803
|
-
timer.unref?.();
|
|
1804
1803
|
context.signal?.addEventListener("abort", abort, { once: true });
|
|
1805
1804
|
Promise.resolve()
|
|
1806
1805
|
.then(() => resolver(request))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fadhilp/stateql",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Stateful, agent-oriented database CLI for safe result reuse",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "tsc -p tsconfig.json",
|
|
28
28
|
"test": "npm run build && node --test dist/test/cli.test.js dist/test/credential.test.js dist/test/mysql.test.js dist/test/postgres.test.js dist/test/query.test.js dist/test/sqlite.test.js dist/test/store.test.js dist/test/terminal.test.js dist/test/transaction.test.js dist/test/write.test.js",
|
|
29
|
+
"release": "npm version",
|
|
30
|
+
"version": "npm install",
|
|
29
31
|
"prepack": "npm test"
|
|
30
32
|
},
|
|
31
33
|
"keywords": [
|
|
@@ -39,7 +41,7 @@
|
|
|
39
41
|
],
|
|
40
42
|
"license": "MIT",
|
|
41
43
|
"engines": {
|
|
42
|
-
"node": ">=22.
|
|
44
|
+
"node": ">=22.16"
|
|
43
45
|
},
|
|
44
46
|
"dependencies": {
|
|
45
47
|
"mysql2": "^3.23.1",
|