(
input: UpdateToolPolicyInput,
)
| 3959 | }); |
| 3960 | |
| 3961 | const policiesUpdate = ( |
| 3962 | input: UpdateToolPolicyInput, |
| 3963 | ): Effect.Effect<ToolPolicy, StorageFailure> => |
| 3964 | Effect.gen(function* () { |
| 3965 | if (input.pattern !== undefined && !isValidPattern(input.pattern)) { |
| 3966 | return yield* new StorageError({ |
| 3967 | message: `Invalid tool policy pattern: ${input.pattern}`, |
| 3968 | cause: undefined, |
| 3969 | }); |
| 3970 | } |
| 3971 | const where = (b: AnyCb) => b.and(byOwner(input.owner)(b), b("id", "=", input.id)); |
| 3972 | const existing = yield* core.findFirst("tool_policy", { where }); |
| 3973 | if (!existing) { |
| 3974 | return yield* new StorageError({ |
| 3975 | message: `Tool policy not found: ${input.id}`, |
| 3976 | cause: undefined, |
| 3977 | }); |
| 3978 | } |
| 3979 | const set: Record<string, unknown> = { updated_at: new Date() }; |
| 3980 | if (input.pattern !== undefined) set.pattern = input.pattern; |
| 3981 | if (input.action !== undefined) set.action = input.action; |
| 3982 | if (input.position !== undefined) set.position = input.position; |
| 3983 | yield* core.updateMany("tool_policy", { where, set }); |
| 3984 | const updated = yield* core.findFirst("tool_policy", { where }); |
| 3985 | return rowToToolPolicy(updated ?? ({ ...existing, ...set } as ToolPolicyRow)); |
| 3986 | }); |
| 3987 | |
| 3988 | const policiesRemove = (input: RemoveToolPolicyInput): Effect.Effect<void, StorageFailure> => |
| 3989 | core.deleteMany("tool_policy", { |
no test coverage detected