@itwin/presentation-backend 4.0.0-dev.52 → 4.0.0-dev.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts +41 -41
  2. package/lib/cjs/presentation-backend/BackendLoggerCategory.js +50 -50
  3. package/lib/cjs/presentation-backend/Constants.d.ts +8 -8
  4. package/lib/cjs/presentation-backend/Constants.js +40 -36
  5. package/lib/cjs/presentation-backend/Constants.js.map +1 -1
  6. package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +11 -11
  7. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +260 -260
  8. package/lib/cjs/presentation-backend/NativePlatform.d.ts +87 -87
  9. package/lib/cjs/presentation-backend/NativePlatform.js +140 -140
  10. package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
  11. package/lib/cjs/presentation-backend/Presentation.d.ts +106 -106
  12. package/lib/cjs/presentation-backend/Presentation.d.ts.map +1 -1
  13. package/lib/cjs/presentation-backend/Presentation.js +148 -148
  14. package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
  15. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts +12 -12
  16. package/lib/cjs/presentation-backend/PresentationIpcHandler.js +41 -41
  17. package/lib/cjs/presentation-backend/PresentationManager.d.ts +456 -456
  18. package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
  19. package/lib/cjs/presentation-backend/PresentationManager.js +309 -309
  20. package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +61 -61
  21. package/lib/cjs/presentation-backend/PresentationManagerDetail.js +430 -426
  22. package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
  23. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +62 -62
  24. package/lib/cjs/presentation-backend/PresentationRpcImpl.js +388 -388
  25. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts +102 -102
  26. package/lib/cjs/presentation-backend/RulesetEmbedder.js +283 -279
  27. package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
  28. package/lib/cjs/presentation-backend/RulesetManager.d.ts +53 -53
  29. package/lib/cjs/presentation-backend/RulesetManager.js +73 -73
  30. package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts +140 -140
  31. package/lib/cjs/presentation-backend/RulesetVariablesManager.js +129 -129
  32. package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +28 -28
  33. package/lib/cjs/presentation-backend/SelectionScopesHelper.js +210 -210
  34. package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +123 -123
  35. package/lib/cjs/presentation-backend/TemporaryStorage.js +151 -151
  36. package/lib/cjs/presentation-backend/UpdatesTracker.d.ts +27 -27
  37. package/lib/cjs/presentation-backend/UpdatesTracker.js +54 -54
  38. package/lib/cjs/presentation-backend/Utils.d.ts +49 -49
  39. package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -1
  40. package/lib/cjs/presentation-backend/Utils.js +107 -107
  41. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.d.ts +16 -16
  42. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js +55 -51
  43. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -1
  44. package/lib/cjs/presentation-backend/domain/RulesetElements.d.ts +21 -21
  45. package/lib/cjs/presentation-backend/domain/RulesetElements.js +38 -38
  46. package/lib/cjs/presentation-backend.d.ts +19 -19
  47. package/lib/cjs/presentation-backend.js +39 -35
  48. package/lib/cjs/presentation-backend.js.map +1 -1
  49. package/package.json +14 -14
@@ -1,55 +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
- };
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
55
  //# sourceMappingURL=UpdatesTracker.js.map
