@armoury/fivem-framework-server 1.0.22 → 1.0.24

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.
@@ -19,17 +19,14 @@ exports.SERVER_EAGER_PROVIDERS = exports.SERVER_LAZY_PROVIDERS = void 0;
19
19
  exports.bootstrap = bootstrap;
20
20
  require("reflect-metadata");
21
21
  const fivem_framework_common_1 = require("@armoury/fivem-framework-common");
22
- const database_1 = require("./database/database");
23
22
  const services_1 = require("./services");
24
23
  exports.SERVER_LAZY_PROVIDERS = [];
25
24
  exports.SERVER_EAGER_PROVIDERS = [
26
- database_1.Database.forChild(),
27
25
  services_1.SessionService,
28
26
  ];
29
27
  async function bootstrap(_class, options = {}) {
30
28
  return (0, fivem_framework_common_1.bootstrapWithProviders)(_class, exports.SERVER_LAZY_PROVIDERS, options, undefined, (key, index) => Cfx.Server.GetResourceMetadata(Cfx.Server.GetCurrentResourceName(), key, index), (resourceName) => Cfx.exports[resourceName], exports.SERVER_EAGER_PROVIDERS);
31
29
  }
32
- __exportStar(require("./database"), exports);
33
30
  __exportStar(require("./services"), exports);
34
31
  __exportStar(require("./models"), exports);
35
32
  __exportStar(require("@armoury/fivem-framework-common"), exports);
@@ -16,19 +16,27 @@ exports.SessionService = void 0;
16
16
  const fivem_framework_common_1 = require("@armoury/fivem-framework-common");
17
17
  const injection_js_1 = require("injection-js");
18
18
  let SessionService = class SessionService {
19
- // TODO: Move to AccountsService inside @armoury/fivem-roleplay-gamemode-server
20
- // public constructor(
21
- // private readonly _repository: SessionRepository,
22
- // ) { }
23
19
  constructor(armouryResource) {
24
20
  this.armouryResource = armouryResource;
25
21
  }
22
+ getNumPlayersConnected() {
23
+ return this.armouryResource.instance.getNumPlayersConnected();
24
+ }
25
+ getAllPlayerIds() {
26
+ return this.armouryResource.instance.getAllPlayerIds();
27
+ }
28
+ getAllPlayerPrincipals() {
29
+ return this.armouryResource.instance.getAllPlayerPrincipals();
30
+ }
26
31
  isPlayerConnected(playerId) {
27
32
  return this.armouryResource.instance.isPlayerConnected(playerId);
28
33
  }
29
34
  getSessionByPlayerId(playerId) {
30
35
  return this.armouryResource.instance.getSessionByPlayerId(playerId);
31
36
  }
37
+ getSessionByPrincipal(principal) {
38
+ return this.armouryResource.instance.getSessionByPrincipal(principal);
39
+ }
32
40
  setPlayerPrincipal(playerId, principal) {
33
41
  this.armouryResource.instance.setPlayerPrincipal(playerId, principal);
34
42
  }
@@ -16,4 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./account"), exports);
18
18
  __exportStar(require("./character"), exports);
19
+ /** Session */
19
20
  __exportStar(require("./session"), exports);
21
+ __exportStar(require("./session-update-type"), exports);
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SessionUpdateType = void 0;
4
+ var SessionUpdateType;
5
+ (function (SessionUpdateType) {
6
+ SessionUpdateType[SessionUpdateType["PrincipalUpdate"] = 0] = "PrincipalUpdate";
7
+ })(SessionUpdateType || (exports.SessionUpdateType = SessionUpdateType = {}));
@@ -6,7 +6,7 @@ class Session {
6
6
  this.id = id;
7
7
  this.platformId = platformId;
8
8
  this.lastKnownName = lastKnownName;
9
- this.principal = principal !== null && principal !== void 0 ? principal : id;
9
+ this.principal = principal;
10
10
  }
11
11
  }
12
12
  exports.Session = Session;
@@ -1,17 +1,14 @@
1
1
  /// <reference path = "../ambient.declarations.d.ts" />
2
2
  import 'reflect-metadata';
3
3
  import { bootstrapWithProviders } from '@armoury/fivem-framework-common';
4
- import { Database } from './database/database';
5
4
  import { SessionService } from './services';
6
5
  export const SERVER_LAZY_PROVIDERS = [];
7
6
  export const SERVER_EAGER_PROVIDERS = [
8
- Database.forChild(),
9
7
  SessionService,
10
8
  ];
11
9
  export async function bootstrap(_class, options = {}) {
12
10
  return bootstrapWithProviders(_class, SERVER_LAZY_PROVIDERS, options, undefined, (key, index) => Cfx.Server.GetResourceMetadata(Cfx.Server.GetCurrentResourceName(), key, index), (resourceName) => Cfx.exports[resourceName], SERVER_EAGER_PROVIDERS);
13
11
  }
14
- export * from './database';
15
12
  export * from './services';
16
13
  export * from './models';
17
14
  export * from '@armoury/fivem-framework-common';
@@ -13,19 +13,27 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
13
13
  import { Resource, ResourceRef } from '@armoury/fivem-framework-common';
