@01.software/sdk 0.39.0 → 0.41.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/CHANGELOG.md +492 -0
- package/MIGRATION.md +183 -0
- package/README.md +64 -21
- package/dist/client.cjs +47 -69
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +6 -6
- package/dist/client.d.ts +6 -6
- package/dist/client.js +47 -69
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-DVfB0Em1.d.cts → collection-client-Bymfni8u.d.cts} +3 -3
- package/dist/{collection-client-CaMgs5KE.d.ts → collection-client-CN4lj6gi.d.ts} +3 -3
- package/dist/const-4BUtUdGU.d.cts +32 -0
- package/dist/const-ymprfiPf.d.ts +32 -0
- 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 +119 -136
- 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 +119 -136
- 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.d.cts +5 -5
- package/dist/query.d.ts +5 -5
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- package/dist/server.cjs +40 -69
- 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 +40 -69
- package/dist/server.js.map +1 -1
- package/dist/{types-Cmrd1ezc.d.ts → types-Bh2p-EMc.d.ts} +5 -1
- package/dist/{types-CVf8sCZ-.d.ts → types-Bl-m9ttd.d.cts} +129 -77
- package/dist/{types-D0ubzQw0.d.cts → types-BvpjooU-.d.cts} +5 -1
- package/dist/{types-BQo7UdI9.d.cts → types-CHrzs2GB.d.ts} +129 -77
- 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 +6 -4
- package/dist/const-6XHz_jej.d.ts +0 -32
- package/dist/const-B5KT72c7.d.cts +0 -32
package/dist/index.js
CHANGED
|
@@ -1526,6 +1526,19 @@ var CustomerAuth = class {
|
|
|
1526
1526
|
const params = new URLSearchParams();
|
|
1527
1527
|
if (options?.page) params.set("page", String(options.page));
|
|
1528
1528
|
if (options?.limit) params.set("limit", String(options.limit));
|
|
1529
|
+
if (options?.displayFinancialStatus) {
|
|
1530
|
+
params.set("displayFinancialStatus", options.displayFinancialStatus);
|
|
1531
|
+
}
|
|
1532
|
+
if (options?.displayFulfillmentStatus) {
|
|
1533
|
+
params.set("displayFulfillmentStatus", options.displayFulfillmentStatus);
|
|
1534
|
+
}
|
|
1535
|
+
if (options?.returnStatus) params.set("returnStatus", options.returnStatus);
|
|
1536
|
+
if (options?.primaryDisplayStatus) {
|
|
1537
|
+
params.set("primaryDisplayStatus", options.primaryDisplayStatus);
|
|
1538
|
+
}
|
|
1539
|
+
if (options?.returnDisplayStatus) {
|
|
1540
|
+
params.set("returnDisplayStatus", options.returnDisplayStatus);
|
|
1541
|
+
}
|
|
1529
1542
|
if (options?.status) params.set("status", options.status);
|
|
1530
1543
|
const qs = params.toString();
|
|
1531
1544
|
return this.requestJson(`/api/customers/me/orders${qs ? `?${qs}` : ""}`, {
|
|
@@ -1798,25 +1811,14 @@ function resolveProductSelectionMedia(input) {
|
|
|
1798
1811
|
function resolveProductDisplayMedia(input) {
|
|
1799
1812
|
const pool = mediaArray(input.productMediaPool);
|
|
1800
1813
|
const poolById = buildPoolById(pool);
|
|
1801
|
-
const
|
|
1802
|
-
if (
|
|
1803
|
-
const
|
|
1804
|
-
if (
|
|
1805
|
-
return {
|
|
1806
|
-
primaryImage: listingPrimary,
|
|
1807
|
-
images: uniqueWithPrimaryFirst(listingPrimary, pool),
|
|
1808
|
-
source: "listing_primary"
|
|
1809
|
-
};
|
|
1810
|
-
}
|
|
1811
|
-
}
|
|
1812
|
-
const productPrimaryPointer = getMediaId(input.productPrimaryMediaItemId);
|
|
1813
|
-
if (productPrimaryPointer) {
|
|
1814
|
-
const productPrimary = poolById.get(productPrimaryPointer);
|
|
1815
|
-
if (productPrimary) {
|
|
1814
|
+
const featuredImagePointer = toPointerId(input.featuredImage);
|
|
1815
|
+
if (featuredImagePointer) {
|
|
1816
|
+
const featuredImage = poolById.get(featuredImagePointer);
|
|
1817
|
+
if (featuredImage) {
|
|
1816
1818
|
return {
|
|
1817
|
-
primaryImage:
|
|
1818
|
-
images: uniqueWithPrimaryFirst(
|
|
1819
|
-
source: "
|
|
1819
|
+
primaryImage: featuredImage,
|
|
1820
|
+
images: uniqueWithPrimaryFirst(featuredImage, pool),
|
|
1821
|
+
source: "featured_image"
|
|
1820
1822
|
};
|
|
1821
1823
|
}
|
|
1822
1824
|
}
|
|
@@ -1836,22 +1838,16 @@ function resolveProductDisplayMedia(input) {
|
|
|
1836
1838
|
source: "none"
|
|
1837
1839
|
};
|
|
1838
1840
|
}
|
|
1839
|
-
function
|
|
1841
|
+
function resolveFeaturedImagePointer(input) {
|
|
1840
1842
|
const pool = mediaArray(input.productMediaPool);
|
|
1841
1843
|
const resolvedPointer = getMediaId(input.resolvedPrimary);
|
|
1842
1844
|
if (resolvedPointer && input.resolvedSource !== "product_pool" && input.resolvedSource !== "none") {
|
|
1843
1845
|
return resolvedPointer;
|
|
1844
1846
|
}
|
|
1845
1847
|
const poolById = buildPoolById(pool);
|
|
1846
|
-
const
|
|
1847
|
-
if (
|
|
1848
|
-
return
|
|
1849
|
-
}
|
|
1850
|
-
const primaryPointer = toPointerId(input.productPrimaryMediaItemId);
|
|
1851
|
-
if (primaryPointer && poolById.has(primaryPointer)) return primaryPointer;
|
|
1852
|
-
const thumbnailPointer = getMediaId(input.productThumbnail);
|
|
1853
|
-
if (thumbnailPointer && poolById.has(thumbnailPointer)) {
|
|
1854
|
-
return thumbnailPointer;
|
|
1848
|
+
const featuredImagePointer = getMediaId(input.featuredImage);
|
|
1849
|
+
if (featuredImagePointer && poolById.has(featuredImagePointer)) {
|
|
1850
|
+
return featuredImagePointer;
|
|
1855
1851
|
}
|
|
1856
1852
|
if (pool.length > 0) {
|
|
1857
1853
|
const firstPoolId = getMediaId(pool[0]);
|
|
@@ -1930,18 +1926,22 @@ function getFirstMediaId(values) {
|
|
|
1930
1926
|
}
|
|
1931
1927
|
return null;
|
|
1932
1928
|
}
|
|
1929
|
+
function inProductMediaPool(product, mediaId2) {
|
|
1930
|
+
if (mediaId2 == null) return null;
|
|
1931
|
+
const images = Array.isArray(product?.images) ? product.images : [];
|
|
1932
|
+
for (const image of images) {
|
|
1933
|
+
if (extractEntityId(image) === mediaId2) return mediaId2;
|
|
1934
|
+
}
|
|
1935
|
+
return null;
|
|
1936
|
+
}
|
|
1933
1937
|
function getVariantPrimaryImage(variant) {
|
|
1934
1938
|
if (!variant) return null;
|
|
1935
1939
|
return extractEntityId(variant.thumbnail) ?? getFirstMediaId(variant.images);
|
|
1936
1940
|
}
|
|
1937
1941
|
function resolveGenericListingPrimaryImage(product, resolvedPrimary, resolvedSource) {
|
|
1938
|
-
return
|
|
1942
|
+
return resolveFeaturedImagePointer({
|
|
1939
1943
|
productMediaPool: product?.images ?? [],
|
|
1940
|
-
|
|
1941
|
-
product?.primaryMediaItemId ?? null
|
|
1942
|
-
),
|
|
1943
|
-
productThumbnail: product?.thumbnail ?? null,
|
|
1944
|
-
listingPrimaryImage: product?.listing?.primaryImage ?? null,
|
|
1944
|
+
featuredImage: product?.featuredImage ?? null,
|
|
1945
1945
|
resolvedPrimary,
|
|
1946
1946
|
resolvedSource
|
|
1947
1947
|
});
|
|
@@ -2594,7 +2594,7 @@ function normalizedSelectionFromByOptionId(matrix, selectedByOptionId, variantId
|
|
|
2594
2594
|
variantId
|
|
2595
2595
|
};
|
|
2596
2596
|
}
|
|
2597
|
-
function buildFilledNormalizedSelection(matrix, normalizedSelection,
|
|
2597
|
+
function buildFilledNormalizedSelection(matrix, normalizedSelection, selectionHintVariant) {
|
|
2598
2598
|
const selectedByOptionId = new Map(
|
|
2599
2599
|
Object.entries(normalizedSelection.byOptionId)
|
|
2600
2600
|
);
|
|
@@ -2635,7 +2635,7 @@ function buildFilledNormalizedSelection(matrix, normalizedSelection, listing) {
|
|
|
2635
2635
|
const orderedMatches = [...matchingVariantEntries].sort(
|
|
2636
2636
|
(left, right) => compareVariantOrder(left.source, right.source)
|
|
2637
2637
|
);
|
|
2638
|
-
const hintVariantId =
|
|
2638
|
+
const hintVariantId = selectionHintVariant != null ? String(selectionHintVariant) : null;
|
|
2639
2639
|
const hintedEntry = hintVariantId != null ? orderedMatches.find((entry) => entry.id === hintVariantId) : void 0;
|
|
2640
2640
|
const availableEntry = orderedMatches.find(
|
|
2641
2641
|
(entry) => isVariantAvailableForSale(entry.source)
|
|
@@ -2694,7 +2694,6 @@ function buildSelectionMedia(detail, selectedVariant, matchingVariants, selected
|
|
|
2694
2694
|
const productPool = mediaArray2(detail.images);
|
|
2695
2695
|
const resolvedMedia = resolveProductSelectionMedia({
|
|
2696
2696
|
productMediaPool: productPool,
|
|
2697
|
-
productPrimaryMediaItemId: getRelationID(detail.primaryMediaItemId),
|
|
2698
2697
|
selectedVariant: selectedVariant ? {
|
|
2699
2698
|
id: selectedVariant.id,
|
|
2700
2699
|
images: selectedVariant.images
|
|
@@ -2717,8 +2716,7 @@ function buildSelectionMedia(detail, selectedVariant, matchingVariants, selected
|
|
|
2717
2716
|
}
|
|
2718
2717
|
const displayMedia = resolveProductDisplayMedia({
|
|
2719
2718
|
productMediaPool: productPool,
|
|
2720
|
-
|
|
2721
|
-
listingPrimaryImage: detail.listing.primaryImage ?? null
|
|
2719
|
+
featuredImage: detail.featuredImage ?? null
|
|
2722
2720
|
});
|
|
2723
2721
|
if (displayMedia.source !== "none") {
|
|
2724
2722
|
return {
|
|
@@ -2731,10 +2729,9 @@ function buildSelectionMedia(detail, selectedVariant, matchingVariants, selected
|
|
|
2731
2729
|
}
|
|
2732
2730
|
function buildSelectionStock(selectedVariant, matchingVariants) {
|
|
2733
2731
|
if (selectedVariant) {
|
|
2734
|
-
const availableStock =
|
|
2735
|
-
const isActive = selectedVariant.isActive !== false;
|
|
2732
|
+
const availableStock = getVariantAvailableStock(selectedVariant);
|
|
2736
2733
|
return {
|
|
2737
|
-
availableForSale:
|
|
2734
|
+
availableForSale: getVariantAvailableForSale(selectedVariant),
|
|
2738
2735
|
isUnlimited: selectedVariant.isUnlimited,
|
|
2739
2736
|
stock: selectedVariant.stock,
|
|
2740
2737
|
reservedStock: selectedVariant.reservedStock,
|
|
@@ -2755,7 +2752,7 @@ function buildAvailableValueStock(variants) {
|
|
|
2755
2752
|
);
|
|
2756
2753
|
const isUnlimited = activeVariants.some((variant) => variant.isUnlimited);
|
|
2757
2754
|
const availableStock = isUnlimited ? null : activeVariants.reduce(
|
|
2758
|
-
(sum, variant) => sum +
|
|
2755
|
+
(sum, variant) => sum + (getVariantAvailableStock(variant) ?? 0),
|
|
2759
2756
|
0
|
|
2760
2757
|
);
|
|
2761
2758
|
return {
|
|
@@ -2788,14 +2785,15 @@ function getCandidateVariantsForValue(matrix, optionId, valueId, selectedValueId
|
|
|
2788
2785
|
}
|
|
2789
2786
|
function getResolutionContext(context) {
|
|
2790
2787
|
return {
|
|
2788
|
+
featuredImage: context?.featuredImage ?? context?.detail?.featuredImage,
|
|
2791
2789
|
images: context?.images ?? context?.detail?.images ?? [],
|
|
2792
|
-
|
|
2793
|
-
primaryMediaItemId: context?.primaryMediaItemId ?? context?.detail?.primaryMediaItemId ?? null
|
|
2790
|
+
selectedOrFirstAvailableVariant: context?.selectedOrFirstAvailableVariant ?? context?.detail?.selectedOrFirstAvailableVariant
|
|
2794
2791
|
};
|
|
2795
2792
|
}
|
|
2796
2793
|
function resolveProductSelectionFromMatrix(matrix, selection = {}, options, context) {
|
|
2797
|
-
const {
|
|
2798
|
-
const
|
|
2794
|
+
const { featuredImage, images, selectedOrFirstAvailableVariant } = getResolutionContext(context);
|
|
2795
|
+
const selectionHintVariant = getRelationID(selectedOrFirstAvailableVariant);
|
|
2796
|
+
const effectiveSelection = hasExplicitSelection(selection) || selectionHintVariant == null ? selection : { ...selection, variantId: selectionHintVariant };
|
|
2799
2797
|
let normalizedSelection = normalizeProductSelectionFromMatrix(
|
|
2800
2798
|
matrix,
|
|
2801
2799
|
effectiveSelection,
|
|
@@ -2805,7 +2803,7 @@ function resolveProductSelectionFromMatrix(matrix, selection = {}, options, cont
|
|
|
2805
2803
|
normalizedSelection = buildFilledNormalizedSelection(
|
|
2806
2804
|
matrix,
|
|
2807
2805
|
normalizedSelection,
|
|
2808
|
-
|
|
2806
|
+
selectionHintVariant
|
|
2809
2807
|
);
|
|
2810
2808
|
}
|
|
2811
2809
|
const matchingVariantEntries = getMatchingVariantEntries(
|
|
@@ -2876,11 +2874,8 @@ function resolveProductSelectionFromMatrix(matrix, selection = {}, options, cont
|
|
|
2876
2874
|
price: buildSelectionPrice(priceVariants),
|
|
2877
2875
|
media: buildSelectionMedia(
|
|
2878
2876
|
{
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
primaryImage: listing.primaryImage ?? null
|
|
2882
|
-
},
|
|
2883
|
-
primaryMediaItemId
|
|
2877
|
+
featuredImage,
|
|
2878
|
+
images
|
|
2884
2879
|
},
|
|
2885
2880
|
selectedVariant,
|
|
2886
2881
|
matchingVariants,
|
|
@@ -2897,7 +2892,9 @@ function resolveProductSelection(detail, selection = {}, options) {
|
|
|
2897
2892
|
}
|
|
2898
2893
|
function selectNext(detail, current = {}, optionSlug, valueSlug, options) {
|
|
2899
2894
|
const matrix = buildProductOptionMatrixFromDetail(detail);
|
|
2900
|
-
const
|
|
2895
|
+
const selectionHintVariant = getRelationID(
|
|
2896
|
+
detail.selectedOrFirstAvailableVariant
|
|
2897
|
+
);
|
|
2901
2898
|
const normalizedCurrent = normalizeProductSelectionFromMatrix(
|
|
2902
2899
|
matrix,
|
|
2903
2900
|
current,
|
|
@@ -2933,7 +2930,7 @@ function selectNext(detail, current = {}, optionSlug, valueSlug, options) {
|
|
|
2933
2930
|
return buildFilledNormalizedSelection(
|
|
2934
2931
|
matrix,
|
|
2935
2932
|
normalizedSelectionFromByOptionId(matrix, selectedByOptionId, null),
|
|
2936
|
-
|
|
2933
|
+
selectionHintVariant
|
|
2937
2934
|
);
|
|
2938
2935
|
};
|
|
2939
2936
|
const keepPriorSelection = () => {
|
|
@@ -2944,7 +2941,7 @@ function selectNext(detail, current = {}, optionSlug, valueSlug, options) {
|
|
|
2944
2941
|
return buildFilledNormalizedSelection(
|
|
2945
2942
|
matrix,
|
|
2946
2943
|
normalizedSelectionFromByOptionId(matrix, selectedByOptionId, null),
|
|
2947
|
-
|
|
2944
|
+
selectionHintVariant
|
|
2948
2945
|
);
|
|
2949
2946
|
};
|
|
2950
2947
|
const clickedResult = keepClickedSelection();
|
|
@@ -3117,11 +3114,18 @@ function compareVariantOrder(a, b) {
|
|
|
3117
3114
|
const bId = String(getRelationID(b.id) ?? "");
|
|
3118
3115
|
return aId.localeCompare(bId);
|
|
3119
3116
|
}
|
|
3120
|
-
function
|
|
3117
|
+
function getVariantAvailableForSale(variant) {
|
|
3121
3118
|
if (variant.isActive === false) return false;
|
|
3122
3119
|
if (variant.isUnlimited) return true;
|
|
3123
3120
|
return (variant.stock ?? 0) - (variant.reservedStock ?? 0) > 0;
|
|
3124
3121
|
}
|
|
3122
|
+
function getVariantAvailableStock(variant) {
|
|
3123
|
+
if (variant.isUnlimited) return null;
|
|
3124
|
+
return Math.max(0, (variant.stock ?? 0) - (variant.reservedStock ?? 0));
|
|
3125
|
+
}
|
|
3126
|
+
function isVariantAvailableForSale(variant) {
|
|
3127
|
+
return getVariantAvailableForSale(variant);
|
|
3128
|
+
}
|
|
3125
3129
|
function sortVariantsForMediaSelection(variants) {
|
|
3126
3130
|
const orderedVariants = [...variants].sort(compareVariantOrder);
|
|
3127
3131
|
const activeVariants = orderedVariants.filter(
|
|
@@ -3154,7 +3158,7 @@ function getMinMax(values) {
|
|
|
3154
3158
|
max: Math.max(...numbers)
|
|
3155
3159
|
};
|
|
3156
3160
|
}
|
|
3157
|
-
function
|
|
3161
|
+
function buildProductListingGroupProjection(product, variants) {
|
|
3158
3162
|
const orderedVariants = [...variants].sort(compareVariantOrder);
|
|
3159
3163
|
const activeVariants = orderedVariants.filter(
|
|
3160
3164
|
(variant) => variant.isActive !== false
|
|
@@ -3175,7 +3179,6 @@ function buildProductListingProjection(product, variants) {
|
|
|
3175
3179
|
const mediaSelectionVariants = sortVariantsForMediaSelection(variants);
|
|
3176
3180
|
const resolvedProductMedia = resolveProductSelectionMedia({
|
|
3177
3181
|
productMediaPool,
|
|
3178
|
-
productPrimaryMediaItemId: getRelationID(product?.primaryMediaItemId),
|
|
3179
3182
|
selectedVariant: selectionHintVariant && selectionHintHasPoolMedia ? {
|
|
3180
3183
|
id: selectionHintVariant.id,
|
|
3181
3184
|
images: selectionHintVariant.images
|
|
@@ -3201,47 +3204,22 @@ function buildProductListingCard(item, options = {}) {
|
|
|
3201
3204
|
const product = item.product;
|
|
3202
3205
|
const groups = item.groups;
|
|
3203
3206
|
const variants = getProductListingCardVariants(item);
|
|
3204
|
-
const projectedListing =
|
|
3205
|
-
const selectionHintVariant = getRelationID(
|
|
3206
|
-
product.listing && "selectionHintVariant" in product.listing ? product.listing.selectionHintVariant : null
|
|
3207
|
-
) ?? projectedListing.selectionHintVariant;
|
|
3207
|
+
const projectedListing = buildProductListingGroupProjection(product, variants);
|
|
3208
|
+
const selectionHintVariant = getRelationID(product.selectedOrFirstAvailableVariant) ?? projectedListing.selectionHintVariant;
|
|
3208
3209
|
const representativeVariant = findListingCardRepresentativeVariant(
|
|
3209
3210
|
variants,
|
|
3210
3211
|
selectionHintVariant
|
|
3211
3212
|
);
|
|
3212
3213
|
const productMediaPool = mediaArray2(product.images);
|
|
3213
|
-
const
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
(poolItem) => getRelationID(poolItem) === getRelationID(image)
|
|
3217
|
-
)
|
|
3218
|
-
)
|
|
3219
|
-
);
|
|
3220
|
-
const resolvedPrimaryMedia = resolveProductSelectionMedia(
|
|
3221
|
-
{
|
|
3222
|
-
productMediaPool,
|
|
3223
|
-
productPrimaryMediaItemId: getRelationID(product.primaryMediaItemId),
|
|
3224
|
-
selectedVariant: representativeHasPoolMedia ? representativeVariant : null,
|
|
3225
|
-
matchingVariants: representativeHasPoolMedia ? [] : variants
|
|
3226
|
-
}
|
|
3227
|
-
);
|
|
3228
|
-
const listingPrimaryPointer = resolveListingPrimaryImagePointer({
|
|
3229
|
-
productMediaPool,
|
|
3230
|
-
productPrimaryMediaItemId: getRelationID(product.primaryMediaItemId),
|
|
3231
|
-
productThumbnail: product.thumbnail ?? null,
|
|
3232
|
-
listingPrimaryImage: product.listing?.primaryImage ?? null,
|
|
3233
|
-
resolvedPrimary: resolvedPrimaryMedia.primaryImage,
|
|
3234
|
-
resolvedSource: resolvedPrimaryMedia.source
|
|
3235
|
-
});
|
|
3236
|
-
const listingPrimaryMedia = listingPrimaryPointer ? productMediaPool.find(
|
|
3237
|
-
(item2) => getRelationID(item2) === listingPrimaryPointer
|
|
3238
|
-
) ?? resolvedPrimaryMedia.primaryImage ?? null : null;
|
|
3214
|
+
const featuredImageId = getRelationID(product.featuredImage);
|
|
3215
|
+
const featuredImageFromPool = featuredImageId ? productMediaPool.find((item2) => getRelationID(item2) === featuredImageId) : void 0;
|
|
3216
|
+
const listingPrimaryMedia = featuredImageFromPool ?? product.featuredImage ?? productMediaPool[0] ?? null;
|
|
3239
3217
|
const priceRange = resolveListingCardPriceRange(
|
|
3240
3218
|
product,
|
|
3241
3219
|
projectedListing,
|
|
3242
3220
|
groups
|
|
3243
3221
|
);
|
|
3244
|
-
const availableForSale = product.
|
|
3222
|
+
const availableForSale = product.availableForSale != null ? product.availableForSale : groups.length > 0 ? groups.some((group) => group.listing.availableForSale) : projectedListing.availableForSale;
|
|
3245
3223
|
const swatches = groups.length > 1 ? groups.map((group) => buildListingSwatch(product, group, options)) : [];
|
|
3246
3224
|
return {
|
|
3247
3225
|
id: String(product.id),
|
|
@@ -3287,23 +3265,20 @@ function toShopifyPriceRangeV2(listing) {
|
|
|
3287
3265
|
maxVariantPrice: { amount: listing.maxPrice ?? null }
|
|
3288
3266
|
};
|
|
3289
3267
|
}
|
|
3290
|
-
function
|
|
3291
|
-
return
|
|
3292
|
-
}
|
|
3293
|
-
function listingDefinesCompareAtProjection(listing) {
|
|
3294
|
-
return "minCompareAtPrice" in listing || "maxCompareAtPrice" in listing;
|
|
3268
|
+
function hasCompleteProductPriceRange(priceRange) {
|
|
3269
|
+
return priceRange?.minVariantPrice?.amount != null && priceRange?.maxVariantPrice?.amount != null;
|
|
3295
3270
|
}
|
|
3296
3271
|
function resolveListingCardPriceRange(product, projectedListing, groups) {
|
|
3297
|
-
|
|
3298
|
-
if (hasCompleteListingPriceProjection(listing)) {
|
|
3272
|
+
if (hasCompleteProductPriceRange(product.priceRange)) {
|
|
3299
3273
|
const groupRange = groups.length > 0 ? aggregateListingPriceRange(groups) : null;
|
|
3300
|
-
const
|
|
3274
|
+
const minCompareAtPrice = product.compareAtPriceRange?.minVariantPrice?.amount ?? groupRange?.minCompareAtPrice ?? null;
|
|
3275
|
+
const maxCompareAtPrice = product.compareAtPriceRange?.maxVariantPrice?.amount ?? groupRange?.maxCompareAtPrice ?? null;
|
|
3301
3276
|
return {
|
|
3302
|
-
minPrice:
|
|
3303
|
-
maxPrice:
|
|
3304
|
-
minCompareAtPrice
|
|
3305
|
-
maxCompareAtPrice
|
|
3306
|
-
isPriceRange:
|
|
3277
|
+
minPrice: product.priceRange.minVariantPrice.amount,
|
|
3278
|
+
maxPrice: product.priceRange.maxVariantPrice.amount,
|
|
3279
|
+
minCompareAtPrice,
|
|
3280
|
+
maxCompareAtPrice,
|
|
3281
|
+
isPriceRange: product.priceRange.isPriceRange ?? product.priceRange.minVariantPrice.amount !== product.priceRange.maxVariantPrice.amount
|
|
3307
3282
|
};
|
|
3308
3283
|
}
|
|
3309
3284
|
if (groups.length > 0) {
|
|
@@ -3369,6 +3344,10 @@ var PRODUCT_PLP_FIND_OPTIONS = {
|
|
|
3369
3344
|
options: { limit: 50, sort: "_order" }
|
|
3370
3345
|
}
|
|
3371
3346
|
};
|
|
3347
|
+
function projectProductToListingShape(product) {
|
|
3348
|
+
const featuredImage = product.featuredImage != null ? product.featuredImage : product.images?.find((image) => image != null);
|
|
3349
|
+
return { ...product, featuredImage };
|
|
3350
|
+
}
|
|
3372
3351
|
function buildProductListingGroupsByOption(args) {
|
|
3373
3352
|
const primaryOptionId = args.primaryOptionId ?? void 0;
|
|
3374
3353
|
if (!primaryOptionId) return [];
|
|
@@ -3385,26 +3364,13 @@ function buildProductListingGroupsByOption(args) {
|
|
|
3385
3364
|
if (variants.length === 0) {
|
|
3386
3365
|
return [];
|
|
3387
3366
|
}
|
|
3388
|
-
const listingBase =
|
|
3389
|
-
const
|
|
3390
|
-
const
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
productPrimaryMediaItemId: extractEntityId(
|
|
3396
|
-
args.product?.primaryMediaItemId ?? null
|
|
3397
|
-
),
|
|
3398
|
-
selectedVariant: null,
|
|
3399
|
-
matchingVariants: orderedVariants,
|
|
3400
|
-
selectedOptionValues: [
|
|
3401
|
-
{
|
|
3402
|
-
id: value.id,
|
|
3403
|
-
swatch: normalizeMatrixSwatch(value.swatch)
|
|
3404
|
-
}
|
|
3405
|
-
]
|
|
3406
|
-
});
|
|
3407
|
-
const groupPrimaryImage = extractEntityId(resolvedMedia.primaryImage) ?? getFirstAvailableVariantPrimaryImage(variants) ?? extractEntityId(args.product?.thumbnail) ?? getFirstMediaId(args.product?.images);
|
|
3367
|
+
const listingBase = buildProductListingGroupProjection(void 0, variants);
|
|
3368
|
+
const normalizedSwatch = normalizeMatrixSwatch(value.swatch);
|
|
3369
|
+
const swatchMediaId = normalizedSwatch?.mediaItemId == null ? null : String(normalizedSwatch.mediaItemId);
|
|
3370
|
+
const groupPrimaryImage = inProductMediaPool(args.product, swatchMediaId) ?? inProductMediaPool(
|
|
3371
|
+
args.product,
|
|
3372
|
+
getFirstAvailableVariantPrimaryImage(variants)
|
|
3373
|
+
) ?? getFirstMediaId(args.product?.images);
|
|
3408
3374
|
return [
|
|
3409
3375
|
{
|
|
3410
3376
|
optionId: primaryOption.id,
|
|
@@ -3477,15 +3443,19 @@ function buildProductListingPageWhere(params) {
|
|
|
3477
3443
|
if (tagIds) clauses.push({ tags: { in: tagIds } });
|
|
3478
3444
|
const minPrice = filters?.price?.min;
|
|
3479
3445
|
if (minPrice != null) {
|
|
3480
|
-
clauses.push({
|
|
3446
|
+
clauses.push({
|
|
3447
|
+
"priceRange.maxVariantPrice.amount": { greater_than_equal: minPrice }
|
|
3448
|
+
});
|
|
3481
3449
|
}
|
|
3482
3450
|
const maxPrice = filters?.price?.max;
|
|
3483
3451
|
if (maxPrice != null) {
|
|
3484
|
-
clauses.push({
|
|
3452
|
+
clauses.push({
|
|
3453
|
+
"priceRange.minVariantPrice.amount": { less_than_equal: maxPrice }
|
|
3454
|
+
});
|
|
3485
3455
|
}
|
|
3486
3456
|
if (filters?.availableForSale != null) {
|
|
3487
3457
|
clauses.push({
|
|
3488
|
-
|
|
3458
|
+
availableForSale: { equals: filters.availableForSale }
|
|
3489
3459
|
});
|
|
3490
3460
|
}
|
|
3491
3461
|
if (clauses.length === 0) return void 0;
|
|
@@ -3710,6 +3680,12 @@ var OrderApi = class extends BaseApi {
|
|
|
3710
3680
|
idempotencyRequestOptions(params.idempotencyKey)
|
|
3711
3681
|
);
|
|
3712
3682
|
}
|
|
3683
|
+
/**
|
|
3684
|
+
* Returns a `PublicOrder`-compatible shape even when the server backs the
|
|
3685
|
+
* response with a Checkout (checkout/order separation, #1285). `orderNumber`
|
|
3686
|
+
* stays the stable cross-window key. A breaking `PublicCheckout` split is a
|
|
3687
|
+
* deferred follow-up (design D10 / Q3-b); do not change this return type here.
|
|
3688
|
+
*/
|
|
3713
3689
|
checkout(params) {
|
|
3714
3690
|
const { body, idempotencyKey } = splitIdempotencyKey(params);
|
|
3715
3691
|
return this.request(
|
|
@@ -4087,17 +4063,19 @@ function mergeProductDetailWithStock(catalog, snapshot) {
|
|
|
4087
4063
|
(sum, variant) => sum + Math.max(0, (variant.stock ?? 0) - (variant.reservedStock ?? 0)),
|
|
4088
4064
|
0
|
|
4089
4065
|
);
|
|
4090
|
-
const { liveStockRequired: _liveStockRequired, ...listingBase } = catalog.listing;
|
|
4091
4066
|
const availableForSale = snapshot.snapshots.some(
|
|
4092
4067
|
(item) => item.status === "available" && item.availableForSale
|
|
4093
4068
|
);
|
|
4069
|
+
const selectedVariantId = typeof catalog.selectedOrFirstAvailableVariant === "object" && catalog.selectedOrFirstAvailableVariant !== null ? String(catalog.selectedOrFirstAvailableVariant.id) : catalog.selectedOrFirstAvailableVariant != null ? String(catalog.selectedOrFirstAvailableVariant) : null;
|
|
4070
|
+
const selectedOrFirstAvailableVariant = selectedVariantId != null ? variants.find((variant) => String(variant.id) === selectedVariantId) ?? selectedVariantId : null;
|
|
4094
4071
|
return {
|
|
4095
4072
|
stockMergeStatus: missingSnapshotCount === 0 ? "complete" : "partial",
|
|
4096
4073
|
product: {
|
|
4097
4074
|
...catalog,
|
|
4098
4075
|
product: { ...catalog.product, totalInventory },
|
|
4099
4076
|
variants,
|
|
4100
|
-
|
|
4077
|
+
availableForSale,
|
|
4078
|
+
selectedOrFirstAvailableVariant
|
|
4101
4079
|
}
|
|
4102
4080
|
};
|
|
4103
4081
|
}
|
|
@@ -4377,6 +4355,7 @@ var INTERNAL_COLLECTIONS = [
|
|
|
4377
4355
|
"commerce-notification-intents",
|
|
4378
4356
|
"product-collection-items",
|
|
4379
4357
|
"order-status-logs",
|
|
4358
|
+
"tenant-commerce-config",
|
|
4380
4359
|
"api-keys",
|
|
4381
4360
|
"personal-access-tokens",
|
|
4382
4361
|
"tenant-entitlements",
|
|
@@ -4401,6 +4380,7 @@ var COLLECTIONS = [
|
|
|
4401
4380
|
"product-collections",
|
|
4402
4381
|
"brands",
|
|
4403
4382
|
"customer-profiles",
|
|
4383
|
+
"customer-profile-stats",
|
|
4404
4384
|
"discounts",
|
|
4405
4385
|
"shipping-policies",
|
|
4406
4386
|
"shipping-zones",
|
|
@@ -4429,8 +4409,6 @@ var COLLECTIONS = [
|
|
|
4429
4409
|
"canvas-edge-types",
|
|
4430
4410
|
"canvas-categories",
|
|
4431
4411
|
"canvas-tags",
|
|
4432
|
-
"canvas-nodes",
|
|
4433
|
-
"canvas-edges",
|
|
4434
4412
|
"video-categories",
|
|
4435
4413
|
"video-tags",
|
|
4436
4414
|
"forms",
|
|
@@ -4465,11 +4443,15 @@ var SERVER_ONLY_COLLECTIONS = [
|
|
|
4465
4443
|
"form-submissions",
|
|
4466
4444
|
"carts",
|
|
4467
4445
|
"cart-items",
|
|
4446
|
+
"checkouts",
|
|
4447
|
+
"checkout-items",
|
|
4468
4448
|
"posts",
|
|
4469
4449
|
"comments",
|
|
4470
4450
|
"reactions",
|
|
4471
4451
|
"bookmarks",
|
|
4472
4452
|
"live-streams",
|
|
4453
|
+
"canvas-nodes",
|
|
4454
|
+
"canvas-edges",
|
|
4473
4455
|
"customer-groups",
|
|
4474
4456
|
"reports",
|
|
4475
4457
|
"community-bans",
|
|
@@ -4647,8 +4629,7 @@ function resolveProductMedia(input) {
|
|
|
4647
4629
|
};
|
|
4648
4630
|
}
|
|
4649
4631
|
const display = resolveProductDisplayMedia({
|
|
4650
|
-
productMediaPool: input.productMediaPool
|
|
4651
|
-
productPrimaryMediaItemId: input.productPrimaryMediaItemId
|
|
4632
|
+
productMediaPool: input.productMediaPool
|
|
4652
4633
|
});
|
|
4653
4634
|
return {
|
|
4654
4635
|
primaryImage: display.primaryImage,
|
|
@@ -4776,8 +4757,7 @@ function resolveProductGallery(input) {
|
|
|
4776
4757
|
if (legacyResolved && legacyResolved.source !== "none") return legacyResolved;
|
|
4777
4758
|
return resolveProductDisplayMedia({
|
|
4778
4759
|
productMediaPool: input.productMediaPool ?? input.pool ?? null,
|
|
4779
|
-
|
|
4780
|
-
listingPrimaryImage: input.listingPrimaryImage
|
|
4760
|
+
featuredImage: input.featuredImage
|
|
4781
4761
|
});
|
|
4782
4762
|
}
|
|
4783
4763
|
|
|
@@ -5146,8 +5126,8 @@ export {
|
|
|
5146
5126
|
ValidationError,
|
|
5147
5127
|
buildProductHref,
|
|
5148
5128
|
buildProductListingCard,
|
|
5129
|
+
buildProductListingGroupProjection,
|
|
5149
5130
|
buildProductListingGroupsByOption,
|
|
5150
|
-
buildProductListingProjection,
|
|
5151
5131
|
buildProductOptionMatrix,
|
|
5152
5132
|
buildProductOptionMatrixFromDetail,
|
|
5153
5133
|
createAnalytics,
|
|
@@ -5174,6 +5154,8 @@ export {
|
|
|
5174
5154
|
getImageUrl,
|
|
5175
5155
|
getProductSelectionImages,
|
|
5176
5156
|
getSelectedValueByOptionId,
|
|
5157
|
+
getVariantAvailableForSale,
|
|
5158
|
+
getVariantAvailableStock,
|
|
5177
5159
|
getVideoGif,
|
|
5178
5160
|
getVideoMp4Url,
|
|
5179
5161
|
getVideoStoryboard,
|
|
@@ -5206,7 +5188,8 @@ export {
|
|
|
5206
5188
|
normalizeProductSelectionFromMatrix,
|
|
5207
5189
|
normalizeSelectedValueIds,
|
|
5208
5190
|
parseProductSelection,
|
|
5209
|
-
|
|
5191
|
+
projectProductToListingShape,
|
|
5192
|
+
resolveFeaturedImagePointer,
|
|
5210
5193
|
resolveProductDisplayMedia,
|
|
5211
5194
|
resolveProductGallery,
|
|
5212
5195
|
resolveProductMedia,
|