@doist/todoist-api-typescript 5.2.0 → 5.3.0

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, GetCompletedTasksByCompletionDateArgs, GetCompletedTasksByDueDateArgs, GetCompletedTasksResponse } 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, GetArchivedProjectsArgs, GetArchivedProjectsResponse } 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.
@@ -139,6 +139,13 @@ export declare class TodoistApi {
139
139
  * @returns A promise that resolves to an array of projects.
140
140
  */
141
141
  getProjects(args?: GetProjectsArgs): Promise<GetProjectsResponse>;
142
+ /**
143
+ * Retrieves all archived projects with optional filters.
144
+ *
145
+ * @param args - Optional filters for retrieving archived projects.
146
+ * @returns A promise that resolves to an array of archived projects.
147
+ */
148
+ getArchivedProjects(args?: GetArchivedProjectsArgs): Promise<GetArchivedProjectsResponse>;
142
149
  /**
143
150
  * Creates a new project with the provided parameters.
144
151
  *
@@ -434,6 +434,29 @@ var TodoistApi = /** @class */ (function () {
434
434
  });
435
435
  });
436
436
  };
437
+ /**
438
+ * Retrieves all archived projects with optional filters.
439
+ *
440
+ * @param args - Optional filters for retrieving archived projects.
441
+ * @returns A promise that resolves to an array of archived projects.
442
+ */
443
+ TodoistApi.prototype.getArchivedProjects = function () {
444
+ return __awaiter(this, arguments, void 0, function (args) {
445
+ var _a, results, nextCursor;
446
+ if (args === void 0) { args = {}; }
447
+ return __generator(this, function (_b) {
448
+ switch (_b.label) {
449
+ case 0: return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, endpoints_1.ENDPOINT_REST_PROJECTS_ARCHIVED, this.authToken, args)];
450
+ case 1:
451
+ _a = (_b.sent()).data, results = _a.results, nextCursor = _a.nextCursor;
452
+ return [2 /*return*/, {
453
+ results: (0, validators_1.validateProjectArray)(results),
454
+ nextCursor: nextCursor,
455
+ }];
456
+ }
457
+ });
458
+ });
459
+ };
437
460
  /**
438
461
  * Creates a new project with the provided parameters.
439
462
  *
@@ -7,7 +7,6 @@ export declare const ENDPOINT_REST_TASKS = "tasks";
7
7
  export declare const ENDPOINT_REST_TASKS_FILTER: string;
8
8
  export declare const ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE: string;
9
9
  export declare const ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE: string;
10
- export declare const ENDPOINT_REST_PROJECTS = "projects";
11
10
  export declare const ENDPOINT_REST_SECTIONS = "sections";
12
11
  export declare const ENDPOINT_REST_LABELS = "labels";
13
12
  export declare const ENDPOINT_REST_LABELS_SHARED: string;
@@ -16,6 +15,8 @@ export declare const ENDPOINT_REST_LABELS_SHARED_REMOVE: string;
16
15
  export declare const ENDPOINT_REST_COMMENTS = "comments";
17
16
  export declare const ENDPOINT_REST_TASK_CLOSE = "close";
18
17
  export declare const ENDPOINT_REST_TASK_REOPEN = "reopen";
18
+ export declare const ENDPOINT_REST_PROJECTS = "projects";
19
+ export declare const ENDPOINT_REST_PROJECTS_ARCHIVED: string;
19
20
  export declare const ENDPOINT_REST_PROJECT_COLLABORATORS = "collaborators";
20
21
  export declare const PROJECT_ARCHIVE = "archive";
21
22
  export declare const PROJECT_UNARCHIVE = "unarchive";
@@ -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.PROJECT_UNARCHIVE = exports.PROJECT_ARCHIVE = 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.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.PROJECT_UNARCHIVE = exports.PROJECT_ARCHIVE = exports.ENDPOINT_REST_PROJECT_COLLABORATORS = exports.ENDPOINT_REST_PROJECTS_ARCHIVED = exports.ENDPOINT_REST_PROJECTS = 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_TASKS_COMPLETED_BY_DUE_DATE = exports.ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE = exports.ENDPOINT_REST_TASKS_FILTER = exports.ENDPOINT_REST_TASKS = exports.API_BASE_URI = exports.API_VERSION = exports.TODOIST_WEB_URI = void 0;
4
4
  exports.getSyncBaseUri = getSyncBaseUri;
5
5
  exports.getAuthBaseUri = getAuthBaseUri;
6
6
  var BASE_URI = 'https://api.todoist.com';
@@ -23,7 +23,6 @@ exports.ENDPOINT_REST_TASKS = 'tasks';
23
23
  exports.ENDPOINT_REST_TASKS_FILTER = exports.ENDPOINT_REST_TASKS + '/filter';
24
24
  exports.ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE = exports.ENDPOINT_REST_TASKS + '/completed/by_completion_date';
25
25
  exports.ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE = exports.ENDPOINT_REST_TASKS + '/completed/by_due_date';
26
- exports.ENDPOINT_REST_PROJECTS = 'projects';
27
26
  exports.ENDPOINT_REST_SECTIONS = 'sections';
28
27
  exports.ENDPOINT_REST_LABELS = 'labels';
29
28
  exports.ENDPOINT_REST_LABELS_SHARED = exports.ENDPOINT_REST_LABELS + '/shared';
@@ -32,6 +31,8 @@ exports.ENDPOINT_REST_LABELS_SHARED_REMOVE = exports.ENDPOINT_REST_LABELS_SHARED
32
31
  exports.ENDPOINT_REST_COMMENTS = 'comments';
33
32
  exports.ENDPOINT_REST_TASK_CLOSE = 'close';
34
33
  exports.ENDPOINT_REST_TASK_REOPEN = 'reopen';
34
+ exports.ENDPOINT_REST_PROJECTS = 'projects';
35
+ exports.ENDPOINT_REST_PROJECTS_ARCHIVED = exports.ENDPOINT_REST_PROJECTS + '/archived';
35
36
  exports.ENDPOINT_REST_PROJECT_COLLABORATORS = 'collaborators';
36
37
  exports.PROJECT_ARCHIVE = 'archive';
37
38
  exports.PROJECT_UNARCHIVE = 'unarchive';
@@ -80,6 +80,7 @@ export declare const PROJECT_WITH_OPTIONALS_AS_NULL: PersonalProject;
80
80
  export declare const DEFAULT_SECTION: Section;
81
81
  export declare const INVALID_SECTION: {
82
82
  projectId: undefined;
83
+ url: string;
83
84
  id: string;
84
85
  userId: string;
85
86
  addedAt: string;
@@ -46,6 +46,7 @@ var DEFAULT_IS_COLLAPSED = false;
46
46
  // URL constants using the helper functions
47
47
  var DEFAULT_TASK_URL = (0, urlHelpers_1.getTaskUrl)(exports.DEFAULT_TASK_ID, exports.DEFAULT_TASK_CONTENT);
48
48
  var DEFAULT_PROJECT_URL = (0, urlHelpers_1.getProjectUrl)(exports.DEFAULT_PROJECT_ID, exports.DEFAULT_PROJECT_NAME);
49
+ var DEFAULT_SECTION_URL = (0, urlHelpers_1.getSectionUrl)(DEFAULT_SECTION_ID, DEFAULT_SECTION_NAME);
49
50
  exports.DEFAULT_AUTH_TOKEN = 'AToken';
50
51
  exports.DEFAULT_REQUEST_ID = 'ARequestID';
51
52
  exports.INVALID_ENTITY_ID = 1234;
@@ -154,6 +155,7 @@ exports.DEFAULT_SECTION = {
154
155
  isArchived: false,
155
156
  isDeleted: false,
156
157
  isCollapsed: false,
158
+ url: DEFAULT_SECTION_URL,
157
159
  };
158
160
  exports.INVALID_SECTION = __assign(__assign({}, exports.DEFAULT_SECTION), { projectId: undefined });
159
161
  exports.DEFAULT_LABEL = {
@@ -199,7 +199,7 @@ export declare const PersonalProjectSchema: z.ZodPipe<z.ZodObject<{
199
199
  isCollapsed: z.ZodBoolean;
200
200
  isShared: z.ZodBoolean;
201
201
  parentId: z.ZodNullable<z.ZodString>;
202
- inboxProject: z.ZodBoolean;
202
+ inboxProject: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
203
203
  }, z.core.$strip>, z.ZodTransform<{
204
204
  url: string;
205
205
  id: string;
@@ -331,7 +331,7 @@ export type WorkspaceProject = z.infer<typeof WorkspaceProjectSchema>;
331
331
  * @see https://todoist.com/api/v1/docs#tag/Projects
332
332
  */
