/** * Related Party Subresource * * Generic subresource that wraps the underlying client-relationships endpoints * with a fixed `relationshipType`. Used by `clients.legalRepresentatives` and * `clients.controllingBeneficiaries` to give consumers a typed, * subresource-shaped API: * * ```ts * sdk.clients.legalRepresentatives.create(parentId, { ...child }); * sdk.clients.legalRepresentatives.list(parentId); * ``` * * The factory takes a parent `ClientsResource` reference so that scoped * variants automatically inherit correct input validation, transformation, * and instantiation through virtual dispatch on the parent. */ import type { ClientRelationshipType, CreateClientInput } from "@artu-ai/shared"; import type { Client, ClientData, LinkedClient } from "../../models"; export interface RelatedPartyCreateResult { child: TClient; parent: TClient; link: LinkedClient; } /** * Public shape of a typed relationship subresource. * * @typeParam TClient - The scope-specific client model returned by `create`. * @typeParam TCreateInput - The scope-specific child create input accepted by `create`. */ export interface RelatedPartySubresource { /** * Creates a new (non-primary) client and links it to `parentClientId` * with the relationship type bound by this subresource. */ create(parentClientId: string, input: TCreateInput, metadata?: Record): Promise>; /** * Lists relationships of this type for `parentClientId`. */ list(parentClientId: string): Promise; /** * Retrieves a single relationship by link ID. */ retrieve(linkId: string): Promise; /** * Updates the metadata on a relationship. */ update(linkId: string, metadata?: Record): Promise; /** * Removes the relationship between `parentClientId` and `childClientId`. * * Note: this only deletes the relationship row. The child client is left * in place (still queryable via `clients.list({ filter: { isPrimary: false } })` * or by ID). */ delete(parentClientId: string, childClientId: string): Promise; } /** * Minimal shape required by the factory from the parent resource. * * Kept narrow on purpose so scoped subclasses can satisfy it without * exposing every internal helper of `ClientsResource`. */ export interface RelatedPartyParent { createRelatedClient(parentClientId: string, relationshipType: ClientRelationshipType, input: TCreateInput, metadata?: Record): Promise>; listLinkedClients(parentClientId: string, relationshipType: ClientRelationshipType): Promise; retrieveLinkedClient(linkId: string): Promise; updateLinkedClient(linkId: string, metadata?: Record): Promise; unlinkClient(parentClientId: string, childClientId: string, relationshipType: ClientRelationshipType): Promise; } export declare function makeRelatedPartySubresource(parent: RelatedPartyParent, relationshipType: ClientRelationshipType): RelatedPartySubresource; export type { ClientData };