@doist/todoist-api-typescript 5.4.0 → 5.5.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, CurrentUser } from './types/entities';
1
+ import { PersonalProject, WorkspaceProject, Label, Section, Comment, Task, CurrentUser, ProductivityStats } 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.
@@ -339,4 +339,10 @@ export declare class TodoistApi {
339
339
  * @returns A promise that resolves to `true` if successful.
340
340
  */
341
341
  deleteComment(id: string, requestId?: string): Promise<boolean>;
342
+ /**
343
+ * Retrieves productivity stats for the authenticated user.
344
+ *
345
+ * @returns A promise that resolves to the productivity stats.
346
+ */
347
+ getProductivityStats(): Promise<ProductivityStats>;
342
348
  }
@@ -992,6 +992,24 @@ var TodoistApi = /** @class */ (function () {
992
992
  });
993
993
  });
994
994
  };
995
+ /**
996
+ * Retrieves productivity stats for the authenticated user.
997
+ *
998
+ * @returns A promise that resolves to the productivity stats.
999
+ */
1000
+ TodoistApi.prototype.getProductivityStats = function () {
1001
+ return __awaiter(this, void 0, void 0, function () {
1002
+ var response;
1003
+ return __generator(this, function (_a) {
1004
+ switch (_a.label) {
1005
+ case 0: return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, endpoints_1.ENDPOINT_REST_PRODUCTIVITY, this.authToken)];
1006
+ case 1:
1007
+ response = _a.sent();
1008
+ return [2 /*return*/, (0, validators_1.validateProductivityStats)(response.data)];
1009
+ }
1010
+ });
1011
+ });
1012
+ };
995
1013
  return TodoistApi;
996
1014
  }());
997
1015
  exports.TodoistApi = TodoistApi;
@@ -19,6 +19,7 @@ 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
21
  export declare const ENDPOINT_REST_USER = "user";
22
+ export declare const ENDPOINT_REST_PRODUCTIVITY: string;
22
23
  export declare const PROJECT_ARCHIVE = "archive";
23
24
  export declare const PROJECT_UNARCHIVE = "unarchive";
24
25
  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_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;
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_PRODUCTIVITY = 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';
@@ -35,6 +35,7 @@ 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
37
  exports.ENDPOINT_REST_USER = 'user';
38
+ exports.ENDPOINT_REST_PRODUCTIVITY = exports.ENDPOINT_REST_TASKS + '/completed/stats';
38
39
  exports.PROJECT_ARCHIVE = 'archive';
39
40
  exports.PROJECT_UNARCHIVE = 'unarchive';
40
41
  exports.ENDPOINT_SYNC_QUICK_ADD = exports.ENDPOINT_REST_TASKS + '/quick';
