@gzl10/nexus-sdk 0.1.6 → 0.1.8
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 +59 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Knex } from 'knex';
|
|
2
|
-
import { RequestHandler, Router } from 'express';
|
|
2
|
+
import { Request, RequestHandler, Router } from 'express';
|
|
3
3
|
export { CookieOptions, NextFunction, Request, RequestHandler, Response, Router } from 'express';
|
|
4
4
|
import { Logger } from 'pino';
|
|
5
5
|
|
|
@@ -11,6 +11,46 @@ import { Logger } from 'pino';
|
|
|
11
11
|
* depending on the full @gzl10/nexus-backend package.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Request autenticado con usuario y abilities CASL
|
|
16
|
+
* El backend especializa TUser y TAbility con tipos concretos
|
|
17
|
+
*/
|
|
18
|
+
interface AuthRequest<TUser = unknown, TAbility = unknown> extends Request {
|
|
19
|
+
user: TUser;
|
|
20
|
+
ability: TAbility;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Usuario base sin contraseña para uso en plugins
|
|
24
|
+
* Usado para tipar relaciones con usuarios (ej: author, created_by)
|
|
25
|
+
*/
|
|
26
|
+
interface BaseUser {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
email: string;
|
|
30
|
+
role_id: string;
|
|
31
|
+
created_at: Date;
|
|
32
|
+
updated_at: Date;
|
|
33
|
+
created_by: string | null;
|
|
34
|
+
updated_by: string | null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Parámetros de paginación para queries
|
|
38
|
+
*/
|
|
39
|
+
interface PaginationParams {
|
|
40
|
+
page: number;
|
|
41
|
+
limit: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Resultado paginado genérico
|
|
45
|
+
*/
|
|
46
|
+
interface PaginatedResult<T> {
|
|
47
|
+
items: T[];
|
|
48
|
+
total: number;
|
|
49
|
+
page: number;
|
|
50
|
+
limit: number;
|
|
51
|
+
totalPages: number;
|
|
52
|
+
hasNext: boolean;
|
|
53
|
+
}
|
|
14
54
|
/**
|
|
15
55
|
* Tipo de campo para formularios dinámicos
|
|
16
56
|
*/
|
|
@@ -68,6 +108,21 @@ interface ModuleRequirements {
|
|
|
68
108
|
env?: string[];
|
|
69
109
|
modules?: string[];
|
|
70
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Resolver de usuarios para plugins
|
|
113
|
+
* Permite acceder a usuarios sin conocer la implementación interna
|
|
114
|
+
*/
|
|
115
|
+
interface UsersResolver {
|
|
116
|
+
findById: (id: string) => Promise<BaseUser | null>;
|
|
117
|
+
findByIds: (ids: string[]) => Promise<BaseUser[]>;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Servicios core inyectados por el backend
|
|
121
|
+
* Los plugins acceden a estos servicios via ctx.services
|
|
122
|
+
*/
|
|
123
|
+
interface CoreServices {
|
|
124
|
+
users?: UsersResolver;
|
|
125
|
+
}
|
|
71
126
|
/**
|
|
72
127
|
* Helpers para migraciones de base de datos
|
|
73
128
|
*/
|
|
@@ -122,6 +177,8 @@ interface ModuleContext {
|
|
|
122
177
|
data?: Record<string, unknown>;
|
|
123
178
|
}) => Promise<void>;
|
|
124
179
|
};
|
|
180
|
+
/** Servicios de módulos core (users, etc.) */
|
|
181
|
+
services: CoreServices & Record<string, unknown>;
|
|
125
182
|
}
|
|
126
183
|
/**
|
|
127
184
|
* Manifest de un módulo Nexus
|
|
@@ -184,4 +241,4 @@ interface PluginManifest {
|
|
|
184
241
|
modules: ModuleManifest[];
|
|
185
242
|
}
|
|
186
243
|
|
|
187
|
-
export type { FieldValidation, FormField, FormFieldType, ListType, MigrationHelpers, ModuleContext, ModuleEntity, ModuleManifest, ModuleMiddlewares, ModuleRequirements, PluginCategory, PluginManifest };
|
|
244
|
+
export type { AuthRequest, BaseUser, CoreServices, FieldValidation, FormField, FormFieldType, ListType, MigrationHelpers, ModuleContext, ModuleEntity, ModuleManifest, ModuleMiddlewares, ModuleRequirements, PaginatedResult, PaginationParams, PluginCategory, PluginManifest, UsersResolver };
|