@itwin/core-backend 5.1.0-dev.3 → 5.1.0-dev.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/lib/cjs/Category.d.ts +37 -0
  2. package/lib/cjs/Category.d.ts.map +1 -1
  3. package/lib/cjs/Category.js +73 -0
  4. package/lib/cjs/Category.js.map +1 -1
  5. package/lib/cjs/DisplayStyle.d.ts +5 -0
  6. package/lib/cjs/DisplayStyle.d.ts.map +1 -1
  7. package/lib/cjs/DisplayStyle.js +27 -0
  8. package/lib/cjs/DisplayStyle.js.map +1 -1
  9. package/lib/cjs/Element.d.ts +166 -10
  10. package/lib/cjs/Element.d.ts.map +1 -1
  11. package/lib/cjs/Element.js +510 -9
  12. package/lib/cjs/Element.js.map +1 -1
  13. package/lib/cjs/Entity.d.ts +41 -1
  14. package/lib/cjs/Entity.d.ts.map +1 -1
  15. package/lib/cjs/Entity.js +58 -0
  16. package/lib/cjs/Entity.js.map +1 -1
  17. package/lib/cjs/IModelDb.d.ts +19 -36
  18. package/lib/cjs/IModelDb.d.ts.map +1 -1
  19. package/lib/cjs/IModelDb.js +129 -69
  20. package/lib/cjs/IModelDb.js.map +1 -1
  21. package/lib/cjs/IModelHost.d.ts +13 -0
  22. package/lib/cjs/IModelHost.d.ts.map +1 -1
  23. package/lib/cjs/IModelHost.js +6 -0
  24. package/lib/cjs/IModelHost.js.map +1 -1
  25. package/lib/cjs/Material.d.ts +19 -0
  26. package/lib/cjs/Material.d.ts.map +1 -1
  27. package/lib/cjs/Material.js +29 -0
  28. package/lib/cjs/Material.js.map +1 -1
  29. package/lib/cjs/Model.d.ts +42 -6
  30. package/lib/cjs/Model.d.ts.map +1 -1
  31. package/lib/cjs/Model.js +93 -5
  32. package/lib/cjs/Model.js.map +1 -1
  33. package/lib/cjs/TxnManager.d.ts.map +1 -1
  34. package/lib/cjs/TxnManager.js +1 -0
  35. package/lib/cjs/TxnManager.js.map +1 -1
  36. package/lib/cjs/ViewDefinition.d.ts +100 -0
  37. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  38. package/lib/cjs/ViewDefinition.js +208 -0
  39. package/lib/cjs/ViewDefinition.js.map +1 -1
  40. package/lib/cjs/ViewStateHydrator.js +3 -3
  41. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  42. package/lib/cjs/internal/ElementLRUCache.d.ts +28 -0
  43. package/lib/cjs/internal/ElementLRUCache.d.ts.map +1 -0
  44. package/lib/cjs/internal/ElementLRUCache.js +120 -0
  45. package/lib/cjs/internal/ElementLRUCache.js.map +1 -0
  46. package/lib/cjs/internal/Symbols.d.ts +1 -0
  47. package/lib/cjs/internal/Symbols.d.ts.map +1 -1
  48. package/lib/cjs/internal/Symbols.js +2 -1
  49. package/lib/cjs/internal/Symbols.js.map +1 -1
  50. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +2 -2
  51. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  52. package/lib/esm/Category.d.ts +37 -0
  53. package/lib/esm/Category.d.ts.map +1 -1
  54. package/lib/esm/Category.js +73 -0
  55. package/lib/esm/Category.js.map +1 -1
  56. package/lib/esm/DisplayStyle.d.ts +5 -0
  57. package/lib/esm/DisplayStyle.d.ts.map +1 -1
  58. package/lib/esm/DisplayStyle.js +27 -0
  59. package/lib/esm/DisplayStyle.js.map +1 -1
  60. package/lib/esm/Element.d.ts +166 -10
  61. package/lib/esm/Element.d.ts.map +1 -1
  62. package/lib/esm/Element.js +513 -12
  63. package/lib/esm/Element.js.map +1 -1
  64. package/lib/esm/Entity.d.ts +41 -1
  65. package/lib/esm/Entity.d.ts.map +1 -1
  66. package/lib/esm/Entity.js +58 -0
  67. package/lib/esm/Entity.js.map +1 -1
  68. package/lib/esm/IModelDb.d.ts +19 -36
  69. package/lib/esm/IModelDb.d.ts.map +1 -1
  70. package/lib/esm/IModelDb.js +132 -72
  71. package/lib/esm/IModelDb.js.map +1 -1
  72. package/lib/esm/IModelHost.d.ts +13 -0
  73. package/lib/esm/IModelHost.d.ts.map +1 -1
  74. package/lib/esm/IModelHost.js +6 -0
  75. package/lib/esm/IModelHost.js.map +1 -1
  76. package/lib/esm/Material.d.ts +19 -0
  77. package/lib/esm/Material.d.ts.map +1 -1
  78. package/lib/esm/Material.js +30 -1
  79. package/lib/esm/Material.js.map +1 -1
  80. package/lib/esm/Model.d.ts +42 -6
  81. package/lib/esm/Model.d.ts.map +1 -1
  82. package/lib/esm/Model.js +94 -6
  83. package/lib/esm/Model.js.map +1 -1
  84. package/lib/esm/TxnManager.d.ts.map +1 -1
  85. package/lib/esm/TxnManager.js +1 -0
  86. package/lib/esm/TxnManager.js.map +1 -1
  87. package/lib/esm/ViewDefinition.d.ts +100 -0
  88. package/lib/esm/ViewDefinition.d.ts.map +1 -1
  89. package/lib/esm/ViewDefinition.js +209 -1
  90. package/lib/esm/ViewDefinition.js.map +1 -1
  91. package/lib/esm/ViewStateHydrator.js +3 -3
  92. package/lib/esm/ViewStateHydrator.js.map +1 -1
  93. package/lib/esm/internal/ElementLRUCache.d.ts +28 -0
  94. package/lib/esm/internal/ElementLRUCache.d.ts.map +1 -0
  95. package/lib/esm/internal/ElementLRUCache.js +116 -0
  96. package/lib/esm/internal/ElementLRUCache.js.map +1 -0
  97. package/lib/esm/internal/Symbols.d.ts +1 -0
  98. package/lib/esm/internal/Symbols.d.ts.map +1 -1
  99. package/lib/esm/internal/Symbols.js +1 -0
  100. package/lib/esm/internal/Symbols.js.map +1 -1
  101. package/lib/esm/rpc-impl/IModelReadRpcImpl.js +2 -2
  102. package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  103. package/lib/esm/test/ElementLRUCache.test.d.ts +2 -0
  104. package/lib/esm/test/ElementLRUCache.test.d.ts.map +1 -0
  105. package/lib/esm/test/ElementLRUCache.test.js +212 -0
  106. package/lib/esm/test/ElementLRUCache.test.js.map +1 -0
  107. package/lib/esm/test/ecdb/ECSqlQuery.test.js +0 -23
  108. package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -1
  109. package/lib/esm/test/imodel/IModel.test.js +22 -11
  110. package/lib/esm/test/imodel/IModel.test.js.map +1 -1
  111. package/lib/esm/test/standalone/SnapshotDb.test.js +1 -0
  112. package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
  113. package/lib/esm/test/standalone/TxnManager.test.js +1 -1
  114. package/lib/esm/test/standalone/TxnManager.test.js.map +1 -1
  115. package/package.json +12 -12
