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

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 (70) hide show
  1. package/CHANGELOG.md +47 -1
  2. package/lib/cjs/assets/primary-presentation-rules/ElementProperties.PresentationRuleSet.json +14 -14
  3. package/lib/cjs/assets/supplemental-presentation-rules/BisCore.PresentationRuleSet.json +726 -762
  4. package/lib/cjs/assets/supplemental-presentation-rules/Functional.PresentationRuleSet.json +139 -139
  5. package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts +41 -41
  6. package/lib/cjs/presentation-backend/BackendLoggerCategory.js +50 -50
  7. package/lib/cjs/presentation-backend/BackendLoggerCategory.js.map +1 -1
  8. package/lib/cjs/presentation-backend/Constants.d.ts +8 -8
  9. package/lib/cjs/presentation-backend/Constants.js +40 -36
  10. package/lib/cjs/presentation-backend/Constants.js.map +1 -1
  11. package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +11 -11
  12. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +272 -274
  13. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
  14. package/lib/cjs/presentation-backend/NativePlatform.d.ts +87 -87
  15. package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -1
  16. package/lib/cjs/presentation-backend/NativePlatform.js +147 -140
  17. package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
  18. package/lib/cjs/presentation-backend/Presentation.d.ts +106 -106
  19. package/lib/cjs/presentation-backend/Presentation.d.ts.map +1 -1
  20. package/lib/cjs/presentation-backend/Presentation.js +148 -150
  21. package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
  22. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts +11 -12
  23. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts.map +1 -1
  24. package/lib/cjs/presentation-backend/PresentationIpcHandler.js +30 -41
  25. package/lib/cjs/presentation-backend/PresentationIpcHandler.js.map +1 -1
  26. package/lib/cjs/presentation-backend/PresentationManager.d.ts +463 -445
  27. package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
  28. package/lib/cjs/presentation-backend/PresentationManager.js +317 -311
  29. package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
  30. package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +61 -61
  31. package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts.map +1 -1
  32. package/lib/cjs/presentation-backend/PresentationManagerDetail.js +442 -430
  33. package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
  34. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +62 -62
  35. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
  36. package/lib/cjs/presentation-backend/PresentationRpcImpl.js +388 -388
  37. package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
  38. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts +102 -102
  39. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts.map +1 -1
  40. package/lib/cjs/presentation-backend/RulesetEmbedder.js +287 -282
  41. package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
  42. package/lib/cjs/presentation-backend/RulesetManager.d.ts +53 -53
  43. package/lib/cjs/presentation-backend/RulesetManager.js +73 -73
  44. package/lib/cjs/presentation-backend/RulesetManager.js.map +1 -1
  45. package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts +140 -140
  46. package/lib/cjs/presentation-backend/RulesetVariablesManager.js +129 -129
  47. package/lib/cjs/presentation-backend/RulesetVariablesManager.js.map +1 -1
  48. package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +28 -28
  49. package/lib/cjs/presentation-backend/SelectionScopesHelper.js +226 -229
  50. package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
  51. package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +123 -123
  52. package/lib/cjs/presentation-backend/TemporaryStorage.js +151 -151
  53. package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -1
  54. package/lib/cjs/presentation-backend/UpdatesTracker.d.ts +27 -27
  55. package/lib/cjs/presentation-backend/UpdatesTracker.js +54 -54
  56. package/lib/cjs/presentation-backend/UpdatesTracker.js.map +1 -1
  57. package/lib/cjs/presentation-backend/Utils.d.ts +49 -49
  58. package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -1
  59. package/lib/cjs/presentation-backend/Utils.js +107 -106
  60. package/lib/cjs/presentation-backend/Utils.js.map +1 -1
  61. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.d.ts +16 -16
  62. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js +55 -51
  63. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -1
  64. package/lib/cjs/presentation-backend/domain/RulesetElements.d.ts +21 -21
  65. package/lib/cjs/presentation-backend/domain/RulesetElements.js +38 -38
  66. package/lib/cjs/presentation-backend/domain/RulesetElements.js.map +1 -1
  67. package/lib/cjs/presentation-backend.d.ts +19 -19
  68. package/lib/cjs/presentation-backend.js +39 -35
  69. package/lib/cjs/presentation-backend.js.map +1 -1
  70. package/package.json +20 -18
