Skip to content

Commit b08d08d

Browse files
xuyushun441-sysos-zhuangclaude
authored
fix(rest): ADR-0046 — /meta/doc list omits content by default (#1790)
The runtime dispatcher's /metadata/doc route already slims doc list responses (#1789), but the console reads the REST server's /meta/:type route, which still returned full bodies. Apply the same rule here: list responses carry name + label only, ?include=content opts back in, and GET /meta/doc/:name always returns the full body. Found during live verification of the console /docs/:name route — the list endpoint is the path that must stay content-free because manuals are the one metadata payload that grows unbounded. Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 1ada658 commit b08d08d

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@objectstack/rest": patch
3+
---
4+
5+
ADR-0046: `GET /meta/doc` list responses omit `content` by default (`?include=content` opts back in; `GET /meta/doc/:name` always returns the full body). The runtime dispatcher's `/metadata/doc` route already slims docs (#1789) — this applies the same rule on the REST `/meta/:type` route the console actually reads, keeping unbounded manuals off the list surface.

packages/rest/src/rest-server.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,6 +1832,29 @@ export class RestServer {
18321832
}
18331833
}
18341834

1835+
// ADR-0046: `doc` list responses omit `content` by
1836+
// default — manuals are the one metadata payload that
1837+
// grows unbounded, and the list surface only needs
1838+
// name + label. `?include=content` opts back in; the
1839+
// single-item GET /meta/doc/:name always returns the
1840+
// full body.
1841+
if (req.params.type === 'doc' && req.query?.include !== 'content') {
1842+
const raw = visible as unknown;
1843+
const list: any[] | null = Array.isArray(raw)
1844+
? (raw as any[])
1845+
: (raw && typeof raw === 'object' && Array.isArray((raw as any).items))
1846+
? ((raw as any).items as any[])
1847+
: null;
1848+
if (list) {
1849+
const slim = list.map((it: any) => {
1850+
if (!it || typeof it !== 'object') return it;
1851+
const { content: _content, ...rest } = it;
1852+
return rest;
1853+
});
1854+
visible = Array.isArray(raw) ? slim : { ...(raw as any), items: slim };
1855+
}
1856+
}
1857+
18351858
const translated = await this.translateMetaItems(req, req.params.type, environmentId, visible);
18361859
res.header('Vary', 'Accept-Language');
18371860
res.json(translated);

0 commit comments

Comments
 (0)