@itwin/core-backend 5.1.0-dev.27 → 5.1.0-dev.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/lib/cjs/Category.d.ts +4 -4
  2. package/lib/cjs/Category.js +4 -4
  3. package/lib/cjs/Category.js.map +1 -1
  4. package/lib/cjs/CodeSpecs.d.ts +1 -1
  5. package/lib/cjs/CodeSpecs.js +1 -1
  6. package/lib/cjs/CodeSpecs.js.map +1 -1
  7. package/lib/cjs/DisplayStyle.d.ts +4 -4
  8. package/lib/cjs/DisplayStyle.js +3 -3
  9. package/lib/cjs/DisplayStyle.js.map +1 -1
  10. package/lib/cjs/Element.d.ts +50 -50
  11. package/lib/cjs/Element.js +50 -50
  12. package/lib/cjs/Element.js.map +1 -1
  13. package/lib/cjs/ElementAspect.d.ts +7 -7
  14. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  15. package/lib/cjs/ElementAspect.js +7 -7
  16. package/lib/cjs/ElementAspect.js.map +1 -1
  17. package/lib/cjs/Entity.d.ts +2 -2
  18. package/lib/cjs/Entity.js +1 -1
  19. package/lib/cjs/Entity.js.map +1 -1
  20. package/lib/cjs/IModelDb.d.ts +6 -6
  21. package/lib/cjs/IModelDb.d.ts.map +1 -1
  22. package/lib/cjs/IModelDb.js +27 -15
  23. package/lib/cjs/IModelDb.js.map +1 -1
  24. package/lib/cjs/Model.d.ts +22 -22
  25. package/lib/cjs/Model.js +22 -22
  26. package/lib/cjs/Model.js.map +1 -1
  27. package/lib/cjs/TextAnnotationElement.d.ts +2 -2
  28. package/lib/cjs/TextAnnotationElement.js +2 -2
  29. package/lib/cjs/TextAnnotationElement.js.map +1 -1
  30. package/lib/cjs/Texture.d.ts +1 -1
  31. package/lib/cjs/Texture.js +1 -1
  32. package/lib/cjs/Texture.js.map +1 -1
  33. package/lib/cjs/TxnManager.d.ts +4 -4
  34. package/lib/cjs/TxnManager.js +1 -1
  35. package/lib/cjs/TxnManager.js.map +1 -1
  36. package/lib/cjs/ViewDefinition.d.ts +14 -14
  37. package/lib/cjs/ViewDefinition.js +14 -14
  38. package/lib/cjs/ViewDefinition.js.map +1 -1
  39. package/lib/esm/Category.d.ts +4 -4
  40. package/lib/esm/Category.js +4 -4
  41. package/lib/esm/Category.js.map +1 -1
  42. package/lib/esm/CodeSpecs.d.ts +1 -1
  43. package/lib/esm/CodeSpecs.js +1 -1
  44. package/lib/esm/CodeSpecs.js.map +1 -1
  45. package/lib/esm/DisplayStyle.d.ts +4 -4
  46. package/lib/esm/DisplayStyle.js +3 -3
  47. package/lib/esm/DisplayStyle.js.map +1 -1
  48. package/lib/esm/Element.d.ts +50 -50
  49. package/lib/esm/Element.js +50 -50
  50. package/lib/esm/Element.js.map +1 -1
  51. package/lib/esm/ElementAspect.d.ts +7 -7
  52. package/lib/esm/ElementAspect.d.ts.map +1 -1
  53. package/lib/esm/ElementAspect.js +7 -7
  54. package/lib/esm/ElementAspect.js.map +1 -1
  55. package/lib/esm/Entity.d.ts +2 -2
  56. package/lib/esm/Entity.js +1 -1
  57. package/lib/esm/Entity.js.map +1 -1
  58. package/lib/esm/IModelDb.d.ts +6 -6
  59. package/lib/esm/IModelDb.d.ts.map +1 -1
  60. package/lib/esm/IModelDb.js +28 -16
  61. package/lib/esm/IModelDb.js.map +1 -1
  62. package/lib/esm/Model.d.ts +22 -22
  63. package/lib/esm/Model.js +22 -22
  64. package/lib/esm/Model.js.map +1 -1
  65. package/lib/esm/TextAnnotationElement.d.ts +2 -2
  66. package/lib/esm/TextAnnotationElement.js +2 -2
  67. package/lib/esm/TextAnnotationElement.js.map +1 -1
  68. package/lib/esm/Texture.d.ts +1 -1
  69. package/lib/esm/Texture.js +1 -1
  70. package/lib/esm/Texture.js.map +1 -1
  71. package/lib/esm/TxnManager.d.ts +4 -4
  72. package/lib/esm/TxnManager.js +1 -1
  73. package/lib/esm/TxnManager.js.map +1 -1
  74. package/lib/esm/ViewDefinition.d.ts +14 -14
  75. package/lib/esm/ViewDefinition.js +14 -14
  76. package/lib/esm/ViewDefinition.js.map +1 -1
  77. package/lib/esm/test/imodel/IModel.test.js +32 -3
  78. package/lib/esm/test/imodel/IModel.test.js.map +1 -1
  79. package/package.json +12 -12
