mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 15:30:56 +00:00
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { applyDecorators, UseGuards } from '@nestjs/common';
|
|
import { JwtGuard } from '@tria-plc/api-common/modules/auth/services/jwt.guard';
|
|
|
|
import { FreightPermissionGuard } from './freight-permission.guard';
|
|
import {
|
|
FREIGHT_PERMS,
|
|
type RuleEngineApprovableSlug,
|
|
type RuleEngineResourceSlug,
|
|
} from '../seed/freight-permissions.registry';
|
|
|
|
export const RuleEngineView = (slug: RuleEngineResourceSlug) =>
|
|
applyDecorators(
|
|
UseGuards(JwtGuard, FreightPermissionGuard([FREIGHT_PERMS.ruleEngine.view(slug)])),
|
|
);
|
|
|
|
export const RuleEngineManage = (slug: RuleEngineResourceSlug) =>
|
|
applyDecorators(
|
|
UseGuards(JwtGuard, FreightPermissionGuard([FREIGHT_PERMS.ruleEngine.manage(slug)])),
|
|
);
|
|
|
|
/**
|
|
* Deciding a filed change — a step above `manage`, which only lets a staff
|
|
* member propose one. Super admins pass any freight permission check, so
|
|
* approvals work before the permission is granted to a director role.
|
|
*/
|
|
export const RuleEngineApprove = (slug: RuleEngineApprovableSlug) =>
|
|
applyDecorators(
|
|
UseGuards(JwtGuard, FreightPermissionGuard([FREIGHT_PERMS.ruleEngine.approve(slug)])),
|
|
);
|