333
333
  export type ProjectViewStyle = 'list' | 'board' | 'calendar';
334
- export declare const SectionSchema: z.ZodObject<{
334
+ export declare const SectionSchema: z.ZodPipe<z.ZodObject<{
335
335
  id: z.ZodString;
336
336
  userId: z.ZodString;
337
337
  projectId: z.ZodString;
@@ -343,7 +343,32 @@ export declare const SectionSchema: z.ZodObject<{
343
343
  isArchived: z.ZodBoolean;
344
344
  isDeleted: z.ZodBoolean;
345
345
  isCollapsed: z.ZodBoolean;
346
- }, z.core.$strip>;
346
+ }, z.core.$strip>, z.ZodTransform<{
347
+ url: string;
348
+ id: string;
349
+ userId: string;
350
+ projectId: string;
351
+ addedAt: string;
352
+ updatedAt: string;
353
+ archivedAt: string | null;
354
+ name: string;
355
+ sectionOrder: number;
356
+ isArchived: boolean;
357
+ isDeleted: boolean;
358
+ isCollapsed: boolean;
359
+ }, {
360
+ id: string;
361
+ userId: string;
362
+ projectId: string;
363
+ addedAt: string;
364
+ updatedAt: string;
365
+ archivedAt: string | null;
366
+ name: string;
367
+ sectionOrder: number;
368
+ isArchived: boolean;
369
+ isDeleted: boolean;
370
+ isCollapsed: boolean;
371
+ }>>;
347
372
  /**
348
373
  * Represents a section in a Todoist project.
349
374
  * @see https://todoist.com/api/v1/docs#tag/Sections
@@ -101,7 +101,7 @@ exports.BaseProjectSchema = zod_1.z.object({
101
101
  */
102
102
  exports.PersonalProjectSchema = exports.BaseProjectSchema.extend({
103
103
  parentId: zod_1.z.string().nullable(),
104
- inboxProject: zod_1.z.boolean(),
104
+ inboxProject: zod_1.z.boolean().optional().default(false),
105
105
  }).transform(function (data) {
106
106
  return __assign(__assign({}, data), { url: (0, urlHelpers_1.getProjectUrl)(data.id, data.name) });
107
107
  });
@@ -119,7 +119,8 @@ exports.WorkspaceProjectSchema = exports.BaseProjectSchema.extend({
119
119
  }).transform(function (data) {
120
120
  return __assign(__assign({}, data), { url: (0, urlHelpers_1.getProjectUrl)(data.id, data.name) });
121
121
  });
122
- exports.SectionSchema = zod_1.z.object({
122
+ exports.SectionSchema = zod_1.z
123
+ .object({
123
124
  id: zod_1.z.string(),
124
125
  userId: zod_1.z.string(),
125
126
  projectId: zod_1.z.string(),
@@ -131,6 +132,9 @@ exports.SectionSchema = zod_1.z.object({
131
132
  isArchived: zod_1.z.boolean(),
132
133
  isDeleted: zod_1.z.boolean(),
133
134
  isCollapsed: zod_1.z.boolean(),
135
+ })
136
+ .transform(function (data) {
137
+ return __assign(__assign({}, data), { url: (0, urlHelpers_1.getSectionUrl)(data.id, data.name) });
134
138
  });
135
139
  exports.LabelSchema = zod_1.z.object({
136
140
  id: zod_1.z.string(),
@@ -157,6 +157,22 @@ export type GetProjectsResponse = {
157
157
  results: (PersonalProject | WorkspaceProject)[];
158
158
  nextCursor: string | null;
159
159
  };
160
+ /**
161
+ * Arguments for retrieving archived projects.
162
+ * @see https://todoist.com/api/v1/docs#tag/Projects/operation/get_archived_projects_api_v1_projects_archived_get
163
+ */
164
+ export type GetArchivedProjectsArgs = {
165
+ cursor?: string | null;
166
+ limit?: number;
167
+ };
168
+ /**
169
+ * Response from retrieving archived projects.
170
+ * @see https://todoist.com/api/v1/docs#tag/Projects/operation/get_archived_projects_api_v1_projects_archived_get
171
+ */
172
+ export type GetArchivedProjectsResponse = {
173
+ results: (PersonalProject | WorkspaceProject)[];
174
+ nextCursor: string | null;
175
+ };
160
176
  /**
161
177
  * Arguments for creating a new project.
162
178
  * @see https://todoist.com/api/v1/docs#tag/Projects/operation/create_project_api_v1_projects_post
@@ -14,3 +14,11 @@ export declare function getTaskUrl(taskId: string, content?: string): string;
14
14
  * @returns The URL string for the project view.
15
15
  */
16
16
  export declare function getProjectUrl(projectId: string, name?: string): string;
17
+ /**
18
+ * Generate the URL for a given section.
19
+ *
20
+ * @param sectionId The ID of the section.
21
+ * @param name The name of the section.
22
+ * @returns The URL string for the section view.
23
+ */
24
+ export declare function getSectionUrl(sectionId: string, name?: string): string;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getTaskUrl = getTaskUrl;
4
4
  exports.getProjectUrl = getProjectUrl;
5
+ exports.getSectionUrl = getSectionUrl;
5
6
  var endpoints_1 = require("../consts/endpoints");
6
7
  /**
7
8
  * Generate the URL for a given task.
@@ -27,6 +28,18 @@ function getProjectUrl(projectId, name) {
27
28
  var path = slug ? "".concat(slug, "-").concat(projectId) : projectId;
28
29
  return "".concat(endpoints_1.TODOIST_WEB_URI, "/project/").concat(path);
29
30
  }
31
+ /**
32
+ * Generate the URL for a given section.
33
+ *
34
+ * @param sectionId The ID of the section.
35
+ * @param name The name of the section.
36
+ * @returns The URL string for the section view.
37
+ */
38
+ function getSectionUrl(sectionId, name) {
39
+ var slug = name ? slugify(name) : undefined;
40
+ var path = slug ? "".concat(slug, "-").concat(sectionId) : sectionId;
41
+ return "".concat(endpoints_1.TODOIST_WEB_URI, "/section/").concat(path);
42
+ }
30
43
  /**
31
44
  * Slugify function borrowed from Django.
32
45
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/todoist-api-typescript",
3
- "version": "5.2.0",
3
+ "version": "5.3.0",
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",