@@ -577,6 +577,86 @@ export declare const CurrentUserSchema: z.ZodObject<{
577
577
  * @see https://todoist.com/api/v1/docs#tag/User
578
578
  */
579
579
  export type CurrentUser = z.infer<typeof CurrentUserSchema>;
580
+ export declare const ProductivityStatsSchema: z.ZodObject<{
581
+ completedCount: z.ZodNumber;
582
+ daysItems: z.ZodArray<z.ZodObject<{
583
+ items: z.ZodArray<z.ZodObject<{
584
+ id: z.ZodString;
585
+ completed: z.ZodNumber;
586
+ }, z.core.$strip>>;
587
+ totalCompleted: z.ZodNumber;
588
+ date: z.ZodString;
589
+ }, z.core.$strip>>;
590
+ goals: z.ZodObject<{
591
+ currentDailyStreak: z.ZodObject<{
592
+ count: z.ZodNumber;
593
+ start: z.ZodString;
594
+ end: z.ZodString;
595
+ }, z.core.$strip>;
596
+ currentWeeklyStreak: z.ZodObject<{
597
+ count: z.ZodNumber;
598
+ start: z.ZodString;
599
+ end: z.ZodString;
600
+ }, z.core.$strip>;
601
+ dailyGoal: z.ZodNumber;
602
+ ignoreDays: z.ZodArray<z.ZodNumber>;
603
+ karmaDisabled: z.ZodNumber;
604
+ lastDailyStreak: z.ZodObject<{
605
+ count: z.ZodNumber;
606
+ start: z.ZodString;
607
+ end: z.ZodString;
608
+ }, z.core.$strip>;
609
+ lastWeeklyStreak: z.ZodObject<{
610
+ count: z.ZodNumber;
611
+ start: z.ZodString;
612
+ end: z.ZodString;
613
+ }, z.core.$strip>;
614
+ maxDailyStreak: z.ZodObject<{
615
+ count: z.ZodNumber;
616
+ start: z.ZodString;
617
+ end: z.ZodString;
618
+ }, z.core.$strip>;
619
+ maxWeeklyStreak: z.ZodObject<{
620
+ count: z.ZodNumber;
621
+ start: z.ZodString;
622
+ end: z.ZodString;
623
+ }, z.core.$strip>;
624
+ user: z.ZodString;
625
+ userId: z.ZodString;
626
+ vacationMode: z.ZodNumber;
627
+ weeklyGoal: z.ZodNumber;
628
+ }, z.core.$strip>;
629
+ karma: z.ZodNumber;
630
+ karmaGraphData: z.ZodArray<z.ZodObject<{
631
+ date: z.ZodString;
632
+ karmaAvg: z.ZodNumber;
633
+ }, z.core.$strip>>;
634
+ karmaLastUpdate: z.ZodNumber;
635
+ karmaTrend: z.ZodString;
636
+ karmaUpdateReasons: z.ZodArray<z.ZodObject<{
637
+ time: z.ZodString;
638
+ newKarma: z.ZodNumber;
639
+ positiveKarma: z.ZodNumber;
640
+ negativeKarma: z.ZodNumber;
641
+ positiveKarmaReasons: z.ZodArray<z.ZodAny>;
642
+ negativeKarmaReasons: z.ZodArray<z.ZodAny>;
643
+ }, z.core.$strip>>;
644
+ projectColors: z.ZodRecord<z.ZodString, z.ZodString>;
645
+ weekItems: z.ZodArray<z.ZodObject<{
646
+ items: z.ZodArray<z.ZodObject<{
647
+ id: z.ZodString;
648
+ completed: z.ZodNumber;
649
+ }, z.core.$strip>>;
650
+ totalCompleted: z.ZodNumber;
651
+ from: z.ZodString;
652
+ to: z.ZodString;
653
+ }, z.core.$strip>>;
654
+ }, z.core.$strip>;
655
+ /**
656
+ * Represents the Productivity stats for the authenticated user.
657
+ * @see https://developer.todoist.com/api/v1/#tag/User/operation/get_productivity_stats_api_v1_tasks_completed_stats_get
658
+ */
659
+ export type ProductivityStats = z.infer<typeof ProductivityStatsSchema>;
580
660
  export declare const ColorSchema: z.ZodObject<{
581
661
  id: z.ZodNumber;
582
662
  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.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;
25
+ exports.ColorSchema = exports.ProductivityStatsSchema = 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
@@ -225,6 +225,61 @@ exports.CurrentUserSchema = zod_1.z.object({
225
225
  daysOff: zod_1.z.array(zod_1.z.number().int()),
226
226
  weekendStartDay: zod_1.z.number().int(),
227
227
  });
228
+ var StreakSchema = zod_1.z.object({
229
+ count: zod_1.z.number(),
230
+ start: zod_1.z.string(),
231
+ end: zod_1.z.string(),
232
+ });
233
+ var CompletedItemSchema = zod_1.z.object({
234
+ id: zod_1.z.string(),
235
+ completed: zod_1.z.number(),
236
+ });
237
+ var ItemsWithDateSchema = zod_1.z.object({
238
+ items: zod_1.z.array(CompletedItemSchema),
239
+ totalCompleted: zod_1.z.number(),
240
+ });
241
+ var KarmaUpdateSchema = zod_1.z.object({
242
+ time: zod_1.z.string(),
243
+ newKarma: zod_1.z.number(),
244
+ positiveKarma: zod_1.z.number(),
245
+ negativeKarma: zod_1.z.number(),
246
+ positiveKarmaReasons: zod_1.z.array(zod_1.z.any()),
247
+ negativeKarmaReasons: zod_1.z.array(zod_1.z.any()),
248
+ });
249
+ exports.ProductivityStatsSchema = zod_1.z.object({
250
+ completedCount: zod_1.z.number(),
251
+ daysItems: zod_1.z.array(ItemsWithDateSchema.extend({
252
+ date: zod_1.z.string(),
253
+ })),
254
+ goals: zod_1.z.object({
255
+ currentDailyStreak: StreakSchema,
256
+ currentWeeklyStreak: StreakSchema,
257
+ dailyGoal: zod_1.z.number(),
258
+ ignoreDays: zod_1.z.array(zod_1.z.number()),
259
+ karmaDisabled: zod_1.z.number(),
260
+ lastDailyStreak: StreakSchema,
261
+ lastWeeklyStreak: StreakSchema,
262
+ maxDailyStreak: StreakSchema,
263
+ maxWeeklyStreak: StreakSchema,
264
+ user: zod_1.z.string(),
265
+ userId: zod_1.z.string(),
266
+ vacationMode: zod_1.z.number(),
267
+ weeklyGoal: zod_1.z.number(),
268
+ }),
269
+ karma: zod_1.z.number(),
270
+ karmaGraphData: zod_1.z.array(zod_1.z.object({
271
+ date: zod_1.z.string(),
272
+ karmaAvg: zod_1.z.number(),
273
+ })),
274
+ karmaLastUpdate: zod_1.z.number(),
275
+ karmaTrend: zod_1.z.string(),
276
+ karmaUpdateReasons: zod_1.z.array(KarmaUpdateSchema),
277
+ projectColors: zod_1.z.record(zod_1.z.string(), zod_1.z.string()),
278
+ weekItems: zod_1.z.array(ItemsWithDateSchema.extend({
279
+ from: zod_1.z.string(),
280
+ to: zod_1.z.string(),
281
+ })),
282
+ });
228
283
  exports.ColorSchema = zod_1.z.object({
229
284
  /** @deprecated No longer used */
230
285
  id: zod_1.z.number(),
@@ -1,4 +1,4 @@
1
- import { type Task, type Section, type Label, type Comment, type User, type CurrentUser, type WorkspaceProject, type PersonalProject } from '../types/entities';
1
+ import { type Task, type Section, type Label, type Comment, type User, type CurrentUser, type ProductivityStats, 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,4 +28,5 @@ 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 validateProductivityStats(input: unknown): ProductivityStats;
31
32
  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.validateProductivityStats = validateProductivityStats;
17
18
  exports.validateCurrentUser = validateCurrentUser;
18
19
  var entities_1 = require("../types/entities");
19
20
  function validateTask(input) {
@@ -76,6 +77,9 @@ function validateUser(input) {
76
77
  function validateUserArray(input) {
77
78
  return input.map(validateUser);
78
79
  }
80
+ function validateProductivityStats(input) {
81
+ return entities_1.ProductivityStatsSchema.parse(input);
82
+ }
79
83
  function validateCurrentUser(input) {
80
84
  return entities_1.CurrentUserSchema.parse(input);
81
85
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/todoist-api-typescript",
3
- "version": "5.4.0",
3
+ "version": "5.5.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",