@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"}
@@ -13,6 +13,7 @@ import { FrontendLocalizationHelper } from "./LocalizationHelper";
13
13
  import { RulesetManagerImpl } from "./RulesetManager";
14
14
  import { RulesetVariablesManagerImpl } from "./RulesetVariablesManager";
15
15
  import { TRANSIENT_ELEMENT_CLASSNAME } from "./selection/SelectionManager";
16
+ import { StreamedResponseGenerator } from "./StreamedResponseGenerator";
16
17
  /**
17
18
  * Frontend Presentation manager which basically just forwards all calls to
18
19
  * the backend implementation.
@@ -189,14 +190,31 @@ export class PresentationManager {
189
190
  }
190
191
  return { ...options, rulesetOrId: foundRulesetOrId, rulesetVariables: variables };
191
192
  }
192
- /** Retrieves nodes */
193
- async getNodes(requestOptions) {
193
+ /** Returns an iterator that polls nodes asynchronously. */
194
+ async getNodesIterator(requestOptions) {
194
195
  this.startIModelInitialization(requestOptions.imodel);
195
196
  const options = await this.addRulesetAndVariablesToOptions(requestOptions);
196
197
  const rpcOptions = this.toRpcTokenOptions({ ...options });
197
- const result = await buildPagedArrayResponse(options.paging, async (partialPageOptions) => this._requestsHandler.getPagedNodes({ ...rpcOptions, paging: partialPageOptions }));
198
- // eslint-disable-next-line deprecation/deprecation
199
- return this._localizationHelper.getLocalizedNodes(result.items.map(Node.fromJSON));
198
+ const generator = new StreamedResponseGenerator({
199
+ ...requestOptions,
200
+ getBatch: async (paging) => {
201
+ const result = await this._requestsHandler.getPagedNodes({ ...rpcOptions, paging });
202
+ return {
203
+ total: result.total,
204
+ // eslint-disable-next-line deprecation/deprecation
205
+ items: this._localizationHelper.getLocalizedNodes(result.items.map(Node.fromJSON)),
206
+ };
207
+ },
208
+ });
209
+ return generator.createAsyncIteratorResponse();
210
+ }
211
+ /**
212
+ * Retrieves nodes
213
+ * @deprecated in 4.5. Use [[getNodesIterator]] instead.
214
+ */
215
+ async getNodes(requestOptions) {
216
+ const result = await this.getNodesIterator(requestOptions);
217
+ return collect(result.items);
200
218
  }
201
219
  /** Retrieves nodes count. */
202
220
  async getNodesCount(requestOptions) {
@@ -205,16 +223,15 @@ export class PresentationManager {
205
223
  const rpcOptions = this.toRpcTokenOptions({ ...options });
206
224
  return this._requestsHandler.getNodesCount(rpcOptions);
207
225
  }
208
- /** Retrieves total nodes count and a single page of nodes. */
226
+ /**
227
+ * Retrieves total nodes count and a single page of nodes.
228
+ * @deprecated in 4.5. Use [[getNodesIterator]] instead.
229
+ */
209
230
  async getNodesAndCount(requestOptions) {
210
- this.startIModelInitialization(requestOptions.imodel);
211
- const options = await this.addRulesetAndVariablesToOptions(requestOptions);
212
- const rpcOptions = this.toRpcTokenOptions({ ...options });
213
- const result = await buildPagedArrayResponse(options.paging, async (partialPageOptions) => this._requestsHandler.getPagedNodes({ ...rpcOptions, paging: partialPageOptions }));
231
+ const result = await this.getNodesIterator(requestOptions);
214
232
  return {
215
233
  count: result.total,
216
- // eslint-disable-next-line deprecation/deprecation
217
- nodes: this._localizationHelper.getLocalizedNodes(result.items.map(Node.fromJSON)),
234
+ nodes: await collect(result.items),
218
235
  };
219
236
  }
220
237
  /**
@@ -290,54 +307,92 @@ export class PresentationManager {
290
307
  });
291
308
  return this._requestsHandler.getContentSetSize(rpcOptions);
292
309
  }
293
- /** Retrieves content which consists of a content descriptor and a page of records. */
294
- async getContent(requestOptions) {
295
- return (await this.getContentAndSize(requestOptions))?.content;
296
- }
297
- /** Retrieves content set size and content which consists of a content descriptor and a page of records. */
298
- async getContentAndSize(requestOptions) {
299
- this.startIModelInitialization(requestOptions.imodel);
300
- try {
301
- const options = await this.addRulesetAndVariablesToOptions(requestOptions);
302
- const rpcOptions = this.toRpcTokenOptions({
303
- ...options,
304
- descriptor: getDescriptorOverrides(requestOptions.descriptor),
305
- keys: stripTransientElementKeys(requestOptions.keys).toJSON(),
306
- ...(!requestOptions.omitFormattedValues && this._schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),
307
- });
308
- let descriptor = requestOptions.descriptor instanceof Descriptor ? requestOptions.descriptor : undefined;
309
- const result = await buildPagedArrayResponse(options.paging, async (partialPageOptions, requestIndex) => {
310
- if (0 === requestIndex && !descriptor) {
311
- const content = await this._requestsHandler.getPagedContent({ ...rpcOptions, paging: partialPageOptions });
312
- if (content) {
313
- descriptor = Descriptor.fromJSON(content.descriptor);
314
- return content.contentSet;
315
- }
316
- return { total: 0, items: [] };
317
- }
318
- return this._requestsHandler.getPagedContentSet({ ...rpcOptions, paging: partialPageOptions });
319
- });
320
- if (!descriptor) {
310
+ async getContentIteratorInternal(requestOptions) {
311
+ const options = await this.addRulesetAndVariablesToOptions(requestOptions);
312
+ const rpcOptions = this.toRpcTokenOptions({
313
+ ...options,
314
+ descriptor: getDescriptorOverrides(requestOptions.descriptor),
315
+ keys: stripTransientElementKeys(requestOptions.keys).toJSON(),
316
+ ...(!requestOptions.omitFormattedValues && this._schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),
317
+ });
318
+ let contentFormatter;
319
+ if (!requestOptions.omitFormattedValues && this._schemaContextProvider) {
320
+ const koqPropertyFormatter = new KoqPropertyValueFormatter(this._schemaContextProvider(requestOptions.imodel), this._defaultFormats);
321
+ contentFormatter = new ContentFormatter(new ContentPropertyValueFormatter(koqPropertyFormatter), requestOptions.unitSystem ?? this._explicitActiveUnitSystem ?? IModelApp.quantityFormatter.activeUnitSystem);
322
+ }
323
+ let descriptor = requestOptions.descriptor instanceof Descriptor ? requestOptions.descriptor : undefined;
324
+ let firstPage;
325
+ if (!descriptor) {
326
+ const firstPageResponse = await this._requestsHandler.getPagedContent(rpcOptions);
327
+ if (!firstPageResponse?.descriptor || !firstPageResponse.contentSet) {
321
328
  return undefined;
322
329
  }
323
- const items = result.items.map((itemJson) => Item.fromJSON(itemJson)).filter((item) => item !== undefined);
324
- const resultContent = new Content(descriptor, items);
325
- if (!requestOptions.omitFormattedValues && this._schemaContextProvider) {
326
- const koqPropertyFormatter = new KoqPropertyValueFormatter(this._schemaContextProvider(requestOptions.imodel), this._defaultFormats);
327
- const contentFormatter = new ContentFormatter(new ContentPropertyValueFormatter(koqPropertyFormatter), requestOptions.unitSystem ?? this._explicitActiveUnitSystem ?? IModelApp.quantityFormatter.activeUnitSystem);
328
- await contentFormatter.formatContent(resultContent);
330
+ descriptor = Descriptor.fromJSON(firstPageResponse?.descriptor);
331
+ firstPage = firstPageResponse?.contentSet;
332
+ }
333
+ // istanbul ignore if
334
+ if (!descriptor) {
335
+ return undefined;
336
+ }
337
+ descriptor = this._localizationHelper.getLocalizedContentDescriptor(descriptor);
338
+ const getPage = async (paging, requestIndex) => {
339
+ let contentSet = requestIndex === 0 ? firstPage : undefined;
340
+ contentSet ??= await this._requestsHandler.getPagedContentSet({ ...rpcOptions, paging });
341
+ let items = contentSet.items.map((x) => Item.fromJSON(x)).filter((x) => x !== undefined);
342
+ if (contentFormatter) {
343
+ items = await contentFormatter.formatContentItems(items, descriptor);
329
344
  }
345
+ items = this._localizationHelper.getLocalizedContentItems(items);
330
346
  return {
331
- size: result.total,
332
- content: this._localizationHelper.getLocalizedContent(resultContent),
347
+ total: contentSet.total,
348
+ items,
333
349
  };
350
+ };
351
+ const generator = new StreamedResponseGenerator({
352
+ ...requestOptions,
353
+ getBatch: getPage,
354
+ });
355
+ return {
356
+ ...(await generator.createAsyncIteratorResponse()),
357
+ descriptor,
358
+ };
359
+ }
360
+ /** Retrieves a content descriptor, item count and async generator for the items themselves. */
361
+ async getContentIterator(requestOptions) {
362
+ this.startIModelInitialization(requestOptions.imodel);
363
+ const response = await this.getContentIteratorInternal(requestOptions);
364
+ if (!response) {
365
+ return undefined;
334
366
  }
335
- finally {
336
- await this.ensureIModelInitialized(requestOptions.imodel);
367
+ await this.ensureIModelInitialized(requestOptions.imodel);
368
+ return response;
369
+ }
370
+ /**
371
+ * Retrieves content which consists of a content descriptor and a page of records.
372
+ * @deprecated in 4.5. Use [[getContentIterator]] instead.
373
+ */
374
+ async getContent(requestOptions) {
375
+ // eslint-disable-next-line deprecation/deprecation
376
+ return (await this.getContentAndSize(requestOptions))?.content;
377
+ }
378
+ /**
379
+ * Retrieves content set size and content which consists of a content descriptor and a page of records.
380
+ * @deprecated in 4.5. Use [[getContentIterator]] instead.
381
+ */
382
+ async getContentAndSize(requestOptions) {
383
+ const response = await this.getContentIterator(requestOptions);
384
+ if (!response) {
385
+ return undefined;
337
386
  }
387
+ const { descriptor, total } = response;
388
+ const items = await collect(response.items);
389
+ return {
390
+ content: new Content(descriptor, items),
391
+ size: total,
392
+ };
338
393
  }
339
- /** Retrieves distinct values of specific field from the content. */
340
- async getPagedDistinctValues(requestOptions) {
394
+ /** Returns an iterator that asynchronously polls distinct values of specific field from the content. */
395
+ async getDistinctValuesIterator(requestOptions) {
341
396
  this.startIModelInitialization(requestOptions.imodel);
342
397
  const options = await this.addRulesetAndVariablesToOptions(requestOptions);
343
398
  const rpcOptions = {
@@ -345,11 +400,28 @@ export class PresentationManager {
345
400
  descriptor: getDescriptorOverrides(options.descriptor),
346
401
  keys: stripTransientElementKeys(options.keys).toJSON(),
347
402
  };
348
- const result = await buildPagedArrayResponse(requestOptions.paging, async (partialPageOptions) => this._requestsHandler.getPagedDistinctValues({ ...rpcOptions, paging: partialPageOptions }));
403
+ const generator = new StreamedResponseGenerator({
404
+ ...requestOptions,
405
+ getBatch: async (paging) => {
406
+ const response = await this._requestsHandler.getPagedDistinctValues({ ...rpcOptions, paging });
407
+ return {
408
+ total: response.total,
409
+ // eslint-disable-next-line deprecation/deprecation
410
+ items: response.items.map((x) => this._localizationHelper.getLocalizedDisplayValueGroup(DisplayValueGroup.fromJSON(x))),
411
+ };
412
+ },
413
+ });
414
+ return generator.createAsyncIteratorResponse();
415
+ }
416
+ /**
417
+ * Retrieves distinct values of specific field from the content.
418
+ * @deprecated in 4.5. Use [[getDistinctValuesIterator]] instead.
419
+ */
420
+ async getPagedDistinctValues(requestOptions) {
421
+ const result = await this.getDistinctValuesIterator(requestOptions);
349
422
  return {
350
- ...result,
351
- // eslint-disable-next-line deprecation/deprecation
352
- items: result.items.map(DisplayValueGroup.fromJSON).map((g) => this._localizationHelper.getLocalizedDisplayValueGroup(g)),
423
+ total: result.total,
424
+ items: await collect(result.items),
353
425
  };
354
426
  }
355
427
  /**
@@ -376,9 +448,9 @@ export class PresentationManager {
376
448
  ...this.toRpcTokenOptions(options),
377
449
  keys: stripTransientElementKeys(options.keys).toJSON(),
378
450
  };
379
- const props = {
380
- page: requestOptions.paging,
381
- get: async (page) => {
451
+ const generator = new StreamedResponseGenerator({
452
+ ...requestOptions,
453
+ getBatch: async (page) => {
382
454
  const keys = await this._requestsHandler.getContentInstanceKeys({ ...rpcOptions, paging: page });
383
455
  return {
384
456
  total: keys.total,
@@ -390,8 +462,14 @@ export class PresentationManager {
390
462
  }, new Array()),
391
463
  };
392
464
  },
465
+ });
466
+ const { total, items } = await generator.createAsyncIteratorResponse();
467
+ return {
468
+ total,
469
+ async *items() {
470
+ yield* items;
471
+ },
393
472
  };
394
- return createPagedGeneratorResponse(props);
395
473
  }
396
474
  /** Retrieves display label definition of specific item. */
397
475
  async getDisplayLabelDefinition(requestOptions) {
@@ -401,14 +479,27 @@ export class PresentationManager {
401
479
  return this._localizationHelper.getLocalizedLabelDefinition(result);
402
480
  }
403
481
  /** Retrieves display label definition of specific items. */
404
- async getDisplayLabelDefinitions(requestOptions) {
482
+ async getDisplayLabelDefinitionsIterator(requestOptions) {
405
483
  this.startIModelInitialization(requestOptions.imodel);
406
484
  const rpcOptions = this.toRpcTokenOptions({ ...requestOptions });
407
- const result = await buildPagedArrayResponse(undefined, async (partialPageOptions) => {
408
- const partialKeys = !partialPageOptions.start ? rpcOptions.keys : rpcOptions.keys.slice(partialPageOptions.start);
409
- return this._requestsHandler.getPagedDisplayLabelDefinitions({ ...rpcOptions, keys: partialKeys });
485
+ const generator = new StreamedResponseGenerator({
486
+ ...requestOptions,
487
+ getBatch: async (page) => {
488
+ const partialKeys = !page.start ? rpcOptions.keys : rpcOptions.keys.slice(page.start);
489
+ const result = await this._requestsHandler.getPagedDisplayLabelDefinitions({ ...rpcOptions, keys: partialKeys });
490
+ result.items = this._localizationHelper.getLocalizedLabelDefinitions(result.items);
491
+ return result;
492
+ },
410
493
  });
411
- return this._localizationHelper.getLocalizedLabelDefinitions(result.items);
494
+ return generator.createAsyncIteratorResponse();
495
+ }
496
+ /**
497
+ * Retrieves display label definition of specific items.
498
+ * @deprecated in 4.5. Use [[getDisplayLabelDefinitionsIterator]] instead.
499
+ */
500
+ async getDisplayLabelDefinitions(requestOptions) {
501
+ const { items } = await this.getDisplayLabelDefinitionsIterator(requestOptions);
502
+ return collect(items);
412
503
  }
413
504
  }
414
505
  const getDescriptorOverrides = (descriptorOrOverrides) => {
@@ -417,47 +508,6 @@ const getDescriptorOverrides = (descriptorOrOverrides) => {
417
508
  }
418
509
  return descriptorOrOverrides;
419
510
  };
420
- async function createPagedGeneratorResponse(props) {
421
- let pageStart = props.page?.start ?? 0;
422
- let pageSize = props.page?.size ?? 0;
423
- let requestIndex = 0;
424
- const firstPage = await props.get({ start: pageStart, size: pageSize }, requestIndex++);
425
- return {
426
- total: firstPage.total,
427
- async *items() {
428
- let partialResult = firstPage;
429
- while (true) {
430
- for (const item of partialResult.items) {
431
- yield item;
432
- }
433
- const receivedItemsCount = partialResult.items.length;
434
- if (partialResult.total !== 0 && receivedItemsCount === 0) {
435
- if (pageStart >= partialResult.total) {
436
- throw new Error(`Requested page with start index ${pageStart} is out of bounds. Total number of items: ${partialResult.total}`);
437
- }
438
- throw new Error("Paged request returned non zero total count but no items");
439
- }
440
- if ((pageSize !== 0 && receivedItemsCount >= pageSize) || receivedItemsCount >= partialResult.total - pageStart) {
441
- break;
442
- }
443
- if (pageSize !== 0) {
444
- pageSize -= receivedItemsCount;
445
- }
446
- pageStart += receivedItemsCount;
447
- partialResult = await props.get({ start: pageStart, size: pageSize }, requestIndex++);
448
- }
449
- },
450
- };
451
- }
452
- /** @internal */
453
- export const buildPagedArrayResponse = async (requestedPage, getter) => {
454
- const items = new Array();
455
- const gen = await createPagedGeneratorResponse({ page: requestedPage, get: getter });
456
- for await (const item of gen.items()) {
457
- items.push(item);
458
- }
459
- return { total: gen.total, items };
460
- };
461
511
  const stripTransientElementKeys = (keys) => {
462
512
  if (!keys.some((key) => Key.isInstanceKey(key) && key.className === TRANSIENT_ELEMENT_CLASSNAME)) {
463
513
  return keys;
@@ -473,4 +523,11 @@ const stripTransientElementKeys = (keys) => {
473
523
  });
474
524
  return copy;
475
525
  };
526
+ async function collect(iter) {
527
+ const result = new Array();
528
+ for await (const value of iter) {
529
+ result.push(value);
530
+ }
531
+ return result;
532
+ }
476
533
  //# sourceMappingURL=PresentationManager.js.map