@shoppexio/storefront 1.0.93 → 1.0.95

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
@@ -259,6 +259,8 @@ interface Product {
259
259
  /** The merchant's word for one / several delivered units of a SERIALS product ("License key"); null when unset. */
260
260
  label_singular?: string | null;
261
261
  label_plural?: string | null;
262
+ /** The merchant's SKU; null when they set none. */
263
+ sku?: string | null;
262
264
  /**
263
265
  * The merchant's explicit service status for storefront `/status` pages; null
264
266
  * when they set none (the product is then not listed there).
@@ -412,6 +414,8 @@ interface ProductVariant {
412
414
  id: string;
413
415
  title: string;
414
416
  price?: number;
417
+ /** The merchant's SKU for this option; null when they set none. */
418
+ sku?: string | null;
415
419
  /**
416
420
  * RAW local stock for this option only. `-1` (or any negative value) means
417
421
  * unlimited, `0` means no local units — which a supplier-backed option reports
@@ -451,6 +455,12 @@ interface ProductVariant {
451
455
  /** Merchant-selected storefront highlight. It does not affect selection or availability. */
452
456
  is_featured?: boolean;
453
457
  isFeatured?: boolean;
458
+ /**
459
+ * A private option, sold only through its direct link. The server lists it
460
+ * only on `getProduct(id, { variant })` naming it, never in product lists.
461
+ * Absent on servers older than private variants.
462
+ */
463
+ is_private?: boolean;
454
464
  /** License validity in days for this option. Zero means lifetime. */
455
465
  license_period?: number | null;
456
466
  }
@@ -468,6 +478,8 @@ interface PriceVariant {
468
478
  /** The merchant's one-line note on this option ("1 seat"); absent when unset. */
469
479
  description?: string;
470
480
  price: number;
481
+ /** The merchant's SKU for this option; null when they set none. */
482
+ sku?: string | null;
471
483
  /**
472
484
  * RAW local stock for this price variant only. `-1` (or any negative value)
473
485
  * means unlimited, `0` means no local units — which a supplier-backed variant
@@ -507,6 +519,12 @@ interface PriceVariant {
507
519
  /** Merchant-selected storefront highlight. It does not affect selection or availability. */
508
520
  is_featured?: boolean;
509
521
  isFeatured?: boolean;
522
+ /**
523
+ * A private option, sold only through its direct link. The server lists it
524
+ * only on `getProduct(id, { variant })` naming it, never in product lists.
525
+ * Absent on servers older than private variants.
526
+ */
527
+ is_private?: boolean;
510
528
  /** License validity in days for this option. Zero means lifetime. */
511
529
  license_period?: number | null;
512
530
  }
@@ -1538,7 +1556,14 @@ declare function getStorefrontProductsPage(options?: GetStorefrontProductsPageOp
1538
1556
  products: Product[];
1539
1557
  pagination: CursorPagination | null;
1540
1558
  }>>;
1541
- declare function getProduct(idOrSlug: string): Promise<SDKResponse<Product>>;
1559
+ declare function getProduct(idOrSlug: string, options?: {
1560
+ /**
1561
+ * A variant id from the page URL (`?variant=<id>`). A private variant is
1562
+ * listed only when it is named here; it then comes first in the variants,
1563
+ * so a buy box that opens on the first sellable option preselects it.
1564
+ */
1565
+ variant?: string;
1566
+ }): Promise<SDKResponse<Product>>;
1542
1567
  declare function getCategories(): Promise<SDKResponse<string[]>>;
1543
1568
 
1544
1569
  /**
package/dist/index.d.ts CHANGED
@@ -259,6 +259,8 @@ interface Product {
259
259
  /** The merchant's word for one / several delivered units of a SERIALS product ("License key"); null when unset. */
260
260
  label_singular?: string | null;
261
261
  label_plural?: string | null;
262
+ /** The merchant's SKU; null when they set none. */
263
+ sku?: string | null;
262
264
  /**
263
265
  * The merchant's explicit service status for storefront `/status` pages; null
264
266
  * when they set none (the product is then not listed there).
@@ -412,6 +414,8 @@ interface ProductVariant {
412
414
  id: string;
413
415
  title: string;
414
416
  price?: number;
417
+ /** The merchant's SKU for this option; null when they set none. */
418
+ sku?: string | null;
415
419
  /**
416
420
  * RAW local stock for this option only. `-1` (or any negative value) means
417
421
  * unlimited, `0` means no local units — which a supplier-backed option reports
@@ -451,6 +455,12 @@ interface ProductVariant {
451
455
  /** Merchant-selected storefront highlight. It does not affect selection or availability. */
452
456
  is_featured?: boolean;
453
457
  isFeatured?: boolean;
458
+ /**
459
+ * A private option, sold only through its direct link. The server lists it
460
+ * only on `getProduct(id, { variant })` naming it, never in product lists.
461
+ * Absent on servers older than private variants.
462
+ */
463
+ is_private?: boolean;
454
464
  /** License validity in days for this option. Zero means lifetime. */
