(
input: UpdateToolPolicyInput,
)
| 3542 | }); |
| 3543 | |
| 3544 | const policiesUpdate = ( |
| 3545 | input: UpdateToolPolicyInput, |
| 3546 | ): Effect.Effect<ToolPolicy, StorageFailure> => |
| 3547 | Effect.gen(function* () { |
| 3548 | if (input.pattern !== undefined && !isValidPattern(input.pattern)) { |
| 3549 | return yield* new StorageError({ |
| 3550 | message: `Invalid tool policy pattern: ${input.pattern}`, |
| 3551 | cause: undefined, |
| 3552 | }); |
| 3553 | } |
| 3554 | const where = (b: AnyCb) => b.and(byOwner(input.owner)(b), b("id", "=", input.id)); |
| 3555 | const existing = yield* core.findFirst("tool_policy", { where }); |
| 3556 | if (!existing) { |
| 3557 | return yield* new StorageError({ |
| 3558 | message: `Tool policy not found: ${input.id}`, |
| 3559 | cause: undefined, |
| 3560 | }); |
| 3561 | } |
| 3562 | const set: Record<string, unknown> = { updated_at: new Date() }; |
| 3563 | if (input.pattern !== undefined) set.pattern = input.pattern; |
| 3564 | if (input.action !== undefined) set.action = input.action; |
| 3565 | if (input.position !== undefined) set.position = input.position; |
| 3566 | yield* core.updateMany("tool_policy", { where, set }); |
| 3567 | const updated = yield* core.findFirst("tool_policy", { where }); |
| 3568 | return rowToToolPolicy(updated ?? ({ ...existing, ...set } as ToolPolicyRow)); |
| 3569 | }); |
| 3570 | |
| 3571 | const policiesRemove = (input: RemoveToolPolicyInput): Effect.Effect<void, StorageFailure> => |
| 3572 | core.deleteMany("tool_policy", { |
no test coverage detected