UNPKG

@itwin/core-common

Version:

iTwin.js components common to frontend and backend

283 lines • 13.3 kB
/** @packageDocumentation * @module Codes */ import { GuidString, Id64String } from "@itwin/core-bentley"; import { IModel } from "./IModel"; /** * The ElementId of the element that defines the scope for a Code value. * @note For insert or update, you may supply the FederationGuid of the scope element and it will be converted to the ElementId of that element. * @public * @extensions */ export type CodeScopeProps = Id64String | GuidString; /** The parameters that define a Code * @public * @extensions */ export interface CodeProps { /** Either the stringified 64-bit Id of the CodeSpec for this code, or the name of the CodeSpec. */ spec: Id64String | string; /** Either the ElementId or the FederationGuid of the element that provides the scope for this code. */ scope: CodeScopeProps; /** the value of this code. May be undefined. */ value?: string; } /** * A three-part structure containing information about the [Code]($docs/bis/guide/fundamentals/codes) of an Element * @public */ export declare class Code implements CodeProps { /** The id of the [CodeSpec]($docs/bis/guide/fundamentals/codes.md#codespec) of the Element */ spec: Id64String; /** The [CodeScope]($docs/bis/guide/fundamentals/codes.md#codescope-property) of the Element */ scope: Id64String; /** The [CodeValue]($docs/bis/guide/fundamentals/codes.md#codevalue-property) of the Element * @note Leading and trailing whitespace is invalid so is automatically trimmed. */ get value(): string; set value(val: string); private _value?; constructor(codeProps: CodeProps); /** Create an empty, non-unique code with no special meaning. */ static createEmpty(): Code; static fromJSON(json?: any): Code; toJSON(): CodeProps; equals(other: Code): boolean; /** @internal */ static equalCodes(c1: CodeProps, c2: CodeProps): boolean; /** Determine whether this Code is valid. */ static isValid(c: CodeProps): boolean; /** Determine if this code is valid but not otherwise meaningful (and therefore not necessarily unique) */ static isEmpty(c: CodeProps): boolean; toString(): string; } /** Names of the internal BIS CodeSpecs. These names match those specified by the native library. * For other domains, the best practice is to include the domain name or alias as part of the CodeSpec name to ensure global uniqueness. * @public * @extensions * @see [CodeSpec]($docs/bis/guide/fundamentals/codes.md#codespec) */ export declare enum BisCodeSpec { /** The name of the standard [[CodeSpec]] used when creating *empty* codes. * @see [[Code.createEmpty]] */ nullCodeSpec = "bis:NullCodeSpec", /** @internal */ annotationFrameStyle = "bis:AnnotationFrameStyle", /** @internal */ annotationLeaderStyle = "bis:AnnotationLeaderStyle", /** @internal */ annotationTextStyle = "bis:AnnotationTextStyle", /** The name of the standard [[CodeSpec]] used when creating codes for [AuxCoordSystem2d]($backend) elements. * @see [AuxCoordSystem2d.createCode]($backend) */ auxCoordSystem2d = "bis:AuxCoordSystem2d", /** The name of the standard [[CodeSpec]] used when creating codes for [AuxCoordSystem3d]($backend) elements. * @see [AuxCoordSystem3d.createCode]($backend) */ auxCoordSystem3d = "bis:AuxCoordSystem3d", /** The name of the standard [[CodeSpec]] used when creating codes for [AuxCoordSystemSpatial]($backend) elements. * @see [AuxCoordSystemSpatial.createCode]($backend) */ auxCoordSystemSpatial = "bis:AuxCoordSystemSpatial", /** The name of the standard [[CodeSpec]] used when creating codes for [CategorySelector]($backend) elements. * @see [CategorySelector.createCode]($backend) */ categorySelector = "bis:CategorySelector", /** @internal */ colorBook = "bis:ColorBook", /** The name of the standard [[CodeSpec]] used when creating codes for [DisplayStyle]($backend) elements. * @see [DisplayStyle.createCode]($backend) */ displayStyle = "bis:DisplayStyle", /** The name of the standard [[CodeSpec]] used when creating codes for [Drawing]($backend) elements. * @see [Drawing.createCode]($backend) */ drawing = "bis:Drawing", /** The name of the standard [[CodeSpec]] used when creating codes for [DrawingCategory]($backend) elements. * @see [DrawingCategory.createCode]($backend) */ drawingCategory = "bis:DrawingCategory", /** The name of the standard [[CodeSpec]] used when creating codes for [ExternalSource]($backend) elements. * @note This CodeSpec is not automatically created, so use [ExternalSource.ensureCodeSpec]($backend) to make sure that it exists. * @see [ExternalSource.createCode]($backend) */ externalSource = "bis:ExternalSource", /** The name of the standard [[CodeSpec]] used when creating codes for [ExternalSourceAttachment]($backend) elements. * @note This CodeSpec is not automatically created, so use [ExternalSourceAttachment.ensureCodeSpec]($backend) to make sure that it exists. * @see [ExternalSource.createCode]($backend) */ externalSourceAttachment = "bis:ExternalSourceAttachment", /** The name of the standard [[CodeSpec]] used when creating codes for [GeometryPart]($backend) elements. * @see [GeometryPart.createCode]($backend) */ geometryPart = "bis:GeometryPart", /** The name of the standard [[CodeSpec]] used when creating codes for [GraphicalType2d]($backend) elements. * @see [GraphicalType2d.createCode]($backend) */ graphicalType2d = "bis:GraphicalType2d", /** The name of the standard [[CodeSpec]] used when creating codes for [LineStyle]($backend) elements. * @see [LineStyle.createCode]($backend) */ lineStyle = "bis:LineStyle", /** The name of the standard [[CodeSpec]] used when creating codes for [LinkElement]($backend) elements. * @see [LinkElement.createCode]($backend) */ linkElement = "bis:LinkElement", /** The name of the standard [[CodeSpec]] used when creating codes for [ModelSelector]($backend) elements. * @see [ModelSelector.createCode]($backend) */ modelSelector = "bis:ModelSelector", /** The name of the standard [[CodeSpec]] used when creating codes for [PhysicalMaterial]($backend) elements. * @see [PhysicalMaterial.createCode]($backend) */ physicalMaterial = "bis:PhysicalMaterial", /** The name of the standard [[CodeSpec]] used when creating codes for [PhysicalType]($backend) elements. * @see [PhysicalType.createCode]($backend) */ physicalType = "bis:PhysicalType", /** The name of the standard [[CodeSpec]] used when creating codes for [InformationPartitionElement]($backend) elements. * @see [InformationPartitionElement.createCode]($backend) */ informationPartitionElement = "bis:InformationPartitionElement", /** The name of the standard [[CodeSpec]] used when creating codes for [RenderMaterialElement]($backend) elements. * @see [RenderMaterialElement.createCode]($backend) */ renderMaterial = "bis:RenderMaterial", /** The name of the standard [[CodeSpec]] used when creating codes for [Sheet]($backend) elements. * @see [Sheet.createCode]($backend) */ sheet = "bis:Sheet", /** The name of the standard [[CodeSpec]] used when creating codes for [SheetIndex]($backend) elements. * @see [SheetIndex.createCode]($backend) */ sheetIndex = "bis:SheetIndex", /** The name of the standard [[CodeSpec]] used when creating codes for [SheetIndexEntry]($backend) elements. * @see [SheetIndexEntry.createCode]($backend) */ sheetIndexEntry = "bis:SheetIndexEntry", /** The name of the standard [[CodeSpec]] used when creating codes for [SpatialCategory]($backend) elements. * @see [SpatialCategory.createCode]($backend) */ spatialCategory = "bis:SpatialCategory", /** The name of the standard [[CodeSpec]] used when creating codes for [SpatialLocationType]($backend) elements. * @see [SpatialLocationType.createCode]($backend) */ spatialLocationType = "bis:SpatialLocationType", /** The name of the standard [[CodeSpec]] used when creating codes for [SubCategory]($backend) elements. * @see [SubCategory.createCode]($backend) */ subCategory = "bis:SubCategory", /** The name of the standard [[CodeSpec]] used when creating codes for [Subject]($backend) elements. * @see [Subject.createCode]($backend) */ subject = "bis:Subject", /** The name of the standard [[CodeSpec]] used when creating codes for [TemplateRecipe2d]($backend) elements. * @see [TemplateRecipe2d.createCode]($backend) */ templateRecipe2d = "bis:TemplateRecipe2d", /** The name of the standard [[CodeSpec]] used when creating codes for [TemplateRecipe3d]($backend) elements. * @see [TemplateRecipe3d.createCode]($backend) */ templateRecipe3d = "bis:TemplateRecipe3d", /** @internal */ textAnnotationSeed = "bis:TextAnnotationSeed", /** The name of the standard [[CodeSpec]] used when creating codes for [Texture]($backend) elements. * @see [Texture.createCode]($backend) */ texture = "bis:Texture", /** The name of the standard [[CodeSpec]] used when creating codes for [ViewDefinition]($backend) elements. * @see [ViewDefinition.createCode]($backend) */ viewDefinition = "bis:ViewDefinition" } /** The scope of the Code. * @public */ export declare namespace CodeScopeSpec { /** The standard ways the CodeScope can be specified. * @public */ enum Type { /** The Code value must be unique within (at least) the iModel repository */ Repository = 1, /** The Code value must be unique within the scope of the Model */ Model = 2, /** The Code value must be unique among other children of the same parent element */ ParentElement = 3, /** The Code value must be unique among other elements also scoped by the same element */ RelatedElement = 4 } /** * Requirements for how the CodeScope Element is identified. * @public */ enum ScopeRequirement { /** The ElementId of CodeScope element identifies its scope. Used for Codes that are unique only within a single iModel. */ ElementId = 1, /** The FederationGuid of the CodeScope element identifies its scope. Used for Codes that are globally unique. */ FederationGuid = 2 } } /** * The JSON properties of a CodeSpec * @public */ export interface CodeSpecProperties { scopeSpec: { /** the type of CodeSpec */ type: CodeScopeSpec.Type; /** If true, the federationGuid of the scope element identifies the scope, for Codes that are globally unique. * Otherwise, the ElementId of the scopeElement is used, for Codes that are scoped only within a single iModel. */ fGuidRequired?: boolean; /** The relationship className (in the form "schema:class"), when `type` is `CodeScopeSpec.Type.RelatedElement` */ relationship?: string; }; spec?: { isManagedWithDgnDb?: boolean; }; version?: string; } /** A [Code Specification]($docs/bis/guide/references/glossary#codespec) captures the rules for encoding and decoding significant business information into * and from a Code (string). This specification is used to generate and validate Codes. * * A CodeSpec defines the format of a Code for a certain type of Element in an IModel. * A CodeSpec can identify an external system that maintains and/or assigns Codes. * @public */ export declare class CodeSpec { /** The iModel holding this CodeSpec. */ iModel: IModel; /** The id of this CodeSpec. */ id: Id64String; /** The name of this CodeSpec. */ name: string; /** The JSON properties for this CodeSpec. * @note Use the getters and setters instead of accessing this directly. * @internal */ properties: CodeSpecProperties; private constructor(); /** Create a new CodeSpec from the specified parameters * > Note: CodeSpec.id will not be valid until inserted * @see [CodeSpecs.insert]($backend) */ static create(iModel: IModel, name: string, scopeType: CodeScopeSpec.Type, scopeReq?: CodeScopeSpec.ScopeRequirement): CodeSpec; /** Create a new CodeSpec directly from JSON. Used internally by the CodeSpecs.load function. * @internal */ static createFromJson(iModel: IModel, id: Id64String, name: string, properties?: CodeSpecProperties): CodeSpec; /** Will be true if the id of this CodeSpec is valid. */ get isValid(): boolean; get isExternal(): boolean; /** The scope type of this CodeSpec. */ get scopeType(): CodeScopeSpec.Type; set scopeType(scopeType: CodeScopeSpec.Type); /** Will be `CodeScopeSpec.ScopeRequirement.FederationGuid` if the scoping element is required to have a FederationGuid or * CodeScopeSpec.ScopeRequirement.ElementId` otherwise (the default). */ get scopeReq(): CodeScopeSpec.ScopeRequirement; set scopeReq(req: CodeScopeSpec.ScopeRequirement); } //# sourceMappingURL=Code.d.ts.map