From 02ef091460fbf1586ae900921a121001ad5eeea7 Mon Sep 17 00:00:00 2001 From: Zach McElrath Date: Sun, 19 Nov 2023 21:48:02 -0500 Subject: [PATCH] support querying on just a particular Task by id --- .../bots/load/clickup_tasks_load/bot.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/clickup/bundle/bots/load/clickup_tasks_load/bot.ts b/apps/clickup/bundle/bots/load/clickup_tasks_load/bot.ts index 8c8712b..b675a1e 100644 --- a/apps/clickup/bundle/bots/load/clickup_tasks_load/bot.ts +++ b/apps/clickup/bundle/bots/load/clickup_tasks_load/bot.ts @@ -93,8 +93,8 @@ export default function clickup_tasks_load(bot: LoadBotApi) { }, {} ) - // List id must be provided by conditions - let listId + // Either List id or Task Id must be provided by conditions + let listId, taskId const queryParams = ["archived=false"] as string[] const buildQueryStringConditions = () => { if (!conditions || !conditions.length) return @@ -109,6 +109,11 @@ export default function clickup_tasks_load(bot: LoadBotApi) { listId = condition.value return } + // Special case: "uesio/core.id", use this as the task id condition + if (field === "uesio/core.id") { + taskId = condition.value + return + } if (value === null || value === undefined) return const encodedValue = encodeURIComponent(value as string) switch (condition.operator) { @@ -138,15 +143,15 @@ export default function clickup_tasks_load(bot: LoadBotApi) { } buildQueryStringConditions() - if (!listId) { + if (!listId && !taskId) { throw new Error( - "Clickup Tasks Load Bot requires a list id condition to be set" + "querying Clickup Tasks requires either a list id or task id condition to be set" ) } - const url = `${bot.getIntegration().getBaseURL()}/list/${listId}/task${ - queryParams.length ? "?" + queryParams.join("&") : "" - }` + const url = `${bot.getIntegration().getBaseURL()}/${ + listId ? `list/${listId}/task` : `task/${taskId}` + }${queryParams.length ? "?" + queryParams.join("&") : ""}` const result = bot.http.request({ method: "GET",