@@ -1,50 +1,50 @@
1
- /** @packageDocumentation
2
- * @module Core
3
- */
4
- import { IModelDb } from "@itwin/core-backend";
5
- import { Id64String } from "@itwin/core-bentley";
6
- import { Diagnostics, DiagnosticsOptions, InstanceKey } from "@itwin/presentation-common";
7
- /** @internal */
8
- export declare function getLocalizedStringEN(key: string): string;
9
- /** @internal */
10
- export declare function getElementKey(imodel: IModelDb, id: Id64String): InstanceKey | undefined;
11
- /** @internal */
12
- export declare function normalizeVersion(version?: string): string;
13
- /**
14
- * A function that received request diagnostics and, optionally, request context.
15
- * @beta
16
- */
17
- export declare type BackendDiagnosticsHandler<TContext = any> = (logs: Diagnostics, requestContext?: TContext) => void;
18
- /**
19
- * Data structure for backend diagnostics options.
20
- * @beta
21
- */
22
- export interface BackendDiagnosticsOptions<TContext = any> extends DiagnosticsOptions {
23
- /**
24
- * An optional function to supply request context that'll be passed to [[handler]] when
25
- * it's called after the request is fulfilled.
26
- */
27
- requestContextSupplier?: () => TContext;
28
- /**
29
- * Request diagnostics handler function that is called after the request is fulfilled. The handler
30
- * receives request diagnostics as the first argument and, optionally, request context as the
31
- * second (see [[requestContextSupplier]]).
32
- */
33
- handler: BackendDiagnosticsHandler<TContext>;
34
- }
35
- /**
36
- * Data structure which contains backend diagnostics options.
37
- * @public
38
- */
39
- export interface BackendDiagnosticsAttribute {
40
- /**
41
- * Backend diagnostics options.
42
- * @beta
43
- */
44
- diagnostics?: BackendDiagnosticsOptions;
45
- }
46
- /** @internal */
47
- export declare function combineDiagnosticsOptions(...options: Array<BackendDiagnosticsOptions | undefined>): DiagnosticsOptions | undefined;
48
- /** @internal */
49
- export declare function reportDiagnostics<TContext>(diagnostics: Diagnostics, options: BackendDiagnosticsOptions<TContext>, context?: TContext): void;
1
+ /** @packageDocumentation
2
+ * @module Core
3
+ */
4
+ import { IModelDb } from "@itwin/core-backend";
5
+ import { Id64String } from "@itwin/core-bentley";
6
+ import { Diagnostics, DiagnosticsOptions, InstanceKey } from "@itwin/presentation-common";
7
+ /** @internal */
8
+ export declare function getLocalizedStringEN(key: string): string;
9
+ /** @internal */
10
+ export declare function getElementKey(imodel: IModelDb, id: Id64String): InstanceKey | undefined;
11
+ /** @internal */
12
+ export declare function normalizeVersion(version?: string): string;
13
+ /**
14
+ * A function that received request diagnostics and, optionally, request context.
15
+ * @beta
16
+ */
17
+ export type BackendDiagnosticsHandler<TContext = any> = (logs: Diagnostics, requestContext?: TContext) => void;
18
+ /**
19
+ * Data structure for backend diagnostics options.
20
+ * @beta
21
+ */
22
+ export interface BackendDiagnosticsOptions<TContext = any> extends DiagnosticsOptions {
23
+ /**
24
+ * An optional function to supply request context that'll be passed to [[handler]] when
25
+ * it's called after the request is fulfilled.
26
+ */
27
+ requestContextSupplier?: () => TContext;
28
+ /**
29
+ * Request diagnostics handler function that is called after the request is fulfilled. The handler
30
+ * receives request diagnostics as the first argument and, optionally, request context as the
31
+ * second (see [[requestContextSupplier]]).
32
+ */
33
+ handler: BackendDiagnosticsHandler<TContext>;
34
+ }
35
+ /**
36
+ * Data structure which contains backend diagnostics options.
37
+ * @public
38
+ */
39
+ export interface BackendDiagnosticsAttribute {
40
+ /**
41
+ * Backend diagnostics options.
42
+ * @beta
43
+ */
44
+ diagnostics?: BackendDiagnosticsOptions;
45
+ }
46
+ /** @internal */
47
+ export declare function combineDiagnosticsOptions(...options: Array<BackendDiagnosticsOptions | undefined>): DiagnosticsOptions | undefined;
48
+ /** @internal */
49
+ export declare function reportDiagnostics<TContext>(diagnostics: Diagnostics, options: BackendDiagnosticsOptions<TContext>, context?: TContext): void;
50
50
  //# sourceMappingURL=Utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/Utils.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAW,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAY,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EACuD,WAAW,EAAuB,kBAAkB,EAAE,WAAW,EAC9H,MAAM,4BAA4B,CAAC;AAIpC,gBAAgB;AAChB,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,UAY/C;AAED,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;AAED;;;GAGG;AACH,oBAAY,yBAAyB,CAAC,QAAQ,GAAG,GAAG,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,cAAc,CAAC,EAAE,QAAQ,KAAK,IAAI,CAAC;AAE/G;;;GAGG;AACH,MAAM,WAAW,yBAAyB,CAAC,QAAQ,GAAG,GAAG,CAAE,SAAQ,kBAAkB;IACnF;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,QAAQ,CAAC;IAExC;;;;OAIG;IACH,OAAO,EAAE,yBAAyB,CAAC,QAAQ,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;OAGG;IACH,WAAW,CAAC,EAAE,yBAAyB,CAAC;CACzC;AAED,gBAAgB;AAChB,wBAAgB,yBAAyB,CAAC,GAAG,OAAO,EAAE,KAAK,CAAC,yBAAyB,GAAG,SAAS,CAAC,GAAG,kBAAkB,GAAG,SAAS,CAgBlI;AAED,gBAAgB;AAChB,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,yBAAyB,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,QAAQ,QAGrI"}
