@mastra/libsql 1.14.1 → 1.14.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/dist/index.js CHANGED
@@ -12041,19 +12041,22 @@ var WorkflowsLibSQL = class extends WorkflowsStorage {
12041
12041
  updatedAt
12042
12042
  }) {
12043
12043
  const now = /* @__PURE__ */ new Date();
12044
- const data = {
12045
- workflow_name: workflowName,
12046
- run_id: runId,
12047
- resourceId,
12048
- snapshot,
12049
- createdAt: createdAt ?? now,
12050
- updatedAt: updatedAt ?? now
12051
- };
12052
- this.logger.debug("Persisting workflow snapshot", { workflowName, runId, data });
12053
- await this.#db.insert({
12054
- tableName: TABLE_WORKFLOW_SNAPSHOT,
12055
- record: data
12056
- });
12044
+ const createdAtValue = (createdAt ?? now).toISOString();
12045
+ const updatedAtValue = (updatedAt ?? now).toISOString();
12046
+ this.logger.debug("Persisting workflow snapshot", { workflowName, runId });
12047
+ await this.executeWithRetry(
12048
+ () => withClientWriteLock(
12049
+ this.#client,
12050
+ () => this.#client.execute({
12051
+ sql: `INSERT INTO ${TABLE_WORKFLOW_SNAPSHOT} (workflow_name, run_id, resourceId, snapshot, createdAt, updatedAt)
12052
+ VALUES (?, ?, ?, jsonb(?), ?, ?)
12053
+ ON CONFLICT(workflow_name, run_id)
12054
+ DO UPDATE SET resourceId = excluded.resourceId, snapshot = excluded.snapshot, updatedAt = excluded.updatedAt`,
12055
+ args: [workflowName, runId, resourceId ?? null, safeStringify(snapshot), createdAtValue, updatedAtValue]
12056
+ })
12057
+ ),
12058
+ "persistWorkflowSnapshot"
12059
+ );
12057
12060
  }
12058
12061
  async loadWorkflowSnapshot({
12059
12062
  workflowName,