@doist/todoist-api-typescript 5.0.2 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { PersonalProject, WorkspaceProject, Label, Section, Comment, Task } from './types/entities';
2
- import { AddCommentArgs, AddLabelArgs, AddProjectArgs, AddSectionArgs, AddTaskArgs, GetProjectCommentsArgs, GetTaskCommentsArgs, GetTasksArgs, GetTasksByFilterArgs, UpdateCommentArgs, UpdateLabelArgs, UpdateProjectArgs, UpdateSectionArgs, UpdateTaskArgs, QuickAddTaskArgs, GetSharedLabelsArgs, RenameSharedLabelArgs, RemoveSharedLabelArgs, GetProjectsArgs, GetProjectCollaboratorsArgs, GetLabelsArgs, GetLabelsResponse, GetTasksResponse, GetProjectsResponse, GetProjectCollaboratorsResponse, GetSectionsArgs, GetSectionsResponse, GetSharedLabelsResponse, GetCommentsResponse, type MoveTaskArgs } from './types/requests';
2
+ import { AddCommentArgs, AddLabelArgs, AddProjectArgs, AddSectionArgs, AddTaskArgs, GetProjectCommentsArgs, GetTaskCommentsArgs, GetTasksArgs, GetTasksByFilterArgs, UpdateCommentArgs, UpdateLabelArgs, UpdateProjectArgs, UpdateSectionArgs, UpdateTaskArgs, QuickAddTaskArgs, GetSharedLabelsArgs, RenameSharedLabelArgs, RemoveSharedLabelArgs, GetProjectsArgs, GetProjectCollaboratorsArgs, GetLabelsArgs, GetLabelsResponse, GetTasksResponse, GetProjectsResponse, GetProjectCollaboratorsResponse, GetSectionsArgs, GetSectionsResponse, GetSharedLabelsResponse, GetCommentsResponse, type MoveTaskArgs, GetCompletedTasksByCompletionDateArgs, GetCompletedTasksByDueDateArgs, GetCompletedTasksResponse } from './types/requests';
3
3
  /**
4
4
  * A client for interacting with the Todoist API v1.
5
5
  * This class provides methods to manage tasks, projects, sections, labels, and comments in Todoist.
@@ -54,6 +54,20 @@ export declare class TodoistApi {
54
54
  * @returns A promise that resolves to a paginated response of tasks.
55
55
  */
56
56
  getTasksByFilter(args: GetTasksByFilterArgs): Promise<GetTasksResponse>;
57
+ /**
58
+ * Retrieves completed tasks by completion date.
59
+ *
60
+ * @param args - Parameters for filtering, including required since, until.
61
+ * @returns A promise that resolves to a paginated response of completed tasks.
62
+ */
63
+ getCompletedTasksByCompletionDate(args: GetCompletedTasksByCompletionDateArgs): Promise<GetCompletedTasksResponse>;
64
+ /**
65
+ * Retrieves completed tasks by due date.
66
+ *
67
+ * @param args - Parameters for filtering, including required since, until.
68
+ * @returns A promise that resolves to a paginated response of completed tasks.
69
+ */
70
+ getCompletedTasksByDueDate(args: GetCompletedTasksByDueDateArgs): Promise<GetCompletedTasksResponse>;
57
71
  /**
58
72
  * Creates a new task with the provided parameters.
59
73
  *
@@ -167,6 +167,50 @@ var TodoistApi = /** @class */ (function () {
167
167
  });
168
168
  });
169
169
  };
