mowojang 0.4.3 → 0.4.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.
@@ -1,5 +1,74 @@
1
- import type { Player, Username, UUID, ClientOptions, MowojangCape, MowojangProfile, MowojangRequestConfig, MowojangResponse, MowojangSession, MowojangSkin } from "../types/index.d.ts";
2
- export default class Client {
1
+ import { LoggerConfig } from '@pixelic/logger';
2
+ import { CacheOptions, CacheRequestConfig, buildStorage, buildMemoryStorage } from 'axios-cache-interceptor';
3
+
4
+ /**
5
+ * Minecraft Username or UUIDv4 (both undashed and dashed will be accepted)
6
+ *
7
+ * @example "Technoblade" or "b876ec32-e396-476b-a115-8438d83c67d4"
8
+ */
9
+ type Player = string | UUID;
10
+ /**
11
+ * Minecraft Username
12
+ *
13
+ * @example "Pixelic"
14
+ */
15
+ type Username = string;
16
+ /**
17
+ * Minecraft UUIDv4 (both undashed and dashed will be accepted)
18
+ *
19
+ * @example b876ec32e396476ba1158438d83c67d4
20
+ */
21
+ type UUID = string;
22
+
23
+ type ClientOptions = {
24
+ logger?: LoggerConfig;
25
+ validation?: ValidationOptions;
26
+ timeout?: number;
27
+ cache?: CacheOptions;
28
+ baseURL?: string;
29
+ fallback?: boolean;
30
+ };
31
+ type ValidationOptions = {
32
+ enabled?: boolean;
33
+ minimumUsernameLength?: 1 | 2;
34
+ };
35
+ type MowojangRequestConfig = {
36
+ validation?: ValidationOptions;
37
+ cache?: CacheRequestConfig<any, any>["cache"];
38
+ };
39
+ type MowojangError = "INVALID_PLAYER";
40
+ type MowojangResponse<D, E extends MowojangError | undefined> = Promise<{
41
+ data: D;
42
+ error: null;
43
+ } | {
44
+ data: null;
45
+ error: E extends undefined ? "UNKNOWN_ERROR" | "INVALID_INPUT" : E | "UNKNOWN_ERROR" | "INVALID_INPUT";
46
+ }>;
47
+
48
+ type MowojangProfile = {
49
+ UUID: UUID;
50
+ username: Username;
51
+ };
52
+ type MowojangSession = {
53
+ UUID: UUID;
54
+ username: Username;
55
+ skin: MowojangSkin;
56
+ cape: MowojangCape;
57
+ actions: ("FORCED_NAME_CHANGE" | "USING_BANNED_SKIN")[];
58
+ };
59
+ type MowojangSkin = null | {
60
+ url: string;
61
+ hash: string;
62
+ metadata: {
63
+ slim: boolean;
64
+ };
65
+ };
66
+ type MowojangCape = null | {
67
+ url: string;
68
+ hash: string;
69
+ };
70
+
71
+ declare class Client {
3
72
  private logger;
4
73
  private axios;
5
74
  private validation;
@@ -62,3 +131,19 @@ export default class Client {
62
131
  */
63
132
  getCapeBuffer(player: Player, config?: MowojangRequestConfig): Promise<null | Buffer>;
64
133
  }
134
+
135
+ declare const validate: {
136
+ player: (player: Player, minimumUsernameLength?: 1 | 2) => boolean;
137
+ UUID: (UUID: UUID) => boolean;
138
+ username: (username: string, minimumLength?: 1 | 2) => boolean;
139
+ };
140
+ declare const utils: {
141
+ dashUUID: (UUID: UUID) => UUID;
142
+ undashUUID: (UUID: UUID) => UUID;
143
+ };
144
+ declare const cache: {
145
+ buildStorage: typeof buildStorage;
146
+ buildMemoryStorage: typeof buildMemoryStorage;
147
+ };
148
+
149
+ export { Client, cache, utils, validate };