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