@gzl10/nexus-sdk 0.7.0 → 0.8.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/dist/cli/index.js CHANGED
@@ -150,6 +150,6 @@ New file: ${path}`));
150
150
  }
151
151
 
152
152
  // src/cli/index.ts
153
- var program = new Command2().name("nexus-sdk").description("Nexus SDK CLI - Code generation from EntityDefinitions").version("0.7.0");
153
+ var program = new Command2().name("nexus-sdk").description("Nexus SDK CLI - Code generation from EntityDefinitions").version("0.8.0");
154
154
  program.addCommand(createGenerateCommand());
155
155
  program.parse();
package/dist/index.d.ts CHANGED
@@ -145,7 +145,7 @@ type DbType = 'string' | 'text' | 'integer' | 'decimal' | 'boolean' | 'date' | '
145
145
  /**
146
146
  * Tipos de input en UI
147
147
  */
148
- type InputType = 'text' | 'email' | 'password' | 'url' | 'tel' | 'number' | 'decimal' | 'textarea' | 'markdown' | 'select' | 'multiselect' | 'checkbox' | 'switch' | 'date' | 'datetime' | 'file' | 'image' | 'hidden';
148
+ type InputType = 'text' | 'email' | 'password' | 'url' | 'tel' | 'number' | 'decimal' | 'textarea' | 'markdown' | 'select' | 'multiselect' | 'checkbox' | 'switch' | 'date' | 'datetime' | 'file' | 'fileArray' | 'image' | 'imageArray' | 'hidden';
149
149
  /**
150
150
  * Configuración de base de datos para un campo
151
151
  */
@@ -200,6 +200,24 @@ interface FieldCaslAccess {
200
200
  /** Roles que pueden escribir este campo (vacío = todos, null = nadie excepto ADMIN) */
201
201
  writeRoles?: string[];
202
202
  }
203
+ /**
204
+ * Configuración de storage para campos file/image
205
+ */
206
+ interface FieldStorageConfig {
207
+ /** Tipos MIME aceptados (ej: 'image/*', 'application/pdf') */
208
+ accept?: string;
209
+ /** Tamaño máximo en bytes (default: 10MB) */
210
+ maxSize?: number;
211
+ /** Número máximo de archivos para tipos array */
212
+ maxFiles?: number;
213
+ /** Carpeta/prefijo en storage (ej: 'avatars', 'documents') */
214
+ folder?: string;
215
+ /** Tamaños de thumbnails a generar para imágenes */
216
+ thumbnails?: Array<{
217
+ width: number;
218
+ height: number;
219
+ }>;
220
+ }
203
221
  /**
204
222
  * Metadata del campo
205
223
  */
@@ -231,6 +249,7 @@ interface FieldDefinition {
231
249
  relation?: FieldRelation;
232
250
  validation?: FieldValidationConfig;
233
251
  options?: FieldOptions;
252
+ storage?: FieldStorageConfig;
234
253
  meta?: FieldMeta;
235
254
  }
236
255
  /**
@@ -370,8 +389,8 @@ interface EventEntityDefinition extends BaseEntityDefinition {
370
389
  type: 'event';
371
390
  /** Campo para mostrar en listas */
372
391
  labelField: string;
373
- /** Siempre true para eventos */
374
- timestamps: true;
392
+ /** Si false, no añade created_at/updated_at automáticos (útil si defines created_at explícitamente) */
393
+ timestamps?: boolean;
375
394
  /** Política de retención automática */
376
395
  retention?: {
377
396
  /** Eliminar registros más antiguos que N días */
@@ -602,9 +621,10 @@ interface ModuleAbilities {
602
621
  */
603
622
  type PluginAuthRequest = AuthRequest<BaseUser, AbilityLike>;
604
623
  /**
605
- * Helpers para migraciones de base de datos
624
+ * Helpers del contexto (migraciones, utilidades)
606
625
  */
607
- interface MigrationHelpers {
626
+ interface ContextHelpers {
627
+ generateId: () => string;
608
628
  addTimestamps: (table: Knex.CreateTableBuilder, db: Knex) => void;
609
629
  addAuditFieldsIfMissing: (db: Knex, tableName: string) => Promise<void>;
610
630
  addColumnIfMissing: (db: Knex, tableName: string, columnName: string, columnBuilder: (table: Knex.AlterTableBuilder) => void) => Promise<boolean>;
@@ -647,12 +667,10 @@ interface EventEmitterLike {
647
667
  interface ModuleContext {
648
668
  db: Knex;
649
669
  logger: Logger;
650
- generateId: () => string;
651
670
  dbType: 'sqlite' | 'postgresql' | 'mysql';
652
- helpers: MigrationHelpers;
671
+ helpers: ContextHelpers;
653
672
  createRouter: () => Router;
654
673
  middleware: ModuleMiddlewares;
655
- registerMiddleware: (name: string, handler: RequestHandler) => void;
656
674
  /** Configuración resuelta de la aplicación */
657
675
  config: Record<string, unknown>;
658
676
  errors: {
@@ -668,16 +686,6 @@ interface ModuleContext {
668
686
  abilities: ModuleAbilities;
669
687
  /** Sistema de eventos compatible con EventEmitter2 */
670
688
  events: EventEmitterLike;
671
- mail: {
672
- send: (options: {
673
- to: string | string[];
674
- subject: string;
675
- html?: string;
676
- text?: string;
677
- template?: string;
678
- data?: Record<string, unknown>;
679
- }) => Promise<unknown>;
680
- };
681
689
  /** Servicios de módulos (inyectados por backend) */
682
690
  services: Record<string, unknown>;
683
691
  }
@@ -742,4 +750,4 @@ interface PluginManifest {
742
750
  modules: ModuleManifest[];
743
751
  }
744
752
 
745
- export { type AbilityLike, type ActionEntityDefinition, type AuthRequest, type BaseUser, type CaslAction, type CollectionEntityDefinition, type ComputedEntityDefinition, type ConfigEntityDefinition, type DbType, type EntityCaslConfig, type EntityDefinition, type EntityIndex, type EntityType, type EventEmitterLike, type EventEntityDefinition, type ExternalEntityDefinition, type FieldCaslAccess, type FieldDbConfig, type FieldDefinition, type FieldMeta, type FieldOptions, type FieldRelation, type FieldValidationConfig, type ForbiddenErrorConstructor, type ForbiddenErrorInstance, GENERATED_DIR, type InputType, type KnexAlterTableBuilder, type KnexCreateTableBuilder, type KnexTransaction, type MigrationHelpers, type ModuleAbilities, type ModuleContext, type ModuleManifest, type ModuleMiddlewares, type ModuleRequirements, type NonPersistentEntityDefinition, type OwnershipCondition, type PaginatedResult, type PaginationParams, type PersistentEntityDefinition, type PluginAuthRequest, type PluginCategory, type PluginManifest, type ReferenceEntityDefinition, type RolePermission, type SingleEntityDefinition, type TempEntityDefinition, type ValidateSchemas, type ValidationSchema, type ViewEntityDefinition, type VirtualEntityDefinition, generateModel, generateModelsFile, generateReadOnlyModel, getEntityName, getEntitySubject, hasTable, isPersistentEntity, isSingletonEntity };
753
+ export { type AbilityLike, type ActionEntityDefinition, type AuthRequest, type BaseUser, type CaslAction, type CollectionEntityDefinition, type ComputedEntityDefinition, type ConfigEntityDefinition, type ContextHelpers, type DbType, type EntityCaslConfig, type EntityDefinition, type EntityIndex, type EntityType, type EventEmitterLike, type EventEntityDefinition, type ExternalEntityDefinition, type FieldCaslAccess, type FieldDbConfig, type FieldDefinition, type FieldMeta, type FieldOptions, type FieldRelation, type FieldStorageConfig, type FieldValidationConfig, type ForbiddenErrorConstructor, type ForbiddenErrorInstance, GENERATED_DIR, type InputType, type KnexAlterTableBuilder, type KnexCreateTableBuilder, type KnexTransaction, type ModuleAbilities, type ModuleContext, type ModuleManifest, type ModuleMiddlewares, type ModuleRequirements, type NonPersistentEntityDefinition, type OwnershipCondition, type PaginatedResult, type PaginationParams, type PersistentEntityDefinition, type PluginAuthRequest, type PluginCategory, type PluginManifest, type ReferenceEntityDefinition, type RolePermission, type SingleEntityDefinition, type TempEntityDefinition, type ValidateSchemas, type ValidationSchema, type ViewEntityDefinition, type VirtualEntityDefinition, generateModel, generateModelsFile, generateReadOnlyModel, getEntityName, getEntitySubject, hasTable, isPersistentEntity, isSingletonEntity };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gzl10/nexus-sdk",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "SDK types for creating Nexus plugins and modules",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",