@itwin/core-backend 5.14.0-dev.3 → 5.14.0-dev.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +11 -5
- package/lib/cjs/BriefcaseManager.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/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +1 -0
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +42 -7
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +175 -74
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/SchemaSync.d.ts +126 -18
- package/lib/cjs/SchemaSync.d.ts.map +1 -1
- package/lib/cjs/SchemaSync.js +303 -81
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/SynchronousChannel.d.ts +11 -1
- package/lib/cjs/SynchronousChannel.d.ts.map +1 -1
- package/lib/cjs/SynchronousChannel.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +8 -5
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/internal/SchemaSyncReservations.d.ts.map +1 -1
- package/lib/cjs/internal/SchemaSyncReservations.js +13 -3
- package/lib/cjs/internal/SchemaSyncReservations.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/CloudSqlite.d.ts.map +1 -1
- package/lib/esm/CloudSqlite.js +10 -3
- package/lib/esm/CloudSqlite.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/IModelDb.d.ts +42 -7
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +175 -74
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/SchemaSync.d.ts +126 -18
- package/lib/esm/SchemaSync.d.ts.map +1 -1
- package/lib/esm/SchemaSync.js +304 -82
- package/lib/esm/SchemaSync.js.map +1 -1
- package/lib/esm/SynchronousChannel.d.ts +11 -1
- package/lib/esm/SynchronousChannel.d.ts.map +1 -1
- package/lib/esm/SynchronousChannel.js.map +1 -1
- package/lib/esm/TxnManager.d.ts.map +1 -1
- package/lib/esm/TxnManager.js +9 -6
- package/lib/esm/TxnManager.js.map +1 -1
- package/lib/esm/internal/SchemaSyncReservations.d.ts.map +1 -1
- package/lib/esm/internal/SchemaSyncReservations.js +13 -3
- package/lib/esm/internal/SchemaSyncReservations.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/standalone/SchemaSyncDb.test.js +5 -25
- package/lib/esm/test/standalone/SchemaSyncDb.test.js.map +1 -1
- package/lib/esm/test/standalone/SchemaSyncElementReservation.test.js +1 -0
- package/lib/esm/test/standalone/SchemaSyncElementReservation.test.js.map +1 -1
- package/package.json +14 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaSync.js","sourceRoot":"","sources":["../../src/SchemaSync.ts"],"names":[],"mappings":";AAAA;;;+F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,MAAM,CAAC,sBAAY,CAAC,CAAC,cAAc,EAAE,CAAC;QACxC,CAAC;QAED,IAAI,SAAS,EAAE,CAAC;YACd,IAAI,GAAG,CAAC,iBAAiB;gBACvB,MAAM,SAAS,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,uDAAuD,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;;gBAEzH,MAAM,SAAS,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,mDAAmD,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QACzH,CAAC;QAED,MAAM,MAAM,CAAC,mCAAmC,EAAE,CAAC;IACrD,CAAC,CAAC;IAEF,0EAA0E;IAC1E,MAAa,WAAY,SAAQ,yBAAW,CAAC,QAAiD;QAC5F,YAAmB,KAAuC;YACxD,KAAK,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;QAChE,CAAC;QAEM,MAAM;YACX,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,mBAAS,CAAC,CAAC,WAAW,EAAE,QAAQ,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,aAAa,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1I,CAAC;QACD;;;;SAIC;QACM,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,KAAiC;YAChE,OAAO,KAAK,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;QACrF,CAAC;KACF;IAhBY,sBAAW,cAgBvB,CAAA;AACH,CAAC,EA7SgB,UAAU,0BAAV,UAAU,QA6S1B","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 { DbResult, Guid, GuidString, Id64, Id64String, 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 { 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 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 of the requested reservations conflict with existing reservations. */\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 = \"4.1.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 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 sharedAccessByIModel = new Map<string, CloudAccess>();\r\n export 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 testSyncCache = nativeDb.queryLocalValue(testSyncCachePropKey);\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\r\n try {\r\n // Reuse the existing access for this container so there is only ever one CloudAccess per container (per cache).\r\n const sharedAccessKey = propsString + (testSyncCache ?? \"\");\r\n const cached = sharedAccessByIModel.get(sharedAccessKey);\r\n if (cached)\r\n return cached;\r\n\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 if (testSyncCache)\r\n access.setCache(CloudSqlite.CloudCaches.getCache({ cacheName: testSyncCache }));\r\n sharedAccessByIModel.set(sharedAccessKey, access);\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 await iModel.initializeSharedElementReservations();\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}\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,EAAE;QACZ,SAAS,EAAE,KAAK,EAAE,QAAgB,EAAE,OAAe,EAAE,EAAE;YACrD,qBAAM,CAAC,OAAO,CAAC,YAAY,EAAE,oCAAoC,QAAQ,UAAU,OAAO,aAAa,CAAC,CAAC;YACzG,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;IACF,MAAM,yBAAyB,GAAG,mBAAmB,CAAC;IACtD,MAAM,mBAAmB,GAAG,aAAa,CAAC,CAAC,OAAO;IAClD,MAAM,cAAc,GAAsB,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,4BAA4B,EAAE,CAAC;IAyB1G,kFAAkF;IAClF,MAAa,YAAa,SAAQ,4BAAiB;QACzC,qBAAqB,CAAW;QACf,SAAS,GAA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b,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"]}
|
|
@@ -14,7 +14,9 @@ export declare namespace SynchronousChannel {
|
|
|
14
14
|
* @beta
|
|
15
15
|
*/
|
|
16
16
|
interface ReserveElementsArgs {
|
|
17
|
-
/** The elements to reserve. The whole batch succeeds or fails together.
|
|
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
|
+
*/
|
|
18
20
|
elements: Iterable<{
|
|
19
21
|
/** The federationGuid that stably identifies this element across briefcases. Reservations always require an explicit federationGuid. */
|
|
20
22
|
federationGuid: GuidString;
|
|
@@ -27,6 +29,12 @@ export declare namespace SynchronousChannel {
|
|
|
27
29
|
* Interface used to ***reserve*** elements with shared identities as part of [coordinating simultaneous edits]($docs/learning/backend/ConcurrencyControl.md) from multiple briefcases.
|
|
28
30
|
* Unlike **locks** (via [[LockControl]]), which block users from making conflicting changes to existing elements, **reservations** can be used to communicate "in-flight"
|
|
29
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.
|
|
30
38
|
* @see [[IModelDb.reservations]] to access the reservations for an iModel.
|
|
31
39
|
* @beta
|
|
32
40
|
*/
|
|
@@ -54,6 +62,8 @@ export declare namespace SynchronousChannel {
|
|
|
54
62
|
needsElementReservation(federationGuid: GuidString): boolean;
|
|
55
63
|
/**
|
|
56
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.
|
|
57
67
|
* @throws Error if the requested elements are inconsistent with existing reservations, or if any other error occurs while updating the reservations.
|
|
58
68
|
*/
|
|
59
69
|
reserveElements(args: ReserveElementsArgs): Promise<void>;
|
|
@@ -1 +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
|
|
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"}
|
|
@@ -1 +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 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 * @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 * @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"]}
|
|
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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TxnManager.d.ts","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AAI,MAAM;IAI5C;;;;OAIG;IACI,OAAO,IAAI,OAAO;IAIzB;;;;OAIG;IACI,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
|
@@ -1015,12 +1015,9 @@ class TxnManager {
|
|
|
1015
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
1016
|
return core_bentley_1.DbConflictResolution.Skip;
|
|
1017
1017
|
}
|
|
1018
|
+
// Where schema sync is in use, native has already resolved ec_ rows by comparing sync db
|
|
1019
|
+
// versions before we get here.
|
|
1018
1020
|
if (args.cause === "Data" && !args.indirect) {
|
|
1019
|
-
if (args.tableName === "be_Prop") {
|
|
1020
|
-
if (args.getValueText(0, "Old") === "ec_Db" && args.getValueText(1, "Old") === "localDbInfo") {
|
|
1021
|
-
return core_bentley_1.DbConflictResolution.Skip;
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
1021
|
if (args.tableName.startsWith("ec_")) {
|
|
1025
1022
|
return core_bentley_1.DbConflictResolution.Skip;
|
|
1026
1023
|
}
|
|
@@ -1029,6 +1026,12 @@ class TxnManager {
|
|
|
1029
1026
|
if (args.tableName.startsWith("ec_")) {
|
|
1030
1027
|
return core_bentley_1.DbConflictResolution.Skip;
|
|
1031
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
|
+
}
|
|
1032
1035
|
}
|
|
1033
1036
|
try {
|
|
1034
1037
|
const resolution = this.rebaser.onConflict(args);
|