@zintrust/core 0.1.19 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/bin/zintrust-main.d.ts.map +1 -1
- package/bin/zintrust-main.js +9 -0
- package/package.json +3 -2
- package/public/error-pages/404.html +145 -0
- package/public/error-pages/500.html +266 -0
- package/public/error-pages/error.css +628 -0
- package/public/error-pages/error.js +428 -0
- package/public/zintrust.svg +30 -0
- package/routes/api.d.ts.map +1 -1
- package/routes/api.js +41 -17
- package/routes/metrics.d.ts +9 -0
- package/routes/metrics.d.ts.map +1 -0
- package/routes/metrics.js +20 -0
- package/routes/openapi.d.ts +9 -0
- package/routes/openapi.d.ts.map +1 -0
- package/routes/openapi.js +76 -0
- package/src/boot/Application.d.ts +2 -2
- package/src/boot/Application.d.ts.map +1 -1
- package/src/boot/Application.js +66 -13
- package/src/boot/Server.d.ts +3 -2
- package/src/boot/Server.d.ts.map +1 -1
- package/src/boot/Server.js +39 -165
- package/src/boot/bootstrap.js +2 -0
- package/src/cache/Cache.d.ts +1 -1
- package/src/cache/Cache.d.ts.map +1 -1
- package/src/cache/CacheDriver.d.ts +4 -0
- package/src/cache/CacheDriver.d.ts.map +1 -1
- package/src/cache/drivers/KVDriver.d.ts +1 -1
- package/src/cache/drivers/KVDriver.d.ts.map +1 -1
- package/src/cache/drivers/MemoryDriver.d.ts +1 -1
- package/src/cache/drivers/MemoryDriver.d.ts.map +1 -1
- package/src/cache/drivers/MemoryDriver.js +16 -0
- package/src/cache/drivers/MongoDriver.d.ts +1 -1
- package/src/cache/drivers/MongoDriver.d.ts.map +1 -1
- package/src/cache/drivers/RedisDriver.d.ts +1 -1
- package/src/cache/drivers/RedisDriver.d.ts.map +1 -1
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +10 -4
- package/src/cli/commands/AddCommand.d.ts +2 -2
- package/src/cli/commands/AddCommand.d.ts.map +1 -1
- package/src/cli/commands/AddCommand.js +135 -58
- package/src/cli/commands/ConfigCommand.d.ts +1 -1
- package/src/cli/commands/ConfigCommand.d.ts.map +1 -1
- package/src/cli/commands/CreateCommand.d.ts +15 -0
- package/src/cli/commands/CreateCommand.d.ts.map +1 -0
- package/src/cli/commands/CreateCommand.js +143 -0
- package/src/cli/commands/D1MigrateCommand.d.ts +1 -1
- package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/D1MigrateCommand.js +16 -20
- package/src/cli/commands/DbSeedCommand.d.ts +9 -0
- package/src/cli/commands/DbSeedCommand.d.ts.map +1 -0
- package/src/cli/commands/DbSeedCommand.js +171 -0
- package/src/cli/commands/DebugCommand.d.ts +1 -1
- package/src/cli/commands/DebugCommand.d.ts.map +1 -1
- package/src/cli/commands/FixCommand.d.ts +1 -1
- package/src/cli/commands/FixCommand.d.ts.map +1 -1
- package/src/cli/commands/JwtDevCommand.d.ts +8 -0
- package/src/cli/commands/JwtDevCommand.d.ts.map +1 -0
- package/src/cli/commands/JwtDevCommand.js +114 -0
- package/src/cli/commands/KeyGenerateCommand.d.ts +1 -1
- package/src/cli/commands/KeyGenerateCommand.d.ts.map +1 -1
- package/src/cli/commands/LogsCommand.d.ts +2 -2
- package/src/cli/commands/LogsCommand.d.ts.map +1 -1
- package/src/cli/commands/LogsCommand.js +36 -2
- package/src/cli/commands/MakeMailTemplateCommand.d.ts +1 -1
- package/src/cli/commands/MakeMailTemplateCommand.d.ts.map +1 -1
- package/src/cli/commands/MakeNotificationTemplateCommand.d.ts +1 -1
- package/src/cli/commands/MakeNotificationTemplateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.d.ts +1 -1
- package/src/cli/commands/MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.js +324 -35
- package/src/cli/commands/NewCommand.d.ts +1 -1
- package/src/cli/commands/NewCommand.d.ts.map +1 -1
- package/src/cli/commands/NewCommand.js +12 -4
- package/src/cli/commands/PluginCommand.d.ts +1 -1
- package/src/cli/commands/PluginCommand.d.ts.map +1 -1
- package/src/cli/commands/PrepareCommand.d.ts +1 -1
- package/src/cli/commands/PrepareCommand.d.ts.map +1 -1
- package/src/cli/commands/QACommand.d.ts +2 -2
- package/src/cli/commands/QACommand.d.ts.map +1 -1
- package/src/cli/commands/RoutesCommand.d.ts +10 -0
- package/src/cli/commands/RoutesCommand.d.ts.map +1 -0
- package/src/cli/commands/RoutesCommand.js +242 -0
- package/src/cli/commands/SimulateCommand.d.ts +1 -1
- package/src/cli/commands/SimulateCommand.d.ts.map +1 -1
- package/src/cli/commands/index.d.ts +3 -0
- package/src/cli/commands/index.d.ts.map +1 -1
- package/src/cli/commands/index.js +3 -0
- package/src/cli/config/ConfigManager.d.ts +1 -1
- package/src/cli/config/ConfigManager.d.ts.map +1 -1
- package/src/cli/config/ConfigValidator.d.ts +1 -1
- package/src/cli/config/ConfigValidator.d.ts.map +1 -1
- package/src/cli/config/ConfigValidator.js +1 -1
- package/src/cli/d1/D1SqlMigrations.d.ts +20 -0
- package/src/cli/d1/D1SqlMigrations.d.ts.map +1 -0
- package/src/cli/d1/D1SqlMigrations.js +229 -0
- package/src/cli/d1/WranglerConfig.d.ts +4 -0
- package/src/cli/d1/WranglerConfig.d.ts.map +1 -0
- package/src/cli/d1/WranglerConfig.js +122 -0
- package/src/cli/d1/WranglerD1.d.ts +11 -0
- package/src/cli/d1/WranglerD1.d.ts.map +1 -0
- package/src/cli/d1/WranglerD1.js +16 -0
- package/src/cli/scaffolding/ControllerGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/ControllerGenerator.js +76 -26
- package/src/cli/scaffolding/FactoryGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/FactoryGenerator.js +3 -1
- package/src/cli/scaffolding/GovernanceScaffolder.d.ts +23 -0
- package/src/cli/scaffolding/GovernanceScaffolder.d.ts.map +1 -0
- package/src/cli/scaffolding/GovernanceScaffolder.js +327 -0
- package/src/cli/scaffolding/MigrationGenerator.d.ts +10 -0
- package/src/cli/scaffolding/MigrationGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/MigrationGenerator.js +137 -51
- package/src/cli/scaffolding/ModelGenerator.js +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.js +36 -4
- package/src/cli/scaffolding/RouteGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/RouteGenerator.js +79 -43
- package/src/cli/scaffolding/SeederGenerator.d.ts +5 -0
- package/src/cli/scaffolding/SeederGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/SeederGenerator.js +63 -15
- package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ServiceScaffolder.js +28 -7
- package/src/cli/scaffolding/index.d.ts +2 -0
- package/src/cli/scaffolding/index.d.ts.map +1 -1
- package/src/cli/scaffolding/index.js +1 -0
- package/src/common/index.d.ts +8 -0
- package/src/common/index.d.ts.map +1 -1
- package/src/common/index.js +28 -0
- package/src/common/utility.d.ts +38 -0
- package/src/common/utility.d.ts.map +1 -0
- package/src/common/utility.js +101 -0
- package/src/config/FileLogWriter.d.ts +2 -1
- package/src/config/FileLogWriter.d.ts.map +1 -1
- package/src/config/FileLogWriter.js +83 -2
- package/src/config/app.d.ts.map +1 -1
- package/src/config/app.js +3 -1
- package/src/config/broadcast.d.ts +14 -28
- package/src/config/broadcast.d.ts.map +1 -1
- package/src/config/broadcast.js +69 -35
- package/src/config/cache.d.ts +13 -45
- package/src/config/cache.d.ts.map +1 -1
- package/src/config/cache.js +69 -25
- package/src/config/cloudflare.d.ts +1 -1
- package/src/config/cloudflare.d.ts.map +1 -1
- package/src/config/database.d.ts +22 -64
- package/src/config/database.d.ts.map +1 -1
- package/src/config/database.js +191 -37
- package/src/config/env.d.ts +12 -0
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +14 -0
- package/src/config/index.d.ts +33 -137
- package/src/config/index.d.ts.map +1 -1
- package/src/config/logging/KvLogger.js +1 -1
- package/src/config/logging/SlackLogger.js +2 -2
- package/src/config/mail.d.ts +19 -55
- package/src/config/mail.d.ts.map +1 -1
- package/src/config/mail.js +63 -21
- package/src/config/middleware.d.ts +44 -1
- package/src/config/middleware.d.ts.map +1 -1
- package/src/config/middleware.js +157 -5
- package/src/config/notification.d.ts +14 -27
- package/src/config/notification.d.ts.map +1 -1
- package/src/config/notification.js +82 -36
- package/src/config/queue.d.ts +21 -51
- package/src/config/queue.d.ts.map +1 -1
- package/src/config/queue.js +72 -27
- package/src/config/security.d.ts +1 -1
- package/src/config/security.js +1 -1
- package/src/config/storage.d.ts +27 -34
- package/src/config/storage.d.ts.map +1 -1
- package/src/config/storage.js +97 -56
- package/src/config/type.d.ts +13 -2
- package/src/config/type.d.ts.map +1 -1
- package/src/events/EventDispatcher.d.ts.map +1 -1
- package/src/events/EventDispatcher.js +6 -4
- package/src/exceptions/ZintrustError.d.ts +7 -0
- package/src/exceptions/ZintrustError.d.ts.map +1 -1
- package/src/exceptions/ZintrustError.js +56 -0
- package/src/features/Auth.d.ts +1 -1
- package/src/features/Auth.d.ts.map +1 -1
- package/src/features/Auth.js +3 -3
- package/src/features/Queue.js +1 -1
- package/src/functions/cloudflare.d.ts.map +1 -1
- package/src/functions/cloudflare.js +3 -14
- package/src/functions/deno.d.ts.map +1 -1
- package/src/functions/deno.js +3 -14
- package/src/functions/lambda.d.ts.map +1 -1
- package/src/functions/lambda.js +3 -14
- package/src/health/StartupHealthChecks.js +1 -1
- package/src/http/Controller.d.ts +2 -2
- package/src/http/Controller.d.ts.map +1 -1
- package/src/http/FileUpload.d.ts +68 -0
- package/src/http/FileUpload.d.ts.map +1 -0
- package/src/http/FileUpload.js +120 -0
- package/src/http/Kernel.d.ts +5 -5
- package/src/http/Kernel.d.ts.map +1 -1
- package/src/http/Kernel.js +139 -23
- package/src/http/Request.d.ts +20 -1
- package/src/http/Request.d.ts.map +1 -1
- package/src/http/Request.js +23 -0
- package/src/http/RequestContext.d.ts +6 -0
- package/src/http/RequestContext.d.ts.map +1 -1
- package/src/http/RequestContext.js +77 -1
- package/src/http/Response.d.ts +1 -1
- package/src/http/Response.d.ts.map +1 -1
- package/src/http/ValidationHelper.d.ts +78 -0
- package/src/http/ValidationHelper.d.ts.map +1 -0
- package/src/http/ValidationHelper.js +121 -0
- package/src/http/error-pages/ErrorPageRenderer.d.ts +17 -0
- package/src/http/error-pages/ErrorPageRenderer.d.ts.map +1 -0
- package/src/http/error-pages/ErrorPageRenderer.js +88 -0
- package/src/http/middleware/BodyParsingMiddleware.d.ts +12 -0
- package/src/http/middleware/BodyParsingMiddleware.d.ts.map +1 -0
- package/src/http/middleware/BodyParsingMiddleware.js +251 -0
- package/src/http/middleware/FileUploadMiddleware.d.ts +12 -0
- package/src/http/middleware/FileUploadMiddleware.d.ts.map +1 -0
- package/src/http/middleware/FileUploadMiddleware.js +74 -0
- package/src/http/parsers/BodyParsers.d.ts +32 -0
- package/src/http/parsers/BodyParsers.d.ts.map +1 -0
- package/src/http/parsers/BodyParsers.js +159 -0
- package/src/http/parsers/MultipartParser.d.ts +33 -0
- package/src/http/parsers/MultipartParser.d.ts.map +1 -0
- package/src/http/parsers/MultipartParser.js +156 -0
- package/src/http/parsers/MultipartParserRegistry.d.ts +34 -0
- package/src/http/parsers/MultipartParserRegistry.d.ts.map +1 -0
- package/src/http/parsers/MultipartParserRegistry.js +20 -0
- package/src/http/validated.d.ts +12 -0
- package/src/http/validated.d.ts.map +1 -0
- package/src/http/validated.js +41 -0
- package/src/index.d.ts +73 -12
- package/src/index.d.ts.map +1 -1
- package/src/index.js +60 -5
- package/src/microservices/PostgresAdapter.d.ts.map +1 -1
- package/src/microservices/PostgresAdapter.js +0 -1
- package/src/microservices/RequestTracingMiddleware.d.ts +2 -2
- package/src/microservices/RequestTracingMiddleware.d.ts.map +1 -1
- package/src/microservices/RequestTracingMiddleware.js +3 -0
- package/src/microservices/ServiceAuthMiddleware.d.ts +2 -2
- package/src/microservices/ServiceAuthMiddleware.d.ts.map +1 -1
- package/src/middleware/AuthMiddleware.d.ts +10 -0
- package/src/middleware/AuthMiddleware.d.ts.map +1 -0
- package/src/middleware/AuthMiddleware.js +16 -0
- package/src/middleware/CsrfMiddleware.d.ts +11 -1
- package/src/middleware/CsrfMiddleware.d.ts.map +1 -1
- package/src/middleware/CsrfMiddleware.js +33 -0
- package/src/middleware/JwtAuthMiddleware.d.ts +11 -0
- package/src/middleware/JwtAuthMiddleware.d.ts.map +1 -0
- package/src/middleware/JwtAuthMiddleware.js +73 -0
- package/src/middleware/LoggingMiddleware.d.ts.map +1 -1
- package/src/middleware/LoggingMiddleware.js +8 -3
- package/src/middleware/MiddlewareStack.d.ts +2 -2
- package/src/middleware/MiddlewareStack.d.ts.map +1 -1
- package/src/middleware/RateLimiter.d.ts +2 -2
- package/src/middleware/RateLimiter.d.ts.map +1 -1
- package/src/middleware/SanitizeBodyMiddleware.d.ts +12 -0
- package/src/middleware/SanitizeBodyMiddleware.d.ts.map +1 -0
- package/src/middleware/SanitizeBodyMiddleware.js +31 -0
- package/src/middleware/SecurityMiddleware.d.ts +1 -1
- package/src/middleware/SecurityMiddleware.d.ts.map +1 -1
- package/src/middleware/SessionMiddleware.d.ts +1 -1
- package/src/middleware/SessionMiddleware.d.ts.map +1 -1
- package/src/middleware/ValidationMiddleware.d.ts +25 -0
- package/src/middleware/ValidationMiddleware.d.ts.map +1 -0
- package/src/middleware/ValidationMiddleware.js +251 -0
- package/src/migrations/MigrationDiscovery.d.ts +5 -0
- package/src/migrations/MigrationDiscovery.d.ts.map +1 -0
- package/src/migrations/MigrationDiscovery.js +16 -0
- package/src/migrations/MigrationLoader.d.ts +5 -0
- package/src/migrations/MigrationLoader.d.ts.map +1 -0
- package/src/migrations/MigrationLoader.js +43 -0
- package/src/migrations/MigrationLock.d.ts +4 -0
- package/src/migrations/MigrationLock.d.ts.map +1 -0
- package/src/migrations/MigrationLock.js +33 -0
- package/src/migrations/Migrator.d.ts +23 -0
- package/src/migrations/Migrator.d.ts.map +1 -0
- package/src/migrations/Migrator.js +4 -0
- package/src/migrations/MigratorFactory.d.ts +25 -0
- package/src/migrations/MigratorFactory.d.ts.map +1 -0
- package/src/migrations/MigratorFactory.js +339 -0
- package/src/migrations/schema/Blueprint.d.ts +5 -0
- package/src/migrations/schema/Blueprint.d.ts.map +1 -0
- package/src/migrations/schema/Blueprint.js +189 -0
- package/src/migrations/schema/Schema.d.ts +8 -0
- package/src/migrations/schema/Schema.d.ts.map +1 -0
- package/src/migrations/schema/Schema.js +141 -0
- package/src/migrations/schema/SchemaCompiler.d.ts +20 -0
- package/src/migrations/schema/SchemaCompiler.d.ts.map +1 -0
- package/src/migrations/schema/SchemaCompiler.js +262 -0
- package/src/migrations/schema/index.d.ts +5 -0
- package/src/migrations/schema/index.d.ts.map +1 -0
- package/src/migrations/schema/index.js +3 -0
- package/src/migrations/schema/types.d.ts +86 -0
- package/src/migrations/schema/types.d.ts.map +1 -0
- package/src/migrations/schema/types.js +1 -0
- package/src/migrations/types.d.ts +45 -0
- package/src/migrations/types.d.ts.map +1 -0
- package/src/migrations/types.js +1 -0
- package/src/node-singletons/crypto.d.ts +1 -1
- package/src/node-singletons/crypto.d.ts.map +1 -1
- package/src/node-singletons/crypto.js +1 -1
- package/src/node-singletons/fs.d.ts +2 -2
- package/src/node-singletons/fs.d.ts.map +1 -1
- package/src/node-singletons/fs.js +1 -1
- package/src/node-singletons/util.d.ts +6 -0
- package/src/node-singletons/util.d.ts.map +1 -0
- package/src/node-singletons/util.js +5 -0
- package/src/node.d.ts +3 -1
- package/src/node.d.ts.map +1 -1
- package/src/node.js +6 -2
- package/src/observability/OpenTelemetry.d.ts +62 -0
- package/src/observability/OpenTelemetry.d.ts.map +1 -0
- package/src/observability/OpenTelemetry.js +167 -0
- package/src/observability/PrometheusMetrics.d.ts +25 -0
- package/src/observability/PrometheusMetrics.d.ts.map +1 -0
- package/src/observability/PrometheusMetrics.js +114 -0
- package/src/openapi/OpenApiGenerator.d.ts +68 -0
- package/src/openapi/OpenApiGenerator.d.ts.map +1 -0
- package/src/openapi/OpenApiGenerator.js +287 -0
- package/src/orm/Database.d.ts +5 -2
- package/src/orm/Database.d.ts.map +1 -1
- package/src/orm/Database.js +219 -63
- package/src/orm/DatabaseAdapter.d.ts +14 -0
- package/src/orm/DatabaseAdapter.d.ts.map +1 -1
- package/src/orm/DatabaseAdapterRegistry.d.ts.map +1 -1
- package/src/orm/DatabaseAdapterRegistry.js +3 -1
- package/src/orm/DatabaseRuntimeRegistration.d.ts.map +1 -1
- package/src/orm/DatabaseRuntimeRegistration.js +12 -0
- package/src/orm/Model.d.ts +30 -2
- package/src/orm/Model.d.ts.map +1 -1
- package/src/orm/Model.js +255 -62
- package/src/orm/QueryBuilder.d.ts +22 -1
- package/src/orm/QueryBuilder.d.ts.map +1 -1
- package/src/orm/QueryBuilder.js +406 -99
- package/src/orm/Relationships.d.ts +7 -1
- package/src/orm/Relationships.d.ts.map +1 -1
- package/src/orm/Relationships.js +18 -0
- package/src/orm/SchemaCompiler.d.ts +9 -0
- package/src/orm/SchemaCompiler.d.ts.map +1 -0
- package/src/orm/SchemaCompiler.js +145 -0
- package/src/orm/adapters/D1Adapter.d.ts +1 -1
- package/src/orm/adapters/D1Adapter.d.ts.map +1 -1
- package/src/orm/adapters/MySQLAdapter.d.ts +1 -1
- package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/MySQLAdapter.js +88 -69
- package/src/orm/adapters/PostgreSQLAdapter.d.ts +1 -1
- package/src/orm/adapters/PostgreSQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/PostgreSQLAdapter.js +88 -69
- package/src/orm/adapters/SQLServerAdapter.d.ts +1 -1
- package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLiteAdapter.d.ts +1 -1
- package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLiteAdapter.js +59 -3
- package/src/orm/maintenance/SqliteMaintenance.d.ts +5 -0
- package/src/orm/maintenance/SqliteMaintenance.d.ts.map +1 -0
- package/src/orm/maintenance/SqliteMaintenance.js +14 -0
- package/src/orm/migrations/MigrationStore.d.ts +38 -0
- package/src/orm/migrations/MigrationStore.d.ts.map +1 -0
- package/src/orm/migrations/MigrationStore.js +157 -0
- package/src/performance/CodeGenerationBenchmark.d.ts.map +1 -1
- package/src/performance/Optimizer.d.ts +7 -6
- package/src/performance/Optimizer.d.ts.map +1 -1
- package/src/performance/Optimizer.js +170 -55
- package/src/profiling/MemoryProfiler.d.ts +1 -1
- package/src/profiling/MemoryProfiler.d.ts.map +1 -1
- package/src/profiling/N1Detector.d.ts +1 -1
- package/src/profiling/N1Detector.d.ts.map +1 -1
- package/src/profiling/QueryLogger.d.ts +1 -1
- package/src/profiling/QueryLogger.d.ts.map +1 -1
- package/src/profiling/RequestProfiler.d.ts +3 -3
- package/src/profiling/RequestProfiler.d.ts.map +1 -1
- package/src/routes/metrics.d.ts +2 -0
- package/src/routes/metrics.d.ts.map +1 -0
- package/src/routes/metrics.js +1 -0
- package/src/routing/CoreRoutes.d.ts +12 -0
- package/src/routing/CoreRoutes.d.ts.map +1 -0
- package/src/routing/CoreRoutes.js +151 -0
- package/src/routing/RouteRegistry.d.ts +39 -0
- package/src/routing/RouteRegistry.d.ts.map +1 -0
- package/src/routing/RouteRegistry.js +44 -0
- package/src/routing/Router.d.ts +26 -9
- package/src/routing/Router.d.ts.map +1 -1
- package/src/routing/Router.js +79 -35
- package/src/routing/common.d.ts +15 -0
- package/src/routing/common.d.ts.map +1 -0
- package/src/routing/common.js +47 -0
- package/src/routing/doc.d.ts +27 -0
- package/src/routing/doc.d.ts.map +1 -0
- package/src/routing/doc.js +110 -0
- package/src/routing/error.d.ts +21 -0
- package/src/routing/error.d.ts.map +1 -0
- package/src/routing/error.js +126 -0
- package/src/routing/errorPages.d.ts +14 -0
- package/src/routing/errorPages.d.ts.map +1 -0
- package/src/routing/errorPages.js +103 -0
- package/src/routing/publicRoot.d.ts +27 -0
- package/src/routing/publicRoot.d.ts.map +1 -0
- package/src/routing/publicRoot.js +110 -0
- package/src/runtime/PluginAutoImports.d.ts +21 -0
- package/src/runtime/PluginAutoImports.d.ts.map +1 -0
- package/src/runtime/PluginAutoImports.js +59 -0
- package/src/runtime/PluginManager.d.ts +1 -5
- package/src/runtime/PluginManager.d.ts.map +1 -1
- package/src/runtime/PluginManager.js +25 -18
- package/src/runtime/RuntimeDetector.d.ts +1 -1
- package/src/runtime/RuntimeDetector.d.ts.map +1 -1
- package/src/runtime/StartupConfigFileRegistry.d.ts +20 -0
- package/src/runtime/StartupConfigFileRegistry.d.ts.map +1 -0
- package/src/runtime/StartupConfigFileRegistry.js +44 -0
- package/src/runtime/adapters/CloudflareAdapter.d.ts +1 -1
- package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/CloudflareAdapter.js +1 -1
- package/src/runtime/adapters/DenoAdapter.d.ts +1 -1
- package/src/runtime/adapters/DenoAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/DenoAdapter.js +1 -1
- package/src/runtime/adapters/LambdaAdapter.d.ts +1 -1
- package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/LambdaAdapter.js +1 -1
- package/src/runtime/adapters/NodeServerAdapter.d.ts +1 -1
- package/src/runtime/adapters/NodeServerAdapter.d.ts.map +1 -1
- package/src/runtime/getKernel.d.ts +9 -0
- package/src/runtime/getKernel.d.ts.map +1 -0
- package/src/runtime/getKernel.js +27 -0
- package/src/runtime/useFileLoader.d.ts +26 -0
- package/src/runtime/useFileLoader.d.ts.map +1 -0
- package/src/runtime/useFileLoader.js +188 -0
- package/src/scripts/TemplateImportsCheck.js +40 -0
- package/src/scripts/TemplateSync.js +90 -24
- package/src/security/Encryptor.d.ts.map +1 -1
- package/src/security/Encryptor.js +64 -7
- package/src/security/JwtManager.d.ts +1 -0
- package/src/security/JwtManager.d.ts.map +1 -1
- package/src/security/JwtManager.js +33 -0
- package/src/security/Sanitizer.d.ts +76 -0
- package/src/security/Sanitizer.d.ts.map +1 -0
- package/src/security/Sanitizer.js +412 -0
- package/src/security/TokenRevocation.d.ts +7 -0
- package/src/security/TokenRevocation.d.ts.map +1 -0
- package/src/security/TokenRevocation.js +57 -0
- package/src/security/XssProtection.d.ts.map +1 -1
- package/src/security/XssProtection.js +62 -14
- package/src/seeders/SeederDiscovery.d.ts +5 -0
- package/src/seeders/SeederDiscovery.d.ts.map +1 -0
- package/src/seeders/SeederDiscovery.js +21 -0
- package/src/seeders/SeederLoader.d.ts +5 -0
- package/src/seeders/SeederLoader.d.ts.map +1 -0
- package/src/seeders/SeederLoader.js +60 -0
- package/src/seeders/types.d.ts +18 -0
- package/src/seeders/types.d.ts.map +1 -0
- package/src/seeders/types.js +1 -0
- package/src/session/SessionManager.js +1 -1
- package/src/templates/adapters/MySQLAdapter.ts.tpl +109 -85
- package/src/templates/adapters/PostgreSQLAdapter.ts.tpl +129 -88
- package/src/templates/adapters/SQLServerAdapter.ts.tpl +5 -9
- package/src/templates/adapters/SQLiteAdapter.ts.tpl +78 -11
- package/src/templates/features/Queue.ts.tpl +3 -2
- package/src/templates/project/basic/app/Controllers/AuthController.ts.tpl +217 -0
- package/src/templates/project/basic/app/Controllers/UserController.ts.tpl +1 -12
- package/src/templates/project/basic/app/Types/controller.ts.tpl +46 -0
- package/src/templates/project/basic/config/FileLogWriter.ts.tpl +5 -236
- package/src/templates/project/basic/config/SecretsManager.ts.tpl +10 -447
- package/src/templates/project/basic/config/StartupConfigValidator.ts.tpl +9 -268
- package/src/templates/project/basic/config/app.ts.tpl +13 -153
- package/src/templates/project/basic/config/broadcast.ts.tpl +29 -126
- package/src/templates/project/basic/config/cache.ts.tpl +12 -70
- package/src/templates/project/basic/config/cloudflare.ts.tpl +4 -39
- package/src/templates/project/basic/config/constants.ts.tpl +9 -65
- package/src/templates/project/basic/config/database.ts.tpl +66 -123
- package/src/templates/project/basic/config/env.ts.tpl +5 -169
- package/src/templates/project/basic/config/features.ts.tpl +6 -54
- package/src/templates/project/basic/config/index.ts.tpl +8 -23
- package/src/templates/project/basic/config/logging/HttpLogger.ts.tpl +7 -114
- package/src/templates/project/basic/config/mail.ts.tpl +9 -62
- package/src/templates/project/basic/config/microservices.ts.tpl +11 -97
- package/src/templates/project/basic/config/middleware.ts.tpl +25 -43
- package/src/templates/project/basic/config/notification.ts.tpl +13 -114
- package/src/templates/project/basic/config/queue.ts.tpl +9 -40
- package/src/templates/project/basic/config/security.ts.tpl +11 -163
- package/src/templates/project/basic/config/startup.ts.tpl +10 -21
- package/src/templates/project/basic/config/storage.ts.tpl +57 -137
- package/src/templates/project/basic/config/type.ts.tpl +32 -451
- package/src/templates/project/basic/database/factories/UserFactory.ts.tpl +80 -0
- package/src/templates/project/basic/database/migrations/create_tasks_table.ts.tpl +28 -0
- package/src/templates/project/basic/database/migrations/create_users_table.ts.tpl +29 -0
- package/src/templates/project/basic/database/seeders/DatabaseSeeder.ts.tpl +19 -0
- package/src/templates/project/basic/database/seeders/UserSeeder.ts.tpl +18 -0
- package/src/templates/project/basic/database/seeders/index.ts.tpl +2 -0
- package/src/templates/project/basic/routes/api.ts.tpl +71 -33
- package/src/templates/project/basic/routes/metrics.ts.tpl +22 -0
- package/src/templates/project/basic/src/index.ts.tpl +3 -0
- package/src/templates/project/basic/tsconfig.json.tpl +12 -11
- package/src/testing/TestEnvironment.d.ts +40 -0
- package/src/testing/TestEnvironment.d.ts.map +1 -0
- package/src/testing/TestEnvironment.js +141 -0
- package/src/testing/TestHttp.d.ts +29 -0
- package/src/testing/TestHttp.d.ts.map +1 -0
- package/src/testing/TestHttp.js +96 -0
- package/src/testing/index.d.ts +5 -0
- package/src/testing/index.d.ts.map +1 -0
- package/src/testing/index.js +2 -0
- package/src/time/DateTime.d.ts +181 -0
- package/src/time/DateTime.d.ts.map +1 -0
- package/src/time/DateTime.js +300 -0
- package/src/time/index.d.ts +7 -0
- package/src/time/index.d.ts.map +1 -0
- package/src/time/index.js +5 -0
- package/src/tools/http/Http.d.ts.map +1 -1
- package/src/tools/http/Http.js +4 -0
- package/src/tools/mail/drivers/Smtp.js +1 -1
- package/src/tools/queue/drivers/InMemory.d.ts +1 -1
- package/src/tools/queue/drivers/InMemory.d.ts.map +1 -1
- package/src/tools/queue/drivers/InMemory.js +1 -1
- package/src/tools/queue/drivers/Redis.d.ts +1 -1
- package/src/tools/queue/drivers/Redis.d.ts.map +1 -1
- package/src/tools/queue/drivers/Redis.js +1 -1
- package/src/validation/ValidationError.d.ts.map +1 -1
- package/src/validation/ValidationError.js +4 -2
- package/src/validation/Validator.d.ts +49 -16
- package/src/validation/Validator.d.ts.map +1 -1
- package/src/validation/Validator.js +307 -5
- package/src/common/uuid.d.ts +0 -3
- package/src/common/uuid.d.ts.map +0 -1
- package/src/common/uuid.js +0 -30
- package/src/templates/project/basic/.env.example.tpl +0 -74
- package/src/templates/project/basic/.env.tpl +0 -166
- package/src/templates/project/basic/config/logging/KvLogger.ts.tpl +0 -181
- package/src/templates/project/basic/config/logging/SlackLogger.ts.tpl +0 -156
- package/src/templates/project/basic/database/migrations/index.ts.tpl +0 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ColumnDefinition, ForeignKeyDefinition, IndexDefinition, TableDefinition } from '../../migrations/schema/types';
|
|
2
|
+
type AlterTablePlan = {
|
|
3
|
+
addColumns: ColumnDefinition[];
|
|
4
|
+
dropColumns: string[];
|
|
5
|
+
createIndexes: IndexDefinition[];
|
|
6
|
+
dropIndexes: string[];
|
|
7
|
+
addForeignKeys: ForeignKeyDefinition[];
|
|
8
|
+
dropForeignKeys: string[];
|
|
9
|
+
};
|
|
10
|
+
export declare const MigrationSchemaCompiler: Readonly<{
|
|
11
|
+
compileCreateTable(driver: string, def: TableDefinition, opts?: {
|
|
12
|
+
ifNotExists?: boolean;
|
|
13
|
+
}): string[];
|
|
14
|
+
compileDropTable(driver: string, table: string, opts?: {
|
|
15
|
+
ifExists?: boolean;
|
|
16
|
+
}): string;
|
|
17
|
+
compileAlterTable(driver: string, table: string, plan: AlterTablePlan): string[];
|
|
18
|
+
}>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=SchemaCompiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaCompiler.d.ts","sourceRoot":"","sources":["../../../../src/migrations/schema/SchemaCompiler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAEhB,oBAAoB,EACpB,eAAe,EACf,eAAe,EAChB,MAAM,2BAA2B,CAAC;AAMnC,KAAK,cAAc,GAAG;IACpB,UAAU,EAAE,gBAAgB,EAAE,CAAC;IAC/B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,EAAE,eAAe,EAAE,CAAC;IACjC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,EAAE,oBAAoB,EAAE,CAAC;IACvC,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC;AAoUF,eAAO,MAAM,uBAAuB;+BAExB,MAAM,OACT,eAAe,SACb;QAAE,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,GAC/B,MAAM,EAAE;6BAKc,MAAM,SAAS,MAAM,SAAS;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM;8BAK5D,MAAM,SAAS,MAAM,QAAQ,cAAc,GAAG,MAAM,EAAE;EAIhF,CAAC"}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
2
|
+
const IDENT_RE = /^[A-Za-z_]\w*$/;
|
|
3
|
+
function isSupportedDriver(driver) {
|
|
4
|
+
return (driver === 'sqlite' ||
|
|
5
|
+
driver === 'd1' ||
|
|
6
|
+
driver === 'd1-remote' ||
|
|
7
|
+
driver === 'postgresql' ||
|
|
8
|
+
driver === 'mysql' ||
|
|
9
|
+
driver === 'sqlserver');
|
|
10
|
+
}
|
|
11
|
+
function assertIdentifier(label, value) {
|
|
12
|
+
if (!IDENT_RE.test(value)) {
|
|
13
|
+
throw ErrorFactory.createValidationError(`Invalid ${label} identifier: ${value}`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function requireSupportedDriver(driver) {
|
|
17
|
+
if (!isSupportedDriver(driver)) {
|
|
18
|
+
throw ErrorFactory.createValidationError(`Unsupported DB driver: ${driver}`);
|
|
19
|
+
}
|
|
20
|
+
return driver;
|
|
21
|
+
}
|
|
22
|
+
function quoteIdent(driver, ident) {
|
|
23
|
+
assertIdentifier('SQL', ident);
|
|
24
|
+
if (driver === 'mysql')
|
|
25
|
+
return `\`${ident}\``;
|
|
26
|
+
return `"${ident}"`;
|
|
27
|
+
}
|
|
28
|
+
function isSqliteFamily(driver) {
|
|
29
|
+
return driver === 'sqlite' || driver === 'd1' || driver === 'd1-remote';
|
|
30
|
+
}
|
|
31
|
+
function normalizeForeignKeyAction(action) {
|
|
32
|
+
switch (action) {
|
|
33
|
+
case 'CASCADE':
|
|
34
|
+
case 'SET NULL':
|
|
35
|
+
case 'RESTRICT':
|
|
36
|
+
case 'NO ACTION':
|
|
37
|
+
case 'SET DEFAULT':
|
|
38
|
+
return action;
|
|
39
|
+
default:
|
|
40
|
+
throw ErrorFactory.createValidationError(`Unsupported foreign key action: ${String(action)}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const TYPE_SQL = Object.freeze({
|
|
44
|
+
STRING: (driver, def) => {
|
|
45
|
+
const len = typeof def.length === 'number' && Number.isFinite(def.length) ? def.length : 255;
|
|
46
|
+
return isSqliteFamily(driver) ? 'TEXT' : `VARCHAR(${len})`;
|
|
47
|
+
},
|
|
48
|
+
INTEGER: (driver) => (driver === 'mysql' ? 'INT' : 'INTEGER'),
|
|
49
|
+
REAL: (driver) => (driver === 'sqlserver' ? 'FLOAT' : 'REAL'),
|
|
50
|
+
BOOLEAN: (driver) => (driver === 'mysql' ? 'TINYINT(1)' : 'BOOLEAN'),
|
|
51
|
+
TEXT: () => 'TEXT',
|
|
52
|
+
JSON: (driver) => {
|
|
53
|
+
if (driver === 'postgresql')
|
|
54
|
+
return 'JSONB';
|
|
55
|
+
if (driver === 'mysql')
|
|
56
|
+
return 'JSON';
|
|
57
|
+
return 'TEXT';
|
|
58
|
+
},
|
|
59
|
+
TIMESTAMP: (driver) => {
|
|
60
|
+
if (driver === 'mysql')
|
|
61
|
+
return 'DATETIME';
|
|
62
|
+
if (driver === 'postgresql')
|
|
63
|
+
return 'TIMESTAMP';
|
|
64
|
+
return 'TEXT';
|
|
65
|
+
},
|
|
66
|
+
BLOB: () => 'BLOB',
|
|
67
|
+
});
|
|
68
|
+
function getColumnTypeSql(driver, def) {
|
|
69
|
+
return TYPE_SQL[def.type](driver, def);
|
|
70
|
+
}
|
|
71
|
+
function getAutoIncrementColumnSql(driver, colName) {
|
|
72
|
+
const sqliteFamily = isSqliteFamily(driver);
|
|
73
|
+
if (sqliteFamily) {
|
|
74
|
+
return `${colName} INTEGER PRIMARY KEY AUTOINCREMENT`;
|
|
75
|
+
}
|
|
76
|
+
if (driver === 'postgresql') {
|
|
77
|
+
return `${colName} SERIAL PRIMARY KEY`;
|
|
78
|
+
}
|
|
79
|
+
if (driver === 'mysql') {
|
|
80
|
+
return `${colName} INT AUTO_INCREMENT PRIMARY KEY`;
|
|
81
|
+
}
|
|
82
|
+
if (driver === 'sqlserver') {
|
|
83
|
+
return `${colName} INT IDENTITY(1,1) PRIMARY KEY`;
|
|
84
|
+
}
|
|
85
|
+
throw ErrorFactory.createValidationError(`Auto-increment not supported for driver: ${driver}`);
|
|
86
|
+
}
|
|
87
|
+
function formatDefaultValueSql(table, def) {
|
|
88
|
+
if (def.defaultValue === undefined)
|
|
89
|
+
return null;
|
|
90
|
+
const dv = def.defaultValue;
|
|
91
|
+
if (dv === null)
|
|
92
|
+
return 'DEFAULT NULL';
|
|
93
|
+
if (typeof dv === 'number' && Number.isFinite(dv))
|
|
94
|
+
return `DEFAULT ${dv}`;
|
|
95
|
+
if (typeof dv === 'boolean')
|
|
96
|
+
return `DEFAULT ${dv ? 1 : 0}`;
|
|
97
|
+
if (typeof dv === 'string') {
|
|
98
|
+
if (dv === 'CURRENT_TIMESTAMP')
|
|
99
|
+
return 'DEFAULT CURRENT_TIMESTAMP';
|
|
100
|
+
const escaped = dv.replaceAll("'", "''");
|
|
101
|
+
return `DEFAULT '${escaped}'`;
|
|
102
|
+
}
|
|
103
|
+
throw ErrorFactory.createValidationError(`Unsupported default type for ${table}.${def.name}`);
|
|
104
|
+
}
|
|
105
|
+
function buildColumnSql(driver, table, def) {
|
|
106
|
+
assertIdentifier('table', table);
|
|
107
|
+
assertIdentifier('column', def.name);
|
|
108
|
+
const col = quoteIdent(driver, def.name);
|
|
109
|
+
if (def.autoIncrement === true) {
|
|
110
|
+
if (def.type !== 'INTEGER') {
|
|
111
|
+
throw ErrorFactory.createValidationError(`Auto-increment column must be INTEGER: ${table}.${def.name}`);
|
|
112
|
+
}
|
|
113
|
+
return getAutoIncrementColumnSql(driver, col);
|
|
114
|
+
}
|
|
115
|
+
const parts = [`${col} ${getColumnTypeSql(driver, def)}`];
|
|
116
|
+
if (driver === 'mysql' &&
|
|
117
|
+
def.unsigned === true &&
|
|
118
|
+
(def.type === 'INTEGER' || def.type === 'REAL')) {
|
|
119
|
+
parts.push('UNSIGNED');
|
|
120
|
+
}
|
|
121
|
+
if (def.nullable !== true)
|
|
122
|
+
parts.push('NOT NULL');
|
|
123
|
+
if (def.unique === true)
|
|
124
|
+
parts.push('UNIQUE');
|
|
125
|
+
if (def.primary === true)
|
|
126
|
+
parts.push('PRIMARY KEY');
|
|
127
|
+
const defaultSql = formatDefaultValueSql(table, def);
|
|
128
|
+
if (defaultSql !== null)
|
|
129
|
+
parts.push(defaultSql);
|
|
130
|
+
return parts.join(' ');
|
|
131
|
+
}
|
|
132
|
+
function buildPrimaryKeyConstraintSql(driver, columns) {
|
|
133
|
+
const cols = columns.map((c) => {
|
|
134
|
+
assertIdentifier('column', c);
|
|
135
|
+
return quoteIdent(driver, c);
|
|
136
|
+
});
|
|
137
|
+
return `PRIMARY KEY (${cols.join(', ')})`;
|
|
138
|
+
}
|
|
139
|
+
function buildForeignKeyConstraintSql(driver, table, fk) {
|
|
140
|
+
assertIdentifier('table', table);
|
|
141
|
+
assertIdentifier('foreign key', fk.name);
|
|
142
|
+
assertIdentifier('referenced table', fk.referencedTable);
|
|
143
|
+
for (const c of fk.columns)
|
|
144
|
+
assertIdentifier('column', c);
|
|
145
|
+
for (const c of fk.referencedColumns)
|
|
146
|
+
assertIdentifier('referenced column', c);
|
|
147
|
+
const constraint = `CONSTRAINT ${quoteIdent(driver, fk.name)}`;
|
|
148
|
+
const localCols = fk.columns.map((c) => quoteIdent(driver, c)).join(', ');
|
|
149
|
+
const refCols = fk.referencedColumns.map((c) => quoteIdent(driver, c)).join(', ');
|
|
150
|
+
const parts = [
|
|
151
|
+
`${constraint} FOREIGN KEY (${localCols}) REFERENCES ${quoteIdent(driver, fk.referencedTable)} (${refCols})`,
|
|
152
|
+
];
|
|
153
|
+
if (fk.onDelete)
|
|
154
|
+
parts.push(`ON DELETE ${normalizeForeignKeyAction(fk.onDelete)}`);
|
|
155
|
+
if (fk.onUpdate)
|
|
156
|
+
parts.push(`ON UPDATE ${normalizeForeignKeyAction(fk.onUpdate)}`);
|
|
157
|
+
return parts.join(' ');
|
|
158
|
+
}
|
|
159
|
+
function buildCreateIndexSql(driver, table, idx) {
|
|
160
|
+
assertIdentifier('table', table);
|
|
161
|
+
assertIdentifier('index', idx.name);
|
|
162
|
+
for (const c of idx.columns)
|
|
163
|
+
assertIdentifier('column', c);
|
|
164
|
+
const unique = idx.type === 'UNIQUE' ? 'UNIQUE ' : '';
|
|
165
|
+
const cols = idx.columns.map((c) => quoteIdent(driver, c)).join(', ');
|
|
166
|
+
return `CREATE ${unique}INDEX ${quoteIdent(driver, idx.name)} ON ${quoteIdent(driver, table)} (${cols})`;
|
|
167
|
+
}
|
|
168
|
+
function buildDropIndexSql(driver, table, indexName) {
|
|
169
|
+
assertIdentifier('table', table);
|
|
170
|
+
assertIdentifier('index', indexName);
|
|
171
|
+
if (driver === 'mysql') {
|
|
172
|
+
return `DROP INDEX ${quoteIdent(driver, indexName)} ON ${quoteIdent(driver, table)}`;
|
|
173
|
+
}
|
|
174
|
+
return `DROP INDEX IF EXISTS ${quoteIdent(driver, indexName)}`;
|
|
175
|
+
}
|
|
176
|
+
function buildDropTableSql(driver, table, ifExists) {
|
|
177
|
+
assertIdentifier('table', table);
|
|
178
|
+
const ine = ifExists ? 'IF EXISTS ' : '';
|
|
179
|
+
return `DROP TABLE ${ine}${quoteIdent(driver, table)}`;
|
|
180
|
+
}
|
|
181
|
+
function buildCreateTableStatements(driver, def, ifNotExists) {
|
|
182
|
+
assertIdentifier('table', def.name);
|
|
183
|
+
if (def.columns.length === 0) {
|
|
184
|
+
throw ErrorFactory.createValidationError(`Schema for table '${def.name}' has no columns`);
|
|
185
|
+
}
|
|
186
|
+
const primaryCols = def.columns.filter((c) => c.primary === true).map((c) => c.name);
|
|
187
|
+
const colLines = def.columns.map((c) => buildColumnSql(driver, def.name, c));
|
|
188
|
+
const constraints = [];
|
|
189
|
+
if (primaryCols.length > 1)
|
|
190
|
+
constraints.push(buildPrimaryKeyConstraintSql(driver, primaryCols));
|
|
191
|
+
for (const fk of def.foreignKeys) {
|
|
192
|
+
constraints.push(buildForeignKeyConstraintSql(driver, def.name, fk));
|
|
193
|
+
}
|
|
194
|
+
const allLines = [...colLines, ...constraints].map((l) => ` ${l}`);
|
|
195
|
+
const ine = ifNotExists ? 'IF NOT EXISTS ' : '';
|
|
196
|
+
const createSql = `CREATE TABLE ${ine}${quoteIdent(driver, def.name)} (\n${allLines.join(',\n')}\n)`;
|
|
197
|
+
const statements = [createSql];
|
|
198
|
+
for (const idx of def.indexes) {
|
|
199
|
+
statements.push(buildCreateIndexSql(driver, def.name, idx));
|
|
200
|
+
}
|
|
201
|
+
return statements;
|
|
202
|
+
}
|
|
203
|
+
function compileAddColumns(driver, table, cols) {
|
|
204
|
+
return cols.map((col) => {
|
|
205
|
+
const colSql = buildColumnSql(driver, table, col);
|
|
206
|
+
return `ALTER TABLE ${quoteIdent(driver, table)} ADD COLUMN ${colSql}`;
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
function compileIndexOps(driver, table, plan) {
|
|
210
|
+
const create = plan.createIndexes.map((idx) => buildCreateIndexSql(driver, table, idx));
|
|
211
|
+
const drop = plan.dropIndexes.map((idx) => buildDropIndexSql(driver, table, idx));
|
|
212
|
+
return [...create, ...drop];
|
|
213
|
+
}
|
|
214
|
+
function compileAdvancedAlterOps(driver, table, plan) {
|
|
215
|
+
const needs = plan.dropColumns.length > 0 ||
|
|
216
|
+
plan.addForeignKeys.length > 0 ||
|
|
217
|
+
plan.dropForeignKeys.length > 0;
|
|
218
|
+
if (!needs)
|
|
219
|
+
return [];
|
|
220
|
+
if (isSqliteFamily(driver)) {
|
|
221
|
+
throw ErrorFactory.createValidationError('SQLite/D1 does not support dropping columns or altering foreign keys safely (table rebuild required)');
|
|
222
|
+
}
|
|
223
|
+
const statements = [];
|
|
224
|
+
for (const col of plan.dropColumns) {
|
|
225
|
+
assertIdentifier('column', col);
|
|
226
|
+
statements.push(`ALTER TABLE ${quoteIdent(driver, table)} DROP COLUMN ${quoteIdent(driver, col)}`);
|
|
227
|
+
}
|
|
228
|
+
for (const fk of plan.addForeignKeys) {
|
|
229
|
+
statements.push(`ALTER TABLE ${quoteIdent(driver, table)} ADD ${buildForeignKeyConstraintSql(driver, table, fk)}`);
|
|
230
|
+
}
|
|
231
|
+
for (const fkName of plan.dropForeignKeys) {
|
|
232
|
+
assertIdentifier('foreign key', fkName);
|
|
233
|
+
if (driver === 'mysql') {
|
|
234
|
+
statements.push(`ALTER TABLE ${quoteIdent(driver, table)} DROP FOREIGN KEY ${quoteIdent(driver, fkName)}`);
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
statements.push(`ALTER TABLE ${quoteIdent(driver, table)} DROP CONSTRAINT ${quoteIdent(driver, fkName)}`);
|
|
238
|
+
}
|
|
239
|
+
return statements;
|
|
240
|
+
}
|
|
241
|
+
function buildAlterTableStatements(driver, table, plan) {
|
|
242
|
+
assertIdentifier('table', table);
|
|
243
|
+
return [
|
|
244
|
+
...compileAddColumns(driver, table, plan.addColumns),
|
|
245
|
+
...compileIndexOps(driver, table, plan),
|
|
246
|
+
...compileAdvancedAlterOps(driver, table, plan),
|
|
247
|
+
];
|
|
248
|
+
}
|
|
249
|
+
export const MigrationSchemaCompiler = Object.freeze({
|
|
250
|
+
compileCreateTable(driver, def, opts) {
|
|
251
|
+
const d = requireSupportedDriver(driver);
|
|
252
|
+
return buildCreateTableStatements(d, def, opts?.ifNotExists !== false);
|
|
253
|
+
},
|
|
254
|
+
compileDropTable(driver, table, opts) {
|
|
255
|
+
const d = requireSupportedDriver(driver);
|
|
256
|
+
return buildDropTableSql(d, table, opts?.ifExists !== false);
|
|
257
|
+
},
|
|
258
|
+
compileAlterTable(driver, table, plan) {
|
|
259
|
+
const d = requireSupportedDriver(driver);
|
|
260
|
+
return buildAlterTableStatements(d, table, plan);
|
|
261
|
+
},
|
|
262
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { MigrationBlueprint } from '../../migrations/schema/Blueprint';
|
|
2
|
+
export { Schema } from '../../migrations/schema/Schema';
|
|
3
|
+
export { MigrationSchemaCompiler } from '../../migrations/schema/SchemaCompiler';
|
|
4
|
+
export type { Blueprint, BlueprintCallback, ColumnBuilder, ColumnDefinition, ColumnType, ForeignKeyAction, ForeignKeyBuilder, ForeignKeyDefinition, IndexDefinition, IndexType, SchemaBuilder, TableDefinition, } from '../../migrations/schema/types';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/migrations/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,SAAS,EACT,aAAa,EACb,eAAe,GAChB,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { IDatabase } from '../../orm/Database';
|
|
2
|
+
export type ColumnType = 'STRING' | 'INTEGER' | 'REAL' | 'BOOLEAN' | 'TEXT' | 'JSON' | 'TIMESTAMP' | 'BLOB';
|
|
3
|
+
export type IndexType = 'INDEX' | 'UNIQUE';
|
|
4
|
+
export type ForeignKeyAction = 'CASCADE' | 'SET NULL' | 'RESTRICT' | 'NO ACTION' | 'SET DEFAULT';
|
|
5
|
+
export type ColumnDefinition = {
|
|
6
|
+
name: string;
|
|
7
|
+
type: ColumnType;
|
|
8
|
+
length?: number;
|
|
9
|
+
nullable: boolean;
|
|
10
|
+
defaultValue?: unknown;
|
|
11
|
+
primary: boolean;
|
|
12
|
+
unique: boolean;
|
|
13
|
+
autoIncrement: boolean;
|
|
14
|
+
unsigned: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type IndexDefinition = {
|
|
17
|
+
name: string;
|
|
18
|
+
columns: string[];
|
|
19
|
+
type: IndexType;
|
|
20
|
+
};
|
|
21
|
+
export type ForeignKeyDefinition = {
|
|
22
|
+
name: string;
|
|
23
|
+
columns: string[];
|
|
24
|
+
referencedTable: string;
|
|
25
|
+
referencedColumns: string[];
|
|
26
|
+
onDelete?: ForeignKeyAction;
|
|
27
|
+
onUpdate?: ForeignKeyAction;
|
|
28
|
+
};
|
|
29
|
+
export type TableDefinition = {
|
|
30
|
+
name: string;
|
|
31
|
+
columns: ColumnDefinition[];
|
|
32
|
+
indexes: IndexDefinition[];
|
|
33
|
+
foreignKeys: ForeignKeyDefinition[];
|
|
34
|
+
};
|
|
35
|
+
export type BlueprintCallback<TBlueprint> = (table: TBlueprint) => void | Promise<void>;
|
|
36
|
+
export type ColumnBuilder = {
|
|
37
|
+
nullable(): ColumnBuilder;
|
|
38
|
+
notNullable(): ColumnBuilder;
|
|
39
|
+
default(value: unknown): ColumnBuilder;
|
|
40
|
+
unique(): ColumnBuilder;
|
|
41
|
+
primary(): ColumnBuilder;
|
|
42
|
+
autoIncrement(): ColumnBuilder;
|
|
43
|
+
unsigned(): ColumnBuilder;
|
|
44
|
+
getDefinition(): ColumnDefinition;
|
|
45
|
+
};
|
|
46
|
+
export type ForeignKeyBuilder = {
|
|
47
|
+
references(columns: string | string[]): ForeignKeyBuilder;
|
|
48
|
+
on(table: string): ForeignKeyBuilder;
|
|
49
|
+
onDelete(action: ForeignKeyAction): ForeignKeyBuilder;
|
|
50
|
+
onUpdate(action: ForeignKeyAction): ForeignKeyBuilder;
|
|
51
|
+
getDefinition(): ForeignKeyDefinition;
|
|
52
|
+
};
|
|
53
|
+
export type Blueprint = {
|
|
54
|
+
string(name: string, length?: number): ColumnBuilder;
|
|
55
|
+
integer(name: string): ColumnBuilder;
|
|
56
|
+
bigInteger(name: string): ColumnBuilder;
|
|
57
|
+
real(name: string): ColumnBuilder;
|
|
58
|
+
boolean(name: string): ColumnBuilder;
|
|
59
|
+
text(name: string): ColumnBuilder;
|
|
60
|
+
json(name: string): ColumnBuilder;
|
|
61
|
+
timestamp(name: string): ColumnBuilder;
|
|
62
|
+
blob(name: string): ColumnBuilder;
|
|
63
|
+
id(name?: string): ColumnBuilder;
|
|
64
|
+
timestamps(createdAt?: string, updatedAt?: string): void;
|
|
65
|
+
index(columns: string | string[], name?: string): void;
|
|
66
|
+
unique(columns: string | string[], name?: string): void;
|
|
67
|
+
foreign(columns: string | string[], name?: string): ForeignKeyBuilder;
|
|
68
|
+
dropColumn(name: string): void;
|
|
69
|
+
dropIndex(name: string): void;
|
|
70
|
+
dropForeign(name: string): void;
|
|
71
|
+
getDefinition(): TableDefinition;
|
|
72
|
+
getDropColumns(): string[];
|
|
73
|
+
getDropIndexes(): string[];
|
|
74
|
+
getDropForeignKeys(): string[];
|
|
75
|
+
};
|
|
76
|
+
export type SchemaBuilder = {
|
|
77
|
+
create(tableName: string, callback: BlueprintCallback<Blueprint>): Promise<void>;
|
|
78
|
+
table(tableName: string, callback: BlueprintCallback<Blueprint>): Promise<void>;
|
|
79
|
+
drop(tableName: string): Promise<void>;
|
|
80
|
+
dropIfExists(tableName: string): Promise<void>;
|
|
81
|
+
hasTable(tableName: string): Promise<boolean>;
|
|
82
|
+
hasColumn(tableName: string, columnName: string): Promise<boolean>;
|
|
83
|
+
getAllTables(): Promise<string[]>;
|
|
84
|
+
getDb(): IDatabase;
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/migrations/schema/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,MAAM,UAAU,GAClB,QAAQ,GACR,SAAS,GACT,MAAM,GACN,SAAS,GACT,MAAM,GACN,MAAM,GACN,WAAW,GACX,MAAM,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE3C,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,aAAa,CAAC;AAEjG,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EA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
+
export type MigrationRecordStatus = 'running' | 'completed' | 'failed';
|
|
4
|
+
export type MigrationRecord = {
|
|
5
|
+
name: string;
|
|
6
|
+
scope: MigrationScope;
|
|
7
|
+
service: string;
|
|
8
|
+
batch: number;
|
|
9
|
+
status: MigrationRecordStatus;
|
|
10
|
+
appliedAt: string | null;
|
|
11
|
+
};
|
|
12
|
+
export type MigrationModule = {
|
|
13
|
+
migration?: {
|
|
14
|
+
up?: unknown;
|
|
15
|
+
down?: unknown;
|
|
16
|
+
};
|
|
17
|
+
up?: unknown;
|
|
18
|
+
down?: unknown;
|
|
19
|
+
};
|
|
20
|
+
export type MigrationHandler = (db: IDatabase) => Promise<void>;
|
|
21
|
+
export type LoadedMigration = {
|
|
22
|
+
name: string;
|
|
23
|
+
filePath: string;
|
|
24
|
+
up: MigrationHandler;
|
|
25
|
+
down: MigrationHandler;
|
|
26
|
+
};
|
|
27
|
+
export type MigratorStatusRow = {
|
|
28
|
+
name: string;
|
|
29
|
+
applied: boolean;
|
|
30
|
+
batch: number | null;
|
|
31
|
+
status: string | null;
|
|
32
|
+
appliedAt: string | null;
|
|
33
|
+
};
|
|
34
|
+
export type MigratorOptions = {
|
|
35
|
+
db: IDatabase;
|
|
36
|
+
projectRoot: string;
|
|
37
|
+
globalDir: string;
|
|
38
|
+
extension: string;
|
|
39
|
+
lockFile?: string;
|
|
40
|
+
separateTracking?: boolean;
|
|
41
|
+
scope?: MigrationScope;
|
|
42
|
+
service?: string;
|
|
43
|
+
includeGlobal?: boolean;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/migrations/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,SAAS,CAAC;AAElD,MAAM,MAAM,qBAAqB,GAA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CAAC,EAAE,cAAc,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Safe to import in both API and CLI code
|
|
4
4
|
* Exported from node:crypto built-in
|
|
5
5
|
*/
|
|
6
|
-
export { createCipheriv, createDecipheriv, createHash, createHmac, createSign, createVerify, generateKeyPairSync, pbkdf2Sync, randomBytes, randomInt, timingSafeEqual, } from 'node:crypto';
|
|
6
|
+
export { createCipheriv, createDecipheriv, createHash, createHmac, createSign, createVerify, generateKeyPairSync, pbkdf2, pbkdf2Sync, randomBytes, randomInt, timingSafeEqual, } from 'node:crypto';
|
|
7
7
|
//# sourceMappingURL=crypto.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../../src/node-singletons/crypto.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,SAAS,EACT,eAAe,GAChB,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../../src/node-singletons/crypto.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,MAAM,EACN,UAAU,EACV,WAAW,EACX,SAAS,EACT,eAAe,GAChB,MAAM,aAAa,CAAC"}
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Safe to import in both API and CLI code
|
|
4
4
|
* Exported from node:crypto built-in
|
|
5
5
|
*/
|
|
6
|
-
export { createCipheriv, createDecipheriv, createHash, createHmac, createSign, createVerify, generateKeyPairSync, pbkdf2Sync, randomBytes, randomInt, timingSafeEqual, } from 'node:crypto';
|
|
6
|
+
export { createCipheriv, createDecipheriv, createHash, createHmac, createSign, createVerify, generateKeyPairSync, pbkdf2, pbkdf2Sync, randomBytes, randomInt, timingSafeEqual, } from 'node:crypto';
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import * as fs from 'node:fs';
|
|
7
7
|
export * as fsPromises from 'node:fs/promises';
|
|
8
|
-
export { appendFileSync, copyFileSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, renameSync, rmSync, statSync, unlinkSync, utimesSync, writeFileSync, } from 'node:fs';
|
|
9
|
-
export type { Stats } from 'node:fs';
|
|
8
|
+
export { appendFileSync, copyFileSync, createReadStream, createWriteStream, existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, renameSync, rmSync, statSync, unlinkSync, utimesSync, writeFileSync, } from 'node:fs';
|
|
9
|
+
export type { ReadStream, Stats, WriteStream } from 'node:fs';
|
|
10
10
|
export { mkdir, mkdtemp, readFile, realpath, rm, stat, writeFile } from 'node:fs/promises';
|
|
11
11
|
export default fs;
|
|
12
12
|
//# sourceMappingURL=fs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/node-singletons/fs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAK9B,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EACL,cAAc,EACd,YAAY,EACZ,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,UAAU,EACV,MAAM,EACN,QAAQ,EACR,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/node-singletons/fs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAK9B,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EACL,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,UAAU,EACV,MAAM,EACN,QAAQ,EACR,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE9D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG3F,eAAe,EAAE,CAAC"}
|
|
@@ -8,7 +8,7 @@ import * as fs from 'node:fs';
|
|
|
8
8
|
// Exporting it here keeps imports consistent and makes Vitest mocking of
|
|
9
9
|
// `node:fs/promises` flow through this singleton layer.
|
|
10
10
|
export * as fsPromises from 'node:fs/promises';
|
|
11
|
-
export { appendFileSync, copyFileSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, renameSync, rmSync, statSync, unlinkSync, utimesSync, writeFileSync, } from 'node:fs';
|
|
11
|
+
export { appendFileSync, copyFileSync, createReadStream, createWriteStream, existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, renameSync, rmSync, statSync, unlinkSync, utimesSync, writeFileSync, } from 'node:fs';
|
|
12
12
|
export { mkdir, mkdtemp, readFile, realpath, rm, stat, writeFile } from 'node:fs/promises';
|
|
13
13
|
// Default export for compatibility
|
|
14
14
|
export default fs;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/node-singletons/util.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,WAAW,CAAC"}
|
package/src/node.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { default, default as process } from './node-singletons/process';
|
|
2
|
-
export {
|
|
2
|
+
export { cleanOnce, FileLogWriter } from './config/FileLogWriter';
|
|
3
3
|
export { listTemplates, loadTemplate, renderTemplate } from './tools/mail/templates/markdown';
|
|
4
4
|
export { MailFake } from './tools/mail/testing';
|
|
5
5
|
export { FakeStorage } from './tools/storage/testing';
|
|
6
|
+
export { TestEnvironment, TestHttp } from './testing/index';
|
|
7
|
+
export type { ITestEnvironment, TestEnvironmentOptions, TestHeaders, TestHttpRequestInput, TestHttpResponseRecorder, TestRequestInput, TestResponse, } from './testing/index';
|
|
6
8
|
export { listTemplates as listNotificationTemplates, loadTemplate as loadNotificationTemplate, renderTemplate as renderNotificationTemplate, } from './tools/notification/templates/markdown';
|
|
7
9
|
//# sourceMappingURL=node.d.ts.map
|
package/src/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EACV,gBAAgB,EAChB,sBAAsB,EACtB,WAAW,EACX,oBAAoB,EACpB,wBAAwB,EACxB,gBAAgB,EAChB,YAAY,GACb,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,aAAa,IAAI,yBAAyB,EAC1C,YAAY,IAAI,wBAAwB,EACxC,cAAc,IAAI,0BAA0B,GAC7C,MAAM,kCAAkC,CAAC"}
|
package/src/node.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { Logger } from './config/logger.js';
|
|
1
2
|
// Runtime marker to make this re-export-only module coverable in V8 coverage.
|
|
2
3
|
const __coverageMarker = true;
|
|
3
|
-
|
|
4
|
+
if (__coverageMarker !== true) {
|
|
5
|
+
throw Logger.error('Unreachable');
|
|
6
|
+
}
|
|
4
7
|
export { default, default as process } from './node-singletons/process.js';
|
|
5
|
-
export {
|
|
8
|
+
export { cleanOnce, FileLogWriter } from './config/FileLogWriter.js';
|
|
6
9
|
export { listTemplates, loadTemplate, renderTemplate } from './tools/mail/templates/markdown/index.js';
|
|
7
10
|
export { MailFake } from './tools/mail/testing.js';
|
|
8
11
|
export { FakeStorage } from './tools/storage/testing.js';
|
|
12
|
+
export { TestEnvironment, TestHttp } from './testing/index.js';
|
|
9
13
|
export { listTemplates as listNotificationTemplates, loadTemplate as loadNotificationTemplate, renderTemplate as renderNotificationTemplate, } from './tools/notification/templates/markdown/index.js';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional OpenTelemetry integration.
|
|
3
|
+
*
|
|
4
|
+
* Design goals:
|
|
5
|
+
* - No hard dependency on SDKs/exporters (apps bring their own).
|
|
6
|
+
* - Safe to import in runtimes without tracing configured (no-op behavior).
|
|
7
|
+
* - Best-effort: never breaks request handling.
|
|
8
|
+
*
|
|
9
|
+
* Tiny Node enablement snippet (exporter is app-owned):
|
|
10
|
+
*
|
|
11
|
+
* npm i @opentelemetry/sdk-node @opentelemetry/auto-instrumentations-node \
|
|
12
|
+
* @opentelemetry/exporter-trace-otlp-http
|
|
13
|
+
*
|
|
14
|
+
* // in your app entrypoint (before creating the server)
|
|
15
|
+
* import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
16
|
+
* import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
|
17
|
+
* import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
18
|
+
*
|
|
19
|
+
* const sdk = new NodeSDK({
|
|
20
|
+
* traceExporter: new OTLPTraceExporter({ url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT }),
|
|
21
|
+
* instrumentations: [getNodeAutoInstrumentations()],
|
|
22
|
+
* });
|
|
23
|
+
* await sdk.start();
|
|
24
|
+
* process.env.OTEL_ENABLED = 'true';
|
|
25
|
+
*/
|
|
26
|
+
import { type Context, type Span } from '@opentelemetry/api';
|
|
27
|
+
export interface StartHttpServerSpanInput {
|
|
28
|
+
method: string;
|
|
29
|
+
path: string;
|
|
30
|
+
requestId?: string;
|
|
31
|
+
serviceName?: string;
|
|
32
|
+
userId?: string;
|
|
33
|
+
tenantId?: string;
|
|
34
|
+
userAgent?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface EndHttpServerSpanInput {
|
|
37
|
+
route?: string;
|
|
38
|
+
status?: number;
|
|
39
|
+
error?: unknown;
|
|
40
|
+
}
|
|
41
|
+
export interface StartedSpan {
|
|
42
|
+
span: Span;
|
|
43
|
+
context: Context;
|
|
44
|
+
}
|
|
45
|
+
export interface RecordDbQuerySpanInput {
|
|
46
|
+
driver: string;
|
|
47
|
+
durationMs: number;
|
|
48
|
+
}
|
|
49
|
+
type HeaderGetter = {
|
|
50
|
+
getHeader(name: string): unknown;
|
|
51
|
+
};
|
|
52
|
+
export declare const OpenTelemetry: Readonly<{
|
|
53
|
+
isEnabled: () => boolean;
|
|
54
|
+
startHttpServerSpan: (req: HeaderGetter, input: StartHttpServerSpanInput) => StartedSpan;
|
|
55
|
+
runWithContext: <T>(ctx: Context, fn: () => Promise<T>) => Promise<T>;
|
|
56
|
+
setHttpRoute: (span: Span, method: string, route: string) => void;
|
|
57
|
+
endHttpServerSpan: (span: Span, input: EndHttpServerSpanInput) => void;
|
|
58
|
+
injectTraceHeaders: (headers: Record<string, string>) => Record<string, string>;
|
|
59
|
+
recordDbQuerySpan: (input: RecordDbQuerySpanInput) => void;
|
|
60
|
+
}>;
|
|
61
|
+
export default OpenTelemetry;
|
|
62
|
+
//# sourceMappingURL=OpenTelemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenTelemetry.d.ts","sourceRoot":"","sources":["../../../src/observability/OpenTelemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH,OAAO,EAML,KAAK,OAAO,EACZ,KAAK,IAAI,EACV,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,KAAK,YAAY,GAAG;IAClB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAClC,CAAC;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