(
input: UpdateToolPolicyInput,
)
| 3443 | }); |
| 3444 | |
| 3445 | const policiesUpdate = ( |
| 3446 | input: UpdateToolPolicyInput, |
| 3447 | ): Effect.Effect<ToolPolicy, StorageFailure> => |
| 3448 | Effect.gen(function* () { |
| 3449 | if (input.pattern !== undefined && !isValidPattern(input.pattern)) { |
| 3450 | return yield* new StorageError({ |
| 3451 | message: `Invalid tool policy pattern: ${input.pattern}`, |
| 3452 | cause: undefined, |
| 3453 | }); |
| 3454 | } |
| 3455 | const where = (b: AnyCb) => b.and(byOwner(input.owner)(b), b("id", "=", input.id)); |
| 3456 | const existing = yield* core.findFirst("tool_policy", { where }); |
| 3457 | if (!existing) { |
| 3458 | return yield* new StorageError({ |
| 3459 | message: `Tool policy not found: ${input.id}`, |
| 3460 | cause: undefined, |
| 3461 | }); |
| 3462 | } |
| 3463 | const set: Record<string, unknown> = { updated_at: new Date() }; |
| 3464 | if (input.pattern !== undefined) set.pattern = input.pattern; |
| 3465 | if (input.action !== undefined) set.action = input.action; |
| 3466 | if (input.position !== undefined) set.position = input.position; |
| 3467 | yield* core.updateMany("tool_policy", { where, set }); |
| 3468 | const updated = yield* core.findFirst("tool_policy", { where }); |
| 3469 | return rowToToolPolicy(updated ?? ({ ...existing, ...set } as ToolPolicyRow)); |
| 3470 | }); |
| 3471 | |
| 3472 | const policiesRemove = (input: RemoveToolPolicyInput): Effect.Effect<void, StorageFailure> => |
| 3473 | core.deleteMany("tool_policy", { |
no test coverage detected