@doist/todoist-api-typescript 5.6.3 → 5.7.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.
@@ -112,8 +112,18 @@ export declare class TodoistApi {
112
112
  * @param args - The paramets that should contain only one of projectId, sectionId, or parentId
113
113
  * @param requestId - Optional custom identifier for the request.
114
114
  * @returns - A promise that resolves to an array of the updated tasks.
115
+ * @deprecated Use `moveTask` for single task operations. This method uses the Sync API and may be removed in a future version.
115
116
  */
116
117
  moveTasks(ids: string[], args: MoveTaskArgs, requestId?: string): Promise<Task[]>;
118
+ /**
119
+ * Moves a task by its ID to either a different parent/section/project.
120
+ *
121
+ * @param id - The unique identifier of the task to be moved.
122
+ * @param args - The parameters that should contain exactly one of projectId, sectionId, or parentId
123
+ * @param requestId - Optional custom identifier for the request.
124
+ * @returns A promise that resolves to the updated task.
125
+ */
126
+ moveTask(id: string, args: MoveTaskArgs, requestId?: string): Promise<Task>;
117
127
  /**
118
128
  * Closes (completes) a task by its ID.
119
129
  *
@@ -51,6 +51,8 @@ exports.TodoistApi = void 0;
51
51
  var restClient_1 = require("./restClient");
52
52
  var endpoints_1 = require("./consts/endpoints");
53
53
  var validators_1 = require("./utils/validators");
54
+ var urlHelpers_1 = require("./utils/urlHelpers");
55
+ var activity_helpers_1 = require("./utils/activity-helpers");
54
56
  var zod_1 = require("zod");
55
57
  var uuid_1 = require("uuid");
56
58
  var types_1 = require("./types");
@@ -320,6 +322,7 @@ var TodoistApi = /** @class */ (function () {
320
322
  * @param args - The paramets that should contain only one of projectId, sectionId, or parentId
321
323
  * @param requestId - Optional custom identifier for the request.
322
324
  * @returns - A promise that resolves to an array of the updated tasks.
325
+ * @deprecated Use `moveTask` for single task operations. This method uses the Sync API and may be removed in a future version.
323
326
  */
324
327
  TodoistApi.prototype.moveTasks = function (ids, args, requestId) {
325
328
  return __awaiter(this, void 0, void 0, function () {
@@ -364,6 +367,29 @@ var TodoistApi = /** @class */ (function () {
364
367
  });
365
368
  });
366
369
  };
370
+ /**
371
+ * Moves a task by its ID to either a different parent/section/project.
372
+ *
373
+ * @param id - The unique identifier of the task to be moved.
374
+ * @param args - The parameters that should contain exactly one of projectId, sectionId, or parentId
375
+ * @param requestId - Optional custom identifier for the request.
376
+ * @returns A promise that resolves to the updated task.
377
+ */
378
+ TodoistApi.prototype.moveTask = function (id, args, requestId) {
379
+ return __awaiter(this, void 0, void 0, function () {
380
+ var response;
381
+ return __generator(this, function (_a) {
382
+ switch (_a.label) {
383
+ case 0:
384
+ zod_1.z.string().parse(id);
385
+ return [4 /*yield*/, (0, restClient_1.request)('POST', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_TASKS, id, endpoints_1.ENDPOINT_REST_TASK_MOVE), this.authToken, __assign(__assign(__assign({}, (args.projectId && { project_id: args.projectId })), (args.sectionId && { section_id: args.sectionId })), (args.parentId && { parent_id: args.parentId })), requestId)];
386
+ case 1:
387
+ response = _a.sent();
388
+ return [2 /*return*/, (0, validators_1.validateTask)(response.data)];
389
+ }
390
+ });
391
+ });
392
+ };
367
393
  /**
368
394
  * Closes (completes) a task by its ID.
369
395
  *
@@ -1040,15 +1066,23 @@ var TodoistApi = /** @class */ (function () {
1040
1066
  */
1041
1067
  TodoistApi.prototype.getActivityLogs = function () {
1042
1068
  return __awaiter(this, arguments, void 0, function (args) {
1043
- var _a, results, nextCursor;
1069
+ var processedArgs, _a, results, nextCursor, normalizedResults;
1044
1070
  if (args === void 0) { args = {}; }
1045
1071
  return __generator(this, function (_b) {
1046
1072
  switch (_b.label) {
1047
- case 0: return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, endpoints_1.ENDPOINT_REST_ACTIVITIES, this.authToken, args)];
1073
+ case 0:
1074
+ processedArgs = __assign(__assign(__assign(__assign({}, args), (args.since instanceof Date && { since: (0, urlHelpers_1.formatDateToYYYYMMDD)(args.since) })), (args.until instanceof Date && { until: (0, urlHelpers_1.formatDateToYYYYMMDD)(args.until) })), (args.objectType && { objectType: (0, activity_helpers_1.normalizeObjectTypeForApi)(args.objectType) }));
1075
+ return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, endpoints_1.ENDPOINT_REST_ACTIVITIES, this.authToken, processedArgs)
1076
+ // Convert legacy API object types back to modern SDK types
1077
+ ];
1048
1078
  case 1:
1049
1079
  _a = (_b.sent()).data, results = _a.results, nextCursor = _a.nextCursor;
1080
+ normalizedResults = results.map(function (event) {
1081
+ var normalizedType = (0, activity_helpers_1.denormalizeObjectTypeFromApi)(event.objectType);
1082
+ return __assign(__assign({}, event), { objectType: normalizedType || event.objectType });
1083
+ });
1050
1084
  return [2 /*return*/, {
1051
- results: (0, validators_1.validateActivityEventArray)(results),
1085
+ results: (0, validators_1.validateActivityEventArray)(normalizedResults),
1052
1086
  nextCursor: nextCursor,
1053
1087
  }];
1054
1088
  }
@@ -16,6 +16,7 @@ export declare const ENDPOINT_REST_LABELS_SHARED_REMOVE: string;
16
16
  export declare const ENDPOINT_REST_COMMENTS = "comments";
17
17
  export declare const ENDPOINT_REST_TASK_CLOSE = "close";
18
18
  export declare const ENDPOINT_REST_TASK_REOPEN = "reopen";
19
+ export declare const ENDPOINT_REST_TASK_MOVE = "move";
19
20
  export declare const ENDPOINT_REST_PROJECTS = "projects";
20
21
  export declare const ENDPOINT_REST_PROJECTS_ARCHIVED: string;
21
22
  export declare const ENDPOINT_REST_PROJECT_COLLABORATORS = "collaborators";
@@ -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_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;
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_MOVE = 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';
@@ -32,6 +32,7 @@ exports.ENDPOINT_REST_LABELS_SHARED_REMOVE = exports.ENDPOINT_REST_LABELS_SHARED
32
32
  exports.ENDPOINT_REST_COMMENTS = 'comments';
33
33
  exports.ENDPOINT_REST_TASK_CLOSE = 'close';
34
34
  exports.ENDPOINT_REST_TASK_REOPEN = 'reopen';
35
+ exports.ENDPOINT_REST_TASK_MOVE = 'move';
35
36
  exports.ENDPOINT_REST_PROJECTS = 'projects';
36
37
  exports.ENDPOINT_REST_PROJECTS_ARCHIVED = exports.ENDPOINT_REST_PROJECTS + '/archived';
37
38
  exports.ENDPOINT_REST_PROJECT_COLLABORATORS = 'collaborators';
@@ -670,10 +670,21 @@ 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
+ * @deprecated Use 'task' instead. This will be removed in the next major version.
675
+ */
676
+ type DeprecatedItem = 'item';
677
+ /**
678
+ * @deprecated Use 'comment' instead. This will be removed in the next major version.
679
+ */
680
+ type DeprecatedNote = 'note';
673
681
  /**
674
682
  * Type hints for known object types. Accepts any string for forward compatibility.
683
+ * Supports both modern naming ('task', 'comment') and legacy naming ('item', 'note').
684
+ *
685
+ * **Note**: The legacy values 'item' and 'note' are deprecated. Use 'task' and 'comment' instead.
675
686
  */
676
- export type ActivityObjectType = 'item' | 'note' | 'project' | (string & Record<string, never>);
687
+ export type ActivityObjectType = 'task' | 'comment' | 'project' | DeprecatedItem | DeprecatedNote | (string & Record<string, never>);
677
688
  /**
678
689
  * Type hints for known event types. Accepts any string for forward compatibility.
679
690
  */
@@ -702,3 +713,4 @@ export declare const ActivityEventSchema: z.ZodObject<{
702
713
  * Represents an activity log event in Todoist.
703
714
  */
704
715
  export type ActivityEvent = z.infer<typeof ActivityEventSchema>;
716
+ export {};
@@ -1,5 +1,5 @@
1
1
  import type { RequireAllOrNone, RequireOneOrNone, RequireExactlyOne } from 'type-fest';
2
- import type { ActivityEvent, Comment, Duration, Label, PersonalProject, ProjectViewStyle, Section, Task, User, WorkspaceProject } from './entities';
2
+ import type { ActivityEvent, ActivityEventType, ActivityObjectType, 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
@@ -383,24 +383,94 @@ export type UpdateCommentArgs = {
383
383
  /**
384
384
  * Arguments for retrieving activity logs.
385
385
  */
386
- export type GetActivityLogsArgs = {
387
- objectType?: string;
388
- eventType?: string;
386
+ type GetActivityLogsArgsBase = {
387
+ /**
388
+ * Type of object to filter by (e.g., 'task', 'comment', 'project').
389
+ * Accepts both modern naming ('task', 'comment') and legacy naming ('item', 'note').
390
+ */
391
+ objectType?: ActivityObjectType;
392
+ /**
393
+ * Type of event to filter by (e.g., 'added', 'updated', 'deleted', 'completed', 'uncompleted', 'archived', 'unarchived', 'shared', 'left').
394
+ */
395
+ eventType?: ActivityEventType;
396
+ /**
397
+ * Filter by the ID of a specific object.
398
+ */
389
399
  objectId?: string;
400
+ /**
401
+ * Filter events by parent project ID.
402
+ */
390
403
  parentProjectId?: string;
404
+ /**
405
+ * Filter events by parent task ID.
406
+ */
391
407
  parentItemId?: string;
408
+ /**
409
+ * When true, includes the parent object data in the response.
410
+ */
392
411
  includeParentObject?: boolean;
412
+ /**
413
+ * When true, includes child object data in the response.
414
+ */
393
415
  includeChildObjects?: boolean;
416
+ /**
417
+ * Filter by the user ID who initiated the event.
418
+ */
394
419
  initiatorId?: string;
420
+ /**
421
+ * When true, filters for events with no initiator (system-generated events).
422
+ * When false, filters for events with an initiator.
423
+ * When null or undefined, no filtering on initiator is applied.
424
+ */
395
425
  initiatorIdNull?: boolean | null;
426
+ /**
427
+ * When true, ensures the last state of objects is included in the response.
428
+ */
396
429
  ensureLastState?: boolean;
430
+ /**
431
+ * When true, includes comment annotations in the response.
432
+ */
397
433
  annotateNotes?: boolean;
434
+ /**
435
+ * When true, includes parent object annotations in the response.
436
+ */
398
437
  annotateParents?: boolean;
399
- since?: string;
400
- until?: string;
438
+ /**
439
+ * Pagination cursor for retrieving the next page of results.
440
+ */
401
441
  cursor?: string | null;
442
+ /**
443
+ * Maximum number of results to return per page.
444
+ */
402
445
  limit?: number;
403
446
  };
447
+ type GetActivityLogsArgsWithDate = GetActivityLogsArgsBase & {
448
+ /**
449
+ * Start date for filtering events (inclusive).
450
+ */
451
+ since?: Date;
452
+ /**
453
+ * End date for filtering events (inclusive).
454
+ */
455
+ until?: Date;
456
+ };
457
+ /**
458
+ * @deprecated String dates (YYYY-MM-DD format) are deprecated. Use Date objects instead.
459
+ * This type will be removed in the next major version.
460
+ */
461
+ type GetActivityLogsArgsWithString = GetActivityLogsArgsBase & {
462
+ /**
463
+ * Start date for filtering events in YYYY-MM-DD format (inclusive).
464
+ * @deprecated Use Date object instead. String format will be removed in the next major version.
465
+ */
466
+ since?: string;
467
+ /**
468
+ * End date for filtering events in YYYY-MM-DD format (inclusive).
469
+ * @deprecated Use Date object instead. String format will be removed in the next major version.
470
+ */
471
+ until?: string;
472
+ };
473
+ export type GetActivityLogsArgs = GetActivityLogsArgsWithDate | GetActivityLogsArgsWithString;
404
474
  /**
405
475
  * Response from retrieving activity logs.
406
476
  */
@@ -408,3 +478,4 @@ export type GetActivityLogsResponse = {
408
478
  results: ActivityEvent[];
409
479
  nextCursor: string | null;
410
480
  };
481
+ export {};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Converts modern SDK object type naming to legacy API naming.
3
+ * Maps 'task' -> 'item' and 'comment' -> 'note' for API requests.
4
+ * Other values pass through unchanged.
5
+ *
6
+ * @internal
7
+ * @param objectType The object type using modern naming.
8
+ * @returns The object type using legacy API naming.
9
+ */
10
+ export declare function normalizeObjectTypeForApi(objectType: string | undefined): string | undefined;
11
+ /**
12
+ * Converts legacy API object type naming to modern SDK naming.
13
+ * Maps 'item' -> 'task' and 'note' -> 'comment' for SDK responses.
14
+ * Other values pass through unchanged.
15
+ *
16
+ * @internal
17
+ * @param objectType The object type using legacy API naming.
18
+ * @returns The object type using modern SDK naming.
19
+ */
20
+ export declare function denormalizeObjectTypeFromApi(objectType: string | undefined): string | undefined;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeObjectTypeForApi = normalizeObjectTypeForApi;
4
+ exports.denormalizeObjectTypeFromApi = denormalizeObjectTypeFromApi;
5
+ /**
6
+ * Converts modern SDK object type naming to legacy API naming.
7
+ * Maps 'task' -> 'item' and 'comment' -> 'note' for API requests.
8
+ * Other values pass through unchanged.
9
+ *
10
+ * @internal
11
+ * @param objectType The object type using modern naming.
12
+ * @returns The object type using legacy API naming.
13
+ */
14
+ function normalizeObjectTypeForApi(objectType) {
15
+ if (!objectType)
16
+ return objectType;
17
+ if (objectType === 'task')
18
+ return 'item';
19
+ if (objectType === 'comment')
20
+ return 'note';
21
+ return objectType;
22
+ }
23
+ /**
24
+ * Converts legacy API object type naming to modern SDK naming.
25
+ * Maps 'item' -> 'task' and 'note' -> 'comment' for SDK responses.
26
+ * Other values pass through unchanged.
27
+ *
28
+ * @internal
29
+ * @param objectType The object type using legacy API naming.
30
+ * @returns The object type using modern SDK naming.
31
+ */
32
+ function denormalizeObjectTypeFromApi(objectType) {
33
+ if (!objectType)
34
+ return objectType;
35
+ if (objectType === 'item')
36
+ return 'task';
37
+ if (objectType === 'note')
38
+ return 'comment';
39
+ return objectType;
40
+ }
@@ -1,3 +1,3 @@
1
1
  export * from './colors';
2
2
  export * from './sanitization';
3
- export * from './urlHelpers';
3
+ export { getTaskUrl, getProjectUrl, getSectionUrl } from './urlHelpers';
@@ -14,6 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.getSectionUrl = exports.getProjectUrl = exports.getTaskUrl = void 0;
17
18
  __exportStar(require("./colors"), exports);
18
19
  __exportStar(require("./sanitization"), exports);
19
- __exportStar(require("./urlHelpers"), exports);
20
+ var urlHelpers_1 = require("./urlHelpers");
21
+ Object.defineProperty(exports, "getTaskUrl", { enumerable: true, get: function () { return urlHelpers_1.getTaskUrl; } });
22
+ Object.defineProperty(exports, "getProjectUrl", { enumerable: true, get: function () { return urlHelpers_1.getProjectUrl; } });
23
+ Object.defineProperty(exports, "getSectionUrl", { enumerable: true, get: function () { return urlHelpers_1.getSectionUrl; } });
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Formats a Date object to YYYY-MM-DD string format.
3
+ *
4
+ * @internal
5
+ * @param date The Date object to format.
6
+ * @returns The formatted date string in YYYY-MM-DD format.
7
+ */
8
+ export declare function formatDateToYYYYMMDD(date: Date): string;
1
9
  /**
2
10
  * Generate the URL for a given task.
3
11
  *
@@ -1,9 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatDateToYYYYMMDD = formatDateToYYYYMMDD;
3
4
  exports.getTaskUrl = getTaskUrl;
4
5
  exports.getProjectUrl = getProjectUrl;
5
6
  exports.getSectionUrl = getSectionUrl;
6
7
  var endpoints_1 = require("../consts/endpoints");
8
+ /**
9
+ * Formats a Date object to YYYY-MM-DD string format.
10
+ *
11
+ * @internal
12
+ * @param date The Date object to format.
13
+ * @returns The formatted date string in YYYY-MM-DD format.
14
+ */
15
+ function formatDateToYYYYMMDD(date) {
16
+ var year = date.getFullYear();
17
+ var month = String(date.getMonth() + 1).padStart(2, '0');
18
+ var day = String(date.getDate()).padStart(2, '0');
19
+ return "".concat(year, "-").concat(month, "-").concat(day);
20
+ }
7
21
  /**
8
22
  * Generate the URL for a given task.
9
23
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/todoist-api-typescript",
3
- "version": "5.6.3",
3
+ "version": "5.7.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",
@@ -30,14 +30,13 @@
30
30
  "camelcase": "6.3.0",
31
31
  "emoji-regex": "10.5.0",
32
32
  "ts-custom-error": "^3.2.0",
33
- "uuid": "^11.0.0",
33
+ "uuid": "11.1.0",
34
34
  "zod": "4.1.5"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@doist/eslint-config": "11.1.0",
38
38
  "@doist/prettier-config": "4.0.0",
39
39
  "@types/jest": "30.0.0",
40
- "@types/uuid": "10.0.0",
41
40
  "@typescript-eslint/eslint-plugin": "6.21.0",
42
41
  "@typescript-eslint/parser": "6.21.0",
43
42
  "eslint": "8.35.0",