@@ -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, 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";
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
- return this.getModelJson({ id });
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
- return this.tryGetModelJson({ id });
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
- /** Read the properties for a Model as a json string.
1528
- * @param modelIdArg a json string with the identity of the model to load. Must have either "id" or "code".
1529
- * @returns a json string with the properties of the model.
1530
- * @throws [[IModelError]] if the model is not found or cannot be loaded.
1531
- * @see tryGetModelJson
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
- return modelJson;
1540
- }
1541
- /** Read the properties for a Model as a json string.
1542
- * @param modelIdArg a json string with the identity of the model to load. Must have either "id" or "code".
1543
- * @returns a json string with the properties of the model or `undefined` if the model is not found.
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
- catch {
1551
- return undefined;
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
- props = Id64.isId64(props) ? { id: props } : { federationGuid: props };
1739
+ args = Id64.isId64(props) ? { partialKey: { id: props, baseClassName } } : { federationGuid: props };
1719
1740
  }
1720
1741
  else if (props instanceof Code) {
1721
- props = { code: props };
1742
+ args = { code: props };
1722
1743
  }
1723
- try {
1724
- return this._iModel[_nativeDb].getElement(props);
1725
- }
1726
- catch (err) {
1727
- throw new IModelError(err.errorNumber, err.message);
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(elementId) {
1737
- if (typeof elementId === "string") {
1738
- elementId = Id64.isId64(elementId) ? { id: elementId } : { federationGuid: elementId };
1766
+ tryGetElementProps(props) {
1767
+ if (typeof props === "string") {
1768
+ props = Id64.isId64(props) ? { id: props } : { federationGuid: props };
1739
1769
  }
1740
- else if (elementId instanceof Code) {
1741
- elementId = { code: elementId };
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.tryGetElementJson(elementId);
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
- * Note: lack of a "completed" state because polling a completed request returns the content as a Uint8Array.
2381
- * @internal
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
  });