@zintrust/core 0.1.28 → 0.1.30
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 +166 -185
- package/bin/z.d.ts +7 -0
- package/bin/z.d.ts.map +1 -0
- package/bin/z.js +7 -0
- package/bin/zin.d.ts +7 -0
- package/bin/zin.d.ts.map +1 -0
- package/bin/zin.js +7 -0
- package/bin/zintrust-main.d.ts +9 -0
- package/bin/zintrust-main.d.ts.map +1 -0
- package/bin/zintrust-main.js +110 -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 +10 -0
- package/bin/zintrust.d.ts.map +1 -0
- package/bin/zintrust.js +10 -0
- package/bin/zt.d.ts +7 -0
- package/bin/zt.d.ts.map +1 -0
- package/bin/zt.js +7 -0
- package/package.json +42 -140
- package/src/auth/Auth.d.ts +20 -0
- package/src/auth/Auth.d.ts.map +1 -0
- package/src/auth/Auth.js +33 -0
- package/src/boot/Application.d.ts +31 -0
- package/src/boot/Application.d.ts.map +1 -0
- package/src/boot/Application.js +351 -0
- package/src/boot/Server.d.ts +24 -0
- package/src/boot/Server.d.ts.map +1 -0
- package/src/boot/Server.js +117 -0
- package/src/boot/bootstrap.d.ts +7 -0
- package/src/boot/bootstrap.d.ts.map +1 -0
- package/src/boot/bootstrap.js +232 -0
- package/src/builder/BundleOptimizer.d.ts +42 -0
- package/src/builder/BundleOptimizer.d.ts.map +1 -0
- package/src/builder/BundleOptimizer.js +352 -0
- package/src/cache/Cache.d.ts +39 -0
- package/src/cache/Cache.d.ts.map +1 -0
- package/src/cache/Cache.js +142 -0
- package/src/cache/CacheDriver.d.ts +32 -0
- package/src/cache/CacheDriver.d.ts.map +1 -0
- package/src/cache/CacheDriver.js +6 -0
- package/src/cache/CacheDriverRegistry.d.ts +15 -0
- package/src/cache/CacheDriverRegistry.d.ts.map +1 -0
- package/src/cache/CacheDriverRegistry.js +19 -0
- package/src/cache/CacheRuntimeRegistration.d.ts +11 -0
- package/src/cache/CacheRuntimeRegistration.d.ts.map +1 -0
- package/src/cache/CacheRuntimeRegistration.js +21 -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 +55 -0
- package/src/cache/drivers/KVRemoteDriver.d.ts +11 -0
- package/src/cache/drivers/KVRemoteDriver.d.ts.map +1 -0
- package/src/cache/drivers/KVRemoteDriver.js +70 -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 +71 -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 +84 -0
- package/src/cli/BaseCommand.d.ts +41 -0
- package/src/cli/BaseCommand.d.ts.map +1 -0
- package/src/cli/BaseCommand.js +69 -0
- package/src/cli/CLI.d.ts +21 -0
- package/src/cli/CLI.d.ts.map +1 -0
- package/src/cli/CLI.js +242 -0
- package/src/cli/ErrorHandler.d.ts +23 -0
- package/src/cli/ErrorHandler.d.ts.map +1 -0
- package/src/cli/ErrorHandler.js +99 -0
- package/src/cli/PromptHelper.d.ts +47 -0
- package/src/cli/PromptHelper.d.ts.map +1 -0
- package/src/cli/PromptHelper.js +156 -0
- package/src/cli/commands/AddCommand.d.ts +96 -0
- package/src/cli/commands/AddCommand.d.ts.map +1 -0
- package/src/cli/commands/AddCommand.js +932 -0
- package/src/cli/commands/BroadcastWorkCommand.d.ts +10 -0
- package/src/cli/commands/BroadcastWorkCommand.d.ts.map +1 -0
- package/src/cli/commands/BroadcastWorkCommand.js +16 -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 +307 -0
- 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 +19 -0
- package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -0
- package/src/cli/commands/D1MigrateCommand.js +71 -0
- 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 +139 -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 +68 -0
- 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 +9 -0
- package/src/cli/commands/KeyGenerateCommand.d.ts.map +1 -0
- package/src/cli/commands/KeyGenerateCommand.js +76 -0
- package/src/cli/commands/LogsCleanupCommand.d.ts +6 -0
- package/src/cli/commands/LogsCleanupCommand.d.ts.map +1 -0
- package/src/cli/commands/LogsCleanupCommand.js +20 -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 +217 -0
- package/src/cli/commands/MakeMailTemplateCommand.d.ts +10 -0
- package/src/cli/commands/MakeMailTemplateCommand.d.ts.map +1 -0
- package/src/cli/commands/MakeMailTemplateCommand.js +76 -0
- package/src/cli/commands/MakeNotificationTemplateCommand.d.ts +10 -0
- package/src/cli/commands/MakeNotificationTemplateCommand.d.ts.map +1 -0
- package/src/cli/commands/MakeNotificationTemplateCommand.js +115 -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 +302 -0
- package/src/cli/commands/MigrateWorkerCommand.d.ts +9 -0
- package/src/cli/commands/MigrateWorkerCommand.d.ts.map +1 -0
- package/src/cli/commands/MigrateWorkerCommand.js +136 -0
- package/src/cli/commands/NewCommand.d.ts +37 -0
- package/src/cli/commands/NewCommand.d.ts.map +1 -0
- package/src/cli/commands/NewCommand.js +408 -0
- package/src/cli/commands/NotificationWorkCommand.d.ts +10 -0
- package/src/cli/commands/NotificationWorkCommand.d.ts.map +1 -0
- package/src/cli/commands/NotificationWorkCommand.js +16 -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 +98 -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/PublishCommand.d.ts +5 -0
- package/src/cli/commands/PublishCommand.d.ts.map +1 -0
- package/src/cli/commands/PublishCommand.js +54 -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 +480 -0
- package/src/cli/commands/QueueCommand.d.ts +10 -0
- package/src/cli/commands/QueueCommand.d.ts.map +1 -0
- package/src/cli/commands/QueueCommand.js +113 -0
- package/src/cli/commands/QueueLockCommand.d.ts +7 -0
- package/src/cli/commands/QueueLockCommand.d.ts.map +1 -0
- package/src/cli/commands/QueueLockCommand.js +138 -0
- package/src/cli/commands/QueueWorkCommandUtils.d.ts +10 -0
- package/src/cli/commands/QueueWorkCommandUtils.d.ts.map +1 -0
- package/src/cli/commands/QueueWorkCommandUtils.js +43 -0
- package/src/cli/commands/ResourceControlCommand.d.ts +6 -0
- package/src/cli/commands/ResourceControlCommand.d.ts.map +1 -0
- package/src/cli/commands/ResourceControlCommand.js +43 -0
- 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 +251 -0
- package/src/cli/commands/SecretsCommand.d.ts +16 -0
- package/src/cli/commands/SecretsCommand.d.ts.map +1 -0
- package/src/cli/commands/SecretsCommand.js +91 -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 +326 -0
- package/src/cli/commands/TemplatesCommand.d.ts +3 -0
- package/src/cli/commands/TemplatesCommand.d.ts.map +1 -0
- package/src/cli/commands/TemplatesCommand.js +65 -0
- package/src/cli/commands/UpgradeCommand.d.ts +16 -0
- package/src/cli/commands/UpgradeCommand.d.ts.map +1 -0
- package/src/cli/commands/UpgradeCommand.js +107 -0
- package/src/cli/commands/WorkerCommands.d.ts +17 -0
- package/src/cli/commands/WorkerCommands.d.ts.map +1 -0
- package/src/cli/commands/WorkerCommands.js +288 -0
- package/src/cli/commands/createKindWorkCommand.d.ts +9 -0
- package/src/cli/commands/createKindWorkCommand.d.ts.map +1 -0
- package/src/cli/commands/createKindWorkCommand.js +33 -0
- package/src/cli/commands/index.d.ts +24 -0
- package/src/cli/commands/index.d.ts.map +1 -0
- package/src/cli/commands/index.js +23 -0
- package/src/cli/commands/runner/index.d.ts +3 -0
- package/src/cli/commands/runner/index.d.ts.map +1 -0
- package/src/cli/commands/runner/index.js +139 -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 +172 -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/d1/D1SqlMigrations.d.ts +20 -0
- package/src/cli/d1/D1SqlMigrations.d.ts.map +1 -0
- package/src/cli/d1/D1SqlMigrations.js +230 -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/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/env/EnvFileBackfill.d.ts +10 -0
- package/src/cli/env/EnvFileBackfill.d.ts.map +1 -0
- package/src/cli/env/EnvFileBackfill.js +64 -0
- package/src/cli/index.d.ts +15 -0
- package/src/cli/index.d.ts.map +1 -0
- package/src/cli/index.js +15 -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 +575 -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 +358 -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/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 +45 -0
- package/src/cli/scaffolding/MigrationGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/MigrationGenerator.js +344 -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 +259 -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 +629 -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 +322 -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 +361 -0
- package/src/cli/scaffolding/SeederGenerator.d.ts +52 -0
- package/src/cli/scaffolding/SeederGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/SeederGenerator.js +334 -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 +268 -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 +390 -0
- package/src/cli/scaffolding/TemplateEngine.d.ts +42 -0
- package/src/cli/scaffolding/TemplateEngine.d.ts.map +1 -0
- package/src/cli/scaffolding/TemplateEngine.js +107 -0
- package/src/cli/scaffolding/TemplateGenerator.d.ts +40 -0
- package/src/cli/scaffolding/TemplateGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/TemplateGenerator.js +172 -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 +37 -0
- package/src/cli/scaffolding/index.d.ts.map +1 -0
- package/src/cli/scaffolding/index.js +20 -0
- package/src/cli/services/VersionChecker.d.ts +82 -0
- package/src/cli/services/VersionChecker.d.ts.map +1 -0
- package/src/cli/services/VersionChecker.js +258 -0
- package/src/cli/utils/DatabaseCliUtils.d.ts +20 -0
- package/src/cli/utils/DatabaseCliUtils.d.ts.map +1 -0
- package/src/cli/utils/DatabaseCliUtils.js +54 -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 +102 -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 +92 -0
- package/src/cli/workers/QueueWorkRunner.d.ts +23 -0
- package/src/cli/workers/QueueWorkRunner.d.ts.map +1 -0
- package/src/cli/workers/QueueWorkRunner.js +273 -0
- package/src/collections/Collection.d.ts +30 -0
- package/src/collections/Collection.d.ts.map +1 -0
- package/src/collections/Collection.js +181 -0
- package/src/collections/index.d.ts +3 -0
- package/src/collections/index.d.ts.map +1 -0
- package/src/collections/index.js +1 -0
- package/src/common/AwsSigV4.d.ts +41 -0
- package/src/common/AwsSigV4.d.ts.map +1 -0
- package/src/common/AwsSigV4.js +69 -0
- package/src/common/ExternalServiceUtils.d.ts +63 -0
- package/src/common/ExternalServiceUtils.d.ts.map +1 -0
- package/src/common/ExternalServiceUtils.js +116 -0
- package/src/common/HealthRoutes.d.ts +10 -0
- package/src/common/HealthRoutes.d.ts.map +1 -0
- package/src/common/HealthRoutes.js +114 -0
- package/src/common/RemoteSignedJson.d.ts +21 -0
- package/src/common/RemoteSignedJson.d.ts.map +1 -0
- package/src/common/RemoteSignedJson.js +86 -0
- package/src/common/index.d.ts +134 -0
- package/src/common/index.d.ts.map +1 -0
- package/src/common/index.js +328 -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 +23 -0
- package/src/config/FileLogWriter.d.ts.map +1 -0
- package/src/config/FileLogWriter.js +273 -0
- package/src/config/SecretsManager.d.ts +81 -0
- package/src/config/SecretsManager.d.ts.map +1 -0
- package/src/config/SecretsManager.js +355 -0
- package/src/config/StartupConfigValidator.d.ts +7 -0
- package/src/config/StartupConfigValidator.d.ts.map +1 -0
- package/src/config/StartupConfigValidator.js +179 -0
- package/src/config/app.d.ts +62 -0
- package/src/config/app.d.ts.map +1 -0
- package/src/config/app.js +184 -0
- package/src/config/broadcast.d.ts +22 -0
- package/src/config/broadcast.d.ts.map +1 -0
- package/src/config/broadcast.js +138 -0
- package/src/config/cache.d.ts +23 -0
- package/src/config/cache.d.ts.map +1 -0
- package/src/config/cache.js +125 -0
- package/src/config/cloudflare.d.ts +14 -0
- package/src/config/cloudflare.d.ts.map +1 -0
- package/src/config/cloudflare.js +38 -0
- package/src/config/constants.d.ts +238 -0
- package/src/config/constants.d.ts.map +1 -0
- package/src/config/constants.js +145 -0
- package/src/config/database.d.ts +41 -0
- package/src/config/database.d.ts.map +1 -0
- package/src/config/database.js +286 -0
- package/src/config/env.d.ts +128 -0
- package/src/config/env.d.ts.map +1 -0
- package/src/config/env.js +220 -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 +241 -0
- package/src/config/index.d.ts.map +1 -0
- package/src/config/index.js +41 -0
- package/src/config/logger.d.ts +19 -0
- package/src/config/logger.d.ts.map +1 -0
- package/src/config/logger.js +338 -0
- package/src/config/logging/HttpLogger.d.ts +23 -0
- package/src/config/logging/HttpLogger.d.ts.map +1 -0
- package/src/config/logging/HttpLogger.js +93 -0
- package/src/config/logging/KvLogger.d.ts +22 -0
- package/src/config/logging/KvLogger.d.ts.map +1 -0
- package/src/config/logging/KvLogger.js +143 -0
- package/src/config/logging/SlackLogger.d.ts +23 -0
- package/src/config/logging/SlackLogger.d.ts.map +1 -0
- package/src/config/logging/SlackLogger.js +119 -0
- package/src/config/mail.d.ts +27 -0
- package/src/config/mail.d.ts.map +1 -0
- package/src/config/mail.js +154 -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/middleware.d.ts +48 -0
- package/src/config/middleware.d.ts.map +1 -0
- package/src/config/middleware.js +205 -0
- package/src/config/notification.d.ts +24 -0
- package/src/config/notification.d.ts.map +1 -0
- package/src/config/notification.js +149 -0
- package/src/config/queue.d.ts +57 -0
- package/src/config/queue.d.ts.map +1 -0
- package/src/config/queue.js +144 -0
- package/src/config/redis.d.ts +17 -0
- package/src/config/redis.d.ts.map +1 -0
- package/src/config/redis.js +54 -0
- package/src/config/security.d.ts +123 -0
- package/src/config/security.d.ts.map +1 -0
- package/src/config/security.js +154 -0
- package/src/config/startup.d.ts +25 -0
- package/src/config/startup.d.ts.map +1 -0
- package/src/config/startup.js +16 -0
- package/src/config/storage.d.ts +45 -0
- package/src/config/storage.d.ts.map +1 -0
- package/src/config/storage.js +161 -0
- package/src/config/type.d.ts +492 -0
- package/src/config/type.d.ts.map +1 -0
- package/src/config/type.js +10 -0
- package/src/config/workers.d.ts +13 -0
- package/src/config/workers.d.ts.map +1 -0
- package/src/config/workers.js +216 -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/Paginator.d.ts +37 -0
- package/src/database/Paginator.d.ts.map +1 -0
- package/src/database/Paginator.js +81 -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 +2 -0
- package/src/events/EventDispatcher.d.ts +16 -0
- package/src/events/EventDispatcher.d.ts.map +1 -0
- package/src/events/EventDispatcher.js +92 -0
- package/src/events/index.d.ts +3 -0
- package/src/events/index.d.ts.map +1 -0
- package/src/events/index.js +1 -0
- package/src/exceptions/ZintrustError.d.ts +98 -0
- package/src/exceptions/ZintrustError.d.ts.map +1 -0
- package/src/exceptions/ZintrustError.js +170 -0
- package/src/functions/cloudflare.d.ts +5 -0
- package/src/functions/cloudflare.d.ts.map +1 -0
- package/src/functions/cloudflare.js +23 -0
- package/src/functions/deno.d.ts +3 -0
- package/src/functions/deno.d.ts.map +1 -0
- package/src/functions/deno.js +20 -0
- package/src/functions/lambda.d.ts +2 -0
- package/src/functions/lambda.d.ts.map +1 -0
- package/src/functions/lambda.js +26 -0
- package/src/health/RuntimeHealthProbes.d.ts +13 -0
- package/src/health/RuntimeHealthProbes.d.ts.map +1 -0
- package/src/health/RuntimeHealthProbes.js +62 -0
- package/src/health/StartupHealthChecks.d.ts +26 -0
- package/src/health/StartupHealthChecks.d.ts.map +1 -0
- package/src/health/StartupHealthChecks.js +124 -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/ErrorResponse.d.ts +28 -0
- package/src/http/ErrorResponse.d.ts.map +1 -0
- package/src/http/ErrorResponse.js +42 -0
- 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 +29 -0
- package/src/http/Kernel.d.ts.map +1 -0
- package/src/http/Kernel.js +254 -0
- package/src/http/Request.d.ts +64 -0
- package/src/http/Request.d.ts.map +1 -0
- package/src/http/Request.js +237 -0
- package/src/http/RequestContext.d.ts +26 -0
- package/src/http/RequestContext.d.ts.map +1 -0
- package/src/http/RequestContext.js +153 -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/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 +89 -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.map +1 -0
- package/src/index.js +212 -0
- package/src/lang/lang.d.ts +23 -0
- package/src/lang/lang.d.ts.map +1 -0
- package/src/lang/lang.js +22 -0
- package/src/microservices/MicroserviceBootstrap.d.ts +75 -0
- package/src/microservices/MicroserviceBootstrap.d.ts.map +1 -0
- package/src/microservices/MicroserviceBootstrap.js +288 -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 +268 -0
- package/src/microservices/PostgresAdapter.d.ts +90 -0
- package/src/microservices/PostgresAdapter.d.ts.map +1 -0
- package/src/microservices/PostgresAdapter.js +306 -0
- package/src/microservices/RequestTracingMiddleware.d.ts +41 -0
- package/src/microservices/RequestTracingMiddleware.d.ts.map +1 -0
- package/src/microservices/RequestTracingMiddleware.js +125 -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 +299 -0
- package/src/microservices/ServiceHealthMonitor.d.ts +96 -0
- package/src/microservices/ServiceHealthMonitor.d.ts.map +1 -0
- package/src/microservices/ServiceHealthMonitor.js +383 -0
- 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 +29 -0
- package/src/middleware/CsrfMiddleware.d.ts.map +1 -0
- package/src/middleware/CsrfMiddleware.js +132 -0
- package/src/middleware/ErrorHandlerMiddleware.d.ts +6 -0
- package/src/middleware/ErrorHandlerMiddleware.d.ts.map +1 -0
- package/src/middleware/ErrorHandlerMiddleware.js +41 -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 +9 -0
- package/src/middleware/LoggingMiddleware.d.ts.map +1 -0
- package/src/middleware/LoggingMiddleware.js +41 -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 +57 -0
- package/src/middleware/RateLimiter.d.ts.map +1 -0
- package/src/middleware/RateLimiter.js +270 -0
- 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 +33 -0
- package/src/middleware/SecurityMiddleware.d.ts.map +1 -0
- package/src/middleware/SecurityMiddleware.js +106 -0
- package/src/middleware/SessionMiddleware.d.ts +8 -0
- package/src/middleware/SessionMiddleware.d.ts.map +1 -0
- package/src/middleware/SessionMiddleware.js +15 -0
- 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/middleware/index.d.ts +11 -0
- package/src/middleware/index.d.ts.map +1 -0
- package/src/middleware/index.js +10 -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/enum/index.d.ts +93 -0
- package/src/migrations/enum/index.d.ts.map +1 -0
- package/src/migrations/enum/index.js +92 -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 +191 -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 +142 -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 +270 -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 +87 -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/async_hooks.d.ts +9 -0
- package/src/node-singletons/async_hooks.d.ts.map +1 -0
- package/src/node-singletons/async_hooks.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 +35 -0
- package/src/node-singletons/index.d.ts.map +1 -0
- package/src/node-singletons/index.js +36 -0
- package/src/node-singletons/module.d.ts +9 -0
- package/src/node-singletons/module.d.ts.map +1 -0
- package/src/node-singletons/module.js +9 -0
- package/src/node-singletons/net.d.ts +9 -0
- package/src/node-singletons/net.d.ts.map +1 -0
- package/src/node-singletons/net.js +8 -0
- package/src/node-singletons/os.d.ts +18 -0
- package/src/node-singletons/os.d.ts.map +1 -0
- package/src/node-singletons/os.js +17 -0
- package/src/node-singletons/path.d.ts +9 -0
- package/src/node-singletons/path.d.ts.map +1 -0
- package/src/node-singletons/path.js +8 -0
- package/src/node-singletons/perf-hooks.d.ts +9 -0
- package/src/node-singletons/perf-hooks.d.ts.map +1 -0
- package/src/node-singletons/perf-hooks.js +8 -0
- package/src/node-singletons/process.d.ts +23 -0
- package/src/node-singletons/process.d.ts.map +1 -0
- package/src/node-singletons/process.js +8 -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 +8 -0
- package/src/node-singletons/tls.d.ts +9 -0
- package/src/node-singletons/tls.d.ts.map +1 -0
- package/src/node-singletons/tls.js +8 -0
- package/src/node-singletons/url.d.ts +9 -0
- package/src/node-singletons/url.d.ts.map +1 -0
- package/src/node-singletons/url.js +8 -0
- 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 +9 -0
- package/src/node.d.ts.map +1 -0
- package/src/node.js +13 -0
- package/src/observability/OpenTelemetry.d.ts +62 -0
- package/src/observability/OpenTelemetry.d.ts.map +1 -0
- package/src/observability/OpenTelemetry.js +222 -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/ConnectionManager.d.ts +125 -0
- package/src/orm/ConnectionManager.d.ts.map +1 -0
- package/src/orm/ConnectionManager.js +571 -0
- package/src/orm/Database.d.ts +35 -0
- package/src/orm/Database.d.ts.map +1 -0
- package/src/orm/Database.js +350 -0
- package/src/orm/DatabaseAdapter.d.ts +117 -0
- package/src/orm/DatabaseAdapter.d.ts.map +1 -0
- package/src/orm/DatabaseAdapter.js +57 -0
- package/src/orm/DatabaseAdapterRegistry.d.ts +14 -0
- package/src/orm/DatabaseAdapterRegistry.d.ts.map +1 -0
- package/src/orm/DatabaseAdapterRegistry.js +21 -0
- package/src/orm/DatabaseRuntimeRegistration.d.ts +17 -0
- package/src/orm/DatabaseRuntimeRegistration.d.ts.map +1 -0
- package/src/orm/DatabaseRuntimeRegistration.js +73 -0
- package/src/orm/Model.d.ts +135 -0
- package/src/orm/Model.d.ts.map +1 -0
- package/src/orm/Model.js +533 -0
- package/src/orm/QueryBuilder.d.ts +98 -0
- package/src/orm/QueryBuilder.d.ts.map +1 -0
- package/src/orm/QueryBuilder.js +1057 -0
- package/src/orm/Relationships.d.ts +119 -0
- package/src/orm/Relationships.d.ts.map +1 -0
- package/src/orm/Relationships.js +306 -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/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 +15 -0
- package/src/orm/adapters/D1Adapter.d.ts.map +1 -0
- package/src/orm/adapters/D1Adapter.js +132 -0
- package/src/orm/adapters/D1RemoteAdapter.d.ts +11 -0
- package/src/orm/adapters/D1RemoteAdapter.d.ts.map +1 -0
- package/src/orm/adapters/D1RemoteAdapter.js +163 -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 +109 -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 +108 -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 +84 -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 +225 -0
- 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/Benchmark.d.ts +87 -0
- package/src/performance/Benchmark.d.ts.map +1 -0
- package/src/performance/Benchmark.js +307 -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 +100 -0
- package/src/performance/Optimizer.d.ts.map +1 -0
- package/src/performance/Optimizer.js +627 -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 +96 -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/routes/CoreRoutes.d.ts +12 -0
- package/src/routes/CoreRoutes.d.ts.map +1 -0
- package/src/routes/CoreRoutes.js +39 -0
- package/src/routes/RouteRegistry.d.ts +39 -0
- package/src/routes/RouteRegistry.d.ts.map +1 -0
- package/src/routes/RouteRegistry.js +44 -0
- package/src/routes/Router.d.ts +73 -0
- package/src/routes/Router.d.ts.map +1 -0
- package/src/routes/Router.js +250 -0
- package/src/routes/common.d.ts +15 -0
- package/src/routes/common.d.ts.map +1 -0
- package/src/routes/common.js +47 -0
- package/src/routes/doc.d.ts +27 -0
- package/src/routes/doc.d.ts.map +1 -0
- package/src/routes/doc.js +110 -0
- package/src/routes/error.d.ts +21 -0
- package/src/routes/error.d.ts.map +1 -0
- package/src/routes/error.js +127 -0
- package/src/routes/errorPages.d.ts +14 -0
- package/src/routes/errorPages.d.ts.map +1 -0
- package/src/routes/errorPages.js +103 -0
- package/src/routes/health.d.ts +6 -0
- package/src/routes/health.d.ts.map +1 -0
- package/src/routes/health.js +5 -0
- package/src/routes/metrics.d.ts +9 -0
- package/src/routes/metrics.d.ts.map +1 -0
- package/src/routes/metrics.js +20 -0
- package/src/routes/openapi.d.ts +9 -0
- package/src/routes/openapi.d.ts.map +1 -0
- package/src/routes/openapi.js +76 -0
- package/src/routes/publicRoot.d.ts +27 -0
- package/src/routes/publicRoot.d.ts.map +1 -0
- package/src/routes/publicRoot.js +112 -0
- package/src/runtime/PluginAutoImports.d.ts +21 -0
- package/src/runtime/PluginAutoImports.d.ts.map +1 -0
- package/src/runtime/PluginAutoImports.js +53 -0
- package/src/runtime/PluginManager.d.ts +28 -0
- package/src/runtime/PluginManager.d.ts.map +1 -0
- package/src/runtime/PluginManager.js +373 -0
- package/src/runtime/PluginRegistry.d.ts +27 -0
- package/src/runtime/PluginRegistry.d.ts.map +1 -0
- package/src/runtime/PluginRegistry.js +183 -0
- package/src/runtime/RuntimeAdapter.d.ts +126 -0
- package/src/runtime/RuntimeAdapter.d.ts.map +1 -0
- package/src/runtime/RuntimeAdapter.js +146 -0
- package/src/runtime/StartupConfigFileRegistry.d.ts +22 -0
- package/src/runtime/StartupConfigFileRegistry.d.ts.map +1 -0
- package/src/runtime/StartupConfigFileRegistry.js +44 -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 +193 -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 +157 -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 +306 -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 +200 -0
- 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/scheduler/ScheduleRunner.d.ts +18 -0
- package/src/scheduler/ScheduleRunner.d.ts.map +1 -0
- package/src/scheduler/ScheduleRunner.js +155 -0
- package/src/scheduler/index.d.ts +3 -0
- package/src/scheduler/index.d.ts.map +1 -0
- package/src/scheduler/index.js +1 -0
- package/src/scheduler/types.d.ts +16 -0
- package/src/scheduler/types.d.ts.map +1 -0
- package/src/scheduler/types.js +4 -0
- package/src/schedules/index.d.ts +2 -0
- package/src/schedules/index.d.ts.map +1 -0
- package/src/schedules/index.js +1 -0
- package/src/schedules/log-cleanup.d.ts +4 -0
- package/src/schedules/log-cleanup.d.ts.map +1 -0
- package/src/schedules/log-cleanup.js +18 -0
- package/src/scripts/GenerateEnvArtifacts.d.ts +13 -0
- package/src/scripts/GenerateEnvArtifacts.d.ts.map +1 -0
- package/src/scripts/GenerateEnvArtifacts.js +171 -0
- package/src/scripts/TemplateImportsCheck.d.ts +2 -0
- package/src/scripts/TemplateImportsCheck.d.ts.map +1 -0
- package/src/scripts/TemplateImportsCheck.js +151 -0
- package/src/scripts/TemplateSync.d.ts +7 -0
- package/src/scripts/TemplateSync.d.ts.map +1 -0
- package/src/scripts/TemplateSync.js +399 -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/EncryptedEnvelope.d.ts +77 -0
- package/src/security/EncryptedEnvelope.d.ts.map +1 -0
- package/src/security/EncryptedEnvelope.js +256 -0
- package/src/security/Encryptor.d.ts +15 -0
- package/src/security/Encryptor.d.ts.map +1 -0
- package/src/security/Encryptor.js +199 -0
- package/src/security/Hash.d.ts +14 -0
- package/src/security/Hash.d.ts.map +1 -0
- package/src/security/Hash.js +81 -0
- package/src/security/JwtManager.d.ts +42 -0
- package/src/security/JwtManager.d.ts.map +1 -0
- package/src/security/JwtManager.js +262 -0
- package/src/security/PasswordResetTokenBroker.d.ts +39 -0
- package/src/security/PasswordResetTokenBroker.d.ts.map +1 -0
- package/src/security/PasswordResetTokenBroker.js +131 -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/SignedRequest.d.ts +53 -0
- package/src/security/SignedRequest.d.ts.map +1 -0
- package/src/security/SignedRequest.js +172 -0
- package/src/security/StartupSecretValidation.d.ts +20 -0
- package/src/security/StartupSecretValidation.d.ts.map +1 -0
- package/src/security/StartupSecretValidation.js +139 -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/UrlValidator.d.ts +20 -0
- package/src/security/UrlValidator.d.ts.map +1 -0
- package/src/security/UrlValidator.js +41 -0
- package/src/security/Xss.d.ts +14 -0
- package/src/security/Xss.d.ts.map +1 -0
- package/src/security/Xss.js +57 -0
- package/src/security/XssProtection.d.ts +24 -0
- package/src/security/XssProtection.d.ts.map +1 -0
- package/src/security/XssProtection.js +324 -0
- 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.d.ts +39 -0
- package/src/session/SessionManager.d.ts.map +1 -0
- package/src/session/SessionManager.js +149 -0
- package/src/session/index.d.ts +3 -0
- package/src/session/index.d.ts.map +1 -0
- package/src/session/index.js +1 -0
- package/src/start.d.ts +21 -0
- package/src/start.d.ts.map +1 -0
- package/src/start.js +59 -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/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/toolkit/Secrets/EnvFile.d.ts +15 -0
- package/src/toolkit/Secrets/EnvFile.d.ts.map +1 -0
- package/src/toolkit/Secrets/EnvFile.js +63 -0
- package/src/toolkit/Secrets/Manifest.d.ts +24 -0
- package/src/toolkit/Secrets/Manifest.d.ts.map +1 -0
- package/src/toolkit/Secrets/Manifest.js +71 -0
- package/src/toolkit/Secrets/index.d.ts +42 -0
- package/src/toolkit/Secrets/index.d.ts.map +1 -0
- package/src/toolkit/Secrets/index.js +123 -0
- package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts +14 -0
- package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts.map +1 -0
- package/src/toolkit/Secrets/providers/AwsSecretsManager.js +132 -0
- package/src/toolkit/Secrets/providers/CloudflareKv.d.ts +9 -0
- package/src/toolkit/Secrets/providers/CloudflareKv.d.ts.map +1 -0
- package/src/toolkit/Secrets/providers/CloudflareKv.js +74 -0
- package/src/tools/broadcast/Broadcast.d.ts +17 -0
- package/src/tools/broadcast/Broadcast.d.ts.map +1 -0
- package/src/tools/broadcast/Broadcast.js +84 -0
- package/src/tools/broadcast/BroadcastRegistry.d.ts +15 -0
- package/src/tools/broadcast/BroadcastRegistry.d.ts.map +1 -0
- package/src/tools/broadcast/BroadcastRegistry.js +29 -0
- package/src/tools/broadcast/BroadcastRuntimeRegistration.d.ts +11 -0
- package/src/tools/broadcast/BroadcastRuntimeRegistration.d.ts.map +1 -0
- package/src/tools/broadcast/BroadcastRuntimeRegistration.js +23 -0
- package/src/tools/broadcast/drivers/BaseDriver.d.ts +5 -0
- package/src/tools/broadcast/drivers/BaseDriver.d.ts.map +1 -0
- package/src/tools/broadcast/drivers/BaseDriver.js +8 -0
- package/src/tools/broadcast/drivers/InMemory.d.ts +18 -0
- package/src/tools/broadcast/drivers/InMemory.d.ts.map +1 -0
- package/src/tools/broadcast/drivers/InMemory.js +16 -0
- package/src/tools/broadcast/drivers/Pusher.d.ts +8 -0
- package/src/tools/broadcast/drivers/Pusher.d.ts.map +1 -0
- package/src/tools/broadcast/drivers/Pusher.js +75 -0
- package/src/tools/broadcast/drivers/Redis.d.ts +19 -0
- package/src/tools/broadcast/drivers/Redis.d.ts.map +1 -0
- package/src/tools/broadcast/drivers/Redis.js +25 -0
- package/src/tools/broadcast/drivers/RedisHttps.d.ts +14 -0
- package/src/tools/broadcast/drivers/RedisHttps.d.ts.map +1 -0
- package/src/tools/broadcast/drivers/RedisHttps.js +50 -0
- package/src/tools/broadcast/index.d.ts +9 -0
- package/src/tools/broadcast/index.d.ts.map +1 -0
- package/src/tools/broadcast/index.js +8 -0
- package/src/tools/http/Http.d.ts +49 -0
- package/src/tools/http/Http.d.ts.map +1 -0
- package/src/tools/http/Http.js +173 -0
- package/src/tools/http/HttpResponse.d.ts +32 -0
- package/src/tools/http/HttpResponse.d.ts.map +1 -0
- package/src/tools/http/HttpResponse.js +80 -0
- package/src/tools/http/index.d.ts +15 -0
- package/src/tools/http/index.d.ts.map +1 -0
- package/src/tools/http/index.js +9 -0
- package/src/tools/mail/Mail.d.ts +2 -0
- package/src/tools/mail/Mail.d.ts.map +1 -0
- package/src/tools/mail/Mail.js +1 -0
- package/src/tools/mail/MailDriverRegistry.d.ts +18 -0
- package/src/tools/mail/MailDriverRegistry.d.ts.map +1 -0
- package/src/tools/mail/MailDriverRegistry.js +23 -0
- package/src/tools/mail/attachments.d.ts +23 -0
- package/src/tools/mail/attachments.d.ts.map +1 -0
- package/src/tools/mail/attachments.js +26 -0
- package/src/tools/mail/drivers/BaseDriver.d.ts +5 -0
- package/src/tools/mail/drivers/BaseDriver.d.ts.map +1 -0
- package/src/tools/mail/drivers/BaseDriver.js +8 -0
- package/src/tools/mail/drivers/Mailgun.d.ts +31 -0
- package/src/tools/mail/drivers/Mailgun.d.ts.map +1 -0
- package/src/tools/mail/drivers/Mailgun.js +81 -0
- package/src/tools/mail/drivers/SendGrid.d.ts +29 -0
- package/src/tools/mail/drivers/SendGrid.d.ts.map +1 -0
- package/src/tools/mail/drivers/SendGrid.js +58 -0
- package/src/tools/mail/drivers/Ses.d.ts +24 -0
- package/src/tools/mail/drivers/Ses.d.ts.map +1 -0
- package/src/tools/mail/drivers/Ses.js +117 -0
- package/src/tools/mail/drivers/Smtp.d.ts +38 -0
- package/src/tools/mail/drivers/Smtp.d.ts.map +1 -0
- package/src/tools/mail/drivers/Smtp.js +349 -0
- package/src/tools/mail/index.d.ts +40 -0
- package/src/tools/mail/index.d.ts.map +1 -0
- package/src/tools/mail/index.js +129 -0
- package/src/tools/mail/template-loader.d.ts +10 -0
- package/src/tools/mail/template-loader.d.ts.map +1 -0
- package/src/tools/mail/template-loader.js +101 -0
- package/src/tools/mail/template-utils.d.ts +10 -0
- package/src/tools/mail/template-utils.d.ts.map +1 -0
- package/src/tools/mail/template-utils.js +16 -0
- package/src/tools/mail/templates/index.d.ts +57 -0
- package/src/tools/mail/templates/index.d.ts.map +1 -0
- package/src/tools/mail/templates/index.js +104 -0
- package/src/tools/mail/testing.d.ts +41 -0
- package/src/tools/mail/testing.d.ts.map +1 -0
- package/src/tools/mail/testing.js +34 -0
- package/src/tools/notification/Driver.d.ts +11 -0
- package/src/tools/notification/Driver.d.ts.map +1 -0
- package/src/tools/notification/Driver.js +1 -0
- package/src/tools/notification/Notification.d.ts +24 -0
- package/src/tools/notification/Notification.d.ts.map +1 -0
- package/src/tools/notification/Notification.js +35 -0
- package/src/tools/notification/NotificationChannelRegistry.d.ts +15 -0
- package/src/tools/notification/NotificationChannelRegistry.d.ts.map +1 -0
- package/src/tools/notification/NotificationChannelRegistry.js +36 -0
- package/src/tools/notification/NotificationRuntimeRegistration.d.ts +13 -0
- package/src/tools/notification/NotificationRuntimeRegistration.d.ts.map +1 -0
- package/src/tools/notification/NotificationRuntimeRegistration.js +25 -0
- package/src/tools/notification/Registry.d.ts +10 -0
- package/src/tools/notification/Registry.d.ts.map +1 -0
- package/src/tools/notification/Registry.js +26 -0
- package/src/tools/notification/Service.d.ts +7 -0
- package/src/tools/notification/Service.d.ts.map +1 -0
- package/src/tools/notification/Service.js +91 -0
- package/src/tools/notification/config.d.ts +5 -0
- package/src/tools/notification/config.d.ts.map +1 -0
- package/src/tools/notification/config.js +5 -0
- package/src/tools/notification/drivers/BaseDriver.d.ts +5 -0
- package/src/tools/notification/drivers/BaseDriver.d.ts.map +1 -0
- package/src/tools/notification/drivers/BaseDriver.js +8 -0
- package/src/tools/notification/drivers/Console.d.ts +7 -0
- package/src/tools/notification/drivers/Console.d.ts.map +1 -0
- package/src/tools/notification/drivers/Console.js +13 -0
- package/src/tools/notification/drivers/Slack.d.ts +16 -0
- package/src/tools/notification/drivers/Slack.d.ts.map +1 -0
- package/src/tools/notification/drivers/Slack.js +24 -0
- package/src/tools/notification/drivers/SlackNotification.d.ts +8 -0
- package/src/tools/notification/drivers/SlackNotification.d.ts.map +1 -0
- package/src/tools/notification/drivers/SlackNotification.js +13 -0
- package/src/tools/notification/drivers/Termii.d.ts +10 -0
- package/src/tools/notification/drivers/Termii.d.ts.map +1 -0
- package/src/tools/notification/drivers/Termii.js +36 -0
- package/src/tools/notification/drivers/Twilio.d.ts +21 -0
- package/src/tools/notification/drivers/Twilio.d.ts.map +1 -0
- package/src/tools/notification/drivers/Twilio.js +48 -0
- package/src/tools/notification/drivers/TwilioNotification.d.ts +8 -0
- package/src/tools/notification/drivers/TwilioNotification.d.ts.map +1 -0
- package/src/tools/notification/drivers/TwilioNotification.js +13 -0
- package/src/tools/notification/templates/markdown/index.d.ts +15 -0
- package/src/tools/notification/templates/markdown/index.d.ts.map +1 -0
- package/src/tools/notification/templates/markdown/index.js +38 -0
- package/src/tools/notification/templates/markdown/registry.d.ts +15 -0
- package/src/tools/notification/templates/markdown/registry.d.ts.map +1 -0
- package/src/tools/notification/templates/markdown/registry.js +36 -0
- package/src/tools/notification/testing.d.ts +19 -0
- package/src/tools/notification/testing.d.ts.map +1 -0
- package/src/tools/notification/testing.js +35 -0
- package/src/tools/notification/testingHelpers.d.ts +12 -0
- package/src/tools/notification/testingHelpers.d.ts.map +1 -0
- package/src/tools/notification/testingHelpers.js +32 -0
- package/src/tools/queue/AdvancedQueue.d.ts +19 -0
- package/src/tools/queue/AdvancedQueue.d.ts.map +1 -0
- package/src/tools/queue/AdvancedQueue.js +352 -0
- package/src/tools/queue/DeduplicationBuilder.d.ts +20 -0
- package/src/tools/queue/DeduplicationBuilder.d.ts.map +1 -0
- package/src/tools/queue/DeduplicationBuilder.js +77 -0
- package/src/tools/queue/LockProvider.d.ts +22 -0
- package/src/tools/queue/LockProvider.d.ts.map +1 -0
- package/src/tools/queue/LockProvider.js +282 -0
- package/src/tools/queue/Queue.d.ts +25 -0
- package/src/tools/queue/Queue.d.ts.map +1 -0
- package/src/tools/queue/Queue.js +53 -0
- package/src/tools/queue/QueueExtensions.d.ts +46 -0
- package/src/tools/queue/QueueExtensions.d.ts.map +1 -0
- package/src/tools/queue/QueueExtensions.js +129 -0
- package/src/tools/queue/QueueRuntimeRegistration.d.ts +11 -0
- package/src/tools/queue/QueueRuntimeRegistration.d.ts.map +1 -0
- package/src/tools/queue/QueueRuntimeRegistration.js +25 -0
- package/src/tools/queue/drivers/Database.d.ts +23 -0
- package/src/tools/queue/drivers/Database.d.ts.map +1 -0
- package/src/tools/queue/drivers/Database.js +123 -0
- package/src/tools/queue/drivers/InMemory.d.ts +10 -0
- package/src/tools/queue/drivers/InMemory.d.ts.map +1 -0
- package/src/tools/queue/drivers/InMemory.js +55 -0
- package/src/tools/queue/drivers/Redis.d.ts +10 -0
- package/src/tools/queue/drivers/Redis.d.ts.map +1 -0
- package/src/tools/queue/drivers/Redis.js +26 -0
- package/src/tools/queue/index.d.ts +9 -0
- package/src/tools/queue/index.d.ts.map +1 -0
- package/src/tools/queue/index.js +7 -0
- package/src/tools/redis/RedisKeyManager.d.ts +66 -0
- package/src/tools/redis/RedisKeyManager.d.ts.map +1 -0
- package/src/tools/redis/RedisKeyManager.js +126 -0
- package/src/tools/storage/LocalSignedUrl.d.ts +12 -0
- package/src/tools/storage/LocalSignedUrl.d.ts.map +1 -0
- package/src/tools/storage/LocalSignedUrl.js +108 -0
- package/src/tools/storage/StorageDiskRegistry.d.ts +14 -0
- package/src/tools/storage/StorageDiskRegistry.d.ts.map +1 -0
- package/src/tools/storage/StorageDiskRegistry.js +36 -0
- package/src/tools/storage/StorageDriverRegistry.d.ts +16 -0
- package/src/tools/storage/StorageDriverRegistry.d.ts.map +1 -0
- package/src/tools/storage/StorageDriverRegistry.js +20 -0
- package/src/tools/storage/StorageRuntimeRegistration.d.ts +10 -0
- package/src/tools/storage/StorageRuntimeRegistration.d.ts.map +1 -0
- package/src/tools/storage/StorageRuntimeRegistration.js +21 -0
- package/src/tools/storage/drivers/Gcs.d.ts +20 -0
- package/src/tools/storage/drivers/Gcs.d.ts.map +1 -0
- package/src/tools/storage/drivers/Gcs.js +152 -0
- package/src/tools/storage/drivers/Local.d.ts +18 -0
- package/src/tools/storage/drivers/Local.d.ts.map +1 -0
- package/src/tools/storage/drivers/Local.js +89 -0
- package/src/tools/storage/drivers/R2.d.ts +20 -0
- package/src/tools/storage/drivers/R2.d.ts.map +1 -0
- package/src/tools/storage/drivers/R2.js +73 -0
- package/src/tools/storage/drivers/S3.d.ts +26 -0
- package/src/tools/storage/drivers/S3.d.ts.map +1 -0
- package/src/tools/storage/drivers/S3.js +259 -0
- package/src/tools/storage/index.d.ts +21 -0
- package/src/tools/storage/index.d.ts.map +1 -0
- package/src/tools/storage/index.js +150 -0
- package/src/tools/storage/testing.d.ts +23 -0
- package/src/tools/storage/testing.d.ts.map +1 -0
- package/src/tools/storage/testing.js +53 -0
- package/src/tools/templates/MarkdownRenderer.d.ts +14 -0
- package/src/tools/templates/MarkdownRenderer.d.ts.map +1 -0
- package/src/tools/templates/MarkdownRenderer.js +300 -0
- package/src/tools/templates/index.d.ts +5 -0
- package/src/tools/templates/index.d.ts.map +1 -0
- package/src/tools/templates/index.js +4 -0
- package/src/types/Queue.d.ts +62 -0
- package/src/types/Queue.d.ts.map +1 -0
- package/src/types/Queue.js +5 -0
- package/src/validation/ValidationError.d.ts +42 -0
- package/src/validation/ValidationError.d.ts.map +1 -0
- package/src/validation/ValidationError.js +55 -0
- package/src/validation/Validator.d.ts +93 -0
- package/src/validation/Validator.d.ts.map +1 -0
- package/src/validation/Validator.js +492 -0
- package/bin/z.ts +0 -10
- package/bin/zin.ts +0 -10
- package/bin/zintrust-main.ts +0 -130
- package/bin/zintrust-microservices.ts +0 -199
- package/bin/zintrust.ts +0 -14
- package/bin/zt.ts +0 -10
- package/dist/src/index.js +0 -212
- package/src/auth/Auth.ts +0 -42
- package/src/boot/Application.ts +0 -490
- package/src/boot/Server.ts +0 -155
- package/src/boot/bootstrap.ts +0 -274
- package/src/builder/BundleOptimizer.ts +0 -483
- package/src/cache/Cache.ts +0 -185
- package/src/cache/CacheDriver.ts +0 -39
- package/src/cache/CacheDriverRegistry.ts +0 -29
- package/src/cache/CacheRuntimeRegistration.ts +0 -24
- package/src/cache/drivers/KVDriver.ts +0 -63
- package/src/cache/drivers/KVRemoteDriver.ts +0 -97
- package/src/cache/drivers/MemoryDriver.ts +0 -85
- package/src/cache/drivers/MongoDriver.ts +0 -96
- package/src/cache/drivers/RedisDriver.ts +0 -95
- package/src/cli/BaseCommand.ts +0 -106
- package/src/cli/CLI.ts +0 -280
- package/src/cli/ErrorHandler.ts +0 -130
- package/src/cli/PromptHelper.ts +0 -203
- package/src/cli/commands/AddCommand.ts +0 -1290
- package/src/cli/commands/BroadcastWorkCommand.ts +0 -20
- package/src/cli/commands/ConfigCommand.ts +0 -422
- package/src/cli/commands/CreateCommand.ts +0 -177
- package/src/cli/commands/D1MigrateCommand.ts +0 -98
- package/src/cli/commands/DbSeedCommand.ts +0 -181
- package/src/cli/commands/DebugCommand.ts +0 -71
- package/src/cli/commands/FixCommand.ts +0 -84
- package/src/cli/commands/JwtDevCommand.ts +0 -154
- package/src/cli/commands/KeyGenerateCommand.ts +0 -86
- package/src/cli/commands/LogsCleanupCommand.ts +0 -24
- package/src/cli/commands/LogsCommand.ts +0 -270
- package/src/cli/commands/MakeMailTemplateCommand.ts +0 -119
- package/src/cli/commands/MakeNotificationTemplateCommand.ts +0 -164
- package/src/cli/commands/MigrateCommand.ts +0 -435
- package/src/cli/commands/MigrateWorkerCommand.ts +0 -180
- package/src/cli/commands/NewCommand.ts +0 -546
- package/src/cli/commands/NotificationWorkCommand.ts +0 -20
- package/src/cli/commands/PluginCommand.ts +0 -112
- package/src/cli/commands/PrepareCommand.ts +0 -65
- package/src/cli/commands/PublishCommand.ts +0 -79
- package/src/cli/commands/QACommand.ts +0 -551
- package/src/cli/commands/QueueCommand.ts +0 -145
- package/src/cli/commands/QueueLockCommand.ts +0 -156
- package/src/cli/commands/QueueWorkCommandUtils.ts +0 -54
- package/src/cli/commands/ResourceControlCommand.ts +0 -49
- package/src/cli/commands/RoutesCommand.ts +0 -316
- package/src/cli/commands/SecretsCommand.ts +0 -144
- package/src/cli/commands/SimulateCommand.ts +0 -97
- package/src/cli/commands/StartCommand.ts +0 -448
- package/src/cli/commands/TemplatesCommand.ts +0 -72
- package/src/cli/commands/UpgradeCommand.ts +0 -128
- package/src/cli/commands/WorkerCommands.ts +0 -373
- package/src/cli/commands/createKindWorkCommand.ts +0 -56
- package/src/cli/commands/index.ts +0 -28
- package/src/cli/commands/runner/index.ts +0 -140
- package/src/cli/config/ConfigManager.ts +0 -221
- package/src/cli/config/ConfigSchema.ts +0 -263
- package/src/cli/config/ConfigValidator.ts +0 -250
- package/src/cli/config/index.ts +0 -21
- package/src/cli/d1/D1SqlMigrations.ts +0 -289
- package/src/cli/d1/WranglerConfig.ts +0 -146
- package/src/cli/d1/WranglerD1.ts +0 -28
- package/src/cli/debug/Dashboard.ts +0 -227
- package/src/cli/env/EnvFileBackfill.ts +0 -80
- package/src/cli/index.ts +0 -17
- package/src/cli/logger/Logger.ts +0 -193
- package/src/cli/scaffolding/ControllerGenerator.ts +0 -633
- package/src/cli/scaffolding/FactoryGenerator.ts +0 -430
- package/src/cli/scaffolding/FeatureScaffolder.ts +0 -811
- package/src/cli/scaffolding/FileGenerator.ts +0 -262
- package/src/cli/scaffolding/GovernanceScaffolder.ts +0 -392
- package/src/cli/scaffolding/MigrationGenerator.ts +0 -418
- package/src/cli/scaffolding/ModelGenerator.ts +0 -337
- package/src/cli/scaffolding/ProjectScaffolder.ts +0 -786
- package/src/cli/scaffolding/RequestFactoryGenerator.ts +0 -561
- package/src/cli/scaffolding/ResponseFactoryGenerator.ts +0 -394
- package/src/cli/scaffolding/RouteGenerator.ts +0 -450
- package/src/cli/scaffolding/SeederGenerator.ts +0 -428
- package/src/cli/scaffolding/ServiceIntegrationTestGenerator.ts +0 -317
- package/src/cli/scaffolding/ServiceRequestFactoryGenerator.ts +0 -485
- package/src/cli/scaffolding/ServiceScaffolder.ts +0 -449
- package/src/cli/scaffolding/TemplateEngine.ts +0 -141
- package/src/cli/scaffolding/TemplateGenerator.ts +0 -255
- package/src/cli/scaffolding/WorkflowGenerator.ts +0 -221
- package/src/cli/scaffolding/index.ts +0 -89
- package/src/cli/services/VersionChecker.ts +0 -308
- package/src/cli/utils/DatabaseCliUtils.ts +0 -75
- package/src/cli/utils/DistPackager.ts +0 -154
- package/src/cli/utils/EnvFileLoader.ts +0 -218
- package/src/cli/utils/spawn.ts +0 -116
- package/src/cli/workers/QueueWorkRunner.ts +0 -377
- package/src/collections/Collection.ts +0 -241
- package/src/collections/index.ts +0 -2
- package/src/common/AwsSigV4.ts +0 -116
- package/src/common/ExternalServiceUtils.ts +0 -151
- package/src/common/HealthRoutes.ts +0 -144
- package/src/common/RemoteSignedJson.ts +0 -117
- package/src/common/index.ts +0 -380
- package/src/common/utility.ts +0 -140
- package/src/config/FileLogWriter.ts +0 -342
- package/src/config/SecretsManager.ts +0 -452
- package/src/config/StartupConfigValidator.ts +0 -268
- package/src/config/app.ts +0 -229
- package/src/config/broadcast.ts +0 -194
- package/src/config/cache.ts +0 -175
- package/src/config/cloudflare.ts +0 -43
- package/src/config/constants.ts +0 -167
- package/src/config/database.ts +0 -344
- package/src/config/env.ts +0 -245
- package/src/config/features.ts +0 -57
- package/src/config/index.ts +0 -46
- package/src/config/logger.ts +0 -387
- package/src/config/logging/HttpLogger.ts +0 -121
- package/src/config/logging/KvLogger.ts +0 -181
- package/src/config/logging/SlackLogger.ts +0 -156
- package/src/config/mail.ts +0 -186
- package/src/config/microservices.ts +0 -104
- package/src/config/middleware.ts +0 -360
- package/src/config/notification.ts +0 -205
- package/src/config/queue.ts +0 -205
- package/src/config/redis.ts +0 -84
- package/src/config/security.ts +0 -170
- package/src/config/startup.ts +0 -29
- package/src/config/storage.ts +0 -205
- package/src/config/type.ts +0 -611
- package/src/config/workers.ts +0 -257
- package/src/container/ServiceContainer.ts +0 -108
- package/src/database/Paginator.ts +0 -141
- package/src/database/factories/.gitkeep +0 -0
- package/src/database/migrations/.gitkeep +0 -0
- package/src/database/migrations/index.ts +0 -2
- package/src/database/seeders/.gitkeep +0 -0
- package/src/events/EventDispatcher.ts +0 -141
- package/src/events/index.ts +0 -2
- package/src/exceptions/ZintrustError.ts +0 -290
- package/src/functions/cloudflare.ts +0 -28
- package/src/functions/deno.ts +0 -25
- package/src/functions/lambda.ts +0 -30
- package/src/health/RuntimeHealthProbes.ts +0 -75
- package/src/health/StartupHealthChecks.ts +0 -156
- package/src/http/Controller.ts +0 -64
- package/src/http/ErrorResponse.ts +0 -76
- package/src/http/FileUpload.ts +0 -194
- package/src/http/Kernel.ts +0 -356
- package/src/http/Request.ts +0 -382
- package/src/http/RequestContext.ts +0 -194
- package/src/http/Response.ts +0 -93
- package/src/http/ValidationHelper.ts +0 -131
- package/src/http/error-pages/ErrorPageRenderer.ts +0 -108
- package/src/http/middleware/BodyParsingMiddleware.ts +0 -294
- package/src/http/middleware/FileUploadMiddleware.ts +0 -91
- package/src/http/parsers/BodyParsers.ts +0 -188
- package/src/http/parsers/MultipartParser.ts +0 -211
- package/src/http/parsers/MultipartParserRegistry.ts +0 -54
- package/src/http/validated.ts +0 -55
- package/src/index.ts +0 -436
- package/src/lang/lang.ts +0 -22
- package/src/microservices/MicroserviceBootstrap.ts +0 -411
- package/src/microservices/MicroserviceGenerator.ts +0 -534
- package/src/microservices/MicroserviceManager.ts +0 -409
- package/src/microservices/PostgresAdapter.ts +0 -475
- package/src/microservices/RequestTracingMiddleware.ts +0 -207
- package/src/microservices/ServiceAuthMiddleware.ts +0 -363
- package/src/microservices/ServiceBundler.ts +0 -432
- package/src/microservices/ServiceHealthMonitor.ts +0 -512
- package/src/middleware/AuthMiddleware.ts +0 -29
- package/src/middleware/CsrfMiddleware.ts +0 -177
- package/src/middleware/ErrorHandlerMiddleware.ts +0 -52
- package/src/middleware/JwtAuthMiddleware.ts +0 -99
- package/src/middleware/LoggingMiddleware.ts +0 -55
- package/src/middleware/MiddlewareStack.ts +0 -69
- package/src/middleware/RateLimiter.ts +0 -338
- package/src/middleware/SanitizeBodyMiddleware.ts +0 -41
- package/src/middleware/SecurityMiddleware.ts +0 -145
- package/src/middleware/SessionMiddleware.ts +0 -26
- package/src/middleware/ValidationMiddleware.ts +0 -296
- package/src/middleware/index.ts +0 -11
- package/src/migrations/MigrationDiscovery.ts +0 -17
- package/src/migrations/MigrationLoader.ts +0 -59
- package/src/migrations/MigrationLock.ts +0 -42
- package/src/migrations/Migrator.ts +0 -16
- package/src/migrations/MigratorFactory.ts +0 -473
- package/src/migrations/enum/index.ts +0 -114
- package/src/migrations/schema/Blueprint.ts +0 -240
- package/src/migrations/schema/Schema.ts +0 -228
- package/src/migrations/schema/SchemaCompiler.ts +0 -375
- package/src/migrations/schema/index.ts +0 -17
- package/src/migrations/schema/types.ts +0 -113
- package/src/migrations/types.ts +0 -52
- package/src/node-singletons/async_hooks.ts +0 -12
- package/src/node-singletons/child-process.ts +0 -7
- package/src/node-singletons/crypto.ts +0 -21
- package/src/node-singletons/events.ts +0 -7
- package/src/node-singletons/fs.ts +0 -38
- package/src/node-singletons/http.ts +0 -13
- package/src/node-singletons/index.ts +0 -38
- package/src/node-singletons/module.ts +0 -12
- package/src/node-singletons/net.ts +0 -10
- package/src/node-singletons/os.ts +0 -20
- package/src/node-singletons/path.ts +0 -11
- package/src/node-singletons/perf-hooks.ts +0 -11
- package/src/node-singletons/process.ts +0 -58
- package/src/node-singletons/readline.ts +0 -12
- package/src/node-singletons/tls.ts +0 -10
- package/src/node-singletons/url.ts +0 -11
- package/src/node-singletons/util.ts +0 -6
- package/src/node.ts +0 -32
- package/src/observability/OpenTelemetry.ts +0 -295
- package/src/observability/PrometheusMetrics.ts +0 -161
- package/src/openapi/OpenApiGenerator.ts +0 -452
- package/src/orm/ConnectionManager.ts +0 -759
- package/src/orm/Database.ts +0 -521
- package/src/orm/DatabaseAdapter.ts +0 -169
- package/src/orm/DatabaseAdapterRegistry.ts +0 -38
- package/src/orm/DatabaseRuntimeRegistration.ts +0 -87
- package/src/orm/Model.ts +0 -1025
- package/src/orm/QueryBuilder.ts +0 -1492
- package/src/orm/Relationships.ts +0 -419
- package/src/orm/Schema.ts +0 -403
- package/src/orm/SchemaCompiler.ts +0 -160
- package/src/orm/adapters/D1Adapter.ts +0 -149
- package/src/orm/adapters/D1RemoteAdapter.ts +0 -236
- package/src/orm/adapters/MySQLAdapter.ts +0 -129
- package/src/orm/adapters/PostgreSQLAdapter.ts +0 -148
- package/src/orm/adapters/SQLServerAdapter.ts +0 -99
- package/src/orm/adapters/SQLiteAdapter.ts +0 -314
- package/src/orm/maintenance/SqliteMaintenance.ts +0 -22
- package/src/orm/migrations/MigrationStore.ts +0 -232
- package/src/performance/Benchmark.ts +0 -456
- package/src/performance/CodeGenerationBenchmark.ts +0 -338
- package/src/performance/Optimizer.ts +0 -846
- package/src/performance/establish-baseline.ts +0 -69
- package/src/profiling/MemoryProfiler.ts +0 -111
- package/src/profiling/N1Detector.ts +0 -144
- package/src/profiling/QueryLogger.ts +0 -233
- package/src/profiling/RequestProfiler.ts +0 -123
- package/src/profiling/types.ts +0 -86
- package/src/routes/CoreRoutes.ts +0 -47
- package/src/routes/RouteRegistry.ts +0 -106
- package/src/routes/Router.ts +0 -435
- package/src/routes/common.ts +0 -50
- package/src/routes/doc.ts +0 -139
- package/src/routes/error.ts +0 -185
- package/src/routes/errorPages.ts +0 -125
- package/src/routes/health.ts +0 -6
- package/src/routes/metrics.ts +0 -24
- package/src/routes/openapi.ts +0 -93
- package/src/routes/publicRoot.ts +0 -125
- package/src/runtime/PluginAutoImports.ts +0 -67
- package/src/runtime/PluginManager.ts +0 -468
- package/src/runtime/PluginRegistry.ts +0 -232
- package/src/runtime/RuntimeAdapter.ts +0 -291
- package/src/runtime/StartupConfigFileRegistry.ts +0 -64
- package/src/runtime/adapters/CloudflareAdapter.ts +0 -273
- package/src/runtime/adapters/DenoAdapter.ts +0 -269
- package/src/runtime/adapters/FargateAdapter.ts +0 -230
- package/src/runtime/adapters/LambdaAdapter.ts +0 -475
- package/src/runtime/adapters/NodeServerAdapter.ts +0 -289
- package/src/runtime/getKernel.ts +0 -34
- package/src/runtime/useFileLoader.ts +0 -234
- package/src/scheduler/ScheduleRunner.ts +0 -219
- package/src/scheduler/index.ts +0 -2
- package/src/scheduler/types.ts +0 -18
- package/src/schedules/index.ts +0 -1
- package/src/schedules/log-cleanup.ts +0 -21
- package/src/scripts/GenerateEnvArtifacts.ts +0 -203
- package/src/scripts/TemplateImportsCheck.ts +0 -180
- package/src/scripts/TemplateSync.ts +0 -489
- package/src/security/CsrfTokenManager.ts +0 -102
- package/src/security/EncryptedEnvelope.ts +0 -373
- package/src/security/Encryptor.ts +0 -259
- package/src/security/Hash.ts +0 -97
- package/src/security/JwtManager.ts +0 -375
- package/src/security/PasswordResetTokenBroker.ts +0 -193
- package/src/security/Sanitizer.ts +0 -614
- package/src/security/SignedRequest.ts +0 -315
- package/src/security/StartupSecretValidation.ts +0 -162
- package/src/security/TokenRevocation.ts +0 -64
- package/src/security/UrlValidator.ts +0 -57
- package/src/security/Xss.ts +0 -74
- package/src/security/XssProtection.ts +0 -396
- package/src/seeders/SeederDiscovery.ts +0 -22
- package/src/seeders/SeederLoader.ts +0 -88
- package/src/seeders/types.ts +0 -20
- package/src/services/default/test/.env +0 -19
- package/src/services/default/users/.env +0 -19
- package/src/services/ecommerce/docker-compose.yml +0 -155
- package/src/services/ecommerce/init-db.sql +0 -71
- package/src/services/ecommerce/orders/service.config.json +0 -20
- package/src/services/ecommerce/payments/service.config.json +0 -19
- package/src/services/ecommerce/users/Dockerfile +0 -57
- package/src/services/ecommerce/users/service.config.json +0 -20
- package/src/session/SessionManager.ts +0 -241
- package/src/session/index.ts +0 -2
- package/src/start.ts +0 -68
- package/src/testing/TestEnvironment.ts +0 -213
- package/src/testing/TestHttp.ts +0 -134
- package/src/testing/index.ts +0 -11
- package/src/time/DateTime.ts +0 -548
- package/src/time/index.ts +0 -7
- package/src/toolkit/Secrets/EnvFile.ts +0 -80
- package/src/toolkit/Secrets/Manifest.ts +0 -119
- package/src/toolkit/Secrets/index.ts +0 -192
- package/src/toolkit/Secrets/providers/AwsSecretsManager.ts +0 -189
- package/src/toolkit/Secrets/providers/CloudflareKv.ts +0 -94
- package/src/tools/broadcast/Broadcast.ts +0 -116
- package/src/tools/broadcast/BroadcastRegistry.ts +0 -38
- package/src/tools/broadcast/BroadcastRuntimeRegistration.ts +0 -31
- package/src/tools/broadcast/drivers/BaseDriver.ts +0 -10
- package/src/tools/broadcast/drivers/InMemory.ts +0 -20
- package/src/tools/broadcast/drivers/Pusher.ts +0 -107
- package/src/tools/broadcast/drivers/Redis.ts +0 -49
- package/src/tools/broadcast/drivers/RedisHttps.ts +0 -74
- package/src/tools/broadcast/index.ts +0 -8
- package/src/tools/http/Http.ts +0 -234
- package/src/tools/http/HttpResponse.ts +0 -118
- package/src/tools/http/index.ts +0 -11
- package/src/tools/mail/Mail.ts +0 -1
- package/src/tools/mail/MailDriverRegistry.ts +0 -34
- package/src/tools/mail/attachments.ts +0 -47
- package/src/tools/mail/drivers/BaseDriver.ts +0 -10
- package/src/tools/mail/drivers/Mailgun.ts +0 -130
- package/src/tools/mail/drivers/SendGrid.ts +0 -103
- package/src/tools/mail/drivers/Ses.ts +0 -179
- package/src/tools/mail/drivers/Smtp.ts +0 -490
- package/src/tools/mail/index.ts +0 -218
- package/src/tools/mail/template-loader.ts +0 -128
- package/src/tools/mail/template-utils.ts +0 -19
- package/src/tools/mail/templates/auth-password-reset.html +0 -231
- package/src/tools/mail/templates/auth-welcome.html +0 -236
- package/src/tools/mail/templates/general.html +0 -109
- package/src/tools/mail/templates/index.ts +0 -143
- package/src/tools/mail/templates/job-completed.html +0 -188
- package/src/tools/mail/templates/notifications-new-comment.html +0 -228
- package/src/tools/mail/templates/password-reset.html +0 -221
- package/src/tools/mail/templates/performance-report.html +0 -258
- package/src/tools/mail/templates/welcome.html +0 -187
- package/src/tools/mail/templates/worker-alert.html +0 -229
- package/src/tools/mail/testing.ts +0 -59
- package/src/tools/notification/Driver.ts +0 -11
- package/src/tools/notification/Notification.ts +0 -55
- package/src/tools/notification/NotificationChannelRegistry.ts +0 -46
- package/src/tools/notification/NotificationRuntimeRegistration.ts +0 -36
- package/src/tools/notification/Registry.ts +0 -35
- package/src/tools/notification/Service.ts +0 -136
- package/src/tools/notification/config.ts +0 -7
- package/src/tools/notification/drivers/BaseDriver.ts +0 -10
- package/src/tools/notification/drivers/Console.ts +0 -18
- package/src/tools/notification/drivers/Slack.ts +0 -42
- package/src/tools/notification/drivers/SlackNotification.ts +0 -17
- package/src/tools/notification/drivers/Termii.ts +0 -43
- package/src/tools/notification/drivers/Twilio.ts +0 -77
- package/src/tools/notification/drivers/TwilioNotification.ts +0 -19
- package/src/tools/notification/templates/markdown/index.ts +0 -49
- package/src/tools/notification/templates/markdown/notifications/new-follow.md +0 -12
- package/src/tools/notification/templates/markdown/registry.ts +0 -45
- package/src/tools/notification/testing.ts +0 -50
- package/src/tools/notification/testingHelpers.ts +0 -44
- package/src/tools/queue/AdvancedQueue.ts +0 -458
- package/src/tools/queue/DeduplicationBuilder.ts +0 -111
- package/src/tools/queue/LockProvider.ts +0 -335
- package/src/tools/queue/Queue.ts +0 -78
- package/src/tools/queue/QueueExtensions.ts +0 -161
- package/src/tools/queue/QueueRuntimeRegistration.ts +0 -29
- package/src/tools/queue/drivers/Database.ts +0 -183
- package/src/tools/queue/drivers/InMemory.ts +0 -64
- package/src/tools/queue/drivers/Redis.ts +0 -33
- package/src/tools/queue/index.ts +0 -28
- package/src/tools/redis/RedisKeyManager.ts +0 -142
- package/src/tools/storage/LocalSignedUrl.ts +0 -142
- package/src/tools/storage/StorageDiskRegistry.ts +0 -45
- package/src/tools/storage/StorageDriverRegistry.ts +0 -31
- package/src/tools/storage/StorageRuntimeRegistration.ts +0 -32
- package/src/tools/storage/drivers/Gcs.ts +0 -201
- package/src/tools/storage/drivers/Local.ts +0 -116
- package/src/tools/storage/drivers/R2.ts +0 -99
- package/src/tools/storage/drivers/S3.ts +0 -347
- package/src/tools/storage/index.ts +0 -217
- package/src/tools/storage/testing.ts +0 -80
- package/src/tools/templates/MarkdownRenderer.ts +0 -354
- package/src/tools/templates/index.ts +0 -5
- package/src/types/Queue.ts +0 -71
- package/src/types/redis.d.ts +0 -11
- package/src/validation/ValidationError.ts +0 -79
- package/src/validation/Validator.ts +0 -681
- package/src/zintrust.plugins.ts +0 -13
- /package/{dist/src → src}/index.d.ts +0 -0
|
@@ -0,0 +1,1057 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QueryBuilder - Type-Safe Query Builder
|
|
3
|
+
* Build queries without raw SQL
|
|
4
|
+
*/
|
|
5
|
+
import { createPaginator } from '../database/Paginator.js';
|
|
6
|
+
import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
7
|
+
const getIdentifierQuote = (dialect) => {
|
|
8
|
+
const d = (dialect ?? '').toLowerCase();
|
|
9
|
+
if (d === 'mysql') {
|
|
10
|
+
return {
|
|
11
|
+
open: '`',
|
|
12
|
+
close: '`',
|
|
13
|
+
escape: (raw) => raw.replaceAll('`', '``'),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
if (d === 'sqlserver') {
|
|
17
|
+
return {
|
|
18
|
+
open: '[',
|
|
19
|
+
close: ']',
|
|
20
|
+
escape: (raw) => raw.replaceAll(']', ']]'),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
// sqlite/postgresql/d1/d1-remote: standard SQL double-quote identifiers.
|
|
24
|
+
return {
|
|
25
|
+
open: '"',
|
|
26
|
+
close: '"',
|
|
27
|
+
escape: (raw) => raw.replaceAll('"', '""'),
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
const escapeIdentifier = (id, dialect) => {
|
|
31
|
+
const q = getIdentifierQuote(dialect);
|
|
32
|
+
return id
|
|
33
|
+
.split('.')
|
|
34
|
+
.map((part) => `${q.open}${q.escape(part)}${q.close}`)
|
|
35
|
+
.join('.');
|
|
36
|
+
};
|
|
37
|
+
const SAFE_IDENTIFIER_PATH = /^[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*$/;
|
|
38
|
+
const SAFE_IDENTIFIER = /^[A-Za-z_]\w*$/;
|
|
39
|
+
const assertSafeIdentifierPath = (id, label) => {
|
|
40
|
+
const trimmed = id.trim();
|
|
41
|
+
if (trimmed.length === 0) {
|
|
42
|
+
throw ErrorFactory.createDatabaseError(`Empty SQL identifier for ${label}`);
|
|
43
|
+
}
|
|
44
|
+
if (!SAFE_IDENTIFIER_PATH.test(trimmed)) {
|
|
45
|
+
throw ErrorFactory.createDatabaseError(`Unsafe SQL identifier for ${label}`);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const assertSafeIdentifier = (id, label) => {
|
|
49
|
+
const trimmed = id.trim();
|
|
50
|
+
if (trimmed.length === 0) {
|
|
51
|
+
throw ErrorFactory.createDatabaseError(`Empty SQL identifier for ${label}`);
|
|
52
|
+
}
|
|
53
|
+
if (!SAFE_IDENTIFIER.test(trimmed)) {
|
|
54
|
+
throw ErrorFactory.createDatabaseError(`Unsafe SQL identifier for ${label}`);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const normalizeOrderDirection = (direction) => {
|
|
58
|
+
if (direction === undefined || direction === null)
|
|
59
|
+
return 'ASC';
|
|
60
|
+
const trimmed = String(direction).trim();
|
|
61
|
+
if (trimmed.length === 0)
|
|
62
|
+
return 'ASC';
|
|
63
|
+
const normalized = trimmed.toUpperCase();
|
|
64
|
+
if (normalized === 'ASC' || normalized === 'DESC')
|
|
65
|
+
return normalized;
|
|
66
|
+
throw ErrorFactory.createDatabaseError('Unsafe ORDER BY direction');
|
|
67
|
+
};
|
|
68
|
+
const normalizeOperator = (operator) => operator.trim().toUpperCase();
|
|
69
|
+
const ALLOWED_OPERATORS = new Set([
|
|
70
|
+
'=',
|
|
71
|
+
'!=',
|
|
72
|
+
'<>',
|
|
73
|
+
'<',
|
|
74
|
+
'<=',
|
|
75
|
+
'>',
|
|
76
|
+
'>=',
|
|
77
|
+
'LIKE',
|
|
78
|
+
'NOT LIKE',
|
|
79
|
+
'ILIKE',
|
|
80
|
+
'NOT ILIKE',
|
|
81
|
+
'IN',
|
|
82
|
+
'NOT IN',
|
|
83
|
+
'BETWEEN',
|
|
84
|
+
'NOT BETWEEN',
|
|
85
|
+
'IS',
|
|
86
|
+
'IS NOT',
|
|
87
|
+
]);
|
|
88
|
+
const assertSafeOperator = (operator) => {
|
|
89
|
+
const normalized = normalizeOperator(operator);
|
|
90
|
+
if (!ALLOWED_OPERATORS.has(normalized)) {
|
|
91
|
+
throw ErrorFactory.createDatabaseError('Unsafe SQL operator');
|
|
92
|
+
}
|
|
93
|
+
return normalized;
|
|
94
|
+
};
|
|
95
|
+
const assertSafeLimitOffset = (value, label) => {
|
|
96
|
+
if (!Number.isFinite(value) || !Number.isInteger(value) || value < 0) {
|
|
97
|
+
throw ErrorFactory.createDatabaseError(`Unsafe ${label} value`);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const isNumericLiteral = (value) => {
|
|
101
|
+
// Strict, injection-resistant numeric literal allow-list.
|
|
102
|
+
// Allows: 0, 1, 1.5, 0001
|
|
103
|
+
// Disallows: 1e3, 1;DROP, 1 as ok
|
|
104
|
+
return /^(?:0|[1-9]\d*)(?:\.\d+)?$/.test(value);
|
|
105
|
+
};
|
|
106
|
+
const ALLOWED_AGGREGATES = new Set(['MAX', 'MIN', 'COUNT', 'SUM', 'AVG']);
|
|
107
|
+
const tryParseAggregateSelectExpr = (raw) => {
|
|
108
|
+
// Aggregate functions: MAX(col) [AS alias]
|
|
109
|
+
// Capture content greedily to avoid ReDoS from overlapping whitespace patterns (S5852)
|
|
110
|
+
const agg = /^(MAX|MIN|COUNT|SUM|AVG)\(([^)]+)\)(?: AS (\S+))?$/i.exec(raw);
|
|
111
|
+
if (agg === null)
|
|
112
|
+
return null;
|
|
113
|
+
const fn = agg[1]?.toUpperCase();
|
|
114
|
+
const arg = (agg[2] ?? '').trim();
|
|
115
|
+
const alias = (agg[3] ?? '').trim();
|
|
116
|
+
if (!ALLOWED_AGGREGATES.has(fn))
|
|
117
|
+
return null;
|
|
118
|
+
if (arg !== '*') {
|
|
119
|
+
assertSafeIdentifierPath(arg, 'aggregate argument');
|
|
120
|
+
}
|
|
121
|
+
if (alias.length > 0) {
|
|
122
|
+
assertSafeIdentifier(alias, 'aggregate alias');
|
|
123
|
+
}
|
|
124
|
+
return { kind: 'aggregate', fn, arg, alias: alias.length > 0 ? alias : undefined };
|
|
125
|
+
};
|
|
126
|
+
const tryParseColumnAliasSelectExpr = (raw) => {
|
|
127
|
+
// Column alias: col [AS alias]
|
|
128
|
+
// Avoid catastrophic backtracking by using a linear-time separator scan.
|
|
129
|
+
const upperRaw = raw.toUpperCase();
|
|
130
|
+
const asIndex = upperRaw.indexOf(' AS ');
|
|
131
|
+
if (asIndex === -1)
|
|
132
|
+
return null;
|
|
133
|
+
const asSeparator = { index: asIndex, 0: raw.slice(asIndex, asIndex + 4) };
|
|
134
|
+
const col = raw.slice(0, asSeparator.index).trim();
|
|
135
|
+
const alias = raw.slice(asSeparator.index + asSeparator[0].length).trim();
|
|
136
|
+
// Alias must be a single token (no whitespace).
|
|
137
|
+
if (col.length === 0 || alias.length === 0 || /\s/.test(alias))
|
|
138
|
+
return null;
|
|
139
|
+
assertSafeIdentifierPath(col, 'select column');
|
|
140
|
+
assertSafeIdentifier(alias, 'select alias');
|
|
141
|
+
return { kind: 'column', column: col, alias };
|
|
142
|
+
};
|
|
143
|
+
const tryParseSelectExpr = (expr) => {
|
|
144
|
+
const raw = expr.trim();
|
|
145
|
+
if (raw.length === 0) {
|
|
146
|
+
throw ErrorFactory.createDatabaseError('Empty SQL identifier for select column');
|
|
147
|
+
}
|
|
148
|
+
if (raw === '*')
|
|
149
|
+
return { kind: 'all' };
|
|
150
|
+
if (isNumericLiteral(raw))
|
|
151
|
+
return { kind: 'literal', value: raw };
|
|
152
|
+
const aggregate = tryParseAggregateSelectExpr(raw);
|
|
153
|
+
if (aggregate !== null)
|
|
154
|
+
return aggregate;
|
|
155
|
+
const aliased = tryParseColumnAliasSelectExpr(raw);
|
|
156
|
+
if (aliased !== null)
|
|
157
|
+
return aliased;
|
|
158
|
+
// Plain identifier path
|
|
159
|
+
assertSafeIdentifierPath(raw, 'select column');
|
|
160
|
+
return { kind: 'column', column: raw };
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Build SELECT clause
|
|
164
|
+
*/
|
|
165
|
+
const formatSelectExpr = (parsed, dialect) => {
|
|
166
|
+
if (parsed.kind === 'all')
|
|
167
|
+
return '*';
|
|
168
|
+
if (parsed.kind === 'literal')
|
|
169
|
+
return parsed.value;
|
|
170
|
+
if (parsed.kind === 'aggregate') {
|
|
171
|
+
const argSql = parsed.arg === '*' ? '*' : escapeIdentifier(parsed.arg, dialect);
|
|
172
|
+
const base = `${parsed.fn}(${argSql})`;
|
|
173
|
+
const alias = typeof parsed.alias === 'string' && parsed.alias.length > 0 ? parsed.alias : null;
|
|
174
|
+
return alias === null ? base : `${base} AS ${escapeIdentifier(alias, dialect)}`;
|
|
175
|
+
}
|
|
176
|
+
const base = escapeIdentifier(parsed.column, dialect);
|
|
177
|
+
const alias = typeof parsed.alias === 'string' && parsed.alias.length > 0 ? parsed.alias : null;
|
|
178
|
+
return alias === null ? base : `${base} AS ${escapeIdentifier(alias, dialect)}`;
|
|
179
|
+
};
|
|
180
|
+
const buildSelectClause = (columns, dialect) => {
|
|
181
|
+
const out = [];
|
|
182
|
+
for (const c of columns) {
|
|
183
|
+
const parsed = tryParseSelectExpr(String(c));
|
|
184
|
+
if (parsed === null)
|
|
185
|
+
continue;
|
|
186
|
+
out.push(formatSelectExpr(parsed, dialect));
|
|
187
|
+
}
|
|
188
|
+
return out.join(', ');
|
|
189
|
+
};
|
|
190
|
+
const compileWhere = (conditions, dialect) => {
|
|
191
|
+
if (conditions.length === 0)
|
|
192
|
+
return { sql: '', parameters: [] };
|
|
193
|
+
const parameters = [];
|
|
194
|
+
const clauses = conditions.map((clause) => {
|
|
195
|
+
assertSafeIdentifierPath(clause.column, 'where column');
|
|
196
|
+
const operator = assertSafeOperator(clause.operator);
|
|
197
|
+
const columnSql = escapeIdentifier(clause.column, dialect);
|
|
198
|
+
if (operator === 'IN' || operator === 'NOT IN') {
|
|
199
|
+
if (!Array.isArray(clause.value) || clause.value.length === 0) {
|
|
200
|
+
throw ErrorFactory.createDatabaseError('IN operator requires a non-empty array');
|
|
201
|
+
}
|
|
202
|
+
const values = clause.value;
|
|
203
|
+
const placeholders = values.map(() => '?').join(', ');
|
|
204
|
+
for (const v of values)
|
|
205
|
+
parameters.push(v);
|
|
206
|
+
return `${columnSql} ${operator} (${placeholders})`;
|
|
207
|
+
}
|
|
208
|
+
if (operator === 'BETWEEN' || operator === 'NOT BETWEEN') {
|
|
209
|
+
if (!Array.isArray(clause.value) || clause.value.length !== 2) {
|
|
210
|
+
throw ErrorFactory.createDatabaseError('BETWEEN operator requires a 2-item array');
|
|
211
|
+
}
|
|
212
|
+
const range = clause.value;
|
|
213
|
+
parameters.push(range[0], range[1]);
|
|
214
|
+
return `${columnSql} ${operator} ? AND ?`;
|
|
215
|
+
}
|
|
216
|
+
if (operator === 'IS' || operator === 'IS NOT') {
|
|
217
|
+
if (clause.value === null || clause.value === undefined) {
|
|
218
|
+
return `${columnSql} ${operator} NULL`;
|
|
219
|
+
}
|
|
220
|
+
parameters.push(clause.value);
|
|
221
|
+
return `${columnSql} ${operator} ?`;
|
|
222
|
+
}
|
|
223
|
+
parameters.push(clause.value);
|
|
224
|
+
return `${columnSql} ${operator} ?`;
|
|
225
|
+
});
|
|
226
|
+
return { sql: ` WHERE ${clauses.join(' AND ')}`, parameters };
|
|
227
|
+
};
|
|
228
|
+
const buildSoftDeleteWhereClause = (column, mode) => {
|
|
229
|
+
const col = column.trim();
|
|
230
|
+
if (col.length === 0)
|
|
231
|
+
return null;
|
|
232
|
+
assertSafeIdentifierPath(col, 'soft delete column');
|
|
233
|
+
if (mode === 'include')
|
|
234
|
+
return null;
|
|
235
|
+
if (mode === 'only')
|
|
236
|
+
return { column: col, operator: 'IS NOT', value: null };
|
|
237
|
+
return { column: col, operator: 'IS', value: null };
|
|
238
|
+
};
|
|
239
|
+
const getEffectiveWhereConditions = (state) => {
|
|
240
|
+
if (state.softDelete === undefined)
|
|
241
|
+
return state.whereConditions;
|
|
242
|
+
const clause = buildSoftDeleteWhereClause(state.softDelete.column, state.softDelete.mode);
|
|
243
|
+
if (clause === null)
|
|
244
|
+
return state.whereConditions;
|
|
245
|
+
return [...state.whereConditions, clause];
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* Build ORDER BY clause
|
|
249
|
+
*/
|
|
250
|
+
const buildOrderByClause = (orderByClauses, dialect) => {
|
|
251
|
+
if (orderByClauses.length === 0)
|
|
252
|
+
return '';
|
|
253
|
+
const parts = orderByClauses.map((orderBy) => {
|
|
254
|
+
const col = orderBy.column.trim();
|
|
255
|
+
let columnSql = col;
|
|
256
|
+
if (!isNumericLiteral(col)) {
|
|
257
|
+
assertSafeIdentifierPath(col, 'order by column');
|
|
258
|
+
columnSql = escapeIdentifier(col, dialect);
|
|
259
|
+
}
|
|
260
|
+
const dir = normalizeOrderDirection(orderBy.direction);
|
|
261
|
+
return `${columnSql} ${dir}`;
|
|
262
|
+
});
|
|
263
|
+
return ` ORDER BY ${parts.join(', ')}`;
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* Build LIMIT and OFFSET clause
|
|
267
|
+
*/
|
|
268
|
+
const buildLimitOffsetClause = (limit, offset) => {
|
|
269
|
+
let sql = '';
|
|
270
|
+
if (limit !== undefined && limit !== null) {
|
|
271
|
+
assertSafeLimitOffset(limit, 'LIMIT');
|
|
272
|
+
sql += ` LIMIT ${limit}`;
|
|
273
|
+
}
|
|
274
|
+
if (offset !== undefined && offset !== null) {
|
|
275
|
+
assertSafeLimitOffset(offset, 'OFFSET');
|
|
276
|
+
sql += ` OFFSET ${offset}`;
|
|
277
|
+
}
|
|
278
|
+
return sql;
|
|
279
|
+
};
|
|
280
|
+
const buildSelectQuery = (state) => {
|
|
281
|
+
if (state.tableName.length > 0) {
|
|
282
|
+
assertSafeIdentifierPath(state.tableName, 'table name');
|
|
283
|
+
}
|
|
284
|
+
const columns = buildSelectClause(state.selectColumns, state.dialect);
|
|
285
|
+
const fromClause = state.tableName.length > 0 ? ` FROM ${escapeIdentifier(state.tableName, state.dialect)}` : '';
|
|
286
|
+
const where = compileWhere(getEffectiveWhereConditions(state), state.dialect);
|
|
287
|
+
const sql = `SELECT ${columns}${fromClause}${where.sql}${buildOrderByClause(state.orderByClauses, state.dialect)}${buildLimitOffsetClause(state.limitValue, state.offsetValue)}`;
|
|
288
|
+
return { sql, parameters: where.parameters };
|
|
289
|
+
};
|
|
290
|
+
const buildCountQuery = (state) => {
|
|
291
|
+
if (state.tableName.length > 0) {
|
|
292
|
+
assertSafeIdentifierPath(state.tableName, 'table name');
|
|
293
|
+
}
|
|
294
|
+
const fromClause = state.tableName.length > 0 ? ` FROM ${escapeIdentifier(state.tableName, state.dialect)}` : '';
|
|
295
|
+
const where = compileWhere(getEffectiveWhereConditions(state), state.dialect);
|
|
296
|
+
const sql = `SELECT COUNT(*) AS total${fromClause}${where.sql}`;
|
|
297
|
+
return { sql, parameters: where.parameters };
|
|
298
|
+
};
|
|
299
|
+
const applyWhereCondition = (state, column, operator, value) => {
|
|
300
|
+
const col = String(column).trim();
|
|
301
|
+
assertSafeIdentifierPath(col, 'where column');
|
|
302
|
+
let op;
|
|
303
|
+
let val;
|
|
304
|
+
// Shorthand: where('id', 123)
|
|
305
|
+
if (value === undefined) {
|
|
306
|
+
op = '=';
|
|
307
|
+
val = operator;
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
if (typeof operator !== 'string') {
|
|
311
|
+
throw ErrorFactory.createDatabaseError('Unsafe SQL operator');
|
|
312
|
+
}
|
|
313
|
+
op = assertSafeOperator(operator);
|
|
314
|
+
val = value;
|
|
315
|
+
}
|
|
316
|
+
state.whereConditions.push({ column: col, operator: op, value: val });
|
|
317
|
+
};
|
|
318
|
+
const applyOrderByClause = (state, column, direction) => {
|
|
319
|
+
const col = String(column).trim();
|
|
320
|
+
if (!isNumericLiteral(col)) {
|
|
321
|
+
assertSafeIdentifierPath(col, 'order by column');
|
|
322
|
+
}
|
|
323
|
+
const dir = normalizeOrderDirection(direction);
|
|
324
|
+
state.orderByClauses.push({ column: col, direction: dir });
|
|
325
|
+
};
|
|
326
|
+
const applyLimit = (state, count) => {
|
|
327
|
+
assertSafeLimitOffset(count, 'LIMIT');
|
|
328
|
+
state.limitValue = count;
|
|
329
|
+
};
|
|
330
|
+
const applyOffset = (state, count) => {
|
|
331
|
+
assertSafeLimitOffset(count, 'OFFSET');
|
|
332
|
+
state.offsetValue = count;
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* Execute query and return first result
|
|
336
|
+
*/
|
|
337
|
+
async function executeFirst(builder, db) {
|
|
338
|
+
if (!db)
|
|
339
|
+
throw ErrorFactory.createDatabaseError('Database instance not provided to QueryBuilder');
|
|
340
|
+
builder.limit(1);
|
|
341
|
+
const results = (await db.query(builder.toSQL(), builder.getParameters(), builder.isReadOperation()));
|
|
342
|
+
return results[0] ?? null;
|
|
343
|
+
}
|
|
344
|
+
async function executeFirstOrFail(builder, db, message) {
|
|
345
|
+
const result = await executeFirst(builder, db);
|
|
346
|
+
if (result === null)
|
|
347
|
+
throw ErrorFactory.createNotFoundError(message ?? 'Resource not found');
|
|
348
|
+
return result;
|
|
349
|
+
}
|
|
350
|
+
const compileInsert = (tableName, values, dialect) => {
|
|
351
|
+
const items = Array.isArray(values) ? values : [values];
|
|
352
|
+
if (items.length === 0) {
|
|
353
|
+
throw ErrorFactory.createDatabaseError('INSERT requires at least one column');
|
|
354
|
+
}
|
|
355
|
+
// Use keys from the first item
|
|
356
|
+
const keys = Object.keys(items[0] ?? {});
|
|
357
|
+
if (keys.length === 0) {
|
|
358
|
+
throw ErrorFactory.createDatabaseError('INSERT requires at least one column');
|
|
359
|
+
}
|
|
360
|
+
assertSafeIdentifierPath(tableName, 'table name');
|
|
361
|
+
for (const key of keys)
|
|
362
|
+
assertSafeIdentifier(key, 'insert column');
|
|
363
|
+
const colsSql = keys.map((k) => escapeIdentifier(k, dialect)).join(', ');
|
|
364
|
+
// Single row or multi-row placeholders
|
|
365
|
+
const rowPlaceholders = `(${keys.map(() => '?').join(', ')})`;
|
|
366
|
+
const placeholders = items.map(() => rowPlaceholders).join(', ');
|
|
367
|
+
const parameters = [];
|
|
368
|
+
for (const item of items) {
|
|
369
|
+
for (const key of keys) {
|
|
370
|
+
parameters.push(item[key]);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
const sql = `INSERT INTO ${escapeIdentifier(tableName, dialect)} (${colsSql}) VALUES ${placeholders}`;
|
|
374
|
+
return { sql, parameters };
|
|
375
|
+
};
|
|
376
|
+
const compileUpdate = (tableName, values, conditions, dialect) => {
|
|
377
|
+
const keys = Object.keys(values);
|
|
378
|
+
if (keys.length === 0) {
|
|
379
|
+
throw ErrorFactory.createDatabaseError('UPDATE requires at least one column');
|
|
380
|
+
}
|
|
381
|
+
if (conditions.length === 0) {
|
|
382
|
+
throw ErrorFactory.createDatabaseError('UPDATE requires at least one WHERE clause');
|
|
383
|
+
}
|
|
384
|
+
assertSafeIdentifierPath(tableName, 'table name');
|
|
385
|
+
for (const key of keys)
|
|
386
|
+
assertSafeIdentifier(key, 'update column');
|
|
387
|
+
const setSql = keys.map((k) => `${escapeIdentifier(k, dialect)} = ?`).join(', ');
|
|
388
|
+
const setParams = keys.map((k) => values[k]);
|
|
389
|
+
const where = compileWhere(conditions, dialect);
|
|
390
|
+
const sql = `UPDATE ${escapeIdentifier(tableName, dialect)} SET ${setSql}${where.sql}`;
|
|
391
|
+
return { sql, parameters: [...setParams, ...where.parameters] };
|
|
392
|
+
};
|
|
393
|
+
const compileDelete = (tableName, conditions, dialect) => {
|
|
394
|
+
if (conditions.length === 0) {
|
|
395
|
+
throw ErrorFactory.createDatabaseError('DELETE requires at least one WHERE clause');
|
|
396
|
+
}
|
|
397
|
+
assertSafeIdentifierPath(tableName, 'table name');
|
|
398
|
+
const where = compileWhere(conditions, dialect);
|
|
399
|
+
const sql = `DELETE FROM ${escapeIdentifier(tableName, dialect)}${where.sql}`;
|
|
400
|
+
return { sql, parameters: where.parameters };
|
|
401
|
+
};
|
|
402
|
+
/**
|
|
403
|
+
* Execute query and return all results
|
|
404
|
+
*/
|
|
405
|
+
async function executeGet(builder, db) {
|
|
406
|
+
if (!db)
|
|
407
|
+
throw ErrorFactory.createDatabaseError('Database instance not provided to QueryBuilder');
|
|
408
|
+
return (await db.query(builder.toSQL(), builder.getParameters(), builder.isReadOperation()));
|
|
409
|
+
}
|
|
410
|
+
const normalizePaginationValue = (value, label) => {
|
|
411
|
+
const n = Math.trunc(value);
|
|
412
|
+
if (!Number.isFinite(n) || n <= 0) {
|
|
413
|
+
throw ErrorFactory.createValidationError(`${label} must be a positive integer`);
|
|
414
|
+
}
|
|
415
|
+
return n;
|
|
416
|
+
};
|
|
417
|
+
async function executePaginate(builder, state, db, page, perPage, options) {
|
|
418
|
+
if (!db)
|
|
419
|
+
throw ErrorFactory.createDatabaseError('Database instance not provided to QueryBuilder');
|
|
420
|
+
const safePage = normalizePaginationValue(page, 'page');
|
|
421
|
+
const safePerPage = normalizePaginationValue(perPage, 'perPage');
|
|
422
|
+
const countQuery = buildCountQuery(state);
|
|
423
|
+
const countRows = (await db.query(countQuery.sql, countQuery.parameters, true));
|
|
424
|
+
const rawTotal = countRows.at(0)?.['total'];
|
|
425
|
+
const total = typeof rawTotal === 'bigint' ? Number(rawTotal) : Number(rawTotal ?? 0);
|
|
426
|
+
const sanitizedTotal = Number.isFinite(total) && total > 0 ? total : 0;
|
|
427
|
+
const offset = (safePage - 1) * safePerPage;
|
|
428
|
+
const prevLimit = state.limitValue;
|
|
429
|
+
const prevOffset = state.offsetValue;
|
|
430
|
+
state.limitValue = safePerPage;
|
|
431
|
+
state.offsetValue = offset;
|
|
432
|
+
const items = await executeGet(builder, db);
|
|
433
|
+
state.limitValue = prevLimit;
|
|
434
|
+
state.offsetValue = prevOffset;
|
|
435
|
+
return createPaginator({
|
|
436
|
+
items,
|
|
437
|
+
total: sanitizedTotal,
|
|
438
|
+
perPage: safePerPage,
|
|
439
|
+
currentPage: safePage,
|
|
440
|
+
baseUrl: options?.baseUrl,
|
|
441
|
+
query: options?.query,
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Create the builder object
|
|
446
|
+
*/
|
|
447
|
+
function attachSelectMethods(builder, state) {
|
|
448
|
+
const clearDefaultStar = () => {
|
|
449
|
+
if (state.selectColumns.length === 1 && state.selectColumns[0] === '*')
|
|
450
|
+
state.selectColumns = [];
|
|
451
|
+
};
|
|
452
|
+
builder.select = (...columns) => {
|
|
453
|
+
state.selectColumns = columns.length > 0 ? columns : ['*'];
|
|
454
|
+
return builder;
|
|
455
|
+
};
|
|
456
|
+
builder.selectAs = (column, alias) => {
|
|
457
|
+
const col = String(column).trim();
|
|
458
|
+
const a = String(alias).trim();
|
|
459
|
+
assertSafeIdentifierPath(col, 'select column');
|
|
460
|
+
assertSafeIdentifier(a, 'select alias');
|
|
461
|
+
clearDefaultStar();
|
|
462
|
+
state.selectColumns.push(`${col} AS ${a}`);
|
|
463
|
+
return builder;
|
|
464
|
+
};
|
|
465
|
+
builder.max = (column, alias = 'max') => {
|
|
466
|
+
const col = String(column).trim();
|
|
467
|
+
const a = String(alias).trim();
|
|
468
|
+
assertSafeIdentifierPath(col, 'aggregate argument');
|
|
469
|
+
assertSafeIdentifier(a, 'aggregate alias');
|
|
470
|
+
clearDefaultStar();
|
|
471
|
+
state.selectColumns.push(`MAX(${col}) AS ${a}`);
|
|
472
|
+
return builder;
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
function attachWhereMethods(builder, state) {
|
|
476
|
+
builder.where = (column, operator, value) => {
|
|
477
|
+
applyWhereCondition(state, column, operator, value);
|
|
478
|
+
return builder;
|
|
479
|
+
};
|
|
480
|
+
builder.andWhere = (column, operator, value) => builder.where(column, operator, value);
|
|
481
|
+
builder.orWhere = (column, operator, value) => builder.where(column, operator, value);
|
|
482
|
+
builder.whereIn = (column, values) => {
|
|
483
|
+
builder.where(column, 'IN', values);
|
|
484
|
+
return builder;
|
|
485
|
+
};
|
|
486
|
+
builder.whereNotIn = (column, values) => {
|
|
487
|
+
builder.where(column, 'NOT IN', values);
|
|
488
|
+
return builder;
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
function attachSoftDeleteMethods(builder, state) {
|
|
492
|
+
builder.withTrashed = () => {
|
|
493
|
+
if (state.softDelete === undefined) {
|
|
494
|
+
state.softDelete = { column: 'deleted_at', mode: 'include' };
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
state.softDelete.mode = 'include';
|
|
498
|
+
}
|
|
499
|
+
return builder;
|
|
500
|
+
};
|
|
501
|
+
builder.onlyTrashed = () => {
|
|
502
|
+
if (state.softDelete === undefined) {
|
|
503
|
+
state.softDelete = { column: 'deleted_at', mode: 'only' };
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
state.softDelete.mode = 'only';
|
|
507
|
+
}
|
|
508
|
+
return builder;
|
|
509
|
+
};
|
|
510
|
+
builder.withoutTrashed = () => {
|
|
511
|
+
if (state.softDelete === undefined) {
|
|
512
|
+
state.softDelete = { column: 'deleted_at', mode: 'exclude' };
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
515
|
+
state.softDelete.mode = 'exclude';
|
|
516
|
+
}
|
|
517
|
+
return builder;
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
function attachJoinOrderPagingMethods(builder, state) {
|
|
521
|
+
builder.join = (tableJoin, on) => {
|
|
522
|
+
state.joins.push({ table: tableJoin, on });
|
|
523
|
+
return builder;
|
|
524
|
+
};
|
|
525
|
+
builder.leftJoin = (tableJoin, on) => builder.join(tableJoin, on);
|
|
526
|
+
builder.orderBy = (column, direction = 'ASC') => {
|
|
527
|
+
applyOrderByClause(state, column, direction);
|
|
528
|
+
return builder;
|
|
529
|
+
};
|
|
530
|
+
builder.limit = (count) => {
|
|
531
|
+
applyLimit(state, count);
|
|
532
|
+
return builder;
|
|
533
|
+
};
|
|
534
|
+
builder.offset = (count) => {
|
|
535
|
+
applyOffset(state, count);
|
|
536
|
+
return builder;
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
function attachIntrospectionMethods(builder, state) {
|
|
540
|
+
builder.getWhereClauses = () => state.whereConditions;
|
|
541
|
+
builder.getSelectColumns = () => state.selectColumns;
|
|
542
|
+
builder.getTable = () => state.tableName;
|
|
543
|
+
builder.getLimit = () => state.limitValue;
|
|
544
|
+
builder.getOffset = () => state.offsetValue;
|
|
545
|
+
builder.getOrderBy = () => state.orderByClauses.at(-1);
|
|
546
|
+
builder.getJoins = () => state.joins;
|
|
547
|
+
builder.isReadOperation = () => true;
|
|
548
|
+
builder.toSQL = () => buildSelectQuery(state).sql;
|
|
549
|
+
builder.getParameters = () => buildSelectQuery(state).parameters;
|
|
550
|
+
// Internal method for eager loading distribution
|
|
551
|
+
builder.getEagerLoads = () => state.eagerLoads;
|
|
552
|
+
builder.getEagerLoadConstraints = () => state.eagerLoadConstraints;
|
|
553
|
+
builder.getEagerLoadCounts = () => state.eagerLoadCounts;
|
|
554
|
+
}
|
|
555
|
+
function attachReadExecutionMethods(builder, state, db) {
|
|
556
|
+
builder.first = async () => executeFirst(builder, db);
|
|
557
|
+
builder.firstOrFail = async (message) => executeFirstOrFail(builder, db, message);
|
|
558
|
+
builder.get = async () => executeGet(builder, db);
|
|
559
|
+
builder.paginate = async (page, perPage, options) => executePaginate(builder, state, db, page, perPage, options);
|
|
560
|
+
// raw just returns results without any hydration logic in callers
|
|
561
|
+
builder.raw = async () => executeGet(builder, db);
|
|
562
|
+
}
|
|
563
|
+
const isNonEmptyString = (value) => typeof value === 'string' && value.length > 0;
|
|
564
|
+
const isKeyValue = (value) => typeof value === 'string' || typeof value === 'number';
|
|
565
|
+
const getModelIds = (models, key) => models.map((model) => model.getAttribute(key)).filter(isKeyValue);
|
|
566
|
+
const applyConstraint = (query, constraint) => {
|
|
567
|
+
if (typeof constraint === 'function') {
|
|
568
|
+
return constraint(query) ?? query;
|
|
569
|
+
}
|
|
570
|
+
return query;
|
|
571
|
+
};
|
|
572
|
+
/**
|
|
573
|
+
* Load relationship counts for a collection of models
|
|
574
|
+
*/
|
|
575
|
+
async function loadCounts(models, relation, db) {
|
|
576
|
+
if (models.length === 0 || !db)
|
|
577
|
+
return;
|
|
578
|
+
const firstModel = models[0];
|
|
579
|
+
if (typeof firstModel[relation] !== 'function')
|
|
580
|
+
return;
|
|
581
|
+
const rel = firstModel[relation]();
|
|
582
|
+
if (rel === null || rel === undefined)
|
|
583
|
+
return;
|
|
584
|
+
const relType = rel.type;
|
|
585
|
+
// Only hasMany and belongsToMany support counts
|
|
586
|
+
if (relType !== 'hasMany' && relType !== 'belongsToMany') {
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
const foreignKey = rel.foreignKey;
|
|
590
|
+
const localKey = rel.localKey;
|
|
591
|
+
const ids = getModelIds(models, localKey);
|
|
592
|
+
if (ids.length === 0)
|
|
593
|
+
return;
|
|
594
|
+
const dialect = typeof db.getType === 'function' ? db.getType() : undefined;
|
|
595
|
+
const queryCounts = async (sql, params) => {
|
|
596
|
+
const results = (await db.query(sql, params, true));
|
|
597
|
+
const map = new Map();
|
|
598
|
+
for (const row of results) {
|
|
599
|
+
let count;
|
|
600
|
+
if (typeof row.count === 'bigint') {
|
|
601
|
+
count = Number(row.count);
|
|
602
|
+
}
|
|
603
|
+
else if (typeof row.count === 'number') {
|
|
604
|
+
count = row.count;
|
|
605
|
+
}
|
|
606
|
+
else {
|
|
607
|
+
count = Number(row.count ?? 0);
|
|
608
|
+
}
|
|
609
|
+
map.set(row.key, count);
|
|
610
|
+
}
|
|
611
|
+
return map;
|
|
612
|
+
};
|
|
613
|
+
const setCountsOnModels = (countMap) => {
|
|
614
|
+
for (const model of models) {
|
|
615
|
+
const modelId = model.getAttribute(localKey);
|
|
616
|
+
if (isKeyValue(modelId)) {
|
|
617
|
+
const count = countMap.get(modelId) ?? 0;
|
|
618
|
+
model.setAttribute(`${relation}_count`, count);
|
|
619
|
+
}
|
|
620
|
+
else {
|
|
621
|
+
model.setAttribute(`${relation}_count`, 0);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
if (relType === 'hasMany') {
|
|
626
|
+
const relatedModel = rel.related;
|
|
627
|
+
if (typeof relatedModel?.query !== 'function')
|
|
628
|
+
return;
|
|
629
|
+
const tempQuery = relatedModel.query();
|
|
630
|
+
const relatedTable = tempQuery.getTable();
|
|
631
|
+
const sql = `SELECT ${escapeIdentifier(foreignKey, dialect)} as key, COUNT(*) as count FROM ${escapeIdentifier(relatedTable, dialect)} WHERE ${escapeIdentifier(foreignKey, dialect)} IN (${ids.map(() => '?').join(',')}) GROUP BY ${escapeIdentifier(foreignKey, dialect)}`;
|
|
632
|
+
const countMap = await queryCounts(sql, ids);
|
|
633
|
+
setCountsOnModels(countMap);
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
// belongsToMany
|
|
637
|
+
const throughTable = rel.throughTable;
|
|
638
|
+
const relatedKey = rel.relatedKey;
|
|
639
|
+
if (!isNonEmptyString(throughTable) || !isNonEmptyString(relatedKey))
|
|
640
|
+
return;
|
|
641
|
+
const sql = `SELECT ${escapeIdentifier(foreignKey, dialect)} as key, COUNT(*) as count FROM ${escapeIdentifier(throughTable, dialect)} WHERE ${escapeIdentifier(foreignKey, dialect)} IN (${ids.map(() => '?').join(',')}) GROUP BY ${escapeIdentifier(foreignKey, dialect)}`;
|
|
642
|
+
const countMap = await queryCounts(sql, ids);
|
|
643
|
+
setCountsOnModels(countMap);
|
|
644
|
+
}
|
|
645
|
+
const getRelationFromModels = (models, relation) => {
|
|
646
|
+
const firstModel = models[0];
|
|
647
|
+
const relationFactory = firstModel?.[relation];
|
|
648
|
+
if (typeof relationFactory !== 'function')
|
|
649
|
+
return null;
|
|
650
|
+
const rel = relationFactory();
|
|
651
|
+
return rel ?? null;
|
|
652
|
+
};
|
|
653
|
+
const assignMorphToGroup = (modelsByType, type, model) => {
|
|
654
|
+
const existing = modelsByType.get(type);
|
|
655
|
+
if (existing) {
|
|
656
|
+
existing.push(model);
|
|
657
|
+
}
|
|
658
|
+
else {
|
|
659
|
+
modelsByType.set(type, [model]);
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
const getModelTable = (model) => {
|
|
663
|
+
const tableGetter = model.getTable;
|
|
664
|
+
if (typeof tableGetter !== 'function')
|
|
665
|
+
return null;
|
|
666
|
+
const table = tableGetter();
|
|
667
|
+
return isNonEmptyString(table) ? table : null;
|
|
668
|
+
};
|
|
669
|
+
const buildSingleMap = (results, key) => {
|
|
670
|
+
const map = new Map();
|
|
671
|
+
for (const result of results) {
|
|
672
|
+
const resultId = result.getAttribute(key);
|
|
673
|
+
if (isKeyValue(resultId)) {
|
|
674
|
+
map.set(resultId, result);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
return map;
|
|
678
|
+
};
|
|
679
|
+
const buildBucketMap = (results, key) => {
|
|
680
|
+
const buckets = new Map();
|
|
681
|
+
for (const result of results) {
|
|
682
|
+
const resultId = result.getAttribute(key);
|
|
683
|
+
if (isKeyValue(resultId)) {
|
|
684
|
+
const existing = buckets.get(resultId) ?? [];
|
|
685
|
+
existing.push(result);
|
|
686
|
+
buckets.set(resultId, existing);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
return buckets;
|
|
690
|
+
};
|
|
691
|
+
const setRelationsFromBuckets = (models, relation, localKey, buckets, isMany) => {
|
|
692
|
+
for (const model of models) {
|
|
693
|
+
const modelId = model.getAttribute(localKey);
|
|
694
|
+
if (!isKeyValue(modelId)) {
|
|
695
|
+
model.setRelation(relation, isMany ? [] : null);
|
|
696
|
+
continue;
|
|
697
|
+
}
|
|
698
|
+
const bucket = buckets.get(modelId) ?? [];
|
|
699
|
+
if (isMany) {
|
|
700
|
+
model.setRelation(relation, bucket);
|
|
701
|
+
}
|
|
702
|
+
else {
|
|
703
|
+
model.setRelation(relation, bucket[0] ?? null);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
const buildParentToThroughIds = (throughResults, throughForeignKey, secondLocalKey) => {
|
|
708
|
+
const parentToThroughIds = new Map();
|
|
709
|
+
for (const throughItem of throughResults) {
|
|
710
|
+
const parentId = throughItem.getAttribute(throughForeignKey);
|
|
711
|
+
const throughId = throughItem.getAttribute(secondLocalKey);
|
|
712
|
+
if (isKeyValue(parentId) && isKeyValue(throughId)) {
|
|
713
|
+
const existing = parentToThroughIds.get(parentId) ?? [];
|
|
714
|
+
existing.push(throughId);
|
|
715
|
+
parentToThroughIds.set(parentId, existing);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
return parentToThroughIds;
|
|
719
|
+
};
|
|
720
|
+
const collectThroughRelated = (throughIds, relatedBuckets) => {
|
|
721
|
+
const aggregated = [];
|
|
722
|
+
for (const throughId of throughIds) {
|
|
723
|
+
const bucket = relatedBuckets.get(throughId);
|
|
724
|
+
if (bucket !== undefined) {
|
|
725
|
+
aggregated.push(...bucket);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
return aggregated;
|
|
729
|
+
};
|
|
730
|
+
const setThroughRelations = (models, relation, localKey, parentToThroughIds, relatedBuckets, isMany) => {
|
|
731
|
+
for (const model of models) {
|
|
732
|
+
const modelId = model.getAttribute(localKey);
|
|
733
|
+
if (!isKeyValue(modelId)) {
|
|
734
|
+
model.setRelation(relation, isMany ? [] : null);
|
|
735
|
+
continue;
|
|
736
|
+
}
|
|
737
|
+
const throughIds = parentToThroughIds.get(modelId) ?? [];
|
|
738
|
+
if (throughIds.length === 0) {
|
|
739
|
+
model.setRelation(relation, isMany ? [] : null);
|
|
740
|
+
continue;
|
|
741
|
+
}
|
|
742
|
+
const aggregated = collectThroughRelated(throughIds, relatedBuckets);
|
|
743
|
+
if (isMany) {
|
|
744
|
+
model.setRelation(relation, aggregated);
|
|
745
|
+
}
|
|
746
|
+
else {
|
|
747
|
+
model.setRelation(relation, aggregated[0] ?? null);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
const buildMorphToGroups = (models, morphType) => {
|
|
752
|
+
const modelsByType = new Map();
|
|
753
|
+
for (const model of models) {
|
|
754
|
+
const type = model.getAttribute(morphType);
|
|
755
|
+
if (isNonEmptyString(type)) {
|
|
756
|
+
assignMorphToGroup(modelsByType, type, model);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
return modelsByType;
|
|
760
|
+
};
|
|
761
|
+
const setMorphToRelations = (models, relation, morphId, relatedMap) => {
|
|
762
|
+
for (const model of models) {
|
|
763
|
+
const modelId = model.getAttribute(morphId);
|
|
764
|
+
if (isKeyValue(modelId)) {
|
|
765
|
+
model.setRelation(relation, relatedMap.get(modelId) ?? null);
|
|
766
|
+
}
|
|
767
|
+
else {
|
|
768
|
+
model.setRelation(relation, null);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
const loadMorphToGroup = async (relation, morphId, modelsOfType, relatedModel, constraint) => {
|
|
773
|
+
const ids = getModelIds(modelsOfType, morphId);
|
|
774
|
+
if (ids.length === 0)
|
|
775
|
+
return;
|
|
776
|
+
const relatedQuery = applyConstraint(relatedModel.query(), constraint);
|
|
777
|
+
const relatedResults = await relatedQuery.whereIn('id', ids).get();
|
|
778
|
+
const relatedMap = buildSingleMap(relatedResults, 'id');
|
|
779
|
+
setMorphToRelations(modelsOfType, relation, morphId, relatedMap);
|
|
780
|
+
};
|
|
781
|
+
const loadMorphToRelation = async (models, relation, rel, constraint) => {
|
|
782
|
+
if (rel.type !== 'morphTo')
|
|
783
|
+
return false;
|
|
784
|
+
const morphType = rel.morphType;
|
|
785
|
+
const morphId = rel.morphId;
|
|
786
|
+
const morphMap = rel.morphMap;
|
|
787
|
+
if (!isNonEmptyString(morphType) ||
|
|
788
|
+
!isNonEmptyString(morphId) ||
|
|
789
|
+
morphMap === null ||
|
|
790
|
+
morphMap === undefined) {
|
|
791
|
+
return true;
|
|
792
|
+
}
|
|
793
|
+
const modelsByType = buildMorphToGroups(models, morphType);
|
|
794
|
+
const tasks = [...modelsByType.entries()].map(async ([type, modelsOfType]) => {
|
|
795
|
+
const relatedModel = morphMap[type];
|
|
796
|
+
if (relatedModel === undefined || typeof relatedModel.query !== 'function') {
|
|
797
|
+
return Promise.resolve(); //NOSONAR
|
|
798
|
+
}
|
|
799
|
+
return loadMorphToGroup(relation, morphId, modelsOfType, relatedModel, constraint);
|
|
800
|
+
});
|
|
801
|
+
await Promise.all(tasks);
|
|
802
|
+
return true;
|
|
803
|
+
};
|
|
804
|
+
const prepareMorphOneMany = (models, rel, localKey, morphId, morphType) => {
|
|
805
|
+
if (!isNonEmptyString(morphType) || !isNonEmptyString(morphId) || !isNonEmptyString(localKey)) {
|
|
806
|
+
return { proceed: false };
|
|
807
|
+
}
|
|
808
|
+
const ids = getModelIds(models, localKey);
|
|
809
|
+
if (ids.length === 0)
|
|
810
|
+
return { proceed: false };
|
|
811
|
+
const relatedModel = rel.related;
|
|
812
|
+
if (typeof relatedModel.query !== 'function')
|
|
813
|
+
return { proceed: false };
|
|
814
|
+
const tableName = getModelTable(models[0]);
|
|
815
|
+
if (tableName === null)
|
|
816
|
+
return { proceed: false };
|
|
817
|
+
return { proceed: true, ids, relatedModel, tableName };
|
|
818
|
+
};
|
|
819
|
+
const loadMorphOneManyRelation = async (models, relation, rel, constraint) => {
|
|
820
|
+
if (rel.type !== 'morphOne' && rel.type !== 'morphMany')
|
|
821
|
+
return false;
|
|
822
|
+
const morphType = rel.morphType;
|
|
823
|
+
const morphId = rel.morphId;
|
|
824
|
+
const localKey = rel.localKey;
|
|
825
|
+
const prep = prepareMorphOneMany(models, rel, localKey, morphId, morphType);
|
|
826
|
+
if (!prep.proceed ||
|
|
827
|
+
prep.ids === undefined ||
|
|
828
|
+
prep.relatedModel === undefined ||
|
|
829
|
+
prep.tableName === undefined ||
|
|
830
|
+
!isNonEmptyString(morphType) ||
|
|
831
|
+
!isNonEmptyString(morphId) ||
|
|
832
|
+
!isNonEmptyString(localKey)) {
|
|
833
|
+
return true;
|
|
834
|
+
}
|
|
835
|
+
const ids = prep.ids;
|
|
836
|
+
const relatedModel = prep.relatedModel;
|
|
837
|
+
const tableName = prep.tableName;
|
|
838
|
+
const relatedQuery = applyConstraint(relatedModel.query(), constraint)
|
|
839
|
+
.where(morphType, '=', tableName)
|
|
840
|
+
.whereIn(morphId, ids);
|
|
841
|
+
const relatedResults = await relatedQuery.get();
|
|
842
|
+
const relatedBuckets = buildBucketMap(relatedResults, morphId);
|
|
843
|
+
const isMany = rel.type === 'morphMany';
|
|
844
|
+
setRelationsFromBuckets(models, relation, localKey, relatedBuckets, isMany);
|
|
845
|
+
return true;
|
|
846
|
+
};
|
|
847
|
+
const loadThroughRelation = async (models, relation, rel, constraint) => {
|
|
848
|
+
if (rel.type !== 'hasOneThrough' && rel.type !== 'hasManyThrough')
|
|
849
|
+
return false;
|
|
850
|
+
const through = rel.through;
|
|
851
|
+
const throughForeignKey = rel.throughForeignKey;
|
|
852
|
+
const secondLocalKey = rel.secondLocalKey;
|
|
853
|
+
const foreignKey = rel.foreignKey;
|
|
854
|
+
const localKey = rel.localKey;
|
|
855
|
+
if (through === undefined ||
|
|
856
|
+
through === null ||
|
|
857
|
+
!isNonEmptyString(throughForeignKey) ||
|
|
858
|
+
!isNonEmptyString(secondLocalKey) ||
|
|
859
|
+
!isNonEmptyString(foreignKey) ||
|
|
860
|
+
!isNonEmptyString(localKey)) {
|
|
861
|
+
return true;
|
|
862
|
+
}
|
|
863
|
+
const ids = getModelIds(models, localKey);
|
|
864
|
+
if (ids.length === 0)
|
|
865
|
+
return true;
|
|
866
|
+
const throughModel = through;
|
|
867
|
+
const relatedModel = rel.related;
|
|
868
|
+
if (typeof throughModel.getTable !== 'function' ||
|
|
869
|
+
typeof relatedModel.query !== 'function' ||
|
|
870
|
+
typeof relatedModel.getTable !== 'function') {
|
|
871
|
+
return true;
|
|
872
|
+
}
|
|
873
|
+
const throughTable = throughModel.getTable();
|
|
874
|
+
const relatedTable = relatedModel.getTable();
|
|
875
|
+
if (!isNonEmptyString(throughTable) || !isNonEmptyString(relatedTable))
|
|
876
|
+
return true;
|
|
877
|
+
let relatedQuery = relatedModel.query();
|
|
878
|
+
relatedQuery = applyConstraint(relatedQuery, constraint);
|
|
879
|
+
relatedQuery = relatedQuery
|
|
880
|
+
.join(throughTable, `${relatedTable}.${foreignKey} = ${throughTable}.${secondLocalKey}`)
|
|
881
|
+
.whereIn(`${throughTable}.${throughForeignKey}`, ids);
|
|
882
|
+
const relatedResults = await relatedQuery.get();
|
|
883
|
+
const throughQuery = throughModel.query().whereIn(throughForeignKey, ids);
|
|
884
|
+
const throughResults = await throughQuery.get();
|
|
885
|
+
const parentToThroughIds = buildParentToThroughIds(throughResults, throughForeignKey, secondLocalKey);
|
|
886
|
+
const relatedBuckets = buildBucketMap(relatedResults, foreignKey);
|
|
887
|
+
const isMany = rel.type === 'hasManyThrough';
|
|
888
|
+
setThroughRelations(models, relation, localKey, parentToThroughIds, relatedBuckets, isMany);
|
|
889
|
+
return true;
|
|
890
|
+
};
|
|
891
|
+
const loadStandardRelation = async (models, relation, rel, constraint) => {
|
|
892
|
+
const related = rel.related;
|
|
893
|
+
if (related === null || related === undefined)
|
|
894
|
+
return false;
|
|
895
|
+
const foreignKey = rel.foreignKey;
|
|
896
|
+
const localKey = rel.localKey;
|
|
897
|
+
if (!isNonEmptyString(foreignKey) || !isNonEmptyString(localKey))
|
|
898
|
+
return false;
|
|
899
|
+
const ids = getModelIds(models, localKey);
|
|
900
|
+
if (ids.length === 0)
|
|
901
|
+
return true;
|
|
902
|
+
const relatedModel = rel.related;
|
|
903
|
+
if (typeof relatedModel.query !== 'function')
|
|
904
|
+
return false;
|
|
905
|
+
const relatedQuery = applyConstraint(relatedModel.query(), constraint);
|
|
906
|
+
const relatedResults = await relatedQuery.whereIn(foreignKey, ids).get();
|
|
907
|
+
const relatedBuckets = buildBucketMap(relatedResults, foreignKey);
|
|
908
|
+
const isMany = rel.type === 'hasMany' || rel.type === 'belongsToMany';
|
|
909
|
+
setRelationsFromBuckets(models, relation, localKey, relatedBuckets, isMany);
|
|
910
|
+
return true;
|
|
911
|
+
};
|
|
912
|
+
const loadRelation = async (models, relation, constraint) => {
|
|
913
|
+
if (models.length === 0)
|
|
914
|
+
return;
|
|
915
|
+
const rel = getRelationFromModels(models, relation);
|
|
916
|
+
if (!rel)
|
|
917
|
+
return;
|
|
918
|
+
const type = rel.type;
|
|
919
|
+
if (type === 'morphTo') {
|
|
920
|
+
await loadMorphToRelation(models, relation, rel, constraint);
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
if (type === 'morphOne' || type === 'morphMany') {
|
|
924
|
+
await loadMorphOneManyRelation(models, relation, rel, constraint);
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
if (type === 'hasOneThrough' || type === 'hasManyThrough') {
|
|
928
|
+
await loadThroughRelation(models, relation, rel, constraint);
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
await loadStandardRelation(models, relation, rel, constraint);
|
|
932
|
+
};
|
|
933
|
+
function attachRelationshipMethods(builder, state, db) {
|
|
934
|
+
builder.with = (relation) => {
|
|
935
|
+
if (typeof relation === 'string') {
|
|
936
|
+
state.eagerLoads.push(relation);
|
|
937
|
+
return builder;
|
|
938
|
+
}
|
|
939
|
+
for (const [name, constraint] of Object.entries(relation)) {
|
|
940
|
+
if (state.eagerLoads.includes(name) === false) {
|
|
941
|
+
state.eagerLoads.push(name);
|
|
942
|
+
}
|
|
943
|
+
state.eagerLoadConstraints[name] = constraint;
|
|
944
|
+
}
|
|
945
|
+
return builder;
|
|
946
|
+
};
|
|
947
|
+
builder.withCount = (relation) => {
|
|
948
|
+
state.eagerLoadCounts.push(relation);
|
|
949
|
+
return builder;
|
|
950
|
+
};
|
|
951
|
+
builder.load = async (models, relation, constraint) => {
|
|
952
|
+
await loadRelation(models, relation, constraint);
|
|
953
|
+
};
|
|
954
|
+
builder.loadCount = async (models, relation) => {
|
|
955
|
+
await loadCounts(models, relation, db);
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
function attachWriteMethods(builder, state, db) {
|
|
959
|
+
const ensureDb = () => {
|
|
960
|
+
if (!db)
|
|
961
|
+
throw ErrorFactory.createDatabaseError('Database instance not provided to QueryBuilder');
|
|
962
|
+
return db;
|
|
963
|
+
};
|
|
964
|
+
builder.insert = async (values) => {
|
|
965
|
+
const currentDb = ensureDb();
|
|
966
|
+
const tableName = state.tableName.trim();
|
|
967
|
+
if (tableName.length === 0)
|
|
968
|
+
throw ErrorFactory.createDatabaseError('INSERT requires a table name');
|
|
969
|
+
const compiled = compileInsert(tableName, values, state.dialect);
|
|
970
|
+
const items = Array.isArray(values) ? values : [values];
|
|
971
|
+
const result = await currentDb.execute(compiled.sql, compiled.parameters, false);
|
|
972
|
+
// Return InsertResult with metadata
|
|
973
|
+
// Note: lastInsertId typically only available for single-row inserts in most databases
|
|
974
|
+
// For multi-row inserts, use the insertedRecords array
|
|
975
|
+
return {
|
|
976
|
+
id: result.lastInsertId ??
|
|
977
|
+
(items.length === 1 ? (items[0]?.['id'] ?? null) : null),
|
|
978
|
+
affectedRows: result.rowCount,
|
|
979
|
+
insertedRecords: items,
|
|
980
|
+
};
|
|
981
|
+
};
|
|
982
|
+
builder.update = async (values) => {
|
|
983
|
+
const currentDb = ensureDb();
|
|
984
|
+
const tableName = state.tableName.trim();
|
|
985
|
+
if (tableName.length === 0)
|
|
986
|
+
throw ErrorFactory.createDatabaseError('UPDATE requires a table name');
|
|
987
|
+
const compiled = compileUpdate(tableName, values, state.whereConditions, state.dialect);
|
|
988
|
+
await currentDb.query(compiled.sql, compiled.parameters, false);
|
|
989
|
+
};
|
|
990
|
+
builder.delete = async () => {
|
|
991
|
+
const currentDb = ensureDb();
|
|
992
|
+
const tableName = state.tableName.trim();
|
|
993
|
+
if (tableName.length === 0)
|
|
994
|
+
throw ErrorFactory.createDatabaseError('DELETE requires a table name');
|
|
995
|
+
const compiled = compileDelete(tableName, state.whereConditions, state.dialect);
|
|
996
|
+
await currentDb.query(compiled.sql, compiled.parameters, false);
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
function createBuilder(state, db) {
|
|
1000
|
+
const builder = {};
|
|
1001
|
+
attachSelectMethods(builder, state);
|
|
1002
|
+
attachWhereMethods(builder, state);
|
|
1003
|
+
attachSoftDeleteMethods(builder, state);
|
|
1004
|
+
attachJoinOrderPagingMethods(builder, state);
|
|
1005
|
+
attachIntrospectionMethods(builder, state);
|
|
1006
|
+
attachReadExecutionMethods(builder, state, db);
|
|
1007
|
+
attachRelationshipMethods(builder, state, db);
|
|
1008
|
+
attachWriteMethods(builder, state, db);
|
|
1009
|
+
return builder;
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* QueryBuilder - Type-Safe Query Builder
|
|
1013
|
+
* Sealed namespace object following Pattern 2
|
|
1014
|
+
*
|
|
1015
|
+
* @see FRAMEWORK_REFACTOR_FUNCTION_PATTERN.md for Pattern 2 details
|
|
1016
|
+
*/
|
|
1017
|
+
export const QueryBuilder = Object.freeze({
|
|
1018
|
+
/**
|
|
1019
|
+
* Create a new query builder instance
|
|
1020
|
+
*/
|
|
1021
|
+
create(tableOrDb, db, options = {}) {
|
|
1022
|
+
const hasTable = typeof tableOrDb === 'string';
|
|
1023
|
+
const tableName = hasTable ? String(tableOrDb).trim() : '';
|
|
1024
|
+
const database = hasTable ? db : tableOrDb;
|
|
1025
|
+
if (tableName.length > 0) {
|
|
1026
|
+
assertSafeIdentifierPath(tableName, 'table name');
|
|
1027
|
+
}
|
|
1028
|
+
const state = {
|
|
1029
|
+
tableName,
|
|
1030
|
+
whereConditions: [],
|
|
1031
|
+
selectColumns: ['*'],
|
|
1032
|
+
orderByClauses: [],
|
|
1033
|
+
joins: [],
|
|
1034
|
+
eagerLoads: [],
|
|
1035
|
+
eagerLoadConstraints: {},
|
|
1036
|
+
eagerLoadCounts: [],
|
|
1037
|
+
dialect: typeof database?.getType === 'function' ? database.getType() : undefined,
|
|
1038
|
+
};
|
|
1039
|
+
if (options.softDeleteColumn !== undefined && options.softDeleteColumn.trim().length > 0) {
|
|
1040
|
+
state.softDelete = {
|
|
1041
|
+
column: options.softDeleteColumn.trim(),
|
|
1042
|
+
mode: options.softDeleteMode ?? 'exclude',
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
return createBuilder(state, database);
|
|
1046
|
+
},
|
|
1047
|
+
/**
|
|
1048
|
+
* Ping the database connection.
|
|
1049
|
+
*
|
|
1050
|
+
* This is intentionally a tiny, dependency-free check that can be reused by
|
|
1051
|
+
* health/readiness endpoints without embedding SQL in route handlers.
|
|
1052
|
+
*/
|
|
1053
|
+
async ping(db) {
|
|
1054
|
+
// Use the QueryBuilder itself to avoid embedding raw SQL at call sites.
|
|
1055
|
+
await QueryBuilder.create('', db).select('1').get();
|
|
1056
|
+
},
|
|
1057
|
+
});
|