UNPKG

@itwin/clash-detection-client

Version:

Clash Detection client for the iTwin platform

82 lines 4.01 kB
import { AxiosRestClient } from "./base/rest/AxiosRestClient"; import { Constants } from "./Constants"; import { IModelOperations } from "./operations/imodel/IModelOperations"; import { SuppressionRuleOperations } from "./operations/suppressionRule/SuppressionRuleOperations"; import { RunOperations } from "./operations/run/RunOperations"; import { ResultOperations } from "./operations/result/ResultOperations"; import { TestOperations } from "./operations/test/TestOperations"; import { TemplateOperations } from "./operations/template/TemplateOperations"; import { ClashDetectionApiUrlFormatter } from "./operations/ClashDetectionApiUrlFormatter"; /** * Clash Detection API client for clash detection workflows. For more information on the API visit the * {@link https://developer.bentley.com/apis/clash-detection/ Clash Detection API documentation page}. */ export class ClashDetectionClient { /** * Class constructor. * @param {ClashDetectionClientOptions} options client options. If `options` are `undefined` or if some of the properties * are `undefined` the client uses defaults. See {@link ClashDetectionClientOptions}. */ constructor(options, accessTokenCallback) { const filledClashDetectionClientOptions = ClashDetectionClient.fillConfiguration(options); this._operationsOptions = { ...filledClashDetectionClientOptions, urlFormatter: new ClashDetectionApiUrlFormatter(filledClashDetectionClientOptions.api.baseUrl), accessTokenCallback, }; this.templateId = ""; this.ruleId = ""; this.testId = ""; this.runId = ""; this.resultId = ""; } /** Template operations. See {@link TemplateOperations}. */ get templates() { return new TemplateOperations(this._operationsOptions); } /** Suppression Rule operations. See {@link SuppressionRuleOperations}. */ get rules() { return new SuppressionRuleOperations(this._operationsOptions); } /** Test operations. See {@link TestOperations}. */ get tests() { return new TestOperations(this._operationsOptions); } /** Run operations. See {@link RunOperations}. */ get runs() { return new RunOperations(this._operationsOptions); } /** Result operations. See {@link ResultOperations}. */ get results() { return new ResultOperations(this._operationsOptions); } /** IModel operations. See {@link IModelOperations}. */ get imodel() { return new IModelOperations(this._operationsOptions); } /** * Creates a required configuration instance from user provided options and applying default ones for not specified * options. See {@link ClashDetectionClientOptions}. * @param {ClashDetectionClientOptions} options user-passed client options. * @returns {RecursiveRequired<ClashDetectionClientOptions>} required Clash Detection client configuration options. */ static fillConfiguration(options) { var _a, _b, _c, _d, _e; return { api: { baseUrl: (_b = (_a = options === null || options === void 0 ? void 0 : options.api) === null || _a === void 0 ? void 0 : _a.baseUrl) !== null && _b !== void 0 ? _b : Constants.api.baseUrl, version: (_d = (_c = options === null || options === void 0 ? void 0 : options.api) === null || _c === void 0 ? void 0 : _c.version) !== null && _d !== void 0 ? _d : Constants.api.version, }, restClient: (_e = options === null || options === void 0 ? void 0 : options.restClient) !== null && _e !== void 0 ? _e : new AxiosRestClient(), }; } static toAuthorizationCallback(accessToken) { const splitAccessToken = accessToken.split(" "); const authorization = { scheme: splitAccessToken[0], token: splitAccessToken[1], }; return async () => authorization; } } //# sourceMappingURL=ClashDetectionClient.js.map