Skip to content

Commit 8000a5d

Browse files
committed
Correct a syntax docstring for dql filtering
1 parent dd57f7b commit 8000a5d

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

extensions/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export default function (pi: ExtensionAPI) {
140140
filter: Type.Optional(
141141
Type.String({
142142
description:
143-
'Semicolon-separated fields (e.g. "name;summary;homepageUri") or JsonPath to restrict returned fields.',
143+
'Field-path filter. Use space-separated dot-notation paths (e.g. "title datePublished url summary"), or ;-separated JsonPath filters each prefixed with $ (e.g. "$.title;$.datePublished"). Do NOT join bare field names with ; -- that is rejected (422).',
144144
}),
145145
),
146146
format: Type.Optional(
@@ -159,10 +159,17 @@ export default function (pi: ExtensionAPI) {
159159
try {
160160
const db = getClient();
161161
const format = params.format ?? "json";
162+
// The API rejects `;`-joined bare field paths (422). If the filter is
163+
// not JsonPath (no `$`), convert `;`-separated field names into the
164+
// space-separated dot-notation form the API expects.
165+
const filter =
166+
params.filter != null && !params.filter.includes("$")
167+
? params.filter.split(";").map((s) => s.trim()).filter(Boolean).join(" ")
168+
: params.filter;
162169
const data = await dql(db, params.query, {
163170
size: params.size,
164171
from: params.from,
165-
filter: params.filter,
172+
filter,
166173
format,
167174
exportspec: params.exportspec,
168175
raw: format !== "json",

0 commit comments

Comments
 (0)