@armoury/fivem-framework-server 1.0.23 → 1.0.25
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.
- package/dist/cjs/server/index.js +0 -3
- package/dist/cjs/server/services/session/session.service.js +9 -4
- package/dist/cjs/shared/models/session.js +10 -1
- package/dist/esm/server/index.js +0 -3
- package/dist/esm/server/services/session/session.service.js +9 -4
- package/dist/esm/shared/models/session.js +10 -1
- package/dist/types/server/index.d.ts +0 -1
- package/dist/types/server/services/session/session.service.d.ts +3 -0
- package/dist/types/shared/models/session.d.ts +5 -1
- package/package.json +2 -7
package/dist/cjs/server/index.js
CHANGED
|
@@ -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,13 +16,15 @@ 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
|
+
getClaimValue(sessionId, claimName) {
|
|
23
|
+
return this.armouryResource.instance.getClaimValue(sessionId, claimName);
|
|
24
|
+
}
|
|
25
|
+
setClaim(sessionId, claimName, value) {
|
|
26
|
+
return this.armouryResource.instance.setClaim(sessionId, claimName, value);
|
|
27
|
+
}
|
|
26
28
|
getNumPlayersConnected() {
|
|
27
29
|
return this.armouryResource.instance.getNumPlayersConnected();
|
|
28
30
|
}
|
|
@@ -38,6 +40,9 @@ let SessionService = class SessionService {
|
|
|
38
40
|
getSessionByPlayerId(playerId) {
|
|
39
41
|
return this.armouryResource.instance.getSessionByPlayerId(playerId);
|
|
40
42
|
}
|
|
43
|
+
getSessionByPrincipal(principal) {
|
|
44
|
+
return this.armouryResource.instance.getSessionByPrincipal(principal);
|
|
45
|
+
}
|
|
41
46
|
setPlayerPrincipal(playerId, principal) {
|
|
42
47
|
this.armouryResource.instance.setPlayerPrincipal(playerId, principal);
|
|
43
48
|
}
|
|
@@ -2,11 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Session = void 0;
|
|
4
4
|
class Session {
|
|
5
|
-
constructor(id, platformId, lastKnownName, principal) {
|
|
5
|
+
constructor(id, platformId, lastKnownName, principal, claims = {}) {
|
|
6
6
|
this.id = id;
|
|
7
7
|
this.platformId = platformId;
|
|
8
8
|
this.lastKnownName = lastKnownName;
|
|
9
9
|
this.principal = principal;
|
|
10
|
+
this.claims = claims;
|
|
11
|
+
}
|
|
12
|
+
getClaimValue(claimName) {
|
|
13
|
+
var _a;
|
|
14
|
+
return (_a = this.claims[claimName]) !== null && _a !== void 0 ? _a : null;
|
|
15
|
+
}
|
|
16
|
+
setClaim(claimName, value) {
|
|
17
|
+
this.claims[claimName] = value;
|
|
18
|
+
return value;
|
|
10
19
|
}
|
|
11
20
|
}
|
|
12
21
|
exports.Session = Session;
|
package/dist/esm/server/index.js
CHANGED
|
@@ -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,13 +13,15 @@ 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
|
+
getClaimValue(sessionId, claimName) {
|
|
20
|
+
return this.armouryResource.instance.getClaimValue(sessionId, claimName);
|
|
21
|
+
}
|
|
22
|
+
setClaim(sessionId, claimName, value) {
|
|
23
|
+
return this.armouryResource.instance.setClaim(sessionId, claimName, value);
|
|
24
|
+
}
|
|
23
25
|
getNumPlayersConnected() {
|
|
24
26
|
return this.armouryResource.instance.getNumPlayersConnected();
|
|
25
27
|
}
|
|
@@ -35,6 +37,9 @@ let SessionService = class SessionService {
|
|
|
35
37
|
getSessionByPlayerId(playerId) {
|
|
36
38
|
return this.armouryResource.instance.getSessionByPlayerId(playerId);
|
|
37
39
|
}
|
|
40
|
+
getSessionByPrincipal(principal) {
|
|
41
|
+
return this.armouryResource.instance.getSessionByPrincipal(principal);
|
|
42
|
+
}
|
|
38
43
|
setPlayerPrincipal(playerId, principal) {
|
|
39
44
|
this.armouryResource.instance.setPlayerPrincipal(playerId, principal);
|
|
40
45
|
}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
export class Session {
|
|
2
|
-
constructor(id, platformId, lastKnownName, principal) {
|
|
2
|
+
constructor(id, platformId, lastKnownName, principal, claims = {}) {
|
|
3
3
|
this.id = id;
|
|
4
4
|
this.platformId = platformId;
|
|
5
5
|
this.lastKnownName = lastKnownName;
|
|
6
6
|
this.principal = principal;
|
|
7
|
+
this.claims = claims;
|
|
8
|
+
}
|
|
9
|
+
getClaimValue(claimName) {
|
|
10
|
+
var _a;
|
|
11
|
+
return (_a = this.claims[claimName]) !== null && _a !== void 0 ? _a : null;
|
|
12
|
+
}
|
|
13
|
+
setClaim(claimName, value) {
|
|
14
|
+
this.claims[claimName] = value;
|
|
15
|
+
return value;
|
|
7
16
|
}
|
|
8
17
|
}
|
|
@@ -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,10 +2,13 @@ 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
|
+
getClaimValue<T>(sessionId: number, claimName: string): T | null;
|
|
6
|
+
setClaim<T>(sessionId: number, claimName: string, value: T): T | null;
|
|
5
7
|
getNumPlayersConnected(): number;
|
|
6
8
|
getAllPlayerIds(): number[];
|
|
7
9
|
getAllPlayerPrincipals(): number[];
|
|
8
10
|
isPlayerConnected(playerId: number): boolean;
|
|
9
11
|
getSessionByPlayerId(playerId: number): Session;
|
|
12
|
+
getSessionByPrincipal(principal: number): Session;
|
|
10
13
|
setPlayerPrincipal(playerId: number, principal: number): void;
|
|
11
14
|
}
|
|
@@ -3,11 +3,15 @@ export interface Session {
|
|
|
3
3
|
readonly platformId: string;
|
|
4
4
|
readonly lastKnownName: string;
|
|
5
5
|
principal?: number;
|
|
6
|
+
readonly claims: Record<string, unknown>;
|
|
6
7
|
}
|
|
7
8
|
export declare class Session {
|
|
8
9
|
readonly id: number;
|
|
9
10
|
readonly platformId: string;
|
|
10
11
|
readonly lastKnownName: string;
|
|
11
12
|
principal?: number | undefined;
|
|
12
|
-
|
|
13
|
+
readonly claims: Record<string, unknown>;
|
|
14
|
+
constructor(id: number, platformId: string, lastKnownName: string, principal?: number | undefined, claims?: Record<string, unknown>);
|
|
15
|
+
getClaimValue<T>(claimName: string): T | null;
|
|
16
|
+
setClaim<T>(claimName: string, value: T): T;
|
|
13
17
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@armoury/fivem-framework-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.25",
|
|
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.
|
|
31
|
-
"drizzle-orm": "^0.45.4",
|
|
32
|
-
"mysql2": "^3.24.5"
|
|
30
|
+
"@armoury/fivem-framework-common": "1.0.25"
|
|
33
31
|
},
|
|
34
32
|
"publishConfig": {
|
|
35
33
|
"access": "public"
|
|
36
|
-
},
|
|
37
|
-
"devDependencies": {
|
|
38
|
-
"drizzle-kit": "^0.31.11"
|
|
39
34
|
}
|
|
40
35
|
}
|