@itwin/presentation-frontend 5.0.0-dev.9 → 5.0.0-dev.90
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 +53 -1
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts +3 -3
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js +11 -9
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/Diagnostics.js.map +1 -1
- package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js +2 -1
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/LocalizationHelper.js +1 -0
- package/lib/cjs/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.d.ts +12 -2
- package/lib/cjs/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.js +16 -7
- package/lib/cjs/presentation-frontend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts +4 -2
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.js +31 -21
- package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetManager.js +2 -4
- package/lib/cjs/presentation-frontend/RulesetManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js +4 -2
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/StreamedResponseGenerator.js +1 -0
- package/lib/cjs/presentation-frontend/StreamedResponseGenerator.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +4 -2
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +142 -126
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +2 -3
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +21 -19
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.d.ts +3 -0
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js +4 -0
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.d.ts +1 -0
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js +1 -0
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.d.ts +4 -0
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js +3 -0
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts +5 -2
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.js +35 -13
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts +2 -0
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js +2 -0
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts +27 -7
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js +192 -87
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts +3 -7
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js +6 -11
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend.js.map +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts +3 -3
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js +11 -9
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/Diagnostics.js.map +1 -1
- package/lib/esm/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js +2 -1
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/LocalizationHelper.js +1 -0
- package/lib/esm/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.d.ts +12 -2
- package/lib/esm/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.js +16 -7
- package/lib/esm/presentation-frontend/Presentation.js.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.d.ts +4 -2
- package/lib/esm/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.js +32 -22
- package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetManager.js +2 -4
- package/lib/esm/presentation-frontend/RulesetManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js +4 -2
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/StreamedResponseGenerator.js +1 -0
- package/lib/esm/presentation-frontend/StreamedResponseGenerator.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +4 -2
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +143 -127
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +2 -3
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +22 -20
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.d.ts +3 -0
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js +4 -0
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.d.ts +1 -0
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.js +1 -0
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.d.ts +4 -0
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js +3 -0
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts +5 -2
- package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHandler.js +35 -13
- package/lib/esm/presentation-frontend/selection/SelectionHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts +2 -0
- package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js +2 -0
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts +27 -7
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.js +193 -88
- package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts +3 -7
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js +6 -10
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/esm/presentation-frontend.js.map +1 -1
- package/package.json +25 -26
|
@@ -27,126 +27,22 @@ var FavoritePropertiesScope;
|
|
|
27
27
|
* @public
|
|
28
28
|
*/
|
|
29
29
|
class FavoritePropertiesManager {
|
|
30
|
+
/**
|
|
31
|
+
* Used in tests to avoid collisions between multiple runs using the same storage
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
static FAVORITES_IDENTIFIER_PREFIX = "";
|
|
35
|
+
/** Event raised after favorite properties have changed. */
|
|
36
|
+
onFavoritesChanged = new core_bentley_1.BeEvent();
|
|
37
|
+
_storage;
|
|
38
|
+
_globalProperties;
|
|
39
|
+
_iTwinProperties;
|
|
40
|
+
_imodelProperties;
|
|
41
|
+
_imodelBaseClassesByClass;
|
|
42
|
+
_imodelInitializationPromises;
|
|
43
|
+
/** Property order is saved only in iModel scope */
|
|
44
|
+
_propertiesOrder;
|
|
30
45
|
constructor(props) {
|
|
31
|
-
/** Event raised after favorite properties have changed. */
|
|
32
|
-
this.onFavoritesChanged = new core_bentley_1.BeEvent();
|
|
33
|
-
/**
|
|
34
|
-
* Initialize favorite properties for the provided IModelConnection.
|
|
35
|
-
* @deprecated in 4.5. Initialization is performed automatically by all async methods and only needed for deprecated [[FavoritePropertiesManager.has]] and [[FavoritePropertiesManager.sortFields]].
|
|
36
|
-
*/
|
|
37
|
-
this.initializeConnection = async (imodel) => {
|
|
38
|
-
const imodelId = imodel.iModelId;
|
|
39
|
-
const iTwinId = imodel.iTwinId;
|
|
40
|
-
if (this._globalProperties === undefined) {
|
|
41
|
-
this._globalProperties = (await this._storage.loadProperties()) || new Set();
|
|
42
|
-
}
|
|
43
|
-
if (!this._iTwinProperties.has(iTwinId)) {
|
|
44
|
-
const iTwinProperties = (await this._storage.loadProperties(iTwinId)) || new Set();
|
|
45
|
-
this._iTwinProperties.set(iTwinId, iTwinProperties);
|
|
46
|
-
}
|
|
47
|
-
if (!this._imodelProperties.has(getiModelInfo(iTwinId, imodelId))) {
|
|
48
|
-
const imodelProperties = (await this._storage.loadProperties(iTwinId, imodelId)) || new Set();
|
|
49
|
-
this._imodelProperties.set(getiModelInfo(iTwinId, imodelId), imodelProperties);
|
|
50
|
-
}
|
|
51
|
-
const propertiesOrder = (await this._storage.loadPropertiesOrder(iTwinId, imodelId)) || [];
|
|
52
|
-
this._propertiesOrder.set(getiModelInfo(iTwinId, imodelId), propertiesOrder);
|
|
53
|
-
await this._adjustPropertyOrderInfos(iTwinId, imodelId);
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Function that removes order information of properties that are no longer
|
|
57
|
-
* favorited and adds missing order information for favorited properties.
|
|
58
|
-
*/
|
|
59
|
-
this._adjustPropertyOrderInfos = async (iTwinId, imodelId) => {
|
|
60
|
-
const propertiesOrder = this._propertiesOrder.get(getiModelInfo(iTwinId, imodelId));
|
|
61
|
-
const globalProperties = this._globalProperties;
|
|
62
|
-
const iTwinProperties = this._iTwinProperties.get(iTwinId);
|
|
63
|
-
const imodelProperties = this._imodelProperties.get(getiModelInfo(iTwinId, imodelId));
|
|
64
|
-
// favorite property infos that need to be added to the propertiesOrder array
|
|
65
|
-
const infosToAdd = new Set([...globalProperties, ...iTwinProperties, ...imodelProperties]);
|
|
66
|
-
for (let i = propertiesOrder.length - 1; i >= 0; i--) {
|
|
67
|
-
if (infosToAdd.has(propertiesOrder[i].name)) {
|
|
68
|
-
infosToAdd.delete(propertiesOrder[i].name);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
propertiesOrder.splice(i, 1);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
infosToAdd.forEach((info) => propertiesOrder.push({
|
|
75
|
-
name: info,
|
|
76
|
-
parentClassName: getPropertyClassName(info),
|
|
77
|
-
orderedTimestamp: new Date(),
|
|
78
|
-
priority: 0,
|
|
79
|
-
}));
|
|
80
|
-
let priority = propertiesOrder.length;
|
|
81
|
-
propertiesOrder.forEach((oi) => (oi.priority = priority--));
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* Sorts an array of fields with respect to favorite property order.
|
|
85
|
-
* Non-favorited fields get sorted by their default priority and always have lower priority than favorited fields.
|
|
86
|
-
* @param imodel IModelConnection.
|
|
87
|
-
* @param fields Array of Field's that needs to be sorted.
|
|
88
|
-
* @note `initializeConnection` must be called with the `imodel` before calling this function.
|
|
89
|
-
* @deprecated in 4.5. Use [[FavoritePropertiesManager.sortFieldsAsync]] instead. This method is not async, therefore it requires early initialization by calling [[FavoritePropertiesManager.initializeConnection]].
|
|
90
|
-
*/
|
|
91
|
-
this.sortFields = (imodel, fields) => {
|
|
92
|
-
this.validateInitialization(imodel);
|
|
93
|
-
const iTwinId = imodel.iTwinId;
|
|
94
|
-
const imodelId = imodel.iModelId;
|
|
95
|
-
const fieldPriority = new Map();
|
|
96
|
-
fields.forEach((field) => fieldPriority.set(field, this.getFieldPriority(field, iTwinId, imodelId)));
|
|
97
|
-
const sortFunction = (left, right) => {
|
|
98
|
-
const lp = fieldPriority.get(left);
|
|
99
|
-
const rp = fieldPriority.get(right);
|
|
100
|
-
return lp < rp
|
|
101
|
-
? 1
|
|
102
|
-
: lp > rp
|
|
103
|
-
? -1
|
|
104
|
-
: left.priority < right.priority
|
|
105
|
-
? 1 // if favorite fields have equal priorities, sort by field priority
|
|
106
|
-
: left.priority > right.priority
|
|
107
|
-
? -1
|
|
108
|
-
: left.name.localeCompare(right.name);
|
|
109
|
-
};
|
|
110
|
-
return fields.sort(sortFunction);
|
|
111
|
-
};
|
|
112
|
-
this._getBaseClassesByClass = async (imodel, neededClasses) => {
|
|
113
|
-
const iTwinId = imodel.iTwinId;
|
|
114
|
-
const imodelId = imodel.iModelId;
|
|
115
|
-
const imodelInfo = getiModelInfo(iTwinId, imodelId);
|
|
116
|
-
let baseClasses;
|
|
117
|
-
if (this._imodelBaseClassesByClass.has(imodelInfo)) {
|
|
118
|
-
baseClasses = this._imodelBaseClassesByClass.get(imodelInfo);
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
this._imodelBaseClassesByClass.set(imodelInfo, (baseClasses = {}));
|
|
122
|
-
}
|
|
123
|
-
const missingClasses = new Set();
|
|
124
|
-
neededClasses.forEach((className) => {
|
|
125
|
-
if (!baseClasses.hasOwnProperty(className)) {
|
|
126
|
-
missingClasses.add(className);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
if (missingClasses.size === 0) {
|
|
130
|
-
return baseClasses;
|
|
131
|
-
}
|
|
132
|
-
const query = `
|
|
133
|
-
SELECT (derivedSchema.Name || ':' || derivedClass.Name) AS "ClassFullName", (baseSchema.Name || ':' || baseClass.Name) AS "BaseClassFullName"
|
|
134
|
-
FROM ECDbMeta.ClassHasAllBaseClasses baseClassRels
|
|
135
|
-
INNER JOIN ECDbMeta.ECClassDef derivedClass ON derivedClass.ECInstanceId = baseClassRels.SourceECInstanceId
|
|
136
|
-
INNER JOIN ECDbMeta.ECSchemaDef derivedSchema ON derivedSchema.ECInstanceId = derivedClass.Schema.Id
|
|
137
|
-
INNER JOIN ECDbMeta.ECClassDef baseClass ON baseClass.ECInstanceId = baseClassRels.TargetECInstanceId
|
|
138
|
-
INNER JOIN ECDbMeta.ECSchemaDef baseSchema ON baseSchema.ECInstanceId = baseClass.Schema.Id
|
|
139
|
-
WHERE (derivedSchema.Name || ':' || derivedClass.Name) IN (${[...missingClasses].map((className) => `'${className}'`).join(",")})`;
|
|
140
|
-
const reader = imodel.createQueryReader(query, undefined, { rowFormat: core_common_1.QueryRowFormat.UseJsPropertyNames });
|
|
141
|
-
while (await reader.step()) {
|
|
142
|
-
const row = reader.current.toRow();
|
|
143
|
-
if (!(row.classFullName in baseClasses)) {
|
|
144
|
-
baseClasses[row.classFullName] = [];
|
|
145
|
-
}
|
|
146
|
-
baseClasses[row.classFullName].push(row.baseClassFullName);
|
|
147
|
-
}
|
|
148
|
-
return baseClasses;
|
|
149
|
-
};
|
|
150
46
|
this._storage = props.storage;
|
|
151
47
|
this._iTwinProperties = new Map();
|
|
152
48
|
this._imodelProperties = new Map();
|
|
@@ -154,12 +50,70 @@ class FavoritePropertiesManager {
|
|
|
154
50
|
this._imodelBaseClassesByClass = new Map();
|
|
155
51
|
this._imodelInitializationPromises = new Map();
|
|
156
52
|
}
|
|
157
|
-
dispose() {
|
|
53
|
+
[Symbol.dispose]() {
|
|
158
54
|
// istanbul ignore else
|
|
159
|
-
if ((0, core_bentley_1.
|
|
55
|
+
if ((0, core_bentley_1.isDisposable)(this._storage)) {
|
|
56
|
+
this._storage[Symbol.dispose]();
|
|
57
|
+
}
|
|
58
|
+
else if ((0, core_bentley_1.isIDisposable)(this._storage)) { /* eslint-disable-line @typescript-eslint/no-deprecated */
|
|
160
59
|
this._storage.dispose();
|
|
161
60
|
}
|
|
162
61
|
}
|
|
62
|
+
/** @deprecated in 5.0 Use [Symbol.dispose] instead. */
|
|
63
|
+
// istanbul ignore next
|
|
64
|
+
dispose() {
|
|
65
|
+
this[Symbol.dispose]();
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Initialize favorite properties for the provided IModelConnection.
|
|
69
|
+
* @deprecated in 4.5. Initialization is performed automatically by all async methods and only needed for deprecated [[FavoritePropertiesManager.has]] and [[FavoritePropertiesManager.sortFields]].
|
|
70
|
+
*/
|
|
71
|
+
initializeConnection = async (imodel) => {
|
|
72
|
+
const imodelId = imodel.iModelId;
|
|
73
|
+
const iTwinId = imodel.iTwinId;
|
|
74
|
+
if (this._globalProperties === undefined) {
|
|
75
|
+
this._globalProperties = (await this._storage.loadProperties()) || new Set();
|
|
76
|
+
}
|
|
77
|
+
if (!this._iTwinProperties.has(iTwinId)) {
|
|
78
|
+
const iTwinProperties = (await this._storage.loadProperties(iTwinId)) || new Set();
|
|
79
|
+
this._iTwinProperties.set(iTwinId, iTwinProperties);
|
|
80
|
+
}
|
|
81
|
+
if (!this._imodelProperties.has(getiModelInfo(iTwinId, imodelId))) {
|
|
82
|
+
const imodelProperties = (await this._storage.loadProperties(iTwinId, imodelId)) || new Set();
|
|
83
|
+
this._imodelProperties.set(getiModelInfo(iTwinId, imodelId), imodelProperties);
|
|
84
|
+
}
|
|
85
|
+
const propertiesOrder = (await this._storage.loadPropertiesOrder(iTwinId, imodelId)) || [];
|
|
86
|
+
this._propertiesOrder.set(getiModelInfo(iTwinId, imodelId), propertiesOrder);
|
|
87
|
+
await this._adjustPropertyOrderInfos(iTwinId, imodelId);
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Function that removes order information of properties that are no longer
|
|
91
|
+
* favorited and adds missing order information for favorited properties.
|
|
92
|
+
*/
|
|
93
|
+
_adjustPropertyOrderInfos = async (iTwinId, imodelId) => {
|
|
94
|
+
const propertiesOrder = this._propertiesOrder.get(getiModelInfo(iTwinId, imodelId));
|
|
95
|
+
const globalProperties = this._globalProperties;
|
|
96
|
+
const iTwinProperties = this._iTwinProperties.get(iTwinId);
|
|
97
|
+
const imodelProperties = this._imodelProperties.get(getiModelInfo(iTwinId, imodelId));
|
|
98
|
+
// favorite property infos that need to be added to the propertiesOrder array
|
|
99
|
+
const infosToAdd = new Set([...globalProperties, ...iTwinProperties, ...imodelProperties]);
|
|
100
|
+
for (let i = propertiesOrder.length - 1; i >= 0; i--) {
|
|
101
|
+
if (infosToAdd.has(propertiesOrder[i].name)) {
|
|
102
|
+
infosToAdd.delete(propertiesOrder[i].name);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
propertiesOrder.splice(i, 1);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
infosToAdd.forEach((info) => propertiesOrder.push({
|
|
109
|
+
name: info,
|
|
110
|
+
parentClassName: getPropertyClassName(info),
|
|
111
|
+
orderedTimestamp: new Date(),
|
|
112
|
+
priority: 0,
|
|
113
|
+
}));
|
|
114
|
+
let priority = propertiesOrder.length;
|
|
115
|
+
propertiesOrder.forEach((oi) => (oi.priority = priority--));
|
|
116
|
+
};
|
|
163
117
|
isInitialized(imodel) {
|
|
164
118
|
const iTwinId = imodel.iTwinId;
|
|
165
119
|
const imodelId = imodel.iModelId;
|
|
@@ -352,6 +306,35 @@ class FavoritePropertiesManager {
|
|
|
352
306
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
353
307
|
return this.has(field, imodel, scope);
|
|
354
308
|
}
|
|
309
|
+
/**
|
|
310
|
+
* Sorts an array of fields with respect to favorite property order.
|
|
311
|
+
* Non-favorited fields get sorted by their default priority and always have lower priority than favorited fields.
|
|
312
|
+
* @param imodel IModelConnection.
|
|
313
|
+
* @param fields Array of Field's that needs to be sorted.
|
|
314
|
+
* @note `initializeConnection` must be called with the `imodel` before calling this function.
|
|
315
|
+
* @deprecated in 4.5. Use [[FavoritePropertiesManager.sortFieldsAsync]] instead. This method is not async, therefore it requires early initialization by calling [[FavoritePropertiesManager.initializeConnection]].
|
|
316
|
+
*/
|
|
317
|
+
sortFields = (imodel, fields) => {
|
|
318
|
+
this.validateInitialization(imodel);
|
|
319
|
+
const iTwinId = imodel.iTwinId;
|
|
320
|
+
const imodelId = imodel.iModelId;
|
|
321
|
+
const fieldPriority = new Map();
|
|
322
|
+
fields.forEach((field) => fieldPriority.set(field, this.getFieldPriority(field, iTwinId, imodelId)));
|
|
323
|
+
const sortFunction = (left, right) => {
|
|
324
|
+
const lp = fieldPriority.get(left);
|
|
325
|
+
const rp = fieldPriority.get(right);
|
|
326
|
+
return lp < rp
|
|
327
|
+
? 1
|
|
328
|
+
: lp > rp
|
|
329
|
+
? -1
|
|
330
|
+
: left.priority < right.priority
|
|
331
|
+
? 1 // if favorite fields have equal priorities, sort by field priority
|
|
332
|
+
: left.priority > right.priority
|
|
333
|
+
? -1
|
|
334
|
+
: left.name.localeCompare(right.name);
|
|
335
|
+
};
|
|
336
|
+
return fields.sort(sortFunction);
|
|
337
|
+
};
|
|
355
338
|
/**
|
|
356
339
|
* Sorts an array of fields with respect to favorite property order.
|
|
357
340
|
* Non-favorited fields get sorted by their default priority and always have lower priority than favorited fields.
|
|
@@ -372,6 +355,44 @@ class FavoritePropertiesManager {
|
|
|
372
355
|
const mostRecent = getMostRecentOrderInfo(fieldOrderInfos);
|
|
373
356
|
return mostRecent.priority;
|
|
374
357
|
}
|
|
358
|
+
_getBaseClassesByClass = async (imodel, neededClasses) => {
|
|
359
|
+
const iTwinId = imodel.iTwinId;
|
|
360
|
+
const imodelId = imodel.iModelId;
|
|
361
|
+
const imodelInfo = getiModelInfo(iTwinId, imodelId);
|
|
362
|
+
let baseClasses;
|
|
363
|
+
if (this._imodelBaseClassesByClass.has(imodelInfo)) {
|
|
364
|
+
baseClasses = this._imodelBaseClassesByClass.get(imodelInfo);
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
this._imodelBaseClassesByClass.set(imodelInfo, (baseClasses = {}));
|
|
368
|
+
}
|
|
369
|
+
const missingClasses = new Set();
|
|
370
|
+
neededClasses.forEach((className) => {
|
|
371
|
+
if (!baseClasses.hasOwnProperty(className)) {
|
|
372
|
+
missingClasses.add(className);
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
if (missingClasses.size === 0) {
|
|
376
|
+
return baseClasses;
|
|
377
|
+
}
|
|
378
|
+
const query = `
|
|
379
|
+
SELECT (derivedSchema.Name || ':' || derivedClass.Name) AS "ClassFullName", (baseSchema.Name || ':' || baseClass.Name) AS "BaseClassFullName"
|
|
380
|
+
FROM ECDbMeta.ClassHasAllBaseClasses baseClassRels
|
|
381
|
+
INNER JOIN ECDbMeta.ECClassDef derivedClass ON derivedClass.ECInstanceId = baseClassRels.SourceECInstanceId
|
|
382
|
+
INNER JOIN ECDbMeta.ECSchemaDef derivedSchema ON derivedSchema.ECInstanceId = derivedClass.Schema.Id
|
|
383
|
+
INNER JOIN ECDbMeta.ECClassDef baseClass ON baseClass.ECInstanceId = baseClassRels.TargetECInstanceId
|
|
384
|
+
INNER JOIN ECDbMeta.ECSchemaDef baseSchema ON baseSchema.ECInstanceId = baseClass.Schema.Id
|
|
385
|
+
WHERE (derivedSchema.Name || ':' || derivedClass.Name) IN (${[...missingClasses].map((className) => `'${className}'`).join(",")})`;
|
|
386
|
+
const reader = imodel.createQueryReader(query, undefined, { rowFormat: core_common_1.QueryRowFormat.UseJsPropertyNames });
|
|
387
|
+
while (await reader.step()) {
|
|
388
|
+
const row = reader.current.toRow();
|
|
389
|
+
if (!(row.classFullName in baseClasses)) {
|
|
390
|
+
baseClasses[row.classFullName] = [];
|
|
391
|
+
}
|
|
392
|
+
baseClasses[row.classFullName].push(row.baseClassFullName);
|
|
393
|
+
}
|
|
394
|
+
return baseClasses;
|
|
395
|
+
};
|
|
375
396
|
/** Changes field properties priorities to lower than another fields priority
|
|
376
397
|
* @param imodel IModelConnection.
|
|
377
398
|
* @param field Field that priority is being changed.
|
|
@@ -486,11 +507,6 @@ class FavoritePropertiesManager {
|
|
|
486
507
|
}
|
|
487
508
|
}
|
|
488
509
|
exports.FavoritePropertiesManager = FavoritePropertiesManager;
|
|
489
|
-
/**
|
|
490
|
-
* Used in tests to avoid collisions between multiple runs using the same storage
|
|
491
|
-
* @internal
|
|
492
|
-
*/
|
|
493
|
-
FavoritePropertiesManager.FAVORITES_IDENTIFIER_PREFIX = "";
|
|
494
510
|
var Direction;
|
|
495
511
|
(function (Direction) {
|
|
496
512
|
Direction[Direction["Up"] = -1] = "Up";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FavoritePropertiesManager.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/favorite-properties/FavoritePropertiesManager.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAA0E;AAC1E,oDAAoD;AAKpD;;;GAGG;AACH,IAAY,uBAIX;AAJD,WAAY,uBAAuB;IACjC,yEAAM,CAAA;IACN,uEAAK,CAAA;IACL,yEAAM,CAAA;AACR,CAAC,EAJW,uBAAuB,uCAAvB,uBAAuB,QAIlC;AAkCD;;;;;GAKG;AACH,MAAa,yBAAyB;IAoBpC,YAAmB,KAAqC;QAbxD,2DAA2D;QACpD,uBAAkB,GAAG,IAAI,sBAAO,EAAc,CAAC;QA4BtD;;;WAGG;QACI,yBAAoB,GAAG,KAAK,EAAE,MAAwB,EAAE,EAAE;YAC/D,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAS,CAAC;YAClC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAQ,CAAC;YAEhC,IAAI,IAAI,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;gBACzC,IAAI,CAAC,iBAAiB,GAAG,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC,IAAI,IAAI,GAAG,EAAoB,CAAC;YACjG,CAAC;Y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C,oBAAoB,EAAE,EAAE,CAAC;QACxC,eAAe,CAAC,iCAAiC,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5D,CAAC;SAAM,CAAC;QACN,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,UAAyC,EAAE,EAAE,CAC3E,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,gBAAgB,IAAI,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { BeEvent, IDisposable, isIDisposable } from \"@itwin/core-bentley\";\r\nimport { QueryRowFormat } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"@itwin/core-frontend\";\r\nimport { ClassId, Field, NestedContentField, PropertiesField } from \"@itwin/presentation-common\";\r\nimport { IFavoritePropertiesStorage } from \"./FavoritePropertiesStorage\";\r\n\r\n/**\r\n * Scopes that favorite properties can be stored in.\r\n * @public\r\n */\r\nexport enum FavoritePropertiesScope {\r\n Global,\r\n ITwin,\r\n IModel,\r\n}\r\n\r\n/**\r\n * Format:\r\n * Regular property - [{path from parent class}-]{schema name}:{class name}:{property name}.\r\n * Nested property - [{path from parent class}-]{content class schema name}:{content class name}.\r\n * Primitive property - {field name}.\r\n * @public\r\n */\r\nexport type PropertyFullName = string;\r\n\r\n/**\r\n * Holds the information of favorite properties ordering.\r\n * @public\r\n */\r\nexport interface FavoritePropertiesOrderInfo {\r\n parentClassName: string | undefined;\r\n name: PropertyFullName;\r\n priority: number;\r\n orderedTimestamp: Date;\r\n}\r\n\r\n/**\r\n * Properties for initializing [[FavoritePropertiesManager]]\r\n * @public\r\n */\r\nexport interface FavoritePropertiesManagerProps {\r\n /**\r\n * Implementation of a persistence layer for storing favorite properties and their order.\r\n * @public\r\n */\r\n storage: IFavoritePropertiesStorage;\r\n}\r\n\r\n/**\r\n * The favorite property manager which lets to store favorite properties\r\n * and check if field contains favorite properties.\r\n *\r\n * @public\r\n */\r\nexport class FavoritePropertiesManager implements IDisposable {\r\n /**\r\n * Used in tests to avoid collisions between multiple runs using the same storage\r\n * @internal\r\n */\r\n public static FAVORITES_IDENTIFIER_PREFIX = \"\";\r\n\r\n /** Event raised after favorite properties have changed. */\r\n public onFavoritesChanged = new BeEvent<() => void>();\r\n\r\n private _storage: IFavoritePropertiesStorage;\r\n private _globalProperties: Set<PropertyFullName> | undefined;\r\n private _iTwinProperties: Map<string, Set<PropertyFullName>>;\r\n private _imodelProperties: Map<string, Set<PropertyFullName>>;\r\n private _imodelBaseClassesByClass: Map<string, { [className: string]: string[] }>;\r\n private _imodelInitializationPromises: Map<IModelConnection, Promise<void>>;\r\n\r\n /** Property order is saved only in iModel scope */\r\n private _propertiesOrder: Map<string, FavoritePropertiesOrderInfo[]>;\r\n\r\n public constructor(props: FavoritePropertiesManagerProps) {\r\n this._storage = props.storage;\r\n this._iTwinProperties = new Map<string, Set<PropertyFullName>>();\r\n this._imodelProperties = new Map<string, Set<PropertyFullName>>();\r\n this._propertiesOrder = new Map<string, FavoritePropertiesOrderInfo[]>();\r\n this._imodelBaseClassesByClass = new Map<string, { [className: string]: string[] }>();\r\n this._imodelInitializationPromises = new Map<IModelConnection, Promise<void>>();\r\n }\r\n\r\n public dispose() {\r\n // istanbul ignore else\r\n if (isIDisposable(this._storage)) {\r\n this._storage.dispose();\r\n }\r\n }\r\n\r\n /**\r\n * Initialize favorite properties for the provided IModelConnection.\r\n * @deprecated in 4.5. Initialization is performed automatically by all async methods and only needed for deprecated [[FavoritePropertiesManager.has]] and [[FavoritePropertiesManager.sortFields]].\r\n */\r\n public initializeConnection = async (imodel: IModelConnection) => {\r\n const imodelId = imodel.iModelId!;\r\n const iTwinId = imodel.iTwinId!;\r\n\r\n if (this._globalProperties === undefined) {\r\n this._globalProperties = (await this._storage.loadProperties()) || new Set<PropertyFullName>();\r\n }\r\n\r\n if (!this._iTwinProperties.has(iTwinId)) {\r\n const iTwinProperties = (await this._storage.loadProperties(iTwinId)) || new Set<PropertyFullName>();\r\n this._iTwinProperties.set(iTwinId, iTwinProperties);\r\n }\r\n\r\n if (!this._imodelProperties.has(getiModelInfo(iTwinId, imodelId))) {\r\n const imodelProperties = (await this._storage.loadProperties(iTwinId, imodelId)) || new Set<PropertyFullName>();\r\n this._imodelProperties.set(getiModelInfo(iTwinId, imodelId), imodelProperties);\r\n }\r\n const propertiesOrder = (await this._storage.loadPropertiesOrder(iTwinId, imodelId)) || [];\r\n this._propertiesOrder.set(getiModelInfo(iTwinId, imodelId), propertiesOrder);\r\n await this._adjustPropertyOrderInfos(iTwinId, imodelId);\r\n };\r\n\r\n /**\r\n * Function that removes order information of properties that are no longer\r\n * favorited and adds missing order information for favorited properties.\r\n */\r\n private _adjustPropertyOrderInfos = async (iTwinId: string, imodelId: string) => {\r\n const propertiesOrder = this._propertiesOrder.get(getiModelInfo(iTwinId, imodelId))!;\r\n\r\n const globalProperties = this._globalProperties!;\r\n const iTwinProperties = this._iTwinProperties.get(iTwinId)!;\r\n const imodelProperties = this._imodelProperties.get(getiModelInfo(iTwinId, imodelId))!;\r\n // favorite property infos that need to be added to the propertiesOrder array\r\n const infosToAdd = new Set<string>([...globalProperties, ...iTwinProperties, ...imodelProperties]);\r\n\r\n for (let i = propertiesOrder.length - 1; i >= 0; i--) {\r\n if (infosToAdd.has(propertiesOrder[i].name)) {\r\n infosToAdd.delete(propertiesOrder[i].name);\r\n } else {\r\n propertiesOrder.splice(i, 1);\r\n }\r\n }\r\n\r\n infosToAdd.forEach((info) =>\r\n propertiesOrder.push({\r\n name: info,\r\n parentClassName: getPropertyClassName(info),\r\n orderedTimestamp: new Date(),\r\n priority: 0,\r\n }),\r\n );\r\n\r\n let priority = propertiesOrder.length;\r\n propertiesOrder.forEach((oi) => (oi.priority = priority--));\r\n };\r\n\r\n private isInitialized(imodel: IModelConnection): boolean {\r\n const iTwinId = imodel.iTwinId!;\r\n const imodelId = imodel.iModelId!;\r\n return this._imodelProperties.has(getiModelInfo(iTwinId, imodelId));\r\n }\r\n\r\n /**\r\n * Checks if [[FavoritePropertiesManager.initializeConnection]] has been called for a given imodel.\r\n * Can be removed when [[FavoritePropertiesManager.has]] and [[FavoritePropertiesManager.sortFields]] are removed.\r\n */\r\n private validateInitialization(imodel: IModelConnection) {\r\n const iTwinId = imodel.iTwinId!;\r\n const imodelId = imodel.iModelId!;\r\n if (!this.isInitialized(imodel)) {\r\n throw Error(\r\n `Favorite properties are not initialized for iModel: '${imodelId}', in iTwin: '${iTwinId}'. Call initializeConnection() with an IModelConnection to initialize.`,\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Calls [[FavoritePropertiesManager.initializeConnection]] and caches the promise which should be awaited by calling [[FavoritePropertiesManager.ensureInitialized]].\r\n * @internal\r\n */\r\n public startConnectionInitialization(imodel: IModelConnection) {\r\n if (!this.isInitialized(imodel) && !this._imodelInitializationPromises.has(imodel)) {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n this._imodelInitializationPromises.set(imodel, this.initializeConnection(imodel));\r\n }\r\n }\r\n\r\n /**\r\n * Performs the initialization process or finishes the one that was started by [[FavoritePropertiesManager.startConnectionInitialization]].\r\n * @internal\r\n */\r\n public async ensureInitialized(imodel: IModelConnection) {\r\n if (this.isInitialized(imodel)) {\r\n return;\r\n }\r\n\r\n let promise = this._imodelInitializationPromises.get(imodel);\r\n if (!promise) {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n promise = this.initializeConnection(imodel);\r\n\r\n // Put the promise in the map to avoid possible multiple initializations from different promises.\r\n this._imodelInitializationPromises.set(imodel, promise);\r\n }\r\n\r\n await promise;\r\n\r\n // Remove this promise from the map, because the next time this method is called, `this.isInitialized` should return true.\r\n this._imodelInitializationPromises.delete(imodel);\r\n }\r\n\r\n /**\r\n * Adds favorite properties into a certain scope.\r\n * @param field Field that contains properties. If field contains multiple properties, all of them will be favorited.\r\n * @param imodel IModelConnection.\r\n * @param scope FavoritePropertiesScope to put the favorite properties into.\r\n */\r\n public async add(field: Field, imodel: IModelConnection, scope: FavoritePropertiesScope): Promise<void> {\r\n await this.ensureInitialized(imodel);\r\n const iTwinId = imodel.iTwinId!;\r\n const imodelId = imodel.iModelId!;\r\n\r\n let favoriteProperties: Set<PropertyFullName>;\r\n let saveProperties: (properties: Set<PropertyFullName>) => Promise<void>;\r\n switch (scope) {\r\n case FavoritePropertiesScope.Global:\r\n favoriteProperties = this._globalProperties!;\r\n saveProperties = async (properties) => this._storage.saveProperties(properties);\r\n break;\r\n case FavoritePropertiesScope.ITwin:\r\n favoriteProperties = this._iTwinProperties.get(iTwinId)!;\r\n saveProperties = async (properties) => this._storage.saveProperties(properties, iTwinId);\r\n break;\r\n default:\r\n favoriteProperties = this._imodelProperties.get(getiModelInfo(iTwinId, imodelId))!;\r\n saveProperties = async (properties) => this._storage.saveProperties(properties, iTwinId, imodelId);\r\n }\r\n\r\n const countBefore = favoriteProperties.size;\r\n const fieldInfos = getFieldInfos(field);\r\n fieldInfos.forEach((info) => favoriteProperties.add(info));\r\n if (favoriteProperties.size !== countBefore) {\r\n const saves: Array<Promise<void>> = [];\r\n saves.push(saveProperties(favoriteProperties));\r\n\r\n const propertiesOrder = this._propertiesOrder.get(getiModelInfo(iTwinId, imodelId))!;\r\n addOrderInfos(propertiesOrder, createFieldOrderInfos(field));\r\n saves.push(this._storage.savePropertiesOrder(propertiesOrder, iTwinId, imodelId));\r\n\r\n await Promise.all(saves);\r\n this.onFavoritesChanged.raiseEvent();\r\n }\r\n }\r\n\r\n /**\r\n * Removes favorite properties from a scope specified and all the more general scopes.\r\n * @param field Field that contains properties. If field contains multiple properties, all of them will be un-favorited.\r\n * @param imodel IModelConnection.\r\n * @param scope FavoritePropertiesScope to remove the favorite properties from. It also removes from more general scopes.\r\n */\r\n public async remove(field: Field, imodel: IModelConnection, scope: FavoritePropertiesScope): Promise<void> {\r\n await this.ensureInitialized(imodel);\r\n const iTwinId = imodel.iTwinId!;\r\n const imodelId = imodel.iModelId!;\r\n\r\n const fieldInfos = getFieldInfos(field);\r\n const workingScopes: Array<{ properties: Set<PropertyFullName>; save: (properties: Set<PropertyFullName>) => Promise<void> }> = [];\r\n workingScopes.push({\r\n properties: this._globalProperties!,\r\n save: async (properties) => this._storage.saveProperties(properties),\r\n });\r\n if (scope === FavoritePropertiesScope.ITwin || scope === FavoritePropertiesScope.IModel) {\r\n workingScopes.push({\r\n properties: this._iTwinProperties.get(iTwinId)!,\r\n save: async (properties) => this._storage.saveProperties(properties, iTwinId),\r\n });\r\n }\r\n if (scope === FavoritePropertiesScope.IModel) {\r\n workingScopes.push({\r\n properties: this._imodelProperties.get(getiModelInfo(iTwinId, imodelId))!,\r\n save: async (properties) => this._storage.saveProperties(properties, iTwinId, imodelId),\r\n });\r\n }\r\n\r\n const saves: Array<Promise<void>> = [];\r\n let favoritesChanged = false;\r\n for (const { properties, save } of workingScopes) {\r\n const countBefore = properties.size;\r\n fieldInfos.forEach((info) => properties.delete(info));\r\n if (properties.size !== countBefore) {\r\n saves.push(save(properties));\r\n favoritesChanged = true;\r\n }\r\n }\r\n if (!favoritesChanged) {\r\n return;\r\n }\r\n\r\n const propertiesOrder = this._propertiesOrder.get(getiModelInfo(iTwinId, imodelId))!;\r\n removeOrderInfos(propertiesOrder, createFieldOrderInfos(field));\r\n saves.push(this._storage.savePropertiesOrder(propertiesOrder, iTwinId, imodelId));\r\n\r\n await Promise.all(saves);\r\n this.onFavoritesChanged.raiseEvent();\r\n }\r\n\r\n /**\r\n * Removes all favorite properties from a certain scope.\r\n * @param imodel IModelConnection.\r\n * @param scope FavoritePropertiesScope to remove the favorite properties from.\r\n */\r\n public async clear(imodel: IModelConnection, scope: FavoritePropertiesScope): Promise<void> {\r\n await this.ensureInitialized(imodel);\r\n const iTwinId = imodel.iTwinId!;\r\n const imodelId = imodel.iModelId!;\r\n\r\n let favoriteProperties: Set<PropertyFullName>;\r\n let saveProperties: () => Promise<void>;\r\n switch (scope) {\r\n case FavoritePropertiesScope.Global:\r\n favoriteProperties = this._globalProperties!;\r\n saveProperties = async () => this._storage.saveProperties(new Set<PropertyFullName>());\r\n break;\r\n case FavoritePropertiesScope.ITwin:\r\n favoriteProperties = this._iTwinProperties.get(iTwinId)!;\r\n saveProperties = async () => this._storage.saveProperties(new Set<PropertyFullName>(), iTwinId);\r\n break;\r\n default:\r\n favoriteProperties = this._imodelProperties.get(getiModelInfo(iTwinId, imodelId))!;\r\n saveProperties = async () => this._storage.saveProperties(new Set<PropertyFullName>(), iTwinId, imodelId);\r\n }\r\n\r\n if (favoriteProperties.size === 0) {\r\n return;\r\n }\r\n\r\n favoriteProperties.clear();\r\n const saves: Array<Promise<void>> = [];\r\n saves.push(saveProperties());\r\n saves.push(this._adjustPropertyOrderInfos(iTwinId, imodelId));\r\n await Promise.all(saves);\r\n this.onFavoritesChanged.raiseEvent();\r\n }\r\n\r\n /**\r\n * Check if field contains at least one favorite property.\r\n * @param field Field that contains properties.\r\n * @param imodel IModelConnection.\r\n * @param scope FavoritePropertiesScope to check for favorite properties. It also checks the more general scopes.\r\n * @note `initializeConnection` must be called with the `imodel` before calling this function.\r\n * @deprecated in 4.5. Use [[FavoritePropertiesManager.hasAsync]] instead. This method is not async, therefore it requires early initialization by calling [[FavoritePropertiesManager.initializeConnection]].\r\n */\r\n public has(field: Field, imodel: IModelConnection, scope: FavoritePropertiesScope): boolean {\r\n this.validateInitialization(imodel);\r\n const iTwinId = imodel.iTwinId!;\r\n const imodelId = imodel.iModelId!;\r\n\r\n const fieldInfos = getFieldInfos(field);\r\n return (\r\n setHasAny(this._globalProperties!, fieldInfos) ||\r\n (scope !== FavoritePropertiesScope.Global && setHasAny(this._iTwinProperties.get(iTwinId)!, fieldInfos)) ||\r\n (scope === FavoritePropertiesScope.IModel && setHasAny(this._imodelProperties.get(getiModelInfo(iTwinId, imodelId))!, fieldInfos))\r\n );\r\n }\r\n\r\n /**\r\n * Check if field contains at least one favorite property.\r\n * @param field Field that contains properties.\r\n * @param imodel IModelConnection.\r\n * @param scope FavoritePropertiesScope to check for favorite properties. It also checks the more general scopes.\r\n */\r\n public async hasAsync(field: Field, imodel: IModelConnection, scope: FavoritePropertiesScope): Promise<boolean> {\r\n await this.ensureInitialized(imodel);\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n return this.has(field, imodel, scope);\r\n }\r\n\r\n /**\r\n * Sorts an array of fields with respect to favorite property order.\r\n * Non-favorited fields get sorted by their default priority and always have lower priority than favorited fields.\r\n * @param imodel IModelConnection.\r\n * @param fields Array of Field's that needs to be sorted.\r\n * @note `initializeConnection` must be called with the `imodel` before calling this function.\r\n * @deprecated in 4.5. Use [[FavoritePropertiesManager.sortFieldsAsync]] instead. This method is not async, therefore it requires early initialization by calling [[FavoritePropertiesManager.initializeConnection]].\r\n */\r\n public sortFields = (imodel: IModelConnection, fields: Field[]): Field[] => {\r\n this.validateInitialization(imodel);\r\n const iTwinId = imodel.iTwinId!;\r\n const imodelId = imodel.iModelId!;\r\n\r\n const fieldPriority = new Map<Field, number>();\r\n fields.forEach((field) => fieldPriority.set(field, this.getFieldPriority(field, iTwinId, imodelId)));\r\n\r\n const sortFunction = (left: Field, right: Field): number => {\r\n const lp = fieldPriority.get(left)!;\r\n const rp = fieldPriority.get(right)!;\r\n return lp < rp\r\n ? 1\r\n : lp > rp\r\n ? -1\r\n : left.priority < right.priority\r\n ? 1 // if favorite fields have equal priorities, sort by field priority\r\n : left.priority > right.priority\r\n ? -1\r\n : left.name.localeCompare(right.name);\r\n };\r\n\r\n return fields.sort(sortFunction);\r\n };\r\n\r\n /**\r\n * Sorts an array of fields with respect to favorite property order.\r\n * Non-favorited fields get sorted by their default priority and always have lower priority than favorited fields.\r\n * @param imodel IModelConnection.\r\n * @param fields Array of Field's that needs to be sorted.\r\n */\r\n public async sortFieldsAsync(imodel: IModelConnection, fields: Field[]): Promise<Field[]> {\r\n await this.ensureInitialized(imodel);\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n return this.sortFields(imodel, fields);\r\n }\r\n\r\n private getFieldPriority(field: Field, iTwinId: string, imodelId: string): number {\r\n const orderInfos = this._propertiesOrder.get(getiModelInfo(iTwinId, imodelId))!;\r\n const fieldOrderInfos = getFieldOrderInfos(field, orderInfos);\r\n if (fieldOrderInfos.length === 0) {\r\n return -1;\r\n }\r\n const mostRecent = getMostRecentOrderInfo(fieldOrderInfos);\r\n return mostRecent.priority;\r\n }\r\n\r\n private _getBaseClassesByClass = async (imodel: IModelConnection, neededClasses: Set<string>): Promise<{ [className: string]: string[] }> => {\r\n const iTwinId = imodel.iTwinId!;\r\n const imodelId = imodel.iModelId!;\r\n\r\n const imodelInfo = getiModelInfo(iTwinId, imodelId);\r\n let baseClasses: { [className: string]: string[] };\r\n if (this._imodelBaseClassesByClass.has(imodelInfo)) {\r\n baseClasses = this._imodelBaseClassesByClass.get(imodelInfo)!;\r\n } else {\r\n this._imodelBaseClassesByClass.set(imodelInfo, (baseClasses = {}));\r\n }\r\n\r\n const missingClasses = new Set<string>();\r\n neededClasses.forEach((className) => {\r\n if (!baseClasses.hasOwnProperty(className)) {\r\n missingClasses.add(className);\r\n }\r\n });\r\n if (missingClasses.size === 0) {\r\n return baseClasses;\r\n }\r\n\r\n const query = `\r\n SELECT (derivedSchema.Name || ':' || derivedClass.Name) AS \"ClassFullName\", (baseSchema.Name || ':' || baseClass.Name) AS \"BaseClassFullName\"\r\n FROM ECDbMeta.ClassHasAllBaseClasses baseClassRels\r\n INNER JOIN ECDbMeta.ECClassDef derivedClass ON derivedClass.ECInstanceId = baseClassRels.SourceECInstanceId\r\n INNER JOIN ECDbMeta.ECSchemaDef derivedSchema ON derivedSchema.ECInstanceId = derivedClass.Schema.Id\r\n INNER JOIN ECDbMeta.ECClassDef baseClass ON baseClass.ECInstanceId = baseClassRels.TargetECInstanceId\r\n INNER JOIN ECDbMeta.ECSchemaDef baseSchema ON baseSchema.ECInstanceId = baseClass.Schema.Id\r\n WHERE (derivedSchema.Name || ':' || derivedClass.Name) IN (${[...missingClasses].map((className) => `'${className}'`).join(\",\")})`;\r\n const reader = imodel.createQueryReader(query, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames });\r\n while (await reader.step()) {\r\n const row = reader.current.toRow();\r\n if (!(row.classFullName in baseClasses)) {\r\n baseClasses[row.classFullName] = [];\r\n }\r\n baseClasses[row.classFullName].push(row.baseClassFullName);\r\n }\r\n return baseClasses;\r\n };\r\n\r\n /** Changes field properties priorities to lower than another fields priority\r\n * @param imodel IModelConnection.\r\n * @param field Field that priority is being changed.\r\n * @param afterField Field that goes before the moved field. If undefined the moving field is changed to the highest priority (to the top).\r\n * @param visibleFields Array of fields to move the field in.\r\n */\r\n public async changeFieldPriority(imodel: IModelConnection, field: Field, afterField: Field | undefined, visibleFields: Field[]) {\r\n /**\r\n * How it works:\r\n * 1. Gets the orderInfo's for `field` (`orderInfo`) and `afterField` (`afterOrderInfo`) by selecting the most recent order informations for each field\r\n * 2. Iterates all orderInfo's that are in between `afterOrderInfo` and `orderInfo` when sorted by priority\r\n * 3. For each iterated orderInfo it checks if it is relevant:\r\n * 3.1. If orderInfo belongs to a primitive property, orderInfo is relevant\r\n * 3.2. If orderInfo's field is visible, orderInfo is relevant\r\n * 3.3. If orderInfo's class has a base class or itself in previously labeled relevant orderInfo's, orderInfo is relevant\r\n * 3.4. If 3.1 - 3.3 don't pass, orderInfo is irrelevant\r\n * 4. Irrelevant orderInfos's get moved after `orderInfo` (depends on the direction)\r\n * 5. All `field` orderInfo's get moved after `afterOrderInfo`\r\n */\r\n await this.ensureInitialized(imodel);\r\n const iTwinId = imodel.iTwinId!;\r\n const imodelId = imodel.iModelId!;\r\n\r\n if (field === afterField) {\r\n throw Error(\"`field` can not be the same as `afterField`.\");\r\n }\r\n\r\n const allOrderInfos = this._propertiesOrder.get(getiModelInfo(iTwinId, imodelId))!;\r\n\r\n const findFieldOrderInfoData = (f: Field) => {\r\n if (!visibleFields.includes(f)) {\r\n throw Error(\"Field is not contained in visible fields.\");\r\n }\r\n const infos = getFieldOrderInfos(f, allOrderInfos);\r\n\r\n if (infos.length === 0) {\r\n throw Error(\"Field has no property order information.\");\r\n }\r\n const info = getMostRecentOrderInfo(infos);\r\n const index = allOrderInfos.indexOf(info);\r\n return { infos, mostRecent: { info, index } };\r\n };\r\n\r\n const {\r\n infos: movingOrderInfos,\r\n mostRecent: { index: orderInfoIndex },\r\n } = findFieldOrderInfoData(field);\r\n\r\n let afterOrderInfo: FavoritePropertiesOrderInfo | undefined;\r\n let afterOrderInfoIndex;\r\n if (afterField === undefined) {\r\n afterOrderInfo = undefined;\r\n afterOrderInfoIndex = -1;\r\n } else {\r\n ({\r\n mostRecent: { info: afterOrderInfo, index: afterOrderInfoIndex },\r\n } = findFieldOrderInfoData(afterField));\r\n }\r\n\r\n let direction: Direction; // where to go from `afterOrderInfo` to `orderInfo`\r\n let startIndex: number;\r\n if (orderInfoIndex < afterOrderInfoIndex) {\r\n direction = Direction.Up;\r\n startIndex = afterOrderInfoIndex;\r\n } else {\r\n direction = Direction.Down;\r\n startIndex = afterOrderInfoIndex + 1;\r\n }\r\n\r\n const neededClassNames: Set<string> = allOrderInfos.reduce((classNames: Set<string>, oi) => {\r\n if (oi.parentClassName) {\r\n classNames.add(oi.parentClassName);\r\n }\r\n return classNames;\r\n }, new Set<string>());\r\n const baseClassesByClass = await this._getBaseClassesByClass(imodel, neededClassNames);\r\n\r\n const visibleOrderInfos = visibleFields.reduce(\r\n (union: FavoritePropertiesOrderInfo[], currField) => union.concat(getFieldOrderInfos(currField, allOrderInfos)),\r\n [],\r\n );\r\n const irrelevantOrderInfos: FavoritePropertiesOrderInfo[] = []; // orderInfos's that won't change their logical order in respect to other properties\r\n const relevantClasses: Set<ClassId> = new Set<ClassId>(); // currently relevant classes\r\n\r\n for (let i = startIndex; i !== orderInfoIndex; i += direction) {\r\n const currOrderInfo = allOrderInfos[i];\r\n\r\n // primitive properties are always relevant, because we can't determine their relevance based on the class hierarchy\r\n if (currOrderInfo.parentClassName === undefined) {\r\n continue;\r\n }\r\n\r\n const visible = visibleOrderInfos.includes(currOrderInfo);\r\n if (visible) {\r\n relevantClasses.add(currOrderInfo.parentClassName);\r\n continue;\r\n }\r\n\r\n const hasBaseClasses = baseClassesByClass[currOrderInfo.parentClassName].some((classId) => relevantClasses.has(classId));\r\n if (hasBaseClasses) {\r\n continue;\r\n }\r\n\r\n if (direction === Direction.Down) {\r\n irrelevantOrderInfos.push(currOrderInfo);\r\n } else {\r\n irrelevantOrderInfos.unshift(currOrderInfo);\r\n }\r\n }\r\n\r\n // remove irrelevantOrderInfo's to add them after the `orderInfo`\r\n irrelevantOrderInfos.forEach((foi) => {\r\n const index = allOrderInfos.findIndex((oi) => oi.parentClassName === foi.parentClassName && oi.name === foi.name);\r\n allOrderInfos.splice(index, 1);\r\n });\r\n\r\n // remove movingOrderInfos's to add them after the `afterOrderInfo`\r\n movingOrderInfos.forEach((foi) => {\r\n const index = allOrderInfos.findIndex((oi) => oi.parentClassName === foi.parentClassName && oi.name === foi.name);\r\n allOrderInfos.splice(index, 1);\r\n });\r\n movingOrderInfos.forEach((oi) => (oi.orderedTimestamp = new Date()));\r\n\r\n afterOrderInfoIndex = afterOrderInfo === undefined ? -1 : allOrderInfos.indexOf(afterOrderInfo);\r\n allOrderInfos.splice(afterOrderInfoIndex + 1, 0, ...movingOrderInfos);\r\n allOrderInfos.splice(afterOrderInfoIndex + 1 + (direction === Direction.Up ? movingOrderInfos.length : 0), 0, ...irrelevantOrderInfos);\r\n\r\n // reassign priority numbers\r\n let priority = allOrderInfos.length;\r\n allOrderInfos.forEach((oi) => (oi.priority = priority--));\r\n\r\n await this._storage.savePropertiesOrder(allOrderInfos, iTwinId, imodelId);\r\n this.onFavoritesChanged.raiseEvent();\r\n }\r\n}\r\n\r\nenum Direction {\r\n Up = -1,\r\n Down = 1,\r\n}\r\n\r\nconst getiModelInfo = (iTwinId: string, imodelId: string) => `${iTwinId}/${imodelId}`;\r\n\r\nconst getPropertiesFieldPropertyNames = (field: PropertiesField) => {\r\n const nestingPrefix = getNestingPrefix(field.parent);\r\n return field.properties.map(\r\n (property) => `${FavoritePropertiesManager.FAVORITES_IDENTIFIER_PREFIX}${nestingPrefix}${property.property.classInfo.name}:${property.property.name}`,\r\n );\r\n};\r\n\r\nconst getNestedContentFieldPropertyName = (field: NestedContentField) => {\r\n const nestingPrefix = getNestingPrefix(field);\r\n return `${FavoritePropertiesManager.FAVORITES_IDENTIFIER_PREFIX}${nestingPrefix}${field.contentClassInfo.name}`;\r\n};\r\n\r\nconst getNestingPrefix = (field: NestedContentField | undefined) => {\r\n const path: string[] = [];\r\n let curr = field;\r\n while (curr !== undefined) {\r\n curr.pathToPrimaryClass.forEach((rel) => {\r\n // Relationship directions are reversed, because we are generating a relationship list starting from the parent\r\n path.push(`${rel.isForwardRelationship ? \"B\" : \"F\"}:${rel.relationshipInfo.name}`);\r\n path.push(rel.targetClassInfo.name);\r\n });\r\n curr = curr.parent;\r\n }\r\n if (path.length === 0) {\r\n return \"\";\r\n }\r\n\r\n path.reverse();\r\n return `${path.join(\"-\")}-`;\r\n};\r\n\r\nconst getPropertyClassName = (propertyName: PropertyFullName): string | undefined => {\r\n const propertyNameStart = propertyName.split(\"-\")[0];\r\n const parts = propertyNameStart.split(\":\").length;\r\n if (parts === 1) {\r\n // primitive\r\n return undefined;\r\n }\r\n if (parts === 2) {\r\n // nested property OR nested property parent class OR regular property parent class\r\n return propertyNameStart;\r\n }\r\n // regular property without parent class\r\n return propertyNameStart.substring(0, propertyName.lastIndexOf(\":\"));\r\n};\r\n\r\n/** @internal */\r\nexport const getFieldInfos = (field: Field): Set<PropertyFullName> => {\r\n const fieldInfos: Set<PropertyFullName> = new Set<PropertyFullName>();\r\n if (field.isPropertiesField()) {\r\n getPropertiesFieldPropertyNames(field).forEach((info) => fieldInfos.add(info));\r\n } else if (field.isNestedContentField()) {\r\n fieldInfos.add(getNestedContentFieldPropertyName(field));\r\n } else {\r\n fieldInfos.add(`${FavoritePropertiesManager.FAVORITES_IDENTIFIER_PREFIX}${field.name}`);\r\n }\r\n return fieldInfos;\r\n};\r\n\r\nconst setHasAny = (set: Set<string>, lookup: Set<string>) => {\r\n for (const key of lookup) {\r\n if (set.has(key)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n};\r\n\r\nconst addOrderInfos = (dest: FavoritePropertiesOrderInfo[], source: FavoritePropertiesOrderInfo[]) => {\r\n source.forEach((si) => {\r\n const index = dest.findIndex((di) => di.name === si.name);\r\n if (index === -1) {\r\n si.orderedTimestamp = new Date();\r\n dest.push(si);\r\n }\r\n });\r\n let priority = dest.length;\r\n dest.forEach((info) => (info.priority = priority--));\r\n};\r\n\r\nconst removeOrderInfos = (container: FavoritePropertiesOrderInfo[], toRemove: FavoritePropertiesOrderInfo[]) => {\r\n toRemove.forEach((roi) => {\r\n const index = container.findIndex((oi) => oi.name === roi.name);\r\n /* istanbul ignore else */\r\n if (index >= 0) {\r\n container.splice(index, 1);\r\n }\r\n });\r\n};\r\n\r\n/** @internal */\r\nexport const createFieldOrderInfos = (field: Field): FavoritePropertiesOrderInfo[] => {\r\n if (field.isNestedContentField()) {\r\n const propertyName = getNestedContentFieldPropertyName(field);\r\n return [\r\n {\r\n parentClassName: getPropertyClassName(propertyName),\r\n name: propertyName,\r\n priority: 0,\r\n orderedTimestamp: new Date(),\r\n },\r\n ];\r\n }\r\n if (field.isPropertiesField()) {\r\n return getPropertiesFieldPropertyNames(field).map((propertyName) => ({\r\n parentClassName: getPropertyClassName(propertyName),\r\n name: propertyName,\r\n priority: 0,\r\n orderedTimestamp: new Date(),\r\n }));\r\n }\r\n return [\r\n {\r\n parentClassName: undefined,\r\n name: field.name,\r\n priority: 0,\r\n orderedTimestamp: new Date(),\r\n },\r\n ];\r\n};\r\n\r\nconst getFieldOrderInfos = (field: Field, orderInfos: FavoritePropertiesOrderInfo[]): FavoritePropertiesOrderInfo[] => {\r\n const fieldOrderInfos: FavoritePropertiesOrderInfo[] = [];\r\n const tryAddOrderInfo = (name: string) => {\r\n const fieldOrderInfo = orderInfos.find((oi) => oi.name === name);\r\n if (fieldOrderInfo !== undefined) {\r\n fieldOrderInfos.push(fieldOrderInfo);\r\n }\r\n };\r\n\r\n if (field.isPropertiesField()) {\r\n getPropertiesFieldPropertyNames(field).forEach(tryAddOrderInfo);\r\n } else if (field.isNestedContentField()) {\r\n tryAddOrderInfo(getNestedContentFieldPropertyName(field));\r\n } else {\r\n tryAddOrderInfo(field.name);\r\n }\r\n\r\n return fieldOrderInfos;\r\n};\r\n\r\nconst getMostRecentOrderInfo = (orderInfos: FavoritePropertiesOrderInfo[]) =>\r\n orderInfos.reduce((recent, curr) => (recent && recent.orderedTimestamp >= curr.orderedTimestamp ? recent : curr));\r\n"]}
|
|
1
|
+
{"version":3,"file":"FavoritePropertiesManager.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/favorite-properties/FavoritePropertiesManager.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAA2E;AAC3E,oDAAoD;AAKpD;;;GAGG;AACH,IAAY,uBAIX;AAJD,WAAY,uBAAuB;IACjC,yEAAM,CAAA;IACN,uEAAK,CAAA;IACL,yEAAM,CAAA;AACR,CAAC,EAJW,uBAAuB,uCAAvB,uBAAuB,QAIlC;AAkCD;;;;;GAKG;AACH,MAAa,yBAAyB;IACpC;;;OAGG;IACI,MAAM,CAAC,2BAA2B,GAAG,EAAE,CAAC;IAE/C,2DAA2D;IACpD,kBAAkB,GAAG,IAAI,sBAAO,EAAc,CAAC;IAE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------------------------------\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 Core\n */\n\nimport { BeEvent, isDisposable, isIDisposable } from \"@itwin/core-bentley\";\nimport { QueryRowFormat } from \"@itwin/core-common\";\nimport { IModelConnection } from \"@itwin/core-frontend\";\nimport { ClassId, Field, NestedContentField, PropertiesField } from \"@itwin/presentation-common\";\nimport { IFavoritePropertiesStorage } from \"./FavoritePropertiesStorage\";\n\n/**\n * Scopes that favorite properties can be stored in.\n * @public\n */\nexport enum FavoritePropertiesScope {\n Global,\n ITwin,\n IModel,\n}\n\n/**\n * Format:\n * Regular property - [{path from parent class}-]{schema name}:{class name}:{property name}.\n * Nested property - [{path from parent class}-]{content class schema name}:{content class name}.\n * Primitive property - {field name}.\n * @public\n */\nexport type PropertyFullName = string;\n\n/**\n * Holds the information of favorite properties ordering.\n * @public\n */\nexport interface FavoritePropertiesOrderInfo {\n parentClassName: string | undefined;\n name: PropertyFullName;\n priority: number;\n orderedTimestamp: Date;\n}\n\n/**\n * Properties for initializing [[FavoritePropertiesManager]]\n * @public\n */\nexport interface FavoritePropertiesManagerProps {\n /**\n * Implementation of a persistence layer for storing favorite properties and their order.\n * @public\n */\n storage: IFavoritePropertiesStorage;\n}\n\n/**\n * The favorite property manager which lets to store favorite properties\n * and check if field contains favorite properties.\n *\n * @public\n */\nexport class FavoritePropertiesManager implements Disposable {\n /**\n * Used in tests to avoid collisions between multiple runs using the same storage\n * @internal\n */\n public static FAVORITES_IDENTIFIER_PREFIX = \"\";\n\n /** Event raised after favorite properties have changed. */\n public onFavoritesChanged = new BeEvent<() => void>();\n\n private _storage: IFavoritePropertiesStorage;\n private _globalProperties: Set<PropertyFullName> | undefined;\n private _iTwinProperties: Map<string, Set<PropertyFullName>>;\n private _imodelProperties: Map<string, Set<PropertyFullName>>;\n private _imodelBaseClassesByClass: Map<string, { [className: string]: string[] }>;\n private _imodelInitializationPromises: Map<IModelConnection, Promise<void>>;\n\n /** Property order is saved only in iModel scope */\n private _propertiesOrder: Map<string, FavoritePropertiesOrderInfo[]>;\n\n public constructor(props: FavoritePropertiesManagerProps) {\n this._storage = props.storage;\n this._iTwinProperties = new Map<string, Set<PropertyFullName>>();\n this._imodelProperties = new Map<string, Set<PropertyFullName>>();\n this._propertiesOrder = new Map<string, FavoritePropertiesOrderInfo[]>();\n this._imodelBaseClassesByClass = new Map<string, { [className: string]: string[] }>();\n this._imodelInitializationPromises = new Map<IModelConnection, Promise<void>>();\n }\n\n public [Symbol.dispose]() {\n // istanbul ignore else\n if (isDisposable(this._storage)) {\n this._storage[Symbol.dispose]();\n } else if (isIDisposable(this._storage)) { /* eslint-disable-line @typescript-eslint/no-deprecated */\n this._storage.dispose();\n }\n }\n\n /** @deprecated in 5.0 Use [Symbol.dispose] instead. */\n // istanbul ignore next\n public dispose() {\n this[Symbol.dispose]();\n }\n\n /**\n * Initialize favorite properties for the provided IModelConnection.\n * @deprecated in 4.5. Initialization is performed automatically by all async methods and only needed for deprecated [[FavoritePropertiesManager.has]] and [[FavoritePropertiesManager.sortFields]].\n */\n public initializeConnection = async (imodel: IModelConnection) => {\n const imodelId = imodel.iModelId!;\n const iTwinId = imodel.iTwinId!;\n\n if (this._globalProperties === undefined) {\n this._globalProperties = (await this._storage.loadProperties()) || new Set<PropertyFullName>();\n }\n\n if (!this._iTwinProperties.has(iTwinId)) {\n const iTwinProperties = (await this._storage.loadProperties(iTwinId)) || new Set<PropertyFullName>();\n this._iTwinProperties.set(iTwinId, iTwinProperties);\n }\n\n if (!this._imodelProperties.has(getiModelInfo(iTwinId, imodelId))) {\n const imodelProperties = (await this._storage.loadProperties(iTwinId, imodelId)) || new Set<PropertyFullName>();\n this._imodelProperties.set(getiModelInfo(iTwinId, imodelId), imodelProperties);\n }\n const propertiesOrder = (await this._storage.loadPropertiesOrder(iTwinId, imodelId)) || [];\n this._propertiesOrder.set(getiModelInfo(iTwinId, imodelId), propertiesOrder);\n await this._adjustPropertyOrderInfos(iTwinId, imodelId);\n };\n\n /**\n * Function that removes order information of properties that are no longer\n * favorited and adds missing order information for favorited properties.\n */\n private _adjustPropertyOrderInfos = async (iTwinId: string, imodelId: string) => {\n const propertiesOrder = this._propertiesOrder.get(getiModelInfo(iTwinId, imodelId))!;\n\n const globalProperties = this._globalProperties!;\n const iTwinProperties = this._iTwinProperties.get(iTwinId)!;\n const imodelProperties = this._imodelProperties.get(getiModelInfo(iTwinId, imodelId))!;\n // favorite property infos that need to be added to the propertiesOrder array\n const infosToAdd = new Set<string>([...globalProperties, ...iTwinProperties, ...imodelProperties]);\n\n for (let i = propertiesOrder.length - 1; i >= 0; i--) {\n if (infosToAdd.has(propertiesOrder[i].name)) {\n infosToAdd.delete(propertiesOrder[i].name);\n } else {\n propertiesOrder.splice(i, 1);\n }\n }\n\n infosToAdd.forEach((info) =>\n propertiesOrder.push({\n name: info,\n parentClassName: getPropertyClassName(info),\n orderedTimestamp: new Date(),\n priority: 0,\n }),\n );\n\n let priority = propertiesOrder.length;\n propertiesOrder.forEach((oi) => (oi.priority = priority--));\n };\n\n private isInitialized(imodel: IModelConnection): boolean {\n const iTwinId = imodel.iTwinId!;\n const imodelId = imodel.iModelId!;\n return this._imodelProperties.has(getiModelInfo(iTwinId, imodelId));\n }\n\n /**\n * Checks if [[FavoritePropertiesManager.initializeConnection]] has been called for a given imodel.\n * Can be removed when [[FavoritePropertiesManager.has]] and [[FavoritePropertiesManager.sortFields]] are removed.\n */\n private validateInitialization(imodel: IModelConnection) {\n const iTwinId = imodel.iTwinId!;\n const imodelId = imodel.iModelId!;\n if (!this.isInitialized(imodel)) {\n throw Error(\n `Favorite properties are not initialized for iModel: '${imodelId}', in iTwin: '${iTwinId}'. Call initializeConnection() with an IModelConnection to initialize.`,\n );\n }\n }\n\n /**\n * Calls [[FavoritePropertiesManager.initializeConnection]] and caches the promise which should be awaited by calling [[FavoritePropertiesManager.ensureInitialized]].\n * @internal\n */\n public startConnectionInitialization(imodel: IModelConnection) {\n if (!this.isInitialized(imodel) && !this._imodelInitializationPromises.has(imodel)) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n this._imodelInitializationPromises.set(imodel, this.initializeConnection(imodel));\n }\n }\n\n /**\n * Performs the initialization process or finishes the one that was started by [[FavoritePropertiesManager.startConnectionInitialization]].\n * @internal\n */\n public async ensureInitialized(imodel: IModelConnection) {\n if (this.isInitialized(imodel)) {\n return;\n }\n\n let promise = this._imodelInitializationPromises.get(imodel);\n if (!promise) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n promise = this.initializeConnection(imodel);\n\n // Put the promise in the map to avoid possible multiple initializations from different promises.\n this._imodelInitializationPromises.set(imodel, promise);\n }\n\n await promise;\n\n // Remove this promise from the map, because the next time this method is called, `this.isInitialized` should return true.\n this._imodelInitializationPromises.delete(imodel);\n }\n\n /**\n * Adds favorite properties into a certain scope.\n * @param field Field that contains properties. If field contains multiple properties, all of them will be favorited.\n * @param imodel IModelConnection.\n * @param scope FavoritePropertiesScope to put the favorite properties into.\n */\n public async add(field: Field, imodel: IModelConnection, scope: FavoritePropertiesScope): Promise<void> {\n await this.ensureInitialized(imodel);\n const iTwinId = imodel.iTwinId!;\n const imodelId = imodel.iModelId!;\n\n let favoriteProperties: Set<PropertyFullName>;\n let saveProperties: (properties: Set<PropertyFullName>) => Promise<void>;\n switch (scope) {\n case FavoritePropertiesScope.Global:\n favoriteProperties = this._globalProperties!;\n saveProperties = async (properties) => this._storage.saveProperties(properties);\n break;\n case FavoritePropertiesScope.ITwin:\n favoriteProperties = this._iTwinProperties.get(iTwinId)!;\n saveProperties = async (properties) => this._storage.saveProperties(properties, iTwinId);\n break;\n default:\n favoriteProperties = this._imodelProperties.get(getiModelInfo(iTwinId, imodelId))!;\n saveProperties = async (properties) => this._storage.saveProperties(properties, iTwinId, imodelId);\n }\n\n const countBefore = favoriteProperties.size;\n const fieldInfos = getFieldInfos(field);\n fieldInfos.forEach((info) => favoriteProperties.add(info));\n if (favoriteProperties.size !== countBefore) {\n const saves: Array<Promise<void>> = [];\n saves.push(saveProperties(favoriteProperties));\n\n const propertiesOrder = this._propertiesOrder.get(getiModelInfo(iTwinId, imodelId))!;\n addOrderInfos(propertiesOrder, createFieldOrderInfos(field));\n saves.push(this._storage.savePropertiesOrder(propertiesOrder, iTwinId, imodelId));\n\n await Promise.all(saves);\n this.onFavoritesChanged.raiseEvent();\n }\n }\n\n /**\n * Removes favorite properties from a scope specified and all the more general scopes.\n * @param field Field that contains properties. If field contains multiple properties, all of them will be un-favorited.\n * @param imodel IModelConnection.\n * @param scope FavoritePropertiesScope to remove the favorite properties from. It also removes from more general scopes.\n */\n public async remove(field: Field, imodel: IModelConnection, scope: FavoritePropertiesScope): Promise<void> {\n await this.ensureInitialized(imodel);\n const iTwinId = imodel.iTwinId!;\n const imodelId = imodel.iModelId!;\n\n const fieldInfos = getFieldInfos(field);\n const workingScopes: Array<{ properties: Set<PropertyFullName>; save: (properties: Set<PropertyFullName>) => Promise<void> }> = [];\n workingScopes.push({\n properties: this._globalProperties!,\n save: async (properties) => this._storage.saveProperties(properties),\n });\n if (scope === FavoritePropertiesScope.ITwin || scope === FavoritePropertiesScope.IModel) {\n workingScopes.push({\n properties: this._iTwinProperties.get(iTwinId)!,\n save: async (properties) => this._storage.saveProperties(properties, iTwinId),\n });\n }\n if (scope === FavoritePropertiesScope.IModel) {\n workingScopes.push({\n properties: this._imodelProperties.get(getiModelInfo(iTwinId, imodelId))!,\n save: async (properties) => this._storage.saveProperties(properties, iTwinId, imodelId),\n });\n }\n\n const saves: Array<Promise<void>> = [];\n let favoritesChanged = false;\n for (const { properties, save } of workingScopes) {\n const countBefore = properties.size;\n fieldInfos.forEach((info) => properties.delete(info));\n if (properties.size !== countBefore) {\n saves.push(save(properties));\n favoritesChanged = true;\n }\n }\n if (!favoritesChanged) {\n return;\n }\n\n const propertiesOrder = this._propertiesOrder.get(getiModelInfo(iTwinId, imodelId))!;\n removeOrderInfos(propertiesOrder, createFieldOrderInfos(field));\n saves.push(this._storage.savePropertiesOrder(propertiesOrder, iTwinId, imodelId));\n\n await Promise.all(saves);\n this.onFavoritesChanged.raiseEvent();\n }\n\n /**\n * Removes all favorite properties from a certain scope.\n * @param imodel IModelConnection.\n * @param scope FavoritePropertiesScope to remove the favorite properties from.\n */\n public async clear(imodel: IModelConnection, scope: FavoritePropertiesScope): Promise<void> {\n await this.ensureInitialized(imodel);\n const iTwinId = imodel.iTwinId!;\n const imodelId = imodel.iModelId!;\n\n let favoriteProperties: Set<PropertyFullName>;\n let saveProperties: () => Promise<void>;\n switch (scope) {\n case FavoritePropertiesScope.Global:\n favoriteProperties = this._globalProperties!;\n saveProperties = async () => this._storage.saveProperties(new Set<PropertyFullName>());\n break;\n case FavoritePropertiesScope.ITwin:\n favoriteProperties = this._iTwinProperties.get(iTwinId)!;\n saveProperties = async () => this._storage.saveProperties(new Set<PropertyFullName>(), iTwinId);\n break;\n default:\n favoriteProperties = this._imodelProperties.get(getiModelInfo(iTwinId, imodelId))!;\n saveProperties = async () => this._storage.saveProperties(new Set<PropertyFullName>(), iTwinId, imodelId);\n }\n\n if (favoriteProperties.size === 0) {\n return;\n }\n\n favoriteProperties.clear();\n const saves: Array<Promise<void>> = [];\n saves.push(saveProperties());\n saves.push(this._adjustPropertyOrderInfos(iTwinId, imodelId));\n await Promise.all(saves);\n this.onFavoritesChanged.raiseEvent();\n }\n\n /**\n * Check if field contains at least one favorite property.\n * @param field Field that contains properties.\n * @param imodel IModelConnection.\n * @param scope FavoritePropertiesScope to check for favorite properties. It also checks the more general scopes.\n * @note `initializeConnection` must be called with the `imodel` before calling this function.\n * @deprecated in 4.5. Use [[FavoritePropertiesManager.hasAsync]] instead. This method is not async, therefore it requires early initialization by calling [[FavoritePropertiesManager.initializeConnection]].\n */\n public has(field: Field, imodel: IModelConnection, scope: FavoritePropertiesScope): boolean {\n this.validateInitialization(imodel);\n const iTwinId = imodel.iTwinId!;\n const imodelId = imodel.iModelId!;\n\n const fieldInfos = getFieldInfos(field);\n return (\n setHasAny(this._globalProperties!, fieldInfos) ||\n (scope !== FavoritePropertiesScope.Global && setHasAny(this._iTwinProperties.get(iTwinId)!, fieldInfos)) ||\n (scope === FavoritePropertiesScope.IModel && setHasAny(this._imodelProperties.get(getiModelInfo(iTwinId, imodelId))!, fieldInfos))\n );\n }\n\n /**\n * Check if field contains at least one favorite property.\n * @param field Field that contains properties.\n * @param imodel IModelConnection.\n * @param scope FavoritePropertiesScope to check for favorite properties. It also checks the more general scopes.\n */\n public async hasAsync(field: Field, imodel: IModelConnection, scope: FavoritePropertiesScope): Promise<boolean> {\n await this.ensureInitialized(imodel);\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return this.has(field, imodel, scope);\n }\n\n /**\n * Sorts an array of fields with respect to favorite property order.\n * Non-favorited fields get sorted by their default priority and always have lower priority than favorited fields.\n * @param imodel IModelConnection.\n * @param fields Array of Field's that needs to be sorted.\n * @note `initializeConnection` must be called with the `imodel` before calling this function.\n * @deprecated in 4.5. Use [[FavoritePropertiesManager.sortFieldsAsync]] instead. This method is not async, therefore it requires early initialization by calling [[FavoritePropertiesManager.initializeConnection]].\n */\n public sortFields = (imodel: IModelConnection, fields: Field[]): Field[] => {\n this.validateInitialization(imodel);\n const iTwinId = imodel.iTwinId!;\n const imodelId = imodel.iModelId!;\n\n const fieldPriority = new Map<Field, number>();\n fields.forEach((field) => fieldPriority.set(field, this.getFieldPriority(field, iTwinId, imodelId)));\n\n const sortFunction = (left: Field, right: Field): number => {\n const lp = fieldPriority.get(left)!;\n const rp = fieldPriority.get(right)!;\n return lp < rp\n ? 1\n : lp > rp\n ? -1\n : left.priority < right.priority\n ? 1 // if favorite fields have equal priorities, sort by field priority\n : left.priority > right.priority\n ? -1\n : left.name.localeCompare(right.name);\n };\n\n return fields.sort(sortFunction);\n };\n\n /**\n * Sorts an array of fields with respect to favorite property order.\n * Non-favorited fields get sorted by their default priority and always have lower priority than favorited fields.\n * @param imodel IModelConnection.\n * @param fields Array of Field's that needs to be sorted.\n */\n public async sortFieldsAsync(imodel: IModelConnection, fields: Field[]): Promise<Field[]> {\n await this.ensureInitialized(imodel);\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return this.sortFields(imodel, fields);\n }\n\n private getFieldPriority(field: Field, iTwinId: string, imodelId: string): number {\n const orderInfos = this._propertiesOrder.get(getiModelInfo(iTwinId, imodelId))!;\n const fieldOrderInfos = getFieldOrderInfos(field, orderInfos);\n if (fieldOrderInfos.length === 0) {\n return -1;\n }\n const mostRecent = getMostRecentOrderInfo(fieldOrderInfos);\n return mostRecent.priority;\n }\n\n private _getBaseClassesByClass = async (imodel: IModelConnection, neededClasses: Set<string>): Promise<{ [className: string]: string[] }> => {\n const iTwinId = imodel.iTwinId!;\n const imodelId = imodel.iModelId!;\n\n const imodelInfo = getiModelInfo(iTwinId, imodelId);\n let baseClasses: { [className: string]: string[] };\n if (this._imodelBaseClassesByClass.has(imodelInfo)) {\n baseClasses = this._imodelBaseClassesByClass.get(imodelInfo)!;\n } else {\n this._imodelBaseClassesByClass.set(imodelInfo, (baseClasses = {}));\n }\n\n const missingClasses = new Set<string>();\n neededClasses.forEach((className) => {\n if (!baseClasses.hasOwnProperty(className)) {\n missingClasses.add(className);\n }\n });\n if (missingClasses.size === 0) {\n return baseClasses;\n }\n\n const query = `\n SELECT (derivedSchema.Name || ':' || derivedClass.Name) AS \"ClassFullName\", (baseSchema.Name || ':' || baseClass.Name) AS \"BaseClassFullName\"\n FROM ECDbMeta.ClassHasAllBaseClasses baseClassRels\n INNER JOIN ECDbMeta.ECClassDef derivedClass ON derivedClass.ECInstanceId = baseClassRels.SourceECInstanceId\n INNER JOIN ECDbMeta.ECSchemaDef derivedSchema ON derivedSchema.ECInstanceId = derivedClass.Schema.Id\n INNER JOIN ECDbMeta.ECClassDef baseClass ON baseClass.ECInstanceId = baseClassRels.TargetECInstanceId\n INNER JOIN ECDbMeta.ECSchemaDef baseSchema ON baseSchema.ECInstanceId = baseClass.Schema.Id\n WHERE (derivedSchema.Name || ':' || derivedClass.Name) IN (${[...missingClasses].map((className) => `'${className}'`).join(\",\")})`;\n const reader = imodel.createQueryReader(query, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames });\n while (await reader.step()) {\n const row = reader.current.toRow();\n if (!(row.classFullName in baseClasses)) {\n baseClasses[row.classFullName] = [];\n }\n baseClasses[row.classFullName].push(row.baseClassFullName);\n }\n return baseClasses;\n };\n\n /** Changes field properties priorities to lower than another fields priority\n * @param imodel IModelConnection.\n * @param field Field that priority is being changed.\n * @param afterField Field that goes before the moved field. If undefined the moving field is changed to the highest priority (to the top).\n * @param visibleFields Array of fields to move the field in.\n */\n public async changeFieldPriority(imodel: IModelConnection, field: Field, afterField: Field | undefined, visibleFields: Field[]) {\n /**\n * How it works:\n * 1. Gets the orderInfo's for `field` (`orderInfo`) and `afterField` (`afterOrderInfo`) by selecting the most recent order informations for each field\n * 2. Iterates all orderInfo's that are in between `afterOrderInfo` and `orderInfo` when sorted by priority\n * 3. For each iterated orderInfo it checks if it is relevant:\n * 3.1. If orderInfo belongs to a primitive property, orderInfo is relevant\n * 3.2. If orderInfo's field is visible, orderInfo is relevant\n * 3.3. If orderInfo's class has a base class or itself in previously labeled relevant orderInfo's, orderInfo is relevant\n * 3.4. If 3.1 - 3.3 don't pass, orderInfo is irrelevant\n * 4. Irrelevant orderInfos's get moved after `orderInfo` (depends on the direction)\n * 5. All `field` orderInfo's get moved after `afterOrderInfo`\n */\n await this.ensureInitialized(imodel);\n const iTwinId = imodel.iTwinId!;\n const imodelId = imodel.iModelId!;\n\n if (field === afterField) {\n throw Error(\"`field` can not be the same as `afterField`.\");\n }\n\n const allOrderInfos = this._propertiesOrder.get(getiModelInfo(iTwinId, imodelId))!;\n\n const findFieldOrderInfoData = (f: Field) => {\n if (!visibleFields.includes(f)) {\n throw Error(\"Field is not contained in visible fields.\");\n }\n const infos = getFieldOrderInfos(f, allOrderInfos);\n\n if (infos.length === 0) {\n throw Error(\"Field has no property order information.\");\n }\n const info = getMostRecentOrderInfo(infos);\n const index = allOrderInfos.indexOf(info);\n return { infos, mostRecent: { info, index } };\n };\n\n const {\n infos: movingOrderInfos,\n mostRecent: { index: orderInfoIndex },\n } = findFieldOrderInfoData(field);\n\n let afterOrderInfo: FavoritePropertiesOrderInfo | undefined;\n let afterOrderInfoIndex;\n if (afterField === undefined) {\n afterOrderInfo = undefined;\n afterOrderInfoIndex = -1;\n } else {\n ({\n mostRecent: { info: afterOrderInfo, index: afterOrderInfoIndex },\n } = findFieldOrderInfoData(afterField));\n }\n\n let direction: Direction; // where to go from `afterOrderInfo` to `orderInfo`\n let startIndex: number;\n if (orderInfoIndex < afterOrderInfoIndex) {\n direction = Direction.Up;\n startIndex = afterOrderInfoIndex;\n } else {\n direction = Direction.Down;\n startIndex = afterOrderInfoIndex + 1;\n }\n\n const neededClassNames: Set<string> = allOrderInfos.reduce((classNames: Set<string>, oi) => {\n if (oi.parentClassName) {\n classNames.add(oi.parentClassName);\n }\n return classNames;\n }, new Set<string>());\n const baseClassesByClass = await this._getBaseClassesByClass(imodel, neededClassNames);\n\n const visibleOrderInfos = visibleFields.reduce(\n (union: FavoritePropertiesOrderInfo[], currField) => union.concat(getFieldOrderInfos(currField, allOrderInfos)),\n [],\n );\n const irrelevantOrderInfos: FavoritePropertiesOrderInfo[] = []; // orderInfos's that won't change their logical order in respect to other properties\n const relevantClasses: Set<ClassId> = new Set<ClassId>(); // currently relevant classes\n\n for (let i = startIndex; i !== orderInfoIndex; i += direction) {\n const currOrderInfo = allOrderInfos[i];\n\n // primitive properties are always relevant, because we can't determine their relevance based on the class hierarchy\n if (currOrderInfo.parentClassName === undefined) {\n continue;\n }\n\n const visible = visibleOrderInfos.includes(currOrderInfo);\n if (visible) {\n relevantClasses.add(currOrderInfo.parentClassName);\n continue;\n }\n\n const hasBaseClasses = baseClassesByClass[currOrderInfo.parentClassName].some((classId) => relevantClasses.has(classId));\n if (hasBaseClasses) {\n continue;\n }\n\n if (direction === Direction.Down) {\n irrelevantOrderInfos.push(currOrderInfo);\n } else {\n irrelevantOrderInfos.unshift(currOrderInfo);\n }\n }\n\n // remove irrelevantOrderInfo's to add them after the `orderInfo`\n irrelevantOrderInfos.forEach((foi) => {\n const index = allOrderInfos.findIndex((oi) => oi.parentClassName === foi.parentClassName && oi.name === foi.name);\n allOrderInfos.splice(index, 1);\n });\n\n // remove movingOrderInfos's to add them after the `afterOrderInfo`\n movingOrderInfos.forEach((foi) => {\n const index = allOrderInfos.findIndex((oi) => oi.parentClassName === foi.parentClassName && oi.name === foi.name);\n allOrderInfos.splice(index, 1);\n });\n movingOrderInfos.forEach((oi) => (oi.orderedTimestamp = new Date()));\n\n afterOrderInfoIndex = afterOrderInfo === undefined ? -1 : allOrderInfos.indexOf(afterOrderInfo);\n allOrderInfos.splice(afterOrderInfoIndex + 1, 0, ...movingOrderInfos);\n allOrderInfos.splice(afterOrderInfoIndex + 1 + (direction === Direction.Up ? movingOrderInfos.length : 0), 0, ...irrelevantOrderInfos);\n\n // reassign priority numbers\n let priority = allOrderInfos.length;\n allOrderInfos.forEach((oi) => (oi.priority = priority--));\n\n await this._storage.savePropertiesOrder(allOrderInfos, iTwinId, imodelId);\n this.onFavoritesChanged.raiseEvent();\n }\n}\n\nenum Direction {\n Up = -1,\n Down = 1,\n}\n\nconst getiModelInfo = (iTwinId: string, imodelId: string) => `${iTwinId}/${imodelId}`;\n\nconst getPropertiesFieldPropertyNames = (field: PropertiesField) => {\n const nestingPrefix = getNestingPrefix(field.parent);\n return field.properties.map(\n (property) => `${FavoritePropertiesManager.FAVORITES_IDENTIFIER_PREFIX}${nestingPrefix}${property.property.classInfo.name}:${property.property.name}`,\n );\n};\n\nconst getNestedContentFieldPropertyName = (field: NestedContentField) => {\n const nestingPrefix = getNestingPrefix(field);\n return `${FavoritePropertiesManager.FAVORITES_IDENTIFIER_PREFIX}${nestingPrefix}${field.contentClassInfo.name}`;\n};\n\nconst getNestingPrefix = (field: NestedContentField | undefined) => {\n const path: string[] = [];\n let curr = field;\n while (curr !== undefined) {\n curr.pathToPrimaryClass.forEach((rel) => {\n // Relationship directions are reversed, because we are generating a relationship list starting from the parent\n path.push(`${rel.isForwardRelationship ? \"B\" : \"F\"}:${rel.relationshipInfo.name}`);\n path.push(rel.targetClassInfo.name);\n });\n curr = curr.parent;\n }\n if (path.length === 0) {\n return \"\";\n }\n\n path.reverse();\n return `${path.join(\"-\")}-`;\n};\n\nconst getPropertyClassName = (propertyName: PropertyFullName): string | undefined => {\n const propertyNameStart = propertyName.split(\"-\")[0];\n const parts = propertyNameStart.split(\":\").length;\n if (parts === 1) {\n // primitive\n return undefined;\n }\n if (parts === 2) {\n // nested property OR nested property parent class OR regular property parent class\n return propertyNameStart;\n }\n // regular property without parent class\n return propertyNameStart.substring(0, propertyName.lastIndexOf(\":\"));\n};\n\n/** @internal */\nexport const getFieldInfos = (field: Field): Set<PropertyFullName> => {\n const fieldInfos: Set<PropertyFullName> = new Set<PropertyFullName>();\n if (field.isPropertiesField()) {\n getPropertiesFieldPropertyNames(field).forEach((info) => fieldInfos.add(info));\n } else if (field.isNestedContentField()) {\n fieldInfos.add(getNestedContentFieldPropertyName(field));\n } else {\n fieldInfos.add(`${FavoritePropertiesManager.FAVORITES_IDENTIFIER_PREFIX}${field.name}`);\n }\n return fieldInfos;\n};\n\nconst setHasAny = (set: Set<string>, lookup: Set<string>) => {\n for (const key of lookup) {\n if (set.has(key)) {\n return true;\n }\n }\n return false;\n};\n\nconst addOrderInfos = (dest: FavoritePropertiesOrderInfo[], source: FavoritePropertiesOrderInfo[]) => {\n source.forEach((si) => {\n const index = dest.findIndex((di) => di.name === si.name);\n if (index === -1) {\n si.orderedTimestamp = new Date();\n dest.push(si);\n }\n });\n let priority = dest.length;\n dest.forEach((info) => (info.priority = priority--));\n};\n\nconst removeOrderInfos = (container: FavoritePropertiesOrderInfo[], toRemove: FavoritePropertiesOrderInfo[]) => {\n toRemove.forEach((roi) => {\n const index = container.findIndex((oi) => oi.name === roi.name);\n /* istanbul ignore else */\n if (index >= 0) {\n container.splice(index, 1);\n }\n });\n};\n\n/** @internal */\nexport const createFieldOrderInfos = (field: Field): FavoritePropertiesOrderInfo[] => {\n if (field.isNestedContentField()) {\n const propertyName = getNestedContentFieldPropertyName(field);\n return [\n {\n parentClassName: getPropertyClassName(propertyName),\n name: propertyName,\n priority: 0,\n orderedTimestamp: new Date(),\n },\n ];\n }\n if (field.isPropertiesField()) {\n return getPropertiesFieldPropertyNames(field).map((propertyName) => ({\n parentClassName: getPropertyClassName(propertyName),\n name: propertyName,\n priority: 0,\n orderedTimestamp: new Date(),\n }));\n }\n return [\n {\n parentClassName: undefined,\n name: field.name,\n priority: 0,\n orderedTimestamp: new Date(),\n },\n ];\n};\n\nconst getFieldOrderInfos = (field: Field, orderInfos: FavoritePropertiesOrderInfo[]): FavoritePropertiesOrderInfo[] => {\n const fieldOrderInfos: FavoritePropertiesOrderInfo[] = [];\n const tryAddOrderInfo = (name: string) => {\n const fieldOrderInfo = orderInfos.find((oi) => oi.name === name);\n if (fieldOrderInfo !== undefined) {\n fieldOrderInfos.push(fieldOrderInfo);\n }\n };\n\n if (field.isPropertiesField()) {\n getPropertiesFieldPropertyNames(field).forEach(tryAddOrderInfo);\n } else if (field.isNestedContentField()) {\n tryAddOrderInfo(getNestedContentFieldPropertyName(field));\n } else {\n tryAddOrderInfo(field.name);\n }\n\n return fieldOrderInfos;\n};\n\nconst getMostRecentOrderInfo = (orderInfos: FavoritePropertiesOrderInfo[]) =>\n orderInfos.reduce((recent, curr) => (recent && recent.orderedTimestamp >= curr.orderedTimestamp ? recent : curr));\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Core
|
|
3
3
|
*/
|
|
4
|
-
import { IDisposable } from "@itwin/core-bentley";
|
|
5
4
|
import { IConnectivityInformationProvider } from "../ConnectivityInformationProvider";
|
|
6
5
|
import { FavoritePropertiesOrderInfo, PropertyFullName } from "./FavoritePropertiesManager";
|
|
7
6
|
/** @internal */
|
|
@@ -75,13 +74,13 @@ export interface OfflineCachingFavoritePropertiesStorageProps {
|
|
|
75
74
|
connectivityInfo?: IConnectivityInformationProvider;
|
|
76
75
|
}
|
|
77
76
|
/** @internal */
|
|
78
|
-
export declare class OfflineCachingFavoritePropertiesStorage implements IFavoritePropertiesStorage,
|
|
77
|
+
export declare class OfflineCachingFavoritePropertiesStorage implements IFavoritePropertiesStorage, Disposable {
|
|
79
78
|
private _connectivityInfo;
|
|
80
79
|
private _impl;
|
|
81
80
|
private _propertiesOfflineCache;
|
|
82
81
|
private _propertiesOrderOfflineCache;
|
|
83
82
|
constructor(props: OfflineCachingFavoritePropertiesStorageProps);
|
|
84
|
-
dispose(): void;
|
|
83
|
+
[Symbol.dispose](): void;
|
|
85
84
|
get impl(): IFavoritePropertiesStorage;
|
|
86
85
|
private onConnectivityStatusChanged;
|
|
87
86
|
loadProperties(iTwinId?: string, imodelId?: string): Promise<Set<string> | undefined>;
|
package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FavoritePropertiesStorage.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/favorite-properties/FavoritePropertiesStorage.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"FavoritePropertiesStorage.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/favorite-properties/FavoritePropertiesStorage.ts"],"names":[],"mappings":"AAIA;;GAEG;AAMH,OAAO,EAAmC,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACvH,OAAO,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE5F,gBAAgB;AAChB,eAAO,MAAM,uCAAuC,0BAA0B,CAAC;AAC/E,gBAAgB;AAChB,eAAO,MAAM,uCAAuC,eAAe,C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