import { Field, InputType, ObjectType, Int, Float } from 'type-graphql' /** * Dataset Labeling Integration Types * * Types for integrating DataSample with Label Studio tasks and AI predictions */ @InputType({ description: 'Request to create Label Studio tasks from DataSamples' }) export class CreateLabelingTasksRequest { @Field(type => Int, { description: 'Label Studio project ID' }) projectId: number @Field({ description: 'DataSet ID to sync' }) dataSetId: string @Field({ nullable: true, description: 'Image field name in DataSample.data or DataSample.rawData' }) imageField?: string @Field({ nullable: true, defaultValue: true, description: 'Auto-generate AI predictions for created tasks' }) autoGeneratePredictions?: boolean @Field(type => Float, { nullable: true, description: 'Confidence threshold for AI predictions' }) confidenceThreshold?: number @Field({ nullable: true, description: 'AI model ID to use for predictions' }) modelId?: string @Field({ nullable: true, description: 'Only create tasks for samples after this date' }) sinceDate?: Date @Field({ nullable: true, description: 'Maximum number of tasks to create' }) limit?: number } @ObjectType({ description: 'Result of task creation from dataset' }) export class TaskCreationResult { @Field(type => Int, { description: 'Total DataSamples processed' }) totalSamples: number @Field(type => Int, { description: 'Number of tasks successfully created' }) tasksCreated: number @Field(type => Int, { description: 'Number of tasks that failed to create' }) tasksFailed: number @Field(type => Int, { description: 'Number of samples skipped (no image, already exists, etc.)' }) tasksSkipped: number @Field(type => [Int], { description: 'Array of created Label Studio task IDs' }) taskIds: number[] @Field(type => Int, { nullable: true, description: 'Number of AI predictions generated' }) predictionsCreated?: number @Field({ nullable: true, description: 'Error message if operation partially failed' }) error?: string } @InputType({ description: 'Request to sync Label Studio annotations back to DataSamples' }) export class SyncAnnotationsRequest { @Field(type => Int, { description: 'Label Studio project ID' }) projectId: number @Field({ description: 'DataSet ID to sync annotations to' }) dataSetId: string @Field({ nullable: true, defaultValue: false, description: 'Only sync completed annotations' }) completedOnly?: boolean @Field({ nullable: true, description: 'Only sync annotations updated after this date' }) sinceDate?: Date } @ObjectType({ description: 'Result of syncing annotations to dataset' }) export class SyncAnnotationsResult { @Field(type => Int, { description: 'Total annotations processed' }) totalAnnotations: number @Field(type => Int, { description: 'Number of DataSamples successfully updated' }) samplesUpdated: number @Field(type => Int, { description: 'Number of updates that failed' }) updatesFailed: number @Field(type => Int, { description: 'Number of annotations skipped' }) skipped: number @Field({ nullable: true, description: 'Error message if operation partially failed' }) error?: string } @ObjectType({ description: 'Labeling status for a dataset' }) export class DatasetLabelingStatus { @Field({ description: 'DataSet ID' }) dataSetId: string @Field({ description: 'DataSet name' }) dataSetName: string @Field(type => Int, { description: 'Total number of DataSamples in the dataset' }) totalSamples: number @Field(type => Int, { description: 'Number of samples with Label Studio tasks' }) tasksCreated: number @Field(type => Int, { description: 'Number of samples with AI predictions' }) withPredictions: number @Field(type => Int, { description: 'Number of samples with human annotations' }) withAnnotations: number @Field(type => Int, { description: 'Number of samples with completed annotations' }) annotationsCompleted: number @Field(type => Int, { description: 'Number of samples not yet processed' }) notProcessed: number @Field(type => Float, { description: 'Labeling completion rate (0-1)' }) completionRate: number @Field({ nullable: true, description: 'Associated Label Studio project ID' }) projectId?: number @Field({ nullable: true, description: 'Last sync timestamp' }) lastSyncedAt?: Date } @ObjectType({ description: 'Mapping between DataSample and Label Studio task' }) export class DataSampleTaskMapping { @Field({ description: 'DataSample ID' }) dataSampleId: string @Field({ description: 'DataSample name' }) dataSampleName: string @Field(type => Int, { description: 'Label Studio task ID' }) taskId: number @Field({ nullable: true, description: 'Image URL used in the task' }) imageUrl?: string @Field({ nullable: true, description: 'Task creation timestamp' }) createdAt?: Date @Field({ nullable: true, description: 'Whether task has AI prediction' }) hasPrediction?: boolean @Field({ nullable: true, description: 'Whether task has human annotation' }) hasAnnotation?: boolean @Field({ nullable: true, description: 'Whether annotation is completed' }) isCompleted?: boolean } @InputType({ description: 'Request to query dataset labeling status' }) export class DatasetLabelingStatusRequest { @Field({ description: 'DataSet ID' }) dataSetId: string @Field(type => Int, { nullable: true, description: 'Associated Label Studio project ID' }) projectId?: number } @InputType({ description: 'Request to generate predictions for existing tasks' }) export class GeneratePredictionsForDatasetRequest { @Field({ description: 'DataSet ID' }) dataSetId: string @Field(type => Int, { description: 'Label Studio project ID' }) projectId: number @Field({ nullable: true, description: 'AI model ID to use' }) modelId?: string @Field(type => Float, { nullable: true, description: 'Confidence threshold' }) confidenceThreshold?: number @Field({ nullable: true, defaultValue: false, description: 'Regenerate predictions even if they already exist' }) forceRegenerate?: boolean }