/* * The `twin-reference-progress` channel — **progress says whose import it is, and the filter asks.** Pure. * * The subscription filtered on `source` alone and checked only that the caller had some domain, so * anyone who knew a source name — and names like `sap-ewm-1710` are shared between tenants — received * another tenant's import progress, including its failure text. Same fix and same rule as * `engine/twin-state-channel.ts`. */ export const REFERENCE_PROGRESS_TOPIC = 'twin-reference-progress' export interface ReferenceProgressPayload { domainId: string twinReferenceProgress: M } export function referenceProgressPayload(domainId: string, message: M): ReferenceProgressPayload { if (!domainId) throw new Error('referenceProgressPayload: domainId is required — import progress always belongs to a tenant') return { domainId, twinReferenceProgress: message } } /** Passes only this tenant's progress for this source. */ export function referenceProgressFilter(domainId: string, source: string) { return (p: ReferenceProgressPayload | undefined): boolean => !!p && p.domainId === domainId && p.twinReferenceProgress?.source === source }