blockmine 1.4.7 → 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 (32) 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 +298 -171
  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/image/1.png +0 -0
  27. package/image/2.png +0 -0
  28. package/image/3.png +0 -0
  29. package/package.json +7 -2
  30. package/test_visual_command.json +9 -0
  31. package/frontend/dist/assets/index-BGh31hwx.js +0 -8179
  32. package/frontend/dist/assets/index-CKAIPNvH.css +0 -1
@@ -16,5 +16,10 @@
16
16
  "license": "ISC",
17
17
  "devDependencies": {
18
18
  "nodemon": "^3.1.2"
19
+ },
20
+ "dependencies": {
21
+ "express-validator": "^7.2.1",
22
+ "pino": "^9.7.0",
23
+ "pino-pretty": "^13.0.0"
19
24
  }
20
25
  }
@@ -0,0 +1,26 @@
1
+ -- RedefineTables
2
+ PRAGMA defer_foreign_keys=ON;
3
+ PRAGMA foreign_keys=OFF;
4
+ CREATE TABLE "new_Command" (
5
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
6
+ "botId" INTEGER NOT NULL,
7
+ "name" TEXT NOT NULL,
8
+ "isEnabled" BOOLEAN NOT NULL DEFAULT true,
9
+ "cooldown" INTEGER NOT NULL DEFAULT 0,
10
+ "aliases" TEXT NOT NULL DEFAULT '[]',
11
+ "description" TEXT,
12
+ "owner" TEXT,
13
+ "permissionId" INTEGER,
14
+ "allowedChatTypes" TEXT NOT NULL DEFAULT '["chat", "private"]',
15
+ "isVisual" BOOLEAN NOT NULL DEFAULT false,
16
+ "argumentsJson" TEXT DEFAULT '[]',
17
+ "graphJson" TEXT DEFAULT 'null',
18
+ CONSTRAINT "Command_botId_fkey" FOREIGN KEY ("botId") REFERENCES "Bot" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
19
+ CONSTRAINT "Command_permissionId_fkey" FOREIGN KEY ("permissionId") REFERENCES "Permission" ("id") ON DELETE SET NULL ON UPDATE CASCADE
20
+ );
21
+ INSERT INTO "new_Command" ("aliases", "allowedChatTypes", "botId", "cooldown", "description", "id", "isEnabled", "name", "owner", "permissionId") SELECT "aliases", "allowedChatTypes", "botId", "cooldown", "description", "id", "isEnabled", "name", "owner", "permissionId" FROM "Command";
22
+ DROP TABLE "Command";
23
+ ALTER TABLE "new_Command" RENAME TO "Command";
24
+ CREATE UNIQUE INDEX "Command_botId_name_key" ON "Command"("botId", "name");
25
+ PRAGMA foreign_keys=ON;
26
+ PRAGMA defer_foreign_keys=OFF;
@@ -0,0 +1,14 @@
1
+ -- CreateTable
2
+ CREATE TABLE "EventGraph" (
3
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
4
+ "botId" INTEGER NOT NULL,
5
+ "eventType" TEXT NOT NULL,
6
+ "isEnabled" BOOLEAN NOT NULL DEFAULT true,
7
+ "graphJson" TEXT DEFAULT 'null',
8
+ "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
9
+ "updatedAt" DATETIME NOT NULL,
10
+ CONSTRAINT "EventGraph_botId_fkey" FOREIGN KEY ("botId") REFERENCES "Bot" ("id") ON DELETE CASCADE ON UPDATE CASCADE
11
+ );
12
+
13
+ -- CreateIndex
14
+ CREATE UNIQUE INDEX "EventGraph_botId_eventType_key" ON "EventGraph"("botId", "eventType");
@@ -0,0 +1,26 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - Added the required column `name` to the `EventGraph` table without a default value. This is not possible if the table is not empty.
5
+
6
+ */
7
+ -- RedefineTables
8
+ PRAGMA defer_foreign_keys=ON;
9
+ PRAGMA foreign_keys=OFF;
10
+ CREATE TABLE "new_EventGraph" (
11
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
12
+ "botId" INTEGER NOT NULL,
13
+ "name" TEXT NOT NULL,
14
+ "eventType" TEXT NOT NULL,
15
+ "isEnabled" BOOLEAN NOT NULL DEFAULT true,
16
+ "graphJson" TEXT DEFAULT 'null',
17
+ "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
18
+ "updatedAt" DATETIME NOT NULL,
19
+ CONSTRAINT "EventGraph_botId_fkey" FOREIGN KEY ("botId") REFERENCES "Bot" ("id") ON DELETE CASCADE ON UPDATE CASCADE
20
+ );
21
+ INSERT INTO "new_EventGraph" ("botId", "createdAt", "eventType", "graphJson", "id", "isEnabled", "updatedAt", "name") SELECT "botId", "createdAt", "eventType", "graphJson", "id", "isEnabled", "updatedAt", "eventType" FROM "EventGraph";
22
+ DROP TABLE "EventGraph";
23
+ ALTER TABLE "new_EventGraph" RENAME TO "EventGraph";
24
+ CREATE UNIQUE INDEX "EventGraph_botId_name_key" ON "EventGraph"("botId", "name");
25
+ PRAGMA foreign_keys=ON;
26
+ PRAGMA defer_foreign_keys=OFF;
@@ -0,0 +1,36 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the column `eventType` on the `EventGraph` table. All the data in the column will be lost.
5
+
6
+ */
7
+ -- CreateTable
8
+ CREATE TABLE "EventTrigger" (
9
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
10
+ "graphId" INTEGER NOT NULL,
11
+ "eventType" TEXT NOT NULL,
12
+ CONSTRAINT "EventTrigger_graphId_fkey" FOREIGN KEY ("graphId") REFERENCES "EventGraph" ("id") ON DELETE CASCADE ON UPDATE CASCADE
13
+ );
14
+
15
+ -- RedefineTables
16
+ PRAGMA defer_foreign_keys=ON;
17
+ PRAGMA foreign_keys=OFF;
18
+ CREATE TABLE "new_EventGraph" (
19
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
20
+ "botId" INTEGER NOT NULL,
21
+ "name" TEXT NOT NULL,
22
+ "isEnabled" BOOLEAN NOT NULL DEFAULT true,
23
+ "graphJson" TEXT DEFAULT 'null',
24
+ "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
25
+ "updatedAt" DATETIME NOT NULL,
26
+ CONSTRAINT "EventGraph_botId_fkey" FOREIGN KEY ("botId") REFERENCES "Bot" ("id") ON DELETE CASCADE ON UPDATE CASCADE
27
+ );
28
+ INSERT INTO "new_EventGraph" ("botId", "createdAt", "graphJson", "id", "isEnabled", "name", "updatedAt") SELECT "botId", "createdAt", "graphJson", "id", "isEnabled", "name", "updatedAt" FROM "EventGraph";
29
+ DROP TABLE "EventGraph";
30
+ ALTER TABLE "new_EventGraph" RENAME TO "EventGraph";
31
+ CREATE UNIQUE INDEX "EventGraph_botId_name_key" ON "EventGraph"("botId", "name");
32
+ PRAGMA foreign_keys=ON;
33
+ PRAGMA defer_foreign_keys=OFF;
34
+
35
+ -- CreateIndex
36
+ CREATE UNIQUE INDEX "EventTrigger_graphId_eventType_key" ON "EventTrigger"("graphId", "eventType");
@@ -1,3 +1,3 @@
1
- # Please do not edit this file manually
2
- # It should be added in your version-control system (i.e. Git)
1
+ # Please do not edit this file manually
2
+ # It should be added in your version-control system (i.e. Git)
3
3
  provider = "sqlite"
