@graphql-hive/laboratory
Version:
35 lines (34 loc) • 1.23 kB
TypeScript
import { LaboratoryOperation } from './operations';
export interface LaboratoryTestTaskBase {
id: string;
next: string | null;
}
export interface LaboratoryTestTaskOperation extends LaboratoryTestTaskBase {
type: "operation";
data: Pick<LaboratoryOperation, "id">;
}
export interface LaboratoryTestTaskUtlity extends LaboratoryTestTaskBase {
type: "utility";
data: unknown;
}
export type LaboratoryTestTask = LaboratoryTestTaskOperation | LaboratoryTestTaskUtlity;
export interface LaboratoryTest {
id: string;
name: string;
description?: string;
createdAt: string;
tasks: LaboratoryTestTask[];
}
export interface LaboratoryTestState {
tests: LaboratoryTest[];
}
export interface LaboratoryTestActions {
addTest: (test: Omit<LaboratoryTest, "id" | "createdAt" | "tasks">) => LaboratoryTest;
addTaskToTest: (testId: string, task: Pick<LaboratoryTestTask, "type" | "data">) => void;
deleteTaskFromTest: (testId: string, taskId: string) => void;
deleteTest: (testId: string) => void;
}
export declare const useTests: (props: {
defaultTests?: LaboratoryTest[];
onTestsChange?: (test: LaboratoryTest[]) => void;
}) => LaboratoryTestState & LaboratoryTestActions;