@gameap/debug 0.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.
@@ -0,0 +1,397 @@
1
+ import type { ServerData } from '@gameap/plugin-sdk'
2
+
3
+ // Extended server type for API responses (includes nested game object)
4
+ export interface ServerListItem {
5
+ id: number
6
+ enabled: boolean
7
+ installed: number // 0 = not installed, 1 = installed, 2 = installing
8
+ blocked: boolean
9
+ name: string
10
+ game_id: string
11
+ ds_id: number
12
+ game_mod_id: number
13
+ expires: string | null
14
+ server_ip: string
15
+ server_port: number
16
+ query_port: number
17
+ rcon_port: number
18
+ process_active: boolean
19
+ last_process_check: string
20
+ game: GameInfo
21
+ online: boolean
22
+ }
23
+
24
+ // Game info for nested game object
25
+ export interface GameInfo {
26
+ code: string
27
+ name: string
28
+ engine: string
29
+ engine_version: string
30
+ steam_app_id_linux?: number
31
+ steam_app_id_windows?: number
32
+ steam_app_set_config?: string
33
+ remote_repository_linux?: string | null
34
+ remote_repository_windows?: string | null
35
+ local_repository_linux?: string | null
36
+ local_repository_windows?: string | null
37
+ enabled?: number
38
+ }
39
+
40
+ // Full server details for /api/servers/:id
41
+ export interface ServerDetails extends ServerListItem {
42
+ uuid: string
43
+ uuid_short: string
44
+ rcon: string
45
+ dir: string
46
+ su_user: string
47
+ cpu_limit: number | null
48
+ ram_limit: number | null
49
+ net_limit: number | null
50
+ start_command: string
51
+ stop_command: string | null
52
+ force_stop_command: string | null
53
+ restart_command: string | null
54
+ aliases: Record<string, string | number>
55
+ vars: Record<string, string> | null
56
+ created_at: string
57
+ updated_at: string
58
+ }
59
+
60
+ // Mock games with full info
61
+ const minecraftGame: GameInfo = {
62
+ code: 'minecraft',
63
+ name: 'Minecraft',
64
+ engine: 'Minecraft',
65
+ engine_version: '1',
66
+ steam_app_id_linux: 0,
67
+ steam_app_id_windows: 0,
68
+ steam_app_set_config: '',
69
+ remote_repository_linux: 'http://packages.gameap.com/mcrun/mcrun-v1.2.0-linux-amd64.tar.gz',
70
+ remote_repository_windows: 'http://packages.gameap.com/mcrun/mcrun-v1.2.0-windows-amd64.zip',
71
+ local_repository_linux: null,
72
+ local_repository_windows: null,
73
+ enabled: 1,
74
+ }
75
+
76
+ const cs2Game: GameInfo = {
77
+ code: 'cs2',
78
+ name: 'Counter-Strike 2',
79
+ engine: 'Source2',
80
+ engine_version: '1',
81
+ steam_app_id_linux: 730,
82
+ steam_app_id_windows: 730,
83
+ steam_app_set_config: '',
84
+ remote_repository_linux: null,
85
+ remote_repository_windows: null,
86
+ local_repository_linux: null,
87
+ local_repository_windows: null,
88
+ enabled: 1,
89
+ }
90
+
91
+ const rustGame: GameInfo = {
92
+ code: 'rust',
93
+ name: 'Rust',
94
+ engine: 'Unity',
95
+ engine_version: '1',
96
+ steam_app_id_linux: 258550,
97
+ steam_app_id_windows: 258550,
98
+ steam_app_set_config: '',
99
+ remote_repository_linux: null,
100
+ remote_repository_windows: null,
101
+ local_repository_linux: null,
102
+ local_repository_windows: null,
103
+ enabled: 1,
104
+ }
105
+
106
+ // Mock servers for list API
107
+ export const mockServersList: ServerListItem[] = [
108
+ {
109
+ id: 1,
110
+ enabled: true,
111
+ installed: 1,
112
+ blocked: false,
113
+ name: 'Minecraft Survival',
114
+ game_id: 'minecraft',
115
+ ds_id: 1,
116
+ game_mod_id: 1,
117
+ expires: null,
118
+ server_ip: '192.168.1.100',
119
+ server_port: 25565,
120
+ query_port: 25565,
121
+ rcon_port: 25575,
122
+ process_active: true,
123
+ last_process_check: new Date().toISOString(),
124
+ game: minecraftGame,
125
+ online: true,
126
+ },
127
+ {
128
+ id: 2,
129
+ enabled: true,
130
+ installed: 1,
131
+ blocked: false,
132
+ name: 'CS2 Competitive',
133
+ game_id: 'cs2',
134
+ ds_id: 1,
135
+ game_mod_id: 2,
136
+ expires: null,
137
+ server_ip: '192.168.1.101',
138
+ server_port: 27015,
139
+ query_port: 27015,
140
+ rcon_port: 27015,
141
+ process_active: false,
142
+ last_process_check: new Date().toISOString(),
143
+ game: cs2Game,
144
+ online: false,
145
+ },
146
+ {
147
+ id: 3,
148
+ enabled: true,
149
+ installed: 0, // Not installed
150
+ blocked: false,
151
+ name: 'Rust Server',
152
+ game_id: 'rust',
153
+ ds_id: 1,
154
+ game_mod_id: 3,
155
+ expires: null,
156
+ server_ip: '192.168.1.102',
157
+ server_port: 28015,
158
+ query_port: 28016,
159
+ rcon_port: 28016,
160
+ process_active: false,
161
+ last_process_check: new Date().toISOString(),
162
+ game: rustGame,
163
+ online: false,
164
+ },
165
+ ]
166
+
167
+ // Full server details for /api/servers/:id
168
+ export const mockServersDetails: Record<number, ServerDetails> = {
169
+ 1: {
170
+ id: 1,
171
+ uuid: '019a1234-abcd-7000-8000-000000000001',
172
+ uuid_short: '019a1234',
173
+ enabled: true,
174
+ installed: 1,
175
+ blocked: false,
176
+ name: 'Minecraft Survival',
177
+ game_id: 'minecraft',
178
+ ds_id: 1,
179
+ game_mod_id: 1,
180
+ expires: null,
181
+ server_ip: '192.168.1.100',
182
+ server_port: 25565,
183
+ query_port: 25565,
184
+ rcon_port: 25575,
185
+ game: minecraftGame,
186
+ last_process_check: new Date().toISOString(),
187
+ online: true,
188
+ rcon: 'rcon_password_123',
189
+ dir: 'servers/019a1234-abcd-7000-8000-000000000001',
190
+ su_user: 'gameap',
191
+ cpu_limit: null,
192
+ ram_limit: null,
193
+ net_limit: null,
194
+ start_command: './mcrun run --version={version} --mod={mod} --ip={ip} --port={port} --query-port={query_port} --rcon-port={rcon_port} --rcon-password={rcon_password}',
195
+ stop_command: null,
196
+ force_stop_command: null,
197
+ restart_command: null,
198
+ process_active: true,
199
+ aliases: {
200
+ ip: '192.168.1.100',
201
+ port: 25565,
202
+ query_port: 25565,
203
+ rcon_password: 'rcon_password_123',
204
+ rcon_port: 25575,
205
+ uuid: '019a1234-abcd-7000-8000-000000000001',
206
+ uuid_short: '019a1234',
207
+ },
208
+ vars: {
209
+ version: '1.20.4',
210
+ mod: 'vanilla',
211
+ },
212
+ created_at: '2024-01-01T10:00:00+00:00',
213
+ updated_at: '2024-12-17T12:00:00+00:00',
214
+ },
215
+ 2: {
216
+ id: 2,
217
+ uuid: '019a5678-efgh-7000-8000-000000000002',
218
+ uuid_short: '019a5678',
219
+ enabled: true,
220
+ installed: 1,
221
+ blocked: false,
222
+ name: 'CS2 Competitive',
223
+ game_id: 'cs2',
224
+ ds_id: 1,
225
+ game_mod_id: 2,
226
+ expires: null,
227
+ server_ip: '192.168.1.101',
228
+ server_port: 27015,
229
+ query_port: 27015,
230
+ rcon_port: 27015,
231
+ game: cs2Game,
232
+ last_process_check: new Date().toISOString(),
233
+ online: false,
234
+ rcon: 'cs2_rcon_pass',
235
+ dir: 'servers/019a5678-efgh-7000-8000-000000000002',
236
+ su_user: 'gameap',
237
+ cpu_limit: null,
238
+ ram_limit: null,
239
+ net_limit: null,
240
+ start_command: './cs2 -dedicated +map de_dust2 +maxplayers 20 -port {port}',
241
+ stop_command: null,
242
+ force_stop_command: null,
243
+ restart_command: null,
244
+ process_active: false,
245
+ aliases: {
246
+ ip: '192.168.1.101',
247
+ port: 27015,
248
+ query_port: 27015,
249
+ rcon_password: 'cs2_rcon_pass',
250
+ rcon_port: 27015,
251
+ uuid: '019a5678-efgh-7000-8000-000000000002',
252
+ uuid_short: '019a5678',
253
+ },
254
+ vars: {
255
+ maxplayers: '20',
256
+ map: 'de_dust2',
257
+ },
258
+ created_at: '2024-02-15T14:00:00+00:00',
259
+ updated_at: '2024-12-17T12:00:00+00:00',
260
+ },
261
+ 3: {
262
+ id: 3,
263
+ uuid: '019a9012-ijkl-7000-8000-000000000003',
264
+ uuid_short: '019a9012',
265
+ enabled: true,
266
+ installed: 0,
267
+ blocked: false,
268
+ name: 'Rust Server',
269
+ game_id: 'rust',
270
+ ds_id: 1,
271
+ game_mod_id: 3,
272
+ expires: null,
273
+ server_ip: '192.168.1.102',
274
+ server_port: 28015,
275
+ query_port: 28016,
276
+ rcon_port: 28016,
277
+ game: rustGame,
278
+ last_process_check: new Date().toISOString(),
279
+ online: false,
280
+ rcon: 'rust_rcon_pass',
281
+ dir: 'servers/019a9012-ijkl-7000-8000-000000000003',
282
+ su_user: 'gameap',
283
+ cpu_limit: null,
284
+ ram_limit: null,
285
+ net_limit: null,
286
+ start_command: './RustDedicated -batchmode +server.port {port} +rcon.port {rcon_port} +rcon.password {rcon_password}',
287
+ stop_command: null,
288
+ force_stop_command: null,
289
+ restart_command: null,
290
+ process_active: false,
291
+ aliases: {
292
+ ip: '192.168.1.102',
293
+ port: 28015,
294
+ query_port: 28016,
295
+ rcon_password: 'rust_rcon_pass',
296
+ rcon_port: 28016,
297
+ uuid: '019a9012-ijkl-7000-8000-000000000003',
298
+ uuid_short: '019a9012',
299
+ },
300
+ vars: null,
301
+ created_at: '2024-03-20T09:00:00+00:00',
302
+ updated_at: '2024-12-17T12:00:00+00:00',
303
+ },
304
+ }
305
+
306
+ // Server data for plugin SDK (used by useServer hook)
307
+ export const minecraftServer: ServerData = {
308
+ id: 1,
309
+ uuid: '019a1234-abcd-7000-8000-000000000001',
310
+ name: 'Minecraft Survival',
311
+ game_id: 'minecraft',
312
+ game_mod_id: 1,
313
+ ip: '192.168.1.100',
314
+ port: 25565,
315
+ query_port: 25565,
316
+ rcon_port: 25575,
317
+ enabled: true,
318
+ installed: true,
319
+ blocked: false,
320
+ start_command: './mcrun run --version={version} --mod={mod} --ip={ip} --port={port}',
321
+ dir: 'servers/019a1234-abcd-7000-8000-000000000001',
322
+ process_active: true,
323
+ last_process_check: new Date().toISOString(),
324
+ }
325
+
326
+ export const csServer: ServerData = {
327
+ id: 2,
328
+ uuid: '019a5678-efgh-7000-8000-000000000002',
329
+ name: 'CS2 Competitive',
330
+ game_id: 'cs2',
331
+ game_mod_id: 2,
332
+ ip: '192.168.1.101',
333
+ port: 27015,
334
+ query_port: 27015,
335
+ rcon_port: 27015,
336
+ enabled: true,
337
+ installed: true,
338
+ blocked: false,
339
+ start_command: './cs2 -dedicated +map de_dust2 +maxplayers 20 -port {port}',
340
+ dir: 'servers/019a5678-efgh-7000-8000-000000000002',
341
+ process_active: false,
342
+ last_process_check: new Date().toISOString(),
343
+ }
344
+
345
+ export const serverMocks: Record<string, ServerData> = {
346
+ minecraft: minecraftServer,
347
+ cs: csServer,
348
+ }
349
+
350
+ // Server abilities as object with boolean values (matching real API format)
351
+ export const serverAbilities: Record<number, Record<string, boolean>> = {
352
+ 1: { // Minecraft
353
+ 'game-server-common': true,
354
+ 'game-server-console-send': true,
355
+ 'game-server-console-view': true,
356
+ 'game-server-files': true,
357
+ 'game-server-pause': false,
358
+ 'game-server-rcon-console': false,
359
+ 'game-server-rcon-players': false,
360
+ 'game-server-restart': true,
361
+ 'game-server-settings': true,
362
+ 'game-server-start': true,
363
+ 'game-server-stop': true,
364
+ 'game-server-tasks': true,
365
+ 'game-server-update': true,
366
+ },
367
+ 2: { // CS2
368
+ 'game-server-common': true,
369
+ 'game-server-console-send': true,
370
+ 'game-server-console-view': true,
371
+ 'game-server-files': true,
372
+ 'game-server-pause': false,
373
+ 'game-server-rcon-console': true,
374
+ 'game-server-rcon-players': true,
375
+ 'game-server-restart': true,
376
+ 'game-server-settings': true,
377
+ 'game-server-start': true,
378
+ 'game-server-stop': true,
379
+ 'game-server-tasks': true,
380
+ 'game-server-update': true,
381
+ },
382
+ 3: { // Rust (not installed)
383
+ 'game-server-common': true,
384
+ 'game-server-console-send': false,
385
+ 'game-server-console-view': false,
386
+ 'game-server-files': false,
387
+ 'game-server-pause': false,
388
+ 'game-server-rcon-console': false,
389
+ 'game-server-rcon-players': false,
390
+ 'game-server-restart': false,
391
+ 'game-server-settings': true,
392
+ 'game-server-start': false,
393
+ 'game-server-stop': false,
394
+ 'game-server-tasks': false,
395
+ 'game-server-update': true,
396
+ },
397
+ }