(
slug: IntegrationSlug,
)
| 2956 | }); |
| 2957 | |
| 2958 | const integrationsRemove = ( |
| 2959 | slug: IntegrationSlug, |
| 2960 | ): Effect.Effect<void, IntegrationRemovalNotAllowedError | StorageFailure> => |
| 2961 | transaction( |
| 2962 | Effect.gen(function* () { |
| 2963 | const existing = yield* findIntegrationRow(slug); |
| 2964 | if (!existing) return null; |
| 2965 | if (!existing.can_remove) { |
| 2966 | return yield* new IntegrationRemovalNotAllowedError({ slug }); |
| 2967 | } |
| 2968 | const runtime = runtimes.get(existing.plugin_id); |
| 2969 | if (runtime?.plugin.removeIntegration) { |
| 2970 | yield* runtime.plugin |
| 2971 | .removeIntegration({ |
| 2972 | ctx: runtime.ctx, |
| 2973 | integration: rowToIntegrationRecord(existing, describeAuthMethodsForRow(existing)), |
| 2974 | }) |
| 2975 | .pipe( |
| 2976 | Effect.mapError((cause) => |
| 2977 | pluginStorageFailure(existing.plugin_id, "removeIntegration", cause), |
| 2978 | ), |
| 2979 | ); |
| 2980 | } |
| 2981 | // Drop owned connections / tools / definitions for this integration. |
| 2982 | const where = (b: AnyCb) => b("integration", "=", String(slug)); |
| 2983 | yield* core.deleteMany("tool", { where }); |
| 2984 | yield* core.deleteMany("definition", { where }); |
| 2985 | yield* core.deleteMany("connection", { where }); |
| 2986 | yield* core.deleteMany("integration", { |
| 2987 | where: (b: AnyCb) => b("slug", "=", String(slug)), |
| 2988 | }); |
| 2989 | return existing.plugin_id; |
| 2990 | }), |
| 2991 | ).pipe( |
| 2992 | Effect.tap((removedPluginId) => |
| 2993 | removedPluginId !== null |
| 2994 | ? notifyIntegrationChange({ kind: "removed", pluginKey: removedPluginId, slug }) |
| 2995 | : Effect.void, |
| 2996 | ), |
| 2997 | Effect.asVoid, |
| 2998 | ); |
| 2999 | |
| 3000 | const integrationsDetect = ( |
| 3001 | url: string, |
no test coverage detected