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 Project from "./Project";
import User from "./User";
import TracePipeline from "./TracePipeline";
import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
import Route from "../../Types/API/Route";
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 EnableDocumentation from "../../Types/Database/EnableDocumentation";
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 { PlanType } from "../../Types/Billing/SubscriptionPlan";
import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
let TracePipelineProcessor = class TracePipelineProcessor extends BaseModel {
    constructor() {
        super(...arguments);
        this.project = undefined;
        this.projectId = undefined;
        this.tracePipeline = undefined;
        this.tracePipelineId = undefined;
        this.name = undefined;
        this.processorType = undefined;
        this.configuration = undefined;
        this.isEnabled = undefined;
        this.sortOrder = undefined;
        this.createdByUser = undefined;
        this.createdByUserId = undefined;
    }
};
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectTracePipelineProcessor,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.TelemetryAdmin,
            Permission.TelemetryMember,
            Permission.TelemetryViewer,
            Permission.ReadProjectTracePipelineProcessor,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "projectId",
        type: TableColumnType.Entity,
        modelType: Project,
        title: "Project",
        description: "Relation to the project this trace pipeline processor belongs to.",
    }),
    ManyToOne(() => {
        return Project;
    }, {
        eager: false,
        nullable: true,
        onDelete: "CASCADE",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "projectId" }),
    __metadata("design:type", Project)
], TracePipelineProcessor.prototype, "project", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectTracePipelineProcessor,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.TelemetryAdmin,
            Permission.TelemetryMember,
            Permission.TelemetryViewer,
            Permission.ReadProjectTracePipelineProcessor,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: true,
        canReadOnRelationQuery: true,
        title: "Project ID",
        description: "ID of the project this trace pipeline processor belongs to.",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: false,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], TracePipelineProcessor.prototype, "projectId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectTracePipelineProcessor,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.TelemetryAdmin,
            Permission.TelemetryMember,
            Permission.TelemetryViewer,
            Permission.ReadProjectTracePipelineProcessor,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "tracePipelineId",
        type: TableColumnType.Entity,
        modelType: TracePipeline,
        title: "Trace Pipeline",
        description: "Relation to the trace pipeline this processor belongs to.",
    }),
    ManyToOne(() => {
        return TracePipeline;
    }, {
        eager: false,
        nullable: false,
        onDelete: "CASCADE",
        orphanedRowAction: "delete",
    }),
    JoinColumn({ name: "tracePipelineId" }),
    __metadata("design:type", TracePipeline)
], TracePipelineProcessor.prototype, "tracePipeline", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectTracePipelineProcessor,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.TelemetryAdmin,
            Permission.TelemetryMember,
            Permission.TelemetryViewer,
            Permission.ReadProjectTracePipelineProcessor,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: true,
        canReadOnRelationQuery: true,
        title: "Trace Pipeline ID",
        description: "ID of the trace pipeline this processor belongs to.",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: false,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], TracePipelineProcessor.prototype, "tracePipelineId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectTracePipelineProcessor,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.TelemetryAdmin,
            Permission.TelemetryMember,
            Permission.TelemetryViewer,
            Permission.ReadProjectTracePipelineProcessor,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditProjectTracePipelineProcessor,
        ],
    }),
    TableColumn({
        required: true,
        type: TableColumnType.Name,
        canReadOnRelationQuery: true,
        title: "Name",
        description: "Friendly name for this processor.",
    }),
    Column({
        nullable: false,
        type: ColumnType.Name,
        length: ColumnLength.Name,
    }),
    __metadata("design:type", String)
], TracePipelineProcessor.prototype, "name", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectTracePipelineProcessor,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.TelemetryAdmin,
            Permission.TelemetryMember,
            Permission.TelemetryViewer,
            Permission.ReadProjectTracePipelineProcessor,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditProjectTracePipelineProcessor,
        ],
    }),
    TableColumn({
        required: true,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Processor Type",
        description: "The type of processor: AttributeRemapper, SpanNameRemapper, StatusRemapper, SpanKindRemapper, or CategoryProcessor.",
    }),
    Column({
        nullable: false,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], TracePipelineProcessor.prototype, "processorType", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectTracePipelineProcessor,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.TelemetryAdmin,
            Permission.TelemetryMember,
            Permission.TelemetryViewer,
            Permission.ReadProjectTracePipelineProcessor,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditProjectTracePipelineProcessor,
        ],
    }),
    TableColumn({
        title: "Configuration",
        required: true,
        type: TableColumnType.JSON,
        canReadOnRelationQuery: true,
        description: "Processor-specific configuration as JSON (e.g., source/target fields, mapping rules).",
    }),
    Column({
        type: ColumnType.JSON,
        nullable: false,
        default: () => {
            return "'{}'";
        },
    }),
    __metadata("design:type", Object)
], TracePipelineProcessor.prototype, "configuration", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectTracePipelineProcessor,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.TelemetryAdmin,
            Permission.TelemetryMember,
            Permission.TelemetryViewer,
            Permission.ReadProjectTracePipelineProcessor,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditProjectTracePipelineProcessor,
        ],
    }),
    Index(),
    TableColumn({
        required: true,
        type: TableColumnType.Boolean,
        canReadOnRelationQuery: true,
        title: "Enabled",
        description: "Whether this processor is active.",
        defaultValue: true,
    }),
    Column({
        nullable: false,
        type: ColumnType.Boolean,
        default: true,
    }),
    __metadata("design:type", Boolean)
], TracePipelineProcessor.prototype, "isEnabled", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectTracePipelineProcessor,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.TelemetryAdmin,
            Permission.TelemetryMember,
            Permission.TelemetryViewer,
            Permission.ReadProjectTracePipelineProcessor,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditProjectTracePipelineProcessor,
        ],
    }),
    TableColumn({
        title: "Sort Order",
        required: true,
        type: TableColumnType.Number,
        canReadOnRelationQuery: true,
        description: "Determines the execution order of this processor within its pipeline.",
        defaultValue: 0,
    }),
    Column({
        type: ColumnType.Number,
        nullable: false,
        default: 0,
    }),
    __metadata("design:type", Number)
], TracePipelineProcessor.prototype, "sortOrder", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.TelemetryAdmin,
            Permission.TelemetryMember,
            Permission.TelemetryViewer,
            Permission.ReadProjectTracePipelineProcessor,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "createdByUserId",
        type: TableColumnType.Entity,
        modelType: User,
        title: "Created By User",
        description: "Relation to the user who created this trace pipeline processor.",
    }),
    ManyToOne(() => {
        return User;
    }, {
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "createdByUserId" }),
    __metadata("design:type", User)
], TracePipelineProcessor.prototype, "createdByUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.TelemetryAdmin,
            Permission.TelemetryMember,
            Permission.TelemetryViewer,
            Permission.ReadProjectTracePipelineProcessor,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ObjectID,
        title: "Created By User ID",
        description: "ID of the user who created this trace pipeline processor.",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], TracePipelineProcessor.prototype, "createdByUserId", void 0);
TracePipelineProcessor = __decorate([
    EnableDocumentation(),
    TableBillingAccessControl({
        create: PlanType.Free,
        read: PlanType.Free,
        update: PlanType.Free,
        delete: PlanType.Free,
    }),
    TenantColumn("projectId"),
    CrudApiEndpoint(new Route("/trace-pipeline-processor")),
    Entity({
        name: "TracePipelineProcessor",
    }),
    TableMetadata({
        tableName: "TracePipelineProcessor",
        singularName: "Trace Pipeline Processor",
        pluralName: "Trace Pipeline Processors",
        icon: IconProp.Settings,
        tableDescription: "Individual processors within a trace pipeline that transform span data during ingestion.",
    }),
    TableAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectTracePipelineProcessor,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.TelemetryAdmin,
            Permission.TelemetryMember,
            Permission.TelemetryViewer,
            Permission.ReadProjectTracePipelineProcessor,
        ],
        delete: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.DeleteProjectTracePipelineProcessor,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditProjectTracePipelineProcessor,
        ],
    })
], TracePipelineProcessor);
export default TracePipelineProcessor;
//# sourceMappingURL=TracePipelineProcessor.js.map