Skip to content

Commit 6cb0e04

Browse files
authored
fix(pandadoc): resolve list_templates id through the API (#250)
Looking up a template by ID returns an empty result when the template is not on the first page, because one page is fetched and then filtered locally. ``` before: list_templates({ id: "tpl_055" }) -> results: [] after: list_templates({ id: "tpl_055" }) -> results: [tpl_055] ``` PandaDoc accepts `id` as a query parameter, so the filter was never needed. https://developers.pandadoc.com/reference/list-templates
1 parent 8785a4d commit 6cb0e04

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

src/providers/pandadoc/actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const pandadocActions: ProviderActionDefinition[] = [
8787
{
8888
...pageInput,
8989
q: s.string("Search query."),
90-
id: s.string("Filter locally by template ID."),
90+
id: s.string("Only return the template with this ID."),
9191
shared: s.boolean("Whether to include shared templates."),
9292
deleted: s.boolean("Whether to include deleted templates."),
9393
folder_uuid: s.string("Folder UUID filter."),

src/providers/pandadoc/runtime.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export const pandadocActionHandlers: Record<string, PandadocActionHandler> = {
7676
path: "/public/v1/templates",
7777
query: {
7878
q: optionalString(input.q),
79+
id: optionalString(input.id),
7980
page: optionalInteger(input.page),
8081
count: optionalInteger(input.count),
8182
shared: optionalBoolean(input.shared),
@@ -88,10 +89,8 @@ export const pandadocActionHandlers: Record<string, PandadocActionHandler> = {
8889
"PandaDoc template list response",
8990
providerResponseError,
9091
);
91-
const id = optionalString(input.id);
92-
const results = listResults(payload).filter((item) => !id || optionalString(item.id) === id);
9392
return compactObject({
94-
results,
93+
results: listResults(payload),
9594
count: optionalInteger(payload.count),
9695
next: optionalString(payload.next) ?? null,
9796
previous: optionalString(payload.previous) ?? null,

0 commit comments

Comments
 (0)