"use strict"; 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); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AIUsage = exports.UsageStatus = exports.AIModelType = void 0; const typeorm_1 = require("typeorm"); const ai_config_entity_1 = require("./ai-config.entity"); var AIModelType; (function (AIModelType) { AIModelType["CHAT"] = "chat"; AIModelType["COMPLETION"] = "completion"; AIModelType["EMBEDDING"] = "embedding"; AIModelType["IMAGE"] = "image"; })(AIModelType || (exports.AIModelType = AIModelType = {})); var UsageStatus; (function (UsageStatus) { UsageStatus["PENDING"] = "pending"; UsageStatus["COMPLETED"] = "completed"; UsageStatus["FAILED"] = "failed"; UsageStatus["CANCELLED"] = "cancelled"; })(UsageStatus || (exports.UsageStatus = UsageStatus = {})); let AIUsage = class AIUsage { get total_tokens() { return this.input_tokens + this.output_tokens; } get cost_total() { return Number(this.cost_input) + Number(this.cost_output); } }; exports.AIUsage = AIUsage; __decorate([ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'), __metadata("design:type", String) ], AIUsage.prototype, "id", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'uuid' }), __metadata("design:type", String) ], AIUsage.prototype, "tenant_id", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'uuid' }), __metadata("design:type", String) ], AIUsage.prototype, "user_id", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'enum', enum: ai_config_entity_1.AIProvider }), __metadata("design:type", String) ], AIUsage.prototype, "provider", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'varchar', length: 100 }), __metadata("design:type", String) ], AIUsage.prototype, "model", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'enum', enum: AIModelType, default: AIModelType.CHAT }), __metadata("design:type", String) ], AIUsage.prototype, "model_type", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'enum', enum: UsageStatus, default: UsageStatus.PENDING }), __metadata("design:type", String) ], AIUsage.prototype, "status", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'int', default: 0 }), __metadata("design:type", Number) ], AIUsage.prototype, "input_tokens", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'int', default: 0 }), __metadata("design:type", Number) ], AIUsage.prototype, "output_tokens", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'numeric', precision: 12, scale: 6, default: 0 }), __metadata("design:type", Number) ], AIUsage.prototype, "cost_input", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'numeric', precision: 12, scale: 6, default: 0 }), __metadata("design:type", Number) ], AIUsage.prototype, "cost_output", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'int', nullable: true }), __metadata("design:type", Number) ], AIUsage.prototype, "latency_ms", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'timestamptz', default: () => 'NOW()' }), __metadata("design:type", Date) ], AIUsage.prototype, "started_at", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'timestamptz', nullable: true }), __metadata("design:type", Date) ], AIUsage.prototype, "completed_at", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'varchar', length: 100, nullable: true }), __metadata("design:type", String) ], AIUsage.prototype, "request_id", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'varchar', length: 50, nullable: true }), __metadata("design:type", String) ], AIUsage.prototype, "endpoint", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'text', nullable: true }), __metadata("design:type", String) ], AIUsage.prototype, "error_message", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'jsonb', default: {} }), __metadata("design:type", Object) ], AIUsage.prototype, "metadata", void 0); __decorate([ (0, typeorm_1.CreateDateColumn)({ type: 'timestamptz' }), __metadata("design:type", Date) ], AIUsage.prototype, "created_at", void 0); exports.AIUsage = AIUsage = __decorate([ (0, typeorm_1.Entity)({ name: 'usage', schema: 'ai' }) ], AIUsage); //# sourceMappingURL=ai-usage.entity.js.map