import type { DependenciesOverridesData } from '@teambit/legacy.consumer-config'; import type { Policy, PolicyConfigKeys, PolicyConfigKeysNames, PolicyEntry, SemverVersion } from '../policy'; import type { DependencyLifecycleType } from '../../dependencies'; export type VariantPolicyConfigObject = Partial>; type VariantPolicyLifecycleConfigObject = { [dependencyId: string]: VariantPolicyConfigEntryValue; }; type VariantPolicyLifecycleConfigEntryObject = { name: string; version: string; /** * hide the dependency from the component's package.json / dependencies list */ hidden?: boolean; /** * force add to component dependencies even if it's not used by the component. */ force?: boolean; optional?: boolean; }; export type VariantPolicyConfigArr = Partial>; export type VariantPolicyConfigEntryValue = VariantPolicyEntryValue | VariantPolicyEntryVersion; /** * Allowed values are valid semver values, git urls, fs path. */ export type VariantPolicyEntryVersion = SemverVersion; export type VariantPolicyEntryValue = { version: VariantPolicyEntryVersion; resolveFromEnv?: boolean; optional?: boolean; workspaceSingleton?: boolean; override?: boolean; }; export type DependencySource = 'auto' | 'env' | 'env-own' | 'slots' | 'config'; export type VariantPolicyEntry = PolicyEntry & { value: VariantPolicyEntryValue; source?: DependencySource; /** * hide the dependency from the component's package.json / dependencies list */ hidden?: boolean; /** * force add to component dependencies even if it's not used by the component. */ force?: boolean; optional?: boolean; }; export type SerializedVariantPolicyEntry = VariantPolicyEntry; export type SerializedVariantPolicy = SerializedVariantPolicyEntry[]; export interface VariantPolicyFromConfigObjectOptions { includeLegacyPeersInSelfPolicy?: boolean; source?: DependencySource; hidden?: boolean; force?: boolean; optional?: boolean; } export declare class VariantPolicy implements Policy { private _policiesEntries; constructor(_policiesEntries: VariantPolicyEntry[]); get entries(): VariantPolicyEntry[]; get names(): string[]; get length(): number; find(depId: string, lifecycleType?: DependencyLifecycleType): VariantPolicyEntry | undefined; byLifecycleType(lifecycleType: DependencyLifecycleType): VariantPolicy; sortByName(): VariantPolicy; /** * Return a hash of all the peers names and their version * This useful when you want to compare 2 envs */ hashNameVersion(): string; filter(predicate: (dep: VariantPolicyEntry, index?: number) => boolean): VariantPolicy; hiddenOnly(): VariantPolicy; /** * Filter only deps which should be resolved from the env */ getResolvedFromEnv(): VariantPolicy; getDepVersion(depId: string, lifecycleType?: DependencyLifecycleType): VariantPolicyEntryVersion | undefined; getValidSemverDepVersion(depId: string, lifecycleType?: DependencyLifecycleType): VariantPolicyEntryVersion | undefined; serialize(): SerializedVariantPolicy; toConfigObject(): VariantPolicyConfigObject; /** * Create a manifest object in the form of a package.json entries * a.k.a { [depId]: version } * @returns */ toVersionManifest(): { [name: string]: string; }; toNameVersionTuple(): [string, string][]; /** * This used in in the legacy to apply env component policy on stuff that were auto detected * it will take used only entries (which means entries that component are really uses) * and in case of hidden deps it will mark them as removed using the "-" value to remove them from the component * @returns */ toLegacyAutoDetectOverrides(): DependenciesOverridesData; toLegacyDepsOverrides(): DependenciesOverridesData; static fromConfigObject(configObject: any, // VariantPolicyConfigArr | VariantPolicyConfigObj, options?: VariantPolicyFromConfigObjectOptions): VariantPolicy; static fromArray(entries: VariantPolicyEntry[]): VariantPolicy; static parse(serializedEntries: SerializedVariantPolicy): VariantPolicy; static getEmpty(): VariantPolicy; static mergePolices(policies: VariantPolicy[]): VariantPolicy; } export declare function createVariantPolicyEntry(depId: string, value: VariantPolicyConfigEntryValue, lifecycleType: DependencyLifecycleType, opts: VariantPolicyFromConfigObjectOptions): VariantPolicyEntry; export {};