(
slug: IntegrationSlug,
)
| 3126 | }); |
| 3127 | |
| 3128 | const integrationsRemove = ( |
| 3129 | slug: IntegrationSlug, |
| 3130 | ): Effect.Effect<void, IntegrationRemovalNotAllowedError | StorageFailure> => |
| 3131 | transaction( |
| 3132 | Effect.gen(function* () { |
| 3133 | const existing = yield* findIntegrationRow(slug); |
| 3134 | if (!existing) return null; |
| 3135 | if (!existing.can_remove) { |
| 3136 | return yield* new IntegrationRemovalNotAllowedError({ slug }); |
| 3137 | } |
| 3138 | const runtime = runtimes.get(existing.plugin_id); |
| 3139 | if (runtime?.plugin.removeIntegration) { |
| 3140 | yield* runtime.plugin |
| 3141 | .removeIntegration({ |
| 3142 | ctx: runtime.ctx, |
| 3143 | integration: rowToIntegrationRecord(existing, describeAuthMethodsForRow(existing)), |
| 3144 | }) |
| 3145 | .pipe( |
| 3146 | Effect.mapError((cause) => |
| 3147 | pluginStorageFailure(existing.plugin_id, "removeIntegration", cause), |
| 3148 | ), |
| 3149 | ); |
| 3150 | } |
| 3151 | // Drop owned connections / tools / definitions for this integration. |
| 3152 | const where = (b: AnyCb) => b("integration", "=", String(slug)); |
| 3153 | yield* core.deleteMany("tool", { where }); |
| 3154 | yield* core.deleteMany("definition", { where }); |
| 3155 | yield* core.deleteMany("connection", { where }); |
| 3156 | yield* core.deleteMany("integration", { |
| 3157 | where: (b: AnyCb) => b("slug", "=", String(slug)), |
| 3158 | }); |
| 3159 | return existing.plugin_id; |
| 3160 | }), |
| 3161 | ).pipe( |
| 3162 | Effect.tap((removedPluginId) => |
| 3163 | removedPluginId !== null |
| 3164 | ? notifyIntegrationChange({ kind: "removed", pluginKey: removedPluginId, slug }) |
| 3165 | : Effect.void, |
| 3166 | ), |
| 3167 | Effect.asVoid, |
| 3168 | ); |
| 3169 | |
| 3170 | const integrationsDetect = ( |
| 3171 | url: string, |
no test coverage detected