1
+ {"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/Utils.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAW,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAY,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EACuD,WAAW,EAAuB,kBAAkB,EAAE,WAAW,EAC9H,MAAM,4BAA4B,CAAC;AAIpC,gBAAgB;AAChB,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,UAY/C;AAED,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;AAED;;;GAGG;AACH,MAAM,MAAM,yBAAyB,CAAC,QAAQ,GAAG,GAAG,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,cAAc,CAAC,EAAE,QAAQ,KAAK,IAAI,CAAC;AAE/G;;;GAGG;AACH,MAAM,WAAW,yBAAyB,CAAC,QAAQ,GAAG,GAAG,CAAE,SAAQ,kBAAkB;IACnF;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,QAAQ,CAAC;IAExC;;;;OAIG;IACH,OAAO,EAAE,yBAAyB,CAAC,QAAQ,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;OAGG;IACH,WAAW,CAAC,EAAE,yBAAyB,CAAC;CACzC;AAED,gBAAgB;AAChB,wBAAgB,yBAAyB,CAAC,GAAG,OAAO,EAAE,KAAK,CAAC,yBAAyB,GAAG,SAAS,CAAC,GAAG,kBAAkB,GAAG,SAAS,CAgBlI;AAED,gBAAgB;AAChB,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,yBAAyB,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,QAAQ,QAGrI"}
@@ -1,108 +1,108 @@
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.reportDiagnostics = exports.combineDiagnosticsOptions = exports.normalizeVersion = exports.getElementKey = exports.getLocalizedStringEN = void 0;
11
- const semver_1 = require("semver");
12
- const core_backend_1 = require("@itwin/core-backend");
13
- const core_bentley_1 = require("@itwin/core-bentley");
14
- const presentation_common_1 = require("@itwin/presentation-common");
15
- const presentation = require("@itwin/presentation-common/lib/cjs/assets/locales/en/Presentation.json"); // eslint-disable-line @typescript-eslint/no-var-requires
16
- /** @internal */
17
- function getLocalizedStringEN(key) {
18
- let result = presentation;
19
- const [namespace, identifier] = key.split(":", 2);
20
- if (namespace !== "Presentation")
21
- return key;
22
- const keySteps = identifier.split(".");
23
- for (const keyStep of keySteps) {
24
- if (keyStep in result === false)
25
- return key;
26
- result = result[keyStep];
27
- }
28
- return typeof result === "string" ? result : key;
29
- }
30
- exports.getLocalizedStringEN = getLocalizedStringEN;
31
- /** @internal */
32
- function getElementKey(imodel, id) {
33
- let key;
34
- const query = `SELECT ECClassId FROM ${core_backend_1.Element.classFullName} e WHERE ECInstanceId = ?`;
35
- imodel.withPreparedStatement(query, (stmt) => {
36
- try {
37
- stmt.bindId(1, id);
38
- if (stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW)
39
- key = { className: stmt.getValue(0).getClassNameForClassId().replace(".", ":"), id };
40
- }
41
- catch { }
42
- });
43
- return key;
44
- }
45
- exports.getElementKey = getElementKey;
46
- /** @internal */
47
- function normalizeVersion(version) {
48
- if (version) {
49
- const parsedVersion = (0, semver_1.parse)(version, true);
50
- if (parsedVersion)
51
- return `${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch}`;
52
- }
53
- return "0.0.0";
54
- }
55
- exports.normalizeVersion = normalizeVersion;
56
- /** @internal */
57
- function combineDiagnosticsOptions(...options) {
58
- const combinedOptions = {};
59
- options.forEach((d) => {
60
- if (!d)
61
- return;
62
- if (d.perf === true || typeof d.perf === "object" && (!combinedOptions.perf || typeof combinedOptions.perf === "object" && d.perf.minimumDuration < combinedOptions.perf.minimumDuration)) {
63
- combinedOptions.perf = d.perf;
64
- }
65
- const combinedDev = (0, presentation_common_1.combineDiagnosticsSeverities)(d.dev, combinedOptions.dev);
66
- if (combinedDev)
67
- combinedOptions.dev = combinedDev;
68
- const combinedEditor = (0, presentation_common_1.combineDiagnosticsSeverities)(d.editor, combinedOptions.editor);
69
- if (combinedEditor)
70
- combinedOptions.editor = combinedEditor;
71
- });
72
- return (combinedOptions.dev || combinedOptions.editor || combinedOptions.perf) ? combinedOptions : undefined;
73
- }
74
- exports.combineDiagnosticsOptions = combineDiagnosticsOptions;
75
- /** @internal */
76
- function reportDiagnostics(diagnostics, options, context) {
77
- const stripped = diagnostics.logs ? stripDiagnostics(options, diagnostics.logs) : undefined;
78
- stripped && options.handler({ logs: stripped }, context);
79
- }
80
- exports.reportDiagnostics = reportDiagnostics;
81
- function stripDiagnostics(options, diagnostics) {
82
- const stripped = [];
83
- diagnostics.forEach((entry) => {
84
- if (presentation_common_1.DiagnosticsLogEntry.isScope(entry)) {
85
- const scopeLogs = stripDiagnostics(options, entry.logs ?? []);
86
- const strippedScope = { ...entry, logs: scopeLogs };
87
- if (!strippedScope.logs)
88
- delete strippedScope.logs;
89
- if (entry.duration !== undefined && (options.perf === true || typeof options.perf === "object" && entry.duration >= options.perf.minimumDuration)) {
90
- stripped.push(strippedScope);
91
- }
92
- else if (scopeLogs) {
93
- delete strippedScope.duration;
94
- delete strippedScope.scopeCreateTimestamp;
95
- stripped.push(strippedScope);
96
- }
97
- }
98
- else {
99
- const matchesDevSeverity = entry.severity.dev && (0, presentation_common_1.compareDiagnosticsSeverities)(entry.severity.dev, options.dev) >= 0;
100
- const matchesEditorSeverity = entry.severity.editor && (0, presentation_common_1.compareDiagnosticsSeverities)(entry.severity.editor, options.editor) >= 0;
101
- if (matchesDevSeverity || matchesEditorSeverity) {
102
- stripped.push({ ...entry });
103
- }
104
- }
105
- });
106
- return stripped.length > 0 ? stripped : undefined;
107
- }
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.reportDiagnostics = exports.combineDiagnosticsOptions = exports.normalizeVersion = exports.getElementKey = exports.getLocalizedStringEN = void 0;
11
+ const semver_1 = require("semver");
12
+ const core_backend_1 = require("@itwin/core-backend");
13
+ const core_bentley_1 = require("@itwin/core-bentley");
14
+ const presentation_common_1 = require("@itwin/presentation-common");
15
+ const presentation = require("@itwin/presentation-common/lib/cjs/assets/locales/en/Presentation.json"); // eslint-disable-line @typescript-eslint/no-var-requires
16
+ /** @internal */
17
+ function getLocalizedStringEN(key) {
18
+ let result = presentation;
19
+ const [namespace, identifier] = key.split(":", 2);
20
+ if (namespace !== "Presentation")
21
+ return key;
22
+ const keySteps = identifier.split(".");
23
+ for (const keyStep of keySteps) {
24
+ if (keyStep in result === false)
25
+ return key;
26
+ result = result[keyStep];
27
+ }
28
+ return typeof result === "string" ? result : key;
29
+ }
30
+ exports.getLocalizedStringEN = getLocalizedStringEN;
31
+ /** @internal */
32
+ function getElementKey(imodel, id) {
33
+ let key;
34
+ const query = `SELECT ECClassId FROM ${core_backend_1.Element.classFullName} e WHERE ECInstanceId = ?`;
35
+ imodel.withPreparedStatement(query, (stmt) => {
36
+ try {
37
+ stmt.bindId(1, id);
38
+ if (stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW)
39
+ key = { className: stmt.getValue(0).getClassNameForClassId().replace(".", ":"), id };
40
+ }
41
+ catch { }
42
+ });
43
+ return key;
44
+ }
45
+ exports.getElementKey = getElementKey;
46
+ /** @internal */
47
+ function normalizeVersion(version) {
48
+ if (version) {
49
+ const parsedVersion = (0, semver_1.parse)(version, true);
50
+ if (parsedVersion)
51
+ return `${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch}`;
52
+ }
53
+ return "0.0.0";
54
+ }
55
+ exports.normalizeVersion = normalizeVersion;
56
+ /** @internal */
57
+ function combineDiagnosticsOptions(...options) {
58
+ const combinedOptions = {};
59
+ options.forEach((d) => {
60
+ if (!d)
61
+ return;
62
+ if (d.perf === true || typeof d.perf === "object" && (!combinedOptions.perf || typeof combinedOptions.perf === "object" && d.perf.minimumDuration < combinedOptions.perf.minimumDuration)) {
63
+ combinedOptions.perf = d.perf;
64
+ }
65
+ const combinedDev = (0, presentation_common_1.combineDiagnosticsSeverities)(d.dev, combinedOptions.dev);
66
+ if (combinedDev)
67
+ combinedOptions.dev = combinedDev;
68
+ const combinedEditor = (0, presentation_common_1.combineDiagnosticsSeverities)(d.editor, combinedOptions.editor);
69
+ if (combinedEditor)
70
+ combinedOptions.editor = combinedEditor;
71
+ });
72
+ return (combinedOptions.dev || combinedOptions.editor || combinedOptions.perf) ? combinedOptions : undefined;
73
+ }
74
+ exports.combineDiagnosticsOptions = combineDiagnosticsOptions;
75
+ /** @internal */
76
+ function reportDiagnostics(diagnostics, options, context) {
77
+ const stripped = diagnostics.logs ? stripDiagnostics(options, diagnostics.logs) : undefined;
78
+ stripped && options.handler({ logs: stripped }, context);
79
+ }
80
+ exports.reportDiagnostics = reportDiagnostics;
81
+ function stripDiagnostics(options, diagnostics) {
82
+ const stripped = [];
83
+ diagnostics.forEach((entry) => {
84
+ if (presentation_common_1.DiagnosticsLogEntry.isScope(entry)) {
85
+ const scopeLogs = stripDiagnostics(options, entry.logs ?? []);
86
+ const strippedScope = { ...entry, logs: scopeLogs };
87
+ if (!strippedScope.logs)
88
+ delete strippedScope.logs;
89
+ if (entry.duration !== undefined && (options.perf === true || typeof options.perf === "object" && entry.duration >= options.perf.minimumDuration)) {
90
+ stripped.push(strippedScope);
91
+ }
92
+ else if (scopeLogs) {
93
+ delete strippedScope.duration;
94
+ delete strippedScope.scopeCreateTimestamp;
95
+ stripped.push(strippedScope);
96
+ }
97
+ }
98
+ else {
99
+ const matchesDevSeverity = entry.severity.dev && (0, presentation_common_1.compareDiagnosticsSeverities)(entry.severity.dev, options.dev) >= 0;
100
+ const matchesEditorSeverity = entry.severity.editor && (0, presentation_common_1.compareDiagnosticsSeverities)(entry.severity.editor, options.editor) >= 0;
101
+ if (matchesDevSeverity || matchesEditorSeverity) {
102
+ stripped.push({ ...entry });
103
+ }
104
+ }
105
+ });
106
+ return stripped.length > 0 ? stripped : undefined;
107
+ }
108
108
  //# sourceMappingURL=Utils.js.map
