@gzl10/nexus-backend 0.12.6 → 0.12.7

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/README.md CHANGED
@@ -73,7 +73,7 @@ await start({
73
73
 
74
74
  // Custom routes
75
75
  beforeRoutes: (app) => {
76
- app.get('/health', (_req, res) => res.json({ ok: true }))
76
+ app.get('/api/health_custom', (_req, res) => res.json({ ok: true }))
77
77
  },
78
78
  afterRoutes: (app, serveSPA) => {
79
79
  serveSPA('/admin', '../admin/dist')
package/dist/cli.js CHANGED
@@ -30,7 +30,7 @@ program.command("ui").description("Open UI in browser").option("-p, --port <port
30
30
  const baseUrl = (process.env["BACKEND_URL"] || `http://localhost:${port}`).replace(/\/$/, "");
31
31
  const url = `${baseUrl}/ui`;
32
32
  try {
33
- const res = await fetch(`${baseUrl}/health`);
33
+ const res = await fetch(`${baseUrl}/api/health`);
34
34
  if (!res.ok) throw new Error();
35
35
  } catch {
36
36
  consola.error(`Nexus no est\xE1 corriendo en ${baseUrl}`);
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/env-loader.ts","../src/cli.ts"],"sourcesContent":["/**\n * Loads .env before any other project import.\n * This file ONLY imports from node/npm, never from local files.\n */\nimport { existsSync } from 'fs'\nimport { join, dirname } from 'path'\nimport { config } from 'dotenv'\n\nlet dir = process.cwd()\nconsole.log('[env-loader] Starting search from cwd:', dir)\n\nfor (let i = 0; i < 3; i++) {\n const envPath = join(dir, '.env')\n const exists = existsSync(envPath)\n console.log(`[env-loader] Checking: ${envPath}`, exists ? '✓ FOUND' : '✗ not found')\n if (exists) {\n config({ path: envPath })\n console.log('[env-loader] Loaded:', envPath)\n break\n }\n const parent = dirname(dir)\n if (parent === dir) break\n dir = parent\n}\n","#!/usr/bin/env node\nimport './env-loader.js'\nimport { Command } from 'commander'\nimport { consola } from 'consola'\n\nconst program = new Command()\n\nprogram\n .name('nexus')\n .description('Nexus Backend CLI')\n .version('0.1.0')\n\nprogram\n .command('ui')\n .description('Open UI in browser')\n .option('-p, --port <port>', 'Nexus backend port')\n .action(async (options) => {\n const port = parseInt(options.port || process.env['PORT'] || '3000', 10)\n const baseUrl = (process.env['BACKEND_URL'] || `http://localhost:${port}`).replace(/\\/$/, '')\n const url = `${baseUrl}/ui`\n\n // Verificar que Nexus está corriendo\n try {\n const res = await fetch(`${baseUrl}/health`)\n if (!res.ok) throw new Error()\n } catch {\n consola.error(`Nexus no está corriendo en ${baseUrl}`)\n consola.info('Inicia el servidor primero con: pnpm dev')\n process.exit(1)\n }\n\n // Abrir navegador\n const { exec } = await import('child_process')\n const cmd = process.platform === 'darwin' ? 'open'\n : process.platform === 'win32' ? 'start'\n : 'xdg-open'\n\n exec(`${cmd} ${url}`)\n consola.success(`Abriendo: ${url}`)\n })\n\nprogram.parse()\n"],"mappings":";;;AAIA,SAAS,kBAAkB;AAC3B,SAAS,MAAM,eAAe;AAC9B,SAAS,cAAc;AAEvB,IAAI,MAAM,QAAQ,IAAI;AACtB,QAAQ,IAAI,0CAA0C,GAAG;AAEzD,SAAS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,QAAM,UAAU,KAAK,KAAK,MAAM;AAChC,QAAM,SAAS,WAAW,OAAO;AACjC,UAAQ,IAAI,0BAA0B,OAAO,IAAI,SAAS,iBAAY,kBAAa;AACnF,MAAI,QAAQ;AACV,WAAO,EAAE,MAAM,QAAQ,CAAC;AACxB,YAAQ,IAAI,wBAAwB,OAAO;AAC3C;AAAA,EACF;AACA,QAAM,SAAS,QAAQ,GAAG;AAC1B,MAAI,WAAW,IAAK;AACpB,QAAM;AACR;;;ACrBA,SAAS,eAAe;AACxB,SAAS,eAAe;AAExB,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,OAAO,EACZ,YAAY,mBAAmB,EAC/B,QAAQ,OAAO;AAElB,QACG,QAAQ,IAAI,EACZ,YAAY,oBAAoB,EAChC,OAAO,qBAAqB,oBAAoB,EAChD,OAAO,OAAO,YAAY;AACzB,QAAM,OAAO,SAAS,QAAQ,QAAQ,QAAQ,IAAI,MAAM,KAAK,QAAQ,EAAE;AACvE,QAAM,WAAW,QAAQ,IAAI,aAAa,KAAK,oBAAoB,IAAI,IAAI,QAAQ,OAAO,EAAE;AAC5F,QAAM,MAAM,GAAG,OAAO;AAGtB,MAAI;AACF,UAAM,MAAM,MAAM,MAAM,GAAG,OAAO,SAAS;AAC3C,QAAI,CAAC,IAAI,GAAI,OAAM,IAAI,MAAM;AAAA,EAC/B,QAAQ;AACN,YAAQ,MAAM,iCAA8B,OAAO,EAAE;AACrD,YAAQ,KAAK,0CAA0C;AACvD,YAAQ,KAAK,CAAC;AAAA,EAChB;AAGA,QAAM,EAAE,KAAK,IAAI,MAAM,OAAO,eAAe;AAC7C,QAAM,MAAM,QAAQ,aAAa,WAAW,SAChC,QAAQ,aAAa,UAAU,UAC/B;AAEZ,OAAK,GAAG,GAAG,IAAI,GAAG,EAAE;AACpB,UAAQ,QAAQ,aAAa,GAAG,EAAE;AACpC,CAAC;AAEH,QAAQ,MAAM;","names":[]}
1
+ {"version":3,"sources":["../src/env-loader.ts","../src/cli.ts"],"sourcesContent":["/**\n * Loads .env before any other project import.\n * This file ONLY imports from node/npm, never from local files.\n */\nimport { existsSync } from 'fs'\nimport { join, dirname } from 'path'\nimport { config } from 'dotenv'\n\nlet dir = process.cwd()\nconsole.log('[env-loader] Starting search from cwd:', dir)\n\nfor (let i = 0; i < 3; i++) {\n const envPath = join(dir, '.env')\n const exists = existsSync(envPath)\n console.log(`[env-loader] Checking: ${envPath}`, exists ? '✓ FOUND' : '✗ not found')\n if (exists) {\n config({ path: envPath })\n console.log('[env-loader] Loaded:', envPath)\n break\n }\n const parent = dirname(dir)\n if (parent === dir) break\n dir = parent\n}\n","#!/usr/bin/env node\nimport './env-loader.js'\nimport { Command } from 'commander'\nimport { consola } from 'consola'\n\nconst program = new Command()\n\nprogram\n .name('nexus')\n .description('Nexus Backend CLI')\n .version('0.1.0')\n\nprogram\n .command('ui')\n .description('Open UI in browser')\n .option('-p, --port <port>', 'Nexus backend port')\n .action(async (options) => {\n const port = parseInt(options.port || process.env['PORT'] || '3000', 10)\n const baseUrl = (process.env['BACKEND_URL'] || `http://localhost:${port}`).replace(/\\/$/, '')\n const url = `${baseUrl}/ui`\n\n // Verificar que Nexus está corriendo\n try {\n const res = await fetch(`${baseUrl}/api/health`)\n if (!res.ok) throw new Error()\n } catch {\n consola.error(`Nexus no está corriendo en ${baseUrl}`)\n consola.info('Inicia el servidor primero con: pnpm dev')\n process.exit(1)\n }\n\n // Abrir navegador\n const { exec } = await import('child_process')\n const cmd = process.platform === 'darwin' ? 'open'\n : process.platform === 'win32' ? 'start'\n : 'xdg-open'\n\n exec(`${cmd} ${url}`)\n consola.success(`Abriendo: ${url}`)\n })\n\nprogram.parse()\n"],"mappings":";;;AAIA,SAAS,kBAAkB;AAC3B,SAAS,MAAM,eAAe;AAC9B,SAAS,cAAc;AAEvB,IAAI,MAAM,QAAQ,IAAI;AACtB,QAAQ,IAAI,0CAA0C,GAAG;AAEzD,SAAS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,QAAM,UAAU,KAAK,KAAK,MAAM;AAChC,QAAM,SAAS,WAAW,OAAO;AACjC,UAAQ,IAAI,0BAA0B,OAAO,IAAI,SAAS,iBAAY,kBAAa;AACnF,MAAI,QAAQ;AACV,WAAO,EAAE,MAAM,QAAQ,CAAC;AACxB,YAAQ,IAAI,wBAAwB,OAAO;AAC3C;AAAA,EACF;AACA,QAAM,SAAS,QAAQ,GAAG;AAC1B,MAAI,WAAW,IAAK;AACpB,QAAM;AACR;;;ACrBA,SAAS,eAAe;AACxB,SAAS,eAAe;AAExB,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,OAAO,EACZ,YAAY,mBAAmB,EAC/B,QAAQ,OAAO;AAElB,QACG,QAAQ,IAAI,EACZ,YAAY,oBAAoB,EAChC,OAAO,qBAAqB,oBAAoB,EAChD,OAAO,OAAO,YAAY;AACzB,QAAM,OAAO,SAAS,QAAQ,QAAQ,QAAQ,IAAI,MAAM,KAAK,QAAQ,EAAE;AACvE,QAAM,WAAW,QAAQ,IAAI,aAAa,KAAK,oBAAoB,IAAI,IAAI,QAAQ,OAAO,EAAE;AAC5F,QAAM,MAAM,GAAG,OAAO;AAGtB,MAAI;AACF,UAAM,MAAM,MAAM,MAAM,GAAG,OAAO,aAAa;AAC/C,QAAI,CAAC,IAAI,GAAI,OAAM,IAAI,MAAM;AAAA,EAC/B,QAAQ;AACN,YAAQ,MAAM,iCAA8B,OAAO,EAAE;AACrD,YAAQ,KAAK,0CAA0C;AACvD,YAAQ,KAAK,CAAC;AAAA,EAChB;AAGA,QAAM,EAAE,KAAK,IAAI,MAAM,OAAO,eAAe;AAC7C,QAAM,MAAM,QAAQ,aAAa,WAAW,SAChC,QAAQ,aAAa,UAAU,UAC/B;AAEZ,OAAK,GAAG,GAAG,IAAI,GAAG,EAAE;AACpB,UAAQ,QAAQ,aAAa,GAAG,EAAE;AACpC,CAAC;AAEH,QAAQ,MAAM;","names":[]}
package/dist/index.d.ts CHANGED
@@ -91,13 +91,16 @@ declare function getAdapter(name: string): ExternalAdapter | undefined;
91
91
  /**
92
92
  * Users module types
93
93
  */
94
+ /** User type discriminator */
95
+ type UserType = 'human' | 'bot' | 'service';
94
96
  /**
95
97
  * System user
96
98
  */
97
99
  interface User {
98
100
  id: string;
99
- email: string;
100
- password: string;
101
+ type: UserType;
102
+ email: string | null;
103
+ password: string | null;
101
104
  name: string;
102
105
  avatar?: string | null;
103
106
  metadata?: Record<string, unknown> | null;
@@ -204,7 +207,6 @@ interface ServeSPAOptions {
204
207
  type ServeSPAFunction = (endpoint: string, distPath: string, options?: ServeSPAOptions) => void;
205
208
  interface NexusConfig {
206
209
  port?: number;
207
- host?: string;
208
210
  timezone?: string;
209
211
  /**
210
212
  * UI/Frontend configuration.
@@ -1449,6 +1451,7 @@ declare class NotificationService {
1449
1451
  private generateId;
1450
1452
  private nowTimestamp;
1451
1453
  private formatTimestamp;
1454
+ private safeJsonParse;
1452
1455
  private socket;
1453
1456
  private events;
1454
1457
  constructor(ctx: ModuleContext);
@@ -1511,4 +1514,6 @@ declare function getProjectPath(): string;
1511
1514
  */
1512
1515
  declare function findEnvFile(): string | null;
1513
1516
 
1514
- export { ActionService, type Actions, type AppAbility, type AppManifest, type AuthAudit, BaseEntityService, type CaslRulesFunction, CollectionService, ComputedService, ConfigService, type DbEventPayload, type EntityController, type EntityHandler, type EntityRuntime, type EntityService, EventService, type ExternalAdapter, ExternalService, type JwtPayload, type NexusConfig, type NexusEventName, type NexusEventPayload, type NexusEvents, type Notification, type NotificationPayload, type NotificationPriority, NotificationService, type NotificationTarget, type NotificationType, ReferenceService, type RefreshToken, type ResolvedConfig, type Role, type RoleWithCounts, type SendNotificationInput, type ServeSPAFunction, type ServeSPAOptions, SingleService, type SubjectRegistry, type SubjectStrings, type Subjects, TempService, type TokenPair, type User, type UserPresence, type UserWithRoles, type UserWithoutPassword, ViewService, VirtualService, closeSocketIO, createApp, createEntityRuntime, createEntityService, createModuleRouters, createModuleServices, db, defineAbilityFor, destroyDb, findEnvFile, getAdapter, getConfig, getConnectedUsers, getCoreManifest, getCoreModules, getDatabaseType, getDb, getIO, getLibPath, getModule, getModules, getNotificationService, getOrderedModules, getPlugin, getPlugins, getProjectPath, getRegisteredSubjects, getServiceKey, getUserManifest, getUserModules, getUserSocketCount, hasUserApp, initNotificationService, initSocketIO, isRunning, isSocketIOInitialized, isUserConnected, isValidSubject, loadCoreModules, nexusEvents, packRules, registerAdapter, registerModule, restart, start, stop, unpackRules };
1517
+ declare const version: string;
1518
+
1519
+ export { ActionService, type Actions, type AppAbility, type AppManifest, type AuthAudit, BaseEntityService, type CaslRulesFunction, CollectionService, ComputedService, ConfigService, type DbEventPayload, type EntityController, type EntityHandler, type EntityRuntime, type EntityService, EventService, type ExternalAdapter, ExternalService, type JwtPayload, type NexusConfig, type NexusEventName, type NexusEventPayload, type NexusEvents, type Notification, type NotificationPayload, type NotificationPriority, NotificationService, type NotificationTarget, type NotificationType, ReferenceService, type RefreshToken, type ResolvedConfig, type Role, type RoleWithCounts, type SendNotificationInput, type ServeSPAFunction, type ServeSPAOptions, SingleService, type SubjectRegistry, type SubjectStrings, type Subjects, TempService, type TokenPair, type User, type UserPresence, type UserWithRoles, type UserWithoutPassword, ViewService, VirtualService, closeSocketIO, createApp, createEntityRuntime, createEntityService, createModuleRouters, createModuleServices, db, defineAbilityFor, destroyDb, findEnvFile, getAdapter, getConfig, getConnectedUsers, getCoreManifest, getCoreModules, getDatabaseType, getDb, getIO, getLibPath, getModule, getModules, getNotificationService, getOrderedModules, getPlugin, getPlugins, getProjectPath, getRegisteredSubjects, getServiceKey, getUserManifest, getUserModules, getUserSocketCount, hasUserApp, initNotificationService, initSocketIO, isRunning, isSocketIOInitialized, isUserConnected, isValidSubject, loadCoreModules, nexusEvents, packRules, registerAdapter, registerModule, restart, start, stop, unpackRules, version };