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 Label from "./Label";
import Project from "./Project";
import User from "./User";
import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
import Route from "../../Types/API/Route";
import Color from "../../Types/Color";
import ColumnAccessControl from "../../Types/Database/AccessControl/ColumnAccessControl";
import OperationalResource from "../../Types/Database/AccessControl/OperationalResource";
import TableAccessControl from "../../Types/Database/AccessControl/TableAccessControl";
import AccessControlColumn from "../../Types/Database/AccessControlColumn";
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 EnableWorkflow from "../../Types/Database/EnableWorkflow";
import ColorField from "../../Types/Database/ColorField";
import SlugifyColumn from "../../Types/Database/SlugifyColumn";
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 UniqueColumnBy from "../../Types/Database/UniqueColumnBy";
import IconProp from "../../Types/Icon/IconProp";
import ObjectID from "../../Types/ObjectID";
import Permission from "../../Types/Permission";
import TechStack from "../../Types/Service/TechStack";
import { Column, Entity, Index, JoinColumn, JoinTable, ManyToMany, ManyToOne, } from "typeorm";
let Service = class Service extends BaseModel {
    constructor() {
        super(...arguments);
        this.project = undefined;
        this.projectId = undefined;
        this.name = undefined;
        this.slug = undefined;
        this.description = undefined;
        this.createdByUser = undefined;
        this.createdByUserId = undefined;
        this.deletedByUser = undefined;
        this.deletedByUserId = undefined;
        this.labels = undefined;
        this.serviceColor = undefined;
        // This column is deprecated and will be removed in the future.
        this.serviceLanguage = undefined;
        this.techStack = undefined;
        this.retainTelemetryDataForDays = undefined;
        this.metricCardinalityBudget = undefined;
        this.metricDownsamplingRetentionDays = undefined;
        this.telemetryRetentionConfig = undefined;
        this.lastSeenAt = undefined;
        /*
         * The columns below are auto-populated from OpenTelemetry resource
         * attributes at ingest time (see OTelIngestService.telemetryServiceFromName).
         * They are system-managed — not user-editable — so create/update access
         * control is empty and writes only happen via the root ingest path.
         */
        this.serviceVersion = undefined;
        this.deploymentEnvironment = undefined;
        this.serviceNamespace = undefined;
        this.runtimeName = undefined;
        this.runtimeVersion = undefined;
        this.telemetrySdkLanguage = undefined;
        this.cloudProvider = undefined;
        this.cloudPlatform = undefined;
        this.cloudRegion = undefined;
        this.cloudAccountId = undefined;
    }
};
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateService,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "projectId",
        type: TableColumnType.Entity,
        modelType: Project,
        title: "Project",
        description: "Relation to Project Resource in which this object belongs",
    }),
    ManyToOne(() => {
        return Project;
    }, {
        eager: false,
        nullable: true,
        onDelete: "CASCADE",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "projectId" }),
    __metadata("design:type", Project)
], Service.prototype, "project", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateService,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: true,
        canReadOnRelationQuery: true,
        title: "Project ID",
        description: "ID of your OneUptime Project in which this object belongs",
        example: "5f8b9c0d-e1a2-4b3c-8d5e-6f7a8b9c0d1e",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: false,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], Service.prototype, "projectId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateService,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditService,
        ],
    }),
    TableColumn({
        required: true,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Name",
        description: "Any friendly name of this object",
        example: "User Authentication API",
    }),
    Column({
        nullable: false,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    UniqueColumnBy("projectId"),
    __metadata("design:type", String)
], Service.prototype, "name", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [],
    }),
    TableColumn({
        required: true,
        unique: true,
        type: TableColumnType.Slug,
        computed: true,
        title: "Slug",
        description: "Friendly globally unique name for your object",
    }),
    Column({
        nullable: false,
        type: ColumnType.Slug,
        length: ColumnLength.Slug,
    }),
    __metadata("design:type", String)
], Service.prototype, "slug", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateService,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditService,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.LongText,
        canReadOnRelationQuery: true,
        title: "Description",
        description: "Friendly description that will help you remember",
        example: "RESTful API service that handles user authentication, authorization, and session management for the platform",
    }),
    Column({
        nullable: true,
        type: ColumnType.LongText,
        length: ColumnLength.LongText,
    }),
    __metadata("design:type", String)
], Service.prototype, "description", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateService,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "createdByUserId",
        type: TableColumnType.Entity,
        modelType: User,
        title: "Created by User",
        description: "Relation to User who created this object (if this object was created by a User)",
    }),
    ManyToOne(() => {
        return User;
    }, {
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "createdByUserId" }),
    __metadata("design:type", User)
], Service.prototype, "createdByUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateService,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        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)",
        example: "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], Service.prototype, "createdByUserId", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "deletedByUserId",
        type: TableColumnType.Entity,
        title: "Deleted by User",
        modelType: User,
        description: "Relation to User who deleted this object (if this object was deleted by a User)",
    }),
    ManyToOne(() => {
        return User;
    }, {
        cascade: false,
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "deletedByUserId" }),
    __metadata("design:type", User)
], Service.prototype, "deletedByUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        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)",
        example: "b2c3d4e5-f6a7-8901-bcde-f12345678901",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], Service.prototype, "deletedByUserId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateService,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditService,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: Label,
        title: "Labels",
        description: "Relation to Labels Array where this object is categorized in.",
    }),
    ManyToMany(() => {
        return Label;
    }, { eager: false }),
    JoinTable({
        name: "ServiceLabel",
        inverseJoinColumn: {
            name: "labelId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "serviceId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], Service.prototype, "labels", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateService,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditService,
        ],
    }),
    ColorField(),
    TableColumn({
        type: TableColumnType.Color,
        title: "Service Color",
        description: "Color for this service",
        canReadOnRelationQuery: true,
    }),
    Column({
        type: ColumnType.Color,
        nullable: true,
        unique: false,
        transformer: Color.getDatabaseTransformer(),
    }),
    __metadata("design:type", Color)
], Service.prototype, "serviceColor", void 0);
__decorate([
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Service Language",
        description: "Language in which this service is written",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Service.prototype, "serviceLanguage", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateService,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditService,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.JSON,
        canReadOnRelationQuery: true,
        title: "Tech Stack",
        description: "Tech stack used in the service. This will help other developers understand the service better.",
    }),
    Column({
        nullable: true,
        type: ColumnType.JSON,
    }),
    __metadata("design:type", Array)
], Service.prototype, "techStack", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateService,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditService,
        ],
    }),
    TableColumn({
        type: TableColumnType.Number,
        title: "Retain Telemetry Data For Days",
        description: "Number of days to retain telemetry data for this service. Leave blank to use the project-wide default.",
    }),
    Column({
        type: ColumnType.Number,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", Number)
], Service.prototype, "retainTelemetryDataForDays", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateService,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditService,
        ],
    }),
    TableColumn({
        type: TableColumnType.Number,
        required: false,
        title: "Metric Cardinality Budget",
        description: "Max number of distinct metric series this service may emit per metric. When exceeded, the highest-cardinality attribute is auto-bucketed. Null inherits the project default.",
    }),
    Column({
        type: ColumnType.Number,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", Number)
], Service.prototype, "metricCardinalityBudget", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateService,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditService,
        ],
    }),
    TableColumn({
        type: TableColumnType.JSON,
        required: false,
        title: "Metric Downsampling Retention (days per tier)",
        description: "Per-tier retention override (raw, 1m, 5m, 1h, 1d) in days. Null fields inherit the project default.",
    }),
    Column({
        type: ColumnType.JSON,
        nullable: true,
    }),
    __metadata("design:type", Object)
], Service.prototype, "metricDownsamplingRetentionDays", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateService,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditService,
        ],
    }),
    TableColumn({
        type: TableColumnType.JSON,
        required: false,
        title: "Telemetry Data Retention Overrides",
        description: "Per-pillar retention overrides for this service (logs by severity, traces by status, metrics, profiles). Unset fields fall back to the service default, then the project's retention settings.",
    }),
    Column({
        type: ColumnType.JSON,
        nullable: true,
    }),
    __metadata("design:type", Object)
], Service.prototype, "telemetryRetentionConfig", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Date,
        canReadOnRelationQuery: true,
        title: "Last Seen At",
        description: "When telemetry was last received for this service",
    }),
    Column({
        nullable: true,
        type: ColumnType.Date,
    }),
    __metadata("design:type", Date)
], Service.prototype, "lastSeenAt", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Service Version",
        description: "Last-seen value of the service.version OpenTelemetry resource attribute.",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Service.prototype, "serviceVersion", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Deployment Environment",
        description: "Last-seen value of the deployment.environment.name (or deployment.environment) OpenTelemetry resource attribute, e.g. production, staging.",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Service.prototype, "deploymentEnvironment", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Service Namespace",
        description: "Last-seen value of the service.namespace OpenTelemetry resource attribute.",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Service.prototype, "serviceNamespace", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Runtime Name",
        description: "Last-seen value of the process.runtime.name OpenTelemetry resource attribute, e.g. nodejs, go, OpenJDK Runtime Environment.",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Service.prototype, "runtimeName", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Runtime Version",
        description: "Last-seen value of the process.runtime.version OpenTelemetry resource attribute.",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Service.prototype, "runtimeVersion", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Telemetry SDK Language",
        description: "Last-seen value of the telemetry.sdk.language OpenTelemetry resource attribute, e.g. java, dotnet, nodejs, python, go. Drives technology-specific golden metrics on the service overview.",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Service.prototype, "telemetrySdkLanguage", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Cloud Provider",
        description: "Last-seen value of the cloud.provider OpenTelemetry resource attribute, e.g. aws, gcp, azure.",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Service.prototype, "cloudProvider", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Cloud Platform",
        description: "Last-seen value of the cloud.platform OpenTelemetry resource attribute, e.g. aws_ecs, gcp_cloud_run, aws_lambda.",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Service.prototype, "cloudPlatform", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Cloud Region",
        description: "Last-seen value of the cloud.region OpenTelemetry resource attribute, e.g. us-east-1.",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Service.prototype, "cloudRegion", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Cloud Account ID",
        description: "Last-seen value of the cloud.account.id OpenTelemetry resource attribute.",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Service.prototype, "cloudAccountId", void 0);
