@doist/todoist-api-typescript 5.6.0 → 5.6.3

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, CurrentUser, ProductivityStats } 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, GetArchivedProjectsArgs, GetArchivedProjectsResponse, SearchCompletedTasksArgs } 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, SearchCompletedTasksArgs, GetActivityLogsArgs, GetActivityLogsResponse } 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.
@@ -352,4 +352,11 @@ export declare class TodoistApi {
352
352
  * @returns A promise that resolves to the productivity stats.
353
353
  */
354
354
  getProductivityStats(): Promise<ProductivityStats>;
355
+ /**
356
+ * Retrieves activity logs with optional filters.
357
+ *
358
+ * @param args - Optional filter parameters for activity logs.
359
+ * @returns A promise that resolves to a paginated response of activity events.
360
+ */
361
+ getActivityLogs(args?: GetActivityLogsArgs): Promise<GetActivityLogsResponse>;
355
362
  }
@@ -1032,6 +1032,29 @@ var TodoistApi = /** @class */ (function () {
1032
1032
  });
1033
1033
  });
1034
1034
  };
1035
+ /**
1036
+ * Retrieves activity logs with optional filters.
1037
+ *
1038
+ * @param args - Optional filter parameters for activity logs.
1039
+ * @returns A promise that resolves to a paginated response of activity events.
1040
+ */
1041
+ TodoistApi.prototype.getActivityLogs = function () {
1042
+ return __awaiter(this, arguments, void 0, function (args) {
1043
+ var _a, results, nextCursor;
1044
+ if (args === void 0) { args = {}; }
1045
+ return __generator(this, function (_b) {
1046
+ switch (_b.label) {
1047
+ case 0: return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, endpoints_1.ENDPOINT_REST_ACTIVITIES, this.authToken, args)];
1048
+ case 1:
1049
+ _a = (_b.sent()).data, results = _a.results, nextCursor = _a.nextCursor;
1050
+ return [2 /*return*/, {
1051
+ results: (0, validators_1.validateActivityEventArray)(results),
1052
+ nextCursor: nextCursor,
1053
+ }];
1054
+ }
1055
+ });
1056
+ });
1057
+ };
1035
1058
  return TodoistApi;
1036
1059
  }());
1037
1060
  exports.TodoistApi = TodoistApi;
@@ -21,6 +21,7 @@ export declare const ENDPOINT_REST_PROJECTS_ARCHIVED: string;
21
21
  export declare const ENDPOINT_REST_PROJECT_COLLABORATORS = "collaborators";
22
22
  export declare const ENDPOINT_REST_USER = "user";
23
23
  export declare const ENDPOINT_REST_PRODUCTIVITY: string;
24
+ export declare const ENDPOINT_REST_ACTIVITIES = "activities";
24
25
  export declare const PROJECT_ARCHIVE = "archive";
25
26
  export declare const PROJECT_UNARCHIVE = "unarchive";
26
27
  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_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_SEARCH = 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_ACTIVITIES = 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_SEARCH = 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';
@@ -37,6 +37,7 @@ exports.ENDPOINT_REST_PROJECTS_ARCHIVED = exports.ENDPOINT_REST_PROJECTS + '/arc
37
37
  exports.ENDPOINT_REST_PROJECT_COLLABORATORS = 'collaborators';
38
38
  exports.ENDPOINT_REST_USER = 'user';
39
39
  exports.ENDPOINT_REST_PRODUCTIVITY = exports.ENDPOINT_REST_TASKS + '/completed/stats';
40
+ exports.ENDPOINT_REST_ACTIVITIES = 'activities';
40
41
  exports.PROJECT_ARCHIVE = 'archive';
41
42
  exports.PROJECT_UNARCHIVE = 'unarchive';
42
43
  exports.ENDPOINT_SYNC_QUICK_ADD = exports.ENDPOINT_REST_TASKS + '/quick';
