@gzl10/nexus-sdk 0.6.0 → 0.7.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.
@@ -28,12 +28,20 @@ function generateModel(entity) {
28
28
  lines.push(` ${name}${optional}: ${tsType}`);
29
29
  }
30
30
  if (timestamps) {
31
- lines.push(` created_at: Date`);
32
- lines.push(` updated_at: Date`);
31
+ if (!fields["created_at"]) {
32
+ lines.push(` created_at: Date`);
33
+ }
34
+ if (!fields["updated_at"]) {
35
+ lines.push(` updated_at: Date`);
36
+ }
33
37
  }
34
38
  if (audit) {
35
- lines.push(` created_by: string | null`);
36
- lines.push(` updated_by: string | null`);
39
+ if (!fields["created_by"]) {
40
+ lines.push(` created_by: string | null`);
41
+ }
42
+ if (!fields["updated_by"]) {
43
+ lines.push(` updated_by: string | null`);
44
+ }
37
45
  }
38
46
  lines.push(`}`);
39
47
  lines.push(``);
package/dist/cli/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  GENERATED_DIR,
4
4
  generateModelsFile
5
- } from "../chunk-UZT5CTOT.js";
5
+ } from "../chunk-LQZB6HXM.js";
6
6
 
7
7
  // src/cli/index.ts
8
8
  import { Command as Command2 } from "commander";
@@ -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.6.0");
153
+ var program = new Command2().name("nexus-sdk").description("Nexus SDK CLI - Code generation from EntityDefinitions").version("0.7.0");
154
154
  program.addCommand(createGenerateCommand());
155
155
  program.parse();
package/dist/index.d.ts CHANGED
@@ -138,43 +138,6 @@ interface PaginatedResult<T> {
138
138
  totalPages: number;
139
139
  hasNext: boolean;
140
140
  }
141
- /**
142
- * Tipo de campo para formularios dinámicos
143
- */
144
- type FormFieldType = 'text' | 'email' | 'password' | 'number' | 'textarea' | 'markdown' | 'select' | 'checkbox' | 'date' | 'datetime';
145
- /**
146
- * JSON Schema para validación de campos (subset serializable)
147
- */
148
- interface FieldValidation {
149
- type?: 'string' | 'number' | 'integer' | 'boolean';
150
- minLength?: number;
151
- maxLength?: number;
152
- minimum?: number;
153
- maximum?: number;
154
- pattern?: string;
155
- format?: 'email' | 'uri' | 'date' | 'date-time' | 'uuid';
156
- errorMessage?: string;
157
- }
158
- /**
159
- * Configuración de un campo de formulario
160
- */
161
- interface FormField {
162
- label: string;
163
- type: FormFieldType;
164
- required?: boolean;
165
- placeholder?: string;
166
- createOnly?: boolean;
167
- disabled?: boolean;
168
- hidden?: boolean;
169
- optionsEndpoint?: string;
170
- optionValue?: string;
171
- optionLabel?: string;
172
- validation?: FieldValidation;
173
- }
174
- /**
175
- * Tipo de visualización de lista
176
- */
177
- type ListType = 'table' | 'list' | 'grid' | 'masonry';
178
141
  /**
179
142
  * Tipos de columna en base de datos
180
143
  */
