webcake-storefront-mcp 1.36.1 → 1.36.2

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
@@ -1,8 +1,29 @@
1
+ import { BREAKPOINTS } from "./builder/grid.js";
1
2
  const DEFAULT_TIMEOUT = 15000;
2
3
  /** Stamped on every site and page this MCP server creates (backend columns `sites.by_ai`
3
4
  * and `pages.by_ai`), so the builder can flag AI-authored work. Mirrors the landing-page convention. */
4
5
  export const BY_AI_MARKER = "mcp";
6
+ const SETTINGS_READ_ERR = "Không đọc được site settings, huỷ lưu để tránh ghi đè rỗng";
5
7
  export class WebcakeCmsApi {
8
+ /** Parse (if string) and guarantee settings.breakpoints is a usable object — an empty/missing
9
+ * breakpoints would make the backend compile CSS without media queries. */
10
+ ensureSafeSettings(s) {
11
+ const obj = typeof s === "string" ? JSON.parse(s) : s && typeof s === "object" ? { ...s } : {};
12
+ const bp = obj.breakpoints;
13
+ const valid = bp && typeof bp === "object" && !Array.isArray(bp) &&
14
+ Object.values(bp).some((v) => Array.isArray(v) && v.length === 2 && v.every((n) => typeof n === "number"));
15
+ if (!valid)
16
+ obj.breakpoints = { ...BREAKPOINTS };
17
+ return obj;
18
+ }
19
+ async readSettingsOrThrow() {
20
+ try {
21
+ return await this.getSiteSettings();
22
+ }
23
+ catch (e) {
24
+ throw new Error(`${SETTINGS_READ_ERR}: ${e?.message || e}`);
25
+ }
26
+ }
6
27
  baseUrl;
7
28
  token;
8
29
  siteId;
@@ -253,8 +274,8 @@ export class WebcakeCmsApi {
253
274
  async saveGlobalSections({ global_sections = [], pages = [], settings, changes } = {}) {
254
275
  let s = settings;
255
276
  if (s === undefined)
256
- s = await this.getSiteSettings().catch(() => ({}));
257
- const settingsStr = typeof s === "string" ? s : JSON.stringify(s || {});
277
+ s = await this.readSettingsOrThrow();
278
+ const settingsStr = JSON.stringify(this.ensureSafeSettings(s));
258
279
  return this.request("POST", `/api/v1/site/${this.siteId}/save`, {
259
280
  body: {
260
281
  settings: settingsStr,
@@ -299,8 +320,8 @@ export class WebcakeCmsApi {
299
320
  return { rebuilt: 0 };
300
321
  let s = settings;
301
322
  if (s === undefined)
302
- s = await this.getSiteSettings().catch(() => ({}));
303
- const settingsStr = typeof s === "string" ? s : JSON.stringify(s || {});
323
+ s = await this.readSettingsOrThrow();
324
+ const settingsStr = JSON.stringify(this.ensureSafeSettings(s));
304
325
  const changes = {};
305
326
  for (const p of pages)
306
327
  changes[p.id] = 1;
@@ -327,11 +348,11 @@ export class WebcakeCmsApi {
327
348
  async publishSite(params = {}) {
328
349
  let settings = params.settings;
329
350
  if (settings === undefined) {
330
- settings = await this.getSiteSettings().catch(() => ({}));
351
+ settings = await this.readSettingsOrThrow();
331
352
  }
332
353
  // The save pipeline stores site.settings as a JSON STRING — an object body is
333
354
  // rejected (422). Stringify unless the caller already passed a string.
334
- const settingsStr = typeof settings === "string" ? settings : JSON.stringify(settings || {});
355
+ const settingsStr = JSON.stringify(this.ensureSafeSettings(settings));
335
356
  // Collect every page WITH its saved source so the backend has something to publish.
336
357
  let pages = params.pages;
337
358
  let changes = params.changes;
@@ -414,7 +435,7 @@ export class WebcakeCmsApi {
414
435
  }
415
436
  }
416
437
  async updateSiteSettings(newSettings) {
417
- return this.request("POST", `/api/v1/dashboard/site/${this.siteId}/update_site`, { body: { settings: newSettings }, timeout: 60000 });
438
+ return this.request("POST", `/api/v1/dashboard/site/${this.siteId}/update_site`, { body: { settings: this.ensureSafeSettings(newSettings) }, timeout: 60000 });
418
439
  }
419
440
  /** Read the full site.settings object (parsed). Empty object if unset/unparseable. */
420
441
  async getSiteSettings() {
@@ -427,7 +448,7 @@ export class WebcakeCmsApi {
427
448
  return JSON.parse(raw);
428
449
  }
429
450
  catch {
430
- return {};
451
+ throw new Error(`${SETTINGS_READ_ERR} (settings không phải JSON hợp lệ)`);
431
452
  }
432
453
  }
433
454
  return {};
@@ -1,4 +1,11 @@
1
1
  [
2
+ {
3
+ "v": "1.36.2",
4
+ "d": "29/10/2026",
5
+ "type": "Fixed",
6
+ "en": "publish_site, create_global_section, delete_global_section, update_site_custom_code, and append_site_custom_code now fail with a clear error instead…",
7
+ "vi": "publish_site, create_global_section, delete_global_section, update_site_custom_code và append_site_custom_code nay báo lỗi rõ ràng thay vì âm thầm…"
8
+ },
2
9
  {
3
10
  "v": "1.36.1",
4
11
  "d": "27/10/2026",
@@ -33,12 +40,5 @@
33
40
  "type": "Added",
34
41
  "en": "New list_section_templates tool browses the designer-made section template library (categories, search by term, thumbnails) for starting a section…",
35
42
  "vi": "Tool mới list_section_templates để duyệt thư viện mẫu section do designer tạo (theo danh mục, tìm kiếm bằng term, có thumbnail) làm điểm khởi đầu…"
36
- },
37
- {
38
- "v": "1.33.2",
39
- "d": "14/10/2026",
40
- "type": "Added",
41
- "en": "list_orders responses now include a status_name field alongside the numeric status.",
42
- "vi": "Kết quả trả về của list_orders nay có thêm trường status_name bên cạnh status dạng số."
43
43
  }
44
44
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webcake-storefront-mcp",
3
- "version": "1.36.1",
3
+ "version": "1.36.2",
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",