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

Function integrationsRemove

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

Source from the content-addressed store, hash-verified

2376 });
2377
2378 const integrationsRemove = (
2379 slug: IntegrationSlug,
2380 ): Effect.Effect<void, IntegrationRemovalNotAllowedError | StorageFailure> =>
2381 transaction(
2382 Effect.gen(function* () {
2383 const existing = yield* findIntegrationRow(slug);
2384 if (!existing) return null;
2385 if (!existing.can_remove) {
2386 return yield* new IntegrationRemovalNotAllowedError({ slug });
2387 }
2388 const runtime = runtimes.get(existing.plugin_id);
2389 if (runtime?.plugin.removeIntegration) {
2390 yield* runtime.plugin
2391 .removeIntegration({
2392 ctx: runtime.ctx,
2393 integration: rowToIntegrationRecord(existing, describeAuthMethodsForRow(existing)),
2394 })
2395 .pipe(
2396 Effect.mapError((cause) =>
2397 pluginStorageFailure(existing.plugin_id, "removeIntegration", cause),
2398 ),
2399 );
2400 }
2401 // Drop owned connections / tools / definitions for this integration.
2402 const where = (b: AnyCb) => b("integration", "=", String(slug));
2403 yield* core.deleteMany("tool", { where });
2404 yield* core.deleteMany("definition", { where });
2405 yield* core.deleteMany("connection", { where });
2406 yield* core.deleteMany("integration", {
2407 where: (b: AnyCb) => b("slug", "=", String(slug)),
2408 });
2409 return existing.plugin_id;
2410 }),
2411 ).pipe(
2412 Effect.tap((removedPluginId) =>
2413 removedPluginId !== null
2414 ? notifyIntegrationChange({ kind: "removed", pluginKey: removedPluginId, slug })
2415 : Effect.void,
2416 ),
2417 Effect.asVoid,
2418 );
2419
2420 const integrationsDetect = (
2421 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