(
ref: ConnectionRef,
input: UpdateConnectionInput,
)
| 4670 | findConnectionRow(ref).pipe(Effect.map((row) => (row ? rowToConnection(row) : null))); |
| 4671 | |
| 4672 | const connectionsUpdate = ( |
| 4673 | ref: ConnectionRef, |
| 4674 | input: UpdateConnectionInput, |
| 4675 | ): Effect.Effect<Connection, ConnectionNotFoundError | OrgWriteDeniedError | StorageFailure> => |
| 4676 | transaction( |
| 4677 | Effect.gen(function* () { |
| 4678 | yield* guardOrgWrite(ref.owner); |
| 4679 | const row = yield* findConnectionRow(ref); |
| 4680 | if (!row) { |
| 4681 | return yield* new ConnectionNotFoundError({ |
| 4682 | owner: ref.owner, |
| 4683 | integration: ref.integration, |
| 4684 | name: ref.name, |
| 4685 | }); |
| 4686 | } |
| 4687 | const set: Record<string, unknown> = { updated_at: new Date() }; |
| 4688 | if (input.description !== undefined) set.description = input.description; |
| 4689 | if (input.identityLabel !== undefined) set.identity_label = input.identityLabel; |
| 4690 | yield* core.updateMany("connection", { |
| 4691 | where: (b: AnyCb) => |
| 4692 | b.and( |
| 4693 | byOwner(ref.owner)(b), |
| 4694 | b("integration", "=", String(ref.integration)), |
| 4695 | b("name", "=", String(ref.name)), |
| 4696 | ), |
| 4697 | set, |
| 4698 | }); |
| 4699 | const updated = yield* findConnectionRow(ref); |
| 4700 | return rowToConnection(updated ?? row); |
| 4701 | }), |
| 4702 | ); |
| 4703 | |
| 4704 | const connectionsRemove = ( |
| 4705 | ref: ConnectionRef, |
no test coverage detected