(
slug: IntegrationSlug,
)
| 1945 | }); |
| 1946 | |
| 1947 | const integrationsRemove = ( |
| 1948 | slug: IntegrationSlug, |
| 1949 | ): Effect.Effect<void, IntegrationRemovalNotAllowedError | StorageFailure> => |
| 1950 | transaction( |
| 1951 | Effect.gen(function* () { |
| 1952 | const existing = yield* findIntegrationRow(slug); |
| 1953 | if (!existing) return; |
| 1954 | if (!existing.can_remove) { |
| 1955 | return yield* new IntegrationRemovalNotAllowedError({ slug }); |
| 1956 | } |
| 1957 | const runtime = runtimes.get(existing.plugin_id); |
| 1958 | if (runtime?.plugin.removeIntegration) { |
| 1959 | yield* runtime.plugin |
| 1960 | .removeIntegration({ |
| 1961 | ctx: runtime.ctx, |
| 1962 | integration: rowToIntegrationRecord(existing, describeAuthMethodsForRow(existing)), |
| 1963 | }) |
| 1964 | .pipe( |
| 1965 | Effect.mapError((cause) => |
| 1966 | pluginStorageFailure(existing.plugin_id, "removeIntegration", cause), |
| 1967 | ), |
| 1968 | ); |
| 1969 | } |
| 1970 | // Drop owned connections / tools / definitions for this integration. |
| 1971 | const where = (b: AnyCb) => b("integration", "=", String(slug)); |
| 1972 | yield* core.deleteMany("tool", { where }); |
| 1973 | yield* core.deleteMany("definition", { where }); |
| 1974 | yield* core.deleteMany("connection", { where }); |
| 1975 | yield* core.deleteMany("integration", { |
| 1976 | where: (b: AnyCb) => b("slug", "=", String(slug)), |
| 1977 | }); |
| 1978 | }), |
| 1979 | ); |
| 1980 | |
| 1981 | const integrationsDetect = ( |
| 1982 | url: string, |
no test coverage detected