mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2026-09-02 21:03:34 +03:00
Resolve duplicates between policies and pipelines
This commit is contained in:
@@ -3,6 +3,11 @@ import {
|
||||
type SupportingFileBindings,
|
||||
type ToolApiStep,
|
||||
} from "@app/hooks/tools/shared/toolAutomation";
|
||||
import type {
|
||||
PolicyRunView,
|
||||
PolicyRunStatus,
|
||||
RunOutputFile,
|
||||
} from "@app/policies/types";
|
||||
|
||||
/**
|
||||
* Pipelines service layer: the backend contract.
|
||||
@@ -132,37 +137,10 @@ export interface TriggerInfo {
|
||||
supportedSourceTypes: string[];
|
||||
}
|
||||
|
||||
export type PolicyRunStatus =
|
||||
| "PENDING"
|
||||
| "RUNNING"
|
||||
| "WAITING_FOR_INPUT"
|
||||
| "COMPLETED"
|
||||
| "FAILED"
|
||||
| "CANCELLED";
|
||||
|
||||
/** One file a run produced, downloadable via /api/v1/general/files/{fileId}. */
|
||||
export interface RunOutputFile {
|
||||
fileId: string;
|
||||
fileName: string | null;
|
||||
}
|
||||
|
||||
/** A run's current state. Mirrors the backend `PolicyRunView`. */
|
||||
export interface PolicyRunView {
|
||||
runId: string;
|
||||
policyId: string | null;
|
||||
status: PolicyRunStatus;
|
||||
currentStep: number;
|
||||
stepCount: number;
|
||||
/** Human-readable failure message; set when status is FAILED. */
|
||||
error: string | null;
|
||||
errorCode: string | null;
|
||||
/**
|
||||
* Files the run produced, present once it completes. Whole-run, not per step: the backend keeps
|
||||
* one flat list, so nothing here can be attributed to an individual step.
|
||||
*/
|
||||
outputs?: RunOutputFile[] | null;
|
||||
createdAt: number;
|
||||
}
|
||||
// One run view for the whole app: the builder test-run poll and the catalogue runs list read the
|
||||
// same backend PolicyRunView, so the type is defined once in the codec (imported above) and
|
||||
// re-exported here for callers that reach it through the pipelines API.
|
||||
export type { PolicyRunView, PolicyRunStatus, RunOutputFile };
|
||||
|
||||
/** GET /api/v1/policies/overview: KPI strip + one row per policy for the admin. */
|
||||
export async function fetchPipelines(): Promise<PipelinesOverviewResponse> {
|
||||
|
||||
@@ -47,7 +47,7 @@ function activityAction(run: PolicyRunView): string {
|
||||
|
||||
export function runsToActivity(runs: PolicyRunView[]): PolicyActivityItem[] {
|
||||
return runs.map((run) => ({
|
||||
doc: run.outputs[0]?.fileName ?? "Policy run",
|
||||
doc: run.outputs?.[0]?.fileName ?? "Policy run",
|
||||
action: activityAction(run),
|
||||
time: relativeTime(run.createdAt),
|
||||
status: activityStatus(run),
|
||||
|
||||
@@ -70,6 +70,12 @@ export type PolicyRunStatus =
|
||||
| "FAILED"
|
||||
| "CANCELLED";
|
||||
|
||||
/** One file a run produced, downloadable via /api/v1/general/files/{fileId}. */
|
||||
export interface RunOutputFile {
|
||||
fileId: string;
|
||||
fileName: string | null;
|
||||
}
|
||||
|
||||
export interface PolicyRunView {
|
||||
runId: string;
|
||||
policyId: string | null;
|
||||
@@ -79,7 +85,7 @@ export interface PolicyRunView {
|
||||
error: string | null;
|
||||
errorCode?: string | null;
|
||||
errorSubscribed?: boolean | null;
|
||||
outputs: { fileId: string; fileName: string }[];
|
||||
outputs?: RunOutputFile[] | null;
|
||||
/** Creation timestamp in epoch milliseconds. */
|
||||
createdAt: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user