@voltagent/libsql 1.0.13 → 1.0.14

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/index.d.mts CHANGED
@@ -160,6 +160,17 @@ declare class LibSQLMemoryAdapter implements StorageAdapter {
160
160
  * Get workflow state by execution ID
161
161
  */
162
162
  getWorkflowState(executionId: string): Promise<WorkflowStateEntry | null>;
163
+ /**
164
+ * Query workflow states with optional filters
165
+ */
166
+ queryWorkflowRuns(query: {
167
+ workflowId?: string;
168
+ status?: WorkflowStateEntry["status"];
169
+ from?: Date;
170
+ to?: Date;
171
+ limit?: number;
172
+ offset?: number;
173
+ }): Promise<WorkflowStateEntry[]>;
163
174
  /**
164
175
  * Set workflow state
165
176
  */
package/dist/index.d.ts CHANGED
@@ -160,6 +160,17 @@ declare class LibSQLMemoryAdapter implements StorageAdapter {
160
160
  * Get workflow state by execution ID
161
161
  */
162
162
  getWorkflowState(executionId: string): Promise<WorkflowStateEntry | null>;
163
+ /**
164
+ * Query workflow states with optional filters
165
+ */
166
+ queryWorkflowRuns(query: {
167
+ workflowId?: string;
168
+ status?: WorkflowStateEntry["status"];
169
+ from?: Date;
170
+ to?: Date;
171
+ limit?: number;
172
+ offset?: number;
173
+ }): Promise<WorkflowStateEntry[]>;
163
174
  /**
164
175
  * Set workflow state
165
176
  */
package/dist/index.js CHANGED
@@ -953,6 +953,63 @@ var LibSQLMemoryAdapter = class {
953
953
  updatedAt: new Date(row.updated_at)
954
954
  };
955
955
  }
956
+ /**
957
+ * Query workflow states with optional filters
958
+ */
959
+ async queryWorkflowRuns(query) {
960
+ await this.initialize();
961
+ const workflowStatesTable = `${this.tablePrefix}_workflow_states`;
962
+ const conditions = [];
963
+ const args = [];
964
+ if (query.workflowId) {
965
+ conditions.push("workflow_id = ?");
966
+ args.push(query.workflowId);
967
+ }
968
+ if (query.status) {
969
+ conditions.push("status = ?");
970
+ args.push(query.status);
971
+ }
972
+ if (query.from) {
973
+ conditions.push("created_at >= ?");
974
+ args.push(query.from.toISOString());
975
+ }
976
+ if (query.to) {
977
+ conditions.push("created_at <= ?");
978
+ args.push(query.to.toISOString());
979
+ }
980
+ let sql = `SELECT * FROM ${workflowStatesTable}`;
981
+ if (conditions.length > 0) {
982
+ sql += ` WHERE ${conditions.join(" AND ")}`;
983
+ }
984
+ sql += " ORDER BY created_at DESC";
985
+ if (query.limit !== void 0) {
986
+ sql += " LIMIT ?";
987
+ args.push(query.limit);
988
+ }
989
+ if (query.offset !== void 0) {
990
+ sql += " OFFSET ?";
991
+ args.push(query.offset);
992
+ }
993
+ const result = await this.client.execute({
994
+ sql,
995
+ args
996
+ });
997
+ return result.rows.map((row) => ({
998
+ id: row.id,
999
+ workflowId: row.workflow_id,
1000
+ workflowName: row.workflow_name,
1001
+ status: row.status,
1002
+ suspension: row.suspension ? JSON.parse(row.suspension) : void 0,
1003
+ events: row.events ? JSON.parse(row.events) : void 0,
1004
+ output: row.output ? JSON.parse(row.output) : void 0,
1005
+ cancellation: row.cancellation ? JSON.parse(row.cancellation) : void 0,
1006
+ userId: row.user_id,
1007
+ conversationId: row.conversation_id,
1008
+ metadata: row.metadata ? JSON.parse(row.metadata) : void 0,
1009
+ createdAt: new Date(row.created_at),
1010
+ updatedAt: new Date(row.updated_at)
1011
+ }));
1012
+ }
956
1013
  /**
957
1014
  * Set workflow state
958
1015
  */