@zintrust/core 0.1.1 → 0.1.3
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 +3 -3
- package/bin/zintrust.d.ts.map +1 -1
- package/bin/zintrust.js +18 -1
- package/package.json +15 -1
- package/src/boot/Application.d.ts.map +1 -1
- package/src/boot/Application.js +46 -3
- package/src/boot/Server.d.ts.map +1 -1
- package/src/boot/Server.js +3 -4
- package/src/boot/bootstrap.js +77 -6
- package/src/builder/BundleOptimizer.d.ts.map +1 -1
- package/src/builder/BundleOptimizer.js +6 -4
- package/src/cache/drivers/KVDriver.d.ts.map +1 -1
- package/src/cache/drivers/KVDriver.js +6 -6
- package/src/cache/drivers/RedisDriver.js +1 -1
- package/src/cli/BaseCommand.d.ts +2 -2
- package/src/cli/BaseCommand.d.ts.map +1 -1
- package/src/cli/BaseCommand.js +2 -1
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +11 -4
- package/src/cli/commands/AddCommand.js +1 -1
- package/src/cli/commands/ConfigCommand.d.ts.map +1 -1
- package/src/cli/commands/ConfigCommand.js +34 -4
- package/src/cli/commands/D1MigrateCommand.d.ts +4 -0
- package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/D1MigrateCommand.js +4 -3
- package/src/cli/commands/FixCommand.d.ts.map +1 -1
- package/src/cli/commands/FixCommand.js +3 -16
- 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.map +1 -1
- package/src/cli/commands/LogsCommand.js +1 -1
- 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 +74 -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 +113 -0
- package/src/cli/commands/NewCommand.d.ts +4 -0
- package/src/cli/commands/NewCommand.d.ts.map +1 -1
- package/src/cli/commands/NewCommand.js +33 -20
- package/src/cli/commands/PluginCommand.d.ts.map +1 -1
- package/src/cli/commands/PluginCommand.js +8 -4
- package/src/cli/commands/PrepareCommand.d.ts.map +1 -1
- package/src/cli/commands/PrepareCommand.js +1 -1
- package/src/cli/commands/QACommand.d.ts.map +1 -1
- package/src/cli/commands/QACommand.js +11 -20
- 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/StartCommand.d.ts.map +1 -1
- package/src/cli/commands/StartCommand.js +2 -2
- 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/index.d.ts +5 -0
- package/src/cli/commands/index.d.ts.map +1 -1
- package/src/cli/commands/index.js +5 -0
- package/src/cli/config/ConfigManager.js +1 -1
- package/src/cli/index.d.ts +2 -1
- package/src/cli/index.d.ts.map +1 -1
- package/src/cli/index.js +2 -1
- package/src/cli/scaffolding/ControllerGenerator.js +1 -1
- package/src/cli/scaffolding/FeatureScaffolder.js +4 -4
- package/src/cli/scaffolding/FileGenerator.js +1 -1
- package/src/cli/scaffolding/ModelGenerator.js +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.js +61 -11
- package/src/cli/scaffolding/ResponseFactoryGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/ResponseFactoryGenerator.js +3 -2
- package/src/cli/scaffolding/RouteGenerator.js +1 -1
- package/src/cli/scaffolding/ServiceIntegrationTestGenerator.js +1 -1
- package/src/cli/scaffolding/ServiceScaffolder.js +2 -2
- 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/index.d.ts +1 -0
- package/src/cli/scaffolding/index.d.ts.map +1 -1
- package/src/cli/scaffolding/index.js +1 -0
- package/src/cli/utils/spawn.js +1 -1
- 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/index.d.ts +39 -0
- package/src/common/index.d.ts.map +1 -1
- package/src/common/index.js +101 -8
- package/src/common/uuid.d.ts +3 -0
- package/src/common/uuid.d.ts.map +1 -0
- package/src/common/uuid.js +30 -0
- package/src/config/FileLogWriter.d.ts +22 -0
- package/src/config/FileLogWriter.d.ts.map +1 -0
- package/src/config/FileLogWriter.js +192 -0
- package/src/config/SecretsManager.d.ts.map +1 -1
- package/src/config/SecretsManager.js +37 -11
- package/src/config/StartupConfigValidator.d.ts +15 -0
- package/src/config/StartupConfigValidator.d.ts.map +1 -0
- package/src/config/StartupConfigValidator.js +86 -0
- package/src/config/app.d.ts +2 -1
- package/src/config/app.d.ts.map +1 -1
- package/src/config/app.js +65 -15
- package/src/config/broadcast.d.ts +47 -0
- package/src/config/broadcast.d.ts.map +1 -0
- package/src/config/broadcast.js +54 -0
- package/src/config/cache.d.ts +13 -17
- package/src/config/cache.d.ts.map +1 -1
- package/src/config/cache.js +9 -11
- package/src/config/cloudflare.d.ts +26 -0
- package/src/config/cloudflare.d.ts.map +1 -0
- package/src/config/cloudflare.js +38 -0
- package/src/config/env.d.ts +6 -0
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +6 -0
- package/src/config/index.d.ts +52 -28
- package/src/config/index.d.ts.map +1 -1
- package/src/config/index.js +3 -0
- package/src/config/logger.d.ts +2 -0
- package/src/config/logger.d.ts.map +1 -1
- package/src/config/logger.js +270 -11
- 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 +81 -0
- package/src/config/mail.d.ts.map +1 -0
- package/src/config/mail.js +73 -0
- package/src/config/middleware.d.ts +8 -0
- package/src/config/middleware.d.ts.map +1 -0
- package/src/config/middleware.js +18 -0
- package/src/config/notification.d.ts +62 -0
- package/src/config/notification.d.ts.map +1 -0
- package/src/config/notification.js +43 -0
- package/src/config/security.d.ts.map +1 -1
- package/src/config/security.js +2 -2
- package/src/config/startup.d.ts +23 -0
- package/src/config/startup.d.ts.map +1 -0
- package/src/config/startup.js +15 -0
- package/src/config/storage.d.ts +21 -35
- package/src/config/storage.d.ts.map +1 -1
- package/src/config/storage.js +57 -37
- package/src/database/migrations/index.d.ts +1 -1
- package/src/database/migrations/index.d.ts.map +1 -1
- package/src/database/migrations/index.js +2 -1
- package/src/features/Queue.js +1 -25
- 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/ErrorResponse.d.ts +28 -0
- package/src/http/ErrorResponse.d.ts.map +1 -0
- package/src/http/ErrorResponse.js +42 -0
- package/src/http/Kernel.d.ts +5 -0
- package/src/http/Kernel.d.ts.map +1 -1
- package/src/http/Kernel.js +96 -30
- package/src/http/RequestContext.d.ts +20 -0
- package/src/http/RequestContext.d.ts.map +1 -0
- package/src/http/RequestContext.js +77 -0
- package/src/index.d.ts +9 -1
- package/src/index.d.ts.map +1 -1
- package/src/index.js +8 -2
- package/src/microservices/MicroserviceManager.d.ts.map +1 -1
- package/src/microservices/MicroserviceManager.js +9 -6
- package/src/microservices/PostgresAdapter.d.ts.map +1 -1
- package/src/microservices/PostgresAdapter.js +3 -1
- package/src/microservices/ServiceBundler.d.ts.map +1 -1
- package/src/microservices/ServiceBundler.js +6 -4
- package/src/microservices/ServiceHealthMonitor.js +2 -2
- package/src/middleware/CsrfMiddleware.d.ts.map +1 -1
- package/src/middleware/CsrfMiddleware.js +2 -19
- package/src/middleware/ErrorHandlerMiddleware.d.ts +6 -0
- package/src/middleware/ErrorHandlerMiddleware.d.ts.map +1 -0
- package/src/middleware/ErrorHandlerMiddleware.js +33 -0
- package/src/middleware/LoggingMiddleware.d.ts +9 -0
- package/src/middleware/LoggingMiddleware.d.ts.map +1 -0
- package/src/middleware/LoggingMiddleware.js +36 -0
- package/src/middleware/index.d.ts +2 -0
- package/src/middleware/index.d.ts.map +1 -1
- package/src/middleware/index.js +2 -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/fs.d.ts +2 -2
- package/src/node-singletons/fs.d.ts.map +1 -1
- package/src/node-singletons/fs.js +2 -2
- package/src/node-singletons/http.d.ts +1 -1
- package/src/node-singletons/http.d.ts.map +1 -1
- package/src/node-singletons/http.js +1 -1
- package/src/node-singletons/index.d.ts +4 -0
- package/src/node-singletons/index.d.ts.map +1 -1
- package/src/node-singletons/index.js +4 -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 +3 -3
- package/src/node-singletons/os.d.ts.map +1 -1
- package/src/node-singletons/os.js +3 -4
- package/src/node-singletons/path.d.ts +3 -1
- package/src/node-singletons/path.d.ts.map +1 -1
- package/src/node-singletons/path.js +3 -1
- package/src/node-singletons/perf-hooks.d.ts +3 -1
- package/src/node-singletons/perf-hooks.d.ts.map +1 -1
- package/src/node-singletons/perf-hooks.js +3 -1
- 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 +3 -3
- package/src/node-singletons/readline.d.ts.map +1 -1
- package/src/node-singletons/readline.js +3 -4
- 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 +3 -1
- package/src/node-singletons/url.d.ts.map +1 -1
- package/src/node-singletons/url.js +3 -1
- package/src/orm/ConnectionManager.d.ts +6 -1
- package/src/orm/ConnectionManager.d.ts.map +1 -1
- package/src/orm/ConnectionManager.js +14 -0
- package/src/orm/DatabaseAdapter.d.ts +6 -0
- package/src/orm/DatabaseAdapter.d.ts.map +1 -1
- package/src/orm/QueryBuilder.d.ts +8 -1
- package/src/orm/QueryBuilder.d.ts.map +1 -1
- package/src/orm/QueryBuilder.js +188 -28
- package/src/orm/adapters/D1Adapter.d.ts.map +1 -1
- package/src/orm/adapters/D1Adapter.js +18 -12
- package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/MySQLAdapter.js +4 -0
- package/src/orm/adapters/PostgreSQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/PostgreSQLAdapter.js +4 -0
- package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLServerAdapter.js +4 -0
- package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLiteAdapter.js +4 -0
- package/src/performance/CodeGenerationBenchmark.js +3 -3
- package/src/performance/Optimizer.d.ts +1 -1
- package/src/performance/Optimizer.d.ts.map +1 -1
- package/src/performance/Optimizer.js +150 -75
- package/src/performance/establish-baseline.js +3 -3
- package/src/runtime/PluginManager.d.ts +3 -1
- package/src/runtime/PluginManager.d.ts.map +1 -1
- package/src/runtime/PluginManager.js +124 -28
- package/src/runtime/RuntimeDetector.d.ts.map +1 -1
- package/src/runtime/RuntimeDetector.js +47 -6
- package/src/runtime/adapters/CloudflareAdapter.js +2 -2
- package/src/runtime/adapters/FargateAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/FargateAdapter.js +2 -1
- package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/LambdaAdapter.js +4 -2
- package/src/runtime/adapters/NodeServerAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/NodeServerAdapter.js +2 -1
- 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/TemplateSync.js +109 -70
- package/src/security/CsrfTokenManager.js +1 -1
- package/src/security/Encryptor.js +1 -1
- 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/StartupSecretValidation.d.ts +20 -0
- package/src/security/StartupSecretValidation.d.ts.map +1 -0
- package/src/security/StartupSecretValidation.js +61 -0
- package/src/security/UrlValidator.d.ts +0 -1
- package/src/security/UrlValidator.d.ts.map +1 -1
- package/src/security/UrlValidator.js +1 -2
- 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.map +1 -1
- package/src/security/XssProtection.js +155 -17
- package/src/templates/adapters/MySQLAdapter.ts.tpl +5 -0
- package/src/templates/adapters/PostgreSQLAdapter.ts.tpl +5 -0
- package/src/templates/adapters/SQLServerAdapter.ts.tpl +5 -0
- package/src/templates/adapters/SQLiteAdapter.ts.tpl +5 -0
- package/src/templates/features/Queue.ts.tpl +1 -29
- package/src/templates/project/basic/.env.example.tpl +48 -0
- package/src/templates/project/basic/.env.tpl +89 -94
- package/src/templates/project/basic/app/Toolkit/Broadcast/sendBroadcast.ts.tpl +7 -0
- package/src/templates/project/basic/app/Toolkit/Mail/sendWelcomeEmail.ts.tpl +30 -0
- package/src/templates/project/basic/app/Toolkit/Notification/sendSlackNotification.ts.tpl +10 -0
- package/src/templates/project/basic/app/Toolkit/Notification/sendSms.ts.tpl +13 -0
- package/src/templates/project/basic/config/FileLogWriter.ts.tpl +240 -0
- package/src/templates/project/basic/config/SecretsManager.ts.tpl +44 -21
- package/src/templates/project/basic/config/StartupConfigValidator.ts.tpl +151 -0
- package/src/templates/project/basic/config/app.ts.tpl +84 -15
- package/src/templates/project/basic/config/broadcast.ts.tpl +97 -0
- package/src/templates/project/basic/config/cache.ts.tpl +19 -23
- package/src/templates/project/basic/config/cloudflare.ts.tpl +57 -0
- package/src/templates/project/basic/config/env.ts.tpl +7 -1
- package/src/templates/project/basic/config/index.ts.tpl +3 -0
- package/src/templates/project/basic/config/logger.ts.tpl +301 -11
- package/src/templates/project/basic/config/logging/HttpLogger.ts.tpl +121 -0
- package/src/templates/project/basic/config/logging/KvLogger.ts.tpl +181 -0
- package/src/templates/project/basic/config/logging/SlackLogger.ts.tpl +156 -0
- package/src/templates/project/basic/config/mail.ts.tpl +141 -0
- package/src/templates/project/basic/config/middleware.ts.tpl +27 -0
- package/src/templates/project/basic/config/notification.ts.tpl +86 -0
- package/src/templates/project/basic/config/security.ts.tpl +4 -5
- package/src/templates/project/basic/config/startup.ts.tpl +27 -0
- package/src/templates/project/basic/config/storage.ts.tpl +77 -42
- package/src/templates/project/basic/database/migrations/index.ts.tpl +1 -1
- package/src/templates/project/basic/package.json.tpl +1 -1
- package/src/templates/project/basic/routes/api.ts.tpl +11 -37
- package/src/templates/project/basic/routes/broadcast.ts.tpl +32 -0
- package/src/templates/project/basic/routes/health.ts.tpl +134 -0
- package/src/templates/project/basic/routes/storage.ts.tpl +42 -0
- package/src/templates/project/basic/src/index.ts.tpl +38 -11
- package/src/templates/project/basic/template.json +3 -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 +119 -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 +131 -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 +73 -0
- package/src/tools/broadcast/Broadcast.d.ts +7 -0
- package/src/tools/broadcast/Broadcast.d.ts.map +1 -0
- package/src/tools/broadcast/Broadcast.js +37 -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 +73 -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 +7 -0
- package/src/tools/broadcast/index.d.ts.map +1 -0
- package/src/tools/broadcast/index.js +6 -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 +169 -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 +22 -0
- package/src/tools/mail/Mail.d.ts.map +1 -0
- package/src/tools/mail/Mail.js +105 -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 +57 -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 +116 -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 +327 -0
- package/src/tools/mail/templates/index.d.ts +27 -0
- package/src/tools/mail/templates/index.d.ts.map +1 -0
- package/src/tools/mail/templates/index.js +35 -0
- package/src/tools/mail/templates/markdown/index.d.ts +17 -0
- package/src/tools/mail/templates/markdown/index.d.ts.map +1 -0
- package/src/tools/mail/templates/markdown/index.js +49 -0
- package/src/tools/mail/templates/markdown/registry.d.ts +15 -0
- package/src/tools/mail/templates/markdown/registry.d.ts.map +1 -0
- package/src/tools/mail/templates/markdown/registry.js +34 -0
- package/src/tools/mail/templates/markdown/validator.d.ts +16 -0
- package/src/tools/mail/templates/markdown/validator.d.ts.map +1 -0
- package/src/tools/mail/templates/markdown/validator.js +24 -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 +11 -0
- package/src/tools/notification/Notification.d.ts.map +1 -0
- package/src/tools/notification/Notification.js +11 -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 +22 -0
- package/src/tools/notification/Service.d.ts +6 -0
- package/src/tools/notification/Service.d.ts.map +1 -0
- package/src/tools/notification/Service.js +18 -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/Termii.d.ts +10 -0
- package/src/tools/notification/drivers/Termii.d.ts.map +1 -0
- package/src/tools/notification/drivers/Termii.js +47 -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/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/Queue.d.ts +23 -0
- package/src/tools/queue/Queue.d.ts.map +1 -0
- package/src/tools/queue/Queue.js +38 -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 +91 -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/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 +258 -0
- package/src/tools/storage/index.d.ts +24 -0
- package/src/tools/storage/index.d.ts.map +1 -0
- package/src/tools/storage/index.js +111 -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 +52 -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/orm/QueryBuilder.js
CHANGED
|
@@ -7,20 +7,115 @@ import { ErrorFactory } from '../exceptions/ZintrustError';
|
|
|
7
7
|
* Escape SQL identifier
|
|
8
8
|
*/
|
|
9
9
|
const escapeIdentifier = (id) => `"${id.replaceAll('"', '""')}"`;
|
|
10
|
+
const SAFE_IDENTIFIER_PATH = /^[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*$/;
|
|
11
|
+
const assertSafeIdentifierPath = (id, label) => {
|
|
12
|
+
const trimmed = id.trim();
|
|
13
|
+
if (trimmed.length === 0) {
|
|
14
|
+
throw ErrorFactory.createDatabaseError(`Empty SQL identifier for ${label}`);
|
|
15
|
+
}
|
|
16
|
+
if (!SAFE_IDENTIFIER_PATH.test(trimmed)) {
|
|
17
|
+
throw ErrorFactory.createDatabaseError(`Unsafe SQL identifier for ${label}`);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const normalizeOrderDirection = (direction) => {
|
|
21
|
+
if (direction === undefined || direction === null)
|
|
22
|
+
return 'ASC';
|
|
23
|
+
const trimmed = String(direction).trim();
|
|
24
|
+
if (trimmed.length === 0)
|
|
25
|
+
return 'ASC';
|
|
26
|
+
const normalized = trimmed.toUpperCase();
|
|
27
|
+
if (normalized === 'ASC' || normalized === 'DESC')
|
|
28
|
+
return normalized;
|
|
29
|
+
throw ErrorFactory.createDatabaseError('Unsafe ORDER BY direction');
|
|
30
|
+
};
|
|
31
|
+
const normalizeOperator = (operator) => operator.trim().toUpperCase();
|
|
32
|
+
const ALLOWED_OPERATORS = new Set([
|
|
33
|
+
'=',
|
|
34
|
+
'!=',
|
|
35
|
+
'<>',
|
|
36
|
+
'<',
|
|
37
|
+
'<=',
|
|
38
|
+
'>',
|
|
39
|
+
'>=',
|
|
40
|
+
'LIKE',
|
|
41
|
+
'NOT LIKE',
|
|
42
|
+
'ILIKE',
|
|
43
|
+
'NOT ILIKE',
|
|
44
|
+
'IN',
|
|
45
|
+
'NOT IN',
|
|
46
|
+
'BETWEEN',
|
|
47
|
+
'NOT BETWEEN',
|
|
48
|
+
'IS',
|
|
49
|
+
'IS NOT',
|
|
50
|
+
]);
|
|
51
|
+
const assertSafeOperator = (operator) => {
|
|
52
|
+
const normalized = normalizeOperator(operator);
|
|
53
|
+
if (!ALLOWED_OPERATORS.has(normalized)) {
|
|
54
|
+
throw ErrorFactory.createDatabaseError('Unsafe SQL operator');
|
|
55
|
+
}
|
|
56
|
+
return normalized;
|
|
57
|
+
};
|
|
58
|
+
const assertSafeLimitOffset = (value, label) => {
|
|
59
|
+
if (!Number.isFinite(value) || !Number.isInteger(value) || value < 0) {
|
|
60
|
+
throw ErrorFactory.createDatabaseError(`Unsafe ${label} value`);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const isNumericLiteral = (value) => {
|
|
64
|
+
// Strict, injection-resistant numeric literal allow-list.
|
|
65
|
+
// Allows: 0, 1, 1.5, 0001
|
|
66
|
+
// Disallows: 1e3, 1;DROP, 1 as ok
|
|
67
|
+
return /^(?:0|[1-9]\d*)(?:\.\d+)?$/.test(value);
|
|
68
|
+
};
|
|
10
69
|
/**
|
|
11
70
|
* Build SELECT clause
|
|
12
71
|
*/
|
|
13
|
-
const buildSelectClause = (columns) => columns
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
72
|
+
const buildSelectClause = (columns) => columns
|
|
73
|
+
.map((c) => {
|
|
74
|
+
if (c === '*')
|
|
75
|
+
return c;
|
|
76
|
+
if (isNumericLiteral(c))
|
|
77
|
+
return c;
|
|
78
|
+
assertSafeIdentifierPath(c, 'select column');
|
|
79
|
+
return escapeIdentifier(c);
|
|
80
|
+
})
|
|
81
|
+
.join(', ');
|
|
82
|
+
const compileWhere = (conditions) => {
|
|
18
83
|
if (conditions.length === 0)
|
|
19
|
-
return '';
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
.
|
|
23
|
-
|
|
84
|
+
return { sql: '', parameters: [] };
|
|
85
|
+
const parameters = [];
|
|
86
|
+
const clauses = conditions.map((clause) => {
|
|
87
|
+
assertSafeIdentifierPath(clause.column, 'where column');
|
|
88
|
+
const operator = assertSafeOperator(clause.operator);
|
|
89
|
+
const columnSql = escapeIdentifier(clause.column);
|
|
90
|
+
if (operator === 'IN' || operator === 'NOT IN') {
|
|
91
|
+
if (!Array.isArray(clause.value) || clause.value.length === 0) {
|
|
92
|
+
throw ErrorFactory.createDatabaseError('IN operator requires a non-empty array');
|
|
93
|
+
}
|
|
94
|
+
const values = clause.value;
|
|
95
|
+
const placeholders = values.map(() => '?').join(', ');
|
|
96
|
+
for (const v of values)
|
|
97
|
+
parameters.push(v);
|
|
98
|
+
return `${columnSql} ${operator} (${placeholders})`;
|
|
99
|
+
}
|
|
100
|
+
if (operator === 'BETWEEN' || operator === 'NOT BETWEEN') {
|
|
101
|
+
if (!Array.isArray(clause.value) || clause.value.length !== 2) {
|
|
102
|
+
throw ErrorFactory.createDatabaseError('BETWEEN operator requires a 2-item array');
|
|
103
|
+
}
|
|
104
|
+
const range = clause.value;
|
|
105
|
+
parameters.push(range[0], range[1]);
|
|
106
|
+
return `${columnSql} ${operator} ? AND ?`;
|
|
107
|
+
}
|
|
108
|
+
if (operator === 'IS' || operator === 'IS NOT') {
|
|
109
|
+
if (clause.value === null || clause.value === undefined) {
|
|
110
|
+
return `${columnSql} ${operator} NULL`;
|
|
111
|
+
}
|
|
112
|
+
parameters.push(clause.value);
|
|
113
|
+
return `${columnSql} ${operator} ?`;
|
|
114
|
+
}
|
|
115
|
+
parameters.push(clause.value);
|
|
116
|
+
return `${columnSql} ${operator} ?`;
|
|
117
|
+
});
|
|
118
|
+
return { sql: ` WHERE ${clauses.join(' AND ')}`, parameters };
|
|
24
119
|
};
|
|
25
120
|
/**
|
|
26
121
|
* Build ORDER BY clause
|
|
@@ -28,19 +123,74 @@ const buildWhereClause = (conditions) => {
|
|
|
28
123
|
const buildOrderByClause = (orderBy) => {
|
|
29
124
|
if (!orderBy)
|
|
30
125
|
return '';
|
|
31
|
-
|
|
126
|
+
const col = orderBy.column.trim();
|
|
127
|
+
if (!isNumericLiteral(col)) {
|
|
128
|
+
assertSafeIdentifierPath(col, 'order by column');
|
|
129
|
+
}
|
|
130
|
+
const dir = normalizeOrderDirection(orderBy.direction);
|
|
131
|
+
// Keep output unquoted for backwards compatibility; validation prevents injection.
|
|
132
|
+
return ` ORDER BY ${col} ${dir}`;
|
|
32
133
|
};
|
|
33
134
|
/**
|
|
34
135
|
* Build LIMIT and OFFSET clause
|
|
35
136
|
*/
|
|
36
137
|
const buildLimitOffsetClause = (limit, offset) => {
|
|
37
138
|
let sql = '';
|
|
38
|
-
if (limit !== undefined && limit !== null)
|
|
139
|
+
if (limit !== undefined && limit !== null) {
|
|
140
|
+
assertSafeLimitOffset(limit, 'LIMIT');
|
|
39
141
|
sql += ` LIMIT ${limit}`;
|
|
40
|
-
|
|
142
|
+
}
|
|
143
|
+
if (offset !== undefined && offset !== null) {
|
|
144
|
+
assertSafeLimitOffset(offset, 'OFFSET');
|
|
41
145
|
sql += ` OFFSET ${offset}`;
|
|
146
|
+
}
|
|
42
147
|
return sql;
|
|
43
148
|
};
|
|
149
|
+
const buildSelectQuery = (state) => {
|
|
150
|
+
if (state.tableName.length > 0) {
|
|
151
|
+
assertSafeIdentifierPath(state.tableName, 'table name');
|
|
152
|
+
}
|
|
153
|
+
const columns = buildSelectClause(state.selectColumns);
|
|
154
|
+
const fromClause = state.tableName.length > 0 ? ` FROM ${escapeIdentifier(state.tableName)}` : '';
|
|
155
|
+
const where = compileWhere(state.whereConditions);
|
|
156
|
+
const sql = `SELECT ${columns}${fromClause}${where.sql}${buildOrderByClause(state.orderByClause)}${buildLimitOffsetClause(state.limitValue, state.offsetValue)}`;
|
|
157
|
+
return { sql, parameters: where.parameters };
|
|
158
|
+
};
|
|
159
|
+
const applyWhereCondition = (state, column, operator, value) => {
|
|
160
|
+
const col = String(column).trim();
|
|
161
|
+
assertSafeIdentifierPath(col, 'where column');
|
|
162
|
+
let op;
|
|
163
|
+
let val;
|
|
164
|
+
// Shorthand: where('id', 123)
|
|
165
|
+
if (value === undefined) {
|
|
166
|
+
op = '=';
|
|
167
|
+
val = operator;
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
if (typeof operator !== 'string') {
|
|
171
|
+
throw ErrorFactory.createDatabaseError('Unsafe SQL operator');
|
|
172
|
+
}
|
|
173
|
+
op = assertSafeOperator(operator);
|
|
174
|
+
val = value;
|
|
175
|
+
}
|
|
176
|
+
state.whereConditions.push({ column: col, operator: op, value: val });
|
|
177
|
+
};
|
|
178
|
+
const applyOrderByClause = (state, column, direction) => {
|
|
179
|
+
const col = String(column).trim();
|
|
180
|
+
if (!isNumericLiteral(col)) {
|
|
181
|
+
assertSafeIdentifierPath(col, 'order by column');
|
|
182
|
+
}
|
|
183
|
+
const dir = normalizeOrderDirection(direction);
|
|
184
|
+
state.orderByClause = { column: col, direction: dir };
|
|
185
|
+
};
|
|
186
|
+
const applyLimit = (state, count) => {
|
|
187
|
+
assertSafeLimitOffset(count, 'LIMIT');
|
|
188
|
+
state.limitValue = count;
|
|
189
|
+
};
|
|
190
|
+
const applyOffset = (state, count) => {
|
|
191
|
+
assertSafeLimitOffset(count, 'OFFSET');
|
|
192
|
+
state.offsetValue = count;
|
|
193
|
+
};
|
|
44
194
|
/**
|
|
45
195
|
* Execute query and return first result
|
|
46
196
|
*/
|
|
@@ -69,9 +219,7 @@ function createBuilder(state, db) {
|
|
|
69
219
|
return builder;
|
|
70
220
|
},
|
|
71
221
|
where: (column, operator, value) => {
|
|
72
|
-
|
|
73
|
-
const finalValue = value === undefined ? operator : value;
|
|
74
|
-
state.whereConditions.push({ column, operator: finalOperator, value: finalValue });
|
|
222
|
+
applyWhereCondition(state, column, operator, value);
|
|
75
223
|
return builder;
|
|
76
224
|
},
|
|
77
225
|
andWhere: (column, operator, value) => builder.where(column, operator, value),
|
|
@@ -82,15 +230,15 @@ function createBuilder(state, db) {
|
|
|
82
230
|
},
|
|
83
231
|
leftJoin: (tableJoin, on) => builder.join(tableJoin, on),
|
|
84
232
|
orderBy: (column, direction = 'ASC') => {
|
|
85
|
-
state
|
|
233
|
+
applyOrderByClause(state, column, direction);
|
|
86
234
|
return builder;
|
|
87
235
|
},
|
|
88
236
|
limit: (count) => {
|
|
89
|
-
state
|
|
237
|
+
applyLimit(state, count);
|
|
90
238
|
return builder;
|
|
91
239
|
},
|
|
92
240
|
offset: (count) => {
|
|
93
|
-
state
|
|
241
|
+
applyOffset(state, count);
|
|
94
242
|
return builder;
|
|
95
243
|
},
|
|
96
244
|
getWhereClauses: () => state.whereConditions,
|
|
@@ -101,12 +249,8 @@ function createBuilder(state, db) {
|
|
|
101
249
|
getOrderBy: () => state.orderByClause,
|
|
102
250
|
getJoins: () => state.joins,
|
|
103
251
|
isReadOperation: () => true,
|
|
104
|
-
toSQL: () =>
|
|
105
|
-
|
|
106
|
-
const tableEscaped = escapeIdentifier(state.tableName);
|
|
107
|
-
return `SELECT ${columns} FROM ${tableEscaped}${buildWhereClause(state.whereConditions)}${buildOrderByClause(state.orderByClause)}${buildLimitOffsetClause(state.limitValue, state.offsetValue)}`;
|
|
108
|
-
},
|
|
109
|
-
getParameters: () => state.whereConditions.map((clause) => clause.value),
|
|
252
|
+
toSQL: () => buildSelectQuery(state).sql,
|
|
253
|
+
getParameters: () => buildSelectQuery(state).parameters,
|
|
110
254
|
first: async () => executeFirst(builder, db),
|
|
111
255
|
get: async () => executeGet(builder, db),
|
|
112
256
|
};
|
|
@@ -122,13 +266,29 @@ export const QueryBuilder = Object.freeze({
|
|
|
122
266
|
/**
|
|
123
267
|
* Create a new query builder instance
|
|
124
268
|
*/
|
|
125
|
-
create(
|
|
269
|
+
create(tableOrDb, db) {
|
|
270
|
+
const hasTable = typeof tableOrDb === 'string';
|
|
271
|
+
const tableName = hasTable ? String(tableOrDb).trim() : '';
|
|
272
|
+
const database = hasTable ? db : tableOrDb;
|
|
273
|
+
if (tableName.length > 0) {
|
|
274
|
+
assertSafeIdentifierPath(tableName, 'table name');
|
|
275
|
+
}
|
|
126
276
|
const state = {
|
|
127
|
-
tableName
|
|
277
|
+
tableName,
|
|
128
278
|
whereConditions: [],
|
|
129
279
|
selectColumns: ['*'],
|
|
130
280
|
joins: [],
|
|
131
281
|
};
|
|
132
|
-
return createBuilder(state,
|
|
282
|
+
return createBuilder(state, database);
|
|
283
|
+
},
|
|
284
|
+
/**
|
|
285
|
+
* Ping the database connection.
|
|
286
|
+
*
|
|
287
|
+
* This is intentionally a tiny, dependency-free check that can be reused by
|
|
288
|
+
* health/readiness endpoints without embedding SQL in route handlers.
|
|
289
|
+
*/
|
|
290
|
+
async ping(db) {
|
|
291
|
+
// Use the QueryBuilder itself to avoid embedding raw SQL at call sites.
|
|
292
|
+
await QueryBuilder.create('', db).select('1').get();
|
|
133
293
|
},
|
|
134
294
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"D1Adapter.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/D1Adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"D1Adapter.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/D1Adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAAE,cAAc,EAAe,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAUlG;;GAEG;AACH,eAAO,MAAM,SAAS;IACpB;;OAEG;oBAEa,cAAc,GAAG,gBAAgB;EAkHjD,CAAC;AAEH,eAAe,SAAS,CAAC"}
|
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cloudflare D1 Database Adapter
|
|
3
3
|
*/
|
|
4
|
+
import { Cloudflare } from '../../config/cloudflare';
|
|
4
5
|
import { FeatureFlags } from '../../config/features';
|
|
5
6
|
import { Logger } from '../../config/logger';
|
|
6
7
|
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
8
|
+
import { QueryBuilder } from '../QueryBuilder';
|
|
7
9
|
/**
|
|
8
10
|
* Get D1 binding from config or global environment
|
|
9
11
|
*/
|
|
10
12
|
function getD1Binding(_config) {
|
|
11
|
-
|
|
12
|
-
if (_config.d1 !== undefined && _config.d1 !== null)
|
|
13
|
-
return _config.d1;
|
|
14
|
-
// 2. Check global env (Cloudflare Workers)
|
|
15
|
-
const globalEnv = globalThis.env;
|
|
16
|
-
if (globalEnv?.DB !== undefined)
|
|
17
|
-
return globalEnv.DB;
|
|
18
|
-
// 3. Check global scope
|
|
19
|
-
const globalDB = globalThis.DB;
|
|
20
|
-
if (globalDB !== undefined)
|
|
21
|
-
return globalDB;
|
|
22
|
-
return null;
|
|
13
|
+
return Cloudflare.getD1Binding(_config);
|
|
23
14
|
}
|
|
24
15
|
/**
|
|
25
16
|
* D1 adapter implementation
|
|
@@ -78,6 +69,21 @@ export const D1Adapter = Object.freeze({
|
|
|
78
69
|
throw ErrorFactory.createTryCatchError(`D1 queryOne failed: ${sql}`, error);
|
|
79
70
|
}
|
|
80
71
|
},
|
|
72
|
+
async ping() {
|
|
73
|
+
if (!connected)
|
|
74
|
+
throw ErrorFactory.createConnectionError('Database not connected');
|
|
75
|
+
const db = getD1Binding(_config);
|
|
76
|
+
if (db === null) {
|
|
77
|
+
throw ErrorFactory.createConfigError('D1 database binding not found');
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
// Use a minimal, side-effect-free query.
|
|
81
|
+
await db.prepare(QueryBuilder.create('').select('1').toSQL()).bind().first();
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
throw ErrorFactory.createTryCatchError('D1 ping failed', error);
|
|
85
|
+
}
|
|
86
|
+
},
|
|
81
87
|
async transaction(callback) {
|
|
82
88
|
if (!connected)
|
|
83
89
|
throw ErrorFactory.createConnectionError('Database not connected');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MySQLAdapter.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/MySQLAdapter.ts"],"names":[],"mappings":"AAEA;;GAEG;AAKH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"MySQLAdapter.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/MySQLAdapter.ts"],"names":[],"mappings":"AAEA;;GAEG;AAKH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAGrF;;;GAGG;AACH,eAAO,MAAM,YAAY;IACvB;;OAEG;mBACY,cAAc,GAAG,gBAAgB;EA8EhD,CAAC;AAEH,eAAe,YAAY,CAAC"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { FeatureFlags } from '../../config/features';
|
|
7
7
|
import { Logger } from '../../config/logger';
|
|
8
8
|
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
9
|
+
import { QueryBuilder } from '../QueryBuilder';
|
|
9
10
|
/**
|
|
10
11
|
* MySQL adapter implementation
|
|
11
12
|
* Sealed namespace for immutability
|
|
@@ -38,6 +39,9 @@ export const MySQLAdapter = Object.freeze({
|
|
|
38
39
|
const result = await this.query(sql, parameters);
|
|
39
40
|
return result.rows[0] ?? null;
|
|
40
41
|
},
|
|
42
|
+
async ping() {
|
|
43
|
+
await this.query(QueryBuilder.create('').select('1').toSQL(), []);
|
|
44
|
+
},
|
|
41
45
|
async transaction(callback) {
|
|
42
46
|
if (!connected)
|
|
43
47
|
throw ErrorFactory.createConnectionError('Database not connected');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgreSQLAdapter.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/PostgreSQLAdapter.ts"],"names":[],"mappings":"AAEA;;GAEG;AAKH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"PostgreSQLAdapter.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/PostgreSQLAdapter.ts"],"names":[],"mappings":"AAEA;;GAEG;AAKH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAGrF;;;GAGG;AACH,eAAO,MAAM,iBAAiB;IAC5B;;OAEG;mBACY,cAAc,GAAG,gBAAgB;EAiFhD,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { FeatureFlags } from '../../config/features';
|
|
7
7
|
import { Logger } from '../../config/logger';
|
|
8
8
|
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
9
|
+
import { QueryBuilder } from '../QueryBuilder';
|
|
9
10
|
/**
|
|
10
11
|
* PostgreSQL adapter implementation
|
|
11
12
|
* Sealed namespace for immutability
|
|
@@ -38,6 +39,9 @@ export const PostgreSQLAdapter = Object.freeze({
|
|
|
38
39
|
const result = await this.query(sql, parameters);
|
|
39
40
|
return result.rows[0] ?? null;
|
|
40
41
|
},
|
|
42
|
+
async ping() {
|
|
43
|
+
await this.query(QueryBuilder.create('').select('1').toSQL(), []);
|
|
44
|
+
},
|
|
41
45
|
async transaction(callback) {
|
|
42
46
|
if (!connected)
|
|
43
47
|
throw ErrorFactory.createConnectionError('Database not connected');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SQLServerAdapter.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/SQLServerAdapter.ts"],"names":[],"mappings":"AAEA;;GAEG;AAKH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"SQLServerAdapter.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/SQLServerAdapter.ts"],"names":[],"mappings":"AAEA;;GAEG;AAKH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAGrF;;;GAGG;AACH,eAAO,MAAM,gBAAgB;IAC3B;;OAEG;mBACY,cAAc,GAAG,gBAAgB;EA4EhD,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { FeatureFlags } from '../../config/features';
|
|
7
7
|
import { Logger } from '../../config/logger';
|
|
8
8
|
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
9
|
+
import { QueryBuilder } from '../QueryBuilder';
|
|
9
10
|
/**
|
|
10
11
|
* SQL Server adapter implementation
|
|
11
12
|
* Sealed namespace for immutability
|
|
@@ -38,6 +39,9 @@ export const SQLServerAdapter = Object.freeze({
|
|
|
38
39
|
const result = await this.query(sql, parameters);
|
|
39
40
|
return result.rows[0] ?? null;
|
|
40
41
|
},
|
|
42
|
+
async ping() {
|
|
43
|
+
await this.query(QueryBuilder.create('').select('1').toSQL(), []);
|
|
44
|
+
},
|
|
41
45
|
async transaction(callback) {
|
|
42
46
|
try {
|
|
43
47
|
return await callback(this);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SQLiteAdapter.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/SQLiteAdapter.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAMH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"SQLiteAdapter.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/SQLiteAdapter.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAMH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AA6HrF,iBAAS,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,gBAAgB,CAoDrE;AAED,eAAO,MAAM,aAAa;;EAExB,CAAC"}
|
|
@@ -8,6 +8,7 @@ import { FeatureFlags } from '../../config/features';
|
|
|
8
8
|
import { Logger } from '../../config/logger';
|
|
9
9
|
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
10
10
|
import { performance } from '../../node-singletons/perf-hooks';
|
|
11
|
+
import { QueryBuilder } from '../QueryBuilder';
|
|
11
12
|
import Database from 'better-sqlite3';
|
|
12
13
|
function normalizeFilename(database) {
|
|
13
14
|
const value = (database ?? '').trim();
|
|
@@ -107,6 +108,9 @@ function createSQLiteAdapter(config) {
|
|
|
107
108
|
const result = await adapter.query(sql, parameters);
|
|
108
109
|
return result.rows[0] ?? null;
|
|
109
110
|
},
|
|
111
|
+
async ping() {
|
|
112
|
+
await adapter.query(QueryBuilder.create('').select('1').toSQL(), []);
|
|
113
|
+
},
|
|
110
114
|
async transaction(callback) {
|
|
111
115
|
return transactionSQLite(state, adapter, callback);
|
|
112
116
|
},
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Code Generation Benchmarks
|
|
3
3
|
* Measure performance of all code generators
|
|
4
4
|
*/
|
|
5
|
+
import { esmFilePath } from '../common/index';
|
|
5
6
|
import { Logger } from '../config/logger';
|
|
6
7
|
import { ErrorFactory } from '../exceptions/ZintrustError';
|
|
7
8
|
import { fs } from '../node-singletons/index.js';
|
|
8
|
-
import
|
|
9
|
+
import * as path from '../node-singletons/path';
|
|
9
10
|
import { Benchmark, MemoryMonitor } from './Benchmark';
|
|
10
|
-
import * as path from 'node:path';
|
|
11
11
|
function isBenchmarkFactory(value) {
|
|
12
12
|
if (typeof value !== 'object' || value === null)
|
|
13
13
|
return false;
|
|
@@ -221,7 +221,7 @@ const isMain = (() => {
|
|
|
221
221
|
const entrypoint = process.argv[1];
|
|
222
222
|
if (typeof entrypoint !== 'string')
|
|
223
223
|
return false;
|
|
224
|
-
const currentFilePath =
|
|
224
|
+
const currentFilePath = esmFilePath(import.meta.url);
|
|
225
225
|
// Use realpathSync to handle symlinks (common on macOS /var -> /private/var)
|
|
226
226
|
if (!('realpathSync' in fs)) {
|
|
227
227
|
return path.resolve(entrypoint) === path.resolve(currentFilePath);
|
|
@@ -22,7 +22,7 @@ export declare const GenerationCache: Readonly<{
|
|
|
22
22
|
/**
|
|
23
23
|
* Create a new generation cache instance
|
|
24
24
|
*/
|
|
25
|
-
create(cacheDir?: string, ttlMs?: number): IGenerationCache;
|
|
25
|
+
create(cacheDir?: string, ttlMs?: number, maxEntries?: number): IGenerationCache;
|
|
26
26
|
}>;
|
|
27
27
|
export interface ILazyLoader {
|
|
28
28
|
load<T>(modulePath: string): Promise<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Optimizer.d.ts","sourceRoot":"","sources":["../../../src/performance/Optimizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"Optimizer.d.ts","sourceRoot":"","sources":["../../../src/performance/Optimizer.ts"],"names":[],"mappings":"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"}
|