neekuro 2.2.0 → 2.3.0
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/CHANGELOG.md +31 -14
- package/README.md +117 -117
- package/package.json +64 -64
- package/sources/classes/SFW.js +25 -4
- package/sources/classes/errors/APIError.js +49 -49
- package/sources/classes/errors/Error.js +21 -21
- package/sources/classes/package/NekoGif.js +46 -46
- package/sources/classes/package/welcome.js +446 -446
- package/sources/classes/user/BaseUser.js +20 -20
- package/sources/classes/user/User.js +34 -34
- package/sources/main/index.js +20 -20
- package/sources/rest/APIClient.js +34 -34
- package/sources/typings/index.d.ts +374 -355
- package/sources/utils/imageLoader.js +38 -26
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
//#region constants
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Categoria SFW
|
|
5
|
-
* aqui encontraras categorias no nsfw como accion y reaccion
|
|
6
|
-
* @example
|
|
7
|
-
* // obtiene el objeto SFW
|
|
8
|
-
* const SFW = require('neekuro').SFW
|
|
9
|
-
*/
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Categoria SFW
|
|
5
|
+
* aqui encontraras categorias no nsfw como accion y reaccion
|
|
6
|
+
* @example
|
|
7
|
+
* // obtiene el objeto SFW
|
|
8
|
+
* const SFW = require('neekuro').SFW
|
|
9
|
+
*/
|
|
10
10
|
export const SFW: {
|
|
11
|
-
/**
|
|
12
|
-
* Funcion principal para obtener gifs de cierta categoria
|
|
13
|
-
* @param category category: corresponde a la subcategoria de SFW
|
|
14
|
-
* @param gif gif: corresponde al gif que quieras obtener por categoria
|
|
15
|
-
* @example
|
|
16
|
-
* const { SFW } = require('neekuro')
|
|
17
|
-
*
|
|
18
|
-
* // se obtiene el objeto (es necesario que esto sea dentro de una funcion asincrona)
|
|
19
|
-
* let cuddle = await SFW.getGif('action', 'cuddle')
|
|
20
|
-
*
|
|
21
|
-
* // obtener url
|
|
22
|
-
* cuddle.getUrl();
|
|
23
|
-
* // obtener anime
|
|
24
|
-
* cuddle.getAnime();
|
|
25
|
-
*/
|
|
11
|
+
/**
|
|
12
|
+
* Funcion principal para obtener gifs de cierta categoria
|
|
13
|
+
* @param category category: corresponde a la subcategoria de SFW
|
|
14
|
+
* @param gif gif: corresponde al gif que quieras obtener por categoria
|
|
15
|
+
* @example
|
|
16
|
+
* const { SFW } = require('neekuro')
|
|
17
|
+
*
|
|
18
|
+
* // se obtiene el objeto (es necesario que esto sea dentro de una funcion asincrona)
|
|
19
|
+
* let cuddle = await SFW.getGif('action', 'cuddle')
|
|
20
|
+
*
|
|
21
|
+
* // obtener url
|
|
22
|
+
* cuddle.getUrl();
|
|
23
|
+
* // obtener anime
|
|
24
|
+
* cuddle.getAnime();
|
|
25
|
+
*/
|
|
26
26
|
getGif<T extends SfwCategories>(category: T, gif: GifMap[T]): Promise<NekoGif>
|
|
27
27
|
/** Obtiene todos los GIF disponibles y utiliza la caché interna. */
|
|
28
28
|
getGifs<T extends SfwCategories>(category: T, gif: GifMap[T]): Promise<NekoGif[]>
|
|
@@ -35,117 +35,128 @@ export const SFW: {
|
|
|
35
35
|
/** Configura el TTL en milisegundos. El valor cero desactiva la caché. */
|
|
36
36
|
setCacheTTL(milliseconds: number): void
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
//#endregion
|
|
40
|
-
|
|
41
|
-
//#region types
|
|
42
|
-
|
|
43
|
-
export type ActionGifs =
|
|
44
|
-
'cook' |
|
|
45
|
-
'cuddle' |
|
|
46
|
-
'cure' |
|
|
47
|
-
'draw' |
|
|
48
|
-
'drive' |
|
|
49
|
-
'eat' |
|
|
50
|
-
'explosion' |
|
|
51
|
-
'feed' |
|
|
52
|
-
'
|
|
53
|
-
'
|
|
54
|
-
'
|
|
55
|
-
'
|
|
56
|
-
'
|
|
57
|
-
'
|
|
58
|
-
'
|
|
59
|
-
'
|
|
60
|
-
'
|
|
61
|
-
'
|
|
62
|
-
'
|
|
63
|
-
'
|
|
64
|
-
'
|
|
65
|
-
'
|
|
66
|
-
'
|
|
67
|
-
'
|
|
68
|
-
'
|
|
69
|
-
'
|
|
70
|
-
'
|
|
71
|
-
'
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
'
|
|
75
|
-
'
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
'
|
|
79
|
-
'
|
|
80
|
-
'
|
|
81
|
-
'
|
|
82
|
-
'
|
|
83
|
-
'
|
|
84
|
-
'
|
|
85
|
-
'
|
|
86
|
-
'
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
export
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
|
|
41
|
+
//#region types
|
|
42
|
+
|
|
43
|
+
export type ActionGifs =
|
|
44
|
+
'cook' |
|
|
45
|
+
'cuddle' |
|
|
46
|
+
'cure' |
|
|
47
|
+
'draw' |
|
|
48
|
+
'drive' |
|
|
49
|
+
'eat' |
|
|
50
|
+
'explosion' |
|
|
51
|
+
'feed' |
|
|
52
|
+
'handhold' |
|
|
53
|
+
'highfive' |
|
|
54
|
+
'hug' |
|
|
55
|
+
'kickbut' |
|
|
56
|
+
'kill' |
|
|
57
|
+
'kiss' |
|
|
58
|
+
'lick' |
|
|
59
|
+
'pat' |
|
|
60
|
+
'peek' |
|
|
61
|
+
'playing' |
|
|
62
|
+
'poke' |
|
|
63
|
+
'punch' |
|
|
64
|
+
'read' |
|
|
65
|
+
'run' |
|
|
66
|
+
'sape' |
|
|
67
|
+
'shoot' |
|
|
68
|
+
'sip' |
|
|
69
|
+
'slap' |
|
|
70
|
+
'sleep' |
|
|
71
|
+
'stare' |
|
|
72
|
+
'tickle' |
|
|
73
|
+
'travel' |
|
|
74
|
+
'wave' |
|
|
75
|
+
'work';
|
|
76
|
+
|
|
77
|
+
export type ReactionGifs = 'angry' |
|
|
78
|
+
'blush' |
|
|
79
|
+
'bored' |
|
|
80
|
+
'confused' |
|
|
81
|
+
'cry' |
|
|
82
|
+
'dance' |
|
|
83
|
+
'disgust' |
|
|
84
|
+
'facepalm' |
|
|
85
|
+
'happy' |
|
|
86
|
+
'laugh' |
|
|
87
|
+
'like' |
|
|
88
|
+
'love' |
|
|
89
|
+
'nervous' |
|
|
90
|
+
'pout' |
|
|
91
|
+
'scream' |
|
|
92
|
+
'shrug' |
|
|
93
|
+
'smug' |
|
|
94
|
+
'surprised' |
|
|
95
|
+
'think' |
|
|
96
|
+
'vomit' |
|
|
97
|
+
'wink';
|
|
98
|
+
|
|
99
|
+
export type SfwCategories = 'action' | 'reaction';
|
|
100
|
+
|
|
101
|
+
export type FontNames = 'arial' | 'calibri' | 'custom';
|
|
102
|
+
|
|
103
|
+
//#endregion
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
//#region inferfaces
|
|
107
|
+
|
|
108
|
+
export interface APIClientData {
|
|
109
|
+
token: string
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface WelcomeBackgroundData {
|
|
113
|
+
type: 'color' | 'image'
|
|
114
|
+
value: string | Buffer
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface WelcomeAvatarData {
|
|
118
|
+
x?: number
|
|
119
|
+
y?: number
|
|
120
|
+
border?: string
|
|
121
|
+
radio?: number
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface WelcomeTextData {
|
|
125
|
+
x?: number
|
|
126
|
+
y?: number
|
|
127
|
+
font_size?: number
|
|
128
|
+
text_color?: string
|
|
129
|
+
}
|
|
130
|
+
|
|
120
131
|
export interface WelcomeData {
|
|
121
132
|
font: FontNames;
|
|
122
133
|
layout: 'center' | 'manual';
|
|
123
|
-
width: number;
|
|
124
|
-
height: number;
|
|
125
|
-
background: WelcomeBackgroundData;
|
|
126
|
-
avatar: {
|
|
127
|
-
source: string | Buffer | null;
|
|
128
|
-
x: number;
|
|
129
|
-
y: number;
|
|
130
|
-
radio: number;
|
|
131
|
-
border: string;
|
|
132
|
-
};
|
|
133
|
-
title: {
|
|
134
|
-
content: string | null;
|
|
135
|
-
x: number;
|
|
136
|
-
y: number;
|
|
137
|
-
font_size: number;
|
|
138
|
-
text_color: string;
|
|
139
|
-
};
|
|
140
|
-
description: {
|
|
141
|
-
content: string | null;
|
|
142
|
-
x: number;
|
|
143
|
-
y: number;
|
|
144
|
-
font_size: number;
|
|
145
|
-
text_color: string;
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
|
|
134
|
+
width: number;
|
|
135
|
+
height: number;
|
|
136
|
+
background: WelcomeBackgroundData;
|
|
137
|
+
avatar: {
|
|
138
|
+
source: string | Buffer | null;
|
|
139
|
+
x: number;
|
|
140
|
+
y: number;
|
|
141
|
+
radio: number;
|
|
142
|
+
border: string;
|
|
143
|
+
};
|
|
144
|
+
title: {
|
|
145
|
+
content: string | null;
|
|
146
|
+
x: number;
|
|
147
|
+
y: number;
|
|
148
|
+
font_size: number;
|
|
149
|
+
text_color: string;
|
|
150
|
+
};
|
|
151
|
+
description: {
|
|
152
|
+
content: string | null;
|
|
153
|
+
x: number;
|
|
154
|
+
y: number;
|
|
155
|
+
font_size: number;
|
|
156
|
+
text_color: string;
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
149
160
|
export interface NekoGifInterface {
|
|
150
161
|
url: string | null
|
|
151
162
|
anime?: string | null
|
|
@@ -155,12 +166,12 @@ export interface GifData {
|
|
|
155
166
|
url: string
|
|
156
167
|
anime: string
|
|
157
168
|
}
|
|
158
|
-
|
|
159
|
-
export declare interface GifMap {
|
|
160
|
-
action: ActionGifs
|
|
161
|
-
reaction: ReactionGifs
|
|
162
|
-
}
|
|
163
|
-
|
|
169
|
+
|
|
170
|
+
export declare interface GifMap {
|
|
171
|
+
action: ActionGifs
|
|
172
|
+
reaction: ReactionGifs
|
|
173
|
+
}
|
|
174
|
+
|
|
164
175
|
export interface GifResponse extends ApiResponse {
|
|
165
176
|
data: GifData
|
|
166
177
|
}
|
|
@@ -168,241 +179,249 @@ export interface GifResponse extends ApiResponse {
|
|
|
168
179
|
export interface GifListResponse extends ApiResponse {
|
|
169
180
|
data: GifData[]
|
|
170
181
|
}
|
|
171
|
-
|
|
172
|
-
export interface ApiResponse {
|
|
173
|
-
message?: string,
|
|
174
|
-
code: number
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
//#endregion
|
|
178
|
-
|
|
179
|
-
//#region Classes
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Clase Welcome
|
|
183
|
-
* Genera una imagen de bienvenida para discord
|
|
184
|
-
* @example
|
|
185
|
-
* const welcome = new neekuro.Welcome()
|
|
186
|
-
* .setResolution(1200, 600)
|
|
187
|
-
* .setFont('arial')
|
|
188
|
-
* .setTitle('¡Bienvenido!', { text_color: '#FF5733' })
|
|
189
|
-
* .setDescription('Al servidor de la comunidad', { font_size: 24 });
|
|
190
|
-
*/
|
|
191
|
-
export class Welcome {
|
|
192
|
-
private data: WelcomeData;
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Construye una nueva instancia de Welcome con configuración predeterminada
|
|
196
|
-
*/
|
|
197
|
-
constructor();
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Establece la resolución de la imagen de bienvenida
|
|
201
|
-
* @param width Ancho en píxeles o 'default' para
|
|
202
|
-
* @param height Alto en píxeles o 'default' para
|
|
203
|
-
* @throws {NekoError} Si los parámetros son inválidos
|
|
204
|
-
*/
|
|
182
|
+
|
|
183
|
+
export interface ApiResponse {
|
|
184
|
+
message?: string,
|
|
185
|
+
code: number
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
//#endregion
|
|
189
|
+
|
|
190
|
+
//#region Classes
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Clase Welcome
|
|
194
|
+
* Genera una imagen de bienvenida para discord
|
|
195
|
+
* @example
|
|
196
|
+
* const welcome = new neekuro.Welcome()
|
|
197
|
+
* .setResolution(1200, 600)
|
|
198
|
+
* .setFont('arial')
|
|
199
|
+
* .setTitle('¡Bienvenido!', { text_color: '#FF5733' })
|
|
200
|
+
* .setDescription('Al servidor de la comunidad', { font_size: 24 });
|
|
201
|
+
*/
|
|
202
|
+
export class Welcome {
|
|
203
|
+
private data: WelcomeData;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Construye una nueva instancia de Welcome con configuración predeterminada
|
|
207
|
+
*/
|
|
208
|
+
constructor();
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Establece la resolución de la imagen de bienvenida
|
|
212
|
+
* @param width Ancho en píxeles o 'default' para 1140px
|
|
213
|
+
* @param height Alto en píxeles o 'default' para 520px
|
|
214
|
+
* @throws {NekoError} Si los parámetros son inválidos
|
|
215
|
+
*/
|
|
205
216
|
setResolution(width: number | 'default', height: number | 'default'): this;
|
|
206
217
|
|
|
207
218
|
/** Selecciona distribución automática centrada o coordenadas manuales. */
|
|
208
219
|
setLayout(layout: 'center' | 'manual'): this;
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Configura la tipografía para el texto de la imagen
|
|
212
|
-
* @param name Nombre de la fuente predefinida o 'custom' para personalizada
|
|
213
|
-
* @param dir Ruta al archivo .ttf (requerido si name='custom')
|
|
214
|
-
* @throws {NekoError} Si la fuente no existe o los parámetros son inválidos
|
|
215
|
-
*/
|
|
216
|
-
setFont(name: FontNames, dir?: string): this;
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Agrega un título a la imagen de bienvenida
|
|
220
|
-
* @param text Texto del título
|
|
221
|
-
* @param data Configuración opcional del título
|
|
222
|
-
* @throws {NekoError} Si los parámetros son inválidos
|
|
223
|
-
*/
|
|
224
|
-
setTitle(text: string, data?: WelcomeTextData): this;
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Agrega una descripción a la imagen de bienvenida
|
|
228
|
-
* @param text Texto de la descripción
|
|
229
|
-
* @param data Configuración opcional de la descripción
|
|
230
|
-
* @throws {NekoError} Si los parámetros son inválidos
|
|
231
|
-
*/
|
|
232
|
-
setDescription(text: string, data?: WelcomeTextData): this;
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Establece el fondo de la imagen (color o imagen)
|
|
236
|
-
* @param type Tipo de fondo ('color' o 'image')
|
|
237
|
-
* @param value Color hexadecimal o imagen (URL/Buffer)
|
|
238
|
-
* @throws {NekoError} Si los parámetros son inválidos
|
|
239
|
-
*/
|
|
240
|
-
setBackground(type: 'color' | 'image', value: string | Buffer): this;
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Establece el avatar y su configuración
|
|
244
|
-
* @param source URL o Buffer de la imagen (formatos soportados: JPEG, PNG, GIF)
|
|
245
|
-
* @param data Configuración opcional del avatar
|
|
246
|
-
* @throws {NekoError} Si los parámetros son inválidos o el formato no es soportado
|
|
247
|
-
*/
|
|
248
|
-
setAvatar(source: string | Buffer, data?: WelcomeAvatarData): this;
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Genera la imagen de bienvenida con la configuración actual
|
|
252
|
-
* @returns Buffer de la imagen generada
|
|
253
|
-
* @throws {NekoError} Si faltan datos requeridos
|
|
254
|
-
* @throws {Error} Si hay problemas al cargar imágenes
|
|
255
|
-
*/
|
|
256
|
-
build(): Promise<Buffer>;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Clase Usuario
|
|
261
|
-
* Instancia al usuario que va a usar la api
|
|
262
|
-
* @example
|
|
263
|
-
* let { User } = require('neekuro')
|
|
264
|
-
* let user = new User('token')
|
|
265
|
-
*/
|
|
266
|
-
export class User {
|
|
267
|
-
private
|
|
268
|
-
private
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* puedes establecer el token a partir de aqui, pero recomiendo usar el metodo dedicado
|
|
272
|
-
* @param token Token de la api
|
|
273
|
-
*/
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Configura la tipografía para el texto de la imagen
|
|
223
|
+
* @param name Nombre de la fuente predefinida o 'custom' para personalizada
|
|
224
|
+
* @param dir Ruta al archivo .ttf (requerido si name='custom')
|
|
225
|
+
* @throws {NekoError} Si la fuente no existe o los parámetros son inválidos
|
|
226
|
+
*/
|
|
227
|
+
setFont(name: FontNames, dir?: string): this;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Agrega un título a la imagen de bienvenida
|
|
231
|
+
* @param text Texto del título
|
|
232
|
+
* @param data Configuración opcional del título
|
|
233
|
+
* @throws {NekoError} Si los parámetros son inválidos
|
|
234
|
+
*/
|
|
235
|
+
setTitle(text: string, data?: WelcomeTextData): this;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Agrega una descripción a la imagen de bienvenida
|
|
239
|
+
* @param text Texto de la descripción
|
|
240
|
+
* @param data Configuración opcional de la descripción
|
|
241
|
+
* @throws {NekoError} Si los parámetros son inválidos
|
|
242
|
+
*/
|
|
243
|
+
setDescription(text: string, data?: WelcomeTextData): this;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Establece el fondo de la imagen (color o imagen)
|
|
247
|
+
* @param type Tipo de fondo ('color' o 'image')
|
|
248
|
+
* @param value Color hexadecimal o imagen (URL/Buffer)
|
|
249
|
+
* @throws {NekoError} Si los parámetros son inválidos
|
|
250
|
+
*/
|
|
251
|
+
setBackground(type: 'color' | 'image', value: string | Buffer): this;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Establece el avatar y su configuración
|
|
255
|
+
* @param source URL o Buffer de la imagen (formatos soportados: JPEG, PNG, GIF)
|
|
256
|
+
* @param data Configuración opcional del avatar
|
|
257
|
+
* @throws {NekoError} Si los parámetros son inválidos o el formato no es soportado
|
|
258
|
+
*/
|
|
259
|
+
setAvatar(source: string | Buffer, data?: WelcomeAvatarData): this;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Genera la imagen de bienvenida con la configuración actual
|
|
263
|
+
* @returns Buffer de la imagen generada
|
|
264
|
+
* @throws {NekoError} Si faltan datos requeridos
|
|
265
|
+
* @throws {Error} Si hay problemas al cargar imágenes
|
|
266
|
+
*/
|
|
267
|
+
build(): Promise<Buffer>;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Clase Usuario
|
|
272
|
+
* Instancia al usuario que va a usar la api
|
|
273
|
+
* @example
|
|
274
|
+
* let { User } = require('neekuro')
|
|
275
|
+
* let user = new User('token')
|
|
276
|
+
*/
|
|
277
|
+
export class User {
|
|
278
|
+
#private;
|
|
279
|
+
private token_: string | undefined;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* puedes establecer el token a partir de aqui, pero recomiendo usar el metodo dedicado
|
|
283
|
+
* @param token Token de la api
|
|
284
|
+
*/
|
|
274
285
|
constructor(token?: string);
|
|
275
|
-
/**
|
|
276
|
-
* establece el token para usar la api
|
|
277
|
-
* @example
|
|
278
|
-
* // no tan recomendada (token expuesto)
|
|
279
|
-
* user.
|
|
280
|
-
* // recomendada (token
|
|
281
|
-
* user.
|
|
282
|
-
*/
|
|
283
|
-
public token(token: string): void;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Clase NekoGif
|
|
288
|
-
* Crea un objeto Gif a partir de la respuesta del servidor
|
|
289
|
-
*/
|
|
290
|
-
export class NekoGif {
|
|
291
|
-
private url: string | null;
|
|
292
|
-
private anime: string | null;
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* Recepcion de la respuesta del servidor.
|
|
296
|
-
* @param response respuesta del servidor
|
|
297
|
-
*/
|
|
298
|
-
constructor(response: GifResponse);
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* Obten la url del gif
|
|
302
|
-
* @returns {string | null} string: URL
|
|
303
|
-
*/
|
|
304
|
-
public getUrl(): string | null;
|
|
305
|
-
/**
|
|
306
|
-
* Obten el anime del gif
|
|
307
|
-
* @returns {string | null} string: Anime
|
|
308
|
-
*/
|
|
309
|
-
public getAnime(): string | null;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Clase BaseUser
|
|
314
|
-
* Unicamente es para el manejo del token a traves de todo el paquete
|
|
315
|
-
*/
|
|
316
|
-
export class BaseUser {
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Obten el token del usuario si este ya se estableció
|
|
320
|
-
* @returns {string} Token de usuario
|
|
321
|
-
*/
|
|
286
|
+
/**
|
|
287
|
+
* establece el token para usar la api
|
|
288
|
+
* @example
|
|
289
|
+
* // no tan recomendada (token expuesto)
|
|
290
|
+
* user.token('mf3a***');
|
|
291
|
+
* // recomendada (token fuera del código fuente)
|
|
292
|
+
* user.token(process.env['NeeKuroToken']);
|
|
293
|
+
*/
|
|
294
|
+
public token(token: string): void;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Clase NekoGif
|
|
299
|
+
* Crea un objeto Gif a partir de la respuesta del servidor
|
|
300
|
+
*/
|
|
301
|
+
export class NekoGif {
|
|
302
|
+
private url: string | null;
|
|
303
|
+
private anime: string | null;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Recepcion de la respuesta del servidor.
|
|
307
|
+
* @param response respuesta del servidor
|
|
308
|
+
*/
|
|
309
|
+
constructor(response: GifResponse);
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Obten la url del gif
|
|
313
|
+
* @returns {string | null} string: URL
|
|
314
|
+
*/
|
|
315
|
+
public getUrl(): string | null;
|
|
316
|
+
/**
|
|
317
|
+
* Obten el anime del gif
|
|
318
|
+
* @returns {string | null} string: Anime
|
|
319
|
+
*/
|
|
320
|
+
public getAnime(): string | null;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Clase BaseUser
|
|
325
|
+
* Unicamente es para el manejo del token a traves de todo el paquete
|
|
326
|
+
*/
|
|
327
|
+
export class BaseUser {
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Obten el token del usuario si este ya se estableció
|
|
331
|
+
* @returns {string} Token de usuario
|
|
332
|
+
*/
|
|
322
333
|
public static getToken(): string | null
|
|
323
334
|
|
|
324
335
|
/** Versión interna que cambia cuando se establece un token diferente. */
|
|
325
336
|
public static getTokenVersion(): number
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Establece el token "global" para todo el paquete
|
|
329
|
-
* @param token token: token a establecer
|
|
330
|
-
*/
|
|
331
|
-
public static setToken(token: string): void
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* Clase APIClient
|
|
336
|
-
* Se encarga de hacer las solicitudes al servidor
|
|
337
|
-
*/
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Establece el token "global" para todo el paquete
|
|
340
|
+
* @param token token: token a establecer
|
|
341
|
+
*/
|
|
342
|
+
public static setToken(token: string): void
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Clase APIClient
|
|
347
|
+
* Se encarga de hacer las solicitudes al servidor
|
|
348
|
+
*/
|
|
338
349
|
export class APIClient {
|
|
339
|
-
/**
|
|
340
|
-
* Instanciamiento de la clase
|
|
341
|
-
* @param baseUrl baseUrl: link principal de la api
|
|
342
|
-
* @param data data: objeto para las solicitudes (unicamente requiere el token dentro)
|
|
343
|
-
* @example
|
|
344
|
-
* new APIClient('/ruta', { token: '***' });
|
|
345
|
-
*/
|
|
346
|
-
constructor(baseUrl: string, data: APIClientData);
|
|
347
|
-
/**
|
|
348
|
-
* Obtiene el objeto compartido por la api rest a traves de la ruta y con autorizacion por token
|
|
349
|
-
* @param endpoint establece la ruta a la que se quiere comunicar en la api
|
|
350
|
-
* @throws {APIError} solo si sucede un error entre solicitudes
|
|
351
|
-
*/
|
|
350
|
+
/**
|
|
351
|
+
* Instanciamiento de la clase
|
|
352
|
+
* @param baseUrl baseUrl: link principal de la api
|
|
353
|
+
* @param data data: objeto para las solicitudes (unicamente requiere el token dentro)
|
|
354
|
+
* @example
|
|
355
|
+
* new APIClient('/ruta', { token: '***' });
|
|
356
|
+
*/
|
|
357
|
+
constructor(baseUrl: string, data: APIClientData);
|
|
358
|
+
/**
|
|
359
|
+
* Obtiene el objeto compartido por la api rest a traves de la ruta y con autorizacion por token
|
|
360
|
+
* @param endpoint establece la ruta a la que se quiere comunicar en la api
|
|
361
|
+
* @throws {APIError} solo si sucede un error entre solicitudes
|
|
362
|
+
*/
|
|
352
363
|
public get<T extends ApiResponse = GifResponse>(endpoint: string, options?: { timeout?: number }): Promise<T>
|
|
353
364
|
}
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* Clase APIError
|
|
357
|
-
* Errores personalizados respecto a la api rest
|
|
358
|
-
*/
|
|
359
|
-
export class APIError extends Error {
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* url a la que se realizo la solicitud
|
|
363
|
-
*/
|
|
364
|
-
url: string;
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* codigo HTTP de la api
|
|
368
|
-
*/
|
|
369
|
-
statusCode: number;
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* respuesta de la api
|
|
373
|
-
*/
|
|
374
|
-
data: ApiResponse;
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* Determina el mensaje del error basado en el codigo
|
|
378
|
-
* @param response respuesta de la api
|
|
379
|
-
* @returns Mensaje de error
|
|
380
|
-
*/
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
*
|
|
385
|
-
* @param endpoint
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Clase APIError
|
|
368
|
+
* Errores personalizados respecto a la api rest
|
|
369
|
+
*/
|
|
370
|
+
export class APIError extends Error {
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* url a la que se realizo la solicitud
|
|
374
|
+
*/
|
|
375
|
+
url: string;
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* codigo HTTP de la api
|
|
379
|
+
*/
|
|
380
|
+
statusCode: number;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* respuesta de la api
|
|
384
|
+
*/
|
|
385
|
+
data: ApiResponse;
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Determina el mensaje del error basado en el codigo
|
|
389
|
+
* @param response respuesta de la api
|
|
390
|
+
* @returns Mensaje de error
|
|
391
|
+
*/
|
|
392
|
+
static determineMessage(response?: ApiResponse): string;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Crea un error para fallos de red o timeout (código 503)
|
|
396
|
+
* @param endpoint ruta solicitada
|
|
397
|
+
* @param url URL completa de la solicitud
|
|
398
|
+
* @param message descripción del fallo
|
|
399
|
+
*/
|
|
400
|
+
static fromNetworkError(endpoint: string, url: string, message: string): APIError;
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Instanciamiento de un error de api
|
|
404
|
+
* @param endpoint endpoint: ruta solicitada
|
|
386
405
|
* @param response respuesta HTTP o representación de un error de red
|
|
387
|
-
* @param data data: objeto dado por la api
|
|
388
|
-
*/
|
|
406
|
+
* @param data data: objeto dado por la api
|
|
407
|
+
*/
|
|
389
408
|
constructor(endpoint: string, response: { url?: string; status?: number }, data: ApiResponse);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* Clase NekoError
|
|
394
|
-
* Errores personalizados respecto al paquete
|
|
395
|
-
*/
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Clase NekoError
|
|
413
|
+
* Errores personalizados respecto al paquete
|
|
414
|
+
*/
|
|
396
415
|
export class NekoError extends Error {
|
|
397
|
-
/**
|
|
398
|
-
* Instanciamiento de un error del paquete
|
|
399
|
-
* @param name name: nombre del error
|
|
400
|
-
* @param message message: mensaje del error
|
|
401
|
-
*/
|
|
402
|
-
constructor(name: string, message: string);
|
|
416
|
+
/**
|
|
417
|
+
* Instanciamiento de un error del paquete
|
|
418
|
+
* @param name name: nombre del error
|
|
419
|
+
* @param message message: mensaje del error
|
|
420
|
+
*/
|
|
421
|
+
constructor(name: string, message: string);
|
|
403
422
|
}
|
|
404
423
|
|
|
405
424
|
/** Alias heredado de versiones 2.0.x. Prefiere NekoError. */
|
|
406
425
|
export { NekoError as Error };
|
|
407
|
-
|
|
426
|
+
|
|
408
427
|
//#endregion
|