mowojang 0.5.0 → 0.5.1
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/index.d.ts +21 -1
- package/dist/index.js +23 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ type Username = string;
|
|
|
16
16
|
/**
|
|
17
17
|
* Minecraft UUIDv4 (both undashed and dashed will be accepted)
|
|
18
18
|
*
|
|
19
|
-
* @example
|
|
19
|
+
* @example 14727fae-fbdc-4aff-848c-d2713eb9939e
|
|
20
20
|
*/
|
|
21
21
|
type UUID = string;
|
|
22
22
|
|
|
@@ -117,6 +117,8 @@ declare class Client {
|
|
|
117
117
|
*
|
|
118
118
|
* Players considered "INVALID" are excluded from the results
|
|
119
119
|
*
|
|
120
|
+
* Default cache TTL: 1 hour when config.cache is not provided.
|
|
121
|
+
*
|
|
120
122
|
* @example
|
|
121
123
|
* ```TS
|
|
122
124
|
* const profiles = await client.getProfiles(["Pixelic", "14727faefbdc4aff848cd2713eb9939e"]);
|
|
@@ -128,6 +130,8 @@ declare class Client {
|
|
|
128
130
|
/**
|
|
129
131
|
* Returns a Player's Profile consisting of their Username and UUID
|
|
130
132
|
*
|
|
133
|
+
* Default cache TTL: 1 hour when config.cache is not provided.
|
|
134
|
+
*
|
|
131
135
|
* @example
|
|
132
136
|
* ```TS
|
|
133
137
|
* const profile = await client.getProfile("Pixelic");
|
|
@@ -137,6 +141,8 @@ declare class Client {
|
|
|
137
141
|
/**
|
|
138
142
|
* A simple Wrapper to retrieve only the UUID of a Player's Profile
|
|
139
143
|
*
|
|
144
|
+
* Uses getProfile cache behavior (default TTL: 1 hour when config.cache is not provided).
|
|
145
|
+
*
|
|
140
146
|
* @example
|
|
141
147
|
* ```TS
|
|
142
148
|
* const uuid = await client.getUUID("Pixelic");
|
|
@@ -146,6 +152,8 @@ declare class Client {
|
|
|
146
152
|
/**
|
|
147
153
|
* A simple Wrapper to retrieve only the Username of a Player's Profile
|
|
148
154
|
*
|
|
155
|
+
* Uses getProfile cache behavior (default TTL: 1 hour when config.cache is not provided).
|
|
156
|
+
*
|
|
149
157
|
* @example
|
|
150
158
|
* ```TS
|
|
151
159
|
* const username = await client.getUsername("14727faefbdc4aff848cd2713eb9939e");
|
|
@@ -157,6 +165,8 @@ declare class Client {
|
|
|
157
165
|
*
|
|
158
166
|
* Players considered "INVALID" are excluded from the results
|
|
159
167
|
*
|
|
168
|
+
* Uses getSession cache behavior (default TTL: 15 minutes when config.cache is not provided).
|
|
169
|
+
*
|
|
160
170
|
* @example
|
|
161
171
|
* ```TS
|
|
162
172
|
* const sessions = await client.getSessions(["Pixelic", "14727faefbdc4aff848cd2713eb9939e"]);
|
|
@@ -166,6 +176,8 @@ declare class Client {
|
|
|
166
176
|
/**
|
|
167
177
|
* Returns a Player's Sessions consisting of their Username, UUID, Skin and Cape
|
|
168
178
|
*
|
|
179
|
+
* Default cache TTL: 15 minutes when config.cache is not provided.
|
|
180
|
+
*
|
|
169
181
|
* @example
|
|
170
182
|
* ```TS
|
|
171
183
|
* const session = await client.getSession("Pixelic");
|
|
@@ -175,6 +187,8 @@ declare class Client {
|
|
|
175
187
|
/**
|
|
176
188
|
* A simple Wrapper to retrieve only the Skin from a Player's Session
|
|
177
189
|
*
|
|
190
|
+
* Uses getSession cache behavior (default TTL: 15 minutes when config.cache is not provided).
|
|
191
|
+
*
|
|
178
192
|
* @example
|
|
179
193
|
* ```TS
|
|
180
194
|
* const skin = await client.getSkin("Pixelic");
|
|
@@ -184,6 +198,8 @@ declare class Client {
|
|
|
184
198
|
/**
|
|
185
199
|
* A simple Wrapper to retrieve only the Player's Skin from their Session Data loaded into a Buffer
|
|
186
200
|
*
|
|
201
|
+
* Default cache TTL for the skin image request: 24 hours when config.cache is not provided.
|
|
202
|
+
*
|
|
187
203
|
* @example
|
|
188
204
|
* ```TS
|
|
189
205
|
* const skinBuffer = await client.getSkinBuffer("Pixelic");
|
|
@@ -193,6 +209,8 @@ declare class Client {
|
|
|
193
209
|
/**
|
|
194
210
|
* A simple Wrapper to retrieve only the Cape Data from a Player's Session
|
|
195
211
|
*
|
|
212
|
+
* Uses getSession cache behavior (default TTL: 15 minutes when config.cache is not provided).
|
|
213
|
+
*
|
|
196
214
|
* @example
|
|
197
215
|
* ```TS
|
|
198
216
|
* const cape = await client.getCape("Pixelic");
|
|
@@ -202,6 +220,8 @@ declare class Client {
|
|
|
202
220
|
/**
|
|
203
221
|
* A simple Wrapper to retrieve only the Player's Cape from their Session Data loaded into a Buffer
|
|
204
222
|
*
|
|
223
|
+
* Default cache TTL for the cape image request: 30 days when config.cache is not provided.
|
|
224
|
+
*
|
|
205
225
|
* @example
|
|
206
226
|
* ```TS
|
|
207
227
|
* const capeBuffer = await client.getCapeBuffer("Pixelic");
|
package/dist/index.js
CHANGED
|
@@ -37,7 +37,7 @@ import { setupCache } from "axios-cache-interceptor";
|
|
|
37
37
|
// package.json
|
|
38
38
|
var package_default = {
|
|
39
39
|
name: "mowojang",
|
|
40
|
-
version: "0.5.
|
|
40
|
+
version: "0.5.1",
|
|
41
41
|
description: "A simple TypeScript compatible wrapper for the Mowojang-API.",
|
|
42
42
|
exports: {
|
|
43
43
|
".": {
|
|
@@ -318,6 +318,8 @@ var Client = class {
|
|
|
318
318
|
*
|
|
319
319
|
* Players considered "INVALID" are excluded from the results
|
|
320
320
|
*
|
|
321
|
+
* Default cache TTL: 1 hour when config.cache is not provided.
|
|
322
|
+
*
|
|
321
323
|
* @example
|
|
322
324
|
* ```TS
|
|
323
325
|
* const profiles = await client.getProfiles(["Pixelic", "14727faefbdc4aff848cd2713eb9939e"]);
|
|
@@ -334,7 +336,7 @@ var Client = class {
|
|
|
334
336
|
const usePost = config?.usePost ?? false;
|
|
335
337
|
if (usePost) {
|
|
336
338
|
const fetchResponse = await this.axios.post(this.baseURL, players, {
|
|
337
|
-
cache: config?.cache ?? { ttl:
|
|
339
|
+
cache: config?.cache ?? { ttl: 60 * 60 * 1e3 }
|
|
338
340
|
});
|
|
339
341
|
if (!Array.isArray(fetchResponse?.data)) return { data: null, error: "UNKNOWN_ERROR" };
|
|
340
342
|
return {
|
|
@@ -360,6 +362,8 @@ var Client = class {
|
|
|
360
362
|
/**
|
|
361
363
|
* Returns a Player's Profile consisting of their Username and UUID
|
|
362
364
|
*
|
|
365
|
+
* Default cache TTL: 1 hour when config.cache is not provided.
|
|
366
|
+
*
|
|
363
367
|
* @example
|
|
364
368
|
* ```TS
|
|
365
369
|
* const profile = await client.getProfile("Pixelic");
|
|
@@ -370,7 +374,7 @@ var Client = class {
|
|
|
370
374
|
if (this.shouldValidate(config) && !validatePlayer(player, this.getValidationMinLength(config)))
|
|
371
375
|
return { data: null, error: "INVALID_INPUT" };
|
|
372
376
|
const fetchResponse = await this.axios.get(`${this.baseURL}/${player}`, {
|
|
373
|
-
cache: config?.cache ?? { ttl:
|
|
377
|
+
cache: config?.cache ?? { ttl: 60 * 60 * 1e3 }
|
|
374
378
|
});
|
|
375
379
|
return {
|
|
376
380
|
data: {
|
|
@@ -386,6 +390,8 @@ var Client = class {
|
|
|
386
390
|
/**
|
|
387
391
|
* A simple Wrapper to retrieve only the UUID of a Player's Profile
|
|
388
392
|
*
|
|
393
|
+
* Uses getProfile cache behavior (default TTL: 1 hour when config.cache is not provided).
|
|
394
|
+
*
|
|
389
395
|
* @example
|
|
390
396
|
* ```TS
|
|
391
397
|
* const uuid = await client.getUUID("Pixelic");
|
|
@@ -399,6 +405,8 @@ var Client = class {
|
|
|
399
405
|
/**
|
|
400
406
|
* A simple Wrapper to retrieve only the Username of a Player's Profile
|
|
401
407
|
*
|
|
408
|
+
* Uses getProfile cache behavior (default TTL: 1 hour when config.cache is not provided).
|
|
409
|
+
*
|
|
402
410
|
* @example
|
|
403
411
|
* ```TS
|
|
404
412
|
* const username = await client.getUsername("14727faefbdc4aff848cd2713eb9939e");
|
|
@@ -414,6 +422,8 @@ var Client = class {
|
|
|
414
422
|
*
|
|
415
423
|
* Players considered "INVALID" are excluded from the results
|
|
416
424
|
*
|
|
425
|
+
* Uses getSession cache behavior (default TTL: 15 minutes when config.cache is not provided).
|
|
426
|
+
*
|
|
417
427
|
* @example
|
|
418
428
|
* ```TS
|
|
419
429
|
* const sessions = await client.getSessions(["Pixelic", "14727faefbdc4aff848cd2713eb9939e"]);
|
|
@@ -440,6 +450,8 @@ var Client = class {
|
|
|
440
450
|
/**
|
|
441
451
|
* Returns a Player's Sessions consisting of their Username, UUID, Skin and Cape
|
|
442
452
|
*
|
|
453
|
+
* Default cache TTL: 15 minutes when config.cache is not provided.
|
|
454
|
+
*
|
|
443
455
|
* @example
|
|
444
456
|
* ```TS
|
|
445
457
|
* const session = await client.getSession("Pixelic");
|
|
@@ -494,6 +506,8 @@ var Client = class {
|
|
|
494
506
|
/**
|
|
495
507
|
* A simple Wrapper to retrieve only the Skin from a Player's Session
|
|
496
508
|
*
|
|
509
|
+
* Uses getSession cache behavior (default TTL: 15 minutes when config.cache is not provided).
|
|
510
|
+
*
|
|
497
511
|
* @example
|
|
498
512
|
* ```TS
|
|
499
513
|
* const skin = await client.getSkin("Pixelic");
|
|
@@ -507,6 +521,8 @@ var Client = class {
|
|
|
507
521
|
/**
|
|
508
522
|
* A simple Wrapper to retrieve only the Player's Skin from their Session Data loaded into a Buffer
|
|
509
523
|
*
|
|
524
|
+
* Default cache TTL for the skin image request: 24 hours when config.cache is not provided.
|
|
525
|
+
*
|
|
510
526
|
* @example
|
|
511
527
|
* ```TS
|
|
512
528
|
* const skinBuffer = await client.getSkinBuffer("Pixelic");
|
|
@@ -524,6 +540,8 @@ var Client = class {
|
|
|
524
540
|
/**
|
|
525
541
|
* A simple Wrapper to retrieve only the Cape Data from a Player's Session
|
|
526
542
|
*
|
|
543
|
+
* Uses getSession cache behavior (default TTL: 15 minutes when config.cache is not provided).
|
|
544
|
+
*
|
|
527
545
|
* @example
|
|
528
546
|
* ```TS
|
|
529
547
|
* const cape = await client.getCape("Pixelic");
|
|
@@ -537,6 +555,8 @@ var Client = class {
|
|
|
537
555
|
/**
|
|
538
556
|
* A simple Wrapper to retrieve only the Player's Cape from their Session Data loaded into a Buffer
|
|
539
557
|
*
|
|
558
|
+
* Default cache TTL for the cape image request: 30 days when config.cache is not provided.
|
|
559
|
+
*
|
|
540
560
|
* @example
|
|
541
561
|
* ```TS
|
|
542
562
|
* const capeBuffer = await client.getCapeBuffer("Pixelic");
|