All files / src/utils deletedPlaceholder.ts

100% Statements 3/3
100% Branches 2/2
100% Functions 2/2
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16            10x     162x       10x    
// Mirrors flows-api/infrastructure/lambda/utils/deletedPlaceholder.js.
// A mandatory reference field (user / entity_ref / select) whose target was
// deleted gets its value replaced server-side with a short placeholder string
// carrying this prefix, e.g. "::deleted::Removed member (…a1b2c3)". The UI
// strips the prefix and renders the remaining label with a muted style
// instead of showing the raw internal marker.
const DELETED_PLACEHOLDER_PREFIX = '::deleted::'
 
export function isDeletedPlaceholder(value: unknown): value is string {
  return typeof value === 'string' && value.startsWith(DELETED_PLACEHOLDER_PREFIX)
}
 
export function stripDeletedPlaceholder(value: string): string {
  return value.slice(DELETED_PLACEHOLDER_PREFIX.length)
}