This commit is contained in:
Marshal
2026-07-15 13:29:01 +00:00
parent c71a0043d6
commit 19c9da28ae
59 changed files with 3008 additions and 284 deletions

View File

@@ -24,6 +24,30 @@ export interface RuleEngineReorderPayload {
requiresDirectorApproval?: boolean;
}
/** Priority-rule approval workflow (all priority-config changes go through it). */
const PRIORITY_RULE_CHANGES_BASE = "/priority-rule-change-requests";
export interface PriorityRuleChangeRequest {
id: string;
action: "CREATE" | "UPDATE" | "DELETE";
priorityConfigId: string | null;
priorityConfig?: RuleEngineRecord | null;
payload: Record<string, unknown> | null;
status: "PENDING" | "APPROVED" | "REJECTED";
requestedByUserId: string | null;
decidedByUserId: string | null;
decidedAt: string | null;
decisionNote: string | null;
createdAt: string;
}
export interface SubmitPriorityRuleChangePayload {
action: "CREATE" | "UPDATE" | "DELETE";
priorityConfigId?: string;
create?: Record<string, unknown>;
update?: Record<string, unknown>;
}
const RESOURCE_BASE: Record<RuleEngineResourceSlug, string> = {
"cargo-types": URL_CONSTANTS.RULE_ENGINE.CARGO_TYPES,
"container-types": URL_CONSTANTS.RULE_ENGINE.CONTAINER_TYPES,
@@ -242,6 +266,46 @@ export const ruleEngineService = {
return normalizeEntity<T>(response.data);
},
/** File a priority-rule change (create/update/delete) for approval. */
submitPriorityRuleChange: async (
payload: SubmitPriorityRuleChangePayload,
): Promise<PriorityRuleChangeRequest> => {
const response = await client.post(PRIORITY_RULE_CHANGES_BASE, payload);
return unwrap(response.data) as PriorityRuleChangeRequest;
},
listPriorityRuleChanges: async (
status?: PriorityRuleChangeRequest["status"],
): Promise<PriorityRuleChangeRequest[]> => {
const response = await client.get(PRIORITY_RULE_CHANGES_BASE, {
params: status ? { status } : undefined,
});
const body = unwrap(response.data) as unknown;
return Array.isArray(body) ? (body as PriorityRuleChangeRequest[]) : [];
},
approvePriorityRuleChange: async (
id: string,
decisionNote?: string,
): Promise<PriorityRuleChangeRequest> => {
const response = await client.post(
`${PRIORITY_RULE_CHANGES_BASE}/${id}/approve`,
{ decisionNote },
);
return unwrap(response.data) as PriorityRuleChangeRequest;
},
rejectPriorityRuleChange: async (
id: string,
decisionNote?: string,
): Promise<PriorityRuleChangeRequest> => {
const response = await client.post(
`${PRIORITY_RULE_CHANGES_BASE}/${id}/reject`,
{ decisionNote },
);
return unwrap(response.data) as PriorityRuleChangeRequest;
},
getApprovalChain: async (
requiresDirectorApproval = true,
): Promise<RuleEngineRecord[]> => {