@axiom-lattice/local-stores 1.0.20 → 1.0.21
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +9 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/stores/LocalWorkflowTrackingStore.ts +31 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axiom-lattice/local-stores",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"description": "Local SQLite-based stores for Axiom Lattice framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@types/sql.js": "^1.4.11",
|
|
26
26
|
"sql.js": "^1.14.1",
|
|
27
27
|
"uuid": "^14.0.1",
|
|
28
|
-
"@axiom-lattice/core": "2.1.
|
|
29
|
-
"@axiom-lattice/protocols": "2.1.
|
|
28
|
+
"@axiom-lattice/core": "2.1.99",
|
|
29
|
+
"@axiom-lattice/protocols": "2.1.51"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^20.11.24",
|
|
@@ -13,6 +13,8 @@ import type {
|
|
|
13
13
|
UpdateRunStepRequest,
|
|
14
14
|
StepType,
|
|
15
15
|
WorkflowRunStatus,
|
|
16
|
+
QueryWorkflowRunsOptions,
|
|
17
|
+
QueryWorkflowRunsResult,
|
|
16
18
|
} from "@axiom-lattice/protocols";
|
|
17
19
|
import { ensureTable, nowISO, parseISO } from "../database";
|
|
18
20
|
|
|
@@ -35,6 +37,7 @@ CREATE TABLE IF NOT EXISTS lt_workflow_runs (
|
|
|
35
37
|
);
|
|
36
38
|
CREATE INDEX IF NOT EXISTS idx_lt_wr_thread ON lt_workflow_runs(tenant_id, thread_id);
|
|
37
39
|
CREATE INDEX IF NOT EXISTS idx_lt_wr_assistant ON lt_workflow_runs(tenant_id, assistant_id);
|
|
40
|
+
CREATE INDEX IF NOT EXISTS idx_lt_wr_tenant_status ON lt_workflow_runs(tenant_id, status, updated_at DESC);
|
|
38
41
|
|
|
39
42
|
CREATE TABLE IF NOT EXISTS lt_workflow_steps (
|
|
40
43
|
id TEXT NOT NULL,
|
|
@@ -186,6 +189,34 @@ export class LocalWorkflowTrackingStore implements WorkflowTrackingStore {
|
|
|
186
189
|
return rows.map(mapRowToRun);
|
|
187
190
|
}
|
|
188
191
|
|
|
192
|
+
async queryWorkflowRuns(tenantId: string, options: QueryWorkflowRunsOptions = {}): Promise<QueryWorkflowRunsResult> {
|
|
193
|
+
const conditions: string[] = ["tenant_id = ?"];
|
|
194
|
+
const whereParams: unknown[] = [tenantId];
|
|
195
|
+
if (options.status) { conditions.push("status = ?"); whereParams.push(options.status); }
|
|
196
|
+
if (options.assistantId) { conditions.push("assistant_id = ?"); whereParams.push(options.assistantId); }
|
|
197
|
+
const where = conditions.join(" AND ");
|
|
198
|
+
|
|
199
|
+
const countRow = this.db.prepare(
|
|
200
|
+
`SELECT COUNT(*) AS count FROM lt_workflow_runs WHERE ${where}`,
|
|
201
|
+
).get(...whereParams) as { count: number };
|
|
202
|
+
|
|
203
|
+
const selectParams: unknown[] = [...whereParams];
|
|
204
|
+
let sql = `SELECT * FROM lt_workflow_runs WHERE ${where} ORDER BY updated_at DESC, id DESC`;
|
|
205
|
+
if (options.limit !== undefined) {
|
|
206
|
+
sql += " LIMIT ?";
|
|
207
|
+
selectParams.push(options.limit);
|
|
208
|
+
} else if (options.offset !== undefined) {
|
|
209
|
+
sql += " LIMIT -1"; // SQLite requires LIMIT before OFFSET
|
|
210
|
+
}
|
|
211
|
+
if (options.offset !== undefined) {
|
|
212
|
+
sql += " OFFSET ?";
|
|
213
|
+
selectParams.push(options.offset);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const rows = this.db.prepare(sql).all(...selectParams) as unknown as RunRow[];
|
|
217
|
+
return { records: rows.map(mapRowToRun), total: countRow.count };
|
|
218
|
+
}
|
|
219
|
+
|
|
189
220
|
async createRunStep(request: CreateRunStepRequest): Promise<RunStep> {
|
|
190
221
|
const now = nowISO();
|
|
191
222
|
const id = `step_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|