@open-core/framework 1.0.1-beta.1 → 1.0.4-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 (109) hide show
  1. package/README.md +12 -2
  2. package/dist/client/client-bootstrap.js +11 -14
  3. package/dist/client/client-core.d.ts +0 -17
  4. package/dist/client/client-core.js +0 -45
  5. package/dist/client/controllers/spawner.controller.d.ts +12 -0
  6. package/dist/client/controllers/spawner.controller.js +51 -0
  7. package/dist/client/index.d.ts +1 -0
  8. package/dist/client/index.js +1 -0
  9. package/dist/client/interfaces/appearance.interface.d.ts +19 -0
  10. package/dist/client/interfaces/appearance.interface.js +2 -0
  11. package/dist/client/services/appearance.service.d.ts +6 -0
  12. package/dist/client/services/appearance.service.js +89 -0
  13. package/dist/client/services/{world/blip.service.d.ts → blip.service.d.ts} +1 -1
  14. package/dist/client/services/index.d.ts +9 -4
  15. package/dist/client/services/index.js +9 -8
  16. package/dist/client/services/{world/marker.service.d.ts → marker.service.d.ts} +1 -1
  17. package/dist/client/services/{world/ped.service.d.ts → ped.service.d.ts} +1 -1
  18. package/dist/client/services/spawn.service.d.ts +73 -0
  19. package/dist/client/services/spawn.service.js +261 -0
  20. package/dist/client/services/{ui/textui.service.d.ts → textui.service.d.ts} +1 -1
  21. package/dist/client/services/{world/vehicle.service.d.ts → vehicle.service.d.ts} +1 -1
  22. package/dist/client/system/processors/export.processor.js +1 -1
  23. package/dist/index.d.ts +0 -2
  24. package/dist/index.js +1 -6
  25. package/dist/server/bootstrap.js +2 -2
  26. package/dist/server/controllers/command.controller.d.ts +1 -1
  27. package/dist/server/controllers/command.controller.js +6 -6
  28. package/dist/server/controllers/session.controller.d.ts +9 -0
  29. package/dist/server/controllers/session.controller.js +70 -0
  30. package/dist/server/database/adapters/oxmysql.adapter.js +1 -1
  31. package/dist/server/decorators/command.d.ts +34 -4
  32. package/dist/server/decorators/command.js +11 -6
  33. package/dist/server/decorators/controller.d.ts +22 -0
  34. package/dist/server/decorators/controller.js +22 -0
  35. package/dist/server/decorators/export.d.ts +38 -0
  36. package/dist/server/decorators/export.js +38 -0
  37. package/dist/server/decorators/guard.d.ts +51 -0
  38. package/dist/server/decorators/guard.js +43 -0
  39. package/dist/server/decorators/index.d.ts +4 -4
  40. package/dist/server/decorators/index.js +7 -4
  41. package/dist/server/decorators/onFiveMEvent.d.ts +6 -0
  42. package/dist/server/decorators/{coreEvent.js → onFiveMEvent.js} +8 -3
  43. package/dist/server/decorators/onFrameworkEvent.d.ts +22 -0
  44. package/dist/server/decorators/onFrameworkEvent.js +29 -0
  45. package/dist/server/decorators/onNet.d.ts +58 -0
  46. package/dist/server/decorators/onNet.js +57 -0
  47. package/dist/server/decorators/onTick.d.ts +31 -0
  48. package/dist/server/decorators/onTick.js +31 -0
  49. package/dist/server/decorators/public.d.ts +19 -8
  50. package/dist/server/decorators/public.js +19 -8
  51. package/dist/server/decorators/requiresState.d.ts +18 -17
  52. package/dist/server/decorators/requiresState.js +18 -17
  53. package/dist/server/decorators/throttle.d.ts +39 -0
  54. package/dist/server/decorators/throttle.js +27 -0
  55. package/dist/server/decorators/utils.d.ts +50 -0
  56. package/dist/server/decorators/utils.js +50 -0
  57. package/dist/server/entities/player.js +1 -1
  58. package/dist/server/error-handler.js +2 -2
  59. package/dist/server/helpers/resolve-method.d.ts +5 -0
  60. package/dist/server/helpers/resolve-method.js +18 -0
  61. package/dist/server/index.js +2 -0
  62. package/dist/server/loaders/playerSession.loader.js +13 -4
  63. package/dist/server/services/command.service.d.ts +1 -1
  64. package/dist/server/services/command.service.js +9 -6
  65. package/dist/server/system/metadata-server.keys.d.ts +1 -0
  66. package/dist/server/system/metadata-server.keys.js +1 -0
  67. package/dist/server/system/processors/command.processor.d.ts +2 -2
  68. package/dist/server/system/processors/command.processor.js +1 -2
  69. package/dist/server/system/processors/coreEvent.processor.d.ts +1 -1
  70. package/dist/server/system/processors/coreEvent.processor.js +6 -3
  71. package/dist/server/system/processors/export.processor.d.ts +1 -1
  72. package/dist/server/system/processors/export.processor.js +7 -3
  73. package/dist/server/system/processors/fivemEvent.processor.d.ts +7 -0
  74. package/dist/server/system/processors/fivemEvent.processor.js +40 -0
  75. package/dist/server/system/processors/netEvent.processor.d.ts +1 -1
  76. package/dist/server/system/processors/netEvent.processor.js +12 -9
  77. package/dist/server/system/processors.register.js +2 -0
  78. package/dist/server/system/schema-generator.d.ts +2 -0
  79. package/dist/server/system/schema-generator.js +34 -0
  80. package/dist/server/templates/admin/admin.controller-template.d.ts +7 -5
  81. package/dist/server/templates/auth/auth-provider.contract.d.ts +2 -2
  82. package/dist/server/types/core-events.d.ts +5 -0
  83. package/package.json +29 -1
  84. package/dist/client/loaders/exports.loader.d.ts +0 -1
  85. package/dist/client/loaders/exports.loader.js +0 -13
  86. package/dist/client/services/core/index.d.ts +0 -1
  87. package/dist/client/services/core/index.js +0 -17
  88. package/dist/client/services/core/spawn.service.d.ts +0 -20
  89. package/dist/client/services/core/spawn.service.js +0 -143
  90. package/dist/client/services/streaming/index.d.ts +0 -1
  91. package/dist/client/services/streaming/index.js +0 -17
  92. package/dist/client/services/ui/index.d.ts +0 -3
  93. package/dist/client/services/ui/index.js +0 -19
  94. package/dist/client/services/world/index.d.ts +0 -4
  95. package/dist/client/services/world/index.js +0 -20
  96. package/dist/server/decorators/coreEvent.d.ts +0 -2
  97. package/dist/server/decorators/netEvent.d.ts +0 -36
  98. package/dist/server/decorators/netEvent.js +0 -40
  99. /package/dist/client/services/{world/blip.service.js → blip.service.js} +0 -0
  100. /package/dist/client/services/{world/marker.service.js → marker.service.js} +0 -0
  101. /package/dist/client/services/{ui/notification.service.d.ts → notification.service.d.ts} +0 -0
  102. /package/dist/client/services/{ui/notification.service.js → notification.service.js} +0 -0
  103. /package/dist/client/services/{world/ped.service.js → ped.service.js} +0 -0
  104. /package/dist/client/services/{ui/progress.service.d.ts → progress.service.d.ts} +0 -0
  105. /package/dist/client/services/{ui/progress.service.js → progress.service.js} +0 -0
  106. /package/dist/client/services/{streaming/streaming.service.d.ts → streaming.service.d.ts} +0 -0
  107. /package/dist/client/services/{streaming/streaming.service.js → streaming.service.js} +0 -0
  108. /package/dist/client/services/{ui/textui.service.js → textui.service.js} +0 -0
  109. /package/dist/client/services/{world/vehicle.service.js → vehicle.service.js} +0 -0
