ANW-26 HTTP /query markdown-merge mode

Accept: text/markdown on /query concatenates matched note bodies into one
markdown document, each fragment preceded by an HTML-comment source marker.
Adds __anw-order (frontmatter-key ordering, asc/desc, missing-key-last) and
__anw-kind (homogeneity guard, 400 on a mixed merge). Both evaluate over the
full matched set before __anw-limit truncates. Merge mode uses its own
body-cloning projection; the JSON path is unchanged (no body clone).
This commit is contained in:
Andreas Brenner 2026-06-14 18:20:38 +03:00
parent 0c461be698
commit 03cc12e640
6 changed files with 529 additions and 1 deletions

View file

@ -0,0 +1,8 @@
# [ANW-26] __anw-kind=status rejects a mixed merge: alpha (draft) and anwesen
# (active) carry distinct status values, so the guard returns 400.
GET {{host}}/query?__anw-path=Projects&status__exists=true&__anw-kind=status
Accept: text/markdown
HTTP 400
[Asserts]
body contains "draft"
body contains "active"

View file

@ -0,0 +1,8 @@
# [ANW-26] __anw-kind=kind passes when every matched note carries the same
# value (both PDRs have kind: PDR).
GET {{host}}/query?__anw-path=Projects&kind=PDR&__anw-kind=kind
Accept: text/markdown
HTTP 200
[Asserts]
body contains "First PDR."
body contains "Second PDR."

View file

@ -0,0 +1,11 @@
# [ANW-26] Accept: text/markdown on /query merges matched note bodies into
# one document, each fragment preceded by its source marker.
GET {{host}}/query?__anw-path=Projects&kind=PDR
Accept: text/markdown
HTTP 200
[Asserts]
header "Content-Type" == "text/markdown; charset=utf-8"
body contains "<!-- source: Projects/PDR-001-intro.md -->"
body contains "<!-- source: Projects/PDR-002-followup.md -->"
body contains "First PDR."
body contains "Second PDR."

View file

@ -0,0 +1,7 @@
# [ANW-26] __anw-order=num:desc orders fragments by the `num` key descending,
# so PDR-002 (num 2) precedes PDR-001 (num 1) in the merged body.
GET {{host}}/query?__anw-path=Projects&kind=PDR&__anw-order=num:desc
Accept: text/markdown
HTTP 200
[Asserts]
body matches /(?s)Second PDR.*First PDR/