@itwin/core-backend 5.9.0-dev.9 → 5.9.1
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/CHANGELOG.md +45 -1
- package/lib/cjs/BriefcaseManager.d.ts +14 -62
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +29 -159
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/Category.d.ts +4 -4
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.d.ts +9 -1
- package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +7 -1
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/ChangesetReader.d.ts +186 -0
- package/lib/cjs/ChangesetReader.d.ts.map +1 -0
- package/lib/cjs/ChangesetReader.js +372 -0
- package/lib/cjs/ChangesetReader.js.map +1 -0
- package/lib/cjs/ChangesetReaderTypes.d.ts +120 -0
- package/lib/cjs/ChangesetReaderTypes.d.ts.map +1 -0
- package/lib/cjs/ChangesetReaderTypes.js +23 -0
- package/lib/cjs/ChangesetReaderTypes.js.map +1 -0
- package/lib/cjs/CloudSqlite.d.ts +1 -1
- package/lib/cjs/CloudSqlite.d.ts.map +1 -1
- package/lib/cjs/CloudSqlite.js +68 -13
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/CodeSpecs.d.ts +3 -3
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/DisplayStyle.d.ts +2 -2
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/EditTxn.d.ts +55 -1
- package/lib/cjs/EditTxn.d.ts.map +1 -1
- package/lib/cjs/EditTxn.js +43 -1
- package/lib/cjs/EditTxn.js.map +1 -1
- package/lib/cjs/Element.d.ts +79 -10
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +38 -2
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.d.ts +1 -1
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementGraphics.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.d.ts +5 -5
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/ExternalSource.d.ts +2 -2
- package/lib/cjs/ExternalSource.d.ts.map +1 -1
- package/lib/cjs/ExternalSource.js.map +1 -1
- package/lib/cjs/GeographicCRSServices.d.ts +15 -0
- package/lib/cjs/GeographicCRSServices.d.ts.map +1 -1
- package/lib/cjs/GeographicCRSServices.js +13 -4
- package/lib/cjs/GeographicCRSServices.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +31 -23
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +44 -25
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelIncrementalSchemaLocater.js.map +1 -1
- package/lib/cjs/IModelJsFs.d.ts +2 -0
- package/lib/cjs/IModelJsFs.d.ts.map +1 -1
- package/lib/cjs/IModelJsFs.js +14 -0
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/IpcHost.d.ts.map +1 -1
- package/lib/cjs/IpcHost.js +20 -9
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LineStyle.d.ts +6 -6
- package/lib/cjs/LineStyle.js.map +1 -1
- package/lib/cjs/Material.d.ts +1 -1
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.d.ts +40 -6
- package/lib/cjs/Model.d.ts.map +1 -1
- package/lib/cjs/Model.js +24 -0
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/PartialChangeUnifier.d.ts +77 -0
- package/lib/cjs/PartialChangeUnifier.d.ts.map +1 -0
- package/lib/cjs/PartialChangeUnifier.js +234 -0
- package/lib/cjs/PartialChangeUnifier.js.map +1 -0
- package/lib/cjs/Relationship.d.ts +10 -10
- package/lib/cjs/Relationship.js +6 -6
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/SheetIndex.d.ts +4 -4
- package/lib/cjs/SheetIndex.d.ts.map +1 -1
- package/lib/cjs/SheetIndex.js.map +1 -1
- package/lib/cjs/SqliteChangesetReader.d.ts.map +1 -1
- package/lib/cjs/SqliteChangesetReader.js +1 -1
- package/lib/cjs/SqliteChangesetReader.js.map +1 -1
- package/lib/cjs/Texture.d.ts +1 -1
- package/lib/cjs/Texture.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts +17 -0
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +120 -13
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts +25 -13
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +77 -25
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/ViewStore.d.ts.map +1 -1
- package/lib/cjs/ViewStore.js +63 -21
- package/lib/cjs/ViewStore.js.map +1 -1
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +1 -1
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
- package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -1
- package/lib/cjs/core-backend.d.ts +3 -0
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +3 -0
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.d.ts +1 -1
- package/lib/cjs/domains/FunctionalElements.d.ts.map +1 -1
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/GenericElements.d.ts +2 -2
- package/lib/cjs/domains/GenericElements.d.ts.map +1 -1
- package/lib/cjs/domains/GenericElements.js.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.d.ts +2 -2
- package/lib/cjs/internal/ChannelAdmin.d.ts.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
- package/lib/cjs/internal/IntegrityCheck.d.ts +10 -10
- package/lib/cjs/internal/IntegrityCheck.js +22 -22
- package/lib/cjs/internal/IntegrityCheck.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/cjs/workspace/Settings.d.ts +6 -4
- package/lib/cjs/workspace/Settings.d.ts.map +1 -1
- package/lib/cjs/workspace/Settings.js.map +1 -1
- package/lib/esm/BriefcaseManager.d.ts +14 -62
- package/lib/esm/BriefcaseManager.d.ts.map +1 -1
- package/lib/esm/BriefcaseManager.js +30 -160
- package/lib/esm/BriefcaseManager.js.map +1 -1
- package/lib/esm/Category.d.ts +4 -4
- package/lib/esm/Category.js.map +1 -1
- package/lib/esm/ChangesetECAdaptor.d.ts +9 -1
- package/lib/esm/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/esm/ChangesetECAdaptor.js +7 -1
- package/lib/esm/ChangesetECAdaptor.js.map +1 -1
- package/lib/esm/ChangesetReader.d.ts +186 -0
- package/lib/esm/ChangesetReader.d.ts.map +1 -0
- package/lib/esm/ChangesetReader.js +368 -0
- package/lib/esm/ChangesetReader.js.map +1 -0
- package/lib/esm/ChangesetReaderTypes.d.ts +120 -0
- package/lib/esm/ChangesetReaderTypes.d.ts.map +1 -0
- package/lib/esm/ChangesetReaderTypes.js +20 -0
- package/lib/esm/ChangesetReaderTypes.js.map +1 -0
- package/lib/esm/CloudSqlite.d.ts +1 -1
- package/lib/esm/CloudSqlite.d.ts.map +1 -1
- package/lib/esm/CloudSqlite.js +69 -14
- package/lib/esm/CloudSqlite.js.map +1 -1
- package/lib/esm/CodeSpecs.d.ts +3 -3
- package/lib/esm/CodeSpecs.js.map +1 -1
- package/lib/esm/ConcurrentQuery.js.map +1 -1
- package/lib/esm/DevTools.js.map +1 -1
- package/lib/esm/DisplayStyle.d.ts +2 -2
- package/lib/esm/DisplayStyle.js.map +1 -1
- package/lib/esm/ECSqlStatement.d.ts.map +1 -1
- package/lib/esm/ECSqlStatement.js.map +1 -1
- package/lib/esm/EditTxn.d.ts +55 -1
- package/lib/esm/EditTxn.d.ts.map +1 -1
- package/lib/esm/EditTxn.js +43 -1
- package/lib/esm/EditTxn.js.map +1 -1
- package/lib/esm/Element.d.ts +79 -10
- package/lib/esm/Element.d.ts.map +1 -1
- package/lib/esm/Element.js +38 -2
- package/lib/esm/Element.js.map +1 -1
- package/lib/esm/ElementAspect.d.ts +1 -1
- package/lib/esm/ElementAspect.js.map +1 -1
- package/lib/esm/ElementGraphics.js.map +1 -1
- package/lib/esm/ElementTreeWalker.d.ts +5 -5
- package/lib/esm/ElementTreeWalker.js.map +1 -1
- package/lib/esm/ExternalSource.d.ts +2 -2
- package/lib/esm/ExternalSource.d.ts.map +1 -1
- package/lib/esm/ExternalSource.js.map +1 -1
- package/lib/esm/GeographicCRSServices.d.ts +15 -0
- package/lib/esm/GeographicCRSServices.d.ts.map +1 -1
- package/lib/esm/GeographicCRSServices.js +12 -4
- package/lib/esm/GeographicCRSServices.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +31 -23
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +45 -26
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/IModelIncrementalSchemaLocater.js.map +1 -1
- package/lib/esm/IModelJsFs.d.ts +2 -0
- package/lib/esm/IModelJsFs.d.ts.map +1 -1
- package/lib/esm/IModelJsFs.js +14 -0
- package/lib/esm/IModelJsFs.js.map +1 -1
- package/lib/esm/IpcHost.d.ts.map +1 -1
- package/lib/esm/IpcHost.js +20 -9
- package/lib/esm/IpcHost.js.map +1 -1
- package/lib/esm/LineStyle.d.ts +6 -6
- package/lib/esm/LineStyle.js.map +1 -1
- package/lib/esm/Material.d.ts +1 -1
- package/lib/esm/Material.js.map +1 -1
- package/lib/esm/Model.d.ts +40 -6
- package/lib/esm/Model.d.ts.map +1 -1
- package/lib/esm/Model.js +24 -0
- package/lib/esm/Model.js.map +1 -1
- package/lib/esm/PartialChangeUnifier.d.ts +77 -0
- package/lib/esm/PartialChangeUnifier.d.ts.map +1 -0
- package/lib/esm/PartialChangeUnifier.js +230 -0
- package/lib/esm/PartialChangeUnifier.js.map +1 -0
- package/lib/esm/Relationship.d.ts +10 -10
- package/lib/esm/Relationship.js +6 -6
- package/lib/esm/Relationship.js.map +1 -1
- package/lib/esm/SheetIndex.d.ts +4 -4
- package/lib/esm/SheetIndex.d.ts.map +1 -1
- package/lib/esm/SheetIndex.js.map +1 -1
- package/lib/esm/SqliteChangesetReader.d.ts.map +1 -1
- package/lib/esm/SqliteChangesetReader.js +1 -1
- package/lib/esm/SqliteChangesetReader.js.map +1 -1
- package/lib/esm/Texture.d.ts +1 -1
- package/lib/esm/Texture.js.map +1 -1
- package/lib/esm/TxnManager.d.ts +17 -0
- package/lib/esm/TxnManager.d.ts.map +1 -1
- package/lib/esm/TxnManager.js +121 -14
- package/lib/esm/TxnManager.js.map +1 -1
- package/lib/esm/ViewDefinition.d.ts +25 -13
- package/lib/esm/ViewDefinition.d.ts.map +1 -1
- package/lib/esm/ViewDefinition.js +78 -26
- package/lib/esm/ViewDefinition.js.map +1 -1
- package/lib/esm/ViewStore.d.ts.map +1 -1
- package/lib/esm/ViewStore.js +64 -22
- package/lib/esm/ViewStore.js.map +1 -1
- package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +1 -1
- package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
- package/lib/esm/annotations/TextAnnotationElement.js.map +1 -1
- package/lib/esm/core-backend.d.ts +3 -0
- package/lib/esm/core-backend.d.ts.map +1 -1
- package/lib/esm/core-backend.js +3 -0
- package/lib/esm/core-backend.js.map +1 -1
- package/lib/esm/domains/FunctionalElements.d.ts +1 -1
- package/lib/esm/domains/FunctionalElements.d.ts.map +1 -1
- package/lib/esm/domains/FunctionalElements.js.map +1 -1
- package/lib/esm/domains/GenericElements.d.ts +2 -2
- package/lib/esm/domains/GenericElements.d.ts.map +1 -1
- package/lib/esm/domains/GenericElements.js.map +1 -1
- package/lib/esm/internal/ChannelAdmin.d.ts +2 -2
- package/lib/esm/internal/ChannelAdmin.d.ts.map +1 -1
- package/lib/esm/internal/ChannelAdmin.js.map +1 -1
- package/lib/esm/internal/IntegrityCheck.d.ts +10 -10
- package/lib/esm/internal/IntegrityCheck.js +22 -22
- package/lib/esm/internal/IntegrityCheck.js.map +1 -1
- package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/esm/test/ElementDrivesElement.test.d.ts.map +1 -1
- package/lib/esm/test/ElementDrivesElement.test.js.map +1 -1
- package/lib/esm/test/IModelTestUtils.d.ts +1 -0
- package/lib/esm/test/IModelTestUtils.d.ts.map +1 -1
- package/lib/esm/test/IModelTestUtils.js +5 -0
- package/lib/esm/test/IModelTestUtils.js.map +1 -1
- package/lib/esm/test/IpcHost.test.js +112 -0
- package/lib/esm/test/IpcHost.test.js.map +1 -1
- package/lib/esm/test/annotations/LeaderGeometry.test.js +0 -1
- package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
- package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
- package/lib/esm/test/element/DeleteDefinitionElements.test.js +819 -26
- package/lib/esm/test/element/DeleteDefinitionElements.test.js.map +1 -1
- package/lib/esm/test/element/ElementRoundTrip.test.js +144 -3
- package/lib/esm/test/element/ElementRoundTrip.test.js.map +1 -1
- package/lib/esm/test/element/SheetInformationAspect.test.js.map +1 -1
- package/lib/esm/test/hubaccess/Rebase.test.js +1 -1
- package/lib/esm/test/hubaccess/Rebase.test.js.map +1 -1
- package/lib/esm/test/hubaccess/SemanticRebase.test.js +2242 -68
- package/lib/esm/test/hubaccess/SemanticRebase.test.js.map +1 -1
- package/lib/esm/test/imodel/IModel.test.js +1 -1
- package/lib/esm/test/imodel/IModel.test.js.map +1 -1
- package/lib/esm/test/imodel/SchemaXmlImport.test.js +64 -0
- package/lib/esm/test/imodel/SchemaXmlImport.test.js.map +1 -1
- package/lib/esm/test/misc/GeoServices.test.js +43 -1
- package/lib/esm/test/misc/GeoServices.test.js.map +1 -1
- package/lib/esm/test/sheetindex/SheetIndex.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangesetReader.test.js +4184 -1654
- package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
- package/lib/esm/test/standalone/DeleteElements.test.d.ts +2 -0
- package/lib/esm/test/standalone/DeleteElements.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/DeleteElements.test.js +625 -0
- package/lib/esm/test/standalone/DeleteElements.test.js.map +1 -0
- package/lib/esm/test/standalone/GeometryStream.test.js.map +1 -1
- package/lib/esm/test/standalone/IntegrityCheck.test.js +214 -5
- package/lib/esm/test/standalone/IntegrityCheck.test.js.map +1 -1
- package/lib/esm/test/standalone/SQliteChangesetReaderAndChangesetECAdaptor.test.d.ts +2 -0
- package/lib/esm/test/standalone/SQliteChangesetReaderAndChangesetECAdaptor.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/SQliteChangesetReaderAndChangesetECAdaptor.test.js +1862 -0
- package/lib/esm/test/standalone/SQliteChangesetReaderAndChangesetECAdaptor.test.js.map +1 -0
- package/lib/esm/test/standalone/TxnManager.test.js +90 -0
- package/lib/esm/test/standalone/TxnManager.test.js.map +1 -1
- package/lib/esm/test/standalone/ViewDefinition.test.js +18 -7
- package/lib/esm/test/standalone/ViewDefinition.test.js.map +1 -1
- package/lib/esm/test/standalone/Workspace.test.js.map +1 -1
- package/lib/esm/workspace/Settings.d.ts +6 -4
- package/lib/esm/workspace/Settings.d.ts.map +1 -1
- package/lib/esm/workspace/Settings.js.map +1 -1
- package/package.json +15 -15
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChangesetReader = void 0;
|
|
4
|
+
/*---------------------------------------------------------------------------------------------
|
|
5
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
+
*--------------------------------------------------------------------------------------------*/
|
|
8
|
+
/** @packageDocumentation
|
|
9
|
+
* @module ECDb
|
|
10
|
+
*/
|
|
11
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
|
+
const core_common_1 = require("@itwin/core-common");
|
|
13
|
+
const NativePlatform_1 = require("./internal/NativePlatform");
|
|
14
|
+
const Symbols_1 = require("./internal/Symbols");
|
|
15
|
+
const ChangesetReaderTypes_1 = require("./ChangesetReaderTypes");
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// ChangesetReader
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
/**
|
|
20
|
+
* Reads EC-typed changeset data natively from a changeset file, changeset group,
|
|
21
|
+
* in-memory transaction, or local un-pushed changes.
|
|
22
|
+
*
|
|
23
|
+
* Implements [ChangeSource]($backend) so rows can be fed directly into
|
|
24
|
+
* [PartialChangeUnifier]($backend) to merge partial (per-table) instances into
|
|
25
|
+
* complete EC instances.
|
|
26
|
+
*
|
|
27
|
+
* When the current row is a non-EC internal SQLite table, [[isECTable]] is `false`
|
|
28
|
+
* and both [[inserted]] and [[deleted]] remain `undefined`.
|
|
29
|
+
*
|
|
30
|
+
* @note The native reader operates one SQLite table-row at a time. Multi-table EC
|
|
31
|
+
* instances must be merged using [PartialChangeUnifier]($backend).
|
|
32
|
+
* @beta
|
|
33
|
+
*/
|
|
34
|
+
class ChangesetReader {
|
|
35
|
+
_nativeReader = new NativePlatform_1.IModelNative.platform.ChangesetReader();
|
|
36
|
+
// Internal options — keep ECClassId as raw Id so the unifier can use it as-is.
|
|
37
|
+
_rowOptions;
|
|
38
|
+
_propFilter = ChangesetReaderTypes_1.PropertyFilter.All;
|
|
39
|
+
_changeIndex = 0;
|
|
40
|
+
_op;
|
|
41
|
+
_isECTable;
|
|
42
|
+
_tableName;
|
|
43
|
+
_isIndirectChange;
|
|
44
|
+
/** The db used for EC schema resolution. */
|
|
45
|
+
db;
|
|
46
|
+
/**
|
|
47
|
+
* `true` when the current row belongs to an EC-mapped table.
|
|
48
|
+
* Valid only after a successful call to [[step]].
|
|
49
|
+
* @beta
|
|
50
|
+
*/
|
|
51
|
+
get isECTable() {
|
|
52
|
+
if (this._isECTable === undefined)
|
|
53
|
+
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadRequest, "ChangesetReader.isECTable is only valid after step() has positioned the reader on a current valid change.");
|
|
54
|
+
return this._isECTable;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Name of the SQLite table for the current change row.
|
|
58
|
+
* Valid only after a successful call to [[step]].
|
|
59
|
+
* @beta
|
|
60
|
+
*/
|
|
61
|
+
get tableName() {
|
|
62
|
+
if (this._tableName === undefined)
|
|
63
|
+
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadRequest, "ChangesetReader.tableName is only valid after step() has positioned the reader on a current valid change.");
|
|
64
|
+
return this._tableName;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* `true` when the current change was applied indirectly
|
|
68
|
+
* Valid only after a successful call to [[step]].
|
|
69
|
+
* @beta
|
|
70
|
+
*/
|
|
71
|
+
get isIndirectChange() {
|
|
72
|
+
if (this._isIndirectChange === undefined)
|
|
73
|
+
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadRequest, "ChangesetReader.isIndirectChange is only valid after step() has positioned the reader on a current valid change.");
|
|
74
|
+
return this._isIndirectChange;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Post-change (inserted or updated-new) EC instance, populated after each [[step]] call.
|
|
78
|
+
* `undefined` when the current row is a Delete or a non-EC table row or [[step]] returned false.
|
|
79
|
+
* @beta
|
|
80
|
+
*/
|
|
81
|
+
inserted;
|
|
82
|
+
/**
|
|
83
|
+
* Pre-change (deleted or updated-old) EC instance, populated after each [[step]] call.
|
|
84
|
+
* `undefined` when the current row is an Insert or a non-EC table row or [[step]] returned false.
|
|
85
|
+
* @beta
|
|
86
|
+
*/
|
|
87
|
+
deleted;
|
|
88
|
+
// Private — callers use static factory methods.
|
|
89
|
+
constructor(db) {
|
|
90
|
+
this.db = db;
|
|
91
|
+
}
|
|
92
|
+
/** Map public RowFormatOptions to the native adaptor options.
|
|
93
|
+
* @internal */
|
|
94
|
+
toNativeRowOptions(opts) {
|
|
95
|
+
return {
|
|
96
|
+
abbreviateBlobs: opts.abbreviateBlobs,
|
|
97
|
+
classIdsToClassNames: opts.classIdsToClassNames,
|
|
98
|
+
useJsName: opts.useJsName,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
// ---------------------------------------------------------------------------
|
|
102
|
+
// Static factory methods
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
/**
|
|
105
|
+
* Open a changeset file from disk.
|
|
106
|
+
* @param args.fileName Absolute path to the changeset file.
|
|
107
|
+
* @param args.db Database at or after the changeset's ending state, used for schema resolution.
|
|
108
|
+
* @param args.invert When `true`, invert all operations (Insert↔Delete).
|
|
109
|
+
* @param args.valueOptions Row adaptor options controlling how EC property values are formatted.
|
|
110
|
+
* @param args.propFilter Controls which properties are included. Defaults to `All`.
|
|
111
|
+
* @beta
|
|
112
|
+
*/
|
|
113
|
+
static openFile(args) {
|
|
114
|
+
const reader = new ChangesetReader(args.db);
|
|
115
|
+
reader._rowOptions = args.rowOptions;
|
|
116
|
+
const propFilter = args.propFilter ?? ChangesetReaderTypes_1.PropertyFilter.All;
|
|
117
|
+
reader._propFilter = propFilter;
|
|
118
|
+
try {
|
|
119
|
+
reader._nativeReader.openFile(args.db[Symbols_1._nativeDb], args.fileName, args.invert ?? false, reader._propFilter);
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
reader.close();
|
|
123
|
+
throw e;
|
|
124
|
+
}
|
|
125
|
+
return reader;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Concatenate multiple changeset files and read them as a single logical stream.
|
|
129
|
+
* @param args.changesetFiles Ordered list of changeset file paths.
|
|
130
|
+
* @param args.db Database with schema at or ahead of the last changeset.
|
|
131
|
+
* @param args.valueOptions Row adaptor options controlling how EC property values are formatted.
|
|
132
|
+
* @param args.propFilter Controls which properties are included. Defaults to `All`.
|
|
133
|
+
* @beta
|
|
134
|
+
*/
|
|
135
|
+
static openGroup(args) {
|
|
136
|
+
if (args.changesetFiles.length === 0)
|
|
137
|
+
throw new Error("changesetFiles must contain at least one file.");
|
|
138
|
+
const reader = new ChangesetReader(args.db);
|
|
139
|
+
reader._rowOptions = args.rowOptions;
|
|
140
|
+
const propFilter = args.propFilter ?? ChangesetReaderTypes_1.PropertyFilter.All;
|
|
141
|
+
reader._propFilter = propFilter;
|
|
142
|
+
try {
|
|
143
|
+
reader._nativeReader.openGroup(args.db[Symbols_1._nativeDb], args.changesetFiles, args.invert ?? false, reader._propFilter);
|
|
144
|
+
}
|
|
145
|
+
catch (e) {
|
|
146
|
+
reader.close();
|
|
147
|
+
throw e;
|
|
148
|
+
}
|
|
149
|
+
return reader;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Read pending (not yet pushed) local changes from an open IModelDb.
|
|
153
|
+
* @param args.db Must be an [IModelDb]($backend) (not [ECDb]($backend)).
|
|
154
|
+
* @param args.includeInMemoryChanges Also include in-memory (not yet saved to disk) changes.
|
|
155
|
+
* @param args.valueOptions Row adaptor options controlling how EC property values are formatted.
|
|
156
|
+
* @param args.propFilter Controls which properties are included. Defaults to `All`.
|
|
157
|
+
* @beta
|
|
158
|
+
*/
|
|
159
|
+
static openLocalChanges(args) {
|
|
160
|
+
const reader = new ChangesetReader(args.db);
|
|
161
|
+
reader._rowOptions = args.rowOptions;
|
|
162
|
+
const propFilter = args.propFilter ?? ChangesetReaderTypes_1.PropertyFilter.All;
|
|
163
|
+
reader._propFilter = propFilter;
|
|
164
|
+
try {
|
|
165
|
+
reader._nativeReader.openLocalChanges(args.db[Symbols_1._nativeDb], args.includeInMemoryChanges ?? false, args.invert ?? false, reader._propFilter);
|
|
166
|
+
}
|
|
167
|
+
catch (e) {
|
|
168
|
+
reader.close();
|
|
169
|
+
throw e;
|
|
170
|
+
}
|
|
171
|
+
return reader;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Read the in-memory (not yet saved to disk) changes of an open IModelDb.
|
|
175
|
+
* @param args.db Must be an [IModelDb]($backend).
|
|
176
|
+
* @param args.valueOptions Row adaptor options controlling how EC property values are formatted.
|
|
177
|
+
* @param args.propFilter Controls which properties are included. Defaults to `All`.
|
|
178
|
+
* @beta
|
|
179
|
+
*/
|
|
180
|
+
static openInMemoryChanges(args) {
|
|
181
|
+
const reader = new ChangesetReader(args.db);
|
|
182
|
+
reader._rowOptions = args.rowOptions;
|
|
183
|
+
const propFilter = args.propFilter ?? ChangesetReaderTypes_1.PropertyFilter.All;
|
|
184
|
+
reader._propFilter = propFilter;
|
|
185
|
+
try {
|
|
186
|
+
reader._nativeReader.openInMemoryChanges(args.db[Symbols_1._nativeDb], args.invert ?? false, reader._propFilter);
|
|
187
|
+
}
|
|
188
|
+
catch (e) {
|
|
189
|
+
reader.close();
|
|
190
|
+
throw e;
|
|
191
|
+
}
|
|
192
|
+
return reader;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Read a single saved transaction by its id.
|
|
196
|
+
* @param args.db Must be an [IModelDb]($backend) ([ECDb]($backend) does not support transactions).
|
|
197
|
+
* @param args.txnId The id of the saved transaction to read.
|
|
198
|
+
* @param args.valueOptions Row adaptor options controlling how EC property values are formatted.
|
|
199
|
+
* @param args.propFilter Controls which properties are included. Defaults to `All`.
|
|
200
|
+
* @beta
|
|
201
|
+
*/
|
|
202
|
+
static openTxn(args) {
|
|
203
|
+
const reader = new ChangesetReader(args.db);
|
|
204
|
+
reader._rowOptions = args.rowOptions ?? {};
|
|
205
|
+
const propFilter = args.propFilter ?? ChangesetReaderTypes_1.PropertyFilter.All;
|
|
206
|
+
reader._propFilter = propFilter;
|
|
207
|
+
try {
|
|
208
|
+
reader._nativeReader.openTxn(args.db[Symbols_1._nativeDb], args.txnId, args.invert ?? false, reader._propFilter);
|
|
209
|
+
}
|
|
210
|
+
catch (e) {
|
|
211
|
+
reader.close();
|
|
212
|
+
throw e;
|
|
213
|
+
}
|
|
214
|
+
return reader;
|
|
215
|
+
}
|
|
216
|
+
// ---------------------------------------------------------------------------
|
|
217
|
+
// Filtering
|
|
218
|
+
// ---------------------------------------------------------------------------
|
|
219
|
+
/**
|
|
220
|
+
* Restrict iteration to changes from the named SQLite tables.
|
|
221
|
+
* That means the rows for changes from other tables will be skipped entirely and won't be visible through the reader.
|
|
222
|
+
* @param tableNames SQLite table names to include.
|
|
223
|
+
* Note: Table names must be provided in the correct case for proper filtering.
|
|
224
|
+
* @beta
|
|
225
|
+
*/
|
|
226
|
+
setTableNameFilters(tableNames) {
|
|
227
|
+
this._nativeReader.setTableNameFilters(Array.from(tableNames));
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Restrict iteration to changes with the given operation types.
|
|
231
|
+
* That means the rows for changes with other operation types will be skipped entirely and won't be visible through the reader.
|
|
232
|
+
* @param ops Operations to include.
|
|
233
|
+
* @beta
|
|
234
|
+
*/
|
|
235
|
+
setOpCodeFilters(ops) {
|
|
236
|
+
this._nativeReader.setOpCodeFilters(Array.from(ops));
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Restrict iteration to changes for the given EC class names.
|
|
240
|
+
* That means the rows for changes from other EC classes will be skipped entirely and won't be visible through the reader.
|
|
241
|
+
* @param classNames EC class names to include. The classNames should be in the full name format(i.e. "SchemaName:ClassName").
|
|
242
|
+
* 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.
|
|
243
|
+
* @beta
|
|
244
|
+
*/
|
|
245
|
+
setClassNameFilters(classNames) {
|
|
246
|
+
this._nativeReader.setClassNameFilters(Array.from(classNames));
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Remove the table-name filters
|
|
250
|
+
* @beta
|
|
251
|
+
*/
|
|
252
|
+
clearTableNameFilters() {
|
|
253
|
+
this._nativeReader.clearTableNameFilters();
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Remove the op-code filters
|
|
257
|
+
* @beta
|
|
258
|
+
*/
|
|
259
|
+
clearOpCodeFilters() {
|
|
260
|
+
this._nativeReader.clearOpCodeFilters();
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Remove the class-name filters
|
|
264
|
+
* @beta
|
|
265
|
+
*/
|
|
266
|
+
clearClassNameFilters() {
|
|
267
|
+
this._nativeReader.clearClassNameFilters();
|
|
268
|
+
}
|
|
269
|
+
// ---------------------------------------------------------------------------
|
|
270
|
+
// Iteration
|
|
271
|
+
// ---------------------------------------------------------------------------
|
|
272
|
+
/**
|
|
273
|
+
* Advance to the next change and populate `inserted` and/or `deleted`.
|
|
274
|
+
* @returns `true` while positioned on a valid change; `false` when the stream is exhausted.
|
|
275
|
+
* @beta
|
|
276
|
+
*/
|
|
277
|
+
step() {
|
|
278
|
+
this.inserted = undefined;
|
|
279
|
+
this.deleted = undefined;
|
|
280
|
+
this._op = undefined;
|
|
281
|
+
this._isECTable = undefined;
|
|
282
|
+
this._tableName = undefined;
|
|
283
|
+
this._isIndirectChange = undefined;
|
|
284
|
+
if (this._nativeReader.step()) {
|
|
285
|
+
this._changeIndex++;
|
|
286
|
+
const meta = this._nativeReader.getChangeMetadata();
|
|
287
|
+
const nativeOp = meta.opCode;
|
|
288
|
+
const op = nativeOp === core_bentley_1.DbOpcode.Insert ? "Inserted" : nativeOp === core_bentley_1.DbOpcode.Update ? "Updated" : "Deleted";
|
|
289
|
+
this._op = op;
|
|
290
|
+
this._tableName = meta.tableName;
|
|
291
|
+
this._isIndirectChange = meta.isIndirectChange;
|
|
292
|
+
this._isECTable = meta.isECTable;
|
|
293
|
+
const nativeRowOpts = this._rowOptions ? this.toNativeRowOptions(this._rowOptions) : {};
|
|
294
|
+
if (op === "Inserted" || op === "Updated") {
|
|
295
|
+
const rowValue = this._nativeReader.getValue(core_bentley_1.DbChangeStage.New, nativeRowOpts);
|
|
296
|
+
if (rowValue !== undefined) {
|
|
297
|
+
this.inserted = {
|
|
298
|
+
...rowValue.data,
|
|
299
|
+
$meta: {
|
|
300
|
+
op,
|
|
301
|
+
tables: [this._tableName],
|
|
302
|
+
changeIndexes: [this._changeIndex],
|
|
303
|
+
stage: "New",
|
|
304
|
+
instanceKey: rowValue.key,
|
|
305
|
+
propFilter: this._propFilter,
|
|
306
|
+
changeFetchedPropNames: rowValue.changeFetchedPropNames,
|
|
307
|
+
rowOptions: this._rowOptions,
|
|
308
|
+
isIndirectChange: this._isIndirectChange,
|
|
309
|
+
},
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (op === "Deleted" || op === "Updated") {
|
|
314
|
+
const rowValue = this._nativeReader.getValue(core_bentley_1.DbChangeStage.Old, nativeRowOpts);
|
|
315
|
+
if (rowValue !== undefined) {
|
|
316
|
+
this.deleted = {
|
|
317
|
+
...rowValue.data,
|
|
318
|
+
$meta: {
|
|
319
|
+
op,
|
|
320
|
+
tables: [this._tableName],
|
|
321
|
+
changeIndexes: [this._changeIndex],
|
|
322
|
+
stage: "Old",
|
|
323
|
+
instanceKey: rowValue.key,
|
|
324
|
+
propFilter: this._propFilter,
|
|
325
|
+
changeFetchedPropNames: rowValue.changeFetchedPropNames,
|
|
326
|
+
rowOptions: this._rowOptions,
|
|
327
|
+
isIndirectChange: this._isIndirectChange,
|
|
328
|
+
},
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* SQLite opcode of the current change.
|
|
338
|
+
* Valid only after a successful call to [[step]].
|
|
339
|
+
* @beta
|
|
340
|
+
*/
|
|
341
|
+
get op() {
|
|
342
|
+
if (this._op === undefined)
|
|
343
|
+
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadRequest, "ChangesetReader.op is only valid after step() has positioned the reader on a current valid change.");
|
|
344
|
+
return this._op;
|
|
345
|
+
}
|
|
346
|
+
// ---------------------------------------------------------------------------
|
|
347
|
+
// Lifecycle
|
|
348
|
+
// ---------------------------------------------------------------------------
|
|
349
|
+
/**
|
|
350
|
+
* Close the reader and release all native resources.
|
|
351
|
+
* @beta
|
|
352
|
+
*/
|
|
353
|
+
close() {
|
|
354
|
+
this._changeIndex = 0;
|
|
355
|
+
this._op = undefined;
|
|
356
|
+
this._isECTable = undefined;
|
|
357
|
+
this._tableName = undefined;
|
|
358
|
+
this._isIndirectChange = undefined;
|
|
359
|
+
this.inserted = undefined;
|
|
360
|
+
this.deleted = undefined;
|
|
361
|
+
this._nativeReader.close();
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Implements the `Disposable` contract — calls [[close]].
|
|
365
|
+
* @beta
|
|
366
|
+
*/
|
|
367
|
+
[Symbol.dispose]() {
|
|
368
|
+
this.close();
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
exports.ChangesetReader = ChangesetReader;
|
|
372
|
+
//# sourceMappingURL=ChangesetReader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChangesetReader.js","sourceRoot":"","sources":["../../src/ChangesetReader.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAwF;AACxF,oDAAiD;AAEjD,8DAAyD;AACzD,gDAA+C;AAE/C,iEAA6H;AAI7H,8EAA8E;AAC9E,kBAAkB;AAClB,8EAA8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EAAE,CAAC;IACf,CAAC;CACF;AArXD,0CAqXC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ECDb\n */\nimport { DbChangeStage, DbOpcode, Id64String, IModelStatus } from \"@itwin/core-bentley\";\nimport { IModelError } from \"@itwin/core-common\";\nimport { IModelDb } from \"./IModelDb\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { _nativeDb } from \"./internal/Symbols\";\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport { ChangeInstance, ChangesetReaderArgs, ChangeSource, PropertyFilter, RowFormatOptions } from \"./ChangesetReaderTypes\";\nimport { AnyDb, SqliteChangeOp } from \"./SqliteChangesetReader\";\n\n\n// ---------------------------------------------------------------------------\n// ChangesetReader\n// ---------------------------------------------------------------------------\n\n/**\n * Reads EC-typed changeset data natively from a changeset file, changeset group,\n * in-memory transaction, or local un-pushed changes.\n *\n * Implements [ChangeSource]($backend) so rows can be fed directly into\n * [PartialChangeUnifier]($backend) to merge partial (per-table) instances into\n * complete EC instances.\n *\n * When the current row is a non-EC internal SQLite table, [[isECTable]] is `false`\n * and both [[inserted]] and [[deleted]] remain `undefined`.\n *\n * @note The native reader operates one SQLite table-row at a time. Multi-table EC\n * instances must be merged using [PartialChangeUnifier]($backend).\n * @beta\n */\nexport class ChangesetReader implements Disposable, ChangeSource {\n private readonly _nativeReader: IModelJsNative.ChangesetReader = new IModelNative.platform.ChangesetReader();\n // Internal options — keep ECClassId as raw Id so the unifier can use it as-is.\n private _rowOptions?: RowFormatOptions;\n private _propFilter: PropertyFilter = PropertyFilter.All;\n private _changeIndex = 0;\n private _op?: SqliteChangeOp;\n private _isECTable?: boolean;\n private _tableName?: string;\n private _isIndirectChange?: boolean;\n\n /** The db used for EC schema resolution. */\n public readonly db: AnyDb;\n\n /**\n * `true` when the current row belongs to an EC-mapped table.\n * Valid only after a successful call to [[step]].\n * @beta\n */\n public get isECTable(): boolean {\n if (this._isECTable === undefined)\n throw new IModelError(IModelStatus.BadRequest, \"ChangesetReader.isECTable is only valid after step() has positioned the reader on a current valid change.\");\n return this._isECTable;\n }\n\n /**\n * Name of the SQLite table for the current change row.\n * Valid only after a successful call to [[step]].\n * @beta\n */\n public get tableName(): string {\n if (this._tableName === undefined)\n throw new IModelError(IModelStatus.BadRequest, \"ChangesetReader.tableName is only valid after step() has positioned the reader on a current valid change.\");\n return this._tableName;\n }\n\n /**\n * `true` when the current change was applied indirectly\n * Valid only after a successful call to [[step]].\n * @beta\n */\n public get isIndirectChange(): boolean {\n if (this._isIndirectChange === undefined)\n throw new IModelError(IModelStatus.BadRequest, \"ChangesetReader.isIndirectChange is only valid after step() has positioned the reader on a current valid change.\");\n return this._isIndirectChange;\n }\n\n /**\n * Post-change (inserted or updated-new) EC instance, populated after each [[step]] call.\n * `undefined` when the current row is a Delete or a non-EC table row or [[step]] returned false.\n * @beta\n */\n public inserted?: ChangeInstance;\n\n /**\n * Pre-change (deleted or updated-old) EC instance, populated after each [[step]] call.\n * `undefined` when the current row is an Insert or a non-EC table row or [[step]] returned false.\n * @beta\n */\n public deleted?: ChangeInstance;\n\n // Private — callers use static factory methods.\n private constructor(db: AnyDb) {\n this.db = db;\n }\n\n /** Map public RowFormatOptions to the native adaptor options.\n * @internal */\n private toNativeRowOptions(opts: RowFormatOptions): IModelJsNative.ECSqlRowAdaptorOptions {\n return {\n abbreviateBlobs: opts.abbreviateBlobs,\n classIdsToClassNames: opts.classIdsToClassNames,\n useJsName: opts.useJsName,\n };\n }\n\n // ---------------------------------------------------------------------------\n // Static factory methods\n // ---------------------------------------------------------------------------\n\n /**\n * Open a changeset file from disk.\n * @param args.fileName Absolute path to the changeset file.\n * @param args.db Database at or after the changeset's ending state, used for schema resolution.\n * @param args.invert When `true`, invert all operations (Insert↔Delete).\n * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.\n * @param args.propFilter Controls which properties are included. Defaults to `All`.\n * @beta\n */\n public static openFile(args: { readonly fileName: string } & ChangesetReaderArgs): ChangesetReader {\n const reader = new ChangesetReader(args.db);\n reader._rowOptions = args.rowOptions;\n const propFilter = args.propFilter ?? PropertyFilter.All;\n reader._propFilter = propFilter;\n try {\n reader._nativeReader.openFile(args.db[_nativeDb], args.fileName, args.invert ?? false, reader._propFilter);\n }\n catch (e) {\n reader.close();\n throw e;\n }\n return reader;\n }\n\n /**\n * Concatenate multiple changeset files and read them as a single logical stream.\n * @param args.changesetFiles Ordered list of changeset file paths.\n * @param args.db Database with schema at or ahead of the last changeset.\n * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.\n * @param args.propFilter Controls which properties are included. Defaults to `All`.\n * @beta\n */\n public static openGroup(args: { readonly changesetFiles: string[] } & ChangesetReaderArgs): ChangesetReader {\n if (args.changesetFiles.length === 0)\n throw new Error(\"changesetFiles must contain at least one file.\");\n const reader = new ChangesetReader(args.db);\n reader._rowOptions = args.rowOptions;\n const propFilter = args.propFilter ?? PropertyFilter.All;\n reader._propFilter = propFilter;\n try {\n reader._nativeReader.openGroup(args.db[_nativeDb], args.changesetFiles, args.invert ?? false, reader._propFilter);\n }\n catch (e) {\n reader.close();\n throw e;\n }\n return reader;\n }\n\n /**\n * Read pending (not yet pushed) local changes from an open IModelDb.\n * @param args.db Must be an [IModelDb]($backend) (not [ECDb]($backend)).\n * @param args.includeInMemoryChanges Also include in-memory (not yet saved to disk) changes.\n * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.\n * @param args.propFilter Controls which properties are included. Defaults to `All`.\n * @beta\n */\n public static openLocalChanges(\n args: Omit<ChangesetReaderArgs, \"db\"> & { db: IModelDb; includeInMemoryChanges?: boolean },\n ): ChangesetReader {\n const reader = new ChangesetReader(args.db);\n reader._rowOptions = args.rowOptions;\n const propFilter = args.propFilter ?? PropertyFilter.All;\n reader._propFilter = propFilter;\n try {\n reader._nativeReader.openLocalChanges(args.db[_nativeDb], args.includeInMemoryChanges ?? false, args.invert ?? false, reader._propFilter);\n } catch (e) {\n reader.close();\n throw e;\n }\n return reader;\n }\n\n /**\n * Read the in-memory (not yet saved to disk) changes of an open IModelDb.\n * @param args.db Must be an [IModelDb]($backend).\n * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.\n * @param args.propFilter Controls which properties are included. Defaults to `All`.\n * @beta\n */\n public static openInMemoryChanges(\n args: Omit<ChangesetReaderArgs, \"db\"> & { db: IModelDb },\n ): ChangesetReader {\n const reader = new ChangesetReader(args.db);\n reader._rowOptions = args.rowOptions;\n const propFilter = args.propFilter ?? PropertyFilter.All;\n reader._propFilter = propFilter;\n try {\n reader._nativeReader.openInMemoryChanges(args.db[_nativeDb], args.invert ?? false, reader._propFilter);\n } catch (e) {\n reader.close();\n throw e;\n }\n return reader;\n }\n\n /**\n * Read a single saved transaction by its id.\n * @param args.db Must be an [IModelDb]($backend) ([ECDb]($backend) does not support transactions).\n * @param args.txnId The id of the saved transaction to read.\n * @param args.valueOptions Row adaptor options controlling how EC property values are formatted.\n * @param args.propFilter Controls which properties are included. Defaults to `All`.\n * @beta\n */\n public static openTxn(\n args: Omit<ChangesetReaderArgs, \"db\"> & { db: IModelDb; txnId: Id64String },\n ): ChangesetReader {\n const reader = new ChangesetReader(args.db);\n reader._rowOptions = args.rowOptions ?? {};\n const propFilter = args.propFilter ?? PropertyFilter.All;\n reader._propFilter = propFilter;\n try {\n reader._nativeReader.openTxn(args.db[_nativeDb], args.txnId, args.invert ?? false, reader._propFilter);\n } catch (e) {\n reader.close();\n throw e;\n }\n return reader;\n }\n\n // ---------------------------------------------------------------------------\n // Filtering\n // ---------------------------------------------------------------------------\n\n /**\n * Restrict iteration to changes from the named SQLite tables.\n * That means the rows for changes from other tables will be skipped entirely and won't be visible through the reader.\n * @param tableNames SQLite table names to include.\n * Note: Table names must be provided in the correct case for proper filtering.\n * @beta\n */\n public setTableNameFilters(tableNames: Set<string>): void {\n this._nativeReader.setTableNameFilters(Array.from(tableNames));\n }\n\n /**\n * Restrict iteration to changes with the given operation types.\n * That means the rows for changes with other operation types will be skipped entirely and won't be visible through the reader.\n * @param ops Operations to include.\n * @beta\n */\n public setOpCodeFilters(ops: Set<SqliteChangeOp>): void {\n this._nativeReader.setOpCodeFilters(Array.from(ops));\n }\n\n /**\n * Restrict iteration to changes for the given EC class names.\n * That means the rows for changes from other EC classes will be skipped entirely and won't be visible through the reader.\n * @param classNames EC class names to include. The classNames should be in the full name format(i.e. \"SchemaName:ClassName\").\n * 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.\n * @beta\n */\n public setClassNameFilters(classNames: Set<string>): void {\n this._nativeReader.setClassNameFilters(Array.from(classNames));\n }\n\n /**\n * Remove the table-name filters\n * @beta\n */\n public clearTableNameFilters(): void {\n this._nativeReader.clearTableNameFilters();\n }\n\n /**\n * Remove the op-code filters\n * @beta\n */\n public clearOpCodeFilters(): void {\n this._nativeReader.clearOpCodeFilters();\n }\n\n /**\n * Remove the class-name filters\n * @beta\n */\n public clearClassNameFilters(): void {\n this._nativeReader.clearClassNameFilters();\n }\n\n // ---------------------------------------------------------------------------\n // Iteration\n // ---------------------------------------------------------------------------\n\n /**\n * Advance to the next change and populate `inserted` and/or `deleted`.\n * @returns `true` while positioned on a valid change; `false` when the stream is exhausted.\n * @beta\n */\n public step(): boolean {\n this.inserted = undefined;\n this.deleted = undefined;\n this._op = undefined;\n this._isECTable = undefined;\n this._tableName = undefined;\n this._isIndirectChange = undefined;\n\n if (this._nativeReader.step()) {\n this._changeIndex++;\n const meta = this._nativeReader.getChangeMetadata();\n const nativeOp = meta.opCode;\n const op: SqliteChangeOp = nativeOp === DbOpcode.Insert ? \"Inserted\" : nativeOp === DbOpcode.Update ? \"Updated\" : \"Deleted\";\n this._op = op;\n\n this._tableName = meta.tableName;\n this._isIndirectChange = meta.isIndirectChange;\n this._isECTable = meta.isECTable;\n\n const nativeRowOpts = this._rowOptions ? this.toNativeRowOptions(this._rowOptions) : {};\n\n if (op === \"Inserted\" || op === \"Updated\") {\n const rowValue = this._nativeReader.getValue(DbChangeStage.New, nativeRowOpts);\n if (rowValue !== undefined) {\n this.inserted = {\n ...rowValue.data,\n $meta: {\n op,\n tables: [this._tableName],\n changeIndexes: [this._changeIndex],\n stage: \"New\",\n instanceKey: rowValue.key,\n propFilter: this._propFilter,\n changeFetchedPropNames: rowValue.changeFetchedPropNames,\n rowOptions: this._rowOptions,\n isIndirectChange: this._isIndirectChange,\n },\n };\n }\n }\n\n if (op === \"Deleted\" || op === \"Updated\") {\n const rowValue = this._nativeReader.getValue(DbChangeStage.Old, nativeRowOpts);\n if (rowValue !== undefined) {\n this.deleted = {\n ...rowValue.data,\n $meta: {\n op,\n tables: [this._tableName],\n changeIndexes: [this._changeIndex],\n stage: \"Old\",\n instanceKey: rowValue.key,\n propFilter: this._propFilter,\n changeFetchedPropNames: rowValue.changeFetchedPropNames,\n rowOptions: this._rowOptions,\n isIndirectChange: this._isIndirectChange,\n },\n };\n }\n }\n\n return true;\n }\n\n return false;\n }\n\n /**\n * SQLite opcode of the current change.\n * Valid only after a successful call to [[step]].\n * @beta\n */\n public get op(): SqliteChangeOp {\n if (this._op === undefined)\n throw new IModelError(IModelStatus.BadRequest, \"ChangesetReader.op is only valid after step() has positioned the reader on a current valid change.\");\n return this._op;\n }\n\n // ---------------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------------\n\n /**\n * Close the reader and release all native resources.\n * @beta\n */\n public close(): void {\n this._changeIndex = 0;\n this._op = undefined;\n this._isECTable = undefined;\n this._tableName = undefined;\n this._isIndirectChange = undefined;\n this.inserted = undefined;\n this.deleted = undefined;\n this._nativeReader.close();\n }\n\n /**\n * Implements the `Disposable` contract — calls [[close]].\n * @beta\n */\n public [Symbol.dispose](): void {\n this.close();\n }\n}\n\n\n"]}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module ECDb
|
|
3
|
+
*/
|
|
4
|
+
import { AnyDb, SqliteChangeOp, SqliteValueStage } from "./SqliteChangesetReader";
|
|
5
|
+
/**
|
|
6
|
+
* Controls which properties are included in the output of [ChangesetReader]($backend).
|
|
7
|
+
* @beta
|
|
8
|
+
*/
|
|
9
|
+
export declare enum PropertyFilter {
|
|
10
|
+
/** All EC properties mapped to changed tables. */
|
|
11
|
+
All = 0,
|
|
12
|
+
/** For classes whose base class is `BisCore:Element`, only `BisCore:Element` properties
|
|
13
|
+
* mapped to changed tables are returned. If no `BisCore:Element` class property changed,
|
|
14
|
+
* only `ECInstanceId` and `ECClassId` are returned. For other classes all mapped properties
|
|
15
|
+
* are returned. */
|
|
16
|
+
BisCoreElement = 1,
|
|
17
|
+
/** Only `ECInstanceId` and `ECClassId`. */
|
|
18
|
+
InstanceKey = 2
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Row-formatting options for [ChangesetReader]($backend) factory methods.
|
|
22
|
+
* Controls how EC property values are represented in the returned instances.
|
|
23
|
+
* @beta
|
|
24
|
+
*/
|
|
25
|
+
export interface RowFormatOptions {
|
|
26
|
+
/**
|
|
27
|
+
* When `false`, binary properties are returned as full `Uint8Array` values.
|
|
28
|
+
* When `true` (or omitted), binary properties are summarized as `{ bytes: N }`.
|
|
29
|
+
*/
|
|
30
|
+
abbreviateBlobs?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* When `true`, `ECClassId` and `RelECClassId` values are converted from hex strings
|
|
33
|
+
* to fully-qualified class names (e.g. `"BisCore.DrawingModel"`).
|
|
34
|
+
*/
|
|
35
|
+
classIdsToClassNames?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* When `true`, all property keys and struct sub-keys are returned in camelCase
|
|
38
|
+
* (e.g. `id`, `className`, `lastMod`). Navigation property sub-keys use
|
|
39
|
+
* `{ id, relClassName }` instead of `{ Id, RelECClassId }`.
|
|
40
|
+
*/
|
|
41
|
+
useJsName?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Metadata attached to every [[ChangeInstance]].
|
|
45
|
+
* @beta
|
|
46
|
+
*/
|
|
47
|
+
export interface ChangeMeta {
|
|
48
|
+
/** SQLite tables that contributed columns to this change row. */
|
|
49
|
+
tables: string[];
|
|
50
|
+
/** Operation that produced this change. */
|
|
51
|
+
op: SqliteChangeOp;
|
|
52
|
+
/** Whether this is the pre-change (`"Old"`) or post-change (`"New"`) snapshot. */
|
|
53
|
+
stage: SqliteValueStage;
|
|
54
|
+
/** Change-stream index positions. */
|
|
55
|
+
changeIndexes: number[];
|
|
56
|
+
/**
|
|
57
|
+
* ECInstanceId and class Id in format "<ECInstanceId>-<ECClassId>".
|
|
58
|
+
*/
|
|
59
|
+
instanceKey: string;
|
|
60
|
+
/** Reader property filter that was active when this change row was captured. */
|
|
61
|
+
propFilter: PropertyFilter;
|
|
62
|
+
/** EC property names fetched from the current row of changeset or transaction or any other change stream.
|
|
63
|
+
For compound data properties like point2d, point3d or navigation properties,
|
|
64
|
+
the full name of the property is returned in case all the components of the property are fetched from the change.
|
|
65
|
+
If all of the components are not fetched from the changes(meaning they did not change),
|
|
66
|
+
then the individual component names which changed are returned smartly by using `.` as a separator (e.g. "MyPoint.X", "MyPoint.Y" for a point3d property "MyPoint" if only X and Y changed).
|
|
67
|
+
For struct properties the property names are always returned in the "StructProp.MemberName" format.
|
|
68
|
+
So if only X changed for a point2d property named "Myp2d" inide a struct "CustomStruct", the returned property name will be "CustomStruct.Myp2d.X".
|
|
69
|
+
Similaly if both X and Y changed for the same point2d property, the returned property name will be "CustomStruct.Myp2d". */
|
|
70
|
+
changeFetchedPropNames: string[];
|
|
71
|
+
/** Row adaptor options that were active when this change row was captured. */
|
|
72
|
+
rowOptions?: RowFormatOptions;
|
|
73
|
+
/** `true` when the change was applied indirectly */
|
|
74
|
+
isIndirectChange: boolean;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* An EC instance produced by [ChangesetReader]($backend) after each `step()`.
|
|
78
|
+
* Contains the EC property bag plus mandatory `$meta` metadata.
|
|
79
|
+
* @beta
|
|
80
|
+
*/
|
|
81
|
+
export interface ChangeInstance {
|
|
82
|
+
/** Metadata describing the origin and identity of this change. */
|
|
83
|
+
$meta: ChangeMeta;
|
|
84
|
+
/** EC property bag (ECClassId, ECInstanceId, user-defined properties, ...). */
|
|
85
|
+
[key: string]: any;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Contract for any reader that produces EC-typed changed instances compatible with
|
|
89
|
+
* [PartialChangeUnifier]($backend).
|
|
90
|
+
* @beta
|
|
91
|
+
*/
|
|
92
|
+
export interface ChangeSource {
|
|
93
|
+
/** The SQLite opcode of the current change row. */
|
|
94
|
+
readonly op: SqliteChangeOp;
|
|
95
|
+
/**
|
|
96
|
+
* The newly-inserted or post-update EC instance.
|
|
97
|
+
* `undefined` when the current row is a Delete, or when `isECTable` is `false`.
|
|
98
|
+
*/
|
|
99
|
+
readonly inserted?: ChangeInstance;
|
|
100
|
+
/**
|
|
101
|
+
* The deleted or pre-update EC instance.
|
|
102
|
+
* `undefined` when the current row is an Insert, or when `isECTable` is `false`.
|
|
103
|
+
*/
|
|
104
|
+
readonly deleted?: ChangeInstance;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Arguments common to all [ChangesetReader]($backend) `open*` factory methods.
|
|
108
|
+
* @beta
|
|
109
|
+
*/
|
|
110
|
+
export interface ChangesetReaderArgs {
|
|
111
|
+
/** The db used to resolve EC schema. Must be at or ahead of the changeset being read. */
|
|
112
|
+
readonly db: AnyDb;
|
|
113
|
+
/** invert the changeset operations */
|
|
114
|
+
readonly invert?: boolean;
|
|
115
|
+
/** Row adaptor options controlling how EC property values are formatted. */
|
|
116
|
+
readonly rowOptions?: RowFormatOptions;
|
|
117
|
+
/** Controls which properties are included in the change output. Defaults to PropertyFilter.All. */
|
|
118
|
+
readonly propFilter?: PropertyFilter;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=ChangesetReaderTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChangesetReaderTypes.d.ts","sourceRoot":"","sources":["../../src/ChangesetReaderTypes.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAMlF;;;GAGG;AACH,oBAAY,cAAc;IACxB,kDAAkD;IAClD,GAAG,IAAI;IACP;;;uBAGmB;IACnB,cAAc,IAAI;IAClB,2CAA2C;IAC3C,WAAW,IAAI;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAMD;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,iEAAiE;IACjE,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,2CAA2C;IAC3C,EAAE,EAAE,cAAc,CAAC;IACnB,kFAAkF;IAClF,KAAK,EAAE,gBAAgB,CAAC;IACxB,qCAAqC;IACrC,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,gFAAgF;IAChF,UAAU,EAAE,cAAc,CAAC;IAC3B;;;;;;;+HAO2H;IAC3H,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC,8EAA8E;IAC9E,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,oDAAoD;IACpD,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,kEAAkE;IAClE,KAAK,EAAE,UAAU,CAAC;IAClB,+EAA+E;IAC/E,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,mDAAmD;IACnD,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;CACnC;AAMD;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,yFAAyF;IACzF,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,sCAAsC;IACtC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,4EAA4E;IAC5E,QAAQ,CAAC,UAAU,CAAC,EAAE,gBAAgB,CAAC;IACvC,mGAAmG;IACnG,QAAQ,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC;CACtC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PropertyFilter = void 0;
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Type aliases
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
/**
|
|
8
|
+
* Controls which properties are included in the output of [ChangesetReader]($backend).
|
|
9
|
+
* @beta
|
|
10
|
+
*/
|
|
11
|
+
var PropertyFilter;
|
|
12
|
+
(function (PropertyFilter) {
|
|
13
|
+
/** All EC properties mapped to changed tables. */
|
|
14
|
+
PropertyFilter[PropertyFilter["All"] = 0] = "All";
|
|
15
|
+
/** For classes whose base class is `BisCore:Element`, only `BisCore:Element` properties
|
|
16
|
+
* mapped to changed tables are returned. If no `BisCore:Element` class property changed,
|
|
17
|
+
* only `ECInstanceId` and `ECClassId` are returned. For other classes all mapped properties
|
|
18
|
+
* are returned. */
|
|
19
|
+
PropertyFilter[PropertyFilter["BisCoreElement"] = 1] = "BisCoreElement";
|
|
20
|
+
/** Only `ECInstanceId` and `ECClassId`. */
|
|
21
|
+
PropertyFilter[PropertyFilter["InstanceKey"] = 2] = "InstanceKey";
|
|
22
|
+
})(PropertyFilter || (exports.PropertyFilter = PropertyFilter = {}));
|
|
23
|
+
//# sourceMappingURL=ChangesetReaderTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChangesetReaderTypes.js","sourceRoot":"","sources":["../../src/ChangesetReaderTypes.ts"],"names":[],"mappings":";;;AASA,8EAA8E;AAC9E,eAAe;AACf,8EAA8E;AAE9E;;;GAGG;AACH,IAAY,cAUX;AAVD,WAAY,cAAc;IACxB,kDAAkD;IAClD,iDAAO,CAAA;IACP;;;uBAGmB;IACnB,uEAAkB,CAAA;IAClB,2CAA2C;IAC3C,iEAAe,CAAA;AACjB,CAAC,EAVW,cAAc,8BAAd,cAAc,QAUzB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ECDb\n */\nimport { AnyDb, SqliteChangeOp, SqliteValueStage } from \"./SqliteChangesetReader\";\n\n// ---------------------------------------------------------------------------\n// Type aliases\n// ---------------------------------------------------------------------------\n\n/**\n * Controls which properties are included in the output of [ChangesetReader]($backend).\n * @beta\n */\nexport enum PropertyFilter {\n /** All EC properties mapped to changed tables. */\n All = 0,\n /** For classes whose base class is `BisCore:Element`, only `BisCore:Element` properties\n * mapped to changed tables are returned. If no `BisCore:Element` class property changed,\n * only `ECInstanceId` and `ECClassId` are returned. For other classes all mapped properties\n * are returned. */\n BisCoreElement = 1,\n /** Only `ECInstanceId` and `ECClassId`. */\n InstanceKey = 2,\n}\n\n/**\n * Row-formatting options for [ChangesetReader]($backend) factory methods.\n * Controls how EC property values are represented in the returned instances.\n * @beta\n */\nexport interface RowFormatOptions {\n /**\n * When `false`, binary properties are returned as full `Uint8Array` values.\n * When `true` (or omitted), binary properties are summarized as `{ bytes: N }`.\n */\n abbreviateBlobs?: boolean;\n /**\n * When `true`, `ECClassId` and `RelECClassId` values are converted from hex strings\n * to fully-qualified class names (e.g. `\"BisCore.DrawingModel\"`).\n */\n classIdsToClassNames?: boolean;\n /**\n * When `true`, all property keys and struct sub-keys are returned in camelCase\n * (e.g. `id`, `className`, `lastMod`). Navigation property sub-keys use\n * `{ id, relClassName }` instead of `{ Id, RelECClassId }`.\n */\n useJsName?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Public interfaces\n// ---------------------------------------------------------------------------\n\n/**\n * Metadata attached to every [[ChangeInstance]].\n * @beta\n */\nexport interface ChangeMeta {\n /** SQLite tables that contributed columns to this change row. */\n tables: string[];\n /** Operation that produced this change. */\n op: SqliteChangeOp;\n /** Whether this is the pre-change (`\"Old\"`) or post-change (`\"New\"`) snapshot. */\n stage: SqliteValueStage;\n /** Change-stream index positions. */\n changeIndexes: number[];\n /**\n * ECInstanceId and class Id in format \"<ECInstanceId>-<ECClassId>\".\n */\n instanceKey: string;\n /** Reader property filter that was active when this change row was captured. */\n propFilter: PropertyFilter;\n /** EC property names fetched from the current row of changeset or transaction or any other change stream.\n For compound data properties like point2d, point3d or navigation properties,\n the full name of the property is returned in case all the components of the property are fetched from the change.\n If all of the components are not fetched from the changes(meaning they did not change),\n then the individual component names which changed are returned smartly by using `.` as a separator (e.g. \"MyPoint.X\", \"MyPoint.Y\" for a point3d property \"MyPoint\" if only X and Y changed).\n For struct properties the property names are always returned in the \"StructProp.MemberName\" format.\n So if only X changed for a point2d property named \"Myp2d\" inide a struct \"CustomStruct\", the returned property name will be \"CustomStruct.Myp2d.X\".\n Similaly if both X and Y changed for the same point2d property, the returned property name will be \"CustomStruct.Myp2d\". */\n changeFetchedPropNames: string[];\n /** Row adaptor options that were active when this change row was captured. */\n rowOptions?: RowFormatOptions;\n /** `true` when the change was applied indirectly */\n isIndirectChange: boolean;\n}\n\n/**\n * An EC instance produced by [ChangesetReader]($backend) after each `step()`.\n * Contains the EC property bag plus mandatory `$meta` metadata.\n * @beta\n */\nexport interface ChangeInstance {\n /** Metadata describing the origin and identity of this change. */\n $meta: ChangeMeta;\n /** EC property bag (ECClassId, ECInstanceId, user-defined properties, ...). */\n [key: string]: any;\n}\n\n/**\n * Contract for any reader that produces EC-typed changed instances compatible with\n * [PartialChangeUnifier]($backend).\n * @beta\n */\nexport interface ChangeSource {\n /** The SQLite opcode of the current change row. */\n readonly op: SqliteChangeOp;\n /**\n * The newly-inserted or post-update EC instance.\n * `undefined` when the current row is a Delete, or when `isECTable` is `false`.\n */\n readonly inserted?: ChangeInstance;\n /**\n * The deleted or pre-update EC instance.\n * `undefined` when the current row is an Insert, or when `isECTable` is `false`.\n */\n readonly deleted?: ChangeInstance;\n}\n\n// ---------------------------------------------------------------------------\n// ChangesetReader args / options\n// ---------------------------------------------------------------------------\n\n/**\n * Arguments common to all [ChangesetReader]($backend) `open*` factory methods.\n * @beta\n */\nexport interface ChangesetReaderArgs {\n /** The db used to resolve EC schema. Must be at or ahead of the changeset being read. */\n readonly db: AnyDb;\n /** invert the changeset operations */\n readonly invert?: boolean;\n /** Row adaptor options controlling how EC property values are formatted. */\n readonly rowOptions?: RowFormatOptions;\n /** Controls which properties are included in the change output. Defaults to PropertyFilter.All. */\n readonly propFilter?: PropertyFilter;\n}\n"]}
|
package/lib/cjs/CloudSqlite.d.ts
CHANGED
|
@@ -369,7 +369,7 @@ export declare namespace CloudSqlite {
|
|
|
369
369
|
* Notes:
|
|
370
370
|
* - all methods and accessors of this interface (other than `initializeContainer`) require that the `connect` method be successfully called first.
|
|
371
371
|
* Otherwise they will throw an exception or return meaningless values.
|
|
372
|
-
* - before a SQLiteDb in a container may be opened for write access, the container's write lock must be held (see [[acquireWriteLock]].
|
|
372
|
+
* - before a SQLiteDb in a container may be opened for write access, the container's write lock must be held (see [[acquireWriteLock]]).
|
|
373
373
|
* - a single CloudContainer may hold more than one SQLiteDb, but often they are 1:1.
|
|
374
374
|
* - the write lock is per-Container, not per-SQLiteDb (which is the reason they are often 1:1)
|
|
375
375
|
* - the accessToken (a SAS key) member provides time limited, restricted, access to the container. It must be refreshed before it expires.
|