@@ -1 +1 @@
1
- {"version":3,"file":"ElementPropertiesHelper.js","sourceRoot":"","sources":["../../../src/presentation-backend/ElementPropertiesHelper.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,sDAAyE;AACzE,oEAKoC;AAEpC,gBAAgB;AACT,MAAM,uBAAuB,GAAG,CAAC,OAA4B,EAAuB,EAAE;IAC3F,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC;QAC7C,OAAO,EAAE,CAAC;IAEZ,MAAM,OAAO,GAAG,IAAI,wBAAwB,EAAE,CAAC;IAC/C,IAAA,qCAAe,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,OAAO,CAAC,KA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AC,CAAC;IAC7D,WAAW,KAAW,CAAC;IAEvB,WAAW,CAAC,KAAuB;QACxC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC,CAAC;QAChF,OAAO,IAAI,CAAC;IACd,CAAC;IACM,YAAY,KAAW,IAAI,CAAC,eAAe,CAAC,GAAG,EAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAE9D,UAAU,CAAC,KAAsB;QACtC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC,CAAC;QAC/E,OAAO,IAAI,CAAC;IACd,CAAC;IACM,WAAW,KAAW,IAAI,CAAC,eAAe,CAAC,GAAG,EAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAE7D,kBAAkB,CAAC,KAA8B;QACtD,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE;YACpD,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,EAAE;SACV,CAAC,CAAC;IACL,CAAC;IACM,qBAAqB,CAAC,KAAiC;;QAC5D,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE;YAC9C,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,MAAA,MAAA,KAAK,CAAC,YAAY,0CAAE,QAAQ,EAAE,mCAAI,EAAE;SAC5C,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { ECSqlStatement, IModelDb } from \"@itwin/core-backend\";\r\nimport { assert, DbResult, Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport {\r\n CategoryDescription, Content, ElementProperties, ElementPropertiesItem, ElementPropertiesPrimitiveArrayPropertyItem, ElementPropertiesPropertyItem,\r\n ElementPropertiesStructArrayPropertyItem, IContentVisitor, Item, PresentationError, PresentationStatus, ProcessFieldHierarchiesProps, ProcessMergedValueProps,\r\n ProcessPrimitiveValueProps, PropertyValueFormat, StartArrayProps, StartCategoryProps, StartContentProps, StartFieldProps, StartItemProps,\r\n StartStructProps, traverseContent,\r\n} from \"@itwin/presentation-common\";\r\n\r\n/** @internal */\r\nexport const buildElementsProperties = (content: Content | undefined): ElementProperties[] => {\r\n if (!content || content.contentSet.length === 0)\r\n return [];\r\n\r\n const builder = new ElementPropertiesBuilder();\r\n traverseContent(builder, content);\r\n return builder.items;\r\n};\r\n\r\n/** @internal */\r\nexport function getElementsCount(db: IModelDb, classNames?: string[]) {\r\n const filter = createElementsFilter(\"e\", classNames);\r\n const query = `\r\n SELECT COUNT(e.ECInstanceId)\r\n FROM bis.Element e\r\n ${filter ? `WHERE ${filter}` : \"\"}\r\n `;\r\n\r\n return db.withPreparedStatement(query, (stmt: ECSqlStatement) => {\r\n return stmt.step() === DbResult.BE_SQLITE_ROW ? stmt.getValue(0).getInteger() : 0;\r\n });\r\n}\r\n\r\n/** @internal */\r\nexport function* iterateElementIds(db: IModelDb, classNames?: string[], limit?: number) {\r\n let lastElementId;\r\n while (true) {\r\n const result = queryElementIds(db, classNames, limit, lastElementId);\r\n yield result.ids;\r\n lastElementId = result.lastElementId;\r\n if (!lastElementId)\r\n break;\r\n }\r\n}\r\n\r\nfunction queryElementIds(db: IModelDb, classNames?: string[], limit?: number, lastElementId?: Id64String) {\r\n function createWhereClause() {\r\n const classFilter = createElementsFilter(\"e\", classNames);\r\n const elementFilter = lastElementId ? `e.ECInstanceId > ?` : undefined;\r\n if (!classFilter && !elementFilter)\r\n return \"\";\r\n if (classFilter && elementFilter)\r\n return `WHERE ${classFilter} AND ${elementFilter}`;\r\n return `WHERE ${classFilter ?? \"\"} ${elementFilter ?? \"\"}`;\r\n }\r\n\r\n const query = `\r\n SELECT e.ECInstanceId elId, eSchemaDef.Name || ':' || eClassDef.Name elClassName\r\n FROM bis.Element e\r\n LEFT JOIN meta.ECClassDef eClassDef ON eClassDef.ECInstanceId = e.ECClassId\r\n LEFT JOIN meta.ECSchemaDef eSchemaDef ON eSchemaDef.ECInstanceId = eClassDef.Schema.Id\r\n ${createWhereClause()}\r\n ORDER BY e.ECInstanceId ASC\r\n `;\r\n\r\n return db.withPreparedStatement(query, (stmt: ECSqlStatement) => {\r\n if (lastElementId)\r\n stmt.bindId(1, lastElementId);\r\n\r\n const ids = new Map<string, string[]>();\r\n let currentClassName = \"\";\r\n let currentIds: string[] = [];\r\n let loadedIds = 0;\r\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\r\n const row = stmt.getRow();\r\n if (!row.elId || !row.elClassName)\r\n continue;\r\n\r\n if (currentClassName !== row.elClassName) {\r\n currentClassName = row.elClassName;\r\n const existingIds = ids.get(row.elClassName);\r\n if (!existingIds) {\r\n currentIds = [];\r\n ids.set(row.elClassName, currentIds);\r\n } else {\r\n currentIds = existingIds;\r\n }\r\n }\r\n currentIds.push(row.elId);\r\n loadedIds++;\r\n if (limit && loadedIds >= limit)\r\n return { ids, lastElementId: row.elId };\r\n }\r\n return { ids, lastElementId: undefined };\r\n });\r\n}\r\n\r\nfunction createElementsFilter(elementAlias: string, classNames?: string[]) {\r\n if (classNames === undefined || classNames.length === 0)\r\n return undefined;\r\n\r\n // check if list contains only valid class names\r\n const classNameRegExp = new RegExp(/^[\\w]+[.:][\\w]+$/);\r\n const invalidName = classNames.find((name) => !name.match(classNameRegExp));\r\n if (invalidName) {\r\n throw new PresentationError(PresentationStatus.InvalidArgument, `Encountered invalid class name - ${invalidName}.\r\n Valid class name formats: \"<schema name or alias>.<class name>\", \"<schema name or alias>:<class name>\"`);\r\n }\r\n\r\n return `${elementAlias}.ECClassId IS (${classNames.join(\",\")})`;\r\n}\r\n\r\ninterface IPropertiesAppender {\r\n append(label: string, item: ElementPropertiesItem): void;\r\n finish(): void;\r\n}\r\n\r\nclass ElementPropertiesAppender implements IPropertiesAppender {\r\n private _propertyItems: { [label: string]: ElementPropertiesItem } = {};\r\n private _categoryItemAppenders: { [categoryName: string]: IPropertiesAppender } = {};\r\n constructor(private _item: Item, private _onItemFinished: (item: ElementProperties) => void) { }\r\n\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n this._propertyItems[label] = item;\r\n }\r\n\r\n public finish(): void {\r\n // eslint-disable-next-line guard-for-in\r\n for (const categoryName in this._categoryItemAppenders) {\r\n const appender = this._categoryItemAppenders[categoryName];\r\n appender.finish();\r\n }\r\n\r\n this._onItemFinished({\r\n class: this._item.classInfo?.label ?? \"\",\r\n id: this._item.primaryKeys[0]?.id ?? Id64.invalid,\r\n label: this._item.label.displayValue,\r\n items: this._propertyItems,\r\n });\r\n }\r\n\r\n public getCategoryAppender(parentAppender: IPropertiesAppender, category: CategoryDescription): IPropertiesAppender {\r\n let appender = this._categoryItemAppenders[category.name];\r\n if (!appender) {\r\n appender = new CategoryItemAppender(parentAppender, category);\r\n this._categoryItemAppenders[category.name] = appender;\r\n }\r\n return appender;\r\n }\r\n}\r\n\r\nclass CategoryItemAppender implements IPropertiesAppender {\r\n private _items: { [label: string]: ElementPropertiesItem } = {};\r\n constructor(private _parentAppender: IPropertiesAppender, private _category: CategoryDescription) { }\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n this._items[label] = item;\r\n }\r\n public finish(): void {\r\n if (Object.keys(this._items).length === 0)\r\n return;\r\n\r\n this._parentAppender.append(this._category.label, {\r\n type: \"category\",\r\n items: this._items,\r\n });\r\n }\r\n}\r\n\r\nclass ArrayItemAppender implements IPropertiesAppender {\r\n private _items: ElementPropertiesPropertyItem[] = [];\r\n constructor(private _parentAppender: IPropertiesAppender, private _props: StartArrayProps) { }\r\n public append(_label: string, item: ElementPropertiesItem): void {\r\n assert(item.type !== \"category\");\r\n this._items.push(item);\r\n }\r\n public finish(): void {\r\n assert(this._props.valueType.valueFormat === PropertyValueFormat.Array);\r\n if (this._props.valueType.memberType.valueFormat === PropertyValueFormat.Primitive)\r\n this._parentAppender.append(this._props.hierarchy.field.label, this.createPrimitivesArray());\r\n else\r\n this._parentAppender.append(this._props.hierarchy.field.label, this.createStructsArray());\r\n }\r\n private createPrimitivesArray(): ElementPropertiesPrimitiveArrayPropertyItem {\r\n return {\r\n type: \"array\",\r\n valueType: \"primitive\",\r\n values: this._items.map((item) => {\r\n assert(item.type === \"primitive\");\r\n return item.value;\r\n }),\r\n };\r\n }\r\n private createStructsArray(): ElementPropertiesStructArrayPropertyItem {\r\n return {\r\n type: \"array\",\r\n valueType: \"struct\",\r\n values: this._items.map((item) => {\r\n assert(item.type === \"struct\");\r\n return item.members;\r\n }),\r\n };\r\n }\r\n}\r\n\r\nclass StructItemAppender implements IPropertiesAppender {\r\n private _members: { [label: string]: ElementPropertiesPropertyItem } = {};\r\n constructor(private _parentAppender: IPropertiesAppender, private _props: StartStructProps) { }\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n assert(item.type !== \"category\");\r\n this._members[label] = item;\r\n }\r\n public finish(): void {\r\n assert(this._props.valueType.valueFormat === PropertyValueFormat.Struct);\r\n this._parentAppender.append(this._props.hierarchy.field.label, {\r\n type: \"struct\",\r\n members: this._members,\r\n });\r\n }\r\n}\r\n\r\nclass ElementPropertiesBuilder implements IContentVisitor {\r\n private _appendersStack: IPropertiesAppender[] = [];\r\n private _items: ElementProperties[] = [];\r\n private _elementPropertiesAppender: ElementPropertiesAppender | undefined;\r\n\r\n public get items(): ElementProperties[] {\r\n return this._items;\r\n }\r\n\r\n private get _currentAppender(): IPropertiesAppender {\r\n const appender = this._appendersStack[this._appendersStack.length - 1];\r\n assert(appender !== undefined);\r\n return appender;\r\n }\r\n\r\n public startContent(_props: StartContentProps): boolean { return true; }\r\n public finishContent(): void { }\r\n\r\n public processFieldHierarchies(_props: ProcessFieldHierarchiesProps): void { }\r\n\r\n public startItem(props: StartItemProps): boolean {\r\n this._elementPropertiesAppender = new ElementPropertiesAppender(props.item, (item) => this._items.push(item));\r\n this._appendersStack.push(this._elementPropertiesAppender);\r\n return true;\r\n }\r\n public finishItem(): void {\r\n this._appendersStack.pop();\r\n assert(this._elementPropertiesAppender !== undefined);\r\n this._elementPropertiesAppender.finish();\r\n this._elementPropertiesAppender = undefined;\r\n }\r\n\r\n public startCategory(props: StartCategoryProps): boolean {\r\n assert(this._elementPropertiesAppender !== undefined);\r\n this._appendersStack.push(this._elementPropertiesAppender.getCategoryAppender(this._currentAppender, props.category));\r\n return true;\r\n }\r\n public finishCategory(): void {\r\n this._appendersStack.pop();\r\n }\r\n\r\n public startField(_props: StartFieldProps): boolean { return true; }\r\n public finishField(): void { }\r\n\r\n public startStruct(props: StartStructProps): boolean {\r\n this._appendersStack.push(new StructItemAppender(this._currentAppender, props));\r\n return true;\r\n }\r\n public finishStruct(): void { this._appendersStack.pop()!.finish(); }\r\n\r\n public startArray(props: StartArrayProps): boolean {\r\n this._appendersStack.push(new ArrayItemAppender(this._currentAppender, props));\r\n return true;\r\n }\r\n public finishArray(): void { this._appendersStack.pop()!.finish(); }\r\n\r\n public processMergedValue(props: ProcessMergedValueProps): void {\r\n this._currentAppender.append(props.mergedField.label, {\r\n type: \"primitive\",\r\n value: \"\",\r\n });\r\n }\r\n public processPrimitiveValue(props: ProcessPrimitiveValueProps): void {\r\n this._currentAppender.append(props.field.label, {\r\n type: \"primitive\",\r\n value: props.displayValue?.toString() ?? \"\",\r\n });\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ElementPropertiesHelper.js","sourceRoot":"","sources":["../../../src/presentation-backend/ElementPropertiesHelper.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,sDAAyE;AACzE,oEAKoC;AAEpC,gBAAgB;AACT,MAAM,uBAAuB,GAAG,CAAC,OAA4B,EAA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CAAC;QACtH,OAAO,IAAI,CAAC;IACd,CAAC;IACM,cAAc;QACnB,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC;IAC7B,CAAC;IAEM,UAAU,CAAC,MAAuB,IAAa,OAAO,IAAI,CAAC,CAAC,CAAC;IAC7D,WAAW,KAAW,CAAC;IAEvB,WAAW,CAAC,KAAuB;QACxC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC,CAAC;QAChF,OAAO,IAAI,CAAC;IACd,CAAC;IACM,YAAY,KAAW,IAAI,CAAC,eAAe,CAAC,GAAG,EAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAE9D,UAAU,CAAC,KAAsB;QACtC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC,CAAC;QAC/E,OAAO,IAAI,CAAC;IACd,CAAC;IACM,WAAW,KAAW,IAAI,CAAC,eAAe,CAAC,GAAG,EAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAE7D,kBAAkB,CAAC,KAA8B;QACtD,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE;YACpD,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,EAAE;SACV,CAAC,CAAC;IACL,CAAC;IACM,qBAAqB,CAAC,KAAiC;QAC5D,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE;YAC9C,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,KAAK,CAAC,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE;SAC5C,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Core\n */\n\nimport { ECSqlStatement, IModelDb } from \"@itwin/core-backend\";\nimport { assert, DbResult, Id64, Id64String } from \"@itwin/core-bentley\";\nimport {\n CategoryDescription, Content, ElementProperties, ElementPropertiesItem, ElementPropertiesPrimitiveArrayPropertyItem, ElementPropertiesPropertyItem,\n ElementPropertiesStructArrayPropertyItem, IContentVisitor, Item, PresentationError, PresentationStatus, ProcessFieldHierarchiesProps, ProcessMergedValueProps,\n ProcessPrimitiveValueProps, PropertyValueFormat, StartArrayProps, StartCategoryProps, StartContentProps, StartFieldProps, StartItemProps,\n StartStructProps, traverseContent,\n} from \"@itwin/presentation-common\";\n\n/** @internal */\nexport const buildElementsProperties = (content: Content | undefined): ElementProperties[] => {\n if (!content || content.contentSet.length === 0)\n return [];\n\n const builder = new ElementPropertiesBuilder();\n traverseContent(builder, content);\n return builder.items;\n};\n\n/** @internal */\nexport function getElementsCount(db: IModelDb, classNames?: string[]) {\n const filter = createElementsFilter(\"e\", classNames);\n const query = `\n SELECT COUNT(e.ECInstanceId)\n FROM bis.Element e\n ${filter ? `WHERE ${filter}` : \"\"}\n `;\n\n return db.withPreparedStatement(query, (stmt: ECSqlStatement) => {\n return stmt.step() === DbResult.BE_SQLITE_ROW ? stmt.getValue(0).getInteger() : 0;\n });\n}\n\n/** @internal */\nexport function* iterateElementIds(db: IModelDb, classNames?: string[], limit?: number) {\n let lastElementId;\n while (true) {\n const result = queryElementIds(db, classNames, limit, lastElementId);\n yield result.ids;\n lastElementId = result.lastElementId;\n if (!lastElementId)\n break;\n }\n}\n\nfunction queryElementIds(db: IModelDb, classNames?: string[], limit?: number, lastElementId?: Id64String) {\n function createWhereClause() {\n const classFilter = createElementsFilter(\"e\", classNames);\n const elementFilter = lastElementId ? `e.ECInstanceId > ?` : undefined;\n if (!classFilter && !elementFilter)\n return \"\";\n if (classFilter && elementFilter)\n return `WHERE ${classFilter} AND ${elementFilter}`;\n return `WHERE ${classFilter ?? \"\"} ${elementFilter ?? \"\"}`;\n }\n\n const query = `\n SELECT e.ECInstanceId elId, eSchemaDef.Name || ':' || eClassDef.Name elClassName\n FROM bis.Element e\n LEFT JOIN meta.ECClassDef eClassDef ON eClassDef.ECInstanceId = e.ECClassId\n LEFT JOIN meta.ECSchemaDef eSchemaDef ON eSchemaDef.ECInstanceId = eClassDef.Schema.Id\n ${createWhereClause()}\n ORDER BY e.ECInstanceId ASC\n `;\n\n return db.withPreparedStatement(query, (stmt: ECSqlStatement) => {\n if (lastElementId)\n stmt.bindId(1, lastElementId);\n\n const ids = new Map<string, string[]>();\n let currentClassName = \"\";\n let currentIds: string[] = [];\n let loadedIds = 0;\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\n const row = stmt.getRow();\n if (!row.elId || !row.elClassName)\n continue;\n\n if (currentClassName !== row.elClassName) {\n currentClassName = row.elClassName;\n const existingIds = ids.get(row.elClassName);\n if (!existingIds) {\n currentIds = [];\n ids.set(row.elClassName, currentIds);\n } else {\n currentIds = existingIds;\n }\n }\n currentIds.push(row.elId);\n loadedIds++;\n if (limit && loadedIds >= limit)\n return { ids, lastElementId: row.elId };\n }\n return { ids, lastElementId: undefined };\n });\n}\n\nfunction createElementsFilter(elementAlias: string, classNames?: string[]) {\n if (classNames === undefined || classNames.length === 0)\n return undefined;\n\n // check if list contains only valid class names\n const classNameRegExp = new RegExp(/^[\\w]+[.:][\\w]+$/);\n const invalidName = classNames.find((name) => !name.match(classNameRegExp));\n if (invalidName) {\n throw new PresentationError(PresentationStatus.InvalidArgument, `Encountered invalid class name - ${invalidName}.\n Valid class name formats: \"<schema name or alias>.<class name>\", \"<schema name or alias>:<class name>\"`);\n }\n\n return `${elementAlias}.ECClassId IS (${classNames.join(\",\")})`;\n}\n\ninterface IPropertiesAppender {\n append(label: string, item: ElementPropertiesItem): void;\n finish(): void;\n}\n\nclass ElementPropertiesAppender implements IPropertiesAppender {\n private _propertyItems: { [label: string]: ElementPropertiesItem } = {};\n private _categoryItemAppenders: { [categoryName: string]: IPropertiesAppender } = {};\n constructor(private _item: Item, private _onItemFinished: (item: ElementProperties) => void) { }\n\n public append(label: string, item: ElementPropertiesItem): void {\n this._propertyItems[label] = item;\n }\n\n public finish(): void {\n // eslint-disable-next-line guard-for-in\n for (const categoryName in this._categoryItemAppenders) {\n const appender = this._categoryItemAppenders[categoryName];\n appender.finish();\n }\n\n this._onItemFinished({\n class: this._item.classInfo?.label ?? \"\",\n id: this._item.primaryKeys[0]?.id ?? Id64.invalid,\n label: this._item.label.displayValue,\n items: this._propertyItems,\n });\n }\n\n public getCategoryAppender(parentAppender: IPropertiesAppender, category: CategoryDescription): IPropertiesAppender {\n let appender = this._categoryItemAppenders[category.name];\n if (!appender) {\n appender = new CategoryItemAppender(parentAppender, category);\n this._categoryItemAppenders[category.name] = appender;\n }\n return appender;\n }\n}\n\nclass CategoryItemAppender implements IPropertiesAppender {\n private _items: { [label: string]: ElementPropertiesItem } = {};\n constructor(private _parentAppender: IPropertiesAppender, private _category: CategoryDescription) { }\n public append(label: string, item: ElementPropertiesItem): void {\n this._items[label] = item;\n }\n public finish(): void {\n if (Object.keys(this._items).length === 0)\n return;\n\n this._parentAppender.append(this._category.label, {\n type: \"category\",\n items: this._items,\n });\n }\n}\n\nclass ArrayItemAppender implements IPropertiesAppender {\n private _items: ElementPropertiesPropertyItem[] = [];\n constructor(private _parentAppender: IPropertiesAppender, private _props: StartArrayProps) { }\n public append(_label: string, item: ElementPropertiesItem): void {\n assert(item.type !== \"category\");\n this._items.push(item);\n }\n public finish(): void {\n assert(this._props.valueType.valueFormat === PropertyValueFormat.Array);\n if (this._props.valueType.memberType.valueFormat === PropertyValueFormat.Primitive)\n this._parentAppender.append(this._props.hierarchy.field.label, this.createPrimitivesArray());\n else\n this._parentAppender.append(this._props.hierarchy.field.label, this.createStructsArray());\n }\n private createPrimitivesArray(): ElementPropertiesPrimitiveArrayPropertyItem {\n return {\n type: \"array\",\n valueType: \"primitive\",\n values: this._items.map((item) => {\n assert(item.type === \"primitive\");\n return item.value;\n }),\n };\n }\n private createStructsArray(): ElementPropertiesStructArrayPropertyItem {\n return {\n type: \"array\",\n valueType: \"struct\",\n values: this._items.map((item) => {\n assert(item.type === \"struct\");\n return item.members;\n }),\n };\n }\n}\n\nclass StructItemAppender implements IPropertiesAppender {\n private _members: { [label: string]: ElementPropertiesPropertyItem } = {};\n constructor(private _parentAppender: IPropertiesAppender, private _props: StartStructProps) { }\n public append(label: string, item: ElementPropertiesItem): void {\n assert(item.type !== \"category\");\n this._members[label] = item;\n }\n public finish(): void {\n assert(this._props.valueType.valueFormat === PropertyValueFormat.Struct);\n this._parentAppender.append(this._props.hierarchy.field.label, {\n type: \"struct\",\n members: this._members,\n });\n }\n}\n\nclass ElementPropertiesBuilder implements IContentVisitor {\n private _appendersStack: IPropertiesAppender[] = [];\n private _items: ElementProperties[] = [];\n private _elementPropertiesAppender: ElementPropertiesAppender | undefined;\n\n public get items(): ElementProperties[] {\n return this._items;\n }\n\n private get _currentAppender(): IPropertiesAppender {\n const appender = this._appendersStack[this._appendersStack.length - 1];\n assert(appender !== undefined);\n return appender;\n }\n\n public startContent(_props: StartContentProps): boolean { return true; }\n public finishContent(): void { }\n\n public processFieldHierarchies(_props: ProcessFieldHierarchiesProps): void { }\n\n public startItem(props: StartItemProps): boolean {\n this._elementPropertiesAppender = new ElementPropertiesAppender(props.item, (item) => this._items.push(item));\n this._appendersStack.push(this._elementPropertiesAppender);\n return true;\n }\n public finishItem(): void {\n this._appendersStack.pop();\n assert(this._elementPropertiesAppender !== undefined);\n this._elementPropertiesAppender.finish();\n this._elementPropertiesAppender = undefined;\n }\n\n public startCategory(props: StartCategoryProps): boolean {\n assert(this._elementPropertiesAppender !== undefined);\n this._appendersStack.push(this._elementPropertiesAppender.getCategoryAppender(this._currentAppender, props.category));\n return true;\n }\n public finishCategory(): void {\n this._appendersStack.pop();\n }\n\n public startField(_props: StartFieldProps): boolean { return true; }\n public finishField(): void { }\n\n public startStruct(props: StartStructProps): boolean {\n this._appendersStack.push(new StructItemAppender(this._currentAppender, props));\n return true;\n }\n public finishStruct(): void { this._appendersStack.pop()!.finish(); }\n\n public startArray(props: StartArrayProps): boolean {\n this._appendersStack.push(new ArrayItemAppender(this._currentAppender, props));\n return true;\n }\n public finishArray(): void { this._appendersStack.pop()!.finish(); }\n\n public processMergedValue(props: ProcessMergedValueProps): void {\n this._currentAppender.append(props.mergedField.label, {\n type: \"primitive\",\n value: \"\",\n });\n }\n public processPrimitiveValue(props: ProcessPrimitiveValueProps): void {\n this._currentAppender.append(props.field.label, {\n type: \"primitive\",\n value: props.displayValue?.toString() ?? \"\",\n });\n }\n}\n"]}
@@ -1,88 +1,88 @@
1
- /** @packageDocumentation
2
- * @module Core
3
- */
4
- import { IModelDb, IModelJsNative } from "@itwin/core-backend";
5
- import { BeEvent, IDisposable } from "@itwin/core-bentley";
6
- import { FormatProps } from "@itwin/core-quantity";
7
- import { DiagnosticsScopeLogs, NodeKey, UpdateInfoJSON, VariableValue, VariableValueTypes } from "@itwin/presentation-common";
8
- /** @internal */
9
- export declare enum NativePlatformRequestTypes {
10
- GetRootNodes = "GetRootNodes",
11
- GetRootNodesCount = "GetRootNodesCount",
12
- GetChildren = "GetChildren",
13
- GetChildrenCount = "GetChildrenCount",
14
- GetNodesDescriptor = "GetNodesDescriptor",
15
- GetNodePaths = "GetNodePaths",
16
- GetFilteredNodePaths = "GetFilteredNodePaths",
17
- GetContentSources = "GetContentSources",
18
- GetContentDescriptor = "GetContentDescriptor",
19
- GetContentSetSize = "GetContentSetSize",
20
- GetContent = "GetContent",
21
- GetPagedDistinctValues = "GetPagedDistinctValues",
22
- GetDisplayLabel = "GetDisplayLabel",
23
- CompareHierarchies = "CompareHierarchies"
24
- }
25
- /**
26
- * Enumeration of unit systems supported by native presentation manager.
27
- * @internal
28
- */
29
- export declare enum NativePresentationUnitSystem {
30
- Metric = "metric",
31
- BritishImperial = "british-imperial",
32
- UsCustomary = "us-customary",
33
- UsSurvey = "us-survey"
34
- }
35
- /** @internal */
36
- export interface NativePresentationDefaultUnitFormats {
37
- [phenomenon: string]: {
38
- unitSystems: NativePresentationUnitSystem[];
39
- format: FormatProps;
40
- };
41
- }
42
- /** @internal */
43
- export interface NativePresentationKeySetJSON {
44
- instanceKeys: Array<[string, string[]]>;
45
- nodeKeys: NodeKey[];
46
- }
47
- /** @internal */
48
- export interface NativePlatformResponse<TResult> {
49
- result: TResult;
50
- diagnostics?: DiagnosticsScopeLogs;
51
- }
52
- /** @internal */
53
- export interface NativePlatformDefinition extends IDisposable {
54
- getImodelAddon(imodel: IModelDb): any;
55
- setupRulesetDirectories(directories: string[]): NativePlatformResponse<void>;
56
- setupSupplementalRulesetDirectories(directories: string[]): NativePlatformResponse<void>;
57
- forceLoadSchemas(db: any): Promise<NativePlatformResponse<void>>;
58
- getRulesets(rulesetId: string): NativePlatformResponse<string>;
59
- addRuleset(serializedRulesetJson: string): NativePlatformResponse<string>;
60
- removeRuleset(rulesetId: string, hash: string): NativePlatformResponse<boolean>;
61
- clearRulesets(): NativePlatformResponse<void>;
62
- handleRequest(db: any, options: string, cancelEvent?: BeEvent<() => void>): Promise<NativePlatformResponse<string>>;
63
- getRulesetVariableValue(rulesetId: string, variableId: string, type: VariableValueTypes): NativePlatformResponse<VariableValue>;
64
- setRulesetVariableValue(rulesetId: string, variableId: string, type: VariableValueTypes, value: VariableValue): NativePlatformResponse<void>;
65
- unsetRulesetVariableValue(rulesetId: string, variableId: string): NativePlatformResponse<void>;
66
- getUpdateInfo(): NativePlatformResponse<UpdateInfoJSON | undefined>;
67
- updateHierarchyState(db: any, rulesetId: string, stateChanges: Array<{
68
- nodeKey: undefined | NodeKey;
69
- isExpanded?: boolean;
70
- instanceFilters?: string[];
71
- }>): NativePlatformResponse<void>;
72
- }
73
- /** @internal */
74
- export interface DefaultNativePlatformProps {
75
- id: string;
76
- taskAllocationsMap: {
77
- [priority: number]: number;
78
- };
79
- isChangeTrackingEnabled: boolean;
80
- cacheConfig?: IModelJsNative.ECPresentationHierarchyCacheConfig;
81
- contentCacheSize?: number;
82
- workerConnectionCacheSize?: number;
83
- defaultFormats?: NativePresentationDefaultUnitFormats;
84
- useMmap?: boolean | number;
85
- }
86
- /** @internal */
87
- export declare const createDefaultNativePlatform: (props: DefaultNativePlatformProps) => new () => NativePlatformDefinition;
1
+ /** @packageDocumentation
2
+ * @module Core
3
+ */
4
+ import { IModelDb, IModelJsNative } from "@itwin/core-backend";
5
+ import { BeEvent, IDisposable } from "@itwin/core-bentley";
6
+ import { FormatProps } from "@itwin/core-quantity";
7
+ import { DiagnosticsScopeLogs, NodeKey, PresentationError, UpdateInfo, VariableValue, VariableValueTypes } from "@itwin/presentation-common";
8
+ /** @internal */
9
+ export declare enum NativePlatformRequestTypes {
10
+ GetRootNodes = "GetRootNodes",
11
+ GetRootNodesCount = "GetRootNodesCount",
12
+ GetChildren = "GetChildren",
13
+ GetChildrenCount = "GetChildrenCount",
14
+ GetNodesDescriptor = "GetNodesDescriptor",
15
+ GetNodePaths = "GetNodePaths",
16
+ GetFilteredNodePaths = "GetFilteredNodePaths",
17
+ GetContentSources = "GetContentSources",
18
+ GetContentDescriptor = "GetContentDescriptor",
19
+ GetContentSetSize = "GetContentSetSize",
20
+ GetContent = "GetContent",
21
+ GetPagedDistinctValues = "GetPagedDistinctValues",
22
+ GetDisplayLabel = "GetDisplayLabel",
23
+ CompareHierarchies = "CompareHierarchies"
24
+ }
25
+ /**
26
+ * Enumeration of unit systems supported by native presentation manager.
27
+ * @internal
28
+ */
29
+ export declare enum NativePresentationUnitSystem {
30
+ Metric = "metric",
31
+ BritishImperial = "british-imperial",
32
+ UsCustomary = "us-customary",
33
+ UsSurvey = "us-survey"
34
+ }
35
+ /** @internal */
36
+ export interface NativePresentationDefaultUnitFormats {
37
+ [phenomenon: string]: {
38
+ unitSystems: NativePresentationUnitSystem[];
39
+ format: FormatProps;
40
+ };
41
+ }
42
+ /** @internal */
43
+ export interface NativePresentationKeySetJSON {
44
+ instanceKeys: Array<[string, string[]]>;
45
+ nodeKeys: NodeKey[];
46
+ }
47
+ /** @internal */
48
+ export interface NativePlatformResponse<TResult> {
49
+ result: TResult;
50
+ diagnostics?: DiagnosticsScopeLogs;
51
+ }
52
+ /** @internal */
53
+ export interface NativePlatformDefinition extends IDisposable {
54
+ getImodelAddon(imodel: IModelDb): any;
55
+ setupRulesetDirectories(directories: string[]): NativePlatformResponse<void>;
56
+ setupSupplementalRulesetDirectories(directories: string[]): NativePlatformResponse<void>;
57
+ forceLoadSchemas(db: any): Promise<NativePlatformResponse<void>>;
58
+ getRulesets(rulesetId: string): NativePlatformResponse<string>;
59
+ addRuleset(serializedRulesetJson: string): NativePlatformResponse<string>;
60
+ removeRuleset(rulesetId: string, hash: string): NativePlatformResponse<boolean>;
61
+ clearRulesets(): NativePlatformResponse<void>;
62
+ handleRequest(db: any, options: string, cancelEvent?: BeEvent<() => void>): Promise<NativePlatformResponse<string>>;
63
+ getRulesetVariableValue(rulesetId: string, variableId: string, type: VariableValueTypes): NativePlatformResponse<VariableValue>;
64
+ setRulesetVariableValue(rulesetId: string, variableId: string, type: VariableValueTypes, value: VariableValue): NativePlatformResponse<void>;
65
+ unsetRulesetVariableValue(rulesetId: string, variableId: string): NativePlatformResponse<void>;
66
+ getUpdateInfo(): NativePlatformResponse<UpdateInfo | undefined>;
67
+ }
68
+ /** @internal */
69
+ export interface DefaultNativePlatformProps {
70
+ id: string;
71
+ taskAllocationsMap: {
72
+ [priority: number]: number;
73
+ };
74
+ isChangeTrackingEnabled: boolean;
75
+ cacheConfig?: IModelJsNative.ECPresentationHierarchyCacheConfig;
76
+ contentCacheSize?: number;
77
+ workerConnectionCacheSize?: number;
78
+ defaultFormats?: NativePresentationDefaultUnitFormats;
79
+ useMmap?: boolean | number;
80
+ }
81
+ /** @internal */
82
+ export declare class PresentationNativePlatformResponseError extends PresentationError {
83
+ readonly diagnostics?: DiagnosticsScopeLogs;
84
+ constructor(errorResponse: IModelJsNative.ECPresentationManagerResponse<unknown>);
85
+ }
86
+ /** @internal */
87
+ export declare const createDefaultNativePlatform: (props: DefaultNativePlatformProps) => new () => NativePlatformDefinition;
88
88
  //# sourceMappingURL=NativePlatform.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NativePlatform.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/NativePlatform.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAc,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EACL,oBAAoB,EAAE,OAAO,EAAyC,cAAc,EAAE,aAAa,EAAqB,kBAAkB,EAC3I,MAAM,4BAA4B,CAAC;AAGpC,gBAAgB;AAChB,oBAAY,0BAA0B;IACpC,YAAY,iBAAiB;IAC7B,iBAAiB,sBAAsB;IACvC,WAAW,gBAAgB;IAC3B,gBAAgB,qBAAqB;IACrC,kBAAkB,uBAAuB;IACzC,YAAY,iBAAiB;IAC7B,oBAAoB,yBAAyB;IAC7C,iBAAiB,sBAAsB;IACvC,oBAAoB,yBAAyB;IAC7C,iBAAiB,sBAAsB;IACvC,UAAU,eAAe;IACzB,sBAAsB,2BAA2B;IACjD,eAAe,oBAAoB;IACnC,kBAAkB,uBAAuB;CAC1C;AAED;;;GAGG;AACH,oBAAY,4BAA4B;IACtC,MAAM,WAAW;IACjB,eAAe,qBAAqB;IACpC,WAAW,iBAAiB;IAC5B,QAAQ,cAAc;CACvB;AAED,gBAAgB;AAChB,MAAM,WAAW,oCAAoC;IACnD,CAAC,UAAU,EAAE,MAAM,GAAG;QACpB,WAAW,EAAE,4BAA4B,EAAE,CAAC;QAC5C,MAAM,EAAE,WAAW,CAAC;KACrB,CAAC;CACH;AAED,gBAAgB;AAChB,MAAM,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AS,CAAC,CAAC;CACjE;AAED,gBAAgB;AAChB,MAAM,WAAW,0BAA0B;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,kBAAkB,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACnD,uBAAuB,EAAE,OAAO,CAAC;IACjC,WAAW,CAAC,EAAE,cAAc,CAAC,kCAAkC,CAAC;IAChE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,cAAc,CAAC,EAAE,oCAAoC,CAAC;IACtD,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC5B;AAED,gBAAgB;AAChB,qBAAa,uCAAwC,SAAQ,iBAAiB;IAC5E,SAAgB,WAAW,CAAC,EAAE,oBAAoB,CAAC;gBAChC,aAAa,EAAE,cAAc,CAAC,6BAA6B,CAAC,OAAO,CAAC;CAKxF;AAWD,gBAAgB;AAChB,eAAO,MAAM,2BAA2B,UAAW,0BAA0B,KAAG,UAAU,wBA2FzF,CAAC"}
@@ -1,141 +1,148 @@
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.createDefaultNativePlatform = exports.NativePresentationUnitSystem = exports.NativePlatformRequestTypes = void 0;
11
- const core_backend_1 = require("@itwin/core-backend");
12
- const presentation_common_1 = require("@itwin/presentation-common");
13
- const PresentationManager_1 = require("./PresentationManager");
14
- /** @internal */
15
- var NativePlatformRequestTypes;
16
- (function (NativePlatformRequestTypes) {
17
- NativePlatformRequestTypes["GetRootNodes"] = "GetRootNodes";
18
- NativePlatformRequestTypes["GetRootNodesCount"] = "GetRootNodesCount";
19
- NativePlatformRequestTypes["GetChildren"] = "GetChildren";
20
- NativePlatformRequestTypes["GetChildrenCount"] = "GetChildrenCount";
21
- NativePlatformRequestTypes["GetNodesDescriptor"] = "GetNodesDescriptor";
22
- NativePlatformRequestTypes["GetNodePaths"] = "GetNodePaths";
23
- NativePlatformRequestTypes["GetFilteredNodePaths"] = "GetFilteredNodePaths";
24
- NativePlatformRequestTypes["GetContentSources"] = "GetContentSources";
25
- NativePlatformRequestTypes["GetContentDescriptor"] = "GetContentDescriptor";
26
- NativePlatformRequestTypes["GetContentSetSize"] = "GetContentSetSize";
27
- NativePlatformRequestTypes["GetContent"] = "GetContent";
28
- NativePlatformRequestTypes["GetPagedDistinctValues"] = "GetPagedDistinctValues";
29
- NativePlatformRequestTypes["GetDisplayLabel"] = "GetDisplayLabel";
30
- NativePlatformRequestTypes["CompareHierarchies"] = "CompareHierarchies";
31
- })(NativePlatformRequestTypes = exports.NativePlatformRequestTypes || (exports.NativePlatformRequestTypes = {}));
32
- /**
33
- * Enumeration of unit systems supported by native presentation manager.
34
- * @internal
35
- */
36
- var NativePresentationUnitSystem;
37
- (function (NativePresentationUnitSystem) {
38
- NativePresentationUnitSystem["Metric"] = "metric";
39
- NativePresentationUnitSystem["BritishImperial"] = "british-imperial";
40
- NativePresentationUnitSystem["UsCustomary"] = "us-customary";
41
- NativePresentationUnitSystem["UsSurvey"] = "us-survey";
42
- })(NativePresentationUnitSystem = exports.NativePresentationUnitSystem || (exports.NativePresentationUnitSystem = {}));
43
- /** @internal */
44
- const createDefaultNativePlatform = (props) => {
45
- // note the implementation is constructed here to make PresentationManager
46
- // usable without loading the actual addon (if addon is set to something other)
47
- return class {
48
- constructor() {
49
- var _a;
50
- const cacheConfig = (_a = props.cacheConfig) !== null && _a !== void 0 ? _a : { mode: PresentationManager_1.HierarchyCacheMode.Disk, directory: "" };
51
- const defaultFormats = props.defaultFormats ? this.getSerializedDefaultFormatsMap(props.defaultFormats) : {};
52
- this._nativeAddon = new core_backend_1.IModelHost.platform.ECPresentationManager({ ...props, cacheConfig, defaultFormats });
53
- }
54
- getStatus(responseStatus) {
55
- switch (responseStatus) {
56
- case 65537 /* InvalidArgument */: return presentation_common_1.PresentationStatus.InvalidArgument;
57
- case 1 /* Canceled */: return presentation_common_1.PresentationStatus.Canceled;
58
- default: return presentation_common_1.PresentationStatus.Error;
59
- }
60
- }
61
- getSerializedDefaultFormatsMap(defaultMap) {
62
- const res = {};
63
- Object.keys(defaultMap).forEach((key) => {
64
- const value = defaultMap[key];
65
- res[key] = { unitSystems: value.unitSystems, serializedFormat: JSON.stringify(value.format) };
66
- });
67
- return res;
68
- }
69
- createSuccessResponse(response) {
70
- const retValue = { result: response.result };
71
- if (response.diagnostics)
72
- retValue.diagnostics = response.diagnostics;
73
- return retValue;
74
- }
75
- handleResult(response) {
76
- if (response.error)
77
- throw new presentation_common_1.PresentationError(this.getStatus(response.error.status), response.error.message);
78
- return this.createSuccessResponse(response);
79
- }
80
- handleVoidResult(response) {
81
- if (response.error)
82
- throw new presentation_common_1.PresentationError(this.getStatus(response.error.status), response.error.message);
83
- return this.createSuccessResponse(response);
84
- }
85
- dispose() {
86
- this._nativeAddon.dispose();
87
- }
88
- async forceLoadSchemas(db) {
89
- const response = await this._nativeAddon.forceLoadSchemas(db);
90
- if (response.error)
91
- throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.Error, response.error.message);
92
- return this.createSuccessResponse(response);
93
- }
94
- setupRulesetDirectories(directories) {
95
- return this.handleVoidResult(this._nativeAddon.setupRulesetDirectories(directories));
96
- }
97
- setupSupplementalRulesetDirectories(directories) {
98
- return this.handleVoidResult(this._nativeAddon.setupSupplementalRulesetDirectories(directories));
99
- }
100
- getImodelAddon(imodel) {
101
- if (!imodel.nativeDb)
102
- throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.InvalidArgument, "imodel");
103
- return imodel.nativeDb;
104
- }
105
- getRulesets(rulesetId) {
106
- return this.handleResult(this._nativeAddon.getRulesets(rulesetId));
107
- }
108
- addRuleset(serializedRulesetJson) {
109
- return this.handleResult(this._nativeAddon.addRuleset(serializedRulesetJson));
110
- }
111
- removeRuleset(rulesetId, hash) {
112
- return this.handleResult(this._nativeAddon.removeRuleset(rulesetId, hash));
113
- }
114
- clearRulesets() {
115
- return this.handleVoidResult(this._nativeAddon.clearRulesets());
116
- }
117
- async handleRequest(db, options, cancelEvent) {
118
- const response = this._nativeAddon.handleRequest(db, options);
119
- cancelEvent === null || cancelEvent === void 0 ? void 0 : cancelEvent.addOnce(() => response.cancel());
120
- const result = await response.result;
121
- return this.handleResult(result);
122
- }
123
- getRulesetVariableValue(rulesetId, variableId, type) {
124
- return this.handleResult(this._nativeAddon.getRulesetVariableValue(rulesetId, variableId, type));
125
- }
126
- setRulesetVariableValue(rulesetId, variableId, type, value) {
127
- return this.handleVoidResult(this._nativeAddon.setRulesetVariableValue(rulesetId, variableId, type, value));
128
- }
129
- unsetRulesetVariableValue(rulesetId, variableId) {
130
- return this.handleVoidResult(this._nativeAddon.unsetRulesetVariableValue(rulesetId, variableId));
131
- }
132
- getUpdateInfo() {
133
- return this.handleResult(this._nativeAddon.getUpdateInfo());
134
- }
135
- updateHierarchyState(db, rulesetId, stateChanges) {
136
- return this.handleResult(this._nativeAddon.updateHierarchyState(db, rulesetId, stateChanges));
137
- }
138
- };
139
- };
140
- exports.createDefaultNativePlatform = createDefaultNativePlatform;
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.createDefaultNativePlatform = exports.PresentationNativePlatformResponseError = exports.NativePresentationUnitSystem = exports.NativePlatformRequestTypes = void 0;
11
+ const core_backend_1 = require("@itwin/core-backend");
12
+ const core_bentley_1 = require("@itwin/core-bentley");
13
+ const presentation_common_1 = require("@itwin/presentation-common");
14
+ const PresentationManager_1 = require("./PresentationManager");
15
+ /** @internal */
16
+ var NativePlatformRequestTypes;
17
+ (function (NativePlatformRequestTypes) {
18
+ NativePlatformRequestTypes["GetRootNodes"] = "GetRootNodes";
19
+ NativePlatformRequestTypes["GetRootNodesCount"] = "GetRootNodesCount";
20
+ NativePlatformRequestTypes["GetChildren"] = "GetChildren";
21
+ NativePlatformRequestTypes["GetChildrenCount"] = "GetChildrenCount";
22
+ NativePlatformRequestTypes["GetNodesDescriptor"] = "GetNodesDescriptor";
23
+ NativePlatformRequestTypes["GetNodePaths"] = "GetNodePaths";
24
+ NativePlatformRequestTypes["GetFilteredNodePaths"] = "GetFilteredNodePaths";
25
+ NativePlatformRequestTypes["GetContentSources"] = "GetContentSources";
26
+ NativePlatformRequestTypes["GetContentDescriptor"] = "GetContentDescriptor";
27
+ NativePlatformRequestTypes["GetContentSetSize"] = "GetContentSetSize";
28
+ NativePlatformRequestTypes["GetContent"] = "GetContent";
29
+ NativePlatformRequestTypes["GetPagedDistinctValues"] = "GetPagedDistinctValues";
30
+ NativePlatformRequestTypes["GetDisplayLabel"] = "GetDisplayLabel";
31
+ NativePlatformRequestTypes["CompareHierarchies"] = "CompareHierarchies";
32
+ })(NativePlatformRequestTypes = exports.NativePlatformRequestTypes || (exports.NativePlatformRequestTypes = {}));
33
+ /**
34
+ * Enumeration of unit systems supported by native presentation manager.
35
+ * @internal
36
+ */
37
+ var NativePresentationUnitSystem;
38
+ (function (NativePresentationUnitSystem) {
39
+ NativePresentationUnitSystem["Metric"] = "metric";
40
+ NativePresentationUnitSystem["BritishImperial"] = "british-imperial";
41
+ NativePresentationUnitSystem["UsCustomary"] = "us-customary";
42
+ NativePresentationUnitSystem["UsSurvey"] = "us-survey";
43
+ })(NativePresentationUnitSystem = exports.NativePresentationUnitSystem || (exports.NativePresentationUnitSystem = {}));
44
+ /** @internal */
45
+ class PresentationNativePlatformResponseError extends presentation_common_1.PresentationError {
46
+ constructor(errorResponse) {
47
+ (0, core_bentley_1.assert)(!!errorResponse.error);
48
+ super(getPresentationStatusFromNativeResponseStatus(errorResponse.error.status), errorResponse.error.message);
49
+ this.diagnostics = errorResponse.diagnostics;
50
+ }
51
+ }
52
+ exports.PresentationNativePlatformResponseError = PresentationNativePlatformResponseError;
53
+ function getPresentationStatusFromNativeResponseStatus(nativeResponseStatus) {
54
+ switch (nativeResponseStatus) {
55
+ case 65537 /* IModelJsNative.ECPresentationStatus.InvalidArgument */: return presentation_common_1.PresentationStatus.InvalidArgument;
56
+ case 65538 /* IModelJsNative.ECPresentationStatus.ResultSetTooLarge */: return presentation_common_1.PresentationStatus.ResultSetTooLarge;
57
+ case 1 /* IModelJsNative.ECPresentationStatus.Canceled */: return presentation_common_1.PresentationStatus.Canceled;
58
+ }
59
+ return presentation_common_1.PresentationStatus.Error;
60
+ }
61
+ /** @internal */
62
+ const createDefaultNativePlatform = (props) => {
63
+ // note the implementation is constructed here to make PresentationManager
64
+ // usable without loading the actual addon (if addon is set to something other)
65
+ return class {
66
+ constructor() {
67
+ const cacheConfig = props.cacheConfig ?? { mode: PresentationManager_1.HierarchyCacheMode.Disk, directory: "" };
68
+ const defaultFormats = props.defaultFormats ? this.getSerializedDefaultFormatsMap(props.defaultFormats) : {};
69
+ this._nativeAddon = new core_backend_1.IModelHost.platform.ECPresentationManager({ ...props, cacheConfig, defaultFormats });
70
+ }
71
+ getSerializedDefaultFormatsMap(defaultMap) {
72
+ const res = {};
73
+ Object.keys(defaultMap).forEach((key) => {
74
+ const value = defaultMap[key];
75
+ res[key] = { unitSystems: value.unitSystems, serializedFormat: JSON.stringify(value.format) };
76
+ });
77
+ return res;
78
+ }
79
+ createSuccessResponse(response) {
80
+ const retValue = { result: response.result };
81
+ if (response.diagnostics)
82
+ retValue.diagnostics = response.diagnostics;
83
+ return retValue;
84
+ }
85
+ handleResult(response) {
86
+ if (response.error)
87
+ throw new PresentationNativePlatformResponseError(response);
88
+ return this.createSuccessResponse(response);
89
+ }
90
+ handleVoidResult(response) {
91
+ if (response.error)
92
+ throw new PresentationNativePlatformResponseError(response);
93
+ return this.createSuccessResponse(response);
94
+ }
95
+ dispose() {
96
+ this._nativeAddon.dispose();
97
+ }
98
+ async forceLoadSchemas(db) {
99
+ const response = await this._nativeAddon.forceLoadSchemas(db);
100
+ if (response.error)
101
+ throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.Error, response.error.message);
102
+ return this.createSuccessResponse(response);
103
+ }
104
+ setupRulesetDirectories(directories) {
105
+ return this.handleVoidResult(this._nativeAddon.setupRulesetDirectories(directories));
106
+ }
107
+ setupSupplementalRulesetDirectories(directories) {
108
+ return this.handleVoidResult(this._nativeAddon.setupSupplementalRulesetDirectories(directories));
109
+ }
110
+ getImodelAddon(imodel) {
111
+ if (!imodel.nativeDb)
112
+ throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.InvalidArgument, "imodel");
113
+ return imodel.nativeDb;
114
+ }
115
+ getRulesets(rulesetId) {
116
+ return this.handleResult(this._nativeAddon.getRulesets(rulesetId));
117
+ }
118
+ addRuleset(serializedRulesetJson) {
119
+ return this.handleResult(this._nativeAddon.addRuleset(serializedRulesetJson));
120
+ }
121
+ removeRuleset(rulesetId, hash) {
122
+ return this.handleResult(this._nativeAddon.removeRuleset(rulesetId, hash));
123
+ }
124
+ clearRulesets() {
125
+ return this.handleVoidResult(this._nativeAddon.clearRulesets());
126
+ }
127
+ async handleRequest(db, options, cancelEvent) {
128
+ const response = this._nativeAddon.handleRequest(db, options);
129
+ cancelEvent?.addOnce(() => response.cancel());
130
+ const result = await response.result;
131
+ return this.handleResult(result);
132
+ }
133
+ getRulesetVariableValue(rulesetId, variableId, type) {
134
+ return this.handleResult(this._nativeAddon.getRulesetVariableValue(rulesetId, variableId, type));
135
+ }
136
+ setRulesetVariableValue(rulesetId, variableId, type, value) {
137
+ return this.handleVoidResult(this._nativeAddon.setRulesetVariableValue(rulesetId, variableId, type, value));
138
+ }
139
+ unsetRulesetVariableValue(rulesetId, variableId) {
140
+ return this.handleVoidResult(this._nativeAddon.unsetRulesetVariableValue(rulesetId, variableId));
141
+ }
142
+ getUpdateInfo() {
143
+ return this.handleResult(this._nativeAddon.getUpdateInfo());
144
+ }
145
+ };
146
+ };
147
+ exports.createDefaultNativePlatform = createDefaultNativePlatform;
141
148
  //# sourceMappingURL=NativePlatform.js.map