// Copyright © 2022-2026 Partium, Inc. DBA Partium import { Observable } from 'rxjs'; import { BaseService, PaginatedRequestService, ServiceProvider } from '../../core'; import { Part, RELATION_TYPE } from '../models/part'; export interface RelatedPartsSummaryResponse { duplicates: number; substitutes: number; equivalents: number; not_related: number; } export type RelatedPartsSummary = { duplicatesCount: number; substitutesCount: number; equivalentsCount: number; notRelatedCount: number; }; /** * Options for the getRelatedParts method. */ export interface RelatedPartsRequestOptions { /** * If true, the enriched part-attributes will also be included in the response. */ includeAttributes?: boolean; } /** * Service for getting and setting parts. */ export interface RelatedPartsService { /** * Get a summary of the related parts, how many parts of different relation types are available. * * @param partiumPartId partiumId of the part for which to get the relation summary * @returns summary over the related parts for the given part */ getSummary(partiumPartId: string): Observable; /** * Get a paginated list of the related parts of a given relation-type, for the given part. * * @param partiumPartId partiumId of the part for which to get relations * @param relationTypes type or array of types of the relation(s) to retrieve * @param options options for the request * @returns observable that emits with a Service of type PaginatedRequestService. * This service can be used to retrieve a paginated list of the * related parts. */ getRelatedParts(partiumPartId: string, relationTypes: RELATION_TYPE | RELATION_TYPE[], options?: RelatedPartsRequestOptions): PaginatedRequestService; /** * Create a new relation between two parts. * For some relation-types it is relevant, in which direction the relation goes, so there is the relation-source (=anchor) and * the relation target (related part): * Anchor-Part | Related-Part | Type | Meaning * ------------------------------------------------------------------------------------------- * A | B | DUPLICATE | A and B are duplicates; B and A are duplicates * B | A | DUPLICATE | A and B are duplicates; B and A are duplicates * A | B | EQUIVALENT | A and B are equivalent; B and A are equivalent * B | A | EQUIVALENT | A and B are equivalent; B and A are equivalent * A | B | SUBSTITUTE | A is a predecessor of B; B is a successor of A * B | A | SUBSTITUTE | B is a predecessor of A; A is a successor of B * * @param anchorPartId partiumId of the anchor part * @param relatedPartId partiumId of the related part * @param relationType type of relation */ createPartRelation(anchorPartId: string, relatedPartId: string, relationType: RELATION_TYPE): Observable; } export declare class RelatedPartsServiceImpl extends BaseService implements RelatedPartsService { private PAGINATION_PAGE_SIZE; private httpsService; constructor(serviceProvider: ServiceProvider); onCreate(): void; getSummary(partiumPartId: string): Observable; getRelatedParts(partiumPartId: string, relationTypes: RELATION_TYPE | RELATION_TYPE[], options?: RelatedPartsRequestOptions): PaginatedRequestService; createPartRelation(anchorPartId: string, relatedPartId: string, relationType: RELATION_TYPE): Observable; }