@itwin/presentation-backend 4.0.0-dev.8 → 4.0.0-dev.80

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 (59) hide show
  1. package/CHANGELOG.md +47 -1
  2. package/lib/cjs/assets/supplemental-presentation-rules/BisCore.PresentationRuleSet.json +5 -3
  3. package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts +41 -41
  4. package/lib/cjs/presentation-backend/BackendLoggerCategory.js +50 -50
  5. package/lib/cjs/presentation-backend/Constants.d.ts +8 -8
  6. package/lib/cjs/presentation-backend/Constants.js +40 -36
  7. package/lib/cjs/presentation-backend/Constants.js.map +1 -1
  8. package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +11 -11
  9. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +260 -262
  10. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
  11. package/lib/cjs/presentation-backend/NativePlatform.d.ts +87 -87
  12. package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -1
  13. package/lib/cjs/presentation-backend/NativePlatform.js +140 -140
  14. package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
  15. package/lib/cjs/presentation-backend/Presentation.d.ts +106 -106
  16. package/lib/cjs/presentation-backend/Presentation.d.ts.map +1 -1
  17. package/lib/cjs/presentation-backend/Presentation.js +148 -150
  18. package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
  19. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts +12 -12
  20. package/lib/cjs/presentation-backend/PresentationIpcHandler.js +41 -41
  21. package/lib/cjs/presentation-backend/PresentationManager.d.ts +456 -445
  22. package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
  23. package/lib/cjs/presentation-backend/PresentationManager.js +309 -311
  24. package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
  25. package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +61 -61
  26. package/lib/cjs/presentation-backend/PresentationManagerDetail.js +430 -430
  27. package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
  28. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +62 -62
  29. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
  30. package/lib/cjs/presentation-backend/PresentationRpcImpl.js +388 -388
  31. package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
  32. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts +102 -102
  33. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts.map +1 -1
  34. package/lib/cjs/presentation-backend/RulesetEmbedder.js +284 -279
  35. package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
  36. package/lib/cjs/presentation-backend/RulesetManager.d.ts +53 -53
  37. package/lib/cjs/presentation-backend/RulesetManager.js +73 -73
  38. package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts +140 -140
  39. package/lib/cjs/presentation-backend/RulesetVariablesManager.js +129 -129
  40. package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +28 -28
  41. package/lib/cjs/presentation-backend/SelectionScopesHelper.js +210 -213
  42. package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
  43. package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +123 -123
  44. package/lib/cjs/presentation-backend/TemporaryStorage.js +151 -151
  45. package/lib/cjs/presentation-backend/UpdatesTracker.d.ts +27 -27
  46. package/lib/cjs/presentation-backend/UpdatesTracker.js +54 -54
  47. package/lib/cjs/presentation-backend/Utils.d.ts +49 -49
  48. package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -1
  49. package/lib/cjs/presentation-backend/Utils.js +107 -106
  50. package/lib/cjs/presentation-backend/Utils.js.map +1 -1
  51. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.d.ts +16 -16
  52. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js +55 -51
  53. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -1
  54. package/lib/cjs/presentation-backend/domain/RulesetElements.d.ts +21 -21
  55. package/lib/cjs/presentation-backend/domain/RulesetElements.js +38 -38
  56. package/lib/cjs/presentation-backend.d.ts +19 -19
  57. package/lib/cjs/presentation-backend.js +39 -35
  58. package/lib/cjs/presentation-backend.js.map +1 -1
  59. package/package.json +18 -18
@@ -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): any;
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
  //# source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,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,yBAAyB,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,QAAQ,QAGrI"}
