@base44/app-plugin-commerce 0.1.12 → 0.1.14

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.
@@ -9,7 +9,7 @@
9
9
  * import { base44 } from "@/api/base44Client";
10
10
  * export const store = createStorefront(base44);
11
11
  *
12
- * It owns the two things hand-rolled clients keep getting wrong:
12
+ * It owns the things hand-rolled clients keep getting wrong:
13
13
  *
14
14
  * - The cart_token lifecycle: the token is sent with every cart/checkout call
15
15
  * and re-persisted from every response (a stale token silently starts a
@@ -17,6 +17,11 @@
17
17
  * - The store-info split: payment_gateways, currency, countries/currencies
18
18
  * live ONLY on get-store-info — the cart view never carries them.
19
19
  * getStoreInfo() caches the call; read them from there, never off a cart.
20
+ * - Envelope unwrapping: every method resolves straight to the data you use.
21
+ * listCategories() and listRibbons() resolve to ARRAYS — the raw actions'
22
+ * { categories } / { ribbons } wrappers are unwrapped here, so never dig
23
+ * for `.categories` on the result. Only the raw escape hatch inv(fn,
24
+ * payload) returns an action's payload as-is.
20
25
  */
21
26
 
22
27
  /** The stable error code a failed storefront call carries, if any. */
@@ -65,11 +70,13 @@ export function createStorefront(base44, { storageKey = "cart_token", storage }
65
70
  const by = typeof ref === "string" ? { slug: ref } : ref;
66
71
  return inv("commerce/storefront-catalog", { action: "get-product", ...by });
67
72
  },
73
+ /** ARRAY of root categories, subcategories nested under `children`. */
68
74
  listCategories() {
69
- return inv("commerce/storefront-catalog", { action: "list-categories" });
75
+ return inv("commerce/storefront-catalog", { action: "list-categories" }).then((d) => d.categories);
70
76
  },
77
+ /** ARRAY of { id, name, count }. */
71
78
  listRibbons() {
72
- return inv("commerce/storefront-catalog", { action: "list-ribbons" });
79
+ return inv("commerce/storefront-catalog", { action: "list-ribbons" }).then((d) => d.ribbons);
73
80
  },
74
81
 
75
82
  // ── cart (token handled internally; every call returns the full view) ─