@@ -624,12 +587,12 @@ interface ForbiddenErrorConstructor {
624
587
  * Permite usar CASL en plugins sin importar @casl/ability directamente
625
588
  */
626
589
  interface ModuleAbilities {
627
- /** Crea una ability CASL para un usuario (acepta argumentos adicionales como permissions) */
628
- defineAbilityFor: (user: any, ...args: any[]) => any;
629
- /** Empaqueta reglas CASL para enviar al cliente (recibe ability, retorna reglas) */
630
- packRules: (ability: any) => unknown[];
590
+ /** Crea una ability CASL para un usuario */
591
+ defineAbilityFor: (user: BaseUser | null, ...args: unknown[]) => unknown;
592
+ /** Empaqueta reglas CASL para enviar al cliente */
593
+ packRules: (ability: unknown) => unknown[];
631
594
  /** Wrapper para verificar permisos contra instancias */
632
- subject: (type: string, object: Record<string, any>) => unknown;
595
+ subject: (type: string, object: Record<string, unknown>) => unknown;
633
596
  /** Error de CASL para throwUnlessCan */
634
597
  ForbiddenError: ForbiddenErrorConstructor;
635
598
  }
@@ -668,6 +631,16 @@ interface ModuleMiddlewares {
668
631
  validate: (schemas: ValidateSchemas) => RequestHandler;
669
632
  [key: string]: RequestHandler | ((...args: any[]) => RequestHandler) | undefined;
670
633
  }
634
+ /**
635
+ * Interfaz mínima de EventEmitter compatible con EventEmitter2
636
+ */
637
+ interface EventEmitterLike {
638
+ emit: (event: string, ...args: unknown[]) => boolean;
639
+ on: (event: string, listener: (...args: unknown[]) => void) => this;
640
+ off: (event: string, listener: (...args: unknown[]) => void) => this;
641
+ once: (event: string, listener: (...args: unknown[]) => void) => this;
642
+ onAny?: (listener: (event: string, ...args: unknown[]) => void) => this;
643
+ }
671
644
  /**
672
645
  * Contexto inyectado a los módulos
673
646
  */
@@ -680,8 +653,8 @@ interface ModuleContext {
680
653
  createRouter: () => Router;
681
654
  middleware: ModuleMiddlewares;
682
655
  registerMiddleware: (name: string, handler: RequestHandler) => void;
683
- /** Configuración resuelta de la aplicación (permite propiedades tipadas del backend) */
684
- config: any;
656
+ /** Configuración resuelta de la aplicación */
657
+ config: Record<string, unknown>;
685
658
  errors: {
686
659
  AppError: new (message: string, statusCode?: number) => Error;
687
660
  NotFoundError: new (message?: string) => Error;
@@ -693,8 +666,8 @@ interface ModuleContext {
693
666
  };
694
667
  };
695
668
  abilities: ModuleAbilities;
696
- /** Sistema de eventos (EventEmitter2 compatible, permite implementaciones tipadas) */
697
- events: any;
669
+ /** Sistema de eventos compatible con EventEmitter2 */
670
+ events: EventEmitterLike;
698
671
  mail: {
699
672
  send: (options: {
700
673
  to: string | string[];
@@ -736,8 +709,6 @@ interface ModuleManifest {
736
709
  routes?: (ctx: ModuleContext) => Router;
737
710
  /** Prefijo de rutas (default: /{name}) */
738
711
  routePrefix?: string;
739
- /** Subjects CASL adicionales (sin entity). Los subjects de entities se infieren automáticamente */
740
- additionalSubjects?: string[];
741
712
  /**
742
713
  * Definiciones de entidades (nuevo sistema unificado).
743
714
  * Single source of truth para BD, validación, UI y CASL.
@@ -771,4 +742,4 @@ interface PluginManifest {
771
742
  modules: ModuleManifest[];
772
743
  }
773
744
 
774
- 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 EventEntityDefinition, type ExternalEntityDefinition, type FieldCaslAccess, type FieldDbConfig, type FieldDefinition, type FieldMeta, type FieldOptions, type FieldRelation, type FieldValidation, type FieldValidationConfig, type ForbiddenErrorConstructor, type ForbiddenErrorInstance, type FormField, type FormFieldType, GENERATED_DIR, type InputType, type KnexAlterTableBuilder, type KnexCreateTableBuilder, type KnexTransaction, type ListType, 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 };
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 };
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  hasTable,
9
9
  isPersistentEntity,
10
10
  isSingletonEntity
11
- } from "./chunk-UZT5CTOT.js";
11
+ } from "./chunk-LQZB6HXM.js";
12
12
  export {
13
13
  GENERATED_DIR,
14
14
  generateModel,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gzl10/nexus-sdk",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "SDK types for creating Nexus plugins and modules",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",