@@ -36,7 +36,8 @@ model Bot {
36
36
  users User[]
37
37
  groups Group[]
38
38
  permissions Permission[]
39
- commands Command[]
39
+ commands Command[]
40
+ eventGraphs EventGraph[]
40
41
 
41
42
  createdAt DateTime @default(now())
42
43
  updatedAt DateTime @updatedAt
@@ -64,22 +65,52 @@ model InstalledPlugin {
64
65
  }
65
66
 
66
67
  model Command {
67
- id Int @id @default(autoincrement())
68
- botId Int
69
- bot Bot @relation(fields: [botId], references: [id], onDelete: Cascade)
70
- name String
71
- isEnabled Boolean @default(true)
72
- cooldown Int @default(0)
73
- aliases String @default("[]") // Храним как джсон строку
74
- description String?
75
- owner String?
76
- permissionId Int?
77
- permission Permission? @relation(fields: [permissionId], references: [id], onDelete: SetNull)
78
- allowedChatTypes String @default("[\"chat\", \"private\"]")
68
+ id Int @id @default(autoincrement())
69
+ botId Int
70
+ bot Bot @relation(fields: [botId], references: [id], onDelete: Cascade)
71
+ name String
72
+ isEnabled Boolean @default(true)
73
+ cooldown Int @default(0)
74
+ aliases String @default("[]")
75
+ description String?
76
+ owner String?
77
+ permissionId Int?
78
+ permission Permission? @relation(fields: [permissionId], references: [id], onDelete: SetNull)
79
+ allowedChatTypes String @default("[\"chat\", \"private\"]")
80
+
81
+ isVisual Boolean @default(false)
82
+ argumentsJson String? @default("[]")
83
+ graphJson String? @default("null")
79
84
 
80
85
  @@unique([botId, name])
81
86
  }
82
87
 
88
+ model EventGraph {
89
+ id Int @id @default(autoincrement())
90
+ botId Int
91
+ bot Bot @relation(fields: [botId], references: [id], onDelete: Cascade)
92
+ name String
93
+ isEnabled Boolean @default(true)
94
+ graphJson String? @default("null")
95
+ variables String? @default("[]")
96
+
97
+ triggers EventTrigger[]
98
+
99
+ createdAt DateTime @default(now())
100
+ updatedAt DateTime @updatedAt
101
+
102
+ @@unique([botId, name])
103
+ }
104
+
105
+ model EventTrigger {
106
+ id Int @id @default(autoincrement())
107
+ graphId Int
108
+ graph EventGraph @relation(fields: [graphId], references: [id], onDelete: Cascade)
109
+ eventType String // e.g., "entitySpawn", "chat"
110
+
111
+ @@unique([graphId, eventType])
112
+ }
113
+
83
114
  model User {
84
115
  id Int @id @default(autoincrement())
85
116
  username String
@@ -163,7 +194,7 @@ model PanelUser {
163
194
  // Роли пользователей (Admin, Moderator, Viewer)
164
195
  model PanelRole {
165
196
  id Int @id @default(autoincrement())
166
- name String @unique // Например, "Admin", "Moderator", "Viewer"
197
+ name String @unique
167
198
 
168
199
  // Храним права как джсон строку. SQLite не поддерживает массивы.
169
200
  // Пример: '["bot:create", "bot:delete", "user:manage"]'