@itwin/core-backend 5.13.0-dev.8 → 5.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -1
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +11 -5
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/Category.d.ts +4 -4
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.d.ts +5 -0
- package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +13 -3
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/CloudSqlite.d.ts.map +1 -1
- package/lib/cjs/CloudSqlite.js +9 -2
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/CodeSpecs.d.ts +3 -3
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/DisplayStyle.d.ts +2 -2
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +1 -0
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/EditTxn.d.ts.map +1 -1
- package/lib/cjs/EditTxn.js +1 -0
- package/lib/cjs/EditTxn.js.map +1 -1
- package/lib/cjs/Element.d.ts +48 -12
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +120 -24
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +72 -22
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +226 -89
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/Model.d.ts +5 -5
- package/lib/cjs/Model.d.ts.map +1 -1
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/PropertyStore.js +1 -1
- package/lib/cjs/PropertyStore.js.map +1 -1
- package/lib/cjs/SchemaSync.d.ts +158 -22
- package/lib/cjs/SchemaSync.d.ts.map +1 -1
- package/lib/cjs/SchemaSync.js +417 -76
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/SynchronousChannel.d.ts +72 -0
- package/lib/cjs/SynchronousChannel.d.ts.map +1 -0
- package/lib/cjs/SynchronousChannel.js +11 -0
- package/lib/cjs/SynchronousChannel.js.map +1 -0
- package/lib/cjs/Texture.d.ts +1 -1
- package/lib/cjs/Texture.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts +44 -4
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +80 -19
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts +6 -6
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/annotations/LeaderGeometry.d.ts +22 -7
- package/lib/cjs/annotations/LeaderGeometry.d.ts.map +1 -1
- package/lib/cjs/annotations/LeaderGeometry.js +104 -36
- package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
- package/lib/cjs/annotations/TextAnnotationElement.d.ts +1 -1
- package/lib/cjs/annotations/TextAnnotationElement.d.ts.map +1 -1
- package/lib/cjs/annotations/TextAnnotationElement.js +25 -10
- 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/internal/IntegrityCheck.d.ts +22 -0
- package/lib/cjs/internal/IntegrityCheck.d.ts.map +1 -1
- package/lib/cjs/internal/IntegrityCheck.js +13 -0
- package/lib/cjs/internal/IntegrityCheck.js.map +1 -1
- package/lib/cjs/internal/NoReservations.d.ts +6 -0
- package/lib/cjs/internal/NoReservations.d.ts.map +1 -0
- package/lib/cjs/internal/NoReservations.js +21 -0
- package/lib/cjs/internal/NoReservations.js.map +1 -0
- package/lib/cjs/internal/SchemaSyncReservations.d.ts +4 -0
- package/lib/cjs/internal/SchemaSyncReservations.d.ts.map +1 -0
- package/lib/cjs/internal/SchemaSyncReservations.js +128 -0
- package/lib/cjs/internal/SchemaSyncReservations.js.map +1 -0
- package/lib/cjs/internal/Symbols.d.ts +1 -0
- package/lib/cjs/internal/Symbols.d.ts.map +1 -1
- package/lib/cjs/internal/Symbols.js +2 -1
- package/lib/cjs/internal/Symbols.js.map +1 -1
- package/lib/esm/BriefcaseManager.d.ts.map +1 -1
- package/lib/esm/BriefcaseManager.js +11 -5
- package/lib/esm/BriefcaseManager.js.map +1 -1
- package/lib/esm/Category.d.ts +4 -4
- package/lib/esm/Category.js.map +1 -1
- package/lib/esm/ChangesetECAdaptor.d.ts +5 -0
- package/lib/esm/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/esm/ChangesetECAdaptor.js +13 -3
- package/lib/esm/ChangesetECAdaptor.js.map +1 -1
- package/lib/esm/CloudSqlite.d.ts.map +1 -1
- package/lib/esm/CloudSqlite.js +10 -3
- package/lib/esm/CloudSqlite.js.map +1 -1
- package/lib/esm/CodeSpecs.d.ts +3 -3
- package/lib/esm/CodeSpecs.js.map +1 -1
- package/lib/esm/DisplayStyle.d.ts +2 -2
- package/lib/esm/DisplayStyle.js.map +1 -1
- package/lib/esm/ECDb.d.ts.map +1 -1
- package/lib/esm/ECDb.js +1 -0
- package/lib/esm/ECDb.js.map +1 -1
- package/lib/esm/EditTxn.d.ts.map +1 -1
- package/lib/esm/EditTxn.js +1 -0
- package/lib/esm/EditTxn.js.map +1 -1
- package/lib/esm/Element.d.ts +48 -12
- package/lib/esm/Element.d.ts.map +1 -1
- package/lib/esm/Element.js +121 -25
- package/lib/esm/Element.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +72 -22
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +227 -90
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/Model.d.ts +5 -5
- package/lib/esm/Model.d.ts.map +1 -1
- package/lib/esm/Model.js.map +1 -1
- package/lib/esm/PropertyStore.js +1 -1
- package/lib/esm/PropertyStore.js.map +1 -1
- package/lib/esm/SchemaSync.d.ts +158 -22
- package/lib/esm/SchemaSync.d.ts.map +1 -1
- package/lib/esm/SchemaSync.js +419 -78
- package/lib/esm/SchemaSync.js.map +1 -1
- package/lib/esm/SynchronousChannel.d.ts +72 -0
- package/lib/esm/SynchronousChannel.d.ts.map +1 -0
- package/lib/esm/SynchronousChannel.js +9 -0
- package/lib/esm/SynchronousChannel.js.map +1 -0
- package/lib/esm/Texture.d.ts +1 -1
- package/lib/esm/Texture.js.map +1 -1
- package/lib/esm/TxnManager.d.ts +44 -4
- package/lib/esm/TxnManager.d.ts.map +1 -1
- package/lib/esm/TxnManager.js +81 -20
- package/lib/esm/TxnManager.js.map +1 -1
- package/lib/esm/ViewDefinition.d.ts +6 -6
- package/lib/esm/ViewDefinition.d.ts.map +1 -1
- package/lib/esm/ViewDefinition.js.map +1 -1
- package/lib/esm/annotations/LeaderGeometry.d.ts +22 -7
- package/lib/esm/annotations/LeaderGeometry.d.ts.map +1 -1
- package/lib/esm/annotations/LeaderGeometry.js +104 -36
- package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
- package/lib/esm/annotations/TextAnnotationElement.d.ts +1 -1
- package/lib/esm/annotations/TextAnnotationElement.d.ts.map +1 -1
- package/lib/esm/annotations/TextAnnotationElement.js +25 -10
- 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/internal/IntegrityCheck.d.ts +22 -0
- package/lib/esm/internal/IntegrityCheck.d.ts.map +1 -1
- package/lib/esm/internal/IntegrityCheck.js +13 -0
- package/lib/esm/internal/IntegrityCheck.js.map +1 -1
- package/lib/esm/internal/NoReservations.d.ts +6 -0
- package/lib/esm/internal/NoReservations.d.ts.map +1 -0
- package/lib/esm/internal/NoReservations.js +18 -0
- package/lib/esm/internal/NoReservations.js.map +1 -0
- package/lib/esm/internal/SchemaSyncReservations.d.ts +4 -0
- package/lib/esm/internal/SchemaSyncReservations.d.ts.map +1 -0
- package/lib/esm/internal/SchemaSyncReservations.js +125 -0
- package/lib/esm/internal/SchemaSyncReservations.js.map +1 -0
- package/lib/esm/internal/Symbols.d.ts +1 -0
- package/lib/esm/internal/Symbols.d.ts.map +1 -1
- package/lib/esm/internal/Symbols.js +1 -0
- package/lib/esm/internal/Symbols.js.map +1 -1
- package/lib/esm/test/IModelTestUtils.d.ts +1 -1
- package/lib/esm/test/IModelTestUtils.d.ts.map +1 -1
- package/lib/esm/test/IModelTestUtils.js +8 -3
- package/lib/esm/test/IModelTestUtils.js.map +1 -1
- package/lib/esm/test/annotations/LeaderGeometry.test.js +178 -2
- package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
- package/lib/esm/test/annotations/TextAnnotation.test.js +48 -18
- package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlStatement.test.js +177 -0
- package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
- package/lib/esm/test/ecdb/QueryReaders.test.js +2 -16
- package/lib/esm/test/ecdb/QueryReaders.test.js.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js +2 -2
- package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
- package/lib/esm/test/element/ElementRoundTrip.test.js +80 -2
- package/lib/esm/test/element/ElementRoundTrip.test.js.map +1 -1
- package/lib/esm/test/hubaccess/Rebase.test.js +3 -1
- package/lib/esm/test/hubaccess/Rebase.test.js.map +1 -1
- package/lib/esm/test/hubaccess/SemanticRebase.test.js +29 -28
- package/lib/esm/test/hubaccess/SemanticRebase.test.js.map +1 -1
- package/lib/esm/test/hubaccess/SemanticRebaseTestUtils.d.ts +3 -0
- package/lib/esm/test/hubaccess/SemanticRebaseTestUtils.d.ts.map +1 -0
- package/lib/esm/test/hubaccess/SemanticRebaseTestUtils.js +15 -0
- package/lib/esm/test/hubaccess/SemanticRebaseTestUtils.js.map +1 -0
- package/lib/esm/test/imodel/IModelECSql.test.d.ts +2 -0
- package/lib/esm/test/imodel/IModelECSql.test.d.ts.map +1 -0
- package/lib/esm/test/imodel/IModelECSql.test.js +367 -0
- package/lib/esm/test/imodel/IModelECSql.test.js.map +1 -0
- package/lib/esm/test/imodel/IModelElements.test.d.ts +2 -0
- package/lib/esm/test/imodel/IModelElements.test.d.ts.map +1 -0
- package/lib/esm/test/imodel/IModelElements.test.js +969 -0
- package/lib/esm/test/imodel/IModelElements.test.js.map +1 -0
- package/lib/esm/test/imodel/IModelGeolocation.test.d.ts +2 -0
- package/lib/esm/test/imodel/IModelGeolocation.test.d.ts.map +1 -0
- package/lib/esm/test/imodel/IModelGeolocation.test.js +539 -0
- package/lib/esm/test/imodel/IModelGeolocation.test.js.map +1 -0
- package/lib/esm/test/imodel/IModelLifecycle.test.d.ts +2 -0
- package/lib/esm/test/imodel/IModelLifecycle.test.d.ts.map +1 -0
- package/lib/esm/test/imodel/IModelLifecycle.test.js +499 -0
- package/lib/esm/test/imodel/IModelLifecycle.test.js.map +1 -0
- package/lib/esm/test/imodel/IModelMetadata.test.d.ts +2 -0
- package/lib/esm/test/imodel/IModelMetadata.test.d.ts.map +1 -0
- package/lib/esm/test/imodel/IModelMetadata.test.js +274 -0
- package/lib/esm/test/imodel/IModelMetadata.test.js.map +1 -0
- package/lib/esm/test/imodel/IModelModels.test.d.ts +2 -0
- package/lib/esm/test/imodel/IModelModels.test.d.ts.map +1 -0
- package/lib/esm/test/imodel/IModelModels.test.js +357 -0
- package/lib/esm/test/imodel/IModelModels.test.js.map +1 -0
- package/lib/esm/test/imodel/IModelRelationships.test.d.ts +2 -0
- package/lib/esm/test/imodel/IModelRelationships.test.d.ts.map +1 -0
- package/lib/esm/test/imodel/IModelRelationships.test.js +407 -0
- package/lib/esm/test/imodel/IModelRelationships.test.js.map +1 -0
- package/lib/esm/test/imodel/IModelTestFixtures.d.ts +53 -0
- package/lib/esm/test/imodel/IModelTestFixtures.d.ts.map +1 -0
- package/lib/esm/test/imodel/IModelTestFixtures.js +107 -0
- package/lib/esm/test/imodel/IModelTestFixtures.js.map +1 -0
- package/lib/esm/test/imodel/IModelViews.test.d.ts +2 -0
- package/lib/esm/test/imodel/IModelViews.test.d.ts.map +1 -0
- package/lib/esm/test/imodel/IModelViews.test.js +199 -0
- package/lib/esm/test/imodel/IModelViews.test.js.map +1 -0
- package/lib/esm/test/index.d.ts +0 -1
- package/lib/esm/test/index.d.ts.map +1 -1
- package/lib/esm/test/index.js +0 -1
- package/lib/esm/test/index.js.map +1 -1
- package/lib/esm/test/standalone/ChangesetReader.test.js +8 -26
- package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
- package/lib/esm/test/standalone/DgnDomainMergeConflict.test.d.ts +2 -0
- package/lib/esm/test/standalone/DgnDomainMergeConflict.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/DgnDomainMergeConflict.test.js +263 -0
- package/lib/esm/test/standalone/DgnDomainMergeConflict.test.js.map +1 -0
- package/lib/esm/test/standalone/GeometryStream.test.js +1 -3
- package/lib/esm/test/standalone/GeometryStream.test.js.map +1 -1
- package/lib/esm/test/standalone/IModelWrite.test.d.ts.map +1 -1
- package/lib/esm/test/standalone/IModelWrite.test.js +78 -1
- package/lib/esm/test/standalone/IModelWrite.test.js.map +1 -1
- package/lib/esm/test/standalone/IntegrityCheck.test.js +29 -10
- package/lib/esm/test/standalone/IntegrityCheck.test.js.map +1 -1
- package/lib/esm/test/standalone/SQliteChangesetReaderAndChangesetECAdaptor.test.js +23 -0
- package/lib/esm/test/standalone/SQliteChangesetReaderAndChangesetECAdaptor.test.js.map +1 -1
- package/lib/esm/test/standalone/SchemaSyncDb.test.d.ts +2 -0
- package/lib/esm/test/standalone/SchemaSyncDb.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/SchemaSyncDb.test.js +201 -0
- package/lib/esm/test/standalone/SchemaSyncDb.test.js.map +1 -0
- package/lib/esm/test/standalone/SchemaSyncElementReservation.test.d.ts +2 -0
- package/lib/esm/test/standalone/SchemaSyncElementReservation.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/SchemaSyncElementReservation.test.js +460 -0
- package/lib/esm/test/standalone/SchemaSyncElementReservation.test.js.map +1 -0
- package/lib/esm/test/standalone/SnapshotDb.test.js +1 -0
- package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
- package/lib/esm/test/standalone/TxnManager.test.js +108 -8
- package/lib/esm/test/standalone/TxnManager.test.js.map +1 -1
- package/package.json +14 -17
- package/lib/esm/test/RevisionUtility.d.ts +0 -33
- package/lib/esm/test/RevisionUtility.d.ts.map +0 -1
- package/lib/esm/test/RevisionUtility.js +0 -52
- package/lib/esm/test/RevisionUtility.js.map +0 -1
- package/lib/esm/test/imodel/IModel.test.d.ts +0 -2
- package/lib/esm/test/imodel/IModel.test.d.ts.map +0 -1
- package/lib/esm/test/imodel/IModel.test.js +0 -3277
- package/lib/esm/test/imodel/IModel.test.js.map +0 -1
|
@@ -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,gDAA6D;AAE7D,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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AAC,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":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module SQLiteDb\r\n */\r\n\r\nimport { CloudSqlite } from \"./CloudSqlite\";\r\nimport { VersionedSqliteDb } from \"./SQLiteDb\";\r\nimport { BriefcaseDb, IModelDb } from \"./IModelDb\";\r\nimport { DbResult, OpenMode } from \"@itwin/core-bentley\";\r\nimport { IModelError, LocalFileName } from \"@itwin/core-common\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { IModelNative } from \"./internal/NativePlatform\";\r\nimport { _implicitTxn, _nativeDb } from \"./internal/Symbols\";\r\n\r\n/** @internal */\r\nexport namespace SchemaSync {\r\n const lockParams: CloudSqlite.ObtainLockParams = { retryDelayMs: 1000, nRetries: 30 };\r\n\r\n /** A CloudSqlite database for synchronizing schema changes across briefcases. */\r\n export class SchemaSyncDb extends VersionedSqliteDb {\r\n public override readonly myVersion = \"4.0.0\";\r\n protected override createDDL() { }\r\n }\r\n\r\n const syncProperty = { namespace: \"itwinjs\", name: \"SchemaSync\" };\r\n const defaultDbName = \"SchemaSyncDb\";\r\n const testSyncCachePropKey = \"test.schema_sync.cache_name\";\r\n // for tests only\r\n export const setTestCache = (iModel: IModelDb, cacheName?: string) => {\r\n if (cacheName)\r\n iModel[_nativeDb].saveLocalValue(testSyncCachePropKey, cacheName);\r\n else\r\n iModel[_nativeDb].deleteLocalValue(testSyncCachePropKey);\r\n };\r\n\r\n const getCloudAccess = async (arg: IModelDb | { readonly fileName: LocalFileName }) => {\r\n let nativeDb: IModelJsNative.DgnDb | undefined;\r\n const argIsIModelDb = arg instanceof IModelDb;\r\n if (argIsIModelDb) {\r\n nativeDb = arg[_nativeDb];\r\n } else {\r\n nativeDb = new IModelNative.platform.DgnDb();\r\n nativeDb.openIModel(arg.fileName, OpenMode.Readonly);\r\n }\r\n\r\n const propsString = nativeDb.queryFileProperty(syncProperty, true) as string | undefined;\r\n if (!propsString)\r\n throw new Error(\"iModel does not have a SchemaSyncDb\");\r\n try {\r\n const props = JSON.parse(propsString) as CloudSqlite.ContainerProps;\r\n const accessToken = await CloudSqlite.requestToken(props);\r\n const access = new CloudAccess({ ...props, accessToken });\r\n Object.assign(access.lockParams, lockParams);\r\n const testSyncCache = nativeDb.queryLocalValue(testSyncCachePropKey);\r\n if (testSyncCache)\r\n access.setCache(CloudSqlite.CloudCaches.getCache({ cacheName: testSyncCache }));\r\n return access;\r\n } finally {\r\n if (!argIsIModelDb) {\r\n nativeDb.closeFile();\r\n }\r\n }\r\n };\r\n\r\n export const withLockedAccess = async (iModel: IModelDb | { readonly fileName: LocalFileName }, args: { operationName: string, openMode?: OpenMode, user?: string }, operation: (access: CloudAccess) => Promise<void>): Promise<void> => {\r\n const access = await getCloudAccess(iModel);\r\n try {\r\n await access.withLockedDb(args, async () => operation(access));\r\n } finally {\r\n access.close();\r\n }\r\n };\r\n\r\n export const withReadonlyAccess = async (iModel: IModelDb | { readonly fileName: LocalFileName }, operation: (access: CloudAccess) => Promise<void>): Promise<void> => {\r\n const access = await getCloudAccess(iModel);\r\n access.synchronizeWithCloud();\r\n access.openForRead();\r\n try {\r\n await operation(access);\r\n } finally {\r\n access.close();\r\n }\r\n };\r\n\r\n export const isEnabled = (iModel: IModelDb) => {\r\n return iModel[_nativeDb].schemaSyncEnabled();\r\n };\r\n\r\n /** Synchronize local briefcase schemas with cloud container */\r\n export const pull = async (iModel: IModelDb) => {\r\n if (iModel[_nativeDb].schemaSyncEnabled() && !iModel.isReadonly) {\r\n await SchemaSync.withReadonlyAccess(iModel, async (syncAccess) => {\r\n const schemaSyncDbUri = syncAccess.getUri();\r\n iModel.clearCaches();\r\n iModel[_nativeDb].schemaSyncPull(schemaSyncDbUri);\r\n iModel[_implicitTxn].saveChanges(\"schema synchronized with cloud container\");\r\n });\r\n }\r\n };\r\n\r\n export const initializeForIModel = async (arg: { iModel: IModelDb, containerProps: CloudSqlite.ContainerProps, overrideContainer?: boolean }) => {\r\n const props = { baseUri: arg.containerProps.baseUri, containerId: arg.containerProps.containerId, storageType: arg.containerProps.storageType }; // sanitize to only known properties\r\n const iModel = arg.iModel;\r\n const briefcase = iModel instanceof BriefcaseDb ? iModel : undefined;\r\n await iModel.acquireSchemaLock();\r\n if (briefcase) {\r\n if (briefcase.txns.hasLocalChanges) {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Enabling SchemaSync for iModel failed. There are unsaved or un-pushed local changes.\");\r\n }\r\n await briefcase.pullChanges();\r\n }\r\n try {\r\n iModel[_implicitTxn].saveFileProperty(syncProperty, JSON.stringify(props));\r\n await withLockedAccess(arg.iModel, { operationName: \"initialize schemaSync\", openMode: OpenMode.Readonly }, async (syncAccess) => {\r\n iModel[_nativeDb].schemaSyncInit(syncAccess.getUri(), props.containerId, arg.overrideContainer ?? false);\r\n iModel[_implicitTxn].saveChanges(`Enable SchemaSync (container id: ${props.containerId})`);\r\n });\r\n } catch (err) {\r\n throw err;\r\n } finally {\r\n iModel[_implicitTxn].abandonChanges();\r\n }\r\n\r\n if (briefcase) {\r\n if (arg.overrideContainer)\r\n await briefcase.pushChanges({ description: `Overriding SchemaSync for iModel with container-id: ${props.containerId}` });\r\n else\r\n await briefcase.pushChanges({ description: `Enable SchemaSync for iModel with container-id: ${props.containerId}` });\r\n }\r\n };\r\n\r\n /** Provides access to a cloud-based `SchemaSyncDb` to hold ECSchemas. */\r\n export class CloudAccess extends CloudSqlite.DbAccess<SchemaSyncDb> {\r\n public constructor(props: CloudSqlite.ContainerAccessProps) {\r\n super({ dbType: SchemaSyncDb, props, dbName: defaultDbName });\r\n }\r\n\r\n public getUri() {\r\n return `${this.getCloudDb()[_nativeDb].getFilePath()}?vfs=${this.container.cache?.name}&writable=${this.container.isWriteable ? 1 : 0}`;\r\n }\r\n /**\r\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).\r\n * A valid sasToken that grants write access must be supplied. This function creates and uploads an empty ChannelDb into the container.\r\n * @note this deletes any existing content in the container.\r\n */\r\n public static async initializeDb(props: CloudSqlite.ContainerProps) {\r\n return super._initializeDb({ props, dbType: SchemaSyncDb, dbName: defaultDbName });\r\n }\r\n }\r\n}\r\n\r\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaSync.js","sourceRoot":"","sources":["../../src/SchemaSync.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,iCAAiC;AACjC,+CAA4C;AAC5C,yCAAyD;AACzD,yCAAmD;AACnD,sDAAkJ;AAClJ,oDAAoI;AAGpI,8DAAyD;AACzD,gDAA6D;AAE7D,gBAAgB;AAChB,IAAiB,UAAU,CAmlB1B;AAnlBD,WAAiB,UAAU;IACzB;;;;;OAKG;IACH,MAAM,UAAU,GAAiC;QAC/C,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE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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;QAED,wFAAwF;QACjF,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAA6B;YAClE,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,aAAa,EAAb,WAAA,aAAa,EAAE,EAAE,CAAC,CAAC;YACnH,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;YAC/B,OAAO,KAAK,CAAC;QACf,CAAC;KACF;IAvBY,sBAAW,cAuBvB,CAAA;AACH,CAAC,EAnlBgB,UAAU,0BAAV,UAAU,QAmlB1B","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module SQLiteDb\r\n */\r\n\r\nimport * as semver from \"semver\";\r\nimport { CloudSqlite } from \"./CloudSqlite\";\r\nimport { SQLiteDb, VersionedSqliteDb } from \"./SQLiteDb\";\r\nimport { BriefcaseDb, IModelDb } from \"./IModelDb\";\r\nimport { BentleyError, ChangeSetStatus, DbResult, Guid, GuidString, Id64, Id64String, IModelStatus, Logger, OpenMode } from \"@itwin/core-bentley\";\r\nimport { BriefcaseIdValue, Code, ElementReservationError, FilePropertyProps, IModelError, LocalFileName } from \"@itwin/core-common\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport type { BlobContainer } from \"./BlobContainerService\";\r\nimport { IModelNative } from \"./internal/NativePlatform\";\r\nimport { _implicitTxn, _nativeDb } from \"./internal/Symbols\";\r\n\r\n/** @internal */\r\nexport namespace SchemaSync {\r\n /** How long a briefcase waits for another briefcase's schema import to finish before giving up.\r\n *\r\n * `nRetries` alone does not bound the wait: when the count runs out `CloudSqlite.withLockedDb` asks\r\n * `onFailure` what to do, and anything other than \"stop\" restarts the whole cycle. Without an\r\n * `onFailure` the caller waits forever with no way to give up, so this supplies one.\r\n */\r\n const lockParams: CloudSqlite.ObtainLockParams = {\r\n retryDelayMs: 6000,\r\n nRetries: 10,\r\n onFailure: async (lockedBy: string, expires: string) => {\r\n Logger.logInfo(\"SchemaSync\", `schema sync container is held by ${lockedBy} until ${expires}; giving up`);\r\n return \"stop\";\r\n },\r\n };\r\n const reservedElementsTableName = \"reserved_elements\";\r\n const maxLocalIdExclusive = 0x10000000000; // 2^40\r\n const idSequenceProp: FilePropertyProps = { namespace: \"schemasync\", name: \"nextReservedElementLocalId\" };\r\n\r\n /** Identifies an element to be reserved in a `SchemaSyncDb`. @internal */\r\n export interface ProposedElementReservation {\r\n readonly federationGuid: GuidString;\r\n readonly ecClassId: Id64String;\r\n readonly code: Code;\r\n readonly isCategory?: boolean;\r\n }\r\n\r\n /** An element reservation that has been persisted in a `SchemaSyncDb`. @internal */\r\n export interface ReservedElement extends ProposedElementReservation {\r\n readonly elementId: Id64String;\r\n }\r\n\r\n export interface ReadMethods {\r\n /** Look up an existing element reservation by federationGuid. */\r\n findReservedElement(federationGuid: GuidString): ReservedElement | undefined;\r\n }\r\n\r\n export interface WriteMethods {\r\n /** Reserve the specified elements in the `SchemaSyncDb`. Throws if any requested reservation conflicts with an existing reservation. */\r\n reserveElements(identities: ProposedElementReservation[]): Promise<void>;\r\n }\r\n\r\n /** A CloudSqlite database for synchronizing schema changes across briefcases. */\r\n export class SchemaSyncDb extends VersionedSqliteDb implements ReadMethods, WriteMethods {\r\n private _supportsReservations?: boolean;\r\n public override readonly myVersion = \"5.0.0\";\r\n protected override createDDL() {\r\n this.ensureReservedElementsTable();\r\n }\r\n\r\n public override openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer) {\r\n super.openDb(dbName, openMode, container);\r\n this._supportsReservations = semver.lte(this.myVersion, semver.minVersion(this.getRequiredVersions().readVersion) ?? \"0.0.0\");\r\n }\r\n\r\n private ensureReservedElementsTable(): void {\r\n if (this._supportsReservations)\r\n return;\r\n\r\n this.executeSQL(`\r\n CREATE TABLE IF NOT EXISTS ${reservedElementsTableName} (\r\n federationGuid BLOB PRIMARY KEY,\r\n elementId INTEGER NOT NULL UNIQUE,\r\n ecClassId INTEGER NOT NULL,\r\n codeSpecId INTEGER NOT NULL,\r\n codeScope TEXT NOT NULL,\r\n codeValue TEXT COLLATE NOCASE\r\n )`);\r\n this.executeSQL(`CREATE UNIQUE INDEX IF NOT EXISTS idx_reserved_elem_code ON ${reservedElementsTableName}(codeSpecId, codeScope, codeValue)`);\r\n const minVersion = `^${this.myVersion}`;\r\n this.setRequiredVersions({ readVersion: minVersion, writeVersion: minVersion });\r\n this._supportsReservations = true;\r\n }\r\n\r\n public findReservedElement(federationGuid: GuidString): ReservedElement | undefined {\r\n if (!this._supportsReservations)\r\n return undefined;\r\n\r\n return this.withPreparedSqliteStatement(\r\n `SELECT elementId, ecClassId, codeSpecId, codeScope, codeValue FROM ${reservedElementsTableName} WHERE federationGuid=?`,\r\n (stmt) => {\r\n stmt.bindGuid(1, federationGuid);\r\n if (!stmt.nextRow())\r\n return undefined;\r\n\r\n return {\r\n federationGuid,\r\n elementId: stmt.getValueId(0),\r\n ecClassId: stmt.getValueId(1),\r\n code: new Code({\r\n spec: stmt.getValueId(2),\r\n scope: stmt.getValueString(3),\r\n value: stmt.getValueStringMaybe(4),\r\n }),\r\n };\r\n },\r\n );\r\n }\r\n\r\n private insertReservedElement(id: ProposedElementReservation, elementId: Id64String): void {\r\n this.withPreparedSqliteStatement(\r\n `INSERT INTO ${reservedElementsTableName} (federationGuid, elementId, ecClassId, codeSpecId, codeScope, codeValue) VALUES (?, ?, ?, ?, ?, ?)`,\r\n (stmt) => {\r\n stmt.bindGuid(1, id.federationGuid);\r\n stmt.bindId(2, elementId);\r\n stmt.bindId(3, id.ecClassId);\r\n stmt.bindId(4, id.code.spec);\r\n stmt.bindString(5, id.code.scope);\r\n if (id.code.value === \"\")\r\n stmt.bindNull(6);\r\n else\r\n stmt.bindString(6, id.code.value);\r\n stmt.stepForWrite();\r\n },\r\n );\r\n }\r\n\r\n public async reserveElements(elements: ProposedElementReservation[]): Promise<void> {\r\n this.ensureReservedElementsTable();\r\n\r\n // Insert new reservations as we go, so later entries in `elements` can dedupe against earlier ones\r\n // through the shared (still-uncommitted) transaction. The caller commits on success and abandons on error.\r\n let nextLocalId = this.getNextReservedElementLocalId();\r\n const firstLocalId = nextLocalId;\r\n\r\n for (const def of elements) {\r\n if (!def.federationGuid || !Guid.isGuid(def.federationGuid)) {\r\n ElementReservationError.throwError(\"invalid-reservation\", {\r\n message: \"Element reservation requires an explicit, valid federationGuid\",\r\n });\r\n }\r\n\r\n // Identity is always the federationGuid. If a reservation already exists for it, it must match exactly.\r\n const existing = this.findReservedElement(def.federationGuid);\r\n if (existing) {\r\n if (!this.existingMatches(existing, def)) {\r\n ElementReservationError.throwError(\"reservation-conflict\", {\r\n message: `Element reservation conflict for federationGuid ${existing.federationGuid}: existing row does not match requested class/code`,\r\n federationGuid: existing.federationGuid,\r\n });\r\n }\r\n continue;\r\n }\r\n\r\n const elementId = Id64.fromLocalAndBriefcaseIds(nextLocalId, BriefcaseIdValue.SchemaSyncElementReserved);\r\n this.insertReservedElement(def, elementId);\r\n // skip a local id for each reserved category because category inserts always trigger a second insert for default subcategory\r\n nextLocalId += def.isCategory ? 2 : 1;\r\n if (nextLocalId >= maxLocalIdExclusive) {\r\n this.abandonChanges();\r\n ElementReservationError.throwError(\"id-sequence-exhausted\", { message: `SchemaSync reserved-element local-id sequence exhausted` });\r\n }\r\n }\r\n\r\n if (nextLocalId !== firstLocalId)\r\n this.setNextReservedElementLocalId(nextLocalId);\r\n }\r\n\r\n private existingMatches(existing: ProposedElementReservation, id: ProposedElementReservation): boolean {\r\n return existing.federationGuid === id.federationGuid\r\n && existing.ecClassId === id.ecClassId\r\n && existing.code.equals(id.code);\r\n }\r\n\r\n private getNextReservedElementLocalId(): number {\r\n const stored = this[_nativeDb].queryFileProperty(idSequenceProp, true) as string | undefined;\r\n const current = stored ? Number(stored) : 1;\r\n if (!Number.isInteger(current) || current < 1)\r\n ElementReservationError.throwError(\"corrupt-reservation-data\", { message: `Corrupt SchemaSync reserved-element local-id counter: '${stored}'` });\r\n\r\n return current;\r\n }\r\n\r\n private setNextReservedElementLocalId(next: number): void {\r\n this[_nativeDb].saveFileProperty(idSequenceProp, String(next));\r\n }\r\n }\r\n\r\n const syncProperty = { namespace: \"itwinjs\", name: \"SchemaSync\" };\r\n const defaultDbName = \"SchemaSyncDb\";\r\n /** The `containerType` recorded on a BlobContainer that holds an iModel's `SchemaSyncDb`. */\r\n export const containerType = \"schema-sync\";\r\n const testSyncCachePropKey = \"test.schema_sync.cache_name\";\r\n // for tests only\r\n export function setTestCache(iModel: IModelDb, cacheName?: string): void {\r\n if (cacheName)\r\n iModel[_nativeDb].saveLocalValue(testSyncCachePropKey, cacheName);\r\n else\r\n iModel[_nativeDb].deleteLocalValue(testSyncCachePropKey);\r\n }\r\n\r\n /** Either an open iModel or the name of a closed briefcase file. Every local read below accepts both, so\r\n * a caller that has only a file name does not have to open a `BriefcaseDb` to ask a question about it.\r\n */\r\n export type IModelOrFileName = IModelDb | { readonly fileName: LocalFileName };\r\n\r\n /** Read from an open iModel, or from a closed file opened readonly for the duration of `operation`. */\r\n function readFromIModel<T>(arg: IModelOrFileName, operation: (nativeDb: IModelJsNative.DgnDb) => T): T {\r\n if (arg instanceof IModelDb)\r\n return operation(arg[_nativeDb]);\r\n\r\n const nativeDb = new IModelNative.platform.DgnDb();\r\n nativeDb.openIModel(arg.fileName, OpenMode.Readonly);\r\n try {\r\n return operation(nativeDb);\r\n } finally {\r\n nativeDb.closeFile();\r\n }\r\n }\r\n\r\n /** Whether this iModel's ECSchemas are governed by a `SchemaSyncDb`.\r\n *\r\n * This is the single question every schema operation branches on. It reads one `be_Prop` row written when\r\n * schema sync was enabled and carried to every other briefcase by that changeset - no cloud access, and it\r\n * works on a readonly briefcase, a checkpoint, or a closed file.\r\n * @note This says nothing about whether the container is reachable, or even named. Use\r\n * [[queryContainerProps]] for that. The two are separate on purpose: a file that says it is governed by a\r\n * sync db must never fall back to importing schemas on its own, whatever state the container is in.\r\n */\r\n export function isEnabled(arg: IModelOrFileName): boolean {\r\n return readFromIModel(arg, (nativeDb) => nativeDb.schemaSyncEnabled());\r\n }\r\n\r\n /** One pass over the values schema sync keeps in the file: which container holds the sync db, plus the\r\n * test-only cache override. Read together so a closed file is opened once.\r\n */\r\n function readLocalSyncProps(arg: IModelOrFileName) {\r\n return readFromIModel(arg, (nativeDb) => {\r\n const propsString = nativeDb.queryFileProperty(syncProperty, true) as string | undefined;\r\n let containerProps: CloudSqlite.ContainerProps | undefined;\r\n if (propsString !== undefined) {\r\n try {\r\n containerProps = JSON.parse(propsString) as CloudSqlite.ContainerProps;\r\n } catch (e) {\r\n // Deliberately not swallowed into `undefined`: that would read as \"schema sync was never\r\n // enabled\" and let this briefcase import schemas on its own.\r\n throw new IModelError(DbResult.BE_SQLITE_CORRUPT, `iModel names a SchemaSyncDb container but the property cannot be read: ${BentleyError.getErrorMessage(e)}`);\r\n }\r\n }\r\n return {\r\n containerProps,\r\n testCacheName: nativeDb.queryLocalValue(testSyncCachePropKey),\r\n };\r\n });\r\n }\r\n\r\n /** The container holding this iModel's `SchemaSyncDb`, or `undefined` if schema sync was never enabled.\r\n *\r\n * Local read of the same `be_Prop` file property that [[initializeForIModel]] wrote. Requesting an access\r\n * token for the container is a separate, asynchronous step.\r\n */\r\n export function queryContainerProps(arg: IModelOrFileName): CloudSqlite.ContainerProps | undefined {\r\n return readLocalSyncProps(arg).containerProps;\r\n }\r\n\r\n interface SharedCloudAccess {\r\n access: CloudAccess;\r\n key: string;\r\n referenceCount: number;\r\n }\r\n\r\n const sharedAccessByContainer = new Map<string, SharedCloudAccess | Promise<SharedCloudAccess>>();\r\n const sharedAccessByInstance = new WeakMap<CloudAccess, SharedCloudAccess>();\r\n\r\n export async function getCloudAccess(arg: IModelOrFileName): Promise<CloudAccess> {\r\n const { containerProps, testCacheName } = readLocalSyncProps(arg);\r\n if (undefined === containerProps)\r\n throw new IModelError(DbResult.BE_SQLITE_NOTFOUND, \"iModel does not have a SchemaSyncDb\");\r\n\r\n const sharedAccessKey = JSON.stringify(containerProps) + (testCacheName ?? \"\");\r\n let shared = sharedAccessByContainer.get(sharedAccessKey);\r\n if (undefined === shared) {\r\n const pending = (async () => {\r\n const accessToken = await CloudSqlite.requestToken(containerProps);\r\n const access = new CloudAccess({ ...containerProps, accessToken });\r\n Object.assign(access.lockParams, lockParams);\r\n if (testCacheName)\r\n access.setCache(CloudSqlite.CloudCaches.getCache({ cacheName: testCacheName }));\r\n\r\n const created = { access, key: sharedAccessKey, referenceCount: 0 };\r\n sharedAccessByInstance.set(access, created);\r\n return created;\r\n })();\r\n sharedAccessByContainer.set(sharedAccessKey, pending);\r\n try {\r\n shared = await pending;\r\n if (sharedAccessByContainer.get(sharedAccessKey) === pending)\r\n sharedAccessByContainer.set(sharedAccessKey, shared);\r\n } catch (error) {\r\n if (sharedAccessByContainer.get(sharedAccessKey) === pending)\r\n sharedAccessByContainer.delete(sharedAccessKey);\r\n throw error;\r\n }\r\n } else if (shared instanceof Promise) {\r\n shared = await shared;\r\n }\r\n\r\n ++shared.referenceCount;\r\n return shared.access;\r\n }\r\n\r\n /** Release an access obtained through [[getCloudAccess]]. */\r\n export function releaseCloudAccess(access: CloudAccess): void {\r\n const shared = sharedAccessByInstance.get(access);\r\n if (undefined === shared) {\r\n access.close();\r\n return;\r\n }\r\n\r\n if (--shared.referenceCount > 0)\r\n return;\r\n\r\n sharedAccessByInstance.delete(access);\r\n if (sharedAccessByContainer.get(shared.key) === shared)\r\n sharedAccessByContainer.delete(shared.key);\r\n access.close();\r\n }\r\n\r\n /** Arguments for [[withLockedAccess]]. */\r\n export interface WithLockedAccessArgs {\r\n operationName: string;\r\n openMode?: OpenMode;\r\n user?: string;\r\n }\r\n\r\n export async function withLockedAccess(iModel: IModelOrFileName, args: WithLockedAccessArgs, operation: (access: CloudAccess) => Promise<void>): Promise<void> {\r\n const access = await SchemaSync.getCloudAccess(iModel);\r\n try {\r\n await access.withLockedDb(args, async () => operation(access));\r\n } finally {\r\n releaseCloudAccess(access);\r\n }\r\n }\r\n\r\n /** Build the tables and indexes the briefcase's `ec_` rows describe. A merged schema changeset carries\r\n * those rows but no DDL, so the physical columns are missing until this runs. Needs no cloud access.\r\n */\r\n export function updateDbSchema(iModel: IModelDb): void {\r\n if (isEnabled(iModel) && !iModel.isReadonly) {\r\n iModel.clearCaches();\r\n iModel[_nativeDb].schemaSyncUpdateDbSchema();\r\n iModel[_implicitTxn].saveChanges(\"materialized db schema from ec_ tables\");\r\n }\r\n }\r\n\r\n /** Whether a failed [[IModelDb.importSchemas]] can be retried through the upgrade path.\r\n *\r\n * The update tier refuses two kinds of change: one that has to move data between columns, and one\r\n * that destroys instances or property values. They arrive as different statuses because they are\r\n * different changes, but they mean one thing to a caller - this needs\r\n * [[BriefcaseDb.upgradeSchemas]], which takes the exclusive schema lock.\r\n *\r\n * The retry is the app's decision, not the platform's: taking that lock disturbs everyone else, so\r\n * only the app knows whether to do it now, schedule it, or tell the user.\r\n * ```ts\r\n * try {\r\n * await db.importSchemas(files);\r\n * } catch (e) {\r\n * if (!SchemaSync.requiresUpgrade(e)) throw e;\r\n * await db.upgradeSchemas(files, { description: \"...\" });\r\n * }\r\n * ```\r\n * @internal\r\n */\r\n export function requiresUpgrade(error: unknown): boolean {\r\n const errorNumber = (error as { errorNumber?: number } | undefined)?.errorNumber;\r\n return errorNumber === DbResult.BE_SQLITE_ERROR_DataTransformRequired\r\n || errorNumber === DbResult.BE_SQLITE_ERROR_DataDeletionRequired;\r\n }\r\n\r\n /** Arguments for [[createContainerForIModel]]. */\r\n export interface CreateContainerForIModelArgs {\r\n iModel: IModelDb;\r\n label?: string;\r\n description?: string;\r\n }\r\n\r\n /** Create a cloud container to hold this iModel's `SchemaSyncDb`, and initialize it as empty.\r\n *\r\n * The container is scoped to the iModel, so the service deletes it when the iModel is deleted. Pass the\r\n * returned props to [[initializeForIModel]] - the two calls together are what enables schema sync on an\r\n * iModel that was created without it.\r\n * @note The current user must be authorized to create containers for the iTwin.\r\n */\r\n export async function createContainerForIModel(arg: CreateContainerForIModelArgs): Promise<CloudSqlite.ContainerProps> {\r\n const iModel = arg.iModel;\r\n const iTwinId = iModel.iTwinId;\r\n if (undefined === iTwinId)\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Cannot create a SchemaSync container for an iModel that has no iTwin\");\r\n\r\n return CloudAccess.createNewContainer({\r\n scope: { iTwinId, iModelId: iModel.iModelId },\r\n metadata: { label: arg.label ?? `SchemaSync for ${iModel.name}`, description: arg.description },\r\n });\r\n }\r\n\r\n /** Arguments for [[initializeForIModel]]. */\r\n export interface InitializeForIModelArgs {\r\n iModel: IModelDb;\r\n containerProps: CloudSqlite.ContainerProps;\r\n /** Replace the container already recorded on this iModel instead of failing. */\r\n overrideContainer?: boolean;\r\n }\r\n\r\n /** Refuse initialization before a caller provisions a container, then hold the exclusive schema lock and pull to the tip. */\r\n async function prepareToInitializeForIModel(iModel: IModelDb, overrideContainer: boolean): Promise<BriefcaseDb | undefined> {\r\n const briefcase = iModel instanceof BriefcaseDb ? iModel : undefined;\r\n if (briefcase && !briefcase.locks.isServerBased)\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Cannot enable SchemaSync without server-based locking\");\r\n\r\n if (briefcase && (iModel[_nativeDb].hasUnsavedChanges() || briefcase.txns.hasLocalChanges))\r\n throw new IModelError(ChangeSetStatus.HasLocalChanges, \"Cannot enable SchemaSync while there are local changes\");\r\n\r\n const assertContainerCanBeInitialized = () => {\r\n const localInfo = iModel[_nativeDb].schemaSyncGetLocalDbInfo();\r\n if (localInfo && !overrideContainer)\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Local db already initialized to schema sync (container-id: ${localInfo.id})`);\r\n };\r\n\r\n assertContainerCanBeInitialized();\r\n await iModel.acquireSchemaLock();\r\n await briefcase?.pullChanges();\r\n assertContainerCanBeInitialized();\r\n return briefcase;\r\n }\r\n\r\n async function initializeAfterPreflight(arg: InitializeForIModelArgs, briefcase: BriefcaseDb | undefined): Promise<void> {\r\n const props = { baseUri: arg.containerProps.baseUri, containerId: arg.containerProps.containerId, storageType: arg.containerProps.storageType }; // sanitize to only known properties\r\n const iModel = arg.iModel;\r\n const description = arg.overrideContainer\r\n ? `Overriding SchemaSync for iModel with container-id: ${props.containerId}`\r\n : `Enable SchemaSync for iModel with container-id: ${props.containerId}`;\r\n const txnBeforeInit = briefcase?.txns.getCurrentTxnId();\r\n try {\r\n iModel[_implicitTxn].saveFileProperty(syncProperty, JSON.stringify(props));\r\n try {\r\n await withLockedAccess(iModel, { operationName: \"initialize schemaSync\", openMode: OpenMode.Readonly }, async (syncAccess) => {\r\n iModel[_nativeDb].schemaSyncInit(syncAccess.getUri(), props.containerId, arg.overrideContainer ?? false);\r\n iModel[_implicitTxn].saveChanges(description);\r\n });\r\n } catch (error) {\r\n iModel[_implicitTxn].abandonChanges();\r\n if (briefcase && txnBeforeInit !== undefined && briefcase.txns.getCurrentTxnId() !== txnBeforeInit) {\r\n const status = briefcase[_nativeDb].cancelTo(txnBeforeInit, true);\r\n if (status !== IModelStatus.Success)\r\n Logger.logError(\"SchemaSync\", `Failed to roll back schema sync initialization after the container upload failed: ${IModelStatus[status] ?? status}`);\r\n }\r\n throw error;\r\n }\r\n\r\n // Upload the initialized container before publishing the property that tells every briefcase to use it.\r\n // If the push fails, this briefcase keeps the local txn and exclusive schema lock so the push can be retried.\r\n await briefcase?.pushChanges({ description });\r\n } finally {\r\n iModel[_implicitTxn].abandonChanges();\r\n }\r\n\r\n await iModel.initializeSharedElementReservations();\r\n }\r\n\r\n /** Enable schema sync for an iModel, seeding the container from this briefcase.\r\n * @note Takes the exclusive schema lock, refuses local changes, and pulls the briefcase to the tip before writing the container.\r\n * If this operation fails after acquiring the schema lock, it leaves the lock held.\r\n */\r\n export async function initializeForIModel(arg: InitializeForIModelArgs): Promise<void> {\r\n const briefcase = await prepareToInitializeForIModel(arg.iModel, arg.overrideContainer ?? false);\r\n await initializeAfterPreflight(arg, briefcase);\r\n }\r\n\r\n /** The part of a SchemaSyncDb to restore from an authoritative briefcase. @alpha */\r\n export type RepairScope = \"schemaMetadata\" | \"schemaMetadataAndProfile\";\r\n\r\n const nativeRepairScope: Record<RepairScope, number> = {\r\n schemaMetadata: 0,\r\n schemaMetadataAndProfile: 1,\r\n };\r\n\r\n /** Arguments for [[repairForIModel]]. @alpha */\r\n export interface RepairForIModelArgs {\r\n /** A clean SchemaSync-enabled briefcase at the tip of the iModel timeline. */\r\n iModel: BriefcaseDb;\r\n /** Include the schema-owned EC and BeSQLite profile table definitions. */\r\n scope?: RepairScope;\r\n }\r\n\r\n /** Restore the schema-owned portion of the SchemaSyncDb from a briefcase at the tip of the timeline.\r\n *\r\n * This operation takes the exclusive schema lock and refuses to pull or modify the briefcase. Element\r\n * reservations and all other target-only state in the SchemaSyncDb are preserved.\r\n * @alpha\r\n */\r\n export async function repairForIModel(arg: RepairForIModelArgs): Promise<void> {\r\n const iModel = arg.iModel;\r\n if (!isEnabled(iModel))\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Cannot repair SchemaSync because it is not enabled for this iModel\");\r\n\r\n if (iModel[_nativeDb].hasUnsavedChanges() || iModel.txns.hasLocalChanges)\r\n throw new IModelError(ChangeSetStatus.HasLocalChanges, \"Cannot repair SchemaSync while there are local changes\");\r\n\r\n if (!iModel.locks.isServerBased)\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Cannot repair SchemaSync without server-based locking\");\r\n\r\n if (arg.scope !== undefined && arg.scope !== \"schemaMetadata\" && arg.scope !== \"schemaMetadataAndProfile\")\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Unknown SchemaSync repair scope\");\r\n\r\n const briefcaseManagerModule = await import(\"./BriefcaseManager\");\r\n const assertBriefcaseIsAtTip = async () => {\r\n const latestChangeset = await briefcaseManagerModule.BriefcaseManager.getLatestChangeset({ iModelId: iModel.iModelId });\r\n if (latestChangeset.id !== iModel.changeset.id)\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Cannot repair SchemaSync from a briefcase that is not at the tip of the iModel timeline\");\r\n };\r\n\r\n // Avoid asking Hub for an exclusive lock it cannot grant to a briefcase that first needs to pull.\r\n await assertBriefcaseIsAtTip();\r\n const schemaLockWasHeld = iModel.holdsSchemaLock;\r\n if (!schemaLockWasHeld)\r\n await iModel.acquireSchemaLock();\r\n try {\r\n // Close the race between the preflight query and acquiring the exclusive lock.\r\n await assertBriefcaseIsAtTip();\r\n const repairScope = nativeRepairScope[arg.scope ?? \"schemaMetadata\"];\r\n await withLockedAccess(iModel, { openMode: OpenMode.Readonly, operationName: \"repair schema sync\" }, async (syncAccess) => {\r\n const nativeDb = iModel[_nativeDb] as IModelJsNative.DgnDb & { schemaSyncRepair(syncDbUri: string, scope: number): void };\r\n nativeDb.schemaSyncRepair(syncAccess.getUri(), repairScope);\r\n });\r\n Logger.logInfo(\"SchemaSync\", `Repaired SchemaSyncDb from changeset ${iModel.changeset.id || \"0\"}`);\r\n } finally {\r\n if (!schemaLockWasHeld)\r\n await iModel.locks.abandonAllLocks();\r\n }\r\n }\r\n\r\n /** Arguments for [[enableForIModel]]. */\r\n export interface EnableForIModelArgs {\r\n iModel: IModelDb;\r\n /** An existing container to use. When omitted one is created for this iModel. */\r\n containerProps?: CloudSqlite.ContainerProps;\r\n /** Replace the container already recorded on this iModel instead of failing. */\r\n overrideContainer?: boolean;\r\n label?: string;\r\n description?: string;\r\n }\r\n\r\n /** Turn schema sync on for an iModel: create the container if needed, record it, and seed it.\r\n *\r\n * The single call callers should use. [[createContainerForIModel]] and [[initializeForIModel]] have\r\n * to happen in this order, and an iModel left between the two is one that names a container nothing\r\n * has seeded.\r\n * @returns the container props recorded on the iModel.\r\n * @note Takes the exclusive schema lock and pushes, same protocol as [[BriefcaseDb.upgradeSchemas]] -\r\n * every operation that changes how a file is governed uses it. If this operation fails after acquiring the schema lock,\r\n * it leaves the lock held.\r\n */\r\n export async function enableForIModel(arg: EnableForIModelArgs): Promise<CloudSqlite.ContainerProps> {\r\n if (undefined === arg.containerProps && undefined === arg.iModel.iTwinId)\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Cannot create a SchemaSync container for an iModel that has no iTwin\");\r\n\r\n const briefcase = await prepareToInitializeForIModel(arg.iModel, arg.overrideContainer ?? false);\r\n const containerProps = arg.containerProps\r\n ?? await createContainerForIModel({ iModel: arg.iModel, label: arg.label, description: arg.description });\r\n await initializeAfterPreflight({ iModel: arg.iModel, containerProps, overrideContainer: arg.overrideContainer }, briefcase);\r\n return containerProps;\r\n }\r\n\r\n /** Arguments for [[CloudAccess.createNewContainer]]. */\r\n export interface CreateNewContainerProps {\r\n scope: BlobContainer.Scope;\r\n metadata: Omit<BlobContainer.Metadata, \"containerType\">;\r\n }\r\n\r\n /** Provides access to a cloud-based `SchemaSyncDb` to hold ECSchemas. */\r\n export class CloudAccess extends CloudSqlite.DbAccess<SchemaSyncDb, ReadMethods, WriteMethods> {\r\n public constructor(props: CloudSqlite.ContainerAccessProps) {\r\n super({ dbType: SchemaSyncDb, props, dbName: defaultDbName });\r\n }\r\n\r\n public getUri() {\r\n return `${this.getCloudDb()[_nativeDb].getFilePath()}?vfs=${this.container.cache?.name}&writable=${this.container.isWriteable ? 1 : 0}`;\r\n }\r\n /**\r\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).\r\n * A valid sasToken that grants write access must be supplied. This function creates and uploads an empty ChannelDb into the container.\r\n * @note this deletes any existing content in the container.\r\n */\r\n public static async initializeDb(props: CloudSqlite.ContainerProps) {\r\n return super._initializeDb({ props, dbType: SchemaSyncDb, dbName: defaultDbName });\r\n }\r\n\r\n /** Create and initialize a new `schema-sync` BlobContainer to hold a `SchemaSyncDb`. */\r\n public static async createNewContainer(args: CreateNewContainerProps): Promise<CloudSqlite.ContainerProps> {\r\n const props = await this.createBlobContainer({ scope: args.scope, metadata: { ...args.metadata, containerType } });\r\n await this.initializeDb(props);\r\n return props;\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module iModels
|
|
3
|
+
*/
|
|
4
|
+
import { GuidString } from "@itwin/core-bentley";
|
|
5
|
+
import { CodeProps } from "@itwin/core-common";
|
|
6
|
+
import { _close, _implementationProhibited, _onReservedElementInsert } from "./internal/Symbols";
|
|
7
|
+
import { OnElementPropsArg } from "./Element";
|
|
8
|
+
/** Types used by the synchronous coordination channels that help multiple briefcases avoid conflicts
|
|
9
|
+
* before they appear in the asynchronous changeset timeline.
|
|
10
|
+
* @beta
|
|
11
|
+
*/
|
|
12
|
+
export declare namespace SynchronousChannel {
|
|
13
|
+
/** Arguments for [[SynchronousChannel.Reservations.reserveElements]].
|
|
14
|
+
* @beta
|
|
15
|
+
*/
|
|
16
|
+
interface ReserveElementsArgs {
|
|
17
|
+
/** The elements to reserve. The whole batch succeeds or fails together.
|
|
18
|
+
* @note Every element listed here becomes a *shared* element that must be inserted identically by every briefcase. See the note on [[SynchronousChannel.Reservations]].
|
|
19
|
+
*/
|
|
20
|
+
elements: Iterable<{
|
|
21
|
+
/** The federationGuid that stably identifies this element across briefcases. Reservations always require an explicit federationGuid. */
|
|
22
|
+
federationGuid: GuidString;
|
|
23
|
+
classFullName: string;
|
|
24
|
+
/** The Code for this element. When a non-empty [[Code.value]] is supplied, it must be unique across all reservations. Defaults to an empty Code. */
|
|
25
|
+
code?: CodeProps;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Interface used to ***reserve*** elements with shared identities as part of [coordinating simultaneous edits]($docs/learning/backend/ConcurrencyControl.md) from multiple briefcases.
|
|
30
|
+
* Unlike **locks** (via [[LockControl]]), which block users from making conflicting changes to existing elements, **reservations** can be used to communicate "in-flight"
|
|
31
|
+
* changes between briefcases, allowing users to concurrently add and use identical dependencies (e.g., component definitions, schemas, etc.) without introducing conflicts.
|
|
32
|
+
*
|
|
33
|
+
* @note A reserved element is a *shared* element: every briefcase that inserts it must insert the **exact same element**. The reservation assigns a single shared
|
|
34
|
+
* ElementId that all briefcases use, and when multiple briefcases push their inserts they are merged together as one row rather than producing a conflict.
|
|
35
|
+
* Because these duplicate inserts are silently collapsed, the property values written by each briefcase are **not** reconciled — if two briefcases insert the same reserved
|
|
36
|
+
* element with *different* contents, one briefcase's values win arbitrarily and the other's changes will be lost. Callers are therefore responsible for ensuring that every
|
|
37
|
+
* insert of a given reserved element has the same property values across all briefcases. Only use reservations for content that is deterministically identical everywhere.
|
|
38
|
+
* @see [[IModelDb.reservations]] to access the reservations for an iModel.
|
|
39
|
+
* @beta
|
|
40
|
+
*/
|
|
41
|
+
interface Reservations {
|
|
42
|
+
/** @internal*/
|
|
43
|
+
readonly [_implementationProhibited]: unknown;
|
|
44
|
+
/** @internal true if this Reservations uses a server-based concurrency approach. */
|
|
45
|
+
readonly isServerBased: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Close the local reservation database
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
[_close]: () => void;
|
|
51
|
+
/**
|
|
52
|
+
* Notification that a new element with an explicitly-set federationGuid is being inserted. Called by [[Element.onInsert]]
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
[_onReservedElementInsert]: (arg: OnElementPropsArg) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Determine whether an ID has already been reserved for a future element with the given federationGuid.
|
|
58
|
+
* @note Due to local caching, a return value of `false` cannot be taken as a guarantee that no other briefcase has already reserved the same
|
|
59
|
+
* element, only that a reservation for the element with the given federationGuid was seen as of the last call to [[reserveElements]].
|
|
60
|
+
* @throws [ElementReservationError]($common) if the federationGuid is not a valid GUID.
|
|
61
|
+
*/
|
|
62
|
+
needsElementReservation(federationGuid: GuidString): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Acquire reservations for one or more elements from the reservation service, if required and not already reserved by another user.
|
|
65
|
+
* @note Reserving an element establishes a shared identity that every briefcase must insert *identically*. See the note on [[SynchronousChannel.Reservations]] for why divergent
|
|
66
|
+
* inserts of the same reserved element are unsafe.
|
|
67
|
+
* @throws Error if the requested elements are inconsistent with existing reservations, or if any other error occurs while updating the reservations.
|
|
68
|
+
*/
|
|
69
|
+
reserveElements(args: ReserveElementsArgs): Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=SynchronousChannel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SynchronousChannel.d.ts","sourceRoot":"","sources":["../../src/SynchronousChannel.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACjG,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C;;;GAGG;AACH,yBAAiB,kBAAkB,CAAC;IAClC;;OAEG;IACH,UAAiB,mBAAmB;QAClC;;WAEG;QACH,QAAQ,EAAE,QAAQ,CAAC;YACjB,wIAAwI;YACxI,cAAc,EAAE,UAAU,CAAC;YAC3B,aAAa,EAAE,MAAM,CAAC;YACtB,oJAAoJ;YACpJ,IAAI,CAAC,EAAE,SAAS,CAAC;SAClB,CAAC,CAAC;KACJ;IAED;;;;;;;;;;;;OAYG;IACH,UAAiB,YAAY;QAC3B,eAAe;QACf,QAAQ,CAAC,CAAC,yBAAyB,CAAC,EAAE,OAAO,CAAC;QAE9C,oFAAoF;QACpF,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;QAEhC;;;WAGG;QACH,CAAC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;QAErB;;;WAGG;QACH,CAAC,wBAAwB,CAAC,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,IAAI,CAAC;QAE7D;;;;;WAKG;QACH,uBAAuB,CAAC,cAAc,EAAE,UAAU,GAAG,OAAO,CAAC;QAE7D;;;;;WAKG;QACH,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KAC3D;CAEF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module iModels
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
const Symbols_1 = require("./internal/Symbols");
|
|
11
|
+
//# sourceMappingURL=SynchronousChannel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SynchronousChannel.js","sourceRoot":"","sources":["../../src/SynchronousChannel.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAIH,gDAAiG","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module iModels\r\n */\r\n\r\nimport { GuidString } from \"@itwin/core-bentley\";\r\nimport { CodeProps } from \"@itwin/core-common\";\r\nimport { _close, _implementationProhibited, _onReservedElementInsert } from \"./internal/Symbols\";\r\nimport { OnElementPropsArg } from \"./Element\";\r\n\r\n/** Types used by the synchronous coordination channels that help multiple briefcases avoid conflicts\r\n * before they appear in the asynchronous changeset timeline.\r\n * @beta\r\n */\r\nexport namespace SynchronousChannel {\r\n /** Arguments for [[SynchronousChannel.Reservations.reserveElements]].\r\n * @beta\r\n */\r\n export interface ReserveElementsArgs {\r\n /** The elements to reserve. The whole batch succeeds or fails together.\r\n * @note Every element listed here becomes a *shared* element that must be inserted identically by every briefcase. See the note on [[SynchronousChannel.Reservations]].\r\n */\r\n elements: Iterable<{\r\n /** The federationGuid that stably identifies this element across briefcases. Reservations always require an explicit federationGuid. */\r\n federationGuid: GuidString;\r\n classFullName: string;\r\n /** The Code for this element. When a non-empty [[Code.value]] is supplied, it must be unique across all reservations. Defaults to an empty Code. */\r\n code?: CodeProps;\r\n }>;\r\n }\r\n\r\n /**\r\n * Interface used to ***reserve*** elements with shared identities as part of [coordinating simultaneous edits]($docs/learning/backend/ConcurrencyControl.md) from multiple briefcases.\r\n * Unlike **locks** (via [[LockControl]]), which block users from making conflicting changes to existing elements, **reservations** can be used to communicate \"in-flight\"\r\n * changes between briefcases, allowing users to concurrently add and use identical dependencies (e.g., component definitions, schemas, etc.) without introducing conflicts.\r\n *\r\n * @note A reserved element is a *shared* element: every briefcase that inserts it must insert the **exact same element**. The reservation assigns a single shared\r\n * ElementId that all briefcases use, and when multiple briefcases push their inserts they are merged together as one row rather than producing a conflict.\r\n * Because these duplicate inserts are silently collapsed, the property values written by each briefcase are **not** reconciled — if two briefcases insert the same reserved\r\n * element with *different* contents, one briefcase's values win arbitrarily and the other's changes will be lost. Callers are therefore responsible for ensuring that every\r\n * insert of a given reserved element has the same property values across all briefcases. Only use reservations for content that is deterministically identical everywhere.\r\n * @see [[IModelDb.reservations]] to access the reservations for an iModel.\r\n * @beta\r\n */\r\n export interface Reservations {\r\n /** @internal*/\r\n readonly [_implementationProhibited]: unknown;\r\n\r\n /** @internal true if this Reservations uses a server-based concurrency approach. */\r\n readonly isServerBased: boolean;\r\n\r\n /**\r\n * Close the local reservation database\r\n * @internal\r\n */\r\n [_close]: () => void;\r\n\r\n /**\r\n * Notification that a new element with an explicitly-set federationGuid is being inserted. Called by [[Element.onInsert]]\r\n * @internal\r\n */\r\n [_onReservedElementInsert]: (arg: OnElementPropsArg) => void;\r\n\r\n /**\r\n * Determine whether an ID has already been reserved for a future element with the given federationGuid.\r\n * @note Due to local caching, a return value of `false` cannot be taken as a guarantee that no other briefcase has already reserved the same\r\n * element, only that a reservation for the element with the given federationGuid was seen as of the last call to [[reserveElements]].\r\n * @throws [ElementReservationError]($common) if the federationGuid is not a valid GUID.\r\n */\r\n needsElementReservation(federationGuid: GuidString): boolean;\r\n\r\n /**\r\n * Acquire reservations for one or more elements from the reservation service, if required and not already reserved by another user.\r\n * @note Reserving an element establishes a shared identity that every briefcase must insert *identically*. See the note on [[SynchronousChannel.Reservations]] for why divergent\r\n * inserts of the same reserved element are unsafe.\r\n * @throws Error if the requested elements are inconsistent with existing reservations, or if any other error occurs while updating the reservations.\r\n */\r\n reserveElements(args: ReserveElementsArgs): Promise<void>;\r\n }\r\n\r\n}\r\n"]}
|
package/lib/cjs/Texture.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ export declare class Texture extends DefinitionElement {
|
|
|
57
57
|
*/
|
|
58
58
|
static insertTexture(txn: EditTxn, definitionModelId: Id64String, name: string, format: ImageSourceFormat, data: Uint8Array | Base64EncodedString, description?: string): Id64String;
|
|
59
59
|
/** Insert a new texture into a [[DefinitionModel]].
|
|
60
|
-
* @deprecated in 5.9.0 -
|
|
60
|
+
* @deprecated in 5.9.0 - might be removed in next major version. Use Texture.insertTexture(txn, ...) instead.
|
|
61
61
|
*/
|
|
62
62
|
static insertTexture(iModelDb: IModelDb, definitionModelId: Id64String, name: string, format: ImageSourceFormat, data: Uint8Array | Base64EncodedString, description?: string): Id64String;
|
|
63
63
|
}
|
package/lib/cjs/Texture.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Texture.js","sourceRoot":"","sources":["../../src/Texture.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,oDAE4B;AAC5B,uCAA8C;AAC9C,uCAAoC;AAEpC,gDAAkD;AAUlD;;GAEG;AACH,MAAa,OAAQ,SAAQ,2BAAiB;IAC5C,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,SAAS,CAAC,CAAC,CAAC;IAC7D,MAAM,CAAoB;IAC1B,IAAI,CAAa;IACjB,WAAW,CAAU;IAE5B,YAAY;IACZ,YAAsB,KAAyB,EAAE,MAAgB;QAC/D,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,iCAAmB,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;QACvG,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;IACvC,CAAC;IAEe,MAAM;QACpB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAkB,CAAC;QAC3C,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QACzB,GAAG,CAAC,IAAI,GAAG,iCAAmB,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzD,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACnC,OAAO,GAAG,CAAC;IACb,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,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;CACF;AAhFD,0BAgFC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Elements\r\n */\r\n\r\nimport { Id64String } from \"@itwin/core-bentley\";\r\nimport {\r\n Base64EncodedString, BisCodeSpec, Code, CodeScopeProps, CodeSpec, ImageSourceFormat, TextureProps,\r\n} from \"@itwin/core-common\";\r\nimport { DefinitionElement } from \"./Element\";\r\nimport { EditTxn } from \"./EditTxn\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { _implicitTxn } from \"./internal/Symbols\";\r\n\r\n/** A [TextureProps]($common) in which the image data can be specified either as a base-64-encoded string or a Uint8Array.\r\n * @see [[Texture]] constructor.\r\n * @beta\r\n */\r\nexport interface TextureCreateProps extends Omit<TextureProps, \"data\"> {\r\n data: Base64EncodedString | Uint8Array;\r\n}\r\n\r\n/** Defines a rendering texture that is associated with a Material and applied to surface geometry.\r\n * @public @preview\r\n */\r\nexport class Texture extends DefinitionElement {\r\n /** @internal */\r\n public static override get className(): string { return \"Texture\"; }\r\n public format: ImageSourceFormat;\r\n public data: Uint8Array;\r\n public description?: string;\r\n\r\n /** @beta */\r\n protected constructor(props: TextureCreateProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.format = props.format;\r\n this.data = typeof props.data === \"string\" ? Base64EncodedString.toUint8Array(props.data) : props.data;\r\n this.description = props.description;\r\n }\r\n\r\n public override toJSON(): TextureProps {\r\n const val = super.toJSON() as TextureProps;\r\n val.format = this.format;\r\n val.data = Base64EncodedString.fromUint8Array(this.data);\r\n val.description = this.description;\r\n return val;\r\n }\r\n\r\n /** Create a Code for a Texture given a name that is meant to be unique within the scope of the specified DefinitionModel.\r\n * @param iModel The IModelDb\r\n * @param scopeModelId The Id of the DefinitionModel that contains the Texture and provides the scope for its name.\r\n * @param name The Texture name\r\n */\r\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, name: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.texture);\r\n return 0 === name.length ? Code.createEmpty() : new Code({ spec: codeSpec.id, scope: scopeModelId, value: name });\r\n }\r\n\r\n /** Create a texture with the given parameters.\r\n * @param iModelDb The iModel to contain the texture.\r\n * @param definitionModelId The [[DefinitionModel]] to contain the texture.\r\n * @param name The name to serve as the texture's [Code]($common) value.\r\n * @param format The format of the image data.\r\n * @param data The image data in the format specified by `format`.\r\n * @param description An optional description of the texture\r\n * @returns The newly constructed Texture element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n * @see [[insertTexture]] to insert a new texture into the iModel.\r\n */\r\n public static createTexture(iModelDb: IModelDb, definitionModelId: Id64String, name: string, format: ImageSourceFormat, data: Uint8Array | Base64EncodedString, description?: string): Texture {\r\n const textureProps: TextureCreateProps = {\r\n classFullName: this.classFullName,\r\n code: this.createCode(iModelDb, definitionModelId, name),\r\n format,\r\n data,\r\n description,\r\n model: definitionModelId,\r\n isPrivate: false,\r\n };\r\n\r\n return new Texture(textureProps, iModelDb);\r\n }\r\n\r\n /** Insert a new texture into a [[DefinitionModel]].\r\n * @param iModelDb The iModel to contain the texture.\r\n * @param definitionModelId The [[DefinitionModel]] to contain the texture.\r\n * @param name The name to serve as the texture's [Code]($common) value.\r\n * @param format The format of the image data.\r\n * @param data The image data in the format specified by `format`.\r\n * @param description An optional description of the texture\r\n * @returns The Id of the newly-inserted texture element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n * @see [[insertTexture]] to insert a new texture into the iModel.\r\n * @beta\r\n */\r\n public static insertTexture(txn: EditTxn, definitionModelId: Id64String, name: string, format: ImageSourceFormat, data: Uint8Array | Base64EncodedString, description?: string): Id64String;\r\n /** Insert a new texture into a [[DefinitionModel]].\r\n * @deprecated in 5.9.0 -
|
|
1
|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AI,CAAC,MAAM,CAAC,CAAC,CAAC,kBAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,kBAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACpH,CAAC;IAED;;;;;;;;;;OAUG;IACI,MAAM,CAAC,aAAa,CAAC,QAAkB,EAAE,iBAA6B,EAAE,IAAY,EAAE,MAAyB,EAAE,IAAsC,EAAE,WAAoB;QAClL,MAAM,YAAY,GAAuB;YACvC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,CAAC;YACxD,MAAM;YACN,IAAI;YACJ,WAAW;YACX,KAAK,EAAE,iBAAiB;YACxB,SAAS,EAAE,KAAK;SACjB,CAAC;QAEF,OAAO,IAAI,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAmBM,MAAM,CAAC,aAAa,CAAC,OAA2B,EAAE,iBAA6B,EAAE,IAAY,EAAE,MAAyB,EAAE,IAAsC,EAAE,WAAoB;QAC3L,MAAM,GAAG,GAAG,OAAO,YAAY,iBAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,sBAAY,CAAC,CAAC;QACzE,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;QACnG,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;CACF;AAhFD,0BAgFC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Elements\r\n */\r\n\r\nimport { Id64String } from \"@itwin/core-bentley\";\r\nimport {\r\n Base64EncodedString, BisCodeSpec, Code, CodeScopeProps, CodeSpec, ImageSourceFormat, TextureProps,\r\n} from \"@itwin/core-common\";\r\nimport { DefinitionElement } from \"./Element\";\r\nimport { EditTxn } from \"./EditTxn\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { _implicitTxn } from \"./internal/Symbols\";\r\n\r\n/** A [TextureProps]($common) in which the image data can be specified either as a base-64-encoded string or a Uint8Array.\r\n * @see [[Texture]] constructor.\r\n * @beta\r\n */\r\nexport interface TextureCreateProps extends Omit<TextureProps, \"data\"> {\r\n data: Base64EncodedString | Uint8Array;\r\n}\r\n\r\n/** Defines a rendering texture that is associated with a Material and applied to surface geometry.\r\n * @public @preview\r\n */\r\nexport class Texture extends DefinitionElement {\r\n /** @internal */\r\n public static override get className(): string { return \"Texture\"; }\r\n public format: ImageSourceFormat;\r\n public data: Uint8Array;\r\n public description?: string;\r\n\r\n /** @beta */\r\n protected constructor(props: TextureCreateProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.format = props.format;\r\n this.data = typeof props.data === \"string\" ? Base64EncodedString.toUint8Array(props.data) : props.data;\r\n this.description = props.description;\r\n }\r\n\r\n public override toJSON(): TextureProps {\r\n const val = super.toJSON() as TextureProps;\r\n val.format = this.format;\r\n val.data = Base64EncodedString.fromUint8Array(this.data);\r\n val.description = this.description;\r\n return val;\r\n }\r\n\r\n /** Create a Code for a Texture given a name that is meant to be unique within the scope of the specified DefinitionModel.\r\n * @param iModel The IModelDb\r\n * @param scopeModelId The Id of the DefinitionModel that contains the Texture and provides the scope for its name.\r\n * @param name The Texture name\r\n */\r\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, name: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.texture);\r\n return 0 === name.length ? Code.createEmpty() : new Code({ spec: codeSpec.id, scope: scopeModelId, value: name });\r\n }\r\n\r\n /** Create a texture with the given parameters.\r\n * @param iModelDb The iModel to contain the texture.\r\n * @param definitionModelId The [[DefinitionModel]] to contain the texture.\r\n * @param name The name to serve as the texture's [Code]($common) value.\r\n * @param format The format of the image data.\r\n * @param data The image data in the format specified by `format`.\r\n * @param description An optional description of the texture\r\n * @returns The newly constructed Texture element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n * @see [[insertTexture]] to insert a new texture into the iModel.\r\n */\r\n public static createTexture(iModelDb: IModelDb, definitionModelId: Id64String, name: string, format: ImageSourceFormat, data: Uint8Array | Base64EncodedString, description?: string): Texture {\r\n const textureProps: TextureCreateProps = {\r\n classFullName: this.classFullName,\r\n code: this.createCode(iModelDb, definitionModelId, name),\r\n format,\r\n data,\r\n description,\r\n model: definitionModelId,\r\n isPrivate: false,\r\n };\r\n\r\n return new Texture(textureProps, iModelDb);\r\n }\r\n\r\n /** Insert a new texture into a [[DefinitionModel]].\r\n * @param iModelDb The iModel to contain the texture.\r\n * @param definitionModelId The [[DefinitionModel]] to contain the texture.\r\n * @param name The name to serve as the texture's [Code]($common) value.\r\n * @param format The format of the image data.\r\n * @param data The image data in the format specified by `format`.\r\n * @param description An optional description of the texture\r\n * @returns The Id of the newly-inserted texture element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n * @see [[insertTexture]] to insert a new texture into the iModel.\r\n * @beta\r\n */\r\n public static insertTexture(txn: EditTxn, definitionModelId: Id64String, name: string, format: ImageSourceFormat, data: Uint8Array | Base64EncodedString, description?: string): Id64String;\r\n /** Insert a new texture into a [[DefinitionModel]].\r\n * @deprecated in 5.9.0 - might be removed in next major version. Use Texture.insertTexture(txn, ...) instead.\r\n */\r\n public static insertTexture(iModelDb: IModelDb, definitionModelId: Id64String, name: string, format: ImageSourceFormat, data: Uint8Array | Base64EncodedString, description?: string): Id64String;\r\n public static insertTexture(txnOrDb: EditTxn | IModelDb, definitionModelId: Id64String, name: string, format: ImageSourceFormat, data: Uint8Array | Base64EncodedString, description?: string): Id64String {\r\n const txn = txnOrDb instanceof EditTxn ? txnOrDb : txnOrDb[_implicitTxn];\r\n const texture = this.createTexture(txn.iModel, definitionModelId, name, format, data, description);\r\n return texture.insert(txn);\r\n }\r\n}\r\n"]}
|
package/lib/cjs/TxnManager.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module iModels
|
|
3
3
|
*/
|
|
4
4
|
import { BeEvent, DbConflictResolution, DbResult, Id64String, IModelStatus } from "@itwin/core-bentley";
|
|
5
|
-
import { ChangesetIdWithIndex, ChangesetIndexAndId, ChangesetProps, EntityIdAndClassIdIterable, ModelGeometryChangesProps, ModelIdAndGeometryGuid, ReinstateTxnArgs, ReverseTxnArgs, TxnProps } from "@itwin/core-common";
|
|
5
|
+
import { ChangesetIdWithIndex, ChangesetIndexAndId, ChangesetProps, EntityIdAndClassId, EntityIdAndClassIdIterable, ModelGeometryChangesProps, ModelIdAndGeometryGuid, ReinstateTxnArgs, ReverseTxnArgs, TxnEntityMetadata, TxnProps } from "@itwin/core-common";
|
|
6
6
|
import { BriefcaseDb } from "./IModelDb";
|
|
7
7
|
import { RelationshipProps } from "./Relationship";
|
|
8
8
|
import { DbRebaseChangesetConflictArgs, RebaseChangesetConflictArgs } from "./internal/ChangesetConflictArgs";
|
|
@@ -22,7 +22,19 @@ export interface ValidationError {
|
|
|
22
22
|
/** Optional description of what went wrong. */
|
|
23
23
|
message?: string;
|
|
24
24
|
}
|
|
25
|
-
/** Describes
|
|
25
|
+
/** Describes an entity changed by a transaction, including its ECClass metadata.
|
|
26
|
+
* @public @preview
|
|
27
|
+
*/
|
|
28
|
+
export interface TxnChangedEntity extends EntityIdAndClassId {
|
|
29
|
+
/** Metadata describing the entity's ECClass. */
|
|
30
|
+
readonly metadata: TxnEntityMetadata;
|
|
31
|
+
}
|
|
32
|
+
/** An iterable collection of [[TxnChangedEntity]]s.
|
|
33
|
+
* For efficiency, the iterator returns the same [[TxnChangedEntity]] object on each iteration. Copy the entity if you intend to retain a reference to it.
|
|
34
|
+
* @public @preview
|
|
35
|
+
*/
|
|
36
|
+
export type TxnChangedEntityIterable = Iterable<Readonly<TxnChangedEntity>>;
|
|
37
|
+
/** Describes the entities that changed as part of a transaction by their Ids and ECClass Ids.
|
|
26
38
|
* @see [[TxnManager.onElementsChanged]] and [[TxnManager.onModelsChanged]].
|
|
27
39
|
* @public @preview
|
|
28
40
|
*/
|
|
@@ -34,6 +46,18 @@ export interface TxnChangedEntities {
|
|
|
34
46
|
/** The entities that were modified by the transaction, including any [[Element]]s for which one of their [[ElementAspect]]s was changed. */
|
|
35
47
|
readonly updates: EntityIdAndClassIdIterable;
|
|
36
48
|
}
|
|
49
|
+
/** Describes a set of [[Element]]s or [[Model]]s that changed as part of a transaction, including ECClass metadata for each changed entity.
|
|
50
|
+
* @see [[TxnManager.onElementsChanged]] and [[TxnManager.onModelsChanged]].
|
|
51
|
+
* @public @preview
|
|
52
|
+
*/
|
|
53
|
+
export interface TxnChangedEntitiesWithMetadata extends TxnChangedEntities {
|
|
54
|
+
/** The entities that were inserted by the transaction. */
|
|
55
|
+
readonly inserts: TxnChangedEntityIterable;
|
|
56
|
+
/** The entities that were deleted by the transaction. */
|
|
57
|
+
readonly deletes: TxnChangedEntityIterable;
|
|
58
|
+
/** The entities that were modified by the transaction, including any [[Element]]s for which one of their [[ElementAspect]]s was changed. */
|
|
59
|
+
readonly updates: TxnChangedEntityIterable;
|
|
60
|
+
}
|
|
37
61
|
/** Arguments supplied to [[TxnManager.queryLocalChanges]].
|
|
38
62
|
* @beta
|
|
39
63
|
*/
|
|
@@ -409,14 +433,30 @@ export declare class TxnManager {
|
|
|
409
433
|
readonly onEndValidation: BeEvent<() => void>;
|
|
410
434
|
/** Called after validation completes from [[IModelDb.saveChanges]].
|
|
411
435
|
* The argument to the event holds the list of elements that were inserted, updated, and deleted.
|
|
436
|
+
* Each changed entity includes its `id`, `classId`, and [[TxnChangedEntity.metadata]]. Use `metadata.classFullName` for an exact class match or `metadata.is` to match a class or one of its subclasses.
|
|
437
|
+
* @example
|
|
438
|
+
* ```ts
|
|
439
|
+
* iModel.txns.onElementsChanged.addListener((changes) => {
|
|
440
|
+
* for (const change of changes.inserts) {
|
|
441
|
+
* if (change.metadata.classFullName === "MySchema:MyElement")
|
|
442
|
+
* invalidateCache();
|
|
443
|
+
* }
|
|
444
|
+
*
|
|
445
|
+
* for (const change of changes.updates) {
|
|
446
|
+
* if (change.metadata.is("BisCore:GeometricElement"))
|
|
447
|
+
* invalidateGeometryCache(change.id);
|
|
448
|
+
* }
|
|
449
|
+
* });
|
|
450
|
+
* ```
|
|
412
451
|
* @note If there are many changed elements in a single Txn, the notifications are sent in batches so this event *may be called multiple times* per Txn.
|
|
413
452
|
*/
|
|
414
|
-
readonly onElementsChanged: BeEvent<(changes:
|
|
453
|
+
readonly onElementsChanged: BeEvent<(changes: TxnChangedEntitiesWithMetadata) => void>;
|
|
415
454
|
/** Called after validation completes from [[IModelDb.saveChanges]].
|
|
416
455
|
* The argument to the event holds the list of models that were inserted, updated, and deleted.
|
|
456
|
+
* Each changed model includes its `id`, `classId`, and [[TxnChangedEntity.metadata]]. Use `metadata.classFullName` for an exact class match or `metadata.is` to match a class or one of its subclasses.
|
|
417
457
|
* @note If there are many changed models in a single Txn, the notifications are sent in batches so this event *may be called multiple times* per Txn.
|
|
418
458
|
*/
|
|
419
|
-
readonly onModelsChanged: BeEvent<(changes:
|
|
459
|
+
readonly onModelsChanged: BeEvent<(changes: TxnChangedEntitiesWithMetadata) => void>;
|
|
420
460
|
/** Event raised after the geometry within one or more [[GeometricModel]]s is modified by applying a changeset or validation of a transaction.
|
|
421
461
|
* A model's geometry can change as a result of:
|
|
422
462
|
* - Insertion or deletion of a geometric element within the model; or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TxnManager.d.ts","sourceRoot":"","sources":["../../src/TxnManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,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,mBAAmB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAetD;;;;OAIG;IACU,wBAAwB,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAcpF;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,eAAe,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC;IACxC;;;;;OAKG;IACH,SAAS,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC;;;;;OAKG;IACH,OAAO,CAAC,IAAI,IAAI,CAAC;CAClB"}
|
package/lib/cjs/TxnManager.js
CHANGED
|
@@ -77,6 +77,16 @@ function setMaxEntitiesPerEvent(max) {
|
|
|
77
77
|
ChangedEntitiesProc.maxPerEvent = max;
|
|
78
78
|
return prevMax;
|
|
79
79
|
}
|
|
80
|
+
class TxnEntityMetadataImpl {
|
|
81
|
+
classFullName;
|
|
82
|
+
baseClasses = [];
|
|
83
|
+
constructor(classFullName) {
|
|
84
|
+
this.classFullName = classFullName;
|
|
85
|
+
}
|
|
86
|
+
is(baseClassFullName) {
|
|
87
|
+
return this.classFullName === baseClassFullName || this.baseClasses.some((baseClass) => baseClass.is(baseClassFullName));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
80
90
|
/** Maintains an ordered array of entity Ids and a parallel array containing the index of the corresponding entity's class Id. */
|
|
81
91
|
class ChangedEntitiesArray {
|
|
82
92
|
entityIds = new core_bentley_1.OrderedId64Array();
|
|
@@ -109,12 +119,17 @@ class ChangedEntitiesArray {
|
|
|
109
119
|
entities[type] = core_bentley_1.CompressedId64Set.compressIds(this.entityIds);
|
|
110
120
|
entities[`${type}Meta`] = this._classIndices;
|
|
111
121
|
}
|
|
112
|
-
iterable(classIds) {
|
|
122
|
+
iterable(classIds, metadata) {
|
|
113
123
|
function* iterator(entityIds, classIndices) {
|
|
114
|
-
|
|
124
|
+
let entity;
|
|
115
125
|
for (let i = 0; i < entityIds.length; i++) {
|
|
126
|
+
const classIndex = classIndices[i];
|
|
127
|
+
const entityMetadata = metadata[classIndex];
|
|
128
|
+
(0, core_bentley_1.assert)(undefined !== entityMetadata);
|
|
129
|
+
entity ??= { id: "", classId: "", metadata: entityMetadata };
|
|
116
130
|
entity.id = entityIds[i];
|
|
117
|
-
entity.classId = classIds[
|
|
131
|
+
entity.classId = classIds[classIndex];
|
|
132
|
+
entity.metadata = entityMetadata;
|
|
118
133
|
yield entity;
|
|
119
134
|
}
|
|
120
135
|
}
|
|
@@ -160,10 +175,10 @@ class ChangedEntitiesProc {
|
|
|
160
175
|
const meta = db.classMetaDataRegistry.findByClassId(classId);
|
|
161
176
|
nameToIndex.set(meta?.ecclass ?? "", nameToIndex.size);
|
|
162
177
|
}
|
|
163
|
-
const
|
|
178
|
+
const metadata = [];
|
|
164
179
|
function addMetadata(name, index) {
|
|
165
180
|
const bases = [];
|
|
166
|
-
|
|
181
|
+
metadata[index] = { name, bases };
|
|
167
182
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
168
183
|
const meta = db.tryGetMetaData(name);
|
|
169
184
|
if (!meta) {
|
|
@@ -186,25 +201,43 @@ class ChangedEntitiesProc {
|
|
|
186
201
|
}
|
|
187
202
|
addMetadata(name, index);
|
|
188
203
|
}
|
|
189
|
-
return
|
|
204
|
+
return metadata;
|
|
205
|
+
}
|
|
206
|
+
populateBackendMetadata(frontendMetadata) {
|
|
207
|
+
const backendMetadata = frontendMetadata.map(({ name }) => new TxnEntityMetadataImpl(name));
|
|
208
|
+
for (let index = 0; index < frontendMetadata.length; index++) {
|
|
209
|
+
const frontend = frontendMetadata[index];
|
|
210
|
+
const backend = backendMetadata[index];
|
|
211
|
+
(0, core_bentley_1.assert)(undefined !== frontend && undefined !== backend);
|
|
212
|
+
for (const baseClassIndex of frontend.bases) {
|
|
213
|
+
const baseClass = backendMetadata[baseClassIndex];
|
|
214
|
+
(0, core_bentley_1.assert)(undefined !== baseClass);
|
|
215
|
+
backend.baseClasses.push(baseClass);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return backendMetadata;
|
|
190
219
|
}
|
|
191
220
|
sendEvent(iModel, evt, evtName) {
|
|
192
221
|
if (this._currSize === 0)
|
|
193
222
|
return;
|
|
194
223
|
const classIds = this._classIds.toArray();
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
224
|
+
const frontendMetadata = this.populateMetadata(iModel, classIds);
|
|
225
|
+
// Notify backend listeners. Avoid constructing the backend metadata graph when there are no listeners.
|
|
226
|
+
if (evt.numberOfListeners > 0) {
|
|
227
|
+
const backendMetadata = this.populateBackendMetadata(frontendMetadata);
|
|
228
|
+
const txnEntities = {
|
|
229
|
+
inserts: this._inserted.iterable(classIds, backendMetadata),
|
|
230
|
+
deletes: this._deleted.iterable(classIds, backendMetadata),
|
|
231
|
+
updates: this._updated.iterable(classIds, backendMetadata),
|
|
232
|
+
};
|
|
233
|
+
evt.raiseEvent(txnEntities);
|
|
234
|
+
}
|
|
202
235
|
// Notify frontend listeners.
|
|
203
236
|
const entities = {
|
|
204
237
|
insertedMeta: [],
|
|
205
238
|
updatedMeta: [],
|
|
206
239
|
deletedMeta: [],
|
|
207
|
-
meta:
|
|
240
|
+
meta: frontendMetadata,
|
|
208
241
|
};
|
|
209
242
|
this._inserted.addToChangedEntities(entities, "inserted");
|
|
210
243
|
this._deleted.addToChangedEntities(entities, "deleted");
|
|
@@ -973,12 +1006,18 @@ class TxnManager {
|
|
|
973
1006
|
};
|
|
974
1007
|
};
|
|
975
1008
|
// Default conflict resolution for which custom handler is never called.
|
|
1009
|
+
// A local txn that imported a domain replays an insert to `dgn_Domain` for a domain the
|
|
1010
|
+
// just-merged changesets already registered. Both rows describe the same domain, so the
|
|
1011
|
+
// merged row wins and the local insert is dropped. Only a primary key collision on an insert
|
|
1012
|
+
// is benign - an update or delete whose "before" values do not match (`Data`) describes a real
|
|
1013
|
+
// divergence and is left to the handlers below.
|
|
1014
|
+
if (args.tableName === "dgn_Domain" && args.cause === "Conflict" && args.opcode === "Inserted") {
|
|
1015
|
+
core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.BackendLoggerCategory.IModelDb, "dgn_Domain insert conflict during rebase. Keeping the merged row and skipping the local change.", getChangeMetaData());
|
|
1016
|
+
return core_bentley_1.DbConflictResolution.Skip;
|
|
1017
|
+
}
|
|
1018
|
+
// Where schema sync is in use, native has already resolved ec_ rows by comparing sync db
|
|
1019
|
+
// versions before we get here.
|
|
976
1020
|
if (args.cause === "Data" && !args.indirect) {
|
|
977
|
-
if (args.tableName === "be_Prop") {
|
|
978
|
-
if (args.getValueText(0, "Old") === "ec_Db" && args.getValueText(1, "Old") === "localDbInfo") {
|
|
979
|
-
return core_bentley_1.DbConflictResolution.Skip;
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
1021
|
if (args.tableName.startsWith("ec_")) {
|
|
983
1022
|
return core_bentley_1.DbConflictResolution.Skip;
|
|
984
1023
|
}
|
|
@@ -987,6 +1026,12 @@ class TxnManager {
|
|
|
987
1026
|
if (args.tableName.startsWith("ec_")) {
|
|
988
1027
|
return core_bentley_1.DbConflictResolution.Skip;
|
|
989
1028
|
}
|
|
1029
|
+
// Skip PRIMARY KEY conflicts for inserted rows that were pre-reserved via SchemaSync - these are the same shared element.
|
|
1030
|
+
const isReserved = (id) => typeof id === "string" && core_bentley_1.Id64.getBriefcaseId(id) === core_common_1.BriefcaseIdValue.SchemaSyncElementReserved;
|
|
1031
|
+
const pkValues = args.getPrimaryKeyValues();
|
|
1032
|
+
if (args.opcode === "Inserted" && pkValues.length > 0 && pkValues.every(isReserved)) {
|
|
1033
|
+
return core_bentley_1.DbConflictResolution.Skip;
|
|
1034
|
+
}
|
|
990
1035
|
}
|
|
991
1036
|
try {
|
|
992
1037
|
const resolution = this.rebaser.onConflict(args);
|
|
@@ -1070,11 +1115,27 @@ class TxnManager {
|
|
|
1070
1115
|
onEndValidation = new core_bentley_1.BeEvent();
|
|
1071
1116
|
/** Called after validation completes from [[IModelDb.saveChanges]].
|
|
1072
1117
|
* The argument to the event holds the list of elements that were inserted, updated, and deleted.
|
|
1118
|
+
* Each changed entity includes its `id`, `classId`, and [[TxnChangedEntity.metadata]]. Use `metadata.classFullName` for an exact class match or `metadata.is` to match a class or one of its subclasses.
|
|
1119
|
+
* @example
|
|
1120
|
+
* ```ts
|
|
1121
|
+
* iModel.txns.onElementsChanged.addListener((changes) => {
|
|
1122
|
+
* for (const change of changes.inserts) {
|
|
1123
|
+
* if (change.metadata.classFullName === "MySchema:MyElement")
|
|
1124
|
+
* invalidateCache();
|
|
1125
|
+
* }
|
|
1126
|
+
*
|
|
1127
|
+
* for (const change of changes.updates) {
|
|
1128
|
+
* if (change.metadata.is("BisCore:GeometricElement"))
|
|
1129
|
+
* invalidateGeometryCache(change.id);
|
|
1130
|
+
* }
|
|
1131
|
+
* });
|
|
1132
|
+
* ```
|
|
1073
1133
|
* @note If there are many changed elements in a single Txn, the notifications are sent in batches so this event *may be called multiple times* per Txn.
|
|
1074
1134
|
*/
|
|
1075
1135
|
onElementsChanged = new core_bentley_1.BeEvent();
|
|
1076
1136
|
/** Called after validation completes from [[IModelDb.saveChanges]].
|
|
1077
1137
|
* The argument to the event holds the list of models that were inserted, updated, and deleted.
|
|
1138
|
+
* Each changed model includes its `id`, `classId`, and [[TxnChangedEntity.metadata]]. Use `metadata.classFullName` for an exact class match or `metadata.is` to match a class or one of its subclasses.
|
|
1078
1139
|
* @note If there are many changed models in a single Txn, the notifications are sent in batches so this event *may be called multiple times* per Txn.
|
|
1079
1140
|
*/
|
|
1080
1141
|
onModelsChanged = new core_bentley_1.BeEvent();
|