@itwin/core-backend 5.1.0-dev.3 → 5.1.0-dev.4
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/Category.d.ts +37 -0
- package/lib/cjs/Category.d.ts.map +1 -1
- package/lib/cjs/Category.js +73 -0
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/DisplayStyle.d.ts +5 -0
- package/lib/cjs/DisplayStyle.d.ts.map +1 -1
- package/lib/cjs/DisplayStyle.js +27 -0
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/Element.d.ts +166 -10
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +510 -9
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/Entity.d.ts +41 -1
- package/lib/cjs/Entity.d.ts.map +1 -1
- package/lib/cjs/Entity.js +58 -0
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +19 -36
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +129 -69
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +13 -0
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +6 -0
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/Material.d.ts +19 -0
- package/lib/cjs/Material.d.ts.map +1 -1
- package/lib/cjs/Material.js +29 -0
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.d.ts +42 -6
- package/lib/cjs/Model.d.ts.map +1 -1
- package/lib/cjs/Model.js +93 -5
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +1 -0
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts +100 -0
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +208 -0
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/ViewStateHydrator.js +3 -3
- package/lib/cjs/ViewStateHydrator.js.map +1 -1
- package/lib/cjs/internal/ElementLRUCache.d.ts +28 -0
- package/lib/cjs/internal/ElementLRUCache.d.ts.map +1 -0
- package/lib/cjs/internal/ElementLRUCache.js +120 -0
- package/lib/cjs/internal/ElementLRUCache.js.map +1 -0
- package/lib/cjs/internal/Symbols.d.ts +1 -0
- package/lib/cjs/internal/Symbols.d.ts.map +1 -1
- package/lib/cjs/internal/Symbols.js +2 -1
- package/lib/cjs/internal/Symbols.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +2 -2
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/esm/Category.d.ts +37 -0
- package/lib/esm/Category.d.ts.map +1 -1
- package/lib/esm/Category.js +73 -0
- package/lib/esm/Category.js.map +1 -1
- package/lib/esm/DisplayStyle.d.ts +5 -0
- package/lib/esm/DisplayStyle.d.ts.map +1 -1
- package/lib/esm/DisplayStyle.js +27 -0
- package/lib/esm/DisplayStyle.js.map +1 -1
- package/lib/esm/Element.d.ts +166 -10
- package/lib/esm/Element.d.ts.map +1 -1
- package/lib/esm/Element.js +513 -12
- package/lib/esm/Element.js.map +1 -1
- package/lib/esm/Entity.d.ts +41 -1
- package/lib/esm/Entity.d.ts.map +1 -1
- package/lib/esm/Entity.js +58 -0
- package/lib/esm/Entity.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +19 -36
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +132 -72
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/IModelHost.d.ts +13 -0
- package/lib/esm/IModelHost.d.ts.map +1 -1
- package/lib/esm/IModelHost.js +6 -0
- package/lib/esm/IModelHost.js.map +1 -1
- package/lib/esm/Material.d.ts +19 -0
- package/lib/esm/Material.d.ts.map +1 -1
- package/lib/esm/Material.js +30 -1
- package/lib/esm/Material.js.map +1 -1
- package/lib/esm/Model.d.ts +42 -6
- package/lib/esm/Model.d.ts.map +1 -1
- package/lib/esm/Model.js +94 -6
- package/lib/esm/Model.js.map +1 -1
- package/lib/esm/TxnManager.d.ts.map +1 -1
- package/lib/esm/TxnManager.js +1 -0
- package/lib/esm/TxnManager.js.map +1 -1
- package/lib/esm/ViewDefinition.d.ts +100 -0
- package/lib/esm/ViewDefinition.d.ts.map +1 -1
- package/lib/esm/ViewDefinition.js +209 -1
- package/lib/esm/ViewDefinition.js.map +1 -1
- package/lib/esm/ViewStateHydrator.js +3 -3
- package/lib/esm/ViewStateHydrator.js.map +1 -1
- package/lib/esm/internal/ElementLRUCache.d.ts +28 -0
- package/lib/esm/internal/ElementLRUCache.d.ts.map +1 -0
- package/lib/esm/internal/ElementLRUCache.js +116 -0
- package/lib/esm/internal/ElementLRUCache.js.map +1 -0
- package/lib/esm/internal/Symbols.d.ts +1 -0
- package/lib/esm/internal/Symbols.d.ts.map +1 -1
- package/lib/esm/internal/Symbols.js +1 -0
- package/lib/esm/internal/Symbols.js.map +1 -1
- package/lib/esm/rpc-impl/IModelReadRpcImpl.js +2 -2
- package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/esm/test/ElementLRUCache.test.d.ts +2 -0
- package/lib/esm/test/ElementLRUCache.test.d.ts.map +1 -0
- package/lib/esm/test/ElementLRUCache.test.js +212 -0
- package/lib/esm/test/ElementLRUCache.test.js.map +1 -0
- package/lib/esm/test/ecdb/ECSqlQuery.test.js +0 -23
- package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -1
- package/lib/esm/test/imodel/IModel.test.js +22 -11
- package/lib/esm/test/imodel/IModel.test.js.map +1 -1
- package/lib/esm/test/standalone/SnapshotDb.test.js +1 -0
- package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
- package/lib/esm/test/standalone/TxnManager.test.js +1 -1
- package/lib/esm/test/standalone/TxnManager.test.js.map +1 -1
- package/package.json +12 -12
package/lib/esm/IModelDb.js
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
import * as fs from "fs";
|
|
9
9
|
import { join } from "path";
|
|
10
10
|
import * as touch from "touch";
|
|
11
|
-
import { assert, BeEvent, BentleyStatus, ChangeSetStatus, DbChangeStage, DbConflictCause, DbConflictResolution, DbResult, Guid, Id64, IModelStatus, JsonUtils, Logger, LogLevel,
|
|
12
|
-
import { BriefcaseIdValue, Code, DomainOptions, ECJsNames, ECSqlReader, EntityMetaData, FontMap, IModel, IModelError, IModelNotFoundResponse, ProfileOptions, QueryRowFormat, SchemaState, ViewStoreRpc
|
|
11
|
+
import { assert, BeEvent, BentleyStatus, ChangeSetStatus, DbChangeStage, DbConflictCause, DbConflictResolution, DbResult, Guid, Id64, IModelStatus, JsonUtils, Logger, LogLevel, LRUMap, OpenMode } from "@itwin/core-bentley";
|
|
12
|
+
import { BriefcaseIdValue, Code, DomainOptions, ECJsNames, ECSqlReader, EntityMetaData, FontMap, IModel, IModelError, IModelNotFoundResponse, ProfileOptions, QueryRowFormat, SchemaState, ViewStoreRpc } from "@itwin/core-common";
|
|
13
13
|
import { Range2d, Range3d } from "@itwin/core-geometry";
|
|
14
14
|
import { BackendLoggerCategory } from "./BackendLoggerCategory";
|
|
15
15
|
import { BriefcaseManager } from "./BriefcaseManager";
|
|
@@ -44,9 +44,10 @@ import { SettingsImpl } from "./internal/workspace/SettingsImpl";
|
|
|
44
44
|
import { IModelNative } from "./internal/NativePlatform";
|
|
45
45
|
import { createNoOpLockControl } from "./internal/NoLocks";
|
|
46
46
|
import { createIModelDbFonts } from "./internal/IModelDbFontsImpl";
|
|
47
|
-
import { _close, _hubAccess, _nativeDb, _releaseAllLocks } from "./internal/Symbols";
|
|
47
|
+
import { _cache, _close, _hubAccess, _nativeDb, _releaseAllLocks } from "./internal/Symbols";
|
|
48
48
|
import { SchemaContext, SchemaJsonLocater } from "@itwin/ecschema-metadata";
|
|
49
49
|
import { SchemaMap } from "./Schema";
|
|
50
|
+
import { ElementLRUCache } from "./internal/ElementLRUCache";
|
|
50
51
|
// spell:ignore fontid fontmap
|
|
51
52
|
const loggerCategory = BackendLoggerCategory.IModelDb;
|
|
52
53
|
/** @internal */
|
|
@@ -576,6 +577,8 @@ export class IModelDb extends IModel {
|
|
|
576
577
|
this._jsClassMap = undefined;
|
|
577
578
|
this._schemaMap = undefined;
|
|
578
579
|
this._schemaContext = undefined;
|
|
580
|
+
this.elements[_cache].clear();
|
|
581
|
+
this.models[_cache].clear();
|
|
579
582
|
}
|
|
580
583
|
/** Update the project extents for this iModel.
|
|
581
584
|
* <p><em>Example:</em>
|
|
@@ -976,6 +979,24 @@ export class IModelDb extends IModel {
|
|
|
976
979
|
return ClassRegistry.getClass(classFullName, this);
|
|
977
980
|
}
|
|
978
981
|
}
|
|
982
|
+
/** Constructs a ResolveInstanceKeyArgs from given parameters
|
|
983
|
+
* @throws [[IModelError]] if the combination of supplied parameters is invalid.
|
|
984
|
+
* @internal
|
|
985
|
+
*/
|
|
986
|
+
getInstanceArgs(instanceId, baseClassName, federationGuid, code) {
|
|
987
|
+
if (instanceId && baseClassName) {
|
|
988
|
+
return { partialKey: { id: instanceId, baseClassName } };
|
|
989
|
+
}
|
|
990
|
+
else if (federationGuid) {
|
|
991
|
+
return { federationGuid };
|
|
992
|
+
}
|
|
993
|
+
else if (code) {
|
|
994
|
+
return { code };
|
|
995
|
+
}
|
|
996
|
+
else {
|
|
997
|
+
throw new IModelError(IModelStatus.InvalidId, "Either instanceId and baseClassName or federationGuid or code must be specified");
|
|
998
|
+
}
|
|
999
|
+
}
|
|
979
1000
|
/** Get metadata for a class. This method will load the metadata from the iModel into the cache as a side-effect, if necessary.
|
|
980
1001
|
* @throws [[IModelError]] if the metadata cannot be found nor loaded.
|
|
981
1002
|
* @deprecated in 5.0. Please use `getSchemaItem` from `SchemaContext` class instead.
|
|
@@ -1458,6 +1479,8 @@ function processSchemaWriteStatus(status) {
|
|
|
1458
1479
|
class Models {
|
|
1459
1480
|
_iModel;
|
|
1460
1481
|
/** @internal */
|
|
1482
|
+
[_cache] = new LRUMap(500);
|
|
1483
|
+
/** @internal */
|
|
1461
1484
|
constructor(_iModel) {
|
|
1462
1485
|
this._iModel = _iModel;
|
|
1463
1486
|
}
|
|
@@ -1467,7 +1490,10 @@ function processSchemaWriteStatus(status) {
|
|
|
1467
1490
|
* @see tryGetModelProps
|
|
1468
1491
|
*/
|
|
1469
1492
|
getModelProps(id) {
|
|
1470
|
-
|
|
1493
|
+
const model = this.tryGetModelProps(id);
|
|
1494
|
+
if (undefined === model)
|
|
1495
|
+
throw new IModelError(IModelStatus.NotFound, `Model=${id}`);
|
|
1496
|
+
return model;
|
|
1471
1497
|
}
|
|
1472
1498
|
/** Get the ModelProps with the specified identifier.
|
|
1473
1499
|
* @param modelId The Model identifier.
|
|
@@ -1477,7 +1503,25 @@ function processSchemaWriteStatus(status) {
|
|
|
1477
1503
|
* @see getModelProps
|
|
1478
1504
|
*/
|
|
1479
1505
|
tryGetModelProps(id) {
|
|
1480
|
-
|
|
1506
|
+
try {
|
|
1507
|
+
if (IModelHost.configuration?.disableThinnedNativeInstanceWorkflow) {
|
|
1508
|
+
return this._iModel[_nativeDb].getModel({ id });
|
|
1509
|
+
}
|
|
1510
|
+
const cachedMdl = this[_cache].get(id);
|
|
1511
|
+
if (cachedMdl) {
|
|
1512
|
+
return cachedMdl;
|
|
1513
|
+
}
|
|
1514
|
+
const options = { useJsNames: true };
|
|
1515
|
+
const instanceKey = this.resolveModelKey({ id });
|
|
1516
|
+
const rawInstance = this._iModel[_nativeDb].readInstance(instanceKey, options);
|
|
1517
|
+
const classDef = this._iModel.getJsClass(rawInstance.classFullName);
|
|
1518
|
+
const modelProps = classDef.deserialize({ row: rawInstance, iModel: this._iModel });
|
|
1519
|
+
this[_cache].set(id, modelProps);
|
|
1520
|
+
return modelProps;
|
|
1521
|
+
}
|
|
1522
|
+
catch {
|
|
1523
|
+
return undefined;
|
|
1524
|
+
}
|
|
1481
1525
|
}
|
|
1482
1526
|
/** Query for the last modified time for a [[Model]].
|
|
1483
1527
|
* @param modelId The Id of the model.
|
|
@@ -1524,32 +1568,22 @@ function processSchemaWriteStatus(status) {
|
|
|
1524
1568
|
return model; // modelClass was not specified, cannot call instanceof to validate
|
|
1525
1569
|
return model instanceof modelClass ? model : undefined;
|
|
1526
1570
|
}
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
* @internal
|
|
1533
|
-
*/
|
|
1534
|
-
getModelJson(modelIdArg) {
|
|
1535
|
-
const modelJson = this.tryGetModelJson(modelIdArg);
|
|
1536
|
-
if (undefined === modelJson) {
|
|
1537
|
-
throw new IModelError(IModelStatus.NotFound, `Model=(id: ${modelIdArg.id}, code: ${modelIdArg.code})`);
|
|
1571
|
+
resolveModelKey(modelIdArg) {
|
|
1572
|
+
const baseClassName = "BisCore:Model";
|
|
1573
|
+
let args;
|
|
1574
|
+
if (modelIdArg.id) {
|
|
1575
|
+
args = { partialKey: { id: modelIdArg.id, baseClassName } };
|
|
1538
1576
|
}
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
* @see getModelJson
|
|
1545
|
-
*/
|
|
1546
|
-
tryGetModelJson(modelIdArg) {
|
|
1547
|
-
try {
|
|
1548
|
-
return this._iModel[_nativeDb].getModel(modelIdArg);
|
|
1577
|
+
else if (modelIdArg.code) {
|
|
1578
|
+
const modelId = this._iModel.elements.getElementProps({ code: modelIdArg.code }).id;
|
|
1579
|
+
if (!modelId)
|
|
1580
|
+
throw new IModelError(IModelStatus.NotFound, `Model not found with code: [spec:${modelIdArg.code.spec}, scope:${modelIdArg.code.scope}, value:${modelIdArg.code.value}])`);
|
|
1581
|
+
args = { partialKey: { id: modelId, baseClassName } };
|
|
1549
1582
|
}
|
|
1550
|
-
|
|
1551
|
-
|
|
1583
|
+
else {
|
|
1584
|
+
throw new IModelError(IModelStatus.InvalidId, `Invalid model identifier: ${JSON.stringify(modelIdArg)}`);
|
|
1552
1585
|
}
|
|
1586
|
+
return this._iModel[_nativeDb].resolveInstanceKey(args);
|
|
1553
1587
|
}
|
|
1554
1588
|
/** Get the sub-model of the specified Element.
|
|
1555
1589
|
* See [[IModelDb.Elements.queryElementIdByCode]] for more on how to find an element by Code.
|
|
@@ -1602,6 +1636,8 @@ function processSchemaWriteStatus(status) {
|
|
|
1602
1636
|
*/
|
|
1603
1637
|
updateModel(props) {
|
|
1604
1638
|
try {
|
|
1639
|
+
if (props.id)
|
|
1640
|
+
this[_cache].delete(props.id);
|
|
1605
1641
|
this._iModel[_nativeDb].updateModel(props);
|
|
1606
1642
|
}
|
|
1607
1643
|
catch (err) {
|
|
@@ -1618,6 +1654,7 @@ function processSchemaWriteStatus(status) {
|
|
|
1618
1654
|
* @see [[TxnManager.onModelGeometryChanged]] for the event emitted in response to such a change.
|
|
1619
1655
|
*/
|
|
1620
1656
|
updateGeometryGuid(modelId) {
|
|
1657
|
+
this._iModel.models[_cache].delete(modelId);
|
|
1621
1658
|
const error = this._iModel[_nativeDb].updateModelGeometryGuid(modelId);
|
|
1622
1659
|
if (error !== IModelStatus.Success)
|
|
1623
1660
|
throw new IModelError(error, `updating geometry guid for model ${modelId}`);
|
|
@@ -1629,6 +1666,7 @@ function processSchemaWriteStatus(status) {
|
|
|
1629
1666
|
deleteModel(ids) {
|
|
1630
1667
|
Id64.toIdSet(ids).forEach((id) => {
|
|
1631
1668
|
try {
|
|
1669
|
+
this[_cache].delete(id);
|
|
1632
1670
|
this._iModel[_nativeDb].deleteModel(id);
|
|
1633
1671
|
}
|
|
1634
1672
|
catch (err) {
|
|
@@ -1667,6 +1705,8 @@ function processSchemaWriteStatus(status) {
|
|
|
1667
1705
|
class Elements {
|
|
1668
1706
|
_iModel;
|
|
1669
1707
|
/** @internal */
|
|
1708
|
+
[_cache] = new ElementLRUCache();
|
|
1709
|
+
/** @internal */
|
|
1670
1710
|
constructor(_iModel) {
|
|
1671
1711
|
this._iModel = _iModel;
|
|
1672
1712
|
}
|
|
@@ -1682,50 +1722,40 @@ function processSchemaWriteStatus(status) {
|
|
|
1682
1722
|
return !stmt.nextRow() ? undefined : stmt.getValueId(0);
|
|
1683
1723
|
}) : undefined;
|
|
1684
1724
|
}
|
|
1685
|
-
/** Read element data from the iModel as JSON
|
|
1686
|
-
* @param elementIdArg a json string with the identity of the element to load. Must have one of "id", "federationGuid", or "code".
|
|
1687
|
-
* @returns The JSON properties of the element.
|
|
1688
|
-
* @throws [[IModelError]] if the element is not found or cannot be loaded.
|
|
1689
|
-
* @see tryGetElementJson
|
|
1690
|
-
* @internal
|
|
1691
|
-
*/
|
|
1692
|
-
getElementJson(elementId) {
|
|
1693
|
-
const elementProps = this.tryGetElementJson(elementId);
|
|
1694
|
-
if (undefined === elementProps)
|
|
1695
|
-
throw new IModelError(IModelStatus.NotFound, `reading element={id: ${elementId.id} federationGuid: ${elementId.federationGuid}, code: ${elementId.code}}`);
|
|
1696
|
-
return elementProps;
|
|
1697
|
-
}
|
|
1698
|
-
/** Read element data from the iModel as JSON
|
|
1699
|
-
* @param loadProps - a json string with the identity of the element to load. Must have one of "id", "federationGuid", or "code".
|
|
1700
|
-
* @returns The JSON properties of the element or `undefined` if the element is not found.
|
|
1701
|
-
* @throws [[IModelError]] if the element exists, but cannot be loaded.
|
|
1702
|
-
* @see getElementJson
|
|
1703
|
-
*/
|
|
1704
|
-
tryGetElementJson(loadProps) {
|
|
1705
|
-
try {
|
|
1706
|
-
return this._iModel[_nativeDb].getElement(loadProps);
|
|
1707
|
-
}
|
|
1708
|
-
catch {
|
|
1709
|
-
return undefined;
|
|
1710
|
-
}
|
|
1711
|
-
}
|
|
1712
1725
|
/** Get properties of an Element by Id, FederationGuid, or Code
|
|
1713
1726
|
* @throws [[IModelError]] if the element is not found or cannot be loaded.
|
|
1714
1727
|
* @see tryGetElementProps
|
|
1715
1728
|
*/
|
|
1716
1729
|
getElementProps(props) {
|
|
1730
|
+
const elProp = this.tryGetElementProps(props);
|
|
1731
|
+
if (undefined === elProp)
|
|
1732
|
+
throw new IModelError(IModelStatus.NotFound, `element not found`);
|
|
1733
|
+
return elProp;
|
|
1734
|
+
}
|
|
1735
|
+
resolveElementKey(props) {
|
|
1736
|
+
const baseClassName = "BisCore:Element";
|
|
1737
|
+
let args;
|
|
1717
1738
|
if (typeof props === "string") {
|
|
1718
|
-
|
|
1739
|
+
args = Id64.isId64(props) ? { partialKey: { id: props, baseClassName } } : { federationGuid: props };
|
|
1719
1740
|
}
|
|
1720
1741
|
else if (props instanceof Code) {
|
|
1721
|
-
|
|
1742
|
+
args = { code: props };
|
|
1722
1743
|
}
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1744
|
+
else {
|
|
1745
|
+
if (props.id) {
|
|
1746
|
+
args = { partialKey: { id: props.id, baseClassName } };
|
|
1747
|
+
}
|
|
1748
|
+
else if (props.federationGuid) {
|
|
1749
|
+
args = { federationGuid: props.federationGuid };
|
|
1750
|
+
}
|
|
1751
|
+
else if (props.code) {
|
|
1752
|
+
args = { code: props.code };
|
|
1753
|
+
}
|
|
1754
|
+
else {
|
|
1755
|
+
throw new IModelError(IModelStatus.InvalidId, "Element Id or FederationGuid or Code is required");
|
|
1756
|
+
}
|
|
1728
1757
|
}
|
|
1758
|
+
return this._iModel[_nativeDb].resolveInstanceKey(args);
|
|
1729
1759
|
}
|
|
1730
1760
|
/** Get properties of an Element by Id, FederationGuid, or Code
|
|
1731
1761
|
* @returns The properties of the element or `undefined` if the element is not found.
|
|
@@ -1733,14 +1763,32 @@ function processSchemaWriteStatus(status) {
|
|
|
1733
1763
|
* @note Useful for cases when an element may or may not exist and throwing an `Error` would be overkill.
|
|
1734
1764
|
* @see getElementProps
|
|
1735
1765
|
*/
|
|
1736
|
-
tryGetElementProps(
|
|
1737
|
-
if (typeof
|
|
1738
|
-
|
|
1766
|
+
tryGetElementProps(props) {
|
|
1767
|
+
if (typeof props === "string") {
|
|
1768
|
+
props = Id64.isId64(props) ? { id: props } : { federationGuid: props };
|
|
1739
1769
|
}
|
|
1740
|
-
else if (
|
|
1741
|
-
|
|
1770
|
+
else if (props instanceof Code) {
|
|
1771
|
+
props = { code: props };
|
|
1772
|
+
}
|
|
1773
|
+
try {
|
|
1774
|
+
if (IModelHost.configuration?.disableThinnedNativeInstanceWorkflow) {
|
|
1775
|
+
return this._iModel[_nativeDb].getElement(props);
|
|
1776
|
+
}
|
|
1777
|
+
const cachedElm = this[_cache].get(props);
|
|
1778
|
+
if (cachedElm) {
|
|
1779
|
+
return cachedElm.elProps;
|
|
1780
|
+
}
|
|
1781
|
+
const options = { ...props, useJsNames: true };
|
|
1782
|
+
const instanceKey = this.resolveElementKey(props);
|
|
1783
|
+
const rawInstance = this._iModel[_nativeDb].readInstance(instanceKey, options);
|
|
1784
|
+
const classDef = this._iModel.getJsClass(rawInstance.classFullName);
|
|
1785
|
+
const elementProps = classDef.deserialize({ row: rawInstance, iModel: this._iModel, options: { element: props } });
|
|
1786
|
+
this[_cache].set({ elProps: elementProps, loadOptions: props });
|
|
1787
|
+
return elementProps;
|
|
1788
|
+
}
|
|
1789
|
+
catch {
|
|
1790
|
+
return undefined;
|
|
1742
1791
|
}
|
|
1743
|
-
return this.tryGetElementJson(elementId);
|
|
1744
1792
|
}
|
|
1745
1793
|
/** Get an element by Id, FederationGuid, or Code
|
|
1746
1794
|
* @param elementId either the element's Id, Code, or FederationGuid, or an ElementLoadProps
|
|
@@ -1773,7 +1821,7 @@ function processSchemaWriteStatus(status) {
|
|
|
1773
1821
|
elementId = { code: elementId };
|
|
1774
1822
|
else
|
|
1775
1823
|
elementId.onlyBaseProperties = false; // we must load all properties to construct the element.
|
|
1776
|
-
const elementProps = this.
|
|
1824
|
+
const elementProps = this.tryGetElementProps(elementId);
|
|
1777
1825
|
if (undefined === elementProps)
|
|
1778
1826
|
return undefined; // no Element with that elementId found
|
|
1779
1827
|
const element = this._iModel.constructEntity(elementProps);
|
|
@@ -1837,6 +1885,11 @@ function processSchemaWriteStatus(status) {
|
|
|
1837
1885
|
*/
|
|
1838
1886
|
insertElement(elProps, options) {
|
|
1839
1887
|
try {
|
|
1888
|
+
this[_cache].delete({
|
|
1889
|
+
id: elProps.id,
|
|
1890
|
+
federationGuid: elProps.federationGuid,
|
|
1891
|
+
code: elProps.code,
|
|
1892
|
+
});
|
|
1840
1893
|
return elProps.id = this._iModel[_nativeDb].insertElement(elProps, options);
|
|
1841
1894
|
}
|
|
1842
1895
|
catch (err) {
|
|
@@ -1858,6 +1911,11 @@ function processSchemaWriteStatus(status) {
|
|
|
1858
1911
|
*/
|
|
1859
1912
|
updateElement(elProps) {
|
|
1860
1913
|
try {
|
|
1914
|
+
this[_cache].delete({
|
|
1915
|
+
id: elProps.id,
|
|
1916
|
+
federationGuid: elProps.federationGuid,
|
|
1917
|
+
code: elProps.code,
|
|
1918
|
+
});
|
|
1861
1919
|
this._iModel[_nativeDb].updateElement(elProps);
|
|
1862
1920
|
}
|
|
1863
1921
|
catch (err) {
|
|
@@ -1875,6 +1933,7 @@ function processSchemaWriteStatus(status) {
|
|
|
1875
1933
|
const iModel = this._iModel;
|
|
1876
1934
|
Id64.toIdSet(ids).forEach((id) => {
|
|
1877
1935
|
try {
|
|
1936
|
+
this[_cache].delete({ id });
|
|
1878
1937
|
iModel[_nativeDb].deleteElement(id);
|
|
1879
1938
|
}
|
|
1880
1939
|
catch (err) {
|
|
@@ -2377,9 +2436,9 @@ function processSchemaWriteStatus(status) {
|
|
|
2377
2436
|
}
|
|
2378
2437
|
IModelDb.Views = Views;
|
|
2379
2438
|
/** Represents the current state of a pollable tile content request.
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2439
|
+
* Note: lack of a "completed" state because polling a completed request returns the content as a Uint8Array.
|
|
2440
|
+
* @internal
|
|
2441
|
+
*/
|
|
2383
2442
|
let TileContentState;
|
|
2384
2443
|
(function (TileContentState) {
|
|
2385
2444
|
TileContentState[TileContentState["New"] = 0] = "New";
|
|
@@ -2628,6 +2687,7 @@ export class BriefcaseDb extends IModelDb {
|
|
|
2628
2687
|
touch.sync(briefcaseDb.watchFilePathName);
|
|
2629
2688
|
// Restart default txn to trigger events when watch file is changed by some other process.
|
|
2630
2689
|
const watcher = fs.watch(briefcaseDb.watchFilePathName, { persistent: false }, () => {
|
|
2690
|
+
nativeDb.clearECDbCache();
|
|
2631
2691
|
nativeDb.restartDefaultTxn();
|
|
2632
2692
|
briefcaseDb.changeset = briefcaseDb[_nativeDb].getCurrentChangeset();
|
|
2633
2693
|
});
|