@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":"BriefcaseManager.js","sourceRoot":"","sources":["../../src/BriefcaseManager.ts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T,UAAU,CAAC,UAAU,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,EAAe,EAAE,GAAoB;QACrE,IAAI,UAAU,GAAG,GAAG,CAAC,eAAe,IAAI,CAAC,CAAC;QAC1C,OAAO,IAAI,EAAE,CAAC;YACZ,IAAI,CAAC;gBACH,MAAM,gBAAgB,CAAC,sBAAsB,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;gBACvD,IAAI,CAAC,EAAE,CAAC,4BAA4B;oBAClC,MAAM,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAC5B,oFAAoF;gBACpF,wFAAwF;gBACxF,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,cAAc,EAAE;oBACjC,OAAO;gBAET,MAAM,gBAAgB,CAAC,WAAW,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;YAC9C,CAAC;YAAC,OAAO,GAAQ,EAAE,CAAC;gBAClB,IAAI,UAAU,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC,WAAW,KAAK,eAAe,CAAC,cAAc;oBACzE,MAAM,CAAC,GAAG,CAAC,CAAC;gBACd,MAAM,CAAC,GAAG,CAAC,eAAe,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAClE,CAAC;QACH,CAAC;IACH,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 iModels\n */\n\n// cspell:ignore cset csets ecchanges\n\nimport * as path from \"node:path\";\nimport * as os from \"node:os\";\nimport {\n AccessToken, BeDuration, ChangeSetStatus, DbResult, GuidString, IModelHubStatus, IModelStatus, Logger, OpenMode, Optional, StopWatch\n} from \"@itwin/core-bentley\";\nimport {\n BriefcaseId, BriefcaseIdValue, BriefcaseProps, ChangesetFileProps, ChangesetIndex, ChangesetIndexOrId, ChangesetProps, ChangesetRange, ChangesetType, IModelError, IModelVersion, LocalBriefcaseProps,\n LocalDirName, LocalFileName, RequestNewBriefcaseProps,\n} from \"@itwin/core-common\";\nimport { AcquireNewBriefcaseIdArg, DownloadChangesetArg, DownloadChangesetRangeArg, IModelNameArg } from \"./BackendHubAccess\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { CheckpointManager, CheckpointProps, ProgressFunction } from \"./CheckpointManager\";\nimport { BriefcaseDb, IModelDb, TokenArg } from \"./IModelDb\";\nimport { IModelHost } from \"./IModelHost\";\nimport { IModelJsFs } from \"./IModelJsFs\";\nimport { SchemaSync } from \"./SchemaSync\";\nimport { _hubAccess, _nativeDb, _releaseAllLocks } from \"./internal/Symbols\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { StashManager, StashProps } from \"./StashManager\";\n\nconst loggerCategory = BackendLoggerCategory.IModelDb;\n\n/** The argument for [[BriefcaseManager.downloadBriefcase]]\n * @public\n*/\nexport interface RequestNewBriefcaseArg extends TokenArg, RequestNewBriefcaseProps {\n /** If present, a function called periodically during the download to indicate progress.\n * @note return non-zero from this function to abort the download.\n */\n onProgress?: ProgressFunction;\n}\n\n/**\n * Parameters for pushing changesets to iModelHub\n * @public\n */\nexport interface PushChangesArgs extends TokenArg {\n /** A description of the changes. This is visible on the iModel's timeline. */\n description: string;\n /** if present, the locks are retained after the operation. Otherwise, *all* locks are released after the changeset is successfully pushed. */\n retainLocks?: true;\n /** number of times to retry pull/merge if other users are pushing at the same time. Default is 5 */\n mergeRetryCount?: number;\n /** delay to wait between pull/merge retry attempts. Default is 3 seconds */\n mergeRetryDelay?: BeDuration;\n /** the number of time to attempt to retry to push the changeset upon failure. Default is 3 */\n pushRetryCount?: number;\n /** The delay to wait between retry attempts on failed pushes. Default is 3 seconds. */\n pushRetryDelay?: BeDuration;\n /**\n * (unused)\n * @deprecated in 5.1.8 - will not be removed until after 2026-10-01. Not used by BriefcaseManager. Caller should remove this flag.\n * @internal\n */\n noFastForward?: true;\n}\n\n/**\n * Specifies a specific index for pulling changes.\n * @public\n */\nexport interface ToChangesetArgs extends TokenArg {\n /** The last ChangesetIndex to pull. If not present, pull *all* newer changesets. */\n toIndex?: ChangesetIndex;\n}\n\n/** Arguments for [[BriefcaseManager.pullAndApplyChangesets]]\n * @public\n */\nexport type PullChangesArgs = ToChangesetArgs & {\n /** If present, a function called periodically during the download to indicate progress.\n * @note return non-zero from this function to abort the download.\n */\n onProgress?: ProgressFunction;\n /**\n * (unused)\n * @deprecated in 5.1.8 - will not be removed until after 2026-10-01. Not used by BriefcaseManager. Caller should remove this flag.\n * @internal\n */\n noFastForward?: true;\n};\n\n/** Arguments for [[BriefcaseManager.revertTimelineChanges]]\n * @public\n */\nexport type RevertChangesArgs = Optional<PushChangesArgs, \"description\"> & {\n /** If present, a function called periodically during the download to indicate progress.\n * @note return non-zero from this function to abort the download.\n */\n onProgress?: ProgressFunction;\n /** The index of the changeset to revert to */\n toIndex: ChangesetIndex;\n /** If present, schema changes are skipped during the revert operation. */\n skipSchemaChanges?: true;\n};\n\n/** Manages downloading Briefcases and downloading and uploading changesets.\n * @public\n */\nexport class BriefcaseManager {\n /** @internal */\n public static readonly PULL_MERGE_RESTORE_POINT_NAME = \"$pull_merge_restore_point\";\n\n /** Get the local path of the folder storing files that are associated with an imodel */\n public static getIModelPath(iModelId: GuidString): LocalDirName { return path.join(this._cacheDir, iModelId); }\n\n /** @internal */\n public static getChangeSetsPath(iModelId: GuidString): LocalDirName { return path.join(this.getIModelPath(iModelId), \"changesets\"); }\n\n /** @internal */\n public static getChangeCachePathName(iModelId: GuidString): LocalFileName { return path.join(this.getIModelPath(iModelId), iModelId.concat(\".bim.ecchanges\")); }\n\n /** @internal */\n public static getChangedElementsPathName(iModelId: GuidString): LocalFileName { return path.join(this.getIModelPath(iModelId), iModelId.concat(\".bim.elems\")); }\n\n private static _briefcaseSubDir = \"briefcases\";\n /** Get the local path of the folder storing briefcases associated with the specified iModel. */\n public static getBriefcaseBasePath(iModelId: GuidString): LocalDirName {\n return path.join(this.getIModelPath(iModelId), this._briefcaseSubDir);\n }\n\n /** Get the name of the local file that holds, or will hold, a local briefcase in the briefcase cache.\n * @note The briefcase cache is a local directory established in the call to [[BriefcaseManager.initialize]].\n * @param briefcase the iModelId and BriefcaseId for the filename\n * @see getIModelPath\n */\n public static getFileName(briefcase: BriefcaseProps): LocalFileName {\n return path.join(this.getBriefcaseBasePath(briefcase.iModelId), `${briefcase.briefcaseId}.bim`);\n }\n\n private static setupCacheDir(cacheRootDir: LocalDirName) {\n this._cacheDir = cacheRootDir;\n IModelJsFs.recursiveMkDirSync(this._cacheDir);\n }\n\n private static _initialized?: boolean;\n /** Initialize BriefcaseManager\n * @param cacheRootDir The root directory for storing a cache of downloaded briefcase files on the local computer.\n * Briefcases are stored relative to this path in sub-folders organized by IModelId.\n * @note It is perfectly valid for applications to store briefcases in locations they manage, outside of `cacheRootDir`.\n */\n public static initialize(cacheRootDir: LocalDirName) {\n if (this._initialized)\n return;\n this.setupCacheDir(cacheRootDir);\n IModelHost.onBeforeShutdown.addOnce(() => this.finalize());\n this._initialized = true;\n }\n\n private static finalize() {\n this._initialized = false;\n }\n\n /** Get a list of the local briefcase held in the briefcase cache, optionally for a single iModelId\n * @param iModelId if present, only briefcases for this iModelId are returned, otherwise all briefcases for all\n * iModels in the briefcase cache are returned.\n * @note usually there should only be one briefcase per iModel.\n */\n public static getCachedBriefcases(iModelId?: GuidString): LocalBriefcaseProps[] {\n const briefcaseList: LocalBriefcaseProps[] = [];\n const iModelDirs = IModelJsFs.readdirSync(this._cacheDir);\n for (const iModelDir of iModelDirs) {\n if (iModelId && iModelId !== iModelDir)\n continue;\n const bcPath = path.join(this._cacheDir, iModelDir, this._briefcaseSubDir);\n try {\n if (!IModelJsFs.lstatSync(bcPath)?.isDirectory)\n continue;\n } catch {\n continue;\n }\n\n const briefcases = IModelJsFs.readdirSync(bcPath);\n for (const briefcaseName of briefcases) {\n if (briefcaseName.endsWith(\".bim\")) {\n try {\n const fileName = path.join(bcPath, briefcaseName);\n const fileSize = IModelJsFs.lstatSync(fileName)?.size ?? 0;\n const db = IModelDb.openDgnDb({ path: fileName }, OpenMode.Readonly);\n briefcaseList.push({ fileName, iTwinId: db.getITwinId(), iModelId: db.getIModelId(), briefcaseId: db.getBriefcaseId(), changeset: db.getCurrentChangeset(), fileSize });\n db.closeFile();\n } catch { }\n }\n }\n }\n return briefcaseList;\n }\n\n private static _cacheDir: LocalDirName;\n /** Get the root directory for the briefcase cache */\n public static get cacheDir(): LocalDirName { return this._cacheDir; }\n\n /** Determine whether the supplied briefcaseId is in the range of assigned BriefcaseIds issued by iModelHub\n * @note this does check whether the id was actually acquired by the caller.\n */\n public static isValidBriefcaseId(id: BriefcaseId) {\n return id >= BriefcaseIdValue.FirstValid && id <= BriefcaseIdValue.LastValid;\n }\n\n /** Acquire a new briefcaseId from iModelHub for the supplied iModelId\n * @note usually there should only be one briefcase per iModel per user. If a single user acquires more than one briefcaseId,\n * it's a good idea to supply different aliases for each of them.\n */\n public static async acquireNewBriefcaseId(arg: AcquireNewBriefcaseIdArg): Promise<BriefcaseId> {\n return IModelHost[_hubAccess].acquireNewBriefcaseId(arg);\n }\n\n /**\n * Download a new briefcase from iModelHub for the supplied iModelId.\n *\n * Briefcases are local files holding a copy of an iModel.\n * Briefcases may either be specific to an individual user (so that it can be modified to create changesets), or it can be readonly so it can accept but not create changesets.\n * Every briefcase internally holds its [[BriefcaseId]]. Writeable briefcases have a `BriefcaseId` \"assigned\" to them by iModelHub. No two users will ever have the same BriefcaseId.\n * Readonly briefcases are \"unassigned\" with the special value [[BriefcaseId.Unassigned]].\n *\n * Typically a given user will have only one briefcase on their machine for a given iModelId. Rarely, it may be necessary to use more than one\n * briefcase to make isolated independent sets of changes, but that is exceedingly complicated and rare.\n *\n * Callers of this method may supply a BriefcaseId, or if none is supplied, a new one is acquired from iModelHub.\n *\n * @param arg The arguments that specify the briefcase file to be downloaded.\n * @returns The properties of the local briefcase in a Promise that is resolved after the briefcase is fully downloaded and the briefcase file is ready for use via [BriefcaseDb.open]($backend).\n * @note The location of the local file to hold the briefcase is arbitrary and may be any valid *local* path on your machine. If you don't supply\n * a filename, the local briefcase cache is used by creating a file with the briefcaseId as its name in the `briefcases` folder below the folder named\n * for the IModelId.\n * @note *It is invalid to edit briefcases on a shared network drive* and that is a sure way to corrupt your briefcase (see https://www.sqlite.org/howtocorrupt.html)\n */\n public static async downloadBriefcase(arg: RequestNewBriefcaseArg): Promise<LocalBriefcaseProps> {\n const briefcaseId = arg.briefcaseId ?? await this.acquireNewBriefcaseId({ deviceName: `${os.hostname()}:${os.type()}:${os.arch()}`, ...arg });\n const fileName = arg.fileName ?? this.getFileName({ ...arg, briefcaseId });\n\n if (IModelJsFs.existsSync(fileName))\n throw new IModelError(IModelStatus.FileAlreadyExists, `Briefcase \"${fileName}\" already exists`);\n\n const asOf = arg.asOf ?? IModelVersion.latest().toJSON();\n const changeset = await IModelHost[_hubAccess].getChangesetFromVersion({ ...arg, version: IModelVersion.fromJSON(asOf) });\n const checkpoint: CheckpointProps = { ...arg, changeset };\n\n try {\n await CheckpointManager.downloadCheckpoint({ localFile: fileName, checkpoint, onProgress: arg.onProgress });\n } catch (error: unknown) {\n const errorMessage = `Failed to download briefcase to ${fileName}, errorMessage: ${(error as Error).message}`;\n if (arg.accessToken && arg.briefcaseId === undefined) {\n Logger.logInfo(loggerCategory, `${errorMessage}, releasing the briefcaseId...`);\n await this.releaseBriefcase(arg.accessToken, { briefcaseId, iModelId: arg.iModelId });\n }\n if (IModelJsFs.existsSync(fileName)) {\n if (arg.accessToken && arg.briefcaseId === undefined)\n Logger.logTrace(loggerCategory, `Deleting the file: ${fileName}...`);\n else\n Logger.logInfo(loggerCategory, `${errorMessage}, deleting the file...`);\n try {\n IModelJsFs.unlinkSync(fileName);\n Logger.logInfo(loggerCategory, `Deleted ${fileName}`);\n } catch (deleteError: unknown) {\n Logger.logWarning(loggerCategory, `Failed to delete ${fileName}. errorMessage: ${(deleteError as Error).message}`);\n }\n }\n throw error;\n }\n\n const fileSize = IModelJsFs.lstatSync(fileName)?.size ?? 0;\n const response: LocalBriefcaseProps = {\n fileName,\n briefcaseId,\n iModelId: arg.iModelId,\n iTwinId: arg.iTwinId,\n changeset: checkpoint.changeset,\n fileSize,\n };\n\n // now open the downloaded checkpoint and reset its BriefcaseId\n const nativeDb = new IModelNative.platform.DgnDb();\n try {\n nativeDb.openIModel(fileName, OpenMode.ReadWrite);\n } catch (err: any) {\n throw new IModelError(err.errorNumber, `Could not open downloaded briefcase for write access: ${fileName}, err=${err.message}`);\n }\n try {\n nativeDb.enableWalMode(); // local briefcases should use WAL journal mode\n nativeDb.resetBriefcaseId(briefcaseId);\n if (nativeDb.getCurrentChangeset().id !== checkpoint.changeset.id)\n throw new IModelError(IModelStatus.InvalidId, `Downloaded briefcase has wrong changesetId: ${fileName}`);\n } finally {\n nativeDb.saveChanges();\n nativeDb.closeFile();\n }\n return response;\n }\n\n /** Deletes change sets of an iModel from local disk\n * @internal\n */\n public static deleteChangeSetsFromLocalDisk(iModelId: string) {\n const changesetsPath = BriefcaseManager.getChangeSetsPath(iModelId);\n BriefcaseManager.deleteFolderAndContents(changesetsPath);\n }\n\n /** Releases a briefcaseId from iModelHub. After this call it is illegal to generate changesets for the released briefcaseId.\n * @note generally, this method should not be called directly. Instead use [[deleteBriefcaseFiles]].\n * @see deleteBriefcaseFiles\n */\n public static async releaseBriefcase(accessToken: AccessToken, briefcase: BriefcaseProps): Promise<void> {\n if (this.isValidBriefcaseId(briefcase.briefcaseId))\n return IModelHost[_hubAccess].releaseBriefcase({ accessToken, iModelId: briefcase.iModelId, briefcaseId: briefcase.briefcaseId });\n }\n\n /**\n * Delete and clean up a briefcase and all of its associated files. First, this method opens the supplied filename to determine its briefcaseId.\n * Then, if a requestContext is supplied, it releases a BriefcaseId from iModelHub. Finally it deletes the local briefcase file and\n * associated files (that is, all files in the same directory that start with the briefcase name).\n * @param filePath the full file name of the Briefcase to delete\n * @param accessToken for releasing the briefcaseId\n */\n public static async deleteBriefcaseFiles(filePath: LocalFileName, accessToken?: AccessToken): Promise<void> {\n try {\n const db = IModelDb.openDgnDb({ path: filePath }, OpenMode.Readonly);\n const briefcase: BriefcaseProps = {\n iModelId: db.getIModelId(),\n briefcaseId: db.getBriefcaseId(),\n };\n db.closeFile();\n\n if (accessToken) {\n if (this.isValidBriefcaseId(briefcase.briefcaseId)) {\n await BriefcaseManager.releaseBriefcase(accessToken, briefcase);\n }\n }\n } catch { }\n\n // first try to delete the briefcase file\n try {\n if (IModelJsFs.existsSync(filePath))\n IModelJsFs.unlinkSync(filePath);\n } catch (err) {\n throw new IModelError(IModelStatus.BadRequest, `cannot delete briefcase file ${String(err)}`);\n }\n\n // next, delete all files that start with the briefcase's filePath (e.g. \"a.bim-locks\", \"a.bim-journal\", etc.)\n try {\n const dirName = path.dirname(filePath);\n const fileName = path.basename(filePath);\n const files = IModelJsFs.readdirSync(dirName);\n for (const file of files) {\n if (file.startsWith(fileName))\n this.deleteFile(path.join(dirName, file)); // don't throw on error\n }\n } catch { }\n }\n\n /** Deletes a file\n * - Does not throw any error, but logs it instead\n * - Returns true if the delete was successful\n */\n private static deleteFile(pathname: LocalFileName): boolean {\n try {\n IModelJsFs.unlinkSync(pathname);\n } catch (error) {\n Logger.logError(loggerCategory, `Cannot delete file ${pathname}, ${String(error)}`);\n return false;\n }\n return true;\n }\n\n /** Deletes a folder, checking if it's empty\n * - Does not throw any error, but logs it instead\n * - Returns true if the delete was successful\n */\n private static deleteFolderIfEmpty(folderPathname: LocalDirName): boolean {\n try {\n const files = IModelJsFs.readdirSync(folderPathname);\n if (files.length > 0)\n return false;\n\n IModelJsFs.rmdirSync(folderPathname);\n } catch {\n Logger.logError(loggerCategory, `Cannot delete folder: ${folderPathname}`);\n return false;\n }\n return true;\n }\n\n /** Deletes the contents of a folder, but not the folder itself\n * - Does not throw any errors, but logs them.\n * - returns true if the delete was successful.\n */\n private static deleteFolderContents(folderPathname: LocalDirName): boolean {\n if (!IModelJsFs.existsSync(folderPathname))\n return false;\n\n let status = true;\n const files = IModelJsFs.readdirSync(folderPathname);\n for (const file of files) {\n const curPath = path.join(folderPathname, file);\n const locStatus = (IModelJsFs.lstatSync(curPath)?.isDirectory) ? BriefcaseManager.deleteFolderAndContents(curPath) : BriefcaseManager.deleteFile(curPath);\n if (!locStatus)\n status = false;\n }\n return status;\n }\n\n /** Download all the changesets in the specified range.\n * @beta\n */\n public static async downloadChangesets(arg: DownloadChangesetRangeArg): Promise<ChangesetFileProps[]> {\n return IModelHost[_hubAccess].downloadChangesets(arg);\n }\n\n /** Download a single changeset.\n * @beta\n */\n public static async downloadChangeset(arg: DownloadChangesetArg): Promise<ChangesetFileProps> {\n return IModelHost[_hubAccess].downloadChangeset(arg);\n }\n\n /** Query the hub for the properties for a ChangesetIndex or ChangesetId */\n public static async queryChangeset(arg: { iModelId: GuidString, changeset: ChangesetIndexOrId }): Promise<ChangesetProps> {\n return IModelHost[_hubAccess].queryChangeset({ ...arg, accessToken: await IModelHost.getAccessToken() });\n }\n\n /** Query the hub for an array of changeset properties given a ChangesetRange */\n public static async queryChangesets(arg: { iModelId: GuidString, range: ChangesetRange }): Promise<ChangesetProps[]> {\n return IModelHost[_hubAccess].queryChangesets({ ...arg, accessToken: await IModelHost.getAccessToken() });\n }\n\n /** Query the hub for the ChangesetProps of the most recent changeset */\n public static async getLatestChangeset(arg: { iModelId: GuidString }): Promise<ChangesetProps> {\n return IModelHost[_hubAccess].getLatestChangeset({ ...arg, accessToken: await IModelHost.getAccessToken() });\n }\n\n /** Query the Id of an iModel by name.\n * @param arg Identifies the iModel of interest\n * @returns the Id of the corresponding iModel, or `undefined` if no such iModel exists.\n */\n public static async queryIModelByName(arg: IModelNameArg): Promise<GuidString | undefined> {\n return IModelHost[_hubAccess].queryIModelByName(arg);\n }\n\n /** Deletes a folder and all it's contents.\n * - Does not throw any errors, but logs them.\n * - returns true if the delete was successful.\n */\n private static deleteFolderAndContents(folderPathname: LocalDirName): boolean {\n if (!IModelJsFs.existsSync(folderPathname))\n return true;\n\n let status = false;\n status = BriefcaseManager.deleteFolderContents(folderPathname);\n if (!status)\n return false;\n\n status = BriefcaseManager.deleteFolderIfEmpty(folderPathname);\n return status;\n }\n\n private static async applySingleChangeset(db: IModelDb, changesetFile: ChangesetFileProps, fastForward: boolean) {\n if (changesetFile.changesType === ChangesetType.Schema || changesetFile.changesType === ChangesetType.SchemaSync)\n db.clearCaches(); // for schema changesets, statement caches may become invalid. Do this *before* applying, in case db needs to be closed (open statements hold db open.)\n\n db[_nativeDb].applyChangeset(changesetFile, fastForward);\n db.changeset = db[_nativeDb].getCurrentChangeset();\n\n // we're done with this changeset, delete it\n IModelJsFs.removeSync(changesetFile.pathname);\n }\n\n /** @internal */\n public static async revertTimelineChanges(db: IModelDb, arg: RevertChangesArgs): Promise<void> {\n if (!db.isOpen || db[_nativeDb].isReadonly())\n throw new IModelError(ChangeSetStatus.ApplyError, \"Briefcase must be open ReadWrite to revert timeline changes\");\n\n let currentIndex = db.changeset.index;\n if (currentIndex === undefined)\n currentIndex = (await IModelHost[_hubAccess].queryChangeset({ accessToken: arg.accessToken, iModelId: db.iModelId, changeset: { id: db.changeset.id } })).index;\n\n if (!arg.toIndex) {\n throw new IModelError(ChangeSetStatus.ApplyError, \"toIndex must be specified to revert changesets\");\n }\n if (arg.toIndex > currentIndex) {\n throw new IModelError(ChangeSetStatus.ApplyError, \"toIndex must be less than or equal to the current index\");\n }\n if (!db.holdsSchemaLock) {\n throw new IModelError(ChangeSetStatus.ApplyError, \"Cannot revert timeline changesets without holding a schema lock\");\n }\n\n // Download change sets\n const changesets = await IModelHost[_hubAccess].downloadChangesets({\n accessToken: arg.accessToken,\n iModelId: db.iModelId,\n range: { first: arg.toIndex, end: currentIndex },\n targetDir: BriefcaseManager.getChangeSetsPath(db.iModelId),\n progressCallback: arg.onProgress,\n });\n\n if (changesets.length === 0)\n return;\n\n changesets.reverse();\n db.clearCaches();\n\n const stopwatch = new StopWatch(`Reverting changes`, true);\n Logger.logInfo(loggerCategory, `Starting reverting timeline changes from ${arg.toIndex} to ${currentIndex}`);\n\n /**\n * Revert timeline changes from the current index to the specified index.\n * It does not change parent of the current changeset.\n * All changes during revert operation are stored in a new changeset.\n * Revert operation require schema lock as we do not acquire individual locks for each element.\n * Optionally schema changes can be skipped (required for schema sync case).\n */\n db[_nativeDb].revertTimelineChanges(changesets, arg.skipSchemaChanges ?? false);\n Logger.logInfo(loggerCategory, `Reverted timeline changes from ${arg.toIndex} to ${currentIndex} (${stopwatch.elapsedSeconds} seconds)`);\n\n changesets.forEach((changeset) => {\n IModelJsFs.removeSync(changeset.pathname);\n });\n db.notifyChangesetApplied();\n }\n\n /**\n * @internal\n * Pulls and applies changesets from the iModelHub to the specified IModelDb instance.\n *\n * This method downloads and applies all changesets required to bring the local briefcase up to the specified changeset index.\n * It supports both forward and reverse application of changesets, depending on the `toIndex` argument.\n * If there are pending local transactions and a reverse operation is requested, an error is thrown.\n * The method manages restore points for safe merging, handles local transaction reversal, applies each changeset in order,\n * and resumes or rebases local changes as appropriate for the type of database.\n *\n * @param db The IModelDb instance to which changesets will be applied. Must be open and writable.\n * @param arg The arguments for pulling changesets, including access token, target changeset index, and optional progress callback.\n * @throws IModelError If the briefcase is not open in read-write mode, if there are pending transactions when reversing, or if applying a changeset fails.\n * @returns A promise that resolves when all required changesets have been applied.\n */\n public static async pullAndApplyChangesets(db: IModelDb, arg: PullChangesArgs): Promise<void> {\n const nativeDb = db[_nativeDb];\n if (!db.isOpen || nativeDb.isReadonly()) // don't use db.isReadonly - we reopen the file writable just for this operation but db.isReadonly is still true\n throw new IModelError(ChangeSetStatus.ApplyError, \"Briefcase must be open ReadWrite to process change sets\");\n\n let currentIndex = db.changeset.index;\n if (currentIndex === undefined)\n currentIndex = (await IModelHost[_hubAccess].queryChangeset({ accessToken: arg.accessToken, iModelId: db.iModelId, changeset: { id: db.changeset.id } })).index;\n\n const reverse = (arg.toIndex && arg.toIndex < currentIndex) ? true : false;\n\n if (nativeDb.hasPendingTxns() && reverse) {\n throw new IModelError(ChangeSetStatus.ApplyError, \"Cannot reverse changesets when there are pending changes\");\n }\n\n // Download change sets\n const changesets = await IModelHost[_hubAccess].downloadChangesets({\n accessToken: arg.accessToken,\n iModelId: db.iModelId,\n range: { first: reverse ? arg.toIndex! + 1 : currentIndex + 1, end: reverse ? currentIndex : arg.toIndex }, // eslint-disable-line @typescript-eslint/no-non-null-assertion\n targetDir: BriefcaseManager.getChangeSetsPath(db.iModelId),\n progressCallback: arg.onProgress,\n });\n\n if (changesets.length === 0)\n return; // nothing to apply\n\n if (reverse)\n changesets.reverse();\n\n\n const briefcaseDb = db instanceof BriefcaseDb ? db : undefined;\n if (briefcaseDb) {\n if (briefcaseDb.txns.rebaser.isRebasing) {\n throw new IModelError(IModelStatus.BadRequest, \"Cannot pull and apply changeset while rebasing\");\n }\n if (briefcaseDb.txns.isIndirectChanges) {\n throw new IModelError(IModelStatus.BadRequest, \"Cannot pull and apply changeset while in an indirect change scope\");\n }\n }\n\n // create restore point if certain conditions are met\n if (briefcaseDb && briefcaseDb.txns.hasPendingTxns && !briefcaseDb.txns.hasPendingSchemaChanges && !reverse && !IModelHost.configuration?.disableRestorePointOnPullMerge) {\n Logger.logInfo(loggerCategory, `Creating restore point ${this.PULL_MERGE_RESTORE_POINT_NAME}`);\n await this.createRestorePoint(briefcaseDb, this.PULL_MERGE_RESTORE_POINT_NAME);\n }\n\n if (!reverse) {\n const reversedTxns = nativeDb.pullMergeReverseLocalChanges();\n Logger.logInfo(loggerCategory, `Reversed ${reversedTxns.length} local changes`);\n }\n\n // apply incoming changes\n for (const changeset of changesets) {\n const stopwatch = new StopWatch(`[${changeset.id}]`, true);\n Logger.logInfo(loggerCategory, `Starting application of changeset with id ${stopwatch.description}`);\n try {\n await this.applySingleChangeset(db, changeset, false);\n Logger.logInfo(loggerCategory, `Applied changeset with id ${stopwatch.description} (${stopwatch.elapsedSeconds} seconds)`);\n } catch (err: any) {\n if (err instanceof Error) {\n Logger.logError(loggerCategory, `Error applying changeset with id ${stopwatch.description}: ${err.message}`);\n }\n db.abandonChanges();\n throw err;\n }\n }\n if (!reverse) {\n if (briefcaseDb) {\n await briefcaseDb.txns.rebaser.resume();\n } else {\n // Only Briefcase has change management. Following is\n // for test related to standalone db with txn enabled.\n nativeDb.pullMergeRebaseBegin();\n let txnId = nativeDb.pullMergeRebaseNext();\n while (txnId) {\n nativeDb.pullMergeRebaseReinstateTxn();\n nativeDb.pullMergeRebaseUpdateTxn();\n txnId = nativeDb.pullMergeRebaseNext();\n }\n nativeDb.pullMergeRebaseEnd();\n if (!nativeDb.isReadonly) {\n nativeDb.saveChanges(\"Merge.\");\n }\n }\n\n if (briefcaseDb && this.containsRestorePoint(briefcaseDb, this.PULL_MERGE_RESTORE_POINT_NAME)) {\n Logger.logInfo(loggerCategory, `Dropping restore point ${this.PULL_MERGE_RESTORE_POINT_NAME}`);\n this.dropRestorePoint(briefcaseDb, this.PULL_MERGE_RESTORE_POINT_NAME);\n }\n }\n // notify listeners\n db.notifyChangesetApplied();\n }\n\n /**\n * @internal\n * Creates a restore point for the specified briefcase database.\n *\n * @param db - The {@link BriefcaseDb} instance for which to create the restore point.\n * @param name - The unique name for the restore point. Must be a non-empty string.\n * @returns A promise that resolves to the created stash object representing the restore point.\n */\n public static async createRestorePoint(db: BriefcaseDb, name: string): Promise<StashProps> {\n Logger.logTrace(loggerCategory, `Creating restore point ${name}`);\n this.dropRestorePoint(db, name);\n\n const stash = await StashManager.stash({ db, description: this.makeRestorePointKey(name) });\n db[_nativeDb].saveLocalValue(this.makeRestorePointKey(name), stash.id);\n db.saveChanges(\"Create restore point\");\n Logger.logTrace(loggerCategory, `Created restore point ${name}`, () => stash);\n return stash;\n }\n\n /**\n * @internal\n * Drops a previously created restore point from the specified briefcase database.\n *\n * @param db - The {@link BriefcaseDb} instance from which to drop the restore point.\n * @param name - The name of the restore point to be dropped. Must be a non-empty string.\n */\n public static dropRestorePoint(db: BriefcaseDb, name: string): void {\n Logger.logTrace(loggerCategory, `Dropping restore point ${name}`);\n\n const restorePointId = db[_nativeDb].queryLocalValue(this.makeRestorePointKey(name));\n if (restorePointId) {\n StashManager.dropStash({ db, stash: restorePointId });\n db[_nativeDb].deleteLocalValue(this.makeRestorePointKey(name));\n db.saveChanges(\"Drop restore point\");\n Logger.logTrace(loggerCategory, `Dropped restore point ${name}`);\n }\n\n }\n\n /**\n * @internal\n * Checks if a restore point with the specified name exists in the given briefcase database.\n *\n * @param db - The {@link BriefcaseDb} instance to search within.\n * @param name - The name of the restore point to check for existence.\n * @returns `true` if the restore point exists and its stash is present; otherwise, `false`.\n */\n public static containsRestorePoint(db: BriefcaseDb, name: string): boolean {\n Logger.logTrace(loggerCategory, `Checking if restore point ${name} exists`);\n const key = this.makeRestorePointKey(name);\n const restorePointId = db[_nativeDb].queryLocalValue(key);\n if (!restorePointId) {\n return false;\n }\n\n const stash = StashManager.tryGetStash({ db, stash: restorePointId });\n if (!stash) {\n Logger.logTrace(loggerCategory, `Restore point ${name} does not exist. Deleting ${key}`);\n db[_nativeDb].deleteLocalValue(key);\n return false;\n }\n return true;\n }\n\n private static makeRestorePointKey(name: string): string {\n if (name.length === 0) {\n throw new Error(\"Invalid restore point name\");\n }\n return `restore_point/${name}`;\n }\n\n /**\n * @internal\n * Restores the state of a briefcase database to a previously saved restore point.\n *\n * @param db - The {@link BriefcaseDb} instance to restore.\n * @param name - The name of the restore point to apply.\n */\n public static async restorePoint(db: BriefcaseDb, name: string): Promise<void> {\n Logger.logTrace(loggerCategory, `Restoring to restore point ${name}`);\n const restorePointId = db[_nativeDb].queryLocalValue(this.makeRestorePointKey(name));\n if (!restorePointId) {\n throw new Error(`Restore point not found: ${name}`);\n }\n\n await StashManager.restore({ db, stash: restorePointId });\n Logger.logTrace(loggerCategory, `Restored to restore point ${name}`);\n this.dropRestorePoint(db, name);\n }\n\n /** create a changeset from the current changes, and push it to iModelHub */\n private static async pushChanges(db: BriefcaseDb, arg: PushChangesArgs): Promise<void> {\n if (db.txns.rebaser.isRebasing) {\n throw new IModelError(IModelStatus.BadRequest, \"Cannot push changeset while rebasing\");\n }\n if (db.txns.isIndirectChanges) {\n throw new IModelError(IModelStatus.BadRequest, \"Cannot push changeset while in an indirect change scope\");\n }\n\n const changesetProps = db[_nativeDb].startCreateChangeset() as ChangesetFileProps;\n changesetProps.briefcaseId = db.briefcaseId;\n changesetProps.description = arg.description;\n const fileSize = IModelJsFs.lstatSync(changesetProps.pathname)?.size;\n if (!fileSize) // either undefined or 0 means error\n throw new IModelError(IModelStatus.NoContent, \"error creating changeset\");\n\n changesetProps.size = fileSize;\n const id = IModelNative.platform.DgnDb.computeChangesetId(changesetProps);\n if (id !== changesetProps.id) {\n throw new IModelError(DbResult.BE_SQLITE_ERROR_InvalidChangeSetVersion, `Changeset id ${changesetProps.id} does not match computed id ${id}.`);\n }\n\n let retryCount = arg.pushRetryCount ?? 3;\n while (true) {\n try {\n const accessToken = await IModelHost.getAccessToken();\n const index = await IModelHost[_hubAccess].pushChangeset({ accessToken, iModelId: db.iModelId, changesetProps });\n db[_nativeDb].completeCreateChangeset({ index });\n db.changeset = db[_nativeDb].getCurrentChangeset();\n if (!arg.retainLocks)\n await db.locks[_releaseAllLocks]();\n\n return;\n } catch (err: any) {\n const shouldRetry = () => {\n if (retryCount-- <= 0)\n return false;\n switch (err.errorNumber) {\n case IModelHubStatus.AnotherUserPushing:\n case IModelHubStatus.DatabaseTemporarilyLocked:\n case IModelHubStatus.OperationFailed:\n return true;\n }\n return false;\n };\n\n if (!shouldRetry()) {\n db[_nativeDb].abandonCreateChangeset();\n throw err;\n }\n } finally {\n IModelJsFs.removeSync(changesetProps.pathname);\n }\n }\n }\n\n /** Pull/merge (if necessary), then push all local changes as a changeset. Called by [[BriefcaseDb.pushChanges]]\n * @internal\n */\n public static async pullMergePush(db: BriefcaseDb, arg: PushChangesArgs): Promise<void> {\n let retryCount = arg.mergeRetryCount ?? 5;\n while (true) {\n try {\n await BriefcaseManager.pullAndApplyChangesets(db, arg);\n if (!db.skipSyncSchemasOnPullAndPush)\n await SchemaSync.pull(db);\n // pullAndApply rebase changes and might remove redundant changes in local briefcase\n // this mean hasPendingTxns was true before but now after pullAndApply it might be false\n if (!db[_nativeDb].hasPendingTxns())\n return;\n\n await BriefcaseManager.pushChanges(db, arg);\n } catch (err: any) {\n if (retryCount-- <= 0 || err.errorNumber !== IModelHubStatus.PullIsRequired)\n throw (err);\n await (arg.mergeRetryDelay ?? BeDuration.fromSeconds(3)).wait();\n }\n }\n }\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BriefcaseManager.js","sourceRoot":"","sources":["../../src/BriefcaseManager.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,qCAAqC;AAErC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EACQ,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAc,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAY,SAAS,EACrI,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACQ,gBAAgB,EAA0G,aAAa,EAAE,WAAW,EAAE,aAAa,GAEjL,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAqC,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAY,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE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B,IAAI,UAAU,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC,WAAW,KAAK,eAAe,CAAC,cAAc;oBACzE,MAAM,CAAC,GAAG,CAAC,CAAC;gBACd,MAAM,CAAC,GAAG,CAAC,eAAe,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAClE,CAAC;QACH,CAAC;IACH,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 iModels\r\n */\r\n\r\n// cspell:ignore cset csets ecchanges\r\n\r\nimport * as path from \"node:path\";\r\nimport * as os from \"node:os\";\r\nimport {\r\n AccessToken, BeDuration, ChangeSetStatus, DbResult, GuidString, IModelHubStatus, IModelStatus, Logger, OpenMode, Optional, StopWatch\r\n} from \"@itwin/core-bentley\";\r\nimport {\r\n BriefcaseId, BriefcaseIdValue, BriefcaseProps, ChangesetFileProps, ChangesetIndex, ChangesetIndexOrId, ChangesetProps, ChangesetRange, ChangesetType, IModelError, IModelVersion, LocalBriefcaseProps,\r\n LocalDirName, LocalFileName, RequestNewBriefcaseProps,\r\n} from \"@itwin/core-common\";\r\nimport { AcquireNewBriefcaseIdArg, DownloadChangesetArg, DownloadChangesetRangeArg, IModelNameArg } from \"./BackendHubAccess\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { CheckpointManager, CheckpointProps, ProgressFunction } from \"./CheckpointManager\";\r\nimport { BriefcaseDb, IModelDb, TokenArg } from \"./IModelDb\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { IModelJsFs } from \"./IModelJsFs\";\r\nimport { SchemaSync } from \"./SchemaSync\";\r\nimport { _hubAccess, _nativeDb, _releaseAllLocks } from \"./internal/Symbols\";\r\nimport { IModelNative } from \"./internal/NativePlatform\";\r\nimport { StashManager, StashProps } from \"./StashManager\";\r\n\r\nconst loggerCategory = BackendLoggerCategory.IModelDb;\r\n\r\n/** The argument for [[BriefcaseManager.downloadBriefcase]]\r\n * @public\r\n*/\r\nexport interface RequestNewBriefcaseArg extends TokenArg, RequestNewBriefcaseProps {\r\n /** If present, a function called periodically during the download to indicate progress.\r\n * @note return non-zero from this function to abort the download.\r\n */\r\n onProgress?: ProgressFunction;\r\n}\r\n\r\n/**\r\n * Parameters for pushing changesets to iModelHub\r\n * @public\r\n */\r\nexport interface PushChangesArgs extends TokenArg {\r\n /** A description of the changes. This is visible on the iModel's timeline. */\r\n description: string;\r\n /** if present, the locks are retained after the operation. Otherwise, *all* locks are released after the changeset is successfully pushed. */\r\n retainLocks?: true;\r\n /** number of times to retry pull/merge if other users are pushing at the same time. Default is 5 */\r\n mergeRetryCount?: number;\r\n /** delay to wait between pull/merge retry attempts. Default is 3 seconds */\r\n mergeRetryDelay?: BeDuration;\r\n /** the number of time to attempt to retry to push the changeset upon failure. Default is 3 */\r\n pushRetryCount?: number;\r\n /** The delay to wait between retry attempts on failed pushes. Default is 3 seconds. */\r\n pushRetryDelay?: BeDuration;\r\n /**\r\n * (unused)\r\n * @deprecated in 5.1.8 - will not be removed until after 2026-10-01. Not used by BriefcaseManager. Caller should remove this flag.\r\n * @internal\r\n */\r\n noFastForward?: true;\r\n}\r\n\r\n/**\r\n * Specifies a specific index for pulling changes.\r\n * @public\r\n */\r\nexport interface ToChangesetArgs extends TokenArg {\r\n /** The last ChangesetIndex to pull. If not present, pull *all* newer changesets. */\r\n toIndex?: ChangesetIndex;\r\n}\r\n\r\n/** Arguments for [[BriefcaseManager.pullAndApplyChangesets]]\r\n * @public\r\n */\r\nexport type PullChangesArgs = ToChangesetArgs & {\r\n /** If present, a function called periodically during the download to indicate progress.\r\n * @note return non-zero from this function to abort the download.\r\n */\r\n onProgress?: ProgressFunction;\r\n /**\r\n * (unused)\r\n * @deprecated in 5.1.8 - will not be removed until after 2026-10-01. Not used by BriefcaseManager. Caller should remove this flag.\r\n * @internal\r\n */\r\n noFastForward?: true;\r\n};\r\n\r\n/** Arguments for [[BriefcaseManager.revertTimelineChanges]]\r\n * @public\r\n */\r\nexport type RevertChangesArgs = Optional<PushChangesArgs, \"description\"> & {\r\n /** If present, a function called periodically during the download to indicate progress.\r\n * @note return non-zero from this function to abort the download.\r\n */\r\n onProgress?: ProgressFunction;\r\n /** The index of the changeset to revert to */\r\n toIndex: ChangesetIndex;\r\n /** If present, schema changes are skipped during the revert operation. */\r\n skipSchemaChanges?: true;\r\n};\r\n\r\n/** Manages downloading Briefcases and downloading and uploading changesets.\r\n * @public\r\n */\r\nexport class BriefcaseManager {\r\n /** @internal */\r\n public static readonly PULL_MERGE_RESTORE_POINT_NAME = \"$pull_merge_restore_point\";\r\n\r\n /** Get the local path of the folder storing files that are associated with an imodel */\r\n public static getIModelPath(iModelId: GuidString): LocalDirName { return path.join(this._cacheDir, iModelId); }\r\n\r\n /** @internal */\r\n public static getChangeSetsPath(iModelId: GuidString): LocalDirName { return path.join(this.getIModelPath(iModelId), \"changesets\"); }\r\n\r\n /** @internal */\r\n public static getChangeCachePathName(iModelId: GuidString): LocalFileName { return path.join(this.getIModelPath(iModelId), iModelId.concat(\".bim.ecchanges\")); }\r\n\r\n /** @internal */\r\n public static getChangedElementsPathName(iModelId: GuidString): LocalFileName { return path.join(this.getIModelPath(iModelId), iModelId.concat(\".bim.elems\")); }\r\n\r\n private static _briefcaseSubDir = \"briefcases\";\r\n /** Get the local path of the folder storing briefcases associated with the specified iModel. */\r\n public static getBriefcaseBasePath(iModelId: GuidString): LocalDirName {\r\n return path.join(this.getIModelPath(iModelId), this._briefcaseSubDir);\r\n }\r\n\r\n /** Get the name of the local file that holds, or will hold, a local briefcase in the briefcase cache.\r\n * @note The briefcase cache is a local directory established in the call to [[BriefcaseManager.initialize]].\r\n * @param briefcase the iModelId and BriefcaseId for the filename\r\n * @see getIModelPath\r\n */\r\n public static getFileName(briefcase: BriefcaseProps): LocalFileName {\r\n return path.join(this.getBriefcaseBasePath(briefcase.iModelId), `${briefcase.briefcaseId}.bim`);\r\n }\r\n\r\n private static setupCacheDir(cacheRootDir: LocalDirName) {\r\n this._cacheDir = cacheRootDir;\r\n IModelJsFs.recursiveMkDirSync(this._cacheDir);\r\n }\r\n\r\n private static _initialized?: boolean;\r\n /** Initialize BriefcaseManager\r\n * @param cacheRootDir The root directory for storing a cache of downloaded briefcase files on the local computer.\r\n * Briefcases are stored relative to this path in sub-folders organized by IModelId.\r\n * @note It is perfectly valid for applications to store briefcases in locations they manage, outside of `cacheRootDir`.\r\n */\r\n public static initialize(cacheRootDir: LocalDirName) {\r\n if (this._initialized)\r\n return;\r\n this.setupCacheDir(cacheRootDir);\r\n IModelHost.onBeforeShutdown.addOnce(() => this.finalize());\r\n this._initialized = true;\r\n }\r\n\r\n private static finalize() {\r\n this._initialized = false;\r\n }\r\n\r\n /** Get a list of the local briefcase held in the briefcase cache, optionally for a single iModelId\r\n * @param iModelId if present, only briefcases for this iModelId are returned, otherwise all briefcases for all\r\n * iModels in the briefcase cache are returned.\r\n * @note usually there should only be one briefcase per iModel.\r\n */\r\n public static getCachedBriefcases(iModelId?: GuidString): LocalBriefcaseProps[] {\r\n const briefcaseList: LocalBriefcaseProps[] = [];\r\n const iModelDirs = IModelJsFs.readdirSync(this._cacheDir);\r\n for (const iModelDir of iModelDirs) {\r\n if (iModelId && iModelId !== iModelDir)\r\n continue;\r\n const bcPath = path.join(this._cacheDir, iModelDir, this._briefcaseSubDir);\r\n try {\r\n if (!IModelJsFs.lstatSync(bcPath)?.isDirectory)\r\n continue;\r\n } catch {\r\n continue;\r\n }\r\n\r\n const briefcases = IModelJsFs.readdirSync(bcPath);\r\n for (const briefcaseName of briefcases) {\r\n if (briefcaseName.endsWith(\".bim\")) {\r\n try {\r\n const fileName = path.join(bcPath, briefcaseName);\r\n const fileSize = IModelJsFs.lstatSync(fileName)?.size ?? 0;\r\n const db = IModelDb.openDgnDb({ path: fileName }, OpenMode.Readonly);\r\n briefcaseList.push({ fileName, iTwinId: db.getITwinId(), iModelId: db.getIModelId(), briefcaseId: db.getBriefcaseId(), changeset: db.getCurrentChangeset(), fileSize });\r\n db.closeFile();\r\n } catch { }\r\n }\r\n }\r\n }\r\n return briefcaseList;\r\n }\r\n\r\n private static _cacheDir: LocalDirName;\r\n /** Get the root directory for the briefcase cache */\r\n public static get cacheDir(): LocalDirName { return this._cacheDir; }\r\n\r\n /** Determine whether the supplied briefcaseId is in the range of assigned BriefcaseIds issued by iModelHub\r\n * @note this does check whether the id was actually acquired by the caller.\r\n */\r\n public static isValidBriefcaseId(id: BriefcaseId) {\r\n return id >= BriefcaseIdValue.FirstValid && id <= BriefcaseIdValue.LastValid;\r\n }\r\n\r\n /** Acquire a new briefcaseId from iModelHub for the supplied iModelId\r\n * @note usually there should only be one briefcase per iModel per user. If a single user acquires more than one briefcaseId,\r\n * it's a good idea to supply different aliases for each of them.\r\n */\r\n public static async acquireNewBriefcaseId(arg: AcquireNewBriefcaseIdArg): Promise<BriefcaseId> {\r\n return IModelHost[_hubAccess].acquireNewBriefcaseId(arg);\r\n }\r\n\r\n /**\r\n * Download a new briefcase from iModelHub for the supplied iModelId.\r\n *\r\n * Briefcases are local files holding a copy of an iModel.\r\n * Briefcases may either be specific to an individual user (so that it can be modified to create changesets), or it can be readonly so it can accept but not create changesets.\r\n * Every briefcase internally holds its [[BriefcaseId]]. Writeable briefcases have a `BriefcaseId` \"assigned\" to them by iModelHub. No two users will ever have the same BriefcaseId.\r\n * Readonly briefcases are \"unassigned\" with the special value [[BriefcaseId.Unassigned]].\r\n *\r\n * Typically a given user will have only one briefcase on their machine for a given iModelId. Rarely, it may be necessary to use more than one\r\n * briefcase to make isolated independent sets of changes, but that is exceedingly complicated and rare.\r\n *\r\n * Callers of this method may supply a BriefcaseId, or if none is supplied, a new one is acquired from iModelHub.\r\n *\r\n * @param arg The arguments that specify the briefcase file to be downloaded.\r\n * @returns The properties of the local briefcase in a Promise that is resolved after the briefcase is fully downloaded and the briefcase file is ready for use via [BriefcaseDb.open]($backend).\r\n * @note The location of the local file to hold the briefcase is arbitrary and may be any valid *local* path on your machine. If you don't supply\r\n * a filename, the local briefcase cache is used by creating a file with the briefcaseId as its name in the `briefcases` folder below the folder named\r\n * for the IModelId.\r\n * @note *It is invalid to edit briefcases on a shared network drive* and that is a sure way to corrupt your briefcase (see https://www.sqlite.org/howtocorrupt.html)\r\n */\r\n public static async downloadBriefcase(arg: RequestNewBriefcaseArg): Promise<LocalBriefcaseProps> {\r\n const briefcaseId = arg.briefcaseId ?? await this.acquireNewBriefcaseId({ deviceName: `${os.hostname()}:${os.type()}:${os.arch()}`, ...arg });\r\n const fileName = arg.fileName ?? this.getFileName({ ...arg, briefcaseId });\r\n\r\n if (IModelJsFs.existsSync(fileName))\r\n throw new IModelError(IModelStatus.FileAlreadyExists, `Briefcase \"${fileName}\" already exists`);\r\n\r\n const asOf = arg.asOf ?? IModelVersion.latest().toJSON();\r\n const changeset = await IModelHost[_hubAccess].getChangesetFromVersion({ ...arg, version: IModelVersion.fromJSON(asOf) });\r\n const checkpoint: CheckpointProps = { ...arg, changeset };\r\n\r\n try {\r\n await CheckpointManager.downloadCheckpoint({ localFile: fileName, checkpoint, onProgress: arg.onProgress });\r\n } catch (error: unknown) {\r\n const errorMessage = `Failed to download briefcase to ${fileName}, errorMessage: ${(error as Error).message}`;\r\n if (arg.accessToken && arg.briefcaseId === undefined) {\r\n Logger.logInfo(loggerCategory, `${errorMessage}, releasing the briefcaseId...`);\r\n await this.releaseBriefcase(arg.accessToken, { briefcaseId, iModelId: arg.iModelId });\r\n }\r\n if (IModelJsFs.existsSync(fileName)) {\r\n if (arg.accessToken && arg.briefcaseId === undefined)\r\n Logger.logTrace(loggerCategory, `Deleting the file: ${fileName}...`);\r\n else\r\n Logger.logInfo(loggerCategory, `${errorMessage}, deleting the file...`);\r\n try {\r\n IModelJsFs.unlinkSync(fileName);\r\n Logger.logInfo(loggerCategory, `Deleted ${fileName}`);\r\n } catch (deleteError: unknown) {\r\n Logger.logWarning(loggerCategory, `Failed to delete ${fileName}. errorMessage: ${(deleteError as Error).message}`);\r\n }\r\n }\r\n throw error;\r\n }\r\n\r\n const fileSize = IModelJsFs.lstatSync(fileName)?.size ?? 0;\r\n const response: LocalBriefcaseProps = {\r\n fileName,\r\n briefcaseId,\r\n iModelId: arg.iModelId,\r\n iTwinId: arg.iTwinId,\r\n changeset: checkpoint.changeset,\r\n fileSize,\r\n };\r\n\r\n // now open the downloaded checkpoint and reset its BriefcaseId\r\n const nativeDb = new IModelNative.platform.DgnDb();\r\n try {\r\n nativeDb.openIModel(fileName, OpenMode.ReadWrite);\r\n } catch (err: any) {\r\n throw new IModelError(err.errorNumber, `Could not open downloaded briefcase for write access: ${fileName}, err=${err.message}`);\r\n }\r\n try {\r\n nativeDb.enableWalMode(); // local briefcases should use WAL journal mode\r\n nativeDb.resetBriefcaseId(briefcaseId);\r\n if (nativeDb.getCurrentChangeset().id !== checkpoint.changeset.id)\r\n throw new IModelError(IModelStatus.InvalidId, `Downloaded briefcase has wrong changesetId: ${fileName}`);\r\n } finally {\r\n nativeDb.saveChanges();\r\n nativeDb.closeFile();\r\n }\r\n return response;\r\n }\r\n\r\n /** Deletes change sets of an iModel from local disk\r\n * @internal\r\n */\r\n public static deleteChangeSetsFromLocalDisk(iModelId: string) {\r\n const changesetsPath = BriefcaseManager.getChangeSetsPath(iModelId);\r\n BriefcaseManager.deleteFolderAndContents(changesetsPath);\r\n }\r\n\r\n /** Releases a briefcaseId from iModelHub. After this call it is illegal to generate changesets for the released briefcaseId.\r\n * @note generally, this method should not be called directly. Instead use [[deleteBriefcaseFiles]].\r\n * @see deleteBriefcaseFiles\r\n */\r\n public static async releaseBriefcase(accessToken: AccessToken, briefcase: BriefcaseProps): Promise<void> {\r\n if (this.isValidBriefcaseId(briefcase.briefcaseId))\r\n return IModelHost[_hubAccess].releaseBriefcase({ accessToken, iModelId: briefcase.iModelId, briefcaseId: briefcase.briefcaseId });\r\n }\r\n\r\n /**\r\n * Delete and clean up a briefcase and all of its associated files. First, this method opens the supplied filename to determine its briefcaseId.\r\n * Then, if a requestContext is supplied, it releases a BriefcaseId from iModelHub. Finally it deletes the local briefcase file and\r\n * associated files (that is, all files in the same directory that start with the briefcase name).\r\n * @param filePath the full file name of the Briefcase to delete\r\n * @param accessToken for releasing the briefcaseId\r\n */\r\n public static async deleteBriefcaseFiles(filePath: LocalFileName, accessToken?: AccessToken): Promise<void> {\r\n try {\r\n const db = IModelDb.openDgnDb({ path: filePath }, OpenMode.Readonly);\r\n const briefcase: BriefcaseProps = {\r\n iModelId: db.getIModelId(),\r\n briefcaseId: db.getBriefcaseId(),\r\n };\r\n db.closeFile();\r\n\r\n if (accessToken) {\r\n if (this.isValidBriefcaseId(briefcase.briefcaseId)) {\r\n await BriefcaseManager.releaseBriefcase(accessToken, briefcase);\r\n }\r\n }\r\n } catch { }\r\n\r\n // first try to delete the briefcase file\r\n try {\r\n if (IModelJsFs.existsSync(filePath))\r\n IModelJsFs.unlinkSync(filePath);\r\n } catch (err) {\r\n throw new IModelError(IModelStatus.BadRequest, `cannot delete briefcase file ${String(err)}`);\r\n }\r\n\r\n // next, delete all files that start with the briefcase's filePath (e.g. \"a.bim-locks\", \"a.bim-journal\", etc.)\r\n try {\r\n const dirName = path.dirname(filePath);\r\n const fileName = path.basename(filePath);\r\n const files = IModelJsFs.readdirSync(dirName);\r\n for (const file of files) {\r\n if (file.startsWith(fileName))\r\n this.deleteFile(path.join(dirName, file)); // don't throw on error\r\n }\r\n } catch { }\r\n }\r\n\r\n /** Deletes a file\r\n * - Does not throw any error, but logs it instead\r\n * - Returns true if the delete was successful\r\n */\r\n private static deleteFile(pathname: LocalFileName): boolean {\r\n try {\r\n IModelJsFs.unlinkSync(pathname);\r\n } catch (error) {\r\n Logger.logError(loggerCategory, `Cannot delete file ${pathname}, ${String(error)}`);\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n /** Deletes a folder, checking if it's empty\r\n * - Does not throw any error, but logs it instead\r\n * - Returns true if the delete was successful\r\n */\r\n private static deleteFolderIfEmpty(folderPathname: LocalDirName): boolean {\r\n try {\r\n const files = IModelJsFs.readdirSync(folderPathname);\r\n if (files.length > 0)\r\n return false;\r\n\r\n IModelJsFs.rmdirSync(folderPathname);\r\n } catch {\r\n Logger.logError(loggerCategory, `Cannot delete folder: ${folderPathname}`);\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n /** Deletes the contents of a folder, but not the folder itself\r\n * - Does not throw any errors, but logs them.\r\n * - returns true if the delete was successful.\r\n */\r\n private static deleteFolderContents(folderPathname: LocalDirName): boolean {\r\n if (!IModelJsFs.existsSync(folderPathname))\r\n return false;\r\n\r\n let status = true;\r\n const files = IModelJsFs.readdirSync(folderPathname);\r\n for (const file of files) {\r\n const curPath = path.join(folderPathname, file);\r\n const locStatus = (IModelJsFs.lstatSync(curPath)?.isDirectory) ? BriefcaseManager.deleteFolderAndContents(curPath) : BriefcaseManager.deleteFile(curPath);\r\n if (!locStatus)\r\n status = false;\r\n }\r\n return status;\r\n }\r\n\r\n /** Download all the changesets in the specified range.\r\n * @beta\r\n */\r\n public static async downloadChangesets(arg: DownloadChangesetRangeArg): Promise<ChangesetFileProps[]> {\r\n return IModelHost[_hubAccess].downloadChangesets(arg);\r\n }\r\n\r\n /** Download a single changeset.\r\n * @beta\r\n */\r\n public static async downloadChangeset(arg: DownloadChangesetArg): Promise<ChangesetFileProps> {\r\n return IModelHost[_hubAccess].downloadChangeset(arg);\r\n }\r\n\r\n /** Query the hub for the properties for a ChangesetIndex or ChangesetId */\r\n public static async queryChangeset(arg: { iModelId: GuidString, changeset: ChangesetIndexOrId }): Promise<ChangesetProps> {\r\n return IModelHost[_hubAccess].queryChangeset({ ...arg, accessToken: await IModelHost.getAccessToken() });\r\n }\r\n\r\n /** Query the hub for an array of changeset properties given a ChangesetRange */\r\n public static async queryChangesets(arg: { iModelId: GuidString, range: ChangesetRange }): Promise<ChangesetProps[]> {\r\n return IModelHost[_hubAccess].queryChangesets({ ...arg, accessToken: await IModelHost.getAccessToken() });\r\n }\r\n\r\n /** Query the hub for the ChangesetProps of the most recent changeset */\r\n public static async getLatestChangeset(arg: { iModelId: GuidString }): Promise<ChangesetProps> {\r\n return IModelHost[_hubAccess].getLatestChangeset({ ...arg, accessToken: await IModelHost.getAccessToken() });\r\n }\r\n\r\n /** Query the Id of an iModel by name.\r\n * @param arg Identifies the iModel of interest\r\n * @returns the Id of the corresponding iModel, or `undefined` if no such iModel exists.\r\n */\r\n public static async queryIModelByName(arg: IModelNameArg): Promise<GuidString | undefined> {\r\n return IModelHost[_hubAccess].queryIModelByName(arg);\r\n }\r\n\r\n /** Deletes a folder and all it's contents.\r\n * - Does not throw any errors, but logs them.\r\n * - returns true if the delete was successful.\r\n */\r\n private static deleteFolderAndContents(folderPathname: LocalDirName): boolean {\r\n if (!IModelJsFs.existsSync(folderPathname))\r\n return true;\r\n\r\n let status = false;\r\n status = BriefcaseManager.deleteFolderContents(folderPathname);\r\n if (!status)\r\n return false;\r\n\r\n status = BriefcaseManager.deleteFolderIfEmpty(folderPathname);\r\n return status;\r\n }\r\n\r\n private static async applySingleChangeset(db: IModelDb, changesetFile: ChangesetFileProps, fastForward: boolean) {\r\n if (changesetFile.changesType === ChangesetType.Schema || changesetFile.changesType === ChangesetType.SchemaSync)\r\n db.clearCaches(); // for schema changesets, statement caches may become invalid. Do this *before* applying, in case db needs to be closed (open statements hold db open.)\r\n\r\n db[_nativeDb].applyChangeset(changesetFile, fastForward);\r\n db.changeset = db[_nativeDb].getCurrentChangeset();\r\n\r\n // we're done with this changeset, delete it\r\n IModelJsFs.removeSync(changesetFile.pathname);\r\n }\r\n\r\n /** @internal */\r\n public static async revertTimelineChanges(db: IModelDb, arg: RevertChangesArgs): Promise<void> {\r\n if (!db.isOpen || db[_nativeDb].isReadonly())\r\n throw new IModelError(ChangeSetStatus.ApplyError, \"Briefcase must be open ReadWrite to revert timeline changes\");\r\n\r\n let currentIndex = db.changeset.index;\r\n if (currentIndex === undefined)\r\n currentIndex = (await IModelHost[_hubAccess].queryChangeset({ accessToken: arg.accessToken, iModelId: db.iModelId, changeset: { id: db.changeset.id } })).index;\r\n\r\n if (!arg.toIndex) {\r\n throw new IModelError(ChangeSetStatus.ApplyError, \"toIndex must be specified to revert changesets\");\r\n }\r\n if (arg.toIndex > currentIndex) {\r\n throw new IModelError(ChangeSetStatus.ApplyError, \"toIndex must be less than or equal to the current index\");\r\n }\r\n if (!db.holdsSchemaLock) {\r\n throw new IModelError(ChangeSetStatus.ApplyError, \"Cannot revert timeline changesets without holding a schema lock\");\r\n }\r\n\r\n // Download change sets\r\n const changesets = await IModelHost[_hubAccess].downloadChangesets({\r\n accessToken: arg.accessToken,\r\n iModelId: db.iModelId,\r\n range: { first: arg.toIndex, end: currentIndex },\r\n targetDir: BriefcaseManager.getChangeSetsPath(db.iModelId),\r\n progressCallback: arg.onProgress,\r\n });\r\n\r\n if (changesets.length === 0)\r\n return;\r\n\r\n changesets.reverse();\r\n db.clearCaches();\r\n\r\n const stopwatch = new StopWatch(`Reverting changes`, true);\r\n Logger.logInfo(loggerCategory, `Starting reverting timeline changes from ${arg.toIndex} to ${currentIndex}`);\r\n\r\n /**\r\n * Revert timeline changes from the current index to the specified index.\r\n * It does not change parent of the current changeset.\r\n * All changes during revert operation are stored in a new changeset.\r\n * Revert operation require schema lock as we do not acquire individual locks for each element.\r\n * Optionally schema changes can be skipped (required for schema sync case).\r\n */\r\n db[_nativeDb].revertTimelineChanges(changesets, arg.skipSchemaChanges ?? false);\r\n Logger.logInfo(loggerCategory, `Reverted timeline changes from ${arg.toIndex} to ${currentIndex} (${stopwatch.elapsedSeconds} seconds)`);\r\n\r\n changesets.forEach((changeset) => {\r\n IModelJsFs.removeSync(changeset.pathname);\r\n });\r\n db.notifyChangesetApplied();\r\n }\r\n\r\n /**\r\n * @internal\r\n * Pulls and applies changesets from the iModelHub to the specified IModelDb instance.\r\n *\r\n * This method downloads and applies all changesets required to bring the local briefcase up to the specified changeset index.\r\n * It supports both forward and reverse application of changesets, depending on the `toIndex` argument.\r\n * If there are pending local transactions and a reverse operation is requested, an error is thrown.\r\n * The method manages restore points for safe merging, handles local transaction reversal, applies each changeset in order,\r\n * and resumes or rebases local changes as appropriate for the type of database.\r\n *\r\n * @param db The IModelDb instance to which changesets will be applied. Must be open and writable.\r\n * @param arg The arguments for pulling changesets, including access token, target changeset index, and optional progress callback.\r\n * @throws IModelError If the briefcase is not open in read-write mode, if there are pending transactions when reversing, or if applying a changeset fails.\r\n * @returns A promise that resolves when all required changesets have been applied.\r\n */\r\n public static async pullAndApplyChangesets(db: IModelDb, arg: PullChangesArgs): Promise<void> {\r\n const nativeDb = db[_nativeDb];\r\n if (!db.isOpen || nativeDb.isReadonly()) // don't use db.isReadonly - we reopen the file writable just for this operation but db.isReadonly is still true\r\n throw new IModelError(ChangeSetStatus.ApplyError, \"Briefcase must be open ReadWrite to process change sets\");\r\n\r\n let currentIndex = db.changeset.index;\r\n if (currentIndex === undefined)\r\n currentIndex = (await IModelHost[_hubAccess].queryChangeset({ accessToken: arg.accessToken, iModelId: db.iModelId, changeset: { id: db.changeset.id } })).index;\r\n\r\n const reverse = (arg.toIndex && arg.toIndex < currentIndex) ? true : false;\r\n\r\n if (nativeDb.hasPendingTxns() && reverse) {\r\n throw new IModelError(ChangeSetStatus.ApplyError, \"Cannot reverse changesets when there are pending changes\");\r\n }\r\n\r\n // Download change sets\r\n const changesets = await IModelHost[_hubAccess].downloadChangesets({\r\n accessToken: arg.accessToken,\r\n iModelId: db.iModelId,\r\n range: { first: reverse ? arg.toIndex! + 1 : currentIndex + 1, end: reverse ? currentIndex : arg.toIndex }, // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n targetDir: BriefcaseManager.getChangeSetsPath(db.iModelId),\r\n progressCallback: arg.onProgress,\r\n });\r\n\r\n if (changesets.length === 0)\r\n return; // nothing to apply\r\n\r\n if (reverse)\r\n changesets.reverse();\r\n\r\n\r\n const briefcaseDb = db instanceof BriefcaseDb ? db : undefined;\r\n if (briefcaseDb) {\r\n if (briefcaseDb.txns.rebaser.isRebasing) {\r\n throw new IModelError(IModelStatus.BadRequest, \"Cannot pull and apply changeset while rebasing\");\r\n }\r\n if (briefcaseDb.txns.isIndirectChanges) {\r\n throw new IModelError(IModelStatus.BadRequest, \"Cannot pull and apply changeset while in an indirect change scope\");\r\n }\r\n }\r\n\r\n // create restore point if certain conditions are met\r\n if (briefcaseDb && briefcaseDb.txns.hasPendingTxns && !briefcaseDb.txns.hasPendingSchemaChanges && !reverse && !IModelHost.configuration?.disableRestorePointOnPullMerge) {\r\n Logger.logInfo(loggerCategory, `Creating restore point ${this.PULL_MERGE_RESTORE_POINT_NAME}`);\r\n await this.createRestorePoint(briefcaseDb, this.PULL_MERGE_RESTORE_POINT_NAME);\r\n }\r\n\r\n if (!reverse) {\r\n const reversedTxns = nativeDb.pullMergeReverseLocalChanges();\r\n Logger.logInfo(loggerCategory, `Reversed ${reversedTxns.length} local changes`);\r\n }\r\n\r\n // apply incoming changes\r\n for (const changeset of changesets) {\r\n const stopwatch = new StopWatch(`[${changeset.id}]`, true);\r\n Logger.logInfo(loggerCategory, `Starting application of changeset with id ${stopwatch.description}`);\r\n try {\r\n await this.applySingleChangeset(db, changeset, false);\r\n Logger.logInfo(loggerCategory, `Applied changeset with id ${stopwatch.description} (${stopwatch.elapsedSeconds} seconds)`);\r\n } catch (err: any) {\r\n if (err instanceof Error) {\r\n Logger.logError(loggerCategory, `Error applying changeset with id ${stopwatch.description}: ${err.message}`);\r\n }\r\n db.abandonChanges();\r\n throw err;\r\n }\r\n }\r\n if (!reverse) {\r\n if (briefcaseDb) {\r\n await briefcaseDb.txns.rebaser.resume();\r\n } else {\r\n // Only Briefcase has change management. Following is\r\n // for test related to standalone db with txn enabled.\r\n nativeDb.pullMergeRebaseBegin();\r\n let txnId = nativeDb.pullMergeRebaseNext();\r\n while (txnId) {\r\n nativeDb.pullMergeRebaseReinstateTxn();\r\n nativeDb.pullMergeRebaseUpdateTxn();\r\n txnId = nativeDb.pullMergeRebaseNext();\r\n }\r\n nativeDb.pullMergeRebaseEnd();\r\n if (!nativeDb.isReadonly) {\r\n nativeDb.saveChanges(\"Merge.\");\r\n }\r\n }\r\n\r\n if (briefcaseDb && this.containsRestorePoint(briefcaseDb, this.PULL_MERGE_RESTORE_POINT_NAME)) {\r\n Logger.logInfo(loggerCategory, `Dropping restore point ${this.PULL_MERGE_RESTORE_POINT_NAME}`);\r\n this.dropRestorePoint(briefcaseDb, this.PULL_MERGE_RESTORE_POINT_NAME);\r\n }\r\n }\r\n // notify listeners\r\n db.notifyChangesetApplied();\r\n }\r\n\r\n /**\r\n * @internal\r\n * Creates a restore point for the specified briefcase database.\r\n *\r\n * @param db - The {@link BriefcaseDb} instance for which to create the restore point.\r\n * @param name - The unique name for the restore point. Must be a non-empty string.\r\n * @returns A promise that resolves to the created stash object representing the restore point.\r\n */\r\n public static async createRestorePoint(db: BriefcaseDb, name: string): Promise<StashProps> {\r\n Logger.logTrace(loggerCategory, `Creating restore point ${name}`);\r\n this.dropRestorePoint(db, name);\r\n\r\n const stash = await StashManager.stash({ db, description: this.makeRestorePointKey(name) });\r\n db[_nativeDb].saveLocalValue(this.makeRestorePointKey(name), stash.id);\r\n db.saveChanges(\"Create restore point\");\r\n Logger.logTrace(loggerCategory, `Created restore point ${name}`, () => stash);\r\n return stash;\r\n }\r\n\r\n /**\r\n * @internal\r\n * Drops a previously created restore point from the specified briefcase database.\r\n *\r\n * @param db - The {@link BriefcaseDb} instance from which to drop the restore point.\r\n * @param name - The name of the restore point to be dropped. Must be a non-empty string.\r\n */\r\n public static dropRestorePoint(db: BriefcaseDb, name: string): void {\r\n Logger.logTrace(loggerCategory, `Dropping restore point ${name}`);\r\n\r\n const restorePointId = db[_nativeDb].queryLocalValue(this.makeRestorePointKey(name));\r\n if (restorePointId) {\r\n StashManager.dropStash({ db, stash: restorePointId });\r\n db[_nativeDb].deleteLocalValue(this.makeRestorePointKey(name));\r\n db.saveChanges(\"Drop restore point\");\r\n Logger.logTrace(loggerCategory, `Dropped restore point ${name}`);\r\n }\r\n\r\n }\r\n\r\n /**\r\n * @internal\r\n * Checks if a restore point with the specified name exists in the given briefcase database.\r\n *\r\n * @param db - The {@link BriefcaseDb} instance to search within.\r\n * @param name - The name of the restore point to check for existence.\r\n * @returns `true` if the restore point exists and its stash is present; otherwise, `false`.\r\n */\r\n public static containsRestorePoint(db: BriefcaseDb, name: string): boolean {\r\n Logger.logTrace(loggerCategory, `Checking if restore point ${name} exists`);\r\n const key = this.makeRestorePointKey(name);\r\n const restorePointId = db[_nativeDb].queryLocalValue(key);\r\n if (!restorePointId) {\r\n return false;\r\n }\r\n\r\n const stash = StashManager.tryGetStash({ db, stash: restorePointId });\r\n if (!stash) {\r\n Logger.logTrace(loggerCategory, `Restore point ${name} does not exist. Deleting ${key}`);\r\n db[_nativeDb].deleteLocalValue(key);\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n private static makeRestorePointKey(name: string): string {\r\n if (name.length === 0) {\r\n throw new Error(\"Invalid restore point name\");\r\n }\r\n return `restore_point/${name}`;\r\n }\r\n\r\n /**\r\n * @internal\r\n * Restores the state of a briefcase database to a previously saved restore point.\r\n *\r\n * @param db - The {@link BriefcaseDb} instance to restore.\r\n * @param name - The name of the restore point to apply.\r\n */\r\n public static async restorePoint(db: BriefcaseDb, name: string): Promise<void> {\r\n Logger.logTrace(loggerCategory, `Restoring to restore point ${name}`);\r\n const restorePointId = db[_nativeDb].queryLocalValue(this.makeRestorePointKey(name));\r\n if (!restorePointId) {\r\n throw new Error(`Restore point not found: ${name}`);\r\n }\r\n\r\n await StashManager.restore({ db, stash: restorePointId });\r\n Logger.logTrace(loggerCategory, `Restored to restore point ${name}`);\r\n this.dropRestorePoint(db, name);\r\n }\r\n\r\n /** create a changeset from the current changes, and push it to iModelHub */\r\n private static async pushChanges(db: BriefcaseDb, arg: PushChangesArgs): Promise<void> {\r\n if (db.txns.rebaser.isRebasing) {\r\n throw new IModelError(IModelStatus.BadRequest, \"Cannot push changeset while rebasing\");\r\n }\r\n if (db.txns.isIndirectChanges) {\r\n throw new IModelError(IModelStatus.BadRequest, \"Cannot push changeset while in an indirect change scope\");\r\n }\r\n\r\n const changesetProps = db[_nativeDb].startCreateChangeset() as ChangesetFileProps;\r\n changesetProps.briefcaseId = db.briefcaseId;\r\n changesetProps.description = arg.description;\r\n const fileSize = IModelJsFs.lstatSync(changesetProps.pathname)?.size;\r\n if (!fileSize) // either undefined or 0 means error\r\n throw new IModelError(IModelStatus.NoContent, \"error creating changeset\");\r\n\r\n changesetProps.size = fileSize;\r\n const id = IModelNative.platform.DgnDb.computeChangesetId(changesetProps);\r\n if (id !== changesetProps.id) {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR_InvalidChangeSetVersion, `Changeset id ${changesetProps.id} does not match computed id ${id}.`);\r\n }\r\n\r\n let retryCount = arg.pushRetryCount ?? 3;\r\n while (true) {\r\n try {\r\n const accessToken = await IModelHost.getAccessToken();\r\n const index = await IModelHost[_hubAccess].pushChangeset({ accessToken, iModelId: db.iModelId, changesetProps });\r\n db[_nativeDb].completeCreateChangeset({ index });\r\n db.changeset = db[_nativeDb].getCurrentChangeset();\r\n if (!arg.retainLocks)\r\n await db.locks[_releaseAllLocks]();\r\n\r\n return;\r\n } catch (err: any) {\r\n const shouldRetry = () => {\r\n if (retryCount-- <= 0)\r\n return false;\r\n switch (err.errorNumber) {\r\n case IModelHubStatus.AnotherUserPushing:\r\n case IModelHubStatus.DatabaseTemporarilyLocked:\r\n case IModelHubStatus.OperationFailed:\r\n return true;\r\n }\r\n return false;\r\n };\r\n\r\n if (!shouldRetry()) {\r\n db[_nativeDb].abandonCreateChangeset();\r\n throw err;\r\n }\r\n } finally {\r\n IModelJsFs.removeSync(changesetProps.pathname);\r\n }\r\n }\r\n }\r\n\r\n /** Pull/merge (if necessary), then push all local changes as a changeset. Called by [[BriefcaseDb.pushChanges]]\r\n * @internal\r\n */\r\n public static async pullMergePush(db: BriefcaseDb, arg: PushChangesArgs): Promise<void> {\r\n let retryCount = arg.mergeRetryCount ?? 5;\r\n while (true) {\r\n try {\r\n await BriefcaseManager.pullAndApplyChangesets(db, arg);\r\n if (!db.skipSyncSchemasOnPullAndPush)\r\n await SchemaSync.pull(db);\r\n // pullAndApply rebase changes and might remove redundant changes in local briefcase\r\n // this mean hasPendingTxns was true before but now after pullAndApply it might be false\r\n if (!db[_nativeDb].hasPendingTxns())\r\n return;\r\n\r\n await BriefcaseManager.pushChanges(db, arg);\r\n } catch (err: any) {\r\n if (retryCount-- <= 0 || err.errorNumber !== IModelHubStatus.PullIsRequired)\r\n throw (err);\r\n await (arg.mergeRetryDelay ?? BeDuration.fromSeconds(3)).wait();\r\n }\r\n }\r\n }\r\n\r\n}\r\n"]}
|
package/lib/esm/CatalogDb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CatalogDb.js","sourceRoot":"","sources":["../../src/CatalogDb.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAsB,gBAAgB,EAAyB,MAAM,oBAAoB,CAAC;AACjI,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YA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AO,CAAC,CAAC,MAAM,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACrE,CAAC;IACM,KAAK,CAAC,YAAY,CAAC,IAA4B;QACpD,OAAO,CAAC,MAAM,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC;IACnE,CAAC;IACM,KAAK,CAAC,gBAAgB,CAAC,IAAwC;QACpE,OAAO,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IACM,KAAK,CAAC,OAAO,CAAC,GAAW;QAC9B,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;IACzC,CAAC;IACM,KAAK,CAAC,qBAAqB,CAAC,GAAW,EAAE,QAAgC;QAC9E,gBAAgB,CAAC,GAAG,CAAC,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IACxD,CAAC;CACF","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 iModels\n */\n\nimport * as fs from \"fs\";\nimport { join } from \"path\";\nimport { CloudSqlite } from \"./CloudSqlite\";\nimport { IModelHost, KnownLocations } from \"./IModelHost\";\nimport { BriefcaseIdValue, CatalogError, type CatalogIModel, CloudSqliteError, IModelConnectionProps } from \"@itwin/core-common\";\nimport { IpcHandler } from \"./IpcHost\";\nimport { StandaloneDb } from \"./IModelDb\";\nimport { Guid, OpenMode } from \"@itwin/core-bentley\";\nimport { _nativeDb } from \"./internal/Symbols\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\n\ninterface CatalogCloudCache extends CloudSqlite.CloudCache {\n writeable: boolean;\n catalogContainers: Map<string, CloudSqlite.CloudContainer>;\n}\n\nlet readonlyCloudCache: CatalogCloudCache | undefined;\nlet writeableCloudCache: CatalogCloudCache | undefined;\nconst catalogManifestName = \"CatalogManifest\";\n\n// we make a readonly CloudCache and a writeable CloudCache. That way the access token authorizations are distinct.\nfunction makeCloudCache(arg: CloudSqlite.CreateCloudCacheArg, writeable: boolean) {\n const cache = CloudSqlite.CloudCaches.getCache(arg) as CatalogCloudCache;\n // if the cache was just created, add the \"catalog\" members as hidden\n if (undefined === cache.catalogContainers) {\n CloudSqlite.addHiddenProperty(cache, \"catalogContainers\", new Map<string, CloudSqlite.CloudContainer>());\n CloudSqlite.addHiddenProperty(cache, \"writeable\", writeable);\n }\n return cache;\n}\n\n// find an existing CloudContainer for accessing a CatalogIModel, or make a new one and connect it\nasync function getCatalogContainerObj(cache: CatalogCloudCache, containerId: string): Promise<CloudSqlite.CloudContainer> {\n const cloudContainer = cache.catalogContainers.get(containerId);\n if (undefined !== cloudContainer)\n return cloudContainer;\n\n const accessLevel = cache.writeable ? \"write\" : \"read\";\n const tokenProps = await CloudSqlite.getBlobService().requestToken({ containerId, accessLevel, userToken: await IModelHost.getAccessToken() });\n const container = CloudSqlite.createCloudContainer({\n accessLevel,\n baseUri: tokenProps.baseUri,\n containerId,\n storageType: tokenProps.provider,\n writeable: cache.writeable,\n accessToken: tokenProps.token\n });\n cache.catalogContainers.set(containerId, container); // save the container in the map of ContainerIds so we can reuse them\n container.connect(cache);\n return container;\n}\n\nfunction getReadonlyCloudCache() { return readonlyCloudCache ??= makeCloudCache({ cacheName: \"catalogs\", cacheSize: \"10G\" }, false) };\nfunction getWritableCloudCache() { return writeableCloudCache ??= makeCloudCache({ cacheName: \"writeableCatalogs\", cacheSize: \"10G\" }, true) };\nasync function getReadonlyContainer(containerId: string) { return getCatalogContainerObj(getReadonlyCloudCache(), containerId) };\nasync function getWriteableContainer(containerId: string) { return getCatalogContainerObj(getWritableCloudCache(), containerId) };\n\n/** Throw an error if the write lock is not held for the supplied container */\nfunction ensureLocked(container: CloudSqlite.CloudContainer, reason: string) {\n if (!container.hasWriteLock)\n CloudSqliteError.throwError(\"write-lock-not-held\", { message: `Write lock must be held to ${reason}` });\n}\n/** update the manifest in a CatalogIModel (calls `saveChanges`) */\nfunction updateManifest(nativeDb: IModelJsNative.DgnDb, manifest: CatalogIModel.Manifest) {\n nativeDb.saveLocalValue(catalogManifestName, JSON.stringify(manifest));\n nativeDb.saveChanges(\"update manifest\");\n}\nfunction catalogDbNameWithDefault(dbName?: string): string {\n return dbName ?? \"catalog-db\";\n}\n\n/** A [[StandaloneDb]] that provides read-only access to the contents of a [CatalogIModel]($common).\n * @see [[CatalogDb.openReadonly]] to instantiate this type.\n * @beta\n */\nexport interface CatalogDb extends StandaloneDb {\n /** Get the catalog's manifest. */\n getManifest(): CatalogIModel.Manifest | undefined;\n /** Get the catalog's version information. */\n getVersion(): string;\n /** Get the catalog's manifest and version. */\n getInfo(): { manifest?: CatalogIModel.Manifest, version: string };\n /** Returns true if the catalog was opened in read-write mode. */\n isEditable(): this is EditableCatalogDb;\n}\n\n/** A writable [[CatalogDb]].\n * @see [[CatalogDb.openEditable]] to instantiate this type.\n * @beta\n */\nexport interface EditableCatalogDb extends CatalogDb {\n /** Update the contents of the catalog manifest. */\n updateCatalogManifest(manifest: CatalogIModel.Manifest): void;\n}\n\n/** A StandaloneDb that holds a CatalogIModel */\nclass CatalogDbImpl extends StandaloneDb implements CatalogDb {\n public isEditable(): this is EditableCatalogDb {\n return false;\n }\n\n public getManifest(): CatalogIModel.Manifest | undefined {\n const manifestString = this[_nativeDb].queryLocalValue(catalogManifestName);\n if (undefined === manifestString)\n return undefined;\n return JSON.parse(manifestString) as CatalogIModel.Manifest;\n }\n\n public getVersion(): string {\n return CloudSqlite.parseDbFileName(this[_nativeDb].getFilePath()).version;\n }\n\n public getInfo() {\n return { manifest: this.getManifest(), version: this.getVersion() };\n }\n}\n\n/**\n * A CatalogDb that permits editing.\n * This class ensures that CatalogIModels never have a Txn table when they are published.\n * It also automatically updates the `lastEditedBy` field in the CatalogManifest.\n */\nclass EditableCatalogDbImpl extends CatalogDbImpl implements EditableCatalogDb {\n public override isEditable(): this is EditableCatalogDb {\n return true;\n }\n\n public updateCatalogManifest(manifest: CatalogIModel.Manifest): void {\n updateManifest(this[_nativeDb], manifest);\n }\n\n // Make sure the txn table is deleted and update the manifest every time we close.\n public override beforeClose(): void {\n try {\n const manifest = this.getManifest();\n const container = this.cloudContainer;\n if (container && manifest) {\n manifest.lastEditedBy = CloudSqlite.getWriteLockHeldBy(container);\n this.updateCatalogManifest(manifest);\n }\n\n // when saved, CatalogIModels should never have any Txns. If we wanted to create a changeset, we'd have to do it here.\n this[_nativeDb].deleteAllTxns();\n } catch { } // ignore errors attempting to update\n\n // might also want to vacuum here?\n super.beforeClose();\n }\n}\n\nfunction findCatalogByKey(key: string): CatalogDbImpl & EditableCatalogDb {\n return CatalogDbImpl.findByKey(key) as CatalogDbImpl & EditableCatalogDb;\n}\n\n/** @beta */\nexport namespace CatalogDb {\n /** Create a new [[BlobContainer]] to hold versions of a [[CatalogDb]].\n * @returns The properties of the newly created container.\n * @note creating new containers requires \"admin\" authorization.\n */\n export async function createNewContainer(args: CatalogIModel.CreateNewContainerArgs): Promise<CatalogIModel.NewContainerProps> {\n const dbName = catalogDbNameWithDefault(args.dbName);\n CloudSqlite.validateDbName(dbName);\n CloudSqlite.validateDbVersion(args.version);\n\n const tmpName = join(KnownLocations.tmpdir, `temp-${dbName}`);\n try {\n // make a copy of the file they supplied so we can modify its contents safely\n fs.copyFileSync(args.localCatalogFile, tmpName);\n const nativeDb = new IModelNative.platform.DgnDb();\n nativeDb.openIModel(tmpName, OpenMode.ReadWrite);\n nativeDb.setITwinId(Guid.empty); // catalogs must be a StandaloneDb\n nativeDb.setIModelId(Guid.createValue()); // make sure its iModelId is unique\n updateManifest(nativeDb, args.manifest); // store the manifest inside the Catalog\n nativeDb.deleteAllTxns(); // Catalogs should never have Txns (and, this must be empty before resetting BriefcaseId)\n nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned); // catalogs should always be unassigned\n nativeDb.saveChanges(); // save change to briefcaseId\n nativeDb.vacuum();\n nativeDb.closeFile();\n } catch (e: unknown) {\n CatalogError.throwError(\"invalid-seed-catalog\", { message: \"Illegal seed catalog\", ...args, cause: e });\n }\n\n const userToken = await IModelHost.getAccessToken();\n // create tne new container from the blob service, requires \"admin\" authorization\n const cloudContainerProps = await CloudSqlite.getBlobService().create({ scope: { iTwinId: args.iTwinId }, metadata: { ...args.metadata, containerType: \"CatalogIModel\" }, userToken });\n\n // now create a CloudSqlite container object to access it\n const container = CloudSqlite.createCloudContainer({\n accessToken: await CloudSqlite.requestToken(cloudContainerProps),\n accessLevel: \"admin\",\n writeable: true,\n baseUri: cloudContainerProps.baseUri,\n containerId: cloudContainerProps.containerId,\n storageType: cloudContainerProps.provider,\n });\n\n // initialize the container for use by CloudSqlite\n container.initializeContainer({ blockSize: 4 * 1024 * 1024 });\n container.connect(getWritableCloudCache());\n\n // upload the initial version of the Catalog\n await CloudSqlite.withWriteLock({ user: \"initialize\", container }, async () => {\n await CloudSqlite.uploadDb(container, { dbName: CloudSqlite.makeSemverName(dbName, args.version), localFileName: tmpName });\n fs.unlinkSync(tmpName); // delete temporary copy of catalog\n });\n container.disconnect();\n return cloudContainerProps;\n }\n\n /** Acquire the write lock for a [CatalogIModel]($common) container. Only one person may obtain the write lock at a time.\n * You must obtain the lock before attempting to write to the container via functions like [[CatalogDb.openEditable]] and [[CatalogDb.createNewVersion]].\n * @note This requires \"write\" authorization to the container\n */\n export async function acquireWriteLock(args: {\n /** The id of the container */\n containerId: string,\n /**\n * The name of the individual acquiring the lock. This will be shown to others who attempt to acquire the lock while it is held.\n * It is also stored in the \"lastEditedBy\" field of the manifest of any new version edited while the lock is held.\n */\n username: string;\n }): Promise<void> {\n const container = await getWriteableContainer(args.containerId);\n return CloudSqlite.acquireWriteLock({ container, user: args.username });\n }\n\n /** Release the write lock on a [CatalogIModel]($common) container. This uploads all changes made while the lock is held, so they become visible to other users. */\n export async function releaseWriteLock(args: {\n /** The id of the container */\n containerId: string,\n /** If true, abandon all local changes before releasing the lock */\n abandon?: true\n }): Promise<void> {\n const container = await getWriteableContainer(args.containerId);\n if (args.abandon)\n container.abandonChanges();\n CloudSqlite.releaseWriteLock(container);\n }\n\n /** Open an [[EditableCatalogDb]] for write access.\n * @note Once a version of a catalog iModel has been published (i.e. the write lock has been released), it is no longer editable, *unless* it is a prerelease version.\n * @note The write lock must be held for this operation to succeed\n */\n export async function openEditable(args: CatalogIModel.OpenArgs): Promise<EditableCatalogDb> {\n const dbName = catalogDbNameWithDefault(args.dbName);\n if (undefined === args.containerId) // local file?\n return EditableCatalogDbImpl.openFile(dbName, OpenMode.ReadWrite, args) as EditableCatalogDbImpl;\n\n const container = await getWriteableContainer(args.containerId);\n ensureLocked(container, \"open a Catalog for editing\"); // editing Catalogs requires the write lock\n\n // look up the full name with version\n const dbFullName = CloudSqlite.querySemverMatch({ container, dbName, version: args.version ?? \"*\" });\n if (!CloudSqlite.isSemverEditable(dbFullName, container))\n CloudSqliteError.throwError(\"already-published\", { message: \"Catalog has already been published and is not editable. Make a new version first.\", ...args })\n\n if (args.prefetch)\n CloudSqlite.startCloudPrefetch(container, dbFullName);\n\n return EditableCatalogDbImpl.openFile(dbFullName, OpenMode.ReadWrite, { container, ...args }) as EditableCatalogDbImpl;\n }\n\n /** Open a [[CatalogDb]] for read-only access. */\n export async function openReadonly(args: CatalogIModel.OpenArgs): Promise<CatalogDb> {\n const dbName = catalogDbNameWithDefault(args.dbName);\n if (undefined === args.containerId) // local file?\n return CatalogDbImpl.openFile(dbName, OpenMode.Readonly, args) as CatalogDbImpl;\n\n const container = await getReadonlyContainer(args.containerId);\n if (args.syncWithCloud)\n container.checkForChanges();\n\n const dbFullName = CloudSqlite.querySemverMatch({ container, ...args, dbName });\n if (args.prefetch)\n CloudSqlite.startCloudPrefetch(container, dbFullName);\n\n return CatalogDbImpl.openFile(dbFullName, OpenMode.Readonly, { container, ...args }) as CatalogDbImpl;\n }\n\n /**\n * Create a new version of a [CatalogIModel]($common) as a copy of an existing version. Immediately after this operation, the new version will be an exact copy\n * of the source CatalogIModel. Then, use [[CatalogDb.openEditable]] to modify the new version with new content.\n * @note The write lock must be held for this operation to succeed\n */\n export async function createNewVersion(args: CatalogIModel.CreateNewVersionArgs): Promise<{ oldDb: CatalogIModel.NameAndVersion; newDb: CatalogIModel.NameAndVersion; }> {\n const container = await getWriteableContainer(args.containerId);\n ensureLocked(container, \"create a new version\");\n return CloudSqlite.createNewDbVersion(container, { ...args, fromDb: { ...args.fromDb, dbName: catalogDbNameWithDefault(args.fromDb.dbName) } });\n }\n}\n\n/**\n * Handler for Ipc access to CatalogIModels. Registered by NativeHost.\n * @internal\n */\nexport class CatalogIModelHandler extends IpcHandler implements CatalogIModel.IpcMethods {\n public get channelName(): CatalogIModel.IpcChannel { return \"catalogIModel/ipc\"; }\n\n public async createNewContainer(args: CatalogIModel.CreateNewContainerArgs): Promise<CatalogIModel.NewContainerProps> {\n return CatalogDb.createNewContainer(args);\n }\n public async acquireWriteLock(args: { containerId: string, username: string; }): Promise<void> {\n return CatalogDb.acquireWriteLock(args);\n }\n public async releaseWriteLock(args: { containerId: string, abandon?: true; }): Promise<void> {\n return CatalogDb.releaseWriteLock(args);\n }\n public async openReadonly(args: CatalogIModel.OpenArgs): Promise<IModelConnectionProps> {\n return ((await CatalogDb.openReadonly(args)).getConnectionProps());\n }\n public async openEditable(args: CatalogIModel.OpenArgs): Promise<IModelConnectionProps> {\n return (await CatalogDb.openEditable(args)).getConnectionProps();\n }\n public async createNewVersion(args: CatalogIModel.CreateNewVersionArgs): Promise<{ oldDb: CatalogIModel.NameAndVersion; newDb: CatalogIModel.NameAndVersion; }> {\n return CatalogDb.createNewVersion(args);\n }\n public async getInfo(key: string): Promise<{ manifest?: CatalogIModel.Manifest, version: string }> {\n return findCatalogByKey(key).getInfo();\n }\n public async updateCatalogManifest(key: string, manifest: CatalogIModel.Manifest): Prom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AC,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IACxD,CAAC;CACF","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 iModels\r\n */\r\n\r\nimport * as fs from \"fs\";\r\nimport { join } from \"path\";\r\nimport { CloudSqlite } from \"./CloudSqlite\";\r\nimport { IModelHost, KnownLocations } from \"./IModelHost\";\r\nimport { BriefcaseIdValue, CatalogError, type CatalogIModel, CloudSqliteError, IModelConnectionProps } from \"@itwin/core-common\";\r\nimport { IpcHandler } from \"./IpcHost\";\r\nimport { StandaloneDb } from \"./IModelDb\";\r\nimport { Guid, OpenMode } from \"@itwin/core-bentley\";\r\nimport { _nativeDb } from \"./internal/Symbols\";\r\nimport { IModelNative } from \"./internal/NativePlatform\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\n\r\ninterface CatalogCloudCache extends CloudSqlite.CloudCache {\r\n writeable: boolean;\r\n catalogContainers: Map<string, CloudSqlite.CloudContainer>;\r\n}\r\n\r\nlet readonlyCloudCache: CatalogCloudCache | undefined;\r\nlet writeableCloudCache: CatalogCloudCache | undefined;\r\nconst catalogManifestName = \"CatalogManifest\";\r\n\r\n// we make a readonly CloudCache and a writeable CloudCache. That way the access token authorizations are distinct.\r\nfunction makeCloudCache(arg: CloudSqlite.CreateCloudCacheArg, writeable: boolean) {\r\n const cache = CloudSqlite.CloudCaches.getCache(arg) as CatalogCloudCache;\r\n // if the cache was just created, add the \"catalog\" members as hidden\r\n if (undefined === cache.catalogContainers) {\r\n CloudSqlite.addHiddenProperty(cache, \"catalogContainers\", new Map<string, CloudSqlite.CloudContainer>());\r\n CloudSqlite.addHiddenProperty(cache, \"writeable\", writeable);\r\n }\r\n return cache;\r\n}\r\n\r\n// find an existing CloudContainer for accessing a CatalogIModel, or make a new one and connect it\r\nasync function getCatalogContainerObj(cache: CatalogCloudCache, containerId: string): Promise<CloudSqlite.CloudContainer> {\r\n const cloudContainer = cache.catalogContainers.get(containerId);\r\n if (undefined !== cloudContainer)\r\n return cloudContainer;\r\n\r\n const accessLevel = cache.writeable ? \"write\" : \"read\";\r\n const tokenProps = await CloudSqlite.getBlobService().requestToken({ containerId, accessLevel, userToken: await IModelHost.getAccessToken() });\r\n const container = CloudSqlite.createCloudContainer({\r\n accessLevel,\r\n baseUri: tokenProps.baseUri,\r\n containerId,\r\n storageType: tokenProps.provider,\r\n writeable: cache.writeable,\r\n accessToken: tokenProps.token\r\n });\r\n cache.catalogContainers.set(containerId, container); // save the container in the map of ContainerIds so we can reuse them\r\n container.connect(cache);\r\n return container;\r\n}\r\n\r\nfunction getReadonlyCloudCache() { return readonlyCloudCache ??= makeCloudCache({ cacheName: \"catalogs\", cacheSize: \"10G\" }, false) };\r\nfunction getWritableCloudCache() { return writeableCloudCache ??= makeCloudCache({ cacheName: \"writeableCatalogs\", cacheSize: \"10G\" }, true) };\r\nasync function getReadonlyContainer(containerId: string) { return getCatalogContainerObj(getReadonlyCloudCache(), containerId) };\r\nasync function getWriteableContainer(containerId: string) { return getCatalogContainerObj(getWritableCloudCache(), containerId) };\r\n\r\n/** Throw an error if the write lock is not held for the supplied container */\r\nfunction ensureLocked(container: CloudSqlite.CloudContainer, reason: string) {\r\n if (!container.hasWriteLock)\r\n CloudSqliteError.throwError(\"write-lock-not-held\", { message: `Write lock must be held to ${reason}` });\r\n}\r\n/** update the manifest in a CatalogIModel (calls `saveChanges`) */\r\nfunction updateManifest(nativeDb: IModelJsNative.DgnDb, manifest: CatalogIModel.Manifest) {\r\n nativeDb.saveLocalValue(catalogManifestName, JSON.stringify(manifest));\r\n nativeDb.saveChanges(\"update manifest\");\r\n}\r\nfunction catalogDbNameWithDefault(dbName?: string): string {\r\n return dbName ?? \"catalog-db\";\r\n}\r\n\r\n/** A [[StandaloneDb]] that provides read-only access to the contents of a [CatalogIModel]($common).\r\n * @see [[CatalogDb.openReadonly]] to instantiate this type.\r\n * @beta\r\n */\r\nexport interface CatalogDb extends StandaloneDb {\r\n /** Get the catalog's manifest. */\r\n getManifest(): CatalogIModel.Manifest | undefined;\r\n /** Get the catalog's version information. */\r\n getVersion(): string;\r\n /** Get the catalog's manifest and version. */\r\n getInfo(): { manifest?: CatalogIModel.Manifest, version: string };\r\n /** Returns true if the catalog was opened in read-write mode. */\r\n isEditable(): this is EditableCatalogDb;\r\n}\r\n\r\n/** A writable [[CatalogDb]].\r\n * @see [[CatalogDb.openEditable]] to instantiate this type.\r\n * @beta\r\n */\r\nexport interface EditableCatalogDb extends CatalogDb {\r\n /** Update the contents of the catalog manifest. */\r\n updateCatalogManifest(manifest: CatalogIModel.Manifest): void;\r\n}\r\n\r\n/** A StandaloneDb that holds a CatalogIModel */\r\nclass CatalogDbImpl extends StandaloneDb implements CatalogDb {\r\n public isEditable(): this is EditableCatalogDb {\r\n return false;\r\n }\r\n\r\n public getManifest(): CatalogIModel.Manifest | undefined {\r\n const manifestString = this[_nativeDb].queryLocalValue(catalogManifestName);\r\n if (undefined === manifestString)\r\n return undefined;\r\n return JSON.parse(manifestString) as CatalogIModel.Manifest;\r\n }\r\n\r\n public getVersion(): string {\r\n return CloudSqlite.parseDbFileName(this[_nativeDb].getFilePath()).version;\r\n }\r\n\r\n public getInfo() {\r\n return { manifest: this.getManifest(), version: this.getVersion() };\r\n }\r\n}\r\n\r\n/**\r\n * A CatalogDb that permits editing.\r\n * This class ensures that CatalogIModels never have a Txn table when they are published.\r\n * It also automatically updates the `lastEditedBy` field in the CatalogManifest.\r\n */\r\nclass EditableCatalogDbImpl extends CatalogDbImpl implements EditableCatalogDb {\r\n public override isEditable(): this is EditableCatalogDb {\r\n return true;\r\n }\r\n\r\n public updateCatalogManifest(manifest: CatalogIModel.Manifest): void {\r\n updateManifest(this[_nativeDb], manifest);\r\n }\r\n\r\n // Make sure the txn table is deleted and update the manifest every time we close.\r\n public override beforeClose(): void {\r\n try {\r\n const manifest = this.getManifest();\r\n const container = this.cloudContainer;\r\n if (container && manifest) {\r\n manifest.lastEditedBy = CloudSqlite.getWriteLockHeldBy(container);\r\n this.updateCatalogManifest(manifest);\r\n }\r\n\r\n // when saved, CatalogIModels should never have any Txns. If we wanted to create a changeset, we'd have to do it here.\r\n this[_nativeDb].deleteAllTxns();\r\n } catch { } // ignore errors attempting to update\r\n\r\n // might also want to vacuum here?\r\n super.beforeClose();\r\n }\r\n}\r\n\r\nfunction findCatalogByKey(key: string): CatalogDbImpl & EditableCatalogDb {\r\n return CatalogDbImpl.findByKey(key) as CatalogDbImpl & EditableCatalogDb;\r\n}\r\n\r\n/** @beta */\r\nexport namespace CatalogDb {\r\n /** Create a new [[BlobContainer]] to hold versions of a [[CatalogDb]].\r\n * @returns The properties of the newly created container.\r\n * @note creating new containers requires \"admin\" authorization.\r\n */\r\n export async function createNewContainer(args: CatalogIModel.CreateNewContainerArgs): Promise<CatalogIModel.NewContainerProps> {\r\n const dbName = catalogDbNameWithDefault(args.dbName);\r\n CloudSqlite.validateDbName(dbName);\r\n CloudSqlite.validateDbVersion(args.version);\r\n\r\n const tmpName = join(KnownLocations.tmpdir, `temp-${dbName}`);\r\n try {\r\n // make a copy of the file they supplied so we can modify its contents safely\r\n fs.copyFileSync(args.localCatalogFile, tmpName);\r\n const nativeDb = new IModelNative.platform.DgnDb();\r\n nativeDb.openIModel(tmpName, OpenMode.ReadWrite);\r\n nativeDb.setITwinId(Guid.empty); // catalogs must be a StandaloneDb\r\n nativeDb.setIModelId(Guid.createValue()); // make sure its iModelId is unique\r\n updateManifest(nativeDb, args.manifest); // store the manifest inside the Catalog\r\n nativeDb.deleteAllTxns(); // Catalogs should never have Txns (and, this must be empty before resetting BriefcaseId)\r\n nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned); // catalogs should always be unassigned\r\n nativeDb.saveChanges(); // save change to briefcaseId\r\n nativeDb.vacuum();\r\n nativeDb.closeFile();\r\n } catch (e: unknown) {\r\n CatalogError.throwError(\"invalid-seed-catalog\", { message: \"Illegal seed catalog\", ...args, cause: e });\r\n }\r\n\r\n const userToken = await IModelHost.getAccessToken();\r\n // create tne new container from the blob service, requires \"admin\" authorization\r\n const cloudContainerProps = await CloudSqlite.getBlobService().create({ scope: { iTwinId: args.iTwinId }, metadata: { ...args.metadata, containerType: \"CatalogIModel\" }, userToken });\r\n\r\n // now create a CloudSqlite container object to access it\r\n const container = CloudSqlite.createCloudContainer({\r\n accessToken: await CloudSqlite.requestToken(cloudContainerProps),\r\n accessLevel: \"admin\",\r\n writeable: true,\r\n baseUri: cloudContainerProps.baseUri,\r\n containerId: cloudContainerProps.containerId,\r\n storageType: cloudContainerProps.provider,\r\n });\r\n\r\n // initialize the container for use by CloudSqlite\r\n container.initializeContainer({ blockSize: 4 * 1024 * 1024 });\r\n container.connect(getWritableCloudCache());\r\n\r\n // upload the initial version of the Catalog\r\n await CloudSqlite.withWriteLock({ user: \"initialize\", container }, async () => {\r\n await CloudSqlite.uploadDb(container, { dbName: CloudSqlite.makeSemverName(dbName, args.version), localFileName: tmpName });\r\n fs.unlinkSync(tmpName); // delete temporary copy of catalog\r\n });\r\n container.disconnect();\r\n return cloudContainerProps;\r\n }\r\n\r\n /** Acquire the write lock for a [CatalogIModel]($common) container. Only one person may obtain the write lock at a time.\r\n * You must obtain the lock before attempting to write to the container via functions like [[CatalogDb.openEditable]] and [[CatalogDb.createNewVersion]].\r\n * @note This requires \"write\" authorization to the container\r\n */\r\n export async function acquireWriteLock(args: {\r\n /** The id of the container */\r\n containerId: string,\r\n /**\r\n * The name of the individual acquiring the lock. This will be shown to others who attempt to acquire the lock while it is held.\r\n * It is also stored in the \"lastEditedBy\" field of the manifest of any new version edited while the lock is held.\r\n */\r\n username: string;\r\n }): Promise<void> {\r\n const container = await getWriteableContainer(args.containerId);\r\n return CloudSqlite.acquireWriteLock({ container, user: args.username });\r\n }\r\n\r\n /** Release the write lock on a [CatalogIModel]($common) container. This uploads all changes made while the lock is held, so they become visible to other users. */\r\n export async function releaseWriteLock(args: {\r\n /** The id of the container */\r\n containerId: string,\r\n /** If true, abandon all local changes before releasing the lock */\r\n abandon?: true\r\n }): Promise<void> {\r\n const container = await getWriteableContainer(args.containerId);\r\n if (args.abandon)\r\n container.abandonChanges();\r\n CloudSqlite.releaseWriteLock(container);\r\n }\r\n\r\n /** Open an [[EditableCatalogDb]] for write access.\r\n * @note Once a version of a catalog iModel has been published (i.e. the write lock has been released), it is no longer editable, *unless* it is a prerelease version.\r\n * @note The write lock must be held for this operation to succeed\r\n */\r\n export async function openEditable(args: CatalogIModel.OpenArgs): Promise<EditableCatalogDb> {\r\n const dbName = catalogDbNameWithDefault(args.dbName);\r\n if (undefined === args.containerId) // local file?\r\n return EditableCatalogDbImpl.openFile(dbName, OpenMode.ReadWrite, args) as EditableCatalogDbImpl;\r\n\r\n const container = await getWriteableContainer(args.containerId);\r\n ensureLocked(container, \"open a Catalog for editing\"); // editing Catalogs requires the write lock\r\n\r\n // look up the full name with version\r\n const dbFullName = CloudSqlite.querySemverMatch({ container, dbName, version: args.version ?? \"*\" });\r\n if (!CloudSqlite.isSemverEditable(dbFullName, container))\r\n CloudSqliteError.throwError(\"already-published\", { message: \"Catalog has already been published and is not editable. Make a new version first.\", ...args })\r\n\r\n if (args.prefetch)\r\n CloudSqlite.startCloudPrefetch(container, dbFullName);\r\n\r\n return EditableCatalogDbImpl.openFile(dbFullName, OpenMode.ReadWrite, { container, ...args }) as EditableCatalogDbImpl;\r\n }\r\n\r\n /** Open a [[CatalogDb]] for read-only access. */\r\n export async function openReadonly(args: CatalogIModel.OpenArgs): Promise<CatalogDb> {\r\n const dbName = catalogDbNameWithDefault(args.dbName);\r\n if (undefined === args.containerId) // local file?\r\n return CatalogDbImpl.openFile(dbName, OpenMode.Readonly, args) as CatalogDbImpl;\r\n\r\n const container = await getReadonlyContainer(args.containerId);\r\n if (args.syncWithCloud)\r\n container.checkForChanges();\r\n\r\n const dbFullName = CloudSqlite.querySemverMatch({ container, ...args, dbName });\r\n if (args.prefetch)\r\n CloudSqlite.startCloudPrefetch(container, dbFullName);\r\n\r\n return CatalogDbImpl.openFile(dbFullName, OpenMode.Readonly, { container, ...args }) as CatalogDbImpl;\r\n }\r\n\r\n /**\r\n * Create a new version of a [CatalogIModel]($common) as a copy of an existing version. Immediately after this operation, the new version will be an exact copy\r\n * of the source CatalogIModel. Then, use [[CatalogDb.openEditable]] to modify the new version with new content.\r\n * @note The write lock must be held for this operation to succeed\r\n */\r\n export async function createNewVersion(args: CatalogIModel.CreateNewVersionArgs): Promise<{ oldDb: CatalogIModel.NameAndVersion; newDb: CatalogIModel.NameAndVersion; }> {\r\n const container = await getWriteableContainer(args.containerId);\r\n ensureLocked(container, \"create a new version\");\r\n return CloudSqlite.createNewDbVersion(container, { ...args, fromDb: { ...args.fromDb, dbName: catalogDbNameWithDefault(args.fromDb.dbName) } });\r\n }\r\n}\r\n\r\n/**\r\n * Handler for Ipc access to CatalogIModels. Registered by NativeHost.\r\n * @internal\r\n */\r\nexport class CatalogIModelHandler extends IpcHandler implements CatalogIModel.IpcMethods {\r\n public get channelName(): CatalogIModel.IpcChannel { return \"catalogIModel/ipc\"; }\r\n\r\n public async createNewContainer(args: CatalogIModel.CreateNewContainerArgs): Promise<CatalogIModel.NewContainerProps> {\r\n return CatalogDb.createNewContainer(args);\r\n }\r\n public async acquireWriteLock(args: { containerId: string, username: string; }): Promise<void> {\r\n return CatalogDb.acquireWriteLock(args);\r\n }\r\n public async releaseWriteLock(args: { containerId: string, abandon?: true; }): Promise<void> {\r\n return CatalogDb.releaseWriteLock(args);\r\n }\r\n public async openReadonly(args: CatalogIModel.OpenArgs): Promise<IModelConnectionProps> {\r\n return ((await CatalogDb.openReadonly(args)).getConnectionProps());\r\n }\r\n public async openEditable(args: CatalogIModel.OpenArgs): Promise<IModelConnectionProps> {\r\n return (await CatalogDb.openEditable(args)).getConnectionProps();\r\n }\r\n public async createNewVersion(args: CatalogIModel.CreateNewVersionArgs): Promise<{ oldDb: CatalogIModel.NameAndVersion; newDb: CatalogIModel.NameAndVersion; }> {\r\n return CatalogDb.createNewVersion(args);\r\n }\r\n public async getInfo(key: string): Promise<{ manifest?: CatalogIModel.Manifest, version: string }> {\r\n return findCatalogByKey(key).getInfo();\r\n }\r\n public async updateCatalogManifest(key: string, manifest: CatalogIModel.Manifest): Promise<void> {\r\n findCatalogByKey(key).updateCatalogManifest(manifest);\r\n }\r\n}\r\n"]}
|
package/lib/esm/Category.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Category.js","sourceRoot":"","sources":["../../src/Category.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAc,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EACL,WAAW,EAAiB,IAAI,EAA0C,IAAI,EAAE,qBAAqB,GACtG,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAGrE;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,iBAAiB;IACzC,MAAM,KAAc,SAAS,KAAa,OAAO,aAAa,CAAC,CAAC,CAAC;IACxE,qDAAqD;IAC9C,UAAU,CAAwB;IACzC,gDAAgD;IACzC,WAAW,CAAU;IAE5B,YAAsB,KAAuB,EAAE,MAAgB;QAC7D,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,qBAAqB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC9D,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC3D,CAAC;IAED;;;;OAIG;IACO,MAA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AC;QAClF,OAAO,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,UAAU,CAAC,MAAgB,EAAE,YAA4B,EAAE,SAAiB;QACxF,MAAM,QAAQ,GAAa,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,eAAe,CAAC,eAAe,EAAE,CAAC,CAAC;QACzF,OAAO,IAAI,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAChF,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAAC,QAAkB,EAAE,iBAA6B,EAAE,IAAY;QAClF,MAAM,aAAa,GAAkB;YACnC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,KAAK,EAAE,iBAAiB;YACxB,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,CAAC;YACxD,SAAS,EAAE,KAAK;SACjB,CAAC;QACF,OAAO,IAAI,eAAe,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,MAAM,CAAC,QAAkB,EAAE,iBAA6B,EAAE,IAAY,EAAE,iBAAsE;QAC1J,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,CAAC,CAAC;QAChE,QAAQ,CAAC,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QACjE,QAAQ,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;QACjD,OAAO,QAAQ,CAAC,EAAE,CAAC;IACrB,CAAC;CACF","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 iModels\n */\n\nimport { Id64, Id64String, JsonUtils } from \"@itwin/core-bentley\";\nimport {\n BisCodeSpec, CategoryProps, Code, CodeScopeProps, CodeSpec, ElementProps, Rank, SubCategoryAppearance, SubCategoryProps,\n} from \"@itwin/core-common\";\nimport { DefinitionElement } from \"./Element\";\nimport { IModelDb } from \"./IModelDb\";\nimport { CategoryOwnsSubCategories } from \"./NavigationRelationship\";\nimport { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from \"./Entity\";\n\n/** Defines the appearance for graphics in Geometric elements\n * @public @preview\n */\nexport class SubCategory extends DefinitionElement {\n public static override get className(): string { return \"SubCategory\"; }\n /** The Appearance parameters for this SubCategory */\n public appearance: SubCategoryAppearance;\n /** Optional description of this SubCategory. */\n public description?: string;\n\n protected constructor(props: SubCategoryProps, iModel: IModelDb) {\n super(props, iModel);\n this.appearance = new SubCategoryAppearance(props.appearance);\n this.description = JsonUtils.asString(props.description);\n }\n\n /**\n * SubCategory custom HandledProps include 'description' and 'properties'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"description\", source: \"Class\" },\n { propertyName: \"properties\", source: \"Class\" },\n ];\n\n /**\n * SubCategory deserializes 'description' and 'properties'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): SubCategoryProps {\n const elProps = super.deserialize(props) as SubCategoryProps;\n elProps.description = JsonUtils.asString(props.row.description);\n if (props.row.properties !== '') {\n elProps.appearance = JSON.parse(props.row.properties) as SubCategoryAppearance.Props;\n } else {\n elProps.appearance = undefined;\n }\n return elProps;\n }\n\n /**\n * SubCategory serialize 'description' and 'properties'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: SubCategoryProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.description !== undefined) {\n inst.description = props.description;\n }\n if (props.appearance !== undefined) {\n inst.properties = JSON.stringify(props.appearance);\n }\n return inst;\n }\n\n public override toJSON(): SubCategoryProps {\n const val = super.toJSON() as SubCategoryProps;\n val.appearance = this.appearance.toJSON();\n if (this.description && this.description.length > 0)\n val.description = this.description;\n return val;\n }\n\n /** Get the SubCategory's name (its Code value). */\n public getSubCategoryName(): string { return this.code.value; }\n /** Get the Id of the SubCategory. */\n public getSubCategoryId(): Id64String { return this.id; }\n /** Get the Id of this SubCategory's parent Category. */\n public getCategoryId(): Id64String { return this.parent ? this.parent.id : Id64.invalid; }\n /** Check if this is the default SubCategory of its parent Category. */\n public get isDefaultSubCategory(): boolean { return IModelDb.getDefaultSubCategoryId(this.getCategoryId()) === this.getSubCategoryId(); }\n\n /** Create a Code for a SubCategory given a name that is meant to be unique within the scope of the specified parent Category.\n * @param iModel The IModel\n * @param parentCategoryId The Id of the parent Category that owns the SubCategory and provides the scope for its name.\n * @param codeValue The name of the SubCategory\n */\n public static createCode(iModel: IModelDb, parentCategoryId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.subCategory);\n return new Code({ spec: codeSpec.id, scope: parentCategoryId, value: codeValue });\n }\n\n /** Create a new SubCategory\n * @param iModelDb The iModel\n * @param parentCategoryId Create the new SubCategory as a child of this [[Category]]\n * @param name The name of the SubCategory\n * @param appearance The appearance settings to use for this SubCategory\n * @returns The newly constructed SubCategory element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): SubCategory {\n if (appearance instanceof SubCategoryAppearance)\n appearance = appearance.toJSON();\n\n const parentCategory = iModelDb.elements.getElement<Category>(parentCategoryId);\n const subCategoryProps: SubCategoryProps = {\n classFullName: this.classFullName,\n model: parentCategory.model,\n parent: new CategoryOwnsSubCategories(parentCategoryId),\n code: this.createCode(iModelDb, parentCategoryId, name),\n appearance,\n };\n return new SubCategory(subCategoryProps, iModelDb);\n }\n\n /** Insert a new SubCategory\n * @param iModelDb Insert into this iModel\n * @param parentCategoryId Insert the new SubCategory as a child of this Category\n * @param name The name of the SubCategory\n * @param appearance The appearance settings to use for this SubCategory\n * @returns The Id of the newly inserted SubCategory element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\n const subCategory = this.create(iModelDb, parentCategoryId, name, appearance);\n return iModelDb.elements.insertElement(subCategory.toJSON());\n }\n}\n\n/** A Category element is the target of the `category` member of [[GeometricElement]].\n * @public @preview\n */\nexport class Category extends DefinitionElement {\n public static override get className(): string { return \"Category\"; }\n public rank: Rank = Rank.User;\n public description?: string;\n\n protected constructor(props: CategoryProps, iModel: IModelDb) {\n super(props, iModel);\n this.rank = JsonUtils.asInt(props.rank);\n this.description = JsonUtils.asString(props.description);\n }\n\n /**\n * Category custom HandledProps include 'rank' and 'description'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"rank\", source: \"Class\" },\n { propertyName: \"description\", source: \"Class\" },\n ];\n\n /**\n * Category deserializes 'rank' and 'description'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): CategoryProps {\n const elProps = super.deserialize(props) as CategoryProps;\n elProps.description = JsonUtils.asString(props.row.description);\n elProps.rank = JsonUtils.asInt(props.row.rank);\n return elProps;\n }\n\n /**\n * Category serialize 'rank' and 'description'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: CategoryProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (undefined !== props.description) {\n inst.description = props.description;\n }\n inst.rank = props.rank;\n return inst;\n }\n public override toJSON(): CategoryProps {\n const val = super.toJSON() as CategoryProps;\n val.rank = this.rank;\n if (this.description && this.description.length > 0)\n val.description = this.description;\n return val;\n }\n\n /** Get the Id of the default SubCategory for this Category. */\n public myDefaultSubCategoryId(): Id64String { return IModelDb.getDefaultSubCategoryId(this.id); }\n\n /** Set the appearance of the default SubCategory for this Category */\n public setDefaultAppearance(props: SubCategoryAppearance.Props | SubCategoryAppearance): void {\n if (props instanceof SubCategoryAppearance)\n props = props.toJSON();\n\n const subCat = this.iModel.elements.getElement<SubCategory>(this.myDefaultSubCategoryId());\n subCat.appearance = new SubCategoryAppearance(props);\n this.iModel.elements.updateElement(subCat.toJSON());\n }\n}\n\n/** Categorizes 2d GeometricElements.\n * @public @preview\n */\nexport class DrawingCategory extends Category {\n public static override get className(): string { return \"DrawingCategory\"; }\n\n protected constructor(opts: ElementProps, iModel: IModelDb) { super(opts, iModel); }\n\n /** Get the name of the CodeSpec that is used by DrawingCategory objects. */\n public static getCodeSpecName(): string { return BisCodeSpec.drawingCategory; }\n\n /** Looks up the CategoryId of a DrawingCategory by model and name */\n public static queryCategoryIdByName(iModel: IModelDb, scopeModelId: Id64String, categoryName: string): Id64String | undefined {\n const code: Code = DrawingCategory.createCode(iModel, scopeModelId, categoryName);\n return iModel.elements.queryElementIdByCode(code);\n }\n\n /** Create a Code for a DrawingCategory given a name that is meant to be unique within the scope of the specified DefinitionModel.\n * @param iModel The IModel\n * @param scopeModelId The Id of the DefinitionModel that contains the DrawingCategory and provides the scope for its name.\n * @param codeValue The name of the category\n * @return A drawing category Code\n */\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(DrawingCategory.getCodeSpecName());\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n /** Create a new DrawingCategory\n * @param iModelDb The iModel\n * @param definitionModelId The [[DefinitionModel]]\n * @param name The name of the DrawingCategory\n * @returns The newly constructed DrawingCategory element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): DrawingCategory {\n const categoryProps: CategoryProps = {\n classFullName: this.classFullName,\n model: definitionModelId,\n code: this.createCode(iModelDb, definitionModelId, name),\n isPrivate: false,\n };\n return new DrawingCategory(categoryProps, iModelDb);\n }\n\n /** Insert a new DrawingCategory\n * @param iModelDb Insert into this iModel\n * @param definitionModelId Insert the new DrawingCategory into this [[DefinitionModel]]\n * @param name The name of the DrawingCategory\n * @param defaultAppearance The appearance settings to use for the default SubCategory of this DrawingCategory\n * @returns The Id of the newly inserted DrawingCategory element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\n const category = this.create(iModelDb, definitionModelId, name);\n const elements = iModelDb.elements;\n category.id = elements.insertElement(category.toJSON());\n category.setDefaultAppearance(defaultAppearance);\n return category.id;\n }\n}\n\n/** Categorizes SpatialElements. See [how to create a SpatialCategory]($docs/learning/backend/CreateElements.md#SpatialCategory).\n * @public @preview\n */\nexport class SpatialCategory extends Category {\n public static override get className(): string { return \"SpatialCategory\"; }\n protected constructor(opts: ElementProps, iModel: IModelDb) { super(opts, iModel); }\n\n /** Get the name of the CodeSpec that is used by SpatialCategory objects. */\n public static getCodeSpecName(): string { return BisCodeSpec.spatialCategory; }\n\n /** Looks up the CategoryId of a SpatialCategory by model and name */\n public static queryCategoryIdByName(iModel: IModelDb, scopeModelId: Id64String, categoryName: string): Id64String | undefined {\n const code: Code = SpatialCategory.createCode(iModel, scopeModelId, categoryName);\n return iModel.elements.queryElementIdByCode(code);\n }\n\n /** Create a Code for a SpatialCategory given a name that is meant to be unique within the scope of the specified DefinitionModel.\n * @param iModel The IModel\n * @param scopeModelId The Id of the DefinitionModel that contains the SpatialCategory and provides the scope for its name.\n * @param codeValue The name of the category\n * @return A spatial category Code\n */\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(SpatialCategory.getCodeSpecName());\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n /** Create a new SpatialCategory\n * @param iModelDb The iModel\n * @param definitionModelId The [[DefinitionModel]]\n * @param name The name/CodeValue of the SpatialCategory\n * @returns The newly constructed SpatialCategory element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): SpatialCategory {\n const categoryProps: CategoryProps = {\n classFullName: this.classFullName,\n model: definitionModelId,\n code: this.createCode(iModelDb, definitionModelId, name),\n isPrivate: false,\n };\n return new SpatialCategory(categoryProps, iModelDb);\n }\n\n /** Insert a new SpatialCategory\n * @param iModelDb Insert into this iModel\n * @param definitionModelId Insert the new SpatialCategory into this DefinitionModel\n * @param name The name of the SpatialCategory\n * @param defaultAppearance The appearance settings to use for the default SubCategory of this SpatialCategory\n * @returns The Id of the newly inserted SpatialCategory element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\n const category = this.create(iModelDb, definitionModelId, name);\n category.id = iModelDb.elements.insertElement(category.toJSON());\n category.setDefaultAppearance(defaultAppearance);\n return category.id;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Category.js","sourceRoot":"","sources":["../../src/Category.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAc,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EACL,WAAW,EAAiB,IAAI,EAA0C,IAAI,EAAE,qBAAqB,GACtG,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAGrE;;GAEG;AACH,MAAM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AAM,CAAC,MAAM,CAAC,QAAkB,EAAE,iBAA6B,EAAE,IAAY,EAAE,iBAAsE;QAC1J,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,CAAC,CAAC;QAChE,QAAQ,CAAC,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QACjE,QAAQ,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;QACjD,OAAO,QAAQ,CAAC,EAAE,CAAC;IACrB,CAAC;CACF","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 iModels\r\n */\r\n\r\nimport { Id64, Id64String, JsonUtils } from \"@itwin/core-bentley\";\r\nimport {\r\n BisCodeSpec, CategoryProps, Code, CodeScopeProps, CodeSpec, ElementProps, Rank, SubCategoryAppearance, SubCategoryProps,\r\n} from \"@itwin/core-common\";\r\nimport { DefinitionElement } from \"./Element\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { CategoryOwnsSubCategories } from \"./NavigationRelationship\";\r\nimport { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from \"./Entity\";\r\n\r\n/** Defines the appearance for graphics in Geometric elements\r\n * @public @preview\r\n */\r\nexport class SubCategory extends DefinitionElement {\r\n public static override get className(): string { return \"SubCategory\"; }\r\n /** The Appearance parameters for this SubCategory */\r\n public appearance: SubCategoryAppearance;\r\n /** Optional description of this SubCategory. */\r\n public description?: string;\r\n\r\n protected constructor(props: SubCategoryProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.appearance = new SubCategoryAppearance(props.appearance);\r\n this.description = JsonUtils.asString(props.description);\r\n }\r\n\r\n /**\r\n * SubCategory custom HandledProps include 'description' and 'properties'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\r\n { propertyName: \"description\", source: \"Class\" },\r\n { propertyName: \"properties\", source: \"Class\" },\r\n ];\r\n\r\n /**\r\n * SubCategory deserializes 'description' and 'properties'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n public static override deserialize(props: DeserializeEntityArgs): SubCategoryProps {\r\n const elProps = super.deserialize(props) as SubCategoryProps;\r\n elProps.description = JsonUtils.asString(props.row.description);\r\n if (props.row.properties !== '') {\r\n elProps.appearance = JSON.parse(props.row.properties) as SubCategoryAppearance.Props;\r\n } else {\r\n elProps.appearance = undefined;\r\n }\r\n return elProps;\r\n }\r\n\r\n /**\r\n * SubCategory serialize 'description' and 'properties'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n public static override serialize(props: SubCategoryProps, iModel: IModelDb): ECSqlRow {\r\n const inst = super.serialize(props, iModel);\r\n if (props.description !== undefined) {\r\n inst.description = props.description;\r\n }\r\n if (props.appearance !== undefined) {\r\n inst.properties = JSON.stringify(props.appearance);\r\n }\r\n return inst;\r\n }\r\n\r\n public override toJSON(): SubCategoryProps {\r\n const val = super.toJSON() as SubCategoryProps;\r\n val.appearance = this.appearance.toJSON();\r\n if (this.description && this.description.length > 0)\r\n val.description = this.description;\r\n return val;\r\n }\r\n\r\n /** Get the SubCategory's name (its Code value). */\r\n public getSubCategoryName(): string { return this.code.value; }\r\n /** Get the Id of the SubCategory. */\r\n public getSubCategoryId(): Id64String { return this.id; }\r\n /** Get the Id of this SubCategory's parent Category. */\r\n public getCategoryId(): Id64String { return this.parent ? this.parent.id : Id64.invalid; }\r\n /** Check if this is the default SubCategory of its parent Category. */\r\n public get isDefaultSubCategory(): boolean { return IModelDb.getDefaultSubCategoryId(this.getCategoryId()) === this.getSubCategoryId(); }\r\n\r\n /** Create a Code for a SubCategory given a name that is meant to be unique within the scope of the specified parent Category.\r\n * @param iModel The IModel\r\n * @param parentCategoryId The Id of the parent Category that owns the SubCategory and provides the scope for its name.\r\n * @param codeValue The name of the SubCategory\r\n */\r\n public static createCode(iModel: IModelDb, parentCategoryId: CodeScopeProps, codeValue: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.subCategory);\r\n return new Code({ spec: codeSpec.id, scope: parentCategoryId, value: codeValue });\r\n }\r\n\r\n /** Create a new SubCategory\r\n * @param iModelDb The iModel\r\n * @param parentCategoryId Create the new SubCategory as a child of this [[Category]]\r\n * @param name The name of the SubCategory\r\n * @param appearance The appearance settings to use for this SubCategory\r\n * @returns The newly constructed SubCategory element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): SubCategory {\r\n if (appearance instanceof SubCategoryAppearance)\r\n appearance = appearance.toJSON();\r\n\r\n const parentCategory = iModelDb.elements.getElement<Category>(parentCategoryId);\r\n const subCategoryProps: SubCategoryProps = {\r\n classFullName: this.classFullName,\r\n model: parentCategory.model,\r\n parent: new CategoryOwnsSubCategories(parentCategoryId),\r\n code: this.createCode(iModelDb, parentCategoryId, name),\r\n appearance,\r\n };\r\n return new SubCategory(subCategoryProps, iModelDb);\r\n }\r\n\r\n /** Insert a new SubCategory\r\n * @param iModelDb Insert into this iModel\r\n * @param parentCategoryId Insert the new SubCategory as a child of this Category\r\n * @param name The name of the SubCategory\r\n * @param appearance The appearance settings to use for this SubCategory\r\n * @returns The Id of the newly inserted SubCategory element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n */\r\n public static insert(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\r\n const subCategory = this.create(iModelDb, parentCategoryId, name, appearance);\r\n return iModelDb.elements.insertElement(subCategory.toJSON());\r\n }\r\n}\r\n\r\n/** A Category element is the target of the `category` member of [[GeometricElement]].\r\n * @public @preview\r\n */\r\nexport class Category extends DefinitionElement {\r\n public static override get className(): string { return \"Category\"; }\r\n public rank: Rank = Rank.User;\r\n public description?: string;\r\n\r\n protected constructor(props: CategoryProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.rank = JsonUtils.asInt(props.rank);\r\n this.description = JsonUtils.asString(props.description);\r\n }\r\n\r\n /**\r\n * Category custom HandledProps include 'rank' and 'description'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\r\n { propertyName: \"rank\", source: \"Class\" },\r\n { propertyName: \"description\", source: \"Class\" },\r\n ];\r\n\r\n /**\r\n * Category deserializes 'rank' and 'description'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n public static override deserialize(props: DeserializeEntityArgs): CategoryProps {\r\n const elProps = super.deserialize(props) as CategoryProps;\r\n elProps.description = JsonUtils.asString(props.row.description);\r\n elProps.rank = JsonUtils.asInt(props.row.rank);\r\n return elProps;\r\n }\r\n\r\n /**\r\n * Category serialize 'rank' and 'description'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n public static override serialize(props: CategoryProps, iModel: IModelDb): ECSqlRow {\r\n const inst = super.serialize(props, iModel);\r\n if (undefined !== props.description) {\r\n inst.description = props.description;\r\n }\r\n inst.rank = props.rank;\r\n return inst;\r\n }\r\n public override toJSON(): CategoryProps {\r\n const val = super.toJSON() as CategoryProps;\r\n val.rank = this.rank;\r\n if (this.description && this.description.length > 0)\r\n val.description = this.description;\r\n return val;\r\n }\r\n\r\n /** Get the Id of the default SubCategory for this Category. */\r\n public myDefaultSubCategoryId(): Id64String { return IModelDb.getDefaultSubCategoryId(this.id); }\r\n\r\n /** Set the appearance of the default SubCategory for this Category */\r\n public setDefaultAppearance(props: SubCategoryAppearance.Props | SubCategoryAppearance): void {\r\n if (props instanceof SubCategoryAppearance)\r\n props = props.toJSON();\r\n\r\n const subCat = this.iModel.elements.getElement<SubCategory>(this.myDefaultSubCategoryId());\r\n subCat.appearance = new SubCategoryAppearance(props);\r\n this.iModel.elements.updateElement(subCat.toJSON());\r\n }\r\n}\r\n\r\n/** Categorizes 2d GeometricElements.\r\n * @public @preview\r\n */\r\nexport class DrawingCategory extends Category {\r\n public static override get className(): string { return \"DrawingCategory\"; }\r\n\r\n protected constructor(opts: ElementProps, iModel: IModelDb) { super(opts, iModel); }\r\n\r\n /** Get the name of the CodeSpec that is used by DrawingCategory objects. */\r\n public static getCodeSpecName(): string { return BisCodeSpec.drawingCategory; }\r\n\r\n /** Looks up the CategoryId of a DrawingCategory by model and name */\r\n public static queryCategoryIdByName(iModel: IModelDb, scopeModelId: Id64String, categoryName: string): Id64String | undefined {\r\n const code: Code = DrawingCategory.createCode(iModel, scopeModelId, categoryName);\r\n return iModel.elements.queryElementIdByCode(code);\r\n }\r\n\r\n /** Create a Code for a DrawingCategory given a name that is meant to be unique within the scope of the specified DefinitionModel.\r\n * @param iModel The IModel\r\n * @param scopeModelId The Id of the DefinitionModel that contains the DrawingCategory and provides the scope for its name.\r\n * @param codeValue The name of the category\r\n * @return A drawing category Code\r\n */\r\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(DrawingCategory.getCodeSpecName());\r\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\r\n }\r\n\r\n /** Create a new DrawingCategory\r\n * @param iModelDb The iModel\r\n * @param definitionModelId The [[DefinitionModel]]\r\n * @param name The name of the DrawingCategory\r\n * @returns The newly constructed DrawingCategory element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): DrawingCategory {\r\n const categoryProps: CategoryProps = {\r\n classFullName: this.classFullName,\r\n model: definitionModelId,\r\n code: this.createCode(iModelDb, definitionModelId, name),\r\n isPrivate: false,\r\n };\r\n return new DrawingCategory(categoryProps, iModelDb);\r\n }\r\n\r\n /** Insert a new DrawingCategory\r\n * @param iModelDb Insert into this iModel\r\n * @param definitionModelId Insert the new DrawingCategory into this [[DefinitionModel]]\r\n * @param name The name of the DrawingCategory\r\n * @param defaultAppearance The appearance settings to use for the default SubCategory of this DrawingCategory\r\n * @returns The Id of the newly inserted DrawingCategory element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n */\r\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\r\n const category = this.create(iModelDb, definitionModelId, name);\r\n const elements = iModelDb.elements;\r\n category.id = elements.insertElement(category.toJSON());\r\n category.setDefaultAppearance(defaultAppearance);\r\n return category.id;\r\n }\r\n}\r\n\r\n/** Categorizes SpatialElements. See [how to create a SpatialCategory]($docs/learning/backend/CreateElements.md#SpatialCategory).\r\n * @public @preview\r\n */\r\nexport class SpatialCategory extends Category {\r\n public static override get className(): string { return \"SpatialCategory\"; }\r\n protected constructor(opts: ElementProps, iModel: IModelDb) { super(opts, iModel); }\r\n\r\n /** Get the name of the CodeSpec that is used by SpatialCategory objects. */\r\n public static getCodeSpecName(): string { return BisCodeSpec.spatialCategory; }\r\n\r\n /** Looks up the CategoryId of a SpatialCategory by model and name */\r\n public static queryCategoryIdByName(iModel: IModelDb, scopeModelId: Id64String, categoryName: string): Id64String | undefined {\r\n const code: Code = SpatialCategory.createCode(iModel, scopeModelId, categoryName);\r\n return iModel.elements.queryElementIdByCode(code);\r\n }\r\n\r\n /** Create a Code for a SpatialCategory given a name that is meant to be unique within the scope of the specified DefinitionModel.\r\n * @param iModel The IModel\r\n * @param scopeModelId The Id of the DefinitionModel that contains the SpatialCategory and provides the scope for its name.\r\n * @param codeValue The name of the category\r\n * @return A spatial category Code\r\n */\r\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(SpatialCategory.getCodeSpecName());\r\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\r\n }\r\n\r\n /** Create a new SpatialCategory\r\n * @param iModelDb The iModel\r\n * @param definitionModelId The [[DefinitionModel]]\r\n * @param name The name/CodeValue of the SpatialCategory\r\n * @returns The newly constructed SpatialCategory element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): SpatialCategory {\r\n const categoryProps: CategoryProps = {\r\n classFullName: this.classFullName,\r\n model: definitionModelId,\r\n code: this.createCode(iModelDb, definitionModelId, name),\r\n isPrivate: false,\r\n };\r\n return new SpatialCategory(categoryProps, iModelDb);\r\n }\r\n\r\n /** Insert a new SpatialCategory\r\n * @param iModelDb Insert into this iModel\r\n * @param definitionModelId Insert the new SpatialCategory into this DefinitionModel\r\n * @param name The name of the SpatialCategory\r\n * @param defaultAppearance The appearance settings to use for the default SubCategory of this SpatialCategory\r\n * @returns The Id of the newly inserted SpatialCategory element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n */\r\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\r\n const category = this.create(iModelDb, definitionModelId, name);\r\n category.id = iModelDb.elements.insertElement(category.toJSON());\r\n category.setDefaultAppearance(defaultAppearance);\r\n return category.id;\r\n }\r\n}\r\n"]}
|
|
@@ -237,8 +237,8 @@ export class ChangeSummaryManager {
|
|
|
237
237
|
throw new IModelError(IModelStatus.BadArg, "Change Cache file must be attached to iModel.");
|
|
238
238
|
// query instance changes
|
|
239
239
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
240
|
-
const instanceChange = iModel.withPreparedStatement(`SELECT ic.Summary.Id summaryId, s.Name changedInstanceSchemaName, c.Name changedInstanceClassName, ic.ChangedInstance.Id changedInstanceId,
|
|
241
|
-
ic.OpCode, ic.IsIndirect FROM ecchange.change.InstanceChange ic JOIN main.meta.ECClassDef c ON c.ECInstanceId = ic.ChangedInstance.ClassId
|
|
240
|
+
const instanceChange = iModel.withPreparedStatement(`SELECT ic.Summary.Id summaryId, s.Name changedInstanceSchemaName, c.Name changedInstanceClassName, ic.ChangedInstance.Id changedInstanceId,
|
|
241
|
+
ic.OpCode, ic.IsIndirect FROM ecchange.change.InstanceChange ic JOIN main.meta.ECClassDef c ON c.ECInstanceId = ic.ChangedInstance.ClassId
|
|
242
242
|
JOIN main.meta.ECSchemaDef s ON c.Schema.Id = s.ECInstanceId WHERE ic.ECInstanceId =? `,
|
|
243
243
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
244
244
|
(stmt) => {
|