(
ref: ConnectionRef,
)
| 4253 | }); |
| 4254 | |
| 4255 | const connectionsRemove = ( |
| 4256 | ref: ConnectionRef, |
| 4257 | ): Effect.Effect<void, ConnectionNotFoundError | StorageFailure> => |
| 4258 | transaction( |
| 4259 | Effect.gen(function* () { |
| 4260 | const row = yield* findConnectionRow(ref); |
| 4261 | if (!row) { |
| 4262 | return yield* new ConnectionNotFoundError({ |
| 4263 | owner: ref.owner, |
| 4264 | integration: ref.integration, |
| 4265 | name: ref.name, |
| 4266 | }); |
| 4267 | } |
| 4268 | const integrationRow = yield* findIntegrationRow(ref.integration); |
| 4269 | const runtime = integrationRow ? runtimes.get(integrationRow.plugin_id) : undefined; |
| 4270 | if (integrationRow && runtime?.plugin.removeConnection) { |
| 4271 | yield* runtime.plugin |
| 4272 | .removeConnection({ |
| 4273 | ctx: runtime.ctx, |
| 4274 | integration: ref.integration, |
| 4275 | connection: ref, |
| 4276 | }) |
| 4277 | .pipe( |
| 4278 | Effect.mapError((cause) => |
| 4279 | pluginStorageFailure(integrationRow.plugin_id, "removeConnection", cause), |
| 4280 | ), |
| 4281 | ); |
| 4282 | } |
| 4283 | const where = (b: AnyCb) => |
| 4284 | b.and( |
| 4285 | byOwner(ref.owner)(b), |
| 4286 | b("integration", "=", String(ref.integration)), |
| 4287 | b("connection", "=", String(ref.name)), |
| 4288 | ); |
| 4289 | yield* core.deleteMany("tool", { where }); |
| 4290 | yield* core.deleteMany("definition", { where }); |
| 4291 | yield* core.deleteMany("connection", { |
| 4292 | where: (b: AnyCb) => |
| 4293 | b.and( |
| 4294 | byOwner(ref.owner)(b), |
| 4295 | b("integration", "=", String(ref.integration)), |
| 4296 | b("name", "=", String(ref.name)), |
| 4297 | ), |
| 4298 | }); |
| 4299 | }), |
| 4300 | ); |
| 4301 | |
| 4302 | const connectionsRefresh = ( |
| 4303 | ref: ConnectionRef, |
no test coverage detected