14
14
  import { Injectable } from 'injection-js';
15
15
  let SessionService = class SessionService {
16
- // TODO: Move to AccountsService inside @armoury/fivem-roleplay-gamemode-server
17
- // public constructor(
18
- // private readonly _repository: SessionRepository,
19
- // ) { }
20
16
  constructor(armouryResource) {
21
17
  this.armouryResource = armouryResource;
22
18
  }
19
+ getNumPlayersConnected() {
20
+ return this.armouryResource.instance.getNumPlayersConnected();
21
+ }
22
+ getAllPlayerIds() {
23
+ return this.armouryResource.instance.getAllPlayerIds();
24
+ }
25
+ getAllPlayerPrincipals() {
26
+ return this.armouryResource.instance.getAllPlayerPrincipals();
27
+ }
23
28
  isPlayerConnected(playerId) {
24
29
  return this.armouryResource.instance.isPlayerConnected(playerId);
25
30
  }
26
31
  getSessionByPlayerId(playerId) {
27
32
  return this.armouryResource.instance.getSessionByPlayerId(playerId);
28
33
  }
34
+ getSessionByPrincipal(principal) {
35
+ return this.armouryResource.instance.getSessionByPrincipal(principal);
36
+ }
29
37
  setPlayerPrincipal(playerId, principal) {
30
38
  this.armouryResource.instance.setPlayerPrincipal(playerId, principal);
31
39
  }
@@ -1,3 +1,5 @@
1
1
  export * from './account';
2
2
  export * from './character';
3
+ /** Session */
3
4
  export * from './session';
5
+ export * from './session-update-type';
@@ -0,0 +1,4 @@
1
+ export var SessionUpdateType;
2
+ (function (SessionUpdateType) {
3
+ SessionUpdateType[SessionUpdateType["PrincipalUpdate"] = 0] = "PrincipalUpdate";
4
+ })(SessionUpdateType || (SessionUpdateType = {}));
@@ -3,6 +3,6 @@ export class Session {
3
3
  this.id = id;
4
4
  this.platformId = platformId;
5
5
  this.lastKnownName = lastKnownName;
6
- this.principal = principal !== null && principal !== void 0 ? principal : id;
6
+ this.principal = principal;
7
7
  }
8
8
  }
@@ -7,7 +7,6 @@ export declare const SERVER_EAGER_PROVIDERS: Provider[];
7
7
  export declare function bootstrap<T extends {
8
8
  new (...args: any[]): any;
9
9
  } & Provider>(_class: T, options?: BootstrapOptions): Promise<InstanceType<T>>;
10
- export * from './database';
11
10
  export * from './services';
12
11
  export * from './models';
13
12
  export * from '@armoury/fivem-framework-common';
@@ -2,7 +2,11 @@ import { ResourceRef, Session } from '@armoury/fivem-framework-common';
2
2
  export declare class SessionService {
3
3
  private readonly armouryResource;
4
4
  constructor(armouryResource: ResourceRef);
5
+ getNumPlayersConnected(): number;
6
+ getAllPlayerIds(): number[];
7
+ getAllPlayerPrincipals(): number[];
5
8
  isPlayerConnected(playerId: number): boolean;
6
9
  getSessionByPlayerId(playerId: number): Session;
10
+ getSessionByPrincipal(principal: number): Session;
7
11
  setPlayerPrincipal(playerId: number, principal: number): void;
8
12
  }
@@ -1,3 +1,5 @@
1
1
  export * from './account';
2
2
  export * from './character';
3
+ /** Session */
3
4
  export * from './session';
5
+ export * from './session-update-type';
@@ -0,0 +1,3 @@
1
+ export declare enum SessionUpdateType {
2
+ PrincipalUpdate = 0
3
+ }
@@ -2,11 +2,12 @@ export interface Session {
2
2
  readonly id: number;
3
3
  readonly platformId: string;
4
4
  readonly lastKnownName: string;
5
- principal: number;
5
+ principal?: number;
6
6
  }
7
7
  export declare class Session {
8
8
  readonly id: number;
9
9
  readonly platformId: string;
10
10
  readonly lastKnownName: string;
11
- constructor(id: number, platformId: string, lastKnownName: string, principal?: number);
11
+ principal?: number | undefined;
12
+ constructor(id: number, platformId: string, lastKnownName: string, principal?: number | undefined);
12
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@armoury/fivem-framework-server",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "Server APIs for the Armoury FiveM framework",
5
5
  "main": "dist/cjs/server/index.js",
6
6
  "module": "dist/esm/server/index.js",
@@ -27,14 +27,9 @@
27
27
  "rxjs": "^7.8.1"
28
28
  },
29
29
  "peerDependencies": {
30
- "@armoury/fivem-framework-common": "1.0.22",
31
- "drizzle-orm": "^0.45.4",
32
- "mysql2": "^3.24.5"
30
+ "@armoury/fivem-framework-common": "1.0.24"
33
31
  },
34
32
  "publishConfig": {
35
33
  "access": "public"
36
- },
37
- "devDependencies": {
38
- "drizzle-kit": "^0.31.11"
39
34
  }
40
35
  }