@01.software/sdk 0.22.0 → 0.23.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 +92 -69
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.js.map +1 -1
- package/dist/const-CMdmNgEs.d.ts +34 -0
- package/dist/const-Cgd4op4V.d.cts +34 -0
- package/dist/index.cjs +50 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +50 -8
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-DeLBmtzd.d.cts → payload-types-D8-G1PiT.d.cts} +129 -8
- package/dist/{payload-types-DeLBmtzd.d.ts → payload-types-D8-G1PiT.d.ts} +129 -8
- 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.map +1 -1
- package/dist/{server-BARh_6zH.d.ts → server-D7FcHj7J.d.ts} +35 -12
- package/dist/{server-BcQr-nGn.d.cts → server-DJcDyOmM.d.cts} +35 -12
- package/dist/server.cjs +9 -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 +9 -1
- package/dist/server.js.map +1 -1
- package/dist/{types-D7iFEsPc.d.cts → types-BQqfXbB2.d.ts} +18 -2
- package/dist/{types-KkuKwsli.d.ts → types-C_kwEIvY.d.cts} +18 -2
- 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 +3 -3
- package/dist/webhook.d.ts +3 -3
- package/package.json +3 -3
- package/dist/const-CfcjPbOu.d.ts +0 -24
- package/dist/const-DraU44bA.d.cts +0 -24
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as Article,
|
|
3
|
-
import { C as CustomerAuth, a as CustomerAuthOptions, S as StockCheckParams, b as StockCheckResponse, L as ListingGroupsParams, P as ProductListingGroupsResponse, A as AddItemParams, U as UpdateItemParams, R as RemoveItemParams, c as ApplyDiscountParams, d as RemoveDiscountParams, e as ClearCartParams, f as CheckoutParams, g as PayloadFindResponse, V as ValidateDiscountParams, h as ValidateDiscountResult, i as CalculateShippingParams, j as CalculateShippingResult, k as ApiQueryOptions, l as ProductListingGroupsQueryOptions, m as ClientConfig, n as CommunityClient, o as ReadOnlyQueryHooks, p as ReadOnlyCollectionClient, q as ClientState } from './server-
|
|
4
|
-
export { v as ApiError, z as AuthError,
|
|
1
|
+
import { d as Cart, e as CartItem, O as Order, f as Product } from './payload-types-D8-G1PiT.cjs';
|
|
2
|
+
export { A as Article, g as ArticleAuthor, h as ArticleCategory, i as ArticleTag, D as Document, I as Image, P as Post, j as PostCategory, k as ProductVariant, T as Tenant, V as Video } from './payload-types-D8-G1PiT.cjs';
|
|
3
|
+
import { C as CustomerAuth, a as CustomerAuthOptions, S as StockCheckParams, b as StockCheckResponse, L as ListingGroupsParams, P as ProductListingGroupsResponse, A as AddItemParams, U as UpdateItemParams, R as RemoveItemParams, c as ApplyDiscountParams, d as RemoveDiscountParams, e as ClearCartParams, f as CheckoutParams, g as PayloadFindResponse, V as ValidateDiscountParams, h as ValidateDiscountResult, i as CalculateShippingParams, j as CalculateShippingResult, k as ApiQueryOptions, l as ProductListingGroupsQueryOptions, m as ClientConfig, n as CommunityClient, o as ReadOnlyQueryHooks, p as ReadOnlyCollectionClient, q as ClientState } from './server-DJcDyOmM.cjs';
|
|
4
|
+
export { v as ApiError, z as AuthError, aV as BanCustomerParams, af as BaseApi, ap as BulkImportFulfillmentsParams, aq as BulkImportFulfillmentsResponse, aB as CartApi, aC as CartApiOptions, ac as ClientMetadata, ab as ClientServerConfig, aL as CollectionClient, b3 as CollectionDetailQueryParams, b9 as CollectionHooks, b4 as CollectionInfiniteQueryParams, aI as CollectionQueryBuilder, b2 as CollectionQueryParams, aU as CommunityBan, aQ as CommunityClientOptions, aR as CommunityPost, w as ConfigError, H as ConflictError, au as CreateFulfillmentParams, an as CreateOrderParams, ar as CreateReturnParams, aX as CustomerAuthResponse, ba as CustomerHooks, b0 as CustomerLoginData, a_ as CustomerProfile, aY as CustomerRefreshResponse, a$ as CustomerRegisterData, aZ as CustomerRegisterResponse, ak as CustomerSnapshot, r as DebugConfig, D as DeepPartial, ax as DiscountApi, ay as DiscountApiOptions, E as ExtractArrayType, aN as GenerateMetadataOptions, G as GoneError, b7 as InfiniteQueryOptions, aS as ModerationApi, aT as ModerationApiOptions, N as NetworkError, F as NotFoundError, ai as OrderApi, aj as OrderApiOptions, ad as PaginationMeta, ae as PayloadMutationResponse, B as PermissionError, aD as ProductApi, aE as ProductApiOptions, bl as ProductListingGroup, aF as ProductListingGroupSummary, aG as ProductListingGroupsItem, bf as ProductListingProductShape, bk as ProductListingProjection, bj as ProductOptionMatrix, bh as ProductOptionMatrixOption, bg as ProductOptionMatrixValue, bi as ProductOptionMatrixVariant, bd as ProductOptionShape, bc as ProductOptionValueShape, be as ProductVariantShape, bb as QueryHooks, b5 as QueryOptions, I as RateLimitError, aK as ReadOnlyQueryBuilder, ah as RequestOptions, s as RetryConfig, am as ReturnItem, al as ReturnReason, av as ReturnWithRefundParams, t as SDKError, ag as ServerApiOptions, a9 as ServerClient, a9 as ServerClientType, aM as ServerCollectionClient, aJ as ServerCollectionQueryBuilder, aO as ServerCommerceClient, aP as ServerCommerceClientOptions, x as ServiceUnavailableError, az as ShippingApi, aA as ShippingApiOptions, aH as StockCheckResult, b8 as SuspenseInfiniteQueryOptions, b6 as SuspenseQueryOptions, T as TimeoutError, aW as UnbanCustomerParams, aw as UpdateFulfillmentParams, ao as UpdateOrderParams, b1 as UpdateProfileData, as as UpdateReturnParams, at as UpdateTransactionParams, y as UsageLimitError, u as ValidationError, bs as buildProductListingGroupsByOption, br as buildProductListingProjection, bm as buildProductOptionMatrix, a3 as createAuthError, a6 as createConflictError, a5 as createNotFoundError, a4 as createPermissionError, a7 as createRateLimitError, a8 as createServerClient, bp as getAvailableOptionValues, bn as getSelectedValueByOptionId, O as isApiError, _ as isAuthError, Q as isConfigError, a1 as isConflictError, X as isGoneError, K as isNetworkError, a0 as isNotFoundError, $ as isPermissionError, a2 as isRateLimitError, J as isSDKError, Y as isServiceUnavailableError, W as isTimeoutError, Z as isUsageLimitError, M as isValidationError, bo as normalizeSelectedValueIds, aa as resolveApiUrl, bq as resolveVariantForSelection } from './server-DJcDyOmM.cjs';
|
|
5
5
|
import { QueryClient } from '@tanstack/react-query';
|
|
6
|
-
export { C as CollectionType } from './types-
|
|
7
|
-
import { P as PublicCollection } from './const-
|
|
8
|
-
export {
|
|
6
|
+
export { C as CollectionType } from './types-C_kwEIvY.cjs';
|
|
7
|
+
import { P as PublicCollection } from './const-Cgd4op4V.cjs';
|
|
8
|
+
export { b as COLLECTIONS, C as Collection, I as INTERNAL_COLLECTIONS, e as InternalCollection, d as SERVER_COLLECTIONS, c as SERVER_ONLY_COLLECTIONS, S as ServerCollection, a as ServerOnlyCollection } from './const-Cgd4op4V.cjs';
|
|
9
9
|
export { a as RealtimeConnection, R as RealtimeEvent, b as RealtimeListener } from './realtime-D7HtUpqt.cjs';
|
|
10
10
|
export { CUSTOMER_PASSWORD_RESET_OPERATION, CustomerAuthWebhookEvent, CustomerAuthWebhookHandlers, CustomerPasswordResetWebhookData, CustomerPasswordResetWebhookEvent, WebhookEvent, WebhookHandler, WebhookOperation, WebhookOptions, createCustomerAuthWebhookHandler, createTypedWebhookHandler, handleWebhook, isCustomerPasswordResetWebhookEvent, isValidWebhookEvent } from './webhook.cjs';
|
|
11
11
|
export { b as IMAGE_SIZES, I as ImageData, a as ImagePalette, f as ImagePlaceholderOptions, d as getImageLqip, e as getImagePalette, h as getImagePlaceholderStyle, c as getImageSrcSet, g as getImageUrl } from './image-TT8lTsk5.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as Article,
|
|
3
|
-
import { C as CustomerAuth, a as CustomerAuthOptions, S as StockCheckParams, b as StockCheckResponse, L as ListingGroupsParams, P as ProductListingGroupsResponse, A as AddItemParams, U as UpdateItemParams, R as RemoveItemParams, c as ApplyDiscountParams, d as RemoveDiscountParams, e as ClearCartParams, f as CheckoutParams, g as PayloadFindResponse, V as ValidateDiscountParams, h as ValidateDiscountResult, i as CalculateShippingParams, j as CalculateShippingResult, k as ApiQueryOptions, l as ProductListingGroupsQueryOptions, m as ClientConfig, n as CommunityClient, o as ReadOnlyQueryHooks, p as ReadOnlyCollectionClient, q as ClientState } from './server-
|
|
4
|
-
export { v as ApiError, z as AuthError,
|
|
1
|
+
import { d as Cart, e as CartItem, O as Order, f as Product } from './payload-types-D8-G1PiT.js';
|
|
2
|
+
export { A as Article, g as ArticleAuthor, h as ArticleCategory, i as ArticleTag, D as Document, I as Image, P as Post, j as PostCategory, k as ProductVariant, T as Tenant, V as Video } from './payload-types-D8-G1PiT.js';
|
|
3
|
+
import { C as CustomerAuth, a as CustomerAuthOptions, S as StockCheckParams, b as StockCheckResponse, L as ListingGroupsParams, P as ProductListingGroupsResponse, A as AddItemParams, U as UpdateItemParams, R as RemoveItemParams, c as ApplyDiscountParams, d as RemoveDiscountParams, e as ClearCartParams, f as CheckoutParams, g as PayloadFindResponse, V as ValidateDiscountParams, h as ValidateDiscountResult, i as CalculateShippingParams, j as CalculateShippingResult, k as ApiQueryOptions, l as ProductListingGroupsQueryOptions, m as ClientConfig, n as CommunityClient, o as ReadOnlyQueryHooks, p as ReadOnlyCollectionClient, q as ClientState } from './server-D7FcHj7J.js';
|
|
4
|
+
export { v as ApiError, z as AuthError, aV as BanCustomerParams, af as BaseApi, ap as BulkImportFulfillmentsParams, aq as BulkImportFulfillmentsResponse, aB as CartApi, aC as CartApiOptions, ac as ClientMetadata, ab as ClientServerConfig, aL as CollectionClient, b3 as CollectionDetailQueryParams, b9 as CollectionHooks, b4 as CollectionInfiniteQueryParams, aI as CollectionQueryBuilder, b2 as CollectionQueryParams, aU as CommunityBan, aQ as CommunityClientOptions, aR as CommunityPost, w as ConfigError, H as ConflictError, au as CreateFulfillmentParams, an as CreateOrderParams, ar as CreateReturnParams, aX as CustomerAuthResponse, ba as CustomerHooks, b0 as CustomerLoginData, a_ as CustomerProfile, aY as CustomerRefreshResponse, a$ as CustomerRegisterData, aZ as CustomerRegisterResponse, ak as CustomerSnapshot, r as DebugConfig, D as DeepPartial, ax as DiscountApi, ay as DiscountApiOptions, E as ExtractArrayType, aN as GenerateMetadataOptions, G as GoneError, b7 as InfiniteQueryOptions, aS as ModerationApi, aT as ModerationApiOptions, N as NetworkError, F as NotFoundError, ai as OrderApi, aj as OrderApiOptions, ad as PaginationMeta, ae as PayloadMutationResponse, B as PermissionError, aD as ProductApi, aE as ProductApiOptions, bl as ProductListingGroup, aF as ProductListingGroupSummary, aG as ProductListingGroupsItem, bf as ProductListingProductShape, bk as ProductListingProjection, bj as ProductOptionMatrix, bh as ProductOptionMatrixOption, bg as ProductOptionMatrixValue, bi as ProductOptionMatrixVariant, bd as ProductOptionShape, bc as ProductOptionValueShape, be as ProductVariantShape, bb as QueryHooks, b5 as QueryOptions, I as RateLimitError, aK as ReadOnlyQueryBuilder, ah as RequestOptions, s as RetryConfig, am as ReturnItem, al as ReturnReason, av as ReturnWithRefundParams, t as SDKError, ag as ServerApiOptions, a9 as ServerClient, a9 as ServerClientType, aM as ServerCollectionClient, aJ as ServerCollectionQueryBuilder, aO as ServerCommerceClient, aP as ServerCommerceClientOptions, x as ServiceUnavailableError, az as ShippingApi, aA as ShippingApiOptions, aH as StockCheckResult, b8 as SuspenseInfiniteQueryOptions, b6 as SuspenseQueryOptions, T as TimeoutError, aW as UnbanCustomerParams, aw as UpdateFulfillmentParams, ao as UpdateOrderParams, b1 as UpdateProfileData, as as UpdateReturnParams, at as UpdateTransactionParams, y as UsageLimitError, u as ValidationError, bs as buildProductListingGroupsByOption, br as buildProductListingProjection, bm as buildProductOptionMatrix, a3 as createAuthError, a6 as createConflictError, a5 as createNotFoundError, a4 as createPermissionError, a7 as createRateLimitError, a8 as createServerClient, bp as getAvailableOptionValues, bn as getSelectedValueByOptionId, O as isApiError, _ as isAuthError, Q as isConfigError, a1 as isConflictError, X as isGoneError, K as isNetworkError, a0 as isNotFoundError, $ as isPermissionError, a2 as isRateLimitError, J as isSDKError, Y as isServiceUnavailableError, W as isTimeoutError, Z as isUsageLimitError, M as isValidationError, bo as normalizeSelectedValueIds, aa as resolveApiUrl, bq as resolveVariantForSelection } from './server-D7FcHj7J.js';
|
|
5
5
|
import { QueryClient } from '@tanstack/react-query';
|
|
6
|
-
export { C as CollectionType } from './types-
|
|
7
|
-
import { P as PublicCollection } from './const-
|
|
8
|
-
export {
|
|
6
|
+
export { C as CollectionType } from './types-BQqfXbB2.js';
|
|
7
|
+
import { P as PublicCollection } from './const-CMdmNgEs.js';
|
|
8
|
+
export { b as COLLECTIONS, C as Collection, I as INTERNAL_COLLECTIONS, e as InternalCollection, d as SERVER_COLLECTIONS, c as SERVER_ONLY_COLLECTIONS, S as ServerCollection, a as ServerOnlyCollection } from './const-CMdmNgEs.js';
|
|
9
9
|
export { a as RealtimeConnection, R as RealtimeEvent, b as RealtimeListener } from './realtime-D7HtUpqt.js';
|
|
10
10
|
export { CUSTOMER_PASSWORD_RESET_OPERATION, CustomerAuthWebhookEvent, CustomerAuthWebhookHandlers, CustomerPasswordResetWebhookData, CustomerPasswordResetWebhookEvent, WebhookEvent, WebhookHandler, WebhookOperation, WebhookOptions, createCustomerAuthWebhookHandler, createTypedWebhookHandler, handleWebhook, isCustomerPasswordResetWebhookEvent, isValidWebhookEvent } from './webhook.js';
|
|
11
11
|
export { b as IMAGE_SIZES, I as ImageData, a as ImagePalette, f as ImagePlaceholderOptions, d as getImageLqip, e as getImagePalette, h as getImagePlaceholderStyle, c as getImageSrcSet, g as getImageUrl } from './image-TT8lTsk5.js';
|
package/dist/index.js
CHANGED
|
@@ -234,6 +234,8 @@ var CollectionQueryBuilder = class {
|
|
|
234
234
|
);
|
|
235
235
|
}
|
|
236
236
|
};
|
|
237
|
+
var ServerCollectionQueryBuilder = class extends CollectionQueryBuilder {
|
|
238
|
+
};
|
|
237
239
|
|
|
238
240
|
// src/core/collection/http-client.ts
|
|
239
241
|
import { stringify } from "qs-esm";
|
|
@@ -1072,6 +1074,11 @@ var CollectionClient = class extends HttpClient {
|
|
|
1072
1074
|
return this.parseMutationResponse(response);
|
|
1073
1075
|
}
|
|
1074
1076
|
};
|
|
1077
|
+
var ServerCollectionClient = class extends CollectionClient {
|
|
1078
|
+
from(collection) {
|
|
1079
|
+
return new ServerCollectionQueryBuilder(this, collection);
|
|
1080
|
+
}
|
|
1081
|
+
};
|
|
1075
1082
|
var ReadOnlyCollectionClient = class extends HttpClient {
|
|
1076
1083
|
from(collection) {
|
|
1077
1084
|
return new ReadOnlyCollectionQueryBuilder(this, collection);
|
|
@@ -1153,8 +1160,8 @@ var COLLECTIONS = [
|
|
|
1153
1160
|
"transactions",
|
|
1154
1161
|
"customers",
|
|
1155
1162
|
"customer-profiles",
|
|
1163
|
+
"customer-profile-lists",
|
|
1156
1164
|
"customer-addresses",
|
|
1157
|
-
"customer-groups",
|
|
1158
1165
|
"carts",
|
|
1159
1166
|
"cart-items",
|
|
1160
1167
|
"discounts",
|
|
@@ -1210,6 +1217,11 @@ var COLLECTIONS = [
|
|
|
1210
1217
|
"event-occurrences",
|
|
1211
1218
|
"event-tags"
|
|
1212
1219
|
];
|
|
1220
|
+
var SERVER_ONLY_COLLECTIONS = ["customer-groups"];
|
|
1221
|
+
var SERVER_COLLECTIONS = [
|
|
1222
|
+
...COLLECTIONS,
|
|
1223
|
+
...SERVER_ONLY_COLLECTIONS
|
|
1224
|
+
];
|
|
1213
1225
|
|
|
1214
1226
|
// src/core/api/parse-response.ts
|
|
1215
1227
|
async function parseApiResponse(response, endpoint) {
|
|
@@ -2628,7 +2640,7 @@ var ServerClient = class {
|
|
|
2628
2640
|
unbanCustomer: moderationApi.unbanCustomer.bind(moderationApi)
|
|
2629
2641
|
}
|
|
2630
2642
|
});
|
|
2631
|
-
this.collections = new
|
|
2643
|
+
this.collections = new ServerCollectionClient(
|
|
2632
2644
|
this.config.publishableKey,
|
|
2633
2645
|
this.config.secretKey,
|
|
2634
2646
|
void 0,
|
|
@@ -2950,12 +2962,24 @@ function getVariantPrimaryImage(variant) {
|
|
|
2950
2962
|
if (!variant) return null;
|
|
2951
2963
|
return extractEntityId(variant.thumbnail) ?? getFirstMediaId(variant.images);
|
|
2952
2964
|
}
|
|
2965
|
+
function getFirstAvailableVariantPrimaryImage(variants) {
|
|
2966
|
+
const orderedVariants = [...variants].sort(compareVariantOrder);
|
|
2967
|
+
for (const variant of orderedVariants) {
|
|
2968
|
+
if (!isVariantAvailableForSale(variant)) continue;
|
|
2969
|
+
const image = getVariantPrimaryImage(variant);
|
|
2970
|
+
if (image != null) return image;
|
|
2971
|
+
}
|
|
2972
|
+
return null;
|
|
2973
|
+
}
|
|
2953
2974
|
function normalizeOptionValue(value, fallbackOptionId) {
|
|
2954
2975
|
return {
|
|
2955
2976
|
id: String(value.id),
|
|
2956
2977
|
optionId: getRelationID(value.option) ?? fallbackOptionId,
|
|
2957
2978
|
label: value.value || value.slug || String(value.id),
|
|
2958
2979
|
slug: value.slug ?? null,
|
|
2980
|
+
swatchColor: value.swatchColor ?? null,
|
|
2981
|
+
thumbnail: value.thumbnail ?? null,
|
|
2982
|
+
images: value.images ?? null,
|
|
2959
2983
|
order: value._order ?? value["_product-option-values_values_order"] ?? ""
|
|
2960
2984
|
};
|
|
2961
2985
|
}
|
|
@@ -2984,7 +3008,10 @@ function buildProductOptionMatrix({
|
|
|
2984
3008
|
const valuesById = /* @__PURE__ */ new Map();
|
|
2985
3009
|
for (const rawValue of option.values?.docs ?? []) {
|
|
2986
3010
|
if (!isProductOptionValueDoc(rawValue)) continue;
|
|
2987
|
-
const normalizedValue = normalizeOptionValue(
|
|
3011
|
+
const normalizedValue = normalizeOptionValue(
|
|
3012
|
+
rawValue,
|
|
3013
|
+
String(option.id)
|
|
3014
|
+
);
|
|
2988
3015
|
valuesById.set(normalizedValue.id, normalizedValue);
|
|
2989
3016
|
}
|
|
2990
3017
|
return {
|
|
@@ -2996,7 +3023,9 @@ function buildProductOptionMatrix({
|
|
|
2996
3023
|
)
|
|
2997
3024
|
};
|
|
2998
3025
|
}).sort((left, right) => compareOrder(left.order, right.order));
|
|
2999
|
-
const optionById = new Map(
|
|
3026
|
+
const optionById = new Map(
|
|
3027
|
+
normalizedOptions.map((option) => [option.id, option])
|
|
3028
|
+
);
|
|
3000
3029
|
const valueById = /* @__PURE__ */ new Map();
|
|
3001
3030
|
const valueToOptionId = /* @__PURE__ */ new Map();
|
|
3002
3031
|
for (const option of normalizedOptions) {
|
|
@@ -3075,10 +3104,12 @@ function compareVariantOrder(a, b) {
|
|
|
3075
3104
|
function isVariantAvailableForSale(variant) {
|
|
3076
3105
|
if (variant.isActive === false) return false;
|
|
3077
3106
|
if (variant.isUnlimited) return true;
|
|
3078
|
-
return (variant.stock ?? 0) > 0;
|
|
3107
|
+
return (variant.stock ?? 0) - (variant.reservedStock ?? 0) > 0;
|
|
3079
3108
|
}
|
|
3080
3109
|
function getMinMax(values) {
|
|
3081
|
-
const numbers = values.filter(
|
|
3110
|
+
const numbers = values.filter(
|
|
3111
|
+
(value) => typeof value === "number"
|
|
3112
|
+
);
|
|
3082
3113
|
if (numbers.length === 0) {
|
|
3083
3114
|
return { min: null, max: null };
|
|
3084
3115
|
}
|
|
@@ -3089,7 +3120,9 @@ function getMinMax(values) {
|
|
|
3089
3120
|
}
|
|
3090
3121
|
function buildProductListingProjection(product, variants) {
|
|
3091
3122
|
const orderedVariants = [...variants].sort(compareVariantOrder);
|
|
3092
|
-
const activeVariants = orderedVariants.filter(
|
|
3123
|
+
const activeVariants = orderedVariants.filter(
|
|
3124
|
+
(variant) => variant.isActive !== false
|
|
3125
|
+
);
|
|
3093
3126
|
const availableVariants = activeVariants.filter(isVariantAvailableForSale);
|
|
3094
3127
|
const selectionHintVariant = availableVariants[0] ?? activeVariants[0] ?? null;
|
|
3095
3128
|
const { min: minPrice, max: maxPrice } = getMinMax(
|
|
@@ -3128,7 +3161,9 @@ function buildProductListingGroupsByOption(args) {
|
|
|
3128
3161
|
return [];
|
|
3129
3162
|
}
|
|
3130
3163
|
const listingBase = buildProductListingProjection(void 0, variants);
|
|
3164
|
+
const optionValuePrimaryImage = extractEntityId(value.thumbnail) ?? getFirstMediaId(value.images);
|
|
3131
3165
|
const productFallbackImage = extractEntityId(args.product?.thumbnail) ?? getFirstMediaId(args.product?.images);
|
|
3166
|
+
const groupPrimaryImage = getFirstAvailableVariantPrimaryImage(variants) ?? optionValuePrimaryImage ?? productFallbackImage;
|
|
3132
3167
|
return [
|
|
3133
3168
|
{
|
|
3134
3169
|
optionId: primaryOption.id,
|
|
@@ -3136,12 +3171,15 @@ function buildProductListingGroupsByOption(args) {
|
|
|
3136
3171
|
optionValueId: value.id,
|
|
3137
3172
|
optionValueLabel: value.label,
|
|
3138
3173
|
optionValueSlug: value.slug,
|
|
3174
|
+
optionValueSwatchColor: value.swatchColor ?? null,
|
|
3175
|
+
optionValueThumbnail: value.thumbnail ?? null,
|
|
3176
|
+
optionValueImages: value.images ?? null,
|
|
3139
3177
|
variantIds: variants.map((variant) => String(variant.id)),
|
|
3140
3178
|
variantCount: variants.length,
|
|
3141
3179
|
variants,
|
|
3142
3180
|
listing: {
|
|
3143
3181
|
...listingBase,
|
|
3144
|
-
primaryImage:
|
|
3182
|
+
primaryImage: groupPrimaryImage
|
|
3145
3183
|
}
|
|
3146
3184
|
}
|
|
3147
3185
|
];
|
|
@@ -3465,7 +3503,11 @@ export {
|
|
|
3465
3503
|
ReadOnlyCollectionClient,
|
|
3466
3504
|
RealtimeConnection,
|
|
3467
3505
|
SDKError,
|
|
3506
|
+
SERVER_COLLECTIONS,
|
|
3507
|
+
SERVER_ONLY_COLLECTIONS,
|
|
3468
3508
|
ServerClient,
|
|
3509
|
+
ServerCollectionClient,
|
|
3510
|
+
ServerCollectionQueryBuilder,
|
|
3469
3511
|
ServerCommerceClient,
|
|
3470
3512
|
ServiceUnavailableError,
|
|
3471
3513
|
ShippingApi,
|