@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.cjs
CHANGED
|
@@ -63,8 +63,8 @@ __export(src_exports, {
|
|
|
63
63
|
ValidationError: () => ValidationError,
|
|
64
64
|
buildProductHref: () => buildProductHref,
|
|
65
65
|
buildProductListingCard: () => buildProductListingCard,
|
|
66
|
+
buildProductListingGroupProjection: () => buildProductListingGroupProjection,
|
|
66
67
|
buildProductListingGroupsByOption: () => buildProductListingGroupsByOption,
|
|
67
|
-
buildProductListingProjection: () => buildProductListingProjection,
|
|
68
68
|
buildProductOptionMatrix: () => buildProductOptionMatrix,
|
|
69
69
|
buildProductOptionMatrixFromDetail: () => buildProductOptionMatrixFromDetail,
|
|
70
70
|
createAnalytics: () => createAnalytics,
|
|
@@ -91,6 +91,8 @@ __export(src_exports, {
|
|
|
91
91
|
getImageUrl: () => getImageUrl,
|
|
92
92
|
getProductSelectionImages: () => getProductSelectionImages,
|
|
93
93
|
getSelectedValueByOptionId: () => getSelectedValueByOptionId,
|
|
94
|
+
getVariantAvailableForSale: () => getVariantAvailableForSale,
|
|
95
|
+
getVariantAvailableStock: () => getVariantAvailableStock,
|
|
94
96
|
getVideoGif: () => getVideoGif,
|
|
95
97
|
getVideoMp4Url: () => getVideoMp4Url,
|
|
96
98
|
getVideoStoryboard: () => getVideoStoryboard,
|
|
@@ -123,7 +125,8 @@ __export(src_exports, {
|
|
|
123
125
|
normalizeProductSelectionFromMatrix: () => normalizeProductSelectionFromMatrix,
|
|
124
126
|
normalizeSelectedValueIds: () => normalizeSelectedValueIds,
|
|
125
127
|
parseProductSelection: () => parseProductSelection,
|
|
126
|
-
|
|
128
|
+
projectProductToListingShape: () => projectProductToListingShape,
|
|
129
|
+
resolveFeaturedImagePointer: () => resolveFeaturedImagePointer,
|
|
127
130
|
resolveProductDisplayMedia: () => resolveProductDisplayMedia,
|
|
128
131
|
resolveProductGallery: () => resolveProductGallery,
|
|
129
132
|
resolveProductMedia: () => resolveProductMedia,
|
|
@@ -1667,6 +1670,19 @@ var CustomerAuth = class {
|
|
|
1667
1670
|
const params = new URLSearchParams();
|
|
1668
1671
|
if (options?.page) params.set("page", String(options.page));
|
|
1669
1672
|
if (options?.limit) params.set("limit", String(options.limit));
|
|
1673
|
+
if (options?.displayFinancialStatus) {
|
|
1674
|
+
params.set("displayFinancialStatus", options.displayFinancialStatus);
|
|
1675
|
+
}
|
|
1676
|
+
if (options?.displayFulfillmentStatus) {
|
|
1677
|
+
params.set("displayFulfillmentStatus", options.displayFulfillmentStatus);
|
|
1678
|
+
}
|
|
1679
|
+
if (options?.returnStatus) params.set("returnStatus", options.returnStatus);
|
|
1680
|
+
if (options?.primaryDisplayStatus) {
|
|
1681
|
+
params.set("primaryDisplayStatus", options.primaryDisplayStatus);
|
|
1682
|
+
}
|
|
1683
|
+
if (options?.returnDisplayStatus) {
|
|
1684
|
+
params.set("returnDisplayStatus", options.returnDisplayStatus);
|
|
1685
|
+
}
|
|
1670
1686
|
if (options?.status) params.set("status", options.status);
|
|
1671
1687
|
const qs = params.toString();
|
|
1672
1688
|
return this.requestJson(`/api/customers/me/orders${qs ? `?${qs}` : ""}`, {
|
|
@@ -1939,25 +1955,14 @@ function resolveProductSelectionMedia(input) {
|
|
|
1939
1955
|
function resolveProductDisplayMedia(input) {
|
|
1940
1956
|
const pool = mediaArray(input.productMediaPool);
|
|
1941
1957
|
const poolById = buildPoolById(pool);
|
|
1942
|
-
const
|
|
1943
|
-
if (
|
|
1944
|
-
const
|
|
1945
|
-
if (
|
|
1946
|
-
return {
|
|
1947
|
-
primaryImage: listingPrimary,
|
|
1948
|
-
images: uniqueWithPrimaryFirst(listingPrimary, pool),
|
|
1949
|
-
source: "listing_primary"
|
|
1950
|
-
};
|
|
1951
|
-
}
|
|
1952
|
-
}
|
|
1953
|
-
const productPrimaryPointer = getMediaId(input.productPrimaryMediaItemId);
|
|
1954
|
-
if (productPrimaryPointer) {
|
|
1955
|
-
const productPrimary = poolById.get(productPrimaryPointer);
|
|
1956
|
-
if (productPrimary) {
|
|
1958
|
+
const featuredImagePointer = toPointerId(input.featuredImage);
|
|
1959
|
+
if (featuredImagePointer) {
|
|
1960
|
+
const featuredImage = poolById.get(featuredImagePointer);
|
|
1961
|
+
if (featuredImage) {
|
|
1957
1962
|
return {
|
|
1958
|
-
primaryImage:
|
|
1959
|
-
images: uniqueWithPrimaryFirst(
|
|
1960
|
-
source: "
|
|
1963
|
+
primaryImage: featuredImage,
|
|
1964
|
+
images: uniqueWithPrimaryFirst(featuredImage, pool),
|
|
1965
|
+
source: "featured_image"
|
|
1961
1966
|
};
|
|
1962
1967
|
}
|
|
1963
1968
|
}
|
|
@@ -1977,22 +1982,16 @@ function resolveProductDisplayMedia(input) {
|
|
|
1977
1982
|
source: "none"
|
|
1978
1983
|
};
|
|
1979
1984
|
}
|
|
1980
|
-
function
|
|
1985
|
+
function resolveFeaturedImagePointer(input) {
|
|
1981
1986
|
const pool = mediaArray(input.productMediaPool);
|
|
1982
1987
|
const resolvedPointer = getMediaId(input.resolvedPrimary);
|
|
1983
1988
|
if (resolvedPointer && input.resolvedSource !== "product_pool" && input.resolvedSource !== "none") {
|
|
1984
1989
|
return resolvedPointer;
|
|
1985
1990
|
}
|
|
1986
1991
|
const poolById = buildPoolById(pool);
|
|
1987
|
-
const
|
|
1988
|
-
if (
|
|
1989
|
-
return
|
|
1990
|
-
}
|
|
1991
|
-
const primaryPointer = toPointerId(input.productPrimaryMediaItemId);
|
|
1992
|
-
if (primaryPointer && poolById.has(primaryPointer)) return primaryPointer;
|
|
1993
|
-
const thumbnailPointer = getMediaId(input.productThumbnail);
|
|
1994
|
-
if (thumbnailPointer && poolById.has(thumbnailPointer)) {
|
|
1995
|
-
return thumbnailPointer;
|
|
1992
|
+
const featuredImagePointer = getMediaId(input.featuredImage);
|
|
1993
|
+
if (featuredImagePointer && poolById.has(featuredImagePointer)) {
|
|
1994
|
+
return featuredImagePointer;
|
|
1996
1995
|
}
|
|
1997
1996
|
if (pool.length > 0) {
|
|
1998
1997
|
const firstPoolId = getMediaId(pool[0]);
|
|
@@ -2071,18 +2070,22 @@ function getFirstMediaId(values) {
|
|
|
2071
2070
|
}
|
|
2072
2071
|
return null;
|
|
2073
2072
|
}
|
|
2073
|
+
function inProductMediaPool(product, mediaId2) {
|
|
2074
|
+
if (mediaId2 == null) return null;
|
|
2075
|
+
const images = Array.isArray(product?.images) ? product.images : [];
|
|
2076
|
+
for (const image of images) {
|
|
2077
|
+
if (extractEntityId(image) === mediaId2) return mediaId2;
|
|
2078
|
+
}
|
|
2079
|
+
return null;
|
|
2080
|
+
}
|
|
2074
2081
|
function getVariantPrimaryImage(variant) {
|
|
2075
2082
|
if (!variant) return null;
|
|
2076
2083
|
return extractEntityId(variant.thumbnail) ?? getFirstMediaId(variant.images);
|
|
2077
2084
|
}
|
|
2078
2085
|
function resolveGenericListingPrimaryImage(product, resolvedPrimary, resolvedSource) {
|
|
2079
|
-
return
|
|
2086
|
+
return resolveFeaturedImagePointer({
|
|
2080
2087
|
productMediaPool: product?.images ?? [],
|
|
2081
|
-
|
|
2082
|
-
product?.primaryMediaItemId ?? null
|
|
2083
|
-
),
|
|
2084
|
-
productThumbnail: product?.thumbnail ?? null,
|
|
2085
|
-
listingPrimaryImage: product?.listing?.primaryImage ?? null,
|
|
2088
|
+
featuredImage: product?.featuredImage ?? null,
|
|
2086
2089
|
resolvedPrimary,
|
|
2087
2090
|
resolvedSource
|
|
2088
2091
|
});
|
|
@@ -2735,7 +2738,7 @@ function normalizedSelectionFromByOptionId(matrix, selectedByOptionId, variantId
|
|
|
2735
2738
|
variantId
|
|
2736
2739
|
};
|
|
2737
2740
|
}
|
|
2738
|
-
function buildFilledNormalizedSelection(matrix, normalizedSelection,
|
|
2741
|
+
function buildFilledNormalizedSelection(matrix, normalizedSelection, selectionHintVariant) {
|
|
2739
2742
|
const selectedByOptionId = new Map(
|
|
2740
2743
|
Object.entries(normalizedSelection.byOptionId)
|
|
2741
2744
|
);
|
|
@@ -2776,7 +2779,7 @@ function buildFilledNormalizedSelection(matrix, normalizedSelection, listing) {
|
|
|
2776
2779
|
const orderedMatches = [...matchingVariantEntries].sort(
|
|
2777
2780
|
(left, right) => compareVariantOrder(left.source, right.source)
|
|
2778
2781
|
);
|
|
2779
|
-
const hintVariantId =
|
|
2782
|
+
const hintVariantId = selectionHintVariant != null ? String(selectionHintVariant) : null;
|
|
2780
2783
|
const hintedEntry = hintVariantId != null ? orderedMatches.find((entry) => entry.id === hintVariantId) : void 0;
|
|
2781
2784
|
const availableEntry = orderedMatches.find(
|
|
2782
2785
|
(entry) => isVariantAvailableForSale(entry.source)
|
|
@@ -2835,7 +2838,6 @@ function buildSelectionMedia(detail, selectedVariant, matchingVariants, selected
|
|
|
2835
2838
|
const productPool = mediaArray2(detail.images);
|
|
2836
2839
|
const resolvedMedia = resolveProductSelectionMedia({
|
|
2837
2840
|
productMediaPool: productPool,
|
|
2838
|
-
productPrimaryMediaItemId: getRelationID(detail.primaryMediaItemId),
|
|
2839
2841
|
selectedVariant: selectedVariant ? {
|
|
2840
2842
|
id: selectedVariant.id,
|
|
2841
2843
|
images: selectedVariant.images
|
|
@@ -2858,8 +2860,7 @@ function buildSelectionMedia(detail, selectedVariant, matchingVariants, selected
|
|
|
2858
2860
|
}
|
|
2859
2861
|
const displayMedia = resolveProductDisplayMedia({
|
|
2860
2862
|
productMediaPool: productPool,
|
|
2861
|
-
|
|
2862
|
-
listingPrimaryImage: detail.listing.primaryImage ?? null
|
|
2863
|
+
featuredImage: detail.featuredImage ?? null
|
|
2863
2864
|
});
|
|
2864
2865
|
if (displayMedia.source !== "none") {
|
|
2865
2866
|
return {
|
|
@@ -2872,10 +2873,9 @@ function buildSelectionMedia(detail, selectedVariant, matchingVariants, selected
|
|
|
2872
2873
|
}
|
|
2873
2874
|
function buildSelectionStock(selectedVariant, matchingVariants) {
|
|
2874
2875
|
if (selectedVariant) {
|
|
2875
|
-
const availableStock =
|
|
2876
|
-
const isActive = selectedVariant.isActive !== false;
|
|
2876
|
+
const availableStock = getVariantAvailableStock(selectedVariant);
|
|
2877
2877
|
return {
|
|
2878
|
-
availableForSale:
|
|
2878
|
+
availableForSale: getVariantAvailableForSale(selectedVariant),
|
|
2879
2879
|
isUnlimited: selectedVariant.isUnlimited,
|
|
2880
2880
|
stock: selectedVariant.stock,
|
|
2881
2881
|
reservedStock: selectedVariant.reservedStock,
|
|
@@ -2896,7 +2896,7 @@ function buildAvailableValueStock(variants) {
|
|
|
2896
2896
|
);
|
|
2897
2897
|
const isUnlimited = activeVariants.some((variant) => variant.isUnlimited);
|
|
2898
2898
|
const availableStock = isUnlimited ? null : activeVariants.reduce(
|
|
2899
|
-
(sum, variant) => sum +
|
|
2899
|
+
(sum, variant) => sum + (getVariantAvailableStock(variant) ?? 0),
|
|
2900
2900
|
0
|
|
2901
2901
|
);
|
|
2902
2902
|
return {
|
|
@@ -2929,14 +2929,15 @@ function getCandidateVariantsForValue(matrix, optionId, valueId, selectedValueId
|
|
|
2929
2929
|
}
|
|
2930
2930
|
function getResolutionContext(context) {
|
|
2931
2931
|
return {
|
|
2932
|
+
featuredImage: context?.featuredImage ?? context?.detail?.featuredImage,
|
|
2932
2933
|
images: context?.images ?? context?.detail?.images ?? [],
|
|
2933
|
-
|
|
2934
|
-
primaryMediaItemId: context?.primaryMediaItemId ?? context?.detail?.primaryMediaItemId ?? null
|
|
2934
|
+
selectedOrFirstAvailableVariant: context?.selectedOrFirstAvailableVariant ?? context?.detail?.selectedOrFirstAvailableVariant
|
|
2935
2935
|
};
|
|
2936
2936
|
}
|
|
2937
2937
|
function resolveProductSelectionFromMatrix(matrix, selection = {}, options, context) {
|
|
2938
|
-
const {
|
|
2939
|
-
const
|
|
2938
|
+
const { featuredImage, images, selectedOrFirstAvailableVariant } = getResolutionContext(context);
|
|
2939
|
+
const selectionHintVariant = getRelationID(selectedOrFirstAvailableVariant);
|
|
2940
|
+
const effectiveSelection = hasExplicitSelection(selection) || selectionHintVariant == null ? selection : { ...selection, variantId: selectionHintVariant };
|
|
2940
2941
|
let normalizedSelection = normalizeProductSelectionFromMatrix(
|
|
2941
2942
|
matrix,
|
|
2942
2943
|
effectiveSelection,
|
|
@@ -2946,7 +2947,7 @@ function resolveProductSelectionFromMatrix(matrix, selection = {}, options, cont
|
|
|
2946
2947
|
normalizedSelection = buildFilledNormalizedSelection(
|
|
2947
2948
|
matrix,
|
|
2948
2949
|
normalizedSelection,
|
|
2949
|
-
|
|
2950
|
+
selectionHintVariant
|
|
2950
2951
|
);
|
|
2951
2952
|
}
|
|
2952
2953
|
const matchingVariantEntries = getMatchingVariantEntries(
|
|
@@ -3017,11 +3018,8 @@ function resolveProductSelectionFromMatrix(matrix, selection = {}, options, cont
|
|
|
3017
3018
|
price: buildSelectionPrice(priceVariants),
|
|
3018
3019
|
media: buildSelectionMedia(
|
|
3019
3020
|
{
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
primaryImage: listing.primaryImage ?? null
|
|
3023
|
-
},
|
|
3024
|
-
primaryMediaItemId
|
|
3021
|
+
featuredImage,
|
|
3022
|
+
images
|
|
3025
3023
|
},
|
|
3026
3024
|
selectedVariant,
|
|
3027
3025
|
matchingVariants,
|
|
@@ -3038,7 +3036,9 @@ function resolveProductSelection(detail, selection = {}, options) {
|
|
|
3038
3036
|
}
|
|
3039
3037
|
function selectNext(detail, current = {}, optionSlug, valueSlug, options) {
|
|
3040
3038
|
const matrix = buildProductOptionMatrixFromDetail(detail);
|
|
3041
|
-
const
|
|
3039
|
+
const selectionHintVariant = getRelationID(
|
|
3040
|
+
detail.selectedOrFirstAvailableVariant
|
|
3041
|
+
);
|
|
3042
3042
|
const normalizedCurrent = normalizeProductSelectionFromMatrix(
|
|
3043
3043
|
matrix,
|
|
3044
3044
|
current,
|
|
@@ -3074,7 +3074,7 @@ function selectNext(detail, current = {}, optionSlug, valueSlug, options) {
|
|
|
3074
3074
|
return buildFilledNormalizedSelection(
|
|
3075
3075
|
matrix,
|
|
3076
3076
|
normalizedSelectionFromByOptionId(matrix, selectedByOptionId, null),
|
|
3077
|
-
|
|
3077
|
+
selectionHintVariant
|
|
3078
3078
|
);
|
|
3079
3079
|
};
|
|
3080
3080
|
const keepPriorSelection = () => {
|
|
@@ -3085,7 +3085,7 @@ function selectNext(detail, current = {}, optionSlug, valueSlug, options) {
|
|
|
3085
3085
|
return buildFilledNormalizedSelection(
|
|
3086
3086
|
matrix,
|
|
3087
3087
|
normalizedSelectionFromByOptionId(matrix, selectedByOptionId, null),
|
|
3088
|
-
|
|
3088
|
+
selectionHintVariant
|
|
3089
3089
|
);
|
|
3090
3090
|
};
|
|
3091
3091
|
const clickedResult = keepClickedSelection();
|
|
@@ -3258,11 +3258,18 @@ function compareVariantOrder(a, b) {
|
|
|
3258
3258
|
const bId = String(getRelationID(b.id) ?? "");
|
|
3259
3259
|
return aId.localeCompare(bId);
|
|
3260
3260
|
}
|
|
3261
|
-
function
|
|
3261
|
+
function getVariantAvailableForSale(variant) {
|
|
3262
3262
|
if (variant.isActive === false) return false;
|
|
3263
3263
|
if (variant.isUnlimited) return true;
|
|
3264
3264
|
return (variant.stock ?? 0) - (variant.reservedStock ?? 0) > 0;
|
|
3265
3265
|
}
|
|
3266
|
+
function getVariantAvailableStock(variant) {
|
|
3267
|
+
if (variant.isUnlimited) return null;
|
|
3268
|
+
return Math.max(0, (variant.stock ?? 0) - (variant.reservedStock ?? 0));
|
|
3269
|
+
}
|
|
3270
|
+
function isVariantAvailableForSale(variant) {
|
|
3271
|
+
return getVariantAvailableForSale(variant);
|
|
3272
|
+
}
|
|
3266
3273
|
function sortVariantsForMediaSelection(variants) {
|
|
3267
3274
|
const orderedVariants = [...variants].sort(compareVariantOrder);
|
|
3268
3275
|
const activeVariants = orderedVariants.filter(
|
|
@@ -3295,7 +3302,7 @@ function getMinMax(values) {
|
|
|
3295
3302
|
max: Math.max(...numbers)
|
|
3296
3303
|
};
|
|
3297
3304
|
}
|
|
3298
|
-
function
|
|
3305
|
+
function buildProductListingGroupProjection(product, variants) {
|
|
3299
3306
|
const orderedVariants = [...variants].sort(compareVariantOrder);
|
|
3300
3307
|
const activeVariants = orderedVariants.filter(
|
|
3301
3308
|
(variant) => variant.isActive !== false
|
|
@@ -3316,7 +3323,6 @@ function buildProductListingProjection(product, variants) {
|
|
|
3316
3323
|
const mediaSelectionVariants = sortVariantsForMediaSelection(variants);
|
|
3317
3324
|
const resolvedProductMedia = resolveProductSelectionMedia({
|
|
3318
3325
|
productMediaPool,
|
|
3319
|
-
productPrimaryMediaItemId: getRelationID(product?.primaryMediaItemId),
|
|
3320
3326
|
selectedVariant: selectionHintVariant && selectionHintHasPoolMedia ? {
|
|
3321
3327
|
id: selectionHintVariant.id,
|
|
3322
3328
|
images: selectionHintVariant.images
|
|
@@ -3342,47 +3348,22 @@ function buildProductListingCard(item, options = {}) {
|
|
|
3342
3348
|
const product = item.product;
|
|
3343
3349
|
const groups = item.groups;
|
|
3344
3350
|
const variants = getProductListingCardVariants(item);
|
|
3345
|
-
const projectedListing =
|
|
3346
|
-
const selectionHintVariant = getRelationID(
|
|
3347
|
-
product.listing && "selectionHintVariant" in product.listing ? product.listing.selectionHintVariant : null
|
|
3348
|
-
) ?? projectedListing.selectionHintVariant;
|
|
3351
|
+
const projectedListing = buildProductListingGroupProjection(product, variants);
|
|
3352
|
+
const selectionHintVariant = getRelationID(product.selectedOrFirstAvailableVariant) ?? projectedListing.selectionHintVariant;
|
|
3349
3353
|
const representativeVariant = findListingCardRepresentativeVariant(
|
|
3350
3354
|
variants,
|
|
3351
3355
|
selectionHintVariant
|
|
3352
3356
|
);
|
|
3353
3357
|
const productMediaPool = mediaArray2(product.images);
|
|
3354
|
-
const
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
(poolItem) => getRelationID(poolItem) === getRelationID(image)
|
|
3358
|
-
)
|
|
3359
|
-
)
|
|
3360
|
-
);
|
|
3361
|
-
const resolvedPrimaryMedia = resolveProductSelectionMedia(
|
|
3362
|
-
{
|
|
3363
|
-
productMediaPool,
|
|
3364
|
-
productPrimaryMediaItemId: getRelationID(product.primaryMediaItemId),
|
|
3365
|
-
selectedVariant: representativeHasPoolMedia ? representativeVariant : null,
|
|
3366
|
-
matchingVariants: representativeHasPoolMedia ? [] : variants
|
|
3367
|
-
}
|
|
3368
|
-
);
|
|
3369
|
-
const listingPrimaryPointer = resolveListingPrimaryImagePointer({
|
|
3370
|
-
productMediaPool,
|
|
3371
|
-
productPrimaryMediaItemId: getRelationID(product.primaryMediaItemId),
|
|
3372
|
-
productThumbnail: product.thumbnail ?? null,
|
|
3373
|
-
listingPrimaryImage: product.listing?.primaryImage ?? null,
|
|
3374
|
-
resolvedPrimary: resolvedPrimaryMedia.primaryImage,
|
|
3375
|
-
resolvedSource: resolvedPrimaryMedia.source
|
|
3376
|
-
});
|
|
3377
|
-
const listingPrimaryMedia = listingPrimaryPointer ? productMediaPool.find(
|
|
3378
|
-
(item2) => getRelationID(item2) === listingPrimaryPointer
|
|
3379
|
-
) ?? resolvedPrimaryMedia.primaryImage ?? null : null;
|
|
3358
|
+
const featuredImageId = getRelationID(product.featuredImage);
|
|
3359
|
+
const featuredImageFromPool = featuredImageId ? productMediaPool.find((item2) => getRelationID(item2) === featuredImageId) : void 0;
|
|
3360
|
+
const listingPrimaryMedia = featuredImageFromPool ?? product.featuredImage ?? productMediaPool[0] ?? null;
|
|
3380
3361
|
const priceRange = resolveListingCardPriceRange(
|
|
3381
3362
|
product,
|
|
3382
3363
|
projectedListing,
|
|
3383
3364
|
groups
|
|
3384
3365
|
);
|
|
3385
|
-
const availableForSale = product.
|
|
3366
|
+
const availableForSale = product.availableForSale != null ? product.availableForSale : groups.length > 0 ? groups.some((group) => group.listing.availableForSale) : projectedListing.availableForSale;
|
|
3386
3367
|
const swatches = groups.length > 1 ? groups.map((group) => buildListingSwatch(product, group, options)) : [];
|
|
3387
3368
|
return {
|
|
3388
3369
|
id: String(product.id),
|
|
@@ -3428,23 +3409,20 @@ function toShopifyPriceRangeV2(listing) {
|
|
|
3428
3409
|
maxVariantPrice: { amount: listing.maxPrice ?? null }
|
|
3429
3410
|
};
|
|
3430
3411
|
}
|
|
3431
|
-
function
|
|
3432
|
-
return
|
|
3433
|
-
}
|
|
3434
|
-
function listingDefinesCompareAtProjection(listing) {
|
|
3435
|
-
return "minCompareAtPrice" in listing || "maxCompareAtPrice" in listing;
|
|
3412
|
+
function hasCompleteProductPriceRange(priceRange) {
|
|
3413
|
+
return priceRange?.minVariantPrice?.amount != null && priceRange?.maxVariantPrice?.amount != null;
|
|
3436
3414
|
}
|
|
3437
3415
|
function resolveListingCardPriceRange(product, projectedListing, groups) {
|
|
3438
|
-
|
|
3439
|
-
if (hasCompleteListingPriceProjection(listing)) {
|
|
3416
|
+
if (hasCompleteProductPriceRange(product.priceRange)) {
|
|
3440
3417
|
const groupRange = groups.length > 0 ? aggregateListingPriceRange(groups) : null;
|
|
3441
|
-
const
|
|
3418
|
+
const minCompareAtPrice = product.compareAtPriceRange?.minVariantPrice?.amount ?? groupRange?.minCompareAtPrice ?? null;
|
|
3419
|
+
const maxCompareAtPrice = product.compareAtPriceRange?.maxVariantPrice?.amount ?? groupRange?.maxCompareAtPrice ?? null;
|
|
3442
3420
|
return {
|
|
3443
|
-
minPrice:
|
|
3444
|
-
maxPrice:
|
|
3445
|
-
minCompareAtPrice
|
|
3446
|
-
maxCompareAtPrice
|
|
3447
|
-
isPriceRange:
|
|
3421
|
+
minPrice: product.priceRange.minVariantPrice.amount,
|
|
3422
|
+
maxPrice: product.priceRange.maxVariantPrice.amount,
|
|
3423
|
+
minCompareAtPrice,
|
|
3424
|
+
maxCompareAtPrice,
|
|
3425
|
+
isPriceRange: product.priceRange.isPriceRange ?? product.priceRange.minVariantPrice.amount !== product.priceRange.maxVariantPrice.amount
|
|
3448
3426
|
};
|
|
3449
3427
|
}
|
|
3450
3428
|
if (groups.length > 0) {
|
|
@@ -3510,6 +3488,10 @@ var PRODUCT_PLP_FIND_OPTIONS = {
|
|
|
3510
3488
|
options: { limit: 50, sort: "_order" }
|
|
3511
3489
|
}
|
|
3512
3490
|
};
|
|
3491
|
+
function projectProductToListingShape(product) {
|
|
3492
|
+
const featuredImage = product.featuredImage != null ? product.featuredImage : product.images?.find((image) => image != null);
|
|
3493
|
+
return { ...product, featuredImage };
|
|
3494
|
+
}
|
|
3513
3495
|
function buildProductListingGroupsByOption(args) {
|
|
3514
3496
|
const primaryOptionId = args.primaryOptionId ?? void 0;
|
|
3515
3497
|
if (!primaryOptionId) return [];
|
|
@@ -3526,26 +3508,13 @@ function buildProductListingGroupsByOption(args) {
|
|
|
3526
3508
|
if (variants.length === 0) {
|
|
3527
3509
|
return [];
|
|
3528
3510
|
}
|
|
3529
|
-
const listingBase =
|
|
3530
|
-
const
|
|
3531
|
-
const
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
productPrimaryMediaItemId: extractEntityId(
|
|
3537
|
-
args.product?.primaryMediaItemId ?? null
|
|
3538
|
-
),
|
|
3539
|
-
selectedVariant: null,
|
|
3540
|
-
matchingVariants: orderedVariants,
|
|
3541
|
-
selectedOptionValues: [
|
|
3542
|
-
{
|
|
3543
|
-
id: value.id,
|
|
3544
|
-
swatch: normalizeMatrixSwatch(value.swatch)
|
|
3545
|
-
}
|
|
3546
|
-
]
|
|
3547
|
-
});
|
|
3548
|
-
const groupPrimaryImage = extractEntityId(resolvedMedia.primaryImage) ?? getFirstAvailableVariantPrimaryImage(variants) ?? extractEntityId(args.product?.thumbnail) ?? getFirstMediaId(args.product?.images);
|
|
3511
|
+
const listingBase = buildProductListingGroupProjection(void 0, variants);
|
|
3512
|
+
const normalizedSwatch = normalizeMatrixSwatch(value.swatch);
|
|
3513
|
+
const swatchMediaId = normalizedSwatch?.mediaItemId == null ? null : String(normalizedSwatch.mediaItemId);
|
|
3514
|
+
const groupPrimaryImage = inProductMediaPool(args.product, swatchMediaId) ?? inProductMediaPool(
|
|
3515
|
+
args.product,
|
|
3516
|
+
getFirstAvailableVariantPrimaryImage(variants)
|
|
3517
|
+
) ?? getFirstMediaId(args.product?.images);
|
|
3549
3518
|
return [
|
|
3550
3519
|
{
|
|
3551
3520
|
optionId: primaryOption.id,
|
|
@@ -3618,15 +3587,19 @@ function buildProductListingPageWhere(params) {
|
|
|
3618
3587
|
if (tagIds) clauses.push({ tags: { in: tagIds } });
|
|
3619
3588
|
const minPrice = filters?.price?.min;
|
|
3620
3589
|
if (minPrice != null) {
|
|
3621
|
-
clauses.push({
|
|
3590
|
+
clauses.push({
|
|
3591
|
+
"priceRange.maxVariantPrice.amount": { greater_than_equal: minPrice }
|
|
3592
|
+
});
|
|
3622
3593
|
}
|
|
3623
3594
|
const maxPrice = filters?.price?.max;
|
|
3624
3595
|
if (maxPrice != null) {
|
|
3625
|
-
clauses.push({
|
|
3596
|
+
clauses.push({
|
|
3597
|
+
"priceRange.minVariantPrice.amount": { less_than_equal: maxPrice }
|
|
3598
|
+
});
|
|
3626
3599
|
}
|
|
3627
3600
|
if (filters?.availableForSale != null) {
|
|
3628
3601
|
clauses.push({
|
|
3629
|
-
|
|
3602
|
+
availableForSale: { equals: filters.availableForSale }
|
|
3630
3603
|
});
|
|
3631
3604
|
}
|
|
3632
3605
|
if (clauses.length === 0) return void 0;
|
|
@@ -3851,6 +3824,12 @@ var OrderApi = class extends BaseApi {
|
|
|
3851
3824
|
idempotencyRequestOptions(params.idempotencyKey)
|
|
3852
3825
|
);
|
|
3853
3826
|
}
|
|
3827
|
+
/**
|
|
3828
|
+
* Returns a `PublicOrder`-compatible shape even when the server backs the
|
|
3829
|
+
* response with a Checkout (checkout/order separation, #1285). `orderNumber`
|
|
3830
|
+
* stays the stable cross-window key. A breaking `PublicCheckout` split is a
|
|
3831
|
+
* deferred follow-up (design D10 / Q3-b); do not change this return type here.
|
|
3832
|
+
*/
|
|
3854
3833
|
checkout(params) {
|
|
3855
3834
|
const { body, idempotencyKey } = splitIdempotencyKey(params);
|
|
3856
3835
|
return this.request(
|
|
@@ -4228,17 +4207,19 @@ function mergeProductDetailWithStock(catalog, snapshot) {
|
|
|
4228
4207
|
(sum, variant) => sum + Math.max(0, (variant.stock ?? 0) - (variant.reservedStock ?? 0)),
|
|
4229
4208
|
0
|
|
4230
4209
|
);
|
|
4231
|
-
const { liveStockRequired: _liveStockRequired, ...listingBase } = catalog.listing;
|
|
4232
4210
|
const availableForSale = snapshot.snapshots.some(
|
|
4233
4211
|
(item) => item.status === "available" && item.availableForSale
|
|
4234
4212
|
);
|
|
4213
|
+
const selectedVariantId = typeof catalog.selectedOrFirstAvailableVariant === "object" && catalog.selectedOrFirstAvailableVariant !== null ? String(catalog.selectedOrFirstAvailableVariant.id) : catalog.selectedOrFirstAvailableVariant != null ? String(catalog.selectedOrFirstAvailableVariant) : null;
|
|
4214
|
+
const selectedOrFirstAvailableVariant = selectedVariantId != null ? variants.find((variant) => String(variant.id) === selectedVariantId) ?? selectedVariantId : null;
|
|
4235
4215
|
return {
|
|
4236
4216
|
stockMergeStatus: missingSnapshotCount === 0 ? "complete" : "partial",
|
|
4237
4217
|
product: {
|
|
4238
4218
|
...catalog,
|
|
4239
4219
|
product: { ...catalog.product, totalInventory },
|
|
4240
4220
|
variants,
|
|
4241
|
-
|
|
4221
|
+
availableForSale,
|
|
4222
|
+
selectedOrFirstAvailableVariant
|
|
4242
4223
|
}
|
|
4243
4224
|
};
|
|
4244
4225
|
}
|
|
@@ -4518,6 +4499,7 @@ var INTERNAL_COLLECTIONS = [
|
|
|
4518
4499
|
"commerce-notification-intents",
|
|
4519
4500
|
"product-collection-items",
|
|
4520
4501
|
"order-status-logs",
|
|
4502
|
+
"tenant-commerce-config",
|
|
4521
4503
|
"api-keys",
|
|
4522
4504
|
"personal-access-tokens",
|
|
4523
4505
|
"tenant-entitlements",
|
|
@@ -4542,6 +4524,7 @@ var COLLECTIONS = [
|
|
|
4542
4524
|
"product-collections",
|
|
4543
4525
|
"brands",
|
|
4544
4526
|
"customer-profiles",
|
|
4527
|
+
"customer-profile-stats",
|
|
4545
4528
|
"discounts",
|
|
4546
4529
|
"shipping-policies",
|
|
4547
4530
|
"shipping-zones",
|
|
@@ -4570,8 +4553,6 @@ var COLLECTIONS = [
|
|
|
4570
4553
|
"canvas-edge-types",
|
|
4571
4554
|
"canvas-categories",
|
|
4572
4555
|
"canvas-tags",
|
|
4573
|
-
"canvas-nodes",
|
|
4574
|
-
"canvas-edges",
|
|
4575
4556
|
"video-categories",
|
|
4576
4557
|
"video-tags",
|
|
4577
4558
|
"forms",
|
|
@@ -4606,11 +4587,15 @@ var SERVER_ONLY_COLLECTIONS = [
|
|
|
4606
4587
|
"form-submissions",
|
|
4607
4588
|
"carts",
|
|
4608
4589
|
"cart-items",
|
|
4590
|
+
"checkouts",
|
|
4591
|
+
"checkout-items",
|
|
4609
4592
|
"posts",
|
|
4610
4593
|
"comments",
|
|
4611
4594
|
"reactions",
|
|
4612
4595
|
"bookmarks",
|
|
4613
4596
|
"live-streams",
|
|
4597
|
+
"canvas-nodes",
|
|
4598
|
+
"canvas-edges",
|
|
4614
4599
|
"customer-groups",
|
|
4615
4600
|
"reports",
|
|
4616
4601
|
"community-bans",
|
|
@@ -4788,8 +4773,7 @@ function resolveProductMedia(input) {
|
|
|
4788
4773
|
};
|
|
4789
4774
|
}
|
|
4790
4775
|
const display = resolveProductDisplayMedia({
|
|
4791
|
-
productMediaPool: input.productMediaPool
|
|
4792
|
-
productPrimaryMediaItemId: input.productPrimaryMediaItemId
|
|
4776
|
+
productMediaPool: input.productMediaPool
|
|
4793
4777
|
});
|
|
4794
4778
|
return {
|
|
4795
4779
|
primaryImage: display.primaryImage,
|
|
@@ -4917,8 +4901,7 @@ function resolveProductGallery(input) {
|
|
|
4917
4901
|
if (legacyResolved && legacyResolved.source !== "none") return legacyResolved;
|
|
4918
4902
|
return resolveProductDisplayMedia({
|
|
4919
4903
|
productMediaPool: input.productMediaPool ?? input.pool ?? null,
|
|
4920
|
-
|
|
4921
|
-
listingPrimaryImage: input.listingPrimaryImage
|
|
4904
|
+
featuredImage: input.featuredImage
|
|
4922
4905
|
});
|
|
4923
4906
|
}
|
|
4924
4907
|
|