170
+ /**
171
+ * Retrieves completed tasks by completion date.
172
+ *
173
+ * @param args - Parameters for filtering, including required since, until.
174
+ * @returns A promise that resolves to a paginated response of completed tasks.
175
+ */
176
+ TodoistApi.prototype.getCompletedTasksByCompletionDate = function (args) {
177
+ return __awaiter(this, void 0, void 0, function () {
178
+ var _a, items, nextCursor;
179
+ return __generator(this, function (_b) {
180
+ switch (_b.label) {
181
+ case 0: return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, endpoints_1.ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE, this.authToken, args)];
182
+ case 1:
183
+ _a = (_b.sent()).data, items = _a.items, nextCursor = _a.nextCursor;
184
+ return [2 /*return*/, {
185
+ items: (0, validators_1.validateTaskArray)(items),
186
+ nextCursor: nextCursor,
187
+ }];
188
+ }
189
+ });
190
+ });
191
+ };
192
+ /**
193
+ * Retrieves completed tasks by due date.
194
+ *
195
+ * @param args - Parameters for filtering, including required since, until.
196
+ * @returns A promise that resolves to a paginated response of completed tasks.
197
+ */
198
+ TodoistApi.prototype.getCompletedTasksByDueDate = function (args) {
199
+ return __awaiter(this, void 0, void 0, function () {
200
+ var _a, items, nextCursor;
201
+ return __generator(this, function (_b) {
202
+ switch (_b.label) {
203
+ case 0: return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, endpoints_1.ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE, this.authToken, args)];
204
+ case 1:
205
+ _a = (_b.sent()).data, items = _a.items, nextCursor = _a.nextCursor;
206
+ return [2 /*return*/, {
207
+ items: (0, validators_1.validateTaskArray)(items),
208
+ nextCursor: nextCursor,
209
+ }];
210
+ }
211
+ });
212
+ });
213
+ };
170
214
  /**
171
215
  * Creates a new task with the provided parameters.
172
216
  *
@@ -5,6 +5,8 @@ export declare function getSyncBaseUri(domainBase?: string): string;
5
5
  export declare function getAuthBaseUri(domainBase?: string): string;
6
6
  export declare const ENDPOINT_REST_TASKS = "tasks";
7
7
  export declare const ENDPOINT_REST_TASKS_FILTER: string;
8
+ export declare const ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE: string;
9
+ export declare const ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE: string;
8
10
  export declare const ENDPOINT_REST_PROJECTS = "projects";
9
11
  export declare const ENDPOINT_REST_SECTIONS = "sections";
10
12
  export declare const ENDPOINT_REST_LABELS = "labels";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ENDPOINT_REVOKE_TOKEN = exports.ENDPOINT_GET_TOKEN = exports.ENDPOINT_AUTHORIZATION = exports.ENDPOINT_SYNC = exports.ENDPOINT_SYNC_QUICK_ADD = exports.ENDPOINT_REST_PROJECT_COLLABORATORS = exports.ENDPOINT_REST_TASK_REOPEN = exports.ENDPOINT_REST_TASK_CLOSE = exports.ENDPOINT_REST_COMMENTS = exports.ENDPOINT_REST_LABELS_SHARED_REMOVE = exports.ENDPOINT_REST_LABELS_SHARED_RENAME = exports.ENDPOINT_REST_LABELS_SHARED = exports.ENDPOINT_REST_LABELS = exports.ENDPOINT_REST_SECTIONS = exports.ENDPOINT_REST_PROJECTS = exports.ENDPOINT_REST_TASKS_FILTER = exports.ENDPOINT_REST_TASKS = exports.getAuthBaseUri = exports.getSyncBaseUri = exports.API_BASE_URI = exports.API_VERSION = exports.TODOIST_WEB_URI = void 0;
3
+ exports.ENDPOINT_REVOKE_TOKEN = exports.ENDPOINT_GET_TOKEN = exports.ENDPOINT_AUTHORIZATION = exports.ENDPOINT_SYNC = exports.ENDPOINT_SYNC_QUICK_ADD = exports.ENDPOINT_REST_PROJECT_COLLABORATORS = exports.ENDPOINT_REST_TASK_REOPEN = exports.ENDPOINT_REST_TASK_CLOSE = exports.ENDPOINT_REST_COMMENTS = exports.ENDPOINT_REST_LABELS_SHARED_REMOVE = exports.ENDPOINT_REST_LABELS_SHARED_RENAME = exports.ENDPOINT_REST_LABELS_SHARED = exports.ENDPOINT_REST_LABELS = exports.ENDPOINT_REST_SECTIONS = exports.ENDPOINT_REST_PROJECTS = exports.ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE = exports.ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE = exports.ENDPOINT_REST_TASKS_FILTER = exports.ENDPOINT_REST_TASKS = exports.getAuthBaseUri = exports.getSyncBaseUri = exports.API_BASE_URI = exports.API_VERSION = exports.TODOIST_WEB_URI = void 0;
4
4
  var BASE_URI = 'https://api.todoist.com';
5
5
  var TODOIST_URI = 'https://todoist.com';
6
6
  exports.TODOIST_WEB_URI = 'https://app.todoist.com/app';
@@ -21,6 +21,8 @@ function getAuthBaseUri(domainBase) {
21
21
  exports.getAuthBaseUri = getAuthBaseUri;
22
22
  exports.ENDPOINT_REST_TASKS = 'tasks';
23
23
  exports.ENDPOINT_REST_TASKS_FILTER = exports.ENDPOINT_REST_TASKS + '/filter';
24
+ exports.ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE = exports.ENDPOINT_REST_TASKS + '/completed/by_completion_date';
25
+ exports.ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE = exports.ENDPOINT_REST_TASKS + '/completed/by_due_date';
24
26
  exports.ENDPOINT_REST_PROJECTS = 'projects';
25
27
  exports.ENDPOINT_REST_SECTIONS = 'sections';
26
28
  exports.ENDPOINT_REST_LABELS = 'labels';
@@ -58,6 +58,7 @@ var errors_1 = require("./types/errors");
58
58
  var uuid_1 = require("uuid");
59
59
  var axios_retry_1 = __importDefault(require("axios-retry"));
60
60
  var endpoints_1 = require("./consts/endpoints");
61
+ var processing_helpers_1 = require("./utils/processing-helpers");
61
62
  function paramsSerializer(params) {
62
63
  var qs = new URLSearchParams();
63
64
  Object.keys(params).forEach(function (key) {
@@ -106,7 +107,11 @@ function getRequestConfiguration(baseURL, apiToken, requestId) {
106
107
  }
107
108
  function getAxiosClient(baseURL, apiToken, requestId) {
108
109
  var configuration = getRequestConfiguration(baseURL, apiToken, requestId);
109
- var client = (0, axios_case_converter_1.default)(axios_1.default.create(configuration));
110
+ var client = (0, axios_case_converter_1.default)(axios_1.default.create(configuration), {
111
+ caseFunctions: {
112
+ camel: processing_helpers_1.customCamelCase,
113
+ },
114
+ });
110
115
  (0, axios_retry_1.default)(client, {
111
116
  retries: 3,
112
117
  retryCondition: isNetworkError,
@@ -48,6 +48,39 @@ export type GetTasksByFilterArgs = {
48
48
  cursor?: string | null;
49
49
  limit?: number;
50
50
  };
51
+ /**
52
+ * Arguments for retrieving completed tasks by completion date.
53
+ * @see https://todoist.com/api/v1/docs#tag/Tasks/operation/tasks_completed_by_completion_date_api_v1_tasks_completed_by_completion_date_get
54
+ */
55
+ export type GetCompletedTasksByCompletionDateArgs = {
56
+ since: string;
57
+ until: string;
58
+ workspaceId?: string | null;
59
+ projectId?: string | null;
60
+ sectionId?: string | null;
61
+ parentId?: string | null;
62
+ filterQuery?: string | null;
63
+ filterLang?: string | null;
64
+ cursor?: string | null;
65
+ limit?: number;
66
+ publicKey?: string | null;
67
+ };
68
+ /**
69
+ * Arguments for retrieving completed tasks by due date.
70
+ * @see https://todoist.com/api/v1/docs#tag/Tasks/operation/tasks_completed_by_due_date_api_v1_tasks_completed_by_due_date_get
71
+ */
72
+ export type GetCompletedTasksByDueDateArgs = {
73
+ since: string;
74
+ until: string;
75
+ workspaceId?: string | null;
76
+ projectId?: string | null;
77
+ sectionId?: string | null;
78
+ parentId?: string | null;
79
+ filterQuery?: string | null;
80
+ filterLang?: string | null;
81
+ cursor?: string | null;
82
+ limit?: number;
83
+ };
51
84
  /**
52
85
  * @see https://todoist.com/api/v1/docs#tag/Tasks/operation/get_tasks_api_v1_tasks_get
53
86
  */
