(
ref: ConnectionRef,
)
| 2648 | }); |
| 2649 | |
| 2650 | const connectionsRemove = ( |
| 2651 | ref: ConnectionRef, |
| 2652 | ): Effect.Effect<void, ConnectionNotFoundError | StorageFailure> => |
| 2653 | transaction( |
| 2654 | Effect.gen(function* () { |
| 2655 | const row = yield* findConnectionRow(ref); |
| 2656 | if (!row) { |
| 2657 | return yield* new ConnectionNotFoundError({ |
| 2658 | owner: ref.owner, |
| 2659 | integration: ref.integration, |
| 2660 | name: ref.name, |
| 2661 | }); |
| 2662 | } |
| 2663 | const integrationRow = yield* findIntegrationRow(ref.integration); |
| 2664 | const runtime = integrationRow ? runtimes.get(integrationRow.plugin_id) : undefined; |
| 2665 | if (integrationRow && runtime?.plugin.removeConnection) { |
| 2666 | yield* runtime.plugin |
| 2667 | .removeConnection({ |
| 2668 | ctx: runtime.ctx, |
| 2669 | integration: ref.integration, |
| 2670 | connection: ref, |
| 2671 | }) |
| 2672 | .pipe( |
| 2673 | Effect.mapError((cause) => |
| 2674 | pluginStorageFailure(integrationRow.plugin_id, "removeConnection", cause), |
| 2675 | ), |
| 2676 | ); |
| 2677 | } |
| 2678 | const where = (b: AnyCb) => |
| 2679 | b.and( |
| 2680 | byOwner(ref.owner)(b), |
| 2681 | b("integration", "=", String(ref.integration)), |
| 2682 | b("connection", "=", String(ref.name)), |
| 2683 | ); |
| 2684 | yield* core.deleteMany("tool", { where }); |
| 2685 | yield* core.deleteMany("definition", { where }); |
| 2686 | yield* core.deleteMany("connection", { |
| 2687 | where: (b: AnyCb) => |
| 2688 | b.and( |
| 2689 | byOwner(ref.owner)(b), |
| 2690 | b("integration", "=", String(ref.integration)), |
| 2691 | b("name", "=", String(ref.name)), |
| 2692 | ), |
| 2693 | }); |
| 2694 | }), |
| 2695 | ); |
| 2696 | |
| 2697 | const connectionsRefresh = ( |
| 2698 | ref: ConnectionRef, |
no test coverage detected