(
ref: ConnectionRef,
)
| 3515 | }); |
| 3516 | |
| 3517 | const connectionsRemove = ( |
| 3518 | ref: ConnectionRef, |
| 3519 | ): Effect.Effect<void, ConnectionNotFoundError | StorageFailure> => |
| 3520 | transaction( |
| 3521 | Effect.gen(function* () { |
| 3522 | const row = yield* findConnectionRow(ref); |
| 3523 | if (!row) { |
| 3524 | return yield* new ConnectionNotFoundError({ |
| 3525 | owner: ref.owner, |
| 3526 | integration: ref.integration, |
| 3527 | name: ref.name, |
| 3528 | }); |
| 3529 | } |
| 3530 | const integrationRow = yield* findIntegrationRow(ref.integration); |
| 3531 | const runtime = integrationRow ? runtimes.get(integrationRow.plugin_id) : undefined; |
| 3532 | if (integrationRow && runtime?.plugin.removeConnection) { |
| 3533 | yield* runtime.plugin |
| 3534 | .removeConnection({ |
| 3535 | ctx: runtime.ctx, |
| 3536 | integration: ref.integration, |
| 3537 | connection: ref, |
| 3538 | }) |
| 3539 | .pipe( |
| 3540 | Effect.mapError((cause) => |
| 3541 | pluginStorageFailure(integrationRow.plugin_id, "removeConnection", cause), |
| 3542 | ), |
| 3543 | ); |
| 3544 | } |
| 3545 | const where = (b: AnyCb) => |
| 3546 | b.and( |
| 3547 | byOwner(ref.owner)(b), |
| 3548 | b("integration", "=", String(ref.integration)), |
| 3549 | b("connection", "=", String(ref.name)), |
| 3550 | ); |
| 3551 | yield* core.deleteMany("tool", { where }); |
| 3552 | yield* core.deleteMany("definition", { where }); |
| 3553 | yield* core.deleteMany("connection", { |
| 3554 | where: (b: AnyCb) => |
| 3555 | b.and( |
| 3556 | byOwner(ref.owner)(b), |
| 3557 | b("integration", "=", String(ref.integration)), |
| 3558 | b("name", "=", String(ref.name)), |
| 3559 | ), |
| 3560 | }); |
| 3561 | }), |
| 3562 | ); |
| 3563 | |
| 3564 | const connectionsRefresh = ( |
| 3565 | ref: ConnectionRef, |
no test coverage detected