@doist/todoist-api-typescript 5.3.0 → 5.4.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,4 +1,4 @@
1
- import { PersonalProject, WorkspaceProject, Label, Section, Comment, Task } from './types/entities';
1
+ import { PersonalProject, WorkspaceProject, Label, Section, Comment, Task, CurrentUser } from './types/entities';
2
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.
@@ -33,6 +33,12 @@ export declare class TodoistApi {
33
33
  * Optional custom API base URL. If not provided, defaults to Todoist's standard API endpoint
34
34
  */
35
35
  baseUrl?: string);
36
+ /**
37
+ * Retrieves information about the authenticated user.
38
+ *
39
+ * @returns A promise that resolves to the current user's information.
40
+ */
41
+ getUser(): Promise<CurrentUser>;
36
42
  /**
37
43
  * Retrieves a single active (non-completed) task by its ID.
38
44
  *
@@ -101,6 +101,24 @@ var TodoistApi = /** @class */ (function () {
101
101
  this.authToken = authToken;
102
102
  this.syncApiBase = (0, endpoints_1.getSyncBaseUri)(baseUrl);
103
103
  }
104
+ /**
105
+ * Retrieves information about the authenticated user.
106
+ *
107
+ * @returns A promise that resolves to the current user's information.
108
+ */
109
+ TodoistApi.prototype.getUser = function () {
110
+ return __awaiter(this, void 0, void 0, function () {
111
+ var response;
112
+ return __generator(this, function (_a) {
113
+ switch (_a.label) {
114
+ case 0: return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, endpoints_1.ENDPOINT_REST_USER, this.authToken)];
115
+ case 1:
116
+ response = _a.sent();
117
+ return [2 /*return*/, (0, validators_1.validateCurrentUser)(response.data)];
118
+ }
119
+ });
120
+ });
121
+ };
104
122
  /**
105
123
  * Retrieves a single active (non-completed) task by its ID.
106
124
  *
@@ -18,6 +18,7 @@ export declare const ENDPOINT_REST_TASK_REOPEN = "reopen";
18
18
  export declare const ENDPOINT_REST_PROJECTS = "projects";
19
19
  export declare const ENDPOINT_REST_PROJECTS_ARCHIVED: string;
20
20
  export declare const ENDPOINT_REST_PROJECT_COLLABORATORS = "collaborators";
21
+ export declare const ENDPOINT_REST_USER = "user";
21
22
  export declare const PROJECT_ARCHIVE = "archive";
22
23
  export declare const PROJECT_UNARCHIVE = "unarchive";
23
24
  export declare const ENDPOINT_SYNC_QUICK_ADD: string;
@@ -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_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;
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_USER = 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';
@@ -34,6 +34,7 @@ exports.ENDPOINT_REST_TASK_REOPEN = 'reopen';
34
34
  exports.ENDPOINT_REST_PROJECTS = 'projects';
35
35
  exports.ENDPOINT_REST_PROJECTS_ARCHIVED = exports.ENDPOINT_REST_PROJECTS + '/archived';
36
36
  exports.ENDPOINT_REST_PROJECT_COLLABORATORS = 'collaborators';
37
+ exports.ENDPOINT_REST_USER = 'user';
37
38
  exports.PROJECT_ARCHIVE = 'archive';
38
39
  exports.PROJECT_UNARCHIVE = 'unarchive';
39
40
  exports.ENDPOINT_SYNC_QUICK_ADD = exports.ENDPOINT_REST_TASKS + '/quick';
@@ -528,10 +528,55 @@ export declare const UserSchema: z.ZodObject<{
528
528
  email: z.ZodString;
529
529
  }, z.core.$strip>;
530
530
  /**
531
- * Represents a user in Todoist.
531
+ * Represents a user in Todoist (simplified for collaborators).
532
532
  * @see https://todoist.com/api/v1/docs#tag/User
533
533
  */
534
534
  export type User = z.infer<typeof UserSchema>;
