@zintrust/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/z.d.ts +7 -0
- package/bin/z.d.ts.map +1 -0
- package/bin/z.js +6 -0
- package/bin/zin.d.ts +7 -0
- package/bin/zin.d.ts.map +1 -0
- package/bin/zin.js +6 -0
- package/bin/zintrust-microservices.d.ts +7 -0
- package/bin/zintrust-microservices.d.ts.map +1 -0
- package/bin/zintrust-microservices.js +165 -0
- package/bin/zintrust.d.ts +9 -0
- package/bin/zintrust.d.ts.map +1 -0
- package/bin/zintrust.js +51 -0
- package/bin/zt.d.ts +7 -0
- package/bin/zt.d.ts.map +1 -0
- package/bin/zt.js +6 -0
- package/package.json +80 -0
- package/src/boot/Application.d.ts +31 -0
- package/src/boot/Application.d.ts.map +1 -0
- package/src/boot/Application.js +159 -0
- package/src/boot/Server.d.ts +23 -0
- package/src/boot/Server.d.ts.map +1 -0
- package/src/boot/Server.js +236 -0
- package/src/boot/bootstrap.d.ts +7 -0
- package/src/boot/bootstrap.d.ts.map +1 -0
- package/src/boot/bootstrap.js +64 -0
- package/src/builder/BundleOptimizer.d.ts +42 -0
- package/src/builder/BundleOptimizer.d.ts.map +1 -0
- package/src/builder/BundleOptimizer.js +356 -0
- package/src/cache/Cache.d.ts +26 -0
- package/src/cache/Cache.d.ts.map +1 -0
- package/src/cache/Cache.js +89 -0
- package/src/cache/CacheDriver.d.ts +28 -0
- package/src/cache/CacheDriver.d.ts.map +1 -0
- package/src/cache/CacheDriver.js +6 -0
- package/src/cache/drivers/KVDriver.d.ts +12 -0
- package/src/cache/drivers/KVDriver.d.ts.map +1 -0
- package/src/cache/drivers/KVDriver.js +54 -0
- package/src/cache/drivers/MemoryDriver.d.ts +12 -0
- package/src/cache/drivers/MemoryDriver.d.ts.map +1 -0
- package/src/cache/drivers/MemoryDriver.js +50 -0
- package/src/cache/drivers/MongoDriver.d.ts +17 -0
- package/src/cache/drivers/MongoDriver.d.ts.map +1 -0
- package/src/cache/drivers/MongoDriver.js +80 -0
- package/src/cache/drivers/RedisDriver.d.ts +12 -0
- package/src/cache/drivers/RedisDriver.d.ts.map +1 -0
- package/src/cache/drivers/RedisDriver.js +79 -0
- package/src/cli/BaseCommand.d.ts +39 -0
- package/src/cli/BaseCommand.d.ts.map +1 -0
- package/src/cli/BaseCommand.js +58 -0
- package/src/cli/CLI.d.ts +21 -0
- package/src/cli/CLI.d.ts.map +1 -0
- package/src/cli/CLI.js +203 -0
- package/src/cli/ErrorHandler.d.ts +23 -0
- package/src/cli/ErrorHandler.d.ts.map +1 -0
- package/src/cli/ErrorHandler.js +95 -0
- package/src/cli/PromptHelper.d.ts +47 -0
- package/src/cli/PromptHelper.d.ts.map +1 -0
- package/src/cli/PromptHelper.js +155 -0
- package/src/cli/commands/AddCommand.d.ts +15 -0
- package/src/cli/commands/AddCommand.d.ts.map +1 -0
- package/src/cli/commands/AddCommand.js +817 -0
- package/src/cli/commands/ConfigCommand.d.ts +15 -0
- package/src/cli/commands/ConfigCommand.d.ts.map +1 -0
- package/src/cli/commands/ConfigCommand.js +273 -0
- package/src/cli/commands/D1MigrateCommand.d.ts +15 -0
- package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -0
- package/src/cli/commands/D1MigrateCommand.js +73 -0
- package/src/cli/commands/DebugCommand.d.ts +15 -0
- package/src/cli/commands/DebugCommand.d.ts.map +1 -0
- package/src/cli/commands/DebugCommand.js +52 -0
- package/src/cli/commands/FixCommand.d.ts +15 -0
- package/src/cli/commands/FixCommand.d.ts.map +1 -0
- package/src/cli/commands/FixCommand.js +80 -0
- package/src/cli/commands/KeyGenerateCommand.d.ts +9 -0
- package/src/cli/commands/KeyGenerateCommand.d.ts.map +1 -0
- package/src/cli/commands/KeyGenerateCommand.js +76 -0
- package/src/cli/commands/LogsCommand.d.ts +19 -0
- package/src/cli/commands/LogsCommand.d.ts.map +1 -0
- package/src/cli/commands/LogsCommand.js +185 -0
- package/src/cli/commands/MigrateCommand.d.ts +15 -0
- package/src/cli/commands/MigrateCommand.d.ts.map +1 -0
- package/src/cli/commands/MigrateCommand.js +56 -0
- package/src/cli/commands/NewCommand.d.ts +32 -0
- package/src/cli/commands/NewCommand.d.ts.map +1 -0
- package/src/cli/commands/NewCommand.js +280 -0
- package/src/cli/commands/PluginCommand.d.ts +9 -0
- package/src/cli/commands/PluginCommand.d.ts.map +1 -0
- package/src/cli/commands/PluginCommand.js +94 -0
- package/src/cli/commands/PrepareCommand.d.ts +8 -0
- package/src/cli/commands/PrepareCommand.d.ts.map +1 -0
- package/src/cli/commands/PrepareCommand.js +51 -0
- package/src/cli/commands/QACommand.d.ts +33 -0
- package/src/cli/commands/QACommand.d.ts.map +1 -0
- package/src/cli/commands/QACommand.js +490 -0
- package/src/cli/commands/SimulateCommand.d.ts +12 -0
- package/src/cli/commands/SimulateCommand.d.ts.map +1 -0
- package/src/cli/commands/SimulateCommand.js +79 -0
- package/src/cli/commands/StartCommand.d.ts +5 -0
- package/src/cli/commands/StartCommand.d.ts.map +1 -0
- package/src/cli/commands/StartCommand.js +227 -0
- package/src/cli/commands/index.d.ts +11 -0
- package/src/cli/commands/index.d.ts.map +1 -0
- package/src/cli/commands/index.js +10 -0
- package/src/cli/config/ConfigManager.d.ts +42 -0
- package/src/cli/config/ConfigManager.d.ts.map +1 -0
- package/src/cli/config/ConfigManager.js +175 -0
- package/src/cli/config/ConfigSchema.d.ts +195 -0
- package/src/cli/config/ConfigSchema.d.ts.map +1 -0
- package/src/cli/config/ConfigSchema.js +171 -0
- package/src/cli/config/ConfigValidator.d.ts +41 -0
- package/src/cli/config/ConfigValidator.d.ts.map +1 -0
- package/src/cli/config/ConfigValidator.js +200 -0
- package/src/cli/config/index.d.ts +8 -0
- package/src/cli/config/index.d.ts.map +1 -0
- package/src/cli/config/index.js +7 -0
- package/src/cli/debug/Dashboard.d.ts +34 -0
- package/src/cli/debug/Dashboard.d.ts.map +1 -0
- package/src/cli/debug/Dashboard.js +152 -0
- package/src/cli/index.d.ts +14 -0
- package/src/cli/index.d.ts.map +1 -0
- package/src/cli/index.js +14 -0
- package/src/cli/logger/Logger.d.ts +43 -0
- package/src/cli/logger/Logger.d.ts.map +1 -0
- package/src/cli/logger/Logger.js +137 -0
- package/src/cli/scaffolding/ControllerGenerator.d.ts +44 -0
- package/src/cli/scaffolding/ControllerGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/ControllerGenerator.js +540 -0
- package/src/cli/scaffolding/FactoryGenerator.d.ts +47 -0
- package/src/cli/scaffolding/FactoryGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/FactoryGenerator.js +356 -0
- package/src/cli/scaffolding/FeatureScaffolder.d.ts +40 -0
- package/src/cli/scaffolding/FeatureScaffolder.d.ts.map +1 -0
- package/src/cli/scaffolding/FeatureScaffolder.js +747 -0
- package/src/cli/scaffolding/FileGenerator.d.ts +31 -0
- package/src/cli/scaffolding/FileGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/FileGenerator.js +222 -0
- package/src/cli/scaffolding/MigrationGenerator.d.ts +35 -0
- package/src/cli/scaffolding/MigrationGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/MigrationGenerator.js +257 -0
- package/src/cli/scaffolding/ModelGenerator.d.ts +81 -0
- package/src/cli/scaffolding/ModelGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/ModelGenerator.js +249 -0
- package/src/cli/scaffolding/ProjectScaffolder.d.ts +66 -0
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -0
- package/src/cli/scaffolding/ProjectScaffolder.js +439 -0
- package/src/cli/scaffolding/RequestFactoryGenerator.d.ts +50 -0
- package/src/cli/scaffolding/RequestFactoryGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/RequestFactoryGenerator.js +465 -0
- package/src/cli/scaffolding/ResponseFactoryGenerator.d.ts +43 -0
- package/src/cli/scaffolding/ResponseFactoryGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/ResponseFactoryGenerator.js +321 -0
- package/src/cli/scaffolding/RouteGenerator.d.ts +66 -0
- package/src/cli/scaffolding/RouteGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/RouteGenerator.js +306 -0
- package/src/cli/scaffolding/SeederGenerator.d.ts +47 -0
- package/src/cli/scaffolding/SeederGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/SeederGenerator.js +286 -0
- package/src/cli/scaffolding/ServiceIntegrationTestGenerator.d.ts +40 -0
- package/src/cli/scaffolding/ServiceIntegrationTestGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/ServiceIntegrationTestGenerator.js +267 -0
- package/src/cli/scaffolding/ServiceRequestFactoryGenerator.d.ts +45 -0
- package/src/cli/scaffolding/ServiceRequestFactoryGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/ServiceRequestFactoryGenerator.js +397 -0
- package/src/cli/scaffolding/ServiceScaffolder.d.ts +45 -0
- package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -0
- package/src/cli/scaffolding/ServiceScaffolder.js +367 -0
- package/src/cli/scaffolding/TemplateEngine.d.ts +35 -0
- package/src/cli/scaffolding/TemplateEngine.d.ts.map +1 -0
- package/src/cli/scaffolding/TemplateEngine.js +379 -0
- package/src/cli/scaffolding/WorkflowGenerator.d.ts +31 -0
- package/src/cli/scaffolding/WorkflowGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/WorkflowGenerator.js +193 -0
- package/src/cli/scaffolding/index.d.ts +34 -0
- package/src/cli/scaffolding/index.d.ts.map +1 -0
- package/src/cli/scaffolding/index.js +18 -0
- package/src/cli/utils/DistPackager.d.ts +8 -0
- package/src/cli/utils/DistPackager.d.ts.map +1 -0
- package/src/cli/utils/DistPackager.js +94 -0
- package/src/cli/utils/EnvFileLoader.d.ts +21 -0
- package/src/cli/utils/EnvFileLoader.d.ts.map +1 -0
- package/src/cli/utils/EnvFileLoader.js +166 -0
- package/src/cli/utils/spawn.d.ts +11 -0
- package/src/cli/utils/spawn.d.ts.map +1 -0
- package/src/cli/utils/spawn.js +81 -0
- package/src/common/index.d.ts +87 -0
- package/src/common/index.d.ts.map +1 -0
- package/src/common/index.js +207 -0
- package/src/config/SecretsManager.d.ts +122 -0
- package/src/config/SecretsManager.d.ts.map +1 -0
- package/src/config/SecretsManager.js +328 -0
- package/src/config/app.d.ts +56 -0
- package/src/config/app.d.ts.map +1 -0
- package/src/config/app.js +77 -0
- package/src/config/cache.d.ts +76 -0
- package/src/config/cache.d.ts.map +1 -0
- package/src/config/cache.js +62 -0
- package/src/config/constants.d.ts +108 -0
- package/src/config/constants.d.ts.map +1 -0
- package/src/config/constants.js +64 -0
- package/src/config/database.d.ts +122 -0
- package/src/config/database.d.ts.map +1 -0
- package/src/config/database.js +89 -0
- package/src/config/env.d.ts +56 -0
- package/src/config/env.d.ts.map +1 -0
- package/src/config/env.js +133 -0
- package/src/config/features.d.ts +27 -0
- package/src/config/features.d.ts.map +1 -0
- package/src/config/features.js +49 -0
- package/src/config/index.d.ts +554 -0
- package/src/config/index.d.ts.map +1 -0
- package/src/config/index.js +31 -0
- package/src/config/logger.d.ts +17 -0
- package/src/config/logger.d.ts.map +1 -0
- package/src/config/logger.js +77 -0
- package/src/config/microservices.d.ts +88 -0
- package/src/config/microservices.d.ts.map +1 -0
- package/src/config/microservices.js +90 -0
- package/src/config/queue.d.ts +107 -0
- package/src/config/queue.d.ts.map +1 -0
- package/src/config/queue.js +74 -0
- package/src/config/security.d.ts +108 -0
- package/src/config/security.d.ts.map +1 -0
- package/src/config/security.js +134 -0
- package/src/config/storage.d.ts +105 -0
- package/src/config/storage.d.ts.map +1 -0
- package/src/config/storage.js +79 -0
- package/src/container/ServiceContainer.d.ts +25 -0
- package/src/container/ServiceContainer.d.ts.map +1 -0
- package/src/container/ServiceContainer.js +75 -0
- package/src/database/migrations/index.d.ts +2 -0
- package/src/database/migrations/index.d.ts.map +1 -0
- package/src/database/migrations/index.js +1 -0
- package/src/exceptions/ZintrustError.d.ts +88 -0
- package/src/exceptions/ZintrustError.d.ts.map +1 -0
- package/src/exceptions/ZintrustError.js +110 -0
- package/src/features/Auth.d.ts +20 -0
- package/src/features/Auth.d.ts.map +1 -0
- package/src/features/Auth.js +32 -0
- package/src/features/Queue.d.ts +21 -0
- package/src/features/Queue.d.ts.map +1 -0
- package/src/features/Queue.js +59 -0
- package/src/functions/cloudflare.d.ts +5 -0
- package/src/functions/cloudflare.d.ts.map +1 -0
- package/src/functions/cloudflare.js +34 -0
- package/src/functions/deno.d.ts +3 -0
- package/src/functions/deno.d.ts.map +1 -0
- package/src/functions/deno.js +31 -0
- package/src/functions/lambda.d.ts +2 -0
- package/src/functions/lambda.d.ts.map +1 -0
- package/src/functions/lambda.js +32 -0
- package/src/http/Controller.d.ts +20 -0
- package/src/http/Controller.d.ts.map +1 -0
- package/src/http/Controller.js +46 -0
- package/src/http/Kernel.d.ts +24 -0
- package/src/http/Kernel.d.ts.map +1 -0
- package/src/http/Kernel.js +72 -0
- package/src/http/Request.d.ts +36 -0
- package/src/http/Request.d.ts.map +1 -0
- package/src/http/Request.js +142 -0
- package/src/http/Response.d.ts +32 -0
- package/src/http/Response.d.ts.map +1 -0
- package/src/http/Response.js +70 -0
- package/src/index.d.ts +43 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +37 -0
- package/src/microservices/MicroserviceBootstrap.d.ts +75 -0
- package/src/microservices/MicroserviceBootstrap.d.ts.map +1 -0
- package/src/microservices/MicroserviceBootstrap.js +285 -0
- package/src/microservices/MicroserviceGenerator.d.ts +27 -0
- package/src/microservices/MicroserviceGenerator.d.ts.map +1 -0
- package/src/microservices/MicroserviceGenerator.js +436 -0
- package/src/microservices/MicroserviceManager.d.ts +68 -0
- package/src/microservices/MicroserviceManager.d.ts.map +1 -0
- package/src/microservices/MicroserviceManager.js +266 -0
- package/src/microservices/PostgresAdapter.d.ts +90 -0
- package/src/microservices/PostgresAdapter.d.ts.map +1 -0
- package/src/microservices/PostgresAdapter.js +286 -0
- package/src/microservices/RequestTracingMiddleware.d.ts +41 -0
- package/src/microservices/RequestTracingMiddleware.d.ts.map +1 -0
- package/src/microservices/RequestTracingMiddleware.js +122 -0
- package/src/microservices/ServiceAuthMiddleware.d.ts +58 -0
- package/src/microservices/ServiceAuthMiddleware.d.ts.map +1 -0
- package/src/microservices/ServiceAuthMiddleware.js +240 -0
- package/src/microservices/ServiceBundler.d.ts +45 -0
- package/src/microservices/ServiceBundler.d.ts.map +1 -0
- package/src/microservices/ServiceBundler.js +297 -0
- package/src/microservices/ServiceHealthMonitor.d.ts +96 -0
- package/src/microservices/ServiceHealthMonitor.d.ts.map +1 -0
- package/src/microservices/ServiceHealthMonitor.js +379 -0
- package/src/middleware/CsrfMiddleware.d.ts +19 -0
- package/src/middleware/CsrfMiddleware.d.ts.map +1 -0
- package/src/middleware/CsrfMiddleware.js +121 -0
- package/src/middleware/MiddlewareStack.d.ts +27 -0
- package/src/middleware/MiddlewareStack.d.ts.map +1 -0
- package/src/middleware/MiddlewareStack.js +43 -0
- package/src/middleware/RateLimiter.d.ts +22 -0
- package/src/middleware/RateLimiter.d.ts.map +1 -0
- package/src/middleware/RateLimiter.js +72 -0
- package/src/middleware/SecurityMiddleware.d.ts +33 -0
- package/src/middleware/SecurityMiddleware.d.ts.map +1 -0
- package/src/middleware/SecurityMiddleware.js +106 -0
- package/src/middleware/index.d.ts +9 -0
- package/src/middleware/index.d.ts.map +1 -0
- package/src/middleware/index.js +8 -0
- package/src/node-singletons/child-process.d.ts +7 -0
- package/src/node-singletons/child-process.d.ts.map +1 -0
- package/src/node-singletons/child-process.js +6 -0
- package/src/node-singletons/crypto.d.ts +7 -0
- package/src/node-singletons/crypto.d.ts.map +1 -0
- package/src/node-singletons/crypto.js +6 -0
- package/src/node-singletons/events.d.ts +7 -0
- package/src/node-singletons/events.d.ts.map +1 -0
- package/src/node-singletons/events.js +6 -0
- package/src/node-singletons/fs.d.ts +12 -0
- package/src/node-singletons/fs.d.ts.map +1 -0
- package/src/node-singletons/fs.js +14 -0
- package/src/node-singletons/http.d.ts +8 -0
- package/src/node-singletons/http.d.ts.map +1 -0
- package/src/node-singletons/http.js +6 -0
- package/src/node-singletons/index.d.ts +30 -0
- package/src/node-singletons/index.d.ts.map +1 -0
- package/src/node-singletons/index.js +31 -0
- package/src/node-singletons/os.d.ts +9 -0
- package/src/node-singletons/os.d.ts.map +1 -0
- package/src/node-singletons/os.js +9 -0
- package/src/node-singletons/path.d.ts +7 -0
- package/src/node-singletons/path.d.ts.map +1 -0
- package/src/node-singletons/path.js +6 -0
- package/src/node-singletons/perf-hooks.d.ts +7 -0
- package/src/node-singletons/perf-hooks.d.ts.map +1 -0
- package/src/node-singletons/perf-hooks.js +6 -0
- package/src/node-singletons/readline.d.ts +10 -0
- package/src/node-singletons/readline.d.ts.map +1 -0
- package/src/node-singletons/readline.js +9 -0
- package/src/node-singletons/url.d.ts +7 -0
- package/src/node-singletons/url.d.ts.map +1 -0
- package/src/node-singletons/url.js +6 -0
- package/src/orm/ConnectionManager.d.ts +118 -0
- package/src/orm/ConnectionManager.d.ts.map +1 -0
- package/src/orm/ConnectionManager.js +401 -0
- package/src/orm/Database.d.ts +31 -0
- package/src/orm/Database.d.ts.map +1 -0
- package/src/orm/Database.js +163 -0
- package/src/orm/DatabaseAdapter.d.ts +96 -0
- package/src/orm/DatabaseAdapter.d.ts.map +1 -0
- package/src/orm/DatabaseAdapter.js +40 -0
- package/src/orm/Model.d.ts +91 -0
- package/src/orm/Model.d.ts.map +1 -0
- package/src/orm/Model.js +206 -0
- package/src/orm/QueryBuilder.d.ts +52 -0
- package/src/orm/QueryBuilder.d.ts.map +1 -0
- package/src/orm/QueryBuilder.js +134 -0
- package/src/orm/Relationships.d.ts +53 -0
- package/src/orm/Relationships.d.ts.map +1 -0
- package/src/orm/Relationships.js +98 -0
- package/src/orm/Schema.d.ts +123 -0
- package/src/orm/Schema.d.ts.map +1 -0
- package/src/orm/Schema.js +169 -0
- package/src/orm/adapters/D1Adapter.d.ts +15 -0
- package/src/orm/adapters/D1Adapter.d.ts.map +1 -0
- package/src/orm/adapters/D1Adapter.js +125 -0
- package/src/orm/adapters/MySQLAdapter.d.ts +16 -0
- package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -0
- package/src/orm/adapters/MySQLAdapter.js +87 -0
- package/src/orm/adapters/PostgreSQLAdapter.d.ts +16 -0
- package/src/orm/adapters/PostgreSQLAdapter.d.ts.map +1 -0
- package/src/orm/adapters/PostgreSQLAdapter.js +87 -0
- package/src/orm/adapters/SQLServerAdapter.d.ts +16 -0
- package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -0
- package/src/orm/adapters/SQLServerAdapter.js +81 -0
- package/src/orm/adapters/SQLiteAdapter.d.ts +11 -0
- package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -0
- package/src/orm/adapters/SQLiteAdapter.js +131 -0
- package/src/performance/Benchmark.d.ts +87 -0
- package/src/performance/Benchmark.d.ts.map +1 -0
- package/src/performance/Benchmark.js +304 -0
- package/src/performance/CodeGenerationBenchmark.d.ts +23 -0
- package/src/performance/CodeGenerationBenchmark.d.ts.map +1 -0
- package/src/performance/CodeGenerationBenchmark.js +249 -0
- package/src/performance/Optimizer.d.ts +99 -0
- package/src/performance/Optimizer.d.ts.map +1 -0
- package/src/performance/Optimizer.js +396 -0
- package/src/performance/establish-baseline.d.ts +9 -0
- package/src/performance/establish-baseline.d.ts.map +1 -0
- package/src/performance/establish-baseline.js +55 -0
- package/src/profiling/MemoryProfiler.d.ts +32 -0
- package/src/profiling/MemoryProfiler.d.ts.map +1 -0
- package/src/profiling/MemoryProfiler.js +84 -0
- package/src/profiling/N1Detector.d.ts +16 -0
- package/src/profiling/N1Detector.d.ts.map +1 -0
- package/src/profiling/N1Detector.js +120 -0
- package/src/profiling/QueryLogger.d.ts +107 -0
- package/src/profiling/QueryLogger.d.ts.map +1 -0
- package/src/profiling/QueryLogger.js +148 -0
- package/src/profiling/RequestProfiler.d.ts +30 -0
- package/src/profiling/RequestProfiler.d.ts.map +1 -0
- package/src/profiling/RequestProfiler.js +94 -0
- package/src/profiling/types.d.ts +77 -0
- package/src/profiling/types.d.ts.map +1 -0
- package/src/profiling/types.js +5 -0
- package/src/routing/Router.d.ts +52 -0
- package/src/routing/Router.d.ts.map +1 -0
- package/src/routing/Router.js +191 -0
- package/src/runtime/PluginManager.d.ts +30 -0
- package/src/runtime/PluginManager.d.ts.map +1 -0
- package/src/runtime/PluginManager.js +197 -0
- package/src/runtime/PluginRegistry.d.ts +22 -0
- package/src/runtime/PluginRegistry.d.ts.map +1 -0
- package/src/runtime/PluginRegistry.js +93 -0
- package/src/runtime/RuntimeAdapter.d.ts +126 -0
- package/src/runtime/RuntimeAdapter.d.ts.map +1 -0
- package/src/runtime/RuntimeAdapter.js +127 -0
- package/src/runtime/RuntimeDetector.d.ts +15 -0
- package/src/runtime/RuntimeDetector.d.ts.map +1 -0
- package/src/runtime/RuntimeDetector.js +219 -0
- package/src/runtime/adapters/CloudflareAdapter.d.ts +43 -0
- package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -0
- package/src/runtime/adapters/CloudflareAdapter.js +175 -0
- package/src/runtime/adapters/DenoAdapter.d.ts +30 -0
- package/src/runtime/adapters/DenoAdapter.d.ts.map +1 -0
- package/src/runtime/adapters/DenoAdapter.js +191 -0
- package/src/runtime/adapters/FargateAdapter.d.ts +40 -0
- package/src/runtime/adapters/FargateAdapter.d.ts.map +1 -0
- package/src/runtime/adapters/FargateAdapter.js +156 -0
- package/src/runtime/adapters/LambdaAdapter.d.ts +13 -0
- package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -0
- package/src/runtime/adapters/LambdaAdapter.js +302 -0
- package/src/runtime/adapters/NodeServerAdapter.d.ts +16 -0
- package/src/runtime/adapters/NodeServerAdapter.d.ts.map +1 -0
- package/src/runtime/adapters/NodeServerAdapter.js +199 -0
- package/src/scripts/TemplateSync.d.ts +7 -0
- package/src/scripts/TemplateSync.d.ts.map +1 -0
- package/src/scripts/TemplateSync.js +234 -0
- package/src/security/CsrfTokenManager.d.ts +28 -0
- package/src/security/CsrfTokenManager.d.ts.map +1 -0
- package/src/security/CsrfTokenManager.js +78 -0
- package/src/security/Encryptor.d.ts +15 -0
- package/src/security/Encryptor.d.ts.map +1 -0
- package/src/security/Encryptor.js +142 -0
- package/src/security/JwtManager.d.ts +41 -0
- package/src/security/JwtManager.d.ts.map +1 -0
- package/src/security/JwtManager.js +229 -0
- package/src/security/UrlValidator.d.ts +21 -0
- package/src/security/UrlValidator.d.ts.map +1 -0
- package/src/security/UrlValidator.js +42 -0
- package/src/security/XssProtection.d.ts +24 -0
- package/src/security/XssProtection.d.ts.map +1 -0
- package/src/security/XssProtection.js +133 -0
- package/src/templates/TemplateRegistry.d.ts +40 -0
- package/src/templates/TemplateRegistry.d.ts.map +1 -0
- package/src/templates/TemplateRegistry.js +78 -0
- package/src/templates/TemplateRegistry.ts +91 -0
- package/src/templates/adapters/MySQLAdapter.ts.tpl +97 -0
- package/src/templates/adapters/PostgreSQLAdapter.ts.tpl +101 -0
- package/src/templates/adapters/SQLServerAdapter.ts.tpl +95 -0
- package/src/templates/adapters/SQLiteAdapter.ts.tpl +189 -0
- package/src/templates/features/Auth.ts.tpl +40 -0
- package/src/templates/features/Queue.ts.tpl +75 -0
- package/src/templates/project/basic/.env.example.tpl +26 -0
- package/src/templates/project/basic/.env.tpl +164 -0
- package/src/templates/project/basic/README.md.tpl +13 -0
- package/src/templates/project/basic/app/Controllers/UserController.ts.tpl +155 -0
- package/src/templates/project/basic/app/Middleware/ProfilerMiddleware.ts.tpl +55 -0
- package/src/templates/project/basic/app/Middleware/index.ts.tpl +304 -0
- package/src/templates/project/basic/app/Models/Post.ts.tpl +30 -0
- package/src/templates/project/basic/app/Models/User.ts.tpl +53 -0
- package/src/templates/project/basic/config/SecretsManager.ts.tpl +453 -0
- package/src/templates/project/basic/config/app.ts.tpl +97 -0
- package/src/templates/project/basic/config/cache.ts.tpl +117 -0
- package/src/templates/project/basic/config/constants.ts.tpl +70 -0
- package/src/templates/project/basic/config/database.ts.tpl +152 -0
- package/src/templates/project/basic/config/env.ts.tpl +148 -0
- package/src/templates/project/basic/config/features.ts.tpl +57 -0
- package/src/templates/project/basic/config/index.ts.tpl +36 -0
- package/src/templates/project/basic/config/logger.ts.tpl +95 -0
- package/src/templates/project/basic/config/microservices.ts.tpl +104 -0
- package/src/templates/project/basic/config/queue.ts.tpl +134 -0
- package/src/templates/project/basic/config/security.ts.tpl +149 -0
- package/src/templates/project/basic/config/storage.ts.tpl +136 -0
- package/src/templates/project/basic/database/factories/.gitkeep.tpl +0 -0
- package/src/templates/project/basic/database/migrations/.gitkeep.tpl +0 -0
- package/src/templates/project/basic/database/migrations/index.ts.tpl +2 -0
- package/src/templates/project/basic/database/seeders/.gitkeep.tpl +0 -0
- package/src/templates/project/basic/package.json.tpl +22 -0
- package/src/templates/project/basic/routes/api.ts.tpl +135 -0
- package/src/templates/project/basic/src/index.ts.tpl +49 -0
- package/src/templates/project/basic/template.json +17 -0
- package/src/templates/project/basic/tsconfig.json.tpl +20 -0
- package/src/validation/ValidationError.d.ts +42 -0
- package/src/validation/ValidationError.d.ts.map +1 -0
- package/src/validation/ValidationError.js +53 -0
- package/src/validation/Validator.d.ts +60 -0
- package/src/validation/Validator.d.ts.map +1 -0
- package/src/validation/Validator.js +190 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relationship Types
|
|
3
|
+
* Define how models relate to each other
|
|
4
|
+
*/
|
|
5
|
+
import { IModel, Model, ModelStatic } from './Model';
|
|
6
|
+
export type RelationshipType = 'hasOne' | 'hasMany' | 'belongsTo' | 'belongsToMany';
|
|
7
|
+
export interface Relation {
|
|
8
|
+
type: RelationshipType;
|
|
9
|
+
related: typeof Model;
|
|
10
|
+
foreignKey: string;
|
|
11
|
+
localKey: string;
|
|
12
|
+
throughTable?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface IRelationship {
|
|
15
|
+
get(instance: IModel): Promise<unknown>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* HasOne Relationship
|
|
19
|
+
* Sealed namespace object following Pattern 2
|
|
20
|
+
*
|
|
21
|
+
* @see FRAMEWORK_REFACTOR_FUNCTION_PATTERN.md for Pattern 2 details
|
|
22
|
+
*/
|
|
23
|
+
export declare const HasOne: Readonly<{
|
|
24
|
+
create(relatedModel: ModelStatic, foreignKey: string, localKey: string): IRelationship;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* HasMany Relationship
|
|
28
|
+
* Sealed namespace object following Pattern 2
|
|
29
|
+
*
|
|
30
|
+
* @see FRAMEWORK_REFACTOR_FUNCTION_PATTERN.md for Pattern 2 details
|
|
31
|
+
*/
|
|
32
|
+
export declare const HasMany: Readonly<{
|
|
33
|
+
create(relatedModel: ModelStatic, foreignKey: string, localKey: string): IRelationship;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* BelongsTo Relationship
|
|
37
|
+
* Sealed namespace object following Pattern 2
|
|
38
|
+
*
|
|
39
|
+
* @see FRAMEWORK_REFACTOR_FUNCTION_PATTERN.md for Pattern 2 details
|
|
40
|
+
*/
|
|
41
|
+
export declare const BelongsTo: Readonly<{
|
|
42
|
+
create(relatedModel: ModelStatic, foreignKey: string, localKey: string): IRelationship;
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* BelongsToMany Relationship
|
|
46
|
+
* Sealed namespace object following Pattern 2
|
|
47
|
+
*
|
|
48
|
+
* @see FRAMEWORK_REFACTOR_FUNCTION_PATTERN.md for Pattern 2 details
|
|
49
|
+
*/
|
|
50
|
+
export declare const BelongsToMany: Readonly<{
|
|
51
|
+
create(relatedModel: ModelStatic, throughTable: string, foreignKey: string, relatedKey: string): IRelationship;
|
|
52
|
+
}>;
|
|
53
|
+
//# sourceMappingURL=Relationships.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Relationships.d.ts","sourceRoot":"","sources":["../../../src/orm/Relationships.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExD,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,eAAe,CAAC;AAEpF,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,EAAE,OAAO,KAAK,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACzC;AAUD;;;;;GAKG;AACH,eAAO,MAAM,MAAM;yBACI,WAAW,cAAc,MAAM,YAAY,MAAM,GAAG,aAAa;EAUtF,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,OAAO;yBACG,WAAW,cAAc,MAAM,YAAY,MAAM,GAAG,aAAa;EAUtF,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,SAAS;yBACC,WAAW,cAAc,MAAM,YAAY,MAAM,GAAG,aAAa;EAUtF,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,aAAa;yBAER,WAAW,gBACX,MAAM,cACR,MAAM,cACN,MAAM,GACjB,aAAa;EA8BhB,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relationship Types
|
|
3
|
+
* Define how models relate to each other
|
|
4
|
+
*/
|
|
5
|
+
import { ErrorFactory } from '../exceptions/ZintrustError';
|
|
6
|
+
const getRelatedTableName = (relatedModel) => {
|
|
7
|
+
if (typeof relatedModel.getTable === 'function') {
|
|
8
|
+
return relatedModel.getTable();
|
|
9
|
+
}
|
|
10
|
+
throw ErrorFactory.createConfigError('Related model does not provide a table name');
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* HasOne Relationship
|
|
14
|
+
* Sealed namespace object following Pattern 2
|
|
15
|
+
*
|
|
16
|
+
* @see FRAMEWORK_REFACTOR_FUNCTION_PATTERN.md for Pattern 2 details
|
|
17
|
+
*/
|
|
18
|
+
export const HasOne = Object.freeze({
|
|
19
|
+
create(relatedModel, foreignKey, localKey) {
|
|
20
|
+
return {
|
|
21
|
+
async get(instance) {
|
|
22
|
+
const value = instance.getAttribute(localKey);
|
|
23
|
+
if (value === undefined || value === null || value === '')
|
|
24
|
+
return null;
|
|
25
|
+
return relatedModel.query().where(foreignKey, '=', value).first();
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* HasMany Relationship
|
|
32
|
+
* Sealed namespace object following Pattern 2
|
|
33
|
+
*
|
|
34
|
+
* @see FRAMEWORK_REFACTOR_FUNCTION_PATTERN.md for Pattern 2 details
|
|
35
|
+
*/
|
|
36
|
+
export const HasMany = Object.freeze({
|
|
37
|
+
create(relatedModel, foreignKey, localKey) {
|
|
38
|
+
return {
|
|
39
|
+
async get(instance) {
|
|
40
|
+
const value = instance.getAttribute(localKey);
|
|
41
|
+
if (value === undefined || value === null || value === '')
|
|
42
|
+
return [];
|
|
43
|
+
return relatedModel.query().where(foreignKey, '=', value).get();
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* BelongsTo Relationship
|
|
50
|
+
* Sealed namespace object following Pattern 2
|
|
51
|
+
*
|
|
52
|
+
* @see FRAMEWORK_REFACTOR_FUNCTION_PATTERN.md for Pattern 2 details
|
|
53
|
+
*/
|
|
54
|
+
export const BelongsTo = Object.freeze({
|
|
55
|
+
create(relatedModel, foreignKey, localKey) {
|
|
56
|
+
return {
|
|
57
|
+
async get(instance) {
|
|
58
|
+
const value = instance.getAttribute(foreignKey);
|
|
59
|
+
if (value === undefined || value === null || value === '')
|
|
60
|
+
return null;
|
|
61
|
+
return relatedModel.query().where(localKey, '=', value).first();
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
/**
|
|
67
|
+
* BelongsToMany Relationship
|
|
68
|
+
* Sealed namespace object following Pattern 2
|
|
69
|
+
*
|
|
70
|
+
* @see FRAMEWORK_REFACTOR_FUNCTION_PATTERN.md for Pattern 2 details
|
|
71
|
+
*/
|
|
72
|
+
export const BelongsToMany = Object.freeze({
|
|
73
|
+
create(relatedModel, throughTable, foreignKey, relatedKey) {
|
|
74
|
+
const isValidInstance = (instance) => {
|
|
75
|
+
const instanceId = instance.getAttribute('id');
|
|
76
|
+
return (instanceId !== undefined &&
|
|
77
|
+
instanceId !== null &&
|
|
78
|
+
instanceId !== '' &&
|
|
79
|
+
throughTable !== '' &&
|
|
80
|
+
foreignKey !== '' &&
|
|
81
|
+
relatedKey !== '');
|
|
82
|
+
};
|
|
83
|
+
return {
|
|
84
|
+
async get(instance) {
|
|
85
|
+
if (!isValidInstance(instance)) {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
const instanceId = instance.getAttribute('id');
|
|
89
|
+
const relatedTable = getRelatedTableName(relatedModel);
|
|
90
|
+
return relatedModel
|
|
91
|
+
.query()
|
|
92
|
+
.join(throughTable, `${relatedTable}.id = ${throughTable}.${relatedKey}`)
|
|
93
|
+
.where(`${throughTable}.${foreignKey}`, instanceId)
|
|
94
|
+
.get();
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema - Column definition and type system
|
|
3
|
+
* Defines database columns with type safety
|
|
4
|
+
*/
|
|
5
|
+
export type ColumnType = 'string' | 'integer' | 'boolean' | 'date' | 'datetime' | 'json' | 'text' | 'timestamp' | 'decimal' | 'uuid' | 'float' | 'double' | 'binary' | 'enum' | 'bigInteger' | 'smallInteger' | 'tinyInteger' | 'mediumInteger' | 'time' | 'year' | 'char' | 'longText' | 'mediumText' | 'tinyText' | 'blob' | 'mediumBlob' | 'longBlob' | 'tinyBlob' | 'ipAddress' | 'macAddress' | 'geometry' | 'point' | 'lineString' | 'polygon' | 'geometryCollection' | 'multiPoint' | 'multiLineString' | 'multiPolygon';
|
|
6
|
+
export interface ColumnDefinition {
|
|
7
|
+
name: string;
|
|
8
|
+
type: ColumnType;
|
|
9
|
+
nullable: boolean;
|
|
10
|
+
default?: unknown;
|
|
11
|
+
unique: boolean;
|
|
12
|
+
primary: boolean;
|
|
13
|
+
index: boolean;
|
|
14
|
+
autoIncrement?: boolean;
|
|
15
|
+
unsigned?: boolean;
|
|
16
|
+
comment?: string;
|
|
17
|
+
references?: string;
|
|
18
|
+
on?: string;
|
|
19
|
+
onDelete?: string;
|
|
20
|
+
onUpdate?: string;
|
|
21
|
+
renameTo?: string;
|
|
22
|
+
change?: boolean;
|
|
23
|
+
drop?: boolean;
|
|
24
|
+
after?: string;
|
|
25
|
+
first?: boolean;
|
|
26
|
+
charset?: string;
|
|
27
|
+
collation?: string;
|
|
28
|
+
length?: number;
|
|
29
|
+
precision?: number;
|
|
30
|
+
scale?: number;
|
|
31
|
+
values?: string[];
|
|
32
|
+
}
|
|
33
|
+
export interface IColumn {
|
|
34
|
+
nullable(): IColumn;
|
|
35
|
+
default(value: unknown): IColumn;
|
|
36
|
+
unique(): IColumn;
|
|
37
|
+
primary(): IColumn;
|
|
38
|
+
index(): IColumn;
|
|
39
|
+
autoIncrement(): IColumn;
|
|
40
|
+
unsigned(): IColumn;
|
|
41
|
+
comment(text: string): IColumn;
|
|
42
|
+
references(column: string): IColumn;
|
|
43
|
+
on(table: string): IColumn;
|
|
44
|
+
onDelete(action: string): IColumn;
|
|
45
|
+
onUpdate(action: string): IColumn;
|
|
46
|
+
renameTo(name: string): IColumn;
|
|
47
|
+
change(): IColumn;
|
|
48
|
+
drop(): IColumn;
|
|
49
|
+
after(column: string): IColumn;
|
|
50
|
+
first(): IColumn;
|
|
51
|
+
charset(value: string): IColumn;
|
|
52
|
+
collation(value: string): IColumn;
|
|
53
|
+
length(value: number): IColumn;
|
|
54
|
+
precision(value: number): IColumn;
|
|
55
|
+
scale(value: number): IColumn;
|
|
56
|
+
values(value: string[]): IColumn;
|
|
57
|
+
getDefinition(): ColumnDefinition;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Column - Column definition builder
|
|
61
|
+
* Sealed namespace object following Pattern 2
|
|
62
|
+
*
|
|
63
|
+
* @see FRAMEWORK_REFACTOR_FUNCTION_PATTERN.md for Pattern 2 details
|
|
64
|
+
*/
|
|
65
|
+
export declare const Column: Readonly<{
|
|
66
|
+
/**
|
|
67
|
+
* Create a new column instance
|
|
68
|
+
*/
|
|
69
|
+
create(name: string, type: ColumnType): IColumn;
|
|
70
|
+
}>;
|
|
71
|
+
export interface ISchema {
|
|
72
|
+
string(name: string, length?: number): IColumn;
|
|
73
|
+
integer(name: string): IColumn;
|
|
74
|
+
boolean(name: string): IColumn;
|
|
75
|
+
date(name: string): IColumn;
|
|
76
|
+
datetime(name: string): IColumn;
|
|
77
|
+
json(name: string): IColumn;
|
|
78
|
+
text(name: string): IColumn;
|
|
79
|
+
timestamp(name: string): IColumn;
|
|
80
|
+
decimal(name: string, precision?: number, scale?: number): IColumn;
|
|
81
|
+
uuid(name: string): IColumn;
|
|
82
|
+
float(name: string): IColumn;
|
|
83
|
+
double(name: string): IColumn;
|
|
84
|
+
binary(name: string): IColumn;
|
|
85
|
+
enum(name: string, values: string[]): IColumn;
|
|
86
|
+
bigInteger(name: string): IColumn;
|
|
87
|
+
smallInteger(name: string): IColumn;
|
|
88
|
+
tinyInteger(name: string): IColumn;
|
|
89
|
+
mediumInteger(name: string): IColumn;
|
|
90
|
+
time(name: string): IColumn;
|
|
91
|
+
year(name: string): IColumn;
|
|
92
|
+
char(name: string, length?: number): IColumn;
|
|
93
|
+
longText(name: string): IColumn;
|
|
94
|
+
mediumText(name: string): IColumn;
|
|
95
|
+
tinyText(name: string): IColumn;
|
|
96
|
+
blob(name: string): IColumn;
|
|
97
|
+
mediumBlob(name: string): IColumn;
|
|
98
|
+
longBlob(name: string): IColumn;
|
|
99
|
+
tinyBlob(name: string): IColumn;
|
|
100
|
+
ipAddress(name: string): IColumn;
|
|
101
|
+
macAddress(name: string): IColumn;
|
|
102
|
+
geometry(name: string): IColumn;
|
|
103
|
+
point(name: string): IColumn;
|
|
104
|
+
lineString(name: string): IColumn;
|
|
105
|
+
polygon(name: string): IColumn;
|
|
106
|
+
geometryCollection(name: string): IColumn;
|
|
107
|
+
multiPoint(name: string): IColumn;
|
|
108
|
+
multiLineString(name: string): IColumn;
|
|
109
|
+
multiPolygon(name: string): IColumn;
|
|
110
|
+
increments(name: string): IColumn;
|
|
111
|
+
bigIncrements(name: string): IColumn;
|
|
112
|
+
timestamps(): void;
|
|
113
|
+
softDeletes(): void;
|
|
114
|
+
getColumns(): Map<string, IColumn>;
|
|
115
|
+
getTable(): string;
|
|
116
|
+
}
|
|
117
|
+
export declare const Schema: Readonly<{
|
|
118
|
+
/**
|
|
119
|
+
* Create a new schema instance
|
|
120
|
+
*/
|
|
121
|
+
create(table: string): ISchema;
|
|
122
|
+
}>;
|
|
123
|
+
//# sourceMappingURL=Schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../../src/orm/Schema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,UAAU,GAClB,QAAQ,GACR,SAAS,GACT,SAAS,GACT,MAAM,GACN,UAAU,GACV,MAAM,GACN,MAAM,GACN,WAAW,GACX,SAAS,GACT,MAAM,GACN,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,YAAY,GACZ,cAAc,GACd,aAAa,GACb,eAAe,GACf,MAAM,GACN,MAA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EAwD9B,CAAC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema - Column definition and type system
|
|
3
|
+
* Defines database columns with type safety
|
|
4
|
+
*/
|
|
5
|
+
const definitionBuilder = (name, type) => {
|
|
6
|
+
return {
|
|
7
|
+
name,
|
|
8
|
+
type,
|
|
9
|
+
nullable: false,
|
|
10
|
+
unique: false,
|
|
11
|
+
primary: false,
|
|
12
|
+
index: false,
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
const createColumnFromDefinition = (definition) => {
|
|
16
|
+
const column = {};
|
|
17
|
+
const enable = (key) => {
|
|
18
|
+
return () => {
|
|
19
|
+
definition[key] = true;
|
|
20
|
+
return column;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const assign = (key) => {
|
|
24
|
+
return (value) => {
|
|
25
|
+
definition[key] = value;
|
|
26
|
+
return column;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
column.nullable = enable('nullable');
|
|
30
|
+
column.unique = enable('unique');
|
|
31
|
+
column.primary = enable('primary');
|
|
32
|
+
column.index = enable('index');
|
|
33
|
+
column.autoIncrement = enable('autoIncrement');
|
|
34
|
+
column.unsigned = enable('unsigned');
|
|
35
|
+
column.change = enable('change');
|
|
36
|
+
column.drop = enable('drop');
|
|
37
|
+
column.first = enable('first');
|
|
38
|
+
column.default = assign('default');
|
|
39
|
+
column.comment = assign('comment');
|
|
40
|
+
column.references = assign('references');
|
|
41
|
+
column.on = assign('on');
|
|
42
|
+
column.onDelete = assign('onDelete');
|
|
43
|
+
column.onUpdate = assign('onUpdate');
|
|
44
|
+
column.renameTo = assign('renameTo');
|
|
45
|
+
column.after = assign('after');
|
|
46
|
+
column.charset = assign('charset');
|
|
47
|
+
column.collation = assign('collation');
|
|
48
|
+
column.length = assign('length');
|
|
49
|
+
column.precision = assign('precision');
|
|
50
|
+
column.scale = assign('scale');
|
|
51
|
+
column.values = assign('values');
|
|
52
|
+
column.getDefinition = () => ({ ...definition });
|
|
53
|
+
return column;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Column - Column definition builder
|
|
57
|
+
* Sealed namespace object following Pattern 2
|
|
58
|
+
*
|
|
59
|
+
* @see FRAMEWORK_REFACTOR_FUNCTION_PATTERN.md for Pattern 2 details
|
|
60
|
+
*/
|
|
61
|
+
export const Column = Object.freeze({
|
|
62
|
+
/**
|
|
63
|
+
* Create a new column instance
|
|
64
|
+
*/
|
|
65
|
+
create(name, type) {
|
|
66
|
+
const definition = definitionBuilder(name, type);
|
|
67
|
+
return createColumnFromDefinition(definition);
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
/**
|
|
71
|
+
* Schema - Table definition builder
|
|
72
|
+
* Refactored to Functional Object pattern
|
|
73
|
+
*/
|
|
74
|
+
/**
|
|
75
|
+
* Create a column proxy to track definition updates
|
|
76
|
+
*/
|
|
77
|
+
const createColumnProxy = (name, type, columns) => {
|
|
78
|
+
const column = Column.create(name, type);
|
|
79
|
+
columns.set(name, column);
|
|
80
|
+
return column;
|
|
81
|
+
};
|
|
82
|
+
const SIMPLE_SCHEMA_COLUMN_TYPES = [
|
|
83
|
+
'integer',
|
|
84
|
+
'boolean',
|
|
85
|
+
'date',
|
|
86
|
+
'datetime',
|
|
87
|
+
'json',
|
|
88
|
+
'text',
|
|
89
|
+
'timestamp',
|
|
90
|
+
'uuid',
|
|
91
|
+
'float',
|
|
92
|
+
'double',
|
|
93
|
+
'binary',
|
|
94
|
+
'bigInteger',
|
|
95
|
+
'smallInteger',
|
|
96
|
+
'tinyInteger',
|
|
97
|
+
'mediumInteger',
|
|
98
|
+
'time',
|
|
99
|
+
'year',
|
|
100
|
+
'longText',
|
|
101
|
+
'mediumText',
|
|
102
|
+
'tinyText',
|
|
103
|
+
'blob',
|
|
104
|
+
'mediumBlob',
|
|
105
|
+
'longBlob',
|
|
106
|
+
'tinyBlob',
|
|
107
|
+
'ipAddress',
|
|
108
|
+
'macAddress',
|
|
109
|
+
'geometry',
|
|
110
|
+
'point',
|
|
111
|
+
'lineString',
|
|
112
|
+
'polygon',
|
|
113
|
+
'geometryCollection',
|
|
114
|
+
'multiPoint',
|
|
115
|
+
'multiLineString',
|
|
116
|
+
'multiPolygon',
|
|
117
|
+
];
|
|
118
|
+
const setSchemaMethod = (target, key, fn) => {
|
|
119
|
+
target[key] = fn;
|
|
120
|
+
};
|
|
121
|
+
export const Schema = Object.freeze({
|
|
122
|
+
/**
|
|
123
|
+
* Create a new schema instance
|
|
124
|
+
*/
|
|
125
|
+
create(table) {
|
|
126
|
+
const columns = new Map();
|
|
127
|
+
const schema = {};
|
|
128
|
+
setSchemaMethod(schema, 'string', (name, length) => {
|
|
129
|
+
const col = createColumnProxy(name, 'string', columns);
|
|
130
|
+
if (length !== undefined)
|
|
131
|
+
col.length(length);
|
|
132
|
+
return col;
|
|
133
|
+
});
|
|
134
|
+
setSchemaMethod(schema, 'decimal', (name, precision, scale) => {
|
|
135
|
+
const col = createColumnProxy(name, 'decimal', columns);
|
|
136
|
+
if (precision !== undefined)
|
|
137
|
+
col.precision(precision);
|
|
138
|
+
if (scale !== undefined)
|
|
139
|
+
col.scale(scale);
|
|
140
|
+
return col;
|
|
141
|
+
});
|
|
142
|
+
setSchemaMethod(schema, 'enum', (name, values) => {
|
|
143
|
+
const col = createColumnProxy(name, 'enum', columns);
|
|
144
|
+
col.values(values);
|
|
145
|
+
return col;
|
|
146
|
+
});
|
|
147
|
+
setSchemaMethod(schema, 'char', (name, length) => {
|
|
148
|
+
const col = createColumnProxy(name, 'char', columns);
|
|
149
|
+
if (length !== undefined)
|
|
150
|
+
col.length(length);
|
|
151
|
+
return col;
|
|
152
|
+
});
|
|
153
|
+
for (const type of SIMPLE_SCHEMA_COLUMN_TYPES) {
|
|
154
|
+
setSchemaMethod(schema, type, (name) => createColumnProxy(name, type, columns));
|
|
155
|
+
}
|
|
156
|
+
setSchemaMethod(schema, 'increments', (name) => createColumnProxy(name, 'integer', columns).primary().autoIncrement());
|
|
157
|
+
setSchemaMethod(schema, 'bigIncrements', (name) => createColumnProxy(name, 'bigInteger', columns).primary().autoIncrement());
|
|
158
|
+
setSchemaMethod(schema, 'timestamps', () => {
|
|
159
|
+
createColumnProxy('created_at', 'timestamp', columns).nullable();
|
|
160
|
+
createColumnProxy('updated_at', 'timestamp', columns).nullable();
|
|
161
|
+
});
|
|
162
|
+
setSchemaMethod(schema, 'softDeletes', () => {
|
|
163
|
+
createColumnProxy('deleted_at', 'timestamp', columns).nullable();
|
|
164
|
+
});
|
|
165
|
+
setSchemaMethod(schema, 'getColumns', () => columns);
|
|
166
|
+
setSchemaMethod(schema, 'getTable', () => table);
|
|
167
|
+
return schema;
|
|
168
|
+
},
|
|
169
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare D1 Database Adapter
|
|
3
|
+
*/
|
|
4
|
+
import { DatabaseConfig, IDatabaseAdapter } from '../DatabaseAdapter';
|
|
5
|
+
/**
|
|
6
|
+
* D1 adapter implementation
|
|
7
|
+
*/
|
|
8
|
+
export declare const D1Adapter: Readonly<{
|
|
9
|
+
/**
|
|
10
|
+
* Create a new D1 adapter instance
|
|
11
|
+
*/
|
|
12
|
+
create(_config: DatabaseConfig): IDatabaseAdapter;
|
|
13
|
+
}>;
|
|
14
|
+
export default D1Adapter;
|
|
15
|
+
//# sourceMappingURL=D1Adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"D1Adapter.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/D1Adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EAAE,cAAc,EAAe,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAoBlG;;GAEG;AACH,eAAO,MAAM,SAAS;IACpB;;OAEG;oBAEa,cAAc,GAAG,gBAAgB;EAkGjD,CAAC;AAEH,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare D1 Database Adapter
|
|
3
|
+
*/
|
|
4
|
+
import { FeatureFlags } from '../../config/features';
|
|
5
|
+
import { Logger } from '../../config/logger';
|
|
6
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
7
|
+
/**
|
|
8
|
+
* Get D1 binding from config or global environment
|
|
9
|
+
*/
|
|
10
|
+
function getD1Binding(_config) {
|
|
11
|
+
// 1. Check config
|
|
12
|
+
if (_config.d1 !== undefined && _config.d1 !== null)
|
|
13
|
+
return _config.d1;
|
|
14
|
+
// 2. Check global env (Cloudflare Workers)
|
|
15
|
+
const globalEnv = globalThis.env;
|
|
16
|
+
if (globalEnv?.DB !== undefined)
|
|
17
|
+
return globalEnv.DB;
|
|
18
|
+
// 3. Check global scope
|
|
19
|
+
const globalDB = globalThis.DB;
|
|
20
|
+
if (globalDB !== undefined)
|
|
21
|
+
return globalDB;
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* D1 adapter implementation
|
|
26
|
+
*/
|
|
27
|
+
export const D1Adapter = Object.freeze({
|
|
28
|
+
/**
|
|
29
|
+
* Create a new D1 adapter instance
|
|
30
|
+
*/
|
|
31
|
+
// eslint-disable-next-line max-lines-per-function
|
|
32
|
+
create(_config) {
|
|
33
|
+
let connected = false;
|
|
34
|
+
return {
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
36
|
+
async connect() {
|
|
37
|
+
connected = true;
|
|
38
|
+
Logger.info('✓ D1 connected');
|
|
39
|
+
},
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
41
|
+
async disconnect() {
|
|
42
|
+
connected = false;
|
|
43
|
+
Logger.info('✓ D1 disconnected');
|
|
44
|
+
},
|
|
45
|
+
async query(sql, parameters) {
|
|
46
|
+
if (!connected)
|
|
47
|
+
throw ErrorFactory.createConnectionError('Database not connected');
|
|
48
|
+
const db = getD1Binding(_config);
|
|
49
|
+
if (db === null) {
|
|
50
|
+
throw ErrorFactory.createConfigError('D1 database binding not found');
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const stmt = db.prepare(sql);
|
|
54
|
+
const result = await stmt.bind(...parameters).all();
|
|
55
|
+
const rows = result.results ?? [];
|
|
56
|
+
return {
|
|
57
|
+
rows,
|
|
58
|
+
rowCount: rows.length,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
throw ErrorFactory.createTryCatchError(`D1 query failed: ${sql}`, error);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
async queryOne(sql, parameters) {
|
|
66
|
+
if (!connected)
|
|
67
|
+
throw ErrorFactory.createConnectionError('Database not connected');
|
|
68
|
+
const db = getD1Binding(_config);
|
|
69
|
+
if (db === null) {
|
|
70
|
+
throw ErrorFactory.createConfigError('D1 database binding not found');
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const stmt = db.prepare(sql);
|
|
74
|
+
const result = await stmt.bind(...parameters).first();
|
|
75
|
+
return result ?? null;
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
throw ErrorFactory.createTryCatchError(`D1 queryOne failed: ${sql}`, error);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
async transaction(callback) {
|
|
82
|
+
if (!connected)
|
|
83
|
+
throw ErrorFactory.createConnectionError('Database not connected');
|
|
84
|
+
try {
|
|
85
|
+
const result = await callback(this);
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
throw ErrorFactory.createTryCatchError('Transaction failed', error);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
getType() {
|
|
93
|
+
return 'd1';
|
|
94
|
+
},
|
|
95
|
+
isConnected() {
|
|
96
|
+
return connected;
|
|
97
|
+
},
|
|
98
|
+
async rawQuery(sql, parameters) {
|
|
99
|
+
if (!FeatureFlags.isRawQueryEnabled()) {
|
|
100
|
+
throw ErrorFactory.createConfigError('Raw SQL queries are disabled');
|
|
101
|
+
}
|
|
102
|
+
if (!connected) {
|
|
103
|
+
throw ErrorFactory.createConnectionError('Database not connected');
|
|
104
|
+
}
|
|
105
|
+
const db = getD1Binding(_config);
|
|
106
|
+
if (db === null) {
|
|
107
|
+
throw ErrorFactory.createConfigError('D1 database binding not found');
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
Logger.warn(`Raw SQL Query executed: ${sql}`, { parameters });
|
|
111
|
+
const stmt = db.prepare(sql);
|
|
112
|
+
const result = await stmt.bind(...(parameters ?? [])).all();
|
|
113
|
+
return result.results ?? [];
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
throw ErrorFactory.createTryCatchError(`Raw SQL query failed: ${sql}`, error);
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
getPlaceholder(_index) {
|
|
120
|
+
return '?';
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
export default D1Adapter;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MySQL Database Adapter
|
|
3
|
+
*/
|
|
4
|
+
import { DatabaseConfig, IDatabaseAdapter } from '../DatabaseAdapter';
|
|
5
|
+
/**
|
|
6
|
+
* MySQL adapter implementation
|
|
7
|
+
* Sealed namespace for immutability
|
|
8
|
+
*/
|
|
9
|
+
export declare const MySQLAdapter: Readonly<{
|
|
10
|
+
/**
|
|
11
|
+
* Create a new MySQL adapter instance
|
|
12
|
+
*/
|
|
13
|
+
create(config: DatabaseConfig): IDatabaseAdapter;
|
|
14
|
+
}>;
|
|
15
|
+
export default MySQLAdapter;
|
|
16
|
+
//# sourceMappingURL=MySQLAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MySQLAdapter.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/MySQLAdapter.ts"],"names":[],"mappings":"AAEA;;GAEG;AAKH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAErF;;;GAGG;AACH,eAAO,MAAM,YAAY;IACvB;;OAEG;mBACY,cAAc,GAAG,gBAAgB;EA0EhD,CAAC;AAEH,eAAe,YAAY,CAAC"}
|