@itwin/core-backend 5.0.0-dev.97 → 5.0.0-dev.99
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.d.ts +2 -8
- package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +12 -5
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +1 -0
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/CheckpointManager.d.ts +8 -15
- package/lib/cjs/CheckpointManager.d.ts.map +1 -1
- package/lib/cjs/CheckpointManager.js +23 -54
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ECDb.d.ts +37 -1
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +81 -0
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSqlStatement.d.ts +181 -2
- package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
- package/lib/cjs/ECSqlStatement.js +224 -5
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.d.ts +16 -4
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +40 -2
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.d.ts.map +1 -1
- package/lib/cjs/ElementAspect.js +1 -0
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
- package/lib/cjs/ElementTreeWalker.js +4 -0
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/HubMock.d.ts +1 -1
- package/lib/cjs/HubMock.d.ts.map +1 -1
- package/lib/cjs/HubMock.js +13 -2
- package/lib/cjs/HubMock.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +4 -0
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +33 -3
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +2 -0
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/ViewStore.d.ts.map +1 -1
- package/lib/cjs/ViewStore.js +2 -1
- package/lib/cjs/ViewStore.js.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.d.ts.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.js +2 -0
- package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
- package/lib/cjs/internal/Symbols.d.ts +2 -0
- package/lib/cjs/internal/Symbols.d.ts.map +1 -1
- package/lib/cjs/internal/Symbols.js +3 -1
- package/lib/cjs/internal/Symbols.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +1 -0
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +11 -22
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/esm/BackendHubAccess.d.ts +2 -8
- package/lib/esm/BackendHubAccess.d.ts.map +1 -1
- package/lib/esm/BackendHubAccess.js.map +1 -1
- package/lib/esm/ChangeSummaryManager.d.ts.map +1 -1
- package/lib/esm/ChangeSummaryManager.js +12 -5
- package/lib/esm/ChangeSummaryManager.js.map +1 -1
- package/lib/esm/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/esm/ChangesetECAdaptor.js +1 -0
- package/lib/esm/ChangesetECAdaptor.js.map +1 -1
- package/lib/esm/CheckpointManager.d.ts +8 -15
- package/lib/esm/CheckpointManager.d.ts.map +1 -1
- package/lib/esm/CheckpointManager.js +22 -52
- package/lib/esm/CheckpointManager.js.map +1 -1
- package/lib/esm/ECDb.d.ts +37 -1
- package/lib/esm/ECDb.d.ts.map +1 -1
- package/lib/esm/ECDb.js +82 -1
- package/lib/esm/ECDb.js.map +1 -1
- package/lib/esm/ECSqlStatement.d.ts +181 -2
- package/lib/esm/ECSqlStatement.d.ts.map +1 -1
- package/lib/esm/ECSqlStatement.js +222 -4
- package/lib/esm/ECSqlStatement.js.map +1 -1
- package/lib/esm/Element.d.ts +16 -4
- package/lib/esm/Element.d.ts.map +1 -1
- package/lib/esm/Element.js +40 -2
- package/lib/esm/Element.js.map +1 -1
- package/lib/esm/ElementAspect.d.ts.map +1 -1
- package/lib/esm/ElementAspect.js +1 -0
- package/lib/esm/ElementAspect.js.map +1 -1
- package/lib/esm/ElementTreeWalker.d.ts.map +1 -1
- package/lib/esm/ElementTreeWalker.js +4 -0
- package/lib/esm/ElementTreeWalker.js.map +1 -1
- package/lib/esm/HubMock.d.ts +1 -1
- package/lib/esm/HubMock.d.ts.map +1 -1
- package/lib/esm/HubMock.js +13 -2
- package/lib/esm/HubMock.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +4 -0
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +33 -3
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/Relationship.d.ts.map +1 -1
- package/lib/esm/Relationship.js +2 -0
- package/lib/esm/Relationship.js.map +1 -1
- package/lib/esm/ViewStore.d.ts.map +1 -1
- package/lib/esm/ViewStore.js +2 -1
- package/lib/esm/ViewStore.js.map +1 -1
- package/lib/esm/internal/ChannelAdmin.d.ts.map +1 -1
- package/lib/esm/internal/ChannelAdmin.js +2 -0
- package/lib/esm/internal/ChannelAdmin.js.map +1 -1
- package/lib/esm/internal/Symbols.d.ts +2 -0
- package/lib/esm/internal/Symbols.d.ts.map +1 -1
- package/lib/esm/internal/Symbols.js +2 -0
- package/lib/esm/internal/Symbols.js.map +1 -1
- package/lib/esm/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/esm/rpc-impl/IModelReadRpcImpl.js +1 -0
- package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/esm/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
- package/lib/esm/rpc-impl/RpcBriefcaseUtility.js +13 -24
- package/lib/esm/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/esm/test/CloudSqliteMock.d.ts +37 -0
- package/lib/esm/test/CloudSqliteMock.d.ts.map +1 -0
- package/lib/esm/test/CloudSqliteMock.js +117 -0
- package/lib/esm/test/CloudSqliteMock.js.map +1 -0
- package/lib/esm/test/IModelTestUtils.d.ts +1 -1
- package/lib/esm/test/IModelTestUtils.d.ts.map +1 -1
- package/lib/esm/test/IModelTestUtils.js +16 -4
- package/lib/esm/test/IModelTestUtils.js.map +1 -1
- package/lib/esm/test/PrintElementTree.js +1 -0
- package/lib/esm/test/PrintElementTree.js.map +1 -1
- package/lib/esm/test/SchemaUtils.test.js +2 -0
- package/lib/esm/test/SchemaUtils.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECDb.test.js +12 -1
- package/lib/esm/test/ecdb/ECDb.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlAst.test.js +1 -0
- package/lib/esm/test/ecdb/ECSqlAst.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlQuery.test.js +6 -0
- package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlReader.test.js +1 -1
- package/lib/esm/test/ecdb/ECSqlReader.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlStatement.test.js +253 -163
- package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
- package/lib/esm/test/ecdb/SqliteStatement.test.js +2 -0
- package/lib/esm/test/ecdb/SqliteStatement.test.js.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestGenerator.js +1 -0
- package/lib/esm/test/ecsql/src/ECSqlTestGenerator.js.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js +5 -1
- package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
- package/lib/esm/test/element/ElementRoundTrip.test.js +10 -0
- package/lib/esm/test/element/ElementRoundTrip.test.js.map +1 -1
- package/lib/esm/test/font/IModelDbFonts.test.js +3 -1
- package/lib/esm/test/font/IModelDbFonts.test.js.map +1 -1
- package/lib/esm/test/hubaccess/BriefcaseManager.test.js +18 -7
- package/lib/esm/test/hubaccess/BriefcaseManager.test.js.map +1 -1
- package/lib/esm/test/hubaccess/CheckpointManager.test.js +5 -91
- package/lib/esm/test/hubaccess/CheckpointManager.test.js.map +1 -1
- package/lib/esm/test/imodel/ElementTreeWalker.test.js +1 -0
- package/lib/esm/test/imodel/ElementTreeWalker.test.js.map +1 -1
- package/lib/esm/test/imodel/IModel.test.js +14 -0
- package/lib/esm/test/imodel/IModel.test.js.map +1 -1
- package/lib/esm/test/schema/GenericDomain.test.js +1 -0
- package/lib/esm/test/schema/GenericDomain.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangeMerge.test.js +0 -4
- package/lib/esm/test/standalone/ChangeMerge.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangesetReader.test.js +1 -0
- package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
- package/lib/esm/test/standalone/Drawing.test.d.ts +2 -0
- package/lib/esm/test/standalone/Drawing.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/Drawing.test.js +120 -0
- package/lib/esm/test/standalone/Drawing.test.js.map +1 -0
- package/lib/esm/test/standalone/IModelWrite.test.js +22 -6
- package/lib/esm/test/standalone/IModelWrite.test.js.map +1 -1
- package/lib/esm/test/standalone/RenderMaterialElement.test.js +1 -0
- package/lib/esm/test/standalone/RenderMaterialElement.test.js.map +1 -1
- package/lib/esm/test/standalone/SnapshotDb.test.js +4 -3
- package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
- package/package.json +13 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementAspect.js","sourceRoot":"","sources":["../../src/ElementAspect.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAA+I;AAC/I,qCAAkC;AAGlC,sDAA2D;AAC3D,gDAAoD;AA0BpD;;;;GAIG;AACH,MAAa,aAAc,SAAQ,eAAM;IAChC,MAAM,KAAc,SAAS,KAAa,OAAO,eAAe,CAAC,CAAC,CAAC;IACnE,OAAO,CAAiB;IAE/B,kFAAkF;IAClF,YAAY,KAAyB,EAAE,MAAgB;QACrD,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,4BAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAE,CAAC,CAAC,+DAA+D;IACzH,CAAC;IAEe,MAAM;QACpB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAwB,CAAC;QACjD,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC3B,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;OAIG;IACO,MAAM,CAAC,QAAQ,CAAC,GAAqB;QAC7C,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;QAC9B,MAAM,CAAC,QAAQ,CAAC,wBAAc,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3C,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;IAChF,CAAC;IAED;;;OAGG;IACO,MAAM,CAAC,UAAU,CAAC,IAAsB,IAAU,CAAC;IAE7D;;;;OAIG;IACO,MAAM,CAAC,QAAQ,CAAC,GAAqB;QAC7C,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,GAA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,CAAC,YAAY,CAAC,CAAC;QACxC,IAAI,IAAI,CAAC,KAAK;YACZ,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACzC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACzC,IAAI,IAAI,CAAC,MAAM;YACb,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC;CACF;AArFD,oDAqFC;AAED,cAAc;AACd,WAAiB,oBAAoB;IACnC;;OAEG;IACH,IAAY,IASX;IATD,WAAY,IAAI;QACd,oFAAoF;QACpF,2BAAmB,CAAA;QACnB,yFAAyF;QACzF,qCAA6B,CAAA;QAC7B;;WAEG;QACH,uBAAe,CAAA;IACjB,CAAC,EATW,IAAI,GAAJ,yBAAI,KAAJ,yBAAI,QASf;AACH,CAAC,EAdgB,oBAAoB,oCAApB,oBAAoB,QAcpC","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 ElementAspects\n */\n\nimport { ChannelRootAspectProps, ElementAspectProps, EntityReferenceSet, ExternalSourceAspectProps, RelatedElement } from \"@itwin/core-common\";\nimport { Entity } from \"./Entity\";\nimport { IModelDb } from \"./IModelDb\";\nimport { ECSqlStatement } from \"./ECSqlStatement\";\nimport { DbResult, Id64String } from \"@itwin/core-bentley\";\nimport { _verifyChannel } from \"./internal/Symbols\";\n\n/** Argument for the `ElementAspect.onXxx` static methods\n * @beta\n */\nexport interface OnAspectArg {\n /** The iModel for the aspect affected by this event. */\n iModel: IModelDb;\n /** The model for the aspect affected by this event */\n model: Id64String;\n}\n/** Argument for the `ElementAspect.onXxx` static methods that supply the properties of an aspect to be inserted or updated.\n * @beta\n */\nexport interface OnAspectPropsArg extends OnAspectArg {\n /** The new properties of the aspect affected by this event. */\n props: Readonly<ElementAspectProps>;\n}\n/** Argument for the `ElementAspect.onXxx` static methods that only supply the Id of the affected aspect.\n * @beta\n */\nexport interface OnAspectIdArg extends OnAspectArg {\n /** The Id of the aspect affected by this event */\n aspectId: Id64String;\n}\n\n/** An Element Aspect is a class that defines a set of properties that are related to (and owned by) a single element.\n * Semantically, an ElementAspect can be considered part of the Element. Thus, an ElementAspect is deleted if its owning Element is deleted.\n * BIS Guideline: Subclass ElementUniqueAspect or ElementMultiAspect rather than subclassing ElementAspect directly.\n * @public\n */\nexport class ElementAspect extends Entity {\n public static override get className(): string { return \"ElementAspect\"; }\n public element: RelatedElement;\n\n /** Construct an aspect from its JSON representation and its containing iModel. */\n constructor(props: ElementAspectProps, iModel: IModelDb) {\n super(props, iModel);\n this.element = RelatedElement.fromJSON(props.element)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n }\n\n public override toJSON(): ElementAspectProps {\n const val = super.toJSON() as ElementAspectProps;\n val.element = this.element;\n return val;\n }\n\n /** Called before a new ElementAspect is inserted.\n * @note throw an exception to disallow the insert\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onInsert(arg: OnAspectPropsArg): void {\n const { props, iModel } = arg;\n iModel.channels[_verifyChannel](arg.model);\n iModel.locks.checkExclusiveLock(props.element.id, \"element\", \"insert aspect\");\n }\n\n /** Called after a new ElementAspect was inserted.\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onInserted(_arg: OnAspectPropsArg): void { }\n\n /** Called before an ElementAspect is updated.\n * @note throw an exception to disallow the update\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onUpdate(arg: OnAspectPropsArg): void {\n const { props, iModel } = arg;\n iModel.channels[_verifyChannel](arg.model);\n iModel.locks.checkExclusiveLock(props.element.id, \"element\", \"update aspect\");\n }\n\n /** Called after an ElementAspect was updated.\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onUpdated(_arg: OnAspectPropsArg): void { }\n\n /** Called before an ElementAspect is deleted.\n * @note throw an exception to disallow the delete\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onDelete(arg: OnAspectIdArg): void {\n const { aspectId, iModel } = arg;\n iModel.channels[_verifyChannel](arg.model);\n const { element } = iModel.elements.getAspect(aspectId);\n iModel.locks.checkExclusiveLock(element.id, \"element\", \"delete aspect\");\n }\n\n /** Called after an ElementAspect was deleted.\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onDeleted(_arg: OnAspectIdArg): void { }\n}\n/** An Element Unique Aspect is an ElementAspect where there can be only zero or one instance of the Element Aspect class per Element.\n * @public\n */\nexport class ElementUniqueAspect extends ElementAspect {\n public static override get className(): string { return \"ElementUniqueAspect\"; }\n}\n\n/** An Element Multi-Aspect is an ElementAspect where there can be **n** instances of the Element Aspect class per Element.\n * @public\n */\nexport class ElementMultiAspect extends ElementAspect {\n public static override get className(): string { return \"ElementMultiAspect\"; }\n}\n\n/**\n * @public\n */\nexport class ChannelRootAspect extends ElementUniqueAspect {\n public static override get className(): string { return \"ChannelRootAspect\"; }\n /** Insert a ChannelRootAspect on the specified element.\n * @deprecated in 4.0 use [[ChannelControl.makeChannelRoot]]. This method does not enforce the rule that channels may not nest and is therefore dangerous.\n */\n public static insert(iModel: IModelDb, ownerId: Id64String, channelName: string) {\n const props: ChannelRootAspectProps = { classFullName: this.classFullName, element: { id: ownerId }, owner: channelName };\n iModel.elements.insertAspect(props);\n }\n}\n\n/** An ElementMultiAspect that stores synchronization information for an Element originating from an external source.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.2\n * @public\n */\nexport class ExternalSourceAspect extends ElementMultiAspect {\n public static override get className(): string { return \"ExternalSourceAspect\"; }\n\n /** An element that scopes the combination of `kind` and `identifier` to uniquely identify the object from the external source.\n * @note Warning: in a future major release the `scope` property will be optional, since the scope is intended to be potentially invalid.\n * all references should treat it as potentially undefined, but we cannot change the type yet since that is a breaking change.\n */\n public scope: RelatedElement;\n /** The identifier of the object in the source repository. */\n public identifier: string;\n /** The kind of object within the source repository. */\n public kind: string;\n /** The cryptographic hash (any algorithm) of the source object's content. If defined, it must be guaranteed to change when the source object's content changes. */\n public checksum?: string;\n /** An optional value that is typically a version number or a pseudo version number like last modified time.\n * It will be used by the synchronization process to detect that a source object is unchanged so that computing a cryptographic hash can be avoided.\n * If present, this value must be guaranteed to change when any of the source object's content changes.\n */\n public version?: string;\n /** A place where additional JSON properties can be stored. For example, provenance information or properties relating to the synchronization process.\n * @note Warning: in a future major release, the type of `jsonProperties` will be changed to object, and itwin.js will automatically stringify it when writing to the iModel.\n * This will be a breaking change, since application code will have to change from supplying a string to supplying an object.\n */\n public jsonProperties?: string;\n /** The source of the imported/synchronized object. Should point to an instance of [ExternalSource]($backend). */\n public source?: RelatedElement;\n\n /** Construct an aspect from its JSON representation and its containing iModel. */\n constructor(props: ExternalSourceAspectProps, iModel: IModelDb) {\n super(props, iModel);\n this.scope = RelatedElement.fromJSON(props.scope)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n this.source = RelatedElement.fromJSON(props.source);\n this.identifier = props.identifier;\n this.kind = props.kind;\n this.checksum = props.checksum;\n this.version = props.version;\n this.jsonProperties = props.jsonProperties;\n }\n\n /** Look up the elements that contain one or more ExternalSourceAspect with the specified Scope, Kind, and Identifier.\n * The result of this function is an array of all of the ExternalSourceAspects that were found, each associated with the owning element.\n * A given element could have more than one ExternalSourceAspect with the given scope, kind, and identifier.\n * Also, many elements could have ExternalSourceAspect with the same scope, kind, and identifier.\n * Therefore, the result array could have more than one entry with the same elementId.\n * Aspects are never shared. Each aspect has its own unique ECInstanceId.\n * @param iModelDb The iModel to query\n * @param scope The scope of the ExternalSourceAspects to find\n * @param kind The kind of the ExternalSourceAspects to find\n * @param identifier The identifier of the ExternalSourceAspects to find\n * @returns the query results\n */\n public static findAllBySource(iModelDb: IModelDb, scope: Id64String, kind: string, identifier: string): Array<{ elementId: Id64String, aspectId: Id64String }> {\n const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;\n const found: Array<{ elementId: Id64String, aspectId: Id64String }> = [];\n iModelDb.withPreparedStatement(sql, (statement: ECSqlStatement) => {\n statement.bindId(\"scope\", scope);\n statement.bindString(\"kind\", kind);\n statement.bindString(\"identifier\", identifier);\n while (DbResult.BE_SQLITE_ROW === statement.step()) {\n found.push({ elementId: statement.getValue(0).getId(), aspectId: statement.getValue(1).getId() });\n }\n });\n return found;\n }\n\n public override toJSON(): ExternalSourceAspectProps {\n const val = super.toJSON() as ExternalSourceAspectProps;\n val.scope = this.scope;\n val.source = this.source;\n val.identifier = this.identifier;\n val.kind = this.kind;\n val.checksum = this.checksum;\n val.version = this.version;\n val.jsonProperties = this.jsonProperties;\n return val;\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n if (this.scope)\n referenceIds.addElement(this.scope.id);\n referenceIds.addElement(this.element.id);\n if (this.source)\n referenceIds.addElement(this.source.id);\n }\n}\n\n/** @public */\nexport namespace ExternalSourceAspect {\n /** Standard values for the `Kind` property of `ExternalSourceAspect`.\n * @public\n */\n export enum Kind {\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Element]] provenance */\n Element = \"Element\",\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Relationship]] provenance */\n Relationship = \"Relationship\",\n /** Indicates that the [[ExternalSourceAspect]] is storing *scope* provenance\n * @see [[ExternalSourceAspect.scope]]\n */\n Scope = \"Scope\",\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ElementAspect.js","sourceRoot":"","sources":["../../src/ElementAspect.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAA+I;AAC/I,qCAAkC;AAGlC,sDAA2D;AAC3D,gDAAoD;AA0BpD;;;;GAIG;AACH,MAAa,aAAc,SAAQ,eAAM;IAChC,MAAM,KAAc,SAAS,KAAa,OAAO,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AAtFD,oDAsFC;AAED,cAAc;AACd,WAAiB,oBAAoB;IACnC;;OAEG;IACH,IAAY,IASX;IATD,WAAY,IAAI;QACd,oFAAoF;QACpF,2BAAmB,CAAA;QACnB,yFAAyF;QACzF,qCAA6B,CAAA;QAC7B;;WAEG;QACH,uBAAe,CAAA;IACjB,CAAC,EATW,IAAI,GAAJ,yBAAI,KAAJ,yBAAI,QASf;AACH,CAAC,EAdgB,oBAAoB,oCAApB,oBAAoB,QAcpC","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 ElementAspects\n */\n\nimport { ChannelRootAspectProps, ElementAspectProps, EntityReferenceSet, ExternalSourceAspectProps, RelatedElement } from \"@itwin/core-common\";\nimport { Entity } from \"./Entity\";\nimport { IModelDb } from \"./IModelDb\";\nimport { ECSqlStatement } from \"./ECSqlStatement\";\nimport { DbResult, Id64String } from \"@itwin/core-bentley\";\nimport { _verifyChannel } from \"./internal/Symbols\";\n\n/** Argument for the `ElementAspect.onXxx` static methods\n * @beta\n */\nexport interface OnAspectArg {\n /** The iModel for the aspect affected by this event. */\n iModel: IModelDb;\n /** The model for the aspect affected by this event */\n model: Id64String;\n}\n/** Argument for the `ElementAspect.onXxx` static methods that supply the properties of an aspect to be inserted or updated.\n * @beta\n */\nexport interface OnAspectPropsArg extends OnAspectArg {\n /** The new properties of the aspect affected by this event. */\n props: Readonly<ElementAspectProps>;\n}\n/** Argument for the `ElementAspect.onXxx` static methods that only supply the Id of the affected aspect.\n * @beta\n */\nexport interface OnAspectIdArg extends OnAspectArg {\n /** The Id of the aspect affected by this event */\n aspectId: Id64String;\n}\n\n/** An Element Aspect is a class that defines a set of properties that are related to (and owned by) a single element.\n * Semantically, an ElementAspect can be considered part of the Element. Thus, an ElementAspect is deleted if its owning Element is deleted.\n * BIS Guideline: Subclass ElementUniqueAspect or ElementMultiAspect rather than subclassing ElementAspect directly.\n * @public\n */\nexport class ElementAspect extends Entity {\n public static override get className(): string { return \"ElementAspect\"; }\n public element: RelatedElement;\n\n /** Construct an aspect from its JSON representation and its containing iModel. */\n constructor(props: ElementAspectProps, iModel: IModelDb) {\n super(props, iModel);\n this.element = RelatedElement.fromJSON(props.element)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n }\n\n public override toJSON(): ElementAspectProps {\n const val = super.toJSON() as ElementAspectProps;\n val.element = this.element;\n return val;\n }\n\n /** Called before a new ElementAspect is inserted.\n * @note throw an exception to disallow the insert\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onInsert(arg: OnAspectPropsArg): void {\n const { props, iModel } = arg;\n iModel.channels[_verifyChannel](arg.model);\n iModel.locks.checkExclusiveLock(props.element.id, \"element\", \"insert aspect\");\n }\n\n /** Called after a new ElementAspect was inserted.\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onInserted(_arg: OnAspectPropsArg): void { }\n\n /** Called before an ElementAspect is updated.\n * @note throw an exception to disallow the update\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onUpdate(arg: OnAspectPropsArg): void {\n const { props, iModel } = arg;\n iModel.channels[_verifyChannel](arg.model);\n iModel.locks.checkExclusiveLock(props.element.id, \"element\", \"update aspect\");\n }\n\n /** Called after an ElementAspect was updated.\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onUpdated(_arg: OnAspectPropsArg): void { }\n\n /** Called before an ElementAspect is deleted.\n * @note throw an exception to disallow the delete\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onDelete(arg: OnAspectIdArg): void {\n const { aspectId, iModel } = arg;\n iModel.channels[_verifyChannel](arg.model);\n const { element } = iModel.elements.getAspect(aspectId);\n iModel.locks.checkExclusiveLock(element.id, \"element\", \"delete aspect\");\n }\n\n /** Called after an ElementAspect was deleted.\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onDeleted(_arg: OnAspectIdArg): void { }\n}\n/** An Element Unique Aspect is an ElementAspect where there can be only zero or one instance of the Element Aspect class per Element.\n * @public\n */\nexport class ElementUniqueAspect extends ElementAspect {\n public static override get className(): string { return \"ElementUniqueAspect\"; }\n}\n\n/** An Element Multi-Aspect is an ElementAspect where there can be **n** instances of the Element Aspect class per Element.\n * @public\n */\nexport class ElementMultiAspect extends ElementAspect {\n public static override get className(): string { return \"ElementMultiAspect\"; }\n}\n\n/**\n * @public\n */\nexport class ChannelRootAspect extends ElementUniqueAspect {\n public static override get className(): string { return \"ChannelRootAspect\"; }\n /** Insert a ChannelRootAspect on the specified element.\n * @deprecated in 4.0 use [[ChannelControl.makeChannelRoot]]. This method does not enforce the rule that channels may not nest and is therefore dangerous.\n */\n public static insert(iModel: IModelDb, ownerId: Id64String, channelName: string) {\n const props: ChannelRootAspectProps = { classFullName: this.classFullName, element: { id: ownerId }, owner: channelName };\n iModel.elements.insertAspect(props);\n }\n}\n\n/** An ElementMultiAspect that stores synchronization information for an Element originating from an external source.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.2\n * @public\n */\nexport class ExternalSourceAspect extends ElementMultiAspect {\n public static override get className(): string { return \"ExternalSourceAspect\"; }\n\n /** An element that scopes the combination of `kind` and `identifier` to uniquely identify the object from the external source.\n * @note Warning: in a future major release the `scope` property will be optional, since the scope is intended to be potentially invalid.\n * all references should treat it as potentially undefined, but we cannot change the type yet since that is a breaking change.\n */\n public scope: RelatedElement;\n /** The identifier of the object in the source repository. */\n public identifier: string;\n /** The kind of object within the source repository. */\n public kind: string;\n /** The cryptographic hash (any algorithm) of the source object's content. If defined, it must be guaranteed to change when the source object's content changes. */\n public checksum?: string;\n /** An optional value that is typically a version number or a pseudo version number like last modified time.\n * It will be used by the synchronization process to detect that a source object is unchanged so that computing a cryptographic hash can be avoided.\n * If present, this value must be guaranteed to change when any of the source object's content changes.\n */\n public version?: string;\n /** A place where additional JSON properties can be stored. For example, provenance information or properties relating to the synchronization process.\n * @note Warning: in a future major release, the type of `jsonProperties` will be changed to object, and itwin.js will automatically stringify it when writing to the iModel.\n * This will be a breaking change, since application code will have to change from supplying a string to supplying an object.\n */\n public jsonProperties?: string;\n /** The source of the imported/synchronized object. Should point to an instance of [ExternalSource]($backend). */\n public source?: RelatedElement;\n\n /** Construct an aspect from its JSON representation and its containing iModel. */\n constructor(props: ExternalSourceAspectProps, iModel: IModelDb) {\n super(props, iModel);\n this.scope = RelatedElement.fromJSON(props.scope)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n this.source = RelatedElement.fromJSON(props.source);\n this.identifier = props.identifier;\n this.kind = props.kind;\n this.checksum = props.checksum;\n this.version = props.version;\n this.jsonProperties = props.jsonProperties;\n }\n\n /** Look up the elements that contain one or more ExternalSourceAspect with the specified Scope, Kind, and Identifier.\n * The result of this function is an array of all of the ExternalSourceAspects that were found, each associated with the owning element.\n * A given element could have more than one ExternalSourceAspect with the given scope, kind, and identifier.\n * Also, many elements could have ExternalSourceAspect with the same scope, kind, and identifier.\n * Therefore, the result array could have more than one entry with the same elementId.\n * Aspects are never shared. Each aspect has its own unique ECInstanceId.\n * @param iModelDb The iModel to query\n * @param scope The scope of the ExternalSourceAspects to find\n * @param kind The kind of the ExternalSourceAspects to find\n * @param identifier The identifier of the ExternalSourceAspects to find\n * @returns the query results\n */\n public static findAllBySource(iModelDb: IModelDb, scope: Id64String, kind: string, identifier: string): Array<{ elementId: Id64String, aspectId: Id64String }> {\n const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;\n const found: Array<{ elementId: Id64String, aspectId: Id64String }> = [];\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n iModelDb.withPreparedStatement(sql, (statement: ECSqlStatement) => {\n statement.bindId(\"scope\", scope);\n statement.bindString(\"kind\", kind);\n statement.bindString(\"identifier\", identifier);\n while (DbResult.BE_SQLITE_ROW === statement.step()) {\n found.push({ elementId: statement.getValue(0).getId(), aspectId: statement.getValue(1).getId() });\n }\n });\n return found;\n }\n\n public override toJSON(): ExternalSourceAspectProps {\n const val = super.toJSON() as ExternalSourceAspectProps;\n val.scope = this.scope;\n val.source = this.source;\n val.identifier = this.identifier;\n val.kind = this.kind;\n val.checksum = this.checksum;\n val.version = this.version;\n val.jsonProperties = this.jsonProperties;\n return val;\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n if (this.scope)\n referenceIds.addElement(this.scope.id);\n referenceIds.addElement(this.element.id);\n if (this.source)\n referenceIds.addElement(this.source.id);\n }\n}\n\n/** @public */\nexport namespace ExternalSourceAspect {\n /** Standard values for the `Kind` property of `ExternalSourceAspect`.\n * @public\n */\n export enum Kind {\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Element]] provenance */\n Element = \"Element\",\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Relationship]] provenance */\n Relationship = \"Relationship\",\n /** Indicates that the [[ExternalSourceAspect]] is storing *scope* provenance\n * @see [[ExternalSourceAspect.scope]]\n */\n Scope = \"Scope\",\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementTreeWalker.d.ts","sourceRoot":"","sources":["../../src/ElementTreeWalker.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAoB,SAAS,EAAE,UAAU,EAAoB,MAAM,qBAAqB,CAAC;AAIhG,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAmB,KAAK,EAAE,MAAM,SAAS,CAAC;AAIjD,YAAY;AACZ,MAAM,WAAW,0BAA0B;IAAG,KAAK,EAAE,KAAK,CAAC;IAAC,iBAAiB,EAAE,OAAO,CAAA;CAAE;
|
|
1
|
+
{"version":3,"file":"ElementTreeWalker.d.ts","sourceRoot":"","sources":["../../src/ElementTreeWalker.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAoB,SAAS,EAAE,UAAU,EA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ACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;AAClF;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI,CAAC;AAyBrE;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,0BAA0B,GAAG,IAAI,CAIxH"}
|
|
@@ -32,6 +32,7 @@ function sortChildrenBeforeParents(iModel, ids) {
|
|
|
32
32
|
return [...sortChildrenBeforeParents(iModel, children), parents];
|
|
33
33
|
}
|
|
34
34
|
function isModelEmpty(iModel, modelId) {
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
35
36
|
return iModel.withPreparedStatement(`select count(*) from ${Element_1.Element.classFullName} where Model.Id = ?`, (stmt) => {
|
|
36
37
|
stmt.bindId(1, modelId);
|
|
37
38
|
stmt.step();
|
|
@@ -138,6 +139,7 @@ function logModel(op, iModel, modelId, scope, logElements) {
|
|
|
138
139
|
const model = iModel.models.getModel(modelId);
|
|
139
140
|
core_bentley_1.Logger.logTrace(loggerCategory, `${op} ${fmtModel(model)} ${scope ? scope.toString() : ""}`);
|
|
140
141
|
if (logElements) {
|
|
142
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
141
143
|
iModel.withPreparedStatement(`select ecinstanceid from ${Element_1.Element.classFullName} where Model.Id = ?`, (stmt) => {
|
|
142
144
|
stmt.bindId(1, modelId);
|
|
143
145
|
while (stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW) {
|
|
@@ -197,6 +199,7 @@ class ElementTreeBottomUp {
|
|
|
197
199
|
_processSubModel(model, parenScope) {
|
|
198
200
|
const scope = new ElementTreeWalkerScope(parenScope, model);
|
|
199
201
|
// Visit only the top-level parents. processElementTree will visit their children (bottom-up).
|
|
202
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
200
203
|
model.iModel.withPreparedStatement(`select ECInstanceId from bis:Element where Model.id=? and Parent.Id is null`, (stmt) => {
|
|
201
204
|
stmt.bindId(1, model.id);
|
|
202
205
|
while (stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW) {
|
|
@@ -344,6 +347,7 @@ class ElementTreeTopDown {
|
|
|
344
347
|
_processSubModel(subModel, scope) {
|
|
345
348
|
const subModelScope = new ElementTreeWalkerScope(scope, subModel);
|
|
346
349
|
// Visit only the top-level parents. processElementTree will recurse into their children.
|
|
350
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
347
351
|
this._iModel.withPreparedStatement(`select ECInstanceId from bis:Element where Model.id=? and Parent.Id is null`, (stmt) => {
|
|
348
352
|
stmt.bindId(1, subModel.id);
|
|
349
353
|
while (stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementTreeWalker.js","sourceRoot":"","sources":["../../src/ElementTreeWalker.ts"],"names":[],"mappings":";;;AA2dA,8CAqBC;AAWD,sDAIC;AA/fD;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAgG;AAChG,oDAA4C;AAC5C,mEAAgE;AAChE,uCAA0G;AAC1G,yCAAsC;AACtC,mCAAiD;AAEjD,MAAM,cAAc,GAAG,GAAG,6CAAqB,CAAC,QAAQ,oBAAoB,CAAC;AAK7E,SAAS,yBAAyB,CAAC,MAAgB,EAAE,GAAc;IACjE,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAc,EAAE,CAAC;IAC9B,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAClD,IAAI,QAAQ,KAAK,SAAS,IAAI,GA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AE,IAAI,GAAG,SAAS,CAAC,EAAE;AAC9F,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CAAC,MAAgB,EAAE,UAAsB,EAAE,MAAkC;IAChH,MAAM,GAAG,GAAG,IAAI,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtD,GAAG,CAAC,2BAA2B,CAAC,UAAU,CAAC,CAAC;IAC5C,GAAG,CAAC,4BAA4B,EAAE,CAAC;AACrC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Elements\n */\nimport { assert, DbResult, Id64Array, Id64String, Logger, LogLevel } from \"@itwin/core-bentley\";\nimport { IModel } from \"@itwin/core-common\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { DefinitionContainer, DefinitionElement, DefinitionPartition, Element, Subject } from \"./Element\";\nimport { IModelDb } from \"./IModelDb\";\nimport { DefinitionModel, Model } from \"./Model\";\n\nconst loggerCategory = `${BackendLoggerCategory.IModelDb}.ElementTreeWalker`;\n\n/** @beta */\nexport interface ElementTreeWalkerModelInfo { model: Model, isDefinitionModel: boolean }\n\nfunction sortChildrenBeforeParents(iModel: IModelDb, ids: Id64Array): Array<Id64Array> {\n const children: Id64Array = [];\n const parents: Id64Array = [];\n for (const eid of ids) {\n const parentId = iModel.elements.queryParent(eid);\n if (parentId !== undefined && ids.includes(parentId))\n children.push(eid);\n else\n parents.push(eid);\n }\n\n if (children.length === 0)\n return [parents];\n\n return [...sortChildrenBeforeParents(iModel, children), parents];\n}\n\nfunction isModelEmpty(iModel: IModelDb, modelId: Id64String): boolean {\n return iModel.withPreparedStatement(`select count(*) from ${Element.classFullName} where Model.Id = ?`, (stmt) => {\n stmt.bindId(1, modelId);\n stmt.step();\n return stmt.getValue(0).getInteger() === 0;\n });\n}\n\nfunction isDefinitionModel(model: Model): boolean {\n return (model.id !== IModel.repositoryModelId) && (model instanceof DefinitionModel);\n}\n\nenum ElementPruningClassification { PRUNING_CLASS_Normal = 0, PRUNING_CLASS_Subject = 1, PRUNING_CLASS_Definition = 2, PRUNING_CLASS_DefinitionPartition = 3, }\n\nfunction classifyElementForPruning(iModel: IModelDb, elementId: Id64String): ElementPruningClassification {\n const el = iModel.elements.getElement(elementId);\n // DefinitionContainer is submodeled by a DefinitionModel and so it must be classified as PRUNING_CLASS_DefinitionPartition for tree-walking purposes.\n // Since DefinitionContainer is-a DefinitionElement the (el instanceof DefinitionElement) case below would classify it as PRUNING_CLASS_Definition.\n // That is why we special-case it here.\n if (el instanceof DefinitionContainer)\n return ElementPruningClassification.PRUNING_CLASS_DefinitionPartition;\n return (el instanceof Subject) ? ElementPruningClassification.PRUNING_CLASS_Subject :\n (el instanceof DefinitionElement) ? ElementPruningClassification.PRUNING_CLASS_Definition :\n (el instanceof DefinitionPartition) ? ElementPruningClassification.PRUNING_CLASS_DefinitionPartition :\n ElementPruningClassification.PRUNING_CLASS_Normal;\n}\n\n/** Records the path that a tree search took to reach an element or model. This object is immutable.\n * @beta\n */\nexport class ElementTreeWalkerScope {\n public readonly topElement: Id64String = \"\";\n /** path of parent elements and enclosing models */\n public readonly path: Array<Id64String | ElementTreeWalkerModelInfo> = [];\n /** cached info about the immediately enclosing model (i.e., the last model in path) */\n public readonly enclosingModelInfo: ElementTreeWalkerModelInfo;\n\n constructor(topElement: Id64String, model: Model);\n constructor(enclosingScope: ElementTreeWalkerScope, newScope: Id64String | Model);\n constructor(arg1: Id64String | ElementTreeWalkerScope, arg2: Model | Id64String) {\n if (typeof arg1 === \"string\") {\n // normal constructor\n assert(arg2 instanceof Model);\n this.topElement = arg1;\n this.path.push(this.enclosingModelInfo = { model: arg2, isDefinitionModel: isDefinitionModel(arg2) });\n } else if (arg1 instanceof ElementTreeWalkerScope) {\n // copy-like constructor\n this.topElement = arg1.topElement;\n this.path = [...arg1.path];\n if (typeof arg2 === \"string\") {\n // with new parent\n this.path.push(arg2);\n this.enclosingModelInfo = arg1.enclosingModelInfo;\n } else {\n // with new enclosing model\n this.path.push(this.enclosingModelInfo = { model: arg2, isDefinitionModel: isDefinitionModel(arg2) });\n }\n } else {\n throw new Error(\"invalid constructor signature\");\n }\n }\n\n public get enclosingModel(): Model { return this.enclosingModelInfo.model; }\n public get inDefinitionModel(): boolean { return this.enclosingModelInfo.isDefinitionModel; } // NB: this will return false for the RepositoryModel!\n public get inRepositoryModel(): boolean { return this.enclosingModelInfo.model.id === IModelDb.repositoryModelId; }\n\n public static createTopScope(iModel: IModelDb, topElementId: Id64String) {\n const topElement = iModel.elements.getElement(topElementId);\n const topElementModel = iModel.models.getModel(topElement.model);\n return new ElementTreeWalkerScope(topElementId, topElementModel);\n }\n\n private fmtItem(v: Id64String | ElementTreeWalkerModelInfo): string {\n if (typeof v === \"string\")\n return `element ${v}`;\n return `model ${v.model.id} ${v.isDefinitionModel ? \"(DEFN)\" : \"\"}`;\n }\n\n public toString(): string {\n return `[ ${this.path.map((v) => this.fmtItem(v)).join(\" / \")} ]`;\n }\n}\n\nfunction fmtElement(iModel: IModelDb, elementId: Id64String): string {\n const el = iModel.elements.getElement(elementId);\n return `${el.id} ${el.classFullName} ${el.getDisplayLabel()}`;\n}\n\nfunction fmtModel(model: Model): string {\n return `${model.id} ${model.classFullName} ${model.name}`;\n}\n\nlet isTraceEnabledChecked = -1;\n\nfunction isTraceEnabled(): boolean {\n if (isTraceEnabledChecked === -1)\n isTraceEnabledChecked = Logger.isEnabled(loggerCategory, LogLevel.Trace) ? 1 : 0;\n return isTraceEnabledChecked === 1;\n}\n\nfunction logElement(op: string, iModel: IModelDb, elementId: Id64String, scope?: ElementTreeWalkerScope, logChildren?: boolean): void {\n if (!isTraceEnabled())\n return;\n\n Logger.logTrace(loggerCategory, `${op} ${fmtElement(iModel, elementId)} ${scope ? scope.toString() : \"\"}`);\n\n if (logChildren)\n iModel.elements.queryChildren(elementId).forEach((c) => logElement(\" - \", iModel, c, undefined, true));\n}\n\nfunction logModel(op: string, iModel: IModelDb, modelId: Id64String, scope?: ElementTreeWalkerScope, logElements?: boolean): void {\n if (!isTraceEnabled())\n return;\n const model: Model = iModel.models.getModel(modelId);\n Logger.logTrace(loggerCategory, `${op} ${fmtModel(model)} ${scope ? scope.toString() : \"\"}`);\n\n if (logElements) {\n iModel.withPreparedStatement(`select ecinstanceid from ${Element.classFullName} where Model.Id = ?`, (stmt) => {\n stmt.bindId(1, modelId);\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\n logElement(\" - \", iModel, stmt.getValue(0).getId());\n }\n });\n }\n}\n\n/** Does a depth-first search on the tree defined by an element and its sub-models and children.\n * Sub-models are visited before their modeled elements, and children are visited before their parents.\n *\n * The following callbacks allow the subclass to exclude elements and sub-trees from the search:\n * * [[ElementTreeBottomUp.shouldExploreModel]], [[ElementTreeBottomUp.shouldExploreChildren]]\n * * [[ElementTreeBottomUp.shouldVisitElement]], [[ElementTreeBottomUp.shouldVisitModel]]\n *\n * The [[ElementTreeBottomUp.visitElement]] and [[ElementTreeBottomUp.visitModel]] callbacks allow\n * the subclass to process the elements and models that are encountered in the search.\n * @beta\n */\nexport abstract class ElementTreeBottomUp {\n constructor(protected _iModel: IModelDb) { }\n\n /** Return true if the search should recurse into this model */\n protected shouldExploreModel(_model: Model, _scope: ElementTreeWalkerScope): boolean { return true; }\n /** Return true if the search should recurse into the children (if any) of this element */\n protected shouldExploreChildren(_parentId: Id64String, _scope: ElementTreeWalkerScope): boolean { return true; }\n /** Return true if the search should visit this element */\n protected shouldVisitElement(_elementId: Id64String, _scope: ElementTreeWalkerScope): boolean { return true; }\n /** Return true if the search should visit this model */\n protected shouldVisitModel(_model: Model, _scope: ElementTreeWalkerScope): boolean { return true; }\n\n /** Called to visit a model */\n protected abstract visitModel(model: Model, scope: ElementTreeWalkerScope): void;\n\n /** Called to visit an element */\n protected abstract visitElement(elementId: Id64String, scope: ElementTreeWalkerScope): void;\n\n /** The main tree-walking function */\n protected processElementTree(element: Id64String, scope: ElementTreeWalkerScope) {\n const subModel = this._iModel.models.tryGetModel<Model>(element);\n if (subModel !== undefined) {\n if (this.shouldExploreModel(subModel, scope))\n this._processSubModel(subModel, scope);\n\n if (this.shouldVisitModel(subModel, scope))\n this.visitModel(subModel, scope);\n }\n\n if (this.shouldExploreChildren(element, scope))\n this._processChildren(element, scope);\n\n if (this.shouldVisitElement(element, scope))\n this.visitElement(element, scope);\n }\n\n /** process the children of the specified parent element */\n private _processChildren(parentElement: Id64String, parentScope: ElementTreeWalkerScope): void {\n const children = this._iModel.elements.queryChildren(parentElement);\n if (children.length === 0)\n return;\n\n const childrenScope = new ElementTreeWalkerScope(parentScope, parentElement);\n\n for (const childElement of children)\n this.processElementTree(childElement, childrenScope);\n }\n\n /** process the elements in the specified model */\n private _processSubModel(model: Model, parenScope: ElementTreeWalkerScope): void {\n const scope = new ElementTreeWalkerScope(parenScope, model);\n // Visit only the top-level parents. processElementTree will visit their children (bottom-up).\n model.iModel.withPreparedStatement(`select ECInstanceId from bis:Element where Model.id=? and Parent.Id is null`, (stmt) => {\n stmt.bindId(1, model.id);\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\n const elementId = stmt.getValue(0).getId();\n this.processElementTree(elementId, scope);\n }\n });\n }\n}\n\n/** Helper class that manages the deletion of definitions and subjects */\nclass SpecialElements {\n public definitionModels: Id64Array = [];\n public definitions: Id64Array = [];\n public subjects: Id64Array = [];\n\n public recordSpecialElement(iModel: IModelDb, elementId: Id64String): boolean {\n // Defer Definitions and Subjects\n const cls = classifyElementForPruning(iModel, elementId);\n if (cls === ElementPruningClassification.PRUNING_CLASS_Subject) {\n this.subjects.push(elementId);\n return true;\n } else if (cls === ElementPruningClassification.PRUNING_CLASS_Definition) {\n this.definitions.push(elementId);\n return true;\n } else if (cls === ElementPruningClassification.PRUNING_CLASS_DefinitionPartition) {\n this.definitionModels.push(elementId);\n return true;\n }\n return false; // not a special element\n }\n\n /** Delete special elements - This calls Elements.deleteDefinitionElements to process the collected definition elements as a group and then\n * calls Models.deleteModel on collected definition models. It then deletes all collected Subjects by calling Element.deleteElement on them.\n * @note Caller must ensure that the special elements were recorded in a depth-first search.\n */\n public deleteSpecialElements(iModel: IModelDb) {\n // It's dangerous to pass a mixture of SubCategories and Categories to deleteDefinitionElements.\n // That function will delete the Categories first, which automatically deletes all their child\n // SubCategories (in native code). If a SubCategory in the list is one of those children, then\n // deleteDefinitionElements will try and fail with an exception to delete that SubCategory in a subsequent step.\n // To work around this, we delete the SubCategories first, then everything else.\n // A similar problem occurs when you pass other kinds of elements to deleteDefinitionElements, where some are\n // children and others are parents. deleteDefinitionElements does not preserve the order that you specify,\n // and it does not process children before parents.\n for (const definitions of sortChildrenBeforeParents(iModel, this.definitions)) {\n if (isTraceEnabled())\n definitions.forEach((e) => logElement(\"try delete\", iModel, e));\n\n iModel.elements.deleteDefinitionElements(definitions); // will not delete definitions that are still in use.\n }\n\n for (const m of this.definitionModels) {\n if (!isModelEmpty(iModel, m)) {\n logModel(\"Model not empty - cannot delete - may contain Definitions that are still in use\", iModel, m, undefined, true);\n } else {\n logModel(\"delete\", iModel, m);\n iModel.models.deleteModel(m);\n iModel.elements.deleteElement(m);\n }\n }\n\n for (const e of this.subjects) {\n if (iModel.elements.queryChildren(e).length !== 0) {\n logElement(\"Subject still has children - cannot delete - may have child DefinitionModels\", iModel, e, undefined, true);\n } else {\n logElement(\"delete\", iModel, e);\n iModel.elements.deleteElement(e);\n }\n }\n }\n\n}\n\n/** Deletes an entire element tree, including sub-models and child elements.\n * Items are deleted in bottom-up order. Definitions and Subjects are deleted after normal elements.\n * Call deleteNormalElements on each tree. Then call deleteSpecialElements.\n * @see deleteElementTree for a simple way to use this class.\n * @beta\n */\nexport class ElementTreeDeleter extends ElementTreeBottomUp {\n protected _special: SpecialElements = new SpecialElements();\n\n protected override shouldExploreModel(_model: Model): boolean { return true; }\n protected override shouldVisitElement(_elementId: Id64String): boolean { return true; }\n\n protected override visitModel(model: Model, _scope: ElementTreeWalkerScope): void {\n if (isDefinitionModel(model))\n return; // we recorded definition models in visitElement when we encountered the DefinitionPartition elements.\n\n // visitElement has already deleted the elements in the model. So, now it's safe to delete the model itself.\n logModel(\"delete\", this._iModel, model.id, _scope);\n model.delete();\n }\n\n protected override visitElement(elementId: Id64String, _scope: ElementTreeWalkerScope): void {\n if (!this._special.recordSpecialElement(this._iModel, elementId)) {\n logElement(\"delete\", this._iModel, elementId, _scope);\n this._iModel.elements.deleteElement(elementId);\n }\n }\n\n /**\n * Delete the \"normal\" elements and record the special elements for deferred processing.\n * @param topElement The parent of the sub-tree to be deleted. Top element itself is also deleted.\n * @param scope How the parent was found\n * @see deleteSpecialElements\n */\n public deleteNormalElements(topElement: Id64String, scope?: ElementTreeWalkerScope): void {\n const topScope = scope ?? ElementTreeWalkerScope.createTopScope(this._iModel, topElement);\n this.processElementTree(topElement, topScope); //\n }\n\n /** Delete all special elements that were found and deferred by deleteNormalElements. Call this\n * function once after all element trees are processed by deleteNormalElements.\n */\n public deleteSpecialElements(): void {\n this._special.deleteSpecialElements(this._iModel);\n }\n\n}\n\n/** Does a breadth-first search on the tree defined by an element and its sub-models and children.\n * Parents are visited first, then children, then sub-models.\n * The subclass can \"prune\" sub-trees from the search. When a sub-tree is \"pruned\" the search does *not* recurse into it.\n * If a sub-tree is not pruned, then the search does recurse into it.\n * @beta\n */\nabstract class ElementTreeTopDown {\n constructor(protected _iModel: IModelDb) { }\n\n /** Should the search *not* recurse into this sub-tree? */\n protected shouldPrune(_elementId: Id64String, _scope: ElementTreeWalkerScope): boolean { return false; }\n\n protected abstract prune(_elementId: Id64String, _scope: ElementTreeWalkerScope): void;\n\n protected processElementTree(element: Id64String, scope: ElementTreeWalkerScope) {\n\n if (this.shouldPrune(element, scope)) {\n this.prune(element, scope);\n return;\n }\n\n this._processChildren(element, scope);\n\n const subModel = this._iModel.models.tryGetModel<Model>(element);\n if (subModel !== undefined) {\n this._processSubModel(subModel, scope);\n }\n }\n\n private _processChildren(element: Id64String, scope: ElementTreeWalkerScope) {\n let parentScope: ElementTreeWalkerScope | undefined;\n for (const childElement of this._iModel.elements.queryChildren(element)) {\n if (parentScope === undefined)\n parentScope = new ElementTreeWalkerScope(scope, element);\n this.processElementTree(childElement, parentScope);\n }\n }\n\n private _processSubModel(subModel: Model, scope: ElementTreeWalkerScope) {\n const subModelScope = new ElementTreeWalkerScope(scope, subModel);\n // Visit only the top-level parents. processElementTree will recurse into their children.\n this._iModel.withPreparedStatement(`select ECInstanceId from bis:Element where Model.id=? and Parent.Id is null`, (stmt) => {\n stmt.bindId(1, subModel.id);\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\n const elementId = stmt.getValue(0).getId();\n this.processElementTree(elementId, subModelScope);\n }\n });\n }\n\n}\n\n/** Signature of the filter function used by ElementSubTreeDeleter.\n * @param elementId The sub-tree parent element.\n * @param scope The path followed by the top-down search to the element\n * @return true if the element and its children and sub-models should be deleted.\n * @beta\n */\nexport type ElementSubTreeDeleteFilter = (elementId: Id64String, scope: ElementTreeWalkerScope) => boolean;\n\n/** Performs a breadth-first search to visit elements in top-down order.\n * When the supplied filter function chooses an element, ElementTreeDeleter is used to delete it and its sub-tree.\n * @beta\n */\nexport class ElementSubTreeDeleter extends ElementTreeTopDown {\n private _treeDeleter: ElementTreeDeleter;\n private _shouldPruneCb: ElementSubTreeDeleteFilter;\n\n /** Construct an ElementSubTreeDeleter.\n * @param iModel The iModel\n * @param topElement Where to start the search.\n * @param shouldPruneCb Callback that selects sub-trees that should be deleted.\n * @see deleteElementSubTrees for a simple way to use this class.\n */\n public constructor(iModel: IModelDb, shouldPruneCb: ElementSubTreeDeleteFilter) {\n super(iModel);\n this._treeDeleter = new ElementTreeDeleter(this._iModel);\n this._shouldPruneCb = shouldPruneCb;\n }\n\n protected override shouldPrune(elementId: Id64String, scope: ElementTreeWalkerScope): boolean { return this._shouldPruneCb(elementId, scope); }\n\n protected prune(elementId: Id64String, scope: ElementTreeWalkerScope): void {\n this._treeDeleter.deleteNormalElements(elementId, scope);\n }\n\n /** Traverses the tree of elements beginning with the top element, and deletes all selected sub-trees.\n * Normal elements are deleted. Any special elements that are encountered are deferred.\n * Call deleteSpecialElementSubTrees after all top elements have been processed. */\n public deleteNormalElementSubTrees(topElement: Id64String, scope?: ElementTreeWalkerScope) {\n const topScope = scope ?? ElementTreeWalkerScope.createTopScope(this._iModel, topElement);\n this.processElementTree(topElement, topScope); // deletes normal elements and their sub-trees, defers special elements\n }\n\n /** Delete all special elements and their sub-trees that were found in the course of processing.\n * The sub-trees were already expanded by ElementTreeDeleter.deleteNormalElements.\n */\n public deleteSpecialElementSubTrees() {\n this._treeDeleter.deleteSpecialElements();\n }\n}\n\n/** Arguments supplied to [[deleteElementTree]].\n * @beta\n */\nexport interface DeleteElementTreeArgs {\n /** The iModel containing the elements to delete. */\n iModel: IModelDb;\n /** The Id of the root element of the tree to delete. */\n topElement: Id64String;\n /** The maximum number of passes to make when deleting definition elements.\n * Default: 5\n */\n maxPasses?: number;\n}\n\n/** Deletes an element tree starting with the specified top element. The top element is also deleted. Uses ElementTreeDeleter.\n * @param iModel The iModel\n * @param topElement The parent of the sub-tree\n * @beta\n */\nexport function deleteElementTree(iModel: IModelDb, topElement: Id64String): void;\n/** Deletes an element tree starting with the specified top element. The top element is also deleted. Uses ElementTreeDeleter.\n * @param args Specifies the iModel and top element.\n * @beta\n */\nexport function deleteElementTree(args: DeleteElementTreeArgs): void;\n/** @internal */\nexport function deleteElementTree(arg0: DeleteElementTreeArgs | IModelDb, arg1?: Id64String): void {\n let maxPasses;\n let iModel: IModelDb;\n let topElement: Id64String;\n if (arg0 instanceof IModelDb) {\n assert(typeof arg1 === \"string\");\n iModel = arg0;\n topElement = arg1;\n } else {\n iModel = arg0.iModel;\n topElement = arg0.topElement;\n maxPasses = arg0.maxPasses;\n }\n\n maxPasses = maxPasses ?? 5;\n let pass = 0;\n do {\n const del = new ElementTreeDeleter(iModel);\n del.deleteNormalElements(topElement);\n del.deleteSpecialElements();\n } while ((iModel.elements.tryGetElement(topElement) !== undefined) && (++pass < maxPasses));\n}\n\n/** Deletes all element sub-trees that are selected by the supplied filter. Uses ElementSubTreeDeleter.\n * If the filter selects the top element itself, then the entire tree (including the top element) is deleted.\n * That has the same effect as calling [[deleteElementTree]] on the top element.\n * @note The caller may have to call this function multiple times if there are multiple layers of dependencies among definition elements.\n * @param iModel The iModel\n * @param topElement Where to start the search.\n * @param filter Callback that selects sub-trees that should be deleted.\n * @beta\n */\nexport function deleteElementSubTrees(iModel: IModelDb, topElement: Id64String, filter: ElementSubTreeDeleteFilter): void {\n const del = new ElementSubTreeDeleter(iModel, filter);\n del.deleteNormalElementSubTrees(topElement);\n del.deleteSpecialElementSubTrees();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ElementTreeWalker.js","sourceRoot":"","sources":["../../src/ElementTreeWalker.ts"],"names":[],"mappings":";;;AA+dA,8CAqBC;AAWD,sDAIC;AAngBD;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAgG;AAChG,oDAA4C;AAC5C,mEAAgE;AAChE,uCAA0G;AAC1G,yCAAsC;AACtC,mCAAiD;AAEjD,MAAM,cAAc,GAAG,GAAG,6CAAqB,CAAC,QAAQ,oBAAoB,CAAC;AAK7E,SAAS,yBAAyB,CAAC,MAAgB,EAAE,GAAc;IACjE,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAc,EAAE,CAAC;IAC9B,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAClD,IAAI,QAAQ,KAAK,SAAS,IAAI,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAClD,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;;YAEnB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC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AACH,SAAgB,qBAAqB,CAAC,MAAgB,EAAE,UAAsB,EAAE,MAAkC;IAChH,MAAM,GAAG,GAAG,IAAI,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtD,GAAG,CAAC,2BAA2B,CAAC,UAAU,CAAC,CAAC;IAC5C,GAAG,CAAC,4BAA4B,EAAE,CAAC;AACrC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Elements\n */\nimport { assert, DbResult, Id64Array, Id64String, Logger, LogLevel } from \"@itwin/core-bentley\";\nimport { IModel } from \"@itwin/core-common\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { DefinitionContainer, DefinitionElement, DefinitionPartition, Element, Subject } from \"./Element\";\nimport { IModelDb } from \"./IModelDb\";\nimport { DefinitionModel, Model } from \"./Model\";\n\nconst loggerCategory = `${BackendLoggerCategory.IModelDb}.ElementTreeWalker`;\n\n/** @beta */\nexport interface ElementTreeWalkerModelInfo { model: Model, isDefinitionModel: boolean }\n\nfunction sortChildrenBeforeParents(iModel: IModelDb, ids: Id64Array): Array<Id64Array> {\n const children: Id64Array = [];\n const parents: Id64Array = [];\n for (const eid of ids) {\n const parentId = iModel.elements.queryParent(eid);\n if (parentId !== undefined && ids.includes(parentId))\n children.push(eid);\n else\n parents.push(eid);\n }\n\n if (children.length === 0)\n return [parents];\n\n return [...sortChildrenBeforeParents(iModel, children), parents];\n}\n\nfunction isModelEmpty(iModel: IModelDb, modelId: Id64String): boolean {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return iModel.withPreparedStatement(`select count(*) from ${Element.classFullName} where Model.Id = ?`, (stmt) => {\n stmt.bindId(1, modelId);\n stmt.step();\n return stmt.getValue(0).getInteger() === 0;\n });\n}\n\nfunction isDefinitionModel(model: Model): boolean {\n return (model.id !== IModel.repositoryModelId) && (model instanceof DefinitionModel);\n}\n\nenum ElementPruningClassification { PRUNING_CLASS_Normal = 0, PRUNING_CLASS_Subject = 1, PRUNING_CLASS_Definition = 2, PRUNING_CLASS_DefinitionPartition = 3, }\n\nfunction classifyElementForPruning(iModel: IModelDb, elementId: Id64String): ElementPruningClassification {\n const el = iModel.elements.getElement(elementId);\n // DefinitionContainer is submodeled by a DefinitionModel and so it must be classified as PRUNING_CLASS_DefinitionPartition for tree-walking purposes.\n // Since DefinitionContainer is-a DefinitionElement the (el instanceof DefinitionElement) case below would classify it as PRUNING_CLASS_Definition.\n // That is why we special-case it here.\n if (el instanceof DefinitionContainer)\n return ElementPruningClassification.PRUNING_CLASS_DefinitionPartition;\n return (el instanceof Subject) ? ElementPruningClassification.PRUNING_CLASS_Subject :\n (el instanceof DefinitionElement) ? ElementPruningClassification.PRUNING_CLASS_Definition :\n (el instanceof DefinitionPartition) ? ElementPruningClassification.PRUNING_CLASS_DefinitionPartition :\n ElementPruningClassification.PRUNING_CLASS_Normal;\n}\n\n/** Records the path that a tree search took to reach an element or model. This object is immutable.\n * @beta\n */\nexport class ElementTreeWalkerScope {\n public readonly topElement: Id64String = \"\";\n /** path of parent elements and enclosing models */\n public readonly path: Array<Id64String | ElementTreeWalkerModelInfo> = [];\n /** cached info about the immediately enclosing model (i.e., the last model in path) */\n public readonly enclosingModelInfo: ElementTreeWalkerModelInfo;\n\n constructor(topElement: Id64String, model: Model);\n constructor(enclosingScope: ElementTreeWalkerScope, newScope: Id64String | Model);\n constructor(arg1: Id64String | ElementTreeWalkerScope, arg2: Model | Id64String) {\n if (typeof arg1 === \"string\") {\n // normal constructor\n assert(arg2 instanceof Model);\n this.topElement = arg1;\n this.path.push(this.enclosingModelInfo = { model: arg2, isDefinitionModel: isDefinitionModel(arg2) });\n } else if (arg1 instanceof ElementTreeWalkerScope) {\n // copy-like constructor\n this.topElement = arg1.topElement;\n this.path = [...arg1.path];\n if (typeof arg2 === \"string\") {\n // with new parent\n this.path.push(arg2);\n this.enclosingModelInfo = arg1.enclosingModelInfo;\n } else {\n // with new enclosing model\n this.path.push(this.enclosingModelInfo = { model: arg2, isDefinitionModel: isDefinitionModel(arg2) });\n }\n } else {\n throw new Error(\"invalid constructor signature\");\n }\n }\n\n public get enclosingModel(): Model { return this.enclosingModelInfo.model; }\n public get inDefinitionModel(): boolean { return this.enclosingModelInfo.isDefinitionModel; } // NB: this will return false for the RepositoryModel!\n public get inRepositoryModel(): boolean { return this.enclosingModelInfo.model.id === IModelDb.repositoryModelId; }\n\n public static createTopScope(iModel: IModelDb, topElementId: Id64String) {\n const topElement = iModel.elements.getElement(topElementId);\n const topElementModel = iModel.models.getModel(topElement.model);\n return new ElementTreeWalkerScope(topElementId, topElementModel);\n }\n\n private fmtItem(v: Id64String | ElementTreeWalkerModelInfo): string {\n if (typeof v === \"string\")\n return `element ${v}`;\n return `model ${v.model.id} ${v.isDefinitionModel ? \"(DEFN)\" : \"\"}`;\n }\n\n public toString(): string {\n return `[ ${this.path.map((v) => this.fmtItem(v)).join(\" / \")} ]`;\n }\n}\n\nfunction fmtElement(iModel: IModelDb, elementId: Id64String): string {\n const el = iModel.elements.getElement(elementId);\n return `${el.id} ${el.classFullName} ${el.getDisplayLabel()}`;\n}\n\nfunction fmtModel(model: Model): string {\n return `${model.id} ${model.classFullName} ${model.name}`;\n}\n\nlet isTraceEnabledChecked = -1;\n\nfunction isTraceEnabled(): boolean {\n if (isTraceEnabledChecked === -1)\n isTraceEnabledChecked = Logger.isEnabled(loggerCategory, LogLevel.Trace) ? 1 : 0;\n return isTraceEnabledChecked === 1;\n}\n\nfunction logElement(op: string, iModel: IModelDb, elementId: Id64String, scope?: ElementTreeWalkerScope, logChildren?: boolean): void {\n if (!isTraceEnabled())\n return;\n\n Logger.logTrace(loggerCategory, `${op} ${fmtElement(iModel, elementId)} ${scope ? scope.toString() : \"\"}`);\n\n if (logChildren)\n iModel.elements.queryChildren(elementId).forEach((c) => logElement(\" - \", iModel, c, undefined, true));\n}\n\nfunction logModel(op: string, iModel: IModelDb, modelId: Id64String, scope?: ElementTreeWalkerScope, logElements?: boolean): void {\n if (!isTraceEnabled())\n return;\n const model: Model = iModel.models.getModel(modelId);\n Logger.logTrace(loggerCategory, `${op} ${fmtModel(model)} ${scope ? scope.toString() : \"\"}`);\n\n if (logElements) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n iModel.withPreparedStatement(`select ecinstanceid from ${Element.classFullName} where Model.Id = ?`, (stmt) => {\n stmt.bindId(1, modelId);\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\n logElement(\" - \", iModel, stmt.getValue(0).getId());\n }\n });\n }\n}\n\n/** Does a depth-first search on the tree defined by an element and its sub-models and children.\n * Sub-models are visited before their modeled elements, and children are visited before their parents.\n *\n * The following callbacks allow the subclass to exclude elements and sub-trees from the search:\n * * [[ElementTreeBottomUp.shouldExploreModel]], [[ElementTreeBottomUp.shouldExploreChildren]]\n * * [[ElementTreeBottomUp.shouldVisitElement]], [[ElementTreeBottomUp.shouldVisitModel]]\n *\n * The [[ElementTreeBottomUp.visitElement]] and [[ElementTreeBottomUp.visitModel]] callbacks allow\n * the subclass to process the elements and models that are encountered in the search.\n * @beta\n */\nexport abstract class ElementTreeBottomUp {\n constructor(protected _iModel: IModelDb) { }\n\n /** Return true if the search should recurse into this model */\n protected shouldExploreModel(_model: Model, _scope: ElementTreeWalkerScope): boolean { return true; }\n /** Return true if the search should recurse into the children (if any) of this element */\n protected shouldExploreChildren(_parentId: Id64String, _scope: ElementTreeWalkerScope): boolean { return true; }\n /** Return true if the search should visit this element */\n protected shouldVisitElement(_elementId: Id64String, _scope: ElementTreeWalkerScope): boolean { return true; }\n /** Return true if the search should visit this model */\n protected shouldVisitModel(_model: Model, _scope: ElementTreeWalkerScope): boolean { return true; }\n\n /** Called to visit a model */\n protected abstract visitModel(model: Model, scope: ElementTreeWalkerScope): void;\n\n /** Called to visit an element */\n protected abstract visitElement(elementId: Id64String, scope: ElementTreeWalkerScope): void;\n\n /** The main tree-walking function */\n protected processElementTree(element: Id64String, scope: ElementTreeWalkerScope) {\n const subModel = this._iModel.models.tryGetModel<Model>(element);\n if (subModel !== undefined) {\n if (this.shouldExploreModel(subModel, scope))\n this._processSubModel(subModel, scope);\n\n if (this.shouldVisitModel(subModel, scope))\n this.visitModel(subModel, scope);\n }\n\n if (this.shouldExploreChildren(element, scope))\n this._processChildren(element, scope);\n\n if (this.shouldVisitElement(element, scope))\n this.visitElement(element, scope);\n }\n\n /** process the children of the specified parent element */\n private _processChildren(parentElement: Id64String, parentScope: ElementTreeWalkerScope): void {\n const children = this._iModel.elements.queryChildren(parentElement);\n if (children.length === 0)\n return;\n\n const childrenScope = new ElementTreeWalkerScope(parentScope, parentElement);\n\n for (const childElement of children)\n this.processElementTree(childElement, childrenScope);\n }\n\n /** process the elements in the specified model */\n private _processSubModel(model: Model, parenScope: ElementTreeWalkerScope): void {\n const scope = new ElementTreeWalkerScope(parenScope, model);\n // Visit only the top-level parents. processElementTree will visit their children (bottom-up).\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n model.iModel.withPreparedStatement(`select ECInstanceId from bis:Element where Model.id=? and Parent.Id is null`, (stmt) => {\n stmt.bindId(1, model.id);\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\n const elementId = stmt.getValue(0).getId();\n this.processElementTree(elementId, scope);\n }\n });\n }\n}\n\n/** Helper class that manages the deletion of definitions and subjects */\nclass SpecialElements {\n public definitionModels: Id64Array = [];\n public definitions: Id64Array = [];\n public subjects: Id64Array = [];\n\n public recordSpecialElement(iModel: IModelDb, elementId: Id64String): boolean {\n // Defer Definitions and Subjects\n const cls = classifyElementForPruning(iModel, elementId);\n if (cls === ElementPruningClassification.PRUNING_CLASS_Subject) {\n this.subjects.push(elementId);\n return true;\n } else if (cls === ElementPruningClassification.PRUNING_CLASS_Definition) {\n this.definitions.push(elementId);\n return true;\n } else if (cls === ElementPruningClassification.PRUNING_CLASS_DefinitionPartition) {\n this.definitionModels.push(elementId);\n return true;\n }\n return false; // not a special element\n }\n\n /** Delete special elements - This calls Elements.deleteDefinitionElements to process the collected definition elements as a group and then\n * calls Models.deleteModel on collected definition models. It then deletes all collected Subjects by calling Element.deleteElement on them.\n * @note Caller must ensure that the special elements were recorded in a depth-first search.\n */\n public deleteSpecialElements(iModel: IModelDb) {\n // It's dangerous to pass a mixture of SubCategories and Categories to deleteDefinitionElements.\n // That function will delete the Categories first, which automatically deletes all their child\n // SubCategories (in native code). If a SubCategory in the list is one of those children, then\n // deleteDefinitionElements will try and fail with an exception to delete that SubCategory in a subsequent step.\n // To work around this, we delete the SubCategories first, then everything else.\n // A similar problem occurs when you pass other kinds of elements to deleteDefinitionElements, where some are\n // children and others are parents. deleteDefinitionElements does not preserve the order that you specify,\n // and it does not process children before parents.\n for (const definitions of sortChildrenBeforeParents(iModel, this.definitions)) {\n if (isTraceEnabled())\n definitions.forEach((e) => logElement(\"try delete\", iModel, e));\n\n iModel.elements.deleteDefinitionElements(definitions); // will not delete definitions that are still in use.\n }\n\n for (const m of this.definitionModels) {\n if (!isModelEmpty(iModel, m)) {\n logModel(\"Model not empty - cannot delete - may contain Definitions that are still in use\", iModel, m, undefined, true);\n } else {\n logModel(\"delete\", iModel, m);\n iModel.models.deleteModel(m);\n iModel.elements.deleteElement(m);\n }\n }\n\n for (const e of this.subjects) {\n if (iModel.elements.queryChildren(e).length !== 0) {\n logElement(\"Subject still has children - cannot delete - may have child DefinitionModels\", iModel, e, undefined, true);\n } else {\n logElement(\"delete\", iModel, e);\n iModel.elements.deleteElement(e);\n }\n }\n }\n\n}\n\n/** Deletes an entire element tree, including sub-models and child elements.\n * Items are deleted in bottom-up order. Definitions and Subjects are deleted after normal elements.\n * Call deleteNormalElements on each tree. Then call deleteSpecialElements.\n * @see deleteElementTree for a simple way to use this class.\n * @beta\n */\nexport class ElementTreeDeleter extends ElementTreeBottomUp {\n protected _special: SpecialElements = new SpecialElements();\n\n protected override shouldExploreModel(_model: Model): boolean { return true; }\n protected override shouldVisitElement(_elementId: Id64String): boolean { return true; }\n\n protected override visitModel(model: Model, _scope: ElementTreeWalkerScope): void {\n if (isDefinitionModel(model))\n return; // we recorded definition models in visitElement when we encountered the DefinitionPartition elements.\n\n // visitElement has already deleted the elements in the model. So, now it's safe to delete the model itself.\n logModel(\"delete\", this._iModel, model.id, _scope);\n model.delete();\n }\n\n protected override visitElement(elementId: Id64String, _scope: ElementTreeWalkerScope): void {\n if (!this._special.recordSpecialElement(this._iModel, elementId)) {\n logElement(\"delete\", this._iModel, elementId, _scope);\n this._iModel.elements.deleteElement(elementId);\n }\n }\n\n /**\n * Delete the \"normal\" elements and record the special elements for deferred processing.\n * @param topElement The parent of the sub-tree to be deleted. Top element itself is also deleted.\n * @param scope How the parent was found\n * @see deleteSpecialElements\n */\n public deleteNormalElements(topElement: Id64String, scope?: ElementTreeWalkerScope): void {\n const topScope = scope ?? ElementTreeWalkerScope.createTopScope(this._iModel, topElement);\n this.processElementTree(topElement, topScope); //\n }\n\n /** Delete all special elements that were found and deferred by deleteNormalElements. Call this\n * function once after all element trees are processed by deleteNormalElements.\n */\n public deleteSpecialElements(): void {\n this._special.deleteSpecialElements(this._iModel);\n }\n\n}\n\n/** Does a breadth-first search on the tree defined by an element and its sub-models and children.\n * Parents are visited first, then children, then sub-models.\n * The subclass can \"prune\" sub-trees from the search. When a sub-tree is \"pruned\" the search does *not* recurse into it.\n * If a sub-tree is not pruned, then the search does recurse into it.\n * @beta\n */\nabstract class ElementTreeTopDown {\n constructor(protected _iModel: IModelDb) { }\n\n /** Should the search *not* recurse into this sub-tree? */\n protected shouldPrune(_elementId: Id64String, _scope: ElementTreeWalkerScope): boolean { return false; }\n\n protected abstract prune(_elementId: Id64String, _scope: ElementTreeWalkerScope): void;\n\n protected processElementTree(element: Id64String, scope: ElementTreeWalkerScope) {\n\n if (this.shouldPrune(element, scope)) {\n this.prune(element, scope);\n return;\n }\n\n this._processChildren(element, scope);\n\n const subModel = this._iModel.models.tryGetModel<Model>(element);\n if (subModel !== undefined) {\n this._processSubModel(subModel, scope);\n }\n }\n\n private _processChildren(element: Id64String, scope: ElementTreeWalkerScope) {\n let parentScope: ElementTreeWalkerScope | undefined;\n for (const childElement of this._iModel.elements.queryChildren(element)) {\n if (parentScope === undefined)\n parentScope = new ElementTreeWalkerScope(scope, element);\n this.processElementTree(childElement, parentScope);\n }\n }\n\n private _processSubModel(subModel: Model, scope: ElementTreeWalkerScope) {\n const subModelScope = new ElementTreeWalkerScope(scope, subModel);\n // Visit only the top-level parents. processElementTree will recurse into their children.\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n this._iModel.withPreparedStatement(`select ECInstanceId from bis:Element where Model.id=? and Parent.Id is null`, (stmt) => {\n stmt.bindId(1, subModel.id);\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\n const elementId = stmt.getValue(0).getId();\n this.processElementTree(elementId, subModelScope);\n }\n });\n }\n\n}\n\n/** Signature of the filter function used by ElementSubTreeDeleter.\n * @param elementId The sub-tree parent element.\n * @param scope The path followed by the top-down search to the element\n * @return true if the element and its children and sub-models should be deleted.\n * @beta\n */\nexport type ElementSubTreeDeleteFilter = (elementId: Id64String, scope: ElementTreeWalkerScope) => boolean;\n\n/** Performs a breadth-first search to visit elements in top-down order.\n * When the supplied filter function chooses an element, ElementTreeDeleter is used to delete it and its sub-tree.\n * @beta\n */\nexport class ElementSubTreeDeleter extends ElementTreeTopDown {\n private _treeDeleter: ElementTreeDeleter;\n private _shouldPruneCb: ElementSubTreeDeleteFilter;\n\n /** Construct an ElementSubTreeDeleter.\n * @param iModel The iModel\n * @param topElement Where to start the search.\n * @param shouldPruneCb Callback that selects sub-trees that should be deleted.\n * @see deleteElementSubTrees for a simple way to use this class.\n */\n public constructor(iModel: IModelDb, shouldPruneCb: ElementSubTreeDeleteFilter) {\n super(iModel);\n this._treeDeleter = new ElementTreeDeleter(this._iModel);\n this._shouldPruneCb = shouldPruneCb;\n }\n\n protected override shouldPrune(elementId: Id64String, scope: ElementTreeWalkerScope): boolean { return this._shouldPruneCb(elementId, scope); }\n\n protected prune(elementId: Id64String, scope: ElementTreeWalkerScope): void {\n this._treeDeleter.deleteNormalElements(elementId, scope);\n }\n\n /** Traverses the tree of elements beginning with the top element, and deletes all selected sub-trees.\n * Normal elements are deleted. Any special elements that are encountered are deferred.\n * Call deleteSpecialElementSubTrees after all top elements have been processed. */\n public deleteNormalElementSubTrees(topElement: Id64String, scope?: ElementTreeWalkerScope) {\n const topScope = scope ?? ElementTreeWalkerScope.createTopScope(this._iModel, topElement);\n this.processElementTree(topElement, topScope); // deletes normal elements and their sub-trees, defers special elements\n }\n\n /** Delete all special elements and their sub-trees that were found in the course of processing.\n * The sub-trees were already expanded by ElementTreeDeleter.deleteNormalElements.\n */\n public deleteSpecialElementSubTrees() {\n this._treeDeleter.deleteSpecialElements();\n }\n}\n\n/** Arguments supplied to [[deleteElementTree]].\n * @beta\n */\nexport interface DeleteElementTreeArgs {\n /** The iModel containing the elements to delete. */\n iModel: IModelDb;\n /** The Id of the root element of the tree to delete. */\n topElement: Id64String;\n /** The maximum number of passes to make when deleting definition elements.\n * Default: 5\n */\n maxPasses?: number;\n}\n\n/** Deletes an element tree starting with the specified top element. The top element is also deleted. Uses ElementTreeDeleter.\n * @param iModel The iModel\n * @param topElement The parent of the sub-tree\n * @beta\n */\nexport function deleteElementTree(iModel: IModelDb, topElement: Id64String): void;\n/** Deletes an element tree starting with the specified top element. The top element is also deleted. Uses ElementTreeDeleter.\n * @param args Specifies the iModel and top element.\n * @beta\n */\nexport function deleteElementTree(args: DeleteElementTreeArgs): void;\n/** @internal */\nexport function deleteElementTree(arg0: DeleteElementTreeArgs | IModelDb, arg1?: Id64String): void {\n let maxPasses;\n let iModel: IModelDb;\n let topElement: Id64String;\n if (arg0 instanceof IModelDb) {\n assert(typeof arg1 === \"string\");\n iModel = arg0;\n topElement = arg1;\n } else {\n iModel = arg0.iModel;\n topElement = arg0.topElement;\n maxPasses = arg0.maxPasses;\n }\n\n maxPasses = maxPasses ?? 5;\n let pass = 0;\n do {\n const del = new ElementTreeDeleter(iModel);\n del.deleteNormalElements(topElement);\n del.deleteSpecialElements();\n } while ((iModel.elements.tryGetElement(topElement) !== undefined) && (++pass < maxPasses));\n}\n\n/** Deletes all element sub-trees that are selected by the supplied filter. Uses ElementSubTreeDeleter.\n * If the filter selects the top element itself, then the entire tree (including the top element) is deleted.\n * That has the same effect as calling [[deleteElementTree]] on the top element.\n * @note The caller may have to call this function multiple times if there are multiple layers of dependencies among definition elements.\n * @param iModel The iModel\n * @param topElement Where to start the search.\n * @param filter Callback that selects sub-trees that should be deleted.\n * @beta\n */\nexport function deleteElementSubTrees(iModel: IModelDb, topElement: Id64String, filter: ElementSubTreeDeleteFilter): void {\n const del = new ElementSubTreeDeleter(iModel, filter);\n del.deleteNormalElementSubTrees(topElement);\n del.deleteSpecialElementSubTrees();\n}\n"]}
|
package/lib/cjs/HubMock.d.ts
CHANGED
|
@@ -81,7 +81,7 @@ export declare class HubMock {
|
|
|
81
81
|
static pushChangeset(arg: IModelIdArg & {
|
|
82
82
|
changesetProps: ChangesetFileProps;
|
|
83
83
|
}): Promise<ChangesetIndex>;
|
|
84
|
-
static queryV2Checkpoint(
|
|
84
|
+
static queryV2Checkpoint(arg: CheckpointProps): Promise<V2CheckpointAccessProps | undefined>;
|
|
85
85
|
static downloadV1Checkpoint(arg: DownloadRequest): Promise<ChangesetIndexAndId>;
|
|
86
86
|
static releaseAllLocks(arg: BriefcaseDbArg): Promise<void>;
|
|
87
87
|
static queryAllLocks(_arg: BriefcaseDbArg): Promise<LockProps[]>;
|
package/lib/cjs/HubMock.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HubMock.d.ts","sourceRoot":"","sources":["../../src/HubMock.ts"],"names":[],"mappings":"AAMA,OAAO,EAAQ,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EACL,kBAAkB,EAAE,cAAc,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Ac,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;WAIzF,aAAa,CAAC,GAAG,EAAE,WAAW,GAAG;QAAE,cAAc,EAAE,kBAAkB,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;WAIjG,iBAAiB,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC;WAarF,oBAAoB,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;WAIxE,eAAe,CAAC,GAAG,EAAE,cAAc;WAKnC,aAAa,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;WAIzD,YAAY,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;WAIhE,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;WAStE,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG;QAAE,OAAO,EAAE,UAAU,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;mBAItE,qBAAqB;CAqB3C"}
|
package/lib/cjs/HubMock.js
CHANGED
|
@@ -12,6 +12,7 @@ const IModelHost_1 = require("./IModelHost");
|
|
|
12
12
|
const IModelJsFs_1 = require("./IModelJsFs");
|
|
13
13
|
const LocalHub_1 = require("./LocalHub");
|
|
14
14
|
const Symbols_1 = require("./internal/Symbols");
|
|
15
|
+
const CloudSqliteMock_1 = require("./test/CloudSqliteMock");
|
|
15
16
|
function wasStarted(val) {
|
|
16
17
|
if (undefined === val)
|
|
17
18
|
throw new Error("Call HubMock.startup first");
|
|
@@ -74,6 +75,7 @@ class HubMock {
|
|
|
74
75
|
this._saveHubAccess = IModelHost_1.IModelHost[Symbols_1._getHubAccess]();
|
|
75
76
|
IModelHost_1.IModelHost[Symbols_1._setHubAccess](this);
|
|
76
77
|
HubMock._iTwinId = core_bentley_1.Guid.createValue(); // all iModels for this test get the same "iTwinId"
|
|
78
|
+
CloudSqliteMock_1.CloudSqliteMock.startup();
|
|
77
79
|
}
|
|
78
80
|
/** Stop a HubMock that was previously started with [[startup]]
|
|
79
81
|
* @note this function throws an exception if any of the iModels used during the tests are left open.
|
|
@@ -81,6 +83,7 @@ class HubMock {
|
|
|
81
83
|
static shutdown() {
|
|
82
84
|
if (this.mockRoot === undefined)
|
|
83
85
|
return;
|
|
86
|
+
CloudSqliteMock_1.CloudSqliteMock.shutdown();
|
|
84
87
|
HubMock._iTwinId = undefined;
|
|
85
88
|
for (const hub of this.hubs)
|
|
86
89
|
hub[1].cleanup();
|
|
@@ -173,8 +176,16 @@ class HubMock {
|
|
|
173
176
|
static async pushChangeset(arg) {
|
|
174
177
|
return this.findLocalHub(arg.iModelId).addChangeset(arg.changesetProps);
|
|
175
178
|
}
|
|
176
|
-
static async queryV2Checkpoint(
|
|
177
|
-
return
|
|
179
|
+
static async queryV2Checkpoint(arg) {
|
|
180
|
+
return {
|
|
181
|
+
accountName: "none",
|
|
182
|
+
sasToken: "none",
|
|
183
|
+
containerId: core_bentley_1.Guid.createValue(),
|
|
184
|
+
dbName: `${arg.changeset.index ?? 0}.bim`,
|
|
185
|
+
storageType: "mock",
|
|
186
|
+
isMock: true,
|
|
187
|
+
checkpoint: arg,
|
|
188
|
+
};
|
|
178
189
|
}
|
|
179
190
|
static async downloadV1Checkpoint(arg) {
|
|
180
191
|
return this.findLocalHub(arg.checkpoint.iModelId).downloadCheckpoint({ changeset: arg.checkpoint.changeset, targetFile: arg.localFile });
|
package/lib/cjs/HubMock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HubMock.js","sourceRoot":"","sources":["../../src/HubMock.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,+BAA4B;AAC5B,sDAAuD;AASvD,2DAAyG;AACzG,6CAA0C;AAC1C,6CAA0C;AAC1C,yCAAsC;AAEtC,g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AAC,CAAC,CAAC;gBAChB,OAAO,CAAC,SAAS,CAAC,CAAC;YACrB,CAAC,EAAE,GAAG,CAAC,CAAC;QACV,CAAC,CAAC,CAAC;IACL,CAAC;;AApNH,0BAqNC","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\nimport { join } from \"path\";\nimport { Guid, GuidString } from \"@itwin/core-bentley\";\nimport {\n ChangesetFileProps, ChangesetIndex, ChangesetIndexAndId, ChangesetProps, ChangesetRange, IModelVersion, LocalDirName,\n} from \"@itwin/core-common\";\nimport {\n AcquireNewBriefcaseIdArg,\n BackendHubAccess, BriefcaseDbArg, BriefcaseIdArg, ChangesetArg, CreateNewIModelProps, DownloadChangesetArg, DownloadChangesetRangeArg, IModelIdArg, IModelNameArg,\n LockMap, LockProps, V2CheckpointAccessProps,\n} from \"./BackendHubAccess\";\nimport { CheckpointProps, DownloadRequest, ProgressFunction, ProgressStatus } from \"./CheckpointManager\";\nimport { IModelHost } from \"./IModelHost\";\nimport { IModelJsFs } from \"./IModelJsFs\";\nimport { LocalHub } from \"./LocalHub\";\nimport { TokenArg } from \"./IModelDb\";\nimport { _getHubAccess, _setHubAccess } from \"./internal/Symbols\";\n\nfunction wasStarted(val: string | undefined): asserts val is string {\n if (undefined === val)\n throw new Error(\"Call HubMock.startup first\");\n}\n\n/**\n * Mocks iModelHub for testing creating Briefcases, downloading checkpoints, and simulating multiple users pushing and pulling changesets, etc.\n *\n * Generally, tests for apis that *create or modify* iModels can and should be mocked. Otherwise they:\n * - create tremendous load on the test servers when they run on programmer's desktops and in CI jobs\n * - waste network and data center resources (i.e. $$$s),\n * - interfere with other tests running on the same or other systems, and\n * - (far worse) are the source of test flakiness outside of the api being tested.\n *\n * This class can be used to create tests that do not require authentication, are synchronous,\n * are guaranteed to be self-contained (i.e. do not interfere with other tests running at the same time or later), and do not fail for reasons outside\n * of the control of the test itself. As a bonus, in addition to making tests more reliable, mocking IModelHub generally makes tests run *much* faster.\n *\n * On the other hand, tests that expect to find an existing iModels, checkpoints, changesets, etc. in IModelHub cannot be mocked. In that case, those tests\n * should be careful to NOT modify the data, since doing so causes interference with other tests running simultaneously. These tests should be limited to\n * low level testing of the core apis only.\n *\n * To initialize HubMock, call [[startup]] at the beginning of your test, usually in `describe.before`. Thereafter, all access to iModelHub for an iModel will be\n * directed to a [[LocalHub]] - your test code does not change. After the test(s) complete, call [[shutdown]] (usually in `describe.after`) to stop mocking IModelHub and clean\n * up any resources used by the test(s). If you want to mock a single test, call [[startup]] as the first line and [[shutdown]] as the last. If you wish to run the\n * test against a \"real\" IModelHub, you can simply comment off the call [[startup]], though in that case you should make sure the name of your\n * iModel is unique so your test won't collide with other tests (iModel name uniqueness is not necessary for mocked tests.)\n *\n * Mocked tests must always start by creating a new iModel via [[IModelHost[_hubAccess].createNewIModel]] with a `version0` iModel.\n * They use mock (aka \"bogus\") credentials for `AccessTokens`, which is fine since [[HubMock]] never accesses resources outside the current\n * computer.\n *\n * @note Only one HubMock at a time, *running in a single process*, may be active. The comments above about multiple simultaneous tests refer to tests\n * running on different computers, or on a single computer in multiple processes. All of those scenarios are problematic without mocking.\n *\n * @internal\n */\nexport class HubMock {\n private static mockRoot: LocalDirName | undefined;\n private static hubs = new Map<string, LocalHub>();\n private static _saveHubAccess: BackendHubAccess | undefined;\n private static _iTwinId: GuidString | undefined;\n\n /** Determine whether a test us currently being run under HubMock */\n public static get isValid() { return undefined !== this.mockRoot; }\n public static get iTwinId() {\n wasStarted(this._iTwinId);\n return this._iTwinId;\n }\n\n /**\n * Begin mocking IModelHub access. After this call, all access to IModelHub will be directed to a [[LocalHub]].\n * @param mockName a unique name (e.g. \"MyTest\") for this HubMock to disambiguate tests when more than one is simultaneously active.\n * It is used to create a private directory used by the HubMock for a test. That directory is removed when [[shutdown]] is called.\n */\n public static startup(mockName: LocalDirName, outputDir: string) {\n if (this.isValid)\n throw new Error(\"Either a previous test did not call HubMock.shutdown() properly, or more than one test is simultaneously attempting to use HubMock, which is not allowed\");\n\n this.hubs.clear();\n this.mockRoot = join(outputDir, \"HubMock\", mockName);\n IModelJsFs.recursiveMkDirSync(this.mockRoot);\n IModelJsFs.purgeDirSync(this.mockRoot);\n this._saveHubAccess = IModelHost[_getHubAccess]();\n\n IModelHost[_setHubAccess](this);\n HubMock._iTwinId = Guid.createValue(); // all iModels for this test get the same \"iTwinId\"\n }\n\n /** Stop a HubMock that was previously started with [[startup]]\n * @note this function throws an exception if any of the iModels used during the tests are left open.\n */\n public static shutdown() {\n if (this.mockRoot === undefined)\n return;\n\n HubMock._iTwinId = undefined;\n for (const hub of this.hubs)\n hub[1].cleanup();\n\n this.hubs.clear();\n IModelJsFs.purgeDirSync(this.mockRoot);\n IModelJsFs.removeSync(this.mockRoot);\n IModelHost[_setHubAccess](this._saveHubAccess);\n this.mockRoot = undefined;\n }\n\n public static findLocalHub(iModelId: GuidString): LocalHub {\n const hub = this.hubs.get(iModelId);\n if (!hub)\n throw new Error(`local hub for iModel ${iModelId} not created`);\n return hub;\n }\n\n /** create a [[LocalHub]] for an iModel. */\n public static async createNewIModel(arg: CreateNewIModelProps): Promise<GuidString> {\n wasStarted(this.mockRoot);\n const props = { ...arg, iModelId: Guid.createValue() };\n const mock = new LocalHub(join(this.mockRoot, props.iModelId), props);\n this.hubs.set(props.iModelId, mock);\n return props.iModelId;\n }\n\n /** remove the [[LocalHub]] for an iModel */\n public static destroy(iModelId: GuidString) {\n this.findLocalHub(iModelId).cleanup();\n this.hubs.delete(iModelId);\n }\n\n /** All methods below are mocks of the [[BackendHubAccess]] interface */\n\n public static async getChangesetFromNamedVersion(arg: IModelIdArg & { versionName: string }): Promise<ChangesetProps> {\n return this.findLocalHub(arg.iModelId).findNamedVersion(arg.versionName);\n }\n\n private static changesetIndexFromArg(arg: ChangesetArg) {\n return (undefined !== arg.changeset.index) ? arg.changeset.index : this.findLocalHub(arg.iModelId).getChangesetIndex(arg.changeset.id);\n }\n\n public static async getChangesetFromVersion(arg: IModelIdArg & { version: IModelVersion }): Promise<ChangesetProps> {\n const hub = this.findLocalHub(arg.iModelId);\n const version = arg.version;\n if (version.isFirst)\n return hub.getChangesetByIndex(0);\n\n const asOf = version.getAsOfChangeSet();\n if (asOf)\n return hub.getChangesetById(asOf);\n\n const versionName = version.getName();\n if (versionName)\n return hub.findNamedVersion(versionName);\n\n return hub.getLatestChangeset();\n }\n\n public static async getLatestChangeset(arg: IModelIdArg): Promise<ChangesetProps> {\n return this.findLocalHub(arg.iModelId).getLatestChangeset();\n }\n\n private static async getAccessToken(arg: TokenArg) {\n return arg.accessToken ?? await IModelHost.getAccessToken();\n }\n\n public static async getMyBriefcaseIds(arg: IModelIdArg): Promise<number[]> {\n const accessToken = await this.getAccessToken(arg);\n return this.findLocalHub(arg.iModelId).getBriefcaseIds(accessToken);\n }\n\n public static async acquireNewBriefcaseId(arg: AcquireNewBriefcaseIdArg): Promise<number> {\n const accessToken = await this.getAccessToken(arg);\n return this.findLocalHub(arg.iModelId).acquireNewBriefcaseId(accessToken, arg.briefcaseAlias);\n }\n\n /** Release a briefcaseId. After this call it is illegal to generate changesets for the released briefcaseId. */\n public static async releaseBriefcase(arg: BriefcaseIdArg): Promise<void> {\n return this.findLocalHub(arg.iModelId).releaseBriefcaseId(arg.briefcaseId);\n }\n\n public static async downloadChangeset(arg: DownloadChangesetArg): Promise<ChangesetFileProps> {\n const changesetProps = this.findLocalHub(arg.iModelId).downloadChangeset({ index: this.changesetIndexFromArg(arg), targetDir: arg.targetDir });\n\n if (arg.progressCallback) {\n const totalSize = IModelJsFs.lstatSync(changesetProps.pathname)?.size;\n if (totalSize)\n await HubMock.mockProgressReporting(arg.progressCallback, totalSize);\n }\n\n return changesetProps;\n }\n\n public static async downloadChangesets(arg: DownloadChangesetRangeArg): Promise<ChangesetFileProps[]> {\n const changesetProps = this.findLocalHub(arg.iModelId).downloadChangesets({ range: arg.range, targetDir: arg.targetDir });\n\n if (arg.progressCallback) {\n const totalSize = changesetProps.reduce((sum, props) => sum + (IModelJsFs.lstatSync(props.pathname)?.size ?? 0), 0);\n await HubMock.mockProgressReporting(arg.progressCallback, totalSize);\n }\n\n return changesetProps;\n }\n\n public static async queryChangeset(arg: ChangesetArg): Promise<ChangesetProps> {\n return this.findLocalHub(arg.iModelId).getChangesetByIndex(this.changesetIndexFromArg(arg));\n }\n\n public static async queryChangesets(arg: IModelIdArg & { range?: ChangesetRange }): Promise<ChangesetProps[]> {\n return this.findLocalHub(arg.iModelId).queryChangesets(arg.range);\n }\n\n public static async pushChangeset(arg: IModelIdArg & { changesetProps: ChangesetFileProps }): Promise<ChangesetIndex> {\n return this.findLocalHub(arg.iModelId).addChangeset(arg.changesetProps);\n }\n\n public static async queryV2Checkpoint(_arg: CheckpointProps): Promise<V2CheckpointAccessProps | undefined> {\n return undefined;\n }\n\n\n public static async downloadV1Checkpoint(arg: DownloadRequest): Promise<ChangesetIndexAndId> {\n return this.findLocalHub(arg.checkpoint.iModelId).downloadCheckpoint({ changeset: arg.checkpoint.changeset, targetFile: arg.localFile });\n }\n\n public static async releaseAllLocks(arg: BriefcaseDbArg) {\n const hub = this.findLocalHub(arg.iModelId);\n hub.releaseAllLocks({ briefcaseId: arg.briefcaseId, changesetIndex: hub.getIndexFromChangeset(arg.changeset) });\n }\n\n public static async queryAllLocks(_arg: BriefcaseDbArg): Promise<LockProps[]> {\n return [];\n }\n\n public static async acquireLocks(arg: BriefcaseDbArg, locks: LockMap): Promise<void> {\n this.findLocalHub(arg.iModelId).acquireLocks(locks, arg);\n }\n\n public static async queryIModelByName(arg: IModelNameArg): Promise<GuidString | undefined> {\n for (const hub of this.hubs) {\n const localHub = hub[1];\n if (localHub.iTwinId === arg.iTwinId && localHub.iModelName === arg.iModelName)\n return localHub.iModelId;\n }\n return undefined;\n }\n\n public static async deleteIModel(arg: IModelIdArg & { iTwinId: GuidString }): Promise<void> {\n return this.destroy(arg.iModelId);\n }\n\n private static async mockProgressReporting(progressCallback: ProgressFunction, totalSize: number): Promise<void> {\n await new Promise((resolve, reject) => {\n let rejected = false;\n\n const mockProgress = (index: number) => {\n const bytesDownloaded = Math.floor(totalSize * (index / 4));\n if (!rejected && progressCallback(bytesDownloaded, totalSize) === ProgressStatus.Abort){\n rejected = true;\n reject(new Error(\"AbortError\"));\n }\n };\n\n mockProgress(1);\n setTimeout(() => mockProgress(2), 50);\n setTimeout(() => mockProgress(3), 100);\n setTimeout(() => {\n mockProgress(4);\n resolve(undefined);\n }, 150);\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"HubMock.js","sourceRoot":"","sources":["../../src/HubMock.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,+BAA4B;AAC5B,sDAAuD;AASvD,2DAAyG;AACzG,6CAA0C;AAC1C,6CAA0C;AAC1C,yCAAsC;AAEtC,gDAAkE;AAClE,4DAAyD;AAEzD,SAAS,UAAU,CAAC,GAAuB;IACzC,IAAI,SAAS,KAAK,GAAG;QACnB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAa,OAAO;IACV,MAAM,CAAC,QAAQ,CAA2B;IAC1C,MAAM,CAAC,IAAI,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC1C,MAAM,CAAC,cAAc,CAA+B;IACpD,MAAM,CAAC,QAAQ,CAAyB;IAEhD,oEAAoE;IAC7D,MAAM,KAAK,OAAO,KAAK,OAAO,SAAS,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC5D,MAAM,KAAK,OAAO;QACvB,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,OAAO,CAAC,QAAsB,EAAE,SAAiB;QAC7D,IAAI,I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0C;QACzE,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IAEO,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,gBAAkC,EAAE,SAAiB;QAC9F,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACpC,IAAI,QAAQ,GAAG,KAAK,CAAC;YAErB,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,EAAE;gBACrC,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;gBAC5D,IAAI,CAAC,QAAQ,IAAI,gBAAgB,CAAC,eAAe,EAAE,SAAS,CAAC,KAAK,kCAAc,CAAC,KAAK,EAAC,CAAC;oBACtF,QAAQ,GAAG,IAAI,CAAC;oBAChB,MAAM,CAAC,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;gBAClC,CAAC;YACH,CAAC,CAAC;YAEF,YAAY,CAAC,CAAC,CAAC,CAAC;YAChB,UAAU,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACtC,UAAU,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;YACvC,UAAU,CAAC,GAAG,EAAE;gBACd,YAAY,CAAC,CAAC,CAAC,CAAC;gBAChB,OAAO,CAAC,SAAS,CAAC,CAAC;YACrB,CAAC,EAAE,GAAG,CAAC,CAAC;QACV,CAAC,CAAC,CAAC;IACL,CAAC;;AA9NH,0BA+NC","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\nimport { join } from \"path\";\nimport { Guid, GuidString } from \"@itwin/core-bentley\";\nimport {\n ChangesetFileProps, ChangesetIndex, ChangesetIndexAndId, ChangesetProps, ChangesetRange, IModelVersion, LocalDirName,\n} from \"@itwin/core-common\";\nimport {\n AcquireNewBriefcaseIdArg,\n BackendHubAccess, BriefcaseDbArg, BriefcaseIdArg, ChangesetArg, CreateNewIModelProps, DownloadChangesetArg, DownloadChangesetRangeArg, IModelIdArg, IModelNameArg,\n LockMap, LockProps, V2CheckpointAccessProps,\n} from \"./BackendHubAccess\";\nimport { CheckpointProps, DownloadRequest, ProgressFunction, ProgressStatus } from \"./CheckpointManager\";\nimport { IModelHost } from \"./IModelHost\";\nimport { IModelJsFs } from \"./IModelJsFs\";\nimport { LocalHub } from \"./LocalHub\";\nimport { TokenArg } from \"./IModelDb\";\nimport { _getHubAccess, _setHubAccess } from \"./internal/Symbols\";\nimport { CloudSqliteMock } from \"./test/CloudSqliteMock\";\n\nfunction wasStarted(val: string | undefined): asserts val is string {\n if (undefined === val)\n throw new Error(\"Call HubMock.startup first\");\n}\n\n/**\n * Mocks iModelHub for testing creating Briefcases, downloading checkpoints, and simulating multiple users pushing and pulling changesets, etc.\n *\n * Generally, tests for apis that *create or modify* iModels can and should be mocked. Otherwise they:\n * - create tremendous load on the test servers when they run on programmer's desktops and in CI jobs\n * - waste network and data center resources (i.e. $$$s),\n * - interfere with other tests running on the same or other systems, and\n * - (far worse) are the source of test flakiness outside of the api being tested.\n *\n * This class can be used to create tests that do not require authentication, are synchronous,\n * are guaranteed to be self-contained (i.e. do not interfere with other tests running at the same time or later), and do not fail for reasons outside\n * of the control of the test itself. As a bonus, in addition to making tests more reliable, mocking IModelHub generally makes tests run *much* faster.\n *\n * On the other hand, tests that expect to find an existing iModels, checkpoints, changesets, etc. in IModelHub cannot be mocked. In that case, those tests\n * should be careful to NOT modify the data, since doing so causes interference with other tests running simultaneously. These tests should be limited to\n * low level testing of the core apis only.\n *\n * To initialize HubMock, call [[startup]] at the beginning of your test, usually in `describe.before`. Thereafter, all access to iModelHub for an iModel will be\n * directed to a [[LocalHub]] - your test code does not change. After the test(s) complete, call [[shutdown]] (usually in `describe.after`) to stop mocking IModelHub and clean\n * up any resources used by the test(s). If you want to mock a single test, call [[startup]] as the first line and [[shutdown]] as the last. If you wish to run the\n * test against a \"real\" IModelHub, you can simply comment off the call [[startup]], though in that case you should make sure the name of your\n * iModel is unique so your test won't collide with other tests (iModel name uniqueness is not necessary for mocked tests.)\n *\n * Mocked tests must always start by creating a new iModel via [[IModelHost[_hubAccess].createNewIModel]] with a `version0` iModel.\n * They use mock (aka \"bogus\") credentials for `AccessTokens`, which is fine since [[HubMock]] never accesses resources outside the current\n * computer.\n *\n * @note Only one HubMock at a time, *running in a single process*, may be active. The comments above about multiple simultaneous tests refer to tests\n * running on different computers, or on a single computer in multiple processes. All of those scenarios are problematic without mocking.\n *\n * @internal\n */\nexport class HubMock {\n private static mockRoot: LocalDirName | undefined;\n private static hubs = new Map<string, LocalHub>();\n private static _saveHubAccess: BackendHubAccess | undefined;\n private static _iTwinId: GuidString | undefined;\n\n /** Determine whether a test us currently being run under HubMock */\n public static get isValid() { return undefined !== this.mockRoot; }\n public static get iTwinId() {\n wasStarted(this._iTwinId);\n return this._iTwinId;\n }\n\n /**\n * Begin mocking IModelHub access. After this call, all access to IModelHub will be directed to a [[LocalHub]].\n * @param mockName a unique name (e.g. \"MyTest\") for this HubMock to disambiguate tests when more than one is simultaneously active.\n * It is used to create a private directory used by the HubMock for a test. That directory is removed when [[shutdown]] is called.\n */\n public static startup(mockName: LocalDirName, outputDir: string) {\n if (this.isValid)\n throw new Error(\"Either a previous test did not call HubMock.shutdown() properly, or more than one test is simultaneously attempting to use HubMock, which is not allowed\");\n\n this.hubs.clear();\n this.mockRoot = join(outputDir, \"HubMock\", mockName);\n IModelJsFs.recursiveMkDirSync(this.mockRoot);\n IModelJsFs.purgeDirSync(this.mockRoot);\n this._saveHubAccess = IModelHost[_getHubAccess]();\n\n IModelHost[_setHubAccess](this);\n HubMock._iTwinId = Guid.createValue(); // all iModels for this test get the same \"iTwinId\"\n CloudSqliteMock.startup();\n }\n\n /** Stop a HubMock that was previously started with [[startup]]\n * @note this function throws an exception if any of the iModels used during the tests are left open.\n */\n public static shutdown() {\n if (this.mockRoot === undefined)\n return;\n\n CloudSqliteMock.shutdown();\n HubMock._iTwinId = undefined;\n for (const hub of this.hubs)\n hub[1].cleanup();\n\n this.hubs.clear();\n IModelJsFs.purgeDirSync(this.mockRoot);\n IModelJsFs.removeSync(this.mockRoot);\n IModelHost[_setHubAccess](this._saveHubAccess);\n this.mockRoot = undefined;\n }\n\n public static findLocalHub(iModelId: GuidString): LocalHub {\n const hub = this.hubs.get(iModelId);\n if (!hub)\n throw new Error(`local hub for iModel ${iModelId} not created`);\n return hub;\n }\n\n /** create a [[LocalHub]] for an iModel. */\n public static async createNewIModel(arg: CreateNewIModelProps): Promise<GuidString> {\n wasStarted(this.mockRoot);\n const props = { ...arg, iModelId: Guid.createValue() };\n const mock = new LocalHub(join(this.mockRoot, props.iModelId), props);\n this.hubs.set(props.iModelId, mock);\n return props.iModelId;\n }\n\n /** remove the [[LocalHub]] for an iModel */\n public static destroy(iModelId: GuidString) {\n this.findLocalHub(iModelId).cleanup();\n this.hubs.delete(iModelId);\n }\n\n /** All methods below are mocks of the [[BackendHubAccess]] interface */\n\n public static async getChangesetFromNamedVersion(arg: IModelIdArg & { versionName: string }): Promise<ChangesetProps> {\n return this.findLocalHub(arg.iModelId).findNamedVersion(arg.versionName);\n }\n\n private static changesetIndexFromArg(arg: ChangesetArg) {\n return (undefined !== arg.changeset.index) ? arg.changeset.index : this.findLocalHub(arg.iModelId).getChangesetIndex(arg.changeset.id);\n }\n\n public static async getChangesetFromVersion(arg: IModelIdArg & { version: IModelVersion }): Promise<ChangesetProps> {\n const hub = this.findLocalHub(arg.iModelId);\n const version = arg.version;\n if (version.isFirst)\n return hub.getChangesetByIndex(0);\n\n const asOf = version.getAsOfChangeSet();\n if (asOf)\n return hub.getChangesetById(asOf);\n\n const versionName = version.getName();\n if (versionName)\n return hub.findNamedVersion(versionName);\n\n return hub.getLatestChangeset();\n }\n\n public static async getLatestChangeset(arg: IModelIdArg): Promise<ChangesetProps> {\n return this.findLocalHub(arg.iModelId).getLatestChangeset();\n }\n\n private static async getAccessToken(arg: TokenArg) {\n return arg.accessToken ?? await IModelHost.getAccessToken();\n }\n\n public static async getMyBriefcaseIds(arg: IModelIdArg): Promise<number[]> {\n const accessToken = await this.getAccessToken(arg);\n return this.findLocalHub(arg.iModelId).getBriefcaseIds(accessToken);\n }\n\n public static async acquireNewBriefcaseId(arg: AcquireNewBriefcaseIdArg): Promise<number> {\n const accessToken = await this.getAccessToken(arg);\n return this.findLocalHub(arg.iModelId).acquireNewBriefcaseId(accessToken, arg.briefcaseAlias);\n }\n\n /** Release a briefcaseId. After this call it is illegal to generate changesets for the released briefcaseId. */\n public static async releaseBriefcase(arg: BriefcaseIdArg): Promise<void> {\n return this.findLocalHub(arg.iModelId).releaseBriefcaseId(arg.briefcaseId);\n }\n\n public static async downloadChangeset(arg: DownloadChangesetArg): Promise<ChangesetFileProps> {\n const changesetProps = this.findLocalHub(arg.iModelId).downloadChangeset({ index: this.changesetIndexFromArg(arg), targetDir: arg.targetDir });\n\n if (arg.progressCallback) {\n const totalSize = IModelJsFs.lstatSync(changesetProps.pathname)?.size;\n if (totalSize)\n await HubMock.mockProgressReporting(arg.progressCallback, totalSize);\n }\n\n return changesetProps;\n }\n\n public static async downloadChangesets(arg: DownloadChangesetRangeArg): Promise<ChangesetFileProps[]> {\n const changesetProps = this.findLocalHub(arg.iModelId).downloadChangesets({ range: arg.range, targetDir: arg.targetDir });\n\n if (arg.progressCallback) {\n const totalSize = changesetProps.reduce((sum, props) => sum + (IModelJsFs.lstatSync(props.pathname)?.size ?? 0), 0);\n await HubMock.mockProgressReporting(arg.progressCallback, totalSize);\n }\n\n return changesetProps;\n }\n\n public static async queryChangeset(arg: ChangesetArg): Promise<ChangesetProps> {\n return this.findLocalHub(arg.iModelId).getChangesetByIndex(this.changesetIndexFromArg(arg));\n }\n\n public static async queryChangesets(arg: IModelIdArg & { range?: ChangesetRange }): Promise<ChangesetProps[]> {\n return this.findLocalHub(arg.iModelId).queryChangesets(arg.range);\n }\n\n public static async pushChangeset(arg: IModelIdArg & { changesetProps: ChangesetFileProps }): Promise<ChangesetIndex> {\n return this.findLocalHub(arg.iModelId).addChangeset(arg.changesetProps);\n }\n\n public static async queryV2Checkpoint(arg: CheckpointProps): Promise<V2CheckpointAccessProps | undefined> {\n return {\n accountName: \"none\",\n sasToken: \"none\",\n containerId: Guid.createValue(),\n dbName: `${arg.changeset.index ?? 0}.bim`,\n storageType: \"mock\",\n isMock: true,\n checkpoint: arg,\n } as V2CheckpointAccessProps;\n }\n\n\n public static async downloadV1Checkpoint(arg: DownloadRequest): Promise<ChangesetIndexAndId> {\n return this.findLocalHub(arg.checkpoint.iModelId).downloadCheckpoint({ changeset: arg.checkpoint.changeset, targetFile: arg.localFile });\n }\n\n public static async releaseAllLocks(arg: BriefcaseDbArg) {\n const hub = this.findLocalHub(arg.iModelId);\n hub.releaseAllLocks({ briefcaseId: arg.briefcaseId, changesetIndex: hub.getIndexFromChangeset(arg.changeset) });\n }\n\n public static async queryAllLocks(_arg: BriefcaseDbArg): Promise<LockProps[]> {\n return [];\n }\n\n public static async acquireLocks(arg: BriefcaseDbArg, locks: LockMap): Promise<void> {\n this.findLocalHub(arg.iModelId).acquireLocks(locks, arg);\n }\n\n public static async queryIModelByName(arg: IModelNameArg): Promise<GuidString | undefined> {\n for (const hub of this.hubs) {\n const localHub = hub[1];\n if (localHub.iTwinId === arg.iTwinId && localHub.iModelName === arg.iModelName)\n return localHub.iModelId;\n }\n return undefined;\n }\n\n public static async deleteIModel(arg: IModelIdArg & { iTwinId: GuidString }): Promise<void> {\n return this.destroy(arg.iModelId);\n }\n\n private static async mockProgressReporting(progressCallback: ProgressFunction, totalSize: number): Promise<void> {\n await new Promise((resolve, reject) => {\n let rejected = false;\n\n const mockProgress = (index: number) => {\n const bytesDownloaded = Math.floor(totalSize * (index / 4));\n if (!rejected && progressCallback(bytesDownloaded, totalSize) === ProgressStatus.Abort){\n rejected = true;\n reject(new Error(\"AbortError\"));\n }\n };\n\n mockProgress(1);\n setTimeout(() => mockProgress(2), 50);\n setTimeout(() => mockProgress(3), 100);\n setTimeout(() => {\n mockProgress(4);\n resolve(undefined);\n }, 150);\n });\n }\n}\n"]}
|
package/lib/cjs/IModelDb.d.ts
CHANGED
|
@@ -291,6 +291,7 @@ export declare abstract class IModelDb extends IModel {
|
|
|
291
291
|
* @returns the value returned by `callback`.
|
|
292
292
|
* @see [[withStatement]]
|
|
293
293
|
* @public
|
|
294
|
+
* @deprecated in 4.11. Use [[createQueryReader]] instead.
|
|
294
295
|
*/
|
|
295
296
|
withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors?: boolean): T;
|
|
296
297
|
/**
|
|
@@ -303,6 +304,7 @@ export declare abstract class IModelDb extends IModel {
|
|
|
303
304
|
* @returns the value returned by `callback`.
|
|
304
305
|
* @see [[withPreparedStatement]]
|
|
305
306
|
* @public
|
|
307
|
+
* @deprecated in 4.11. Use [[createQueryReader]] instead.
|
|
306
308
|
*/
|
|
307
309
|
withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors?: boolean): T;
|
|
308
310
|
/** Allow to execute query and read results along with meta data. The result are streamed.
|
|
@@ -510,11 +512,13 @@ export declare abstract class IModelDb extends IModel {
|
|
|
510
512
|
* @param sql The ECSQL statement to prepare
|
|
511
513
|
* @param logErrors Determines if error will be logged if statement fail to prepare
|
|
512
514
|
* @throws [[IModelError]] if there is a problem preparing the statement.
|
|
515
|
+
* @deprecated in 4.11. Use [IModelDb.createQueryReader]($backend) or [ECDb.createQueryReader]($backend) to query.
|
|
513
516
|
*/
|
|
514
517
|
prepareStatement(sql: string, logErrors?: boolean): ECSqlStatement;
|
|
515
518
|
/** Prepare an ECSQL statement.
|
|
516
519
|
* @param sql The ECSQL statement to prepare
|
|
517
520
|
* @returns `undefined` if there is a problem preparing the statement.
|
|
521
|
+
* @deprecated in 4.11. Use [IModelDb.createQueryReader]($backend) or [ECDb.createQueryReader]($backend) to query.
|
|
518
522
|
*/
|
|
519
523
|
tryPrepareStatement(sql: string): ECSqlStatement | undefined;
|
|
520
524
|
/** Construct an entity (Element or Model) from an iModel.
|