@@ -1,107 +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 ecPresentation = require("@itwin/presentation-common/lib/cjs/assets/locales/en/ECPresentation.json"); // eslint-disable-line @typescript-eslint/no-var-requires
16
- const rulesEngine = require("@itwin/presentation-common/lib/cjs/assets/locales/en/RulesEngine.json"); // eslint-disable-line @typescript-eslint/no-var-requires
17
- /** @internal */
18
- function getLocalizedStringEN(key) {
19
- const [namespace, identifier] = key.split(":", 2);
20
- if (namespace === "ECPresentation") {
21
- return ecPresentation[identifier];
22
- }
23
- if (namespace === "RulesEngine") {
24
- return rulesEngine[identifier];
25
- }
26
- return key;
27
- }
28
- exports.getLocalizedStringEN = getLocalizedStringEN;
29
- /** @internal */
30
- function getElementKey(imodel, id) {
31
- let key;
32
- const query = `SELECT ECClassId FROM ${core_backend_1.Element.classFullName} e WHERE ECInstanceId = ?`;
33
- imodel.withPreparedStatement(query, (stmt) => {
34
- try {
35
- stmt.bindId(1, id);
36
- if (stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW)
37
- key = { className: stmt.getValue(0).getClassNameForClassId().replace(".", ":"), id };
38
- }
39
- catch { }
40
- });
41
- return key;
42
- }
43
- exports.getElementKey = getElementKey;
44
- /** @internal */
45
- function normalizeVersion(version) {
46
- if (version) {
47
- const parsedVersion = (0, semver_1.parse)(version, true);
48
- if (parsedVersion)
49
- return `${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch}`;
50
- }
51
- return "0.0.0";
52
- }
53
- exports.normalizeVersion = normalizeVersion;
54
- /** @internal */
55
- function combineDiagnosticsOptions(...options) {
56
- const combinedOptions = {};
57
- options.forEach((d) => {
58
- if (!d)
59
- return;
60
- if (d.perf === true || typeof d.perf === "object" && (!combinedOptions.perf || typeof combinedOptions.perf === "object" && d.perf.minimumDuration < combinedOptions.perf.minimumDuration)) {
61
- combinedOptions.perf = d.perf;
62
- }
63
- const combinedDev = (0, presentation_common_1.combineDiagnosticsSeverities)(d.dev, combinedOptions.dev);
64
- if (combinedDev)
65
- combinedOptions.dev = combinedDev;
66
- const combinedEditor = (0, presentation_common_1.combineDiagnosticsSeverities)(d.editor, combinedOptions.editor);
67
- if (combinedEditor)
68
- combinedOptions.editor = combinedEditor;
69
- });
70
- return (combinedOptions.dev || combinedOptions.editor || combinedOptions.perf) ? combinedOptions : undefined;
71
- }
72
- exports.combineDiagnosticsOptions = combineDiagnosticsOptions;
73
- /** @internal */
74
- function reportDiagnostics(diagnostics, options, context) {
75
- const stripped = diagnostics.logs ? stripDiagnostics(options, diagnostics.logs) : undefined;
76
- stripped && options.handler({ logs: stripped }, context);
77
- }
78
- exports.reportDiagnostics = reportDiagnostics;
79
- function stripDiagnostics(options, diagnostics) {
80
- const stripped = [];
81
- diagnostics.forEach((entry) => {
82
- var _a;
83
- if (presentation_common_1.DiagnosticsLogEntry.isScope(entry)) {
84
- const scopeLogs = stripDiagnostics(options, (_a = entry.logs) !== null && _a !== void 0 ? _a : []);
85
- const strippedScope = { ...entry, logs: scopeLogs };
86
- if (!strippedScope.logs)
87
- delete strippedScope.logs;
88
- if (entry.duration !== undefined && (options.perf === true || typeof options.perf === "object" && entry.duration >= options.perf.minimumDuration)) {
89
- stripped.push(strippedScope);
90
- }
91
- else if (scopeLogs) {
92
- delete strippedScope.duration;
93
- delete strippedScope.scopeCreateTimestamp;
94
- stripped.push(strippedScope);
95
- }
96
- }
97
- else {
98
- const matchesDevSeverity = entry.severity.dev && (0, presentation_common_1.compareDiagnosticsSeverities)(entry.severity.dev, options.dev) >= 0;
99
- const matchesEditorSeverity = entry.severity.editor && (0, presentation_common_1.compareDiagnosticsSeverities)(entry.severity.editor, options.editor) >= 0;
100
- if (matchesDevSeverity || matchesEditorSeverity) {
101
- stripped.push({ ...entry });
102
- }
103
- }
104
- });
105
- return stripped.length > 0 ? stripped : undefined;
106
- }
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
+ }
107
108
  //# sourceMappingURL=Utils.js.map
