@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
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/require-await */
|
|
2
|
-
/* eslint-disable no-await-in-loop */
|
|
3
2
|
/**
|
|
4
3
|
* Plugin Manager
|
|
5
4
|
* Handles installation and removal of framework plugins.
|
|
6
5
|
*/
|
|
6
|
+
import { execSync } from '../node-singletons/child-process.js';
|
|
7
7
|
import { SpawnUtil } from '../cli/utils/spawn.js';
|
|
8
8
|
import { esmDirname, resolvePackageManager } from '../common/index.js';
|
|
9
9
|
import { Logger } from '../config/logger.js';
|
|
10
10
|
import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
11
|
-
import { execSync } from '../node-singletons/child-process.js';
|
|
12
11
|
import { existsSync, fsPromises as fs } from '../node-singletons/fs.js';
|
|
13
12
|
import * as path from '../node-singletons/path.js';
|
|
14
13
|
import { PluginRegistry } from './PluginRegistry.js';
|
|
@@ -88,6 +87,21 @@ async function npmInstall(packages, options) {
|
|
|
88
87
|
Logger.info(`Installing ${options.label}: ${packages.join(', ')}...`);
|
|
89
88
|
const projectRoot = options.projectRoot ?? resolveProjectRoot();
|
|
90
89
|
const pm = options.packageManager ?? resolvePackageManager();
|
|
90
|
+
// Legacy behavior: npm uses execSync in this framework.
|
|
91
|
+
// This keeps behavior predictable for CI/test environments and matches existing unit tests.
|
|
92
|
+
if (pm === 'npm') {
|
|
93
|
+
const cmd = options.dev
|
|
94
|
+
? `npm install -D ${packages.join(' ')}`
|
|
95
|
+
: `npm install ${packages.join(' ')}`;
|
|
96
|
+
try {
|
|
97
|
+
execSync(cmd, { cwd: projectRoot, stdio: 'inherit' });
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
ErrorFactory.createCliError(`Failed to install ${options.label}`, { error });
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
91
105
|
let cmd;
|
|
92
106
|
let args = [];
|
|
93
107
|
switch (pm) {
|
|
@@ -106,20 +120,12 @@ async function npmInstall(packages, options) {
|
|
|
106
120
|
break;
|
|
107
121
|
}
|
|
108
122
|
try {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
const exit = await SpawnUtil.spawnAndWait({ command: cmd, args, cwd: projectRoot });
|
|
118
|
-
if (exit !== 0) {
|
|
119
|
-
throw ErrorFactory.createCliError(`Package manager ${pm} failed to install ${options.label}`, {
|
|
120
|
-
exit,
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
+
// Use async spawn for all package managers to avoid blocking event loop
|
|
124
|
+
const exit = await SpawnUtil.spawnAndWait({ command: cmd, args, cwd: projectRoot });
|
|
125
|
+
if (exit !== 0) {
|
|
126
|
+
throw ErrorFactory.createCliError(`Package manager ${pm} failed to install ${options.label}`, {
|
|
127
|
+
exit,
|
|
128
|
+
});
|
|
123
129
|
}
|
|
124
130
|
}
|
|
125
131
|
catch (error) {
|
|
@@ -130,7 +136,8 @@ async function npmInstall(packages, options) {
|
|
|
130
136
|
async function copyPluginTemplates(plugin) {
|
|
131
137
|
const templateRoot = resolveTemplateRootOrThrow();
|
|
132
138
|
const projectRoot = resolveProjectRoot();
|
|
133
|
-
|
|
139
|
+
// Parallelize file operations using Promise.all
|
|
140
|
+
await Promise.all(plugin.templates.map(async (template) => {
|
|
134
141
|
const sourcePath = path.join(templateRoot, template.source);
|
|
135
142
|
const destPath = path.join(projectRoot, template.destination);
|
|
136
143
|
// Prevent path traversal: resolved destination must be within project root
|
|
@@ -154,7 +161,7 @@ async function copyPluginTemplates(plugin) {
|
|
|
154
161
|
ErrorFactory.createCliError(`Failed to copy template ${template.source}`, { error });
|
|
155
162
|
throw error;
|
|
156
163
|
}
|
|
157
|
-
}
|
|
164
|
+
}));
|
|
158
165
|
}
|
|
159
166
|
async function ensurePluginAutoImports(plugin) {
|
|
160
167
|
const rawImports = plugin.autoImports;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeDetector.d.ts","sourceRoot":"","sources":["../../../src/runtime/RuntimeDetector.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"RuntimeDetector.d.ts","sourceRoot":"","sources":["../../../src/runtime/RuntimeDetector.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAkK9F,eAAO,MAAM,eAAe;;;yBA9GF,MAAM;4BAyBD,aAAa,KAAG,cAAc;uCAQnB,MAAM,UAAU,aAAa,KAAG,cAAc;0BAuD7D,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;EA6BhD,CAAC;AA8IH,eAAO,MAAM,oBAAoB;0BAtGE,eAAe,KAAG,OAAO,CAAC,IAAI,CAAC;wBA0DlC,MAAM,KAAe,OAAO,CAAC,IAAI,CAAC;iCAmChC,IAAI;EAapC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare enum StartupConfigFile {
|
|
2
|
+
Broadcast = "config/broadcast.ts",
|
|
3
|
+
Cache = "config/cache.ts",
|
|
4
|
+
Database = "config/database.ts",
|
|
5
|
+
Mail = "config/mail.ts",
|
|
6
|
+
Middleware = "config/middleware.ts",
|
|
7
|
+
Notification = "config/notification.ts",
|
|
8
|
+
Queue = "config/queue.ts",
|
|
9
|
+
Storage = "config/storage.ts"
|
|
10
|
+
}
|
|
11
|
+
export declare const StartupConfigFileRegistry: Readonly<{
|
|
12
|
+
preload(files: readonly StartupConfigFile[]): Promise<void>;
|
|
13
|
+
isPreloaded(): boolean;
|
|
14
|
+
get<T>(file: StartupConfigFile): T | undefined;
|
|
15
|
+
has(file: StartupConfigFile): boolean;
|
|
16
|
+
/** Intended for tests only. */
|
|
17
|
+
clear(): void;
|
|
18
|
+
}>;
|
|
19
|
+
export default StartupConfigFileRegistry;
|
|
20
|
+
//# sourceMappingURL=StartupConfigFileRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StartupConfigFileRegistry.d.ts","sourceRoot":"","sources":["../../../src/runtime/StartupConfigFileRegistry.ts"],"names":[],"mappings":"AAEA,oBAAY,iBAAiB;IAC3B,SAAS,wBAAwB;IACjC,KAAK,oBAAoB;IACzB,QAAQ,uBAAuB;IAC/B,IAAI,mBAAmB;IACvB,UAAU,yBAAyB;IACnC,YAAY,2BAA2B;IACvC,KAAK,oBAAoB;IACzB,OAAO,sBAAsB;CAC9B;AAKD,eAAO,MAAM,yBAAyB;mBACf,SAAS,iBAAiB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;mBAelD,OAAO;QAIlB,CAAC,QAAQ,iBAAiB,GAAG,CAAC,GAAG,SAAS;cAIpC,iBAAiB,GAAG,OAAO;IAIrC,+BAA+B;aACtB,IAAI;EAIb,CAAC;AAEH,eAAe,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import useFileLoader from '../runtime/useFileLoader.js';
|
|
2
|
+
export var StartupConfigFile;
|
|
3
|
+
(function (StartupConfigFile) {
|
|
4
|
+
StartupConfigFile["Broadcast"] = "config/broadcast.ts";
|
|
5
|
+
StartupConfigFile["Cache"] = "config/cache.ts";
|
|
6
|
+
StartupConfigFile["Database"] = "config/database.ts";
|
|
7
|
+
StartupConfigFile["Mail"] = "config/mail.ts";
|
|
8
|
+
StartupConfigFile["Middleware"] = "config/middleware.ts";
|
|
9
|
+
StartupConfigFile["Notification"] = "config/notification.ts";
|
|
10
|
+
StartupConfigFile["Queue"] = "config/queue.ts";
|
|
11
|
+
StartupConfigFile["Storage"] = "config/storage.ts";
|
|
12
|
+
})(StartupConfigFile || (StartupConfigFile = {}));
|
|
13
|
+
const cache = new Map();
|
|
14
|
+
let preloaded = false;
|
|
15
|
+
export const StartupConfigFileRegistry = Object.freeze({
|
|
16
|
+
async preload(files) {
|
|
17
|
+
const tasks = files.map(async (file) => {
|
|
18
|
+
const loader = useFileLoader(file);
|
|
19
|
+
if (!loader.exists()) {
|
|
20
|
+
cache.delete(file);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const value = await loader.get();
|
|
24
|
+
cache.set(file, value);
|
|
25
|
+
});
|
|
26
|
+
await Promise.all(tasks);
|
|
27
|
+
preloaded = true;
|
|
28
|
+
},
|
|
29
|
+
isPreloaded() {
|
|
30
|
+
return preloaded;
|
|
31
|
+
},
|
|
32
|
+
get(file) {
|
|
33
|
+
return cache.get(file);
|
|
34
|
+
},
|
|
35
|
+
has(file) {
|
|
36
|
+
return cache.has(file);
|
|
37
|
+
},
|
|
38
|
+
/** Intended for tests only. */
|
|
39
|
+
clear() {
|
|
40
|
+
cache.clear();
|
|
41
|
+
preloaded = false;
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
export default StartupConfigFileRegistry;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdapterConfig, RuntimeAdapter } from '../RuntimeAdapter';
|
|
1
|
+
import type { AdapterConfig, RuntimeAdapter } from '../RuntimeAdapter';
|
|
2
2
|
/**
|
|
3
3
|
* Cloudflare Workers adapter for Cloudflare's edge compute platform
|
|
4
4
|
* Uses fetch API and handles D1 database, KV storage bindings
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudflareAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtime/adapters/CloudflareAdapter.ts"],"names":[],"mappings":"AAMA,OAAO,
|
|
1
|
+
{"version":3,"file":"CloudflareAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtime/adapters/CloudflareAdapter.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,aAAa,EAGb,cAAc,EAAC,MAAM,yBAAyB,CAAC;AAOjD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;IAC5B;;OAEG;mBACY,aAAa,GAAG,cAAc;IAoD7C;;;OAGG;qBACc,OAAO;IAKxB;;;OAGG;qBACc,MAAM,GAAG,OAAO;EAIjC,CAAC;AA4IH;;;;GAIG;AACH,MAAM,WAAW,iBAAkB,SAAQ,OAAO;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IACjC,EAAE,CAAC,EAAE;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { appConfig } from '../../config/index.js';
|
|
5
5
|
import { Logger } from '../../config/logger.js';
|
|
6
|
-
import { createMockHttpObjects, ErrorResponse, HttpResponse
|
|
6
|
+
import { createMockHttpObjects, ErrorResponse, HttpResponse } from '../RuntimeAdapter.js';
|
|
7
7
|
/**
|
|
8
8
|
* Cloudflare Workers adapter for Cloudflare's edge compute platform
|
|
9
9
|
* Uses fetch API and handles D1 database, KV storage bindings
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DenoAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtime/adapters/DenoAdapter.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"DenoAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtime/adapters/DenoAdapter.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EAGb,cAAc,EAAC,MAAM,yBAAyB,CAAC;AAMjD;;;GAGG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;mBACY,aAAa,GAAG,cAAc,GAAG;QAC9C,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KAC1D;IAwDD;;OAEG;yBAEQ,cAAc,SACjB,MAAM,SACN,MAAM,GACX,OAAO,CAAC,IAAI,CAAC;IAQhB;;OAEG;aACY,OAAO,CAAC,OAAO,CAAC;IAK/B;;OAEG;mBACY,MAAM,iBAAiB,MAAM,GAAG,MAAM;IAKrD;;OAEG;2BACoB,OAAO;EAI9B,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Runtime adapter for Deno
|
|
3
3
|
*/
|
|
4
4
|
import Logger from '../../config/logger.js';
|
|
5
|
-
import { createMockHttpObjects, ErrorResponse
|
|
5
|
+
import { createMockHttpObjects, ErrorResponse } from '../RuntimeAdapter.js';
|
|
6
6
|
/**
|
|
7
7
|
* Deno runtime adapter for Deno Deploy and edge compute environments
|
|
8
8
|
* Sealed namespace for immutability
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdapterConfig, RuntimeAdapter } from '../RuntimeAdapter';
|
|
1
|
+
import type { AdapterConfig, RuntimeAdapter } from '../RuntimeAdapter';
|
|
2
2
|
/**
|
|
3
3
|
* AWS Lambda adapter for API Gateway and ALB events
|
|
4
4
|
* Converts Lambda events to standard HTTP format for Zintrust framework
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LambdaAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtime/adapters/LambdaAdapter.ts"],"names":[],"mappings":"AAYA,OAAO,
|
|
1
|
+
{"version":3,"file":"LambdaAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtime/adapters/LambdaAdapter.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,aAAa,EAGb,cAAc,EAAC,MAAM,yBAAyB,CAAC;AAMjD;;;;GAIG;AACH,eAAO,MAAM,aAAa;IACxB;;OAEG;mBACY,aAAa,GAAG,cAAc;EA8D7C,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { Env } from '../../config/env.js';
|
|
5
5
|
import { Logger } from '../../config/logger.js';
|
|
6
6
|
import { IncomingMessage, ServerResponse, } from '../../node-singletons/http.js';
|
|
7
|
-
import { ErrorResponse, HttpResponse
|
|
7
|
+
import { ErrorResponse, HttpResponse } from '../RuntimeAdapter.js';
|
|
8
8
|
/**
|
|
9
9
|
* AWS Lambda adapter for API Gateway and ALB events
|
|
10
10
|
* Converts Lambda events to standard HTTP format for Zintrust framework
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdapterConfig, RuntimeAdapter } from '../RuntimeAdapter';
|
|
1
|
+
import type { AdapterConfig, RuntimeAdapter } from '../RuntimeAdapter';
|
|
2
2
|
/**
|
|
3
3
|
* Node.js HTTP Server adapter for standard containers and traditional servers
|
|
4
4
|
* Uses Node.js built-in HTTP server for maximum compatibility
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeServerAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtime/adapters/NodeServerAdapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NodeServerAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtime/adapters/NodeServerAdapter.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EAGb,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;IAC5B;;OAEG;mBACY,aAAa,GAAG,cAAc,GAAG;QAC9C,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACzD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;KACvB;EAoED,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IKernel } from '../http/Kernel';
|
|
2
|
+
export declare function getKernel(): Promise<IKernel>;
|
|
3
|
+
/**
|
|
4
|
+
* Test-only helper.
|
|
5
|
+
*
|
|
6
|
+
* Allows unit tests to reset the singleton between cases without leaking state.
|
|
7
|
+
*/
|
|
8
|
+
export declare function __resetKernelForTests(): void;
|
|
9
|
+
//# sourceMappingURL=getKernel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getKernel.d.ts","sourceRoot":"","sources":["../../../src/runtime/getKernel.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAK5C,wBAAsB,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAkBlD;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Application } from '../boot/Application.js';
|
|
2
|
+
import { Kernel } from '../http/Kernel.js';
|
|
3
|
+
let kernelPromise = null;
|
|
4
|
+
export async function getKernel() {
|
|
5
|
+
if (kernelPromise !== null) {
|
|
6
|
+
return kernelPromise;
|
|
7
|
+
}
|
|
8
|
+
const initialize = async () => {
|
|
9
|
+
const app = Application.create();
|
|
10
|
+
await app.boot();
|
|
11
|
+
return Kernel.create(app.getRouter(), app.getContainer());
|
|
12
|
+
};
|
|
13
|
+
kernelPromise = initialize().catch((error) => {
|
|
14
|
+
// Allow retry on subsequent calls if initialization fails.
|
|
15
|
+
kernelPromise = null;
|
|
16
|
+
throw error;
|
|
17
|
+
});
|
|
18
|
+
return kernelPromise;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Test-only helper.
|
|
22
|
+
*
|
|
23
|
+
* Allows unit tests to reset the singleton between cases without leaking state.
|
|
24
|
+
*/
|
|
25
|
+
export function __resetKernelForTests() {
|
|
26
|
+
kernelPromise = null;
|
|
27
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project file loader
|
|
3
|
+
*
|
|
4
|
+
* Loads project-owned files (typically config modules) from the project root.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* - useFileLoader('config/mail.ts').get<TypeMail>()
|
|
8
|
+
* - useFileLoader('config', 'mail.ts').get<TypeMail>()
|
|
9
|
+
*/
|
|
10
|
+
export type FileLoader = Readonly<{
|
|
11
|
+
/** Absolute filesystem candidates (in resolution order). */
|
|
12
|
+
candidates: () => readonly string[];
|
|
13
|
+
/** Returns the first existing candidate path (or the first candidate if none exist). */
|
|
14
|
+
path: () => string;
|
|
15
|
+
/** Whether any candidate exists on disk. */
|
|
16
|
+
exists: () => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Loads the file via ESM dynamic import and returns:
|
|
19
|
+
* - `default` export when present
|
|
20
|
+
* - otherwise the full module namespace object
|
|
21
|
+
*/
|
|
22
|
+
get: <T = unknown>() => Promise<T>;
|
|
23
|
+
}>;
|
|
24
|
+
export declare const useFileLoader: (...args: [string] | [string, ...string[]]) => FileLoader;
|
|
25
|
+
export default useFileLoader;
|
|
26
|
+
//# sourceMappingURL=useFileLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFileLoader.d.ts","sourceRoot":"","sources":["../../../src/runtime/useFileLoader.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAUH,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,4DAA4D;IAC5D,UAAU,EAAE,MAAM,SAAS,MAAM,EAAE,CAAC;IACpC,wFAAwF;IACxF,IAAI,EAAE,MAAM,MAAM,CAAC;IACnB,4CAA4C;IAC5C,MAAM,EAAE,MAAM,OAAO,CAAC;IACtB;;;;OAIG;IACH,GAAG,EAAE,CAAC,CAAC,GAAG,OAAO,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;CACpC,CAAC,CAAC;AAyIH,eAAO,MAAM,aAAa,GAAI,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,KAAG,UA+DzE,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project file loader
|
|
3
|
+
*
|
|
4
|
+
* Loads project-owned files (typically config modules) from the project root.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* - useFileLoader('config/mail.ts').get<TypeMail>()
|
|
8
|
+
* - useFileLoader('config', 'mail.ts').get<TypeMail>()
|
|
9
|
+
*/
|
|
10
|
+
import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
11
|
+
import { existsSync } from '../node-singletons/fs.js';
|
|
12
|
+
import pathModule, { extname, join, resolve, sep } from '../node-singletons/path.js';
|
|
13
|
+
import processModule from '../node-singletons/process.js';
|
|
14
|
+
import { pathToFileURL } from '../node-singletons/url.js';
|
|
15
|
+
const resolveProjectRoot = () => {
|
|
16
|
+
const isTestRuntime = () => {
|
|
17
|
+
const nodeEnv = processModule.env?.['NODE_ENV'];
|
|
18
|
+
const isVitest = processModule.env?.['VITEST'] !== undefined ||
|
|
19
|
+
processModule.env?.['VITEST_WORKER_ID'] !== undefined ||
|
|
20
|
+
processModule.env?.['VITEST_POOL_ID'] !== undefined;
|
|
21
|
+
return nodeEnv === 'testing' || isVitest;
|
|
22
|
+
};
|
|
23
|
+
const isCoreRepo = (cwdPath) => {
|
|
24
|
+
const fromNpm = processModule.env?.['npm_package_name'];
|
|
25
|
+
if (fromNpm === '@zintrust/core')
|
|
26
|
+
return true;
|
|
27
|
+
// Vitest suites (notably CoverageBoost) may mock `@node-singletons/fs` to return
|
|
28
|
+
// `existsSync() === true` for everything and `readFileSync() === '{}'`, which makes
|
|
29
|
+
// any package.json-based detection unreliable. Instead, detect a core repo checkout
|
|
30
|
+
// by checking whether this module is being executed from within the current cwd.
|
|
31
|
+
// - core repo tests: import.meta.url points into `<cwd>/src/...`
|
|
32
|
+
// - consumer apps: import.meta.url points into `node_modules/@zintrust/core/...`
|
|
33
|
+
try {
|
|
34
|
+
const cwdAbs = resolve(cwdPath);
|
|
35
|
+
const selfUrl = new URL(import.meta.url);
|
|
36
|
+
const selfPath = decodeURIComponent(selfUrl.pathname);
|
|
37
|
+
const selfAbs = resolve(selfPath);
|
|
38
|
+
return selfAbs === cwdAbs || selfAbs.startsWith(cwdAbs + sep);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const fromEnv = processModule.env?.['ZINTRUST_PROJECT_ROOT'];
|
|
45
|
+
if (typeof fromEnv === 'string' && fromEnv.trim().length > 0)
|
|
46
|
+
return fromEnv.trim();
|
|
47
|
+
const cwd = processModule.cwd();
|
|
48
|
+
// In the ZinTrust core repo, `config/*.ts` are templates (not consumer app config).
|
|
49
|
+
// During core test runs, we avoid auto-loading them to prevent unexpected overrides.
|
|
50
|
+
// In normal runs, keep the historical behavior (projectRoot = cwd).
|
|
51
|
+
if (isCoreRepo(cwd) && isTestRuntime()) {
|
|
52
|
+
return resolve(cwd, '.zintrust-internal-project-root');
|
|
53
|
+
}
|
|
54
|
+
return cwd;
|
|
55
|
+
};
|
|
56
|
+
const isInternalProjectRoot = (projectRoot) => pathModule.basename(projectRoot) === '.zintrust-internal-project-root';
|
|
57
|
+
const normalizeProjectRelativePath = (raw) => {
|
|
58
|
+
const value = String(raw ?? '').trim();
|
|
59
|
+
if (value.length === 0) {
|
|
60
|
+
throw ErrorFactory.createConfigError('useFileLoader() requires a non-empty path');
|
|
61
|
+
}
|
|
62
|
+
if (value.includes('\u0000')) {
|
|
63
|
+
throw ErrorFactory.createSecurityError('Invalid file path (null byte)');
|
|
64
|
+
}
|
|
65
|
+
const normalized = value.replaceAll('\\', '/').replace(/^\.\/+/, '');
|
|
66
|
+
if (pathModule.isAbsolute(normalized)) {
|
|
67
|
+
throw ErrorFactory.createSecurityError('Absolute paths are not allowed', { requested: value });
|
|
68
|
+
}
|
|
69
|
+
return normalized;
|
|
70
|
+
};
|
|
71
|
+
const resolveWithinProjectRoot = (projectRoot, relativePath) => {
|
|
72
|
+
const rootAbs = resolve(projectRoot);
|
|
73
|
+
const candidateAbs = resolve(projectRoot, relativePath);
|
|
74
|
+
if (candidateAbs === rootAbs)
|
|
75
|
+
return candidateAbs;
|
|
76
|
+
if (!candidateAbs.startsWith(rootAbs + sep)) {
|
|
77
|
+
throw ErrorFactory.createSecurityError('Invalid file path (path traversal detected)', {
|
|
78
|
+
projectRoot: rootAbs,
|
|
79
|
+
requested: relativePath,
|
|
80
|
+
resolved: candidateAbs,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return candidateAbs;
|
|
84
|
+
};
|
|
85
|
+
const replaceExtension = (filePath, nextExt) => {
|
|
86
|
+
const current = extname(filePath);
|
|
87
|
+
if (current.length === 0)
|
|
88
|
+
return `${filePath}${nextExt}`;
|
|
89
|
+
return filePath.slice(0, -current.length) + nextExt;
|
|
90
|
+
};
|
|
91
|
+
const unique = (items) => {
|
|
92
|
+
const seen = new Set();
|
|
93
|
+
const out = [];
|
|
94
|
+
for (const item of items) {
|
|
95
|
+
if (seen.has(item))
|
|
96
|
+
continue;
|
|
97
|
+
seen.add(item);
|
|
98
|
+
out.push(item);
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
};
|
|
102
|
+
const buildCandidateAbsolutePaths = (projectRoot, relativePath) => {
|
|
103
|
+
const ext = extname(relativePath);
|
|
104
|
+
const baseRelCandidates = unique([
|
|
105
|
+
relativePath,
|
|
106
|
+
...(ext.length === 0
|
|
107
|
+
? [`${relativePath}.ts`, `${relativePath}.js`, `${relativePath}.mjs`]
|
|
108
|
+
: []),
|
|
109
|
+
...(ext === '.ts'
|
|
110
|
+
? [replaceExtension(relativePath, '.js'), replaceExtension(relativePath, '.mjs')]
|
|
111
|
+
: []),
|
|
112
|
+
...(ext === '.js'
|
|
113
|
+
? [replaceExtension(relativePath, '.mjs'), replaceExtension(relativePath, '.ts')]
|
|
114
|
+
: []),
|
|
115
|
+
...(ext === '.mjs'
|
|
116
|
+
? [replaceExtension(relativePath, '.js'), replaceExtension(relativePath, '.ts')]
|
|
117
|
+
: []),
|
|
118
|
+
]);
|
|
119
|
+
const absCandidates = baseRelCandidates.flatMap((rel) => [
|
|
120
|
+
resolveWithinProjectRoot(projectRoot, rel),
|
|
121
|
+
resolveWithinProjectRoot(projectRoot, join('dist', rel)),
|
|
122
|
+
]);
|
|
123
|
+
return unique(absCandidates);
|
|
124
|
+
};
|
|
125
|
+
const importModule = async (filePath) => {
|
|
126
|
+
const url = pathToFileURL(filePath).href;
|
|
127
|
+
return (await import(url));
|
|
128
|
+
};
|
|
129
|
+
export const useFileLoader = (...args) => {
|
|
130
|
+
const relativePath = args.length === 1
|
|
131
|
+
? normalizeProjectRelativePath(args[0])
|
|
132
|
+
: normalizeProjectRelativePath(args.join('/'));
|
|
133
|
+
const projectRoot = resolveProjectRoot();
|
|
134
|
+
const isInternalRoot = isInternalProjectRoot(projectRoot);
|
|
135
|
+
const candidates = buildCandidateAbsolutePaths(projectRoot, relativePath);
|
|
136
|
+
// The core repo uses `.zintrust-internal-project-root` as a sentinel during core test runs.
|
|
137
|
+
// In this mode, we must *never* import project config templates.
|
|
138
|
+
// This also avoids test suites that mock `existsSync()` globally (e.g. CoverageBoost).
|
|
139
|
+
const exists = () => (isInternalRoot ? false : candidates.some((c) => existsSync(c)));
|
|
140
|
+
const resolveFirstExistingPath = () => {
|
|
141
|
+
if (isInternalRoot)
|
|
142
|
+
return candidates[0] ?? resolveWithinProjectRoot(projectRoot, relativePath);
|
|
143
|
+
for (const candidate of candidates) {
|
|
144
|
+
if (existsSync(candidate))
|
|
145
|
+
return candidate;
|
|
146
|
+
}
|
|
147
|
+
return candidates[0] ?? resolveWithinProjectRoot(projectRoot, relativePath);
|
|
148
|
+
};
|
|
149
|
+
const get = async () => {
|
|
150
|
+
if (isInternalRoot) {
|
|
151
|
+
throw ErrorFactory.createNotFoundError('Project file not found', {
|
|
152
|
+
projectRoot,
|
|
153
|
+
relativePath,
|
|
154
|
+
candidates,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
const candidate = candidates.find((c) => existsSync(c));
|
|
158
|
+
if (candidate === undefined) {
|
|
159
|
+
throw ErrorFactory.createNotFoundError('Project file not found', {
|
|
160
|
+
projectRoot,
|
|
161
|
+
relativePath,
|
|
162
|
+
candidates,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
try {
|
|
166
|
+
const mod = await importModule(candidate);
|
|
167
|
+
if (Object.hasOwn(mod, 'default') && mod.default !== undefined) {
|
|
168
|
+
return mod.default;
|
|
169
|
+
}
|
|
170
|
+
return mod;
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
throw ErrorFactory.createTryCatchError('Failed to import project file', {
|
|
174
|
+
candidate,
|
|
175
|
+
projectRoot,
|
|
176
|
+
relativePath,
|
|
177
|
+
error,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
return Object.freeze({
|
|
182
|
+
candidates: () => candidates,
|
|
183
|
+
path: resolveFirstExistingPath,
|
|
184
|
+
exists,
|
|
185
|
+
get,
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
export default useFileLoader;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
|
+
import ts from 'typescript';
|
|
3
4
|
const TEMPLATES_ROOT = path.resolve(process.cwd(), 'src/templates');
|
|
4
5
|
const bannedPrefixes = [
|
|
5
6
|
'@exceptions/',
|
|
@@ -79,6 +80,29 @@ function checkFile(filePath) {
|
|
|
79
80
|
}
|
|
80
81
|
return offenses;
|
|
81
82
|
}
|
|
83
|
+
function looksLikeTypeScriptTemplate(text) {
|
|
84
|
+
// Only attempt TS parsing when the template appears to contain TS module syntax.
|
|
85
|
+
// Many templates are not TS (markdown/env/etc.) and should not be validated this way.
|
|
86
|
+
return /\b(import|export)\b/.test(text);
|
|
87
|
+
}
|
|
88
|
+
function getTypeScriptSyntaxErrors(filePath) {
|
|
89
|
+
const text = fs.readFileSync(filePath, 'utf8');
|
|
90
|
+
if (!looksLikeTypeScriptTemplate(text))
|
|
91
|
+
return [];
|
|
92
|
+
const sourceFile = ts.createSourceFile(filePath, text, ts.ScriptTarget.ESNext, true, ts.ScriptKind.TS);
|
|
93
|
+
const diagnostics = sourceFile
|
|
94
|
+
.parseDiagnostics;
|
|
95
|
+
if (!diagnostics || diagnostics.length === 0)
|
|
96
|
+
return [];
|
|
97
|
+
const out = [];
|
|
98
|
+
for (const d of diagnostics) {
|
|
99
|
+
const message = ts.flattenDiagnosticMessageText(d.messageText, '\n');
|
|
100
|
+
const pos = typeof d.start === 'number' ? d.start : 0;
|
|
101
|
+
const { line } = sourceFile.getLineAndCharacterOfPosition(pos);
|
|
102
|
+
out.push({ line: line + 1, message });
|
|
103
|
+
}
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
82
106
|
function main() {
|
|
83
107
|
if (!fs.existsSync(TEMPLATES_ROOT)) {
|
|
84
108
|
process.stderr.write(`Templates root not found: ${TEMPLATES_ROOT}\n`);
|
|
@@ -86,6 +110,7 @@ function main() {
|
|
|
86
110
|
}
|
|
87
111
|
const files = listFilesRecursive(TEMPLATES_ROOT).filter(isTemplateFile);
|
|
88
112
|
const allOffenses = [];
|
|
113
|
+
const allSyntaxErrors = [];
|
|
89
114
|
for (const file of files) {
|
|
90
115
|
const offenses = checkFile(file);
|
|
91
116
|
for (const o of offenses) {
|
|
@@ -96,6 +121,21 @@ function main() {
|
|
|
96
121
|
text: o.text,
|
|
97
122
|
});
|
|
98
123
|
}
|
|
124
|
+
const syntaxErrors = getTypeScriptSyntaxErrors(file);
|
|
125
|
+
for (const e of syntaxErrors) {
|
|
126
|
+
allSyntaxErrors.push({
|
|
127
|
+
file: path.relative(process.cwd(), file),
|
|
128
|
+
line: e.line,
|
|
129
|
+
message: e.message,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (allSyntaxErrors.length > 0) {
|
|
134
|
+
process.stderr.write('Template syntax check failed. TypeScript parse errors found:\n');
|
|
135
|
+
for (const e of allSyntaxErrors) {
|
|
136
|
+
process.stderr.write(`- ${e.file}:${e.line} -> ${e.message}\n`);
|
|
137
|
+
}
|
|
138
|
+
process.exit(1);
|
|
99
139
|
}
|
|
100
140
|
if (allOffenses.length > 0) {
|
|
101
141
|
process.stderr.write('Template import check failed. Disallowed import specifiers found:\n');
|