@itwin/core-backend 5.9.0-dev.3 → 5.9.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/lib/cjs/BriefcaseManager.js +3 -3
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/Category.d.ts +37 -7
- package/lib/cjs/Category.d.ts.map +1 -1
- package/lib/cjs/Category.js +33 -42
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +5 -2
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/ChannelControl.d.ts +29 -0
- package/lib/cjs/ChannelControl.d.ts.map +1 -1
- package/lib/cjs/ChannelControl.js.map +1 -1
- package/lib/cjs/CheckpointManager.js +1 -1
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/CodeSpecs.d.ts +32 -3
- package/lib/cjs/CodeSpecs.d.ts.map +1 -1
- package/lib/cjs/CodeSpecs.js +48 -20
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/DisplayStyle.d.ts +18 -3
- package/lib/cjs/DisplayStyle.d.ts.map +1 -1
- package/lib/cjs/DisplayStyle.js +10 -21
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/EditTxn.d.ts +262 -0
- package/lib/cjs/EditTxn.d.ts.map +1 -0
- package/lib/cjs/EditTxn.js +548 -0
- package/lib/cjs/EditTxn.js.map +1 -0
- package/lib/cjs/Element.d.ts +74 -5
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +63 -75
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.d.ts +10 -0
- package/lib/cjs/ElementAspect.d.ts.map +1 -1
- package/lib/cjs/ElementAspect.js +21 -12
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.d.ts +56 -3
- package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
- package/lib/cjs/ElementTreeWalker.js +53 -40
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/ExternalSource.d.ts +11 -2
- package/lib/cjs/ExternalSource.d.ts.map +1 -1
- package/lib/cjs/ExternalSource.js +10 -8
- package/lib/cjs/ExternalSource.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +66 -22
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +174 -288
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +22 -0
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +9 -0
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IpcHost.js +2 -2
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LineStyle.d.ts +47 -7
- package/lib/cjs/LineStyle.d.ts.map +1 -1
- package/lib/cjs/LineStyle.js +38 -33
- package/lib/cjs/LineStyle.js.map +1 -1
- package/lib/cjs/Material.d.ts +8 -1
- package/lib/cjs/Material.d.ts.map +1 -1
- package/lib/cjs/Material.js +6 -12
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.d.ts +59 -20
- package/lib/cjs/Model.d.ts.map +1 -1
- package/lib/cjs/Model.js +38 -80
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/Relationship.d.ts +72 -7
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +39 -21
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/SchemaSync.js +4 -4
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/SheetIndex.d.ts +9 -0
- package/lib/cjs/SheetIndex.d.ts.map +1 -1
- package/lib/cjs/SheetIndex.js +38 -35
- package/lib/cjs/SheetIndex.js.map +1 -1
- package/lib/cjs/StashManager.js +1 -1
- package/lib/cjs/StashManager.js.map +1 -1
- package/lib/cjs/Texture.d.ts +6 -0
- package/lib/cjs/Texture.d.ts.map +1 -1
- package/lib/cjs/Texture.js +6 -14
- package/lib/cjs/Texture.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts +5 -5
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +23 -7
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts +21 -1
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +27 -66
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +14 -6
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.js +33 -27
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
- package/lib/cjs/annotations/TextAnnotationElement.d.ts.map +1 -1
- package/lib/cjs/annotations/TextAnnotationElement.js +6 -5
- package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -1
- package/lib/cjs/core-backend.d.ts +1 -0
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +1 -0
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.d.ts +6 -2
- package/lib/cjs/domains/FunctionalElements.d.ts.map +1 -1
- package/lib/cjs/domains/FunctionalElements.js +8 -13
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/GenericElements.d.ts +11 -4
- package/lib/cjs/domains/GenericElements.d.ts.map +1 -1
- package/lib/cjs/domains/GenericElements.js +13 -24
- package/lib/cjs/domains/GenericElements.js.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.d.ts +15 -0
- package/lib/cjs/internal/ChannelAdmin.d.ts.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.js +5 -3
- package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
- package/lib/cjs/internal/Symbols.d.ts +4 -0
- package/lib/cjs/internal/Symbols.d.ts.map +1 -1
- package/lib/cjs/internal/Symbols.js +5 -1
- package/lib/cjs/internal/Symbols.js.map +1 -1
- package/lib/cjs/internal/annotations/fields.d.ts +3 -2
- package/lib/cjs/internal/annotations/fields.d.ts.map +1 -1
- package/lib/cjs/internal/annotations/fields.js +7 -6
- package/lib/cjs/internal/annotations/fields.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/esm/BriefcaseManager.js +3 -3
- package/lib/esm/BriefcaseManager.js.map +1 -1
- package/lib/esm/Category.d.ts +37 -7
- package/lib/esm/Category.d.ts.map +1 -1
- package/lib/esm/Category.js +33 -42
- package/lib/esm/Category.js.map +1 -1
- package/lib/esm/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/esm/ChangesetECAdaptor.js +5 -2
- package/lib/esm/ChangesetECAdaptor.js.map +1 -1
- package/lib/esm/ChannelControl.d.ts +29 -0
- package/lib/esm/ChannelControl.d.ts.map +1 -1
- package/lib/esm/ChannelControl.js.map +1 -1
- package/lib/esm/CheckpointManager.js +1 -1
- package/lib/esm/CheckpointManager.js.map +1 -1
- package/lib/esm/CodeSpecs.d.ts +32 -3
- package/lib/esm/CodeSpecs.d.ts.map +1 -1
- package/lib/esm/CodeSpecs.js +49 -21
- package/lib/esm/CodeSpecs.js.map +1 -1
- package/lib/esm/DisplayStyle.d.ts +18 -3
- package/lib/esm/DisplayStyle.d.ts.map +1 -1
- package/lib/esm/DisplayStyle.js +10 -21
- package/lib/esm/DisplayStyle.js.map +1 -1
- package/lib/esm/EditTxn.d.ts +262 -0
- package/lib/esm/EditTxn.d.ts.map +1 -0
- package/lib/esm/EditTxn.js +543 -0
- package/lib/esm/EditTxn.js.map +1 -0
- package/lib/esm/Element.d.ts +74 -5
- package/lib/esm/Element.d.ts.map +1 -1
- package/lib/esm/Element.js +64 -76
- package/lib/esm/Element.js.map +1 -1
- package/lib/esm/ElementAspect.d.ts +10 -0
- package/lib/esm/ElementAspect.d.ts.map +1 -1
- package/lib/esm/ElementAspect.js +22 -13
- package/lib/esm/ElementAspect.js.map +1 -1
- package/lib/esm/ElementTreeWalker.d.ts +56 -3
- package/lib/esm/ElementTreeWalker.d.ts.map +1 -1
- package/lib/esm/ElementTreeWalker.js +53 -40
- package/lib/esm/ElementTreeWalker.js.map +1 -1
- package/lib/esm/ExternalSource.d.ts +11 -2
- package/lib/esm/ExternalSource.d.ts.map +1 -1
- package/lib/esm/ExternalSource.js +10 -8
- package/lib/esm/ExternalSource.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +66 -22
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +176 -290
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/IModelHost.d.ts +22 -0
- package/lib/esm/IModelHost.d.ts.map +1 -1
- package/lib/esm/IModelHost.js +9 -0
- package/lib/esm/IModelHost.js.map +1 -1
- package/lib/esm/IpcHost.js +3 -3
- package/lib/esm/IpcHost.js.map +1 -1
- package/lib/esm/LineStyle.d.ts +47 -7
- package/lib/esm/LineStyle.d.ts.map +1 -1
- package/lib/esm/LineStyle.js +38 -33
- package/lib/esm/LineStyle.js.map +1 -1
- package/lib/esm/Material.d.ts +8 -1
- package/lib/esm/Material.d.ts.map +1 -1
- package/lib/esm/Material.js +6 -12
- package/lib/esm/Material.js.map +1 -1
- package/lib/esm/Model.d.ts +59 -20
- package/lib/esm/Model.d.ts.map +1 -1
- package/lib/esm/Model.js +39 -81
- package/lib/esm/Model.js.map +1 -1
- package/lib/esm/Relationship.d.ts +72 -7
- package/lib/esm/Relationship.d.ts.map +1 -1
- package/lib/esm/Relationship.js +40 -22
- package/lib/esm/Relationship.js.map +1 -1
- package/lib/esm/SchemaSync.js +5 -5
- package/lib/esm/SchemaSync.js.map +1 -1
- package/lib/esm/SheetIndex.d.ts +9 -0
- package/lib/esm/SheetIndex.d.ts.map +1 -1
- package/lib/esm/SheetIndex.js +38 -35
- package/lib/esm/SheetIndex.js.map +1 -1
- package/lib/esm/StashManager.js +1 -1
- package/lib/esm/StashManager.js.map +1 -1
- package/lib/esm/Texture.d.ts +6 -0
- package/lib/esm/Texture.d.ts.map +1 -1
- package/lib/esm/Texture.js +6 -14
- package/lib/esm/Texture.js.map +1 -1
- package/lib/esm/TxnManager.d.ts +5 -5
- package/lib/esm/TxnManager.d.ts.map +1 -1
- package/lib/esm/TxnManager.js +23 -7
- package/lib/esm/TxnManager.js.map +1 -1
- package/lib/esm/ViewDefinition.d.ts +21 -1
- package/lib/esm/ViewDefinition.d.ts.map +1 -1
- package/lib/esm/ViewDefinition.js +27 -66
- package/lib/esm/ViewDefinition.js.map +1 -1
- package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +14 -6
- package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
- package/lib/esm/annotations/ElementDrivesTextAnnotation.js +33 -27
- package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
- package/lib/esm/annotations/TextAnnotationElement.d.ts.map +1 -1
- package/lib/esm/annotations/TextAnnotationElement.js +6 -5
- package/lib/esm/annotations/TextAnnotationElement.js.map +1 -1
- package/lib/esm/core-backend.d.ts +1 -0
- package/lib/esm/core-backend.d.ts.map +1 -1
- package/lib/esm/core-backend.js +1 -0
- package/lib/esm/core-backend.js.map +1 -1
- package/lib/esm/domains/FunctionalElements.d.ts +6 -2
- package/lib/esm/domains/FunctionalElements.d.ts.map +1 -1
- package/lib/esm/domains/FunctionalElements.js +8 -13
- package/lib/esm/domains/FunctionalElements.js.map +1 -1
- package/lib/esm/domains/GenericElements.d.ts +11 -4
- package/lib/esm/domains/GenericElements.d.ts.map +1 -1
- package/lib/esm/domains/GenericElements.js +13 -24
- package/lib/esm/domains/GenericElements.js.map +1 -1
- package/lib/esm/internal/ChannelAdmin.d.ts +15 -0
- package/lib/esm/internal/ChannelAdmin.d.ts.map +1 -1
- package/lib/esm/internal/ChannelAdmin.js +6 -4
- package/lib/esm/internal/ChannelAdmin.js.map +1 -1
- package/lib/esm/internal/Symbols.d.ts +4 -0
- package/lib/esm/internal/Symbols.d.ts.map +1 -1
- package/lib/esm/internal/Symbols.js +4 -0
- package/lib/esm/internal/Symbols.js.map +1 -1
- package/lib/esm/internal/annotations/fields.d.ts +3 -2
- package/lib/esm/internal/annotations/fields.d.ts.map +1 -1
- package/lib/esm/internal/annotations/fields.js +7 -6
- package/lib/esm/internal/annotations/fields.js.map +1 -1
- package/lib/esm/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
- package/lib/esm/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/esm/test/AnnotationTestUtils.js.map +1 -1
- package/lib/esm/test/ElementDrivesElement.test.d.ts +20 -19
- package/lib/esm/test/ElementDrivesElement.test.d.ts.map +1 -1
- package/lib/esm/test/ElementDrivesElement.test.js +111 -96
- package/lib/esm/test/ElementDrivesElement.test.js.map +1 -1
- package/lib/esm/test/ElementLRUCache.test.js.map +1 -1
- package/lib/esm/test/IModelHost.test.js +56 -2
- package/lib/esm/test/IModelHost.test.js.map +1 -1
- package/lib/esm/test/IModelTestUtils.d.ts +23 -23
- package/lib/esm/test/IModelTestUtils.d.ts.map +1 -1
- package/lib/esm/test/IModelTestUtils.js +466 -449
- package/lib/esm/test/IModelTestUtils.js.map +1 -1
- package/lib/esm/test/PropertyDb.test.js +2 -2
- package/lib/esm/test/PropertyDb.test.js.map +1 -1
- package/lib/esm/test/SquashSchemaAndDataChanges.test.js +27 -18
- package/lib/esm/test/SquashSchemaAndDataChanges.test.js.map +1 -1
- package/lib/esm/test/TestChangeSetUtility.d.ts.map +1 -1
- package/lib/esm/test/TestChangeSetUtility.js +11 -7
- package/lib/esm/test/TestChangeSetUtility.js.map +1 -1
- package/lib/esm/test/TestEditTxn.d.ts +8 -0
- package/lib/esm/test/TestEditTxn.d.ts.map +1 -0
- package/lib/esm/test/TestEditTxn.js +34 -0
- package/lib/esm/test/TestEditTxn.js.map +1 -0
- package/lib/esm/test/TestUtils.d.ts +1 -0
- package/lib/esm/test/TestUtils.d.ts.map +1 -1
- package/lib/esm/test/TestUtils.js +8 -1
- package/lib/esm/test/TestUtils.js.map +1 -1
- package/lib/esm/test/annotations/Fields.test.js +82 -90
- 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/TextAnnotation.test.js +156 -99
- package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
- package/lib/esm/test/annotations/TextBlock.test.js +5 -3
- 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.map +1 -1
- package/lib/esm/test/categories/Category.test.js +63 -3
- package/lib/esm/test/categories/Category.test.js.map +1 -1
- package/lib/esm/test/codespec/CodeSpec.test.js +88 -5
- package/lib/esm/test/codespec/CodeSpec.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECDb.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlAst.test.js +3 -2
- package/lib/esm/test/ecdb/ECSqlAst.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlQuery.test.js +2 -2
- package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlStatement.test.js +0 -1
- package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
- package/lib/esm/test/ecdb/QueryReaders.test.js +17 -14
- package/lib/esm/test/ecdb/QueryReaders.test.js.map +1 -1
- package/lib/esm/test/ecdb/SqliteStatement.test.js +2 -2
- package/lib/esm/test/ecdb/SqliteStatement.test.js.map +1 -1
- package/lib/esm/test/ecsql/dataset/ECSqlDatasets.d.ts.map +1 -1
- package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js +30 -28
- package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js.map +1 -1
- 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 +159 -143
- package/lib/esm/test/element/DeleteDefinitionElements.test.js.map +1 -1
- package/lib/esm/test/element/ElementAspect.test.js +68 -60
- package/lib/esm/test/element/ElementAspect.test.js.map +1 -1
- package/lib/esm/test/element/ElementDependencyGraph.test.d.ts.map +1 -1
- package/lib/esm/test/element/ElementDependencyGraph.test.js +51 -43
- package/lib/esm/test/element/ElementDependencyGraph.test.js.map +1 -1
- package/lib/esm/test/element/ElementRoundTrip.test.js +37 -38
- package/lib/esm/test/element/ElementRoundTrip.test.js.map +1 -1
- package/lib/esm/test/element/ExcludedElements.test.js +2 -2
- package/lib/esm/test/element/ExcludedElements.test.js.map +1 -1
- package/lib/esm/test/element/ExternalSource.test.js +40 -38
- package/lib/esm/test/element/ExternalSource.test.js.map +1 -1
- package/lib/esm/test/element/NullStructArray.test.js +10 -9
- package/lib/esm/test/element/NullStructArray.test.js.map +1 -1
- package/lib/esm/test/element/ProjectInformationRecord.test.js +5 -2
- package/lib/esm/test/element/ProjectInformationRecord.test.js.map +1 -1
- package/lib/esm/test/element/SheetInformationAspect.test.js +43 -11
- package/lib/esm/test/element/SheetInformationAspect.test.js.map +1 -1
- package/lib/esm/test/element/UrlLink.test.js +2 -2
- package/lib/esm/test/element/UrlLink.test.js.map +1 -1
- package/lib/esm/test/font/IModelDbFonts.test.js +87 -73
- package/lib/esm/test/font/IModelDbFonts.test.js.map +1 -1
- package/lib/esm/test/hubaccess/ApplyChangeset.test.js +164 -125
- package/lib/esm/test/hubaccess/ApplyChangeset.test.js.map +1 -1
- package/lib/esm/test/hubaccess/BriefcaseManager.test.js +2 -4
- package/lib/esm/test/hubaccess/BriefcaseManager.test.js.map +1 -1
- package/lib/esm/test/hubaccess/Rebase.test.js +313 -247
- package/lib/esm/test/hubaccess/Rebase.test.js.map +1 -1
- package/lib/esm/test/hubaccess/SemanticRebase.test.js +322 -247
- package/lib/esm/test/hubaccess/SemanticRebase.test.js.map +1 -1
- package/lib/esm/test/imodel/Code.test.js +31 -31
- package/lib/esm/test/imodel/Code.test.js.map +1 -1
- package/lib/esm/test/imodel/ElementTreeWalker.test.js +57 -48
- package/lib/esm/test/imodel/ElementTreeWalker.test.js.map +1 -1
- package/lib/esm/test/imodel/IModel.test.js +419 -344
- package/lib/esm/test/imodel/IModel.test.js.map +1 -1
- package/lib/esm/test/imodel/ProjectExtents.test.js +2 -2
- package/lib/esm/test/imodel/ProjectExtents.test.js.map +1 -1
- package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js.map +1 -1
- package/lib/esm/test/incrementalSchemaLocater/TestContext.d.ts.map +1 -1
- package/lib/esm/test/incrementalSchemaLocater/TestContext.js +2 -2
- package/lib/esm/test/incrementalSchemaLocater/TestContext.js.map +1 -1
- package/lib/esm/test/index.d.ts +1 -0
- package/lib/esm/test/index.d.ts.map +1 -1
- package/lib/esm/test/index.js +1 -0
- package/lib/esm/test/index.js.map +1 -1
- package/lib/esm/test/schema/ClassRegistry.test.js +23 -22
- package/lib/esm/test/schema/ClassRegistry.test.js.map +1 -1
- package/lib/esm/test/schema/FunctionalDomain.test.js +36 -34
- package/lib/esm/test/schema/FunctionalDomain.test.js.map +1 -1
- package/lib/esm/test/schema/GenericDomain.test.js +114 -94
- package/lib/esm/test/schema/GenericDomain.test.js.map +1 -1
- package/lib/esm/test/schema/IModelSchemaContext.test.js +2 -1
- package/lib/esm/test/schema/IModelSchemaContext.test.js.map +1 -1
- package/lib/esm/test/schema/SchemaImportCallbacks.test.js +207 -192
- package/lib/esm/test/schema/SchemaImportCallbacks.test.js.map +1 -1
- package/lib/esm/test/sheetindex/SheetIndex.test.d.ts +1 -3
- package/lib/esm/test/sheetindex/SheetIndex.test.d.ts.map +1 -1
- package/lib/esm/test/sheetindex/SheetIndex.test.js +312 -247
- package/lib/esm/test/sheetindex/SheetIndex.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangeMerge.test.js +101 -82
- package/lib/esm/test/standalone/ChangeMerge.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangesetReader.test.js +114 -85
- package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
- package/lib/esm/test/standalone/DisplayStyle.test.js +43 -40
- package/lib/esm/test/standalone/DisplayStyle.test.js.map +1 -1
- package/lib/esm/test/standalone/Drawing.test.js +4 -3
- package/lib/esm/test/standalone/Drawing.test.js.map +1 -1
- package/lib/esm/test/standalone/EditTxn.test.d.ts +2 -0
- package/lib/esm/test/standalone/EditTxn.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/EditTxn.test.js +219 -0
- package/lib/esm/test/standalone/EditTxn.test.js.map +1 -0
- package/lib/esm/test/standalone/ElementMesh.test.js +16 -13
- package/lib/esm/test/standalone/ElementMesh.test.js.map +1 -1
- package/lib/esm/test/standalone/ExportGraphics.test.js +26 -20
- package/lib/esm/test/standalone/ExportGraphics.test.js.map +1 -1
- package/lib/esm/test/standalone/GeometryChangeEvents.test.js +11 -15
- package/lib/esm/test/standalone/GeometryChangeEvents.test.js.map +1 -1
- package/lib/esm/test/standalone/GeometryStream.test.js +212 -165
- package/lib/esm/test/standalone/GeometryStream.test.js.map +1 -1
- package/lib/esm/test/standalone/HubMock.test.js +31 -25
- package/lib/esm/test/standalone/HubMock.test.js.map +1 -1
- package/lib/esm/test/standalone/IModelLimits.test.js +11 -8
- package/lib/esm/test/standalone/IModelLimits.test.js.map +1 -1
- package/lib/esm/test/standalone/IModelWrite.test.d.ts +2 -2
- package/lib/esm/test/standalone/IModelWrite.test.d.ts.map +1 -1
- package/lib/esm/test/standalone/IModelWrite.test.js +184 -142
- package/lib/esm/test/standalone/IModelWrite.test.js.map +1 -1
- package/lib/esm/test/standalone/InlineGeometryPartReferences.test.js +25 -22
- package/lib/esm/test/standalone/InlineGeometryPartReferences.test.js.map +1 -1
- package/lib/esm/test/standalone/IntegrityCheck.test.js +20 -18
- package/lib/esm/test/standalone/IntegrityCheck.test.js.map +1 -1
- package/lib/esm/test/standalone/MergeConflict.test.d.ts +2 -2
- package/lib/esm/test/standalone/MergeConflict.test.d.ts.map +1 -1
- package/lib/esm/test/standalone/MergeConflict.test.js +49 -33
- package/lib/esm/test/standalone/MergeConflict.test.js.map +1 -1
- package/lib/esm/test/standalone/RenderMaterialElement.test.js +5 -5
- package/lib/esm/test/standalone/RenderMaterialElement.test.js.map +1 -1
- package/lib/esm/test/standalone/RenderTimeline.test.js +3 -2
- package/lib/esm/test/standalone/RenderTimeline.test.js.map +1 -1
- package/lib/esm/test/standalone/SectionDrawing.test.js +7 -7
- package/lib/esm/test/standalone/SectionDrawing.test.js.map +1 -1
- package/lib/esm/test/standalone/ServerBasedLocks.test.js +21 -19
- package/lib/esm/test/standalone/ServerBasedLocks.test.js.map +1 -1
- package/lib/esm/test/standalone/Settings.test.js +7 -4
- package/lib/esm/test/standalone/Settings.test.js.map +1 -1
- package/lib/esm/test/standalone/SettingsSchemas.test.js +2 -1
- package/lib/esm/test/standalone/SettingsSchemas.test.js.map +1 -1
- package/lib/esm/test/standalone/SnapshotDb.test.js +3 -1
- package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
- package/lib/esm/test/standalone/StandaloneDb.test.js +7 -6
- package/lib/esm/test/standalone/StandaloneDb.test.js.map +1 -1
- package/lib/esm/test/standalone/Texture.test.js +5 -4
- package/lib/esm/test/standalone/Texture.test.js.map +1 -1
- package/lib/esm/test/standalone/TileCache.test.d.ts.map +1 -1
- package/lib/esm/test/standalone/TileCache.test.js +5 -3
- package/lib/esm/test/standalone/TileCache.test.js.map +1 -1
- package/lib/esm/test/standalone/TileTree.test.js +35 -31
- package/lib/esm/test/standalone/TileTree.test.js.map +1 -1
- package/lib/esm/test/standalone/TxnManager.test.js +700 -653
- package/lib/esm/test/standalone/TxnManager.test.js.map +1 -1
- package/lib/esm/test/standalone/ViewDefinition.test.js +295 -229
- package/lib/esm/test/standalone/ViewDefinition.test.js.map +1 -1
- package/lib/esm/test/standalone/Workspace.test.js +25 -23
- package/lib/esm/test/standalone/Workspace.test.js.map +1 -1
- package/package.json +12 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Relationship.js","sourceRoot":"","sources":["../../src/Relationship.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+E;AAC/E,oDAAyG;AAEzG,qCAAkC;AAElC,gDAA+C;AAC/C,gEAA6D;AAI7D;;GAEG;AACH,MAAa,YAAa,SAAQ,eAAM;IAC/B,MAAM,KAAc,SAAS,KAAa,OAAO,cAAc,CAAC,CAAC,CAAC;IACzD,QAAQ,CAAa;IACrB,QAAQ,CAAa;IAErC,YAAsB,KAAwB,EAAE,MAAgB;QAC9D,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,mBAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,CAAC,QAAQ,GAAG,mBAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAEe,MAAM;QACpB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAuB,CAAC;QAChD,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC7B,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC7B,OAAO,GAAG,CAAC;IACb,CAAC;IAED,gHAAgH;IAChG,KAAK,CAAC,WAAW;QAC/B,IAAI,IAAI,CAAC,SAAS,IAAI,qCAAiB,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YA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C,CAAC;gBAClC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBAClC,OAAO,uBAAQ,CAAC,aAAa,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAO,CAAC,CAAC,CAAC,SAAS,CAAC;YACjF,CAAC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,SAAS,KAAK,KAAK,EAAE,CAAC;YACxB,KAAK,CAAC,aAAa,GAAI,KAAa,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACI,WAAW,CAAyB,eAAuB,EAAE,QAAsC;QACxG,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAI,IAAI,CAAC,gBAAgB,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC3F,CAAC;IAED;;;;;;OAMG;IACI,cAAc,CAAyB,gBAAwB,EAAE,QAAsC;QAC5G,MAAM,iBAAiB,GAAG,IAAI,CAAC,mBAAmB,CAAoB,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QAClG,OAAO,SAAS,KAAK,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1G,CAAC;CACF;AAjHD,sCAiHC","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 Relationships\n */\n\nimport { DbResult, Id64, Id64String, IModelStatus } from \"@itwin/core-bentley\";\nimport { EntityReferenceSet, IModelError, RelationshipProps, SourceAndTarget } from \"@itwin/core-common\";\nimport { ECSqlStatement } from \"./ECSqlStatement\";\nimport { Entity } from \"./Entity\";\nimport { IModelDb } from \"./IModelDb\";\nimport { _nativeDb } from \"./internal/Symbols\";\nimport { RelationshipClass } from \"@itwin/ecschema-metadata\";\n\nexport type { SourceAndTarget, RelationshipProps } from \"@itwin/core-common\"; // for backwards compatibility\n\n/** Base class for all link table ECRelationships\n * @public\n */\nexport class Relationship extends Entity {\n public static override get className(): string { return \"Relationship\"; }\n public readonly sourceId: Id64String;\n public readonly targetId: Id64String;\n\n protected constructor(props: RelationshipProps, iModel: IModelDb) {\n super(props, iModel);\n this.sourceId = Id64.fromJSON(props.sourceId);\n this.targetId = Id64.fromJSON(props.targetId);\n }\n\n public override toJSON(): RelationshipProps {\n const val = super.toJSON() as RelationshipProps;\n val.sourceId = this.sourceId;\n val.targetId = this.targetId;\n return val;\n }\n\n /** Query metadata for this relationship class from the iModel's schema. Returns cached metadata if available.*/\n public override async getMetaData(): Promise<RelationshipClass> {\n if (this._metadata && RelationshipClass.isRelationshipClass(this._metadata)) {\n return this._metadata;\n }\n\n const relationship = await this.iModel.schemaContext.getSchemaItem(this.schemaItemKey, RelationshipClass);\n if (relationship !== undefined) {\n this._metadata = relationship;\n return this._metadata;\n } else {\n throw new Error(`Cannot get metadata for ${this.classFullName}`);\n }\n }\n\n /**\n * Callback invoked by saveChanges on an ElementDrivesElement relationship when its input has changed or is the output of some upstream relationship whose input has changed.\n * This callback is invoked after the input element has been processed by upstream relationships.\n * A subclass of ElementDrivesElement can re-implement this static method to take some action. onRootChanged may modify the output element only.\n * @param _props The ElementDrivesElement relationship instance.\n * @param _iModel The iModel\n */\n public static onRootChanged(_props: RelationshipProps, _iModel: IModelDb): void { }\n\n /**\n * Callback invoked by saveChanges on an ElementDrivesElement relationship when the relationship instance has been deleted.\n * A subclass of ElementDrivesElement can re-implement this static method to take some action.\n * @param _props The deleted ElementDrivesElement relationship instance.\n * @param _iModel The iModel\n */\n public static onDeletedDependency(_props: RelationshipProps, _iModel: IModelDb): void { }\n\n /** Insert this Relationship into the iModel. */\n public insert(): Id64String { return this.id = this.iModel.relationships.insertInstance(this.toJSON()); }\n /** Update this Relationship in the iModel. */\n public update() { this.iModel.relationships.updateInstance(this.toJSON()); }\n /** Delete this Relationship from the iModel. */\n public delete() { this.iModel.relationships.deleteInstance(this.toJSON()); }\n\n public static getInstance<T extends Relationship>(iModel: IModelDb, criteria: Id64String | SourceAndTarget): T { return iModel.relationships.getInstance(this.classFullName, criteria); }\n}\n\n/** A Relationship where one Element refers to another Element\n * @public\n */\nexport class ElementRefersToElements extends Relationship {\n public static override get className(): string { return \"ElementRefersToElements\"; }\n /** Create an instance of the Relationship.\n * @param iModel The iModel that will contain the relationship\n * @param sourceId The sourceId of the relationship, that is, the driver element\n * @param targetId The targetId of the relationship, that is, the driven element\n * @return an instance of the specified class.\n */\n public static create<T extends ElementRefersToElements>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String): T {\n return iModel.relationships.createInstance({ sourceId, targetId, classFullName: this.classFullName }) as T;\n }\n /** Insert a new instance of the Relationship.\n * @param iModel The iModel that will contain the relationship\n * @param sourceId The sourceId of the relationship, that is, the driver element\n * @param targetId The targetId of the relationship, that is, the driven element\n * @return The Id of the inserted Relationship.\n */\n public static insert<T extends ElementRefersToElements>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String): Id64String {\n const relationship: T = this.create(iModel, sourceId, targetId);\n return iModel.relationships.insertInstance(relationship.toJSON());\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n referenceIds.addElement(this.sourceId);\n referenceIds.addElement(this.targetId);\n }\n}\n\n/** Relates a [[DrawingGraphic]] to the [[Element]] that it represents\n * @public\n */\nexport class DrawingGraphicRepresentsElement extends ElementRefersToElements {\n public static override get className(): string { return \"DrawingGraphicRepresentsElement\"; }\n}\n\n/** Relates a [[GraphicalElement3d]] to the [[Element]] that it represents\n * @public\n */\nexport class GraphicalElement3dRepresentsElement extends ElementRefersToElements {\n public static override get className(): string { return \"GraphicalElement3dRepresentsElement\"; }\n}\n\n/** Relates a [[SynchronizationConfigLink]] to N [[ExternalSource]] instances.\n * Each relationship instance represents an external source processed by the synchronization configuration.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\n * @beta\n */\nexport class SynchronizationConfigProcessesSources extends ElementRefersToElements {\n public static override get className(): string { return \"SynchronizationConfigProcessesSources\"; }\n}\n\n/** Relates a [[SynchronizationConfigLink]] to *root* [[ExternalSource]] instances.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\n * @beta\n */\nexport class SynchronizationConfigSpecifiesRootSources extends SynchronizationConfigProcessesSources {\n public static override get className(): string { return \"SynchronizationConfigSpecifiesRootSources\"; }\n}\n\n/** Properties that are common to all types of link table ECRelationships\n * @public\n */\nexport interface ElementGroupsMembersProps extends RelationshipProps {\n memberPriority: number;\n}\n\n/** An ElementRefersToElements relationship where one Element *groups* a set of other Elements.\n * @public\n */\nexport class ElementGroupsMembers extends ElementRefersToElements {\n public static override get className(): string { return \"ElementGroupsMembers\"; }\n public memberPriority: number;\n\n constructor(props: ElementGroupsMembersProps, iModel: IModelDb) {\n super(props, iModel);\n this.memberPriority = props.memberPriority;\n }\n\n public static override create<T extends ElementRefersToElements>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String, memberPriority: number = 0): T {\n const props: ElementGroupsMembersProps = { sourceId, targetId, memberPriority, classFullName: this.classFullName };\n return iModel.relationships.createInstance(props) as T;\n }\n}\n\n/** Relates a [[DefinitionGroup]] to its [[DefinitionElement]] members.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.10\n * @public\n */\nexport class DefinitionGroupGroupsDefinitions extends ElementGroupsMembers {\n public static override get className(): string { return \"DefinitionGroupGroupsDefinitions\"; }\n}\n\n/** Represents group membership where the group Element (and its properties) impart information about the member Elements above mere membership.\n * Implies that properties of the group should be considered as properties of its members.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.11\n * @public\n */\nexport class GroupImpartsToMembers extends ElementGroupsMembers {\n public static override get className(): string { return \"GroupImpartsToMembers\"; }\n}\n\n/** Relates an [[ExternalSourceGroup]] to its [[ExternalSource]] members.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\n * @beta\n */\nexport class ExternalSourceGroupGroupsSources extends ElementGroupsMembers {\n public static override get className(): string { return \"ExternalSourceGroupGroupsSources\"; }\n}\n\n/** Properties that are common to all types of ElementDrivesElements\n * @beta\n */\nexport interface ElementDrivesElementProps extends RelationshipProps {\n status: number;\n priority: number;\n}\n\n/** A Relationship indicating that one Element *drives* another Element.\n * An ElementDrivesElement relationship defines a one-way \"driving\" relationship from the source to the target.\n * When the source of an ElementDrivesElement relationship changes, the ElementDrivesElement itself can get a callback, and both the source and target elements can get callbacks.\n * By inserting ElementDrivesElement relationships, an app can create and store an acyclic directed graph of dependencies between elements.\n *\n * # Defining dependencies\n * Create an ElementDrivesElement relationship to specify that the source element drives the target element.\n * For example, to specify that element e1 drives element e2, create a relationship between them like this:\n * ```ts\n * const ede = ElementDrivesElement.create(iModel, e1id, e2id);\n * ede.insert();\n * ```\n * This creates a persistent relationship. The fact that e1 drives e2 is persisted in the iModel.\n *\n * # Defining dependency graphs\n * When you create multiple ElementDrivesElement relationships, you create a network of dependencies. The target of one may be the source of another.\n * A change in the content of an DgnElement can therefore trigger changes to many downstream elements.\n *\n * For example, to make element e1 drive element e2 and e2 drive another element, e3, create two relationships like this:\n * ```ts\n * const ede12 = ElementDrivesElement.create(iModel, e1id, e2id);\n * const ede23 = ElementDrivesElement.create(iModel, e2id, e3id);\n * ede12.insert();\n * ede23.insert();\n * ```\n * Those two relationships create this graph:\n * ```\n * e1 --> e2 --> e3\n * ```\n * Where the \"-->\" is meant to represent a driving relationship.\n *\n * The order in which you create the relationships does not matter.\n * The graph indicates that e3 depends on e2 and e2 depends on e1.\n *\n * An ElementDrivesElement relationship is between one source element and one target element.\n * Many ElementDrivesElement relationships can point to a given element, and many can point out of it.\n * Thus, you can define many:many relationships.\n * For example:\n * ```ts\n * const ede12 = ElementDrivesElement.create(iModel, e1id, e2id);\n * const ede112 = ElementDrivesElement.create(iModel, e11id, e2id);\n * const ede23 = ElementDrivesElement.create(iModel, e2id, e3id);\n * const ede231 = ElementDrivesElement.create(iModel, e2id, e31id);\n * ede12.insert();\n * ede112.insert();\n * ede23.insert();\n * ede231.insert();\n * ```\n * Creates this graph:\n * ```\n * e1 e3\n * \\ /\n * e2\n * / \\\n * e11 e31\n * ```\n * e2 depends on both e1 and e11. e2 then drives e3 and e31.\n *\n * In an ElementDrivesElement dependency graph, the relationships are the \"edges\" and the Elements are the \"nodes\".\n * The following terms are used when referring to the elements (nodes) in a dependency graph:\n * * Inputs - The sources of all edges that point to the element. This includes all upstream elements that flow into the element.\n * * Outputs - The targets of all edges that point out of the element. This includes all downstream elements.\n *\n * # Subgraph Processing\n * When changes are made, only the part of the overall graph that is affected will be processed. So, for example,\n * suppose we have this graph:\n * ```\n * e1 --> e2 --> e3\n * ```\n * If e1 changes, then the subgraph to be processed is equal to the full graph, as shown.\n *\n * If only e2 changes, then the subgraph to be processed is just:\n * ```\n * e2 --> e3\n * ```\n * If only e3 changes, then the subgraph consists of e3 by itself.\n *\n * Returning to the second example above, suppose we have this graph:\n * ```\n * e1 e3\n * \\ /\n * e2\n * / \\\n * e11 e31\n * ```\n * If e1 is changed, the affected subgraph is:\n * ```\n * e1 e3\n * \\ /\n * e2\n * \\\n * e31\n * ```\n * If e2 is changed, the affected subgraph is:\n * ```\n * e3\n * /\n * e2\n * \\\n * e31\n * ```\n * # Callbacks\n * Once the affected subgraph to process is found, it propagates changes through it by making callbacks.\n * Classes for both elements (nodes) and ElementDrivesElements relationships (edges) can receive callbacks.\n *\n * ## ElementDrivesElement Callbacks\n * The following callbacks are invoked on ElementDrivesElement relationship classes (edges):\n * * onRootChanged\n * * onDeletedDependency\n *\n * Note that these are static methods. Their default implementations do nothing.\n * To receive and act on these callbacks, a domain should define a subclass of ElementDrivesElement and use that to create relationships.\n * The subclass should then implement the callbacks that it would like to act on.\n *\n * A ElementDrivesElement subclass callback is expected to make changes to the output element only!\n *\n * ## Element Callbacks\n * The following callbacks are invoked on Element classes (nodes):\n * * Element.onBeforeOutputsHandled\n * * Element.onAllInputsHandled\n *\n * ## Order\n * Callbacks are invoked by BriefcaseDb.saveChanges.\n * They are invoked in dependency (topological) order: driving elements first, then driven elements.\n *\n * Each callback is invoked only once. No matter how many times a given element was changed during the transaction,\n * a callback such as ElementDrivesElement.onRootChanged will be invoked only once.\n * In the same way, no matter how many of its inputs were changed, a callback such as Element.onAllInputsHandled will be\n * invoked only once.\n *\n * For example, suppose we have a graph:\n * ```\n * e1 --> e2 --> e3\n * ```\n *\n * Suppose that e1 is directly modified. No callbacks are made at that time.\n * Later, when BriefcaseDb.saveChanges is called, the following callbacks are made, in order:\n * 1. Element.onBeforeOutputsHandled e1\n * 1. ElementDrivesElement.onRootChanged e1->e2\n * 1. Element.onAllInputsHandled e2\n * 1. ElementDrivesElement.onRootChanged e2->e3\n * 1. Element.onAllInputsHandled e3\n *\n * Suppose that e3 is modified directly and BriefcaseDb.saveChanges is called.\n * Since no input to a relationship was changed, the sub-graph will be empty, and no callbacks will be made.\n *\n * Returning to the second example above, suppose we have this graph:\n * ```\n * e1 e3\n * \\ /\n * e2\n * / \\\n * e11 e31\n * ```\n * If e1 is changed and BriefcaseDb.saveChanges is called, the subgraph is:\n * ```\n * e1 e3\n * \\ /\n * e2\n * \\\n * e31\n * ```\n * The callbacks are:\n * 1. Element.onBeforeOutputsHandled e1\n * 1. ElementDrivesElement.onRootChanged e1->e2\n * 1. Element.onAllInputsHandled e2\n * 1. ElementDrivesElement.onRootChanged e2->e3\n * 1. Element.onAllInputsHandled e3\n * 1. ElementDrivesElement.onRootChanged e2->e31\n * 1. Element.onAllInputsHandled e31\n *\n * (The ElementDrivesElement.)\n *\n * #Errors\n * Circular dependencies are not permitted. If a cycle is detected, that is treated as a fatal error. All ElementDrivesElement relationships\n * involved in a cycle will have their status set to 1, indicating a failure.\n *\n * A callback may call txnManager.reportError to reject an invalid change. It can classify the error as fatal or just a warning.\n * A callback make set the status value of an ElementDrivesElement instance to 1 to indicate a processing failure in that edge.\n *\n * After BriefcaseDb.saveChanges is called, an app should check db.txns.validationErrors and db.txns.hasFatalError to find out if graph-evaluation failed.\n *\n * @beta\n */\nexport class ElementDrivesElement extends Relationship {\n public static override get className(): string { return \"ElementDrivesElement\"; }\n /** Relationship status\n * * 0 indicates no errors. Set after a successful evaluation.\n * * 1 indicates that this driving relationship could not be evaluated. The callback itself can set this to indicate that it failed to process the input changes. Also, it is set if the relationship is part of a circular dependency.\n * * 0x80 The app or callback can set this to indicate to not propagate changes through this relationship.\n */\n public status: number;\n /** Affects the order in which relationships are processed in the case where two relationships have the same output. */\n public priority: number;\n\n protected constructor(props: ElementDrivesElementProps, iModel: IModelDb) {\n super(props, iModel);\n this.status = props.status;\n this.priority = props.priority;\n }\n\n public static create<T extends ElementDrivesElement>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String, priority: number = 0): T {\n const props: ElementDrivesElementProps = { sourceId, targetId, priority, status: 0, classFullName: this.classFullName };\n return iModel.relationships.createInstance(props) as T;\n }\n\n public override toJSON(): ElementDrivesElementProps {\n const props = super.toJSON() as ElementDrivesElementProps;\n props.status = this.status;\n props.priority = this.priority;\n return props;\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n referenceIds.addElement(this.sourceId);\n referenceIds.addElement(this.targetId);\n }\n}\n\n/** The third (and last) possible link-table relationship base class in an iModel.\n * Has no external use, but is included for completeness of the [Entity.collectReferenceIds]($backend)\n * implementations for link-table relationships. Generating the types of the source and target automatically would require\n * coupling this package with ecschema-metadata which we do not want to do.\n * @internal\n */\nexport class ModelSelectorRefersToModels extends Relationship {\n public static override get className(): string { return \"ModelSelectorRefersToModels\"; }\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n referenceIds.addElement(this.sourceId);\n referenceIds.addModel(this.targetId);\n }\n}\n\n/** Manages [[Relationship]]s.\n * @public\n */\nexport class Relationships {\n private _iModel: IModelDb;\n\n /** @internal */\n public constructor(iModel: IModelDb) { this._iModel = iModel; }\n\n /** Create a new instance of a Relationship.\n * @param props The properties of the new Relationship.\n * @throws [[IModelError]] if there is a problem creating the Relationship.\n */\n public createInstance(props: RelationshipProps): Relationship { return this._iModel.constructEntity<Relationship>(props); }\n\n /** Check classFullName to ensure it is a link table relationship class. */\n private checkRelationshipClass(classFullName: string) {\n if (!this._iModel[_nativeDb].isLinkTableRelationship(classFullName.replace(\".\", \":\"))) {\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Class '${classFullName}' must be a relationship class and it should be subclass of BisCore:ElementRefersToElements or BisCore:ElementDrivesElement.`);\n }\n }\n\n /** Insert a new relationship instance into the iModel. The relationship provided must be subclass of BisCore:ElementRefersToElements or BisCore:ElementDrivesElement.\n * @param props The properties of the new relationship.\n * @returns The Id of the newly inserted relationship.\n * @note The id property of the props object is set as a side effect of this function.\n */\n public insertInstance(props: RelationshipProps): Id64String {\n this.checkRelationshipClass(props.classFullName);\n return props.id = this._iModel[_nativeDb].insertLinkTableRelationship(props);\n }\n\n /** Update the properties of an existing relationship instance in the iModel.\n * @param props the properties of the relationship instance to update. Any properties that are not present will be left unchanged.\n */\n public updateInstance(props: RelationshipProps): void {\n this._iModel[_nativeDb].updateLinkTableRelationship(props);\n }\n\n /** Delete an Relationship instance from this iModel. */\n public deleteInstance(props: RelationshipProps): void {\n this._iModel[_nativeDb].deleteLinkTableRelationship(props);\n }\n\n /** Delete multiple Relationship instances from this iModel.\n * @param props The properties of the relationship instances to delete.\n * @remarks This method handles bulk deletion of relationships and supports mixed collections containing instances from different relationship classes.\n */\n public deleteInstances(props: ReadonlyArray<RelationshipProps>): void {\n this._iModel[_nativeDb].deleteLinkTableRelationships(props);\n }\n\n /** Get the props of a Relationship instance\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\n * @param criteria Either the relationship instanceId or the source and target Ids\n * @throws [IModelError]($common) if the relationship is not found or cannot be loaded.\n * @see tryGetInstanceProps\n */\n public getInstanceProps<T extends RelationshipProps>(relClassFullName: string, criteria: Id64String | SourceAndTarget): T {\n const relationshipProps = this.tryGetInstanceProps<T>(relClassFullName, criteria);\n if (undefined === relationshipProps) {\n throw new IModelError(IModelStatus.NotFound, \"Relationship not found\");\n }\n return relationshipProps;\n }\n\n /** Get the props of a Relationship instance\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\n * @param criteria Either the relationship instanceId or the source and target Ids\n * @returns The RelationshipProps or `undefined` if the relationship is not found.\n * @note Useful for cases when a relationship may or may not exist and throwing an `Error` would be overkill.\n * @see getInstanceProps\n */\n public tryGetInstanceProps<T extends RelationshipProps>(relClassFullName: string, criteria: Id64String | SourceAndTarget): T | undefined {\n let props: T | undefined;\n if (typeof criteria === \"string\") {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n props = this._iModel.withPreparedStatement(`SELECT * FROM ${relClassFullName} WHERE ecinstanceid=?`, (stmt: ECSqlStatement) => {\n stmt.bindId(1, criteria);\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getRow() as T : undefined;\n });\n } else {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n props = this._iModel.withPreparedStatement(`SELECT * FROM ${relClassFullName} WHERE SourceECInstanceId=? AND TargetECInstanceId=?`, (stmt: ECSqlStatement) => {\n stmt.bindId(1, criteria.sourceId);\n stmt.bindId(2, criteria.targetId);\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getRow() as T : undefined;\n });\n }\n if (undefined !== props) {\n props.classFullName = (props as any).className.replace(\".\", \":\");\n }\n return props;\n }\n\n /** Get a Relationship instance\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\n * @param criteria Either the relationship instanceId or the source and target Ids\n * @throws [IModelError]($common) if the relationship is not found or cannot be loaded.\n * @see tryGetInstance\n */\n public getInstance<T extends Relationship>(relClassSqlName: string, criteria: Id64String | SourceAndTarget): T {\n return this._iModel.constructEntity<T>(this.getInstanceProps(relClassSqlName, criteria));\n }\n\n /** Get a Relationship instance\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\n * @param criteria Either the relationship instanceId or the source and target Ids\n * @returns The relationship or `undefined` if the relationship is not found.\n * @note Useful for cases when a relationship may or may not exist and throwing an `Error` would be overkill.\n * @see getInstance\n */\n public tryGetInstance<T extends Relationship>(relClassFullName: string, criteria: Id64String | SourceAndTarget): T | undefined {\n const relationshipProps = this.tryGetInstanceProps<RelationshipProps>(relClassFullName, criteria);\n return undefined !== relationshipProps ? this._iModel.constructEntity<T>(relationshipProps) : undefined;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Relationship.js","sourceRoot":"","sources":["../../src/Relationship.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+E;AAC/E,oDAAyG;AAEzG,qCAAkC;AAClC,uCAAoC;AAEpC,gDAA6D;AAC7D,gEAA6D;AAgB7D;;GAEG;AACH,MAAa,YAAa,SAAQ,eAAM;IAC/B,MAAM,KAAc,SAAS,KAAa,OAAO,cAAc,CAAC,CAAC,CAAC;IACzD,QAAQ,CAAa;IACrB,QAAQ,CAAa;IAErC,YAAsB,KAAwB,EAAE,MAAgB;QAC9D,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,mBAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,CAAC,QAAQ,GAAG,mBAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAEe,MAAM;QACpB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAuB,CAAC;QAChD,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC7B,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CA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AC;IAC3F,CAAC;IAED;;;;;;OAMG;IACI,cAAc,CAAyB,gBAAwB,EAAE,QAAsC;QAC5G,MAAM,iBAAiB,GAAG,IAAI,CAAC,mBAAmB,CAAoB,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QAClG,OAAO,SAAS,KAAK,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1G,CAAC;CACF;AArHD,sCAqHC","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 Relationships\n */\n\nimport { DbResult, Id64, Id64String, IModelStatus } from \"@itwin/core-bentley\";\nimport { EntityReferenceSet, IModelError, RelationshipProps, SourceAndTarget } from \"@itwin/core-common\";\nimport { ECSqlStatement } from \"./ECSqlStatement\";\nimport { Entity } from \"./Entity\";\nimport { EditTxn } from \"./EditTxn\";\nimport { IModelDb } from \"./IModelDb\";\nimport { _implicitTxn, _nativeDb } from \"./internal/Symbols\";\nimport { RelationshipClass } from \"@itwin/ecschema-metadata\";\n\nexport type { SourceAndTarget, RelationshipProps } from \"@itwin/core-common\"; // for backwards compatibility\n\n/** Argument for relationship dependency callbacks.\n * @beta\n */\nexport interface OnDependencyArg {\n /** The iModel for the relationship affected by this method. */\n iModel: IModelDb;\n /** The ElementDrivesElement relationship instance affected by this method. */\n props: RelationshipProps;\n /** The transaction for indirect processing. */\n indirectEditTxn: EditTxn;\n}\n\n/** Base class for all link table ECRelationships\n * @public\n */\nexport class Relationship extends Entity {\n public static override get className(): string { return \"Relationship\"; }\n public readonly sourceId: Id64String;\n public readonly targetId: Id64String;\n\n protected constructor(props: RelationshipProps, iModel: IModelDb) {\n super(props, iModel);\n this.sourceId = Id64.fromJSON(props.sourceId);\n this.targetId = Id64.fromJSON(props.targetId);\n }\n\n public override toJSON(): RelationshipProps {\n const val = super.toJSON() as RelationshipProps;\n val.sourceId = this.sourceId;\n val.targetId = this.targetId;\n return val;\n }\n\n /** Query metadata for this relationship class from the iModel's schema. Returns cached metadata if available.*/\n public override async getMetaData(): Promise<RelationshipClass> {\n if (this._metadata && RelationshipClass.isRelationshipClass(this._metadata)) {\n return this._metadata;\n }\n\n const relationship = await this.iModel.schemaContext.getSchemaItem(this.schemaItemKey, RelationshipClass);\n if (relationship !== undefined) {\n this._metadata = relationship;\n return this._metadata;\n } else {\n throw new Error(`Cannot get metadata for ${this.classFullName}`);\n }\n }\n\n /**\n * Callback invoked by saveChanges on an ElementDrivesElement relationship when its input has changed or is the output of some upstream relationship whose input has changed.\n * This callback is invoked after the input element has been processed by upstream relationships.\n * A subclass of ElementDrivesElement can re-implement this static method to take some action. onRootChanged may modify the output element only.\n * @beta\n */\n public static onRootChangedArg(arg: OnDependencyArg): void {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n this.onRootChanged(arg.props, arg.iModel);\n }\n\n /**\n * Callback invoked by saveChanges on an ElementDrivesElement relationship when its input has changed or is the output of some upstream relationship whose input has changed.\n * This callback is invoked after the input element has been processed by upstream relationships.\n * A subclass of ElementDrivesElement can re-implement this static method to take some action. onRootChanged may modify the output element only.\n * @param _props The ElementDrivesElement relationship instance.\n * @param _iModel The iModel\n * @deprecated Use onRootChangedArg instead.\n */\n public static onRootChanged(_props: RelationshipProps, _iModel: IModelDb): void { }\n\n /**\n * Callback invoked by saveChanges on an ElementDrivesElement relationship when the relationship instance has been deleted.\n * A subclass of ElementDrivesElement can re-implement this static method to take some action.\n * @beta\n */\n public static onDeletedDependencyArg(arg: OnDependencyArg): void {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n this.onDeletedDependency(arg.props, arg.iModel);\n }\n\n /**\n * Callback invoked by saveChanges on an ElementDrivesElement relationship when the relationship instance has been deleted.\n * A subclass of ElementDrivesElement can re-implement this static method to take some action.\n * @param _props The deleted ElementDrivesElement relationship instance.\n * @param _iModel The iModel\n * @deprecated Use onDeletedDependencyArg instead.\n */\n public static onDeletedDependency(_props: RelationshipProps, _iModel: IModelDb): void { }\n\n /**\n * Insert this Relationship into the iModel using the supplied EditTxn.\n * @beta\n */\n public insert(txn: EditTxn): Id64String;\n /**\n * Insert this Relationship into the iModel.\n * @deprecated Use Relationship.insert(txn) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\n */\n public insert(): Id64String;\n public insert(txn?: EditTxn): Id64String { return this.id = (txn ?? this.iModel[_implicitTxn]).insertRelationship(this.toJSON()); }\n\n /**\n * Update this Relationship in the iModel using the supplied EditTxn.\n * @beta\n */\n public update(txn: EditTxn): void;\n /**\n * Update this Relationship in the iModel.\n * @deprecated Use Relationship.update(txn) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\n */\n public update(): void;\n public update(txn?: EditTxn) { (txn ?? this.iModel[_implicitTxn]).updateRelationship(this.toJSON()); }\n\n /**\n * Delete this Relationship from the iModel using the supplied EditTxn.\n * @beta\n */\n public delete(txn: EditTxn): void;\n /**\n * Delete this Relationship from the iModel.\n * @deprecated Use Relationship.delete(txn) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\n */\n public delete(): void;\n public delete(txn?: EditTxn) { (txn ?? this.iModel[_implicitTxn]).deleteRelationship(this.toJSON()); }\n\n public static getInstance<T extends Relationship>(iModel: IModelDb, criteria: Id64String | SourceAndTarget): T { return iModel.relationships.getInstance(this.classFullName, criteria); }\n}\n\n/** A Relationship where one Element refers to another Element\n * @public\n */\nexport class ElementRefersToElements extends Relationship {\n public static override get className(): string { return \"ElementRefersToElements\"; }\n /** Create an instance of the Relationship.\n * @param iModel The iModel that will contain the relationship\n * @param sourceId The sourceId of the relationship, that is, the driver element\n * @param targetId The targetId of the relationship, that is, the driven element\n * @return an instance of the specified class.\n */\n public static create<T extends ElementRefersToElements>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String): T {\n return iModel.relationships.createInstance({ sourceId, targetId, classFullName: this.classFullName }) as T;\n }\n\n /** Insert a new instance of the Relationship using an explicit transaction.\n * @param txn The EditTxn used to perform the insert.\n * @param sourceId The sourceId of the relationship, that is, the driver element\n * @param targetId The targetId of the relationship, that is, the driven element\n * @return The Id of the inserted Relationship.\n * @beta\n */\n public static insert(txn: EditTxn, sourceId: Id64String, targetId: Id64String): Id64String;\n /** Insert a new instance of the Relationship.\n * @param iModel The iModel that will contain the relationship.\n * @param sourceId The sourceId of the relationship, that is, the driver element.\n * @param targetId The targetId of the relationship, that is, the driven element.\n * @return The Id of the inserted Relationship.\n * @deprecated Use ElementRefersToElements.insert(txn, ...) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\n */\n public static insert(iModel: IModelDb, sourceId: Id64String, targetId: Id64String): Id64String;\n public static insert(txnOrIModel: EditTxn | IModelDb, sourceId: Id64String, targetId: Id64String): Id64String {\n const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];\n const relationship = this.create(txn.iModel, sourceId, targetId);\n return txn.insertRelationship(relationship.toJSON());\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n referenceIds.addElement(this.sourceId);\n referenceIds.addElement(this.targetId);\n }\n}\n\n/** Relates a [[DrawingGraphic]] to the [[Element]] that it represents\n * @public\n */\nexport class DrawingGraphicRepresentsElement extends ElementRefersToElements {\n public static override get className(): string { return \"DrawingGraphicRepresentsElement\"; }\n}\n\n/** Relates a [[GraphicalElement3d]] to the [[Element]] that it represents\n * @public\n */\nexport class GraphicalElement3dRepresentsElement extends ElementRefersToElements {\n public static override get className(): string { return \"GraphicalElement3dRepresentsElement\"; }\n}\n\n/** Relates a [[SynchronizationConfigLink]] to N [[ExternalSource]] instances.\n * Each relationship instance represents an external source processed by the synchronization configuration.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\n * @beta\n */\nexport class SynchronizationConfigProcessesSources extends ElementRefersToElements {\n public static override get className(): string { return \"SynchronizationConfigProcessesSources\"; }\n}\n\n/** Relates a [[SynchronizationConfigLink]] to *root* [[ExternalSource]] instances.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\n * @beta\n */\nexport class SynchronizationConfigSpecifiesRootSources extends SynchronizationConfigProcessesSources {\n public static override get className(): string { return \"SynchronizationConfigSpecifiesRootSources\"; }\n}\n\n/** Properties that are common to all types of link table ECRelationships\n * @public\n */\nexport interface ElementGroupsMembersProps extends RelationshipProps {\n memberPriority: number;\n}\n\n/** An ElementRefersToElements relationship where one Element *groups* a set of other Elements.\n * @public\n */\nexport class ElementGroupsMembers extends ElementRefersToElements {\n public static override get className(): string { return \"ElementGroupsMembers\"; }\n public memberPriority: number;\n\n constructor(props: ElementGroupsMembersProps, iModel: IModelDb) {\n super(props, iModel);\n this.memberPriority = props.memberPriority;\n }\n\n public static override create<T extends ElementRefersToElements>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String, memberPriority: number = 0): T {\n const props: ElementGroupsMembersProps = { sourceId, targetId, memberPriority, classFullName: this.classFullName };\n return iModel.relationships.createInstance(props) as T;\n }\n}\n\n/** Relates a [[DefinitionGroup]] to its [[DefinitionElement]] members.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.10\n * @public\n */\nexport class DefinitionGroupGroupsDefinitions extends ElementGroupsMembers {\n public static override get className(): string { return \"DefinitionGroupGroupsDefinitions\"; }\n}\n\n/** Represents group membership where the group Element (and its properties) impart information about the member Elements above mere membership.\n * Implies that properties of the group should be considered as properties of its members.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.11\n * @public\n */\nexport class GroupImpartsToMembers extends ElementGroupsMembers {\n public static override get className(): string { return \"GroupImpartsToMembers\"; }\n}\n\n/** Relates an [[ExternalSourceGroup]] to its [[ExternalSource]] members.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\n * @beta\n */\nexport class ExternalSourceGroupGroupsSources extends ElementGroupsMembers {\n public static override get className(): string { return \"ExternalSourceGroupGroupsSources\"; }\n}\n\n/** Properties that are common to all types of ElementDrivesElements\n * @beta\n */\nexport interface ElementDrivesElementProps extends RelationshipProps {\n status: number;\n priority: number;\n}\n\n/** A Relationship indicating that one Element *drives* another Element.\n * An ElementDrivesElement relationship defines a one-way \"driving\" relationship from the source to the target.\n * When the source of an ElementDrivesElement relationship changes, the ElementDrivesElement itself can get a callback, and both the source and target elements can get callbacks.\n * By inserting ElementDrivesElement relationships, an app can create and store an acyclic directed graph of dependencies between elements.\n *\n * # Defining dependencies\n * Create an ElementDrivesElement relationship to specify that the source element drives the target element.\n * For example, to specify that element e1 drives element e2, create a relationship between them like this:\n * ```ts\n * const ede = ElementDrivesElement.create(iModel, e1id, e2id);\n * ede.insert();\n * ```\n * This creates a persistent relationship. The fact that e1 drives e2 is persisted in the iModel.\n *\n * # Defining dependency graphs\n * When you create multiple ElementDrivesElement relationships, you create a network of dependencies. The target of one may be the source of another.\n * A change in the content of an DgnElement can therefore trigger changes to many downstream elements.\n *\n * For example, to make element e1 drive element e2 and e2 drive another element, e3, create two relationships like this:\n * ```ts\n * const ede12 = ElementDrivesElement.create(iModel, e1id, e2id);\n * const ede23 = ElementDrivesElement.create(iModel, e2id, e3id);\n * ede12.insert();\n * ede23.insert();\n * ```\n * Those two relationships create this graph:\n * ```\n * e1 --> e2 --> e3\n * ```\n * Where the \"-->\" is meant to represent a driving relationship.\n *\n * The order in which you create the relationships does not matter.\n * The graph indicates that e3 depends on e2 and e2 depends on e1.\n *\n * An ElementDrivesElement relationship is between one source element and one target element.\n * Many ElementDrivesElement relationships can point to a given element, and many can point out of it.\n * Thus, you can define many:many relationships.\n * For example:\n * ```ts\n * const ede12 = ElementDrivesElement.create(iModel, e1id, e2id);\n * const ede112 = ElementDrivesElement.create(iModel, e11id, e2id);\n * const ede23 = ElementDrivesElement.create(iModel, e2id, e3id);\n * const ede231 = ElementDrivesElement.create(iModel, e2id, e31id);\n * ede12.insert();\n * ede112.insert();\n * ede23.insert();\n * ede231.insert();\n * ```\n * Creates this graph:\n * ```\n * e1 e3\n * \\ /\n * e2\n * / \\\n * e11 e31\n * ```\n * e2 depends on both e1 and e11. e2 then drives e3 and e31.\n *\n * In an ElementDrivesElement dependency graph, the relationships are the \"edges\" and the Elements are the \"nodes\".\n * The following terms are used when referring to the elements (nodes) in a dependency graph:\n * * Inputs - The sources of all edges that point to the element. This includes all upstream elements that flow into the element.\n * * Outputs - The targets of all edges that point out of the element. This includes all downstream elements.\n *\n * # Subgraph Processing\n * When changes are made, only the part of the overall graph that is affected will be processed. So, for example,\n * suppose we have this graph:\n * ```\n * e1 --> e2 --> e3\n * ```\n * If e1 changes, then the subgraph to be processed is equal to the full graph, as shown.\n *\n * If only e2 changes, then the subgraph to be processed is just:\n * ```\n * e2 --> e3\n * ```\n * If only e3 changes, then the subgraph consists of e3 by itself.\n *\n * Returning to the second example above, suppose we have this graph:\n * ```\n * e1 e3\n * \\ /\n * e2\n * / \\\n * e11 e31\n * ```\n * If e1 is changed, the affected subgraph is:\n * ```\n * e1 e3\n * \\ /\n * e2\n * \\\n * e31\n * ```\n * If e2 is changed, the affected subgraph is:\n * ```\n * e3\n * /\n * e2\n * \\\n * e31\n * ```\n * # Callbacks\n * Once the affected subgraph to process is found, it propagates changes through it by making callbacks.\n * Classes for both elements (nodes) and ElementDrivesElements relationships (edges) can receive callbacks.\n *\n * ## ElementDrivesElement Callbacks\n * The following callbacks are invoked on ElementDrivesElement relationship classes (edges):\n * * onRootChanged\n * * onDeletedDependency\n *\n * Note that these are static methods. Their default implementations do nothing.\n * To receive and act on these callbacks, a domain should define a subclass of ElementDrivesElement and use that to create relationships.\n * The subclass should then implement the callbacks that it would like to act on.\n *\n * A ElementDrivesElement subclass callback is expected to make changes to the output element only!\n *\n * ## Element Callbacks\n * The following callbacks are invoked on Element classes (nodes):\n * * Element.onBeforeOutputsHandled\n * * Element.onAllInputsHandled\n *\n * ## Order\n * Callbacks are invoked by BriefcaseDb.saveChanges.\n * They are invoked in dependency (topological) order: driving elements first, then driven elements.\n *\n * Each callback is invoked only once. No matter how many times a given element was changed during the transaction,\n * a callback such as ElementDrivesElement.onRootChanged will be invoked only once.\n * In the same way, no matter how many of its inputs were changed, a callback such as Element.onAllInputsHandled will be\n * invoked only once.\n *\n * For example, suppose we have a graph:\n * ```\n * e1 --> e2 --> e3\n * ```\n *\n * Suppose that e1 is directly modified. No callbacks are made at that time.\n * Later, when BriefcaseDb.saveChanges is called, the following callbacks are made, in order:\n * 1. Element.onBeforeOutputsHandled e1\n * 1. ElementDrivesElement.onRootChanged e1->e2\n * 1. Element.onAllInputsHandled e2\n * 1. ElementDrivesElement.onRootChanged e2->e3\n * 1. Element.onAllInputsHandled e3\n *\n * Suppose that e3 is modified directly and BriefcaseDb.saveChanges is called.\n * Since no input to a relationship was changed, the sub-graph will be empty, and no callbacks will be made.\n *\n * Returning to the second example above, suppose we have this graph:\n * ```\n * e1 e3\n * \\ /\n * e2\n * / \\\n * e11 e31\n * ```\n * If e1 is changed and BriefcaseDb.saveChanges is called, the subgraph is:\n * ```\n * e1 e3\n * \\ /\n * e2\n * \\\n * e31\n * ```\n * The callbacks are:\n * 1. Element.onBeforeOutputsHandled e1\n * 1. ElementDrivesElement.onRootChanged e1->e2\n * 1. Element.onAllInputsHandled e2\n * 1. ElementDrivesElement.onRootChanged e2->e3\n * 1. Element.onAllInputsHandled e3\n * 1. ElementDrivesElement.onRootChanged e2->e31\n * 1. Element.onAllInputsHandled e31\n *\n * (The ElementDrivesElement.)\n *\n * #Errors\n * Circular dependencies are not permitted. If a cycle is detected, that is treated as a fatal error. All ElementDrivesElement relationships\n * involved in a cycle will have their status set to 1, indicating a failure.\n *\n * A callback may call txnManager.reportError to reject an invalid change. It can classify the error as fatal or just a warning.\n * A callback make set the status value of an ElementDrivesElement instance to 1 to indicate a processing failure in that edge.\n *\n * After BriefcaseDb.saveChanges is called, an app should check db.txns.validationErrors and db.txns.hasFatalError to find out if graph-evaluation failed.\n *\n * @beta\n */\nexport class ElementDrivesElement extends Relationship {\n public static override get className(): string { return \"ElementDrivesElement\"; }\n /** Relationship status\n * * 0 indicates no errors. Set after a successful evaluation.\n * * 1 indicates that this driving relationship could not be evaluated. The callback itself can set this to indicate that it failed to process the input changes. Also, it is set if the relationship is part of a circular dependency.\n * * 0x80 The app or callback can set this to indicate to not propagate changes through this relationship.\n */\n public status: number;\n /** Affects the order in which relationships are processed in the case where two relationships have the same output. */\n public priority: number;\n\n protected constructor(props: ElementDrivesElementProps, iModel: IModelDb) {\n super(props, iModel);\n this.status = props.status;\n this.priority = props.priority;\n }\n\n public static create<T extends ElementDrivesElement>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String, priority: number = 0): T {\n const props: ElementDrivesElementProps = { sourceId, targetId, priority, status: 0, classFullName: this.classFullName };\n return iModel.relationships.createInstance(props) as T;\n }\n\n public override toJSON(): ElementDrivesElementProps {\n const props = super.toJSON() as ElementDrivesElementProps;\n props.status = this.status;\n props.priority = this.priority;\n return props;\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n referenceIds.addElement(this.sourceId);\n referenceIds.addElement(this.targetId);\n }\n}\n\n/** The third (and last) possible link-table relationship base class in an iModel.\n * Has no external use, but is included for completeness of the [Entity.collectReferenceIds]($backend)\n * implementations for link-table relationships. Generating the types of the source and target automatically would require\n * coupling this package with ecschema-metadata which we do not want to do.\n * @internal\n */\nexport class ModelSelectorRefersToModels extends Relationship {\n public static override get className(): string { return \"ModelSelectorRefersToModels\"; }\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n referenceIds.addElement(this.sourceId);\n referenceIds.addModel(this.targetId);\n }\n}\n\n/** Manages [[Relationship]]s.\n * @public\n */\nexport class Relationships {\n private _iModel: IModelDb;\n\n /** @internal */\n public constructor(iModel: IModelDb) { this._iModel = iModel; }\n\n /** Create a new instance of a Relationship.\n * @param props The properties of the new Relationship.\n * @throws [[IModelError]] if there is a problem creating the Relationship.\n */\n public createInstance(props: RelationshipProps): Relationship { return this._iModel.constructEntity<Relationship>(props); }\n\n /** Check classFullName to ensure it is a link table relationship class. */\n private checkRelationshipClass(classFullName: string) {\n if (!this._iModel[_nativeDb].isLinkTableRelationship(classFullName.replace(\".\", \":\"))) {\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Class '${classFullName}' must be a relationship class and it should be subclass of BisCore:ElementRefersToElements or BisCore:ElementDrivesElement.`);\n }\n }\n\n /** Insert a new relationship instance into the iModel. The relationship provided must be subclass of BisCore:ElementRefersToElements or BisCore:ElementDrivesElement.\n * @param props The properties of the new relationship.\n * @returns The Id of the newly inserted relationship.\n * @note The id property of the props object is set as a side effect of this function.\n * @deprecated Use EditTxn.insertRelationship instead.\n */\n public insertInstance(props: RelationshipProps): Id64String {\n return this._iModel[_implicitTxn].insertRelationship(props);\n }\n\n /** Update the properties of an existing relationship instance in the iModel.\n * @param props the properties of the relationship instance to update. Any properties that are not present will be left unchanged.\n * @deprecated Use EditTxn.updateRelationship instead.\n */\n public updateInstance(props: RelationshipProps): void {\n this._iModel[_implicitTxn].updateRelationship(props);\n }\n\n /** Delete an Relationship instance from this iModel.\n * @deprecated Use EditTxn.deleteRelationship instead.\n */\n public deleteInstance(props: RelationshipProps): void {\n this._iModel[_implicitTxn].deleteRelationship(props);\n }\n\n /** Delete multiple Relationship instances from this iModel.\n * @param props The properties of the relationship instances to delete.\n * @remarks This method handles bulk deletion of relationships and supports mixed collections containing instances from different relationship classes.\n * @deprecated Use EditTxn.deleteRelationships instead.\n */\n public deleteInstances(props: ReadonlyArray<RelationshipProps>): void {\n this._iModel[_implicitTxn].deleteRelationships(props);\n }\n\n /** Get the props of a Relationship instance\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\n * @param criteria Either the relationship instanceId or the source and target Ids\n * @throws [IModelError]($common) if the relationship is not found or cannot be loaded.\n * @see tryGetInstanceProps\n */\n public getInstanceProps<T extends RelationshipProps>(relClassFullName: string, criteria: Id64String | SourceAndTarget): T {\n const relationshipProps = this.tryGetInstanceProps<T>(relClassFullName, criteria);\n if (undefined === relationshipProps) {\n throw new IModelError(IModelStatus.NotFound, \"Relationship not found\");\n }\n return relationshipProps;\n }\n\n /** Get the props of a Relationship instance\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\n * @param criteria Either the relationship instanceId or the source and target Ids\n * @returns The RelationshipProps or `undefined` if the relationship is not found.\n * @note Useful for cases when a relationship may or may not exist and throwing an `Error` would be overkill.\n * @see getInstanceProps\n */\n public tryGetInstanceProps<T extends RelationshipProps>(relClassFullName: string, criteria: Id64String | SourceAndTarget): T | undefined {\n let props: T | undefined;\n if (typeof criteria === \"string\") {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n props = this._iModel.withPreparedStatement(`SELECT * FROM ${relClassFullName} WHERE ecinstanceid=?`, (stmt: ECSqlStatement) => {\n stmt.bindId(1, criteria);\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getRow() as T : undefined;\n });\n } else {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n props = this._iModel.withPreparedStatement(`SELECT * FROM ${relClassFullName} WHERE SourceECInstanceId=? AND TargetECInstanceId=?`, (stmt: ECSqlStatement) => {\n stmt.bindId(1, criteria.sourceId);\n stmt.bindId(2, criteria.targetId);\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getRow() as T : undefined;\n });\n }\n if (undefined !== props) {\n props.classFullName = (props as any).className.replace(\".\", \":\");\n }\n return props;\n }\n\n /** Get a Relationship instance\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\n * @param criteria Either the relationship instanceId or the source and target Ids\n * @throws [IModelError]($common) if the relationship is not found or cannot be loaded.\n * @see tryGetInstance\n */\n public getInstance<T extends Relationship>(relClassSqlName: string, criteria: Id64String | SourceAndTarget): T {\n return this._iModel.constructEntity<T>(this.getInstanceProps(relClassSqlName, criteria));\n }\n\n /** Get a Relationship instance\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\n * @param criteria Either the relationship instanceId or the source and target Ids\n * @returns The relationship or `undefined` if the relationship is not found.\n * @note Useful for cases when a relationship may or may not exist and throwing an `Error` would be overkill.\n * @see getInstance\n */\n public tryGetInstance<T extends Relationship>(relClassFullName: string, criteria: Id64String | SourceAndTarget): T | undefined {\n const relationshipProps = this.tryGetInstanceProps<RelationshipProps>(relClassFullName, criteria);\n return undefined !== relationshipProps ? this._iModel.constructEntity<T>(relationshipProps) : undefined;\n }\n}\n"]}
|
package/lib/cjs/SchemaSync.js
CHANGED
|
@@ -94,7 +94,7 @@ var SchemaSync;
|
|
|
94
94
|
const schemaSyncDbUri = syncAccess.getUri();
|
|
95
95
|
iModel.clearCaches();
|
|
96
96
|
iModel[Symbols_1._nativeDb].schemaSyncPull(schemaSyncDbUri);
|
|
97
|
-
iModel.saveChanges("schema synchronized with cloud container");
|
|
97
|
+
iModel[Symbols_1._implicitTxn].saveChanges("schema synchronized with cloud container");
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
};
|
|
@@ -110,17 +110,17 @@ var SchemaSync;
|
|
|
110
110
|
await briefcase.pullChanges();
|
|
111
111
|
}
|
|
112
112
|
try {
|
|
113
|
-
iModel.saveFileProperty(syncProperty, JSON.stringify(props));
|
|
113
|
+
iModel[Symbols_1._implicitTxn].saveFileProperty(syncProperty, JSON.stringify(props));
|
|
114
114
|
await SchemaSync.withLockedAccess(arg.iModel, { operationName: "initialize schemaSync", openMode: core_bentley_1.OpenMode.Readonly }, async (syncAccess) => {
|
|
115
115
|
iModel[Symbols_1._nativeDb].schemaSyncInit(syncAccess.getUri(), props.containerId, arg.overrideContainer ?? false);
|
|
116
|
-
iModel.saveChanges(`Enable SchemaSync (container id: ${props.containerId})`);
|
|
116
|
+
iModel[Symbols_1._implicitTxn].saveChanges(`Enable SchemaSync (container id: ${props.containerId})`);
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
catch (err) {
|
|
120
120
|
throw err;
|
|
121
121
|
}
|
|
122
122
|
finally {
|
|
123
|
-
iModel.abandonChanges();
|
|
123
|
+
iModel[Symbols_1._implicitTxn].abandonChanges();
|
|
124
124
|
}
|
|
125
125
|
if (briefcase) {
|
|
126
126
|
if (arg.overrideContainer)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaSync.js","sourceRoot":"","sources":["../../src/SchemaSync.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,+CAA4C;AAC5C,yCAA+C;AAC/C,yCAAmD;AACnD,sDAAyD;AACzD,oDAAgE;AAEhE,8DAAyD;AACzD,gDAA+C;AAE/C,gBAAgB;AAChB,IAAiB,UAAU,CAsI1B;AAtID,WAAiB,UAAU;IACzB,MAAM,UAAU,GAAiC,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAEtF,kFAAkF;IAClF,MAAa,YAAa,SAAQ,4BAAiB;QACxB,SAAS,GAAG,OAAO,CAAC;QAC1B,SAAS,KAAK,CAAC;KACnC;IAHY,uBAAY,eAGxB,CAAA;IAED,MAAM,YAAY,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IAClE,MAAM,aAAa,GAAG,cAAc,CAAC;IACrC,MAAM,oBAAoB,GAAG,6BAA6B,CAAC;IAC3D,iBAAiB;IACJ,uBAAY,GAAG,CAAC,MAAgB,EAAE,SAAkB,EAAE,EAAE;QACnE,IAAI,SAAS;YACX,MAAM,CAAC,mBAAS,CAAC,CAAC,cAAc,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC;;YAElE,MAAM,CAAC,mBAAS,CAAC,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;IAC7D,CAAC,CAAC;IAEF,MAAM,cAAc,GAAG,KAAK,EAAE,GAAoD,EAAE,EAAE;QACpF,IAAI,QAA0C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,CAAC;YAChF,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,GAAG,CAAC;QACZ,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,cAAc,EAAE,CAAC;QAC1B,CAAC;QAED,IAAI,SAAS,EAAE,CAAC;YACd,IAAI,GAAG,CAAC,iBAAiB;gBACvB,MAAM,SAAS,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,uDAAuD,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;;gBAEzH,MAAM,SAAS,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,mDAAmD,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QACzH,CAAC;IACH,CAAC,CAAC;IAEF,0EAA0E;IAC1E,MAAa,WAAY,SAAQ,yBAAW,CAAC,QAAsB;QACjE,YAAmB,KAAuC;YACxD,KAAK,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;QAChE,CAAC;QAEM,MAAM;YACX,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,mBAAS,CAAC,CAAC,WAAW,EAAE,QAAQ,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,aAAa,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1I,CAAC;QACD;;;;SAIC;QACM,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,KAAiC;YAChE,OAAO,KAAK,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;QACrF,CAAC;KACF;IAhBY,sBAAW,cAgBvB,CAAA;AACH,CAAC,EAtIgB,UAAU,0BAAV,UAAU,QAsI1B","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\n/** @packageDocumentation\n * @module SQLiteDb\n */\n\nimport { CloudSqlite } from \"./CloudSqlite\";\nimport { VersionedSqliteDb } from \"./SQLiteDb\";\nimport { BriefcaseDb, IModelDb } from \"./IModelDb\";\nimport { DbResult, OpenMode } from \"@itwin/core-bentley\";\nimport { IModelError, LocalFileName } from \"@itwin/core-common\";\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { _nativeDb } from \"./internal/Symbols\";\n\n/** @internal */\nexport namespace SchemaSync {\n const lockParams: CloudSqlite.ObtainLockParams = { retryDelayMs: 1000, nRetries: 30 };\n\n /** A CloudSqlite database for synchronizing schema changes across briefcases. */\n export class SchemaSyncDb extends VersionedSqliteDb {\n public override readonly myVersion = \"4.0.0\";\n protected override createDDL() { }\n }\n\n const syncProperty = { namespace: \"itwinjs\", name: \"SchemaSync\" };\n const defaultDbName = \"SchemaSyncDb\";\n const testSyncCachePropKey = \"test.schema_sync.cache_name\";\n // for tests only\n export const setTestCache = (iModel: IModelDb, cacheName?: string) => {\n if (cacheName)\n iModel[_nativeDb].saveLocalValue(testSyncCachePropKey, cacheName);\n else\n iModel[_nativeDb].deleteLocalValue(testSyncCachePropKey);\n };\n\n const getCloudAccess = async (arg: IModelDb | { readonly fileName: LocalFileName }) => {\n let nativeDb: IModelJsNative.DgnDb | undefined;\n const argIsIModelDb = arg instanceof IModelDb;\n if (argIsIModelDb) {\n nativeDb = arg[_nativeDb];\n } else {\n nativeDb = new IModelNative.platform.DgnDb();\n nativeDb.openIModel(arg.fileName, OpenMode.Readonly);\n }\n\n const propsString = nativeDb.queryFileProperty(syncProperty, true) as string | undefined;\n if (!propsString)\n throw new Error(\"iModel does not have a SchemaSyncDb\");\n try {\n const props = JSON.parse(propsString) as CloudSqlite.ContainerProps;\n const accessToken = await CloudSqlite.requestToken(props);\n const access = new CloudAccess({ ...props, accessToken });\n Object.assign(access.lockParams, lockParams);\n const testSyncCache = nativeDb.queryLocalValue(testSyncCachePropKey);\n if (testSyncCache)\n access.setCache(CloudSqlite.CloudCaches.getCache({ cacheName: testSyncCache }));\n return access;\n } finally {\n if (!argIsIModelDb) {\n nativeDb.closeFile();\n }\n }\n };\n\n export const withLockedAccess = async (iModel: IModelDb | { readonly fileName: LocalFileName }, args: { operationName: string, openMode?: OpenMode, user?: string }, operation: (access: CloudAccess) => Promise<void>): Promise<void> => {\n const access = await getCloudAccess(iModel);\n try {\n await access.withLockedDb(args, async () => operation(access));\n } finally {\n access.close();\n }\n };\n\n export const withReadonlyAccess = async (iModel: IModelDb | { readonly fileName: LocalFileName }, operation: (access: CloudAccess) => Promise<void>): Promise<void> => {\n const access = await getCloudAccess(iModel);\n access.synchronizeWithCloud();\n access.openForRead();\n try {\n await operation(access);\n } finally {\n access.close();\n }\n };\n\n export const isEnabled = (iModel: IModelDb) => {\n return iModel[_nativeDb].schemaSyncEnabled();\n };\n\n /** Synchronize local briefcase schemas with cloud container */\n export const pull = async (iModel: IModelDb) => {\n if (iModel[_nativeDb].schemaSyncEnabled() && !iModel.isReadonly) {\n await SchemaSync.withReadonlyAccess(iModel, async (syncAccess) => {\n const schemaSyncDbUri = syncAccess.getUri();\n iModel.clearCaches();\n iModel[_nativeDb].schemaSyncPull(schemaSyncDbUri);\n iModel.saveChanges(\"schema synchronized with cloud container\");\n });\n }\n };\n\n export const initializeForIModel = async (arg: { iModel: IModelDb, containerProps: CloudSqlite.ContainerProps, overrideContainer?: boolean }) => {\n const props = { baseUri: arg.containerProps.baseUri, containerId: arg.containerProps.containerId, storageType: arg.containerProps.storageType }; // sanitize to only known properties\n const iModel = arg.iModel;\n const briefcase = iModel instanceof BriefcaseDb ? iModel : undefined;\n await iModel.acquireSchemaLock();\n if (briefcase) {\n if (briefcase.txns.hasLocalChanges) {\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Enabling SchemaSync for iModel failed. There are unsaved or un-pushed local changes.\");\n }\n await briefcase.pullChanges();\n }\n try {\n iModel.saveFileProperty(syncProperty, JSON.stringify(props));\n await withLockedAccess(arg.iModel, { operationName: \"initialize schemaSync\", openMode: OpenMode.Readonly }, async (syncAccess) => {\n iModel[_nativeDb].schemaSyncInit(syncAccess.getUri(), props.containerId, arg.overrideContainer ?? false);\n iModel.saveChanges(`Enable SchemaSync (container id: ${props.containerId})`);\n });\n } catch (err) {\n throw err;\n } finally {\n iModel.abandonChanges();\n }\n\n if (briefcase) {\n if (arg.overrideContainer)\n await briefcase.pushChanges({ description: `Overriding SchemaSync for iModel with container-id: ${props.containerId}` });\n else\n await briefcase.pushChanges({ description: `Enable SchemaSync for iModel with container-id: ${props.containerId}` });\n }\n };\n\n /** Provides access to a cloud-based `SchemaSyncDb` to hold ECSchemas. */\n export class CloudAccess extends CloudSqlite.DbAccess<SchemaSyncDb> {\n public constructor(props: CloudSqlite.ContainerAccessProps) {\n super({ dbType: SchemaSyncDb, props, dbName: defaultDbName });\n }\n\n public getUri() {\n return `${this.getCloudDb()[_nativeDb].getFilePath()}?vfs=${this.container.cache?.name}&writable=${this.container.isWriteable ? 1 : 0}`;\n }\n /**\n * Initialize a cloud container for use as a SchemaSync. The container must first be created via its storage supplier api (e.g. Azure, or AWS).\n * A valid sasToken that grants write access must be supplied. This function creates and uploads an empty ChannelDb into the container.\n * @note this deletes any existing content in the container.\n */\n public static async initializeDb(props: CloudSqlite.ContainerProps) {\n return super._initializeDb({ props, dbType: SchemaSyncDb, dbName: defaultDbName });\n }\n }\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaSync.js","sourceRoot":"","sources":["../../src/SchemaSync.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,+CAA4C;AAC5C,yCAA+C;AAC/C,yCAAmD;AACnD,sDAAyD;AACzD,oDAAgE;AAEhE,8DAAyD;AACzD,gDAA6D;AAE7D,gBAAgB;AAChB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E,mDAAmD,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QACzH,CAAC;IACH,CAAC,CAAC;IAEF,0EAA0E;IAC1E,MAAa,WAAY,SAAQ,yBAAW,CAAC,QAAsB;QACjE,YAAmB,KAAuC;YACxD,KAAK,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;QAChE,CAAC;QAEM,MAAM;YACX,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,mBAAS,CAAC,CAAC,WAAW,EAAE,QAAQ,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,aAAa,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1I,CAAC;QACD;;;;SAIC;QACM,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,KAAiC;YAChE,OAAO,KAAK,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;QACrF,CAAC;KACF;IAhBY,sBAAW,cAgBvB,CAAA;AACH,CAAC,EAtIgB,UAAU,0BAAV,UAAU,QAsI1B","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\n/** @packageDocumentation\n * @module SQLiteDb\n */\n\nimport { CloudSqlite } from \"./CloudSqlite\";\nimport { VersionedSqliteDb } from \"./SQLiteDb\";\nimport { BriefcaseDb, IModelDb } from \"./IModelDb\";\nimport { DbResult, OpenMode } from \"@itwin/core-bentley\";\nimport { IModelError, LocalFileName } from \"@itwin/core-common\";\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { _implicitTxn, _nativeDb } from \"./internal/Symbols\";\n\n/** @internal */\nexport namespace SchemaSync {\n const lockParams: CloudSqlite.ObtainLockParams = { retryDelayMs: 1000, nRetries: 30 };\n\n /** A CloudSqlite database for synchronizing schema changes across briefcases. */\n export class SchemaSyncDb extends VersionedSqliteDb {\n public override readonly myVersion = \"4.0.0\";\n protected override createDDL() { }\n }\n\n const syncProperty = { namespace: \"itwinjs\", name: \"SchemaSync\" };\n const defaultDbName = \"SchemaSyncDb\";\n const testSyncCachePropKey = \"test.schema_sync.cache_name\";\n // for tests only\n export const setTestCache = (iModel: IModelDb, cacheName?: string) => {\n if (cacheName)\n iModel[_nativeDb].saveLocalValue(testSyncCachePropKey, cacheName);\n else\n iModel[_nativeDb].deleteLocalValue(testSyncCachePropKey);\n };\n\n const getCloudAccess = async (arg: IModelDb | { readonly fileName: LocalFileName }) => {\n let nativeDb: IModelJsNative.DgnDb | undefined;\n const argIsIModelDb = arg instanceof IModelDb;\n if (argIsIModelDb) {\n nativeDb = arg[_nativeDb];\n } else {\n nativeDb = new IModelNative.platform.DgnDb();\n nativeDb.openIModel(arg.fileName, OpenMode.Readonly);\n }\n\n const propsString = nativeDb.queryFileProperty(syncProperty, true) as string | undefined;\n if (!propsString)\n throw new Error(\"iModel does not have a SchemaSyncDb\");\n try {\n const props = JSON.parse(propsString) as CloudSqlite.ContainerProps;\n const accessToken = await CloudSqlite.requestToken(props);\n const access = new CloudAccess({ ...props, accessToken });\n Object.assign(access.lockParams, lockParams);\n const testSyncCache = nativeDb.queryLocalValue(testSyncCachePropKey);\n if (testSyncCache)\n access.setCache(CloudSqlite.CloudCaches.getCache({ cacheName: testSyncCache }));\n return access;\n } finally {\n if (!argIsIModelDb) {\n nativeDb.closeFile();\n }\n }\n };\n\n export const withLockedAccess = async (iModel: IModelDb | { readonly fileName: LocalFileName }, args: { operationName: string, openMode?: OpenMode, user?: string }, operation: (access: CloudAccess) => Promise<void>): Promise<void> => {\n const access = await getCloudAccess(iModel);\n try {\n await access.withLockedDb(args, async () => operation(access));\n } finally {\n access.close();\n }\n };\n\n export const withReadonlyAccess = async (iModel: IModelDb | { readonly fileName: LocalFileName }, operation: (access: CloudAccess) => Promise<void>): Promise<void> => {\n const access = await getCloudAccess(iModel);\n access.synchronizeWithCloud();\n access.openForRead();\n try {\n await operation(access);\n } finally {\n access.close();\n }\n };\n\n export const isEnabled = (iModel: IModelDb) => {\n return iModel[_nativeDb].schemaSyncEnabled();\n };\n\n /** Synchronize local briefcase schemas with cloud container */\n export const pull = async (iModel: IModelDb) => {\n if (iModel[_nativeDb].schemaSyncEnabled() && !iModel.isReadonly) {\n await SchemaSync.withReadonlyAccess(iModel, async (syncAccess) => {\n const schemaSyncDbUri = syncAccess.getUri();\n iModel.clearCaches();\n iModel[_nativeDb].schemaSyncPull(schemaSyncDbUri);\n iModel[_implicitTxn].saveChanges(\"schema synchronized with cloud container\");\n });\n }\n };\n\n export const initializeForIModel = async (arg: { iModel: IModelDb, containerProps: CloudSqlite.ContainerProps, overrideContainer?: boolean }) => {\n const props = { baseUri: arg.containerProps.baseUri, containerId: arg.containerProps.containerId, storageType: arg.containerProps.storageType }; // sanitize to only known properties\n const iModel = arg.iModel;\n const briefcase = iModel instanceof BriefcaseDb ? iModel : undefined;\n await iModel.acquireSchemaLock();\n if (briefcase) {\n if (briefcase.txns.hasLocalChanges) {\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Enabling SchemaSync for iModel failed. There are unsaved or un-pushed local changes.\");\n }\n await briefcase.pullChanges();\n }\n try {\n iModel[_implicitTxn].saveFileProperty(syncProperty, JSON.stringify(props));\n await withLockedAccess(arg.iModel, { operationName: \"initialize schemaSync\", openMode: OpenMode.Readonly }, async (syncAccess) => {\n iModel[_nativeDb].schemaSyncInit(syncAccess.getUri(), props.containerId, arg.overrideContainer ?? false);\n iModel[_implicitTxn].saveChanges(`Enable SchemaSync (container id: ${props.containerId})`);\n });\n } catch (err) {\n throw err;\n } finally {\n iModel[_implicitTxn].abandonChanges();\n }\n\n if (briefcase) {\n if (arg.overrideContainer)\n await briefcase.pushChanges({ description: `Overriding SchemaSync for iModel with container-id: ${props.containerId}` });\n else\n await briefcase.pushChanges({ description: `Enable SchemaSync for iModel with container-id: ${props.containerId}` });\n }\n };\n\n /** Provides access to a cloud-based `SchemaSyncDb` to hold ECSchemas. */\n export class CloudAccess extends CloudSqlite.DbAccess<SchemaSyncDb> {\n public constructor(props: CloudSqlite.ContainerAccessProps) {\n super({ dbType: SchemaSyncDb, props, dbName: defaultDbName });\n }\n\n public getUri() {\n return `${this.getCloudDb()[_nativeDb].getFilePath()}?vfs=${this.container.cache?.name}&writable=${this.container.isWriteable ? 1 : 0}`;\n }\n /**\n * Initialize a cloud container for use as a SchemaSync. The container must first be created via its storage supplier api (e.g. Azure, or AWS).\n * A valid sasToken that grants write access must be supplied. This function creates and uploads an empty ChannelDb into the container.\n * @note this deletes any existing content in the container.\n */\n public static async initializeDb(props: CloudSqlite.ContainerProps) {\n return super._initializeDb({ props, dbType: SchemaSyncDb, dbName: defaultDbName });\n }\n }\n}\n\n"]}
|
package/lib/cjs/SheetIndex.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Code, CodeScopeProps, EntityReferenceSet, RelatedElementProps, SheetIndexEntryProps, SheetIndexReferenceProps, SheetReferenceProps } from "@itwin/core-common";
|
|
5
5
|
import { InformationReferenceElement } from "./Element";
|
|
6
|
+
import { EditTxn } from "./EditTxn";
|
|
6
7
|
import { IModelDb } from "./IModelDb";
|
|
7
8
|
import { Id64String } from "@itwin/core-bentley";
|
|
8
9
|
import { SheetIndexReferenceRefersToSheetIndex, SheetReferenceRefersToSheet } from "./NavigationRelationship";
|
|
@@ -63,6 +64,8 @@ export declare class SheetIndex extends InformationReferenceElement {
|
|
|
63
64
|
* @returns The Id of the newly inserted SheetIndex
|
|
64
65
|
* @throws [[IModelError]] if there is a problem inserting the SheetIndex
|
|
65
66
|
*/
|
|
67
|
+
static insert(txn: EditTxn, modelId: Id64String, name: string): Id64String;
|
|
68
|
+
/** @deprecated Use SheetIndex.insert(txn, ...) instead. */
|
|
66
69
|
static insert(iModelDb: IModelDb, modelId: Id64String, name: string): Id64String;
|
|
67
70
|
}
|
|
68
71
|
/** The base class for all elements that can participate in a [[SheetIndex]] hierarchy.
|
|
@@ -97,6 +100,8 @@ export declare class SheetIndexFolder extends SheetIndexEntry {
|
|
|
97
100
|
* @returns The Id of the newly inserted SheetIndexFolder element.
|
|
98
101
|
* @throws [[IModelError]] if unable to create the element.
|
|
99
102
|
*/
|
|
103
|
+
static insert(txn: EditTxn, arg: Omit<SheetIndexEntryCreateArgs, "iModelDb">): Id64String;
|
|
104
|
+
/** @deprecated Use SheetIndexFolder.insert(txn, ...) instead. */
|
|
100
105
|
static insert(arg: SheetIndexEntryCreateArgs): Id64String;
|
|
101
106
|
}
|
|
102
107
|
/** A node within one [[SheetIndex]] that incorporates another [[SheetIndex]] as a sub-tree.
|
|
@@ -118,6 +123,8 @@ export declare class SheetIndexReference extends SheetIndexEntry {
|
|
|
118
123
|
* @returns The Id of the newly inserted SheetIndexReference element.
|
|
119
124
|
* @throws [[IModelError]] if unable to create the element.
|
|
120
125
|
*/
|
|
126
|
+
static insert(txn: EditTxn, arg: Omit<SheetIndexReferenceCreateArgs, "iModelDb">): Id64String;
|
|
127
|
+
/** @deprecated Use SheetIndexReference.insert(txn, ...) instead. */
|
|
121
128
|
static insert(arg: SheetIndexReferenceCreateArgs): Id64String;
|
|
122
129
|
/** @alpha */
|
|
123
130
|
protected collectReferenceIds(referenceIds: EntityReferenceSet): void;
|
|
@@ -141,6 +148,8 @@ export declare class SheetReference extends SheetIndexEntry {
|
|
|
141
148
|
* @returns The Id of the newly inserted SheetReference element.
|
|
142
149
|
* @throws [[IModelError]] if unable to create the element.
|
|
143
150
|
*/
|
|
151
|
+
static insert(txn: EditTxn, arg: Omit<SheetReferenceCreateArgs, "iModelDb">): Id64String;
|
|
152
|
+
/** @deprecated Use SheetReference.insert(txn, ...) instead. */
|
|
144
153
|
static insert(arg: SheetReferenceCreateArgs): Id64String;
|
|
145
154
|
/** @alpha */
|
|
146
155
|
protected collectReferenceIds(referenceIds: EntityReferenceSet): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SheetIndex.d.ts","sourceRoot":"","sources":["../../src/SheetIndex.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAe,IAAI,EAAE,cAAc,EAA0B,kBAAkB,EAAe,mBAAmB,EAAE,oBAAoB,EAAyB,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACjP,OAAO,EAAE,2BAA2B,EAAS,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,UAAU,EAAgB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAsD,qCAAqC,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"SheetIndex.d.ts","sourceRoot":"","sources":["../../src/SheetIndex.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAe,IAAI,EAAE,cAAc,EAA0B,kBAAkB,EAAe,mBAAmB,EAAE,oBAAoB,EAAyB,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACjP,OAAO,EAAE,2BAA2B,EAAS,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,UAAU,EAAgB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAsD,qCAAqC,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAGlK;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,0DAA0D;IAC1D,QAAQ,EAAE,QAAQ,CAAC;IACnB,iFAAiF;IACjF,iBAAiB,EAAE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CAA6B;IAE3E,iEAAiE;IAC1D,KAAK,EAAE,2BAA2B,GAAG,SAAS,CAAC;IAEtD,SAAS,aAAa,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ;IAWlE,SAAS,CAAC,MAAM,CAAC,gCAAgC,CAAC,EAAE,EAAE,UAAU,GAAG,mBAAmB;IAItE,MAAM,IAAI,mBAAmB;IAO7C;;;OAGG;WACW,MAAM,CAAC,GAAG,EAAE,wBAAwB;IAQlD;;;OAGG;WACW,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,wBAAwB,EAAE,UAAU,CAAC,GAAG,UAAU;IAC/F,+DAA+D;WACjD,MAAM,CAAC,GAAG,EAAE,wBAAwB,GAAG,UAAU;IAe/D,aAAa;cACM,mBAAmB,CAAC,YAAY,EAAE,kBAAkB,GAAG,IAAI;CAK/E"}
|
package/lib/cjs/SheetIndex.js
CHANGED
|
@@ -10,8 +10,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.SheetReference = exports.SheetIndexReference = exports.SheetIndexFolder = exports.SheetIndexEntry = exports.SheetIndex = void 0;
|
|
11
11
|
const core_common_1 = require("@itwin/core-common");
|
|
12
12
|
const Element_1 = require("./Element");
|
|
13
|
+
const EditTxn_1 = require("./EditTxn");
|
|
13
14
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
14
15
|
const NavigationRelationship_1 = require("./NavigationRelationship");
|
|
16
|
+
const Symbols_1 = require("./internal/Symbols");
|
|
15
17
|
/** A [structured collection]($docs/bis/domains/drawings-sheets#sheet-index) of [[SheetIndexEntry]]s.
|
|
16
18
|
* The sheet index is a tree whose leaf nodes refer to [[Sheet]]s, optionally grouped by [[SheetIndexFolder]]s and/or incorporating
|
|
17
19
|
* sub-trees via [[SheetIndexReference]]s.
|
|
@@ -43,17 +45,10 @@ class SheetIndex extends Element_1.InformationReferenceElement {
|
|
|
43
45
|
};
|
|
44
46
|
return new this(props, iModelDb);
|
|
45
47
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
* @returns The Id of the newly inserted SheetIndex
|
|
51
|
-
* @throws [[IModelError]] if there is a problem inserting the SheetIndex
|
|
52
|
-
*/
|
|
53
|
-
static insert(iModelDb, modelId, name) {
|
|
54
|
-
const instance = this.create(iModelDb, modelId, name);
|
|
55
|
-
const elements = iModelDb.elements;
|
|
56
|
-
instance.id = elements.insertElement(instance.toJSON());
|
|
48
|
+
static insert(txnOrDb, modelId, name) {
|
|
49
|
+
const txn = txnOrDb instanceof EditTxn_1.EditTxn ? txnOrDb : txnOrDb[Symbols_1._implicitTxn];
|
|
50
|
+
const instance = this.create(txn.iModel, modelId, name);
|
|
51
|
+
instance.id = instance.insert(txn);
|
|
57
52
|
return instance.id;
|
|
58
53
|
}
|
|
59
54
|
}
|
|
@@ -113,14 +108,16 @@ class SheetIndexFolder extends SheetIndexEntry {
|
|
|
113
108
|
const props = this.createProps(arg);
|
|
114
109
|
return new this(props, arg.iModelDb);
|
|
115
110
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
111
|
+
static insert(txnOrArg, arg) {
|
|
112
|
+
const txn = txnOrArg instanceof EditTxn_1.EditTxn ? txnOrArg : txnOrArg.iModelDb[Symbols_1._implicitTxn];
|
|
113
|
+
const createArg = txnOrArg instanceof EditTxn_1.EditTxn ? arg : {
|
|
114
|
+
sheetIndexModelId: txnOrArg.sheetIndexModelId,
|
|
115
|
+
parentId: txnOrArg.parentId,
|
|
116
|
+
name: txnOrArg.name,
|
|
117
|
+
priority: txnOrArg.priority,
|
|
118
|
+
};
|
|
119
|
+
const instance = this.create({ ...createArg, iModelDb: txn.iModel });
|
|
120
|
+
instance.id = instance.insert(txn);
|
|
124
121
|
return instance.id;
|
|
125
122
|
}
|
|
126
123
|
}
|
|
@@ -161,14 +158,17 @@ class SheetIndexReference extends SheetIndexEntry {
|
|
|
161
158
|
};
|
|
162
159
|
return new this(props, arg.iModelDb);
|
|
163
160
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
161
|
+
static insert(txnOrArg, arg) {
|
|
162
|
+
const txn = txnOrArg instanceof EditTxn_1.EditTxn ? txnOrArg : txnOrArg.iModelDb[Symbols_1._implicitTxn];
|
|
163
|
+
const createArg = txnOrArg instanceof EditTxn_1.EditTxn ? arg : {
|
|
164
|
+
sheetIndexModelId: txnOrArg.sheetIndexModelId,
|
|
165
|
+
parentId: txnOrArg.parentId,
|
|
166
|
+
name: txnOrArg.name,
|
|
167
|
+
priority: txnOrArg.priority,
|
|
168
|
+
sheetIndexId: txnOrArg.sheetIndexId,
|
|
169
|
+
};
|
|
170
|
+
const instance = this.create({ ...createArg, iModelDb: txn.iModel });
|
|
171
|
+
instance.id = instance.insert(txn);
|
|
172
172
|
return instance.id;
|
|
173
173
|
}
|
|
174
174
|
/** @alpha */
|
|
@@ -215,14 +215,17 @@ class SheetReference extends SheetIndexEntry {
|
|
|
215
215
|
};
|
|
216
216
|
return new this(props, arg.iModelDb);
|
|
217
217
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
218
|
+
static insert(txnOrArg, arg) {
|
|
219
|
+
const txn = txnOrArg instanceof EditTxn_1.EditTxn ? txnOrArg : txnOrArg.iModelDb[Symbols_1._implicitTxn];
|
|
220
|
+
const createArg = txnOrArg instanceof EditTxn_1.EditTxn ? arg : {
|
|
221
|
+
sheetIndexModelId: txnOrArg.sheetIndexModelId,
|
|
222
|
+
parentId: txnOrArg.parentId,
|
|
223
|
+
name: txnOrArg.name,
|
|
224
|
+
priority: txnOrArg.priority,
|
|
225
|
+
sheetId: txnOrArg.sheetId,
|
|
226
|
+
};
|
|
227
|
+
const instance = this.create({ ...createArg, iModelDb: txn.iModel });
|
|
228
|
+
instance.id = instance.insert(txn);
|
|
226
229
|
return instance.id;
|
|
227
230
|
}
|
|
228
231
|
/** @alpha */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SheetIndex.js","sourceRoot":"","sources":["../../src/SheetIndex.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAAiP;AACjP,uCAA+D;AAE/D,sDAA+D;AAC/D,qEAAkK;AAkClK;;;;GAIG;AACH,MAAa,UAAW,SAAQ,qCAA2B;IAClD,MAAM,KAAc,SAAS,KAAa,OAAO,YAAY,CAAC,CAAC,CAAC;IAEvE;;;;OAIG;IACI,MAAM,CAAC,UAAU,CAAC,MAAgB,EAAE,sBAAsC,EAAE,SAAiB;QAClG,MAAM,QAAQ,GAAa,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,yBAAW,CAAC,UAAU,CAAC,CAAC;QAC9E,OAAO,IAAI,kBAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,sBAAsB,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAC1F,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAAC,QAAkB,EAAE,OAAmB,EAAE,IAAY;QACxE,MAAM,KAAK,GAAiB;YAC1B,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE;YACvD,KAAK,EAAE,OAAO;SACf,CAAC;QACF,OAAO,IAAI,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAAC,QAAkB,EAAE,OAAmB,EAAE,IAAY;QACxE,MAAM,QAAQ,GAAG,IAA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------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Elements\n */\n\nimport { BisCodeSpec, Code, CodeScopeProps, CodeSpec, ElementProps, EntityReferenceSet, IModelError, RelatedElementProps, SheetIndexEntryProps, SheetIndexFolderProps, SheetIndexReferenceProps, SheetReferenceProps } from \"@itwin/core-common\";\nimport { InformationReferenceElement, Sheet } from \"./Element\";\nimport { IModelDb } from \"./IModelDb\";\nimport { Id64String, IModelStatus } from \"@itwin/core-bentley\";\nimport { SheetIndexFolderOwnsEntries, SheetIndexOwnsEntries, SheetIndexReferenceRefersToSheetIndex, SheetReferenceRefersToSheet } from \"./NavigationRelationship\";\n\n/** Arguments used to create a [[SheetIndexEntry]].\n * @beta\n */\nexport interface SheetIndexEntryCreateArgs {\n /** The iModel that will contain the sheet index entry. */\n iModelDb: IModelDb;\n /** The Id of the [[SheetIndexModel]] that will contain the sheet index entry. */\n sheetIndexModelId: Id64String;\n /** The [[SheetIndex]] or [[SheetIndexFolder]] that is parent to this SheetIndexEntry */\n parentId: Id64String;\n /** The name of the SheetIndexEntry */\n name: string;\n /** The priority of the SheetIndexEntry */\n priority: number;\n}\n\n/** Arguments supplied when creating a [[SheetIndexReference]].\n * @beta\n */\nexport interface SheetIndexReferenceCreateArgs extends SheetIndexEntryCreateArgs {\n /** The [[SheetIndex]] to which the reference refers. */\n sheetIndexId?: Id64String;\n}\n\n/** Arguments supplied when creating a [[SheetReference]].\n * @beta\n */\nexport interface SheetReferenceCreateArgs extends SheetIndexEntryCreateArgs {\n /** The [[Sheet]] to which the reference refers. */\n sheetId?: Id64String;\n}\n\n/** A [structured collection]($docs/bis/domains/drawings-sheets#sheet-index) of [[SheetIndexEntry]]s.\n * The sheet index is a tree whose leaf nodes refer to [[Sheet]]s, optionally grouped by [[SheetIndexFolder]]s and/or incorporating\n * sub-trees via [[SheetIndexReference]]s.\n * @beta\n */\nexport class SheetIndex extends InformationReferenceElement {\n public static override get className(): string { return \"SheetIndex\"; }\n\n /** Create a Code for a SheetIndex given a name that is meant to be unique within the scope of the specified SheetIndexModel.\n * @param iModel The IModelDb\n * @param scopeSheetIndexModelId The Id of the Model that contains the LinkElement and provides the scope for its name.\n * @param codeValue The SheetIndex name\n */\n public static createCode(iModel: IModelDb, scopeSheetIndexModelId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.sheetIndex);\n return new Code({ spec: codeSpec.id, scope: scopeSheetIndexModelId, value: codeValue });\n }\n\n /** Create a SheetIndex\n * @param iModelDb The IModelDb\n * @param modelId The Id of the Model that contains the SheetIndex and provides the scope for its name.\n * @param name The name (codeValue) of the SheetIndex\n * @returns The newly constructed SheetIndex\n * @throws [[IModelError]] if there is a problem creating the SheetIndex\n */\n public static create(iModelDb: IModelDb, modelId: Id64String, name: string): SheetIndex {\n const props: ElementProps = {\n classFullName: this.classFullName,\n code: this.createCode(iModelDb, modelId, name).toJSON(),\n model: modelId,\n };\n return new this(props, iModelDb);\n }\n\n /** Insert a SheetIndex\n * @param iModelDb The IModelDb\n * @param modelId The Id of the Model that contains the SheetIndex and provides the scope for its name.\n * @param name The name (codeValue) of the SheetIndex\n * @returns The Id of the newly inserted SheetIndex\n * @throws [[IModelError]] if there is a problem inserting the SheetIndex\n */\n public static insert(iModelDb: IModelDb, modelId: Id64String, name: string): Id64String {\n const instance = this.create(iModelDb, modelId, name);\n const elements = iModelDb.elements;\n instance.id = elements.insertElement(instance.toJSON());\n return instance.id;\n }\n}\n\n/** The base class for all elements that can participate in a [[SheetIndex]] hierarchy.\n * @beta\n*/\nexport abstract class SheetIndexEntry extends InformationReferenceElement {\n public static override get className(): string { return \"SheetIndexEntry\"; }\n /** Can be used to prioritize or order members within a SheetIndex or SheetIndexFolder. */\n public entryPriority: number;\n\n protected constructor(props: SheetIndexEntryProps, iModel: IModelDb) {\n super(props, iModel);\n this.entryPriority = props.entryPriority;\n }\n\n public override toJSON(): SheetIndexEntryProps {\n return { ...super.toJSON(), entryPriority: this.entryPriority };\n }\n\n /** Create a Code for a Sheet Index Entry given a name that is meant to be unique within the scope of the specified SheetIndexModel.\n * @param iModel The IModel\n * @param scopeModelId The Id of the [[SheetIndexModel]] that contains the [[SheetIndexEntry]] and provides the scope for its name.\n * @param codeValue The name of the entry\n */\n public static createCode(iModelDb: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModelDb.codeSpecs.getByName(BisCodeSpec.sheetIndexEntry);\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n protected static createParentRelationshipProps(iModelDb: IModelDb, id: Id64String): RelatedElementProps {\n const parentElementProps = iModelDb.elements.getElementProps(id);\n const isFolder = parentElementProps.classFullName === SheetIndexFolder.classFullName;\n const relClass = isFolder ? SheetIndexFolderOwnsEntries : SheetIndexOwnsEntries;\n return { id, relClassName: relClass.classFullName };\n }\n\n protected static createProps(arg: SheetIndexEntryCreateArgs) {\n const parent = this.createParentRelationshipProps(arg.iModelDb, arg.parentId);\n const props: SheetIndexEntryProps = {\n classFullName: this.classFullName,\n model: arg.sheetIndexModelId,\n code: this.createCode(arg.iModelDb, arg.sheetIndexModelId, arg.name),\n entryPriority: arg.priority,\n parent,\n };\n return props;\n }\n}\n\n/** A container used to group [[SheetIndexEntry]]s within a [[SheetIndex]].\n * @beta\n */\nexport class SheetIndexFolder extends SheetIndexEntry {\n public static override get className(): string { return \"SheetIndexFolder\"; }\n\n /** Create a new SheetIndexFolder\n * @returns The newly constructed SheetIndexFolder element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(arg: SheetIndexEntryCreateArgs) {\n const props: SheetIndexFolderProps = this.createProps(arg);\n return new this(props, arg.iModelDb);\n }\n\n /** Create a new SheetIndexFolder\n * @returns The Id of the newly inserted SheetIndexFolder element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static insert(arg: SheetIndexEntryCreateArgs): Id64String {\n const instance = this.create(arg);\n const elements = arg.iModelDb.elements;\n instance.id = elements.insertElement(instance.toJSON());\n return instance.id;\n }\n}\n\n/** A node within one [[SheetIndex]] that incorporates another [[SheetIndex]] as a sub-tree.\n * @beta\n*/\nexport class SheetIndexReference extends SheetIndexEntry {\n public static override get className(): string { return \"SheetIndexReference\"; }\n\n /** The bis:SheetIndex that this bis:SheetIndexReference is pointing to. */\n public sheetIndex?: SheetIndexReferenceRefersToSheetIndex;\n\n protected constructor(props: SheetIndexReferenceProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.sheetIndex) {\n const sheetIndex = iModel.elements.tryGetElement<SheetIndex>(props.sheetIndex.id);\n if (!sheetIndex)\n throw new IModelError(IModelStatus.NotFound, \"SheetIndex not found\");\n\n this.sheetIndex = new SheetIndexReferenceRefersToSheetIndex(props.sheetIndex.id);\n }\n }\n\n protected static createReferenceRelationshipProps(id: Id64String): RelatedElementProps {\n return { id, relClassName: SheetIndexReferenceRefersToSheetIndex.classFullName };\n }\n\n public override toJSON(): SheetIndexReferenceProps { // This override only specializes the return type\n return {\n ...super.toJSON(),\n sheetIndex: this.sheetIndex ? this.sheetIndex.toJSON() : undefined,\n } as SheetIndexReferenceProps;\n }\n\n /** Create a new SheetIndexReference\n * @returns The newly constructed SheetIndexReference element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(arg: SheetIndexReferenceCreateArgs) {\n const props: SheetIndexReferenceProps = {\n ...this.createProps(arg),\n sheetIndex: arg.sheetIndexId ? this.createReferenceRelationshipProps(arg.sheetIndexId) : undefined,\n };\n return new this(props, arg.iModelDb);\n }\n\n /** Create a new SheetIndexReference\n * @returns The Id of the newly inserted SheetIndexReference element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static insert(arg: SheetIndexReferenceCreateArgs): Id64String {\n const instance = this.create(arg);\n const elements = arg.iModelDb.elements;\n instance.id = elements.insertElement(instance.toJSON());\n return instance.id;\n }\n\n /** @alpha */\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n if (this.sheetIndex)\n referenceIds.addElement(this.sheetIndex.id);\n }\n}\n\n/** A leaf node in a [[SheetIndex]] that refers to a specific [[Sheet]].\n * @beta\n*/\nexport class SheetReference extends SheetIndexEntry {\n public static override get className(): string { return \"SheetReference\"; }\n\n /** The bis:Sheet that this bis:SheetReference is pointing to. */\n public sheet: SheetReferenceRefersToSheet | undefined;\n\n protected constructor(props: SheetReferenceProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.sheet) {\n const sheet = iModel.elements.tryGetElement<Sheet>(props.sheet.id);\n if (!sheet)\n throw new IModelError(IModelStatus.NotFound, \"Sheet not found\");\n\n this.sheet = new SheetReferenceRefersToSheet(sheet.id);\n }\n }\n\n protected static createReferenceRelationshipProps(id: Id64String): RelatedElementProps {\n return { id, relClassName: SheetIndexReferenceRefersToSheetIndex.classFullName };\n }\n\n public override toJSON(): SheetReferenceProps { // This override only specializes the return type\n return {\n ...super.toJSON(),\n sheet: this.sheet ? this.sheet.toJSON() : undefined,\n } as SheetReferenceProps;\n }\n\n /** Create a new SheetReference\n * @returns The newly constructed SheetReference element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(arg: SheetReferenceCreateArgs) {\n const props: SheetReferenceProps = {\n ...this.createProps(arg),\n sheet: arg.sheetId ? this.createReferenceRelationshipProps(arg.sheetId) : undefined,\n };\n return new this(props, arg.iModelDb);\n }\n\n /** Insert a new SheetReference\n * @returns The Id of the newly inserted SheetReference element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static insert(arg: SheetReferenceCreateArgs): Id64String {\n const instance = this.create(arg);\n const elements = arg.iModelDb.elements;\n instance.id = elements.insertElement(instance.toJSON());\n return instance.id;\n }\n\n /** @alpha */\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n if (this.sheet)\n referenceIds.addModel(this.sheet.id);\n }\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,CAAC,CAAC,SAAS;SACpF,CAAC;QACF,OAAO,IAAI,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IASM,MAAM,CAAC,MAAM,CAAC,QAA4C,EAAE,GAAgD;QACjH,MAAM,GAAG,GAAG,QAAQ,YAAY,iBAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,sBAAY,CAAC,CAAC;QACrF,MAAM,SAAS,GAAG,QAAQ,YAAY,iBAAO,CAAC,CAAC,CAAC,GAAI,CAAC,CAAC,CAAC;YACrD,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB;YAC7C,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,OAAO,EAAE,QAAQ,CAAC,OAAO;SAC1B,CAAC;QACF,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,SAAS,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;QACrE,QAAQ,CAAC,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO,QAAQ,CAAC,EAAE,CAAC;IACrB,CAAC;IAED,aAAa;IACM,mBAAmB,CAAC,YAAgC;QACrE,KAAK,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;QACxC,IAAI,IAAI,CAAC,KAAK;YACZ,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACzC,CAAC;CACF;AAnED,wCAmEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Elements\n */\n\nimport { BisCodeSpec, Code, CodeScopeProps, CodeSpec, ElementProps, EntityReferenceSet, IModelError, RelatedElementProps, SheetIndexEntryProps, SheetIndexFolderProps, SheetIndexReferenceProps, SheetReferenceProps } from \"@itwin/core-common\";\nimport { InformationReferenceElement, Sheet } from \"./Element\";\nimport { EditTxn } from \"./EditTxn\";\nimport { IModelDb } from \"./IModelDb\";\nimport { Id64String, IModelStatus } from \"@itwin/core-bentley\";\nimport { SheetIndexFolderOwnsEntries, SheetIndexOwnsEntries, SheetIndexReferenceRefersToSheetIndex, SheetReferenceRefersToSheet } from \"./NavigationRelationship\";\nimport { _implicitTxn } from \"./internal/Symbols\";\n\n/** Arguments used to create a [[SheetIndexEntry]].\n * @beta\n */\nexport interface SheetIndexEntryCreateArgs {\n /** The iModel that will contain the sheet index entry. */\n iModelDb: IModelDb;\n /** The Id of the [[SheetIndexModel]] that will contain the sheet index entry. */\n sheetIndexModelId: Id64String;\n /** The [[SheetIndex]] or [[SheetIndexFolder]] that is parent to this SheetIndexEntry */\n parentId: Id64String;\n /** The name of the SheetIndexEntry */\n name: string;\n /** The priority of the SheetIndexEntry */\n priority: number;\n}\n\n/** Arguments supplied when creating a [[SheetIndexReference]].\n * @beta\n */\nexport interface SheetIndexReferenceCreateArgs extends SheetIndexEntryCreateArgs {\n /** The [[SheetIndex]] to which the reference refers. */\n sheetIndexId?: Id64String;\n}\n\n/** Arguments supplied when creating a [[SheetReference]].\n * @beta\n */\nexport interface SheetReferenceCreateArgs extends SheetIndexEntryCreateArgs {\n /** The [[Sheet]] to which the reference refers. */\n sheetId?: Id64String;\n}\n\n/** A [structured collection]($docs/bis/domains/drawings-sheets#sheet-index) of [[SheetIndexEntry]]s.\n * The sheet index is a tree whose leaf nodes refer to [[Sheet]]s, optionally grouped by [[SheetIndexFolder]]s and/or incorporating\n * sub-trees via [[SheetIndexReference]]s.\n * @beta\n */\nexport class SheetIndex extends InformationReferenceElement {\n public static override get className(): string { return \"SheetIndex\"; }\n\n /** Create a Code for a SheetIndex given a name that is meant to be unique within the scope of the specified SheetIndexModel.\n * @param iModel The IModelDb\n * @param scopeSheetIndexModelId The Id of the Model that contains the LinkElement and provides the scope for its name.\n * @param codeValue The SheetIndex name\n */\n public static createCode(iModel: IModelDb, scopeSheetIndexModelId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.sheetIndex);\n return new Code({ spec: codeSpec.id, scope: scopeSheetIndexModelId, value: codeValue });\n }\n\n /** Create a SheetIndex\n * @param iModelDb The IModelDb\n * @param modelId The Id of the Model that contains the SheetIndex and provides the scope for its name.\n * @param name The name (codeValue) of the SheetIndex\n * @returns The newly constructed SheetIndex\n * @throws [[IModelError]] if there is a problem creating the SheetIndex\n */\n public static create(iModelDb: IModelDb, modelId: Id64String, name: string): SheetIndex {\n const props: ElementProps = {\n classFullName: this.classFullName,\n code: this.createCode(iModelDb, modelId, name).toJSON(),\n model: modelId,\n };\n return new this(props, iModelDb);\n }\n\n /** Insert a SheetIndex\n * @param iModelDb The IModelDb\n * @param modelId The Id of the Model that contains the SheetIndex and provides the scope for its name.\n * @param name The name (codeValue) of the SheetIndex\n * @returns The Id of the newly inserted SheetIndex\n * @throws [[IModelError]] if there is a problem inserting the SheetIndex\n */\n public static insert(txn: EditTxn, modelId: Id64String, name: string): Id64String;\n /** @deprecated Use SheetIndex.insert(txn, ...) instead. */\n public static insert(iModelDb: IModelDb, modelId: Id64String, name: string): Id64String;\n public static insert(txnOrDb: EditTxn | IModelDb, modelId: Id64String, name: string): Id64String {\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\n const instance = this.create(txn.iModel, modelId, name);\n instance.id = instance.insert(txn);\n return instance.id;\n }\n}\n\n/** The base class for all elements that can participate in a [[SheetIndex]] hierarchy.\n * @beta\n*/\nexport abstract class SheetIndexEntry extends InformationReferenceElement {\n public static override get className(): string { return \"SheetIndexEntry\"; }\n /** Can be used to prioritize or order members within a SheetIndex or SheetIndexFolder. */\n public entryPriority: number;\n\n protected constructor(props: SheetIndexEntryProps, iModel: IModelDb) {\n super(props, iModel);\n this.entryPriority = props.entryPriority;\n }\n\n public override toJSON(): SheetIndexEntryProps {\n return { ...super.toJSON(), entryPriority: this.entryPriority };\n }\n\n /** Create a Code for a Sheet Index Entry given a name that is meant to be unique within the scope of the specified SheetIndexModel.\n * @param iModel The IModel\n * @param scopeModelId The Id of the [[SheetIndexModel]] that contains the [[SheetIndexEntry]] and provides the scope for its name.\n * @param codeValue The name of the entry\n */\n public static createCode(iModelDb: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModelDb.codeSpecs.getByName(BisCodeSpec.sheetIndexEntry);\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n protected static createParentRelationshipProps(iModelDb: IModelDb, id: Id64String): RelatedElementProps {\n const parentElementProps = iModelDb.elements.getElementProps(id);\n const isFolder = parentElementProps.classFullName === SheetIndexFolder.classFullName;\n const relClass = isFolder ? SheetIndexFolderOwnsEntries : SheetIndexOwnsEntries;\n return { id, relClassName: relClass.classFullName };\n }\n\n protected static createProps(arg: SheetIndexEntryCreateArgs) {\n const parent = this.createParentRelationshipProps(arg.iModelDb, arg.parentId);\n const props: SheetIndexEntryProps = {\n classFullName: this.classFullName,\n model: arg.sheetIndexModelId,\n code: this.createCode(arg.iModelDb, arg.sheetIndexModelId, arg.name),\n entryPriority: arg.priority,\n parent,\n };\n return props;\n }\n}\n\n/** A container used to group [[SheetIndexEntry]]s within a [[SheetIndex]].\n * @beta\n */\nexport class SheetIndexFolder extends SheetIndexEntry {\n public static override get className(): string { return \"SheetIndexFolder\"; }\n\n /** Create a new SheetIndexFolder\n * @returns The newly constructed SheetIndexFolder element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(arg: SheetIndexEntryCreateArgs) {\n const props: SheetIndexFolderProps = this.createProps(arg);\n return new this(props, arg.iModelDb);\n }\n\n /** Create a new SheetIndexFolder\n * @returns The Id of the newly inserted SheetIndexFolder element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static insert(txn: EditTxn, arg: Omit<SheetIndexEntryCreateArgs, \"iModelDb\">): Id64String;\n /** @deprecated Use SheetIndexFolder.insert(txn, ...) instead. */\n public static insert(arg: SheetIndexEntryCreateArgs): Id64String;\n public static insert(txnOrArg: EditTxn | SheetIndexEntryCreateArgs, arg?: Omit<SheetIndexEntryCreateArgs, \"iModelDb\">): Id64String {\n const txn = txnOrArg instanceof EditTxn ? txnOrArg : txnOrArg.iModelDb[_implicitTxn];\n const createArg = txnOrArg instanceof EditTxn ? arg! : {\n sheetIndexModelId: txnOrArg.sheetIndexModelId,\n parentId: txnOrArg.parentId,\n name: txnOrArg.name,\n priority: txnOrArg.priority,\n };\n const instance = this.create({ ...createArg, iModelDb: txn.iModel });\n instance.id = instance.insert(txn);\n return instance.id;\n }\n}\n\n/** A node within one [[SheetIndex]] that incorporates another [[SheetIndex]] as a sub-tree.\n * @beta\n*/\nexport class SheetIndexReference extends SheetIndexEntry {\n public static override get className(): string { return \"SheetIndexReference\"; }\n\n /** The bis:SheetIndex that this bis:SheetIndexReference is pointing to. */\n public sheetIndex?: SheetIndexReferenceRefersToSheetIndex;\n\n protected constructor(props: SheetIndexReferenceProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.sheetIndex) {\n const sheetIndex = iModel.elements.tryGetElement<SheetIndex>(props.sheetIndex.id);\n if (!sheetIndex)\n throw new IModelError(IModelStatus.NotFound, \"SheetIndex not found\");\n\n this.sheetIndex = new SheetIndexReferenceRefersToSheetIndex(props.sheetIndex.id);\n }\n }\n\n protected static createReferenceRelationshipProps(id: Id64String): RelatedElementProps {\n return { id, relClassName: SheetIndexReferenceRefersToSheetIndex.classFullName };\n }\n\n public override toJSON(): SheetIndexReferenceProps { // This override only specializes the return type\n return {\n ...super.toJSON(),\n sheetIndex: this.sheetIndex ? this.sheetIndex.toJSON() : undefined,\n } as SheetIndexReferenceProps;\n }\n\n /** Create a new SheetIndexReference\n * @returns The newly constructed SheetIndexReference element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(arg: SheetIndexReferenceCreateArgs) {\n const props: SheetIndexReferenceProps = {\n ...this.createProps(arg),\n sheetIndex: arg.sheetIndexId ? this.createReferenceRelationshipProps(arg.sheetIndexId) : undefined,\n };\n return new this(props, arg.iModelDb);\n }\n\n /** Create a new SheetIndexReference\n * @returns The Id of the newly inserted SheetIndexReference element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static insert(txn: EditTxn, arg: Omit<SheetIndexReferenceCreateArgs, \"iModelDb\">): Id64String;\n /** @deprecated Use SheetIndexReference.insert(txn, ...) instead. */\n public static insert(arg: SheetIndexReferenceCreateArgs): Id64String;\n public static insert(txnOrArg: EditTxn | SheetIndexReferenceCreateArgs, arg?: Omit<SheetIndexReferenceCreateArgs, \"iModelDb\">): Id64String {\n const txn = txnOrArg instanceof EditTxn ? txnOrArg : txnOrArg.iModelDb[_implicitTxn];\n const createArg = txnOrArg instanceof EditTxn ? arg! : {\n sheetIndexModelId: txnOrArg.sheetIndexModelId,\n parentId: txnOrArg.parentId,\n name: txnOrArg.name,\n priority: txnOrArg.priority,\n sheetIndexId: txnOrArg.sheetIndexId,\n };\n const instance = this.create({ ...createArg, iModelDb: txn.iModel });\n instance.id = instance.insert(txn);\n return instance.id;\n }\n\n /** @alpha */\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n if (this.sheetIndex)\n referenceIds.addElement(this.sheetIndex.id);\n }\n}\n\n/** A leaf node in a [[SheetIndex]] that refers to a specific [[Sheet]].\n * @beta\n*/\nexport class SheetReference extends SheetIndexEntry {\n public static override get className(): string { return \"SheetReference\"; }\n\n /** The bis:Sheet that this bis:SheetReference is pointing to. */\n public sheet: SheetReferenceRefersToSheet | undefined;\n\n protected constructor(props: SheetReferenceProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.sheet) {\n const sheet = iModel.elements.tryGetElement<Sheet>(props.sheet.id);\n if (!sheet)\n throw new IModelError(IModelStatus.NotFound, \"Sheet not found\");\n\n this.sheet = new SheetReferenceRefersToSheet(sheet.id);\n }\n }\n\n protected static createReferenceRelationshipProps(id: Id64String): RelatedElementProps {\n return { id, relClassName: SheetIndexReferenceRefersToSheetIndex.classFullName };\n }\n\n public override toJSON(): SheetReferenceProps { // This override only specializes the return type\n return {\n ...super.toJSON(),\n sheet: this.sheet ? this.sheet.toJSON() : undefined,\n } as SheetReferenceProps;\n }\n\n /** Create a new SheetReference\n * @returns The newly constructed SheetReference element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(arg: SheetReferenceCreateArgs) {\n const props: SheetReferenceProps = {\n ...this.createProps(arg),\n sheet: arg.sheetId ? this.createReferenceRelationshipProps(arg.sheetId) : undefined,\n };\n return new this(props, arg.iModelDb);\n }\n\n /** Insert a new SheetReference\n * @returns The Id of the newly inserted SheetReference element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static insert(txn: EditTxn, arg: Omit<SheetReferenceCreateArgs, \"iModelDb\">): Id64String;\n /** @deprecated Use SheetReference.insert(txn, ...) instead. */\n public static insert(arg: SheetReferenceCreateArgs): Id64String;\n public static insert(txnOrArg: EditTxn | SheetReferenceCreateArgs, arg?: Omit<SheetReferenceCreateArgs, \"iModelDb\">): Id64String {\n const txn = txnOrArg instanceof EditTxn ? txnOrArg : txnOrArg.iModelDb[_implicitTxn];\n const createArg = txnOrArg instanceof EditTxn ? arg! : {\n sheetIndexModelId: txnOrArg.sheetIndexModelId,\n parentId: txnOrArg.parentId,\n name: txnOrArg.name,\n priority: txnOrArg.priority,\n sheetId: txnOrArg.sheetId,\n };\n const instance = this.create({ ...createArg, iModelDb: txn.iModel });\n instance.id = instance.insert(txn);\n return instance.id;\n }\n\n /** @alpha */\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n if (this.sheet)\n referenceIds.addModel(this.sheet.id);\n }\n}\n"]}
|
package/lib/cjs/StashManager.js
CHANGED
|
@@ -304,7 +304,7 @@ class StashManager {
|
|
|
304
304
|
}
|
|
305
305
|
db[Symbols_1._nativeDb].stashRestore(stashFile);
|
|
306
306
|
db[Symbols_1._resetIModelDb]();
|
|
307
|
-
db.saveChanges();
|
|
307
|
+
db[Symbols_1._nativeDb].saveChanges();
|
|
308
308
|
core_bentley_1.Logger.logInfo(loggerCategory, `Restored stash: ${this.getStashId(args)}`);
|
|
309
309
|
}
|
|
310
310
|
}
|