mundane-sdk 0.0.3 → 0.1.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/dist/src/index.js +4 -13
- package/dist/src/schema.js +7 -9
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -114,7 +114,7 @@ class TaskState {
|
|
|
114
114
|
this.seen.add(name);
|
|
115
115
|
}
|
|
116
116
|
async loadCache() {
|
|
117
|
-
const rows = await this.db.all("SELECT
|
|
117
|
+
const rows = await this.db.all("SELECT name, kind, encoding, result, status, error FROM mundane_steps ORDER BY id");
|
|
118
118
|
for (const row of rows)
|
|
119
119
|
this.cache.set(row.name, row);
|
|
120
120
|
}
|
|
@@ -132,10 +132,9 @@ class TaskState {
|
|
|
132
132
|
existing.error = null;
|
|
133
133
|
return existing;
|
|
134
134
|
}
|
|
135
|
-
const now = new Date().toISOString();
|
|
136
135
|
await this.db.run("INSERT INTO mundane_steps (name, kind, encoding, result, status, started_at) " +
|
|
137
|
-
"VALUES (?, ?, ?, NULL, 'pending', ?)", [name, kind, encoding,
|
|
138
|
-
const row =
|
|
136
|
+
"VALUES (?, ?, ?, NULL, 'pending', ?)", [name, kind, encoding, new Date().toISOString()]);
|
|
137
|
+
const row = { name, kind, encoding, result: null, status: "pending", error: null };
|
|
139
138
|
this.cache.set(name, row);
|
|
140
139
|
return row;
|
|
141
140
|
}
|
|
@@ -205,15 +204,7 @@ class ContextImpl {
|
|
|
205
204
|
}
|
|
206
205
|
}
|
|
207
206
|
async function run(path, fn) {
|
|
208
|
-
|
|
209
|
-
try {
|
|
210
|
-
lock = await (0, lock_1.acquireLock)(path);
|
|
211
|
-
}
|
|
212
|
-
catch (e) {
|
|
213
|
-
if (e instanceof errors_1.LockedError)
|
|
214
|
-
throw e;
|
|
215
|
-
throw e;
|
|
216
|
-
}
|
|
207
|
+
const lock = await (0, lock_1.acquireLock)(path);
|
|
217
208
|
let db = null;
|
|
218
209
|
try {
|
|
219
210
|
db = await (0, db_1.openDb)(path);
|
package/dist/src/schema.js
CHANGED
|
@@ -50,15 +50,13 @@ async function bootstrap(db) {
|
|
|
50
50
|
await db.exec(exports.CREATE_META);
|
|
51
51
|
await db.exec(exports.CREATE_STEPS);
|
|
52
52
|
await db.exec(exports.CREATE_INDEX);
|
|
53
|
-
|
|
54
|
-
exports.SCHEMA_VERSION,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
new Date().toISOString(),
|
|
61
|
-
]);
|
|
53
|
+
for (const [key, value] of [
|
|
54
|
+
["schema_version", exports.SCHEMA_VERSION],
|
|
55
|
+
["task_id", (0, node_crypto_1.randomUUID)()],
|
|
56
|
+
["created_at", new Date().toISOString()],
|
|
57
|
+
]) {
|
|
58
|
+
await db.run("INSERT OR IGNORE INTO mundane_meta (key, value) VALUES (?, ?)", [key, value]);
|
|
59
|
+
}
|
|
62
60
|
await db.exec("COMMIT");
|
|
63
61
|
}
|
|
64
62
|
catch (e) {
|