@twinfinity/twin
    Preparing search index...

    Class TwinClient

    Implements

    Index

    Constructors

    • Parameters

      • baseUrl: string | URL
      • _httpClient: TwinfinityHttpClient

      Returns TwinClient

    Methods

    • Executes a batch of asset operations (upsert, delete, restore) atomically. All operations succeed or all are rolled back.

      Parameters

      • twinId: string
      • operations: AssetBatchOperation[]

        Array of batch operations (max 1000).

      • Optionalsignal: AbortSignal

      Returns Promise<AssetBatchResponse>

      On validation failure (400).

      On insufficient permissions (403).

      On conflict (409) or not found (404). The error's response has per-item results with reverted statuses.

    • Retrieves multiple assets by ID in a single request.

      Parameters

      • twinId: string
      • ids: string[]

        Array of asset IDs (max 1000).

      • Optionalsignal: AbortSignal

      Returns Promise<AssetBatchGetResponse>

      On validation failure (400).

    • Parameters

      • twinId: string
      • assets: AssetPost[]
      • Optionalsignal: AbortSignal

      Returns Promise<AssetGet[]>

      On invalid request body (400). The error's errorBody has structured detail.

    • Creates a new twin or updates an existing one (upsert). Provide etag in the twin body to update.

      Parameters

      • twinId: string
      • twin: TwinPut
      • Optionalsignal: AbortSignal

      Returns Promise<TwinGet>

      On invalid request body (400).

      On etag mismatch (409). The error's currentTwin contains the server's current state.

    • Parameters

      • twinId: string
      • fileId: string
      • twinFile: TwinFilePut
      • Optionalsignal: AbortSignal

      Returns Promise<TwinFileGet>

      On invalid request body (400).

      On etag mismatch (409). The error's currentTwinFile contains the server's current state.

    • Parameters

      • twinId: string
      • fileId: string
      • twinFile: unknown
      • Optionalsignal: AbortSignal

      Returns Promise<Response>

    • Parameters

      • twinId: string
      • twin: unknown
      • Optionalsignal: AbortSignal

      Returns Promise<Response>

    • Parameters

      • twinId: string
      • assetId: string
      • etag: string
      • Optionalsignal: AbortSignal

      Returns Promise<AssetGet>

      When the asset does not exist (404).

      On etag mismatch (409). The error's currentAsset contains the server's current state.

    • Parameters

      • twinId: string
      • etag: string
      • Optionalsignal: AbortSignal

      Returns Promise<TwinGet>

      When the twin does not exist (404).

      On etag mismatch (409). The error's currentTwin contains the server's current state.

    • Parameters

      • twinId: string
      • fileId: string
      • deleteRequest: TwinFileDelete
      • Optionalsignal: AbortSignal

      Returns Promise<TwinFileGet>

      When the file does not exist (404).

      On etag mismatch (409). The error's currentTwinFile contains the server's current state.

      On invalid request (400).

    • Parameters

      • twinId: string
      • assetId: string
      • Optionalsignal: AbortSignal

      Returns Promise<AssetGet>

      When the asset does not exist (404).

    • Parameters

      • twinId: string
      • twinVersion: number
      • processorId: string
      • offset: number = 0
      • limit: number = 100
      • Optionalsignal: AbortSignal

      Returns Promise<PaginatedResponse<TwinProcessorEvent>>

      On invalid query parameters (400).

      When the processor does not exist for this twin version (404).

    • Parameters

      • twin: string | { id: string; version: number }

        Twin ID string, or {id, version} to fetch a specific version.

      • Optionalsignal: AbortSignal

      Returns Promise<TwinGet>

      When the twin or version does not exist (404).

    • Parameters

      • twinId: string
      • fileId: string
      • Optionalsignal: AbortSignal

      Returns Promise<TwinFileGet>

      When the file does not exist (404).

      On invalid request (400).

    • Parameters

      • twinId: string
      • fileId: string
      • Optionalsignal: AbortSignal

      Returns Promise<Blob>

      When the file does not exist (404).

    • Parameters

      • twinId: string
      • fileId: string
      • version: number
      • Optionalsignal: AbortSignal

      Returns Promise<TwinFileGet>

      When the file or version does not exist (404).

    • Parameters

      • twinId: string
      • fileId: string
      • version: number
      • Optionalsignal: AbortSignal

      Returns Promise<Blob>

      When the file or version does not exist (404).

    • Fetches all twins by auto-paginating through listTwins. Caps at 1000 pages.

      Parameters

      • OptionalrelatedTo: string

        Filter twins by container ID.

      • Optionalsignal: AbortSignal

      Returns Promise<ListTwinItem[]>

    • Parameters

      • twinId: string
      • offset: number = 0
      • limit: number = 100
      • Optionaloptions: { includeDeleted?: boolean }
      • Optionalsignal: AbortSignal

      Returns Promise<PaginatedResponse<AssetListItem>>

      On invalid query parameters (400).

      When the twin does not exist (404).

    • Parameters

      • OptionalrelatedTo: string

        Filter twins by container ID.

      • page: undefined | string = undefined
      • limit: number = 100
      • Optionalsignal: AbortSignal

      Returns Promise<PaginatedResponse<ListTwinItem>>

      On invalid query parameters (400).

    • Parameters

      • id: string
      • Optionaloptions: { includeDeleted?: boolean; limit?: number; page: undefined | string }
      • Optionalsignal: AbortSignal

      Returns Promise<PaginatedResponse<ListTwinItem>>

      On invalid query parameters (400).

    • Downloads and deserializes geometry info (t8gi) using default types. When no version is specified, searches versions newest-first for one containing t8gi content.

      Parameters

      • twin: string | { id: string; version: number }

        Twin ID string, or {id, version} to load a specific version.

      • Optionalsignal: AbortSignal

      Returns Promise<TwinGeometryInfo<T8GIMeshDescriptor, T8GIStyle, T8GIRegion>>

      When no version has t8gi content.

    • Downloads and deserializes geometry info (t8gi) using custom factory functions. When no version is specified, searches versions newest-first for one containing t8gi content.

      Type Parameters

      • TMeshDescriptor
      • TStyle
      • TRegion

      Parameters

      • twin: string | { id: string; version: number }

        Twin ID string, or {id, version} to load a specific version.

      • meshDescriptorFactory: (dto: T8GIMeshDescriptorDTO) => TMeshDescriptor
      • styleFactory: (dto: T8GIStyleDTO) => TStyle
      • regionFactory: (dto: T8GIRegionDTO) => TRegion
      • Optionalsignal: AbortSignal

      Returns Promise<TwinGeometryInfo<TMeshDescriptor, TStyle, TRegion>>

      When no version has t8gi content.

    • Downloads and deserializes the T8 client model (t8cm + t8cm-ext) using default types. When no version is specified, searches versions newest-first for one containing t8cm content.

      Parameters

      • twin: string | { id: string; version: number }

        Twin ID string, or {id, version} to load a specific version.

      • Optionalsignal: AbortSignal

      Returns Promise<
          Twin<
              T8Project<T8Product<T8EntityType<T8Unit>, T8Unit>, T8Unit>,
              T8Product<T8EntityType<T8Unit>, T8Unit>,
              T8EntityType<T8Unit>,
              T8Unit,
          >,
      >

      When no version has t8cm content.

    • Downloads and deserializes the T8 client model using custom factory functions for domain-specific types. When no version is specified, searches versions newest-first for one containing t8cm content.

      Type Parameters

      • TProject
      • TProduct
      • TEntityType
      • TUnit

      Parameters

      • twin: string | { id: string; version: number }

        Twin ID string, or {id, version} to load a specific version.

      • projectFactory: (dto: T8ClientProjectDTO<TUnit>) => TProject
      • productFactory: (dto: T8ClientProductDTO<TUnit>) => TProduct
      • entityTypeFactory: (dto: T8ClientEntityTypeDTO<TUnit>) => TEntityType
      • unitFactory: (dto: T8ClientUnitDTO, dataModel: T8ClientModelDTO) => TUnit
      • connectProject: (dto: T8ClientProjectConnectionsDTO<TProduct>, project: TProject) => void
      • connectProduct: (
            dto: T8ClientProductConnectionsDTO<TProduct, TEntityType>,
            product: TProduct,
        ) => void
      • Optionalsignal: AbortSignal

      Returns Promise<Twin<TProject, TProduct, TEntityType, TUnit>>

      When no version has t8cm content.

    • Downloads and deserializes both the client model (t8cm) and geometry (t8gi/t8gd) into a combined result. When no version is specified, searches versions newest-first for one containing both t8cm and t8gi content.

      Parameters

      • twin: string | { id: string; version: number }

        Twin ID string, or {id, version} to load a specific version.

      • Optionalsignal: AbortSignal

      Returns Promise<
          Twin<
              T8ProjectWithGeometry,
              T8ProductWithGeometry<T8EntityType<T8Unit>>,
              T8EntityType<T8Unit>,
              T8Unit,
          >,
      >

      When no version has both t8cm and t8gi content.

    • Parameters

      • twinId: string
      • assetId: string
      • etag: string

      Returns Promise<AssetGet>

      When the asset does not exist (404).

      On etag mismatch (409). The error's currentAsset contains the server's current state.

    • Parameters

      • twinId: string
      • etag: string
      • Optionalsignal: AbortSignal

      Returns Promise<TwinGet>

      When the twin does not exist (404).

      On etag mismatch (409). The error's currentTwin contains the server's current state.

    • Parameters

      • twinId: string
      • fileId: string
      • etag: string
      • Optionalsignal: AbortSignal

      Returns Promise<TwinFileGet>

      When the file does not exist (404).

      On etag mismatch (409). The error's currentTwinFile contains the server's current state.

      On invalid request (400).

    • Parameters

      • twinId: string
      • assetId: string
      • asset: AssetPut
      • Optionalsignal: AbortSignal

      Returns Promise<AssetGet>

      On invalid request body (400). The error's errorBody has structured detail.

      On etag mismatch (409). The error's currentAsset contains the server's current state.