Files
maestro/src/utils/cdc.ts
T
RafaelandWOZCODE 27eed59a1f UPDATE: PipelineExecutionGuard decides by the pipeline's explicit connector type
Review (maestro #510): the guard inferred 'editable' from the absence of run
history. It now reads GET /pipeline/{id} (DB only) and short-circuits on
job.input.connector === 'cdc'; batch keeps the pipeline_run check. Adds
src/utils/cdc.ts as the single isCdc* helper.

Co-Authored-By: WOZCODE <contact@withwoz.com>
2026-08-29 12:48:28 -03:00

35 lines
1.1 KiB
TypeScript

/**
* Single source of truth for "is this CDC?" across maestro.
*
* Two shapes carry the discriminator:
* - a connection/input `plugin` (`mysql_cdc`, ...), used before a platform
* pipeline exists (create flows, DynamoDB inputs);
* - a platform job `input.connector === 'cdc'`, the explicit type the
* platform-api stamps on every CDC job.
*
* Keep the plugin list in sync with pi-factory (`CDC_PLUGINS`) and in-factory
* (`cdcPlugins`).
*/
export const CDC_PLUGINS: readonly string[] = ['mysql_cdc', 'postgresql_cdc', 'oracle_cdc'];
export function isCdcPlugin(plugin?: string | null): boolean {
return plugin != null && CDC_PLUGINS.includes(plugin);
}
export interface PlatformJobLike {
input?: { connector?: string } | null;
}
export interface PlatformPipelineLike {
jobs?: PlatformJobLike[] | null;
}
export function isCdcJob(job?: PlatformJobLike | null): boolean {
return job?.input?.connector === 'cdc';
}
/** A pipeline is CDC when any of its platform jobs is a CDC job. */
export function isCdcPipeline(pipeline?: PlatformPipelineLike | null): boolean {
return (pipeline?.jobs ?? []).some((job) => isCdcJob(job));
}