@gzl10/nexus-sdk 0.1.8 → 0.1.9
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 +43 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -108,6 +108,43 @@ interface ModuleRequirements {
|
|
|
108
108
|
env?: string[];
|
|
109
109
|
modules?: string[];
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Interfaz genérica para ability CASL
|
|
113
|
+
* Permite verificar permisos sin depender directamente de @casl/ability
|
|
114
|
+
*/
|
|
115
|
+
interface AbilityLike {
|
|
116
|
+
can: (action: string, subject: unknown) => boolean;
|
|
117
|
+
cannot: (action: string, subject: unknown) => boolean;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Error de forbidden con método throwUnlessCan
|
|
121
|
+
*/
|
|
122
|
+
interface ForbiddenErrorInstance {
|
|
123
|
+
throwUnlessCan: (action: string, subject: unknown) => void;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Constructor de ForbiddenError con método from()
|
|
127
|
+
*/
|
|
128
|
+
interface ForbiddenErrorConstructor {
|
|
129
|
+
from: (ability: AbilityLike) => ForbiddenErrorInstance;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Abilities CASL disponibles en el contexto
|
|
133
|
+
* Permite usar CASL en plugins sin importar @casl/ability directamente
|
|
134
|
+
*/
|
|
135
|
+
interface ModuleAbilities {
|
|
136
|
+
/** Wrapper para verificar permisos contra instancias */
|
|
137
|
+
subject: (type: string, object: unknown) => unknown;
|
|
138
|
+
/** Error de CASL para throwUnlessCan */
|
|
139
|
+
ForbiddenError: ForbiddenErrorConstructor;
|
|
140
|
+
/** Otros métodos que el backend pueda añadir */
|
|
141
|
+
[key: string]: unknown;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* AuthRequest pre-tipado para uso en plugins
|
|
145
|
+
* Usa BaseUser y AbilityLike para tipado básico sin depender del backend
|
|
146
|
+
*/
|
|
147
|
+
type PluginAuthRequest = AuthRequest<BaseUser, AbilityLike>;
|
|
111
148
|
/**
|
|
112
149
|
* Resolver de usuarios para plugins
|
|
113
150
|
* Permite acceder a usuarios sin conocer la implementación interna
|
|
@@ -157,12 +194,12 @@ interface ModuleContext {
|
|
|
157
194
|
config: Record<string, unknown>;
|
|
158
195
|
errors: {
|
|
159
196
|
AppError: new (message: string, statusCode?: number) => Error;
|
|
160
|
-
NotFoundError: new (message
|
|
161
|
-
UnauthorizedError: new (message
|
|
162
|
-
ForbiddenError: new (message
|
|
163
|
-
ConflictError: new (message
|
|
197
|
+
NotFoundError: new (message?: string) => Error;
|
|
198
|
+
UnauthorizedError: new (message?: string) => Error;
|
|
199
|
+
ForbiddenError: new (message?: string) => Error;
|
|
200
|
+
ConflictError: new (message?: string) => Error;
|
|
164
201
|
};
|
|
165
|
-
abilities:
|
|
202
|
+
abilities: ModuleAbilities;
|
|
166
203
|
events: {
|
|
167
204
|
emit: (event: string, ...args: unknown[]) => boolean;
|
|
168
205
|
on: (event: string, listener: (...args: unknown[]) => void) => unknown;
|
|
@@ -241,4 +278,4 @@ interface PluginManifest {
|
|
|
241
278
|
modules: ModuleManifest[];
|
|
242
279
|
}
|
|
243
280
|
|
|
244
|
-
export type { AuthRequest, BaseUser, CoreServices, FieldValidation, FormField, FormFieldType, ListType, MigrationHelpers, ModuleContext, ModuleEntity, ModuleManifest, ModuleMiddlewares, ModuleRequirements, PaginatedResult, PaginationParams, PluginCategory, PluginManifest, UsersResolver };
|
|
281
|
+
export type { AbilityLike, AuthRequest, BaseUser, CoreServices, FieldValidation, ForbiddenErrorConstructor, ForbiddenErrorInstance, FormField, FormFieldType, ListType, MigrationHelpers, ModuleAbilities, ModuleContext, ModuleEntity, ModuleManifest, ModuleMiddlewares, ModuleRequirements, PaginatedResult, PaginationParams, PluginAuthRequest, PluginCategory, PluginManifest, UsersResolver };
|