UNPKG

@altostra/core

Version:

Core library for shared types and logic

196 lines (195 loc) • 8.39 kB
import type { LogicalId } from "../../../aws/CloudFormation/LogicalId"; import type { It } from "../../../common/Iterable"; import type { Logger, OperationLoggingSeverity } from "../../../common/Logging"; import type { Maybe } from "../../../common/Maybe"; import type { Dict, Void } from "../../../common/Types"; import type { AxiosInstance } from 'axios'; import type { DeploymentName } from "../../CustomTypes/DeploymentName"; import type { TaggedDeploymentPart } from "../../CustomTypes/TaggedDeployment"; import type { ProjectId } from "../../DeployableProject/Common"; import type { ExtraData } from "../../Types"; import type { ErrorMapping, IdentityToken, Pagination } from "../common"; import type { ItemSelection } from "../ItemSelection"; import { ServiceClientBase as NonValidatingServiceClient } from "../ServiceClientBase"; import type { ProjectValidatingServiceClientCtor } from "../ServiceClientBase/ProjectValidatingServiceClient"; import type { BossDeploymentResponse } from "./DeploymentResponse"; import type { CombinedDeploymentHistoryActionItem, Deployment, DeploymentEntityResponse, EnvironmentName, VersionUsageHistoryResponse } from "./Types"; declare const ServiceClientBase: ProjectValidatingServiceClientCtor<typeof NonValidatingServiceClient>; export interface DeploymentsManagerOptions { axios?: AxiosInstance; endpoint: string; getToken: () => Promise<IdentityToken>; logger?: Logger<OperationLoggingSeverity>; errorMapping?: ErrorMapping; } export declare type DeploymentType = 'create' | 'createOrUpdate' | 'update'; export interface DeploymentParamsBase { /** * The deployment's project id */ projectId: ProjectId; /** * The build tag to deploy */ tag: TaggedDeploymentPart; /** * The deployment name */ deployment: DeploymentName; /** * `'create'` to create a new deployment in the specified environment \ * `'createOrUpdate'` to create a new deployment if deployment cannot be found by the provided name; \ * &nbsp;&nbsp;&nbsp;&nbsp;Otherwise, redeploy to existing deployment \ * `'update'` to update existing deployment */ deploymentType?: DeploymentType; /** * The deployment environment (optional) */ environment?: EnvironmentName; /** * A new configuration set (If not specified, the existing one, if any, is used) */ configSet?: Dict<string>; /** * A new configuration map (If not specified, the existing one, if any, is used) */ configMap?: Dict<string>; /** * Set to `true` if you wish to delete the deployed stack if it has staled * (e.g. was not created successfully to begin with) and then continue with * the deployment. * * Set to `false` if you wish to leave the deployment stack if it has staled. \ * Doing so would fail the deployment */ deleteStaleStack?: boolean; /** * Upsert the deployment without throwing any errors if regarding to deployment existence */ force?: boolean; deploymentParams?: Dict<string>; /** * Set to `true` if altostra should manage your lambdas' sources files. * * Set to `false` the sources managed by the user */ isSourcesRequired?: boolean; } export interface UpdateDeploymentParams extends DeploymentParamsBase { /** * 'update'` to update existing deployment (optional) */ deploymentType?: 'update'; } export interface CreateDeploymentParams extends DeploymentParamsBase { /** * The deployment environment */ environment: EnvironmentName; } export declare type DeploymentParams = CreateDeploymentParams | UpdateDeploymentParams; export interface IDeploymentsManager { /** * Gets a single deployment by project-id and name * @param projectIdOrSelection The project of the deployment to get * @param name The name of the deployment * * @returns Promise for deployment */ get(projectIdOrSelection: ItemSelection | ProjectId, name: DeploymentName): Promise<DeploymentEntityResponse>; /** * Lists all deployments for a Project * @param projectIdOrSelection A project to list its deployments * @param pagination Page selection * * @returns A promise for an array of project deployments */ list(projectIdOrSelection: ItemSelection | ProjectId, pagination?: Pagination): Promise<Deployment[]>; /** * Returns the history of specified deployment * @param projectIdOrSelection The deployment's project * @param deploymentName The name of the deployment * @param pagination Page selection * * @returns A promise for an array of deployment history items */ getHistory(projectIdOrSelection: ItemSelection | ProjectId, deploymentName: DeploymentName, pagination?: Pagination): Promise<CombinedDeploymentHistoryActionItem[]>; /** * Creating or redeploying an existing deployment, using a specified build-tag * @param params Create or update deploymentParameters * * @returns A promise for the change-set review page in AWS */ deploy(params: DeploymentParams): Promise<BossDeploymentResponse>; /** * Initiating deployment deletion * @param projectId The deployment's project id * @param deploymentName The name of the deployment * * @returns A `Promise<void>` */ deleteDeployment(projectId: ProjectId, deploymentName: DeploymentName, options?: DeleteDeploymentOptions): Promise<Void>; /** * Returns a list of deployment history items where a version was deployed * @param projectId The project id * @param version The version name to look for * @param pagination A pagination object */ getImageUsage(projectId: ProjectId, version: TaggedDeploymentPart, pagination?: Pagination): Promise<VersionUsageHistoryResponse>; } export declare class DeploymentsManager extends ServiceClientBase implements IDeploymentsManager { #private; constructor({ axios, endpoint, getToken, logger, errorMapping, }: DeploymentsManagerOptions); /** * Gets a single deployment by project-id and name * @param projectIdOrSelection The project of the deployment to get * @param name The name of the deployment * * @returns Promise for deployment */ get(projectIdOrSelection: ItemSelection | ProjectId, name: DeploymentName): Promise<DeploymentEntityResponse>; /** * Lists all deployments for a Project * @param projectIdOrSelection A project to list its deployments * @param pagination Page selection * * @returns A promise for an array of project deployments */ list(projectIdOrSelection: ItemSelection | ProjectId, pagination?: Pagination): Promise<Deployment[]>; /** * Returns the history of specified deployment * @param projectIdOrSelection The deployment's project * @param deploymentName The name of the deployment * @param pagination Page selection * * @returns A promise for an array of deployment history items */ getHistory(projectIdOrSelection: ItemSelection | ProjectId, deploymentName: DeploymentName, pagination?: Pagination): Promise<CombinedDeploymentHistoryActionItem[]>; getLatestMetadata(projectId: ProjectId, deploymentName: DeploymentName, latestDeploymentOnly?: boolean): Promise<Maybe<ExtraData>>; /** * Creating or redeploying an existing deployment, using a specified build-tag * @param params Create or update deploymentParameters * * @returns A promise for the change-set review page in AWS */ deploy(params: DeploymentParams): Promise<BossDeploymentResponse>; /** * Initiating deployment deletion * @param projectId The deployment's project id * @param deploymentName The name of the deployment * * @returns A `Promise<void>` */ deleteDeployment(projectId: ProjectId, deploymentName: DeploymentName, { bucketsToEmpty, }?: DeleteDeploymentOptions): Promise<Void>; getImageUsage(projectId: ProjectId, version: TaggedDeploymentPart, pagination?: Pagination): Promise<VersionUsageHistoryResponse>; } export interface DeploymentHistoryFilter { successfulOnly?: boolean; hasExtraData?: boolean; } export interface DeleteDeploymentOptions { bucketsToEmpty?: LogicalId[]; } export declare function filterHistoryBy({ successfulOnly, hasExtraData, }: DeploymentHistoryFilter): (it: Iterable<CombinedDeploymentHistoryActionItem>) => It<CombinedDeploymentHistoryActionItem>; export {};