(
ref: ConnectionRef,
)
| 4816 | ); |
| 4817 | |
| 4818 | const connectionsRemove = ( |
| 4819 | ref: ConnectionRef, |
| 4820 | ): Effect.Effect<void, ConnectionNotFoundError | OrgWriteDeniedError | StorageFailure> => |
| 4821 | transaction( |
| 4822 | Effect.gen(function* () { |
| 4823 | yield* guardOrgWrite(ref.owner); |
| 4824 | const row = yield* findConnectionRow(ref); |
| 4825 | if (!row) { |
| 4826 | return yield* new ConnectionNotFoundError({ |
| 4827 | owner: ref.owner, |
| 4828 | integration: ref.integration, |
| 4829 | name: ref.name, |
| 4830 | }); |
| 4831 | } |
| 4832 | const integrationRow = yield* findIntegrationRow(ref.integration); |
| 4833 | const runtime = integrationRow ? runtimes.get(integrationRow.plugin_id) : undefined; |
| 4834 | if (integrationRow && runtime?.plugin.removeConnection) { |
| 4835 | yield* runtime.plugin |
| 4836 | .removeConnection({ |
| 4837 | ctx: runtime.ctx, |
| 4838 | integration: ref.integration, |
| 4839 | connection: ref, |
| 4840 | }) |
| 4841 | .pipe( |
| 4842 | Effect.mapError((cause) => |
| 4843 | pluginStorageFailure(integrationRow.plugin_id, "removeConnection", cause), |
| 4844 | ), |
| 4845 | ); |
| 4846 | } |
| 4847 | const where = (b: AnyCb) => |
| 4848 | b.and( |
| 4849 | byOwner(ref.owner)(b), |
| 4850 | b("integration", "=", String(ref.integration)), |
| 4851 | b("connection", "=", String(ref.name)), |
| 4852 | ); |
| 4853 | yield* core.deleteMany("tool", { where }); |
| 4854 | yield* core.deleteMany("definition", { where }); |
| 4855 | yield* core.deleteMany("connection", { |
| 4856 | where: (b: AnyCb) => |
| 4857 | b.and( |
| 4858 | byOwner(ref.owner)(b), |
| 4859 | b("integration", "=", String(ref.integration)), |
| 4860 | b("name", "=", String(ref.name)), |
| 4861 | ), |
| 4862 | }); |
| 4863 | }), |
| 4864 | ); |
| 4865 | |
| 4866 | const connectionsRefresh = ( |
| 4867 | ref: ConnectionRef, |
no test coverage detected