Service = __decorate([
    OperationalResource(),
    AccessControlColumn("labels"),
    EnableDocumentation(),
    TenantColumn("projectId"),
    TableAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateService,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadService,
        ],
        delete: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.DeleteService,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditService,
        ],
    }),
    EnableWorkflow({
        create: true,
        delete: true,
        update: true,
        read: true,
    }),
    CrudApiEndpoint(new Route("/service")),
    SlugifyColumn("name", "slug")
    /*
     * Enforce one Service row per (projectId, name) at the DB level.
     * Without this, parallel OTel scope batches arriving from a brand-new
     * source within the same project all miss telemetryServiceFromName's
     * findOneBy on first contact and each create their own row, producing
     * duplicate "host/<hostname>" (or other auto-synthesized) services.
     * The DB constraint converts the race into a unique-violation error
     * that the service layer's catch-and-refetch path resolves to the
     * winning row.
     */
    ,
    Index(["projectId", "name"], { unique: true }),
    TableMetadata({
        tableName: "Service",
        singularName: "Service",
        pluralName: "Services",
        icon: IconProp.SquareStack,
        tableDescription: "Services is a collection of services that you have in your organization. It can be a collection of services that you are monitoring or services that you are providing to your customers. It can be anything that you want to keep track of.",
    }),
    Entity({
        name: "Service",
    })
], Service);
export default Service;
//# sourceMappingURL=Service.js.map