@itwin/imodels-client-authoring
Version:
iModels API client wrapper for applications that author iModels.
86 lines • 4.29 kB
JavaScript
;
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 imodels_client_management_1 = require("@itwin/imodels-client-management");
const internal_1 = require("./base/internal");
const operations_1 = require("./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}.
*/
class IModelsClient extends imodels_client_management_1.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.fillAuthoringClientConfiguration(options);
super(filledIModelsClientOptions);
this._operationsOptions = {
...filledIModelsClientOptions,
parseErrorFunc: (response, originalError) => internal_1.IModelsErrorParser.parse(response, originalError),
urlFormatter: new operations_1.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 operations_1.IModelOperations(this._operationsOptions, this);
}
/** Baseline file operations. See {@link BaselineFileOperations}. */
get baselineFiles() {
return new operations_1.BaselineFileOperations(this._operationsOptions);
}
/** 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 operations_1.ChangesetExtendedDataOperations(this._operationsOptions);
}
/** Changeset Group operations. See {@link ChangesetGroupOperations}. */
get changesetGroups() {
return new operations_1.ChangesetGroupOperations(this._operationsOptions, this);
}
/** Lock operations. See {@link LockOperations}. */
get locks() {
return new operations_1.LockOperations(this._operationsOptions);
}
static fillAuthoringClientConfiguration(options) {
const retryPolicy = options?.retryPolicy ??
new imodels_client_management_1.AxiosRetryPolicy({
maxRetries: imodels_client_management_1.Constants.retryPolicy.maxRetries,
backoffAlgorithm: new imodels_client_management_1.ExponentialBackoffAlgorithm({
baseDelayInMs: imodels_client_management_1.Constants.retryPolicy.baseDelayInMs,
factor: imodels_client_management_1.Constants.retryPolicy.delayFactor,
}),
});
return {
api: this.fillApiConfiguration(options?.api),
restClient: options.restClient ?? new imodels_client_management_1.AxiosRestClient(retryPolicy),
localFileSystem: options.localFileSystem ?? new internal_1.NodeLocalFileSystem(),
headers: options.headers ?? {},
cloudStorage: options.cloudStorage,
retryPolicy,
};
}
}
exports.IModelsClient = IModelsClient;
//# sourceMappingURL=IModelsClient.js.map