@itwin/ecschema-metadata
Version:
ECObjects core concepts in typescript
291 lines • 16.5 kB
TypeScript
import { SchemaContext } from "../Context";
import { SchemaInfo } from "../Interfaces";
import { ECClass } from "../Metadata/Class";
import { Property } from "../Metadata/Property";
import { RelationshipConstraint } from "../Metadata/RelationshipClass";
import { Schema } from "../Metadata/Schema";
import { SchemaItem } from "../Metadata/SchemaItem";
import { ISchemaPartVisitor } from "../SchemaPartVisitorDelegate";
import { AbstractParserConstructor, CAProviderTuple } from "./AbstractParser";
type AnyCAContainer = Schema | ECClass | Property | RelationshipConstraint;
/**
* Specifies the version specification for the schema
* @internal
*/
export interface ECSpecVersion {
readVersion: number;
writeVersion: number;
}
/**
* This class properly handles the order the deserialization of ECSchemas and SchemaItems from serialized formats.
* For example, when deserializing an ECClass most times all base class should be de-serialized before the given class.
* @internal
*/
export declare class SchemaReadHelper<T = unknown> {
private _context;
private _visitorHelper?;
private _parserType;
private _parser;
private _schema?;
private _schemaInfo?;
constructor(parserType: AbstractParserConstructor<T>, context?: SchemaContext, visitor?: ISchemaPartVisitor);
/**
* Creates a complete SchemaInfo and starts parsing the schema from a serialized representation.
* The info and schema promise will be registered with the SchemaContext. The complete schema can be retrieved by
* calling getCachedSchema on the context.
* @param schema The Schema to populate
* @param rawSchema The serialized data to use to populate the Schema.
* @param addSchemaToCache Optional parameter that indicates if the schema should be added to the SchemaContext.
* The default is true. If false, the schema loading will not begin asynchronously in the background because the
* schema promise must be added to the context. In this case, only the SchemaInfo is returned.
*/
readSchemaInfo(schema: Schema, rawSchema: T, addSchemaToCache?: boolean): Promise<SchemaInfo>;
/**
* Populates the given Schema from a serialized representation.
* @param schema The Schema to populate
* @param rawSchema The serialized data to use to populate the Schema.
* @param addSchemaToCache Optional parameter that indicates if the schema should be added to the SchemaContext.
* The default is true. If false, the schema will be loaded directly by this method and not from the context's schema cache.
*/
readSchema(schema: Schema, rawSchema: T, addSchemaToCache?: boolean): Promise<Schema>;
/**
* Called when a SchemaItem has been successfully loaded by the Helper. The default implementation simply
* checks if the schema item is undefined. An implementation of the helper may choose to partially load
* a schema item in which case this method would indicate if the item has been fully loaded.
* @param schemaItem The SchemaItem to check.
* @returns True if the SchemaItem has been fully loaded, false otherwise.
*/
protected isSchemaItemLoaded(schemaItem: SchemaItem | undefined): boolean;
private loadSchema;
/**
* Populates the given Schema from a serialized representation.
* @param schema The Schema to populate
* @param rawSchema The serialized data to use to populate the Schema.
*/
readSchemaSync(schema: Schema, rawSchema: T): Schema;
/**
* Ensures that the schema references can be located and adds them to the schema.
* @param ref The object to read the SchemaReference's props from.
*/
private loadSchemaReference;
/**
* Ensures that the schema references can be located and adds them to the schema.
* @param ref The object to read the SchemaReference's props from.
*/
private loadSchemaReferenceSync;
/**
* Validates schema references against multiple EC rules.
* @param schema The schema to validate.
*/
private validateSchemaReferences;
/**
* Given the schema item object, the anticipated type and the name a schema item is created and loaded into the schema provided.
* @param schema The Schema the SchemaItem to.
* @param name The name of the schema item to be loaded.
* @param itemType The SchemaItemType of the item to load.
* @param schemaItemObject The Object to populate the SchemaItem with.
*/
protected loadSchemaItem(schema: Schema, name: string, itemType: string, schemaItemObject?: Readonly<unknown>): Promise<SchemaItem | undefined>;
/**
* Load the customAttribute class dependencies for a set of CustomAttribute objects and add
* them to a given custom attribute container.
* @param container The CustomAttributeContainer that each CustomAttribute will be added to.
* @param customAttributes An iterable set of parsed CustomAttribute objects.
*/
protected loadCustomAttributes(container: AnyCAContainer, caProviders: Iterable<CAProviderTuple>): Promise<void>;
/**
* Given the schema item object, the anticipated type and the name a schema item is created and loaded into the schema provided.
* @param schema The Schema the SchemaItem to.
* @param name The name of the schema item to be loaded.
* @param itemType The SchemaItemType of the item to load.
* @param schemaItemObject The Object to populate the SchemaItem with.
*/
private loadSchemaItemSync;
/**
* Given the full (Schema.ItemName) or qualified (alias:ItemName) item name, returns
* a tuple of strings in the format ["SchemaName", "ItemName"]. The schema name may be
* empty if the item comes from the schema being parsed.
* @param fullOrQualifiedName The full or qualified name of the schema item.
* @param schema The schema that will be used to lookup the schema name by alias, if necessary.
*/
private static resolveSchemaAndItemName;
/**
* Finds the a SchemaItem matching the name first by checking the schema that is being deserialized. If it does
* not exist within the schema, the SchemaContext will be searched.
* @param name The full (Schema.ItemName) or qualified (alias:ItemName) name of the SchemaItem to search for.
* @param skipVisitor Used to break Mixin -appliesTo-> Entity -extends-> Mixin cycle.
* @param loadCallBack Only called if the SchemaItem had to be loaded.
* @return The SchemaItem if it had to be loaded, otherwise undefined.
*/
private findSchemaItem;
/**
* Finds the a SchemaItem matching the name first by checking the schema that is being deserialized. If it does
* not exist within the schema, the SchemaContext will be searched.
* @param name The full (Schema.ItemName) or qualified (alias:ItemName) name of the SchemaItem to search for.
* @param skipVisitor Used to break Mixin -appliesTo-> Entity -extends-> Mixin cycle.
* @param loadCallBack Only called if the SchemaItem had to be loaded.
* @return The SchemaItem if it had to be loaded, otherwise undefined.
*/
private findSchemaItemSync;
/**
* Load dependencies on phenomenon and unitSystem for a Unit object and load the Unit from its serialized format.
* @param unit The Unit object that we are loading dependencies for and "deserializing into".
* @param rawUnit The serialized unit data
*/
private loadUnit;
/**
* Load dependencies on phenomenon and unitSystem for a Unit object and load the Unit from its serialized format.
* @param unit The Unit object that we are loading dependencies for and "deserializing into".
* @param rawUnit The serialized unit data
*/
private loadUnitSync;
/**
* Load the persistence unit and presentation unit dependencies for a KindOfQuantity object and load the KoQ from its serialized format.
* @param koq The KindOfQuantity object that we are loading dependencies for and "deserializing into".
* @param rawKoQ The serialized kind of quantity data
*/
private loadKindOfQuantity;
/**
* Load the persistence unit and presentation unit dependencies for a KindOfQuantity object and load the KoQ from its serialized format.
* @param koq The KindOfQuantity object that we are loading dependencies for and "deserializing into".
* @param rawKoQ The serialized kind of quantity data
*/
private loadKindOfQuantitySync;
/**
* Load the phenomenon dependency for a Constant object and load the Constant from its serialized format.
* @param constant The Constant object that we are loading the phenomenon dependency for
* @param rawConstant The serialized constant data
*/
private loadConstant;
/**
* Load the phenomenon dependency for a Constant object and load the Constant from its serialized format.
* @param constant The Constant object that we are loading dependencies for and "deserializing into".
* @param rawConstant The serialized constant data
*/
private loadConstantSync;
/**
* Load the unit system and invertsUnit dependencies for an Inverted Unit object and load the Inverted Unit from its serialized format.
* @param invertedUnit The InvertedUnit object that we are loading dependencies for and "deserializing into".
* @param rawInvertedUnit The serialized inverted unit data.
*/
private loadInvertedUnit;
/**
* Load the unit system and invertsUnit dependencies for an Inverted Unit object and load the Inverted Unit from its serialized format.
* @param invertedUnit The InvertedUnit object that we are loading dependencies for and "deserializing into".
* @param rawInvertedUnit The serialized inverted unit data.
*/
private loadInvertedUnitSync;
/**
* Load the unit dependencies for a Format object and load the Format from its serialized format.
* @param format The Format object that we are loading dependencies for and "deserializing into".
* @param rawFormat The serialized format data.
*/
private loadFormat;
/**
* Load the unit dependencies for a Format object and load the Format from its serialized format.
* @param format The Format object that we are loading dependencies for and "deserializing into".
* @param rawFormat The serialized format data.
*/
private loadFormatSync;
/**
* Load the base class and property type dependencies for an ECClass object and load the ECClass (and its properties) from its serialized format.
* @param classObj The ECClass object that we are loading dependencies for and "deserializing into".
* @param classProps The parsed class props object.
* @param rawClass The serialized class data.
*/
private loadClass;
/**
* Load the base class and property type dependencies for an ECClass object and load the ECClass (and its properties) from its serialized format.
* @param classObj The ECClass object that we are loading dependencies for and "deserializing into".
* @param classProps The parsed class props object.
* @param rawClass The serialized class data.
*/
private loadClassSync;
/**
* Load the mixin, base class, and property type dependencies for an EntityClass object and load the EntityClass (and properties) from its serialized format.
* @param entity The EntityClass that we are loading dependencies for and "deserializing into".
* @param rawEntity The serialized entity class data.
*/
private loadEntityClass;
/**
* Load the mixin, base class, and property type dependencies for an EntityClass object and load the EntityClass (and properties) from its serialized format.
* @param entity The EntityClass that we are loading dependencies for and "deserializing into".
* @param rawEntity The serialized entity class data.
*/
private loadEntityClassSync;
/**
* Load the appliesTo class, base class, and property type dependencies for a Mixin object and load the Mixin (and properties) from its serialized format.
* @param mixin The Mixin that we are loading dependencies for and "deserializing into".
* @param rawMixin The serialized mixin data.
*/
private loadMixin;
/**
* Load the appliesTo class, base class, and property type dependencies for a Mixin object and load the Mixin (and properties) from its serialized format.
* @param mixin The Mixin that we are loading dependencies for and "deserializing into".
* @param rawMixin The serialized mixin data.
*/
private loadMixinSync;
/**
* Load the relationship constraint, base class, and property type dependencies for a RelationshipClass object and load the RelationshipClass (and properties) from its serialized format.
* @param rel The RelationshipClass that we are loading dependencies for and "deserializing into".
* @param rawRel The serialized relationship class data.
*/
private loadRelationshipClass;
/**
* Load the relationship constraint, base class, and property type dependencies for a RelationshipClass object and load the RelationshipClass (and properties) from its serialized format.
* @param rel The RelationshipClass that we are loading dependencies for and "deserializing into".
* @param rawRel The serialized relationship class data.
*/
private loadRelationshipClassSync;
/**
* Load the abstract constraint and constraint class dependencies for a RelationshipConstraint object and load the RelationshipConstraint from its parsed props.
* @param relConstraint The RelationshipConstraint that we are loading dependencies for and "deserializing into".
* @param props The parsed relationship constraint props.
*/
private loadRelationshipConstraint;
/**
* Load the abstract constraint and constraint class dependencies for a RelationshipConstraint object and load the RelationshipConstraint from its parsed props.
* @param relConstraint The RelationshipConstraint that we are loading dependencies for and "deserializing into".
* @param props The parsed relationship constraint props.
*/
private loadRelationshipConstraintSync;
/**
* Load the type dependencies for a serialized property, then creates and deserialized the Property object in the given ECClass.
* @param classObj The ECClass that the Property should be created in.
* @param propName The name of the Property.
* @param propType The (serialized string) kind of property to create.
* @param rawProperty The serialized property data.
*/
private loadPropertyTypes;
/**
* Load the type dependencies for a serialized property, then creates and deserialized the Property object in the given ECClass.
* @param classObj The ECClass that the Property should be created in.
* @param propName The name of the Property.
* @param propType The (serialized string) kind of property to create.
* @param rawProperty The serialized property data.
*/
private loadPropertyTypesSync;
/**
* Load the propertyCategory, kindOfQuantity, and customAttribute dependencies for a Property object and load the Property from its parsed props.
* @param propertyObj The Property that we are loading dependencies for and "deserializing into".
* @param props The parsed property props.
* @param rawProperty The serialized property data.
*/
private loadProperty;
/**
* Load the propertyCategory, kindOfQuantity, and customAttribute dependencies for a Property object and load the Property from its parsed props.
* @param propertyObj The Property that we are loading dependencies for and "deserializing into".
* @param props The parsed property props.
* @param rawProperty The serialized property data.
*/
private loadPropertySync;
/**
* Load the customAttribute class dependencies for a set of CustomAttribute objects and add them to a given custom attribute container.
* @param container The CustomAttributeContainer that each CustomAttribute will be added to.
* @param customAttributes An iterable set of parsed CustomAttribute objects.
*/
private loadCustomAttributesSync;
static isECSpecVersionNewer(ecSpecVersion?: ECSpecVersion): boolean;
}
export {};
//# sourceMappingURL=Helper.d.ts.map