@hexagen-monaco/sync 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +33 -0
- package/README.md +181 -0
- package/dist/application/index.d.ts +3 -0
- package/dist/application/index.d.ts.map +1 -0
- package/dist/application/ports/index.d.ts +2 -0
- package/dist/application/ports/index.d.ts.map +1 -0
- package/dist/application/ports/out/architecture-graph-provider.port.d.ts +6 -0
- package/dist/application/ports/out/architecture-graph-provider.port.d.ts.map +1 -0
- package/dist/application/ports/out/file-system.port.d.ts +22 -0
- package/dist/application/ports/out/file-system.port.d.ts.map +1 -0
- package/dist/application/ports/out/generator-config.port.d.ts +51 -0
- package/dist/application/ports/out/generator-config.port.d.ts.map +1 -0
- package/dist/application/ports/out/index.d.ts +9 -0
- package/dist/application/ports/out/index.d.ts.map +1 -0
- package/dist/application/ports/out/linter-report-provider.port.d.ts +6 -0
- package/dist/application/ports/out/linter-report-provider.port.d.ts.map +1 -0
- package/dist/application/ports/out/ownership-registry.port.d.ts +35 -0
- package/dist/application/ports/out/ownership-registry.port.d.ts.map +1 -0
- package/dist/application/ports/out/project-configuration-read.port.d.ts +9 -0
- package/dist/application/ports/out/project-configuration-read.port.d.ts.map +1 -0
- package/dist/application/ports/out/symbol-reference-provider.port.d.ts +10 -0
- package/dist/application/ports/out/symbol-reference-provider.port.d.ts.map +1 -0
- package/dist/application/ports/out/workspace-file-provider.port.d.ts +14 -0
- package/dist/application/ports/out/workspace-file-provider.port.d.ts.map +1 -0
- package/dist/application/use-cases/get-architecture-graph.use-case.d.ts +8 -0
- package/dist/application/use-cases/get-architecture-graph.use-case.d.ts.map +1 -0
- package/dist/application/use-cases/get-linter-report.use-case.d.ts +8 -0
- package/dist/application/use-cases/get-linter-report.use-case.d.ts.map +1 -0
- package/dist/application/use-cases/get-manifest-resource.use-case.d.ts +8 -0
- package/dist/application/use-cases/get-manifest-resource.use-case.d.ts.map +1 -0
- package/dist/application/use-cases/index.d.ts +4 -0
- package/dist/application/use-cases/index.d.ts.map +1 -0
- package/dist/application/use-cases/refactoring-impact.use-case.d.ts +29 -0
- package/dist/application/use-cases/refactoring-impact.use-case.d.ts.map +1 -0
- package/dist/application/use-cases/stub-generation.use-case.d.ts +23 -0
- package/dist/application/use-cases/stub-generation.use-case.d.ts.map +1 -0
- package/dist/arch-linter-bin.d.ts +20 -0
- package/dist/arch-linter-bin.d.ts.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +12149 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/add/index.d.ts +8 -0
- package/dist/commands/add/index.d.ts.map +1 -0
- package/dist/commands/add/validate.d.ts +2 -0
- package/dist/commands/add/validate.d.ts.map +1 -0
- package/dist/commands/arch/add.d.ts +3 -0
- package/dist/commands/arch/add.d.ts.map +1 -0
- package/dist/commands/arch/context/command.d.ts +4 -0
- package/dist/commands/arch/context/command.d.ts.map +1 -0
- package/dist/commands/arch/context/persistence.d.ts +22 -0
- package/dist/commands/arch/context/persistence.d.ts.map +1 -0
- package/dist/commands/arch/context/wizard.d.ts +7 -0
- package/dist/commands/arch/context/wizard.d.ts.map +1 -0
- package/dist/commands/arch/diff.d.ts +3 -0
- package/dist/commands/arch/diff.d.ts.map +1 -0
- package/dist/commands/arch/edit.d.ts +9 -0
- package/dist/commands/arch/edit.d.ts.map +1 -0
- package/dist/commands/arch/index.d.ts +3 -0
- package/dist/commands/arch/index.d.ts.map +1 -0
- package/dist/commands/arch/list.d.ts +2 -0
- package/dist/commands/arch/list.d.ts.map +1 -0
- package/dist/commands/arch/port/persistence.d.ts +28 -0
- package/dist/commands/arch/port/persistence.d.ts.map +1 -0
- package/dist/commands/arch/port.d.ts +4 -0
- package/dist/commands/arch/port.d.ts.map +1 -0
- package/dist/commands/arch/refactor-rename-entity.d.ts +3 -0
- package/dist/commands/arch/refactor-rename-entity.d.ts.map +1 -0
- package/dist/commands/arch/refactor-rename-port.d.ts +3 -0
- package/dist/commands/arch/refactor-rename-port.d.ts.map +1 -0
- package/dist/commands/arch/refactor-rename-use-case.d.ts +3 -0
- package/dist/commands/arch/refactor-rename-use-case.d.ts.map +1 -0
- package/dist/commands/arch/refactor-shared.d.ts +11 -0
- package/dist/commands/arch/refactor-shared.d.ts.map +1 -0
- package/dist/commands/arch/refactor.d.ts +3 -0
- package/dist/commands/arch/refactor.d.ts.map +1 -0
- package/dist/commands/arch/remove/context.d.ts +7 -0
- package/dist/commands/arch/remove/context.d.ts.map +1 -0
- package/dist/commands/arch/remove/port.d.ts +7 -0
- package/dist/commands/arch/remove/port.d.ts.map +1 -0
- package/dist/commands/arch/remove.d.ts +3 -0
- package/dist/commands/arch/remove.d.ts.map +1 -0
- package/dist/commands/arch/validate.d.ts +2 -0
- package/dist/commands/arch/validate.d.ts.map +1 -0
- package/dist/commands/manifest/index.d.ts +3 -0
- package/dist/commands/manifest/index.d.ts.map +1 -0
- package/dist/commands/manifest/split-utils.d.ts +8 -0
- package/dist/commands/manifest/split-utils.d.ts.map +1 -0
- package/dist/commands/manifest/split.d.ts +3 -0
- package/dist/commands/manifest/split.d.ts.map +1 -0
- package/dist/commands/shared/confirm.d.ts +5 -0
- package/dist/commands/shared/confirm.d.ts.map +1 -0
- package/dist/commands/shared/error-formatter.d.ts +7 -0
- package/dist/commands/shared/error-formatter.d.ts.map +1 -0
- package/dist/commands/shared/index.d.ts +15 -0
- package/dist/commands/shared/index.d.ts.map +1 -0
- package/dist/commands/shared/project-root.d.ts +3 -0
- package/dist/commands/shared/project-root.d.ts.map +1 -0
- package/dist/commands/shared/prompt-service.d.ts +15 -0
- package/dist/commands/shared/prompt-service.d.ts.map +1 -0
- package/dist/commands/shared/spinner.d.ts +13 -0
- package/dist/commands/shared/spinner.d.ts.map +1 -0
- package/dist/commands/shared/template-engine-path.d.ts +12 -0
- package/dist/commands/shared/template-engine-path.d.ts.map +1 -0
- package/dist/commands/shared/validation.d.ts +15 -0
- package/dist/commands/shared/validation.d.ts.map +1 -0
- package/dist/commands/shared/yaml-service.d.ts +23 -0
- package/dist/commands/shared/yaml-service.d.ts.map +1 -0
- package/dist/commands/templates/index.d.ts +3 -0
- package/dist/commands/templates/index.d.ts.map +1 -0
- package/dist/commands/templates/info.d.ts +2 -0
- package/dist/commands/templates/info.d.ts.map +1 -0
- package/dist/commands/templates/list.d.ts +2 -0
- package/dist/commands/templates/list.d.ts.map +1 -0
- package/dist/config/barrel-exclusions.d.ts +10 -0
- package/dist/config/barrel-exclusions.d.ts.map +1 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/domain/index.d.ts +5 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/result.d.ts +4 -0
- package/dist/domain/result.d.ts.map +1 -0
- package/dist/domain/services/architectural-boundary-checker.d.ts +18 -0
- package/dist/domain/services/architectural-boundary-checker.d.ts.map +1 -0
- package/dist/domain/services/emission-plan-builder.d.ts +17 -0
- package/dist/domain/services/emission-plan-builder.d.ts.map +1 -0
- package/dist/domain/services/impact-analysis.types.d.ts +24 -0
- package/dist/domain/services/impact-analysis.types.d.ts.map +1 -0
- package/dist/domain/services/impact-request-validator.d.ts +14 -0
- package/dist/domain/services/impact-request-validator.d.ts.map +1 -0
- package/dist/domain/services/index.d.ts +7 -0
- package/dist/domain/services/index.d.ts.map +1 -0
- package/dist/domain/services/layer-classifier.d.ts +4 -0
- package/dist/domain/services/layer-classifier.d.ts.map +1 -0
- package/dist/domain/services/stub-template-resolver.d.ts +16 -0
- package/dist/domain/services/stub-template-resolver.d.ts.map +1 -0
- package/dist/domain/session.d.ts +6 -0
- package/dist/domain/session.d.ts.map +1 -0
- package/dist/domain/stub-templates.d.ts +8 -0
- package/dist/domain/stub-templates.d.ts.map +1 -0
- package/dist/domain/types.d.ts +4 -0
- package/dist/domain/types.d.ts.map +1 -0
- package/dist/fs-utils.d.ts +28 -0
- package/dist/fs-utils.d.ts.map +1 -0
- package/dist/generators/apps-framework-templates.d.ts +4 -0
- package/dist/generators/apps-framework-templates.d.ts.map +1 -0
- package/dist/generators/apps.d.ts +5 -0
- package/dist/generators/apps.d.ts.map +1 -0
- package/dist/generators/architecture-file-templates.d.ts +9 -0
- package/dist/generators/architecture-file-templates.d.ts.map +1 -0
- package/dist/generators/architecture-files.d.ts +5 -0
- package/dist/generators/architecture-files.d.ts.map +1 -0
- package/dist/generators/barrels/index.d.ts +6 -0
- package/dist/generators/barrels/index.d.ts.map +1 -0
- package/dist/generators/barrels/recursive.d.ts +44 -0
- package/dist/generators/barrels/recursive.d.ts.map +1 -0
- package/dist/generators/barrels/utils.d.ts +56 -0
- package/dist/generators/barrels/utils.d.ts.map +1 -0
- package/dist/generators/barrels.d.ts +31 -0
- package/dist/generators/barrels.d.ts.map +1 -0
- package/dist/generators/eslint.d.ts +47 -0
- package/dist/generators/eslint.d.ts.map +1 -0
- package/dist/generators/layer-folders.d.ts +16 -0
- package/dist/generators/layer-folders.d.ts.map +1 -0
- package/dist/generators/migration-assistant.d.ts +7 -0
- package/dist/generators/migration-assistant.d.ts.map +1 -0
- package/dist/generators/migration-audit.d.ts +28 -0
- package/dist/generators/migration-audit.d.ts.map +1 -0
- package/dist/generators/migration-stubs.d.ts +7 -0
- package/dist/generators/migration-stubs.d.ts.map +1 -0
- package/dist/generators/package-json.d.ts +11 -0
- package/dist/generators/package-json.d.ts.map +1 -0
- package/dist/generators/port-analyzer.d.ts +56 -0
- package/dist/generators/port-analyzer.d.ts.map +1 -0
- package/dist/generators/reap.d.ts +11 -0
- package/dist/generators/reap.d.ts.map +1 -0
- package/dist/generators/root-file-templates.d.ts +8 -0
- package/dist/generators/root-file-templates.d.ts.map +1 -0
- package/dist/generators/root-files.d.ts +5 -0
- package/dist/generators/root-files.d.ts.map +1 -0
- package/dist/generators/stubs/index.d.ts +4 -0
- package/dist/generators/stubs/index.d.ts.map +1 -0
- package/dist/generators/stubs/stub-templates.d.ts +3 -0
- package/dist/generators/stubs/stub-templates.d.ts.map +1 -0
- package/dist/generators/stubs.d.ts +5 -0
- package/dist/generators/stubs.d.ts.map +1 -0
- package/dist/generators/test-generator.d.ts +7 -0
- package/dist/generators/test-generator.d.ts.map +1 -0
- package/dist/generators/test-templates/data-builder.d.ts +2 -0
- package/dist/generators/test-templates/data-builder.d.ts.map +1 -0
- package/dist/generators/test-templates/enhanced-test-double.d.ts +2 -0
- package/dist/generators/test-templates/enhanced-test-double.d.ts.map +1 -0
- package/dist/generators/test-templates/index.d.ts +5 -0
- package/dist/generators/test-templates/index.d.ts.map +1 -0
- package/dist/generators/test-templates/integration-test.d.ts +2 -0
- package/dist/generators/test-templates/integration-test.d.ts.map +1 -0
- package/dist/generators/test-templates/unit-test.d.ts +2 -0
- package/dist/generators/test-templates/unit-test.d.ts.map +1 -0
- package/dist/generators/tsconfig.d.ts +16 -0
- package/dist/generators/tsconfig.d.ts.map +1 -0
- package/dist/generators/validators/index.d.ts +11 -0
- package/dist/generators/validators/index.d.ts.map +1 -0
- package/dist/generators/validators/validate-dependencies.d.ts +7 -0
- package/dist/generators/validators/validate-dependencies.d.ts.map +1 -0
- package/dist/generators/validators/validate-manifest-sync.d.ts +5 -0
- package/dist/generators/validators/validate-manifest-sync.d.ts.map +1 -0
- package/dist/generators/validators/validate-port-adapter.d.ts +5 -0
- package/dist/generators/validators/validate-port-adapter.d.ts.map +1 -0
- package/dist/generators/validators/validation-types.d.ts +20 -0
- package/dist/generators/validators/validation-types.d.ts.map +1 -0
- package/dist/generators/validators.d.ts +7 -0
- package/dist/generators/validators.d.ts.map +1 -0
- package/dist/generators/wiring.d.ts +20 -0
- package/dist/generators/wiring.d.ts.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8070 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/adapters/atomic-file-system.adapter.d.ts +13 -0
- package/dist/infrastructure/adapters/atomic-file-system.adapter.d.ts.map +1 -0
- package/dist/infrastructure/adapters/file-system-workspace.adapter.d.ts +12 -0
- package/dist/infrastructure/adapters/file-system-workspace.adapter.d.ts.map +1 -0
- package/dist/infrastructure/adapters/in-memory-config-double.d.ts +30 -0
- package/dist/infrastructure/adapters/in-memory-config-double.d.ts.map +1 -0
- package/dist/infrastructure/adapters/index.d.ts +5 -0
- package/dist/infrastructure/adapters/index.d.ts.map +1 -0
- package/dist/infrastructure/adapters/yaml-config.adapter.d.ts +38 -0
- package/dist/infrastructure/adapters/yaml-config.adapter.d.ts.map +1 -0
- package/dist/infrastructure/index.d.ts +2 -0
- package/dist/infrastructure/index.d.ts.map +1 -0
- package/dist/linter.d.ts +7 -0
- package/dist/linter.d.ts.map +1 -0
- package/dist/loaders/index.d.ts +2 -0
- package/dist/loaders/index.d.ts.map +1 -0
- package/dist/loaders/manifest-merge-loader.d.ts +3 -0
- package/dist/loaders/manifest-merge-loader.d.ts.map +1 -0
- package/dist/lock.d.ts +14 -0
- package/dist/lock.d.ts.map +1 -0
- package/dist/manifest-service.d.ts +10 -0
- package/dist/manifest-service.d.ts.map +1 -0
- package/dist/migration-report.d.ts +12 -0
- package/dist/migration-report.d.ts.map +1 -0
- package/dist/preflight.d.ts +7 -0
- package/dist/preflight.d.ts.map +1 -0
- package/dist/refactoring/git-operations.d.ts +9 -0
- package/dist/refactoring/git-operations.d.ts.map +1 -0
- package/dist/refactoring/impact-analyzer.d.ts +23 -0
- package/dist/refactoring/impact-analyzer.d.ts.map +1 -0
- package/dist/refactoring/index.d.ts +6 -0
- package/dist/refactoring/index.d.ts.map +1 -0
- package/dist/refactoring/refactoring-engine.d.ts +40 -0
- package/dist/refactoring/refactoring-engine.d.ts.map +1 -0
- package/dist/refactoring/refactoring-patterns/base-pattern.d.ts +37 -0
- package/dist/refactoring/refactoring-patterns/base-pattern.d.ts.map +1 -0
- package/dist/refactoring/refactoring-patterns/index.d.ts +5 -0
- package/dist/refactoring/refactoring-patterns/index.d.ts.map +1 -0
- package/dist/refactoring/refactoring-patterns/refactoring-utils.d.ts +8 -0
- package/dist/refactoring/refactoring-patterns/refactoring-utils.d.ts.map +1 -0
- package/dist/refactoring/refactoring-patterns/rename-entity.pattern.d.ts +19 -0
- package/dist/refactoring/refactoring-patterns/rename-entity.pattern.d.ts.map +1 -0
- package/dist/refactoring/refactoring-patterns/rename-port.pattern.d.ts +42 -0
- package/dist/refactoring/refactoring-patterns/rename-port.pattern.d.ts.map +1 -0
- package/dist/refactoring/refactoring-patterns/rename-use-case.pattern.d.ts +40 -0
- package/dist/refactoring/refactoring-patterns/rename-use-case.pattern.d.ts.map +1 -0
- package/dist/refactoring/safe-refactoring-orchestrator.d.ts +24 -0
- package/dist/refactoring/safe-refactoring-orchestrator.d.ts.map +1 -0
- package/dist/refactoring/validation-suite.d.ts +20 -0
- package/dist/refactoring/validation-suite.d.ts.map +1 -0
- package/dist/results.d.ts +16 -0
- package/dist/results.d.ts.map +1 -0
- package/dist/sync-engine-helpers.d.ts +15 -0
- package/dist/sync-engine-helpers.d.ts.map +1 -0
- package/dist/sync-engine-init.d.ts +12 -0
- package/dist/sync-engine-init.d.ts.map +1 -0
- package/dist/sync-engine.d.ts +21 -0
- package/dist/sync-engine.d.ts.map +1 -0
- package/dist/template-engine.d.ts +3 -0
- package/dist/template-engine.d.ts.map +1 -0
- package/dist/templates/__example__/files/example-output.txt +9 -0
- package/dist/templates/__example__/manifest.json +44 -0
- package/dist/templates/adobe-creative-production/README.md +89 -0
- package/dist/templates/adobe-creative-production/files/.env.adobe-creative-production.example +6 -0
- package/dist/templates/adobe-creative-production/files/src/domain/ports/out/creative-production.port.ts +62 -0
- package/dist/templates/adobe-creative-production/files/src/infrastructure/adobe/creative-production/creative-production.adapter.ts +144 -0
- package/dist/templates/adobe-creative-production/manifest.json +25 -0
- package/dist/templates/adobe-express/README.md +85 -0
- package/dist/templates/adobe-express/files/.env.adobe-express.example +7 -0
- package/dist/templates/adobe-express/files/src/domain/ports/out/express.port.ts +47 -0
- package/dist/templates/adobe-express/files/src/infrastructure/adobe/express/express.adapter.ts +155 -0
- package/dist/templates/adobe-express/manifest.json +32 -0
- package/dist/templates/adobe-firefly-composite/README.md +75 -0
- package/dist/templates/adobe-firefly-composite/files/.env.adobe-composite.example +5 -0
- package/dist/templates/adobe-firefly-composite/files/src/domain/ports/out/composite.port.ts +39 -0
- package/dist/templates/adobe-firefly-composite/files/src/infrastructure/adobe/composite/composite.adapter.ts +102 -0
- package/dist/templates/adobe-firefly-composite/manifest.json +32 -0
- package/dist/templates/adobe-firefly-content-tagging/README.md +70 -0
- package/dist/templates/adobe-firefly-content-tagging/files/.env.adobe-content-tagging.example +4 -0
- package/dist/templates/adobe-firefly-content-tagging/files/src/domain/ports/out/content-tagging.port.ts +28 -0
- package/dist/templates/adobe-firefly-content-tagging/files/src/infrastructure/adobe/content-tagging/content-tagging.adapter.ts +120 -0
- package/dist/templates/adobe-firefly-content-tagging/manifest.json +31 -0
- package/dist/templates/adobe-firefly-core/README.md +147 -0
- package/dist/templates/adobe-firefly-core/files/.env.adobe.example +15 -0
- package/dist/templates/adobe-firefly-core/files/src/domain/ports/out/firefly-auth.port.ts +11 -0
- package/dist/templates/adobe-firefly-core/files/src/domain/ports/out/firefly-job.port.ts +50 -0
- package/dist/templates/adobe-firefly-core/files/src/domain/ports/out/firefly-storage.port.ts +20 -0
- package/dist/templates/adobe-firefly-core/files/src/infrastructure/adobe/auth/ims-token-provider.adapter.ts +112 -0
- package/dist/templates/adobe-firefly-core/files/src/infrastructure/adobe/auth/smoke-token.ts +17 -0
- package/dist/templates/adobe-firefly-core/files/src/infrastructure/adobe/errors/firefly-errors.ts +91 -0
- package/dist/templates/adobe-firefly-core/files/src/infrastructure/adobe/http/firefly-client.ts +135 -0
- package/dist/templates/adobe-firefly-core/files/src/infrastructure/adobe/index.ts +46 -0
- package/dist/templates/adobe-firefly-core/files/src/infrastructure/adobe/jobs/job-poller.ts +52 -0
- package/dist/templates/adobe-firefly-core/files/src/infrastructure/adobe/jobs/job-port.ts +149 -0
- package/dist/templates/adobe-firefly-core/files/src/infrastructure/adobe/jobs/job-result.ts +113 -0
- package/dist/templates/adobe-firefly-core/files/src/infrastructure/adobe/jobs/webhook-verifier.ts +67 -0
- package/dist/templates/adobe-firefly-core/files/src/infrastructure/adobe/storage/passthrough-storage.adapter.ts +36 -0
- package/dist/templates/adobe-firefly-core/manifest.json +86 -0
- package/dist/templates/adobe-firefly-custom-models/README.md +96 -0
- package/dist/templates/adobe-firefly-custom-models/files/.env.adobe-custom-models.example +6 -0
- package/dist/templates/adobe-firefly-custom-models/files/src/domain/ports/out/custom-model.port.ts +77 -0
- package/dist/templates/adobe-firefly-custom-models/files/src/infrastructure/adobe/custom-models/firefly-custom-model.adapter.ts +199 -0
- package/dist/templates/adobe-firefly-custom-models/manifest.json +33 -0
- package/dist/templates/adobe-firefly-generate/README.md +86 -0
- package/dist/templates/adobe-firefly-generate/files/.env.adobe-generate.example +5 -0
- package/dist/templates/adobe-firefly-generate/files/src/domain/ports/out/image-generation.port.ts +61 -0
- package/dist/templates/adobe-firefly-generate/files/src/infrastructure/adobe/generate/firefly-generate.adapter.ts +167 -0
- package/dist/templates/adobe-firefly-generate/manifest.json +45 -0
- package/dist/templates/adobe-firefly-media/README.md +99 -0
- package/dist/templates/adobe-firefly-media/files/.env.adobe-media.example +8 -0
- package/dist/templates/adobe-firefly-media/files/src/domain/ports/out/media-generation.port.ts +80 -0
- package/dist/templates/adobe-firefly-media/files/src/infrastructure/adobe/media/firefly-media.adapter.ts +161 -0
- package/dist/templates/adobe-firefly-media/manifest.json +32 -0
- package/dist/templates/adobe-firefly-storage-azure/README.md +88 -0
- package/dist/templates/adobe-firefly-storage-azure/files/.env.adobe-storage-azure.example +9 -0
- package/dist/templates/adobe-firefly-storage-azure/files/src/infrastructure/adobe/storage/azure-blob-presign.adapter.ts +171 -0
- package/dist/templates/adobe-firefly-storage-azure/files/src/infrastructure/adobe/storage/azure-register.ts +15 -0
- package/dist/templates/adobe-firefly-storage-azure/manifest.json +37 -0
- package/dist/templates/adobe-firefly-storage-gcs/README.md +85 -0
- package/dist/templates/adobe-firefly-storage-gcs/files/.env.adobe-storage-gcs.example +8 -0
- package/dist/templates/adobe-firefly-storage-gcs/files/src/infrastructure/adobe/storage/gcs-presign.adapter.ts +100 -0
- package/dist/templates/adobe-firefly-storage-gcs/files/src/infrastructure/adobe/storage/gcs-register.ts +15 -0
- package/dist/templates/adobe-firefly-storage-gcs/manifest.json +33 -0
- package/dist/templates/adobe-firefly-storage-s3/README.md +76 -0
- package/dist/templates/adobe-firefly-storage-s3/files/.env.adobe-storage-s3.example +8 -0
- package/dist/templates/adobe-firefly-storage-s3/files/src/infrastructure/adobe/storage/s3-presign.adapter.ts +109 -0
- package/dist/templates/adobe-firefly-storage-s3/files/src/infrastructure/adobe/storage/s3-register.ts +15 -0
- package/dist/templates/adobe-firefly-storage-s3/manifest.json +31 -0
- package/dist/templates/adobe-firefly-upscale/README.md +68 -0
- package/dist/templates/adobe-firefly-upscale/files/.env.adobe-upscale.example +3 -0
- package/dist/templates/adobe-firefly-upscale/files/src/domain/ports/out/upscale.port.ts +25 -0
- package/dist/templates/adobe-firefly-upscale/files/src/infrastructure/adobe/upscale/upscale.adapter.ts +85 -0
- package/dist/templates/adobe-firefly-upscale/manifest.json +30 -0
- package/dist/templates/adobe-illustrator/README.md +80 -0
- package/dist/templates/adobe-illustrator/files/.env.adobe-illustrator.example +7 -0
- package/dist/templates/adobe-illustrator/files/src/domain/ports/out/illustrator.port.ts +51 -0
- package/dist/templates/adobe-illustrator/files/src/infrastructure/adobe/illustrator/illustrator.adapter.ts +167 -0
- package/dist/templates/adobe-illustrator/manifest.json +38 -0
- package/dist/templates/adobe-ims-spa/README.md +99 -0
- package/dist/templates/adobe-ims-spa/files/.env.adobe-ims.example +12 -0
- package/dist/templates/adobe-ims-spa/files/app/api/auth/callback/route.ts +84 -0
- package/dist/templates/adobe-ims-spa/files/app/api/auth/login/route.ts +30 -0
- package/dist/templates/adobe-ims-spa/files/app/api/auth/logout/route.ts +24 -0
- package/dist/templates/adobe-ims-spa/files/app/api/auth/me/route.ts +18 -0
- package/dist/templates/adobe-ims-spa/files/middleware.ts +74 -0
- package/dist/templates/adobe-ims-spa/files/src/domain/ports/out/ims-auth.port.ts +24 -0
- package/dist/templates/adobe-ims-spa/files/src/infrastructure/auth/adobe-ims/adobe-ims-auth.adapter.ts +71 -0
- package/dist/templates/adobe-ims-spa/files/src/infrastructure/auth/adobe-ims/config.ts +34 -0
- package/dist/templates/adobe-ims-spa/files/src/infrastructure/auth/adobe-ims/ims-client.ts +85 -0
- package/dist/templates/adobe-ims-spa/files/src/infrastructure/auth/adobe-ims/pkce.ts +37 -0
- package/dist/templates/adobe-ims-spa/files/src/infrastructure/auth/adobe-ims/token-store.ts +54 -0
- package/dist/templates/adobe-ims-spa/files/src/infrastructure/auth/adobe-ims/user-profile-mapper.ts +12 -0
- package/dist/templates/adobe-ims-spa/files/src/lib/auth/get-current-user.ts +56 -0
- package/dist/templates/adobe-ims-spa/files/src/lib/auth/require-auth.ts +11 -0
- package/dist/templates/adobe-ims-spa/manifest.json +88 -0
- package/dist/templates/adobe-indesign/README.md +76 -0
- package/dist/templates/adobe-indesign/files/.env.adobe-indesign.example +7 -0
- package/dist/templates/adobe-indesign/files/src/domain/ports/out/indesign.port.ts +43 -0
- package/dist/templates/adobe-indesign/files/src/infrastructure/adobe/indesign/indesign.adapter.ts +160 -0
- package/dist/templates/adobe-indesign/manifest.json +38 -0
- package/dist/templates/adobe-lightroom/README.md +81 -0
- package/dist/templates/adobe-lightroom/files/.env.adobe-lightroom.example +7 -0
- package/dist/templates/adobe-lightroom/files/src/domain/ports/out/lightroom.port.ts +36 -0
- package/dist/templates/adobe-lightroom/files/src/infrastructure/adobe/lightroom/lightroom.adapter.ts +145 -0
- package/dist/templates/adobe-lightroom/manifest.json +39 -0
- package/dist/templates/adobe-photoshop/README.md +87 -0
- package/dist/templates/adobe-photoshop/files/.env.adobe-photoshop.example +7 -0
- package/dist/templates/adobe-photoshop/files/src/domain/ports/out/photoshop-automation.port.ts +60 -0
- package/dist/templates/adobe-photoshop/files/src/infrastructure/adobe/photoshop/photoshop-automation.adapter.ts +180 -0
- package/dist/templates/adobe-photoshop/manifest.json +45 -0
- package/dist/templates/adobe-substance-3d/README.md +88 -0
- package/dist/templates/adobe-substance-3d/files/.env.adobe-substance-3d.example +12 -0
- package/dist/templates/adobe-substance-3d/files/src/domain/ports/out/substance-3d.port.ts +45 -0
- package/dist/templates/adobe-substance-3d/files/src/infrastructure/adobe/substance-3d/substance-3d.adapter.ts +177 -0
- package/dist/templates/adobe-substance-3d/manifest.json +39 -0
- package/dist/templates/agents-md/README.md +55 -0
- package/dist/templates/agents-md/files/.agents/architecture.md +42 -0
- package/dist/templates/agents-md/files/.agents/git.md +30 -0
- package/dist/templates/agents-md/files/.agents/session-log.md +37 -0
- package/dist/templates/agents-md/files/.agents/tech-stack.md +34 -0
- package/dist/templates/agents-md/files/.agents/testing.md +30 -0
- package/dist/templates/agents-md/files/AGENTS.md +97 -0
- package/dist/templates/agents-md/manifest.json +49 -0
- package/dist/templates/auth-mock/README.md +57 -0
- package/dist/templates/auth-mock/files/.env.auth.example +9 -0
- package/dist/templates/auth-mock/files/middleware.ts +28 -0
- package/dist/templates/auth-mock/manifest.json +23 -0
- package/dist/templates/bedrock-agentcore-runtime/README.md +68 -0
- package/dist/templates/bedrock-agentcore-runtime/files/.env.agentcore.example +19 -0
- package/dist/templates/bedrock-agentcore-runtime/files/.github/workflows/deploy-agentcore.yml +100 -0
- package/dist/templates/bedrock-agentcore-runtime/files/Dockerfile.agentcore +33 -0
- package/dist/templates/bedrock-agentcore-runtime/files/agentcore/agentcore.json +16 -0
- package/dist/templates/bedrock-agentcore-runtime/files/agentcore/aws-targets.json +7 -0
- package/dist/templates/bedrock-agentcore-runtime/files/iam/agentcore-runtime-role.policy.json +49 -0
- package/dist/templates/bedrock-agentcore-runtime/files/infra/agentcore-stack.ts +90 -0
- package/dist/templates/bedrock-agentcore-runtime/files/src/infrastructure/agentcore/http/invocations.handler.ts +152 -0
- package/dist/templates/bedrock-agentcore-runtime/files/src/infrastructure/agentcore/http/ping.handler.ts +13 -0
- package/dist/templates/bedrock-agentcore-runtime/files/src/infrastructure/agentcore/http/server.ts +134 -0
- package/dist/templates/bedrock-agentcore-runtime/files/src/infrastructure/agentcore/runtime/payload.ts +63 -0
- package/dist/templates/bedrock-agentcore-runtime/files/src/infrastructure/agentcore/runtime/session.ts +58 -0
- package/dist/templates/bedrock-agentcore-runtime/manifest.json +89 -0
- package/dist/templates/bedrock-agentcore-services/README.md +65 -0
- package/dist/templates/bedrock-agentcore-services/files/.env.agentcore-services.example +20 -0
- package/dist/templates/bedrock-agentcore-services/files/agentcore/agentcore-services.json +14 -0
- package/dist/templates/bedrock-agentcore-services/files/src/domain/ports/out/agent-identity.port.ts +26 -0
- package/dist/templates/bedrock-agentcore-services/files/src/domain/ports/out/agent-memory.port.ts +30 -0
- package/dist/templates/bedrock-agentcore-services/files/src/domain/ports/out/tool-gateway.port.ts +27 -0
- package/dist/templates/bedrock-agentcore-services/files/src/infrastructure/agentcore/gateway/agentcore-gateway.adapter.ts +103 -0
- package/dist/templates/bedrock-agentcore-services/files/src/infrastructure/agentcore/gateway/mcp-tool-mapper.ts +44 -0
- package/dist/templates/bedrock-agentcore-services/files/src/infrastructure/agentcore/identity/agentcore-identity.adapter.ts +82 -0
- package/dist/templates/bedrock-agentcore-services/files/src/infrastructure/agentcore/identity/idp-bridge.ts +74 -0
- package/dist/templates/bedrock-agentcore-services/files/src/infrastructure/agentcore/memory/agentcore-memory.adapter.ts +82 -0
- package/dist/templates/bedrock-agentcore-services/files/src/infrastructure/agentcore/memory/memory-config.ts +45 -0
- package/dist/templates/bedrock-agentcore-services/manifest.json +97 -0
- package/dist/templates/better-auth/README.md +60 -0
- package/dist/templates/better-auth/files/.env.better-auth.example +20 -0
- package/dist/templates/better-auth/files/app/api/auth/[...all]/route.ts +5 -0
- package/dist/templates/better-auth/files/src/db/index.ts +10 -0
- package/dist/templates/better-auth/files/src/db/migrations/0001_better_auth.sql +49 -0
- package/dist/templates/better-auth/files/src/db/schema/better-auth.ts +57 -0
- package/dist/templates/better-auth/files/src/lib/auth-client.ts +13 -0
- package/dist/templates/better-auth/files/src/lib/auth.ts +72 -0
- package/dist/templates/better-auth/manifest.json +71 -0
- package/dist/templates/bullmq/README.md +61 -0
- package/dist/templates/bullmq/files/.env.bullmq.example +34 -0
- package/dist/templates/bullmq/files/app/admin/queues/[[...slug]]/route.ts +103 -0
- package/dist/templates/bullmq/files/scripts/start-worker.ts +55 -0
- package/dist/templates/bullmq/files/server/startup/start-workers.ts +171 -0
- package/dist/templates/bullmq/files/src/infrastructure/queue/connection.ts +105 -0
- package/dist/templates/bullmq/files/src/infrastructure/queue/fallback/sync-executor.ts +96 -0
- package/dist/templates/bullmq/files/src/infrastructure/queue/index.ts +30 -0
- package/dist/templates/bullmq/files/src/infrastructure/queue/jobs/ai-generation.job.ts +53 -0
- package/dist/templates/bullmq/files/src/infrastructure/queue/jobs/email.job.ts +42 -0
- package/dist/templates/bullmq/files/src/infrastructure/queue/jobs/export.job.ts +49 -0
- package/dist/templates/bullmq/files/src/infrastructure/queue/jobs/image-processing.job.ts +48 -0
- package/dist/templates/bullmq/files/src/infrastructure/queue/jobs/webhook.job.ts +139 -0
- package/dist/templates/bullmq/files/src/infrastructure/queue/parse-int-env.ts +28 -0
- package/dist/templates/bullmq/files/src/infrastructure/queue/queues.ts +153 -0
- package/dist/templates/bullmq/files/src/infrastructure/queue/scheduler/job-scheduler.ts +70 -0
- package/dist/templates/bullmq/files/src/infrastructure/queue/workers.ts +101 -0
- package/dist/templates/bullmq/manifest.json +120 -0
- package/dist/templates/ci-github-actions/README.md +62 -0
- package/dist/templates/ci-github-actions/files/.github/dependabot.yml +20 -0
- package/dist/templates/ci-github-actions/files/.github/workflows/ci.yml +103 -0
- package/dist/templates/ci-github-actions/files/.github/workflows/deploy-fly.yml +30 -0
- package/dist/templates/ci-github-actions/files/.github/workflows/deploy-railway.yml +32 -0
- package/dist/templates/ci-github-actions/files/.github/workflows/deploy-vercel.yml +39 -0
- package/dist/templates/ci-github-actions/files/.github/workflows/deploy-vps.yml +34 -0
- package/dist/templates/ci-github-actions/files/.github/workflows/preview.yml +58 -0
- package/dist/templates/ci-github-actions/files/fly.toml +23 -0
- package/dist/templates/ci-github-actions/manifest.json +100 -0
- package/dist/templates/clerk/README.md +59 -0
- package/dist/templates/clerk/files/.env.clerk.example +11 -0
- package/dist/templates/clerk/files/app/(protected)/layout.tsx +18 -0
- package/dist/templates/clerk/files/app/api/protected-example/route.ts +17 -0
- package/dist/templates/clerk/files/middleware.ts +25 -0
- package/dist/templates/clerk/files/src/lib/auth.ts +12 -0
- package/dist/templates/clerk/files/src/lib/role-guard.tsx +32 -0
- package/dist/templates/clerk/manifest.json +67 -0
- package/dist/templates/design-system/README.md +60 -0
- package/dist/templates/design-system/files/.storybook/main.ts +9 -0
- package/dist/templates/design-system/files/.storybook/preview.ts +13 -0
- package/dist/templates/design-system/files/DESIGN.md +76 -0
- package/dist/templates/design-system/files/src/components/ui/button.stories.tsx +17 -0
- package/dist/templates/design-system/files/src/components/ui/button.tsx +61 -0
- package/dist/templates/design-system/files/src/components/ui/card.tsx +40 -0
- package/dist/templates/design-system/files/src/components/ui/index.ts +6 -0
- package/dist/templates/design-system/files/src/components/ui/input.tsx +29 -0
- package/dist/templates/design-system/files/src/lib/cn.ts +13 -0
- package/dist/templates/design-system/files/src/styles/globals.css +37 -0
- package/dist/templates/design-system/files/src/styles/theme.ts +56 -0
- package/dist/templates/design-system/files/src/styles/tokens.css +73 -0
- package/dist/templates/design-system/files/tailwind.config.ts +58 -0
- package/dist/templates/design-system/manifest.json +81 -0
- package/dist/templates/docker/README.md +62 -0
- package/dist/templates/docker/files/.dockerignore +34 -0
- package/dist/templates/docker/files/.github/workflows/docker-build.yml +74 -0
- package/dist/templates/docker/files/Dockerfile +57 -0
- package/dist/templates/docker/files/docker-compose.ci.yml +22 -0
- package/dist/templates/docker/files/docker-compose.override.yml +20 -0
- package/dist/templates/docker/files/docker-compose.yml +109 -0
- package/dist/templates/docker/manifest.json +59 -0
- package/dist/templates/env-setup/README.md +70 -0
- package/dist/templates/env-setup/files/.env.example +28 -0
- package/dist/templates/env-setup/files/.gitignore.hexagen +16 -0
- package/dist/templates/env-setup/files/SETUP.md +70 -0
- package/dist/templates/env-setup/files/scripts/check-env.ts +95 -0
- package/dist/templates/env-setup/files/src/config/env.client.ts +18 -0
- package/dist/templates/env-setup/files/src/config/env.server.ts +49 -0
- package/dist/templates/env-setup/files/src/config/env.ts +14 -0
- package/dist/templates/env-setup/files/src/config/load-env.ts +40 -0
- package/dist/templates/env-setup/manifest.json +55 -0
- package/dist/templates/error-handling/README.md +72 -0
- package/dist/templates/error-handling/files/.env.sentry.example +8 -0
- package/dist/templates/error-handling/files/app/components/ErrorBoundary.tsx +49 -0
- package/dist/templates/error-handling/files/app/components/ErrorFallback.tsx +35 -0
- package/dist/templates/error-handling/files/server/middleware/error-handler.ts +131 -0
- package/dist/templates/error-handling/files/src/application/errors/application.error.ts +33 -0
- package/dist/templates/error-handling/files/src/domain/errors/authorization.error.ts +20 -0
- package/dist/templates/error-handling/files/src/domain/errors/domain.error.ts +23 -0
- package/dist/templates/error-handling/files/src/domain/errors/not-found.error.ts +11 -0
- package/dist/templates/error-handling/files/src/domain/errors/validation.error.ts +17 -0
- package/dist/templates/error-handling/files/src/infrastructure/errors/external-service.error.ts +24 -0
- package/dist/templates/error-handling/files/src/infrastructure/errors/infrastructure.error.ts +22 -0
- package/dist/templates/error-handling/files/src/infrastructure/errors/llm-errors.ts +57 -0
- package/dist/templates/error-handling/files/src/shared/errors/error-codes.ts +29 -0
- package/dist/templates/error-handling/files/src/shared/result.ts +38 -0
- package/dist/templates/error-handling/manifest.json +63 -0
- package/dist/templates/eslint-no-console/README.md +78 -0
- package/dist/templates/eslint-no-console/files/eslint.no-console.mjs +35 -0
- package/dist/templates/eslint-no-console/manifest.json +28 -0
- package/dist/templates/github-oauth/README.md +61 -0
- package/dist/templates/github-oauth/files/.env.github-oauth.example +13 -0
- package/dist/templates/github-oauth/files/app/api/auth/callback/github/route.ts +105 -0
- package/dist/templates/github-oauth/files/app/api/auth/login/github/route.ts +33 -0
- package/dist/templates/github-oauth/files/app/api/auth/logout/github/route.ts +8 -0
- package/dist/templates/github-oauth/files/app/api/auth/me/route.ts +10 -0
- package/dist/templates/github-oauth/files/middleware.ts +59 -0
- package/dist/templates/github-oauth/files/src/infrastructure/auth/github/config.ts +34 -0
- package/dist/templates/github-oauth/files/src/infrastructure/auth/github/github-auth.adapter.ts +12 -0
- package/dist/templates/github-oauth/files/src/infrastructure/auth/github/github-client.ts +95 -0
- package/dist/templates/github-oauth/files/src/infrastructure/auth/github/github-user.ts +8 -0
- package/dist/templates/github-oauth/files/src/infrastructure/auth/github/session-store.ts +56 -0
- package/dist/templates/github-oauth/files/src/infrastructure/auth/github/user-profile-mapper.ts +24 -0
- package/dist/templates/github-oauth/files/src/lib/auth/get-current-user.ts +31 -0
- package/dist/templates/github-oauth/files/src/lib/auth/require-auth.ts +11 -0
- package/dist/templates/github-oauth/manifest.json +83 -0
- package/dist/templates/google-oauth/README.md +70 -0
- package/dist/templates/google-oauth/files/.env.google-oauth.example +14 -0
- package/dist/templates/google-oauth/files/app/api/auth/callback/google/route.ts +78 -0
- package/dist/templates/google-oauth/files/app/api/auth/login/google/route.ts +34 -0
- package/dist/templates/google-oauth/files/app/api/auth/logout/google/route.ts +8 -0
- package/dist/templates/google-oauth/files/app/api/auth/me/route.ts +13 -0
- package/dist/templates/google-oauth/files/middleware.ts +62 -0
- package/dist/templates/google-oauth/files/src/infrastructure/auth/google/config.ts +29 -0
- package/dist/templates/google-oauth/files/src/infrastructure/auth/google/google-auth.adapter.ts +22 -0
- package/dist/templates/google-oauth/files/src/infrastructure/auth/google/google-client.ts +65 -0
- package/dist/templates/google-oauth/files/src/infrastructure/auth/google/google-user.ts +9 -0
- package/dist/templates/google-oauth/files/src/infrastructure/auth/google/session-store.ts +62 -0
- package/dist/templates/google-oauth/files/src/infrastructure/auth/google/user-profile-mapper.ts +24 -0
- package/dist/templates/google-oauth/files/src/lib/auth/get-current-user.ts +36 -0
- package/dist/templates/google-oauth/files/src/lib/auth/require-auth.ts +13 -0
- package/dist/templates/google-oauth/manifest.json +82 -0
- package/dist/templates/langgraph/README.md +60 -0
- package/dist/templates/langgraph/files/.env.langgraph.example +26 -0
- package/dist/templates/langgraph/files/app/api/agent/invoke/route.ts +48 -0
- package/dist/templates/langgraph/files/app/api/agent/resume/route.ts +66 -0
- package/dist/templates/langgraph/files/app/api/agent/stream/route.ts +63 -0
- package/dist/templates/langgraph/files/src/domain/ports/out/agent-graph.port.ts +78 -0
- package/dist/templates/langgraph/files/src/infrastructure/langgraph/adapters/langgraph.adapter.ts +185 -0
- package/dist/templates/langgraph/files/src/infrastructure/langgraph/checkpointers/index.ts +84 -0
- package/dist/templates/langgraph/files/src/infrastructure/langgraph/checkpointers/memory-checkpointer.ts +12 -0
- package/dist/templates/langgraph/files/src/infrastructure/langgraph/checkpointers/postgres-checkpointer.ts +20 -0
- package/dist/templates/langgraph/files/src/infrastructure/langgraph/checkpointers/redis-checkpointer.ts +25 -0
- package/dist/templates/langgraph/files/src/infrastructure/langgraph/checkpointers/supabase-checkpointer.ts +26 -0
- package/dist/templates/langgraph/files/src/infrastructure/langgraph/edges/routing.ts +31 -0
- package/dist/templates/langgraph/files/src/infrastructure/langgraph/graphs/research-agent.graph.ts +81 -0
- package/dist/templates/langgraph/files/src/infrastructure/langgraph/graphs/simple-chain.graph.ts +81 -0
- package/dist/templates/langgraph/files/src/infrastructure/langgraph/index.ts +23 -0
- package/dist/templates/langgraph/files/src/infrastructure/langgraph/nodes/human-review.node.ts +34 -0
- package/dist/templates/langgraph/files/src/infrastructure/langgraph/nodes/input-processor.node.ts +31 -0
- package/dist/templates/langgraph/files/src/infrastructure/langgraph/nodes/llm-call.node.ts +38 -0
- package/dist/templates/langgraph/files/src/infrastructure/langgraph/nodes/output-formatter.node.ts +27 -0
- package/dist/templates/langgraph/files/src/infrastructure/langgraph/nodes/planner.node.ts +51 -0
- package/dist/templates/langgraph/files/src/infrastructure/langgraph/nodes/researcher.node.ts +63 -0
- package/dist/templates/langgraph/files/src/infrastructure/langgraph/nodes/synthesiser.node.ts +62 -0
- package/dist/templates/langgraph/files/src/infrastructure/langgraph/state/graph-state.ts +57 -0
- package/dist/templates/langgraph/files/src/infrastructure/langgraph/streaming/token-stream.ts +84 -0
- package/dist/templates/langgraph/manifest.json +131 -0
- package/dist/templates/llm-adapter/README.md +63 -0
- package/dist/templates/llm-adapter/files/.env.llm.example +49 -0
- package/dist/templates/llm-adapter/files/src/domain/ports/out/llm-client.port.ts +36 -0
- package/dist/templates/llm-adapter/files/src/infrastructure/llm/adapters/anthropic-llm-client.adapter.ts +111 -0
- package/dist/templates/llm-adapter/files/src/infrastructure/llm/adapters/azure-openai-llm-client.adapter.ts +105 -0
- package/dist/templates/llm-adapter/files/src/infrastructure/llm/adapters/ollama-llm-client.adapter.ts +102 -0
- package/dist/templates/llm-adapter/files/src/infrastructure/llm/adapters/openai-llm-client.adapter.ts +104 -0
- package/dist/templates/llm-adapter/files/src/infrastructure/llm/adapters/xai-llm-client.adapter.ts +104 -0
- package/dist/templates/llm-adapter/files/src/infrastructure/llm/constants/capabilities.ts +38 -0
- package/dist/templates/llm-adapter/files/src/infrastructure/llm/constants/models.ts +39 -0
- package/dist/templates/llm-adapter/files/src/infrastructure/llm/errors/llm-errors.ts +83 -0
- package/dist/templates/llm-adapter/files/src/infrastructure/llm/index.ts +39 -0
- package/dist/templates/llm-adapter/files/src/infrastructure/llm/router/llm-router.ts +117 -0
- package/dist/templates/llm-adapter/files/src/infrastructure/llm/router/provider-registry.ts +45 -0
- package/dist/templates/llm-adapter/files/src/infrastructure/llm/smoke-test.ts +25 -0
- package/dist/templates/llm-adapter/files/src/infrastructure/llm/utils/parse-env.ts +8 -0
- package/dist/templates/llm-adapter/files/src/infrastructure/llm/utils/retry.ts +39 -0
- package/dist/templates/llm-adapter/files/src/infrastructure/llm/utils/structured-output.ts +78 -0
- package/dist/templates/llm-adapter/files/src/infrastructure/llm/utils/timeout.ts +22 -0
- package/dist/templates/llm-adapter/manifest.json +113 -0
- package/dist/templates/llm-adapter-bedrock/README.md +58 -0
- package/dist/templates/llm-adapter-bedrock/files/.env.bedrock.example +23 -0
- package/dist/templates/llm-adapter-bedrock/files/src/infrastructure/llm/adapters/bedrock-llm-client.adapter.ts +126 -0
- package/dist/templates/llm-adapter-bedrock/files/src/infrastructure/llm/adapters/bedrock-register.ts +20 -0
- package/dist/templates/llm-adapter-bedrock/files/src/infrastructure/llm/errors/bedrock-errors.ts +42 -0
- package/dist/templates/llm-adapter-bedrock/manifest.json +51 -0
- package/dist/templates/magic-link/README.md +66 -0
- package/dist/templates/magic-link/files/.env.magic-link.example +24 -0
- package/dist/templates/magic-link/files/app/api/auth/logout/route.ts +12 -0
- package/dist/templates/magic-link/files/app/api/auth/magic-link/request/route.ts +34 -0
- package/dist/templates/magic-link/files/app/api/auth/magic-link/verify/route.ts +41 -0
- package/dist/templates/magic-link/files/app/api/auth/me/route.ts +10 -0
- package/dist/templates/magic-link/files/middleware.ts +60 -0
- package/dist/templates/magic-link/files/src/infrastructure/auth/magic-link/config.ts +17 -0
- package/dist/templates/magic-link/files/src/infrastructure/auth/magic-link/email-templates.ts +46 -0
- package/dist/templates/magic-link/files/src/infrastructure/auth/magic-link/email-transport.ts +71 -0
- package/dist/templates/magic-link/files/src/infrastructure/auth/magic-link/magic-link-auth.adapter.ts +11 -0
- package/dist/templates/magic-link/files/src/infrastructure/auth/magic-link/magic-link-store.ts +31 -0
- package/dist/templates/magic-link/files/src/infrastructure/auth/magic-link/session-store.ts +56 -0
- package/dist/templates/magic-link/files/src/infrastructure/auth/magic-link/token-generator.ts +71 -0
- package/dist/templates/magic-link/files/src/infrastructure/auth/magic-link/user-profile-mapper.ts +10 -0
- package/dist/templates/magic-link/files/src/lib/auth/get-current-user.ts +28 -0
- package/dist/templates/magic-link/files/src/lib/auth/require-auth.ts +11 -0
- package/dist/templates/magic-link/manifest.json +99 -0
- package/dist/templates/microsoft-entra/README.md +63 -0
- package/dist/templates/microsoft-entra/files/.env.microsoft-entra.example +17 -0
- package/dist/templates/microsoft-entra/files/app/api/auth/callback/entra/route.ts +93 -0
- package/dist/templates/microsoft-entra/files/app/api/auth/login/entra/route.ts +29 -0
- package/dist/templates/microsoft-entra/files/app/api/auth/logout/entra/route.ts +26 -0
- package/dist/templates/microsoft-entra/files/app/api/auth/me/route.ts +10 -0
- package/dist/templates/microsoft-entra/files/middleware.ts +59 -0
- package/dist/templates/microsoft-entra/files/src/infrastructure/auth/entra/config.ts +43 -0
- package/dist/templates/microsoft-entra/files/src/infrastructure/auth/entra/entra-auth.adapter.ts +14 -0
- package/dist/templates/microsoft-entra/files/src/infrastructure/auth/entra/entra-client.ts +82 -0
- package/dist/templates/microsoft-entra/files/src/infrastructure/auth/entra/entra-user.ts +9 -0
- package/dist/templates/microsoft-entra/files/src/infrastructure/auth/entra/group-role-mapper.ts +22 -0
- package/dist/templates/microsoft-entra/files/src/infrastructure/auth/entra/pkce.ts +20 -0
- package/dist/templates/microsoft-entra/files/src/infrastructure/auth/entra/session-store.ts +56 -0
- package/dist/templates/microsoft-entra/files/src/infrastructure/auth/entra/user-profile-mapper.ts +33 -0
- package/dist/templates/microsoft-entra/files/src/lib/auth/get-current-user.ts +31 -0
- package/dist/templates/microsoft-entra/files/src/lib/auth/require-auth.ts +11 -0
- package/dist/templates/microsoft-entra/manifest.json +93 -0
- package/dist/templates/nextauth/README.md +61 -0
- package/dist/templates/nextauth/files/.env.nextauth.example +16 -0
- package/dist/templates/nextauth/files/app/api/auth/[...nextauth]/route.ts +4 -0
- package/dist/templates/nextauth/files/middleware.ts +17 -0
- package/dist/templates/nextauth/files/src/auth.config.ts +41 -0
- package/dist/templates/nextauth/files/src/auth.ts +67 -0
- package/dist/templates/nextauth/files/types/next-auth.d.ts +16 -0
- package/dist/templates/nextauth/manifest.json +74 -0
- package/dist/templates/observability/README.md +69 -0
- package/dist/templates/observability/files/.env.observability.example +12 -0
- package/dist/templates/observability/files/.env.otel.example +7 -0
- package/dist/templates/observability/files/app/api/health/route.ts +37 -0
- package/dist/templates/observability/files/instrumentation.ts +52 -0
- package/dist/templates/observability/files/server/middleware/request-logger.ts +53 -0
- package/dist/templates/observability/files/src/infrastructure/logging/context.ts +21 -0
- package/dist/templates/observability/files/src/infrastructure/logging/correlation.ts +39 -0
- package/dist/templates/observability/files/src/infrastructure/logging/index.ts +12 -0
- package/dist/templates/observability/files/src/infrastructure/logging/logger.ts +68 -0
- package/dist/templates/observability/files/src/infrastructure/logging/redact.ts +89 -0
- package/dist/templates/observability/manifest.json +57 -0
- package/dist/templates/rate-limiting/README.md +63 -0
- package/dist/templates/rate-limiting/files/.env.rate-limit.example +21 -0
- package/dist/templates/rate-limiting/files/server/errors/rate-limit-exceeded.error.ts +43 -0
- package/dist/templates/rate-limiting/files/server/middleware/rate-limit.ts +79 -0
- package/dist/templates/rate-limiting/files/server/utils/get-client-ip.ts +27 -0
- package/dist/templates/rate-limiting/files/server/utils/rate-limiter.ts +82 -0
- package/dist/templates/rate-limiting/files/server/utils/session-id.ts +28 -0
- package/dist/templates/rate-limiting/files/types/rate-limit.d.ts +12 -0
- package/dist/templates/rate-limiting/manifest.json +66 -0
- package/dist/templates/shared-types/README.md +59 -0
- package/dist/templates/shared-types/files/.env.shared-types.example +14 -0
- package/dist/templates/shared-types/files/src/domain/value-objects/user-context.ts +11 -0
- package/dist/templates/shared-types/files/src/infrastructure/auth/mock-user.ts +16 -0
- package/dist/templates/shared-types/files/src/infrastructure/auth/session/session-manager.ts +59 -0
- package/dist/templates/shared-types/manifest.json +37 -0
- package/dist/templates/supabase/README.md +59 -0
- package/dist/templates/supabase/files/.env.supabase.example +15 -0
- package/dist/templates/supabase/files/drizzle.config.ts +15 -0
- package/dist/templates/supabase/files/scripts/gen-types.sh +9 -0
- package/dist/templates/supabase/files/scripts/migrate.ts +23 -0
- package/dist/templates/supabase/files/src/infrastructure/supabase/admin.ts +23 -0
- package/dist/templates/supabase/files/src/infrastructure/supabase/client.ts +16 -0
- package/dist/templates/supabase/files/src/infrastructure/supabase/drizzle/client.ts +17 -0
- package/dist/templates/supabase/files/src/infrastructure/supabase/drizzle/schema.ts +10 -0
- package/dist/templates/supabase/files/src/infrastructure/supabase/realtime/subscribe.ts +41 -0
- package/dist/templates/supabase/files/src/infrastructure/supabase/result.ts +30 -0
- package/dist/templates/supabase/files/src/infrastructure/supabase/server.ts +28 -0
- package/dist/templates/supabase/files/src/infrastructure/supabase/storage/delete.ts +17 -0
- package/dist/templates/supabase/files/src/infrastructure/supabase/storage/download.ts +17 -0
- package/dist/templates/supabase/files/src/infrastructure/supabase/storage/index.ts +4 -0
- package/dist/templates/supabase/files/src/infrastructure/supabase/storage/signed-url.ts +26 -0
- package/dist/templates/supabase/files/src/infrastructure/supabase/storage/upload.ts +24 -0
- package/dist/templates/supabase/files/src/infrastructure/supabase/types/database.types.ts +10 -0
- package/dist/templates/supabase/files/supabase/migrations/0001_example_rls.sql +23 -0
- package/dist/templates/supabase/files/supabase/seed.sql +7 -0
- package/dist/templates/supabase/manifest.json +133 -0
- package/dist/templates/supabase-auth/README.md +55 -0
- package/dist/templates/supabase-auth/files/app/api/auth/me/route.ts +10 -0
- package/dist/templates/supabase-auth/files/middleware.ts +108 -0
- package/dist/templates/supabase-auth/files/src/lib/auth/get-current-user.ts +46 -0
- package/dist/templates/supabase-auth/files/src/lib/auth/require-auth.ts +11 -0
- package/dist/templates/supabase-auth/manifest.json +40 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/manifest/apps.d.ts +24 -0
- package/dist/types/manifest/apps.d.ts.map +1 -0
- package/dist/types/manifest/bounded-context.d.ts +43 -0
- package/dist/types/manifest/bounded-context.d.ts.map +1 -0
- package/dist/types/manifest/generator.d.ts +51 -0
- package/dist/types/manifest/generator.d.ts.map +1 -0
- package/dist/types/manifest/helpers.d.ts +30 -0
- package/dist/types/manifest/helpers.d.ts.map +1 -0
- package/dist/types/manifest/index.d.ts +8 -0
- package/dist/types/manifest/index.d.ts.map +1 -0
- package/dist/types/manifest/layers.d.ts +32 -0
- package/dist/types/manifest/layers.d.ts.map +1 -0
- package/dist/types/manifest/manifest.d.ts +64 -0
- package/dist/types/manifest/manifest.d.ts.map +1 -0
- package/dist/types/manifest/monorepo.d.ts +94 -0
- package/dist/types/manifest/monorepo.d.ts.map +1 -0
- package/dist/types/manifest.d.ts +2 -0
- package/dist/types/manifest.d.ts.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { betterAuth } from "better-auth";
|
|
2
|
+
import { magicLink } from "better-auth/plugins";
|
|
3
|
+
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
4
|
+
import { db } from "../db";
|
|
5
|
+
import * as schema from "../db/schema/better-auth";
|
|
6
|
+
|
|
7
|
+
// Session lifetime in seconds (from the session_expiry_days answer).
|
|
8
|
+
const SESSION_EXPIRY_SECONDS = Number("{session_expiry_days}") * 24 * 60 * 60;
|
|
9
|
+
|
|
10
|
+
// Providers selected at setup: {providers}.
|
|
11
|
+
// The template engine can't conditionally emit code, so each provider activates
|
|
12
|
+
// at runtime only when its credentials are present — an email/password-only
|
|
13
|
+
// deployment enables no social providers and needs no extra secrets.
|
|
14
|
+
const socialProviders: Record<
|
|
15
|
+
string,
|
|
16
|
+
{ clientId: string; clientSecret: string }
|
|
17
|
+
> = {};
|
|
18
|
+
if (process.env.GOOGLE_CLIENT_ID && process.env.GOOGLE_CLIENT_SECRET) {
|
|
19
|
+
socialProviders.google = {
|
|
20
|
+
clientId: process.env.GOOGLE_CLIENT_ID,
|
|
21
|
+
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if (process.env.GITHUB_CLIENT_ID && process.env.GITHUB_CLIENT_SECRET) {
|
|
25
|
+
socialProviders.github = {
|
|
26
|
+
clientId: process.env.GITHUB_CLIENT_ID,
|
|
27
|
+
clientSecret: process.env.GITHUB_CLIENT_SECRET,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Magic link is opt-in: set BETTER_AUTH_MAGIC_LINK=true after implementing
|
|
32
|
+
// delivery in sendMagicLink() below. Off by default, so it adds no surface.
|
|
33
|
+
const plugins: ReturnType<typeof magicLink>[] = [];
|
|
34
|
+
if (process.env.BETTER_AUTH_MAGIC_LINK === "true") {
|
|
35
|
+
plugins.push(
|
|
36
|
+
magicLink({
|
|
37
|
+
sendMagicLink: () => {
|
|
38
|
+
// TODO: deliver the link via your email transport (e.g. Resend).
|
|
39
|
+
// Rejects until implemented — never log the URL or recipient (PII + bearer token).
|
|
40
|
+
return Promise.reject(
|
|
41
|
+
new Error(
|
|
42
|
+
"Magic link delivery is not configured. Implement sendMagicLink() in src/lib/auth.ts with your email transport.",
|
|
43
|
+
),
|
|
44
|
+
);
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// The single Better Auth server instance. Import { auth } from here in route
|
|
51
|
+
// handlers and server components — never import "better-auth" directly elsewhere.
|
|
52
|
+
//
|
|
53
|
+
// This scaffold targets the "{database}" answer with the Drizzle (PostgreSQL)
|
|
54
|
+
// adapter and the schema in src/db. For Prisma or Kysely, swap the adapter
|
|
55
|
+
// import and regenerate the schema: npx @better-auth/cli generate
|
|
56
|
+
export const auth = betterAuth({
|
|
57
|
+
baseURL: process.env.BETTER_AUTH_URL,
|
|
58
|
+
secret: process.env.BETTER_AUTH_SECRET,
|
|
59
|
+
database: drizzleAdapter(db, { provider: "pg", schema }),
|
|
60
|
+
emailAndPassword: {
|
|
61
|
+
enabled: true,
|
|
62
|
+
},
|
|
63
|
+
socialProviders,
|
|
64
|
+
session: {
|
|
65
|
+
expiresIn: SESSION_EXPIRY_SECONDS,
|
|
66
|
+
},
|
|
67
|
+
// Better Auth's built-in rate limiter (from the rate_limiting answer).
|
|
68
|
+
rateLimit: {
|
|
69
|
+
enabled: "{rate_limiting}" === "true",
|
|
70
|
+
},
|
|
71
|
+
plugins,
|
|
72
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "better-auth",
|
|
3
|
+
"name": "Better Auth",
|
|
4
|
+
"description": "Standalone Better Auth server: email/password + Google/GitHub social providers, magic-link plugin, built-in rate limiting, typed auth client, and core DB schema + migration",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"requires": ["env-setup"],
|
|
7
|
+
"conflicts": [
|
|
8
|
+
"auth-mock",
|
|
9
|
+
"google-oauth",
|
|
10
|
+
"github-oauth",
|
|
11
|
+
"microsoft-entra",
|
|
12
|
+
"magic-link",
|
|
13
|
+
"adobe-ims-spa",
|
|
14
|
+
"nextauth",
|
|
15
|
+
"clerk",
|
|
16
|
+
"supabase-auth"
|
|
17
|
+
],
|
|
18
|
+
"questions": [
|
|
19
|
+
{
|
|
20
|
+
"id": "providers",
|
|
21
|
+
"type": "multiselect",
|
|
22
|
+
"prompt": "Which providers do you plan to use? (social providers activate from env at runtime; magic-link is opt-in via BETTER_AUTH_MAGIC_LINK)",
|
|
23
|
+
"options": ["email-password", "google", "github", "magic-link"],
|
|
24
|
+
"default": ["email-password", "google"]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"id": "database",
|
|
28
|
+
"type": "select",
|
|
29
|
+
"prompt": "Database adapter? (the scaffold ships Drizzle/Postgres; other choices require swapping the adapter import and regenerating the schema)",
|
|
30
|
+
"options": ["drizzle", "prisma", "kysely"],
|
|
31
|
+
"default": "drizzle"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "session_expiry_days",
|
|
35
|
+
"type": "select",
|
|
36
|
+
"prompt": "Session expiry (days)?",
|
|
37
|
+
"options": ["1", "7", "30"],
|
|
38
|
+
"default": "7"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"id": "rate_limiting",
|
|
42
|
+
"type": "boolean",
|
|
43
|
+
"prompt": "Enable Better Auth built-in rate limiting?",
|
|
44
|
+
"default": true
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"envVars": ["BETTER_AUTH_SECRET", "BETTER_AUTH_URL", "DATABASE_URL"],
|
|
48
|
+
"outputs": [
|
|
49
|
+
"src/lib/auth.ts",
|
|
50
|
+
"src/lib/auth-client.ts",
|
|
51
|
+
"src/db/index.ts",
|
|
52
|
+
"app/api/auth/[...all]/route.ts",
|
|
53
|
+
"src/db/schema/better-auth.ts",
|
|
54
|
+
"src/db/migrations/0001_better_auth.sql",
|
|
55
|
+
".env.better-auth.example"
|
|
56
|
+
],
|
|
57
|
+
"checklist": [
|
|
58
|
+
"Install dependencies: npm install better-auth drizzle-orm pg (and npm install -D @types/pg)",
|
|
59
|
+
"Merge .env.better-auth.example into .env.local",
|
|
60
|
+
"Generate BETTER_AUTH_SECRET: openssl rand -hex 32",
|
|
61
|
+
"Set BETTER_AUTH_URL to your deployment URL and DATABASE_URL to your Postgres connection string",
|
|
62
|
+
"The Drizzle/Postgres adapter is already wired in src/lib/auth.ts via src/db/index.ts \u2014 for Prisma/Kysely, swap the adapter import and regenerate the schema",
|
|
63
|
+
"Apply src/db/migrations/0001_better_auth.sql to your database (or run your migration tool); regenerate with npx @better-auth/cli generate if you change adapters",
|
|
64
|
+
"Set GOOGLE_/GITHUB_ credentials for the social providers you want \u2014 each activates automatically when both its vars are present",
|
|
65
|
+
"Magic link is off by default \u2014 implement sendMagicLink() delivery in src/lib/auth.ts, then set BETTER_AUTH_MAGIC_LINK=true to enable it",
|
|
66
|
+
"Built-in rateLimit is enabled per the rate_limiting answer \u2014 if you also add the standalone rate-limiting template, reconcile the two",
|
|
67
|
+
"Standalone framework \u2014 conflicts with all Group A adapters and the other Group B frameworks; use only one auth strategy",
|
|
68
|
+
"Test flow: sign up with email/password, then GET /api/auth/get-session returns the session; social sign-in redirects through /api/auth/*"
|
|
69
|
+
],
|
|
70
|
+
"branch": "feature/generator-template-better-auth"
|
|
71
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# BullMQ (`bullmq`)
|
|
2
|
+
|
|
3
|
+
> Typed BullMQ job queues with workers, a scheduler, a Redis→in-process fallback, an optional
|
|
4
|
+
> Bull Board dashboard, and per-queue routing. For background work too slow for request/response.
|
|
5
|
+
|
|
6
|
+
| | |
|
|
7
|
+
| ------------- | ----------------------------------- |
|
|
8
|
+
| **ID** | `bullmq` |
|
|
9
|
+
| **Category** | Persistence / background jobs |
|
|
10
|
+
| **Requires** | `env-setup` |
|
|
11
|
+
| **Conflicts** | none |
|
|
12
|
+
| **Branch** | `feature/generator-template-bullmq` |
|
|
13
|
+
|
|
14
|
+
Author/agent-facing reference, beside `manifest.json` — not emitted into projects.
|
|
15
|
+
|
|
16
|
+
## What it does
|
|
17
|
+
|
|
18
|
+
Sets up typed queues + workers over Redis, with a graceful fallback to synchronous in-process
|
|
19
|
+
execution when Redis is absent (dev-friendly), a recurring-job scheduler defined in code, and an
|
|
20
|
+
optional admin dashboard. Good for image generation, email, webhooks, exports, AI generation.
|
|
21
|
+
|
|
22
|
+
## What it scaffolds
|
|
23
|
+
|
|
24
|
+
- `src/infrastructure/queue/{connection,queues,workers,index}.ts`, `fallback/sync-executor.ts`,
|
|
25
|
+
`scheduler/job-scheduler.ts`.
|
|
26
|
+
- `server/startup/start-workers.ts` (always emitted), plus `scripts/start-worker.ts` when `worker_mode=separate-service`.
|
|
27
|
+
- Optional Bull Board route; optional example jobs (image-processing/email/webhook/export/ai-generation).
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
`hexagen add bullmq`. Questions: `worker_mode` (`same-process`/`separate-service`), `queue_names`,
|
|
32
|
+
`job_examples` (multiselect), `redis_source`, `concurrency`, `bull_board` (bool).
|
|
33
|
+
|
|
34
|
+
Env: `REDIS_URL`, `REDIS_MAX_RETRIES`, `REDIS_CONNECTION_TIMEOUT_MS`, `BULLMQ_FALLBACK_MODE`,
|
|
35
|
+
`BULLMQ_QUEUE_NAMES`, `WORKER_CONCURRENCY`, `WEBHOOK_FETCH_TIMEOUT_MS`, `BULL_BOARD_*`.
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { addJob } from "@/infrastructure/queue";
|
|
41
|
+
|
|
42
|
+
await addJob("images", "upscale", { inputHref, outputHref }); // routes by job.name to its handler
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Notes for agents
|
|
46
|
+
|
|
47
|
+
- `npm install bullmq ioredis` (+ `@bull-board/nextjs @bull-board/api` if dashboard enabled).
|
|
48
|
+
- `BULLMQ_FALLBACK_MODE=auto` runs without Redis (watch for `[bullmq:fallback]` warnings).
|
|
49
|
+
- Same-process: import `start-workers.ts` at startup. Separate-service: run `scripts/start-worker.ts`
|
|
50
|
+
on a worker machine (don't import the same-process file).
|
|
51
|
+
- Set `BULL_BOARD_USERNAME`/`PASSWORD` before production.
|
|
52
|
+
|
|
53
|
+
## Checklist (post-install)
|
|
54
|
+
|
|
55
|
+
Install deps; merge env; start Redis; choose worker mode + wiring; secure Bull Board; add jobs via
|
|
56
|
+
`addJob`; define recurring jobs in `job-scheduler.ts`.
|
|
57
|
+
|
|
58
|
+
## Related
|
|
59
|
+
|
|
60
|
+
Requires [`env-setup`](../env-setup). Fans out per-asset work for the Adobe Firefly services
|
|
61
|
+
(e.g. [`adobe-lightroom`](../adobe-lightroom)).
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# ─── BullMQ / Redis ───────────────────────────────────────────────────────────
|
|
2
|
+
# Redis connection string. Leave unset (and use BULLMQ_FALLBACK_MODE=auto)
|
|
3
|
+
# to run the queue layer in in-process fallback mode during local dev.
|
|
4
|
+
REDIS_URL=redis://localhost:6379
|
|
5
|
+
|
|
6
|
+
# Connection retry behaviour.
|
|
7
|
+
REDIS_MAX_RETRIES=3
|
|
8
|
+
REDIS_CONNECTION_TIMEOUT_MS=5000
|
|
9
|
+
|
|
10
|
+
# auto — try Redis, fall back to in-process executor if it errors
|
|
11
|
+
# always — force in-process (never connect)
|
|
12
|
+
# never — fail loudly when Redis is unavailable
|
|
13
|
+
BULLMQ_FALLBACK_MODE=auto
|
|
14
|
+
|
|
15
|
+
# Comma-separated queue names. Overrides the install-time default.
|
|
16
|
+
BULLMQ_QUEUE_NAMES={queue_names}
|
|
17
|
+
|
|
18
|
+
# Default per-queue worker concurrency.
|
|
19
|
+
WORKER_CONCURRENCY={concurrency}
|
|
20
|
+
|
|
21
|
+
# Outbound webhook fetch timeout (ms). Caps how long a single attempt waits
|
|
22
|
+
# for the target to respond before aborting; BullMQ then retries per the
|
|
23
|
+
# queue's policy. Only relevant if you installed the webhook example.
|
|
24
|
+
WEBHOOK_FETCH_TIMEOUT_MS=30000
|
|
25
|
+
|
|
26
|
+
# ─── Bull Board dashboard ─────────────────────────────────────────────────────
|
|
27
|
+
# Set BULL_BOARD_ENABLED=false to hide the dashboard entirely.
|
|
28
|
+
BULL_BOARD_ENABLED=true
|
|
29
|
+
BULL_BOARD_BASE_PATH=/admin/queues
|
|
30
|
+
|
|
31
|
+
# Required in production — Basic Auth credentials. Leave blank in dev to
|
|
32
|
+
# expose the dashboard without auth.
|
|
33
|
+
BULL_BOARD_USERNAME=admin
|
|
34
|
+
BULL_BOARD_PASSWORD=
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { timingSafeEqual } from "node:crypto";
|
|
2
|
+
import type { NextRequest } from "next/server";
|
|
3
|
+
import { NextResponse } from "next/server";
|
|
4
|
+
import { createBullBoard } from "@bull-board/api";
|
|
5
|
+
import { BullMQAdapter } from "@bull-board/api/bullMQAdapter";
|
|
6
|
+
import { NextjsAdapter } from "@bull-board/nextjs";
|
|
7
|
+
import { isFallbackActive } from "../../../../src/infrastructure/queue/connection";
|
|
8
|
+
import { QUEUE_NAMES, getQueue } from "../../../../src/infrastructure/queue/queues";
|
|
9
|
+
|
|
10
|
+
// Bull Board dashboard mounted at BULL_BOARD_BASE_PATH (default /admin/queues).
|
|
11
|
+
// In production we require HTTP Basic Auth (BULL_BOARD_USERNAME +
|
|
12
|
+
// BULL_BOARD_PASSWORD); in development the route is open to keep iteration
|
|
13
|
+
// friction down. When the queue layer is in fallback mode there are no real
|
|
14
|
+
// Bull queues to inspect — we return 503 with a hint rather than a confusing
|
|
15
|
+
// empty board.
|
|
16
|
+
|
|
17
|
+
const BASE_PATH = process.env.BULL_BOARD_BASE_PATH ?? "/admin/queues";
|
|
18
|
+
const ENABLED = (process.env.BULL_BOARD_ENABLED ?? "true").toLowerCase() !== "false";
|
|
19
|
+
const USERNAME = process.env.BULL_BOARD_USERNAME ?? "";
|
|
20
|
+
const PASSWORD = process.env.BULL_BOARD_PASSWORD ?? "";
|
|
21
|
+
const IS_PRODUCTION = process.env.NODE_ENV === "production";
|
|
22
|
+
|
|
23
|
+
const serverAdapter = new NextjsAdapter();
|
|
24
|
+
serverAdapter.setBasePath(BASE_PATH);
|
|
25
|
+
|
|
26
|
+
let initialized = false;
|
|
27
|
+
|
|
28
|
+
function init(): void {
|
|
29
|
+
if (initialized) return;
|
|
30
|
+
if (isFallbackActive()) return;
|
|
31
|
+
createBullBoard({
|
|
32
|
+
queues: QUEUE_NAMES.map((n) => new BullMQAdapter(getQueue(n))),
|
|
33
|
+
serverAdapter,
|
|
34
|
+
});
|
|
35
|
+
initialized = true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function unauthorized(): NextResponse {
|
|
39
|
+
return new NextResponse("Unauthorized", {
|
|
40
|
+
status: 401,
|
|
41
|
+
headers: { "WWW-Authenticate": 'Basic realm="bull-board"' },
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Constant-time string comparison. timingSafeEqual requires equal-length
|
|
46
|
+
// buffers; pad / mismatch handling keeps the runtime constant regardless of
|
|
47
|
+
// the inputs so an attacker can't learn the expected username or password
|
|
48
|
+
// length from the response time.
|
|
49
|
+
function safeCompare(a: string, b: string): boolean {
|
|
50
|
+
const aBuf = Buffer.from(a);
|
|
51
|
+
const bBuf = Buffer.from(b);
|
|
52
|
+
if (aBuf.length !== bBuf.length) {
|
|
53
|
+
// Still do a constant-time op on a same-length buffer so the length-
|
|
54
|
+
// mismatch path takes a comparable wall-clock time.
|
|
55
|
+
timingSafeEqual(aBuf, aBuf);
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
return timingSafeEqual(aBuf, bBuf);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function checkAuth(request: NextRequest): NextResponse | null {
|
|
62
|
+
if (!IS_PRODUCTION) return null;
|
|
63
|
+
if (!USERNAME || !PASSWORD) {
|
|
64
|
+
return new NextResponse(
|
|
65
|
+
"Bull Board is disabled: BULL_BOARD_USERNAME and BULL_BOARD_PASSWORD must be set in production.",
|
|
66
|
+
{ status: 503 },
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
const header = request.headers.get("authorization") ?? "";
|
|
70
|
+
if (!header.toLowerCase().startsWith("basic ")) return unauthorized();
|
|
71
|
+
const decoded = Buffer.from(header.slice(6), "base64").toString("utf-8");
|
|
72
|
+
const idx = decoded.indexOf(":");
|
|
73
|
+
if (idx < 0) return unauthorized();
|
|
74
|
+
const user = decoded.slice(0, idx);
|
|
75
|
+
const pass = decoded.slice(idx + 1);
|
|
76
|
+
// Evaluate BOTH sides so a wrong username doesn't short-circuit the
|
|
77
|
+
// password comparison — that asymmetry would leak whether the username
|
|
78
|
+
// was correct via the response time.
|
|
79
|
+
const userOk = safeCompare(user, USERNAME);
|
|
80
|
+
const passOk = safeCompare(pass, PASSWORD);
|
|
81
|
+
if (!userOk || !passOk) return unauthorized();
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function handle(request: NextRequest): Promise<Response> {
|
|
86
|
+
if (!ENABLED) return new NextResponse("Bull Board is disabled.", { status: 404 });
|
|
87
|
+
const authErr = checkAuth(request);
|
|
88
|
+
if (authErr) return authErr;
|
|
89
|
+
if (isFallbackActive()) {
|
|
90
|
+
return new NextResponse(
|
|
91
|
+
"Bull Board: queue layer is running in fallback mode (no Redis). No real queues to display.",
|
|
92
|
+
{ status: 503 },
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
init();
|
|
96
|
+
return serverAdapter.handleRequest(request);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export const GET = handle;
|
|
100
|
+
export const POST = handle;
|
|
101
|
+
export const PUT = handle;
|
|
102
|
+
export const PATCH = handle;
|
|
103
|
+
export const DELETE = handle;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Separate-service worker entrypoint. Run on a dedicated worker dyno /
|
|
3
|
+
* machine / container with:
|
|
4
|
+
*
|
|
5
|
+
* node --import tsx/esm scripts/start-worker.ts
|
|
6
|
+
*
|
|
7
|
+
* This file OWNS its process, so it installs SIGINT/SIGTERM handlers that
|
|
8
|
+
* call `shutdownWorkers()` and exit cleanly. Same-process consumers
|
|
9
|
+
* (Next.js custom server, `instrumentation.ts`) must NOT use this file —
|
|
10
|
+
* they import `bootstrapWorkers` + `shutdownWorkers` from
|
|
11
|
+
* server/startup/start-workers.ts and wire them into the host process's
|
|
12
|
+
* existing lifecycle, so the web server's own graceful shutdown stays in
|
|
13
|
+
* charge of HTTP draining.
|
|
14
|
+
*/
|
|
15
|
+
import {
|
|
16
|
+
bootstrapWorkers,
|
|
17
|
+
shutdownWorkers,
|
|
18
|
+
} from "../server/startup/start-workers";
|
|
19
|
+
|
|
20
|
+
let shuttingDown = false;
|
|
21
|
+
|
|
22
|
+
async function gracefulExit(signal: NodeJS.Signals): Promise<void> {
|
|
23
|
+
if (shuttingDown) return;
|
|
24
|
+
shuttingDown = true;
|
|
25
|
+
// eslint-disable-next-line no-console
|
|
26
|
+
console.log(`[bullmq:worker] ${signal} received, shutting down…`);
|
|
27
|
+
try {
|
|
28
|
+
await shutdownWorkers();
|
|
29
|
+
} catch (err) {
|
|
30
|
+
// eslint-disable-next-line no-console
|
|
31
|
+
console.error("[bullmq:worker] error during shutdown", err);
|
|
32
|
+
}
|
|
33
|
+
process.exit(0);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function main(): Promise<void> {
|
|
37
|
+
// Register signal handlers BEFORE awaiting bootstrap so a SIGINT/SIGTERM
|
|
38
|
+
// received during startup (e.g. a long Redis handshake under a container
|
|
39
|
+
// health-check that decides to kill the worker) still routes through
|
|
40
|
+
// gracefulExit() instead of slamming the process with the default handler.
|
|
41
|
+
for (const signal of ["SIGINT", "SIGTERM"] as const) {
|
|
42
|
+
process.once(signal, () => {
|
|
43
|
+
void gracefulExit(signal);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
await bootstrapWorkers();
|
|
47
|
+
// eslint-disable-next-line no-console
|
|
48
|
+
console.log("[bullmq:worker] up");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
main().catch((err) => {
|
|
52
|
+
// eslint-disable-next-line no-console
|
|
53
|
+
console.error("[bullmq:worker] fatal", err);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
});
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import {
|
|
2
|
+
closeAllQueues,
|
|
3
|
+
disconnectRedis,
|
|
4
|
+
QUEUE_NAMES,
|
|
5
|
+
type QueueName,
|
|
6
|
+
registerFallbackHandler,
|
|
7
|
+
registerJobHandler,
|
|
8
|
+
scheduleRecurringJobs,
|
|
9
|
+
startWorkers,
|
|
10
|
+
stopWorkers,
|
|
11
|
+
} from "../../src/infrastructure/queue";
|
|
12
|
+
|
|
13
|
+
// Same-process worker bootstrap. Wire `bootstrapWorkers()` into your
|
|
14
|
+
// Next.js custom server, `instrumentation.ts`, or wherever your app
|
|
15
|
+
// performs one-time startup. The companion `shutdownWorkers()` is exposed
|
|
16
|
+
// for the host application to invoke during ITS shutdown lifecycle —
|
|
17
|
+
// this file intentionally does NOT install process-level SIGINT/SIGTERM
|
|
18
|
+
// handlers in same-process mode, because doing so hijacks Next.js's
|
|
19
|
+
// graceful HTTP shutdown and drops in-flight requests. The separate-
|
|
20
|
+
// service entrypoint (scripts/start-worker.ts) installs its own signal
|
|
21
|
+
// handlers because it owns the process.
|
|
22
|
+
|
|
23
|
+
interface JobModule {
|
|
24
|
+
jobName: string;
|
|
25
|
+
defaultQueue: string;
|
|
26
|
+
handler: (job: never) => Promise<unknown>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Distinguish "this exact job file isn't installed" from a real init failure
|
|
31
|
+
* (syntax error, missing transitive dep, throwing top-level code) — only the
|
|
32
|
+
* former should be silently skipped. Node's ESM loader reports a missing
|
|
33
|
+
* module as `ERR_MODULE_NOT_FOUND` with the failing specifier in the
|
|
34
|
+
* message, so we accept the error only if BOTH conditions match the
|
|
35
|
+
* job file we tried to import. Any other shape is rethrown so the operator
|
|
36
|
+
* sees the real problem instead of a worker that mysteriously does nothing.
|
|
37
|
+
*/
|
|
38
|
+
function isMissingJobModule(err: unknown, specifier: string): boolean {
|
|
39
|
+
if (!(err instanceof Error)) return false;
|
|
40
|
+
const code = (err as { code?: string }).code;
|
|
41
|
+
if (code !== "ERR_MODULE_NOT_FOUND") return false;
|
|
42
|
+
return err.message.includes(specifier);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function loadOptionalJob(
|
|
46
|
+
specifier: string,
|
|
47
|
+
pick: (m: Record<string, unknown>) => JobModule,
|
|
48
|
+
): Promise<JobModule | null> {
|
|
49
|
+
try {
|
|
50
|
+
const m = (await import(specifier)) as Record<string, unknown>;
|
|
51
|
+
return pick(m);
|
|
52
|
+
} catch (err) {
|
|
53
|
+
if (isMissingJobModule(err, specifier)) return null;
|
|
54
|
+
throw err;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function loadEnabledJobs(): Promise<JobModule[]> {
|
|
59
|
+
// Each block dynamic-imports a job file and is tolerated as missing only
|
|
60
|
+
// when the file genuinely isn't installed. Anything else (syntax error,
|
|
61
|
+
// throwing init code, missing transitive dep) propagates so it surfaces
|
|
62
|
+
// at startup rather than as a silently-disabled handler at runtime.
|
|
63
|
+
const candidates = await Promise.all([
|
|
64
|
+
loadOptionalJob(
|
|
65
|
+
"../../src/infrastructure/queue/jobs/image-processing.job",
|
|
66
|
+
(m) => ({
|
|
67
|
+
jobName: m.IMAGE_PROCESSING_JOB_NAME as string,
|
|
68
|
+
defaultQueue: m.IMAGE_PROCESSING_DEFAULT_QUEUE as string,
|
|
69
|
+
handler: m.processImageProcessingJob as JobModule["handler"],
|
|
70
|
+
}),
|
|
71
|
+
),
|
|
72
|
+
loadOptionalJob(
|
|
73
|
+
"../../src/infrastructure/queue/jobs/email.job",
|
|
74
|
+
(m) => ({
|
|
75
|
+
jobName: m.EMAIL_JOB_NAME as string,
|
|
76
|
+
defaultQueue: m.EMAIL_DEFAULT_QUEUE as string,
|
|
77
|
+
handler: m.processEmailJob as JobModule["handler"],
|
|
78
|
+
}),
|
|
79
|
+
),
|
|
80
|
+
loadOptionalJob(
|
|
81
|
+
"../../src/infrastructure/queue/jobs/webhook.job",
|
|
82
|
+
(m) => ({
|
|
83
|
+
jobName: m.WEBHOOK_JOB_NAME as string,
|
|
84
|
+
defaultQueue: m.WEBHOOK_DEFAULT_QUEUE as string,
|
|
85
|
+
handler: m.processWebhookJob as JobModule["handler"],
|
|
86
|
+
}),
|
|
87
|
+
),
|
|
88
|
+
loadOptionalJob(
|
|
89
|
+
"../../src/infrastructure/queue/jobs/export.job",
|
|
90
|
+
(m) => ({
|
|
91
|
+
jobName: m.EXPORT_JOB_NAME as string,
|
|
92
|
+
defaultQueue: m.EXPORT_DEFAULT_QUEUE as string,
|
|
93
|
+
handler: m.processExportJob as JobModule["handler"],
|
|
94
|
+
}),
|
|
95
|
+
),
|
|
96
|
+
loadOptionalJob(
|
|
97
|
+
"../../src/infrastructure/queue/jobs/ai-generation.job",
|
|
98
|
+
(m) => ({
|
|
99
|
+
jobName: m.AI_GENERATION_JOB_NAME as string,
|
|
100
|
+
defaultQueue: m.AI_GENERATION_DEFAULT_QUEUE as string,
|
|
101
|
+
handler: m.processAIGenerationJob as JobModule["handler"],
|
|
102
|
+
}),
|
|
103
|
+
),
|
|
104
|
+
]);
|
|
105
|
+
return candidates.filter((c): c is JobModule => c !== null);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function pickQueueForJob(job: JobModule): QueueName | null {
|
|
109
|
+
// Prefer the job's declared default queue when it's enabled at runtime;
|
|
110
|
+
// otherwise fall through to the first enabled queue. With QueueName as a
|
|
111
|
+
// literal union we cast the runtime list to string[] for the membership
|
|
112
|
+
// check, then re-narrow on a hit. If there is no enabled queue at all the
|
|
113
|
+
// job is silently skipped — registerHandlers logs that case.
|
|
114
|
+
const names = QUEUE_NAMES as ReadonlyArray<string>;
|
|
115
|
+
if (names.includes(job.defaultQueue)) return job.defaultQueue as QueueName;
|
|
116
|
+
return (QUEUE_NAMES[0] as QueueName | undefined) ?? null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async function registerHandlers(): Promise<void> {
|
|
120
|
+
const jobs = await loadEnabledJobs();
|
|
121
|
+
for (const job of jobs) {
|
|
122
|
+
const queue = pickQueueForJob(job);
|
|
123
|
+
if (queue === null) {
|
|
124
|
+
// eslint-disable-next-line no-console
|
|
125
|
+
console.warn(
|
|
126
|
+
`[bullmq] no enabled queues — skipping handler registration for job '${job.jobName}'.`,
|
|
127
|
+
);
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
registerJobHandler(queue, job.jobName, job.handler);
|
|
131
|
+
registerFallbackHandler(queue, job.jobName, job.handler);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let started = false;
|
|
136
|
+
|
|
137
|
+
export async function bootstrapWorkers(): Promise<void> {
|
|
138
|
+
if (started) return;
|
|
139
|
+
// The flag only flips after the full sequence succeeds. If we set it up
|
|
140
|
+
// front and registerHandlers/startWorkers/scheduleRecurringJobs throws,
|
|
141
|
+
// every retry would short-circuit on `if (started) return` while the
|
|
142
|
+
// process sits in a half-started state — workers spawned but no scheduler,
|
|
143
|
+
// or handlers registered against a queue that never opened a Worker.
|
|
144
|
+
try {
|
|
145
|
+
await registerHandlers();
|
|
146
|
+
startWorkers();
|
|
147
|
+
await scheduleRecurringJobs();
|
|
148
|
+
started = true;
|
|
149
|
+
} catch (error) {
|
|
150
|
+
// Roll back partial state so the next bootstrapWorkers() call can retry
|
|
151
|
+
// from a clean slate. All three rollback steps are swallowed because the
|
|
152
|
+
// original error is what the caller needs to see.
|
|
153
|
+
await stopWorkers().catch(() => undefined);
|
|
154
|
+
await closeAllQueues().catch(() => undefined);
|
|
155
|
+
await disconnectRedis().catch(() => undefined);
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Stop workers + close queues + disconnect Redis. Idempotent. The host
|
|
162
|
+
* application should call this during its own graceful shutdown — see the
|
|
163
|
+
* `instrumentation.ts` pattern in Next.js, or your custom server's exit
|
|
164
|
+
* hook. The separate-service entrypoint installs SIGINT/SIGTERM handlers
|
|
165
|
+
* around this function because it owns the process.
|
|
166
|
+
*/
|
|
167
|
+
export async function shutdownWorkers(): Promise<void> {
|
|
168
|
+
await stopWorkers();
|
|
169
|
+
await closeAllQueues();
|
|
170
|
+
await disconnectRedis();
|
|
171
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import IORedis, { type Redis } from "ioredis";
|
|
2
|
+
import { parseIntEnv } from "./parse-int-env";
|
|
3
|
+
|
|
4
|
+
export { parseIntEnv };
|
|
5
|
+
|
|
6
|
+
// Single Redis connection used by all queues + workers. We probe it once at
|
|
7
|
+
// module load: if the URL is unreachable or REDIS_URL is unset, the queue
|
|
8
|
+
// layer routes addJob() calls to the in-process fallback executor instead
|
|
9
|
+
// of throwing — local dev works without Redis, and a single warning is
|
|
10
|
+
// logged so the mode is visible.
|
|
11
|
+
|
|
12
|
+
const REDIS_URL = process.env.REDIS_URL ?? "";
|
|
13
|
+
const MAX_RETRIES = parseIntEnv("REDIS_MAX_RETRIES", 3, 0);
|
|
14
|
+
const CONNECT_TIMEOUT_MS = parseIntEnv("REDIS_CONNECTION_TIMEOUT_MS", 5000, 1);
|
|
15
|
+
const FALLBACK_MODE = process.env.BULLMQ_FALLBACK_MODE ?? "auto";
|
|
16
|
+
|
|
17
|
+
let connection: Redis | null = null;
|
|
18
|
+
let fallbackActive = false;
|
|
19
|
+
// Logging guards: each side flips the *other* guard on transition so the
|
|
20
|
+
// pair stays in sync (every fallback re-arms the recovery announce; every
|
|
21
|
+
// recovery re-arms the fallback announce).
|
|
22
|
+
let warnedFallback = false;
|
|
23
|
+
let warnedRecovery = false;
|
|
24
|
+
|
|
25
|
+
function announceFallback(reason: string): void {
|
|
26
|
+
if (warnedFallback) return;
|
|
27
|
+
warnedFallback = true;
|
|
28
|
+
warnedRecovery = false;
|
|
29
|
+
// eslint-disable-next-line no-console
|
|
30
|
+
console.warn(
|
|
31
|
+
`[bullmq:fallback] Redis unavailable (${reason}) — running jobs synchronously in-process. Set BULLMQ_FALLBACK_MODE=never to disable.`,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function announceRecovery(): void {
|
|
36
|
+
if (warnedRecovery) return;
|
|
37
|
+
warnedRecovery = true;
|
|
38
|
+
warnedFallback = false;
|
|
39
|
+
// eslint-disable-next-line no-console
|
|
40
|
+
console.info(
|
|
41
|
+
"[bullmq:fallback] Redis recovered — resuming real BullMQ queues.",
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// "never" forces real Redis even if it errors; "always" forces fallback.
|
|
46
|
+
// "auto" (default) tries Redis once and falls back on failure.
|
|
47
|
+
if (FALLBACK_MODE === "always") {
|
|
48
|
+
fallbackActive = true;
|
|
49
|
+
} else if (!REDIS_URL && FALLBACK_MODE === "auto") {
|
|
50
|
+
fallbackActive = true;
|
|
51
|
+
announceFallback("REDIS_URL not set");
|
|
52
|
+
} else if (REDIS_URL) {
|
|
53
|
+
try {
|
|
54
|
+
connection = new IORedis(REDIS_URL, {
|
|
55
|
+
maxRetriesPerRequest: null, // BullMQ requires null here
|
|
56
|
+
enableReadyCheck: true,
|
|
57
|
+
connectTimeout: CONNECT_TIMEOUT_MS,
|
|
58
|
+
retryStrategy: (times) => (times >= MAX_RETRIES ? null : Math.min(times * 200, 2000)),
|
|
59
|
+
});
|
|
60
|
+
connection.on("error", (err) => {
|
|
61
|
+
if (FALLBACK_MODE === "auto") {
|
|
62
|
+
fallbackActive = true;
|
|
63
|
+
announceFallback(err.message);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
// Recover from a transient blip: when ioredis reconnects (after a
|
|
67
|
+
// socket drop / Redis restart / network flake), clear fallback so
|
|
68
|
+
// addJob() resumes pushing to BullMQ instead of permanently degrading
|
|
69
|
+
// to in-process execution until process restart.
|
|
70
|
+
const onUp = () => {
|
|
71
|
+
if (FALLBACK_MODE === "auto" && fallbackActive) {
|
|
72
|
+
fallbackActive = false;
|
|
73
|
+
announceRecovery();
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
connection.on("ready", onUp);
|
|
77
|
+
connection.on("connect", onUp);
|
|
78
|
+
} catch (err) {
|
|
79
|
+
if (FALLBACK_MODE === "auto") {
|
|
80
|
+
fallbackActive = true;
|
|
81
|
+
announceFallback(err instanceof Error ? err.message : String(err));
|
|
82
|
+
} else {
|
|
83
|
+
throw err;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function getRedisConnection(): Redis | null {
|
|
89
|
+
return connection;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function isRedisAvailable(): boolean {
|
|
93
|
+
return connection !== null && !fallbackActive;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function isFallbackActive(): boolean {
|
|
97
|
+
return fallbackActive;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export async function disconnectRedis(): Promise<void> {
|
|
101
|
+
if (connection) {
|
|
102
|
+
await connection.quit().catch(() => undefined);
|
|
103
|
+
connection = null;
|
|
104
|
+
}
|
|
105
|
+
}
|