(
input: UpdateToolPolicyInput,
)
| 4031 | }); |
| 4032 | |
| 4033 | const policiesUpdate = ( |
| 4034 | input: UpdateToolPolicyInput, |
| 4035 | ): Effect.Effect<ToolPolicy, StorageFailure> => |
| 4036 | Effect.gen(function* () { |
| 4037 | if (input.pattern !== undefined && !isValidPattern(input.pattern)) { |
| 4038 | return yield* new StorageError({ |
| 4039 | message: `Invalid tool policy pattern: ${input.pattern}`, |
| 4040 | cause: undefined, |
| 4041 | }); |
| 4042 | } |
| 4043 | const where = (b: AnyCb) => b.and(byOwner(input.owner)(b), b("id", "=", input.id)); |
| 4044 | const existing = yield* core.findFirst("tool_policy", { where }); |
| 4045 | if (!existing) { |
| 4046 | return yield* new StorageError({ |
| 4047 | message: `Tool policy not found: ${input.id}`, |
| 4048 | cause: undefined, |
| 4049 | }); |
| 4050 | } |
| 4051 | const set: Record<string, unknown> = { updated_at: new Date() }; |
| 4052 | if (input.pattern !== undefined) set.pattern = input.pattern; |
| 4053 | if (input.action !== undefined) set.action = input.action; |
| 4054 | if (input.position !== undefined) set.position = input.position; |
| 4055 | yield* core.updateMany("tool_policy", { where, set }); |
| 4056 | const updated = yield* core.findFirst("tool_policy", { where }); |
| 4057 | return rowToToolPolicy(updated ?? ({ ...existing, ...set } as ToolPolicyRow)); |
| 4058 | }); |
| 4059 | |
| 4060 | const policiesRemove = (input: RemoveToolPolicyInput): Effect.Effect<void, StorageFailure> => |
| 4061 | core.deleteMany("tool_policy", { |
no test coverage detected