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

Function connectionsRemove

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

Source from the content-addressed store, hash-verified

2632 });
2633
2634 const connectionsRemove = (
2635 ref: ConnectionRef,
2636 ): Effect.Effect<void, ConnectionNotFoundError | StorageFailure> =>
2637 transaction(
2638 Effect.gen(function* () {
2639 const row = yield* findConnectionRow(ref);
2640 if (!row) {
2641 return yield* new ConnectionNotFoundError({
2642 owner: ref.owner,
2643 integration: ref.integration,
2644 name: ref.name,
2645 });
2646 }
2647 const integrationRow = yield* findIntegrationRow(ref.integration);
2648 const runtime = integrationRow ? runtimes.get(integrationRow.plugin_id) : undefined;
2649 if (integrationRow && runtime?.plugin.removeConnection) {
2650 yield* runtime.plugin
2651 .removeConnection({
2652 ctx: runtime.ctx,
2653 integration: ref.integration,
2654 connection: ref,
2655 })
2656 .pipe(
2657 Effect.mapError((cause) =>
2658 pluginStorageFailure(integrationRow.plugin_id, "removeConnection", cause),
2659 ),
2660 );
2661 }
2662 const where = (b: AnyCb) =>
2663 b.and(
2664 byOwner(ref.owner)(b),
2665 b("integration", "=", String(ref.integration)),
2666 b("connection", "=", String(ref.name)),
2667 );
2668 yield* core.deleteMany("tool", { where });
2669 yield* core.deleteMany("definition", { where });
2670 yield* core.deleteMany("connection", {
2671 where: (b: AnyCb) =>
2672 b.and(
2673 byOwner(ref.owner)(b),
2674 b("integration", "=", String(ref.integration)),
2675 b("name", "=", String(ref.name)),
2676 ),
2677 });
2678 }),
2679 );
2680
2681 const connectionsRefresh = (
2682 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