"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); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; Object.defineProperty(exports, "__esModule", { value: true }); exports.GuestController = void 0; const common_1 = require("@nestjs/common"); const swagger_1 = require("@nestjs/swagger"); const guest_service_1 = require("./guest.service"); const better_auth_guard_1 = require("../auth/better-auth.guard"); const subscription_guard_1 = require("../billing/subscription.guard"); const guest_dto_1 = require("./guest.dto"); const shared_types_1 = require("@micprotocol/shared-types"); let GuestController = class GuestController { guestService; constructor(guestService) { this.guestService = guestService; } async findAll(req, podcastId, filter) { return this.guestService.findMany(podcastId, filter, req.userId); } async create(req, podcastId, data) { return this.guestService.create(podcastId, data, req.userId); } async bulkCreate(req, podcastId, data) { return this.guestService.createMany(podcastId, data.guests, req.userId); } async getTopPriority(req, podcastId, limit) { return this.guestService.getTopPriority(podcastId, limit, req.userId); } async getNeedsFollowUp(req, podcastId, days) { return this.guestService.getNeedsFollowUp(podcastId, days, req.userId); } async getStatusCounts(req, podcastId) { return this.guestService.getStatusCounts(podcastId, req.userId); } async findOne(req, podcastId, id) { return this.guestService.findById(id, podcastId, req.userId); } async update(req, podcastId, id, data) { return this.guestService.update(id, podcastId, data, req.userId); } async updateStatus(req, podcastId, id, data) { return this.guestService.updateStatus(id, podcastId, data.status, req.userId); } async delete(req, podcastId, id) { await this.guestService.delete(id, podcastId, req.userId); } async bulkDelete(req, podcastId, data) { return this.guestService.deleteMany(data.ids, podcastId, req.userId); } async addTag(req, podcastId, guestId, data) { return this.guestService.addTag(guestId, podcastId, data.tagId, req.userId); } async removeTag(req, podcastId, guestId, tagId) { await this.guestService.removeTag(guestId, podcastId, tagId, req.userId); } async merge(req, podcastId, data) { return this.guestService.mergeGuests(podcastId, data.targetId, data.sourceIds, req.userId); } }; exports.GuestController = GuestController; __decorate([ (0, common_1.Get)(), (0, swagger_1.ApiOperation)({ summary: "List podcast guests", description: "Get all guests with filtering, sorting, and pagination", }), (0, swagger_1.ApiParam)({ name: "podcastId", description: "Podcast ID" }), (0, swagger_1.ApiQuery)({ name: "status", enum: shared_types_1.GuestStatus, required: false }), (0, swagger_1.ApiQuery)({ name: "search", required: false }), (0, swagger_1.ApiQuery)({ name: "tags", required: false, description: "Comma-separated tag IDs" }), (0, swagger_1.ApiQuery)({ name: "minPriority", type: Number, required: false }), (0, swagger_1.ApiQuery)({ name: "maxPriority", type: Number, required: false }), (0, swagger_1.ApiQuery)({ name: "page", type: Number, required: false }), (0, swagger_1.ApiQuery)({ name: "limit", type: Number, required: false }), (0, swagger_1.ApiQuery)({ name: "sortBy", required: false, enum: ["fullName", "company", "status", "priorityScore", "lastContactAt", "createdAt"] }), (0, swagger_1.ApiQuery)({ name: "sortOrder", required: false, enum: ["asc", "desc"] }), (0, swagger_1.ApiResponse)({ status: 200, description: "Paginated list of guests with facets", }), __param(0, (0, common_1.Req)()), __param(1, (0, common_1.Param)("podcastId")), __param(2, (0, common_1.Query)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String, guest_dto_1.GuestFilterDto]), __metadata("design:returntype", Promise) ], GuestController.prototype, "findAll", null); __decorate([ (0, common_1.Post)(), (0, common_1.HttpCode)(common_1.HttpStatus.CREATED), (0, swagger_1.ApiOperation)({ summary: "Create guest", description: "Create a new guest with automatic priority scoring", }), (0, swagger_1.ApiParam)({ name: "podcastId", description: "Podcast ID" }), (0, swagger_1.ApiResponse)({ status: 201, description: "Guest created with computed priority score", }), (0, swagger_1.ApiResponse)({ status: 409, description: "Guest with email already exists" }), __param(0, (0, common_1.Req)()), __param(1, (0, common_1.Param)("podcastId")), __param(2, (0, common_1.Body)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String, guest_dto_1.CreateGuestDto]), __metadata("design:returntype", Promise) ], GuestController.prototype, "create", null); __decorate([ (0, common_1.Post)("bulk"), (0, common_1.HttpCode)(common_1.HttpStatus.CREATED), (0, swagger_1.ApiOperation)({ summary: "Bulk create guests", description: "Create multiple guests at once (useful for imports)", }), (0, swagger_1.ApiParam)({ name: "podcastId", description: "Podcast ID" }), __param(0, (0, common_1.Req)()), __param(1, (0, common_1.Param)("podcastId")), __param(2, (0, common_1.Body)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String, guest_dto_1.BulkCreateGuestsDto]), __metadata("design:returntype", Promise) ], GuestController.prototype, "bulkCreate", null); __decorate([ (0, common_1.Get)("top-priority"), (0, swagger_1.ApiOperation)({ summary: "Get top priority guests", description: "Get guests with highest priority scores for outreach", }), (0, swagger_1.ApiParam)({ name: "podcastId", description: "Podcast ID" }), (0, swagger_1.ApiQuery)({ name: "limit", type: Number, required: false, description: "Number of guests to return" }), __param(0, (0, common_1.Req)()), __param(1, (0, common_1.Param)("podcastId")), __param(2, (0, common_1.Query)("limit", new common_1.DefaultValuePipe(10), common_1.ParseIntPipe)), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String, Number]), __metadata("design:returntype", Promise) ], GuestController.prototype, "getTopPriority", null); __decorate([ (0, common_1.Get)("needs-follow-up"), (0, swagger_1.ApiOperation)({ summary: "Get guests needing follow-up", description: "Get contacted guests who haven't been reached in a while", }), (0, swagger_1.ApiParam)({ name: "podcastId", description: "Podcast ID" }), (0, swagger_1.ApiQuery)({ name: "days", type: Number, required: false, description: "Days since last contact" }), __param(0, (0, common_1.Req)()), __param(1, (0, common_1.Param)("podcastId")), __param(2, (0, common_1.Query)("days", new common_1.DefaultValuePipe(7), common_1.ParseIntPipe)), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String, Number]), __metadata("design:returntype", Promise) ], GuestController.prototype, "getNeedsFollowUp", null); __decorate([ (0, common_1.Get)("status-counts"), (0, swagger_1.ApiOperation)({ summary: "Get status distribution", description: "Get count of guests by status for dashboard", }), __param(0, (0, common_1.Req)()), __param(1, (0, common_1.Param)("podcastId")), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String]), __metadata("design:returntype", Promise) ], GuestController.prototype, "getStatusCounts", null); __decorate([ (0, common_1.Get)(":id"), (0, swagger_1.ApiOperation)({ summary: "Get guest details" }), (0, swagger_1.ApiParam)({ name: "podcastId", description: "Podcast ID" }), (0, swagger_1.ApiParam)({ name: "id", description: "Guest ID" }), (0, swagger_1.ApiResponse)({ status: 200, description: "Guest with full details" }), (0, swagger_1.ApiResponse)({ status: 404, description: "Guest not found" }), __param(0, (0, common_1.Req)()), __param(1, (0, common_1.Param)("podcastId")), __param(2, (0, common_1.Param)("id")), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String, String]), __metadata("design:returntype", Promise) ], GuestController.prototype, "findOne", null); __decorate([ (0, common_1.Put)(":id"), (0, swagger_1.ApiOperation)({ summary: "Update guest", description: "Update guest details with automatic score recalculation", }), (0, swagger_1.ApiParam)({ name: "podcastId", description: "Podcast ID" }), (0, swagger_1.ApiParam)({ name: "id", description: "Guest ID" }), __param(0, (0, common_1.Req)()), __param(1, (0, common_1.Param)("podcastId")), __param(2, (0, common_1.Param)("id")), __param(3, (0, common_1.Body)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String, String, guest_dto_1.UpdateGuestDto]), __metadata("design:returntype", Promise) ], GuestController.prototype, "update", null); __decorate([ (0, common_1.Patch)(":id/status"), (0, swagger_1.ApiOperation)({ summary: "Update guest status", description: "Update status with automatic timestamp tracking", }), (0, swagger_1.ApiParam)({ name: "podcastId", description: "Podcast ID" }), (0, swagger_1.ApiParam)({ name: "id", description: "Guest ID" }), __param(0, (0, common_1.Req)()), __param(1, (0, common_1.Param)("podcastId")), __param(2, (0, common_1.Param)("id")), __param(3, (0, common_1.Body)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String, String, guest_dto_1.UpdateGuestStatusDto]), __metadata("design:returntype", Promise) ], GuestController.prototype, "updateStatus", null); __decorate([ (0, common_1.Delete)(":id"), (0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT), (0, swagger_1.ApiOperation)({ summary: "Delete guest" }), __param(0, (0, common_1.Req)()), __param(1, (0, common_1.Param)("podcastId")), __param(2, (0, common_1.Param)("id")), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String, String]), __metadata("design:returntype", Promise) ], GuestController.prototype, "delete", null); __decorate([ (0, common_1.Post)("bulk-delete"), (0, common_1.HttpCode)(common_1.HttpStatus.OK), (0, swagger_1.ApiOperation)({ summary: "Bulk delete guests", description: "Delete multiple guests at once", }), __param(0, (0, common_1.Req)()), __param(1, (0, common_1.Param)("podcastId")), __param(2, (0, common_1.Body)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String, guest_dto_1.BulkDeleteGuestsDto]), __metadata("design:returntype", Promise) ], GuestController.prototype, "bulkDelete", null); __decorate([ (0, common_1.Post)(":id/tags"), (0, common_1.HttpCode)(common_1.HttpStatus.CREATED), (0, swagger_1.ApiOperation)({ summary: "Add tag to guest" }), __param(0, (0, common_1.Req)()), __param(1, (0, common_1.Param)("podcastId")), __param(2, (0, common_1.Param)("id")), __param(3, (0, common_1.Body)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String, String, guest_dto_1.AddTagDto]), __metadata("design:returntype", Promise) ], GuestController.prototype, "addTag", null); __decorate([ (0, common_1.Delete)(":id/tags/:tagId"), (0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT), (0, swagger_1.ApiOperation)({ summary: "Remove tag from guest" }), __param(0, (0, common_1.Req)()), __param(1, (0, common_1.Param)("podcastId")), __param(2, (0, common_1.Param)("id")), __param(3, (0, common_1.Param)("tagId")), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String, String, String]), __metadata("design:returntype", Promise) ], GuestController.prototype, "removeTag", null); __decorate([ (0, common_1.Post)("merge"), (0, common_1.HttpCode)(common_1.HttpStatus.OK), (0, swagger_1.ApiOperation)({ summary: "Merge duplicate guests", description: "Merge source guests into target guest", }), __param(0, (0, common_1.Req)()), __param(1, (0, common_1.Param)("podcastId")), __param(2, (0, common_1.Body)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String, guest_dto_1.MergeGuestsDto]), __metadata("design:returntype", Promise) ], GuestController.prototype, "merge", null); exports.GuestController = GuestController = __decorate([ (0, swagger_1.ApiTags)("Guests"), (0, swagger_1.ApiBearerAuth)("jwt"), (0, common_1.UseGuards)(better_auth_guard_1.BetterAuthGuard, subscription_guard_1.SubscriptionGuard), (0, common_1.Controller)("podcasts/:podcastId/guests"), __metadata("design:paramtypes", [guest_service_1.GuestService]) ], GuestController); //# sourceMappingURL=guest.controller.js.map