.ts
TypeScript
(application/typescript)
// 3rd-party
import type { FastifyRequest } from "fastify";
// generated via script [prisma:generate]
import type { Artefact, Pipeline, Stage } from "@prisma/client";

// Lightweight shared types for pipeline domain to minimize coupling in MVP.
export type Manifest = { manifest: string; version?: string };

export type PipelineEntity = Pipeline;
export type StageEntity = Stage;
export type ArtefactEntity = Artefact;

export interface PipelineServiceDeps {
  request: FastifyRequest;
  runner: any; // GitfossCIRunnerClient
}

export type PipelineServiceAPI = {
  listByRepo(orgSlug: string, repoSlug: string): Promise<Pipeline[]>;
  listByRepoId(repoId: string): Promise<Pipeline[]>;
  getRepoPipelineManifest(orgSlug: string, repoSlug: string): Promise<Manifest>;
  parsePipelineManifest(manifestJsonOrYml: string): Manifest;
  getPipelineManifest(pipelineId: string): Promise<Manifest>;
  getPipelineStages(pipelineId: string): Promise<Stage[]>;
  getPipelineStageLogs(
    pipelineId: string,
    stageId: string,
  ): Promise<Stage["logs"][]>;
  getPipelineArtefacts(pipelineId: string): Promise<Artefact[]>;
  getPipeline(pipelineId: string): Promise<Pipeline>;
  setPipeline(pipelineId: string, data: Partial<Pipeline>): Promise<Pipeline>;
  rmPipeline(pipelineId: string, reason: string): Promise<Pipeline>;
  initRunnerForRepo(
    orgSlug: string,
    repoSlug: string,
    manifest: string,
  ): Promise<void>;
  triggerRunner(
    orgSlug: string,
    repoSlug: string,
    pipelineId: string,
  ): Promise<Pipeline>;
  cancelRunner(pipelineId: string): Promise<void>;
  resetRunnerCache(orgSlug: string, repoSlug: string): Promise<void>;
};