@itwin/core-backend 4.8.0-dev.27 → 4.8.0-dev.29
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/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +9 -3
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/LockControl.d.ts +7 -0
- package/lib/cjs/LockControl.d.ts.map +1 -1
- package/lib/cjs/LockControl.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/NoLocks.d.ts.map +1 -1
- package/lib/cjs/internal/NoLocks.js +1 -0
- package/lib/cjs/internal/NoLocks.js.map +1 -1
- package/lib/cjs/internal/ServerBasedLocks.d.ts +1 -0
- package/lib/cjs/internal/ServerBasedLocks.d.ts.map +1 -1
- package/lib/cjs/internal/ServerBasedLocks.js +6 -0
- package/lib/cjs/internal/ServerBasedLocks.js.map +1 -1
- package/package.json +13 -13
package/lib/cjs/LockControl.d.ts
CHANGED
|
@@ -56,6 +56,13 @@ export interface LockControl {
|
|
|
56
56
|
/** if present, one or more elements to obtain exclusive lock */
|
|
57
57
|
exclusive?: Id64Arg;
|
|
58
58
|
}): Promise<void>;
|
|
59
|
+
/** Release all locks currently held by this briefcase from the locker server.
|
|
60
|
+
* This is typically done on your behalf by [[BriefcaseDb.pushChanges]].
|
|
61
|
+
* You may want to do it manually when abandoning all of your briefcase's local changes.
|
|
62
|
+
* You cannot release your locks if your briefcase contains local changes.
|
|
63
|
+
* @throws Error if the briefcase has local changes, or if any other error occurs while releasing the locks.
|
|
64
|
+
*/
|
|
65
|
+
releaseAllLocks(): Promise<void>;
|
|
59
66
|
/**
|
|
60
67
|
* Release all locks currently held by this Briefcase from the lock server.
|
|
61
68
|
* Not possible to release locks unless push or abandon all changes. Should only be called internally.
|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CAAC,gBAAgB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LockControl.js","sourceRoot":"","sources":["../../src/LockControl.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAGH,gDAA6G","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module iModels\n */\n\nimport { Id64Arg, Id64String } from \"@itwin/core-bentley\";\nimport { _close, _elementWasCreated, _implementationProhibited, _releaseAllLocks } from \"./internal/Symbols\";\n\n/**\n * Interface for acquiring element locks to [coordinate simultaneous edits]($docs/learning/backend/ConcurrencyControl.md) from multiple briefcases.\n * @see [[IModelDb.locks]] to access the locks for an iModel.\n * @public\n */\nexport interface LockControl {\n /** @internal*/\n readonly [_implementationProhibited]: unknown;\n\n /**\n * true if this LockControl uses a server-based concurrency approach.\n */\n readonly isServerBased: boolean;\n\n /**\n * Close the local lock control database\n * @internal\n */\n [_close]: () => void;\n\n /**\n * Notification that a new element was just created. Called by [[Element.onInserted]]\n * @internal\n */\n [_elementWasCreated]: (id: Id64String) => void;\n\n /**\n * Throw if locks are required and the exclusive lock is not held on the supplied element.\n * Note: there is no need to check the shared locks on parents/models since an element cannot hold the exclusive lock without first obtaining them.\n * Called by functions like [[Element.onUpdate]], [[Element.onDelete]], etc.\n */\n checkExclusiveLock(id: Id64String, type: string, operation: string): void;\n\n /**\n * Throw if locks are required and a shared lock is not held on the supplied element.\n * Called by [[Element.onInsert]] to ensure shared lock is held on the new element's model and parent element.\n */\n checkSharedLock(id: Id64String, type: string, operation: string): void;\n\n /**\n * Determine whether the owning iModel currently holds the exclusive lock on the specified element.\n */\n holdsExclusiveLock(id: Id64String): boolean;\n\n /**\n * Determine whether the owning iModel currently holds a shared lock on the specified element.\n */\n holdsSharedLock(id: Id64String): boolean;\n\n /**\n * Acquire locks on one or more elements from the lock server, if required and not already held.\n * If any required lock is not available, this method throws an exception and *none* of the requested locks are acquired.\n * @note Acquiring the exclusive lock on an element requires also obtaining a shared lock on all its owner elements. This method will\n * attempt to acquire all necessary locks for both sets of input ids.\n */\n acquireLocks(arg: {\n /** if present, one or more elements to obtain shared lock */\n shared?: Id64Arg;\n /** if present, one or more elements to obtain exclusive lock */\n exclusive?: Id64Arg;\n }): Promise<void>;\n\n /**\n * Release all locks currently held by this Briefcase from the lock server.\n * Not possible to release locks unless push or abandon all changes. Should only be called internally.\n * @internal\n */\n [_releaseAllLocks]: () => Promise<void>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"LockControl.js","sourceRoot":"","sources":["../../src/LockControl.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAGH,gDAA6G","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module iModels\n */\n\nimport { Id64Arg, Id64String } from \"@itwin/core-bentley\";\nimport { _close, _elementWasCreated, _implementationProhibited, _releaseAllLocks } from \"./internal/Symbols\";\n\n/**\n * Interface for acquiring element locks to [coordinate simultaneous edits]($docs/learning/backend/ConcurrencyControl.md) from multiple briefcases.\n * @see [[IModelDb.locks]] to access the locks for an iModel.\n * @public\n */\nexport interface LockControl {\n /** @internal*/\n readonly [_implementationProhibited]: unknown;\n\n /**\n * true if this LockControl uses a server-based concurrency approach.\n */\n readonly isServerBased: boolean;\n\n /**\n * Close the local lock control database\n * @internal\n */\n [_close]: () => void;\n\n /**\n * Notification that a new element was just created. Called by [[Element.onInserted]]\n * @internal\n */\n [_elementWasCreated]: (id: Id64String) => void;\n\n /**\n * Throw if locks are required and the exclusive lock is not held on the supplied element.\n * Note: there is no need to check the shared locks on parents/models since an element cannot hold the exclusive lock without first obtaining them.\n * Called by functions like [[Element.onUpdate]], [[Element.onDelete]], etc.\n */\n checkExclusiveLock(id: Id64String, type: string, operation: string): void;\n\n /**\n * Throw if locks are required and a shared lock is not held on the supplied element.\n * Called by [[Element.onInsert]] to ensure shared lock is held on the new element's model and parent element.\n */\n checkSharedLock(id: Id64String, type: string, operation: string): void;\n\n /**\n * Determine whether the owning iModel currently holds the exclusive lock on the specified element.\n */\n holdsExclusiveLock(id: Id64String): boolean;\n\n /**\n * Determine whether the owning iModel currently holds a shared lock on the specified element.\n */\n holdsSharedLock(id: Id64String): boolean;\n\n /**\n * Acquire locks on one or more elements from the lock server, if required and not already held.\n * If any required lock is not available, this method throws an exception and *none* of the requested locks are acquired.\n * @note Acquiring the exclusive lock on an element requires also obtaining a shared lock on all its owner elements. This method will\n * attempt to acquire all necessary locks for both sets of input ids.\n */\n acquireLocks(arg: {\n /** if present, one or more elements to obtain shared lock */\n shared?: Id64Arg;\n /** if present, one or more elements to obtain exclusive lock */\n exclusive?: Id64Arg;\n }): Promise<void>;\n\n /** Release all locks currently held by this briefcase from the locker server.\n * This is typically done on your behalf by [[BriefcaseDb.pushChanges]].\n * You may want to do it manually when abandoning all of your briefcase's local changes.\n * You cannot release your locks if your briefcase contains local changes.\n * @throws Error if the briefcase has local changes, or if any other error occurs while releasing the locks.\n */\n releaseAllLocks(): Promise<void>;\n\n /**\n * Release all locks currently held by this Briefcase from the lock server.\n * Not possible to release locks unless push or abandon all changes. Should only be called internally.\n * @internal\n */\n [_releaseAllLocks]: () => Promise<void>;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-backend.d.ts","sourceRoot":"","sources":["../../src/core-backend.ts"],"names":[],"mappings":"AAKA,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AAC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yBAAyB,CAAC;AACxC,OAAO,EAAE,4BAA4B,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC3F,cAAc,0BAA0B,CAAC;AACzC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AAErC,cAAc,0BAA0B,CAAC;AAEzC;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;IAGI;AAEJ;;;GAGG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;GAEG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG"}
|
package/lib/cjs/core-backend.js
CHANGED
|
@@ -63,6 +63,7 @@ __exportStar(require("./IpcHost"), exports);
|
|
|
63
63
|
__exportStar(require("./LineStyle"), exports);
|
|
64
64
|
__exportStar(require("./LocalhostIpcHost"), exports);
|
|
65
65
|
__exportStar(require("./LocalHub"), exports);
|
|
66
|
+
__exportStar(require("./LockControl"), exports);
|
|
66
67
|
__exportStar(require("./Material"), exports);
|
|
67
68
|
__exportStar(require("./Model"), exports);
|
|
68
69
|
__exportStar(require("./NativeAppStorage"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-backend.js","sourceRoot":"","sources":["../../src/core-backend.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;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AAEH;;;IAGI;AAEJ;;;GAGG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;GAEG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nexport * from \"./BackendHubAccess\";\nexport * from \"./BackendLoggerCategory\";\nexport * from \"./BisCoreSchema\";\nexport * from \"./BlobContainerService\";\nexport * from \"./BriefcaseManager\";\nexport * from \"./Category\";\nexport * from \"./ChangedElementsDb\";\nexport * from \"./ChangeSummaryManager\";\nexport * from \"./ChannelControl\";\nexport * from \"./CheckpointManager\";\nexport * from \"./ClassRegistry\";\nexport * from \"./CloudSqlite\";\nexport * from \"./CodeService\";\nexport * from \"./CodeSpecs\";\nexport * from \"./DevTools\";\nexport * from \"./DisplayStyle\";\nexport * from \"./domains/FunctionalElements\";\nexport * from \"./domains/FunctionalSchema\";\nexport * from \"./domains/GenericElements\";\nexport * from \"./domains/GenericSchema\";\nexport * from \"./ECDb\";\nexport * from \"./ECSchemaXmlContext\";\nexport * from \"./ECSqlStatement\";\nexport * from \"./Element\";\nexport * from \"./ElementAspect\";\nexport * from \"./ElementGraphics\";\nexport * from \"./ElementTreeWalker\";\nexport * from \"./Entity\";\nexport * from \"./EntityReferences\";\nexport * from \"./ExportGraphics\";\nexport * from \"./ExternalSource\";\nexport * from \"./GeoCoordConfig\";\nexport * from \"./GeographicCRSServices\";\nexport * from \"./HubMock\";\nexport * from \"./IModelCloneContext\";\nexport * from \"./IModelDb\";\nexport * from \"./IModelElementCloneContext\";\nexport * from \"./IModelHost\";\nexport * from \"./IModelJsFs\";\nexport * from \"./SchemaSync\";\nexport * from \"./IpcHost\";\nexport * from \"./LineStyle\";\nexport * from \"./LocalhostIpcHost\";\nexport * from \"./LocalHub\";\nexport * from \"./Material\";\nexport * from \"./Model\";\nexport * from \"./NativeAppStorage\";\nexport * from \"./NativeHost\";\nexport * from \"./NavigationRelationship\";\nexport * from \"./PropertyStore\";\nexport * from \"./Relationship\";\nexport * from \"./rpc/tracing\";\nexport * from \"./Schema\";\nexport * from \"./SchemaUtils\";\nexport * from \"./SQLiteDb\";\nexport * from \"./SqliteStatement\";\nexport * from \"./TextAnnotationElement\";\nexport { computeLayoutTextBlockResult, LayoutTextBlockArgs } from \"./TextAnnotationLayout\";\nexport * from \"./TextAnnotationGeometry\";\nexport * from \"./Texture\";\nexport * from \"./TileStorage\";\nexport * from \"./TxnManager\";\nexport * from \"./ViewDefinition\";\nexport * from \"./ViewStore\";\nexport * from \"./workspace/Settings\";\nexport * from \"./workspace/SettingsSchemas\";\nexport * from \"./workspace/Workspace\";\nexport * from \"./workspace/WorkspaceEditor\";\nexport * from \"./SqliteChangesetReader\";\nexport * from \"./ChangesetECAdaptor\";\n\nexport * from \"./internal/cross-package\";\n\n/** @docs-package-description\n * The core-backend package always runs on the computer with a local Briefcase.\n *\n * It contains classes that [backend code]($docs/learning/backend/index.md) can use to work with directly with iModels.\n */\n\n/**\n * @docs-group-description BlobContainers\n * Classes for working with cloud-based blob containers.\n */\n\n/**\n * @docs-group-description Codes\n * Classes for working with [Codes]($docs/BIS/guide/fundamentals/codes.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description ECDb\n * Classes for working with ECDb.\n */\n\n/**\n * @docs-group-description ECSQL\n * Classes for working with [ECSQL]($docs/learning/ECSQL.md)\n */\n\n/**\n * @docs-group-description ElementAspects\n * Subclasses of [ElementAspects]($docs/bis/guide/fundamentals/elementaspect-fundamentals.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description ElementGeometry\n * Classes for defining the symbology and geometry of geometric elements\n */\n\n/**\n * @docs-group-description Elements\n * Subclasses of [Elements]($docs/BIS/guide/fundamentals/element-fundamentals.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description ExportGraphics\n * APIs for producing low-level graphics primitives from element geometry.\n */\n\n/**\n * @docs-group-description HubAccess\n * APIs for working with IModelHub\n */\n\n/**\n * @docs-group-description IModelHost\n * Classes for configuring and administering the backend [host]($docs/learning/backend/IModelHost.md).\n * See [the learning article]($docs/learning/backend/IModelHost.md).\n */\n\n/**\n * @docs-group-description iModels\n * Classes for working with [iModels]($docs/learning/iModels.md).\n * See [the learning article]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description Logging\n * Logger categories used by this package.\n */\n\n/**\n * @docs-group-description Models\n * Subclasses of [Models]($docs/BIS/guide/fundamentals/model-fundamentals.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description NativeApp\n * Classes for working with Mobile/Desktop Application.\n */\n\n/**\n * @docs-group-description Portability\n */\n\n/**\n * @docs-group-description Relationships\n * Classes that describe the [relationships]($docs/bis/guide/fundamentals/relationship-fundamentals.md) between elements.\n */\n\n/**\n * @docs-group-description RpcInterface\n * Classes for working with [RpcInterfaces]($docs/learning/RpcInterface.md).\n */\n\n/**\n * @docs-group-description Schema\n * Classes for working with [ECSchemas]($docs/learning/backend/SchemasAndElementsInTypeScript.md)\n */\n\n/**\n * @docs-group-description SQLite\n * Classes for working directly with SQLite\n */\n\n/**\n * @docs-group-description SQLiteDb\n * Classes for working with SQLiteDb.\n */\n\n/**\n * @docs-group-description TileStorage\n * Class for working with cloud storage using iTwin/object-storage cloud providers\n */\n\n/**\n * @docs-group-description ViewDefinitions\n * Classes for working with Elements that define what appears in [Views]($docs/learning/frontend/views.md).\n * See [the learning articles]($docs/learning/backend/createelements/#orthographicviewdefinition).\n */\n\n/**\n * @docs-group-description Workspace\n * APIs for loading and using Settings and Workspace resources\n */\n"]}
|
|
1
|
+
{"version":3,"file":"core-backend.js","sourceRoot":"","sources":["../../src/core-backend.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;;;;;AAE/F,qDAAmC;AACnC,0DAAwC;AACxC,kDAAgC;AAChC,yDAAuC;AACvC,qDAAmC;AACnC,6CAA2B;AAC3B,sDAAoC;AACpC,yDAAuC;AACvC,mDAAiC;AACjC,sDAAoC;AACpC,kDAAgC;AAChC,gDAA8B;AAC9B,gDAA8B;AAC9B,8CAA4B;AAC5B,6CAA2B;AAC3B,iDAA+B;AAC/B,+DAA6C;AAC7C,6DAA2C;AAC3C,4DAA0C;AAC1C,0DAAwC;AACxC,yCAAuB;AACvB,uDAAqC;AACrC,mDAAiC;AACjC,4CAA0B;AAC1B,kDAAgC;AAChC,oDAAkC;AAClC,sDAAoC;AACpC,2CAAyB;AACzB,qDAAmC;AACnC,mDAAiC;AACjC,mDAAiC;AACjC,mDAAiC;AACjC,0DAAwC;AACxC,4CAA0B;AAC1B,uDAAqC;AACrC,6CAA2B;AAC3B,8DAA4C;AAC5C,+CAA6B;AAC7B,+CAA6B;AAC7B,+CAA6B;AAC7B,4CAA0B;AAC1B,8CAA4B;AAC5B,qDAAmC;AACnC,6CAA2B;AAC3B,gDAA8B;AAC9B,6CAA2B;AAC3B,0CAAwB;AACxB,qDAAmC;AACnC,+CAA6B;AAC7B,2DAAyC;AACzC,kDAAgC;AAChC,iDAA+B;AAC/B,gDAA8B;AAC9B,2CAAyB;AACzB,gDAA8B;AAC9B,6CAA2B;AAC3B,oDAAkC;AAClC,0DAAwC;AACxC,+DAA2F;AAAlF,oIAAA,4BAA4B,OAAA;AACrC,2DAAyC;AACzC,4CAA0B;AAC1B,gDAA8B;AAC9B,+CAA6B;AAC7B,mDAAiC;AACjC,8CAA4B;AAC5B,uDAAqC;AACrC,8DAA4C;AAC5C,wDAAsC;AACtC,8DAA4C;AAC5C,0DAAwC;AACxC,uDAAqC;AAErC,2DAAyC;AAEzC;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;IAGI;AAEJ;;;GAGG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;GAEG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nexport * from \"./BackendHubAccess\";\nexport * from \"./BackendLoggerCategory\";\nexport * from \"./BisCoreSchema\";\nexport * from \"./BlobContainerService\";\nexport * from \"./BriefcaseManager\";\nexport * from \"./Category\";\nexport * from \"./ChangedElementsDb\";\nexport * from \"./ChangeSummaryManager\";\nexport * from \"./ChannelControl\";\nexport * from \"./CheckpointManager\";\nexport * from \"./ClassRegistry\";\nexport * from \"./CloudSqlite\";\nexport * from \"./CodeService\";\nexport * from \"./CodeSpecs\";\nexport * from \"./DevTools\";\nexport * from \"./DisplayStyle\";\nexport * from \"./domains/FunctionalElements\";\nexport * from \"./domains/FunctionalSchema\";\nexport * from \"./domains/GenericElements\";\nexport * from \"./domains/GenericSchema\";\nexport * from \"./ECDb\";\nexport * from \"./ECSchemaXmlContext\";\nexport * from \"./ECSqlStatement\";\nexport * from \"./Element\";\nexport * from \"./ElementAspect\";\nexport * from \"./ElementGraphics\";\nexport * from \"./ElementTreeWalker\";\nexport * from \"./Entity\";\nexport * from \"./EntityReferences\";\nexport * from \"./ExportGraphics\";\nexport * from \"./ExternalSource\";\nexport * from \"./GeoCoordConfig\";\nexport * from \"./GeographicCRSServices\";\nexport * from \"./HubMock\";\nexport * from \"./IModelCloneContext\";\nexport * from \"./IModelDb\";\nexport * from \"./IModelElementCloneContext\";\nexport * from \"./IModelHost\";\nexport * from \"./IModelJsFs\";\nexport * from \"./SchemaSync\";\nexport * from \"./IpcHost\";\nexport * from \"./LineStyle\";\nexport * from \"./LocalhostIpcHost\";\nexport * from \"./LocalHub\";\nexport * from \"./LockControl\";\nexport * from \"./Material\";\nexport * from \"./Model\";\nexport * from \"./NativeAppStorage\";\nexport * from \"./NativeHost\";\nexport * from \"./NavigationRelationship\";\nexport * from \"./PropertyStore\";\nexport * from \"./Relationship\";\nexport * from \"./rpc/tracing\";\nexport * from \"./Schema\";\nexport * from \"./SchemaUtils\";\nexport * from \"./SQLiteDb\";\nexport * from \"./SqliteStatement\";\nexport * from \"./TextAnnotationElement\";\nexport { computeLayoutTextBlockResult, LayoutTextBlockArgs } from \"./TextAnnotationLayout\";\nexport * from \"./TextAnnotationGeometry\";\nexport * from \"./Texture\";\nexport * from \"./TileStorage\";\nexport * from \"./TxnManager\";\nexport * from \"./ViewDefinition\";\nexport * from \"./ViewStore\";\nexport * from \"./workspace/Settings\";\nexport * from \"./workspace/SettingsSchemas\";\nexport * from \"./workspace/Workspace\";\nexport * from \"./workspace/WorkspaceEditor\";\nexport * from \"./SqliteChangesetReader\";\nexport * from \"./ChangesetECAdaptor\";\n\nexport * from \"./internal/cross-package\";\n\n/** @docs-package-description\n * The core-backend package always runs on the computer with a local Briefcase.\n *\n * It contains classes that [backend code]($docs/learning/backend/index.md) can use to work with directly with iModels.\n */\n\n/**\n * @docs-group-description BlobContainers\n * Classes for working with cloud-based blob containers.\n */\n\n/**\n * @docs-group-description Codes\n * Classes for working with [Codes]($docs/BIS/guide/fundamentals/codes.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description ECDb\n * Classes for working with ECDb.\n */\n\n/**\n * @docs-group-description ECSQL\n * Classes for working with [ECSQL]($docs/learning/ECSQL.md)\n */\n\n/**\n * @docs-group-description ElementAspects\n * Subclasses of [ElementAspects]($docs/bis/guide/fundamentals/elementaspect-fundamentals.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description ElementGeometry\n * Classes for defining the symbology and geometry of geometric elements\n */\n\n/**\n * @docs-group-description Elements\n * Subclasses of [Elements]($docs/BIS/guide/fundamentals/element-fundamentals.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description ExportGraphics\n * APIs for producing low-level graphics primitives from element geometry.\n */\n\n/**\n * @docs-group-description HubAccess\n * APIs for working with IModelHub\n */\n\n/**\n * @docs-group-description IModelHost\n * Classes for configuring and administering the backend [host]($docs/learning/backend/IModelHost.md).\n * See [the learning article]($docs/learning/backend/IModelHost.md).\n */\n\n/**\n * @docs-group-description iModels\n * Classes for working with [iModels]($docs/learning/iModels.md).\n * See [the learning article]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description Logging\n * Logger categories used by this package.\n */\n\n/**\n * @docs-group-description Models\n * Subclasses of [Models]($docs/BIS/guide/fundamentals/model-fundamentals.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description NativeApp\n * Classes for working with Mobile/Desktop Application.\n */\n\n/**\n * @docs-group-description Portability\n */\n\n/**\n * @docs-group-description Relationships\n * Classes that describe the [relationships]($docs/bis/guide/fundamentals/relationship-fundamentals.md) between elements.\n */\n\n/**\n * @docs-group-description RpcInterface\n * Classes for working with [RpcInterfaces]($docs/learning/RpcInterface.md).\n */\n\n/**\n * @docs-group-description Schema\n * Classes for working with [ECSchemas]($docs/learning/backend/SchemasAndElementsInTypeScript.md)\n */\n\n/**\n * @docs-group-description SQLite\n * Classes for working directly with SQLite\n */\n\n/**\n * @docs-group-description SQLiteDb\n * Classes for working with SQLiteDb.\n */\n\n/**\n * @docs-group-description TileStorage\n * Class for working with cloud storage using iTwin/object-storage cloud providers\n */\n\n/**\n * @docs-group-description ViewDefinitions\n * Classes for working with Elements that define what appears in [Views]($docs/learning/frontend/views.md).\n * See [the learning articles]($docs/learning/backend/createelements/#orthographicviewdefinition).\n */\n\n/**\n * @docs-group-description Workspace\n * APIs for loading and using Settings and Workspace resources\n */\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoLocks.d.ts","sourceRoot":"","sources":["../../../src/internal/NoLocks.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"NoLocks.d.ts","sourceRoot":"","sources":["../../../src/internal/NoLocks.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAmB7C,wBAAgB,qBAAqB,IAAI,WAAW,CAEnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoLocks.js","sourceRoot":"","sources":["../../../src/internal/NoLocks.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;AAO/F,uCAAoG;AAEpG,yJAAyJ;AACzJ,MAAM,OAAO;IAAb;QACkB,QAA2B,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"NoLocks.js","sourceRoot":"","sources":["../../../src/internal/NoLocks.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;AAO/F,uCAAoG;AAEpG,yJAAyJ;AACzJ,MAAM,OAAO;IAAb;QACkB,QAA2B,GAAG,SAAS,CAAC;IAY1D,CAAC;IAXC,IAAW,aAAa,KAAK,OAAO,KAAK,CAAC,CAAC,CAAC;IACrC,OAFU,mCAAyB,EAElC,gBAAM,EAAC,KAAW,CAAC;IACpB,aAAa,KAAW,CAAC;IACzB,kBAAkB,KAAc,OAAO,KAAK,CAAC,CAAC,CAAC;IAC/C,eAAe,KAAc,OAAO,KAAK,CAAC,CAAC,CAAC;IAC5C,kBAAkB,KAAW,CAAC;IAC9B,eAAe,KAAW,CAAC;IAC3B,CAAC,4BAAkB,CAAC,KAAW,CAAC;IAChC,KAAK,CAAC,YAAY,KAAK,CAAC;IACxB,KAAK,CAAC,CAAC,0BAAgB,CAAC,KAAoB,CAAC;IAC7C,KAAK,CAAC,eAAe,KAAoB,CAAC;CAClD;AAED,SAAgB,qBAAqB;IACnC,OAAO,IAAI,OAAO,EAAE,CAAC;AACvB,CAAC;AAFD,sDAEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module iModels\n */\n\nimport { LockControl } from \"../LockControl\";\nimport { _close, _elementWasCreated, _implementationProhibited, _releaseAllLocks } from \"./Symbols\";\n\n/** A null-implementation of LockControl that does not attempt to limit access between briefcases. This relies on change-merging to resolve conflicts. */\nclass NoLocks implements LockControl {\n public readonly [_implementationProhibited] = undefined;\n public get isServerBased() { return false; }\n public [_close](): void { }\n public clearAllLocks(): void { }\n public holdsExclusiveLock(): boolean { return false; }\n public holdsSharedLock(): boolean { return false; }\n public checkExclusiveLock(): void { }\n public checkSharedLock(): void { }\n public [_elementWasCreated](): void { }\n public async acquireLocks() { }\n public async [_releaseAllLocks](): Promise<void> { }\n public async releaseAllLocks(): Promise<void> { }\n}\n\nexport function createNoOpLockControl(): LockControl {\n return new NoLocks();\n}\n"]}
|
|
@@ -23,6 +23,7 @@ export declare class ServerBasedLocks implements LockControl {
|
|
|
23
23
|
/** only for tests */
|
|
24
24
|
getLockCount(state: LockState): number;
|
|
25
25
|
[_releaseAllLocks](): Promise<void>;
|
|
26
|
+
releaseAllLocks(): Promise<void>;
|
|
26
27
|
private insertLock;
|
|
27
28
|
private ownerHoldsExclusiveLock;
|
|
28
29
|
/** Determine whether an the exclusive lock is already held by an element (or one of its owners) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerBasedLocks.d.ts","sourceRoot":"","sources":["../../../src/internal/ServerBasedLocks.ts"],"names":[],"mapp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GAAkG;IAC3F,eAAe,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAKvE;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAEvE"}
|
|
@@ -68,6 +68,12 @@ class ServerBasedLocks {
|
|
|
68
68
|
await IModelHost_1.IModelHost.hubAccess.releaseAllLocks(this.briefcase); // throws if unsuccessful
|
|
69
69
|
this.clearAllLocks();
|
|
70
70
|
}
|
|
71
|
+
async releaseAllLocks() {
|
|
72
|
+
if (this.briefcase.txns.hasLocalChanges) {
|
|
73
|
+
throw new Error("Locks cannot be released while the briefcase contains local changes");
|
|
74
|
+
}
|
|
75
|
+
return this[Symbols_1._releaseAllLocks]();
|
|
76
|
+
}
|
|
71
77
|
insertLock(id, state, origin) {
|
|
72
78
|
this.lockDb.withPreparedSqliteStatement("INSERT INTO locks(id,state,origin) VALUES (?,?,?) ON CONFLICT(id) DO UPDATE SET state=excluded.state,origin=excluded.origin", (stmt) => {
|
|
73
79
|
stmt.bindId(1, id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerBasedLocks.js","sourceRoot":"","sources":["../../../src/internal/ServerBasedLocks.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;AAE/F;;GAEG;AAEH,sDAAkG;AAClG,oDAAoE;AAIpE,8CAA2C;AAC3C,0CAAuC;AACvC,uCAA+G;AAmB/G,MAAa,gBAAgB;IAG3B,IAAW,aAAa,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;IAI3C,YAAmB,MAAmB;QANtB,QAA2B,GAAG,SAAS,CAAC;QAGrC,WAAM,GAAG,IAAI,mBAAQ,EAAE,CAAC;QAIzC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC;QACxB,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,mBAAS,CAAC,CAAC,mBAAmB,EAAE,QAAQ,CAAC;QAClE,IAAI,CAAC;YACH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AAI,CAAC,UAAU,CAAC,EAAE,EAAE,uBAAS,CAAC,SAAS,gCAAwB,CAAC;QAChE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;IAC5B,CAAC;IAED,yDAAyD;IACzD,IAAY,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAElF,uGAAuG;IAChG,kBAAkB,CAAC,EAAc,EAAE,IAAY,EAAE,SAAiB;QACvE,IAAI,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC;YACxD,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,WAAW,EAAE,8BAA8B,IAAI,QAAQ,SAAS,QAAQ,EAAE,GAAG,CAAC,CAAC;IACtH,CAAC;IAED,kGAAkG;IAC3F,eAAe,CAAC,EAAc,EAAE,IAAY,EAAE,SAAiB;QACpE,IAAI,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;YACrD,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,WAAW,EAAE,2BAA2B,IAAI,QAAQ,SAAS,QAAQ,EAAE,GAAG,CAAC,CAAC;IACnH,CAAC;CAEF;AApLD,4CAoLC;AAED,SAAgB,sBAAsB,CAAC,MAAmB;IACxD,OAAO,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC;AAFD,wDAEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module iModels\n */\n\nimport { DbResult, Id64, Id64Arg, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\nimport { IModel, IModelError, LockState } from \"@itwin/core-common\";\nimport { LockMap } from \"../BackendHubAccess\";\nimport { BriefcaseDb } from \"../IModelDb\";\nimport { LockControl } from \"../LockControl\";\nimport { IModelHost } from \"../IModelHost\";\nimport { SQLiteDb } from \"../SQLiteDb\";\nimport { _close, _elementWasCreated, _implementationProhibited, _nativeDb, _releaseAllLocks } from \"./Symbols\";\n\n/**\n * Both the Model and Parent of an element are considered \"owners\" of their member elements. That means:\n * 1) they must hold at least a shared lock before an exclusive lock can be acquired for their members\n * 2) if they hold an exclusive lock, then all of their members are exclusively locked implicitly.\n */\ninterface ElementOwners {\n readonly modelId: Id64String;\n readonly parentId: Id64String | undefined;\n}\n\n// eslint-disable-next-line no-restricted-syntax\nconst enum LockOrigin {\n Acquired = 0,\n NewElement = 1,\n Discovered = 2,\n}\n\nexport class ServerBasedLocks implements LockControl {\n public readonly [_implementationProhibited] = undefined;\n\n public get isServerBased() { return true; }\n protected readonly lockDb = new SQLiteDb();\n protected readonly briefcase: BriefcaseDb;\n\n public constructor(iModel: BriefcaseDb) {\n this.briefcase = iModel;\n const dbName = `${iModel[_nativeDb].getTempFileBaseName()}-locks`;\n try {\n this.lockDb.openDb(dbName, OpenMode.ReadWrite);\n } catch (_e) {\n this.lockDb.createDb(dbName);\n this.lockDb.executeSQL(\"CREATE TABLE locks(id INTEGER PRIMARY KEY NOT NULL,state INTEGER NOT NULL,origin INTEGER)\");\n this.lockDb.saveChanges();\n }\n }\n\n public [_close]() {\n if (this.lockDb.isOpen)\n this.lockDb.closeDb();\n }\n\n private getOwners(id: Id64String): ElementOwners {\n return this.briefcase.withPreparedSqliteStatement(\"SELECT ModelId,ParentId FROM bis_Element WHERE id=?\", (stmt) => {\n stmt.bindId(1, id);\n const rc = stmt.step();\n if (DbResult.BE_SQLITE_ROW !== rc)\n throw new IModelError(rc, `element ${id} not found`);\n\n return { modelId: stmt.getValueId(0), parentId: stmt.getValueId(1) };\n });\n }\n\n private getLockState(id?: Id64String): LockState | undefined {\n return (id === undefined || !Id64.isValid(id)) ? undefined : this.lockDb.withPreparedSqliteStatement(\"SELECT state FROM locks WHERE id=?\", (stmt) => {\n stmt.bindId(1, id);\n return (DbResult.BE_SQLITE_ROW === stmt.step()) ? stmt.getValueInteger(0) : undefined;\n });\n }\n\n /** Clear the cache of locally held locks.\n * Note: does *not* release locks from server.\n */\n private clearAllLocks() {\n this.lockDb.executeSQL(\"DELETE FROM locks\");\n this.lockDb.saveChanges();\n }\n\n /** only for tests */\n public getLockCount(state: LockState): number {\n return this.lockDb.withSqliteStatement(\"SELECT count(*) FROM locks WHERE state=?\", (stmt) => {\n stmt.bindInteger(1, state);\n stmt.step();\n return stmt.getValueInteger(0);\n });\n }\n\n public async [_releaseAllLocks](): Promise<void> {\n await IModelHost.hubAccess.releaseAllLocks(this.briefcase); // throws if unsuccessful\n this.clearAllLocks();\n }\n\n private insertLock(id: Id64String, state: LockState, origin: LockOrigin): true {\n this.lockDb.withPreparedSqliteStatement(\"INSERT INTO locks(id,state,origin) VALUES (?,?,?) ON CONFLICT(id) DO UPDATE SET state=excluded.state,origin=excluded.origin\", (stmt) => {\n stmt.bindId(1, id);\n stmt.bindInteger(2, state);\n stmt.bindInteger(3, origin);\n const rc = stmt.step();\n if (DbResult.BE_SQLITE_DONE !== rc)\n throw new IModelError(rc, \"can't insert lock into database\");\n });\n return true;\n }\n\n private ownerHoldsExclusiveLock(id: Id64String | undefined): boolean {\n if (id === undefined || id === IModel.rootSubjectId)\n return false; // has no owners\n\n const { modelId, parentId } = this.getOwners(id);\n if (this.getLockState(modelId) === LockState.Exclusive || this.getLockState(parentId) === LockState.Exclusive)\n return true;\n\n // see if this model is exclusively locked by one of its owners. If so, save that fact on modelId so future tests won't have to descend.\n if (this.ownerHoldsExclusiveLock(modelId))\n return this.insertLock(modelId, LockState.Exclusive, LockOrigin.Discovered);\n\n // see if the parent is exclusively locked by one of its owners. If so, save that fact on parentId so future tests won't have to descend.\n return this.ownerHoldsExclusiveLock(parentId) ? this.insertLock(parentId!, LockState.Exclusive, LockOrigin.Discovered) : false; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n }\n\n /** Determine whether an the exclusive lock is already held by an element (or one of its owners) */\n public holdsExclusiveLock(id: Id64String): boolean {\n // see if we hold the exclusive lock. or if one of the element's owners is exclusively locked (recursively)\n return this.getLockState(id) === LockState.Exclusive || this.ownerHoldsExclusiveLock(id);\n }\n\n public holdsSharedLock(id: Id64String): boolean {\n const state = this.getLockState(id);\n // see if we hold shared or exclusive lock, or if an owner has exclusive lock. If so we implicitly have shared lock, but owner holding shared lock doesn't help.\n return (state === LockState.Shared || state === LockState.Exclusive) || this.ownerHoldsExclusiveLock(id);\n }\n\n /** if the shared lock on the element supplied is not already held, add it to the set of shared locks required. Then, check owners. */\n private addSharedLock(id: Id64String | undefined, locks: Set<Id64String>) {\n // if the id is not valid, or of the lock is already in the set, or if we already hold a shared lock, we're done\n // Note: if we hold a shared lock, it is guaranteed that we also hold all required shared locks on owners.\n if (id === undefined || !Id64.isValid(id) || locks.has(id) || this.holdsSharedLock(id))\n return;\n\n locks.add(id); // add to set of needed shared locks\n this.addOwnerSharedLocks(id, locks); // check parent models and groups\n }\n\n /** add owners (recursively) of an element to a list of required shared locks, if not already held. */\n private addOwnerSharedLocks(id: Id64String, locks: Set<Id64String>) {\n const el = this.getOwners(id);\n this.addSharedLock(el.parentId, locks); // if this element is in a group\n this.addSharedLock(el.modelId, locks); // check its model\n }\n\n /** attempt to acquire all necessary locks for a set of elements */\n private async acquireAllLocks(locks: LockMap) {\n if (locks.size === 0) // no locks are required.\n return;\n\n const sharedLocks = new Set<Id64String>();\n for (const lock of locks)\n this.addOwnerSharedLocks(lock[0], sharedLocks);\n\n for (const shared of sharedLocks) {\n if (!locks.has(shared)) // we may already be asking for exclusive lock\n locks.set(shared, LockState.Shared);\n }\n\n await IModelHost.hubAccess.acquireLocks(this.briefcase, locks); // throws if unsuccessful\n for (const lock of locks)\n this.insertLock(lock[0], lock[1], LockOrigin.Acquired);\n this.lockDb.saveChanges();\n }\n\n public async acquireLocks(arg: { shared?: Id64Arg, exclusive?: Id64Arg }): Promise<void> {\n const locks = new Map<Id64String, LockState>();\n if (arg.shared) {\n for (const id of Id64.iterable(arg.shared)) {\n if (!this.holdsSharedLock(id))\n locks.set(id, LockState.Shared);\n }\n }\n if (arg.exclusive) {\n for (const id of Id64.iterable(arg.exclusive)) {\n if (!this.holdsExclusiveLock(id))\n locks.set(id, LockState.Exclusive);\n }\n }\n return this.acquireAllLocks(locks);\n }\n\n /** When an element is newly created in a session, we hold the lock on it implicitly. Save that fact. */\n public [_elementWasCreated](id: Id64String) {\n this.insertLock(id, LockState.Exclusive, LockOrigin.NewElement);\n this.lockDb.saveChanges();\n }\n\n /** locks are not necessary during change propagation. */\n private get _locksAreRequired() { return !this.briefcase.txns.isIndirectChanges; }\n\n /** throw if locks are currently required and the exclusive lock is not held on the supplied element */\n public checkExclusiveLock(id: Id64String, type: string, operation: string) {\n if (this._locksAreRequired && !this.holdsExclusiveLock(id))\n throw new IModelError(IModelStatus.LockNotHeld, `exclusive lock not held on ${type} for ${operation} (id=${id})`);\n }\n\n /** throw if locks are currently required and a shared lock is not held on the supplied element */\n public checkSharedLock(id: Id64String, type: string, operation: string) {\n if (this._locksAreRequired && !this.holdsSharedLock(id))\n throw new IModelError(IModelStatus.LockNotHeld, `shared lock not held on ${type} for ${operation} (id=${id})`);\n }\n\n}\n\nexport function createServerBasedLocks(iModel: BriefcaseDb): LockControl {\n return new ServerBasedLocks(iModel);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ServerBasedLocks.js","sourceRoot":"","sources":["../../../src/internal/ServerBasedLocks.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;AAE/F;;GAEG;AAEH,sDAAkG;AAClG,oDAAoE;AAIpE,8CAA2C;AAC3C,0CAAuC;AACvC,uCAA+G;AAmB/G,MAAa,gBAAgB;IAG3B,IAAW,aAAa,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;IAI3C,YAAmB,MAAmB;QANtB,QAA2B,GAAG,SAAS,CAAC;QAGrC,WAAM,GAAG,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AAC,MAAmB;IACxD,OAAO,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC;AAFD,wDAEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module iModels\n */\n\nimport { DbResult, Id64, Id64Arg, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\nimport { IModel, IModelError, LockState } from \"@itwin/core-common\";\nimport { LockMap } from \"../BackendHubAccess\";\nimport { BriefcaseDb } from \"../IModelDb\";\nimport { LockControl } from \"../LockControl\";\nimport { IModelHost } from \"../IModelHost\";\nimport { SQLiteDb } from \"../SQLiteDb\";\nimport { _close, _elementWasCreated, _implementationProhibited, _nativeDb, _releaseAllLocks } from \"./Symbols\";\n\n/**\n * Both the Model and Parent of an element are considered \"owners\" of their member elements. That means:\n * 1) they must hold at least a shared lock before an exclusive lock can be acquired for their members\n * 2) if they hold an exclusive lock, then all of their members are exclusively locked implicitly.\n */\ninterface ElementOwners {\n readonly modelId: Id64String;\n readonly parentId: Id64String | undefined;\n}\n\n// eslint-disable-next-line no-restricted-syntax\nconst enum LockOrigin {\n Acquired = 0,\n NewElement = 1,\n Discovered = 2,\n}\n\nexport class ServerBasedLocks implements LockControl {\n public readonly [_implementationProhibited] = undefined;\n\n public get isServerBased() { return true; }\n protected readonly lockDb = new SQLiteDb();\n protected readonly briefcase: BriefcaseDb;\n\n public constructor(iModel: BriefcaseDb) {\n this.briefcase = iModel;\n const dbName = `${iModel[_nativeDb].getTempFileBaseName()}-locks`;\n try {\n this.lockDb.openDb(dbName, OpenMode.ReadWrite);\n } catch (_e) {\n this.lockDb.createDb(dbName);\n this.lockDb.executeSQL(\"CREATE TABLE locks(id INTEGER PRIMARY KEY NOT NULL,state INTEGER NOT NULL,origin INTEGER)\");\n this.lockDb.saveChanges();\n }\n }\n\n public [_close]() {\n if (this.lockDb.isOpen)\n this.lockDb.closeDb();\n }\n\n private getOwners(id: Id64String): ElementOwners {\n return this.briefcase.withPreparedSqliteStatement(\"SELECT ModelId,ParentId FROM bis_Element WHERE id=?\", (stmt) => {\n stmt.bindId(1, id);\n const rc = stmt.step();\n if (DbResult.BE_SQLITE_ROW !== rc)\n throw new IModelError(rc, `element ${id} not found`);\n\n return { modelId: stmt.getValueId(0), parentId: stmt.getValueId(1) };\n });\n }\n\n private getLockState(id?: Id64String): LockState | undefined {\n return (id === undefined || !Id64.isValid(id)) ? undefined : this.lockDb.withPreparedSqliteStatement(\"SELECT state FROM locks WHERE id=?\", (stmt) => {\n stmt.bindId(1, id);\n return (DbResult.BE_SQLITE_ROW === stmt.step()) ? stmt.getValueInteger(0) : undefined;\n });\n }\n\n /** Clear the cache of locally held locks.\n * Note: does *not* release locks from server.\n */\n private clearAllLocks() {\n this.lockDb.executeSQL(\"DELETE FROM locks\");\n this.lockDb.saveChanges();\n }\n\n /** only for tests */\n public getLockCount(state: LockState): number {\n return this.lockDb.withSqliteStatement(\"SELECT count(*) FROM locks WHERE state=?\", (stmt) => {\n stmt.bindInteger(1, state);\n stmt.step();\n return stmt.getValueInteger(0);\n });\n }\n\n public async [_releaseAllLocks](): Promise<void> {\n await IModelHost.hubAccess.releaseAllLocks(this.briefcase); // throws if unsuccessful\n this.clearAllLocks();\n }\n\n public async releaseAllLocks(): Promise<void> {\n if (this.briefcase.txns.hasLocalChanges) {\n throw new Error(\"Locks cannot be released while the briefcase contains local changes\");\n }\n\n return this[_releaseAllLocks]();\n }\n\n private insertLock(id: Id64String, state: LockState, origin: LockOrigin): true {\n this.lockDb.withPreparedSqliteStatement(\"INSERT INTO locks(id,state,origin) VALUES (?,?,?) ON CONFLICT(id) DO UPDATE SET state=excluded.state,origin=excluded.origin\", (stmt) => {\n stmt.bindId(1, id);\n stmt.bindInteger(2, state);\n stmt.bindInteger(3, origin);\n const rc = stmt.step();\n if (DbResult.BE_SQLITE_DONE !== rc)\n throw new IModelError(rc, \"can't insert lock into database\");\n });\n return true;\n }\n\n private ownerHoldsExclusiveLock(id: Id64String | undefined): boolean {\n if (id === undefined || id === IModel.rootSubjectId)\n return false; // has no owners\n\n const { modelId, parentId } = this.getOwners(id);\n if (this.getLockState(modelId) === LockState.Exclusive || this.getLockState(parentId) === LockState.Exclusive)\n return true;\n\n // see if this model is exclusively locked by one of its owners. If so, save that fact on modelId so future tests won't have to descend.\n if (this.ownerHoldsExclusiveLock(modelId))\n return this.insertLock(modelId, LockState.Exclusive, LockOrigin.Discovered);\n\n // see if the parent is exclusively locked by one of its owners. If so, save that fact on parentId so future tests won't have to descend.\n return this.ownerHoldsExclusiveLock(parentId) ? this.insertLock(parentId!, LockState.Exclusive, LockOrigin.Discovered) : false; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n }\n\n /** Determine whether an the exclusive lock is already held by an element (or one of its owners) */\n public holdsExclusiveLock(id: Id64String): boolean {\n // see if we hold the exclusive lock. or if one of the element's owners is exclusively locked (recursively)\n return this.getLockState(id) === LockState.Exclusive || this.ownerHoldsExclusiveLock(id);\n }\n\n public holdsSharedLock(id: Id64String): boolean {\n const state = this.getLockState(id);\n // see if we hold shared or exclusive lock, or if an owner has exclusive lock. If so we implicitly have shared lock, but owner holding shared lock doesn't help.\n return (state === LockState.Shared || state === LockState.Exclusive) || this.ownerHoldsExclusiveLock(id);\n }\n\n /** if the shared lock on the element supplied is not already held, add it to the set of shared locks required. Then, check owners. */\n private addSharedLock(id: Id64String | undefined, locks: Set<Id64String>) {\n // if the id is not valid, or of the lock is already in the set, or if we already hold a shared lock, we're done\n // Note: if we hold a shared lock, it is guaranteed that we also hold all required shared locks on owners.\n if (id === undefined || !Id64.isValid(id) || locks.has(id) || this.holdsSharedLock(id))\n return;\n\n locks.add(id); // add to set of needed shared locks\n this.addOwnerSharedLocks(id, locks); // check parent models and groups\n }\n\n /** add owners (recursively) of an element to a list of required shared locks, if not already held. */\n private addOwnerSharedLocks(id: Id64String, locks: Set<Id64String>) {\n const el = this.getOwners(id);\n this.addSharedLock(el.parentId, locks); // if this element is in a group\n this.addSharedLock(el.modelId, locks); // check its model\n }\n\n /** attempt to acquire all necessary locks for a set of elements */\n private async acquireAllLocks(locks: LockMap) {\n if (locks.size === 0) // no locks are required.\n return;\n\n const sharedLocks = new Set<Id64String>();\n for (const lock of locks)\n this.addOwnerSharedLocks(lock[0], sharedLocks);\n\n for (const shared of sharedLocks) {\n if (!locks.has(shared)) // we may already be asking for exclusive lock\n locks.set(shared, LockState.Shared);\n }\n\n await IModelHost.hubAccess.acquireLocks(this.briefcase, locks); // throws if unsuccessful\n for (const lock of locks)\n this.insertLock(lock[0], lock[1], LockOrigin.Acquired);\n this.lockDb.saveChanges();\n }\n\n public async acquireLocks(arg: { shared?: Id64Arg, exclusive?: Id64Arg }): Promise<void> {\n const locks = new Map<Id64String, LockState>();\n if (arg.shared) {\n for (const id of Id64.iterable(arg.shared)) {\n if (!this.holdsSharedLock(id))\n locks.set(id, LockState.Shared);\n }\n }\n if (arg.exclusive) {\n for (const id of Id64.iterable(arg.exclusive)) {\n if (!this.holdsExclusiveLock(id))\n locks.set(id, LockState.Exclusive);\n }\n }\n return this.acquireAllLocks(locks);\n }\n\n /** When an element is newly created in a session, we hold the lock on it implicitly. Save that fact. */\n public [_elementWasCreated](id: Id64String) {\n this.insertLock(id, LockState.Exclusive, LockOrigin.NewElement);\n this.lockDb.saveChanges();\n }\n\n /** locks are not necessary during change propagation. */\n private get _locksAreRequired() { return !this.briefcase.txns.isIndirectChanges; }\n\n /** throw if locks are currently required and the exclusive lock is not held on the supplied element */\n public checkExclusiveLock(id: Id64String, type: string, operation: string) {\n if (this._locksAreRequired && !this.holdsExclusiveLock(id))\n throw new IModelError(IModelStatus.LockNotHeld, `exclusive lock not held on ${type} for ${operation} (id=${id})`);\n }\n\n /** throw if locks are currently required and a shared lock is not held on the supplied element */\n public checkSharedLock(id: Id64String, type: string, operation: string) {\n if (this._locksAreRequired && !this.holdsSharedLock(id))\n throw new IModelError(IModelStatus.LockNotHeld, `shared lock not held on ${type} for ${operation} (id=${id})`);\n }\n\n}\n\nexport function createServerBasedLocks(iModel: BriefcaseDb): LockControl {\n return new ServerBasedLocks(iModel);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-backend",
|
|
3
|
-
"version": "4.8.0-dev.
|
|
3
|
+
"version": "4.8.0-dev.29",
|
|
4
4
|
"description": "iTwin.js backend components",
|
|
5
5
|
"main": "lib/cjs/core-backend.js",
|
|
6
6
|
"typings": "lib/cjs/core-backend",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"url": "http://www.bentley.com"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@itwin/core-bentley": "^4.8.0-dev.
|
|
29
|
-
"@itwin/core-common": "^4.8.0-dev.
|
|
30
|
-
"@itwin/core-geometry": "^4.8.0-dev.
|
|
28
|
+
"@itwin/core-bentley": "^4.8.0-dev.29",
|
|
29
|
+
"@itwin/core-common": "^4.8.0-dev.29",
|
|
30
|
+
"@itwin/core-geometry": "^4.8.0-dev.29",
|
|
31
31
|
"@opentelemetry/api": "^1.0.4"
|
|
32
32
|
},
|
|
33
33
|
"peerDependenciesMeta": {
|
|
@@ -69,16 +69,16 @@
|
|
|
69
69
|
"ts-node": "^10.8.2",
|
|
70
70
|
"typescript": "~5.3.3",
|
|
71
71
|
"webpack": "^5.76.0",
|
|
72
|
-
"@itwin/build-tools": "4.8.0-dev.
|
|
73
|
-
"@itwin/core-
|
|
74
|
-
"@itwin/core-
|
|
75
|
-
"@itwin/core-
|
|
76
|
-
"@itwin/core-
|
|
77
|
-
"
|
|
78
|
-
"
|
|
72
|
+
"@itwin/build-tools": "4.8.0-dev.29",
|
|
73
|
+
"@itwin/core-bentley": "4.8.0-dev.29",
|
|
74
|
+
"@itwin/core-webpack-tools": "4.8.0-dev.29",
|
|
75
|
+
"@itwin/core-common": "4.8.0-dev.29",
|
|
76
|
+
"@itwin/core-geometry": "4.8.0-dev.29",
|
|
77
|
+
"internal-tools": "3.0.0-dev.69",
|
|
78
|
+
"@itwin/ecsql-common": "4.8.0-dev.29"
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@bentley/imodeljs-native": "4.8.
|
|
81
|
+
"@bentley/imodeljs-native": "4.8.25",
|
|
82
82
|
"@itwin/cloud-agnostic-core": "^2.1.0",
|
|
83
83
|
"@itwin/object-storage-azure": "^2.2.2",
|
|
84
84
|
"@itwin/object-storage-core": "^2.2.2",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"semver": "^7.3.5",
|
|
93
93
|
"touch": "^3.1.0",
|
|
94
94
|
"ws": "^7.5.10",
|
|
95
|
-
"@itwin/core-telemetry": "4.8.0-dev.
|
|
95
|
+
"@itwin/core-telemetry": "4.8.0-dev.29"
|
|
96
96
|
},
|
|
97
97
|
"nyc": {
|
|
98
98
|
"extends": "./node_modules/@itwin/build-tools/.nycrc"
|