(
input: UpdateToolPolicyInput,
)
| 3985 | }); |
| 3986 | |
| 3987 | const policiesUpdate = ( |
| 3988 | input: UpdateToolPolicyInput, |
| 3989 | ): Effect.Effect<ToolPolicy, StorageFailure> => |
| 3990 | Effect.gen(function* () { |
| 3991 | if (input.pattern !== undefined && !isValidPattern(input.pattern)) { |
| 3992 | return yield* new StorageError({ |
| 3993 | message: `Invalid tool policy pattern: ${input.pattern}`, |
| 3994 | cause: undefined, |
| 3995 | }); |
| 3996 | } |
| 3997 | const where = (b: AnyCb) => b.and(byOwner(input.owner)(b), b("id", "=", input.id)); |
| 3998 | const existing = yield* core.findFirst("tool_policy", { where }); |
| 3999 | if (!existing) { |
| 4000 | return yield* new StorageError({ |
| 4001 | message: `Tool policy not found: ${input.id}`, |
| 4002 | cause: undefined, |
| 4003 | }); |
| 4004 | } |
| 4005 | const set: Record<string, unknown> = { updated_at: new Date() }; |
| 4006 | if (input.pattern !== undefined) set.pattern = input.pattern; |
| 4007 | if (input.action !== undefined) set.action = input.action; |
| 4008 | if (input.position !== undefined) set.position = input.position; |
| 4009 | yield* core.updateMany("tool_policy", { where, set }); |
| 4010 | const updated = yield* core.findFirst("tool_policy", { where }); |
| 4011 | return rowToToolPolicy(updated ?? ({ ...existing, ...set } as ToolPolicyRow)); |
| 4012 | }); |
| 4013 | |
| 4014 | const policiesRemove = (input: RemoveToolPolicyInput): Effect.Effect<void, StorageFailure> => |
| 4015 | core.deleteMany("tool_policy", { |
no test coverage detected