(
ref: ConnectionRef,
)
| 2731 | }); |
| 2732 | |
| 2733 | const connectionsRemove = ( |
| 2734 | ref: ConnectionRef, |
| 2735 | ): Effect.Effect<void, ConnectionNotFoundError | StorageFailure> => |
| 2736 | transaction( |
| 2737 | Effect.gen(function* () { |
| 2738 | const row = yield* findConnectionRow(ref); |
| 2739 | if (!row) { |
| 2740 | return yield* new ConnectionNotFoundError({ |
| 2741 | owner: ref.owner, |
| 2742 | integration: ref.integration, |
| 2743 | name: ref.name, |
| 2744 | }); |
| 2745 | } |
| 2746 | const integrationRow = yield* findIntegrationRow(ref.integration); |
| 2747 | const runtime = integrationRow ? runtimes.get(integrationRow.plugin_id) : undefined; |
| 2748 | if (integrationRow && runtime?.plugin.removeConnection) { |
| 2749 | yield* runtime.plugin |
| 2750 | .removeConnection({ |
| 2751 | ctx: runtime.ctx, |
| 2752 | integration: ref.integration, |
| 2753 | connection: ref, |
| 2754 | }) |
| 2755 | .pipe( |
| 2756 | Effect.mapError((cause) => |
| 2757 | pluginStorageFailure(integrationRow.plugin_id, "removeConnection", cause), |
| 2758 | ), |
| 2759 | ); |
| 2760 | } |
| 2761 | const where = (b: AnyCb) => |
| 2762 | b.and( |
| 2763 | byOwner(ref.owner)(b), |
| 2764 | b("integration", "=", String(ref.integration)), |
| 2765 | b("connection", "=", String(ref.name)), |
| 2766 | ); |
| 2767 | yield* core.deleteMany("tool", { where }); |
| 2768 | yield* core.deleteMany("definition", { where }); |
| 2769 | yield* core.deleteMany("connection", { |
| 2770 | where: (b: AnyCb) => |
| 2771 | b.and( |
| 2772 | byOwner(ref.owner)(b), |
| 2773 | b("integration", "=", String(ref.integration)), |
| 2774 | b("name", "=", String(ref.name)), |
| 2775 | ), |
| 2776 | }); |
| 2777 | }), |
| 2778 | ); |
| 2779 | |
| 2780 | const connectionsRefresh = ( |
| 2781 | ref: ConnectionRef, |
no test coverage detected