sbuilder-mcp 0.98.7 → 0.98.9
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 +21 -0
- package/CHANGELOG.vi.md +21 -0
- package/dist/catalog/deadkeys.generated.js +2 -2
- package/dist/catalog/shapes.generated.js +15 -1
- package/dist/catalog/source.generated.js +2 -2
- package/dist/core/tree.js +6 -2
- package/dist/domains/site/builder.js +13 -0
- package/dist/domains/site/findings.js +3 -0
- package/dist/domains/site/formdoc.js +6 -4
- package/dist/domains/site/review.js +17 -0
- package/dist/domains/site/writecheck.js +9 -7
- package/dist/tools/page.js +34 -17
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,27 @@ 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.98.9] - 2026-10-29
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
- `sb_set` and `sb_add` no longer fail with "Cannot read properties of undefined (reading 'responsive')", even with `dry_run`, when a hidden node's `data.parent` points at a node that no longer exists.
|
|
13
|
+
- `sb_set` evaluates `hidden_band` against the parent chain after applying all `edits[]`, so a batch that hides a parent in narrow bands and the child at base no longer warns, and a batch that unhides the parent does.
|
|
14
|
+
- A phone field that looks like a confirmation field (such as "SĐT nhận mã xác nhận" or `confirmed_phone`) is treated as a re-entry field only when the form has another phone field, so a form's only phone field is reported as the phone field.
|
|
15
|
+
|
|
16
|
+
## [0.98.8] - 2026-10-29
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- `sb_review` reports `hidden_desktop_dead` for a node with a dead `responsive.desktop.config.hidden` slot and says how to fix it.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- The catalog regenerates so that `POST /_wb/account/register` accepts `phone`, `form` and `answers`, where `form` and `answers` only let the platform check the form's rules and are not stored.
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
- `sb_set` removes the dead desktop `hidden` slot when it writes or unsets `hidden` at desktop or base.
|
|
26
|
+
- `sb_add` and `sb_set` no longer report `hidden_band` as visible in a band where a parent node is already hidden.
|
|
27
|
+
- A phone re-entry field that the builder generates is no longer treated as the phone field of a register form.
|
|
28
|
+
- `sb_publish`, `sb_page_state` and the next `sb_publish` use the remembered cascade state only while the page's `publishedAt` is still the one the cascade recorded, so a page published through the editor or `sb_api_call`, or unpublished, is no longer treated as cascaded.
|
|
29
|
+
|
|
9
30
|
## [0.98.7] - 2026-10-29
|
|
10
31
|
|
|
11
32
|
### Fixed
|
package/CHANGELOG.vi.md
CHANGED
|
@@ -6,6 +6,27 @@ 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.98.9] - 2026-10-29
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
- `sb_set` và `sb_add` không còn lỗi "Cannot read properties of undefined (reading 'responsive')", kể cả khi dùng `dry_run`, khi `data.parent` của node bị ẩn trỏ vào node đã không còn tồn tại.
|
|
13
|
+
- `sb_set` xét `hidden_band` trên chuỗi node cha sau khi áp toàn bộ `edits[]`, nên batch ẩn node cha ở các dải hẹp và ẩn node con ở base không còn cảnh báo, còn batch bỏ ẩn node cha thì có.
|
|
14
|
+
- Ô số điện thoại trông như ô xác nhận (như "SĐT nhận mã xác nhận" hoặc `confirmed_phone`) chỉ được coi là ô nhập lại khi form còn một ô số điện thoại khác, nên ô số điện thoại duy nhất của form được báo là trường phone.
|
|
15
|
+
|
|
16
|
+
## [0.98.8] - 2026-10-29
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- `sb_review` báo `hidden_desktop_dead` với node có slot `responsive.desktop.config.hidden` chết và nêu cách sửa.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- Catalog được tái sinh để `POST /_wb/account/register` nhận thêm `phone`, `form` và `answers`, trong đó `form` và `answers` chỉ để platform kiểm luật của form và không được lưu.
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
- `sb_set` xoá slot `hidden` chết ở desktop khi ghi hoặc unset `hidden` ở desktop hoặc base.
|
|
26
|
+
- `sb_add` và `sb_set` không còn báo `hidden_band` là còn hiện ở dải mà node cha đã bị ẩn.
|
|
27
|
+
- Ô nhập lại số điện thoại do builder tự dựng không còn bị coi là trường phone của form đăng ký.
|
|
28
|
+
- `sb_publish`, `sb_page_state` và lần `sb_publish` kế tiếp chỉ dùng trạng thái cascade đã nhớ khi `publishedAt` của trang vẫn là mốc cascade đã ghi, nên trang được publish qua editor hoặc `sb_api_call`, hoặc bị gỡ publish, không còn bị coi là đã cascade.
|
|
29
|
+
|
|
9
30
|
## [0.98.7] - 2026-10-29
|
|
10
31
|
|
|
11
32
|
### Fixed
|
|
@@ -4,7 +4,7 @@ export const SHAPE_SOURCE = {
|
|
|
4
4
|
"fromHandlers": 334,
|
|
5
5
|
"fromSwaggerOnly": 10,
|
|
6
6
|
"withReadOnly": 29,
|
|
7
|
-
"structsRead":
|
|
7
|
+
"structsRead": 3469
|
|
8
8
|
};
|
|
9
9
|
export const REQUEST_SHAPES = {
|
|
10
10
|
"post:/api/sites/{id}/ai-credits/purchase": {
|
|
@@ -3238,6 +3238,20 @@ export const REQUEST_SHAPES = {
|
|
|
3238
3238
|
{
|
|
3239
3239
|
"name": "password",
|
|
3240
3240
|
"type": "string"
|
|
3241
|
+
},
|
|
3242
|
+
{
|
|
3243
|
+
"name": "phone",
|
|
3244
|
+
"type": "string",
|
|
3245
|
+
"note": "Optional — a register form with a phone field (control name \"phone\", the palette's contact-phone row) sends it."
|
|
3246
|
+
},
|
|
3247
|
+
{
|
|
3248
|
+
"name": "form",
|
|
3249
|
+
"type": "string",
|
|
3250
|
+
"note": "Form + Answers: which register form sent this, and its answers (passwords excluded) — read only to check the form's own rules, never stored."
|
|
3251
|
+
},
|
|
3252
|
+
{
|
|
3253
|
+
"name": "answers",
|
|
3254
|
+
"type": "{ [string]: string }"
|
|
3241
3255
|
}
|
|
3242
3256
|
],
|
|
3243
3257
|
"source": "go",
|
|
@@ -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": "a666c262a63a0057ce25db75d983e1325b1fde8b",
|
|
5
|
+
"committedAt": "2026-10-29T12:22:29+07:00",
|
|
6
6
|
"dirty": false
|
|
7
7
|
};
|
package/dist/core/tree.js
CHANGED
|
@@ -130,12 +130,16 @@ export function subtreeIds(doc, id) {
|
|
|
130
130
|
walk(doc, id, (n) => out.push(n.id));
|
|
131
131
|
return out;
|
|
132
132
|
}
|
|
133
|
-
/**
|
|
133
|
+
/**
|
|
134
|
+
* Ids from this node's parent up to ROOT. Cycle-safe for the same reason, and
|
|
135
|
+
* stops at a parent pointer naming a node the document does not hold — every
|
|
136
|
+
* caller maps the ids back to `doc.nodes[a]`, and a dangling one is undefined.
|
|
137
|
+
*/
|
|
134
138
|
export function ancestors(doc, id) {
|
|
135
139
|
const out = [];
|
|
136
140
|
const seen = new Set([id]);
|
|
137
141
|
let cur = doc.nodes[id]?.data.parent ?? null;
|
|
138
|
-
while (cur && !seen.has(cur)) {
|
|
142
|
+
while (cur && !seen.has(cur) && doc.nodes[cur]) {
|
|
139
143
|
seen.add(cur);
|
|
140
144
|
out.push(cur);
|
|
141
145
|
cur = doc.nodes[cur]?.data.parent ?? null;
|
|
@@ -471,6 +471,17 @@ export function setKeys(doc, id, keys, opts) {
|
|
|
471
471
|
if (Object.keys(seeds).length)
|
|
472
472
|
keys = { ...seeds, ...keys };
|
|
473
473
|
}
|
|
474
|
+
// A DEAD `responsive.desktop.config.hidden` — where sb_set wrote a desktop
|
|
475
|
+
// `hidden` before 0.98.6, and read by nothing (render/css.go hiddenAt reads
|
|
476
|
+
// base for desktop). A desktop/base write or unset of `hidden` now lands at
|
|
477
|
+
// base, so it would never reach that slot: clear it in the same call.
|
|
478
|
+
const deskCfg = doc.node(id).responsive?.desktop?.config ?? {};
|
|
479
|
+
const deadHidden = namespace === 'config' &&
|
|
480
|
+
'hidden' in deskCfg &&
|
|
481
|
+
('hidden' in keys || (opts.unset ?? []).includes('hidden')) &&
|
|
482
|
+
(opts.base || (opts.breakpoint ?? 'desktop') === 'desktop')
|
|
483
|
+
? [{ op: 'unset', path: ['nodes', id, 'responsive', 'desktop', 'config', 'hidden'] }]
|
|
484
|
+
: [];
|
|
474
485
|
if (opts.base) {
|
|
475
486
|
// Base IS legitimate, and this used to throw for anything that was not an
|
|
476
487
|
// identity key — a refusal built on a misread of the platform's responsive
|
|
@@ -497,6 +508,7 @@ export function setKeys(doc, id, keys, opts) {
|
|
|
497
508
|
value: v,
|
|
498
509
|
})),
|
|
499
510
|
...removals,
|
|
511
|
+
...deadHidden,
|
|
500
512
|
...(rebind ? [rebind] : []),
|
|
501
513
|
];
|
|
502
514
|
}
|
|
@@ -528,6 +540,7 @@ export function setKeys(doc, id, keys, opts) {
|
|
|
528
540
|
path: ['nodes', id, 'responsive', bp, namespace, k],
|
|
529
541
|
})),
|
|
530
542
|
...unsetSplit.base.map((k) => ({ op: 'unset', path: ['nodes', id, namespace, k] })),
|
|
543
|
+
...deadHidden,
|
|
531
544
|
...(rebind ? [rebind] : []),
|
|
532
545
|
];
|
|
533
546
|
}
|
|
@@ -170,6 +170,9 @@ export const FIX = {
|
|
|
170
170
|
'{ "position": "sticky" } — sb_set seeds the offset and the layer order with it. Until ' +
|
|
171
171
|
'then the platform compiles no rule for this state at all, so the override is stored, ' +
|
|
172
172
|
'published and never painted. To drop it instead, remove the stuck slot.',
|
|
173
|
+
hidden_desktop_dead: 'To hide it at ≥1440px: sb_set id "<id>", namespace config, keys { "hidden": true } (lands at base). ' +
|
|
174
|
+
'To show it: sb_set id "<id>", namespace config, unset ["hidden"]. Either call also clears the dead ' +
|
|
175
|
+
'desktop slot.',
|
|
173
176
|
// FORM DOCUMENT findings (`sb_page_open form_id`) — stored by the platform, answerable by nobody.
|
|
174
177
|
form_options_empty: 'Give it choices: sb_set id "<id>", namespace specials, keys { "options": ["…", "…"] } — ' +
|
|
175
178
|
'each string is both what the visitor sees and the value posted. Or sb_remove it.',
|
|
@@ -176,10 +176,12 @@ export function formFieldFindings(d, formType) {
|
|
|
176
176
|
// when some field already posts as `phone`; the re-entry box is not a phone.
|
|
177
177
|
if (formType === 'register') {
|
|
178
178
|
const fields = formFields(d).filter((n) => collectsValue(n.data.type));
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
179
|
+
// A hand-built confirm box (tel, no mapTo) is told apart by its name or label.
|
|
180
|
+
const reentry = (n) => /confirm|repeat|re_?enter|xac_?nhan|nhap_?lai/i.test(`${postedName(n)} ${nameFromLabel(String(n.specials?.label ?? ''))}`);
|
|
181
|
+
const tel = (n) => n.specials?.mapTo === 'customer.phone' || n.specials?.inputType === 'tel';
|
|
182
|
+
// …but only when it confirms SOMETHING: the one phone-like box on the form
|
|
183
|
+
// ("SĐT nhận mã xác nhận", confirmed_phone) IS the phone, whatever it says.
|
|
184
|
+
const phoneish = fields.find((n) => n.specials?.mapTo === 'customer.phone' || (tel(n) && n.specials?.mapTo !== 'customer.confirmPhone' && !reentry(n))) ?? fields.find(tel);
|
|
183
185
|
if (phoneish && !fields.some((n) => postedName(n) === 'phone')) {
|
|
184
186
|
out.push({
|
|
185
187
|
code: 'form_register_phone',
|
|
@@ -1192,6 +1192,23 @@ opts = {}) {
|
|
|
1192
1192
|
fix: fill('stuck_no_host', { id }),
|
|
1193
1193
|
});
|
|
1194
1194
|
}
|
|
1195
|
+
// A DEAD DESKTOP `hidden`. Before 0.98.6 sb_set's default desktop write put
|
|
1196
|
+
// config.hidden in responsive.desktop, which nothing reads: desktop takes
|
|
1197
|
+
// BASE config.hidden (render/css.go hiddenAt), so the node still shows.
|
|
1198
|
+
const deskHidden = n
|
|
1199
|
+
.responsive?.desktop?.config;
|
|
1200
|
+
if (deskHidden && 'hidden' in deskHidden) {
|
|
1201
|
+
const baseHidden = n.config?.hidden === true;
|
|
1202
|
+
out.push({
|
|
1203
|
+
code: 'hidden_desktop_dead',
|
|
1204
|
+
nodeId: id,
|
|
1205
|
+
type,
|
|
1206
|
+
problem: `responsive.desktop.config.hidden (${JSON.stringify(deskHidden.hidden)}) is read by nothing — desktop reads base ` +
|
|
1207
|
+
`config.hidden, so this node ${baseHidden ? 'is hidden at ≥1440px by base, not by this slot' : 'still shows at ≥1440px'}.`,
|
|
1208
|
+
key: 'config.hidden',
|
|
1209
|
+
fix: fill('hidden_desktop_dead', { id }),
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1195
1212
|
const bindings = n.bindings ?? [];
|
|
1196
1213
|
// A container with nothing in it is a band of empty space. The commonest way
|
|
1197
1214
|
// to ship one is to add the section and then get distracted.
|
|
@@ -448,10 +448,11 @@ export function cascadeTail(node, written, id) {
|
|
|
448
448
|
* base expects it gone everywhere, so say which bands still show it — once per
|
|
449
449
|
* process, since the fact is the same for every node. `node` is AS IT WILL BE.
|
|
450
450
|
*/
|
|
451
|
-
export function hiddenBand(node, id) {
|
|
451
|
+
export function hiddenBand(node, id, above = []) {
|
|
452
452
|
if (node.config?.hidden !== true)
|
|
453
453
|
return [];
|
|
454
|
-
|
|
454
|
+
// A band an ANCESTOR hides there is not showing this node either (`above`).
|
|
455
|
+
const shown = ['laptop', 'tablet', 'mobile'].filter((bp) => [node, ...above].every((n) => n.responsive?.[bp]?.config?.hidden !== true));
|
|
455
456
|
if (!shown.length)
|
|
456
457
|
return [];
|
|
457
458
|
return [
|
|
@@ -470,9 +471,9 @@ export function hiddenBand(node, id) {
|
|
|
470
471
|
];
|
|
471
472
|
}
|
|
472
473
|
/** The same, for every node of a nested `sb_add` spec, as each will be born. */
|
|
473
|
-
export function specCheck(spec, idOf) {
|
|
474
|
+
export function specCheck(spec, idOf, above = []) {
|
|
474
475
|
const out = [];
|
|
475
|
-
const walk = (s) => {
|
|
476
|
+
const walk = (s, up) => {
|
|
476
477
|
// addSubtree's minted id, so a per-node note names (and dedupes on) its node.
|
|
477
478
|
const id = idOf?.get(s);
|
|
478
479
|
const d = ELEMENTS[s.type]?.defaults;
|
|
@@ -480,7 +481,8 @@ export function specCheck(spec, idOf) {
|
|
|
480
481
|
if (s.config)
|
|
481
482
|
out.push(...writeCheck(s.type, 'config', s.config));
|
|
482
483
|
// Born as addSubtree stores it: a desktop-slot `hidden` lands at base.
|
|
483
|
-
|
|
484
|
+
const self = { config: { hidden: s.responsive?.desktop?.config?.hidden ?? s.config?.hidden }, responsive: s.responsive };
|
|
485
|
+
out.push(...hiddenBand(self, id, up));
|
|
484
486
|
for (const slot of Object.values(s.responsive ?? {}))
|
|
485
487
|
if (slot.config)
|
|
486
488
|
out.push(...writeCheck(s.type, 'config', slot.config));
|
|
@@ -517,9 +519,9 @@ export function specCheck(spec, idOf) {
|
|
|
517
519
|
}
|
|
518
520
|
}
|
|
519
521
|
for (const c of s.children ?? [])
|
|
520
|
-
walk(c);
|
|
522
|
+
walk(c, [self, ...up]);
|
|
521
523
|
};
|
|
522
|
-
walk(spec);
|
|
524
|
+
walk(spec, above);
|
|
523
525
|
return out;
|
|
524
526
|
}
|
|
525
527
|
/** The notes `say` has not said yet, deduped within the call too. */
|
package/dist/tools/page.js
CHANGED
|
@@ -19,7 +19,7 @@ import { skinLevelNote } from '../domains/site/fieldskin.js';
|
|
|
19
19
|
import { siteTheme } from '../domains/site/theme-fetch.js';
|
|
20
20
|
import { ensureSiteTheme } from './theme.js';
|
|
21
21
|
import { request, redact, watchPageWrites, onPageSourceWrite, onGlobalWrite, onFormDocumentWrite } from '../transport/http.js';
|
|
22
|
-
import { SPEC_GLOBAL_ID, SPEC_GLOBAL_REV, SPEC_OVERLAY_ID, SPEC_OVERLAY_REV, subtreeIds } from '../core/tree.js';
|
|
22
|
+
import { SPEC_GLOBAL_ID, SPEC_GLOBAL_REV, SPEC_OVERLAY_ID, SPEC_OVERLAY_REV, subtreeIds, ancestors } from '../core/tree.js';
|
|
23
23
|
import { siteToken } from './credentialpick.js';
|
|
24
24
|
import { validateForSave } from '../domains/site/validate.js';
|
|
25
25
|
import { cascadeTail, formDocChecks, hiddenBand, sayChecks, specCheck, writeCheck } from '../domains/site/writecheck.js';
|
|
@@ -1487,7 +1487,7 @@ export function registerPageTools(server, ctx) {
|
|
|
1487
1487
|
.join(' ');
|
|
1488
1488
|
// Keys an element does not read, and values it does not know — on EVERY
|
|
1489
1489
|
// node of the nested spec, as each will be born. Warned, still written.
|
|
1490
|
-
const found = sayChecks([...specCheck(spec, idOf), ...session.formChecks(patches)], say);
|
|
1490
|
+
const found = sayChecks([...specCheck(spec, idOf, [parent_id, ...ancestors(d.doc, parent_id)].map((a) => d.doc.nodes[a])), ...session.formChecks(patches)], say);
|
|
1491
1491
|
const checks = found.length ? { checks: found } : {};
|
|
1492
1492
|
// A base-only key in a breakpoint slot lands at BASE (addSubtree routes it,
|
|
1493
1493
|
// as sb_set does) and so reaches every width — routed AND said.
|
|
@@ -1714,14 +1714,16 @@ export function registerPageTools(server, ctx) {
|
|
|
1714
1714
|
return cascadeTail(probe.nodes[e.id], { [bp]: e.keys }, e.id);
|
|
1715
1715
|
});
|
|
1716
1716
|
// config.hidden at base/desktop hides ≥1440px only — judged on the node
|
|
1717
|
-
// AS IT WILL BE
|
|
1717
|
+
// AS IT WILL BE — and so are its ancestors, since one edits[] can hide the
|
|
1718
|
+
// parent at the narrow bands — so a batch that hides every band says nothing.
|
|
1718
1719
|
const hidden = batch.flatMap((e) => {
|
|
1719
1720
|
const bp = e.breakpoint ?? 'desktop';
|
|
1720
1721
|
if (e.namespace !== 'config' || e.state || e.keys.hidden !== true || (!e.base && bp !== 'desktop') || !d.doc.nodes[e.id])
|
|
1721
1722
|
return [];
|
|
1722
|
-
const
|
|
1723
|
-
|
|
1724
|
-
|
|
1723
|
+
const chain = [e.id, ...ancestors(d.doc, e.id)];
|
|
1724
|
+
const probe = { nodes: Object.fromEntries(chain.map((a) => [a, JSON.parse(JSON.stringify(d.doc.nodes[a]))])) };
|
|
1725
|
+
applyPatches(probe, patches.filter((p) => p.path[0] === 'nodes' && chain.includes(String(p.path[1]))));
|
|
1726
|
+
return hiddenBand(probe.nodes[e.id], e.id, chain.slice(1).map((a) => probe.nodes[a]));
|
|
1725
1727
|
});
|
|
1726
1728
|
const found = sayChecks([...checked, ...tail, ...hidden, ...session.formChecks(patches)], say);
|
|
1727
1729
|
const checks = found.length ? { checks: found } : {};
|
|
@@ -2606,11 +2608,16 @@ export function registerPageTools(server, ctx) {
|
|
|
2606
2608
|
// publishSourceFor, by design) and writes a fresh published row — and the
|
|
2607
2609
|
// page list's `publishedAt` is denormalised from that row, so the draft that
|
|
2608
2610
|
// did NOT go live now reads older than "published". Remembered here until the
|
|
2609
|
-
// page is published by name
|
|
2611
|
+
// page is published by name — or until its publishedAt is no longer the one
|
|
2612
|
+
// the cascade wrote: the editor or sb_api_call published it, or it was
|
|
2613
|
+
// unpublished, and the timestamps tell the truth again.
|
|
2610
2614
|
// ponytail: in-process; a new process sees only timestamps again. Exact would
|
|
2611
2615
|
// compare each page's updatedAt with its live version's createdAt
|
|
2612
2616
|
// (GET …/versions, isLive) — a heavy listing per page.
|
|
2613
2617
|
const cascadeMasked = new Map();
|
|
2618
|
+
// Compared as instants (ms): the publish answer and the listings may print
|
|
2619
|
+
// the same time at different precision.
|
|
2620
|
+
const stillCascaded = (m, now) => typeof m.publishedAt === 'string' && typeof now === 'string' && Date.parse(m.publishedAt) === Date.parse(now);
|
|
2614
2621
|
server.registerTool('sb_publish', {
|
|
2615
2622
|
description: 'Compile the draft into the live page, and report which revision went live (id, ' +
|
|
2616
2623
|
'publishedAt, fromVersionId). PUBLISH CASCADES: a page sharing a global section with ' +
|
|
@@ -2664,13 +2671,15 @@ export function registerPageTools(server, ctx) {
|
|
|
2664
2671
|
// A remembered page no longer listed was DELETED: sending its id makes
|
|
2665
2672
|
// the platform's publishTargets refuse the whole batch (ErrPageNotFound),
|
|
2666
2673
|
// on every publish_drafts:true until restart. Forget it.
|
|
2667
|
-
|
|
2674
|
+
// Published or unpublished by another door since: publishedAt moved, forget it too.
|
|
2675
|
+
const listed = new Map((got.pages ?? []).map((p) => [String(p.id), p]));
|
|
2668
2676
|
const memory = cascadeMasked.get(site_id);
|
|
2669
2677
|
for (const m of memory?.values() ?? []) {
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2678
|
+
const id = m.row.pageId;
|
|
2679
|
+
if (!listed.has(id) || !stillCascaded(m, listed.get(id).publishedAt))
|
|
2680
|
+
memory.delete(id);
|
|
2681
|
+
else if (id !== page_id && !drafts.some((d) => d.pageId === id))
|
|
2682
|
+
drafts.push(m.row);
|
|
2674
2683
|
}
|
|
2675
2684
|
const unborn = others.filter((p) => state(p) === 'never_published').map(row);
|
|
2676
2685
|
fresh = unborn.filter((r) => !heldFromFirstPublish(r.type));
|
|
@@ -2750,9 +2759,12 @@ export function registerPageTools(server, ctx) {
|
|
|
2750
2759
|
cascadeMasked.set(site_id, masked);
|
|
2751
2760
|
for (const id of asked)
|
|
2752
2761
|
masked.delete(id);
|
|
2753
|
-
for (const d of drafts)
|
|
2754
|
-
if (cascaded.includes(d.pageId))
|
|
2755
|
-
|
|
2762
|
+
for (const d of drafts) {
|
|
2763
|
+
if (!cascaded.includes(d.pageId))
|
|
2764
|
+
continue;
|
|
2765
|
+
const at = published.find((p) => String(p.pageId) === d.pageId)?.publishedAt;
|
|
2766
|
+
masked.set(d.pageId, { row: d, publishedAt: at });
|
|
2767
|
+
}
|
|
2756
2768
|
// A 200 PROVES A ROW WAS STORED, NOT THAT A VISITOR IS BEING SERVED IT.
|
|
2757
2769
|
// The storefront answers `cache-control: public, max-age=60`, so the two
|
|
2758
2770
|
// legitimately differ for up to a minute — long enough for a caller to
|
|
@@ -2843,8 +2855,13 @@ export function registerPageTools(server, ctx) {
|
|
|
2843
2855
|
const row = (live.published ?? []).find((p) => p.pageId === pageId);
|
|
2844
2856
|
const publishedNodes = Object.keys((row?.document?.nodes ?? {})).length;
|
|
2845
2857
|
// The same cascade memory sb_publish lists unpublished_drafts from: a
|
|
2846
|
-
// cascade moved publishedAt past this draft, so the timestamps lie
|
|
2847
|
-
|
|
2858
|
+
// cascade moved publishedAt past this draft, so the timestamps lie —
|
|
2859
|
+
// while the live row still carries the publishedAt that cascade wrote.
|
|
2860
|
+
const memory = cascadeMasked.get(site_id);
|
|
2861
|
+
const remembered = memory?.get(pageId);
|
|
2862
|
+
if (remembered && !stillCascaded(remembered, row?.publishedAt))
|
|
2863
|
+
memory.delete(pageId);
|
|
2864
|
+
const drift = memory?.has(pageId)
|
|
2848
2865
|
? {
|
|
2849
2866
|
state: 'draft_ahead',
|
|
2850
2867
|
note: 'The draft has changes the live page does not. A cascade this process ran republished ' +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sbuilder-mcp",
|
|
3
|
-
"version": "0.98.
|
|
3
|
+
"version": "0.98.9",
|
|
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",
|