mirror of
https://github.com/dadosfera/maestro.git
synced 2026-10-24 20:49:07 +00:00
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>
35 lines
1.1 KiB
TypeScript
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));
|
|
}
|