import { Entity, Property, ManyToOne, Enum } from '@mikro-orm/core';
import { BaseEntity } from './_BaseEntity';
import { User } from './user/_User';
import { App } from './app/_App';

export enum PromptType {
    API_DOCUMENTATION = 'api_documentation',
    ENDPOINT_ANALYSIS = 'endpoint_analysis',
    SCHEMA_GENERATION = 'schema_generation',
    CUSTOM = 'custom'
}

export enum PromptStatus {
    PENDING = 'pending',
    PROCESSING = 'processing',
    COMPLETED = 'completed',
    FAILED = 'failed'
}

@Entity()
export class Prompt extends BaseEntity {
    @Property({ type: 'text', nullable: true })
    name?: string;

    @Property({ type: 'text' })
    content!: string;

    @Property({ type: 'jsonb', default: '{}' })
    metadata!: Record<string, any>;

    @Enum(() => PromptType)
    type!: PromptType;

    @Enum(() => PromptStatus)
    status: PromptStatus = PromptStatus.PENDING;

    @ManyToOne(() => User)
    user!: User;

    @ManyToOne(() => App)
    app!: App;

    @Property({ type: 'jsonb', nullable: true })
    processedResult?: Record<string, any>;

    @Property({ type: 'text', nullable: true })
    errorMessage?: string;
} 