@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/client.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { R as ReadOnlyCollectionClient } from './collection-client-
|
|
2
|
-
import { C as CommerceClient, a as CommunityClient, b as ContentClient, E as EventsClient, c as CustomerNamespace, d as ClientState, e as ClientConfig } from './types-
|
|
3
|
-
export { A as AddItemParams, f as ApiQueryOptions, g as ApplyDiscountParams, h as CheckoutParams, i as ClearCartParams, j as ClientMetadata, k as ContentClientOptions, D as DebugConfig, l as DeepPartial, m as ExtractArrayType, P as PayloadFindResponse, n as PayloadMutationResponse, o as PublicCart, p as PublicCartItem, q as PublicCartReference, r as PublicMediaAsset, s as PublicMediaSize, t as PublicOrder, u as PublicOrderItem, v as PublicOrderReference, R as RemoveDiscountParams, w as RemoveItemParams, x as RetryConfig, y as RootClient, y as RootClientType, z as RootCollectionClient, B as RootReadOnlyQueryBuilder, S as Sort, F as StorefrontContentListOptions, G as StorefrontContentReference, H as StorefrontGalleryItem, I as StorefrontGalleryItemsListOptions, J as StorefrontGalleryItemsSort, K as StorefrontLink, L as StorefrontLinksListOptions, M as StorefrontLinksSort, U as UpdateItemParams, W as Where } from './types-
|
|
4
|
-
import './payload-types-
|
|
5
|
-
export { C as Collection, P as PublicCollection } from './const-
|
|
1
|
+
import { R as ReadOnlyCollectionClient } from './collection-client-Bymfni8u.cjs';
|
|
2
|
+
import { C as CommerceClient, a as CommunityClient, b as ContentClient, E as EventsClient, c as CustomerNamespace, d as ClientState, e as ClientConfig } from './types-Bl-m9ttd.cjs';
|
|
3
|
+
export { A as AddItemParams, f as ApiQueryOptions, g as ApplyDiscountParams, h as CheckoutParams, i as ClearCartParams, j as ClientMetadata, k as ContentClientOptions, D as DebugConfig, l as DeepPartial, m as ExtractArrayType, P as PayloadFindResponse, n as PayloadMutationResponse, o as PublicCart, p as PublicCartItem, q as PublicCartReference, r as PublicMediaAsset, s as PublicMediaSize, t as PublicOrder, u as PublicOrderItem, v as PublicOrderReference, R as RemoveDiscountParams, w as RemoveItemParams, x as RetryConfig, y as RootClient, y as RootClientType, z as RootCollectionClient, B as RootReadOnlyQueryBuilder, S as Sort, F as StorefrontContentListOptions, G as StorefrontContentReference, H as StorefrontGalleryItem, I as StorefrontGalleryItemsListOptions, J as StorefrontGalleryItemsSort, K as StorefrontLink, L as StorefrontLinksListOptions, M as StorefrontLinksSort, U as UpdateItemParams, W as Where } from './types-Bl-m9ttd.cjs';
|
|
4
|
+
import './payload-types-DC0xzR9i.cjs';
|
|
5
|
+
export { C as Collection, P as PublicCollection } from './const-4BUtUdGU.cjs';
|
|
6
6
|
import './metadata.cjs';
|
|
7
|
-
import './types-
|
|
7
|
+
import './types-BvpjooU-.cjs';
|
|
8
8
|
|
|
9
9
|
declare class Client {
|
|
10
10
|
commerce: CommerceClient;
|
package/dist/client.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { R as ReadOnlyCollectionClient } from './collection-client-
|
|
2
|
-
import { C as CommerceClient, a as CommunityClient, b as ContentClient, E as EventsClient, c as CustomerNamespace, d as ClientState, e as ClientConfig } from './types-
|
|
3
|
-
export { A as AddItemParams, f as ApiQueryOptions, g as ApplyDiscountParams, h as CheckoutParams, i as ClearCartParams, j as ClientMetadata, k as ContentClientOptions, D as DebugConfig, l as DeepPartial, m as ExtractArrayType, P as PayloadFindResponse, n as PayloadMutationResponse, o as PublicCart, p as PublicCartItem, q as PublicCartReference, r as PublicMediaAsset, s as PublicMediaSize, t as PublicOrder, u as PublicOrderItem, v as PublicOrderReference, R as RemoveDiscountParams, w as RemoveItemParams, x as RetryConfig, y as RootClient, y as RootClientType, z as RootCollectionClient, B as RootReadOnlyQueryBuilder, S as Sort, F as StorefrontContentListOptions, G as StorefrontContentReference, H as StorefrontGalleryItem, I as StorefrontGalleryItemsListOptions, J as StorefrontGalleryItemsSort, K as StorefrontLink, L as StorefrontLinksListOptions, M as StorefrontLinksSort, U as UpdateItemParams, W as Where } from './types-
|
|
4
|
-
import './payload-types-
|
|
5
|
-
export { C as Collection, P as PublicCollection } from './const-
|
|
1
|
+
import { R as ReadOnlyCollectionClient } from './collection-client-CN4lj6gi.js';
|
|
2
|
+
import { C as CommerceClient, a as CommunityClient, b as ContentClient, E as EventsClient, c as CustomerNamespace, d as ClientState, e as ClientConfig } from './types-CHrzs2GB.js';
|
|
3
|
+
export { A as AddItemParams, f as ApiQueryOptions, g as ApplyDiscountParams, h as CheckoutParams, i as ClearCartParams, j as ClientMetadata, k as ContentClientOptions, D as DebugConfig, l as DeepPartial, m as ExtractArrayType, P as PayloadFindResponse, n as PayloadMutationResponse, o as PublicCart, p as PublicCartItem, q as PublicCartReference, r as PublicMediaAsset, s as PublicMediaSize, t as PublicOrder, u as PublicOrderItem, v as PublicOrderReference, R as RemoveDiscountParams, w as RemoveItemParams, x as RetryConfig, y as RootClient, y as RootClientType, z as RootCollectionClient, B as RootReadOnlyQueryBuilder, S as Sort, F as StorefrontContentListOptions, G as StorefrontContentReference, H as StorefrontGalleryItem, I as StorefrontGalleryItemsListOptions, J as StorefrontGalleryItemsSort, K as StorefrontLink, L as StorefrontLinksListOptions, M as StorefrontLinksSort, U as UpdateItemParams, W as Where } from './types-CHrzs2GB.js';
|
|
4
|
+
import './payload-types-DC0xzR9i.js';
|
|
5
|
+
export { C as Collection, P as PublicCollection } from './const-ymprfiPf.js';
|
|
6
6
|
import './metadata.js';
|
|
7
|
-
import './types-
|
|
7
|
+
import './types-Bh2p-EMc.js';
|
|
8
8
|
|
|
9
9
|
declare class Client {
|
|
10
10
|
commerce: CommerceClient;
|
package/dist/client.js
CHANGED
|
@@ -1451,6 +1451,19 @@ var CustomerAuth = class {
|
|
|
1451
1451
|
const params = new URLSearchParams();
|
|
1452
1452
|
if (options?.page) params.set("page", String(options.page));
|
|
1453
1453
|
if (options?.limit) params.set("limit", String(options.limit));
|
|
1454
|
+
if (options?.displayFinancialStatus) {
|
|
1455
|
+
params.set("displayFinancialStatus", options.displayFinancialStatus);
|
|
1456
|
+
}
|
|
1457
|
+
if (options?.displayFulfillmentStatus) {
|
|
1458
|
+
params.set("displayFulfillmentStatus", options.displayFulfillmentStatus);
|
|
1459
|
+
}
|
|
1460
|
+
if (options?.returnStatus) params.set("returnStatus", options.returnStatus);
|
|
1461
|
+
if (options?.primaryDisplayStatus) {
|
|
1462
|
+
params.set("primaryDisplayStatus", options.primaryDisplayStatus);
|
|
1463
|
+
}
|
|
1464
|
+
if (options?.returnDisplayStatus) {
|
|
1465
|
+
params.set("returnDisplayStatus", options.returnDisplayStatus);
|
|
1466
|
+
}
|
|
1454
1467
|
if (options?.status) params.set("status", options.status);
|
|
1455
1468
|
const qs = params.toString();
|
|
1456
1469
|
return this.requestJson(`/api/customers/me/orders${qs ? `?${qs}` : ""}`, {
|
|
@@ -1565,9 +1578,6 @@ function getMediaId(value) {
|
|
|
1565
1578
|
}
|
|
1566
1579
|
return null;
|
|
1567
1580
|
}
|
|
1568
|
-
function toPointerId(value) {
|
|
1569
|
-
return getMediaId(value);
|
|
1570
|
-
}
|
|
1571
1581
|
function mediaArray(value) {
|
|
1572
1582
|
if (!Array.isArray(value)) return [];
|
|
1573
1583
|
return value.filter((entry) => entry != null);
|
|
@@ -1684,22 +1694,16 @@ function resolveProductSelectionMedia(input) {
|
|
|
1684
1694
|
source: "none"
|
|
1685
1695
|
};
|
|
1686
1696
|
}
|
|
1687
|
-
function
|
|
1697
|
+
function resolveFeaturedImagePointer(input) {
|
|
1688
1698
|
const pool = mediaArray(input.productMediaPool);
|
|
1689
1699
|
const resolvedPointer = getMediaId(input.resolvedPrimary);
|
|
1690
1700
|
if (resolvedPointer && input.resolvedSource !== "product_pool" && input.resolvedSource !== "none") {
|
|
1691
1701
|
return resolvedPointer;
|
|
1692
1702
|
}
|
|
1693
1703
|
const poolById = buildPoolById(pool);
|
|
1694
|
-
const
|
|
1695
|
-
if (
|
|
1696
|
-
return
|
|
1697
|
-
}
|
|
1698
|
-
const primaryPointer = toPointerId(input.productPrimaryMediaItemId);
|
|
1699
|
-
if (primaryPointer && poolById.has(primaryPointer)) return primaryPointer;
|
|
1700
|
-
const thumbnailPointer = getMediaId(input.productThumbnail);
|
|
1701
|
-
if (thumbnailPointer && poolById.has(thumbnailPointer)) {
|
|
1702
|
-
return thumbnailPointer;
|
|
1704
|
+
const featuredImagePointer = getMediaId(input.featuredImage);
|
|
1705
|
+
if (featuredImagePointer && poolById.has(featuredImagePointer)) {
|
|
1706
|
+
return featuredImagePointer;
|
|
1703
1707
|
}
|
|
1704
1708
|
if (pool.length > 0) {
|
|
1705
1709
|
const firstPoolId = getMediaId(pool[0]);
|
|
@@ -1754,13 +1758,9 @@ function extractEntityId(value) {
|
|
|
1754
1758
|
return null;
|
|
1755
1759
|
}
|
|
1756
1760
|
function resolveGenericListingPrimaryImage(product, resolvedPrimary, resolvedSource) {
|
|
1757
|
-
return
|
|
1761
|
+
return resolveFeaturedImagePointer({
|
|
1758
1762
|
productMediaPool: product?.images ?? [],
|
|
1759
|
-
|
|
1760
|
-
product?.primaryMediaItemId ?? null
|
|
1761
|
-
),
|
|
1762
|
-
productThumbnail: product?.thumbnail ?? null,
|
|
1763
|
-
listingPrimaryImage: product?.listing?.primaryImage ?? null,
|
|
1763
|
+
featuredImage: product?.featuredImage ?? null,
|
|
1764
1764
|
resolvedPrimary,
|
|
1765
1765
|
resolvedSource
|
|
1766
1766
|
});
|
|
@@ -2362,11 +2362,14 @@ function compareVariantOrder(a, b) {
|
|
|
2362
2362
|
const bId = String(getRelationID(b.id) ?? "");
|
|
2363
2363
|
return aId.localeCompare(bId);
|
|
2364
2364
|
}
|
|
2365
|
-
function
|
|
2365
|
+
function getVariantAvailableForSale(variant) {
|
|
2366
2366
|
if (variant.isActive === false) return false;
|
|
2367
2367
|
if (variant.isUnlimited) return true;
|
|
2368
2368
|
return (variant.stock ?? 0) - (variant.reservedStock ?? 0) > 0;
|
|
2369
2369
|
}
|
|
2370
|
+
function isVariantAvailableForSale(variant) {
|
|
2371
|
+
return getVariantAvailableForSale(variant);
|
|
2372
|
+
}
|
|
2370
2373
|
function sortVariantsForMediaSelection(variants) {
|
|
2371
2374
|
const orderedVariants = [...variants].sort(compareVariantOrder);
|
|
2372
2375
|
const activeVariants = orderedVariants.filter(
|
|
@@ -2399,7 +2402,7 @@ function getMinMax(values) {
|
|
|
2399
2402
|
max: Math.max(...numbers)
|
|
2400
2403
|
};
|
|
2401
2404
|
}
|
|
2402
|
-
function
|
|
2405
|
+
function buildProductListingGroupProjection(product, variants) {
|
|
2403
2406
|
const orderedVariants = [...variants].sort(compareVariantOrder);
|
|
2404
2407
|
const activeVariants = orderedVariants.filter(
|
|
2405
2408
|
(variant) => variant.isActive !== false
|
|
@@ -2420,7 +2423,6 @@ function buildProductListingProjection(product, variants) {
|
|
|
2420
2423
|
const mediaSelectionVariants = sortVariantsForMediaSelection(variants);
|
|
2421
2424
|
const resolvedProductMedia = resolveProductSelectionMedia({
|
|
2422
2425
|
productMediaPool,
|
|
2423
|
-
productPrimaryMediaItemId: getRelationID(product?.primaryMediaItemId),
|
|
2424
2426
|
selectedVariant: selectionHintVariant && selectionHintHasPoolMedia ? {
|
|
2425
2427
|
id: selectionHintVariant.id,
|
|
2426
2428
|
images: selectionHintVariant.images
|
|
@@ -2446,47 +2448,22 @@ function buildProductListingCard(item, options = {}) {
|
|
|
2446
2448
|
const product = item.product;
|
|
2447
2449
|
const groups = item.groups;
|
|
2448
2450
|
const variants = getProductListingCardVariants(item);
|
|
2449
|
-
const projectedListing =
|
|
2450
|
-
const selectionHintVariant = getRelationID(
|
|
2451
|
-
product.listing && "selectionHintVariant" in product.listing ? product.listing.selectionHintVariant : null
|
|
2452
|
-
) ?? projectedListing.selectionHintVariant;
|
|
2451
|
+
const projectedListing = buildProductListingGroupProjection(product, variants);
|
|
2452
|
+
const selectionHintVariant = getRelationID(product.selectedOrFirstAvailableVariant) ?? projectedListing.selectionHintVariant;
|
|
2453
2453
|
const representativeVariant = findListingCardRepresentativeVariant(
|
|
2454
2454
|
variants,
|
|
2455
2455
|
selectionHintVariant
|
|
2456
2456
|
);
|
|
2457
2457
|
const productMediaPool = mediaArray2(product.images);
|
|
2458
|
-
const
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
(poolItem) => getRelationID(poolItem) === getRelationID(image)
|
|
2462
|
-
)
|
|
2463
|
-
)
|
|
2464
|
-
);
|
|
2465
|
-
const resolvedPrimaryMedia = resolveProductSelectionMedia(
|
|
2466
|
-
{
|
|
2467
|
-
productMediaPool,
|
|
2468
|
-
productPrimaryMediaItemId: getRelationID(product.primaryMediaItemId),
|
|
2469
|
-
selectedVariant: representativeHasPoolMedia ? representativeVariant : null,
|
|
2470
|
-
matchingVariants: representativeHasPoolMedia ? [] : variants
|
|
2471
|
-
}
|
|
2472
|
-
);
|
|
2473
|
-
const listingPrimaryPointer = resolveListingPrimaryImagePointer({
|
|
2474
|
-
productMediaPool,
|
|
2475
|
-
productPrimaryMediaItemId: getRelationID(product.primaryMediaItemId),
|
|
2476
|
-
productThumbnail: product.thumbnail ?? null,
|
|
2477
|
-
listingPrimaryImage: product.listing?.primaryImage ?? null,
|
|
2478
|
-
resolvedPrimary: resolvedPrimaryMedia.primaryImage,
|
|
2479
|
-
resolvedSource: resolvedPrimaryMedia.source
|
|
2480
|
-
});
|
|
2481
|
-
const listingPrimaryMedia = listingPrimaryPointer ? productMediaPool.find(
|
|
2482
|
-
(item2) => getRelationID(item2) === listingPrimaryPointer
|
|
2483
|
-
) ?? resolvedPrimaryMedia.primaryImage ?? null : null;
|
|
2458
|
+
const featuredImageId = getRelationID(product.featuredImage);
|
|
2459
|
+
const featuredImageFromPool = featuredImageId ? productMediaPool.find((item2) => getRelationID(item2) === featuredImageId) : void 0;
|
|
2460
|
+
const listingPrimaryMedia = featuredImageFromPool ?? product.featuredImage ?? productMediaPool[0] ?? null;
|
|
2484
2461
|
const priceRange = resolveListingCardPriceRange(
|
|
2485
2462
|
product,
|
|
2486
2463
|
projectedListing,
|
|
2487
2464
|
groups
|
|
2488
2465
|
);
|
|
2489
|
-
const availableForSale = product.
|
|
2466
|
+
const availableForSale = product.availableForSale != null ? product.availableForSale : groups.length > 0 ? groups.some((group) => group.listing.availableForSale) : projectedListing.availableForSale;
|
|
2490
2467
|
const swatches = groups.length > 1 ? groups.map((group) => buildListingSwatch(product, group, options)) : [];
|
|
2491
2468
|
return {
|
|
2492
2469
|
id: String(product.id),
|
|
@@ -2526,23 +2503,20 @@ function findListingCardRepresentativeVariant(variants, representativeVariantId)
|
|
|
2526
2503
|
(variant) => getRelationID(variant.id) === representativeVariantId
|
|
2527
2504
|
) ?? null;
|
|
2528
2505
|
}
|
|
2529
|
-
function
|
|
2530
|
-
return
|
|
2531
|
-
}
|
|
2532
|
-
function listingDefinesCompareAtProjection(listing) {
|
|
2533
|
-
return "minCompareAtPrice" in listing || "maxCompareAtPrice" in listing;
|
|
2506
|
+
function hasCompleteProductPriceRange(priceRange) {
|
|
2507
|
+
return priceRange?.minVariantPrice?.amount != null && priceRange?.maxVariantPrice?.amount != null;
|
|
2534
2508
|
}
|
|
2535
2509
|
function resolveListingCardPriceRange(product, projectedListing, groups) {
|
|
2536
|
-
|
|
2537
|
-
if (hasCompleteListingPriceProjection(listing)) {
|
|
2510
|
+
if (hasCompleteProductPriceRange(product.priceRange)) {
|
|
2538
2511
|
const groupRange = groups.length > 0 ? aggregateListingPriceRange(groups) : null;
|
|
2539
|
-
const
|
|
2512
|
+
const minCompareAtPrice = product.compareAtPriceRange?.minVariantPrice?.amount ?? groupRange?.minCompareAtPrice ?? null;
|
|
2513
|
+
const maxCompareAtPrice = product.compareAtPriceRange?.maxVariantPrice?.amount ?? groupRange?.maxCompareAtPrice ?? null;
|
|
2540
2514
|
return {
|
|
2541
|
-
minPrice:
|
|
2542
|
-
maxPrice:
|
|
2543
|
-
minCompareAtPrice
|
|
2544
|
-
maxCompareAtPrice
|
|
2545
|
-
isPriceRange:
|
|
2515
|
+
minPrice: product.priceRange.minVariantPrice.amount,
|
|
2516
|
+
maxPrice: product.priceRange.maxVariantPrice.amount,
|
|
2517
|
+
minCompareAtPrice,
|
|
2518
|
+
maxCompareAtPrice,
|
|
2519
|
+
isPriceRange: product.priceRange.isPriceRange ?? product.priceRange.minVariantPrice.amount !== product.priceRange.maxVariantPrice.amount
|
|
2546
2520
|
};
|
|
2547
2521
|
}
|
|
2548
2522
|
if (groups.length > 0) {
|
|
@@ -2654,15 +2628,19 @@ function buildProductListingPageWhere(params) {
|
|
|
2654
2628
|
if (tagIds) clauses.push({ tags: { in: tagIds } });
|
|
2655
2629
|
const minPrice = filters?.price?.min;
|
|
2656
2630
|
if (minPrice != null) {
|
|
2657
|
-
clauses.push({
|
|
2631
|
+
clauses.push({
|
|
2632
|
+
"priceRange.maxVariantPrice.amount": { greater_than_equal: minPrice }
|
|
2633
|
+
});
|
|
2658
2634
|
}
|
|
2659
2635
|
const maxPrice = filters?.price?.max;
|
|
2660
2636
|
if (maxPrice != null) {
|
|
2661
|
-
clauses.push({
|
|
2637
|
+
clauses.push({
|
|
2638
|
+
"priceRange.minVariantPrice.amount": { less_than_equal: maxPrice }
|
|
2639
|
+
});
|
|
2662
2640
|
}
|
|
2663
2641
|
if (filters?.availableForSale != null) {
|
|
2664
2642
|
clauses.push({
|
|
2665
|
-
|
|
2643
|
+
availableForSale: { equals: filters.availableForSale }
|
|
2666
2644
|
});
|
|
2667
2645
|
}
|
|
2668
2646
|
if (clauses.length === 0) return void 0;
|