@builder6/server 0.6.3 → 0.7.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.
Files changed (93) hide show
  1. package/dist/app.express.js +0 -1
  2. package/dist/app.express.js.map +1 -1
  3. package/dist/app.module.js +4 -4
  4. package/dist/app.module.js.map +1 -1
  5. package/dist/index.d.ts +0 -1
  6. package/dist/index.js +0 -15
  7. package/dist/index.js.map +1 -1
  8. package/dist/oidc/oidc.service.js +1 -1
  9. package/dist/oidc/oidc.service.js.map +1 -1
  10. package/dist/plugin/plugin.module.js +1 -3
  11. package/dist/plugin/plugin.module.js.map +1 -1
  12. package/package.json +9 -8
  13. package/dist/files/files.controller.d.ts +0 -11
  14. package/dist/files/files.controller.js +0 -148
  15. package/dist/files/files.controller.js.map +0 -1
  16. package/dist/files/files.module.d.ts +0 -2
  17. package/dist/files/files.module.js +0 -26
  18. package/dist/files/files.module.js.map +0 -1
  19. package/dist/files/files.moleculer.d.ts +0 -10
  20. package/dist/files/files.moleculer.js +0 -53
  21. package/dist/files/files.moleculer.js.map +0 -1
  22. package/dist/files/files.service.d.ts +0 -30
  23. package/dist/files/files.service.js +0 -207
  24. package/dist/files/files.service.js.map +0 -1
  25. package/dist/files/index.d.ts +0 -3
  26. package/dist/files/index.js +0 -20
  27. package/dist/files/index.js.map +0 -1
  28. package/dist/rooms/globals/augmentation.d.ts +0 -25
  29. package/dist/rooms/globals/augmentation.js +0 -3
  30. package/dist/rooms/globals/augmentation.js.map +0 -1
  31. package/dist/rooms/lib/DateToString.d.ts +0 -3
  32. package/dist/rooms/lib/DateToString.js +0 -3
  33. package/dist/rooms/lib/DateToString.js.map +0 -1
  34. package/dist/rooms/lib/Json.d.ts +0 -9
  35. package/dist/rooms/lib/Json.js +0 -18
  36. package/dist/rooms/lib/Json.js.map +0 -1
  37. package/dist/rooms/lib/utils.d.ts +0 -33
  38. package/dist/rooms/lib/utils.js +0 -122
  39. package/dist/rooms/lib/utils.js.map +0 -1
  40. package/dist/rooms/protocol/AuthToken.d.ts +0 -50
  41. package/dist/rooms/protocol/AuthToken.js +0 -49
  42. package/dist/rooms/protocol/AuthToken.js.map +0 -1
  43. package/dist/rooms/protocol/Authentication.d.ts +0 -22
  44. package/dist/rooms/protocol/Authentication.js +0 -3
  45. package/dist/rooms/protocol/Authentication.js.map +0 -1
  46. package/dist/rooms/protocol/BaseActivitiesData.d.ts +0 -4
  47. package/dist/rooms/protocol/BaseActivitiesData.js +0 -3
  48. package/dist/rooms/protocol/BaseActivitiesData.js.map +0 -1
  49. package/dist/rooms/protocol/BaseRoomInfo.d.ts +0 -6
  50. package/dist/rooms/protocol/BaseRoomInfo.js +0 -3
  51. package/dist/rooms/protocol/BaseRoomInfo.js.map +0 -1
  52. package/dist/rooms/protocol/BaseUserMeta.d.ts +0 -10
  53. package/dist/rooms/protocol/BaseUserMeta.js +0 -3
  54. package/dist/rooms/protocol/BaseUserMeta.js.map +0 -1
  55. package/dist/rooms/protocol/ClientMsg.d.ts +0 -41
  56. package/dist/rooms/protocol/ClientMsg.js +0 -13
  57. package/dist/rooms/protocol/ClientMsg.js.map +0 -1
  58. package/dist/rooms/protocol/Comments.d.ts +0 -146
  59. package/dist/rooms/protocol/Comments.js +0 -3
  60. package/dist/rooms/protocol/Comments.js.map +0 -1
  61. package/dist/rooms/protocol/InboxNotifications.d.ts +0 -49
  62. package/dist/rooms/protocol/InboxNotifications.js +0 -3
  63. package/dist/rooms/protocol/InboxNotifications.js.map +0 -1
  64. package/dist/rooms/protocol/Op.d.ts +0 -82
  65. package/dist/rooms/protocol/Op.js +0 -28
  66. package/dist/rooms/protocol/Op.js.map +0 -1
  67. package/dist/rooms/protocol/SerializedCrdt.d.ts +0 -40
  68. package/dist/rooms/protocol/SerializedCrdt.js +0 -19
  69. package/dist/rooms/protocol/SerializedCrdt.js.map +0 -1
  70. package/dist/rooms/protocol/ServerMsg.d.ts +0 -128
  71. package/dist/rooms/protocol/ServerMsg.js +0 -25
  72. package/dist/rooms/protocol/ServerMsg.js.map +0 -1
  73. package/dist/rooms/protocol/VersionHistory.d.ts +0 -9
  74. package/dist/rooms/protocol/VersionHistory.js +0 -3
  75. package/dist/rooms/protocol/VersionHistory.js.map +0 -1
  76. package/dist/rooms/rooms.controller.d.ts +0 -64
  77. package/dist/rooms/rooms.controller.js +0 -401
  78. package/dist/rooms/rooms.controller.js.map +0 -1
  79. package/dist/rooms/rooms.gateway.d.ts +0 -30
  80. package/dist/rooms/rooms.gateway.js +0 -188
  81. package/dist/rooms/rooms.gateway.js.map +0 -1
  82. package/dist/rooms/rooms.guard.d.ts +0 -9
  83. package/dist/rooms/rooms.guard.js +0 -48
  84. package/dist/rooms/rooms.guard.js.map +0 -1
  85. package/dist/rooms/rooms.module.d.ts +0 -2
  86. package/dist/rooms/rooms.module.js +0 -36
  87. package/dist/rooms/rooms.module.js.map +0 -1
  88. package/dist/rooms/rooms.service.d.ts +0 -51
  89. package/dist/rooms/rooms.service.js +0 -225
  90. package/dist/rooms/rooms.service.js.map +0 -1
  91. package/views/ag-grid/README.md +0 -15
  92. package/views/ag-grid/ag-grid.hbs +0 -1099
  93. package/views/devextreme/datagrid.hbs +0 -240
