@finos/legend-graph
Version:
Legend graph and graph manager
80 lines • 4.35 kB
TypeScript
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type GenericClazz } from '@finos/legend-shared';
import type { Package } from '../../../../../../../graph/metamodel/pure/packageableElements/domain/Package.js';
import type { PackageableElement } from '../../../../../../../graph/metamodel/pure/packageableElements/PackageableElement.js';
import type { V1_PackageableElement } from '../../../model/packageableElements/V1_PackageableElement.js';
import { type V1_GraphBuilderContext } from './V1_GraphBuilderContext.js';
export type V1_ElementBuilderPass = (elementProtocol: V1_PackageableElement, context: V1_GraphBuilderContext) => void;
export type V1_ElementFirstPassBuilder = (elementProtocol: V1_PackageableElement, context: V1_GraphBuilderContext) => PackageableElement;
export type V1_ElementSecondPassBuilder = V1_ElementBuilderPass;
export type V1_ElementThirdPassBuilder = V1_ElementBuilderPass;
export type V1_ElementFourthPassBuilder = V1_ElementBuilderPass;
export type V1_ElementFifthPassBuilder = V1_ElementBuilderPass;
export declare const V1_checkDuplicatedElement: (path: string, context: V1_GraphBuilderContext, cache: Set<string> | undefined) => void;
/**
* Element builder is a mechanism to handling the building process of
* element.
* - Each builder focuses on only 1 element type.
* - Each builder specifies prerequisites element types so that while
* building the Pure graph, we can order the builders appropriately.
* - Each builder has 5 passes. NOTE: not all elements require 5-pass
* building process. But this should give enough flexibility on how
* elements can be processed.
*
* NOTE: we aim to have the first pass to be relatively simple: just build
* the basic element, index it and put it in the element tree based on its
* path. Since this common task is required by many other builder processes,
* the first pass will be run first and separately from other passes.
*
* Also note that as of right now we will run build pass 2-5 of each element
* consecutively so there is no opportunity to `interleave` build passes of
* different elements. That definitely seems more flexible, but also incur
* a fair amount of complexity we don't see the need for right now.
*/
export declare class V1_ElementBuilder<T extends V1_PackageableElement> {
readonly elementClassName: string;
private _class;
private prerequisites;
private firstPass;
private secondPass?;
private thirdPass?;
private fourthPass?;
private fifthPass?;
constructor(props: {
elementClassName: string;
_class: GenericClazz<T>;
prerequisites?: GenericClazz<V1_PackageableElement>[] | undefined;
/**
* We aim to build the basic element and index it.
*
* NOTE: aim to put specialized build logic in the second pass and beyond.
*/
firstPass: V1_ElementFirstPassBuilder;
secondPass?: V1_ElementSecondPassBuilder;
thirdPass?: V1_ElementThirdPassBuilder;
fourthPass?: V1_ElementFourthPassBuilder;
fifthPass?: V1_ElementFifthPassBuilder;
});
getElementProtocolClass(): GenericClazz<T>;
getPrerequisiteElementProtocolClasses(): GenericClazz<V1_PackageableElement>[];
runFirstPass(elementProtocol: T, context: V1_GraphBuilderContext, packageCache: Map<string, Package> | undefined, elementPathCache: Set<string> | undefined): PackageableElement;
runSecondPass(elementProtocol: T, context: V1_GraphBuilderContext): void;
runThirdPass(elementProtocol: T, context: V1_GraphBuilderContext): void;
runFourthPass(elementProtocol: T, context: V1_GraphBuilderContext): void;
runFifthPass(elementProtocol: T, context: V1_GraphBuilderContext): void;
}
//# sourceMappingURL=V1_ElementBuilder.d.ts.map