@misiki/gocommerce-connector 0.25.0 → 0.26.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.
@@ -616,6 +616,7 @@ function toProduct(p, extra = {}) {
616
616
  freeGift: freeGiftOf(p),
617
617
  // Counted by the engine, rounded down, and absent rather than zero.
618
618
  soldAtLeast: typeof p.sold_at_least === "number" && p.sold_at_least > 0 ? p.sold_at_least : null,
619
+ designable: typeof p.designable === "boolean" ? p.designable : void 0,
619
620
  // Product-level stock is what a card shows before a variant is picked:
620
621
  // buyable when any live variant is, counted only where counting means
621
622
  // something.
@@ -676,6 +677,7 @@ function fromSearchDoc(d) {
676
677
  // built from it must not claim to count.
677
678
  manageInventory: false,
678
679
  allowBackorder: false,
680
+ designable: typeof d.designable === "boolean" ? d.designable : void 0,
679
681
  productTags: arr(d.tags).join(","),
680
682
  category: d.category ? { name: d.category.split(" / ").pop() ?? d.category, slug: "" } : null,
681
683
  vendor: d.vendor ? { businessName: d.vendor } : null,
@@ -1791,7 +1793,7 @@ var CartService = class extends BaseService {
1791
1793
  await this.data(`/api/carts/${encodeURIComponent(id2)}/line-items`, { method: "POST", body })
1792
1794
  );
1793
1795
  } catch (err) {
1794
- if (err instanceof GoCommerceError && /cart not found|checked out/.test(err.message)) {
1796
+ if (cartGone(err)) {
1795
1797
  const fresh = await this.open();
1796
1798
  return this.present(
1797
1799
  await this.data(`/api/carts/${encodeURIComponent(fresh)}/line-items`, { method: "POST", body })
@@ -2029,6 +2031,8 @@ var CartService = class extends BaseService {
2029
2031
  }
2030
2032
  };
2031
2033
  var clean = (id2) => id2 && id2 !== "undefined" && id2 !== "null" ? id2 : null;
2034
+ var cartGone = (err) => err instanceof GoCommerceError && (err.code === "cart_not_found" || err.code === "cart_checked_out" || cartGoneOnOlderEngine(err));
2035
+ var cartGoneOnOlderEngine = (err) => err.code === "not_found" && err.message === "cart not found" || err.code === "conflict" && err.message === "this cart has already been checked out";
2032
2036
  var cartService = new CartService();
2033
2037
 
2034
2038
  // src/services/customizer-service.ts
@@ -2450,7 +2454,8 @@ var OrderService = class extends BaseService {
2450
2454
  title: l.title,
2451
2455
  img: mediaUrl(l.image_url),
2452
2456
  price: toMajor(l.unit_price),
2453
- qty: l.quantity
2457
+ qty: l.quantity,
2458
+ designId: l.metadata?.design?.id ?? null
2454
2459
  });
2455
2460
  }
2456
2461
  }
@@ -2460,7 +2465,8 @@ var OrderService = class extends BaseService {
2460
2465
  return lines.flatMap((l, i) => {
2461
2466
  const p = live[i];
2462
2467
  if (!p) return [];
2463
- return [{ ...l, productId: String(l.productId), variantId: String(l.variantId), slug: p.slug }];
2468
+ const designable = typeof p.designable === "boolean" ? p.designable : void 0;
2469
+ return [{ ...l, productId: String(l.productId), variantId: String(l.variantId), slug: p.slug, designable }];
2464
2470
  });
2465
2471
  }
2466
2472
  /** The "someone just bought" popup would publish other shoppers' purchases; the engine offers none. */