import { Field, ObjectType, InputType, Int, Float } from 'type-graphql' // ============================================================================ // Project Types // ============================================================================ @ObjectType({ description: 'Label Studio project information' }) export class LabelStudioProject { @Field(type => Int, { description: 'Project ID' }) id: number @Field({ description: 'Project title' }) title: string @Field({ nullable: true, description: 'Project description' }) description?: string @Field({ description: 'Label configuration XML' }) labelConfig: string @Field({ nullable: true, description: 'Expert instruction' }) expertInstruction?: string @Field(type => Int, { description: 'Number of tasks' }) taskCount: number @Field(type => Int, { description: 'Number of completed tasks' }) completedTaskCount: number @Field(type => Float, { description: 'Completion rate (0-1)' }) completionRate: number @Field({ nullable: true, description: 'Created date' }) createdAt: Date @Field({ nullable: true, description: 'Updated date' }) updatedAt: Date } @InputType({ description: 'Input for creating Label Studio project' }) export class CreateProjectInput { @Field({ description: 'Project title' }) title: string @Field({ nullable: true, description: 'Project description' }) description?: string @Field({ description: 'Label configuration XML' }) labelConfig: string @Field({ nullable: true, description: 'Expert instruction' }) expertInstruction?: string } @InputType({ description: 'Label config specification for flexible project creation' }) export class LabelConfigSpecInput { @Field({ description: 'Data type (image, text, audio, video, timeseries, html, hypertext)' }) dataType: string @Field({ nullable: true, description: 'Data name (default: data)' }) dataName?: string @Field({ description: 'Control specifications as JSON array' }) controls: string } @InputType({ description: 'Input for creating project with flexible config builder' }) export class CreateProjectWithSpecInput { @Field({ description: 'Project title' }) title: string @Field({ nullable: true, description: 'Project description' }) description?: string @Field({ description: 'Label config specification' }) labelConfigSpec: LabelConfigSpecInput @Field({ nullable: true, description: 'Expert instruction' }) expertInstruction?: string } @InputType({ description: 'Export annotations input' }) export class ExportAnnotationsInput { @Field({ description: 'Export format (json, jsonl, csv, rank-csv, coco, yolo, ner-json)' }) format: string @Field({ nullable: true, description: 'Filter by task IDs' }) taskIds?: string } @ObjectType({ description: 'Annotation export result' }) export class AnnotationExportResult { @Field({ description: 'Exported data as JSON string' }) data: string @Field(type => Int, { description: 'Number of annotations exported' }) count: number @Field({ description: 'Export format used' }) format: string } // ============================================================================ // Task Types // ============================================================================ @ObjectType({ description: 'Label Studio task' }) export class LabelStudioTask { @Field(type => Int, { description: 'Task ID' }) id: number @Field({ description: 'Task data (JSON)' }) data: string @Field(type => Int, { description: 'Number of annotations' }) annotationCount: number @Field({ description: 'Is task completed' }) isCompleted: boolean @Field({ nullable: true, description: 'Task created date' }) createdAt?: Date } @InputType({ description: 'Input for creating tasks' }) export class TaskDataInput { @Field({ description: 'Task data as JSON string' }) data: string } @InputType({ description: 'Task transformation rule for flexible data import' }) export class TaskTransformRuleInput { @Field({ description: 'Field mapping as JSON (Label Studio field -> source path)' }) dataFields: string @Field({ nullable: true, description: 'Prediction configuration as JSON' }) predictions?: string @Field({ nullable: true, description: 'Metadata mapping as JSON' }) meta?: string } @InputType({ description: 'Input for importing tasks with transformation' }) export class ImportTasksWithTransformInput { @Field({ description: 'Source data as JSON array string' }) sourceData: string @Field({ description: 'Transformation rule' }) transformRule: TaskTransformRuleInput } @ObjectType({ description: 'Result of task import operation' }) export class TaskImportResult { @Field(type => Int, { description: 'Number of tasks imported' }) imported: number @Field(type => Int, { description: 'Number of tasks failed' }) failed: number @Field(type => [Int], { description: 'IDs of imported tasks' }) taskIds: number[] @Field(type => [String], { nullable: true, description: 'Error messages' }) errors?: string[] } // ============================================================================ // Annotation Types // ============================================================================ @ObjectType({ description: 'Label Studio annotation' }) export class LabelStudioAnnotation { @Field(type => Int, { description: 'Annotation ID' }) id: number @Field(type => Int, { description: 'Task ID' }) taskId: number @Field({ description: 'Annotation result (JSON)' }) result: string @Field({ description: 'Completed by user email' }) completedBy: string @Field({ description: 'Created date' }) createdAt: Date @Field({ nullable: true, description: 'Lead time in seconds' }) leadTime?: number } // ============================================================================ // Prediction Types // ============================================================================ @ObjectType({ description: 'Label Studio prediction (AI pre-annotation)' }) export class LabelStudioPrediction { @Field(type => Int, { description: 'Prediction ID' }) id: number @Field(type => Int, { description: 'Task ID' }) taskId: number @Field({ description: 'Prediction result (JSON)' }) result: string @Field(type => Float, { nullable: true, description: 'Prediction confidence score (0-1)' }) score?: number @Field({ nullable: true, description: 'Model version that generated this prediction' }) modelVersion?: string @Field({ nullable: true, description: 'Created date' }) createdAt?: Date } @InputType({ description: 'Input for creating a prediction' }) export class PredictionInput { @Field(type => Int, { description: 'Task ID to create prediction for' }) taskId: number @Field({ description: 'Prediction result as JSON string' }) result: string @Field(type => Float, { nullable: true, description: 'Prediction confidence score (0-1)' }) score?: number @Field({ nullable: true, description: 'Model version' }) modelVersion?: string } @InputType({ description: 'Input for bulk prediction creation' }) export class BulkPredictionInput { @Field(type => Int, { description: 'Task ID' }) taskId: number @Field({ description: 'Prediction result as JSON string' }) result: string @Field(type => Float, { nullable: true, description: 'Prediction confidence score (0-1)' }) score?: number @Field({ nullable: true, description: 'Model version' }) modelVersion?: string } @ObjectType({ description: 'Result of prediction import operation' }) export class PredictionImportResult { @Field(type => Int, { description: 'Number of predictions created' }) created: number @Field(type => Int, { description: 'Number of predictions failed' }) failed: number @Field(type => [String], { nullable: true, description: 'Error messages' }) errors?: string[] } @ObjectType({ description: 'Export result' }) export class ExportResult { @Field({ description: 'Export file path or URL' }) exportPath: string @Field(type => Int, { description: 'Number of annotations exported' }) annotationCount: number @Field({ description: 'Export format (JSON, CSV, YOLO, etc.)' }) format: string } // ============================================================================ // Analytics Types // ============================================================================ @ObjectType({ description: 'Project metrics and statistics' }) export class ProjectMetrics { @Field(type => Int, { description: 'Total number of tasks' }) totalTasks: number @Field(type => Int, { description: 'Number of completed tasks' }) completedTasks: number @Field(type => Int, { description: 'Total annotations' }) totalAnnotations: number @Field(type => Float, { description: 'Average annotations per task' }) avgAnnotationsPerTask: number @Field(type => Float, { description: 'Completion rate (0-1)' }) completionRate: number @Field(type => Float, { nullable: true, description: 'Average time per task in seconds' }) avgTimePerTask?: number @Field(type => [AnnotatorStats], { description: 'Statistics per annotator' }) annotatorStats: AnnotatorStats[] } @ObjectType({ description: 'Annotator statistics' }) export class AnnotatorStats { @Field({ description: 'User email' }) email: string @Field(type => Int, { description: 'Number of annotations' }) annotationCount: number @Field(type => Float, { description: 'Average time per annotation in seconds' }) avgTime: number @Field({ description: 'Last annotation date' }) lastAnnotationDate: Date } // ============================================================================ // ML Backend Types // ============================================================================ @ObjectType({ description: 'ML Backend information' }) export class MLBackend { @Field(type => Int, { description: 'ML Backend ID' }) id: number @Field({ description: 'ML Backend URL' }) url: string @Field({ description: 'ML Backend title' }) title: string @Field({ description: 'Is interactive preannotation enabled' }) isInteractive: boolean @Field({ description: 'Model version' }) modelVersion: string } @InputType({ description: 'Input for adding ML Backend' }) export class AddMLBackendInput { @Field({ description: 'ML Backend URL' }) url: string @Field({ description: 'ML Backend title' }) title: string @Field({ nullable: true, description: 'Is interactive preannotation enabled' }) isInteractive?: boolean }