Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/adr-0046-rest-doc-list-slim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@objectstack/rest": patch
---

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.
23 changes: 23 additions & 0 deletions packages/rest/src/rest-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1832,6 +1832,29 @@ export class RestServer {
}
}

// ADR-0046: `doc` list responses omit `content` by
// default — manuals are the one metadata payload that
// grows unbounded, and the list surface only needs
// name + label. `?include=content` opts back in; the
// single-item GET /meta/doc/:name always returns the
// full body.
if (req.params.type === 'doc' && req.query?.include !== 'content') {
const raw = visible as unknown;
const list: any[] | null = Array.isArray(raw)
? (raw as any[])
: (raw && typeof raw === 'object' && Array.isArray((raw as any).items))
? ((raw as any).items as any[])
: null;
if (list) {
const slim = list.map((it: any) => {
if (!it || typeof it !== 'object') return it;
const { content: _content, ...rest } = it;
return rest;
});
visible = Array.isArray(raw) ? slim : { ...(raw as any), items: slim };
}
}

const translated = await this.translateMetaItems(req, req.params.type, environmentId, visible);
res.header('Vary', 'Accept-Language');
res.json(translated);
Expand Down