import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
import moment from 'moment';
import { Workspace } from './workspace.model';
import { Agents } from './agent.schema';

export enum script_status {
    ACTIVE = 'ACTIVE',
    IN_ACTIVE = 'IN_ACTIVE',
    DELETED = 'DELETED',
}

@Schema()
export class Script extends Document {

    @Prop({ type: Types.ObjectId, ref: Workspace.name, default: null })
    workspace_id: Types.ObjectId

    @Prop({ type: Types.ObjectId, ref: Agents.name, default: null })
    agent_id: Types.ObjectId

    @Prop({ type: String, default: null })
    key: string;

    @Prop({ type: String, default: null })
    name: string;

    @Prop({ type: String, default: null })
    image: string;

    @Prop({ type: String, default: null })
    colour: string;

    @Prop({ type: String, default: null })
    font_colour: string;

    @Prop({ type: String, default: null })
    title: string;

    @Prop({ type: String, default: null })
    description: string;

    @Prop({ type: String, enum: script_status, default: script_status.ACTIVE })
    script_status: string = null;

    @Prop({ default: moment().utc().valueOf() })
    updated_at: number = moment().utc().valueOf();

    @Prop({ default: moment().utc().valueOf() })
    created_at: number = moment().utc().valueOf();
}

export const ScriptSchema = SchemaFactory.createForClass(Script);
