sbuilder-mcp 0.99.0 → 0.100.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 +23 -0
- package/CHANGELOG.vi.md +23 -0
- package/README.md +1 -1
- package/README.vi.md +1 -1
- package/dist/catalog/deadkeys.generated.js +2 -2
- package/dist/catalog/elements.generated.js +7 -4
- package/dist/catalog/source.generated.js +2 -2
- package/dist/catalog/translations.generated.js +3 -0
- package/dist/domains/site/document.js +7 -3
- package/dist/domains/site/review.js +3 -1
- package/dist/domains/site/writecheck.js +1 -1
- package/dist/tools/page.js +41 -15
- package/dist/tools/store.js +7 -3
- package/dist/transport/pages.js +6 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,29 @@ 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.100.1] - 2026-10-29
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- `sb_outline` collapses only shared headers, footers and overlays, not global custom sections, and a collapsed line carries `collapsed: true`.
|
|
13
|
+
- `sb_duplicate` lists at most 40 nodes in `copies`, and past that it returns the top-level copy plus `copied` and `copies_truncated`.
|
|
14
|
+
- `sb_publish` shows `cascade_note` once per process, on its first appearance in a dry run or a real publish.
|
|
15
|
+
- The error for a missing page source now reads "page <id> not found on site <site> (deleted, or not this site/key)".
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
- `sb_store` with `action: "form"` and `node_id` places the form the same way as `sb_add` and checks that the position can be saved first, so a refused position no longer leaves a stray form behind.
|
|
19
|
+
- `sb_review` no longer reports `default_font` when `responsive[bp].style.fontFamily` is already set.
|
|
20
|
+
- `sb_review` no longer counts `background-color` or `border-color` as `color` for `link_colour`.
|
|
21
|
+
|
|
22
|
+
## [0.100.0] - 2026-10-29
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
- Buttons and icons accept the `clear_cart` click action, which empties the whole cart, and `sb_event` offers it on buttons.
|
|
26
|
+
- `product` gains a translatable `summary` field.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
- `sb_add` and `sb_set` seed a text dataset with `kind: "summary"` bound to `product.summary` instead of `product.title`.
|
|
30
|
+
- The catalog now lists `product.summary` among the binding sources.
|
|
31
|
+
|
|
9
32
|
## [0.99.0] - 2026-10-29
|
|
10
33
|
|
|
11
34
|
### Added
|
package/CHANGELOG.vi.md
CHANGED
|
@@ -6,6 +6,29 @@ 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.100.1] - 2026-10-29
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- `sb_outline` chỉ thu gọn header, footer dùng chung và overlay, không thu gọn global custom section, và dòng thu gọn mang `collapsed: true`.
|
|
13
|
+
- `sb_duplicate` liệt kê tối đa 40 node trong `copies`, quá giới hạn thì trả bản sao cấp trên cùng với `copied` và `copies_truncated`.
|
|
14
|
+
- `sb_publish` chỉ hiện `cascade_note` một lần mỗi process, ở lần xuất hiện đầu tiên khi chạy thử hoặc publish thật.
|
|
15
|
+
- Lỗi khi không tìm thấy nguồn trang nay ghi "page <id> not found on site <site> (deleted, or not this site/key)".
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
- `sb_store` với `action: "form"` và `node_id` đặt form giống `sb_add` và kiểm tra vị trí có lưu được trước, nên vị trí bị từ chối không còn để lại form thừa.
|
|
19
|
+
- `sb_review` không còn báo `default_font` khi `responsive[bp].style.fontFamily` đã được đặt.
|
|
20
|
+
- `sb_review` không còn tính `background-color` hay `border-color` là `color` khi xét `link_colour`.
|
|
21
|
+
|
|
22
|
+
## [0.100.0] - 2026-10-29
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
- Button và icon nhận click action `clear_cart` để xoá toàn bộ giỏ hàng, và `sb_event` đưa action này cho button.
|
|
26
|
+
- `product` có thêm trường dịch `summary`.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
- `sb_add` và `sb_set` seed text dataset có `kind: "summary"` bind vào `product.summary` thay vì `product.title`.
|
|
30
|
+
- Catalog liệt kê thêm `product.summary` trong các nguồn binding.
|
|
31
|
+
|
|
9
32
|
## [0.99.0] - 2026-10-29
|
|
10
33
|
|
|
11
34
|
### Added
|
package/README.md
CHANGED
|
@@ -119,7 +119,7 @@ in this client: one would put the very key the platform exists to hold back into
|
|
|
119
119
|
| `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 |
|
|
120
120
|
|
|
121
121
|
Twenty-eight tools, **919 API operations** (344 of the 429 writes carrying a body shape read
|
|
122
|
-
off the handler), 124 elements,
|
|
122
|
+
off the handler), 124 elements, 96 binding sources. `sb_api_find`
|
|
123
123
|
is an index rather than a tool per endpoint, so the tool list stays short while everything
|
|
124
124
|
the platform can do stays reachable — and operations added to the platform arrive with the
|
|
125
125
|
next `npm run codegen`.
|
package/README.vi.md
CHANGED
|
@@ -116,7 +116,7 @@ nhét ngược lại vào mọi bản cài.
|
|
|
116
116
|
| `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 |
|
|
117
117
|
|
|
118
118
|
Hai mươi tám tool, **919 operation API** (344 trong 429 lệnh ghi có hình dạng body đọc thẳng
|
|
119
|
-
từ handler), 124 element,
|
|
119
|
+
từ handler), 124 element, 96 nguồn binding. `sb_api_find` là
|
|
120
120
|
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
|
|
121
121
|
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
|
|
122
122
|
`npm run codegen` kế tiếp.
|
|
@@ -826,6 +826,7 @@ export const ELEMENTS = {
|
|
|
826
826
|
"cart_remove",
|
|
827
827
|
"cart_increment",
|
|
828
828
|
"cart_decrement",
|
|
829
|
+
"clear_cart",
|
|
829
830
|
"change_tab",
|
|
830
831
|
"open_dropdown",
|
|
831
832
|
"close_dropdown",
|
|
@@ -1461,6 +1462,7 @@ export const ELEMENTS = {
|
|
|
1461
1462
|
"cart_remove",
|
|
1462
1463
|
"cart_increment",
|
|
1463
1464
|
"cart_decrement",
|
|
1465
|
+
"clear_cart",
|
|
1464
1466
|
"change_tab",
|
|
1465
1467
|
"open_dropdown",
|
|
1466
1468
|
"close_dropdown",
|
|
@@ -29199,7 +29201,7 @@ export const ELEMENTS = {
|
|
|
29199
29201
|
"product|summary": [
|
|
29200
29202
|
{
|
|
29201
29203
|
"id": "bind-text",
|
|
29202
|
-
"source": "product.
|
|
29204
|
+
"source": "product.summary",
|
|
29203
29205
|
"field": "specials.boundText",
|
|
29204
29206
|
"target": {
|
|
29205
29207
|
"type": "product",
|
|
@@ -32597,9 +32599,9 @@ export const ELEMENTS = {
|
|
|
32597
32599
|
"animation",
|
|
32598
32600
|
"class_css"
|
|
32599
32601
|
],
|
|
32600
|
-
"description": "A store-bound text display for a product title, vendor, or description (config.kind). Renders escaped plain text for title/vendor, or the product's sanitized rich-text HTML for the description kind. For the description kind, a Compact display type clamps the text to config.descriptionLines with an optional \"show more / show less\" toggle. Owns no children; when placed under a product it binds to that product's live field, falling back to the seeded config text when unbound. Supports default / hover / active interaction states.",
|
|
32602
|
+
"description": "A store-bound text display for a product title, vendor, summary (the short description), or description (config.kind). Renders escaped plain text for title/vendor/summary, or the product's sanitized rich-text HTML for the description kind. For the description kind, a Compact display type clamps the text to config.descriptionLines with an optional \"show more / show less\" toggle. Owns no children; when placed under a product it binds to that product's live field, falling back to the seeded config text when unbound. Supports default / hover / active interaction states.",
|
|
32601
32603
|
"useWhen": [
|
|
32602
|
-
"Product title, vendor, or description text in a product layout",
|
|
32604
|
+
"Product title, vendor, short summary, or description text in a product layout",
|
|
32603
32605
|
"A long product description that should collapse to a few lines with a \"show more\" toggle",
|
|
32604
32606
|
"Product text that needs hover/active styling"
|
|
32605
32607
|
],
|
|
@@ -32609,7 +32611,7 @@ export const ELEMENTS = {
|
|
|
32609
32611
|
"Free-form author HTML/markup — the description kind renders only the product's own sanitized rich text, not arbitrary content"
|
|
32610
32612
|
],
|
|
32611
32613
|
"contentTips": [
|
|
32612
|
-
"Set config.kind to \"title\", \"vendor\", or \"description\"",
|
|
32614
|
+
"Set config.kind to \"title\", \"vendor\", \"summary\" (the product's one-line short description, plain text — the card line), or \"description\"",
|
|
32613
32615
|
"For a description, set config.descriptionDisplayType to \"Compact\" and config.descriptionLines to clamp it; enable specials.moreButtonEnabled for the toggle",
|
|
32614
32616
|
"Customise config.moreText / config.lessText and config.icon (the chevron) for the toggle",
|
|
32615
32617
|
"Style per state (default / hover / active) via the state switcher",
|
|
@@ -36363,6 +36365,7 @@ export const BINDING_SOURCES = [
|
|
|
36363
36365
|
"product.priceCents",
|
|
36364
36366
|
"product.ratingAverage",
|
|
36365
36367
|
"product.ratingCount",
|
|
36368
|
+
"product.summary",
|
|
36366
36369
|
"product.tags",
|
|
36367
36370
|
"product.title",
|
|
36368
36371
|
"product.url",
|
|
@@ -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-10-
|
|
4
|
+
"commit": "69a6becbb8e36b80028b3b8c4ca1f92a4cc6d5bc",
|
|
5
|
+
"committedAt": "2026-10-29T15:59:30+07:00",
|
|
6
6
|
"dirty": false
|
|
7
7
|
};
|
|
@@ -189,8 +189,9 @@ export class PageDoc {
|
|
|
189
189
|
*/
|
|
190
190
|
/**
|
|
191
191
|
* `chrome: false` (the tool's default) stops at a shared header/footer or an
|
|
192
|
-
* overlay: one line each, no kids
|
|
193
|
-
* ~70% of a routine outline (TTG gap #52).
|
|
192
|
+
* overlay: one line each, no kids, marked `collapsed`. They are the same on
|
|
193
|
+
* every page and were ~70% of a routine outline (TTG gap #52). A CUSTOM global
|
|
194
|
+
* is middle-band content the agent designs in, so it stays expanded.
|
|
194
195
|
*/
|
|
195
196
|
outline(opts = {}) {
|
|
196
197
|
const depth = opts.depth ?? 1;
|
|
@@ -213,7 +214,10 @@ export class PageDoc {
|
|
|
213
214
|
out.global = true;
|
|
214
215
|
if (appBlockRoot(this.doc, id) === id)
|
|
215
216
|
out.app = true;
|
|
216
|
-
const
|
|
217
|
+
const kind = n.specials?.globalKind;
|
|
218
|
+
const collapsed = opts.chrome === false && level === 0 && (out.overlay || (out.global && (kind === 'header' || kind === 'footer')));
|
|
219
|
+
if (collapsed && level + 1 < depth && (kidIds.length || satellitesOf(this.doc, id).length))
|
|
220
|
+
out.collapsed = true;
|
|
217
221
|
if (level + 1 < depth && !collapsed) {
|
|
218
222
|
// Satellites come FIRST, and are counted apart from `children`: they are
|
|
219
223
|
// this node's own chrome, not content in it, and mixing the two would
|
|
@@ -542,7 +542,9 @@ opts = {}) {
|
|
|
542
542
|
// is another family: a deliberate literal is the author's.
|
|
543
543
|
const ff = n.style?.fontFamily;
|
|
544
544
|
const seedFont = meta.defaults.style?.fontFamily;
|
|
545
|
-
|
|
545
|
+
// A family set at any breakpoint is the author's answer too.
|
|
546
|
+
const perBp = Object.values(n.responsive ?? {}).some((r) => r?.style?.fontFamily !== undefined);
|
|
547
|
+
if (opts.bodyFont && !perBp && typeof ff === 'string' && ff === seedFont && !ff.includes('var(') && family(ff) !== family(opts.bodyFont)) {
|
|
546
548
|
out.push({
|
|
547
549
|
code: 'default_font',
|
|
548
550
|
nodeId: id,
|
|
@@ -301,7 +301,7 @@ export function writeCheck(type, namespace, keys, opts = {}) {
|
|
|
301
301
|
}
|
|
302
302
|
/** `<a …>` tags in rich text that set no colour of their own. */
|
|
303
303
|
export function unstyledLinks(html) {
|
|
304
|
-
return (html.match(/<a\b[^>]*>/gi) ?? []).filter((tag) => !/style\s*=\s*["'][^"']
|
|
304
|
+
return (html.match(/<a\b[^>]*>/gi) ?? []).filter((tag) => !/style\s*=\s*["'](?:[^"']*[;\s])?color\s*:/i.test(tag)).length;
|
|
305
305
|
}
|
|
306
306
|
export const LINK_COLOUR = {
|
|
307
307
|
problem: "A link in this rich text has no colour of its own, so it renders in the browser's default link blue " +
|
package/dist/tools/page.js
CHANGED
|
@@ -20,7 +20,7 @@ import { skinLevelNote } from '../domains/site/fieldskin.js';
|
|
|
20
20
|
import { siteTheme } from '../domains/site/theme-fetch.js';
|
|
21
21
|
import { ensureSiteTheme } from './theme.js';
|
|
22
22
|
import { request, redact, watchPageWrites, onPageSourceWrite, onGlobalWrite, onFormDocumentWrite } from '../transport/http.js';
|
|
23
|
-
import { SPEC_GLOBAL_ID, SPEC_GLOBAL_REV, SPEC_OVERLAY_ID, SPEC_OVERLAY_REV, subtreeIds, ancestors } from '../core/tree.js';
|
|
23
|
+
import { SPEC_GLOBAL_ID, SPEC_GLOBAL_REV, SPEC_OVERLAY_ID, SPEC_OVERLAY_REV, subtreeIds, ancestors, childrenOf } from '../core/tree.js';
|
|
24
24
|
import { siteToken } from './credentialpick.js';
|
|
25
25
|
import { validateForSave } from '../domains/site/validate.js';
|
|
26
26
|
import { cascadeTail, formDocChecks, hiddenBand, sayChecks, specCheck, writeCheck } from '../domains/site/writecheck.js';
|
|
@@ -75,6 +75,8 @@ export function reviewField(ctx, doc, formTypes, pageType, formDocType, formRedi
|
|
|
75
75
|
*/
|
|
76
76
|
/** How long a save in the live room waits for its ops' acks before leaving `X-WB-Live-Peer` off. */
|
|
77
77
|
const LIVE_ACK_CAP_MS = 2_000;
|
|
78
|
+
/** sb_duplicate's full old → [new, type] map stops here; past it, the top level and a count. */
|
|
79
|
+
const DUPLICATE_COPIES_CAP = 40;
|
|
78
80
|
/**
|
|
79
81
|
* Why `applyAndSave` would refuse this batch on this document, or null — the
|
|
80
82
|
* ONE place that question is answered, so a dry run and the real write cannot
|
|
@@ -99,6 +101,21 @@ export function saveRefusal(d, patches) {
|
|
|
99
101
|
}
|
|
100
102
|
return { before, refusal: null };
|
|
101
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* `addSubtree` with sb_add's placement: ROOT WITH NO INDEX MEANS "ANOTHER
|
|
106
|
+
* SECTION OF THE PAGE" — the end of the middle band, as sb_template_use and
|
|
107
|
+
* sb_duplicate already place one. Appended last it landed after a shared
|
|
108
|
+
* footer, and the band-order check refused the save — on exactly the call
|
|
109
|
+
* empty_page's fix names. Only when a footer is there to land behind: a FORM
|
|
110
|
+
* document's root has none, and addSubtree's own default (above the submit
|
|
111
|
+
* button) is right. Shared with sb_store action:"form" + node_id, which
|
|
112
|
+
* appended after the footer and stored a stray form.
|
|
113
|
+
*/
|
|
114
|
+
export function addPlaced(d, parentId, spec, index, guard) {
|
|
115
|
+
const rootKids = d.doc.nodes[d.doc.root_node_id]?.data.nodes.length ?? 0;
|
|
116
|
+
const mid = parentId === d.doc.root_node_id ? middleEnd(d.doc) : rootKids;
|
|
117
|
+
return addSubtree(d, parentId, spec, index ?? (mid < rootKids ? mid : undefined), guard);
|
|
118
|
+
}
|
|
102
119
|
/** `once` for a real write, `peek` for a dry run — the same notes, spent once. */
|
|
103
120
|
function noticeFor(ctx, dryRun) {
|
|
104
121
|
return dryRun !== false ? (k, b) => ctx.notices.peek(k, b) : (k, b) => ctx.notices.once(k, b);
|
|
@@ -1520,16 +1537,7 @@ export function registerPageTools(server, ctx) {
|
|
|
1520
1537
|
}, async ({ parent_id, spec, index, dry_run, force }) => {
|
|
1521
1538
|
const d = session.current();
|
|
1522
1539
|
const guard = { force, forced: [] };
|
|
1523
|
-
|
|
1524
|
-
// middle band, as sb_template_use and sb_duplicate already place one.
|
|
1525
|
-
// Appended last it landed after a shared footer, and the band-order check
|
|
1526
|
-
// refused the save — on exactly the call empty_page's fix names.
|
|
1527
|
-
// Only when a footer is there to land behind: a FORM document's root has
|
|
1528
|
-
// none, and addSubtree's own default (above the submit button) is right.
|
|
1529
|
-
const rootKids = d.doc.nodes[d.doc.root_node_id]?.data.nodes.length ?? 0;
|
|
1530
|
-
const mid = parent_id === d.doc.root_node_id ? middleEnd(d.doc) : rootKids;
|
|
1531
|
-
const at = index ?? (mid < rootKids ? mid : undefined);
|
|
1532
|
-
const { patches, ids, idOf } = addSubtree(d, parent_id, spec, at, guard);
|
|
1540
|
+
const { patches, ids, idOf } = addPlaced(d, parent_id, spec, index, guard);
|
|
1533
1541
|
const forced = guard.forced.length ? { forced: guard.forced } : {};
|
|
1534
1542
|
// THE SEED COPY IN THE SITE'S LANGUAGE (TTG gap #46): an empty state minted
|
|
1535
1543
|
// here said "No products yet" on a Vietnamese store, while sb_page_create
|
|
@@ -2086,8 +2094,25 @@ export function registerPageTools(server, ctx) {
|
|
|
2086
2094
|
await session.applyAndSave(patches);
|
|
2087
2095
|
// EVERY copy's id, not just the root's: editing the copied row's answer
|
|
2088
2096
|
// used to take a whole sb_outline to find (TTG gap #53).
|
|
2089
|
-
|
|
2090
|
-
|
|
2097
|
+
// CAPPED: the map grows with the subtree, and a 200-node section would
|
|
2098
|
+
// pour 200 pairs into the reader. Past the cap, the copy's top level only.
|
|
2099
|
+
const entry = (from) => [from, [map[from], d.doc.nodes[from]?.data.type ?? '']];
|
|
2100
|
+
const all = Object.keys(map);
|
|
2101
|
+
if (all.length <= DUPLICATE_COPIES_CAP) {
|
|
2102
|
+
return text({ duplicated: id, into: ids[0], copies: Object.fromEntries(all.map(entry)), rev: d.rev, ...forcedOf() });
|
|
2103
|
+
}
|
|
2104
|
+
const top = [id, ...childrenOf(d.doc, id)].filter((k) => k in map).slice(0, DUPLICATE_COPIES_CAP);
|
|
2105
|
+
const how = ctx.notices.once('duplicate-truncated', 'copies holds the copy and its direct children only (copied counts every node); a deeper sb_outline reads the rest.');
|
|
2106
|
+
return text({
|
|
2107
|
+
duplicated: id,
|
|
2108
|
+
into: ids[0],
|
|
2109
|
+
copied: all.length,
|
|
2110
|
+
copies: Object.fromEntries(top.map(entry)),
|
|
2111
|
+
copies_truncated: true,
|
|
2112
|
+
...(how ? { copies_note: how } : {}),
|
|
2113
|
+
rev: d.rev,
|
|
2114
|
+
...forcedOf(),
|
|
2115
|
+
});
|
|
2091
2116
|
}
|
|
2092
2117
|
// ONTO ANOTHER PAGE — the editor's paste (`useCanvasClipboard.ts`).
|
|
2093
2118
|
const from = session.location();
|
|
@@ -2811,8 +2836,9 @@ export function registerPageTools(server, ctx) {
|
|
|
2811
2836
|
// NO CASCADE PREVIEW EXISTS on the platform (page/globalservice.go
|
|
2812
2837
|
// cascadeTargets runs inside publish only), so the dry run says the rule
|
|
2813
2838
|
// rather than a list it cannot know (TTG gap #59); the real answer names
|
|
2814
|
-
// the pages under `cascaded`.
|
|
2815
|
-
|
|
2839
|
+
// the pages under `cascaded`. SPENT on first show, dry or real: a dry
|
|
2840
|
+
// run repeated it on every preview.
|
|
2841
|
+
const cascade = ctx.notices.once('publish-cascade', 'Publishing also republishes, from their LAST PUBLISHED version (never their draft), every live page ' +
|
|
2816
2842
|
'whose shared header/footer, overlay (cart drawer, pop-up) or app block is behind its master. The ' +
|
|
2817
2843
|
'platform offers no preview of that list; the real publish names them under cascaded.');
|
|
2818
2844
|
return text({ dry_run: true, would_post: path, body, ...draftNote(drafts, fresh), ...(cascade ? { cascade_note: cascade } : {}) });
|
package/dist/tools/store.js
CHANGED
|
@@ -42,7 +42,7 @@ import { API_DEFINITIONS } from '../catalog/api.generated.js';
|
|
|
42
42
|
import { siteToken } from './credentialpick.js';
|
|
43
43
|
import { siteFor } from './context.js';
|
|
44
44
|
import { withFreshIds } from '../domains/site/ids.js';
|
|
45
|
-
import { siteChrome, wearChrome } from './page.js';
|
|
45
|
+
import { addPlaced, saveRefusal, siteChrome, wearChrome } from './page.js';
|
|
46
46
|
import { addSubtree } from '../domains/site/builder.js';
|
|
47
47
|
import { attachGlobal, buildChrome, detachGlobal, promoteGlobal, saveTemplate } from './chrome.js';
|
|
48
48
|
import { bindMenu } from './menu.js';
|
|
@@ -398,7 +398,11 @@ async function seedForm(ctx, session, siteId, key, formName, pageName, headline,
|
|
|
398
398
|
throw new Error('sbuilder: action:"form" takes page_name (a new page) or node_id (the open page), not both.');
|
|
399
399
|
if (session.site() !== siteId)
|
|
400
400
|
throw new Error(`sbuilder: the open page is on site ${session.site()}, not ${siteId} — open a page of this site first.`);
|
|
401
|
-
|
|
401
|
+
// sb_add's placement AND the save's own verdict: a page that would refuse
|
|
402
|
+
// the form node must refuse it here, while there is still no form.
|
|
403
|
+
const refusal = saveRefusal(session.current(), addPlaced(session.current(), parentId, { type: 'form', specials: { formId: 'frm_check' } }).patches).refusal;
|
|
404
|
+
if (refusal)
|
|
405
|
+
throw new Error(`sbuilder: ${refusal} — no form was created.`);
|
|
402
406
|
}
|
|
403
407
|
const tpl = FORM_TEMPLATES[key];
|
|
404
408
|
const site = encodeURIComponent(siteId);
|
|
@@ -499,7 +503,7 @@ async function seedForm(ctx, session, siteId, key, formName, pageName, headline,
|
|
|
499
503
|
let placed;
|
|
500
504
|
if (parentId) {
|
|
501
505
|
try {
|
|
502
|
-
const { patches, ids } =
|
|
506
|
+
const { patches, ids } = addPlaced(session.current(), parentId, { type: 'form', specials: { formId: form.id } });
|
|
503
507
|
await session.applyAndSave(patches);
|
|
504
508
|
placed = { id: ids[0], parent: parentId };
|
|
505
509
|
}
|
package/dist/transport/pages.js
CHANGED
|
@@ -16,14 +16,15 @@ export function sourcePath(siteId, pageId) {
|
|
|
16
16
|
* back out on write.
|
|
17
17
|
*/
|
|
18
18
|
/**
|
|
19
|
-
* A 404 on a page's source is a DELETED page
|
|
19
|
+
* A 404 on a page's source is a DELETED page, a wrong site id, or a key scoped to
|
|
20
|
+
* another site — and the session
|
|
20
21
|
* may still be pointing at it: a bare "source not found [http 404]" after an
|
|
21
22
|
* sb_api_call delete told the caller nothing (TTG gap #57). Same status and
|
|
22
23
|
* code, a sentence that says what to do.
|
|
23
24
|
*/
|
|
24
|
-
const gone = (pageId) => (e) => {
|
|
25
|
+
const gone = (siteId, pageId) => (e) => {
|
|
25
26
|
if (e instanceof ApiError && e.status === 404) {
|
|
26
|
-
throw new ApiError(404, e.code, `page ${pageId}
|
|
27
|
+
throw new ApiError(404, e.code, `page ${pageId} not found on site ${siteId} (deleted, or not this site/key) — sb_page_open another page; sb_page_list lists them`, e.details, e.fields);
|
|
27
28
|
}
|
|
28
29
|
throw e;
|
|
29
30
|
};
|
|
@@ -34,7 +35,7 @@ export async function loadSource(ctx, siteId, pageId) {
|
|
|
34
35
|
path: sourcePath(siteId, pageId),
|
|
35
36
|
token: siteToken(ctx),
|
|
36
37
|
fetchImpl: ctx.fetchImpl,
|
|
37
|
-
}).catch(gone(pageId)));
|
|
38
|
+
}).catch(gone(siteId, pageId)));
|
|
38
39
|
return out.source;
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
@@ -71,6 +72,6 @@ livePeer) {
|
|
|
71
72
|
body: { document, schemaVersion: document.schema_version ?? 1, ...(baseRev ? { baseRev } : {}) },
|
|
72
73
|
...(livePeer && LIVE_PEER.test(livePeer) ? { headers: { 'X-WB-Live-Peer': livePeer } } : {}),
|
|
73
74
|
fetchImpl: ctx.fetchImpl,
|
|
74
|
-
}).catch(gone(pageId)));
|
|
75
|
+
}).catch(gone(siteId, pageId)));
|
|
75
76
|
return out.source;
|
|
76
77
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sbuilder-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.100.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",
|