@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,65 @@
|
|
|
1
|
+
import type { InfraDiagnostic, InfraOutput, InfraOwnedResource } from '@ankhorage/contracts/infra';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
InfraDownOperationResult,
|
|
5
|
+
InfraOperationRequest,
|
|
6
|
+
InfraOrchestrationDependencies,
|
|
7
|
+
} from '../../../../types/infraOrchestration.js';
|
|
8
|
+
import { appendInfraFailure } from '../../utils/appendInfraFailure.js';
|
|
9
|
+
import { createInfraLedger } from '../../utils/createInfraLedger.js';
|
|
10
|
+
import { retainUnchangedAdapterOutputs } from '../../utils/retainUnchangedAdapterOutputs.js';
|
|
11
|
+
import { retainUnchangedAdapterResources } from '../../utils/retainUnchangedAdapterResources.js';
|
|
12
|
+
import { prepareInfraOperationAsync } from './prepareInfraOperationAsync.js';
|
|
13
|
+
|
|
14
|
+
/*** Reversibly suspend services and runtime while retaining compute and persistent data. */
|
|
15
|
+
export async function downInfraEnvironmentAsync(
|
|
16
|
+
request: InfraOperationRequest,
|
|
17
|
+
dependencies: InfraOrchestrationDependencies,
|
|
18
|
+
): Promise<InfraDownOperationResult> {
|
|
19
|
+
const prepared = await prepareInfraOperationAsync(request, 'down', dependencies);
|
|
20
|
+
if (!prepared.ok) return prepared;
|
|
21
|
+
const diagnostics: InfraDiagnostic[] = [...prepared.diagnostics];
|
|
22
|
+
const resources: InfraOwnedResource[] = [];
|
|
23
|
+
const outputs: InfraOutput[] = [];
|
|
24
|
+
const replacedAdapters = new Set<string>();
|
|
25
|
+
for (const service of [...prepared.value.adapters.services].reverse()) {
|
|
26
|
+
if (service.suspendAsync === undefined) continue;
|
|
27
|
+
const result = await service.suspendAsync(prepared.value.context);
|
|
28
|
+
if (!result.ok) return appendInfraFailure(diagnostics, result);
|
|
29
|
+
replacedAdapters.add(service.descriptor.id);
|
|
30
|
+
resources.push(...result.value.resources);
|
|
31
|
+
outputs.push(...result.value.outputs);
|
|
32
|
+
diagnostics.push(...result.diagnostics);
|
|
33
|
+
}
|
|
34
|
+
if (prepared.value.runtimeDesired.targets.length > 0) {
|
|
35
|
+
const runtime = await prepared.value.adapters.runtime.suspendAsync(
|
|
36
|
+
prepared.value.context,
|
|
37
|
+
prepared.value.runtimeDesired,
|
|
38
|
+
);
|
|
39
|
+
if (!runtime.ok) return appendInfraFailure(diagnostics, runtime);
|
|
40
|
+
replacedAdapters.add(prepared.value.adapters.runtime.descriptor.id);
|
|
41
|
+
resources.push(...runtime.value.resources);
|
|
42
|
+
outputs.push(...runtime.value.outputs);
|
|
43
|
+
diagnostics.push(...runtime.diagnostics);
|
|
44
|
+
}
|
|
45
|
+
const previousResources = request.previous?.resources ?? [];
|
|
46
|
+
const previousOutputs = request.previous?.outputs ?? [];
|
|
47
|
+
return {
|
|
48
|
+
ok: true,
|
|
49
|
+
value: {
|
|
50
|
+
environment: prepared.value.environment.id,
|
|
51
|
+
ledger: createInfraLedger({
|
|
52
|
+
projectId: request.projectId,
|
|
53
|
+
environment: prepared.value.environment.id,
|
|
54
|
+
targets:
|
|
55
|
+
prepared.value.compute.targets.length > 0
|
|
56
|
+
? prepared.value.compute.targets
|
|
57
|
+
: (request.previous?.targets ?? []),
|
|
58
|
+
resources: retainUnchangedAdapterResources(previousResources, resources, replacedAdapters),
|
|
59
|
+
outputs: retainUnchangedAdapterOutputs(previousOutputs, outputs, replacedAdapters),
|
|
60
|
+
previous: request.previous,
|
|
61
|
+
}),
|
|
62
|
+
},
|
|
63
|
+
diagnostics,
|
|
64
|
+
};
|
|
65
|
+
}
|
package/src/features/environment-lifecycle/application/use-cases/generateInfraEnvironmentAsync.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { InfraDiagnostic } from '@ankhorage/contracts/infra';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
InfraGenerateOperationResult,
|
|
5
|
+
InfraOperationRequest,
|
|
6
|
+
InfraOrchestrationDependencies,
|
|
7
|
+
} from '../../../../types/infraOrchestration.js';
|
|
8
|
+
import { appendInfraFailure } from '../../utils/appendInfraFailure.js';
|
|
9
|
+
import { createInfraLedger } from '../../utils/createInfraLedger.js';
|
|
10
|
+
import { mergeInfraOutputs } from '../../utils/mergeInfraOutputs.js';
|
|
11
|
+
import { mergeInfraResources } from '../../utils/mergeInfraResources.js';
|
|
12
|
+
import { prepareInfraOperationAsync } from './prepareInfraOperationAsync.js';
|
|
13
|
+
|
|
14
|
+
/*** Generate deterministic review artifacts without mutating local or remote infrastructure. */
|
|
15
|
+
export async function generateInfraEnvironmentAsync(
|
|
16
|
+
request: InfraOperationRequest,
|
|
17
|
+
dependencies: InfraOrchestrationDependencies,
|
|
18
|
+
): Promise<InfraGenerateOperationResult> {
|
|
19
|
+
const prepared = await prepareInfraOperationAsync(request, 'generate', dependencies);
|
|
20
|
+
if (!prepared.ok) return prepared;
|
|
21
|
+
const diagnostics: InfraDiagnostic[] = [...prepared.diagnostics];
|
|
22
|
+
const { runtime } = prepared.value.adapters;
|
|
23
|
+
const artifacts =
|
|
24
|
+
runtime.generateAsync === undefined || prepared.value.runtimeDesired.targets.length === 0
|
|
25
|
+
? { ok: true as const, value: [], diagnostics: [] }
|
|
26
|
+
: await runtime.generateAsync(prepared.value.context, prepared.value.runtimeDesired);
|
|
27
|
+
if (!artifacts.ok) return appendInfraFailure(diagnostics, artifacts);
|
|
28
|
+
diagnostics.push(...artifacts.diagnostics);
|
|
29
|
+
return {
|
|
30
|
+
ok: true,
|
|
31
|
+
value: {
|
|
32
|
+
environment: prepared.value.environment.id,
|
|
33
|
+
artifacts: artifacts.value,
|
|
34
|
+
ledger: createInfraLedger({
|
|
35
|
+
projectId: request.projectId,
|
|
36
|
+
environment: prepared.value.environment.id,
|
|
37
|
+
targets:
|
|
38
|
+
prepared.value.compute.targets.length > 0
|
|
39
|
+
? prepared.value.compute.targets
|
|
40
|
+
: (request.previous?.targets ?? []),
|
|
41
|
+
resources: mergeInfraResources(
|
|
42
|
+
request.previous?.resources ?? [],
|
|
43
|
+
prepared.value.compute.resources,
|
|
44
|
+
),
|
|
45
|
+
outputs: mergeInfraOutputs(request.previous?.outputs ?? [], prepared.value.compute.outputs),
|
|
46
|
+
artifacts: artifacts.value,
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
diagnostics,
|
|
50
|
+
};
|
|
51
|
+
}
|
package/src/features/environment-lifecycle/application/use-cases/getInfraEnvironmentOutputs.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InfraOperationRequest,
|
|
3
|
+
InfraOutputsOperationResult,
|
|
4
|
+
} from '../../../../types/infraOrchestration.js';
|
|
5
|
+
import { resolveInfraEnvironment } from '../../domain/resolveInfraEnvironment.js';
|
|
6
|
+
|
|
7
|
+
/*** Return only safe serialized public outputs and secret references from the canonical ledger. */
|
|
8
|
+
export function getInfraEnvironmentOutputs(
|
|
9
|
+
request: InfraOperationRequest,
|
|
10
|
+
): InfraOutputsOperationResult {
|
|
11
|
+
const environment = resolveInfraEnvironment({
|
|
12
|
+
manifest: request.manifest,
|
|
13
|
+
environment: request.environment,
|
|
14
|
+
operation: 'outputs',
|
|
15
|
+
});
|
|
16
|
+
if (!environment.ok) return environment;
|
|
17
|
+
if (
|
|
18
|
+
request.previous !== undefined &&
|
|
19
|
+
(request.previous.projectId !== request.projectId ||
|
|
20
|
+
request.previous.environment !== environment.value.id)
|
|
21
|
+
) {
|
|
22
|
+
return {
|
|
23
|
+
ok: false,
|
|
24
|
+
diagnostics: [
|
|
25
|
+
{
|
|
26
|
+
severity: 'error',
|
|
27
|
+
code: 'infra-ledger-scope-mismatch',
|
|
28
|
+
message: 'Stored Infra state does not belong to the selected project and environment.',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
ok: true,
|
|
35
|
+
value: {
|
|
36
|
+
environment: environment.value.id,
|
|
37
|
+
outputs: request.previous?.outputs ?? [],
|
|
38
|
+
},
|
|
39
|
+
diagnostics: environment.diagnostics,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { InfraDiagnostic, InfraPlanAction } from '@ankhorage/contracts/infra';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
InfraOperationRequest,
|
|
5
|
+
InfraOrchestrationDependencies,
|
|
6
|
+
InfraPlanOperationResult,
|
|
7
|
+
} from '../../../../types/infraOrchestration.js';
|
|
8
|
+
import { orderInfraPlanActions } from '../../domain/orderInfraPlanActions.js';
|
|
9
|
+
import { appendInfraFailure } from '../../utils/appendInfraFailure.js';
|
|
10
|
+
import { prepareInfraOperationAsync } from './prepareInfraOperationAsync.js';
|
|
11
|
+
|
|
12
|
+
/*** Aggregate a side-effect-free dependency-ordered plan from all selected adapters. */
|
|
13
|
+
export async function planInfraEnvironmentAsync(
|
|
14
|
+
request: InfraOperationRequest,
|
|
15
|
+
dependencies: InfraOrchestrationDependencies,
|
|
16
|
+
): Promise<InfraPlanOperationResult> {
|
|
17
|
+
const prepared = await prepareInfraOperationAsync(request, 'plan', dependencies);
|
|
18
|
+
if (!prepared.ok) return prepared;
|
|
19
|
+
const diagnostics: InfraDiagnostic[] = [...prepared.diagnostics];
|
|
20
|
+
const actions: InfraPlanAction[] = [];
|
|
21
|
+
const compute = await prepared.value.adapters.compute.planAsync(
|
|
22
|
+
prepared.value.context,
|
|
23
|
+
prepared.value.environment.desired.deployment.compute,
|
|
24
|
+
);
|
|
25
|
+
if (!compute.ok) return appendInfraFailure(diagnostics, compute);
|
|
26
|
+
actions.push(...compute.value);
|
|
27
|
+
diagnostics.push(...compute.diagnostics);
|
|
28
|
+
if (prepared.value.runtimeDesired.targets.length === 0) {
|
|
29
|
+
actions.push({
|
|
30
|
+
owner: {
|
|
31
|
+
projectId: request.projectId,
|
|
32
|
+
environment: prepared.value.environment.id,
|
|
33
|
+
adapter: prepared.value.adapters.runtime.descriptor.id,
|
|
34
|
+
resourceId: 'runtime',
|
|
35
|
+
},
|
|
36
|
+
operation: 'create',
|
|
37
|
+
impact: 'none',
|
|
38
|
+
detail: 'Runtime planning is deferred until the planned compute target exists.',
|
|
39
|
+
dependsOn: compute.value.map(({ owner }) => owner),
|
|
40
|
+
});
|
|
41
|
+
} else {
|
|
42
|
+
const runtime = await prepared.value.adapters.runtime.planAsync(
|
|
43
|
+
prepared.value.context,
|
|
44
|
+
prepared.value.runtimeDesired,
|
|
45
|
+
);
|
|
46
|
+
if (!runtime.ok) return appendInfraFailure(diagnostics, runtime);
|
|
47
|
+
actions.push(...runtime.value);
|
|
48
|
+
diagnostics.push(...runtime.diagnostics);
|
|
49
|
+
}
|
|
50
|
+
for (const service of prepared.value.adapters.services) {
|
|
51
|
+
const plan = await service.planAsync(prepared.value.context);
|
|
52
|
+
if (!plan.ok) return appendInfraFailure(diagnostics, plan);
|
|
53
|
+
actions.push(...plan.value);
|
|
54
|
+
diagnostics.push(...plan.diagnostics);
|
|
55
|
+
}
|
|
56
|
+
const ordered = orderInfraPlanActions(actions);
|
|
57
|
+
if (!ordered.ok) return appendInfraFailure(diagnostics, ordered);
|
|
58
|
+
return {
|
|
59
|
+
ok: true,
|
|
60
|
+
value: {
|
|
61
|
+
projectId: request.projectId,
|
|
62
|
+
environment: prepared.value.environment.id,
|
|
63
|
+
actions: ordered.value,
|
|
64
|
+
},
|
|
65
|
+
diagnostics,
|
|
66
|
+
};
|
|
67
|
+
}
|
package/src/features/environment-lifecycle/application/use-cases/prepareInfraOperationAsync.ts
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { InfraDiagnostic, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
InfraOperationRequest,
|
|
5
|
+
InfraOrchestrationDependencies,
|
|
6
|
+
PreparedInfraOperation,
|
|
7
|
+
} from '../../../../types/infraOrchestration.js';
|
|
8
|
+
import { resolveInfraEnvironment } from '../../domain/resolveInfraEnvironment.js';
|
|
9
|
+
import { appendInfraFailure } from '../../utils/appendInfraFailure.js';
|
|
10
|
+
import { createInfraExecutionContext } from '../../utils/createInfraExecutionContext.js';
|
|
11
|
+
import { collectInfraWorkloadsAsync } from './collectInfraWorkloadsAsync.js';
|
|
12
|
+
import { resolveInfraAdaptersAsync } from './resolveInfraAdaptersAsync.js';
|
|
13
|
+
import { validateInfraAdaptersAsync } from './validateInfraAdaptersAsync.js';
|
|
14
|
+
|
|
15
|
+
/*** Resolve and validate one operation without creating, updating or deleting infrastructure. */
|
|
16
|
+
export async function prepareInfraOperationAsync(
|
|
17
|
+
request: InfraOperationRequest,
|
|
18
|
+
operation: 'validate' | 'plan' | 'generate' | 'status' | 'outputs' | 'down' | 'destroy',
|
|
19
|
+
dependencies: InfraOrchestrationDependencies,
|
|
20
|
+
): Promise<InfraResult<PreparedInfraOperation>> {
|
|
21
|
+
const diagnostics: InfraDiagnostic[] = [];
|
|
22
|
+
const environment = resolveInfraEnvironment({
|
|
23
|
+
manifest: request.manifest,
|
|
24
|
+
environment: request.environment,
|
|
25
|
+
operation,
|
|
26
|
+
});
|
|
27
|
+
if (!environment.ok) return environment;
|
|
28
|
+
diagnostics.push(...environment.diagnostics);
|
|
29
|
+
if (
|
|
30
|
+
request.previous !== undefined &&
|
|
31
|
+
request.previousDesired !== undefined &&
|
|
32
|
+
!hasSameProviderSelection(request.previousDesired, environment.value.desired)
|
|
33
|
+
) {
|
|
34
|
+
return {
|
|
35
|
+
ok: false,
|
|
36
|
+
diagnostics: [
|
|
37
|
+
...diagnostics,
|
|
38
|
+
{
|
|
39
|
+
severity: 'error',
|
|
40
|
+
code: 'infra-provider-selection-changed',
|
|
41
|
+
message:
|
|
42
|
+
'Stored Infra resources use another provider selection. Destroy that environment before applying the new selection.',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const adapters = await resolveInfraAdaptersAsync(
|
|
48
|
+
environment.value.desired,
|
|
49
|
+
dependencies.adapterResolver,
|
|
50
|
+
);
|
|
51
|
+
if (!adapters.ok) return appendInfraFailure(diagnostics, adapters);
|
|
52
|
+
diagnostics.push(...adapters.diagnostics);
|
|
53
|
+
const context = createInfraExecutionContext(request, environment.value, dependencies);
|
|
54
|
+
const validation = await validateInfraAdaptersAsync(context, adapters.value);
|
|
55
|
+
if (!validation.ok) return appendInfraFailure(diagnostics, validation);
|
|
56
|
+
diagnostics.push(...validation.diagnostics);
|
|
57
|
+
const workloads = await collectInfraWorkloadsAsync(context, adapters.value.services);
|
|
58
|
+
if (!workloads.ok) return appendInfraFailure(diagnostics, workloads);
|
|
59
|
+
diagnostics.push(...workloads.diagnostics);
|
|
60
|
+
const compute = await adapters.value.compute.inspectAsync(
|
|
61
|
+
context,
|
|
62
|
+
environment.value.desired.deployment.compute,
|
|
63
|
+
);
|
|
64
|
+
if (!compute.ok) return appendInfraFailure(diagnostics, compute);
|
|
65
|
+
diagnostics.push(...compute.diagnostics);
|
|
66
|
+
const runtimeDesired = {
|
|
67
|
+
selection: environment.value.desired.deployment.runtime,
|
|
68
|
+
targets:
|
|
69
|
+
compute.value.targets.length > 0
|
|
70
|
+
? compute.value.targets
|
|
71
|
+
: (request.previous?.targets ?? compute.value.targets),
|
|
72
|
+
workloads: [...(environment.value.desired.workloads ?? []), ...workloads.value],
|
|
73
|
+
availableOutputs: mergeOutputs(request.previous?.outputs ?? [], compute.value.outputs),
|
|
74
|
+
};
|
|
75
|
+
if (runtimeDesired.targets.length === 0) {
|
|
76
|
+
diagnostics.push({
|
|
77
|
+
severity: 'info',
|
|
78
|
+
code: 'infra-runtime-target-deferred',
|
|
79
|
+
message: 'Runtime validation is deferred until compute exposes a portable target.',
|
|
80
|
+
});
|
|
81
|
+
} else {
|
|
82
|
+
const runtime = await adapters.value.runtime.validateAsync(context, runtimeDesired);
|
|
83
|
+
if (!runtime.ok) return appendInfraFailure(diagnostics, runtime);
|
|
84
|
+
diagnostics.push(...runtime.diagnostics);
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
ok: true,
|
|
88
|
+
value: {
|
|
89
|
+
environment: environment.value,
|
|
90
|
+
context,
|
|
91
|
+
adapters: adapters.value,
|
|
92
|
+
compute: compute.value,
|
|
93
|
+
runtimeDesired,
|
|
94
|
+
},
|
|
95
|
+
diagnostics,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/*** Compare provider identity only; configuration changes remain normal in-place reconciliation. */
|
|
100
|
+
function hasSameProviderSelection(
|
|
101
|
+
previous: PreparedInfraOperation['environment']['desired'],
|
|
102
|
+
current: PreparedInfraOperation['environment']['desired'],
|
|
103
|
+
): boolean {
|
|
104
|
+
return providerSelection(previous).join('\0') === providerSelection(current).join('\0');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/*** Read the closed provider slots in stable capability order. */
|
|
108
|
+
function providerSelection(
|
|
109
|
+
desired: PreparedInfraOperation['environment']['desired'],
|
|
110
|
+
): readonly (string | undefined)[] {
|
|
111
|
+
return [
|
|
112
|
+
desired.deployment.compute.provider,
|
|
113
|
+
desired.deployment.runtime.provider,
|
|
114
|
+
desired.database?.provider,
|
|
115
|
+
desired.objectStorage?.provider,
|
|
116
|
+
desired.auth?.provider,
|
|
117
|
+
desired.authz?.provider,
|
|
118
|
+
desired.secretStore?.provider,
|
|
119
|
+
];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/*** Prefer freshly inspected outputs while preserving unrelated safe prior values. */
|
|
123
|
+
function mergeOutputs(
|
|
124
|
+
previous: PreparedInfraOperation['runtimeDesired']['availableOutputs'],
|
|
125
|
+
current: PreparedInfraOperation['runtimeDesired']['availableOutputs'],
|
|
126
|
+
): PreparedInfraOperation['runtimeDesired']['availableOutputs'] {
|
|
127
|
+
const currentKeys = new Set(current.map(outputKey));
|
|
128
|
+
return [...previous.filter((output) => !currentKeys.has(outputKey(output))), ...current];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/*** Create one stable public-or-secret output identity without reading its value. */
|
|
132
|
+
function outputKey(
|
|
133
|
+
output: PreparedInfraOperation['runtimeDesired']['availableOutputs'][number],
|
|
134
|
+
): string {
|
|
135
|
+
const { owner } = output;
|
|
136
|
+
return `${owner.projectId}\0${owner.environment}\0${owner.adapter}\0${owner.resourceId}\0${output.name}`;
|
|
137
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import {
|
|
2
|
+
INFRA_ADAPTER_CATALOG,
|
|
3
|
+
type InfraAdapterDescriptor,
|
|
4
|
+
type InfraComputeAdapter,
|
|
5
|
+
type InfraDiagnostic,
|
|
6
|
+
type InfraEnvironmentSpec,
|
|
7
|
+
type InfraResult,
|
|
8
|
+
type InfraRuntimeAdapter,
|
|
9
|
+
type InfraServiceAdapter,
|
|
10
|
+
isInfraAdapterDescriptor,
|
|
11
|
+
validateInfraAdapterSelection,
|
|
12
|
+
} from '@ankhorage/contracts/infra';
|
|
13
|
+
|
|
14
|
+
import type { ResolvedInfraAdapters } from '../../../../types/infraOrchestration.js';
|
|
15
|
+
import type {
|
|
16
|
+
InfraAdapterPackageModule,
|
|
17
|
+
InfraAdapterPackageResolver,
|
|
18
|
+
} from '../ports/outbound/infraAdapterPackage.js';
|
|
19
|
+
|
|
20
|
+
/*** Resolve exactly the selected provider packages and validate their public adapter boundaries. */
|
|
21
|
+
export async function resolveInfraAdaptersAsync(
|
|
22
|
+
environment: InfraEnvironmentSpec,
|
|
23
|
+
resolver: InfraAdapterPackageResolver,
|
|
24
|
+
): Promise<InfraResult<ResolvedInfraAdapters>> {
|
|
25
|
+
const entries = getSelectedCatalogEntries(environment);
|
|
26
|
+
const modules = await Promise.all(
|
|
27
|
+
entries.map(async (entry) => loadModuleAsync(entry.package, resolver)),
|
|
28
|
+
);
|
|
29
|
+
const loadingDiagnostics = modules.flatMap((result) => result.diagnostics);
|
|
30
|
+
if (loadingDiagnostics.length > 0) return { ok: false, diagnostics: loadingDiagnostics };
|
|
31
|
+
const loaded = modules.flatMap((result) => (result.ok ? [result.value] : []));
|
|
32
|
+
const selection = validateInfraAdapterSelection(
|
|
33
|
+
environment,
|
|
34
|
+
loaded.map(({ infraAdapterDescriptor }) => infraAdapterDescriptor),
|
|
35
|
+
);
|
|
36
|
+
if (!selection.ok) return selection;
|
|
37
|
+
const instantiated = instantiateModules(loaded);
|
|
38
|
+
if (!instantiated.ok) return instantiated;
|
|
39
|
+
const instances = instantiated.value;
|
|
40
|
+
const compute = instances.find(isComputeAdapter);
|
|
41
|
+
const runtime = instances.find(isRuntimeAdapter);
|
|
42
|
+
const services = instances.filter(isServiceAdapter);
|
|
43
|
+
const diagnostics = validateInstances(compute, runtime, services, selection.value);
|
|
44
|
+
return diagnostics.length > 0 || compute === undefined || runtime === undefined
|
|
45
|
+
? { ok: false, diagnostics }
|
|
46
|
+
: {
|
|
47
|
+
ok: true,
|
|
48
|
+
value: { compute, runtime, services: orderServiceAdapters(services) },
|
|
49
|
+
diagnostics: [],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/*** Order services by selected capability dependencies while preserving catalog order for peers. */
|
|
54
|
+
function orderServiceAdapters(
|
|
55
|
+
services: readonly InfraServiceAdapter[],
|
|
56
|
+
): readonly InfraServiceAdapter[] {
|
|
57
|
+
const pending = [...services];
|
|
58
|
+
const ordered: InfraServiceAdapter[] = [];
|
|
59
|
+
const provided = new Set<string>(['compute', 'runtime', 'workloads', 'networking']);
|
|
60
|
+
while (pending.length > 0) {
|
|
61
|
+
const index = pending.findIndex((service) =>
|
|
62
|
+
service.descriptor.dependencies.every(
|
|
63
|
+
(dependency) =>
|
|
64
|
+
provided.has(dependency) ||
|
|
65
|
+
!services.some(({ descriptor }) => hasCapability(descriptor, dependency)),
|
|
66
|
+
),
|
|
67
|
+
);
|
|
68
|
+
if (index < 0) return services;
|
|
69
|
+
const [service] = pending.splice(index, 1);
|
|
70
|
+
if (service === undefined) return services;
|
|
71
|
+
ordered.push(service);
|
|
72
|
+
for (const capability of service.descriptor.capabilities) provided.add(capability);
|
|
73
|
+
}
|
|
74
|
+
return ordered;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/*** Compare catalog capability values across descriptor union members. */
|
|
78
|
+
function hasCapability(descriptor: InfraAdapterDescriptor, capability: string): boolean {
|
|
79
|
+
return (descriptor.capabilities as readonly string[]).includes(capability);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/*** Invoke selected factories safely and require their instances to match the module descriptor. */
|
|
83
|
+
function instantiateModules(
|
|
84
|
+
modules: readonly InfraAdapterPackageModule[],
|
|
85
|
+
): InfraResult<readonly unknown[]> {
|
|
86
|
+
const instances: unknown[] = [];
|
|
87
|
+
const diagnostics: InfraDiagnostic[] = [];
|
|
88
|
+
for (const module of modules) {
|
|
89
|
+
try {
|
|
90
|
+
const instance = module.createInfraAdapter();
|
|
91
|
+
if (!isAdapterForDescriptor(instance, module.infraAdapterDescriptor)) {
|
|
92
|
+
diagnostics.push(
|
|
93
|
+
instanceDiagnostic(
|
|
94
|
+
module.infraAdapterDescriptor.id,
|
|
95
|
+
`Selected adapter factory for ${module.infraAdapterDescriptor.package} returned a mismatched lifecycle implementation.`,
|
|
96
|
+
),
|
|
97
|
+
);
|
|
98
|
+
} else instances.push(instance);
|
|
99
|
+
} catch {
|
|
100
|
+
diagnostics.push(
|
|
101
|
+
instanceDiagnostic(
|
|
102
|
+
module.infraAdapterDescriptor.id,
|
|
103
|
+
`Selected adapter factory for ${module.infraAdapterDescriptor.package} could not be created.`,
|
|
104
|
+
),
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return diagnostics.length > 0
|
|
109
|
+
? { ok: false, diagnostics }
|
|
110
|
+
: { ok: true, value: instances, diagnostics: [] };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/*** Select each configured adapter once, including multi-capability service providers. */
|
|
114
|
+
function getSelectedCatalogEntries(environment: InfraEnvironmentSpec) {
|
|
115
|
+
const ids = new Set([
|
|
116
|
+
environment.deployment.compute.provider,
|
|
117
|
+
environment.deployment.runtime.provider,
|
|
118
|
+
environment.database?.provider,
|
|
119
|
+
environment.objectStorage?.provider,
|
|
120
|
+
environment.auth?.provider,
|
|
121
|
+
environment.authz?.provider,
|
|
122
|
+
environment.secretStore?.provider,
|
|
123
|
+
]);
|
|
124
|
+
return Object.values(INFRA_ADAPTER_CATALOG).filter((entry) => ids.has(entry.id));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/*** Convert module-resolution errors into provider-safe diagnostics without importing alternatives. */
|
|
128
|
+
async function loadModuleAsync(
|
|
129
|
+
packageName: string,
|
|
130
|
+
resolver: InfraAdapterPackageResolver,
|
|
131
|
+
): Promise<InfraResult<InfraAdapterPackageModule>> {
|
|
132
|
+
try {
|
|
133
|
+
const loaded: unknown = await resolver.loadAsync(packageName);
|
|
134
|
+
return isInfraAdapterPackageModule(loaded)
|
|
135
|
+
? { ok: true, value: loaded, diagnostics: [] }
|
|
136
|
+
: adapterFailure(
|
|
137
|
+
'infra-adapter-module-invalid',
|
|
138
|
+
`Selected adapter package ${packageName} does not export its canonical descriptor and factory.`,
|
|
139
|
+
);
|
|
140
|
+
} catch {
|
|
141
|
+
return adapterFailure(
|
|
142
|
+
'infra-adapter-package-unavailable',
|
|
143
|
+
`Selected adapter package ${packageName} could not be loaded.`,
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/*** Validate the runtime shape of a dynamically loaded provider package. */
|
|
149
|
+
function isInfraAdapterPackageModule(value: unknown): value is InfraAdapterPackageModule {
|
|
150
|
+
return (
|
|
151
|
+
isRecord(value) &&
|
|
152
|
+
isInfraAdapterDescriptor(value.infraAdapterDescriptor) &&
|
|
153
|
+
typeof value.createInfraAdapter === 'function'
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/*** Validate one compute adapter instance without trusting a dynamic module cast. */
|
|
158
|
+
function isComputeAdapter(value: unknown): value is InfraComputeAdapter {
|
|
159
|
+
return hasAdapterMethods(value, 'compute', [
|
|
160
|
+
'validateAsync',
|
|
161
|
+
'inspectAsync',
|
|
162
|
+
'planAsync',
|
|
163
|
+
'ensureAsync',
|
|
164
|
+
'statusAsync',
|
|
165
|
+
'destroyAsync',
|
|
166
|
+
]);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/*** Validate one runtime adapter instance without trusting a dynamic module cast. */
|
|
170
|
+
function isRuntimeAdapter(value: unknown): value is InfraRuntimeAdapter {
|
|
171
|
+
return hasAdapterMethods(value, 'runtime', [
|
|
172
|
+
'validateAsync',
|
|
173
|
+
'planAsync',
|
|
174
|
+
'ensureAsync',
|
|
175
|
+
'statusAsync',
|
|
176
|
+
'suspendAsync',
|
|
177
|
+
'destroyAsync',
|
|
178
|
+
]);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/*** Validate one service adapter instance without trusting a dynamic module cast. */
|
|
182
|
+
function isServiceAdapter(value: unknown): value is InfraServiceAdapter {
|
|
183
|
+
return hasAdapterMethods(value, 'service', [
|
|
184
|
+
'validateAsync',
|
|
185
|
+
'planAsync',
|
|
186
|
+
'desiredWorkloadsAsync',
|
|
187
|
+
'reconcileAsync',
|
|
188
|
+
'statusAsync',
|
|
189
|
+
'destroyAsync',
|
|
190
|
+
]);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/*** Match a factory result to the exact descriptor selected from its module. */
|
|
194
|
+
function isAdapterForDescriptor(value: unknown, expected: InfraAdapterDescriptor): boolean {
|
|
195
|
+
const validShape =
|
|
196
|
+
expected.kind === 'compute'
|
|
197
|
+
? isComputeAdapter(value)
|
|
198
|
+
: expected.kind === 'runtime'
|
|
199
|
+
? isRuntimeAdapter(value)
|
|
200
|
+
: isServiceAdapter(value);
|
|
201
|
+
return (
|
|
202
|
+
validShape &&
|
|
203
|
+
isRecord(value) &&
|
|
204
|
+
isInfraAdapterDescriptor(value.descriptor) &&
|
|
205
|
+
value.descriptor.id === expected.id &&
|
|
206
|
+
value.descriptor.package === expected.package
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/*** Check a dynamic adapter descriptor kind and its required lifecycle methods. */
|
|
211
|
+
function hasAdapterMethods(
|
|
212
|
+
value: unknown,
|
|
213
|
+
kind: InfraAdapterDescriptor['kind'],
|
|
214
|
+
methods: readonly string[],
|
|
215
|
+
): boolean {
|
|
216
|
+
return (
|
|
217
|
+
isRecord(value) &&
|
|
218
|
+
isInfraAdapterDescriptor(value.descriptor) &&
|
|
219
|
+
value.descriptor.kind === kind &&
|
|
220
|
+
methods.every((method) => typeof Reflect.get(value, method) === 'function')
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/*** Ensure factories returned exactly one matching compute/runtime adapter and every service. */
|
|
225
|
+
function validateInstances(
|
|
226
|
+
compute: InfraComputeAdapter | undefined,
|
|
227
|
+
runtime: InfraRuntimeAdapter | undefined,
|
|
228
|
+
services: readonly InfraServiceAdapter[],
|
|
229
|
+
descriptors: readonly InfraAdapterDescriptor[],
|
|
230
|
+
): readonly InfraDiagnostic[] {
|
|
231
|
+
const expectedServices = descriptors.filter(({ kind }) => kind === 'service').length;
|
|
232
|
+
const diagnostics: InfraDiagnostic[] = [];
|
|
233
|
+
if (compute === undefined)
|
|
234
|
+
diagnostics.push(instanceDiagnostic('compute', 'Selected compute adapter factory is invalid.'));
|
|
235
|
+
if (runtime === undefined)
|
|
236
|
+
diagnostics.push(instanceDiagnostic('runtime', 'Selected runtime adapter factory is invalid.'));
|
|
237
|
+
if (services.length !== expectedServices)
|
|
238
|
+
diagnostics.push(
|
|
239
|
+
instanceDiagnostic('service', 'A selected service adapter factory is invalid.'),
|
|
240
|
+
);
|
|
241
|
+
return diagnostics;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/*** Create an adapter-factory diagnostic without exposing module exception details. */
|
|
245
|
+
function instanceDiagnostic(kind: string, message: string): InfraDiagnostic {
|
|
246
|
+
return { severity: 'error', code: `infra-${kind}-adapter-invalid`, message };
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/*** Create a failed adapter resolution result. */
|
|
250
|
+
function adapterFailure(code: string, message: string): InfraResult<never> {
|
|
251
|
+
return { ok: false, diagnostics: [{ severity: 'error', code, message }] };
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/*** Narrow dynamically loaded module and adapter values. */
|
|
255
|
+
function isRecord(value: unknown): value is Readonly<Record<string, unknown>> {
|
|
256
|
+
return typeof value === 'object' && value !== null;
|
|
257
|
+
}
|