@itwin/presentation-frontend 4.5.0-dev.23 → 4.5.0-dev.24

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 (23) hide show
  1. package/lib/cjs/presentation-frontend/PresentationManager.d.ts +77 -17
  2. package/lib/cjs/presentation-frontend/PresentationManager.d.ts.map +1 -1
  3. package/lib/cjs/presentation-frontend/PresentationManager.js +164 -108
  4. package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
  5. package/lib/cjs/presentation-frontend/StreamedResponseGenerator.d.ts +30 -0
  6. package/lib/cjs/presentation-frontend/StreamedResponseGenerator.d.ts.map +1 -0
  7. package/lib/cjs/presentation-frontend/StreamedResponseGenerator.js +117 -0
  8. package/lib/cjs/presentation-frontend/StreamedResponseGenerator.js.map +1 -0
  9. package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.d.ts.map +1 -1
  10. package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js +8 -4
  11. package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
  12. package/lib/esm/presentation-frontend/PresentationManager.d.ts +77 -17
  13. package/lib/esm/presentation-frontend/PresentationManager.d.ts.map +1 -1
  14. package/lib/esm/presentation-frontend/PresentationManager.js +163 -106
  15. package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
  16. package/lib/esm/presentation-frontend/StreamedResponseGenerator.d.ts +30 -0
  17. package/lib/esm/presentation-frontend/StreamedResponseGenerator.d.ts.map +1 -0
  18. package/lib/esm/presentation-frontend/StreamedResponseGenerator.js +113 -0
  19. package/lib/esm/presentation-frontend/StreamedResponseGenerator.js.map +1 -0
  20. package/lib/esm/presentation-frontend/selection/HiliteSetProvider.d.ts.map +1 -1
  21. package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js +8 -4
  22. package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
  23. package/package.json +15 -15
@@ -5,7 +5,7 @@ import { BeEvent, IDisposable } from "@itwin/core-bentley";
5
5
  import { IModelConnection } from "@itwin/core-frontend";
6
6
  import { UnitSystemKey } from "@itwin/core-quantity";
7
7
  import { SchemaContext } from "@itwin/ecschema-metadata";
8
- import { ClientDiagnosticsAttribute, Content, ContentDescriptorRequestOptions, ContentInstanceKeysRequestOptions, ContentRequestOptions, ContentSourcesRequestOptions, ContentUpdateInfo, Descriptor, DescriptorOverrides, DisplayLabelRequestOptions, DisplayLabelsRequestOptions, DisplayValueGroup, DistinctValuesRequestOptions, ElementProperties, FilterByInstancePathsHierarchyRequestOptions, FilterByTextHierarchyRequestOptions, FormatsMap, HierarchyLevelDescriptorRequestOptions, HierarchyRequestOptions, HierarchyUpdateInfo, InstanceKey, KeySet, LabelDefinition, Node, NodeKey, NodePathElement, Paged, PagedResponse, PageOptions, RpcRequestsHandler, RulesetVariable, SelectClassInfo, SingleElementPropertiesRequestOptions } from "@itwin/presentation-common";
8
+ import { ClientDiagnosticsAttribute, Content, ContentDescriptorRequestOptions, ContentInstanceKeysRequestOptions, ContentRequestOptions, ContentSourcesRequestOptions, ContentUpdateInfo, Descriptor, DescriptorOverrides, DisplayLabelRequestOptions, DisplayLabelsRequestOptions, DisplayValueGroup, DistinctValuesRequestOptions, ElementProperties, FilterByInstancePathsHierarchyRequestOptions, FilterByTextHierarchyRequestOptions, FormatsMap, HierarchyLevelDescriptorRequestOptions, HierarchyRequestOptions, HierarchyUpdateInfo, InstanceKey, Item, KeySet, LabelDefinition, Node, NodeKey, NodePathElement, Paged, PagedResponse, RpcRequestsHandler, RulesetVariable, SelectClassInfo, SingleElementPropertiesRequestOptions } from "@itwin/presentation-common";
9
9
  import { IpcRequestsHandler } from "./IpcRequestsHandler";
10
10
  import { RulesetManager } from "./RulesetManager";
11
11
  import { RulesetVariablesManager } from "./RulesetVariablesManager";
@@ -33,6 +33,28 @@ export interface IModelContentChangeEventArgs {
33
33
  /** Key of iModel that was used to create content. It matches [[IModelConnection.key]] property. */
34
34
  imodelKey: string;
35
35
  }