@@ -1,188 +0,0 @@
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.RoomsGateway = void 0;
13
- const websockets_1 = require("@nestjs/websockets");
14
- const ws_1 = require("ws");
15
- const ioredis_1 = require("ioredis");
16
- const url = require("url");
17
- const uuid_1 = require("uuid");
18
- const ServerMsg_1 = require("./protocol/ServerMsg");
19
- const jwt_1 = require("@nestjs/jwt");
20
- let RoomsGateway = class RoomsGateway {
21
- constructor(jwtService) {
22
- this.jwtService = jwtService;
23
- this.roomStates = new Map();
24
- this.redis = new ioredis_1.default('redis://localhost:6379');
25
- this.pubRedis = new ioredis_1.default('redis://localhost:6379');
26
- }
27
- async afterInit() {
28
- console.log('Rooms Gateway Initialized with Redis');
29
- this.redis.subscribe('rooms_channel', (err) => {
30
- if (err) {
31
- console.error('Failed to subscribe: ', err);
32
- }
33
- });
34
- this.redis.on('message', (channel, message) => {
35
- if (channel === 'rooms_channel') {
36
- const parsedMessage = JSON.parse(message);
37
- this.handleBroadcastedMessage(parsedMessage);
38
- }
39
- });
40
- }
41
- async handleConnection(client, req) {
42
- const parsedUrl = url.parse(req.url, true);
43
- const roomId = parsedUrl.query['roomId'];
44
- const token = parsedUrl.query['tok'];
45
- const jwt = (await this.jwtService.decode(token));
46
- const userId = jwt.uid;
47
- if (userId && roomId) {
48
- client.on('message', (message) => {
49
- const messageStr = message.toString();
50
- console.log('Received message from client: ', messageStr);
51
- if (messageStr === 'ping') {
52
- client.send('pong');
53
- return;
54
- }
55
- const parsedMessage = JSON.parse(messageStr);
56
- if (Array.isArray(parsedMessage)) {
57
- parsedMessage.forEach((msg) => {
58
- this.handleClientMessage(client, msg);
59
- });
60
- }
61
- else if (typeof parsedMessage === 'object') {
62
- this.handleClientMessage(client, parsedMessage);
63
- }
64
- });
65
- client.on('close', () => {
66
- this.handleLeaveRoom(client, { roomId, userId });
67
- });
68
- await this.handleJoinRoom(client, { roomId, userId });
69
- }
70
- else {
71
- client.close();
72
- }
73
- }
74
- async handleClientMessage(client, parsedMessage) {
75
- console.log('Received message from client: ', parsedMessage);
76
- if (parsedMessage.type === ServerMsg_1.ServerMsgCode.UPDATE_PRESENCE) {
77
- this.handleUpdatePresence(client, parsedMessage);
78
- }
79
- }
80
- async handleJoinRoom(client, payload) {
81
- const { roomId, userId } = payload;
82
- let roomState = this.roomStates.get(roomId);
83
- if (!roomState) {
84
- roomState = { roomId, connections: {} };
85
- this.roomStates.set(roomId, roomState);
86
- }
87
- const connectionId = await this.pubRedis.incr(`room:${roomId}:connectionId`);
88
- const nonce = (0, uuid_1.v4)();
89
- roomState.connections[connectionId] = { userId, nonce, roomId, client };
90
- await this.pubRedis.hset(`room:${roomId}:connections`, connectionId.toString(), JSON.stringify({ userId, nonce, roomId }));
91
- client.connectionId = connectionId;
92
- const users = await Promise.all(Object.keys(roomState.connections).map(async (connId) => {
93
- const connection = roomState.connections[parseInt(connId)];
94
- const roomId = connection.roomId;
95
- const scopes = await this.getUserScopes(roomId, connection.userId);
96
- return {
97
- connectionId: parseInt(connId),
98
- userId: connection.userId,
99
- scopes,
100
- };
101
- }));
102
- const roomStateResponse = {
103
- type: ServerMsg_1.ServerMsgCode.ROOM_STATE,
104
- actor: connectionId,
105
- nonce: nonce,
106
- scopes: await this.getUserScopes(roomId, userId),
107
- users: users.reduce((acc, user) => {
108
- acc[user.connectionId] = {
109
- id: user.userId,
110
- scopes: user.scopes,
111
- };
112
- return acc;
113
- }, {}),
114
- };
115
- client.send(JSON.stringify(roomStateResponse));
116
- this.broadcastToRoom(roomId, {
117
- type: ServerMsg_1.ServerMsgCode.USER_JOINED,
118
- actor: connectionId,
119
- userId,
120
- });
121
- console.log(`User ${connectionId},${userId} has join room: ${roomId}`);
122
- return connectionId;
123
- }
124
- async handleLeaveRoom(client, payload) {
125
- const { roomId, userId } = payload;
126
- const connectionId = client.connectionId;
127
- const roomState = this.roomStates.get(roomId);
128
- if (roomState && roomState.connections[connectionId]) {
129
- delete roomState.connections[connectionId];
130
- await this.pubRedis.hdel(`room:${roomId}:connections`, connectionId.toString());
131
- if (Object.keys(roomState.connections).length === 0) {
132
- this.roomStates.delete(roomId);
133
- }
134
- this.broadcastToRoom(roomId, {
135
- type: ServerMsg_1.ServerMsgCode.USER_LEFT,
136
- actor: connectionId,
137
- });
138
- console.log(`User ${connectionId},${userId} has left room: ${roomId}`);
139
- }
140
- }
141
- async handleUpdatePresence(client, payload) {
142
- }
143
- broadcastToRoom(roomId, message) {
144
- this.pubRedis.publish('rooms_channel', JSON.stringify({ roomId, message }));
145
- }
146
- handleBroadcastedMessage(parsedMessage) {
147
- const { roomId, message } = parsedMessage;
148
- const roomState = this.roomStates.get(roomId);
149
- if (roomState) {
150
- Object.keys(roomState.connections).forEach((connectionId) => {
151
- const client = roomState.connections[connectionId].client;
152
- if (client.readyState === ws_1.WebSocket.OPEN) {
153
- client.send(JSON.stringify(message));
154
- }
155
- });
156
- }
157
- }
158
- async getUserScopes(roomId, userId) {
159
- return ['room:write', 'comments:write'];
160
- }
161
- };
162
- exports.RoomsGateway = RoomsGateway;
163
- __decorate([
164
- (0, websockets_1.WebSocketServer)(),
165
- __metadata("design:type", ws_1.Server)
166
- ], RoomsGateway.prototype, "server", void 0);
167
- __decorate([
168
- (0, websockets_1.SubscribeMessage)('leaveRoom'),
169
- __metadata("design:type", Function),
170
- __metadata("design:paramtypes", [ws_1.WebSocket, Object]),
171
- __metadata("design:returntype", Promise)
172
- ], RoomsGateway.prototype, "handleLeaveRoom", null);
173
- __decorate([
174
- (0, websockets_1.SubscribeMessage)('updatePresence'),
175
- __metadata("design:type", Function),
176
- __metadata("design:paramtypes", [ws_1.WebSocket, Object]),
177
- __metadata("design:returntype", Promise)
178
- ], RoomsGateway.prototype, "handleUpdatePresence", null);
179
- exports.RoomsGateway = RoomsGateway = __decorate([
180
- (0, websockets_1.WebSocketGateway)({
181
- path: '/v7',
182
- cors: {
183
- origin: '*',
184
- },
185
- }),
186
- __metadata("design:paramtypes", [jwt_1.JwtService])
187
- ], RoomsGateway);
188
- //# sourceMappingURL=rooms.gateway.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":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EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAC9E,CAAC;IAEO,wBAAwB,CAAC,aAGhC;QACC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,aAAa,CAAC;QAC1C,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAE9C,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;gBAC1D,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC;gBAC1D,IAAI,MAAM,CAAC,UAAU,KAAK,cAAS,CAAC,IAAI,EAAE,CAAC;oBACzC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;gBACvC,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,MAAc,EAAE,MAAc;QAChD,OAAO,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IAC1C,CAAC;CACF,CAAA;AA/NY,oCAAY;AACJ;IAAlB,IAAA,4BAAe,GAAE;8BAAS,WAAM;4CAAC;AAsJ5B;IADL,IAAA,6BAAgB,EAAC,WAAW,CAAC;;qCAEpB,cAAS;;mDA+BlB;AAGK;IADL,IAAA,6BAAgB,EAAC,gBAAgB,CAAC;;qCAEzB,cAAS;;wDASlB;uBApMU,YAAY;IANxB,IAAA,6BAAgB,EAAC;QAChB,IAAI,EAAE,KAAK;QACX,IAAI,EAAE;YACJ,MAAM,EAAE,GAAG;SACZ;KACF,CAAC;qCAQgC,gBAAU;GAP/B,YAAY,CA+NxB"}
@@ -1,9 +0,0 @@
1
- import { CanActivate, ExecutionContext } from '@nestjs/common';
2
- import { RoomsService } from './rooms.service';
3
- import { JwtService } from '@nestjs/jwt';
4
- export declare class RoomsGuard implements CanActivate {
5
- private roomsService;
6
- private jwtService;
7
- constructor(roomsService: RoomsService, jwtService: JwtService);
8
- canActivate(context: ExecutionContext): Promise<boolean>;
9
- }
@@ -1,48 +0,0 @@
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.RoomsGuard = void 0;
13
- const common_1 = require("@nestjs/common");
14
- const rooms_service_1 = require("./rooms.service");
15
- const jwt_1 = require("@nestjs/jwt");
16
- let RoomsGuard = class RoomsGuard {
17
- constructor(roomsService, jwtService) {
18
- this.roomsService = roomsService;
19
- this.jwtService = jwtService;
20
- }
21
- async canActivate(context) {
22
- const request = context.switchToHttp().getRequest();
23
- const [type, bearerToken] = request.headers.authorization?.split(' ') ?? [];
24
- const token = type === 'Bearer' ? bearerToken : undefined;
25
- if (!token) {
26
- console.error('Token not found', token);
27
- throw new common_1.UnauthorizedException();
28
- }
29
- if (this.jwtService.verify(token) === false) {
30
- throw new common_1.UnauthorizedException();
31
- }
32
- try {
33
- const jwt = await this.jwtService.decode(token);
34
- request['jwt'] = jwt;
35
- }
36
- catch {
37
- throw new common_1.UnauthorizedException();
38
- }
39
- return true;
40
- }
41
- };
42
- exports.RoomsGuard = RoomsGuard;
43
- exports.RoomsGuard = RoomsGuard = __decorate([
44
- (0, common_1.Injectable)(),
45
- __metadata("design:paramtypes", [rooms_service_1.RoomsService,
46
- jwt_1.JwtService])
47
- ], RoomsGuard);
48
- //# sourceMappingURL=rooms.guard.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rooms.guard.js","sourceRoot":"","sources":["../../src/rooms/rooms.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAKwB;AACxB,mDAA+C;AAC/C,qCAAyC;AAGlC,IAAM,UAAU,GAAhB,MAAM,UAAU;IACrB,YACU,YAA0B,EAC1B,UAAsB;QADtB,iBAAY,GAAZ,YAAY,CAAc;QAC1B,eAAU,GAAV,UAAU,CAAY;IAC7B,CAAC;IAEJ,KAAK,CAAC,WAAW,CAAC,OAAyB;QACzC,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QAC5E,MAAM,KAAK,GAAG,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1D,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;YACxC,MAAM,IAAI,8BAAqB,EAAE,CAAC;QACpC,CAAC;QACD,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,KAAK,EAAE,CAAC;YAC5C,MAAM,IAAI,8BAAqB,EAAE,CAAC;QACpC,CAAC;QACD,IAAI,CAAC;YAGH,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAChD,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;QACvB,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,8BAAqB,EAAE,CAAC;QACpC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AA3BY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;qCAGa,4BAAY;QACd,gBAAU;GAHrB,UAAU,CA2BtB"}
@@ -1,2 +0,0 @@
1
- export declare class RoomsModule {
2
- }
@@ -1,36 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.RoomsModule = void 0;
10
- const common_1 = require("@nestjs/common");
11
- const rooms_controller_1 = require("./rooms.controller");
12
- const rooms_service_1 = require("./rooms.service");
13
- const core_1 = require("@builder6/core");
14
- const jwt_1 = require("@nestjs/jwt");
15
- const core_2 = require("@builder6/core");
16
- const rooms_gateway_1 = require("./rooms.gateway");
17
- const files_module_1 = require("../files/files.module");
18
- let RoomsModule = class RoomsModule {
19
- };
20
- exports.RoomsModule = RoomsModule;
21
- exports.RoomsModule = RoomsModule = __decorate([
22
- (0, common_1.Module)({
23
- imports: [
24
- core_2.AuthModule,
25
- core_1.MongodbModule,
26
- files_module_1.FilesModule,
27
- jwt_1.JwtModule.register({
28
- secret: process.env.JWT_SECRET || 'secret',
29
- signOptions: { expiresIn: '60s' },
30
- }),
31
- ],
32
- controllers: [rooms_controller_1.RoomsController],
33
- providers: [rooms_service_1.RoomsService, rooms_gateway_1.RoomsGateway],
34
- })
35
- ], RoomsModule);
36
- //# sourceMappingURL=rooms.module.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rooms.module.js","sourceRoot":"","sources":["../../src/rooms/rooms.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,yDAAqD;AACrD,mDAA+C;AAC/C,yCAA+C;AAC/C,qCAAwC;AACxC,yCAA4C;AAC5C,mDAA+C;AAC/C,wDAAmD;AAgB5C,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IAbvB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,iBAAU;YACV,oBAAa;YACb,0BAAW;YACX,eAAS,CAAC,QAAQ,CAAC;gBACjB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,QAAQ;gBAC1C,WAAW,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;aAClC,CAAC;SACH;QACD,WAAW,EAAE,CAAC,kCAAe,CAAC;QAC9B,SAAS,EAAE,CAAC,4BAAY,EAAE,4BAAY,CAAC;KACxC,CAAC;GACW,WAAW,CAAG"}
@@ -1,51 +0,0 @@
1
- import { MongodbService } from '@builder6/core';
2
- export interface CreateThreadParams {
3
- id?: string;
4
- comment?: CreateCommentParams;
5
- metadata?: object;
6
- resolved: boolean;
7
- roomId?: string;
8
- userId?: string;
9
- }
10
- export interface CreateCommentParams {
11
- id?: string;
12
- attachmentIds: string[];
13
- body: object;
14
- roomId?: string;
15
- threadId?: string;
16
- userId?: string;
17
- }
18
- export interface Attachment {
19
- id: string;
20
- mimeType: string;
21
- name: string;
22
- size: number;
23
- type: string;
24
- }
25
- export declare class RoomsService {
26
- private mongodbService;
27
- constructor(mongodbService: MongodbService);
28
- getAttachmentById(attachmentId: string): Promise<Attachment>;
29
- getUsers(userIds: string | string[]): Promise<any[]>;
30
- searchUsers(spaceId: string, keyword: string, roomId: string): Promise<string[]>;
31
- getThread(roomId: string, threadId: string): Promise<any>;
32
- getThreads(roomId: string, since?: Date): Promise<any>;
33
- getComments(roomId: string, threadId: string): Promise<any>;
34
- createThread({ id, comment, metadata, resolved, roomId, userId, }: CreateThreadParams): Promise<any>;
35
- updateThread(threadId: any, thread?: CreateThreadParams): Promise<any>;
36
- createComment({ id, attachmentIds, body, roomId, threadId, userId, }: CreateCommentParams): Promise<any>;
37
- updateComment(commentId: any, { attachmentIds, body, userId }: CreateCommentParams): Promise<any>;
38
- deleteComment(commentId: any): Promise<any>;
39
- createReaction(commentId: string, { userId, emoji }: {
40
- userId: string;
41
- emoji: string;
42
- }): Promise<{
43
- emoji: string;
44
- createdAt: any;
45
- userId: string;
46
- }>;
47
- deleteReaction(commentId: string, { userId, emoji }: {
48
- userId: string;
49
- emoji: string;
50
- }): Promise<any>;
51
- }
@@ -1,225 +0,0 @@
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.RoomsService = void 0;
13
- const core_1 = require("@builder6/core");
14
- const common_1 = require("@nestjs/common");
15
- let RoomsService = class RoomsService {
16
- constructor(mongodbService) {
17
- this.mongodbService = mongodbService;
18
- }
19
- async getAttachmentById(attachmentId) {
20
- const attachment = await this.mongodbService.findOne('cfs.files.filerecord', {
21
- _id: attachmentId,
22
- });
23
- return {
24
- id: attachmentId,
25
- mimeType: attachment.original.type,
26
- name: attachment.original.name,
27
- size: attachment.original.size,
28
- type: 'attachment',
29
- };
30
- }
31
- async getUsers(userIds) {
32
- if (typeof userIds === 'string') {
33
- userIds = [userIds];
34
- }
35
- const users = [];
36
- for (const userId of userIds) {
37
- const user = await this.mongodbService.findOne('users', {
38
- _id: userId,
39
- });
40
- users.push({
41
- name: user ? user.name : 'Unknown',
42
- });
43
- }
44
- return users;
45
- }
46
- async searchUsers(spaceId, keyword, roomId) {
47
- const spaceUsers = await this.mongodbService.find('space_users', {
48
- space: spaceId,
49
- $or: [
50
- { username: { $regex: keyword, $options: 'i' } },
51
- { email: { $regex: keyword, $options: 'i' } },
52
- { name: { $regex: keyword, $options: 'i' } },
53
- ],
54
- });
55
- return spaceUsers.map((spaceUser) => spaceUser.user);
56
- }
57
- async getThread(roomId, threadId) {
58
- const thread = await this.mongodbService.findOne('b6_threads', {
59
- roomId: roomId,
60
- _id: threadId,
61
- });
62
- if (!thread) {
63
- return null;
64
- }
65
- const comments = await this.getComments(roomId, threadId);
66
- thread.comments = comments;
67
- return thread;
68
- }
69
- async getThreads(roomId, since) {
70
- const queryOptions = { roomId: roomId };
71
- if (since) {
72
- queryOptions.updatedAt = { $gt: since };
73
- }
74
- const threads = await this.mongodbService.find('b6_threads', queryOptions);
75
- for (const thread of threads) {
76
- const comments = await this.getComments(roomId, thread.id);
77
- thread.comments = comments;
78
- }
79
- return threads;
80
- }
81
- async getComments(roomId, threadId) {
82
- const comments = await this.mongodbService.find('b6_comments', {
83
- roomId: roomId,
84
- threadId: threadId,
85
- });
86
- for (const comment of comments) {
87
- comment.attachments = [];
88
- for (const attachmentId of comment.attachmentIds) {
89
- const attachment = await this.getAttachmentById(attachmentId);
90
- comment.attachments.push(attachment);
91
- }
92
- }
93
- return comments;
94
- }
95
- async createThread({ id, comment, metadata, resolved = false, roomId, userId, }) {
96
- const newThread = {
97
- createdAt: new Date().toISOString(),
98
- updatedAt: new Date().toISOString(),
99
- _id: id,
100
- id,
101
- resolved,
102
- metadata,
103
- type: 'thread',
104
- roomId,
105
- userId,
106
- };
107
- const result = await this.mongodbService.insertOne('b6_threads', newThread);
108
- const newComment = await this.createComment({
109
- id: comment.id,
110
- attachmentIds: comment.attachmentIds,
111
- body: comment.body,
112
- roomId,
113
- threadId: id,
114
- userId,
115
- });
116
- result.comments = [newComment];
117
- return result;
118
- }
119
- async updateThread(threadId, thread) {
120
- const newThread = {
121
- updatedAt: new Date().toISOString(),
122
- ...thread,
123
- };
124
- const result = await this.mongodbService.findOneAndUpdate('b6_threads', { _id: threadId }, newThread);
125
- return result;
126
- }
127
- async createComment({ id, attachmentIds, body, roomId, threadId, userId, }) {
128
- const newComment = {
129
- createdAt: new Date().toISOString(),
130
- _id: id,
131
- id,
132
- reactions: [],
133
- roomId,
134
- threadId,
135
- userId,
136
- type: 'comment',
137
- attachmentIds,
138
- body,
139
- };
140
- const result = await this.mongodbService.insertOne('b6_comments', newComment);
141
- result.attachments = [];
142
- for (const attachmentId of attachmentIds) {
143
- const attachment = await this.getAttachmentById(attachmentId);
144
- result.attachments.push(attachment);
145
- }
146
- delete result['_id'];
147
- delete result['attachmentIds'];
148
- return result;
149
- }
150
- async updateComment(commentId, { attachmentIds, body, userId }) {
151
- const newComment = {
152
- updatedAt: new Date().toISOString(),
153
- type: 'comment',
154
- attachmentIds,
155
- body,
156
- userId,
157
- };
158
- const result = (await this.mongodbService.findOneAndUpdate('b6_comments', { _id: commentId }, newComment));
159
- result.attachments = [];
160
- for (const attachmentId of attachmentIds) {
161
- const attachment = await this.getAttachmentById(attachmentId);
162
- result.attachments.push(attachment);
163
- }
164
- delete result['_id'];
165
- delete result['attachmentIds'];
166
- return result;
167
- }
168
- async deleteComment(commentId) {
169
- const result = await this.mongodbService.deleteOne('b6_comments', {
170
- _id: commentId,
171
- });
172
- return result;
173
- }
174
- async createReaction(commentId, { userId, emoji }) {
175
- const comment = await this.mongodbService.findOne('b6_comments', {
176
- _id: commentId,
177
- });
178
- if (!comment) {
179
- throw new Error('Comment not found');
180
- }
181
- let reaction = comment.reactions.find((reaction) => reaction.emoji === emoji);
182
- if (reaction) {
183
- const userExists = reaction.users.some((user) => user.id === userId);
184
- if (!userExists) {
185
- reaction.users.push({ id: userId });
186
- }
187
- }
188
- else {
189
- reaction = {
190
- emoji,
191
- createdAt: new Date().toISOString(),
192
- users: [{ id: userId }],
193
- };
194
- comment.reactions.push(reaction);
195
- }
196
- await this.mongodbService.findOneAndUpdate('b6_comments', { _id: commentId }, comment);
197
- return {
198
- emoji,
199
- createdAt: reaction.createdAt,
200
- userId,
201
- };
202
- }
203
- async deleteReaction(commentId, { userId, emoji }) {
204
- const comment = await this.mongodbService.findOne('b6_comments', {
205
- _id: commentId,
206
- });
207
- if (!comment) {
208
- throw new Error('Comment not found');
209
- }
210
- const reaction = comment.reactions.find((reaction) => reaction.emoji === emoji);
211
- if (!reaction) {
212
- throw new Error('Reaction not found');
213
- }
214
- reaction.users = reaction.users.filter((user) => user.id !== userId);
215
- comment.reactions = comment.reactions.filter((reaction) => reaction.users.length > 0);
216
- await this.mongodbService.findOneAndUpdate('b6_comments', { _id: commentId }, comment);
217
- return null;
218
- }
219
- };
220
- exports.RoomsService = RoomsService;
221
- exports.RoomsService = RoomsService = __decorate([
222
- (0, common_1.Injectable)(),
223
- __metadata("design:paramtypes", [core_1.MongodbService])
224
- ], RoomsService);
225
- //# sourceMappingURL=rooms.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rooms.service.js","sourceRoot":"","sources":["../../src/rooms/rooms.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAgD;AAChD,2CAA4C;AA6BrC,IAAM,YAAY,GAAlB,MAAM,YAAY;IACvB,YAAoB,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;IAAG,CAAC;IAEtD,KAAK,CAAC,iBAAiB,CAAC,YAAoB;QAI1C,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAClD,sBAAsB,EACtB;YACE,GAAG,EAAE,YAAY;SAClB,CACF,CAAC;QACF,OAA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AAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC;QAErE,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAC1C,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CACxC,CAAC;QAEF,MAAM,IAAI,CAAC,cAAc,CAAC,gBAAgB,CACxC,aAAa,EACb,EAAE,GAAG,EAAE,SAAS,EAAE,EAClB,OAAO,CACR,CAAC;QAEF,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAxUY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;qCAEyB,qBAAc;GADvC,YAAY,CAwUxB"}
@@ -1,15 +0,0 @@
1
- ## 数据校验
2
-
3
- 先校验字段值有效性,校验合法的各种字段类型值,再校验用户配置的校验规则,最终把所有校验错误信息合并提示给用户。
4
-
5
- ### 字段类型校验
6
-
7
- 各种字段类型校验规则:
8
-
9
- - number: 合法number,小数位数
10
- - date: 合法的日期格式,YYYY-MM-DD、YYYY/MM/DD,兼容前导0省略情况,另外兼容了 YYYY-MM-DDTHH:MM:SS.SSSZ 这种服务端返回的格式(复制其它字段列保存时,是保存整行数据,日期列会自动取这种格式提交)
11
- - select: 数据类型只支持字符串,且必须是字段定义过的选项范围内值
12
- - boolean: true/false TRUE/FALSE
13
-
14
- 其它逻辑:每种字段类型校验失败都不会去主动变更转换字段值,以原始值交给ag-grid显示以明显告知用户数据不合法。
15
-