@doist/todoist-api-typescript 6.9.0 → 6.10.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.
- package/dist/cjs/rest-client.js +1 -1
- package/dist/cjs/todoist-api.js +18 -6
- package/dist/cjs/utils/activity-helpers.js +18 -0
- package/dist/esm/rest-client.js +1 -1
- package/dist/esm/todoist-api.js +19 -7
- package/dist/esm/utils/activity-helpers.js +17 -0
- package/dist/types/types/entities.d.ts +15 -0
- package/dist/types/types/requests.d.ts +31 -15
- package/dist/types/utils/activity-helpers.d.ts +8 -0
- package/package.json +1 -1
package/dist/cjs/rest-client.js
CHANGED
|
@@ -15,7 +15,7 @@ function paramsSerializer(params) {
|
|
|
15
15
|
const value = params[key];
|
|
16
16
|
if (value != null) {
|
|
17
17
|
if (Array.isArray(value)) {
|
|
18
|
-
qs.append(key,
|
|
18
|
+
qs.append(key, JSON.stringify(value));
|
|
19
19
|
}
|
|
20
20
|
else if (typeof value === 'string' ||
|
|
21
21
|
typeof value === 'number' ||
|
package/dist/cjs/todoist-api.js
CHANGED
|
@@ -1085,18 +1085,30 @@ class TodoistApi {
|
|
|
1085
1085
|
* @returns A promise that resolves to a paginated response of activity events.
|
|
1086
1086
|
*/
|
|
1087
1087
|
async getActivityLogs(args = {}) {
|
|
1088
|
-
var _a, _b;
|
|
1088
|
+
var _a, _b, _c;
|
|
1089
1089
|
// Resolve dateFrom: prefer new param, fall back to deprecated `since`
|
|
1090
1090
|
const rawDateFrom = (_a = args.dateFrom) !== null && _a !== void 0 ? _a : args.since;
|
|
1091
1091
|
const rawDateTo = (_b = args.dateTo) !== null && _b !== void 0 ? _b : args.until;
|
|
1092
1092
|
// Convert Date objects to YYYY-MM-DD strings
|
|
1093
1093
|
const dateFrom = rawDateFrom instanceof Date ? (0, url_helpers_1.formatDateToYYYYMMDD)(rawDateFrom) : rawDateFrom;
|
|
1094
1094
|
const dateTo = rawDateTo instanceof Date ? (0, url_helpers_1.formatDateToYYYYMMDD)(rawDateTo) : rawDateTo;
|
|
1095
|
-
// Destructure out deprecated
|
|
1096
|
-
const { since: _since, until: _until, dateFrom: _dateFrom, dateTo: _dateTo } =
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1095
|
+
// Destructure out deprecated, raw date, and filter-type fields so they don't leak into payload
|
|
1096
|
+
const _d = args, { since: _since, until: _until, dateFrom: _dateFrom, dateTo: _dateTo, objectType, eventType, objectEventTypes } = _d, rest = __rest(_d, ["since", "until", "dateFrom", "dateTo", "objectType", "eventType", "objectEventTypes"]);
|
|
1097
|
+
// Build normalized objectEventTypes for the API
|
|
1098
|
+
let normalizedObjectEventTypes;
|
|
1099
|
+
if (objectEventTypes !== undefined) {
|
|
1100
|
+
const arr = Array.isArray(objectEventTypes) ? objectEventTypes : [objectEventTypes];
|
|
1101
|
+
normalizedObjectEventTypes = arr.map(activity_helpers_1.normalizeObjectEventTypeForApi);
|
|
1102
|
+
}
|
|
1103
|
+
else if (objectType !== undefined || eventType !== undefined) {
|
|
1104
|
+
// Synthesize combined filter from deprecated separate params
|
|
1105
|
+
const objPart = (_c = (0, activity_helpers_1.normalizeObjectTypeForApi)(objectType)) !== null && _c !== void 0 ? _c : '';
|
|
1106
|
+
const evtPart = eventType !== null && eventType !== void 0 ? eventType : '';
|
|
1107
|
+
normalizedObjectEventTypes = [`${objPart}:${evtPart}`];
|
|
1108
|
+
}
|
|
1109
|
+
const processedArgs = Object.assign(Object.assign(Object.assign(Object.assign({}, rest), (dateFrom !== undefined ? { dateFrom } : {})), (dateTo !== undefined ? { dateTo } : {})), (normalizedObjectEventTypes !== undefined
|
|
1110
|
+
? { objectEventTypes: normalizedObjectEventTypes }
|
|
1111
|
+
: {}));
|
|
1100
1112
|
const { data: { results, nextCursor }, } = await (0, rest_client_1.request)({
|
|
1101
1113
|
httpMethod: 'GET',
|
|
1102
1114
|
baseUri: this.syncApiBase,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeObjectTypeForApi = normalizeObjectTypeForApi;
|
|
4
4
|
exports.denormalizeObjectTypeFromApi = denormalizeObjectTypeFromApi;
|
|
5
|
+
exports.normalizeObjectEventTypeForApi = normalizeObjectEventTypeForApi;
|
|
5
6
|
/**
|
|
6
7
|
* Converts modern SDK object type naming to legacy API naming.
|
|
7
8
|
* Maps 'task' -> 'item' and 'comment' -> 'note' for API requests.
|
|
@@ -38,3 +39,20 @@ function denormalizeObjectTypeFromApi(objectType) {
|
|
|
38
39
|
return 'comment';
|
|
39
40
|
return objectType;
|
|
40
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Normalizes an `ActivityObjectEventType` filter string for the API,
|
|
44
|
+
* converting modern object type names to legacy API names.
|
|
45
|
+
* e.g. 'task:added' -> 'item:added', 'comment:' -> 'note:', ':deleted' -> ':deleted'
|
|
46
|
+
*
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
function normalizeObjectEventTypeForApi(filter) {
|
|
50
|
+
var _a, _b;
|
|
51
|
+
const colonIndex = filter.indexOf(':');
|
|
52
|
+
if (colonIndex === -1) {
|
|
53
|
+
return (_a = normalizeObjectTypeForApi(filter)) !== null && _a !== void 0 ? _a : filter;
|
|
54
|
+
}
|
|
55
|
+
const objectPart = filter.slice(0, colonIndex);
|
|
56
|
+
const eventPart = filter.slice(colonIndex); // includes the colon
|
|
57
|
+
return `${(_b = normalizeObjectTypeForApi(objectPart)) !== null && _b !== void 0 ? _b : objectPart}${eventPart}`;
|
|
58
|
+
}
|
package/dist/esm/rest-client.js
CHANGED
|
@@ -10,7 +10,7 @@ export function paramsSerializer(params) {
|
|
|
10
10
|
const value = params[key];
|
|
11
11
|
if (value != null) {
|
|
12
12
|
if (Array.isArray(value)) {
|
|
13
|
-
qs.append(key,
|
|
13
|
+
qs.append(key, JSON.stringify(value));
|
|
14
14
|
}
|
|
15
15
|
else if (typeof value === 'string' ||
|
|
16
16
|
typeof value === 'number' ||
|
package/dist/esm/todoist-api.js
CHANGED
|
@@ -14,7 +14,7 @@ import { getSyncBaseUri, ENDPOINT_REST_TASKS, ENDPOINT_REST_TASKS_FILTER, ENDPOI
|
|
|
14
14
|
import { validateAttachment, validateComment, validateCommentArray, validateCurrentUser, validateLabel, validateLabelArray, validateProject, validateProjectArray, validateSection, validateSectionArray, validateTask, validateTaskArray, validateUserArray, validateProductivityStats, validateActivityEventArray, validateWorkspaceUserArray, validateWorkspaceInvitation, validateWorkspaceInvitationArray, validateWorkspacePlanDetails, validateJoinWorkspaceResult, validateWorkspaceArray, } from './utils/validators.js';
|
|
15
15
|
import { formatDateToYYYYMMDD } from './utils/url-helpers.js';
|
|
16
16
|
import { uploadMultipartFile } from './utils/multipart-upload.js';
|
|
17
|
-
import { normalizeObjectTypeForApi, denormalizeObjectTypeFromApi } from './utils/activity-helpers.js';
|
|
17
|
+
import { normalizeObjectTypeForApi, normalizeObjectEventTypeForApi, denormalizeObjectTypeFromApi, } from './utils/activity-helpers.js';
|
|
18
18
|
import { processTaskContent } from './utils/uncompletable-helpers.js';
|
|
19
19
|
import { z } from 'zod';
|
|
20
20
|
import { v4 as uuidv4 } from 'uuid';
|
|
@@ -1082,18 +1082,30 @@ export class TodoistApi {
|
|
|
1082
1082
|
* @returns A promise that resolves to a paginated response of activity events.
|
|
1083
1083
|
*/
|
|
1084
1084
|
async getActivityLogs(args = {}) {
|
|
1085
|
-
var _a, _b;
|
|
1085
|
+
var _a, _b, _c;
|
|
1086
1086
|
// Resolve dateFrom: prefer new param, fall back to deprecated `since`
|
|
1087
1087
|
const rawDateFrom = (_a = args.dateFrom) !== null && _a !== void 0 ? _a : args.since;
|
|
1088
1088
|
const rawDateTo = (_b = args.dateTo) !== null && _b !== void 0 ? _b : args.until;
|
|
1089
1089
|
// Convert Date objects to YYYY-MM-DD strings
|
|
1090
1090
|
const dateFrom = rawDateFrom instanceof Date ? formatDateToYYYYMMDD(rawDateFrom) : rawDateFrom;
|
|
1091
1091
|
const dateTo = rawDateTo instanceof Date ? formatDateToYYYYMMDD(rawDateTo) : rawDateTo;
|
|
1092
|
-
// Destructure out deprecated
|
|
1093
|
-
const { since: _since, until: _until, dateFrom: _dateFrom, dateTo: _dateTo } =
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1092
|
+
// Destructure out deprecated, raw date, and filter-type fields so they don't leak into payload
|
|
1093
|
+
const _d = args, { since: _since, until: _until, dateFrom: _dateFrom, dateTo: _dateTo, objectType, eventType, objectEventTypes } = _d, rest = __rest(_d, ["since", "until", "dateFrom", "dateTo", "objectType", "eventType", "objectEventTypes"]);
|
|
1094
|
+
// Build normalized objectEventTypes for the API
|
|
1095
|
+
let normalizedObjectEventTypes;
|
|
1096
|
+
if (objectEventTypes !== undefined) {
|
|
1097
|
+
const arr = Array.isArray(objectEventTypes) ? objectEventTypes : [objectEventTypes];
|
|
1098
|
+
normalizedObjectEventTypes = arr.map(normalizeObjectEventTypeForApi);
|
|
1099
|
+
}
|
|
1100
|
+
else if (objectType !== undefined || eventType !== undefined) {
|
|
1101
|
+
// Synthesize combined filter from deprecated separate params
|
|
1102
|
+
const objPart = (_c = normalizeObjectTypeForApi(objectType)) !== null && _c !== void 0 ? _c : '';
|
|
1103
|
+
const evtPart = eventType !== null && eventType !== void 0 ? eventType : '';
|
|
1104
|
+
normalizedObjectEventTypes = [`${objPart}:${evtPart}`];
|
|
1105
|
+
}
|
|
1106
|
+
const processedArgs = Object.assign(Object.assign(Object.assign(Object.assign({}, rest), (dateFrom !== undefined ? { dateFrom } : {})), (dateTo !== undefined ? { dateTo } : {})), (normalizedObjectEventTypes !== undefined
|
|
1107
|
+
? { objectEventTypes: normalizedObjectEventTypes }
|
|
1108
|
+
: {}));
|
|
1097
1109
|
const { data: { results, nextCursor }, } = await request({
|
|
1098
1110
|
httpMethod: 'GET',
|
|
1099
1111
|
baseUri: this.syncApiBase,
|
|
@@ -34,3 +34,20 @@ export function denormalizeObjectTypeFromApi(objectType) {
|
|
|
34
34
|
return 'comment';
|
|
35
35
|
return objectType;
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Normalizes an `ActivityObjectEventType` filter string for the API,
|
|
39
|
+
* converting modern object type names to legacy API names.
|
|
40
|
+
* e.g. 'task:added' -> 'item:added', 'comment:' -> 'note:', ':deleted' -> ':deleted'
|
|
41
|
+
*
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
export function normalizeObjectEventTypeForApi(filter) {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
const colonIndex = filter.indexOf(':');
|
|
47
|
+
if (colonIndex === -1) {
|
|
48
|
+
return (_a = normalizeObjectTypeForApi(filter)) !== null && _a !== void 0 ? _a : filter;
|
|
49
|
+
}
|
|
50
|
+
const objectPart = filter.slice(0, colonIndex);
|
|
51
|
+
const eventPart = filter.slice(colonIndex); // includes the colon
|
|
52
|
+
return `${(_b = normalizeObjectTypeForApi(objectPart)) !== null && _b !== void 0 ? _b : objectPart}${eventPart}`;
|
|
53
|
+
}
|
|
@@ -717,6 +717,21 @@ export type ActivityObjectType = 'task' | 'comment' | 'project' | DeprecatedItem
|
|
|
717
717
|
* Type hints for known event types. Accepts any string for forward compatibility.
|
|
718
718
|
*/
|
|
719
719
|
export type ActivityEventType = 'added' | 'updated' | 'deleted' | 'completed' | 'uncompleted' | 'archived' | 'unarchived' | 'shared' | 'left' | (string & Record<string, never>);
|
|
720
|
+
type ModernActivityObjectType = 'task' | 'comment' | 'project' | (string & Record<string, never>);
|
|
721
|
+
/**
|
|
722
|
+
* Combined object:event filter string for the `objectEventTypes` parameter of `getActivityLogs`.
|
|
723
|
+
*
|
|
724
|
+
* Uses modern object type names (`task`, `comment`) rather than legacy API names (`item`, `note`).
|
|
725
|
+
* Either part may be omitted:
|
|
726
|
+
* - `'task:added'` — task additions only
|
|
727
|
+
* - `'task:'` — all events for tasks
|
|
728
|
+
* - `':deleted'` — all deleted events across all object types
|
|
729
|
+
*
|
|
730
|
+
* The final `string & Record<string, never>` member allows any arbitrary string
|
|
731
|
+
* to be passed for forward compatibility, while still providing autocomplete for
|
|
732
|
+
* the known combinations above.
|
|
733
|
+
*/
|
|
734
|
+
export type ActivityObjectEventType = `${ModernActivityObjectType}:${ActivityEventType}` | `${ModernActivityObjectType}:` | `:${ActivityEventType}` | (string & Record<string, never>);
|
|
720
735
|
/**
|
|
721
736
|
* Flexible object containing event-specific data.
|
|
722
737
|
* Uses z.record to accept any properties for forward compatibility.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RequireAllOrNone, RequireOneOrNone, RequireExactlyOne } from 'type-fest';
|
|
2
2
|
import type { ColorKey } from '../utils/colors.js';
|
|
3
|
-
import type { ActivityEvent, ActivityEventType, ActivityObjectType, Comment, Duration, Label, PersonalProject, ProjectViewStyle, ProjectVisibility, Section, Task, User, WorkspaceProject } from './entities.js';
|
|
3
|
+
import type { ActivityEvent, ActivityEventType, ActivityObjectEventType, ActivityObjectType, Comment, Duration, Label, PersonalProject, ProjectViewStyle, ProjectVisibility, Section, Task, User, WorkspaceProject } from './entities.js';
|
|
4
4
|
/**
|
|
5
5
|
* Arguments for creating a new task.
|
|
6
6
|
* @see https://todoist.com/api/v1/docs#tag/Tasks/operation/create_task_api_v1_tasks_post
|
|
@@ -404,18 +404,9 @@ export type UpdateCommentArgs = {
|
|
|
404
404
|
content: string;
|
|
405
405
|
};
|
|
406
406
|
/**
|
|
407
|
-
*
|
|
407
|
+
* Common arguments for retrieving activity logs (excluding filter-type params).
|
|
408
408
|
*/
|
|
409
|
-
type
|
|
410
|
-
/**
|
|
411
|
-
* Type of object to filter by (e.g., 'task', 'comment', 'project').
|
|
412
|
-
* Accepts both modern naming ('task', 'comment') and legacy naming ('item', 'note').
|
|
413
|
-
*/
|
|
414
|
-
objectType?: ActivityObjectType;
|
|
415
|
-
/**
|
|
416
|
-
* Type of event to filter by (e.g., 'added', 'updated', 'deleted', 'completed', 'uncompleted', 'archived', 'unarchived', 'shared', 'left').
|
|
417
|
-
*/
|
|
418
|
-
eventType?: ActivityEventType;
|
|
409
|
+
type GetActivityLogsArgsCommon = {
|
|
419
410
|
/**
|
|
420
411
|
* Filter by the ID of a specific object.
|
|
421
412
|
*/
|
|
@@ -477,7 +468,32 @@ type GetActivityLogsArgsBase = {
|
|
|
477
468
|
*/
|
|
478
469
|
dateTo?: Date | string;
|
|
479
470
|
};
|
|
480
|
-
|
|
471
|
+
/** Use the legacy separate objectType/eventType params. Cannot be combined with objectEventTypes. */
|
|
472
|
+
type GetActivityLogsArgsLegacy = GetActivityLogsArgsCommon & {
|
|
473
|
+
/**
|
|
474
|
+
* Type of object to filter by (e.g., 'task', 'comment', 'project').
|
|
475
|
+
* Accepts both modern naming ('task', 'comment') and legacy naming ('item', 'note').
|
|
476
|
+
* @deprecated Use `objectEventTypes` instead.
|
|
477
|
+
*/
|
|
478
|
+
objectType?: ActivityObjectType;
|
|
479
|
+
/**
|
|
480
|
+
* Type of event to filter by (e.g., 'added', 'updated', 'deleted').
|
|
481
|
+
* @deprecated Use `objectEventTypes` instead.
|
|
482
|
+
*/
|
|
483
|
+
eventType?: ActivityEventType;
|
|
484
|
+
objectEventTypes?: never;
|
|
485
|
+
};
|
|
486
|
+
/** Use the modern combined objectEventTypes param. Cannot be combined with objectType/eventType. */
|
|
487
|
+
type GetActivityLogsArgsModern = GetActivityLogsArgsCommon & {
|
|
488
|
+
/**
|
|
489
|
+
* One or more combined object:event filter strings, e.g. `'task:added'`, `'task:'`, `':deleted'`.
|
|
490
|
+
* Accepts a single value or an array of values for multi-type filtering.
|
|
491
|
+
*/
|
|
492
|
+
objectEventTypes?: ActivityObjectEventType | ActivityObjectEventType[];
|
|
493
|
+
objectType?: never;
|
|
494
|
+
eventType?: never;
|
|
495
|
+
};
|
|
496
|
+
type GetActivityLogsArgsWithDate<TBase> = TBase & {
|
|
481
497
|
/**
|
|
482
498
|
* @deprecated Use `dateFrom` instead. Will be removed in the next major version.
|
|
483
499
|
*/
|
|
@@ -491,7 +507,7 @@ type GetActivityLogsArgsWithDate = GetActivityLogsArgsBase & {
|
|
|
491
507
|
* @deprecated String dates (YYYY-MM-DD format) are deprecated. Use Date objects instead.
|
|
492
508
|
* This type will be removed in the next major version.
|
|
493
509
|
*/
|
|
494
|
-
type GetActivityLogsArgsWithString =
|
|
510
|
+
type GetActivityLogsArgsWithString<TBase> = TBase & {
|
|
495
511
|
/**
|
|
496
512
|
* @deprecated Use `dateFrom` instead. Will be removed in the next major version.
|
|
497
513
|
*/
|
|
@@ -501,7 +517,7 @@ type GetActivityLogsArgsWithString = GetActivityLogsArgsBase & {
|
|
|
501
517
|
*/
|
|
502
518
|
until?: string;
|
|
503
519
|
};
|
|
504
|
-
export type GetActivityLogsArgs = GetActivityLogsArgsWithDate | GetActivityLogsArgsWithString
|
|
520
|
+
export type GetActivityLogsArgs = GetActivityLogsArgsWithDate<GetActivityLogsArgsLegacy> | GetActivityLogsArgsWithString<GetActivityLogsArgsLegacy> | GetActivityLogsArgsWithDate<GetActivityLogsArgsModern> | GetActivityLogsArgsWithString<GetActivityLogsArgsModern>;
|
|
505
521
|
/**
|
|
506
522
|
* Response from retrieving activity logs.
|
|
507
523
|
*/
|
|
@@ -18,3 +18,11 @@ export declare function normalizeObjectTypeForApi(objectType: string | undefined
|
|
|
18
18
|
* @returns The object type using modern SDK naming.
|
|
19
19
|
*/
|
|
20
20
|
export declare function denormalizeObjectTypeFromApi(objectType: string | undefined): string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Normalizes an `ActivityObjectEventType` filter string for the API,
|
|
23
|
+
* converting modern object type names to legacy API names.
|
|
24
|
+
* e.g. 'task:added' -> 'item:added', 'comment:' -> 'note:', ':deleted' -> ':deleted'
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export declare function normalizeObjectEventTypeForApi(filter: string): string;
|
package/package.json
CHANGED