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

Function integrationsRemove

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

Source from the content-addressed store, hash-verified

3310 });
3311
3312 const integrationsRemove = (
3313 slug: IntegrationSlug,
3314 ): Effect.Effect<
3315 void,
3316 IntegrationRemovalNotAllowedError | OrgWriteDeniedError | StorageFailure
3317 > =>
3318 transaction(
3319 Effect.gen(function* () {
3320 yield* guardOrgWrite();
3321 const existing = yield* findIntegrationRow(slug);
3322 if (!existing) return null;
3323 if (!existing.can_remove) {
3324 return yield* new IntegrationRemovalNotAllowedError({ slug });
3325 }
3326 const runtime = runtimes.get(existing.plugin_id);
3327 if (runtime?.plugin.removeIntegration) {
3328 const authMethods = yield* describeAuthMethodsForRow(existing);
3329 yield* runtime.plugin
3330 .removeIntegration({
3331 ctx: runtime.ctx,
3332 integration: rowToIntegrationRecord(existing, authMethods),
3333 })
3334 .pipe(
3335 Effect.mapError((cause) =>
3336 pluginStorageFailure(existing.plugin_id, "removeIntegration", cause),
3337 ),
3338 );
3339 }
3340 // Drop owned connections / tools / definitions for this integration.
3341 const where = (b: AnyCb) => b("integration", "=", String(slug));
3342 yield* core.deleteMany("tool", { where });
3343 yield* core.deleteMany("definition", { where });
3344 yield* core.deleteMany("connection", { where });
3345 yield* core.deleteMany("integration", {
3346 where: (b: AnyCb) => b("slug", "=", String(slug)),
3347 });
3348 return existing.plugin_id;
3349 }),
3350 ).pipe(
3351 Effect.tap((removedPluginId) =>
3352 removedPluginId !== null
3353 ? notifyIntegrationChange({
3354 kind: "removed",
3355 pluginKey: removedPluginId,
3356 slug,
3357 })
3358 : Effect.void,
3359 ),
3360 Effect.asVoid,
3361 );
3362
3363 const integrationsDetect = (
3364 url: string,

Callers 1

createExecutorFunction · 0.85

Calls 8

guardOrgWriteFunction · 0.85
findIntegrationRowFunction · 0.85
rowToIntegrationRecordFunction · 0.85
pluginStorageFailureFunction · 0.85
notifyIntegrationChangeFunction · 0.85
transactionFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected