UNPKG

@itwin/core-common

Version:

iTwin.js components common to frontend and backend

53 lines 2.49 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module Schema */ /** * Types of concrete entities. Used for storing strings in JavaScript reference-equality containers which encode * low-level entity information. * @note the values of this enum are unstable, do not depend upon their values between versions of iTwin.js * (e.g. do not serialize them and load them in another version of iTwin.js and expect them to work) * CodeSpecs are excepted since their JavaScript representation does not derive from [Entity]($backend) * @note the string value of each variant is required/guaranteed to be 1 character * @see EntityReference * @alpha */ export var ConcreteEntityTypes; (function (ConcreteEntityTypes) { ConcreteEntityTypes["Model"] = "m"; ConcreteEntityTypes["Element"] = "e"; ConcreteEntityTypes["ElementAspect"] = "a"; ConcreteEntityTypes["Relationship"] = "r"; })(ConcreteEntityTypes || (ConcreteEntityTypes = {})); /** * Adds some utilities to the [[ConcreteEntityTypes]] enum * @alpha */ (function (ConcreteEntityTypes) { const toBisCoreRootClassFullNameMap = { [ConcreteEntityTypes.Model]: "BisCore:Model", [ConcreteEntityTypes.Element]: "BisCore:Element", [ConcreteEntityTypes.ElementAspect]: "BisCore:ElementAspect", [ConcreteEntityTypes.Relationship]: "BisCore:Relationship", }; /** used by the transformer to figure out where to check for the existence in a db of a concrete element id * @internal */ function toBisCoreRootClassFullName(type) { return toBisCoreRootClassFullNameMap[type]; } ConcreteEntityTypes.toBisCoreRootClassFullName = toBisCoreRootClassFullName; })(ConcreteEntityTypes || (ConcreteEntityTypes = {})); /** A set of concrete entity ids, with additional functions to more literately add ids where you have the raw id and know what type it is * @alpha */ export class EntityReferenceSet extends Set { addElement(id) { this.add(`e${id}`); } addModel(id) { this.add(`m${id}`); } addAspect(id) { this.add(`a${id}`); } addRelationship(id) { this.add(`r${id}`); } } //# sourceMappingURL=EntityReference.js.map