diff --git a/src/TodoistApi.ts b/src/TodoistApi.ts index e620c9e..1a3cce6 100644 --- a/src/TodoistApi.ts +++ b/src/TodoistApi.ts @@ -9,6 +9,7 @@ import { GetProjectCommentsArgs, GetTaskCommentsArgs, GetTasksArgs, + GetTasksByFilterArgs, UpdateCommentArgs, UpdateLabelArgs, UpdateProjectArgs, @@ -37,6 +38,7 @@ import { getTaskFromQuickAddResponse } from './utils/taskConverters' import { getSyncBaseUri, ENDPOINT_REST_TASKS, + ENDPOINT_REST_TASKS_FILTER, ENDPOINT_REST_PROJECTS, ENDPOINT_SYNC_QUICK_ADD, ENDPOINT_REST_TASK_CLOSE, @@ -158,6 +160,29 @@ export class TodoistApi { } } + /** + * Retrieves tasks filtered by a filter string. + * + * @param args - Parameters for filtering tasks, including the query string and optional language. + * @returns A promise that resolves to a paginated response of tasks. + */ + async getTasksByFilter(args: GetTasksByFilterArgs): Promise { + const { + data: { results, nextCursor }, + } = await request( + 'GET', + this.syncApiBase, + ENDPOINT_REST_TASKS_FILTER, + this.authToken, + args, + ) + + return { + results: validateTaskArray(results), + nextCursor, + } + } + /** * Creates a new task with the provided parameters. * diff --git a/src/consts/endpoints.ts b/src/consts/endpoints.ts index 51e05af..7e01bb8 100644 --- a/src/consts/endpoints.ts +++ b/src/consts/endpoints.ts @@ -3,7 +3,7 @@ const TODOIST_URI = 'https://todoist.com' // The API version is not configurable, to ensure // compatibility between the API and the client. -export const API_VERSION = 'v9.220' +export const API_VERSION = 'v9.222' export const API_BASE_URI = `/api/${API_VERSION}/` const API_AUTHORIZATION_BASE_URI = '/oauth/' @@ -17,6 +17,7 @@ export function getAuthBaseUri(domainBase: string = TODOIST_URI): string { } export const ENDPOINT_REST_TASKS = 'tasks' +export const ENDPOINT_REST_TASKS_FILTER = ENDPOINT_REST_TASKS + '/filter' export const ENDPOINT_REST_PROJECTS = 'projects' export const ENDPOINT_REST_SECTIONS = 'sections' export const ENDPOINT_REST_LABELS = 'labels' diff --git a/src/types/requests.ts b/src/types/requests.ts index 9a29b5f..713d525 100644 --- a/src/types/requests.ts +++ b/src/types/requests.ts @@ -44,13 +44,23 @@ export type AddTaskArgs = { export type GetTasksArgs = { projectId?: string sectionId?: string + parentId?: string label?: string - filter?: string - lang?: string ids?: string[] cursor?: string | null limit?: number } + +/** + * @see http://todoist.com/api/v1/docs#tag/Tasks/operation/get_tasks_by_filter_api_v1_tasks_filter_get + */ +export type GetTasksByFilterArgs = { + query: string + lang?: string + cursor?: string | null + limit?: number +} + /** * @see https://developer.todoist.com/rest/v2/#tasks */ diff --git a/website/docs/api/.md b/website/docs/api/.md index 6f6f186..947abdd 100644 --- a/website/docs/api/.md +++ b/website/docs/api/.md @@ -19,6 +19,7 @@ | [Duration](interfaces/Duration.md) | Represents the duration of a task. | | [Label](interfaces/Label.md) | Represents a label in Todoist, which is used to categorize tasks. | | [Project](interfaces/Project.md) | Represents a project in Todoist, which can contain multiple tasks. | +| [RawComment](interfaces/RawComment.md) | Represents the raw comment data as received from the API before transformation. | | [Section](interfaces/Section.md) | Represents a section within a project, used to group tasks. | | [Task](interfaces/Task.md) | A task is a unit of work. It can be a simple to-do item or a more complex task with subtasks, comments, and attachments. | | [User](interfaces/User.md) | Represents a user in Todoist. | @@ -48,6 +49,7 @@ | [GetSharedLabelsResponse](type-aliases/GetSharedLabelsResponse.md) | - | | [GetTaskCommentsArgs](type-aliases/GetTaskCommentsArgs.md) | - | | [GetTasksArgs](type-aliases/GetTasksArgs.md) | - | +| [GetTasksByFilterArgs](type-aliases/GetTasksByFilterArgs.md) | - | | [GetTasksResponse](type-aliases/GetTasksResponse.md) | - | | [MoveTaskArgs](type-aliases/MoveTaskArgs.md) | - | | [Permission](type-aliases/Permission.md) | Permission scopes that can be requested during OAuth2 authorization. | diff --git a/website/docs/api/classes/TodoistApi.md b/website/docs/api/classes/TodoistApi.md index afcfbe0..aa53cef 100644 --- a/website/docs/api/classes/TodoistApi.md +++ b/website/docs/api/classes/TodoistApi.md @@ -559,6 +559,28 @@ A promise that resolves to an array of tasks. *** +### getTasksByFilter() + +```ts +getTasksByFilter(args: GetTasksByFilterArgs): Promise +``` + +Retrieves tasks filtered by a filter string. + +#### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `args` | [`GetTasksByFilterArgs`](../type-aliases/GetTasksByFilterArgs.md) | Parameters for filtering tasks, including the query string and optional language. | + +#### Returns + +`Promise`\<[`GetTasksResponse`](../type-aliases/GetTasksResponse.md)\> + +A promise that resolves to a paginated response of tasks. + +*** + ### moveTasks() ```ts diff --git a/website/docs/api/interfaces/Comment.md b/website/docs/api/interfaces/Comment.md index ca80288..2a26ff6 100644 --- a/website/docs/api/interfaces/Comment.md +++ b/website/docs/api/interfaces/Comment.md @@ -12,11 +12,15 @@ https://developer.todoist.com/sync/v9/#notes ## Properties -| Property | Type | -| ------ | ------ | -| `attachment` | \| `null` \| \{ `fileDuration`: `null` \| `number`; `fileName`: `null` \| `string`; `fileSize`: `null` \| `number`; `fileType`: `null` \| `string`; `fileUrl`: `null` \| `string`; `image`: `null` \| `string`; `imageHeight`: `null` \| `number`; `imageWidth`: `null` \| `number`; `resourceType`: `string`; `title`: `null` \| `string`; `uploadState`: `null` \| `"pending"` \| `"completed"`; `url`: `null` \| `string`; \} | -| `content` | `string` | -| `id` | `string` | -| `postedAt` | `string` | -| `projectId` | `null` \| `string` | -| `taskId` | `null` \| `string` | +| Property | Type | Default value | +| ------ | ------ | ------ | +| `content` | `string` | `undefined` | +| `fileAttachment` | \| `null` \| \{ `fileDuration`: `null` \| `number`; `fileName`: `null` \| `string`; `fileSize`: `null` \| `number`; `fileType`: `null` \| `string`; `fileUrl`: `null` \| `string`; `image`: `null` \| `string`; `imageHeight`: `null` \| `number`; `imageWidth`: `null` \| `number`; `resourceType`: `string`; `title`: `null` \| `string`; `uploadState`: `null` \| `"pending"` \| `"completed"`; `url`: `null` \| `string`; \} | `undefined` | +| `id` | `string` | `undefined` | +| `isDeleted` | `boolean` | `undefined` | +| `postedAt` | `string` | `undefined` | +| `postedUid` | `string` | `undefined` | +| `projectId?` | `string` | `undefined` | +| `reactions` | `null` \| `Record`\<`string`, `string`[]\> | `undefined` | +| `taskId` | `undefined` \| `string` | `itemId` | +| `uidsToNotify` | `null` \| `string`[] | `undefined` | diff --git a/website/docs/api/interfaces/RawComment.md b/website/docs/api/interfaces/RawComment.md new file mode 100644 index 0000000..edba542 --- /dev/null +++ b/website/docs/api/interfaces/RawComment.md @@ -0,0 +1,26 @@ +# RawComment + +Represents the raw comment data as received from the API before transformation. + +## See + +https://developer.todoist.com/sync/v9/#notes + +## Extends + +- `TypeOf`\<*typeof* `RawCommentSchema`\> + +## Properties + +| Property | Type | +| ------ | ------ | +| `content` | `string` | +| `fileAttachment` | \| `null` \| \{ `fileDuration`: `null` \| `number`; `fileName`: `null` \| `string`; `fileSize`: `null` \| `number`; `fileType`: `null` \| `string`; `fileUrl`: `null` \| `string`; `image`: `null` \| `string`; `imageHeight`: `null` \| `number`; `imageWidth`: `null` \| `number`; `resourceType`: `string`; `title`: `null` \| `string`; `uploadState`: `null` \| `"pending"` \| `"completed"`; `url`: `null` \| `string`; \} | +| `id` | `string` | +| `isDeleted` | `boolean` | +| `itemId?` | `string` | +| `postedAt` | `string` | +| `postedUid` | `string` | +| `projectId?` | `string` | +| `reactions` | `null` \| `Record`\<`string`, `string`[]\> | +| `uidsToNotify` | `null` \| `string`[] | diff --git a/website/docs/api/interfaces/Section.md b/website/docs/api/interfaces/Section.md index 13d271a..4a2ae0e 100644 --- a/website/docs/api/interfaces/Section.md +++ b/website/docs/api/interfaces/Section.md @@ -14,7 +14,14 @@ https://developer.todoist.com/sync/v9/#sections | Property | Type | | ------ | ------ | +| `addedAt` | `string` | +| `archivedAt` | `null` \| `string` | | `id` | `string` | +| `isArchived` | `boolean` | +| `isCollapsed` | `boolean` | +| `isDeleted` | `boolean` | | `name` | `string` | -| `order` | `number` | | `projectId` | `string` | +| `sectionOrder` | `number` | +| `updatedAt` | `string` | +| `userId` | `string` | diff --git a/website/docs/api/type-aliases/GetTasksArgs.md b/website/docs/api/type-aliases/GetTasksArgs.md index f253b7e..5d66b26 100644 --- a/website/docs/api/type-aliases/GetTasksArgs.md +++ b/website/docs/api/type-aliases/GetTasksArgs.md @@ -3,11 +3,10 @@ ```ts type GetTasksArgs = { cursor: string | null; - filter: string; ids: string[]; label: string; - lang: string; limit: number; + parentId: string; projectId: string; sectionId: string; }; @@ -18,11 +17,10 @@ type GetTasksArgs = { | Name | Type | | ------ | ------ | | `cursor`? | `string` \| `null` | -| `filter`? | `string` | | `ids`? | `string`[] | | `label`? | `string` | -| `lang`? | `string` | | `limit`? | `number` | +| `parentId`? | `string` | | `projectId`? | `string` | | `sectionId`? | `string` | diff --git a/website/docs/api/type-aliases/GetTasksByFilterArgs.md b/website/docs/api/type-aliases/GetTasksByFilterArgs.md new file mode 100644 index 0000000..68f8f55 --- /dev/null +++ b/website/docs/api/type-aliases/GetTasksByFilterArgs.md @@ -0,0 +1,23 @@ +# GetTasksByFilterArgs + +```ts +type GetTasksByFilterArgs = { + cursor: string | null; + lang: string; + limit: number; + query: string; +}; +``` + +## Type declaration + +| Name | Type | +| ------ | ------ | +| `cursor`? | `string` \| `null` | +| `lang`? | `string` | +| `limit`? | `number` | +| `query` | `string` | + +## See + +http://todoist.com/api/v1/docs#tag/Tasks/operation/get_tasks_by_filter_api_v1_tasks_filter_get diff --git a/website/docs/api/typedoc-sidebar.cjs b/website/docs/api/typedoc-sidebar.cjs index d8d7529..d2a6c1c 100644 --- a/website/docs/api/typedoc-sidebar.cjs +++ b/website/docs/api/typedoc-sidebar.cjs @@ -1,4 +1,4 @@ // @ts-check /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ -const typedocSidebar = { items: [{"type":"category","label":"Classes","items":[{"type":"doc","id":"api/classes/TodoistApi","label":"TodoistApi"},{"type":"doc","id":"api/classes/TodoistRequestError","label":"TodoistRequestError"}]},{"type":"category","label":"Interfaces","items":[{"type":"doc","id":"api/interfaces/Attachment","label":"Attachment"},{"type":"doc","id":"api/interfaces/Color","label":"Color"},{"type":"doc","id":"api/interfaces/Comment","label":"Comment"},{"type":"doc","id":"api/interfaces/Deadline","label":"Deadline"},{"type":"doc","id":"api/interfaces/DueDate","label":"DueDate"},{"type":"doc","id":"api/interfaces/Duration","label":"Duration"},{"type":"doc","id":"api/interfaces/Label","label":"Label"},{"type":"doc","id":"api/interfaces/Project","label":"Project"},{"type":"doc","id":"api/interfaces/Section","label":"Section"},{"type":"doc","id":"api/interfaces/Task","label":"Task"},{"type":"doc","id":"api/interfaces/User","label":"User"}]},{"type":"category","label":"Type Aliases","items":[{"type":"doc","id":"api/type-aliases/AddCommentArgs","label":"AddCommentArgs"},{"type":"doc","id":"api/type-aliases/AddLabelArgs","label":"AddLabelArgs"},{"type":"doc","id":"api/type-aliases/AddProjectArgs","label":"AddProjectArgs"},{"type":"doc","id":"api/type-aliases/AddSectionArgs","label":"AddSectionArgs"},{"type":"doc","id":"api/type-aliases/AddTaskArgs","label":"AddTaskArgs"},{"type":"doc","id":"api/type-aliases/AuthTokenRequestArgs","label":"AuthTokenRequestArgs"},{"type":"doc","id":"api/type-aliases/AuthTokenResponse","label":"AuthTokenResponse"},{"type":"doc","id":"api/type-aliases/GetCommentsResponse","label":"GetCommentsResponse"},{"type":"doc","id":"api/type-aliases/GetLabelsArgs","label":"GetLabelsArgs"},{"type":"doc","id":"api/type-aliases/GetLabelsResponse","label":"GetLabelsResponse"},{"type":"doc","id":"api/type-aliases/GetProjectCollaboratorsArgs","label":"GetProjectCollaboratorsArgs"},{"type":"doc","id":"api/type-aliases/GetProjectCollaboratorsResponse","label":"GetProjectCollaboratorsResponse"},{"type":"doc","id":"api/type-aliases/GetProjectCommentsArgs","label":"GetProjectCommentsArgs"},{"type":"doc","id":"api/type-aliases/GetProjectsArgs","label":"GetProjectsArgs"},{"type":"doc","id":"api/type-aliases/GetProjectsResponse","label":"GetProjectsResponse"},{"type":"doc","id":"api/type-aliases/GetSectionsArgs","label":"GetSectionsArgs"},{"type":"doc","id":"api/type-aliases/GetSectionsResponse","label":"GetSectionsResponse"},{"type":"doc","id":"api/type-aliases/GetSharedLabelsArgs","label":"GetSharedLabelsArgs"},{"type":"doc","id":"api/type-aliases/GetSharedLabelsResponse","label":"GetSharedLabelsResponse"},{"type":"doc","id":"api/type-aliases/GetTaskCommentsArgs","label":"GetTaskCommentsArgs"},{"type":"doc","id":"api/type-aliases/GetTasksArgs","label":"GetTasksArgs"},{"type":"doc","id":"api/type-aliases/GetTasksResponse","label":"GetTasksResponse"},{"type":"doc","id":"api/type-aliases/MoveTaskArgs","label":"MoveTaskArgs"},{"type":"doc","id":"api/type-aliases/Permission","label":"Permission"},{"type":"doc","id":"api/type-aliases/ProjectViewStyle","label":"ProjectViewStyle"},{"type":"doc","id":"api/type-aliases/QuickAddTaskArgs","label":"QuickAddTaskArgs"},{"type":"doc","id":"api/type-aliases/QuickAddTaskResponse","label":"QuickAddTaskResponse"},{"type":"doc","id":"api/type-aliases/RemoveSharedLabelArgs","label":"RemoveSharedLabelArgs"},{"type":"doc","id":"api/type-aliases/RenameSharedLabelArgs","label":"RenameSharedLabelArgs"},{"type":"doc","id":"api/type-aliases/RevokeAuthTokenRequestArgs","label":"RevokeAuthTokenRequestArgs"},{"type":"doc","id":"api/type-aliases/SyncTask","label":"SyncTask"},{"type":"doc","id":"api/type-aliases/TaskWithSanitizedContent","label":"TaskWithSanitizedContent"},{"type":"doc","id":"api/type-aliases/UpdateCommentArgs","label":"UpdateCommentArgs"},{"type":"doc","id":"api/type-aliases/UpdateLabelArgs","label":"UpdateLabelArgs"},{"type":"doc","id":"api/type-aliases/UpdateProjectArgs","label":"UpdateProjectArgs"},{"type":"doc","id":"api/type-aliases/UpdateSectionArgs","label":"UpdateSectionArgs"},{"type":"doc","id":"api/type-aliases/UpdateTaskArgs","label":"UpdateTaskArgs"}]},{"type":"category","label":"Functions","items":[{"type":"doc","id":"api/functions/getAuthorizationUrl","label":"getAuthorizationUrl"},{"type":"doc","id":"api/functions/getAuthStateParameter","label":"getAuthStateParameter"},{"type":"doc","id":"api/functions/getAuthToken","label":"getAuthToken"},{"type":"doc","id":"api/functions/getColorByKey","label":"getColorByKey"},{"type":"doc","id":"api/functions/getSanitizedContent","label":"getSanitizedContent"},{"type":"doc","id":"api/functions/getSanitizedTasks","label":"getSanitizedTasks"},{"type":"doc","id":"api/functions/revokeAuthToken","label":"revokeAuthToken"}]}]}; +const typedocSidebar = { items: [{"type":"category","label":"Classes","items":[{"type":"doc","id":"api/classes/TodoistApi","label":"TodoistApi"},{"type":"doc","id":"api/classes/TodoistRequestError","label":"TodoistRequestError"}]},{"type":"category","label":"Interfaces","items":[{"type":"doc","id":"api/interfaces/Attachment","label":"Attachment"},{"type":"doc","id":"api/interfaces/Color","label":"Color"},{"type":"doc","id":"api/interfaces/Comment","label":"Comment"},{"type":"doc","id":"api/interfaces/Deadline","label":"Deadline"},{"type":"doc","id":"api/interfaces/DueDate","label":"DueDate"},{"type":"doc","id":"api/interfaces/Duration","label":"Duration"},{"type":"doc","id":"api/interfaces/Label","label":"Label"},{"type":"doc","id":"api/interfaces/Project","label":"Project"},{"type":"doc","id":"api/interfaces/RawComment","label":"RawComment"},{"type":"doc","id":"api/interfaces/Section","label":"Section"},{"type":"doc","id":"api/interfaces/Task","label":"Task"},{"type":"doc","id":"api/interfaces/User","label":"User"}]},{"type":"category","label":"Type Aliases","items":[{"type":"doc","id":"api/type-aliases/AddCommentArgs","label":"AddCommentArgs"},{"type":"doc","id":"api/type-aliases/AddLabelArgs","label":"AddLabelArgs"},{"type":"doc","id":"api/type-aliases/AddProjectArgs","label":"AddProjectArgs"},{"type":"doc","id":"api/type-aliases/AddSectionArgs","label":"AddSectionArgs"},{"type":"doc","id":"api/type-aliases/AddTaskArgs","label":"AddTaskArgs"},{"type":"doc","id":"api/type-aliases/AuthTokenRequestArgs","label":"AuthTokenRequestArgs"},{"type":"doc","id":"api/type-aliases/AuthTokenResponse","label":"AuthTokenResponse"},{"type":"doc","id":"api/type-aliases/GetCommentsResponse","label":"GetCommentsResponse"},{"type":"doc","id":"api/type-aliases/GetLabelsArgs","label":"GetLabelsArgs"},{"type":"doc","id":"api/type-aliases/GetLabelsResponse","label":"GetLabelsResponse"},{"type":"doc","id":"api/type-aliases/GetProjectCollaboratorsArgs","label":"GetProjectCollaboratorsArgs"},{"type":"doc","id":"api/type-aliases/GetProjectCollaboratorsResponse","label":"GetProjectCollaboratorsResponse"},{"type":"doc","id":"api/type-aliases/GetProjectCommentsArgs","label":"GetProjectCommentsArgs"},{"type":"doc","id":"api/type-aliases/GetProjectsArgs","label":"GetProjectsArgs"},{"type":"doc","id":"api/type-aliases/GetProjectsResponse","label":"GetProjectsResponse"},{"type":"doc","id":"api/type-aliases/GetSectionsArgs","label":"GetSectionsArgs"},{"type":"doc","id":"api/type-aliases/GetSectionsResponse","label":"GetSectionsResponse"},{"type":"doc","id":"api/type-aliases/GetSharedLabelsArgs","label":"GetSharedLabelsArgs"},{"type":"doc","id":"api/type-aliases/GetSharedLabelsResponse","label":"GetSharedLabelsResponse"},{"type":"doc","id":"api/type-aliases/GetTaskCommentsArgs","label":"GetTaskCommentsArgs"},{"type":"doc","id":"api/type-aliases/GetTasksArgs","label":"GetTasksArgs"},{"type":"doc","id":"api/type-aliases/GetTasksByFilterArgs","label":"GetTasksByFilterArgs"},{"type":"doc","id":"api/type-aliases/GetTasksResponse","label":"GetTasksResponse"},{"type":"doc","id":"api/type-aliases/MoveTaskArgs","label":"MoveTaskArgs"},{"type":"doc","id":"api/type-aliases/Permission","label":"Permission"},{"type":"doc","id":"api/type-aliases/ProjectViewStyle","label":"ProjectViewStyle"},{"type":"doc","id":"api/type-aliases/QuickAddTaskArgs","label":"QuickAddTaskArgs"},{"type":"doc","id":"api/type-aliases/QuickAddTaskResponse","label":"QuickAddTaskResponse"},{"type":"doc","id":"api/type-aliases/RemoveSharedLabelArgs","label":"RemoveSharedLabelArgs"},{"type":"doc","id":"api/type-aliases/RenameSharedLabelArgs","label":"RenameSharedLabelArgs"},{"type":"doc","id":"api/type-aliases/RevokeAuthTokenRequestArgs","label":"RevokeAuthTokenRequestArgs"},{"type":"doc","id":"api/type-aliases/SyncTask","label":"SyncTask"},{"type":"doc","id":"api/type-aliases/TaskWithSanitizedContent","label":"TaskWithSanitizedContent"},{"type":"doc","id":"api/type-aliases/UpdateCommentArgs","label":"UpdateCommentArgs"},{"type":"doc","id":"api/type-aliases/UpdateLabelArgs","label":"UpdateLabelArgs"},{"type":"doc","id":"api/type-aliases/UpdateProjectArgs","label":"UpdateProjectArgs"},{"type":"doc","id":"api/type-aliases/UpdateSectionArgs","label":"UpdateSectionArgs"},{"type":"doc","id":"api/type-aliases/UpdateTaskArgs","label":"UpdateTaskArgs"}]},{"type":"category","label":"Functions","items":[{"type":"doc","id":"api/functions/getAuthorizationUrl","label":"getAuthorizationUrl"},{"type":"doc","id":"api/functions/getAuthStateParameter","label":"getAuthStateParameter"},{"type":"doc","id":"api/functions/getAuthToken","label":"getAuthToken"},{"type":"doc","id":"api/functions/getColorByKey","label":"getColorByKey"},{"type":"doc","id":"api/functions/getSanitizedContent","label":"getSanitizedContent"},{"type":"doc","id":"api/functions/getSanitizedTasks","label":"getSanitizedTasks"},{"type":"doc","id":"api/functions/revokeAuthToken","label":"revokeAuthToken"}]}]}; module.exports = typedocSidebar.items; \ No newline at end of file