sbuilder-mcp 0.110.0 → 0.110.1
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/CHANGELOG.md +14 -0
- package/CHANGELOG.vi.md +14 -0
- package/README.md +2 -2
- package/README.vi.md +2 -2
- package/dist/catalog/api.generated.js +162 -5
- package/dist/catalog/deadkeys.generated.js +3 -3
- package/dist/catalog/elements.generated.js +95 -13
- package/dist/catalog/overlays.generated.js +2 -0
- package/dist/catalog/shapes.generated.js +23 -5
- package/dist/catalog/source.generated.js +2 -2
- package/dist/catalog/storepages.generated.js +2 -0
- package/dist/catalog/translations.generated.js +4 -1
- package/dist/core/tree.js +28 -0
- package/dist/domains/site/builder.js +68 -4
- package/dist/domains/site/document.js +9 -1
- package/dist/domains/site/inert.js +10 -8
- package/dist/tools/page.js +9 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,20 @@ All notable changes to this project are documented in this file.
|
|
|
6
6
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
7
7
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
8
|
|
|
9
|
+
## [0.110.1] - 2026-11-19
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- `sb_add` takes `menu_item_id` to turn a menu row into a mega panel, and `sb_outline` tags the panel with its row id and label.
|
|
13
|
+
- The `sale-badge` element gains a `tag` mode that binds product tags, and `product-variants` gains a `showAttributes` option.
|
|
14
|
+
- The API catalog grows to 1009 operations, adding `POST /api/v1/code-components/preview` and `GET /api/v1/pages/{id}/preview`.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- `sb_remove` of a mega panel clears its menu row's `panelId` in the same save.
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
- `sb_move` of a menu's mega panel and a same-page `sb_duplicate` of one are refused with a pointer to `sb_remove` or `menu_item_id`, instead of leaving a row that points at nothing.
|
|
21
|
+
- A mega panel added under its menu with `menu_item_id` no longer warns that it never renders.
|
|
22
|
+
|
|
9
23
|
## [0.110.0] - 2026-11-19
|
|
10
24
|
|
|
11
25
|
### Added
|
package/CHANGELOG.vi.md
CHANGED
|
@@ -6,6 +6,20 @@ Mọi thay đổi đáng chú ý của dự án được ghi lại trong file n
|
|
|
6
6
|
Định dạng dựa trên [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
7
7
|
và dự án tuân theo [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
8
|
|
|
9
|
+
## [0.110.1] - 2026-11-19
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- `sb_add` nhận `menu_item_id` để biến một hàng menu thành mega panel, và `sb_outline` gắn nhãn panel bằng id và nhãn của hàng đó.
|
|
13
|
+
- Phần tử `sale-badge` có thêm chế độ `tag` gắn thẻ sản phẩm, và `product-variants` có thêm tùy chọn `showAttributes`.
|
|
14
|
+
- Danh mục API tăng lên 1009 thao tác, thêm `POST /api/v1/code-components/preview` và `GET /api/v1/pages/{id}/preview`.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- `sb_remove` một mega panel xoá `panelId` của hàng menu tương ứng trong cùng một lần lưu.
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
- `sb_move` mega panel của menu và `sb_duplicate` nó trong cùng trang bị từ chối kèm gợi ý dùng `sb_remove` hoặc `menu_item_id`, thay vì để lại một hàng trỏ vào chỗ không có gì.
|
|
21
|
+
- Mega panel thêm vào menu bằng `menu_item_id` không còn bị cảnh báo là không bao giờ hiển thị.
|
|
22
|
+
|
|
9
23
|
## [0.110.0] - 2026-11-19
|
|
10
24
|
|
|
11
25
|
### Added
|
package/README.md
CHANGED
|
@@ -110,7 +110,7 @@ in this client: one would put the very key the platform exists to hold back into
|
|
|
110
110
|
| `sb_node_read` | One node in full, with a warning if it is a shared global |
|
|
111
111
|
| `sb_catalog_search` | Find an element by what it should do, using the platform's own AI hints |
|
|
112
112
|
| `sb_traits_for` | An element's inspector — tabs, groups, controls and what each declared one writes — plus its AI hints, defaults and containment rules |
|
|
113
|
-
| `sb_add` | Add an element — or a whole nested subtree — in one call; a filter arrives with its option rows read from the catalogue |
|
|
113
|
+
| `sb_add` | Add an element — or a whole nested subtree — in one call; a filter arrives with its option rows read from the catalogue; `menu_item_id` turns a menu row into a mega panel |
|
|
114
114
|
| `sb_set` | Write style/config/specials. Per breakpoint by default |
|
|
115
115
|
| `sb_move` | Move a node to another parent |
|
|
116
116
|
| `sb_remove` | Remove a node and its subtree |
|
|
@@ -142,7 +142,7 @@ in this client: one would put the very key the platform exists to hold back into
|
|
|
142
142
|
| `sb_store` | Run a store flow that must happen in a fixed order — `checkout` (the four writes that make a working one), `checkout_sync` (the store's current payment and delivery methods into every existing order form, checkout page republished), `form` (any of the platform's 17 templates with its own field document), `chrome` (one shared header or footer on a real site menu — site name linked home, desktop menu, mobile drawer, search, cart and account icons), `menu` (a menu node bound to the site's menu, its links resolved), `overlay_attach` (a pop-up or quick view on the open page), `cart` (the site's cart drawer, when it has none; `relocalize` puts an existing one in the site's language) and `app` (a built-in app plus the pages it needs), `global_attach` / `global_detach` (put an EXISTING shared section on the open page, or take it off), `global_promote` (make a section on the page a NEW shared section) and `template_save` (save a section as a reusable template) |
|
|
143
143
|
| `sb_undo` | Undo / redo this session's writes — page and form edits and `sb_api_call` PUTs, each named by tool and target, the open page's by default (`all: true` for every page); a page is refused if someone else saved it since. The platform's versions and history (`sb_page_version`) outlive this process |
|
|
144
144
|
|
|
145
|
-
Forty tools, **
|
|
145
|
+
Forty tools, **1011 API operations** (375 of the 466 writes carrying a body shape read
|
|
146
146
|
off the handler), 125 elements, 96 binding sources. `sb_api_find`
|
|
147
147
|
is an index rather than a tool per endpoint, so the tool list stays short while everything
|
|
148
148
|
the platform can do stays reachable — and operations added to the platform arrive with the
|
package/README.vi.md
CHANGED
|
@@ -106,7 +106,7 @@ nhét ngược lại vào mọi bản cài.
|
|
|
106
106
|
| `sb_node_read` | Một node đầy đủ, kèm cảnh báo nếu nó là global dùng chung |
|
|
107
107
|
| `sb_catalog_search` | Tìm element theo việc nó cần làm, dùng chính AI hints của nền tảng |
|
|
108
108
|
| `sb_traits_for` | Inspector của element — tab, nhóm, control và mỗi control khai báo sẵn ghi vào đâu — kèm AI hints, default và luật chứa con |
|
|
109
|
-
| `sb_add` | Thêm một element — hoặc cả cây con lồng nhau — trong một lần gọi; filter được tạo kèm sẵn các dòng lấy từ catalogue |
|
|
109
|
+
| `sb_add` | Thêm một element — hoặc cả cây con lồng nhau — trong một lần gọi; filter được tạo kèm sẵn các dòng lấy từ catalogue; `menu_item_id` biến một dòng menu thành mega panel |
|
|
110
110
|
| `sb_set` | Ghi style/config/specials. Mặc định theo breakpoint |
|
|
111
111
|
| `sb_move` | Chuyển node sang cha khác |
|
|
112
112
|
| `sb_remove` | Xoá node và cả cây con |
|
|
@@ -138,7 +138,7 @@ nhét ngược lại vào mọi bản cài.
|
|
|
138
138
|
| `sb_store` | Chạy một luồng cửa hàng bắt buộc đúng thứ tự — `checkout` (bốn lệnh ghi tạo nên trang thanh toán), `checkout_sync` (đưa phương thức thanh toán và giao hàng hiện tại vào mọi form đặt hàng đã có, publish lại trang thanh toán), `form` (một trong 17 template của nền tảng kèm field document của nó), `chrome` (một header hoặc footer dùng chung trên menu thật của site — tên site dẫn về trang chủ, menu desktop, drawer mobile, ô tìm kiếm, icon giỏ hàng và tài khoản), `menu` (một node menu bind vào menu của site, link đã phân giải), `overlay_attach` (một pop-up hay quick view trên trang đang mở), `cart` (ngăn giỏ hàng của site, khi chưa có; `relocalize` đưa ngăn giỏ đã có về ngôn ngữ của site), `app` (một app dựng sẵn kèm những trang nó cần), và `global_attach` / `global_detach` (đặt một section dùng chung ĐÃ CÓ lên trang đang mở, hoặc gỡ ra), `global_promote` (biến một section trên trang thành section dùng chung MỚI) và `template_save` (lưu một section làm mẫu dùng lại) |
|
|
139
139
|
| `sb_undo` | Hoàn tác / làm lại các thao tác ghi trong phiên — chỉnh sửa trang, form và PUT qua `sb_api_call`, mỗi mục ghi tên tool và đối tượng, mặc định của trang đang mở (`all: true` cho mọi trang); trang bị từ chối nếu người khác đã lưu sau đó. Version và history của nền tảng (`sb_page_version`) sống lâu hơn process này |
|
|
140
140
|
|
|
141
|
-
Bốn mươi tool, **
|
|
141
|
+
Bốn mươi tool, **1011 operation API** (375 trong 466 lệnh ghi có hình dạng body đọc thẳng
|
|
142
142
|
từ handler), 125 element, 96 nguồn binding. `sb_api_find` là
|
|
143
143
|
một chỉ mục chứ không phải mỗi endpoint một tool, nên danh sách tool vẫn ngắn trong khi mọi
|
|
144
144
|
thứ nền tảng làm được vẫn với tới — và operation mới thêm bên nền tảng sẽ tự có sau lần
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const SWAGGER_SOURCE = {
|
|
2
|
-
"operations":
|
|
3
|
-
"definitions":
|
|
4
|
-
"bodyCarrying":
|
|
2
|
+
"operations": 1011,
|
|
3
|
+
"definitions": 444,
|
|
4
|
+
"bodyCarrying": 487,
|
|
5
5
|
"bodyUndescribed": 122,
|
|
6
6
|
"generatedFrom": "server/docs/swagger.json"
|
|
7
7
|
};
|
|
@@ -28999,6 +28999,27 @@ export const API_OPERATIONS = [
|
|
|
28999
28999
|
"bodyRef": "internal_publicapi.CodeComponentInput",
|
|
29000
29000
|
"credential": "apiKey"
|
|
29001
29001
|
},
|
|
29002
|
+
{
|
|
29003
|
+
"id": "post:/api/v1/code-components/preview",
|
|
29004
|
+
"method": "POST",
|
|
29005
|
+
"path": "/api/v1/code-components/preview",
|
|
29006
|
+
"tags": [
|
|
29007
|
+
"v1"
|
|
29008
|
+
],
|
|
29009
|
+
"summary": "Render an unstored SSR bundle once, before uploading it",
|
|
29010
|
+
"params": [
|
|
29011
|
+
{
|
|
29012
|
+
"name": "preview",
|
|
29013
|
+
"in": "body",
|
|
29014
|
+
"required": true,
|
|
29015
|
+
"type": "object",
|
|
29016
|
+
"description": "Bundle, props schema and props"
|
|
29017
|
+
}
|
|
29018
|
+
],
|
|
29019
|
+
"bodyDescribed": true,
|
|
29020
|
+
"bodyRef": "internal_publicapi.CodeComponentPreviewInput",
|
|
29021
|
+
"credential": "apiKey"
|
|
29022
|
+
},
|
|
29002
29023
|
{
|
|
29003
29024
|
"id": "get:/api/v1/code-components/{name}",
|
|
29004
29025
|
"method": "GET",
|
|
@@ -31135,6 +31156,27 @@ export const API_OPERATIONS = [
|
|
|
31135
31156
|
"bodyRef": "internal_publicapi.PageDocumentInput",
|
|
31136
31157
|
"credential": "apiKey"
|
|
31137
31158
|
},
|
|
31159
|
+
{
|
|
31160
|
+
"id": "get:/api/v1/pages/{id}/preview",
|
|
31161
|
+
"method": "GET",
|
|
31162
|
+
"path": "/api/v1/pages/{id}/preview",
|
|
31163
|
+
"tags": [
|
|
31164
|
+
"v1"
|
|
31165
|
+
],
|
|
31166
|
+
"summary": "Mint a draft-preview link for one page",
|
|
31167
|
+
"params": [
|
|
31168
|
+
{
|
|
31169
|
+
"name": "id",
|
|
31170
|
+
"in": "path",
|
|
31171
|
+
"required": true,
|
|
31172
|
+
"type": "string",
|
|
31173
|
+
"description": "Page ID"
|
|
31174
|
+
}
|
|
31175
|
+
],
|
|
31176
|
+
"bodyDescribed": false,
|
|
31177
|
+
"bodyRef": null,
|
|
31178
|
+
"credential": "apiKey"
|
|
31179
|
+
},
|
|
31138
31180
|
{
|
|
31139
31181
|
"id": "post:/api/v1/pages/{id}/publish",
|
|
31140
31182
|
"method": "POST",
|
|
@@ -31394,6 +31436,48 @@ export const API_OPERATIONS = [
|
|
|
31394
31436
|
"bodyRef": "internal_publicapi.ProductInput",
|
|
31395
31437
|
"credential": "apiKey"
|
|
31396
31438
|
},
|
|
31439
|
+
{
|
|
31440
|
+
"id": "get:/api/v1/site-settings",
|
|
31441
|
+
"method": "GET",
|
|
31442
|
+
"path": "/api/v1/site-settings",
|
|
31443
|
+
"tags": [
|
|
31444
|
+
"v1"
|
|
31445
|
+
],
|
|
31446
|
+
"summary": "Read or save the site's settings",
|
|
31447
|
+
"params": [
|
|
31448
|
+
{
|
|
31449
|
+
"name": "siteSettings",
|
|
31450
|
+
"in": "body",
|
|
31451
|
+
"required": false,
|
|
31452
|
+
"type": "object",
|
|
31453
|
+
"description": "The settings to save (PUT only)"
|
|
31454
|
+
}
|
|
31455
|
+
],
|
|
31456
|
+
"bodyDescribed": true,
|
|
31457
|
+
"bodyRef": "internal_publicapi.SiteSettingsInput",
|
|
31458
|
+
"credential": "apiKey"
|
|
31459
|
+
},
|
|
31460
|
+
{
|
|
31461
|
+
"id": "put:/api/v1/site-settings",
|
|
31462
|
+
"method": "PUT",
|
|
31463
|
+
"path": "/api/v1/site-settings",
|
|
31464
|
+
"tags": [
|
|
31465
|
+
"v1"
|
|
31466
|
+
],
|
|
31467
|
+
"summary": "Read or save the site's settings",
|
|
31468
|
+
"params": [
|
|
31469
|
+
{
|
|
31470
|
+
"name": "siteSettings",
|
|
31471
|
+
"in": "body",
|
|
31472
|
+
"required": false,
|
|
31473
|
+
"type": "object",
|
|
31474
|
+
"description": "The settings to save (PUT only)"
|
|
31475
|
+
}
|
|
31476
|
+
],
|
|
31477
|
+
"bodyDescribed": true,
|
|
31478
|
+
"bodyRef": "internal_publicapi.SiteSettingsInput",
|
|
31479
|
+
"credential": "apiKey"
|
|
31480
|
+
},
|
|
31397
31481
|
{
|
|
31398
31482
|
"id": "get:/api/v1/theme",
|
|
31399
31483
|
"method": "GET",
|
|
@@ -40619,6 +40703,29 @@ export const API_DEFINITIONS = {
|
|
|
40619
40703
|
}
|
|
40620
40704
|
}
|
|
40621
40705
|
},
|
|
40706
|
+
"internal_publicapi.CodeComponentPreviewInput": {
|
|
40707
|
+
"type": "object",
|
|
40708
|
+
"properties": {
|
|
40709
|
+
"props": {
|
|
40710
|
+
"type": "object",
|
|
40711
|
+
"additionalProperties": {}
|
|
40712
|
+
},
|
|
40713
|
+
"propsSchema": {
|
|
40714
|
+
"type": "object"
|
|
40715
|
+
},
|
|
40716
|
+
"ssrBundle": {
|
|
40717
|
+
"type": "string"
|
|
40718
|
+
}
|
|
40719
|
+
}
|
|
40720
|
+
},
|
|
40721
|
+
"internal_publicapi.CodeComponentPreviewResponse": {
|
|
40722
|
+
"type": "object",
|
|
40723
|
+
"properties": {
|
|
40724
|
+
"html": {
|
|
40725
|
+
"type": "string"
|
|
40726
|
+
}
|
|
40727
|
+
}
|
|
40728
|
+
},
|
|
40622
40729
|
"internal_publicapi.CodeComponentResponse": {
|
|
40623
40730
|
"type": "object",
|
|
40624
40731
|
"properties": {
|
|
@@ -42057,6 +42164,23 @@ export const API_DEFINITIONS = {
|
|
|
42057
42164
|
}
|
|
42058
42165
|
}
|
|
42059
42166
|
},
|
|
42167
|
+
"internal_publicapi.PagePreview": {
|
|
42168
|
+
"type": "object",
|
|
42169
|
+
"properties": {
|
|
42170
|
+
"url": {
|
|
42171
|
+
"description": "URL opens the page's saved draft as a visitor would see it. Signed, valid\nfor one hour, needs no credential: whoever holds it can view the draft.",
|
|
42172
|
+
"type": "string"
|
|
42173
|
+
}
|
|
42174
|
+
}
|
|
42175
|
+
},
|
|
42176
|
+
"internal_publicapi.PagePreviewResponse": {
|
|
42177
|
+
"type": "object",
|
|
42178
|
+
"properties": {
|
|
42179
|
+
"preview": {
|
|
42180
|
+
"$ref": "#/definitions/internal_publicapi.PagePreview"
|
|
42181
|
+
}
|
|
42182
|
+
}
|
|
42183
|
+
},
|
|
42060
42184
|
"internal_publicapi.PageResponse": {
|
|
42061
42185
|
"type": "object",
|
|
42062
42186
|
"properties": {
|
|
@@ -42281,16 +42405,49 @@ export const API_DEFINITIONS = {
|
|
|
42281
42405
|
}
|
|
42282
42406
|
}
|
|
42283
42407
|
},
|
|
42284
|
-
"internal_publicapi.
|
|
42408
|
+
"internal_publicapi.SiteSettings": {
|
|
42409
|
+
"type": "object",
|
|
42410
|
+
"properties": {
|
|
42411
|
+
"document": {
|
|
42412
|
+
"description": "Document is null until settings have been saved.",
|
|
42413
|
+
"type": "object"
|
|
42414
|
+
},
|
|
42415
|
+
"updatedAt": {
|
|
42416
|
+
"description": "UpdatedAt is \"\" until settings have been saved. Send it back as\nexpectedUpdatedAt.",
|
|
42417
|
+
"type": "string"
|
|
42418
|
+
}
|
|
42419
|
+
}
|
|
42420
|
+
},
|
|
42421
|
+
"internal_publicapi.SiteSettingsInput": {
|
|
42285
42422
|
"type": "object",
|
|
42286
42423
|
"properties": {
|
|
42287
42424
|
"document": {
|
|
42288
|
-
"description": "Document is null until a theme has been saved.",
|
|
42289
42425
|
"type": "array",
|
|
42290
42426
|
"items": {
|
|
42291
42427
|
"type": "integer"
|
|
42292
42428
|
}
|
|
42293
42429
|
},
|
|
42430
|
+
"expectedUpdatedAt": {
|
|
42431
|
+
"description": "ExpectedUpdatedAt is the `updatedAt` you read (\"\" when none was saved\nyet). REQUIRED to be present: a settings save replaces the whole document\nand is live at once, so a blind write is refused rather than defaulted.",
|
|
42432
|
+
"type": "string"
|
|
42433
|
+
}
|
|
42434
|
+
}
|
|
42435
|
+
},
|
|
42436
|
+
"internal_publicapi.SiteSettingsResponse": {
|
|
42437
|
+
"type": "object",
|
|
42438
|
+
"properties": {
|
|
42439
|
+
"siteSettings": {
|
|
42440
|
+
"$ref": "#/definitions/internal_publicapi.SiteSettings"
|
|
42441
|
+
}
|
|
42442
|
+
}
|
|
42443
|
+
},
|
|
42444
|
+
"internal_publicapi.Theme": {
|
|
42445
|
+
"type": "object",
|
|
42446
|
+
"properties": {
|
|
42447
|
+
"document": {
|
|
42448
|
+
"description": "Document is null until a theme has been saved.",
|
|
42449
|
+
"type": "object"
|
|
42450
|
+
},
|
|
42294
42451
|
"updatedAt": {
|
|
42295
42452
|
"description": "UpdatedAt is \"\" until a theme has been saved. Send it back as\nexpectedUpdatedAt.",
|
|
42296
42453
|
"type": "string"
|
|
@@ -16026,7 +16026,7 @@ export const ELEMENTS = {
|
|
|
16026
16026
|
"Use a consistent image ratio (config.featureImageRatio) so the layout does not jump between images — default is a uniform 1:1 square; \"auto\" uses each image's natural size.",
|
|
16027
16027
|
"Hover-zoom is on by default at 150% (config.hoverZoomValue); set it to 100 to disable, or raise it up to 300 for a closer zoom.",
|
|
16028
16028
|
"Nav arrows sit \"inside\" (overlaid) or \"outside\" the image via config.listNavPosition.",
|
|
16029
|
-
"config.hoverSwapImage
|
|
16029
|
+
"config.hoverSwapImage fades in the NEXT gallery photo while the pointer is on the tile OR anywhere on the linked product card around it — the product-grid effect, nothing else to set. It needs a gallery of 2+, is off by default, and does nothing on a touch screen (no pointer), so a phone keeps the first photo."
|
|
16030
16030
|
],
|
|
16031
16031
|
"semantics": [
|
|
16032
16032
|
"product-image",
|
|
@@ -17123,7 +17123,9 @@ export const ELEMENTS = {
|
|
|
17123
17123
|
"direction": "vertical",
|
|
17124
17124
|
"gap": 8
|
|
17125
17125
|
},
|
|
17126
|
-
"optionGap": ""
|
|
17126
|
+
"optionGap": "",
|
|
17127
|
+
"showAttributes": [],
|
|
17128
|
+
"pickAction": "select"
|
|
17127
17129
|
},
|
|
17128
17130
|
"specials": {
|
|
17129
17131
|
"displayType": "select",
|
|
@@ -17356,7 +17358,9 @@ export const ELEMENTS = {
|
|
|
17356
17358
|
"key": "variant_display",
|
|
17357
17359
|
"label": "Variant display",
|
|
17358
17360
|
"controls": [
|
|
17359
|
-
"variant_display"
|
|
17361
|
+
"variant_display",
|
|
17362
|
+
"variant_show_attributes",
|
|
17363
|
+
"variant_pick_action"
|
|
17360
17364
|
]
|
|
17361
17365
|
},
|
|
17362
17366
|
{
|
|
@@ -17452,6 +17456,8 @@ export const ELEMENTS = {
|
|
|
17452
17456
|
"displayType",
|
|
17453
17457
|
"defaultVariant",
|
|
17454
17458
|
"variant_display",
|
|
17459
|
+
"variant_show_attributes",
|
|
17460
|
+
"variant_pick_action",
|
|
17455
17461
|
"variant_label",
|
|
17456
17462
|
"variant_option",
|
|
17457
17463
|
"width_select",
|
|
@@ -17483,6 +17489,10 @@ export const ELEMENTS = {
|
|
|
17483
17489
|
"Seed config.attributes with { name, values } objects — one per product attribute",
|
|
17484
17490
|
"Use specials.displayType: \"select\" for a dropdown, \"image_label\" for image+label buttons, or \"image\" for image swatches",
|
|
17485
17491
|
"Use specials.defaultVariant.enabled + values to pre-select a value per attribute",
|
|
17492
|
+
"A product CARD in a list (product-list / dataset card) should usually show only the colour axis: set config.showAttributes to that one attribute name (e.g. [\"Color\"] or [\"Màu sắc\"]) and leave Size for the product page buy box, which keeps showAttributes empty (= every attribute)",
|
|
17493
|
+
"config.showAttributes matches attribute names trimmed and case-insensitively, keeps the product order, and drops a name the product does not have",
|
|
17494
|
+
"config.pickAction: \"add_to_cart\" turns every value into a quick-add button — clicking a size selects it AND adds that variant (quantity 1) to the cart, keeping any colour already picked elsewhere on the card. Use it for a product-CARD quick add (showAttributes [\"Size\"], specials.displayType \"image_label\"), usually inside a flex-block overlay with config.revealOnHover true; keep the default \"select\" on a product page buy box, where an Add to cart button does the adding",
|
|
17495
|
+
"Sold-out values are crossed out automatically on the published page (both modes); in \"add_to_cart\" mode they cannot be clicked. Do not hand-style or hide them",
|
|
17486
17496
|
"Style the attribute labels through the product-variant-label satellite and the options through the product-variant-option satellite",
|
|
17487
17497
|
"Do not add children — the blocks, labels and options are rendered internally"
|
|
17488
17498
|
],
|
|
@@ -27854,8 +27864,10 @@ export const ELEMENTS = {
|
|
|
27854
27864
|
"specials": {
|
|
27855
27865
|
"mode": "percent",
|
|
27856
27866
|
"text": "Sale",
|
|
27867
|
+
"tag": "",
|
|
27857
27868
|
"boundPriceCents": "",
|
|
27858
|
-
"boundCompareCents": ""
|
|
27869
|
+
"boundCompareCents": "",
|
|
27870
|
+
"boundTags": ""
|
|
27859
27871
|
},
|
|
27860
27872
|
"style": {
|
|
27861
27873
|
"display": "inline-flex",
|
|
@@ -27887,6 +27899,11 @@ export const ELEMENTS = {
|
|
|
27887
27899
|
"source": "product.compareAtCents",
|
|
27888
27900
|
"field": "specials.boundCompareCents"
|
|
27889
27901
|
},
|
|
27902
|
+
{
|
|
27903
|
+
"id": "bind-tags",
|
|
27904
|
+
"source": "product.tags",
|
|
27905
|
+
"field": "specials.boundTags"
|
|
27906
|
+
},
|
|
27890
27907
|
{
|
|
27891
27908
|
"id": "bind-product-id",
|
|
27892
27909
|
"source": "product.id",
|
|
@@ -27911,6 +27928,11 @@ export const ELEMENTS = {
|
|
|
27911
27928
|
"source": "product.compareAtCents",
|
|
27912
27929
|
"field": "specials.boundCompareCents"
|
|
27913
27930
|
},
|
|
27931
|
+
{
|
|
27932
|
+
"id": "bind-tags",
|
|
27933
|
+
"source": "product.tags",
|
|
27934
|
+
"field": "specials.boundTags"
|
|
27935
|
+
},
|
|
27914
27936
|
{
|
|
27915
27937
|
"id": "bind-product-id",
|
|
27916
27938
|
"source": "product.id",
|
|
@@ -27933,6 +27955,11 @@ export const ELEMENTS = {
|
|
|
27933
27955
|
"source": "product.compareAtCents",
|
|
27934
27956
|
"field": "specials.boundCompareCents"
|
|
27935
27957
|
},
|
|
27958
|
+
{
|
|
27959
|
+
"id": "bind-tags",
|
|
27960
|
+
"source": "product.tags",
|
|
27961
|
+
"field": "specials.boundTags"
|
|
27962
|
+
},
|
|
27936
27963
|
{
|
|
27937
27964
|
"id": "bind-product-id",
|
|
27938
27965
|
"source": "product.id",
|
|
@@ -27955,6 +27982,11 @@ export const ELEMENTS = {
|
|
|
27955
27982
|
"source": "product.compareAtCents",
|
|
27956
27983
|
"field": "specials.boundCompareCents"
|
|
27957
27984
|
},
|
|
27985
|
+
{
|
|
27986
|
+
"id": "bind-tags",
|
|
27987
|
+
"source": "product.tags",
|
|
27988
|
+
"field": "specials.boundTags"
|
|
27989
|
+
},
|
|
27958
27990
|
{
|
|
27959
27991
|
"id": "bind-product-id",
|
|
27960
27992
|
"source": "product.id",
|
|
@@ -27977,6 +28009,11 @@ export const ELEMENTS = {
|
|
|
27977
28009
|
"source": "product.compareAtCents",
|
|
27978
28010
|
"field": "specials.boundCompareCents"
|
|
27979
28011
|
},
|
|
28012
|
+
{
|
|
28013
|
+
"id": "bind-tags",
|
|
28014
|
+
"source": "product.tags",
|
|
28015
|
+
"field": "specials.boundTags"
|
|
28016
|
+
},
|
|
27980
28017
|
{
|
|
27981
28018
|
"id": "bind-product-id",
|
|
27982
28019
|
"source": "product.id",
|
|
@@ -27999,6 +28036,11 @@ export const ELEMENTS = {
|
|
|
27999
28036
|
"source": "product.compareAtCents",
|
|
28000
28037
|
"field": "specials.boundCompareCents"
|
|
28001
28038
|
},
|
|
28039
|
+
{
|
|
28040
|
+
"id": "bind-tags",
|
|
28041
|
+
"source": "product.tags",
|
|
28042
|
+
"field": "specials.boundTags"
|
|
28043
|
+
},
|
|
28002
28044
|
{
|
|
28003
28045
|
"id": "bind-product-id",
|
|
28004
28046
|
"source": "product.id",
|
|
@@ -28021,6 +28063,11 @@ export const ELEMENTS = {
|
|
|
28021
28063
|
"source": "product.compareAtCents",
|
|
28022
28064
|
"field": "specials.boundCompareCents"
|
|
28023
28065
|
},
|
|
28066
|
+
{
|
|
28067
|
+
"id": "bind-tags",
|
|
28068
|
+
"source": "product.tags",
|
|
28069
|
+
"field": "specials.boundTags"
|
|
28070
|
+
},
|
|
28024
28071
|
{
|
|
28025
28072
|
"id": "bind-product-id",
|
|
28026
28073
|
"source": "product.id",
|
|
@@ -28043,6 +28090,11 @@ export const ELEMENTS = {
|
|
|
28043
28090
|
"source": "product.compareAtCents",
|
|
28044
28091
|
"field": "specials.boundCompareCents"
|
|
28045
28092
|
},
|
|
28093
|
+
{
|
|
28094
|
+
"id": "bind-tags",
|
|
28095
|
+
"source": "product.tags",
|
|
28096
|
+
"field": "specials.boundTags"
|
|
28097
|
+
},
|
|
28046
28098
|
{
|
|
28047
28099
|
"id": "bind-product-id",
|
|
28048
28100
|
"source": "product.id",
|
|
@@ -28065,6 +28117,11 @@ export const ELEMENTS = {
|
|
|
28065
28117
|
"source": "product.compareAtCents",
|
|
28066
28118
|
"field": "specials.boundCompareCents"
|
|
28067
28119
|
},
|
|
28120
|
+
{
|
|
28121
|
+
"id": "bind-tags",
|
|
28122
|
+
"source": "product.tags",
|
|
28123
|
+
"field": "specials.boundTags"
|
|
28124
|
+
},
|
|
28068
28125
|
{
|
|
28069
28126
|
"id": "bind-product-id",
|
|
28070
28127
|
"source": "product.id",
|
|
@@ -28084,7 +28141,8 @@ export const ELEMENTS = {
|
|
|
28084
28141
|
"product",
|
|
28085
28142
|
"productId",
|
|
28086
28143
|
"boundPriceCents",
|
|
28087
|
-
"boundCompareCents"
|
|
28144
|
+
"boundCompareCents",
|
|
28145
|
+
"boundTags"
|
|
28088
28146
|
]
|
|
28089
28147
|
},
|
|
28090
28148
|
{
|
|
@@ -28092,7 +28150,8 @@ export const ELEMENTS = {
|
|
|
28092
28150
|
"label": "Content",
|
|
28093
28151
|
"controls": [
|
|
28094
28152
|
"sale_badge_mode",
|
|
28095
|
-
"sale_badge_text"
|
|
28153
|
+
"sale_badge_text",
|
|
28154
|
+
"sale_badge_tag"
|
|
28096
28155
|
]
|
|
28097
28156
|
},
|
|
28098
28157
|
{
|
|
@@ -28186,8 +28245,10 @@ export const ELEMENTS = {
|
|
|
28186
28245
|
"productId",
|
|
28187
28246
|
"boundPriceCents",
|
|
28188
28247
|
"boundCompareCents",
|
|
28248
|
+
"boundTags",
|
|
28189
28249
|
"sale_badge_mode",
|
|
28190
28250
|
"sale_badge_text",
|
|
28251
|
+
"sale_badge_tag",
|
|
28191
28252
|
"width_select",
|
|
28192
28253
|
"height_select",
|
|
28193
28254
|
"size_bounds",
|
|
@@ -28207,18 +28268,21 @@ export const ELEMENTS = {
|
|
|
28207
28268
|
"animation",
|
|
28208
28269
|
"class_css"
|
|
28209
28270
|
],
|
|
28210
|
-
"description": "A small
|
|
28271
|
+
"description": "A small pill for a product card or product page: \"−20%\" / \"Sale\" computed from the bound product's price and compare-at cents, or a merchandising label like \"NEW\" / \"BÁN CHẠY\" driven by the product's tags. Purely static — no island, no runtime module. Three content modes: specials.mode \"percent\" shows a computed \"−N%\"; \"text\" shows an authored word (default \"Sale\"); \"tag\" shows specials.text only when the bound product carries the tag in specials.tag (trimmed, case-insensitive). percent/text render nothing when the product has no real saving (no compare-at price, or compare-at at or below price) — it never invents a discount; tag mode renders nothing when the product lacks the tag.",
|
|
28211
28272
|
"useWhen": [
|
|
28212
28273
|
"A product card or product page needs a quick visual flag that the item is on sale",
|
|
28213
|
-
"Beside a pricing-dataset price display, to draw attention to the struck-through compare-at"
|
|
28274
|
+
"Beside a pricing-dataset price display, to draw attention to the struck-through compare-at",
|
|
28275
|
+
"A product card needs a NEW / BEST SELLER / BÁN CHẠY pill on only the products the merchant tagged — use specials.mode \"tag\""
|
|
28214
28276
|
],
|
|
28215
28277
|
"avoidWhen": [
|
|
28216
28278
|
"The exact amount saved needs to show in money (\"tiết kiệm 50.000₫\") — this element only shows a percentage or a fixed word, never a formatted amount",
|
|
28217
|
-
"The badge should show on every product regardless of a real discount — that is authored text, not this element"
|
|
28279
|
+
"The badge should show on every product regardless of a real discount or tag — that is authored text, not this element"
|
|
28218
28280
|
],
|
|
28219
28281
|
"contentTips": [
|
|
28220
28282
|
"Leave specials.mode as \"percent\" for a computed \"−N%\"; set it to \"text\" for a generic word like \"Sale\" instead",
|
|
28221
|
-
"The percentage and the visibility both come from the bound product — nothing to seed here beyond the mode/text choice"
|
|
28283
|
+
"The percentage and the visibility both come from the bound product — nothing to seed here beyond the mode/text choice",
|
|
28284
|
+
"For a NEW / BEST SELLER pill set specials.mode \"tag\", specials.tag to the product tag to match (e.g. \"new\", \"ban-chay\") and specials.text to the word shown (e.g. \"NEW\", \"BÁN CHẠY\"); one badge per tag — stack two badges for two pills",
|
|
28285
|
+
"Tag mode reads specials.boundTags, filled by the binding {\"id\":\"bind-tags\",\"source\":\"product.tags\",\"field\":\"specials.boundTags\"} that the editor adds on drop. A badge authored OUTSIDE the editor (sb page source, MCP sb_add) must carry that binding — or be bound with sb_bind product.tags → specials.boundTags — or it renders nothing"
|
|
28222
28286
|
],
|
|
28223
28287
|
"semantics": [
|
|
28224
28288
|
"product",
|
|
@@ -28227,7 +28291,10 @@ export const ELEMENTS = {
|
|
|
28227
28291
|
"ecommerce",
|
|
28228
28292
|
"price",
|
|
28229
28293
|
"badge",
|
|
28230
|
-
"promotion"
|
|
28294
|
+
"promotion",
|
|
28295
|
+
"tag",
|
|
28296
|
+
"new",
|
|
28297
|
+
"bestseller"
|
|
28231
28298
|
]
|
|
28232
28299
|
},
|
|
28233
28300
|
"flash-sale-price": {
|
|
@@ -36729,7 +36796,8 @@ export const BOUND_SPECIALS = {
|
|
|
36729
36796
|
],
|
|
36730
36797
|
"sale-badge": [
|
|
36731
36798
|
"boundCompareCents",
|
|
36732
|
-
"boundPriceCents"
|
|
36799
|
+
"boundPriceCents",
|
|
36800
|
+
"boundTags"
|
|
36733
36801
|
],
|
|
36734
36802
|
"spline-scene": [
|
|
36735
36803
|
"boundModel"
|
|
@@ -38804,6 +38872,17 @@ export const TRAIT_WRITES = {
|
|
|
38804
38872
|
}
|
|
38805
38873
|
]
|
|
38806
38874
|
},
|
|
38875
|
+
"sale_badge_tag": {
|
|
38876
|
+
"key": "sale_badge_tag",
|
|
38877
|
+
"label": "Tag",
|
|
38878
|
+
"writes": [
|
|
38879
|
+
{
|
|
38880
|
+
"target": "specials",
|
|
38881
|
+
"writeKey": "tag",
|
|
38882
|
+
"type": "string"
|
|
38883
|
+
}
|
|
38884
|
+
]
|
|
38885
|
+
},
|
|
38807
38886
|
"flash_sale_show_percent": {
|
|
38808
38887
|
"key": "flash_sale_show_percent",
|
|
38809
38888
|
"label": "Show −X%",
|
|
@@ -41410,7 +41489,8 @@ export const ELEMENT_VALUES = {
|
|
|
41410
41489
|
"writeKey": "mode",
|
|
41411
41490
|
"values": [
|
|
41412
41491
|
"percent",
|
|
41413
|
-
"text"
|
|
41492
|
+
"text",
|
|
41493
|
+
"tag"
|
|
41414
41494
|
],
|
|
41415
41495
|
"readBy": "sale_badge_mode (editor picker)"
|
|
41416
41496
|
}
|
|
@@ -41481,6 +41561,8 @@ export const BASE_ONLY_CONFIG = [
|
|
|
41481
41561
|
"backgroundSceneModelUrl",
|
|
41482
41562
|
"rowLimit",
|
|
41483
41563
|
"clampTitle",
|
|
41564
|
+
"showAttributes",
|
|
41565
|
+
"pickAction",
|
|
41484
41566
|
"optionSource",
|
|
41485
41567
|
"recordAggregates",
|
|
41486
41568
|
"recordCollectionId",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export const SHAPE_SOURCE = {
|
|
2
|
-
"writeOperations":
|
|
3
|
-
"shaped":
|
|
4
|
-
"fromHandlers":
|
|
5
|
-
"fromSwaggerOnly":
|
|
2
|
+
"writeOperations": 466,
|
|
3
|
+
"shaped": 375,
|
|
4
|
+
"fromHandlers": 363,
|
|
5
|
+
"fromSwaggerOnly": 12,
|
|
6
6
|
"withReadOnly": 29,
|
|
7
|
-
"structsRead":
|
|
7
|
+
"structsRead": 3870
|
|
8
8
|
};
|
|
9
9
|
export const REQUEST_SHAPES = {
|
|
10
10
|
"post:/api/ai/credits": {
|
|
@@ -10288,6 +10288,24 @@ export const REQUEST_SHAPES = {
|
|
|
10288
10288
|
"source": "go",
|
|
10289
10289
|
"goType": "CodeComponentInput"
|
|
10290
10290
|
},
|
|
10291
|
+
"post:/api/v1/code-components/preview": {
|
|
10292
|
+
"fields": [
|
|
10293
|
+
{
|
|
10294
|
+
"name": "ssrBundle",
|
|
10295
|
+
"type": "string"
|
|
10296
|
+
},
|
|
10297
|
+
{
|
|
10298
|
+
"name": "propsSchema",
|
|
10299
|
+
"type": "object"
|
|
10300
|
+
},
|
|
10301
|
+
{
|
|
10302
|
+
"name": "props",
|
|
10303
|
+
"type": "{ [string]: any }"
|
|
10304
|
+
}
|
|
10305
|
+
],
|
|
10306
|
+
"source": "go",
|
|
10307
|
+
"goType": "CodeComponentPreviewInput"
|
|
10308
|
+
},
|
|
10291
10309
|
"post:/api/v1/code-files": {
|
|
10292
10310
|
"fields": [
|
|
10293
10311
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// GENERATED by scripts/gen-catalog.ts — do not edit by hand.
|
|
2
2
|
// The platform commit every other generated file here describes.
|
|
3
3
|
export const PLATFORM_SOURCE = {
|
|
4
|
-
"commit": "
|
|
5
|
-
"committedAt": "2026-11-
|
|
4
|
+
"commit": "c55f578089bc8e167e65812f87b578c526ee9236",
|
|
5
|
+
"committedAt": "2026-11-19T18:39:43+07:00",
|
|
6
6
|
"dirty": false
|
|
7
7
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
export const TRANSLATION_SOURCE = {
|
|
4
4
|
"elements": 68,
|
|
5
5
|
"pairs": 190,
|
|
6
|
-
"neverKeys":
|
|
6
|
+
"neverKeys": 191,
|
|
7
7
|
"entityTypes": 12
|
|
8
8
|
};
|
|
9
9
|
/** Every entity type a translation record can name, including "node". */
|
|
@@ -388,6 +388,7 @@ export const NEVER_TRANSLATED = [
|
|
|
388
388
|
"boundMoneyOverride",
|
|
389
389
|
"boundPriceCents",
|
|
390
390
|
"boundProductURL",
|
|
391
|
+
"boundTags",
|
|
391
392
|
"boundValue",
|
|
392
393
|
"breakEnd",
|
|
393
394
|
"breakStart",
|
|
@@ -446,6 +447,7 @@ export const NEVER_TRANSLATED = [
|
|
|
446
447
|
"hrefParams",
|
|
447
448
|
"html",
|
|
448
449
|
"htmlTag",
|
|
450
|
+
"hydrateProps",
|
|
449
451
|
"icon",
|
|
450
452
|
"iconEnabled",
|
|
451
453
|
"iconName",
|
|
@@ -544,6 +546,7 @@ export const NEVER_TRANSLATED = [
|
|
|
544
546
|
"stepMode",
|
|
545
547
|
"stylePreset",
|
|
546
548
|
"symbolChar",
|
|
549
|
+
"tag",
|
|
547
550
|
"target",
|
|
548
551
|
"thresholdCents",
|
|
549
552
|
"trackUrl",
|
package/dist/core/tree.js
CHANGED
|
@@ -186,3 +186,31 @@ export function appBlockRoot(doc, id) {
|
|
|
186
186
|
return a;
|
|
187
187
|
return null;
|
|
188
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Every row of a menu snapshot, depth first — the editor's `findRow`
|
|
191
|
+
* (features/menus/megaPanel.ts) and `findRowByPanelId` both walk this way.
|
|
192
|
+
*/
|
|
193
|
+
export function menuRows(raw, out = []) {
|
|
194
|
+
if (!Array.isArray(raw))
|
|
195
|
+
return out;
|
|
196
|
+
for (const r of raw) {
|
|
197
|
+
if (!r || typeof r !== 'object')
|
|
198
|
+
continue;
|
|
199
|
+
out.push(r);
|
|
200
|
+
menuRows(r.items, out);
|
|
201
|
+
}
|
|
202
|
+
return out;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* A row's mega panel, resolved the way the renderers do (menu/html.go
|
|
206
|
+
* panelChild, the store's menuRowPanel): the id must name a `menu-panel` that
|
|
207
|
+
* really is a CHILD of this menu. A dangling id reads as no panel.
|
|
208
|
+
*/
|
|
209
|
+
export function rowPanel(doc, menuId, row) {
|
|
210
|
+
const pid = row.panelId;
|
|
211
|
+
if (typeof pid !== 'string' || pid === '')
|
|
212
|
+
return null;
|
|
213
|
+
if (!doc.nodes[menuId]?.data.nodes.includes(pid))
|
|
214
|
+
return null;
|
|
215
|
+
return doc.nodes[pid]?.data.type === 'menu-panel' ? pid : null;
|
|
216
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isOverlay, subtreeIds, ancestors, appBlockRoot, SPEC_GLOBAL_ID, SPEC_GLOBAL_KIND, SPEC_GLOBAL_REF, } from '../../core/tree.js';
|
|
1
|
+
import { isOverlay, subtreeIds, ancestors, appBlockRoot, menuRows, rowPanel, SPEC_GLOBAL_ID, SPEC_GLOBAL_KIND, SPEC_GLOBAL_REF, } from '../../core/tree.js';
|
|
2
2
|
import { ELEMENTS, ELEMENT_SEEDS, SATELLITE_RULES } from '../../catalog/elements.generated.js';
|
|
3
3
|
import { bindingsForConfig, createNode, mintSatellites, seedFor } from './node.js';
|
|
4
4
|
import { refuseSecondTemplate } from './traps.js';
|
|
@@ -44,9 +44,40 @@ function isPriceLeaf(parentType, parentKind, child) {
|
|
|
44
44
|
}
|
|
45
45
|
function requireContainer(parentType, parentId, parentKind, child) {
|
|
46
46
|
if (!ELEMENTS[parentType]?.isContainer && !isPriceLeaf(parentType, parentKind, child)) {
|
|
47
|
-
|
|
47
|
+
// The one child a menu holds is a MEGA PANEL, and it is only ever born
|
|
48
|
+
// bound to a row — so the refusal names the call that makes one.
|
|
49
|
+
const mega = parentType === 'menu' && child?.type === 'menu-panel'
|
|
50
|
+
? ` A mega panel is added on its own: sb_add parent_id ${parentId} with menu_item_id ` +
|
|
51
|
+
'(the row id from its specials.menuItems) and spec {type:"menu-panel"}.'
|
|
52
|
+
: '';
|
|
53
|
+
throw new Error(`sbuilder: ${parentId} is a ${parentType}, which is not a container — it cannot hold children.${mega}`);
|
|
48
54
|
}
|
|
49
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* A MEGA PANEL for one menu row — the editor's convertMenuRowToPanel
|
|
58
|
+
* (stores/node.ts): the panel is appended to the MENU's `data.nodes`, and the
|
|
59
|
+
* row (matched by id at any depth) gets `panelId` in the same save. Returns the
|
|
60
|
+
* cloned snapshot whose matching row the caller points at the minted panel.
|
|
61
|
+
*/
|
|
62
|
+
function megaPanelRows(doc, menuId, menuItemId) {
|
|
63
|
+
const menu = doc.node(menuId);
|
|
64
|
+
const rows = structuredClone(menu.specials?.menuItems ?? []);
|
|
65
|
+
const all = menuRows(rows);
|
|
66
|
+
const row = all.find((r) => r.id === menuItemId);
|
|
67
|
+
if (!row) {
|
|
68
|
+
const known = all.map((r) => r.id).filter((x) => typeof x === 'string' && x !== '');
|
|
69
|
+
throw new Error(`sbuilder: the menu ${menuId} has no row "${menuItemId}". Its rows: ` +
|
|
70
|
+
(known.length ? known.join(', ') : 'none (bind it first with sb_store action:"menu")') +
|
|
71
|
+
'.');
|
|
72
|
+
}
|
|
73
|
+
const existing = rowPanel(doc.doc, menuId, row);
|
|
74
|
+
if (existing) {
|
|
75
|
+
throw new Error(`sbuilder: row "${menuItemId}" of ${menuId} already has a mega panel (${existing}). Add ` +
|
|
76
|
+
`content into it with sb_add parent_id ${existing}, restyle it with sb_set, or sb_remove ` +
|
|
77
|
+
`${existing} to put the row back on its link list.`);
|
|
78
|
+
}
|
|
79
|
+
return { rows, row };
|
|
80
|
+
}
|
|
50
81
|
function requireAllowed(parentType, childType, g) {
|
|
51
82
|
const child = ELEMENTS[childType];
|
|
52
83
|
if (!child) {
|
|
@@ -130,9 +161,14 @@ function seeded(spec, rule, owner) {
|
|
|
130
161
|
* patches come out flat in CREATION ORDER, so a peer applying them left to right
|
|
131
162
|
* never sees a child referenced before the node exists.
|
|
132
163
|
*/
|
|
133
|
-
export function addSubtree(doc, parentId, spec, index, guard) {
|
|
164
|
+
export function addSubtree(doc, parentId, spec, index, guard, menuItemId) {
|
|
134
165
|
const parent = doc.node(parentId);
|
|
135
166
|
soft(guard, () => refuseAppBlockParent(doc, parentId, 'adding'));
|
|
167
|
+
if (menuItemId !== undefined && !(parent.data.type === 'menu' && spec.type === 'menu-panel')) {
|
|
168
|
+
throw new Error(`sbuilder: menu_item_id names the menu row a mega panel serves, so it applies only to a ` +
|
|
169
|
+
`menu-panel added directly under a menu — not to a ${spec.type} under a ${parent.data.type}.`);
|
|
170
|
+
}
|
|
171
|
+
const mega = menuItemId !== undefined ? megaPanelRows(doc, parentId, menuItemId) : undefined;
|
|
136
172
|
// A SATELLITE the parent declares (`icon` → `cart-count` as `cartCountId`) is
|
|
137
173
|
// attached the way the editor's `addDetachedNode` does: `data.parent` = the
|
|
138
174
|
// host, NOT in its `data.nodes`, and the host points at it from base config.
|
|
@@ -149,7 +185,7 @@ export function addSubtree(doc, parentId, spec, index, guard) {
|
|
|
149
185
|
// A DOCUMENT'S OWN ROOT always holds children — including a FORM document's,
|
|
150
186
|
// whose root is a `form`: a leaf on a page (its meta says isContainer:false,
|
|
151
187
|
// because the fields live elsewhere) and the field list in its own document.
|
|
152
|
-
if (parentId !== doc.doc.root_node_id)
|
|
188
|
+
if (parentId !== doc.doc.root_node_id && !mega)
|
|
153
189
|
requireContainer(parent.data.type, parentId, parent.config?.kind, spec);
|
|
154
190
|
requireAllowed(parent.data.type, spec.type, guard);
|
|
155
191
|
soft(guard, () => refuseBesideSegments(doc, parentId, spec.type));
|
|
@@ -269,6 +305,10 @@ export function addSubtree(doc, parentId, spec, index, guard) {
|
|
|
269
305
|
}
|
|
270
306
|
const at = index ?? indexBeforeFormBar(doc, parentId, spec.type);
|
|
271
307
|
patches.push({ op: 'insert', path: ['nodes', parentId, 'data', 'nodes'], index: at, value: rootId });
|
|
308
|
+
if (mega) {
|
|
309
|
+
mega.row.panelId = rootId;
|
|
310
|
+
patches.push({ op: 'set', path: ['nodes', parentId, 'specials', 'menuItems'], value: mega.rows });
|
|
311
|
+
}
|
|
272
312
|
return { patches, ids, idOf };
|
|
273
313
|
}
|
|
274
314
|
/**
|
|
@@ -616,6 +656,7 @@ function rebindPatch(doc, id, keys) {
|
|
|
616
656
|
* (not part of this document at all).
|
|
617
657
|
*/
|
|
618
658
|
export function duplicateNode(doc, id, guard) {
|
|
659
|
+
refuseMenuPanel(doc, id, 'Duplicating', 'a copy would be named by no row and render nowhere. Give another row its own panel with sb_add parent_id <menu> menu_item_id <row id>');
|
|
619
660
|
const parentId = doc.has(id) ? doc.node(id).data.parent : null;
|
|
620
661
|
const at = parentId && doc.has(parentId) ? doc.node(parentId).data.nodes.indexOf(id) : -1;
|
|
621
662
|
return copyNodeInto(doc, id, doc, parentId ?? '', at < 0 ? APPEND : at + 1, guard);
|
|
@@ -718,8 +759,21 @@ export function copyNodeInto(src, id, target, parentId, index, guard) {
|
|
|
718
759
|
patches.push({ op: 'insert', path: ['nodes', parentId, 'data', 'nodes'], index, value: rootId });
|
|
719
760
|
return { patches, ids, map };
|
|
720
761
|
}
|
|
762
|
+
/**
|
|
763
|
+
* A MENU'S MEGA PANEL lives only where its row points: moved out, the row names
|
|
764
|
+
* a node the menu no longer holds (the dropdown silently falls back to links);
|
|
765
|
+
* duplicated, the copy is named by no row. Both are refused.
|
|
766
|
+
*/
|
|
767
|
+
function refuseMenuPanel(doc, id, verb, why) {
|
|
768
|
+
const n = doc.doc.nodes[id];
|
|
769
|
+
const parent = n?.data.parent ? doc.doc.nodes[n.data.parent] : undefined;
|
|
770
|
+
if (n?.data.type !== 'menu-panel' || parent?.data.type !== 'menu')
|
|
771
|
+
return;
|
|
772
|
+
throw new Error(`sbuilder: ${id} is the mega panel of a row of the menu ${n.data.parent}. ${verb} it is refused: ${why}.`);
|
|
773
|
+
}
|
|
721
774
|
export function moveNode(doc, id, newParentId, index, guard) {
|
|
722
775
|
const n = doc.node(id);
|
|
776
|
+
refuseMenuPanel(doc, id, 'Moving', `its row would still point at it while the menu no longer holds it. To take the panel away, sb_remove ${id} (the row goes back to its link list in the same save)`);
|
|
723
777
|
refuseOverlay(doc, id, 'moving');
|
|
724
778
|
soft(guard, () => refuseAppBlockInterior(doc, id, 'moving'));
|
|
725
779
|
const newParent = doc.node(newParentId);
|
|
@@ -775,6 +829,16 @@ export function removeNode(doc, id, guard) {
|
|
|
775
829
|
patches.push({ op: 'set', path: ['nodes', parentId, 'config', rule.configKey], value: '' });
|
|
776
830
|
}
|
|
777
831
|
}
|
|
832
|
+
// A MEGA PANEL: its row goes back on the plain link list in the same save,
|
|
833
|
+
// as the editor's removeMenuRowPanel does — never a row naming a gone node.
|
|
834
|
+
if (parent.data.type === 'menu' && n.data.type === 'menu-panel') {
|
|
835
|
+
const rows = structuredClone(parent.specials?.menuItems ?? []);
|
|
836
|
+
const hits = menuRows(rows).filter((r) => r.panelId === id);
|
|
837
|
+
for (const r of hits)
|
|
838
|
+
delete r.panelId;
|
|
839
|
+
if (hits.length)
|
|
840
|
+
patches.push({ op: 'set', path: ['nodes', parentId, 'specials', 'menuItems'], value: rows });
|
|
841
|
+
}
|
|
778
842
|
}
|
|
779
843
|
// Unset the whole subtree AND everything hanging off it — a node left behind
|
|
780
844
|
// is an orphan the save check rejects, and the agent would never guess why.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { applyPatches } from '../../core/patch.js';
|
|
2
|
-
import { childrenOf, isOverlay, appBlockRoot } from '../../core/tree.js';
|
|
2
|
+
import { childrenOf, isOverlay, appBlockRoot, menuRows, rowPanel } from '../../core/tree.js';
|
|
3
3
|
import { bandOf, isGlobal } from './traps.js';
|
|
4
4
|
import { SATELLITE_RULES } from '../../catalog/elements.generated.js';
|
|
5
5
|
/**
|
|
@@ -204,6 +204,14 @@ export class PageDoc {
|
|
|
204
204
|
const label = n.specials?.label;
|
|
205
205
|
if ((n.data.type === 'accordion-content' || n.data.type === 'tab-content') && typeof label === 'string' && label)
|
|
206
206
|
out.label = label;
|
|
207
|
+
const menuId = n.data.parent;
|
|
208
|
+
if (n.data.type === 'menu-panel' && menuId && this.doc.nodes[menuId]?.data.type === 'menu') {
|
|
209
|
+
const row = menuRows(this.doc.nodes[menuId].specials?.menuItems).find((r) => rowPanel(this.doc, menuId, r) === id);
|
|
210
|
+
if (typeof row?.id === 'string')
|
|
211
|
+
out.menu_item = row.id;
|
|
212
|
+
if (typeof row?.label === 'string' && row.label)
|
|
213
|
+
out.label = row.label;
|
|
214
|
+
}
|
|
207
215
|
if (level === 0) {
|
|
208
216
|
if (isOverlay(this.doc, id))
|
|
209
217
|
out.overlay = true;
|
|
@@ -244,15 +244,17 @@ export const INERT_ON_ADD = {
|
|
|
244
244
|
'beside it.',
|
|
245
245
|
host: 'hamburger-menu',
|
|
246
246
|
},
|
|
247
|
-
//
|
|
248
|
-
//
|
|
249
|
-
//
|
|
247
|
+
// A menu-panel renders only as a MENU's child that one row of the menu's
|
|
248
|
+
// specials.menuItems names through `panelId` — the one way to place it is
|
|
249
|
+
// sb_add with menu_item_id (which writes both halves), so under a menu it is
|
|
250
|
+
// hosted and silent. Any ordinary container on a page also accepts one.
|
|
250
251
|
'menu-panel': {
|
|
251
|
-
note: 'A menu-panel is a mega-menu surface behind ONE entry of a site menu
|
|
252
|
-
"
|
|
253
|
-
'
|
|
254
|
-
'
|
|
255
|
-
'
|
|
252
|
+
note: 'A menu-panel is a mega-menu surface behind ONE entry of a site menu: it renders only as ' +
|
|
253
|
+
"the menu's own child that the entry's row names (specials.menuItems[].panelId). Placed " +
|
|
254
|
+
'loose on a page it is accepted by any ordinary container and, per its own AVOID, "only ' +
|
|
255
|
+
'renders inside its owning menu entry" — never on its own. Add it with sb_add parent_id ' +
|
|
256
|
+
'<menu> menu_item_id <row id>, which appends it and points the row at it in one save.',
|
|
257
|
+
host: 'menu',
|
|
256
258
|
},
|
|
257
259
|
};
|
|
258
260
|
/** The hint for a type, or null. */
|
package/dist/tools/page.js
CHANGED
|
@@ -116,10 +116,10 @@ export function saveRefusal(d, patches) {
|
|
|
116
116
|
* button) is right. Shared with sb_store action:"form" + node_id, which
|
|
117
117
|
* appended after the footer and stored a stray form.
|
|
118
118
|
*/
|
|
119
|
-
export function addPlaced(d, parentId, spec, index, guard) {
|
|
119
|
+
export function addPlaced(d, parentId, spec, index, guard, menuItemId) {
|
|
120
120
|
const rootKids = d.doc.nodes[d.doc.root_node_id]?.data.nodes.length ?? 0;
|
|
121
121
|
const mid = parentId === d.doc.root_node_id ? middleEnd(d.doc) : rootKids;
|
|
122
|
-
return addSubtree(d, parentId, spec, index ?? (mid < rootKids ? mid : undefined), guard);
|
|
122
|
+
return addSubtree(d, parentId, spec, index ?? (mid < rootKids ? mid : undefined), guard, menuItemId);
|
|
123
123
|
}
|
|
124
124
|
/** `once` for a real write, `peek` for a dry run — the same notes, spent once. */
|
|
125
125
|
function noticeFor(ctx, dryRun) {
|
|
@@ -1587,11 +1587,16 @@ export function registerPageTools(server, ctx) {
|
|
|
1587
1587
|
parent_id: z.string(),
|
|
1588
1588
|
spec: specSchema,
|
|
1589
1589
|
index: z.number().int().min(0).optional(),
|
|
1590
|
+
menu_item_id: z
|
|
1591
|
+
.string()
|
|
1592
|
+
.min(1)
|
|
1593
|
+
.optional()
|
|
1594
|
+
.describe('Mega panel: the menuItems row id whose dropdown it becomes (menu parent, menu-panel spec)'),
|
|
1590
1595
|
dry_run: z.boolean().optional(),
|
|
1591
1596
|
force: z.boolean().optional().describe('Override a render-inference guard; reported as forced'),
|
|
1592
1597
|
},
|
|
1593
1598
|
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
1594
|
-
}, async ({ parent_id, spec, index, dry_run, force }) => {
|
|
1599
|
+
}, async ({ parent_id, spec, index, menu_item_id, dry_run, force }) => {
|
|
1595
1600
|
const d = session.current();
|
|
1596
1601
|
// A CODE COMPONENT IS CHECKED AGAINST WHAT THE SITE PUSHED before anything
|
|
1597
1602
|
// is placed: an unknown name, version or prop stores a blank box, and only
|
|
@@ -1616,7 +1621,7 @@ export function registerPageTools(server, ctx) {
|
|
|
1616
1621
|
}
|
|
1617
1622
|
const derived = ccDropped.size ? { derived: derivedNote([...ccDropped]) } : {};
|
|
1618
1623
|
const guard = { force, forced: [] };
|
|
1619
|
-
const { patches, ids, idOf } = addPlaced(d, parent_id, spec, index, guard);
|
|
1624
|
+
const { patches, ids, idOf } = addPlaced(d, parent_id, spec, index, guard, menu_item_id);
|
|
1620
1625
|
const forced = guard.forced.length ? { forced: guard.forced } : {};
|
|
1621
1626
|
// THE SEED COPY IN THE SITE'S LANGUAGE (TTG gap #46): an empty state minted
|
|
1622
1627
|
// here said "No products yet" on a Vietnamese store, while sb_page_create
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sbuilder-mcp",
|
|
3
|
-
"version": "0.110.
|
|
3
|
+
"version": "0.110.1",
|
|
4
4
|
"description": "MCP server that designs and operates a Store Builder site — pages, data, theme and publish — through the platform's own API and live-edit protocol.",
|
|
5
5
|
"mcpName": "io.github.vuluu2k/sbuilder-mcp",
|
|
6
6
|
"type": "module",
|