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

Function connectionsRemove

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

Source from the content-addressed store, hash-verified

4702 );
4703
4704 const connectionsRemove = (
4705 ref: ConnectionRef,
4706 ): Effect.Effect<void, ConnectionNotFoundError | OrgWriteDeniedError | StorageFailure> =>
4707 transaction(
4708 Effect.gen(function* () {
4709 yield* guardOrgWrite(ref.owner);
4710 const row = yield* findConnectionRow(ref);
4711 if (!row) {
4712 return yield* new ConnectionNotFoundError({
4713 owner: ref.owner,
4714 integration: ref.integration,
4715 name: ref.name,
4716 });
4717 }
4718 const integrationRow = yield* findIntegrationRow(ref.integration);
4719 const runtime = integrationRow ? runtimes.get(integrationRow.plugin_id) : undefined;
4720 if (integrationRow && runtime?.plugin.removeConnection) {
4721 yield* runtime.plugin
4722 .removeConnection({
4723 ctx: runtime.ctx,
4724 integration: ref.integration,
4725 connection: ref,
4726 })
4727 .pipe(
4728 Effect.mapError((cause) =>
4729 pluginStorageFailure(integrationRow.plugin_id, "removeConnection", cause),
4730 ),
4731 );
4732 }
4733 const where = (b: AnyCb) =>
4734 b.and(
4735 byOwner(ref.owner)(b),
4736 b("integration", "=", String(ref.integration)),
4737 b("connection", "=", String(ref.name)),
4738 );
4739 yield* core.deleteMany("tool", { where });
4740 yield* core.deleteMany("definition", { where });
4741 yield* core.deleteMany("connection", {
4742 where: (b: AnyCb) =>
4743 b.and(
4744 byOwner(ref.owner)(b),
4745 b("integration", "=", String(ref.integration)),
4746 b("name", "=", String(ref.name)),
4747 ),
4748 });
4749 }),
4750 );
4751
4752 const connectionsRefresh = (
4753 ref: ConnectionRef,

Callers 1

createExecutorFunction · 0.85

Calls 7

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

Tested by

no test coverage detected