MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / integrationsRemove

Function integrationsRemove

packages/core/sdk/src/executor.ts:2297–2337  ·  view source on GitHub ↗
(
      slug: IntegrationSlug,
    )

Source from the content-addressed store, hash-verified

2295 });
2296
2297 const integrationsRemove = (
2298 slug: IntegrationSlug,
2299 ): Effect.Effect<void, IntegrationRemovalNotAllowedError | StorageFailure> =>
2300 transaction(
2301 Effect.gen(function* () {
2302 const existing = yield* findIntegrationRow(slug);
2303 if (!existing) return null;
2304 if (!existing.can_remove) {
2305 return yield* new IntegrationRemovalNotAllowedError({ slug });
2306 }
2307 const runtime = runtimes.get(existing.plugin_id);
2308 if (runtime?.plugin.removeIntegration) {
2309 yield* runtime.plugin
2310 .removeIntegration({
2311 ctx: runtime.ctx,
2312 integration: rowToIntegrationRecord(existing, describeAuthMethodsForRow(existing)),
2313 })
2314 .pipe(
2315 Effect.mapError((cause) =>
2316 pluginStorageFailure(existing.plugin_id, "removeIntegration", cause),
2317 ),
2318 );
2319 }
2320 // Drop owned connections / tools / definitions for this integration.
2321 const where = (b: AnyCb) => b("integration", "=", String(slug));
2322 yield* core.deleteMany("tool", { where });
2323 yield* core.deleteMany("definition", { where });
2324 yield* core.deleteMany("connection", { where });
2325 yield* core.deleteMany("integration", {
2326 where: (b: AnyCb) => b("slug", "=", String(slug)),
2327 });
2328 return existing.plugin_id;
2329 }),
2330 ).pipe(
2331 Effect.tap((removedPluginId) =>
2332 removedPluginId !== null
2333 ? notifyIntegrationChange({ kind: "removed", pluginKey: removedPluginId, slug })
2334 : Effect.void,
2335 ),
2336 Effect.asVoid,
2337 );
2338
2339 const integrationsDetect = (
2340 url: string,

Callers 1

createExecutorFunction · 0.85

Calls 7

findIntegrationRowFunction · 0.85
rowToIntegrationRecordFunction · 0.85
pluginStorageFailureFunction · 0.85
notifyIntegrationChangeFunction · 0.85
transactionFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected