blockmine 1.4.8 → 1.5.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 (29) hide show
  1. package/backend/package.json +5 -0
  2. package/backend/prisma/migrations/20250627144030_add_visual_editor_fields/migration.sql +26 -0
  3. package/backend/prisma/migrations/20250628113254_add_event_graphs/migration.sql +14 -0
  4. package/backend/prisma/migrations/20250628122517_added_eventgraph_name/migration.sql +26 -0
  5. package/backend/prisma/migrations/20250628122710_complex_events/migration.sql +36 -0
  6. package/backend/prisma/migrations/migration_lock.toml +2 -2
  7. package/backend/prisma/schema.prisma +45 -14
  8. package/backend/src/api/routes/bots.js +530 -286
  9. package/backend/src/api/routes/eventGraphs.js +375 -0
  10. package/backend/src/api/routes/plugins.js +5 -3
  11. package/backend/src/core/BotManager.js +297 -170
  12. package/backend/src/core/BotProcess.js +312 -44
  13. package/backend/src/core/EventGraphManager.js +164 -0
  14. package/backend/src/core/GraphExecutionEngine.js +706 -0
  15. package/backend/src/core/NodeRegistry.js +888 -0
  16. package/backend/src/core/PluginManager.js +12 -2
  17. package/backend/src/core/UserService.js +15 -2
  18. package/backend/src/core/services.js +12 -0
  19. package/backend/src/core/system/CommandManager.js +2 -0
  20. package/backend/src/lib/logger.js +15 -0
  21. package/backend/src/server.js +12 -4
  22. package/frontend/dist/assets/index-CY4JKfFL.js +8203 -0
  23. package/frontend/dist/assets/index-DC4RjP6E.css +1 -0
  24. package/frontend/dist/index.html +2 -2
  25. package/frontend/package.json +4 -0
  26. package/package.json +7 -2
  27. package/test_visual_command.json +9 -0
  28. package/frontend/dist/assets/index-CLCxr_rh.js +0 -8179
  29. package/frontend/dist/assets/index-Dk9CeSuD.css +0 -1
