@itwin/presentation-backend 3.0.0-dev.100
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 +936 -0
- package/LICENSE.md +9 -0
- package/README.md +12 -0
- package/lib/cjs/assets/primary-presentation-rules/ElementProperties.PresentationRuleSet.json +14 -0
- package/lib/cjs/assets/supplemental-presentation-rules/BisCore.PresentationRuleSet.json +739 -0
- package/lib/cjs/assets/supplemental-presentation-rules/Functional.PresentationRuleSet.json +139 -0
- package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts +42 -0
- package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts.map +1 -0
- package/lib/cjs/presentation-backend/BackendLoggerCategory.js +51 -0
- package/lib/cjs/presentation-backend/BackendLoggerCategory.js.map +1 -0
- package/lib/cjs/presentation-backend/Constants.d.ts +14 -0
- package/lib/cjs/presentation-backend/Constants.d.ts.map +1 -0
- package/lib/cjs/presentation-backend/Constants.js +44 -0
- package/lib/cjs/presentation-backend/Constants.js.map +1 -0
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +12 -0
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts.map +1 -0
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +256 -0
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -0
- package/lib/cjs/presentation-backend/NativePlatform.d.ts +86 -0
- package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -0
- package/lib/cjs/presentation-backend/NativePlatform.js +153 -0
- package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -0
- package/lib/cjs/presentation-backend/Presentation.d.ts +98 -0
- package/lib/cjs/presentation-backend/Presentation.d.ts.map +1 -0
- package/lib/cjs/presentation-backend/Presentation.js +135 -0
- package/lib/cjs/presentation-backend/Presentation.js.map +1 -0
- package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts +13 -0
- package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts.map +1 -0
- package/lib/cjs/presentation-backend/PresentationIpcHandler.js +41 -0
- package/lib/cjs/presentation-backend/PresentationIpcHandler.js.map +1 -0
- package/lib/cjs/presentation-backend/PresentationManager.d.ts +379 -0
- package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -0
- package/lib/cjs/presentation-backend/PresentationManager.js +635 -0
- package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -0
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +58 -0
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -0
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js +271 -0
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -0
- package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts +105 -0
- package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts.map +1 -0
- package/lib/cjs/presentation-backend/RulesetEmbedder.js +283 -0
- package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -0
- package/lib/cjs/presentation-backend/RulesetManager.d.ts +54 -0
- package/lib/cjs/presentation-backend/RulesetManager.d.ts.map +1 -0
- package/lib/cjs/presentation-backend/RulesetManager.js +74 -0
- package/lib/cjs/presentation-backend/RulesetManager.js.map +1 -0
- package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts +141 -0
- package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts.map +1 -0
- package/lib/cjs/presentation-backend/RulesetVariablesManager.js +130 -0
- package/lib/cjs/presentation-backend/RulesetVariablesManager.js.map +1 -0
- package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +38 -0
- package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts.map +1 -0
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js +257 -0
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -0
- package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +73 -0
- package/lib/cjs/presentation-backend/TemporaryStorage.d.ts.map +1 -0
- package/lib/cjs/presentation-backend/TemporaryStorage.js +92 -0
- package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -0
- package/lib/cjs/presentation-backend/UpdatesTracker.d.ts +28 -0
- package/lib/cjs/presentation-backend/UpdatesTracker.d.ts.map +1 -0
- package/lib/cjs/presentation-backend/UpdatesTracker.js +55 -0
- package/lib/cjs/presentation-backend/UpdatesTracker.js.map +1 -0
- package/lib/cjs/presentation-backend/Utils.d.ts +11 -0
- package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -0
- package/lib/cjs/presentation-backend/Utils.js +39 -0
- package/lib/cjs/presentation-backend/Utils.js.map +1 -0
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.d.ts +17 -0
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.d.ts.map +1 -0
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js +52 -0
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -0
- package/lib/cjs/presentation-backend/domain/RulesetElements.d.ts +22 -0
- package/lib/cjs/presentation-backend/domain/RulesetElements.d.ts.map +1 -0
- package/lib/cjs/presentation-backend/domain/RulesetElements.js +39 -0
- package/lib/cjs/presentation-backend/domain/RulesetElements.js.map +1 -0
- package/lib/cjs/presentation-backend.d.ts +20 -0
- package/lib/cjs/presentation-backend.d.ts.map +1 -0
- package/lib/cjs/presentation-backend.js +36 -0
- package/lib/cjs/presentation-backend.js.map +1 -0
- package/package.json +99 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Core
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.TemporaryStorage = void 0;
|
|
11
|
+
/**
|
|
12
|
+
* Storage for values that get removed from it after being unused (not-requested
|
|
13
|
+
* for a specified amount of time).
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
class TemporaryStorage {
|
|
18
|
+
/**
|
|
19
|
+
* Constructor. Creates the storage using supplied params.
|
|
20
|
+
*/
|
|
21
|
+
constructor(props) {
|
|
22
|
+
/**
|
|
23
|
+
* Cleans up values that are currently outdated (based
|
|
24
|
+
* on their lifetime specified through [[Props]]).
|
|
25
|
+
*/
|
|
26
|
+
this.disposeOutdatedValues = () => {
|
|
27
|
+
const now = (new Date()).getTime();
|
|
28
|
+
const valuesToDispose = [];
|
|
29
|
+
for (const entry of this._values.entries()) {
|
|
30
|
+
if (!this.props.valueLifetime || ((now - entry["1"].lastUsed.getTime()) > this.props.valueLifetime))
|
|
31
|
+
valuesToDispose.push(entry["0"]);
|
|
32
|
+
}
|
|
33
|
+
for (const id of valuesToDispose) {
|
|
34
|
+
if (this.props.cleanupHandler)
|
|
35
|
+
this.props.cleanupHandler(this._values.get(id).value);
|
|
36
|
+
this._values.delete(id);
|
|
37
|
+
this.props.onDisposedSingle && this.props.onDisposedSingle(id);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
this.props = props;
|
|
41
|
+
this._values = new Map();
|
|
42
|
+
if (this.props.cleanupInterval)
|
|
43
|
+
this._timer = setInterval(this.disposeOutdatedValues, this.props.cleanupInterval);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Destructor. Must be called to clean up the stored values
|
|
47
|
+
* and other resources
|
|
48
|
+
*/
|
|
49
|
+
dispose() {
|
|
50
|
+
if (this._timer)
|
|
51
|
+
clearInterval(this._timer);
|
|
52
|
+
if (this.props.cleanupHandler) {
|
|
53
|
+
this._values.forEach((v) => {
|
|
54
|
+
this.props.cleanupHandler(v.value);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
this._values.clear();
|
|
58
|
+
this.props.onDisposedAll && this.props.onDisposedAll();
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get a value from the storage. If the value with the
|
|
62
|
+
* specified id doesn't exist, it gets created.
|
|
63
|
+
*
|
|
64
|
+
* **Note:** requesting a value with this method updates
|
|
65
|
+
* it's last used time.
|
|
66
|
+
*/
|
|
67
|
+
getValue(id) {
|
|
68
|
+
if (this._values.has(id)) {
|
|
69
|
+
const v = this._values.get(id);
|
|
70
|
+
v.lastUsed = new Date();
|
|
71
|
+
return v.value;
|
|
72
|
+
}
|
|
73
|
+
const value = this.props.factory(id);
|
|
74
|
+
this._values.set(id, { value, lastUsed: new Date() });
|
|
75
|
+
this.props.onCreated && this.props.onCreated(id);
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get all values currently in this storage.
|
|
80
|
+
*
|
|
81
|
+
* **Note:** requesting values with this method **doesn't**
|
|
82
|
+
* update their last used times.
|
|
83
|
+
*/
|
|
84
|
+
get values() {
|
|
85
|
+
const values = new Array();
|
|
86
|
+
for (const v of this._values.values())
|
|
87
|
+
values.push(v.value);
|
|
88
|
+
return values;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.TemporaryStorage = TemporaryStorage;
|
|
92
|
+
//# sourceMappingURL=TemporaryStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemporaryStorage.js","sourceRoot":"","sources":["../../../src/presentation-backend/TemporaryStorage.ts"],"names":[],"mappings":"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","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 { IDisposable } from \"@itwin/core-bentley\";\r\n\r\n/**\r\n * Configuration properties for [[TemporaryStorage]].\r\n * @internal\r\n */\r\nexport interface TemporaryStorageProps<T> {\r\n /** A factory method that creates a stored value given it's identifier */\r\n factory: (id: string) => T;\r\n\r\n /** A method that's called for every value before it's removed from storage */\r\n cleanupHandler?: (value: T) => void;\r\n\r\n onCreated?: (id: string) => void;\r\n onDisposedSingle?: (id: string) => void;\r\n onDisposedAll?: () => void;\r\n\r\n /**\r\n * An interval at which the storage attempts to clean up its values.\r\n * When `0` or `undefined` is specified, values are not cleaned up\r\n * automatically and cleanup has to be initiated manually by calling\r\n * [[TemporaryStorage.disposeOutdatedValues]].\r\n */\r\n cleanupInterval?: number;\r\n\r\n /**\r\n * Shortest period of time which the value should be kept in storage\r\n * unused before it's cleaned up. `0` or `undefined` means values\r\n * are removed from the storage on every cleanup (either manual call to\r\n * [[TemporaryStorage.disposeOutdatedValues]] or scheduled (controlled\r\n * by [[cleanupInterval]]))\r\n */\r\n valueLifetime?: number;\r\n}\r\n\r\n/** Value with know last used time */\r\ninterface TemporaryValue<T> {\r\n lastUsed: Date;\r\n value: T;\r\n}\r\n\r\n/**\r\n * Storage for values that get removed from it after being unused (not-requested\r\n * for a specified amount of time).\r\n *\r\n * @internal\r\n */\r\nexport class TemporaryStorage<T> implements IDisposable {\r\n\r\n private _values: Map<string, TemporaryValue<T>>;\r\n private _timer?: NodeJS.Timer;\r\n public readonly props: TemporaryStorageProps<T>;\r\n\r\n /**\r\n * Constructor. Creates the storage using supplied params.\r\n */\r\n constructor(props: TemporaryStorageProps<T>) {\r\n this.props = props;\r\n this._values = new Map<string, TemporaryValue<T>>();\r\n if (this.props.cleanupInterval)\r\n this._timer = setInterval(this.disposeOutdatedValues, this.props.cleanupInterval);\r\n }\r\n\r\n /**\r\n * Destructor. Must be called to clean up the stored values\r\n * and other resources\r\n */\r\n public dispose() {\r\n if (this._timer)\r\n clearInterval(this._timer);\r\n\r\n if (this.props.cleanupHandler) {\r\n this._values.forEach((v) => {\r\n this.props.cleanupHandler!(v.value);\r\n });\r\n }\r\n this._values.clear();\r\n this.props.onDisposedAll && this.props.onDisposedAll();\r\n }\r\n\r\n /**\r\n * Cleans up values that are currently outdated (based\r\n * on their lifetime specified through [[Props]]).\r\n */\r\n public disposeOutdatedValues = () => {\r\n const now = (new Date()).getTime();\r\n const valuesToDispose: string[] = [];\r\n for (const entry of this._values.entries()) {\r\n if (!this.props.valueLifetime || ((now - entry[\"1\"].lastUsed.getTime()) > this.props.valueLifetime))\r\n valuesToDispose.push(entry[\"0\"]);\r\n }\r\n for (const id of valuesToDispose) {\r\n if (this.props.cleanupHandler)\r\n this.props.cleanupHandler(this._values.get(id)!.value);\r\n this._values.delete(id);\r\n this.props.onDisposedSingle && this.props.onDisposedSingle(id);\r\n }\r\n };\r\n\r\n /**\r\n * Get a value from the storage. If the value with the\r\n * specified id doesn't exist, it gets created.\r\n *\r\n * **Note:** requesting a value with this method updates\r\n * it's last used time.\r\n */\r\n public getValue(id: string): T {\r\n if (this._values.has(id)) {\r\n const v = this._values.get(id)!;\r\n v.lastUsed = new Date();\r\n return v.value;\r\n }\r\n\r\n const value = this.props.factory(id);\r\n this._values.set(id, { value, lastUsed: new Date() });\r\n this.props.onCreated && this.props.onCreated(id);\r\n return value;\r\n }\r\n\r\n /**\r\n * Get all values currently in this storage.\r\n *\r\n * **Note:** requesting values with this method **doesn't**\r\n * update their last used times.\r\n */\r\n public get values(): T[] {\r\n const values = new Array<T>();\r\n for (const v of this._values.values())\r\n values.push(v.value);\r\n return values;\r\n }\r\n\r\n}\r\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Core
|
|
3
|
+
*/
|
|
4
|
+
import { IDisposable } from "@itwin/core-bentley";
|
|
5
|
+
import { NativePlatformDefinition } from "./NativePlatform";
|
|
6
|
+
/**
|
|
7
|
+
* Configuration properties for [[UpdatesTracker]].
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export interface UpdatesTrackerProps {
|
|
11
|
+
nativePlatformGetter: () => NativePlatformDefinition;
|
|
12
|
+
pollInterval: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* An updates handler which polls native platform for update records
|
|
16
|
+
* and emits an event to the frontend if any are found.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare class UpdatesTracker implements IDisposable {
|
|
21
|
+
private _getNativePlatform;
|
|
22
|
+
private _intervalHandle;
|
|
23
|
+
private constructor();
|
|
24
|
+
static create(props: UpdatesTrackerProps): UpdatesTracker;
|
|
25
|
+
dispose(): void;
|
|
26
|
+
private onInterval;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=UpdatesTracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpdatesTracker.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/UpdatesTracker.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAU,MAAM,qBAAqB,CAAC;AAI1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAE5D;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;IACrD,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,qBAAa,cAAe,YAAW,WAAW;IAChD,OAAO,CAAC,kBAAkB,CAAiC;IAC3D,OAAO,CAAC,eAAe,CAAM;IAE7B,OAAO;WAKO,MAAM,CAAC,KAAK,EAAE,mBAAmB;IAExC,OAAO;IAId,OAAO,CAAC,UAAU;CAMnB"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Core
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.UpdatesTracker = void 0;
|
|
11
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
|
+
const core_backend_1 = require("@itwin/core-backend");
|
|
13
|
+
const presentation_common_1 = require("@itwin/presentation-common");
|
|
14
|
+
const BackendLoggerCategory_1 = require("./BackendLoggerCategory");
|
|
15
|
+
/**
|
|
16
|
+
* An updates handler which polls native platform for update records
|
|
17
|
+
* and emits an event to the frontend if any are found.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
class UpdatesTracker {
|
|
22
|
+
constructor(props) {
|
|
23
|
+
this._getNativePlatform = props.nativePlatformGetter;
|
|
24
|
+
this._intervalHandle = setInterval(this.onInterval.bind(this), props.pollInterval);
|
|
25
|
+
}
|
|
26
|
+
static create(props) { return new UpdatesTracker(props); }
|
|
27
|
+
dispose() {
|
|
28
|
+
clearInterval(this._intervalHandle);
|
|
29
|
+
}
|
|
30
|
+
onInterval() {
|
|
31
|
+
const response = this._getNativePlatform().getUpdateInfo();
|
|
32
|
+
const info = parseUpdateInfo(response.result);
|
|
33
|
+
if (info)
|
|
34
|
+
core_backend_1.IpcHost.send(presentation_common_1.PresentationIpcEvents.Update, info);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.UpdatesTracker = UpdatesTracker;
|
|
38
|
+
const parseUpdateInfo = (info) => {
|
|
39
|
+
if (info === undefined)
|
|
40
|
+
return undefined;
|
|
41
|
+
const parsedInfo = {};
|
|
42
|
+
for (const fileName in info) {
|
|
43
|
+
// istanbul ignore if
|
|
44
|
+
if (!info.hasOwnProperty(fileName))
|
|
45
|
+
continue;
|
|
46
|
+
const imodelDb = core_backend_1.IModelDb.findByFilename(fileName);
|
|
47
|
+
if (!imodelDb) {
|
|
48
|
+
core_bentley_1.Logger.logError(BackendLoggerCategory_1.PresentationBackendLoggerCategory.PresentationManager, `Update records IModelDb not found with path ${fileName}`);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
parsedInfo[imodelDb.getRpcProps().key] = info[fileName];
|
|
52
|
+
}
|
|
53
|
+
return Object.keys(parsedInfo).length > 0 ? parsedInfo : undefined;
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=UpdatesTracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpdatesTracker.js","sourceRoot":"","sources":["../../../src/presentation-backend/UpdatesTracker.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA0D;AAC1D,sDAAwD;AACxD,oEAAmF;AACnF,mEAA4E;AAY5E;;;;;GAKG;AACH,MAAa,cAAc;IAIzB,YAAoB,KAA0B;QAC5C,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC,oBAAoB,CAAC;QACrD,IAAI,CAAC,eAAe,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IACrF,CAAC;IAEM,MAAM,CAAC,MAAM,CAAC,KAA0B,IAAI,OAAO,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE/E,OAAO;QACZ,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACtC,CAAC;IAEO,UAAU;QAChB,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC,aAAa,EAAE,CAAC;QAC3D,MAAM,IAAI,GAAG,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC9C,IAAI,IAAI;YACN,sBAAO,CAAC,IAAI,CAAC,2CAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACrD,CAAC;CACF;AArBD,wCAqBC;AAED,MAAM,eAAe,GAAG,CAAC,IAAgC,EAAE,EAAE;IAC3D,IAAI,IAAI,KAAK,SAAS;QACpB,OAAO,SAAS,CAAC;IAEnB,MAAM,UAAU,GAAmB,EAAE,CAAC;IACtC,KAAK,MAAM,QAAQ,IAAI,IAAI,EAAE;QAC3B,qBAAqB;QACrB,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC;YAChC,SAAS;QAEX,MAAM,QAAQ,GAAG,uBAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QACnD,IAAI,CAAC,QAAQ,EAAE;YACb,qBAAM,CAAC,QAAQ,CAAC,yDAAiC,CAAC,mBAAmB,EAAE,+CAA+C,QAAQ,EAAE,CAAC,CAAC;YAClI,SAAS;SACV;QAED,UAAU,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;KACzD;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;AACrE,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { IDisposable, Logger } from \"@itwin/core-bentley\";\r\nimport { IModelDb, IpcHost } from \"@itwin/core-backend\";\r\nimport { PresentationIpcEvents, UpdateInfoJSON } from \"@itwin/presentation-common\";\r\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { NativePlatformDefinition } from \"./NativePlatform\";\r\n\r\n/**\r\n * Configuration properties for [[UpdatesTracker]].\r\n * @internal\r\n */\r\nexport interface UpdatesTrackerProps {\r\n nativePlatformGetter: () => NativePlatformDefinition;\r\n pollInterval: number;\r\n}\r\n\r\n/**\r\n * An updates handler which polls native platform for update records\r\n * and emits an event to the frontend if any are found.\r\n *\r\n * @internal\r\n */\r\nexport class UpdatesTracker implements IDisposable {\r\n private _getNativePlatform: () => NativePlatformDefinition;\r\n private _intervalHandle: any;\r\n\r\n private constructor(props: UpdatesTrackerProps) {\r\n this._getNativePlatform = props.nativePlatformGetter;\r\n this._intervalHandle = setInterval(this.onInterval.bind(this), props.pollInterval);\r\n }\r\n\r\n public static create(props: UpdatesTrackerProps) { return new UpdatesTracker(props); }\r\n\r\n public dispose() {\r\n clearInterval(this._intervalHandle);\r\n }\r\n\r\n private onInterval() {\r\n const response = this._getNativePlatform().getUpdateInfo();\r\n const info = parseUpdateInfo(response.result);\r\n if (info)\r\n IpcHost.send(PresentationIpcEvents.Update, info);\r\n }\r\n}\r\n\r\nconst parseUpdateInfo = (info: UpdateInfoJSON | undefined) => {\r\n if (info === undefined)\r\n return undefined;\r\n\r\n const parsedInfo: UpdateInfoJSON = {};\r\n for (const fileName in info) {\r\n // istanbul ignore if\r\n if (!info.hasOwnProperty(fileName))\r\n continue;\r\n\r\n const imodelDb = IModelDb.findByFilename(fileName);\r\n if (!imodelDb) {\r\n Logger.logError(PresentationBackendLoggerCategory.PresentationManager, `Update records IModelDb not found with path ${fileName}`);\r\n continue;\r\n }\r\n\r\n parsedInfo[imodelDb.getRpcProps().key] = info[fileName];\r\n }\r\n return Object.keys(parsedInfo).length > 0 ? parsedInfo : undefined;\r\n};\r\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Core
|
|
3
|
+
*/
|
|
4
|
+
import { Id64String } from "@itwin/core-bentley";
|
|
5
|
+
import { IModelDb } from "@itwin/core-backend";
|
|
6
|
+
import { InstanceKey } from "@itwin/presentation-common";
|
|
7
|
+
/** @internal */
|
|
8
|
+
export declare function getElementKey(imodel: IModelDb, id: Id64String): InstanceKey | undefined;
|
|
9
|
+
/** @internal */
|
|
10
|
+
export declare function normalizeVersion(version?: string): string;
|
|
11
|
+
//# sourceMappingURL=Utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/Utils.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAY,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAW,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,gBAAgB;AAChB,wBAAgB,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,GAAG,WAAW,GAAG,SAAS,CAWvF;AAED,gBAAgB;AAChB,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,MAAM,UAOhD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Core
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.normalizeVersion = exports.getElementKey = void 0;
|
|
11
|
+
const semver_1 = require("semver");
|
|
12
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
13
|
+
const core_backend_1 = require("@itwin/core-backend");
|
|
14
|
+
/** @internal */
|
|
15
|
+
function getElementKey(imodel, id) {
|
|
16
|
+
let key;
|
|
17
|
+
const query = `SELECT ECClassId FROM ${core_backend_1.Element.classFullName} e WHERE ECInstanceId = ?`;
|
|
18
|
+
imodel.withPreparedStatement(query, (stmt) => {
|
|
19
|
+
try {
|
|
20
|
+
stmt.bindId(1, id);
|
|
21
|
+
if (stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW)
|
|
22
|
+
key = { className: stmt.getValue(0).getClassNameForClassId().replace(".", ":"), id };
|
|
23
|
+
}
|
|
24
|
+
catch { }
|
|
25
|
+
});
|
|
26
|
+
return key;
|
|
27
|
+
}
|
|
28
|
+
exports.getElementKey = getElementKey;
|
|
29
|
+
/** @internal */
|
|
30
|
+
function normalizeVersion(version) {
|
|
31
|
+
if (version) {
|
|
32
|
+
const parsedVersion = (0, semver_1.parse)(version, true);
|
|
33
|
+
if (parsedVersion)
|
|
34
|
+
return `${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch}`;
|
|
35
|
+
}
|
|
36
|
+
return "0.0.0";
|
|
37
|
+
}
|
|
38
|
+
exports.normalizeVersion = normalizeVersion;
|
|
39
|
+
//# sourceMappingURL=Utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/presentation-backend/Utils.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,mCAA+C;AAC/C,sDAA2D;AAC3D,sDAAwD;AAGxD,gBAAgB;AAChB,SAAgB,aAAa,CAAC,MAAgB,EAAE,EAAc;IAC5D,IAAI,GAA4B,CAAC;IACjC,MAAM,KAAK,GAAG,yBAAyB,sBAAO,CAAC,aAAa,2BAA2B,CAAC;IACxF,MAAM,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE;QAC3C,IAAI;YACF,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACnB,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,uBAAQ,CAAC,aAAa;gBACxC,GAAG,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,sBAAsB,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC;SACxF;QAAC,MAAM,GAAG;IACb,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACb,CAAC;AAXD,sCAWC;AAED,gBAAgB;AAChB,SAAgB,gBAAgB,CAAC,OAAgB;IAC/C,IAAI,OAAO,EAAE;QACX,MAAM,aAAa,GAAG,IAAA,cAAY,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAClD,IAAI,aAAa;YACf,OAAO,GAAG,aAAa,CAAC,KAAK,IAAI,aAAa,CAAC,KAAK,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;KACjF;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAPD,4CAOC","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 { parse as parseVersion } from \"semver\";\r\nimport { DbResult, Id64String } from \"@itwin/core-bentley\";\r\nimport { Element, IModelDb } from \"@itwin/core-backend\";\r\nimport { InstanceKey } from \"@itwin/presentation-common\";\r\n\r\n/** @internal */\r\nexport function getElementKey(imodel: IModelDb, id: Id64String): InstanceKey | undefined {\r\n let key: InstanceKey | undefined;\r\n const query = `SELECT ECClassId FROM ${Element.classFullName} e WHERE ECInstanceId = ?`;\r\n imodel.withPreparedStatement(query, (stmt) => {\r\n try {\r\n stmt.bindId(1, id);\r\n if (stmt.step() === DbResult.BE_SQLITE_ROW)\r\n key = { className: stmt.getValue(0).getClassNameForClassId().replace(\".\", \":\"), id };\r\n } catch { }\r\n });\r\n return key;\r\n}\r\n\r\n/** @internal */\r\nexport function normalizeVersion(version?: string) {\r\n if (version) {\r\n const parsedVersion = parseVersion(version, true);\r\n if (parsedVersion)\r\n return `${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch}`;\r\n }\r\n return \"0.0.0\";\r\n}\r\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Core
|
|
3
|
+
*/
|
|
4
|
+
import { Schema } from "@itwin/core-backend";
|
|
5
|
+
/** @internal */
|
|
6
|
+
export declare class PresentationRules extends Schema {
|
|
7
|
+
static get schemaName(): string;
|
|
8
|
+
/** Registers this schema and it's elements' classes */
|
|
9
|
+
static registerSchema(): void;
|
|
10
|
+
}
|
|
11
|
+
/** @internal */
|
|
12
|
+
export declare namespace PresentationRules {
|
|
13
|
+
enum CodeSpec {
|
|
14
|
+
Ruleset = "PresentationRules:Ruleset"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=PresentationRulesDomain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PresentationRulesDomain.d.ts","sourceRoot":"","sources":["../../../../src/presentation-backend/domain/PresentationRulesDomain.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAiB,MAAM,EAAW,MAAM,qBAAqB,CAAC;AAGrE,gBAAgB;AAChB,qBAAa,iBAAkB,SAAQ,MAAM;IAC3C,WAA2B,UAAU,IAAI,MAAM,CAAgC;IAE/E,uDAAuD;WACzC,cAAc;CAM7B;AAED,gBAAgB;AAEhB,yBAAiB,iBAAiB,CAAC;IACjC,KAAY,QAAQ;QAClB,OAAO,8BAA8B;KACtC;CACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Core
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.PresentationRules = void 0;
|
|
30
|
+
const core_backend_1 = require("@itwin/core-backend");
|
|
31
|
+
const RulesetElements = __importStar(require("./RulesetElements"));
|
|
32
|
+
/** @internal */
|
|
33
|
+
class PresentationRules extends core_backend_1.Schema {
|
|
34
|
+
static get schemaName() { return "PresentationRules"; }
|
|
35
|
+
/** Registers this schema and it's elements' classes */
|
|
36
|
+
static registerSchema() {
|
|
37
|
+
if (this !== core_backend_1.Schemas.getRegisteredSchema(PresentationRules.schemaName)) {
|
|
38
|
+
core_backend_1.Schemas.registerSchema(PresentationRules);
|
|
39
|
+
core_backend_1.ClassRegistry.registerModule(RulesetElements, this);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.PresentationRules = PresentationRules;
|
|
44
|
+
/** @internal */
|
|
45
|
+
/* istanbul ignore next */
|
|
46
|
+
(function (PresentationRules) {
|
|
47
|
+
let CodeSpec;
|
|
48
|
+
(function (CodeSpec) {
|
|
49
|
+
CodeSpec["Ruleset"] = "PresentationRules:Ruleset";
|
|
50
|
+
})(CodeSpec = PresentationRules.CodeSpec || (PresentationRules.CodeSpec = {}));
|
|
51
|
+
})(PresentationRules = exports.PresentationRules || (exports.PresentationRules = {}));
|
|
52
|
+
//# sourceMappingURL=PresentationRulesDomain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PresentationRulesDomain.js","sourceRoot":"","sources":["../../../../src/presentation-backend/domain/PresentationRulesDomain.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;AAEH,sDAAqE;AACrE,mEAAqD;AAErD,gBAAgB;AAChB,MAAa,iBAAkB,SAAQ,qBAAM;IACpC,MAAM,KAAc,UAAU,KAAa,OAAO,mBAAmB,CAAC,CAAC,CAAC;IAE/E,uDAAuD;IAChD,MAAM,CAAC,cAAc;QAC1B,IAAI,IAAI,KAAK,sBAAO,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,UAAU,CAAC,EAAE;YACtE,sBAAO,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;YAC1C,4BAAa,CAAC,cAAc,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;SACrD;IACH,CAAC;CACF;AAVD,8CAUC;AAED,gBAAgB;AAChB,0BAA0B;AAC1B,WAAiB,iBAAiB;IAChC,IAAY,QAEX;IAFD,WAAY,QAAQ;QAClB,iDAAqC,CAAA;IACvC,CAAC,EAFW,QAAQ,GAAR,0BAAQ,KAAR,0BAAQ,QAEnB;AACH,CAAC,EAJgB,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAIjC","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 { ClassRegistry, Schema, Schemas } from \"@itwin/core-backend\";\r\nimport * as RulesetElements from \"./RulesetElements\";\r\n\r\n/** @internal */\r\nexport class PresentationRules extends Schema {\r\n public static override get schemaName(): string { return \"PresentationRules\"; }\r\n\r\n /** Registers this schema and it's elements' classes */\r\n public static registerSchema() {\r\n if (this !== Schemas.getRegisteredSchema(PresentationRules.schemaName)) {\r\n Schemas.registerSchema(PresentationRules);\r\n ClassRegistry.registerModule(RulesetElements, this);\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\n/* istanbul ignore next */\r\nexport namespace PresentationRules { // eslint-disable-line no-redeclare\r\n export enum CodeSpec {\r\n Ruleset = \"PresentationRules:Ruleset\",\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Core
|
|
3
|
+
*/
|
|
4
|
+
import { Id64String } from "@itwin/core-bentley";
|
|
5
|
+
import { DefinitionElement, IModelDb } from "@itwin/core-backend";
|
|
6
|
+
import { Code } from "@itwin/core-common";
|
|
7
|
+
import { Ruleset as PresentationRuleset } from "@itwin/presentation-common";
|
|
8
|
+
/** @internal */
|
|
9
|
+
export declare class Ruleset extends DefinitionElement {
|
|
10
|
+
/**
|
|
11
|
+
* Name of the `Ruleset` element class.
|
|
12
|
+
*/
|
|
13
|
+
static get className(): string;
|
|
14
|
+
/**
|
|
15
|
+
* Generates a unique code for a ruleset
|
|
16
|
+
* @param iModelDb DB the ruleset is supposed to be inserted into
|
|
17
|
+
* @param modelId ID of a the model this ruleset should be created in
|
|
18
|
+
* @param ruleset The ruleset code is being created for
|
|
19
|
+
*/
|
|
20
|
+
static createRulesetCode(iModelDb: IModelDb, modelId: Id64String, ruleset: PresentationRuleset): Code;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=RulesetElements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RulesetElements.d.ts","sourceRoot":"","sources":["../../../../src/presentation-backend/domain/RulesetElements.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAI5E,gBAAgB;AAChB,qBAAa,OAAQ,SAAQ,iBAAiB;IAC5C;;OAEG;IACH,WAA2B,SAAS,IAAI,MAAM,CAAsB;IAEpE;;;;;OAKG;WACW,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,mBAAmB;CAWtG"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Core
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.Ruleset = void 0;
|
|
11
|
+
const core_backend_1 = require("@itwin/core-backend");
|
|
12
|
+
const core_common_1 = require("@itwin/core-common");
|
|
13
|
+
const Utils_1 = require("../Utils");
|
|
14
|
+
const PresentationRulesDomain_1 = require("./PresentationRulesDomain");
|
|
15
|
+
/** @internal */
|
|
16
|
+
class Ruleset extends core_backend_1.DefinitionElement {
|
|
17
|
+
/**
|
|
18
|
+
* Name of the `Ruleset` element class.
|
|
19
|
+
*/
|
|
20
|
+
static get className() { return "Ruleset"; }
|
|
21
|
+
/**
|
|
22
|
+
* Generates a unique code for a ruleset
|
|
23
|
+
* @param iModelDb DB the ruleset is supposed to be inserted into
|
|
24
|
+
* @param modelId ID of a the model this ruleset should be created in
|
|
25
|
+
* @param ruleset The ruleset code is being created for
|
|
26
|
+
*/
|
|
27
|
+
static createRulesetCode(iModelDb, modelId, ruleset) {
|
|
28
|
+
let codeValue = ruleset.id;
|
|
29
|
+
if (ruleset.version)
|
|
30
|
+
codeValue += `@${(0, Utils_1.normalizeVersion)(ruleset.version)}`;
|
|
31
|
+
return new core_common_1.Code({
|
|
32
|
+
spec: iModelDb.codeSpecs.getByName(PresentationRulesDomain_1.PresentationRules.CodeSpec.Ruleset).id,
|
|
33
|
+
scope: modelId.toString(),
|
|
34
|
+
value: codeValue,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.Ruleset = Ruleset;
|
|
39
|
+
//# sourceMappingURL=RulesetElements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RulesetElements.js","sourceRoot":"","sources":["../../../../src/presentation-backend/domain/RulesetElements.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,sDAAkE;AAClE,oDAA0C;AAE1C,oCAA4C;AAC5C,uEAA8D;AAE9D,gBAAgB;AAChB,MAAa,OAAQ,SAAQ,gCAAiB;IAC5C;;OAEG;IACI,MAAM,KAAc,SAAS,KAAa,OAAO,SAAS,CAAC,CAAC,CAAC;IAEpE;;;;;OAKG;IACI,MAAM,CAAC,iBAAiB,CAAC,QAAkB,EAAE,OAAmB,EAAE,OAA4B;QACnG,IAAI,SAAS,GAAG,OAAO,CAAC,EAAE,CAAC;QAC3B,IAAI,OAAO,CAAC,OAAO;YACjB,SAAS,IAAI,IAAI,IAAA,wBAAgB,EAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAEvD,OAAO,IAAI,kBAAI,CAAC;YACd,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,2CAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE;YACzE,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE;YACzB,KAAK,EAAE,SAAS;SACjB,CAAC,CAAC;IACL,CAAC;CACF;AAvBD,0BAuBC","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 { Id64String } from \"@itwin/core-bentley\";\r\nimport { DefinitionElement, IModelDb } from \"@itwin/core-backend\";\r\nimport { Code } from \"@itwin/core-common\";\r\nimport { Ruleset as PresentationRuleset } from \"@itwin/presentation-common\";\r\nimport { normalizeVersion } from \"../Utils\";\r\nimport { PresentationRules } from \"./PresentationRulesDomain\";\r\n\r\n/** @internal */\r\nexport class Ruleset extends DefinitionElement {\r\n /**\r\n * Name of the `Ruleset` element class.\r\n */\r\n public static override get className(): string { return \"Ruleset\"; }\r\n\r\n /**\r\n * Generates a unique code for a ruleset\r\n * @param iModelDb DB the ruleset is supposed to be inserted into\r\n * @param modelId ID of a the model this ruleset should be created in\r\n * @param ruleset The ruleset code is being created for\r\n */\r\n public static createRulesetCode(iModelDb: IModelDb, modelId: Id64String, ruleset: PresentationRuleset) {\r\n let codeValue = ruleset.id;\r\n if (ruleset.version)\r\n codeValue += `@${normalizeVersion(ruleset.version)}`;\r\n\r\n return new Code({\r\n spec: iModelDb.codeSpecs.getByName(PresentationRules.CodeSpec.Ruleset).id,\r\n scope: modelId.toString(),\r\n value: codeValue,\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Core
|
|
3
|
+
*
|
|
4
|
+
* @docs-group-description Core
|
|
5
|
+
* Common types used for retrieving presentation data from iModels.
|
|
6
|
+
*/
|
|
7
|
+
export * from "./presentation-backend/Presentation";
|
|
8
|
+
export * from "./presentation-backend/PresentationManager";
|
|
9
|
+
export * from "./presentation-backend/RulesetManager";
|
|
10
|
+
export * from "./presentation-backend/RulesetVariablesManager";
|
|
11
|
+
export * from "./presentation-backend/RulesetEmbedder";
|
|
12
|
+
export * from "./presentation-backend/Utils";
|
|
13
|
+
/**
|
|
14
|
+
* @module Logging
|
|
15
|
+
*
|
|
16
|
+
* @docs-group-description Logging
|
|
17
|
+
* Types related to logging in this package.
|
|
18
|
+
*/
|
|
19
|
+
export * from "./presentation-backend/BackendLoggerCategory";
|
|
20
|
+
//# sourceMappingURL=presentation-backend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation-backend.d.ts","sourceRoot":"","sources":["../../src/presentation-backend.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,cAAc,qCAAqC,CAAC;AACpD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,uCAAuC,CAAC;AACtD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,wCAAwC,CAAC;AACvD,cAAc,8BAA8B,CAAC;AAE7C;;;;;GAKG;AACH,cAAc,8CAA8C,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
/*---------------------------------------------------------------------------------------------
|
|
14
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
15
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
16
|
+
*--------------------------------------------------------------------------------------------*/
|
|
17
|
+
/**
|
|
18
|
+
* @module Core
|
|
19
|
+
*
|
|
20
|
+
* @docs-group-description Core
|
|
21
|
+
* Common types used for retrieving presentation data from iModels.
|
|
22
|
+
*/
|
|
23
|
+
__exportStar(require("./presentation-backend/Presentation"), exports);
|
|
24
|
+
__exportStar(require("./presentation-backend/PresentationManager"), exports);
|
|
25
|
+
__exportStar(require("./presentation-backend/RulesetManager"), exports);
|
|
26
|
+
__exportStar(require("./presentation-backend/RulesetVariablesManager"), exports);
|
|
27
|
+
__exportStar(require("./presentation-backend/RulesetEmbedder"), exports);
|
|
28
|
+
__exportStar(require("./presentation-backend/Utils"), exports);
|
|
29
|
+
/**
|
|
30
|
+
* @module Logging
|
|
31
|
+
*
|
|
32
|
+
* @docs-group-description Logging
|
|
33
|
+
* Types related to logging in this package.
|
|
34
|
+
*/
|
|
35
|
+
__exportStar(require("./presentation-backend/BackendLoggerCategory"), exports);
|
|
36
|
+
//# sourceMappingURL=presentation-backend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation-backend.js","sourceRoot":"","sources":["../../src/presentation-backend.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F;;;;;GAKG;AACH,sEAAoD;AACpD,6EAA2D;AAC3D,wEAAsD;AACtD,iFAA+D;AAC/D,yEAAuD;AACvD,+DAA6C;AAE7C;;;;;GAKG;AACH,+EAA6D","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/**\r\n * @module Core\r\n *\r\n * @docs-group-description Core\r\n * Common types used for retrieving presentation data from iModels.\r\n */\r\nexport * from \"./presentation-backend/Presentation\";\r\nexport * from \"./presentation-backend/PresentationManager\";\r\nexport * from \"./presentation-backend/RulesetManager\";\r\nexport * from \"./presentation-backend/RulesetVariablesManager\";\r\nexport * from \"./presentation-backend/RulesetEmbedder\";\r\nexport * from \"./presentation-backend/Utils\";\r\n\r\n/**\r\n * @module Logging\r\n *\r\n * @docs-group-description Logging\r\n * Types related to logging in this package.\r\n */\r\nexport * from \"./presentation-backend/BackendLoggerCategory\";\r\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@itwin/presentation-backend",
|
|
3
|
+
"version": "3.0.0-dev.100",
|
|
4
|
+
"description": "Backend of iModel.js Presentation library",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/imodeljs/imodeljs/tree/master/presentation/backend"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"Bentley",
|
|
12
|
+
"EC",
|
|
13
|
+
"Presentation",
|
|
14
|
+
"iModelJS",
|
|
15
|
+
"Backend"
|
|
16
|
+
],
|
|
17
|
+
"author": {
|
|
18
|
+
"name": "Bentley Systems, Inc.",
|
|
19
|
+
"url": "http://www.bentley.com"
|
|
20
|
+
},
|
|
21
|
+
"main": "lib/cjs/presentation-backend.js",
|
|
22
|
+
"typings": "lib/cjs/presentation-backend",
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@itwin/core-bentley": "^3.0.0-dev.100",
|
|
25
|
+
"@itwin/core-backend": "^3.0.0-dev.100",
|
|
26
|
+
"@itwin/core-common": "^3.0.0-dev.100",
|
|
27
|
+
"@itwin/core-quantity": "^3.0.0-dev.100",
|
|
28
|
+
"@itwin/presentation-common": "^3.0.0-dev.100"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@itwin/core-bentley": "3.0.0-dev.100",
|
|
32
|
+
"@itwin/build-tools": "3.0.0-dev.100",
|
|
33
|
+
"@itwin/eslint-plugin": "3.0.0-dev.100",
|
|
34
|
+
"@itwin/core-backend": "3.0.0-dev.100",
|
|
35
|
+
"@itwin/core-common": "3.0.0-dev.100",
|
|
36
|
+
"@itwin/core-quantity": "3.0.0-dev.100",
|
|
37
|
+
"@itwin/presentation-common": "3.0.0-dev.100",
|
|
38
|
+
"@types/chai": "^4.1.4",
|
|
39
|
+
"@types/chai-as-promised": "^7",
|
|
40
|
+
"@types/chai-jest-snapshot": "^1.3.0",
|
|
41
|
+
"@types/chai-subset": "1.3.1",
|
|
42
|
+
"@types/deep-equal": "^1",
|
|
43
|
+
"@types/faker": "^4.1.0",
|
|
44
|
+
"@types/lolex": "^2.1.2",
|
|
45
|
+
"@types/mocha": "^8.2.2",
|
|
46
|
+
"@types/node": "14.14.31",
|
|
47
|
+
"@types/object-hash": "^1.3.0",
|
|
48
|
+
"@types/semver": "^5.5.0",
|
|
49
|
+
"@types/sinon": "^9.0.0",
|
|
50
|
+
"@types/sinon-chai": "^3.2.0",
|
|
51
|
+
"chai": "^4.1.2",
|
|
52
|
+
"chai-as-promised": "^7",
|
|
53
|
+
"chai-jest-snapshot": "^2.0.0",
|
|
54
|
+
"chai-subset": "1.6.0",
|
|
55
|
+
"cpx": "^1.5.0",
|
|
56
|
+
"cross-env": "^5.1.4",
|
|
57
|
+
"deep-equal": "^1",
|
|
58
|
+
"eslint": "^7.11.0",
|
|
59
|
+
"faker": "^4.1.0",
|
|
60
|
+
"lolex": "^2.7.1",
|
|
61
|
+
"mocha": "^8.3.2",
|
|
62
|
+
"nyc": "^15.1.0",
|
|
63
|
+
"rimraf": "^3.0.2",
|
|
64
|
+
"sinon": "^9.0.2",
|
|
65
|
+
"sinon-chai": "^3.2.0",
|
|
66
|
+
"typemoq": "^2.1.0",
|
|
67
|
+
"typescript": "~4.4.0"
|
|
68
|
+
},
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"object-hash": "^1.3.1",
|
|
71
|
+
"semver": "^5.5.0"
|
|
72
|
+
},
|
|
73
|
+
"nyc": {
|
|
74
|
+
"extends": "./node_modules/@itwin/build-tools/.nycrc"
|
|
75
|
+
},
|
|
76
|
+
"eslintConfig": {
|
|
77
|
+
"plugins": [
|
|
78
|
+
"@itwin"
|
|
79
|
+
],
|
|
80
|
+
"extends": "plugin:@itwin/itwinjs-recommended"
|
|
81
|
+
},
|
|
82
|
+
"scripts": {
|
|
83
|
+
"build": "npm run -s build:cjs",
|
|
84
|
+
"build:ci": "npm run -s build",
|
|
85
|
+
"build:cjs": "npm run -s copy:assets && tsc 1>&2",
|
|
86
|
+
"copy:assets": "cpx \"./assets/**/*\" ./lib/cjs/assets",
|
|
87
|
+
"build:watch": "npm run -s build:cjs -- -w",
|
|
88
|
+
"clean": "rimraf lib .rush/temp/package-deps*.json",
|
|
89
|
+
"cover": "nyc npm -s test",
|
|
90
|
+
"docs": "npm run -s docs:reference && npm run -s extract && npm run -s docs:changelog",
|
|
91
|
+
"docs:changelog": "cpx ./CHANGELOG.md ../../generated-docs/presentation/presentation-backend",
|
|
92
|
+
"docs:reference": "betools docs --includes=../../generated-docs/extract --json=../../generated-docs/presentation/presentation-backend/file.json --tsIndexFile=presentation-backend.ts --onlyJson",
|
|
93
|
+
"extract": "betools extract --fileExt=ts --extractFrom=./src/test --recursive --out=../../generated-docs/extract",
|
|
94
|
+
"extract-api": "betools extract-api --entry=presentation-backend",
|
|
95
|
+
"lint": "eslint -f visualstudio \"./src/**/*.ts\" 1>&2",
|
|
96
|
+
"test": "mocha --config ../.mocharc.json --file ./lib/cjs/test/index.test.js \"./lib/cjs/test/**/*.test.js\"",
|
|
97
|
+
"test:watch": "npm -s test -- --reporter min --watch-extensions ts --watch"
|
|
98
|
+
}
|
|
99
|
+
}
|