// @bun
var{defineProperty:D,getOwnPropertyNames:F,getOwnPropertyDescriptor:H}=Object,K=Object.prototype.hasOwnProperty;function L(b){return this[b]}var T=(b)=>{var j=(E??=new WeakMap).get(b),z;if(j)return j;if(j=D({},"__esModule",{value:!0}),b&&typeof b==="object"||typeof b==="function"){for(var q of F(b))if(!K.call(j,q))D(j,q,{get:L.bind(b,q),enumerable:!(z=H(b,q))||z.enumerable})}return E.set(b,j),j},E;var M=(b)=>b;function Q(b,j){this[b]=M.bind(null,j)}var U=(b,j)=>{for(var z in j)D(b,z,{get:j[z],enumerable:!0,configurable:!0,set:Q.bind(j,z)})};var V=(b,j)=>()=>(b&&(j=b(b=0)),j);class R{prisma;constructor(b){this.prisma=b}async create(b){await this.prisma.workflowState.create({data:{id:b.workflowId,name:b.workflowName,version:b.workflowVersion,status:b.status,currentStep:b.currentStep,data:b.data,history:b.history,retryCounts:b.retryCounts??{},createdAt:b.createdAt,updatedAt:b.updatedAt}})}async get(b){let j=await this.prisma.workflowState.findUnique({where:{id:b}});if(!j)return;return{workflowId:j.id,workflowName:j.name,workflowVersion:j.version,currentStep:j.currentStep,data:j.data,history:j.history,retryCounts:j.retryCounts,status:j.status,createdAt:j.createdAt,updatedAt:j.updatedAt}}async update(b,j){let z=await this.get(b);if(!z)throw Error(`Workflow ${b} not found`);let q=j(z),B=await this.prisma.workflowState.update({where:{id:b},data:{status:q.status,currentStep:q.currentStep,data:q.data,history:q.history,retryCounts:q.retryCounts,updatedAt:q.updatedAt}});return{workflowId:B.id,workflowName:B.name,workflowVersion:B.version,currentStep:B.currentStep,data:B.data,history:B.history,retryCounts:B.retryCounts,status:B.status,createdAt:B.createdAt,updatedAt:B.updatedAt}}async list(b){let j={};if(b?.status)j.status=b.status;return(await this.prisma.workflowState.findMany({where:j})).map((q)=>({workflowId:q.id,workflowName:q.name,workflowVersion:q.version,currentStep:q.currentStep,data:q.data,history:q.history,retryCounts:q.retryCounts,status:q.status,createdAt:q.createdAt,updatedAt:q.updatedAt}))}}export{R as PrismaStateStore};
