Types: Category to CategoryLookup
The types of @poltura/theme-sdk/data, Category to CategoryLookup.
Ezen az oldalon
import { … } from '@poltura/theme-sdk/data';Category
A product category with its place in the category tree.
idrequiredstringThe category's id.
namerequiredstringThe category's name in the page language.
hrefrequiredstringThe category page's path.
handlerequiredstringThe category's URL segment.
pathrequiredreadonly string[]The URL segments from the root category down to this one.
parentIdrequiredstring | nullThe parent category's id, or null for a root category.
descriptionrequiredRichTextValue | nullThe description, or null.
imagerequiredMediaImageRef | nullThe category's image, or null.
childrenrequiredreadonly CategoryRef[]The direct subcategories, in the merchant's order.
CategoryQuery
Which categories useCategories lists.
parentIdstring | nullOnly the children of this category; null lists the root categories. Omit it for every category.
limitnumberHow many categories to list, at most 100. Defaults to 100.
CategoryRef
A category as other view models link to it.
idrequiredstringThe category's id.
namerequiredstringThe category's name in the page language.
hrefrequiredstringThe category page's path.
Collection
A hand-picked group of products with its own page.
idrequiredstringThe collection's id.
titlerequiredstringThe collection's title in the page language.
hrefrequiredstringThe collection page's path.
handlerequiredstringThe collection's URL segment.
descriptionrequiredRichTextValue | nullThe description, or null.
imagerequiredMediaImageRef | nullThe collection's image, or null.
CollectionQuery
Which collections useCollections lists.
pagenumberThe page number, from 1. Defaults to 1.
limitnumberHow many items a page holds, at most 100. Defaults to the store's page size.
CollectionRef
A collection as other view models link to it.
idrequiredstringThe collection's id.
titlerequiredstringThe collection's title in the page language.
hrefrequiredstringThe collection page's path.
InfiniteQueryResult
What useInfiniteProducts answers: every page loaded so far and a way to load the next.
type InfiniteQueryResult<T> = Omit<QueryResult<readonly T[]>, 'data'> & {
readonly pages: readonly T[];
readonly hasNextPage: boolean;
readonly isFetchingNextPage: boolean;
fetchNextPage(): void;
}PageRequest
Which page of a list to read.
pagenumberThe page number, from 1. Defaults to 1.
limitnumberHow many items a page holds, at most 100. Defaults to the store's page size.
ProductAttribute
A merchant-defined product attribute a list can be filtered by, such as material or colour.
idrequiredstringThe attribute's id.
handlerequiredstringThe attribute's stable key, as a filter group id names it.
namerequiredstringThe attribute's name in the page language.
kindrequired'select' | 'color'Whether its values are plain choices or colours.
unitrequiredstring | nullThe unit its values are measured in, such as `cm`, or null.
valuesrequiredreadonly ProductAttributeValue[]The values, in name order.
ProductAttributeValue
One value of a product attribute, such as "Cotton" or "Red".
idrequiredstringThe value's id.
labelrequiredstringThe value's text in the page language.
colorrequiredstring | nullThe colour of a colour attribute's value as a CSS colour, otherwise null.
iconrequiredIconValue | nullThe icon shown beside the value, as `ContentIcon` draws it, or null.
ProductPage
One page of a product list.
itemsrequiredreadonly ProductCard[]The products on this page.
totalrequirednumberHow many products match over every page.
pagerequirednumberThe page number, from 1.
pageCountrequirednumberHow many pages there are.
ProductQuery
Which products useProducts lists; every given narrowing applies at once.
pagenumberThe page number, from 1. Defaults to 1.
limitnumberHow many items a page holds, at most 100. Defaults to the store's page size.
searchstringSearch words, matched against titles, descriptions and specifications.
idsreadonly string[]Only these products, by id.
handlesreadonly string[]Only these products, by URL segment.
categoryIdsreadonly string[]Only products in these categories, by id.
collectionIdsreadonly string[]Only products in these collections, by id.
tagsreadonly string[]Only products with these tags, by tag text.
filtersListingFilterSelectionA filter selection, as {@link ListingFilterSelection} holds it.
sortProductSortThe order; defaults to `popularity`.
ProductSort
The orders a product list can be sorted in.
type ProductSort = 'popularity' | 'newest' | 'oldest' | 'titleAsc' | 'titleDesc' | 'priceAsc' | 'priceDesc'ProductTypeRef
A product type, such as "T-shirt" or "Gift card".
idrequiredstringThe type's id.
namerequiredstringThe type's name in the page language.
QueryOptions
Options every data hook takes.
enabledbooleanWhether the read runs; false keeps it idle until the inputs it needs are known. Defaults to true.
suspensebooleanSuspends the component until the answer arrives, so `data` is never undefined.
keepPreviousbooleanKeeps showing the previous answer while new inputs load, such as the next page.
QueryResult
What a data hook answers: the data once it arrived, the read's status and a way to read again.
type QueryResult<T>datarequiredT | undefinedThe answer, or undefined while the first one loads or after a failure.
statusrequiredQueryStatusWhere the read is.
errorrequiredStoreReadError | nullWhy the read failed, or null.
isFetchingrequiredbooleanWhether a read is in flight, the first one or a refresh.
refetchrequired() => voidReads again.
QueryStatus
Where a read is: still loading its first answer, failed, or answered.
type QueryStatus = 'pending' | 'error' | 'success'StoreReadErrorCode
Why a store read failed.
type StoreReadErrorCode = 'forbidden' | 'unknownKind' | 'badParams' | 'unauthenticated' | 'budget' | 'tooLarge' | 'timeout' | 'unavailable' | 'internal'SuspenseQueryOptions
QueryOptions that suspend: the hook answers a SuspenseQueryResult.
type SuspenseQueryOptions = Omit<QueryOptions, 'suspense' | 'enabled'> & {
readonly suspense: true;
}SuspenseQueryResult
What a data hook answers with { suspense: true }: the component renders only once the data is there.
type SuspenseQueryResult<T> = Omit<QueryResult<T>, 'data' | 'status' | 'error'> & {
readonly data: T;
readonly status: 'success';
readonly error: null;
}ProductLookup
Names one product, by its URL segment or by its id.
type ProductLookup = {
readonly handle: string;
} | {
readonly id: string;
}CategoryLookup
Names one category, by its URL path from the root or by its id.
type CategoryLookup = {
readonly path: readonly string[];
} | {
readonly id: string;
}