@zintrust/core 0.1.19 → 0.1.21
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 +10 -10
- package/bin/zintrust-main.d.ts.map +1 -1
- package/bin/zintrust-main.js +9 -0
- package/package.json +3 -2
- package/public/error-pages/404.html +145 -0
- package/public/error-pages/500.html +266 -0
- package/public/error-pages/error.css +628 -0
- package/public/error-pages/error.js +428 -0
- package/public/zintrust.svg +30 -0
- package/routes/api.d.ts.map +1 -1
- package/routes/api.js +41 -17
- package/routes/metrics.d.ts +9 -0
- package/routes/metrics.d.ts.map +1 -0
- package/routes/metrics.js +20 -0
- package/routes/openapi.d.ts +9 -0
- package/routes/openapi.d.ts.map +1 -0
- package/routes/openapi.js +76 -0
- package/src/boot/Application.d.ts +2 -2
- package/src/boot/Application.d.ts.map +1 -1
- package/src/boot/Application.js +66 -13
- package/src/boot/Server.d.ts +3 -2
- package/src/boot/Server.d.ts.map +1 -1
- package/src/boot/Server.js +39 -165
- package/src/boot/bootstrap.js +2 -0
- package/src/cache/Cache.d.ts +1 -1
- package/src/cache/Cache.d.ts.map +1 -1
- package/src/cache/CacheDriver.d.ts +4 -0
- package/src/cache/CacheDriver.d.ts.map +1 -1
- package/src/cache/drivers/KVDriver.d.ts +1 -1
- package/src/cache/drivers/KVDriver.d.ts.map +1 -1
- package/src/cache/drivers/MemoryDriver.d.ts +1 -1
- package/src/cache/drivers/MemoryDriver.d.ts.map +1 -1
- package/src/cache/drivers/MemoryDriver.js +16 -0
- package/src/cache/drivers/MongoDriver.d.ts +1 -1
- package/src/cache/drivers/MongoDriver.d.ts.map +1 -1
- package/src/cache/drivers/RedisDriver.d.ts +1 -1
- package/src/cache/drivers/RedisDriver.d.ts.map +1 -1
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +10 -4
- package/src/cli/commands/AddCommand.d.ts +2 -2
- package/src/cli/commands/AddCommand.d.ts.map +1 -1
- package/src/cli/commands/AddCommand.js +135 -58
- package/src/cli/commands/ConfigCommand.d.ts +1 -1
- package/src/cli/commands/ConfigCommand.d.ts.map +1 -1
- package/src/cli/commands/CreateCommand.d.ts +15 -0
- package/src/cli/commands/CreateCommand.d.ts.map +1 -0
- package/src/cli/commands/CreateCommand.js +143 -0
- package/src/cli/commands/D1MigrateCommand.d.ts +1 -1
- package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/D1MigrateCommand.js +16 -20
- package/src/cli/commands/DbSeedCommand.d.ts +9 -0
- package/src/cli/commands/DbSeedCommand.d.ts.map +1 -0
- package/src/cli/commands/DbSeedCommand.js +171 -0
- package/src/cli/commands/DebugCommand.d.ts +1 -1
- package/src/cli/commands/DebugCommand.d.ts.map +1 -1
- package/src/cli/commands/FixCommand.d.ts +1 -1
- package/src/cli/commands/FixCommand.d.ts.map +1 -1
- package/src/cli/commands/JwtDevCommand.d.ts +8 -0
- package/src/cli/commands/JwtDevCommand.d.ts.map +1 -0
- package/src/cli/commands/JwtDevCommand.js +114 -0
- package/src/cli/commands/KeyGenerateCommand.d.ts +1 -1
- package/src/cli/commands/KeyGenerateCommand.d.ts.map +1 -1
- package/src/cli/commands/LogsCommand.d.ts +2 -2
- package/src/cli/commands/LogsCommand.d.ts.map +1 -1
- package/src/cli/commands/LogsCommand.js +36 -2
- package/src/cli/commands/MakeMailTemplateCommand.d.ts +1 -1
- package/src/cli/commands/MakeMailTemplateCommand.d.ts.map +1 -1
- package/src/cli/commands/MakeNotificationTemplateCommand.d.ts +1 -1
- package/src/cli/commands/MakeNotificationTemplateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.d.ts +1 -1
- package/src/cli/commands/MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.js +324 -35
- package/src/cli/commands/NewCommand.d.ts +1 -1
- package/src/cli/commands/NewCommand.d.ts.map +1 -1
- package/src/cli/commands/NewCommand.js +12 -4
- package/src/cli/commands/PluginCommand.d.ts +1 -1
- package/src/cli/commands/PluginCommand.d.ts.map +1 -1
- package/src/cli/commands/PrepareCommand.d.ts +1 -1
- package/src/cli/commands/PrepareCommand.d.ts.map +1 -1
- package/src/cli/commands/QACommand.d.ts +2 -2
- package/src/cli/commands/QACommand.d.ts.map +1 -1
- package/src/cli/commands/RoutesCommand.d.ts +10 -0
- package/src/cli/commands/RoutesCommand.d.ts.map +1 -0
- package/src/cli/commands/RoutesCommand.js +242 -0
- package/src/cli/commands/SimulateCommand.d.ts +1 -1
- package/src/cli/commands/SimulateCommand.d.ts.map +1 -1
- package/src/cli/commands/index.d.ts +3 -0
- package/src/cli/commands/index.d.ts.map +1 -1
- package/src/cli/commands/index.js +3 -0
- package/src/cli/config/ConfigManager.d.ts +1 -1
- package/src/cli/config/ConfigManager.d.ts.map +1 -1
- package/src/cli/config/ConfigValidator.d.ts +1 -1
- package/src/cli/config/ConfigValidator.d.ts.map +1 -1
- package/src/cli/config/ConfigValidator.js +1 -1
- package/src/cli/d1/D1SqlMigrations.d.ts +20 -0
- package/src/cli/d1/D1SqlMigrations.d.ts.map +1 -0
- package/src/cli/d1/D1SqlMigrations.js +229 -0
- package/src/cli/d1/WranglerConfig.d.ts +4 -0
- package/src/cli/d1/WranglerConfig.d.ts.map +1 -0
- package/src/cli/d1/WranglerConfig.js +122 -0
- package/src/cli/d1/WranglerD1.d.ts +11 -0
- package/src/cli/d1/WranglerD1.d.ts.map +1 -0
- package/src/cli/d1/WranglerD1.js +16 -0
- package/src/cli/scaffolding/ControllerGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/ControllerGenerator.js +76 -26
- package/src/cli/scaffolding/FactoryGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/FactoryGenerator.js +3 -1
- package/src/cli/scaffolding/GovernanceScaffolder.d.ts +23 -0
- package/src/cli/scaffolding/GovernanceScaffolder.d.ts.map +1 -0
- package/src/cli/scaffolding/GovernanceScaffolder.js +327 -0
- package/src/cli/scaffolding/MigrationGenerator.d.ts +10 -0
- package/src/cli/scaffolding/MigrationGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/MigrationGenerator.js +137 -51
- package/src/cli/scaffolding/ModelGenerator.js +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.js +36 -4
- package/src/cli/scaffolding/RouteGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/RouteGenerator.js +79 -43
- package/src/cli/scaffolding/SeederGenerator.d.ts +5 -0
- package/src/cli/scaffolding/SeederGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/SeederGenerator.js +63 -15
- package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ServiceScaffolder.js +28 -7
- package/src/cli/scaffolding/index.d.ts +2 -0
- package/src/cli/scaffolding/index.d.ts.map +1 -1
- package/src/cli/scaffolding/index.js +1 -0
- package/src/common/index.d.ts +8 -0
- package/src/common/index.d.ts.map +1 -1
- package/src/common/index.js +28 -0
- package/src/common/utility.d.ts +38 -0
- package/src/common/utility.d.ts.map +1 -0
- package/src/common/utility.js +101 -0
- package/src/config/FileLogWriter.d.ts +2 -1
- package/src/config/FileLogWriter.d.ts.map +1 -1
- package/src/config/FileLogWriter.js +83 -2
- package/src/config/app.d.ts.map +1 -1
- package/src/config/app.js +3 -1
- package/src/config/broadcast.d.ts +14 -28
- package/src/config/broadcast.d.ts.map +1 -1
- package/src/config/broadcast.js +69 -35
- package/src/config/cache.d.ts +13 -45
- package/src/config/cache.d.ts.map +1 -1
- package/src/config/cache.js +69 -25
- package/src/config/cloudflare.d.ts +1 -1
- package/src/config/cloudflare.d.ts.map +1 -1
- package/src/config/database.d.ts +22 -64
- package/src/config/database.d.ts.map +1 -1
- package/src/config/database.js +191 -37
- package/src/config/env.d.ts +12 -0
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +14 -0
- package/src/config/index.d.ts +33 -137
- package/src/config/index.d.ts.map +1 -1
- package/src/config/logging/KvLogger.js +1 -1
- package/src/config/logging/SlackLogger.js +2 -2
- package/src/config/mail.d.ts +19 -55
- package/src/config/mail.d.ts.map +1 -1
- package/src/config/mail.js +63 -21
- package/src/config/middleware.d.ts +44 -1
- package/src/config/middleware.d.ts.map +1 -1
- package/src/config/middleware.js +157 -5
- package/src/config/notification.d.ts +14 -27
- package/src/config/notification.d.ts.map +1 -1
- package/src/config/notification.js +82 -36
- package/src/config/queue.d.ts +21 -51
- package/src/config/queue.d.ts.map +1 -1
- package/src/config/queue.js +72 -27
- package/src/config/security.d.ts +1 -1
- package/src/config/security.js +1 -1
- package/src/config/storage.d.ts +27 -34
- package/src/config/storage.d.ts.map +1 -1
- package/src/config/storage.js +97 -56
- package/src/config/type.d.ts +13 -2
- package/src/config/type.d.ts.map +1 -1
- package/src/events/EventDispatcher.d.ts.map +1 -1
- package/src/events/EventDispatcher.js +6 -4
- package/src/exceptions/ZintrustError.d.ts +7 -0
- package/src/exceptions/ZintrustError.d.ts.map +1 -1
- package/src/exceptions/ZintrustError.js +56 -0
- package/src/features/Auth.d.ts +1 -1
- package/src/features/Auth.d.ts.map +1 -1
- package/src/features/Auth.js +3 -3
- package/src/features/Queue.js +1 -1
- package/src/functions/cloudflare.d.ts.map +1 -1
- package/src/functions/cloudflare.js +3 -14
- package/src/functions/deno.d.ts.map +1 -1
- package/src/functions/deno.js +3 -14
- package/src/functions/lambda.d.ts.map +1 -1
- package/src/functions/lambda.js +3 -14
- package/src/health/StartupHealthChecks.js +1 -1
- package/src/http/Controller.d.ts +2 -2
- package/src/http/Controller.d.ts.map +1 -1
- package/src/http/FileUpload.d.ts +68 -0
- package/src/http/FileUpload.d.ts.map +1 -0
- package/src/http/FileUpload.js +120 -0
- package/src/http/Kernel.d.ts +5 -5
- package/src/http/Kernel.d.ts.map +1 -1
- package/src/http/Kernel.js +139 -23
- package/src/http/Request.d.ts +20 -1
- package/src/http/Request.d.ts.map +1 -1
- package/src/http/Request.js +23 -0
- package/src/http/RequestContext.d.ts +6 -0
- package/src/http/RequestContext.d.ts.map +1 -1
- package/src/http/RequestContext.js +77 -1
- package/src/http/Response.d.ts +1 -1
- package/src/http/Response.d.ts.map +1 -1
- package/src/http/ValidationHelper.d.ts +78 -0
- package/src/http/ValidationHelper.d.ts.map +1 -0
- package/src/http/ValidationHelper.js +121 -0
- package/src/http/error-pages/ErrorPageRenderer.d.ts +17 -0
- package/src/http/error-pages/ErrorPageRenderer.d.ts.map +1 -0
- package/src/http/error-pages/ErrorPageRenderer.js +88 -0
- package/src/http/middleware/BodyParsingMiddleware.d.ts +12 -0
- package/src/http/middleware/BodyParsingMiddleware.d.ts.map +1 -0
- package/src/http/middleware/BodyParsingMiddleware.js +251 -0
- package/src/http/middleware/FileUploadMiddleware.d.ts +12 -0
- package/src/http/middleware/FileUploadMiddleware.d.ts.map +1 -0
- package/src/http/middleware/FileUploadMiddleware.js +74 -0
- package/src/http/parsers/BodyParsers.d.ts +32 -0
- package/src/http/parsers/BodyParsers.d.ts.map +1 -0
- package/src/http/parsers/BodyParsers.js +159 -0
- package/src/http/parsers/MultipartParser.d.ts +33 -0
- package/src/http/parsers/MultipartParser.d.ts.map +1 -0
- package/src/http/parsers/MultipartParser.js +156 -0
- package/src/http/parsers/MultipartParserRegistry.d.ts +34 -0
- package/src/http/parsers/MultipartParserRegistry.d.ts.map +1 -0
- package/src/http/parsers/MultipartParserRegistry.js +20 -0
- package/src/http/validated.d.ts +12 -0
- package/src/http/validated.d.ts.map +1 -0
- package/src/http/validated.js +41 -0
- package/src/index.d.ts +73 -12
- package/src/index.d.ts.map +1 -1
- package/src/index.js +60 -5
- package/src/microservices/PostgresAdapter.d.ts.map +1 -1
- package/src/microservices/PostgresAdapter.js +0 -1
- package/src/microservices/RequestTracingMiddleware.d.ts +2 -2
- package/src/microservices/RequestTracingMiddleware.d.ts.map +1 -1
- package/src/microservices/RequestTracingMiddleware.js +3 -0
- package/src/microservices/ServiceAuthMiddleware.d.ts +2 -2
- package/src/microservices/ServiceAuthMiddleware.d.ts.map +1 -1
- package/src/middleware/AuthMiddleware.d.ts +10 -0
- package/src/middleware/AuthMiddleware.d.ts.map +1 -0
- package/src/middleware/AuthMiddleware.js +16 -0
- package/src/middleware/CsrfMiddleware.d.ts +11 -1
- package/src/middleware/CsrfMiddleware.d.ts.map +1 -1
- package/src/middleware/CsrfMiddleware.js +33 -0
- package/src/middleware/JwtAuthMiddleware.d.ts +11 -0
- package/src/middleware/JwtAuthMiddleware.d.ts.map +1 -0
- package/src/middleware/JwtAuthMiddleware.js +73 -0
- package/src/middleware/LoggingMiddleware.d.ts.map +1 -1
- package/src/middleware/LoggingMiddleware.js +8 -3
- package/src/middleware/MiddlewareStack.d.ts +2 -2
- package/src/middleware/MiddlewareStack.d.ts.map +1 -1
- package/src/middleware/RateLimiter.d.ts +2 -2
- package/src/middleware/RateLimiter.d.ts.map +1 -1
- package/src/middleware/SanitizeBodyMiddleware.d.ts +12 -0
- package/src/middleware/SanitizeBodyMiddleware.d.ts.map +1 -0
- package/src/middleware/SanitizeBodyMiddleware.js +31 -0
- package/src/middleware/SecurityMiddleware.d.ts +1 -1
- package/src/middleware/SecurityMiddleware.d.ts.map +1 -1
- package/src/middleware/SessionMiddleware.d.ts +1 -1
- package/src/middleware/SessionMiddleware.d.ts.map +1 -1
- package/src/middleware/ValidationMiddleware.d.ts +25 -0
- package/src/middleware/ValidationMiddleware.d.ts.map +1 -0
- package/src/middleware/ValidationMiddleware.js +251 -0
- package/src/migrations/MigrationDiscovery.d.ts +5 -0
- package/src/migrations/MigrationDiscovery.d.ts.map +1 -0
- package/src/migrations/MigrationDiscovery.js +16 -0
- package/src/migrations/MigrationLoader.d.ts +5 -0
- package/src/migrations/MigrationLoader.d.ts.map +1 -0
- package/src/migrations/MigrationLoader.js +43 -0
- package/src/migrations/MigrationLock.d.ts +4 -0
- package/src/migrations/MigrationLock.d.ts.map +1 -0
- package/src/migrations/MigrationLock.js +33 -0
- package/src/migrations/Migrator.d.ts +23 -0
- package/src/migrations/Migrator.d.ts.map +1 -0
- package/src/migrations/Migrator.js +4 -0
- package/src/migrations/MigratorFactory.d.ts +25 -0
- package/src/migrations/MigratorFactory.d.ts.map +1 -0
- package/src/migrations/MigratorFactory.js +339 -0
- package/src/migrations/schema/Blueprint.d.ts +5 -0
- package/src/migrations/schema/Blueprint.d.ts.map +1 -0
- package/src/migrations/schema/Blueprint.js +189 -0
- package/src/migrations/schema/Schema.d.ts +8 -0
- package/src/migrations/schema/Schema.d.ts.map +1 -0
- package/src/migrations/schema/Schema.js +141 -0
- package/src/migrations/schema/SchemaCompiler.d.ts +20 -0
- package/src/migrations/schema/SchemaCompiler.d.ts.map +1 -0
- package/src/migrations/schema/SchemaCompiler.js +262 -0
- package/src/migrations/schema/index.d.ts +5 -0
- package/src/migrations/schema/index.d.ts.map +1 -0
- package/src/migrations/schema/index.js +3 -0
- package/src/migrations/schema/types.d.ts +86 -0
- package/src/migrations/schema/types.d.ts.map +1 -0
- package/src/migrations/schema/types.js +1 -0
- package/src/migrations/types.d.ts +45 -0
- package/src/migrations/types.d.ts.map +1 -0
- package/src/migrations/types.js +1 -0
- package/src/node-singletons/crypto.d.ts +1 -1
- package/src/node-singletons/crypto.d.ts.map +1 -1
- package/src/node-singletons/crypto.js +1 -1
- package/src/node-singletons/fs.d.ts +2 -2
- package/src/node-singletons/fs.d.ts.map +1 -1
- package/src/node-singletons/fs.js +1 -1
- package/src/node-singletons/util.d.ts +6 -0
- package/src/node-singletons/util.d.ts.map +1 -0
- package/src/node-singletons/util.js +5 -0
- package/src/node.d.ts +3 -1
- package/src/node.d.ts.map +1 -1
- package/src/node.js +6 -2
- package/src/observability/OpenTelemetry.d.ts +62 -0
- package/src/observability/OpenTelemetry.d.ts.map +1 -0
- package/src/observability/OpenTelemetry.js +167 -0
- package/src/observability/PrometheusMetrics.d.ts +25 -0
- package/src/observability/PrometheusMetrics.d.ts.map +1 -0
- package/src/observability/PrometheusMetrics.js +114 -0
- package/src/openapi/OpenApiGenerator.d.ts +68 -0
- package/src/openapi/OpenApiGenerator.d.ts.map +1 -0
- package/src/openapi/OpenApiGenerator.js +287 -0
- package/src/orm/Database.d.ts +5 -2
- package/src/orm/Database.d.ts.map +1 -1
- package/src/orm/Database.js +219 -63
- package/src/orm/DatabaseAdapter.d.ts +14 -0
- package/src/orm/DatabaseAdapter.d.ts.map +1 -1
- package/src/orm/DatabaseAdapterRegistry.d.ts.map +1 -1
- package/src/orm/DatabaseAdapterRegistry.js +3 -1
- package/src/orm/DatabaseRuntimeRegistration.d.ts.map +1 -1
- package/src/orm/DatabaseRuntimeRegistration.js +12 -0
- package/src/orm/Model.d.ts +30 -2
- package/src/orm/Model.d.ts.map +1 -1
- package/src/orm/Model.js +255 -62
- package/src/orm/QueryBuilder.d.ts +22 -1
- package/src/orm/QueryBuilder.d.ts.map +1 -1
- package/src/orm/QueryBuilder.js +406 -99
- package/src/orm/Relationships.d.ts +7 -1
- package/src/orm/Relationships.d.ts.map +1 -1
- package/src/orm/Relationships.js +18 -0
- package/src/orm/SchemaCompiler.d.ts +9 -0
- package/src/orm/SchemaCompiler.d.ts.map +1 -0
- package/src/orm/SchemaCompiler.js +145 -0
- package/src/orm/adapters/D1Adapter.d.ts +1 -1
- package/src/orm/adapters/D1Adapter.d.ts.map +1 -1
- package/src/orm/adapters/MySQLAdapter.d.ts +1 -1
- package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/MySQLAdapter.js +88 -69
- package/src/orm/adapters/PostgreSQLAdapter.d.ts +1 -1
- package/src/orm/adapters/PostgreSQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/PostgreSQLAdapter.js +88 -69
- package/src/orm/adapters/SQLServerAdapter.d.ts +1 -1
- package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLiteAdapter.d.ts +1 -1
- package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLiteAdapter.js +59 -3
- package/src/orm/maintenance/SqliteMaintenance.d.ts +5 -0
- package/src/orm/maintenance/SqliteMaintenance.d.ts.map +1 -0
- package/src/orm/maintenance/SqliteMaintenance.js +14 -0
- package/src/orm/migrations/MigrationStore.d.ts +38 -0
- package/src/orm/migrations/MigrationStore.d.ts.map +1 -0
- package/src/orm/migrations/MigrationStore.js +157 -0
- package/src/performance/CodeGenerationBenchmark.d.ts.map +1 -1
- package/src/performance/Optimizer.d.ts +7 -6
- package/src/performance/Optimizer.d.ts.map +1 -1
- package/src/performance/Optimizer.js +170 -55
- package/src/profiling/MemoryProfiler.d.ts +1 -1
- package/src/profiling/MemoryProfiler.d.ts.map +1 -1
- package/src/profiling/N1Detector.d.ts +1 -1
- package/src/profiling/N1Detector.d.ts.map +1 -1
- package/src/profiling/QueryLogger.d.ts +1 -1
- package/src/profiling/QueryLogger.d.ts.map +1 -1
- package/src/profiling/RequestProfiler.d.ts +3 -3
- package/src/profiling/RequestProfiler.d.ts.map +1 -1
- package/src/routes/metrics.d.ts +2 -0
- package/src/routes/metrics.d.ts.map +1 -0
- package/src/routes/metrics.js +1 -0
- package/src/routing/CoreRoutes.d.ts +12 -0
- package/src/routing/CoreRoutes.d.ts.map +1 -0
- package/src/routing/CoreRoutes.js +151 -0
- package/src/routing/RouteRegistry.d.ts +39 -0
- package/src/routing/RouteRegistry.d.ts.map +1 -0
- package/src/routing/RouteRegistry.js +44 -0
- package/src/routing/Router.d.ts +26 -9
- package/src/routing/Router.d.ts.map +1 -1
- package/src/routing/Router.js +79 -35
- package/src/routing/common.d.ts +15 -0
- package/src/routing/common.d.ts.map +1 -0
- package/src/routing/common.js +47 -0
- package/src/routing/doc.d.ts +27 -0
- package/src/routing/doc.d.ts.map +1 -0
- package/src/routing/doc.js +110 -0
- package/src/routing/error.d.ts +21 -0
- package/src/routing/error.d.ts.map +1 -0
- package/src/routing/error.js +126 -0
- package/src/routing/errorPages.d.ts +14 -0
- package/src/routing/errorPages.d.ts.map +1 -0
- package/src/routing/errorPages.js +103 -0
- package/src/routing/publicRoot.d.ts +27 -0
- package/src/routing/publicRoot.d.ts.map +1 -0
- package/src/routing/publicRoot.js +110 -0
- package/src/runtime/PluginAutoImports.d.ts +21 -0
- package/src/runtime/PluginAutoImports.d.ts.map +1 -0
- package/src/runtime/PluginAutoImports.js +59 -0
- package/src/runtime/PluginManager.d.ts +1 -5
- package/src/runtime/PluginManager.d.ts.map +1 -1
- package/src/runtime/PluginManager.js +25 -18
- package/src/runtime/RuntimeDetector.d.ts +1 -1
- package/src/runtime/RuntimeDetector.d.ts.map +1 -1
- package/src/runtime/StartupConfigFileRegistry.d.ts +20 -0
- package/src/runtime/StartupConfigFileRegistry.d.ts.map +1 -0
- package/src/runtime/StartupConfigFileRegistry.js +44 -0
- package/src/runtime/adapters/CloudflareAdapter.d.ts +1 -1
- package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/CloudflareAdapter.js +1 -1
- package/src/runtime/adapters/DenoAdapter.d.ts +1 -1
- package/src/runtime/adapters/DenoAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/DenoAdapter.js +1 -1
- package/src/runtime/adapters/LambdaAdapter.d.ts +1 -1
- package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/LambdaAdapter.js +1 -1
- package/src/runtime/adapters/NodeServerAdapter.d.ts +1 -1
- package/src/runtime/adapters/NodeServerAdapter.d.ts.map +1 -1
- package/src/runtime/getKernel.d.ts +9 -0
- package/src/runtime/getKernel.d.ts.map +1 -0
- package/src/runtime/getKernel.js +27 -0
- package/src/runtime/useFileLoader.d.ts +26 -0
- package/src/runtime/useFileLoader.d.ts.map +1 -0
- package/src/runtime/useFileLoader.js +188 -0
- package/src/scripts/TemplateImportsCheck.js +40 -0
- package/src/scripts/TemplateSync.js +90 -24
- package/src/security/Encryptor.d.ts.map +1 -1
- package/src/security/Encryptor.js +64 -7
- package/src/security/JwtManager.d.ts +1 -0
- package/src/security/JwtManager.d.ts.map +1 -1
- package/src/security/JwtManager.js +33 -0
- package/src/security/Sanitizer.d.ts +76 -0
- package/src/security/Sanitizer.d.ts.map +1 -0
- package/src/security/Sanitizer.js +412 -0
- package/src/security/TokenRevocation.d.ts +7 -0
- package/src/security/TokenRevocation.d.ts.map +1 -0
- package/src/security/TokenRevocation.js +57 -0
- package/src/security/XssProtection.d.ts.map +1 -1
- package/src/security/XssProtection.js +62 -14
- package/src/seeders/SeederDiscovery.d.ts +5 -0
- package/src/seeders/SeederDiscovery.d.ts.map +1 -0
- package/src/seeders/SeederDiscovery.js +21 -0
- package/src/seeders/SeederLoader.d.ts +5 -0
- package/src/seeders/SeederLoader.d.ts.map +1 -0
- package/src/seeders/SeederLoader.js +60 -0
- package/src/seeders/types.d.ts +18 -0
- package/src/seeders/types.d.ts.map +1 -0
- package/src/seeders/types.js +1 -0
- package/src/session/SessionManager.js +1 -1
- package/src/templates/adapters/MySQLAdapter.ts.tpl +109 -85
- package/src/templates/adapters/PostgreSQLAdapter.ts.tpl +129 -88
- package/src/templates/adapters/SQLServerAdapter.ts.tpl +5 -9
- package/src/templates/adapters/SQLiteAdapter.ts.tpl +78 -11
- package/src/templates/features/Queue.ts.tpl +3 -2
- package/src/templates/project/basic/app/Controllers/AuthController.ts.tpl +217 -0
- package/src/templates/project/basic/app/Controllers/UserController.ts.tpl +1 -12
- package/src/templates/project/basic/app/Types/controller.ts.tpl +46 -0
- package/src/templates/project/basic/config/FileLogWriter.ts.tpl +5 -236
- package/src/templates/project/basic/config/SecretsManager.ts.tpl +10 -447
- package/src/templates/project/basic/config/StartupConfigValidator.ts.tpl +9 -268
- package/src/templates/project/basic/config/app.ts.tpl +13 -153
- package/src/templates/project/basic/config/broadcast.ts.tpl +29 -126
- package/src/templates/project/basic/config/cache.ts.tpl +12 -70
- package/src/templates/project/basic/config/cloudflare.ts.tpl +4 -39
- package/src/templates/project/basic/config/constants.ts.tpl +9 -65
- package/src/templates/project/basic/config/database.ts.tpl +66 -123
- package/src/templates/project/basic/config/env.ts.tpl +5 -169
- package/src/templates/project/basic/config/features.ts.tpl +6 -54
- package/src/templates/project/basic/config/index.ts.tpl +8 -23
- package/src/templates/project/basic/config/logging/HttpLogger.ts.tpl +7 -114
- package/src/templates/project/basic/config/mail.ts.tpl +9 -62
- package/src/templates/project/basic/config/microservices.ts.tpl +11 -97
- package/src/templates/project/basic/config/middleware.ts.tpl +25 -43
- package/src/templates/project/basic/config/notification.ts.tpl +13 -114
- package/src/templates/project/basic/config/queue.ts.tpl +9 -40
- package/src/templates/project/basic/config/security.ts.tpl +11 -163
- package/src/templates/project/basic/config/startup.ts.tpl +10 -21
- package/src/templates/project/basic/config/storage.ts.tpl +57 -137
- package/src/templates/project/basic/config/type.ts.tpl +32 -451
- package/src/templates/project/basic/database/factories/UserFactory.ts.tpl +80 -0
- package/src/templates/project/basic/database/migrations/create_tasks_table.ts.tpl +28 -0
- package/src/templates/project/basic/database/migrations/create_users_table.ts.tpl +29 -0
- package/src/templates/project/basic/database/seeders/DatabaseSeeder.ts.tpl +19 -0
- package/src/templates/project/basic/database/seeders/UserSeeder.ts.tpl +18 -0
- package/src/templates/project/basic/database/seeders/index.ts.tpl +2 -0
- package/src/templates/project/basic/routes/api.ts.tpl +71 -33
- package/src/templates/project/basic/routes/metrics.ts.tpl +22 -0
- package/src/templates/project/basic/src/index.ts.tpl +3 -0
- package/src/templates/project/basic/tsconfig.json.tpl +12 -11
- package/src/testing/TestEnvironment.d.ts +40 -0
- package/src/testing/TestEnvironment.d.ts.map +1 -0
- package/src/testing/TestEnvironment.js +141 -0
- package/src/testing/TestHttp.d.ts +29 -0
- package/src/testing/TestHttp.d.ts.map +1 -0
- package/src/testing/TestHttp.js +96 -0
- package/src/testing/index.d.ts +5 -0
- package/src/testing/index.d.ts.map +1 -0
- package/src/testing/index.js +2 -0
- package/src/time/DateTime.d.ts +181 -0
- package/src/time/DateTime.d.ts.map +1 -0
- package/src/time/DateTime.js +300 -0
- package/src/time/index.d.ts +7 -0
- package/src/time/index.d.ts.map +1 -0
- package/src/time/index.js +5 -0
- package/src/tools/http/Http.d.ts.map +1 -1
- package/src/tools/http/Http.js +4 -0
- package/src/tools/mail/drivers/Smtp.js +1 -1
- package/src/tools/queue/drivers/InMemory.d.ts +1 -1
- package/src/tools/queue/drivers/InMemory.d.ts.map +1 -1
- package/src/tools/queue/drivers/InMemory.js +1 -1
- package/src/tools/queue/drivers/Redis.d.ts +1 -1
- package/src/tools/queue/drivers/Redis.d.ts.map +1 -1
- package/src/tools/queue/drivers/Redis.js +1 -1
- package/src/validation/ValidationError.d.ts.map +1 -1
- package/src/validation/ValidationError.js +4 -2
- package/src/validation/Validator.d.ts +49 -16
- package/src/validation/Validator.d.ts.map +1 -1
- package/src/validation/Validator.js +307 -5
- package/src/common/uuid.d.ts +0 -3
- package/src/common/uuid.d.ts.map +0 -1
- package/src/common/uuid.js +0 -30
- package/src/templates/project/basic/.env.example.tpl +0 -74
- package/src/templates/project/basic/.env.tpl +0 -166
- package/src/templates/project/basic/config/logging/KvLogger.ts.tpl +0 -181
- package/src/templates/project/basic/config/logging/SlackLogger.ts.tpl +0 -156
- package/src/templates/project/basic/database/migrations/index.ts.tpl +0 -2
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DateTime - Immutable Date/Time Utilities
|
|
3
|
+
* Provides chainable, type-safe date/time operations with multiple format support
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* DateTime interface defining all available operations
|
|
7
|
+
*/
|
|
8
|
+
export interface IDateTime {
|
|
9
|
+
/**
|
|
10
|
+
* Get the underlying Date object
|
|
11
|
+
*/
|
|
12
|
+
toDate(): Date;
|
|
13
|
+
/**
|
|
14
|
+
* Format the date using pattern tokens
|
|
15
|
+
* Supported tokens: YYYY, YY, MMMM, MMM, MM, M, DD, D, HH, H, mm, ss, SSS
|
|
16
|
+
*/
|
|
17
|
+
format(pattern: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Convert to ISO 8601 string (YYYY-MM-DDTHH:mm:ss.sssZ)
|
|
20
|
+
*/
|
|
21
|
+
toISO(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Convert to RFC 3339 string (same as ISO 8601)
|
|
24
|
+
*/
|
|
25
|
+
toRFC3339(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Get human-readable relative time (e.g., "2 hours ago", "in 3 days")
|
|
28
|
+
*/
|
|
29
|
+
ago(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Get relative time from a specific date
|
|
32
|
+
*/
|
|
33
|
+
relative(other: Date | IDateTime): string;
|
|
34
|
+
/**
|
|
35
|
+
* Add days to the date (returns new IDateTime)
|
|
36
|
+
*/
|
|
37
|
+
addDays(days: number): IDateTime;
|
|
38
|
+
/**
|
|
39
|
+
* Add hours to the date (returns new IDateTime)
|
|
40
|
+
*/
|
|
41
|
+
addHours(hours: number): IDateTime;
|
|
42
|
+
/**
|
|
43
|
+
* Add minutes to the date (returns new IDateTime)
|
|
44
|
+
*/
|
|
45
|
+
addMinutes(minutes: number): IDateTime;
|
|
46
|
+
/**
|
|
47
|
+
* Add seconds to the date (returns new IDateTime)
|
|
48
|
+
*/
|
|
49
|
+
addSeconds(seconds: number): IDateTime;
|
|
50
|
+
/**
|
|
51
|
+
* Add months to the date (returns new IDateTime)
|
|
52
|
+
*/
|
|
53
|
+
addMonths(months: number): IDateTime;
|
|
54
|
+
/**
|
|
55
|
+
* Add years to the date (returns new IDateTime)
|
|
56
|
+
*/
|
|
57
|
+
addYears(years: number): IDateTime;
|
|
58
|
+
/**
|
|
59
|
+
* Check if this date is before another date
|
|
60
|
+
*/
|
|
61
|
+
isBefore(other: Date | IDateTime): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Check if this date is after another date
|
|
64
|
+
*/
|
|
65
|
+
isAfter(other: Date | IDateTime): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Check if this date is the same as another date (ignoring time)
|
|
68
|
+
*/
|
|
69
|
+
isSame(other: Date | IDateTime): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Check if this date is between two dates (inclusive)
|
|
72
|
+
*/
|
|
73
|
+
isBetween(start: Date | IDateTime, end: Date | IDateTime): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Get difference in milliseconds from another date
|
|
76
|
+
*/
|
|
77
|
+
diffMs(other: Date | IDateTime): number;
|
|
78
|
+
/**
|
|
79
|
+
* Get difference in seconds from another date
|
|
80
|
+
*/
|
|
81
|
+
diffSeconds(other: Date | IDateTime): number;
|
|
82
|
+
/**
|
|
83
|
+
* Get difference in minutes from another date
|
|
84
|
+
*/
|
|
85
|
+
diffMinutes(other: Date | IDateTime): number;
|
|
86
|
+
/**
|
|
87
|
+
* Get difference in hours from another date
|
|
88
|
+
*/
|
|
89
|
+
diffHours(other: Date | IDateTime): number;
|
|
90
|
+
/**
|
|
91
|
+
* Get difference in days from another date
|
|
92
|
+
*/
|
|
93
|
+
diffDays(other: Date | IDateTime): number;
|
|
94
|
+
/**
|
|
95
|
+
* Start of day (00:00:00)
|
|
96
|
+
*/
|
|
97
|
+
startOfDay(): IDateTime;
|
|
98
|
+
/**
|
|
99
|
+
* End of day (23:59:59)
|
|
100
|
+
*/
|
|
101
|
+
endOfDay(): IDateTime;
|
|
102
|
+
/**
|
|
103
|
+
* Start of month
|
|
104
|
+
*/
|
|
105
|
+
startOfMonth(): IDateTime;
|
|
106
|
+
/**
|
|
107
|
+
* End of month
|
|
108
|
+
*/
|
|
109
|
+
endOfMonth(): IDateTime;
|
|
110
|
+
/**
|
|
111
|
+
* Clone this datetime
|
|
112
|
+
*/
|
|
113
|
+
clone(): IDateTime;
|
|
114
|
+
/**
|
|
115
|
+
* Get Unix timestamp (milliseconds since epoch)
|
|
116
|
+
*/
|
|
117
|
+
getTime(): number;
|
|
118
|
+
/**
|
|
119
|
+
* Get year
|
|
120
|
+
*/
|
|
121
|
+
getYear(): number;
|
|
122
|
+
/**
|
|
123
|
+
* Get month (0-11)
|
|
124
|
+
*/
|
|
125
|
+
getMonth(): number;
|
|
126
|
+
/**
|
|
127
|
+
* Get day of month (1-31)
|
|
128
|
+
*/
|
|
129
|
+
getDate(): number;
|
|
130
|
+
/**
|
|
131
|
+
* Get hours (0-23)
|
|
132
|
+
*/
|
|
133
|
+
getHours(): number;
|
|
134
|
+
/**
|
|
135
|
+
* Get minutes (0-59)
|
|
136
|
+
*/
|
|
137
|
+
getMinutes(): number;
|
|
138
|
+
/**
|
|
139
|
+
* Get seconds (0-59)
|
|
140
|
+
*/
|
|
141
|
+
getSeconds(): number;
|
|
142
|
+
/**
|
|
143
|
+
* Get milliseconds (0-999)
|
|
144
|
+
*/
|
|
145
|
+
getMilliseconds(): number;
|
|
146
|
+
/**
|
|
147
|
+
* Get day of week (0=Sunday, 6=Saturday)
|
|
148
|
+
*/
|
|
149
|
+
getDayOfWeek(): number;
|
|
150
|
+
/**
|
|
151
|
+
* Get day of year (1-366)
|
|
152
|
+
*/
|
|
153
|
+
getDayOfYear(): number;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* DateTime namespace - sealed namespace object grouping all DateTime operations
|
|
157
|
+
* Immutable by design - all operations return new IDateTime instances
|
|
158
|
+
*/
|
|
159
|
+
export declare const DateTime: Readonly<{
|
|
160
|
+
/**
|
|
161
|
+
* Create a DateTime from a Date object
|
|
162
|
+
*/
|
|
163
|
+
create(date?: Date): IDateTime;
|
|
164
|
+
/**
|
|
165
|
+
* Get current DateTime
|
|
166
|
+
*/
|
|
167
|
+
now(): IDateTime;
|
|
168
|
+
/**
|
|
169
|
+
* Parse a date string
|
|
170
|
+
*/
|
|
171
|
+
parse(dateString: string): IDateTime;
|
|
172
|
+
/**
|
|
173
|
+
* Create DateTime from timestamp (milliseconds since epoch)
|
|
174
|
+
*/
|
|
175
|
+
fromTimestamp(timestamp: number): IDateTime;
|
|
176
|
+
/**
|
|
177
|
+
* Create DateTime from components
|
|
178
|
+
*/
|
|
179
|
+
fromComponents(year: number, month: number, day?: number, hours?: number, minutes?: number, seconds?: number): IDateTime;
|
|
180
|
+
}>;
|
|
181
|
+
//# sourceMappingURL=DateTime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateTime.d.ts","sourceRoot":"","sources":["../../../src/time/DateTime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,MAAM,IAAI,IAAI,CAAC;IAEf;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAEhC;;OAEG;IACH,KAAK,IAAI,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,IAAI,MAAM,CAAC;IAEpB;;OAEG;IACH,GAAG,IAAI,MAAM,CAAC;IAEd;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC;IAE1C;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAEjC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAEvC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAEvC;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAErC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC;IAE3C;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC;IAE1C;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC;IAEzC;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,EAAE,GAAG,EAAE,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC;IAEnE;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC;IAExC;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC;IAE7C;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC;IAE7C;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC;IAE3C;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC;IAE1C;;OAEG;IACH,UAAU,IAAI,SAAS,CAAC;IAExB;;OAEG;IACH,QAAQ,IAAI,SAAS,CAAC;IAEtB;;OAEG;IACH,YAAY,IAAI,SAAS,CAAC;IAE1B;;OAEG;IACH,UAAU,IAAI,SAAS,CAAC;IAExB;;OAEG;IACH,KAAK,IAAI,SAAS,CAAC;IAEnB;;OAEG;IACH,OAAO,IAAI,MAAM,CAAC;IAElB;;OAEG;IACH,OAAO,IAAI,MAAM,CAAC;IAElB;;OAEG;IACH,QAAQ,IAAI,MAAM,CAAC;IAEnB;;OAEG;IACH,OAAO,IAAI,MAAM,CAAC;IAElB;;OAEG;IACH,QAAQ,IAAI,MAAM,CAAC;IAEnB;;OAEG;IACH,UAAU,IAAI,MAAM,CAAC;IAErB;;OAEG;IACH,UAAU,IAAI,MAAM,CAAC;IAErB;;OAEG;IACH,eAAe,IAAI,MAAM,CAAC;IAE1B;;OAEG;IACH,YAAY,IAAI,MAAM,CAAC;IAEvB;;OAEG;IACH,YAAY,IAAI,MAAM,CAAC;CACxB;AAsTD;;;GAGG;AACH,eAAO,MAAM,QAAQ;IACnB;;OAEG;kBACU,IAAI,GAAgB,SAAS;IAI1C;;OAEG;WACI,SAAS;IAIhB;;OAEG;sBACe,MAAM,GAAG,SAAS;IAIpC;;OAEG;6BACsB,MAAM,GAAG,SAAS;IAI3C;;OAEG;yBAEK,MAAM,SACL,MAAM,QACR,MAAM,UACJ,MAAM,YACJ,MAAM,YACN,MAAM,GACd,SAAS;EAGZ,CAAC"}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DateTime - Immutable Date/Time Utilities
|
|
3
|
+
* Provides chainable, type-safe date/time operations with multiple format support
|
|
4
|
+
*/
|
|
5
|
+
import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
6
|
+
/**
|
|
7
|
+
* Create a DateTime instance from a Date or string
|
|
8
|
+
*/
|
|
9
|
+
const monthNames = [
|
|
10
|
+
'January',
|
|
11
|
+
'February',
|
|
12
|
+
'March',
|
|
13
|
+
'April',
|
|
14
|
+
'May',
|
|
15
|
+
'June',
|
|
16
|
+
'July',
|
|
17
|
+
'August',
|
|
18
|
+
'September',
|
|
19
|
+
'October',
|
|
20
|
+
'November',
|
|
21
|
+
'December',
|
|
22
|
+
];
|
|
23
|
+
const monthNamesShort = [
|
|
24
|
+
'Jan',
|
|
25
|
+
'Feb',
|
|
26
|
+
'Mar',
|
|
27
|
+
'Apr',
|
|
28
|
+
'May',
|
|
29
|
+
'Jun',
|
|
30
|
+
'Jul',
|
|
31
|
+
'Aug',
|
|
32
|
+
'Sep',
|
|
33
|
+
'Oct',
|
|
34
|
+
'Nov',
|
|
35
|
+
'Dec',
|
|
36
|
+
];
|
|
37
|
+
const padZero = (num, length = 2) => {
|
|
38
|
+
return String(num).padStart(length, '0');
|
|
39
|
+
};
|
|
40
|
+
const getDayOfYearHelper = (date) => {
|
|
41
|
+
const start = new Date(date.getFullYear(), 0, 0);
|
|
42
|
+
const diff = date.getTime() - start.getTime();
|
|
43
|
+
const oneDay = 1000 * 60 * 60 * 24;
|
|
44
|
+
return Math.floor(diff / oneDay);
|
|
45
|
+
};
|
|
46
|
+
const calculateAgo = (value) => {
|
|
47
|
+
const now = new Date();
|
|
48
|
+
const diffMs = now.getTime() - value.getTime();
|
|
49
|
+
if (diffMs < 1000)
|
|
50
|
+
return 'just now';
|
|
51
|
+
if (diffMs < 60000)
|
|
52
|
+
return `${Math.floor(diffMs / 1000)} seconds ago`;
|
|
53
|
+
if (diffMs < 3600000)
|
|
54
|
+
return `${Math.floor(diffMs / 60000)} minutes ago`;
|
|
55
|
+
if (diffMs < 86400000)
|
|
56
|
+
return `${Math.floor(diffMs / 3600000)} hours ago`;
|
|
57
|
+
if (diffMs < 604800000)
|
|
58
|
+
return `${Math.floor(diffMs / 86400000)} days ago`;
|
|
59
|
+
if (diffMs < 2592000000)
|
|
60
|
+
return `${Math.floor(diffMs / 604800000)} weeks ago`;
|
|
61
|
+
if (diffMs < 31536000000)
|
|
62
|
+
return `${Math.floor(diffMs / 2592000000)} months ago`;
|
|
63
|
+
return `${Math.floor(diffMs / 31536000000)} years ago`;
|
|
64
|
+
};
|
|
65
|
+
const formatRelativeTime = (diffMs, isFuture) => {
|
|
66
|
+
const unit = (count, label) => isFuture ? `in ${count} ${label}` : `${count} ${label} ago`;
|
|
67
|
+
if (diffMs < 1000)
|
|
68
|
+
return 'just now';
|
|
69
|
+
if (diffMs < 60000)
|
|
70
|
+
return unit(Math.floor(diffMs / 1000), 'seconds');
|
|
71
|
+
if (diffMs < 3600000)
|
|
72
|
+
return unit(Math.floor(diffMs / 60000), 'minutes');
|
|
73
|
+
if (diffMs < 86400000)
|
|
74
|
+
return unit(Math.floor(diffMs / 3600000), 'hours');
|
|
75
|
+
if (diffMs < 604800000)
|
|
76
|
+
return unit(Math.floor(diffMs / 86400000), 'days');
|
|
77
|
+
if (diffMs < 2592000000)
|
|
78
|
+
return unit(Math.floor(diffMs / 604800000), 'weeks');
|
|
79
|
+
if (diffMs < 31536000000)
|
|
80
|
+
return unit(Math.floor(diffMs / 2592000000), 'months');
|
|
81
|
+
return unit(Math.floor(diffMs / 31536000000), 'years');
|
|
82
|
+
};
|
|
83
|
+
const calculateRelative = (value, other) => {
|
|
84
|
+
const otherDate = other instanceof Date ? other : other.toDate();
|
|
85
|
+
const diffMs = otherDate.getTime() - value.getTime();
|
|
86
|
+
if (diffMs < 0) {
|
|
87
|
+
return formatRelativeTime(Math.abs(diffMs), false);
|
|
88
|
+
}
|
|
89
|
+
return formatRelativeTime(diffMs, true);
|
|
90
|
+
};
|
|
91
|
+
const createAddMethods = (value) => {
|
|
92
|
+
return {
|
|
93
|
+
addDays: (days) => {
|
|
94
|
+
const newDate = new Date(value);
|
|
95
|
+
newDate.setDate(newDate.getDate() + days);
|
|
96
|
+
return createDateTime(newDate);
|
|
97
|
+
},
|
|
98
|
+
addHours: (hours) => {
|
|
99
|
+
const newDate = new Date(value);
|
|
100
|
+
newDate.setHours(newDate.getHours() + hours);
|
|
101
|
+
return createDateTime(newDate);
|
|
102
|
+
},
|
|
103
|
+
addMinutes: (minutes) => {
|
|
104
|
+
const newDate = new Date(value);
|
|
105
|
+
newDate.setMinutes(newDate.getMinutes() + minutes);
|
|
106
|
+
return createDateTime(newDate);
|
|
107
|
+
},
|
|
108
|
+
addSeconds: (seconds) => {
|
|
109
|
+
const newDate = new Date(value);
|
|
110
|
+
newDate.setSeconds(newDate.getSeconds() + seconds);
|
|
111
|
+
return createDateTime(newDate);
|
|
112
|
+
},
|
|
113
|
+
addMonths: (months) => {
|
|
114
|
+
const newDate = new Date(value);
|
|
115
|
+
newDate.setMonth(newDate.getMonth() + months);
|
|
116
|
+
return createDateTime(newDate);
|
|
117
|
+
},
|
|
118
|
+
addYears: (years) => {
|
|
119
|
+
const newDate = new Date(value);
|
|
120
|
+
newDate.setFullYear(newDate.getFullYear() + years);
|
|
121
|
+
return createDateTime(newDate);
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
const createCompareMethods = (value) => {
|
|
126
|
+
return {
|
|
127
|
+
isBefore: (other) => {
|
|
128
|
+
const otherDate = other instanceof Date ? other : other.toDate();
|
|
129
|
+
return value.getTime() < otherDate.getTime();
|
|
130
|
+
},
|
|
131
|
+
isAfter: (other) => {
|
|
132
|
+
const otherDate = other instanceof Date ? other : other.toDate();
|
|
133
|
+
return value.getTime() > otherDate.getTime();
|
|
134
|
+
},
|
|
135
|
+
isSame: (other) => {
|
|
136
|
+
const otherDate = other instanceof Date ? other : other.toDate();
|
|
137
|
+
return (value.getFullYear() === otherDate.getFullYear() &&
|
|
138
|
+
value.getMonth() === otherDate.getMonth() &&
|
|
139
|
+
value.getDate() === otherDate.getDate());
|
|
140
|
+
},
|
|
141
|
+
isBetween: (start, end) => {
|
|
142
|
+
const startDate = start instanceof Date ? start : start.toDate();
|
|
143
|
+
const endDate = end instanceof Date ? end : end.toDate();
|
|
144
|
+
return value.getTime() >= startDate.getTime() && value.getTime() <= endDate.getTime();
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
const createDiffMethods = (value) => {
|
|
149
|
+
const getOtherDate = (other) => other instanceof Date ? other : other.toDate();
|
|
150
|
+
return {
|
|
151
|
+
diffMs: (other) => {
|
|
152
|
+
return value.getTime() - getOtherDate(other).getTime();
|
|
153
|
+
},
|
|
154
|
+
diffSeconds: (other) => {
|
|
155
|
+
return Math.floor((value.getTime() - getOtherDate(other).getTime()) / 1000);
|
|
156
|
+
},
|
|
157
|
+
diffMinutes: (other) => {
|
|
158
|
+
return Math.floor((value.getTime() - getOtherDate(other).getTime()) / 60000);
|
|
159
|
+
},
|
|
160
|
+
diffHours: (other) => {
|
|
161
|
+
return Math.floor((value.getTime() - getOtherDate(other).getTime()) / 3600000);
|
|
162
|
+
},
|
|
163
|
+
diffDays: (other) => {
|
|
164
|
+
return Math.floor((value.getTime() - getOtherDate(other).getTime()) / 86400000);
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
const createBoundaryMethods = (value) => {
|
|
169
|
+
return {
|
|
170
|
+
startOfDay: () => {
|
|
171
|
+
const newDate = new Date(value);
|
|
172
|
+
newDate.setHours(0, 0, 0, 0);
|
|
173
|
+
return createDateTime(newDate);
|
|
174
|
+
},
|
|
175
|
+
endOfDay: () => {
|
|
176
|
+
const newDate = new Date(value);
|
|
177
|
+
newDate.setHours(23, 59, 59, 999);
|
|
178
|
+
return createDateTime(newDate);
|
|
179
|
+
},
|
|
180
|
+
startOfMonth: () => {
|
|
181
|
+
const newDate = new Date(value);
|
|
182
|
+
newDate.setDate(1);
|
|
183
|
+
newDate.setHours(0, 0, 0, 0);
|
|
184
|
+
return createDateTime(newDate);
|
|
185
|
+
},
|
|
186
|
+
endOfMonth: () => {
|
|
187
|
+
const newDate = new Date(value);
|
|
188
|
+
newDate.setMonth(newDate.getMonth() + 1);
|
|
189
|
+
newDate.setDate(0);
|
|
190
|
+
newDate.setHours(23, 59, 59, 999);
|
|
191
|
+
return createDateTime(newDate);
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
const createDateTime = (date) => {
|
|
196
|
+
// Create a copy to ensure immutability
|
|
197
|
+
const value = new Date(date);
|
|
198
|
+
const addMethods = createAddMethods(value);
|
|
199
|
+
const compareMethods = createCompareMethods(value);
|
|
200
|
+
const diffMethods = createDiffMethods(value);
|
|
201
|
+
const boundaryMethods = createBoundaryMethods(value);
|
|
202
|
+
return {
|
|
203
|
+
toDate: () => new Date(value),
|
|
204
|
+
format: (pattern) => {
|
|
205
|
+
let result = pattern;
|
|
206
|
+
const year = value.getFullYear();
|
|
207
|
+
const month = value.getMonth();
|
|
208
|
+
const day = value.getDate();
|
|
209
|
+
const hours = value.getHours();
|
|
210
|
+
const minutes = value.getMinutes();
|
|
211
|
+
const seconds = value.getSeconds();
|
|
212
|
+
const milliseconds = value.getMilliseconds();
|
|
213
|
+
// Replace tokens in the pattern
|
|
214
|
+
result = result.replaceAll('YYYY', String(year));
|
|
215
|
+
result = result.replaceAll('YY', String(year).slice(-2));
|
|
216
|
+
result = result.replaceAll('MMMM', monthNames[month] ?? '');
|
|
217
|
+
result = result.replaceAll('MMM', monthNamesShort[month] ?? '');
|
|
218
|
+
result = result.replaceAll('MM', padZero(month + 1));
|
|
219
|
+
result = result.replaceAll('M', String(month + 1));
|
|
220
|
+
result = result.replaceAll('DD', padZero(day));
|
|
221
|
+
result = result.replaceAll('D', String(day));
|
|
222
|
+
result = result.replaceAll('HH', padZero(hours));
|
|
223
|
+
result = result.replaceAll('H', String(hours));
|
|
224
|
+
result = result.replaceAll('mm', padZero(minutes));
|
|
225
|
+
result = result.replaceAll('m', String(minutes));
|
|
226
|
+
result = result.replaceAll('ss', padZero(seconds));
|
|
227
|
+
result = result.replaceAll('s', String(seconds));
|
|
228
|
+
result = result.replaceAll('SSS', padZero(milliseconds, 3));
|
|
229
|
+
result = result.replaceAll('S', String(milliseconds));
|
|
230
|
+
return result;
|
|
231
|
+
},
|
|
232
|
+
toISO: () => value.toISOString(),
|
|
233
|
+
toRFC3339: () => value.toISOString(),
|
|
234
|
+
ago: () => calculateAgo(value),
|
|
235
|
+
relative: (other) => calculateRelative(value, other),
|
|
236
|
+
...addMethods,
|
|
237
|
+
...compareMethods,
|
|
238
|
+
...diffMethods,
|
|
239
|
+
...boundaryMethods,
|
|
240
|
+
clone: () => createDateTime(new Date(value)),
|
|
241
|
+
getTime: () => value.getTime(),
|
|
242
|
+
getYear: () => value.getFullYear(),
|
|
243
|
+
getMonth: () => value.getMonth(),
|
|
244
|
+
getDate: () => value.getDate(),
|
|
245
|
+
getHours: () => value.getHours(),
|
|
246
|
+
getMinutes: () => value.getMinutes(),
|
|
247
|
+
getSeconds: () => value.getSeconds(),
|
|
248
|
+
getMilliseconds: () => value.getMilliseconds(),
|
|
249
|
+
getDayOfWeek: () => value.getDay(),
|
|
250
|
+
getDayOfYear: () => getDayOfYearHelper(value),
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Parse a date string into a DateTime object
|
|
255
|
+
* Supports: ISO 8601, RFC 3339, common formats
|
|
256
|
+
*/
|
|
257
|
+
const parse = (dateString) => {
|
|
258
|
+
// Try to parse as ISO 8601 / RFC 3339
|
|
259
|
+
const parsedDate = new Date(dateString);
|
|
260
|
+
if (Number.isNaN(parsedDate.getTime())) {
|
|
261
|
+
throw ErrorFactory.createValidationError(`Invalid date string: ${dateString}`);
|
|
262
|
+
}
|
|
263
|
+
return createDateTime(parsedDate);
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* DateTime namespace - sealed namespace object grouping all DateTime operations
|
|
267
|
+
* Immutable by design - all operations return new IDateTime instances
|
|
268
|
+
*/
|
|
269
|
+
export const DateTime = Object.freeze({
|
|
270
|
+
/**
|
|
271
|
+
* Create a DateTime from a Date object
|
|
272
|
+
*/
|
|
273
|
+
create(date = new Date()) {
|
|
274
|
+
return createDateTime(date);
|
|
275
|
+
},
|
|
276
|
+
/**
|
|
277
|
+
* Get current DateTime
|
|
278
|
+
*/
|
|
279
|
+
now() {
|
|
280
|
+
return createDateTime(new Date());
|
|
281
|
+
},
|
|
282
|
+
/**
|
|
283
|
+
* Parse a date string
|
|
284
|
+
*/
|
|
285
|
+
parse(dateString) {
|
|
286
|
+
return parse(dateString);
|
|
287
|
+
},
|
|
288
|
+
/**
|
|
289
|
+
* Create DateTime from timestamp (milliseconds since epoch)
|
|
290
|
+
*/
|
|
291
|
+
fromTimestamp(timestamp) {
|
|
292
|
+
return createDateTime(new Date(timestamp));
|
|
293
|
+
},
|
|
294
|
+
/**
|
|
295
|
+
* Create DateTime from components
|
|
296
|
+
*/
|
|
297
|
+
fromComponents(year, month, day = 1, hours = 0, minutes = 0, seconds = 0) {
|
|
298
|
+
return createDateTime(new Date(year, month - 1, day, hours, minutes, seconds));
|
|
299
|
+
},
|
|
300
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/time/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Http.d.ts","sourceRoot":"","sources":["../../../../src/tools/http/Http.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"Http.d.ts","sourceRoot":"","sources":["../../../../src/tools/http/Http.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAElF,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,CAAC;IACtD,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,YAAY,CAAC;IAC3D,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,YAAY,CAAC;IACnE,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,YAAY,CAAC;IAChE,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,CAAC;IACtC,MAAM,IAAI,YAAY,CAAC;IACvB,MAAM,IAAI,YAAY,CAAC;IACvB,IAAI,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CAChC;AAqJD;;GAEG;AACH,eAAO,MAAM,UAAU;IACrB;;OAEG;aACM,MAAM,GAAG,YAAY;IAI9B;;OAEG;cACO,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY;IAQ/D;;OAEG;aACM,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY;IAQ9D;;OAEG;eACQ,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY;IAQhE;;OAEG;gBACS,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY;EAOjE,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
package/src/tools/http/Http.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* await HttpClient.get('https://api.example.com/users').withAuth(token).send();
|
|
6
6
|
* await HttpClient.post('https://api.example.com/users', data).withTimeout(5000).send();
|
|
7
7
|
*/
|
|
8
|
+
import { OpenTelemetry } from '../../observability/OpenTelemetry.js';
|
|
8
9
|
import { Env } from '../../config/env.js';
|
|
9
10
|
import { Logger } from '../../config/logger.js';
|
|
10
11
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
@@ -20,6 +21,9 @@ async function performRequest(state) {
|
|
|
20
21
|
timeoutId = globalThis.setTimeout(() => controller.abort(), timeout);
|
|
21
22
|
}
|
|
22
23
|
const buildInit = () => {
|
|
24
|
+
if (OpenTelemetry.isEnabled()) {
|
|
25
|
+
OpenTelemetry.injectTraceHeaders(state.headers);
|
|
26
|
+
}
|
|
23
27
|
const init = {
|
|
24
28
|
method: state.method,
|
|
25
29
|
headers: state.headers,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { generateUuid } from '../../../common/
|
|
1
|
+
import { generateUuid } from '../../../common/utility.js';
|
|
2
2
|
import { ErrorFactory } from '../../../exceptions/ZintrustError.js';
|
|
3
3
|
import * as net from '../../../node-singletons/net.js';
|
|
4
4
|
import * as tls from '../../../node-singletons/tls.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { QueueMessage } from '../../queue/Queue';
|
|
1
|
+
import type { QueueMessage } from '../../queue/Queue';
|
|
2
2
|
export declare const InMemoryQueue: {
|
|
3
3
|
readonly enqueue: <T = unknown>(queue: string, payload: T) => Promise<string>;
|
|
4
4
|
readonly dequeue: <T = unknown>(queue: string) => Promise<QueueMessage<T> | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InMemory.d.ts","sourceRoot":"","sources":["../../../../../src/tools/queue/drivers/InMemory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"InMemory.d.ts","sourceRoot":"","sources":["../../../../../src/tools/queue/drivers/InMemory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIvD,eAAO,MAAM,aAAa;uBAQR,CAAC,mBAAmB,MAAM,WAAW,CAAC,KAAG,OAAO,CAAC,MAAM,CAAC;uBAmBxD,CAAC,mBAAmB,MAAM,KAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;2BAW7D,MAAM,OAAO,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;6BAKjC,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC;4BAOzB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;CAMzC,CAAC;AAEL,eAAe,aAAa,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { QueueMessage } from '../../queue/Queue';
|
|
1
|
+
import type { QueueMessage } from '../../queue/Queue';
|
|
2
2
|
export declare const RedisQueue: {
|
|
3
3
|
readonly enqueue: <T = unknown>(queue: string, payload: T) => Promise<string>;
|
|
4
4
|
readonly dequeue: <T = unknown>(queue: string) => Promise<QueueMessage<T> | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Redis.d.ts","sourceRoot":"","sources":["../../../../../src/tools/queue/drivers/Redis.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"Redis.d.ts","sourceRoot":"","sources":["../../../../../src/tools/queue/drivers/Redis.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAevD,eAAO,MAAM,UAAU;uBAuDL,CAAC,mBAAmB,MAAM,WAAW,CAAC,KAAG,OAAO,CAAC,MAAM,CAAC;uBAQxD,CAAC,mBAAmB,MAAM,KAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;2BAY7D,MAAM,OAAO,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;6BAMjC,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC;4BAKzB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;CAKzC,CAAC;AAEL,eAAe,UAAU,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { generateUuid } from '../../../common/
|
|
1
|
+
import { generateUuid } from '../../../common/utility.js';
|
|
2
2
|
import { ErrorFactory } from '../../../exceptions/ZintrustError.js';
|
|
3
3
|
const getRedisUrl = () => {
|
|
4
4
|
const url = (process.env['REDIS_URL'] ?? '').trim();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationError.d.ts","sourceRoot":"","sources":["../../../src/validation/ValidationError.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"ValidationError.d.ts","sourceRoot":"","sources":["../../../src/validation/ValidationError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,gBAAiB,SAAQ,KAAK;IAC7C,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACrC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACjD,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CACvC;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,QAAQ,UAAU,EAAE,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAWtE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,UAAU,EAAE,EAAE,OAAO,MAAM,KAAG,MAAM,GAAG,SAE5E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,UAAU,EAAE,EAAE,OAAO,MAAM,KAAG,OAEnE,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,qBAAqB,GACzB,QAAQ,UAAU,EAAE,EACpB,UAAS,MAA4B,KACpC,gBASF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe;qBAhBlB,UAAU,EAAE,YACX,MAAM,KACd,gBAAgB;uBAjCc,UAAU,EAAE,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;4BAgBlC,UAAU,EAAE,SAAS,MAAM,KAAG,MAAM,GAAG,SAAS;4BAOhD,UAAU,EAAE,SAAS,MAAM,KAAG,OAAO;EA6BzE,CAAC;AAGH,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Validation Error
|
|
3
3
|
* Structured error response for validation failures with field-level details
|
|
4
4
|
*/
|
|
5
|
+
import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
5
6
|
/**
|
|
6
7
|
* Convert errors array to field:errors object
|
|
7
8
|
*/
|
|
@@ -32,8 +33,9 @@ export const hasFieldError = (errors, field) => {
|
|
|
32
33
|
* Create a validation error instance
|
|
33
34
|
*/
|
|
34
35
|
const createValidationError = (errors, message = 'Validation failed') => {
|
|
35
|
-
const error =
|
|
36
|
-
|
|
36
|
+
const error = ErrorFactory.createValidationError(message, {
|
|
37
|
+
errors,
|
|
38
|
+
});
|
|
37
39
|
error.errors = errors;
|
|
38
40
|
error.toObject = () => toObject(errors);
|
|
39
41
|
error.getFieldError = (field) => getFieldError(errors, field);
|