webcake-storefront-mcp 1.28.0 → 1.30.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/dist/api.js CHANGED
@@ -505,6 +505,11 @@ export class WebcakeCmsApi {
505
505
  return this.request("GET", `/api/v1/dashboard/site/${this.siteId}/combo_product/items`, { query: { combo_product_id: comboProductId, ...query } });
506
506
  }
507
507
  // ── Customers ──
508
+ /** List/search customers. Real shape: { customers: { data:[…], total_entries } }. Accepts
509
+ * page/limit and a `term` keyword (name/phone/email). Endpoint is /customer/all (singular). */
510
+ listCustomers(query) {
511
+ return this.request("GET", `/api/v1/dashboard/site/${this.siteId}/customer/all`, { query });
512
+ }
508
513
  findCustomerById(id) {
509
514
  return this.request("GET", `/api/v1/cms_function/${this.siteId}/customer/identity/${id}`);
510
515
  }
@@ -311,7 +311,9 @@ export function headerSection(opts = {}) {
311
311
  { label: "Sản phẩm", navTo: "collections" },
312
312
  { label: "Giỏ hàng", navTo: "cart" },
313
313
  ];
314
- const logo = { type: "text", opts: { text: opts.brand || "Shop", specials: { tag: "h2" }, style: { fontSize: "24px", fontWeight: "800", color: p.text } } };
314
+ const logo = opts.logo
315
+ ? { type: "image", opts: { config: { src: opts.logo }, style: { height: 40, width: 140 } } }
316
+ : { type: "text", opts: { text: opts.brand || "Shop", specials: { tag: "h2" }, style: { fontSize: "24px", fontWeight: "800", color: p.text } } };
315
317
  // Real designer templates use a `menu` of `menu-item`s, NOT text links — and a menu-item's
316
318
  // navigation lives in its SPECIALS (linkType/linkPage/pageId), not events. We build the
317
319
  // items directly (via buildElement, so buildFromSpec doesn't grid-stack the menu) and leave
@@ -327,16 +329,32 @@ export function headerSection(opts = {}) {
327
329
  children: menuItems,
328
330
  },
329
331
  };
332
+ // Right-hand actions: optional search / account / language, then cart + CTA — like real headers.
333
+ const actionChildren = [];
334
+ const actionWidths = [];
335
+ if (opts.search !== false) {
336
+ actionChildren.push({ type: "input-search", opts: { specials: { field_name: "search", placeholder: "Tìm kiếm sản phẩm...", showIcon: true }, config: { inputBackground: p.surfaceAlt, inputBorderColor: p.border, inputBorderRadius: "8px", iconColor: p.muted, placeholderColor: p.muted, iconAlign: "left" }, style: { height: 40 } } });
337
+ actionWidths.push({ unit: "px", absValue: 200 });
338
+ }
339
+ if (opts.account) {
340
+ actionChildren.push({ type: "member-bar", opts: { specials: { showView: "not_logged", layoutShow: "text", textLogin: "Đăng nhập", textSignup: "Đăng ký" }, config: { colorIcon: p.text }, style: { color: p.text } } });
341
+ actionWidths.push({ unit: "max-c" });
342
+ }
343
+ if (opts.language) {
344
+ actionChildren.push({ type: "language-menu", opts: { specials: { show_flag: true, type: "dropdown" }, config: { color: p.text, display: "abbreviated" } } });
345
+ actionWidths.push({ unit: "max-c" });
346
+ }
347
+ actionChildren.push({ type: "cart-icon", opts: { style: { width: 26, height: 26, color: p.text } } });
348
+ actionWidths.push({ unit: "px", absValue: 32 });
349
+ actionChildren.push(cta(opts.cta || "Đặt mua ngay", p, { navTo: "collections", height: 44 }));
350
+ actionWidths.push({ unit: "max-c" });
330
351
  const actions = {
331
352
  type: "container",
332
353
  layout: "row",
333
354
  columnGap: 16,
334
- colWidths: [{ unit: "px", absValue: 32 }, { unit: "max-c" }],
335
- collapse: { bp4: 2 },
336
- children: [
337
- { type: "cart-icon", opts: { style: { width: 26, height: 26, color: p.text } } },
338
- cta(opts.cta || "Đặt mua ngay", p, { navTo: "collections", height: 44 }),
339
- ],
355
+ colWidths: actionWidths,
356
+ collapse: { bp4: Math.min(2, actionChildren.length) },
357
+ children: actionChildren,
340
358
  };