@@ -9,7 +9,7 @@ import * as fs from "fs";
9
9
  import { join } from "path";
10
10
  import * as touch from "touch";
11
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";
12
+ import { BriefcaseIdValue, Code, DomainOptions, ECJsNames, ECSqlReader, EntityMetaData, FontMap, IModel, IModelError, IModelNotFoundResponse, ProfileOptions, QueryRowFormat, SchemaState, ViewStoreError, 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";
@@ -1477,7 +1477,7 @@ function processSchemaWriteStatus(status) {
1477
1477
  /** @public */
1478
1478
  (function (IModelDb) {
1479
1479
  /** The collection of models in an [[IModelDb]].
1480
- * @public
1480
+ * @public @preview
1481
1481
  */
1482
1482
  class Models {
1483
1483
  _iModel;
@@ -1631,7 +1631,9 @@ function processSchemaWriteStatus(status) {
1631
1631
  return props.id = this._iModel[_nativeDb].insertModel(props);
1632
1632
  }
1633
1633
  catch (err) {
1634
- throw new IModelError(err.errorNumber, `Error inserting model [${err.message}], class=${props.classFullName}`);
1634
+ const error = new IModelError(err.errorNumber, `Error inserting model [${err.message}], class=${props.classFullName}`);
1635
+ error.cause = err;
1636
+ throw error;
1635
1637
  }
1636
1638
  }
1637
1639
  /** Update an existing model.
@@ -1645,7 +1647,9 @@ function processSchemaWriteStatus(status) {
1645
1647
  this._iModel[_nativeDb].updateModel(props);
1646
1648
  }
1647
1649
  catch (err) {
1648
- throw new IModelError(err.errorNumber, `error updating model [${err.message}] id=${props.id}`);
1650
+ const error = new IModelError(err.errorNumber, `Error updating model [${err.message}], id: ${props.id}`);
1651
+ error.cause = err;
1652
+ throw error;
1649
1653
  }
1650
1654
  }
1651
1655
  /** Mark the geometry of [[GeometricModel]] as having changed, by recording an indirect change to its GeometryGuid property.
@@ -1661,7 +1665,7 @@ function processSchemaWriteStatus(status) {
1661
1665
  this._iModel.models[_cache].delete(modelId);
1662
1666
  const error = this._iModel[_nativeDb].updateModelGeometryGuid(modelId);
1663
1667
  if (error !== IModelStatus.Success)
1664
- throw new IModelError(error, `updating geometry guid for model ${modelId}`);
1668
+ throw new IModelError(error, `Error updating geometry guid for model ${modelId}`);
1665
1669
  }
1666
1670
  /** Delete one or more existing models.
1667
1671
  * @param ids The Ids of the models to be deleted
@@ -1674,7 +1678,9 @@ function processSchemaWriteStatus(status) {
1674
1678
  this._iModel[_nativeDb].deleteModel(id);
1675
1679
  }
1676
1680
  catch (err) {
1677
- throw new IModelError(err.errorNumber, `error deleting model [${err.message}] id ${id}`);
1681
+ const error = new IModelError(err.errorNumber, `Error deleting model [${err.message}], id: ${id}`);
1682
+ error.cause = err;
1683
+ throw error;
1678
1684
  }
1679
1685
  });
1680
1686
  }
@@ -1704,7 +1710,7 @@ function processSchemaWriteStatus(status) {
1704
1710
  }
1705
1711
  IModelDb.Models = Models;
1706
1712
  /** The collection of elements in an [[IModelDb]].
1707
- * @public
1713
+ * @public @preview
1708
1714
  */
1709
1715
  class Elements {
1710
1716
  _iModel;
@@ -1882,7 +1888,7 @@ function processSchemaWriteStatus(status) {
1882
1888
  /** Insert a new element into the iModel.
1883
1889
  * @param elProps The properties of the new element.
1884
1890
  * @returns The newly inserted element's Id.
1885
- * @throws [[IModelError]] if unable to insert the element.
1891
+ * @throws [[ITwinError]] if unable to insert the element.
1886
1892
  * @note For convenience, the value of `elProps.id` is updated to reflect the resultant element's id.
1887
1893
  * However when `elProps.federationGuid` is not present or undefined, a new Guid will be generated and stored on the resultant element. But
1888
1894
  * the value of `elProps.federationGuid` is *not* updated. Generally, it is best to re-read the element after inserting (e.g. via [[getElementProps]])
@@ -1912,7 +1918,7 @@ function processSchemaWriteStatus(status) {
1912
1918
  * @param elProps the properties of the element to update.
1913
1919
  * @note The values of `classFullName` and `model` *may not be changed* by this method. Further, it will permute the `elProps` object by adding or
1914
1920
  * overwriting their values to the correct values.
1915
- * @throws [[IModelError]] if unable to update the element.
1921
+ * @throws [[ITwinError]] if unable to update the element.
1916
1922
  */
1917
1923
  updateElement(elProps) {
1918
1924
  try {
@@ -1931,7 +1937,7 @@ function processSchemaWriteStatus(status) {
1931
1937
  }
1932
1938
  /** Delete one or more elements from this iModel.
1933
1939
  * @param ids The set of Ids of the element(s) to be deleted
1934
- * @throws [[IModelError]]
1940
+ * @throws [[ITwinError]]
1935
1941
  * @see deleteDefinitionElements
1936
1942
  */
1937
1943
  deleteElement(ids) {
@@ -2218,7 +2224,9 @@ function processSchemaWriteStatus(status) {
2218
2224
  return this._iModel[_nativeDb].insertElementAspect(aspectProps);
2219
2225
  }
2220
2226
  catch (err) {
2221
- throw new IModelError(err.errorNumber, `Error inserting ElementAspect [${err.message}], class: ${aspectProps.classFullName}`);
2227
+ const error = new IModelError(err.errorNumber, `Error inserting ElementAspect [${err.message}], class: ${aspectProps.classFullName}`, aspectProps);
2228
+ error.cause = err;
2229
+ throw error;
2222
2230
  }
2223
2231
  }
2224
2232
  /** Update an exist ElementAspect within the iModel.
@@ -2230,7 +2238,9 @@ function processSchemaWriteStatus(status) {
2230
2238
  this._iModel[_nativeDb].updateElementAspect(aspectProps);
2231
2239
  }
2232
2240
  catch (err) {
2233
- throw new IModelError(err.errorNumber, `Error updating ElementAspect [${err.message}], id: ${aspectProps.id}`);
2241
+ const error = new IModelError(err.errorNumber, `Error updating ElementAspect [${err.message}], id: ${aspectProps.id}`, aspectProps);
2242
+ error.cause = err;
2243
+ throw error;
2234
2244
  }
2235
2245
  }
2236
2246
  /** Delete one or more ElementAspects from this iModel.
@@ -2244,14 +2254,16 @@ function processSchemaWriteStatus(status) {
2244
2254
  iModel[_nativeDb].deleteElementAspect(aspectInstanceId);
2245
2255
  }
2246
2256
  catch (err) {
2247
- throw new IModelError(err.errorNumber, `Error deleting ElementAspect [${err.message}], id: ${aspectInstanceId}`);
2257
+ const error = new IModelError(err.errorNumber, `Error deleting ElementAspect [${err.message}], id: ${aspectInstanceId}`);
2258
+ error.cause = err;
2259
+ throw error;
2248
2260
  }
2249
2261
  });
2250
2262
  }
2251
2263
  }
2252
2264
  IModelDb.Elements = Elements;
2253
2265
  /** The collection of views in an [[IModelDb]].
2254
- * @public
2266
+ * @public @preview
2255
2267
  */
2256
2268
  class Views {
2257
2269
  _iModel;
@@ -2277,7 +2289,7 @@ function processSchemaWriteStatus(status) {
2277
2289
  if (undefined === props) {
2278
2290
  const propsString = this._iModel.queryFilePropertyString(Views.viewStoreProperty);
2279
2291
  if (!propsString)
2280
- throw new Error("iModel does not have a default ViewStore");
2292
+ ViewStoreError.throwError("no-viewstore", { message: "iModel does not have a default ViewStore" });
2281
2293
  props = JSON.parse(propsString);
2282
2294
  }
2283
2295
  const accessToken = await CloudSqlite.requestToken({
@@ -2398,7 +2410,7 @@ function processSchemaWriteStatus(status) {
2398
2410
  }
2399
2411
  getViewThumbnailArg(viewDefinitionId) {
2400
2412
  if (!Id64.isValid(viewDefinitionId))
2401
- throw new Error("illegal thumbnail id");
2413
+ throw new IModelError(IModelStatus.BadArg, "illegal thumbnail id");
2402
2414
  return { namespace: "dgn_View", name: "Thumbnail", id: viewDefinitionId };
2403
2415
  }
2404
2416
  /** Get the thumbnail for a view.