feat(ingest): route direct-write connectors through isolated diffs

This commit is contained in:
Andrey Avtomonov 2026-05-18 02:37:26 +02:00
parent a00285fd42
commit 449db1d42a
4 changed files with 91 additions and 1 deletions

View file

@ -0,0 +1,40 @@
import { describe, expect, it } from 'vitest';
import {
defaultIsolatedDiffSourceKeys,
isIsolatedDiffDirectWriteSourceKey,
ISOLATED_DIFF_DIRECT_WRITE_SOURCE_KEYS,
} from './source-routing.js';
describe('isolated-diff source routing', () => {
it('keeps the runner-owned direct-write connector list explicit', () => {
expect(ISOLATED_DIFF_DIRECT_WRITE_SOURCE_KEYS).toEqual([
'metabase',
'notion',
'lookml',
'looker',
'dbt',
'metricflow',
]);
});
it('returns a mutable copy for runtime settings', () => {
const keys = defaultIsolatedDiffSourceKeys();
keys.push('fake');
expect(defaultIsolatedDiffSourceKeys()).toEqual([
'metabase',
'notion',
'lookml',
'looker',
'dbt',
'metricflow',
]);
});
it('recognizes migrated connector source keys only', () => {
expect(isIsolatedDiffDirectWriteSourceKey('notion')).toBe(true);
expect(isIsolatedDiffDirectWriteSourceKey('metricflow')).toBe(true);
expect(isIsolatedDiffDirectWriteSourceKey('historic-sql')).toBe(false);
expect(isIsolatedDiffDirectWriteSourceKey('live-database')).toBe(false);
});
});

View file

@ -0,0 +1,22 @@
export const ISOLATED_DIFF_DIRECT_WRITE_SOURCE_KEYS = [
'metabase',
'notion',
'lookml',
'looker',
'dbt',
'metricflow',
] as const;
export type IsolatedDiffDirectWriteSourceKey = (typeof ISOLATED_DIFF_DIRECT_WRITE_SOURCE_KEYS)[number];
const ISOLATED_DIFF_DIRECT_WRITE_SOURCE_KEY_SET = new Set<string>(ISOLATED_DIFF_DIRECT_WRITE_SOURCE_KEYS);
export function defaultIsolatedDiffSourceKeys(): string[] {
return [...ISOLATED_DIFF_DIRECT_WRITE_SOURCE_KEYS];
}
export function isIsolatedDiffDirectWriteSourceKey(
sourceKey: string,
): sourceKey is IsolatedDiffDirectWriteSourceKey {
return ISOLATED_DIFF_DIRECT_WRITE_SOURCE_KEY_SET.has(sourceKey);
}