36
+ /**
37
+ * Options for requests that can return multiple pages of items concurrently.
38
+ * @public
39
+ */
40
+ export type MultipleValuesRequestOptions = Paged<{
41
+ maxParallelRequests?: number;
42
+ }>;
43
+ /**
44
+ * Options for requests that retrieve nodes.
45
+ * @public
46
+ */
47
+ export type GetNodesRequestOptions = HierarchyRequestOptions<IModelConnection, NodeKey, RulesetVariable> & ClientDiagnosticsAttribute;
48
+ /**
49
+ * Options for requests that retrieve content.
50
+ * @public
51
+ */
52
+ export type GetContentRequestOptions = ContentRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable> & ClientDiagnosticsAttribute;
53
+ /**
54
+ * Options for requests that retrieve distinct values.
55
+ * @public
56
+ */
57
+ export type GetDistinctValuesRequestOptions = DistinctValuesRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable> & ClientDiagnosticsAttribute;
36
58
  /**
37
59
  * Properties used to configure [[PresentationManager]]
38
60
  * @public
@@ -160,12 +182,23 @@ export declare class PresentationManager implements IDisposable {
160
182
  vars(rulesetId: string): RulesetVariablesManager;
161
183
  private toRpcTokenOptions;
162
184
  private addRulesetAndVariablesToOptions;
163
- /** Retrieves nodes */
164
- getNodes(requestOptions: Paged<HierarchyRequestOptions<IModelConnection, NodeKey, RulesetVariable>> & ClientDiagnosticsAttribute): Promise<Node[]>;
185
+ /** Returns an iterator that polls nodes asynchronously. */
186
+ getNodesIterator(requestOptions: GetNodesRequestOptions & MultipleValuesRequestOptions): Promise<{
187
+ total: number;
188
+ items: AsyncIterableIterator<Node>;
189
+ }>;
190
+ /**
191
+ * Retrieves nodes
192
+ * @deprecated in 4.5. Use [[getNodesIterator]] instead.
193
+ */
194
+ getNodes(requestOptions: GetNodesRequestOptions & MultipleValuesRequestOptions): Promise<Node[]>;
165
195
  /** Retrieves nodes count. */
