@itwin/presentation-backend 5.1.0-dev.37 → 5.1.0-dev.39

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 (24) hide show
  1. package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts +9 -9
  2. package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts.map +1 -1
  3. package/lib/cjs/presentation-backend/BackendLoggerCategory.js +9 -9
  4. package/lib/cjs/presentation-backend/BackendLoggerCategory.js.map +1 -1
  5. package/lib/cjs/presentation-backend/Presentation.d.ts +3 -3
  6. package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
  7. package/lib/cjs/presentation-backend/PresentationManager.d.ts +3 -3
  8. package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
  9. package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
  10. package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -1
  11. package/lib/cjs/presentation-backend/Utils.js.map +1 -1
  12. package/lib/esm/presentation-backend/BackendLoggerCategory.d.ts +9 -9
  13. package/lib/esm/presentation-backend/BackendLoggerCategory.d.ts.map +1 -1
  14. package/lib/esm/presentation-backend/BackendLoggerCategory.js +9 -9
  15. package/lib/esm/presentation-backend/BackendLoggerCategory.js.map +1 -1
  16. package/lib/esm/presentation-backend/Presentation.d.ts +3 -3
  17. package/lib/esm/presentation-backend/Presentation.js.map +1 -1
  18. package/lib/esm/presentation-backend/PresentationManager.d.ts +3 -3
  19. package/lib/esm/presentation-backend/PresentationManager.js.map +1 -1
  20. package/lib/esm/presentation-backend/SelectionScopesHelper.js.map +1 -1
  21. package/lib/esm/presentation-backend/Utils.d.ts.map +1 -1
  22. package/lib/esm/presentation-backend/Utils.js +2 -2
  23. package/lib/esm/presentation-backend/Utils.js.map +1 -1
  24. package/package.json +15 -15
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/presentation-backend/Utils.ts"],"names":[],"mapp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E,CAAC;gBACpJ,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC/B,CAAC;iBAAM,IAAI,SAAS,EAAE,CAAC;gBACrB,OAAO,aAAa,CAAC,QAAQ,CAAC;gBAC9B,OAAO,aAAa,CAAC,oBAAoB,CAAC;gBAC1C,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,kBAAkB,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,IAAI,4BAA4B,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACpH,MAAM,qBAAqB,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,IAAI,4BAA4B,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAChI,IAAI,kBAAkB,IAAI,qBAAqB,EAAE,CAAC;gBAChD,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AACpD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/* eslint-disable @typescript-eslint/ban-ts-comment */\n/** @packageDocumentation\n * @module Core\n */\n\nimport { parse as parseVersion } from \"semver\";\nimport { IModelDb } from \"@itwin/core-backend\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport {\n Diagnostics,\n DiagnosticsLogEntry,\n DiagnosticsOptions,\n InstanceKey,\n} from \"@itwin/presentation-common\";\nimport {\n combineDiagnosticsSeverities,\n compareDiagnosticsSeverities,\n} from \"@itwin/presentation-common/internal\";\n// @ts-ignore TS complains about `with` in CJS builds, but not ESM\nimport presentationStrings from \"@itwin/presentation-common/locales/en/Presentation.json\" with { type: \"json\" };\n\n/** @internal */\nexport function getLocalizedStringEN(key: string) {\n let result: object | string = presentationStrings;\n const [namespace, identifier] = key.split(\":\", 2);\n if (namespace !== \"Presentation\") {\n return key;\n }\n const keySteps = identifier.split(\".\");\n for (const keyStep of keySteps) {\n if (typeof result !== \"object\" || keyStep in result === false) {\n return key;\n }\n result = result[keyStep as keyof typeof result];\n }\n return typeof result === \"string\" ? result : key;\n}\n\n/** @internal */\nexport function getElementKey(imodel: IModelDb, id: Id64String): InstanceKey | undefined {\n const className = imodel.elements.tryGetElementProps(id)?.classFullName;\n return className ? { className, id } : undefined;\n}\n\n/** @internal */\nexport function normalizeVersion(version?: string) {\n if (version) {\n const parsedVersion = parseVersion(version, true);\n if (parsedVersion) {\n return `${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch}`;\n }\n }\n return \"0.0.0\";\n}\n\n/**\n * A function that received request diagnostics and, optionally, request context.\n * @public\n */\nexport type BackendDiagnosticsHandler<TContext = any> = (logs: Diagnostics, requestContext?: TContext) => void;\n\n/**\n * Data structure for backend diagnostics options.\n * @public\n */\nexport interface BackendDiagnosticsOptions<TContext = any> extends DiagnosticsOptions {\n /**\n * An optional function to supply request context that'll be passed to [[handler]] when\n * it's called after the request is fulfilled.\n */\n requestContextSupplier?: () => TContext;\n\n /**\n * Request diagnostics handler function that is called after the request is fulfilled. The handler\n * receives request diagnostics as the first argument and, optionally, request context as the\n * second (see [[requestContextSupplier]]).\n */\n handler: BackendDiagnosticsHandler<TContext>;\n}\n\n/**\n * Data structure which contains backend diagnostics options.\n * @public\n */\nexport interface BackendDiagnosticsAttribute {\n /**\n * Backend diagnostics options.\n * @public\n */\n diagnostics?: BackendDiagnosticsOptions;\n}\n\n/** @internal */\nexport function combineDiagnosticsOptions(...options: Array<BackendDiagnosticsOptions | undefined>): DiagnosticsOptions | undefined {\n const combinedOptions: DiagnosticsOptions = {};\n options.forEach((d) => {\n if (!d) {\n return;\n }\n if (\n d.perf === true ||\n (typeof d.perf === \"object\" &&\n (!combinedOptions.perf || (typeof combinedOptions.perf === \"object\" && d.perf.minimumDuration < combinedOptions.perf.minimumDuration)))\n ) {\n combinedOptions.perf = d.perf;\n }\n const combinedDev = combineDiagnosticsSeverities(d.dev, combinedOptions.dev);\n if (combinedDev) {\n combinedOptions.dev = combinedDev;\n }\n const combinedEditor = combineDiagnosticsSeverities(d.editor, combinedOptions.editor);\n if (combinedEditor) {\n combinedOptions.editor = combinedEditor;\n }\n });\n return combinedOptions.dev || combinedOptions.editor || combinedOptions.perf ? combinedOptions : undefined;\n}\n\n/** @internal */\nexport function reportDiagnostics<TContext>(diagnostics: Diagnostics, options: BackendDiagnosticsOptions<TContext>, context?: TContext) {\n const stripped = diagnostics.logs ? stripDiagnostics(options, diagnostics.logs) : undefined;\n stripped && options.handler({ logs: stripped }, context);\n}\nfunction stripDiagnostics<TEntry extends DiagnosticsLogEntry>(options: DiagnosticsOptions, diagnostics: TEntry[]) {\n const stripped: TEntry[] = [];\n diagnostics.forEach((entry) => {\n if (DiagnosticsLogEntry.isScope(entry)) {\n const scopeLogs = stripDiagnostics(options, entry.logs ?? []);\n const strippedScope = { ...entry, logs: scopeLogs };\n if (!strippedScope.logs) {\n delete strippedScope.logs;\n }\n if (entry.duration !== undefined && (options.perf === true || (typeof options.perf === \"object\" && entry.duration >= options.perf.minimumDuration))) {\n stripped.push(strippedScope);\n } else if (scopeLogs) {\n delete strippedScope.duration;\n delete strippedScope.scopeCreateTimestamp;\n stripped.push(strippedScope);\n }\n } else {\n const matchesDevSeverity = entry.severity.dev && compareDiagnosticsSeverities(entry.severity.dev, options.dev) >= 0;\n const matchesEditorSeverity = entry.severity.editor && compareDiagnosticsSeverities(entry.severity.editor, options.editor) >= 0;\n if (matchesDevSeverity || matchesEditorSeverity) {\n stripped.push({ ...entry });\n }\n }\n });\n return stripped.length > 0 ? stripped : undefined;\n}\n"]}
1
+ {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/presentation-backend/Utils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,sDAAsD;AACtD;;GAEG;AAEH,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,QAAQ,CAAC;AAG/C,OAAO,EAAe,mBAAmB,EAAmC,MAAM,4BAA4B,CAAC;AAC/G,OAAO,EAAE,4BAA4B,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AACjH,kEAAkE;AAClE,OAAO,mBAAmB,MAAM,yDAAyD,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAEhH,gBAAgB;AAChB,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,IAAI,MAAM,GAAoB,mBAAmB,CAAC;IAClD,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAClD,IAAI,SAAS,KAAK,cAAc,EAAE,CAAC;QACjC,OAAO,GAAG,CAAC;IACb,CAAC;IACD,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACvC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;YAC9D,OAAO,GAAG,CAAC;QACb,CAAC;QACD,MAAM,GAAG,MAAM,CAAC,OAA8B,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;AACnD,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,aAAa,CAAC,MAAgB,EAAE,EAAc;IAC5D,MAAM,SAAS,GAAG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IAAI,KAAK,IAAI,IAAI,CAAC,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC;gBACpJ,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC/B,CAAC;iBAAM,IAAI,SAAS,EAAE,CAAC;gBACrB,OAAO,aAAa,CAAC,QAAQ,CAAC;gBAC9B,OAAO,aAAa,CAAC,oBAAoB,CAAC;gBAC1C,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,kBAAkB,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,IAAI,4BAA4B,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACpH,MAAM,qBAAqB,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,IAAI,4BAA4B,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAChI,IAAI,kBAAkB,IAAI,qBAAqB,EAAE,CAAC;gBAChD,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AACpD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/* eslint-disable @typescript-eslint/ban-ts-comment */\n/** @packageDocumentation\n * @module Core\n */\n\nimport { parse as parseVersion } from \"semver\";\nimport { IModelDb } from \"@itwin/core-backend\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { Diagnostics, DiagnosticsLogEntry, DiagnosticsOptions, InstanceKey } from \"@itwin/presentation-common\";\nimport { combineDiagnosticsSeverities, compareDiagnosticsSeverities } from \"@itwin/presentation-common/internal\";\n// @ts-ignore TS complains about `with` in CJS builds, but not ESM\nimport presentationStrings from \"@itwin/presentation-common/locales/en/Presentation.json\" with { type: \"json\" };\n\n/** @internal */\nexport function getLocalizedStringEN(key: string) {\n let result: object | string = presentationStrings;\n const [namespace, identifier] = key.split(\":\", 2);\n if (namespace !== \"Presentation\") {\n return key;\n }\n const keySteps = identifier.split(\".\");\n for (const keyStep of keySteps) {\n if (typeof result !== \"object\" || keyStep in result === false) {\n return key;\n }\n result = result[keyStep as keyof typeof result];\n }\n return typeof result === \"string\" ? result : key;\n}\n\n/** @internal */\nexport function getElementKey(imodel: IModelDb, id: Id64String): InstanceKey | undefined {\n const className = imodel.elements.tryGetElementProps(id)?.classFullName;\n return className ? { className, id } : undefined;\n}\n\n/** @internal */\nexport function normalizeVersion(version?: string) {\n if (version) {\n const parsedVersion = parseVersion(version, true);\n if (parsedVersion) {\n return `${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch}`;\n }\n }\n return \"0.0.0\";\n}\n\n/**\n * A function that received request diagnostics and, optionally, request context.\n * @public\n */\nexport type BackendDiagnosticsHandler<TContext = any> = (logs: Diagnostics, requestContext?: TContext) => void;\n\n/**\n * Data structure for backend diagnostics options.\n * @public\n */\nexport interface BackendDiagnosticsOptions<TContext = any> extends DiagnosticsOptions {\n /**\n * An optional function to supply request context that'll be passed to [[handler]] when\n * it's called after the request is fulfilled.\n */\n requestContextSupplier?: () => TContext;\n\n /**\n * Request diagnostics handler function that is called after the request is fulfilled. The handler\n * receives request diagnostics as the first argument and, optionally, request context as the\n * second (see [[requestContextSupplier]]).\n */\n handler: BackendDiagnosticsHandler<TContext>;\n}\n\n/**\n * Data structure which contains backend diagnostics options.\n * @public\n */\nexport interface BackendDiagnosticsAttribute {\n /**\n * Backend diagnostics options.\n * @public\n */\n diagnostics?: BackendDiagnosticsOptions;\n}\n\n/** @internal */\nexport function combineDiagnosticsOptions(...options: Array<BackendDiagnosticsOptions | undefined>): DiagnosticsOptions | undefined {\n const combinedOptions: DiagnosticsOptions = {};\n options.forEach((d) => {\n if (!d) {\n return;\n }\n if (\n d.perf === true ||\n (typeof d.perf === \"object\" &&\n (!combinedOptions.perf || (typeof combinedOptions.perf === \"object\" && d.perf.minimumDuration < combinedOptions.perf.minimumDuration)))\n ) {\n combinedOptions.perf = d.perf;\n }\n const combinedDev = combineDiagnosticsSeverities(d.dev, combinedOptions.dev);\n if (combinedDev) {\n combinedOptions.dev = combinedDev;\n }\n const combinedEditor = combineDiagnosticsSeverities(d.editor, combinedOptions.editor);\n if (combinedEditor) {\n combinedOptions.editor = combinedEditor;\n }\n });\n return combinedOptions.dev || combinedOptions.editor || combinedOptions.perf ? combinedOptions : undefined;\n}\n\n/** @internal */\nexport function reportDiagnostics<TContext>(diagnostics: Diagnostics, options: BackendDiagnosticsOptions<TContext>, context?: TContext) {\n const stripped = diagnostics.logs ? stripDiagnostics(options, diagnostics.logs) : undefined;\n stripped && options.handler({ logs: stripped }, context);\n}\nfunction stripDiagnostics<TEntry extends DiagnosticsLogEntry>(options: DiagnosticsOptions, diagnostics: TEntry[]) {\n const stripped: TEntry[] = [];\n diagnostics.forEach((entry) => {\n if (DiagnosticsLogEntry.isScope(entry)) {\n const scopeLogs = stripDiagnostics(options, entry.logs ?? []);\n const strippedScope = { ...entry, logs: scopeLogs };\n if (!strippedScope.logs) {\n delete strippedScope.logs;\n }\n if (entry.duration !== undefined && (options.perf === true || (typeof options.perf === \"object\" && entry.duration >= options.perf.minimumDuration))) {\n stripped.push(strippedScope);\n } else if (scopeLogs) {\n delete strippedScope.duration;\n delete strippedScope.scopeCreateTimestamp;\n stripped.push(strippedScope);\n }\n } else {\n const matchesDevSeverity = entry.severity.dev && compareDiagnosticsSeverities(entry.severity.dev, options.dev) >= 0;\n const matchesEditorSeverity = entry.severity.editor && compareDiagnosticsSeverities(entry.severity.editor, options.editor) >= 0;\n if (matchesDevSeverity || matchesEditorSeverity) {\n stripped.push({ ...entry });\n }\n }\n });\n return stripped.length > 0 ? stripped : undefined;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/presentation-backend",
3
- "version": "5.1.0-dev.37",
3
+ "version": "5.1.0-dev.39",
4
4
  "description": "Backend of iTwin.js Presentation library",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -36,12 +36,12 @@
36
36
  "./package.json": "./package.json"
37
37
  },
