import { Ref, ComputedRef } from 'vue'; import { GraphQLClient, SparePartsMachine, SparePart, SparePartsResponse, AttributeFilter, Contact, Customer, ProductTextFilterInput } from '@propeller-commerce/propeller-sdk-v2'; export interface UseSparePartsOptions { /** SDK client. Without it the composable stays idle (controlled mode needs no client). */ graphqlClient?: GraphQLClient; /** * Controlled mode: pre-fetched parts (e.g. SSR-seeded). When the ref's VALUE * is DEFINED the composable performs no fetching and echoes these back. Pass * `[]` (not `undefined`) to show an empty state while the host controls loading. */ parts?: Ref; /** Slug of the machine whose parts to list. */ slug?: Ref; /** Free-text search, scoped server-side to this machine's parts. */ term?: Ref; /** Language for the spare parts themselves (the storefront language). */ language: Ref; /** * Language the MACHINE TREE is authored in. Defaults to `language`. * * `machine(slug:, language:)` is language-scoped and hard-errors with * "No machine found for slug and language" when the machine has no name/slug * in that language. Machine trees are commonly maintained in one language * (typically EN) while their spare parts are localized. */ machineLanguage?: Ref; /** * Extra languages to try when the slug does not resolve in `machineLanguage`. * * A slug resolves only in the language it was authored in, so a tree that is * only half-translated has machines reachable by an NL slug but not an EN * one. `machineLanguage` and `language` are always tried first; list the * shop's other locales here to cover the rest. Order is the try order. */ machineLanguages?: Ref; /** Tax zone for price calculation. */ taxZone?: string; /** Active user — drives `userId` scoping and contact/customer pricing. */ user?: Ref; /** Active company — scopes the assortment. */ companyId?: Ref; /** Attribute (facet) filters. */ textFilters?: Ref; /** Price-range filter lower bound. */ priceFilterMin?: Ref; /** Price-range filter upper bound. */ priceFilterMax?: Ref; /** Sort field. */ sortField?: Ref; /** Sort direction. */ sortOrder?: Ref; /** Items per page. Defaults to 12. */ pageSize?: Ref; /** * Controlled page. When provided the composable renders (and fetches) this * page and `goToPage` becomes advisory — the host owns the number, typically * from the URL. Every other listing input was already an option, so its * absence read as "paging is internal" and it was not (PWP-995b). Omit it to * keep the previous uncontrolled behaviour. */ page?: Ref; /** Image filter config, mirroring `useProductSearch`'s `configuration`. */ configuration?: { /** The channel's anonymous user — logged-out listings are scoped to it. */ anonymousUserId?: number; imageSearchFiltersGrid?: unknown; imageVariantFiltersMedium?: unknown; }; /** Fired with the facet list after each fetch. */ onFiltersChange?: (filters: AttributeFilter[]) => void; /** Fired with the price-slider bounds after each fetch. */ onPriceBoundsChange?: (min: number, max: number) => void; /** Fired with the total item count after each fetch. */ onItemsFoundChange?: (count: number) => void; /** Fired with the raw parts response after each fetch. */ onPartsResponse?: (response: SparePartsResponse) => void; /** Fired with the machine itself after each fetch (name, child machines, …). */ onMachineChange?: (machine: SparePartsMachine) => void; } export interface UseSparePartsReturn { /** The parts to render — the controlled prop when set, else the fetched list. */ displayParts: ComputedRef; /** Child machines of this node, for rendering alongside the parts. */ childMachines: Ref; /** Total parts found. */ itemsFound: Ref; /** `true` while an internal fetch is in flight. Always `false` when controlled. */ isLoading: ComputedRef; /** Current page (1-based). */ currentPage: Ref; /** Total pages. */ totalPages: Ref; /** Re-run the fetch. No-op in controlled mode. */ fetchParts: () => Promise; /** Navigate to a page. */ goToPage: (page: number) => void; /** * The slug resolved in none of the candidate languages. * * Distinct from "resolved but has no parts": this node does not exist, and a * host that renders the usual empty listing for it shows a page built * entirely from the URL. Always `false` in controlled mode. */ notFound: ComputedRef; } /** * useSpareParts — fetch and paginate a machine node's spare-parts list. */ export declare function useSpareParts(options: UseSparePartsOptions): UseSparePartsReturn;