UNPKG

@altostra/core

Version:

Core library for shared types and logic

67 lines (66 loc) 3.14 kB
import type { Maybe } from "../../Common"; import type { ParameterPath, ParameterSpec } from "../../Parameters"; import { ParameterPathBuilder } from "../../Parameters"; import type { PropertyParent, PropertyType } from "../../Parameters/TypeMapping"; import { CONN_ROOT_PATH_PARTS_COUNT, resolveParameterPath, RESOURCE_ROOT_PATH_PARTS_COUNT } from "../../Parameters/TypeMapping"; import type { BlueprintHelper } from "../BlueprintHelper"; import type { ConnectionHelper } from "../ConnectionHelper"; import type { ResourceHelper } from "../ResourceHelper"; import type { SetParametersFromParams } from "./ParametersHelper"; import { ParametersHelper } from "./ParametersHelper"; /** * A helper class to handle blueprint parameters */ export declare class BlueprintParametersHelper extends ParametersHelper { #private; /** * Creates new ParametersHelper instance * @param blueprint The blueprint */ constructor(blueprint: BlueprintHelper, suppressParameterSupportCheck: boolean); /** * Add the parameter at the specified path. \ * * If the parameter exists at the specify path, nothing happens. \ * If the parameter does not exist it is created; otherwise, the path is added * to its spec * @param name The name of the parameter * @param pathsOrSpec Path for the parameter, or parameter spec * @returns The parameter spec of the parameter. */ add(name: string, pathsOrSpec: ParameterPath | ParameterSpec): ParameterSpec; private isGlobalEnvironmentVariablesPath; /** * Returns a PropertyHolder containing the object above the pointed property * (by the provided path), and the relevant property key * @param path Path to get parameter holder from */ getParamParent(path: ParameterPath | ParameterPathBuilder): PropertyParent; hasParamAt(path: ParameterPath | ParameterPathBuilder): boolean; getParamTypeAt(path: ParameterPath | ParameterPathBuilder): Maybe<PropertyType<any>>; /** * Adds and removes parameters from parameterized object. * * If the parameterized object has `Parameter<T>` value, and there's no parameter at the * parameter's property path - then a new parameter is added. * If the parameterized object has simple property at the path where existing * parameter contained - the parameter is removed. * @returns The unparameterized object. */ setParametersFrom<T extends object>({ defaultParameterValue, ...params }: SetParametersFromParams<T>): T; /** * Returns an array of all the resources and an array of all the connections * that use the parameter * @param paramName the parameter name in the blueprint * @returns ParameterUsage objects that contains the arrays */ getParameterUsage(paramName: string): ParameterUsage; } /** * Lists of all the resources and connections that use a parameter */ export interface ParameterUsage { resources: ResourceHelper[]; connections: ConnectionHelper[]; } export { resolveParameterPath, RESOURCE_ROOT_PATH_PARTS_COUNT, CONN_ROOT_PATH_PARTS_COUNT, type PropertyParent, };