455
465
  license_period?: number | null;
456
466
  }
@@ -468,6 +478,8 @@ interface PriceVariant {
468
478
  /** The merchant's one-line note on this option ("1 seat"); absent when unset. */
469
479
  description?: string;
470
480
  price: number;
481
+ /** The merchant's SKU for this option; null when they set none. */
482
+ sku?: string | null;
471
483
  /**
472
484
  * RAW local stock for this price variant only. `-1` (or any negative value)
473
485
  * means unlimited, `0` means no local units — which a supplier-backed variant
@@ -507,6 +519,12 @@ interface PriceVariant {
507
519
  /** Merchant-selected storefront highlight. It does not affect selection or availability. */
508
520
  is_featured?: boolean;
509
521
  isFeatured?: boolean;
522
+ /**
523
+ * A private option, sold only through its direct link. The server lists it
524
+ * only on `getProduct(id, { variant })` naming it, never in product lists.
525
+ * Absent on servers older than private variants.
526
+ */
527
+ is_private?: boolean;
510
528
  /** License validity in days for this option. Zero means lifetime. */
511
529
  license_period?: number | null;
512
530
  }
@@ -1538,7 +1556,14 @@ declare function getStorefrontProductsPage(options?: GetStorefrontProductsPageOp
1538
1556
  products: Product[];
1539
1557
  pagination: CursorPagination | null;
1540
1558
  }>>;
1541
- declare function getProduct(idOrSlug: string): Promise<SDKResponse<Product>>;
1559
+ declare function getProduct(idOrSlug: string, options?: {
1560
+ /**
1561
+ * A variant id from the page URL (`?variant=<id>`). A private variant is
1562
+ * listed only when it is named here; it then comes first in the variants,
1563
+ * so a buy box that opens on the first sellable option preselects it.
1564
+ */
1565
+ variant?: string;
1566
+ }): Promise<SDKResponse<Product>>;
1542
1567
  declare function getCategories(): Promise<SDKResponse<string[]>>;
1543
1568
 
1544
1569
  /**
package/dist/index.js CHANGED
@@ -1228,6 +1228,7 @@ function priceVariantToProductVariant(variant) {
1228
1228
  id: variant.id,
1229
1229
  title: variant.title ?? variant.label ?? "",
1230
1230
  price: typeof variant.price === "number" ? variant.price : Number(variant.price) || 0,
1231
+ sku: variant.sku,
1231
1232
  stock: typeof variant.stock === "number" ? variant.stock : void 0,
1232
1233
  // Dynamic Delivery (S8): carry the availability pair through. A supplier-backed
1233
1234
  // variant reports `stock: 0`, so dropping `orderable` here would make the mapped
@@ -1244,7 +1245,8 @@ function priceVariantToProductVariant(variant) {
1244
1245
  cloudflare_image_id: variant.cloudflare_image_id,
1245
1246
  cloudflareImageId: variant.cloudflareImageId,
1246
1247
  image_url: variant.image_url,
1247
- imageUrl: variant.imageUrl
1248
+ imageUrl: variant.imageUrl,
1249
+ is_private: variant.is_private
1248
1250
  };
1249
1251
  }
1250
1252
  function normalizeProduct(product) {
@@ -1328,7 +1330,7 @@ async function getStorefrontProductsPage(options) {
1328
1330
  }
1329
1331
  return forwardFailure(response);
1330
1332
  }
1331
- async function getProduct(idOrSlug) {
1333
+ async function getProduct(idOrSlug, options = {}) {
1332
1334
  let shopId = getShopId();
1333
1335
  if (!shopId) {
1334
1336
  const store = await getStore();
@@ -1337,13 +1339,16 @@ async function getProduct(idOrSlug) {
1337
1339
  }
1338
1340
  shopId = store.data?.id ?? null;
1339
1341
  }
1340
- const queryParams = shopId ? `?slug_shop_id=${encodeURIComponent(shopId)}` : "";
1342
+ const query = new URLSearchParams();
1343
+ if (shopId) query.set("slug_shop_id", shopId);
1344
+ if (options.variant) query.set("variant", options.variant);
1345
+ const queryParams = query.size > 0 ? `?${query.toString()}` : "";
1341
1346
  const response = await get(
1342
1347
  `${buildEndpoint("/v1/storefront/products/unique/:idOrSlug", { idOrSlug })}${queryParams}`,
1343
1348
  {
1344
1349
  buyerCurrency: true,
1345
1350
  cache: {
1346
- key: `product:${idOrSlug}:${shopId ?? "no-shop"}`,
1351
+ key: `product:${idOrSlug}:${shopId ?? "no-shop"}:${options.variant ?? "no-variant"}`,
1347
1352
  ttl: PRODUCTS_CACHE_TTL,
1348
1353
  staleWhileRevalidate: true
1349
1354
  }