@armoury/fivem-framework-server 1.0.36 → 1.0.37

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,20 +32,14 @@ let SessionService = class SessionService {
32
32
  return this.armouryResource.instance.isPlayerConnected(playerId);
33
33
  }
34
34
  getSessionByPlayerId(playerId) {
35
- return this.toSessionInstance(this.armouryResource.instance.getSessionByPlayerId(playerId));
35
+ return fivem_framework_common_1.Session.from(this.armouryResource.instance.getSessionByPlayerId(playerId));
36
36
  }
37
37
  getSessionByPrincipal(principal) {
38
- return this.toSessionInstance(this.armouryResource.instance.getSessionByPrincipal(principal));
38
+ return fivem_framework_common_1.Session.from(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
- }
49
43
  };
50
44
  exports.SessionService = SessionService;
51
45
  exports.SessionService = SessionService = __decorate([
@@ -105,5 +105,11 @@ class Session {
105
105
  this.setState(claimName, value, false);
106
106
  return value;
107
107
  }
108
+ static from(session) {
109
+ if (session instanceof Session) {
110
+ return session;
111
+ }
112
+ return new Session(session.id, session.platformId, session.lastKnownName, session.principal);
113
+ }
108
114
  }
109
115
  exports.Session = Session;
@@ -29,20 +29,14 @@ let SessionService = class SessionService {
29
29
  return this.armouryResource.instance.isPlayerConnected(playerId);
30
30
  }
31
31
  getSessionByPlayerId(playerId) {
32
- return this.toSessionInstance(this.armouryResource.instance.getSessionByPlayerId(playerId));
32
+ return Session.from(this.armouryResource.instance.getSessionByPlayerId(playerId));
33
33
  }
34
34
  getSessionByPrincipal(principal) {
35
- return this.toSessionInstance(this.armouryResource.instance.getSessionByPrincipal(principal));
35
+ return Session.from(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
- }
46
40
  };
47
41
  SessionService = __decorate([
48
42
  Injectable(),
@@ -102,4 +102,10 @@ export class Session {
102
102
  this.setState(claimName, value, false);
103
103
  return value;
104
104
  }
105
+ static from(session) {
106
+ if (session instanceof Session) {
107
+ return session;
108
+ }
109
+ return new Session(session.id, session.platformId, session.lastKnownName, session.principal);
110
+ }
105
111
  }
@@ -9,5 +9,4 @@ 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;
13
12
  }
@@ -73,6 +73,7 @@ export declare class Session {
73
73
  * @returns the updated value, or null if not found or impossible to update.
74
74
  */
75
75
  setServerClaim<T extends Primitive>(claimName: string, value: T): T | null;
76
+ static from(session: Session): Session;
76
77
  }
77
78
  type Primitive = string | number | boolean | bigint | symbol | null | undefined;
78
79
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@armoury/fivem-framework-server",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
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.36"
30
+ "@armoury/fivem-framework-common": "1.0.37"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"