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

Function connectionsRemove

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

Source from the content-addressed store, hash-verified

3732 });
3733
3734 const connectionsRemove = (
3735 ref: ConnectionRef,
3736 ): Effect.Effect<void, ConnectionNotFoundError | StorageFailure> =>
3737 transaction(
3738 Effect.gen(function* () {
3739 const row = yield* findConnectionRow(ref);
3740 if (!row) {
3741 return yield* new ConnectionNotFoundError({
3742 owner: ref.owner,
3743 integration: ref.integration,
3744 name: ref.name,
3745 });
3746 }
3747 const integrationRow = yield* findIntegrationRow(ref.integration);
3748 const runtime = integrationRow ? runtimes.get(integrationRow.plugin_id) : undefined;
3749 if (integrationRow && runtime?.plugin.removeConnection) {
3750 yield* runtime.plugin
3751 .removeConnection({
3752 ctx: runtime.ctx,
3753 integration: ref.integration,
3754 connection: ref,
3755 })
3756 .pipe(
3757 Effect.mapError((cause) =>
3758 pluginStorageFailure(integrationRow.plugin_id, "removeConnection", cause),
3759 ),
3760 );
3761 }
3762 const where = (b: AnyCb) =>
3763 b.and(
3764 byOwner(ref.owner)(b),
3765 b("integration", "=", String(ref.integration)),
3766 b("connection", "=", String(ref.name)),
3767 );
3768 yield* core.deleteMany("tool", { where });
3769 yield* core.deleteMany("definition", { where });
3770 yield* core.deleteMany("connection", {
3771 where: (b: AnyCb) =>
3772 b.and(
3773 byOwner(ref.owner)(b),
3774 b("integration", "=", String(ref.integration)),
3775 b("name", "=", String(ref.name)),
3776 ),
3777 });
3778 }),
3779 );
3780
3781 const connectionsRefresh = (
3782 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