@enfin/chat-server 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +278 -0
- package/dist/bin/start.js +91 -0
- package/dist/chat-mongoose.module.js +48 -0
- package/dist/chat.constants.js +5 -0
- package/dist/chat.module.js +144 -0
- package/dist/controllers/rooms.controller.js +112 -0
- package/dist/controllers/upload.controller.js +123 -0
- package/dist/controllers/users.controller.js +101 -0
- package/dist/controllers/validation.controller.js +44 -0
- package/dist/dto/call.dto.js +21 -0
- package/dist/dto/message.dto.js +58 -0
- package/dist/dto/presence.dto.js +20 -0
- package/dist/dto/room.dto.js +48 -0
- package/dist/gateways/chat.gateway.js +439 -0
- package/dist/index.js +26 -0
- package/dist/interfaces/index.js +2 -0
- package/dist/main.js +38 -0
- package/dist/schemas/apikey.schema.js +33 -0
- package/dist/schemas/audiocall.schema.js +49 -0
- package/dist/schemas/index.js +34 -0
- package/dist/schemas/message.schema.js +40 -0
- package/dist/schemas/presence.schema.js +23 -0
- package/dist/schemas/room.schema.js +40 -0
- package/dist/schemas/user.schema.js +14 -0
- package/dist/services/apikey.service.js +120 -0
- package/dist/services/call.service.js +145 -0
- package/dist/services/message.service.js +108 -0
- package/dist/services/presence.service.js +65 -0
- package/dist/services/room.service.js +158 -0
- package/dist/services/storage/rate-limiter.service.js +57 -0
- package/dist/services/storage/storage.service.js +96 -0
- package/dist/services/storage/upload-handler.interface.js +2 -0
- package/package.json +68 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var UploadController_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.UploadController = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const platform_express_1 = require("@nestjs/platform-express");
|
|
19
|
+
const multer_1 = require("multer");
|
|
20
|
+
const path_1 = require("path");
|
|
21
|
+
const uuid_1 = require("uuid");
|
|
22
|
+
const apikey_service_1 = require("../services/apikey.service");
|
|
23
|
+
const message_service_1 = require("../services/message.service");
|
|
24
|
+
const room_service_1 = require("../services/room.service");
|
|
25
|
+
let resolvedUploadDir = (() => {
|
|
26
|
+
const raw = process.env.UPLOAD_DIR || 'uploads';
|
|
27
|
+
return (0, path_1.isAbsolute)(raw) ? raw : (0, path_1.join)(process.cwd(), raw);
|
|
28
|
+
})();
|
|
29
|
+
let UploadController = UploadController_1 = class UploadController {
|
|
30
|
+
constructor(apiKeyService, messageService, roomService, uploadDir, fileUploadHandler) {
|
|
31
|
+
this.apiKeyService = apiKeyService;
|
|
32
|
+
this.messageService = messageService;
|
|
33
|
+
this.roomService = roomService;
|
|
34
|
+
this.uploadDir = uploadDir;
|
|
35
|
+
this.fileUploadHandler = fileUploadHandler;
|
|
36
|
+
this.logger = new common_1.Logger(UploadController_1.name);
|
|
37
|
+
resolvedUploadDir = uploadDir;
|
|
38
|
+
}
|
|
39
|
+
async resolveTenant(apiKey) {
|
|
40
|
+
const result = await this.apiKeyService.validateKey(apiKey);
|
|
41
|
+
if (!result.valid) {
|
|
42
|
+
throw new common_1.BadRequestException(result.error || 'Invalid apiKey');
|
|
43
|
+
}
|
|
44
|
+
return result.tenantId;
|
|
45
|
+
}
|
|
46
|
+
async uploadFile(file, apiKey, body, req) {
|
|
47
|
+
if (!file) {
|
|
48
|
+
throw new common_1.BadRequestException('No file uploaded');
|
|
49
|
+
}
|
|
50
|
+
if (!apiKey) {
|
|
51
|
+
throw new common_1.BadRequestException('x-api-key header is required');
|
|
52
|
+
}
|
|
53
|
+
const tenantId = await this.resolveTenant(apiKey);
|
|
54
|
+
// Validate the room exists and user has access
|
|
55
|
+
const room = await this.roomService.getRoom(tenantId, body.roomId);
|
|
56
|
+
if (!room) {
|
|
57
|
+
throw new common_1.BadRequestException('Room not found');
|
|
58
|
+
}
|
|
59
|
+
if (this.fileUploadHandler) {
|
|
60
|
+
// Custom upload path: consumer handles the file (S3, Azure, GCS, etc.)
|
|
61
|
+
// and returns the URL. We don't write to local disk in this case.
|
|
62
|
+
this.logger.log(`[uploadFile] delegating to custom fileUploadHandler for tenantId=${tenantId}`);
|
|
63
|
+
const result = await this.fileUploadHandler({ file, tenantId, roomId: body.roomId });
|
|
64
|
+
if (!result || !result.fileUrl) {
|
|
65
|
+
throw new common_1.BadRequestException('fileUploadHandler must return { fileUrl, fileName, fileType, fileSize }');
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
success: true,
|
|
69
|
+
fileUrl: result.fileUrl,
|
|
70
|
+
fileName: result.fileName ?? file.originalname,
|
|
71
|
+
fileType: result.fileType ?? file.mimetype,
|
|
72
|
+
fileSize: result.fileSize ?? file.size,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// Build the file URL. If the consumer used a global prefix (e.g. 'api'),
|
|
76
|
+
// ChatUploadsController is mounted under that prefix too. The frontend uses
|
|
77
|
+
// serverUrl (without the API prefix) and concatenates fileUrl, so we must
|
|
78
|
+
// include the prefix here.
|
|
79
|
+
const originalUrl = req.originalUrl || req.url || '';
|
|
80
|
+
const match = originalUrl.match(/^(\/[^/]*)?\/upload(\/|$)/);
|
|
81
|
+
const basePrefix = match && match[1] ? match[1] : '';
|
|
82
|
+
const fileUrl = `${basePrefix}/uploads/${file.filename}`;
|
|
83
|
+
return {
|
|
84
|
+
success: true,
|
|
85
|
+
fileUrl,
|
|
86
|
+
fileName: file.originalname,
|
|
87
|
+
fileType: file.mimetype,
|
|
88
|
+
fileSize: file.size,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
exports.UploadController = UploadController;
|
|
93
|
+
__decorate([
|
|
94
|
+
(0, common_1.Post)(),
|
|
95
|
+
(0, common_1.UseInterceptors)((0, platform_express_1.FileInterceptor)('file', {
|
|
96
|
+
storage: (0, multer_1.diskStorage)({
|
|
97
|
+
destination: (_req, _file, cb) => cb(null, resolvedUploadDir),
|
|
98
|
+
filename: (_req, file, cb) => {
|
|
99
|
+
const filename = (0, uuid_1.v4)() + (0, path_1.extname)(file.originalname);
|
|
100
|
+
cb(null, filename);
|
|
101
|
+
},
|
|
102
|
+
}),
|
|
103
|
+
limits: {
|
|
104
|
+
fileSize: 50 * 1024 * 1024, // 50MB limit
|
|
105
|
+
},
|
|
106
|
+
})),
|
|
107
|
+
__param(0, (0, common_1.UploadedFile)()),
|
|
108
|
+
__param(1, (0, common_1.Headers)('x-api-key')),
|
|
109
|
+
__param(2, (0, common_1.Body)()),
|
|
110
|
+
__param(3, (0, common_1.Req)()),
|
|
111
|
+
__metadata("design:type", Function),
|
|
112
|
+
__metadata("design:paramtypes", [Object, String, Object, Object]),
|
|
113
|
+
__metadata("design:returntype", Promise)
|
|
114
|
+
], UploadController.prototype, "uploadFile", null);
|
|
115
|
+
exports.UploadController = UploadController = UploadController_1 = __decorate([
|
|
116
|
+
(0, common_1.Controller)('upload'),
|
|
117
|
+
__param(3, (0, common_1.Inject)('CHAT_UPLOAD_DIR')),
|
|
118
|
+
__param(4, (0, common_1.Optional)()),
|
|
119
|
+
__param(4, (0, common_1.Inject)('CHAT_UPLOAD_HANDLER')),
|
|
120
|
+
__metadata("design:paramtypes", [apikey_service_1.ApiKeyService,
|
|
121
|
+
message_service_1.MessageService,
|
|
122
|
+
room_service_1.RoomService, String, Function])
|
|
123
|
+
], UploadController);
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var UsersController_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.UsersController = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
19
|
+
const mongoose_2 = require("mongoose");
|
|
20
|
+
const user_schema_1 = require("../schemas/user.schema");
|
|
21
|
+
const chat_gateway_1 = require("../gateways/chat.gateway");
|
|
22
|
+
const presence_service_1 = require("../services/presence.service");
|
|
23
|
+
const apikey_service_1 = require("../services/apikey.service");
|
|
24
|
+
let UsersController = UsersController_1 = class UsersController {
|
|
25
|
+
constructor(userModel, presenceService, gateway, apiKeyService) {
|
|
26
|
+
this.userModel = userModel;
|
|
27
|
+
this.presenceService = presenceService;
|
|
28
|
+
this.gateway = gateway;
|
|
29
|
+
this.apiKeyService = apiKeyService;
|
|
30
|
+
this.logger = new common_1.Logger(UsersController_1.name);
|
|
31
|
+
}
|
|
32
|
+
async resolveTenant(apiKey) {
|
|
33
|
+
const result = await this.apiKeyService.validateKey(apiKey);
|
|
34
|
+
if (!result.valid) {
|
|
35
|
+
throw new common_1.BadRequestException(result.error || 'Invalid apiKey');
|
|
36
|
+
}
|
|
37
|
+
return result.tenantId;
|
|
38
|
+
}
|
|
39
|
+
async register(body) {
|
|
40
|
+
if (!body.name || !body.apiKey) {
|
|
41
|
+
throw new common_1.BadRequestException('name and apiKey are required');
|
|
42
|
+
}
|
|
43
|
+
const tenantId = await this.resolveTenant(body.apiKey);
|
|
44
|
+
const userId = body.userId || `user_${Math.random().toString(36).slice(2, 10)}`;
|
|
45
|
+
const user = await this.userModel.findOneAndUpdate({ tenantId, userId }, { userId, name: body.name, avatar: body.avatar }, { upsert: true, new: true });
|
|
46
|
+
// Mark user online in presence store and notify via gateway
|
|
47
|
+
await this.presenceService.setOnline(tenantId, user.userId);
|
|
48
|
+
try {
|
|
49
|
+
this.gateway.server.emit('presence:changed', { userId: user.userId, status: 'online' });
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
this.logger.warn('Failed to emit presence changed', e?.message || e);
|
|
53
|
+
}
|
|
54
|
+
return { userId: user.userId, name: user.name, avatar: user.avatar };
|
|
55
|
+
}
|
|
56
|
+
async list(apiKey) {
|
|
57
|
+
if (!apiKey) {
|
|
58
|
+
throw new common_1.BadRequestException('x-api-key header is required');
|
|
59
|
+
}
|
|
60
|
+
const tenantId = await this.resolveTenant(apiKey);
|
|
61
|
+
const users = await this.userModel.find({ tenantId }).lean().exec();
|
|
62
|
+
const userIds = users.map(u => u.userId);
|
|
63
|
+
// Get presence status for all users
|
|
64
|
+
const presences = await this.presenceService.getPresences(tenantId, userIds);
|
|
65
|
+
const presenceMap = new Map(presences.map(p => [p.userId, p]));
|
|
66
|
+
return users.map(u => {
|
|
67
|
+
const presence = presenceMap.get(u.userId);
|
|
68
|
+
return {
|
|
69
|
+
userId: u.userId,
|
|
70
|
+
name: u.name,
|
|
71
|
+
avatar: u.avatar,
|
|
72
|
+
isOnline: presence?.status === 'online',
|
|
73
|
+
status: presence?.status || 'offline',
|
|
74
|
+
lastSeen: presence?.lastSeen,
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
exports.UsersController = UsersController;
|
|
80
|
+
__decorate([
|
|
81
|
+
(0, common_1.Post)('register'),
|
|
82
|
+
__param(0, (0, common_1.Body)()),
|
|
83
|
+
__metadata("design:type", Function),
|
|
84
|
+
__metadata("design:paramtypes", [Object]),
|
|
85
|
+
__metadata("design:returntype", Promise)
|
|
86
|
+
], UsersController.prototype, "register", null);
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, common_1.Get)(),
|
|
89
|
+
__param(0, (0, common_1.Headers)('x-api-key')),
|
|
90
|
+
__metadata("design:type", Function),
|
|
91
|
+
__metadata("design:paramtypes", [String]),
|
|
92
|
+
__metadata("design:returntype", Promise)
|
|
93
|
+
], UsersController.prototype, "list", null);
|
|
94
|
+
exports.UsersController = UsersController = UsersController_1 = __decorate([
|
|
95
|
+
(0, common_1.Controller)('users'),
|
|
96
|
+
__param(0, (0, mongoose_1.InjectModel)(user_schema_1.User.modelName)),
|
|
97
|
+
__metadata("design:paramtypes", [mongoose_2.Model,
|
|
98
|
+
presence_service_1.PresenceService,
|
|
99
|
+
chat_gateway_1.ChatGateway,
|
|
100
|
+
apikey_service_1.ApiKeyService])
|
|
101
|
+
], UsersController);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var ValidationController_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.ValidationController = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const apikey_service_1 = require("../services/apikey.service");
|
|
19
|
+
const chat_shared_1 = require("../../../shared/dist/index.js");
|
|
20
|
+
let ValidationController = ValidationController_1 = class ValidationController {
|
|
21
|
+
constructor(apiKeyService) {
|
|
22
|
+
this.apiKeyService = apiKeyService;
|
|
23
|
+
this.logger = new common_1.Logger(ValidationController_1.name);
|
|
24
|
+
}
|
|
25
|
+
async validate(body) {
|
|
26
|
+
const { apiKey, clientVersion } = body || {};
|
|
27
|
+
this.logger.log(`[VALIDATION] validate request for apiKey=${apiKey?.slice(0, 12)}...`);
|
|
28
|
+
const result = await this.apiKeyService.validateKey(apiKey, clientVersion || chat_shared_1.SDK_VERSION);
|
|
29
|
+
this.logger.log(`[VALIDATION] result valid=${result.valid} tenantId=${result.tenantId} mode=${result.mode}`);
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
exports.ValidationController = ValidationController;
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, common_1.Post)('validate'),
|
|
36
|
+
__param(0, (0, common_1.Body)()),
|
|
37
|
+
__metadata("design:type", Function),
|
|
38
|
+
__metadata("design:paramtypes", [Object]),
|
|
39
|
+
__metadata("design:returntype", Promise)
|
|
40
|
+
], ValidationController.prototype, "validate", null);
|
|
41
|
+
exports.ValidationController = ValidationController = ValidationController_1 = __decorate([
|
|
42
|
+
(0, common_1.Controller)('validation'),
|
|
43
|
+
__metadata("design:paramtypes", [apikey_service_1.ApiKeyService])
|
|
44
|
+
], ValidationController);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CreateCallDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
class CreateCallDto {
|
|
15
|
+
}
|
|
16
|
+
exports.CreateCallDto = CreateCallDto;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, class_validator_1.IsString)(),
|
|
19
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], CreateCallDto.prototype, "participantId", void 0);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.GetMessagesQueryDto = exports.CreateMessageDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
class CreateMessageDto {
|
|
15
|
+
}
|
|
16
|
+
exports.CreateMessageDto = CreateMessageDto;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, class_validator_1.IsString)(),
|
|
19
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], CreateMessageDto.prototype, "roomId", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, class_validator_1.IsString)(),
|
|
24
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], CreateMessageDto.prototype, "content", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, class_validator_1.IsString)(),
|
|
29
|
+
(0, class_validator_1.IsOptional)(),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], CreateMessageDto.prototype, "fileUrl", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, class_validator_1.IsString)(),
|
|
34
|
+
(0, class_validator_1.IsOptional)(),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], CreateMessageDto.prototype, "fileType", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, class_validator_1.IsString)(),
|
|
39
|
+
(0, class_validator_1.IsOptional)(),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], CreateMessageDto.prototype, "fileName", void 0);
|
|
42
|
+
class GetMessagesQueryDto {
|
|
43
|
+
}
|
|
44
|
+
exports.GetMessagesQueryDto = GetMessagesQueryDto;
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, class_validator_1.IsString)(),
|
|
47
|
+
(0, class_validator_1.IsOptional)(),
|
|
48
|
+
__metadata("design:type", String)
|
|
49
|
+
], GetMessagesQueryDto.prototype, "roomId", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, class_validator_1.IsOptional)(),
|
|
52
|
+
__metadata("design:type", Number)
|
|
53
|
+
], GetMessagesQueryDto.prototype, "limit", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, class_validator_1.IsString)(),
|
|
56
|
+
(0, class_validator_1.IsOptional)(),
|
|
57
|
+
__metadata("design:type", String)
|
|
58
|
+
], GetMessagesQueryDto.prototype, "beforeCursor", void 0);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.UpdatePresenceDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
class UpdatePresenceDto {
|
|
15
|
+
}
|
|
16
|
+
exports.UpdatePresenceDto = UpdatePresenceDto;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, class_validator_1.IsEnum)(['online', 'offline', 'away']),
|
|
19
|
+
__metadata("design:type", String)
|
|
20
|
+
], UpdatePresenceDto.prototype, "status", void 0);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.UpdateRoomDto = exports.CreateRoomDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
class CreateRoomDto {
|
|
15
|
+
}
|
|
16
|
+
exports.CreateRoomDto = CreateRoomDto;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, class_validator_1.IsString)(),
|
|
19
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], CreateRoomDto.prototype, "name", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, class_validator_1.IsEnum)(['direct', 'group']),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], CreateRoomDto.prototype, "type", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, class_validator_1.IsArray)(),
|
|
28
|
+
(0, class_validator_1.IsString)({ each: true }),
|
|
29
|
+
__metadata("design:type", Array)
|
|
30
|
+
], CreateRoomDto.prototype, "members", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, class_validator_1.IsString)(),
|
|
33
|
+
(0, class_validator_1.IsOptional)(),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], CreateRoomDto.prototype, "avatar", void 0);
|
|
36
|
+
class UpdateRoomDto {
|
|
37
|
+
}
|
|
38
|
+
exports.UpdateRoomDto = UpdateRoomDto;
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, class_validator_1.IsString)(),
|
|
41
|
+
(0, class_validator_1.IsOptional)(),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], UpdateRoomDto.prototype, "name", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, class_validator_1.IsString)(),
|
|
46
|
+
(0, class_validator_1.IsOptional)(),
|
|
47
|
+
__metadata("design:type", String)
|
|
48
|
+
], UpdateRoomDto.prototype, "avatar", void 0);
|