Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
65 changes: 65 additions & 0 deletions src/apps/scheduled-tasks-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export interface TaskResponse extends TaskAvailability {
actions: ScheduledTasksTypes.TaskAction[]
}

export type AdhocTaskResponse = Pick<TaskResponse, 'task' | 'actions'>

async function getTasks<
T extends {
taskResponses: TaskResponse[]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
*
Expand Down
Loading