@@ -55,6 +88,14 @@ export type GetTasksResponse = {
55
88
  results: Task[];
56
89
  nextCursor: string | null;
57
90
  };
91
+ /**
92
+ * @see https://todoist.com/api/v1/docs#tag/Tasks/operation/tasks_completed_by_due_date_api_v1_tasks_completed_by_due_date_get
93
+ * @see https://todoist.com/api/v1/docs#tag/Tasks/operation/tasks_completed_by_completion_date_api_v1_tasks_completed_by_completion_date_get
94
+ */
95
+ export type GetCompletedTasksResponse = {
96
+ items: Task[];
97
+ nextCursor: string | null;
98
+ };
58
99
  /**
59
100
  * Arguments for updating a task.
60
101
  * @see https://todoist.com/api/v1/docs#tag/Tasks/operation/update_task_api_v1_tasks__task_id__post
@@ -0,0 +1 @@
1
+ export declare function customCamelCase(input: string): string;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.customCamelCase = void 0;
7
+ var camelcase_1 = __importDefault(require("camelcase"));
8
+ var emoji_regex_1 = __importDefault(require("emoji-regex"));
9
+ function isEmojiKey(key) {
10
+ var regex = (0, emoji_regex_1.default)();
11
+ return regex.test(key);
12
+ }
13
+ function customCamelCase(input) {
14
+ // If the value is a solitary emoji string, return the key as-is
15
+ if (isEmojiKey(input))
16
+ return input;
17
+ return (0, camelcase_1.default)(input);
18
+ }
19
+ exports.customCamelCase = customCamelCase;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/todoist-api-typescript",
3
- "version": "5.0.2",
3
+ "version": "5.1.1",
4
4
  "description": "A typescript wrapper for the Todoist REST API.",
5
5
  "author": "Doist developers",
6
6
  "repository": "git@github.com:doist/todoist-api-typescript.git",
@@ -27,6 +27,8 @@
27
27
  "axios": "^1.0.0",
28
28
  "axios-case-converter": "^1.0.0",
29
29
  "axios-retry": "^3.1.9",
30
+ "camelcase": "6.3.0",
31
+ "emoji-regex": "10.4.0",
30
32
  "ts-custom-error": "^3.2.0",
31
33
  "uuid": "^9.0.0",
32
34
  "zod": "^3.24.1"