@itwin/core-backend 5.10.0-dev.9 → 5.10.0

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 (278) hide show
  1. package/CHANGELOG.md +45 -1
  2. package/lib/cjs/BriefcaseManager.d.ts +8 -1
  3. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  4. package/lib/cjs/BriefcaseManager.js.map +1 -1
  5. package/lib/cjs/Category.d.ts +4 -4
  6. package/lib/cjs/Category.js.map +1 -1
  7. package/lib/cjs/ChangesetECAdaptor.d.ts +6 -6
  8. package/lib/cjs/ChangesetECAdaptor.js +4 -4
  9. package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
  10. package/lib/cjs/ChangesetReader.d.ts +84 -1
  11. package/lib/cjs/ChangesetReader.d.ts.map +1 -1
  12. package/lib/cjs/ChangesetReader.js +108 -12
  13. package/lib/cjs/ChangesetReader.js.map +1 -1
  14. package/lib/cjs/ClassRegistry.d.ts +3 -3
  15. package/lib/cjs/ClassRegistry.js +3 -3
  16. package/lib/cjs/ClassRegistry.js.map +1 -1
  17. package/lib/cjs/CodeSpecs.d.ts +3 -3
  18. package/lib/cjs/CodeSpecs.js.map +1 -1
  19. package/lib/cjs/DisplayStyle.d.ts +2 -2
  20. package/lib/cjs/DisplayStyle.js.map +1 -1
  21. package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
  22. package/lib/cjs/ECSqlStatement.js +4 -0
  23. package/lib/cjs/ECSqlStatement.js.map +1 -1
  24. package/lib/cjs/ECSqlSyncReader.d.ts.map +1 -1
  25. package/lib/cjs/ECSqlSyncReader.js +1 -0
  26. package/lib/cjs/ECSqlSyncReader.js.map +1 -1
  27. package/lib/cjs/Element.d.ts +16 -13
  28. package/lib/cjs/Element.d.ts.map +1 -1
  29. package/lib/cjs/Element.js +8 -5
  30. package/lib/cjs/Element.js.map +1 -1
  31. package/lib/cjs/ElementAspect.d.ts +1 -1
  32. package/lib/cjs/ElementAspect.js.map +1 -1
  33. package/lib/cjs/ElementTreeWalker.d.ts +5 -5
  34. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  35. package/lib/cjs/Entity.d.ts +13 -5
  36. package/lib/cjs/Entity.d.ts.map +1 -1
  37. package/lib/cjs/Entity.js +13 -5
  38. package/lib/cjs/Entity.js.map +1 -1
  39. package/lib/cjs/ExternalSource.d.ts +2 -2
  40. package/lib/cjs/ExternalSource.js.map +1 -1
  41. package/lib/cjs/IModelDb.d.ts +112 -40
  42. package/lib/cjs/IModelDb.d.ts.map +1 -1
  43. package/lib/cjs/IModelDb.js +215 -42
  44. package/lib/cjs/IModelDb.js.map +1 -1
  45. package/lib/cjs/LineStyle.d.ts +6 -6
  46. package/lib/cjs/LineStyle.js.map +1 -1
  47. package/lib/cjs/LocalHub.d.ts +6 -0
  48. package/lib/cjs/LocalHub.d.ts.map +1 -1
  49. package/lib/cjs/LocalHub.js +23 -0
  50. package/lib/cjs/LocalHub.js.map +1 -1
  51. package/lib/cjs/Material.d.ts +1 -1
  52. package/lib/cjs/Material.js.map +1 -1
  53. package/lib/cjs/Model.d.ts +6 -6
  54. package/lib/cjs/Model.js.map +1 -1
  55. package/lib/cjs/Relationship.d.ts +13 -11
  56. package/lib/cjs/Relationship.d.ts.map +1 -1
  57. package/lib/cjs/Relationship.js +9 -7
  58. package/lib/cjs/Relationship.js.map +1 -1
  59. package/lib/cjs/SheetIndex.d.ts +4 -4
  60. package/lib/cjs/SheetIndex.js.map +1 -1
  61. package/lib/cjs/Texture.d.ts +1 -1
  62. package/lib/cjs/Texture.js.map +1 -1
  63. package/lib/cjs/TxnManager.d.ts.map +1 -1
  64. package/lib/cjs/TxnManager.js +7 -0
  65. package/lib/cjs/TxnManager.js.map +1 -1
  66. package/lib/cjs/ViewDefinition.d.ts +6 -6
  67. package/lib/cjs/ViewDefinition.js.map +1 -1
  68. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +1 -1
  69. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  70. package/lib/cjs/annotations/FrameGeometry.d.ts.map +1 -1
  71. package/lib/cjs/annotations/FrameGeometry.js +2 -3
  72. package/lib/cjs/annotations/FrameGeometry.js.map +1 -1
  73. package/lib/cjs/assets/Settings/Schemas/Base.Schema.json +6 -2
  74. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +1 -0
  75. package/lib/cjs/domains/FunctionalElements.d.ts +1 -1
  76. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  77. package/lib/cjs/domains/GenericElements.d.ts +2 -2
  78. package/lib/cjs/domains/GenericElements.js.map +1 -1
  79. package/lib/cjs/internal/ChannelAdmin.d.ts +2 -2
  80. package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
  81. package/lib/cjs/internal/ElementLRUCache.d.ts.map +1 -1
  82. package/lib/cjs/internal/ElementLRUCache.js +23 -4
  83. package/lib/cjs/internal/ElementLRUCache.js.map +1 -1
  84. package/lib/cjs/internal/HubMock.d.ts +24 -1
  85. package/lib/cjs/internal/HubMock.d.ts.map +1 -1
  86. package/lib/cjs/internal/HubMock.js +60 -39
  87. package/lib/cjs/internal/HubMock.js.map +1 -1
  88. package/lib/cjs/internal/ServerBasedLocks.d.ts +19 -1
  89. package/lib/cjs/internal/ServerBasedLocks.d.ts.map +1 -1
  90. package/lib/cjs/internal/ServerBasedLocks.js +55 -1
  91. package/lib/cjs/internal/ServerBasedLocks.js.map +1 -1
  92. package/lib/cjs/internal/cross-package.d.ts +1 -1
  93. package/lib/cjs/internal/cross-package.d.ts.map +1 -1
  94. package/lib/cjs/internal/cross-package.js +1 -2
  95. package/lib/cjs/internal/cross-package.js.map +1 -1
  96. package/lib/cjs/internal/workspace/SettingsSchemasImpl.d.ts.map +1 -1
  97. package/lib/cjs/internal/workspace/SettingsSchemasImpl.js +55 -9
  98. package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -1
  99. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
  100. package/lib/cjs/internal/workspace/WorkspaceImpl.js +7 -11
  101. package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
  102. package/lib/cjs/workspace/SettingsSchemas.d.ts +20 -3
  103. package/lib/cjs/workspace/SettingsSchemas.d.ts.map +1 -1
  104. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  105. package/lib/cjs/workspace/Workspace.d.ts +3 -1
  106. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  107. package/lib/cjs/workspace/Workspace.js.map +1 -1
  108. package/lib/esm/BriefcaseManager.d.ts +8 -1
  109. package/lib/esm/BriefcaseManager.d.ts.map +1 -1
  110. package/lib/esm/BriefcaseManager.js.map +1 -1
  111. package/lib/esm/Category.d.ts +4 -4
  112. package/lib/esm/Category.js.map +1 -1
  113. package/lib/esm/ChangesetECAdaptor.d.ts +6 -6
  114. package/lib/esm/ChangesetECAdaptor.js +4 -4
  115. package/lib/esm/ChangesetECAdaptor.js.map +1 -1
  116. package/lib/esm/ChangesetReader.d.ts +84 -1
  117. package/lib/esm/ChangesetReader.d.ts.map +1 -1
  118. package/lib/esm/ChangesetReader.js +108 -12
  119. package/lib/esm/ChangesetReader.js.map +1 -1
  120. package/lib/esm/ClassRegistry.d.ts +3 -3
  121. package/lib/esm/ClassRegistry.js +3 -3
  122. package/lib/esm/ClassRegistry.js.map +1 -1
  123. package/lib/esm/CodeSpecs.d.ts +3 -3
  124. package/lib/esm/CodeSpecs.js.map +1 -1
  125. package/lib/esm/DisplayStyle.d.ts +2 -2
  126. package/lib/esm/DisplayStyle.js.map +1 -1
  127. package/lib/esm/ECSqlStatement.d.ts.map +1 -1
  128. package/lib/esm/ECSqlStatement.js +4 -0
  129. package/lib/esm/ECSqlStatement.js.map +1 -1
  130. package/lib/esm/ECSqlSyncReader.d.ts.map +1 -1
  131. package/lib/esm/ECSqlSyncReader.js +1 -0
  132. package/lib/esm/ECSqlSyncReader.js.map +1 -1
  133. package/lib/esm/Element.d.ts +16 -13
  134. package/lib/esm/Element.d.ts.map +1 -1
  135. package/lib/esm/Element.js +8 -5
  136. package/lib/esm/Element.js.map +1 -1
  137. package/lib/esm/ElementAspect.d.ts +1 -1
  138. package/lib/esm/ElementAspect.js.map +1 -1
  139. package/lib/esm/ElementTreeWalker.d.ts +5 -5
  140. package/lib/esm/ElementTreeWalker.js.map +1 -1
  141. package/lib/esm/Entity.d.ts +13 -5
  142. package/lib/esm/Entity.d.ts.map +1 -1
  143. package/lib/esm/Entity.js +13 -5
  144. package/lib/esm/Entity.js.map +1 -1
  145. package/lib/esm/ExternalSource.d.ts +2 -2
  146. package/lib/esm/ExternalSource.js.map +1 -1
  147. package/lib/esm/IModelDb.d.ts +112 -40
  148. package/lib/esm/IModelDb.d.ts.map +1 -1
  149. package/lib/esm/IModelDb.js +216 -43
  150. package/lib/esm/IModelDb.js.map +1 -1
  151. package/lib/esm/LineStyle.d.ts +6 -6
  152. package/lib/esm/LineStyle.js.map +1 -1
  153. package/lib/esm/LocalHub.d.ts +6 -0
  154. package/lib/esm/LocalHub.d.ts.map +1 -1
  155. package/lib/esm/LocalHub.js +23 -0
  156. package/lib/esm/LocalHub.js.map +1 -1
  157. package/lib/esm/Material.d.ts +1 -1
  158. package/lib/esm/Material.js.map +1 -1
  159. package/lib/esm/Model.d.ts +6 -6
  160. package/lib/esm/Model.js.map +1 -1
  161. package/lib/esm/Relationship.d.ts +13 -11
  162. package/lib/esm/Relationship.d.ts.map +1 -1
  163. package/lib/esm/Relationship.js +9 -7
  164. package/lib/esm/Relationship.js.map +1 -1
  165. package/lib/esm/SheetIndex.d.ts +4 -4
  166. package/lib/esm/SheetIndex.js.map +1 -1
  167. package/lib/esm/Texture.d.ts +1 -1
  168. package/lib/esm/Texture.js.map +1 -1
  169. package/lib/esm/TxnManager.d.ts.map +1 -1
  170. package/lib/esm/TxnManager.js +7 -0
  171. package/lib/esm/TxnManager.js.map +1 -1
  172. package/lib/esm/ViewDefinition.d.ts +6 -6
  173. package/lib/esm/ViewDefinition.js.map +1 -1
  174. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +1 -1
  175. package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  176. package/lib/esm/annotations/FrameGeometry.d.ts.map +1 -1
  177. package/lib/esm/annotations/FrameGeometry.js +2 -3
  178. package/lib/esm/annotations/FrameGeometry.js.map +1 -1
  179. package/lib/esm/domains/FunctionalElements.d.ts +1 -1
  180. package/lib/esm/domains/FunctionalElements.js.map +1 -1
  181. package/lib/esm/domains/GenericElements.d.ts +2 -2
  182. package/lib/esm/domains/GenericElements.js.map +1 -1
  183. package/lib/esm/internal/ChannelAdmin.d.ts +2 -2
  184. package/lib/esm/internal/ChannelAdmin.js.map +1 -1
  185. package/lib/esm/internal/ElementLRUCache.d.ts.map +1 -1
  186. package/lib/esm/internal/ElementLRUCache.js +23 -4
  187. package/lib/esm/internal/ElementLRUCache.js.map +1 -1
  188. package/lib/esm/internal/HubMock.d.ts +24 -1
  189. package/lib/esm/internal/HubMock.d.ts.map +1 -1
  190. package/lib/esm/internal/HubMock.js +61 -40
  191. package/lib/esm/internal/HubMock.js.map +1 -1
  192. package/lib/esm/internal/ServerBasedLocks.d.ts +19 -1
  193. package/lib/esm/internal/ServerBasedLocks.d.ts.map +1 -1
  194. package/lib/esm/internal/ServerBasedLocks.js +55 -1
  195. package/lib/esm/internal/ServerBasedLocks.js.map +1 -1
  196. package/lib/esm/internal/cross-package.d.ts +1 -1
  197. package/lib/esm/internal/cross-package.d.ts.map +1 -1
  198. package/lib/esm/internal/cross-package.js +1 -1
  199. package/lib/esm/internal/cross-package.js.map +1 -1
  200. package/lib/esm/internal/workspace/SettingsSchemasImpl.d.ts.map +1 -1
  201. package/lib/esm/internal/workspace/SettingsSchemasImpl.js +55 -9
  202. package/lib/esm/internal/workspace/SettingsSchemasImpl.js.map +1 -1
  203. package/lib/esm/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
  204. package/lib/esm/internal/workspace/WorkspaceImpl.js +7 -11
  205. package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -1
  206. package/lib/esm/test/ElementLRUCache.test.js +60 -0
  207. package/lib/esm/test/ElementLRUCache.test.js.map +1 -1
  208. package/lib/esm/test/SchemaChangesetCanBeReversed.test.d.ts +2 -0
  209. package/lib/esm/test/SchemaChangesetCanBeReversed.test.d.ts.map +1 -0
  210. package/lib/esm/test/SchemaChangesetCanBeReversed.test.js +239 -0
  211. package/lib/esm/test/SchemaChangesetCanBeReversed.test.js.map +1 -0
  212. package/lib/esm/test/annotations/FrameGeometry.test.js +2 -1
  213. package/lib/esm/test/annotations/FrameGeometry.test.js.map +1 -1
  214. package/lib/esm/test/ecdb/CTE.test.js +1 -0
  215. package/lib/esm/test/ecdb/CTE.test.js.map +1 -1
  216. package/lib/esm/test/ecdb/ECSqlQuery.test.js +10 -2
  217. package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -1
  218. package/lib/esm/test/ecdb/ECSqlStatement.test.js +10 -0
  219. package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
  220. package/lib/esm/test/ecdb/ECSqlSyncReader.test.js +1 -0
  221. package/lib/esm/test/ecdb/ECSqlSyncReader.test.js.map +1 -1
  222. package/lib/esm/test/ecdb/QueryReaders.test.js +13 -0
  223. package/lib/esm/test/ecdb/QueryReaders.test.js.map +1 -1
  224. package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js +1 -0
  225. package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
  226. package/lib/esm/test/element/DeleteDefinitionElements.test.js +6 -2
  227. package/lib/esm/test/element/DeleteDefinitionElements.test.js.map +1 -1
  228. package/lib/esm/test/element/ElementRoundTrip.test.js +5 -0
  229. package/lib/esm/test/element/ElementRoundTrip.test.js.map +1 -1
  230. package/lib/esm/test/element/ExcludedElements.test.js +1 -0
  231. package/lib/esm/test/element/ExcludedElements.test.js.map +1 -1
  232. package/lib/esm/test/hubaccess/ApplyChangeset.test.js +10 -0
  233. package/lib/esm/test/hubaccess/ApplyChangeset.test.js.map +1 -1
  234. package/lib/esm/test/hubaccess/SemanticRebase.test.js +1 -0
  235. package/lib/esm/test/hubaccess/SemanticRebase.test.js.map +1 -1
  236. package/lib/esm/test/imodel/IModel.test.js +31 -0
  237. package/lib/esm/test/imodel/IModel.test.js.map +1 -1
  238. package/lib/esm/test/schema/ClassRegistry.test.js +3 -0
  239. package/lib/esm/test/schema/ClassRegistry.test.js.map +1 -1
  240. package/lib/esm/test/schema/IModelSchemaContext.test.js +2 -0
  241. package/lib/esm/test/schema/IModelSchemaContext.test.js.map +1 -1
  242. package/lib/esm/test/schema/SchemaViewHidden.test.d.ts +2 -0
  243. package/lib/esm/test/schema/SchemaViewHidden.test.d.ts.map +1 -0
  244. package/lib/esm/test/schema/SchemaViewHidden.test.js +275 -0
  245. package/lib/esm/test/schema/SchemaViewHidden.test.js.map +1 -0
  246. package/lib/esm/test/schema/SchemaViewKoQ.test.d.ts +2 -0
  247. package/lib/esm/test/schema/SchemaViewKoQ.test.d.ts.map +1 -0
  248. package/lib/esm/test/schema/SchemaViewKoQ.test.js +184 -0
  249. package/lib/esm/test/schema/SchemaViewKoQ.test.js.map +1 -0
  250. package/lib/esm/test/schema/SchemaViewLifecycle.test.d.ts +2 -0
  251. package/lib/esm/test/schema/SchemaViewLifecycle.test.d.ts.map +1 -0
  252. package/lib/esm/test/schema/SchemaViewLifecycle.test.js +141 -0
  253. package/lib/esm/test/schema/SchemaViewLifecycle.test.js.map +1 -0
  254. package/lib/esm/test/schema/SchemaViewValidation.test.d.ts +2 -0
  255. package/lib/esm/test/schema/SchemaViewValidation.test.d.ts.map +1 -0
  256. package/lib/esm/test/schema/SchemaViewValidation.test.js +475 -0
  257. package/lib/esm/test/schema/SchemaViewValidation.test.js.map +1 -0
  258. package/lib/esm/test/standalone/ChangesetReader.test.js +945 -337
  259. package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
  260. package/lib/esm/test/standalone/DeleteElements.test.js +45 -0
  261. package/lib/esm/test/standalone/DeleteElements.test.js.map +1 -1
  262. package/lib/esm/test/standalone/IModelWrite.test.js +6 -0
  263. package/lib/esm/test/standalone/IModelWrite.test.js.map +1 -1
  264. package/lib/esm/test/standalone/ServerBasedLocks.test.js +62 -0
  265. package/lib/esm/test/standalone/ServerBasedLocks.test.js.map +1 -1
  266. package/lib/esm/test/standalone/Settings.test.js +2 -0
  267. package/lib/esm/test/standalone/Settings.test.js.map +1 -1
  268. package/lib/esm/test/standalone/SettingsSchemas.test.js +397 -0
  269. package/lib/esm/test/standalone/SettingsSchemas.test.js.map +1 -1
  270. package/lib/esm/test/standalone/Workspace.test.js +23 -0
  271. package/lib/esm/test/standalone/Workspace.test.js.map +1 -1
  272. package/lib/esm/workspace/SettingsSchemas.d.ts +20 -3
  273. package/lib/esm/workspace/SettingsSchemas.d.ts.map +1 -1
  274. package/lib/esm/workspace/SettingsSchemas.js.map +1 -1
  275. package/lib/esm/workspace/Workspace.d.ts +3 -1
  276. package/lib/esm/workspace/Workspace.d.ts.map +1 -1
  277. package/lib/esm/workspace/Workspace.js.map +1 -1
  278. package/package.json +14 -14
