(
slug: IntegrationSlug,
)
| 2390 | }); |
| 2391 | |
| 2392 | const integrationsRemove = ( |
| 2393 | slug: IntegrationSlug, |
| 2394 | ): Effect.Effect<void, IntegrationRemovalNotAllowedError | StorageFailure> => |
| 2395 | transaction( |
| 2396 | Effect.gen(function* () { |
| 2397 | const existing = yield* findIntegrationRow(slug); |
| 2398 | if (!existing) return null; |
| 2399 | if (!existing.can_remove) { |
| 2400 | return yield* new IntegrationRemovalNotAllowedError({ slug }); |
| 2401 | } |
| 2402 | const runtime = runtimes.get(existing.plugin_id); |
| 2403 | if (runtime?.plugin.removeIntegration) { |
| 2404 | yield* runtime.plugin |
| 2405 | .removeIntegration({ |
| 2406 | ctx: runtime.ctx, |
| 2407 | integration: rowToIntegrationRecord(existing, describeAuthMethodsForRow(existing)), |
| 2408 | }) |
| 2409 | .pipe( |
| 2410 | Effect.mapError((cause) => |
| 2411 | pluginStorageFailure(existing.plugin_id, "removeIntegration", cause), |
| 2412 | ), |
| 2413 | ); |
| 2414 | } |
| 2415 | // Drop owned connections / tools / definitions for this integration. |
| 2416 | const where = (b: AnyCb) => b("integration", "=", String(slug)); |
| 2417 | yield* core.deleteMany("tool", { where }); |
| 2418 | yield* core.deleteMany("definition", { where }); |
| 2419 | yield* core.deleteMany("connection", { where }); |
| 2420 | yield* core.deleteMany("integration", { |
| 2421 | where: (b: AnyCb) => b("slug", "=", String(slug)), |
| 2422 | }); |
| 2423 | return existing.plugin_id; |
| 2424 | }), |
| 2425 | ).pipe( |
| 2426 | Effect.tap((removedPluginId) => |
| 2427 | removedPluginId !== null |
| 2428 | ? notifyIntegrationChange({ kind: "removed", pluginKey: removedPluginId, slug }) |
| 2429 | : Effect.void, |
| 2430 | ), |
| 2431 | Effect.asVoid, |
| 2432 | ); |
| 2433 | |
| 2434 | const integrationsDetect = ( |
| 2435 | url: string, |
no test coverage detected