@itwin/core-backend 5.5.0-dev.2 → 5.5.0-dev.5
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/CHANGELOG.md +19 -1
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BackendLoggerCategory.js.map +1 -1
- package/lib/cjs/BisCoreSchema.js.map +1 -1
- package/lib/cjs/BlobContainerService.js.map +1 -1
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/CatalogDb.js.map +1 -1
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +2 -2
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +248 -248
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/ChannelControl.js.map +1 -1
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.js +5 -5
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/CodeService.js.map +1 -1
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementGraphics.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/EntityReferences.js.map +1 -1
- package/lib/cjs/ExportGraphics.js.map +1 -1
- package/lib/cjs/ExternalSource.js.map +1 -1
- package/lib/cjs/FontFile.js.map +1 -1
- package/lib/cjs/GeoCoordConfig.js.map +1 -1
- package/lib/cjs/GeographicCRSServices.js.map +1 -1
- package/lib/cjs/GeometrySummary.js +47 -47
- package/lib/cjs/GeometrySummary.js.map +1 -1
- package/lib/cjs/IModelDb.js +8 -8
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelDbFonts.js.map +1 -1
- package/lib/cjs/IModelElementCloneContext.js.map +1 -1
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IModelIncrementalSchemaLocater.js.map +1 -1
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/ImageSourceConversion.js.map +1 -1
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LineStyle.js.map +1 -1
- package/lib/cjs/LocalHub.js +1 -1
- package/lib/cjs/LocalHub.js.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/LockControl.js.map +1 -1
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/NativeAppStorage.js.map +1 -1
- package/lib/cjs/NativeHost.js.map +1 -1
- package/lib/cjs/NavigationRelationship.js.map +1 -1
- package/lib/cjs/PromiseMemoizer.js.map +1 -1
- package/lib/cjs/PropertyStore.js.map +1 -1
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/Schema.js.map +1 -1
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/SchemaUtils.js.map +1 -1
- package/lib/cjs/SheetIndex.js.map +1 -1
- package/lib/cjs/SqliteChangesetReader.js.map +1 -1
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/StashManager.js.map +1 -1
- package/lib/cjs/Texture.js.map +1 -1
- package/lib/cjs/TileStorage.js.map +1 -1
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/ViewStateHydrator.js.map +1 -1
- package/lib/cjs/ViewStore.js.map +1 -1
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
- package/lib/cjs/annotations/FrameGeometry.js.map +1 -1
- package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
- package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -1
- package/lib/cjs/annotations/TextAnnotationGeometry.js.map +1 -1
- package/lib/cjs/annotations/TextBlockGeometry.js.map +1 -1
- package/lib/cjs/annotations/TextBlockLayout.js.map +1 -1
- package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
- package/lib/cjs/assets/Settings/Schemas/Base.Schema.json +32 -32
- package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +27 -27
- package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +94 -94
- package/lib/cjs/assets/Settings/backend.setting.json5 +21 -21
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
- package/lib/cjs/domains/GenericElements.js.map +1 -1
- package/lib/cjs/domains/GenericSchema.js.map +1 -1
- package/lib/cjs/internal/ChangesetConflictArgs.js.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
- package/lib/cjs/internal/ElementLRUCache.js.map +1 -1
- package/lib/cjs/internal/FontFileImpl.js.map +1 -1
- package/lib/cjs/internal/HubMock.js.map +1 -1
- package/lib/cjs/internal/IModelDbFontsImpl.js.map +1 -1
- package/lib/cjs/internal/NativePlatform.js.map +1 -1
- package/lib/cjs/internal/NoLocks.js.map +1 -1
- package/lib/cjs/internal/OnlineStatus.js.map +1 -1
- package/lib/cjs/internal/ServerBasedLocks.js.map +1 -1
- package/lib/cjs/internal/Symbols.js.map +1 -1
- package/lib/cjs/internal/annotations/fields.js.map +1 -1
- package/lib/cjs/internal/cross-package.js.map +1 -1
- package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js.map +1 -1
- package/lib/cjs/rpc/multipart.js.map +1 -1
- package/lib/cjs/rpc/tracing.js.map +1 -1
- package/lib/cjs/rpc/web/logging.js.map +1 -1
- package/lib/cjs/rpc/web/request.js.map +1 -1
- package/lib/cjs/rpc/web/response.js.map +1 -1
- package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/Settings.js.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -1
- package/lib/esm/BackendHubAccess.js.map +1 -1
- package/lib/esm/BackendLoggerCategory.js.map +1 -1
- package/lib/esm/BisCoreSchema.js.map +1 -1
- package/lib/esm/BlobContainerService.js.map +1 -1
- package/lib/esm/BriefcaseManager.js.map +1 -1
- package/lib/esm/CatalogDb.js.map +1 -1
- package/lib/esm/Category.js.map +1 -1
- package/lib/esm/ChangeSummaryManager.js +2 -2
- package/lib/esm/ChangeSummaryManager.js.map +1 -1
- package/lib/esm/ChangedElementsDb.js.map +1 -1
- package/lib/esm/ChangesetECAdaptor.js +248 -248
- package/lib/esm/ChangesetECAdaptor.js.map +1 -1
- package/lib/esm/ChannelControl.js.map +1 -1
- package/lib/esm/CheckpointManager.js.map +1 -1
- package/lib/esm/ClassRegistry.js +5 -5
- package/lib/esm/ClassRegistry.js.map +1 -1
- package/lib/esm/CloudSqlite.js.map +1 -1
- package/lib/esm/CodeService.js.map +1 -1
- package/lib/esm/CodeSpecs.js.map +1 -1
- package/lib/esm/ConcurrentQuery.js.map +1 -1
- package/lib/esm/CustomViewState3dCreator.js.map +1 -1
- package/lib/esm/DevTools.js.map +1 -1
- package/lib/esm/DisplayStyle.js.map +1 -1
- package/lib/esm/ECDb.js.map +1 -1
- package/lib/esm/ECSchemaXmlContext.js.map +1 -1
- package/lib/esm/ECSqlStatement.js.map +1 -1
- package/lib/esm/Element.js.map +1 -1
- package/lib/esm/ElementAspect.js.map +1 -1
- package/lib/esm/ElementGraphics.js.map +1 -1
- package/lib/esm/ElementTreeWalker.js.map +1 -1
- package/lib/esm/Entity.js.map +1 -1
- package/lib/esm/EntityReferences.js.map +1 -1
- package/lib/esm/ExportGraphics.js.map +1 -1
- package/lib/esm/ExternalSource.js.map +1 -1
- package/lib/esm/FontFile.js.map +1 -1
- package/lib/esm/GeoCoordConfig.js.map +1 -1
- package/lib/esm/GeographicCRSServices.js.map +1 -1
- package/lib/esm/GeometrySummary.js +47 -47
- package/lib/esm/GeometrySummary.js.map +1 -1
- package/lib/esm/IModelDb.js +8 -8
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/IModelDbFonts.js.map +1 -1
- package/lib/esm/IModelElementCloneContext.js.map +1 -1
- package/lib/esm/IModelHost.js.map +1 -1
- package/lib/esm/IModelIncrementalSchemaLocater.js.map +1 -1
- package/lib/esm/IModelJsFs.js.map +1 -1
- package/lib/esm/ImageSourceConversion.js.map +1 -1
- package/lib/esm/IpcHost.js.map +1 -1
- package/lib/esm/LineStyle.js.map +1 -1
- package/lib/esm/LocalHub.js +1 -1
- package/lib/esm/LocalHub.js.map +1 -1
- package/lib/esm/LocalhostIpcHost.js.map +1 -1
- package/lib/esm/LockControl.js.map +1 -1
- package/lib/esm/Material.js.map +1 -1
- package/lib/esm/Model.js.map +1 -1
- package/lib/esm/NativeAppStorage.js.map +1 -1
- package/lib/esm/NativeHost.js.map +1 -1
- package/lib/esm/NavigationRelationship.js.map +1 -1
- package/lib/esm/PromiseMemoizer.js.map +1 -1
- package/lib/esm/PropertyStore.js.map +1 -1
- package/lib/esm/Relationship.js.map +1 -1
- package/lib/esm/RpcBackend.js.map +1 -1
- package/lib/esm/SQLiteDb.js.map +1 -1
- package/lib/esm/Schema.js.map +1 -1
- package/lib/esm/SchemaSync.js.map +1 -1
- package/lib/esm/SchemaUtils.js.map +1 -1
- package/lib/esm/SheetIndex.js.map +1 -1
- package/lib/esm/SqliteChangesetReader.js.map +1 -1
- package/lib/esm/SqliteStatement.js.map +1 -1
- package/lib/esm/StashManager.js.map +1 -1
- package/lib/esm/Texture.js.map +1 -1
- package/lib/esm/TileStorage.js.map +1 -1
- package/lib/esm/TxnManager.js.map +1 -1
- package/lib/esm/ViewDefinition.js.map +1 -1
- package/lib/esm/ViewStateHydrator.js.map +1 -1
- package/lib/esm/ViewStore.js.map +1 -1
- package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
- package/lib/esm/annotations/FrameGeometry.js.map +1 -1
- package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
- package/lib/esm/annotations/TextAnnotationElement.js.map +1 -1
- package/lib/esm/annotations/TextAnnotationGeometry.js.map +1 -1
- package/lib/esm/annotations/TextBlockGeometry.js.map +1 -1
- package/lib/esm/annotations/TextBlockLayout.js.map +1 -1
- package/lib/esm/core-backend.js.map +1 -1
- package/lib/esm/domains/FunctionalElements.js.map +1 -1
- package/lib/esm/domains/FunctionalSchema.js.map +1 -1
- package/lib/esm/domains/GenericElements.js.map +1 -1
- package/lib/esm/domains/GenericSchema.js.map +1 -1
- package/lib/esm/internal/ChangesetConflictArgs.js.map +1 -1
- package/lib/esm/internal/ChannelAdmin.js.map +1 -1
- package/lib/esm/internal/ElementLRUCache.js.map +1 -1
- package/lib/esm/internal/FontFileImpl.js.map +1 -1
- package/lib/esm/internal/HubMock.js.map +1 -1
- package/lib/esm/internal/IModelDbFontsImpl.js.map +1 -1
- package/lib/esm/internal/NativePlatform.js.map +1 -1
- package/lib/esm/internal/NoLocks.js.map +1 -1
- package/lib/esm/internal/OnlineStatus.js.map +1 -1
- package/lib/esm/internal/ServerBasedLocks.js.map +1 -1
- package/lib/esm/internal/Symbols.js.map +1 -1
- package/lib/esm/internal/annotations/fields.js.map +1 -1
- package/lib/esm/internal/cross-package.js.map +1 -1
- package/lib/esm/internal/workspace/SettingsImpl.js.map +1 -1
- package/lib/esm/internal/workspace/SettingsSchemasImpl.js.map +1 -1
- package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/esm/internal/workspace/WorkspaceSqliteDb.js.map +1 -1
- package/lib/esm/rpc/multipart.js.map +1 -1
- package/lib/esm/rpc/tracing.js.map +1 -1
- package/lib/esm/rpc/web/logging.js.map +1 -1
- package/lib/esm/rpc/web/request.js.map +1 -1
- package/lib/esm/rpc/web/response.js.map +1 -1
- package/lib/esm/rpc-impl/DevToolsRpcImpl.js.map +1 -1
- package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/esm/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/esm/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/lib/esm/test/AdvancedEqual.js.map +1 -1
- package/lib/esm/test/AnnotationTestUtils.js.map +1 -1
- package/lib/esm/test/AttachDb.test.js +11 -11
- package/lib/esm/test/AttachDb.test.js.map +1 -1
- package/lib/esm/test/ElementDrivesElement.test.js +23 -23
- package/lib/esm/test/ElementDrivesElement.test.js.map +1 -1
- package/lib/esm/test/ElementLRUCache.test.js.map +1 -1
- package/lib/esm/test/GeometryTestUtil.js.map +1 -1
- package/lib/esm/test/IModelHost.test.js.map +1 -1
- package/lib/esm/test/IModelTestUtils.js.map +1 -1
- package/lib/esm/test/ImageSourceConversion.test.js.map +1 -1
- package/lib/esm/test/IpcHost.test.js.map +1 -1
- package/lib/esm/test/KnownTestLocations.js.map +1 -1
- package/lib/esm/test/PrintElementTree.js.map +1 -1
- package/lib/esm/test/PropertyDb.test.js.map +1 -1
- package/lib/esm/test/RevisionUtility.js.map +1 -1
- package/lib/esm/test/SchemaUtils.test.js +25 -25
- package/lib/esm/test/SchemaUtils.test.js.map +1 -1
- package/lib/esm/test/SequentialLogMatcher.js.map +1 -1
- package/lib/esm/test/TestChangeSetUtility.js.map +1 -1
- package/lib/esm/test/TestUtils.js.map +1 -1
- package/lib/esm/test/annotations/Fields.test.js +53 -53
- package/lib/esm/test/annotations/Fields.test.js.map +1 -1
- package/lib/esm/test/annotations/FrameGeometry.test.js.map +1 -1
- package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
- package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
- package/lib/esm/test/annotations/TextBlock.test.js.map +1 -1
- package/lib/esm/test/assets/IncrementalSchemaLocater/configs/old.config.js.map +1 -1
- package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.js +5 -5
- package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.js.map +1 -1
- package/lib/esm/test/categories/Category.test.js.map +1 -1
- package/lib/esm/test/codespec/CodeSpec.test.js.map +1 -1
- package/lib/esm/test/ecdb/CTE.test.js +88 -88
- package/lib/esm/test/ecdb/CTE.test.js.map +1 -1
- package/lib/esm/test/ecdb/ConcurrentQuery.test.js +15 -15
- package/lib/esm/test/ecdb/ConcurrentQuery.test.js.map +1 -1
- package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.js +15 -15
- package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECDb.test.js +72 -72
- package/lib/esm/test/ecdb/ECDb.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECDbTestHelper.js.map +1 -1
- package/lib/esm/test/ecdb/ECSchemaXmlContext.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlAst.test.js +65 -65
- package/lib/esm/test/ecdb/ECSqlAst.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlReader.test.js +16 -16
- package/lib/esm/test/ecdb/ECSqlReader.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlStatement.test.js +332 -332
- package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
- package/lib/esm/test/ecdb/SqliteStatement.test.js.map +1 -1
- package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestGenerator.js +21 -21
- package/lib/esm/test/ecsql/src/ECSqlTestGenerator.js.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestParser.js.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
- package/lib/esm/test/element/DeleteDefinitionElements.test.js.map +1 -1
- package/lib/esm/test/element/ElementAspect.test.js +22 -22
- package/lib/esm/test/element/ElementAspect.test.js.map +1 -1
- package/lib/esm/test/element/ElementDependencyGraph.test.js.map +1 -1
- package/lib/esm/test/element/ElementRoundTrip.test.js +139 -139
- package/lib/esm/test/element/ElementRoundTrip.test.js.map +1 -1
- package/lib/esm/test/element/ExcludedElements.test.js.map +1 -1
- package/lib/esm/test/element/ExternalSource.test.js.map +1 -1
- package/lib/esm/test/element/NullStructArray.test.js +13 -13
- package/lib/esm/test/element/NullStructArray.test.js.map +1 -1
- package/lib/esm/test/element/ProjectInformationRecord.test.js.map +1 -1
- package/lib/esm/test/element/SheetInformationAspect.test.js.map +1 -1
- package/lib/esm/test/element/UrlLink.test.js.map +1 -1
- package/lib/esm/test/font/FontFile.test.js.map +1 -1
- package/lib/esm/test/font/IModelDbFonts.test.js.map +1 -1
- package/lib/esm/test/hubaccess/ApplyChangeset.test.js +32 -32
- package/lib/esm/test/hubaccess/ApplyChangeset.test.js.map +1 -1
- package/lib/esm/test/hubaccess/BriefcaseManager.test.js.map +1 -1
- package/lib/esm/test/hubaccess/CheckpointManager.test.js.map +1 -1
- package/lib/esm/test/hubaccess/Rebase.test.js +40 -40
- package/lib/esm/test/hubaccess/Rebase.test.js.map +1 -1
- package/lib/esm/test/imageData.js.map +1 -1
- package/lib/esm/test/imodel/Code.test.js.map +1 -1
- package/lib/esm/test/imodel/ElementTreeWalker.test.js.map +1 -1
- package/lib/esm/test/imodel/GetTextureImage.test.js.map +1 -1
- package/lib/esm/test/imodel/IModel.test.js +44 -44
- package/lib/esm/test/imodel/IModel.test.js.map +1 -1
- package/lib/esm/test/imodel/ProjectExtents.test.js.map +1 -1
- package/lib/esm/test/imodel/SchemaXmlImport.test.js.map +1 -1
- package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js +432 -198
- package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js.map +1 -1
- package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.js +272 -190
- package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.js.map +1 -1
- package/lib/esm/test/incrementalSchemaLocater/TestContext.d.ts +27 -0
- package/lib/esm/test/incrementalSchemaLocater/TestContext.d.ts.map +1 -0
- package/lib/esm/test/incrementalSchemaLocater/TestContext.js +136 -0
- package/lib/esm/test/incrementalSchemaLocater/TestContext.js.map +1 -0
- package/lib/esm/test/index.js.map +1 -1
- package/lib/esm/test/misc/DevTools.test.js.map +1 -1
- package/lib/esm/test/misc/EntitySubClasses.test.js.map +1 -1
- package/lib/esm/test/misc/GeoServices.test.js.map +1 -1
- package/lib/esm/test/misc/PromiseMemoizer.test.js.map +1 -1
- package/lib/esm/test/native/DgnDbWorker.test.js.map +1 -1
- package/lib/esm/test/rpc/response.test.js.map +1 -1
- package/lib/esm/test/schema/ClassRegistry.test.js +99 -99
- package/lib/esm/test/schema/ClassRegistry.test.js.map +1 -1
- package/lib/esm/test/schema/FunctionalDomain.test.js.map +1 -1
- package/lib/esm/test/schema/GenericDomain.test.js.map +1 -1
- package/lib/esm/test/schema/IModelSchemaContext.test.js.map +1 -1
- package/lib/esm/test/sheetindex/SheetIndex.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangeMerge.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangesetReader.test.js +346 -127
- package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
- package/lib/esm/test/standalone/CustomViewState3dCreator.test.js.map +1 -1
- package/lib/esm/test/standalone/DisplayStyle.test.js.map +1 -1
- package/lib/esm/test/standalone/Drawing.test.js.map +1 -1
- package/lib/esm/test/standalone/ElementGraphics.test.js.map +1 -1
- package/lib/esm/test/standalone/ElementMesh.test.js.map +1 -1
- package/lib/esm/test/standalone/ExportGraphics.test.js +14 -14
- package/lib/esm/test/standalone/ExportGraphics.test.js.map +1 -1
- package/lib/esm/test/standalone/GeometryChangeEvents.test.js.map +1 -1
- package/lib/esm/test/standalone/GeometryStream.test.js.map +1 -1
- package/lib/esm/test/standalone/HubMock.test.js.map +1 -1
- package/lib/esm/test/standalone/IModelLimits.test.js.map +1 -1
- package/lib/esm/test/standalone/IModelWrite.test.js +27 -27
- package/lib/esm/test/standalone/IModelWrite.test.js.map +1 -1
- package/lib/esm/test/standalone/InlineGeometryPartReferences.test.js.map +1 -1
- package/lib/esm/test/standalone/MergeConflict.test.js.map +1 -1
- package/lib/esm/test/standalone/NativeAppStorage.test.js.map +1 -1
- package/lib/esm/test/standalone/RenderMaterialElement.test.js.map +1 -1
- package/lib/esm/test/standalone/RenderTimeline.test.js.map +1 -1
- package/lib/esm/test/standalone/SQLiteDb.test.js.map +1 -1
- package/lib/esm/test/standalone/SchemaUtils.test.js.map +1 -1
- package/lib/esm/test/standalone/SectionDrawing.test.js.map +1 -1
- package/lib/esm/test/standalone/ServerBasedLocks.test.js.map +1 -1
- package/lib/esm/test/standalone/Setting.test.js.map +1 -1
- package/lib/esm/test/standalone/Settings.test.js.map +1 -1
- package/lib/esm/test/standalone/SettingsSchemas.test.js.map +1 -1
- package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
- package/lib/esm/test/standalone/Texture.test.js.map +1 -1
- package/lib/esm/test/standalone/TileCache.test.js.map +1 -1
- package/lib/esm/test/standalone/TileTree.test.js.map +1 -1
- package/lib/esm/test/standalone/TxnManager.test.js.map +1 -1
- package/lib/esm/test/standalone/ViewDefinition.test.js.map +1 -1
- package/lib/esm/test/standalone/ViewStoreDb.test.js.map +1 -1
- package/lib/esm/test/standalone/Workspace.test.js.map +1 -1
- package/lib/esm/workspace/Settings.js.map +1 -1
- package/lib/esm/workspace/SettingsSchemas.js.map +1 -1
- package/lib/esm/workspace/Workspace.js.map +1 -1
- package/lib/esm/workspace/WorkspaceEditor.js.map +1 -1
- package/package.json +14 -14
- package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.d.ts +0 -11
- package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.d.ts.map +0 -1
- package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.js +0 -36
- package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.js.map +0 -1
- package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.d.ts +0 -20
- package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.d.ts.map +0 -1
- package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.js +0 -126
- package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.js.map +0 -1
- package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.d.ts +0 -24
- package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.d.ts.map +0 -1
- package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.js +0 -67
- package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementAspect.js","sourceRoot":"","sources":["../../src/ElementAspect.ts"],"names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AC,CAAC;IAC5C,CAAC;CACF;AAtFD,oDAsFC;AAED,uBAAuB;AACvB,WAAiB,oBAAoB;IACnC;;OAEG;IACH,IAAY,IASX;IATD,WAAY,IAAI;QACd,oFAAoF;QACpF,2BAAmB,CAAA;QACnB,yFAAyF;QACzF,qCAA6B,CAAA;QAC7B;;WAEG;QACH,uBAAe,CAAA;IACjB,CAAC,EATW,IAAI,GAAJ,yBAAI,KAAJ,yBAAI,QASf;AACH,CAAC,EAdgB,oBAAoB,oCAApB,oBAAoB,QAcpC","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 ElementAspects\n */\n\nimport { ChannelRootAspectProps, ElementAspectProps, EntityReferenceSet, ExternalSourceAspectProps, RelatedElement, SheetInformation, SheetInformationAspectProps } from \"@itwin/core-common\";\nimport { Entity } from \"./Entity\";\nimport { IModelDb } from \"./IModelDb\";\nimport { ECSqlStatement } from \"./ECSqlStatement\";\nimport { assert, DbResult, Id64String } from \"@itwin/core-bentley\";\nimport { _verifyChannel } from \"./internal/Symbols\";\nimport { SheetOwnsSheetInformationAspect } from \"./NavigationRelationship\";\nimport { Sheet } from \"./Element\";\nimport { ECVersion } from \"@itwin/ecschema-metadata\";\n\n/** Argument for the `ElementAspect.onXxx` static methods\n * @beta\n */\nexport interface OnAspectArg {\n /** The iModel for the aspect affected by this event. */\n iModel: IModelDb;\n /** The model for the aspect affected by this event */\n model: Id64String;\n}\n/** Argument for the `ElementAspect.onXxx` static methods that supply the properties of an aspect to be inserted or updated.\n * @beta\n */\nexport interface OnAspectPropsArg extends OnAspectArg {\n /** The new properties of the aspect affected by this event. */\n props: Readonly<ElementAspectProps>;\n}\n/** Argument for the `ElementAspect.onXxx` static methods that only supply the Id of the affected aspect.\n * @beta\n */\nexport interface OnAspectIdArg extends OnAspectArg {\n /** The Id of the aspect affected by this event */\n aspectId: Id64String;\n}\n\n/** An Element Aspect is a class that defines a set of properties that are related to (and owned by) a single element.\n * Semantically, an ElementAspect can be considered part of the Element. Thus, an ElementAspect is deleted if its owning Element is deleted.\n * BIS Guideline: Subclass ElementUniqueAspect or ElementMultiAspect rather than subclassing ElementAspect directly.\n * @public @preview\n */\nexport class ElementAspect extends Entity {\n public static override get className(): string { return \"ElementAspect\"; }\n public element: RelatedElement;\n\n /** Construct an aspect from its JSON representation and its containing iModel. */\n constructor(props: ElementAspectProps, iModel: IModelDb) {\n super(props, iModel);\n this.element = RelatedElement.fromJSON(props.element)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n }\n\n public override toJSON(): ElementAspectProps {\n const val = super.toJSON() as ElementAspectProps;\n val.element = this.element;\n return val;\n }\n\n /** Called before a new ElementAspect is inserted.\n * @note throw an exception to disallow the insert\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onInsert(arg: OnAspectPropsArg): void {\n const { props, iModel } = arg;\n iModel.channels[_verifyChannel](arg.model);\n iModel.locks.checkExclusiveLock(props.element.id, \"element\", \"insert aspect\");\n }\n\n /** Called after a new ElementAspect was inserted.\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onInserted(_arg: OnAspectPropsArg): void { }\n\n /** Called before an ElementAspect is updated.\n * @note throw an exception to disallow the update\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onUpdate(arg: OnAspectPropsArg): void {\n const { props, iModel } = arg;\n iModel.channels[_verifyChannel](arg.model);\n iModel.locks.checkExclusiveLock(props.element.id, \"element\", \"update aspect\");\n }\n\n /** Called after an ElementAspect was updated.\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onUpdated(_arg: OnAspectPropsArg): void { }\n\n /** Called before an ElementAspect is deleted.\n * @note throw an exception to disallow the delete\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onDelete(arg: OnAspectIdArg): void {\n const { aspectId, iModel } = arg;\n iModel.channels[_verifyChannel](arg.model);\n const { element } = iModel.elements.getAspect(aspectId);\n iModel.locks.checkExclusiveLock(element.id, \"element\", \"delete aspect\");\n }\n\n /** Called after an ElementAspect was deleted.\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onDeleted(_arg: OnAspectIdArg): void { }\n}\n/** An Element Unique Aspect is an ElementAspect where there can be only zero or one instance of the Element Aspect class per Element.\n * @public @preview\n */\nexport class ElementUniqueAspect extends ElementAspect {\n public static override get className(): string { return \"ElementUniqueAspect\"; }\n}\n\n/** An Element Multi-Aspect is an ElementAspect where there can be **n** instances of the Element Aspect class per Element.\n * @public @preview\n */\nexport class ElementMultiAspect extends ElementAspect {\n public static override get className(): string { return \"ElementMultiAspect\"; }\n}\n\n/**\n * @public @preview\n */\nexport class ChannelRootAspect extends ElementUniqueAspect {\n public static override get className(): string { return \"ChannelRootAspect\"; }\n /** Insert a ChannelRootAspect on the specified element.\n * @deprecated in 4.0 - will not be removed until after 2026-06-13. Use [[ChannelControl.makeChannelRoot]]. This method does not enforce the rule that channels may not nest and is therefore dangerous.\n */\n public static insert(iModel: IModelDb, ownerId: Id64String, channelName: string) {\n const props: ChannelRootAspectProps = { classFullName: this.classFullName, element: { id: ownerId }, owner: channelName };\n iModel.elements.insertAspect(props);\n }\n}\n\nconst minimumBisCoreVersion = new ECVersion(1, 0, 25);\n\n/** An [[ElementUniqueAspect]] that captures common metadata about a single [[Sheet]].\n * Use [[getSheetInformation]] to retrieve the metadata for a Sheet and [[setSheetInformation]] to create, update, or delete it.\n * @beta\n */\nexport class SheetInformationAspect extends ElementUniqueAspect {\n public static override get className() { return \"SheetInformationAspect\"; }\n \n /** The sheet's metadata. */\n public sheetInformation: SheetInformation;\n\n protected static override onInsert(arg: OnAspectPropsArg): void {\n super.onInsert(arg);\n\n const sheet = arg.iModel.elements.tryGetElement<Sheet>(arg.props.element);\n if (!(sheet instanceof Sheet)) {\n throw new Error(\"SheetInformationAspect can only be applied to a Sheet element\");\n }\n }\n\n private constructor(props: SheetInformationAspectProps, iModel: IModelDb) {\n super(props, iModel);\n\n const designedDate = undefined !== props.designedDate ? new Date(props.designedDate) : undefined;\n\n this.sheetInformation = {\n designedBy: props.designedBy,\n designedDate,\n drawnBy: props.drawnBy,\n checkedBy: props.checkedBy,\n };\n }\n\n public override toJSON(): SheetInformationAspectProps {\n const props = super.toJSON() as SheetInformationAspectProps;\n for (const key of [\"designedBy\", \"drawnBy\", \"checkedBy\"] as const) {\n const value = this.sheetInformation[key];\n if (undefined !== value) {\n props[key] = value;\n }\n }\n\n if (undefined !== this.sheetInformation.designedDate) {\n props.designedDate = this.sheetInformation.designedDate.toISOString();\n }\n\n return props;\n }\n\n private static findForSheet(sheetId: Id64String, iModel: IModelDb): SheetInformationAspect | undefined {\n if (!iModel.meetsMinimumSchemaVersion(\"BisCore\", minimumBisCoreVersion)) {\n return undefined;\n }\n\n const aspects = iModel.elements.getAspects(sheetId, this.classFullName);\n if (aspects[0]) {\n assert(aspects[0] instanceof SheetInformationAspect);\n return aspects[0];\n }\n\n return undefined;\n }\n\n /** Retrieves the metadata hosted by the aspect on the specified sheet, returning `undefined` if no such metadata could be retrieved.\n * @see [[setSheetInformation]] to create, update, or delete the aspect.\n */\n public static getSheetInformation(sheetId: Id64String, iModel: IModelDb): SheetInformation | undefined {\n const aspect = this.findForSheet(sheetId, iModel);\n return aspect?.sheetInformation;\n }\n\n /** Sets the `information` for the [[Sheet]] element specified by ``sheetId`.\n * If `information` is `undefined`, any existing aspect will be deleted.\n * Otherwise, a new aspect will be inserted, or an existing aspect will be updated with the new metadata.\n * @throws Error if the iModel contains a version of the BisCore schema older than 01.00.25.\n */\n public static setSheetInformation(information: SheetInformation | undefined, sheetId: Id64String, iModel: IModelDb): void {\n iModel.requireMinimumSchemaVersion(\"BisCore\", minimumBisCoreVersion, \"SheetInformationAspect\");\n\n const aspect = this.findForSheet(sheetId, iModel);\n if (!information) {\n if (aspect) {\n iModel.elements.deleteAspect(aspect.id);\n }\n\n return;\n }\n\n if (aspect) {\n aspect.sheetInformation = { ...information };\n iModel.elements.updateAspect(aspect.toJSON());\n } else {\n const info = { ...information } as any;\n for (const key of Object.keys(info)) {\n if (info[key] === undefined) {\n delete info[key];\n }\n }\n\n if (undefined !== info.designedDate) {\n info.designedDate = info.designedDate.toISOString();\n }\n\n const props: SheetInformationAspectProps = {\n classFullName: this.classFullName,\n element: {\n id: sheetId,\n relClassName: SheetOwnsSheetInformationAspect.classFullName,\n },\n ...info,\n };\n\n iModel.elements.insertAspect(props);\n }\n }\n}\n\n/** An ElementMultiAspect that stores synchronization information for an Element originating from an external source.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.2\n * @public @preview\n */\nexport class ExternalSourceAspect extends ElementMultiAspect {\n public static override get className(): string { return \"ExternalSourceAspect\"; }\n\n /** An element that scopes the combination of `kind` and `identifier` to uniquely identify the object from the external source.\n * @note Warning: in a future major release the `scope` property will be optional, since the scope is intended to be potentially invalid.\n * all references should treat it as potentially undefined, but we cannot change the type yet since that is a breaking change.\n */\n public scope: RelatedElement;\n /** The identifier of the object in the source repository. */\n public identifier: string;\n /** The kind of object within the source repository. */\n public kind: string;\n /** The cryptographic hash (any algorithm) of the source object's content. If defined, it must be guaranteed to change when the source object's content changes. */\n public checksum?: string;\n /** An optional value that is typically a version number or a pseudo version number like last modified time.\n * It will be used by the synchronization process to detect that a source object is unchanged so that computing a cryptographic hash can be avoided.\n * If present, this value must be guaranteed to change when any of the source object's content changes.\n */\n public version?: string;\n /** A place where additional JSON properties can be stored. For example, provenance information or properties relating to the synchronization process.\n * @note Warning: in a future major release, the type of `jsonProperties` will be changed to object, and itwin.js will automatically stringify it when writing to the iModel.\n * This will be a breaking change, since application code will have to change from supplying a string to supplying an object.\n */\n public jsonProperties?: string;\n /** The source of the imported/synchronized object. Should point to an instance of [ExternalSource]($backend). */\n public source?: RelatedElement;\n\n /** Construct an aspect from its JSON representation and its containing iModel. */\n constructor(props: ExternalSourceAspectProps, iModel: IModelDb) {\n super(props, iModel);\n this.scope = RelatedElement.fromJSON(props.scope)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n this.source = RelatedElement.fromJSON(props.source);\n this.identifier = props.identifier;\n this.kind = props.kind;\n this.checksum = props.checksum;\n this.version = props.version;\n this.jsonProperties = props.jsonProperties;\n }\n\n /** Look up the elements that contain one or more ExternalSourceAspect with the specified Scope, Kind, and Identifier.\n * The result of this function is an array of all of the ExternalSourceAspects that were found, each associated with the owning element.\n * A given element could have more than one ExternalSourceAspect with the given scope, kind, and identifier.\n * Also, many elements could have ExternalSourceAspect with the same scope, kind, and identifier.\n * Therefore, the result array could have more than one entry with the same elementId.\n * Aspects are never shared. Each aspect has its own unique ECInstanceId.\n * @param iModelDb The iModel to query\n * @param scope The scope of the ExternalSourceAspects to find\n * @param kind The kind of the ExternalSourceAspects to find\n * @param identifier The identifier of the ExternalSourceAspects to find\n * @returns the query results\n */\n public static findAllBySource(iModelDb: IModelDb, scope: Id64String, kind: string, identifier: string): Array<{ elementId: Id64String, aspectId: Id64String }> {\n const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;\n const found: Array<{ elementId: Id64String, aspectId: Id64String }> = [];\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n iModelDb.withPreparedStatement(sql, (statement: ECSqlStatement) => {\n statement.bindId(\"scope\", scope);\n statement.bindString(\"kind\", kind);\n statement.bindString(\"identifier\", identifier);\n while (DbResult.BE_SQLITE_ROW === statement.step()) {\n found.push({ elementId: statement.getValue(0).getId(), aspectId: statement.getValue(1).getId() });\n }\n });\n return found;\n }\n\n public override toJSON(): ExternalSourceAspectProps {\n const val = super.toJSON() as ExternalSourceAspectProps;\n val.scope = this.scope;\n val.source = this.source;\n val.identifier = this.identifier;\n val.kind = this.kind;\n val.checksum = this.checksum;\n val.version = this.version;\n val.jsonProperties = this.jsonProperties;\n return val;\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n if (this.scope)\n referenceIds.addElement(this.scope.id);\n referenceIds.addElement(this.element.id);\n if (this.source)\n referenceIds.addElement(this.source.id);\n }\n}\n\n/** @public @preview */\nexport namespace ExternalSourceAspect {\n /** Standard values for the `Kind` property of `ExternalSourceAspect`.\n * @public @preview\n */\n export enum Kind {\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Element]] provenance */\n Element = \"Element\",\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Relationship]] provenance */\n Relationship = \"Relationship\",\n /** Indicates that the [[ExternalSourceAspect]] is storing *scope* provenance\n * @see [[ExternalSourceAspect.scope]]\n */\n Scope = \"Scope\",\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ElementAspect.js","sourceRoot":"","sources":["../../src/ElementAspect.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAA8L;AAC9L,qCAAkC;AAGlC,sDAAmE;AACnE,gDAAoD;AACpD,qEAA2E;AAC3E,uCAAkC;AAClC,gEAAqD;AA0BrD;;;;GAIG;AACH,MAAa,aAAc,SAAQ,eAAM;IAChC,MAAM,KAAc,SAAS,KAAa,OAAO,eAAe,CAAC,CAAC,CAAC;IACnE,OAAO,CAAiB;IAE/B,kFAAkF;IAClF,YAAY,KAAyB,EAAE,MAAgB;QACrD,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,4BAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAE,CAAC,CAAC,+DAA+D;IACzH,CAAC;IAEe,MAAM;QACpB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAwB,CAAC;QACjD,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC3B,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;OAIG;IACO,MAAM,CAAC,QAAQ,CAAC,GAAqB;QAC7C,MAAM,EAAE,KAAK,EAAE,MAAM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Q,CAAC;QAC7B,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC3B,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QACzC,OAAO,GAAG,CAAC;IACb,CAAC;IAEkB,mBAAmB,CAAC,YAAgC;QACrE,KAAK,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;QACxC,IAAI,IAAI,CAAC,KAAK;YACZ,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACzC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACzC,IAAI,IAAI,CAAC,MAAM;YACb,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC;CACF;AAtFD,oDAsFC;AAED,uBAAuB;AACvB,WAAiB,oBAAoB;IACnC;;OAEG;IACH,IAAY,IASX;IATD,WAAY,IAAI;QACd,oFAAoF;QACpF,2BAAmB,CAAA;QACnB,yFAAyF;QACzF,qCAA6B,CAAA;QAC7B;;WAEG;QACH,uBAAe,CAAA;IACjB,CAAC,EATW,IAAI,GAAJ,yBAAI,KAAJ,yBAAI,QASf;AACH,CAAC,EAdgB,oBAAoB,oCAApB,oBAAoB,QAcpC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ElementAspects\r\n */\r\n\r\nimport { ChannelRootAspectProps, ElementAspectProps, EntityReferenceSet, ExternalSourceAspectProps, RelatedElement, SheetInformation, SheetInformationAspectProps } from \"@itwin/core-common\";\r\nimport { Entity } from \"./Entity\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { assert, DbResult, Id64String } from \"@itwin/core-bentley\";\r\nimport { _verifyChannel } from \"./internal/Symbols\";\r\nimport { SheetOwnsSheetInformationAspect } from \"./NavigationRelationship\";\r\nimport { Sheet } from \"./Element\";\r\nimport { ECVersion } from \"@itwin/ecschema-metadata\";\r\n\r\n/** Argument for the `ElementAspect.onXxx` static methods\r\n * @beta\r\n */\r\nexport interface OnAspectArg {\r\n /** The iModel for the aspect affected by this event. */\r\n iModel: IModelDb;\r\n /** The model for the aspect affected by this event */\r\n model: Id64String;\r\n}\r\n/** Argument for the `ElementAspect.onXxx` static methods that supply the properties of an aspect to be inserted or updated.\r\n * @beta\r\n */\r\nexport interface OnAspectPropsArg extends OnAspectArg {\r\n /** The new properties of the aspect affected by this event. */\r\n props: Readonly<ElementAspectProps>;\r\n}\r\n/** Argument for the `ElementAspect.onXxx` static methods that only supply the Id of the affected aspect.\r\n * @beta\r\n */\r\nexport interface OnAspectIdArg extends OnAspectArg {\r\n /** The Id of the aspect affected by this event */\r\n aspectId: Id64String;\r\n}\r\n\r\n/** An Element Aspect is a class that defines a set of properties that are related to (and owned by) a single element.\r\n * Semantically, an ElementAspect can be considered part of the Element. Thus, an ElementAspect is deleted if its owning Element is deleted.\r\n * BIS Guideline: Subclass ElementUniqueAspect or ElementMultiAspect rather than subclassing ElementAspect directly.\r\n * @public @preview\r\n */\r\nexport class ElementAspect extends Entity {\r\n public static override get className(): string { return \"ElementAspect\"; }\r\n public element: RelatedElement;\r\n\r\n /** Construct an aspect from its JSON representation and its containing iModel. */\r\n constructor(props: ElementAspectProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.element = RelatedElement.fromJSON(props.element)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n }\r\n\r\n public override toJSON(): ElementAspectProps {\r\n const val = super.toJSON() as ElementAspectProps;\r\n val.element = this.element;\r\n return val;\r\n }\r\n\r\n /** Called before a new ElementAspect is inserted.\r\n * @note throw an exception to disallow the insert\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onInsert(arg: OnAspectPropsArg): void {\r\n const { props, iModel } = arg;\r\n iModel.channels[_verifyChannel](arg.model);\r\n iModel.locks.checkExclusiveLock(props.element.id, \"element\", \"insert aspect\");\r\n }\r\n\r\n /** Called after a new ElementAspect was inserted.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onInserted(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called before an ElementAspect is updated.\r\n * @note throw an exception to disallow the update\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onUpdate(arg: OnAspectPropsArg): void {\r\n const { props, iModel } = arg;\r\n iModel.channels[_verifyChannel](arg.model);\r\n iModel.locks.checkExclusiveLock(props.element.id, \"element\", \"update aspect\");\r\n }\r\n\r\n /** Called after an ElementAspect was updated.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onUpdated(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called before an ElementAspect is deleted.\r\n * @note throw an exception to disallow the delete\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onDelete(arg: OnAspectIdArg): void {\r\n const { aspectId, iModel } = arg;\r\n iModel.channels[_verifyChannel](arg.model);\r\n const { element } = iModel.elements.getAspect(aspectId);\r\n iModel.locks.checkExclusiveLock(element.id, \"element\", \"delete aspect\");\r\n }\r\n\r\n /** Called after an ElementAspect was deleted.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onDeleted(_arg: OnAspectIdArg): void { }\r\n}\r\n/** An Element Unique Aspect is an ElementAspect where there can be only zero or one instance of the Element Aspect class per Element.\r\n * @public @preview\r\n */\r\nexport class ElementUniqueAspect extends ElementAspect {\r\n public static override get className(): string { return \"ElementUniqueAspect\"; }\r\n}\r\n\r\n/** An Element Multi-Aspect is an ElementAspect where there can be **n** instances of the Element Aspect class per Element.\r\n * @public @preview\r\n */\r\nexport class ElementMultiAspect extends ElementAspect {\r\n public static override get className(): string { return \"ElementMultiAspect\"; }\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport class ChannelRootAspect extends ElementUniqueAspect {\r\n public static override get className(): string { return \"ChannelRootAspect\"; }\r\n /** Insert a ChannelRootAspect on the specified element.\r\n * @deprecated in 4.0 - will not be removed until after 2026-06-13. Use [[ChannelControl.makeChannelRoot]]. This method does not enforce the rule that channels may not nest and is therefore dangerous.\r\n */\r\n public static insert(iModel: IModelDb, ownerId: Id64String, channelName: string) {\r\n const props: ChannelRootAspectProps = { classFullName: this.classFullName, element: { id: ownerId }, owner: channelName };\r\n iModel.elements.insertAspect(props);\r\n }\r\n}\r\n\r\nconst minimumBisCoreVersion = new ECVersion(1, 0, 25);\r\n\r\n/** An [[ElementUniqueAspect]] that captures common metadata about a single [[Sheet]].\r\n * Use [[getSheetInformation]] to retrieve the metadata for a Sheet and [[setSheetInformation]] to create, update, or delete it.\r\n * @beta\r\n */\r\nexport class SheetInformationAspect extends ElementUniqueAspect {\r\n public static override get className() { return \"SheetInformationAspect\"; }\r\n \r\n /** The sheet's metadata. */\r\n public sheetInformation: SheetInformation;\r\n\r\n protected static override onInsert(arg: OnAspectPropsArg): void {\r\n super.onInsert(arg);\r\n\r\n const sheet = arg.iModel.elements.tryGetElement<Sheet>(arg.props.element);\r\n if (!(sheet instanceof Sheet)) {\r\n throw new Error(\"SheetInformationAspect can only be applied to a Sheet element\");\r\n }\r\n }\r\n\r\n private constructor(props: SheetInformationAspectProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n\r\n const designedDate = undefined !== props.designedDate ? new Date(props.designedDate) : undefined;\r\n\r\n this.sheetInformation = {\r\n designedBy: props.designedBy,\r\n designedDate,\r\n drawnBy: props.drawnBy,\r\n checkedBy: props.checkedBy,\r\n };\r\n }\r\n\r\n public override toJSON(): SheetInformationAspectProps {\r\n const props = super.toJSON() as SheetInformationAspectProps;\r\n for (const key of [\"designedBy\", \"drawnBy\", \"checkedBy\"] as const) {\r\n const value = this.sheetInformation[key];\r\n if (undefined !== value) {\r\n props[key] = value;\r\n }\r\n }\r\n\r\n if (undefined !== this.sheetInformation.designedDate) {\r\n props.designedDate = this.sheetInformation.designedDate.toISOString();\r\n }\r\n\r\n return props;\r\n }\r\n\r\n private static findForSheet(sheetId: Id64String, iModel: IModelDb): SheetInformationAspect | undefined {\r\n if (!iModel.meetsMinimumSchemaVersion(\"BisCore\", minimumBisCoreVersion)) {\r\n return undefined;\r\n }\r\n\r\n const aspects = iModel.elements.getAspects(sheetId, this.classFullName);\r\n if (aspects[0]) {\r\n assert(aspects[0] instanceof SheetInformationAspect);\r\n return aspects[0];\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Retrieves the metadata hosted by the aspect on the specified sheet, returning `undefined` if no such metadata could be retrieved.\r\n * @see [[setSheetInformation]] to create, update, or delete the aspect.\r\n */\r\n public static getSheetInformation(sheetId: Id64String, iModel: IModelDb): SheetInformation | undefined {\r\n const aspect = this.findForSheet(sheetId, iModel);\r\n return aspect?.sheetInformation;\r\n }\r\n\r\n /** Sets the `information` for the [[Sheet]] element specified by ``sheetId`.\r\n * If `information` is `undefined`, any existing aspect will be deleted.\r\n * Otherwise, a new aspect will be inserted, or an existing aspect will be updated with the new metadata.\r\n * @throws Error if the iModel contains a version of the BisCore schema older than 01.00.25.\r\n */\r\n public static setSheetInformation(information: SheetInformation | undefined, sheetId: Id64String, iModel: IModelDb): void {\r\n iModel.requireMinimumSchemaVersion(\"BisCore\", minimumBisCoreVersion, \"SheetInformationAspect\");\r\n\r\n const aspect = this.findForSheet(sheetId, iModel);\r\n if (!information) {\r\n if (aspect) {\r\n iModel.elements.deleteAspect(aspect.id);\r\n }\r\n\r\n return;\r\n }\r\n\r\n if (aspect) {\r\n aspect.sheetInformation = { ...information };\r\n iModel.elements.updateAspect(aspect.toJSON());\r\n } else {\r\n const info = { ...information } as any;\r\n for (const key of Object.keys(info)) {\r\n if (info[key] === undefined) {\r\n delete info[key];\r\n }\r\n }\r\n\r\n if (undefined !== info.designedDate) {\r\n info.designedDate = info.designedDate.toISOString();\r\n }\r\n\r\n const props: SheetInformationAspectProps = {\r\n classFullName: this.classFullName,\r\n element: {\r\n id: sheetId,\r\n relClassName: SheetOwnsSheetInformationAspect.classFullName,\r\n },\r\n ...info,\r\n };\r\n\r\n iModel.elements.insertAspect(props);\r\n }\r\n }\r\n}\r\n\r\n/** An ElementMultiAspect that stores synchronization information for an Element originating from an external source.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.2\r\n * @public @preview\r\n */\r\nexport class ExternalSourceAspect extends ElementMultiAspect {\r\n public static override get className(): string { return \"ExternalSourceAspect\"; }\r\n\r\n /** An element that scopes the combination of `kind` and `identifier` to uniquely identify the object from the external source.\r\n * @note Warning: in a future major release the `scope` property will be optional, since the scope is intended to be potentially invalid.\r\n * all references should treat it as potentially undefined, but we cannot change the type yet since that is a breaking change.\r\n */\r\n public scope: RelatedElement;\r\n /** The identifier of the object in the source repository. */\r\n public identifier: string;\r\n /** The kind of object within the source repository. */\r\n public kind: string;\r\n /** The cryptographic hash (any algorithm) of the source object's content. If defined, it must be guaranteed to change when the source object's content changes. */\r\n public checksum?: string;\r\n /** An optional value that is typically a version number or a pseudo version number like last modified time.\r\n * It will be used by the synchronization process to detect that a source object is unchanged so that computing a cryptographic hash can be avoided.\r\n * If present, this value must be guaranteed to change when any of the source object's content changes.\r\n */\r\n public version?: string;\r\n /** A place where additional JSON properties can be stored. For example, provenance information or properties relating to the synchronization process.\r\n * @note Warning: in a future major release, the type of `jsonProperties` will be changed to object, and itwin.js will automatically stringify it when writing to the iModel.\r\n * This will be a breaking change, since application code will have to change from supplying a string to supplying an object.\r\n */\r\n public jsonProperties?: string;\r\n /** The source of the imported/synchronized object. Should point to an instance of [ExternalSource]($backend). */\r\n public source?: RelatedElement;\r\n\r\n /** Construct an aspect from its JSON representation and its containing iModel. */\r\n constructor(props: ExternalSourceAspectProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.scope = RelatedElement.fromJSON(props.scope)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n this.source = RelatedElement.fromJSON(props.source);\r\n this.identifier = props.identifier;\r\n this.kind = props.kind;\r\n this.checksum = props.checksum;\r\n this.version = props.version;\r\n this.jsonProperties = props.jsonProperties;\r\n }\r\n\r\n /** Look up the elements that contain one or more ExternalSourceAspect with the specified Scope, Kind, and Identifier.\r\n * The result of this function is an array of all of the ExternalSourceAspects that were found, each associated with the owning element.\r\n * A given element could have more than one ExternalSourceAspect with the given scope, kind, and identifier.\r\n * Also, many elements could have ExternalSourceAspect with the same scope, kind, and identifier.\r\n * Therefore, the result array could have more than one entry with the same elementId.\r\n * Aspects are never shared. Each aspect has its own unique ECInstanceId.\r\n * @param iModelDb The iModel to query\r\n * @param scope The scope of the ExternalSourceAspects to find\r\n * @param kind The kind of the ExternalSourceAspects to find\r\n * @param identifier The identifier of the ExternalSourceAspects to find\r\n * @returns the query results\r\n */\r\n public static findAllBySource(iModelDb: IModelDb, scope: Id64String, kind: string, identifier: string): Array<{ elementId: Id64String, aspectId: Id64String }> {\r\n const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;\r\n const found: Array<{ elementId: Id64String, aspectId: Id64String }> = [];\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n iModelDb.withPreparedStatement(sql, (statement: ECSqlStatement) => {\r\n statement.bindId(\"scope\", scope);\r\n statement.bindString(\"kind\", kind);\r\n statement.bindString(\"identifier\", identifier);\r\n while (DbResult.BE_SQLITE_ROW === statement.step()) {\r\n found.push({ elementId: statement.getValue(0).getId(), aspectId: statement.getValue(1).getId() });\r\n }\r\n });\r\n return found;\r\n }\r\n\r\n public override toJSON(): ExternalSourceAspectProps {\r\n const val = super.toJSON() as ExternalSourceAspectProps;\r\n val.scope = this.scope;\r\n val.source = this.source;\r\n val.identifier = this.identifier;\r\n val.kind = this.kind;\r\n val.checksum = this.checksum;\r\n val.version = this.version;\r\n val.jsonProperties = this.jsonProperties;\r\n return val;\r\n }\r\n\r\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\r\n super.collectReferenceIds(referenceIds);\r\n if (this.scope)\r\n referenceIds.addElement(this.scope.id);\r\n referenceIds.addElement(this.element.id);\r\n if (this.source)\r\n referenceIds.addElement(this.source.id);\r\n }\r\n}\r\n\r\n/** @public @preview */\r\nexport namespace ExternalSourceAspect {\r\n /** Standard values for the `Kind` property of `ExternalSourceAspect`.\r\n * @public @preview\r\n */\r\n export enum Kind {\r\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Element]] provenance */\r\n Element = \"Element\",\r\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Relationship]] provenance */\r\n Relationship = \"Relationship\",\r\n /** Indicates that the [[ExternalSourceAspect]] is storing *scope* provenance\r\n * @see [[ExternalSourceAspect.scope]]\r\n */\r\n Scope = \"Scope\",\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementGraphics.js","sourceRoot":"","sources":["../../src/ElementGraphics.ts"],"names":[],"mappings":";;AAaA,0DA0BC;AAvCD;;;+FAG+F;AAC/F,sDAA2D;AAC3D,oDAA8E;AAG9E,gDAA+C;AAE/C;;GAEG;AACI,KAAK,UAAU,uBAAuB,CAAC,OAAoC,EAAE,MAAgB;IAClG,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,mBAAS,CAAC,CAAC,uBAAuB,CAAC,OAAc,CAAC,CAAC,CAAC,2CAA2C;IAE3H,IAAI,KAAyB,CAAC;IAC9B,QAAQ,MAAM,CAAC,MAAM,EAAE,CAAC;QACtB,8CAAsC;QACtC;YACE,OAAO,SAAS,CAAC;QACnB;YACE,OAAO,MAAM,CAAC,OAAO,CAAC;QACxB;YACE,KAAK,GAAG,cAAc,CAAC;YACvB,MAAM;QACR;YACE,KAAK,GAAG,8BAA8B,CAAC;YACvC,MAAM;QACR;YACE,KAAK,GAAG,cAAc,OAAO,CAAC,SAAS,YAAY,CAAC;YACpD,MAAM;QACR;YACE,KAAK,GAAG,yBAAyB,OAAO,CAAC,EAAE,GAAG,CAAC;YAC/C,MAAM;IACV,CAAC;IAED,IAAA,qBAAM,EAAC,SAAS,KAAK,KAAK,CAAC,CAAC;IAC5B,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC","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*--------------------------------------------------------------------------------------------*/\nimport { assert, IModelStatus } from \"@itwin/core-bentley\";\nimport { ElementGraphicsRequestProps, IModelError } from \"@itwin/core-common\";\nimport { ElementGraphicsStatus } from \"@bentley/imodeljs-native\";\nimport { IModelDb } from \"./IModelDb\";\nimport { _nativeDb } from \"./internal/Symbols\";\n\n/** See [[IModelDb.generateElementGraphics]] and IModelTileRpcImpl.requestElementGraphics.\n * @internal\n */\nexport async function generateElementGraphics(request: ElementGraphicsRequestProps, iModel: IModelDb): Promise<Uint8Array | undefined> {\n const result = await iModel[_nativeDb].generateElementGraphics(request as any); // ###TODO update package versions in addon\n\n let error: string | undefined;\n switch (result.status) {\n case ElementGraphicsStatus.NoGeometry:\n case ElementGraphicsStatus.Canceled:\n return undefined;\n case ElementGraphicsStatus.Success:\n return result.content;\n case ElementGraphicsStatus.InvalidJson:\n error = \"Invalid JSON\";\n break;\n case ElementGraphicsStatus.UnknownMajorFormatVersion:\n error = \"Unknown major format version\";\n break;\n case ElementGraphicsStatus.ElementNotFound:\n error = `Element Id ${request.elementId} not found`;\n break;\n case ElementGraphicsStatus.DuplicateRequestId:\n error = `Duplicate request Id \"${request.id}\"`;\n break;\n }\n\n assert(undefined !== error);\n throw new IModelError(IModelStatus.BadRequest, error);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ElementGraphics.js","sourceRoot":"","sources":["../../src/ElementGraphics.ts"],"names":[],"mappings":";;AAaA,0DA0BC;AAvCD;;;+FAG+F;AAC/F,sDAA2D;AAC3D,oDAA8E;AAG9E,gDAA+C;AAE/C;;GAEG;AACI,KAAK,UAAU,uBAAuB,CAAC,OAAoC,EAAE,MAAgB;IAClG,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,mBAAS,CAAC,CAAC,uBAAuB,CAAC,OAAc,CAAC,CAAC,CAAC,2CAA2C;IAE3H,IAAI,KAAyB,CAAC;IAC9B,QAAQ,MAAM,CAAC,MAAM,EAAE,CAAC;QACtB,8CAAsC;QACtC;YACE,OAAO,SAAS,CAAC;QACnB;YACE,OAAO,MAAM,CAAC,OAAO,CAAC;QACxB;YACE,KAAK,GAAG,cAAc,CAAC;YACvB,MAAM;QACR;YACE,KAAK,GAAG,8BAA8B,CAAC;YACvC,MAAM;QACR;YACE,KAAK,GAAG,cAAc,OAAO,CAAC,SAAS,YAAY,CAAC;YACpD,MAAM;QACR;YACE,KAAK,GAAG,yBAAyB,OAAO,CAAC,EAAE,GAAG,CAAC;YAC/C,MAAM;IACV,CAAC;IAED,IAAA,qBAAM,EAAC,SAAS,KAAK,KAAK,CAAC,CAAC;IAC5B,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { assert, IModelStatus } from \"@itwin/core-bentley\";\r\nimport { ElementGraphicsRequestProps, IModelError } from \"@itwin/core-common\";\r\nimport { ElementGraphicsStatus } from \"@bentley/imodeljs-native\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { _nativeDb } from \"./internal/Symbols\";\r\n\r\n/** See [[IModelDb.generateElementGraphics]] and IModelTileRpcImpl.requestElementGraphics.\r\n * @internal\r\n */\r\nexport async function generateElementGraphics(request: ElementGraphicsRequestProps, iModel: IModelDb): Promise<Uint8Array | undefined> {\r\n const result = await iModel[_nativeDb].generateElementGraphics(request as any); // ###TODO update package versions in addon\r\n\r\n let error: string | undefined;\r\n switch (result.status) {\r\n case ElementGraphicsStatus.NoGeometry:\r\n case ElementGraphicsStatus.Canceled:\r\n return undefined;\r\n case ElementGraphicsStatus.Success:\r\n return result.content;\r\n case ElementGraphicsStatus.InvalidJson:\r\n error = \"Invalid JSON\";\r\n break;\r\n case ElementGraphicsStatus.UnknownMajorFormatVersion:\r\n error = \"Unknown major format version\";\r\n break;\r\n case ElementGraphicsStatus.ElementNotFound:\r\n error = `Element Id ${request.elementId} not found`;\r\n break;\r\n case ElementGraphicsStatus.DuplicateRequestId:\r\n error = `Duplicate request Id \"${request.id}\"`;\r\n break;\r\n }\r\n\r\n assert(undefined !== error);\r\n throw new IModelError(IModelStatus.BadRequest, error);\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementTreeWalker.js","sourceRoot":"","sources":["../../src/ElementTreeWalker.ts"],"names":[],"mappings":";;;AA+dA,8CAqBC;AAWD,sDAIC;AAngBD;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAgG;AAChG,oDAA4C;AAC5C,mEAAgE;AAChE,uCAA0G;AAC1G,yCAAsC;AACtC,mCAAiD;AAEjD,MAAM,cAAc,GAAG,GAAG,6CAAqB,CAAC,QAAQ,oBAAoB,CAAC;AAK7E,SAAS,yBAAyB,CAAC,MAAgB,EAAE,GAAc;IACjE,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAc,EAAE,CAAC;IAC9B,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAClD,IAAI,QAAQ,KAAK,SAAS,IAAI,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC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,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC,EAAE;AAC9F,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CAAC,MAAgB,EAAE,UAAsB,EAAE,MAAkC;IAChH,MAAM,GAAG,GAAG,IAAI,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtD,GAAG,CAAC,2BAA2B,CAAC,UAAU,CAAC,CAAC;IAC5C,GAAG,CAAC,4BAA4B,EAAE,CAAC;AACrC,CAAC","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 Elements\n */\nimport { assert, DbResult, Id64Array, Id64String, Logger, LogLevel } from \"@itwin/core-bentley\";\nimport { IModel } from \"@itwin/core-common\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { DefinitionContainer, DefinitionElement, DefinitionPartition, Element, Subject } from \"./Element\";\nimport { IModelDb } from \"./IModelDb\";\nimport { DefinitionModel, Model } from \"./Model\";\n\nconst loggerCategory = `${BackendLoggerCategory.IModelDb}.ElementTreeWalker`;\n\n/** @beta */\nexport interface ElementTreeWalkerModelInfo { model: Model, isDefinitionModel: boolean }\n\nfunction sortChildrenBeforeParents(iModel: IModelDb, ids: Id64Array): Array<Id64Array> {\n const children: Id64Array = [];\n const parents: Id64Array = [];\n for (const eid of ids) {\n const parentId = iModel.elements.queryParent(eid);\n if (parentId !== undefined && ids.includes(parentId))\n children.push(eid);\n else\n parents.push(eid);\n }\n\n if (children.length === 0)\n return [parents];\n\n return [...sortChildrenBeforeParents(iModel, children), parents];\n}\n\nfunction isModelEmpty(iModel: IModelDb, modelId: Id64String): boolean {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return iModel.withPreparedStatement(`select count(*) from ${Element.classFullName} where Model.Id = ?`, (stmt) => {\n stmt.bindId(1, modelId);\n stmt.step();\n return stmt.getValue(0).getInteger() === 0;\n });\n}\n\nfunction isDefinitionModel(model: Model): boolean {\n return (model.id !== IModel.repositoryModelId) && (model instanceof DefinitionModel);\n}\n\nenum ElementPruningClassification { PRUNING_CLASS_Normal = 0, PRUNING_CLASS_Subject = 1, PRUNING_CLASS_Definition = 2, PRUNING_CLASS_DefinitionPartition = 3, }\n\nfunction classifyElementForPruning(iModel: IModelDb, elementId: Id64String): ElementPruningClassification {\n const el = iModel.elements.getElement(elementId);\n // DefinitionContainer is submodeled by a DefinitionModel and so it must be classified as PRUNING_CLASS_DefinitionPartition for tree-walking purposes.\n // Since DefinitionContainer is-a DefinitionElement the (el instanceof DefinitionElement) case below would classify it as PRUNING_CLASS_Definition.\n // That is why we special-case it here.\n if (el instanceof DefinitionContainer)\n return ElementPruningClassification.PRUNING_CLASS_DefinitionPartition;\n return (el instanceof Subject) ? ElementPruningClassification.PRUNING_CLASS_Subject :\n (el instanceof DefinitionElement) ? ElementPruningClassification.PRUNING_CLASS_Definition :\n (el instanceof DefinitionPartition) ? ElementPruningClassification.PRUNING_CLASS_DefinitionPartition :\n ElementPruningClassification.PRUNING_CLASS_Normal;\n}\n\n/** Records the path that a tree search took to reach an element or model. This object is immutable.\n * @beta\n */\nexport class ElementTreeWalkerScope {\n public readonly topElement: Id64String = \"\";\n /** path of parent elements and enclosing models */\n public readonly path: Array<Id64String | ElementTreeWalkerModelInfo> = [];\n /** cached info about the immediately enclosing model (i.e., the last model in path) */\n public readonly enclosingModelInfo: ElementTreeWalkerModelInfo;\n\n constructor(topElement: Id64String, model: Model);\n constructor(enclosingScope: ElementTreeWalkerScope, newScope: Id64String | Model);\n constructor(arg1: Id64String | ElementTreeWalkerScope, arg2: Model | Id64String) {\n if (typeof arg1 === \"string\") {\n // normal constructor\n assert(arg2 instanceof Model);\n this.topElement = arg1;\n this.path.push(this.enclosingModelInfo = { model: arg2, isDefinitionModel: isDefinitionModel(arg2) });\n } else if (arg1 instanceof ElementTreeWalkerScope) {\n // copy-like constructor\n this.topElement = arg1.topElement;\n this.path = [...arg1.path];\n if (typeof arg2 === \"string\") {\n // with new parent\n this.path.push(arg2);\n this.enclosingModelInfo = arg1.enclosingModelInfo;\n } else {\n // with new enclosing model\n this.path.push(this.enclosingModelInfo = { model: arg2, isDefinitionModel: isDefinitionModel(arg2) });\n }\n } else {\n throw new Error(\"invalid constructor signature\");\n }\n }\n\n public get enclosingModel(): Model { return this.enclosingModelInfo.model; }\n public get inDefinitionModel(): boolean { return this.enclosingModelInfo.isDefinitionModel; } // NB: this will return false for the RepositoryModel!\n public get inRepositoryModel(): boolean { return this.enclosingModelInfo.model.id === IModelDb.repositoryModelId; }\n\n public static createTopScope(iModel: IModelDb, topElementId: Id64String) {\n const topElement = iModel.elements.getElement(topElementId);\n const topElementModel = iModel.models.getModel(topElement.model);\n return new ElementTreeWalkerScope(topElementId, topElementModel);\n }\n\n private fmtItem(v: Id64String | ElementTreeWalkerModelInfo): string {\n if (typeof v === \"string\")\n return `element ${v}`;\n return `model ${v.model.id} ${v.isDefinitionModel ? \"(DEFN)\" : \"\"}`;\n }\n\n public toString(): string {\n return `[ ${this.path.map((v) => this.fmtItem(v)).join(\" / \")} ]`;\n }\n}\n\nfunction fmtElement(iModel: IModelDb, elementId: Id64String): string {\n const el = iModel.elements.getElement(elementId);\n return `${el.id} ${el.classFullName} ${el.getDisplayLabel()}`;\n}\n\nfunction fmtModel(model: Model): string {\n return `${model.id} ${model.classFullName} ${model.name}`;\n}\n\nlet isTraceEnabledChecked = -1;\n\nfunction isTraceEnabled(): boolean {\n if (isTraceEnabledChecked === -1)\n isTraceEnabledChecked = Logger.isEnabled(loggerCategory, LogLevel.Trace) ? 1 : 0;\n return isTraceEnabledChecked === 1;\n}\n\nfunction logElement(op: string, iModel: IModelDb, elementId: Id64String, scope?: ElementTreeWalkerScope, logChildren?: boolean): void {\n if (!isTraceEnabled())\n return;\n\n Logger.logTrace(loggerCategory, `${op} ${fmtElement(iModel, elementId)} ${scope ? scope.toString() : \"\"}`);\n\n if (logChildren)\n iModel.elements.queryChildren(elementId).forEach((c) => logElement(\" - \", iModel, c, undefined, true));\n}\n\nfunction logModel(op: string, iModel: IModelDb, modelId: Id64String, scope?: ElementTreeWalkerScope, logElements?: boolean): void {\n if (!isTraceEnabled())\n return;\n const model: Model = iModel.models.getModel(modelId);\n Logger.logTrace(loggerCategory, `${op} ${fmtModel(model)} ${scope ? scope.toString() : \"\"}`);\n\n if (logElements) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n iModel.withPreparedStatement(`select ecinstanceid from ${Element.classFullName} where Model.Id = ?`, (stmt) => {\n stmt.bindId(1, modelId);\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\n logElement(\" - \", iModel, stmt.getValue(0).getId());\n }\n });\n }\n}\n\n/** Does a depth-first search on the tree defined by an element and its sub-models and children.\n * Sub-models are visited before their modeled elements, and children are visited before their parents.\n *\n * The following callbacks allow the subclass to exclude elements and sub-trees from the search:\n * * [[ElementTreeBottomUp.shouldExploreModel]], [[ElementTreeBottomUp.shouldExploreChildren]]\n * * [[ElementTreeBottomUp.shouldVisitElement]], [[ElementTreeBottomUp.shouldVisitModel]]\n *\n * The [[ElementTreeBottomUp.visitElement]] and [[ElementTreeBottomUp.visitModel]] callbacks allow\n * the subclass to process the elements and models that are encountered in the search.\n * @beta\n */\nexport abstract class ElementTreeBottomUp {\n constructor(protected _iModel: IModelDb) { }\n\n /** Return true if the search should recurse into this model */\n protected shouldExploreModel(_model: Model, _scope: ElementTreeWalkerScope): boolean { return true; }\n /** Return true if the search should recurse into the children (if any) of this element */\n protected shouldExploreChildren(_parentId: Id64String, _scope: ElementTreeWalkerScope): boolean { return true; }\n /** Return true if the search should visit this element */\n protected shouldVisitElement(_elementId: Id64String, _scope: ElementTreeWalkerScope): boolean { return true; }\n /** Return true if the search should visit this model */\n protected shouldVisitModel(_model: Model, _scope: ElementTreeWalkerScope): boolean { return true; }\n\n /** Called to visit a model */\n protected abstract visitModel(model: Model, scope: ElementTreeWalkerScope): void;\n\n /** Called to visit an element */\n protected abstract visitElement(elementId: Id64String, scope: ElementTreeWalkerScope): void;\n\n /** The main tree-walking function */\n protected processElementTree(element: Id64String, scope: ElementTreeWalkerScope) {\n const subModel = this._iModel.models.tryGetModel<Model>(element);\n if (subModel !== undefined) {\n if (this.shouldExploreModel(subModel, scope))\n this._processSubModel(subModel, scope);\n\n if (this.shouldVisitModel(subModel, scope))\n this.visitModel(subModel, scope);\n }\n\n if (this.shouldExploreChildren(element, scope))\n this._processChildren(element, scope);\n\n if (this.shouldVisitElement(element, scope))\n this.visitElement(element, scope);\n }\n\n /** process the children of the specified parent element */\n private _processChildren(parentElement: Id64String, parentScope: ElementTreeWalkerScope): void {\n const children = this._iModel.elements.queryChildren(parentElement);\n if (children.length === 0)\n return;\n\n const childrenScope = new ElementTreeWalkerScope(parentScope, parentElement);\n\n for (const childElement of children)\n this.processElementTree(childElement, childrenScope);\n }\n\n /** process the elements in the specified model */\n private _processSubModel(model: Model, parenScope: ElementTreeWalkerScope): void {\n const scope = new ElementTreeWalkerScope(parenScope, model);\n // Visit only the top-level parents. processElementTree will visit their children (bottom-up).\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n model.iModel.withPreparedStatement(`select ECInstanceId from bis:Element where Model.id=? and Parent.Id is null`, (stmt) => {\n stmt.bindId(1, model.id);\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\n const elementId = stmt.getValue(0).getId();\n this.processElementTree(elementId, scope);\n }\n });\n }\n}\n\n/** Helper class that manages the deletion of definitions and subjects */\nclass SpecialElements {\n public definitionModels: Id64Array = [];\n public definitions: Id64Array = [];\n public subjects: Id64Array = [];\n\n public recordSpecialElement(iModel: IModelDb, elementId: Id64String): boolean {\n // Defer Definitions and Subjects\n const cls = classifyElementForPruning(iModel, elementId);\n if (cls === ElementPruningClassification.PRUNING_CLASS_Subject) {\n this.subjects.push(elementId);\n return true;\n } else if (cls === ElementPruningClassification.PRUNING_CLASS_Definition) {\n this.definitions.push(elementId);\n return true;\n } else if (cls === ElementPruningClassification.PRUNING_CLASS_DefinitionPartition) {\n this.definitionModels.push(elementId);\n return true;\n }\n return false; // not a special element\n }\n\n /** Delete special elements - This calls Elements.deleteDefinitionElements to process the collected definition elements as a group and then\n * calls Models.deleteModel on collected definition models. It then deletes all collected Subjects by calling Element.deleteElement on them.\n * @note Caller must ensure that the special elements were recorded in a depth-first search.\n */\n public deleteSpecialElements(iModel: IModelDb) {\n // It's dangerous to pass a mixture of SubCategories and Categories to deleteDefinitionElements.\n // That function will delete the Categories first, which automatically deletes all their child\n // SubCategories (in native code). If a SubCategory in the list is one of those children, then\n // deleteDefinitionElements will try and fail with an exception to delete that SubCategory in a subsequent step.\n // To work around this, we delete the SubCategories first, then everything else.\n // A similar problem occurs when you pass other kinds of elements to deleteDefinitionElements, where some are\n // children and others are parents. deleteDefinitionElements does not preserve the order that you specify,\n // and it does not process children before parents.\n for (const definitions of sortChildrenBeforeParents(iModel, this.definitions)) {\n if (isTraceEnabled())\n definitions.forEach((e) => logElement(\"try delete\", iModel, e));\n\n iModel.elements.deleteDefinitionElements(definitions); // will not delete definitions that are still in use.\n }\n\n for (const m of this.definitionModels) {\n if (!isModelEmpty(iModel, m)) {\n logModel(\"Model not empty - cannot delete - may contain Definitions that are still in use\", iModel, m, undefined, true);\n } else {\n logModel(\"delete\", iModel, m);\n iModel.models.deleteModel(m);\n iModel.elements.deleteElement(m);\n }\n }\n\n for (const e of this.subjects) {\n if (iModel.elements.queryChildren(e).length !== 0) {\n logElement(\"Subject still has children - cannot delete - may have child DefinitionModels\", iModel, e, undefined, true);\n } else {\n logElement(\"delete\", iModel, e);\n iModel.elements.deleteElement(e);\n }\n }\n }\n\n}\n\n/** Deletes an entire element tree, including sub-models and child elements.\n * Items are deleted in bottom-up order. Definitions and Subjects are deleted after normal elements.\n * Call deleteNormalElements on each tree. Then call deleteSpecialElements.\n * @see deleteElementTree for a simple way to use this class.\n * @beta\n */\nexport class ElementTreeDeleter extends ElementTreeBottomUp {\n protected _special: SpecialElements = new SpecialElements();\n\n protected override shouldExploreModel(_model: Model): boolean { return true; }\n protected override shouldVisitElement(_elementId: Id64String): boolean { return true; }\n\n protected override visitModel(model: Model, _scope: ElementTreeWalkerScope): void {\n if (isDefinitionModel(model))\n return; // we recorded definition models in visitElement when we encountered the DefinitionPartition elements.\n\n // visitElement has already deleted the elements in the model. So, now it's safe to delete the model itself.\n logModel(\"delete\", this._iModel, model.id, _scope);\n model.delete();\n }\n\n protected override visitElement(elementId: Id64String, _scope: ElementTreeWalkerScope): void {\n if (!this._special.recordSpecialElement(this._iModel, elementId)) {\n logElement(\"delete\", this._iModel, elementId, _scope);\n this._iModel.elements.deleteElement(elementId);\n }\n }\n\n /**\n * Delete the \"normal\" elements and record the special elements for deferred processing.\n * @param topElement The parent of the sub-tree to be deleted. Top element itself is also deleted.\n * @param scope How the parent was found\n * @see deleteSpecialElements\n */\n public deleteNormalElements(topElement: Id64String, scope?: ElementTreeWalkerScope): void {\n const topScope = scope ?? ElementTreeWalkerScope.createTopScope(this._iModel, topElement);\n this.processElementTree(topElement, topScope); //\n }\n\n /** Delete all special elements that were found and deferred by deleteNormalElements. Call this\n * function once after all element trees are processed by deleteNormalElements.\n */\n public deleteSpecialElements(): void {\n this._special.deleteSpecialElements(this._iModel);\n }\n\n}\n\n/** Does a breadth-first search on the tree defined by an element and its sub-models and children.\n * Parents are visited first, then children, then sub-models.\n * The subclass can \"prune\" sub-trees from the search. When a sub-tree is \"pruned\" the search does *not* recurse into it.\n * If a sub-tree is not pruned, then the search does recurse into it.\n * @beta\n */\nabstract class ElementTreeTopDown {\n constructor(protected _iModel: IModelDb) { }\n\n /** Should the search *not* recurse into this sub-tree? */\n protected shouldPrune(_elementId: Id64String, _scope: ElementTreeWalkerScope): boolean { return false; }\n\n protected abstract prune(_elementId: Id64String, _scope: ElementTreeWalkerScope): void;\n\n protected processElementTree(element: Id64String, scope: ElementTreeWalkerScope) {\n\n if (this.shouldPrune(element, scope)) {\n this.prune(element, scope);\n return;\n }\n\n this._processChildren(element, scope);\n\n const subModel = this._iModel.models.tryGetModel<Model>(element);\n if (subModel !== undefined) {\n this._processSubModel(subModel, scope);\n }\n }\n\n private _processChildren(element: Id64String, scope: ElementTreeWalkerScope) {\n let parentScope: ElementTreeWalkerScope | undefined;\n for (const childElement of this._iModel.elements.queryChildren(element)) {\n if (parentScope === undefined)\n parentScope = new ElementTreeWalkerScope(scope, element);\n this.processElementTree(childElement, parentScope);\n }\n }\n\n private _processSubModel(subModel: Model, scope: ElementTreeWalkerScope) {\n const subModelScope = new ElementTreeWalkerScope(scope, subModel);\n // Visit only the top-level parents. processElementTree will recurse into their children.\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n this._iModel.withPreparedStatement(`select ECInstanceId from bis:Element where Model.id=? and Parent.Id is null`, (stmt) => {\n stmt.bindId(1, subModel.id);\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\n const elementId = stmt.getValue(0).getId();\n this.processElementTree(elementId, subModelScope);\n }\n });\n }\n\n}\n\n/** Signature of the filter function used by ElementSubTreeDeleter.\n * @param elementId The sub-tree parent element.\n * @param scope The path followed by the top-down search to the element\n * @return true if the element and its children and sub-models should be deleted.\n * @beta\n */\nexport type ElementSubTreeDeleteFilter = (elementId: Id64String, scope: ElementTreeWalkerScope) => boolean;\n\n/** Performs a breadth-first search to visit elements in top-down order.\n * When the supplied filter function chooses an element, ElementTreeDeleter is used to delete it and its sub-tree.\n * @beta\n */\nexport class ElementSubTreeDeleter extends ElementTreeTopDown {\n private _treeDeleter: ElementTreeDeleter;\n private _shouldPruneCb: ElementSubTreeDeleteFilter;\n\n /** Construct an ElementSubTreeDeleter.\n * @param iModel The iModel\n * @param topElement Where to start the search.\n * @param shouldPruneCb Callback that selects sub-trees that should be deleted.\n * @see deleteElementSubTrees for a simple way to use this class.\n */\n public constructor(iModel: IModelDb, shouldPruneCb: ElementSubTreeDeleteFilter) {\n super(iModel);\n this._treeDeleter = new ElementTreeDeleter(this._iModel);\n this._shouldPruneCb = shouldPruneCb;\n }\n\n protected override shouldPrune(elementId: Id64String, scope: ElementTreeWalkerScope): boolean { return this._shouldPruneCb(elementId, scope); }\n\n protected prune(elementId: Id64String, scope: ElementTreeWalkerScope): void {\n this._treeDeleter.deleteNormalElements(elementId, scope);\n }\n\n /** Traverses the tree of elements beginning with the top element, and deletes all selected sub-trees.\n * Normal elements are deleted. Any special elements that are encountered are deferred.\n * Call deleteSpecialElementSubTrees after all top elements have been processed. */\n public deleteNormalElementSubTrees(topElement: Id64String, scope?: ElementTreeWalkerScope) {\n const topScope = scope ?? ElementTreeWalkerScope.createTopScope(this._iModel, topElement);\n this.processElementTree(topElement, topScope); // deletes normal elements and their sub-trees, defers special elements\n }\n\n /** Delete all special elements and their sub-trees that were found in the course of processing.\n * The sub-trees were already expanded by ElementTreeDeleter.deleteNormalElements.\n */\n public deleteSpecialElementSubTrees() {\n this._treeDeleter.deleteSpecialElements();\n }\n}\n\n/** Arguments supplied to [[deleteElementTree]].\n * @beta\n */\nexport interface DeleteElementTreeArgs {\n /** The iModel containing the elements to delete. */\n iModel: IModelDb;\n /** The Id of the root element of the tree to delete. */\n topElement: Id64String;\n /** The maximum number of passes to make when deleting definition elements.\n * Default: 5\n */\n maxPasses?: number;\n}\n\n/** Deletes an element tree starting with the specified top element. The top element is also deleted. Uses ElementTreeDeleter.\n * @param iModel The iModel\n * @param topElement The parent of the sub-tree\n * @beta\n */\nexport function deleteElementTree(iModel: IModelDb, topElement: Id64String): void;\n/** Deletes an element tree starting with the specified top element. The top element is also deleted. Uses ElementTreeDeleter.\n * @param args Specifies the iModel and top element.\n * @beta\n */\nexport function deleteElementTree(args: DeleteElementTreeArgs): void;\n/** @internal */\nexport function deleteElementTree(arg0: DeleteElementTreeArgs | IModelDb, arg1?: Id64String): void {\n let maxPasses;\n let iModel: IModelDb;\n let topElement: Id64String;\n if (arg0 instanceof IModelDb) {\n assert(typeof arg1 === \"string\");\n iModel = arg0;\n topElement = arg1;\n } else {\n iModel = arg0.iModel;\n topElement = arg0.topElement;\n maxPasses = arg0.maxPasses;\n }\n\n maxPasses = maxPasses ?? 5;\n let pass = 0;\n do {\n const del = new ElementTreeDeleter(iModel);\n del.deleteNormalElements(topElement);\n del.deleteSpecialElements();\n } while ((iModel.elements.tryGetElement(topElement) !== undefined) && (++pass < maxPasses));\n}\n\n/** Deletes all element sub-trees that are selected by the supplied filter. Uses ElementSubTreeDeleter.\n * If the filter selects the top element itself, then the entire tree (including the top element) is deleted.\n * That has the same effect as calling [[deleteElementTree]] on the top element.\n * @note The caller may have to call this function multiple times if there are multiple layers of dependencies among definition elements.\n * @param iModel The iModel\n * @param topElement Where to start the search.\n * @param filter Callback that selects sub-trees that should be deleted.\n * @beta\n */\nexport function deleteElementSubTrees(iModel: IModelDb, topElement: Id64String, filter: ElementSubTreeDeleteFilter): void {\n const del = new ElementSubTreeDeleter(iModel, filter);\n del.deleteNormalElementSubTrees(topElement);\n del.deleteSpecialElementSubTrees();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ElementTreeWalker.js","sourceRoot":"","sources":["../../src/ElementTreeWalker.ts"],"names":[],"mappings":";;;AA+dA,8CAqBC;AAWD,sDAIC;AAngBD;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAgG;AAChG,oDAA4C;AAC5C,mEAAgE;AAChE,uCAA0G;AAC1G,yCAAsC;AACtC,mCAAiD;AAEjD,MAAM,cAAc,GAAG,GAAG,6CAAqB,CAAC,QAAQ,oBAAoB,CAAC;AAK7E,SAAS,yBAAyB,CAAC,MAAgB,EAAE,GAAc;IACjE,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAc,EAAE,CAAC;IAC9B,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAClD,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,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,KAAK,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC,EAAE;AAC9F,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CAAC,MAAgB,EAAE,UAAsB,EAAE,MAAkC;IAChH,MAAM,GAAG,GAAG,IAAI,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtD,GAAG,CAAC,2BAA2B,CAAC,UAAU,CAAC,CAAC;IAC5C,GAAG,CAAC,4BAA4B,EAAE,CAAC;AACrC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Elements\r\n */\r\nimport { assert, DbResult, Id64Array, Id64String, Logger, LogLevel } from \"@itwin/core-bentley\";\r\nimport { IModel } from \"@itwin/core-common\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { DefinitionContainer, DefinitionElement, DefinitionPartition, Element, Subject } from \"./Element\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { DefinitionModel, Model } from \"./Model\";\r\n\r\nconst loggerCategory = `${BackendLoggerCategory.IModelDb}.ElementTreeWalker`;\r\n\r\n/** @beta */\r\nexport interface ElementTreeWalkerModelInfo { model: Model, isDefinitionModel: boolean }\r\n\r\nfunction sortChildrenBeforeParents(iModel: IModelDb, ids: Id64Array): Array<Id64Array> {\r\n const children: Id64Array = [];\r\n const parents: Id64Array = [];\r\n for (const eid of ids) {\r\n const parentId = iModel.elements.queryParent(eid);\r\n if (parentId !== undefined && ids.includes(parentId))\r\n children.push(eid);\r\n else\r\n parents.push(eid);\r\n }\r\n\r\n if (children.length === 0)\r\n return [parents];\r\n\r\n return [...sortChildrenBeforeParents(iModel, children), parents];\r\n}\r\n\r\nfunction isModelEmpty(iModel: IModelDb, modelId: Id64String): boolean {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n return iModel.withPreparedStatement(`select count(*) from ${Element.classFullName} where Model.Id = ?`, (stmt) => {\r\n stmt.bindId(1, modelId);\r\n stmt.step();\r\n return stmt.getValue(0).getInteger() === 0;\r\n });\r\n}\r\n\r\nfunction isDefinitionModel(model: Model): boolean {\r\n return (model.id !== IModel.repositoryModelId) && (model instanceof DefinitionModel);\r\n}\r\n\r\nenum ElementPruningClassification { PRUNING_CLASS_Normal = 0, PRUNING_CLASS_Subject = 1, PRUNING_CLASS_Definition = 2, PRUNING_CLASS_DefinitionPartition = 3, }\r\n\r\nfunction classifyElementForPruning(iModel: IModelDb, elementId: Id64String): ElementPruningClassification {\r\n const el = iModel.elements.getElement(elementId);\r\n // DefinitionContainer is submodeled by a DefinitionModel and so it must be classified as PRUNING_CLASS_DefinitionPartition for tree-walking purposes.\r\n // Since DefinitionContainer is-a DefinitionElement the (el instanceof DefinitionElement) case below would classify it as PRUNING_CLASS_Definition.\r\n // That is why we special-case it here.\r\n if (el instanceof DefinitionContainer)\r\n return ElementPruningClassification.PRUNING_CLASS_DefinitionPartition;\r\n return (el instanceof Subject) ? ElementPruningClassification.PRUNING_CLASS_Subject :\r\n (el instanceof DefinitionElement) ? ElementPruningClassification.PRUNING_CLASS_Definition :\r\n (el instanceof DefinitionPartition) ? ElementPruningClassification.PRUNING_CLASS_DefinitionPartition :\r\n ElementPruningClassification.PRUNING_CLASS_Normal;\r\n}\r\n\r\n/** Records the path that a tree search took to reach an element or model. This object is immutable.\r\n * @beta\r\n */\r\nexport class ElementTreeWalkerScope {\r\n public readonly topElement: Id64String = \"\";\r\n /** path of parent elements and enclosing models */\r\n public readonly path: Array<Id64String | ElementTreeWalkerModelInfo> = [];\r\n /** cached info about the immediately enclosing model (i.e., the last model in path) */\r\n public readonly enclosingModelInfo: ElementTreeWalkerModelInfo;\r\n\r\n constructor(topElement: Id64String, model: Model);\r\n constructor(enclosingScope: ElementTreeWalkerScope, newScope: Id64String | Model);\r\n constructor(arg1: Id64String | ElementTreeWalkerScope, arg2: Model | Id64String) {\r\n if (typeof arg1 === \"string\") {\r\n // normal constructor\r\n assert(arg2 instanceof Model);\r\n this.topElement = arg1;\r\n this.path.push(this.enclosingModelInfo = { model: arg2, isDefinitionModel: isDefinitionModel(arg2) });\r\n } else if (arg1 instanceof ElementTreeWalkerScope) {\r\n // copy-like constructor\r\n this.topElement = arg1.topElement;\r\n this.path = [...arg1.path];\r\n if (typeof arg2 === \"string\") {\r\n // with new parent\r\n this.path.push(arg2);\r\n this.enclosingModelInfo = arg1.enclosingModelInfo;\r\n } else {\r\n // with new enclosing model\r\n this.path.push(this.enclosingModelInfo = { model: arg2, isDefinitionModel: isDefinitionModel(arg2) });\r\n }\r\n } else {\r\n throw new Error(\"invalid constructor signature\");\r\n }\r\n }\r\n\r\n public get enclosingModel(): Model { return this.enclosingModelInfo.model; }\r\n public get inDefinitionModel(): boolean { return this.enclosingModelInfo.isDefinitionModel; } // NB: this will return false for the RepositoryModel!\r\n public get inRepositoryModel(): boolean { return this.enclosingModelInfo.model.id === IModelDb.repositoryModelId; }\r\n\r\n public static createTopScope(iModel: IModelDb, topElementId: Id64String) {\r\n const topElement = iModel.elements.getElement(topElementId);\r\n const topElementModel = iModel.models.getModel(topElement.model);\r\n return new ElementTreeWalkerScope(topElementId, topElementModel);\r\n }\r\n\r\n private fmtItem(v: Id64String | ElementTreeWalkerModelInfo): string {\r\n if (typeof v === \"string\")\r\n return `element ${v}`;\r\n return `model ${v.model.id} ${v.isDefinitionModel ? \"(DEFN)\" : \"\"}`;\r\n }\r\n\r\n public toString(): string {\r\n return `[ ${this.path.map((v) => this.fmtItem(v)).join(\" / \")} ]`;\r\n }\r\n}\r\n\r\nfunction fmtElement(iModel: IModelDb, elementId: Id64String): string {\r\n const el = iModel.elements.getElement(elementId);\r\n return `${el.id} ${el.classFullName} ${el.getDisplayLabel()}`;\r\n}\r\n\r\nfunction fmtModel(model: Model): string {\r\n return `${model.id} ${model.classFullName} ${model.name}`;\r\n}\r\n\r\nlet isTraceEnabledChecked = -1;\r\n\r\nfunction isTraceEnabled(): boolean {\r\n if (isTraceEnabledChecked === -1)\r\n isTraceEnabledChecked = Logger.isEnabled(loggerCategory, LogLevel.Trace) ? 1 : 0;\r\n return isTraceEnabledChecked === 1;\r\n}\r\n\r\nfunction logElement(op: string, iModel: IModelDb, elementId: Id64String, scope?: ElementTreeWalkerScope, logChildren?: boolean): void {\r\n if (!isTraceEnabled())\r\n return;\r\n\r\n Logger.logTrace(loggerCategory, `${op} ${fmtElement(iModel, elementId)} ${scope ? scope.toString() : \"\"}`);\r\n\r\n if (logChildren)\r\n iModel.elements.queryChildren(elementId).forEach((c) => logElement(\" - \", iModel, c, undefined, true));\r\n}\r\n\r\nfunction logModel(op: string, iModel: IModelDb, modelId: Id64String, scope?: ElementTreeWalkerScope, logElements?: boolean): void {\r\n if (!isTraceEnabled())\r\n return;\r\n const model: Model = iModel.models.getModel(modelId);\r\n Logger.logTrace(loggerCategory, `${op} ${fmtModel(model)} ${scope ? scope.toString() : \"\"}`);\r\n\r\n if (logElements) {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n iModel.withPreparedStatement(`select ecinstanceid from ${Element.classFullName} where Model.Id = ?`, (stmt) => {\r\n stmt.bindId(1, modelId);\r\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\r\n logElement(\" - \", iModel, stmt.getValue(0).getId());\r\n }\r\n });\r\n }\r\n}\r\n\r\n/** Does a depth-first search on the tree defined by an element and its sub-models and children.\r\n * Sub-models are visited before their modeled elements, and children are visited before their parents.\r\n *\r\n * The following callbacks allow the subclass to exclude elements and sub-trees from the search:\r\n * * [[ElementTreeBottomUp.shouldExploreModel]], [[ElementTreeBottomUp.shouldExploreChildren]]\r\n * * [[ElementTreeBottomUp.shouldVisitElement]], [[ElementTreeBottomUp.shouldVisitModel]]\r\n *\r\n * The [[ElementTreeBottomUp.visitElement]] and [[ElementTreeBottomUp.visitModel]] callbacks allow\r\n * the subclass to process the elements and models that are encountered in the search.\r\n * @beta\r\n */\r\nexport abstract class ElementTreeBottomUp {\r\n constructor(protected _iModel: IModelDb) { }\r\n\r\n /** Return true if the search should recurse into this model */\r\n protected shouldExploreModel(_model: Model, _scope: ElementTreeWalkerScope): boolean { return true; }\r\n /** Return true if the search should recurse into the children (if any) of this element */\r\n protected shouldExploreChildren(_parentId: Id64String, _scope: ElementTreeWalkerScope): boolean { return true; }\r\n /** Return true if the search should visit this element */\r\n protected shouldVisitElement(_elementId: Id64String, _scope: ElementTreeWalkerScope): boolean { return true; }\r\n /** Return true if the search should visit this model */\r\n protected shouldVisitModel(_model: Model, _scope: ElementTreeWalkerScope): boolean { return true; }\r\n\r\n /** Called to visit a model */\r\n protected abstract visitModel(model: Model, scope: ElementTreeWalkerScope): void;\r\n\r\n /** Called to visit an element */\r\n protected abstract visitElement(elementId: Id64String, scope: ElementTreeWalkerScope): void;\r\n\r\n /** The main tree-walking function */\r\n protected processElementTree(element: Id64String, scope: ElementTreeWalkerScope) {\r\n const subModel = this._iModel.models.tryGetModel<Model>(element);\r\n if (subModel !== undefined) {\r\n if (this.shouldExploreModel(subModel, scope))\r\n this._processSubModel(subModel, scope);\r\n\r\n if (this.shouldVisitModel(subModel, scope))\r\n this.visitModel(subModel, scope);\r\n }\r\n\r\n if (this.shouldExploreChildren(element, scope))\r\n this._processChildren(element, scope);\r\n\r\n if (this.shouldVisitElement(element, scope))\r\n this.visitElement(element, scope);\r\n }\r\n\r\n /** process the children of the specified parent element */\r\n private _processChildren(parentElement: Id64String, parentScope: ElementTreeWalkerScope): void {\r\n const children = this._iModel.elements.queryChildren(parentElement);\r\n if (children.length === 0)\r\n return;\r\n\r\n const childrenScope = new ElementTreeWalkerScope(parentScope, parentElement);\r\n\r\n for (const childElement of children)\r\n this.processElementTree(childElement, childrenScope);\r\n }\r\n\r\n /** process the elements in the specified model */\r\n private _processSubModel(model: Model, parenScope: ElementTreeWalkerScope): void {\r\n const scope = new ElementTreeWalkerScope(parenScope, model);\r\n // Visit only the top-level parents. processElementTree will visit their children (bottom-up).\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n model.iModel.withPreparedStatement(`select ECInstanceId from bis:Element where Model.id=? and Parent.Id is null`, (stmt) => {\r\n stmt.bindId(1, model.id);\r\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\r\n const elementId = stmt.getValue(0).getId();\r\n this.processElementTree(elementId, scope);\r\n }\r\n });\r\n }\r\n}\r\n\r\n/** Helper class that manages the deletion of definitions and subjects */\r\nclass SpecialElements {\r\n public definitionModels: Id64Array = [];\r\n public definitions: Id64Array = [];\r\n public subjects: Id64Array = [];\r\n\r\n public recordSpecialElement(iModel: IModelDb, elementId: Id64String): boolean {\r\n // Defer Definitions and Subjects\r\n const cls = classifyElementForPruning(iModel, elementId);\r\n if (cls === ElementPruningClassification.PRUNING_CLASS_Subject) {\r\n this.subjects.push(elementId);\r\n return true;\r\n } else if (cls === ElementPruningClassification.PRUNING_CLASS_Definition) {\r\n this.definitions.push(elementId);\r\n return true;\r\n } else if (cls === ElementPruningClassification.PRUNING_CLASS_DefinitionPartition) {\r\n this.definitionModels.push(elementId);\r\n return true;\r\n }\r\n return false; // not a special element\r\n }\r\n\r\n /** Delete special elements - This calls Elements.deleteDefinitionElements to process the collected definition elements as a group and then\r\n * calls Models.deleteModel on collected definition models. It then deletes all collected Subjects by calling Element.deleteElement on them.\r\n * @note Caller must ensure that the special elements were recorded in a depth-first search.\r\n */\r\n public deleteSpecialElements(iModel: IModelDb) {\r\n // It's dangerous to pass a mixture of SubCategories and Categories to deleteDefinitionElements.\r\n // That function will delete the Categories first, which automatically deletes all their child\r\n // SubCategories (in native code). If a SubCategory in the list is one of those children, then\r\n // deleteDefinitionElements will try and fail with an exception to delete that SubCategory in a subsequent step.\r\n // To work around this, we delete the SubCategories first, then everything else.\r\n // A similar problem occurs when you pass other kinds of elements to deleteDefinitionElements, where some are\r\n // children and others are parents. deleteDefinitionElements does not preserve the order that you specify,\r\n // and it does not process children before parents.\r\n for (const definitions of sortChildrenBeforeParents(iModel, this.definitions)) {\r\n if (isTraceEnabled())\r\n definitions.forEach((e) => logElement(\"try delete\", iModel, e));\r\n\r\n iModel.elements.deleteDefinitionElements(definitions); // will not delete definitions that are still in use.\r\n }\r\n\r\n for (const m of this.definitionModels) {\r\n if (!isModelEmpty(iModel, m)) {\r\n logModel(\"Model not empty - cannot delete - may contain Definitions that are still in use\", iModel, m, undefined, true);\r\n } else {\r\n logModel(\"delete\", iModel, m);\r\n iModel.models.deleteModel(m);\r\n iModel.elements.deleteElement(m);\r\n }\r\n }\r\n\r\n for (const e of this.subjects) {\r\n if (iModel.elements.queryChildren(e).length !== 0) {\r\n logElement(\"Subject still has children - cannot delete - may have child DefinitionModels\", iModel, e, undefined, true);\r\n } else {\r\n logElement(\"delete\", iModel, e);\r\n iModel.elements.deleteElement(e);\r\n }\r\n }\r\n }\r\n\r\n}\r\n\r\n/** Deletes an entire element tree, including sub-models and child elements.\r\n * Items are deleted in bottom-up order. Definitions and Subjects are deleted after normal elements.\r\n * Call deleteNormalElements on each tree. Then call deleteSpecialElements.\r\n * @see deleteElementTree for a simple way to use this class.\r\n * @beta\r\n */\r\nexport class ElementTreeDeleter extends ElementTreeBottomUp {\r\n protected _special: SpecialElements = new SpecialElements();\r\n\r\n protected override shouldExploreModel(_model: Model): boolean { return true; }\r\n protected override shouldVisitElement(_elementId: Id64String): boolean { return true; }\r\n\r\n protected override visitModel(model: Model, _scope: ElementTreeWalkerScope): void {\r\n if (isDefinitionModel(model))\r\n return; // we recorded definition models in visitElement when we encountered the DefinitionPartition elements.\r\n\r\n // visitElement has already deleted the elements in the model. So, now it's safe to delete the model itself.\r\n logModel(\"delete\", this._iModel, model.id, _scope);\r\n model.delete();\r\n }\r\n\r\n protected override visitElement(elementId: Id64String, _scope: ElementTreeWalkerScope): void {\r\n if (!this._special.recordSpecialElement(this._iModel, elementId)) {\r\n logElement(\"delete\", this._iModel, elementId, _scope);\r\n this._iModel.elements.deleteElement(elementId);\r\n }\r\n }\r\n\r\n /**\r\n * Delete the \"normal\" elements and record the special elements for deferred processing.\r\n * @param topElement The parent of the sub-tree to be deleted. Top element itself is also deleted.\r\n * @param scope How the parent was found\r\n * @see deleteSpecialElements\r\n */\r\n public deleteNormalElements(topElement: Id64String, scope?: ElementTreeWalkerScope): void {\r\n const topScope = scope ?? ElementTreeWalkerScope.createTopScope(this._iModel, topElement);\r\n this.processElementTree(topElement, topScope); //\r\n }\r\n\r\n /** Delete all special elements that were found and deferred by deleteNormalElements. Call this\r\n * function once after all element trees are processed by deleteNormalElements.\r\n */\r\n public deleteSpecialElements(): void {\r\n this._special.deleteSpecialElements(this._iModel);\r\n }\r\n\r\n}\r\n\r\n/** Does a breadth-first search on the tree defined by an element and its sub-models and children.\r\n * Parents are visited first, then children, then sub-models.\r\n * The subclass can \"prune\" sub-trees from the search. When a sub-tree is \"pruned\" the search does *not* recurse into it.\r\n * If a sub-tree is not pruned, then the search does recurse into it.\r\n * @beta\r\n */\r\nabstract class ElementTreeTopDown {\r\n constructor(protected _iModel: IModelDb) { }\r\n\r\n /** Should the search *not* recurse into this sub-tree? */\r\n protected shouldPrune(_elementId: Id64String, _scope: ElementTreeWalkerScope): boolean { return false; }\r\n\r\n protected abstract prune(_elementId: Id64String, _scope: ElementTreeWalkerScope): void;\r\n\r\n protected processElementTree(element: Id64String, scope: ElementTreeWalkerScope) {\r\n\r\n if (this.shouldPrune(element, scope)) {\r\n this.prune(element, scope);\r\n return;\r\n }\r\n\r\n this._processChildren(element, scope);\r\n\r\n const subModel = this._iModel.models.tryGetModel<Model>(element);\r\n if (subModel !== undefined) {\r\n this._processSubModel(subModel, scope);\r\n }\r\n }\r\n\r\n private _processChildren(element: Id64String, scope: ElementTreeWalkerScope) {\r\n let parentScope: ElementTreeWalkerScope | undefined;\r\n for (const childElement of this._iModel.elements.queryChildren(element)) {\r\n if (parentScope === undefined)\r\n parentScope = new ElementTreeWalkerScope(scope, element);\r\n this.processElementTree(childElement, parentScope);\r\n }\r\n }\r\n\r\n private _processSubModel(subModel: Model, scope: ElementTreeWalkerScope) {\r\n const subModelScope = new ElementTreeWalkerScope(scope, subModel);\r\n // Visit only the top-level parents. processElementTree will recurse into their children.\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n this._iModel.withPreparedStatement(`select ECInstanceId from bis:Element where Model.id=? and Parent.Id is null`, (stmt) => {\r\n stmt.bindId(1, subModel.id);\r\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\r\n const elementId = stmt.getValue(0).getId();\r\n this.processElementTree(elementId, subModelScope);\r\n }\r\n });\r\n }\r\n\r\n}\r\n\r\n/** Signature of the filter function used by ElementSubTreeDeleter.\r\n * @param elementId The sub-tree parent element.\r\n * @param scope The path followed by the top-down search to the element\r\n * @return true if the element and its children and sub-models should be deleted.\r\n * @beta\r\n */\r\nexport type ElementSubTreeDeleteFilter = (elementId: Id64String, scope: ElementTreeWalkerScope) => boolean;\r\n\r\n/** Performs a breadth-first search to visit elements in top-down order.\r\n * When the supplied filter function chooses an element, ElementTreeDeleter is used to delete it and its sub-tree.\r\n * @beta\r\n */\r\nexport class ElementSubTreeDeleter extends ElementTreeTopDown {\r\n private _treeDeleter: ElementTreeDeleter;\r\n private _shouldPruneCb: ElementSubTreeDeleteFilter;\r\n\r\n /** Construct an ElementSubTreeDeleter.\r\n * @param iModel The iModel\r\n * @param topElement Where to start the search.\r\n * @param shouldPruneCb Callback that selects sub-trees that should be deleted.\r\n * @see deleteElementSubTrees for a simple way to use this class.\r\n */\r\n public constructor(iModel: IModelDb, shouldPruneCb: ElementSubTreeDeleteFilter) {\r\n super(iModel);\r\n this._treeDeleter = new ElementTreeDeleter(this._iModel);\r\n this._shouldPruneCb = shouldPruneCb;\r\n }\r\n\r\n protected override shouldPrune(elementId: Id64String, scope: ElementTreeWalkerScope): boolean { return this._shouldPruneCb(elementId, scope); }\r\n\r\n protected prune(elementId: Id64String, scope: ElementTreeWalkerScope): void {\r\n this._treeDeleter.deleteNormalElements(elementId, scope);\r\n }\r\n\r\n /** Traverses the tree of elements beginning with the top element, and deletes all selected sub-trees.\r\n * Normal elements are deleted. Any special elements that are encountered are deferred.\r\n * Call deleteSpecialElementSubTrees after all top elements have been processed. */\r\n public deleteNormalElementSubTrees(topElement: Id64String, scope?: ElementTreeWalkerScope) {\r\n const topScope = scope ?? ElementTreeWalkerScope.createTopScope(this._iModel, topElement);\r\n this.processElementTree(topElement, topScope); // deletes normal elements and their sub-trees, defers special elements\r\n }\r\n\r\n /** Delete all special elements and their sub-trees that were found in the course of processing.\r\n * The sub-trees were already expanded by ElementTreeDeleter.deleteNormalElements.\r\n */\r\n public deleteSpecialElementSubTrees() {\r\n this._treeDeleter.deleteSpecialElements();\r\n }\r\n}\r\n\r\n/** Arguments supplied to [[deleteElementTree]].\r\n * @beta\r\n */\r\nexport interface DeleteElementTreeArgs {\r\n /** The iModel containing the elements to delete. */\r\n iModel: IModelDb;\r\n /** The Id of the root element of the tree to delete. */\r\n topElement: Id64String;\r\n /** The maximum number of passes to make when deleting definition elements.\r\n * Default: 5\r\n */\r\n maxPasses?: number;\r\n}\r\n\r\n/** Deletes an element tree starting with the specified top element. The top element is also deleted. Uses ElementTreeDeleter.\r\n * @param iModel The iModel\r\n * @param topElement The parent of the sub-tree\r\n * @beta\r\n */\r\nexport function deleteElementTree(iModel: IModelDb, topElement: Id64String): void;\r\n/** Deletes an element tree starting with the specified top element. The top element is also deleted. Uses ElementTreeDeleter.\r\n * @param args Specifies the iModel and top element.\r\n * @beta\r\n */\r\nexport function deleteElementTree(args: DeleteElementTreeArgs): void;\r\n/** @internal */\r\nexport function deleteElementTree(arg0: DeleteElementTreeArgs | IModelDb, arg1?: Id64String): void {\r\n let maxPasses;\r\n let iModel: IModelDb;\r\n let topElement: Id64String;\r\n if (arg0 instanceof IModelDb) {\r\n assert(typeof arg1 === \"string\");\r\n iModel = arg0;\r\n topElement = arg1;\r\n } else {\r\n iModel = arg0.iModel;\r\n topElement = arg0.topElement;\r\n maxPasses = arg0.maxPasses;\r\n }\r\n\r\n maxPasses = maxPasses ?? 5;\r\n let pass = 0;\r\n do {\r\n const del = new ElementTreeDeleter(iModel);\r\n del.deleteNormalElements(topElement);\r\n del.deleteSpecialElements();\r\n } while ((iModel.elements.tryGetElement(topElement) !== undefined) && (++pass < maxPasses));\r\n}\r\n\r\n/** Deletes all element sub-trees that are selected by the supplied filter. Uses ElementSubTreeDeleter.\r\n * If the filter selects the top element itself, then the entire tree (including the top element) is deleted.\r\n * That has the same effect as calling [[deleteElementTree]] on the top element.\r\n * @note The caller may have to call this function multiple times if there are multiple layers of dependencies among definition elements.\r\n * @param iModel The iModel\r\n * @param topElement Where to start the search.\r\n * @param filter Callback that selects sub-trees that should be deleted.\r\n * @beta\r\n */\r\nexport function deleteElementSubTrees(iModel: IModelDb, topElement: Id64String, filter: ElementSubTreeDeleteFilter): void {\r\n const del = new ElementSubTreeDeleter(iModel, filter);\r\n del.deleteNormalElementSubTrees(topElement);\r\n del.deleteSpecialElementSubTrees();\r\n}\r\n"]}
|
package/lib/cjs/Entity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Entity.js","sourceRoot":"","sources":["../../src/Entity.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAuD;AACvD,oDAA6H;AAG7H,gEAA4G;AAC5G,gDAA+C;AAgC/C;;;;GAIG;AACH,MAAa,MAAM;IACjB;;OAEG;IACa,kBAAkB,GAAG,IAAa,CAAC;IACnD,0CAA0C;IACnC,MAAM,CAAC,MAAM,CAAgB,CAAC,mGAAmG;IAExI,IAAY,KAAK,KAAoB,OAAO,IAAI,CAAC,WAA4B,CAAC,CAAC,CAAC;IAEhF;;;;OAIG;IACI,MAAM,KAAK,SAAS,KAAa,OAAO,QAAQ,CA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,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IAED,gBAAgB;IACT,MAAM,KAAK,mBAAmB,KAAe,OAAO,EAAE,CAAC,CAAC,CAAC;IAEhE;;;;;OAKG;IACI,MAAM,CAAC,EAAE,CAAC,UAAyB;QACxC,6EAA6E;QAC7E,OAAO,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,SAAS,YAAY,UAAU,CAAC;IACrE,CAAC;IAED;;;OAGG;IACI,MAAM,KAAK,gBAAgB,KAAK,OAAO,KAAK,CAAC,CAAC,CAAC;IAEtD;;;;;OAKG;IACI,eAAe;QACpB,MAAM,YAAY,GAAG,IAAI,gCAAkB,EAAE,CAAC;QAC9C,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;QACvC,OAAO,YAAY,CAAC;IACtB,CAAC;IAED;;;;;;;OAOG;IACO,mBAAmB,CAAC,aAAiC;QAC7D,OAAO,CAAC,2BAA2B;IACrC,CAAC;;AAxRH,wBAyRC","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 Schema\n */\n\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\nimport { ElementLoadOptions, EntityProps, EntityReferenceSet, PropertyCallback, PropertyMetaData } from \"@itwin/core-common\";\nimport type { IModelDb } from \"./IModelDb\";\nimport { Schema } from \"./Schema\";\nimport { ECClass, EntityClass, Property, RelationshipClass, SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { _nativeDb } from \"./internal/Symbols\";\n\n/** Represents a row returned by an ECSql query. The row is returned as a map of property names to values.\n * ECSqlRow has same schema as declared in ECSchema for the class and similar to if ECSQL SELECT * FROM <schema>:<class> were executed.\n * @beta */\nexport interface ECSqlRow {\n [key: string]: any\n}\n\n/** Set of properties that are used to deserialize an [[EntityProps]] from an ECSqlRow.\n * @beta */\nexport interface DeserializeEntityArgs {\n /** Row to deserialize */\n row: ECSqlRow;\n /** The IModel that contains this Entity */\n iModel: IModelDb;\n /** The options used when loading */\n options?: {\n /** Options used when loading an element */\n element?: ElementLoadOptions;\n }\n}\n\n/** A property of an [[Entity]] that needs to be custom handled during deserialization and serialization.\n * @beta */\nexport interface CustomHandledProperty {\n /** The name of the property as it appears in the ECSqlRow */\n readonly propertyName: string;\n /** Where the property is defined */\n readonly source: \"Class\" | \"Computed\";\n}\n\n/** Represents one of the fundamental building block in an [[IModelDb]]: as an [[Element]], [[Model]], or [[Relationship]].\n * Every subclass of Entity represents one BIS [ECClass]($ecschema-metadata).\n * An Entity is typically instantiated from an [EntityProps]($common) and can be converted back to this representation via [[Entity.toJSON]].\n * @public @preview\n */\nexport class Entity {\n /** An immutable property used to discriminate between [[Entity]] and [EntityProps]($common), used to inform the TypeScript compiler that these two types\n * are never substitutable for one another. To obtain an EntityProps from an Entity, use [[Entity.toJSON]].\n */\n public readonly isInstanceOfEntity = true as const;\n /** The Schema that defines this class. */\n public static schema: typeof Schema; // TODO: Schema key on the static level, but it requires a version which may differ between imodels\n\n private get _ctor(): typeof Entity { return this.constructor as typeof Entity; }\n\n /** The name of the BIS class associated with this class.\n * @note Every subclass of Entity **MUST** override this method to identify its BIS class.\n * Failure to do so will ordinarily result in an error when the class is registered, since there may only\n * be one JavaScript class for a given BIS class (usually the errant class will collide with its superclass.)\n */\n public static get className(): string { return \"Entity\"; }\n\n /** Serves as a unique identifier for this class. Typed variant of [[classFullName]].\n * @public @preview\n */\n public static get schemaItemKey(): SchemaItemKey {\n // We cannot cache this here because the className gets overridden in subclasses\n return new SchemaItemKey(this.className, this.schema.schemaKey);\n }\n\n /** Cached Metadata for the ECClass */\n protected _metadata?: EntityClass | RelationshipClass;\n\n /** When working with an Entity it can be useful to set property values directly, bypassing the compiler's type checking.\n * This property makes such code slightly less tedious to read and write.\n * @internal\n */\n public get asAny(): any { return this; }\n\n /** The name of the BIS Schema that defines this class */\n public get schemaName(): string { return this._ctor.schema.schemaName; }\n\n /** The name of the BIS class associated with this class. */\n public get className(): string { return this._ctor.className; }\n\n /** The [[IModelDb]] that contains this Entity */\n public iModel: IModelDb;\n\n /** The Id of this Entity. May be invalid if the Entity has not yet been saved in the database. */\n public id: Id64String;\n\n\n protected constructor(props: EntityProps, iModel: IModelDb) {\n this.iModel = iModel;\n this.id = Id64.fromJSON(props.id);\n // copy all auto-handled properties from input to the object being constructed\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n this.forEachProperty((propName: string, meta: PropertyMetaData) => (this as any)[propName] = meta.createProperty((props as any)[propName]), false);\n }\n\n /** Invoke the constructor of the specified `Entity` subclass.\n * @internal\n */\n public static instantiate(subclass: typeof Entity, props: EntityProps, iModel: IModelDb): Entity {\n return new subclass(props, iModel);\n }\n\n /** List of properties that are need to be custom handled during deserialization and serialization.\n * These properties differ between the ECSql instance of an Entity and the Entity itself.\n * @beta */\n protected static readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"id\", source: \"Class\" },\n { propertyName: \"className\", source: \"Class\" },\n { propertyName: \"jsonProperties\", source: \"Class\" }\n ];\n\n /** Get the list of properties that are custom handled by this class and its superclasses.\n * @internal */\n private static getCustomHandledProperties(): readonly CustomHandledProperty[] {\n if (this.name === \"Entity\") {\n return this._customHandledProps;\n }\n\n const superClass = Object.getPrototypeOf(this) as typeof Entity;\n return [\n ...superClass.getCustomHandledProperties(),\n ...this._customHandledProps,\n ];\n }\n\n /** Converts an ECSqlRow of an Entity to an EntityProps. This is used to deserialize an Entity from the database.\n * @beta */\n public static deserialize(props: DeserializeEntityArgs): EntityProps {\n const enProps: EntityProps = {\n classFullName: props.row.classFullName,\n id: props.row.id,\n }\n\n // Handles cases where id64 ints are stored in the jsonProperties and converts them to hex before parsing as a json object in js\n if (props.row.jsonProperties) {\n enProps.jsonProperties = JSON.parse(props.iModel[_nativeDb].patchJsonProperties(props.row.jsonProperties));\n }\n // Auto handles all properties that are not in the 'customHandledProperties' list\n const customHandledProperties = this.getCustomHandledProperties();\n Object.keys(props.row)\n .filter((propertyName) => customHandledProperties.find((val) => val.propertyName === propertyName) === undefined)\n .forEach((propertyName) => (enProps as ECSqlRow)[propertyName] = props.row[propertyName]\n );\n // Handles custom relClassNames to use '.' instead of ':'\n Object.keys(enProps).forEach((propertyName) => {\n if ((enProps as ECSqlRow)[propertyName].relClassName !== undefined && propertyName !== \"modeledElement\" && propertyName !== \"parentModel\") {\n (enProps as ECSqlRow)[propertyName].relClassName = (enProps as ECSqlRow)[propertyName].relClassName.replace(':', '.');\n }\n });\n return enProps;\n }\n\n /** Converts an EntityProps to an ECSqlRow. This is used to serialize an Entity to prepare to write it to the database.\n * @beta */\n public static serialize(props: EntityProps, _iModel: IModelDb): ECSqlRow {\n const inst: ECSqlRow = {\n classFullName: props.classFullName,\n id: props.id,\n }\n\n const customHandledProperties = this.getCustomHandledProperties();\n Object.keys(props)\n .filter((propertyName) => customHandledProperties.find((val) => val.propertyName === propertyName) === undefined)\n .forEach((propertyName) => inst[propertyName] = (props as ECSqlRow)[propertyName]\n );\n return inst;\n }\n\n /** Obtain the JSON representation of this Entity. Subclasses of [[Entity]] typically override this method to return their corresponding sub-type of [EntityProps]($common) -\n * for example, [[GeometricElement.toJSON]] returns a [GeometricElementProps]($common).\n */\n public toJSON(): EntityProps {\n const val: any = {};\n val.classFullName = this.classFullName;\n if (Id64.isValid(this.id))\n val.id = this.id;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n this.forEachProperty((propName: string) => val[propName] = (this as any)[propName], false);\n return val;\n }\n\n /** Call a function for each property of this Entity.\n * @param func The callback to be invoked on each property\n * @param includeCustom If true (default), include custom-handled properties in the iteration. Otherwise, skip custom-handled properties.\n * @note Custom-handled properties are core properties that have behavior enforced by C++ handlers.\n * @deprecated in 5.0 - will not be removed until after 2026-06-13. Please use `forEach` to get the metadata and iterate over the properties instead.\n *\n * @example\n * ```typescript\n * // Deprecated method\n * entity.forEachProperty((name, propMetaData) => {\n * console.log(`Property name: ${name}, Property type: ${propMetaData.primitiveType}`);\n * });\n *\n * // New method\n * entity.forEach((name, property) => {\n * console.log(`Property name: ${name}, Property type: ${property.propertyType}`);\n * });\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public forEachProperty(func: PropertyCallback, includeCustom: boolean = true) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n this.iModel.forEachMetaData(this.classFullName, true, func, includeCustom);\n }\n\n /**\n * Call a function for each property of this Entity.\n * @param func The callback to be invoked on each property.\n * @param includeCustom If true (default), include custom-handled properties in the iteration. Otherwise, skip custom-handled properties.\n * @note Custom-handled properties are core properties that have behavior enforced by C++ handlers.\n * @throws Error if metadata for the class cannot be retrieved.\n *\n * @example\n * ```typescript\n * entity.forEach((name, property) => {\n * console.log(`Property name: ${name}, Property type: ${property.propertyType}`);\n * });\n * ```\n */\n public forEach(func: PropertyHandler, includeCustom: boolean = true) {\n const item = this._metadata ?? this.iModel.schemaContext.getSchemaItemSync(this.schemaItemKey);\n\n if (EntityClass.isEntityClass(item) || RelationshipClass.isRelationshipClass(item)) {\n for (const property of item.getPropertiesSync()) {\n if (includeCustom || !property.customAttributes?.has(`BisCore.CustomHandledProperty`))\n func(property.name, property);\n }\n } else {\n throw new Error(`Cannot get metadata for ${this.classFullName}. Class is not an EntityClass or RelationshipClass.`);\n }\n }\n\n /** Get the full BIS class name of this Entity in the form \"schema:class\" */\n public static get classFullName(): string { return `${this.schema.schemaName}:${this.className}`; }\n\n /** Get the full BIS class name of this Entity in the form \"schema:class\". */\n public get classFullName(): string { return this._ctor.classFullName; }\n /**\n * Get the item key used by the ecschema-metadata package to identify this entity class\n * @public @preview\n */\n public get schemaItemKey(): SchemaItemKey { return this._ctor.schemaItemKey; }\n\n /** Query metadata for this entity class from the iModel's schema. Returns cached metadata if available.\n * @throws [[IModelError]] if there is a problem querying the schema\n * @returns The metadata for the current entity\n * @public @preview\n */\n public async getMetaData(): Promise<EntityClass | RelationshipClass> {\n if (this._metadata) {\n return this._metadata;\n }\n\n const ecClass = await this.iModel.schemaContext.getSchemaItem(this.schemaItemKey, ECClass);\n if (EntityClass.isEntityClass(ecClass) || RelationshipClass.isRelationshipClass(ecClass)) {\n this._metadata = ecClass;\n return this._metadata;\n } else {\n throw new Error(`Cannot get metadata for ${this.classFullName}`);\n }\n }\n\n /** @internal */\n public getMetaDataSync(): EntityClass | RelationshipClass {\n if (this._metadata) {\n return this._metadata;\n }\n\n const ecClass = this.iModel.schemaContext.getSchemaItemSync(this.schemaItemKey, ECClass);\n if (EntityClass.isEntityClass(ecClass) || RelationshipClass.isRelationshipClass(ecClass)) {\n this._metadata = ecClass;\n return this._metadata;\n } else {\n throw new Error(`Cannot get metadata for ${this.classFullName}`);\n }\n }\n \n /** @internal */\n public static get protectedOperations(): string[] { return []; }\n\n /** return whether this Entity class is a subclass of another Entity class\n * @note the subclass-ness is checked according to JavaScript inheritance, to check the underlying raw EC class's\n * inheritance, you can use [ECClass.is]($ecschema-metadata)\n * @note this should have a type of `is<T extends typeof Entity>(otherClass: T): this is T` but can't because of\n * typescript's restriction on the `this` type in static methods\n */\n public static is(otherClass: typeof Entity): boolean {\n // inline of @itwin/core-bentley's isSubclassOf due to protected constructor.\n return this === otherClass || this.prototype instanceof otherClass;\n }\n\n /** whether this JavaScript class was generated for this ECClass because there was no registered custom implementation\n * ClassRegistry overrides this when generating a class\n * @internal\n */\n public static get isGeneratedClass() { return false; }\n\n /** Get the set of this entity's *entity references*, [EntityReferenceSet]($backend). An *entity reference* is any id\n * stored on the entity, in its EC properties or json fields.\n * This is important for cloning operations but can be useful in other situations as well.\n * @see this.collectReferenceIds\n * @beta\n */\n public getReferenceIds(): EntityReferenceSet {\n const referenceIds = new EntityReferenceSet();\n this.collectReferenceIds(referenceIds);\n return referenceIds;\n }\n\n /** Collect the Ids of this entity's *references* at this level of the class hierarchy.\n * A *reference* is any entity referenced by this entity's EC Data, including json fields.\n * This is important for cloning operations but can be useful in other situations as well.\n * @param _referenceIds The Id64Set to populate with reference Ids.\n * @note This should be overridden (with `super` called) at each level the class hierarchy that introduces references.\n * @see getReferenceIds\n * @beta\n */\n protected collectReferenceIds(_referenceIds: EntityReferenceSet): void {\n return; // no references by default\n }\n}\n\n/** A callback function to process properties of an Entity\n * @public @preview\n */\nexport type PropertyHandler = (name: string, property: Property) => void;\n\n/** Parameter type that can accept both abstract constructor types and non-abstract constructor types for `instanceof` to test.\n * @public @preview\n */\nexport type EntityClassType<T> = Function & { prototype: T }; // eslint-disable-line @typescript-eslint/no-unsafe-function-type\n"]}
|
|
1
|
+
{"version":3,"file":"Entity.js","sourceRoot":"","sources":["../../src/Entity.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAuD;AACvD,oDAA6H;AAG7H,gEAA4G;AAC5G,gDAA+C;AAgC/C;;;;GAIG;AACH,MAAa,MAAM;IACjB;;OAEG;IACa,kBAAkB,GAAG,IAAa,CAAC;IACnD,0CAA0C;IACnC,MAAM,CAAC,MAAM,CAAgB,CAAC,mGAAmG;IAExI,IAAY,KAAK,KAAoB,OAAO,IAAI,CAAC,WAA4B,CAAC,CAAC,CAAC;IAEhF;;;;OAIG;IACI,MAAM,KAAK,SAAS,KAAa,OAAO,QAAQ,CAAC,CAAC,CAAC;IAE1D;;OAEG;IACI,MAAM,KAAK,aAAa;QAC7B,gFAAgF;QAChF,OAAO,IAAI,iCAAa,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAClE,CAAC;IAED,sCAAsC;IAC5B,SAAS,CAAmC;IAEtD;;;OAGG;IACH,IAAW,KAAK,KAAU,OAAO,IAAI,CAAC,CAAC,CAAC;IAExC,yDAAyD;IACzD,IAAW,UAAU,KAAa,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IAExE,4DAA4D;IAC5D,IAAW,SAA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IAAI,gCAAkB,EAAE,CAAC;QAC9C,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;QACvC,OAAO,YAAY,CAAC;IACtB,CAAC;IAED;;;;;;;OAOG;IACO,mBAAmB,CAAC,aAAiC;QAC7D,OAAO,CAAC,2BAA2B;IACrC,CAAC;;AAxRH,wBAyRC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Schema\r\n */\r\n\r\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport { ElementLoadOptions, EntityProps, EntityReferenceSet, PropertyCallback, PropertyMetaData } from \"@itwin/core-common\";\r\nimport type { IModelDb } from \"./IModelDb\";\r\nimport { Schema } from \"./Schema\";\r\nimport { ECClass, EntityClass, Property, RelationshipClass, SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { _nativeDb } from \"./internal/Symbols\";\r\n\r\n/** Represents a row returned by an ECSql query. The row is returned as a map of property names to values.\r\n * ECSqlRow has same schema as declared in ECSchema for the class and similar to if ECSQL SELECT * FROM <schema>:<class> were executed.\r\n * @beta */\r\nexport interface ECSqlRow {\r\n [key: string]: any\r\n}\r\n\r\n/** Set of properties that are used to deserialize an [[EntityProps]] from an ECSqlRow.\r\n * @beta */\r\nexport interface DeserializeEntityArgs {\r\n /** Row to deserialize */\r\n row: ECSqlRow;\r\n /** The IModel that contains this Entity */\r\n iModel: IModelDb;\r\n /** The options used when loading */\r\n options?: {\r\n /** Options used when loading an element */\r\n element?: ElementLoadOptions;\r\n }\r\n}\r\n\r\n/** A property of an [[Entity]] that needs to be custom handled during deserialization and serialization.\r\n * @beta */\r\nexport interface CustomHandledProperty {\r\n /** The name of the property as it appears in the ECSqlRow */\r\n readonly propertyName: string;\r\n /** Where the property is defined */\r\n readonly source: \"Class\" | \"Computed\";\r\n}\r\n\r\n/** Represents one of the fundamental building block in an [[IModelDb]]: as an [[Element]], [[Model]], or [[Relationship]].\r\n * Every subclass of Entity represents one BIS [ECClass]($ecschema-metadata).\r\n * An Entity is typically instantiated from an [EntityProps]($common) and can be converted back to this representation via [[Entity.toJSON]].\r\n * @public @preview\r\n */\r\nexport class Entity {\r\n /** An immutable property used to discriminate between [[Entity]] and [EntityProps]($common), used to inform the TypeScript compiler that these two types\r\n * are never substitutable for one another. To obtain an EntityProps from an Entity, use [[Entity.toJSON]].\r\n */\r\n public readonly isInstanceOfEntity = true as const;\r\n /** The Schema that defines this class. */\r\n public static schema: typeof Schema; // TODO: Schema key on the static level, but it requires a version which may differ between imodels\r\n\r\n private get _ctor(): typeof Entity { return this.constructor as typeof Entity; }\r\n\r\n /** The name of the BIS class associated with this class.\r\n * @note Every subclass of Entity **MUST** override this method to identify its BIS class.\r\n * Failure to do so will ordinarily result in an error when the class is registered, since there may only\r\n * be one JavaScript class for a given BIS class (usually the errant class will collide with its superclass.)\r\n */\r\n public static get className(): string { return \"Entity\"; }\r\n\r\n /** Serves as a unique identifier for this class. Typed variant of [[classFullName]].\r\n * @public @preview\r\n */\r\n public static get schemaItemKey(): SchemaItemKey {\r\n // We cannot cache this here because the className gets overridden in subclasses\r\n return new SchemaItemKey(this.className, this.schema.schemaKey);\r\n }\r\n\r\n /** Cached Metadata for the ECClass */\r\n protected _metadata?: EntityClass | RelationshipClass;\r\n\r\n /** When working with an Entity it can be useful to set property values directly, bypassing the compiler's type checking.\r\n * This property makes such code slightly less tedious to read and write.\r\n * @internal\r\n */\r\n public get asAny(): any { return this; }\r\n\r\n /** The name of the BIS Schema that defines this class */\r\n public get schemaName(): string { return this._ctor.schema.schemaName; }\r\n\r\n /** The name of the BIS class associated with this class. */\r\n public get className(): string { return this._ctor.className; }\r\n\r\n /** The [[IModelDb]] that contains this Entity */\r\n public iModel: IModelDb;\r\n\r\n /** The Id of this Entity. May be invalid if the Entity has not yet been saved in the database. */\r\n public id: Id64String;\r\n\r\n\r\n protected constructor(props: EntityProps, iModel: IModelDb) {\r\n this.iModel = iModel;\r\n this.id = Id64.fromJSON(props.id);\r\n // copy all auto-handled properties from input to the object being constructed\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n this.forEachProperty((propName: string, meta: PropertyMetaData) => (this as any)[propName] = meta.createProperty((props as any)[propName]), false);\r\n }\r\n\r\n /** Invoke the constructor of the specified `Entity` subclass.\r\n * @internal\r\n */\r\n public static instantiate(subclass: typeof Entity, props: EntityProps, iModel: IModelDb): Entity {\r\n return new subclass(props, iModel);\r\n }\r\n\r\n /** List of properties that are need to be custom handled during deserialization and serialization.\r\n * These properties differ between the ECSql instance of an Entity and the Entity itself.\r\n * @beta */\r\n protected static readonly _customHandledProps: CustomHandledProperty[] = [\r\n { propertyName: \"id\", source: \"Class\" },\r\n { propertyName: \"className\", source: \"Class\" },\r\n { propertyName: \"jsonProperties\", source: \"Class\" }\r\n ];\r\n\r\n /** Get the list of properties that are custom handled by this class and its superclasses.\r\n * @internal */\r\n private static getCustomHandledProperties(): readonly CustomHandledProperty[] {\r\n if (this.name === \"Entity\") {\r\n return this._customHandledProps;\r\n }\r\n\r\n const superClass = Object.getPrototypeOf(this) as typeof Entity;\r\n return [\r\n ...superClass.getCustomHandledProperties(),\r\n ...this._customHandledProps,\r\n ];\r\n }\r\n\r\n /** Converts an ECSqlRow of an Entity to an EntityProps. This is used to deserialize an Entity from the database.\r\n * @beta */\r\n public static deserialize(props: DeserializeEntityArgs): EntityProps {\r\n const enProps: EntityProps = {\r\n classFullName: props.row.classFullName,\r\n id: props.row.id,\r\n }\r\n\r\n // Handles cases where id64 ints are stored in the jsonProperties and converts them to hex before parsing as a json object in js\r\n if (props.row.jsonProperties) {\r\n enProps.jsonProperties = JSON.parse(props.iModel[_nativeDb].patchJsonProperties(props.row.jsonProperties));\r\n }\r\n // Auto handles all properties that are not in the 'customHandledProperties' list\r\n const customHandledProperties = this.getCustomHandledProperties();\r\n Object.keys(props.row)\r\n .filter((propertyName) => customHandledProperties.find((val) => val.propertyName === propertyName) === undefined)\r\n .forEach((propertyName) => (enProps as ECSqlRow)[propertyName] = props.row[propertyName]\r\n );\r\n // Handles custom relClassNames to use '.' instead of ':'\r\n Object.keys(enProps).forEach((propertyName) => {\r\n if ((enProps as ECSqlRow)[propertyName].relClassName !== undefined && propertyName !== \"modeledElement\" && propertyName !== \"parentModel\") {\r\n (enProps as ECSqlRow)[propertyName].relClassName = (enProps as ECSqlRow)[propertyName].relClassName.replace(':', '.');\r\n }\r\n });\r\n return enProps;\r\n }\r\n\r\n /** Converts an EntityProps to an ECSqlRow. This is used to serialize an Entity to prepare to write it to the database.\r\n * @beta */\r\n public static serialize(props: EntityProps, _iModel: IModelDb): ECSqlRow {\r\n const inst: ECSqlRow = {\r\n classFullName: props.classFullName,\r\n id: props.id,\r\n }\r\n\r\n const customHandledProperties = this.getCustomHandledProperties();\r\n Object.keys(props)\r\n .filter((propertyName) => customHandledProperties.find((val) => val.propertyName === propertyName) === undefined)\r\n .forEach((propertyName) => inst[propertyName] = (props as ECSqlRow)[propertyName]\r\n );\r\n return inst;\r\n }\r\n\r\n /** Obtain the JSON representation of this Entity. Subclasses of [[Entity]] typically override this method to return their corresponding sub-type of [EntityProps]($common) -\r\n * for example, [[GeometricElement.toJSON]] returns a [GeometricElementProps]($common).\r\n */\r\n public toJSON(): EntityProps {\r\n const val: any = {};\r\n val.classFullName = this.classFullName;\r\n if (Id64.isValid(this.id))\r\n val.id = this.id;\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n this.forEachProperty((propName: string) => val[propName] = (this as any)[propName], false);\r\n return val;\r\n }\r\n\r\n /** Call a function for each property of this Entity.\r\n * @param func The callback to be invoked on each property\r\n * @param includeCustom If true (default), include custom-handled properties in the iteration. Otherwise, skip custom-handled properties.\r\n * @note Custom-handled properties are core properties that have behavior enforced by C++ handlers.\r\n * @deprecated in 5.0 - will not be removed until after 2026-06-13. Please use `forEach` to get the metadata and iterate over the properties instead.\r\n *\r\n * @example\r\n * ```typescript\r\n * // Deprecated method\r\n * entity.forEachProperty((name, propMetaData) => {\r\n * console.log(`Property name: ${name}, Property type: ${propMetaData.primitiveType}`);\r\n * });\r\n *\r\n * // New method\r\n * entity.forEach((name, property) => {\r\n * console.log(`Property name: ${name}, Property type: ${property.propertyType}`);\r\n * });\r\n * ```\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public forEachProperty(func: PropertyCallback, includeCustom: boolean = true) {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n this.iModel.forEachMetaData(this.classFullName, true, func, includeCustom);\r\n }\r\n\r\n /**\r\n * Call a function for each property of this Entity.\r\n * @param func The callback to be invoked on each property.\r\n * @param includeCustom If true (default), include custom-handled properties in the iteration. Otherwise, skip custom-handled properties.\r\n * @note Custom-handled properties are core properties that have behavior enforced by C++ handlers.\r\n * @throws Error if metadata for the class cannot be retrieved.\r\n *\r\n * @example\r\n * ```typescript\r\n * entity.forEach((name, property) => {\r\n * console.log(`Property name: ${name}, Property type: ${property.propertyType}`);\r\n * });\r\n * ```\r\n */\r\n public forEach(func: PropertyHandler, includeCustom: boolean = true) {\r\n const item = this._metadata ?? this.iModel.schemaContext.getSchemaItemSync(this.schemaItemKey);\r\n\r\n if (EntityClass.isEntityClass(item) || RelationshipClass.isRelationshipClass(item)) {\r\n for (const property of item.getPropertiesSync()) {\r\n if (includeCustom || !property.customAttributes?.has(`BisCore.CustomHandledProperty`))\r\n func(property.name, property);\r\n }\r\n } else {\r\n throw new Error(`Cannot get metadata for ${this.classFullName}. Class is not an EntityClass or RelationshipClass.`);\r\n }\r\n }\r\n\r\n /** Get the full BIS class name of this Entity in the form \"schema:class\" */\r\n public static get classFullName(): string { return `${this.schema.schemaName}:${this.className}`; }\r\n\r\n /** Get the full BIS class name of this Entity in the form \"schema:class\". */\r\n public get classFullName(): string { return this._ctor.classFullName; }\r\n /**\r\n * Get the item key used by the ecschema-metadata package to identify this entity class\r\n * @public @preview\r\n */\r\n public get schemaItemKey(): SchemaItemKey { return this._ctor.schemaItemKey; }\r\n\r\n /** Query metadata for this entity class from the iModel's schema. Returns cached metadata if available.\r\n * @throws [[IModelError]] if there is a problem querying the schema\r\n * @returns The metadata for the current entity\r\n * @public @preview\r\n */\r\n public async getMetaData(): Promise<EntityClass | RelationshipClass> {\r\n if (this._metadata) {\r\n return this._metadata;\r\n }\r\n\r\n const ecClass = await this.iModel.schemaContext.getSchemaItem(this.schemaItemKey, ECClass);\r\n if (EntityClass.isEntityClass(ecClass) || RelationshipClass.isRelationshipClass(ecClass)) {\r\n this._metadata = ecClass;\r\n return this._metadata;\r\n } else {\r\n throw new Error(`Cannot get metadata for ${this.classFullName}`);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public getMetaDataSync(): EntityClass | RelationshipClass {\r\n if (this._metadata) {\r\n return this._metadata;\r\n }\r\n\r\n const ecClass = this.iModel.schemaContext.getSchemaItemSync(this.schemaItemKey, ECClass);\r\n if (EntityClass.isEntityClass(ecClass) || RelationshipClass.isRelationshipClass(ecClass)) {\r\n this._metadata = ecClass;\r\n return this._metadata;\r\n } else {\r\n throw new Error(`Cannot get metadata for ${this.classFullName}`);\r\n }\r\n }\r\n \r\n /** @internal */\r\n public static get protectedOperations(): string[] { return []; }\r\n\r\n /** return whether this Entity class is a subclass of another Entity class\r\n * @note the subclass-ness is checked according to JavaScript inheritance, to check the underlying raw EC class's\r\n * inheritance, you can use [ECClass.is]($ecschema-metadata)\r\n * @note this should have a type of `is<T extends typeof Entity>(otherClass: T): this is T` but can't because of\r\n * typescript's restriction on the `this` type in static methods\r\n */\r\n public static is(otherClass: typeof Entity): boolean {\r\n // inline of @itwin/core-bentley's isSubclassOf due to protected constructor.\r\n return this === otherClass || this.prototype instanceof otherClass;\r\n }\r\n\r\n /** whether this JavaScript class was generated for this ECClass because there was no registered custom implementation\r\n * ClassRegistry overrides this when generating a class\r\n * @internal\r\n */\r\n public static get isGeneratedClass() { return false; }\r\n\r\n /** Get the set of this entity's *entity references*, [EntityReferenceSet]($backend). An *entity reference* is any id\r\n * stored on the entity, in its EC properties or json fields.\r\n * This is important for cloning operations but can be useful in other situations as well.\r\n * @see this.collectReferenceIds\r\n * @beta\r\n */\r\n public getReferenceIds(): EntityReferenceSet {\r\n const referenceIds = new EntityReferenceSet();\r\n this.collectReferenceIds(referenceIds);\r\n return referenceIds;\r\n }\r\n\r\n /** Collect the Ids of this entity's *references* at this level of the class hierarchy.\r\n * A *reference* is any entity referenced by this entity's EC Data, including json fields.\r\n * This is important for cloning operations but can be useful in other situations as well.\r\n * @param _referenceIds The Id64Set to populate with reference Ids.\r\n * @note This should be overridden (with `super` called) at each level the class hierarchy that introduces references.\r\n * @see getReferenceIds\r\n * @beta\r\n */\r\n protected collectReferenceIds(_referenceIds: EntityReferenceSet): void {\r\n return; // no references by default\r\n }\r\n}\r\n\r\n/** A callback function to process properties of an Entity\r\n * @public @preview\r\n */\r\nexport type PropertyHandler = (name: string, property: Property) => void;\r\n\r\n/** Parameter type that can accept both abstract constructor types and non-abstract constructor types for `instanceof` to test.\r\n * @public @preview\r\n */\r\nexport type EntityClassType<T> = Function & { prototype: T }; // eslint-disable-line @typescript-eslint/no-unsafe-function-type\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityReferences.js","sourceRoot":"","sources":["../../src/EntityReferences.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAAwH;AACxH,sDAAuD;AAEvD,mCAAgC;AAChC,uCAAoC;AACpC,mDAAgD;AAChD,iDAAiE;AACjE,iCAAiC;AAcjC;;;GAGG;AACH,IAAiB,gBAAgB,CAkEhC;AAlED,WAAiB,gBAAgB;IAC/B,SAAgB,OAAO,CAAC,EAAmB;QACzC,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,iCAAmB,CAAC,KAAK,CAAC;IAC7C,CAAC;IAFe,wBAAO,UAEtB,CAAA;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AA;IAED,mEAAmE;IACnE,SAAgB,SAAS,CAAC,EAAc,EAAE,WAA0B;QAClE,MAAM,IAAI,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;QACxC,OAAO,GAAG,IAAI,GAAG,EAAE,EAAE,CAAC;IACxB,CAAC;IAHe,0BAAS,YAGxB,CAAA;IAED,4EAA4E;IAC5E,SAAgB,cAAc,CAAC,EAAc,EAAE,IAAyB;QACtE,OAAO,GAAG,IAAI,GAAG,EAAE,EAAE,CAAC;IACxB,CAAC;IAFe,+BAAc,iBAE7B,CAAA;IAED,+FAA+F;IAC/F,SAAgB,aAAa,CAAC,WAA0B;QACtD,IAAI,WAAW,CAAC,EAAE,CAAC,iBAAO,CAAC;YACzB,OAAO,iCAAmB,CAAC,OAAO,CAAC;aAChC,IAAI,WAAW,CAAC,EAAE,CAAC,6BAAa,CAAC;YACpC,OAAO,iCAAmB,CAAC,aAAa,CAAC;aACtC,IAAI,WAAW,CAAC,EAAE,CAAC,aAAK,CAAC;YAC5B,OAAO,iCAAmB,CAAC,KAAK,CAAC;aAC9B,IAAI,WAAW,CAAC,EAAE,CAAC,2BAAY,CAAC;YACnC,OAAO,iCAAmB,CAAC,YAAY,CAAC;;YAExC,MAAM,CAAC,KAAK,EAAE,iEAAiE,CAAC,CAAC;IACrF,CAAC;IAXe,8BAAa,gBAW5B,CAAA;AACH,CAAC,EAlEgB,gBAAgB,gCAAhB,gBAAgB,QAkEhC","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 Schema\n */\n\nimport { ConcreteEntityTypes, ElementAspectProps, ElementProps, EntityReference, ModelProps } from \"@itwin/core-common\";\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\nimport type { Entity } from \"./Entity\";\nimport { Model } from \"./Model\";\nimport { Element } from \"./Element\";\nimport { ElementAspect } from \"./ElementAspect\";\nimport { Relationship, RelationshipProps } from \"./Relationship\";\nimport * as assert from \"assert\";\n\n/** Concrete classes that can be created, with the notable exception of CodeSpecs since it is does not derive from Entity\n * other entity classes. In the future if there is a need\n * to manage them this way, it can be added\n * @alpha\n */\nexport type ConcreteEntity = Element | Model | ElementAspect | Relationship;\n\n/** Props for a [[ConcreteEntity]]\n * @alpha\n */\nexport type ConcreteEntityProps = ElementProps | ModelProps | ElementAspectProps | RelationshipProps;\n\n/**\n * Utilities for the [EntityReference]($common) type which is a kind of strings\n * @alpha\n */\nexport namespace EntityReferences {\n export function isModel(id: EntityReference) {\n return id[0] === ConcreteEntityTypes.Model;\n }\n export function isElement(id: EntityReference) {\n return id[0] === ConcreteEntityTypes.Element;\n }\n export function isElementAspect(id: EntityReference) {\n return id[0] === ConcreteEntityTypes.ElementAspect;\n }\n export function isRelationship(id: EntityReference) {\n return id[0] === ConcreteEntityTypes.Relationship;\n }\n export function toId64(id: EntityReference) {\n return id.slice(1);\n }\n\n /** split a concrete entity id into its type and raw id */\n export function split(id: EntityReference): [ConcreteEntityTypes, Id64String] {\n return [id[0] as ConcreteEntityTypes, id.slice(1)];\n }\n\n /** used by the transformer to figure out where to check for the existence in a db of a concrete element id\n * @internal\n */\n export function isValid(id: EntityReference): boolean {\n return Id64.isValid(toId64(id));\n }\n\n /** create the invalid id for a concrete entity type\n * @internal\n */\n export function makeInvalid(type: ConcreteEntityTypes): EntityReference {\n return `${type}${Id64.invalid}`;\n }\n\n /** create an EntityReference given an entity */\n export function from(entity: ConcreteEntity): EntityReference {\n const type = typeFromClass(entity.constructor as typeof Entity);\n return `${type}${entity.id}`;\n }\n\n /** create an EntityReference given an id and a JavaScript class */\n export function fromClass(id: Id64String, entityClass: typeof Entity): EntityReference {\n const type = typeFromClass(entityClass);\n return `${type}${id}`;\n }\n\n /** Create an EntityReference quickly from an exact reference type and id */\n export function fromEntityType(id: Id64String, type: ConcreteEntityTypes): EntityReference {\n return `${type}${id}`;\n }\n\n /** @internal the argument entityClass be concrete (i.e. not the Entity abstract base class) */\n export function typeFromClass(entityClass: typeof Entity): ConcreteEntityTypes {\n if (entityClass.is(Element))\n return ConcreteEntityTypes.Element;\n else if (entityClass.is(ElementAspect))\n return ConcreteEntityTypes.ElementAspect;\n else if (entityClass.is(Model))\n return ConcreteEntityTypes.Model;\n else if (entityClass.is(Relationship))\n return ConcreteEntityTypes.Relationship;\n else\n assert(false, \"unknown or abstract entity type passed to EntityReferences.from\");\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"EntityReferences.js","sourceRoot":"","sources":["../../src/EntityReferences.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAAwH;AACxH,sDAAuD;AAEvD,mCAAgC;AAChC,uCAAoC;AACpC,mDAAgD;AAChD,iDAAiE;AACjE,iCAAiC;AAcjC;;;GAGG;AACH,IAAiB,gBAAgB,CAkEhC;AAlED,WAAiB,gBAAgB;IAC/B,SAAgB,OAAO,CAAC,EAAmB;QACzC,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,iCAAmB,CAAC,KAAK,CAAC;IAC7C,CAAC;IAFe,wBAAO,UAEtB,CAAA;IACD,SAAgB,SAAS,CAAC,EAAmB;QAC3C,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,iCAAmB,CAAC,OAAO,CAAC;IAC/C,CAAC;IAFe,0BAAS,YAExB,CAAA;IACD,SAAgB,eAAe,CAAC,EAAmB;QACjD,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,iCAAmB,CAAC,aAAa,CAAC;IACrD,CAAC;IAFe,gCAAe,kBAE9B,CAAA;IACD,SAAgB,cAAc,CAAC,EAAmB;QAChD,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,iCAAmB,CAAC,YAAY,CAAC;IACpD,CAAC;IAFe,+BAAc,iBAE7B,CAAA;IACD,SAAgB,MAAM,CAAC,EAAmB;QACxC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,C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I,WAAW,CAAC,EAAE,CAAC,6BAAa,CAAC;YACpC,OAAO,iCAAmB,CAAC,aAAa,CAAC;aACtC,IAAI,WAAW,CAAC,EAAE,CAAC,aAAK,CAAC;YAC5B,OAAO,iCAAmB,CAAC,KAAK,CAAC;aAC9B,IAAI,WAAW,CAAC,EAAE,CAAC,2BAAY,CAAC;YACnC,OAAO,iCAAmB,CAAC,YAAY,CAAC;;YAExC,MAAM,CAAC,KAAK,EAAE,iEAAiE,CAAC,CAAC;IACrF,CAAC;IAXe,8BAAa,gBAW5B,CAAA;AACH,CAAC,EAlEgB,gBAAgB,gCAAhB,gBAAgB,QAkEhC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Schema\r\n */\r\n\r\nimport { ConcreteEntityTypes, ElementAspectProps, ElementProps, EntityReference, ModelProps } from \"@itwin/core-common\";\r\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport type { Entity } from \"./Entity\";\r\nimport { Model } from \"./Model\";\r\nimport { Element } from \"./Element\";\r\nimport { ElementAspect } from \"./ElementAspect\";\r\nimport { Relationship, RelationshipProps } from \"./Relationship\";\r\nimport * as assert from \"assert\";\r\n\r\n/** Concrete classes that can be created, with the notable exception of CodeSpecs since it is does not derive from Entity\r\n * other entity classes. In the future if there is a need\r\n * to manage them this way, it can be added\r\n * @alpha\r\n */\r\nexport type ConcreteEntity = Element | Model | ElementAspect | Relationship;\r\n\r\n/** Props for a [[ConcreteEntity]]\r\n * @alpha\r\n */\r\nexport type ConcreteEntityProps = ElementProps | ModelProps | ElementAspectProps | RelationshipProps;\r\n\r\n/**\r\n * Utilities for the [EntityReference]($common) type which is a kind of strings\r\n * @alpha\r\n */\r\nexport namespace EntityReferences {\r\n export function isModel(id: EntityReference) {\r\n return id[0] === ConcreteEntityTypes.Model;\r\n }\r\n export function isElement(id: EntityReference) {\r\n return id[0] === ConcreteEntityTypes.Element;\r\n }\r\n export function isElementAspect(id: EntityReference) {\r\n return id[0] === ConcreteEntityTypes.ElementAspect;\r\n }\r\n export function isRelationship(id: EntityReference) {\r\n return id[0] === ConcreteEntityTypes.Relationship;\r\n }\r\n export function toId64(id: EntityReference) {\r\n return id.slice(1);\r\n }\r\n\r\n /** split a concrete entity id into its type and raw id */\r\n export function split(id: EntityReference): [ConcreteEntityTypes, Id64String] {\r\n return [id[0] as ConcreteEntityTypes, id.slice(1)];\r\n }\r\n\r\n /** used by the transformer to figure out where to check for the existence in a db of a concrete element id\r\n * @internal\r\n */\r\n export function isValid(id: EntityReference): boolean {\r\n return Id64.isValid(toId64(id));\r\n }\r\n\r\n /** create the invalid id for a concrete entity type\r\n * @internal\r\n */\r\n export function makeInvalid(type: ConcreteEntityTypes): EntityReference {\r\n return `${type}${Id64.invalid}`;\r\n }\r\n\r\n /** create an EntityReference given an entity */\r\n export function from(entity: ConcreteEntity): EntityReference {\r\n const type = typeFromClass(entity.constructor as typeof Entity);\r\n return `${type}${entity.id}`;\r\n }\r\n\r\n /** create an EntityReference given an id and a JavaScript class */\r\n export function fromClass(id: Id64String, entityClass: typeof Entity): EntityReference {\r\n const type = typeFromClass(entityClass);\r\n return `${type}${id}`;\r\n }\r\n\r\n /** Create an EntityReference quickly from an exact reference type and id */\r\n export function fromEntityType(id: Id64String, type: ConcreteEntityTypes): EntityReference {\r\n return `${type}${id}`;\r\n }\r\n\r\n /** @internal the argument entityClass be concrete (i.e. not the Entity abstract base class) */\r\n export function typeFromClass(entityClass: typeof Entity): ConcreteEntityTypes {\r\n if (entityClass.is(Element))\r\n return ConcreteEntityTypes.Element;\r\n else if (entityClass.is(ElementAspect))\r\n return ConcreteEntityTypes.ElementAspect;\r\n else if (entityClass.is(Model))\r\n return ConcreteEntityTypes.Model;\r\n else if (entityClass.is(Relationship))\r\n return ConcreteEntityTypes.Relationship;\r\n else\r\n assert(false, \"unknown or abstract entity type passed to EntityReferences.from\");\r\n }\r\n}\r\n"]}
|