From eac1a8e334fce9b140508c295a4d7ec20eee23da Mon Sep 17 00:00:00 2001 From: David Porter Date: Tue, 5 May 2026 10:34:53 +1000 Subject: [PATCH] AP-8235 # added `getAdhocTasksForFormsApp` and `getAdhocTaskGroupInstanceTasks` to `scheduledTasksService` --- CHANGELOG.md | 1 + src/apps/scheduled-tasks-service.ts | 65 +++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6e00435..cd1769bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - support adhoc tasks +- `getAdhocTasksForFormsApp` and `getAdhocTaskGroupInstanceTasks` to `scheduledTasksService` ## [10.1.1] - 2026-04-23 diff --git a/src/apps/scheduled-tasks-service.ts b/src/apps/scheduled-tasks-service.ts index 24b2addb..4385e516 100644 --- a/src/apps/scheduled-tasks-service.ts +++ b/src/apps/scheduled-tasks-service.ts @@ -20,6 +20,8 @@ export interface TaskResponse extends TaskAvailability { actions: ScheduledTasksTypes.TaskAction[] } +export type AdhocTaskResponse = Pick + async function getTasks< T extends { taskResponses: TaskResponse[] @@ -95,6 +97,33 @@ export async function getTasksForFormsApp({ return await getTasks(url, abortSignal) } +/** + * Obtain all of the related adhoc Tasks for a specific Forms App + * + * #### Example + * + * ```js + * const formsAppId = 1 + * const tasks = await getAdhocTasksForFormsApp({ formsAppId }) + * ``` + * + * @param formsAppId + * @param abortSignal + * @returns + */ +export async function getAdhocTasksForFormsApp({ + formsAppId, + abortSignal, +}: { + formsAppId: number + abortSignal?: AbortSignal +}) { + const url = `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/adhoc-tasks` + return (await getTasks(url, abortSignal)) as { + taskResponses: AdhocTaskResponse[] + } +} + /** * Obtain all of the tasks related to a Task Group Instances in a specific Forms * App @@ -136,6 +165,42 @@ export async function getTaskGroupInstanceTasks({ }>(url, abortSignal) } +/** + * Obtain all of the adhoc tasks related to a Task Group Instances in a specific + * Forms App + * + * #### Example + * + * ```js + * const formsAppId = 1 + * const taskGroupInstanceId = 'abc123' + * const tasks = await getAdhocTaskGroupInstanceTasks({ + * formsAppId, + * taskGroupInstanceId, + * }) + * ``` + * + * @param formsAppId + * @param taskGroupInstanceId + * @param abortSignal + * @returns + */ +export async function getAdhocTaskGroupInstanceTasks({ + taskGroupInstanceId, + formsAppId, + abortSignal, +}: { + taskGroupInstanceId: string + date: string + formsAppId: number + abortSignal?: AbortSignal +}) { + const url = `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/scheduled-task-group-instances/${taskGroupInstanceId}/adhoc-tasks` + return (await getTasks(url, abortSignal)) as { + taskResponses: AdhocTaskResponse[] + } +} + /** * Obtain all of the Task Group instances for a specific Forms App *