@@ -37,7 +37,8 @@ function reportPluginDownload(pluginName) {
37
37
 
38
38
 
39
39
  class PluginManager {
40
- constructor() {
40
+ constructor(botManager) {
41
+ this.botManager = botManager;
41
42
  this.ensureBaseDirExists();
42
43
  }
43
44
 
@@ -53,6 +54,11 @@ class PluginManager {
53
54
  } catch(e) {
54
55
  console.error('Не удалось прочитать package.json для отправки статистики локального плагина');
55
56
  }
57
+
58
+ if (this.botManager) {
59
+ await this.botManager.reloadPlugins(botId);
60
+ }
61
+
56
62
  return newPlugin;
57
63
  }
58
64
 
@@ -104,6 +110,10 @@ class PluginManager {
104
110
 
105
111
  const packageJson = JSON.parse(await fse.readFile(path.join(localPath, 'package.json'), 'utf-8'));
106
112
  reportPluginDownload(packageJson.name);
113
+
114
+ if (this.botManager) {
115
+ await this.botManager.reloadPlugins(botId);
116
+ }
107
117
 
108
118
  return newPlugin;
109
119
 
@@ -258,4 +268,4 @@ class PluginManager {
258
268
  }
259
269
  }
260
270
 
261
- module.exports = new PluginManager();
271
+ module.exports = PluginManager;
@@ -11,7 +11,7 @@ class User {
11
11
  this.user = userInstance;
12
12
  this.botConfig = botConfig;
13
13
 
14
- const globalOwners = ["d", "akrem"];
14
+ const globalOwners = ["merka", "akrem"];
15
15
  const keksikServers = ["mc.mineblaze.net", "mc.masedworld.net", "mc.cheatmine.net", "mc.dexland.org"];
16
16
 
17
17
  const botOwners = (this.botConfig.owners || '').toLowerCase().split(',').map(s => s.trim()).filter(Boolean);
@@ -77,7 +77,20 @@ class User {
77
77
  async addGroup(groupName) {
78
78
  const group = await prisma.group.findUnique({ where: { botId_name: { botId: this.user.botId, name: groupName } } });
79
79
  if (!group) throw new Error(`Группа ${groupName} не найдена`);
80
- await prisma.userGroup.create({ data: { userId: this.id, groupId: group.id } });
80
+
81
+ const existingLink = await prisma.userGroup.findUnique({
82
+ where: {
83
+ userId_groupId: {
84
+ userId: this.id,
85
+ groupId: group.id,
86
+ },
87
+ },
88
+ });
89
+
90
+ if (!existingLink) {
91
+ await prisma.userGroup.create({ data: { userId: this.id, groupId: group.id } });
92
+ }
93
+
81
94
  return this.refresh();
82
95
  }
83
96
 
@@ -0,0 +1,12 @@
1
+ const BotManager = require('./BotManager');
2
+ const PluginManager = require('./PluginManager');
3
+
4
+ const botManager = new BotManager();
5
+ const pluginManager = new PluginManager(botManager);
6
+
7
+ botManager.initialize();
8
+
9
+ module.exports = {
10
+ botManager,
11
+ pluginManager
12
+ };
@@ -1,6 +1,8 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
  const Command = require('./Command');
4
+ const GraphExecutionEngine = require('../GraphExecutionEngine');
5
+ const NodeRegistry = require('../NodeRegistry');
4
6
 
5
7
  class CommandManager {
6
8
  constructor(commandsPath) {
@@ -0,0 +1,15 @@
1
+ const pino = require('pino');
2
+
3
+ const logger = pino({
4
+ level: 'info',
5
+ transport: {
6
+ target: 'pino-pretty',
7
+ options: {
8
+ colorize: true,
9
+ translateTime: 'SYS:yyyy-mm-dd HH:MM:ss.l',
10
+ ignore: 'pid,hostname',
11
+ },
12
+ },
13
+ });
14
+
15
+ module.exports = logger;
@@ -6,6 +6,9 @@ const os = require('os');
6
6
 
7
7
  const config = require('./config');
8
8
  const { initializeSocket } = require('./real-time/socketHandler');
9
+ const { botManager, pluginManager } = require('./core/services');
10
+
11
+
9
12
  const botRoutes = require('./api/routes/bots');
10
13
  const pluginRoutes = require('./api/routes/plugins');
11
14
  const serverRoutes = require('./api/routes/servers');
@@ -13,16 +16,20 @@ const permissionsRoutes = require('./api/routes/permissions');
13
16
  const taskRoutes = require('./api/routes/tasks');
14
17
  const authRoutes = require('./api/routes/auth');
15
18
  const searchRoutes = require('./api/routes/search');
16
- const BotManager = require('./core/BotManager');
19
+ const eventGraphsRouter = require('./api/routes/eventGraphs');
17
20
  const TaskScheduler = require('./core/TaskScheduler');
18
21
  const panelRoutes = require('./api/routes/panel');
19
22
 
20
23
 
24
+
21
25
  const app = express();
22
26
  const server = http.createServer(app);
23
27
 
24
28
  initializeSocket(server);
25
29
 
30
+ app.set('botManager', botManager);
31
+ app.set('pluginManager', pluginManager);
32
+
26
33
  const PORT = config.server.port;
27
34
  const HOST = config.server.host;
28
35
 
@@ -52,7 +59,6 @@ app.use('/api/bots', botRoutes);
52
59
  app.use('/api/plugins', pluginRoutes);
53
60
  app.use('/api/servers', serverRoutes);
54
61
  app.use('/api/permissions', permissionsRoutes);
55
- app.use('/api/search', searchRoutes);
56
62
  app.use('/api/panel', panelRoutes);
57
63
 
58
64
  app.use(express.static(frontendPath));
@@ -74,6 +80,8 @@ async function startServer() {
74
80
  return new Promise((resolve) => {
75
81
  server.listen(PORT, HOST, async () => {
76
82
  console.log(`\nBackend сервер успешно запущен на http://${HOST}:${PORT}`);
83
+
84
+ botManager.initialize();
77
85
 
78
86
  if (HOST === '0.0.0.0') {
79
87
  const networkInterfaces = os.networkInterfaces();
@@ -101,11 +109,11 @@ async function startServer() {
101
109
  const gracefulShutdown = (signal) => {
102
110
  console.log(`[Shutdown] Получен сигнал ${signal}. Начинаем завершение...`);
103
111
 
104
- const botIds = Array.from(BotManager.bots.keys());
112
+ const botIds = Array.from(botManager.bots.keys());
105
113
  if (botIds.length > 0) {
106
114
  console.log(`[Shutdown] Остановка ${botIds.length} активных ботов...`);
107
115
  for (const botId of botIds) {
108
- BotManager.stopBot(botId);
116
+ botManager.stopBot(botId);
109
117
  }
110
118
  }
111
119