@itwin/property-validation-client
Version:
Property Validation client for the iTwin platform
82 lines • 4.01 kB
JavaScript
import { AxiosRestClient } from "./base/rest/AxiosRestClient";
import { Constants } from "./Constants";
import { RuleOperations } from "./operations/rule/RuleOperations";
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 { SchemaOperations } from "./operations/schema/SchemaOperations";
import { PropertyValidationApiUrlFormatter } from "./operations/PropertyValidationApiUrlFormatter";
/**
* Property Validation API client for property validation workflows. For more information on the API visit the
* {@link https://developer.bentley.com/apis/validation/ Property Validation API documentation page}.
*/
export class PropertyValidationClient {
/**
* Class constructor.
* @param {PropertyValidationClientOptions} options client options. If `options` are `undefined` or if some of the properties
* are `undefined` the client uses defaults. See {@link PropertyValidationClientOptions}.
*/
constructor(options, accessTokenCallback) {
const filledPropertyValidationClientOptions = PropertyValidationClient.fillConfiguration(options);
this._operationsOptions = {
...filledPropertyValidationClientOptions,
urlFormatter: new PropertyValidationApiUrlFormatter(filledPropertyValidationClientOptions.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);
}
/** Rule operations. See {@link RuleOperations}. */
get rules() {
return new RuleOperations(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);
}
/** Schema operations. See {@link SchemaOperations}. */
get schema() {
return new SchemaOperations(this._operationsOptions);
}
/**
* Creates a required configuration instance from user provided options and applying default ones for not specified
* options. See {@link PropertyValidationClientOptions}.
* @param {PropertyValidationClientOptions} options user-passed client options.
* @returns {RecursiveRequired<PropertyValidationClientOptions>} required Property Validation 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=PropertyValidationClient.js.map