| 1 | import type * as appconfig from "@distilled.cloud/aws/appconfig"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Application } from "./Application.ts"; |
| 5 | import type { ConfigurationProfile } from "./ConfigurationProfile.ts"; |
| 6 | |
| 7 | export interface ValidateConfigurationRequest extends Omit< |
| 8 | appconfig.ValidateConfigurationRequest, |
| 9 | "ApplicationId" | "ConfigurationProfileId" |
| 10 | > {} |
| 11 | |
| 12 | /** |
| 13 | * Validate a configuration version against a configuration profile's |
| 14 | * validators from a Lambda (or other AWS runtime). Pairs with |
| 15 | * {@link CreateHostedConfigurationVersion} + {@link StartDeployment}: write |
| 16 | * the new content, validate it, then roll it out. Fails with a typed |
| 17 | * `BadRequestException` when a validator rejects the content; succeeds with |
| 18 | * an empty response when validation passes (including when the profile has |
| 19 | * no validators). |
| 20 | * |
| 21 | * Provide `AppConfig.ValidateConfigurationHttp` on the hosting function's |
| 22 | * Effect to implement the binding. |
| 23 | * |
| 24 | * ### Writing Configuration at Runtime |
| 25 | * **Example:** Validate a version before deploying it |
| 26 | * ```typescript |
| 27 | * const validate = yield* AppConfig.ValidateConfiguration(app, profile); |
| 28 | * yield* validate({ ConfigurationVersion: "2" }); |
| 29 | * ``` |
| 30 | * |
| 31 | * @binding |
| 32 | */ |
| 33 | export interface ValidateConfiguration extends Binding.Service< |
| 34 | ValidateConfiguration, |
| 35 | "AWS.AppConfig.ValidateConfiguration", |
| 36 | ( |
| 37 | application: Application, |
| 38 | configurationProfile: ConfigurationProfile, |
| 39 | ) => Effect.Effect< |
| 40 | ( |
| 41 | request: ValidateConfigurationRequest, |
| 42 | ) => Effect.Effect< |
| 43 | appconfig.ValidateConfigurationResponse, |
| 44 | appconfig.ValidateConfigurationError |
| 45 | > |
| 46 | > |
| 47 | > {} |
| 48 | export const ValidateConfiguration = Binding.Service<ValidateConfiguration>( |
| 49 | "AWS.AppConfig.ValidateConfiguration", |
| 50 | ); |