@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
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InfraAdapterDescriptor,
|
|
3
|
+
InfraComputeAdapter,
|
|
4
|
+
InfraEnvironmentSpec,
|
|
5
|
+
InfraResult,
|
|
6
|
+
InfraRuntimeAdapter,
|
|
7
|
+
InfraServiceAdapter,
|
|
8
|
+
} from '@ankhorage/contracts/infra';
|
|
9
|
+
import { INFRA_ADAPTER_CATALOG } from '@ankhorage/contracts/infra';
|
|
10
|
+
import { describe, expect, it } from 'bun:test';
|
|
11
|
+
|
|
12
|
+
import type { InfraAdapterPackageResolver } from './features/environment-lifecycle/application/ports/outbound/infraAdapterPackage';
|
|
13
|
+
import { resolveInfraAdaptersAsync } from './features/environment-lifecycle/application/use-cases/resolveInfraAdaptersAsync';
|
|
14
|
+
import { resolveInfraEnvironment } from './features/environment-lifecycle/domain/resolveInfraEnvironment';
|
|
15
|
+
|
|
16
|
+
const local = {
|
|
17
|
+
deployment: { compute: { provider: 'local' }, runtime: { provider: 'docker-compose' } },
|
|
18
|
+
database: { provider: 'supabase' },
|
|
19
|
+
auth: { provider: 'supabase' },
|
|
20
|
+
authz: { provider: 'cerbos', kind: 'ABAC' },
|
|
21
|
+
} as const satisfies InfraEnvironmentSpec;
|
|
22
|
+
const manifest = { environments: { local, preview: local }, modules: [] } as const;
|
|
23
|
+
|
|
24
|
+
describe('environment safety', () => {
|
|
25
|
+
it('defaults only to local and requires explicit destroy selection', () => {
|
|
26
|
+
expect(resolveInfraEnvironment({ manifest, operation: 'up' })).toMatchObject({
|
|
27
|
+
ok: true,
|
|
28
|
+
value: { id: 'local' },
|
|
29
|
+
});
|
|
30
|
+
expect(resolveInfraEnvironment({ manifest, operation: 'destroy' })).toMatchObject({
|
|
31
|
+
ok: false,
|
|
32
|
+
diagnostics: [{ code: 'infra-environment-required' }],
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('accepts configured explicit environments and rejects unknown or absent ones', () => {
|
|
37
|
+
expect(
|
|
38
|
+
resolveInfraEnvironment({ manifest, operation: 'up', environment: 'preview' }),
|
|
39
|
+
).toMatchObject({ ok: true, value: { id: 'preview' } });
|
|
40
|
+
expect(
|
|
41
|
+
resolveInfraEnvironment({ manifest, operation: 'status', environment: 'production' }),
|
|
42
|
+
).toMatchObject({ ok: false, diagnostics: [{ code: 'infra-environment-unconfigured' }] });
|
|
43
|
+
expect(
|
|
44
|
+
resolveInfraEnvironment({ manifest, operation: 'status', environment: 'staging' }),
|
|
45
|
+
).toMatchObject({ ok: false, diagnostics: [{ code: 'infra-environment-invalid' }] });
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('selected adapter resolution', () => {
|
|
50
|
+
it('loads only selected packages and deduplicates the Supabase platform', async () => {
|
|
51
|
+
const requested: string[] = [];
|
|
52
|
+
const resolver = createResolver(requested);
|
|
53
|
+
const result = await resolveInfraAdaptersAsync(local, resolver);
|
|
54
|
+
|
|
55
|
+
expect(result.ok).toBe(true);
|
|
56
|
+
expect(requested).toEqual([
|
|
57
|
+
'@ankhorage/local',
|
|
58
|
+
'@ankhorage/docker-compose',
|
|
59
|
+
'@ankhorage/supabase',
|
|
60
|
+
'@ankhorage/cerbos',
|
|
61
|
+
]);
|
|
62
|
+
if (!result.ok) throw new Error('Expected adapters.');
|
|
63
|
+
expect(result.value.services.map(({ descriptor }) => descriptor.id)).toEqual([
|
|
64
|
+
'supabase',
|
|
65
|
+
'cerbos',
|
|
66
|
+
]);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('fails closed for unavailable and malformed selected packages', async () => {
|
|
70
|
+
const missing = await resolveInfraAdaptersAsync(local, {
|
|
71
|
+
loadAsync: () => Promise.reject(new Error('missing')),
|
|
72
|
+
});
|
|
73
|
+
expect(missing.ok).toBe(false);
|
|
74
|
+
expect(
|
|
75
|
+
missing.diagnostics.every(({ code }) => code === 'infra-adapter-package-unavailable'),
|
|
76
|
+
).toBe(true);
|
|
77
|
+
|
|
78
|
+
const malformed = await resolveInfraAdaptersAsync(local, {
|
|
79
|
+
loadAsync: () => Promise.resolve({ createInfraAdapter: () => ({}) }),
|
|
80
|
+
});
|
|
81
|
+
expect(malformed.ok).toBe(false);
|
|
82
|
+
expect(malformed.diagnostics.every(({ code }) => code === 'infra-adapter-module-invalid')).toBe(
|
|
83
|
+
true,
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('rejects a factory that throws or returns another valid adapter identity', async () => {
|
|
88
|
+
const throwing = await resolveInfraAdaptersAsync(local, {
|
|
89
|
+
loadAsync(packageName) {
|
|
90
|
+
const descriptor = descriptorForPackage(packageName);
|
|
91
|
+
return Promise.resolve({
|
|
92
|
+
infraAdapterDescriptor: descriptor,
|
|
93
|
+
createInfraAdapter: () => {
|
|
94
|
+
throw new Error('secret provider detail');
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
expect(throwing.ok).toBe(false);
|
|
100
|
+
expect(throwing.diagnostics[0]).toMatchObject({ code: 'infra-local-adapter-invalid' });
|
|
101
|
+
expect(throwing.diagnostics[0]?.message).not.toContain('secret provider detail');
|
|
102
|
+
|
|
103
|
+
const mismatched = await resolveInfraAdaptersAsync(local, {
|
|
104
|
+
loadAsync(packageName) {
|
|
105
|
+
const descriptor = descriptorForPackage(packageName);
|
|
106
|
+
return Promise.resolve({
|
|
107
|
+
infraAdapterDescriptor: descriptor,
|
|
108
|
+
createInfraAdapter: () =>
|
|
109
|
+
descriptor.id === 'local'
|
|
110
|
+
? createComputeAdapter(INFRA_ADAPTER_CATALOG.hetzner)
|
|
111
|
+
: createAdapter(descriptor),
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
expect(mismatched.ok).toBe(false);
|
|
116
|
+
expect(mismatched.diagnostics[0]).toMatchObject({ code: 'infra-local-adapter-invalid' });
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
function createResolver(requested: string[]): InfraAdapterPackageResolver {
|
|
121
|
+
return {
|
|
122
|
+
loadAsync(packageName) {
|
|
123
|
+
requested.push(packageName);
|
|
124
|
+
const descriptor = descriptorForPackage(packageName);
|
|
125
|
+
return Promise.resolve({
|
|
126
|
+
infraAdapterDescriptor: descriptor,
|
|
127
|
+
createInfraAdapter: () => createAdapter(descriptor),
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function descriptorForPackage(packageName: string): InfraAdapterDescriptor {
|
|
134
|
+
const descriptor = Object.values(INFRA_ADAPTER_CATALOG).find(
|
|
135
|
+
({ package: candidate }) => candidate === packageName,
|
|
136
|
+
);
|
|
137
|
+
if (descriptor === undefined) throw new Error('Unexpected package.');
|
|
138
|
+
return descriptor;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function createAdapter(descriptor: InfraAdapterDescriptor): unknown {
|
|
142
|
+
if (descriptor.kind === 'compute') return createComputeAdapter(descriptor);
|
|
143
|
+
if (descriptor.kind === 'runtime') return createRuntimeAdapter(descriptor);
|
|
144
|
+
return createServiceAdapter(descriptor);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function createComputeAdapter(descriptor: InfraAdapterDescriptor): InfraComputeAdapter {
|
|
148
|
+
return {
|
|
149
|
+
descriptor: descriptor as InfraComputeAdapter['descriptor'],
|
|
150
|
+
validateAsync: successNull,
|
|
151
|
+
inspectAsync: () => Promise.resolve(success({ resources: [], outputs: [], targets: [] })),
|
|
152
|
+
planAsync: successEmpty,
|
|
153
|
+
ensureAsync: () => Promise.resolve(success({ resources: [], outputs: [], targets: [] })),
|
|
154
|
+
statusAsync: successEmpty,
|
|
155
|
+
destroyAsync: () => Promise.resolve(success({ resources: [], outputs: [] })),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function createRuntimeAdapter(descriptor: InfraAdapterDescriptor): InfraRuntimeAdapter {
|
|
160
|
+
return {
|
|
161
|
+
descriptor: descriptor as InfraRuntimeAdapter['descriptor'],
|
|
162
|
+
validateAsync: successNull,
|
|
163
|
+
planAsync: successEmpty,
|
|
164
|
+
ensureAsync: () => Promise.resolve(success({ resources: [], outputs: [] })),
|
|
165
|
+
statusAsync: successEmpty,
|
|
166
|
+
suspendAsync: () => Promise.resolve(success({ resources: [], outputs: [] })),
|
|
167
|
+
destroyAsync: () => Promise.resolve(success({ resources: [], outputs: [] })),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function createServiceAdapter(descriptor: InfraAdapterDescriptor): InfraServiceAdapter {
|
|
172
|
+
return {
|
|
173
|
+
descriptor: descriptor as InfraServiceAdapter['descriptor'],
|
|
174
|
+
validateAsync: successNull,
|
|
175
|
+
planAsync: successEmpty,
|
|
176
|
+
desiredWorkloadsAsync: successEmpty,
|
|
177
|
+
reconcileAsync: () => Promise.resolve(success({ resources: [], outputs: [] })),
|
|
178
|
+
statusAsync: successEmpty,
|
|
179
|
+
destroyAsync: () => Promise.resolve(success({ resources: [], outputs: [] })),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function successNull(): Promise<InfraResult<null>> {
|
|
184
|
+
return Promise.resolve(success(null));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function successEmpty<T>(): Promise<InfraResult<readonly T[]>> {
|
|
188
|
+
return Promise.resolve(success([]));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function success<T>(value: T): InfraResult<T> {
|
|
192
|
+
return { ok: true, value, diagnostics: [] };
|
|
193
|
+
}
|
package/src/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraCredentialPort.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { InfraExecutionContext, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
+
|
|
3
|
+
import { createInfraFailure } from '../../utils/createInfraFailure.js';
|
|
4
|
+
import { normalizeInfraEnvironmentKey } from '../../utils/normalizeInfraEnvironmentKey.js';
|
|
5
|
+
|
|
6
|
+
/*** Resolve execution-only control-plane credentials from exact-name or prefixed environment data. */
|
|
7
|
+
export function createEnvironmentInfraCredentialPort(
|
|
8
|
+
environment: Readonly<Record<string, string | undefined>>,
|
|
9
|
+
): InfraExecutionContext['credentials'] {
|
|
10
|
+
return {
|
|
11
|
+
resolveAsync(reference) {
|
|
12
|
+
const prefixedName = `ANKH_INFRA_CREDENTIAL_${normalizeInfraEnvironmentKey(reference.name)}`;
|
|
13
|
+
const rawValue =
|
|
14
|
+
Reflect.get(environment, reference.name) ?? Reflect.get(environment, prefixedName);
|
|
15
|
+
if (rawValue === undefined || rawValue.length === 0) {
|
|
16
|
+
return Promise.resolve(
|
|
17
|
+
createInfraFailure(
|
|
18
|
+
'infra-control-plane-credential-missing',
|
|
19
|
+
`Control-plane credential ${reference.name} is unavailable. Set ${reference.name} or ${prefixedName}.`,
|
|
20
|
+
),
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
return Promise.resolve(parseCredentialBundle(reference.name, rawValue));
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/*** Parse JSON credential bundles; token variables also support their conventional scalar form. */
|
|
29
|
+
function parseCredentialBundle(
|
|
30
|
+
name: string,
|
|
31
|
+
rawValue: string,
|
|
32
|
+
): InfraResult<Readonly<Record<string, string>>> {
|
|
33
|
+
try {
|
|
34
|
+
const parsed: unknown = JSON.parse(rawValue);
|
|
35
|
+
if (isRecord(parsed) && Object.values(parsed).every((value) => typeof value === 'string')) {
|
|
36
|
+
return { ok: true, value: parsed as Readonly<Record<string, string>>, diagnostics: [] };
|
|
37
|
+
}
|
|
38
|
+
} catch {
|
|
39
|
+
if (name.endsWith('_TOKEN')) {
|
|
40
|
+
return { ok: true, value: { token: rawValue, apiToken: rawValue }, diagnostics: [] };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return createInfraFailure(
|
|
44
|
+
'infra-control-plane-credential-invalid',
|
|
45
|
+
`Control-plane credential ${name} must be a JSON object containing string fields.`,
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/*** Narrow JSON credential bundles. */
|
|
50
|
+
function isRecord(value: unknown): value is Readonly<Record<string, unknown>> {
|
|
51
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
52
|
+
}
|
package/src/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraSecretPort.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { InfraExecutionContext } from '@ankhorage/contracts/infra';
|
|
2
|
+
|
|
3
|
+
import { createInfraFailure } from '../../utils/createInfraFailure.js';
|
|
4
|
+
import { normalizeInfraEnvironmentKey } from '../../utils/normalizeInfraEnvironmentKey.js';
|
|
5
|
+
|
|
6
|
+
/*** Resolve explicitly addressed secret values from environment data without serializing them. */
|
|
7
|
+
export function createEnvironmentInfraSecretPort(
|
|
8
|
+
environment: Readonly<Record<string, string | undefined>>,
|
|
9
|
+
): InfraExecutionContext['secrets'] {
|
|
10
|
+
return {
|
|
11
|
+
resolveAsync(reference) {
|
|
12
|
+
const variable = [
|
|
13
|
+
'ANKH_INFRA_SECRET',
|
|
14
|
+
reference.projectId,
|
|
15
|
+
reference.environment,
|
|
16
|
+
reference.ref,
|
|
17
|
+
reference.key,
|
|
18
|
+
]
|
|
19
|
+
.map(normalizeInfraEnvironmentKey)
|
|
20
|
+
.join('_');
|
|
21
|
+
const value: unknown = Reflect.get(environment, variable);
|
|
22
|
+
return Promise.resolve(
|
|
23
|
+
typeof value !== 'string' || value.length === 0
|
|
24
|
+
? createInfraFailure(
|
|
25
|
+
'infra-secret-unavailable',
|
|
26
|
+
`Secret reference ${reference.ref}/${reference.key} is unavailable. Set ${variable}.`,
|
|
27
|
+
)
|
|
28
|
+
: { ok: true, value, diagnostics: [] },
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { InfraAdapterPackageResolver } from '../../application/ports/outbound/infraAdapterPackage.js';
|
|
2
|
+
|
|
3
|
+
/*** Load only a catalog-selected package through the host module resolver. */
|
|
4
|
+
export function createNodeInfraAdapterPackageResolver(): InfraAdapterPackageResolver {
|
|
5
|
+
return {
|
|
6
|
+
loadAsync(packageName) {
|
|
7
|
+
return import(packageName);
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AppEnvironmentId } from '@ankhorage/contracts/environments';
|
|
2
|
+
import { promises as fs } from 'fs';
|
|
3
|
+
|
|
4
|
+
import type { InfraStoredState } from '../../../../types/infraOrchestration.js';
|
|
5
|
+
import { isInfraStoredState } from '../../utils/isInfraStoredState.js';
|
|
6
|
+
import { resolveInfraStatePath } from '../../utils/resolveInfraStatePath.js';
|
|
7
|
+
|
|
8
|
+
/*** Read exact environment state; malformed ownership state fails closed rather than disappearing. */
|
|
9
|
+
export async function readStoredInfraStateAsync(
|
|
10
|
+
projectPath: string,
|
|
11
|
+
environment: AppEnvironmentId,
|
|
12
|
+
): Promise<InfraStoredState | null> {
|
|
13
|
+
const statePath = resolveInfraStatePath(projectPath, environment);
|
|
14
|
+
try {
|
|
15
|
+
const parsed: unknown = JSON.parse(await fs.readFile(statePath, 'utf8'));
|
|
16
|
+
if (!isInfraStoredState(parsed)) {
|
|
17
|
+
throw new Error(`Stored Infra state has an invalid shape: ${statePath}`);
|
|
18
|
+
}
|
|
19
|
+
return parsed;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if (isMissingFile(error)) return null;
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/*** Recognize only the filesystem's absent-file failure. */
|
|
27
|
+
function isMissingFile(error: unknown): boolean {
|
|
28
|
+
return isRecord(error) && error.code === 'ENOENT';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/*** Narrow filesystem error values. */
|
|
32
|
+
function isRecord(value: unknown): value is Readonly<Record<string, unknown>> {
|
|
33
|
+
return typeof value === 'object' && value !== null;
|
|
34
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AppEnvironmentId } from '@ankhorage/contracts/environments';
|
|
2
|
+
import { promises as fs } from 'fs';
|
|
3
|
+
|
|
4
|
+
import { resolveInfraStatePath } from '../../utils/resolveInfraStatePath.js';
|
|
5
|
+
|
|
6
|
+
/*** Remove only the exact selected environment state after a complete destroy. */
|
|
7
|
+
export async function removeStoredInfraStateAsync(
|
|
8
|
+
projectPath: string,
|
|
9
|
+
environment: AppEnvironmentId,
|
|
10
|
+
): Promise<void> {
|
|
11
|
+
await fs.rm(resolveInfraStatePath(projectPath, environment), { force: true });
|
|
12
|
+
}
|
|
@@ -2,16 +2,10 @@ import { type AppManifest, isAppManifest } from '@ankhorage/contracts';
|
|
|
2
2
|
import { promises as fs } from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
readonly appsRoot: string;
|
|
7
|
-
readonly manifest: AppManifest;
|
|
8
|
-
readonly manifestPath: string;
|
|
9
|
-
readonly projectId: string;
|
|
10
|
-
readonly projectPath: string;
|
|
11
|
-
readonly workspaceRoot: string;
|
|
12
|
-
}
|
|
5
|
+
import type { ResolvedInfraProject } from '../../../../types/infraProject.js';
|
|
13
6
|
|
|
14
|
-
|
|
7
|
+
/*** Resolve one manifest-backed Infra project from the workspace and optional project selector. */
|
|
8
|
+
export async function resolveInfraProjectAsync(options: {
|
|
15
9
|
readonly cwd: string;
|
|
16
10
|
readonly projectId?: string;
|
|
17
11
|
}): Promise<ResolvedInfraProject> {
|
|
@@ -37,7 +31,7 @@ export async function resolveInfraProject(options: {
|
|
|
37
31
|
}
|
|
38
32
|
|
|
39
33
|
const manifestPath = path.join(projectPath, 'ankh.config.json');
|
|
40
|
-
const manifest = await readProjectManifest(
|
|
34
|
+
const manifest = await readProjectManifest(manifestPath);
|
|
41
35
|
|
|
42
36
|
return {
|
|
43
37
|
appsRoot,
|
|
@@ -60,54 +54,25 @@ function resolveProjectPath(appsRoot: string, projectId: string): string {
|
|
|
60
54
|
return projectPath;
|
|
61
55
|
}
|
|
62
56
|
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
name: projectId,
|
|
67
|
-
slug: projectId,
|
|
68
|
-
version: '0.0.0',
|
|
69
|
-
category: 'developer_tools',
|
|
70
|
-
themeId: 'default',
|
|
71
|
-
},
|
|
72
|
-
themes: [],
|
|
73
|
-
activeThemeId: 'default',
|
|
74
|
-
infra: { modules: [] },
|
|
75
|
-
navigator: {
|
|
76
|
-
type: 'stack',
|
|
77
|
-
routes: [{ name: 'index', screenId: 'index' }],
|
|
78
|
-
},
|
|
79
|
-
screens: {},
|
|
80
|
-
settings: {
|
|
81
|
-
localization: {
|
|
82
|
-
defaultLocale: 'en',
|
|
83
|
-
locales: ['en'],
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async function readProjectManifest(args: {
|
|
90
|
-
readonly manifestPath: string;
|
|
91
|
-
readonly projectId: string;
|
|
92
|
-
}): Promise<AppManifest> {
|
|
93
|
-
if (!(await pathExists(args.manifestPath))) {
|
|
94
|
-
return createFallbackManifest(args.projectId);
|
|
57
|
+
async function readProjectManifest(manifestPath: string): Promise<AppManifest> {
|
|
58
|
+
if (!(await pathExists(manifestPath))) {
|
|
59
|
+
throw new Error(`Project manifest not found: ${manifestPath}`);
|
|
95
60
|
}
|
|
96
61
|
|
|
97
|
-
const rawManifest = await fs.readFile(
|
|
62
|
+
const rawManifest = await fs.readFile(manifestPath, 'utf8');
|
|
98
63
|
let parsed: unknown;
|
|
99
64
|
|
|
100
65
|
try {
|
|
101
66
|
parsed = JSON.parse(rawManifest);
|
|
102
67
|
} catch (error) {
|
|
103
68
|
throw new Error(
|
|
104
|
-
`Project manifest is not valid JSON: ${
|
|
69
|
+
`Project manifest is not valid JSON: ${manifestPath}: ${getErrorMessage(error)}`,
|
|
105
70
|
{ cause: error },
|
|
106
71
|
);
|
|
107
72
|
}
|
|
108
73
|
|
|
109
74
|
if (!isAppManifest(parsed)) {
|
|
110
|
-
throw new Error(`Project manifest has an invalid shape: ${
|
|
75
|
+
throw new Error(`Project manifest has an invalid shape: ${manifestPath}`);
|
|
111
76
|
}
|
|
112
77
|
|
|
113
78
|
return parsed;
|
package/src/features/environment-lifecycle/adapters/outbound/writeInfraGeneratedArtifactsAsync.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { InfraGeneratedArtifact, InfraLedger } from '@ankhorage/contracts/infra';
|
|
2
|
+
import { promises as fs } from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
import type { InfraArtifactWriteResult } from '../../../../types/infraProject.js';
|
|
6
|
+
import { resolveProjectFile } from '../../utils/resolveProjectFile.js';
|
|
7
|
+
|
|
8
|
+
/*** Write validated generated artifacts and remove only stale paths from the prior ledger. */
|
|
9
|
+
export async function writeInfraGeneratedArtifactsAsync(
|
|
10
|
+
projectPath: string,
|
|
11
|
+
artifacts: readonly InfraGeneratedArtifact[],
|
|
12
|
+
previous: InfraLedger | undefined,
|
|
13
|
+
): Promise<InfraArtifactWriteResult> {
|
|
14
|
+
const nextPaths = new Set<string>();
|
|
15
|
+
const validated = artifacts.map((artifact) => {
|
|
16
|
+
if (nextPaths.has(artifact.path)) {
|
|
17
|
+
throw new Error(`Duplicate generated Infra artifact path: ${artifact.path}`);
|
|
18
|
+
}
|
|
19
|
+
nextPaths.add(artifact.path);
|
|
20
|
+
return { artifact, outputPath: resolveProjectFile(projectPath, artifact.path) };
|
|
21
|
+
});
|
|
22
|
+
for (const { artifact, outputPath } of validated) {
|
|
23
|
+
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
|
24
|
+
await fs.writeFile(outputPath, artifact.content, 'utf8');
|
|
25
|
+
if (artifact.executable === true) await fs.chmod(outputPath, 0o755);
|
|
26
|
+
}
|
|
27
|
+
const stalePaths = (previous?.artifacts ?? [])
|
|
28
|
+
.map(({ path: artifactPath }) => artifactPath)
|
|
29
|
+
.filter((artifactPath) => !nextPaths.has(artifactPath));
|
|
30
|
+
for (const stalePath of stalePaths) {
|
|
31
|
+
await fs.rm(resolveProjectFile(projectPath, stalePath), { force: true });
|
|
32
|
+
}
|
|
33
|
+
return { written: validated.length, removed: stalePaths.length };
|
|
34
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
import type { InfraStoredState } from '../../../../types/infraOrchestration.js';
|
|
5
|
+
import { isInfraStoredState } from '../../utils/isInfraStoredState.js';
|
|
6
|
+
import { resolveInfraStatePath } from '../../utils/resolveInfraStatePath.js';
|
|
7
|
+
|
|
8
|
+
/*** Persist serializable desired identity plus a secret-safe canonical ledger atomically. */
|
|
9
|
+
export async function writeStoredInfraStateAsync(
|
|
10
|
+
projectPath: string,
|
|
11
|
+
state: InfraStoredState,
|
|
12
|
+
): Promise<void> {
|
|
13
|
+
if (!isInfraStoredState(state)) {
|
|
14
|
+
throw new Error('Refusing to persist invalid or cross-scoped Infra ownership state.');
|
|
15
|
+
}
|
|
16
|
+
const statePath = resolveInfraStatePath(projectPath, state.ledger.environment);
|
|
17
|
+
const temporaryPath = `${statePath}.tmp`;
|
|
18
|
+
await fs.mkdir(path.dirname(statePath), { recursive: true });
|
|
19
|
+
await fs.writeFile(temporaryPath, `${JSON.stringify(state, null, 2)}\n`, 'utf8');
|
|
20
|
+
await fs.rename(temporaryPath, statePath);
|
|
21
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { InfraAdapterDescriptor } from '@ankhorage/contracts/infra';
|
|
2
|
+
|
|
3
|
+
export interface InfraAdapterPackageResolver {
|
|
4
|
+
loadAsync(packageName: string): Promise<unknown>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface InfraAdapterPackageModule {
|
|
8
|
+
readonly infraAdapterDescriptor: InfraAdapterDescriptor;
|
|
9
|
+
readonly createInfraAdapter: () => unknown;
|
|
10
|
+
}
|
package/src/features/environment-lifecycle/application/use-cases/collectInfraWorkloadsAsync.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InfraDiagnostic,
|
|
3
|
+
InfraExecutionContext,
|
|
4
|
+
InfraResult,
|
|
5
|
+
InfraServiceAdapter,
|
|
6
|
+
InfraWorkloadSpec,
|
|
7
|
+
} from '@ankhorage/contracts/infra';
|
|
8
|
+
|
|
9
|
+
import { appendInfraFailure } from '../../utils/appendInfraFailure.js';
|
|
10
|
+
|
|
11
|
+
/*** Collect each service workload graph once in deterministic adapter order. */
|
|
12
|
+
export async function collectInfraWorkloadsAsync(
|
|
13
|
+
context: InfraExecutionContext,
|
|
14
|
+
services: readonly InfraServiceAdapter[],
|
|
15
|
+
): Promise<InfraResult<readonly InfraWorkloadSpec[]>> {
|
|
16
|
+
const workloads: InfraWorkloadSpec[] = [];
|
|
17
|
+
const diagnostics: InfraDiagnostic[] = [];
|
|
18
|
+
for (const service of services) {
|
|
19
|
+
const desired = await service.desiredWorkloadsAsync(context);
|
|
20
|
+
if (!desired.ok) return appendInfraFailure(diagnostics, desired);
|
|
21
|
+
workloads.push(...desired.value);
|
|
22
|
+
diagnostics.push(...desired.diagnostics);
|
|
23
|
+
}
|
|
24
|
+
return { ok: true, value: workloads, diagnostics };
|
|
25
|
+
}
|
package/src/features/environment-lifecycle/application/use-cases/destroyInfraEnvironmentAsync.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InfraDestroyRequest,
|
|
3
|
+
InfraDiagnostic,
|
|
4
|
+
InfraOutput,
|
|
5
|
+
InfraOwnedResource,
|
|
6
|
+
InfraResult,
|
|
7
|
+
} from '@ankhorage/contracts/infra';
|
|
8
|
+
|
|
9
|
+
import type {
|
|
10
|
+
InfraDestroyOperationRequest,
|
|
11
|
+
InfraDestroyOperationResult,
|
|
12
|
+
InfraOrchestrationDependencies,
|
|
13
|
+
} from '../../../../types/infraOrchestration.js';
|
|
14
|
+
import { appendInfraFailure } from '../../utils/appendInfraFailure.js';
|
|
15
|
+
import { createInfraLedger } from '../../utils/createInfraLedger.js';
|
|
16
|
+
import { infraIdentityKey } from '../../utils/infraIdentityKey.js';
|
|
17
|
+
import { mergeInfraOutputs } from '../../utils/mergeInfraOutputs.js';
|
|
18
|
+
import { mergeInfraResources } from '../../utils/mergeInfraResources.js';
|
|
19
|
+
import { prepareInfraOperationAsync } from './prepareInfraOperationAsync.js';
|
|
20
|
+
|
|
21
|
+
/*** Destroy exact owned resources in reverse dependency order behind explicit scope confirmation. */
|
|
22
|
+
export async function destroyInfraEnvironmentAsync(
|
|
23
|
+
request: InfraDestroyOperationRequest,
|
|
24
|
+
dependencies: InfraOrchestrationDependencies,
|
|
25
|
+
): Promise<InfraDestroyOperationResult> {
|
|
26
|
+
const prepared = await prepareInfraOperationAsync(request, 'destroy', dependencies);
|
|
27
|
+
if (!prepared.ok) return prepared;
|
|
28
|
+
const destroyRequest: InfraDestroyRequest = {
|
|
29
|
+
projectId: request.projectId,
|
|
30
|
+
environment: prepared.value.environment.id,
|
|
31
|
+
confirmation: request.confirmation,
|
|
32
|
+
persistence: request.persistence,
|
|
33
|
+
};
|
|
34
|
+
const safety = validateDestroyRequest(destroyRequest, request.previous?.resources ?? []);
|
|
35
|
+
if (!safety.ok) return safety;
|
|
36
|
+
const diagnostics: InfraDiagnostic[] = [...prepared.diagnostics];
|
|
37
|
+
const resources: InfraOwnedResource[] = [];
|
|
38
|
+
const outputs: InfraOutput[] = [];
|
|
39
|
+
for (const service of [...prepared.value.adapters.services].reverse()) {
|
|
40
|
+
const result = await service.destroyAsync(prepared.value.context, destroyRequest);
|
|
41
|
+
if (!result.ok) return appendInfraFailure(diagnostics, result);
|
|
42
|
+
resources.push(...result.value.resources);
|
|
43
|
+
outputs.push(...result.value.outputs);
|
|
44
|
+
diagnostics.push(...result.diagnostics);
|
|
45
|
+
}
|
|
46
|
+
if (prepared.value.runtimeDesired.targets.length > 0) {
|
|
47
|
+
const runtime = await prepared.value.adapters.runtime.destroyAsync(
|
|
48
|
+
prepared.value.context,
|
|
49
|
+
prepared.value.runtimeDesired,
|
|
50
|
+
destroyRequest,
|
|
51
|
+
);
|
|
52
|
+
if (!runtime.ok) return appendInfraFailure(diagnostics, runtime);
|
|
53
|
+
resources.push(...runtime.value.resources);
|
|
54
|
+
outputs.push(...runtime.value.outputs);
|
|
55
|
+
diagnostics.push(...runtime.diagnostics);
|
|
56
|
+
}
|
|
57
|
+
const compute = await prepared.value.adapters.compute.destroyAsync(
|
|
58
|
+
prepared.value.context,
|
|
59
|
+
destroyRequest,
|
|
60
|
+
);
|
|
61
|
+
if (!compute.ok) return appendInfraFailure(diagnostics, compute);
|
|
62
|
+
resources.push(...compute.value.resources);
|
|
63
|
+
outputs.push(...compute.value.outputs);
|
|
64
|
+
diagnostics.push(...compute.diagnostics);
|
|
65
|
+
const remainingResources = mergeInfraResources(resources);
|
|
66
|
+
const remainingOutputs = mergeInfraOutputs(outputs);
|
|
67
|
+
const ledger =
|
|
68
|
+
remainingResources.length === 0 && remainingOutputs.length === 0
|
|
69
|
+
? null
|
|
70
|
+
: createInfraLedger({
|
|
71
|
+
projectId: request.projectId,
|
|
72
|
+
environment: prepared.value.environment.id,
|
|
73
|
+
targets: [],
|
|
74
|
+
resources: remainingResources,
|
|
75
|
+
outputs: remainingOutputs,
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
ok: true,
|
|
79
|
+
value: { environment: prepared.value.environment.id, ledger },
|
|
80
|
+
diagnostics,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/*** Refuse cross-project confirmation and unowned persistent deletion before any mutation. */
|
|
85
|
+
function validateDestroyRequest(
|
|
86
|
+
request: InfraDestroyRequest,
|
|
87
|
+
previous: readonly InfraOwnedResource[],
|
|
88
|
+
): InfraResult<null> {
|
|
89
|
+
if (
|
|
90
|
+
request.confirmation.projectId !== request.projectId ||
|
|
91
|
+
request.confirmation.environment !== request.environment
|
|
92
|
+
) {
|
|
93
|
+
return destroyFailure(
|
|
94
|
+
'infra-destroy-confirmation-mismatch',
|
|
95
|
+
'Infra destroy confirmation must exactly match the selected project and environment.',
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
if (request.persistence.policy === 'retain') {
|
|
99
|
+
return { ok: true, value: null, diagnostics: [] };
|
|
100
|
+
}
|
|
101
|
+
const owned = new Set(previous.map(({ identity }) => infraIdentityKey(identity)));
|
|
102
|
+
const invalid = request.persistence.confirmedResources.some(
|
|
103
|
+
(identity) =>
|
|
104
|
+
identity.projectId !== request.projectId ||
|
|
105
|
+
identity.environment !== request.environment ||
|
|
106
|
+
!owned.has(infraIdentityKey(identity)),
|
|
107
|
+
);
|
|
108
|
+
return invalid
|
|
109
|
+
? destroyFailure(
|
|
110
|
+
'infra-destroy-resource-unowned',
|
|
111
|
+
'Persistent deletion confirmation contains a resource outside the stored Infra scope.',
|
|
112
|
+
)
|
|
113
|
+
: { ok: true, value: null, diagnostics: [] };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/*** Create one stable non-provider-specific destroy safety failure. */
|
|
117
|
+
function destroyFailure(code: string, message: string): InfraResult<never> {
|
|
118
|
+
return { ok: false, diagnostics: [{ severity: 'error', code, message }] };
|
|
119
|
+
}
|