@ankhorage/infra 4.1.12 → 5.1.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 +16 -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/composition/createProjectInfraLifecycle.d.ts +4 -0
- package/dist/features/environment-lifecycle/composition/createProjectInfraLifecycle.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/composition/createProjectInfraLifecycle.js +123 -0
- package/dist/features/environment-lifecycle/composition/createProjectInfraLifecycle.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 +8 -5
- package/dist/project/index.d.ts.map +1 -1
- package/dist/project/index.js +7 -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/types/infraProject.d.ts +43 -0
- 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/composition/createProjectInfraLifecycle.ts +157 -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 +10 -188
- package/src/project/index.ts +15 -22
- package/src/project.test.ts +39 -189
- package/src/projectContractsParser.test.ts +2 -2
- package/src/projectInfrastructure.test.ts +121 -167
- package/src/projectLifecycle.test.ts +136 -0
- 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 +58 -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 +0 -14
- 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
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
|
+
}
|
package/src/features/environment-lifecycle/application/use-cases/validateInfraEnvironmentAsync.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InfraOperationRequest,
|
|
3
|
+
InfraOrchestrationDependencies,
|
|
4
|
+
InfraValidateOperationResult,
|
|
5
|
+
} from '../../../../types/infraOrchestration.js';
|
|
6
|
+
import { prepareInfraOperationAsync } from './prepareInfraOperationAsync.js';
|
|
7
|
+
|
|
8
|
+
/*** Validate one environment and every selected adapter without mutating infrastructure. */
|
|
9
|
+
export async function validateInfraEnvironmentAsync(
|
|
10
|
+
request: InfraOperationRequest,
|
|
11
|
+
dependencies: InfraOrchestrationDependencies,
|
|
12
|
+
): Promise<InfraValidateOperationResult> {
|
|
13
|
+
const prepared = await prepareInfraOperationAsync(request, 'validate', dependencies);
|
|
14
|
+
return prepared.ok
|
|
15
|
+
? {
|
|
16
|
+
ok: true,
|
|
17
|
+
value: { environment: prepared.value.environment.id },
|
|
18
|
+
diagnostics: prepared.diagnostics,
|
|
19
|
+
}
|
|
20
|
+
: prepared;
|
|
21
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { InfraCommandServices } from '../../../types/infraCli.js';
|
|
2
|
+
import { createEnvironmentInfraCredentialPort } from '../adapters/outbound/createEnvironmentInfraCredentialPort.js';
|
|
3
|
+
import { createEnvironmentInfraSecretPort } from '../adapters/outbound/createEnvironmentInfraSecretPort.js';
|
|
4
|
+
import { createNodeInfraAdapterPackageResolver } from '../adapters/outbound/createNodeInfraAdapterPackageResolver.js';
|
|
5
|
+
import { readStoredInfraStateAsync } from '../adapters/outbound/readStoredInfraStateAsync.js';
|
|
6
|
+
import { removeStoredInfraStateAsync } from '../adapters/outbound/removeStoredInfraStateAsync.js';
|
|
7
|
+
import { resolveInfraProjectAsync } from '../adapters/outbound/resolveInfraProjectAsync.js';
|
|
8
|
+
import { writeInfraGeneratedArtifactsAsync } from '../adapters/outbound/writeInfraGeneratedArtifactsAsync.js';
|
|
9
|
+
import { writeStoredInfraStateAsync } from '../adapters/outbound/writeStoredInfraStateAsync.js';
|
|
10
|
+
import { destroyInfraEnvironmentAsync } from '../application/use-cases/destroyInfraEnvironmentAsync.js';
|
|
11
|
+
import { downInfraEnvironmentAsync } from '../application/use-cases/downInfraEnvironmentAsync.js';
|
|
12
|
+
import { generateInfraEnvironmentAsync } from '../application/use-cases/generateInfraEnvironmentAsync.js';
|
|
13
|
+
import { getInfraEnvironmentOutputs } from '../application/use-cases/getInfraEnvironmentOutputs.js';
|
|
14
|
+
import { planInfraEnvironmentAsync } from '../application/use-cases/planInfraEnvironmentAsync.js';
|
|
15
|
+
import { statusInfraEnvironmentAsync } from '../application/use-cases/statusInfraEnvironmentAsync.js';
|
|
16
|
+
import { upInfraEnvironmentAsync } from '../application/use-cases/upInfraEnvironmentAsync.js';
|
|
17
|
+
import { validateInfraEnvironmentAsync } from '../application/use-cases/validateInfraEnvironmentAsync.js';
|
|
18
|
+
|
|
19
|
+
/*** Compose command use cases with filesystem, environment-value and package-resolver adapters. */
|
|
20
|
+
export function createInfraCommandServices(
|
|
21
|
+
overrides: Partial<InfraCommandServices> = {},
|
|
22
|
+
): InfraCommandServices {
|
|
23
|
+
return {
|
|
24
|
+
resolveProject: overrides.resolveProject ?? resolveInfraProjectAsync,
|
|
25
|
+
readState: overrides.readState ?? readStoredInfraStateAsync,
|
|
26
|
+
writeState: overrides.writeState ?? writeStoredInfraStateAsync,
|
|
27
|
+
removeState: overrides.removeState ?? removeStoredInfraStateAsync,
|
|
28
|
+
writeArtifacts: overrides.writeArtifacts ?? writeInfraGeneratedArtifactsAsync,
|
|
29
|
+
operations: overrides.operations ?? {
|
|
30
|
+
validate: validateInfraEnvironmentAsync,
|
|
31
|
+
plan: planInfraEnvironmentAsync,
|
|
32
|
+
generate: generateInfraEnvironmentAsync,
|
|
33
|
+
up: upInfraEnvironmentAsync,
|
|
34
|
+
status: statusInfraEnvironmentAsync,
|
|
35
|
+
outputs: getInfraEnvironmentOutputs,
|
|
36
|
+
down: downInfraEnvironmentAsync,
|
|
37
|
+
destroy: destroyInfraEnvironmentAsync,
|
|
38
|
+
},
|
|
39
|
+
createDependencies:
|
|
40
|
+
overrides.createDependencies ??
|
|
41
|
+
((context) => ({
|
|
42
|
+
adapterResolver: createNodeInfraAdapterPackageResolver(),
|
|
43
|
+
credentials: createEnvironmentInfraCredentialPort(context.env),
|
|
44
|
+
secrets: createEnvironmentInfraSecretPort(context.env),
|
|
45
|
+
})),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type { InfraEnvironmentSpec, InfraManifest } from '@ankhorage/contracts/infra';
|
|
2
|
+
|
|
3
|
+
import { INFRA_PACKAGE_VERSION } from '../../../constants.js';
|
|
4
|
+
import type { InfraOperationRequest, InfraStoredState } from '../../../types/infraOrchestration.js';
|
|
5
|
+
import type {
|
|
6
|
+
CreateProjectInfraLifecycleOptions,
|
|
7
|
+
ProjectInfraLifecycle,
|
|
8
|
+
ProjectInfraOperationRequest,
|
|
9
|
+
} from '../../../types/infraProject.js';
|
|
10
|
+
import { createInfraCommandServices } from './createInfraCommandServices.js';
|
|
11
|
+
|
|
12
|
+
/*** Create the typed project-facing Infra lifecycle backed by canonical use cases and ownership state. */
|
|
13
|
+
export function createProjectInfraLifecycle(
|
|
14
|
+
options: CreateProjectInfraLifecycleOptions = {},
|
|
15
|
+
): ProjectInfraLifecycle {
|
|
16
|
+
const services = createInfraCommandServices(options.services);
|
|
17
|
+
return {
|
|
18
|
+
async validateAsync(request) {
|
|
19
|
+
const prepared = await prepareProjectOperationAsync(request, services);
|
|
20
|
+
return services.operations.validate(prepared.operation, prepared.dependencies);
|
|
21
|
+
},
|
|
22
|
+
async planAsync(request) {
|
|
23
|
+
const prepared = await prepareProjectOperationAsync(request, services);
|
|
24
|
+
return services.operations.plan(prepared.operation, prepared.dependencies);
|
|
25
|
+
},
|
|
26
|
+
async generateAsync(request) {
|
|
27
|
+
const prepared = await prepareProjectOperationAsync(request, services);
|
|
28
|
+
const result = await services.operations.generate(prepared.operation, prepared.dependencies);
|
|
29
|
+
if (!result.ok) return result;
|
|
30
|
+
await services.writeArtifacts(
|
|
31
|
+
request.projectPath,
|
|
32
|
+
result.value.artifacts,
|
|
33
|
+
prepared.state?.ledger,
|
|
34
|
+
);
|
|
35
|
+
await services.writeState(request.projectPath, {
|
|
36
|
+
schemaVersion: 1,
|
|
37
|
+
desired: prepared.desired,
|
|
38
|
+
ledger: result.value.ledger,
|
|
39
|
+
});
|
|
40
|
+
return result;
|
|
41
|
+
},
|
|
42
|
+
async upAsync(request) {
|
|
43
|
+
const prepared = await prepareProjectOperationAsync(request, services);
|
|
44
|
+
const result = await services.operations.up(prepared.operation, prepared.dependencies);
|
|
45
|
+
if (!result.ok) return result;
|
|
46
|
+
await services.writeState(request.projectPath, {
|
|
47
|
+
schemaVersion: 1,
|
|
48
|
+
desired: prepared.desired,
|
|
49
|
+
ledger: result.value.ledger,
|
|
50
|
+
});
|
|
51
|
+
return result;
|
|
52
|
+
},
|
|
53
|
+
async statusAsync(request) {
|
|
54
|
+
const prepared = await prepareProjectOperationAsync(request, services);
|
|
55
|
+
return services.operations.status(prepared.operation, prepared.dependencies);
|
|
56
|
+
},
|
|
57
|
+
async outputsAsync(request) {
|
|
58
|
+
const prepared = await prepareProjectOperationAsync(request, services);
|
|
59
|
+
return services.operations.outputs(prepared.operation);
|
|
60
|
+
},
|
|
61
|
+
async downAsync(request) {
|
|
62
|
+
const prepared = await prepareProjectOperationAsync(request, services);
|
|
63
|
+
const result = await services.operations.down(prepared.operation, prepared.dependencies);
|
|
64
|
+
if (!result.ok) return result;
|
|
65
|
+
await services.writeState(request.projectPath, {
|
|
66
|
+
schemaVersion: 1,
|
|
67
|
+
desired: prepared.desired,
|
|
68
|
+
ledger: result.value.ledger,
|
|
69
|
+
});
|
|
70
|
+
return result;
|
|
71
|
+
},
|
|
72
|
+
async destroyAsync(request) {
|
|
73
|
+
const prepared = await prepareProjectOperationAsync(request, services, true);
|
|
74
|
+
const result = await services.operations.destroy(
|
|
75
|
+
{
|
|
76
|
+
...prepared.operation,
|
|
77
|
+
confirmation: request.confirmation,
|
|
78
|
+
persistence: request.persistence,
|
|
79
|
+
},
|
|
80
|
+
prepared.dependencies,
|
|
81
|
+
);
|
|
82
|
+
if (!result.ok) return result;
|
|
83
|
+
await services.writeArtifacts(request.projectPath, [], prepared.state?.ledger);
|
|
84
|
+
if (result.value.ledger === null)
|
|
85
|
+
await services.removeState(request.projectPath, request.environment);
|
|
86
|
+
else {
|
|
87
|
+
await services.writeState(request.projectPath, {
|
|
88
|
+
schemaVersion: 1,
|
|
89
|
+
desired: prepared.desired,
|
|
90
|
+
ledger: result.value.ledger,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
interface PreparedProjectOperation {
|
|
99
|
+
readonly operation: InfraOperationRequest;
|
|
100
|
+
readonly desired: InfraEnvironmentSpec;
|
|
101
|
+
readonly state: InfraStoredState | null;
|
|
102
|
+
readonly dependencies: ReturnType<
|
|
103
|
+
ReturnType<typeof createInfraCommandServices>['createDependencies']
|
|
104
|
+
>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/*** Resolve one explicit project/environment request with its prior ownership state and dependencies. */
|
|
108
|
+
async function prepareProjectOperationAsync(
|
|
109
|
+
request: ProjectInfraOperationRequest,
|
|
110
|
+
services: ReturnType<typeof createInfraCommandServices>,
|
|
111
|
+
useStoredDesired = false,
|
|
112
|
+
): Promise<PreparedProjectOperation> {
|
|
113
|
+
const state = await services.readState(request.projectPath, request.environment);
|
|
114
|
+
const currentDesired = readEnvironment(request.manifest, request.environment);
|
|
115
|
+
const desired = useStoredDesired && state !== null ? state.desired : currentDesired;
|
|
116
|
+
if (desired === undefined) {
|
|
117
|
+
throw new Error(`Infra environment "${request.environment}" is not configured.`);
|
|
118
|
+
}
|
|
119
|
+
const context = {
|
|
120
|
+
cwd: request.projectPath,
|
|
121
|
+
env: request.executionEnvironment ?? process.env,
|
|
122
|
+
version: INFRA_PACKAGE_VERSION,
|
|
123
|
+
writeStdout: () => undefined,
|
|
124
|
+
writeStderr: () => undefined,
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
state,
|
|
128
|
+
desired,
|
|
129
|
+
operation: {
|
|
130
|
+
projectId: request.projectId,
|
|
131
|
+
manifest: replaceEnvironment(request.manifest, request.environment, desired),
|
|
132
|
+
environment: request.environment,
|
|
133
|
+
...(state === null ? {} : { previous: state.ledger, previousDesired: state.desired }),
|
|
134
|
+
...(request.signal === undefined ? {} : { signal: request.signal }),
|
|
135
|
+
},
|
|
136
|
+
dependencies: services.createDependencies(context),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/*** Read one exact environment without inventing a fallback. */
|
|
141
|
+
function readEnvironment(
|
|
142
|
+
manifest: InfraManifest,
|
|
143
|
+
environment: ProjectInfraOperationRequest['environment'],
|
|
144
|
+
): InfraEnvironmentSpec | undefined {
|
|
145
|
+
if (environment === 'local') return manifest.environments.local;
|
|
146
|
+
if (environment === 'preview') return manifest.environments.preview;
|
|
147
|
+
return manifest.environments.production;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/*** Replace one selected environment while preserving all other manifest state. */
|
|
151
|
+
function replaceEnvironment(
|
|
152
|
+
manifest: InfraManifest,
|
|
153
|
+
environment: ProjectInfraOperationRequest['environment'],
|
|
154
|
+
desired: InfraEnvironmentSpec,
|
|
155
|
+
): InfraManifest {
|
|
156
|
+
return { ...manifest, environments: { ...manifest.environments, [environment]: desired } };
|
|
157
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InfraPlanAction,
|
|
3
|
+
InfraResourceIdentity,
|
|
4
|
+
InfraResult,
|
|
5
|
+
} from '@ankhorage/contracts/infra';
|
|
6
|
+
|
|
7
|
+
/*** Order plan actions dependency-first and reject duplicate owners or dependency cycles. */
|
|
8
|
+
export function orderInfraPlanActions(
|
|
9
|
+
actions: readonly InfraPlanAction[],
|
|
10
|
+
): InfraResult<readonly InfraPlanAction[]> {
|
|
11
|
+
const byOwner = new Map(actions.map((action) => [identityKey(action.owner), action]));
|
|
12
|
+
if (byOwner.size !== actions.length) return invalidPlan('duplicate resource actions');
|
|
13
|
+
const ordered: InfraPlanAction[] = [];
|
|
14
|
+
const complete = new Set<string>();
|
|
15
|
+
const active = new Set<string>();
|
|
16
|
+
for (const action of actions) {
|
|
17
|
+
const result = visitAction(action, byOwner, ordered, complete, active);
|
|
18
|
+
if (!result.ok) return result;
|
|
19
|
+
}
|
|
20
|
+
return { ok: true, value: ordered, diagnostics: [] };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/*** Visit one plan node and its in-plan dependencies exactly once. */
|
|
24
|
+
function visitAction(
|
|
25
|
+
action: InfraPlanAction,
|
|
26
|
+
byOwner: ReadonlyMap<string, InfraPlanAction>,
|
|
27
|
+
ordered: InfraPlanAction[],
|
|
28
|
+
complete: Set<string>,
|
|
29
|
+
active: Set<string>,
|
|
30
|
+
): InfraResult<null> {
|
|
31
|
+
const key = identityKey(action.owner);
|
|
32
|
+
if (complete.has(key)) return { ok: true, value: null, diagnostics: [] };
|
|
33
|
+
if (active.has(key)) return invalidPlan('a dependency cycle');
|
|
34
|
+
active.add(key);
|
|
35
|
+
for (const dependency of action.dependsOn) {
|
|
36
|
+
const dependencyAction = byOwner.get(identityKey(dependency));
|
|
37
|
+
if (dependencyAction === undefined) continue;
|
|
38
|
+
const result = visitAction(dependencyAction, byOwner, ordered, complete, active);
|
|
39
|
+
if (!result.ok) return result;
|
|
40
|
+
}
|
|
41
|
+
active.delete(key);
|
|
42
|
+
complete.add(key);
|
|
43
|
+
ordered.push(action);
|
|
44
|
+
return { ok: true, value: null, diagnostics: [] };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/*** Create a collision-safe key for one provider-owned resource identity. */
|
|
48
|
+
function identityKey(identity: InfraResourceIdentity): string {
|
|
49
|
+
return `${identity.projectId}\0${identity.environment}\0${identity.adapter}\0${identity.resourceId}`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/*** Reject an invalid aggregated plan without exposing provider internals. */
|
|
53
|
+
function invalidPlan(detail: string): InfraResult<never> {
|
|
54
|
+
return {
|
|
55
|
+
ok: false,
|
|
56
|
+
diagnostics: [
|
|
57
|
+
{
|
|
58
|
+
severity: 'error',
|
|
59
|
+
code: 'infra-plan-invalid',
|
|
60
|
+
message: `The aggregated infrastructure plan contains ${detail}.`,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { APP_ENVIRONMENT_IDS, type AppEnvironmentId } from '@ankhorage/contracts/environments';
|
|
2
|
+
import type { InfraResult } from '@ankhorage/contracts/infra';
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
InfraEnvironmentResolutionRequest,
|
|
6
|
+
ResolvedInfraEnvironment,
|
|
7
|
+
} from '../../../types/infraOrchestration.js';
|
|
8
|
+
|
|
9
|
+
/*** Resolve one explicitly configured environment while keeping local as the only safe default. */
|
|
10
|
+
export function resolveInfraEnvironment(
|
|
11
|
+
request: InfraEnvironmentResolutionRequest,
|
|
12
|
+
): InfraResult<ResolvedInfraEnvironment> {
|
|
13
|
+
if (request.operation === 'destroy' && request.environment === undefined) {
|
|
14
|
+
return failure(
|
|
15
|
+
'infra-environment-required',
|
|
16
|
+
'Infra destroy requires an explicit --environment selection.',
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
const environment = request.environment ?? 'local';
|
|
20
|
+
if (!isAppEnvironmentId(environment)) {
|
|
21
|
+
return failure(
|
|
22
|
+
'infra-environment-invalid',
|
|
23
|
+
`Unknown Infra environment "${environment}". Expected local, preview, or production.`,
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
const desired = getEnvironment(request.manifest, environment);
|
|
27
|
+
return desired === undefined
|
|
28
|
+
? failure(
|
|
29
|
+
'infra-environment-unconfigured',
|
|
30
|
+
`Infra environment "${environment}" is not configured.`,
|
|
31
|
+
)
|
|
32
|
+
: {
|
|
33
|
+
ok: true,
|
|
34
|
+
value: { id: environment, desired, manifest: request.manifest },
|
|
35
|
+
diagnostics: [],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/*** Read a closed environment key without an open object-injection boundary. */
|
|
40
|
+
function getEnvironment(
|
|
41
|
+
manifest: InfraEnvironmentResolutionRequest['manifest'],
|
|
42
|
+
environment: AppEnvironmentId,
|
|
43
|
+
) {
|
|
44
|
+
switch (environment) {
|
|
45
|
+
case 'local':
|
|
46
|
+
return manifest.environments.local;
|
|
47
|
+
case 'preview':
|
|
48
|
+
return manifest.environments.preview;
|
|
49
|
+
case 'production':
|
|
50
|
+
return manifest.environments.production;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/*** Narrow a CLI environment string through the canonical Contracts vocabulary. */
|
|
55
|
+
function isAppEnvironmentId(value: string): value is AppEnvironmentId {
|
|
56
|
+
return APP_ENVIRONMENT_IDS.some((environment) => environment === value);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/*** Create a stable environment-resolution diagnostic. */
|
|
60
|
+
function failure(code: string, message: string): InfraResult<never> {
|
|
61
|
+
return { ok: false, diagnostics: [{ severity: 'error', code, message }] };
|
|
62
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { InfraDiagnostic, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
+
|
|
3
|
+
/*** Preserve earlier safe diagnostics when a later lifecycle stage fails. */
|
|
4
|
+
export function appendInfraFailure(
|
|
5
|
+
previous: readonly InfraDiagnostic[],
|
|
6
|
+
failure: { readonly ok: false; readonly diagnostics: readonly InfraDiagnostic[] },
|
|
7
|
+
): InfraResult<never> {
|
|
8
|
+
return { ok: false, diagnostics: [...previous, ...failure.diagnostics] };
|
|
9
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { InfraExecutionContext } from '@ankhorage/contracts/infra';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
InfraOperationRequest,
|
|
5
|
+
InfraOrchestrationDependencies,
|
|
6
|
+
ResolvedInfraEnvironment,
|
|
7
|
+
} from '../../../types/infraOrchestration.js';
|
|
8
|
+
|
|
9
|
+
/*** Create one execution context without copying resolved secret values into serializable state. */
|
|
10
|
+
export function createInfraExecutionContext(
|
|
11
|
+
request: InfraOperationRequest,
|
|
12
|
+
environment: ResolvedInfraEnvironment,
|
|
13
|
+
dependencies: InfraOrchestrationDependencies,
|
|
14
|
+
): InfraExecutionContext {
|
|
15
|
+
return {
|
|
16
|
+
projectId: request.projectId,
|
|
17
|
+
environment: environment.id,
|
|
18
|
+
desired: environment.desired,
|
|
19
|
+
...(request.previous === undefined ? {} : { previous: request.previous }),
|
|
20
|
+
...(request.signal === undefined ? {} : { signal: request.signal }),
|
|
21
|
+
credentials: dependencies.credentials,
|
|
22
|
+
secrets: dependencies.secrets,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
+
|
|
3
|
+
/*** Create one sanitized provider-neutral Infra failure. */
|
|
4
|
+
export function createInfraFailure(code: string, message: string): InfraResult<never> {
|
|
5
|
+
return { ok: false, diagnostics: [{ severity: 'error', code, message }] };
|
|
6
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InfraComputeTarget,
|
|
3
|
+
InfraGeneratedArtifact,
|
|
4
|
+
InfraLedger,
|
|
5
|
+
InfraOutput,
|
|
6
|
+
InfraOwnedResource,
|
|
7
|
+
} from '@ankhorage/contracts/infra';
|
|
8
|
+
|
|
9
|
+
/*** Create deterministic serializable lifecycle state without resolved credential or secret values. */
|
|
10
|
+
export function createInfraLedger(input: {
|
|
11
|
+
readonly projectId: string;
|
|
12
|
+
readonly environment: InfraLedger['environment'];
|
|
13
|
+
readonly targets: readonly InfraComputeTarget[];
|
|
14
|
+
readonly resources: readonly InfraOwnedResource[];
|
|
15
|
+
readonly outputs: readonly InfraOutput[];
|
|
16
|
+
readonly artifacts?: readonly InfraGeneratedArtifact[];
|
|
17
|
+
readonly previous?: InfraLedger;
|
|
18
|
+
}): InfraLedger {
|
|
19
|
+
const artifacts =
|
|
20
|
+
input.artifacts?.map(({ owner, path }) => ({ owner, path })) ?? input.previous?.artifacts ?? [];
|
|
21
|
+
return {
|
|
22
|
+
schemaVersion: 1,
|
|
23
|
+
projectId: input.projectId,
|
|
24
|
+
environment: input.environment,
|
|
25
|
+
targets: input.targets,
|
|
26
|
+
resources: input.resources,
|
|
27
|
+
outputs: input.outputs,
|
|
28
|
+
artifacts,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { InfraResourceIdentity } from '@ankhorage/contracts/infra';
|
|
2
|
+
|
|
3
|
+
/*** Create a stable collision-safe key for an Infra-owned resource. */
|
|
4
|
+
export function infraIdentityKey(identity: InfraResourceIdentity): string {
|
|
5
|
+
return `${identity.projectId}\0${identity.environment}\0${identity.adapter}\0${identity.resourceId}`;
|
|
6
|
+
}
|