@zintrust/core 0.1.1 → 0.1.2
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 +1 -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 +150 -16
- 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 +9 -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/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 +51 -0
- package/src/tools/http/Http.d.ts.map +1 -0
- package/src/tools/http/Http.js +171 -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/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 +17 -0
- package/src/tools/storage/drivers/Local.d.ts.map +1 -0
- package/src/tools/storage/drivers/Local.js +63 -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 +112 -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
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const loadTemplate: (name: string) => {
|
|
2
|
+
subject?: string;
|
|
3
|
+
preheader?: string;
|
|
4
|
+
variables?: string[];
|
|
5
|
+
content: string;
|
|
6
|
+
};
|
|
7
|
+
export { listTemplates, renderTemplate } from '../../templates/markdown/registry';
|
|
8
|
+
declare const _default: {
|
|
9
|
+
loadTemplate: (name: string) => {
|
|
10
|
+
subject?: string;
|
|
11
|
+
preheader?: string;
|
|
12
|
+
variables?: string[];
|
|
13
|
+
content: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export default _default;
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/mail/templates/markdown/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,GACvB,MAAM,MAAM,KACX;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAkD/E,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;;yBArD1E,MAAM,KACX;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;;AAsDlF,wBAAgC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { readFileSync } from '../../../../node-singletons/fs';
|
|
2
|
+
import { join } from '../../../../node-singletons/path';
|
|
3
|
+
export const loadTemplate = (name) => {
|
|
4
|
+
// name e.g. 'auth/welcome'
|
|
5
|
+
const parts = name.split('/');
|
|
6
|
+
// Safe parser for top comment metadata <!-- Key: Value --> lines to avoid regex backtracking
|
|
7
|
+
const dir = join(process.cwd(), 'src', 'tools', 'mail', 'templates', 'markdown', ...parts.slice(0, -1));
|
|
8
|
+
const leaf = parts.at(-1) ?? '';
|
|
9
|
+
const filePath = join(dir, `${leaf}.md`);
|
|
10
|
+
const raw = readFileSync(filePath, 'utf-8');
|
|
11
|
+
const meta = {};
|
|
12
|
+
const parseMetaLine = (line) => {
|
|
13
|
+
// Must start with <!-- and end with --> exactly; trim the inner part and split at first colon
|
|
14
|
+
if (!line.startsWith('<!--') || !line.endsWith('-->'))
|
|
15
|
+
return null;
|
|
16
|
+
const inner = line.slice('<!--'.length, -'-->'.length).trim();
|
|
17
|
+
const idx = inner.indexOf(':');
|
|
18
|
+
if (idx === -1)
|
|
19
|
+
return null;
|
|
20
|
+
const key = inner.slice(0, idx).trim().toLowerCase();
|
|
21
|
+
const val = inner.slice(idx + 1).trim();
|
|
22
|
+
if (!key)
|
|
23
|
+
return null;
|
|
24
|
+
return [key, val];
|
|
25
|
+
};
|
|
26
|
+
// Parse top comment metadata <!-- Key: Value --> lines
|
|
27
|
+
const lines = raw.split(/\r?\n/);
|
|
28
|
+
let i = 0;
|
|
29
|
+
for (; i < lines.length; i++) {
|
|
30
|
+
const kv = parseMetaLine(lines[i]);
|
|
31
|
+
if (!kv)
|
|
32
|
+
break;
|
|
33
|
+
const [key, val] = kv;
|
|
34
|
+
if (key === 'subject')
|
|
35
|
+
meta.subject = val;
|
|
36
|
+
if (key === 'preheader')
|
|
37
|
+
meta.preheader = val;
|
|
38
|
+
if (key === 'variables') {
|
|
39
|
+
meta.variables = val
|
|
40
|
+
.split(',')
|
|
41
|
+
.map((s) => s.trim())
|
|
42
|
+
.filter(Boolean);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const content = lines.slice(i).join('\n').trim();
|
|
46
|
+
return { content, ...meta };
|
|
47
|
+
};
|
|
48
|
+
export { listTemplates, renderTemplate } from '../../templates/markdown/registry';
|
|
49
|
+
export default { loadTemplate };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { loadTemplate } from '../../templates/markdown';
|
|
2
|
+
export declare const listTemplates: () => string[];
|
|
3
|
+
export declare const renderTemplate: (name: string, vars?: Record<string, unknown>) => {
|
|
4
|
+
html: string;
|
|
5
|
+
meta: ReturnType<typeof loadTemplate>;
|
|
6
|
+
};
|
|
7
|
+
declare const _default: {
|
|
8
|
+
listTemplates: () => string[];
|
|
9
|
+
renderTemplate: (name: string, vars?: Record<string, unknown>) => {
|
|
10
|
+
html: string;
|
|
11
|
+
meta: ReturnType<typeof loadTemplate>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
|
15
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/mail/templates/markdown/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AA2BxD,eAAO,MAAM,aAAa,QAAO,MAAM,EAEtC,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,EACZ,OAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,KACjC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAA;CAKvD,CAAC;;yBAZ+B,MAAM,EAAE;2BAKjC,MAAM,SACN,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC5B;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAA;KAAE;;AAO1D,wBAAiD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { loadTemplate } from '../../templates/markdown';
|
|
2
|
+
import { validateTemplateMeta } from '../../templates/markdown/validator';
|
|
3
|
+
import { readdirSync, statSync } from '../../../../node-singletons/fs';
|
|
4
|
+
import { join, relative } from '../../../../node-singletons/path';
|
|
5
|
+
import { MarkdownRenderer } from '../../../templates';
|
|
6
|
+
const BASE = join(process.cwd(), 'src', 'tools', 'mail', 'templates', 'markdown');
|
|
7
|
+
const walkDir = (dir, base = dir) => {
|
|
8
|
+
const entries = readdirSync(dir);
|
|
9
|
+
let files = [];
|
|
10
|
+
for (const e of entries) {
|
|
11
|
+
const p = join(dir, e);
|
|
12
|
+
const s = statSync(p);
|
|
13
|
+
if (s.isDirectory()) {
|
|
14
|
+
files = files.concat(walkDir(p, base));
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (e.endsWith('.md')) {
|
|
18
|
+
const rel = relative(base, p).replaceAll('\\', '/');
|
|
19
|
+
const withoutExt = rel.toLowerCase().endsWith('.md') ? rel.slice(0, -3) : rel;
|
|
20
|
+
files.push(withoutExt);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return files;
|
|
24
|
+
};
|
|
25
|
+
export const listTemplates = () => {
|
|
26
|
+
return walkDir(BASE);
|
|
27
|
+
};
|
|
28
|
+
export const renderTemplate = (name, vars = {}) => {
|
|
29
|
+
const tpl = loadTemplate(name);
|
|
30
|
+
validateTemplateMeta(name, tpl);
|
|
31
|
+
const html = MarkdownRenderer.render(tpl.content, vars);
|
|
32
|
+
return { html, meta: tpl };
|
|
33
|
+
};
|
|
34
|
+
export default { listTemplates, renderTemplate };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const validateTemplateMeta: (name: string, tpl: {
|
|
2
|
+
subject?: string;
|
|
3
|
+
preheader?: string;
|
|
4
|
+
variables?: string[];
|
|
5
|
+
content: string;
|
|
6
|
+
}) => true;
|
|
7
|
+
declare const _default: {
|
|
8
|
+
validateTemplateMeta: (name: string, tpl: {
|
|
9
|
+
subject?: string;
|
|
10
|
+
preheader?: string;
|
|
11
|
+
variables?: string[];
|
|
12
|
+
content: string;
|
|
13
|
+
}) => true;
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
|
16
|
+
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/mail/templates/markdown/validator.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,GAC/B,MAAM,MAAM,EACZ,KAAK;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB,KACA,IA0BF,CAAC;;iCAjCM,MAAM,OACP;QACH,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC;KACjB,KACA,IAAI;;AA4BP,wBAAwC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ErrorFactory } from '../../../../exceptions/ZintrustError';
|
|
2
|
+
export const validateTemplateMeta = (name, tpl) => {
|
|
3
|
+
if (tpl.subject === null || tpl.subject === undefined || tpl.subject.trim() === '') {
|
|
4
|
+
throw ErrorFactory.createValidationError('Template missing subject', { name });
|
|
5
|
+
}
|
|
6
|
+
const placeholders = new Set();
|
|
7
|
+
const rx = /{{\s*([a-zA-Z0-9_.-]+)\s*}}/g;
|
|
8
|
+
let m;
|
|
9
|
+
while ((m = rx.exec(tpl.content)) !== null) {
|
|
10
|
+
placeholders.add(m[1]);
|
|
11
|
+
}
|
|
12
|
+
const metaVars = new Set((tpl.variables ?? []).map((s) => s.trim()).filter(Boolean));
|
|
13
|
+
const missingInContent = Array.from(metaVars).filter((v) => !placeholders.has(v));
|
|
14
|
+
const missingInMeta = Array.from(placeholders).filter((v) => !metaVars.has(v));
|
|
15
|
+
if (missingInContent.length > 0 || missingInMeta.length > 0) {
|
|
16
|
+
throw ErrorFactory.createValidationError('Template variables mismatch', {
|
|
17
|
+
name,
|
|
18
|
+
missingInContent,
|
|
19
|
+
missingInMeta,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
};
|
|
24
|
+
export default { validateTemplateMeta };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
type SentRecord = {
|
|
2
|
+
to: string[];
|
|
3
|
+
subject: string;
|
|
4
|
+
text: string;
|
|
5
|
+
html?: string;
|
|
6
|
+
from?: {
|
|
7
|
+
address?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
};
|
|
10
|
+
attachments?: Array<{
|
|
11
|
+
filename: string;
|
|
12
|
+
content: Buffer;
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
type FakeSendInput = {
|
|
16
|
+
to: string | string[];
|
|
17
|
+
subject: string;
|
|
18
|
+
text: string;
|
|
19
|
+
html?: string;
|
|
20
|
+
from?: {
|
|
21
|
+
address?: string;
|
|
22
|
+
name?: string;
|
|
23
|
+
};
|
|
24
|
+
attachments?: Array<{
|
|
25
|
+
filename: string;
|
|
26
|
+
content: Buffer;
|
|
27
|
+
}>;
|
|
28
|
+
};
|
|
29
|
+
export declare const MailFake: Readonly<{
|
|
30
|
+
_sent: Array<SentRecord>;
|
|
31
|
+
send(input: FakeSendInput): Promise<{
|
|
32
|
+
ok: boolean;
|
|
33
|
+
driver: string;
|
|
34
|
+
}>;
|
|
35
|
+
assertSent(predicate: (r: SentRecord) => boolean): void;
|
|
36
|
+
assertNotSent(predicate: (r: SentRecord) => boolean): void;
|
|
37
|
+
getSent(): SentRecord[];
|
|
38
|
+
reset(): void;
|
|
39
|
+
}>;
|
|
40
|
+
export default MailFake;
|
|
41
|
+
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../../src/tools/mail/testing.ts"],"names":[],"mappings":"AAEA,KAAK,UAAU,GAAG;IAChB,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,WAAW,CAAC,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5D,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,WAAW,CAAC,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5D,CAAC;AAEF,eAAO,MAAM,QAAQ;WACN,KAAK,CAAC,UAAU,CAAC;gBAEZ,aAAa,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;0BAcpD,CAAC,CAAC,EAAE,UAAU,KAAK,OAAO;6BAMvB,CAAC,CAAC,EAAE,UAAU,KAAK,OAAO;;;EAanD,CAAC;AAEH,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
2
|
+
export const MailFake = Object.freeze({
|
|
3
|
+
_sent: [],
|
|
4
|
+
async send(input) {
|
|
5
|
+
const to = Array.isArray(input.to) ? input.to : [input.to];
|
|
6
|
+
this._sent.push({
|
|
7
|
+
to,
|
|
8
|
+
subject: input.subject,
|
|
9
|
+
text: input.text,
|
|
10
|
+
html: input.html,
|
|
11
|
+
from: input.from,
|
|
12
|
+
attachments: input.attachments,
|
|
13
|
+
});
|
|
14
|
+
await Promise.resolve();
|
|
15
|
+
return { ok: true, driver: 'disabled' };
|
|
16
|
+
},
|
|
17
|
+
assertSent(predicate) {
|
|
18
|
+
if (!this._sent.some(predicate)) {
|
|
19
|
+
throw ErrorFactory.createValidationError('Expected a sent mail matching predicate');
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
assertNotSent(predicate) {
|
|
23
|
+
if (this._sent.some(predicate)) {
|
|
24
|
+
throw ErrorFactory.createValidationError('Expected no sent mail matching predicate');
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
getSent() {
|
|
28
|
+
return this._sent.slice();
|
|
29
|
+
},
|
|
30
|
+
reset() {
|
|
31
|
+
this._sent.length = 0;
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
export default MailFake;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface INotificationDriver {
|
|
2
|
+
send(recipient: string, message: string, options?: Record<string, unknown>): Promise<unknown>;
|
|
3
|
+
}
|
|
4
|
+
export type NotificationPayload = {
|
|
5
|
+
recipient: string;
|
|
6
|
+
message: string;
|
|
7
|
+
options?: Record<string, unknown>;
|
|
8
|
+
};
|
|
9
|
+
declare const _default: INotificationDriver;
|
|
10
|
+
export default _default;
|
|
11
|
+
//# sourceMappingURL=Driver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Driver.d.ts","sourceRoot":"","sources":["../../../../src/tools/notification/Driver.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/F;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;wBAE8B,mBAAmB;AAAnD,wBAAoD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notification - Public API entry point
|
|
3
|
+
*
|
|
4
|
+
* A small wrapper over NotificationService to provide the expected module name.
|
|
5
|
+
*/
|
|
6
|
+
export declare const Notification: Readonly<{
|
|
7
|
+
send: (recipient: string, message: string, options?: Record<string, unknown>) => Promise<unknown>;
|
|
8
|
+
listDrivers: () => string[];
|
|
9
|
+
}>;
|
|
10
|
+
export default Notification;
|
|
11
|
+
//# sourceMappingURL=Notification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Notification.d.ts","sourceRoot":"","sources":["../../../../src/tools/notification/Notification.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,eAAO,MAAM,YAAY;;;EAGvB,CAAC;AAEH,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notification - Public API entry point
|
|
3
|
+
*
|
|
4
|
+
* A small wrapper over NotificationService to provide the expected module name.
|
|
5
|
+
*/
|
|
6
|
+
import { NotificationService } from './Service';
|
|
7
|
+
export const Notification = Object.freeze({
|
|
8
|
+
send: NotificationService.send,
|
|
9
|
+
listDrivers: NotificationService.listDrivers,
|
|
10
|
+
});
|
|
11
|
+
export default Notification;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type DriverLike = {
|
|
2
|
+
send(recipient: string, message: string, options?: Record<string, unknown>): Promise<unknown>;
|
|
3
|
+
};
|
|
4
|
+
export declare const NotificationRegistry: Readonly<{
|
|
5
|
+
register(name: string, driver: DriverLike): void;
|
|
6
|
+
get(name: string): DriverLike;
|
|
7
|
+
list(): string[];
|
|
8
|
+
}>;
|
|
9
|
+
export default NotificationRegistry;
|
|
10
|
+
//# sourceMappingURL=Registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Registry.d.ts","sourceRoot":"","sources":["../../../../src/tools/notification/Registry.ts"],"names":[],"mappings":"AAIA,KAAK,UAAU,GAAG;IAChB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/F,CAAC;AAOF,eAAO,MAAM,oBAAoB;mBAChB,MAAM,UAAU,UAAU;cAI/B,MAAM,GAAG,UAAU;YAOrB,MAAM,EAAE;EAGhB,CAAC;AAEH,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
2
|
+
import { ConsoleDriver } from './drivers/Console';
|
|
3
|
+
import { TermiiDriver } from './drivers/Termii';
|
|
4
|
+
const drivers = new Map();
|
|
5
|
+
drivers.set('termii', TermiiDriver);
|
|
6
|
+
drivers.set('console', ConsoleDriver);
|
|
7
|
+
export const NotificationRegistry = Object.freeze({
|
|
8
|
+
register(name, driver) {
|
|
9
|
+
drivers.set(name.toLowerCase(), driver);
|
|
10
|
+
},
|
|
11
|
+
get(name) {
|
|
12
|
+
const key = (name ?? '').toString().trim().toLowerCase();
|
|
13
|
+
const drv = drivers.get(key);
|
|
14
|
+
if (!drv)
|
|
15
|
+
throw ErrorFactory.createConfigError(`Notification driver not registered: ${name}`);
|
|
16
|
+
return drv;
|
|
17
|
+
},
|
|
18
|
+
list() {
|
|
19
|
+
return Array.from(drivers.keys()).sort((a, b) => a.localeCompare(b));
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
export default NotificationRegistry;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Service.d.ts","sourceRoot":"","sources":["../../../../src/tools/notification/Service.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB;oBACR,MAAM,WAAW,MAAM,YAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;mBAYhE,MAAM,EAAE;EAGvB,CAAC;AAEH,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
2
|
+
import { NotificationConfig } from './config';
|
|
3
|
+
import { NotificationRegistry } from './Registry';
|
|
4
|
+
export const NotificationService = Object.freeze({
|
|
5
|
+
async send(recipient, message, options = {}) {
|
|
6
|
+
if (!recipient || typeof recipient !== 'string')
|
|
7
|
+
throw ErrorFactory.createValidationError('Recipient required');
|
|
8
|
+
if (!message || typeof message !== 'string')
|
|
9
|
+
throw ErrorFactory.createValidationError('Message required');
|
|
10
|
+
const driverName = NotificationConfig.getDriver();
|
|
11
|
+
const driver = NotificationRegistry.get(driverName);
|
|
12
|
+
return driver.send(recipient, message, options);
|
|
13
|
+
},
|
|
14
|
+
listDrivers() {
|
|
15
|
+
return NotificationRegistry.list();
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
export default NotificationService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/tools/notification/config.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB;qBACd,MAAM;EACrB,CAAC;AAEH,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseDriver.d.ts","sourceRoot":"","sources":["../../../../../src/tools/notification/drivers/BaseDriver.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;YACP,OAAO,CAAC,OAAO,CAAC;EAI9B,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ErrorFactory } from '../../../exceptions/ZintrustError';
|
|
2
|
+
export const BaseDriver = Object.freeze({
|
|
3
|
+
async send() {
|
|
4
|
+
await Promise.resolve();
|
|
5
|
+
throw ErrorFactory.createConfigError('Notification driver must implement send()');
|
|
6
|
+
},
|
|
7
|
+
});
|
|
8
|
+
export default BaseDriver;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Console.d.ts","sourceRoot":"","sources":["../../../../../src/tools/notification/drivers/Console.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;qBAEV,MAAM,YACR,MAAM,aACN,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC;QAAE,EAAE,EAAE,OAAO,CAAA;KAAE,CAAC;EAU3B,CAAC;AAEH,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const ConsoleDriver = Object.freeze({
|
|
2
|
+
async send(_recipient, _message, _options = {}) {
|
|
3
|
+
// Console driver is for development & simple systems — it should not throw
|
|
4
|
+
// Keep implementation minimal and synchronous-friendly
|
|
5
|
+
// Use out of band logging via ErrorHandler/Logger if required by callers
|
|
6
|
+
// Here we simply return a small payload indicating success
|
|
7
|
+
// Example: { ok: true }
|
|
8
|
+
// NOTE: keep body small to avoid leaking test runner logs
|
|
9
|
+
await Promise.resolve();
|
|
10
|
+
return { ok: true };
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
export default ConsoleDriver;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type SlackConfig = {
|
|
2
|
+
webhookUrl: string;
|
|
3
|
+
};
|
|
4
|
+
export type SlackMessage = Record<string, unknown>;
|
|
5
|
+
export declare const SlackDriver: Readonly<{
|
|
6
|
+
send(config: SlackConfig, payload: SlackMessage): Promise<{
|
|
7
|
+
ok: boolean;
|
|
8
|
+
status?: number;
|
|
9
|
+
}>;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const sendSlackWebhook: (config: SlackConfig, payload: SlackMessage) => Promise<{
|
|
12
|
+
ok: boolean;
|
|
13
|
+
status?: number;
|
|
14
|
+
}>;
|
|
15
|
+
export default SlackDriver;
|
|
16
|
+
//# sourceMappingURL=Slack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Slack.d.ts","sourceRoot":"","sources":["../../../../../src/tools/notification/drivers/Slack.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,WAAW,GAAG;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEnD,eAAO,MAAM,WAAW;iBAEZ,WAAW,WACV,YAAY,GACpB,OAAO,CAAC;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;EAsB5C,CAAC;AAEH,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,WAAW,EACnB,SAAS,YAAY,KACpB,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAsC,CAAC;AAElF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ErrorFactory } from '../../../exceptions/ZintrustError';
|
|
2
|
+
export const SlackDriver = Object.freeze({
|
|
3
|
+
async send(config, payload) {
|
|
4
|
+
const url = config.webhookUrl ?? '';
|
|
5
|
+
if (typeof url !== 'string' || url.trim() === '') {
|
|
6
|
+
throw ErrorFactory.createConfigError('Slack: missing webhook URL');
|
|
7
|
+
}
|
|
8
|
+
const res = await fetch(url, {
|
|
9
|
+
method: 'POST',
|
|
10
|
+
headers: { 'content-type': 'application/json' },
|
|
11
|
+
body: JSON.stringify(payload),
|
|
12
|
+
});
|
|
13
|
+
if (!res.ok) {
|
|
14
|
+
const text = await res.text();
|
|
15
|
+
throw ErrorFactory.createConnectionError(`Slack webhook failed (${res.status})`, {
|
|
16
|
+
status: res.status,
|
|
17
|
+
body: text,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return { ok: true, status: res.status };
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
export const sendSlackWebhook = async (config, payload) => SlackDriver.send(config, payload);
|
|
24
|
+
export default SlackDriver;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Termii SMS Driver (skeleton)
|
|
3
|
+
* - Reads TERMII_API_KEY and TERMII_SENDER from env
|
|
4
|
+
* - POSTs to Termii API endpoint
|
|
5
|
+
*/
|
|
6
|
+
export declare const TermiiDriver: Readonly<{
|
|
7
|
+
send(recipient: string, message: string, options?: Record<string, unknown>): Promise<unknown>;
|
|
8
|
+
}>;
|
|
9
|
+
export default TermiiDriver;
|
|
10
|
+
//# sourceMappingURL=Termii.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Termii.d.ts","sourceRoot":"","sources":["../../../../../src/tools/notification/drivers/Termii.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,YAAY;oBACD,MAAM,WAAW,MAAM,YAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;EA6C/E,CAAC;AAEH,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ErrorFactory } from '../../../exceptions/ZintrustError';
|
|
2
|
+
/**
|
|
3
|
+
* Termii SMS Driver (skeleton)
|
|
4
|
+
* - Reads TERMII_API_KEY and TERMII_SENDER from env
|
|
5
|
+
* - POSTs to Termii API endpoint
|
|
6
|
+
*/
|
|
7
|
+
export const TermiiDriver = Object.freeze({
|
|
8
|
+
async send(recipient, message, options = {}) {
|
|
9
|
+
if (!recipient || typeof recipient !== 'string') {
|
|
10
|
+
throw ErrorFactory.createValidationError('Recipient phone number is required');
|
|
11
|
+
}
|
|
12
|
+
if (!message || typeof message !== 'string') {
|
|
13
|
+
throw ErrorFactory.createValidationError('Message body is required');
|
|
14
|
+
}
|
|
15
|
+
const apiKey = process.env['TERMII_API_KEY'] ?? '';
|
|
16
|
+
const sender = process.env['TERMII_SENDER'] ?? 'Zintrust';
|
|
17
|
+
if (!apiKey) {
|
|
18
|
+
throw ErrorFactory.createConfigError('TERMII_API_KEY is not configured');
|
|
19
|
+
}
|
|
20
|
+
const payload = {
|
|
21
|
+
to: recipient,
|
|
22
|
+
from: sender,
|
|
23
|
+
sms: message,
|
|
24
|
+
api_key: apiKey,
|
|
25
|
+
...options,
|
|
26
|
+
};
|
|
27
|
+
// Use global fetch — tests will mock this
|
|
28
|
+
const url = 'https://api.termii.com/sms/send';
|
|
29
|
+
const res = await globalThis.fetch(url, {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
headers: {
|
|
32
|
+
'Content-Type': 'application/json',
|
|
33
|
+
},
|
|
34
|
+
body: JSON.stringify(payload),
|
|
35
|
+
});
|
|
36
|
+
if (!res.ok) {
|
|
37
|
+
const txt = await res.text().catch(() => '');
|
|
38
|
+
throw ErrorFactory.createTryCatchError(`Termii request failed (${res.status})`, {
|
|
39
|
+
status: res.status,
|
|
40
|
+
body: txt,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const json = await res.json().catch(() => ({}));
|
|
44
|
+
return json;
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
export default TermiiDriver;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type TwilioConfig = {
|
|
2
|
+
accountSid: string;
|
|
3
|
+
authToken: string;
|
|
4
|
+
from: string;
|
|
5
|
+
};
|
|
6
|
+
export type TwilioMessage = {
|
|
7
|
+
to: string;
|
|
8
|
+
body: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const TwilioDriver: Readonly<{
|
|
11
|
+
send(config: TwilioConfig, payload: TwilioMessage): Promise<{
|
|
12
|
+
ok: boolean;
|
|
13
|
+
status?: number;
|
|
14
|
+
}>;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const sendSms: (config: TwilioConfig, payload: TwilioMessage) => Promise<{
|
|
17
|
+
ok: boolean;
|
|
18
|
+
status?: number;
|
|
19
|
+
}>;
|
|
20
|
+
export default TwilioDriver;
|
|
21
|
+
//# sourceMappingURL=Twilio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Twilio.d.ts","sourceRoot":"","sources":["../../../../../src/tools/notification/drivers/Twilio.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAOF,eAAO,MAAM,YAAY;iBAEb,YAAY,WACX,aAAa,GACrB,OAAO,CAAC;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;EA+C5C,CAAC;AAEH,eAAO,MAAM,OAAO,GAClB,QAAQ,YAAY,EACpB,SAAS,aAAa,KACrB,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAuC,CAAC;AAEnF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ErrorFactory } from '../../../exceptions/ZintrustError';
|
|
2
|
+
const buildUrl = (accountSid) => {
|
|
3
|
+
const base = 'https://api.twilio.com/2010-04-01/Accounts/';
|
|
4
|
+
return `${base}${accountSid}/Messages.json`;
|
|
5
|
+
};
|
|
6
|
+
export const TwilioDriver = Object.freeze({
|
|
7
|
+
async send(config, payload) {
|
|
8
|
+
const accountSid = config.accountSid ?? '';
|
|
9
|
+
const authToken = config.authToken ?? '';
|
|
10
|
+
const from = config.from ?? '';
|
|
11
|
+
if (typeof accountSid !== 'string' || accountSid.trim() === '') {
|
|
12
|
+
throw ErrorFactory.createConfigError('Twilio: missing accountSid');
|
|
13
|
+
}
|
|
14
|
+
if (typeof authToken !== 'string' || authToken.trim() === '') {
|
|
15
|
+
throw ErrorFactory.createConfigError('Twilio: missing authToken');
|
|
16
|
+
}
|
|
17
|
+
if (typeof from !== 'string' || from.trim() === '') {
|
|
18
|
+
throw ErrorFactory.createConfigError('Twilio: missing from number');
|
|
19
|
+
}
|
|
20
|
+
if (typeof payload.to !== 'string' || payload.to.trim() === '') {
|
|
21
|
+
throw ErrorFactory.createValidationError('Twilio: missing to number');
|
|
22
|
+
}
|
|
23
|
+
const url = buildUrl(accountSid);
|
|
24
|
+
const params = new URLSearchParams();
|
|
25
|
+
params.append('To', payload.to);
|
|
26
|
+
params.append('From', from);
|
|
27
|
+
params.append('Body', payload.body);
|
|
28
|
+
const basic = Buffer.from(`${accountSid}:${authToken}`).toString('base64');
|
|
29
|
+
const res = await fetch(url, {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
headers: {
|
|
32
|
+
Authorization: `Basic ${basic}`,
|
|
33
|
+
'content-type': 'application/x-www-form-urlencoded',
|
|
34
|
+
},
|
|
35
|
+
body: params.toString(),
|
|
36
|
+
});
|
|
37
|
+
if (!res.ok) {
|
|
38
|
+
const body = await res.text();
|
|
39
|
+
throw ErrorFactory.createConnectionError(`Twilio API failed (${res.status})`, {
|
|
40
|
+
status: res.status,
|
|
41
|
+
body,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return { ok: true, status: res.status };
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
export const sendSms = async (config, payload) => TwilioDriver.send(config, payload);
|
|
48
|
+
export default TwilioDriver;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const loadTemplate: (name: string) => {
|
|
2
|
+
subject?: string;
|
|
3
|
+
content: string;
|
|
4
|
+
variables?: string[];
|
|
5
|
+
};
|
|
6
|
+
export { listTemplates, renderTemplate } from '../../templates/markdown/registry';
|
|
7
|
+
declare const _default: {
|
|
8
|
+
loadTemplate: (name: string) => {
|
|
9
|
+
subject?: string;
|
|
10
|
+
content: string;
|
|
11
|
+
variables?: string[];
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|