341
359
  return buildSection([
342
360
  {
@@ -1,4 +1,18 @@
1
1
  [
2
+ {
3
+ "v": "1.30.0",
4
+ "d": "26/06/2026",
5
+ "type": "Added",
6
+ "en": "New list_customers tool browses or searches the site's customer list; accepts page, limit, and term (name/phone/email keyword) and returns a compact…",
7
+ "vi": "Tool mới list_customers duyệt hoặc tìm kiếm danh sách khách hàng của site; nhận các tham số page, limit và term (từ khóa tên/điện thoại/email) và…"
8
+ },
9
+ {
10
+ "v": "1.29.0",
11
+ "d": "26/06/2026",
12
+ "type": "Added",
13
+ "en": "scaffold_global_sections now accepts a logo parameter (hosted image URL) that renders an image element in the header instead of the brand-name text…",
14
+ "vi": "scaffold_global_sections nay nhận thêm tham số logo (URL hình ảnh được host) để hiển thị phần tử image trong header thay vì node text tên thương hiệu."
15
+ },
2
16
  {
3
17
  "v": "1.28.0",
4
18
  "d": "26/06/2026",
@@ -26,19 +40,5 @@
26
40
  "type": "Fixed",
27
41
  "en": "create_product now accepts a short_description parameter and sends it to the backend as [{description}] — the array shape the real product schema…",
28
42
  "vi": "create_product nay nhận thêm tham số short_description và gửi lên backend dưới dạng [{description}] — đúng kiểu mảng mà schema sản phẩm thực tế yêu…"
29
- },
30
- {
31
- "v": "1.25.0",
32
- "d": "26/06/2026",
33
- "type": "Changed",
34
- "en": "list_elements now documents 16 previously-uncovered element types, completing curated attribute coverage across all 132 factory types: popup…",
35
- "vi": "list_elements nay tài liệu hóa 16 kiểu phần tử trước đây chưa được ghi lại, hoàn thiện độ phủ thuộc tính curated cho toàn bộ 132 kiểu factory: popup…"
36
- },
37
- {
38
- "v": "1.24.0",
39
- "d": "26/06/2026",
40
- "type": "Changed",
41
- "en": "list_elements now documents tabIndex and text_animation_type as shared specials present on every element, covering tab-panel visibility binding and…",
42
- "vi": "list_elements nay tài liệu hóa tabIndex và text_animation_type là các specials dùng chung có trên mọi phần tử, bao gồm gắn kết hiển thị/ẩn cho…"
43
43
  }
44
44
  ]
@@ -1,5 +1,35 @@
1
1
  import { z } from "zod";
2
2
  export function registerCustomerTools(server, api, handle) {
3
+ server.tool("list_customers", "List/search the site's customers (browse or segment). Pass `term` to search by name/phone/email. Returns name, phone, email, order_count, purchased_amount, reward_point, tags, last_order_at. Use find_customer for an exact id/phone/email lookup.", {
4
+ page: z.number().optional().describe("Page number (default 1)"),
5
+ limit: z.number().optional().describe("Items per page (default 50)"),
6
+ term: z.string().optional().describe("Keyword — searches name / phone / email"),
7
+ }, ({ page, limit, term }) => handle(async () => {
8
+ const query = { page: page ?? 1, limit: limit ?? 50 };
9
+ if (term && term.trim())
10
+ query.term = term.trim();
11
+ const res = await api.listCustomers(query);
12
+ // Real shape: { customers: { data:[…], total_entries } }.
13
+ const box = (res && res.customers) || res || {};
14
+ const list = (Array.isArray(box) ? box : box.data) || [];
15
+ if (!Array.isArray(list))
16
+ return res;
17
+ return {
18
+ data: list.map((c) => ({
19
+ id: c.id,
20
+ name: c.name,
21
+ phone_number: c.phone_number || c.recent_phone_number || undefined,
22
+ email: c.email || undefined,
23
+ order_count: c.order_count ?? undefined,
24
+ succeed_order_count: c.succeed_order_count ?? undefined,
25
+ purchased_amount: c.purchased_amount ?? undefined,
26
+ reward_point: c.reward_point ?? undefined,
27
+ tags: c.tags && c.tags.length ? c.tags : undefined,
28
+ last_order_at: c.last_order_at || undefined,
29
+ })),
30
+ total: (box.total_entries ?? res.total) || list.length,
31
+ };
32
+ }));
3
33
  server.tool("find_customer", "Find a customer by ID, phone number, or email", {
4
34
  by: z.enum(["id", "phone", "email"]).describe("Search field"),
5
35
  value: z.string().describe("Search value"),
@@ -135,11 +135,15 @@ force=true. Two-step safety: dry_run=true (default) previews; dry_run=false perf
135
135
  links: z.array(z.object({ label: z.string(), navTo: z.string().optional(), url: z.string().optional() })).optional().describe("Header nav links. navTo = a page slug ('home','collections','cart') auto-wired to open_page; url = external link. Defaults to Home/Products/Cart."),
136
136
  contact: z.object({ phone: z.string().optional(), email: z.string().optional(), address: z.string().optional() }).optional().describe("Real contact info for the footer (don't invent — omit what you don't have)."),
137
137
  cta: z.string().optional().describe("Header call-to-action button label (default 'Đặt mua ngay')."),
138
+ logo: z.string().optional().describe("Logo image URL (hosted) — renders an image instead of the brand text."),
139
+ search: z.boolean().default(true).describe("Add a storefront search box to the header (most real templates have one)."),
140
+ account: z.boolean().default(false).describe("Add a login/account bar (member sites)."),
141
+ language: z.boolean().default(false).describe("Add a language switcher (multilingual sites)."),
138
142
  palette: z.record(z.any()).optional().describe("Optional colour overrides { accent, onAccent, text, muted, surface, surfaceAlt, border }."),
139
143
  include: z.enum(["both", "header", "footer"]).default("both").describe("Which chrome to generate."),
140
144
  force: z.boolean().default(false).describe("Create even if a header/footer global already exists (otherwise that slot is skipped)."),
141
145
  dry_run: z.boolean().default(true).describe("Preview (true) or perform the atomic save (false)."),
142
- }, ({ brand, links, contact, cta, palette, include, force, dry_run }) => handle(async () => {
146
+ }, ({ brand, links, contact, cta, logo, search, account, language, palette, include, force, dry_run }) => handle(async () => {
143
147
  // Which slots already have a global section? (dedupe by type unless force)
144
148
  const existingRes = await api.listGlobalSections().catch(() => null);
145
149
  const existing = (existingRes && (existingRes.data || existingRes.global_sections || existingRes)) || [];
@@ -174,7 +178,7 @@ force=true. Two-step safety: dry_run=true (default) previews; dry_run=false perf
174
178
  if (!force && slotTaken("header"))
175
179
  skipped.push("header");
176
180
  else
177
- toCreate.push({ type: "header", name: "Header", node: buildNode("header", headerSection({ brand, links: links, cta, palette })) });
181
+ toCreate.push({ type: "header", name: "Header", node: buildNode("header", headerSection({ brand, links: links, cta, logo, search, account, language, palette })) });
178
182
  }
179
183
  if (wantFooter) {
180
184
  if (!force && slotTaken("footer"))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webcake-storefront-mcp",
3
- "version": "1.28.0",
3
+ "version": "1.30.0",
4
4
  "description": "MCP server for the WebCake/StoreCake storefront builder — page CRUD, page authoring, products, orders, and more",
5
5
  "mcpName": "io.github.vuluu2k/webcake-storefront-mcp",
6
6
  "license": "MIT",