UNPKG

@itwin/imodels-client-management

Version:

iModels API client wrapper for applications that manage iModels.

103 lines 5.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BriefcaseOperations = 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 types_1 = require("../../base/types"); const SharedFunctions_1 = require("../SharedFunctions"); class BriefcaseOperations extends internal_1.OperationsBase { _iModelsClient; constructor(options, _iModelsClient) { super(options); this._iModelsClient = _iModelsClient; } /** * Gets Briefcases of a specific iModel. This method returns Briefcases in their minimal representation. The returned iterator * internally queries entities in pages. Wraps the * {@link https://developer.bentley.com/apis/imodels-v2/operations/get-imodel-briefcases/ Get iModel Briefcases} * operation from iModels API. * @param {GetBriefcaseListParams} params parameters for this operation. See {@link GetBriefcaseListParams}. * @returns {EntityListIterator<MinimalBriefcase>} iterator for Briefcase list. See {@link EntityListIterator}, * {@link MinimalBriefcase}. */ getMinimalList(params) { return new internal_1.EntityListIteratorImpl(async () => this.getEntityCollectionPage({ authorization: params.authorization, url: this._options.urlFormatter.getBriefcaseListUrl({ iModelId: params.iModelId, urlParams: params.urlParams, }), preferReturn: types_1.PreferReturn.Minimal, entityCollectionAccessor: (response) => response.body.briefcases, headers: params.headers, })); } /** * Gets Briefcases of a specific iModel. This method returns Briefcases in their full representation. The returned iterator * internally queries entities in pages. Wraps the * {@link https://developer.bentley.com/apis/imodels-v2/operations/get-imodel-briefcases/ Get iModel Briefcases} * operation from iModels API. * @param {GetBriefcaseListParams} params parameters for this operation. See {@link GetBriefcaseListParams}. * @returns {EntityListIterator<Briefcase>} iterator for Briefcase list. See {@link EntityListIterator}, {@link Briefcase}. */ getRepresentationList(params) { const entityCollectionAccessor = (response) => { const briefcases = response.body.briefcases; const mappedBriefcases = briefcases.map((briefcase) => this.appendRelatedEntityCallbacks(params.authorization, briefcase, params.headers)); return mappedBriefcases; }; return new internal_1.EntityListIteratorImpl(async () => this.getEntityCollectionPage({ authorization: params.authorization, url: this._options.urlFormatter.getBriefcaseListUrl({ iModelId: params.iModelId, urlParams: params.urlParams, }), preferReturn: types_1.PreferReturn.Representation, entityCollectionAccessor, headers: params.headers, })); } /** * Gets a single Briefcase by its id. This method returns a Briefcase in its full representation. Wraps the * {@link https://developer.bentley.com/apis/imodels-v2/operations/get-imodel-briefcase-details/ Get iModel Briefcase} * operation from iModels API. * @param {GetSingleBriefcaseParams} params parameters for this operation. See {@link GetSingleBriefcaseParams}. * @returns {Promise<Briefcase>} an Briefcase with specified id. See {@link iModel}. */ async getSingle(params) { const response = await this.sendGetRequest({ authorization: params.authorization, url: this._options.urlFormatter.getSingleBriefcaseUrl({ iModelId: params.iModelId, briefcaseId: params.briefcaseId, }), headers: params.headers, }); const result = this.appendRelatedEntityCallbacks(params.authorization, response.body.briefcase, params.headers); return result; } appendRelatedEntityCallbacks(authorization, briefcase, headers) { const getOwner = async () => (0, SharedFunctions_1.getUser)(authorization, this._iModelsClient.users, this._options.urlFormatter, briefcase._links.owner?.href, headers); const checkpointLink = briefcase._links.checkpoint; (0, SharedFunctions_1.assertLink)(checkpointLink); const getCheckpoint = async () => { const response = await this.sendGetRequest({ authorization, url: checkpointLink.href, headers, }); return response.body.checkpoint; }; const result = { ...briefcase, getOwner, getCheckpoint, }; return result; } } exports.BriefcaseOperations = BriefcaseOperations; //# sourceMappingURL=BriefcaseOperations.js.map