* Expand a stored stage policy into its effective form. A stage redacts nothing * unless it is enabled AND names at least one entity type. "Redact all" is not an * expressible policy (the checkbox UI has no such control, and the contract * rejects enabled-with-no-types), so an empty entity list a
(policy: PiiStagePolicy | undefined)
| 45 | * consistent across the UI, the contract, and the masking layer. |
| 46 | */ |
| 47 | function toEffectiveStage(policy: PiiStagePolicy | undefined): EffectivePiiStage { |
| 48 | const types = sanitizeEntityTypes(policy?.entityTypes) |
| 49 | if (!policy?.enabled || types.length === 0) return DISABLED_STAGE |
| 50 | return { |
| 51 | enabled: true, |
| 52 | entityTypes: types, |
| 53 | language: coercePiiLanguage(policy.language) ?? DEFAULT_PII_LANGUAGE, |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Resolve the effective per-stage PII redaction policy for a workspace from the |
no test coverage detected