Μετάβαση στο περιεχόμενο

interpolateConditions

Αυτό το περιεχόμενο δεν είναι ακόμη διαθέσιμο στη γλώσσα σου.

interpolateConditions(conditions, principal): Record<string, unknown>

Defined in: packages/pipeline-casl/src/helpers/ability.ts:74

Resolve template placeholders in a Capability’s conditions against the current CaslPrincipal.

A capability’s conditions, whether supplied as an object or parsed from a compact string, may contain placeholders like ${user.id} or ${user.tenantId} (or {{ property }} syntax). At runtime, before CASL can evaluate the rule, this function replaces each placeholder with the real value from the authenticated principal.

Supports nested property access via dot notation (e.g. ${address.city}).

A placeholder that cannot be resolved against the principal, or that resolves to anything other than a string, number, boolean, null or an array of those, throws rather than collapsing to an empty string or injecting query operators. This fails closed: a condition such as { department: '${department}' } can never silently become { department: '' } and match unintended records.

Record<string, unknown>

CaslPrincipal

Record<string, unknown>

When a placeholder references a property absent from the principal or resolves to an object.

interpolateConditions({ authorId: '${user.id}' }, { id: 'u-1' })
// → { authorId: 'u-1' }
interpolateConditions({ level: '${level}' }, { id: 'u-1', level: 3 })
// → { level: 3 }