@shopkit/data-layer 1.7.0 → 1.8.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/dist/adapters/index.d.mts +2 -2
- package/dist/adapters/index.d.ts +2 -2
- package/dist/adapters/index.js +279 -1
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/index.mjs +279 -1
- package/dist/adapters/index.mjs.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +279 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +279 -1
- package/dist/index.mjs.map +1 -1
- package/dist/{interface-BGV7d5F8.d.ts → interface-CWuOTUIW.d.ts} +8 -1
- package/dist/{interface-CgPiwpPe.d.mts → interface-D4gQCRsx.d.mts} +8 -1
- package/dist/models/index.d.mts +170 -1
- package/dist/models/index.d.ts +170 -1
- package/dist/{service-Cb074q9F.d.ts → service-BEiNHL9V.d.mts} +11 -2
- package/dist/{service-BPzeuSLS.d.mts → service-C4eDXKmf.d.ts} +11 -2
- package/dist/static-params/index.d.mts +1 -1
- package/dist/static-params/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { I as ICommerceClient } from './interface-
|
|
2
|
-
import { I as IShopifyConfig, L as LoggerConfig, a as ICustomConfig, C as CustomBackendClient, S as ShopifyCommerceClient } from './service-
|
|
3
|
-
export { EAvailability, ECollectionSortKey, EFulfillmentStatus, EOrderSortKey, EOrderStatus, EPaymentStatus, EProductSortKey, IAddToCartRequest, IAddress, IArticleByHandleRequest, IBaseQueryParams, IBlogArticleRequest, ICartItemRequest, ICollectionFilterRequest, ICollectionQueryRequest, ICollectionsByhandlesRequest, ICreateCheckoutRequest, ICustomerQueryRequest, ICustomerRequest, IFetchRequest, IGetArticleRequest, IGraphqlRequest, IImage, IMetafield, IMoney, IOptionsRequest, IOrderByIdRequest, IOrderHistoryRequest, IOrderQueryRequest, IOrderRequest, IPaginationParams, IProductFilters, IProductQueryReqest, IProductRecommendationsRequest, IProductsByHandlesRequest, IQueryCollectionsInclude, IQueryCollectionsRequest, IRemoveFromCartRequest, IResponse, IResponseMeta, ISeo, ISingleCartRequest, ISingleCollectionRequest, ISingleCustomerRequest, ISingleOrderRequest, ISingleProductRequest, ITrendingArticleRequest, IUpdateCartRequest, IUpdateCustomerRequest, IUpdateOrderRequest, QueryCollectionsErrorCode, QuerySortDirection } from './models/index.mjs';
|
|
1
|
+
import { I as ICommerceClient } from './interface-D4gQCRsx.mjs';
|
|
2
|
+
import { I as IShopifyConfig, L as LoggerConfig, a as ICustomConfig, C as CustomBackendClient, S as ShopifyCommerceClient } from './service-BEiNHL9V.mjs';
|
|
3
|
+
export { CollectionVariantCardsErrorCode, CollectionVariantCardsSortKey, EAvailability, ECollectionSortKey, EFulfillmentStatus, EOrderSortKey, EOrderStatus, EPaymentStatus, EProductSortKey, IAddToCartRequest, IAddress, IArticleByHandleRequest, IBaseQueryParams, IBlogArticleRequest, ICartItemRequest, ICollectionFilterRequest, ICollectionQueryRequest, ICollectionsByhandlesRequest, ICreateCheckoutRequest, ICustomerQueryRequest, ICustomerRequest, IFetchRequest, IGetArticleRequest, IGetCollectionVariantCardsRequest, IGraphqlRequest, IImage, IMetafield, IMoney, IOptionsRequest, IOrderByIdRequest, IOrderHistoryRequest, IOrderQueryRequest, IOrderRequest, IPaginationParams, IProductFilters, IProductQueryReqest, IProductRecommendationsRequest, IProductsByHandlesRequest, IQueryCollectionsInclude, IQueryCollectionsRequest, IRemoveFromCartRequest, IResponse, IResponseMeta, ISeo, ISingleCartRequest, ISingleCollectionRequest, ISingleCustomerRequest, ISingleOrderRequest, ISingleProductRequest, ITrendingArticleRequest, IUpdateCartRequest, IUpdateCustomerRequest, IUpdateOrderRequest, PriceRangeDto, ProductCardDto, ProductCardImageDto, QueryCollectionsErrorCode, QuerySortDirection, VariantCardDto, VariantCardImageDto, VariantCardOptionDto, VariantCardsPageDto } from './models/index.mjs';
|
|
4
4
|
export { createCollectionProductStaticParams, createCollectionStaticParams, createProductStaticParams, createProductViaCollectionsStaticParams } from './static-params/index.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { I as ICommerceClient } from './interface-
|
|
2
|
-
import { I as IShopifyConfig, L as LoggerConfig, a as ICustomConfig, C as CustomBackendClient, S as ShopifyCommerceClient } from './service-
|
|
3
|
-
export { EAvailability, ECollectionSortKey, EFulfillmentStatus, EOrderSortKey, EOrderStatus, EPaymentStatus, EProductSortKey, IAddToCartRequest, IAddress, IArticleByHandleRequest, IBaseQueryParams, IBlogArticleRequest, ICartItemRequest, ICollectionFilterRequest, ICollectionQueryRequest, ICollectionsByhandlesRequest, ICreateCheckoutRequest, ICustomerQueryRequest, ICustomerRequest, IFetchRequest, IGetArticleRequest, IGraphqlRequest, IImage, IMetafield, IMoney, IOptionsRequest, IOrderByIdRequest, IOrderHistoryRequest, IOrderQueryRequest, IOrderRequest, IPaginationParams, IProductFilters, IProductQueryReqest, IProductRecommendationsRequest, IProductsByHandlesRequest, IQueryCollectionsInclude, IQueryCollectionsRequest, IRemoveFromCartRequest, IResponse, IResponseMeta, ISeo, ISingleCartRequest, ISingleCollectionRequest, ISingleCustomerRequest, ISingleOrderRequest, ISingleProductRequest, ITrendingArticleRequest, IUpdateCartRequest, IUpdateCustomerRequest, IUpdateOrderRequest, QueryCollectionsErrorCode, QuerySortDirection } from './models/index.js';
|
|
1
|
+
import { I as ICommerceClient } from './interface-CWuOTUIW.js';
|
|
2
|
+
import { I as IShopifyConfig, L as LoggerConfig, a as ICustomConfig, C as CustomBackendClient, S as ShopifyCommerceClient } from './service-C4eDXKmf.js';
|
|
3
|
+
export { CollectionVariantCardsErrorCode, CollectionVariantCardsSortKey, EAvailability, ECollectionSortKey, EFulfillmentStatus, EOrderSortKey, EOrderStatus, EPaymentStatus, EProductSortKey, IAddToCartRequest, IAddress, IArticleByHandleRequest, IBaseQueryParams, IBlogArticleRequest, ICartItemRequest, ICollectionFilterRequest, ICollectionQueryRequest, ICollectionsByhandlesRequest, ICreateCheckoutRequest, ICustomerQueryRequest, ICustomerRequest, IFetchRequest, IGetArticleRequest, IGetCollectionVariantCardsRequest, IGraphqlRequest, IImage, IMetafield, IMoney, IOptionsRequest, IOrderByIdRequest, IOrderHistoryRequest, IOrderQueryRequest, IOrderRequest, IPaginationParams, IProductFilters, IProductQueryReqest, IProductRecommendationsRequest, IProductsByHandlesRequest, IQueryCollectionsInclude, IQueryCollectionsRequest, IRemoveFromCartRequest, IResponse, IResponseMeta, ISeo, ISingleCartRequest, ISingleCollectionRequest, ISingleCustomerRequest, ISingleOrderRequest, ISingleProductRequest, ITrendingArticleRequest, IUpdateCartRequest, IUpdateCustomerRequest, IUpdateOrderRequest, PriceRangeDto, ProductCardDto, ProductCardImageDto, QueryCollectionsErrorCode, QuerySortDirection, VariantCardDto, VariantCardImageDto, VariantCardOptionDto, VariantCardsPageDto } from './models/index.js';
|
|
4
4
|
export { createCollectionProductStaticParams, createCollectionStaticParams, createProductStaticParams, createProductViaCollectionsStaticParams } from './static-params/index.js';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/index.js
CHANGED
|
@@ -308,6 +308,16 @@ var BaseCommerceClient = class {
|
|
|
308
308
|
queryCollections(params, options) {
|
|
309
309
|
this.throwNotImplemented("queryCollections");
|
|
310
310
|
}
|
|
311
|
+
/**
|
|
312
|
+
* Read a page of a collection's products, with one card per matching variant
|
|
313
|
+
* @param params - Handle plus page/per_page, sort, filter, fields
|
|
314
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
315
|
+
* @returns Promise resolving to a VariantCardsPageDto
|
|
316
|
+
* @throws NotImplementedError if not implemented in adapter (custom backend only)
|
|
317
|
+
*/
|
|
318
|
+
getCollectionVariantCards(params, options) {
|
|
319
|
+
this.throwNotImplemented("getCollectionVariantCards");
|
|
320
|
+
}
|
|
311
321
|
// ========================================
|
|
312
322
|
// ORDER OPERATIONS
|
|
313
323
|
// ========================================
|
|
@@ -3802,7 +3812,8 @@ var PRODUCT_ENDPOINTS = {
|
|
|
3802
3812
|
getCollectionById: (v = DEFAULT_VERSION, id) => `/api/${v}/collections/${encodeURIComponent(id)}`,
|
|
3803
3813
|
getCollectionsByHandles: (v = DEFAULT_VERSION) => `/api/${v}/collections/details`,
|
|
3804
3814
|
getCollectionFilters: (v = DEFAULT_VERSION, collectionHandle) => `/api/${v}/storefront/collections/${encodeURIComponent(collectionHandle)}/filters`,
|
|
3805
|
-
queryCollections: (v = DEFAULT_VERSION) => `/api/${v}/collections/query
|
|
3815
|
+
queryCollections: (v = DEFAULT_VERSION) => `/api/${v}/collections/query`,
|
|
3816
|
+
collectionVariants: (v = DEFAULT_VERSION, handle) => `/api/${v}/collections/${encodeURIComponent(handle)}/variants`
|
|
3806
3817
|
};
|
|
3807
3818
|
|
|
3808
3819
|
// src/adapters/custom/product/service.ts
|
|
@@ -4467,7 +4478,268 @@ var ProductService2 = class extends BaseCustomService {
|
|
|
4467
4478
|
});
|
|
4468
4479
|
}
|
|
4469
4480
|
}
|
|
4481
|
+
/**
|
|
4482
|
+
* A page of a collection's products, with one card per matching variant
|
|
4483
|
+
* (POST /api/v1/collections/{handle}/variants). A POST because filters are
|
|
4484
|
+
* nested; it is still a read and answers 200.
|
|
4485
|
+
*
|
|
4486
|
+
* With `allVariants: true`, follows `next_cursor` (same body + `after`,
|
|
4487
|
+
* 100 cards per call) and returns the whole page's variants in one result.
|
|
4488
|
+
* The result is complete or it is a failure — never a partial page, which
|
|
4489
|
+
* would be cached as if it were complete. It fails (`UPSTREAM_UNAVAILABLE`)
|
|
4490
|
+
* when a follow-up call fails, when the cursor repeats, or when the page is
|
|
4491
|
+
* not done within ALL_VARIANTS_MAX_CALLS calls or ALL_VARIANTS_DEADLINE_MS.
|
|
4492
|
+
*/
|
|
4493
|
+
async getCollectionVariantCards(params, options) {
|
|
4494
|
+
const handle = typeof params?.handle === "string" ? params.handle.trim() : "";
|
|
4495
|
+
if (!handle) {
|
|
4496
|
+
return formatResponse({
|
|
4497
|
+
success: false,
|
|
4498
|
+
message: "Missing required variable: 'handle'",
|
|
4499
|
+
error: {
|
|
4500
|
+
code: "QUERY_REJECTED",
|
|
4501
|
+
message: "handle: is required"
|
|
4502
|
+
}
|
|
4503
|
+
});
|
|
4504
|
+
}
|
|
4505
|
+
if (handle.includes("/") || handle === "." || handle === "..") {
|
|
4506
|
+
return formatResponse({
|
|
4507
|
+
success: false,
|
|
4508
|
+
message: "Collection not found.",
|
|
4509
|
+
error: {
|
|
4510
|
+
code: "NOT_FOUND",
|
|
4511
|
+
message: `No collection with handle ${handle}`
|
|
4512
|
+
}
|
|
4513
|
+
});
|
|
4514
|
+
}
|
|
4515
|
+
const payload = buildCollectionVariantsPayload(params);
|
|
4516
|
+
const requestOptions = {
|
|
4517
|
+
...options || {},
|
|
4518
|
+
// Same coverage as queryCollections: the broad tag for catalog-wide
|
|
4519
|
+
// purges plus the collection's own, which product.updated /
|
|
4520
|
+
// collection.updated webhooks already purge. No `revalidate`.
|
|
4521
|
+
next: {
|
|
4522
|
+
...options?.next || {},
|
|
4523
|
+
tags: [
|
|
4524
|
+
cacheTags.CacheTags.collections(),
|
|
4525
|
+
cacheTags.CacheTags.collection(handle),
|
|
4526
|
+
...options?.next?.tags || []
|
|
4527
|
+
]
|
|
4528
|
+
}
|
|
4529
|
+
};
|
|
4530
|
+
const endpoint = PRODUCT_ENDPOINTS.collectionVariants(
|
|
4531
|
+
options?.version,
|
|
4532
|
+
handle
|
|
4533
|
+
);
|
|
4534
|
+
const allVariants = params.allVariants === true;
|
|
4535
|
+
const deadline = allVariants ? AbortSignal.timeout(ALL_VARIANTS_DEADLINE_MS) : void 0;
|
|
4536
|
+
const callOptions = () => deadline ? {
|
|
4537
|
+
...requestOptions,
|
|
4538
|
+
signal: anySignal([
|
|
4539
|
+
deadline,
|
|
4540
|
+
options?.signal ?? AbortSignal.timeout(options?.timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS)
|
|
4541
|
+
])
|
|
4542
|
+
} : requestOptions;
|
|
4543
|
+
let followUp = false;
|
|
4544
|
+
try {
|
|
4545
|
+
let result = await this.request(endpoint, "POST", payload, callOptions());
|
|
4546
|
+
if (!result?.data) return noVariantCardsData(result?.request_id);
|
|
4547
|
+
const page = {
|
|
4548
|
+
...result.data,
|
|
4549
|
+
variants: Array.isArray(result.data.variants) ? result.data.variants : []
|
|
4550
|
+
};
|
|
4551
|
+
const errors = Array.isArray(result.errors) ? [...result.errors] : [];
|
|
4552
|
+
if (allVariants) {
|
|
4553
|
+
followUp = true;
|
|
4554
|
+
const variants = [];
|
|
4555
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
4556
|
+
const addCards = (cards) => {
|
|
4557
|
+
for (const card of Array.isArray(cards) ? cards : []) {
|
|
4558
|
+
if (typeof card?.id === "string") {
|
|
4559
|
+
if (seenIds.has(card.id)) continue;
|
|
4560
|
+
seenIds.add(card.id);
|
|
4561
|
+
}
|
|
4562
|
+
variants.push(card);
|
|
4563
|
+
}
|
|
4564
|
+
};
|
|
4565
|
+
addCards(page.variants);
|
|
4566
|
+
const seenCursors = new Set(
|
|
4567
|
+
typeof payload.after === "string" ? [payload.after] : []
|
|
4568
|
+
);
|
|
4569
|
+
let cursor = page.next_cursor;
|
|
4570
|
+
let calls = 1;
|
|
4571
|
+
while (cursor) {
|
|
4572
|
+
if (seenCursors.has(cursor)) {
|
|
4573
|
+
return incompleteVariantCards(
|
|
4574
|
+
"the backend returned a cursor it had already sent",
|
|
4575
|
+
result.request_id,
|
|
4576
|
+
this.logger
|
|
4577
|
+
);
|
|
4578
|
+
}
|
|
4579
|
+
if (calls >= ALL_VARIANTS_MAX_CALLS) {
|
|
4580
|
+
return incompleteVariantCards(
|
|
4581
|
+
`the page has more cards than ${ALL_VARIANTS_MAX_CALLS} calls of ${MAX_VARIANT_CARDS_PER_CALL} hold`,
|
|
4582
|
+
result.request_id,
|
|
4583
|
+
this.logger
|
|
4584
|
+
);
|
|
4585
|
+
}
|
|
4586
|
+
seenCursors.add(cursor);
|
|
4587
|
+
result = await this.request(
|
|
4588
|
+
endpoint,
|
|
4589
|
+
"POST",
|
|
4590
|
+
{ ...payload, after: cursor },
|
|
4591
|
+
callOptions()
|
|
4592
|
+
);
|
|
4593
|
+
calls++;
|
|
4594
|
+
if (!result?.data) return noVariantCardsData(result?.request_id);
|
|
4595
|
+
addCards(result.data.variants);
|
|
4596
|
+
if (Array.isArray(result.errors)) errors.push(...result.errors);
|
|
4597
|
+
cursor = result.data.next_cursor;
|
|
4598
|
+
}
|
|
4599
|
+
page.variants = variants;
|
|
4600
|
+
page.next_cursor = null;
|
|
4601
|
+
}
|
|
4602
|
+
const distinctErrors = dedupeErrors(errors);
|
|
4603
|
+
return formatResponse({
|
|
4604
|
+
success: true,
|
|
4605
|
+
message: "Collection variants retrieved successfully.",
|
|
4606
|
+
data: page,
|
|
4607
|
+
meta: {
|
|
4608
|
+
requestId: result.request_id,
|
|
4609
|
+
...distinctErrors.length > 0 ? { errors: distinctErrors } : {}
|
|
4610
|
+
}
|
|
4611
|
+
});
|
|
4612
|
+
} catch (error) {
|
|
4613
|
+
this.logger.error("Error in getCollectionVariantCards", void 0, {
|
|
4614
|
+
error
|
|
4615
|
+
});
|
|
4616
|
+
const body = error?.body;
|
|
4617
|
+
if (deadline?.aborted) {
|
|
4618
|
+
return incompleteVariantCards(
|
|
4619
|
+
`the page was not complete within ${ALL_VARIANTS_DEADLINE_MS / 1e3}s`,
|
|
4620
|
+
body?.request_id,
|
|
4621
|
+
this.logger
|
|
4622
|
+
);
|
|
4623
|
+
}
|
|
4624
|
+
if (isUpstreamUnavailable(error)) {
|
|
4625
|
+
return formatResponse({
|
|
4626
|
+
success: false,
|
|
4627
|
+
message: "An error occurred while processing the request.",
|
|
4628
|
+
error: {
|
|
4629
|
+
code: "UPSTREAM_UNAVAILABLE",
|
|
4630
|
+
message: typeof error?.status === "number" ? `Request failed: ${error.status}` : "Collection variants request did not complete."
|
|
4631
|
+
},
|
|
4632
|
+
meta: { requestId: body?.request_id }
|
|
4633
|
+
});
|
|
4634
|
+
}
|
|
4635
|
+
const upstreamErrors = Array.isArray(body?.errors) ? body.errors : [];
|
|
4636
|
+
if (error?.status === 404) {
|
|
4637
|
+
if (!followUp && upstreamErrors[0]?.code === "NOT_FOUND") {
|
|
4638
|
+
return formatResponse({
|
|
4639
|
+
success: false,
|
|
4640
|
+
message: "Collection not found.",
|
|
4641
|
+
error: {
|
|
4642
|
+
code: "NOT_FOUND",
|
|
4643
|
+
message: upstreamErrors[0]?.message || `No collection with handle ${handle}`
|
|
4644
|
+
},
|
|
4645
|
+
meta: { requestId: body?.request_id }
|
|
4646
|
+
});
|
|
4647
|
+
}
|
|
4648
|
+
return formatResponse({
|
|
4649
|
+
success: false,
|
|
4650
|
+
message: "An error occurred while processing the request.",
|
|
4651
|
+
error: {
|
|
4652
|
+
code: "UPSTREAM_UNAVAILABLE",
|
|
4653
|
+
message: "Request failed: 404"
|
|
4654
|
+
},
|
|
4655
|
+
meta: { requestId: body?.request_id }
|
|
4656
|
+
});
|
|
4657
|
+
}
|
|
4658
|
+
return formatResponse({
|
|
4659
|
+
success: false,
|
|
4660
|
+
message: "The collection variants request was rejected.",
|
|
4661
|
+
error: {
|
|
4662
|
+
code: "QUERY_REJECTED",
|
|
4663
|
+
message: upstreamErrors[0]?.message || error.message,
|
|
4664
|
+
details: upstreamErrors
|
|
4665
|
+
},
|
|
4666
|
+
meta: { requestId: body?.request_id }
|
|
4667
|
+
});
|
|
4668
|
+
}
|
|
4669
|
+
}
|
|
4470
4670
|
};
|
|
4671
|
+
function incompleteVariantCards(reason, requestId, logger2) {
|
|
4672
|
+
logger2.warn(`getCollectionVariantCards allVariants incomplete: ${reason}`);
|
|
4673
|
+
return formatResponse({
|
|
4674
|
+
success: false,
|
|
4675
|
+
message: "Collection variants page is incomplete.",
|
|
4676
|
+
error: {
|
|
4677
|
+
code: "UPSTREAM_UNAVAILABLE",
|
|
4678
|
+
message: `allVariants: ${reason}; not returning a partial page.`
|
|
4679
|
+
},
|
|
4680
|
+
meta: { requestId }
|
|
4681
|
+
});
|
|
4682
|
+
}
|
|
4683
|
+
function dedupeErrors(errors) {
|
|
4684
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4685
|
+
return errors.filter((e) => {
|
|
4686
|
+
const err = e;
|
|
4687
|
+
const key = JSON.stringify([err?.code, err?.message]);
|
|
4688
|
+
if (seen.has(key)) return false;
|
|
4689
|
+
seen.add(key);
|
|
4690
|
+
return true;
|
|
4691
|
+
});
|
|
4692
|
+
}
|
|
4693
|
+
function anySignal(signals) {
|
|
4694
|
+
const controller = new AbortController();
|
|
4695
|
+
for (const signal of signals) {
|
|
4696
|
+
if (signal.aborted) {
|
|
4697
|
+
controller.abort(signal.reason);
|
|
4698
|
+
break;
|
|
4699
|
+
}
|
|
4700
|
+
signal.addEventListener("abort", () => controller.abort(signal.reason), {
|
|
4701
|
+
once: true
|
|
4702
|
+
});
|
|
4703
|
+
}
|
|
4704
|
+
return controller.signal;
|
|
4705
|
+
}
|
|
4706
|
+
function noVariantCardsData(requestId) {
|
|
4707
|
+
return formatResponse({
|
|
4708
|
+
success: false,
|
|
4709
|
+
message: "Collection variants request returned no data.",
|
|
4710
|
+
error: {
|
|
4711
|
+
code: "UPSTREAM_UNAVAILABLE",
|
|
4712
|
+
message: "No data in collection variants response."
|
|
4713
|
+
},
|
|
4714
|
+
meta: { requestId }
|
|
4715
|
+
});
|
|
4716
|
+
}
|
|
4717
|
+
var COLLECTION_VARIANTS_KEYS = [
|
|
4718
|
+
"filter",
|
|
4719
|
+
"fields",
|
|
4720
|
+
"product",
|
|
4721
|
+
"sort",
|
|
4722
|
+
"page",
|
|
4723
|
+
"per_page",
|
|
4724
|
+
"limit",
|
|
4725
|
+
"after",
|
|
4726
|
+
"ratings",
|
|
4727
|
+
"metafields"
|
|
4728
|
+
];
|
|
4729
|
+
var MAX_VARIANT_CARDS_PER_CALL = 100;
|
|
4730
|
+
var ALL_VARIANTS_MAX_CALLS = 20;
|
|
4731
|
+
var ALL_VARIANTS_DEADLINE_MS = 15e3;
|
|
4732
|
+
function buildCollectionVariantsPayload(params) {
|
|
4733
|
+
const source = params || {};
|
|
4734
|
+
const payload = {};
|
|
4735
|
+
for (const key of COLLECTION_VARIANTS_KEYS) {
|
|
4736
|
+
if (source[key] !== void 0) payload[key] = source[key];
|
|
4737
|
+
}
|
|
4738
|
+
if (source.allVariants === true) {
|
|
4739
|
+
payload.limit = MAX_VARIANT_CARDS_PER_CALL;
|
|
4740
|
+
}
|
|
4741
|
+
return payload;
|
|
4742
|
+
}
|
|
4471
4743
|
var COLLECTIONS_QUERY_KEYS = [
|
|
4472
4744
|
"filter",
|
|
4473
4745
|
"fields",
|
|
@@ -5109,6 +5381,12 @@ var CustomBackendClient = class extends BaseCommerceClient {
|
|
|
5109
5381
|
filterRestOptions(options)
|
|
5110
5382
|
);
|
|
5111
5383
|
}
|
|
5384
|
+
async getCollectionVariantCards(params, options) {
|
|
5385
|
+
return this.productService.getCollectionVariantCards(
|
|
5386
|
+
params,
|
|
5387
|
+
filterRestOptions(options)
|
|
5388
|
+
);
|
|
5389
|
+
}
|
|
5112
5390
|
// ========================================
|
|
5113
5391
|
// CART OPERATIONS
|
|
5114
5392
|
// ========================================
|