// Copyright © 2022-2026 Partium, Inc. DBA Partium import { Observable } from 'rxjs'; import { BaseService, PaginatedRequestService, ServiceProvider } from '../../core'; import { Part } from '../models/part'; import { PartMountingLocationInfo } from '../models/mounting-location'; /** * Options for the getPart method. */ export interface PartDetailRequestOptions { /** * Whether to include the mounting locations. * If true, the mounting locations of the part will be included in the response. (For performance reasons, the BE will * cut after a certain amount of mounting locations). * If false, the mounting locations of the part will not be included in the response. (default) * If a string-array of bom-node-ids is passed, then mounting locations will be included in the response, whereas the * ones with the ids passed will definitely be added (due to performance reasons others might be cut out). */ includeMountingLocations?: boolean | string[]; /** * If true, the enriched metadata and summary-id will also be included in the response. */ includeSummary?: boolean; /** * If true, the enrichment status and enriched metadata will also be included in the response. */ includeEnrichment?: boolean; } /** * Service for getting and setting parts. */ export interface PartService { /** * Will trigger loading the information of a part from the backend. * * It will also fetch the part attributes which is not fetched by getParts * method. * * @param partiumPartId part-id of the part to retrieve * @param options options for the request * @returns observable that emits when the requested part was loaded from * the backend * @returns observable that emits when the requested part was loaded from the * backend. */ getPart(partiumPartId: string, options?: PartDetailRequestOptions): Observable; /** * Will trigger loading the information of all requested parts from the backend. * * It will not fetch the part attributes compared to getPart method. * * The returned array of Parts will be in the same order as the requested * part-ids. For every part that could not be found, the array contains null * instead. * * @param partiumPartIds part-ids of all parts to retrieve * @returns observable that emits when the requested part was loaded from the * backend */ getParts(partiumPartIds: string[]): Observable; /** * Request the information of all parts that have the given assembly hierarchy * node as parent. * * It will not fetch the part attributes compared to getPart method. * * @param assemblyHierarchyNodeId id of the parent assembly hierarchy node * @returns observable that emits with a Service of type PaginatedRequestService. * This service can be used to retrieve a paginated list of the * requested parts. */ getPartsByAssemblyHierarchyNodeId(assemblyHierarchyNodeId: string): PaginatedRequestService; /** * Requests all mounting locations for a part. * * @param partPartiumId partium-id of the part * @param prioritizedLocationIds optional array of location ids to include for sure (the whole list will be cut after a certain amount of elements, but these will be included) * @returns observable that emits all the mounting locations for the part */ getMountingLocationsForPart(partPartiumId: string, prioritizedLocationIds?: string[]): Observable; } export declare class PartServiceImpl extends BaseService implements PartService { private DOWNLOAD_PAGE_SIZE; private PAGINATION_PAGE_SIZE; private httpsService; constructor(serviceProvider: ServiceProvider); onCreate(): void; getPart(partiumPartId: string, options?: PartDetailRequestOptions): Observable; getParts(partiumPartIds: string[]): Observable; getPartsByAssemblyHierarchyNodeId(assemblyHierarchyNodeId: string): PaginatedRequestService; getMountingLocationsForPart(partPartiumId: string, prioritizedLocationIds?: string[]): Observable; /** * Load the requested part from the server. * * @param partiumPartId the partium-id of the parts to get * @param options options for the request */ private loadPartFromServer; /** * Load all requested parts from the server. * Since the response is paginated, it is necessary to do as many request as needed until * all nodes are loaded. * * @param partiumPartIds the partium-ids of the parts to get */ private loadPartsFromServer; /** * Sent request for one page of nodes * * @param page the current page of the pagination (1-indexed) */ private requestPaginatedParts; /** * Order the given parts by the part-ids given in the part-id-array. * If any part is not found in unorderedParts, the array contains null instead. * * @param unorderedParts the parts to order * @param partiumPartIds the order in which to sort * @returns array of given parts, ordered by partiumPartIds (contains null for parts not found) */ private orderParts; }