(
input: UpdateToolPolicyInput,
)
| 6109 | ); |
| 6110 | |
| 6111 | const policiesUpdate = ( |
| 6112 | input: UpdateToolPolicyInput, |
| 6113 | ): Effect.Effect<ToolPolicy, OrgWriteDeniedError | StorageFailure> => |
| 6114 | transaction( |
| 6115 | Effect.gen(function* () { |
| 6116 | yield* guardOrgWrite(input.owner); |
| 6117 | if (input.pattern !== undefined && !isValidPattern(input.pattern)) { |
| 6118 | return yield* new StorageError({ |
| 6119 | message: `Invalid tool policy pattern: ${input.pattern}`, |
| 6120 | cause: undefined, |
| 6121 | }); |
| 6122 | } |
| 6123 | const where = (b: AnyCb) => b.and(byOwner(input.owner)(b), b("id", "=", input.id)); |
| 6124 | const existing = yield* core.findFirst("tool_policy", { where }); |
| 6125 | if (!existing) { |
| 6126 | return yield* new StorageError({ |
| 6127 | message: `Tool policy not found: ${input.id}`, |
| 6128 | cause: undefined, |
| 6129 | }); |
| 6130 | } |
| 6131 | const set: Record<string, unknown> = { updated_at: new Date() }; |
| 6132 | if (input.pattern !== undefined) set.pattern = input.pattern; |
| 6133 | if (input.action !== undefined) set.action = input.action; |
| 6134 | if (input.position !== undefined) set.position = input.position; |
| 6135 | yield* core.updateMany("tool_policy", { where, set }); |
| 6136 | const updated = yield* core.findFirst("tool_policy", { where }); |
| 6137 | if (!updated) { |
| 6138 | return yield* new StorageError({ |
| 6139 | message: `Tool policy disappeared while it was being updated: ${input.id}`, |
| 6140 | cause: undefined, |
| 6141 | }); |
| 6142 | } |
| 6143 | return rowToToolPolicy(updated); |
| 6144 | }), |
| 6145 | ); |
| 6146 | |
| 6147 | const policiesRemove = ( |
| 6148 | input: RemoveToolPolicyInput, |
no test coverage detected