@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,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "adobe-firefly-content-tagging",
|
|
3
|
+
"name": "Adobe Firefly — Content Tagging",
|
|
4
|
+
"description": "Content Tagging service for Adobe Firefly: a ContentTaggingPort + adapter that returns structured tags/metadata for an image (the one service whose result is JSON, not an asset — exercises the foundation's non-asset path). Sync or short async; presigns the input only.",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"requires": ["adobe-firefly-core"],
|
|
7
|
+
"conflicts": [],
|
|
8
|
+
"questions": [
|
|
9
|
+
{
|
|
10
|
+
"id": "min_confidence",
|
|
11
|
+
"type": "select",
|
|
12
|
+
"prompt": "Drop tags below this confidence (0-1)?",
|
|
13
|
+
"options": ["0", "0.5", "0.7"],
|
|
14
|
+
"default": "0.5"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"envVars": ["ADOBE_TAGGING_MIN_CONFIDENCE"],
|
|
18
|
+
"outputs": [
|
|
19
|
+
"src/domain/ports/out/content-tagging.port.ts",
|
|
20
|
+
"src/infrastructure/adobe/content-tagging/content-tagging.adapter.ts",
|
|
21
|
+
".env.adobe-content-tagging.example"
|
|
22
|
+
],
|
|
23
|
+
"checklist": [
|
|
24
|
+
"Confirm the Content Tagging entitlement + scope on your Adobe Developer Console project",
|
|
25
|
+
"Verify the current endpoint/payload against Adobe docs — the adapter handles both a sync response (tags inline) and a short async job, so it works either way; confirm the path",
|
|
26
|
+
"Provide a presigned input href (core passthrough) or install an adobe-firefly-storage-* addon — no output storage is needed (the result is JSON, not an asset)",
|
|
27
|
+
"Tune the confidence floor per environment via ADOBE_TAGGING_MIN_CONFIDENCE (install default set the baseline)",
|
|
28
|
+
"Optional official SDK: npm install @adobe/firefly-services-sdk-js"
|
|
29
|
+
],
|
|
30
|
+
"branch": "feature/generator-template-adobe-firefly-content-tagging"
|
|
31
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# Adobe Firefly Services — Core (`adobe-firefly-core`)
|
|
2
|
+
|
|
3
|
+
> Shared foundation every Adobe Firefly Services addon builds on: IMS auth, a base
|
|
4
|
+
> REST client, the async job port, a presigned-URL storage seam, and Adobe error
|
|
5
|
+
> classification. Install this once; each service addon adds one port + adapter.
|
|
6
|
+
|
|
7
|
+
| | |
|
|
8
|
+
| ------------- | ----------------------------------------------- |
|
|
9
|
+
| **ID** | `adobe-firefly-core` |
|
|
10
|
+
| **Category** | Adobe Firefly Services — foundation |
|
|
11
|
+
| **Requires** | `env-setup`, `error-handling` |
|
|
12
|
+
| **Conflicts** | none |
|
|
13
|
+
| **Branch** | `feature/generator-template-adobe-firefly-core` |
|
|
14
|
+
|
|
15
|
+
This README is author/agent-facing reference for the template itself. It is **not**
|
|
16
|
+
emitted into generated projects — it lives beside `manifest.json`, outside `files/`.
|
|
17
|
+
|
|
18
|
+
## What it does
|
|
19
|
+
|
|
20
|
+
Scaffolds the `infrastructure/adobe/**` foundation plus three outbound domain ports.
|
|
21
|
+
It owns the cross-cutting concerns so each service addon is just one port + one
|
|
22
|
+
adapter:
|
|
23
|
+
|
|
24
|
+
- **`FireflyAuthPort` / `imsTokenProvider`** — IMS OAuth **Server-to-Server**
|
|
25
|
+
(`client_credentials`) token provider, cached in memory until ~5 min before expiry.
|
|
26
|
+
- **`fireflyClient`** — base REST client: injects `Authorization: Bearer` + `x-api-key`,
|
|
27
|
+
applies timeout + bounded retry, and posts **absolute URLs** unchanged (case-insensitive
|
|
28
|
+
`https?://` detection) so service addons on other hosts reuse it.
|
|
29
|
+
- **`FireflyJobPort` / `jobPort`** — async job seam. `await()` (jobId-only, webhook mode),
|
|
30
|
+
`status()` (single read), and `poll()` (the centralised always-poll entry point used by
|
|
31
|
+
every `image.adobe.io` service). Polling has no max-wait cap.
|
|
32
|
+
- **`FireflyStoragePort`** — presigned-URL seam. `passthrough` default (you supply hrefs);
|
|
33
|
+
`setStoragePresigner()` / `getStoragePresigner()` let a `adobe-firefly-storage-*` addon
|
|
34
|
+
swap in S3/GCS/Azure.
|
|
35
|
+
- **`classifyAdobeError` + the `FireflyError` hierarchy** — maps Adobe failures onto typed
|
|
36
|
+
errors; services return `Result<T, FireflyError>`.
|
|
37
|
+
|
|
38
|
+
## Service & API
|
|
39
|
+
|
|
40
|
+
- **Provider:** Adobe Firefly Services. **Host:** `firefly-api.adobe.io` (default
|
|
41
|
+
`ADOBE_FIREFLY_BASE_URL`); service addons may target other hosts (e.g. `image.adobe.io`).
|
|
42
|
+
- **Auth:** IMS OAuth Server-to-Server via `https://{ADOBE_IMS_HOST}/ims/token/v3`
|
|
43
|
+
(`ims-na1` / `ims-eu1`). **Not** the retired JWT / `@adobe/jwt-auth` flow.
|
|
44
|
+
- **Jobs:** async; submit returns a job handle (`jobId` + optional `statusUrl`) resolved by
|
|
45
|
+
polling or a webhook receiver (gated `job_mode=webhook`).
|
|
46
|
+
|
|
47
|
+
## Install
|
|
48
|
+
|
|
49
|
+
Run via `hexagen add adobe-firefly-core`. Questions:
|
|
50
|
+
|
|
51
|
+
| Question | Options (default) | Effect |
|
|
52
|
+
| -------------------- | --------------------------------------- | ---------------------------------------------------------------------------- |
|
|
53
|
+
| `ims_region` | `ims-na1` / `ims-eu1` (`ims-na1`) | IMS host region |
|
|
54
|
+
| `job_mode` | `polling` / `webhook` (`polling`) | how async jobs report completion; `webhook` also emits `webhook-verifier.ts` |
|
|
55
|
+
| `storage_mode` | `passthrough` / `addon` (`passthrough`) | presigned-URL strategy |
|
|
56
|
+
| `default_timeout_ms` | `30000` / `60000` / `120000` (`60000`) | per-request timeout |
|
|
57
|
+
| `max_retries` | `0`–`3` (`2`) | retries on transient failure |
|
|
58
|
+
|
|
59
|
+
Env vars introduced: `ADOBE_CLIENT_ID`, `ADOBE_CLIENT_SECRET`, `ADOBE_SCOPES`,
|
|
60
|
+
`ADOBE_IMS_ORG_ID`, `ADOBE_IMS_HOST`, `ADOBE_FIREFLY_BASE_URL`,
|
|
61
|
+
`ADOBE_JOB_POLL_INTERVAL_MS`, `ADOBE_WEBHOOK_SECRET`.
|
|
62
|
+
|
|
63
|
+
Key emitted files: the three ports under `src/domain/ports/out/`, the adapters under
|
|
64
|
+
`src/infrastructure/adobe/{auth,http,jobs,storage,errors}/`, the `index.ts` barrel, and
|
|
65
|
+
`.env.adobe.example`.
|
|
66
|
+
|
|
67
|
+
## Usage
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
// A service addon's adapter composes the core pieces:
|
|
71
|
+
import { fireflyClient } from "@/infrastructure/adobe/http/firefly-client";
|
|
72
|
+
import { jobPort } from "@/infrastructure/adobe/jobs/job-port";
|
|
73
|
+
import { toJobHandle } from "@/infrastructure/adobe/jobs/job-result";
|
|
74
|
+
import { getStoragePresigner } from "@/infrastructure/adobe/storage/passthrough-storage.adapter";
|
|
75
|
+
|
|
76
|
+
const out = await getStoragePresigner().presignOutput(outputRef);
|
|
77
|
+
const handle = toJobHandle(await fireflyClient.post("/v3/...", body));
|
|
78
|
+
const done = await jobPort.poll(handle); // → JobResult { status, outputs: JobOutput[], ... }
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Smoke-test the token flow without any service call:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npx tsx src/infrastructure/adobe/auth/smoke-token.ts
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Configuration
|
|
88
|
+
|
|
89
|
+
| Env var | Purpose |
|
|
90
|
+
| ----------------------------------------- | ------------------------------------------------------------------ |
|
|
91
|
+
| `ADOBE_CLIENT_ID` / `ADOBE_CLIENT_SECRET` | Server-to-Server OAuth credentials |
|
|
92
|
+
| `ADOBE_SCOPES` | space/comma-separated scopes (per entitlement) |
|
|
93
|
+
| `ADOBE_IMS_ORG_ID` | IMS org id |
|
|
94
|
+
| `ADOBE_IMS_HOST` | e.g. `ims-na1.adobelogin.com` |
|
|
95
|
+
| `ADOBE_FIREFLY_BASE_URL` | default `https://firefly-api.adobe.io` |
|
|
96
|
+
| `ADOBE_JOB_POLL_INTERVAL_MS` | poll backoff base (default 2000) |
|
|
97
|
+
| `ADOBE_WEBHOOK_SECRET` | required in `job_mode=webhook` (verifier fails closed without it) |
|
|
98
|
+
| `ADOBE_WEBHOOK_TIMEOUT_MS` | webhook-mode await timeout in ms (read at runtime, default 600000) |
|
|
99
|
+
|
|
100
|
+
## Notes for agents
|
|
101
|
+
|
|
102
|
+
- **Server-only boundary (ADR-0037).** `infrastructure/adobe/**` is `@hexagen-server-only` —
|
|
103
|
+
the IMS token must never reach a client bundle.
|
|
104
|
+
- **Server-to-Server only.** Do not reintroduce JWT / `@adobe/jwt-auth`.
|
|
105
|
+
- **Webhook mode parks completion promises in memory** — correct for a single long-lived
|
|
106
|
+
instance only. On serverless/multi-instance, use polling or back the registry with a
|
|
107
|
+
shared store (Redis/BullMQ, Postgres).
|
|
108
|
+
- In `job_mode=webhook`, `await()` times out after `ADOBE_WEBHOOK_TIMEOUT_MS` (default 600000).
|
|
109
|
+
This applies only to the webhook-delivering `firefly-api.adobe.io` services (generate / upscale
|
|
110
|
+
/ composite / content-tagging). The `image.adobe.io` services (photoshop … substance-3d) always
|
|
111
|
+
poll by status URL — webhook mode doesn't apply; throttle them with `ADOBE_JOB_POLL_INTERVAL_MS`.
|
|
112
|
+
- `done.outputs` is always a `JobOutput[]` (`{ href?, data? }`); `parseJobResult` is total
|
|
113
|
+
(never throws). There is no per-output id — batch services align positionally.
|
|
114
|
+
|
|
115
|
+
### Family conventions (apply to every Adobe Firefly addon)
|
|
116
|
+
|
|
117
|
+
- **Polling:** all `image.adobe.io` service adapters wait via the centralised
|
|
118
|
+
**`jobPort.poll(handle)`** seam (added in #152). No adapter imports `pollJobStatus`
|
|
119
|
+
directly. A "some still use `pollJobStatus`" diff is the stale pre-#152 state — verify:
|
|
120
|
+
`grep -rl "pollJobStatus(" templates/adobe-*/files` → no matches.
|
|
121
|
+
- **`branch`** is a documented optional field of the manifest schema
|
|
122
|
+
(`src/domain/template-manifest.ts`, `branch?: string`), intentionally present in every
|
|
123
|
+
manifest — not a stale git artifact.
|
|
124
|
+
- **`image.adobe.io` adapter invariants:** `@hexagen-server-only`; absolute URLs via
|
|
125
|
+
`normalizeBase()` (scheme lowercased, trailing slash stripped); status-URL-required guard
|
|
126
|
+
before polling; type-only `import type { FireflyError }` in domain ports.
|
|
127
|
+
- **Tests:** `node:test` + **`node:assert/strict`** (package-wide convention); emit-shape
|
|
128
|
+
tests string-match the payload and are named `adobe-<service>-emit-shape.test.ts`.
|
|
129
|
+
|
|
130
|
+
## Checklist (post-install)
|
|
131
|
+
|
|
132
|
+
1. Create an Adobe Developer Console project; add the Firefly Services / API entitlement.
|
|
133
|
+
2. Generate OAuth Server-to-Server credentials; set `ADOBE_CLIENT_ID` / `ADOBE_CLIENT_SECRET` / `ADOBE_SCOPES`.
|
|
134
|
+
3. Do **not** use JWT — the Service-Account/JWT flow is retired.
|
|
135
|
+
4. Confirm your entitlement covers the specific service addons you install (scopes differ per service).
|
|
136
|
+
5. If `job_mode=webhook`: expose the receiver route publicly and set `ADOBE_WEBHOOK_SECRET`.
|
|
137
|
+
6. Webhook mode parks promises in memory — use polling on serverless/multi-instance.
|
|
138
|
+
7. Smoke the token flow: `npx tsx src/infrastructure/adobe/auth/smoke-token.ts`.
|
|
139
|
+
8. `infrastructure/adobe/**` is `@hexagen-server-only` — never import from a client bundle.
|
|
140
|
+
|
|
141
|
+
## Related
|
|
142
|
+
|
|
143
|
+
Service addons: [`adobe-firefly-generate`](../adobe-firefly-generate), [`adobe-firefly-upscale`](../adobe-firefly-upscale),
|
|
144
|
+
[`adobe-firefly-composite`](../adobe-firefly-composite), [`adobe-firefly-content-tagging`](../adobe-firefly-content-tagging),
|
|
145
|
+
[`adobe-photoshop`](../adobe-photoshop), [`adobe-lightroom`](../adobe-lightroom), [`adobe-illustrator`](../adobe-illustrator),
|
|
146
|
+
[`adobe-indesign`](../adobe-indesign), [`adobe-express`](../adobe-express), [`adobe-creative-production`](../adobe-creative-production),
|
|
147
|
+
[`adobe-substance-3d`](../adobe-substance-3d). Storage: [`adobe-firefly-storage-s3`](../adobe-firefly-storage-s3).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# --- Adobe Firefly Services — Core ---
|
|
2
|
+
# Copy values into .env.local. check:env enforces the `# required` vars below.
|
|
3
|
+
|
|
4
|
+
# Adobe IMS — OAuth Server-to-Server (NOT JWT; the Service-Account/JWT flow is retired)
|
|
5
|
+
ADOBE_CLIENT_ID= # required
|
|
6
|
+
ADOBE_CLIENT_SECRET= # required
|
|
7
|
+
ADOBE_SCOPES=openid,AdobeID,firefly_api,ff_apis # scope set depends on your entitlements
|
|
8
|
+
ADOBE_IMS_ORG_ID= # x-gw-ims-org-id on some services
|
|
9
|
+
ADOBE_IMS_HOST={ims_region}.adobelogin.com
|
|
10
|
+
ADOBE_FIREFLY_BASE_URL=https://firefly-api.adobe.io
|
|
11
|
+
|
|
12
|
+
# Async jobs (job_mode={job_mode}). image.adobe.io services always poll by status URL regardless of job_mode.
|
|
13
|
+
ADOBE_JOB_POLL_INTERVAL_MS=2000 # poll backoff base (ms); raise to throttle long-running image.adobe.io jobs
|
|
14
|
+
ADOBE_WEBHOOK_SECRET= # only if job_mode=webhook (verifier fails closed without it)
|
|
15
|
+
ADOBE_WEBHOOK_TIMEOUT_MS=600000 # webhook-mode await timeout (ms); firefly-api.adobe.io jobs only (image.adobe.io services poll)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbound port for Adobe IMS authentication.
|
|
3
|
+
*
|
|
4
|
+
* Hides the OAuth Server-to-Server (`client_credentials`) token exchange behind a
|
|
5
|
+
* single accessor. The token is privileged and cached inside the adapter — it is
|
|
6
|
+
* never returned to anything outside `infrastructure/adobe/**`.
|
|
7
|
+
*/
|
|
8
|
+
export interface FireflyAuthPort {
|
|
9
|
+
/** A valid IMS bearer token, refreshed transparently before it expires. */
|
|
10
|
+
getAccessToken(): Promise<string>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbound port for Firefly async jobs.
|
|
3
|
+
*
|
|
4
|
+
* Most Firefly operations are asynchronous: a `POST` returns a job, whose result
|
|
5
|
+
* arrives later by polling a status URL or by an inbound webhook. This port hides
|
|
6
|
+
* that transport — service adapters depend only on `await(handle)` and never know
|
|
7
|
+
* which mode is configured, so switching polling↔webhook touches no adapter.
|
|
8
|
+
*
|
|
9
|
+
* `await(handle)` RESOLVES to a `JobResult` for BOTH terminal states — a job
|
|
10
|
+
* that completed but `failed` resolves with `status: "failed"` (uniform across
|
|
11
|
+
* polling and webhook), so adapters must check `result.status` rather than rely
|
|
12
|
+
* on a throw. Only transport/config problems (a missing status URL, a webhook
|
|
13
|
+
* timeout) throw a `FireflyError`, which service adapters catch and convert to
|
|
14
|
+
* a `Result`.
|
|
15
|
+
*/
|
|
16
|
+
export type JobStatus = "running" | "succeeded" | "failed";
|
|
17
|
+
|
|
18
|
+
export interface JobOutput {
|
|
19
|
+
/** Presigned href of an asset output (most services). */
|
|
20
|
+
readonly href?: string;
|
|
21
|
+
/** Inline JSON output (e.g. Content Tagging — the non-asset path). */
|
|
22
|
+
readonly data?: unknown;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface JobResult {
|
|
26
|
+
readonly jobId: string;
|
|
27
|
+
readonly status: JobStatus;
|
|
28
|
+
readonly outputs: JobOutput[];
|
|
29
|
+
/** Failure detail when `status === "failed"`. */
|
|
30
|
+
readonly error?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface JobHandle {
|
|
34
|
+
readonly jobId: string;
|
|
35
|
+
/** Absolute status URL returned by the submit call (used in polling mode). */
|
|
36
|
+
readonly statusUrl?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface FireflyJobPort {
|
|
40
|
+
/**
|
|
41
|
+
* Await terminal completion (polling or webhook, transparently) for
|
|
42
|
+
* webhook-capable services. Some services are tracked only by a status URL and
|
|
43
|
+
* never deliver Firefly webhooks (the image.adobe.io Photoshop/Lightroom/
|
|
44
|
+
* Illustrator APIs); those force polling via the concrete `jobPort.poll(handle)`
|
|
45
|
+
* rather than `await()`, keeping the wait path on the port.
|
|
46
|
+
*/
|
|
47
|
+
await(handle: JobHandle): Promise<JobResult>;
|
|
48
|
+
/** One-shot status check without waiting. */
|
|
49
|
+
status(handle: JobHandle): Promise<JobResult>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbound port for presigned-URL storage.
|
|
3
|
+
*
|
|
4
|
+
* Firefly Services pass inputs/outputs as presigned URLs (`storage: "external"`),
|
|
5
|
+
* never multipart. The default `passthrough` implementation assumes the caller
|
|
6
|
+
* already holds presigned hrefs and returns them unchanged; an opt-in
|
|
7
|
+
* `adobe-firefly-storage-*` addon registers a real presigner (S3/GCS/Azure) via
|
|
8
|
+
* the storage seam without coupling the core to any cloud SDK.
|
|
9
|
+
*/
|
|
10
|
+
export interface PresignedHref {
|
|
11
|
+
/** URL the Firefly service reads from (GET) or writes to (PUT). */
|
|
12
|
+
readonly href: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface FireflyStoragePort {
|
|
16
|
+
/** Presign an input object for Firefly to read. */
|
|
17
|
+
presignInput(ref: string): Promise<PresignedHref>;
|
|
18
|
+
/** Presign an output destination for Firefly to write. */
|
|
19
|
+
presignOutput(ref: string): Promise<PresignedHref>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// @hexagen-server-only
|
|
2
|
+
import type { FireflyAuthPort } from "../../../domain/ports/out/firefly-auth.port";
|
|
3
|
+
import { classifyAdobeError, FireflyServiceError } from "../errors/firefly-errors";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Adobe IMS OAuth Server-to-Server token provider.
|
|
7
|
+
*
|
|
8
|
+
* Exchanges `client_credentials` at `https://<ADOBE_IMS_HOST>/ims/token/v3` for a
|
|
9
|
+
* short-lived bearer token, caches it in memory until shortly before expiry, and
|
|
10
|
+
* refreshes on demand. This replaces the retired Service-Account/JWT flow (the
|
|
11
|
+
* legacy jwt-auth package is not used). The token never leaves
|
|
12
|
+
* `infrastructure/adobe/**`.
|
|
13
|
+
*/
|
|
14
|
+
const REFRESH_SKEW_MS = 5 * 60 * 1000; // refresh 5 min before expiry
|
|
15
|
+
// Bound the token request so a stuck IMS connection can't hang every caller
|
|
16
|
+
// waiting behind the shared in-flight promise.
|
|
17
|
+
const IMS_TOKEN_TIMEOUT_MS = Number(process.env.ADOBE_IMS_TOKEN_TIMEOUT_MS ?? 15_000);
|
|
18
|
+
|
|
19
|
+
interface CachedToken {
|
|
20
|
+
token: string;
|
|
21
|
+
expiresAt: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface ImsTokenResponse {
|
|
25
|
+
access_token: string;
|
|
26
|
+
expires_in: number; // seconds
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
class ImsTokenProvider implements FireflyAuthPort {
|
|
30
|
+
private cached?: CachedToken;
|
|
31
|
+
private inFlight?: Promise<string>;
|
|
32
|
+
|
|
33
|
+
async getAccessToken(): Promise<string> {
|
|
34
|
+
if (this.cached && Date.now() < this.cached.expiresAt - REFRESH_SKEW_MS) {
|
|
35
|
+
return this.cached.token;
|
|
36
|
+
}
|
|
37
|
+
// Collapse concurrent refreshes into a single token request.
|
|
38
|
+
this.inFlight ??= this.fetchToken().finally(() => {
|
|
39
|
+
this.inFlight = undefined;
|
|
40
|
+
});
|
|
41
|
+
return this.inFlight;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private async fetchToken(): Promise<string> {
|
|
45
|
+
const host = process.env.ADOBE_IMS_HOST ?? "{ims_region}.adobelogin.com";
|
|
46
|
+
const clientId = required("ADOBE_CLIENT_ID");
|
|
47
|
+
const clientSecret = required("ADOBE_CLIENT_SECRET");
|
|
48
|
+
const scopes = process.env.ADOBE_SCOPES ?? "openid,AdobeID,firefly_api,ff_apis";
|
|
49
|
+
|
|
50
|
+
const body = new URLSearchParams({
|
|
51
|
+
grant_type: "client_credentials",
|
|
52
|
+
client_id: clientId,
|
|
53
|
+
client_secret: clientSecret,
|
|
54
|
+
scope: scopes.split(",").map((s) => s.trim()).filter(Boolean).join(","),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const controller = new AbortController();
|
|
58
|
+
const timer = setTimeout(() => controller.abort(), IMS_TOKEN_TIMEOUT_MS);
|
|
59
|
+
try {
|
|
60
|
+
const response = await fetch(`https://${host}/ims/token/v3`, {
|
|
61
|
+
method: "POST",
|
|
62
|
+
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
63
|
+
body,
|
|
64
|
+
signal: controller.signal,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if (!response.ok) {
|
|
68
|
+
throw classifyAdobeError({
|
|
69
|
+
status: response.status,
|
|
70
|
+
body: await safeBody(response),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const json = (await response.json()) as ImsTokenResponse;
|
|
75
|
+
this.cached = {
|
|
76
|
+
token: json.access_token,
|
|
77
|
+
expiresAt: Date.now() + json.expires_in * 1000,
|
|
78
|
+
};
|
|
79
|
+
return this.cached.token;
|
|
80
|
+
} catch (error) {
|
|
81
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
82
|
+
// Retryable — a timed-out token request may succeed next time.
|
|
83
|
+
throw new FireflyServiceError(
|
|
84
|
+
`Adobe IMS token request timed out after ${IMS_TOKEN_TIMEOUT_MS}ms`,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
throw error;
|
|
88
|
+
} finally {
|
|
89
|
+
clearTimeout(timer);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function required(name: string): string {
|
|
95
|
+
const value = process.env[name];
|
|
96
|
+
if (!value) {
|
|
97
|
+
// Missing credentials are a config error — fail loud (AGENTS.md).
|
|
98
|
+
throw new Error(`${name} is not set — configure Adobe IMS Server-to-Server credentials in .env.local.`);
|
|
99
|
+
}
|
|
100
|
+
return value;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function safeBody(response: Response): Promise<unknown> {
|
|
104
|
+
try {
|
|
105
|
+
return await response.json();
|
|
106
|
+
} catch {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Shared singleton — one in-memory token cache per process. */
|
|
112
|
+
export const imsTokenProvider = new ImsTokenProvider();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @hexagen-server-only
|
|
2
|
+
import { imsTokenProvider } from "./ims-token-provider.adapter";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Smoke test: verify Adobe IMS Server-to-Server credentials acquire a token.
|
|
6
|
+
* Run: npx tsx src/infrastructure/adobe/auth/smoke-token.ts
|
|
7
|
+
*/
|
|
8
|
+
async function main(): Promise<void> {
|
|
9
|
+
const token = await imsTokenProvider.getAccessToken();
|
|
10
|
+
// Never print the token itself — confirm acquisition only.
|
|
11
|
+
console.log(`✓ IMS token acquired (length ${token.length}).`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
main().catch((error: unknown) => {
|
|
15
|
+
console.error("✗ IMS token flow failed:", error instanceof Error ? error.message : error);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
});
|
package/dist/templates/adobe-firefly-core/files/src/infrastructure/adobe/errors/firefly-errors.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// @hexagen-server-only
|
|
2
|
+
/**
|
|
3
|
+
* Adobe Firefly error hierarchy + classifier.
|
|
4
|
+
*
|
|
5
|
+
* The HTTP error surface is uniform across Firefly Services, so one classifier
|
|
6
|
+
* maps a failed response onto a typed error. Foundation code throws these;
|
|
7
|
+
* service adapters catch and convert to `Result<T, FireflyError>`. All extend
|
|
8
|
+
* `Error`, satisfying the `Result<T, E extends Error>` contract.
|
|
9
|
+
*/
|
|
10
|
+
export class FireflyError extends Error {
|
|
11
|
+
constructor(
|
|
12
|
+
message: string,
|
|
13
|
+
readonly status?: number,
|
|
14
|
+
/** Whether retrying the same request could succeed (429, 5xx). */
|
|
15
|
+
readonly retryable: boolean = false,
|
|
16
|
+
) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = new.target.name;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** 401, or 403 that is not an entitlement problem. */
|
|
23
|
+
export class FireflyAuthError extends FireflyError {}
|
|
24
|
+
|
|
25
|
+
/** 403 where the IMS org/credential lacks the service entitlement or scope. */
|
|
26
|
+
export class FireflyEntitlementError extends FireflyError {}
|
|
27
|
+
|
|
28
|
+
/** 429 — throttled. Carries the parsed `Retry-After` when present. */
|
|
29
|
+
export class FireflyRateLimitError extends FireflyError {
|
|
30
|
+
constructor(
|
|
31
|
+
message: string,
|
|
32
|
+
readonly retryAfterMs?: number,
|
|
33
|
+
) {
|
|
34
|
+
super(message, 429, true);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** 4xx other than 401/403/429 — a bad request the caller must fix. */
|
|
39
|
+
export class FireflyValidationError extends FireflyError {}
|
|
40
|
+
|
|
41
|
+
/** 5xx — transient service failure, safe to retry. */
|
|
42
|
+
export class FireflyServiceError extends FireflyError {
|
|
43
|
+
constructor(message: string, status = 500) {
|
|
44
|
+
super(message, status, true);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface AdobeErrorLike {
|
|
49
|
+
readonly status?: number;
|
|
50
|
+
readonly retryAfterMs?: number;
|
|
51
|
+
readonly message?: string;
|
|
52
|
+
readonly body?: unknown;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Map a failed Adobe response (or thrown error) onto a typed `FireflyError`.
|
|
57
|
+
* 401/403→Auth(/Entitlement), 429→RateLimit, other 4xx→Validation, 5xx→Service.
|
|
58
|
+
*/
|
|
59
|
+
export function classifyAdobeError(error: AdobeErrorLike | unknown): FireflyError {
|
|
60
|
+
if (error instanceof FireflyError) return error;
|
|
61
|
+
|
|
62
|
+
const e = (error ?? {}) as AdobeErrorLike;
|
|
63
|
+
const status = typeof e.status === "number" ? e.status : undefined;
|
|
64
|
+
const detail = e.message ?? describe(e.body) ?? "Adobe Firefly request failed";
|
|
65
|
+
|
|
66
|
+
if (status === 401) return new FireflyAuthError(`Unauthorized: ${detail}`, 401);
|
|
67
|
+
if (status === 403) {
|
|
68
|
+
return /entitle|not\s*entitled|forbidden scope/i.test(detail)
|
|
69
|
+
? new FireflyEntitlementError(`Not entitled: ${detail}`, 403)
|
|
70
|
+
: new FireflyAuthError(`Forbidden: ${detail}`, 403);
|
|
71
|
+
}
|
|
72
|
+
if (status === 429) return new FireflyRateLimitError(`Rate limited: ${detail}`, e.retryAfterMs);
|
|
73
|
+
if (status !== undefined && status >= 500) return new FireflyServiceError(`Service error: ${detail}`, status);
|
|
74
|
+
if (status !== undefined && status >= 400) return new FireflyValidationError(`Invalid request: ${detail}`, status);
|
|
75
|
+
return new FireflyServiceError(detail, status ?? 500);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function describe(body: unknown): string | undefined {
|
|
79
|
+
if (typeof body === "string") return body;
|
|
80
|
+
if (body && typeof body === "object") {
|
|
81
|
+
const b = body as Record<string, unknown>;
|
|
82
|
+
const msg = b.error_description ?? b.message ?? b.error ?? b.title;
|
|
83
|
+
if (typeof msg === "string") return msg;
|
|
84
|
+
try {
|
|
85
|
+
return JSON.stringify(body).slice(0, 300);
|
|
86
|
+
} catch {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
package/dist/templates/adobe-firefly-core/files/src/infrastructure/adobe/http/firefly-client.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// @hexagen-server-only
|
|
2
|
+
import { imsTokenProvider } from "../auth/ims-token-provider.adapter";
|
|
3
|
+
import { classifyAdobeError, FireflyError } from "../errors/firefly-errors";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Base Firefly REST client.
|
|
7
|
+
*
|
|
8
|
+
* Injects the IMS bearer + `x-api-key` (the client id) on every call, applies a
|
|
9
|
+
* per-request timeout and bounded retry on retryable failures (429/5xx, honouring
|
|
10
|
+
* `Retry-After`), and throws a classified `FireflyError` on non-2xx. Service
|
|
11
|
+
* adapters build on this rather than calling `fetch` directly.
|
|
12
|
+
*/
|
|
13
|
+
const BASE_URL = process.env.ADOBE_FIREFLY_BASE_URL ?? "https://firefly-api.adobe.io";
|
|
14
|
+
const DEFAULT_TIMEOUT_MS = Number("{default_timeout_ms}");
|
|
15
|
+
const MAX_RETRIES = Number("{max_retries}");
|
|
16
|
+
|
|
17
|
+
export interface FireflyRequestOptions {
|
|
18
|
+
timeoutMs?: number;
|
|
19
|
+
/** Extra headers (e.g. `x-gw-ims-org-id`) merged over the defaults. */
|
|
20
|
+
headers?: Record<string, string>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class FireflyClient {
|
|
24
|
+
async post<T>(path: string, body: unknown, opts: FireflyRequestOptions = {}): Promise<T> {
|
|
25
|
+
return this.request<T>("POST", path, body, opts);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async get<T>(pathOrUrl: string, opts: FireflyRequestOptions = {}): Promise<T> {
|
|
29
|
+
return this.request<T>("GET", pathOrUrl, undefined, opts);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private async request<T>(
|
|
33
|
+
method: "GET" | "POST",
|
|
34
|
+
pathOrUrl: string,
|
|
35
|
+
body: unknown,
|
|
36
|
+
opts: FireflyRequestOptions,
|
|
37
|
+
): Promise<T> {
|
|
38
|
+
// Status URLs returned by Firefly are absolute; service paths are relative.
|
|
39
|
+
// Case-insensitive: services that post to another host (Photoshop/Lightroom on
|
|
40
|
+
// image.adobe.io) may carry an upper/mixed-case scheme ("HTTPS://…"); without
|
|
41
|
+
// the `i` flag those would be treated as relative and mis-prefixed with BASE_URL.
|
|
42
|
+
const url = /^https?:\/\//i.test(pathOrUrl) ? pathOrUrl : `${BASE_URL}${pathOrUrl}`;
|
|
43
|
+
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
44
|
+
|
|
45
|
+
let lastError: FireflyError | undefined;
|
|
46
|
+
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
47
|
+
try {
|
|
48
|
+
return await this.attempt<T>(method, url, body, timeoutMs, opts.headers);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
const fe = classifyAdobeError(error);
|
|
51
|
+
if (!fe.retryable || attempt === MAX_RETRIES) throw fe;
|
|
52
|
+
lastError = fe;
|
|
53
|
+
await delay(backoffMs(attempt, fe));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Unreachable (loop either returns or throws), but satisfies the type checker.
|
|
57
|
+
throw lastError ?? new FireflyError("Firefly request failed");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private async attempt<T>(
|
|
61
|
+
method: "GET" | "POST",
|
|
62
|
+
url: string,
|
|
63
|
+
body: unknown,
|
|
64
|
+
timeoutMs: number,
|
|
65
|
+
extraHeaders?: Record<string, string>,
|
|
66
|
+
): Promise<T> {
|
|
67
|
+
const token = await imsTokenProvider.getAccessToken();
|
|
68
|
+
const controller = new AbortController();
|
|
69
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
70
|
+
try {
|
|
71
|
+
const response = await fetch(url, {
|
|
72
|
+
method,
|
|
73
|
+
headers: {
|
|
74
|
+
authorization: `Bearer ${token}`,
|
|
75
|
+
"x-api-key": process.env.ADOBE_CLIENT_ID ?? "",
|
|
76
|
+
...(body !== undefined ? { "content-type": "application/json" } : {}),
|
|
77
|
+
...extraHeaders,
|
|
78
|
+
},
|
|
79
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
80
|
+
signal: controller.signal,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if (!response.ok) {
|
|
84
|
+
throw classifyAdobeError({
|
|
85
|
+
status: response.status,
|
|
86
|
+
retryAfterMs: parseRetryAfter(response.headers.get("retry-after")),
|
|
87
|
+
body: await safeBody(response),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
// 202/empty bodies resolve to an empty object.
|
|
91
|
+
return (await safeBody(response)) as T;
|
|
92
|
+
} catch (error) {
|
|
93
|
+
// Match on name, not the DOMException subclass — some edge runtimes / shims
|
|
94
|
+
// throw a plain Error with name "AbortError" rather than a DOMException.
|
|
95
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
96
|
+
throw new FireflyError(`Firefly request timed out after ${timeoutMs}ms`, 408, true);
|
|
97
|
+
}
|
|
98
|
+
throw error;
|
|
99
|
+
} finally {
|
|
100
|
+
clearTimeout(timer);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function backoffMs(attempt: number, error: FireflyError): number {
|
|
106
|
+
if (error instanceof FireflyError && "retryAfterMs" in error) {
|
|
107
|
+
const retryAfter = (error as { retryAfterMs?: number }).retryAfterMs;
|
|
108
|
+
if (typeof retryAfter === "number") return retryAfter;
|
|
109
|
+
}
|
|
110
|
+
return Math.min(2000 * 2 ** attempt, 15000); // exponential, capped
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function parseRetryAfter(value: string | null): number | undefined {
|
|
114
|
+
if (!value) return undefined;
|
|
115
|
+
const seconds = Number(value);
|
|
116
|
+
return Number.isFinite(seconds) ? seconds * 1000 : undefined;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function delay(ms: number): Promise<void> {
|
|
120
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function safeBody(response: Response): Promise<unknown> {
|
|
124
|
+
const text = await response.text();
|
|
125
|
+
if (!text) return {};
|
|
126
|
+
try {
|
|
127
|
+
return JSON.parse(text);
|
|
128
|
+
} catch {
|
|
129
|
+
return text;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Shared singleton used by all service adapters. */
|
|
134
|
+
export const fireflyClient = new FireflyClient();
|
|
135
|
+
export { FireflyClient };
|