UNPKG

@itwin/itwins-client

Version:

iTwins client for the iTwin platform

137 lines 4.9 kB
import { BaseBentleyAPIClient } from "./BaseBentleyAPIClient"; /** Abstract class for accessing working with ITwins Service * @beta */ export class BaseITwinsApiClient extends BaseBentleyAPIClient { /** * Maps the properties of {@link ITwinsQueryArg} to their corresponding query parameter names. * * @remarks * This mapping is used to translate internal property names to the expected parameter names * when constructing iTwins queries. Properties mapped to empty strings are excluded from * the query string as they should be sent as headers instead. * * The mapping includes both OData query parameters (prefixed with $) and iTwins-specific * parameters for filtering and pagination. * * @readonly */ static iTwinsQueryParamMapping = { subClass: "subClass", type: "type", status: "status", search: "$search", displayName: "displayName", // eslint-disable-next-line id-denylist number: "number", top: "$top", skip: "$skip", parentId: "parentId", iTwinAccountId: "iTwinAccountId", includeInactive: "includeInactive", resultMode: "", queryScope: "", }; /** * Maps the properties some of the {@link ODataQueryParams} to their corresponding query parameter names. * * @remarks * This mapping is used to translate internal property names to the expected parameter names * when constructing iTwins queries. Properties mapped to empty strings are excluded from * the query string as they should be sent as headers instead. * * The mapping includes both OData query parameters (prefixed with $) and iTwins-specific * parameters for filtering and pagination. * * @readonly */ // eslint-disable-next-line @typescript-eslint/naming-convention static ODataParamMapping = { top: "$top", skip: "$skip", search: "$search", }; /** * Maps the properties some of the {@link ODataQueryParams} and all of the {@link ITwinsQueryArg} to their corresponding query parameter names. * * @remarks * This mapping is used to translate internal property names to the expected parameter names * when constructing iTwins queries. Properties mapped to empty strings are excluded from * the query string as they should be sent as headers instead. * * The mapping includes both OData query parameters (prefixed with $) and iTwins-specific * parameters for filtering and pagination. * * @readonly */ // eslint-disable-next-line @typescript-eslint/naming-convention static ITwinsGetQueryParamMapping = { subClass: "subClass", type: "type", status: "status", search: "$search", displayName: "displayName", // eslint-disable-next-line id-denylist number: "number", top: "$top", skip: "$skip", parentId: "parentId", iTwinAccountId: "iTwinAccountId", includeInactive: "includeInactive", resultMode: "", queryScope: "", filter: "$filter", orderby: "$orderby", select: "$select", }; /** * Maps the properties of class and subclass to their corresponding query parameter names. * * @remarks * This mapping is used to translate internal property names to the expected parameter names * when constructing repository queries. * * @readonly */ static repositoryParamMapping = { class: "class", subClass: "subClass", }; /** * The base URL for iTwins API endpoints. * The URL can be customized via the constructor parameter or automatically * modified based on the IMJS_URL_PREFIX environment variable for different * deployment environments. * * @readonly */ _baseUrl = "https://api.bentley.com/itwins"; /** * Creates a new BaseClient instance for iTwins API operations * @param url - Optional custom base URL, defaults to production iTwins API URL * * @example * ```typescript * // Use default production URL * const client = new BaseClient(); * * // Use custom URL for development/testing * const client = new ITwinsAccessClient("https://dev-api.bentley.com/itwins"); * ``` */ constructor(url, maxRedirects) { super(maxRedirects); if (url !== undefined) { this._baseUrl = url; } else { const urlPrefix = globalThis.IMJS_URL_PREFIX; if (urlPrefix) { const baseUrl = new URL(this._baseUrl); baseUrl.hostname = `${urlPrefix}${baseUrl.hostname}`; this._baseUrl = baseUrl.href; } } } } //# sourceMappingURL=BaseITwinsApiClient.js.map