@teambit/workspace
Version:
39 lines (38 loc) • 1.6 kB
TypeScript
import type { ComponentID } from '@teambit/component-id';
import type { Consumer } from '@teambit/legacy.consumer';
import type { Workspace } from '..';
export type ComponentStatusLegacy = {
modified: boolean;
newlyCreated: boolean;
deleted: boolean;
staged: boolean;
notExist: boolean;
missingFromScope: boolean;
};
export type ComponentStatusResult = {
id: ComponentID;
status: ComponentStatusLegacy;
};
export declare class ComponentStatusLoader {
private workspace;
private _componentsStatusCache;
constructor(workspace: Workspace);
get consumer(): Consumer;
getManyComponentsStatuses(ids: ComponentID[]): Promise<ComponentStatusResult[]>;
/**
* Get a component status by ID. Return a ComponentStatus object.
* Keep in mind that a result can be a partial object of ComponentStatus, e.g. { notExist: true }.
* Each one of the ComponentStatus properties can be undefined, true or false.
* As a result, in order to check whether a component is not modified use (status.modified === false).
* Don't use (!status.modified) because a component may not exist and the status.modified will be undefined.
*
* The status may have 'true' for several properties. For example, a component can be staged and modified at the
* same time.
*
* The result is cached per ID and can be called several times with no penalties.
*/
getComponentStatusById(id: ComponentID): Promise<ComponentStatusLegacy>;
private getStatus;
clearOneComponentCache(id: ComponentID): void;
clearCache(): void;
}