Phase A (P1 production blockers): - A1: Apply IP rate limiting to public routes (login/refresh) - A2: Publish domain events for workflow instance state transitions (completed/suspended/resumed/terminated) via outbox pattern - A3: Replace hardcoded nil UUID default tenant with dynamic DB lookup - A4: Add GET /api/v1/audit-logs query endpoint with pagination - A5: Enhance CORS wildcard warning for production environments Phase B (P2 functional gaps): - B1: Remove dead erp-common crate (zero references in codebase) - B2: Refactor 5 settings pages to use typed API modules instead of direct client calls; create api/themes.ts; delete dead errors.ts - B3: Add resume/suspend buttons to InstanceMonitor page - B4: Remove unused EventHandler trait from erp-core - B5: Handle task.completed events in message module (send notifications) - B6: Wire TimeoutChecker as 60s background task - B7: Auto-skip ServiceTask nodes instead of crashing the process - B8: Remove empty register_routes() from ErpModule trait and modules
73 lines
1.8 KiB
TypeScript
73 lines
1.8 KiB
TypeScript
import client from './client';
|
|
import type { PaginatedResponse } from './users';
|
|
|
|
export interface TokenInfo {
|
|
id: string;
|
|
node_id: string;
|
|
status: string;
|
|
created_at: string;
|
|
}
|
|
|
|
export interface ProcessInstanceInfo {
|
|
id: string;
|
|
definition_id: string;
|
|
definition_name?: string;
|
|
business_key?: string;
|
|
status: string;
|
|
started_by: string;
|
|
started_at: string;
|
|
completed_at?: string;
|
|
created_at: string;
|
|
active_tokens: TokenInfo[];
|
|
}
|
|
|
|
export interface StartInstanceRequest {
|
|
definition_id: string;
|
|
business_key?: string;
|
|
variables?: Array<{ name: string; var_type?: string; value: unknown }>;
|
|
}
|
|
|
|
export async function startInstance(req: StartInstanceRequest) {
|
|
const { data } = await client.post<{ success: boolean; data: ProcessInstanceInfo }>(
|
|
'/workflow/instances',
|
|
req,
|
|
);
|
|
return data.data;
|
|
}
|
|
|
|
export async function listInstances(page = 1, pageSize = 20) {
|
|
const { data } = await client.get<{ success: boolean; data: PaginatedResponse<ProcessInstanceInfo> }>(
|
|
'/workflow/instances',
|
|
{ params: { page, page_size: pageSize } },
|
|
);
|
|
return data.data;
|
|
}
|
|
|
|
export async function getInstance(id: string) {
|
|
const { data } = await client.get<{ success: boolean; data: ProcessInstanceInfo }>(
|
|
`/workflow/instances/${id}`,
|
|
);
|
|
return data.data;
|
|
}
|
|
|
|
export async function suspendInstance(id: string) {
|
|
const { data } = await client.post<{ success: boolean; data: null }>(
|
|
`/workflow/instances/${id}/suspend`,
|
|
);
|
|
return data.data;
|
|
}
|
|
|
|
export async function resumeInstance(id: string) {
|
|
const { data } = await client.post<{ success: boolean; data: null }>(
|
|
`/workflow/instances/${id}/resume`,
|
|
);
|
|
return data.data;
|
|
}
|
|
|
|
export async function terminateInstance(id: string) {
|
|
const { data } = await client.post<{ success: boolean; data: null }>(
|
|
`/workflow/instances/${id}/terminate`,
|
|
);
|
|
return data.data;
|
|
}
|