@@ -2,6 +2,44 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Export = Export;
4
4
  const metadata_server_keys_1 = require("../system/metadata-server.keys");
5
+ /**
6
+ * Export
7
+ * -----------------------------------------
8
+ * Declares a method as an externally accessible export
9
+ * within the FiveM environment.
10
+ *
11
+ * Methods decorated with `@Export()` are automatically
12
+ * registered by the framework and exposed as native
13
+ * FXServer exports, allowing other resources to call them
14
+ * using:
15
+ *
16
+ * exports.resourceName.exportName(...)
17
+ *
18
+ * This decorator is typically used inside controller
19
+ * classes, where the framework’s module loader inspects
20
+ * metadata to register commands, events and exports
21
+ * consistently.
22
+ *
23
+ * @param name Optional name to expose. If omitted,
24
+ * the method name is used.
25
+ *
26
+ * ```ts
27
+ * @Server.Controller()
28
+ * export class AccountController {
29
+ * @Server.Export('getAccountById')
30
+ * getAccount(id: string) {
31
+ * return this.accountService.find(id)
32
+ * }
33
+ * }
34
+ *
35
+ * // From another resource:
36
+ * // const result = exports['core-resource'].getAccountById('1234')
37
+ *```
38
+ * Internally, this decorator stores metadata used by
39
+ * the server bootstrap to automatically register the
40
+ * export through FXServer's `global.exports` API.
41
+ *
42
+ */
5
43
  function Export(name) {
6
44
  return (target, propertyKey) => {
7
45
  Reflect.defineMetadata(metadata_server_keys_1.METADATA_KEYS.EXPORT, { exportName: name || propertyKey }, target, propertyKey);
@@ -1,5 +1,56 @@
1
1
  export interface GuardOptions {
2
+ /**
3
+ * Minimum rank required to execute the method.
4
+ * Permissions and Role/Ranks are defined by your Principal Controller
5
+ */
2
6
  rank?: number;
7
+ /**
8
+ * Permission required to execute the method.
9
+ * Permissions and Role/Ranks are defined by your Principal Controller
10
+ */
3
11
  permission?: string;
4
12
  }
13
+ /**
14
+ * Guard
15
+ * ------------------------------------------------------------
16
+ * Declarative access-control decorator for controller methods.
17
+ *
18
+ * `@Guard()` protects a method by enforcing rank and/or
19
+ * permission requirements before executing it.
20
+ *
21
+ * Requirements are evaluated through the AccessControlService,
22
+ * which determines whether the player (first argument of the
23
+ * method) is authorized to perform the action.
24
+ *
25
+ * Usage of this decorator allows you to express authorization
26
+ * rules directly at the controller level, promoting a clean
27
+ * and explicit security model.
28
+ *
29
+ * @param options GuardOptions
30
+ * - rank: minimum rank required to execute the method.
31
+ * - permission: specific permission required.
32
+ *
33
+ * Notes:
34
+ * - The decorated method must receive a `Server.Player`
35
+ * instance as its first argument.
36
+ * - When compiling improperly (e.g., benchmarks, stripped
37
+ * decorators), the PropertyDescriptor may be missing.
38
+ * In that case, only metadata is recorded and execution
39
+ * fallback is disabled. This should *never* occur in a
40
+ * production environment.
41
+ *
42
+ * ```ts
43
+ * export class FactionController {
44
+ * @Server.Guard({ permission: 'factions.manage' })
45
+ * async createFaction(player: Player, dto: CreateFactionDTO) {
46
+ * return this.service.create(dto)
47
+ * }
48
+ *
49
+ * @Server.Guard({ rank: 3 })
50
+ * async promoteMember(player: Player, memberID: string) {
51
+ * return this.service.promote(player, memberID)
52
+ * }
53
+ * }
54
+ * ```
55
+ */
5
56
  export declare function Guard(options: GuardOptions): (target: any, propertyKey: string, descriptor?: PropertyDescriptor) => PropertyDescriptor | undefined;
@@ -4,6 +4,49 @@ exports.Guard = Guard;
4
4
  const container_1 = require("../container");
5
5
  const services_1 = require("../services");
6
6
  const logger_1 = require("../../shared/logger");
7
+ /**
8
+ * Guard
9
+ * ------------------------------------------------------------
10
+ * Declarative access-control decorator for controller methods.
11
+ *
12
+ * `@Guard()` protects a method by enforcing rank and/or
13
+ * permission requirements before executing it.
14
+ *
15
+ * Requirements are evaluated through the AccessControlService,
16
+ * which determines whether the player (first argument of the
17
+ * method) is authorized to perform the action.
18
+ *
19
+ * Usage of this decorator allows you to express authorization
20
+ * rules directly at the controller level, promoting a clean
21
+ * and explicit security model.
22
+ *
23
+ * @param options GuardOptions
24
+ * - rank: minimum rank required to execute the method.
25
+ * - permission: specific permission required.
26
+ *
27
+ * Notes:
28
+ * - The decorated method must receive a `Server.Player`
29
+ * instance as its first argument.
30
+ * - When compiling improperly (e.g., benchmarks, stripped
31
+ * decorators), the PropertyDescriptor may be missing.
32
+ * In that case, only metadata is recorded and execution
33
+ * fallback is disabled. This should *never* occur in a
34
+ * production environment.
35
+ *
36
+ * ```ts
37
+ * export class FactionController {
38
+ * @Server.Guard({ permission: 'factions.manage' })
39
+ * async createFaction(player: Player, dto: CreateFactionDTO) {
40
+ * return this.service.create(dto)
41
+ * }
42
+ *
43
+ * @Server.Guard({ rank: 3 })
44
+ * async promoteMember(player: Player, memberID: string) {
45
+ * return this.service.promote(player, memberID)
46
+ * }
47
+ * }
48
+ * ```
49
+ */
7
50
  function Guard(options) {
8
51
  return function (target, propertyKey, descriptor) {
9
52
  var _a;
@@ -1,10 +1,10 @@
1
1
  export * from './bind';
2
2
  export * from './utils';
3
- export * from './command';
4
- export * from './coreEvent';
5
- export * from './netEvent';
3
+ export { Command, CommandConfig } from './command';
4
+ export * from './onFrameworkEvent';
5
+ export * from './onNet';
6
6
  export * from './onTick';
7
- export * from './controller';
7
+ export { Controller } from './controller';
8
8
  export * from './throttle';
9
9
  export * from './guard';
10
10
  export * from './requiresState';
@@ -14,13 +14,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Controller = exports.Command = void 0;
17
18
  __exportStar(require("./bind"), exports);
18
19
  __exportStar(require("./utils"), exports);
19
- __exportStar(require("./command"), exports);
20
- __exportStar(require("./coreEvent"), exports);
21
- __exportStar(require("./netEvent"), exports);
20
+ var command_1 = require("./command");
21
+ Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return command_1.Command; } });
22
+ __exportStar(require("./onFrameworkEvent"), exports);
23
+ __exportStar(require("./onNet"), exports);
22
24
  __exportStar(require("./onTick"), exports);
23
- __exportStar(require("./controller"), exports);
25
+ var controller_1 = require("./controller");
26
+ Object.defineProperty(exports, "Controller", { enumerable: true, get: function () { return controller_1.Controller; } });
24
27
  __exportStar(require("./throttle"), exports);
25
28
  __exportStar(require("./guard"), exports);
26
29
  __exportStar(require("./requiresState"), exports);
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Listen to FiveM events server-side, check the list below
3
+ *
4
+ * https://docs.fivem.net/docs/scripting-reference/events/server-events/
5
+ */
6
+ export declare function OnFiveMEvent(event: string): (target: any, propertyKey: string) => void;
@@ -1,9 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OnCoreEvent = OnCoreEvent;
3
+ exports.OnFiveMEvent = OnFiveMEvent;
4
4
  const metadata_server_keys_1 = require("../system/metadata-server.keys");
5
- function OnCoreEvent(event) {
5
+ /**
6
+ * Listen to FiveM events server-side, check the list below
7
+ *
8
+ * https://docs.fivem.net/docs/scripting-reference/events/server-events/
9
+ */
10
+ function OnFiveMEvent(event) {
6
11
  return (target, propertyKey) => {
7
- Reflect.defineMetadata(metadata_server_keys_1.METADATA_KEYS.CORE_EVENT, { event }, target, propertyKey);
12
+ Reflect.defineMetadata(metadata_server_keys_1.METADATA_KEYS.FIVEM_EVENT, { event }, target, propertyKey);
8
13
  };
9
14
  }
@@ -0,0 +1,22 @@
1
+ import type { CoreEventMap } from '../types/core-events';
2
+ /**
3
+ * Method decorator used to register a method as a listener for an internal OpenCore framework event.
4
+ *
5
+ * When the specified framework event is emitted, this method will be automatically triggered
6
+ * with the arguments provided by the event payload.
7
+ *
8
+ * @param event - The name of the core event to listen for (typed strictly to `CoreEventMap`).
9
+ *
10
+ *
11
+ * ```ts
12
+ * @Server.Controller()
13
+ * export class SystemController {
14
+ *
15
+ * @OnFrameworkEvent('server:ready')
16
+ * public onServerStart() {
17
+ * console.log('OpenCore Framework is ready!')
18
+ * }
19
+ * }
20
+ * ```
21
+ */
22
+ export declare function OnFrameworkEvent<K extends keyof CoreEventMap>(event: K): (target: any, propertyKey: string) => void;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OnFrameworkEvent = OnFrameworkEvent;
4
+ const metadata_server_keys_1 = require("../system/metadata-server.keys");
5
+ /**
6
+ * Method decorator used to register a method as a listener for an internal OpenCore framework event.
7
+ *
8
+ * When the specified framework event is emitted, this method will be automatically triggered
9
+ * with the arguments provided by the event payload.
10
+ *
11
+ * @param event - The name of the core event to listen for (typed strictly to `CoreEventMap`).
12
+ *
13
+ *
14
+ * ```ts
15
+ * @Server.Controller()
16
+ * export class SystemController {
17
+ *
18
+ * @OnFrameworkEvent('server:ready')
19
+ * public onServerStart() {
20
+ * console.log('OpenCore Framework is ready!')
21
+ * }
22
+ * }
23
+ * ```
24
+ */
25
+ function OnFrameworkEvent(event) {
26
+ return (target, propertyKey) => {
27
+ Reflect.defineMetadata(metadata_server_keys_1.METADATA_KEYS.CORE_EVENT, { event }, target, propertyKey);
28
+ };
29
+ }
@@ -0,0 +1,58 @@
1
+ import type { z } from 'zod';
2
+ import type { Player } from '../entities/player';
3
+ export interface NetEventOptions {
4
+ eventName: string;
5
+ schema?: z.ZodType;
6
+ paramTypes?: any;
7
+ }
8
+ type ServerNetHandler<TArgs extends any[] = any[]> = (player: Player, ...args: TArgs) => any;
9
+ /**
10
+ * Registers a server-side network event handler.
11
+ *
12
+ * The decorated method is invoked when the client triggers
13
+ * `emitNet(eventName, ...)`.
14
+ *
15
+ * ## Player Injection
16
+ * The first argument of the handler **must be `Player`** and is automatically
17
+ * replaced with a `Server.Player` instance representing the client that
18
+ * fired the event. You do NOT need to read `source` manually.
19
+ *
20
+ * ## Auto-Validation
21
+ * Arguments after `Player` are automatically validated based on their TypeScript types:
22
+ * - `string` → `z.string()`
23
+ * - `number` → `z.number()`
24
+ * - `boolean` → `z.boolean()`
25
+ * - `any[]` → `z.array(z.any())` (array content not validated)
26
+ *
27
+ * ## Explicit Schema (Advanced)
28
+ * For stricter validation (ranges, formats, nested objects), provide a Zod schema:
29
+ *
30
+ * @example Auto-validation (simple)
31
+ * ```ts
32
+ * @OnNet("auth:login")
33
+ * handleLogin(player: Player, username: string, password: string) {
34
+ * // username and password are validated as strings automatically
35
+ * }
36
+ * ```
37
+ *
38
+ * @example Explicit schema (strict validation)
39
+ * ```ts
40
+ * const transferSchema = z.object({
41
+ * targetId: z.number().positive(),
42
+ * amount: z.number().min(1).max(1000000),
43
+ * })
44
+ *
45
+ * @OnNet("bank:transfer", { schema: transferSchema })
46
+ * handleTransfer(player: Player, data: z.infer<typeof transferSchema>) {
47
+ * // data.amount is guaranteed to be between 1 and 1,000,000
48
+ * }
49
+ * ```
50
+ *
51
+ * @param eventName - The network event name to listen for.
52
+ * @param options - Optional configuration object.
53
+ * @param options.schema - Zod schema for strict payload validation.
54
+ */
55
+ export declare function OnNet<TArgs extends any[]>(eventName: string, options?: {
56
+ schema?: z.ZodType;
57
+ }): <H extends ServerNetHandler<TArgs>>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<H>) => void;
58
+ export {};
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OnNet = OnNet;
4
+ const metadata_server_keys_1 = require("../system/metadata-server.keys");
5
+ /**
6
+ * Registers a server-side network event handler.
7
+ *
8
+ * The decorated method is invoked when the client triggers
9
+ * `emitNet(eventName, ...)`.
10
+ *
11
+ * ## Player Injection
12
+ * The first argument of the handler **must be `Player`** and is automatically
13
+ * replaced with a `Server.Player` instance representing the client that
14
+ * fired the event. You do NOT need to read `source` manually.
15
+ *
16
+ * ## Auto-Validation
17
+ * Arguments after `Player` are automatically validated based on their TypeScript types:
18
+ * - `string` → `z.string()`
19
+ * - `number` → `z.number()`
20
+ * - `boolean` → `z.boolean()`
21
+ * - `any[]` → `z.array(z.any())` (array content not validated)
22
+ *
23
+ * ## Explicit Schema (Advanced)
24
+ * For stricter validation (ranges, formats, nested objects), provide a Zod schema:
25
+ *
26
+ * @example Auto-validation (simple)
27
+ * ```ts
28
+ * @OnNet("auth:login")
29
+ * handleLogin(player: Player, username: string, password: string) {
30
+ * // username and password are validated as strings automatically
31
+ * }
32
+ * ```
33
+ *
34
+ * @example Explicit schema (strict validation)
35
+ * ```ts
36
+ * const transferSchema = z.object({
37
+ * targetId: z.number().positive(),
38
+ * amount: z.number().min(1).max(1000000),
39
+ * })
40
+ *
41
+ * @OnNet("bank:transfer", { schema: transferSchema })
42
+ * handleTransfer(player: Player, data: z.infer<typeof transferSchema>) {
43
+ * // data.amount is guaranteed to be between 1 and 1,000,000
44
+ * }
45
+ * ```
46
+ *
47
+ * @param eventName - The network event name to listen for.
48
+ * @param options - Optional configuration object.
49
+ * @param options.schema - Zod schema for strict payload validation.
50
+ */
51
+ function OnNet(eventName, options) {
52
+ return (target, propertyKey, descriptor) => {
53
+ const paramTypes = Reflect.getMetadata('design:paramtypes', target, propertyKey);
54
+ const metadata = { eventName, schema: options === null || options === void 0 ? void 0 : options.schema, paramTypes };
55
+ Reflect.defineMetadata(metadata_server_keys_1.METADATA_KEYS.NET_EVENT, metadata, target, propertyKey);
56
+ };
57
+ }
@@ -1 +1,32 @@
1
+ /**
2
+ * OnTick
3
+ * ------------------------------------------------------------
4
+ * Marks a method to be executed on every server tick.
5
+ *
6
+ * Methods decorated with `@OnTick()` are automatically
7
+ * registered by the framework's scheduler and invoked on each
8
+ * FXServer tick (~ every 0–10 ms depending on workload).
9
+ *
10
+ * This decorator should be used for lightweight recurring
11
+ * logic: status updates, background checks, cleanup tasks,
12
+ * or time-based processes relevant to gameplay.
13
+ *
14
+ * Heavy or blocking operations should be avoided inside tick
15
+ * handlers, as they directly impact global server performance.
16
+ *
17
+ * ```ts
18
+ * export class SyncController {
19
+ * @OnTick()
20
+ * updatePlayers() {
21
+ * // Runs every tick
22
+ * this.service.syncPositions()
23
+ * }
24
+ * }
25
+ *
26
+ * ```
27
+ *
28
+ * Internally, the decorator only stores metadata. The
29
+ * server bootstrap scans for this metadata and binds the
30
+ * method to FiveM's tick cycle.
31
+ */
1
32
  export declare function OnTick(): (target: any, propertyKey: string) => void;
@@ -2,6 +2,37 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OnTick = OnTick;
4
4
  const metadata_server_keys_1 = require("../system/metadata-server.keys");
5
+ /**
6
+ * OnTick
7
+ * ------------------------------------------------------------
8
+ * Marks a method to be executed on every server tick.
9
+ *
10
+ * Methods decorated with `@OnTick()` are automatically
11
+ * registered by the framework's scheduler and invoked on each
12
+ * FXServer tick (~ every 0–10 ms depending on workload).
13
+ *
14
+ * This decorator should be used for lightweight recurring
15
+ * logic: status updates, background checks, cleanup tasks,
16
+ * or time-based processes relevant to gameplay.
17
+ *
18
+ * Heavy or blocking operations should be avoided inside tick
19
+ * handlers, as they directly impact global server performance.
20
+ *
21
+ * ```ts
22
+ * export class SyncController {
23
+ * @OnTick()
24
+ * updatePlayers() {
25
+ * // Runs every tick
26
+ * this.service.syncPositions()
27
+ * }
28
+ * }
29
+ *
30
+ * ```
31
+ *
32
+ * Internally, the decorator only stores metadata. The
33
+ * server bootstrap scans for this metadata and binds the
34
+ * method to FiveM's tick cycle.
35
+ */
5
36
  function OnTick() {
6
37
  return (target, propertyKey) => {
7
38
  Reflect.defineMetadata(metadata_server_keys_1.METADATA_KEYS.TICK, {}, target, propertyKey);
@@ -1,16 +1,27 @@
1
1
  /**
2
- * **Only works on NetEvents in Server-side**
2
+ * Marks a server-side NetEvent handler as publicly accessible.
3
3
  *
4
- * Marks an endpoint as publicly accessible (no authentication required).
5
- * Use only for login, register, or public info endpoints.
4
+ * This decorator disables authentication requirements for the
5
+ * decorated method. It should only be applied to endpoints used for:
6
+ * - Login
7
+ * - Registration
8
+ * - Public information retrieval
6
9
  *
7
- * @example
10
+ * ## Security Warning
11
+ * This decorator must be used with caution. Public endpoints must NOT
12
+ * modify sensitive game state unless necessary.
13
+ *
14
+ * ## Example
8
15
  * ```ts
9
16
  * class AuthServerController {
10
- * @ Server.Public()
11
- * @ Server.OnNet('auth:login')
12
- * async login(player: Server.Player, credentials: AuthCredentials) { ... }
17
+ * @Public()
18
+ * @OnNet("auth:login")
19
+ * async login(player: Server.Player, credentials: AuthCredentials) {
20
+ * // no authentication required for this event
21
+ * }
13
22
  * }
14
23
  * ```
15
- * */
24
+ *
25
+ * @returns Method decorator that marks a handler as unauthenticated.
26
+ */
16
27
  export declare function Public(): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
@@ -3,20 +3,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Public = Public;
4
4
  const metadata_server_keys_1 = require("../system/metadata-server.keys");
5
5
  /**
6
- * **Only works on NetEvents in Server-side**
6
+ * Marks a server-side NetEvent handler as publicly accessible.
7
7
  *
8
- * Marks an endpoint as publicly accessible (no authentication required).
9
- * Use only for login, register, or public info endpoints.
8
+ * This decorator disables authentication requirements for the
9
+ * decorated method. It should only be applied to endpoints used for:
10
+ * - Login
11
+ * - Registration
12
+ * - Public information retrieval
10
13
  *
11
- * @example
14
+ * ## Security Warning
15
+ * This decorator must be used with caution. Public endpoints must NOT
16
+ * modify sensitive game state unless necessary.
17
+ *
18
+ * ## Example
12
19
  * ```ts
13
20
  * class AuthServerController {
14
- * @ Server.Public()
15
- * @ Server.OnNet('auth:login')
16
- * async login(player: Server.Player, credentials: AuthCredentials) { ... }
21
+ * @Public()
22
+ * @OnNet("auth:login")
23
+ * async login(player: Server.Player, credentials: AuthCredentials) {
24
+ * // no authentication required for this event
25
+ * }
17
26
  * }
18
27
  * ```
19
- * */
28
+ *
29
+ * @returns Method decorator that marks a handler as unauthenticated.
30
+ */
20
31
  function Public() {
21
32
  return function (target, propertyKey, descriptor) {
22
33
  Reflect.defineMetadata(metadata_server_keys_1.METADATA_KEYS.PUBLIC, true, target, propertyKey);
@@ -22,34 +22,35 @@ export interface StateRequirement {
22
22
  errorMessage?: string;
23
23
  }
24
24
  /**
25
- * **Game State Guard Decorator**
25
+ * Enforces gameplay state requirements before executing a method.
26
26
  *
27
- * A method decorator that enforces game logic constraints based on the player's dynamic states.
28
- * It intercepts the method call and validates the player's flags (e.g., 'dead', 'cuffed', 'driving')
29
- * before allowing the controller logic to execute.
27
+ * The decorator intercepts the method call and verifies whether
28
+ * the player satisfies required state flags (e.g. "dead", "cuffed",
29
+ * "on_duty_police").
30
30
  *
31
- * @remarks
32
- * - This decorator assumes the **first argument** of the decorated method is a `Server.Player` instance.
33
- * - It throws a `GAME_STATE_ERROR` (AppError) if requirements are not met, which should be caught by the global error handler.
31
+ * ## Whitelist (`has`)
32
+ * The player MUST have *all* required states. Missing any state blocks execution.
34
33
  *
35
- * @param req - The state requirements configuration (whitelist and/or blacklist).
34
+ * ## Blacklist (`missing`)
35
+ * The player MUST NOT have any of the forbidden states.
36
36
  *
37
- * @throws {Error} If the decorated method is called without a valid Player context (Server-side logic error).
38
- * @throws {AppError} If the player fails the state validation (Client-facing logic error).
37
+ * ## Error Handling
38
+ * - Throws a normal Error if the method is called without a valid Player.
39
+ * - Throws an `AppError(GAME_STATE_ERROR)` if validation fails.
39
40
  *
40
- * @example
41
+ * ## Example
41
42
  * ```ts
42
- * // Example 1: Action requires being alive (not dead) and not handcuffed
43
- * @RequiresState({ missing: ['dead', 'cuffed'] })
43
+ * @RequiresState({ missing: ["dead", "cuffed"] })
44
44
  * openInventory(player: Server.Player) { ... }
45
45
  *
46
- * // Example 2: Action requires being a police officer on duty
47
46
  * @RequiresState({
48
- * has: ['police_duty'],
49
- * missing: ['dead'],
50
- * errorMessage: 'You must be on duty to access the armory.'
47
+ * has: ["police_duty"],
48
+ * missing: ["dead"],
49
+ * errorMessage: "You must be on duty to access the armory."
51
50
  * })
52
51
  * openArmory(player: Server.Player) { ... }
53
52
  * ```
53
+ *
54
+ * @param req - State validation configuration.
54
55
  */
55
56
  export declare function RequiresState(req: StateRequirement): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
@@ -3,35 +3,36 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RequiresState = RequiresState;
4
4
  const utils_1 = require("../../utils");
5
5
  /**
6
- * **Game State Guard Decorator**
6
+ * Enforces gameplay state requirements before executing a method.
7
7
  *
8
- * A method decorator that enforces game logic constraints based on the player's dynamic states.
9
- * It intercepts the method call and validates the player's flags (e.g., 'dead', 'cuffed', 'driving')
10
- * before allowing the controller logic to execute.
8
+ * The decorator intercepts the method call and verifies whether
9
+ * the player satisfies required state flags (e.g. "dead", "cuffed",
10
+ * "on_duty_police").
11
11
  *
12
- * @remarks
13
- * - This decorator assumes the **first argument** of the decorated method is a `Server.Player` instance.
14
- * - It throws a `GAME_STATE_ERROR` (AppError) if requirements are not met, which should be caught by the global error handler.
12
+ * ## Whitelist (`has`)
13
+ * The player MUST have *all* required states. Missing any state blocks execution.
15
14
  *
16
- * @param req - The state requirements configuration (whitelist and/or blacklist).
15
+ * ## Blacklist (`missing`)
16
+ * The player MUST NOT have any of the forbidden states.
17
17
  *
18
- * @throws {Error} If the decorated method is called without a valid Player context (Server-side logic error).
19
- * @throws {AppError} If the player fails the state validation (Client-facing logic error).
18
+ * ## Error Handling
19
+ * - Throws a normal Error if the method is called without a valid Player.
20
+ * - Throws an `AppError(GAME_STATE_ERROR)` if validation fails.
20
21
  *
21
- * @example
22
+ * ## Example
22
23
  * ```ts
23
- * // Example 1: Action requires being alive (not dead) and not handcuffed
24
- * @RequiresState({ missing: ['dead', 'cuffed'] })
24
+ * @RequiresState({ missing: ["dead", "cuffed"] })
25
25
  * openInventory(player: Server.Player) { ... }
26
26
  *
27
- * // Example 2: Action requires being a police officer on duty
28
27
  * @RequiresState({
29
- * has: ['police_duty'],
30
- * missing: ['dead'],
31
- * errorMessage: 'You must be on duty to access the armory.'
28
+ * has: ["police_duty"],
29
+ * missing: ["dead"],
30
+ * errorMessage: "You must be on duty to access the armory."
32
31
  * })
33
32
  * openArmory(player: Server.Player) { ... }
34
33
  * ```
34
+ *
35
+ * @param req - State validation configuration.
35
36
  */
36
37
  function RequiresState(req) {
37
38
  return function (target, propertyKey, descriptor) {