535
+ export declare const TimezoneInfoSchema: z.ZodObject<{
536
+ gmtString: z.ZodString;
537
+ hours: z.ZodNumber;
538
+ isDst: z.ZodNumber;
539
+ minutes: z.ZodNumber;
540
+ timezone: z.ZodString;
541
+ }, z.core.$strip>;
542
+ export declare const CurrentUserSchema: z.ZodObject<{
543
+ id: z.ZodString;
544
+ email: z.ZodString;
545
+ fullName: z.ZodString;
546
+ avatarBig: z.ZodNullable<z.ZodString>;
547
+ avatarMedium: z.ZodNullable<z.ZodString>;
548
+ avatarS640: z.ZodNullable<z.ZodString>;
549
+ avatarSmall: z.ZodNullable<z.ZodString>;
550
+ businessAccountId: z.ZodNullable<z.ZodString>;
551
+ isPremium: z.ZodBoolean;
552
+ dateFormat: z.ZodNumber;
553
+ timeFormat: z.ZodNumber;
554
+ weeklyGoal: z.ZodNumber;
555
+ dailyGoal: z.ZodNumber;
556
+ completedCount: z.ZodNumber;
557
+ completedToday: z.ZodNumber;
558
+ karma: z.ZodNumber;
559
+ karmaTrend: z.ZodString;
560
+ lang: z.ZodString;
561
+ nextWeek: z.ZodNumber;
562
+ startDay: z.ZodNumber;
563
+ startPage: z.ZodString;
564
+ tzInfo: z.ZodObject<{
565
+ gmtString: z.ZodString;
566
+ hours: z.ZodNumber;
567
+ isDst: z.ZodNumber;
568
+ minutes: z.ZodNumber;
569
+ timezone: z.ZodString;
570
+ }, z.core.$strip>;
571
+ inboxProjectId: z.ZodString;
572
+ daysOff: z.ZodArray<z.ZodNumber>;
573
+ weekendStartDay: z.ZodNumber;
574
+ }, z.core.$strip>;
575
+ /**
576
+ * Represents the current authenticated user with detailed information.
577
+ * @see https://todoist.com/api/v1/docs#tag/User
578
+ */
579
+ export type CurrentUser = z.infer<typeof CurrentUserSchema>;
535
580
  export declare const ColorSchema: z.ZodObject<{
536
581
  id: z.ZodNumber;
537
582
  key: z.ZodString;
@@ -22,7 +22,7 @@ var __rest = (this && this.__rest) || function (s, e) {
22
22
  return t;
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.ColorSchema = exports.UserSchema = exports.CommentSchema = exports.RawCommentSchema = exports.AttachmentSchema = exports.LabelSchema = exports.SectionSchema = exports.WorkspaceProjectSchema = exports.PersonalProjectSchema = exports.BaseProjectSchema = exports.TaskSchema = exports.DeadlineSchema = exports.DurationSchema = exports.DueDateSchema = void 0;
25
+ exports.ColorSchema = exports.CurrentUserSchema = exports.TimezoneInfoSchema = exports.UserSchema = exports.CommentSchema = exports.RawCommentSchema = exports.AttachmentSchema = exports.LabelSchema = exports.SectionSchema = exports.WorkspaceProjectSchema = exports.PersonalProjectSchema = exports.BaseProjectSchema = exports.TaskSchema = exports.DeadlineSchema = exports.DurationSchema = exports.DueDateSchema = void 0;
26
26
  var zod_1 = require("zod");
27
27
  var urlHelpers_1 = require("../utils/urlHelpers");
28
28
  exports.DueDateSchema = zod_1.z
@@ -191,6 +191,40 @@ exports.UserSchema = zod_1.z.object({
191
191
  name: zod_1.z.string(),
192
192
  email: zod_1.z.string(),
193
193
  });
194
+ exports.TimezoneInfoSchema = zod_1.z.object({
195
+ gmtString: zod_1.z.string(),
196
+ hours: zod_1.z.number().int(),
197
+ isDst: zod_1.z.number().int(),
198
+ minutes: zod_1.z.number().int(),
199
+ timezone: zod_1.z.string(),
200
+ });
201
+ exports.CurrentUserSchema = zod_1.z.object({
202
+ id: zod_1.z.string(),
203
+ email: zod_1.z.string(),
204
+ fullName: zod_1.z.string(),
205
+ avatarBig: zod_1.z.string().nullable(),
206
+ avatarMedium: zod_1.z.string().nullable(),
207
+ avatarS640: zod_1.z.string().nullable(),
208
+ avatarSmall: zod_1.z.string().nullable(),
209
+ businessAccountId: zod_1.z.string().nullable(),
210
+ isPremium: zod_1.z.boolean(),
211
+ dateFormat: zod_1.z.number().int(),
212
+ timeFormat: zod_1.z.number().int(),
213
+ weeklyGoal: zod_1.z.number().int(),
214
+ dailyGoal: zod_1.z.number().int(),
215
+ completedCount: zod_1.z.number().int(),
216
+ completedToday: zod_1.z.number().int(),
217
+ karma: zod_1.z.number(),
218
+ karmaTrend: zod_1.z.string(),
219
+ lang: zod_1.z.string(),
220
+ nextWeek: zod_1.z.number().int(),
221
+ startDay: zod_1.z.number().int(),
222
+ startPage: zod_1.z.string(),
223
+ tzInfo: exports.TimezoneInfoSchema,
224
+ inboxProjectId: zod_1.z.string(),
225
+ daysOff: zod_1.z.array(zod_1.z.number().int()),
226
+ weekendStartDay: zod_1.z.number().int(),
227
+ });
194
228
  exports.ColorSchema = zod_1.z.object({
195
229
  /** @deprecated No longer used */
196
230
  id: zod_1.z.number(),
@@ -1,4 +1,4 @@
1
- import { type Task, type Section, type Label, type Comment, type User, type WorkspaceProject, type PersonalProject } from '../types/entities';
1
+ import { type Task, type Section, type Label, type Comment, type User, type CurrentUser, type WorkspaceProject, type PersonalProject } from '../types/entities';
2
2
  export declare function validateTask(input: unknown): Task;
3
3
  export declare function validateTaskArray(input: unknown[]): Task[];
4
4
  /**
@@ -28,3 +28,4 @@ export declare function validateComment(input: unknown): Comment;
28
28
  export declare function validateCommentArray(input: unknown[]): Comment[];
29
29
  export declare function validateUser(input: unknown): User;
30
30
  export declare function validateUserArray(input: unknown[]): User[];
31
+ export declare function validateCurrentUser(input: unknown): CurrentUser;
@@ -14,6 +14,7 @@ exports.validateComment = validateComment;
14
14
  exports.validateCommentArray = validateCommentArray;
15
15
  exports.validateUser = validateUser;
16
16
  exports.validateUserArray = validateUserArray;
17
+ exports.validateCurrentUser = validateCurrentUser;
17
18
  var entities_1 = require("../types/entities");
18
19
  function validateTask(input) {
19
20
  return entities_1.TaskSchema.parse(input);
@@ -75,3 +76,6 @@ function validateUser(input) {
75
76
  function validateUserArray(input) {
76
77
  return input.map(validateUser);
77
78
  }
79
+ function validateCurrentUser(input) {
80
+ return entities_1.CurrentUserSchema.parse(input);
81
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/todoist-api-typescript",
3
- "version": "5.3.0",
3
+ "version": "5.4.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",
@@ -15,7 +15,7 @@
15
15
  "format-fix": "npx prettier --write \"./**/*.{ts,tsx,json,md,yml,babelrc,html}\"",
16
16
  "lint": "eslint ./src --ext ts,tsx --fix",
17
17
  "lint-check": "eslint ./src --ext ts,tsx",
18
- "ts-compile-check": "npx tsc -p tsconfig.json",
18
+ "ts-compile-check": "npx tsc -p tsconfig.typecheck.json",
19
19
  "audit": "npm audit --audit-level=moderate",
20
20
  "test": "jest",
21
21
  "build": "npx tsc -p tsconfig.json",