@axiom-lattice/local-stores 1.0.19 → 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 +16 -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/dist/index.mjs
CHANGED
|
@@ -1556,6 +1556,7 @@ CREATE TABLE IF NOT EXISTS lt_workflow_runs (
|
|
|
1556
1556
|
);
|
|
1557
1557
|
CREATE INDEX IF NOT EXISTS idx_lt_wr_thread ON lt_workflow_runs(tenant_id, thread_id);
|
|
1558
1558
|
CREATE INDEX IF NOT EXISTS idx_lt_wr_assistant ON lt_workflow_runs(tenant_id, assistant_id);
|
|
1559
|
+
CREATE INDEX IF NOT EXISTS idx_lt_wr_tenant_status ON lt_workflow_runs(tenant_id, status, updated_at DESC);
|
|
1559
1560
|
|
|
1560
1561
|
CREATE TABLE IF NOT EXISTS lt_workflow_steps (
|
|
1561
1562
|
id TEXT NOT NULL,
|
|
@@ -1681,6 +1682,36 @@ var LocalWorkflowTrackingStore = class {
|
|
|
1681
1682
|
).all(tenantId);
|
|
1682
1683
|
return rows.map(mapRowToRun);
|
|
1683
1684
|
}
|
|
1685
|
+
async queryWorkflowRuns(tenantId, options = {}) {
|
|
1686
|
+
const conditions = ["tenant_id = ?"];
|
|
1687
|
+
const whereParams = [tenantId];
|
|
1688
|
+
if (options.status) {
|
|
1689
|
+
conditions.push("status = ?");
|
|
1690
|
+
whereParams.push(options.status);
|
|
1691
|
+
}
|
|
1692
|
+
if (options.assistantId) {
|
|
1693
|
+
conditions.push("assistant_id = ?");
|
|
1694
|
+
whereParams.push(options.assistantId);
|
|
1695
|
+
}
|
|
1696
|
+
const where = conditions.join(" AND ");
|
|
1697
|
+
const countRow = this.db.prepare(
|
|
1698
|
+
`SELECT COUNT(*) AS count FROM lt_workflow_runs WHERE ${where}`
|
|
1699
|
+
).get(...whereParams);
|
|
1700
|
+
const selectParams = [...whereParams];
|
|
1701
|
+
let sql = `SELECT * FROM lt_workflow_runs WHERE ${where} ORDER BY updated_at DESC, id DESC`;
|
|
1702
|
+
if (options.limit !== void 0) {
|
|
1703
|
+
sql += " LIMIT ?";
|
|
1704
|
+
selectParams.push(options.limit);
|
|
1705
|
+
} else if (options.offset !== void 0) {
|
|
1706
|
+
sql += " LIMIT -1";
|
|
1707
|
+
}
|
|
1708
|
+
if (options.offset !== void 0) {
|
|
1709
|
+
sql += " OFFSET ?";
|
|
1710
|
+
selectParams.push(options.offset);
|
|
1711
|
+
}
|
|
1712
|
+
const rows = this.db.prepare(sql).all(...selectParams);
|
|
1713
|
+
return { records: rows.map(mapRowToRun), total: countRow.count };
|
|
1714
|
+
}
|
|
1684
1715
|
async createRunStep(request) {
|
|
1685
1716
|
const now = nowISO();
|
|
1686
1717
|
const id = `step_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|