| 188 | return record; |
| 189 | }, |
| 190 | async update(id, input, options: RepositoryOptions = {}) { |
| 191 | const existing = repositoryStore.get(id); |
| 192 | if (!existing) { |
| 193 | throw new Error(`Workflow ${id} not found`); |
| 194 | } |
| 195 | if (options.organizationId && existing.organizationId !== options.organizationId) { |
| 196 | throw new Error('Forbidden'); |
| 197 | } |
| 198 | const updated: WorkflowRecord = { |
| 199 | ...existing, |
| 200 | name: input.name, |
| 201 | description: input.description ?? null, |
| 202 | graph: input, |
| 203 | updatedAt: new Date(), |
| 204 | compiledDefinition: existing.compiledDefinition, |
| 205 | }; |
| 206 | repositoryStore.set(id, updated); |
| 207 | return updated; |
| 208 | }, |
| 209 | async findById(id, options: RepositoryOptions = {}) { |
| 210 | const record = repositoryStore.get(id); |
| 211 | if (!record) return undefined; |