@doist/todoist-api-typescript 5.6.3 → 5.6.4
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.
- package/dist/TodoistApi.js +13 -3
- package/dist/types/entities.d.ts +13 -1
- package/dist/types/requests.d.ts +77 -6
- package/dist/utils/activity-helpers.d.ts +20 -0
- package/dist/utils/activity-helpers.js +40 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +5 -1
- package/dist/utils/urlHelpers.d.ts +8 -0
- package/dist/utils/urlHelpers.js +14 -0
- package/package.json +1 -1
package/dist/TodoistApi.js
CHANGED
|
@@ -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");
|
|
@@ -1040,15 +1042,23 @@ var TodoistApi = /** @class */ (function () {
|
|
|
1040
1042
|
*/
|
|
1041
1043
|
TodoistApi.prototype.getActivityLogs = function () {
|
|
1042
1044
|
return __awaiter(this, arguments, void 0, function (args) {
|
|
1043
|
-
var _a, results, nextCursor;
|
|
1045
|
+
var processedArgs, _a, results, nextCursor, normalizedResults;
|
|
1044
1046
|
if (args === void 0) { args = {}; }
|
|
1045
1047
|
return __generator(this, function (_b) {
|
|
1046
1048
|
switch (_b.label) {
|
|
1047
|
-
case 0:
|
|
1049
|
+
case 0:
|
|
1050
|
+
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) }));
|
|
1051
|
+
return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, endpoints_1.ENDPOINT_REST_ACTIVITIES, this.authToken, processedArgs)
|
|
1052
|
+
// Convert legacy API object types back to modern SDK types
|
|
1053
|
+
];
|
|
1048
1054
|
case 1:
|
|
1049
1055
|
_a = (_b.sent()).data, results = _a.results, nextCursor = _a.nextCursor;
|
|
1056
|
+
normalizedResults = results.map(function (event) {
|
|
1057
|
+
var normalizedType = (0, activity_helpers_1.denormalizeObjectTypeFromApi)(event.objectType);
|
|
1058
|
+
return __assign(__assign({}, event), { objectType: normalizedType || event.objectType });
|
|
1059
|
+
});
|
|
1050
1060
|
return [2 /*return*/, {
|
|
1051
|
-
results: (0, validators_1.validateActivityEventArray)(
|
|
1061
|
+
results: (0, validators_1.validateActivityEventArray)(normalizedResults),
|
|
1052
1062
|
nextCursor: nextCursor,
|
|
1053
1063
|
}];
|
|
1054
1064
|
}
|
package/dist/types/entities.d.ts
CHANGED
|
@@ -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 = '
|
|
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 {};
|
package/dist/types/requests.d.ts
CHANGED
|
@@ -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
|
-
|
|
387
|
-
|
|
388
|
-
|
|
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
|
-
|
|
400
|
-
|
|
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
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -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
|
-
|
|
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
|
*
|
package/dist/utils/urlHelpers.js
CHANGED
|
@@ -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