(
slug: IntegrationSlug,
)
| 2758 | }); |
| 2759 | |
| 2760 | const integrationsRemove = ( |
| 2761 | slug: IntegrationSlug, |
| 2762 | ): Effect.Effect<void, IntegrationRemovalNotAllowedError | StorageFailure> => |
| 2763 | transaction( |
| 2764 | Effect.gen(function* () { |
| 2765 | const existing = yield* findIntegrationRow(slug); |
| 2766 | if (!existing) return null; |
| 2767 | if (!existing.can_remove) { |
| 2768 | return yield* new IntegrationRemovalNotAllowedError({ slug }); |
| 2769 | } |
| 2770 | const runtime = runtimes.get(existing.plugin_id); |
| 2771 | if (runtime?.plugin.removeIntegration) { |
| 2772 | yield* runtime.plugin |
| 2773 | .removeIntegration({ |
| 2774 | ctx: runtime.ctx, |
| 2775 | integration: rowToIntegrationRecord(existing, describeAuthMethodsForRow(existing)), |
| 2776 | }) |
| 2777 | .pipe( |
| 2778 | Effect.mapError((cause) => |
| 2779 | pluginStorageFailure(existing.plugin_id, "removeIntegration", cause), |
| 2780 | ), |
| 2781 | ); |
| 2782 | } |
| 2783 | // Drop owned connections / tools / definitions for this integration. |
| 2784 | const where = (b: AnyCb) => b("integration", "=", String(slug)); |
| 2785 | yield* core.deleteMany("tool", { where }); |
| 2786 | yield* core.deleteMany("definition", { where }); |
| 2787 | yield* core.deleteMany("connection", { where }); |
| 2788 | yield* core.deleteMany("integration", { |
| 2789 | where: (b: AnyCb) => b("slug", "=", String(slug)), |
| 2790 | }); |
| 2791 | return existing.plugin_id; |
| 2792 | }), |
| 2793 | ).pipe( |
| 2794 | Effect.tap((removedPluginId) => |
| 2795 | removedPluginId !== null |
| 2796 | ? notifyIntegrationChange({ kind: "removed", pluginKey: removedPluginId, slug }) |
| 2797 | : Effect.void, |
| 2798 | ), |
| 2799 | Effect.asVoid, |
| 2800 | ); |
| 2801 | |
| 2802 | const integrationsDetect = ( |
| 2803 | url: string, |
no test coverage detected