@ankhorage/infra 4.1.12 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +21 -32
- package/dist/cli/bin.d.ts +1 -8
- package/dist/cli/bin.d.ts.map +1 -1
- package/dist/cli/bin.js +2 -34
- package/dist/cli/bin.js.map +1 -1
- package/dist/cli/commands/destroy.d.ts +11 -0
- package/dist/cli/commands/destroy.d.ts.map +1 -0
- package/dist/cli/commands/destroy.js +51 -0
- package/dist/cli/commands/destroy.js.map +1 -0
- package/dist/cli/commands/down.d.ts +11 -0
- package/dist/cli/commands/down.d.ts.map +1 -0
- package/dist/cli/commands/down.js +27 -0
- package/dist/cli/commands/down.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +11 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +29 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/outputs.d.ts +11 -0
- package/dist/cli/commands/outputs.d.ts.map +1 -0
- package/dist/cli/commands/outputs.js +25 -0
- package/dist/cli/commands/outputs.js.map +1 -0
- package/dist/cli/commands/plan.d.ts +11 -0
- package/dist/cli/commands/plan.d.ts.map +1 -0
- package/dist/cli/commands/plan.js +19 -0
- package/dist/cli/commands/plan.js.map +1 -0
- package/dist/cli/commands/status.d.ts +11 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +19 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/up.d.ts +11 -0
- package/dist/cli/commands/up.d.ts.map +1 -0
- package/dist/cli/commands/up.js +28 -0
- package/dist/cli/commands/up.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +11 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +19 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/constants.d.ts +66 -0
- package/dist/cli/constants.d.ts.map +1 -0
- package/dist/cli/constants.js +19 -0
- package/dist/cli/constants.js.map +1 -0
- package/dist/cli/createDefaultInfraCommandContext.d.ts +4 -0
- package/dist/cli/createDefaultInfraCommandContext.d.ts.map +1 -0
- package/dist/{commandContext.js → cli/createDefaultInfraCommandContext.js} +4 -3
- package/dist/cli/createDefaultInfraCommandContext.js.map +1 -0
- package/dist/cli/createInfraRuntimeProvider.d.ts +5 -0
- package/dist/cli/createInfraRuntimeProvider.d.ts.map +1 -0
- package/dist/cli/createInfraRuntimeProvider.js +22 -0
- package/dist/cli/createInfraRuntimeProvider.js.map +1 -0
- package/dist/cli/createProviderCommandDescriptors.d.ts +4 -0
- package/dist/cli/createProviderCommandDescriptors.d.ts.map +1 -0
- package/dist/cli/createProviderCommandDescriptors.js +6 -0
- package/dist/cli/createProviderCommandDescriptors.js.map +1 -0
- package/dist/cli/findInfraCommand.d.ts +4 -0
- package/dist/cli/findInfraCommand.d.ts.map +1 -0
- package/dist/cli/findInfraCommand.js +6 -0
- package/dist/cli/findInfraCommand.js.map +1 -0
- package/dist/cli/index.d.ts +3 -8
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -24
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/renderInfraRootHelp.d.ts +3 -0
- package/dist/cli/renderInfraRootHelp.d.ts.map +1 -0
- package/dist/cli/renderInfraRootHelp.js +21 -0
- package/dist/cli/renderInfraRootHelp.js.map +1 -0
- package/dist/cli/renderUnknownInfraCommand.d.ts +3 -0
- package/dist/cli/renderUnknownInfraCommand.d.ts.map +1 -0
- package/dist/cli/renderUnknownInfraCommand.js +5 -0
- package/dist/cli/renderUnknownInfraCommand.js.map +1 -0
- package/dist/cli/runInfraCliAsync.d.ts +10 -0
- package/dist/cli/runInfraCliAsync.d.ts.map +1 -0
- package/dist/cli/runInfraCliAsync.js +34 -0
- package/dist/cli/runInfraCliAsync.js.map +1 -0
- package/dist/cli/runInfraCommandAsync.d.ts +4 -0
- package/dist/cli/runInfraCommandAsync.d.ts.map +1 -0
- package/dist/cli/runInfraCommandAsync.js +100 -0
- package/dist/cli/runInfraCommandAsync.js.map +1 -0
- package/dist/cli/utils/prepareInfraCommandOperationAsync.d.ts +4 -0
- package/dist/cli/utils/prepareInfraCommandOperationAsync.d.ts.map +1 -0
- package/dist/cli/utils/prepareInfraCommandOperationAsync.js +45 -0
- package/dist/cli/utils/prepareInfraCommandOperationAsync.js.map +1 -0
- package/dist/cli/utils/requireInfraSuccess.d.ts +7 -0
- package/dist/cli/utils/requireInfraSuccess.d.ts.map +1 -0
- package/dist/cli/utils/requireInfraSuccess.js +17 -0
- package/dist/cli/utils/requireInfraSuccess.js.map +1 -0
- package/dist/cli/utils/resolveInfraPersistence.d.ts +4 -0
- package/dist/cli/utils/resolveInfraPersistence.d.ts.map +1 -0
- package/dist/cli/utils/resolveInfraPersistence.js +17 -0
- package/dist/cli/utils/resolveInfraPersistence.js.map +1 -0
- package/dist/cli/utils/writeInfraEnvironmentOutputs.d.ts +5 -0
- package/dist/cli/utils/writeInfraEnvironmentOutputs.d.ts.map +1 -0
- package/dist/cli/utils/writeInfraEnvironmentOutputs.js +16 -0
- package/dist/cli/utils/writeInfraEnvironmentOutputs.js.map +1 -0
- package/dist/cli/utils/writeInfraStructured.d.ts +4 -0
- package/dist/cli/utils/writeInfraStructured.d.ts.map +1 -0
- package/dist/cli/utils/writeInfraStructured.js +8 -0
- package/dist/cli/utils/writeInfraStructured.js.map +1 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/{packageMetadata.js → constants.js} +6 -3
- package/dist/constants.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraCredentialPort.d.ts +4 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraCredentialPort.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraCredentialPort.js +35 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraCredentialPort.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraSecretPort.d.ts +4 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraSecretPort.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraSecretPort.js +23 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraSecretPort.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createNodeInfraAdapterPackageResolver.d.ts +4 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createNodeInfraAdapterPackageResolver.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createNodeInfraAdapterPackageResolver.js +9 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createNodeInfraAdapterPackageResolver.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/readStoredInfraStateAsync.d.ts +5 -0
- package/dist/features/environment-lifecycle/adapters/outbound/readStoredInfraStateAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/readStoredInfraStateAsync.js +28 -0
- package/dist/features/environment-lifecycle/adapters/outbound/readStoredInfraStateAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/removeStoredInfraStateAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/adapters/outbound/removeStoredInfraStateAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/removeStoredInfraStateAsync.js +7 -0
- package/dist/features/environment-lifecycle/adapters/outbound/removeStoredInfraStateAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/resolveInfraProjectAsync.d.ts +7 -0
- package/dist/features/environment-lifecycle/adapters/outbound/resolveInfraProjectAsync.d.ts.map +1 -0
- package/dist/{project.js → features/environment-lifecycle/adapters/outbound/resolveInfraProjectAsync.js} +10 -34
- package/dist/features/environment-lifecycle/adapters/outbound/resolveInfraProjectAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeInfraGeneratedArtifactsAsync.d.ts +5 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeInfraGeneratedArtifactsAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeInfraGeneratedArtifactsAsync.js +28 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeInfraGeneratedArtifactsAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeStoredInfraStateAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeStoredInfraStateAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeStoredInfraStateAsync.js +16 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeStoredInfraStateAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/ports/outbound/infraAdapterPackage.d.ts +9 -0
- package/dist/features/environment-lifecycle/application/ports/outbound/infraAdapterPackage.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/ports/outbound/infraAdapterPackage.js +2 -0
- package/dist/features/environment-lifecycle/application/ports/outbound/infraAdapterPackage.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/collectInfraWorkloadsAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/collectInfraWorkloadsAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/collectInfraWorkloadsAsync.js +15 -0
- package/dist/features/environment-lifecycle/application/use-cases/collectInfraWorkloadsAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/destroyInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/destroyInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/destroyInfraEnvironmentAsync.js +84 -0
- package/dist/features/environment-lifecycle/application/use-cases/destroyInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/downInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/downInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/downInfraEnvironmentAsync.js +55 -0
- package/dist/features/environment-lifecycle/application/use-cases/downInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/generateInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/generateInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/generateInfraEnvironmentAsync.js +38 -0
- package/dist/features/environment-lifecycle/application/use-cases/generateInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/getInfraEnvironmentOutputs.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/getInfraEnvironmentOutputs.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/getInfraEnvironmentOutputs.js +34 -0
- package/dist/features/environment-lifecycle/application/use-cases/getInfraEnvironmentOutputs.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/planInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/planInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/planInfraEnvironmentAsync.js +57 -0
- package/dist/features/environment-lifecycle/application/use-cases/planInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/prepareInfraOperationAsync.d.ts +5 -0
- package/dist/features/environment-lifecycle/application/use-cases/prepareInfraOperationAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/prepareInfraOperationAsync.js +109 -0
- package/dist/features/environment-lifecycle/application/use-cases/prepareInfraOperationAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/resolveInfraAdaptersAsync.d.ts +6 -0
- package/dist/features/environment-lifecycle/application/use-cases/resolveInfraAdaptersAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/resolveInfraAdaptersAsync.js +181 -0
- package/dist/features/environment-lifecycle/application/use-cases/resolveInfraAdaptersAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/statusInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/statusInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/statusInfraEnvironmentAsync.js +68 -0
- package/dist/features/environment-lifecycle/application/use-cases/statusInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/upInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/upInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/upInfraEnvironmentAsync.js +98 -0
- package/dist/features/environment-lifecycle/application/use-cases/upInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraAdaptersAsync.d.ts +5 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraAdaptersAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraAdaptersAsync.js +17 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraAdaptersAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraEnvironmentAsync.js +13 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/composition/createInfraCommandServices.d.ts +4 -0
- package/dist/features/environment-lifecycle/composition/createInfraCommandServices.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/composition/createInfraCommandServices.js +43 -0
- package/dist/features/environment-lifecycle/composition/createInfraCommandServices.js.map +1 -0
- package/dist/features/environment-lifecycle/domain/orderInfraPlanActions.d.ts +4 -0
- package/dist/features/environment-lifecycle/domain/orderInfraPlanActions.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/domain/orderInfraPlanActions.js +54 -0
- package/dist/features/environment-lifecycle/domain/orderInfraPlanActions.js.map +1 -0
- package/dist/features/environment-lifecycle/domain/resolveInfraEnvironment.d.ts +5 -0
- package/dist/features/environment-lifecycle/domain/resolveInfraEnvironment.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/domain/resolveInfraEnvironment.js +39 -0
- package/dist/features/environment-lifecycle/domain/resolveInfraEnvironment.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/appendInfraFailure.d.ts +7 -0
- package/dist/features/environment-lifecycle/utils/appendInfraFailure.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/appendInfraFailure.js +5 -0
- package/dist/features/environment-lifecycle/utils/appendInfraFailure.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/createInfraExecutionContext.d.ts +5 -0
- package/dist/features/environment-lifecycle/utils/createInfraExecutionContext.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/createInfraExecutionContext.js +13 -0
- package/dist/features/environment-lifecycle/utils/createInfraExecutionContext.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/createInfraFailure.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/createInfraFailure.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/createInfraFailure.js +5 -0
- package/dist/features/environment-lifecycle/utils/createInfraFailure.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/createInfraLedger.d.ts +12 -0
- package/dist/features/environment-lifecycle/utils/createInfraLedger.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/createInfraLedger.js +14 -0
- package/dist/features/environment-lifecycle/utils/createInfraLedger.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/infraIdentityKey.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/infraIdentityKey.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/infraIdentityKey.js +5 -0
- package/dist/features/environment-lifecycle/utils/infraIdentityKey.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/isInfraStoredState.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/isInfraStoredState.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/isInfraStoredState.js +103 -0
- package/dist/features/environment-lifecycle/utils/isInfraStoredState.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraOutputs.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraOutputs.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraOutputs.js +10 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraOutputs.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraResources.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraResources.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraResources.js +10 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraResources.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/normalizeInfraEnvironmentKey.d.ts +3 -0
- package/dist/features/environment-lifecycle/utils/normalizeInfraEnvironmentKey.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/normalizeInfraEnvironmentKey.js +8 -0
- package/dist/features/environment-lifecycle/utils/normalizeInfraEnvironmentKey.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/resolveInfraStatePath.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/resolveInfraStatePath.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/resolveInfraStatePath.js +11 -0
- package/dist/features/environment-lifecycle/utils/resolveInfraStatePath.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/resolveProjectFile.d.ts +3 -0
- package/dist/features/environment-lifecycle/utils/resolveProjectFile.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/resolveProjectFile.js +19 -0
- package/dist/features/environment-lifecycle/utils/resolveProjectFile.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterOutputs.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterOutputs.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterOutputs.js +6 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterOutputs.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterResources.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterResources.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterResources.js +6 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterResources.js.map +1 -0
- package/dist/index.d.ts +16 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -15
- package/dist/index.js.map +1 -1
- package/dist/metadata/index.d.ts +1 -1
- package/dist/metadata/index.d.ts.map +1 -1
- package/dist/metadata/index.js +1 -1
- package/dist/metadata/index.js.map +1 -1
- package/dist/project/index.d.ts +7 -5
- package/dist/project/index.d.ts.map +1 -1
- package/dist/project/index.js +6 -5
- package/dist/project/index.js.map +1 -1
- package/dist/readme-usage.js +17 -26
- package/dist/readme-usage.js.map +1 -1
- package/dist/testSupport.d.ts +1 -1
- package/dist/testSupport.d.ts.map +1 -1
- package/dist/testSupport.js +11 -1
- package/dist/testSupport.js.map +1 -1
- package/dist/types/infraCli.d.ts +91 -0
- package/dist/types/infraCli.d.ts.map +1 -0
- package/dist/types/infraCli.js +2 -0
- package/dist/types/infraCli.js.map +1 -0
- package/dist/types/infraOrchestration.d.ts +84 -0
- package/dist/types/infraOrchestration.d.ts.map +1 -0
- package/dist/types/infraOrchestration.js +2 -0
- package/dist/types/infraOrchestration.js.map +1 -0
- package/dist/{project.d.ts → types/infraProject.d.ts} +6 -6
- package/dist/types/infraProject.d.ts.map +1 -0
- package/dist/types/infraProject.js +2 -0
- package/dist/types/infraProject.js.map +1 -0
- package/package.json +20 -10
- package/src/adapterPackages.integration.test.ts +79 -0
- package/src/cli/bin.ts +2 -61
- package/src/cli/cli.test.ts +35 -126
- package/src/cli/commands/destroy.ts +57 -0
- package/src/cli/commands/down.ts +28 -0
- package/src/cli/commands/generate.ts +34 -0
- package/src/cli/commands/outputs.ts +25 -0
- package/src/cli/commands/plan.ts +20 -0
- package/src/cli/commands/status.ts +20 -0
- package/src/cli/commands/up.ts +29 -0
- package/src/cli/commands/validate.ts +20 -0
- package/src/cli/constants.ts +19 -0
- package/src/cli/createDefaultInfraCommandContext.ts +17 -0
- package/src/cli/createInfraRuntimeProvider.ts +35 -0
- package/src/cli/createProviderCommandDescriptors.ts +8 -0
- package/src/cli/findInfraCommand.ts +7 -0
- package/src/cli/index.test.ts +12 -20
- package/src/cli/index.ts +7 -49
- package/src/cli/renderInfraRootHelp.ts +23 -0
- package/src/cli/renderUnknownInfraCommand.ts +4 -0
- package/src/cli/runInfraCliAsync.ts +51 -0
- package/src/cli/runInfraCommandAsync.ts +114 -0
- package/src/cli/utils/prepareInfraCommandOperationAsync.ts +64 -0
- package/src/cli/utils/requireInfraSuccess.ts +24 -0
- package/src/cli/utils/resolveInfraPersistence.ts +22 -0
- package/src/cli/utils/writeInfraEnvironmentOutputs.ts +24 -0
- package/src/cli/utils/writeInfraStructured.ts +11 -0
- package/src/commands.test.ts +198 -196
- package/src/{packageMetadata.ts → constants.ts} +5 -2
- package/src/environmentLifecycle.test.ts +193 -0
- package/src/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraCredentialPort.ts +52 -0
- package/src/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraSecretPort.ts +32 -0
- package/src/features/environment-lifecycle/adapters/outbound/createNodeInfraAdapterPackageResolver.ts +10 -0
- package/src/features/environment-lifecycle/adapters/outbound/readStoredInfraStateAsync.ts +34 -0
- package/src/features/environment-lifecycle/adapters/outbound/removeStoredInfraStateAsync.ts +12 -0
- package/src/{project.ts → features/environment-lifecycle/adapters/outbound/resolveInfraProjectAsync.ts} +10 -45
- package/src/features/environment-lifecycle/adapters/outbound/writeInfraGeneratedArtifactsAsync.ts +34 -0
- package/src/features/environment-lifecycle/adapters/outbound/writeStoredInfraStateAsync.ts +21 -0
- package/src/features/environment-lifecycle/application/ports/outbound/infraAdapterPackage.ts +10 -0
- package/src/features/environment-lifecycle/application/use-cases/collectInfraWorkloadsAsync.ts +25 -0
- package/src/features/environment-lifecycle/application/use-cases/destroyInfraEnvironmentAsync.ts +119 -0
- package/src/features/environment-lifecycle/application/use-cases/downInfraEnvironmentAsync.ts +65 -0
- package/src/features/environment-lifecycle/application/use-cases/generateInfraEnvironmentAsync.ts +51 -0
- package/src/features/environment-lifecycle/application/use-cases/getInfraEnvironmentOutputs.ts +41 -0
- package/src/features/environment-lifecycle/application/use-cases/planInfraEnvironmentAsync.ts +67 -0
- package/src/features/environment-lifecycle/application/use-cases/prepareInfraOperationAsync.ts +137 -0
- package/src/features/environment-lifecycle/application/use-cases/resolveInfraAdaptersAsync.ts +257 -0
- package/src/features/environment-lifecycle/application/use-cases/statusInfraEnvironmentAsync.ts +80 -0
- package/src/features/environment-lifecycle/application/use-cases/upInfraEnvironmentAsync.ts +126 -0
- package/src/features/environment-lifecycle/application/use-cases/validateInfraAdaptersAsync.ts +25 -0
- package/src/features/environment-lifecycle/application/use-cases/validateInfraEnvironmentAsync.ts +21 -0
- package/src/features/environment-lifecycle/composition/createInfraCommandServices.ts +47 -0
- package/src/features/environment-lifecycle/domain/orderInfraPlanActions.ts +64 -0
- package/src/features/environment-lifecycle/domain/resolveInfraEnvironment.ts +62 -0
- package/src/features/environment-lifecycle/utils/appendInfraFailure.ts +9 -0
- package/src/features/environment-lifecycle/utils/createInfraExecutionContext.ts +24 -0
- package/src/features/environment-lifecycle/utils/createInfraFailure.ts +6 -0
- package/src/features/environment-lifecycle/utils/createInfraLedger.ts +30 -0
- package/src/features/environment-lifecycle/utils/infraIdentityKey.ts +6 -0
- package/src/features/environment-lifecycle/utils/isInfraStoredState.ts +141 -0
- package/src/features/environment-lifecycle/utils/mergeInfraOutputs.ts +14 -0
- package/src/features/environment-lifecycle/utils/mergeInfraResources.ts +14 -0
- package/src/features/environment-lifecycle/utils/normalizeInfraEnvironmentKey.ts +7 -0
- package/src/features/environment-lifecycle/utils/resolveInfraStatePath.ts +12 -0
- package/src/features/environment-lifecycle/utils/resolveProjectFile.ts +22 -0
- package/src/features/environment-lifecycle/utils/retainUnchangedAdapterOutputs.ts +15 -0
- package/src/features/environment-lifecycle/utils/retainUnchangedAdapterResources.ts +15 -0
- package/src/index.test.ts +22 -315
- package/src/index.ts +41 -53
- package/src/infraComposition.integration.test.ts +128 -0
- package/src/infraOperations.test.ts +386 -0
- package/src/infraUp.test.ts +260 -0
- package/src/metadata/index.ts +1 -1
- package/src/package.test.ts +4 -2
- package/src/project/index.test.ts +8 -188
- package/src/project/index.ts +7 -22
- package/src/project.test.ts +39 -189
- package/src/projectContractsParser.test.ts +2 -2
- package/src/projectInfrastructure.test.ts +121 -167
- package/src/readme-usage.ts +17 -26
- package/src/testSupport.ts +12 -2
- package/src/types/infraCli.ts +115 -0
- package/src/types/infraOrchestration.ts +126 -0
- package/src/types/infraProject.ts +15 -0
- package/dist/adapters/minikube/auth/index.d.ts +0 -8
- package/dist/adapters/minikube/auth/index.d.ts.map +0 -1
- package/dist/adapters/minikube/auth/index.js +0 -29
- package/dist/adapters/minikube/auth/index.js.map +0 -1
- package/dist/adapters/minikube/auth/oauthRuntime.d.ts +0 -4
- package/dist/adapters/minikube/auth/oauthRuntime.d.ts.map +0 -1
- package/dist/adapters/minikube/auth/oauthRuntime.js +0 -138
- package/dist/adapters/minikube/auth/oauthRuntime.js.map +0 -1
- package/dist/adapters/minikube/auth/supabase/index.d.ts +0 -7
- package/dist/adapters/minikube/auth/supabase/index.d.ts.map +0 -1
- package/dist/adapters/minikube/auth/supabase/index.js +0 -232
- package/dist/adapters/minikube/auth/supabase/index.js.map +0 -1
- package/dist/adapters/minikube/auth/supabase/profile.d.ts +0 -20
- package/dist/adapters/minikube/auth/supabase/profile.d.ts.map +0 -1
- package/dist/adapters/minikube/auth/supabase/profile.js +0 -452
- package/dist/adapters/minikube/auth/supabase/profile.js.map +0 -1
- package/dist/adapters/minikube/auth/targetAwareOAuthRuntime.d.ts +0 -7
- package/dist/adapters/minikube/auth/targetAwareOAuthRuntime.d.ts.map +0 -1
- package/dist/adapters/minikube/auth/targetAwareOAuthRuntime.js +0 -104
- package/dist/adapters/minikube/auth/targetAwareOAuthRuntime.js.map +0 -1
- package/dist/adapters/minikube/authz/cerbos/index.d.ts +0 -13
- package/dist/adapters/minikube/authz/cerbos/index.d.ts.map +0 -1
- package/dist/adapters/minikube/authz/cerbos/index.js +0 -382
- package/dist/adapters/minikube/authz/cerbos/index.js.map +0 -1
- package/dist/adapters/minikube/authz/index.d.ts +0 -9
- package/dist/adapters/minikube/authz/index.d.ts.map +0 -1
- package/dist/adapters/minikube/authz/index.js +0 -23
- package/dist/adapters/minikube/authz/index.js.map +0 -1
- package/dist/adapters/minikube/base/index.d.ts +0 -14
- package/dist/adapters/minikube/base/index.d.ts.map +0 -1
- package/dist/adapters/minikube/base/index.js +0 -3433
- package/dist/adapters/minikube/base/index.js.map +0 -1
- package/dist/adapters/minikube/base/supabaseMigrations.d.ts +0 -2
- package/dist/adapters/minikube/base/supabaseMigrations.d.ts.map +0 -1
- package/dist/adapters/minikube/base/supabaseMigrations.js +0 -6
- package/dist/adapters/minikube/base/supabaseMigrations.js.map +0 -1
- package/dist/adapters/minikube/contracts.d.ts +0 -34
- package/dist/adapters/minikube/contracts.d.ts.map +0 -1
- package/dist/adapters/minikube/contracts.js +0 -10
- package/dist/adapters/minikube/contracts.js.map +0 -1
- package/dist/adapters/minikube/index.d.ts +0 -3
- package/dist/adapters/minikube/index.d.ts.map +0 -1
- package/dist/adapters/minikube/index.js +0 -136
- package/dist/adapters/minikube/index.js.map +0 -1
- package/dist/adapters/minikube/secrets/index.d.ts +0 -7
- package/dist/adapters/minikube/secrets/index.d.ts.map +0 -1
- package/dist/adapters/minikube/secrets/index.js +0 -13
- package/dist/adapters/minikube/secrets/index.js.map +0 -1
- package/dist/adapters/minikube/secrets/supabase-vault/index.d.ts +0 -8
- package/dist/adapters/minikube/secrets/supabase-vault/index.d.ts.map +0 -1
- package/dist/adapters/minikube/secrets/supabase-vault/index.js +0 -118
- package/dist/adapters/minikube/secrets/supabase-vault/index.js.map +0 -1
- package/dist/adapters/minikube/storage/index.d.ts +0 -7
- package/dist/adapters/minikube/storage/index.d.ts.map +0 -1
- package/dist/adapters/minikube/storage/index.js +0 -77
- package/dist/adapters/minikube/storage/index.js.map +0 -1
- package/dist/adapters/minikube/storage/supabase/index.d.ts +0 -7
- package/dist/adapters/minikube/storage/supabase/index.d.ts.map +0 -1
- package/dist/adapters/minikube/storage/supabase/index.js +0 -82
- package/dist/adapters/minikube/storage/supabase/index.js.map +0 -1
- package/dist/authRedirects.d.ts +0 -19
- package/dist/authRedirects.d.ts.map +0 -1
- package/dist/authRedirects.js +0 -80
- package/dist/authRedirects.js.map +0 -1
- package/dist/authTargetRedirects.d.ts +0 -12
- package/dist/authTargetRedirects.d.ts.map +0 -1
- package/dist/authTargetRedirects.js +0 -32
- package/dist/authTargetRedirects.js.map +0 -1
- package/dist/commandContext.d.ts +0 -12
- package/dist/commandContext.d.ts.map +0 -1
- package/dist/commandContext.js.map +0 -1
- package/dist/commands.d.ts +0 -95
- package/dist/commands.d.ts.map +0 -1
- package/dist/commands.js +0 -256
- package/dist/commands.js.map +0 -1
- package/dist/infraValidation.d.ts +0 -4
- package/dist/infraValidation.d.ts.map +0 -1
- package/dist/infraValidation.js +0 -63
- package/dist/infraValidation.js.map +0 -1
- package/dist/packageMetadata.d.ts +0 -10
- package/dist/packageMetadata.d.ts.map +0 -1
- package/dist/packageMetadata.js.map +0 -1
- package/dist/project.d.ts.map +0 -1
- package/dist/project.js.map +0 -1
- package/dist/projectDatabase.d.ts +0 -5
- package/dist/projectDatabase.d.ts.map +0 -1
- package/dist/projectDatabase.js +0 -22
- package/dist/projectDatabase.js.map +0 -1
- package/dist/projectEnvironment.d.ts +0 -6
- package/dist/projectEnvironment.d.ts.map +0 -1
- package/dist/projectEnvironment.js +0 -45
- package/dist/projectEnvironment.js.map +0 -1
- package/dist/projectInfrastructure.d.ts +0 -38
- package/dist/projectInfrastructure.d.ts.map +0 -1
- package/dist/projectInfrastructure.js +0 -145
- package/dist/projectInfrastructure.js.map +0 -1
- package/dist/runtime.d.ts +0 -54
- package/dist/runtime.d.ts.map +0 -1
- package/dist/runtime.js +0 -151
- package/dist/runtime.js.map +0 -1
- package/dist/secretStore.d.ts +0 -19
- package/dist/secretStore.d.ts.map +0 -1
- package/dist/secretStore.js +0 -22
- package/dist/secretStore.js.map +0 -1
- package/dist/types.d.ts +0 -70
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/src/adapters/minikube/README.md +0 -115
- package/src/adapters/minikube/appRuntimeServing.test.ts +0 -28
- package/src/adapters/minikube/auth/index.ts +0 -40
- package/src/adapters/minikube/auth/oauthRuntime.ts +0 -163
- package/src/adapters/minikube/auth/supabase/index.test.ts +0 -227
- package/src/adapters/minikube/auth/supabase/index.ts +0 -293
- package/src/adapters/minikube/auth/supabase/oauthRuntime.test.ts +0 -154
- package/src/adapters/minikube/auth/supabase/profile.integration.test.ts +0 -1028
- package/src/adapters/minikube/auth/supabase/profile.ts +0 -526
- package/src/adapters/minikube/auth/supabase/providerAssignments.test.ts +0 -36
- package/src/adapters/minikube/auth/targetAwareOAuthRuntime.test.ts +0 -83
- package/src/adapters/minikube/auth/targetAwareOAuthRuntime.ts +0 -136
- package/src/adapters/minikube/authz/cerbos/index.ts +0 -486
- package/src/adapters/minikube/authz/index.ts +0 -32
- package/src/adapters/minikube/base/appImageBuild.test.ts +0 -352
- package/src/adapters/minikube/base/index.test.ts +0 -693
- package/src/adapters/minikube/base/index.ts +0 -3763
- package/src/adapters/minikube/base/portForwardRuntime.test.ts +0 -624
- package/src/adapters/minikube/base/supabaseMigrations.test.ts +0 -168
- package/src/adapters/minikube/base/supabaseMigrations.ts +0 -5
- package/src/adapters/minikube/base/twoAppIsolation.integration.test.ts +0 -898
- package/src/adapters/minikube/base/upgradeReconciliation.test.ts +0 -135
- package/src/adapters/minikube/contracts.ts +0 -46
- package/src/adapters/minikube/index.ts +0 -172
- package/src/adapters/minikube/secrets/index.test.ts +0 -147
- package/src/adapters/minikube/secrets/index.ts +0 -19
- package/src/adapters/minikube/secrets/supabase-vault/index.ts +0 -139
- package/src/adapters/minikube/storage/index.ts +0 -91
- package/src/adapters/minikube/storage/supabase/index.ts +0 -108
- package/src/apiInfrastructure.test.ts +0 -69
- package/src/authRedirects.test.ts +0 -63
- package/src/authRedirects.ts +0 -113
- package/src/authTargetRedirects.test.ts +0 -62
- package/src/authTargetRedirects.ts +0 -46
- package/src/commandContext.ts +0 -27
- package/src/commands.ts +0 -404
- package/src/generatedApiLedgerCleanup.test.ts +0 -72
- package/src/infraApiValidation.test.ts +0 -42
- package/src/infraValidation.ts +0 -99
- package/src/minikubeImageLifecycle.test.ts +0 -35
- package/src/projectDatabase.ts +0 -27
- package/src/projectEnvironment.ts +0 -51
- package/src/projectInfrastructure.ts +0 -221
- package/src/runtime.test.ts +0 -124
- package/src/runtime.ts +0 -234
- package/src/secretStore.test.ts +0 -76
- package/src/secretStore.ts +0 -44
- package/src/types.ts +0 -82
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InfraAdapterDescriptor,
|
|
3
|
+
InfraComputeAdapter,
|
|
4
|
+
InfraEnvironmentSpec,
|
|
5
|
+
InfraOwnedResource,
|
|
6
|
+
InfraPlanAction,
|
|
7
|
+
InfraResourceIdentity,
|
|
8
|
+
InfraResourceStatus,
|
|
9
|
+
InfraResult,
|
|
10
|
+
InfraRuntimeAdapter,
|
|
11
|
+
InfraServiceAdapter,
|
|
12
|
+
InfraWorkloadSpec,
|
|
13
|
+
} from '@ankhorage/contracts/infra';
|
|
14
|
+
import { INFRA_ADAPTER_CATALOG } from '@ankhorage/contracts/infra';
|
|
15
|
+
import { describe, expect, it } from 'bun:test';
|
|
16
|
+
|
|
17
|
+
import type { InfraAdapterPackageResolver } from './features/environment-lifecycle/application/ports/outbound/infraAdapterPackage';
|
|
18
|
+
import { destroyInfraEnvironmentAsync } from './features/environment-lifecycle/application/use-cases/destroyInfraEnvironmentAsync';
|
|
19
|
+
import { downInfraEnvironmentAsync } from './features/environment-lifecycle/application/use-cases/downInfraEnvironmentAsync';
|
|
20
|
+
import { generateInfraEnvironmentAsync } from './features/environment-lifecycle/application/use-cases/generateInfraEnvironmentAsync';
|
|
21
|
+
import { getInfraEnvironmentOutputs } from './features/environment-lifecycle/application/use-cases/getInfraEnvironmentOutputs';
|
|
22
|
+
import { planInfraEnvironmentAsync } from './features/environment-lifecycle/application/use-cases/planInfraEnvironmentAsync';
|
|
23
|
+
import { statusInfraEnvironmentAsync } from './features/environment-lifecycle/application/use-cases/statusInfraEnvironmentAsync';
|
|
24
|
+
import { validateInfraEnvironmentAsync } from './features/environment-lifecycle/application/use-cases/validateInfraEnvironmentAsync';
|
|
25
|
+
import type { InfraOrchestrationDependencies } from './types/infraOrchestration';
|
|
26
|
+
|
|
27
|
+
const desired = {
|
|
28
|
+
deployment: { compute: { provider: 'local' }, runtime: { provider: 'docker-compose' } },
|
|
29
|
+
database: { provider: 'supabase' },
|
|
30
|
+
secretStore: { provider: 'supabase-vault' },
|
|
31
|
+
} as const satisfies InfraEnvironmentSpec;
|
|
32
|
+
const manifest = { environments: { local: desired }, modules: [] } as const;
|
|
33
|
+
const computeOwner = owner('local', 'host');
|
|
34
|
+
const runtimeOwner = owner('docker-compose', 'runtime');
|
|
35
|
+
const databaseOwner = owner('supabase', 'database');
|
|
36
|
+
const vaultOwner = owner('supabase-vault', 'vault');
|
|
37
|
+
|
|
38
|
+
describe('provider-neutral lifecycle operations', () => {
|
|
39
|
+
it('validates and plans without calling a mutating adapter method', async () => {
|
|
40
|
+
const calls: string[] = [];
|
|
41
|
+
const dependencies = createDependencies(calls);
|
|
42
|
+
const validation = await validateInfraEnvironmentAsync(
|
|
43
|
+
{ projectId: 'sample', manifest },
|
|
44
|
+
dependencies,
|
|
45
|
+
);
|
|
46
|
+
const plan = await planInfraEnvironmentAsync({ projectId: 'sample', manifest }, dependencies);
|
|
47
|
+
|
|
48
|
+
expect(validation).toMatchObject({ ok: true, value: { environment: 'local' } });
|
|
49
|
+
expect(plan.ok).toBe(true);
|
|
50
|
+
if (!plan.ok) throw new Error('Expected plan.');
|
|
51
|
+
expect(plan.value.actions.map(({ owner: actionOwner }) => actionOwner.resourceId)).toEqual([
|
|
52
|
+
'host',
|
|
53
|
+
'runtime',
|
|
54
|
+
'database',
|
|
55
|
+
'vault',
|
|
56
|
+
]);
|
|
57
|
+
expect(calls).toContain('local.inspect');
|
|
58
|
+
expect(calls.some((call) => call.endsWith('.ensure'))).toBe(false);
|
|
59
|
+
expect(calls.some((call) => call.endsWith('.reconcile'))).toBe(false);
|
|
60
|
+
expect(calls.some((call) => call.endsWith('.destroy'))).toBe(false);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('plans fresh remote compute and a deferred runtime without inventing an SSH target', async () => {
|
|
64
|
+
const calls: string[] = [];
|
|
65
|
+
const remoteManifest = {
|
|
66
|
+
environments: {
|
|
67
|
+
local: desired,
|
|
68
|
+
production: {
|
|
69
|
+
deployment: {
|
|
70
|
+
compute: { provider: 'hetzner', location: 'nbg1' },
|
|
71
|
+
runtime: { provider: 'k3s', topology: { servers: 1, agents: 0 } },
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
modules: [],
|
|
76
|
+
} as const;
|
|
77
|
+
const result = await planInfraEnvironmentAsync(
|
|
78
|
+
{ projectId: 'sample', manifest: remoteManifest, environment: 'production' },
|
|
79
|
+
createDependencies(calls),
|
|
80
|
+
);
|
|
81
|
+
expect(result.ok).toBe(true);
|
|
82
|
+
if (!result.ok) throw new Error('Expected remote plan.');
|
|
83
|
+
expect(result.value.actions.map(({ owner: actionOwner }) => actionOwner.adapter)).toEqual([
|
|
84
|
+
'hetzner',
|
|
85
|
+
'k3s',
|
|
86
|
+
]);
|
|
87
|
+
expect(result.value.actions[1]?.detail).toContain('deferred');
|
|
88
|
+
expect(calls).not.toContain('k3s.validate');
|
|
89
|
+
expect(calls).not.toContain('k3s.plan');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('generates review artifacts without reconciliation and preserves safe state', async () => {
|
|
93
|
+
const calls: string[] = [];
|
|
94
|
+
const result = await generateInfraEnvironmentAsync(
|
|
95
|
+
{ projectId: 'sample', manifest, previous: ledger() },
|
|
96
|
+
createDependencies(calls),
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
expect(result.ok).toBe(true);
|
|
100
|
+
if (!result.ok) throw new Error('Expected generation.');
|
|
101
|
+
expect(result.value.artifacts).toEqual([
|
|
102
|
+
{ owner: runtimeOwner, path: 'infra/compose.yaml', content: 'services: {}\n' },
|
|
103
|
+
]);
|
|
104
|
+
expect(result.value.ledger.outputs).toEqual(ledger().outputs);
|
|
105
|
+
expect(calls).toContain('docker-compose.generate');
|
|
106
|
+
expect(calls.some((call) => call.endsWith('.ensure'))).toBe(false);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('aggregates canonical status and returns only serialized ledger outputs', async () => {
|
|
110
|
+
const calls: string[] = [];
|
|
111
|
+
const status = await statusInfraEnvironmentAsync(
|
|
112
|
+
{ projectId: 'sample', manifest, previous: ledger() },
|
|
113
|
+
createDependencies(calls),
|
|
114
|
+
);
|
|
115
|
+
const outputs = getInfraEnvironmentOutputs({
|
|
116
|
+
projectId: 'sample',
|
|
117
|
+
manifest,
|
|
118
|
+
previous: ledger(),
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
expect(status).toMatchObject({ ok: true, value: { state: 'degraded' } });
|
|
122
|
+
expect(outputs).toMatchObject({
|
|
123
|
+
ok: true,
|
|
124
|
+
value: {
|
|
125
|
+
outputs: [
|
|
126
|
+
{ visibility: 'public', value: 'https://example.test' },
|
|
127
|
+
{ visibility: 'secret', reference: { source: 'secret-store' } },
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
expect(JSON.stringify(outputs)).not.toContain('resolved-secret');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('suspends optional services in reverse dependency order before runtime', async () => {
|
|
135
|
+
const calls: string[] = [];
|
|
136
|
+
const result = await downInfraEnvironmentAsync(
|
|
137
|
+
{ projectId: 'sample', manifest, previous: ledger() },
|
|
138
|
+
createDependencies(calls),
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
expect(result.ok).toBe(true);
|
|
142
|
+
expect(calls.filter((call) => call.endsWith('.suspend'))).toEqual([
|
|
143
|
+
'supabase-vault.suspend',
|
|
144
|
+
'supabase.suspend',
|
|
145
|
+
'docker-compose.suspend',
|
|
146
|
+
]);
|
|
147
|
+
if (!result.ok) throw new Error('Expected down.');
|
|
148
|
+
expect(result.value.ledger.resources).toHaveLength(4);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('refuses mismatched destroy confirmation and destroys in reverse dependency order', async () => {
|
|
152
|
+
const rejectedCalls: string[] = [];
|
|
153
|
+
const rejected = await destroyInfraEnvironmentAsync(
|
|
154
|
+
{
|
|
155
|
+
projectId: 'sample',
|
|
156
|
+
manifest,
|
|
157
|
+
environment: 'local',
|
|
158
|
+
previous: ledger(),
|
|
159
|
+
confirmation: { projectId: 'other', environment: 'local' },
|
|
160
|
+
persistence: { policy: 'retain' },
|
|
161
|
+
},
|
|
162
|
+
createDependencies(rejectedCalls),
|
|
163
|
+
);
|
|
164
|
+
expect(rejected).toMatchObject({
|
|
165
|
+
ok: false,
|
|
166
|
+
diagnostics: [{ code: 'infra-destroy-confirmation-mismatch' }],
|
|
167
|
+
});
|
|
168
|
+
expect(rejectedCalls.some((call) => call.endsWith('.destroy'))).toBe(false);
|
|
169
|
+
|
|
170
|
+
const calls: string[] = [];
|
|
171
|
+
const result = await destroyInfraEnvironmentAsync(
|
|
172
|
+
{
|
|
173
|
+
projectId: 'sample',
|
|
174
|
+
manifest,
|
|
175
|
+
environment: 'local',
|
|
176
|
+
previous: ledger(),
|
|
177
|
+
confirmation: { projectId: 'sample', environment: 'local' },
|
|
178
|
+
persistence: { policy: 'retain' },
|
|
179
|
+
},
|
|
180
|
+
createDependencies(calls),
|
|
181
|
+
);
|
|
182
|
+
expect(result.ok).toBe(true);
|
|
183
|
+
expect(calls.filter((call) => call.endsWith('.destroy'))).toEqual([
|
|
184
|
+
'supabase-vault.destroy',
|
|
185
|
+
'supabase.destroy',
|
|
186
|
+
'docker-compose.destroy',
|
|
187
|
+
'local.destroy',
|
|
188
|
+
]);
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
function createDependencies(calls: string[]): InfraOrchestrationDependencies {
|
|
193
|
+
return {
|
|
194
|
+
adapterResolver: createResolver(calls),
|
|
195
|
+
credentials: { resolveAsync: () => Promise.resolve(success({})) },
|
|
196
|
+
secrets: { resolveAsync: () => Promise.resolve(success('resolved-secret')) },
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function createResolver(calls: string[]): InfraAdapterPackageResolver {
|
|
201
|
+
return {
|
|
202
|
+
loadAsync(packageName) {
|
|
203
|
+
const descriptor = descriptorForPackage(packageName);
|
|
204
|
+
return Promise.resolve({
|
|
205
|
+
infraAdapterDescriptor: descriptor,
|
|
206
|
+
createInfraAdapter: () => createAdapter(descriptor, calls),
|
|
207
|
+
});
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function createAdapter(descriptor: InfraAdapterDescriptor, calls: string[]): unknown {
|
|
213
|
+
if (descriptor.kind === 'compute') return createCompute(descriptor, calls);
|
|
214
|
+
if (descriptor.kind === 'runtime') return createRuntime(descriptor, calls);
|
|
215
|
+
return createService(descriptor, calls);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function createCompute(descriptor: InfraAdapterDescriptor, calls: string[]): InfraComputeAdapter {
|
|
219
|
+
const selectedOwner = descriptor.id === 'hetzner' ? owner('hetzner', 'server') : computeOwner;
|
|
220
|
+
return {
|
|
221
|
+
descriptor: descriptor as InfraComputeAdapter['descriptor'],
|
|
222
|
+
validateAsync: () => recordedAsync(calls, `${descriptor.id}.validate`, null),
|
|
223
|
+
inspectAsync: () =>
|
|
224
|
+
recordedAsync(calls, `${descriptor.id}.inspect`, {
|
|
225
|
+
targets:
|
|
226
|
+
descriptor.id === 'hetzner'
|
|
227
|
+
? []
|
|
228
|
+
: [{ id: 'local', kind: 'local-host', os: 'linux', architecture: 'amd64' }],
|
|
229
|
+
resources: [resource(selectedOwner)],
|
|
230
|
+
outputs: [],
|
|
231
|
+
}),
|
|
232
|
+
planAsync: () => recordedAsync(calls, `${descriptor.id}.plan`, [action(selectedOwner, [])]),
|
|
233
|
+
ensureAsync: () =>
|
|
234
|
+
recordedAsync(calls, `${descriptor.id}.ensure`, { targets: [], resources: [], outputs: [] }),
|
|
235
|
+
statusAsync: () =>
|
|
236
|
+
recordedAsync(calls, `${descriptor.id}.status`, [status(selectedOwner, 'ready')]),
|
|
237
|
+
destroyAsync: () =>
|
|
238
|
+
recordedAsync(calls, `${descriptor.id}.destroy`, { resources: [], outputs: [] }),
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function createRuntime(descriptor: InfraAdapterDescriptor, calls: string[]): InfraRuntimeAdapter {
|
|
243
|
+
return {
|
|
244
|
+
descriptor: descriptor as InfraRuntimeAdapter['descriptor'],
|
|
245
|
+
validateAsync: () => recordedAsync(calls, `${descriptor.id}.validate`, null),
|
|
246
|
+
planAsync: () =>
|
|
247
|
+
recordedAsync(calls, `${descriptor.id}.plan`, [action(runtimeOwner, [computeOwner])]),
|
|
248
|
+
ensureAsync: () =>
|
|
249
|
+
recordedAsync(calls, `${descriptor.id}.ensure`, { resources: [], outputs: [] }),
|
|
250
|
+
statusAsync: () =>
|
|
251
|
+
recordedAsync(calls, `${descriptor.id}.status`, [status(runtimeOwner, 'degraded')]),
|
|
252
|
+
suspendAsync: () =>
|
|
253
|
+
recordedAsync(calls, `${descriptor.id}.suspend`, {
|
|
254
|
+
resources: [resource(runtimeOwner)],
|
|
255
|
+
outputs: [],
|
|
256
|
+
}),
|
|
257
|
+
destroyAsync: () =>
|
|
258
|
+
recordedAsync(calls, `${descriptor.id}.destroy`, { resources: [], outputs: [] }),
|
|
259
|
+
generateAsync: () =>
|
|
260
|
+
recordedAsync(calls, `${descriptor.id}.generate`, [
|
|
261
|
+
{ owner: runtimeOwner, path: 'infra/compose.yaml', content: 'services: {}\n' },
|
|
262
|
+
]),
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function createService(descriptor: InfraAdapterDescriptor, calls: string[]): InfraServiceAdapter {
|
|
267
|
+
const serviceOwner = descriptor.id === 'supabase' ? databaseOwner : vaultOwner;
|
|
268
|
+
const dependencies = descriptor.id === 'supabase' ? [runtimeOwner] : [databaseOwner];
|
|
269
|
+
return {
|
|
270
|
+
descriptor: descriptor as InfraServiceAdapter['descriptor'],
|
|
271
|
+
validateAsync: () => recordedAsync(calls, `${descriptor.id}.validate`, null),
|
|
272
|
+
planAsync: () =>
|
|
273
|
+
recordedAsync(calls, `${descriptor.id}.plan`, [action(serviceOwner, dependencies)]),
|
|
274
|
+
desiredWorkloadsAsync: () =>
|
|
275
|
+
recordedAsync(calls, `${descriptor.id}.workloads`, [workload(descriptor.id)]),
|
|
276
|
+
reconcileAsync: () =>
|
|
277
|
+
recordedAsync(calls, `${descriptor.id}.reconcile`, { resources: [], outputs: [] }),
|
|
278
|
+
statusAsync: () =>
|
|
279
|
+
recordedAsync(calls, `${descriptor.id}.status`, [status(serviceOwner, 'ready')]),
|
|
280
|
+
suspendAsync: () =>
|
|
281
|
+
recordedAsync(calls, `${descriptor.id}.suspend`, {
|
|
282
|
+
resources: [resource(serviceOwner, true)],
|
|
283
|
+
outputs: [],
|
|
284
|
+
}),
|
|
285
|
+
destroyAsync: () =>
|
|
286
|
+
recordedAsync(calls, `${descriptor.id}.destroy`, {
|
|
287
|
+
resources: [resource(serviceOwner, true)],
|
|
288
|
+
outputs: [],
|
|
289
|
+
}),
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function ledger() {
|
|
294
|
+
return {
|
|
295
|
+
schemaVersion: 1,
|
|
296
|
+
projectId: 'sample',
|
|
297
|
+
environment: 'local',
|
|
298
|
+
targets: [{ id: 'local', kind: 'local-host', os: 'linux', architecture: 'amd64' }],
|
|
299
|
+
resources: [
|
|
300
|
+
resource(computeOwner),
|
|
301
|
+
resource(runtimeOwner),
|
|
302
|
+
resource(databaseOwner, true),
|
|
303
|
+
resource(vaultOwner, true),
|
|
304
|
+
],
|
|
305
|
+
outputs: [
|
|
306
|
+
{
|
|
307
|
+
owner: runtimeOwner,
|
|
308
|
+
name: 'url',
|
|
309
|
+
visibility: 'public',
|
|
310
|
+
value: 'https://example.test',
|
|
311
|
+
environmentVariable: 'EXAMPLE_URL',
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
owner: vaultOwner,
|
|
315
|
+
name: 'credential',
|
|
316
|
+
visibility: 'secret',
|
|
317
|
+
reference: {
|
|
318
|
+
source: 'secret-store',
|
|
319
|
+
projectId: 'sample',
|
|
320
|
+
environment: 'local',
|
|
321
|
+
ref: 'example',
|
|
322
|
+
key: 'password',
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
],
|
|
326
|
+
artifacts: [],
|
|
327
|
+
} as const;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function owner(adapter: InfraAdapterDescriptor['id'], resourceId: string): InfraResourceIdentity {
|
|
331
|
+
return { projectId: 'sample', environment: 'local', adapter, resourceId };
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function resource(identity: InfraResourceIdentity, persistent = false): InfraOwnedResource {
|
|
335
|
+
return {
|
|
336
|
+
identity,
|
|
337
|
+
persistent,
|
|
338
|
+
retention: persistent ? 'retain' : 'delete-on-destroy',
|
|
339
|
+
dependsOn: [],
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function action(
|
|
344
|
+
actionOwner: InfraResourceIdentity,
|
|
345
|
+
dependsOn: readonly InfraResourceIdentity[],
|
|
346
|
+
): InfraPlanAction {
|
|
347
|
+
return {
|
|
348
|
+
owner: actionOwner,
|
|
349
|
+
operation: 'create',
|
|
350
|
+
impact: 'none',
|
|
351
|
+
detail: `Create ${actionOwner.resourceId}.`,
|
|
352
|
+
dependsOn,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function status(
|
|
357
|
+
statusOwner: InfraResourceIdentity,
|
|
358
|
+
state: InfraResourceStatus['state'],
|
|
359
|
+
): InfraResourceStatus {
|
|
360
|
+
return { owner: statusOwner, state };
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function workload(id: string): InfraWorkloadSpec {
|
|
364
|
+
return { id, artifact: { kind: 'image', image: `example/${id}:1` } };
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function descriptorForPackage(packageName: string): InfraAdapterDescriptor {
|
|
368
|
+
const descriptor = Object.values(INFRA_ADAPTER_CATALOG).find(
|
|
369
|
+
({ package: candidate }) => candidate === packageName,
|
|
370
|
+
);
|
|
371
|
+
if (descriptor === undefined) throw new Error('Unexpected package.');
|
|
372
|
+
return descriptor;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function recorded<T>(calls: string[], call: string, value: T): InfraResult<T> {
|
|
376
|
+
calls.push(call);
|
|
377
|
+
return success(value);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function recordedAsync<T>(calls: string[], call: string, value: T): Promise<InfraResult<T>> {
|
|
381
|
+
return Promise.resolve(recorded(calls, call, value));
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function success<T>(value: T): InfraResult<T> {
|
|
385
|
+
return { ok: true, value, diagnostics: [] };
|
|
386
|
+
}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InfraAdapterDescriptor,
|
|
3
|
+
InfraComputeAdapter,
|
|
4
|
+
InfraDiagnostic,
|
|
5
|
+
InfraEnvironmentSpec,
|
|
6
|
+
InfraOutput,
|
|
7
|
+
InfraResult,
|
|
8
|
+
InfraRuntimeAdapter,
|
|
9
|
+
InfraRuntimeDesiredState,
|
|
10
|
+
InfraServiceAdapter,
|
|
11
|
+
InfraWorkloadSpec,
|
|
12
|
+
} from '@ankhorage/contracts/infra';
|
|
13
|
+
import { INFRA_ADAPTER_CATALOG } from '@ankhorage/contracts/infra';
|
|
14
|
+
import { describe, expect, it } from 'bun:test';
|
|
15
|
+
|
|
16
|
+
import type { InfraAdapterPackageResolver } from './features/environment-lifecycle/application/ports/outbound/infraAdapterPackage';
|
|
17
|
+
import { upInfraEnvironmentAsync } from './features/environment-lifecycle/application/use-cases/upInfraEnvironmentAsync';
|
|
18
|
+
import type { InfraOrchestrationDependencies } from './types/infraOrchestration';
|
|
19
|
+
|
|
20
|
+
const environment = {
|
|
21
|
+
deployment: { compute: { provider: 'local' }, runtime: { provider: 'docker-compose' } },
|
|
22
|
+
database: { provider: 'supabase' },
|
|
23
|
+
auth: { provider: 'supabase' },
|
|
24
|
+
authz: { provider: 'cerbos', kind: 'ABAC' },
|
|
25
|
+
workloads: [workload('app')],
|
|
26
|
+
} as const satisfies InfraEnvironmentSpec;
|
|
27
|
+
const manifest = { environments: { local: environment }, modules: [] } as const;
|
|
28
|
+
|
|
29
|
+
describe('environment up orchestration', () => {
|
|
30
|
+
it('validates before mutation and reconciles compute, runtime and deduplicated services', async () => {
|
|
31
|
+
const calls: string[] = [];
|
|
32
|
+
const observedRuntimeDesired: InfraRuntimeDesiredState[] = [];
|
|
33
|
+
const observedServiceOutputs: InfraOutput[][] = [];
|
|
34
|
+
const dependencies = createDependencies(calls, observedRuntimeDesired, observedServiceOutputs);
|
|
35
|
+
const result = await upInfraEnvironmentAsync({ projectId: 'sample', manifest }, dependencies);
|
|
36
|
+
|
|
37
|
+
expect(result.ok).toBe(true);
|
|
38
|
+
expect(calls).toEqual([
|
|
39
|
+
'local.validate',
|
|
40
|
+
'supabase.validate',
|
|
41
|
+
'cerbos.validate',
|
|
42
|
+
'supabase.workloads',
|
|
43
|
+
'cerbos.workloads',
|
|
44
|
+
'local.ensure',
|
|
45
|
+
'docker-compose.validate',
|
|
46
|
+
'docker-compose.ensure',
|
|
47
|
+
'supabase.reconcile',
|
|
48
|
+
'cerbos.reconcile',
|
|
49
|
+
]);
|
|
50
|
+
expect(observedRuntimeDesired).toHaveLength(2);
|
|
51
|
+
expect(observedRuntimeDesired[0]?.workloads.map(({ id }) => id)).toEqual([
|
|
52
|
+
'app',
|
|
53
|
+
'supabase',
|
|
54
|
+
'cerbos',
|
|
55
|
+
]);
|
|
56
|
+
expect(observedRuntimeDesired[0]?.targets).toEqual([
|
|
57
|
+
{ id: 'local', kind: 'local-host', os: 'linux', architecture: 'amd64' },
|
|
58
|
+
]);
|
|
59
|
+
expect(observedServiceOutputs).toHaveLength(2);
|
|
60
|
+
expect(observedServiceOutputs[0]?.map(({ name }) => name)).toEqual([
|
|
61
|
+
'computeEndpoint',
|
|
62
|
+
'runtimeEndpoint',
|
|
63
|
+
]);
|
|
64
|
+
if (!result.ok) throw new Error('Expected successful up.');
|
|
65
|
+
expect(result.value.environment).toBe('local');
|
|
66
|
+
expect(result.value.outputs.map(({ name }) => name)).toEqual([
|
|
67
|
+
'computeEndpoint',
|
|
68
|
+
'runtimeEndpoint',
|
|
69
|
+
'supabaseOutput',
|
|
70
|
+
'cerbosOutput',
|
|
71
|
+
]);
|
|
72
|
+
expect(result.diagnostics.map(({ code }) => code)).toEqual(['compute-warning']);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('stops before mutation when service validation fails', async () => {
|
|
76
|
+
const calls: string[] = [];
|
|
77
|
+
const dependencies = createDependencies(calls, [], [], 'supabase.validate');
|
|
78
|
+
const result = await upInfraEnvironmentAsync({ projectId: 'sample', manifest }, dependencies);
|
|
79
|
+
|
|
80
|
+
expect(result).toMatchObject({ ok: false, diagnostics: [{ code: 'fixture-failure' }] });
|
|
81
|
+
expect(calls).toEqual(['local.validate', 'supabase.validate']);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('does not reconcile services after a runtime failure', async () => {
|
|
85
|
+
const calls: string[] = [];
|
|
86
|
+
const dependencies = createDependencies(calls, [], [], 'docker-compose.ensure');
|
|
87
|
+
const result = await upInfraEnvironmentAsync({ projectId: 'sample', manifest }, dependencies);
|
|
88
|
+
|
|
89
|
+
expect(result.ok).toBe(false);
|
|
90
|
+
expect(calls.at(-1)).toBe('docker-compose.ensure');
|
|
91
|
+
expect(calls).not.toContain('supabase.reconcile');
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
function createDependencies(
|
|
96
|
+
calls: string[],
|
|
97
|
+
runtimeDesired: InfraRuntimeDesiredState[],
|
|
98
|
+
serviceOutputs: InfraOutput[][],
|
|
99
|
+
failure?: string,
|
|
100
|
+
): InfraOrchestrationDependencies {
|
|
101
|
+
return {
|
|
102
|
+
adapterResolver: createResolver(calls, runtimeDesired, serviceOutputs, failure),
|
|
103
|
+
credentials: { resolveAsync: () => Promise.resolve(success({})) },
|
|
104
|
+
secrets: { resolveAsync: () => Promise.resolve(success('secret')) },
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function createResolver(
|
|
109
|
+
calls: string[],
|
|
110
|
+
runtimeDesired: InfraRuntimeDesiredState[],
|
|
111
|
+
serviceOutputs: InfraOutput[][],
|
|
112
|
+
failure?: string,
|
|
113
|
+
): InfraAdapterPackageResolver {
|
|
114
|
+
return {
|
|
115
|
+
loadAsync(packageName) {
|
|
116
|
+
const descriptor = descriptorForPackage(packageName);
|
|
117
|
+
return Promise.resolve({
|
|
118
|
+
infraAdapterDescriptor: descriptor,
|
|
119
|
+
createInfraAdapter: () =>
|
|
120
|
+
createAdapter(descriptor, calls, runtimeDesired, serviceOutputs, failure),
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function createAdapter(
|
|
127
|
+
descriptor: InfraAdapterDescriptor,
|
|
128
|
+
calls: string[],
|
|
129
|
+
runtimeDesired: InfraRuntimeDesiredState[],
|
|
130
|
+
serviceOutputs: InfraOutput[][],
|
|
131
|
+
failure?: string,
|
|
132
|
+
): unknown {
|
|
133
|
+
if (descriptor.kind === 'compute') return createCompute(descriptor, calls, failure);
|
|
134
|
+
if (descriptor.kind === 'runtime')
|
|
135
|
+
return createRuntime(descriptor, calls, runtimeDesired, failure);
|
|
136
|
+
return createService(descriptor, calls, serviceOutputs, failure);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function createCompute(
|
|
140
|
+
descriptor: InfraAdapterDescriptor,
|
|
141
|
+
calls: string[],
|
|
142
|
+
failure?: string,
|
|
143
|
+
): InfraComputeAdapter {
|
|
144
|
+
return {
|
|
145
|
+
descriptor: descriptor as InfraComputeAdapter['descriptor'],
|
|
146
|
+
validateAsync: () => recordAsync(calls, `${descriptor.id}.validate`, failure, null),
|
|
147
|
+
inspectAsync: () => Promise.resolve(success({ resources: [], outputs: [], targets: [] })),
|
|
148
|
+
planAsync: () => Promise.resolve(success([])),
|
|
149
|
+
ensureAsync: () => {
|
|
150
|
+
const recorded = record(calls, `${descriptor.id}.ensure`, failure, {
|
|
151
|
+
resources: [],
|
|
152
|
+
outputs: [publicOutput('local', 'compute', 'computeEndpoint')],
|
|
153
|
+
targets: [{ id: 'local', kind: 'local-host', os: 'linux', architecture: 'amd64' } as const],
|
|
154
|
+
});
|
|
155
|
+
return Promise.resolve(
|
|
156
|
+
recorded.ok ? { ...recorded, diagnostics: [diagnostic('compute-warning')] } : recorded,
|
|
157
|
+
);
|
|
158
|
+
},
|
|
159
|
+
statusAsync: () => Promise.resolve(success([])),
|
|
160
|
+
destroyAsync: () => Promise.resolve(success({ resources: [], outputs: [] })),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function createRuntime(
|
|
165
|
+
descriptor: InfraAdapterDescriptor,
|
|
166
|
+
calls: string[],
|
|
167
|
+
observed: InfraRuntimeDesiredState[],
|
|
168
|
+
failure?: string,
|
|
169
|
+
): InfraRuntimeAdapter {
|
|
170
|
+
return {
|
|
171
|
+
descriptor: descriptor as InfraRuntimeAdapter['descriptor'],
|
|
172
|
+
validateAsync: (_context, desired) => {
|
|
173
|
+
observed.push(desired);
|
|
174
|
+
return Promise.resolve(record(calls, `${descriptor.id}.validate`, failure, null));
|
|
175
|
+
},
|
|
176
|
+
planAsync: () => Promise.resolve(success([])),
|
|
177
|
+
ensureAsync: (_context, desired) => {
|
|
178
|
+
observed.push(desired);
|
|
179
|
+
return Promise.resolve(
|
|
180
|
+
record(calls, `${descriptor.id}.ensure`, failure, {
|
|
181
|
+
resources: [],
|
|
182
|
+
outputs: [publicOutput('docker-compose', 'runtime', 'runtimeEndpoint')],
|
|
183
|
+
}),
|
|
184
|
+
);
|
|
185
|
+
},
|
|
186
|
+
statusAsync: () => Promise.resolve(success([])),
|
|
187
|
+
suspendAsync: () => Promise.resolve(success({ resources: [], outputs: [] })),
|
|
188
|
+
destroyAsync: () => Promise.resolve(success({ resources: [], outputs: [] })),
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function createService(
|
|
193
|
+
descriptor: InfraAdapterDescriptor,
|
|
194
|
+
calls: string[],
|
|
195
|
+
observed: InfraOutput[][],
|
|
196
|
+
failure?: string,
|
|
197
|
+
): InfraServiceAdapter {
|
|
198
|
+
return {
|
|
199
|
+
descriptor: descriptor as InfraServiceAdapter['descriptor'],
|
|
200
|
+
validateAsync: () => recordAsync(calls, `${descriptor.id}.validate`, failure, null),
|
|
201
|
+
planAsync: () => Promise.resolve(success([])),
|
|
202
|
+
desiredWorkloadsAsync: () =>
|
|
203
|
+
recordAsync(calls, `${descriptor.id}.workloads`, failure, [workload(descriptor.id)]),
|
|
204
|
+
reconcileAsync: (_context, outputs) => {
|
|
205
|
+
observed.push([...outputs]);
|
|
206
|
+
return Promise.resolve(
|
|
207
|
+
record(calls, `${descriptor.id}.reconcile`, failure, {
|
|
208
|
+
resources: [],
|
|
209
|
+
outputs: [publicOutput(descriptor.id, descriptor.id, `${descriptor.id}Output`)],
|
|
210
|
+
}),
|
|
211
|
+
);
|
|
212
|
+
},
|
|
213
|
+
statusAsync: () => Promise.resolve(success([])),
|
|
214
|
+
destroyAsync: () => Promise.resolve(success({ resources: [], outputs: [] })),
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function record<T>(calls: string[], call: string, failure: string | undefined, value: T) {
|
|
219
|
+
calls.push(call);
|
|
220
|
+
return failure === call
|
|
221
|
+
? ({ ok: false, diagnostics: [diagnostic('fixture-failure')] } as const)
|
|
222
|
+
: success(value);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function recordAsync<T>(calls: string[], call: string, failure: string | undefined, value: T) {
|
|
226
|
+
return Promise.resolve(record(calls, call, failure, value));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function workload(id: string): InfraWorkloadSpec {
|
|
230
|
+
return { id, artifact: { kind: 'image', image: `example/${id}:1` } };
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function publicOutput(
|
|
234
|
+
adapter: InfraAdapterDescriptor['id'],
|
|
235
|
+
resourceId: string,
|
|
236
|
+
name: string,
|
|
237
|
+
): InfraOutput {
|
|
238
|
+
return {
|
|
239
|
+
owner: { projectId: 'sample', environment: 'local', adapter, resourceId },
|
|
240
|
+
name,
|
|
241
|
+
visibility: 'public',
|
|
242
|
+
value: `https://${resourceId}.example.test`,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function descriptorForPackage(packageName: string): InfraAdapterDescriptor {
|
|
247
|
+
const descriptor = Object.values(INFRA_ADAPTER_CATALOG).find(
|
|
248
|
+
({ package: candidate }) => candidate === packageName,
|
|
249
|
+
);
|
|
250
|
+
if (descriptor === undefined) throw new Error('Unexpected package.');
|
|
251
|
+
return descriptor;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function diagnostic(code: string): InfraDiagnostic {
|
|
255
|
+
return { severity: 'warning', code, message: code };
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function success<T>(value: T): InfraResult<T> {
|
|
259
|
+
return { ok: true, value, diagnostics: [] };
|
|
260
|
+
}
|
package/src/metadata/index.ts
CHANGED
package/src/package.test.ts
CHANGED
|
@@ -10,11 +10,13 @@ describe('package metadata', () => {
|
|
|
10
10
|
provider: './dist/cli/index.js',
|
|
11
11
|
capabilities: [
|
|
12
12
|
'infra.validate',
|
|
13
|
+
'infra.plan',
|
|
13
14
|
'infra.generate',
|
|
14
|
-
'infra.status',
|
|
15
15
|
'infra.up',
|
|
16
|
+
'infra.status',
|
|
17
|
+
'infra.outputs',
|
|
16
18
|
'infra.down',
|
|
17
|
-
'infra.
|
|
19
|
+
'infra.destroy',
|
|
18
20
|
],
|
|
19
21
|
} as const satisfies AnkhPackageMetadata;
|
|
20
22
|
|