@@ -1 +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,sDAAwD;AACxD,sDAA2D;AAC3D,oEAEoC;AAEpC,MAAM,cAAc,GAAG,OAAO,CAAC,0EAA0E,CAAC,CAAC,CAAC,yDAAyD;AACrK,MAAM,WAAW,GAAG,OAAO,CAAC,uEAAuE,CAAC,CAAC,CAAC,yDAAyD;AAE/J,gBAAgB;AAChB,SAAgB,oBAAoB,CAAC,GAAW;IAC9C,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC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,IAAI,CAAC,CAAC;YAChI,IAAI,kBAAkB,IAAI,qBAAqB,EAAE;gBAC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;aAC7B;SACF;IACH,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AACpD,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 { parse as parseVersion } from \"semver\";\r\nimport { Element, IModelDb } from \"@itwin/core-backend\";\r\nimport { DbResult, Id64String } from \"@itwin/core-bentley\";\r\nimport {\r\n combineDiagnosticsSeverities, compareDiagnosticsSeverities, Diagnostics, DiagnosticsLogEntry, DiagnosticsOptions, InstanceKey,\r\n} from \"@itwin/presentation-common\";\r\n\r\nconst ecPresentation = require(\"@itwin/presentation-common/lib/cjs/assets/locales/en/ECPresentation.json\"); // eslint-disable-line @typescript-eslint/no-var-requires\r\nconst rulesEngine = require(\"@itwin/presentation-common/lib/cjs/assets/locales/en/RulesEngine.json\"); // eslint-disable-line @typescript-eslint/no-var-requires\r\n\r\n/** @internal */\r\nexport function getLocalizedStringEN(key: string) {\r\n const [namespace, identifier] = key.split(\":\", 2);\r\n if (namespace === \"ECPresentation\") {\r\n return ecPresentation[identifier];\r\n }\r\n if (namespace === \"RulesEngine\") {\r\n return rulesEngine[identifier];\r\n }\r\n return key;\r\n}\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\r\n/**\r\n * A function that received request diagnostics and, optionally, request context.\r\n * @beta\r\n */\r\nexport type BackendDiagnosticsHandler<TContext = any> = (logs: Diagnostics, requestContext?: TContext) => void;\r\n\r\n/**\r\n * Data structure for backend diagnostics options.\r\n * @beta\r\n */\r\nexport interface BackendDiagnosticsOptions<TContext = any> extends DiagnosticsOptions {\r\n /**\r\n * An optional function to supply request context that'll be passed to [[handler]] when\r\n * it's called after the request is fulfilled.\r\n */\r\n requestContextSupplier?: () => TContext;\r\n\r\n /**\r\n * Request diagnostics handler function that is called after the request is fulfilled. The handler\r\n * receives request diagnostics as the first argument and, optionally, request context as the\r\n * second (see [[requestContextSupplier]]).\r\n */\r\n handler: BackendDiagnosticsHandler<TContext>;\r\n}\r\n\r\n/**\r\n * Data structure which contains backend diagnostics options.\r\n * @public\r\n */\r\nexport interface BackendDiagnosticsAttribute {\r\n /**\r\n * Backend diagnostics options.\r\n * @beta\r\n */\r\n diagnostics?: BackendDiagnosticsOptions;\r\n}\r\n\r\n/** @internal */\r\nexport function combineDiagnosticsOptions(...options: Array<BackendDiagnosticsOptions | undefined>): DiagnosticsOptions | undefined {\r\n const combinedOptions: DiagnosticsOptions = {};\r\n options.forEach((d) => {\r\n if (!d)\r\n return;\r\n if (d.perf === true || typeof d.perf === \"object\" && (!combinedOptions.perf || typeof combinedOptions.perf === \"object\" && d.perf.minimumDuration < combinedOptions.perf.minimumDuration)) {\r\n combinedOptions.perf = d.perf;\r\n }\r\n const combinedDev = combineDiagnosticsSeverities(d.dev, combinedOptions.dev);\r\n if (combinedDev)\r\n combinedOptions.dev = combinedDev;\r\n const combinedEditor = combineDiagnosticsSeverities(d.editor, combinedOptions.editor);\r\n if (combinedEditor)\r\n combinedOptions.editor = combinedEditor;\r\n });\r\n return (combinedOptions.dev || combinedOptions.editor || combinedOptions.perf) ? combinedOptions : undefined;\r\n}\r\n\r\n/** @internal */\r\nexport function reportDiagnostics<TContext>(diagnostics: Diagnostics, options: BackendDiagnosticsOptions<TContext>, context?: TContext) {\r\n const stripped = diagnostics.logs ? stripDiagnostics(options, diagnostics.logs) : undefined;\r\n stripped && options.handler({ logs: stripped }, context);\r\n}\r\nfunction stripDiagnostics<TEntry extends DiagnosticsLogEntry>(options: DiagnosticsOptions, diagnostics: TEntry[]) {\r\n const stripped: TEntry[] = [];\r\n diagnostics.forEach((entry) => {\r\n if (DiagnosticsLogEntry.isScope(entry)) {\r\n const scopeLogs = stripDiagnostics(options, entry.logs ?? []);\r\n const strippedScope = { ...entry, logs: scopeLogs };\r\n if (!strippedScope.logs)\r\n delete strippedScope.logs;\r\n if (entry.duration !== undefined && (options.perf === true || typeof options.perf === \"object\" && entry.duration >= options.perf.minimumDuration)) {\r\n stripped.push(strippedScope);\r\n } else if (scopeLogs) {\r\n delete strippedScope.duration;\r\n delete strippedScope.scopeCreateTimestamp;\r\n stripped.push(strippedScope);\r\n }\r\n } else {\r\n const matchesDevSeverity = entry.severity.dev && compareDiagnosticsSeverities(entry.severity.dev, options.dev) >= 0;\r\n const matchesEditorSeverity = entry.severity.editor && compareDiagnosticsSeverities(entry.severity.editor, options.editor) >= 0;\r\n if (matchesDevSeverity || matchesEditorSeverity) {\r\n stripped.push({ ...entry });\r\n }\r\n }\r\n });\r\n return stripped.length > 0 ? stripped : undefined;\r\n}\r\n"]}
1
+ {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/presentation-backend/Utils.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;G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,CAAC;aAC9B;iBAAM,IAAI,SAAS,EAAE;gBACpB,OAAO,aAAa,CAAC,QAAQ,CAAC;gBAC9B,OAAO,aAAa,CAAC,oBAAoB,CAAC;gBAC1C,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;aAC9B;SACF;aAAM;YACL,MAAM,kBAAkB,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,IAAI,IAAA,kDAA4B,EAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACpH,MAAM,qBAAqB,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,IAAI,IAAA,kDAA4B,EAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAChI,IAAI,kBAAkB,IAAI,qBAAqB,EAAE;gBAC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;aAC7B;SACF;IACH,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AACpD,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 { parse as parseVersion } from \"semver\";\r\nimport { Element, IModelDb } from \"@itwin/core-backend\";\r\nimport { DbResult, Id64String } from \"@itwin/core-bentley\";\r\nimport {\r\n combineDiagnosticsSeverities, compareDiagnosticsSeverities, Diagnostics, DiagnosticsLogEntry, DiagnosticsOptions, InstanceKey,\r\n} from \"@itwin/presentation-common\";\r\n\r\nconst presentation = require(\"@itwin/presentation-common/lib/cjs/assets/locales/en/Presentation.json\"); // eslint-disable-line @typescript-eslint/no-var-requires\r\n\r\n/** @internal */\r\nexport function getLocalizedStringEN(key: string) {\r\n let result = presentation;\r\n const [namespace, identifier] = key.split(\":\", 2);\r\n if (namespace !== \"Presentation\")\r\n return key;\r\n const keySteps = identifier.split(\".\");\r\n for (const keyStep of keySteps) {\r\n if (keyStep in result === false)\r\n return key;\r\n result = result[keyStep];\r\n }\r\n return typeof result === \"string\" ? result : key;\r\n}\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\r\n/**\r\n * A function that received request diagnostics and, optionally, request context.\r\n * @beta\r\n */\r\nexport type BackendDiagnosticsHandler<TContext = any> = (logs: Diagnostics, requestContext?: TContext) => void;\r\n\r\n/**\r\n * Data structure for backend diagnostics options.\r\n * @beta\r\n */\r\nexport interface BackendDiagnosticsOptions<TContext = any> extends DiagnosticsOptions {\r\n /**\r\n * An optional function to supply request context that'll be passed to [[handler]] when\r\n * it's called after the request is fulfilled.\r\n */\r\n requestContextSupplier?: () => TContext;\r\n\r\n /**\r\n * Request diagnostics handler function that is called after the request is fulfilled. The handler\r\n * receives request diagnostics as the first argument and, optionally, request context as the\r\n * second (see [[requestContextSupplier]]).\r\n */\r\n handler: BackendDiagnosticsHandler<TContext>;\r\n}\r\n\r\n/**\r\n * Data structure which contains backend diagnostics options.\r\n * @public\r\n */\r\nexport interface BackendDiagnosticsAttribute {\r\n /**\r\n * Backend diagnostics options.\r\n * @beta\r\n */\r\n diagnostics?: BackendDiagnosticsOptions;\r\n}\r\n\r\n/** @internal */\r\nexport function combineDiagnosticsOptions(...options: Array<BackendDiagnosticsOptions | undefined>): DiagnosticsOptions | undefined {\r\n const combinedOptions: DiagnosticsOptions = {};\r\n options.forEach((d) => {\r\n if (!d)\r\n return;\r\n if (d.perf === true || typeof d.perf === \"object\" && (!combinedOptions.perf || typeof combinedOptions.perf === \"object\" && d.perf.minimumDuration < combinedOptions.perf.minimumDuration)) {\r\n combinedOptions.perf = d.perf;\r\n }\r\n const combinedDev = combineDiagnosticsSeverities(d.dev, combinedOptions.dev);\r\n if (combinedDev)\r\n combinedOptions.dev = combinedDev;\r\n const combinedEditor = combineDiagnosticsSeverities(d.editor, combinedOptions.editor);\r\n if (combinedEditor)\r\n combinedOptions.editor = combinedEditor;\r\n });\r\n return (combinedOptions.dev || combinedOptions.editor || combinedOptions.perf) ? combinedOptions : undefined;\r\n}\r\n\r\n/** @internal */\r\nexport function reportDiagnostics<TContext>(diagnostics: Diagnostics, options: BackendDiagnosticsOptions<TContext>, context?: TContext) {\r\n const stripped = diagnostics.logs ? stripDiagnostics(options, diagnostics.logs) : undefined;\r\n stripped && options.handler({ logs: stripped }, context);\r\n}\r\nfunction stripDiagnostics<TEntry extends DiagnosticsLogEntry>(options: DiagnosticsOptions, diagnostics: TEntry[]) {\r\n const stripped: TEntry[] = [];\r\n diagnostics.forEach((entry) => {\r\n if (DiagnosticsLogEntry.isScope(entry)) {\r\n const scopeLogs = stripDiagnostics(options, entry.logs ?? []);\r\n const strippedScope = { ...entry, logs: scopeLogs };\r\n if (!strippedScope.logs)\r\n delete strippedScope.logs;\r\n if (entry.duration !== undefined && (options.perf === true || typeof options.perf === \"object\" && entry.duration >= options.perf.minimumDuration)) {\r\n stripped.push(strippedScope);\r\n } else if (scopeLogs) {\r\n delete strippedScope.duration;\r\n delete strippedScope.scopeCreateTimestamp;\r\n stripped.push(strippedScope);\r\n }\r\n } else {\r\n const matchesDevSeverity = entry.severity.dev && compareDiagnosticsSeverities(entry.severity.dev, options.dev) >= 0;\r\n const matchesEditorSeverity = entry.severity.editor && compareDiagnosticsSeverities(entry.severity.editor, options.editor) >= 0;\r\n if (matchesDevSeverity || matchesEditorSeverity) {\r\n stripped.push({ ...entry });\r\n }\r\n }\r\n });\r\n return stripped.length > 0 ? stripped : undefined;\r\n}\r\n"]}
@@ -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