@@ -1,17 +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
- }
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
17
  //# sourceMappingURL=PresentationRulesDomain.d.ts.map
@@ -1,52 +1,56 @@
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 = {}));
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
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || function (mod) {
26
+ if (mod && mod.__esModule) return mod;
27
+ var result = {};
28
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
+ __setModuleDefault(result, mod);
30
+ return result;
31
+ };
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ exports.PresentationRules = void 0;
34
+ const core_backend_1 = require("@itwin/core-backend");
35
+ const RulesetElements = __importStar(require("./RulesetElements"));
36
+ /** @internal */
37
+ class PresentationRules extends core_backend_1.Schema {
38
+ static get schemaName() { return "PresentationRules"; }
39
+ /** Registers this schema and it's elements' classes */
40
+ static registerSchema() {
41
+ if (this !== core_backend_1.Schemas.getRegisteredSchema(PresentationRules.schemaName)) {
42
+ core_backend_1.Schemas.registerSchema(PresentationRules);
43
+ core_backend_1.ClassRegistry.registerModule(RulesetElements, this);
44
+ }
45
+ }
46
+ }
47
+ exports.PresentationRules = PresentationRules;
48
+ /** @internal */
49
+ /* istanbul ignore next */
50
+ (function (PresentationRules) {
51
+ let CodeSpec;
52
+ (function (CodeSpec) {
53
+ CodeSpec["Ruleset"] = "PresentationRules:Ruleset";
54
+ })(CodeSpec = PresentationRules.CodeSpec || (PresentationRules.CodeSpec = {}));
55
+ })(PresentationRules = exports.PresentationRules || (exports.PresentationRules = {}));
52
56
  //# sourceMappingURL=PresentationRulesDomain.js.map
@@ -1 +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"]}
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"]}
@@ -1,22 +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
- }
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
22
  //# sourceMappingURL=RulesetElements.d.ts.map