@@ -21,6 +21,7 @@ import { AnyDb, SqliteChangeOp } from "./SqliteChangesetReader";
21
21
  * @beta
22
22
  */
23
23
  export declare class ChangesetReader implements Disposable, ChangeSource {
24
+ private static readonly defaultSpillThresholdInBytes;
24
25
  private readonly _nativeReader;
25
26
  private _rowOptions?;
26
27
  private _propFilter;
@@ -34,18 +35,21 @@ export declare class ChangesetReader implements Disposable, ChangeSource {
34
35
  /**
35
36
  * `true` when the current row belongs to an EC-mapped table.
36
37
  * Valid only after a successful call to [[step]].
38
+ * @throws [[IModelError]] if called before a successful [[step]] call.
37
39
  * @beta
38
40
  */
39
41
  get isECTable(): boolean;
40
42
  /**
41
43
  * Name of the SQLite table for the current change row.
42
44
  * Valid only after a successful call to [[step]].
45
+ * @throws [[IModelError]] if called before a successful [[step]] call.
43
46
  * @beta
44
47
  */
45
48
  get tableName(): string;
46
49
  /**
47
50
  * `true` when the current change was applied indirectly
48
51
  * Valid only after a successful call to [[step]].
52
+ * @throws [[IModelError]] if called before a successful [[step]] call.
49
53
  * @beta
50
54
  */
51
55
  get isIndirectChange(): boolean;
@@ -72,6 +76,7 @@ export declare class ChangesetReader implements Disposable, ChangeSource {
72
76
  * @param args.invert When `true`, invert all operations (Insert↔Delete).
73
77
  * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.
74
78
  * @param args.propFilter Controls which properties are included. Defaults to `All`.
79
+ * @throws if the native layer fails to open the file.
75
80
  * @beta
76
81
  */
77
82
  static openFile(args: {
@@ -83,10 +88,17 @@ export declare class ChangesetReader implements Disposable, ChangeSource {
83
88
  * @param args.db Database with schema at or ahead of the last changeset.
84
89
  * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.
85
90
  * @param args.propFilter Controls which properties are included. Defaults to `All`.
91
+ * @param args.spillThresholdInBytes When the total size of the changeset data in the change group exceeds this threshold (in bytes),
92
+ * the reader writes the data to a temporary file on disk and streams it from there instead of buffering everything in memory.
93
+ * This keeps peak memory usage bounded, making the API suitable for processing large changeset groups under low-memory conditions.
94
+ * Defaults to 50 MiB.
95
+ * @throws if `changesetFiles` is empty, or if the native layer fails to open
96
+ * the group.
86
97
  * @beta
87
98
  */
88
99
  static openGroup(args: {
89
100
  readonly changesetFiles: string[];
101
+ spillThresholdInBytes?: number;
90
102
  } & ChangesetReaderArgs): ChangesetReader;
91
103
  /**
92
104
  * Read pending (not yet pushed) local changes from an open IModelDb.
@@ -94,21 +106,34 @@ export declare class ChangesetReader implements Disposable, ChangeSource {
94
106
  * @param args.includeInMemoryChanges Also include in-memory (not yet saved to disk) changes.
95
107
  * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.
96
108
  * @param args.propFilter Controls which properties are included. Defaults to `All`.
109
+ * @param args.spillThresholdInBytes When the total size of all local un-pushed saved changes exceeds this threshold (in bytes),
110
+ * the reader writes the data to a temporary file on disk and streams it from there instead of buffering everything in memory.
111
+ * This keeps peak memory usage bounded, making the API suitable for iModels with large local change backlogs under low-memory conditions.
112
+ * Defaults to 50 MiB.
113
+ * @throws if the native layer
114
+ * fails to open the local changes.
97
115
  * @beta
98
116
  */
99
117
  static openLocalChanges(args: Omit<ChangesetReaderArgs, "db"> & {
100
118
  db: IModelDb;
101
119
  includeInMemoryChanges?: boolean;
120
+ spillThresholdInBytes?: number;
102
121
  }): ChangesetReader;
103
122
  /**
104
123
  * Read the in-memory (not yet saved to disk) changes of an open IModelDb.
105
124
  * @param args.db Must be an [IModelDb]($backend).
106
125
  * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.
107
126
  * @param args.propFilter Controls which properties are included. Defaults to `All`.
127
+ * @param args.spillThresholdInBytes When the total size of the in-memory (unsaved) change data exceeds this threshold (in bytes),
128
+ * the reader writes the data to a temporary file on disk and streams it from there instead of buffering everything in memory.
129
+ * This keeps peak memory usage bounded, making the API suitable for large in-memory transactions under low-memory conditions.
130
+ * Defaults to 50 MiB.
131
+ * @throws if the native layer encounters an error while opening the in-memory changes.
108
132
  * @beta
109
133
  */
110
134
  static openInMemoryChanges(args: Omit<ChangesetReaderArgs, "db"> & {
111
135
  db: IModelDb;
136
+ spillThresholdInBytes?: number;
112
137
  }): ChangesetReader;
113
138
  /**
114
139
  * Read a single saved transaction by its id.
@@ -116,17 +141,27 @@ export declare class ChangesetReader implements Disposable, ChangeSource {
116
141
  * @param args.txnId The id of the saved transaction to read.
117
142
  * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.
118
143
  * @param args.propFilter Controls which properties are included. Defaults to `All`.
144
+ * @param args.spillThresholdInBytes When the total size of the transaction's change data exceeds this threshold (in bytes),
145
+ * the reader writes the data to a temporary file on disk and streams it from there instead of buffering everything in memory.
146
+ * This keeps peak memory usage bounded, making the API suitable for large transactions under low-memory conditions.
147
+ * Defaults to 50 MiB.
148
+ * @throws if `txnId` is not found, or
149
+ * the native layer fails to open the transaction data.
119
150
  * @beta
120
151
  */
121
152
  static openTxn(args: Omit<ChangesetReaderArgs, "db"> & {
122
153
  db: IModelDb;
123
154
  txnId: Id64String;
155
+ spillThresholdInBytes?: number;
124
156
  }): ChangesetReader;
157
+ /** Handle errors that occur while auto closing the reader if there is also an error while opening the reader */
158
+ private handleCloseErrorWhileOpening;
125
159
  /**
126
160
  * Restrict iteration to changes from the named SQLite tables.
127
161
  * That means the rows for changes from other tables will be skipped entirely and won't be visible through the reader.
128
162
  * @param tableNames SQLite table names to include.
129
163
  * Note: Table names must be provided in the correct case for proper filtering.
164
+ * @throws if the native layer encounters an error while setting the filter.
130
165
  * @beta
131
166
  */
132
167
  setTableNameFilters(tableNames: Set<string>): void;
@@ -134,6 +169,7 @@ export declare class ChangesetReader implements Disposable, ChangeSource {
134
169
  * Restrict iteration to changes with the given operation types.
135
170
  * That means the rows for changes with other operation types will be skipped entirely and won't be visible through the reader.
136
171
  * @param ops Operations to include.
172
+ * @throws if the native layer encounters an error while setting the filter.
137
173
  * @beta
138
174
  */
139
175
  setOpCodeFilters(ops: Set<SqliteChangeOp>): void;
@@ -142,43 +178,90 @@ export declare class ChangesetReader implements Disposable, ChangeSource {
142
178
  * That means the rows for changes from other EC classes will be skipped entirely and won't be visible through the reader.
143
179
  * @param classNames EC class names to include. The classNames should be in the full name format(i.e. "SchemaName:ClassName").
144
180
  * Note: Schema names and class names must be provided in the correct case for proper filtering. Derived classes are not automatically included, so they must be specified explicitly if needed.
181
+ * @throws if the native layer encounters an error while setting the filter.
145
182
  * @beta
146
183
  */
147
184
  setClassNameFilters(classNames: Set<string>): void;
148
185
  /**
149
186
  * Remove the table-name filters
187
+ * @throws if the native layer encounters an error.
150
188
  * @beta
151
189
  */
152
190
  clearTableNameFilters(): void;
153
191
  /**
154
192
  * Remove the op-code filters
193
+ * @throws if the native layer encounters an error.
155
194
  * @beta
156
195
  */
157
196
  clearOpCodeFilters(): void;
158
197
  /**
159
198
  * Remove the class-name filters
199
+ * @throws if the native layer encounters an error.
160
200
  * @beta
161
201
  */
162
202
  clearClassNameFilters(): void;
203
+ /**
204
+ * Enable strict mode on the reader.
205
+ *
206
+ * Strict mode affects how the reader handles a **column-count mismatch** between a change
207
+ * record and the corresponding live database table. Such a mismatch can occur when columns
208
+ * have been added to a table after the changeset was created.
209
+ *
210
+ * When strict mode is **enabled**: if the number of columns recorded in a change row differs
211
+ * from the number of columns currently present in the live table, the reader throws an error
212
+ * instead of processing that row.
213
+ *
214
+ * Use strict mode when you need to be certain that every change row is interpreted against
215
+ * exactly the schema that was in effect when the changeset was written.
216
+ *
217
+ * @see [[disableStrictMode]] — the default (lenient) behaviour.
218
+ * @throws if the native layer encounters an error.
219
+ * @beta
220
+ */
221
+ enableStrictMode(): void;
222
+ /**
223
+ * Disable strict mode on the reader (this is the default).
224
+ *
225
+ * When strict mode is **disabled**: if the number of columns recorded in a change row differs
226
+ * from the number of columns currently present in the live table, the reader takes the
227
+ * **minimum** of the two column counts and proceeds normally with that subset. This is safe
228
+ * because SQLite only ever appends new columns at the end of a table and never removes them —
229
+ * so older change records simply lack the trailing columns that were added later, and those
230
+ * missing columns are silently ignored.
231
+ *
232
+ * @see [[enableStrictMode]] — throw on column-count mismatches instead.
233
+ * @throws if the native layer encounters an error.
234
+ * @beta
235
+ */
236
+ disableStrictMode(): void;
163
237
  /**
164
238
  * Advance to the next change and populate `inserted` and/or `deleted`.
165
239
  * @returns `true` while positioned on a valid change; `false` when the stream is exhausted.
240
+ * @throws if the native layer encounters an error while reading or decoding
241
+ * the next change.
166
242
  * @beta
167
243
  */
168
244
  step(): boolean;
169
245
  /**
170
246
  * SQLite opcode of the current change.
171
247
  * Valid only after a successful call to [[step]].
248
+ * @throws [[IModelError]] if called before a successful [[step]] call.
172
249
  * @beta
173
250
  */
174
251
  get op(): SqliteChangeOp;
175
252
  /**
176
253
  * Close the reader and release all native resources.
254
+ *
255
+ * @throws if the native layer encounters an error during cleanup. Native resources
256
+ * are not fully released when this throws — check the native error
257
+ * logs for details.
177
258
  * @beta
178
259
  */
179
260
  close(): void;
180
261
  /**
181
- * Implements the `Disposable` contract — calls [[close]].
262
+ * Implements the `Disposable` contract — delegates to [[close]].
263
+ *
264
+ * @throws if the native layer fails to release its resources (re-thrown from [[close]]).
182
265
  * @beta
183
266
  */
184
267
  [Symbol.dispose](): void;
@@ -1 +1 @@
1
- {"version":3,"file":"ChangesetReader.d.ts","sourceRoot":"","sources":["../../src/ChangesetReader.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAA2B,UAAU,EAAgB,MAAM,qBAAqB,CAAC;AAExF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,YAAY,EAAoC,MAAM,wBAAwB,CAAC;AAC7H,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAOhE;;;;;;;;;;;;;;GAcG;AACH,qBAAa,eAAgB,YAAW,UAAU,EAAE,YAAY;IAC9D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA+E;IAE7G,OAAO,CAAC,WAAW,CAAC,CAAmB;IACvC,OAAO,CAAC,WAAW,CAAsC;IACzD,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,GAAG,CAAC,CAAiB;IAC7B,OAAO,CAAC,UAAU,CAAC,CAAU;IAC7B,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,iBAAiB,CAAC,CAAU;IAEpC,4CAA4C;IAC5C,SAAgB,EAAE,EAAE,KAAK,CAAC;IAE1B;;;;OAIG;IACH,IAAW,SAAS,IAAI,OAAO,CAI9B;IAED;;;;OAIG;IACH,IAAW,SAAS,IAAI,MAAM,CAI7B;IAED;;;;OAIG;IACH,IAAW,gBAAgB,IAAI,OAAO,CAIrC;IAED;;;;OAIG;IACI,QAAQ,CAAC,EAAE,cAAc,CAAC;IAEjC;;;;OAIG;IACI,OAAO,CAAC,EAAE,cAAc,CAAC;IAGhC,O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OAOG;IACI,mBAAmB,CAAC,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI;IAIzD;;;;OAIG;IACI,qBAAqB,IAAI,IAAI;IAIpC;;;;OAIG;IACI,kBAAkB,IAAI,IAAI;IAIjC;;;;OAIG;IACI,qBAAqB,IAAI,IAAI;IAQpC;;;;;;;;;;;;;;;;;OAiBG;IACI,gBAAgB,IAAI,IAAI;IAI/B;;;;;;;;;;;;;OAaG;IACI,iBAAiB,IAAI,IAAI;IAQhC;;;;;;OAMG;IACI,IAAI,IAAI,OAAO;IAmEtB;;;;;OAKG;IACH,IAAW,EAAE,IAAI,cAAc,CAI9B;IAMD;;;;;;;OAOG;IACI,KAAK,IAAI,IAAI;IAWpB;;;;;OAKG;IACI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAGhC"}
@@ -32,6 +32,7 @@ const ChangesetReaderTypes_1 = require("./ChangesetReaderTypes");
32
32
  * @beta
33
33
  */
34
34
  class ChangesetReader {
35
+ static defaultSpillThresholdInBytes = 50 * 1024 * 1024; // 50 MiB
35
36
  _nativeReader = new NativePlatform_1.IModelNative.platform.ChangesetReader();
36
37
  // Internal options — keep ECClassId as raw Id so the unifier can use it as-is.
37
38
  _rowOptions;
@@ -46,6 +47,7 @@ class ChangesetReader {
46
47
  /**
47
48
  * `true` when the current row belongs to an EC-mapped table.
48
49
  * Valid only after a successful call to [[step]].
50
+ * @throws [[IModelError]] if called before a successful [[step]] call.
49
51
  * @beta
50
52
  */
51
53
  get isECTable() {
@@ -56,6 +58,7 @@ class ChangesetReader {
56
58
  /**
57
59
  * Name of the SQLite table for the current change row.
58
60
  * Valid only after a successful call to [[step]].
61
+ * @throws [[IModelError]] if called before a successful [[step]] call.
59
62
  * @beta
60
63
  */
61
64
  get tableName() {
@@ -66,6 +69,7 @@ class ChangesetReader {
66
69
  /**
67
70
  * `true` when the current change was applied indirectly
68
71
  * Valid only after a successful call to [[step]].
72
+ * @throws [[IModelError]] if called before a successful [[step]] call.
69
73
  * @beta
70
74
  */
71
75
  get isIndirectChange() {
@@ -108,6 +112,7 @@ class ChangesetReader {
108
112
  * @param args.invert When `true`, invert all operations (Insert↔Delete).
109
113
  * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.
110
114
  * @param args.propFilter Controls which properties are included. Defaults to `All`.
115
+ * @throws if the native layer fails to open the file.
111
116
  * @beta
112
117
  */
113
118
  static openFile(args) {
@@ -119,7 +124,7 @@ class ChangesetReader {
119
124
  reader._nativeReader.openFile(args.db[Symbols_1._nativeDb], args.fileName, args.invert ?? false, reader._propFilter);
120
125
  }
121
126
  catch (e) {
122
- reader.close();
127
+ reader.handleCloseErrorWhileOpening(e);
123
128
  throw e;
124
129
  }
125
130
  return reader;
@@ -130,20 +135,26 @@ class ChangesetReader {
130
135
  * @param args.db Database with schema at or ahead of the last changeset.
131
136
  * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.
132
137
  * @param args.propFilter Controls which properties are included. Defaults to `All`.
138
+ * @param args.spillThresholdInBytes When the total size of the changeset data in the change group exceeds this threshold (in bytes),
139
+ * the reader writes the data to a temporary file on disk and streams it from there instead of buffering everything in memory.
140
+ * This keeps peak memory usage bounded, making the API suitable for processing large changeset groups under low-memory conditions.
141
+ * Defaults to 50 MiB.
142
+ * @throws if `changesetFiles` is empty, or if the native layer fails to open
143
+ * the group.
133
144
  * @beta
134
145
  */
135
146
  static openGroup(args) {
136
147
  if (args.changesetFiles.length === 0)
137
- throw new Error("changesetFiles must contain at least one file.");
148
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, "changesetFiles must contain at least one file.");
138
149
  const reader = new ChangesetReader(args.db);
139
150
  reader._rowOptions = args.rowOptions;
140
151
  const propFilter = args.propFilter ?? ChangesetReaderTypes_1.PropertyFilter.All;
141
152
  reader._propFilter = propFilter;
142
153
  try {
143
- reader._nativeReader.openGroup(args.db[Symbols_1._nativeDb], args.changesetFiles, args.invert ?? false, reader._propFilter);
154
+ reader._nativeReader.openGroup(args.db[Symbols_1._nativeDb], args.changesetFiles, args.invert ?? false, reader._propFilter, args.spillThresholdInBytes ?? this.defaultSpillThresholdInBytes);
144
155
  }
145
156
  catch (e) {
146
- reader.close();
157
+ reader.handleCloseErrorWhileOpening(e);
147
158
  throw e;
148
159
  }
149
160
  return reader;
@@ -154,6 +165,12 @@ class ChangesetReader {
154
165
  * @param args.includeInMemoryChanges Also include in-memory (not yet saved to disk) changes.
155
166
  * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.
156
167
  * @param args.propFilter Controls which properties are included. Defaults to `All`.
168
+ * @param args.spillThresholdInBytes When the total size of all local un-pushed saved changes exceeds this threshold (in bytes),
169
+ * the reader writes the data to a temporary file on disk and streams it from there instead of buffering everything in memory.
170
+ * This keeps peak memory usage bounded, making the API suitable for iModels with large local change backlogs under low-memory conditions.
171
+ * Defaults to 50 MiB.
172
+ * @throws if the native layer
173
+ * fails to open the local changes.
157
174
  * @beta
158
175
  */
159
176
  static openLocalChanges(args) {
@@ -162,10 +179,10 @@ class ChangesetReader {
162
179
  const propFilter = args.propFilter ?? ChangesetReaderTypes_1.PropertyFilter.All;
163
180
  reader._propFilter = propFilter;
164
181
  try {
165
- reader._nativeReader.openLocalChanges(args.db[Symbols_1._nativeDb], args.includeInMemoryChanges ?? false, args.invert ?? false, reader._propFilter);
182
+ reader._nativeReader.openLocalChanges(args.db[Symbols_1._nativeDb], args.includeInMemoryChanges ?? false, args.invert ?? false, reader._propFilter, args.spillThresholdInBytes ?? this.defaultSpillThresholdInBytes);
166
183
  }
167
184
  catch (e) {
168
- reader.close();
185
+ reader.handleCloseErrorWhileOpening(e);
169
186
  throw e;
170
187
  }
171
188
  return reader;
@@ -175,6 +192,11 @@ class ChangesetReader {
175
192
  * @param args.db Must be an [IModelDb]($backend).
176
193
  * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.
177
194
  * @param args.propFilter Controls which properties are included. Defaults to `All`.
195
+ * @param args.spillThresholdInBytes When the total size of the in-memory (unsaved) change data exceeds this threshold (in bytes),
196
+ * the reader writes the data to a temporary file on disk and streams it from there instead of buffering everything in memory.
197
+ * This keeps peak memory usage bounded, making the API suitable for large in-memory transactions under low-memory conditions.
198
+ * Defaults to 50 MiB.
199
+ * @throws if the native layer encounters an error while opening the in-memory changes.
178
200
  * @beta
179
201
  */
180
202
  static openInMemoryChanges(args) {
@@ -183,10 +205,10 @@ class ChangesetReader {
183
205
  const propFilter = args.propFilter ?? ChangesetReaderTypes_1.PropertyFilter.All;
184
206
  reader._propFilter = propFilter;
185
207
  try {
186
- reader._nativeReader.openInMemoryChanges(args.db[Symbols_1._nativeDb], args.invert ?? false, reader._propFilter);
208
+ reader._nativeReader.openInMemoryChanges(args.db[Symbols_1._nativeDb], args.invert ?? false, reader._propFilter, args.spillThresholdInBytes ?? this.defaultSpillThresholdInBytes);
187
209
  }
188
210
  catch (e) {
189
- reader.close();
211
+ reader.handleCloseErrorWhileOpening(e);
190
212
  throw e;
191
213
  }
192
214
  return reader;
@@ -197,22 +219,40 @@ class ChangesetReader {
197
219
  * @param args.txnId The id of the saved transaction to read.
198
220
  * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.
199
221
  * @param args.propFilter Controls which properties are included. Defaults to `All`.
222
+ * @param args.spillThresholdInBytes When the total size of the transaction's change data exceeds this threshold (in bytes),
223
+ * the reader writes the data to a temporary file on disk and streams it from there instead of buffering everything in memory.
224
+ * This keeps peak memory usage bounded, making the API suitable for large transactions under low-memory conditions.
225
+ * Defaults to 50 MiB.
226
+ * @throws if `txnId` is not found, or
227
+ * the native layer fails to open the transaction data.
200
228
  * @beta
201
229
  */
202
230
  static openTxn(args) {
203
231
  const reader = new ChangesetReader(args.db);
204
- reader._rowOptions = args.rowOptions ?? {};
232
+ reader._rowOptions = args.rowOptions;
205
233
  const propFilter = args.propFilter ?? ChangesetReaderTypes_1.PropertyFilter.All;
206
234
  reader._propFilter = propFilter;
207
235
  try {
208
- reader._nativeReader.openTxn(args.db[Symbols_1._nativeDb], args.txnId, args.invert ?? false, reader._propFilter);
236
+ reader._nativeReader.openTxn(args.db[Symbols_1._nativeDb], args.txnId, args.invert ?? false, reader._propFilter, args.spillThresholdInBytes ?? this.defaultSpillThresholdInBytes);
209
237
  }
210
238
  catch (e) {
211
- reader.close();
239
+ reader.handleCloseErrorWhileOpening(e);
212
240
  throw e;
213
241
  }
214
242
  return reader;
215
243
  }
244
+ /** Handle errors that occur while auto closing the reader if there is also an error while opening the reader */
245
+ handleCloseErrorWhileOpening(e) {
246
+ try {
247
+ this.close();
248
+ }
249
+ catch (closeError) {
250
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, `Failed to open ChangesetReader with error ${e instanceof Error ? e.message : String(e)}.
251
+ Additionally, that triggered an automatic closure of the reader
252
+ releasing native resources which also failed with failure ${closeError instanceof Error ? closeError.message : String(closeError)}.
253
+ Check native error logs for more details.`);
254
+ }
255
+ }
216
256
  // ---------------------------------------------------------------------------
217
257
  // Filtering
218
258
  // ---------------------------------------------------------------------------
@@ -221,6 +261,7 @@ class ChangesetReader {
221
261
  * That means the rows for changes from other tables will be skipped entirely and won't be visible through the reader.
222
262
  * @param tableNames SQLite table names to include.
223
263
  * Note: Table names must be provided in the correct case for proper filtering.
264
+ * @throws if the native layer encounters an error while setting the filter.
224
265
  * @beta
225
266
  */
226
267
  setTableNameFilters(tableNames) {
@@ -230,6 +271,7 @@ class ChangesetReader {
230
271
  * Restrict iteration to changes with the given operation types.
231
272
  * That means the rows for changes with other operation types will be skipped entirely and won't be visible through the reader.
232
273
  * @param ops Operations to include.
274
+ * @throws if the native layer encounters an error while setting the filter.
233
275
  * @beta
234
276
  */
235
277
  setOpCodeFilters(ops) {
@@ -240,6 +282,7 @@ class ChangesetReader {
240
282
  * That means the rows for changes from other EC classes will be skipped entirely and won't be visible through the reader.
241
283
  * @param classNames EC class names to include. The classNames should be in the full name format(i.e. "SchemaName:ClassName").
242
284
  * Note: Schema names and class names must be provided in the correct case for proper filtering. Derived classes are not automatically included, so they must be specified explicitly if needed.
285
+ * @throws if the native layer encounters an error while setting the filter.
243
286
  * @beta
244
287
  */
245
288
  setClassNameFilters(classNames) {
@@ -247,6 +290,7 @@ class ChangesetReader {
247
290
  }
248
291
  /**
249
292
  * Remove the table-name filters
293
+ * @throws if the native layer encounters an error.
250
294
  * @beta
251
295
  */
252
296
  clearTableNameFilters() {
@@ -254,6 +298,7 @@ class ChangesetReader {
254
298
  }
255
299
  /**
256
300
  * Remove the op-code filters
301
+ * @throws if the native layer encounters an error.
257
302
  * @beta
258
303
  */
259
304
  clearOpCodeFilters() {
@@ -261,17 +306,61 @@ class ChangesetReader {
261
306
  }
262
307
  /**
263
308
  * Remove the class-name filters
309
+ * @throws if the native layer encounters an error.
264
310
  * @beta
265
311
  */
266
312
  clearClassNameFilters() {
267
313
  this._nativeReader.clearClassNameFilters();
268
314
  }
269
315
  // ---------------------------------------------------------------------------
316
+ // Strict mode
317
+ // ---------------------------------------------------------------------------
318
+ /**
319
+ * Enable strict mode on the reader.
320
+ *
321
+ * Strict mode affects how the reader handles a **column-count mismatch** between a change
322
+ * record and the corresponding live database table. Such a mismatch can occur when columns
323
+ * have been added to a table after the changeset was created.
324
+ *
325
+ * When strict mode is **enabled**: if the number of columns recorded in a change row differs
326
+ * from the number of columns currently present in the live table, the reader throws an error
327
+ * instead of processing that row.
328
+ *
329
+ * Use strict mode when you need to be certain that every change row is interpreted against
330
+ * exactly the schema that was in effect when the changeset was written.
331
+ *
332
+ * @see [[disableStrictMode]] — the default (lenient) behaviour.
333
+ * @throws if the native layer encounters an error.
334
+ * @beta
335
+ */
336
+ enableStrictMode() {
337
+ this._nativeReader.enableStrictMode();
338
+ }
339
+ /**
340
+ * Disable strict mode on the reader (this is the default).
341
+ *
342
+ * When strict mode is **disabled**: if the number of columns recorded in a change row differs
343
+ * from the number of columns currently present in the live table, the reader takes the
344
+ * **minimum** of the two column counts and proceeds normally with that subset. This is safe
345
+ * because SQLite only ever appends new columns at the end of a table and never removes them —
346
+ * so older change records simply lack the trailing columns that were added later, and those
347
+ * missing columns are silently ignored.
348
+ *
349
+ * @see [[enableStrictMode]] — throw on column-count mismatches instead.
350
+ * @throws if the native layer encounters an error.
351
+ * @beta
352
+ */
353
+ disableStrictMode() {
354
+ this._nativeReader.disableStrictMode();
355
+ }
356
+ // ---------------------------------------------------------------------------
270
357
  // Iteration
271
358
  // ---------------------------------------------------------------------------
272
359
  /**
273
360
  * Advance to the next change and populate `inserted` and/or `deleted`.
274
361
  * @returns `true` while positioned on a valid change; `false` when the stream is exhausted.
362
+ * @throws if the native layer encounters an error while reading or decoding
363
+ * the next change.
275
364
  * @beta
276
365
  */
277
366
  step() {
@@ -336,6 +425,7 @@ class ChangesetReader {
336
425
  /**
337
426
  * SQLite opcode of the current change.
338
427
  * Valid only after a successful call to [[step]].
428
+ * @throws [[IModelError]] if called before a successful [[step]] call.
339
429
  * @beta
340
430
  */
341
431
  get op() {
@@ -348,6 +438,10 @@ class ChangesetReader {
348
438
  // ---------------------------------------------------------------------------
349
439
  /**
350
440
  * Close the reader and release all native resources.
441
+ *
442
+ * @throws if the native layer encounters an error during cleanup. Native resources
443
+ * are not fully released when this throws — check the native error
444
+ * logs for details.
351
445
  * @beta
352
446
  */
353
447
  close() {
@@ -361,7 +455,9 @@ class ChangesetReader {
361
455
  this._nativeReader.close();
362
456
  }
363
457
  /**
364
- * Implements the `Disposable` contract — calls [[close]].
458
+ * Implements the `Disposable` contract — delegates to [[close]].
459
+ *
460
+ * @throws if the native layer fails to release its resources (re-thrown from [[close]]).
365
461
  * @beta
366
462
  */
367
463
  [Symbol.dispose]() {