@itwin/imodels-client-management
Version:
iModels API client wrapper for applications that manage iModels.
69 lines • 3.64 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangesetGroupOperations = void 0;
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
const internal_1 = require("../../base/internal");
const SharedFunctions_1 = require("../SharedFunctions");
class ChangesetGroupOperations extends internal_1.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 internal_1.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 () => (0, SharedFunctions_1.getUser)(authorization, this._iModelsClient.users, this._options.urlFormatter, changesetGroup._links.creator?.href, headers);
const result = {
...changesetGroup,
getCreator,
};
return result;
}
}
exports.ChangesetGroupOperations = ChangesetGroupOperations;
//# sourceMappingURL=ChangesetGroupOperations.js.map