@itwin/core-backend 5.9.0-dev.15 → 5.9.0-dev.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +6 -3
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.d.ts +9 -1
- package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +7 -1
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/ChangesetReader.d.ts +186 -0
- package/lib/cjs/ChangesetReader.d.ts.map +1 -0
- package/lib/cjs/ChangesetReader.js +372 -0
- package/lib/cjs/ChangesetReader.js.map +1 -0
- package/lib/cjs/ChangesetReaderTypes.d.ts +120 -0
- package/lib/cjs/ChangesetReaderTypes.d.ts.map +1 -0
- package/lib/cjs/ChangesetReaderTypes.js +23 -0
- package/lib/cjs/ChangesetReaderTypes.js.map +1 -0
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/EditTxn.d.ts +49 -3
- package/lib/cjs/EditTxn.d.ts.map +1 -1
- package/lib/cjs/EditTxn.js +24 -9
- package/lib/cjs/EditTxn.js.map +1 -1
- package/lib/cjs/Element.d.ts +69 -0
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +36 -0
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementGraphics.js.map +1 -1
- package/lib/cjs/ExternalSource.js.map +1 -1
- package/lib/cjs/GeographicCRSServices.d.ts +15 -0
- package/lib/cjs/GeographicCRSServices.d.ts.map +1 -1
- package/lib/cjs/GeographicCRSServices.js +13 -4
- package/lib/cjs/GeographicCRSServices.js.map +1 -1
- package/lib/cjs/IModelIncrementalSchemaLocater.js.map +1 -1
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/Model.d.ts +34 -0
- package/lib/cjs/Model.d.ts.map +1 -1
- package/lib/cjs/Model.js +24 -0
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/PartialChangeUnifier.d.ts +77 -0
- package/lib/cjs/PartialChangeUnifier.d.ts.map +1 -0
- package/lib/cjs/PartialChangeUnifier.js +234 -0
- package/lib/cjs/PartialChangeUnifier.js.map +1 -0
- package/lib/cjs/SheetIndex.js.map +1 -1
- package/lib/cjs/SqliteChangesetReader.d.ts.map +1 -1
- package/lib/cjs/SqliteChangesetReader.js +1 -1
- package/lib/cjs/SqliteChangesetReader.js.map +1 -1
- package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -1
- package/lib/cjs/core-backend.d.ts +3 -0
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +3 -0
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/esm/BriefcaseManager.d.ts.map +1 -1
- package/lib/esm/BriefcaseManager.js +6 -3
- package/lib/esm/BriefcaseManager.js.map +1 -1
- package/lib/esm/ChangesetECAdaptor.d.ts +9 -1
- package/lib/esm/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/esm/ChangesetECAdaptor.js +7 -1
- package/lib/esm/ChangesetECAdaptor.js.map +1 -1
- package/lib/esm/ChangesetReader.d.ts +186 -0
- package/lib/esm/ChangesetReader.d.ts.map +1 -0
- package/lib/esm/ChangesetReader.js +368 -0
- package/lib/esm/ChangesetReader.js.map +1 -0
- package/lib/esm/ChangesetReaderTypes.d.ts +120 -0
- package/lib/esm/ChangesetReaderTypes.d.ts.map +1 -0
- package/lib/esm/ChangesetReaderTypes.js +20 -0
- package/lib/esm/ChangesetReaderTypes.js.map +1 -0
- package/lib/esm/ConcurrentQuery.js.map +1 -1
- package/lib/esm/DevTools.js.map +1 -1
- package/lib/esm/DisplayStyle.js.map +1 -1
- package/lib/esm/ECSqlStatement.d.ts.map +1 -1
- package/lib/esm/ECSqlStatement.js.map +1 -1
- package/lib/esm/EditTxn.d.ts +49 -3
- package/lib/esm/EditTxn.d.ts.map +1 -1
- package/lib/esm/EditTxn.js +23 -8
- package/lib/esm/EditTxn.js.map +1 -1
- package/lib/esm/Element.d.ts +69 -0
- package/lib/esm/Element.d.ts.map +1 -1
- package/lib/esm/Element.js +36 -0
- package/lib/esm/Element.js.map +1 -1
- package/lib/esm/ElementGraphics.js.map +1 -1
- package/lib/esm/ExternalSource.js.map +1 -1
- package/lib/esm/GeographicCRSServices.d.ts +15 -0
- package/lib/esm/GeographicCRSServices.d.ts.map +1 -1
- package/lib/esm/GeographicCRSServices.js +12 -4
- package/lib/esm/GeographicCRSServices.js.map +1 -1
- package/lib/esm/IModelIncrementalSchemaLocater.js.map +1 -1
- package/lib/esm/IpcHost.js.map +1 -1
- package/lib/esm/Model.d.ts +34 -0
- package/lib/esm/Model.d.ts.map +1 -1
- package/lib/esm/Model.js +24 -0
- package/lib/esm/Model.js.map +1 -1
- package/lib/esm/PartialChangeUnifier.d.ts +77 -0
- package/lib/esm/PartialChangeUnifier.d.ts.map +1 -0
- package/lib/esm/PartialChangeUnifier.js +230 -0
- package/lib/esm/PartialChangeUnifier.js.map +1 -0
- package/lib/esm/SheetIndex.js.map +1 -1
- package/lib/esm/SqliteChangesetReader.d.ts.map +1 -1
- package/lib/esm/SqliteChangesetReader.js +1 -1
- package/lib/esm/SqliteChangesetReader.js.map +1 -1
- package/lib/esm/annotations/TextAnnotationElement.js.map +1 -1
- package/lib/esm/core-backend.d.ts +3 -0
- package/lib/esm/core-backend.d.ts.map +1 -1
- package/lib/esm/core-backend.js +3 -0
- package/lib/esm/core-backend.js.map +1 -1
- package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/esm/test/ElementDrivesElement.test.d.ts.map +1 -1
- package/lib/esm/test/ElementDrivesElement.test.js.map +1 -1
- package/lib/esm/test/annotations/LeaderGeometry.test.js +0 -1
- package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
- package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
- package/lib/esm/test/element/DeleteDefinitionElements.test.js +40 -31
- package/lib/esm/test/element/DeleteDefinitionElements.test.js.map +1 -1
- package/lib/esm/test/element/SheetInformationAspect.test.js.map +1 -1
- package/lib/esm/test/hubaccess/Rebase.test.js +1 -1
- package/lib/esm/test/hubaccess/Rebase.test.js.map +1 -1
- package/lib/esm/test/misc/GeoServices.test.js +43 -1
- package/lib/esm/test/misc/GeoServices.test.js.map +1 -1
- package/lib/esm/test/sheetindex/SheetIndex.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangesetReader.test.js +4184 -1654
- package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
- package/lib/esm/test/standalone/DeleteElements.test.js +39 -15
- package/lib/esm/test/standalone/DeleteElements.test.js.map +1 -1
- package/lib/esm/test/standalone/GeometryStream.test.js.map +1 -1
- package/lib/esm/test/standalone/IntegrityCheck.test.js +1 -1
- package/lib/esm/test/standalone/IntegrityCheck.test.js.map +1 -1
- package/lib/esm/test/standalone/SQliteChangesetReaderAndChangesetECAdaptor.test.d.ts +2 -0
- package/lib/esm/test/standalone/SQliteChangesetReaderAndChangesetECAdaptor.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/SQliteChangesetReaderAndChangesetECAdaptor.test.js +1862 -0
- package/lib/esm/test/standalone/SQliteChangesetReaderAndChangesetECAdaptor.test.js.map +1 -0
- package/lib/esm/test/standalone/ViewDefinition.test.js +1 -1
- package/lib/esm/test/standalone/ViewDefinition.test.js.map +1 -1
- package/lib/esm/test/standalone/Workspace.test.js.map +1 -1
- package/package.json +14 -14
package/lib/cjs/Model.js.map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------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Models\n */\n\n// cspell:ignore elid\n\nimport { GuidString, Id64String, JsonUtils } from \"@itwin/core-bentley\";\nimport { Point2d, Range3d } from \"@itwin/core-geometry\";\nimport {\n AxisAlignedBox3d, ElementProps, EntityReferenceSet, GeometricModel2dProps, GeometricModel3dProps, GeometricModelProps, IModel,\n InformationPartitionElementProps, ModelProps, RelatedElement,\n} from \"@itwin/core-common\";\nimport { DefinitionPartition, DocumentPartition, InformationRecordPartition, PhysicalPartition, SheetIndexPartition, SpatialLocationPartition } from \"./Element\";\nimport { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow, Entity } from \"./Entity\";\nimport { EditTxn } from \"./EditTxn\";\nimport { IModelDb } from \"./IModelDb\";\nimport { SubjectOwnsPartitionElements } from \"./NavigationRelationship\";\nimport { _cache, _implicitTxn, _nativeDb, _verifyChannel } from \"./internal/Symbols\";\n\n/** Argument for the `Model.onXxx` static methods\n * @beta\n */\nexport interface OnModelArg {\n /** The iModel for the Model affected. */\n iModel: IModelDb;\n}\n\n/** Argument for the `Model.onXxx` static methods that supply the properties of a Model to be inserted or updated.\n * @beta\n */\nexport interface OnModelPropsArg extends OnModelArg {\n /** The new properties of the Model affected. */\n props: Readonly<ModelProps>;\n}\n\n/** Argument for the `Model.onXxx` static methods that only supply the Id of the affected Model.\n * @beta\n */\nexport interface OnModelIdArg extends OnModelArg {\n /** The Id of the Model affected */\n id: Id64String;\n}\n\n/** Argument for the `Model.onXxxElement` static methods that supply the properties of an Element for a Model.\n * @beta\n */\nexport interface OnElementInModelPropsArg extends OnModelIdArg {\n /** The new properties of an Element for the affected Model */\n elementProps: Readonly<ElementProps>;\n}\n\n/** Argument for the `Model.onXxxElement` static methods that supply the Id of an Element for a Model.\n * @beta\n */\nexport interface OnElementInModelIdArg extends OnModelIdArg {\n /** The Id of the Element for the affected Model */\n elementId: Id64String;\n}\n\n/** A Model is a container for persisting a collection of related elements within an iModel.\n * See [[IModelDb.Models]] for how to query and manage the Models in an IModelDb.\n * See [Creating models]($docs/learning/backend/CreateModels.md)\n * @public @preview\n */\nexport class Model extends Entity {\n public static override get className(): string { return \"Model\"; }\n /** @internal */\n public static override get protectedOperations() { return [\"onInsert\", \"onUpdate\", \"onDelete\"]; }\n public readonly modeledElement: RelatedElement;\n public readonly name: string;\n public readonly parentModel?: Id64String;\n public readonly jsonProperties: { [key: string]: any };\n public isPrivate: boolean;\n public isTemplate: boolean;\n\n protected constructor(props: ModelProps, iModel: IModelDb) {\n super(props, iModel);\n this.modeledElement = new RelatedElement(props.modeledElement);\n this.name = props.name ? props.name : \"\"; // NB this isn't really a property of Model (it's the code.value of the modeled element), but it comes in ModelProps because it's often needed\n this.parentModel = props.parentModel;\n this.isPrivate = JsonUtils.asBool(props.isPrivate);\n this.isTemplate = JsonUtils.asBool(props.isTemplate);\n this.jsonProperties = { ...props.jsonProperties }; // make sure we have our own copy\n }\n\n /**\n * Model custom HandledProps includes 'isPrivate', 'isTemplate', and 'lastMod'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"isPrivate\", source: \"Class\" },\n { propertyName: \"isTemplate\", source: \"Class\" },\n { propertyName: \"lastMod\", source: \"Class\" },\n ];\n\n /**\n * Model deserializes 'isPrivate', and 'isTemplate', and sets the proper parentModel.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): ModelProps {\n const instance = props.row;\n const modelProps = super.deserialize(props) as ModelProps;\n const modeledElementProps = props.iModel.elements.tryGetElementProps(instance.modeledElement.id);\n if (modeledElementProps) {\n // ModeledElement may be undefined in the case of root Element\n modelProps.name = JsonUtils.asString(modeledElementProps.code.value);\n if (instance.parentModel !== undefined)\n modelProps.parentModel = instance.parentModel.id;\n else\n modelProps.parentModel = modeledElementProps.model;\n }\n if (instance.isPrivate === true)\n modelProps.isPrivate = true;\n if (instance.isTemplate === true)\n modelProps.isTemplate = true;\n return modelProps;\n }\n\n /**\n * Model serializes 'isPrivate', and 'isTemplate'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: ModelProps, _iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, _iModel);\n inst.isPrivate = props.isPrivate ?? false;\n inst.isTemplate = props.isTemplate ?? false;\n return inst;\n }\n\n public override toJSON(): ModelProps {\n const val = super.toJSON() as ModelProps;\n val.name = this.name; // for cloning\n return val;\n }\n\n /** Called before a new Model is inserted.\n * @note throw an exception to disallow the insert\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model to be inserted\n * @beta\n */\n protected static onInsert(arg: OnModelPropsArg): void {\n const { props, iModel } = arg;\n iModel.channels[_verifyChannel](props.modeledElement.id);\n if (props.parentModel) // inserting requires shared lock on parent, if present\n iModel.locks.checkSharedLock(props.parentModel, \"parent model\", \"insert\");\n }\n\n /** Called after a new Model is inserted.\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model that was inserted\n * @beta\n */\n protected static onInserted(_arg: OnModelIdArg): void {\n // we don't need to tell LockControl about models being created - their ModeledElement does that\n }\n\n /** Called before a Model is updated.\n * @note throw an exception to disallow the update\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model to be updated\n * @beta\n */\n protected static onUpdate(arg: OnModelPropsArg): void {\n const id = arg.props.id!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n arg.iModel.channels[_verifyChannel](id);\n arg.iModel.locks.checkExclusiveLock(id, \"model\", \"update\");\n }\n\n /** Called after a Model is updated.\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model that was updated.\n * @beta\n */\n protected static onUpdated(arg: OnModelIdArg): void {\n arg.iModel.models[_cache].delete(arg.id);\n }\n\n /** Called before a Model is deleted.\n * @note throw an exception to disallow the delete\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model to be deleted\n * @beta\n */\n protected static onDelete(arg: OnModelIdArg): void {\n arg.iModel.channels[_verifyChannel](arg.id);\n arg.iModel.locks.checkExclusiveLock(arg.id, \"model\", \"delete\");\n }\n\n /** Called after a Model was deleted.\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model that was deleted\n * @beta\n */\n protected static onDeleted(arg: OnModelIdArg): void {\n arg.iModel.models[_cache].delete(arg.id);\n arg.iModel.elements[_cache].deleteWithModel(arg.id);\n }\n\n /** Called before a prospective Element is to be inserted into an instance of a Model of this class.\n * @note throw an exception to disallow the insert\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model to hold the element\n * @beta\n */\n protected static onInsertElement(_arg: OnElementInModelPropsArg): void { }\n\n /** Called after an Element has been inserted into an instance of a Model of this class.\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model holding the element\n * @beta\n */\n protected static onInsertedElement(arg: OnElementInModelIdArg): void {\n arg.iModel.models[_cache].delete(arg.id);\n }\n\n /** Called when an Element in an instance of a Model of this class is about to be updated.\n * @note throw an exception to disallow the update\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model holding the element\n * @beta\n */\n protected static onUpdateElement(_arg: OnElementInModelPropsArg): void { }\n\n /** Called after an Element in an instance of a Model of this class has been updated.\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model holding the element\n * @beta\n */\n protected static onUpdatedElement(arg: OnElementInModelIdArg): void {\n arg.iModel.models[_cache].delete(arg.id);\n }\n\n /** Called when an Element in an instance of a Model of this class is about to be deleted.\n * @note throw an exception to disallow the delete\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model holding the element\n * @beta\n */\n protected static onDeleteElement(_arg: OnElementInModelIdArg): void { }\n\n /** Called after an Element in an instance of a Model of this class has been deleted.\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model that held the element\n * @beta\n */\n protected static onDeletedElement(arg: OnElementInModelIdArg): void {\n arg.iModel.models[_cache].delete(arg.id);\n }\n\n private getAllUserProperties(): any {\n if (!this.jsonProperties.UserProps)\n this.jsonProperties.UserProps = new Object();\n\n return this.jsonProperties.UserProps;\n }\n\n /** Get a set of JSON user properties by namespace */\n public getUserProperties(namespace: string) { return this.getAllUserProperties()[namespace]; }\n\n /** Change a set of user JSON properties of this Element by namespace. */\n public setUserProperties(nameSpace: string, value: any) { this.getAllUserProperties()[nameSpace] = value; }\n\n /** Remove a set of JSON user properties, specified by namespace, from this Element */\n public removeUserProperties(nameSpace: string) { delete this.getAllUserProperties()[nameSpace]; }\n\n public getJsonProperty(name: string): any { return this.jsonProperties[name]; }\n public setJsonProperty(name: string, value: any) { this.jsonProperties[name] = value; }\n\n /**\n * Insert this Model in the iModel using the supplied EditTxn.\n * @beta\n */\n public insert(txn: EditTxn): Id64String;\n /**\n * Insert this Model in the iModel.\n * @deprecated Use Model.insert(txn) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\n */\n public insert(): Id64String;\n public insert(txn?: EditTxn) { return this.id = (txn ?? this.iModel[_implicitTxn]).insertModel(this.toJSON()); }\n\n /**\n * Update this Model in the iModel using the supplied EditTxn.\n * @beta\n */\n public update(txn: EditTxn): void;\n /**\n * Update this Model in the iModel.\n * @deprecated Use Model.update(txn) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\n */\n public update(): void;\n public update(txn?: EditTxn) { (txn ?? this.iModel[_implicitTxn]).updateModel(this.toJSON()); }\n\n /**\n * Delete this Model from the iModel using the supplied EditTxn.\n * @beta\n */\n public delete(txn: EditTxn): void;\n /**\n * Delete this Model from the iModel.\n * @deprecated Use Model.delete(txn) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\n */\n public delete(): void;\n public delete(txn?: EditTxn) { (txn ?? this.iModel[_implicitTxn]).deleteModel(this.id); }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n if (this.parentModel)\n referenceIds.addModel(this.parentModel);\n referenceIds.addElement(this.modeledElement.id);\n }\n}\n\n/** A container for persisting geometric elements.\n * @public @preview\n */\nexport class GeometricModel extends Model {\n public geometryGuid?: GuidString;\n\n public static override get className(): string { return \"GeometricModel\"; }\n\n protected constructor(props: GeometricModelProps, iModel: IModelDb) {\n super(props, iModel);\n this.geometryGuid = props.geometryGuid;\n }\n\n /** Query for the union of the extents of the elements contained by this model.\n * @note This function blocks the JavaScript event loop. Consider using [[queryRange]] instead.\n */\n public queryExtents(): AxisAlignedBox3d {\n const extents = this.iModel[_nativeDb].queryModelExtents({ id: this.id }).modelExtents;\n return Range3d.fromJSON(extents);\n }\n\n /** Query for the union of the extents of all elements contained within this model. */\n public async queryRange(): Promise<AxisAlignedBox3d> {\n return this.iModel.models.queryRange(this.id);\n }\n}\n\n/** A container for persisting 3d geometric elements.\n * @public @preview\n */\nexport abstract class GeometricModel3d extends GeometricModel {\n /** If true, then the elements in this GeometricModel3d are expected to be in an XY plane.\n * @note The associated ECProperty was added to the BisCore schema in version 1.0.8\n */\n public readonly isPlanProjection: boolean;\n /** If true, then the elements in this GeometricModel3d are not in real-world coordinates and will not be in the spatial index.\n * @note The associated ECProperty was added to the BisCore schema in version 1.0.8\n */\n public readonly isNotSpatiallyLocated: boolean;\n /** If true, then the elements in this GeometricModel3d are in real-world coordinates and will be in the spatial index. */\n public get isSpatiallyLocated(): boolean { return !this.isNotSpatiallyLocated; }\n\n public static override get className(): string { return \"GeometricModel3d\"; }\n\n protected constructor(props: GeometricModel3dProps, iModel: IModelDb) {\n super(props, iModel);\n this.isNotSpatiallyLocated = JsonUtils.asBool(props.isNotSpatiallyLocated);\n this.isPlanProjection = JsonUtils.asBool(props.isPlanProjection);\n }\n\n /**\n * GeometricModel3d custom HandledProps includes 'isPlanProjection', and 'isNotSpatiallyLocated'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"isPlanProjection\", source: \"Class\" },\n { propertyName: \"isNotSpatiallyLocated\", source: \"Class\" },\n ];\n\n /**\n * GeometricModel3d deserializes 'isPlanProjection', and 'isNotSpatiallyLocated'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): GeometricModel3dProps {\n const modelProps = super.deserialize(props) as GeometricModel3dProps;\n const instance = props.row;\n if (instance.isNotSpatiallyLocated === true || instance.isTemplate === true)\n modelProps.isNotSpatiallyLocated = true;\n if (instance.isPlanProjection === true)\n modelProps.isPlanProjection = true;\n return modelProps;\n }\n\n /**\n * GeometricModel3d serializes 'isPlanProjection', and 'isNotSpatiallyLocated'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: GeometricModel3dProps, _iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, _iModel);\n inst.isNotSpatiallyLocated = props.isNotSpatiallyLocated ?? false;\n inst.isPlanProjection = props.isPlanProjection ?? false;\n return inst;\n }\n\n public override toJSON(): GeometricModel3dProps {\n const val = super.toJSON() as GeometricModel3dProps;\n if (this.isNotSpatiallyLocated)\n val.isNotSpatiallyLocated = true;\n\n if (this.isPlanProjection)\n val.isPlanProjection = true;\n\n return val;\n }\n}\n\n/** A container for persisting 2d geometric elements.\n * @public @preview\n */\nexport abstract class GeometricModel2d extends GeometricModel {\n /** The actual coordinates of (0,0) in modeling coordinates. An offset applied to all modeling coordinates. */\n public globalOrigin?: Point2d;\n public static override get className(): string { return \"GeometricModel2d\"; }\n\n protected constructor(props: GeometricModel2dProps, iModel: IModelDb) {\n super(props, iModel);\n this.globalOrigin = props.globalOrigin ? Point2d.fromJSON(props.globalOrigin) : undefined;\n }\n\n public override toJSON(): GeometricModel2dProps {\n const val = super.toJSON() as GeometricModel2dProps;\n if (undefined !== this.globalOrigin)\n val.globalOrigin = Point2d.fromJSON(this.globalOrigin);\n\n return val;\n }\n}\n\n/** A container for persisting 2d graphical elements.\n * @public @preview\n */\nexport abstract class GraphicalModel2d extends GeometricModel2d {\n public static override get className(): string { return \"GraphicalModel2d\"; }\n}\n\n/** A container for persisting GraphicalElement3d instances.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.8\n * @see [[GraphicalPartition3d]]\n * @public @preview\n */\nexport abstract class GraphicalModel3d extends GeometricModel3d {\n public static override get className(): string { return \"GraphicalModel3d\"; }\n}\n\n/** A container for persisting 3d geometric elements that are spatially located.\n * @public @preview\n */\nexport abstract class SpatialModel extends GeometricModel3d {\n public static override get className(): string { return \"SpatialModel\"; }\n}\n\n/** A container for persisting physical elements that model physical space.\n * @see [[PhysicalPartition]]\n * @public @preview\n */\nexport class PhysicalModel extends SpatialModel {\n public static override get className(): string { return \"PhysicalModel\"; }\n /** Insert a PhysicalPartition and a PhysicalModel that sub-models it using an explicit transaction.\n * @param txn The EditTxn used to perform inserts.\n * @param parentSubjectId The PhysicalPartition will be inserted as a child of this Subject element.\n * @param name The name of the PhysicalPartition that the new PhysicalModel will sub-model.\n * @param isPlanProjection Optional value (default is false) that indicates if the contents of this model are expected to be in an XY plane.\n * @returns The Id of the newly inserted PhysicalPartition and PhysicalModel (same value).\n * @throws [[IModelError]] if there is an insert problem.\n * @beta\n */\n public static insert(txn: EditTxn, parentSubjectId: Id64String, name: string, isPlanProjection?: boolean): Id64String;\n /** @deprecated Use PhysicalModel.insert(txn, ...) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help. */\n public static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string, isPlanProjection?: boolean): Id64String;\n public static insert(txnOrDb: EditTxn | IModelDb, parentSubjectId: Id64String, name: string, isPlanProjection?: boolean): Id64String {\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\n const iModelDb = txn.iModel;\n const partitionProps: InformationPartitionElementProps = {\n classFullName: PhysicalPartition.classFullName,\n model: IModel.repositoryModelId,\n parent: new SubjectOwnsPartitionElements(parentSubjectId),\n code: PhysicalPartition.createCode(iModelDb, parentSubjectId, name),\n };\n const partitionId = txn.insertElement(partitionProps);\n const modelProps: GeometricModel3dProps = {\n classFullName: this.classFullName,\n modeledElement: { id: partitionId },\n isPlanProjection,\n };\n return txn.insertModel(modelProps);\n }\n}\n\n/** A container for persisting spatial location elements.\n * @see [[SpatialLocationPartition]]\n * @public @preview\n */\nexport class SpatialLocationModel extends SpatialModel {\n public static override get className(): string { return \"SpatialLocationModel\"; }\n /** Insert a SpatialLocationPartition and a SpatialLocationModel that sub-models it using an explicit transaction.\n * @param txn The EditTxn used to perform inserts.\n * @param parentSubjectId The SpatialLocationPartition will be inserted as a child of this Subject element.\n * @param name The name of the SpatialLocationPartition that the new SpatialLocationModel will sub-model.\n * @param isPlanProjection Optional value (default is false) that indicates if the contents of this model are expected to be in an XY plane.\n * @returns The Id of the newly inserted SpatialLocationPartition and SpatialLocationModel (same value).\n * @throws [[IModelError]] if there is an insert problem.\n * @beta\n */\n public static insert(txn: EditTxn, parentSubjectId: Id64String, name: string, isPlanProjection?: boolean): Id64String;\n /** @deprecated Use SpatialLocationModel.insert(txn, ...) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help. */\n public static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string, isPlanProjection?: boolean): Id64String;\n public static insert(txnOrDb: EditTxn | IModelDb, parentSubjectId: Id64String, name: string, isPlanProjection?: boolean): Id64String {\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\n const iModelDb = txn.iModel;\n const partitionProps: InformationPartitionElementProps = {\n classFullName: SpatialLocationPartition.classFullName,\n model: IModel.repositoryModelId,\n parent: new SubjectOwnsPartitionElements(parentSubjectId),\n code: SpatialLocationPartition.createCode(iModelDb, parentSubjectId, name),\n };\n const partitionId = txn.insertElement(partitionProps);\n const modelProps: GeometricModel3dProps = {\n classFullName: this.classFullName,\n modeledElement: { id: partitionId },\n isPlanProjection,\n };\n return txn.insertModel(modelProps);\n }\n}\n\n/** A 2d model that holds [[DrawingGraphic]]s. DrawingModels may be dimensional or non-dimensional.\n * @public @preview\n */\nexport class DrawingModel extends GraphicalModel2d {\n public static override get className(): string { return \"DrawingModel\"; }\n}\n\n/** A container for persisting section [[DrawingGraphic]]s.\n * @public @preview\n */\nexport class SectionDrawingModel extends DrawingModel {\n public static override get className(): string { return \"SectionDrawingModel\"; }\n}\n\n/** A container for persisting [[ViewAttachment]]s and [[DrawingGraphic]]s.\n * A SheetModel is a digital representation of a *sheet of paper*. SheetModels are 2d models in bounded paper coordinates.\n * SheetModels may contain annotation Elements as well as references to 2d or 3d Views.\n * @public @preview\n */\nexport class SheetModel extends GraphicalModel2d {\n public static override get className(): string { return \"SheetModel\"; }\n}\n\n/** A container for persisting role elements.\n * @public @preview\n */\nexport class RoleModel extends Model {\n public static override get className(): string { return \"RoleModel\"; }\n}\n\n/** A container for persisting information elements.\n * @public @preview\n */\nexport abstract class InformationModel extends Model {\n public static override get className(): string { return \"InformationModel\"; }\n}\n\n/** A container for persisting group information elements.\n * @see [[GroupInformationPartition]]\n * @public @preview\n */\nexport abstract class GroupInformationModel extends InformationModel {\n public static override get className(): string { return \"GroupInformationModel\"; }\n}\n\n/** A sub-model of a [[SheetIndexPartition]] serving as a container for persisting [[SheetIndexEntry]] and [[SheetIndex]] elements.\n * @beta\n */\nexport class SheetIndexModel extends InformationModel {\n public static override get className(): string { return \"SheetIndexModel\"; }\n\n /** Insert a [[SheetIndexPartition]] and a SheetIndexModel that sub-models it.\n * @param txn The active EditTxn.\n * @param parentSubjectId The SheetIndexPartition will be inserted as a child of this Subject element.\n * @param name The name of the SheetIndexPartition that the new SheetIndexModel will sub-model.\n * @returns The Id of the newly inserted SheetIndexModel.\n * @throws [[IModelError]] if there is an insert problem.\n */\n public static insert(txn: EditTxn, parentSubjectId: Id64String, name: string): Id64String;\n /** @deprecated Use SheetIndexModel.insert(txn, ...) instead. */\n public static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string): Id64String;\n public static insert(txnOrDb: EditTxn | IModelDb, parentSubjectId: Id64String, name: string): Id64String {\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\n const partitionId = txn.insertElement({\n classFullName: SheetIndexPartition.classFullName,\n model: IModel.repositoryModelId,\n parent: new SubjectOwnsPartitionElements(parentSubjectId),\n code: SheetIndexPartition.createCode(txn.iModel, parentSubjectId, name),\n });\n return txn.insertModel({\n classFullName: this.classFullName,\n modeledElement: { id: partitionId },\n });\n }\n}\n\n/** A container for persisting Information Record Elements\n * @see [[InformationRecordPartition]]\n * @public @preview\n */\nexport class InformationRecordModel extends InformationModel {\n public static override get className(): string { return \"InformationRecordModel\"; }\n\n /** Insert an InformationRecordPartition and an InformationRecordModel that sub-models it using an explicit transaction.\n * @param txn The EditTxn used to perform inserts.\n * @param parentSubjectId The InformationRecordPartition will be inserted as a child of this Subject element.\n * @param name The name of the InformationRecordPartition that the new InformationRecordModel will sub-model.\n * @returns The Id of the newly inserted InformationRecordModel.\n * @throws [[IModelError]] if there is an insert problem.\n * @beta\n */\n public static insert(txn: EditTxn, parentSubjectId: Id64String, name: string): Id64String;\n public static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string): Id64String;\n public static insert(txnOrDb: EditTxn | IModelDb, parentSubjectId: Id64String, name: string): Id64String {\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\n const partitionId = txn.insertElement({\n classFullName: InformationRecordPartition.classFullName,\n model: IModel.repositoryModelId,\n parent: new SubjectOwnsPartitionElements(parentSubjectId),\n code: InformationRecordPartition.createCode(txn.iModel, parentSubjectId, name),\n });\n return txn.insertModel({\n classFullName: this.classFullName,\n modeledElement: { id: partitionId },\n });\n }\n}\n\n/** A container for persisting definition elements.\n * @see [[DefinitionPartition]]\n * @public @preview\n */\nexport class DefinitionModel extends InformationModel {\n public static override get className(): string { return \"DefinitionModel\"; }\n\n /** Insert a DefinitionPartition and a DefinitionModel that sub-models it.\n * @param txn The active EditTxn.\n * @param parentSubjectId The DefinitionPartition will be inserted as a child of this Subject element.\n * @param name The name of the DefinitionPartition that the new DefinitionModel will sub-model.\n * @returns The Id of the newly inserted DefinitionModel.\n * @throws [[IModelError]] if there is an insert problem.\n * @beta\n */\n public static insert(txn: EditTxn, parentSubjectId: Id64String, name: string): Id64String;\n public static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string): Id64String;\n public static insert(txnOrDb: EditTxn | IModelDb, parentSubjectId: Id64String, name: string): Id64String {\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\n const partitionId = txn.insertElement({\n classFullName: DefinitionPartition.classFullName,\n model: IModel.repositoryModelId,\n parent: new SubjectOwnsPartitionElements(parentSubjectId),\n code: DefinitionPartition.createCode(txn.iModel, parentSubjectId, name),\n });\n return txn.insertModel({\n classFullName: this.classFullName,\n modeledElement: { id: partitionId },\n });\n }\n}\n\n/** The singleton container of repository-related information elements.\n * @public @preview\n */\nexport class RepositoryModel extends DefinitionModel {\n public static override get className(): string { return \"RepositoryModel\"; }\n}\n\n/** Contains a list of document elements.\n * @see [[DocumentPartition]]\n * @public @preview\n */\nexport class DocumentListModel extends InformationModel {\n public static override get className(): string { return \"DocumentListModel\"; }\n\n /** Insert a [[DocumentPartition]] and a DocumentListModel that sub-models it.\n * @param txn The active EditTxn.\n * @param parentSubjectId The DocumentPartition will be inserted as a child of this Subject element.\n * @param name The name of the DocumentPartition that the new DocumentListModel will sub-model.\n * @returns The Id of the newly inserted DocumentPartition and DocumentListModel (same value)\n * @throws [[IModelError]] if there is an insert problem.\n * @beta\n */\n public static insert(txn: EditTxn, parentSubjectId: Id64String, name: string): Id64String;\n public static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string): Id64String;\n public static insert(txnOrDb: EditTxn | IModelDb, parentSubjectId: Id64String, name: string): Id64String {\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\n const partitionId = txn.insertElement({\n classFullName: DocumentPartition.classFullName,\n model: IModel.repositoryModelId,\n parent: new SubjectOwnsPartitionElements(parentSubjectId),\n code: DocumentPartition.createCode(txn.iModel, parentSubjectId, name),\n });\n return txn.insertModel({\n classFullName: this.classFullName,\n modeledElement: { id: partitionId },\n });\n }\n}\n\n/** A container for persisting link elements.\n * @see [[LinkPartition]]\n * @public @preview\n */\nexport class LinkModel extends InformationModel {\n public static override get className(): string { return \"LinkModel\"; }\n}\n\n/** The singleton container for repository-specific definition elements.\n * @public @preview\n */\nexport class DictionaryModel extends DefinitionModel {\n public static override get className(): string { return \"DictionaryModel\"; }\n}\n\n/** Obtains and displays multi-resolution tiled raster organized according to the WebMercator tiling system.\n * @public @preview\n */\nexport class WebMercatorModel extends SpatialModel {\n public static override get className(): string { return \"WebMercatorModel\"; }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Model.js","sourceRoot":"","sources":["../../src/Model.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,qBAAqB;AAErB,sDAAwE;AACxE,wDAAwD;AACxD,oDAG4B;AAC5B,uCAAiK;AACjK,qCAA0F;AAC1F,uCAAoC;AAEpC,qEAAwE;AACxE,gDAAqF;AAgErF;;;;GAIG;AACH,MAAa,KAAM,SAAQ,eAAM;IACxB,MAAM,KAAc,SAAS,KAAa,OAAO,OAAO,CAAC,CAAC,CAAC;IAClE,gBAAgB;IACT,MAAM,KAAc,mBAAmB,KAAK,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACjF,cAAc,CAAiB;IAC/B,IAAI,CAAS;IACb,WAAW,CAAc;IACzB,cAAc,CAAyB;IAChD,SAAS,CAAU;IACnB,UAAU,CAAU;IAE3B,YAAsB,KAAiB,EAAE,MAAgB;QACvD,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,cAAc,GAAG,IAAI,4BAAc,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAC/D,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC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AS,KAAa,OAAO,mBAAmB,CAAC,CAAC,CAAC;IAYvE,MAAM,CAAC,MAAM,CAAC,OAA2B,EAAE,eAA2B,EAAE,IAAY;QACzF,MAAM,GAAG,GAAG,OAAO,YAAY,iBAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,sBAAY,CAAC,CAAC;QACzE,MAAM,WAAW,GAAG,GAAG,CAAC,aAAa,CAAC;YACpC,aAAa,EAAE,2BAAiB,CAAC,aAAa;YAC9C,KAAK,EAAE,oBAAM,CAAC,iBAAiB;YAC/B,MAAM,EAAE,IAAI,qDAA4B,CAAC,eAAe,CAAC;YACzD,IAAI,EAAE,2BAAiB,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,CAAC;SACtE,CAAC,CAAC;QACH,OAAO,GAAG,CAAC,WAAW,CAAC;YACrB,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,cAAc,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE;SACpC,CAAC,CAAC;IACL,CAAC;CACF;AA1BD,8CA0BC;AAED;;;GAGG;AACH,MAAa,SAAU,SAAQ,gBAAgB;IACtC,MAAM,KAAc,SAAS,KAAa,OAAO,WAAW,CAAC,CAAC,CAAC;CACvE;AAFD,8BAEC;AAED;;GAEG;AACH,MAAa,eAAgB,SAAQ,eAAe;IAC3C,MAAM,KAAc,SAAS,KAAa,OAAO,iBAAiB,CAAC,CAAC,CAAC;CAC7E;AAFD,0CAEC;AAED;;GAEG;AACH,MAAa,gBAAiB,SAAQ,YAAY;IACzC,MAAM,KAAc,SAAS,KAAa,OAAO,kBAAkB,CAAC,CAAC,CAAC;CAC9E;AAFD,4CAEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Models\n */\n\n// cspell:ignore elid\n\nimport { GuidString, Id64String, JsonUtils } from \"@itwin/core-bentley\";\nimport { Point2d, Range3d } from \"@itwin/core-geometry\";\nimport {\n AxisAlignedBox3d, ElementProps, EntityReferenceSet, GeometricModel2dProps, GeometricModel3dProps, GeometricModelProps, IModel,\n InformationPartitionElementProps, ModelProps, RelatedElement,\n} from \"@itwin/core-common\";\nimport { DefinitionPartition, DocumentPartition, InformationRecordPartition, PhysicalPartition, SheetIndexPartition, SpatialLocationPartition } from \"./Element\";\nimport { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow, Entity } from \"./Entity\";\nimport { EditTxn } from \"./EditTxn\";\nimport { IModelDb } from \"./IModelDb\";\nimport { SubjectOwnsPartitionElements } from \"./NavigationRelationship\";\nimport { _cache, _implicitTxn, _nativeDb, _verifyChannel } from \"./internal/Symbols\";\n\n/** Argument for the `Model.onXxx` static methods\n * @beta\n */\nexport interface OnModelArg {\n /** The iModel for the Model affected. */\n iModel: IModelDb;\n}\n\n/** Argument for the `Model.onXxx` static methods that supply the properties of a Model to be inserted or updated.\n * @beta\n */\nexport interface OnModelPropsArg extends OnModelArg {\n /** The new properties of the Model affected. */\n props: Readonly<ModelProps>;\n}\n\n/** Argument for the `Model.onXxx` static methods that only supply the Id of the affected Model.\n * @beta\n */\nexport interface OnModelIdArg extends OnModelArg {\n /** The Id of the Model affected */\n id: Id64String;\n}\n\n/** Argument for the `Model.onXxxElement` static methods that supply the properties of an Element for a Model.\n * @beta\n */\nexport interface OnElementInModelPropsArg extends OnModelIdArg {\n /** The new properties of an Element for the affected Model */\n elementProps: Readonly<ElementProps>;\n}\n\n/** Per-model element deletion data used inside [[OnBulkModelEventsArg]].\n * @beta\n */\nexport interface OnBulkDeletedElementsArg extends OnModelIdArg {\n /** The Ids of all Elements that were bulk-deleted from this Model instance. */\n elementIds: Id64String[];\n}\n\n/** Argument for the `Model.onBulkModelEvents` static method.\n * Passed once per distinct Model ECClass, combining both deleted sub-models and\n * deleted-elements-by-model into a single callback.\n * @beta\n */\nexport interface OnBulkModelEventsArg extends OnModelArg {\n /** Ids of Models of this class that were deleted as sub-models. Present only if any sub-models\n * of this class were deleted. */\n deletedModelIds?: Id64String[];\n /** Per-model lists of element Ids deleted from instances of this Model class. Present only if\n * any elements were deleted from models of this class. */\n deletedElementsByModel?: OnBulkDeletedElementsArg[];\n}\n\n/** Argument for the `Model.onXxxElement` static methods that supply the Id of an Element for a Model.\n * @beta\n */\nexport interface OnElementInModelIdArg extends OnModelIdArg {\n /** The Id of the Element for the affected Model */\n elementId: Id64String;\n}\n\n/** A Model is a container for persisting a collection of related elements within an iModel.\n * See [[IModelDb.Models]] for how to query and manage the Models in an IModelDb.\n * See [Creating models]($docs/learning/backend/CreateModels.md)\n * @public @preview\n */\nexport class Model extends Entity {\n public static override get className(): string { return \"Model\"; }\n /** @internal */\n public static override get protectedOperations() { return [\"onInsert\", \"onUpdate\", \"onDelete\"]; }\n public readonly modeledElement: RelatedElement;\n public readonly name: string;\n public readonly parentModel?: Id64String;\n public readonly jsonProperties: { [key: string]: any };\n public isPrivate: boolean;\n public isTemplate: boolean;\n\n protected constructor(props: ModelProps, iModel: IModelDb) {\n super(props, iModel);\n this.modeledElement = new RelatedElement(props.modeledElement);\n this.name = props.name ? props.name : \"\"; // NB this isn't really a property of Model (it's the code.value of the modeled element), but it comes in ModelProps because it's often needed\n this.parentModel = props.parentModel;\n this.isPrivate = JsonUtils.asBool(props.isPrivate);\n this.isTemplate = JsonUtils.asBool(props.isTemplate);\n this.jsonProperties = { ...props.jsonProperties }; // make sure we have our own copy\n }\n\n /**\n * Model custom HandledProps includes 'isPrivate', 'isTemplate', and 'lastMod'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"isPrivate\", source: \"Class\" },\n { propertyName: \"isTemplate\", source: \"Class\" },\n { propertyName: \"lastMod\", source: \"Class\" },\n ];\n\n /**\n * Model deserializes 'isPrivate', and 'isTemplate', and sets the proper parentModel.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): ModelProps {\n const instance = props.row;\n const modelProps = super.deserialize(props) as ModelProps;\n const modeledElementProps = props.iModel.elements.tryGetElementProps(instance.modeledElement.id);\n if (modeledElementProps) {\n // ModeledElement may be undefined in the case of root Element\n modelProps.name = JsonUtils.asString(modeledElementProps.code.value);\n if (instance.parentModel !== undefined)\n modelProps.parentModel = instance.parentModel.id;\n else\n modelProps.parentModel = modeledElementProps.model;\n }\n if (instance.isPrivate === true)\n modelProps.isPrivate = true;\n if (instance.isTemplate === true)\n modelProps.isTemplate = true;\n return modelProps;\n }\n\n /**\n * Model serializes 'isPrivate', and 'isTemplate'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: ModelProps, _iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, _iModel);\n inst.isPrivate = props.isPrivate ?? false;\n inst.isTemplate = props.isTemplate ?? false;\n return inst;\n }\n\n public override toJSON(): ModelProps {\n const val = super.toJSON() as ModelProps;\n val.name = this.name; // for cloning\n return val;\n }\n\n /** Called before a new Model is inserted.\n * @note throw an exception to disallow the insert\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model to be inserted\n * @beta\n */\n protected static onInsert(arg: OnModelPropsArg): void {\n const { props, iModel } = arg;\n iModel.channels[_verifyChannel](props.modeledElement.id);\n if (props.parentModel) // inserting requires shared lock on parent, if present\n iModel.locks.checkSharedLock(props.parentModel, \"parent model\", \"insert\");\n }\n\n /** Called after a new Model is inserted.\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model that was inserted\n * @beta\n */\n protected static onInserted(_arg: OnModelIdArg): void {\n // we don't need to tell LockControl about models being created - their ModeledElement does that\n }\n\n /** Called before a Model is updated.\n * @note throw an exception to disallow the update\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model to be updated\n * @beta\n */\n protected static onUpdate(arg: OnModelPropsArg): void {\n const id = arg.props.id!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n arg.iModel.channels[_verifyChannel](id);\n arg.iModel.locks.checkExclusiveLock(id, \"model\", \"update\");\n }\n\n /** Called after a Model is updated.\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model that was updated.\n * @beta\n */\n protected static onUpdated(arg: OnModelIdArg): void {\n arg.iModel.models[_cache].delete(arg.id);\n }\n\n /** Called before a Model is deleted.\n * @note throw an exception to disallow the delete\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model to be deleted\n * @beta\n */\n protected static onDelete(arg: OnModelIdArg): void {\n arg.iModel.channels[_verifyChannel](arg.id);\n arg.iModel.locks.checkExclusiveLock(arg.id, \"model\", \"delete\");\n }\n\n /** Called after a Model was deleted.\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model that was deleted\n * @beta\n */\n protected static onDeleted(arg: OnModelIdArg): void {\n arg.iModel.models[_cache].delete(arg.id);\n arg.iModel.elements[_cache].deleteWithModel(arg.id);\n }\n\n /** Called once per distinct Model ECClass after a bulk element delete operation, combining\n * both sub-model deletions and element-deletions-by-model into a single callback.\n *\n * `arg.deletedModelIds` — present when models of this class were deleted as sub-model roots.\n * The default implementation calls [[onDeleted]] for each.\n *\n * `arg.deletedElementsByModel` — present when elements were deleted from models of this class.\n * The default implementation calls [[onDeleteElement]] and [[onDeletedElement]] for each element.\n *\n * @note If you override this method, you must call super.\n * @note `this` is the Model class dispatched on.\n * @beta\n */\n protected static onBulkModelEvents(arg: OnBulkModelEventsArg): void {\n if (arg.deletedModelIds !== undefined)\n for (const id of arg.deletedModelIds)\n this.onDeleted({ iModel: arg.iModel, id });\n\n if (arg.deletedElementsByModel !== undefined)\n for (const entry of arg.deletedElementsByModel)\n for (const elementId of entry.elementIds) {\n this.onDeleteElement({ iModel: arg.iModel, id: entry.id, elementId });\n this.onDeletedElement({ iModel: arg.iModel, id: entry.id, elementId });\n }\n }\n\n /** Called before a prospective Element is to be inserted into an instance of a Model of this class.\n * @note throw an exception to disallow the insert\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model to hold the element\n * @beta\n */\n protected static onInsertElement(_arg: OnElementInModelPropsArg): void { }\n\n /** Called after an Element has been inserted into an instance of a Model of this class.\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model holding the element\n * @beta\n */\n protected static onInsertedElement(arg: OnElementInModelIdArg): void {\n arg.iModel.models[_cache].delete(arg.id);\n }\n\n /** Called when an Element in an instance of a Model of this class is about to be updated.\n * @note throw an exception to disallow the update\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model holding the element\n * @beta\n */\n protected static onUpdateElement(_arg: OnElementInModelPropsArg): void { }\n\n /** Called after an Element in an instance of a Model of this class has been updated.\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model holding the element\n * @beta\n */\n protected static onUpdatedElement(arg: OnElementInModelIdArg): void {\n arg.iModel.models[_cache].delete(arg.id);\n }\n\n /** Called when an Element in an instance of a Model of this class is about to be deleted.\n * @note throw an exception to disallow the delete\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model holding the element\n * @beta\n */\n protected static onDeleteElement(_arg: OnElementInModelIdArg): void { }\n\n /** Called after an Element in an instance of a Model of this class has been deleted.\n * @note If you override this method, you must call super.\n * @note `this` is the class of the Model that held the element\n * @beta\n */\n protected static onDeletedElement(arg: OnElementInModelIdArg): void {\n arg.iModel.models[_cache].delete(arg.id);\n }\n\n private getAllUserProperties(): any {\n if (!this.jsonProperties.UserProps)\n this.jsonProperties.UserProps = new Object();\n\n return this.jsonProperties.UserProps;\n }\n\n /** Get a set of JSON user properties by namespace */\n public getUserProperties(namespace: string) { return this.getAllUserProperties()[namespace]; }\n\n /** Change a set of user JSON properties of this Element by namespace. */\n public setUserProperties(nameSpace: string, value: any) { this.getAllUserProperties()[nameSpace] = value; }\n\n /** Remove a set of JSON user properties, specified by namespace, from this Element */\n public removeUserProperties(nameSpace: string) { delete this.getAllUserProperties()[nameSpace]; }\n\n public getJsonProperty(name: string): any { return this.jsonProperties[name]; }\n public setJsonProperty(name: string, value: any) { this.jsonProperties[name] = value; }\n\n /**\n * Insert this Model in the iModel using the supplied EditTxn.\n * @beta\n */\n public insert(txn: EditTxn): Id64String;\n /**\n * Insert this Model in the iModel.\n * @deprecated Use Model.insert(txn) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\n */\n public insert(): Id64String;\n public insert(txn?: EditTxn) { return this.id = (txn ?? this.iModel[_implicitTxn]).insertModel(this.toJSON()); }\n\n /**\n * Update this Model in the iModel using the supplied EditTxn.\n * @beta\n */\n public update(txn: EditTxn): void;\n /**\n * Update this Model in the iModel.\n * @deprecated Use Model.update(txn) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\n */\n public update(): void;\n public update(txn?: EditTxn) { (txn ?? this.iModel[_implicitTxn]).updateModel(this.toJSON()); }\n\n /**\n * Delete this Model from the iModel using the supplied EditTxn.\n * @beta\n */\n public delete(txn: EditTxn): void;\n /**\n * Delete this Model from the iModel.\n * @deprecated Use Model.delete(txn) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\n */\n public delete(): void;\n public delete(txn?: EditTxn) { (txn ?? this.iModel[_implicitTxn]).deleteModel(this.id); }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n if (this.parentModel)\n referenceIds.addModel(this.parentModel);\n referenceIds.addElement(this.modeledElement.id);\n }\n}\n\n/** A container for persisting geometric elements.\n * @public @preview\n */\nexport class GeometricModel extends Model {\n public geometryGuid?: GuidString;\n\n public static override get className(): string { return \"GeometricModel\"; }\n\n protected constructor(props: GeometricModelProps, iModel: IModelDb) {\n super(props, iModel);\n this.geometryGuid = props.geometryGuid;\n }\n\n /** Query for the union of the extents of the elements contained by this model.\n * @note This function blocks the JavaScript event loop. Consider using [[queryRange]] instead.\n */\n public queryExtents(): AxisAlignedBox3d {\n const extents = this.iModel[_nativeDb].queryModelExtents({ id: this.id }).modelExtents;\n return Range3d.fromJSON(extents);\n }\n\n /** Query for the union of the extents of all elements contained within this model. */\n public async queryRange(): Promise<AxisAlignedBox3d> {\n return this.iModel.models.queryRange(this.id);\n }\n}\n\n/** A container for persisting 3d geometric elements.\n * @public @preview\n */\nexport abstract class GeometricModel3d extends GeometricModel {\n /** If true, then the elements in this GeometricModel3d are expected to be in an XY plane.\n * @note The associated ECProperty was added to the BisCore schema in version 1.0.8\n */\n public readonly isPlanProjection: boolean;\n /** If true, then the elements in this GeometricModel3d are not in real-world coordinates and will not be in the spatial index.\n * @note The associated ECProperty was added to the BisCore schema in version 1.0.8\n */\n public readonly isNotSpatiallyLocated: boolean;\n /** If true, then the elements in this GeometricModel3d are in real-world coordinates and will be in the spatial index. */\n public get isSpatiallyLocated(): boolean { return !this.isNotSpatiallyLocated; }\n\n public static override get className(): string { return \"GeometricModel3d\"; }\n\n protected constructor(props: GeometricModel3dProps, iModel: IModelDb) {\n super(props, iModel);\n this.isNotSpatiallyLocated = JsonUtils.asBool(props.isNotSpatiallyLocated);\n this.isPlanProjection = JsonUtils.asBool(props.isPlanProjection);\n }\n\n /**\n * GeometricModel3d custom HandledProps includes 'isPlanProjection', and 'isNotSpatiallyLocated'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"isPlanProjection\", source: \"Class\" },\n { propertyName: \"isNotSpatiallyLocated\", source: \"Class\" },\n ];\n\n /**\n * GeometricModel3d deserializes 'isPlanProjection', and 'isNotSpatiallyLocated'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): GeometricModel3dProps {\n const modelProps = super.deserialize(props) as GeometricModel3dProps;\n const instance = props.row;\n if (instance.isNotSpatiallyLocated === true || instance.isTemplate === true)\n modelProps.isNotSpatiallyLocated = true;\n if (instance.isPlanProjection === true)\n modelProps.isPlanProjection = true;\n return modelProps;\n }\n\n /**\n * GeometricModel3d serializes 'isPlanProjection', and 'isNotSpatiallyLocated'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: GeometricModel3dProps, _iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, _iModel);\n inst.isNotSpatiallyLocated = props.isNotSpatiallyLocated ?? false;\n inst.isPlanProjection = props.isPlanProjection ?? false;\n return inst;\n }\n\n public override toJSON(): GeometricModel3dProps {\n const val = super.toJSON() as GeometricModel3dProps;\n if (this.isNotSpatiallyLocated)\n val.isNotSpatiallyLocated = true;\n\n if (this.isPlanProjection)\n val.isPlanProjection = true;\n\n return val;\n }\n}\n\n/** A container for persisting 2d geometric elements.\n * @public @preview\n */\nexport abstract class GeometricModel2d extends GeometricModel {\n /** The actual coordinates of (0,0) in modeling coordinates. An offset applied to all modeling coordinates. */\n public globalOrigin?: Point2d;\n public static override get className(): string { return \"GeometricModel2d\"; }\n\n protected constructor(props: GeometricModel2dProps, iModel: IModelDb) {\n super(props, iModel);\n this.globalOrigin = props.globalOrigin ? Point2d.fromJSON(props.globalOrigin) : undefined;\n }\n\n public override toJSON(): GeometricModel2dProps {\n const val = super.toJSON() as GeometricModel2dProps;\n if (undefined !== this.globalOrigin)\n val.globalOrigin = Point2d.fromJSON(this.globalOrigin);\n\n return val;\n }\n}\n\n/** A container for persisting 2d graphical elements.\n * @public @preview\n */\nexport abstract class GraphicalModel2d extends GeometricModel2d {\n public static override get className(): string { return \"GraphicalModel2d\"; }\n}\n\n/** A container for persisting GraphicalElement3d instances.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.8\n * @see [[GraphicalPartition3d]]\n * @public @preview\n */\nexport abstract class GraphicalModel3d extends GeometricModel3d {\n public static override get className(): string { return \"GraphicalModel3d\"; }\n}\n\n/** A container for persisting 3d geometric elements that are spatially located.\n * @public @preview\n */\nexport abstract class SpatialModel extends GeometricModel3d {\n public static override get className(): string { return \"SpatialModel\"; }\n}\n\n/** A container for persisting physical elements that model physical space.\n * @see [[PhysicalPartition]]\n * @public @preview\n */\nexport class PhysicalModel extends SpatialModel {\n public static override get className(): string { return \"PhysicalModel\"; }\n /** Insert a PhysicalPartition and a PhysicalModel that sub-models it using an explicit transaction.\n * @param txn The EditTxn used to perform inserts.\n * @param parentSubjectId The PhysicalPartition will be inserted as a child of this Subject element.\n * @param name The name of the PhysicalPartition that the new PhysicalModel will sub-model.\n * @param isPlanProjection Optional value (default is false) that indicates if the contents of this model are expected to be in an XY plane.\n * @returns The Id of the newly inserted PhysicalPartition and PhysicalModel (same value).\n * @throws [[IModelError]] if there is an insert problem.\n * @beta\n */\n public static insert(txn: EditTxn, parentSubjectId: Id64String, name: string, isPlanProjection?: boolean): Id64String;\n /** @deprecated Use PhysicalModel.insert(txn, ...) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help. */\n public static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string, isPlanProjection?: boolean): Id64String;\n public static insert(txnOrDb: EditTxn | IModelDb, parentSubjectId: Id64String, name: string, isPlanProjection?: boolean): Id64String {\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\n const iModelDb = txn.iModel;\n const partitionProps: InformationPartitionElementProps = {\n classFullName: PhysicalPartition.classFullName,\n model: IModel.repositoryModelId,\n parent: new SubjectOwnsPartitionElements(parentSubjectId),\n code: PhysicalPartition.createCode(iModelDb, parentSubjectId, name),\n };\n const partitionId = txn.insertElement(partitionProps);\n const modelProps: GeometricModel3dProps = {\n classFullName: this.classFullName,\n modeledElement: { id: partitionId },\n isPlanProjection,\n };\n return txn.insertModel(modelProps);\n }\n}\n\n/** A container for persisting spatial location elements.\n * @see [[SpatialLocationPartition]]\n * @public @preview\n */\nexport class SpatialLocationModel extends SpatialModel {\n public static override get className(): string { return \"SpatialLocationModel\"; }\n /** Insert a SpatialLocationPartition and a SpatialLocationModel that sub-models it using an explicit transaction.\n * @param txn The EditTxn used to perform inserts.\n * @param parentSubjectId The SpatialLocationPartition will be inserted as a child of this Subject element.\n * @param name The name of the SpatialLocationPartition that the new SpatialLocationModel will sub-model.\n * @param isPlanProjection Optional value (default is false) that indicates if the contents of this model are expected to be in an XY plane.\n * @returns The Id of the newly inserted SpatialLocationPartition and SpatialLocationModel (same value).\n * @throws [[IModelError]] if there is an insert problem.\n * @beta\n */\n public static insert(txn: EditTxn, parentSubjectId: Id64String, name: string, isPlanProjection?: boolean): Id64String;\n /** @deprecated Use SpatialLocationModel.insert(txn, ...) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help. */\n public static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string, isPlanProjection?: boolean): Id64String;\n public static insert(txnOrDb: EditTxn | IModelDb, parentSubjectId: Id64String, name: string, isPlanProjection?: boolean): Id64String {\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\n const iModelDb = txn.iModel;\n const partitionProps: InformationPartitionElementProps = {\n classFullName: SpatialLocationPartition.classFullName,\n model: IModel.repositoryModelId,\n parent: new SubjectOwnsPartitionElements(parentSubjectId),\n code: SpatialLocationPartition.createCode(iModelDb, parentSubjectId, name),\n };\n const partitionId = txn.insertElement(partitionProps);\n const modelProps: GeometricModel3dProps = {\n classFullName: this.classFullName,\n modeledElement: { id: partitionId },\n isPlanProjection,\n };\n return txn.insertModel(modelProps);\n }\n}\n\n/** A 2d model that holds [[DrawingGraphic]]s. DrawingModels may be dimensional or non-dimensional.\n * @public @preview\n */\nexport class DrawingModel extends GraphicalModel2d {\n public static override get className(): string { return \"DrawingModel\"; }\n}\n\n/** A container for persisting section [[DrawingGraphic]]s.\n * @public @preview\n */\nexport class SectionDrawingModel extends DrawingModel {\n public static override get className(): string { return \"SectionDrawingModel\"; }\n}\n\n/** A container for persisting [[ViewAttachment]]s and [[DrawingGraphic]]s.\n * A SheetModel is a digital representation of a *sheet of paper*. SheetModels are 2d models in bounded paper coordinates.\n * SheetModels may contain annotation Elements as well as references to 2d or 3d Views.\n * @public @preview\n */\nexport class SheetModel extends GraphicalModel2d {\n public static override get className(): string { return \"SheetModel\"; }\n}\n\n/** A container for persisting role elements.\n * @public @preview\n */\nexport class RoleModel extends Model {\n public static override get className(): string { return \"RoleModel\"; }\n}\n\n/** A container for persisting information elements.\n * @public @preview\n */\nexport abstract class InformationModel extends Model {\n public static override get className(): string { return \"InformationModel\"; }\n}\n\n/** A container for persisting group information elements.\n * @see [[GroupInformationPartition]]\n * @public @preview\n */\nexport abstract class GroupInformationModel extends InformationModel {\n public static override get className(): string { return \"GroupInformationModel\"; }\n}\n\n/** A sub-model of a [[SheetIndexPartition]] serving as a container for persisting [[SheetIndexEntry]] and [[SheetIndex]] elements.\n * @beta\n */\nexport class SheetIndexModel extends InformationModel {\n public static override get className(): string { return \"SheetIndexModel\"; }\n\n /** Insert a [[SheetIndexPartition]] and a SheetIndexModel that sub-models it.\n * @param txn The active EditTxn.\n * @param parentSubjectId The SheetIndexPartition will be inserted as a child of this Subject element.\n * @param name The name of the SheetIndexPartition that the new SheetIndexModel will sub-model.\n * @returns The Id of the newly inserted SheetIndexModel.\n * @throws [[IModelError]] if there is an insert problem.\n */\n public static insert(txn: EditTxn, parentSubjectId: Id64String, name: string): Id64String;\n /** @deprecated Use SheetIndexModel.insert(txn, ...) instead. */\n public static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string): Id64String;\n public static insert(txnOrDb: EditTxn | IModelDb, parentSubjectId: Id64String, name: string): Id64String {\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\n const partitionId = txn.insertElement({\n classFullName: SheetIndexPartition.classFullName,\n model: IModel.repositoryModelId,\n parent: new SubjectOwnsPartitionElements(parentSubjectId),\n code: SheetIndexPartition.createCode(txn.iModel, parentSubjectId, name),\n });\n return txn.insertModel({\n classFullName: this.classFullName,\n modeledElement: { id: partitionId },\n });\n }\n}\n\n/** A container for persisting Information Record Elements\n * @see [[InformationRecordPartition]]\n * @public @preview\n */\nexport class InformationRecordModel extends InformationModel {\n public static override get className(): string { return \"InformationRecordModel\"; }\n\n /** Insert an InformationRecordPartition and an InformationRecordModel that sub-models it using an explicit transaction.\n * @param txn The EditTxn used to perform inserts.\n * @param parentSubjectId The InformationRecordPartition will be inserted as a child of this Subject element.\n * @param name The name of the InformationRecordPartition that the new InformationRecordModel will sub-model.\n * @returns The Id of the newly inserted InformationRecordModel.\n * @throws [[IModelError]] if there is an insert problem.\n * @beta\n */\n public static insert(txn: EditTxn, parentSubjectId: Id64String, name: string): Id64String;\n public static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string): Id64String;\n public static insert(txnOrDb: EditTxn | IModelDb, parentSubjectId: Id64String, name: string): Id64String {\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\n const partitionId = txn.insertElement({\n classFullName: InformationRecordPartition.classFullName,\n model: IModel.repositoryModelId,\n parent: new SubjectOwnsPartitionElements(parentSubjectId),\n code: InformationRecordPartition.createCode(txn.iModel, parentSubjectId, name),\n });\n return txn.insertModel({\n classFullName: this.classFullName,\n modeledElement: { id: partitionId },\n });\n }\n}\n\n/** A container for persisting definition elements.\n * @see [[DefinitionPartition]]\n * @public @preview\n */\nexport class DefinitionModel extends InformationModel {\n public static override get className(): string { return \"DefinitionModel\"; }\n\n /** Insert a DefinitionPartition and a DefinitionModel that sub-models it.\n * @param txn The active EditTxn.\n * @param parentSubjectId The DefinitionPartition will be inserted as a child of this Subject element.\n * @param name The name of the DefinitionPartition that the new DefinitionModel will sub-model.\n * @returns The Id of the newly inserted DefinitionModel.\n * @throws [[IModelError]] if there is an insert problem.\n * @beta\n */\n public static insert(txn: EditTxn, parentSubjectId: Id64String, name: string): Id64String;\n public static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string): Id64String;\n public static insert(txnOrDb: EditTxn | IModelDb, parentSubjectId: Id64String, name: string): Id64String {\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\n const partitionId = txn.insertElement({\n classFullName: DefinitionPartition.classFullName,\n model: IModel.repositoryModelId,\n parent: new SubjectOwnsPartitionElements(parentSubjectId),\n code: DefinitionPartition.createCode(txn.iModel, parentSubjectId, name),\n });\n return txn.insertModel({\n classFullName: this.classFullName,\n modeledElement: { id: partitionId },\n });\n }\n}\n\n/** The singleton container of repository-related information elements.\n * @public @preview\n */\nexport class RepositoryModel extends DefinitionModel {\n public static override get className(): string { return \"RepositoryModel\"; }\n}\n\n/** Contains a list of document elements.\n * @see [[DocumentPartition]]\n * @public @preview\n */\nexport class DocumentListModel extends InformationModel {\n public static override get className(): string { return \"DocumentListModel\"; }\n\n /** Insert a [[DocumentPartition]] and a DocumentListModel that sub-models it.\n * @param txn The active EditTxn.\n * @param parentSubjectId The DocumentPartition will be inserted as a child of this Subject element.\n * @param name The name of the DocumentPartition that the new DocumentListModel will sub-model.\n * @returns The Id of the newly inserted DocumentPartition and DocumentListModel (same value)\n * @throws [[IModelError]] if there is an insert problem.\n * @beta\n */\n public static insert(txn: EditTxn, parentSubjectId: Id64String, name: string): Id64String;\n public static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string): Id64String;\n public static insert(txnOrDb: EditTxn | IModelDb, parentSubjectId: Id64String, name: string): Id64String {\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\n const partitionId = txn.insertElement({\n classFullName: DocumentPartition.classFullName,\n model: IModel.repositoryModelId,\n parent: new SubjectOwnsPartitionElements(parentSubjectId),\n code: DocumentPartition.createCode(txn.iModel, parentSubjectId, name),\n });\n return txn.insertModel({\n classFullName: this.classFullName,\n modeledElement: { id: partitionId },\n });\n }\n}\n\n/** A container for persisting link elements.\n * @see [[LinkPartition]]\n * @public @preview\n */\nexport class LinkModel extends InformationModel {\n public static override get className(): string { return \"LinkModel\"; }\n}\n\n/** The singleton container for repository-specific definition elements.\n * @public @preview\n */\nexport class DictionaryModel extends DefinitionModel {\n public static override get className(): string { return \"DictionaryModel\"; }\n}\n\n/** Obtains and displays multi-resolution tiled raster organized according to the WebMercator tiling system.\n * @public @preview\n */\nexport class WebMercatorModel extends SpatialModel {\n public static override get className(): string { return \"WebMercatorModel\"; }\n}\n"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ChangeInstance, ChangeSource } from "./ChangesetReaderTypes";
|
|
2
|
+
/**
|
|
3
|
+
* Cache used by [[PartialChangeUnifier]] to accumulate and merge
|
|
4
|
+
* partial EC change instances.
|
|
5
|
+
* @beta
|
|
6
|
+
*/
|
|
7
|
+
export interface ChangeCache extends Disposable {
|
|
8
|
+
/** Retrieve a cached instance by key, or `undefined` if absent. */
|
|
9
|
+
get(key: string): ChangeInstance | undefined;
|
|
10
|
+
/** Insert or replace a cached instance. */
|
|
11
|
+
set(key: string, value: ChangeInstance): void;
|
|
12
|
+
/** Iterate over all cached instances. */
|
|
13
|
+
all(): IterableIterator<ChangeInstance>;
|
|
14
|
+
/** Number of instances currently in the cache. */
|
|
15
|
+
count(): number;
|
|
16
|
+
}
|
|
17
|
+
/** @beta */
|
|
18
|
+
export declare namespace ChangeUnifierCache {
|
|
19
|
+
/**
|
|
20
|
+
* Creates an in-memory cache backed by a `Map`.
|
|
21
|
+
* Fast, but may exhaust memory for very large changesets.
|
|
22
|
+
* @returns An [[ChangeCache]] backed by an in-memory `Map`.
|
|
23
|
+
* @beta
|
|
24
|
+
*/
|
|
25
|
+
function createInMemoryCache(): ChangeCache;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a SQLite-backed cache stored in a temporary SQlite database.
|
|
28
|
+
* Slower than in-memory but useful in handling large changesets.
|
|
29
|
+
* Temporary SQlite database is first created in memory and
|
|
30
|
+
* parts of a temporary database might be flushed to disk if the database becomes large or
|
|
31
|
+
* if SQLite comes under memory pressure.
|
|
32
|
+
* @param bufferedReadInstanceSizeInBytes Read-batch size in bytes (default 10 MB).
|
|
33
|
+
* @returns An [[ChangeCache]] backed by a SQLite temp table.
|
|
34
|
+
* @beta
|
|
35
|
+
*/
|
|
36
|
+
function createSqliteBackedCache(bufferedReadInstanceSizeInBytes?: number): ChangeCache;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Combines partial EC change instances (one per SQLite table row) into complete
|
|
40
|
+
* instances that span all tables mapping to a single EC entity.
|
|
41
|
+
*
|
|
42
|
+
* The merge key is derived from the `instanceKey` and `stage` stored in `$meta.instanceKey` and `$meta.stage`.
|
|
43
|
+
*
|
|
44
|
+
* **Usage:**
|
|
45
|
+
* ```ts
|
|
46
|
+
* using reader = ChangesetReader.openFile({ fileName, db });
|
|
47
|
+
* using unifier = new PartialChangeUnifier();
|
|
48
|
+
* while (reader.step()) {
|
|
49
|
+
* unifier.appendFrom(reader);
|
|
50
|
+
* }
|
|
51
|
+
* for (const instance of unifier.instances) { ... }
|
|
52
|
+
* ```
|
|
53
|
+
* @beta
|
|
54
|
+
*/
|
|
55
|
+
export declare class PartialChangeUnifier implements Disposable {
|
|
56
|
+
private readonly _cache;
|
|
57
|
+
constructor(_cache?: ChangeCache);
|
|
58
|
+
/** Releases the underlying cache. */
|
|
59
|
+
[Symbol.dispose](): void;
|
|
60
|
+
/** Number of complete (merged) instances currently accumulated. */
|
|
61
|
+
get instanceCount(): number;
|
|
62
|
+
/**
|
|
63
|
+
* Append partial changes from the current reader row and merge them into the cache.
|
|
64
|
+
*
|
|
65
|
+
* @param source Any [ChangeSource]($backend) positioned on a valid row.
|
|
66
|
+
* @beta
|
|
67
|
+
*/
|
|
68
|
+
appendFrom(source: ChangeSource): void;
|
|
69
|
+
/**
|
|
70
|
+
* Iterator over all fully-merged EC change instances.
|
|
71
|
+
* @beta
|
|
72
|
+
*/
|
|
73
|
+
get instances(): IterableIterator<ChangeInstance>;
|
|
74
|
+
private buildKey;
|
|
75
|
+
private combine;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=PartialChangeUnifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PartialChangeUnifier.d.ts","sourceRoot":"","sources":["../../src/PartialChangeUnifier.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAQtE;;;;GAIG;AACH,MAAM,WAAW,WAAY,SAAQ,UAAU;IAC7C,mEAAmE;IACnE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAC;IAC7C,2CAA2C;IAC3C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9C,yCAAyC;IACzC,GAAG,IAAI,gBAAgB,CAAC,cAAc,CAAC,CAAC;IACxC,kDAAkD;IAClD,KAAK,IAAI,MAAM,CAAC;CACjB;AAED,YAAY;AACZ,yBAAiB,kBAAkB,CAAC;IAClC;;;;;OAKG;IACH,SAAgB,mBAAmB,IAAI,WAAW,CAEjD;IAED;;;;;;;;;OASG;IACH,SAAgB,uBAAuB,CACrC,+BAA+B,SAAmB,GACjD,WAAW,CAEb;CACF;AAuID;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,oBAAqB,YAAW,UAAU;IAEnD,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,GAAE,WAAiC;IAG5D,qCAAqC;IAC9B,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;IAI/B,mEAAmE;IACnE,IAAW,aAAa,IAAI,MAAM,CAEjC;IAED;;;;;OAKG;IACI,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAa7C;;;OAGG;IACH,IAAW,SAAS,IAAI,gBAAgB,CAAC,cAAc,CAAC,CAEvD;IAMD,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,OAAO;CAiBhB"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PartialChangeUnifier = exports.ChangeUnifierCache = void 0;
|
|
4
|
+
/*---------------------------------------------------------------------------------------------
|
|
5
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
+
*--------------------------------------------------------------------------------------------*/
|
|
8
|
+
/** @packageDocumentation
|
|
9
|
+
* @module ECDb
|
|
10
|
+
*/
|
|
11
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
|
+
const core_common_1 = require("@itwin/core-common");
|
|
13
|
+
const SQLiteDb_1 = require("./SQLiteDb");
|
|
14
|
+
/** @beta */
|
|
15
|
+
var ChangeUnifierCache;
|
|
16
|
+
(function (ChangeUnifierCache) {
|
|
17
|
+
/**
|
|
18
|
+
* Creates an in-memory cache backed by a `Map`.
|
|
19
|
+
* Fast, but may exhaust memory for very large changesets.
|
|
20
|
+
* @returns An [[ChangeCache]] backed by an in-memory `Map`.
|
|
21
|
+
* @beta
|
|
22
|
+
*/
|
|
23
|
+
function createInMemoryCache() {
|
|
24
|
+
return new InMemoryCache();
|
|
25
|
+
}
|
|
26
|
+
ChangeUnifierCache.createInMemoryCache = createInMemoryCache;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a SQLite-backed cache stored in a temporary SQlite database.
|
|
29
|
+
* Slower than in-memory but useful in handling large changesets.
|
|
30
|
+
* Temporary SQlite database is first created in memory and
|
|
31
|
+
* parts of a temporary database might be flushed to disk if the database becomes large or
|
|
32
|
+
* if SQLite comes under memory pressure.
|
|
33
|
+
* @param bufferedReadInstanceSizeInBytes Read-batch size in bytes (default 10 MB).
|
|
34
|
+
* @returns An [[ChangeCache]] backed by a SQLite temp table.
|
|
35
|
+
* @beta
|
|
36
|
+
*/
|
|
37
|
+
function createSqliteBackedCache(bufferedReadInstanceSizeInBytes = 1024 * 1024 * 10) {
|
|
38
|
+
return new SqliteBackedCache(bufferedReadInstanceSizeInBytes);
|
|
39
|
+
}
|
|
40
|
+
ChangeUnifierCache.createSqliteBackedCache = createSqliteBackedCache;
|
|
41
|
+
})(ChangeUnifierCache || (exports.ChangeUnifierCache = ChangeUnifierCache = {}));
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
// Private: InMemoryCache
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
class InMemoryCache {
|
|
46
|
+
_cache = new Map();
|
|
47
|
+
get(key) {
|
|
48
|
+
return this._cache.get(key);
|
|
49
|
+
}
|
|
50
|
+
set(key, value) {
|
|
51
|
+
// Remove undefined meta keys to keep serialised form compact.
|
|
52
|
+
const meta = value.$meta;
|
|
53
|
+
if (meta) {
|
|
54
|
+
Object.keys(meta).forEach((k) => meta[k] === undefined && delete meta[k]);
|
|
55
|
+
}
|
|
56
|
+
this._cache.set(key, value);
|
|
57
|
+
}
|
|
58
|
+
*all() {
|
|
59
|
+
for (const key of Array.from(this._cache.keys()).sort()) {
|
|
60
|
+
const instance = this._cache.get(key);
|
|
61
|
+
if (instance)
|
|
62
|
+
yield instance;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
count() {
|
|
66
|
+
return this._cache.size;
|
|
67
|
+
}
|
|
68
|
+
[Symbol.dispose]() {
|
|
69
|
+
this._cache.clear();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
// Private: NativeSqliteBackedInstanceCache
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
class SqliteBackedCache {
|
|
76
|
+
bufferedReadInstanceSizeInBytes;
|
|
77
|
+
_cacheTable = `[${core_bentley_1.Guid.createValue()}]`;
|
|
78
|
+
static defaultBufferSize = 1024 * 1024 * 10; // 10 MB
|
|
79
|
+
_db;
|
|
80
|
+
constructor(bufferedReadInstanceSizeInBytes = SqliteBackedCache.defaultBufferSize) {
|
|
81
|
+
this.bufferedReadInstanceSizeInBytes = bufferedReadInstanceSizeInBytes;
|
|
82
|
+
this._db = new SQLiteDb_1.SQLiteDb();
|
|
83
|
+
this._db.openDb("", { skipFileCheck: true, rawSQLite: true, openMode: core_bentley_1.OpenMode.ReadWrite }); // creating temp sqlite db https://sqlite.org/inmemorydb.html#:~:text=Temporary%20Databases,under%20the%20default%20SQLite%20configuration.
|
|
84
|
+
if (bufferedReadInstanceSizeInBytes <= 0)
|
|
85
|
+
throw new Error("bufferedReadInstanceSizeInBytes must be greater than 0");
|
|
86
|
+
this.createTempTable();
|
|
87
|
+
}
|
|
88
|
+
createTempTable() {
|
|
89
|
+
this._db.withSqliteStatement(`CREATE TABLE ${this._cacheTable} ([key] text primary key, [value] text)`, (stmt) => {
|
|
90
|
+
if (core_bentley_1.DbResult.BE_SQLITE_DONE !== stmt.step())
|
|
91
|
+
throw new Error("unable to create temp cache table");
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
get(key) {
|
|
95
|
+
return this._db.withPreparedSqliteStatement(`SELECT [value] FROM ${this._cacheTable} WHERE [key]=?`, (stmt) => {
|
|
96
|
+
stmt.reset();
|
|
97
|
+
stmt.clearBindings();
|
|
98
|
+
stmt.bindString(1, key);
|
|
99
|
+
if (stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW)
|
|
100
|
+
return JSON.parse(stmt.getValueString(0), core_common_1.Base64EncodedString.reviver);
|
|
101
|
+
return undefined;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
set(key, value) {
|
|
105
|
+
const shallowCopy = Object.assign({}, value);
|
|
106
|
+
this._db.withPreparedSqliteStatement(`INSERT INTO ${this._cacheTable} ([key], [value]) VALUES (?, ?) ON CONFLICT ([key]) DO UPDATE SET [value] = [excluded].[value]`, (stmt) => {
|
|
107
|
+
stmt.reset();
|
|
108
|
+
stmt.clearBindings();
|
|
109
|
+
stmt.bindString(1, key);
|
|
110
|
+
stmt.bindString(2, JSON.stringify(shallowCopy, core_common_1.Base64EncodedString.replacer));
|
|
111
|
+
stmt.step();
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
*all() {
|
|
115
|
+
const sql = `
|
|
116
|
+
SELECT JSON_GROUP_ARRAY(JSON([value]))
|
|
117
|
+
FROM (
|
|
118
|
+
SELECT [value],
|
|
119
|
+
SUM(LENGTH([value])) OVER (ORDER BY [key] ROWS UNBOUNDED PRECEDING) / ${this.bufferedReadInstanceSizeInBytes} AS [bucket]
|
|
120
|
+
FROM ${this._cacheTable}
|
|
121
|
+
)
|
|
122
|
+
GROUP BY [bucket]`;
|
|
123
|
+
const stmt = this._db.prepareSqliteStatement(sql);
|
|
124
|
+
try {
|
|
125
|
+
while (stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW) {
|
|
126
|
+
const bucket = JSON.parse(stmt.getValueString(0), core_common_1.Base64EncodedString.reviver);
|
|
127
|
+
for (const instance of bucket)
|
|
128
|
+
yield instance;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
stmt[Symbol.dispose]();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
count() {
|
|
136
|
+
return this._db.withPreparedSqliteStatement(`SELECT COUNT(*) FROM ${this._cacheTable}`, (stmt) => {
|
|
137
|
+
stmt.reset();
|
|
138
|
+
if (stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW)
|
|
139
|
+
return stmt.getValue(0).getInteger();
|
|
140
|
+
return 0;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
[Symbol.dispose]() {
|
|
144
|
+
this._db.closeDb();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// ---------------------------------------------------------------------------
|
|
148
|
+
// PartialChangeUnifier
|
|
149
|
+
// ---------------------------------------------------------------------------
|
|
150
|
+
/**
|
|
151
|
+
* Combines partial EC change instances (one per SQLite table row) into complete
|
|
152
|
+
* instances that span all tables mapping to a single EC entity.
|
|
153
|
+
*
|
|
154
|
+
* The merge key is derived from the `instanceKey` and `stage` stored in `$meta.instanceKey` and `$meta.stage`.
|
|
155
|
+
*
|
|
156
|
+
* **Usage:**
|
|
157
|
+
* ```ts
|
|
158
|
+
* using reader = ChangesetReader.openFile({ fileName, db });
|
|
159
|
+
* using unifier = new PartialChangeUnifier();
|
|
160
|
+
* while (reader.step()) {
|
|
161
|
+
* unifier.appendFrom(reader);
|
|
162
|
+
* }
|
|
163
|
+
* for (const instance of unifier.instances) { ... }
|
|
164
|
+
* ```
|
|
165
|
+
* @beta
|
|
166
|
+
*/
|
|
167
|
+
class PartialChangeUnifier {
|
|
168
|
+
_cache;
|
|
169
|
+
constructor(_cache = new InMemoryCache()) {
|
|
170
|
+
this._cache = _cache;
|
|
171
|
+
}
|
|
172
|
+
/** Releases the underlying cache. */
|
|
173
|
+
[Symbol.dispose]() {
|
|
174
|
+
this._cache[Symbol.dispose]();
|
|
175
|
+
}
|
|
176
|
+
/** Number of complete (merged) instances currently accumulated. */
|
|
177
|
+
get instanceCount() {
|
|
178
|
+
return this._cache.count();
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Append partial changes from the current reader row and merge them into the cache.
|
|
182
|
+
*
|
|
183
|
+
* @param source Any [ChangeSource]($backend) positioned on a valid row.
|
|
184
|
+
* @beta
|
|
185
|
+
*/
|
|
186
|
+
appendFrom(source) {
|
|
187
|
+
if (source.op === "Updated") {
|
|
188
|
+
if (source.inserted)
|
|
189
|
+
this.combine(source.inserted);
|
|
190
|
+
if (source.deleted)
|
|
191
|
+
this.combine(source.deleted);
|
|
192
|
+
}
|
|
193
|
+
else if (source.op === "Inserted" && source.inserted) {
|
|
194
|
+
this.combine(source.inserted);
|
|
195
|
+
}
|
|
196
|
+
else if (source.op === "Deleted" && source.deleted) {
|
|
197
|
+
this.combine(source.deleted);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Iterator over all fully-merged EC change instances.
|
|
202
|
+
* @beta
|
|
203
|
+
*/
|
|
204
|
+
get instances() {
|
|
205
|
+
return this._cache.all();
|
|
206
|
+
}
|
|
207
|
+
// ---------------------------------------------------------------------------
|
|
208
|
+
// Private helpers
|
|
209
|
+
// ---------------------------------------------------------------------------
|
|
210
|
+
buildKey(instance) {
|
|
211
|
+
const { instanceKey, stage } = instance.$meta;
|
|
212
|
+
return `${instanceKey}-${stage}`.toLowerCase();
|
|
213
|
+
}
|
|
214
|
+
combine(rhs) {
|
|
215
|
+
const key = this.buildKey(rhs);
|
|
216
|
+
const lhs = this._cache.get(key);
|
|
217
|
+
if (lhs) {
|
|
218
|
+
// Merge data fields — rhs wins for any overlapping columns.
|
|
219
|
+
const { $meta: _rhsMeta, ...rhsData } = rhs;
|
|
220
|
+
Object.assign(lhs, rhsData);
|
|
221
|
+
// Accumulate per-table metadata lists.
|
|
222
|
+
lhs.$meta.tables = [...lhs.$meta.tables, ...rhs.$meta.tables];
|
|
223
|
+
lhs.$meta.changeIndexes = [...lhs.$meta.changeIndexes, ...rhs.$meta.changeIndexes];
|
|
224
|
+
// ECInstanceId will be part of changeset fetchedProps for every table, so we should not include multiple of those in the final list
|
|
225
|
+
lhs.$meta.changeFetchedPropNames = [...new Set([...lhs.$meta.changeFetchedPropNames, ...rhs.$meta.changeFetchedPropNames])];
|
|
226
|
+
this._cache.set(key, lhs);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
this._cache.set(key, rhs);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
exports.PartialChangeUnifier = PartialChangeUnifier;
|
|
234
|
+
//# sourceMappingURL=PartialChangeUnifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PartialChangeUnifier.js","sourceRoot":"","sources":["../../src/PartialChangeUnifier.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAA+D;AAC/D,oDAAyD;AAIzD,yCAAsC;AAsBtC,YAAY;AACZ,IAAiB,kBAAkB,CA0BlC;AA1BD,WAAiB,kBAAkB;IACjC;;;;;OAKG;IACH,SAAgB,mBAAmB;QACjC,OAAO,IAAI,aAAa,EAAE,CAAC;IAC7B,CAAC;IAFe,sCAAmB,sBAElC,CAAA;IAED;;;;;;;;;OASG;IACH,SAAgB,uBAAuB,CACrC,+BAA+B,GAAG,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9D,GAAG,CAAC,KAAK,CAAC,aAAa,GAAG,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,aAAa,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;YACnF,oIAAoI;YACpI,GAAG,CAAC,KAAK,CAAC,sBAAsB,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,sBAAsB,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;YAC5H,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC5B,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;CACF;AApED,oDAoEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ECDb\n */\nimport { DbResult, Guid, OpenMode } from \"@itwin/core-bentley\";\nimport { Base64EncodedString } from \"@itwin/core-common\";\nimport { SqliteStatement } from \"./SqliteStatement\";\nimport { ChangeInstance, ChangeSource } from \"./ChangesetReaderTypes\";\nimport { _nativeDb } from \"./internal/Symbols\";\nimport { SQLiteDb } from \"./SQLiteDb\";\n\n// ---------------------------------------------------------------------------\n// ChangeCache — interface + factory\n// ---------------------------------------------------------------------------\n\n/**\n * Cache used by [[PartialChangeUnifier]] to accumulate and merge\n * partial EC change instances.\n * @beta\n */\nexport interface ChangeCache extends Disposable {\n /** Retrieve a cached instance by key, or `undefined` if absent. */\n get(key: string): ChangeInstance | undefined;\n /** Insert or replace a cached instance. */\n set(key: string, value: ChangeInstance): void;\n /** Iterate over all cached instances. */\n all(): IterableIterator<ChangeInstance>;\n /** Number of instances currently in the cache. */\n count(): number;\n}\n\n/** @beta */\nexport namespace ChangeUnifierCache {\n /**\n * Creates an in-memory cache backed by a `Map`.\n * Fast, but may exhaust memory for very large changesets.\n * @returns An [[ChangeCache]] backed by an in-memory `Map`.\n * @beta\n */\n export function createInMemoryCache(): ChangeCache {\n return new InMemoryCache();\n }\n\n /**\n * Creates a SQLite-backed cache stored in a temporary SQlite database.\n * Slower than in-memory but useful in handling large changesets.\n * Temporary SQlite database is first created in memory and\n * parts of a temporary database might be flushed to disk if the database becomes large or\n * if SQLite comes under memory pressure.\n * @param bufferedReadInstanceSizeInBytes Read-batch size in bytes (default 10 MB).\n * @returns An [[ChangeCache]] backed by a SQLite temp table.\n * @beta\n */\n export function createSqliteBackedCache(\n bufferedReadInstanceSizeInBytes = 1024 * 1024 * 10,\n ): ChangeCache {\n return new SqliteBackedCache(bufferedReadInstanceSizeInBytes);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Private: InMemoryCache\n// ---------------------------------------------------------------------------\n\nclass InMemoryCache implements ChangeCache {\n private readonly _cache = new Map<string, ChangeInstance>();\n\n public get(key: string): ChangeInstance | undefined {\n return this._cache.get(key);\n }\n\n public set(key: string, value: ChangeInstance): void {\n // Remove undefined meta keys to keep serialised form compact.\n const meta = value.$meta as any;\n if (meta) {\n Object.keys(meta).forEach((k) => meta[k] === undefined && delete meta[k]);\n }\n this._cache.set(key, value);\n }\n\n public *all(): IterableIterator<ChangeInstance> {\n for (const key of Array.from(this._cache.keys()).sort()) {\n const instance = this._cache.get(key);\n if (instance)\n yield instance;\n }\n }\n\n public count(): number {\n return this._cache.size;\n }\n\n public [Symbol.dispose](): void {\n this._cache.clear();\n }\n}\n\n// ---------------------------------------------------------------------------\n// Private: NativeSqliteBackedInstanceCache\n// ---------------------------------------------------------------------------\n\nclass SqliteBackedCache implements ChangeCache {\n private readonly _cacheTable = `[${Guid.createValue()}]`;\n public static readonly defaultBufferSize = 1024 * 1024 * 10; // 10 MB\n private _db: SQLiteDb;\n public constructor(\n public readonly bufferedReadInstanceSizeInBytes: number = SqliteBackedCache.defaultBufferSize,\n ) {\n this._db = new SQLiteDb();\n this._db.openDb(\"\", { skipFileCheck: true, rawSQLite: true, openMode: OpenMode.ReadWrite }); // creating temp sqlite db https://sqlite.org/inmemorydb.html#:~:text=Temporary%20Databases,under%20the%20default%20SQLite%20configuration.\n if (bufferedReadInstanceSizeInBytes <= 0)\n throw new Error(\"bufferedReadInstanceSizeInBytes must be greater than 0\");\n this.createTempTable();\n }\n\n private createTempTable(): void {\n this._db.withSqliteStatement(`CREATE TABLE ${this._cacheTable} ([key] text primary key, [value] text)`, (stmt: SqliteStatement) => {\n if (DbResult.BE_SQLITE_DONE !== stmt.step())\n throw new Error(\"unable to create temp cache table\");\n });\n }\n\n public get(key: string): ChangeInstance | undefined {\n return this._db.withPreparedSqliteStatement(\n `SELECT [value] FROM ${this._cacheTable} WHERE [key]=?`,\n (stmt: SqliteStatement) => {\n stmt.reset();\n stmt.clearBindings();\n stmt.bindString(1, key);\n if (stmt.step() === DbResult.BE_SQLITE_ROW)\n return JSON.parse(stmt.getValueString(0), Base64EncodedString.reviver) as ChangeInstance;\n return undefined;\n },\n );\n }\n\n public set(key: string, value: ChangeInstance): void {\n const shallowCopy = Object.assign({}, value);\n this._db.withPreparedSqliteStatement(\n `INSERT INTO ${this._cacheTable} ([key], [value]) VALUES (?, ?) ON CONFLICT ([key]) DO UPDATE SET [value] = [excluded].[value]`,\n (stmt: SqliteStatement) => {\n stmt.reset();\n stmt.clearBindings();\n stmt.bindString(1, key);\n stmt.bindString(2, JSON.stringify(shallowCopy, Base64EncodedString.replacer));\n stmt.step();\n },\n );\n }\n\n public *all(): IterableIterator<ChangeInstance> {\n const sql = `\n SELECT JSON_GROUP_ARRAY(JSON([value]))\n FROM (\n SELECT [value],\n SUM(LENGTH([value])) OVER (ORDER BY [key] ROWS UNBOUNDED PRECEDING) / ${this.bufferedReadInstanceSizeInBytes} AS [bucket]\n FROM ${this._cacheTable}\n )\n GROUP BY [bucket]`;\n\n const stmt = this._db.prepareSqliteStatement(sql);\n try {\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\n const bucket = JSON.parse(stmt.getValueString(0), Base64EncodedString.reviver) as ChangeInstance[];\n for (const instance of bucket)\n yield instance;\n }\n } finally {\n stmt[Symbol.dispose]();\n }\n }\n\n public count(): number {\n return this._db.withPreparedSqliteStatement(\n `SELECT COUNT(*) FROM ${this._cacheTable}`,\n (stmt: SqliteStatement) => {\n stmt.reset();\n if (stmt.step() === DbResult.BE_SQLITE_ROW)\n return stmt.getValue(0).getInteger();\n return 0;\n },\n );\n }\n\n public [Symbol.dispose](): void {\n this._db.closeDb();\n }\n}\n\n// ---------------------------------------------------------------------------\n// PartialChangeUnifier\n// ---------------------------------------------------------------------------\n\n/**\n * Combines partial EC change instances (one per SQLite table row) into complete\n * instances that span all tables mapping to a single EC entity.\n *\n * The merge key is derived from the `instanceKey` and `stage` stored in `$meta.instanceKey` and `$meta.stage`.\n *\n * **Usage:**\n * ```ts\n * using reader = ChangesetReader.openFile({ fileName, db });\n * using unifier = new PartialChangeUnifier();\n * while (reader.step()) {\n * unifier.appendFrom(reader);\n * }\n * for (const instance of unifier.instances) { ... }\n * ```\n * @beta\n */\nexport class PartialChangeUnifier implements Disposable {\n public constructor(\n private readonly _cache: ChangeCache = new InMemoryCache(),\n ) { }\n\n /** Releases the underlying cache. */\n public [Symbol.dispose](): void {\n this._cache[Symbol.dispose]();\n }\n\n /** Number of complete (merged) instances currently accumulated. */\n public get instanceCount(): number {\n return this._cache.count();\n }\n\n /**\n * Append partial changes from the current reader row and merge them into the cache.\n *\n * @param source Any [ChangeSource]($backend) positioned on a valid row.\n * @beta\n */\n public appendFrom(source: ChangeSource): void {\n if (source.op === \"Updated\") {\n if (source.inserted)\n this.combine(source.inserted);\n if (source.deleted)\n this.combine(source.deleted);\n } else if (source.op === \"Inserted\" && source.inserted) {\n this.combine(source.inserted);\n } else if (source.op === \"Deleted\" && source.deleted) {\n this.combine(source.deleted);\n }\n }\n\n /**\n * Iterator over all fully-merged EC change instances.\n * @beta\n */\n public get instances(): IterableIterator<ChangeInstance> {\n return this._cache.all();\n }\n\n // ---------------------------------------------------------------------------\n // Private helpers\n // ---------------------------------------------------------------------------\n\n private buildKey(instance: ChangeInstance): string {\n const { instanceKey, stage } = instance.$meta;\n return `${instanceKey}-${stage}`.toLowerCase();\n }\n\n private combine(rhs: ChangeInstance): void {\n const key = this.buildKey(rhs);\n const lhs = this._cache.get(key);\n if (lhs) {\n // Merge data fields — rhs wins for any overlapping columns.\n const { $meta: _rhsMeta, ...rhsData } = rhs;\n Object.assign(lhs, rhsData);\n // Accumulate per-table metadata lists.\n lhs.$meta.tables = [...lhs.$meta.tables, ...rhs.$meta.tables];\n lhs.$meta.changeIndexes = [...lhs.$meta.changeIndexes, ...rhs.$meta.changeIndexes];\n // ECInstanceId will be part of changeset fetchedProps for every table, so we should not include multiple of those in the final list\n lhs.$meta.changeFetchedPropNames = [...new Set([...lhs.$meta.changeFetchedPropNames, ...rhs.$meta.changeFetchedPropNames])];\n this._cache.set(key, lhs);\n } else {\n this._cache.set(key, rhs);\n }\n }\n}\n"]}
|