@itwin/core-backend 4.8.0-dev.16 → 4.8.0-dev.18
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/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BackendLoggerCategory.js.map +1 -1
- package/lib/cjs/BisCoreSchema.js.map +1 -1
- package/lib/cjs/BlobContainerService.js.map +1 -1
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +4 -2
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/Category.d.ts +0 -6
- package/lib/cjs/Category.d.ts.map +1 -1
- package/lib/cjs/Category.js +0 -6
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +2 -2
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.d.ts.map +1 -1
- package/lib/cjs/ChangedElementsDb.js +2 -1
- package/lib/cjs/ChangedElementsDb.js.map +1 -1
- package/lib/cjs/ChangedElementsManager.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +237 -237
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/ChannelControl.d.ts +4 -26
- package/lib/cjs/ChannelControl.d.ts.map +1 -1
- package/lib/cjs/ChannelControl.js +2 -101
- package/lib/cjs/ChannelControl.js.map +1 -1
- package/lib/cjs/CheckpointManager.d.ts.map +1 -1
- package/lib/cjs/CheckpointManager.js +2 -1
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.js +5 -5
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/CodeService.js.map +1 -1
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
- package/lib/cjs/DevTools.d.ts.map +1 -1
- package/lib/cjs/DevTools.js +2 -1
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/DisplayStyle.d.ts +0 -3
- package/lib/cjs/DisplayStyle.d.ts.map +1 -1
- package/lib/cjs/DisplayStyle.js +0 -3
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.js +2 -2
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.js +2 -2
- package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
- package/lib/cjs/ECSqlStatement.d.ts +6 -3
- package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
- package/lib/cjs/ECSqlStatement.js +3 -3
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.d.ts +2 -59
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +7 -63
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.d.ts +0 -5
- package/lib/cjs/ElementAspect.d.ts.map +1 -1
- package/lib/cjs/ElementAspect.js +4 -8
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementGraphics.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/EntityReferences.js.map +1 -1
- package/lib/cjs/ExportGraphics.js.map +1 -1
- package/lib/cjs/ExternalSource.js.map +1 -1
- package/lib/cjs/GeoCoordConfig.d.ts.map +1 -1
- package/lib/cjs/GeoCoordConfig.js +2 -1
- package/lib/cjs/GeoCoordConfig.js.map +1 -1
- package/lib/cjs/GeographicCRSServices.js +2 -2
- package/lib/cjs/GeographicCRSServices.js.map +1 -1
- package/lib/cjs/GeometrySummary.js +47 -47
- package/lib/cjs/GeometrySummary.js.map +1 -1
- package/lib/cjs/HubMock.js.map +1 -1
- package/lib/cjs/IModelCloneContext.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +11 -86
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +55 -38
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelElementCloneContext.js +2 -2
- package/lib/cjs/IModelElementCloneContext.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +5 -3
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +16 -18
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/IpcHost.d.ts.map +1 -1
- package/lib/cjs/IpcHost.js +2 -1
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LineStyle.js.map +1 -1
- package/lib/cjs/LocalHub.js +1 -1
- package/lib/cjs/LocalHub.js.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/LockControl.d.ts +65 -0
- package/lib/cjs/LockControl.d.ts.map +1 -0
- package/lib/cjs/LockControl.js +11 -0
- package/lib/cjs/LockControl.js.map +1 -0
- package/lib/cjs/Material.d.ts +2 -5
- package/lib/cjs/Material.d.ts.map +1 -1
- package/lib/cjs/Material.js +1 -4
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.d.ts +0 -22
- package/lib/cjs/Model.d.ts.map +1 -1
- package/lib/cjs/Model.js +4 -25
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/NativeAppStorage.js.map +1 -1
- package/lib/cjs/NativeHost.js.map +1 -1
- package/lib/cjs/NavigationRelationship.js.map +1 -1
- package/lib/cjs/PromiseMemoizer.js.map +1 -1
- package/lib/cjs/PropertyStore.js.map +1 -1
- package/lib/cjs/Relationship.d.ts +0 -12
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +0 -12
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/SQLiteDb.d.ts.map +1 -1
- package/lib/cjs/SQLiteDb.js +3 -3
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/Schema.js.map +1 -1
- package/lib/cjs/SchemaSync.js +2 -2
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/SchemaUtils.js +3 -3
- package/lib/cjs/SchemaUtils.js.map +1 -1
- package/lib/cjs/SqliteChangesetReader.d.ts.map +1 -1
- package/lib/cjs/SqliteChangesetReader.js +2 -2
- package/lib/cjs/SqliteChangesetReader.js.map +1 -1
- package/lib/cjs/SqliteStatement.js +2 -2
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/TextAnnotationElement.js.map +1 -1
- package/lib/cjs/TextAnnotationGeometry.js.map +1 -1
- package/lib/cjs/TextAnnotationLayout.js.map +1 -1
- package/lib/cjs/Texture.js.map +1 -1
- package/lib/cjs/TileStorage.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts +2 -1
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +1 -0
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts +1 -18
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +1 -18
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/ViewStateHydrator.js.map +1 -1
- package/lib/cjs/ViewStore.js.map +1 -1
- package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
- package/lib/cjs/assets/Settings/Schemas/Base.Schema.json +32 -32
- package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +27 -27
- package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +94 -94
- package/lib/cjs/assets/Settings/backend.setting.json5 +21 -21
- package/lib/cjs/core-backend.d.ts +1 -1
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +2 -5
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.d.ts +0 -10
- package/lib/cjs/domains/FunctionalElements.d.ts.map +1 -1
- package/lib/cjs/domains/FunctionalElements.js +0 -10
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
- package/lib/cjs/domains/GenericElements.d.ts +0 -18
- package/lib/cjs/domains/GenericElements.d.ts.map +1 -1
- package/lib/cjs/domains/GenericElements.js +0 -18
- package/lib/cjs/domains/GenericElements.js.map +1 -1
- package/lib/cjs/domains/GenericSchema.js.map +1 -1
- package/lib/cjs/internal/ChangesetConflictArgs.d.ts +24 -0
- package/lib/cjs/internal/ChangesetConflictArgs.d.ts.map +1 -0
- package/lib/cjs/internal/ChangesetConflictArgs.js +7 -0
- package/lib/cjs/internal/ChangesetConflictArgs.js.map +1 -0
- package/lib/cjs/internal/ChannelAdmin.d.ts +34 -0
- package/lib/cjs/internal/ChannelAdmin.d.ts.map +1 -0
- package/lib/cjs/internal/ChannelAdmin.js +117 -0
- package/lib/cjs/internal/ChannelAdmin.js.map +1 -0
- package/lib/cjs/internal/NativePlatform.d.ts +15 -0
- package/lib/cjs/internal/NativePlatform.d.ts.map +1 -0
- package/lib/cjs/internal/NativePlatform.js +49 -0
- package/lib/cjs/internal/NativePlatform.js.map +1 -0
- package/lib/cjs/internal/NoLocks.d.ts +6 -0
- package/lib/cjs/internal/NoLocks.d.ts.map +1 -0
- package/lib/cjs/internal/NoLocks.js +30 -0
- package/lib/cjs/internal/NoLocks.js.map +1 -0
- package/lib/cjs/{ServerBasedLocks.d.ts → internal/ServerBasedLocks.d.ts} +9 -16
- package/lib/cjs/internal/ServerBasedLocks.d.ts.map +1 -0
- package/lib/cjs/{ServerBasedLocks.js → internal/ServerBasedLocks.js} +13 -7
- package/lib/cjs/internal/ServerBasedLocks.js.map +1 -0
- package/lib/cjs/internal/Symbols.d.ts +9 -0
- package/lib/cjs/internal/Symbols.d.ts.map +1 -0
- package/lib/cjs/internal/Symbols.js +19 -0
- package/lib/cjs/internal/Symbols.js.map +1 -0
- package/lib/cjs/internal/cross-package.d.ts +3 -0
- package/lib/cjs/internal/cross-package.d.ts.map +1 -0
- package/lib/cjs/internal/cross-package.js +14 -0
- package/lib/cjs/internal/cross-package.js.map +1 -0
- package/lib/cjs/internal/workspace/SettingsImpl.d.ts +2 -2
- package/lib/cjs/internal/workspace/SettingsImpl.d.ts.map +1 -1
- package/lib/cjs/internal/workspace/SettingsImpl.js +3 -3
- package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.js +2 -2
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceImpl.js +5 -5
- package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js.map +1 -1
- package/lib/cjs/rpc/multipart.js.map +1 -1
- package/lib/cjs/rpc/tracing.js +1 -1
- package/lib/cjs/rpc/tracing.js.map +1 -1
- package/lib/cjs/rpc/web/logging.js.map +1 -1
- package/lib/cjs/rpc/web/request.js.map +1 -1
- package/lib/cjs/rpc/web/response.js.map +1 -1
- package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +1 -0
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +4 -0
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +2 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/Settings.d.ts +3 -3
- package/lib/cjs/workspace/Settings.d.ts.map +1 -1
- package/lib/cjs/workspace/Settings.js +1 -1
- package/lib/cjs/workspace/Settings.js.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.d.ts +2 -2
- package/lib/cjs/workspace/SettingsSchemas.d.ts.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.js +1 -1
- package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
- package/lib/cjs/workspace/Workspace.d.ts +4 -4
- package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
- package/lib/cjs/workspace/Workspace.js +1 -1
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/lib/cjs/workspace/WorkspaceEditor.d.ts +2 -2
- package/lib/cjs/workspace/WorkspaceEditor.d.ts.map +1 -1
- package/lib/cjs/workspace/WorkspaceEditor.js +1 -1
- package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -1
- package/package.json +13 -13
- package/lib/cjs/ServerBasedLocks.d.ts.map +0 -1
- package/lib/cjs/ServerBasedLocks.js.map +0 -1
- package/lib/cjs/internal/ImplementationProhibited.d.ts +0 -44
- package/lib/cjs/internal/ImplementationProhibited.d.ts.map +0 -1
- package/lib/cjs/internal/ImplementationProhibited.js +0 -51
- package/lib/cjs/internal/ImplementationProhibited.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkspaceEditor.js","sourceRoot":"","sources":["../../../src/workspace/WorkspaceEditor.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAUH,+EAA4E;AAC5E,uEAA+E;AAC/E,mFAAgF;AAEhF,YAAY;AACZ,IAAiB,eAAe,CAgB/B;AAhBD,WAAiB,eAAe;IAC9B;;;;OAIG;IACH,SAAgB,SAAS;QACvB,OAAO,IAAA,wCAAwB,GAAE,CAAC;IACpC,CAAC;IAFe,yBAAS,YAExB,CAAA;IAED;;OAEG;IACH,SAAgB,aAAa,CAAC,IAAqE;QACjG,qCAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IAC1D,CAAC;IAFe,6BAAa,gBAE5B,CAAA;AACH,CAAC,EAhBgB,eAAe,+BAAf,eAAe,QAgB/B","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 Workspace\r\n */\r\n\r\nimport { LocalFileName } from \"@itwin/core-common\";\r\nimport { SQLiteDb } from \"../SQLiteDb\";\r\nimport { SettingsContainer } from \"./Settings\";\r\nimport { BlobContainer } from \"../BlobContainerService\";\r\nimport {\r\n GetWorkspaceContainerArgs, Workspace, WorkspaceContainer, WorkspaceContainerProps, WorkspaceDb, WorkspaceDbCloudProps, WorkspaceDbManifest, WorkspaceDbName, WorkspaceDbNameAndVersion,\r\n WorkspaceDbProps, WorkspaceDbVersion, WorkspaceResourceName,\r\n} from \"./Workspace\";\r\nimport { WorkspaceSqliteDb } from \"../internal/workspace/WorkspaceSqliteDb\";\r\nimport { constructWorkspaceEditor } from \"../internal/workspace/WorkspaceImpl\";\r\nimport { implementationProhibited } from \"../internal/ImplementationProhibited\";\r\n\r\n/** @beta */\r\nexport namespace WorkspaceEditor {\r\n /**\r\n * Create a new [[WorkspaceEditor]] for creating new versions of [[WorkspaceDb]]s.\r\n * @note the caller becomes the owner of the Workspace.Editor and is responsible for calling [[WorkspaceEditor.close]] on it when they are finished using it.\r\n * @note It is illegal to have more than one Workspace.Editor active in a single session.\r\n */\r\n export function construct(): WorkspaceEditor {\r\n return constructWorkspaceEditor();\r\n }\r\n\r\n /**\r\n * Create a new, empty, [[EditableWorkspaceDb]] file on the local filesystem for importing [[Workspace]] resources.\r\n */\r\n export function createEmptyDb(args: { localFileName: LocalFileName, manifest: WorkspaceDbManifest }): void {\r\n WorkspaceSqliteDb.createNewDb(args.localFileName, args);\r\n }\r\n}\r\n\r\n/** Arguments supplied to [[WorkspaceEditor.createNewCloudContainer]] to create a new [[EditableWorkspaceContainer]].\r\n * @beta\r\n */\r\nexport interface CreateNewWorkspaceContainerArgs {\r\n /**\r\n * The scope of the container. This determines the ownership of the container, how RBAC rights are assigned,\r\n * and the location of the datacenter\r\n */\r\n scope: BlobContainer.Scope;\r\n /** The manifest to be stored in the default WorkspaceDb in the new container. */\r\n manifest: WorkspaceDbManifest;\r\n /** Metadata stored by the BlobContainer service */\r\n metadata: Omit<BlobContainer.Metadata, \"containerType\">;\r\n /** The name of the default [[WorkspaceDb]] created inside the new container.\r\n * Default: \"workspace-db\";\r\n */\r\n dbName?: WorkspaceDbName;\r\n}\r\n\r\n/**\r\n * A [[WorkspaceContainer]] opened for editing by a [[WorkspaceEditor]].\r\n * You can create new [[WorkspaceDb]]s or new versions of existing [[WorkspaceDb]]s inside it.\r\n * Before actually making any changes to the container's contents, you must first obtain an exclusive write lock on it via\r\n * [[acquireWriteLock]]. Only one user can hold the write lock at any given time. When you have finished making changes,\r\n * you can use [[releaseWriteLock]] to publish your changes, or [[abandonChanges]] to discard them.\r\n * @beta\r\n */\r\nexport interface EditableWorkspaceContainer extends WorkspaceContainer {\r\n /**\r\n * Create a copy of an existing [[WorkspaceDb]] in this container with a new [[WorkspaceDbVersion]].\r\n * The copy should be modified with new content before the write lock is released,\r\n * and thereafter may never be modified again.\r\n * @note The copy actually shares all of the data with the original, but with copy-on-write if/when data in the new WorkspaceDb is modified.\r\n * @param props - The properties that determine the source WorkspaceDb to serve as the basis for the new version.\r\n * @returns A promise that resolves to an object containing the old and new WorkspaceDb names and versions.\r\n */\r\n createNewWorkspaceDbVersion(props: CreateNewWorkspaceDbVersionArgs): Promise<{ oldDb: WorkspaceDbNameAndVersion, newDb: WorkspaceDbNameAndVersion }>;\r\n\r\n /**\r\n * Create a new, empty [[WorkspaceDb]].\r\n * @param args - The arguments for creating the new WorkspaceDb.\r\n * @returns A promise that resolves to an EditableWorkspaceDb.\r\n */\r\n createDb(args: { dbName?: WorkspaceDbName, version?: WorkspaceDbVersion, manifest: WorkspaceDbManifest }): Promise<EditableWorkspaceDb>;\r\n\r\n /**\r\n * Get the cloud properties of this container.\r\n */\r\n readonly cloudProps: WorkspaceContainerProps | undefined;\r\n\r\n /**\r\n * Get an editable [[WorkspaceDb]] to add, delete, or update resources *within a newly created version* of a WorkspaceDb.\r\n * @param props - The properties of the WorkspaceDb.\r\n */\r\n getEditableDb(props: WorkspaceDbProps): EditableWorkspaceDb;\r\n\r\n /**\r\n * Acquire the write lock on the container. Use [[releaseWriteLock]] to release the lock after publishing your changes, or\r\n * [[abandonChanges]] to release the lock and discard your changes.\r\n * Only one use can hold the write lock at any given time. However, readers can continue to read the published contents of the container while\r\n * a writer holds the write lock. Readers will only see the writer's changes after they are published by [[releaseWriteLock]].\r\n * @param user - The name of the user acquiring the write lock.\r\n */\r\n acquireWriteLock(user: string): void;\r\n\r\n /**\r\n * Release the write lock on the container. This should be called after all changes to the container's contents are complete. It\r\n * publishes and uploads the changes made to any [[WorkspaceDb]]s while the lock was held, after which those dbs become immutable.\r\n */\r\n releaseWriteLock(): void;\r\n\r\n /**\r\n * Abandon any changes made to the container and release the write lock. Any newly created versions of WorkspaceDbs are discarded.\r\n */\r\n abandonChanges(): void;\r\n}\r\n\r\n/**\r\n * The release increment for a version number, used as part of [[CreateNewWorkspaceDbVersionArgs]] to specify the kind of version to create.\r\n * @see [semver.ReleaseType](https://www.npmjs.com/package/semver)\r\n * @beta\r\n */\r\nexport type WorkspaceDbVersionIncrement = \"major\" | \"minor\" | \"patch\" | \"premajor\" | \"preminor\" | \"prepatch\" | \"prerelease\";\r\n\r\n/**\r\n * Arguments supplied to [[Workspace.createNewWorkspaceDbVersion]].\r\n * @beta\r\n */\r\nexport interface CreateNewWorkspaceDbVersionArgs {\r\n /**\r\n * The properties that determine the source [[WorkspaceDb]] to serve as the basis for the new version.\r\n * This is usually the latest version, but it is possible to create patches to older versions.\r\n */\r\n fromProps?: WorkspaceDbProps;\r\n /** The type of version increment to apply to the source version. */\r\n versionType: WorkspaceDbVersionIncrement;\r\n /** For prerelease versions, a string that becomes part of the version name. */\r\n identifier?: string;\r\n}\r\n\r\n/**\r\n * An editable [[WorkspaceDb]]. This is used only by tools to allow administrators to create and modify WorkspaceDbs.\r\n * For cloud-based WorkspaceDbs, the container's write token must be obtained via [[EditableWorkspaceContainer.acquireWriteLock]] before the methods in this interface may be used.\r\n * Normally, only admins will have write access to a [[Workspace]].\r\n * Only one admin at a time may be editing a Workspace.\r\n * @beta\r\n */\r\nexport interface EditableWorkspaceDb extends WorkspaceDb {\r\n readonly container: EditableWorkspaceContainer;\r\n /**\r\n * The cloud properties of the [[WorkspaceDb]], if this is a cloud-based WorkspaceDb.\r\n */\r\n get cloudProps(): WorkspaceDbCloudProps | undefined;\r\n\r\n /**\r\n * Update the contents of the manifest in this WorkspaceDb.\r\n * @param manifest - The updated manifest.\r\n */\r\n updateManifest(manifest: WorkspaceDbManifest): void;\r\n\r\n /**\r\n * Add or update a resource in this WorkspaceDb that can be loaded as a [[SettingsDictionary]].\r\n * The `settings` will be stored as stringified JSON.\r\n * @param settings - The settings object to add or update.\r\n * @param rscName - The name of the settings resource. Defaults to \"settingsDictionary\" if undefined.\r\n */\r\n updateSettingsResource(settings: SettingsContainer, rscName?: string): void;\r\n\r\n /**\r\n * Add a new string resource to this WorkspaceDb.\r\n * @param rscName - The name of the string resource.\r\n * @param val - The string to save.\r\n * @throws if a string resource named `rscName` already exists.\r\n */\r\n addString(rscName: WorkspaceResourceName, val: string): void;\r\n\r\n /**\r\n * Update an existing string resource with a new value, or add it if it does not exist.\r\n * @param rscName - The name of the string resource.\r\n * @param val - The new value.\r\n */\r\n updateString(rscName: WorkspaceResourceName, val: string): void;\r\n\r\n /**\r\n * Remove a string resource.\r\n * @param rscName - The name of the string resource to remove.\r\n */\r\n removeString(rscName: WorkspaceResourceName): void;\r\n\r\n /**\r\n * Add a new binary resource to this WorkspaceDb.\r\n * @param rscName - The name of the blob resource.\r\n * @param val - The blob to save.\r\n * @throws if a blob resource named `rscName` already exists.\r\n */\r\n addBlob(rscName: WorkspaceResourceName, val: Uint8Array): void;\r\n\r\n /**\r\n * Update an existing blob resource with a new value, or add it if it does not exist.\r\n * @param rscName - The name of the blob resource.\r\n * @param val - The new value.\r\n */\r\n updateBlob(rscName: WorkspaceResourceName, val: Uint8Array): void;\r\n\r\n /**\r\n * Get a BlobIO writer for a previously-added blob WorkspaceResource.\r\n * @param rscName - The name of the blob resource.\r\n * @returns A BlobIO writer.\r\n * @note After writing is complete, the caller must call `close` on the BlobIO and must call `saveChanges` on the `db`.\r\n * @internal\r\n */\r\n getBlobWriter(rscName: WorkspaceResourceName): SQLiteDb.BlobIO;\r\n\r\n /**\r\n * Remove a binary resource.\r\n * @param rscName - The name of the blob resource to remove.\r\n */\r\n removeBlob(rscName: WorkspaceResourceName): void;\r\n\r\n /**\r\n * Copy the contents of an existing local file into this WorkspaceDb as a file resource.\r\n * @param rscName - The name of the file resource.\r\n * @param localFileName - The name of a local file to be read.\r\n * @param fileExt - The extension to be appended to the generated fileName when this WorkspaceDb is extracted from the WorkspaceDb.\r\n * By default, the characters after the last \".\" in `localFileName` are used. Pass this argument to override that.\r\n */\r\n addFile(rscName: WorkspaceResourceName, localFileName: LocalFileName, fileExt?: string): void;\r\n\r\n /**\r\n * Replace an existing file resource with the contents of another local file.\r\n * @param rscName - The name of the file resource.\r\n * @param localFileName - The name of a local file to be read.\r\n * @throws If the file resource does not exist.\r\n */\r\n updateFile(rscName: WorkspaceResourceName, localFileName: LocalFileName): void;\r\n\r\n /**\r\n * Remove a file resource.\r\n * @param rscName - The name of the file resource to remove.\r\n */\r\n removeFile(rscName: WorkspaceResourceName): void;\r\n}\r\n\r\n/** An object that permits administrators to modify the contents of a [[Workspace]].\r\n * Use [[WorkspaceEditor.construct]] to obtain a WorkspaceEditor, and [[close]] when finished using it.\r\n * Only one WorkspaceEditor may be in use at any given time.\r\n * Use [[getContainer]] to edit an existing [[WorkspaceContainer]], or [[createNewCloudContainer]] to create a new [[WorkspaceContainer]].\r\n * @beta\r\n */\r\nexport interface WorkspaceEditor {\r\n /** @internal */\r\n [implementationProhibited]: unknown;\r\n\r\n /**\r\n * The workspace dedicated to this editor.\r\n * @note This workspace is independent from [[IModelHost.appWorkspace]] and all [[IModelDb.workspace]]s. It has its own [[Settings]] and [[WorkspaceDb]]s.\r\n */\r\n readonly workspace: Workspace;\r\n\r\n /**\r\n * Retrieves a container for the editor with the specified properties and access token.\r\n */\r\n getContainer(args: GetWorkspaceContainerArgs): EditableWorkspaceContainer;\r\n\r\n /**\r\n * Asynchronously retrieves a container for the editor with the specified properties.\r\n */\r\n getContainerAsync(props: WorkspaceContainerProps): Promise<EditableWorkspaceContainer>;\r\n\r\n /**\r\n * Creates a new cloud container for holding WorkspaceDbs, from the [[BlobContainer]] service.\r\n * @note The current user must have administrator rights for the iTwin for the container.\r\n */\r\n createNewCloudContainer(args: CreateNewWorkspaceContainerArgs): Promise<EditableWorkspaceContainer>;\r\n\r\n /**\r\n * Closes this editor. All [[workspace]] containers are dropped.\r\n */\r\n close(): void;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"WorkspaceEditor.js","sourceRoot":"","sources":["../../../src/workspace/WorkspaceEditor.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAUH,+EAA4E;AAC5E,uEAA+E;AAC/E,iDAAgE;AAEhE,YAAY;AACZ,IAAiB,eAAe,CAgB/B;AAhBD,WAAiB,eAAe;IAC9B;;;;OAIG;IACH,SAAgB,SAAS;QACvB,OAAO,IAAA,wCAAwB,GAAE,CAAC;IACpC,CAAC;IAFe,yBAAS,YAExB,CAAA;IAED;;OAEG;IACH,SAAgB,aAAa,CAAC,IAAqE;QACjG,qCAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IAC1D,CAAC;IAFe,6BAAa,gBAE5B,CAAA;AACH,CAAC,EAhBgB,eAAe,+BAAf,eAAe,QAgB/B","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 Workspace\n */\n\nimport { LocalFileName } from \"@itwin/core-common\";\nimport { SQLiteDb } from \"../SQLiteDb\";\nimport { SettingsContainer } from \"./Settings\";\nimport { BlobContainer } from \"../BlobContainerService\";\nimport {\n GetWorkspaceContainerArgs, Workspace, WorkspaceContainer, WorkspaceContainerProps, WorkspaceDb, WorkspaceDbCloudProps, WorkspaceDbManifest, WorkspaceDbName, WorkspaceDbNameAndVersion,\n WorkspaceDbProps, WorkspaceDbVersion, WorkspaceResourceName,\n} from \"./Workspace\";\nimport { WorkspaceSqliteDb } from \"../internal/workspace/WorkspaceSqliteDb\";\nimport { constructWorkspaceEditor } from \"../internal/workspace/WorkspaceImpl\";\nimport { _implementationProhibited } from \"../internal/Symbols\";\n\n/** @beta */\nexport namespace WorkspaceEditor {\n /**\n * Create a new [[WorkspaceEditor]] for creating new versions of [[WorkspaceDb]]s.\n * @note the caller becomes the owner of the Workspace.Editor and is responsible for calling [[WorkspaceEditor.close]] on it when they are finished using it.\n * @note It is illegal to have more than one Workspace.Editor active in a single session.\n */\n export function construct(): WorkspaceEditor {\n return constructWorkspaceEditor();\n }\n\n /**\n * Create a new, empty, [[EditableWorkspaceDb]] file on the local filesystem for importing [[Workspace]] resources.\n */\n export function createEmptyDb(args: { localFileName: LocalFileName, manifest: WorkspaceDbManifest }): void {\n WorkspaceSqliteDb.createNewDb(args.localFileName, args);\n }\n}\n\n/** Arguments supplied to [[WorkspaceEditor.createNewCloudContainer]] to create a new [[EditableWorkspaceContainer]].\n * @beta\n */\nexport interface CreateNewWorkspaceContainerArgs {\n /**\n * The scope of the container. This determines the ownership of the container, how RBAC rights are assigned,\n * and the location of the datacenter\n */\n scope: BlobContainer.Scope;\n /** The manifest to be stored in the default WorkspaceDb in the new container. */\n manifest: WorkspaceDbManifest;\n /** Metadata stored by the BlobContainer service */\n metadata: Omit<BlobContainer.Metadata, \"containerType\">;\n /** The name of the default [[WorkspaceDb]] created inside the new container.\n * Default: \"workspace-db\";\n */\n dbName?: WorkspaceDbName;\n}\n\n/**\n * A [[WorkspaceContainer]] opened for editing by a [[WorkspaceEditor]].\n * You can create new [[WorkspaceDb]]s or new versions of existing [[WorkspaceDb]]s inside it.\n * Before actually making any changes to the container's contents, you must first obtain an exclusive write lock on it via\n * [[acquireWriteLock]]. Only one user can hold the write lock at any given time. When you have finished making changes,\n * you can use [[releaseWriteLock]] to publish your changes, or [[abandonChanges]] to discard them.\n * @beta\n */\nexport interface EditableWorkspaceContainer extends WorkspaceContainer {\n /**\n * Create a copy of an existing [[WorkspaceDb]] in this container with a new [[WorkspaceDbVersion]].\n * The copy should be modified with new content before the write lock is released,\n * and thereafter may never be modified again.\n * @note The copy actually shares all of the data with the original, but with copy-on-write if/when data in the new WorkspaceDb is modified.\n * @param props - The properties that determine the source WorkspaceDb to serve as the basis for the new version.\n * @returns A promise that resolves to an object containing the old and new WorkspaceDb names and versions.\n */\n createNewWorkspaceDbVersion(props: CreateNewWorkspaceDbVersionArgs): Promise<{ oldDb: WorkspaceDbNameAndVersion, newDb: WorkspaceDbNameAndVersion }>;\n\n /**\n * Create a new, empty [[WorkspaceDb]].\n * @param args - The arguments for creating the new WorkspaceDb.\n * @returns A promise that resolves to an EditableWorkspaceDb.\n */\n createDb(args: { dbName?: WorkspaceDbName, version?: WorkspaceDbVersion, manifest: WorkspaceDbManifest }): Promise<EditableWorkspaceDb>;\n\n /**\n * Get the cloud properties of this container.\n */\n readonly cloudProps: WorkspaceContainerProps | undefined;\n\n /**\n * Get an editable [[WorkspaceDb]] to add, delete, or update resources *within a newly created version* of a WorkspaceDb.\n * @param props - The properties of the WorkspaceDb.\n */\n getEditableDb(props: WorkspaceDbProps): EditableWorkspaceDb;\n\n /**\n * Acquire the write lock on the container. Use [[releaseWriteLock]] to release the lock after publishing your changes, or\n * [[abandonChanges]] to release the lock and discard your changes.\n * Only one use can hold the write lock at any given time. However, readers can continue to read the published contents of the container while\n * a writer holds the write lock. Readers will only see the writer's changes after they are published by [[releaseWriteLock]].\n * @param user - The name of the user acquiring the write lock.\n */\n acquireWriteLock(user: string): void;\n\n /**\n * Release the write lock on the container. This should be called after all changes to the container's contents are complete. It\n * publishes and uploads the changes made to any [[WorkspaceDb]]s while the lock was held, after which those dbs become immutable.\n */\n releaseWriteLock(): void;\n\n /**\n * Abandon any changes made to the container and release the write lock. Any newly created versions of WorkspaceDbs are discarded.\n */\n abandonChanges(): void;\n}\n\n/**\n * The release increment for a version number, used as part of [[CreateNewWorkspaceDbVersionArgs]] to specify the kind of version to create.\n * @see [semver.ReleaseType](https://www.npmjs.com/package/semver)\n * @beta\n */\nexport type WorkspaceDbVersionIncrement = \"major\" | \"minor\" | \"patch\" | \"premajor\" | \"preminor\" | \"prepatch\" | \"prerelease\";\n\n/**\n * Arguments supplied to [[Workspace.createNewWorkspaceDbVersion]].\n * @beta\n */\nexport interface CreateNewWorkspaceDbVersionArgs {\n /**\n * The properties that determine the source [[WorkspaceDb]] to serve as the basis for the new version.\n * This is usually the latest version, but it is possible to create patches to older versions.\n */\n fromProps?: WorkspaceDbProps;\n /** The type of version increment to apply to the source version. */\n versionType: WorkspaceDbVersionIncrement;\n /** For prerelease versions, a string that becomes part of the version name. */\n identifier?: string;\n}\n\n/**\n * An editable [[WorkspaceDb]]. This is used only by tools to allow administrators to create and modify WorkspaceDbs.\n * For cloud-based WorkspaceDbs, the container's write token must be obtained via [[EditableWorkspaceContainer.acquireWriteLock]] before the methods in this interface may be used.\n * Normally, only admins will have write access to a [[Workspace]].\n * Only one admin at a time may be editing a Workspace.\n * @beta\n */\nexport interface EditableWorkspaceDb extends WorkspaceDb {\n readonly container: EditableWorkspaceContainer;\n /**\n * The cloud properties of the [[WorkspaceDb]], if this is a cloud-based WorkspaceDb.\n */\n get cloudProps(): WorkspaceDbCloudProps | undefined;\n\n /**\n * Update the contents of the manifest in this WorkspaceDb.\n * @param manifest - The updated manifest.\n */\n updateManifest(manifest: WorkspaceDbManifest): void;\n\n /**\n * Add or update a resource in this WorkspaceDb that can be loaded as a [[SettingsDictionary]].\n * The `settings` will be stored as stringified JSON.\n * @param settings - The settings object to add or update.\n * @param rscName - The name of the settings resource. Defaults to \"settingsDictionary\" if undefined.\n */\n updateSettingsResource(settings: SettingsContainer, rscName?: string): void;\n\n /**\n * Add a new string resource to this WorkspaceDb.\n * @param rscName - The name of the string resource.\n * @param val - The string to save.\n * @throws if a string resource named `rscName` already exists.\n */\n addString(rscName: WorkspaceResourceName, val: string): void;\n\n /**\n * Update an existing string resource with a new value, or add it if it does not exist.\n * @param rscName - The name of the string resource.\n * @param val - The new value.\n */\n updateString(rscName: WorkspaceResourceName, val: string): void;\n\n /**\n * Remove a string resource.\n * @param rscName - The name of the string resource to remove.\n */\n removeString(rscName: WorkspaceResourceName): void;\n\n /**\n * Add a new binary resource to this WorkspaceDb.\n * @param rscName - The name of the blob resource.\n * @param val - The blob to save.\n * @throws if a blob resource named `rscName` already exists.\n */\n addBlob(rscName: WorkspaceResourceName, val: Uint8Array): void;\n\n /**\n * Update an existing blob resource with a new value, or add it if it does not exist.\n * @param rscName - The name of the blob resource.\n * @param val - The new value.\n */\n updateBlob(rscName: WorkspaceResourceName, val: Uint8Array): void;\n\n /**\n * Get a BlobIO writer for a previously-added blob WorkspaceResource.\n * @param rscName - The name of the blob resource.\n * @returns A BlobIO writer.\n * @note After writing is complete, the caller must call `close` on the BlobIO and must call `saveChanges` on the `db`.\n * @internal\n */\n getBlobWriter(rscName: WorkspaceResourceName): SQLiteDb.BlobIO;\n\n /**\n * Remove a binary resource.\n * @param rscName - The name of the blob resource to remove.\n */\n removeBlob(rscName: WorkspaceResourceName): void;\n\n /**\n * Copy the contents of an existing local file into this WorkspaceDb as a file resource.\n * @param rscName - The name of the file resource.\n * @param localFileName - The name of a local file to be read.\n * @param fileExt - The extension to be appended to the generated fileName when this WorkspaceDb is extracted from the WorkspaceDb.\n * By default, the characters after the last \".\" in `localFileName` are used. Pass this argument to override that.\n */\n addFile(rscName: WorkspaceResourceName, localFileName: LocalFileName, fileExt?: string): void;\n\n /**\n * Replace an existing file resource with the contents of another local file.\n * @param rscName - The name of the file resource.\n * @param localFileName - The name of a local file to be read.\n * @throws If the file resource does not exist.\n */\n updateFile(rscName: WorkspaceResourceName, localFileName: LocalFileName): void;\n\n /**\n * Remove a file resource.\n * @param rscName - The name of the file resource to remove.\n */\n removeFile(rscName: WorkspaceResourceName): void;\n}\n\n/** An object that permits administrators to modify the contents of a [[Workspace]].\n * Use [[WorkspaceEditor.construct]] to obtain a WorkspaceEditor, and [[close]] when finished using it.\n * Only one WorkspaceEditor may be in use at any given time.\n * Use [[getContainer]] to edit an existing [[WorkspaceContainer]], or [[createNewCloudContainer]] to create a new [[WorkspaceContainer]].\n * @beta\n */\nexport interface WorkspaceEditor {\n /** @internal */\n [_implementationProhibited]: unknown;\n\n /**\n * The workspace dedicated to this editor.\n * @note This workspace is independent from [[IModelHost.appWorkspace]] and all [[IModelDb.workspace]]s. It has its own [[Settings]] and [[WorkspaceDb]]s.\n */\n readonly workspace: Workspace;\n\n /**\n * Retrieves a container for the editor with the specified properties and access token.\n */\n getContainer(args: GetWorkspaceContainerArgs): EditableWorkspaceContainer;\n\n /**\n * Asynchronously retrieves a container for the editor with the specified properties.\n */\n getContainerAsync(props: WorkspaceContainerProps): Promise<EditableWorkspaceContainer>;\n\n /**\n * Creates a new cloud container for holding WorkspaceDbs, from the [[BlobContainer]] service.\n * @note The current user must have administrator rights for the iTwin for the container.\n */\n createNewCloudContainer(args: CreateNewWorkspaceContainerArgs): Promise<EditableWorkspaceContainer>;\n\n /**\n * Closes this editor. All [[workspace]] containers are dropped.\n */\n close(): void;\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.18",
|
|
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.18",
|
|
29
|
+
"@itwin/core-common": "^4.8.0-dev.18",
|
|
30
|
+
"@itwin/core-geometry": "^4.8.0-dev.18",
|
|
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-bentley": "4.8.0-dev.
|
|
74
|
-
"@itwin/core-common": "4.8.0-dev.
|
|
75
|
-
"@itwin/core-geometry": "4.8.0-dev.
|
|
76
|
-
"@itwin/ecsql-common": "4.8.0-dev.
|
|
77
|
-
"
|
|
78
|
-
"
|
|
72
|
+
"@itwin/build-tools": "4.8.0-dev.18",
|
|
73
|
+
"@itwin/core-bentley": "4.8.0-dev.18",
|
|
74
|
+
"@itwin/core-common": "4.8.0-dev.18",
|
|
75
|
+
"@itwin/core-geometry": "4.8.0-dev.18",
|
|
76
|
+
"@itwin/ecsql-common": "4.8.0-dev.18",
|
|
77
|
+
"@itwin/core-webpack-tools": "4.8.0-dev.18",
|
|
78
|
+
"internal-tools": "3.0.0-dev.69"
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@bentley/imodeljs-native": "4.8.
|
|
81
|
+
"@bentley/imodeljs-native": "4.8.17",
|
|
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.18"
|
|
96
96
|
},
|
|
97
97
|
"nyc": {
|
|
98
98
|
"extends": "./node_modules/@itwin/build-tools/.nycrc"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ServerBasedLocks.d.ts","sourceRoot":"","sources":["../../src/ServerBasedLocks.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAkB,OAAO,EAAE,UAAU,EAA0B,MAAM,qBAAqB,CAAC;AAClG,OAAO,EAAuB,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,UAAU,GAAG,SAAS,CAAC;CAC3C;AASD,gBAAgB;AAChB,qBAAa,gBAAiB,YAAW,WAAW;IAClD,IAAW,aAAa,YAAmB;IAC3C,SAAS,CAAC,QAAQ,CAAC,MAAM,WAAkB;IAC3C,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC;g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AAC,GAAG,CAAC,EAAE,EAAE,uBAAS,CAAC,SAAS,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,wGAAwG;IACjG,iBAAiB,CAAC,EAAc;QACrC,IAAI,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;AAlLD,4CAkLC","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 iModels\r\n */\r\n\r\nimport { DbResult, Id64, Id64Arg, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\r\nimport { IModel, IModelError, LockState } from \"@itwin/core-common\";\r\nimport { LockMap } from \"./BackendHubAccess\";\r\nimport { BriefcaseDb, LockControl } from \"./IModelDb\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { SQLiteDb } from \"./SQLiteDb\";\r\n\r\n/**\r\n * Both the Model and Parent of an element are considered \"owners\" of their member elements. That means:\r\n * 1) they must hold at least a shared lock before an exclusive lock can be acquired for their members\r\n * 2) if they hold an exclusive lock, then all of their members are exclusively locked implicitly.\r\n * @internal\r\n */\r\nexport interface ElementOwners {\r\n readonly modelId: Id64String;\r\n readonly parentId: Id64String | undefined;\r\n}\r\n\r\n// eslint-disable-next-line no-restricted-syntax\r\nconst enum LockOrigin {\r\n Acquired = 0,\r\n NewElement = 1,\r\n Discovered = 2,\r\n}\r\n\r\n/** @internal */\r\nexport class ServerBasedLocks implements LockControl {\r\n public get isServerBased() { return true; }\r\n protected readonly lockDb = new SQLiteDb();\r\n protected readonly briefcase: BriefcaseDb;\r\n\r\n public constructor(iModel: BriefcaseDb) {\r\n this.briefcase = iModel;\r\n const dbName = `${iModel.nativeDb.getTempFileBaseName()}-locks`;\r\n try {\r\n this.lockDb.openDb(dbName, OpenMode.ReadWrite);\r\n } catch (_e) {\r\n this.lockDb.createDb(dbName);\r\n this.lockDb.executeSQL(\"CREATE TABLE locks(id INTEGER PRIMARY KEY NOT NULL,state INTEGER NOT NULL,origin INTEGER)\");\r\n this.lockDb.saveChanges();\r\n }\r\n }\r\n\r\n public close() {\r\n if (this.lockDb.isOpen)\r\n this.lockDb.closeDb();\r\n }\r\n\r\n private getOwners(id: Id64String): ElementOwners {\r\n return this.briefcase.withPreparedSqliteStatement(\"SELECT ModelId,ParentId FROM bis_Element WHERE id=?\", (stmt) => {\r\n stmt.bindId(1, id);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_ROW !== rc)\r\n throw new IModelError(rc, `element ${id} not found`);\r\n\r\n return { modelId: stmt.getValueId(0), parentId: stmt.getValueId(1) };\r\n });\r\n }\r\n\r\n private getLockState(id?: Id64String): LockState | undefined {\r\n return (id === undefined || !Id64.isValid(id)) ? undefined : this.lockDb.withPreparedSqliteStatement(\"SELECT state FROM locks WHERE id=?\", (stmt) => {\r\n stmt.bindId(1, id);\r\n return (DbResult.BE_SQLITE_ROW === stmt.step()) ? stmt.getValueInteger(0) : undefined;\r\n });\r\n }\r\n\r\n /** Clear the cache of locally held locks.\r\n * Note: does *not* release locks from server.\r\n */\r\n private clearAllLocks() {\r\n this.lockDb.executeSQL(\"DELETE FROM locks\");\r\n this.lockDb.saveChanges();\r\n }\r\n\r\n /** only for tests */\r\n public getLockCount(state: LockState): number {\r\n return this.lockDb.withSqliteStatement(\"SELECT count(*) FROM locks WHERE state=?\", (stmt) => {\r\n stmt.bindInteger(1, state);\r\n stmt.step();\r\n return stmt.getValueInteger(0);\r\n });\r\n }\r\n\r\n public async releaseAllLocks(): Promise<void> {\r\n await IModelHost.hubAccess.releaseAllLocks(this.briefcase); // throws if unsuccessful\r\n this.clearAllLocks();\r\n }\r\n\r\n private insertLock(id: Id64String, state: LockState, origin: LockOrigin): true {\r\n this.lockDb.withPreparedSqliteStatement(\"INSERT INTO locks(id,state,origin) VALUES (?,?,?) ON CONFLICT(id) DO UPDATE SET state=excluded.state,origin=excluded.origin\", (stmt) => {\r\n stmt.bindId(1, id);\r\n stmt.bindInteger(2, state);\r\n stmt.bindInteger(3, origin);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n throw new IModelError(rc, \"can't insert lock into database\");\r\n });\r\n return true;\r\n }\r\n\r\n private ownerHoldsExclusiveLock(id: Id64String | undefined): boolean {\r\n if (id === undefined || id === IModel.rootSubjectId)\r\n return false; // has no owners\r\n\r\n const { modelId, parentId } = this.getOwners(id);\r\n if (this.getLockState(modelId) === LockState.Exclusive || this.getLockState(parentId) === LockState.Exclusive)\r\n return true;\r\n\r\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.\r\n if (this.ownerHoldsExclusiveLock(modelId))\r\n return this.insertLock(modelId, LockState.Exclusive, LockOrigin.Discovered);\r\n\r\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.\r\n return this.ownerHoldsExclusiveLock(parentId) ? this.insertLock(parentId!, LockState.Exclusive, LockOrigin.Discovered) : false; // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n }\r\n\r\n /** Determine whether an the exclusive lock is already held by an element (or one of its owners) */\r\n public holdsExclusiveLock(id: Id64String): boolean {\r\n // see if we hold the exclusive lock. or if one of the element's owners is exclusively locked (recursively)\r\n return this.getLockState(id) === LockState.Exclusive || this.ownerHoldsExclusiveLock(id);\r\n }\r\n\r\n public holdsSharedLock(id: Id64String): boolean {\r\n const state = this.getLockState(id);\r\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.\r\n return (state === LockState.Shared || state === LockState.Exclusive) || this.ownerHoldsExclusiveLock(id);\r\n }\r\n\r\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. */\r\n private addSharedLock(id: Id64String | undefined, locks: Set<Id64String>) {\r\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\r\n // Note: if we hold a shared lock, it is guaranteed that we also hold all required shared locks on owners.\r\n if (id === undefined || !Id64.isValid(id) || locks.has(id) || this.holdsSharedLock(id))\r\n return;\r\n\r\n locks.add(id); // add to set of needed shared locks\r\n this.addOwnerSharedLocks(id, locks); // check parent models and groups\r\n }\r\n\r\n /** add owners (recursively) of an element to a list of required shared locks, if not already held. */\r\n private addOwnerSharedLocks(id: Id64String, locks: Set<Id64String>) {\r\n const el = this.getOwners(id);\r\n this.addSharedLock(el.parentId, locks); // if this element is in a group\r\n this.addSharedLock(el.modelId, locks); // check its model\r\n }\r\n\r\n /** attempt to acquire all necessary locks for a set of elements */\r\n private async acquireAllLocks(locks: LockMap) {\r\n if (locks.size === 0) // no locks are required.\r\n return;\r\n\r\n const sharedLocks = new Set<Id64String>();\r\n for (const lock of locks)\r\n this.addOwnerSharedLocks(lock[0], sharedLocks);\r\n\r\n for (const shared of sharedLocks) {\r\n if (!locks.has(shared)) // we may already be asking for exclusive lock\r\n locks.set(shared, LockState.Shared);\r\n }\r\n\r\n await IModelHost.hubAccess.acquireLocks(this.briefcase, locks); // throws if unsuccessful\r\n for (const lock of locks)\r\n this.insertLock(lock[0], lock[1], LockOrigin.Acquired);\r\n this.lockDb.saveChanges();\r\n }\r\n\r\n public async acquireLocks(arg: { shared?: Id64Arg, exclusive?: Id64Arg }): Promise<void> {\r\n const locks = new Map<Id64String, LockState>();\r\n if (arg.shared) {\r\n for (const id of Id64.iterable(arg.shared)) {\r\n if (!this.holdsSharedLock(id))\r\n locks.set(id, LockState.Shared);\r\n }\r\n }\r\n if (arg.exclusive) {\r\n for (const id of Id64.iterable(arg.exclusive)) {\r\n if (!this.holdsExclusiveLock(id))\r\n locks.set(id, LockState.Exclusive);\r\n }\r\n }\r\n return this.acquireAllLocks(locks);\r\n }\r\n\r\n /** When an element is newly created in a session, we hold the lock on it implicitly. Save that fact. */\r\n public elementWasCreated(id: Id64String) {\r\n this.insertLock(id, LockState.Exclusive, LockOrigin.NewElement);\r\n this.lockDb.saveChanges();\r\n }\r\n\r\n /** locks are not necessary during change propagation. */\r\n private get _locksAreRequired() { return !this.briefcase.txns.isIndirectChanges; }\r\n\r\n /** throw if locks are currently required and the exclusive lock is not held on the supplied element */\r\n public checkExclusiveLock(id: Id64String, type: string, operation: string) {\r\n if (this._locksAreRequired && !this.holdsExclusiveLock(id))\r\n throw new IModelError(IModelStatus.LockNotHeld, `exclusive lock not held on ${type} for ${operation} (id=${id})`);\r\n }\r\n\r\n /** throw if locks are currently required and a shared lock is not held on the supplied element */\r\n public checkSharedLock(id: Id64String, type: string, operation: string) {\r\n if (this._locksAreRequired && !this.holdsSharedLock(id))\r\n throw new IModelError(IModelStatus.LockNotHeld, `shared lock not held on ${type} for ${operation} (id=${id})`);\r\n }\r\n\r\n}\r\n\r\n"]}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module Workspace
|
|
3
|
-
*/
|
|
4
|
-
/** A symbol used to prevent implementations of an interface from being created outside of the package that defines the interface.
|
|
5
|
-
* This is useful when a package defines a public interface with one or more private implementations.
|
|
6
|
-
* The only way for users of the package to obtain an implementation of the interface is by calling a method in the package's public API that returns one.
|
|
7
|
-
* It permits the package to add new required properties and methods to the interface without breaking API compatibility, because no one
|
|
8
|
-
* else can possibly have created their own implementations lacking those new properties or methods.
|
|
9
|
-
*
|
|
10
|
-
* Simple example:
|
|
11
|
-
* ```ts
|
|
12
|
-
* // @public
|
|
13
|
-
* interface Thing {
|
|
14
|
-
* name: string;
|
|
15
|
-
* [implementationProhibited]: unknown;
|
|
16
|
-
* }
|
|
17
|
-
*
|
|
18
|
-
* // Not exported
|
|
19
|
-
* class ThingImpl implements Thing {
|
|
20
|
-
* constructor(public name: string) { }
|
|
21
|
-
* public readonly [implementationProhibited] = undefined;
|
|
22
|
-
* }
|
|
23
|
-
*
|
|
24
|
-
* // @public
|
|
25
|
-
* export function getThing(name: string): Thing { return new ThingImpl(name); }
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* This effectively turns the interface into a nominal type, bypassing TypeScript's structural typing.
|
|
29
|
-
* If someone attempts to supply their own implementation of `Thing`:
|
|
30
|
-
*
|
|
31
|
-
* ```ts
|
|
32
|
-
* const thing: Thing = { name: "my thing" };
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* ...they will receive a compiler error. Because they cannot access the `implementationProhibited` symbol,
|
|
36
|
-
* they will not be able to appease the compiler except by casting to `any`.
|
|
37
|
-
*
|
|
38
|
-
* Of course, you must make sure not to export the symbol from the package - that would defeat the whole purpose.
|
|
39
|
-
* It is exported here from the internal API for consumption inside the package only. It is not exported from the package's barrel file.
|
|
40
|
-
*
|
|
41
|
-
* The vast majority of interfaces do not need this.
|
|
42
|
-
*/
|
|
43
|
-
export declare const implementationProhibited: unique symbol;
|
|
44
|
-
//# sourceMappingURL=ImplementationProhibited.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ImplementationProhibited.d.ts","sourceRoot":"","sources":["../../../src/internal/ImplementationProhibited.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,wBAAwB,eAAsC,CAAC"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
/** @packageDocumentation
|
|
7
|
-
* @module Workspace
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.implementationProhibited = void 0;
|
|
11
|
-
/** A symbol used to prevent implementations of an interface from being created outside of the package that defines the interface.
|
|
12
|
-
* This is useful when a package defines a public interface with one or more private implementations.
|
|
13
|
-
* The only way for users of the package to obtain an implementation of the interface is by calling a method in the package's public API that returns one.
|
|
14
|
-
* It permits the package to add new required properties and methods to the interface without breaking API compatibility, because no one
|
|
15
|
-
* else can possibly have created their own implementations lacking those new properties or methods.
|
|
16
|
-
*
|
|
17
|
-
* Simple example:
|
|
18
|
-
* ```ts
|
|
19
|
-
* // @public
|
|
20
|
-
* interface Thing {
|
|
21
|
-
* name: string;
|
|
22
|
-
* [implementationProhibited]: unknown;
|
|
23
|
-
* }
|
|
24
|
-
*
|
|
25
|
-
* // Not exported
|
|
26
|
-
* class ThingImpl implements Thing {
|
|
27
|
-
* constructor(public name: string) { }
|
|
28
|
-
* public readonly [implementationProhibited] = undefined;
|
|
29
|
-
* }
|
|
30
|
-
*
|
|
31
|
-
* // @public
|
|
32
|
-
* export function getThing(name: string): Thing { return new ThingImpl(name); }
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* This effectively turns the interface into a nominal type, bypassing TypeScript's structural typing.
|
|
36
|
-
* If someone attempts to supply their own implementation of `Thing`:
|
|
37
|
-
*
|
|
38
|
-
* ```ts
|
|
39
|
-
* const thing: Thing = { name: "my thing" };
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* ...they will receive a compiler error. Because they cannot access the `implementationProhibited` symbol,
|
|
43
|
-
* they will not be able to appease the compiler except by casting to `any`.
|
|
44
|
-
*
|
|
45
|
-
* Of course, you must make sure not to export the symbol from the package - that would defeat the whole purpose.
|
|
46
|
-
* It is exported here from the internal API for consumption inside the package only. It is not exported from the package's barrel file.
|
|
47
|
-
*
|
|
48
|
-
* The vast majority of interfaces do not need this.
|
|
49
|
-
*/
|
|
50
|
-
exports.implementationProhibited = Symbol("implementation prohibited");
|
|
51
|
-
//# sourceMappingURL=ImplementationProhibited.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ImplementationProhibited.js","sourceRoot":"","sources":["../../../src/internal/ImplementationProhibited.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACU,QAAA,wBAAwB,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Workspace\r\n */\r\n\r\n/** A symbol used to prevent implementations of an interface from being created outside of the package that defines the interface.\r\n * This is useful when a package defines a public interface with one or more private implementations.\r\n * The only way for users of the package to obtain an implementation of the interface is by calling a method in the package's public API that returns one.\r\n * It permits the package to add new required properties and methods to the interface without breaking API compatibility, because no one\r\n * else can possibly have created their own implementations lacking those new properties or methods.\r\n *\r\n * Simple example:\r\n * ```ts\r\n * // @public\r\n * interface Thing {\r\n * name: string;\r\n * [implementationProhibited]: unknown;\r\n * }\r\n *\r\n * // Not exported\r\n * class ThingImpl implements Thing {\r\n * constructor(public name: string) { }\r\n * public readonly [implementationProhibited] = undefined;\r\n * }\r\n *\r\n * // @public\r\n * export function getThing(name: string): Thing { return new ThingImpl(name); }\r\n * ```\r\n *\r\n * This effectively turns the interface into a nominal type, bypassing TypeScript's structural typing.\r\n * If someone attempts to supply their own implementation of `Thing`:\r\n *\r\n * ```ts\r\n * const thing: Thing = { name: \"my thing\" };\r\n * ```\r\n *\r\n * ...they will receive a compiler error. Because they cannot access the `implementationProhibited` symbol,\r\n * they will not be able to appease the compiler except by casting to `any`.\r\n *\r\n * Of course, you must make sure not to export the symbol from the package - that would defeat the whole purpose.\r\n * It is exported here from the internal API for consumption inside the package only. It is not exported from the package's barrel file.\r\n *\r\n * The vast majority of interfaces do not need this.\r\n */\r\nexport const implementationProhibited = Symbol(\"implementation prohibited\");\r\n"]}
|