@gzl10/nexus-backend 0.18.0 → 0.19.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/index.d.ts CHANGED
@@ -15,6 +15,8 @@ import pkg from 'eventemitter2';
15
15
  import { Server } from 'socket.io';
16
16
  import { Server as Server$1 } from 'http';
17
17
  import * as qs from 'qs';
18
+ import { A as AppError } from './app-error-CKbYJQ9V.js';
19
+ export { a as AppErrorParams, C as ConflictError, b as ErrorCode, E as ErrorCodes, F as ForbiddenError, N as NotFoundError, U as UnauthorizedError, c as ValidationDetail, V as ValidationError } from './app-error-CKbYJQ9V.js';
18
20
 
19
21
  /**
20
22
  * CASL action types (duplicated from core/abilities to avoid config/ → core/ dependency).
@@ -2118,140 +2120,6 @@ declare function createBatchReporter(sender: SSESender): BatchReporter;
2118
2120
  */
2119
2121
  declare function createSSEHelper(): SSEHelper;
2120
2122
 
2121
- /**
2122
- * Error codes for i18n-friendly error handling.
2123
- * Frontend translates these codes to localized messages.
2124
- *
2125
- * Format: CATEGORY_ACTION_REASON
2126
- *
2127
- * Categories: AUTH, USER, ROLE, VALIDATION, STORAGE, PERMISSION, RESOURCE, SYSTEM
2128
- */
2129
- declare const ErrorCodes: {
2130
- readonly AUTH_INVALID_CREDENTIALS: "AUTH_INVALID_CREDENTIALS";
2131
- readonly AUTH_TOKEN_EXPIRED: "AUTH_TOKEN_EXPIRED";
2132
- readonly AUTH_TOKEN_INVALID: "AUTH_TOKEN_INVALID";
2133
- readonly AUTH_TOKEN_REQUIRED: "AUTH_TOKEN_REQUIRED";
2134
- readonly AUTH_OTP_REQUIRED: "AUTH_OTP_REQUIRED";
2135
- readonly AUTH_OTP_INVALID: "AUTH_OTP_INVALID";
2136
- readonly AUTH_REFRESH_TOKEN_REQUIRED: "AUTH_REFRESH_TOKEN_REQUIRED";
2137
- readonly AUTH_REFRESH_TOKEN_INVALID: "AUTH_REFRESH_TOKEN_INVALID";
2138
- readonly AUTH_REFRESH_TOKEN_EXPIRED: "AUTH_REFRESH_TOKEN_EXPIRED";
2139
- readonly AUTH_SESSION_NOT_FOUND: "AUTH_SESSION_NOT_FOUND";
2140
- readonly AUTH_SESSION_SELF_REVOKE: "AUTH_SESSION_SELF_REVOKE";
2141
- readonly AUTH_VERIFICATION_CODE_INVALID: "AUTH_VERIFICATION_CODE_INVALID";
2142
- readonly AUTH_REGISTRATION_DISABLED: "AUTH_REGISTRATION_DISABLED";
2143
- readonly AUTH_AUTO_CREATE_DISABLED: "AUTH_AUTO_CREATE_DISABLED";
2144
- readonly USER_NOT_FOUND: "USER_NOT_FOUND";
2145
- readonly USER_EMAIL_EXISTS: "USER_EMAIL_EXISTS";
2146
- readonly USER_NOT_AUTHENTICATED: "USER_NOT_AUTHENTICATED";
2147
- readonly ROLE_NOT_FOUND: "ROLE_NOT_FOUND";
2148
- readonly ROLE_NAME_EXISTS: "ROLE_NAME_EXISTS";
2149
- readonly ROLE_SYSTEM_PROTECTED: "ROLE_SYSTEM_PROTECTED";
2150
- readonly ROLE_HAS_USERS: "ROLE_HAS_USERS";
2151
- readonly ROLE_DEFAULT_NOT_FOUND: "ROLE_DEFAULT_NOT_FOUND";
2152
- readonly PERMISSION_DENIED: "PERMISSION_DENIED";
2153
- readonly VALIDATION_ERROR: "VALIDATION_ERROR";
2154
- readonly VALIDATION_FIELD_REQUIRED: "VALIDATION_FIELD_REQUIRED";
2155
- readonly VALIDATION_FIELD_INVALID: "VALIDATION_FIELD_INVALID";
2156
- readonly VALIDATION_JSON_MALFORMED: "VALIDATION_JSON_MALFORMED";
2157
- readonly STORAGE_FILE_NOT_FOUND: "STORAGE_FILE_NOT_FOUND";
2158
- readonly STORAGE_FILE_TOO_LARGE: "STORAGE_FILE_TOO_LARGE";
2159
- readonly STORAGE_FILE_TYPE_NOT_ALLOWED: "STORAGE_FILE_TYPE_NOT_ALLOWED";
2160
- readonly STORAGE_PAYLOAD_TOO_LARGE: "STORAGE_PAYLOAD_TOO_LARGE";
2161
- readonly RESOURCE_NOT_FOUND: "RESOURCE_NOT_FOUND";
2162
- readonly RESOURCE_CONFLICT: "RESOURCE_CONFLICT";
2163
- readonly RESOURCE_CREATE_NOT_SUPPORTED: "RESOURCE_CREATE_NOT_SUPPORTED";
2164
- readonly RESOURCE_UPDATE_NOT_SUPPORTED: "RESOURCE_UPDATE_NOT_SUPPORTED";
2165
- readonly RESOURCE_DELETE_NOT_SUPPORTED: "RESOURCE_DELETE_NOT_SUPPORTED";
2166
- readonly MODULE_NOT_FOUND: "MODULE_NOT_FOUND";
2167
- readonly NOT_FOUND: "NOT_FOUND";
2168
- readonly AUTH_UNAUTHORIZED: "AUTH_UNAUTHORIZED";
2169
- readonly DB_CONSTRAINT_UNIQUE: "DB_CONSTRAINT_UNIQUE";
2170
- readonly DB_CONSTRAINT_FK: "DB_CONSTRAINT_FK";
2171
- readonly DB_CONNECTION_ERROR: "DB_CONNECTION_ERROR";
2172
- readonly SYSTEM_INTERNAL_ERROR: "SYSTEM_INTERNAL_ERROR";
2173
- };
2174
- type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
2175
-
2176
- /**
2177
- * Parameters for creating an AppError with i18n support
2178
- */
2179
- interface AppErrorParams {
2180
- /** Error code for i18n translation (e.g., 'AUTH_INVALID_CREDENTIALS') */
2181
- code: ErrorCode;
2182
- /** Fallback message in English (used if frontend doesn't have translation) */
2183
- message?: string;
2184
- /** Interpolation values for the translated message (e.g., { resource: 'User' }) */
2185
- interpolation?: Record<string, string | number>;
2186
- }
2187
- /**
2188
- * Base application error with i18n support.
2189
- *
2190
- * Can be created with:
2191
- * - String message (legacy, backward compatible)
2192
- * - AppErrorParams object (new, with code and interpolation)
2193
- *
2194
- * @example
2195
- * // Legacy usage
2196
- * throw new AppError('Something went wrong', 400)
2197
- *
2198
- * // New usage with i18n
2199
- * throw new AppError({
2200
- * code: ErrorCodes.USER_NOT_FOUND,
2201
- * message: 'User not found',
2202
- * interpolation: { resource: 'User' }
2203
- * }, 404)
2204
- */
2205
- declare class AppError extends Error {
2206
- readonly statusCode: number;
2207
- readonly code: ErrorCode;
2208
- readonly interpolation?: Record<string, string | number>;
2209
- readonly details?: unknown;
2210
- constructor(params: AppErrorParams | string, statusCode?: number, details?: unknown);
2211
- }
2212
- /**
2213
- * Resource not found error (404)
2214
- */
2215
- declare class NotFoundError$1 extends AppError {
2216
- constructor(resource?: string);
2217
- }
2218
- /**
2219
- * Authentication required error (401)
2220
- */
2221
- declare class UnauthorizedError$1 extends AppError {
2222
- constructor(codeOrMessage?: ErrorCode | string, message?: string);
2223
- }
2224
- /**
2225
- * Access denied error (403)
2226
- */
2227
- declare class ForbiddenError$1 extends AppError {
2228
- constructor(codeOrMessage?: ErrorCode | string, message?: string);
2229
- }
2230
- /**
2231
- * Resource conflict error (409)
2232
- */
2233
- declare class ConflictError$1 extends AppError {
2234
- constructor(codeOrMessage?: ErrorCode | string, message?: string);
2235
- }
2236
- /**
2237
- * Standard validation error detail
2238
- */
2239
- interface ValidationDetail {
2240
- path: string;
2241
- message: string;
2242
- /** Error code for i18n translation */
2243
- code?: string;
2244
- /** Interpolation values */
2245
- interpolation?: Record<string, string | number>;
2246
- }
2247
- /**
2248
- * Validation error with field-level details (400)
2249
- */
2250
- declare class ValidationError extends AppError {
2251
- readonly details: ValidationDetail[];
2252
- constructor(messageOrCode?: string | ErrorCode, details?: ValidationDetail[]);
2253
- }
2254
-
2255
2123
  /**
2256
2124
  * Query filter helpers.
2257
2125
  *
@@ -2682,4 +2550,4 @@ declare const core: {
2682
2550
 
2683
2551
  declare const version: string;
2684
2552
 
2685
- export { type Actions, type AppAbility, AppError, type AppErrorParams, type AppManifest, type AuditEntry, type AuditLogRow, type AuditQuery, type AuditService, BaseEntityService, type BatchReporter, type CaslRulesFunction, CollectionService, ComputedService, SingleService as ConfigService, ConflictError$1 as ConflictError, DagService, type DbEventPayload, type EntityController, type EntityHandler, type EntityRuntime, type EntityService, type ErrorCode, ErrorCodes, CollectionService as EventService, ExternalService, ForbiddenError$1 as ForbiddenError, type JwtPayload, NEXUS_CLIENT_HEADER, NXBadRequestError, NXConflictError, NXForbiddenError, NXNotFoundError, NXUnauthorizedError, type NexusConfig, type NexusEventName, type NexusEventPayload, type NexusEvents, NotFoundError$1 as NotFoundError, NxSettingsService, type RateLimitOptions, CollectionService as ReferenceService, type RefreshToken, type ResolvedConfig, type Role, type RoleWithCounts, type ServeSPAFunction, type ServeSPAOptions, SingleService, type SpaEntry, type StartOptions, type SubjectRegistry, type SubjectStrings, type Subjects, CollectionService as TempService, type TokenPair, TreeService, UnauthorizedError$1 as UnauthorizedError, type User, type UserPresence, type UserWithRoles, type UserWithoutPassword, type ValidationDetail, ValidationError, ViewService, ComputedService as VirtualService, applyFilters, asyncHandler, authAdmin, authorize, checkAbility, closeSocketIO, core, createApp, createBatchReporter, createChildLogger, createEntityRuntime, createEntityService, createLogger, createModuleRouters, createModuleServices, createNexusClientMiddleware, createRateLimit, createSSEHelper, db, defineAbilityFor, destroyDb, discoverModules, discoverPlugins, e, eventBridge, extractModuleManifests, extractPluginManifest, findEnvFile, getConfig, getConnectedUsers, getCoreManifest, getCoreModules, getDatabaseType, getDb, getIO, getLibPath, getModule, getModules, getOrderedModules, getPlugin, getPlugins, getPrismaClient, getProjectPath, getRegisteredSubjects, getServiceKey, getUserManifest, getUserModules, getUserSocketCount, hasModule, hasPlugin, hasUserApp, initSocketIO, isEntityRoom, isModuleManifest, isPluginManifest, isRunning, isSocketIOInitialized, isUserConnected, isValidSubject, loadCoreModules, loadNexusConfig, logger, m, nexusEvents, nxFeatureService, packRules, parseEntityRoom, rateLimiter, registerModule, registerPlugin, requireNexusClient, restart, serializePrisma, start, stop, unpackRules, validate, version };
2553
+ export { type Actions, type AppAbility, AppError, type AppManifest, type AuditEntry, type AuditLogRow, type AuditQuery, type AuditService, BaseEntityService, type BatchReporter, type CaslRulesFunction, CollectionService, ComputedService, SingleService as ConfigService, DagService, type DbEventPayload, type EntityController, type EntityHandler, type EntityRuntime, type EntityService, CollectionService as EventService, ExternalService, type JwtPayload, NEXUS_CLIENT_HEADER, NXBadRequestError, NXConflictError, NXForbiddenError, NXNotFoundError, NXUnauthorizedError, type NexusConfig, type NexusEventName, type NexusEventPayload, type NexusEvents, NxSettingsService, type RateLimitOptions, CollectionService as ReferenceService, type RefreshToken, type ResolvedConfig, type Role, type RoleWithCounts, type ServeSPAFunction, type ServeSPAOptions, SingleService, type SpaEntry, type StartOptions, type SubjectRegistry, type SubjectStrings, type Subjects, CollectionService as TempService, type TokenPair, TreeService, type User, type UserPresence, type UserWithRoles, type UserWithoutPassword, ViewService, ComputedService as VirtualService, applyFilters, asyncHandler, authAdmin, authorize, checkAbility, closeSocketIO, core, createApp, createBatchReporter, createChildLogger, createEntityRuntime, createEntityService, createLogger, createModuleRouters, createModuleServices, createNexusClientMiddleware, createRateLimit, createSSEHelper, db, defineAbilityFor, destroyDb, discoverModules, discoverPlugins, e, eventBridge, extractModuleManifests, extractPluginManifest, findEnvFile, getConfig, getConnectedUsers, getCoreManifest, getCoreModules, getDatabaseType, getDb, getIO, getLibPath, getModule, getModules, getOrderedModules, getPlugin, getPlugins, getPrismaClient, getProjectPath, getRegisteredSubjects, getServiceKey, getUserManifest, getUserModules, getUserSocketCount, hasModule, hasPlugin, hasUserApp, initSocketIO, isEntityRoom, isModuleManifest, isPluginManifest, isRunning, isSocketIOInitialized, isUserConnected, isValidSubject, loadCoreModules, loadNexusConfig, logger, m, nexusEvents, nxFeatureService, packRules, parseEntityRoom, rateLimiter, registerModule, registerPlugin, requireNexusClient, restart, serializePrisma, start, stop, unpackRules, validate, version };