@@ -670,3 +670,35 @@ export declare const ColorSchema: z.ZodObject<{
670
670
  * @see https://todoist.com/api/v1/docs#tag/Colors
671
671
  */
672
672
  export type Color = z.infer<typeof ColorSchema>;
673
+ /**
674
+ * Type hints for known object types. Accepts any string for forward compatibility.
675
+ */
676
+ export type ActivityObjectType = 'item' | 'note' | 'project' | (string & Record<string, never>);
677
+ /**
678
+ * Type hints for known event types. Accepts any string for forward compatibility.
679
+ */
680
+ export type ActivityEventType = 'added' | 'updated' | 'deleted' | 'completed' | 'uncompleted' | 'archived' | 'unarchived' | 'shared' | 'left' | (string & Record<string, never>);
681
+ /**
682
+ * Flexible object containing event-specific data.
683
+ * Uses z.record to accept any properties for forward compatibility.
684
+ */
685
+ export declare const ActivityEventExtraDataSchema: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>;
686
+ export type ActivityEventExtraData = z.infer<typeof ActivityEventExtraDataSchema>;
687
+ /**
688
+ * Activity log event schema. Accepts unknown fields for forward compatibility.
689
+ */
690
+ export declare const ActivityEventSchema: z.ZodObject<{
691
+ objectType: z.ZodString;
692
+ objectId: z.ZodString;
693
+ eventType: z.ZodString;
694
+ eventDate: z.ZodString;
695
+ id: z.ZodNullable<z.ZodString>;
696
+ parentProjectId: z.ZodNullable<z.ZodString>;
697
+ parentItemId: z.ZodNullable<z.ZodString>;
698
+ initiatorId: z.ZodNullable<z.ZodString>;
699
+ extraData: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>;
700
+ }, z.core.$catchall<z.ZodAny>>;
701
+ /**
702
+ * Represents an activity log event in Todoist.
703
+ */
704
+ export type ActivityEvent = z.infer<typeof ActivityEventSchema>;
@@ -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.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;
25
+ exports.ActivityEventSchema = exports.ActivityEventExtraDataSchema = 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
@@ -296,3 +296,24 @@ exports.ColorSchema = zod_1.z.object({
296
296
  */
297
297
  value: zod_1.z.string(),
298
298
  });
299
+ /**
300
+ * Flexible object containing event-specific data.
301
+ * Uses z.record to accept any properties for forward compatibility.
302
+ */
303
+ exports.ActivityEventExtraDataSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.any()).nullable();
304
+ /**
305
+ * Activity log event schema. Accepts unknown fields for forward compatibility.
306
+ */
307
+ exports.ActivityEventSchema = zod_1.z
308
+ .object({
309
+ objectType: zod_1.z.string(),
310
+ objectId: zod_1.z.string(),
311
+ eventType: zod_1.z.string(),
312
+ eventDate: zod_1.z.string(),
313
+ id: zod_1.z.string().nullable(),
314
+ parentProjectId: zod_1.z.string().nullable(),
315
+ parentItemId: zod_1.z.string().nullable(),
316
+ initiatorId: zod_1.z.string().nullable(),
317
+ extraData: exports.ActivityEventExtraDataSchema,
318
+ })
319
+ .catchall(zod_1.z.any());
@@ -1,5 +1,5 @@
1
1
  import type { RequireAllOrNone, RequireOneOrNone, RequireExactlyOne } from 'type-fest';
2
- import type { Comment, Duration, Label, PersonalProject, ProjectViewStyle, Section, Task, User, WorkspaceProject } from './entities';
2
+ import type { ActivityEvent, Comment, Duration, Label, PersonalProject, ProjectViewStyle, Section, Task, User, WorkspaceProject } from './entities';
3
3
  /**
4
4
  * Arguments for creating a new task.
5
5
  * @see https://todoist.com/api/v1/docs#tag/Tasks/operation/create_task_api_v1_tasks_post
@@ -380,3 +380,31 @@ export type AddCommentArgs = {
380
380
  export type UpdateCommentArgs = {
381
381
  content: string;
382
382
  };
383
+ /**
384
+ * Arguments for retrieving activity logs.
385
+ */
386
+ export type GetActivityLogsArgs = {
387
+ objectType?: string;
388
+ eventType?: string;
389
+ objectId?: string;
390
+ parentProjectId?: string;
391
+ parentItemId?: string;
392
+ includeParentObject?: boolean;
393
+ includeChildObjects?: boolean;
394
+ initiatorId?: string;
395
+ initiatorIdNull?: boolean | null;
396
+ ensureLastState?: boolean;
397
+ annotateNotes?: boolean;
398
+ annotateParents?: boolean;
399
+ since?: string;
400
+ until?: string;
401
+ cursor?: string | null;
402
+ limit?: number;
403
+ };
404
+ /**
405
+ * Response from retrieving activity logs.
406
+ */
407
+ export type GetActivityLogsResponse = {
408
+ results: ActivityEvent[];
409
+ nextCursor: string | null;
410
+ };
@@ -1,2 +1,3 @@
1
1
  export * from './colors';
2
2
  export * from './sanitization';
3
+ export * from './urlHelpers';
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./colors"), exports);
18
18
  __exportStar(require("./sanitization"), exports);
19
+ __exportStar(require("./urlHelpers"), exports);
@@ -1,4 +1,4 @@
1
- import { type Task, type Section, type Label, type Comment, type User, type CurrentUser, type ProductivityStats, 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, type ActivityEvent } from '../types/entities';
2
2
  export declare function validateTask(input: unknown): Task;
3
3
  export declare function validateTaskArray(input: unknown[]): Task[];
4
4
  /**
@@ -30,3 +30,5 @@ export declare function validateUser(input: unknown): User;
30
30
  export declare function validateUserArray(input: unknown[]): User[];
31
31
  export declare function validateProductivityStats(input: unknown): ProductivityStats;
32
32
  export declare function validateCurrentUser(input: unknown): CurrentUser;
33
+ export declare function validateActivityEvent(input: unknown): ActivityEvent;
34
+ export declare function validateActivityEventArray(input: unknown[]): ActivityEvent[];
@@ -16,6 +16,8 @@ exports.validateUser = validateUser;
16
16
  exports.validateUserArray = validateUserArray;
17
17
  exports.validateProductivityStats = validateProductivityStats;
18
18
  exports.validateCurrentUser = validateCurrentUser;
19
+ exports.validateActivityEvent = validateActivityEvent;
20
+ exports.validateActivityEventArray = validateActivityEventArray;
19
21
  var entities_1 = require("../types/entities");
20
22
  function validateTask(input) {
21
23
  return entities_1.TaskSchema.parse(input);
@@ -83,3 +85,9 @@ function validateProductivityStats(input) {
83
85
  function validateCurrentUser(input) {
84
86
  return entities_1.CurrentUserSchema.parse(input);
85
87
  }
88
+ function validateActivityEvent(input) {
89
+ return entities_1.ActivityEventSchema.parse(input);
90
+ }
91
+ function validateActivityEventArray(input) {
92
+ return input.map(validateActivityEvent);
93
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/todoist-api-typescript",
3
- "version": "5.6.0",
3
+ "version": "5.6.3",
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",