UNPKG

@itwin/imodels-client-authoring

Version:

iModels API client wrapper for applications that author iModels.

82 lines 4.12 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ import { AxiosRestClient, AxiosRetryPolicy, Constants, ExponentialBackoffAlgorithm, IModelsClient as ManagementIModelsClient, } from "@itwin/imodels-client-management"; import { IModelsErrorParser, NodeLocalFileSystem } from "./base/internal"; import { BaselineFileOperations, BriefcaseOperations, ChangesetExtendedDataOperations, ChangesetGroupOperations, ChangesetOperations, IModelOperations, IModelsApiUrlFormatter, LockOperations, } from "./operations"; /** * iModels API client for iModel authoring workflows. For more information on the API visit the * {@link https://developer.bentley.com/apis/imodels-v2/ iModels API documentation page}. */ export class IModelsClient extends ManagementIModelsClient { _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.fillAuthoringClientConfiguration(options); super(filledIModelsClientOptions); this._operationsOptions = { ...filledIModelsClientOptions, parseErrorFunc: (response, originalError) => IModelsErrorParser.parse(response, originalError), urlFormatter: new IModelsApiUrlFormatter(filledIModelsClientOptions.api.baseUrl), }; } /** * `ClientStorage` instance that is used for file transfer operations. This uses the user provided instance or default one, * see {@link IModelsClientOptions}. */ get cloudStorage() { return this._operationsOptions.cloudStorage; } /** iModel operations. See {@link iModelOperations}. */ get iModels() { return new IModelOperations(this._operationsOptions, this); } /** Baseline file operations. See {@link BaselineFileOperations}. */ get baselineFiles() { return new BaselineFileOperations(this._operationsOptions); } /** Briefcase operations. See {@link BriefcaseOperations}. */ get briefcases() { return new BriefcaseOperations(this._operationsOptions, this); } /** Changeset operations. See {@link ChangesetOperations}. */ get changesets() { return new ChangesetOperations(this._operationsOptions, this); } /** Changeset Extended Data operations. See {@link ChangesetExtendedDataOperations}. */ get changesetExtendedData() { return new ChangesetExtendedDataOperations(this._operationsOptions); } /** Changeset Group operations. See {@link ChangesetGroupOperations}. */ get changesetGroups() { return new ChangesetGroupOperations(this._operationsOptions, this); } /** Lock operations. See {@link LockOperations}. */ get locks() { return new LockOperations(this._operationsOptions); } static fillAuthoringClientConfiguration(options) { const retryPolicy = options?.retryPolicy ?? new AxiosRetryPolicy({ maxRetries: Constants.retryPolicy.maxRetries, backoffAlgorithm: new ExponentialBackoffAlgorithm({ baseDelayInMs: Constants.retryPolicy.baseDelayInMs, factor: Constants.retryPolicy.delayFactor, }), }); return { api: this.fillApiConfiguration(options?.api), restClient: options.restClient ?? new AxiosRestClient(retryPolicy), localFileSystem: options.localFileSystem ?? new NodeLocalFileSystem(), headers: options.headers ?? {}, cloudStorage: options.cloudStorage, retryPolicy, }; } } //# sourceMappingURL=IModelsClient.js.map