Spaces:
Running
Running
Download apps/api/dist/workspace/workspace.controller.js from Benaah/MicProtocol: direct link, hf CLI and curl.
- Browser
- Download file 8.86 kB
-
https://huggingface.co/spaces/Benaah/MicProtocol/resolve/main/apps/api/dist/workspace/workspace.controller.js
- Command line
-
hf download hf://spaces/Benaah/MicProtocol/apps/api/dist/workspace/workspace.controller.js
-
curl -L -o workspace.controller.js https://huggingface.co/spaces/Benaah/MicProtocol/resolve/main/apps/api/dist/workspace/workspace.controller.js
8.86 kB
| ; | |
| 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.WorkspaceController = void 0; | |
| const common_1 = require("@nestjs/common"); | |
| const swagger_1 = require("@nestjs/swagger"); | |
| const workspace_service_1 = require("./workspace.service"); | |
| const better_auth_guard_1 = require("../auth/better-auth.guard"); | |
| const subscription_guard_1 = require("../billing/subscription.guard"); | |
| const workspace_dto_1 = require("./workspace.dto"); | |
| let WorkspaceController = class WorkspaceController { | |
| workspaceService; | |
| constructor(workspaceService) { | |
| this.workspaceService = workspaceService; | |
| } | |
| async findAll(req) { | |
| const userId = req.userId; | |
| return this.workspaceService.findByUser(userId); | |
| } | |
| async create(req, data) { | |
| const userId = req.userId; | |
| return this.workspaceService.create(userId, data); | |
| } | |
| async findOne(req, id) { | |
| const userId = req.userId; | |
| return this.workspaceService.findById(id, userId); | |
| } | |
| async update(req, id, data) { | |
| const userId = req.userId; | |
| return this.workspaceService.update(id, userId, data); | |
| } | |
| async delete(req, id) { | |
| const userId = req.userId; | |
| await this.workspaceService.delete(id, userId); | |
| } | |
| async inviteMember(req, workspaceId, data) { | |
| const userId = req.userId; | |
| return this.workspaceService.inviteMember(workspaceId, userId, data.email, data.role); | |
| } | |
| async removeMember(req, workspaceId, memberId) { | |
| const userId = req.userId; | |
| await this.workspaceService.removeMember(workspaceId, userId, memberId); | |
| } | |
| async updateMemberRole(req, workspaceId, memberId, data) { | |
| const userId = req.userId; | |
| return this.workspaceService.updateMemberRole(workspaceId, userId, memberId, data.role); | |
| } | |
| }; | |
| exports.WorkspaceController = WorkspaceController; | |
| __decorate([ | |
| (0, common_1.Get)(), | |
| (0, swagger_1.ApiOperation)({ | |
| summary: "List user workspaces", | |
| description: "Get all workspaces where the current user is a member", | |
| }), | |
| (0, swagger_1.ApiResponse)({ | |
| status: 200, | |
| description: "List of workspaces retrieved successfully", | |
| }), | |
| __param(0, (0, common_1.Req)()), | |
| __metadata("design:type", Function), | |
| __metadata("design:paramtypes", [Object]), | |
| __metadata("design:returntype", Promise) | |
| ], WorkspaceController.prototype, "findAll", null); | |
| __decorate([ | |
| (0, common_1.Post)(), | |
| (0, common_1.HttpCode)(common_1.HttpStatus.CREATED), | |
| (0, swagger_1.ApiOperation)({ | |
| summary: "Create workspace", | |
| description: "Create a new workspace with the current user as owner", | |
| }), | |
| (0, swagger_1.ApiResponse)({ | |
| status: 201, | |
| description: "Workspace created successfully", | |
| }), | |
| (0, swagger_1.ApiResponse)({ status: 409, description: "Slug already exists" }), | |
| __param(0, (0, common_1.Req)()), | |
| __param(1, (0, common_1.Body)()), | |
| __metadata("design:type", Function), | |
| __metadata("design:paramtypes", [Object, workspace_dto_1.CreateWorkspaceDto]), | |
| __metadata("design:returntype", Promise) | |
| ], WorkspaceController.prototype, "create", null); | |
| __decorate([ | |
| (0, common_1.Get)(":id"), | |
| (0, swagger_1.ApiOperation)({ summary: "Get workspace details" }), | |
| (0, swagger_1.ApiParam)({ name: "id", description: "Workspace ID" }), | |
| (0, swagger_1.ApiResponse)({ status: 200, description: "Workspace details retrieved" }), | |
| (0, swagger_1.ApiResponse)({ status: 404, description: "Workspace not found" }), | |
| (0, swagger_1.ApiResponse)({ status: 403, description: "Access denied" }), | |
| __param(0, (0, common_1.Req)()), | |
| __param(1, (0, common_1.Param)("id")), | |
| __metadata("design:type", Function), | |
| __metadata("design:paramtypes", [Object, String]), | |
| __metadata("design:returntype", Promise) | |
| ], WorkspaceController.prototype, "findOne", null); | |
| __decorate([ | |
| (0, common_1.Put)(":id"), | |
| (0, swagger_1.ApiOperation)({ summary: "Update workspace" }), | |
| (0, swagger_1.ApiParam)({ name: "id", description: "Workspace ID" }), | |
| (0, swagger_1.ApiResponse)({ status: 200, description: "Workspace updated" }), | |
| (0, swagger_1.ApiResponse)({ status: 403, description: "Insufficient permissions" }), | |
| __param(0, (0, common_1.Req)()), | |
| __param(1, (0, common_1.Param)("id")), | |
| __param(2, (0, common_1.Body)()), | |
| __metadata("design:type", Function), | |
| __metadata("design:paramtypes", [Object, String, workspace_dto_1.UpdateWorkspaceDto]), | |
| __metadata("design:returntype", Promise) | |
| ], WorkspaceController.prototype, "update", null); | |
| __decorate([ | |
| (0, common_1.Delete)(":id"), | |
| (0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT), | |
| (0, swagger_1.ApiOperation)({ | |
| summary: "Delete workspace", | |
| description: "Only workspace owner can delete", | |
| }), | |
| (0, swagger_1.ApiParam)({ name: "id", description: "Workspace ID" }), | |
| (0, swagger_1.ApiResponse)({ status: 204, description: "Workspace deleted" }), | |
| (0, swagger_1.ApiResponse)({ status: 403, description: "Only owner can delete" }), | |
| __param(0, (0, common_1.Req)()), | |
| __param(1, (0, common_1.Param)("id")), | |
| __metadata("design:type", Function), | |
| __metadata("design:paramtypes", [Object, String]), | |
| __metadata("design:returntype", Promise) | |
| ], WorkspaceController.prototype, "delete", null); | |
| __decorate([ | |
| (0, common_1.Post)(":id/members"), | |
| (0, common_1.HttpCode)(common_1.HttpStatus.CREATED), | |
| (0, swagger_1.ApiOperation)({ | |
| summary: "Invite member", | |
| description: "Invite a user to join the workspace", | |
| }), | |
| (0, swagger_1.ApiParam)({ name: "id", description: "Workspace ID" }), | |
| __param(0, (0, common_1.Req)()), | |
| __param(1, (0, common_1.Param)("id")), | |
| __param(2, (0, common_1.Body)()), | |
| __metadata("design:type", Function), | |
| __metadata("design:paramtypes", [Object, String, workspace_dto_1.InviteMemberDto]), | |
| __metadata("design:returntype", Promise) | |
| ], WorkspaceController.prototype, "inviteMember", null); | |
| __decorate([ | |
| (0, common_1.Delete)(":id/members/:memberId"), | |
| (0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT), | |
| (0, swagger_1.ApiOperation)({ summary: "Remove member from workspace" }), | |
| (0, swagger_1.ApiParam)({ name: "id", description: "Workspace ID" }), | |
| (0, swagger_1.ApiParam)({ name: "memberId", description: "User ID of member to remove" }), | |
| __param(0, (0, common_1.Req)()), | |
| __param(1, (0, common_1.Param)("id")), | |
| __param(2, (0, common_1.Param)("memberId")), | |
| __metadata("design:type", Function), | |
| __metadata("design:paramtypes", [Object, String, String]), | |
| __metadata("design:returntype", Promise) | |
| ], WorkspaceController.prototype, "removeMember", null); | |
| __decorate([ | |
| (0, common_1.Put)(":id/members/:memberId/role"), | |
| (0, swagger_1.ApiOperation)({ | |
| summary: "Update member role", | |
| description: "Only workspace owner can change roles", | |
| }), | |
| (0, swagger_1.ApiParam)({ name: "id", description: "Workspace ID" }), | |
| (0, swagger_1.ApiParam)({ name: "memberId", description: "User ID of member" }), | |
| __param(0, (0, common_1.Req)()), | |
| __param(1, (0, common_1.Param)("id")), | |
| __param(2, (0, common_1.Param)("memberId")), | |
| __param(3, (0, common_1.Body)()), | |
| __metadata("design:type", Function), | |
| __metadata("design:paramtypes", [Object, String, String, workspace_dto_1.UpdateMemberRoleDto]), | |
| __metadata("design:returntype", Promise) | |
| ], WorkspaceController.prototype, "updateMemberRole", null); | |
| exports.WorkspaceController = WorkspaceController = __decorate([ | |
| (0, swagger_1.ApiTags)("Workspaces"), | |
| (0, swagger_1.ApiBearerAuth)("jwt"), | |
| (0, common_1.UseGuards)(better_auth_guard_1.BetterAuthGuard, subscription_guard_1.SubscriptionGuard), | |
| (0, common_1.Controller)("workspaces"), | |
| __metadata("design:paramtypes", [workspace_service_1.WorkspaceService]) | |
| ], WorkspaceController); | |
| //# sourceMappingURL=workspace.controller.js.map |