(
slug: IntegrationSlug,
)
| 1961 | }); |
| 1962 | |
| 1963 | const integrationsRemove = ( |
| 1964 | slug: IntegrationSlug, |
| 1965 | ): Effect.Effect<void, IntegrationRemovalNotAllowedError | StorageFailure> => |
| 1966 | transaction( |
| 1967 | Effect.gen(function* () { |
| 1968 | const existing = yield* findIntegrationRow(slug); |
| 1969 | if (!existing) return; |
| 1970 | if (!existing.can_remove) { |
| 1971 | return yield* new IntegrationRemovalNotAllowedError({ slug }); |
| 1972 | } |
| 1973 | const runtime = runtimes.get(existing.plugin_id); |
| 1974 | if (runtime?.plugin.removeIntegration) { |
| 1975 | yield* runtime.plugin |
| 1976 | .removeIntegration({ |
| 1977 | ctx: runtime.ctx, |
| 1978 | integration: rowToIntegrationRecord(existing, describeAuthMethodsForRow(existing)), |
| 1979 | }) |
| 1980 | .pipe( |
| 1981 | Effect.mapError((cause) => |
| 1982 | pluginStorageFailure(existing.plugin_id, "removeIntegration", cause), |
| 1983 | ), |
| 1984 | ); |
| 1985 | } |
| 1986 | // Drop owned connections / tools / definitions for this integration. |
| 1987 | const where = (b: AnyCb) => b("integration", "=", String(slug)); |
| 1988 | yield* core.deleteMany("tool", { where }); |
| 1989 | yield* core.deleteMany("definition", { where }); |
| 1990 | yield* core.deleteMany("connection", { where }); |
| 1991 | yield* core.deleteMany("integration", { |
| 1992 | where: (b: AnyCb) => b("slug", "=", String(slug)), |
| 1993 | }); |
| 1994 | }), |
| 1995 | ); |
| 1996 | |
| 1997 | const integrationsDetect = ( |
| 1998 | url: string, |
no test coverage detected