UNPKG

@techsio/storefront-data

Version:

Medusa-first storefront data layer built on TanStack Query.

30 lines (29 loc) • 1.05 kB
import { compactRecord } from "../shared/object-utils.js"; import { resolvePagination } from "../shared/pagination.js"; const stripListInput = (input)=>{ const { enabled: _enabled, customerId: _customerId, page: _page, ...params } = input; return params; }; const stripDetailInput = (input)=>{ const { enabled: _enabled, customerId: _customerId, ...params } = input; return params; }; const createDefaultListParams = (input, defaultPageSize)=>{ const params = stripListInput(input); if ("number" != typeof input.page) return compactRecord(params); const pagination = resolvePagination({ page: input.page, limit: input.limit, offset: input.offset }, defaultPageSize); return compactRecord({ ...params, limit: pagination.limit, offset: pagination.offset }); }; const withCustomerScope = (params, input)=>({ ...params, customerId: input.customerId ?? null }); export { createDefaultListParams, stripDetailInput, stripListInput, withCustomerScope };