@ankhorage/infra 4.1.12 → 5.0.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/CHANGELOG.md +10 -0
- package/README.md +21 -32
- package/dist/cli/bin.d.ts +1 -8
- package/dist/cli/bin.d.ts.map +1 -1
- package/dist/cli/bin.js +2 -34
- package/dist/cli/bin.js.map +1 -1
- package/dist/cli/commands/destroy.d.ts +11 -0
- package/dist/cli/commands/destroy.d.ts.map +1 -0
- package/dist/cli/commands/destroy.js +51 -0
- package/dist/cli/commands/destroy.js.map +1 -0
- package/dist/cli/commands/down.d.ts +11 -0
- package/dist/cli/commands/down.d.ts.map +1 -0
- package/dist/cli/commands/down.js +27 -0
- package/dist/cli/commands/down.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +11 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +29 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/outputs.d.ts +11 -0
- package/dist/cli/commands/outputs.d.ts.map +1 -0
- package/dist/cli/commands/outputs.js +25 -0
- package/dist/cli/commands/outputs.js.map +1 -0
- package/dist/cli/commands/plan.d.ts +11 -0
- package/dist/cli/commands/plan.d.ts.map +1 -0
- package/dist/cli/commands/plan.js +19 -0
- package/dist/cli/commands/plan.js.map +1 -0
- package/dist/cli/commands/status.d.ts +11 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +19 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/up.d.ts +11 -0
- package/dist/cli/commands/up.d.ts.map +1 -0
- package/dist/cli/commands/up.js +28 -0
- package/dist/cli/commands/up.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +11 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +19 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/constants.d.ts +66 -0
- package/dist/cli/constants.d.ts.map +1 -0
- package/dist/cli/constants.js +19 -0
- package/dist/cli/constants.js.map +1 -0
- package/dist/cli/createDefaultInfraCommandContext.d.ts +4 -0
- package/dist/cli/createDefaultInfraCommandContext.d.ts.map +1 -0
- package/dist/{commandContext.js → cli/createDefaultInfraCommandContext.js} +4 -3
- package/dist/cli/createDefaultInfraCommandContext.js.map +1 -0
- package/dist/cli/createInfraRuntimeProvider.d.ts +5 -0
- package/dist/cli/createInfraRuntimeProvider.d.ts.map +1 -0
- package/dist/cli/createInfraRuntimeProvider.js +22 -0
- package/dist/cli/createInfraRuntimeProvider.js.map +1 -0
- package/dist/cli/createProviderCommandDescriptors.d.ts +4 -0
- package/dist/cli/createProviderCommandDescriptors.d.ts.map +1 -0
- package/dist/cli/createProviderCommandDescriptors.js +6 -0
- package/dist/cli/createProviderCommandDescriptors.js.map +1 -0
- package/dist/cli/findInfraCommand.d.ts +4 -0
- package/dist/cli/findInfraCommand.d.ts.map +1 -0
- package/dist/cli/findInfraCommand.js +6 -0
- package/dist/cli/findInfraCommand.js.map +1 -0
- package/dist/cli/index.d.ts +3 -8
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -24
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/renderInfraRootHelp.d.ts +3 -0
- package/dist/cli/renderInfraRootHelp.d.ts.map +1 -0
- package/dist/cli/renderInfraRootHelp.js +21 -0
- package/dist/cli/renderInfraRootHelp.js.map +1 -0
- package/dist/cli/renderUnknownInfraCommand.d.ts +3 -0
- package/dist/cli/renderUnknownInfraCommand.d.ts.map +1 -0
- package/dist/cli/renderUnknownInfraCommand.js +5 -0
- package/dist/cli/renderUnknownInfraCommand.js.map +1 -0
- package/dist/cli/runInfraCliAsync.d.ts +10 -0
- package/dist/cli/runInfraCliAsync.d.ts.map +1 -0
- package/dist/cli/runInfraCliAsync.js +34 -0
- package/dist/cli/runInfraCliAsync.js.map +1 -0
- package/dist/cli/runInfraCommandAsync.d.ts +4 -0
- package/dist/cli/runInfraCommandAsync.d.ts.map +1 -0
- package/dist/cli/runInfraCommandAsync.js +100 -0
- package/dist/cli/runInfraCommandAsync.js.map +1 -0
- package/dist/cli/utils/prepareInfraCommandOperationAsync.d.ts +4 -0
- package/dist/cli/utils/prepareInfraCommandOperationAsync.d.ts.map +1 -0
- package/dist/cli/utils/prepareInfraCommandOperationAsync.js +45 -0
- package/dist/cli/utils/prepareInfraCommandOperationAsync.js.map +1 -0
- package/dist/cli/utils/requireInfraSuccess.d.ts +7 -0
- package/dist/cli/utils/requireInfraSuccess.d.ts.map +1 -0
- package/dist/cli/utils/requireInfraSuccess.js +17 -0
- package/dist/cli/utils/requireInfraSuccess.js.map +1 -0
- package/dist/cli/utils/resolveInfraPersistence.d.ts +4 -0
- package/dist/cli/utils/resolveInfraPersistence.d.ts.map +1 -0
- package/dist/cli/utils/resolveInfraPersistence.js +17 -0
- package/dist/cli/utils/resolveInfraPersistence.js.map +1 -0
- package/dist/cli/utils/writeInfraEnvironmentOutputs.d.ts +5 -0
- package/dist/cli/utils/writeInfraEnvironmentOutputs.d.ts.map +1 -0
- package/dist/cli/utils/writeInfraEnvironmentOutputs.js +16 -0
- package/dist/cli/utils/writeInfraEnvironmentOutputs.js.map +1 -0
- package/dist/cli/utils/writeInfraStructured.d.ts +4 -0
- package/dist/cli/utils/writeInfraStructured.d.ts.map +1 -0
- package/dist/cli/utils/writeInfraStructured.js +8 -0
- package/dist/cli/utils/writeInfraStructured.js.map +1 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/{packageMetadata.js → constants.js} +6 -3
- package/dist/constants.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraCredentialPort.d.ts +4 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraCredentialPort.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraCredentialPort.js +35 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraCredentialPort.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraSecretPort.d.ts +4 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraSecretPort.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraSecretPort.js +23 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraSecretPort.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createNodeInfraAdapterPackageResolver.d.ts +4 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createNodeInfraAdapterPackageResolver.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createNodeInfraAdapterPackageResolver.js +9 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createNodeInfraAdapterPackageResolver.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/readStoredInfraStateAsync.d.ts +5 -0
- package/dist/features/environment-lifecycle/adapters/outbound/readStoredInfraStateAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/readStoredInfraStateAsync.js +28 -0
- package/dist/features/environment-lifecycle/adapters/outbound/readStoredInfraStateAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/removeStoredInfraStateAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/adapters/outbound/removeStoredInfraStateAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/removeStoredInfraStateAsync.js +7 -0
- package/dist/features/environment-lifecycle/adapters/outbound/removeStoredInfraStateAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/resolveInfraProjectAsync.d.ts +7 -0
- package/dist/features/environment-lifecycle/adapters/outbound/resolveInfraProjectAsync.d.ts.map +1 -0
- package/dist/{project.js → features/environment-lifecycle/adapters/outbound/resolveInfraProjectAsync.js} +10 -34
- package/dist/features/environment-lifecycle/adapters/outbound/resolveInfraProjectAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeInfraGeneratedArtifactsAsync.d.ts +5 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeInfraGeneratedArtifactsAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeInfraGeneratedArtifactsAsync.js +28 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeInfraGeneratedArtifactsAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeStoredInfraStateAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeStoredInfraStateAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeStoredInfraStateAsync.js +16 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeStoredInfraStateAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/ports/outbound/infraAdapterPackage.d.ts +9 -0
- package/dist/features/environment-lifecycle/application/ports/outbound/infraAdapterPackage.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/ports/outbound/infraAdapterPackage.js +2 -0
- package/dist/features/environment-lifecycle/application/ports/outbound/infraAdapterPackage.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/collectInfraWorkloadsAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/collectInfraWorkloadsAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/collectInfraWorkloadsAsync.js +15 -0
- package/dist/features/environment-lifecycle/application/use-cases/collectInfraWorkloadsAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/destroyInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/destroyInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/destroyInfraEnvironmentAsync.js +84 -0
- package/dist/features/environment-lifecycle/application/use-cases/destroyInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/downInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/downInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/downInfraEnvironmentAsync.js +55 -0
- package/dist/features/environment-lifecycle/application/use-cases/downInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/generateInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/generateInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/generateInfraEnvironmentAsync.js +38 -0
- package/dist/features/environment-lifecycle/application/use-cases/generateInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/getInfraEnvironmentOutputs.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/getInfraEnvironmentOutputs.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/getInfraEnvironmentOutputs.js +34 -0
- package/dist/features/environment-lifecycle/application/use-cases/getInfraEnvironmentOutputs.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/planInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/planInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/planInfraEnvironmentAsync.js +57 -0
- package/dist/features/environment-lifecycle/application/use-cases/planInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/prepareInfraOperationAsync.d.ts +5 -0
- package/dist/features/environment-lifecycle/application/use-cases/prepareInfraOperationAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/prepareInfraOperationAsync.js +109 -0
- package/dist/features/environment-lifecycle/application/use-cases/prepareInfraOperationAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/resolveInfraAdaptersAsync.d.ts +6 -0
- package/dist/features/environment-lifecycle/application/use-cases/resolveInfraAdaptersAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/resolveInfraAdaptersAsync.js +181 -0
- package/dist/features/environment-lifecycle/application/use-cases/resolveInfraAdaptersAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/statusInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/statusInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/statusInfraEnvironmentAsync.js +68 -0
- package/dist/features/environment-lifecycle/application/use-cases/statusInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/upInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/upInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/upInfraEnvironmentAsync.js +98 -0
- package/dist/features/environment-lifecycle/application/use-cases/upInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraAdaptersAsync.d.ts +5 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraAdaptersAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraAdaptersAsync.js +17 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraAdaptersAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraEnvironmentAsync.js +13 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/composition/createInfraCommandServices.d.ts +4 -0
- package/dist/features/environment-lifecycle/composition/createInfraCommandServices.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/composition/createInfraCommandServices.js +43 -0
- package/dist/features/environment-lifecycle/composition/createInfraCommandServices.js.map +1 -0
- package/dist/features/environment-lifecycle/domain/orderInfraPlanActions.d.ts +4 -0
- package/dist/features/environment-lifecycle/domain/orderInfraPlanActions.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/domain/orderInfraPlanActions.js +54 -0
- package/dist/features/environment-lifecycle/domain/orderInfraPlanActions.js.map +1 -0
- package/dist/features/environment-lifecycle/domain/resolveInfraEnvironment.d.ts +5 -0
- package/dist/features/environment-lifecycle/domain/resolveInfraEnvironment.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/domain/resolveInfraEnvironment.js +39 -0
- package/dist/features/environment-lifecycle/domain/resolveInfraEnvironment.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/appendInfraFailure.d.ts +7 -0
- package/dist/features/environment-lifecycle/utils/appendInfraFailure.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/appendInfraFailure.js +5 -0
- package/dist/features/environment-lifecycle/utils/appendInfraFailure.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/createInfraExecutionContext.d.ts +5 -0
- package/dist/features/environment-lifecycle/utils/createInfraExecutionContext.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/createInfraExecutionContext.js +13 -0
- package/dist/features/environment-lifecycle/utils/createInfraExecutionContext.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/createInfraFailure.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/createInfraFailure.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/createInfraFailure.js +5 -0
- package/dist/features/environment-lifecycle/utils/createInfraFailure.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/createInfraLedger.d.ts +12 -0
- package/dist/features/environment-lifecycle/utils/createInfraLedger.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/createInfraLedger.js +14 -0
- package/dist/features/environment-lifecycle/utils/createInfraLedger.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/infraIdentityKey.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/infraIdentityKey.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/infraIdentityKey.js +5 -0
- package/dist/features/environment-lifecycle/utils/infraIdentityKey.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/isInfraStoredState.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/isInfraStoredState.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/isInfraStoredState.js +103 -0
- package/dist/features/environment-lifecycle/utils/isInfraStoredState.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraOutputs.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraOutputs.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraOutputs.js +10 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraOutputs.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraResources.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraResources.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraResources.js +10 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraResources.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/normalizeInfraEnvironmentKey.d.ts +3 -0
- package/dist/features/environment-lifecycle/utils/normalizeInfraEnvironmentKey.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/normalizeInfraEnvironmentKey.js +8 -0
- package/dist/features/environment-lifecycle/utils/normalizeInfraEnvironmentKey.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/resolveInfraStatePath.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/resolveInfraStatePath.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/resolveInfraStatePath.js +11 -0
- package/dist/features/environment-lifecycle/utils/resolveInfraStatePath.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/resolveProjectFile.d.ts +3 -0
- package/dist/features/environment-lifecycle/utils/resolveProjectFile.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/resolveProjectFile.js +19 -0
- package/dist/features/environment-lifecycle/utils/resolveProjectFile.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterOutputs.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterOutputs.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterOutputs.js +6 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterOutputs.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterResources.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterResources.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterResources.js +6 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterResources.js.map +1 -0
- package/dist/index.d.ts +16 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -15
- package/dist/index.js.map +1 -1
- package/dist/metadata/index.d.ts +1 -1
- package/dist/metadata/index.d.ts.map +1 -1
- package/dist/metadata/index.js +1 -1
- package/dist/metadata/index.js.map +1 -1
- package/dist/project/index.d.ts +7 -5
- package/dist/project/index.d.ts.map +1 -1
- package/dist/project/index.js +6 -5
- package/dist/project/index.js.map +1 -1
- package/dist/readme-usage.js +17 -26
- package/dist/readme-usage.js.map +1 -1
- package/dist/testSupport.d.ts +1 -1
- package/dist/testSupport.d.ts.map +1 -1
- package/dist/testSupport.js +11 -1
- package/dist/testSupport.js.map +1 -1
- package/dist/types/infraCli.d.ts +91 -0
- package/dist/types/infraCli.d.ts.map +1 -0
- package/dist/types/infraCli.js +2 -0
- package/dist/types/infraCli.js.map +1 -0
- package/dist/types/infraOrchestration.d.ts +84 -0
- package/dist/types/infraOrchestration.d.ts.map +1 -0
- package/dist/types/infraOrchestration.js +2 -0
- package/dist/types/infraOrchestration.js.map +1 -0
- package/dist/{project.d.ts → types/infraProject.d.ts} +6 -6
- package/dist/types/infraProject.d.ts.map +1 -0
- package/dist/types/infraProject.js +2 -0
- package/dist/types/infraProject.js.map +1 -0
- package/package.json +20 -10
- package/src/adapterPackages.integration.test.ts +79 -0
- package/src/cli/bin.ts +2 -61
- package/src/cli/cli.test.ts +35 -126
- package/src/cli/commands/destroy.ts +57 -0
- package/src/cli/commands/down.ts +28 -0
- package/src/cli/commands/generate.ts +34 -0
- package/src/cli/commands/outputs.ts +25 -0
- package/src/cli/commands/plan.ts +20 -0
- package/src/cli/commands/status.ts +20 -0
- package/src/cli/commands/up.ts +29 -0
- package/src/cli/commands/validate.ts +20 -0
- package/src/cli/constants.ts +19 -0
- package/src/cli/createDefaultInfraCommandContext.ts +17 -0
- package/src/cli/createInfraRuntimeProvider.ts +35 -0
- package/src/cli/createProviderCommandDescriptors.ts +8 -0
- package/src/cli/findInfraCommand.ts +7 -0
- package/src/cli/index.test.ts +12 -20
- package/src/cli/index.ts +7 -49
- package/src/cli/renderInfraRootHelp.ts +23 -0
- package/src/cli/renderUnknownInfraCommand.ts +4 -0
- package/src/cli/runInfraCliAsync.ts +51 -0
- package/src/cli/runInfraCommandAsync.ts +114 -0
- package/src/cli/utils/prepareInfraCommandOperationAsync.ts +64 -0
- package/src/cli/utils/requireInfraSuccess.ts +24 -0
- package/src/cli/utils/resolveInfraPersistence.ts +22 -0
- package/src/cli/utils/writeInfraEnvironmentOutputs.ts +24 -0
- package/src/cli/utils/writeInfraStructured.ts +11 -0
- package/src/commands.test.ts +198 -196
- package/src/{packageMetadata.ts → constants.ts} +5 -2
- package/src/environmentLifecycle.test.ts +193 -0
- package/src/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraCredentialPort.ts +52 -0
- package/src/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraSecretPort.ts +32 -0
- package/src/features/environment-lifecycle/adapters/outbound/createNodeInfraAdapterPackageResolver.ts +10 -0
- package/src/features/environment-lifecycle/adapters/outbound/readStoredInfraStateAsync.ts +34 -0
- package/src/features/environment-lifecycle/adapters/outbound/removeStoredInfraStateAsync.ts +12 -0
- package/src/{project.ts → features/environment-lifecycle/adapters/outbound/resolveInfraProjectAsync.ts} +10 -45
- package/src/features/environment-lifecycle/adapters/outbound/writeInfraGeneratedArtifactsAsync.ts +34 -0
- package/src/features/environment-lifecycle/adapters/outbound/writeStoredInfraStateAsync.ts +21 -0
- package/src/features/environment-lifecycle/application/ports/outbound/infraAdapterPackage.ts +10 -0
- package/src/features/environment-lifecycle/application/use-cases/collectInfraWorkloadsAsync.ts +25 -0
- package/src/features/environment-lifecycle/application/use-cases/destroyInfraEnvironmentAsync.ts +119 -0
- package/src/features/environment-lifecycle/application/use-cases/downInfraEnvironmentAsync.ts +65 -0
- package/src/features/environment-lifecycle/application/use-cases/generateInfraEnvironmentAsync.ts +51 -0
- package/src/features/environment-lifecycle/application/use-cases/getInfraEnvironmentOutputs.ts +41 -0
- package/src/features/environment-lifecycle/application/use-cases/planInfraEnvironmentAsync.ts +67 -0
- package/src/features/environment-lifecycle/application/use-cases/prepareInfraOperationAsync.ts +137 -0
- package/src/features/environment-lifecycle/application/use-cases/resolveInfraAdaptersAsync.ts +257 -0
- package/src/features/environment-lifecycle/application/use-cases/statusInfraEnvironmentAsync.ts +80 -0
- package/src/features/environment-lifecycle/application/use-cases/upInfraEnvironmentAsync.ts +126 -0
- package/src/features/environment-lifecycle/application/use-cases/validateInfraAdaptersAsync.ts +25 -0
- package/src/features/environment-lifecycle/application/use-cases/validateInfraEnvironmentAsync.ts +21 -0
- package/src/features/environment-lifecycle/composition/createInfraCommandServices.ts +47 -0
- package/src/features/environment-lifecycle/domain/orderInfraPlanActions.ts +64 -0
- package/src/features/environment-lifecycle/domain/resolveInfraEnvironment.ts +62 -0
- package/src/features/environment-lifecycle/utils/appendInfraFailure.ts +9 -0
- package/src/features/environment-lifecycle/utils/createInfraExecutionContext.ts +24 -0
- package/src/features/environment-lifecycle/utils/createInfraFailure.ts +6 -0
- package/src/features/environment-lifecycle/utils/createInfraLedger.ts +30 -0
- package/src/features/environment-lifecycle/utils/infraIdentityKey.ts +6 -0
- package/src/features/environment-lifecycle/utils/isInfraStoredState.ts +141 -0
- package/src/features/environment-lifecycle/utils/mergeInfraOutputs.ts +14 -0
- package/src/features/environment-lifecycle/utils/mergeInfraResources.ts +14 -0
- package/src/features/environment-lifecycle/utils/normalizeInfraEnvironmentKey.ts +7 -0
- package/src/features/environment-lifecycle/utils/resolveInfraStatePath.ts +12 -0
- package/src/features/environment-lifecycle/utils/resolveProjectFile.ts +22 -0
- package/src/features/environment-lifecycle/utils/retainUnchangedAdapterOutputs.ts +15 -0
- package/src/features/environment-lifecycle/utils/retainUnchangedAdapterResources.ts +15 -0
- package/src/index.test.ts +22 -315
- package/src/index.ts +41 -53
- package/src/infraComposition.integration.test.ts +128 -0
- package/src/infraOperations.test.ts +386 -0
- package/src/infraUp.test.ts +260 -0
- package/src/metadata/index.ts +1 -1
- package/src/package.test.ts +4 -2
- package/src/project/index.test.ts +8 -188
- package/src/project/index.ts +7 -22
- package/src/project.test.ts +39 -189
- package/src/projectContractsParser.test.ts +2 -2
- package/src/projectInfrastructure.test.ts +121 -167
- package/src/readme-usage.ts +17 -26
- package/src/testSupport.ts +12 -2
- package/src/types/infraCli.ts +115 -0
- package/src/types/infraOrchestration.ts +126 -0
- package/src/types/infraProject.ts +15 -0
- package/dist/adapters/minikube/auth/index.d.ts +0 -8
- package/dist/adapters/minikube/auth/index.d.ts.map +0 -1
- package/dist/adapters/minikube/auth/index.js +0 -29
- package/dist/adapters/minikube/auth/index.js.map +0 -1
- package/dist/adapters/minikube/auth/oauthRuntime.d.ts +0 -4
- package/dist/adapters/minikube/auth/oauthRuntime.d.ts.map +0 -1
- package/dist/adapters/minikube/auth/oauthRuntime.js +0 -138
- package/dist/adapters/minikube/auth/oauthRuntime.js.map +0 -1
- package/dist/adapters/minikube/auth/supabase/index.d.ts +0 -7
- package/dist/adapters/minikube/auth/supabase/index.d.ts.map +0 -1
- package/dist/adapters/minikube/auth/supabase/index.js +0 -232
- package/dist/adapters/minikube/auth/supabase/index.js.map +0 -1
- package/dist/adapters/minikube/auth/supabase/profile.d.ts +0 -20
- package/dist/adapters/minikube/auth/supabase/profile.d.ts.map +0 -1
- package/dist/adapters/minikube/auth/supabase/profile.js +0 -452
- package/dist/adapters/minikube/auth/supabase/profile.js.map +0 -1
- package/dist/adapters/minikube/auth/targetAwareOAuthRuntime.d.ts +0 -7
- package/dist/adapters/minikube/auth/targetAwareOAuthRuntime.d.ts.map +0 -1
- package/dist/adapters/minikube/auth/targetAwareOAuthRuntime.js +0 -104
- package/dist/adapters/minikube/auth/targetAwareOAuthRuntime.js.map +0 -1
- package/dist/adapters/minikube/authz/cerbos/index.d.ts +0 -13
- package/dist/adapters/minikube/authz/cerbos/index.d.ts.map +0 -1
- package/dist/adapters/minikube/authz/cerbos/index.js +0 -382
- package/dist/adapters/minikube/authz/cerbos/index.js.map +0 -1
- package/dist/adapters/minikube/authz/index.d.ts +0 -9
- package/dist/adapters/minikube/authz/index.d.ts.map +0 -1
- package/dist/adapters/minikube/authz/index.js +0 -23
- package/dist/adapters/minikube/authz/index.js.map +0 -1
- package/dist/adapters/minikube/base/index.d.ts +0 -14
- package/dist/adapters/minikube/base/index.d.ts.map +0 -1
- package/dist/adapters/minikube/base/index.js +0 -3433
- package/dist/adapters/minikube/base/index.js.map +0 -1
- package/dist/adapters/minikube/base/supabaseMigrations.d.ts +0 -2
- package/dist/adapters/minikube/base/supabaseMigrations.d.ts.map +0 -1
- package/dist/adapters/minikube/base/supabaseMigrations.js +0 -6
- package/dist/adapters/minikube/base/supabaseMigrations.js.map +0 -1
- package/dist/adapters/minikube/contracts.d.ts +0 -34
- package/dist/adapters/minikube/contracts.d.ts.map +0 -1
- package/dist/adapters/minikube/contracts.js +0 -10
- package/dist/adapters/minikube/contracts.js.map +0 -1
- package/dist/adapters/minikube/index.d.ts +0 -3
- package/dist/adapters/minikube/index.d.ts.map +0 -1
- package/dist/adapters/minikube/index.js +0 -136
- package/dist/adapters/minikube/index.js.map +0 -1
- package/dist/adapters/minikube/secrets/index.d.ts +0 -7
- package/dist/adapters/minikube/secrets/index.d.ts.map +0 -1
- package/dist/adapters/minikube/secrets/index.js +0 -13
- package/dist/adapters/minikube/secrets/index.js.map +0 -1
- package/dist/adapters/minikube/secrets/supabase-vault/index.d.ts +0 -8
- package/dist/adapters/minikube/secrets/supabase-vault/index.d.ts.map +0 -1
- package/dist/adapters/minikube/secrets/supabase-vault/index.js +0 -118
- package/dist/adapters/minikube/secrets/supabase-vault/index.js.map +0 -1
- package/dist/adapters/minikube/storage/index.d.ts +0 -7
- package/dist/adapters/minikube/storage/index.d.ts.map +0 -1
- package/dist/adapters/minikube/storage/index.js +0 -77
- package/dist/adapters/minikube/storage/index.js.map +0 -1
- package/dist/adapters/minikube/storage/supabase/index.d.ts +0 -7
- package/dist/adapters/minikube/storage/supabase/index.d.ts.map +0 -1
- package/dist/adapters/minikube/storage/supabase/index.js +0 -82
- package/dist/adapters/minikube/storage/supabase/index.js.map +0 -1
- package/dist/authRedirects.d.ts +0 -19
- package/dist/authRedirects.d.ts.map +0 -1
- package/dist/authRedirects.js +0 -80
- package/dist/authRedirects.js.map +0 -1
- package/dist/authTargetRedirects.d.ts +0 -12
- package/dist/authTargetRedirects.d.ts.map +0 -1
- package/dist/authTargetRedirects.js +0 -32
- package/dist/authTargetRedirects.js.map +0 -1
- package/dist/commandContext.d.ts +0 -12
- package/dist/commandContext.d.ts.map +0 -1
- package/dist/commandContext.js.map +0 -1
- package/dist/commands.d.ts +0 -95
- package/dist/commands.d.ts.map +0 -1
- package/dist/commands.js +0 -256
- package/dist/commands.js.map +0 -1
- package/dist/infraValidation.d.ts +0 -4
- package/dist/infraValidation.d.ts.map +0 -1
- package/dist/infraValidation.js +0 -63
- package/dist/infraValidation.js.map +0 -1
- package/dist/packageMetadata.d.ts +0 -10
- package/dist/packageMetadata.d.ts.map +0 -1
- package/dist/packageMetadata.js.map +0 -1
- package/dist/project.d.ts.map +0 -1
- package/dist/project.js.map +0 -1
- package/dist/projectDatabase.d.ts +0 -5
- package/dist/projectDatabase.d.ts.map +0 -1
- package/dist/projectDatabase.js +0 -22
- package/dist/projectDatabase.js.map +0 -1
- package/dist/projectEnvironment.d.ts +0 -6
- package/dist/projectEnvironment.d.ts.map +0 -1
- package/dist/projectEnvironment.js +0 -45
- package/dist/projectEnvironment.js.map +0 -1
- package/dist/projectInfrastructure.d.ts +0 -38
- package/dist/projectInfrastructure.d.ts.map +0 -1
- package/dist/projectInfrastructure.js +0 -145
- package/dist/projectInfrastructure.js.map +0 -1
- package/dist/runtime.d.ts +0 -54
- package/dist/runtime.d.ts.map +0 -1
- package/dist/runtime.js +0 -151
- package/dist/runtime.js.map +0 -1
- package/dist/secretStore.d.ts +0 -19
- package/dist/secretStore.d.ts.map +0 -1
- package/dist/secretStore.js +0 -22
- package/dist/secretStore.js.map +0 -1
- package/dist/types.d.ts +0 -70
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/src/adapters/minikube/README.md +0 -115
- package/src/adapters/minikube/appRuntimeServing.test.ts +0 -28
- package/src/adapters/minikube/auth/index.ts +0 -40
- package/src/adapters/minikube/auth/oauthRuntime.ts +0 -163
- package/src/adapters/minikube/auth/supabase/index.test.ts +0 -227
- package/src/adapters/minikube/auth/supabase/index.ts +0 -293
- package/src/adapters/minikube/auth/supabase/oauthRuntime.test.ts +0 -154
- package/src/adapters/minikube/auth/supabase/profile.integration.test.ts +0 -1028
- package/src/adapters/minikube/auth/supabase/profile.ts +0 -526
- package/src/adapters/minikube/auth/supabase/providerAssignments.test.ts +0 -36
- package/src/adapters/minikube/auth/targetAwareOAuthRuntime.test.ts +0 -83
- package/src/adapters/minikube/auth/targetAwareOAuthRuntime.ts +0 -136
- package/src/adapters/minikube/authz/cerbos/index.ts +0 -486
- package/src/adapters/minikube/authz/index.ts +0 -32
- package/src/adapters/minikube/base/appImageBuild.test.ts +0 -352
- package/src/adapters/minikube/base/index.test.ts +0 -693
- package/src/adapters/minikube/base/index.ts +0 -3763
- package/src/adapters/minikube/base/portForwardRuntime.test.ts +0 -624
- package/src/adapters/minikube/base/supabaseMigrations.test.ts +0 -168
- package/src/adapters/minikube/base/supabaseMigrations.ts +0 -5
- package/src/adapters/minikube/base/twoAppIsolation.integration.test.ts +0 -898
- package/src/adapters/minikube/base/upgradeReconciliation.test.ts +0 -135
- package/src/adapters/minikube/contracts.ts +0 -46
- package/src/adapters/minikube/index.ts +0 -172
- package/src/adapters/minikube/secrets/index.test.ts +0 -147
- package/src/adapters/minikube/secrets/index.ts +0 -19
- package/src/adapters/minikube/secrets/supabase-vault/index.ts +0 -139
- package/src/adapters/minikube/storage/index.ts +0 -91
- package/src/adapters/minikube/storage/supabase/index.ts +0 -108
- package/src/apiInfrastructure.test.ts +0 -69
- package/src/authRedirects.test.ts +0 -63
- package/src/authRedirects.ts +0 -113
- package/src/authTargetRedirects.test.ts +0 -62
- package/src/authTargetRedirects.ts +0 -46
- package/src/commandContext.ts +0 -27
- package/src/commands.ts +0 -404
- package/src/generatedApiLedgerCleanup.test.ts +0 -72
- package/src/infraApiValidation.test.ts +0 -42
- package/src/infraValidation.ts +0 -99
- package/src/minikubeImageLifecycle.test.ts +0 -35
- package/src/projectDatabase.ts +0 -27
- package/src/projectEnvironment.ts +0 -51
- package/src/projectInfrastructure.ts +0 -221
- package/src/runtime.test.ts +0 -124
- package/src/runtime.ts +0 -234
- package/src/secretStore.test.ts +0 -76
- package/src/secretStore.ts +0 -44
- package/src/types.ts +0 -82
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { InfraDiagnostic, InfraPlanAction } from '@ankhorage/contracts/infra';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
InfraOperationRequest,
|
|
5
|
+
InfraOrchestrationDependencies,
|
|
6
|
+
InfraPlanOperationResult,
|
|
7
|
+
} from '../../../../types/infraOrchestration.js';
|
|
8
|
+
import { orderInfraPlanActions } from '../../domain/orderInfraPlanActions.js';
|
|
9
|
+
import { appendInfraFailure } from '../../utils/appendInfraFailure.js';
|
|
10
|
+
import { prepareInfraOperationAsync } from './prepareInfraOperationAsync.js';
|
|
11
|
+
|
|
12
|
+
/*** Aggregate a side-effect-free dependency-ordered plan from all selected adapters. */
|
|
13
|
+
export async function planInfraEnvironmentAsync(
|
|
14
|
+
request: InfraOperationRequest,
|
|
15
|
+
dependencies: InfraOrchestrationDependencies,
|
|
16
|
+
): Promise<InfraPlanOperationResult> {
|
|
17
|
+
const prepared = await prepareInfraOperationAsync(request, 'plan', dependencies);
|
|
18
|
+
if (!prepared.ok) return prepared;
|
|
19
|
+
const diagnostics: InfraDiagnostic[] = [...prepared.diagnostics];
|
|
20
|
+
const actions: InfraPlanAction[] = [];
|
|
21
|
+
const compute = await prepared.value.adapters.compute.planAsync(
|
|
22
|
+
prepared.value.context,
|
|
23
|
+
prepared.value.environment.desired.deployment.compute,
|
|
24
|
+
);
|
|
25
|
+
if (!compute.ok) return appendInfraFailure(diagnostics, compute);
|
|
26
|
+
actions.push(...compute.value);
|
|
27
|
+
diagnostics.push(...compute.diagnostics);
|
|
28
|
+
if (prepared.value.runtimeDesired.targets.length === 0) {
|
|
29
|
+
actions.push({
|
|
30
|
+
owner: {
|
|
31
|
+
projectId: request.projectId,
|
|
32
|
+
environment: prepared.value.environment.id,
|
|
33
|
+
adapter: prepared.value.adapters.runtime.descriptor.id,
|
|
34
|
+
resourceId: 'runtime',
|
|
35
|
+
},
|
|
36
|
+
operation: 'create',
|
|
37
|
+
impact: 'none',
|
|
38
|
+
detail: 'Runtime planning is deferred until the planned compute target exists.',
|
|
39
|
+
dependsOn: compute.value.map(({ owner }) => owner),
|
|
40
|
+
});
|
|
41
|
+
} else {
|
|
42
|
+
const runtime = await prepared.value.adapters.runtime.planAsync(
|
|
43
|
+
prepared.value.context,
|
|
44
|
+
prepared.value.runtimeDesired,
|
|
45
|
+
);
|
|
46
|
+
if (!runtime.ok) return appendInfraFailure(diagnostics, runtime);
|
|
47
|
+
actions.push(...runtime.value);
|
|
48
|
+
diagnostics.push(...runtime.diagnostics);
|
|
49
|
+
}
|
|
50
|
+
for (const service of prepared.value.adapters.services) {
|
|
51
|
+
const plan = await service.planAsync(prepared.value.context);
|
|
52
|
+
if (!plan.ok) return appendInfraFailure(diagnostics, plan);
|
|
53
|
+
actions.push(...plan.value);
|
|
54
|
+
diagnostics.push(...plan.diagnostics);
|
|
55
|
+
}
|
|
56
|
+
const ordered = orderInfraPlanActions(actions);
|
|
57
|
+
if (!ordered.ok) return appendInfraFailure(diagnostics, ordered);
|
|
58
|
+
return {
|
|
59
|
+
ok: true,
|
|
60
|
+
value: {
|
|
61
|
+
projectId: request.projectId,
|
|
62
|
+
environment: prepared.value.environment.id,
|
|
63
|
+
actions: ordered.value,
|
|
64
|
+
},
|
|
65
|
+
diagnostics,
|
|
66
|
+
};
|
|
67
|
+
}
|
package/src/features/environment-lifecycle/application/use-cases/prepareInfraOperationAsync.ts
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { InfraDiagnostic, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
InfraOperationRequest,
|
|
5
|
+
InfraOrchestrationDependencies,
|
|
6
|
+
PreparedInfraOperation,
|
|
7
|
+
} from '../../../../types/infraOrchestration.js';
|
|
8
|
+
import { resolveInfraEnvironment } from '../../domain/resolveInfraEnvironment.js';
|
|
9
|
+
import { appendInfraFailure } from '../../utils/appendInfraFailure.js';
|
|
10
|
+
import { createInfraExecutionContext } from '../../utils/createInfraExecutionContext.js';
|
|
11
|
+
import { collectInfraWorkloadsAsync } from './collectInfraWorkloadsAsync.js';
|
|
12
|
+
import { resolveInfraAdaptersAsync } from './resolveInfraAdaptersAsync.js';
|
|
13
|
+
import { validateInfraAdaptersAsync } from './validateInfraAdaptersAsync.js';
|
|
14
|
+
|
|
15
|
+
/*** Resolve and validate one operation without creating, updating or deleting infrastructure. */
|
|
16
|
+
export async function prepareInfraOperationAsync(
|
|
17
|
+
request: InfraOperationRequest,
|
|
18
|
+
operation: 'validate' | 'plan' | 'generate' | 'status' | 'outputs' | 'down' | 'destroy',
|
|
19
|
+
dependencies: InfraOrchestrationDependencies,
|
|
20
|
+
): Promise<InfraResult<PreparedInfraOperation>> {
|
|
21
|
+
const diagnostics: InfraDiagnostic[] = [];
|
|
22
|
+
const environment = resolveInfraEnvironment({
|
|
23
|
+
manifest: request.manifest,
|
|
24
|
+
environment: request.environment,
|
|
25
|
+
operation,
|
|
26
|
+
});
|
|
27
|
+
if (!environment.ok) return environment;
|
|
28
|
+
diagnostics.push(...environment.diagnostics);
|
|
29
|
+
if (
|
|
30
|
+
request.previous !== undefined &&
|
|
31
|
+
request.previousDesired !== undefined &&
|
|
32
|
+
!hasSameProviderSelection(request.previousDesired, environment.value.desired)
|
|
33
|
+
) {
|
|
34
|
+
return {
|
|
35
|
+
ok: false,
|
|
36
|
+
diagnostics: [
|
|
37
|
+
...diagnostics,
|
|
38
|
+
{
|
|
39
|
+
severity: 'error',
|
|
40
|
+
code: 'infra-provider-selection-changed',
|
|
41
|
+
message:
|
|
42
|
+
'Stored Infra resources use another provider selection. Destroy that environment before applying the new selection.',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const adapters = await resolveInfraAdaptersAsync(
|
|
48
|
+
environment.value.desired,
|
|
49
|
+
dependencies.adapterResolver,
|
|
50
|
+
);
|
|
51
|
+
if (!adapters.ok) return appendInfraFailure(diagnostics, adapters);
|
|
52
|
+
diagnostics.push(...adapters.diagnostics);
|
|
53
|
+
const context = createInfraExecutionContext(request, environment.value, dependencies);
|
|
54
|
+
const validation = await validateInfraAdaptersAsync(context, adapters.value);
|
|
55
|
+
if (!validation.ok) return appendInfraFailure(diagnostics, validation);
|
|
56
|
+
diagnostics.push(...validation.diagnostics);
|
|
57
|
+
const workloads = await collectInfraWorkloadsAsync(context, adapters.value.services);
|
|
58
|
+
if (!workloads.ok) return appendInfraFailure(diagnostics, workloads);
|
|
59
|
+
diagnostics.push(...workloads.diagnostics);
|
|
60
|
+
const compute = await adapters.value.compute.inspectAsync(
|
|
61
|
+
context,
|
|
62
|
+
environment.value.desired.deployment.compute,
|
|
63
|
+
);
|
|
64
|
+
if (!compute.ok) return appendInfraFailure(diagnostics, compute);
|
|
65
|
+
diagnostics.push(...compute.diagnostics);
|
|
66
|
+
const runtimeDesired = {
|
|
67
|
+
selection: environment.value.desired.deployment.runtime,
|
|
68
|
+
targets:
|
|
69
|
+
compute.value.targets.length > 0
|
|
70
|
+
? compute.value.targets
|
|
71
|
+
: (request.previous?.targets ?? compute.value.targets),
|
|
72
|
+
workloads: [...(environment.value.desired.workloads ?? []), ...workloads.value],
|
|
73
|
+
availableOutputs: mergeOutputs(request.previous?.outputs ?? [], compute.value.outputs),
|
|
74
|
+
};
|
|
75
|
+
if (runtimeDesired.targets.length === 0) {
|
|
76
|
+
diagnostics.push({
|
|
77
|
+
severity: 'info',
|
|
78
|
+
code: 'infra-runtime-target-deferred',
|
|
79
|
+
message: 'Runtime validation is deferred until compute exposes a portable target.',
|
|
80
|
+
});
|
|
81
|
+
} else {
|
|
82
|
+
const runtime = await adapters.value.runtime.validateAsync(context, runtimeDesired);
|
|
83
|
+
if (!runtime.ok) return appendInfraFailure(diagnostics, runtime);
|
|
84
|
+
diagnostics.push(...runtime.diagnostics);
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
ok: true,
|
|
88
|
+
value: {
|
|
89
|
+
environment: environment.value,
|
|
90
|
+
context,
|
|
91
|
+
adapters: adapters.value,
|
|
92
|
+
compute: compute.value,
|
|
93
|
+
runtimeDesired,
|
|
94
|
+
},
|
|
95
|
+
diagnostics,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/*** Compare provider identity only; configuration changes remain normal in-place reconciliation. */
|
|
100
|
+
function hasSameProviderSelection(
|
|
101
|
+
previous: PreparedInfraOperation['environment']['desired'],
|
|
102
|
+
current: PreparedInfraOperation['environment']['desired'],
|
|
103
|
+
): boolean {
|
|
104
|
+
return providerSelection(previous).join('\0') === providerSelection(current).join('\0');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/*** Read the closed provider slots in stable capability order. */
|
|
108
|
+
function providerSelection(
|
|
109
|
+
desired: PreparedInfraOperation['environment']['desired'],
|
|
110
|
+
): readonly (string | undefined)[] {
|
|
111
|
+
return [
|
|
112
|
+
desired.deployment.compute.provider,
|
|
113
|
+
desired.deployment.runtime.provider,
|
|
114
|
+
desired.database?.provider,
|
|
115
|
+
desired.objectStorage?.provider,
|
|
116
|
+
desired.auth?.provider,
|
|
117
|
+
desired.authz?.provider,
|
|
118
|
+
desired.secretStore?.provider,
|
|
119
|
+
];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/*** Prefer freshly inspected outputs while preserving unrelated safe prior values. */
|
|
123
|
+
function mergeOutputs(
|
|
124
|
+
previous: PreparedInfraOperation['runtimeDesired']['availableOutputs'],
|
|
125
|
+
current: PreparedInfraOperation['runtimeDesired']['availableOutputs'],
|
|
126
|
+
): PreparedInfraOperation['runtimeDesired']['availableOutputs'] {
|
|
127
|
+
const currentKeys = new Set(current.map(outputKey));
|
|
128
|
+
return [...previous.filter((output) => !currentKeys.has(outputKey(output))), ...current];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/*** Create one stable public-or-secret output identity without reading its value. */
|
|
132
|
+
function outputKey(
|
|
133
|
+
output: PreparedInfraOperation['runtimeDesired']['availableOutputs'][number],
|
|
134
|
+
): string {
|
|
135
|
+
const { owner } = output;
|
|
136
|
+
return `${owner.projectId}\0${owner.environment}\0${owner.adapter}\0${owner.resourceId}\0${output.name}`;
|
|
137
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import {
|
|
2
|
+
INFRA_ADAPTER_CATALOG,
|
|
3
|
+
type InfraAdapterDescriptor,
|
|
4
|
+
type InfraComputeAdapter,
|
|
5
|
+
type InfraDiagnostic,
|
|
6
|
+
type InfraEnvironmentSpec,
|
|
7
|
+
type InfraResult,
|
|
8
|
+
type InfraRuntimeAdapter,
|
|
9
|
+
type InfraServiceAdapter,
|
|
10
|
+
isInfraAdapterDescriptor,
|
|
11
|
+
validateInfraAdapterSelection,
|
|
12
|
+
} from '@ankhorage/contracts/infra';
|
|
13
|
+
|
|
14
|
+
import type { ResolvedInfraAdapters } from '../../../../types/infraOrchestration.js';
|
|
15
|
+
import type {
|
|
16
|
+
InfraAdapterPackageModule,
|
|
17
|
+
InfraAdapterPackageResolver,
|
|
18
|
+
} from '../ports/outbound/infraAdapterPackage.js';
|
|
19
|
+
|
|
20
|
+
/*** Resolve exactly the selected provider packages and validate their public adapter boundaries. */
|
|
21
|
+
export async function resolveInfraAdaptersAsync(
|
|
22
|
+
environment: InfraEnvironmentSpec,
|
|
23
|
+
resolver: InfraAdapterPackageResolver,
|
|
24
|
+
): Promise<InfraResult<ResolvedInfraAdapters>> {
|
|
25
|
+
const entries = getSelectedCatalogEntries(environment);
|
|
26
|
+
const modules = await Promise.all(
|
|
27
|
+
entries.map(async (entry) => loadModuleAsync(entry.package, resolver)),
|
|
28
|
+
);
|
|
29
|
+
const loadingDiagnostics = modules.flatMap((result) => result.diagnostics);
|
|
30
|
+
if (loadingDiagnostics.length > 0) return { ok: false, diagnostics: loadingDiagnostics };
|
|
31
|
+
const loaded = modules.flatMap((result) => (result.ok ? [result.value] : []));
|
|
32
|
+
const selection = validateInfraAdapterSelection(
|
|
33
|
+
environment,
|
|
34
|
+
loaded.map(({ infraAdapterDescriptor }) => infraAdapterDescriptor),
|
|
35
|
+
);
|
|
36
|
+
if (!selection.ok) return selection;
|
|
37
|
+
const instantiated = instantiateModules(loaded);
|
|
38
|
+
if (!instantiated.ok) return instantiated;
|
|
39
|
+
const instances = instantiated.value;
|
|
40
|
+
const compute = instances.find(isComputeAdapter);
|
|
41
|
+
const runtime = instances.find(isRuntimeAdapter);
|
|
42
|
+
const services = instances.filter(isServiceAdapter);
|
|
43
|
+
const diagnostics = validateInstances(compute, runtime, services, selection.value);
|
|
44
|
+
return diagnostics.length > 0 || compute === undefined || runtime === undefined
|
|
45
|
+
? { ok: false, diagnostics }
|
|
46
|
+
: {
|
|
47
|
+
ok: true,
|
|
48
|
+
value: { compute, runtime, services: orderServiceAdapters(services) },
|
|
49
|
+
diagnostics: [],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/*** Order services by selected capability dependencies while preserving catalog order for peers. */
|
|
54
|
+
function orderServiceAdapters(
|
|
55
|
+
services: readonly InfraServiceAdapter[],
|
|
56
|
+
): readonly InfraServiceAdapter[] {
|
|
57
|
+
const pending = [...services];
|
|
58
|
+
const ordered: InfraServiceAdapter[] = [];
|
|
59
|
+
const provided = new Set<string>(['compute', 'runtime', 'workloads', 'networking']);
|
|
60
|
+
while (pending.length > 0) {
|
|
61
|
+
const index = pending.findIndex((service) =>
|
|
62
|
+
service.descriptor.dependencies.every(
|
|
63
|
+
(dependency) =>
|
|
64
|
+
provided.has(dependency) ||
|
|
65
|
+
!services.some(({ descriptor }) => hasCapability(descriptor, dependency)),
|
|
66
|
+
),
|
|
67
|
+
);
|
|
68
|
+
if (index < 0) return services;
|
|
69
|
+
const [service] = pending.splice(index, 1);
|
|
70
|
+
if (service === undefined) return services;
|
|
71
|
+
ordered.push(service);
|
|
72
|
+
for (const capability of service.descriptor.capabilities) provided.add(capability);
|
|
73
|
+
}
|
|
74
|
+
return ordered;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/*** Compare catalog capability values across descriptor union members. */
|
|
78
|
+
function hasCapability(descriptor: InfraAdapterDescriptor, capability: string): boolean {
|
|
79
|
+
return (descriptor.capabilities as readonly string[]).includes(capability);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/*** Invoke selected factories safely and require their instances to match the module descriptor. */
|
|
83
|
+
function instantiateModules(
|
|
84
|
+
modules: readonly InfraAdapterPackageModule[],
|
|
85
|
+
): InfraResult<readonly unknown[]> {
|
|
86
|
+
const instances: unknown[] = [];
|
|
87
|
+
const diagnostics: InfraDiagnostic[] = [];
|
|
88
|
+
for (const module of modules) {
|
|
89
|
+
try {
|
|
90
|
+
const instance = module.createInfraAdapter();
|
|
91
|
+
if (!isAdapterForDescriptor(instance, module.infraAdapterDescriptor)) {
|
|
92
|
+
diagnostics.push(
|
|
93
|
+
instanceDiagnostic(
|
|
94
|
+
module.infraAdapterDescriptor.id,
|
|
95
|
+
`Selected adapter factory for ${module.infraAdapterDescriptor.package} returned a mismatched lifecycle implementation.`,
|
|
96
|
+
),
|
|
97
|
+
);
|
|
98
|
+
} else instances.push(instance);
|
|
99
|
+
} catch {
|
|
100
|
+
diagnostics.push(
|
|
101
|
+
instanceDiagnostic(
|
|
102
|
+
module.infraAdapterDescriptor.id,
|
|
103
|
+
`Selected adapter factory for ${module.infraAdapterDescriptor.package} could not be created.`,
|
|
104
|
+
),
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return diagnostics.length > 0
|
|
109
|
+
? { ok: false, diagnostics }
|
|
110
|
+
: { ok: true, value: instances, diagnostics: [] };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/*** Select each configured adapter once, including multi-capability service providers. */
|
|
114
|
+
function getSelectedCatalogEntries(environment: InfraEnvironmentSpec) {
|
|
115
|
+
const ids = new Set([
|
|
116
|
+
environment.deployment.compute.provider,
|
|
117
|
+
environment.deployment.runtime.provider,
|
|
118
|
+
environment.database?.provider,
|
|
119
|
+
environment.objectStorage?.provider,
|
|
120
|
+
environment.auth?.provider,
|
|
121
|
+
environment.authz?.provider,
|
|
122
|
+
environment.secretStore?.provider,
|
|
123
|
+
]);
|
|
124
|
+
return Object.values(INFRA_ADAPTER_CATALOG).filter((entry) => ids.has(entry.id));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/*** Convert module-resolution errors into provider-safe diagnostics without importing alternatives. */
|
|
128
|
+
async function loadModuleAsync(
|
|
129
|
+
packageName: string,
|
|
130
|
+
resolver: InfraAdapterPackageResolver,
|
|
131
|
+
): Promise<InfraResult<InfraAdapterPackageModule>> {
|
|
132
|
+
try {
|
|
133
|
+
const loaded: unknown = await resolver.loadAsync(packageName);
|
|
134
|
+
return isInfraAdapterPackageModule(loaded)
|
|
135
|
+
? { ok: true, value: loaded, diagnostics: [] }
|
|
136
|
+
: adapterFailure(
|
|
137
|
+
'infra-adapter-module-invalid',
|
|
138
|
+
`Selected adapter package ${packageName} does not export its canonical descriptor and factory.`,
|
|
139
|
+
);
|
|
140
|
+
} catch {
|
|
141
|
+
return adapterFailure(
|
|
142
|
+
'infra-adapter-package-unavailable',
|
|
143
|
+
`Selected adapter package ${packageName} could not be loaded.`,
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/*** Validate the runtime shape of a dynamically loaded provider package. */
|
|
149
|
+
function isInfraAdapterPackageModule(value: unknown): value is InfraAdapterPackageModule {
|
|
150
|
+
return (
|
|
151
|
+
isRecord(value) &&
|
|
152
|
+
isInfraAdapterDescriptor(value.infraAdapterDescriptor) &&
|
|
153
|
+
typeof value.createInfraAdapter === 'function'
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/*** Validate one compute adapter instance without trusting a dynamic module cast. */
|
|
158
|
+
function isComputeAdapter(value: unknown): value is InfraComputeAdapter {
|
|
159
|
+
return hasAdapterMethods(value, 'compute', [
|
|
160
|
+
'validateAsync',
|
|
161
|
+
'inspectAsync',
|
|
162
|
+
'planAsync',
|
|
163
|
+
'ensureAsync',
|
|
164
|
+
'statusAsync',
|
|
165
|
+
'destroyAsync',
|
|
166
|
+
]);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/*** Validate one runtime adapter instance without trusting a dynamic module cast. */
|
|
170
|
+
function isRuntimeAdapter(value: unknown): value is InfraRuntimeAdapter {
|
|
171
|
+
return hasAdapterMethods(value, 'runtime', [
|
|
172
|
+
'validateAsync',
|
|
173
|
+
'planAsync',
|
|
174
|
+
'ensureAsync',
|
|
175
|
+
'statusAsync',
|
|
176
|
+
'suspendAsync',
|
|
177
|
+
'destroyAsync',
|
|
178
|
+
]);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/*** Validate one service adapter instance without trusting a dynamic module cast. */
|
|
182
|
+
function isServiceAdapter(value: unknown): value is InfraServiceAdapter {
|
|
183
|
+
return hasAdapterMethods(value, 'service', [
|
|
184
|
+
'validateAsync',
|
|
185
|
+
'planAsync',
|
|
186
|
+
'desiredWorkloadsAsync',
|
|
187
|
+
'reconcileAsync',
|
|
188
|
+
'statusAsync',
|
|
189
|
+
'destroyAsync',
|
|
190
|
+
]);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/*** Match a factory result to the exact descriptor selected from its module. */
|
|
194
|
+
function isAdapterForDescriptor(value: unknown, expected: InfraAdapterDescriptor): boolean {
|
|
195
|
+
const validShape =
|
|
196
|
+
expected.kind === 'compute'
|
|
197
|
+
? isComputeAdapter(value)
|
|
198
|
+
: expected.kind === 'runtime'
|
|
199
|
+
? isRuntimeAdapter(value)
|
|
200
|
+
: isServiceAdapter(value);
|
|
201
|
+
return (
|
|
202
|
+
validShape &&
|
|
203
|
+
isRecord(value) &&
|
|
204
|
+
isInfraAdapterDescriptor(value.descriptor) &&
|
|
205
|
+
value.descriptor.id === expected.id &&
|
|
206
|
+
value.descriptor.package === expected.package
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/*** Check a dynamic adapter descriptor kind and its required lifecycle methods. */
|
|
211
|
+
function hasAdapterMethods(
|
|
212
|
+
value: unknown,
|
|
213
|
+
kind: InfraAdapterDescriptor['kind'],
|
|
214
|
+
methods: readonly string[],
|
|
215
|
+
): boolean {
|
|
216
|
+
return (
|
|
217
|
+
isRecord(value) &&
|
|
218
|
+
isInfraAdapterDescriptor(value.descriptor) &&
|
|
219
|
+
value.descriptor.kind === kind &&
|
|
220
|
+
methods.every((method) => typeof Reflect.get(value, method) === 'function')
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/*** Ensure factories returned exactly one matching compute/runtime adapter and every service. */
|
|
225
|
+
function validateInstances(
|
|
226
|
+
compute: InfraComputeAdapter | undefined,
|
|
227
|
+
runtime: InfraRuntimeAdapter | undefined,
|
|
228
|
+
services: readonly InfraServiceAdapter[],
|
|
229
|
+
descriptors: readonly InfraAdapterDescriptor[],
|
|
230
|
+
): readonly InfraDiagnostic[] {
|
|
231
|
+
const expectedServices = descriptors.filter(({ kind }) => kind === 'service').length;
|
|
232
|
+
const diagnostics: InfraDiagnostic[] = [];
|
|
233
|
+
if (compute === undefined)
|
|
234
|
+
diagnostics.push(instanceDiagnostic('compute', 'Selected compute adapter factory is invalid.'));
|
|
235
|
+
if (runtime === undefined)
|
|
236
|
+
diagnostics.push(instanceDiagnostic('runtime', 'Selected runtime adapter factory is invalid.'));
|
|
237
|
+
if (services.length !== expectedServices)
|
|
238
|
+
diagnostics.push(
|
|
239
|
+
instanceDiagnostic('service', 'A selected service adapter factory is invalid.'),
|
|
240
|
+
);
|
|
241
|
+
return diagnostics;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/*** Create an adapter-factory diagnostic without exposing module exception details. */
|
|
245
|
+
function instanceDiagnostic(kind: string, message: string): InfraDiagnostic {
|
|
246
|
+
return { severity: 'error', code: `infra-${kind}-adapter-invalid`, message };
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/*** Create a failed adapter resolution result. */
|
|
250
|
+
function adapterFailure(code: string, message: string): InfraResult<never> {
|
|
251
|
+
return { ok: false, diagnostics: [{ severity: 'error', code, message }] };
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/*** Narrow dynamically loaded module and adapter values. */
|
|
255
|
+
function isRecord(value: unknown): value is Readonly<Record<string, unknown>> {
|
|
256
|
+
return typeof value === 'object' && value !== null;
|
|
257
|
+
}
|
package/src/features/environment-lifecycle/application/use-cases/statusInfraEnvironmentAsync.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { InfraDiagnostic, InfraResourceStatus } from '@ankhorage/contracts/infra';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
InfraOperationRequest,
|
|
5
|
+
InfraOrchestrationDependencies,
|
|
6
|
+
InfraStatusOperationResult,
|
|
7
|
+
} from '../../../../types/infraOrchestration.js';
|
|
8
|
+
import { appendInfraFailure } from '../../utils/appendInfraFailure.js';
|
|
9
|
+
import { prepareInfraOperationAsync } from './prepareInfraOperationAsync.js';
|
|
10
|
+
|
|
11
|
+
/*** Aggregate provider-neutral compute, runtime and service status. */
|
|
12
|
+
export async function statusInfraEnvironmentAsync(
|
|
13
|
+
request: InfraOperationRequest,
|
|
14
|
+
dependencies: InfraOrchestrationDependencies,
|
|
15
|
+
): Promise<InfraStatusOperationResult> {
|
|
16
|
+
const prepared = await prepareInfraOperationAsync(request, 'status', dependencies);
|
|
17
|
+
if (!prepared.ok) return prepared;
|
|
18
|
+
const diagnostics: InfraDiagnostic[] = [...prepared.diagnostics];
|
|
19
|
+
const resources: InfraResourceStatus[] = [];
|
|
20
|
+
const compute = await prepared.value.adapters.compute.statusAsync(prepared.value.context);
|
|
21
|
+
if (!compute.ok) return appendInfraFailure(diagnostics, compute);
|
|
22
|
+
resources.push(...compute.value);
|
|
23
|
+
diagnostics.push(...compute.diagnostics);
|
|
24
|
+
if (prepared.value.runtimeDesired.targets.length === 0) {
|
|
25
|
+
resources.push({
|
|
26
|
+
owner: {
|
|
27
|
+
projectId: request.projectId,
|
|
28
|
+
environment: prepared.value.environment.id,
|
|
29
|
+
adapter: prepared.value.adapters.runtime.descriptor.id,
|
|
30
|
+
resourceId: 'runtime',
|
|
31
|
+
},
|
|
32
|
+
state: 'absent',
|
|
33
|
+
detail: 'Compute has not exposed a portable runtime target.',
|
|
34
|
+
});
|
|
35
|
+
} else {
|
|
36
|
+
const runtime = await prepared.value.adapters.runtime.statusAsync(
|
|
37
|
+
prepared.value.context,
|
|
38
|
+
prepared.value.runtimeDesired,
|
|
39
|
+
);
|
|
40
|
+
if (!runtime.ok) return appendInfraFailure(diagnostics, runtime);
|
|
41
|
+
resources.push(...runtime.value);
|
|
42
|
+
diagnostics.push(...runtime.diagnostics);
|
|
43
|
+
}
|
|
44
|
+
for (const service of prepared.value.adapters.services) {
|
|
45
|
+
const status = await service.statusAsync(prepared.value.context);
|
|
46
|
+
if (!status.ok) return appendInfraFailure(diagnostics, status);
|
|
47
|
+
resources.push(...status.value);
|
|
48
|
+
diagnostics.push(...status.diagnostics);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
ok: true,
|
|
52
|
+
value: {
|
|
53
|
+
projectId: request.projectId,
|
|
54
|
+
environment: prepared.value.environment.id,
|
|
55
|
+
state: aggregateInfraStatus(resources),
|
|
56
|
+
resources,
|
|
57
|
+
},
|
|
58
|
+
diagnostics,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/*** Select the most actionable canonical status, treating an empty environment as absent. */
|
|
63
|
+
function aggregateInfraStatus(
|
|
64
|
+
resources: readonly InfraResourceStatus[],
|
|
65
|
+
): InfraResourceStatus['state'] {
|
|
66
|
+
if (resources.length === 0) return 'absent';
|
|
67
|
+
const severity: readonly InfraResourceStatus['state'][] = [
|
|
68
|
+
'failed',
|
|
69
|
+
'degraded',
|
|
70
|
+
'pending',
|
|
71
|
+
'unknown',
|
|
72
|
+
'stopped',
|
|
73
|
+
'retained',
|
|
74
|
+
'absent',
|
|
75
|
+
'ready',
|
|
76
|
+
];
|
|
77
|
+
return (
|
|
78
|
+
severity.find((state) => resources.some((resource) => resource.state === state)) ?? 'unknown'
|
|
79
|
+
);
|
|
80
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InfraDiagnostic,
|
|
3
|
+
InfraExecutionContext,
|
|
4
|
+
InfraOutput,
|
|
5
|
+
InfraOwnedResource,
|
|
6
|
+
InfraResult,
|
|
7
|
+
InfraServiceAdapter,
|
|
8
|
+
} from '@ankhorage/contracts/infra';
|
|
9
|
+
|
|
10
|
+
import type {
|
|
11
|
+
InfraOrchestrationDependencies,
|
|
12
|
+
InfraUpOperationResult,
|
|
13
|
+
InfraUpRequest,
|
|
14
|
+
} from '../../../../types/infraOrchestration.js';
|
|
15
|
+
import { resolveInfraEnvironment } from '../../domain/resolveInfraEnvironment.js';
|
|
16
|
+
import { appendInfraFailure } from '../../utils/appendInfraFailure.js';
|
|
17
|
+
import { createInfraExecutionContext } from '../../utils/createInfraExecutionContext.js';
|
|
18
|
+
import { createInfraLedger } from '../../utils/createInfraLedger.js';
|
|
19
|
+
import { mergeInfraOutputs } from '../../utils/mergeInfraOutputs.js';
|
|
20
|
+
import { collectInfraWorkloadsAsync } from './collectInfraWorkloadsAsync.js';
|
|
21
|
+
import { resolveInfraAdaptersAsync } from './resolveInfraAdaptersAsync.js';
|
|
22
|
+
import { validateInfraAdaptersAsync } from './validateInfraAdaptersAsync.js';
|
|
23
|
+
|
|
24
|
+
/*** Validate and reconcile compute, contributed workloads, runtime and services in dependency order. */
|
|
25
|
+
export async function upInfraEnvironmentAsync(
|
|
26
|
+
request: InfraUpRequest,
|
|
27
|
+
dependencies: InfraOrchestrationDependencies,
|
|
28
|
+
): Promise<InfraUpOperationResult> {
|
|
29
|
+
const environment = resolveInfraEnvironment({
|
|
30
|
+
manifest: request.manifest,
|
|
31
|
+
environment: request.environment,
|
|
32
|
+
operation: 'up',
|
|
33
|
+
});
|
|
34
|
+
if (!environment.ok) return environment;
|
|
35
|
+
const diagnostics: InfraDiagnostic[] = [...environment.diagnostics];
|
|
36
|
+
const adapters = await resolveInfraAdaptersAsync(
|
|
37
|
+
environment.value.desired,
|
|
38
|
+
dependencies.adapterResolver,
|
|
39
|
+
);
|
|
40
|
+
if (!adapters.ok) return appendInfraFailure(diagnostics, adapters);
|
|
41
|
+
diagnostics.push(...adapters.diagnostics);
|
|
42
|
+
const context = createInfraExecutionContext(request, environment.value, dependencies);
|
|
43
|
+
const validation = await validateInfraAdaptersAsync(context, adapters.value);
|
|
44
|
+
if (!validation.ok) return appendInfraFailure(diagnostics, validation);
|
|
45
|
+
diagnostics.push(...validation.diagnostics);
|
|
46
|
+
const workloads = await collectInfraWorkloadsAsync(context, adapters.value.services);
|
|
47
|
+
if (!workloads.ok) return appendInfraFailure(diagnostics, workloads);
|
|
48
|
+
diagnostics.push(...workloads.diagnostics);
|
|
49
|
+
const compute = await adapters.value.compute.ensureAsync(
|
|
50
|
+
context,
|
|
51
|
+
environment.value.desired.deployment.compute,
|
|
52
|
+
);
|
|
53
|
+
if (!compute.ok) return appendInfraFailure(diagnostics, compute);
|
|
54
|
+
diagnostics.push(...compute.diagnostics);
|
|
55
|
+
const runtimeDesired = {
|
|
56
|
+
selection: environment.value.desired.deployment.runtime,
|
|
57
|
+
targets: compute.value.targets,
|
|
58
|
+
workloads: [...(environment.value.desired.workloads ?? []), ...workloads.value],
|
|
59
|
+
availableOutputs: mergeInfraOutputs(request.previous?.outputs ?? [], compute.value.outputs),
|
|
60
|
+
};
|
|
61
|
+
const runtimeValidation = await adapters.value.runtime.validateAsync(context, runtimeDesired);
|
|
62
|
+
if (!runtimeValidation.ok) return appendInfraFailure(diagnostics, runtimeValidation);
|
|
63
|
+
diagnostics.push(...runtimeValidation.diagnostics);
|
|
64
|
+
const runtime = await adapters.value.runtime.ensureAsync(context, runtimeDesired);
|
|
65
|
+
if (!runtime.ok) return appendInfraFailure(diagnostics, runtime);
|
|
66
|
+
diagnostics.push(...runtime.diagnostics);
|
|
67
|
+
const services = await reconcileServicesAsync(context, adapters.value.services, [
|
|
68
|
+
...compute.value.outputs,
|
|
69
|
+
...runtime.value.outputs,
|
|
70
|
+
]);
|
|
71
|
+
if (!services.ok) return appendInfraFailure(diagnostics, services);
|
|
72
|
+
diagnostics.push(...services.diagnostics);
|
|
73
|
+
const resources = [
|
|
74
|
+
...compute.value.resources,
|
|
75
|
+
...runtime.value.resources,
|
|
76
|
+
...services.value.resources,
|
|
77
|
+
];
|
|
78
|
+
const outputs = mergeInfraOutputs(
|
|
79
|
+
compute.value.outputs,
|
|
80
|
+
runtime.value.outputs,
|
|
81
|
+
services.value.outputs,
|
|
82
|
+
);
|
|
83
|
+
const ledger = createInfraLedger({
|
|
84
|
+
projectId: request.projectId,
|
|
85
|
+
environment: environment.value.id,
|
|
86
|
+
targets: compute.value.targets,
|
|
87
|
+
resources,
|
|
88
|
+
outputs,
|
|
89
|
+
previous: request.previous,
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
ok: true,
|
|
93
|
+
value: {
|
|
94
|
+
environment: environment.value.id,
|
|
95
|
+
targets: compute.value.targets,
|
|
96
|
+
resources,
|
|
97
|
+
outputs,
|
|
98
|
+
ledger,
|
|
99
|
+
},
|
|
100
|
+
diagnostics,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/*** Reconcile service-owned external state after its runtime workloads expose outputs. */
|
|
105
|
+
async function reconcileServicesAsync(
|
|
106
|
+
context: InfraExecutionContext,
|
|
107
|
+
services: readonly InfraServiceAdapter[],
|
|
108
|
+
runtimeOutputs: readonly InfraOutput[],
|
|
109
|
+
): Promise<
|
|
110
|
+
InfraResult<{
|
|
111
|
+
readonly resources: readonly InfraOwnedResource[];
|
|
112
|
+
readonly outputs: readonly InfraOutput[];
|
|
113
|
+
}>
|
|
114
|
+
> {
|
|
115
|
+
const resources: InfraOwnedResource[] = [];
|
|
116
|
+
const outputs: InfraOutput[] = [];
|
|
117
|
+
const diagnostics: InfraDiagnostic[] = [];
|
|
118
|
+
for (const service of services) {
|
|
119
|
+
const result = await service.reconcileAsync(context, runtimeOutputs);
|
|
120
|
+
if (!result.ok) return appendInfraFailure(diagnostics, result);
|
|
121
|
+
resources.push(...result.value.resources);
|
|
122
|
+
outputs.push(...result.value.outputs);
|
|
123
|
+
diagnostics.push(...result.diagnostics);
|
|
124
|
+
}
|
|
125
|
+
return { ok: true, value: { resources, outputs }, diagnostics };
|
|
126
|
+
}
|
package/src/features/environment-lifecycle/application/use-cases/validateInfraAdaptersAsync.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InfraDiagnostic,
|
|
3
|
+
InfraExecutionContext,
|
|
4
|
+
InfraResult,
|
|
5
|
+
} from '@ankhorage/contracts/infra';
|
|
6
|
+
|
|
7
|
+
import type { ResolvedInfraAdapters } from '../../../../types/infraOrchestration.js';
|
|
8
|
+
import { appendInfraFailure } from '../../utils/appendInfraFailure.js';
|
|
9
|
+
|
|
10
|
+
/*** Validate compute and service configuration before any mutating adapter call. */
|
|
11
|
+
export async function validateInfraAdaptersAsync(
|
|
12
|
+
context: InfraExecutionContext,
|
|
13
|
+
adapters: ResolvedInfraAdapters,
|
|
14
|
+
): Promise<InfraResult<null>> {
|
|
15
|
+
const diagnostics: InfraDiagnostic[] = [];
|
|
16
|
+
const compute = await adapters.compute.validateAsync(context, context.desired.deployment.compute);
|
|
17
|
+
if (!compute.ok) return compute;
|
|
18
|
+
diagnostics.push(...compute.diagnostics);
|
|
19
|
+
for (const service of adapters.services) {
|
|
20
|
+
const validation = await service.validateAsync(context);
|
|
21
|
+
if (!validation.ok) return appendInfraFailure(diagnostics, validation);
|
|
22
|
+
diagnostics.push(...validation.diagnostics);
|
|
23
|
+
}
|
|
24
|
+
return { ok: true, value: null, diagnostics };
|
|
25
|
+
}
|