@01.software/sdk 0.38.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +169 -54
- package/dist/analytics/react.cjs.map +1 -1
- package/dist/analytics/react.js.map +1 -1
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.js.map +1 -1
- package/dist/client.cjs +1194 -5
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +8 -7
- package/dist/client.d.ts +8 -7
- package/dist/client.js +1194 -5
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-BroIWHY1.d.ts → collection-client-CKFa99C6.d.ts} +16 -10
- package/dist/{collection-client-B0J9wMNE.d.cts → collection-client-VYwYi6u6.d.cts} +16 -10
- package/dist/const-4BUtUdGU.d.cts +32 -0
- package/dist/const-ymprfiPf.d.ts +32 -0
- package/dist/errors.cjs +4 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.js +4 -1
- package/dist/errors.js.map +1 -1
- package/dist/{index-BOLQxveo.d.cts → index-Dquv4xTL.d.cts} +3 -3
- package/dist/{index-CSwR2HSg.d.ts → index-w36lpSkU.d.ts} +3 -3
- package/dist/index.cjs +2796 -2651
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +2796 -2651
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-m3jjhxk9.d.cts → payload-types-DC0xzR9i.d.cts} +470 -265
- package/dist/{payload-types-m3jjhxk9.d.ts → payload-types-DC0xzR9i.d.ts} +470 -265
- package/dist/query.cjs +241 -58
- package/dist/query.cjs.map +1 -1
- package/dist/query.d.cts +151 -26
- package/dist/query.d.ts +151 -26
- package/dist/query.js +241 -58
- package/dist/query.js.map +1 -1
- package/dist/realtime.cjs +5 -1
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- package/dist/realtime.js +5 -1
- package/dist/realtime.js.map +1 -1
- package/dist/server.cjs +1117 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +7 -7
- package/dist/server.d.ts +7 -7
- package/dist/server.js +1117 -1
- package/dist/server.js.map +1 -1
- package/dist/storefront-cache.cjs +144 -0
- package/dist/storefront-cache.cjs.map +1 -0
- package/dist/storefront-cache.d.cts +24 -0
- package/dist/storefront-cache.d.ts +24 -0
- package/dist/storefront-cache.js +121 -0
- package/dist/storefront-cache.js.map +1 -0
- package/dist/{types-Cmrd1ezc.d.ts → types-Bh2p-EMc.d.ts} +5 -1
- package/dist/{types-D0ubzQw0.d.cts → types-BvpjooU-.d.cts} +5 -1
- package/dist/{types-D2xYdz4P.d.ts → types-D5uHrPLr.d.cts} +264 -96
- package/dist/{types-CIGscmus.d.cts → types-Umd-YTjM.d.ts} +264 -96
- package/dist/ui/canvas/server.cjs +5 -1
- package/dist/ui/canvas/server.cjs.map +1 -1
- package/dist/ui/canvas/server.js +5 -1
- package/dist/ui/canvas/server.js.map +1 -1
- package/dist/ui/canvas.cjs +5 -1
- package/dist/ui/canvas.cjs.map +1 -1
- package/dist/ui/canvas.js +5 -1
- package/dist/ui/canvas.js.map +1 -1
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/video.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/webhook.d.cts +4 -4
- package/dist/webhook.d.ts +4 -4
- package/package.json +13 -3
- package/dist/const-6XHz_jej.d.ts +0 -32
- package/dist/const-B5KT72c7.d.cts +0 -32
package/dist/server.js
CHANGED
|
@@ -606,6 +606,32 @@ function listingGroupsQuery(params) {
|
|
|
606
606
|
function listingGroupsCatalogQuery(params) {
|
|
607
607
|
return `/api/products/listing-groups/catalog?ids=${params.productIds.map(encodeURIComponent).join(",")}`;
|
|
608
608
|
}
|
|
609
|
+
function appendListingGroupsQuerySearchParams(search, options) {
|
|
610
|
+
if (options?.page != null) search.set("page", String(options.page));
|
|
611
|
+
if (options?.limit != null) search.set("limit", String(options.limit));
|
|
612
|
+
if (options?.sort != null) {
|
|
613
|
+
const sort = options.sort;
|
|
614
|
+
search.set(
|
|
615
|
+
"sort",
|
|
616
|
+
Array.isArray(sort) ? sort.join(",") : sort
|
|
617
|
+
);
|
|
618
|
+
}
|
|
619
|
+
if (options?.where != null) {
|
|
620
|
+
search.set("whereJson", JSON.stringify(options.where));
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
function listingGroupsQueryUrl(options) {
|
|
624
|
+
const search = new URLSearchParams();
|
|
625
|
+
appendListingGroupsQuerySearchParams(search, options);
|
|
626
|
+
const query = search.toString();
|
|
627
|
+
return `/api/products/listing-groups/query${query ? `?${query}` : ""}`;
|
|
628
|
+
}
|
|
629
|
+
function listingGroupsQueryCatalogUrl(options) {
|
|
630
|
+
const search = new URLSearchParams();
|
|
631
|
+
appendListingGroupsQuerySearchParams(search, options);
|
|
632
|
+
const query = search.toString();
|
|
633
|
+
return `/api/products/listing-groups/query/catalog${query ? `?${query}` : ""}`;
|
|
634
|
+
}
|
|
609
635
|
function stockSnapshotQuery(params) {
|
|
610
636
|
return `/api/products/stock?variantIds=${params.variantIds.map(encodeURIComponent).join(",")}`;
|
|
611
637
|
}
|
|
@@ -1593,6 +1619,1019 @@ var CartApi = class extends CustomerScopedApi {
|
|
|
1593
1619
|
}
|
|
1594
1620
|
};
|
|
1595
1621
|
|
|
1622
|
+
// src/utils/product-selection-media.ts
|
|
1623
|
+
function selectedSwatchMediaItemId(swatch) {
|
|
1624
|
+
if (!swatch || swatch.type !== "media") return null;
|
|
1625
|
+
const id = swatch.mediaItemId;
|
|
1626
|
+
if (id == null || id === "") return null;
|
|
1627
|
+
return String(id);
|
|
1628
|
+
}
|
|
1629
|
+
function getMediaId(value) {
|
|
1630
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
1631
|
+
return String(value);
|
|
1632
|
+
}
|
|
1633
|
+
if (typeof value === "object" && value !== null && "id" in value) {
|
|
1634
|
+
const id = value.id;
|
|
1635
|
+
if (typeof id === "string" || typeof id === "number") return String(id);
|
|
1636
|
+
}
|
|
1637
|
+
return null;
|
|
1638
|
+
}
|
|
1639
|
+
function mediaArray(value) {
|
|
1640
|
+
if (!Array.isArray(value)) return [];
|
|
1641
|
+
return value.filter((entry) => entry != null);
|
|
1642
|
+
}
|
|
1643
|
+
function uniqueWithPrimaryFirst(primary, items) {
|
|
1644
|
+
const unique = /* @__PURE__ */ new Map();
|
|
1645
|
+
for (const item of items) {
|
|
1646
|
+
const id = getMediaId(item);
|
|
1647
|
+
const key = id ?? `inline:${unique.size}`;
|
|
1648
|
+
if (!unique.has(key)) unique.set(key, item);
|
|
1649
|
+
}
|
|
1650
|
+
if (primary) {
|
|
1651
|
+
const primaryId = getMediaId(primary);
|
|
1652
|
+
const prefixed = /* @__PURE__ */ new Map();
|
|
1653
|
+
const primaryKey = primaryId ?? "inline:primary";
|
|
1654
|
+
prefixed.set(primaryKey, primary);
|
|
1655
|
+
for (const [key, value] of unique.entries()) {
|
|
1656
|
+
if (!prefixed.has(key)) prefixed.set(key, value);
|
|
1657
|
+
}
|
|
1658
|
+
return Array.from(prefixed.values());
|
|
1659
|
+
}
|
|
1660
|
+
return Array.from(unique.values());
|
|
1661
|
+
}
|
|
1662
|
+
function buildPoolById(pool) {
|
|
1663
|
+
const poolById = /* @__PURE__ */ new Map();
|
|
1664
|
+
for (const item of pool) {
|
|
1665
|
+
const id = getMediaId(item);
|
|
1666
|
+
if (id) poolById.set(id, item);
|
|
1667
|
+
}
|
|
1668
|
+
return poolById;
|
|
1669
|
+
}
|
|
1670
|
+
function resolveVariantImageItems(variant, poolById) {
|
|
1671
|
+
if (!variant || !Array.isArray(variant.images)) return [];
|
|
1672
|
+
const resolved = [];
|
|
1673
|
+
for (const entry of variant.images) {
|
|
1674
|
+
if (entry == null) continue;
|
|
1675
|
+
if (typeof entry === "string" || typeof entry === "number") {
|
|
1676
|
+
const pooled = poolById.get(String(entry));
|
|
1677
|
+
if (pooled) resolved.push(pooled);
|
|
1678
|
+
continue;
|
|
1679
|
+
}
|
|
1680
|
+
const mediaId = getMediaId(entry);
|
|
1681
|
+
if (mediaId) {
|
|
1682
|
+
const pooled = poolById.get(mediaId);
|
|
1683
|
+
if (pooled) {
|
|
1684
|
+
resolved.push(pooled);
|
|
1685
|
+
}
|
|
1686
|
+
continue;
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
return resolved;
|
|
1690
|
+
}
|
|
1691
|
+
function resolveOptionSwatchPrimary(selectedOptionValues, poolById) {
|
|
1692
|
+
if (!selectedOptionValues?.length) return null;
|
|
1693
|
+
for (const optionValue of selectedOptionValues) {
|
|
1694
|
+
const swatch = optionValue?.swatch;
|
|
1695
|
+
const swatchPointer = selectedSwatchMediaItemId(swatch);
|
|
1696
|
+
if (swatchPointer) {
|
|
1697
|
+
const pooled = poolById.get(swatchPointer);
|
|
1698
|
+
if (pooled) return pooled;
|
|
1699
|
+
}
|
|
1700
|
+
const inline = swatch?.inlineMedia;
|
|
1701
|
+
if (inline != null && typeof inline === "object") {
|
|
1702
|
+
return inline;
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
return null;
|
|
1706
|
+
}
|
|
1707
|
+
function resolveProductSelectionMedia(input) {
|
|
1708
|
+
const pool = mediaArray(input.productMediaPool);
|
|
1709
|
+
const poolById = buildPoolById(pool);
|
|
1710
|
+
const selectedVariantImages = resolveVariantImageItems(
|
|
1711
|
+
input.selectedVariant,
|
|
1712
|
+
poolById
|
|
1713
|
+
);
|
|
1714
|
+
if (selectedVariantImages.length > 0) {
|
|
1715
|
+
const primaryImage = selectedVariantImages[0] ?? null;
|
|
1716
|
+
return {
|
|
1717
|
+
primaryImage,
|
|
1718
|
+
images: uniqueWithPrimaryFirst(primaryImage, selectedVariantImages),
|
|
1719
|
+
source: "variant_media_selected"
|
|
1720
|
+
};
|
|
1721
|
+
}
|
|
1722
|
+
if (input.selectedVariant == null && (input.matchingVariants?.length ?? 0) > 0) {
|
|
1723
|
+
const mergedMatchingImages = [];
|
|
1724
|
+
for (const matchingVariant of input.matchingVariants ?? []) {
|
|
1725
|
+
mergedMatchingImages.push(
|
|
1726
|
+
...resolveVariantImageItems(matchingVariant, poolById)
|
|
1727
|
+
);
|
|
1728
|
+
}
|
|
1729
|
+
if (mergedMatchingImages.length > 0) {
|
|
1730
|
+
const primaryImage = mergedMatchingImages[0] ?? null;
|
|
1731
|
+
return {
|
|
1732
|
+
primaryImage,
|
|
1733
|
+
images: uniqueWithPrimaryFirst(primaryImage, mergedMatchingImages),
|
|
1734
|
+
source: "variant_media_matching"
|
|
1735
|
+
};
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
const optionSwatchPrimary = resolveOptionSwatchPrimary(
|
|
1739
|
+
input.selectedOptionValues,
|
|
1740
|
+
poolById
|
|
1741
|
+
);
|
|
1742
|
+
if (optionSwatchPrimary) {
|
|
1743
|
+
return {
|
|
1744
|
+
primaryImage: optionSwatchPrimary,
|
|
1745
|
+
images: [optionSwatchPrimary],
|
|
1746
|
+
source: "option_swatch"
|
|
1747
|
+
};
|
|
1748
|
+
}
|
|
1749
|
+
return {
|
|
1750
|
+
primaryImage: null,
|
|
1751
|
+
images: [],
|
|
1752
|
+
source: "none"
|
|
1753
|
+
};
|
|
1754
|
+
}
|
|
1755
|
+
function resolveFeaturedImagePointer(input) {
|
|
1756
|
+
const pool = mediaArray(input.productMediaPool);
|
|
1757
|
+
const resolvedPointer = getMediaId(input.resolvedPrimary);
|
|
1758
|
+
if (resolvedPointer && input.resolvedSource !== "product_pool" && input.resolvedSource !== "none") {
|
|
1759
|
+
return resolvedPointer;
|
|
1760
|
+
}
|
|
1761
|
+
const poolById = buildPoolById(pool);
|
|
1762
|
+
const featuredImagePointer = getMediaId(input.featuredImage);
|
|
1763
|
+
if (featuredImagePointer && poolById.has(featuredImagePointer)) {
|
|
1764
|
+
return featuredImagePointer;
|
|
1765
|
+
}
|
|
1766
|
+
if (pool.length > 0) {
|
|
1767
|
+
const firstPoolId = getMediaId(pool[0]);
|
|
1768
|
+
if (firstPoolId) return firstPoolId;
|
|
1769
|
+
}
|
|
1770
|
+
return null;
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
// src/utils/ecommerce.ts
|
|
1774
|
+
var DEFAULT_PRODUCT_SELECTION_URL_EMIT = "slug-compat";
|
|
1775
|
+
function resolveProductSelectionUrlEmit(emit) {
|
|
1776
|
+
return emit ?? DEFAULT_PRODUCT_SELECTION_URL_EMIT;
|
|
1777
|
+
}
|
|
1778
|
+
function appendSlugCompatSelectionParam(params, matrix, optionId, valueId) {
|
|
1779
|
+
const option = matrix.optionById.get(optionId);
|
|
1780
|
+
const value = matrix.valueById.get(valueId);
|
|
1781
|
+
if (!option?.slug || !value?.slug) return false;
|
|
1782
|
+
const slugMatches = option.values.filter(
|
|
1783
|
+
(candidate) => candidate.slug === value.slug
|
|
1784
|
+
);
|
|
1785
|
+
if (slugMatches.length !== 1) return false;
|
|
1786
|
+
params.append(`opt.${option.slug}`, value.slug);
|
|
1787
|
+
return true;
|
|
1788
|
+
}
|
|
1789
|
+
function appendCanonicalSelectionParam(params, optionId, valueId) {
|
|
1790
|
+
params.append(`opt.${optionId}`, valueId);
|
|
1791
|
+
}
|
|
1792
|
+
var ProductSelectionCodecError = class extends Error {
|
|
1793
|
+
constructor(message) {
|
|
1794
|
+
super(message);
|
|
1795
|
+
this.code = "ambiguous_product_selection_query";
|
|
1796
|
+
this.name = "ProductSelectionCodecError";
|
|
1797
|
+
}
|
|
1798
|
+
};
|
|
1799
|
+
function getRelationID(value) {
|
|
1800
|
+
if (typeof value === "string") return value;
|
|
1801
|
+
if (typeof value === "number") return String(value);
|
|
1802
|
+
if (value && typeof value === "object" && "id" in value) {
|
|
1803
|
+
const id = value.id;
|
|
1804
|
+
if (typeof id === "string") return id;
|
|
1805
|
+
if (typeof id === "number") return String(id);
|
|
1806
|
+
}
|
|
1807
|
+
return void 0;
|
|
1808
|
+
}
|
|
1809
|
+
function extractEntityId(value) {
|
|
1810
|
+
if (typeof value === "string") return value;
|
|
1811
|
+
if (typeof value === "number") return String(value);
|
|
1812
|
+
if (value && typeof value === "object" && "id" in value) {
|
|
1813
|
+
if (typeof value.id === "string") return value.id;
|
|
1814
|
+
if (typeof value.id === "number") return String(value.id);
|
|
1815
|
+
}
|
|
1816
|
+
return null;
|
|
1817
|
+
}
|
|
1818
|
+
function resolveGenericListingPrimaryImage(product, resolvedPrimary, resolvedSource) {
|
|
1819
|
+
return resolveFeaturedImagePointer({
|
|
1820
|
+
productMediaPool: product?.images ?? [],
|
|
1821
|
+
featuredImage: product?.featuredImage ?? null,
|
|
1822
|
+
resolvedPrimary,
|
|
1823
|
+
resolvedSource
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
function normalizeProductOptionValueSwatch(swatch) {
|
|
1827
|
+
if (swatch == null) return null;
|
|
1828
|
+
if (typeof swatch !== "object") return null;
|
|
1829
|
+
const raw = swatch;
|
|
1830
|
+
const mediaItemId = extractEntityId(raw.mediaItemId);
|
|
1831
|
+
const color = typeof raw.color === "string" ? raw.color.trim() : "";
|
|
1832
|
+
const hasColor = color.length > 0;
|
|
1833
|
+
if (raw.type === "media" || mediaItemId && raw.type !== "color") {
|
|
1834
|
+
if (!mediaItemId || hasColor) return null;
|
|
1835
|
+
return {
|
|
1836
|
+
type: "media",
|
|
1837
|
+
mediaItemId,
|
|
1838
|
+
color: null
|
|
1839
|
+
};
|
|
1840
|
+
}
|
|
1841
|
+
if (raw.type === "color" || hasColor) {
|
|
1842
|
+
if (mediaItemId || !hasColor) return null;
|
|
1843
|
+
return { type: "color", color, mediaItemId: null };
|
|
1844
|
+
}
|
|
1845
|
+
return null;
|
|
1846
|
+
}
|
|
1847
|
+
function matrixOrder(index) {
|
|
1848
|
+
return String(index).padStart(6, "0");
|
|
1849
|
+
}
|
|
1850
|
+
function buildProductOptionMatrixFromDetail(detail) {
|
|
1851
|
+
const normalizedOptions = detail.options.map((option, optionIndex) => ({
|
|
1852
|
+
id: String(option.id),
|
|
1853
|
+
title: option.title || String(option.id),
|
|
1854
|
+
slug: option.slug,
|
|
1855
|
+
order: matrixOrder(optionIndex),
|
|
1856
|
+
values: option.values.map((value, valueIndex) => ({
|
|
1857
|
+
id: String(value.id),
|
|
1858
|
+
optionId: String(option.id),
|
|
1859
|
+
optionSlug: option.slug,
|
|
1860
|
+
label: value.value || value.slug || String(value.id),
|
|
1861
|
+
slug: value.slug,
|
|
1862
|
+
swatch: normalizeProductOptionValueSwatch(value.swatch),
|
|
1863
|
+
order: matrixOrder(valueIndex)
|
|
1864
|
+
}))
|
|
1865
|
+
}));
|
|
1866
|
+
const optionById = new Map(
|
|
1867
|
+
normalizedOptions.map((option) => [option.id, option])
|
|
1868
|
+
);
|
|
1869
|
+
const optionBySlug = new Map(
|
|
1870
|
+
normalizedOptions.map((option) => [option.slug, option])
|
|
1871
|
+
);
|
|
1872
|
+
const valueById = /* @__PURE__ */ new Map();
|
|
1873
|
+
const valueToOptionId = /* @__PURE__ */ new Map();
|
|
1874
|
+
const valueToOptionSlug = /* @__PURE__ */ new Map();
|
|
1875
|
+
for (const option of normalizedOptions) {
|
|
1876
|
+
for (const value of option.values) {
|
|
1877
|
+
valueById.set(value.id, value);
|
|
1878
|
+
valueToOptionId.set(value.id, option.id);
|
|
1879
|
+
valueToOptionSlug.set(value.id, option.slug);
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
const optionIds = normalizedOptions.map((option) => option.id);
|
|
1883
|
+
const optionSlugs = normalizedOptions.map((option) => option.slug);
|
|
1884
|
+
const normalizedVariants = detail.variants.map((variant) => {
|
|
1885
|
+
const optionValueByOptionId = /* @__PURE__ */ new Map();
|
|
1886
|
+
const optionValueByOptionSlug = /* @__PURE__ */ new Map();
|
|
1887
|
+
for (const rawValue of variant.optionValues) {
|
|
1888
|
+
const optionId = String(rawValue.optionId);
|
|
1889
|
+
const valueId = String(rawValue.valueId);
|
|
1890
|
+
const optionSlug = rawValue.optionSlug;
|
|
1891
|
+
if (!optionById.has(optionId)) continue;
|
|
1892
|
+
if (valueToOptionId.get(valueId) !== optionId) continue;
|
|
1893
|
+
if (optionValueByOptionId.has(optionId)) continue;
|
|
1894
|
+
optionValueByOptionId.set(optionId, valueId);
|
|
1895
|
+
if (optionSlug && !optionValueByOptionSlug.has(optionSlug)) {
|
|
1896
|
+
optionValueByOptionSlug.set(optionSlug, valueId);
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
const optionValueIds = optionIds.map((optionId) => optionValueByOptionId.get(optionId)).filter((valueId) => Boolean(valueId));
|
|
1900
|
+
return {
|
|
1901
|
+
id: String(variant.id),
|
|
1902
|
+
optionValueIds,
|
|
1903
|
+
optionValueByOptionId,
|
|
1904
|
+
optionValueByOptionSlug,
|
|
1905
|
+
source: variant
|
|
1906
|
+
};
|
|
1907
|
+
});
|
|
1908
|
+
return {
|
|
1909
|
+
options: normalizedOptions,
|
|
1910
|
+
optionIds,
|
|
1911
|
+
optionSlugs,
|
|
1912
|
+
optionById,
|
|
1913
|
+
optionBySlug,
|
|
1914
|
+
valueById,
|
|
1915
|
+
valueToOptionId,
|
|
1916
|
+
valueToOptionSlug,
|
|
1917
|
+
variants: normalizedVariants
|
|
1918
|
+
};
|
|
1919
|
+
}
|
|
1920
|
+
function getVariantSelection(matrix, variantId) {
|
|
1921
|
+
if (variantId == null) return void 0;
|
|
1922
|
+
const id = String(variantId);
|
|
1923
|
+
return matrix.variants.find((variant) => variant.id === id);
|
|
1924
|
+
}
|
|
1925
|
+
function hasExplicitSelection(selection) {
|
|
1926
|
+
return Boolean(
|
|
1927
|
+
selection.variantId != null || selection.search || selection.valueIds || Object.keys(selection.byOptionId ?? {}).length > 0 || Object.keys(selection.byOptionSlug ?? {}).length > 0
|
|
1928
|
+
);
|
|
1929
|
+
}
|
|
1930
|
+
function assignSelectedValue(matrix, selectedByOptionId, optionId, valueId) {
|
|
1931
|
+
if (valueId == null) return false;
|
|
1932
|
+
const normalizedValueId = String(valueId);
|
|
1933
|
+
if (matrix.valueToOptionId.get(normalizedValueId) !== optionId) return false;
|
|
1934
|
+
selectedByOptionId.set(optionId, normalizedValueId);
|
|
1935
|
+
return true;
|
|
1936
|
+
}
|
|
1937
|
+
function assignSelectedValueSlugByOptionId(matrix, selectedByOptionId, optionId, valueSlug) {
|
|
1938
|
+
if (!valueSlug) return false;
|
|
1939
|
+
const option = matrix.optionById.get(optionId);
|
|
1940
|
+
if (!option) return false;
|
|
1941
|
+
const values = option.values.filter(
|
|
1942
|
+
(candidate) => candidate.slug === valueSlug
|
|
1943
|
+
);
|
|
1944
|
+
if (values.length > 1) {
|
|
1945
|
+
throw new ProductSelectionCodecError(
|
|
1946
|
+
`Ambiguous product selection value slug "${valueSlug}" for option "${optionId}". Use opt.<optionId>=<valueId>.`
|
|
1947
|
+
);
|
|
1948
|
+
}
|
|
1949
|
+
const value = values[0];
|
|
1950
|
+
if (!value) return false;
|
|
1951
|
+
selectedByOptionId.set(optionId, value.id);
|
|
1952
|
+
return true;
|
|
1953
|
+
}
|
|
1954
|
+
function assignSelectedValueSlugByOptionSlug(matrix, selectedByOptionId, optionSlug, valueSlug) {
|
|
1955
|
+
if (!valueSlug) return false;
|
|
1956
|
+
const option = matrix.optionBySlug.get(optionSlug);
|
|
1957
|
+
if (!option) return false;
|
|
1958
|
+
const values = option.values.filter(
|
|
1959
|
+
(candidate) => candidate.slug === valueSlug
|
|
1960
|
+
);
|
|
1961
|
+
if (values.length > 1) {
|
|
1962
|
+
throw new ProductSelectionCodecError(
|
|
1963
|
+
`Ambiguous product selection value slug "${valueSlug}" for option "${optionSlug}". Use opt.<optionId>=<valueId>.`
|
|
1964
|
+
);
|
|
1965
|
+
}
|
|
1966
|
+
const value = values[0];
|
|
1967
|
+
if (!value) return false;
|
|
1968
|
+
selectedByOptionId.set(option.id, value.id);
|
|
1969
|
+
return true;
|
|
1970
|
+
}
|
|
1971
|
+
function toSearchParams(search) {
|
|
1972
|
+
if (!search) return new URLSearchParams();
|
|
1973
|
+
if (search instanceof URLSearchParams) return new URLSearchParams(search);
|
|
1974
|
+
if (search instanceof URL) return new URLSearchParams(search.searchParams);
|
|
1975
|
+
const trimmed = search.trim();
|
|
1976
|
+
if (!trimmed) return new URLSearchParams();
|
|
1977
|
+
try {
|
|
1978
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed)) {
|
|
1979
|
+
return new URL(trimmed).searchParams;
|
|
1980
|
+
}
|
|
1981
|
+
} catch {
|
|
1982
|
+
return new URLSearchParams();
|
|
1983
|
+
}
|
|
1984
|
+
return new URLSearchParams(
|
|
1985
|
+
trimmed.startsWith("?") ? trimmed.slice(1) : trimmed
|
|
1986
|
+
);
|
|
1987
|
+
}
|
|
1988
|
+
function slugLike(value) {
|
|
1989
|
+
return value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
1990
|
+
}
|
|
1991
|
+
function assertNoAmbiguousSelectionParams(matrix, params) {
|
|
1992
|
+
const knownSelectionKeys = /* @__PURE__ */ new Set();
|
|
1993
|
+
const hasVariantParam = params.has("variant");
|
|
1994
|
+
const hasOptionParams = Array.from(params.keys()).some(
|
|
1995
|
+
(key) => key.startsWith("opt.")
|
|
1996
|
+
);
|
|
1997
|
+
if (hasVariantParam && hasOptionParams) {
|
|
1998
|
+
throw new ProductSelectionCodecError(
|
|
1999
|
+
"Product selection URL cannot mix variant=<variantId> with opt.<optionId>=<valueId> params."
|
|
2000
|
+
);
|
|
2001
|
+
}
|
|
2002
|
+
for (const option of matrix.options) {
|
|
2003
|
+
knownSelectionKeys.add(slugLike(option.slug));
|
|
2004
|
+
knownSelectionKeys.add(slugLike(option.title));
|
|
2005
|
+
for (const value of option.values) {
|
|
2006
|
+
if (value.slug) knownSelectionKeys.add(slugLike(value.slug));
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
for (const [key, value] of params.entries()) {
|
|
2010
|
+
if (key.startsWith("opt.")) {
|
|
2011
|
+
const optionToken = key.slice(4);
|
|
2012
|
+
if (!optionToken || !matrix.optionBySlug.has(optionToken) && !matrix.optionById.has(optionToken)) {
|
|
2013
|
+
throw new ProductSelectionCodecError(
|
|
2014
|
+
`Unknown product selection query parameter "${key}". Use opt.<optionId>=<valueId>.`
|
|
2015
|
+
);
|
|
2016
|
+
}
|
|
2017
|
+
if (!value) {
|
|
2018
|
+
throw new ProductSelectionCodecError(
|
|
2019
|
+
`Product selection query parameter "${key}" requires a value ID or compatibility value slug.`
|
|
2020
|
+
);
|
|
2021
|
+
}
|
|
2022
|
+
continue;
|
|
2023
|
+
}
|
|
2024
|
+
if (key === "variant") {
|
|
2025
|
+
if (!value) {
|
|
2026
|
+
throw new ProductSelectionCodecError(
|
|
2027
|
+
'Product selection query parameter "variant" requires a variant ID.'
|
|
2028
|
+
);
|
|
2029
|
+
}
|
|
2030
|
+
if (!getVariantSelection(matrix, value)) {
|
|
2031
|
+
throw new ProductSelectionCodecError(
|
|
2032
|
+
`Unknown product selection variant "${value}".`
|
|
2033
|
+
);
|
|
2034
|
+
}
|
|
2035
|
+
continue;
|
|
2036
|
+
}
|
|
2037
|
+
const keyToken = slugLike(key);
|
|
2038
|
+
if (knownSelectionKeys.has(keyToken) || value === "" && knownSelectionKeys.has(keyToken)) {
|
|
2039
|
+
throw new ProductSelectionCodecError(
|
|
2040
|
+
`Ambiguous product selection query parameter "${key}". Use opt.<optionId>=<valueId>.`
|
|
2041
|
+
);
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
function emitCompatibilityOptionIdParam(options, event) {
|
|
2046
|
+
try {
|
|
2047
|
+
if (options?.onCompatibilityOptionIdParam) {
|
|
2048
|
+
options.onCompatibilityOptionIdParam(event);
|
|
2049
|
+
return;
|
|
2050
|
+
}
|
|
2051
|
+
options?.onLegacyOptionIdParam?.(event);
|
|
2052
|
+
} catch {
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
function assignSearchSelection(matrix, selectedByOptionId, search, options) {
|
|
2056
|
+
if (!search) return null;
|
|
2057
|
+
const params = toSearchParams(search);
|
|
2058
|
+
assertNoAmbiguousSelectionParams(matrix, params);
|
|
2059
|
+
const variantParam = params.get("variant");
|
|
2060
|
+
if (variantParam != null) {
|
|
2061
|
+
const variantSelection = getVariantSelection(matrix, variantParam);
|
|
2062
|
+
if (!variantSelection) {
|
|
2063
|
+
throw new ProductSelectionCodecError(
|
|
2064
|
+
`Unknown product selection variant "${variantParam}".`
|
|
2065
|
+
);
|
|
2066
|
+
}
|
|
2067
|
+
for (const [optionId, valueId] of variantSelection.optionValueByOptionId) {
|
|
2068
|
+
selectedByOptionId.set(optionId, valueId);
|
|
2069
|
+
}
|
|
2070
|
+
return variantSelection.id;
|
|
2071
|
+
}
|
|
2072
|
+
for (const [key, valueToken] of params.entries()) {
|
|
2073
|
+
if (!key.startsWith("opt.")) continue;
|
|
2074
|
+
const optionToken = key.slice(4);
|
|
2075
|
+
const optionById = matrix.optionById.get(optionToken);
|
|
2076
|
+
if (optionById) {
|
|
2077
|
+
if (assignSelectedValue(
|
|
2078
|
+
matrix,
|
|
2079
|
+
selectedByOptionId,
|
|
2080
|
+
optionById.id,
|
|
2081
|
+
valueToken
|
|
2082
|
+
)) {
|
|
2083
|
+
continue;
|
|
2084
|
+
}
|
|
2085
|
+
const before = selectedByOptionId.get(optionById.id);
|
|
2086
|
+
if (assignSelectedValueSlugByOptionId(
|
|
2087
|
+
matrix,
|
|
2088
|
+
selectedByOptionId,
|
|
2089
|
+
optionById.id,
|
|
2090
|
+
valueToken
|
|
2091
|
+
) && selectedByOptionId.get(optionById.id) !== before) {
|
|
2092
|
+
emitCompatibilityOptionIdParam(options, {
|
|
2093
|
+
optionId: optionById.id,
|
|
2094
|
+
optionSlug: optionById.slug,
|
|
2095
|
+
valueSlug: valueToken,
|
|
2096
|
+
searchParam: key
|
|
2097
|
+
});
|
|
2098
|
+
continue;
|
|
2099
|
+
}
|
|
2100
|
+
throw new ProductSelectionCodecError(
|
|
2101
|
+
`Unknown product selection value "${valueToken}" for option "${optionToken}". Use opt.<optionId>=<valueId>.`
|
|
2102
|
+
);
|
|
2103
|
+
}
|
|
2104
|
+
const optionBySlug = matrix.optionBySlug.get(optionToken);
|
|
2105
|
+
if (optionBySlug) {
|
|
2106
|
+
if (assignSelectedValueSlugByOptionSlug(
|
|
2107
|
+
matrix,
|
|
2108
|
+
selectedByOptionId,
|
|
2109
|
+
optionBySlug.slug,
|
|
2110
|
+
valueToken
|
|
2111
|
+
)) {
|
|
2112
|
+
continue;
|
|
2113
|
+
}
|
|
2114
|
+
if (matrix.valueById.has(valueToken)) {
|
|
2115
|
+
throw new ProductSelectionCodecError(
|
|
2116
|
+
`Unknown product selection value "${valueToken}" for option "${optionToken}". Use opt.<optionId>=<valueId>.`
|
|
2117
|
+
);
|
|
2118
|
+
}
|
|
2119
|
+
throw new ProductSelectionCodecError(
|
|
2120
|
+
`Unknown product selection value "${valueToken}" for option "${optionToken}". Use opt.<optionSlug>=<valueSlug> for compatibility URLs.`
|
|
2121
|
+
);
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
return null;
|
|
2125
|
+
}
|
|
2126
|
+
function normalizeProductSelectionFromMatrix(matrix, selection = {}, options) {
|
|
2127
|
+
const selectedByOptionId = /* @__PURE__ */ new Map();
|
|
2128
|
+
const variantSelection = getVariantSelection(matrix, selection.variantId);
|
|
2129
|
+
const variantId = variantSelection?.id ?? null;
|
|
2130
|
+
if (variantSelection) {
|
|
2131
|
+
for (const [optionId, valueId] of variantSelection.optionValueByOptionId) {
|
|
2132
|
+
selectedByOptionId.set(optionId, valueId);
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
for (const rawValueId of selection.valueIds ?? []) {
|
|
2136
|
+
const valueId = getRelationID(rawValueId);
|
|
2137
|
+
if (!valueId) continue;
|
|
2138
|
+
const optionId = matrix.valueToOptionId.get(valueId);
|
|
2139
|
+
if (!optionId) continue;
|
|
2140
|
+
selectedByOptionId.set(optionId, valueId);
|
|
2141
|
+
}
|
|
2142
|
+
const searchVariantId = assignSearchSelection(
|
|
2143
|
+
matrix,
|
|
2144
|
+
selectedByOptionId,
|
|
2145
|
+
selection.search,
|
|
2146
|
+
options
|
|
2147
|
+
);
|
|
2148
|
+
for (const [rawOptionId, rawSelection] of Object.entries(
|
|
2149
|
+
selection.byOptionId ?? {}
|
|
2150
|
+
)) {
|
|
2151
|
+
const optionId = String(rawOptionId);
|
|
2152
|
+
if (!matrix.optionById.has(optionId)) continue;
|
|
2153
|
+
if (rawSelection && typeof rawSelection === "object" && "valueId" in rawSelection && rawSelection.valueId != null) {
|
|
2154
|
+
assignSelectedValue(
|
|
2155
|
+
matrix,
|
|
2156
|
+
selectedByOptionId,
|
|
2157
|
+
optionId,
|
|
2158
|
+
rawSelection.valueId
|
|
2159
|
+
);
|
|
2160
|
+
continue;
|
|
2161
|
+
}
|
|
2162
|
+
if (typeof rawSelection === "string" || typeof rawSelection === "number") {
|
|
2163
|
+
assignSelectedValue(matrix, selectedByOptionId, optionId, rawSelection);
|
|
2164
|
+
continue;
|
|
2165
|
+
}
|
|
2166
|
+
if (rawSelection && typeof rawSelection === "object" && "valueSlug" in rawSelection) {
|
|
2167
|
+
assignSelectedValueSlugByOptionId(
|
|
2168
|
+
matrix,
|
|
2169
|
+
selectedByOptionId,
|
|
2170
|
+
optionId,
|
|
2171
|
+
rawSelection.valueSlug
|
|
2172
|
+
);
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
for (const [rawOptionSlug, rawSelection] of Object.entries(
|
|
2176
|
+
selection.byOptionSlug ?? {}
|
|
2177
|
+
)) {
|
|
2178
|
+
const optionSlug = String(rawOptionSlug);
|
|
2179
|
+
if (!matrix.optionBySlug.has(optionSlug)) continue;
|
|
2180
|
+
if (rawSelection && typeof rawSelection === "object" && "valueId" in rawSelection && rawSelection.valueId != null) {
|
|
2181
|
+
const option = matrix.optionBySlug.get(optionSlug);
|
|
2182
|
+
if (option) {
|
|
2183
|
+
assignSelectedValue(
|
|
2184
|
+
matrix,
|
|
2185
|
+
selectedByOptionId,
|
|
2186
|
+
option.id,
|
|
2187
|
+
rawSelection.valueId
|
|
2188
|
+
);
|
|
2189
|
+
}
|
|
2190
|
+
continue;
|
|
2191
|
+
}
|
|
2192
|
+
if (rawSelection && typeof rawSelection === "object" && "valueSlug" in rawSelection) {
|
|
2193
|
+
assignSelectedValueSlugByOptionSlug(
|
|
2194
|
+
matrix,
|
|
2195
|
+
selectedByOptionId,
|
|
2196
|
+
optionSlug,
|
|
2197
|
+
rawSelection.valueSlug
|
|
2198
|
+
);
|
|
2199
|
+
continue;
|
|
2200
|
+
}
|
|
2201
|
+
if (typeof rawSelection === "string" || typeof rawSelection === "number") {
|
|
2202
|
+
assignSelectedValueSlugByOptionSlug(
|
|
2203
|
+
matrix,
|
|
2204
|
+
selectedByOptionId,
|
|
2205
|
+
optionSlug,
|
|
2206
|
+
String(rawSelection)
|
|
2207
|
+
);
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
const byOptionId = Object.fromEntries(
|
|
2211
|
+
matrix.optionIds.map((optionId) => [optionId, selectedByOptionId.get(optionId)]).filter((entry) => Boolean(entry[1]))
|
|
2212
|
+
);
|
|
2213
|
+
const byOptionSlug = Object.fromEntries(
|
|
2214
|
+
matrix.options.map((option) => {
|
|
2215
|
+
const valueId = selectedByOptionId.get(option.id);
|
|
2216
|
+
const value = valueId ? matrix.valueById.get(valueId) : void 0;
|
|
2217
|
+
return [option.slug, value?.slug ?? void 0];
|
|
2218
|
+
}).filter((entry) => Boolean(entry[1]))
|
|
2219
|
+
);
|
|
2220
|
+
return {
|
|
2221
|
+
byOptionSlug,
|
|
2222
|
+
byOptionId,
|
|
2223
|
+
valueIds: matrix.optionIds.map((optionId) => byOptionId[optionId]).filter((valueId) => Boolean(valueId)),
|
|
2224
|
+
variantId: searchVariantId ?? variantId
|
|
2225
|
+
};
|
|
2226
|
+
}
|
|
2227
|
+
function stringifyProductSelection(detail, selection = {}, options) {
|
|
2228
|
+
const matrix = buildProductOptionMatrixFromDetail(detail);
|
|
2229
|
+
const normalized = normalizeProductSelectionFromMatrix(
|
|
2230
|
+
matrix,
|
|
2231
|
+
selection,
|
|
2232
|
+
options
|
|
2233
|
+
);
|
|
2234
|
+
const params = new URLSearchParams();
|
|
2235
|
+
if (hasExplicitSelection(selection)) {
|
|
2236
|
+
const matchingVariants = getMatchingVariantEntries(matrix, normalized);
|
|
2237
|
+
const exactVariant = getExactSelectedVariantEntry(
|
|
2238
|
+
matrix,
|
|
2239
|
+
normalized,
|
|
2240
|
+
matchingVariants
|
|
2241
|
+
);
|
|
2242
|
+
if (exactVariant) {
|
|
2243
|
+
params.set("variant", exactVariant.id);
|
|
2244
|
+
return params.toString();
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
const emit = resolveProductSelectionUrlEmit(options?.emit);
|
|
2248
|
+
for (const optionId of matrix.optionIds) {
|
|
2249
|
+
const valueId = normalized.byOptionId[optionId];
|
|
2250
|
+
if (!valueId) continue;
|
|
2251
|
+
if (!matrix.optionById.has(optionId) || !matrix.valueById.has(valueId)) {
|
|
2252
|
+
continue;
|
|
2253
|
+
}
|
|
2254
|
+
if (emit === "slug-compat") {
|
|
2255
|
+
if (appendSlugCompatSelectionParam(params, matrix, optionId, valueId)) {
|
|
2256
|
+
continue;
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
appendCanonicalSelectionParam(params, optionId, valueId);
|
|
2260
|
+
}
|
|
2261
|
+
return params.toString();
|
|
2262
|
+
}
|
|
2263
|
+
function selectedEntries(selection) {
|
|
2264
|
+
return Object.entries(selection.byOptionId);
|
|
2265
|
+
}
|
|
2266
|
+
function getMatchingVariantEntries(matrix, selection) {
|
|
2267
|
+
const entries = selectedEntries(selection);
|
|
2268
|
+
if (entries.length === 0) return matrix.variants;
|
|
2269
|
+
return matrix.variants.filter(
|
|
2270
|
+
(variant) => entries.every(
|
|
2271
|
+
([optionId, valueId]) => variant.optionValueByOptionId.get(optionId) === valueId
|
|
2272
|
+
)
|
|
2273
|
+
);
|
|
2274
|
+
}
|
|
2275
|
+
function getExactSelectedVariantEntry(matrix, selection, matchingVariants) {
|
|
2276
|
+
if (matrix.optionIds.length === 0) {
|
|
2277
|
+
return getVariantSelection(matrix, selection.variantId) ?? (matchingVariants.length === 1 ? matchingVariants[0] ?? null : null);
|
|
2278
|
+
}
|
|
2279
|
+
const allOptionsSelected = matrix.optionIds.every(
|
|
2280
|
+
(optionId) => Boolean(selection.byOptionId[optionId])
|
|
2281
|
+
);
|
|
2282
|
+
if (!allOptionsSelected) return null;
|
|
2283
|
+
return matchingVariants.find(
|
|
2284
|
+
(variant) => matrix.optionIds.every(
|
|
2285
|
+
(optionId) => variant.optionValueByOptionId.get(optionId) === selection.byOptionId[optionId]
|
|
2286
|
+
)
|
|
2287
|
+
) ?? null;
|
|
2288
|
+
}
|
|
2289
|
+
function isPresentMedia(value) {
|
|
2290
|
+
return value != null;
|
|
2291
|
+
}
|
|
2292
|
+
function mediaArray2(values) {
|
|
2293
|
+
if (!Array.isArray(values)) return [];
|
|
2294
|
+
return values.filter(isPresentMedia);
|
|
2295
|
+
}
|
|
2296
|
+
function getProductHrefSlug(product) {
|
|
2297
|
+
if ("product" in product && product.product?.slug) {
|
|
2298
|
+
return product.product.slug;
|
|
2299
|
+
}
|
|
2300
|
+
if ("slug" in product && product.slug) return product.slug;
|
|
2301
|
+
throw new ProductSelectionCodecError(
|
|
2302
|
+
"Product slug is required to build a product href."
|
|
2303
|
+
);
|
|
2304
|
+
}
|
|
2305
|
+
function joinProductPath(basePath, slug, trailingSlash) {
|
|
2306
|
+
const base = basePath.replace(/\/+$/, "");
|
|
2307
|
+
const encodedSlug = encodeURIComponent(slug);
|
|
2308
|
+
return `${base}/${encodedSlug}${trailingSlash ? "/" : ""}`;
|
|
2309
|
+
}
|
|
2310
|
+
function getProductHrefGroupSelection(group, matrix) {
|
|
2311
|
+
if (!group) return null;
|
|
2312
|
+
if (group.variantId != null) return { variantId: group.variantId };
|
|
2313
|
+
const optionId = group.optionId != null ? String(group.optionId) : group.optionSlug ? matrix?.optionBySlug.get(group.optionSlug)?.id : void 0;
|
|
2314
|
+
if (!optionId) return null;
|
|
2315
|
+
const option = matrix?.optionById.get(optionId);
|
|
2316
|
+
const optionValueId = group.optionValueId != null ? String(group.optionValueId) : group.optionValueSlug && option ? option.values.find((value) => value.slug === group.optionValueSlug)?.id : void 0;
|
|
2317
|
+
if (!optionValueId) return null;
|
|
2318
|
+
return { byOptionId: { [optionId]: optionValueId } };
|
|
2319
|
+
}
|
|
2320
|
+
function getProductHrefCodecOptions(options) {
|
|
2321
|
+
return options.emit != null ? { emit: options.emit } : void 0;
|
|
2322
|
+
}
|
|
2323
|
+
function appendGroupByOptionIdHrefParams(params, group, groupSelection, options) {
|
|
2324
|
+
const emit = resolveProductSelectionUrlEmit(options.emit);
|
|
2325
|
+
const byOptionId = groupSelection.byOptionId ?? {};
|
|
2326
|
+
const entries = Object.entries(byOptionId);
|
|
2327
|
+
if (entries.length === 0) return false;
|
|
2328
|
+
for (const [optionId, valueId] of entries) {
|
|
2329
|
+
const optionSlug = group?.optionSlug ?? options.matrix?.optionById.get(optionId)?.slug ?? null;
|
|
2330
|
+
const valueSlug = group?.optionValueSlug ?? options.matrix?.valueById.get(String(valueId))?.slug ?? null;
|
|
2331
|
+
if (emit === "slug-compat" && optionSlug && valueSlug && entries.length === 1) {
|
|
2332
|
+
params.set(`opt.${optionSlug}`, valueSlug);
|
|
2333
|
+
return true;
|
|
2334
|
+
}
|
|
2335
|
+
if (emit === "slug-compat" && options.matrix && appendSlugCompatSelectionParam(
|
|
2336
|
+
params,
|
|
2337
|
+
options.matrix,
|
|
2338
|
+
optionId,
|
|
2339
|
+
String(valueId)
|
|
2340
|
+
)) {
|
|
2341
|
+
continue;
|
|
2342
|
+
}
|
|
2343
|
+
appendCanonicalSelectionParam(params, optionId, String(valueId));
|
|
2344
|
+
}
|
|
2345
|
+
return params.size > 0;
|
|
2346
|
+
}
|
|
2347
|
+
function getPreferCompleteVariantFromHintSelection(group, options) {
|
|
2348
|
+
if (!options.preferCompleteVariantFromHint) return null;
|
|
2349
|
+
if (group?.optionValueId != null || group?.optionValueSlug) return null;
|
|
2350
|
+
const hintVariantId = group?.listing?.selectionHintVariant;
|
|
2351
|
+
if (hintVariantId == null) return null;
|
|
2352
|
+
return { variantId: hintVariantId };
|
|
2353
|
+
}
|
|
2354
|
+
function buildProductHref(product, group, options = {}) {
|
|
2355
|
+
const path = joinProductPath(
|
|
2356
|
+
options.basePath ?? "/products",
|
|
2357
|
+
getProductHrefSlug(product),
|
|
2358
|
+
options.trailingSlash ?? false
|
|
2359
|
+
);
|
|
2360
|
+
const params = new URLSearchParams();
|
|
2361
|
+
if (options.detail && options.selection) {
|
|
2362
|
+
const selection = stringifyProductSelection(
|
|
2363
|
+
options.detail,
|
|
2364
|
+
options.selection,
|
|
2365
|
+
getProductHrefCodecOptions(options)
|
|
2366
|
+
);
|
|
2367
|
+
return selection ? `${path}?${selection}` : path;
|
|
2368
|
+
}
|
|
2369
|
+
const preferVariantSelection = getPreferCompleteVariantFromHintSelection(
|
|
2370
|
+
group,
|
|
2371
|
+
options
|
|
2372
|
+
);
|
|
2373
|
+
if (preferVariantSelection) {
|
|
2374
|
+
if (options.detail) {
|
|
2375
|
+
const selection = stringifyProductSelection(
|
|
2376
|
+
options.detail,
|
|
2377
|
+
preferVariantSelection,
|
|
2378
|
+
getProductHrefCodecOptions(options)
|
|
2379
|
+
);
|
|
2380
|
+
return selection ? `${path}?${selection}` : path;
|
|
2381
|
+
}
|
|
2382
|
+
if (preferVariantSelection.variantId != null) {
|
|
2383
|
+
params.set("variant", String(preferVariantSelection.variantId));
|
|
2384
|
+
return `${path}?${params.toString()}`;
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
const groupSelection = getProductHrefGroupSelection(group, options.matrix);
|
|
2388
|
+
if (groupSelection) {
|
|
2389
|
+
if (options.detail) {
|
|
2390
|
+
const selection = stringifyProductSelection(
|
|
2391
|
+
options.detail,
|
|
2392
|
+
groupSelection,
|
|
2393
|
+
getProductHrefCodecOptions(options)
|
|
2394
|
+
);
|
|
2395
|
+
return selection ? `${path}?${selection}` : path;
|
|
2396
|
+
}
|
|
2397
|
+
if (groupSelection.variantId != null) {
|
|
2398
|
+
params.set("variant", String(groupSelection.variantId));
|
|
2399
|
+
return `${path}?${params.toString()}`;
|
|
2400
|
+
}
|
|
2401
|
+
if (appendGroupByOptionIdHrefParams(params, group, groupSelection, options)) {
|
|
2402
|
+
return `${path}?${params.toString()}`;
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
if (group?.optionValueSlug) {
|
|
2406
|
+
const optionSlug = group.optionSlug ?? (group.optionId != null ? options.matrix?.optionById.get(String(group.optionId))?.slug : void 0);
|
|
2407
|
+
if (optionSlug) {
|
|
2408
|
+
params.set(`opt.${optionSlug}`, group.optionValueSlug);
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
return params.size > 0 ? `${path}?${params.toString()}` : path;
|
|
2412
|
+
}
|
|
2413
|
+
function compareVariantOrder(a, b) {
|
|
2414
|
+
const aOrder = Number(a._order ?? Number.MAX_SAFE_INTEGER);
|
|
2415
|
+
const bOrder = Number(b._order ?? Number.MAX_SAFE_INTEGER);
|
|
2416
|
+
if (Number.isFinite(aOrder) && Number.isFinite(bOrder) && aOrder !== bOrder) {
|
|
2417
|
+
return aOrder - bOrder;
|
|
2418
|
+
}
|
|
2419
|
+
const aId = String(getRelationID(a.id) ?? "");
|
|
2420
|
+
const bId = String(getRelationID(b.id) ?? "");
|
|
2421
|
+
return aId.localeCompare(bId);
|
|
2422
|
+
}
|
|
2423
|
+
function isVariantAvailableForSale(variant) {
|
|
2424
|
+
if (variant.isActive === false) return false;
|
|
2425
|
+
if (variant.isUnlimited) return true;
|
|
2426
|
+
return (variant.stock ?? 0) - (variant.reservedStock ?? 0) > 0;
|
|
2427
|
+
}
|
|
2428
|
+
function sortVariantsForMediaSelection(variants) {
|
|
2429
|
+
const orderedVariants = [...variants].sort(compareVariantOrder);
|
|
2430
|
+
const activeVariants = orderedVariants.filter(
|
|
2431
|
+
(variant) => variant.isActive !== false
|
|
2432
|
+
);
|
|
2433
|
+
const availableVariants = activeVariants.filter(isVariantAvailableForSale);
|
|
2434
|
+
const unavailableActiveVariants = activeVariants.filter(
|
|
2435
|
+
(variant) => !isVariantAvailableForSale(variant)
|
|
2436
|
+
);
|
|
2437
|
+
return [...availableVariants, ...unavailableActiveVariants];
|
|
2438
|
+
}
|
|
2439
|
+
function variantHasPoolMedia(variant, productMediaPool) {
|
|
2440
|
+
if (!variant?.images?.length) return false;
|
|
2441
|
+
return variant.images.some((image) => {
|
|
2442
|
+
const imageId = getRelationID(image);
|
|
2443
|
+
return Boolean(
|
|
2444
|
+
imageId && productMediaPool.some((poolItem) => getRelationID(poolItem) === imageId)
|
|
2445
|
+
);
|
|
2446
|
+
});
|
|
2447
|
+
}
|
|
2448
|
+
function getMinMax(values) {
|
|
2449
|
+
const numbers = values.filter(
|
|
2450
|
+
(value) => typeof value === "number"
|
|
2451
|
+
);
|
|
2452
|
+
if (numbers.length === 0) {
|
|
2453
|
+
return { min: null, max: null };
|
|
2454
|
+
}
|
|
2455
|
+
return {
|
|
2456
|
+
min: Math.min(...numbers),
|
|
2457
|
+
max: Math.max(...numbers)
|
|
2458
|
+
};
|
|
2459
|
+
}
|
|
2460
|
+
function buildProductListingGroupProjection(product, variants) {
|
|
2461
|
+
const orderedVariants = [...variants].sort(compareVariantOrder);
|
|
2462
|
+
const activeVariants = orderedVariants.filter(
|
|
2463
|
+
(variant) => variant.isActive !== false
|
|
2464
|
+
);
|
|
2465
|
+
const availableVariants = activeVariants.filter(isVariantAvailableForSale);
|
|
2466
|
+
const selectionHintVariant = availableVariants[0] ?? activeVariants[0] ?? null;
|
|
2467
|
+
const { min: minPrice, max: maxPrice } = getMinMax(
|
|
2468
|
+
activeVariants.map((variant) => variant.price)
|
|
2469
|
+
);
|
|
2470
|
+
const { min: minCompareAtPrice, max: maxCompareAtPrice } = getMinMax(
|
|
2471
|
+
activeVariants.map((variant) => variant.compareAtPrice)
|
|
2472
|
+
);
|
|
2473
|
+
const productMediaPool = product?.images ?? [];
|
|
2474
|
+
const selectionHintHasPoolMedia = variantHasPoolMedia(
|
|
2475
|
+
selectionHintVariant,
|
|
2476
|
+
productMediaPool
|
|
2477
|
+
);
|
|
2478
|
+
const mediaSelectionVariants = sortVariantsForMediaSelection(variants);
|
|
2479
|
+
const resolvedProductMedia = resolveProductSelectionMedia({
|
|
2480
|
+
productMediaPool,
|
|
2481
|
+
selectedVariant: selectionHintVariant && selectionHintHasPoolMedia ? {
|
|
2482
|
+
id: selectionHintVariant.id,
|
|
2483
|
+
images: selectionHintVariant.images
|
|
2484
|
+
} : null,
|
|
2485
|
+
matchingVariants: selectionHintHasPoolMedia ? [] : mediaSelectionVariants
|
|
2486
|
+
});
|
|
2487
|
+
return {
|
|
2488
|
+
selectionHintVariant: getRelationID(selectionHintVariant?.id) ?? null,
|
|
2489
|
+
primaryImage: resolveGenericListingPrimaryImage(
|
|
2490
|
+
product,
|
|
2491
|
+
resolvedProductMedia.primaryImage,
|
|
2492
|
+
resolvedProductMedia.source
|
|
2493
|
+
),
|
|
2494
|
+
minPrice,
|
|
2495
|
+
maxPrice,
|
|
2496
|
+
minCompareAtPrice,
|
|
2497
|
+
maxCompareAtPrice,
|
|
2498
|
+
isPriceRange: minPrice !== null && maxPrice !== null ? minPrice !== maxPrice : false,
|
|
2499
|
+
availableForSale: availableVariants.length > 0
|
|
2500
|
+
};
|
|
2501
|
+
}
|
|
2502
|
+
function buildProductListingCard(item, options = {}) {
|
|
2503
|
+
const product = item.product;
|
|
2504
|
+
const groups = item.groups;
|
|
2505
|
+
const variants = getProductListingCardVariants(item);
|
|
2506
|
+
const projectedListing = buildProductListingGroupProjection(product, variants);
|
|
2507
|
+
const selectionHintVariant = getRelationID(product.selectedOrFirstAvailableVariant) ?? projectedListing.selectionHintVariant;
|
|
2508
|
+
const representativeVariant = findListingCardRepresentativeVariant(
|
|
2509
|
+
variants,
|
|
2510
|
+
selectionHintVariant
|
|
2511
|
+
);
|
|
2512
|
+
const productMediaPool = mediaArray2(product.images);
|
|
2513
|
+
const featuredImageId = getRelationID(product.featuredImage);
|
|
2514
|
+
const featuredImageFromPool = featuredImageId ? productMediaPool.find((item2) => getRelationID(item2) === featuredImageId) : void 0;
|
|
2515
|
+
const listingPrimaryMedia = featuredImageFromPool ?? product.featuredImage ?? productMediaPool[0] ?? null;
|
|
2516
|
+
const priceRange = resolveListingCardPriceRange(
|
|
2517
|
+
product,
|
|
2518
|
+
projectedListing,
|
|
2519
|
+
groups
|
|
2520
|
+
);
|
|
2521
|
+
const availableForSale = product.availableForSale != null ? product.availableForSale : groups.length > 0 ? groups.some((group) => group.listing.availableForSale) : projectedListing.availableForSale;
|
|
2522
|
+
const swatches = groups.length > 1 ? groups.map((group) => buildListingSwatch(product, group, options)) : [];
|
|
2523
|
+
return {
|
|
2524
|
+
id: String(product.id),
|
|
2525
|
+
href: buildProductHref(
|
|
2526
|
+
{ slug: product.slug },
|
|
2527
|
+
{ listing: { selectionHintVariant } },
|
|
2528
|
+
options
|
|
2529
|
+
),
|
|
2530
|
+
title: product.title,
|
|
2531
|
+
representativeVariant,
|
|
2532
|
+
primaryImage: listingPrimaryMedia,
|
|
2533
|
+
priceRange,
|
|
2534
|
+
availableForSale,
|
|
2535
|
+
swatches
|
|
2536
|
+
};
|
|
2537
|
+
}
|
|
2538
|
+
function getProductListingCardVariants(item) {
|
|
2539
|
+
const productVariants = item.product.variants?.docs;
|
|
2540
|
+
if (Array.isArray(productVariants) && productVariants.length > 0) {
|
|
2541
|
+
return productVariants;
|
|
2542
|
+
}
|
|
2543
|
+
const variants = [];
|
|
2544
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2545
|
+
for (const group of item.groups) {
|
|
2546
|
+
for (const variant of group.variants) {
|
|
2547
|
+
const id = getRelationID(variant.id);
|
|
2548
|
+
if (id && seen.has(id)) continue;
|
|
2549
|
+
if (id) seen.add(id);
|
|
2550
|
+
variants.push(variant);
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
return variants;
|
|
2554
|
+
}
|
|
2555
|
+
function findListingCardRepresentativeVariant(variants, representativeVariantId) {
|
|
2556
|
+
if (representativeVariantId == null) return null;
|
|
2557
|
+
return variants.find(
|
|
2558
|
+
(variant) => getRelationID(variant.id) === representativeVariantId
|
|
2559
|
+
) ?? null;
|
|
2560
|
+
}
|
|
2561
|
+
function hasCompleteProductPriceRange(priceRange) {
|
|
2562
|
+
return priceRange?.minVariantPrice?.amount != null && priceRange?.maxVariantPrice?.amount != null;
|
|
2563
|
+
}
|
|
2564
|
+
function resolveListingCardPriceRange(product, projectedListing, groups) {
|
|
2565
|
+
if (hasCompleteProductPriceRange(product.priceRange)) {
|
|
2566
|
+
const groupRange = groups.length > 0 ? aggregateListingPriceRange(groups) : null;
|
|
2567
|
+
const minCompareAtPrice = product.compareAtPriceRange?.minVariantPrice?.amount ?? groupRange?.minCompareAtPrice ?? null;
|
|
2568
|
+
const maxCompareAtPrice = product.compareAtPriceRange?.maxVariantPrice?.amount ?? groupRange?.maxCompareAtPrice ?? null;
|
|
2569
|
+
return {
|
|
2570
|
+
minPrice: product.priceRange.minVariantPrice.amount,
|
|
2571
|
+
maxPrice: product.priceRange.maxVariantPrice.amount,
|
|
2572
|
+
minCompareAtPrice,
|
|
2573
|
+
maxCompareAtPrice,
|
|
2574
|
+
isPriceRange: product.priceRange.isPriceRange ?? product.priceRange.minVariantPrice.amount !== product.priceRange.maxVariantPrice.amount
|
|
2575
|
+
};
|
|
2576
|
+
}
|
|
2577
|
+
if (groups.length > 0) {
|
|
2578
|
+
return aggregateListingPriceRange(groups);
|
|
2579
|
+
}
|
|
2580
|
+
return {
|
|
2581
|
+
minPrice: projectedListing.minPrice,
|
|
2582
|
+
maxPrice: projectedListing.maxPrice,
|
|
2583
|
+
minCompareAtPrice: projectedListing.minCompareAtPrice,
|
|
2584
|
+
maxCompareAtPrice: projectedListing.maxCompareAtPrice,
|
|
2585
|
+
isPriceRange: projectedListing.isPriceRange
|
|
2586
|
+
};
|
|
2587
|
+
}
|
|
2588
|
+
function aggregateListingPriceRange(groups) {
|
|
2589
|
+
const minPrice = minOfNullable(groups.map((g) => g.listing.minPrice));
|
|
2590
|
+
const maxPrice = maxOfNullable(groups.map((g) => g.listing.maxPrice));
|
|
2591
|
+
const minCompareAtPrice = minOfNullable(
|
|
2592
|
+
groups.map((g) => g.listing.minCompareAtPrice)
|
|
2593
|
+
);
|
|
2594
|
+
const maxCompareAtPrice = maxOfNullable(
|
|
2595
|
+
groups.map((g) => g.listing.maxCompareAtPrice)
|
|
2596
|
+
);
|
|
2597
|
+
const isPriceRange = minPrice !== null && maxPrice !== null && minPrice !== maxPrice;
|
|
2598
|
+
return {
|
|
2599
|
+
minPrice,
|
|
2600
|
+
maxPrice,
|
|
2601
|
+
minCompareAtPrice,
|
|
2602
|
+
maxCompareAtPrice,
|
|
2603
|
+
isPriceRange
|
|
2604
|
+
};
|
|
2605
|
+
}
|
|
2606
|
+
function buildListingSwatch(product, group, options) {
|
|
2607
|
+
return {
|
|
2608
|
+
optionId: group.optionId,
|
|
2609
|
+
optionValueId: group.optionValueId,
|
|
2610
|
+
label: group.optionValueLabel,
|
|
2611
|
+
swatch: group.optionValueSwatch ?? null,
|
|
2612
|
+
href: buildProductHref(
|
|
2613
|
+
{ slug: product.slug },
|
|
2614
|
+
{
|
|
2615
|
+
optionId: group.optionId,
|
|
2616
|
+
optionSlug: group.optionSlug,
|
|
2617
|
+
optionValueId: group.optionValueId,
|
|
2618
|
+
optionValueSlug: group.optionValueSlug,
|
|
2619
|
+
listing: group.listing
|
|
2620
|
+
},
|
|
2621
|
+
options
|
|
2622
|
+
),
|
|
2623
|
+
availableForSale: group.listing.availableForSale
|
|
2624
|
+
};
|
|
2625
|
+
}
|
|
2626
|
+
function minOfNullable(values) {
|
|
2627
|
+
const numbers = values.filter((v) => v !== null);
|
|
2628
|
+
return numbers.length === 0 ? null : Math.min(...numbers);
|
|
2629
|
+
}
|
|
2630
|
+
function maxOfNullable(values) {
|
|
2631
|
+
const numbers = values.filter((v) => v !== null);
|
|
2632
|
+
return numbers.length === 0 ? null : Math.max(...numbers);
|
|
2633
|
+
}
|
|
2634
|
+
|
|
1596
2635
|
// src/core/api/product-api.ts
|
|
1597
2636
|
var PRODUCT_DETAIL_UNAVAILABLE_REASONS = /* @__PURE__ */ new Set([
|
|
1598
2637
|
"not_found",
|
|
@@ -1616,13 +2655,75 @@ function productDetailResultFromError(error) {
|
|
|
1616
2655
|
if (!reason) return void 0;
|
|
1617
2656
|
return { found: false, reason };
|
|
1618
2657
|
}
|
|
2658
|
+
function nonEmpty(values) {
|
|
2659
|
+
return values?.length ? values : void 0;
|
|
2660
|
+
}
|
|
2661
|
+
function buildProductListingPageWhere(params) {
|
|
2662
|
+
const clauses = [];
|
|
2663
|
+
const search = params.search?.trim();
|
|
2664
|
+
if (search) {
|
|
2665
|
+
clauses.push({
|
|
2666
|
+
or: [
|
|
2667
|
+
{ title: { like: search } },
|
|
2668
|
+
{ slug: { like: search } },
|
|
2669
|
+
{ handle: { like: search } }
|
|
2670
|
+
]
|
|
2671
|
+
});
|
|
2672
|
+
}
|
|
2673
|
+
const filters = params.filters;
|
|
2674
|
+
const ids = nonEmpty(filters?.ids);
|
|
2675
|
+
if (ids) clauses.push({ id: { in: ids } });
|
|
2676
|
+
const slugs = nonEmpty(filters?.slugs);
|
|
2677
|
+
if (slugs) clauses.push({ slug: { in: slugs } });
|
|
2678
|
+
const handles = nonEmpty(filters?.handles);
|
|
2679
|
+
if (handles) clauses.push({ handle: { in: handles } });
|
|
2680
|
+
const categoryIds = nonEmpty(filters?.categoryIds);
|
|
2681
|
+
if (categoryIds) clauses.push({ categories: { in: categoryIds } });
|
|
2682
|
+
const tagIds = nonEmpty(filters?.tagIds);
|
|
2683
|
+
if (tagIds) clauses.push({ tags: { in: tagIds } });
|
|
2684
|
+
const minPrice = filters?.price?.min;
|
|
2685
|
+
if (minPrice != null) {
|
|
2686
|
+
clauses.push({
|
|
2687
|
+
"priceRange.maxVariantPrice.amount": { greater_than_equal: minPrice }
|
|
2688
|
+
});
|
|
2689
|
+
}
|
|
2690
|
+
const maxPrice = filters?.price?.max;
|
|
2691
|
+
if (maxPrice != null) {
|
|
2692
|
+
clauses.push({
|
|
2693
|
+
"priceRange.minVariantPrice.amount": { less_than_equal: maxPrice }
|
|
2694
|
+
});
|
|
2695
|
+
}
|
|
2696
|
+
if (filters?.availableForSale != null) {
|
|
2697
|
+
clauses.push({
|
|
2698
|
+
availableForSale: { equals: filters.availableForSale }
|
|
2699
|
+
});
|
|
2700
|
+
}
|
|
2701
|
+
if (clauses.length === 0) return void 0;
|
|
2702
|
+
if (clauses.length === 1) return clauses[0];
|
|
2703
|
+
return { and: clauses };
|
|
2704
|
+
}
|
|
2705
|
+
function buildProductListingPageUrl(params) {
|
|
2706
|
+
const options = {
|
|
2707
|
+
page: params.page,
|
|
2708
|
+
limit: params.limit,
|
|
2709
|
+
sort: params.sort,
|
|
2710
|
+
where: buildProductListingPageWhere(params)
|
|
2711
|
+
};
|
|
2712
|
+
return params.mode === "full" ? listingGroupsQueryUrl(options) : listingGroupsQueryCatalogUrl(options);
|
|
2713
|
+
}
|
|
2714
|
+
function withProductListingCards(response, options) {
|
|
2715
|
+
return {
|
|
2716
|
+
...response,
|
|
2717
|
+
cards: response.docs.map((item) => buildProductListingCard(item, options))
|
|
2718
|
+
};
|
|
2719
|
+
}
|
|
1619
2720
|
function rejectLegacyOptionValueSwatchColor(value) {
|
|
1620
2721
|
if (Object.prototype.hasOwnProperty.call(
|
|
1621
2722
|
value,
|
|
1622
2723
|
"swatchColor"
|
|
1623
2724
|
)) {
|
|
1624
2725
|
throw new TypeError(
|
|
1625
|
-
'Product upsert option values no longer accept
|
|
2726
|
+
'Product upsert option values no longer accept removed flat "swatchColor"; use nested "swatch" instead.'
|
|
1626
2727
|
);
|
|
1627
2728
|
}
|
|
1628
2729
|
}
|
|
@@ -1680,6 +2781,14 @@ var ProductApi = class extends BaseApi {
|
|
|
1680
2781
|
{ method: "GET" }
|
|
1681
2782
|
);
|
|
1682
2783
|
}
|
|
2784
|
+
async listingPage(params = {}) {
|
|
2785
|
+
if (params.mode === "full") {
|
|
2786
|
+
const response2 = await this.request(buildProductListingPageUrl(params), void 0, { method: "GET" });
|
|
2787
|
+
return withProductListingCards(response2, params);
|
|
2788
|
+
}
|
|
2789
|
+
const response = await this.request(buildProductListingPageUrl(params), void 0, { method: "GET" });
|
|
2790
|
+
return withProductListingCards(response, params);
|
|
2791
|
+
}
|
|
1683
2792
|
/**
|
|
1684
2793
|
* Fetch full product detail by slug or id.
|
|
1685
2794
|
* Returns a discriminated result so storefronts can distinguish missing,
|
|
@@ -1823,6 +2932,12 @@ var OrderApi = class extends BaseApi {
|
|
|
1823
2932
|
idempotencyRequestOptions(params.idempotencyKey)
|
|
1824
2933
|
);
|
|
1825
2934
|
}
|
|
2935
|
+
/**
|
|
2936
|
+
* Returns a `PublicOrder`-compatible shape even when the server backs the
|
|
2937
|
+
* response with a Checkout (checkout/order separation, #1285). `orderNumber`
|
|
2938
|
+
* stays the stable cross-window key. A breaking `PublicCheckout` split is a
|
|
2939
|
+
* deferred follow-up (design D10 / Q3-b); do not change this return type here.
|
|
2940
|
+
*/
|
|
1826
2941
|
checkout(params) {
|
|
1827
2942
|
const { body, idempotencyKey } = splitIdempotencyKey(params);
|
|
1828
2943
|
return this.request(
|
|
@@ -1951,6 +3066,7 @@ var ServerCommerceClient = class {
|
|
|
1951
3066
|
this.product = {
|
|
1952
3067
|
stockCheck: productApi.stockCheck.bind(productApi),
|
|
1953
3068
|
listingGroups: productApi.listingGroups.bind(productApi),
|
|
3069
|
+
listingPage: productApi.listingPage.bind(productApi),
|
|
1954
3070
|
detail: productApi.detail.bind(productApi),
|
|
1955
3071
|
previewDetail: productApi.previewDetail.bind(productApi),
|
|
1956
3072
|
upsert: productApi.upsert.bind(productApi)
|