var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import AIAgent from "./AIAgent";
import Project from "./Project";
import User from "./User";
import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
import Route from "../../Types/API/Route";
import { PlanType } from "../../Types/Billing/SubscriptionPlan";
import ColumnAccessControl from "../../Types/Database/AccessControl/ColumnAccessControl";
import TableAccessControl from "../../Types/Database/AccessControl/TableAccessControl";
import TableBillingAccessControl from "../../Types/Database/AccessControl/TableBillingAccessControl";
import ColumnLength from "../../Types/Database/ColumnLength";
import ColumnType from "../../Types/Database/ColumnType";
import CrudApiEndpoint from "../../Types/Database/CrudApiEndpoint";
import TableColumn from "../../Types/Database/TableColumn";
import TableColumnType from "../../Types/Database/TableColumnType";
import TableMetadata from "../../Types/Database/TableMetadata";
import TenantColumn from "../../Types/Database/TenantColumn";
import IconProp from "../../Types/Icon/IconProp";
import ObjectID from "../../Types/ObjectID";
import Permission from "../../Types/Permission";
import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
import EnableDocumentation from "../../Types/Database/EnableDocumentation";
import AIAgentTaskType from "../../Types/AI/AIAgentTaskType";
import AIAgentTaskStatus from "../../Types/AI/AIAgentTaskStatus";
let AIAgentTask = class AIAgentTask extends BaseModel {
    constructor() {
        super(...arguments);
        this.project = undefined;
        this.projectId = undefined;
        this.name = undefined;
        this.description = undefined;
        this.aiAgent = undefined;
        this.aiAgentId = undefined;
        this.taskType = undefined;
        this.status = undefined;
        this.statusMessage = undefined;
        this.metadata = undefined;
        this.startedAt = undefined;
        this.completedAt = undefined;
        this.deletedByUser = undefined;
        this.deletedByUserId = undefined;
        this.createdByUser = undefined;
        this.createdByUserId = undefined;
        this.taskNumber = undefined;
    }
};
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateProjectAIAgentTask,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectAIAgentTask,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.Entity,
        required: true,
        modelType: Project,
        manyToOneRelationColumn: "projectId",
        title: "Project",
        description: "Project this task belongs to.",
    }),
    ManyToOne(() => {
        return Project;
    }, {
        cascade: false,
        eager: false,
        nullable: false,
        onDelete: "CASCADE",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "projectId" }),
    __metadata("design:type", Project)
], AIAgentTask.prototype, "project", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateProjectAIAgentTask,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectAIAgentTask,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: true,
        canReadOnRelationQuery: true,
        title: "Project ID",
        description: "ID of the project this task belongs to.",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: false,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], AIAgentTask.prototype, "projectId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateProjectAIAgentTask,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectAIAgentTask,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditProjectAIAgentTask,
        ],
    }),
    TableColumn({
        required: true,
        type: TableColumnType.VeryLongText,
        title: "Name",
        description: "Name of the AI Agent Task.",
        canReadOnRelationQuery: true,
    }),
    Column({
        nullable: false,
        type: ColumnType.VeryLongText,
    }),
    __metadata("design:type", String)
], AIAgentTask.prototype, "name", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateProjectAIAgentTask,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectAIAgentTask,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditProjectAIAgentTask,
        ],
    }),
    TableColumn({
        required: true,
        type: TableColumnType.VeryLongText,
        title: "Description",
        description: "Description of the AI Agent Task.",
        canReadOnRelationQuery: true,
    }),
    Column({
        nullable: false,
        type: ColumnType.VeryLongText,
    }),
    __metadata("design:type", String)
], AIAgentTask.prototype, "description", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateProjectAIAgentTask,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectAIAgentTask,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditProjectAIAgentTask,
        ],
    }),
    TableColumn({
        type: TableColumnType.Entity,
        required: false,
        modelType: AIAgent,
        title: "AI Agent",
        description: "AI Agent assigned to this task.",
    }),
    ManyToOne(() => {
        return AIAgent;
    }, {
        cascade: false,
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "aiAgentId" }),
    __metadata("design:type", AIAgent)
], AIAgentTask.prototype, "aiAgent", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateProjectAIAgentTask,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectAIAgentTask,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditProjectAIAgentTask,
        ],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: false,
        canReadOnRelationQuery: true,
        title: "AI Agent ID",
        description: "ID of the AI Agent assigned to this task.",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], AIAgentTask.prototype, "aiAgentId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateProjectAIAgentTask,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectAIAgentTask,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        required: true,
        type: TableColumnType.ShortText,
        title: "Task Type",
        description: "Type of task to be performed by the AI agent.",
        canReadOnRelationQuery: true,
    }),
    Column({
        nullable: false,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], AIAgentTask.prototype, "taskType", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateProjectAIAgentTask,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectAIAgentTask,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditProjectAIAgentTask,
        ],
    }),
    Index(),
    TableColumn({
        required: true,
        type: TableColumnType.ShortText,
        title: "Status",
        description: "Current status of the task.",
        canReadOnRelationQuery: true,
    }),
    Column({
        nullable: false,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        default: AIAgentTaskStatus.Scheduled,
    }),
    __metadata("design:type", String)
], AIAgentTask.prototype, "status", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectAIAgentTask,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditProjectAIAgentTask,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.LongText,
        title: "Status Message",
        description: "A message describing the current status or result of the task.",
    }),
    Column({
        nullable: true,
        type: ColumnType.LongText,
    }),
    __metadata("design:type", String)
], AIAgentTask.prototype, "statusMessage", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateProjectAIAgentTask,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectAIAgentTask,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditProjectAIAgentTask,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.JSON,
        title: "Metadata",
        description: "Task-specific metadata containing context for the AI agent. Structure varies based on task type.",
    }),
    Column({
        nullable: true,
        type: ColumnType.JSON,
    }),
    __metadata("design:type", Object)
], AIAgentTask.prototype, "metadata", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectAIAgentTask,
        ],
        update: [],
    }),
    TableColumn({
        isDefaultValueColumn: false,
        required: false,
        type: TableColumnType.Date,
        title: "Started At",
        description: "When the task started execution.",
    }),
    Column({
        nullable: true,
        type: ColumnType.Date,
    }),
    __metadata("design:type", Date)
], AIAgentTask.prototype, "startedAt", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectAIAgentTask,
        ],
        update: [],
    }),
    TableColumn({
        isDefaultValueColumn: false,
        required: false,
        type: TableColumnType.Date,
        title: "Completed At",
        description: "When the task completed execution.",
    }),
    Column({
        nullable: true,
        type: ColumnType.Date,
    }),
    __metadata("design:type", Date)
], AIAgentTask.prototype, "completedAt", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({ type: TableColumnType.Entity, modelType: User }),
    ManyToOne(() => {
        return User;
    }, {
        cascade: false,
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "deletedByUserId" }),
    __metadata("design:type", User)
], AIAgentTask.prototype, "deletedByUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ObjectID,
        title: "Deleted by User ID",
        description: "User ID who deleted this object (if this object was deleted by a User)",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], AIAgentTask.prototype, "deletedByUserId", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [Permission.ProjectOwner, Permission.ProjectAdmin],
        update: [],
    }),
    TableColumn({ type: TableColumnType.Entity, modelType: User }),
    ManyToOne(() => {
        return User;
    }, {
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "createdByUserId" }),
    __metadata("design:type", User)
], AIAgentTask.prototype, "createdByUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [Permission.ProjectOwner, Permission.ProjectAdmin],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ObjectID,
        title: "Created by User ID",
        description: "User ID who created this object (if this object was created by a User)",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], AIAgentTask.prototype, "createdByUserId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateProjectAIAgentTask,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectAIAgentTask,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        isDefaultValueColumn: false,
        required: true,
        type: TableColumnType.Number,
        title: "Task Number",
        description: "A unique, sequential number assigned to each AI Agent Task within a project.",
    }),
    Column({
        type: ColumnType.Number,
        nullable: false,
        default: 1,
    }),
    __metadata("design:type", Number)
], AIAgentTask.prototype, "taskNumber", void 0);
AIAgentTask = __decorate([
    EnableDocumentation(),
    TableBillingAccessControl({
        create: PlanType.Growth,
        read: PlanType.Growth,
        update: PlanType.Growth,
        delete: PlanType.Growth,
    }),
    TenantColumn("projectId"),
    CrudApiEndpoint(new Route("/ai-agent-task")),
    Entity({
        name: "AIAgentTask",
    }),
    TableMetadata({
        tableName: "AIAgentTask",
        singularName: "AI Agent Task",
        pluralName: "AI Agent Tasks",
        icon: IconProp.Bolt,
        tableDescription: "Manage tasks assigned to AI agents. Tasks can be scheduled, monitored, and tracked for completion.",
    }),
    TableAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateProjectAIAgentTask,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectAIAgentTask,
        ],
        delete: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.DeleteProjectAIAgentTask,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditProjectAIAgentTask,
        ],
    })
], AIAgentTask);
export default AIAgentTask;
//# sourceMappingURL=AIAgentTask.js.map