166
- getNodesCount(requestOptions: HierarchyRequestOptions<IModelConnection, NodeKey, RulesetVariable> & ClientDiagnosticsAttribute): Promise<number>;
167
- /** Retrieves total nodes count and a single page of nodes. */
168
- getNodesAndCount(requestOptions: Paged<HierarchyRequestOptions<IModelConnection, NodeKey, RulesetVariable>> & ClientDiagnosticsAttribute): Promise<{
196
+ getNodesCount(requestOptions: GetNodesRequestOptions): Promise<number>;
197
+ /**
198
+ * Retrieves total nodes count and a single page of nodes.
199
+ * @deprecated in 4.5. Use [[getNodesIterator]] instead.
200
+ */
201
+ getNodesAndCount(requestOptions: GetNodesRequestOptions & MultipleValuesRequestOptions): Promise<{
169
202
  count: number;
170
203
  nodes: Node[];
171
204
  }>;
@@ -187,16 +220,37 @@ export declare class PresentationManager implements IDisposable {
187
220
  /** Retrieves the content descriptor which describes the content and can be used to customize it. */
188
221
  getContentDescriptor(requestOptions: ContentDescriptorRequestOptions<IModelConnection, KeySet, RulesetVariable> & ClientDiagnosticsAttribute): Promise<Descriptor | undefined>;
189
222
  /** Retrieves overall content set size. */
190
- getContentSetSize(requestOptions: ContentRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable> & ClientDiagnosticsAttribute): Promise<number>;
191
- /** Retrieves content which consists of a content descriptor and a page of records. */
192
- getContent(requestOptions: Paged<ContentRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>> & ClientDiagnosticsAttribute): Promise<Content | undefined>;
193
- /** Retrieves content set size and content which consists of a content descriptor and a page of records. */
194
- getContentAndSize(requestOptions: Paged<ContentRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>> & ClientDiagnosticsAttribute): Promise<{
223
+ getContentSetSize(requestOptions: GetContentRequestOptions): Promise<number>;
224
+ private getContentIteratorInternal;
225
+ /** Retrieves a content descriptor, item count and async generator for the items themselves. */
226
+ getContentIterator(requestOptions: GetContentRequestOptions & MultipleValuesRequestOptions): Promise<{
227
+ descriptor: Descriptor;
228
+ total: number;
229
+ items: AsyncIterableIterator<Item>;
230
+ } | undefined>;
231
+ /**
232
+ * Retrieves content which consists of a content descriptor and a page of records.
233
+ * @deprecated in 4.5. Use [[getContentIterator]] instead.
234
+ */
235
+ getContent(requestOptions: GetContentRequestOptions & MultipleValuesRequestOptions): Promise<Content | undefined>;
236
+ /**
237
+ * Retrieves content set size and content which consists of a content descriptor and a page of records.
238
+ * @deprecated in 4.5. Use [[getContentIterator]] instead.
239
+ */
240
+ getContentAndSize(requestOptions: GetContentRequestOptions & MultipleValuesRequestOptions): Promise<{
195
241
  content: Content;
196
242
  size: number;
197
243
  } | undefined>;
198
- /** Retrieves distinct values of specific field from the content. */
199
- getPagedDistinctValues(requestOptions: DistinctValuesRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable> & ClientDiagnosticsAttribute): Promise<PagedResponse<DisplayValueGroup>>;
244
+ /** Returns an iterator that asynchronously polls distinct values of specific field from the content. */
245
+ getDistinctValuesIterator(requestOptions: GetDistinctValuesRequestOptions & MultipleValuesRequestOptions): Promise<{
246
+ total: number;
247
+ items: AsyncIterableIterator<DisplayValueGroup>;
248
+ }>;
249
+ /**
250
+ * Retrieves distinct values of specific field from the content.
251
+ * @deprecated in 4.5. Use [[getDistinctValuesIterator]] instead.
252
+ */
253
+ getPagedDistinctValues(requestOptions: GetDistinctValuesRequestOptions & MultipleValuesRequestOptions): Promise<PagedResponse<DisplayValueGroup>>;
200
254
  /**
201
255
  * Retrieves property data in a simplified format for a single element specified by ID.
202
256
  * @public
@@ -206,15 +260,21 @@ export declare class PresentationManager implements IDisposable {
206
260
  * Retrieves content item instance keys.
207
261
  * @public
208
262
  */
209
- getContentInstanceKeys(requestOptions: ContentInstanceKeysRequestOptions<IModelConnection, KeySet, RulesetVariable> & ClientDiagnosticsAttribute): Promise<{
263
+ getContentInstanceKeys(requestOptions: ContentInstanceKeysRequestOptions<IModelConnection, KeySet, RulesetVariable> & ClientDiagnosticsAttribute & MultipleValuesRequestOptions): Promise<{
210
264
  total: number;
211
265
  items: () => AsyncGenerator<InstanceKey>;
212
266
  }>;
213
267
  /** Retrieves display label definition of specific item. */
214
268
  getDisplayLabelDefinition(requestOptions: DisplayLabelRequestOptions<IModelConnection, InstanceKey> & ClientDiagnosticsAttribute): Promise<LabelDefinition>;
215
269
  /** Retrieves display label definition of specific items. */
216
- getDisplayLabelDefinitions(requestOptions: DisplayLabelsRequestOptions<IModelConnection, InstanceKey> & ClientDiagnosticsAttribute): Promise<LabelDefinition[]>;
270
+ getDisplayLabelDefinitionsIterator(requestOptions: DisplayLabelsRequestOptions<IModelConnection, InstanceKey> & ClientDiagnosticsAttribute & MultipleValuesRequestOptions): Promise<{
271
+ total: number;
272
+ items: AsyncIterableIterator<LabelDefinition>;
273
+ }>;
274
+ /**
275
+ * Retrieves display label definition of specific items.
276
+ * @deprecated in 4.5. Use [[getDisplayLabelDefinitionsIterator]] instead.
277
+ */
278
+ getDisplayLabelDefinitions(requestOptions: DisplayLabelsRequestOptions<IModelConnection, InstanceKey> & ClientDiagnosticsAttribute & MultipleValuesRequestOptions): Promise<LabelDefinition[]>;
217
279
  }
218
- /** @internal */
219
- export declare const buildPagedArrayResponse: <TItem>(requestedPage: PageOptions | undefined, getter: (page: Required<PageOptions>, requestIndex: number) => Promise<PagedResponse<TItem>>) => Promise<PagedResponse<TItem>>;
220
280
  //# sourceMappingURL=PresentationManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PresentationManager.d.ts","sourceRoot":"","sources":["../../../src/presentation-frontend/PresentationManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAqB,WAAW,EAAuB,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAa,gBAAgB,EAAU,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EACL,0BAA0B,EAC1B,OAAO,EACP,+BAA+B,EAE/B,iCAAiC,EAEjC,qBAAqB,EACrB,4BAA4B,E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C,gBAAgB,EAAE,MAAM,EAAE,eAAe,CAAC,GAAG,0BAA0B,GACxH,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,cAAc,CAAC,WAAW,CAAC,CAAA;KAAE,CAAC;IA0BvE,2DAA2D;IAC9C,yBAAyB,CACpC,cAAc,EAAE,0BAA0B,CAAC,gBAAgB,EAAE,WAAW,CAAC,GAAG,0BAA0B,GACrG,OAAO,CAAC,eAAe,CAAC;IAO3B,4DAA4D;IAC/C,0BAA0B,CACrC,cAAc,EAAE,2BAA2B,CAAC,gBAAgB,EAAE,WAAW,CAAC,GAAG,0BAA0B,GACtG,OAAO,CAAC,eAAe,EAAE,CAAC;CAS9B;AAmDD,gBAAgB;AAChB,eAAO,MAAM,uBAAuB,yBACnB,WAAW,GAAG,SAAS,iBACvB,SAAS,WAAW,CAAC,gBAAgB,MAAM,oEAQ3D,CAAC"}
1
+ {"version":3,"file":"PresentationManager.d.ts","sourceRoot":"","sources":["../../../src/presentation-frontend/PresentationManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAqB,WAAW,EAAuB,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAa,gBAAgB,EAAU,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EACL,0BAA0B,EAC1B,OAAO,EACP,+BAA+B,EAE/B,iCAAiC,EAEjC,qBAAqB,EACrB,4BAA4B,EAC5B,iBAAiB,EACjB,UAAU,EACV,mBAAmB,EACnB,0BAA0B,EAC1B,2BAA2B,EAC3B,iBAAiB,EACjB,4BAA4B,EAC5B,iBAAiB,EACjB,4CAA4C,EAC5C,mCAAmC,EACnC,UAAU,EACV,sCAAsC,EACtC,uBAAuB,EACvB,mBAAmB,EACnB,WAAW,EACX,IAAI,EAGJ,MA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AAC,KAAK,EAAE,qBAAqB,CAAC,iBAAiB,CAAC,CAAA;KAAE,CAAC;IAwB9E;;;OAGG;IACU,sBAAsB,CACjC,cAAc,EAAE,+BAA+B,GAAG,4BAA4B,GAC7E,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAQ5C;;;OAGG;IACU,oBAAoB,CAC/B,cAAc,EAAE,qCAAqC,CAAC,gBAAgB,CAAC,GAAG,0BAA0B,GACnG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAUzC;;;OAGG;IACU,sBAAsB,CACjC,cAAc,EAAE,iCAAiC,CAAC,gBAAgB,EAAE,MAAM,EAAE,eAAe,CAAC,GAAG,0BAA0B,GAAG,4BAA4B,GACvJ,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,cAAc,CAAC,WAAW,CAAC,CAAA;KAAE,CAAC;IAiCvE,2DAA2D;IAC9C,yBAAyB,CACpC,cAAc,EAAE,0BAA0B,CAAC,gBAAgB,EAAE,WAAW,CAAC,GAAG,0BAA0B,GACrG,OAAO,CAAC,eAAe,CAAC;IAO3B,4DAA4D;IAC/C,kCAAkC,CAC7C,cAAc,EAAE,2BAA2B,CAAC,gBAAgB,EAAE,WAAW,CAAC,GAAG,0BAA0B,GAAG,4BAA4B,GACrI,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,qBAAqB,CAAC,eAAe,CAAC,CAAA;KAAE,CAAC;IAgB5E;;;OAGG;IACU,0BAA0B,CACrC,cAAc,EAAE,2BAA2B,CAAC,gBAAgB,EAAE,WAAW,CAAC,GAAG,0BAA0B,GAAG,4BAA4B,GACrI,OAAO,CAAC,eAAe,EAAE,CAAC;CAI9B"}
@@ -7,7 +7,7 @@
7
7
  * @module Core
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.buildPagedArrayResponse = exports.PresentationManager = void 0;
10
+ exports.PresentationManager = void 0;
11
11
  const core_bentley_1 = require("@itwin/core-bentley");
12
12
  const core_frontend_1 = require("@itwin/core-frontend");
13
13
  const presentation_common_1 = require("@itwin/presentation-common");
@@ -16,6 +16,7 @@ const LocalizationHelper_1 = require("./LocalizationHelper");
16
16
  const RulesetManager_1 = require("./RulesetManager");
17
17
  const RulesetVariablesManager_1 = require("./RulesetVariablesManager");
18
18
  const SelectionManager_1 = require("./selection/SelectionManager");
19
+ const StreamedResponseGenerator_1 = require("./StreamedResponseGenerator");
19
20
  /**
20
21
  * Frontend Presentation manager which basically just forwards all calls to
21
22
  * the backend implementation.
@@ -192,14 +193,31 @@ class PresentationManager {
192
193
  }
193
194
  return { ...options, rulesetOrId: foundRulesetOrId, rulesetVariables: variables };
194
195
  }
195
- /** Retrieves nodes */
196
- async getNodes(requestOptions) {
196
+ /** Returns an iterator that polls nodes asynchronously. */
197
+ async getNodesIterator(requestOptions) {
197
198
  this.startIModelInitialization(requestOptions.imodel);
198
199
  const options = await this.addRulesetAndVariablesToOptions(requestOptions);
199
200
  const rpcOptions = this.toRpcTokenOptions({ ...options });
200
- const result = await (0, exports.buildPagedArrayResponse)(options.paging, async (partialPageOptions) => this._requestsHandler.getPagedNodes({ ...rpcOptions, paging: partialPageOptions }));
201
- // eslint-disable-next-line deprecation/deprecation
202
- return this._localizationHelper.getLocalizedNodes(result.items.map(presentation_common_1.Node.fromJSON));
201
+ const generator = new StreamedResponseGenerator_1.StreamedResponseGenerator({
202
+ ...requestOptions,
203
+ getBatch: async (paging) => {
204
+ const result = await this._requestsHandler.getPagedNodes({ ...rpcOptions, paging });
205
+ return {
206
+ total: result.total,
207
+ // eslint-disable-next-line deprecation/deprecation
208
+ items: this._localizationHelper.getLocalizedNodes(result.items.map(presentation_common_1.Node.fromJSON)),
209
+ };
210
+ },
211
+ });
212
+ return generator.createAsyncIteratorResponse();
213
+ }
214
+ /**
215
+ * Retrieves nodes
216
+ * @deprecated in 4.5. Use [[getNodesIterator]] instead.
217
+ */
218
+ async getNodes(requestOptions) {
219
+ const result = await this.getNodesIterator(requestOptions);
220
+ return collect(result.items);
203
221
  }
204
222
  /** Retrieves nodes count. */
205
223
  async getNodesCount(requestOptions) {
@@ -208,16 +226,15 @@ class PresentationManager {
208
226
  const rpcOptions = this.toRpcTokenOptions({ ...options });
209
227
  return this._requestsHandler.getNodesCount(rpcOptions);
210
228
  }
211
- /** Retrieves total nodes count and a single page of nodes. */
229
+ /**
230
+ * Retrieves total nodes count and a single page of nodes.
231
+ * @deprecated in 4.5. Use [[getNodesIterator]] instead.
232
+ */
212
233
  async getNodesAndCount(requestOptions) {
213
- this.startIModelInitialization(requestOptions.imodel);
214
- const options = await this.addRulesetAndVariablesToOptions(requestOptions);
215
- const rpcOptions = this.toRpcTokenOptions({ ...options });
216
- const result = await (0, exports.buildPagedArrayResponse)(options.paging, async (partialPageOptions) => this._requestsHandler.getPagedNodes({ ...rpcOptions, paging: partialPageOptions }));
234
+ const result = await this.getNodesIterator(requestOptions);
217
235
  return {
218
236
  count: result.total,
219
- // eslint-disable-next-line deprecation/deprecation
220
- nodes: this._localizationHelper.getLocalizedNodes(result.items.map(presentation_common_1.Node.fromJSON)),
237
+ nodes: await collect(result.items),
221
238
  };
222
239
  }
223
240
  /**
@@ -293,54 +310,92 @@ class PresentationManager {
293
310
  });
294
311
  return this._requestsHandler.getContentSetSize(rpcOptions);
295
312
  }
296
- /** Retrieves content which consists of a content descriptor and a page of records. */
297
- async getContent(requestOptions) {
298
- return (await this.getContentAndSize(requestOptions))?.content;
299
- }
300
- /** Retrieves content set size and content which consists of a content descriptor and a page of records. */
301
- async getContentAndSize(requestOptions) {
302
- this.startIModelInitialization(requestOptions.imodel);
303
- try {
304
- const options = await this.addRulesetAndVariablesToOptions(requestOptions);
305
- const rpcOptions = this.toRpcTokenOptions({
306
- ...options,
307
- descriptor: getDescriptorOverrides(requestOptions.descriptor),
308
- keys: stripTransientElementKeys(requestOptions.keys).toJSON(),
309
- ...(!requestOptions.omitFormattedValues && this._schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),
310
- });
311
- let descriptor = requestOptions.descriptor instanceof presentation_common_1.Descriptor ? requestOptions.descriptor : undefined;
312
- const result = await (0, exports.buildPagedArrayResponse)(options.paging, async (partialPageOptions, requestIndex) => {
313
- if (0 === requestIndex && !descriptor) {
314
- const content = await this._requestsHandler.getPagedContent({ ...rpcOptions, paging: partialPageOptions });
315
- if (content) {
316
- descriptor = presentation_common_1.Descriptor.fromJSON(content.descriptor);
317
- return content.contentSet;
318
- }
319
- return { total: 0, items: [] };
320
- }
321
- return this._requestsHandler.getPagedContentSet({ ...rpcOptions, paging: partialPageOptions });
322
- });
323
- if (!descriptor) {
313
+ async getContentIteratorInternal(requestOptions) {
314
+ const options = await this.addRulesetAndVariablesToOptions(requestOptions);
315
+ const rpcOptions = this.toRpcTokenOptions({
316
+ ...options,
317
+ descriptor: getDescriptorOverrides(requestOptions.descriptor),
318
+ keys: stripTransientElementKeys(requestOptions.keys).toJSON(),
319
+ ...(!requestOptions.omitFormattedValues && this._schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),
320
+ });
321
+ let contentFormatter;
322
+ if (!requestOptions.omitFormattedValues && this._schemaContextProvider) {
323
+ const koqPropertyFormatter = new presentation_common_1.KoqPropertyValueFormatter(this._schemaContextProvider(requestOptions.imodel), this._defaultFormats);
324
+ contentFormatter = new presentation_common_1.ContentFormatter(new presentation_common_1.ContentPropertyValueFormatter(koqPropertyFormatter), requestOptions.unitSystem ?? this._explicitActiveUnitSystem ?? core_frontend_1.IModelApp.quantityFormatter.activeUnitSystem);
325
+ }
326
+ let descriptor = requestOptions.descriptor instanceof presentation_common_1.Descriptor ? requestOptions.descriptor : undefined;
327
+ let firstPage;
328
+ if (!descriptor) {
329
+ const firstPageResponse = await this._requestsHandler.getPagedContent(rpcOptions);
330
+ if (!firstPageResponse?.descriptor || !firstPageResponse.contentSet) {
324
331
  return undefined;
325
332
  }
326
- const items = result.items.map((itemJson) => presentation_common_1.Item.fromJSON(itemJson)).filter((item) => item !== undefined);
327
- const resultContent = new presentation_common_1.Content(descriptor, items);
328
- if (!requestOptions.omitFormattedValues && this._schemaContextProvider) {
329
- const koqPropertyFormatter = new presentation_common_1.KoqPropertyValueFormatter(this._schemaContextProvider(requestOptions.imodel), this._defaultFormats);
330
- const contentFormatter = new presentation_common_1.ContentFormatter(new presentation_common_1.ContentPropertyValueFormatter(koqPropertyFormatter), requestOptions.unitSystem ?? this._explicitActiveUnitSystem ?? core_frontend_1.IModelApp.quantityFormatter.activeUnitSystem);
331
- await contentFormatter.formatContent(resultContent);
333
+ descriptor = presentation_common_1.Descriptor.fromJSON(firstPageResponse?.descriptor);
334
+ firstPage = firstPageResponse?.contentSet;
335
+ }
336
+ // istanbul ignore if
337
+ if (!descriptor) {
338
+ return undefined;
339
+ }
340
+ descriptor = this._localizationHelper.getLocalizedContentDescriptor(descriptor);
341
+ const getPage = async (paging, requestIndex) => {
342
+ let contentSet = requestIndex === 0 ? firstPage : undefined;
343
+ contentSet ??= await this._requestsHandler.getPagedContentSet({ ...rpcOptions, paging });
344
+ let items = contentSet.items.map((x) => presentation_common_1.Item.fromJSON(x)).filter((x) => x !== undefined);
345
+ if (contentFormatter) {
346
+ items = await contentFormatter.formatContentItems(items, descriptor);
332
347
  }
348
+ items = this._localizationHelper.getLocalizedContentItems(items);
333
349
  return {
334
- size: result.total,
335
- content: this._localizationHelper.getLocalizedContent(resultContent),
350
+ total: contentSet.total,
351
+ items,
336
352
  };
353
+ };
354
+ const generator = new StreamedResponseGenerator_1.StreamedResponseGenerator({
355
+ ...requestOptions,
356
+ getBatch: getPage,
357
+ });
358
+ return {
359
+ ...(await generator.createAsyncIteratorResponse()),
360
+ descriptor,
361
+ };
362
+ }
363
+ /** Retrieves a content descriptor, item count and async generator for the items themselves. */
364
+ async getContentIterator(requestOptions) {
365
+ this.startIModelInitialization(requestOptions.imodel);
366
+ const response = await this.getContentIteratorInternal(requestOptions);
367
+ if (!response) {
368
+ return undefined;
337
369
  }
338
- finally {
339
- await this.ensureIModelInitialized(requestOptions.imodel);
370
+ await this.ensureIModelInitialized(requestOptions.imodel);
371
+ return response;
372
+ }
373
+ /**
374
+ * Retrieves content which consists of a content descriptor and a page of records.
375
+ * @deprecated in 4.5. Use [[getContentIterator]] instead.
376
+ */
377
+ async getContent(requestOptions) {
378
+ // eslint-disable-next-line deprecation/deprecation
379
+ return (await this.getContentAndSize(requestOptions))?.content;
380
+ }
381
+ /**
382
+ * Retrieves content set size and content which consists of a content descriptor and a page of records.
383
+ * @deprecated in 4.5. Use [[getContentIterator]] instead.
384
+ */
385
+ async getContentAndSize(requestOptions) {
386
+ const response = await this.getContentIterator(requestOptions);
387
+ if (!response) {
388
+ return undefined;
340
389
  }
390
+ const { descriptor, total } = response;
391
+ const items = await collect(response.items);
392
+ return {
393
+ content: new presentation_common_1.Content(descriptor, items),
394
+ size: total,
395
+ };
341
396
  }
342
- /** Retrieves distinct values of specific field from the content. */
343
- async getPagedDistinctValues(requestOptions) {
397
+ /** Returns an iterator that asynchronously polls distinct values of specific field from the content. */
398
+ async getDistinctValuesIterator(requestOptions) {
344
399
  this.startIModelInitialization(requestOptions.imodel);
345
400
  const options = await this.addRulesetAndVariablesToOptions(requestOptions);
346
401
  const rpcOptions = {
@@ -348,11 +403,28 @@ class PresentationManager {
348
403
  descriptor: getDescriptorOverrides(options.descriptor),
349
404
  keys: stripTransientElementKeys(options.keys).toJSON(),
350
405
  };
351
- const result = await (0, exports.buildPagedArrayResponse)(requestOptions.paging, async (partialPageOptions) => this._requestsHandler.getPagedDistinctValues({ ...rpcOptions, paging: partialPageOptions }));
406
+ const generator = new StreamedResponseGenerator_1.StreamedResponseGenerator({
407
+ ...requestOptions,
408
+ getBatch: async (paging) => {
409
+ const response = await this._requestsHandler.getPagedDistinctValues({ ...rpcOptions, paging });
410
+ return {
411
+ total: response.total,
412
+ // eslint-disable-next-line deprecation/deprecation
413
+ items: response.items.map((x) => this._localizationHelper.getLocalizedDisplayValueGroup(presentation_common_1.DisplayValueGroup.fromJSON(x))),
414
+ };
415
+ },
416
+ });
417
+ return generator.createAsyncIteratorResponse();
418
+ }
419
+ /**
420
+ * Retrieves distinct values of specific field from the content.
421
+ * @deprecated in 4.5. Use [[getDistinctValuesIterator]] instead.
422
+ */
423
+ async getPagedDistinctValues(requestOptions) {
424
+ const result = await this.getDistinctValuesIterator(requestOptions);
352
425
  return {
353
- ...result,
354
- // eslint-disable-next-line deprecation/deprecation
355
- items: result.items.map(presentation_common_1.DisplayValueGroup.fromJSON).map((g) => this._localizationHelper.getLocalizedDisplayValueGroup(g)),
426
+ total: result.total,
427
+ items: await collect(result.items),
356
428
  };
357
429
  }
358
430
  /**
@@ -379,9 +451,9 @@ class PresentationManager {
379
451
  ...this.toRpcTokenOptions(options),
380
452
  keys: stripTransientElementKeys(options.keys).toJSON(),
381
453
  };
382
- const props = {
383
- page: requestOptions.paging,
384
- get: async (page) => {
454
+ const generator = new StreamedResponseGenerator_1.StreamedResponseGenerator({
455
+ ...requestOptions,
456
+ getBatch: async (page) => {
385
457
  const keys = await this._requestsHandler.getContentInstanceKeys({ ...rpcOptions, paging: page });
386
458
  return {
387
459
  total: keys.total,
@@ -393,8 +465,14 @@ class PresentationManager {
393
465
  }, new Array()),
394
466
  };
395
467
  },
468
+ });
469
+ const { total, items } = await generator.createAsyncIteratorResponse();
470
+ return {
471
+ total,
472
+ async *items() {
473
+ yield* items;
474
+ },
396
475
  };
397
- return createPagedGeneratorResponse(props);
398
476
  }
399
477
  /** Retrieves display label definition of specific item. */
400
478
  async getDisplayLabelDefinition(requestOptions) {
@@ -404,14 +482,27 @@ class PresentationManager {
404
482
  return this._localizationHelper.getLocalizedLabelDefinition(result);
405
483
  }
406
484
  /** Retrieves display label definition of specific items. */
407
- async getDisplayLabelDefinitions(requestOptions) {
485
+ async getDisplayLabelDefinitionsIterator(requestOptions) {
408
486
  this.startIModelInitialization(requestOptions.imodel);
409
487
  const rpcOptions = this.toRpcTokenOptions({ ...requestOptions });
410
- const result = await (0, exports.buildPagedArrayResponse)(undefined, async (partialPageOptions) => {
411
- const partialKeys = !partialPageOptions.start ? rpcOptions.keys : rpcOptions.keys.slice(partialPageOptions.start);
412
- return this._requestsHandler.getPagedDisplayLabelDefinitions({ ...rpcOptions, keys: partialKeys });
488
+ const generator = new StreamedResponseGenerator_1.StreamedResponseGenerator({
489
+ ...requestOptions,
490
+ getBatch: async (page) => {
491
+ const partialKeys = !page.start ? rpcOptions.keys : rpcOptions.keys.slice(page.start);
492
+ const result = await this._requestsHandler.getPagedDisplayLabelDefinitions({ ...rpcOptions, keys: partialKeys });
493
+ result.items = this._localizationHelper.getLocalizedLabelDefinitions(result.items);
494
+ return result;
495
+ },
413
496
  });
414
- return this._localizationHelper.getLocalizedLabelDefinitions(result.items);
497
+ return generator.createAsyncIteratorResponse();
498
+ }
499
+ /**
500
+ * Retrieves display label definition of specific items.
501
+ * @deprecated in 4.5. Use [[getDisplayLabelDefinitionsIterator]] instead.
502
+ */
503
+ async getDisplayLabelDefinitions(requestOptions) {
504
+ const { items } = await this.getDisplayLabelDefinitionsIterator(requestOptions);
505
+ return collect(items);
415
506
  }
416
507
  }
417
508
  exports.PresentationManager = PresentationManager;
@@ -421,48 +512,6 @@ const getDescriptorOverrides = (descriptorOrOverrides) => {
421
512
  }
422
513
  return descriptorOrOverrides;
423
514
  };
424
- async function createPagedGeneratorResponse(props) {
425
- let pageStart = props.page?.start ?? 0;
426
- let pageSize = props.page?.size ?? 0;
427
- let requestIndex = 0;
428
- const firstPage = await props.get({ start: pageStart, size: pageSize }, requestIndex++);
429
- return {
430
- total: firstPage.total,
431
- async *items() {
432
- let partialResult = firstPage;
433
- while (true) {
434
- for (const item of partialResult.items) {
435
- yield item;
436
- }
437
- const receivedItemsCount = partialResult.items.length;
438
- if (partialResult.total !== 0 && receivedItemsCount === 0) {
439
- if (pageStart >= partialResult.total) {
440
- throw new Error(`Requested page with start index ${pageStart} is out of bounds. Total number of items: ${partialResult.total}`);
441
- }
442
- throw new Error("Paged request returned non zero total count but no items");
443
- }
444
- if ((pageSize !== 0 && receivedItemsCount >= pageSize) || receivedItemsCount >= partialResult.total - pageStart) {
445
- break;
446
- }
447
- if (pageSize !== 0) {
448
- pageSize -= receivedItemsCount;
449
- }
450
- pageStart += receivedItemsCount;
451
- partialResult = await props.get({ start: pageStart, size: pageSize }, requestIndex++);
452
- }
453
- },
454
- };
455
- }
456
- /** @internal */
457
- const buildPagedArrayResponse = async (requestedPage, getter) => {
458
- const items = new Array();
459
- const gen = await createPagedGeneratorResponse({ page: requestedPage, get: getter });
460
- for await (const item of gen.items()) {
461
- items.push(item);
462
- }
463
- return { total: gen.total, items };
464
- };
465
- exports.buildPagedArrayResponse = buildPagedArrayResponse;
466
515
  const stripTransientElementKeys = (keys) => {
467
516
  if (!keys.some((key) => presentation_common_1.Key.isInstanceKey(key) && key.className === SelectionManager_1.TRANSIENT_ELEMENT_CLASSNAME)) {
468
517
  return keys;
@@ -478,4 +527,11 @@ const stripTransientElementKeys = (keys) => {
478
527
  });
479
528
  return copy;
480
529
  };
530
+ async function collect(iter) {
531
+ const result = new Array();
532
+ for await (const value of iter) {
533
+ result.push(value);
534
+ }
535
+ return result;
536
+ }
481
537
  //# sourceMappingURL=PresentationManager.js.map