UNPKG

@puls-atlas/cli

Version:

The Puls Atlas CLI tool for managing Atlas projects

29 lines 1.61 kB
import { normalizeOptionalString } from '../../../utils/value.js'; const hasSourceBeforeAfterSemantics = sourceConfig => normalizeOptionalString(sourceConfig?.type) === 'firestore' || normalizeOptionalString(sourceConfig?.incremental?.mapping?.beforePath) !== null; const hasSourceDeleteSemantics = sourceConfig => { const sourceType = normalizeOptionalString(sourceConfig?.type); const syncClass = normalizeOptionalString(sourceConfig?.syncClass); const deleteStrategy = normalizeOptionalString(sourceConfig?.incremental?.deleteStrategy); const deletedPath = normalizeOptionalString(sourceConfig?.incremental?.mapping?.deletedPath); if (sourceType === 'firestore') { return true; } if (syncClass !== 'delta-merge') { return false; } return deleteStrategy !== null && deleteStrategy !== 'none' || deletedPath !== null; }; export const resolveSearchSourceCapabilities = sourceConfig => { const promotionMode = normalizeOptionalString(sourceConfig?.promotion?.mode); const sourceType = normalizeOptionalString(sourceConfig?.type); const syncClass = normalizeOptionalString(sourceConfig?.syncClass); return { supportsAutomaticPromotion: syncClass === 'snapshot-replace' && promotionMode !== 'manual', supportsBackfill: sourceType === 'firestore', supportsBeforeAfter: hasSourceBeforeAfterSemantics(sourceConfig), supportsDeletes: hasSourceDeleteSemantics(sourceConfig), supportsIncremental: syncClass === 'delta-merge' || syncClass === 'append-only', supportsSnapshot: syncClass === 'snapshot-replace' }; }; export default resolveSearchSourceCapabilities;