/** * apps/worker โ€” CALL_INTEGRATION executor (TASK-0112 ยง2, STUB). * * Config is schema-validated (the UI can build these now); at runtime the * executor looks up the adapter registry and โ€” until Phase 13 lands the * adapters โ€” fails with the FATAL INTEGRATION_NOT_AVAILABLE (Phase 13). The * run is recorded FAILED with that code in error.code; the integration row * is still fetched so a missing row is a distinct INTEGRATION_NOT_FOUND. */ import { FatalError } from "./classify.js"; import { adapterFor } from "./integration-registry.js"; import type { ActionExecutor, ActionResult } from "./types.js"; const executor: ActionExecutor = { type: "CALL_INTEGRATION", async execute(cfg, ctx, deps): Promise { const integrationId = cfg.integrationId as string; const integration = await deps.prisma.integration.findFirst({ where: { id: integrationId, workspaceId: ctx.workspaceId }, select: { id: true, provider: true, status: true } }); if (!integration) throw new FatalError("INTEGRATION_NOT_FOUND", `integration ${integrationId} not found`); const adapter = adapterFor(integration.provider); if (!adapter) { throw new FatalError("INTEGRATION_NOT_AVAILABLE", `no adapter for provider "${integration.provider}" (Phase 13)`); } // Phase-13 path (unreachable until adapters are registered). const result = await adapter.execute(cfg as never, ctx, deps); return result; } }; export default executor;