@01.software/sdk 0.40.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 +12 -1
- package/dist/client.cjs +4 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +3 -3
- package/dist/client.d.ts +3 -3
- package/dist/client.js +4 -1
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-VYwYi6u6.d.cts → collection-client-Bymfni8u.d.cts} +1 -1
- package/dist/{collection-client-CKFa99C6.d.ts → collection-client-CN4lj6gi.d.ts} +1 -1
- package/dist/index.cjs +18 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +18 -5
- package/dist/index.js.map +1 -1
- package/dist/query.d.cts +2 -2
- package/dist/query.d.ts +2 -2
- package/dist/server.cjs +4 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +4 -1
- package/dist/server.js.map +1 -1
- package/dist/{types-D5uHrPLr.d.cts → types-Bl-m9ttd.d.cts} +31 -1
- package/dist/{types-Umd-YTjM.d.ts → types-CHrzs2GB.d.ts} +31 -1
- package/package.json +6 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DebugConfig, x as RetryConfig, f as ApiQueryOptions, P as PayloadFindResponse, n as PayloadMutationResponse, ax as PublicReadQueryOptions } from './types-
|
|
1
|
+
import { D as DebugConfig, x as RetryConfig, f as ApiQueryOptions, P as PayloadFindResponse, n as PayloadMutationResponse, ax as PublicReadQueryOptions } from './types-Bl-m9ttd.cjs';
|
|
2
2
|
import { GenerateMetadataOptions, Metadata } from './metadata.cjs';
|
|
3
3
|
import { S as ServerCollection, P as PublicCollection } from './const-4BUtUdGU.cjs';
|
|
4
4
|
import { C as CollectionType } from './types-BvpjooU-.cjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DebugConfig, x as RetryConfig, f as ApiQueryOptions, P as PayloadFindResponse, n as PayloadMutationResponse, ax as PublicReadQueryOptions } from './types-
|
|
1
|
+
import { D as DebugConfig, x as RetryConfig, f as ApiQueryOptions, P as PayloadFindResponse, n as PayloadMutationResponse, ax as PublicReadQueryOptions } from './types-CHrzs2GB.js';
|
|
2
2
|
import { GenerateMetadataOptions, Metadata } from './metadata.js';
|
|
3
3
|
import { S as ServerCollection, P as PublicCollection } from './const-ymprfiPf.js';
|
|
4
4
|
import { C as CollectionType } from './types-Bh2p-EMc.js';
|
package/dist/index.cjs
CHANGED
|
@@ -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,6 +125,7 @@ __export(src_exports, {
|
|
|
123
125
|
normalizeProductSelectionFromMatrix: () => normalizeProductSelectionFromMatrix,
|
|
124
126
|
normalizeSelectedValueIds: () => normalizeSelectedValueIds,
|
|
125
127
|
parseProductSelection: () => parseProductSelection,
|
|
128
|
+
projectProductToListingShape: () => projectProductToListingShape,
|
|
126
129
|
resolveFeaturedImagePointer: () => resolveFeaturedImagePointer,
|
|
127
130
|
resolveProductDisplayMedia: () => resolveProductDisplayMedia,
|
|
128
131
|
resolveProductGallery: () => resolveProductGallery,
|
|
@@ -2870,10 +2873,9 @@ function buildSelectionMedia(detail, selectedVariant, matchingVariants, selected
|
|
|
2870
2873
|
}
|
|
2871
2874
|
function buildSelectionStock(selectedVariant, matchingVariants) {
|
|
2872
2875
|
if (selectedVariant) {
|
|
2873
|
-
const availableStock =
|
|
2874
|
-
const isActive = selectedVariant.isActive !== false;
|
|
2876
|
+
const availableStock = getVariantAvailableStock(selectedVariant);
|
|
2875
2877
|
return {
|
|
2876
|
-
availableForSale:
|
|
2878
|
+
availableForSale: getVariantAvailableForSale(selectedVariant),
|
|
2877
2879
|
isUnlimited: selectedVariant.isUnlimited,
|
|
2878
2880
|
stock: selectedVariant.stock,
|
|
2879
2881
|
reservedStock: selectedVariant.reservedStock,
|
|
@@ -2894,7 +2896,7 @@ function buildAvailableValueStock(variants) {
|
|
|
2894
2896
|
);
|
|
2895
2897
|
const isUnlimited = activeVariants.some((variant) => variant.isUnlimited);
|
|
2896
2898
|
const availableStock = isUnlimited ? null : activeVariants.reduce(
|
|
2897
|
-
(sum, variant) => sum +
|
|
2899
|
+
(sum, variant) => sum + (getVariantAvailableStock(variant) ?? 0),
|
|
2898
2900
|
0
|
|
2899
2901
|
);
|
|
2900
2902
|
return {
|
|
@@ -3256,11 +3258,18 @@ function compareVariantOrder(a, b) {
|
|
|
3256
3258
|
const bId = String(getRelationID(b.id) ?? "");
|
|
3257
3259
|
return aId.localeCompare(bId);
|
|
3258
3260
|
}
|
|
3259
|
-
function
|
|
3261
|
+
function getVariantAvailableForSale(variant) {
|
|
3260
3262
|
if (variant.isActive === false) return false;
|
|
3261
3263
|
if (variant.isUnlimited) return true;
|
|
3262
3264
|
return (variant.stock ?? 0) - (variant.reservedStock ?? 0) > 0;
|
|
3263
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
|
+
}
|
|
3264
3273
|
function sortVariantsForMediaSelection(variants) {
|
|
3265
3274
|
const orderedVariants = [...variants].sort(compareVariantOrder);
|
|
3266
3275
|
const activeVariants = orderedVariants.filter(
|
|
@@ -3479,6 +3488,10 @@ var PRODUCT_PLP_FIND_OPTIONS = {
|
|
|
3479
3488
|
options: { limit: 50, sort: "_order" }
|
|
3480
3489
|
}
|
|
3481
3490
|
};
|
|
3491
|
+
function projectProductToListingShape(product) {
|
|
3492
|
+
const featuredImage = product.featuredImage != null ? product.featuredImage : product.images?.find((image) => image != null);
|
|
3493
|
+
return { ...product, featuredImage };
|
|
3494
|
+
}
|
|
3482
3495
|
function buildProductListingGroupsByOption(args) {
|
|
3483
3496
|
const primaryOptionId = args.primaryOptionId ?? void 0;
|
|
3484
3497
|
if (!primaryOptionId) return [];
|