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

Function connectionsRemove

packages/core/sdk/src/executor.ts:2524–2569  ·  view source on GitHub ↗
(
      ref: ConnectionRef,
    )

Source from the content-addressed store, hash-verified

2522 });
2523
2524 const connectionsRemove = (
2525 ref: ConnectionRef,
2526 ): Effect.Effect<void, ConnectionNotFoundError | StorageFailure> =>
2527 transaction(
2528 Effect.gen(function* () {
2529 const row = yield* findConnectionRow(ref);
2530 if (!row) {
2531 return yield* new ConnectionNotFoundError({
2532 owner: ref.owner,
2533 integration: ref.integration,
2534 name: ref.name,
2535 });
2536 }
2537 const integrationRow = yield* findIntegrationRow(ref.integration);
2538 const runtime = integrationRow ? runtimes.get(integrationRow.plugin_id) : undefined;
2539 if (integrationRow && runtime?.plugin.removeConnection) {
2540 yield* runtime.plugin
2541 .removeConnection({
2542 ctx: runtime.ctx,
2543 integration: ref.integration,
2544 connection: ref,
2545 })
2546 .pipe(
2547 Effect.mapError((cause) =>
2548 pluginStorageFailure(integrationRow.plugin_id, "removeConnection", cause),
2549 ),
2550 );
2551 }
2552 const where = (b: AnyCb) =>
2553 b.and(
2554 byOwner(ref.owner)(b),
2555 b("integration", "=", String(ref.integration)),
2556 b("connection", "=", String(ref.name)),
2557 );
2558 yield* core.deleteMany("tool", { where });
2559 yield* core.deleteMany("definition", { where });
2560 yield* core.deleteMany("connection", {
2561 where: (b: AnyCb) =>
2562 b.and(
2563 byOwner(ref.owner)(b),
2564 b("integration", "=", String(ref.integration)),
2565 b("name", "=", String(ref.name)),
2566 ),
2567 });
2568 }),
2569 );
2570
2571 const connectionsRefresh = (
2572 ref: ConnectionRef,

Callers 1

createExecutorFunction · 0.85

Calls 6

findConnectionRowFunction · 0.85
findIntegrationRowFunction · 0.85
pluginStorageFailureFunction · 0.85
byOwnerFunction · 0.85
transactionFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected