@itwin/presentation-frontend 5.0.0-dev.9 → 5.0.0-dev.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -1
- package/lib/cjs/package.json +1 -0
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts +3 -3
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js +11 -9
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/Diagnostics.js.map +1 -1
- package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.d.ts +12 -3
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js +7 -7
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/LocalizationHelper.d.ts +1 -1
- package/lib/cjs/presentation-frontend/LocalizationHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/LocalizationHelper.js +7 -6
- package/lib/cjs/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.d.ts +15 -5
- package/lib/cjs/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.js +30 -21
- package/lib/cjs/presentation-frontend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts +9 -6
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.js +55 -44
- package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetManager.js +2 -4
- package/lib/cjs/presentation-frontend/RulesetManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.d.ts +1 -1
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js +4 -2
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/StreamedResponseGenerator.d.ts +1 -1
- package/lib/cjs/presentation-frontend/StreamedResponseGenerator.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/StreamedResponseGenerator.js +1 -0
- package/lib/cjs/presentation-frontend/StreamedResponseGenerator.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +6 -4
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +157 -142
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +4 -5
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +27 -29
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.d.ts +3 -0
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js +8 -2
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.d.ts +2 -1
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js +1 -0
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.d.ts +5 -1
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js +3 -0
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts +8 -5
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.js +35 -13
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts +2 -0
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js +3 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts +31 -11
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js +217 -112
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts +5 -8
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js +6 -11
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend.d.ts +15 -15
- package/lib/cjs/presentation-frontend.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend.js +30 -29
- package/lib/cjs/presentation-frontend.js.map +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts +3 -3
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js +11 -9
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/Diagnostics.js.map +1 -1
- package/lib/esm/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
- package/lib/esm/presentation-frontend/IpcRequestsHandler.d.ts +12 -3
- package/lib/esm/presentation-frontend/IpcRequestsHandler.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js +8 -8
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/LocalizationHelper.d.ts +1 -1
- package/lib/esm/presentation-frontend/LocalizationHelper.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/LocalizationHelper.js +3 -2
- package/lib/esm/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.d.ts +15 -5
- package/lib/esm/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.js +23 -14
- package/lib/esm/presentation-frontend/Presentation.js.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.d.ts +9 -6
- package/lib/esm/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.js +43 -32
- package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetManager.js +2 -4
- package/lib/esm/presentation-frontend/RulesetManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetVariablesManager.d.ts +1 -1
- package/lib/esm/presentation-frontend/RulesetVariablesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js +4 -2
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/StreamedResponseGenerator.d.ts +1 -1
- package/lib/esm/presentation-frontend/StreamedResponseGenerator.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/StreamedResponseGenerator.js +1 -0
- package/lib/esm/presentation-frontend/StreamedResponseGenerator.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +6 -4
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +158 -143
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +4 -5
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +27 -29
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.d.ts +3 -0
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js +8 -2
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.d.ts +2 -1
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.js +1 -0
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.d.ts +5 -1
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js +3 -0
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts +8 -5
- package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHandler.js +35 -13
- package/lib/esm/presentation-frontend/selection/SelectionHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts +2 -0
- package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js +3 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts +31 -11
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.js +203 -98
- package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts +5 -8
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js +6 -10
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/esm/presentation-frontend.d.ts +15 -15
- package/lib/esm/presentation-frontend.d.ts.map +1 -1
- package/lib/esm/presentation-frontend.js +12 -15
- package/lib/esm/presentation-frontend.js.map +1 -1
- package/package.json +42 -42
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StreamedResponseGenerator.d.ts","sourceRoot":"","sources":["../../../src/presentation-frontend/StreamedResponseGenerator.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"StreamedResponseGenerator.d.ts","sourceRoot":"","sources":["../../../src/presentation-frontend/StreamedResponseGenerator.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAExE;;;GAGG;AACH,MAAM,MAAM,8BAA8B,CAAC,KAAK,IAAI,4BAA4B,GAAG;IACjF,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,C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AAE,EAAE,CAAC,WAAW,CAAC,CACtC,CACF,CAAC;IACJ,CAAC;CACF;AAED,SAAS,qBAAqB,CAAC,SAAiB,EAAE,KAAa;IAC7D,IAAI,SAAS,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,mCAAmC,SAAS,6CAA6C,KAAK,EAAE,CAAC,CAAC;IACpH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;AAC9E,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\r\nimport { concat, concatAll, map, mergeMap, Observable, of, range, scan } from \"rxjs\";\r\nimport { eachValueFrom } from \"rxjs-for-await\";\r\nimport { SortedArray } from \"@itwin/core-bentley\";\r\nimport { PagedResponse, PageOptions } from \"@itwin/presentation-common\";\r\nimport { MultipleValuesRequestOptions } from \"./PresentationManager\";\r\n\r\n/**\r\n * Properties for streaming the results.\r\n * @internal\r\n */\r\nexport type StreamedResponseGeneratorProps<TItem> = MultipleValuesRequestOptions & {\r\n getBatch(page: Required<PageOptions>, requestIdx: number): Promise<PagedResponse<TItem>>;\r\n};\r\n\r\n/**\r\n * This class allows loading values in multiple parallel batches and return them either as an array or an async iterator.\r\n * Pages are prefetched in advanced according to the `parallelism` argument.\r\n * @internal\r\n */\r\nexport class StreamedResponseGenerator<TPagedResponseItem> {\r\n constructor(private readonly _props: StreamedResponseGeneratorProps<TPagedResponseItem>) {}\r\n\r\n /** Creates a response with the total item count and an async iterator. */\r\n public async createAsyncIteratorResponse(): Promise<{ total: number; items: AsyncIterableIterator<TPagedResponseItem> }> {\r\n const firstPage = await this.fetchFirstPage();\r\n return {\r\n total: firstPage.total,\r\n items: eachValueFrom(this.getRemainingPages(firstPage).pipe(concatAll())),\r\n };\r\n }\r\n\r\n /**\r\n * Fetches the first page.\r\n * This function has to be called in order to retrieve the total items count.\r\n */\r\n private async fetchFirstPage(): Promise<PagedResponse<TPagedResponseItem>> {\r\n const start = this._props.paging?.start ?? 0;\r\n const batchSize = this._props.batchSize ?? this._props.paging?.size ?? 0;\r\n return this._props.getBatch({ start, size: batchSize }, 0);\r\n }\r\n\r\n private getRemainingPages(firstPage: PagedResponse<TPagedResponseItem>): Observable<TPagedResponseItem[]> {\r\n const pageStart = this._props.paging?.start ?? 0;\r\n const maxParallelRequests = this._props.maxParallelRequests;\r\n const pageSize = this._props.paging?.size;\r\n const { total, items: firstPageItems } = firstPage;\r\n\r\n // If there are no items, return a single empty page.\r\n if (total === 0) {\r\n return of([]);\r\n }\r\n\r\n // If the response is empty, something went wrong.\r\n const receivedItemsLength = firstPage.items.length;\r\n if (!receivedItemsLength) {\r\n handleEmptyPageResult(pageStart, total);\r\n }\r\n\r\n const totalItemsToFetch = total - pageStart;\r\n if (receivedItemsLength === totalItemsToFetch) {\r\n return of(firstPageItems);\r\n }\r\n\r\n let itemsToFetch: number;\r\n let batchSize: number;\r\n if (pageSize) {\r\n itemsToFetch = Math.min(totalItemsToFetch, pageSize) - receivedItemsLength;\r\n batchSize = Math.min(this._props.batchSize ?? Number.MAX_SAFE_INTEGER, pageSize, receivedItemsLength);\r\n } else {\r\n itemsToFetch = totalItemsToFetch - receivedItemsLength;\r\n batchSize = Math.min(this._props.batchSize ?? Number.MAX_SAFE_INTEGER, receivedItemsLength);\r\n }\r\n\r\n const remainingBatches = Math.ceil(itemsToFetch / batchSize);\r\n\r\n // Return the first page and then stream the remaining ones.\r\n return concat(\r\n of(firstPage.items),\r\n range(1, remainingBatches).pipe(\r\n mergeMap(async (idx) => {\r\n const start = pageStart + idx * batchSize;\r\n const size = Math.min(total - start, batchSize);\r\n const page = await this._props.getBatch({ start, size }, idx);\r\n if (!page.items.length) {\r\n handleEmptyPageResult(start, total);\r\n }\r\n\r\n // Pass along the index, so that the items could be sorted.\r\n return { idx, items: page.items };\r\n }, maxParallelRequests),\r\n scan(\r\n // Collect the emitted pages an emit them in the correct order.\r\n (acc, value) => {\r\n let { lastEmitted } = acc;\r\n const { accumulatedBatches } = acc;\r\n const { idx } = value;\r\n\r\n // If current batch is not in order, put it in the accumulator\r\n if (idx - 1 !== lastEmitted) {\r\n accumulatedBatches.insert(value);\r\n return { lastEmitted, accumulatedBatches, itemsToEmit: [] };\r\n }\r\n\r\n // Collect all batches to emit in order.\r\n lastEmitted = idx;\r\n const batchesToEmit = [value];\r\n for (const batch of accumulatedBatches) {\r\n if (batch.idx - 1 !== lastEmitted) {\r\n break;\r\n }\r\n lastEmitted = batch.idx;\r\n batchesToEmit.push(batch);\r\n }\r\n\r\n // Remove batches to emit from the accumulator.\r\n for (const batch of batchesToEmit) {\r\n accumulatedBatches.remove(batch);\r\n }\r\n\r\n const itemsToEmit = batchesToEmit.flatMap((x) => x.items);\r\n return { lastEmitted, accumulatedBatches, itemsToEmit };\r\n },\r\n {\r\n lastEmitted: 0,\r\n accumulatedBatches: new SortedArray<{ idx: number; items: TPagedResponseItem[] }>((a, b) => a.idx - b.idx),\r\n itemsToEmit: new Array<TPagedResponseItem>(),\r\n },\r\n ),\r\n map(({ itemsToEmit }) => itemsToEmit),\r\n ),\r\n );\r\n }\r\n}\r\n\r\nfunction handleEmptyPageResult(pageStart: number, total: number) {\r\n if (pageStart >= total) {\r\n throw new Error(`Requested page with start index ${pageStart} is out of bounds. Total number of items: ${total}`);\r\n }\r\n throw new Error(\"Paged request returned non zero total count but no items\");\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"StreamedResponseGenerator.js","sourceRoot":"","sources":["../../../src/presentation-frontend/StreamedResponseGenerator.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,QAAQ,EAAc,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,gB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MAAM,KAAK,IAAI,aAAa,EAAE,CAAC;gBAClC,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACnC,CAAC;YAED,MAAM,WAAW,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YAC1D,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,WAAW,EAAE,CAAC;QAC1D,CAAC,EACD;YACE,WAAW,EAAE,CAAC;YACd,kBAAkB,EAAE,IAAI,WAAW,CAA+C,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC;YAC1G,WAAW,EAAE,IAAI,KAAK,EAAsB;SAC7C,CACF,EACD,GAAG,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,CACtC,CACF,CAAC;IACJ,CAAC;CACF;AAED,SAAS,qBAAqB,CAAC,SAAiB,EAAE,KAAa;IAC7D,IAAI,SAAS,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,mCAAmC,SAAS,6CAA6C,KAAK,EAAE,CAAC,CAAC;IACpH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;AAC9E,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\nimport { concat, concatAll, map, mergeMap, Observable, of, range, scan } from \"rxjs\";\nimport { eachValueFrom } from \"rxjs-for-await\";\nimport { SortedArray } from \"@itwin/core-bentley\";\nimport { PagedResponse, PageOptions } from \"@itwin/presentation-common\";\nimport { MultipleValuesRequestOptions } from \"./PresentationManager.js\";\n\n/**\n * Properties for streaming the results.\n * @internal\n */\nexport type StreamedResponseGeneratorProps<TItem> = MultipleValuesRequestOptions & {\n getBatch(page: Required<PageOptions>, requestIdx: number): Promise<PagedResponse<TItem>>;\n};\n\n/**\n * This class allows loading values in multiple parallel batches and return them either as an array or an async iterator.\n * Pages are prefetched in advanced according to the `parallelism` argument.\n * @internal\n */\nexport class StreamedResponseGenerator<TPagedResponseItem> {\n constructor(private readonly _props: StreamedResponseGeneratorProps<TPagedResponseItem>) {}\n\n /** Creates a response with the total item count and an async iterator. */\n public async createAsyncIteratorResponse(): Promise<{ total: number; items: AsyncIterableIterator<TPagedResponseItem> }> {\n const firstPage = await this.fetchFirstPage();\n return {\n total: firstPage.total,\n items: eachValueFrom(this.getRemainingPages(firstPage).pipe(concatAll())),\n };\n }\n\n /**\n * Fetches the first page.\n * This function has to be called in order to retrieve the total items count.\n */\n private async fetchFirstPage(): Promise<PagedResponse<TPagedResponseItem>> {\n const start = this._props.paging?.start ?? 0;\n const batchSize = this._props.batchSize ?? this._props.paging?.size ?? 0;\n return this._props.getBatch({ start, size: batchSize }, 0);\n }\n\n private getRemainingPages(firstPage: PagedResponse<TPagedResponseItem>): Observable<TPagedResponseItem[]> {\n const pageStart = this._props.paging?.start ?? 0;\n const maxParallelRequests = this._props.maxParallelRequests;\n const pageSize = this._props.paging?.size;\n const { total, items: firstPageItems } = firstPage;\n\n // If there are no items, return a single empty page.\n if (total === 0) {\n return of([]);\n }\n\n // If the response is empty, something went wrong.\n const receivedItemsLength = firstPage.items.length;\n if (!receivedItemsLength) {\n handleEmptyPageResult(pageStart, total);\n }\n\n const totalItemsToFetch = total - pageStart;\n if (receivedItemsLength === totalItemsToFetch) {\n return of(firstPageItems);\n }\n\n let itemsToFetch: number;\n let batchSize: number;\n if (pageSize) {\n itemsToFetch = Math.min(totalItemsToFetch, pageSize) - receivedItemsLength;\n batchSize = Math.min(this._props.batchSize ?? Number.MAX_SAFE_INTEGER, pageSize, receivedItemsLength);\n } else {\n itemsToFetch = totalItemsToFetch - receivedItemsLength;\n batchSize = Math.min(this._props.batchSize ?? Number.MAX_SAFE_INTEGER, receivedItemsLength);\n }\n\n const remainingBatches = Math.ceil(itemsToFetch / batchSize);\n\n // Return the first page and then stream the remaining ones.\n return concat(\n of(firstPage.items),\n range(1, remainingBatches).pipe(\n mergeMap(async (idx) => {\n const start = pageStart + idx * batchSize;\n const size = Math.min(total - start, batchSize);\n const page = await this._props.getBatch({ start, size }, idx);\n if (!page.items.length) {\n handleEmptyPageResult(start, total);\n }\n\n // Pass along the index, so that the items could be sorted.\n return { idx, items: page.items };\n }, maxParallelRequests),\n scan(\n // Collect the emitted pages an emit them in the correct order.\n (acc, value) => {\n let { lastEmitted } = acc;\n const { accumulatedBatches } = acc;\n const { idx } = value;\n\n // If current batch is not in order, put it in the accumulator\n if (idx - 1 !== lastEmitted) {\n accumulatedBatches.insert(value);\n return { lastEmitted, accumulatedBatches, itemsToEmit: [] };\n }\n\n // Collect all batches to emit in order.\n lastEmitted = idx;\n const batchesToEmit = [value];\n for (const batch of accumulatedBatches) {\n if (batch.idx - 1 !== lastEmitted) {\n break;\n }\n lastEmitted = batch.idx;\n batchesToEmit.push(batch);\n }\n\n // Remove batches to emit from the accumulator.\n for (const batch of batchesToEmit) {\n accumulatedBatches.remove(batch);\n }\n\n const itemsToEmit = batchesToEmit.flatMap((x) => x.items);\n return { lastEmitted, accumulatedBatches, itemsToEmit };\n },\n {\n lastEmitted: 0,\n accumulatedBatches: new SortedArray<{ idx: number; items: TPagedResponseItem[] }>((a, b) => a.idx - b.idx),\n itemsToEmit: new Array<TPagedResponseItem>(),\n },\n ),\n map(({ itemsToEmit }) => itemsToEmit),\n ),\n );\n }\n}\n\nfunction handleEmptyPageResult(pageStart: number, total: number) {\n if (pageStart >= total) {\n throw new Error(`Requested page with start index ${pageStart} is out of bounds. Total number of items: ${total}`);\n }\n throw new Error(\"Paged request returned non zero total count but no items\");\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Core
|
|
3
3
|
*/
|
|
4
|
-
import { BeEvent
|
|
4
|
+
import { BeEvent } from "@itwin/core-bentley";
|
|
5
5
|
import { IModelConnection } from "@itwin/core-frontend";
|
|
6
6
|
import { Field } from "@itwin/presentation-common";
|
|
7
|
-
import { IFavoritePropertiesStorage } from "./FavoritePropertiesStorage";
|
|
7
|
+
import { IFavoritePropertiesStorage } from "./FavoritePropertiesStorage.js";
|
|
8
8
|
/**
|
|
9
9
|
* Scopes that favorite properties can be stored in.
|
|
10
10
|
* @public
|
|
@@ -49,7 +49,7 @@ export interface FavoritePropertiesManagerProps {
|
|
|
49
49
|
*
|
|
50
50
|
* @public
|
|
51
51
|
*/
|
|
52
|
-
export declare class FavoritePropertiesManager implements
|
|
52
|
+
export declare class FavoritePropertiesManager implements Disposable {
|
|
53
53
|
/**
|
|
54
54
|
* Used in tests to avoid collisions between multiple runs using the same storage
|
|
55
55
|
* @internal
|
|
@@ -57,7 +57,7 @@ export declare class FavoritePropertiesManager implements IDisposable {
|
|
|
57
57
|
static FAVORITES_IDENTIFIER_PREFIX: string;
|
|
58
58
|
/** Event raised after favorite properties have changed. */
|
|
59
59
|
onFavoritesChanged: BeEvent<() => void>;
|
|
60
|
-
|
|
60
|
+
readonly storage: IFavoritePropertiesStorage;
|
|
61
61
|
private _globalProperties;
|
|
62
62
|
private _iTwinProperties;
|
|
63
63
|
private _imodelProperties;
|
|
@@ -66,6 +66,8 @@ export declare class FavoritePropertiesManager implements IDisposable {
|
|
|
66
66
|
/** Property order is saved only in iModel scope */
|
|
67
67
|
private _propertiesOrder;
|
|
68
68
|
constructor(props: FavoritePropertiesManagerProps);
|
|
69
|
+
[Symbol.dispose](): void;
|
|
70
|
+
/** @deprecated in 5.0 Use [Symbol.dispose] instead. */
|
|
69
71
|
dispose(): void;
|
|
70
72
|
/**
|
|
71
73
|
* Initialize favorite properties for the provided IModelConnection.
|
package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FavoritePropertiesManager.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/favorite-properties/FavoritePropertiesManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"FavoritePropertiesManager.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/favorite-properties/FavoritePropertiesManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAA+B,MAAM,qBAAqB,CAAC;AAE3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAW,KAAK,EAAuC,MAAM,4BAA4B,CAAC;AACjG,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAE5E;;;GAGG;AACH,oBAAY,uBAAuB;IACjC,MAAM,IAAA;IACN,KAAK,IAAA;IACL,MAAM,IAAA;CACP;AAED;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEtC;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,IAAI,EAAE,gBAAgB,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,IAAI,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;;OAGG;IACH,OAAO,EAAE,0BAA0B,CAAC;CACrC;AAED;;;;;GAKG;AACH,qBAAa,yBAA0B,YAAW,UAAU;IAC1D;;;OAGG;IACH,OAAc,2BAA2B,SAAM;IAE/C,2DAA2D;IACpD,kBAAkB,gBAAqB,IAAI,EAAI;IAEtD,SAAgB,OAAO,EAAE,0BAA0B,CAAC;IAEpD,OAAO,CAAC,iBAAiB,CAAoC;IAC7D,OAAO,CAAC,gBAAgB,CAAqC;IAC7D,OAAO,CAAC,iBAAiB,CAAqC;IAC9D,OAAO,CAAC,yBAAyB,CAA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E,gBAAgB,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAMzF,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,sBAAsB,CAuC5B;IAEF;;;;;OAKG;IACU,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,GAAG,SAAS,EAAE,aAAa,EAAE,KAAK,EAAE;CAgI/H;AAuDD,gBAAgB;AAChB,eAAO,MAAM,aAAa,UAAW,KAAK,KAAG,GAAG,CAAC,gBAAgB,CAUhE,CAAC;AAgCF,gBAAgB;AAChB,eAAO,MAAM,qBAAqB,UAAW,KAAK,KAAG,2BAA2B,EA4B/E,CAAC"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Core
|
|
7
7
|
*/
|
|
8
|
-
import { BeEvent, isIDisposable } from "@itwin/core-bentley";
|
|
8
|
+
import { BeEvent, isDisposable, isIDisposable } from "@itwin/core-bentley";
|
|
9
9
|
import { QueryRowFormat } from "@itwin/core-common";
|
|
10
10
|
/**
|
|
11
11
|
* Scopes that favorite properties can be stored in.
|
|
@@ -24,139 +24,93 @@ export var FavoritePropertiesScope;
|
|
|
24
24
|
* @public
|
|
25
25
|
*/
|
|
26
26
|
export class FavoritePropertiesManager {
|
|
27
|
+
/**
|
|
28
|
+
* Used in tests to avoid collisions between multiple runs using the same storage
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
static FAVORITES_IDENTIFIER_PREFIX = "";
|
|
32
|
+
/** Event raised after favorite properties have changed. */
|
|
33
|
+
onFavoritesChanged = new BeEvent();
|
|
34
|
+
storage;
|
|
35
|
+
_globalProperties;
|
|
36
|
+
_iTwinProperties;
|
|
37
|
+
_imodelProperties;
|
|
38
|
+
_imodelBaseClassesByClass;
|
|
39
|
+
_imodelInitializationPromises;
|
|
40
|
+
/** Property order is saved only in iModel scope */
|
|
41
|
+
_propertiesOrder;
|
|
27
42
|
constructor(props) {
|
|
28
|
-
|
|
29
|
-
this.onFavoritesChanged = new BeEvent();
|
|
30
|
-
/**
|
|
31
|
-
* Initialize favorite properties for the provided IModelConnection.
|
|
32
|
-
* @deprecated in 4.5. Initialization is performed automatically by all async methods and only needed for deprecated [[FavoritePropertiesManager.has]] and [[FavoritePropertiesManager.sortFields]].
|
|
33
|
-
*/
|
|
34
|
-
this.initializeConnection = async (imodel) => {
|
|
35
|
-
const imodelId = imodel.iModelId;
|
|
36
|
-
const iTwinId = imodel.iTwinId;
|
|
37
|
-
if (this._globalProperties === undefined) {
|
|
38
|
-
this._globalProperties = (await this._storage.loadProperties()) || new Set();
|
|
39
|
-
}
|
|
40
|
-
if (!this._iTwinProperties.has(iTwinId)) {
|
|
41
|
-
const iTwinProperties = (await this._storage.loadProperties(iTwinId)) || new Set();
|
|
42
|
-
this._iTwinProperties.set(iTwinId, iTwinProperties);
|
|
43
|
-
}
|
|
44
|
-
if (!this._imodelProperties.has(getiModelInfo(iTwinId, imodelId))) {
|
|
45
|
-
const imodelProperties = (await this._storage.loadProperties(iTwinId, imodelId)) || new Set();
|
|
46
|
-
this._imodelProperties.set(getiModelInfo(iTwinId, imodelId), imodelProperties);
|
|
47
|
-
}
|
|
48
|
-
const propertiesOrder = (await this._storage.loadPropertiesOrder(iTwinId, imodelId)) || [];
|
|
49
|
-
this._propertiesOrder.set(getiModelInfo(iTwinId, imodelId), propertiesOrder);
|
|
50
|
-
await this._adjustPropertyOrderInfos(iTwinId, imodelId);
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Function that removes order information of properties that are no longer
|
|
54
|
-
* favorited and adds missing order information for favorited properties.
|
|
55
|
-
*/
|
|
56
|
-
this._adjustPropertyOrderInfos = async (iTwinId, imodelId) => {
|
|
57
|
-
const propertiesOrder = this._propertiesOrder.get(getiModelInfo(iTwinId, imodelId));
|
|
58
|
-
const globalProperties = this._globalProperties;
|
|
59
|
-
const iTwinProperties = this._iTwinProperties.get(iTwinId);
|
|
60
|
-
const imodelProperties = this._imodelProperties.get(getiModelInfo(iTwinId, imodelId));
|
|
61
|
-
// favorite property infos that need to be added to the propertiesOrder array
|
|
62
|
-
const infosToAdd = new Set([...globalProperties, ...iTwinProperties, ...imodelProperties]);
|
|
63
|
-
for (let i = propertiesOrder.length - 1; i >= 0; i--) {
|
|
64
|
-
if (infosToAdd.has(propertiesOrder[i].name)) {
|
|
65
|
-
infosToAdd.delete(propertiesOrder[i].name);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
propertiesOrder.splice(i, 1);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
infosToAdd.forEach((info) => propertiesOrder.push({
|
|
72
|
-
name: info,
|
|
73
|
-
parentClassName: getPropertyClassName(info),
|
|
74
|
-
orderedTimestamp: new Date(),
|
|
75
|
-
priority: 0,
|
|
76
|
-
}));
|
|
77
|
-
let priority = propertiesOrder.length;
|
|
78
|
-
propertiesOrder.forEach((oi) => (oi.priority = priority--));
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Sorts an array of fields with respect to favorite property order.
|
|
82
|
-
* Non-favorited fields get sorted by their default priority and always have lower priority than favorited fields.
|
|
83
|
-
* @param imodel IModelConnection.
|
|
84
|
-
* @param fields Array of Field's that needs to be sorted.
|
|
85
|
-
* @note `initializeConnection` must be called with the `imodel` before calling this function.
|
|
86
|
-
* @deprecated in 4.5. Use [[FavoritePropertiesManager.sortFieldsAsync]] instead. This method is not async, therefore it requires early initialization by calling [[FavoritePropertiesManager.initializeConnection]].
|
|
87
|
-
*/
|
|
88
|
-
this.sortFields = (imodel, fields) => {
|
|
89
|
-
this.validateInitialization(imodel);
|
|
90
|
-
const iTwinId = imodel.iTwinId;
|
|
91
|
-
const imodelId = imodel.iModelId;
|
|
92
|
-
const fieldPriority = new Map();
|
|
93
|
-
fields.forEach((field) => fieldPriority.set(field, this.getFieldPriority(field, iTwinId, imodelId)));
|
|
94
|
-
const sortFunction = (left, right) => {
|
|
95
|
-
const lp = fieldPriority.get(left);
|
|
96
|
-
const rp = fieldPriority.get(right);
|
|
97
|
-
return lp < rp
|
|
98
|
-
? 1
|
|
99
|
-
: lp > rp
|
|
100
|
-
? -1
|
|
101
|
-
: left.priority < right.priority
|
|
102
|
-
? 1 // if favorite fields have equal priorities, sort by field priority
|
|
103
|
-
: left.priority > right.priority
|
|
104
|
-
? -1
|
|
105
|
-
: left.name.localeCompare(right.name);
|
|
106
|
-
};
|
|
107
|
-
return fields.sort(sortFunction);
|
|
108
|
-
};
|
|
109
|
-
this._getBaseClassesByClass = async (imodel, neededClasses) => {
|
|
110
|
-
const iTwinId = imodel.iTwinId;
|
|
111
|
-
const imodelId = imodel.iModelId;
|
|
112
|
-
const imodelInfo = getiModelInfo(iTwinId, imodelId);
|
|
113
|
-
let baseClasses;
|
|
114
|
-
if (this._imodelBaseClassesByClass.has(imodelInfo)) {
|
|
115
|
-
baseClasses = this._imodelBaseClassesByClass.get(imodelInfo);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
this._imodelBaseClassesByClass.set(imodelInfo, (baseClasses = {}));
|
|
119
|
-
}
|
|
120
|
-
const missingClasses = new Set();
|
|
121
|
-
neededClasses.forEach((className) => {
|
|
122
|
-
if (!baseClasses.hasOwnProperty(className)) {
|
|
123
|
-
missingClasses.add(className);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
if (missingClasses.size === 0) {
|
|
127
|
-
return baseClasses;
|
|
128
|
-
}
|
|
129
|
-
const query = `
|
|
130
|
-
SELECT (derivedSchema.Name || ':' || derivedClass.Name) AS "ClassFullName", (baseSchema.Name || ':' || baseClass.Name) AS "BaseClassFullName"
|
|
131
|
-
FROM ECDbMeta.ClassHasAllBaseClasses baseClassRels
|
|
132
|
-
INNER JOIN ECDbMeta.ECClassDef derivedClass ON derivedClass.ECInstanceId = baseClassRels.SourceECInstanceId
|
|
133
|
-
INNER JOIN ECDbMeta.ECSchemaDef derivedSchema ON derivedSchema.ECInstanceId = derivedClass.Schema.Id
|
|
134
|
-
INNER JOIN ECDbMeta.ECClassDef baseClass ON baseClass.ECInstanceId = baseClassRels.TargetECInstanceId
|
|
135
|
-
INNER JOIN ECDbMeta.ECSchemaDef baseSchema ON baseSchema.ECInstanceId = baseClass.Schema.Id
|
|
136
|
-
WHERE (derivedSchema.Name || ':' || derivedClass.Name) IN (${[...missingClasses].map((className) => `'${className}'`).join(",")})`;
|
|
137
|
-
const reader = imodel.createQueryReader(query, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames });
|
|
138
|
-
while (await reader.step()) {
|
|
139
|
-
const row = reader.current.toRow();
|
|
140
|
-
if (!(row.classFullName in baseClasses)) {
|
|
141
|
-
baseClasses[row.classFullName] = [];
|
|
142
|
-
}
|
|
143
|
-
baseClasses[row.classFullName].push(row.baseClassFullName);
|
|
144
|
-
}
|
|
145
|
-
return baseClasses;
|
|
146
|
-
};
|
|
147
|
-
this._storage = props.storage;
|
|
43
|
+
this.storage = props.storage;
|
|
148
44
|
this._iTwinProperties = new Map();
|
|
149
45
|
this._imodelProperties = new Map();
|
|
150
46
|
this._propertiesOrder = new Map();
|
|
151
47
|
this._imodelBaseClassesByClass = new Map();
|
|
152
48
|
this._imodelInitializationPromises = new Map();
|
|
153
49
|
}
|
|
154
|
-
dispose() {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
50
|
+
[Symbol.dispose]() {
|
|
51
|
+
if (isDisposable(this.storage)) {
|
|
52
|
+
this.storage[Symbol.dispose]();
|
|
53
|
+
/* c8 ignore next 3 */
|
|
54
|
+
}
|
|
55
|
+
else if (isIDisposable(this.storage)) { /* eslint-disable-line @typescript-eslint/no-deprecated */
|
|
56
|
+
this.storage.dispose();
|
|
158
57
|
}
|
|
159
58
|
}
|
|
59
|
+
/** @deprecated in 5.0 Use [Symbol.dispose] instead. */
|
|
60
|
+
/* c8 ignore next 3 */
|
|
61
|
+
dispose() {
|
|
62
|
+
this[Symbol.dispose]();
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Initialize favorite properties for the provided IModelConnection.
|
|
66
|
+
* @deprecated in 4.5. Initialization is performed automatically by all async methods and only needed for deprecated [[FavoritePropertiesManager.has]] and [[FavoritePropertiesManager.sortFields]].
|
|
67
|
+
*/
|
|
68
|
+
initializeConnection = async (imodel) => {
|
|
69
|
+
const imodelId = imodel.iModelId;
|
|
70
|
+
const iTwinId = imodel.iTwinId;
|
|
71
|
+
if (this._globalProperties === undefined) {
|
|
72
|
+
this._globalProperties = (await this.storage.loadProperties()) || new Set();
|
|
73
|
+
}
|
|
74
|
+
if (!this._iTwinProperties.has(iTwinId)) {
|
|
75
|
+
const iTwinProperties = (await this.storage.loadProperties(iTwinId)) || new Set();
|
|
76
|
+
this._iTwinProperties.set(iTwinId, iTwinProperties);
|
|
77
|
+
}
|
|
78
|
+
if (!this._imodelProperties.has(getiModelInfo(iTwinId, imodelId))) {
|
|
79
|
+
const imodelProperties = (await this.storage.loadProperties(iTwinId, imodelId)) || new Set();
|
|
80
|
+
this._imodelProperties.set(getiModelInfo(iTwinId, imodelId), imodelProperties);
|
|
81
|
+
}
|
|
82
|
+
const propertiesOrder = (await this.storage.loadPropertiesOrder(iTwinId, imodelId)) || [];
|
|
83
|
+
this._propertiesOrder.set(getiModelInfo(iTwinId, imodelId), propertiesOrder);
|
|
84
|
+
await this._adjustPropertyOrderInfos(iTwinId, imodelId);
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Function that removes order information of properties that are no longer
|
|
88
|
+
* favorited and adds missing order information for favorited properties.
|
|
89
|
+
*/
|
|
90
|
+
_adjustPropertyOrderInfos = async (iTwinId, imodelId) => {
|
|
91
|
+
const propertiesOrder = this._propertiesOrder.get(getiModelInfo(iTwinId, imodelId));
|
|
92
|
+
const globalProperties = this._globalProperties;
|
|
93
|
+
const iTwinProperties = this._iTwinProperties.get(iTwinId);
|
|
94
|
+
const imodelProperties = this._imodelProperties.get(getiModelInfo(iTwinId, imodelId));
|
|
95
|
+
// favorite property infos that need to be added to the propertiesOrder array
|
|
96
|
+
const infosToAdd = new Set([...globalProperties, ...iTwinProperties, ...imodelProperties]);
|
|
97
|
+
for (let i = propertiesOrder.length - 1; i >= 0; i--) {
|
|
98
|
+
if (infosToAdd.has(propertiesOrder[i].name)) {
|
|
99
|
+
infosToAdd.delete(propertiesOrder[i].name);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
propertiesOrder.splice(i, 1);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
infosToAdd.forEach((info) => propertiesOrder.push({
|
|
106
|
+
name: info,
|
|
107
|
+
parentClassName: getPropertyClassName(info),
|
|
108
|
+
orderedTimestamp: new Date(),
|
|
109
|
+
priority: 0,
|
|
110
|
+
}));
|
|
111
|
+
let priority = propertiesOrder.length;
|
|
112
|
+
propertiesOrder.forEach((oi) => (oi.priority = priority--));
|
|
113
|
+
};
|
|
160
114
|
isInitialized(imodel) {
|
|
161
115
|
const iTwinId = imodel.iTwinId;
|
|
162
116
|
const imodelId = imodel.iModelId;
|
|
@@ -217,15 +171,15 @@ export class FavoritePropertiesManager {
|
|
|
217
171
|
switch (scope) {
|
|
218
172
|
case FavoritePropertiesScope.Global:
|
|
219
173
|
favoriteProperties = this._globalProperties;
|
|
220
|
-
saveProperties = async (properties) => this.
|
|
174
|
+
saveProperties = async (properties) => this.storage.saveProperties(properties);
|
|
221
175
|
break;
|
|
222
176
|
case FavoritePropertiesScope.ITwin:
|
|
223
177
|
favoriteProperties = this._iTwinProperties.get(iTwinId);
|
|
224
|
-
saveProperties = async (properties) => this.
|
|
178
|
+
saveProperties = async (properties) => this.storage.saveProperties(properties, iTwinId);
|
|
225
179
|
break;
|
|
226
180
|
default:
|
|
227
181
|
favoriteProperties = this._imodelProperties.get(getiModelInfo(iTwinId, imodelId));
|
|
228
|
-
saveProperties = async (properties) => this.
|
|
182
|
+
saveProperties = async (properties) => this.storage.saveProperties(properties, iTwinId, imodelId);
|
|
229
183
|
}
|
|
230
184
|
const countBefore = favoriteProperties.size;
|
|
231
185
|
const fieldInfos = getFieldInfos(field);
|
|
@@ -235,7 +189,7 @@ export class FavoritePropertiesManager {
|
|
|
235
189
|
saves.push(saveProperties(favoriteProperties));
|
|
236
190
|
const propertiesOrder = this._propertiesOrder.get(getiModelInfo(iTwinId, imodelId));
|
|
237
191
|
addOrderInfos(propertiesOrder, createFieldOrderInfos(field));
|
|
238
|
-
saves.push(this.
|
|
192
|
+
saves.push(this.storage.savePropertiesOrder(propertiesOrder, iTwinId, imodelId));
|
|
239
193
|
await Promise.all(saves);
|
|
240
194
|
this.onFavoritesChanged.raiseEvent();
|
|
241
195
|
}
|
|
@@ -254,18 +208,18 @@ export class FavoritePropertiesManager {
|
|
|
254
208
|
const workingScopes = [];
|
|
255
209
|
workingScopes.push({
|
|
256
210
|
properties: this._globalProperties,
|
|
257
|
-
save: async (properties) => this.
|
|
211
|
+
save: async (properties) => this.storage.saveProperties(properties),
|
|
258
212
|
});
|
|
259
213
|
if (scope === FavoritePropertiesScope.ITwin || scope === FavoritePropertiesScope.IModel) {
|
|
260
214
|
workingScopes.push({
|
|
261
215
|
properties: this._iTwinProperties.get(iTwinId),
|
|
262
|
-
save: async (properties) => this.
|
|
216
|
+
save: async (properties) => this.storage.saveProperties(properties, iTwinId),
|
|
263
217
|
});
|
|
264
218
|
}
|
|
265
219
|
if (scope === FavoritePropertiesScope.IModel) {
|
|
266
220
|
workingScopes.push({
|
|
267
221
|
properties: this._imodelProperties.get(getiModelInfo(iTwinId, imodelId)),
|
|
268
|
-
save: async (properties) => this.
|
|
222
|
+
save: async (properties) => this.storage.saveProperties(properties, iTwinId, imodelId),
|
|
269
223
|
});
|
|
270
224
|
}
|
|
271
225
|
const saves = [];
|
|
@@ -283,7 +237,7 @@ export class FavoritePropertiesManager {
|
|
|
283
237
|
}
|
|
284
238
|
const propertiesOrder = this._propertiesOrder.get(getiModelInfo(iTwinId, imodelId));
|
|
285
239
|
removeOrderInfos(propertiesOrder, createFieldOrderInfos(field));
|
|
286
|
-
saves.push(this.
|
|
240
|
+
saves.push(this.storage.savePropertiesOrder(propertiesOrder, iTwinId, imodelId));
|
|
287
241
|
await Promise.all(saves);
|
|
288
242
|
this.onFavoritesChanged.raiseEvent();
|
|
289
243
|
}
|
|
@@ -301,15 +255,15 @@ export class FavoritePropertiesManager {
|
|
|
301
255
|
switch (scope) {
|
|
302
256
|
case FavoritePropertiesScope.Global:
|
|
303
257
|
favoriteProperties = this._globalProperties;
|
|
304
|
-
saveProperties = async () => this.
|
|
258
|
+
saveProperties = async () => this.storage.saveProperties(new Set());
|
|
305
259
|
break;
|
|
306
260
|
case FavoritePropertiesScope.ITwin:
|
|
307
261
|
favoriteProperties = this._iTwinProperties.get(iTwinId);
|
|
308
|
-
saveProperties = async () => this.
|
|
262
|
+
saveProperties = async () => this.storage.saveProperties(new Set(), iTwinId);
|
|
309
263
|
break;
|
|
310
264
|
default:
|
|
311
265
|
favoriteProperties = this._imodelProperties.get(getiModelInfo(iTwinId, imodelId));
|
|
312
|
-
saveProperties = async () => this.
|
|
266
|
+
saveProperties = async () => this.storage.saveProperties(new Set(), iTwinId, imodelId);
|
|
313
267
|
}
|
|
314
268
|
if (favoriteProperties.size === 0) {
|
|
315
269
|
return;
|
|
@@ -349,6 +303,35 @@ export class FavoritePropertiesManager {
|
|
|
349
303
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
350
304
|
return this.has(field, imodel, scope);
|
|
351
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Sorts an array of fields with respect to favorite property order.
|
|
308
|
+
* Non-favorited fields get sorted by their default priority and always have lower priority than favorited fields.
|
|
309
|
+
* @param imodel IModelConnection.
|
|
310
|
+
* @param fields Array of Field's that needs to be sorted.
|
|
311
|
+
* @note `initializeConnection` must be called with the `imodel` before calling this function.
|
|
312
|
+
* @deprecated in 4.5. Use [[FavoritePropertiesManager.sortFieldsAsync]] instead. This method is not async, therefore it requires early initialization by calling [[FavoritePropertiesManager.initializeConnection]].
|
|
313
|
+
*/
|
|
314
|
+
sortFields = (imodel, fields) => {
|
|
315
|
+
this.validateInitialization(imodel);
|
|
316
|
+
const iTwinId = imodel.iTwinId;
|
|
317
|
+
const imodelId = imodel.iModelId;
|
|
318
|
+
const fieldPriority = new Map();
|
|
319
|
+
fields.forEach((field) => fieldPriority.set(field, this.getFieldPriority(field, iTwinId, imodelId)));
|
|
320
|
+
const sortFunction = (left, right) => {
|
|
321
|
+
const lp = fieldPriority.get(left);
|
|
322
|
+
const rp = fieldPriority.get(right);
|
|
323
|
+
return lp < rp
|
|
324
|
+
? 1
|
|
325
|
+
: lp > rp
|
|
326
|
+
? -1
|
|
327
|
+
: left.priority < right.priority
|
|
328
|
+
? 1 // if favorite fields have equal priorities, sort by field priority
|
|
329
|
+
: left.priority > right.priority
|
|
330
|
+
? -1
|
|
331
|
+
: left.name.localeCompare(right.name);
|
|
332
|
+
};
|
|
333
|
+
return fields.sort(sortFunction);
|
|
334
|
+
};
|
|
352
335
|
/**
|
|
353
336
|
* Sorts an array of fields with respect to favorite property order.
|
|
354
337
|
* Non-favorited fields get sorted by their default priority and always have lower priority than favorited fields.
|
|
@@ -369,6 +352,44 @@ export class FavoritePropertiesManager {
|
|
|
369
352
|
const mostRecent = getMostRecentOrderInfo(fieldOrderInfos);
|
|
370
353
|
return mostRecent.priority;
|
|
371
354
|
}
|
|
355
|
+
_getBaseClassesByClass = async (imodel, neededClasses) => {
|
|
356
|
+
const iTwinId = imodel.iTwinId;
|
|
357
|
+
const imodelId = imodel.iModelId;
|
|
358
|
+
const imodelInfo = getiModelInfo(iTwinId, imodelId);
|
|
359
|
+
let baseClasses;
|
|
360
|
+
if (this._imodelBaseClassesByClass.has(imodelInfo)) {
|
|
361
|
+
baseClasses = this._imodelBaseClassesByClass.get(imodelInfo);
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
this._imodelBaseClassesByClass.set(imodelInfo, (baseClasses = {}));
|
|
365
|
+
}
|
|
366
|
+
const missingClasses = new Set();
|
|
367
|
+
neededClasses.forEach((className) => {
|
|
368
|
+
if (!baseClasses.hasOwnProperty(className)) {
|
|
369
|
+
missingClasses.add(className);
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
if (missingClasses.size === 0) {
|
|
373
|
+
return baseClasses;
|
|
374
|
+
}
|
|
375
|
+
const query = `
|
|
376
|
+
SELECT (derivedSchema.Name || ':' || derivedClass.Name) AS "ClassFullName", (baseSchema.Name || ':' || baseClass.Name) AS "BaseClassFullName"
|
|
377
|
+
FROM ECDbMeta.ClassHasAllBaseClasses baseClassRels
|
|
378
|
+
INNER JOIN ECDbMeta.ECClassDef derivedClass ON derivedClass.ECInstanceId = baseClassRels.SourceECInstanceId
|
|
379
|
+
INNER JOIN ECDbMeta.ECSchemaDef derivedSchema ON derivedSchema.ECInstanceId = derivedClass.Schema.Id
|
|
380
|
+
INNER JOIN ECDbMeta.ECClassDef baseClass ON baseClass.ECInstanceId = baseClassRels.TargetECInstanceId
|
|
381
|
+
INNER JOIN ECDbMeta.ECSchemaDef baseSchema ON baseSchema.ECInstanceId = baseClass.Schema.Id
|
|
382
|
+
WHERE (derivedSchema.Name || ':' || derivedClass.Name) IN (${[...missingClasses].map((className) => `'${className}'`).join(",")})`;
|
|
383
|
+
const reader = imodel.createQueryReader(query, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames });
|
|
384
|
+
while (await reader.step()) {
|
|
385
|
+
const row = reader.current.toRow();
|
|
386
|
+
if (!(row.classFullName in baseClasses)) {
|
|
387
|
+
baseClasses[row.classFullName] = [];
|
|
388
|
+
}
|
|
389
|
+
baseClasses[row.classFullName].push(row.baseClassFullName);
|
|
390
|
+
}
|
|
391
|
+
return baseClasses;
|
|
392
|
+
};
|
|
372
393
|
/** Changes field properties priorities to lower than another fields priority
|
|
373
394
|
* @param imodel IModelConnection.
|
|
374
395
|
* @param field Field that priority is being changed.
|
|
@@ -478,15 +499,10 @@ export class FavoritePropertiesManager {
|
|
|
478
499
|
// reassign priority numbers
|
|
479
500
|
let priority = allOrderInfos.length;
|
|
480
501
|
allOrderInfos.forEach((oi) => (oi.priority = priority--));
|
|
481
|
-
await this.
|
|
502
|
+
await this.storage.savePropertiesOrder(allOrderInfos, iTwinId, imodelId);
|
|
482
503
|
this.onFavoritesChanged.raiseEvent();
|
|
483
504
|
}
|
|
484
505
|
}
|
|
485
|
-
/**
|
|
486
|
-
* Used in tests to avoid collisions between multiple runs using the same storage
|
|
487
|
-
* @internal
|
|
488
|
-
*/
|
|
489
|
-
FavoritePropertiesManager.FAVORITES_IDENTIFIER_PREFIX = "";
|
|
490
506
|
var Direction;
|
|
491
507
|
(function (Direction) {
|
|
492
508
|
Direction[Direction["Up"] = -1] = "Up";
|
|
@@ -568,7 +584,6 @@ const addOrderInfos = (dest, source) => {
|
|
|
568
584
|
const removeOrderInfos = (container, toRemove) => {
|
|
569
585
|
toRemove.forEach((roi) => {
|
|
570
586
|
const index = container.findIndex((oi) => oi.name === roi.name);
|
|
571
|
-
/* istanbul ignore else */
|
|
572
587
|
if (index >= 0) {
|
|
573
588
|
container.splice(index, 1);
|
|
574
589
|
}
|