@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,455 +1,36 @@
|
|
|
1
|
-
import { Env } from '@zintrust/core';
|
|
2
|
-
import type { Middleware as MiddlewareFn } from '@zintrust/core';
|
|
3
|
-
|
|
4
|
-
export type Environment =
|
|
5
|
-
| 'development'
|
|
6
|
-
| 'dev'
|
|
7
|
-
| 'production'
|
|
8
|
-
| 'prod'
|
|
9
|
-
| 'pro'
|
|
10
|
-
| 'testing'
|
|
11
|
-
| 'test';
|
|
12
|
-
export type StartMode = 'development' | 'production' | 'testing';
|
|
13
|
-
|
|
14
|
-
export type EnvGetValue = ReturnType<typeof Env.get>;
|
|
15
|
-
export type EnvGetBoolValue = ReturnType<typeof Env.getBool>;
|
|
16
|
-
|
|
17
|
-
export type LocalStorageDriverConfig = {
|
|
18
|
-
driver: 'local';
|
|
19
|
-
root: EnvGetValue;
|
|
20
|
-
url: EnvGetValue;
|
|
21
|
-
visibility: EnvGetValue;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type S3StorageDriverConfig = {
|
|
25
|
-
driver: 's3';
|
|
26
|
-
accessKeyId: EnvGetValue;
|
|
27
|
-
secretAccessKey: EnvGetValue;
|
|
28
|
-
region: typeof Env.AWS_REGION;
|
|
29
|
-
bucket: EnvGetValue;
|
|
30
|
-
url: EnvGetValue;
|
|
31
|
-
endpoint: EnvGetValue;
|
|
32
|
-
usePathStyleUrl: EnvGetBoolValue;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export type R2StorageDriverConfig = {
|
|
36
|
-
driver: 'r2';
|
|
37
|
-
accessKeyId: EnvGetValue;
|
|
38
|
-
secretAccessKey: EnvGetValue;
|
|
39
|
-
region: EnvGetValue;
|
|
40
|
-
bucket: EnvGetValue;
|
|
41
|
-
endpoint: EnvGetValue;
|
|
42
|
-
url: EnvGetValue;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export type GcsStorageDriverConfig = {
|
|
46
|
-
driver: 'gcs';
|
|
47
|
-
projectId: EnvGetValue;
|
|
48
|
-
keyFile: EnvGetValue;
|
|
49
|
-
bucket: EnvGetValue;
|
|
50
|
-
url: EnvGetValue;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export type StorageDriverConfig =
|
|
54
|
-
| LocalStorageDriverConfig
|
|
55
|
-
| S3StorageDriverConfig
|
|
56
|
-
| R2StorageDriverConfig
|
|
57
|
-
| GcsStorageDriverConfig;
|
|
58
|
-
|
|
59
|
-
export type StorageDrivers = Record<string, StorageDriverConfig>;
|
|
60
|
-
|
|
61
|
-
export type StorageDriverName = keyof StorageDrivers;
|
|
62
|
-
|
|
63
|
-
export type StorageConfigRuntime = {
|
|
64
|
-
readonly default: string;
|
|
65
|
-
readonly drivers: StorageDrivers;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export type StartupConfigValidationError = {
|
|
69
|
-
key: string;
|
|
70
|
-
value: unknown;
|
|
71
|
-
message: string;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export type StartupConfigValidationResult = {
|
|
75
|
-
valid: boolean;
|
|
76
|
-
errors: StartupConfigValidationError[];
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export interface CloudflareKV {
|
|
80
|
-
get(key: string): Promise<string | null>;
|
|
81
|
-
put(key: string, value: string, options?: { expirationTtl?: number }): Promise<void>;
|
|
82
|
-
delete(key: string): Promise<void>;
|
|
83
|
-
list(options?: { prefix?: string }): Promise<{ keys: { name: string }[] }>;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export interface SecretConfig {
|
|
87
|
-
platform: 'aws' | 'cloudflare' | 'deno' | 'local';
|
|
88
|
-
region?: string;
|
|
89
|
-
kv?: CloudflareKV; // Cloudflare KV namespace
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export interface SecretValue {
|
|
93
|
-
key: string;
|
|
94
|
-
value: string;
|
|
95
|
-
expiresAt?: number;
|
|
96
|
-
rotationEnabled?: boolean;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export interface GetSecretOptions {
|
|
100
|
-
cacheTtl?: number; // Cache time-to-live in milliseconds
|
|
101
|
-
throwIfMissing?: boolean;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export interface SetSecretOptions {
|
|
105
|
-
expirationTtl?: number; // Expiration time-to-live in seconds
|
|
106
|
-
metadata?: Record<string, unknown>;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export interface SecretsManagerInstance {
|
|
110
|
-
getSecret(key: string, options?: GetSecretOptions): Promise<string>;
|
|
111
|
-
setSecret(key: string, value: string, options?: SetSecretOptions): Promise<void>;
|
|
112
|
-
deleteSecret(key: string): Promise<void>;
|
|
113
|
-
rotateSecret(key: string): Promise<void>;
|
|
114
|
-
listSecrets(pattern?: string): Promise<string[]>;
|
|
115
|
-
clearCache(key?: string): void;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export type QueueDriverName = 'sync' | 'database' | 'redis' | 'rabbitmq' | 'sqs';
|
|
119
|
-
|
|
120
|
-
export type SyncQueueDriverConfig = {
|
|
121
|
-
driver: 'sync';
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export type DatabaseQueueDriverConfig = {
|
|
125
|
-
driver: 'database';
|
|
126
|
-
table: string;
|
|
127
|
-
connection: string;
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
export type RedisQueueDriverConfig = {
|
|
131
|
-
driver: 'redis';
|
|
132
|
-
host: string;
|
|
133
|
-
port: number;
|
|
134
|
-
password?: string;
|
|
135
|
-
database: number;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
export type RabbitMqQueueDriverConfig = {
|
|
139
|
-
driver: 'rabbitmq';
|
|
140
|
-
host: string;
|
|
141
|
-
port: number;
|
|
142
|
-
username: string;
|
|
143
|
-
password: string;
|
|
144
|
-
vhost: string;
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
export type SqsQueueDriverConfig = {
|
|
148
|
-
driver: 'sqs';
|
|
149
|
-
key?: string;
|
|
150
|
-
secret?: string;
|
|
151
|
-
region: string;
|
|
152
|
-
queueUrl?: string;
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export type QueueDriversConfig = {
|
|
156
|
-
sync: SyncQueueDriverConfig;
|
|
157
|
-
database: DatabaseQueueDriverConfig;
|
|
158
|
-
redis: RedisQueueDriverConfig;
|
|
159
|
-
rabbitmq: RabbitMqQueueDriverConfig;
|
|
160
|
-
sqs: SqsQueueDriverConfig;
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
export type QueueConfigWithDrivers = {
|
|
164
|
-
default: QueueDriverName;
|
|
165
|
-
drivers: QueueDriversConfig;
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
export type KnownNotificationDriverName = 'console' | 'termii' | 'twilio' | 'slack';
|
|
169
|
-
|
|
170
|
-
export type ConsoleNotificationDriverConfig = { driver: 'console' };
|
|
171
|
-
|
|
172
|
-
export type TermiiNotificationDriverConfig = {
|
|
173
|
-
driver: 'termii';
|
|
174
|
-
apiKey: string;
|
|
175
|
-
sender: string;
|
|
176
|
-
endpoint: string;
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
export type TwilioNotificationDriverConfig = {
|
|
180
|
-
driver: 'twilio';
|
|
181
|
-
accountSid: string;
|
|
182
|
-
authToken: string;
|
|
183
|
-
fromNumber: string;
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
export type SlackNotificationDriverConfig = {
|
|
187
|
-
driver: 'slack';
|
|
188
|
-
webhookUrl: string;
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
export type KnownNotificationDriverConfig =
|
|
192
|
-
| ConsoleNotificationDriverConfig
|
|
193
|
-
| TermiiNotificationDriverConfig
|
|
194
|
-
| TwilioNotificationDriverConfig
|
|
195
|
-
| SlackNotificationDriverConfig;
|
|
196
|
-
|
|
197
|
-
export type NotificationDrivers = Record<string, KnownNotificationDriverConfig>;
|
|
198
|
-
|
|
199
|
-
export type NotificationConfigInput = {
|
|
200
|
-
default: string;
|
|
201
|
-
drivers: NotificationDrivers;
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
export type NotificationProviders = {
|
|
205
|
-
console: ConsoleNotificationDriverConfig;
|
|
206
|
-
termii: TermiiNotificationDriverConfig;
|
|
207
|
-
twilio: TwilioNotificationDriverConfig;
|
|
208
|
-
slack: SlackNotificationDriverConfig;
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
export type MiddlewareConfigType = {
|
|
212
|
-
global: MiddlewareFn[];
|
|
213
|
-
route: Record<string, MiddlewareFn>;
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
export type MailDriverName = 'disabled' | 'sendgrid' | 'smtp' | 'ses' | 'mailgun' | 'nodemailer';
|
|
217
|
-
|
|
218
|
-
export type DisabledMailDriverConfig = {
|
|
219
|
-
driver: 'disabled';
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
export type SendGridMailDriverConfig = {
|
|
223
|
-
driver: 'sendgrid';
|
|
224
|
-
apiKey: string;
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
export type MailgunMailDriverConfig = {
|
|
228
|
-
driver: 'mailgun';
|
|
229
|
-
apiKey: string;
|
|
230
|
-
domain: string;
|
|
231
|
-
baseUrl: string;
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
// Placeholders for future drivers (kept config-first)
|
|
235
|
-
export type SmtpMailDriverConfig = {
|
|
236
|
-
driver: 'smtp';
|
|
237
|
-
host: string;
|
|
238
|
-
port: number;
|
|
239
|
-
username: string;
|
|
240
|
-
password: string;
|
|
241
|
-
secure: boolean | 'starttls';
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
export type NodemailerMailDriverConfig = {
|
|
245
|
-
driver: 'nodemailer';
|
|
246
|
-
host: string;
|
|
247
|
-
port: number;
|
|
248
|
-
username: string;
|
|
249
|
-
password: string;
|
|
250
|
-
secure: boolean | 'starttls';
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
export type SesMailDriverConfig = {
|
|
254
|
-
driver: 'ses';
|
|
255
|
-
region: string;
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
export type MailDriverConfig =
|
|
259
|
-
| DisabledMailDriverConfig
|
|
260
|
-
| SendGridMailDriverConfig
|
|
261
|
-
| MailgunMailDriverConfig
|
|
262
|
-
| SmtpMailDriverConfig
|
|
263
|
-
| NodemailerMailDriverConfig
|
|
264
|
-
| SesMailDriverConfig;
|
|
265
|
-
|
|
266
|
-
export type MailDrivers = Record<string, MailDriverConfig>;
|
|
267
|
-
|
|
268
|
-
export type MailConfigInput = {
|
|
269
|
-
/**
|
|
270
|
-
* Default mailer key name.
|
|
271
|
-
*
|
|
272
|
-
* This is intentionally a string to support named mailers (e.g. 'transactional', 'marketing').
|
|
273
|
-
* The underlying driver is selected by the `driver` field within each mailer config.
|
|
274
|
-
*/
|
|
275
|
-
default: string;
|
|
276
|
-
from: {
|
|
277
|
-
address: string;
|
|
278
|
-
name: string;
|
|
279
|
-
};
|
|
280
|
-
drivers: MailDrivers;
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
export type ProcessLike = {
|
|
284
|
-
env?: Record<string, string | undefined>;
|
|
285
|
-
execPath?: string;
|
|
286
|
-
platform?: string;
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
export type SqliteConnectionConfig = {
|
|
290
|
-
driver: 'sqlite';
|
|
291
|
-
database: string;
|
|
292
|
-
migrations: string;
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
export type PostgresqlConnectionConfig = {
|
|
296
|
-
driver: 'postgresql';
|
|
297
|
-
host: string;
|
|
298
|
-
port: number;
|
|
299
|
-
database: string;
|
|
300
|
-
username: string;
|
|
301
|
-
password: string;
|
|
302
|
-
ssl: boolean;
|
|
303
|
-
pooling: {
|
|
304
|
-
enabled: boolean;
|
|
305
|
-
min: number;
|
|
306
|
-
max: number;
|
|
307
|
-
idleTimeout: number;
|
|
308
|
-
connectionTimeout: number;
|
|
309
|
-
};
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
export type MysqlConnectionConfig = {
|
|
313
|
-
driver: 'mysql';
|
|
314
|
-
host: string;
|
|
315
|
-
port: number;
|
|
316
|
-
database: string;
|
|
317
|
-
username: string;
|
|
318
|
-
password: string;
|
|
319
|
-
pooling: {
|
|
320
|
-
enabled: boolean;
|
|
321
|
-
min: number;
|
|
322
|
-
max: number;
|
|
323
|
-
};
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
export type D1ConnectionConfig = {
|
|
327
|
-
driver: 'd1';
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
export type D1RemoteConnectionConfig = {
|
|
331
|
-
driver: 'd1-remote';
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
export type DatabaseConnectionConfig =
|
|
335
|
-
| SqliteConnectionConfig
|
|
336
|
-
| PostgresqlConnectionConfig
|
|
337
|
-
| MysqlConnectionConfig
|
|
338
|
-
| D1ConnectionConfig
|
|
339
|
-
| D1RemoteConnectionConfig;
|
|
340
|
-
|
|
341
1
|
/**
|
|
342
|
-
*
|
|
2
|
+
* Config Types (template)
|
|
343
3
|
*
|
|
344
|
-
*
|
|
4
|
+
* Keep this file declarative:
|
|
5
|
+
* - Core owns canonical type definitions.
|
|
345
6
|
*/
|
|
346
|
-
export type DatabaseConnections = Record<string, DatabaseConnectionConfig>;
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Default connection name.
|
|
350
|
-
*/
|
|
351
|
-
export type DatabaseConfigShape = {
|
|
352
|
-
default: string;
|
|
353
|
-
connections: DatabaseConnections;
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
export type WorkersEnv = Record<string, unknown>;
|
|
357
|
-
|
|
358
|
-
export type KVNamespace = {
|
|
359
|
-
get(
|
|
360
|
-
key: string,
|
|
361
|
-
options?: { type: 'text' | 'json' | 'arrayBuffer' | 'stream' }
|
|
362
|
-
): Promise<unknown>;
|
|
363
|
-
put(
|
|
364
|
-
key: string,
|
|
365
|
-
value: string | ReadableStream | ArrayBuffer | FormData,
|
|
366
|
-
options?: { expiration?: number; expirationTtl?: number; metadata?: unknown }
|
|
367
|
-
): Promise<void>;
|
|
368
|
-
delete(key: string): Promise<void>;
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
export type MemoryCacheDriverConfig = {
|
|
372
|
-
driver: 'memory';
|
|
373
|
-
ttl: number;
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
export type RedisCacheDriverConfig = {
|
|
377
|
-
driver: 'redis';
|
|
378
|
-
host: string;
|
|
379
|
-
port: number;
|
|
380
|
-
ttl: number;
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
export type MongoCacheDriverConfig = {
|
|
384
|
-
driver: 'mongodb';
|
|
385
|
-
uri: string;
|
|
386
|
-
db: string;
|
|
387
|
-
ttl: number;
|
|
388
|
-
};
|
|
389
|
-
|
|
390
|
-
export type KvCacheDriverConfig = {
|
|
391
|
-
driver: 'kv';
|
|
392
|
-
ttl: number;
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
export type KvRemoteCacheDriverConfig = {
|
|
396
|
-
driver: 'kv-remote';
|
|
397
|
-
ttl: number;
|
|
398
|
-
};
|
|
399
|
-
|
|
400
|
-
export type CacheDriverConfig =
|
|
401
|
-
| MemoryCacheDriverConfig
|
|
402
|
-
| RedisCacheDriverConfig
|
|
403
|
-
| MongoCacheDriverConfig
|
|
404
|
-
| KvCacheDriverConfig
|
|
405
|
-
| KvRemoteCacheDriverConfig;
|
|
406
|
-
|
|
407
|
-
export type CacheDrivers = Record<string, CacheDriverConfig>;
|
|
408
|
-
|
|
409
|
-
export type CacheConfigInput = {
|
|
410
|
-
default: string;
|
|
411
|
-
drivers: CacheDrivers;
|
|
412
|
-
};
|
|
413
|
-
|
|
414
|
-
export type KnownBroadcastDriverName = 'inmemory' | 'pusher' | 'redis' | 'redishttps';
|
|
415
|
-
|
|
416
|
-
export type InMemoryBroadcastDriverConfig = {
|
|
417
|
-
driver: 'inmemory';
|
|
418
|
-
};
|
|
419
|
-
|
|
420
|
-
export type PusherBroadcastDriverConfig = {
|
|
421
|
-
driver: 'pusher';
|
|
422
|
-
appId: string;
|
|
423
|
-
key: string;
|
|
424
|
-
secret: string;
|
|
425
|
-
cluster: string;
|
|
426
|
-
useTLS: boolean;
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
export type RedisBroadcastDriverConfig = {
|
|
430
|
-
driver: 'redis';
|
|
431
|
-
host: string;
|
|
432
|
-
port: number;
|
|
433
|
-
password: string;
|
|
434
|
-
channelPrefix: string;
|
|
435
|
-
};
|
|
436
|
-
|
|
437
|
-
export type RedisHttpsBroadcastDriverConfig = {
|
|
438
|
-
driver: 'redishttps';
|
|
439
|
-
endpoint: string;
|
|
440
|
-
token: string;
|
|
441
|
-
channelPrefix: string;
|
|
442
|
-
};
|
|
443
|
-
|
|
444
|
-
export type KnownBroadcastDriverConfig =
|
|
445
|
-
| InMemoryBroadcastDriverConfig
|
|
446
|
-
| PusherBroadcastDriverConfig
|
|
447
|
-
| RedisBroadcastDriverConfig
|
|
448
|
-
| RedisHttpsBroadcastDriverConfig;
|
|
449
|
-
|
|
450
|
-
export type BroadcastDrivers = Record<string, KnownBroadcastDriverConfig>;
|
|
451
7
|
|
|
452
|
-
export type
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
8
|
+
export type {
|
|
9
|
+
BroadcastConfigInput,
|
|
10
|
+
BroadcastDrivers,
|
|
11
|
+
CacheConfigInput,
|
|
12
|
+
CacheDrivers,
|
|
13
|
+
DatabaseConfig,
|
|
14
|
+
DatabaseConfigShape,
|
|
15
|
+
DatabaseConnectionConfig,
|
|
16
|
+
DatabaseConnections,
|
|
17
|
+
KVNamespace,
|
|
18
|
+
KnownBroadcastDriverConfig,
|
|
19
|
+
KnownBroadcastDriverName,
|
|
20
|
+
MailConfig,
|
|
21
|
+
MailConfigInput,
|
|
22
|
+
MailDriverConfig,
|
|
23
|
+
MailDrivers,
|
|
24
|
+
MicroservicesConfig,
|
|
25
|
+
MiddlewareConfigType,
|
|
26
|
+
NotificationConfig,
|
|
27
|
+
NotificationConfigInput,
|
|
28
|
+
NotificationDrivers,
|
|
29
|
+
ProcessLike,
|
|
30
|
+
QueueConfig,
|
|
31
|
+
StorageConfig,
|
|
32
|
+
StorageConfigRuntime,
|
|
33
|
+
StorageDriverConfig,
|
|
34
|
+
StorageDrivers,
|
|
35
|
+
WorkersEnv,
|
|
36
|
+
} from '@zintrust/core';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { faker } from '@faker-js/faker';
|
|
2
|
+
|
|
3
|
+
interface UserFactoryData {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
email: string;
|
|
7
|
+
password: string;
|
|
8
|
+
email_verified_at: string | null;
|
|
9
|
+
active: boolean;
|
|
10
|
+
created_at: string;
|
|
11
|
+
updated_at: string;
|
|
12
|
+
deleted_at?: string | null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface UserFactory {
|
|
16
|
+
data: (data: Record<string, unknown>) => UserFactory;
|
|
17
|
+
set: (key: string, value: unknown) => UserFactory;
|
|
18
|
+
state: (name: string) => UserFactory;
|
|
19
|
+
count: (n: number) => UserFactoryData[];
|
|
20
|
+
getActiveState: () => { active: boolean; deleted_at: null };
|
|
21
|
+
getInactiveState: () => { active: boolean };
|
|
22
|
+
getDeletedState: () => { deleted_at: string };
|
|
23
|
+
create: () => UserFactoryData;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const makeUserData = (): Omit<UserFactoryData, 'deleted_at'> => ({
|
|
27
|
+
id: faker.number.int({ min: 1, max: 1000 }),
|
|
28
|
+
name: faker.person.fullName(),
|
|
29
|
+
email: faker.internet.email(),
|
|
30
|
+
password: faker.internet.password(),
|
|
31
|
+
email_verified_at: faker.date.past().toISOString(),
|
|
32
|
+
active: true,
|
|
33
|
+
created_at: new Date().toISOString(),
|
|
34
|
+
updated_at: new Date().toISOString(),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
let customData: Record<string, unknown> = {};
|
|
38
|
+
let customStates: Record<string, Record<string, unknown>> = {};
|
|
39
|
+
|
|
40
|
+
export const UserFactory = Object.freeze({
|
|
41
|
+
data(data: Record<string, unknown>): UserFactory {
|
|
42
|
+
customData = { ...data };
|
|
43
|
+
return UserFactory;
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
set(key: string, value: unknown): UserFactory {
|
|
47
|
+
customData[key] = value;
|
|
48
|
+
return UserFactory;
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
state(name: string): UserFactory {
|
|
52
|
+
customStates[name] = {};
|
|
53
|
+
return UserFactory;
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
count(n: number): UserFactoryData[] {
|
|
57
|
+
return Array.from({ length: n }, () => this.create());
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
getActiveState(): { active: boolean; deleted_at: null } {
|
|
61
|
+
return { active: true, deleted_at: null };
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
getInactiveState(): { active: boolean } {
|
|
65
|
+
return { active: false };
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
getDeletedState(): { deleted_at: string } {
|
|
69
|
+
return { deleted_at: new Date().toISOString() };
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
create(): UserFactoryData {
|
|
73
|
+
const base = makeUserData();
|
|
74
|
+
return {
|
|
75
|
+
...base,
|
|
76
|
+
...customData,
|
|
77
|
+
...customStates,
|
|
78
|
+
} as UserFactoryData;
|
|
79
|
+
},
|
|
80
|
+
}) as UserFactory;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Schema as MigrationSchema, type Blueprint } from '@zintrust/core/migrations';
|
|
2
|
+
import type { IDatabase } from '@zintrust/core/orm';
|
|
3
|
+
|
|
4
|
+
export interface Migration {
|
|
5
|
+
up(db: IDatabase): Promise<void>;
|
|
6
|
+
down(db: IDatabase): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const migration: Migration = {
|
|
10
|
+
async up(db: IDatabase): Promise<void> {
|
|
11
|
+
const schema = MigrationSchema.create(db);
|
|
12
|
+
|
|
13
|
+
await schema.create('tasks', (table: Blueprint) => {
|
|
14
|
+
table.id();
|
|
15
|
+
table.string('title');
|
|
16
|
+
table.text('description').nullable();
|
|
17
|
+
table.string('status').default('pending');
|
|
18
|
+
table.unsignedBigInt('user_id');
|
|
19
|
+
table.foreign('user_id').references('id').on('users').onDelete('CASCADE');
|
|
20
|
+
table.timestamps();
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
async down(db: IDatabase): Promise<void> {
|
|
25
|
+
const schema = MigrationSchema.create(db);
|
|
26
|
+
await schema.dropIfExists('tasks');
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Schema as MigrationSchema, type Blueprint } from '@zintrust/core/migrations';
|
|
2
|
+
import type { IDatabase } from '@zintrust/core/orm';
|
|
3
|
+
|
|
4
|
+
export interface Migration {
|
|
5
|
+
up(db: IDatabase): Promise<void>;
|
|
6
|
+
down(db: IDatabase): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const migration: Migration = {
|
|
10
|
+
async up(db: IDatabase): Promise<void> {
|
|
11
|
+
const schema = MigrationSchema.create(db);
|
|
12
|
+
|
|
13
|
+
await schema.create('users', (table: Blueprint) => {
|
|
14
|
+
table.id();
|
|
15
|
+
table.string('name');
|
|
16
|
+
table.string('email').unique();
|
|
17
|
+
table.string('password');
|
|
18
|
+
table.timestamp('email_verified_at').nullable();
|
|
19
|
+
table.boolean('active').default(true);
|
|
20
|
+
table.timestamps();
|
|
21
|
+
table.timestamp('deleted_at').nullable();
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
async down(db: IDatabase): Promise<void> {
|
|
26
|
+
const schema = MigrationSchema.create(db);
|
|
27
|
+
await schema.dropIfExists('users');
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SeederDiscovery } from '@zintrust/core/seeders';
|
|
2
|
+
import { SeederLoader } from '@zintrust/core/seeders';
|
|
3
|
+
import { CommonUtils } from '@zintrust/core/common';
|
|
4
|
+
import * as path from 'node:path';
|
|
5
|
+
import type { IDatabase } from '@zintrust/core/orm';
|
|
6
|
+
|
|
7
|
+
export const DatabaseSeeder = Object.freeze({
|
|
8
|
+
async run(db: IDatabase): Promise<void> {
|
|
9
|
+
const dir = CommonUtils.esmDirname(import.meta.url);
|
|
10
|
+
const files = SeederDiscovery.listSeederFiles(dir).filter((filePath) => {
|
|
11
|
+
const base = path.basename(filePath, path.extname(filePath));
|
|
12
|
+
return base !== 'DatabaseSeeder';
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const seeders = await Promise.all(files.map((filePath) => SeederLoader.load(filePath)));
|
|
16
|
+
|
|
17
|
+
await Promise.all(seeders.map((seeder) => seeder.run(db)));
|
|
18
|
+
},
|
|
19
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IDatabase } from '@zintrust/core/orm';
|
|
2
|
+
|
|
3
|
+
export interface Seeder {
|
|
4
|
+
run(db: IDatabase): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const UserSeeder: Seeder = Object.freeze({
|
|
8
|
+
async run(db: IDatabase): Promise<void> {
|
|
9
|
+
// Example: Use UserFactory from ../factories/UserFactory
|
|
10
|
+
// const users = UserFactory.count(5);
|
|
11
|
+
// for (const user of users) {
|
|
12
|
+
// Insert user data into database
|
|
13
|
+
// await db.query('INSERT INTO users (name, email, password, created_at, updated_at) VALUES (?, ?, ?, ?, ?)', [
|
|
14
|
+
// user.name, user.email, user.password, user.created_at, user.updated_at
|
|
15
|
+
// ]);
|
|
16
|
+
// }
|
|
17
|
+
},
|
|
18
|
+
});
|