@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,27 @@
|
|
|
1
|
+
// @generated by @hexagen/sync — rate-limiting template
|
|
2
|
+
|
|
3
|
+
// Set RATE_LIMIT_TRUST_PROXY=true only when a trusted reverse proxy (e.g. Nginx,
|
|
4
|
+
// Cloudflare, AWS ALB) unconditionally overwrites X-Forwarded-For. In direct-to-app
|
|
5
|
+
// or untrusted-proxy deployments leave it false (the default) — otherwise clients
|
|
6
|
+
// can spoof the header to rotate identities and bypass IP-based rate limiting.
|
|
7
|
+
const TRUST_PROXY = process.env.RATE_LIMIT_TRUST_PROXY === "true";
|
|
8
|
+
|
|
9
|
+
export function getClientIp(
|
|
10
|
+
headers: Record<string, string | string[] | undefined>,
|
|
11
|
+
remoteAddress?: string,
|
|
12
|
+
): string {
|
|
13
|
+
const socketAddr = (remoteAddress ?? "unknown").replace(/^::ffff:/, "");
|
|
14
|
+
|
|
15
|
+
if (TRUST_PROXY) {
|
|
16
|
+
const forwarded = headers["x-forwarded-for"];
|
|
17
|
+
if (forwarded) {
|
|
18
|
+
const raw = Array.isArray(forwarded) ? forwarded[0] : forwarded;
|
|
19
|
+
return raw
|
|
20
|
+
.split(",")[0]
|
|
21
|
+
.trim()
|
|
22
|
+
.replace(/^::ffff:/, "");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return socketAddr;
|
|
27
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// @generated by @hexagen/sync — rate-limiting template
|
|
2
|
+
// Redis-backed: {redis_backed}
|
|
3
|
+
// When true, replace the in-memory store with an ioredis INCR+EXPIREAT implementation
|
|
4
|
+
// and add REDIS_URL to your .env.local.
|
|
5
|
+
import type {
|
|
6
|
+
RateLimitBucket,
|
|
7
|
+
RateLimitResult,
|
|
8
|
+
} from "../../types/rate-limit.js";
|
|
9
|
+
|
|
10
|
+
const WINDOW_MS = 60_000;
|
|
11
|
+
|
|
12
|
+
interface WindowEntry {
|
|
13
|
+
count: number;
|
|
14
|
+
resetAt: number; // Unix seconds
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const store = new Map<string, WindowEntry>();
|
|
18
|
+
|
|
19
|
+
const LIMITS: Record<RateLimitBucket, number> = {
|
|
20
|
+
text: Number(process.env.TEXT_RPM ?? 40),
|
|
21
|
+
image: Number(process.env.IMAGE_RPM ?? 12),
|
|
22
|
+
general: Number(process.env.GENERAL_RPM ?? 60),
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const WARN_AT = Number(process.env.RATE_LIMIT_WARN_AT ?? 0.8);
|
|
26
|
+
const DEBUG = process.env.RATE_LIMIT_DEBUG === "true";
|
|
27
|
+
|
|
28
|
+
export function checkRateLimit(
|
|
29
|
+
clientId: string,
|
|
30
|
+
bucket: RateLimitBucket,
|
|
31
|
+
): RateLimitResult {
|
|
32
|
+
const key = `${clientId}:${bucket}`;
|
|
33
|
+
const now = Date.now();
|
|
34
|
+
const resetAt = Math.ceil((now + WINDOW_MS) / 1000);
|
|
35
|
+
const limit = LIMITS[bucket];
|
|
36
|
+
|
|
37
|
+
let entry = store.get(key);
|
|
38
|
+
if (!entry || now >= entry.resetAt * 1000) {
|
|
39
|
+
entry = { count: 0, resetAt };
|
|
40
|
+
store.set(key, entry);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
entry.count += 1;
|
|
44
|
+
const remaining = Math.max(0, limit - entry.count);
|
|
45
|
+
const allowed = entry.count <= limit;
|
|
46
|
+
|
|
47
|
+
if (DEBUG) {
|
|
48
|
+
const pct = entry.count / limit;
|
|
49
|
+
if (!allowed) {
|
|
50
|
+
// eslint-disable-next-line no-console -- DEBUG-gated rate-limit diagnostic
|
|
51
|
+
console.log(
|
|
52
|
+
`[rate-limit:block] clientId=${clientId} bucket=${bucket} limit=${limit} resetAt=${entry.resetAt}`,
|
|
53
|
+
);
|
|
54
|
+
} else if (pct >= WARN_AT) {
|
|
55
|
+
// eslint-disable-next-line no-console -- DEBUG-gated rate-limit diagnostic
|
|
56
|
+
console.log(
|
|
57
|
+
`[rate-limit:warn] clientId=${clientId} bucket=${bucket} at ${entry.count}/${limit} (${Math.round(pct * 100)}%)`,
|
|
58
|
+
);
|
|
59
|
+
} else {
|
|
60
|
+
// eslint-disable-next-line no-console -- DEBUG-gated rate-limit diagnostic
|
|
61
|
+
console.log(
|
|
62
|
+
`[rate-limit] clientId=${clientId} bucket=${bucket} remaining=${remaining}/${limit}`,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return { allowed, bucket, limit, remaining, resetAt: entry.resetAt };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Purge expired entries to prevent unbounded memory growth
|
|
71
|
+
if (typeof setInterval !== "undefined") {
|
|
72
|
+
const cleanupInterval = setInterval(() => {
|
|
73
|
+
const now = Date.now();
|
|
74
|
+
for (const [key, entry] of store) {
|
|
75
|
+
if (now >= entry.resetAt * 1000) store.delete(key);
|
|
76
|
+
}
|
|
77
|
+
}, WINDOW_MS);
|
|
78
|
+
// unref() is not available in all runtimes (e.g. edge, serverless)
|
|
79
|
+
if (typeof (cleanupInterval as { unref?: unknown }).unref === "function") {
|
|
80
|
+
(cleanupInterval as NodeJS.Timeout).unref();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// @generated by @hexagen/sync — rate-limiting template
|
|
2
|
+
import crypto from "node:crypto";
|
|
3
|
+
|
|
4
|
+
const COOKIE_NAME = "{session_cookie_name}";
|
|
5
|
+
const SESSION_TTL = Number(process.env.RATE_LIMIT_SESSION_TTL ?? 604_800);
|
|
6
|
+
const IS_PROD = process.env.NODE_ENV === "production";
|
|
7
|
+
|
|
8
|
+
export function getOrCreateSessionId(
|
|
9
|
+
getCookie: (name: string) => string | undefined,
|
|
10
|
+
setCookie: (
|
|
11
|
+
name: string,
|
|
12
|
+
value: string,
|
|
13
|
+
options: Record<string, unknown>,
|
|
14
|
+
) => void,
|
|
15
|
+
): string {
|
|
16
|
+
const existing = getCookie(COOKIE_NAME);
|
|
17
|
+
if (existing) return existing;
|
|
18
|
+
|
|
19
|
+
const id = crypto.randomUUID();
|
|
20
|
+
setCookie(COOKIE_NAME, id, {
|
|
21
|
+
httpOnly: true,
|
|
22
|
+
sameSite: "lax",
|
|
23
|
+
secure: IS_PROD,
|
|
24
|
+
maxAge: SESSION_TTL,
|
|
25
|
+
path: "/",
|
|
26
|
+
});
|
|
27
|
+
return id;
|
|
28
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @generated by @hexagen/sync — rate-limiting template
|
|
2
|
+
// Framework: {framework}
|
|
3
|
+
|
|
4
|
+
export type RateLimitBucket = "text" | "image" | "general";
|
|
5
|
+
|
|
6
|
+
export interface RateLimitResult {
|
|
7
|
+
allowed: boolean;
|
|
8
|
+
bucket: RateLimitBucket;
|
|
9
|
+
limit: number;
|
|
10
|
+
remaining: number;
|
|
11
|
+
resetAt: number; // Unix timestamp (seconds)
|
|
12
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "rate-limiting",
|
|
3
|
+
"name": "Rate Limiting",
|
|
4
|
+
"description": "Differentiated middleware (text/image/general), session+IP hybrid identification, configurable limits, debug logging",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"requires": ["env-setup"],
|
|
7
|
+
"conflicts": [],
|
|
8
|
+
"questions": [
|
|
9
|
+
{
|
|
10
|
+
"id": "framework",
|
|
11
|
+
"type": "select",
|
|
12
|
+
"prompt": "Which server framework?",
|
|
13
|
+
"options": ["nitro", "nextjs-api", "express", "fastify"],
|
|
14
|
+
"default": "nitro"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "session_cookie_name",
|
|
18
|
+
"type": "text",
|
|
19
|
+
"prompt": "Session cookie name?",
|
|
20
|
+
"default": "__session"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"id": "differentiated",
|
|
24
|
+
"type": "boolean",
|
|
25
|
+
"prompt": "Differentiate limits by request type (text/image/general)?",
|
|
26
|
+
"default": true
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": "debug_logging",
|
|
30
|
+
"type": "boolean",
|
|
31
|
+
"prompt": "Enable proximity-to-limit debug logging?",
|
|
32
|
+
"default": true
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"id": "redis_backed",
|
|
36
|
+
"type": "boolean",
|
|
37
|
+
"prompt": "Use Redis for distributed rate limiting (multi-instance)?",
|
|
38
|
+
"default": false
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"envVars": [
|
|
42
|
+
"TEXT_RPM",
|
|
43
|
+
"IMAGE_RPM",
|
|
44
|
+
"GENERAL_RPM",
|
|
45
|
+
"RATE_LIMIT_WARN_AT",
|
|
46
|
+
"RATE_LIMIT_SESSION_TTL",
|
|
47
|
+
"RATE_LIMIT_DEBUG",
|
|
48
|
+
"RATE_LIMIT_TRUST_PROXY"
|
|
49
|
+
],
|
|
50
|
+
"outputs": [
|
|
51
|
+
"server/middleware/rate-limit.ts",
|
|
52
|
+
"server/utils/rate-limiter.ts",
|
|
53
|
+
"server/utils/get-client-ip.ts",
|
|
54
|
+
"server/utils/session-id.ts",
|
|
55
|
+
"server/errors/rate-limit-exceeded.error.ts",
|
|
56
|
+
"types/rate-limit.d.ts",
|
|
57
|
+
".env.rate-limit.example"
|
|
58
|
+
],
|
|
59
|
+
"checklist": [
|
|
60
|
+
"Merge .env.rate-limit.example into your .env.local",
|
|
61
|
+
"Set TEXT_RPM=40 and IMAGE_RPM=12 for xAI free tier",
|
|
62
|
+
"Open DevTools → Application → Cookies — confirm __session is set on first request",
|
|
63
|
+
"Set RATE_LIMIT_DEBUG=true during local testing to see limit proximity logs"
|
|
64
|
+
],
|
|
65
|
+
"branch": "feature/generator-template-rate-limiting"
|
|
66
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Shared Types (`shared-types`)
|
|
2
|
+
|
|
3
|
+
> The auth-ecosystem foundation: the `UserContext` domain type, a runtime-overridable
|
|
4
|
+
> `MOCK_USER`, and generic AES-256-GCM session-cookie helpers (incl. the canonical
|
|
5
|
+
> `COOKIE_NAME`). Carries no opinion about mock vs. real auth.
|
|
6
|
+
|
|
7
|
+
| | |
|
|
8
|
+
| ------------- | ------------------------------------------ |
|
|
9
|
+
| **ID** | `shared-types` |
|
|
10
|
+
| **Category** | Foundation (auth) |
|
|
11
|
+
| **Requires** | `env-setup` |
|
|
12
|
+
| **Conflicts** | none |
|
|
13
|
+
| **Branch** | `feature/shared-types-and-derived-answers` |
|
|
14
|
+
|
|
15
|
+
Author/agent-facing reference, beside `manifest.json` — not emitted into projects.
|
|
16
|
+
|
|
17
|
+
## What it does
|
|
18
|
+
|
|
19
|
+
Defines the shape every auth provider speaks (`UserContext`: id, email, name, roles,
|
|
20
|
+
avatarUrl) plus the shared session-cookie machinery, so `auth-mock` and every real provider
|
|
21
|
+
build on one contract instead of re-deriving it.
|
|
22
|
+
|
|
23
|
+
## What it scaffolds
|
|
24
|
+
|
|
25
|
+
- `src/domain/value-objects/user-context.ts` — the domain-owned `UserContext`.
|
|
26
|
+
- `src/infrastructure/auth/mock-user.ts` — `MOCK_USER` (env-overridable defaults).
|
|
27
|
+
- `src/infrastructure/auth/session/session-manager.ts` — AES-256-GCM cookie helpers + `COOKIE_NAME`.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
`hexagen add shared-types`. Question: `session_cookie_name` (default `__auth_session`).
|
|
32
|
+
|
|
33
|
+
Env: `AUTH_COOKIE_NAME`, `AUTH_SESSION_MAX_AGE`, `MOCK_USER_ID`, `MOCK_USER_NAME`,
|
|
34
|
+
`MOCK_USER_EMAIL`, `MOCK_USER_ROLES`, `MOCK_USER_AVATAR_URL`.
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import type { UserContext } from "@/domain/value-objects/user-context";
|
|
40
|
+
import { COOKIE_NAME } from "@/infrastructure/auth/session/session-manager";
|
|
41
|
+
import { MOCK_USER } from "@/infrastructure/auth/mock-user";
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Notes for agents
|
|
45
|
+
|
|
46
|
+
- **Import `COOKIE_NAME` from `session-manager` — never re-derive it** in provider code.
|
|
47
|
+
- `MOCK_USER` defaults are hardcoded but overridable at runtime via `MOCK_USER_*` env vars.
|
|
48
|
+
- This template is auth-agnostic; the mock vs. real decision lives in `auth-mock` and the providers.
|
|
49
|
+
|
|
50
|
+
## Checklist (post-install)
|
|
51
|
+
|
|
52
|
+
`UserContext` is the shared shape; `MOCK_USER` overrides via env; import `COOKIE_NAME` from
|
|
53
|
+
`session-manager`.
|
|
54
|
+
|
|
55
|
+
## Related
|
|
56
|
+
|
|
57
|
+
Prerequisite for [`auth-mock`](../auth-mock), `google-oauth`, `github-oauth`,
|
|
58
|
+
`microsoft-entra`, `magic-link`, `supabase-auth`, `adobe-ims-spa`. Requires
|
|
59
|
+
[`env-setup`](../env-setup).
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# ─── Session cookie ───────────────────────────────────────────────────────────
|
|
2
|
+
# Used by session-manager.ts's cookie helpers. AUTH_COOKIE_NAME overrides the
|
|
3
|
+
# install-time default; AUTH_SESSION_MAX_AGE is in seconds (7d = 604800).
|
|
4
|
+
AUTH_COOKIE_NAME={session_cookie_name}
|
|
5
|
+
AUTH_SESSION_MAX_AGE=604800
|
|
6
|
+
|
|
7
|
+
# ─── Mock user (used by auth-mock middleware + getCurrentUser short-circuits) ─
|
|
8
|
+
# These override the static defaults in src/infrastructure/auth/mock-user.ts.
|
|
9
|
+
# Leave them unset to use the defaults ("Demo User" / "demo@example.com" / etc.).
|
|
10
|
+
MOCK_USER_ID=
|
|
11
|
+
MOCK_USER_NAME=
|
|
12
|
+
MOCK_USER_EMAIL=
|
|
13
|
+
MOCK_USER_ROLES=
|
|
14
|
+
MOCK_USER_AVATAR_URL=
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface UserContext {
|
|
2
|
+
readonly id: string;
|
|
3
|
+
readonly email: string;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly roles: ReadonlyArray<string>;
|
|
6
|
+
readonly avatarUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function hasRole(user: UserContext, role: string): boolean {
|
|
10
|
+
return user.roles.includes(role);
|
|
11
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { UserContext } from "../../domain/value-objects/user-context";
|
|
2
|
+
|
|
3
|
+
// Development-mode user identity. Static defaults — runtime overrides via
|
|
4
|
+
// MOCK_USER_* env vars. These are dev helpers, not configuration; embedding
|
|
5
|
+
// them as install-time prompts forces every production OAuth installer to
|
|
6
|
+
// answer questions about a mock user they will never use.
|
|
7
|
+
export const MOCK_USER: UserContext = {
|
|
8
|
+
id: process.env.MOCK_USER_ID ?? "00000000-0000-0000-0000-000000000001",
|
|
9
|
+
name: process.env.MOCK_USER_NAME ?? "Demo User",
|
|
10
|
+
email: process.env.MOCK_USER_EMAIL ?? "demo@example.com",
|
|
11
|
+
roles: (process.env.MOCK_USER_ROLES ?? "user")
|
|
12
|
+
.split(",")
|
|
13
|
+
.map((r) => r.trim())
|
|
14
|
+
.filter(Boolean),
|
|
15
|
+
avatarUrl: process.env.MOCK_USER_AVATAR_URL,
|
|
16
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// The canonical session-cookie name resolver. Provider code should import this
|
|
2
|
+
// constant rather than re-deriving it — see get-current-user.ts in each
|
|
3
|
+
// provider template.
|
|
4
|
+
export const COOKIE_NAME =
|
|
5
|
+
process.env.AUTH_COOKIE_NAME ?? "{session_cookie_name}";
|
|
6
|
+
|
|
7
|
+
const MAX_AGE = (() => {
|
|
8
|
+
const n = parseInt(process.env.AUTH_SESSION_MAX_AGE ?? "604800", 10);
|
|
9
|
+
return Number.isFinite(n) && n > 0 ? n : 604800;
|
|
10
|
+
})();
|
|
11
|
+
const IS_SECURE = process.env.NODE_ENV === "production";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Reads the session cookie value from a standard Request.
|
|
15
|
+
* Compatible with Next.js route handlers and Edge middleware.
|
|
16
|
+
*/
|
|
17
|
+
export function readSessionToken(request: Request): string | null {
|
|
18
|
+
const cookieHeader = request.headers.get("cookie") ?? "";
|
|
19
|
+
for (const part of cookieHeader.split(";")) {
|
|
20
|
+
const [rawKey, ...rest] = part.trim().split("=");
|
|
21
|
+
if (rawKey.trim() === COOKIE_NAME) {
|
|
22
|
+
return decodeURIComponent(rest.join("="));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Builds a Set-Cookie header string for the given session token.
|
|
30
|
+
*/
|
|
31
|
+
export function buildSessionCookieHeader(token: string): string {
|
|
32
|
+
const parts = [
|
|
33
|
+
`${COOKIE_NAME}=${encodeURIComponent(token)}`,
|
|
34
|
+
`Max-Age=${MAX_AGE}`,
|
|
35
|
+
"Path=/",
|
|
36
|
+
"HttpOnly",
|
|
37
|
+
"SameSite=Lax",
|
|
38
|
+
];
|
|
39
|
+
if (IS_SECURE) parts.push("Secure");
|
|
40
|
+
return parts.join("; ");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Builds a Set-Cookie header string that expires the session cookie immediately.
|
|
45
|
+
* Mirrors the same attributes as buildSessionCookieHeader so browsers correctly
|
|
46
|
+
* overwrite the existing cookie (Secure must match in production).
|
|
47
|
+
*/
|
|
48
|
+
export function buildClearSessionCookieHeader(): string {
|
|
49
|
+
const parts = [
|
|
50
|
+
`${COOKIE_NAME}=`,
|
|
51
|
+
"Max-Age=0",
|
|
52
|
+
"Expires=Thu, 01 Jan 1970 00:00:00 GMT",
|
|
53
|
+
"Path=/",
|
|
54
|
+
"HttpOnly",
|
|
55
|
+
"SameSite=Lax",
|
|
56
|
+
];
|
|
57
|
+
if (IS_SECURE) parts.push("Secure");
|
|
58
|
+
return parts.join("; ");
|
|
59
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "shared-types",
|
|
3
|
+
"name": "Shared Types",
|
|
4
|
+
"description": "Foundation library shared by every auth template: UserContext domain type, a runtime-overridable MOCK_USER for development, and generic AES-256-GCM session-cookie helpers (including the canonical COOKIE_NAME resolver). Carries no opinion about mock vs. real auth.",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"requires": ["env-setup"],
|
|
7
|
+
"conflicts": [],
|
|
8
|
+
"questions": [
|
|
9
|
+
{
|
|
10
|
+
"id": "session_cookie_name",
|
|
11
|
+
"type": "text",
|
|
12
|
+
"prompt": "Session cookie name? (used by the session-manager cookie helpers)",
|
|
13
|
+
"default": "__auth_session"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"envVars": [
|
|
17
|
+
"AUTH_COOKIE_NAME",
|
|
18
|
+
"AUTH_SESSION_MAX_AGE",
|
|
19
|
+
"MOCK_USER_ID",
|
|
20
|
+
"MOCK_USER_NAME",
|
|
21
|
+
"MOCK_USER_EMAIL",
|
|
22
|
+
"MOCK_USER_ROLES",
|
|
23
|
+
"MOCK_USER_AVATAR_URL"
|
|
24
|
+
],
|
|
25
|
+
"outputs": [
|
|
26
|
+
"src/domain/value-objects/user-context.ts",
|
|
27
|
+
"src/infrastructure/auth/mock-user.ts",
|
|
28
|
+
"src/infrastructure/auth/session/session-manager.ts",
|
|
29
|
+
".env.shared-types.example"
|
|
30
|
+
],
|
|
31
|
+
"checklist": [
|
|
32
|
+
"UserContext is the domain-owned shape every auth provider speaks (id, email, name, roles, avatarUrl)",
|
|
33
|
+
"MOCK_USER defaults are hardcoded in mock-user.ts; runtime overrides via MOCK_USER_* env vars",
|
|
34
|
+
"session-manager.ts exports COOKIE_NAME — import from here, don't re-derive in provider code"
|
|
35
|
+
],
|
|
36
|
+
"branch": "feature/shared-types-and-derived-answers"
|
|
37
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Supabase (`supabase`)
|
|
2
|
+
|
|
3
|
+
> SSR-safe browser/server/admin clients, Result-based storage helpers, RLS examples, type
|
|
4
|
+
> generation, and optional Drizzle ORM + realtime. A pure storage/database layer — no auth code.
|
|
5
|
+
|
|
6
|
+
| | |
|
|
7
|
+
| ------------- | ------------------------------------------ |
|
|
8
|
+
| **ID** | `supabase` |
|
|
9
|
+
| **Category** | Persistence / database |
|
|
10
|
+
| **Requires** | `env-setup` |
|
|
11
|
+
| **Conflicts** | none |
|
|
12
|
+
| **Branch** | `feature/shared-types-and-derived-answers` |
|
|
13
|
+
|
|
14
|
+
Author/agent-facing reference, beside `manifest.json` — not emitted into projects.
|
|
15
|
+
|
|
16
|
+
## What it does
|
|
17
|
+
|
|
18
|
+
The Supabase data layer: correctly-scoped clients (browser anon, server SSR, admin service-role),
|
|
19
|
+
Result-returning storage helpers, optional Drizzle ORM, type generation, and example RLS. Carries
|
|
20
|
+
**no auth** — add [`supabase-auth`](../supabase-auth) for session middleware on top.
|
|
21
|
+
|
|
22
|
+
## What it scaffolds
|
|
23
|
+
|
|
24
|
+
- `src/infrastructure/supabase/{client,server,admin,result}.ts` + generated `types/database.types.ts`.
|
|
25
|
+
- Optional `storage/*` helpers (upload/download/signed-url/delete), `drizzle/*`, `realtime/subscribe.ts`.
|
|
26
|
+
- `supabase/seed.sql` (always); optional `migrations/0001_example_rls.sql` (`rls_examples`) and `scripts/gen-types.sh` (`type_gen`).
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
`hexagen add supabase`. Questions: `project_url`, `anon_key` (both required), `features`
|
|
31
|
+
(`storage`), `storage_buckets`, `orm` (bool), `type_gen` (bool), `rls_examples` (bool),
|
|
32
|
+
`realtime_example` (bool).
|
|
33
|
+
|
|
34
|
+
Env: `NEXT_PUBLIC_SUPABASE_URL`, `NEXT_PUBLIC_SUPABASE_ANON_KEY`, `SUPABASE_SERVICE_ROLE_KEY`.
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { createBrowserClient } from "@/infrastructure/supabase/client";
|
|
40
|
+
import { createServerClient } from "@/infrastructure/supabase/server";
|
|
41
|
+
import { adminClient } from "@/infrastructure/supabase/admin"; // service role — server only
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Notes for agents
|
|
45
|
+
|
|
46
|
+
- **`SUPABASE_SERVICE_ROLE_KEY` is server-only** — never `NEXT_PUBLIC_` it (it bypasses RLS).
|
|
47
|
+
- Enable RLS on every table before production (see the example migration).
|
|
48
|
+
- Drizzle is opt-in (`npm install drizzle-orm postgres`, set `SUPABASE_DB_URL`).
|
|
49
|
+
- For auth, install [`supabase-auth`](../supabase-auth).
|
|
50
|
+
|
|
51
|
+
## Checklist (post-install)
|
|
52
|
+
|
|
53
|
+
`npm install @supabase/supabase-js @supabase/ssr`; set URL/anon/service-role; create buckets;
|
|
54
|
+
enable RLS; optionally wire type-gen + Drizzle.
|
|
55
|
+
|
|
56
|
+
## Related
|
|
57
|
+
|
|
58
|
+
Requires [`env-setup`](../env-setup). Auth layer: [`supabase-auth`](../supabase-auth). Background
|
|
59
|
+
jobs: [`bullmq`](../bullmq).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Supabase — copy these into .env.local
|
|
2
|
+
# Project URL + anon key: Project Settings → API (both are public/client-safe)
|
|
3
|
+
NEXT_PUBLIC_SUPABASE_URL={project_url}
|
|
4
|
+
NEXT_PUBLIC_SUPABASE_ANON_KEY={anon_key}
|
|
5
|
+
|
|
6
|
+
# Service role key: Project Settings → API. SERVER-ONLY — never expose to the
|
|
7
|
+
# browser. Bypasses Row Level Security.
|
|
8
|
+
SUPABASE_SERVICE_ROLE_KEY=
|
|
9
|
+
|
|
10
|
+
# Storage
|
|
11
|
+
# Buckets to create: {storage_buckets}
|
|
12
|
+
SUPABASE_SIGNED_URL_EXPIRY=3600
|
|
13
|
+
|
|
14
|
+
# Drizzle (only when orm is enabled): Project Settings → Database → Connection string
|
|
15
|
+
# SUPABASE_DB_URL=postgresql://postgres:password@db.your-project.supabase.co:5432/postgres
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Config } from "drizzle-kit";
|
|
2
|
+
|
|
3
|
+
const url = process.env.SUPABASE_DB_URL;
|
|
4
|
+
if (!url) {
|
|
5
|
+
throw new Error(
|
|
6
|
+
"SUPABASE_DB_URL is required. Set it in .env.local (see .env.supabase.example).",
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
schema: "./src/infrastructure/supabase/drizzle/schema.ts",
|
|
12
|
+
out: "./drizzle",
|
|
13
|
+
dialect: "postgresql",
|
|
14
|
+
dbCredentials: { url },
|
|
15
|
+
} satisfies Config;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# Regenerate TypeScript types from the local Supabase schema.
|
|
5
|
+
# Requires the supabase CLI and a running local instance (supabase start).
|
|
6
|
+
supabase gen types typescript --local \
|
|
7
|
+
> src/infrastructure/supabase/types/database.types.ts
|
|
8
|
+
|
|
9
|
+
echo "✅ Types generated → src/infrastructure/supabase/types/database.types.ts"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { drizzle } from "drizzle-orm/postgres-js";
|
|
2
|
+
import { migrate } from "drizzle-orm/postgres-js/migrator";
|
|
3
|
+
import postgres from "postgres";
|
|
4
|
+
|
|
5
|
+
// Apply pending Drizzle migrations. Run with: yarn migrate
|
|
6
|
+
async function main(): Promise<void> {
|
|
7
|
+
const dbUrl = process.env.SUPABASE_DB_URL;
|
|
8
|
+
if (!dbUrl) {
|
|
9
|
+
throw new Error(
|
|
10
|
+
"SUPABASE_DB_URL is required. Set it in .env.local (see .env.supabase.example).",
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
const migrationClient = postgres(dbUrl, { max: 1 });
|
|
14
|
+
await migrate(drizzle(migrationClient), { migrationsFolder: "./drizzle" });
|
|
15
|
+
await migrationClient.end();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
main()
|
|
19
|
+
.then(() => console.log("✅ Migrations applied"))
|
|
20
|
+
.catch((error) => {
|
|
21
|
+
console.error(error);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createClient } from "@supabase/supabase-js";
|
|
2
|
+
import type { Database } from "./types/database.types";
|
|
3
|
+
|
|
4
|
+
// Service-role client — BYPASSES Row Level Security. Server-only; never import
|
|
5
|
+
// this from client code or a client-facing barrel. Named `admin` on purpose so
|
|
6
|
+
// RLS-bypassing usage is obvious in review.
|
|
7
|
+
let admin: ReturnType<typeof createClient<Database>> | null = null;
|
|
8
|
+
|
|
9
|
+
export function getSupabaseAdmin() {
|
|
10
|
+
if (!process.env.SUPABASE_SERVICE_ROLE_KEY) {
|
|
11
|
+
throw new Error(
|
|
12
|
+
"SUPABASE_SERVICE_ROLE_KEY is required for the admin client (server-only).",
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
if (!admin) {
|
|
16
|
+
admin = createClient<Database>(
|
|
17
|
+
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
18
|
+
process.env.SUPABASE_SERVICE_ROLE_KEY,
|
|
19
|
+
{ auth: { persistSession: false, autoRefreshToken: false } },
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
return admin;
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createBrowserClient } from "@supabase/ssr";
|
|
2
|
+
import type { Database } from "./types/database.types";
|
|
3
|
+
|
|
4
|
+
// Browser client (singleton). Uses the public anon key — safe to ship to the
|
|
5
|
+
// browser. Never use this in server code: it does not propagate auth cookies.
|
|
6
|
+
let client: ReturnType<typeof createBrowserClient<Database>> | null = null;
|
|
7
|
+
|
|
8
|
+
export function getSupabaseClient() {
|
|
9
|
+
if (!client) {
|
|
10
|
+
client = createBrowserClient<Database>(
|
|
11
|
+
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
12
|
+
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
return client;
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { drizzle } from "drizzle-orm/postgres-js";
|
|
2
|
+
import postgres from "postgres";
|
|
3
|
+
import * as schema from "./schema";
|
|
4
|
+
|
|
5
|
+
// Drizzle client over the Supabase Postgres connection. Set SUPABASE_DB_URL
|
|
6
|
+
// (Project Settings → Database → Connection string). prepare:false suits the
|
|
7
|
+
// Supabase connection pooler.
|
|
8
|
+
const dbUrl = process.env.SUPABASE_DB_URL;
|
|
9
|
+
if (!dbUrl) {
|
|
10
|
+
throw new Error(
|
|
11
|
+
"SUPABASE_DB_URL is required. Set it in .env.local (see .env.supabase.example).",
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const queryClient = postgres(dbUrl, { prepare: false });
|
|
16
|
+
|
|
17
|
+
export const db = drizzle(queryClient, { schema });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { pgTable, uuid, text, timestamp } from "drizzle-orm/pg-core";
|
|
2
|
+
|
|
3
|
+
// Example schema — replace with your tables, then generate/apply a migration
|
|
4
|
+
// with `yarn migrate`. Enable RLS on every table before production.
|
|
5
|
+
export const items = pgTable("items", {
|
|
6
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
7
|
+
userId: uuid("user_id").notNull(),
|
|
8
|
+
title: text("title").notNull(),
|
|
9
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
10
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import type { RealtimeChannel } from "@supabase/supabase-js";
|
|
5
|
+
import { getSupabaseClient } from "../client";
|
|
6
|
+
|
|
7
|
+
// Subscribe to INSERTs on a table. Returns the channel — call .unsubscribe() to
|
|
8
|
+
// tear down. `filter` uses PostgREST filter syntax, e.g. "user_id=eq.123".
|
|
9
|
+
export function subscribeToTable<T>(
|
|
10
|
+
table: string,
|
|
11
|
+
filter: string,
|
|
12
|
+
onInsert: (record: T) => void,
|
|
13
|
+
): RealtimeChannel {
|
|
14
|
+
const supabase = getSupabaseClient();
|
|
15
|
+
// Unique channel name per subscription so multiple subscriptions to the same
|
|
16
|
+
// table (different filters/callbacks) don't collide or tear each other down.
|
|
17
|
+
const channelName =
|
|
18
|
+
"realtime:" + table + ":" + filter + ":" + crypto.randomUUID();
|
|
19
|
+
return supabase
|
|
20
|
+
.channel(channelName)
|
|
21
|
+
.on(
|
|
22
|
+
"postgres_changes",
|
|
23
|
+
{ event: "INSERT", schema: "public", table, filter },
|
|
24
|
+
(payload) => onInsert(payload.new as T),
|
|
25
|
+
)
|
|
26
|
+
.subscribe();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// React hook: subscribe on mount, unsubscribe on unmount.
|
|
30
|
+
export function useRealtimeTable<T>(
|
|
31
|
+
table: string,
|
|
32
|
+
filter: string,
|
|
33
|
+
onInsert: (record: T) => void,
|
|
34
|
+
): void {
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const channel = subscribeToTable<T>(table, filter, onInsert);
|
|
37
|
+
return () => {
|
|
38
|
+
void channel.unsubscribe();
|
|
39
|
+
};
|
|
40
|
+
}, [table, filter, onInsert]);
|
|
41
|
+
}
|