@itwin/core-common
Version:
iTwin.js components common to frontend and backend
104 lines • 4.52 kB
JavaScript
;
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Entities
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.Rank = exports.ExternalSourceAttachmentRole = exports.SectionType = exports.TypeDefinition = exports.RelatedElement = void 0;
exports.isPlacement2dProps = isPlacement2dProps;
exports.isPlacement3dProps = isPlacement3dProps;
const core_bentley_1 = require("@itwin/core-bentley");
const IModelError_1 = require("./IModelError");
/** The Id and relationship class of an Element that is somehow related to another Element
* @public @preview
*/
class RelatedElement {
/** The Id of the element to which this element is related. */
id;
/** The full className of the relationship class. */
relClassName;
constructor(props) {
this.id = core_bentley_1.Id64.fromJSON(props.id);
this.relClassName = props.relClassName;
}
static fromJSON(json) {
return json ? new RelatedElement(json) : undefined;
}
/** Used to *null out* an existing navigation relationship. */
static none = new RelatedElement({ id: core_bentley_1.Id64.invalid });
/** Accept the value of a navigation property that might be in the shortened format of just an id or might be in the full RelatedElement format. */
static idFromJson(json) {
if ((typeof json === "object") && ("id" in json)) {
const r = RelatedElement.fromJSON(json);
if (r === undefined)
throw new IModelError_1.IModelError(core_bentley_1.IModelStatus.BadArg, "Problem parsing Id64 from json");
return r.id;
}
return core_bentley_1.Id64.fromJSON(json);
}
toJSON() {
return {
id: this.id,
relClassName: this.relClassName,
};
}
}
exports.RelatedElement = RelatedElement;
/** A [RelatedElement]($common) relationship that describes the [TypeDefinitionElement]($backend) of an element.
* @public @preview
*/
class TypeDefinition extends RelatedElement {
}
exports.TypeDefinition = TypeDefinition;
/** determine if this is Placement2dProps
* @public @preview
*/
function isPlacement2dProps(props) {
return props.angle !== undefined;
}
/** determine if this is Placement3dProps
* @public @preview
*/
function isPlacement3dProps(props) {
return !isPlacement2dProps(props);
}
/** An enumeration of the different types of [SectionDrawing]($backend)s.
* @public @preview
* @extensions
*/
var SectionType;
(function (SectionType) {
SectionType[SectionType["Section"] = 3] = "Section";
SectionType[SectionType["Detail"] = 4] = "Detail";
SectionType[SectionType["Elevation"] = 5] = "Elevation";
SectionType[SectionType["Plan"] = 6] = "Plan";
})(SectionType || (exports.SectionType = SectionType = {}));
/** The role that an attached [ExternalSource]($backend) plays.
* @beta
*/
var ExternalSourceAttachmentRole;
(function (ExternalSourceAttachmentRole) {
/** The attached [ExternalSource]($backend) provides context. */
ExternalSourceAttachmentRole[ExternalSourceAttachmentRole["SpecifyContext"] = 0] = "SpecifyContext";
/** The attached [ExternalSource]($backend) models a part of the whole. */
ExternalSourceAttachmentRole[ExternalSourceAttachmentRole["SpecifyPart"] = 1] = "SpecifyPart";
})(ExternalSourceAttachmentRole || (exports.ExternalSourceAttachmentRole = ExternalSourceAttachmentRole = {}));
/** The *rank* for a Category
* @public @preview
* @extensions
*/
var Rank;
(function (Rank) {
/** This category is predefined by the system */
Rank[Rank["System"] = 0] = "System";
/** This category is defined by a schema. Elements in this category are not recognized by system classes. */
Rank[Rank["Domain"] = 1] = "Domain";
/** This category is defined by an application. Elements in this category are not recognized by system and schema classes. */
Rank[Rank["Application"] = 2] = "Application";
/** This category is defined by a user. Elements in this category are not recognized by system, schema, and application classes. */
Rank[Rank["User"] = 3] = "User";
})(Rank || (exports.Rank = Rank = {}));
//# sourceMappingURL=ElementProps.js.map