@shoppexio/storefront 1.0.93 → 1.0.94

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/index.d.cts CHANGED
@@ -451,6 +451,12 @@ interface ProductVariant {
451
451
  /** Merchant-selected storefront highlight. It does not affect selection or availability. */
452
452
  is_featured?: boolean;
453
453
  isFeatured?: boolean;
454
+ /**
455
+ * A private option, sold only through its direct link. The server lists it
456
+ * only on `getProduct(id, { variant })` naming it, never in product lists.
457
+ * Absent on servers older than private variants.
458
+ */
459
+ is_private?: boolean;
454
460
  /** License validity in days for this option. Zero means lifetime. */
455
461
  license_period?: number | null;
456
462
  }
@@ -507,6 +513,12 @@ interface PriceVariant {
507
513
  /** Merchant-selected storefront highlight. It does not affect selection or availability. */
508
514
  is_featured?: boolean;
509
515
  isFeatured?: boolean;
516
+ /**
517
+ * A private option, sold only through its direct link. The server lists it
518
+ * only on `getProduct(id, { variant })` naming it, never in product lists.
519
+ * Absent on servers older than private variants.
520
+ */
521
+ is_private?: boolean;
510
522
  /** License validity in days for this option. Zero means lifetime. */
511
523
  license_period?: number | null;
512
524
  }
@@ -1538,7 +1550,14 @@ declare function getStorefrontProductsPage(options?: GetStorefrontProductsPageOp
1538
1550
  products: Product[];
1539
1551
  pagination: CursorPagination | null;
1540
1552
  }>>;
1541
- declare function getProduct(idOrSlug: string): Promise<SDKResponse<Product>>;
1553
+ declare function getProduct(idOrSlug: string, options?: {
1554
+ /**
1555
+ * A variant id from the page URL (`?variant=<id>`). A private variant is
1556
+ * listed only when it is named here; it then comes first in the variants,
1557
+ * so a buy box that opens on the first sellable option preselects it.
1558
+ */
1559
+ variant?: string;
1560
+ }): Promise<SDKResponse<Product>>;
1542
1561
  declare function getCategories(): Promise<SDKResponse<string[]>>;
1543
1562
 
1544
1563
  /**
package/dist/index.d.ts CHANGED
@@ -451,6 +451,12 @@ interface ProductVariant {
451
451
  /** Merchant-selected storefront highlight. It does not affect selection or availability. */
452
452
  is_featured?: boolean;
453
453
  isFeatured?: boolean;
454
+ /**
455
+ * A private option, sold only through its direct link. The server lists it
456
+ * only on `getProduct(id, { variant })` naming it, never in product lists.
457
+ * Absent on servers older than private variants.
458
+ */
459
+ is_private?: boolean;
454
460
  /** License validity in days for this option. Zero means lifetime. */
455
461
  license_period?: number | null;
456
462
  }
@@ -507,6 +513,12 @@ interface PriceVariant {
507
513
  /** Merchant-selected storefront highlight. It does not affect selection or availability. */
508
514
  is_featured?: boolean;
509
515
  isFeatured?: boolean;
516
+ /**
517
+ * A private option, sold only through its direct link. The server lists it
518
+ * only on `getProduct(id, { variant })` naming it, never in product lists.
519
+ * Absent on servers older than private variants.
520
+ */
521
+ is_private?: boolean;
510
522
  /** License validity in days for this option. Zero means lifetime. */
511
523
  license_period?: number | null;
512
524
  }
@@ -1538,7 +1550,14 @@ declare function getStorefrontProductsPage(options?: GetStorefrontProductsPageOp
1538
1550
  products: Product[];
1539
1551
  pagination: CursorPagination | null;
1540
1552
  }>>;
1541
- declare function getProduct(idOrSlug: string): Promise<SDKResponse<Product>>;
1553
+ declare function getProduct(idOrSlug: string, options?: {
1554
+ /**
1555
+ * A variant id from the page URL (`?variant=<id>`). A private variant is
1556
+ * listed only when it is named here; it then comes first in the variants,
1557
+ * so a buy box that opens on the first sellable option preselects it.
1558
+ */
1559
+ variant?: string;
1560
+ }): Promise<SDKResponse<Product>>;
1542
1561
  declare function getCategories(): Promise<SDKResponse<string[]>>;
1543
1562
 
1544
1563
  /**
package/dist/index.js CHANGED
@@ -1244,7 +1244,8 @@ function priceVariantToProductVariant(variant) {
1244
1244
  cloudflare_image_id: variant.cloudflare_image_id,
1245
1245
  cloudflareImageId: variant.cloudflareImageId,
1246
1246
  image_url: variant.image_url,
1247
- imageUrl: variant.imageUrl
1247
+ imageUrl: variant.imageUrl,
1248
+ is_private: variant.is_private
1248
1249
  };
1249
1250
  }
1250
1251
  function normalizeProduct(product) {
@@ -1328,7 +1329,7 @@ async function getStorefrontProductsPage(options) {
1328
1329
  }
1329
1330
  return forwardFailure(response);
1330
1331
  }
1331
- async function getProduct(idOrSlug) {
1332
+ async function getProduct(idOrSlug, options = {}) {
1332
1333
  let shopId = getShopId();
1333
1334
  if (!shopId) {
1334
1335
  const store = await getStore();
@@ -1337,13 +1338,16 @@ async function getProduct(idOrSlug) {
1337
1338
  }
1338
1339
  shopId = store.data?.id ?? null;
1339
1340
  }
1340
- const queryParams = shopId ? `?slug_shop_id=${encodeURIComponent(shopId)}` : "";
1341
+ const query = new URLSearchParams();
1342
+ if (shopId) query.set("slug_shop_id", shopId);
1343
+ if (options.variant) query.set("variant", options.variant);
1344
+ const queryParams = query.size > 0 ? `?${query.toString()}` : "";
1341
1345
  const response = await get(
1342
1346
  `${buildEndpoint("/v1/storefront/products/unique/:idOrSlug", { idOrSlug })}${queryParams}`,
1343
1347
  {
1344
1348
  buyerCurrency: true,
1345
1349
  cache: {
1346
- key: `product:${idOrSlug}:${shopId ?? "no-shop"}`,
1350
+ key: `product:${idOrSlug}:${shopId ?? "no-shop"}:${options.variant ?? "no-variant"}`,
1347
1351
  ttl: PRODUCTS_CACHE_TTL,
1348
1352
  staleWhileRevalidate: true
1349
1353
  }