@armoury/fivem-framework-server 1.0.31 → 1.0.36

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.
@@ -32,14 +32,20 @@ let SessionService = class SessionService {
32
32
  return this.armouryResource.instance.isPlayerConnected(playerId);
33
33
  }
34
34
  getSessionByPlayerId(playerId) {
35
- return this.armouryResource.instance.getSessionByPlayerId(playerId);
35
+ return this.toSessionInstance(this.armouryResource.instance.getSessionByPlayerId(playerId));
36
36
  }
37
37
  getSessionByPrincipal(principal) {
38
- return this.armouryResource.instance.getSessionByPrincipal(principal);
38
+ return this.toSessionInstance(this.armouryResource.instance.getSessionByPrincipal(principal));
39
39
  }
40
40
  setPlayerPrincipal(playerId, principal) {
41
41
  this.armouryResource.instance.setPlayerPrincipal(playerId, principal);
42
42
  }
43
+ toSessionInstance(session) {
44
+ if (session instanceof fivem_framework_common_1.Session) {
45
+ return session;
46
+ }
47
+ return new fivem_framework_common_1.Session(session.id, session.platformId, session.lastKnownName, session.principal);
48
+ }
43
49
  };
44
50
  exports.SessionService = SessionService;
45
51
  exports.SessionService = SessionService = __decorate([
@@ -10,7 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  var __param = (this && this.__param) || function (paramIndex, decorator) {
11
11
  return function (target, key) { decorator(target, key, paramIndex); }
12
12
  };
13
- import { Resource, ResourceRef } from '@armoury/fivem-framework-common';
13
+ import { Resource, ResourceRef, Session } from '@armoury/fivem-framework-common';
14
14
  import { Injectable } from 'injection-js';
15
15
  let SessionService = class SessionService {
16
16
  constructor(armouryResource) {
@@ -29,14 +29,20 @@ let SessionService = class SessionService {
29
29
  return this.armouryResource.instance.isPlayerConnected(playerId);
30
30
  }
31
31
  getSessionByPlayerId(playerId) {
32
- return this.armouryResource.instance.getSessionByPlayerId(playerId);
32
+ return this.toSessionInstance(this.armouryResource.instance.getSessionByPlayerId(playerId));
33
33
  }
34
34
  getSessionByPrincipal(principal) {
35
- return this.armouryResource.instance.getSessionByPrincipal(principal);
35
+ return this.toSessionInstance(this.armouryResource.instance.getSessionByPrincipal(principal));
36
36
  }
37
37
  setPlayerPrincipal(playerId, principal) {
38
38
  this.armouryResource.instance.setPlayerPrincipal(playerId, principal);
39
39
  }
40
+ toSessionInstance(session) {
41
+ if (session instanceof Session) {
42
+ return session;
43
+ }
44
+ return new Session(session.id, session.platformId, session.lastKnownName, session.principal);
45
+ }
40
46
  };
41
47
  SessionService = __decorate([
42
48
  Injectable(),
@@ -9,4 +9,5 @@ export declare class SessionService {
9
9
  getSessionByPlayerId(playerId: number): Session;
10
10
  getSessionByPrincipal(principal: number): Session;
11
11
  setPlayerPrincipal(playerId: number, principal: number): void;
12
+ private toSessionInstance;
12
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@armoury/fivem-framework-server",
3
- "version": "1.0.31",
3
+ "version": "1.0.36",
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,7 +27,7 @@
27
27
  "rxjs": "^7.8.1"
28
28
  },
29
29
  "peerDependencies": {
30
- "@armoury/fivem-framework-common": "1.0.31"
30
+ "@armoury/fivem-framework-common": "1.0.36"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"