@open-core/framework 1.0.1-beta.1

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 (275) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +350 -0
  3. package/dist/client/client-bootstrap.d.ts +1 -0
  4. package/dist/client/client-bootstrap.js +53 -0
  5. package/dist/client/client-container.d.ts +2 -0
  6. package/dist/client/client-container.js +6 -0
  7. package/dist/client/client-core.d.ts +18 -0
  8. package/dist/client/client-core.js +52 -0
  9. package/dist/client/decorators/controller.d.ts +3 -0
  10. package/dist/client/decorators/controller.js +14 -0
  11. package/dist/client/decorators/export.d.ts +7 -0
  12. package/dist/client/decorators/export.js +15 -0
  13. package/dist/client/decorators/gameEvent.d.ts +47 -0
  14. package/dist/client/decorators/gameEvent.js +54 -0
  15. package/dist/client/decorators/index.d.ts +10 -0
  16. package/dist/client/decorators/index.js +26 -0
  17. package/dist/client/decorators/interval.d.ts +7 -0
  18. package/dist/client/decorators/interval.js +15 -0
  19. package/dist/client/decorators/key.d.ts +2 -0
  20. package/dist/client/decorators/key.js +10 -0
  21. package/dist/client/decorators/localEvent.d.ts +7 -0
  22. package/dist/client/decorators/localEvent.js +15 -0
  23. package/dist/client/decorators/nui.d.ts +1 -0
  24. package/dist/client/decorators/nui.js +9 -0
  25. package/dist/client/decorators/onNet.d.ts +1 -0
  26. package/dist/client/decorators/onNet.js +9 -0
  27. package/dist/client/decorators/resourceLifecycle.d.ts +11 -0
  28. package/dist/client/decorators/resourceLifecycle.js +24 -0
  29. package/dist/client/decorators/tick.d.ts +1 -0
  30. package/dist/client/decorators/tick.js +9 -0
  31. package/dist/client/index.d.ts +6 -0
  32. package/dist/client/index.js +22 -0
  33. package/dist/client/loaders/exports.loader.d.ts +1 -0
  34. package/dist/client/loaders/exports.loader.js +13 -0
  35. package/dist/client/player/player.d.ts +262 -0
  36. package/dist/client/player/player.js +480 -0
  37. package/dist/client/player/player.loader.d.ts +1 -0
  38. package/dist/client/player/player.loader.js +22 -0
  39. package/dist/client/services/core/index.d.ts +1 -0
  40. package/dist/client/services/core/index.js +17 -0
  41. package/dist/client/services/core/spawn.service.d.ts +20 -0
  42. package/dist/client/services/core/spawn.service.js +143 -0
  43. package/dist/client/services/index.d.ts +4 -0
  44. package/dist/client/services/index.js +24 -0
  45. package/dist/client/services/streaming/index.d.ts +1 -0
  46. package/dist/client/services/streaming/index.js +17 -0
  47. package/dist/client/services/streaming/streaming.service.d.ts +165 -0
  48. package/dist/client/services/streaming/streaming.service.js +341 -0
  49. package/dist/client/services/ui/index.d.ts +3 -0
  50. package/dist/client/services/ui/index.js +19 -0
  51. package/dist/client/services/ui/notification.service.d.ts +76 -0
  52. package/dist/client/services/ui/notification.service.js +111 -0
  53. package/dist/client/services/ui/progress.service.d.ts +82 -0
  54. package/dist/client/services/ui/progress.service.js +210 -0
  55. package/dist/client/services/ui/textui.service.d.ts +82 -0
  56. package/dist/client/services/ui/textui.service.js +156 -0
  57. package/dist/client/services/world/blip.service.d.ts +112 -0
  58. package/dist/client/services/world/blip.service.js +215 -0
  59. package/dist/client/services/world/index.d.ts +4 -0
  60. package/dist/client/services/world/index.js +20 -0
  61. package/dist/client/services/world/marker.service.d.ts +94 -0
  62. package/dist/client/services/world/marker.service.js +153 -0
  63. package/dist/client/services/world/ped.service.d.ts +182 -0
  64. package/dist/client/services/world/ped.service.js +302 -0
  65. package/dist/client/services/world/vehicle.service.d.ts +168 -0
  66. package/dist/client/services/world/vehicle.service.js +296 -0
  67. package/dist/client/system/metadata-client.keys.d.ts +13 -0
  68. package/dist/client/system/metadata-client.keys.js +16 -0
  69. package/dist/client/system/processors/export.processor.d.ts +7 -0
  70. package/dist/client/system/processors/export.processor.js +39 -0
  71. package/dist/client/system/processors/gameEvent.processor.d.ts +10 -0
  72. package/dist/client/system/processors/gameEvent.processor.js +58 -0
  73. package/dist/client/system/processors/interval.processor.d.ts +7 -0
  74. package/dist/client/system/processors/interval.processor.js +43 -0
  75. package/dist/client/system/processors/key.processor.d.ts +8 -0
  76. package/dist/client/system/processors/key.processor.js +27 -0
  77. package/dist/client/system/processors/localEvent.processor.d.ts +7 -0
  78. package/dist/client/system/processors/localEvent.processor.js +38 -0
  79. package/dist/client/system/processors/netEvent.processor.d.ts +7 -0
  80. package/dist/client/system/processors/netEvent.processor.js +38 -0
  81. package/dist/client/system/processors/nui.processor.d.ts +7 -0
  82. package/dist/client/system/processors/nui.processor.js +40 -0
  83. package/dist/client/system/processors/resourceLifecycle.processor.d.ts +9 -0
  84. package/dist/client/system/processors/resourceLifecycle.processor.js +69 -0
  85. package/dist/client/system/processors/tick.processor.d.ts +5 -0
  86. package/dist/client/system/processors/tick.processor.js +37 -0
  87. package/dist/client/system/processors.register.d.ts +1 -0
  88. package/dist/client/system/processors.register.js +27 -0
  89. package/dist/client/types/game-events.d.ts +126 -0
  90. package/dist/client/types/game-events.js +83 -0
  91. package/dist/client/types/index.d.ts +1 -0
  92. package/dist/client/types/index.js +17 -0
  93. package/dist/client/ui-bridge.d.ts +116 -0
  94. package/dist/client/ui-bridge.js +201 -0
  95. package/dist/index.d.ts +7 -0
  96. package/dist/index.js +46 -0
  97. package/dist/server/bootstrap.d.ts +16 -0
  98. package/dist/server/bootstrap.js +57 -0
  99. package/dist/server/bus/core-event-bus.d.ts +6 -0
  100. package/dist/server/bus/core-event-bus.js +31 -0
  101. package/dist/server/configs/api.config.d.ts +71 -0
  102. package/dist/server/configs/api.config.js +81 -0
  103. package/dist/server/configs/config.base.d.ts +63 -0
  104. package/dist/server/configs/config.base.js +64 -0
  105. package/dist/server/configs/index.d.ts +2 -0
  106. package/dist/server/configs/index.js +18 -0
  107. package/dist/server/container.d.ts +2 -0
  108. package/dist/server/container.js +6 -0
  109. package/dist/server/controllers/chat.controller.d.ts +10 -0
  110. package/dist/server/controllers/chat.controller.js +50 -0
  111. package/dist/server/controllers/command.controller.d.ts +7 -0
  112. package/dist/server/controllers/command.controller.js +47 -0
  113. package/dist/server/core.d.ts +1 -0
  114. package/dist/server/core.js +7 -0
  115. package/dist/server/database/adapters/oxmysql.adapter.d.ts +89 -0
  116. package/dist/server/database/adapters/oxmysql.adapter.js +149 -0
  117. package/dist/server/database/database.contract.d.ts +128 -0
  118. package/dist/server/database/database.contract.js +29 -0
  119. package/dist/server/database/database.service.d.ts +216 -0
  120. package/dist/server/database/database.service.js +301 -0
  121. package/dist/server/database/index.d.ts +53 -0
  122. package/dist/server/database/index.js +70 -0
  123. package/dist/server/database/types.d.ts +67 -0
  124. package/dist/server/database/types.js +7 -0
  125. package/dist/server/database.d.ts +7 -0
  126. package/dist/server/database.js +23 -0
  127. package/dist/server/decorators/bind.d.ts +2 -0
  128. package/dist/server/decorators/bind.js +15 -0
  129. package/dist/server/decorators/command.d.ts +19 -0
  130. package/dist/server/decorators/command.js +18 -0
  131. package/dist/server/decorators/controller.d.ts +3 -0
  132. package/dist/server/decorators/controller.js +14 -0
  133. package/dist/server/decorators/coreEvent.d.ts +2 -0
  134. package/dist/server/decorators/coreEvent.js +9 -0
  135. package/dist/server/decorators/export.d.ts +1 -0
  136. package/dist/server/decorators/export.js +9 -0
  137. package/dist/server/decorators/guard.d.ts +5 -0
  138. package/dist/server/decorators/guard.js +39 -0
  139. package/dist/server/decorators/index.d.ts +10 -0
  140. package/dist/server/decorators/index.js +26 -0
  141. package/dist/server/decorators/netEvent.d.ts +36 -0
  142. package/dist/server/decorators/netEvent.js +40 -0
  143. package/dist/server/decorators/onTick.d.ts +1 -0
  144. package/dist/server/decorators/onTick.js +9 -0
  145. package/dist/server/decorators/public.d.ts +16 -0
  146. package/dist/server/decorators/public.js +25 -0
  147. package/dist/server/decorators/requiresState.d.ts +55 -0
  148. package/dist/server/decorators/requiresState.js +62 -0
  149. package/dist/server/decorators/throttle.d.ts +9 -0
  150. package/dist/server/decorators/throttle.js +36 -0
  151. package/dist/server/decorators/utils.d.ts +7 -0
  152. package/dist/server/decorators/utils.js +13 -0
  153. package/dist/server/entities/index.d.ts +1 -0
  154. package/dist/server/entities/index.js +17 -0
  155. package/dist/server/entities/player.d.ts +157 -0
  156. package/dist/server/entities/player.js +217 -0
  157. package/dist/server/error-handler.d.ts +2 -0
  158. package/dist/server/error-handler.js +43 -0
  159. package/dist/server/index.d.ts +10 -0
  160. package/dist/server/index.js +29 -0
  161. package/dist/server/loaders/exports.loader.d.ts +0 -0
  162. package/dist/server/loaders/exports.loader.js +23 -0
  163. package/dist/server/loaders/playerSession.loader.d.ts +1 -0
  164. package/dist/server/loaders/playerSession.loader.js +42 -0
  165. package/dist/server/services/access-control.service.d.ts +56 -0
  166. package/dist/server/services/access-control.service.js +99 -0
  167. package/dist/server/services/chat.service.d.ts +7 -0
  168. package/dist/server/services/chat.service.js +31 -0
  169. package/dist/server/services/command.service.d.ts +15 -0
  170. package/dist/server/services/command.service.js +74 -0
  171. package/dist/server/services/config.service.d.ts +75 -0
  172. package/dist/server/services/config.service.js +116 -0
  173. package/dist/server/services/default/default-security.handler.d.ts +6 -0
  174. package/dist/server/services/default/default-security.handler.js +26 -0
  175. package/dist/server/services/http/http.service.d.ts +50 -0
  176. package/dist/server/services/http/http.service.js +126 -0
  177. package/dist/server/services/index.d.ts +10 -0
  178. package/dist/server/services/index.js +26 -0
  179. package/dist/server/services/parallel/index.d.ts +49 -0
  180. package/dist/server/services/parallel/index.js +67 -0
  181. package/dist/server/services/parallel/parallel-compute.service.d.ts +132 -0
  182. package/dist/server/services/parallel/parallel-compute.service.js +449 -0
  183. package/dist/server/services/parallel/types.d.ts +188 -0
  184. package/dist/server/services/parallel/types.js +7 -0
  185. package/dist/server/services/parallel/worker-pool.d.ts +83 -0
  186. package/dist/server/services/parallel/worker-pool.js +350 -0
  187. package/dist/server/services/parallel/worker.d.ts +19 -0
  188. package/dist/server/services/parallel/worker.js +49 -0
  189. package/dist/server/services/persistence.service.d.ts +59 -0
  190. package/dist/server/services/persistence.service.js +166 -0
  191. package/dist/server/services/player.service.d.ts +96 -0
  192. package/dist/server/services/player.service.js +132 -0
  193. package/dist/server/services/rate-limiter.service.d.ts +5 -0
  194. package/dist/server/services/rate-limiter.service.js +39 -0
  195. package/dist/server/services/registers.d.ts +1 -0
  196. package/dist/server/services/registers.js +18 -0
  197. package/dist/server/setup.d.ts +9 -0
  198. package/dist/server/setup.js +28 -0
  199. package/dist/server/system/metadata-server.keys.d.ts +9 -0
  200. package/dist/server/system/metadata-server.keys.js +12 -0
  201. package/dist/server/system/processors/command.processor.d.ts +9 -0
  202. package/dist/server/system/processors/command.processor.js +31 -0
  203. package/dist/server/system/processors/coreEvent.processor.d.ts +7 -0
  204. package/dist/server/system/processors/coreEvent.processor.js +38 -0
  205. package/dist/server/system/processors/export.processor.d.ts +7 -0
  206. package/dist/server/system/processors/export.processor.js +26 -0
  207. package/dist/server/system/processors/netEvent.processor.d.ts +11 -0
  208. package/dist/server/system/processors/netEvent.processor.js +100 -0
  209. package/dist/server/system/processors/tick.processor.d.ts +5 -0
  210. package/dist/server/system/processors/tick.processor.js +36 -0
  211. package/dist/server/system/processors.register.d.ts +1 -0
  212. package/dist/server/system/processors.register.js +21 -0
  213. package/dist/server/templates/admin/admin.controller-template.d.ts +10 -0
  214. package/dist/server/templates/admin/admin.controller-template.js +2 -0
  215. package/dist/server/templates/auth/auth-provider.contract.d.ts +58 -0
  216. package/dist/server/templates/auth/auth-provider.contract.js +23 -0
  217. package/dist/server/templates/index.d.ts +8 -0
  218. package/dist/server/templates/index.js +21 -0
  219. package/dist/server/templates/persistence/index.d.ts +30 -0
  220. package/dist/server/templates/persistence/index.js +34 -0
  221. package/dist/server/templates/persistence/player-persistence.contract.d.ts +86 -0
  222. package/dist/server/templates/persistence/player-persistence.contract.js +52 -0
  223. package/dist/server/templates/repository/index.d.ts +57 -0
  224. package/dist/server/templates/repository/index.js +61 -0
  225. package/dist/server/templates/repository/repository.contract.d.ts +224 -0
  226. package/dist/server/templates/repository/repository.contract.js +342 -0
  227. package/dist/server/templates/repository/repository.types.d.ts +51 -0
  228. package/dist/server/templates/repository/repository.types.js +7 -0
  229. package/dist/server/templates/security/permission.types.d.ts +32 -0
  230. package/dist/server/templates/security/permission.types.js +2 -0
  231. package/dist/server/templates/security/principal-provider.contract.d.ts +43 -0
  232. package/dist/server/templates/security/principal-provider.contract.js +19 -0
  233. package/dist/server/templates/security/security-handler.contract.d.ts +5 -0
  234. package/dist/server/templates/security/security-handler.contract.js +6 -0
  235. package/dist/server/types/core-events.d.ts +17 -0
  236. package/dist/server/types/core-events.js +2 -0
  237. package/dist/server/types/security.types.d.ts +7 -0
  238. package/dist/server/types/security.types.js +2 -0
  239. package/dist/shared/index.d.ts +1 -0
  240. package/dist/shared/index.js +17 -0
  241. package/dist/shared/logger/core-logger.d.ts +35 -0
  242. package/dist/shared/logger/core-logger.js +52 -0
  243. package/dist/shared/logger/index.d.ts +11 -0
  244. package/dist/shared/logger/index.js +26 -0
  245. package/dist/shared/logger/logger.config.d.ts +47 -0
  246. package/dist/shared/logger/logger.config.js +33 -0
  247. package/dist/shared/logger/logger.service.d.ts +161 -0
  248. package/dist/shared/logger/logger.service.js +279 -0
  249. package/dist/shared/logger/logger.types.d.ts +85 -0
  250. package/dist/shared/logger/logger.types.js +74 -0
  251. package/dist/shared/logger/transports/buffered.transport.d.ts +88 -0
  252. package/dist/shared/logger/transports/buffered.transport.js +174 -0
  253. package/dist/shared/logger/transports/console.transport.d.ts +37 -0
  254. package/dist/shared/logger/transports/console.transport.js +134 -0
  255. package/dist/shared/logger/transports/index.d.ts +3 -0
  256. package/dist/shared/logger/transports/index.js +19 -0
  257. package/dist/shared/logger/transports/transport.interface.d.ts +40 -0
  258. package/dist/shared/logger/transports/transport.interface.js +2 -0
  259. package/dist/system/class-constructor.d.ts +1 -0
  260. package/dist/system/class-constructor.js +2 -0
  261. package/dist/system/decorator-processor.d.ts +4 -0
  262. package/dist/system/decorator-processor.js +2 -0
  263. package/dist/system/metadata.scanner.d.ts +7 -0
  264. package/dist/system/metadata.scanner.js +45 -0
  265. package/dist/utils/errors.d.ts +14 -0
  266. package/dist/utils/errors.js +25 -0
  267. package/dist/utils/index.d.ts +4 -0
  268. package/dist/utils/index.js +20 -0
  269. package/dist/utils/result.d.ts +12 -0
  270. package/dist/utils/result.js +10 -0
  271. package/dist/utils/rgb.d.ts +5 -0
  272. package/dist/utils/rgb.js +2 -0
  273. package/dist/utils/vector3.d.ts +13 -0
  274. package/dist/utils/vector3.js +27 -0
  275. package/package.json +70 -0
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.di = void 0;
4
+ require("reflect-metadata");
5
+ const tsyringe_1 = require("tsyringe");
6
+ exports.di = tsyringe_1.container;
@@ -0,0 +1,10 @@
1
+ import { RGB } from '../../utils';
2
+ import { PlayerService } from '../services';
3
+ import { ChatService } from '../services/chat.service';
4
+ export declare class ChatController {
5
+ private readonly chatService;
6
+ private readonly playerService;
7
+ constructor(chatService: ChatService, playerService: PlayerService);
8
+ apiBroadcast(message: string, author?: string, color?: RGB): void;
9
+ apiSendPrivate(targetId: number, message: string, author?: string): void;
10
+ }
@@ -0,0 +1,50 @@
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.ChatController = void 0;
13
+ const controller_1 = require("../decorators/controller");
14
+ const export_1 = require("../decorators/export");
15
+ const services_1 = require("../services");
16
+ const chat_service_1 = require("../services/chat.service");
17
+ let ChatController = class ChatController {
18
+ constructor(chatService, playerService) {
19
+ this.chatService = chatService;
20
+ this.playerService = playerService;
21
+ }
22
+ apiBroadcast(message, author = 'SYSTEM', color = { r: 255, g: 255, b: 255 }) {
23
+ this.chatService.broadcast(message, author, color);
24
+ }
25
+ apiSendPrivate(targetId, message, author = 'Private') {
26
+ const player = this.playerService.getByClient(targetId);
27
+ if (!player) {
28
+ throw new Error(`Player with client ID ${targetId} not found`);
29
+ }
30
+ this.chatService.sendPrivate(player, message, author);
31
+ }
32
+ };
33
+ exports.ChatController = ChatController;
34
+ __decorate([
35
+ (0, export_1.Export)('core:broadcast'),
36
+ __metadata("design:type", Function),
37
+ __metadata("design:paramtypes", [String, String, Object]),
38
+ __metadata("design:returntype", void 0)
39
+ ], ChatController.prototype, "apiBroadcast", null);
40
+ __decorate([
41
+ (0, export_1.Export)('core:sendprivate'),
42
+ __metadata("design:type", Function),
43
+ __metadata("design:paramtypes", [Number, String, String]),
44
+ __metadata("design:returntype", void 0)
45
+ ], ChatController.prototype, "apiSendPrivate", null);
46
+ exports.ChatController = ChatController = __decorate([
47
+ (0, controller_1.Controller)(),
48
+ __metadata("design:paramtypes", [chat_service_1.ChatService,
49
+ services_1.PlayerService])
50
+ ], ChatController);
@@ -0,0 +1,7 @@
1
+ import { CommandService } from '../services/command.service';
2
+ import { Player } from '../entities';
3
+ export declare class CommandNetworkController {
4
+ private readonly commandService;
5
+ constructor(commandService: CommandService);
6
+ onCommandReceived(player: Player, commandName: string, args: string[], raw: string): Promise<void>;
7
+ }
@@ -0,0 +1,47 @@
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.CommandNetworkController = void 0;
13
+ const netEvent_1 = require("../decorators/netEvent");
14
+ const command_service_1 = require("../services/command.service");
15
+ const entities_1 = require("../entities");
16
+ const decorators_1 = require("../decorators");
17
+ const logger_1 = require("../../shared/logger");
18
+ let CommandNetworkController = class CommandNetworkController {
19
+ constructor(commandService) {
20
+ this.commandService = commandService;
21
+ }
22
+ async onCommandReceived(player, commandName, args, raw) {
23
+ try {
24
+ logger_1.loggers.command.trace(`Received: /${commandName}`, {
25
+ playerId: player.clientID,
26
+ playerName: player.name,
27
+ });
28
+ await this.commandService.execute(player, commandName, args, raw);
29
+ }
30
+ catch (error) {
31
+ logger_1.loggers.command.error(`Execution failed: /${commandName}`, {
32
+ playerId: player.clientID,
33
+ }, error);
34
+ }
35
+ }
36
+ };
37
+ exports.CommandNetworkController = CommandNetworkController;
38
+ __decorate([
39
+ (0, netEvent_1.OnNet)('core:internal:executeCommand'),
40
+ __metadata("design:type", Function),
41
+ __metadata("design:paramtypes", [entities_1.Player, String, Array, String]),
42
+ __metadata("design:returntype", Promise)
43
+ ], CommandNetworkController.prototype, "onCommandReceived", null);
44
+ exports.CommandNetworkController = CommandNetworkController = __decorate([
45
+ (0, decorators_1.Controller)(),
46
+ __metadata("design:paramtypes", [command_service_1.CommandService])
47
+ ], CommandNetworkController);
@@ -0,0 +1 @@
1
+ export declare function init(): Promise<void>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.init = init;
4
+ const bootstrap_1 = require("./bootstrap");
5
+ async function init() {
6
+ await (0, bootstrap_1.initServer)();
7
+ }
@@ -0,0 +1,89 @@
1
+ /**
2
+ * OxMySQL Adapter
3
+ *
4
+ * Default database adapter using oxmysql resource for FiveM.
5
+ * Requires oxmysql to be installed and running on the server.
6
+ *
7
+ * @see https://github.com/overextended/oxmysql
8
+ * @see https://coxdocs.dev/oxmysql/Functions/transaction
9
+ */
10
+ import { DatabaseContract } from '../database.contract';
11
+ import type { ExecuteResult, InsertResult, TransactionInput, TransactionSharedParams } from '../types';
12
+ /**
13
+ * OxMySQL Database Adapter
14
+ *
15
+ * Implements DatabaseContract using oxmysql exports.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { OxMySQLAdapter } from '@open-core/framework/server'
20
+ *
21
+ * // Usually you don't need to instantiate directly,
22
+ * // use DatabaseService instead
23
+ * const adapter = new OxMySQLAdapter()
24
+ * const users = await adapter.query('SELECT * FROM users')
25
+ * ```
26
+ */
27
+ export declare class OxMySQLAdapter extends DatabaseContract {
28
+ private ox;
29
+ constructor();
30
+ /**
31
+ * Execute a query and return all matching rows
32
+ */
33
+ query<T = any>(sql: string, params?: any[]): Promise<T[]>;
34
+ /**
35
+ * Execute a query and return a single row
36
+ */
37
+ single<T = any>(sql: string, params?: any[]): Promise<T | null>;
38
+ /**
39
+ * Execute a query and return a single scalar value
40
+ */
41
+ scalar<T = any>(sql: string, params?: any[]): Promise<T | null>;
42
+ /**
43
+ * Execute an UPDATE or DELETE statement
44
+ */
45
+ execute(sql: string, params?: any[]): Promise<ExecuteResult>;
46
+ /**
47
+ * Execute an INSERT statement
48
+ */
49
+ insert(sql: string, params?: any[]): Promise<InsertResult>;
50
+ /**
51
+ * Execute multiple queries within a transaction.
52
+ *
53
+ * Supports three formats:
54
+ *
55
+ * **1. Specific format (object)**
56
+ * ```typescript
57
+ * await db.transaction([
58
+ * { query: 'INSERT INTO test (id) VALUES (?)', values: [1] },
59
+ * { query: 'INSERT INTO test (id, name) VALUES (?, ?)', values: [2, 'bob'] },
60
+ * ])
61
+ * ```
62
+ *
63
+ * **2. Specific format (tuple)**
64
+ * ```typescript
65
+ * await db.transaction([
66
+ * ['INSERT INTO test (id) VALUES (?)', [1]],
67
+ * ['INSERT INTO test (id, name) VALUES (?, ?)', [2, 'bob']],
68
+ * ])
69
+ * ```
70
+ *
71
+ * **3. Shared format (named parameters)**
72
+ * ```typescript
73
+ * await db.transaction(
74
+ * [
75
+ * 'INSERT INTO test (id, name) VALUES (@someid, @somename)',
76
+ * 'UPDATE test SET name = @newname WHERE id = @someid',
77
+ * ],
78
+ * {
79
+ * someid: 2,
80
+ * somename: 'John Doe',
81
+ * newname: 'John Notdoe',
82
+ * }
83
+ * )
84
+ * ```
85
+ *
86
+ * @see https://coxdocs.dev/oxmysql/Functions/transaction
87
+ */
88
+ transaction(queries: TransactionInput, sharedParams?: TransactionSharedParams): Promise<boolean>;
89
+ }
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ /**
3
+ * OxMySQL Adapter
4
+ *
5
+ * Default database adapter using oxmysql resource for FiveM.
6
+ * Requires oxmysql to be installed and running on the server.
7
+ *
8
+ * @see https://github.com/overextended/oxmysql
9
+ * @see https://coxdocs.dev/oxmysql/Functions/transaction
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.OxMySQLAdapter = void 0;
13
+ const database_contract_1 = require("../database.contract");
14
+ /**
15
+ * Get the oxmysql export from FiveM
16
+ */
17
+ function getOxMySQL() {
18
+ const ox = global.exports['oxmysql'];
19
+ if (!ox) {
20
+ throw new Error('[OpenCore] oxmysql is not available. Make sure oxmysql resource is started before your resource.');
21
+ }
22
+ return ox;
23
+ }
24
+ /**
25
+ * Normalize transaction input to oxmysql format
26
+ */
27
+ function normalizeQueries(queries) {
28
+ if (queries.length === 0)
29
+ return [];
30
+ const first = queries[0];
31
+ // String array - used with shared params
32
+ if (typeof first === 'string') {
33
+ return queries;
34
+ }
35
+ // Tuple format: [query, values]
36
+ if (Array.isArray(first)) {
37
+ return queries.map(([query, values]) => ({
38
+ query,
39
+ values,
40
+ }));
41
+ }
42
+ // Already in TransactionQuery format
43
+ return queries;
44
+ }
45
+ /**
46
+ * OxMySQL Database Adapter
47
+ *
48
+ * Implements DatabaseContract using oxmysql exports.
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * import { OxMySQLAdapter } from '@open-core/framework/server'
53
+ *
54
+ * // Usually you don't need to instantiate directly,
55
+ * // use DatabaseService instead
56
+ * const adapter = new OxMySQLAdapter()
57
+ * const users = await adapter.query('SELECT * FROM users')
58
+ * ```
59
+ */
60
+ class OxMySQLAdapter extends database_contract_1.DatabaseContract {
61
+ constructor() {
62
+ super();
63
+ this.ox = getOxMySQL();
64
+ }
65
+ /**
66
+ * Execute a query and return all matching rows
67
+ */
68
+ async query(sql, params) {
69
+ const result = await this.ox.query_async(sql, params);
70
+ return result !== null && result !== void 0 ? result : [];
71
+ }
72
+ /**
73
+ * Execute a query and return a single row
74
+ */
75
+ async single(sql, params) {
76
+ const result = await this.ox.single_async(sql, params);
77
+ return result !== null && result !== void 0 ? result : null;
78
+ }
79
+ /**
80
+ * Execute a query and return a single scalar value
81
+ */
82
+ async scalar(sql, params) {
83
+ const result = await this.ox.scalar_async(sql, params);
84
+ return result !== null && result !== void 0 ? result : null;
85
+ }
86
+ /**
87
+ * Execute an UPDATE or DELETE statement
88
+ */
89
+ async execute(sql, params) {
90
+ const affectedRows = await this.ox.update_async(sql, params);
91
+ return { affectedRows: affectedRows !== null && affectedRows !== void 0 ? affectedRows : 0 };
92
+ }
93
+ /**
94
+ * Execute an INSERT statement
95
+ */
96
+ async insert(sql, params) {
97
+ const insertId = await this.ox.insert_async(sql, params);
98
+ return { insertId: insertId !== null && insertId !== void 0 ? insertId : 0 };
99
+ }
100
+ /**
101
+ * Execute multiple queries within a transaction.
102
+ *
103
+ * Supports three formats:
104
+ *
105
+ * **1. Specific format (object)**
106
+ * ```typescript
107
+ * await db.transaction([
108
+ * { query: 'INSERT INTO test (id) VALUES (?)', values: [1] },
109
+ * { query: 'INSERT INTO test (id, name) VALUES (?, ?)', values: [2, 'bob'] },
110
+ * ])
111
+ * ```
112
+ *
113
+ * **2. Specific format (tuple)**
114
+ * ```typescript
115
+ * await db.transaction([
116
+ * ['INSERT INTO test (id) VALUES (?)', [1]],
117
+ * ['INSERT INTO test (id, name) VALUES (?, ?)', [2, 'bob']],
118
+ * ])
119
+ * ```
120
+ *
121
+ * **3. Shared format (named parameters)**
122
+ * ```typescript
123
+ * await db.transaction(
124
+ * [
125
+ * 'INSERT INTO test (id, name) VALUES (@someid, @somename)',
126
+ * 'UPDATE test SET name = @newname WHERE id = @someid',
127
+ * ],
128
+ * {
129
+ * someid: 2,
130
+ * somename: 'John Doe',
131
+ * newname: 'John Notdoe',
132
+ * }
133
+ * )
134
+ * ```
135
+ *
136
+ * @see https://coxdocs.dev/oxmysql/Functions/transaction
137
+ */
138
+ async transaction(queries, sharedParams) {
139
+ if (queries.length === 0)
140
+ return true;
141
+ const normalizedQueries = normalizeQueries(queries);
142
+ // Use shared params format if provided
143
+ if (sharedParams) {
144
+ return await this.ox.transaction_async(normalizedQueries, sharedParams);
145
+ }
146
+ return await this.ox.transaction_async(normalizedQueries);
147
+ }
148
+ }
149
+ exports.OxMySQLAdapter = OxMySQLAdapter;
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Database Contract
3
+ *
4
+ * Abstract base class that defines the interface for all database adapters.
5
+ * Implement this contract to create custom database adapters.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * class MyDatabaseAdapter extends DatabaseContract {
10
+ * async query<T>(sql: string, params?: any[]): Promise<T[]> {
11
+ * // Implementation
12
+ * }
13
+ * // ... other methods
14
+ * }
15
+ * ```
16
+ */
17
+ import type { ExecuteResult, InsertResult, TransactionInput, TransactionSharedParams } from './types';
18
+ /**
19
+ * Abstract contract for database adapters.
20
+ *
21
+ * All database adapters must extend this class and implement
22
+ * all abstract methods to ensure consistent behavior across
23
+ * different database backends.
24
+ */
25
+ export declare abstract class DatabaseContract {
26
+ /**
27
+ * Execute a query and return all matching rows.
28
+ *
29
+ * @param sql - The SQL query string
30
+ * @param params - Optional parameters for prepared statement
31
+ * @returns Array of results
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const users = await db.query<User>('SELECT * FROM users WHERE active = ?', [true])
36
+ * ```
37
+ */
38
+ abstract query<T = any>(sql: string, params?: any[]): Promise<T[]>;
39
+ /**
40
+ * Execute a query and return a single row.
41
+ *
42
+ * @param sql - The SQL query string
43
+ * @param params - Optional parameters for prepared statement
44
+ * @returns Single result or null if not found
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const user = await db.single<User>('SELECT * FROM users WHERE id = ?', [userId])
49
+ * if (user) {
50
+ * console.log(user.name)
51
+ * }
52
+ * ```
53
+ */
54
+ abstract single<T = any>(sql: string, params?: any[]): Promise<T | null>;
55
+ /**
56
+ * Execute a query and return a single scalar value.
57
+ *
58
+ * @param sql - The SQL query string
59
+ * @param params - Optional parameters for prepared statement
60
+ * @returns Scalar value or null if not found
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * const count = await db.scalar<number>('SELECT COUNT(*) FROM users')
65
+ * const name = await db.scalar<string>('SELECT name FROM users WHERE id = ?', [userId])
66
+ * ```
67
+ */
68
+ abstract scalar<T = any>(sql: string, params?: any[]): Promise<T | null>;
69
+ /**
70
+ * Execute an UPDATE or DELETE statement.
71
+ *
72
+ * @param sql - The SQL statement
73
+ * @param params - Optional parameters for prepared statement
74
+ * @returns Object containing affected rows count
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * const result = await db.execute('UPDATE users SET active = ? WHERE id = ?', [false, userId])
79
+ * console.log(`Updated ${result.affectedRows} rows`)
80
+ * ```
81
+ */
82
+ abstract execute(sql: string, params?: any[]): Promise<ExecuteResult>;
83
+ /**
84
+ * Execute an INSERT statement.
85
+ *
86
+ * @param sql - The SQL insert statement
87
+ * @param params - Optional parameters for prepared statement
88
+ * @returns Object containing the inserted row ID
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * const result = await db.insert('INSERT INTO users (name, email) VALUES (?, ?)', ['John', 'john@example.com'])
93
+ * console.log(`Inserted user with ID: ${result.insertId}`)
94
+ * ```
95
+ */
96
+ abstract insert(sql: string, params?: any[]): Promise<InsertResult>;
97
+ /**
98
+ * Execute multiple queries within a transaction.
99
+ *
100
+ * All queries are committed together if all succeed, or rolled back if any fails.
101
+ *
102
+ * **Specific format** - Each query has its own parameters:
103
+ * ```typescript
104
+ * await db.transaction([
105
+ * { query: 'INSERT INTO users (name) VALUES (?)', values: ['John'] },
106
+ * { query: 'INSERT INTO logs (action) VALUES (?)', values: ['user_created'] },
107
+ * ])
108
+ * ```
109
+ *
110
+ * **Shared format** - All queries share named parameters:
111
+ * ```typescript
112
+ * await db.transaction(
113
+ * [
114
+ * 'INSERT INTO users (id, name) VALUES (@userid, @username)',
115
+ * 'INSERT INTO profiles (user_id) VALUES (@userid)',
116
+ * ],
117
+ * { userid: 1, username: 'John' }
118
+ * )
119
+ * ```
120
+ *
121
+ * @param queries - Array of queries to execute
122
+ * @param sharedParams - Optional shared parameters for all queries (named params format)
123
+ * @returns true if transaction succeeded, false otherwise
124
+ *
125
+ * @see https://coxdocs.dev/oxmysql/Functions/transaction
126
+ */
127
+ abstract transaction(queries: TransactionInput, sharedParams?: TransactionSharedParams): Promise<boolean>;
128
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /**
3
+ * Database Contract
4
+ *
5
+ * Abstract base class that defines the interface for all database adapters.
6
+ * Implement this contract to create custom database adapters.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * class MyDatabaseAdapter extends DatabaseContract {
11
+ * async query<T>(sql: string, params?: any[]): Promise<T[]> {
12
+ * // Implementation
13
+ * }
14
+ * // ... other methods
15
+ * }
16
+ * ```
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.DatabaseContract = void 0;
20
+ /**
21
+ * Abstract contract for database adapters.
22
+ *
23
+ * All database adapters must extend this class and implement
24
+ * all abstract methods to ensure consistent behavior across
25
+ * different database backends.
26
+ */
27
+ class DatabaseContract {
28
+ }
29
+ exports.DatabaseContract = DatabaseContract;