* Cache-aware wrapper around `getUserPermissionConfig`. When an * `ExecutionContext` is provided, the resolved config is memoized on the * context so repeated checks during a single workflow run share one DB hit.
( userId: string | undefined, workspaceId: string | undefined, ctx?: ExecutionContext )
| 323 | * context so repeated checks during a single workflow run share one DB hit. |
| 324 | */ |
| 325 | async function getPermissionConfig( |
| 326 | userId: string | undefined, |
| 327 | workspaceId: string | undefined, |
| 328 | ctx?: ExecutionContext |
| 329 | ): Promise<PermissionGroupConfig | null> { |
| 330 | if (!userId || !workspaceId) { |
| 331 | return mergeEnvAllowlist(null) |
| 332 | } |
| 333 | |
| 334 | if (ctx) { |
| 335 | if (ctx.permissionConfigLoaded) { |
| 336 | return ctx.permissionConfig ?? null |
| 337 | } |
| 338 | |
| 339 | const config = await getUserPermissionConfig(userId, workspaceId) |
| 340 | ctx.permissionConfig = config |
| 341 | ctx.permissionConfigLoaded = true |
| 342 | return config |
| 343 | } |
| 344 | |
| 345 | return getUserPermissionConfig(userId, workspaceId) |
| 346 | } |
| 347 | |
| 348 | /** |
| 349 | * Returns true when `model` appears in the group's model denylist. Comparison is |
no test coverage detected