MCPcopy Index your code
hub / github.com/simstudioai/sim / resolveEffectivePiiRedaction

Function resolveEffectivePiiRedaction

apps/sim/lib/billing/retention.ts:68–99  ·  view source on GitHub ↗
(params: {
  orgSettings: DataRetentionSettings | null | undefined
  workspaceId: string
})

Source from the content-addressed store, hash-verified

66 * workspace-exemption / off shape). Defensive about the loosely-typed JSON column.
67 */
68export function resolveEffectivePiiRedaction(params: {
69 orgSettings: DataRetentionSettings | null | undefined
70 workspaceId: string
71}): EffectivePiiRedaction {
72 const rules = params.orgSettings?.piiRedaction?.rules
73 if (!Array.isArray(rules) || rules.length === 0) return DEFAULT_PII_REDACTION
74
75 const rule =
76 rules.find((r) => r?.workspaceId === params.workspaceId) ??
77 rules.find((r) => r?.workspaceId == null)
78 if (!rule) return DEFAULT_PII_REDACTION
79
80 if (!rule.stages) {
81 const types = sanitizeEntityTypes(rule.entityTypes)
82 if (types.length === 0) return DEFAULT_PII_REDACTION
83 return {
84 input: DISABLED_STAGE,
85 blockOutputs: DISABLED_STAGE,
86 logs: {
87 enabled: true,
88 entityTypes: types,
89 language: coercePiiLanguage(rule.language) ?? DEFAULT_PII_LANGUAGE,
90 },
91 }
92 }
93
94 return {
95 input: toEffectiveStage(rule.stages.input),
96 blockOutputs: toEffectiveStage(rule.stages.blockOutputs),
97 logs: toEffectiveStage(rule.stages.logs),
98 }
99}
100
101export type RetentionHoursKey =
102 | 'logRetentionHours'

Callers 3

applyPiiRedactionMethod · 0.90
executeWorkflowCoreFunction · 0.90
retention.test.tsFile · 0.90

Calls 3

coercePiiLanguageFunction · 0.90
sanitizeEntityTypesFunction · 0.85
toEffectiveStageFunction · 0.85

Tested by

no test coverage detected