UNPKG

@itwin/imodels-client-management

Version:

iModels API client wrapper for applications that manage iModels.

115 lines 5.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.IModelsClient = 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 axios_1 = require("./base/axios"); const internal_1 = require("./base/internal"); const Constants_1 = require("./Constants"); const operations_1 = require("./operations"); const ChangesetExtendedDataOperations_1 = require("./operations/changeset-extended-data/ChangesetExtendedDataOperations"); const ChangesetGroupOperations_1 = require("./operations/changeset-group/ChangesetGroupOperations"); const CheckpointOperations_1 = require("./operations/checkpoint/CheckpointOperations"); const IModelsApiUrlFormatter_1 = require("./operations/IModelsApiUrlFormatter"); /** * iModels API client for iModel management workflows. For more information on the API visit the * {@link https://developer.bentley.com/apis/imodels-v2/ iModels API documentation page}. */ class IModelsClient { _operationsOptions; /** * Class constructor. * @param {iModelsClientOptions} options client options. If `options` are `undefined` or if some of the properties * are `undefined` the client uses defaults. See {@link iModelsClientOptions}. */ constructor(options) { const filledIModelsClientOptions = IModelsClient.fillManagementClientConfiguration(options); this._operationsOptions = { ...filledIModelsClientOptions, parseErrorFunc: (response, originalError) => internal_1.IModelsErrorParser.parse(response, originalError), urlFormatter: new IModelsApiUrlFormatter_1.IModelsApiUrlFormatter(filledIModelsClientOptions.api.baseUrl), }; } /** iModel operations. See {@link iModelOperations}. */ get iModels() { return new operations_1.IModelOperations(this._operationsOptions, this); } /** Briefcase operations. See {@link BriefcaseOperations}. */ get briefcases() { return new operations_1.BriefcaseOperations(this._operationsOptions, this); } /** Changeset operations. See {@link ChangesetOperations}. */ get changesets() { return new operations_1.ChangesetOperations(this._operationsOptions, this); } /** Changeset Extended Data operations. See {@link ChangesetExtendedDataOperations}. */ get changesetExtendedData() { return new ChangesetExtendedDataOperations_1.ChangesetExtendedDataOperations(this._operationsOptions); } /** Changeset Group operations. See {@link ChangesetGroupOperations}. */ get changesetGroups() { return new ChangesetGroupOperations_1.ChangesetGroupOperations(this._operationsOptions, this); } /** Named version operations. See {@link NamedVersionOperations}. */ get namedVersions() { return new operations_1.NamedVersionOperations(this._operationsOptions, this); } /** Checkpoint operations. See {@link CheckpointOperations}. */ get checkpoints() { return new CheckpointOperations_1.CheckpointOperations(this._operationsOptions); } /** Thumbnail operations. See {@link ThumbnailOperations}. */ get thumbnails() { return new operations_1.ThumbnailOperations(this._operationsOptions); } /** User operations. See {@link UserOperations}. */ get users() { return new operations_1.UserOperations(this._operationsOptions); } /** User Permission operations. See {@link UserPermissionOperations}. */ get userPermissions() { return new operations_1.UserPermissionOperations(this._operationsOptions); } /** Operation operations. See {@link OperationOperations}. */ get operations() { return new operations_1.OperationOperations(this._operationsOptions); } /** Favorite iModel operations. See {@link FavoriteIModelOperations}. */ get favoriteIModels() { return new operations_1.FavoriteIModelOperations(this._operationsOptions); } /** Recent iModel operations. See {@link RecentIModelOperations}. */ get recentIModels() { return new operations_1.RecentIModelOperations(this._operationsOptions); } /** Lock operations. See {@link LockOperations}. */ get locks() { return new operations_1.LockOperations(this._operationsOptions); } static fillManagementClientConfiguration(options) { const retryPolicy = options?.retryPolicy ?? new axios_1.AxiosRetryPolicy({ maxRetries: Constants_1.Constants.retryPolicy.maxRetries, backoffAlgorithm: new axios_1.ExponentialBackoffAlgorithm({ baseDelayInMs: Constants_1.Constants.retryPolicy.baseDelayInMs, factor: Constants_1.Constants.retryPolicy.delayFactor, }), }); return { api: this.fillApiConfiguration(options?.api), restClient: options?.restClient ?? new axios_1.AxiosRestClient(retryPolicy), headers: options?.headers ?? {}, retryPolicy, }; } static fillApiConfiguration(apiOptions) { return { baseUrl: apiOptions?.baseUrl ?? Constants_1.Constants.api.baseUrl, version: apiOptions?.version ?? Constants_1.Constants.api.version, }; } } exports.IModelsClient = IModelsClient; //# sourceMappingURL=IModelsClient.js.map