UNPKG

@itwin/clash-detection-client

Version:

Clash Detection client for the iTwin platform

86 lines 4.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ClashDetectionClient = void 0; const AxiosRestClient_1 = require("./base/rest/AxiosRestClient"); const Constants_1 = require("./Constants"); const IModelOperations_1 = require("./operations/imodel/IModelOperations"); const SuppressionRuleOperations_1 = require("./operations/suppressionRule/SuppressionRuleOperations"); const RunOperations_1 = require("./operations/run/RunOperations"); const ResultOperations_1 = require("./operations/result/ResultOperations"); const TestOperations_1 = require("./operations/test/TestOperations"); const TemplateOperations_1 = require("./operations/template/TemplateOperations"); const ClashDetectionApiUrlFormatter_1 = require("./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}. */ 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_1.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_1.TemplateOperations(this._operationsOptions); } /** Suppression Rule operations. See {@link SuppressionRuleOperations}. */ get rules() { return new SuppressionRuleOperations_1.SuppressionRuleOperations(this._operationsOptions); } /** Test operations. See {@link TestOperations}. */ get tests() { return new TestOperations_1.TestOperations(this._operationsOptions); } /** Run operations. See {@link RunOperations}. */ get runs() { return new RunOperations_1.RunOperations(this._operationsOptions); } /** Result operations. See {@link ResultOperations}. */ get results() { return new ResultOperations_1.ResultOperations(this._operationsOptions); } /** IModel operations. See {@link IModelOperations}. */ get imodel() { return new IModelOperations_1.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_1.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_1.Constants.api.version, }, restClient: (_e = options === null || options === void 0 ? void 0 : options.restClient) !== null && _e !== void 0 ? _e : new AxiosRestClient_1.AxiosRestClient(), }; } static toAuthorizationCallback(accessToken) { const splitAccessToken = accessToken.split(" "); const authorization = { scheme: splitAccessToken[0], token: splitAccessToken[1], }; return async () => authorization; } } exports.ClashDetectionClient = ClashDetectionClient; //# sourceMappingURL=ClashDetectionClient.js.map