38
38
  "peerDependencies": {
39
- "@itwin/core-bentley": "5.1.0-dev.37",
40
- "@itwin/core-backend": "5.1.0-dev.37",
41
- "@itwin/ecschema-metadata": "5.1.0-dev.37",
42
- "@itwin/presentation-common": "5.1.0-dev.37",
43
- "@itwin/core-quantity": "5.1.0-dev.37",
44
- "@itwin/core-common": "5.1.0-dev.37"
39
+ "@itwin/core-backend": "5.1.0-dev.39",
40
+ "@itwin/core-common": "5.1.0-dev.39",
41
+ "@itwin/ecschema-metadata": "5.1.0-dev.39",
42
+ "@itwin/core-bentley": "5.1.0-dev.39",
43
+ "@itwin/core-quantity": "5.1.0-dev.39",
44
+ "@itwin/presentation-common": "5.1.0-dev.39"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@itwin/eslint-plugin": "5.0.0-dev.1",
@@ -76,14 +76,14 @@
76
76
  "sinon-chai": "^3.7.0",
77
77
  "typemoq": "^2.1.0",
78
78
  "typescript": "~5.6.2",
79
- "@itwin/build-tools": "5.1.0-dev.37",
80
- "@itwin/core-backend": "5.1.0-dev.37",
81
- "@itwin/ecschema-metadata": "5.1.0-dev.37",
82
- "@itwin/core-common": "5.1.0-dev.37",
83
- "@itwin/core-quantity": "5.1.0-dev.37",
84
- "@itwin/core-bentley": "5.1.0-dev.37",
85
- "@itwin/presentation-common": "5.1.0-dev.37",
86
- "internal-tools": "3.0.0-dev.69"
79
+ "@itwin/build-tools": "5.1.0-dev.39",
80
+ "@itwin/core-backend": "5.1.0-dev.39",
81
+ "@itwin/presentation-common": "5.1.0-dev.39",
82
+ "@itwin/core-bentley": "5.1.0-dev.39",
83
+ "@itwin/core-common": "5.1.0-dev.39",
84
+ "@itwin/core-quantity": "5.1.0-dev.39",
85
+ "internal-tools": "3.0.0-dev.69",
86
+ "@itwin/ecschema-metadata": "5.1.0-dev.39"
87
87
  },
88
88
  "dependencies": {
89
89
  "@itwin/presentation-shared": "^1.2.1",