UNPKG

@itwin/imodels-client-management

Version:

iModels API client wrapper for applications that manage iModels.

65 lines 3.44 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ import { EntityListIteratorImpl, OperationsBase, } from "../../base/internal"; import { getUser } from "../SharedFunctions"; export class ChangesetGroupOperations extends OperationsBase { _iModelsClient; constructor(options, _iModelsClient) { super(options); this._iModelsClient = _iModelsClient; } /** * Gets Changeset Groups for a specific iModel. Wraps the * {@link https://developer.bentley.com/apis/imodels-v2/operations/get-imodel-changeset-groups/ Get iModel Changeset Groups} * operation from iModels API. * @param {GetChangesetGroupListParams} params parameters for this operation. See {@link GetChangesetGroupListParams}. * @returns {EntityListIterator<ChangesetGroup>} iterator for Changeset Group list, which internally queries entities in pages. * See {@link EntityListIterator}, {@link ChangesetGroup}. */ getList(params) { const entityCollectionAccessor = (response) => { const changesetGroups = response.body.changesetGroups; const mappedChangesetGroups = changesetGroups.map((changesetGroup) => this.appendRelatedEntityCallbacks(params.authorization, changesetGroup, params.headers)); return mappedChangesetGroups; }; return new EntityListIteratorImpl(async () => this.getEntityCollectionPage({ authorization: params.authorization, url: this._options.urlFormatter.getChangesetGroupListUrl({ iModelId: params.iModelId, urlParams: params.urlParams, }), entityCollectionAccessor, headers: params.headers, })); } /** * Gets a single Changeset Group identified by id. Wraps the * {@link https://developer.bentley.com/apis/imodels-v2/operations/get-imodel-changeset-group-details/ Get iModel Changeset Group} * operation from iModels API. * @param {GetSingleChangesetGroupParams} params parameters for this operation. See {@link GetSingleChangesetGroupParams}. * @returns {Promise<ChangesetGroup>} a Changeset Group with the specified id. See {@link ChangesetGroup}. */ async getSingle(params) { const response = await this.sendGetRequest({ authorization: params.authorization, url: this._options.urlFormatter.getSingleChangesetGroupUrl({ iModelId: params.iModelId, changesetGroupId: params.changesetGroupId, }), headers: params.headers, }); const result = this.appendRelatedEntityCallbacks(params.authorization, response.body.changesetGroup, params.headers); return result; } appendRelatedEntityCallbacks(authorization, changesetGroup, headers) { const getCreator = async () => getUser(authorization, this._iModelsClient.users, this._options.urlFormatter, changesetGroup._links.creator?.href, headers); const result = { ...changesetGroup, getCreator, }; return result; } } //# sourceMappingURL=ChangesetGroupOperations.js.map