// Copyright © 2022-2026 Partium, Inc. DBA Partium import { BaseService, ServiceProvider, PaginatedRequestService } from '../../core'; import { Observable } from 'rxjs'; import { AssemblyHierarchyNode } from '../models/assembly-hierarchy-node'; export type AssemblyHierarchyTreeOrder = 'root' | 'leaf'; /** * Service for getting and setting assembly hierarchy nodes. */ export interface AssemblyHierarchyNodesService { /** * Retrieve all assembly hierarchy root nodes. * The returned array of AssemblyHierarchyNode will be ordered by their name. * @param cursorPaginationEnabled if true, the data will be fetched using the cursor as a paginator and return a string with the next and previous pages * @param treeOrder the order in which the assembly hierarchy nodes should be returned * @returns observable that emits with a Service of type PaginatedRequestService. * This service can be used to retrieve a paginated list of the * requested nodes. */ getAssemblyHierarchyRootNodes(cursorPaginationEnabled?: boolean, treeOrder?: AssemblyHierarchyTreeOrder): PaginatedRequestService; /** * Request the information of all assembly hierarchy nodes that have the given * node as parent. * * The returned array of AssemblyHierarchyNode will be ordered by their name. * * @param parentPartiumId parent-id of node from which the children should be * fetched (if null -> root-nodes will be returned) * @param cursorPaginationEnabled if true, the data will be fetched using the cursor as a paginator and return a string with the next and previous pages * @param treeOrder the order in which the assembly hierarchy nodes should be returned * @returns observable that emits with a Service of type PaginatedRequestService. * This service can be used to retrieve a paginated list of the * requested nodes. */ getAssemblyHierarchyNodesByParentId(parentPartiumId: string, cursorPaginationEnabled?: boolean, treeOrder?: AssemblyHierarchyTreeOrder): PaginatedRequestService; /** * Search for assembly hierarchy nodes by the given query. * * @param query the query to search for * @param parentPartiumId (optional) parent-id of node from which the children * should be searched (if null, all nodes will be searched) * @param language (optional) language field the query should be searched in * (default all languages are searched) * Language is expected to be a two-letter string, according to * ISO 639-1 (https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) * @param maxDepth (optional) maximum depth of nodes to be searched (0 = only direct children) * @param cursorPaginationEnabled if true, the data will be fetched using the cursor as a paginator and return a string with the next and previous pages * @param treeOrder the order in which the assembly hierarchy nodes should be returned * * @returns observable that emits with a Service of type PaginatedRequestService. * This service can be used to retrieve a paginated list of the * requested nodes. */ searchAssemblyHierarchyNodesByText(query: string, parentPartiumId?: string, language?: string, maxDepth?: number, cursorPaginationEnabled?: boolean, treeOrder?: AssemblyHierarchyTreeOrder): PaginatedRequestService; /** * Will trigger loading the information of an assembly hierarchy node from the * backend. * * @param partiumId partium-id of the assembly hierarchy node to retrieve * * @param treeOrder the order in which the assembly hierarchy nodes should be returned * @returns observable that emits when the requested assembly hierarchy node was * loaded from the backend. */ getAssemblyHierarchyNode(partiumId: string, treeOrder?: AssemblyHierarchyTreeOrder): Observable; /** * Will trigger loading the information of all requested assembly hierarchy nodes * from the backend. * * The returned array of AssemblyHierarchyNode will be in the same order as the * requested partium-ids. For every assembly hierarchy node that could not be * found, the array contains null instead. * * @param partiumIds partium-ids of all assembly hierarchy nodes to retrieve * @param treeOrder the order in which the assembly hierarchy nodes should be returned * @returns observable that emits when the requested assembly hierarchy node was * loaded from the backend. */ getAssemblyHierarchyNodes(partiumIds: string[], treeOrder?: AssemblyHierarchyTreeOrder): Observable; } export declare class AssemblyHierarchyNodesServiceImpl extends BaseService implements AssemblyHierarchyNodesService { private DOWNLOAD_PAGE_SIZE; private PAGINATION_PAGE_SIZE; private httpsService; constructor(serviceProvider: ServiceProvider); onCreate(): void; getAssemblyHierarchyRootNodes(cursorPaginationEnabled?: boolean, treeOrder?: AssemblyHierarchyTreeOrder): PaginatedRequestService; getAssemblyHierarchyNodesByParentId(parentPartiumId: string, cursorPaginationEnabled?: boolean, treeOrder?: AssemblyHierarchyTreeOrder): PaginatedRequestService; searchAssemblyHierarchyNodesByText(query: string, parentPartiumId?: string, language?: string, maxDepth?: number, cursorPaginationEnabled?: boolean, treeOrder?: AssemblyHierarchyTreeOrder): PaginatedRequestService; getAssemblyHierarchyNode(partiumId: string, treeOrder?: AssemblyHierarchyTreeOrder): Observable; getAssemblyHierarchyNodes(partiumIds: string[], treeOrder?: AssemblyHierarchyTreeOrder): Observable; /** * Load all requested assembly hierarchy nodes from the server. * Since the response is paginated, it is necessary to do as many request as needed until * all nodes are loaded. * * @param partiumIds the partium-ids of the assembly hierarchy nodes to get */ private loadAssemblyHierarchyNodesFromServer; /** * Send request for one page of nodes * * @param page the current page of the pagination (1-indexed) */ private requestPaginatedAssemblyHierarchyNodes; /** * Order the given assembly hierarchy nodes by the part-ids given in the part-id-array. * If any part is not found in unorderedAssemblyHierarchyNodes, the array contains null instead. * * @param unorderedAssemblyHierarchyNodes the assembly hierarchy nodes to order * @param partiumIds the order in which to sort * @returns array of given assembly hierarchy nodes, ordered by partiumIds (contains null for assembly hierarchy nodes not found) */ private orderAssemblyHierarchyNodes; }