(
slug: IntegrationSlug,
)
| 3310 | }); |
| 3311 | |
| 3312 | const integrationsRemove = ( |
| 3313 | slug: IntegrationSlug, |
| 3314 | ): Effect.Effect< |
| 3315 | void, |
| 3316 | IntegrationRemovalNotAllowedError | OrgWriteDeniedError | StorageFailure |
| 3317 | > => |
| 3318 | transaction( |
| 3319 | Effect.gen(function* () { |
| 3320 | yield* guardOrgWrite(); |
| 3321 | const existing = yield* findIntegrationRow(slug); |
| 3322 | if (!existing) return null; |
| 3323 | if (!existing.can_remove) { |
| 3324 | return yield* new IntegrationRemovalNotAllowedError({ slug }); |
| 3325 | } |
| 3326 | const runtime = runtimes.get(existing.plugin_id); |
| 3327 | if (runtime?.plugin.removeIntegration) { |
| 3328 | const authMethods = yield* describeAuthMethodsForRow(existing); |
| 3329 | yield* runtime.plugin |
| 3330 | .removeIntegration({ |
| 3331 | ctx: runtime.ctx, |
| 3332 | integration: rowToIntegrationRecord(existing, authMethods), |
| 3333 | }) |
| 3334 | .pipe( |
| 3335 | Effect.mapError((cause) => |
| 3336 | pluginStorageFailure(existing.plugin_id, "removeIntegration", cause), |
| 3337 | ), |
| 3338 | ); |
| 3339 | } |
| 3340 | // Drop owned connections / tools / definitions for this integration. |
| 3341 | const where = (b: AnyCb) => b("integration", "=", String(slug)); |
| 3342 | yield* core.deleteMany("tool", { where }); |
| 3343 | yield* core.deleteMany("definition", { where }); |
| 3344 | yield* core.deleteMany("connection", { where }); |
| 3345 | yield* core.deleteMany("integration", { |
| 3346 | where: (b: AnyCb) => b("slug", "=", String(slug)), |
| 3347 | }); |
| 3348 | return existing.plugin_id; |
| 3349 | }), |
| 3350 | ).pipe( |
| 3351 | Effect.tap((removedPluginId) => |
| 3352 | removedPluginId !== null |
| 3353 | ? notifyIntegrationChange({ |
| 3354 | kind: "removed", |
| 3355 | pluginKey: removedPluginId, |
| 3356 | slug, |
| 3357 | }) |
| 3358 | : Effect.void, |
| 3359 | ), |
| 3360 | Effect.asVoid, |
| 3361 | ); |
| 3362 | |
| 3363 | const integrationsDetect = ( |
| 3364 | url: string, |
no test coverage detected