libertyts 1.0.2 → 1.0.4
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/helpers/Http/request.d.ts +3 -0
- package/dist/helpers/Http/request.d.ts.map +1 -0
- package/dist/helpers/Http/request.js +21 -0
- package/dist/helpers/Http/request.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/types.d.ts +11 -1
- package/dist/utils/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/helpers/Http/request.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAY,MAAM,sBAAsB,CAAA;AAExD,wBAAsB,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAkB7D"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
export async function request(options) {
|
|
3
|
+
try {
|
|
4
|
+
const axiosResponse = await axios({
|
|
5
|
+
url: options.url,
|
|
6
|
+
method: options.method,
|
|
7
|
+
params: options.params,
|
|
8
|
+
data: options.data,
|
|
9
|
+
headers: options.headers,
|
|
10
|
+
timeout: options.timeout ?? 5000
|
|
11
|
+
});
|
|
12
|
+
return axiosResponse.data;
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
const red = "\x1b[31m";
|
|
16
|
+
const reset = "\x1b[0m";
|
|
17
|
+
console.log(`${red}[REQUEST ERROR]${reset} ${err.message}`);
|
|
18
|
+
throw err;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/helpers/Http/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,MAAM,CAAC,KAAK,UAAU,OAAO,CAAI,OAAgB;IAC/C,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,MAAM,KAAK,CAAC;YAChC,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,IAAI;SACjC,CAAC,CAAA;QAEF,OAAO,aAAa,CAAC,IAAS,CAAA;IAChC,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,MAAM,GAAG,GAAG,UAAU,CAAA;QACtB,MAAM,KAAK,GAAG,SAAS,CAAA;QACvB,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,kBAAkB,KAAK,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;QAC3D,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ClientOptions } from "./utils/types.js";
|
|
1
|
+
import { ClientOptions, Player } from "./utils/types.js";
|
|
2
2
|
export declare class Client {
|
|
3
3
|
private apikey;
|
|
4
4
|
constructor(options: ClientOptions);
|
|
5
|
+
getPlayer(playerName: string): Promise<Player | undefined>;
|
|
5
6
|
}
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAIhE,qBAAa,MAAM;IACf,OAAO,CAAC,MAAM,CAAQ;gBAEV,OAAO,EAAE,aAAa;IAO5B,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;CAYnE"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import API from "./config/API.json" with { type: "json" };
|
|
2
|
+
import { request } from "./helpers/Http/request.js";
|
|
1
3
|
export class Client {
|
|
2
4
|
constructor(options) {
|
|
3
5
|
if (!options?.apiKey) {
|
|
@@ -5,5 +7,16 @@ export class Client {
|
|
|
5
7
|
}
|
|
6
8
|
this.apikey = options.apiKey;
|
|
7
9
|
}
|
|
10
|
+
async getPlayer(playerName) {
|
|
11
|
+
const serverData = await request({
|
|
12
|
+
url: API.BaseURLs.v2 + "/server",
|
|
13
|
+
method: "GET",
|
|
14
|
+
params: { Players: true },
|
|
15
|
+
headers: {
|
|
16
|
+
"server-key": this.apikey
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return serverData.Players.find(p => p.Player.split(":")[0] === playerName);
|
|
20
|
+
}
|
|
8
21
|
}
|
|
9
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,mBAAmB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAEnD,MAAM,OAAO,MAAM;IAGf,YAAY,OAAsB;QAC9B,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAA;QAC9E,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;IAChC,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,UAAkB;QAC9B,MAAM,UAAU,GAAG,MAAM,OAAO,CAAwB;YACpD,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,EAAE,GAAG,SAAS;YAChC,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;YACzB,OAAO,EAAE;gBACL,YAAY,EAAE,IAAI,CAAC,MAAM;aAC5B;SACJ,CAAC,CAAA;QAEF,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAA;IAC9E,CAAC;CACJ"}
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { AxiosResponse } from "axios";
|
|
1
2
|
export interface ClientOptions {
|
|
2
3
|
apiKey: string;
|
|
3
4
|
}
|
|
4
5
|
export type apiKey = string;
|
|
5
6
|
export type Player = {
|
|
7
|
+
Player: string;
|
|
6
8
|
Team: string;
|
|
7
9
|
Callsign: string | null;
|
|
8
10
|
Location: {
|
|
@@ -15,5 +17,13 @@ export type Player = {
|
|
|
15
17
|
Permission: string;
|
|
16
18
|
WantedStars: number;
|
|
17
19
|
};
|
|
18
|
-
export type Request = {
|
|
20
|
+
export type Request<TResponse = any, TBody = any> = {
|
|
21
|
+
url: string;
|
|
22
|
+
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
23
|
+
params?: Record<string, any>;
|
|
24
|
+
data?: TBody;
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
timeout?: number;
|
|
27
|
+
};
|
|
28
|
+
export type Response<T = any> = AxiosResponse<T>;
|
|
19
29
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,aAAa,EAAE,MAAM,OAAO,CAAA;AAEzD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,MAAM,GAAG,MAAM,CAAA;AAE3B,MAAM,MAAM,MAAM,GAAG;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,QAAQ,EAAE;QACR,SAAS,EAAE,MAAM,CAAA;QACjB,SAAS,EAAE,MAAM,CAAA;QACjB,UAAU,EAAE,MAAM,CAAA;QAClB,UAAU,EAAE,MAAM,CAAA;QAClB,cAAc,EAAE,MAAM,CAAA;KACvB,CAAA;IACD,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,OAAO,CAAC,SAAS,GAAG,GAAG,EAAE,KAAK,GAAG,GAAG,IAAI;IAClD,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAA;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5B,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,GAAG,GAAG,IAAI,aAAa,CAAC,CAAC,CAAC,CAAA"}
|