/**
 * 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 LogService } from '@finos/legend-shared';
import type { PackageableElement } from '../../../../../../../graph/metamodel/pure/packageableElements/PackageableElement.js';
import type { PureModel } from '../../../../../../../graph/PureModel.js';
import type { Package } from '../../../../../../../graph/metamodel/pure/packageableElements/domain/Package.js';
import { type Section } from '../../../../../../../graph/metamodel/pure/packageableElements/section/Section.js';
import { StereotypeImplicitReference } from '../../../../../../../graph/metamodel/pure/packageableElements/domain/StereotypeReference.js';
import { GenericTypeImplicitReference, type GenericTypeReference } from '../../../../../../../graph/metamodel/pure/packageableElements/domain/GenericTypeReference.js';
import type { Type } from '../../../../../../../graph/metamodel/pure/packageableElements/domain/Type.js';
import type { Class } from '../../../../../../../graph/metamodel/pure/packageableElements/domain/Class.js';
import type { Enumeration } from '../../../../../../../graph/metamodel/pure/packageableElements/domain/Enumeration.js';
import type { Association } from '../../../../../../../graph/metamodel/pure/packageableElements/domain/Association.js';
import type { Mapping } from '../../../../../../../graph/metamodel/pure/packageableElements/mapping/Mapping.js';
import type { Profile } from '../../../../../../../graph/metamodel/pure/packageableElements/domain/Profile.js';
import type { ConcreteFunctionDefinition } from '../../../../../../../graph/metamodel/pure/packageableElements/function/ConcreteFunctionDefinition.js';
import type { Store } from '../../../../../../../graph/metamodel/pure/packageableElements/store/Store.js';
import type { Service } from '../../../../../../../graph/metamodel/pure/packageableElements/service/Service.js';
import type { FlatData } from '../../../../../../../graph/metamodel/pure/packageableElements/store/flatData/model/FlatData.js';
import type { Database, INTERNAL__LakehouseGeneratedDatabase } from '../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/Database.js';
import type { PackageableConnection } from '../../../../../../../graph/metamodel/pure/packageableElements/connection/PackageableConnection.js';
import type { PackageableRuntime } from '../../../../../../../graph/metamodel/pure/packageableElements/runtime/PackageableRuntime.js';
import type { FileGenerationSpecification } from '../../../../../../../graph/metamodel/pure/packageableElements/fileGeneration/FileGenerationSpecification.js';
import type { GenerationSpecification } from '../../../../../../../graph/metamodel/pure/packageableElements/generationSpecification/GenerationSpecification.js';
import type { Measure, Unit } from '../../../../../../../graph/metamodel/pure/packageableElements/domain/Measure.js';
import { PackageableElementImplicitReference } from '../../../../../../../graph/metamodel/pure/packageableElements/PackageableElementReference.js';
import { TagImplicitReference } from '../../../../../../../graph/metamodel/pure/packageableElements/domain/TagReference.js';
import { PropertyImplicitReference } from '../../../../../../../graph/metamodel/pure/packageableElements/domain/PropertyReference.js';
import { JoinImplicitReference } from '../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/JoinReference.js';
import { FilterImplicitReference } from '../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/FilterReference.js';
import { RootFlatDataRecordTypeImplicitReference } from '../../../../../../../graph/metamodel/pure/packageableElements/store/flatData/model/RootFlatDataRecordTypeReference.js';
import type { ViewImplicitReference } from '../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/ViewReference.js';
import type { TableImplicitReference } from '../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/TableReference.js';
import { EnumValueImplicitReference } from '../../../../../../../graph/metamodel/pure/packageableElements/domain/EnumValueReference.js';
import type { V1_StereotypePtr } from '../../../model/packageableElements/domain/V1_StereotypePtr.js';
import type { V1_PackageableElement } from '../../../model/packageableElements/V1_PackageableElement.js';
import type { V1_TagPtr } from '../../../model/packageableElements/domain/V1_TagPtr.js';
import type { V1_PropertyPointer } from '../../../model/packageableElements/domain/V1_PropertyPointer.js';
import type { V1_JoinPointer } from '../../../model/packageableElements/store/relational/model/V1_JoinPointer.js';
import type { V1_FilterPointer } from '../../../model/packageableElements/store/relational/mapping/V1_FilterPointer.js';
import type { V1_RootFlatDataClassMapping } from '../../../model/packageableElements/store/flatData/mapping/V1_RootFlatDataClassMapping.js';
import type { V1_TablePtr } from '../../../model/packageableElements/store/relational/model/V1_TablePtr.js';
import type { BasicModel } from '../../../../../../../graph/BasicModel.js';
import type { V1_GraphBuilderExtensions } from './V1_GraphBuilderExtensions.js';
import type { GraphBuilderOptions } from '../../../../../../../graph-manager/AbstractPureGraphManager.js';
import { DataType } from '../../../../../../../graph/metamodel/pure/packageableElements/domain/DataType.js';
import type { PropertyOwner } from '../../../../../../../graph/metamodel/pure/packageableElements/domain/AbstractProperty.js';
import type { DataElement } from '../../../../../../../graph/metamodel/pure/packageableElements/data/DataElement.js';
import type { V1_GenericType } from '../../../model/packageableElements/type/V1_GenericType.js';
import type { DataProduct } from '../../../../../../../graph/metamodel/pure/dataProduct/DataProduct.js';
import { type V1_RawGenericType } from '../../../model/rawValueSpecification/V1_RawVariable.js';
export declare const V1_buildFullPath: (packagePath: string | undefined, name: string | undefined) => string;
interface ResolutionResult<T> {
    /**
     * The resolved element.
     */
    element: T;
    /**
     * Flag indicating if we need to use section imports to resolve the element.
     */
    resolvedUsingSectionImports?: boolean | undefined;
    /**
     * Flag indicating if the full path is already provided when resolving the element.
     */
    isFullPath?: boolean | undefined;
}
export declare class V1_GraphBuilderContext {
    private readonly autoImports;
    private readonly sectionImports;
    readonly logService: LogService;
    readonly currentSubGraph: BasicModel;
    readonly extensions: V1_GraphBuilderExtensions;
    readonly graph: PureModel;
    readonly section?: Section | undefined;
    readonly options?: GraphBuilderOptions | undefined;
    constructor(builder: V1_GraphBuilderContextBuilder);
    /**
     * Since we haven't fully supported section index, shortened paths
     * using imports in the graph might need to be fully resolved.
     *
     * To handle this need, we make use of references. References can auto
     * resolve full paths when the section index is deleted. But, when
     * building the graph, we leave the value specifications
     * raw/unprocessed. Hence, we cannot make use of references to do full
     * path resolution, as such, we make a best effort traversal in the model
     * of raw value specifications to resolve path automatically.
     *
     * We create this flag to control the behavior of lambda auto path-resolution.
     * This rewriting behavior should not be done for immutable graphs, such as
     * system, depdendencies, and generation. However, in overall, it would be controlled
     * also by the `TEMPORARY__preserveSectionIndex` flag.
     *
     * NOTE: When we fully support section index, we would certainly need to
     * revise the usefullness of this flag, perhaps, we don't auto-resolve anymore,
     * but this mechanism would still be beneficial as we can keep it as an utility
     * to resolve raw lambdas' paths when the user deliberately delete the section
     * index, for example.
     *
     * https://github.com/finos/legend-studio/issues/1067
     */
    get enableRawLambdaAutoPathResolution(): boolean;
    resolve<T>(path: string, resolverFn: (path: string) => T): ResolutionResult<T>;
    /**
     * This method and this class in general demonstrates the difference
     * between explicit and implicit reference.
     * See {@link PackageableElementImplicitReference} for more details.
     *
     * Notice that every method in the resolver ends up creating an implicit reference.
     * It does not matter whether the full path is specified or not (i.e. so almost
     * no inference was done), the resulting reference must be implicit, as we took the
     * input into account when creating this reference.
     */
    createImplicitPackageableElementReference: <T extends PackageableElement>(path: string, resolverFn: (path: string) => T) => PackageableElementImplicitReference<T>;
    resolveStereotype: (stereotypePtr: V1_StereotypePtr) => StereotypeImplicitReference;
    resolveTag: (tagPtr: V1_TagPtr) => TagImplicitReference;
    resolveGenericType: (path: string) => GenericTypeImplicitReference;
    resolveGenericTypeFromProtocol: (genericType: V1_GenericType) => GenericTypeReference;
    resolveGenericTypeFromProtocolWithRelationType: (genericType: V1_GenericType) => GenericTypeReference;
    resolveRawGenericTypeFromProtocol: (genericType: V1_RawGenericType) => GenericTypeReference;
    resolveOwnProperty: (pointer: V1_PropertyPointer) => PropertyImplicitReference;
    resolveProperty: (pointer: V1_PropertyPointer) => PropertyImplicitReference;
    resolveRootFlatDataRecordType: (classMapping: V1_RootFlatDataClassMapping) => RootFlatDataRecordTypeImplicitReference;
    resolveRelation: (tablePtr: V1_TablePtr, contextDatabse?: Map<string, INTERNAL__LakehouseGeneratedDatabase> | undefined, allowImplicitToGeneratedDatabse?: boolean | undefined) => ViewImplicitReference | TableImplicitReference;
    resolveJoin: (joinPtr: V1_JoinPointer) => JoinImplicitReference;
    resolveFilter: (filterPtr: V1_FilterPointer) => FilterImplicitReference;
    resolveEnumValue: (enumeration: string, enumValue: string) => EnumValueImplicitReference;
    resolveElement: (path: string, includePackage: boolean) => PackageableElementImplicitReference<PackageableElement>;
    resolveType: (path: string) => PackageableElementImplicitReference<Type>;
    resolveDataType: (path: string) => PackageableElementImplicitReference<DataType>;
    resolveProfile: (path: string) => PackageableElementImplicitReference<Profile>;
    resolveClass: (path: string) => PackageableElementImplicitReference<Class>;
    resolveEnumeration: (path: string) => PackageableElementImplicitReference<Enumeration>;
    resolveMeasure: (path: string) => PackageableElementImplicitReference<Measure>;
    resolveUnit: (path: string) => PackageableElementImplicitReference<Unit>;
    resolveAssociation: (path: string) => PackageableElementImplicitReference<Association>;
    resolvePropertyOwner: (path: string) => PackageableElementImplicitReference<PropertyOwner>;
    resolveFunction: (path: string) => PackageableElementImplicitReference<ConcreteFunctionDefinition>;
    resolveStore: (path: string) => PackageableElementImplicitReference<Store>;
    resolveFlatDataStore: (path: string) => PackageableElementImplicitReference<FlatData>;
    resolveDatabase: (path: string, generatedDatabasesInScope?: Map<string, INTERNAL__LakehouseGeneratedDatabase> | undefined) => PackageableElementImplicitReference<Database>;
    resolveMapping: (path: string) => PackageableElementImplicitReference<Mapping>;
    resolveService: (path: string) => PackageableElementImplicitReference<Service>;
    resolveConnection: (path: string) => PackageableElementImplicitReference<PackageableConnection>;
    resolveRuntime: (path: string) => PackageableElementImplicitReference<PackageableRuntime>;
    resolveGenerationSpecification: (path: string) => PackageableElementImplicitReference<GenerationSpecification>;
    resolveFileGeneration: (path: string) => PackageableElementImplicitReference<FileGenerationSpecification>;
    resolveDataElement: (path: string) => PackageableElementImplicitReference<DataElement>;
    resolveDataProduct: (path: string) => PackageableElementImplicitReference<DataProduct>;
}
export declare class V1_GraphBuilderContextBuilder {
    readonly logService: LogService;
    /**
     * The (sub) graph where the current processing is taking place.
     * This information is important because each sub-graph holds their
     * own indexes for elements they are responsible for.
     *
     * e.g. dependency graph, generation graph, system graph, etc.
     */
    readonly currentSubGraph: BasicModel;
    readonly extensions: V1_GraphBuilderExtensions;
    readonly graph: PureModel;
    sectionImports: Package[];
    section?: Section | undefined;
    options?: GraphBuilderOptions | undefined;
    constructor(graph: PureModel, currentSubGraph: BasicModel, extensions: V1_GraphBuilderExtensions, logService: LogService, options?: GraphBuilderOptions);
    withElement(element: V1_PackageableElement): V1_GraphBuilderContextBuilder;
    withSection(section: Section | undefined): V1_GraphBuilderContextBuilder;
    build(): V1_GraphBuilderContext;
}
export {};
//# sourceMappingURL=V1_GraphBuilderContext.d.ts.map