(
ref: ConnectionRef,
)
| 4702 | ); |
| 4703 | |
| 4704 | const connectionsRemove = ( |
| 4705 | ref: ConnectionRef, |
| 4706 | ): Effect.Effect<void, ConnectionNotFoundError | OrgWriteDeniedError | StorageFailure> => |
| 4707 | transaction( |
| 4708 | Effect.gen(function* () { |
| 4709 | yield* guardOrgWrite(ref.owner); |
| 4710 | const row = yield* findConnectionRow(ref); |
| 4711 | if (!row) { |
| 4712 | return yield* new ConnectionNotFoundError({ |
| 4713 | owner: ref.owner, |
| 4714 | integration: ref.integration, |
| 4715 | name: ref.name, |
| 4716 | }); |
| 4717 | } |
| 4718 | const integrationRow = yield* findIntegrationRow(ref.integration); |
| 4719 | const runtime = integrationRow ? runtimes.get(integrationRow.plugin_id) : undefined; |
| 4720 | if (integrationRow && runtime?.plugin.removeConnection) { |
| 4721 | yield* runtime.plugin |
| 4722 | .removeConnection({ |
| 4723 | ctx: runtime.ctx, |
| 4724 | integration: ref.integration, |
| 4725 | connection: ref, |
| 4726 | }) |
| 4727 | .pipe( |
| 4728 | Effect.mapError((cause) => |
| 4729 | pluginStorageFailure(integrationRow.plugin_id, "removeConnection", cause), |
| 4730 | ), |
| 4731 | ); |
| 4732 | } |
| 4733 | const where = (b: AnyCb) => |
| 4734 | b.and( |
| 4735 | byOwner(ref.owner)(b), |
| 4736 | b("integration", "=", String(ref.integration)), |
| 4737 | b("connection", "=", String(ref.name)), |
| 4738 | ); |
| 4739 | yield* core.deleteMany("tool", { where }); |
| 4740 | yield* core.deleteMany("definition", { where }); |
| 4741 | yield* core.deleteMany("connection", { |
| 4742 | where: (b: AnyCb) => |
| 4743 | b.and( |
| 4744 | byOwner(ref.owner)(b), |
| 4745 | b("integration", "=", String(ref.integration)), |
| 4746 | b("name", "=", String(ref.name)), |
| 4747 | ), |
| 4748 | }); |
| 4749 | }), |
| 4750 | ); |
| 4751 | |
| 4752 | const connectionsRefresh = ( |
| 4753 | ref: ConnectionRef, |
no test coverage detected