@itwin/presentation-backend 4.4.0-dev.9 → 4.5.0-dev.2
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 +6 -1
- package/lib/cjs/presentation-backend/BackendLoggerCategory.js.map +1 -1
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +12 -3
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +81 -79
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
- package/lib/cjs/presentation-backend/NativePlatform.d.ts +1 -0
- package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/NativePlatform.js +1 -0
- package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
- package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationIpcHandler.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.d.ts +9 -4
- package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.js +107 -40
- package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +2 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js +18 -4
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js +4 -3
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetEmbedder.js +3 -3
- package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetManager.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetVariablesManager.js.map +1 -1
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js +16 -16
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
- package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -1
- package/lib/cjs/presentation-backend/UpdatesTracker.js.map +1 -1
- package/lib/cjs/presentation-backend/Utils.js.map +1 -1
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -1
- package/lib/cjs/presentation-backend/domain/RulesetElements.js.map +1 -1
- package/lib/cjs/presentation-backend.js.map +1 -1
- package/package.json +16 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# Change Log - @itwin/presentation-backend
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 03 Jan 2024 19:29:41 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 4.3.3
|
|
6
|
+
Wed, 03 Jan 2024 19:28:38 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
4
9
|
|
|
5
10
|
## 4.3.2
|
|
6
11
|
Thu, 14 Dec 2023 20:23:02 GMT
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackendLoggerCategory.js","sourceRoot":"","sources":["../../../src/presentation-backend/BackendLoggerCategory.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH;;;;;GAKG;AACH,IAAY,iCAWX;AAXD,WAAY,iCAAiC;IAC3C,qEAAgC,CAAA;IAEhC,+FAA+F;IAC/F,qGAAgE,CAAA;IAEhE,mEAAmE;IACnE,qEAAgC,CAAA;IAEhC,mEAAmE;IACnE,qEAAgC,CAAA;AAClC,CAAC,EAXW,iCAAiC,GAAjC,yCAAiC,KAAjC,yCAAiC,QAW5C;AAED;;;;;GAKG;AACH,IAAY,uCAsCX;AAtCD,WAAY,uCAAuC;IACjD,kEAAuB,CAAA;IACvB,8FAAmD,CAAA;IACnD,0GAA+D,CAAA;IAC/D,gHAAqE,CAAA;IAErE,4EAAiC,CAAA;IACjC,oGAAyD,CAAA;IACzD,wFAA6C,CAAA;IAC7C,mGAAwD,CAAA;IACxD,+GAAoE,CAAA;IACpE,4FAAiD,CAAA;IACjD,0FAA+C,CAAA;IAC/C,kHAAuE,CAAA;IACvE,0GAA+D,CAAA;IAC/D,wFAA6C,CAAA;IAC7C,8GAAmE,CAAA;IACnE,wGAA6D,CAAA;IAC7D,wGAA6D,CAAA;IAE7D,qEAAqE;IACrE,sGAA2D,CAAA;IAC3D,iDAAiD;IACjD,oGAAyD,CAAA;IACzD,yDAAyD;IACzD,wGAA6D,CAAA;IAC7D,qEAAqE;IACrE,kHAAuE,CAAA;IACvE,6DAA6D;IAC7D,8GAAmE,CAAA;IACnE,mEAAmE;IACnE,0HAA+E,CAAA;IAC/E,uDAAuD;IACvD,sGAA2D,CAAA;IAC3D,wDAAwD;IACxD,sGAA2D,CAAA;IAC3D,kEAAkE;IAClE,0HAA+E,CAAA;AACjF,CAAC,EAtCW,uCAAuC,GAAvC,+CAAuC,KAAvC,+CAAuC,QAsClD","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"BackendLoggerCategory.js","sourceRoot":"","sources":["../../../src/presentation-backend/BackendLoggerCategory.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH;;;;;GAKG;AACH,IAAY,iCAWX;AAXD,WAAY,iCAAiC;IAC3C,qEAAgC,CAAA;IAEhC,+FAA+F;IAC/F,qGAAgE,CAAA;IAEhE,mEAAmE;IACnE,qEAAgC,CAAA;IAEhC,mEAAmE;IACnE,qEAAgC,CAAA;AAClC,CAAC,EAXW,iCAAiC,GAAjC,yCAAiC,KAAjC,yCAAiC,QAW5C;AAED;;;;;GAKG;AACH,IAAY,uCAsCX;AAtCD,WAAY,uCAAuC;IACjD,kEAAuB,CAAA;IACvB,8FAAmD,CAAA;IACnD,0GAA+D,CAAA;IAC/D,gHAAqE,CAAA;IAErE,4EAAiC,CAAA;IACjC,oGAAyD,CAAA;IACzD,wFAA6C,CAAA;IAC7C,mGAAwD,CAAA;IACxD,+GAAoE,CAAA;IACpE,4FAAiD,CAAA;IACjD,0FAA+C,CAAA;IAC/C,kHAAuE,CAAA;IACvE,0GAA+D,CAAA;IAC/D,wFAA6C,CAAA;IAC7C,8GAAmE,CAAA;IACnE,wGAA6D,CAAA;IAC7D,wGAA6D,CAAA;IAE7D,qEAAqE;IACrE,sGAA2D,CAAA;IAC3D,iDAAiD;IACjD,oGAAyD,CAAA;IACzD,yDAAyD;IACzD,wGAA6D,CAAA;IAC7D,qEAAqE;IACrE,kHAAuE,CAAA;IACvE,6DAA6D;IAC7D,8GAAmE,CAAA;IACnE,mEAAmE;IACnE,0HAA+E,CAAA;IAC/E,uDAAuD;IACvD,sGAA2D,CAAA;IAC3D,wDAAwD;IACxD,sGAA2D,CAAA;IAC3D,kEAAkE;IAClE,0HAA+E,CAAA;AACjF,CAAC,EAtCW,uCAAuC,GAAvC,+CAAuC,KAAvC,+CAAuC,QAsClD","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 Logging\n */\n\n/**\n * Logger categories used by this package\n * @note All logger categories in this package start with the `presentation-backend` prefix.\n * @see [Logger]($bentley)\n * @public\n */\nexport enum PresentationBackendLoggerCategory {\n Package = \"presentation-backend\",\n\n /** The logger category used by the [[PresentationManager]] class and other related classes. */\n PresentationManager = \"presentation-backend.PresentationManager\",\n\n /** The logger category used by Presentation RPC implementation. */\n Rpc = \"presentation-backend.Rpc\",\n\n /** The logger category used by Presentation IPC implementation. */\n Ipc = \"presentation-backend.Ipc\",\n}\n\n/**\n * Logger categories used by this package\n * @note Logger categories used by the [[PresentationManager]] native addon.\n * @see [Logger]($bentley)\n * @public\n */\nexport enum PresentationBackendNativeLoggerCategory {\n ECObjects = \"ECObjects\",\n ECObjects_ECExpressions = \"ECObjects.ECExpressions\",\n ECObjects_ECExpressions_Parse = \"ECObjects.ECExpressions.Parse\",\n ECObjects_ECExpressions_Evaluate = \"ECObjects.ECExpressions.Evaluate\",\n\n ECPresentation = \"ECPresentation\",\n ECPresentation_Connections = \"ECPresentation.Connections\",\n ECPresentation_Tasks = \"ECPresentation.Tasks\",\n ECPresentation_Hierarchies = \"ECPresentation.Navigation\",\n ECPresentation_Hierarchies_Cache = \"ECPresentation.Navigation.Cache\",\n ECPresentation_Content = \"ECPresentation.Content\",\n ECPresentation_Update = \"ECPresentation.Update\",\n ECPresentation_Update_Hierarchies = \"ECPresentation.Update.Hierarchies\",\n ECPresentation_Update_Content = \"ECPresentation.Update.Content\",\n ECPresentation_Rules = \"ECPresentation.Rules\",\n ECPresentation_RulesetVariables = \"ECPresentation.RulesetVariables\",\n ECPresentation_ECExpressions = \"ECPresentation.ECExpressions\",\n ECPresentation_Serialization = \"ECPresentation.Serialization\",\n\n /** @deprecated in 4.0. The logging namespace is not used anymore. */\n ECPresentation_Localization = \"ECPresentation.Localization\",\n /** @deprecated in 4.0. Use [[ECPresentation]] */\n ECPresentation_RulesEngine = \"ECPresentation.RulesEngine\",\n /** @deprecated in 4.0. Use [[ECPresentation_Content]] */\n ECPresentation_RulesEngine_Content = \"ECPresentation.Content\",\n /** @deprecated in 4.0. The logging namespace is not used anymore. */\n ECPresentation_RulesEngine_Localization = \"ECPresentation.Localization\",\n /** @deprecated in 4.0. Use [[ECPresentation_Hierarchies]] */\n ECPresentation_RulesEngine_Navigation = \"ECPresentation.Navigation\",\n /** @deprecated in 4.0. Use [[ECPresentation_Hierarchies_Cache]] */\n ECPresentation_RulesEngine_Navigation_Cache = \"ECPresentation.Navigation.Cache\",\n /** @deprecated in 4.0. Use [[ECPresentation_Tasks]] */\n ECPresentation_RulesEngine_Threads = \"ECPresentation.Tasks\",\n /** @deprecated in 4.0. Use [[ECPresentation_Update]] */\n ECPresentation_RulesEngine_Update = \"ECPresentation.Update\",\n /** @deprecated in 4.0. Use [[ECPresentation_RulesetVariables]] */\n ECPresentation_RulesEngine_RulesetVariables = \"ECPresentation.RulesetVariables\",\n}\n"]}
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Core
|
|
3
3
|
*/
|
|
4
|
+
import { Observable } from "rxjs";
|
|
4
5
|
import { IModelDb } from "@itwin/core-backend";
|
|
5
|
-
import {
|
|
6
|
+
import { Id64String } from "@itwin/core-bentley";
|
|
7
|
+
import { Descriptor, ElementProperties, Item } from "@itwin/presentation-common";
|
|
6
8
|
/** @internal */
|
|
7
|
-
export declare const
|
|
9
|
+
export declare const buildElementProperties: (descriptor: Descriptor, item: Item) => ElementProperties;
|
|
8
10
|
/** @internal */
|
|
9
11
|
export declare function getElementsCount(db: IModelDb, classNames?: string[]): number;
|
|
10
12
|
/** @internal */
|
|
11
|
-
export declare function
|
|
13
|
+
export declare function parseFullClassName(fullClassName: string): [string, string];
|
|
14
|
+
/** @internal */
|
|
15
|
+
export declare function getClassesWithInstances(imodel: IModelDb, fullClassNames: string[]): Observable<string>;
|
|
16
|
+
/** @internal */
|
|
17
|
+
export declare function getBatchedClassElementIds(imodel: IModelDb, fullClassName: string, batchSize: number): Promise<Array<{
|
|
18
|
+
from: Id64String;
|
|
19
|
+
to: Id64String;
|
|
20
|
+
}>>;
|
|
12
21
|
//# sourceMappingURL=ElementPropertiesHelper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementPropertiesHelper.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/ElementPropertiesHelper.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAkB,QAAQ,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"ElementPropertiesHelper.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/ElementPropertiesHelper.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAA4B,UAAU,EAAU,MAAM,MAAM,CAAC;AACpE,OAAO,EAAkB,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAA0B,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAEL,UAAU,EACV,iBAAiB,EAMjB,IAAI,EAcL,MAAM,4BAA4B,CAAC;AAEpC,gBAAgB;AAChB,eAAO,MAAM,sBAAsB,eAAgB,UAAU,QAAQ,IAAI,KAAG,iBAI3E,CAAC;AAEF,gBAAgB;AAChB,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,UAWnE;AAED,gBAAgB;AAChB,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAG1E;AAOD,gBAAgB;AAChB,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,CAmBtG;AAED,gBAAgB;AAChB,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,QAAQ,EAChB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,KAAK,CAAC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,UAAU,CAAA;CAAE,CAAC,CAAC,CAqBtD"}
|
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
/** @packageDocumentation
|
|
7
7
|
* @module Core
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
10
|
+
exports.getBatchedClassElementIds = exports.getClassesWithInstances = exports.parseFullClassName = exports.getElementsCount = exports.buildElementProperties = void 0;
|
|
11
|
+
const rxjs_1 = require("rxjs");
|
|
11
12
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
13
|
const presentation_common_1 = require("@itwin/presentation-common");
|
|
13
14
|
/** @internal */
|
|
14
|
-
const
|
|
15
|
-
if (!content || content.contentSet.length === 0)
|
|
16
|
-
return [];
|
|
15
|
+
const buildElementProperties = (descriptor, item) => {
|
|
17
16
|
const builder = new ElementPropertiesBuilder();
|
|
18
|
-
(0, presentation_common_1.
|
|
19
|
-
return builder.items;
|
|
17
|
+
(0, presentation_common_1.traverseContentItem)(builder, descriptor, item);
|
|
18
|
+
return builder.items[0];
|
|
20
19
|
};
|
|
21
|
-
exports.
|
|
20
|
+
exports.buildElementProperties = buildElementProperties;
|
|
22
21
|
/** @internal */
|
|
23
22
|
function getElementsCount(db, classNames) {
|
|
24
23
|
const filter = createElementsFilter("e", classNames);
|
|
25
|
-
const query = `
|
|
26
|
-
SELECT COUNT(e.ECInstanceId)
|
|
27
|
-
FROM bis.Element e
|
|
28
|
-
${filter ? `WHERE ${filter}` : ""}
|
|
24
|
+
const query = `
|
|
25
|
+
SELECT COUNT(e.ECInstanceId)
|
|
26
|
+
FROM bis.Element e
|
|
27
|
+
${filter ? `WHERE ${filter}` : ""}
|
|
29
28
|
`;
|
|
30
29
|
return db.withPreparedStatement(query, (stmt) => {
|
|
31
30
|
return stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW ? stmt.getValue(0).getInteger() : 0;
|
|
@@ -33,73 +32,65 @@ function getElementsCount(db, classNames) {
|
|
|
33
32
|
}
|
|
34
33
|
exports.getElementsCount = getElementsCount;
|
|
35
34
|
/** @internal */
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const result = queryElementIds(db, classNames, limit, lastElementId);
|
|
40
|
-
yield result.ids;
|
|
41
|
-
lastElementId = result.lastElementId;
|
|
42
|
-
if (!lastElementId)
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
35
|
+
function parseFullClassName(fullClassName) {
|
|
36
|
+
const [schemaName, className] = fullClassName.split(/[:\.]/);
|
|
37
|
+
return [schemaName, className];
|
|
45
38
|
}
|
|
46
|
-
exports.
|
|
47
|
-
function
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (!existingIds) {
|
|
80
|
-
currentIds = [];
|
|
81
|
-
ids.set(row.elClassName, currentIds);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
currentIds = existingIds;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
currentIds.push(row.elId);
|
|
88
|
-
loadedIds++;
|
|
89
|
-
if (limit && loadedIds >= limit)
|
|
90
|
-
return { ids, lastElementId: row.elId };
|
|
39
|
+
exports.parseFullClassName = parseFullClassName;
|
|
40
|
+
function getECSqlName(fullClassName) {
|
|
41
|
+
const [schemaName, className] = parseFullClassName(fullClassName);
|
|
42
|
+
return `[${schemaName}].[${className}]`;
|
|
43
|
+
}
|
|
44
|
+
/** @internal */
|
|
45
|
+
function getClassesWithInstances(imodel, fullClassNames) {
|
|
46
|
+
return (0, rxjs_1.from)(fullClassNames).pipe((0, rxjs_1.mergeMap)((fullClassName) => {
|
|
47
|
+
const reader = imodel.createQueryReader(`
|
|
48
|
+
SELECT s.Name, c.Name
|
|
49
|
+
FROM ${getECSqlName(fullClassName)} e
|
|
50
|
+
JOIN meta.ECClassDef c ON c.ECInstanceId = e.ECClassId
|
|
51
|
+
JOIN meta.ECSchemaDef s on s.ECInstanceId = c.Schema.Id
|
|
52
|
+
GROUP BY c.ECInstanceId
|
|
53
|
+
`);
|
|
54
|
+
return (0, rxjs_1.from)(reader.toArray());
|
|
55
|
+
}), (0, rxjs_1.mergeAll)(), (0, rxjs_1.reduce)((set, [schemaName, className]) => {
|
|
56
|
+
set.add(`${schemaName}.${className}`);
|
|
57
|
+
return set;
|
|
58
|
+
}, new Set()), (0, rxjs_1.mergeMap)((set) => [...set]));
|
|
59
|
+
}
|
|
60
|
+
exports.getClassesWithInstances = getClassesWithInstances;
|
|
61
|
+
/** @internal */
|
|
62
|
+
async function getBatchedClassElementIds(imodel, fullClassName, batchSize) {
|
|
63
|
+
const batches = [];
|
|
64
|
+
const reader = imodel.createQueryReader(`SELECT ECInstanceId id FROM ${getECSqlName(fullClassName)} ORDER BY ECInstanceId`);
|
|
65
|
+
let currId;
|
|
66
|
+
let fromId;
|
|
67
|
+
let count = 0;
|
|
68
|
+
while (await reader.step()) {
|
|
69
|
+
currId = reader.current.toRow().id;
|
|
70
|
+
if (!fromId) {
|
|
71
|
+
fromId = currId;
|
|
91
72
|
}
|
|
92
|
-
|
|
93
|
-
|
|
73
|
+
if (++count >= batchSize) {
|
|
74
|
+
batches.push({ from: fromId, to: currId });
|
|
75
|
+
fromId = undefined;
|
|
76
|
+
count = 0;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (fromId && currId) {
|
|
80
|
+
batches.push({ from: fromId, to: currId });
|
|
81
|
+
}
|
|
82
|
+
return batches;
|
|
94
83
|
}
|
|
84
|
+
exports.getBatchedClassElementIds = getBatchedClassElementIds;
|
|
95
85
|
function createElementsFilter(elementAlias, classNames) {
|
|
96
|
-
if (classNames === undefined || classNames.length === 0)
|
|
86
|
+
if (classNames === undefined || classNames.length === 0) {
|
|
97
87
|
return undefined;
|
|
88
|
+
}
|
|
98
89
|
// check if list contains only valid class names
|
|
99
90
|
const classNameRegExp = new RegExp(/^[\w]+[.:][\w]+$/);
|
|
100
91
|
const invalidName = classNames.find((name) => !name.match(classNameRegExp));
|
|
101
92
|
if (invalidName) {
|
|
102
|
-
throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.InvalidArgument, `Encountered invalid class name - ${invalidName}.
|
|
93
|
+
throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.InvalidArgument, `Encountered invalid class name - ${invalidName}.
|
|
103
94
|
Valid class name formats: "<schema name or alias>.<class name>", "<schema name or alias>:<class name>"`);
|
|
104
95
|
}
|
|
105
96
|
return `${elementAlias}.ECClassId IS (${classNames.join(",")})`;
|
|
@@ -146,8 +137,9 @@ class CategoryItemAppender {
|
|
|
146
137
|
this._items[label] = item;
|
|
147
138
|
}
|
|
148
139
|
finish() {
|
|
149
|
-
if (Object.keys(this._items).length === 0)
|
|
140
|
+
if (Object.keys(this._items).length === 0) {
|
|
150
141
|
return;
|
|
142
|
+
}
|
|
151
143
|
this._parentAppender.append(this._category.label, {
|
|
152
144
|
type: "category",
|
|
153
145
|
items: this._items,
|
|
@@ -166,10 +158,12 @@ class ArrayItemAppender {
|
|
|
166
158
|
}
|
|
167
159
|
finish() {
|
|
168
160
|
(0, core_bentley_1.assert)(this._props.valueType.valueFormat === presentation_common_1.PropertyValueFormat.Array);
|
|
169
|
-
if (this._props.valueType.memberType.valueFormat === presentation_common_1.PropertyValueFormat.Primitive)
|
|
161
|
+
if (this._props.valueType.memberType.valueFormat === presentation_common_1.PropertyValueFormat.Primitive) {
|
|
170
162
|
this._parentAppender.append(this._props.hierarchy.field.label, this.createPrimitivesArray());
|
|
171
|
-
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
172
165
|
this._parentAppender.append(this._props.hierarchy.field.label, this.createStructsArray());
|
|
166
|
+
}
|
|
173
167
|
}
|
|
174
168
|
createPrimitivesArray() {
|
|
175
169
|
return {
|
|
@@ -223,7 +217,9 @@ class ElementPropertiesBuilder {
|
|
|
223
217
|
(0, core_bentley_1.assert)(appender !== undefined);
|
|
224
218
|
return appender;
|
|
225
219
|
}
|
|
226
|
-
startContent(_props) {
|
|
220
|
+
startContent(_props) {
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
227
223
|
finishContent() { }
|
|
228
224
|
processFieldHierarchies(_props) { }
|
|
229
225
|
startItem(props) {
|
|
@@ -245,18 +241,24 @@ class ElementPropertiesBuilder {
|
|
|
245
241
|
finishCategory() {
|
|
246
242
|
this._appendersStack.pop();
|
|
247
243
|
}
|
|
248
|
-
startField(_props) {
|
|
244
|
+
startField(_props) {
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
249
247
|
finishField() { }
|
|
250
248
|
startStruct(props) {
|
|
251
249
|
this._appendersStack.push(new StructItemAppender(this._currentAppender, props));
|
|
252
250
|
return true;
|
|
253
251
|
}
|
|
254
|
-
finishStruct() {
|
|
252
|
+
finishStruct() {
|
|
253
|
+
this._appendersStack.pop().finish();
|
|
254
|
+
}
|
|
255
255
|
startArray(props) {
|
|
256
256
|
this._appendersStack.push(new ArrayItemAppender(this._currentAppender, props));
|
|
257
257
|
return true;
|
|
258
258
|
}
|
|
259
|
-
finishArray() {
|
|
259
|
+
finishArray() {
|
|
260
|
+
this._appendersStack.pop().finish();
|
|
261
|
+
}
|
|
260
262
|
processMergedValue(props) {
|
|
261
263
|
this._currentAppender.append(props.mergedField.label, {
|
|
262
264
|
type: "primitive",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementPropertiesHelper.js","sourceRoot":"","sources":["../../../src/presentation-backend/ElementPropertiesHelper.ts"],"names":[],"mappings":";AAAA;;;+F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AAC,CAAC;IACL,CAAC;CACF","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 { ECSqlStatement, IModelDb } from \"@itwin/core-backend\";\r\nimport { assert, DbResult, Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport {\r\n CategoryDescription, Content, ElementProperties, ElementPropertiesItem, ElementPropertiesPrimitiveArrayPropertyItem, ElementPropertiesPropertyItem,\r\n ElementPropertiesStructArrayPropertyItem, IContentVisitor, Item, PresentationError, PresentationStatus, ProcessFieldHierarchiesProps, ProcessMergedValueProps,\r\n ProcessPrimitiveValueProps, PropertyValueFormat, StartArrayProps, StartCategoryProps, StartContentProps, StartFieldProps, StartItemProps,\r\n StartStructProps, traverseContent,\r\n} from \"@itwin/presentation-common\";\r\n\r\n/** @internal */\r\nexport const buildElementsProperties = (content: Content | undefined): ElementProperties[] => {\r\n if (!content || content.contentSet.length === 0)\r\n return [];\r\n\r\n const builder = new ElementPropertiesBuilder();\r\n traverseContent(builder, content);\r\n return builder.items;\r\n};\r\n\r\n/** @internal */\r\nexport function getElementsCount(db: IModelDb, classNames?: string[]) {\r\n const filter = createElementsFilter(\"e\", classNames);\r\n const query = `\r\n SELECT COUNT(e.ECInstanceId)\r\n FROM bis.Element e\r\n ${filter ? `WHERE ${filter}` : \"\"}\r\n `;\r\n\r\n return db.withPreparedStatement(query, (stmt: ECSqlStatement) => {\r\n return stmt.step() === DbResult.BE_SQLITE_ROW ? stmt.getValue(0).getInteger() : 0;\r\n });\r\n}\r\n\r\n/** @internal */\r\nexport function* iterateElementIds(db: IModelDb, classNames?: string[], limit?: number) {\r\n let lastElementId;\r\n while (true) {\r\n const result = queryElementIds(db, classNames, limit, lastElementId);\r\n yield result.ids;\r\n lastElementId = result.lastElementId;\r\n if (!lastElementId)\r\n break;\r\n }\r\n}\r\n\r\nfunction queryElementIds(db: IModelDb, classNames?: string[], limit?: number, lastElementId?: Id64String) {\r\n function createWhereClause() {\r\n const classFilter = createElementsFilter(\"e\", classNames);\r\n const elementFilter = lastElementId ? `e.ECInstanceId > ?` : undefined;\r\n if (!classFilter && !elementFilter)\r\n return \"\";\r\n if (classFilter && elementFilter)\r\n return `WHERE ${classFilter} AND ${elementFilter}`;\r\n return `WHERE ${classFilter ?? \"\"} ${elementFilter ?? \"\"}`;\r\n }\r\n\r\n const query = `\r\n SELECT e.ECInstanceId elId, eSchemaDef.Name || ':' || eClassDef.Name elClassName\r\n FROM bis.Element e\r\n LEFT JOIN meta.ECClassDef eClassDef ON eClassDef.ECInstanceId = e.ECClassId\r\n LEFT JOIN meta.ECSchemaDef eSchemaDef ON eSchemaDef.ECInstanceId = eClassDef.Schema.Id\r\n ${createWhereClause()}\r\n ORDER BY e.ECInstanceId ASC\r\n `;\r\n\r\n return db.withPreparedStatement(query, (stmt: ECSqlStatement) => {\r\n if (lastElementId)\r\n stmt.bindId(1, lastElementId);\r\n\r\n const ids = new Map<string, string[]>();\r\n let currentClassName = \"\";\r\n let currentIds: string[] = [];\r\n let loadedIds = 0;\r\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\r\n const row = stmt.getRow();\r\n if (!row.elId || !row.elClassName)\r\n continue;\r\n\r\n if (currentClassName !== row.elClassName) {\r\n currentClassName = row.elClassName;\r\n const existingIds = ids.get(row.elClassName);\r\n if (!existingIds) {\r\n currentIds = [];\r\n ids.set(row.elClassName, currentIds);\r\n } else {\r\n currentIds = existingIds;\r\n }\r\n }\r\n currentIds.push(row.elId);\r\n loadedIds++;\r\n if (limit && loadedIds >= limit)\r\n return { ids, lastElementId: row.elId };\r\n }\r\n return { ids, lastElementId: undefined };\r\n });\r\n}\r\n\r\nfunction createElementsFilter(elementAlias: string, classNames?: string[]) {\r\n if (classNames === undefined || classNames.length === 0)\r\n return undefined;\r\n\r\n // check if list contains only valid class names\r\n const classNameRegExp = new RegExp(/^[\\w]+[.:][\\w]+$/);\r\n const invalidName = classNames.find((name) => !name.match(classNameRegExp));\r\n if (invalidName) {\r\n throw new PresentationError(PresentationStatus.InvalidArgument, `Encountered invalid class name - ${invalidName}.\r\n Valid class name formats: \"<schema name or alias>.<class name>\", \"<schema name or alias>:<class name>\"`);\r\n }\r\n\r\n return `${elementAlias}.ECClassId IS (${classNames.join(\",\")})`;\r\n}\r\n\r\ninterface IPropertiesAppender {\r\n append(label: string, item: ElementPropertiesItem): void;\r\n finish(): void;\r\n}\r\n\r\nclass ElementPropertiesAppender implements IPropertiesAppender {\r\n private _propertyItems: { [label: string]: ElementPropertiesItem } = {};\r\n private _categoryItemAppenders: { [categoryName: string]: IPropertiesAppender } = {};\r\n constructor(private _item: Item, private _onItemFinished: (item: ElementProperties) => void) { }\r\n\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n this._propertyItems[label] = item;\r\n }\r\n\r\n public finish(): void {\r\n // eslint-disable-next-line guard-for-in\r\n for (const categoryName in this._categoryItemAppenders) {\r\n const appender = this._categoryItemAppenders[categoryName];\r\n appender.finish();\r\n }\r\n\r\n this._onItemFinished({\r\n class: this._item.classInfo?.label ?? \"\",\r\n id: this._item.primaryKeys[0]?.id ?? Id64.invalid,\r\n label: this._item.label.displayValue,\r\n items: this._propertyItems,\r\n });\r\n }\r\n\r\n public getCategoryAppender(parentAppender: IPropertiesAppender, category: CategoryDescription): IPropertiesAppender {\r\n let appender = this._categoryItemAppenders[category.name];\r\n if (!appender) {\r\n appender = new CategoryItemAppender(parentAppender, category);\r\n this._categoryItemAppenders[category.name] = appender;\r\n }\r\n return appender;\r\n }\r\n}\r\n\r\nclass CategoryItemAppender implements IPropertiesAppender {\r\n private _items: { [label: string]: ElementPropertiesItem } = {};\r\n constructor(private _parentAppender: IPropertiesAppender, private _category: CategoryDescription) { }\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n this._items[label] = item;\r\n }\r\n public finish(): void {\r\n if (Object.keys(this._items).length === 0)\r\n return;\r\n\r\n this._parentAppender.append(this._category.label, {\r\n type: \"category\",\r\n items: this._items,\r\n });\r\n }\r\n}\r\n\r\nclass ArrayItemAppender implements IPropertiesAppender {\r\n private _items: ElementPropertiesPropertyItem[] = [];\r\n constructor(private _parentAppender: IPropertiesAppender, private _props: StartArrayProps) { }\r\n public append(_label: string, item: ElementPropertiesItem): void {\r\n assert(item.type !== \"category\");\r\n this._items.push(item);\r\n }\r\n public finish(): void {\r\n assert(this._props.valueType.valueFormat === PropertyValueFormat.Array);\r\n if (this._props.valueType.memberType.valueFormat === PropertyValueFormat.Primitive)\r\n this._parentAppender.append(this._props.hierarchy.field.label, this.createPrimitivesArray());\r\n else\r\n this._parentAppender.append(this._props.hierarchy.field.label, this.createStructsArray());\r\n }\r\n private createPrimitivesArray(): ElementPropertiesPrimitiveArrayPropertyItem {\r\n return {\r\n type: \"array\",\r\n valueType: \"primitive\",\r\n values: this._items.map((item) => {\r\n assert(item.type === \"primitive\");\r\n return item.value;\r\n }),\r\n };\r\n }\r\n private createStructsArray(): ElementPropertiesStructArrayPropertyItem {\r\n return {\r\n type: \"array\",\r\n valueType: \"struct\",\r\n values: this._items.map((item) => {\r\n assert(item.type === \"struct\");\r\n return item.members;\r\n }),\r\n };\r\n }\r\n}\r\n\r\nclass StructItemAppender implements IPropertiesAppender {\r\n private _members: { [label: string]: ElementPropertiesPropertyItem } = {};\r\n constructor(private _parentAppender: IPropertiesAppender, private _props: StartStructProps) { }\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n assert(item.type !== \"category\");\r\n this._members[label] = item;\r\n }\r\n public finish(): void {\r\n assert(this._props.valueType.valueFormat === PropertyValueFormat.Struct);\r\n this._parentAppender.append(this._props.hierarchy.field.label, {\r\n type: \"struct\",\r\n members: this._members,\r\n });\r\n }\r\n}\r\n\r\nclass ElementPropertiesBuilder implements IContentVisitor {\r\n private _appendersStack: IPropertiesAppender[] = [];\r\n private _items: ElementProperties[] = [];\r\n private _elementPropertiesAppender: ElementPropertiesAppender | undefined;\r\n\r\n public get items(): ElementProperties[] {\r\n return this._items;\r\n }\r\n\r\n private get _currentAppender(): IPropertiesAppender {\r\n const appender = this._appendersStack[this._appendersStack.length - 1];\r\n assert(appender !== undefined);\r\n return appender;\r\n }\r\n\r\n public startContent(_props: StartContentProps): boolean { return true; }\r\n public finishContent(): void { }\r\n\r\n public processFieldHierarchies(_props: ProcessFieldHierarchiesProps): void { }\r\n\r\n public startItem(props: StartItemProps): boolean {\r\n this._elementPropertiesAppender = new ElementPropertiesAppender(props.item, (item) => this._items.push(item));\r\n this._appendersStack.push(this._elementPropertiesAppender);\r\n return true;\r\n }\r\n public finishItem(): void {\r\n this._appendersStack.pop();\r\n assert(this._elementPropertiesAppender !== undefined);\r\n this._elementPropertiesAppender.finish();\r\n this._elementPropertiesAppender = undefined;\r\n }\r\n\r\n public startCategory(props: StartCategoryProps): boolean {\r\n assert(this._elementPropertiesAppender !== undefined);\r\n this._appendersStack.push(this._elementPropertiesAppender.getCategoryAppender(this._currentAppender, props.category));\r\n return true;\r\n }\r\n public finishCategory(): void {\r\n this._appendersStack.pop();\r\n }\r\n\r\n public startField(_props: StartFieldProps): boolean { return true; }\r\n public finishField(): void { }\r\n\r\n public startStruct(props: StartStructProps): boolean {\r\n this._appendersStack.push(new StructItemAppender(this._currentAppender, props));\r\n return true;\r\n }\r\n public finishStruct(): void { this._appendersStack.pop()!.finish(); }\r\n\r\n public startArray(props: StartArrayProps): boolean {\r\n this._appendersStack.push(new ArrayItemAppender(this._currentAppender, props));\r\n return true;\r\n }\r\n public finishArray(): void { this._appendersStack.pop()!.finish(); }\r\n\r\n public processMergedValue(props: ProcessMergedValueProps): void {\r\n this._currentAppender.append(props.mergedField.label, {\r\n type: \"primitive\",\r\n value: \"\",\r\n });\r\n }\r\n public processPrimitiveValue(props: ProcessPrimitiveValueProps): void {\r\n this._currentAppender.append(props.field.label, {\r\n type: \"primitive\",\r\n value: props.displayValue?.toString() ?? \"\",\r\n });\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ElementPropertiesHelper.js","sourceRoot":"","sources":["../../../src/presentation-backend/ElementPropertiesHelper.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAAoE;AAEpE,sDAAyE;AACzE,oEAuBoC;AAEpC,gBAAgB;AACT,MAAM,sBAAsB,GAAG,CAAC,UAAsB,EAAE,IAAU,EAAqB,EAAE;IAC9F,MAAM,OAAO,GAAG,IAAI,wBAAwB,EAAE,CAAC;IAC/C,IAAA,yCAAmB,EAAC,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAC/C,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1B,CAAC,CAAC;AAJW,QAAA,sBAAsB,0BAIjC;AAEF,gBAAgB;AAChB,SAAgB,gBAAgB,CAAC,EAAY,EAAE,UAAqB;IAClE,MAAM,MAAM,GAAG,oBAAoB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG;;;MAGV,MAAM,CAAC,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE;GAClC,CAAC;IAEF,OAAO,EAAE,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC,IAAoB,EAAE,EAAE;QAC9D,OAAO,IAAI,CAAC,IAAI,EAAE,KAAK,uBAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACpF,CAAC,CAAC,CAAC;AACL,CAAC;AAXD,4CAWC;AAED,gBAAgB;AAChB,SAAgB,kBAAkB,CAAC,aAAqB;IACtD,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7D,OAAO,CAAC,UAAU,EAAE,SA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AK,CAAC,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE;SAC5C,CAAC,CAAC;IACL,CAAC;CACF","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 Core\n */\n\nimport { from, mergeAll, mergeMap, Observable, reduce } from \"rxjs\";\nimport { ECSqlStatement, IModelDb } from \"@itwin/core-backend\";\nimport { assert, DbResult, Id64, Id64String } from \"@itwin/core-bentley\";\nimport {\n CategoryDescription,\n Descriptor,\n ElementProperties,\n ElementPropertiesItem,\n ElementPropertiesPrimitiveArrayPropertyItem,\n ElementPropertiesPropertyItem,\n ElementPropertiesStructArrayPropertyItem,\n IContentVisitor,\n Item,\n PresentationError,\n PresentationStatus,\n ProcessFieldHierarchiesProps,\n ProcessMergedValueProps,\n ProcessPrimitiveValueProps,\n PropertyValueFormat,\n StartArrayProps,\n StartCategoryProps,\n StartContentProps,\n StartFieldProps,\n StartItemProps,\n StartStructProps,\n traverseContentItem,\n} from \"@itwin/presentation-common\";\n\n/** @internal */\nexport const buildElementProperties = (descriptor: Descriptor, item: Item): ElementProperties => {\n const builder = new ElementPropertiesBuilder();\n traverseContentItem(builder, descriptor, item);\n return builder.items[0];\n};\n\n/** @internal */\nexport function getElementsCount(db: IModelDb, classNames?: string[]) {\n const filter = createElementsFilter(\"e\", classNames);\n const query = `\n SELECT COUNT(e.ECInstanceId)\n FROM bis.Element e\n ${filter ? `WHERE ${filter}` : \"\"}\n `;\n\n return db.withPreparedStatement(query, (stmt: ECSqlStatement) => {\n return stmt.step() === DbResult.BE_SQLITE_ROW ? stmt.getValue(0).getInteger() : 0;\n });\n}\n\n/** @internal */\nexport function parseFullClassName(fullClassName: string): [string, string] {\n const [schemaName, className] = fullClassName.split(/[:\\.]/);\n return [schemaName, className];\n}\n\nfunction getECSqlName(fullClassName: string) {\n const [schemaName, className] = parseFullClassName(fullClassName);\n return `[${schemaName}].[${className}]`;\n}\n\n/** @internal */\nexport function getClassesWithInstances(imodel: IModelDb, fullClassNames: string[]): Observable<string> {\n return from(fullClassNames).pipe(\n mergeMap((fullClassName) => {\n const reader = imodel.createQueryReader(`\n SELECT s.Name, c.Name\n FROM ${getECSqlName(fullClassName)} e\n JOIN meta.ECClassDef c ON c.ECInstanceId = e.ECClassId\n JOIN meta.ECSchemaDef s on s.ECInstanceId = c.Schema.Id\n GROUP BY c.ECInstanceId\n `);\n return from(reader.toArray() as Promise<[string, string][]>);\n }),\n mergeAll(),\n reduce<[string, string], Set<string>>((set, [schemaName, className]) => {\n set.add(`${schemaName}.${className}`);\n return set;\n }, new Set()),\n mergeMap((set) => [...set]),\n );\n}\n\n/** @internal */\nexport async function getBatchedClassElementIds(\n imodel: IModelDb,\n fullClassName: string,\n batchSize: number,\n): Promise<Array<{ from: Id64String, to: Id64String }>> {\n const batches = [];\n const reader = imodel.createQueryReader(`SELECT ECInstanceId id FROM ${getECSqlName(fullClassName)} ORDER BY ECInstanceId`);\n let currId: Id64String | undefined;\n let fromId: Id64String | undefined;\n let count = 0;\n while (await reader.step()) {\n currId = reader.current.toRow().id as Id64String;\n if (!fromId) {\n fromId = currId;\n }\n if (++count >= batchSize) {\n batches.push({ from: fromId, to: currId });\n fromId = undefined;\n count = 0;\n }\n }\n if (fromId && currId) {\n batches.push({ from: fromId, to: currId });\n }\n return batches;\n}\n\nfunction createElementsFilter(elementAlias: string, classNames?: string[]) {\n if (classNames === undefined || classNames.length === 0) {\n return undefined;\n }\n\n // check if list contains only valid class names\n const classNameRegExp = new RegExp(/^[\\w]+[.:][\\w]+$/);\n const invalidName = classNames.find((name) => !name.match(classNameRegExp));\n if (invalidName) {\n throw new PresentationError(\n PresentationStatus.InvalidArgument,\n `Encountered invalid class name - ${invalidName}.\n Valid class name formats: \"<schema name or alias>.<class name>\", \"<schema name or alias>:<class name>\"`,\n );\n }\n\n return `${elementAlias}.ECClassId IS (${classNames.join(\",\")})`;\n}\n\ninterface IPropertiesAppender {\n append(label: string, item: ElementPropertiesItem): void;\n finish(): void;\n}\n\nclass ElementPropertiesAppender implements IPropertiesAppender {\n private _propertyItems: { [label: string]: ElementPropertiesItem } = {};\n private _categoryItemAppenders: { [categoryName: string]: IPropertiesAppender } = {};\n constructor(private _item: Item, private _onItemFinished: (item: ElementProperties) => void) {}\n\n public append(label: string, item: ElementPropertiesItem): void {\n this._propertyItems[label] = item;\n }\n\n public finish(): void {\n // eslint-disable-next-line guard-for-in\n for (const categoryName in this._categoryItemAppenders) {\n const appender = this._categoryItemAppenders[categoryName];\n appender.finish();\n }\n\n this._onItemFinished({\n class: this._item.classInfo?.label ?? \"\",\n id: this._item.primaryKeys[0]?.id ?? Id64.invalid,\n label: this._item.label.displayValue,\n items: this._propertyItems,\n });\n }\n\n public getCategoryAppender(parentAppender: IPropertiesAppender, category: CategoryDescription): IPropertiesAppender {\n let appender = this._categoryItemAppenders[category.name];\n if (!appender) {\n appender = new CategoryItemAppender(parentAppender, category);\n this._categoryItemAppenders[category.name] = appender;\n }\n return appender;\n }\n}\n\nclass CategoryItemAppender implements IPropertiesAppender {\n private _items: { [label: string]: ElementPropertiesItem } = {};\n constructor(private _parentAppender: IPropertiesAppender, private _category: CategoryDescription) {}\n public append(label: string, item: ElementPropertiesItem): void {\n this._items[label] = item;\n }\n public finish(): void {\n if (Object.keys(this._items).length === 0) {\n return;\n }\n\n this._parentAppender.append(this._category.label, {\n type: \"category\",\n items: this._items,\n });\n }\n}\n\nclass ArrayItemAppender implements IPropertiesAppender {\n private _items: ElementPropertiesPropertyItem[] = [];\n constructor(private _parentAppender: IPropertiesAppender, private _props: StartArrayProps) {}\n public append(_label: string, item: ElementPropertiesItem): void {\n assert(item.type !== \"category\");\n this._items.push(item);\n }\n public finish(): void {\n assert(this._props.valueType.valueFormat === PropertyValueFormat.Array);\n if (this._props.valueType.memberType.valueFormat === PropertyValueFormat.Primitive) {\n this._parentAppender.append(this._props.hierarchy.field.label, this.createPrimitivesArray());\n } else {\n this._parentAppender.append(this._props.hierarchy.field.label, this.createStructsArray());\n }\n }\n private createPrimitivesArray(): ElementPropertiesPrimitiveArrayPropertyItem {\n return {\n type: \"array\",\n valueType: \"primitive\",\n values: this._items.map((item) => {\n assert(item.type === \"primitive\");\n return item.value;\n }),\n };\n }\n private createStructsArray(): ElementPropertiesStructArrayPropertyItem {\n return {\n type: \"array\",\n valueType: \"struct\",\n values: this._items.map((item) => {\n assert(item.type === \"struct\");\n return item.members;\n }),\n };\n }\n}\n\nclass StructItemAppender implements IPropertiesAppender {\n private _members: { [label: string]: ElementPropertiesPropertyItem } = {};\n constructor(private _parentAppender: IPropertiesAppender, private _props: StartStructProps) {}\n public append(label: string, item: ElementPropertiesItem): void {\n assert(item.type !== \"category\");\n this._members[label] = item;\n }\n public finish(): void {\n assert(this._props.valueType.valueFormat === PropertyValueFormat.Struct);\n this._parentAppender.append(this._props.hierarchy.field.label, {\n type: \"struct\",\n members: this._members,\n });\n }\n}\n\nclass ElementPropertiesBuilder implements IContentVisitor {\n private _appendersStack: IPropertiesAppender[] = [];\n private _items: ElementProperties[] = [];\n private _elementPropertiesAppender: ElementPropertiesAppender | undefined;\n\n public get items(): ElementProperties[] {\n return this._items;\n }\n\n private get _currentAppender(): IPropertiesAppender {\n const appender = this._appendersStack[this._appendersStack.length - 1];\n assert(appender !== undefined);\n return appender;\n }\n\n public startContent(_props: StartContentProps): boolean {\n return true;\n }\n public finishContent(): void {}\n\n public processFieldHierarchies(_props: ProcessFieldHierarchiesProps): void {}\n\n public startItem(props: StartItemProps): boolean {\n this._elementPropertiesAppender = new ElementPropertiesAppender(props.item, (item) => this._items.push(item));\n this._appendersStack.push(this._elementPropertiesAppender);\n return true;\n }\n public finishItem(): void {\n this._appendersStack.pop();\n assert(this._elementPropertiesAppender !== undefined);\n this._elementPropertiesAppender.finish();\n this._elementPropertiesAppender = undefined;\n }\n\n public startCategory(props: StartCategoryProps): boolean {\n assert(this._elementPropertiesAppender !== undefined);\n this._appendersStack.push(this._elementPropertiesAppender.getCategoryAppender(this._currentAppender, props.category));\n return true;\n }\n public finishCategory(): void {\n this._appendersStack.pop();\n }\n\n public startField(_props: StartFieldProps): boolean {\n return true;\n }\n public finishField(): void {}\n\n public startStruct(props: StartStructProps): boolean {\n this._appendersStack.push(new StructItemAppender(this._currentAppender, props));\n return true;\n }\n public finishStruct(): void {\n this._appendersStack.pop()!.finish();\n }\n\n public startArray(props: StartArrayProps): boolean {\n this._appendersStack.push(new ArrayItemAppender(this._currentAppender, props));\n return true;\n }\n public finishArray(): void {\n this._appendersStack.pop()!.finish();\n }\n\n public processMergedValue(props: ProcessMergedValueProps): void {\n this._currentAppender.append(props.mergedField.label, {\n type: \"primitive\",\n value: \"\",\n });\n }\n public processPrimitiveValue(props: ProcessPrimitiveValueProps): void {\n this._currentAppender.append(props.field.label, {\n type: \"primitive\",\n value: props.displayValue?.toString() ?? \"\",\n });\n }\n}\n"]}
|
|
@@ -17,6 +17,7 @@ export declare enum NativePlatformRequestTypes {
|
|
|
17
17
|
GetContentSources = "GetContentSources",
|
|
18
18
|
GetContentDescriptor = "GetContentDescriptor",
|
|
19
19
|
GetContentSetSize = "GetContentSetSize",
|
|
20
|
+
GetContentSet = "GetContentSet",
|
|
20
21
|
GetContent = "GetContent",
|
|
21
22
|
GetPagedDistinctValues = "GetPagedDistinctValues",
|
|
22
23
|
GetDisplayLabel = "GetDisplayLabel",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativePlatform.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/NativePlatform.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAc,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAU,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO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AC;IACnC,cAAc,CAAC,EAAE,oCAAoC,CAAC;IACtD,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC5B;AAED,gBAAgB;AAChB,qBAAa,uCAAwC,SAAQ,iBAAiB;IAC5E,SAAgB,WAAW,CAAC,EAAE,oBAAoB,CAAC;gBAChC,aAAa,EAAE,cAAc,CAAC,6BAA6B,CAAC,OAAO,CAAC;CAKxF;AAWD,gBAAgB;AAChB,eAAO,MAAM,2BAA2B,UAAW,0BAA0B,KAAG,UAAU,wBA+FzF,CAAC"}
|
|
@@ -25,6 +25,7 @@ var NativePlatformRequestTypes;
|
|
|
25
25
|
NativePlatformRequestTypes["GetContentSources"] = "GetContentSources";
|
|
26
26
|
NativePlatformRequestTypes["GetContentDescriptor"] = "GetContentDescriptor";
|
|
27
27
|
NativePlatformRequestTypes["GetContentSetSize"] = "GetContentSetSize";
|
|
28
|
+
NativePlatformRequestTypes["GetContentSet"] = "GetContentSet";
|
|
28
29
|
NativePlatformRequestTypes["GetContent"] = "GetContent";
|
|
29
30
|
NativePlatformRequestTypes["GetPagedDistinctValues"] = "GetPagedDistinctValues";
|
|
30
31
|
NativePlatformRequestTypes["GetDisplayLabel"] = "GetDisplayLabel";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativePlatform.js","sourceRoot":"","sources":["../../../src/presentation-backend/NativePlatform.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2E;AAC3E,sDAAmE;AAEnE,oEAEoC;AACpC,+DAA2D;AAE3D,gBAAgB;AAChB,IAAY,0BAeX;AAfD,WAAY,0BAA0B;IACpC,2DAA6B,CAAA;IAC7B,qEAAuC,CAAA;IACvC,yDAA2B,CAAA;IAC3B,mEAAqC,CAAA;IACrC,uEAAyC,CAAA;IACzC,2DAA6B,CAAA;IAC7B,2EAA6C,CAAA;IAC7C,qEAAuC,CAAA;IACvC,2EAA6C,CAAA;IAC7C,qEAAuC,CAA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AAuB,CAAC,SAAS,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;QAClH,CAAC;QACM,uBAAuB,CAAC,SAAiB,EAAE,UAAkB,EAAE,IAAwB,EAAE,KAAwB;YACtH,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,YAAY,CAAC,uBAAuB,CAAC,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;QAC9G,CAAC;QACM,yBAAyB,CAAC,SAAiB,EAAE,UAAkB;YACpE,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,YAAY,CAAC,yBAAyB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;QACnG,CAAC;QACM,aAAa;YAClB,OAAO,IAAI,CAAC,YAAY,CAAyB,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,CAAC,CAAC;QACtF,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AA/FW,QAAA,2BAA2B,+BA+FtC","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 { IModelDb, IModelHost, IModelJsNative } from \"@itwin/core-backend\";\r\nimport { assert, BeEvent, IDisposable } from \"@itwin/core-bentley\";\r\nimport { FormatProps } from \"@itwin/core-quantity\";\r\nimport {\r\n DiagnosticsScopeLogs, NodeKey, PresentationError, PresentationStatus, UpdateInfo, VariableValue, VariableValueJSON, VariableValueTypes,\r\n} from \"@itwin/presentation-common\";\r\nimport { HierarchyCacheMode } from \"./PresentationManager\";\r\n\r\n/** @internal */\r\nexport enum NativePlatformRequestTypes {\r\n GetRootNodes = \"GetRootNodes\",\r\n GetRootNodesCount = \"GetRootNodesCount\",\r\n GetChildren = \"GetChildren\",\r\n GetChildrenCount = \"GetChildrenCount\",\r\n GetNodesDescriptor = \"GetNodesDescriptor\",\r\n GetNodePaths = \"GetNodePaths\",\r\n GetFilteredNodePaths = \"GetFilteredNodePaths\",\r\n GetContentSources = \"GetContentSources\",\r\n GetContentDescriptor = \"GetContentDescriptor\",\r\n GetContentSetSize = \"GetContentSetSize\",\r\n GetContent = \"GetContent\",\r\n GetPagedDistinctValues = \"GetPagedDistinctValues\",\r\n GetDisplayLabel = \"GetDisplayLabel\",\r\n CompareHierarchies = \"CompareHierarchies\",\r\n}\r\n\r\n/**\r\n * Enumeration of unit systems supported by native presentation manager.\r\n * @internal\r\n */\r\nexport enum NativePresentationUnitSystem {\r\n Metric = \"metric\",\r\n BritishImperial = \"british-imperial\",\r\n UsCustomary = \"us-customary\",\r\n UsSurvey = \"us-survey\",\r\n}\r\n\r\n/** @internal */\r\nexport interface NativePresentationDefaultUnitFormats {\r\n [phenomenon: string]: Array<{\r\n unitSystems: NativePresentationUnitSystem[];\r\n format: FormatProps;\r\n }>;\r\n}\r\n\r\n/** @internal */\r\nexport interface NativePresentationKeySetJSON {\r\n instanceKeys: Array<[string, string[]]>;\r\n nodeKeys: NodeKey[];\r\n}\r\n\r\n/** @internal */\r\nexport interface NativePlatformResponse<TResult> {\r\n result: TResult;\r\n diagnostics?: DiagnosticsScopeLogs;\r\n}\r\n\r\n/** @internal */\r\nexport interface NativePlatformDefinition extends IDisposable {\r\n getImodelAddon(imodel: IModelDb): any;\r\n\r\n setupRulesetDirectories(directories: string[]): NativePlatformResponse<void>;\r\n setupSupplementalRulesetDirectories(directories: string[]): NativePlatformResponse<void>;\r\n\r\n forceLoadSchemas(db: any): Promise<NativePlatformResponse<void>>;\r\n\r\n registerSupplementalRuleset(serializedRulesetJson: string): NativePlatformResponse<string>;\r\n getRulesets(rulesetId: string): NativePlatformResponse<string>;\r\n addRuleset(serializedRulesetJson: string): NativePlatformResponse<string>;\r\n removeRuleset(rulesetId: string, hash: string): NativePlatformResponse<boolean>;\r\n clearRulesets(): NativePlatformResponse<void>;\r\n\r\n handleRequest(db: any, options: string, cancelEvent?: BeEvent<() => void>): Promise<NativePlatformResponse<string>>;\r\n\r\n getRulesetVariableValue(rulesetId: string, variableId: string, type: VariableValueTypes): NativePlatformResponse<VariableValue>;\r\n setRulesetVariableValue(rulesetId: string, variableId: string, type: VariableValueTypes, value: VariableValue): NativePlatformResponse<void>;\r\n unsetRulesetVariableValue(rulesetId: string, variableId: string): NativePlatformResponse<void>;\r\n\r\n getUpdateInfo(): NativePlatformResponse<UpdateInfo | undefined>;\r\n}\r\n\r\n/** @internal */\r\nexport interface DefaultNativePlatformProps {\r\n id: string;\r\n taskAllocationsMap: { [priority: number]: number };\r\n isChangeTrackingEnabled: boolean;\r\n cacheConfig?: IModelJsNative.ECPresentationHierarchyCacheConfig;\r\n contentCacheSize?: number;\r\n workerConnectionCacheSize?: number;\r\n defaultFormats?: NativePresentationDefaultUnitFormats;\r\n useMmap?: boolean | number;\r\n}\r\n\r\n/** @internal */\r\nexport class PresentationNativePlatformResponseError extends PresentationError {\r\n public readonly diagnostics?: DiagnosticsScopeLogs;\r\n public constructor(errorResponse: IModelJsNative.ECPresentationManagerResponse<unknown>) {\r\n assert(!!errorResponse.error);\r\n super(getPresentationStatusFromNativeResponseStatus(errorResponse.error.status), errorResponse.error.message);\r\n this.diagnostics = errorResponse.diagnostics;\r\n }\r\n}\r\n\r\nfunction getPresentationStatusFromNativeResponseStatus(nativeResponseStatus: IModelJsNative.ECPresentationStatus): PresentationStatus {\r\n switch (nativeResponseStatus) {\r\n case IModelJsNative.ECPresentationStatus.InvalidArgument: return PresentationStatus.InvalidArgument;\r\n case IModelJsNative.ECPresentationStatus.ResultSetTooLarge: return PresentationStatus.ResultSetTooLarge;\r\n case IModelJsNative.ECPresentationStatus.Canceled: return PresentationStatus.Canceled;\r\n }\r\n return PresentationStatus.Error;\r\n}\r\n\r\n/** @internal */\r\nexport const createDefaultNativePlatform = (props: DefaultNativePlatformProps): new () => NativePlatformDefinition => {\r\n // note the implementation is constructed here to make PresentationManager\r\n // usable without loading the actual addon (if addon is set to something other)\r\n return class implements NativePlatformDefinition {\r\n private _nativeAddon: IModelJsNative.ECPresentationManager;\r\n public constructor() {\r\n const cacheConfig = props.cacheConfig ?? { mode: HierarchyCacheMode.Disk, directory: \"\" };\r\n const defaultFormats = props.defaultFormats ? this.getSerializedDefaultFormatsMap(props.defaultFormats) : {};\r\n this._nativeAddon = new IModelHost.platform.ECPresentationManager({ ...props, cacheConfig, defaultFormats });\r\n }\r\n private getSerializedDefaultFormatsMap(defaultMap: NativePresentationDefaultUnitFormats) {\r\n const res: {\r\n [phenomenon: string]: Array<{\r\n unitSystems: string[];\r\n serializedFormat: string;\r\n }>;\r\n } = {};\r\n Object.entries(defaultMap).forEach(([phenomenon, formats]) => {\r\n res[phenomenon] = formats.map((value) => ({ unitSystems: value.unitSystems, serializedFormat: JSON.stringify(value.format) }));\r\n });\r\n return res;\r\n }\r\n private createSuccessResponse<T>(response: IModelJsNative.ECPresentationManagerResponse<T>): NativePlatformResponse<T> {\r\n const retValue: NativePlatformResponse<T> = { result: response.result! };\r\n if (response.diagnostics)\r\n retValue.diagnostics = response.diagnostics;\r\n return retValue;\r\n }\r\n private handleResult<T>(response: IModelJsNative.ECPresentationManagerResponse<T>): NativePlatformResponse<T> {\r\n if (response.error)\r\n throw new PresentationNativePlatformResponseError(response);\r\n return this.createSuccessResponse(response);\r\n }\r\n private handleConvertedResult<TSource, TTarget>(response: IModelJsNative.ECPresentationManagerResponse<TSource>, conv: (s: TSource) => TTarget): NativePlatformResponse<TTarget> {\r\n return this.handleResult<TTarget>((response.result ? { ...response, result: conv(response.result) } : response) as IModelJsNative.ECPresentationManagerResponse<TTarget>);\r\n }\r\n private handleVoidResult(response: IModelJsNative.ECPresentationManagerResponse<void>): NativePlatformResponse<void> {\r\n if (response.error)\r\n throw new PresentationNativePlatformResponseError(response);\r\n return this.createSuccessResponse(response);\r\n }\r\n public dispose() {\r\n this._nativeAddon.dispose();\r\n }\r\n public async forceLoadSchemas(db: any): Promise<NativePlatformResponse<void>> {\r\n const response = await this._nativeAddon.forceLoadSchemas(db);\r\n if (response.error)\r\n throw new PresentationError(PresentationStatus.Error, response.error.message);\r\n return this.createSuccessResponse(response);\r\n }\r\n public setupRulesetDirectories(directories: string[]) {\r\n return this.handleVoidResult(this._nativeAddon.setupRulesetDirectories(directories));\r\n }\r\n public setupSupplementalRulesetDirectories(directories: string[]) {\r\n return this.handleVoidResult(this._nativeAddon.setupSupplementalRulesetDirectories(directories));\r\n }\r\n public getImodelAddon(imodel: IModelDb): any {\r\n if (!imodel.isOpen)\r\n throw new PresentationError(PresentationStatus.InvalidArgument, \"imodel\");\r\n return imodel.nativeDb;\r\n }\r\n public registerSupplementalRuleset(serializedRulesetJson: string) {\r\n return this.handleResult<string>(this._nativeAddon.registerSupplementalRuleset(serializedRulesetJson));\r\n }\r\n public getRulesets(rulesetId: string) {\r\n return this.handleResult<string>(this._nativeAddon.getRulesets(rulesetId));\r\n }\r\n public addRuleset(serializedRulesetJson: string) {\r\n return this.handleResult<string>(this._nativeAddon.addRuleset(serializedRulesetJson));\r\n }\r\n public removeRuleset(rulesetId: string, hash: string) {\r\n return this.handleResult<boolean>(this._nativeAddon.removeRuleset(rulesetId, hash));\r\n }\r\n public clearRulesets() {\r\n return this.handleVoidResult(this._nativeAddon.clearRulesets());\r\n }\r\n public async handleRequest(db: any, options: string, cancelEvent?: BeEvent<() => void>) {\r\n const response = this._nativeAddon.handleRequest(db, options);\r\n cancelEvent?.addOnce(() => response.cancel());\r\n const result = await response.result;\r\n return this.handleConvertedResult<Buffer, string>(result, (buffer) => buffer.toString());\r\n }\r\n public getRulesetVariableValue(rulesetId: string, variableId: string, type: VariableValueTypes) {\r\n return this.handleResult<VariableValue>(this._nativeAddon.getRulesetVariableValue(rulesetId, variableId, type));\r\n }\r\n public setRulesetVariableValue(rulesetId: string, variableId: string, type: VariableValueTypes, value: VariableValueJSON) {\r\n return this.handleVoidResult(this._nativeAddon.setRulesetVariableValue(rulesetId, variableId, type, value));\r\n }\r\n public unsetRulesetVariableValue(rulesetId: string, variableId: string) {\r\n return this.handleVoidResult(this._nativeAddon.unsetRulesetVariableValue(rulesetId, variableId));\r\n }\r\n public getUpdateInfo() {\r\n return this.handleResult<UpdateInfo | undefined>(this._nativeAddon.getUpdateInfo());\r\n }\r\n };\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"NativePlatform.js","sourceRoot":"","sources":["../../../src/presentation-backend/NativePlatform.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2E;AAC3E,sDAAmE;AAEnE,oEAEoC;AACpC,+DAA2D;AAE3D,gBAAgB;AAChB,IAAY,0BAgBX;AAhBD,WAAY,0BAA0B;IACpC,2DAA6B,CAAA;IAC7B,qEAAuC,CAAA;IACvC,yDAA2B,CAAA;IAC3B,mEAAqC,CAAA;IACrC,uEAAyC,CAAA;IACzC,2DAA6B,CAAA;IAC7B,2EAA6C,CAAA;IAC7C,qEAAuC,CAAA;IACvC,2EAA6C,CAAA;IAC7C,qEAAuC,CAAA;IACvC,6DAA+B,CAAA;IAC/B,uDAAyB,CAAA;IACzB,+EAAiD,CAAA;IACjD,iEAAmC,CAAA;IACnC,uEAAyC,CAAA;AAC3C,CAAC,EAhBW,0BAA0B,GAA1B,kCAA0B,KAA1B,kCAA0B,QAgBrC;AAED;;;GAGG;AACH,IAAY,4BAKX;AALD,WAAY,4BAA4B;IACtC,iDAAiB,CAAA;IACjB,oEAAoC,CAAA;IACpC,4DAA4B,CAAA;IAC5B,sDAAsB,CAAA;AACxB,CAAC,EALW,4BAA4B,GAA5B,oCAA4B,KAA5B,oCAA4B,QAKvC;AA0DD,gBAAgB;AAChB,MAAa,uCAAwC,SAAQ,uCAAiB;IAE5E,YAAmB,aAAoE;QACrF,IAAA,qBAAM,EAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC9B,KAAK,CAAC,6CAA6C,CAAC,a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AC,aAAa,EAAE,CAAC,CAAC;QACtF,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AA/FW,QAAA,2BAA2B,+BA+FtC","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 Core\n */\n\nimport { IModelDb, IModelHost, IModelJsNative } from \"@itwin/core-backend\";\nimport { assert, BeEvent, IDisposable } from \"@itwin/core-bentley\";\nimport { FormatProps } from \"@itwin/core-quantity\";\nimport {\n DiagnosticsScopeLogs, NodeKey, PresentationError, PresentationStatus, UpdateInfo, VariableValue, VariableValueJSON, VariableValueTypes,\n} from \"@itwin/presentation-common\";\nimport { HierarchyCacheMode } from \"./PresentationManager\";\n\n/** @internal */\nexport enum NativePlatformRequestTypes {\n GetRootNodes = \"GetRootNodes\",\n GetRootNodesCount = \"GetRootNodesCount\",\n GetChildren = \"GetChildren\",\n GetChildrenCount = \"GetChildrenCount\",\n GetNodesDescriptor = \"GetNodesDescriptor\",\n GetNodePaths = \"GetNodePaths\",\n GetFilteredNodePaths = \"GetFilteredNodePaths\",\n GetContentSources = \"GetContentSources\",\n GetContentDescriptor = \"GetContentDescriptor\",\n GetContentSetSize = \"GetContentSetSize\",\n GetContentSet = \"GetContentSet\",\n GetContent = \"GetContent\",\n GetPagedDistinctValues = \"GetPagedDistinctValues\",\n GetDisplayLabel = \"GetDisplayLabel\",\n CompareHierarchies = \"CompareHierarchies\",\n}\n\n/**\n * Enumeration of unit systems supported by native presentation manager.\n * @internal\n */\nexport enum NativePresentationUnitSystem {\n Metric = \"metric\",\n BritishImperial = \"british-imperial\",\n UsCustomary = \"us-customary\",\n UsSurvey = \"us-survey\",\n}\n\n/** @internal */\nexport interface NativePresentationDefaultUnitFormats {\n [phenomenon: string]: Array<{\n unitSystems: NativePresentationUnitSystem[];\n format: FormatProps;\n }>;\n}\n\n/** @internal */\nexport interface NativePresentationKeySetJSON {\n instanceKeys: Array<[string, string[]]>;\n nodeKeys: NodeKey[];\n}\n\n/** @internal */\nexport interface NativePlatformResponse<TResult> {\n result: TResult;\n diagnostics?: DiagnosticsScopeLogs;\n}\n\n/** @internal */\nexport interface NativePlatformDefinition extends IDisposable {\n getImodelAddon(imodel: IModelDb): any;\n\n setupRulesetDirectories(directories: string[]): NativePlatformResponse<void>;\n setupSupplementalRulesetDirectories(directories: string[]): NativePlatformResponse<void>;\n\n forceLoadSchemas(db: any): Promise<NativePlatformResponse<void>>;\n\n registerSupplementalRuleset(serializedRulesetJson: string): NativePlatformResponse<string>;\n getRulesets(rulesetId: string): NativePlatformResponse<string>;\n addRuleset(serializedRulesetJson: string): NativePlatformResponse<string>;\n removeRuleset(rulesetId: string, hash: string): NativePlatformResponse<boolean>;\n clearRulesets(): NativePlatformResponse<void>;\n\n handleRequest(db: any, options: string, cancelEvent?: BeEvent<() => void>): Promise<NativePlatformResponse<string>>;\n\n getRulesetVariableValue(rulesetId: string, variableId: string, type: VariableValueTypes): NativePlatformResponse<VariableValue>;\n setRulesetVariableValue(rulesetId: string, variableId: string, type: VariableValueTypes, value: VariableValue): NativePlatformResponse<void>;\n unsetRulesetVariableValue(rulesetId: string, variableId: string): NativePlatformResponse<void>;\n\n getUpdateInfo(): NativePlatformResponse<UpdateInfo | undefined>;\n}\n\n/** @internal */\nexport interface DefaultNativePlatformProps {\n id: string;\n taskAllocationsMap: { [priority: number]: number };\n isChangeTrackingEnabled: boolean;\n cacheConfig?: IModelJsNative.ECPresentationHierarchyCacheConfig;\n contentCacheSize?: number;\n workerConnectionCacheSize?: number;\n defaultFormats?: NativePresentationDefaultUnitFormats;\n useMmap?: boolean | number;\n}\n\n/** @internal */\nexport class PresentationNativePlatformResponseError extends PresentationError {\n public readonly diagnostics?: DiagnosticsScopeLogs;\n public constructor(errorResponse: IModelJsNative.ECPresentationManagerResponse<unknown>) {\n assert(!!errorResponse.error);\n super(getPresentationStatusFromNativeResponseStatus(errorResponse.error.status), errorResponse.error.message);\n this.diagnostics = errorResponse.diagnostics;\n }\n}\n\nfunction getPresentationStatusFromNativeResponseStatus(nativeResponseStatus: IModelJsNative.ECPresentationStatus): PresentationStatus {\n switch (nativeResponseStatus) {\n case IModelJsNative.ECPresentationStatus.InvalidArgument: return PresentationStatus.InvalidArgument;\n case IModelJsNative.ECPresentationStatus.ResultSetTooLarge: return PresentationStatus.ResultSetTooLarge;\n case IModelJsNative.ECPresentationStatus.Canceled: return PresentationStatus.Canceled;\n }\n return PresentationStatus.Error;\n}\n\n/** @internal */\nexport const createDefaultNativePlatform = (props: DefaultNativePlatformProps): new () => NativePlatformDefinition => {\n // note the implementation is constructed here to make PresentationManager\n // usable without loading the actual addon (if addon is set to something other)\n return class implements NativePlatformDefinition {\n private _nativeAddon: IModelJsNative.ECPresentationManager;\n public constructor() {\n const cacheConfig = props.cacheConfig ?? { mode: HierarchyCacheMode.Disk, directory: \"\" };\n const defaultFormats = props.defaultFormats ? this.getSerializedDefaultFormatsMap(props.defaultFormats) : {};\n this._nativeAddon = new IModelHost.platform.ECPresentationManager({ ...props, cacheConfig, defaultFormats });\n }\n private getSerializedDefaultFormatsMap(defaultMap: NativePresentationDefaultUnitFormats) {\n const res: {\n [phenomenon: string]: Array<{\n unitSystems: string[];\n serializedFormat: string;\n }>;\n } = {};\n Object.entries(defaultMap).forEach(([phenomenon, formats]) => {\n res[phenomenon] = formats.map((value) => ({ unitSystems: value.unitSystems, serializedFormat: JSON.stringify(value.format) }));\n });\n return res;\n }\n private createSuccessResponse<T>(response: IModelJsNative.ECPresentationManagerResponse<T>): NativePlatformResponse<T> {\n const retValue: NativePlatformResponse<T> = { result: response.result! };\n if (response.diagnostics)\n retValue.diagnostics = response.diagnostics;\n return retValue;\n }\n private handleResult<T>(response: IModelJsNative.ECPresentationManagerResponse<T>): NativePlatformResponse<T> {\n if (response.error)\n throw new PresentationNativePlatformResponseError(response);\n return this.createSuccessResponse(response);\n }\n private handleConvertedResult<TSource, TTarget>(response: IModelJsNative.ECPresentationManagerResponse<TSource>, conv: (s: TSource) => TTarget): NativePlatformResponse<TTarget> {\n return this.handleResult<TTarget>((response.result ? { ...response, result: conv(response.result) } : response) as IModelJsNative.ECPresentationManagerResponse<TTarget>);\n }\n private handleVoidResult(response: IModelJsNative.ECPresentationManagerResponse<void>): NativePlatformResponse<void> {\n if (response.error)\n throw new PresentationNativePlatformResponseError(response);\n return this.createSuccessResponse(response);\n }\n public dispose() {\n this._nativeAddon.dispose();\n }\n public async forceLoadSchemas(db: any): Promise<NativePlatformResponse<void>> {\n const response = await this._nativeAddon.forceLoadSchemas(db);\n if (response.error)\n throw new PresentationError(PresentationStatus.Error, response.error.message);\n return this.createSuccessResponse(response);\n }\n public setupRulesetDirectories(directories: string[]) {\n return this.handleVoidResult(this._nativeAddon.setupRulesetDirectories(directories));\n }\n public setupSupplementalRulesetDirectories(directories: string[]) {\n return this.handleVoidResult(this._nativeAddon.setupSupplementalRulesetDirectories(directories));\n }\n public getImodelAddon(imodel: IModelDb): any {\n if (!imodel.isOpen)\n throw new PresentationError(PresentationStatus.InvalidArgument, \"imodel\");\n return imodel.nativeDb;\n }\n public registerSupplementalRuleset(serializedRulesetJson: string) {\n return this.handleResult<string>(this._nativeAddon.registerSupplementalRuleset(serializedRulesetJson));\n }\n public getRulesets(rulesetId: string) {\n return this.handleResult<string>(this._nativeAddon.getRulesets(rulesetId));\n }\n public addRuleset(serializedRulesetJson: string) {\n return this.handleResult<string>(this._nativeAddon.addRuleset(serializedRulesetJson));\n }\n public removeRuleset(rulesetId: string, hash: string) {\n return this.handleResult<boolean>(this._nativeAddon.removeRuleset(rulesetId, hash));\n }\n public clearRulesets() {\n return this.handleVoidResult(this._nativeAddon.clearRulesets());\n }\n public async handleRequest(db: any, options: string, cancelEvent?: BeEvent<() => void>) {\n const response = this._nativeAddon.handleRequest(db, options);\n cancelEvent?.addOnce(() => response.cancel());\n const result = await response.result;\n return this.handleConvertedResult<Buffer, string>(result, (buffer) => buffer.toString());\n }\n public getRulesetVariableValue(rulesetId: string, variableId: string, type: VariableValueTypes) {\n return this.handleResult<VariableValue>(this._nativeAddon.getRulesetVariableValue(rulesetId, variableId, type));\n }\n public setRulesetVariableValue(rulesetId: string, variableId: string, type: VariableValueTypes, value: VariableValueJSON) {\n return this.handleVoidResult(this._nativeAddon.setRulesetVariableValue(rulesetId, variableId, type, value));\n }\n public unsetRulesetVariableValue(rulesetId: string, variableId: string) {\n return this.handleVoidResult(this._nativeAddon.unsetRulesetVariableValue(rulesetId, variableId));\n }\n public getUpdateInfo() {\n return this.handleResult<UpdateInfo | undefined>(this._nativeAddon.getUpdateInfo());\n }\n };\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Presentation.js","sourceRoot":"","sources":["../../../src/presentation-backend/Presentation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;AAEH,sDAAuE;AACvE,sDAA0D;AAC1D,oDAAgD;AAChD,oEAA6G;AAC7G,mEAA4E;AAC5E,qEAAkE;AAClE,+DAAsF;AACtF,+DAA4D;AAC5D,yDAAkE;AAgElE;;;;;;;;;GASG;AACH,MAAa,YAAY;IAUvB,0BAA0B;IAC1B,gBAAwB,CAAC;IAEzB,+DAA+D;IACxD,MAAM,KAAK,SAAS,KAAK,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAEzD;;;;;;;;OAQG;IACI,MAAM,CAAC,UAAU,CAAC,KAAyB;QAChD,IAAI,CAAC,UAAU,GAAG,KAAK,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,iBAAiB,GAAG,yBAAU,CAAC,gBAAgB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC;QAEjG,IAAI,CAAC,QAAQ,GAAG,IAAI,yCAAmB,CAAC;YACtC,cAAc,EAAE,IAAI,CAAC,UAAU,CAAC,cAAc;SAC/C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UAAU,EAAE,CAAC;IAClC,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACvE,mEAAmE;IACnE,OAAO,CAAC,iBAAiB,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;AAC5D,CAAC,AAL4B,CAK3B;AApIS,oCAAY;AAuIzB,SAAS,oBAAoB,CAAC,KAAwB;IACpD,OAAO,CAAC,CAAE,KAAwC,CAAC,gBAAgB,CAAC;AACtE,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 { BriefcaseDb, IModelHost, IpcHost } from \"@itwin/core-backend\";\r\nimport { DisposeFunc, Logger } from \"@itwin/core-bentley\";\r\nimport { RpcManager } from \"@itwin/core-common\";\r\nimport { PresentationError, PresentationRpcInterface, PresentationStatus } from \"@itwin/presentation-common\";\r\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { PresentationIpcHandler } from \"./PresentationIpcHandler\";\r\nimport { PresentationManager, PresentationManagerProps } from \"./PresentationManager\";\r\nimport { PresentationRpcImpl } from \"./PresentationRpcImpl\";\r\nimport { FactoryBasedTemporaryStorage } from \"./TemporaryStorage\";\r\n\r\n/**\r\n * Base props for initializing the [[Presentation]] library.\r\n *\r\n * @public\r\n */\r\nexport interface PresentationPropsBase extends PresentationManagerProps {\r\n /**\r\n * Time in milliseconds after which the request will timeout.\r\n */\r\n requestTimeout?: number;\r\n\r\n /**\r\n * Should schemas preloading be enabled. If true, [[Presentation]] library listens\r\n * for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.\r\n */\r\n enableSchemasPreload?: boolean;\r\n}\r\n\r\n/**\r\n * Props for initializing the [[Presentation]] library for using multiple [[PresentationManager]]\r\n * instances, one for each frontend.\r\n *\r\n * @public\r\n */\r\nexport interface MultiManagerPresentationProps extends PresentationPropsBase {\r\n /**\r\n * Factory method for creating separate managers for each client\r\n * @internal\r\n */\r\n clientManagerFactory?: (clientId: string, props: PresentationManagerProps) => PresentationManager;\r\n\r\n /**\r\n * How much time should an unused client manager be stored in memory\r\n * before it's disposed.\r\n */\r\n unusedClientLifetime?: number;\r\n}\r\n\r\n/**\r\n * Props for initializing the [[Presentation]] library with ability to use a single\r\n * [[PresentationManager]] instance for handling all requests.\r\n *\r\n * @public\r\n */\r\nexport interface SingleManagerPresentationProps extends PresentationPropsBase {\r\n /**\r\n * Specifies to use single manager for all clients.\r\n * @alpha\r\n */\r\n useSingleManager?: boolean;\r\n}\r\n\r\n/**\r\n * Properties that can be used to configure [[Presentation]] API\r\n * @public\r\n */\r\nexport type PresentationProps = MultiManagerPresentationProps | SingleManagerPresentationProps;\r\n\r\ninterface ClientStoreItem {\r\n manager: PresentationManager;\r\n}\r\n\r\n/**\r\n * Static class used to statically set up Presentation library for the backend.\r\n * Basically what it does is:\r\n * - Register a RPC implementation\r\n * - Create a singleton [[PresentationManager]] instance\r\n * - Subscribe for [IModelHost.onBeforeShutdown]($core-backend) event and terminate\r\n * the presentation manager when that happens.\r\n *\r\n * @public\r\n */\r\nexport class Presentation {\r\n\r\n private static _initProps: PresentationProps | undefined;\r\n private static _clientsStorage: FactoryBasedTemporaryStorage<ClientStoreItem> | undefined;\r\n private static _disposeIpcHandler: DisposeFunc | undefined;\r\n private static _shutdownListener: DisposeFunc | undefined;\r\n private static _disposeIModelOpenedListener: DisposeFunc | undefined;\r\n private static _manager: PresentationManager | undefined;\r\n private static _rpcImpl: PresentationRpcImpl | undefined;\r\n\r\n /* istanbul ignore next */\r\n private constructor() { }\r\n\r\n /** Properties used to initialize the presentation framework */\r\n public static get initProps() { return this._initProps; }\r\n\r\n /**\r\n * Initializes Presentation library for the backend.\r\n *\r\n * See [Setting up iTwin.js Presentation library documentation page]($docs/presentation/setup/index.md#backend) for an example.\r\n *\r\n * **Important:** The method should be called after a call to [IModelHost.startup]($core-backend)\r\n *\r\n * @param props Optional properties for [[PresentationManager]]\r\n */\r\n public static initialize(props?: PresentationProps): void {\r\n this._initProps = props || {};\r\n this._shutdownListener = IModelHost.onBeforeShutdown.addListener(() => Presentation.terminate());\r\n\r\n this._rpcImpl = new PresentationRpcImpl({\r\n requestTimeout: this._initProps.requestTimeout,\r\n });\r\n RpcManager.registerImpl(PresentationRpcInterface, PresentationRpcImpl);\r\n RpcManager.supplyImplInstance(PresentationRpcInterface, this._rpcImpl);\r\n\r\n if (IpcHost.isValid) {\r\n this._disposeIpcHandler = PresentationIpcHandler.register();\r\n }\r\n\r\n if (isSingleManagerProps(this._initProps)) {\r\n this._manager = new PresentationManager(Presentation._initProps);\r\n } else {\r\n this._clientsStorage = new FactoryBasedTemporaryStorage<ClientStoreItem>({\r\n factory: this.createClientManager.bind(this),\r\n cleanupHandler: (_id, storeItem) => this.disposeClientManager(_id, storeItem),\r\n // cleanup unused managers every minute\r\n cleanupInterval: 60 * 1000,\r\n // by default, manager is disposed after 1 hour of being unused\r\n unusedValueLifetime: this._initProps.unusedClientLifetime ?? 60 * 60 * 1000,\r\n // add some logging\r\n onDisposedSingle: /* istanbul ignore next */(id: string) => Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Disposed PresentationManager instance with ID: ${id}. Total instances: ${this._clientsStorage!.values.length}.`),\r\n onDisposedAll: /* istanbul ignore next */() => Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Disposed all PresentationManager instances.`),\r\n });\r\n }\r\n\r\n if (this._initProps.enableSchemasPreload)\r\n this._disposeIModelOpenedListener = BriefcaseDb.onOpened.addListener(this.onIModelOpened);\r\n }\r\n\r\n /**\r\n * Terminates Presentation. Consumers don't need to call this as it's automatically\r\n * called on [IModelHost.onBeforeShutdown]($core-backend) event.\r\n */\r\n public static terminate(): void {\r\n if (this._clientsStorage) {\r\n this._clientsStorage.dispose();\r\n this._clientsStorage = undefined;\r\n }\r\n if (this._disposeIModelOpenedListener) {\r\n this._disposeIModelOpenedListener();\r\n this._disposeIModelOpenedListener = undefined;\r\n }\r\n if (this._shutdownListener) {\r\n this._shutdownListener();\r\n this._shutdownListener = undefined;\r\n }\r\n if (this._manager) {\r\n this._manager.dispose();\r\n this._manager = undefined;\r\n }\r\n RpcManager.unregisterImpl(PresentationRpcInterface);\r\n if (this._rpcImpl) {\r\n this._rpcImpl.dispose();\r\n this._rpcImpl = undefined;\r\n }\r\n if (this._disposeIpcHandler) {\r\n this._disposeIpcHandler();\r\n }\r\n this._initProps = undefined;\r\n }\r\n\r\n private static createClientManager(clientId: string, onManagerUsed: () => void): ClientStoreItem {\r\n const manager = (Presentation._initProps && !isSingleManagerProps(Presentation._initProps) && Presentation._initProps.clientManagerFactory)\r\n ? Presentation._initProps.clientManagerFactory(clientId, Presentation._initProps)\r\n : new PresentationManager({ ...Presentation._initProps, id: clientId });\r\n manager.setOnManagerUsedHandler(onManagerUsed);\r\n Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Created a PresentationManager instance with ID: ${clientId}. Total instances: ${this._clientsStorage!.values.length}.`);\r\n return { manager };\r\n }\r\n\r\n private static disposeClientManager(_id: string, storeItem: ClientStoreItem) {\r\n storeItem.manager.dispose();\r\n }\r\n\r\n /**\r\n * Get an instance of [[PresentationManager]] for specific client\r\n * @param clientId ID of the client requesting presentation data. If no\r\n * ID is provided, the default [[PresentationManager]] is returned.\r\n */\r\n public static getManager(clientId?: string): PresentationManager {\r\n if (this._initProps && isSingleManagerProps(this._initProps) && this._manager)\r\n return this._manager;\r\n if (this._clientsStorage)\r\n return this._clientsStorage.getValue(clientId || \"\").manager;\r\n\r\n throw new PresentationError(PresentationStatus.NotInitialized, \"Presentation must be first initialized by calling Presentation.initialize\");\r\n }\r\n\r\n /**\r\n * Get the time in milliseconds that backend should respond in .\r\n */\r\n public static getRequestTimeout(): number {\r\n if (this._rpcImpl === undefined)\r\n throw new PresentationError(PresentationStatus.NotInitialized, \"Presentation must be first initialized by calling Presentation.initialize\");\r\n return this._rpcImpl.requestTimeout;\r\n }\r\n\r\n private static onIModelOpened = (imodel: BriefcaseDb) => {\r\n const manager = this.getManager();\r\n const imodelAddon = manager.getNativePlatform().getImodelAddon(imodel);\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n manager.getNativePlatform().forceLoadSchemas(imodelAddon);\r\n };\r\n}\r\n\r\nfunction isSingleManagerProps(props: PresentationProps): props is SingleManagerPresentationProps {\r\n return !!(props as SingleManagerPresentationProps).useSingleManager;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Presentation.js","sourceRoot":"","sources":["../../../src/presentation-backend/Presentation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;AAEH,sDAAuE;AACvE,sDAA0D;AAC1D,oDAAgD;AAChD,oEAA6G;AAC7G,mEAA4E;AAC5E,qEAAkE;AAClE,+DAAsF;AACtF,+DAA4D;AAC5D,yDAAkE;AAgElE;;;;;;;;;GASG;AACH,MAAa,YAAY;IAUvB,0BAA0B;IAC1B,gBAAwB,CAAC;IAEzB,+DAA+D;IACxD,MAAM,KAAK,SAAS,KAAK,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAEzD;;;;;;;;OAQG;IACI,MAAM,CAAC,UAAU,CAAC,KAAyB;QAChD,IAAI,CAAC,UAAU,GAAG,KAAK,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,iBAAiB,GAAG,yBAAU,CAAC,gBAAgB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC;QAEjG,IAAI,CAAC,QAAQ,GAAG,IAAI,yCAAmB,CAAC;YACtC,cAAc,EAAE,IAAI,CAAC,UAAU,CAAC,cAAc;SAC/C,CAAC,CAAC;QACH,wBAAU,CAAC,YAAY,CAAC,8CAAwB,EAAE,yCAAmB,CAAC,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C,cAAc,CAAC,MAAM,CAAC,CAAC;IACvE,mEAAmE;IACnE,OAAO,CAAC,iBAAiB,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;AAC5D,CAAC,AAL4B,CAK3B;AApIS,oCAAY;AAuIzB,SAAS,oBAAoB,CAAC,KAAwB;IACpD,OAAO,CAAC,CAAE,KAAwC,CAAC,gBAAgB,CAAC;AACtE,CAAC","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 Core\n */\n\nimport { BriefcaseDb, IModelHost, IpcHost } from \"@itwin/core-backend\";\nimport { DisposeFunc, Logger } from \"@itwin/core-bentley\";\nimport { RpcManager } from \"@itwin/core-common\";\nimport { PresentationError, PresentationRpcInterface, PresentationStatus } from \"@itwin/presentation-common\";\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { PresentationIpcHandler } from \"./PresentationIpcHandler\";\nimport { PresentationManager, PresentationManagerProps } from \"./PresentationManager\";\nimport { PresentationRpcImpl } from \"./PresentationRpcImpl\";\nimport { FactoryBasedTemporaryStorage } from \"./TemporaryStorage\";\n\n/**\n * Base props for initializing the [[Presentation]] library.\n *\n * @public\n */\nexport interface PresentationPropsBase extends PresentationManagerProps {\n /**\n * Time in milliseconds after which the request will timeout.\n */\n requestTimeout?: number;\n\n /**\n * Should schemas preloading be enabled. If true, [[Presentation]] library listens\n * for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.\n */\n enableSchemasPreload?: boolean;\n}\n\n/**\n * Props for initializing the [[Presentation]] library for using multiple [[PresentationManager]]\n * instances, one for each frontend.\n *\n * @public\n */\nexport interface MultiManagerPresentationProps extends PresentationPropsBase {\n /**\n * Factory method for creating separate managers for each client\n * @internal\n */\n clientManagerFactory?: (clientId: string, props: PresentationManagerProps) => PresentationManager;\n\n /**\n * How much time should an unused client manager be stored in memory\n * before it's disposed.\n */\n unusedClientLifetime?: number;\n}\n\n/**\n * Props for initializing the [[Presentation]] library with ability to use a single\n * [[PresentationManager]] instance for handling all requests.\n *\n * @public\n */\nexport interface SingleManagerPresentationProps extends PresentationPropsBase {\n /**\n * Specifies to use single manager for all clients.\n * @alpha\n */\n useSingleManager?: boolean;\n}\n\n/**\n * Properties that can be used to configure [[Presentation]] API\n * @public\n */\nexport type PresentationProps = MultiManagerPresentationProps | SingleManagerPresentationProps;\n\ninterface ClientStoreItem {\n manager: PresentationManager;\n}\n\n/**\n * Static class used to statically set up Presentation library for the backend.\n * Basically what it does is:\n * - Register a RPC implementation\n * - Create a singleton [[PresentationManager]] instance\n * - Subscribe for [IModelHost.onBeforeShutdown]($core-backend) event and terminate\n * the presentation manager when that happens.\n *\n * @public\n */\nexport class Presentation {\n\n private static _initProps: PresentationProps | undefined;\n private static _clientsStorage: FactoryBasedTemporaryStorage<ClientStoreItem> | undefined;\n private static _disposeIpcHandler: DisposeFunc | undefined;\n private static _shutdownListener: DisposeFunc | undefined;\n private static _disposeIModelOpenedListener: DisposeFunc | undefined;\n private static _manager: PresentationManager | undefined;\n private static _rpcImpl: PresentationRpcImpl | undefined;\n\n /* istanbul ignore next */\n private constructor() { }\n\n /** Properties used to initialize the presentation framework */\n public static get initProps() { return this._initProps; }\n\n /**\n * Initializes Presentation library for the backend.\n *\n * See [Setting up iTwin.js Presentation library documentation page]($docs/presentation/setup/index.md#backend) for an example.\n *\n * **Important:** The method should be called after a call to [IModelHost.startup]($core-backend)\n *\n * @param props Optional properties for [[PresentationManager]]\n */\n public static initialize(props?: PresentationProps): void {\n this._initProps = props || {};\n this._shutdownListener = IModelHost.onBeforeShutdown.addListener(() => Presentation.terminate());\n\n this._rpcImpl = new PresentationRpcImpl({\n requestTimeout: this._initProps.requestTimeout,\n });\n RpcManager.registerImpl(PresentationRpcInterface, PresentationRpcImpl);\n RpcManager.supplyImplInstance(PresentationRpcInterface, this._rpcImpl);\n\n if (IpcHost.isValid) {\n this._disposeIpcHandler = PresentationIpcHandler.register();\n }\n\n if (isSingleManagerProps(this._initProps)) {\n this._manager = new PresentationManager(Presentation._initProps);\n } else {\n this._clientsStorage = new FactoryBasedTemporaryStorage<ClientStoreItem>({\n factory: this.createClientManager.bind(this),\n cleanupHandler: (_id, storeItem) => this.disposeClientManager(_id, storeItem),\n // cleanup unused managers every minute\n cleanupInterval: 60 * 1000,\n // by default, manager is disposed after 1 hour of being unused\n unusedValueLifetime: this._initProps.unusedClientLifetime ?? 60 * 60 * 1000,\n // add some logging\n onDisposedSingle: /* istanbul ignore next */(id: string) => Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Disposed PresentationManager instance with ID: ${id}. Total instances: ${this._clientsStorage!.values.length}.`),\n onDisposedAll: /* istanbul ignore next */() => Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Disposed all PresentationManager instances.`),\n });\n }\n\n if (this._initProps.enableSchemasPreload)\n this._disposeIModelOpenedListener = BriefcaseDb.onOpened.addListener(this.onIModelOpened);\n }\n\n /**\n * Terminates Presentation. Consumers don't need to call this as it's automatically\n * called on [IModelHost.onBeforeShutdown]($core-backend) event.\n */\n public static terminate(): void {\n if (this._clientsStorage) {\n this._clientsStorage.dispose();\n this._clientsStorage = undefined;\n }\n if (this._disposeIModelOpenedListener) {\n this._disposeIModelOpenedListener();\n this._disposeIModelOpenedListener = undefined;\n }\n if (this._shutdownListener) {\n this._shutdownListener();\n this._shutdownListener = undefined;\n }\n if (this._manager) {\n this._manager.dispose();\n this._manager = undefined;\n }\n RpcManager.unregisterImpl(PresentationRpcInterface);\n if (this._rpcImpl) {\n this._rpcImpl.dispose();\n this._rpcImpl = undefined;\n }\n if (this._disposeIpcHandler) {\n this._disposeIpcHandler();\n }\n this._initProps = undefined;\n }\n\n private static createClientManager(clientId: string, onManagerUsed: () => void): ClientStoreItem {\n const manager = (Presentation._initProps && !isSingleManagerProps(Presentation._initProps) && Presentation._initProps.clientManagerFactory)\n ? Presentation._initProps.clientManagerFactory(clientId, Presentation._initProps)\n : new PresentationManager({ ...Presentation._initProps, id: clientId });\n manager.setOnManagerUsedHandler(onManagerUsed);\n Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Created a PresentationManager instance with ID: ${clientId}. Total instances: ${this._clientsStorage!.values.length}.`);\n return { manager };\n }\n\n private static disposeClientManager(_id: string, storeItem: ClientStoreItem) {\n storeItem.manager.dispose();\n }\n\n /**\n * Get an instance of [[PresentationManager]] for specific client\n * @param clientId ID of the client requesting presentation data. If no\n * ID is provided, the default [[PresentationManager]] is returned.\n */\n public static getManager(clientId?: string): PresentationManager {\n if (this._initProps && isSingleManagerProps(this._initProps) && this._manager)\n return this._manager;\n if (this._clientsStorage)\n return this._clientsStorage.getValue(clientId || \"\").manager;\n\n throw new PresentationError(PresentationStatus.NotInitialized, \"Presentation must be first initialized by calling Presentation.initialize\");\n }\n\n /**\n * Get the time in milliseconds that backend should respond in .\n */\n public static getRequestTimeout(): number {\n if (this._rpcImpl === undefined)\n throw new PresentationError(PresentationStatus.NotInitialized, \"Presentation must be first initialized by calling Presentation.initialize\");\n return this._rpcImpl.requestTimeout;\n }\n\n private static onIModelOpened = (imodel: BriefcaseDb) => {\n const manager = this.getManager();\n const imodelAddon = manager.getNativePlatform().getImodelAddon(imodel);\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n manager.getNativePlatform().forceLoadSchemas(imodelAddon);\n };\n}\n\nfunction isSingleManagerProps(props: PresentationProps): props is SingleManagerPresentationProps {\n return !!(props as SingleManagerPresentationProps).useSingleManager;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationIpcHandler.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationIpcHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAiD;AACjD,oEAEoC;AACpC,iDAA8C;AAE9C,gBAAgB;AAChB,MAAa,sBAAuB,SAAQ,yBAAU;IAAtD;;QACS,gBAAW,GAAG,mDAA6B,CAAC;IAYrD,CAAC;IAVQ,KAAK,CAAC,kBAAkB,CAAC,MAAqD;QACnF,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;QACjD,MAAM,cAAc,GAAG,qCAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC1D,2BAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3H,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAAC,MAAkC;QAClE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;QACnD,2BAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACtE,CAAC;CACF;AAbD,wDAaC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"PresentationIpcHandler.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationIpcHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAiD;AACjD,oEAEoC;AACpC,iDAA8C;AAE9C,gBAAgB;AAChB,MAAa,sBAAuB,SAAQ,yBAAU;IAAtD;;QACS,gBAAW,GAAG,mDAA6B,CAAC;IAYrD,CAAC;IAVQ,KAAK,CAAC,kBAAkB,CAAC,MAAqD;QACnF,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;QACjD,MAAM,cAAc,GAAG,qCAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC1D,2BAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3H,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAAC,MAAkC;QAClE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;QACnD,2BAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACtE,CAAC;CACF;AAbD,wDAaC","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 RPC\n */\n\nimport { IpcHandler } from \"@itwin/core-backend\";\nimport {\n PRESENTATION_IPC_CHANNEL_NAME, PresentationIpcInterface, RulesetVariable, RulesetVariableJSON, SetRulesetVariableParams, UnsetRulesetVariableParams,\n} from \"@itwin/presentation-common\";\nimport { Presentation } from \"./Presentation\";\n\n/** @internal */\nexport class PresentationIpcHandler extends IpcHandler implements PresentationIpcInterface {\n public channelName = PRESENTATION_IPC_CHANNEL_NAME;\n\n public async setRulesetVariable(params: SetRulesetVariableParams<RulesetVariableJSON>): Promise<void> {\n const { clientId, rulesetId, variable } = params;\n const parsedVariable = RulesetVariable.fromJSON(variable);\n Presentation.getManager(clientId).vars(rulesetId).setValue(parsedVariable.id, parsedVariable.type, parsedVariable.value);\n }\n\n public async unsetRulesetVariable(params: UnsetRulesetVariableParams): Promise<void> {\n const { clientId, rulesetId, variableId } = params;\n Presentation.getManager(clientId).vars(rulesetId).unset(variableId);\n }\n}\n"]}
|