UNPKG

@itwin/itwins-client

Version:

iTwins client for the iTwin platform

184 lines 13.8 kB
import type { AccessToken } from "@itwin/core-bentley"; import { BaseBentleyAPIClient } from "./BaseBentleyAPIClient"; import type { BentleyAPIResponse, ODataQueryParams, ResultMode } from "./types/CommonApiTypes"; import type { ItwinCreate, ITwinMinimalResponse, ITwinRepresentationResponse, ItwinUpdate, MultiITwinMinimalResponse, MultiITwinRepresentationResponse } from "./types/ITwin"; import type { ITwinExportMultiResponse, ITwinExportRequestInfo, ITwinExportSingleResponse } from "./types/ITwinExport"; import type { ITwinImageResponse } from "./types/ITwinImage"; import type { ITwinsGetQueryArg, ITwinsQueryArg } from "./types/ITwinsQueryArgs"; import type { GetMultiRepositoryResourceMinimalResponse, GetMultiRepositoryResourceRepresentationResponse, GetRepositoryResourceMinimalResponse, GetRepositoryResourceRepresentationResponse, MultiRepositoriesResponse, NewRepositoryConfig, PostRepositoryResourceResponse, Repository, ResourceGraphicsResponse, SingleRepositoryResponse } from "./types/Repository"; import type { ParameterMapping } from "./types/typeUtils"; /** Abstract class for accessing working with ITwins Service * @beta */ export declare abstract 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 */ protected static readonly iTwinsQueryParamMapping: ParameterMapping<ITwinsQueryArg>; /** * 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 */ protected static readonly ODataParamMapping: ParameterMapping<Pick<ODataQueryParams, "search" | "skip" | "top">>; /** * 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 */ protected static readonly ITwinsGetQueryParamMapping: ParameterMapping<ITwinsQueryArg & Pick<ODataQueryParams, "filter" | "orderby" | "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 */ protected static readonly repositoryParamMapping: ParameterMapping<{ class: Repository["class"]; subClass: Repository["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 */ protected readonly _baseUrl: string; /** * 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?: string, maxRedirects?: number); /** Create a new iTwin export */ abstract createExport(accessToken: AccessToken, args: ITwinExportRequestInfo): Promise<BentleyAPIResponse<ITwinExportSingleResponse>>; /** Get a iTwin export */ abstract getExport(accessToken: AccessToken, id: string): Promise<BentleyAPIResponse<ITwinExportSingleResponse>>; /** Get a list of iTwin exports for user */ abstract getExports(accessToken: AccessToken): Promise<BentleyAPIResponse<ITwinExportMultiResponse>>; /** Get favorites iTwins accessible to the user */ abstract getFavoritesITwins<T extends ITwinsQueryArg = ITwinsQueryArg>(accessToken: AccessToken, arg?: T): Promise<BentleyAPIResponse<T["resultMode"] extends "representation" ? MultiITwinRepresentationResponse : MultiITwinMinimalResponse>>; /** Add iTwin to favorites */ abstract addITwinToFavorites(accessToken: AccessToken, iTwinId?: string): Promise<BentleyAPIResponse<undefined>>; /** Remove iTwin from favorites */ abstract removeITwinFromFavorites(accessToken: AccessToken, iTwinId?: string): Promise<BentleyAPIResponse<undefined>>; /** Adds image to iTwin */ abstract uploadITwinImage(accessToken: AccessToken, iTwinId: string, imageBlob: Blob, contentType: "image/png" | "image/jpeg"): Promise<BentleyAPIResponse<ITwinImageResponse>>; /** Add the specified iTwin to the user's recently used list */ abstract addITwinToMyRecents(accessToken: AccessToken, iTwinId: string): Promise<BentleyAPIResponse<undefined>>; /** Get recently used iTwins for the current user, maximum 25 items ordered by most recent first */ abstract getRecentUsedITwins<T extends ITwinsQueryArg = ITwinsQueryArg>(accessToken: AccessToken, arg?: T): Promise<BentleyAPIResponse<T["resultMode"] extends "representation" ? MultiITwinRepresentationResponse : MultiITwinMinimalResponse>>; /** Get all global repositories with optional filtering by repository class and subClass identifiers. * @beta */ abstract getGlobalRepositories(accessToken: AccessToken, arg?: { class: Repository["class"]; } | { class: Repository["class"]; subClass: Repository["subClass"]; }): Promise<BentleyAPIResponse<MultiRepositoriesResponse>>; /** Get a specific global repository by ID. * @beta */ abstract getGlobalRepository(accessToken: AccessToken, repositoryId: string): Promise<BentleyAPIResponse<SingleRepositoryResponse>>; /** Get a global repository resource by ID. * @beta */ abstract getGlobalRepositoryResource<T extends ResultMode = "minimal">(accessToken: AccessToken, repositoryId: string, resourceId: string, resultMode?: T): Promise<BentleyAPIResponse<T extends "representation" ? GetRepositoryResourceRepresentationResponse : GetRepositoryResourceMinimalResponse>>; /** Get global repository resources with optional filtering and pagination. * @beta */ abstract getGlobalRepositoryResources<T extends ResultMode = "minimal">(accessToken: AccessToken, repositoryId: string, args?: Pick<ODataQueryParams, "search" | "skip" | "top">, resultMode?: T): Promise<BentleyAPIResponse<T extends "representation" ? GetMultiRepositoryResourceRepresentationResponse : GetMultiRepositoryResourceMinimalResponse>>; /** Get graphics metadata for a global repository resource. * @beta */ abstract getGlobalResourceGraphics(accessToken: AccessToken, repositoryId: string, resourceId: string): Promise<BentleyAPIResponse<ResourceGraphicsResponse>>; /** Create a new repository for the specified iTwin */ abstract createRepository(accessToken: AccessToken, iTwinId: string, repository: NewRepositoryConfig): Promise<BentleyAPIResponse<SingleRepositoryResponse>>; /** Delete the specified repository from an iTwin */ abstract deleteRepository(accessToken: AccessToken, iTwinId: string, repositoryId: string): Promise<BentleyAPIResponse<undefined>>; /** Get all repositories for an iTwin with optional filtering by repository class and subClass identifiers. If subClass is specified, class is also required. */ abstract getRepositories(accessToken: AccessToken, iTwinId: string, arg?: { class: Repository["class"]; } | { class: Repository["class"]; subClass: Repository["subClass"]; }): Promise<BentleyAPIResponse<MultiRepositoriesResponse>>; /** Get a specific repository by ID from an iTwin */ abstract getRepository(accessToken: AccessToken, iTwinId: string, repositoryId: string): Promise<BentleyAPIResponse<SingleRepositoryResponse>>; /** Update a specific repository by ID from an iTwin */ abstract updateRepository(accessToken: AccessToken, iTwinId: string, repositoryId: string, repository: Partial<Omit<Repository, "id" | "class" | "subClass" | "capabilities">>): Promise<BentleyAPIResponse<SingleRepositoryResponse>>; /** Create a repository resource for a repository that exposes a resources collection. */ abstract createRepositoryResource(accessToken: AccessToken, iTwinId: string, repositoryId: string, repositoryResource: Pick<Repository, "id" | "displayName">): Promise<BentleyAPIResponse<PostRepositoryResourceResponse>>; /** Delete a repository resource from a repository */ abstract deleteRepositoryResource(accessToken: AccessToken, iTwinId: string, repositoryId: string, resourceId: string): Promise<BentleyAPIResponse<undefined>>; /** Get a repository resource for a repository */ abstract getRepositoryResource<T extends ResultMode = "minimal">(accessToken: AccessToken, iTwinId: string, repositoryId: string, resourceId: string, resultMode?: T): Promise<BentleyAPIResponse<T extends "representation" ? GetRepositoryResourceRepresentationResponse : GetRepositoryResourceMinimalResponse>>; /** Get repository resources for a repository */ abstract getRepositoryResources<T extends ResultMode = "minimal">(accessToken: AccessToken, iTwinId: string, repositoryId: string, args?: Pick<ODataQueryParams, "search" | "skip" | "top">, resultMode?: T): Promise<BentleyAPIResponse<T extends "representation" ? GetMultiRepositoryResourceRepresentationResponse : GetMultiRepositoryResourceMinimalResponse>>; /** Get a list of resources from a repository using a capability URI */ abstract getRepositoryResourcesByUri<T extends ResultMode = "minimal">(accessToken: AccessToken, uri: string, args?: Pick<ODataQueryParams, "search" | "skip" | "top">, resultMode?: T): Promise<BentleyAPIResponse<T extends "representation" ? GetMultiRepositoryResourceRepresentationResponse : GetMultiRepositoryResourceMinimalResponse>>; /** Get a specific resource from a repository using a capability URI */ abstract getRepositoryResourceByUri<T extends ResultMode = "minimal">(accessToken: AccessToken, uri: string, resultMode?: T): Promise<BentleyAPIResponse<T extends "representation" ? GetRepositoryResourceRepresentationResponse : GetRepositoryResourceMinimalResponse>>; /** Get graphics metadata for a repository resource using ID-based parameters */ abstract getResourceGraphics(accessToken: AccessToken, iTwinId: string, repositoryId: string, resourceId: string): Promise<BentleyAPIResponse<ResourceGraphicsResponse>>; /** Get graphics metadata for a repository resource using a capability URI */ abstract getResourceGraphicsByUri(accessToken: AccessToken, uri: string): Promise<BentleyAPIResponse<ResourceGraphicsResponse>>; /** Get image for iTwin */ abstract getITwinImage(accessToken: AccessToken, iTwinId: string): Promise<BentleyAPIResponse<ITwinImageResponse>>; /** Deletes image from iTwin */ abstract deleteITwinImage(accessToken: AccessToken, iTwinId: string): Promise<BentleyAPIResponse<undefined>>; /** Get iTwins */ abstract getITwins<T extends ITwinsGetQueryArg = ITwinsGetQueryArg>(accessToken: AccessToken, arg?: T): Promise<BentleyAPIResponse<T["resultMode"] extends "representation" ? MultiITwinRepresentationResponse : MultiITwinMinimalResponse>>; /** Delete the specified iTwin */ abstract deleteItwin(accessToken: AccessToken, iTwinId: string): Promise<BentleyAPIResponse<undefined>>; /** Get an ITwin */ abstract getITwin<T extends ResultMode = "minimal">(accessToken: AccessToken, iTwinId: string, resultMode?: T): Promise<BentleyAPIResponse<T extends "representation" ? ITwinRepresentationResponse : ITwinMinimalResponse>>; /** Get the primary account ITwin */ abstract getPrimaryAccount(accessToken: AccessToken): Promise<BentleyAPIResponse<ITwinMinimalResponse>>; abstract getITwinAccount<T extends ResultMode = "minimal">(accessToken: AccessToken, iTwinId: string, resultMode?: T): Promise<BentleyAPIResponse<T extends "representation" ? ITwinRepresentationResponse : ITwinMinimalResponse>>; /** Create a new iTwin */ abstract createITwin(accessToken: AccessToken, iTwin: ItwinCreate): Promise<BentleyAPIResponse<ITwinRepresentationResponse>>; /** Update the specified iTwin */ abstract updateItwin(accessToken: AccessToken, iTwinId: string, iTwin: ItwinUpdate): Promise<BentleyAPIResponse<ITwinRepresentationResponse>>; } //# sourceMappingURL=BaseITwinsApiClient.d.ts.map