(
slug: IntegrationSlug,
)
| 2036 | }); |
| 2037 | |
| 2038 | const integrationsRemove = ( |
| 2039 | slug: IntegrationSlug, |
| 2040 | ): Effect.Effect<void, IntegrationRemovalNotAllowedError | StorageFailure> => |
| 2041 | transaction( |
| 2042 | Effect.gen(function* () { |
| 2043 | const existing = yield* findIntegrationRow(slug); |
| 2044 | if (!existing) return; |
| 2045 | if (!existing.can_remove) { |
| 2046 | return yield* new IntegrationRemovalNotAllowedError({ slug }); |
| 2047 | } |
| 2048 | const runtime = runtimes.get(existing.plugin_id); |
| 2049 | if (runtime?.plugin.removeIntegration) { |
| 2050 | yield* runtime.plugin |
| 2051 | .removeIntegration({ |
| 2052 | ctx: runtime.ctx, |
| 2053 | integration: rowToIntegrationRecord(existing, describeAuthMethodsForRow(existing)), |
| 2054 | }) |
| 2055 | .pipe( |
| 2056 | Effect.mapError((cause) => |
| 2057 | pluginStorageFailure(existing.plugin_id, "removeIntegration", cause), |
| 2058 | ), |
| 2059 | ); |
| 2060 | } |
| 2061 | // Drop owned connections / tools / definitions for this integration. |
| 2062 | const where = (b: AnyCb) => b("integration", "=", String(slug)); |
| 2063 | yield* core.deleteMany("tool", { where }); |
| 2064 | yield* core.deleteMany("definition", { where }); |
| 2065 | yield* core.deleteMany("connection", { where }); |
| 2066 | yield* core.deleteMany("integration", { |
| 2067 | where: (b: AnyCb) => b("slug", "=", String(slug)), |
| 2068 | }); |
| 2069 | }), |
| 2070 | ); |
| 2071 | |
| 2072 | const integrationsDetect = ( |
| 2073 | url: string, |
no test coverage detected