Developers
Start building
Themes/Theme SDK/Modules/data/Types: Category to CategoryLookup

Types: Category to CategoryLookup

The types of @poltura/theme-sdk/data, Category to CategoryLookup.

On this page
import { … } from '@poltura/theme-sdk/data';

Category

A product category with its place in the category tree.

idrequiredstring

The category's id.

namerequiredstring

The category's name in the page language.

hrefrequiredstring

The category page's path.

handlerequiredstring

The category's URL segment.

pathrequiredreadonly string[]

The URL segments from the root category down to this one.

parentIdrequiredstring | null

The parent category's id, or null for a root category.

descriptionrequiredRichTextValue | null

The description, or null.

imagerequiredMediaImageRef | null

The category's image, or null.

childrenrequiredreadonly CategoryRef[]

The direct subcategories, in the merchant's order.

CategoryQuery

Which categories useCategories lists.

parentIdstring | null

Only the children of this category; null lists the root categories. Omit it for every category.

limitnumber

How many categories to list, at most 100. Defaults to 100.

CategoryRef

A category as other view models link to it.

idrequiredstring

The category's id.

namerequiredstring

The category's name in the page language.

hrefrequiredstring

The category page's path.

Collection

A hand-picked group of products with its own page.

idrequiredstring

The collection's id.

titlerequiredstring

The collection's title in the page language.

hrefrequiredstring

The collection page's path.

handlerequiredstring

The collection's URL segment.

descriptionrequiredRichTextValue | null

The description, or null.

imagerequiredMediaImageRef | null

The collection's image, or null.

CollectionQuery

Which collections useCollections lists.

pagenumber

The page number, from 1. Defaults to 1.

limitnumber

How 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.

idrequiredstring

The collection's id.

titlerequiredstring

The collection's title in the page language.

hrefrequiredstring

The 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.

pagenumber

The page number, from 1. Defaults to 1.

limitnumber

How 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.

idrequiredstring

The attribute's id.

handlerequiredstring

The attribute's stable key, as a filter group id names it.

namerequiredstring

The attribute's name in the page language.

kindrequired'select' | 'color'

Whether its values are plain choices or colours.

unitrequiredstring | null

The 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".

idrequiredstring

The value's id.

labelrequiredstring

The value's text in the page language.

colorrequiredstring | null

The colour of a colour attribute's value as a CSS colour, otherwise null.

iconrequiredIconValue | null

The 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.

totalrequirednumber

How many products match over every page.

pagerequirednumber

The page number, from 1.

pageCountrequirednumber

How many pages there are.

ProductQuery

Which products useProducts lists; every given narrowing applies at once.

pagenumber

The page number, from 1. Defaults to 1.

limitnumber

How many items a page holds, at most 100. Defaults to the store's page size.

searchstring

Search 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.

filtersListingFilterSelection

A filter selection, as {@link ListingFilterSelection} holds it.

sortProductSort

The 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".

idrequiredstring

The type's id.

namerequiredstring

The type's name in the page language.

QueryOptions

Options every data hook takes.

enabledboolean

Whether the read runs; false keeps it idle until the inputs it needs are known. Defaults to true.

suspenseboolean

Suspends the component until the answer arrives, so `data` is never undefined.

keepPreviousboolean

Keeps 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 | undefined

The answer, or undefined while the first one loads or after a failure.

statusrequiredQueryStatus

Where the read is.

errorrequiredStoreReadError | null

Why the read failed, or null.

isFetchingrequiredboolean

Whether a read is in flight, the first one or a refresh.

refetchrequired() => void

Reads 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;
}
Last updated