@doist/todoist-api-typescript 5.7.0 → 5.8.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,5 +1,5 @@
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, GetActivityLogsArgs, GetActivityLogsResponse } from './types/requests';
1
+ import { Attachment, 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, GetActivityLogsArgs, GetActivityLogsResponse, UploadFileArgs, DeleteUploadArgs } 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.
@@ -369,4 +369,57 @@ export declare class TodoistApi {
369
369
  * @returns A promise that resolves to a paginated response of activity events.
370
370
  */
371
371
  getActivityLogs(args?: GetActivityLogsArgs): Promise<GetActivityLogsResponse>;
372
+ /**
373
+ * Uploads a file and returns attachment metadata.
374
+ * This creates an upload record that can be referenced in tasks or comments.
375
+ *
376
+ * @param args - Upload parameters including file content, filename, and optional project ID.
377
+ * @param requestId - Optional custom identifier for the request.
378
+ * @returns A promise that resolves to the uploaded file's attachment metadata.
379
+ *
380
+ * @example
381
+ * ```typescript
382
+ * // Upload from a file path
383
+ * const upload = await api.uploadFile({
384
+ * file: '/path/to/document.pdf',
385
+ * projectId: '12345'
386
+ * })
387
+ *
388
+ * // Upload from a Buffer
389
+ * const buffer = fs.readFileSync('/path/to/document.pdf')
390
+ * const upload = await api.uploadFile({
391
+ * file: buffer,
392
+ * fileName: 'document.pdf', // Required for Buffer/Stream
393
+ * projectId: '12345'
394
+ * })
395
+ *
396
+ * // Use the returned fileUrl in a comment
397
+ * await api.addComment({
398
+ * content: 'See attached document',
399
+ * taskId: '67890',
400
+ * attachment: {
401
+ * fileUrl: upload.fileUrl,
402
+ * fileName: upload.fileName,
403
+ * fileType: upload.fileType,
404
+ * resourceType: upload.resourceType
405
+ * }
406
+ * })
407
+ * ```
408
+ */
409
+ uploadFile(args: UploadFileArgs, requestId?: string): Promise<Attachment>;
410
+ /**
411
+ * Deletes an uploaded file by its URL.
412
+ *
413
+ * @param args - The file URL to delete.
414
+ * @param requestId - Optional custom identifier for the request.
415
+ * @returns A promise that resolves to `true` if deletion was successful.
416
+ *
417
+ * @example
418
+ * ```typescript
419
+ * await api.deleteUpload({
420
+ * fileUrl: 'https://cdn.todoist.com/...'
421
+ * })
422
+ * ```
423
+ */
424
+ deleteUpload(args: DeleteUploadArgs, requestId?: string): Promise<boolean>;
372
425
  }
@@ -46,12 +46,19 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
46
46
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
47
  }
48
48
  };
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
49
52
  Object.defineProperty(exports, "__esModule", { value: true });
50
53
  exports.TodoistApi = void 0;
51
54
  var restClient_1 = require("./restClient");
52
55
  var endpoints_1 = require("./consts/endpoints");
53
56
  var validators_1 = require("./utils/validators");
54
57
  var urlHelpers_1 = require("./utils/urlHelpers");
58
+ var form_data_1 = __importDefault(require("form-data"));
59
+ var fs_1 = require("fs");
60
+ var path_1 = require("path");
61
+ var axios_1 = __importDefault(require("axios"));
55
62
  var activity_helpers_1 = require("./utils/activity-helpers");
56
63
  var zod_1 = require("zod");
57
64
  var uuid_1 = require("uuid");
@@ -1089,6 +1096,114 @@ var TodoistApi = /** @class */ (function () {
1089
1096
  });
1090
1097
  });
1091
1098
  };
1099
+ /**
1100
+ * Uploads a file and returns attachment metadata.
1101
+ * This creates an upload record that can be referenced in tasks or comments.
1102
+ *
1103
+ * @param args - Upload parameters including file content, filename, and optional project ID.
1104
+ * @param requestId - Optional custom identifier for the request.
1105
+ * @returns A promise that resolves to the uploaded file's attachment metadata.
1106
+ *
1107
+ * @example
1108
+ * ```typescript
1109
+ * // Upload from a file path
1110
+ * const upload = await api.uploadFile({
1111
+ * file: '/path/to/document.pdf',
1112
+ * projectId: '12345'
1113
+ * })
1114
+ *
1115
+ * // Upload from a Buffer
1116
+ * const buffer = fs.readFileSync('/path/to/document.pdf')
1117
+ * const upload = await api.uploadFile({
1118
+ * file: buffer,
1119
+ * fileName: 'document.pdf', // Required for Buffer/Stream
1120
+ * projectId: '12345'
1121
+ * })
1122
+ *
1123
+ * // Use the returned fileUrl in a comment
1124
+ * await api.addComment({
1125
+ * content: 'See attached document',
1126
+ * taskId: '67890',
1127
+ * attachment: {
1128
+ * fileUrl: upload.fileUrl,
1129
+ * fileName: upload.fileName,
1130
+ * fileType: upload.fileType,
1131
+ * resourceType: upload.resourceType
1132
+ * }
1133
+ * })
1134
+ * ```
1135
+ */
1136
+ TodoistApi.prototype.uploadFile = function (args, requestId) {
1137
+ return __awaiter(this, void 0, void 0, function () {
1138
+ var form, filePath, fileName, url, headers, response;
1139
+ return __generator(this, function (_a) {
1140
+ switch (_a.label) {
1141
+ case 0:
1142
+ form = new form_data_1.default();
1143
+ // Determine file type and add to form data
1144
+ if (typeof args.file === 'string') {
1145
+ filePath = args.file;
1146
+ fileName = args.fileName || (0, path_1.basename)(filePath);
1147
+ form.append('file', (0, fs_1.createReadStream)(filePath), fileName);
1148
+ }
1149
+ else if (Buffer.isBuffer(args.file)) {
1150
+ // Buffer - require fileName
1151
+ if (!args.fileName) {
1152
+ throw new Error('fileName is required when uploading from a Buffer');
1153
+ }
1154
+ form.append('file', args.file, args.fileName);
1155
+ }
1156
+ else {
1157
+ // Stream - require fileName
1158
+ if (!args.fileName) {
1159
+ throw new Error('fileName is required when uploading from a stream');
1160
+ }
1161
+ form.append('file', args.file, args.fileName);
1162
+ }
1163
+ // Add optional project_id as a form field
1164
+ if (args.projectId) {
1165
+ form.append('project_id', args.projectId);
1166
+ }
1167
+ url = "".concat(this.syncApiBase).concat(endpoints_1.ENDPOINT_REST_UPLOADS);
1168
+ headers = __assign({ Authorization: "Bearer ".concat(this.authToken) }, form.getHeaders());
1169
+ if (requestId) {
1170
+ headers['X-Request-Id'] = requestId;
1171
+ }
1172
+ return [4 /*yield*/, axios_1.default.post(url, form, { headers: headers })];
1173
+ case 1:
1174
+ response = _a.sent();
1175
+ return [2 /*return*/, (0, validators_1.validateAttachment)(response.data)];
1176
+ }
1177
+ });
1178
+ });
1179
+ };
1180
+ /**
1181
+ * Deletes an uploaded file by its URL.
1182
+ *
1183
+ * @param args - The file URL to delete.
1184
+ * @param requestId - Optional custom identifier for the request.
1185
+ * @returns A promise that resolves to `true` if deletion was successful.
1186
+ *
1187
+ * @example
1188
+ * ```typescript
1189
+ * await api.deleteUpload({
1190
+ * fileUrl: 'https://cdn.todoist.com/...'
1191
+ * })
1192
+ * ```
1193
+ */
1194
+ TodoistApi.prototype.deleteUpload = function (args, requestId) {
1195
+ return __awaiter(this, void 0, void 0, function () {
1196
+ var response;
1197
+ return __generator(this, function (_a) {
1198
+ switch (_a.label) {
1199
+ case 0: return [4 /*yield*/, (0, restClient_1.request)('DELETE', this.syncApiBase, endpoints_1.ENDPOINT_REST_UPLOADS, this.authToken, args, requestId)];
1200
+ case 1:
1201
+ response = _a.sent();
1202
+ return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
1203
+ }
1204
+ });
1205
+ });
1206
+ };
1092
1207
  return TodoistApi;
1093
1208
  }());
1094
1209
  exports.TodoistApi = TodoistApi;
@@ -29,6 +29,15 @@ export type RevokeAuthTokenRequestArgs = {
29
29
  clientSecret: string;
30
30
  accessToken: string;
31
31
  };
32
+ /**
33
+ * Parameters required to revoke a token using RFC 7009 compliant endpoint.
34
+ * @see https://todoist.com/api/v1/docs#tag/Authorization
35
+ */
36
+ export type RevokeTokenRequestArgs = {
37
+ clientId: string;
38
+ clientSecret: string;
39
+ token: string;
40
+ };
32
41
  /**
33
42
  * Generates a random state parameter for OAuth2 authorization.
34
43
  * The state parameter helps prevent CSRF attacks.
@@ -88,7 +97,28 @@ export declare function getAuthToken(args: AuthTokenRequestArgs, baseUrl?: strin
88
97
  * })
89
98
  * ```
90
99
  *
100
+ * @deprecated Use {@link revokeToken} instead. This function uses a legacy endpoint that will be removed in a future version. The new function uses the RFC 7009 compliant endpoint.
91
101
  * @returns True if revocation was successful
92
102
  * @see https://todoist.com/api/v1/docs#tag/Authorization/operation/revoke_access_token_api_api_v1_access_tokens_delete
93
103
  */
94
104
  export declare function revokeAuthToken(args: RevokeAuthTokenRequestArgs, baseUrl?: string): Promise<boolean>;
105
+ /**
106
+ * Revokes a token using the RFC 7009 OAuth 2.0 Token Revocation standard.
107
+ *
108
+ * This function uses HTTP Basic Authentication with client credentials and follows
109
+ * the RFC 7009 specification for token revocation.
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * await revokeToken({
114
+ * clientId: 'your-client-id',
115
+ * clientSecret: 'your-client-secret',
116
+ * token: 'access-token-to-revoke'
117
+ * })
118
+ * ```
119
+ *
120
+ * @returns True if revocation was successful
121
+ * @see https://datatracker.ietf.org/doc/html/rfc7009
122
+ * @see https://todoist.com/api/v1/docs#tag/Authorization
123
+ */
124
+ export declare function revokeToken(args: RevokeTokenRequestArgs, baseUrl?: string): Promise<boolean>;
@@ -40,10 +40,21 @@ exports.getAuthStateParameter = getAuthStateParameter;
40
40
  exports.getAuthorizationUrl = getAuthorizationUrl;
41
41
  exports.getAuthToken = getAuthToken;
42
42
  exports.revokeAuthToken = revokeAuthToken;
43
+ exports.revokeToken = revokeToken;
43
44
  var restClient_1 = require("./restClient");
44
45
  var uuid_1 = require("uuid");
45
46
  var types_1 = require("./types");
46
47
  var endpoints_1 = require("./consts/endpoints");
48
+ /**
49
+ * Creates a Basic Authentication header value from client credentials.
50
+ * @param clientId - The OAuth client ID
51
+ * @param clientSecret - The OAuth client secret
52
+ * @returns The Basic Auth header value (without the 'Basic ' prefix)
53
+ */
54
+ function createBasicAuthHeader(clientId, clientSecret) {
55
+ var credentials = "".concat(clientId, ":").concat(clientSecret);
56
+ return Buffer.from(credentials).toString('base64');
57
+ }
47
58
  /**
48
59
  * Generates a random state parameter for OAuth2 authorization.
49
60
  * The state parameter helps prevent CSRF attacks.
@@ -127,6 +138,7 @@ function getAuthToken(args, baseUrl) {
127
138
  * })
128
139
  * ```
129
140
  *
141
+ * @deprecated Use {@link revokeToken} instead. This function uses a legacy endpoint that will be removed in a future version. The new function uses the RFC 7009 compliant endpoint.
130
142
  * @returns True if revocation was successful
131
143
  * @see https://todoist.com/api/v1/docs#tag/Authorization/operation/revoke_access_token_api_api_v1_access_tokens_delete
132
144
  */
@@ -143,3 +155,45 @@ function revokeAuthToken(args, baseUrl) {
143
155
  });
144
156
  });
145
157
  }
158
+ /**
159
+ * Revokes a token using the RFC 7009 OAuth 2.0 Token Revocation standard.
160
+ *
161
+ * This function uses HTTP Basic Authentication with client credentials and follows
162
+ * the RFC 7009 specification for token revocation.
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * await revokeToken({
167
+ * clientId: 'your-client-id',
168
+ * clientSecret: 'your-client-secret',
169
+ * token: 'access-token-to-revoke'
170
+ * })
171
+ * ```
172
+ *
173
+ * @returns True if revocation was successful
174
+ * @see https://datatracker.ietf.org/doc/html/rfc7009
175
+ * @see https://todoist.com/api/v1/docs#tag/Authorization
176
+ */
177
+ function revokeToken(args, baseUrl) {
178
+ return __awaiter(this, void 0, void 0, function () {
179
+ var clientId, clientSecret, token, basicAuth, customHeaders, requestBody, response;
180
+ return __generator(this, function (_a) {
181
+ switch (_a.label) {
182
+ case 0:
183
+ clientId = args.clientId, clientSecret = args.clientSecret, token = args.token;
184
+ basicAuth = createBasicAuthHeader(clientId, clientSecret);
185
+ customHeaders = {
186
+ Authorization: "Basic ".concat(basicAuth),
187
+ };
188
+ requestBody = {
189
+ token: token,
190
+ token_type_hint: 'access_token',
191
+ };
192
+ return [4 /*yield*/, (0, restClient_1.request)('POST', (0, endpoints_1.getSyncBaseUri)(baseUrl), endpoints_1.ENDPOINT_REVOKE, undefined, requestBody, undefined, false, customHeaders)];
193
+ case 1:
194
+ response = _a.sent();
195
+ return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
196
+ }
197
+ });
198
+ });
199
+ }
@@ -23,6 +23,7 @@ export declare const ENDPOINT_REST_PROJECT_COLLABORATORS = "collaborators";
23
23
  export declare const ENDPOINT_REST_USER = "user";
24
24
  export declare const ENDPOINT_REST_PRODUCTIVITY: string;
25
25
  export declare const ENDPOINT_REST_ACTIVITIES = "activities";
26
+ export declare const ENDPOINT_REST_UPLOADS = "uploads";
26
27
  export declare const PROJECT_ARCHIVE = "archive";
27
28
  export declare const PROJECT_UNARCHIVE = "unarchive";
28
29
  export declare const ENDPOINT_SYNC_QUICK_ADD: string;
@@ -30,3 +31,4 @@ export declare const ENDPOINT_SYNC = "sync";
30
31
  export declare const ENDPOINT_AUTHORIZATION = "authorize";
31
32
  export declare const ENDPOINT_GET_TOKEN = "access_token";
32
33
  export declare const ENDPOINT_REVOKE_TOKEN = "access_tokens/revoke";
34
+ export declare const ENDPOINT_REVOKE = "revoke";
@@ -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_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;
3
+ exports.ENDPOINT_REVOKE = 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_UPLOADS = 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';
@@ -39,6 +39,7 @@ exports.ENDPOINT_REST_PROJECT_COLLABORATORS = 'collaborators';
39
39
  exports.ENDPOINT_REST_USER = 'user';
40
40
  exports.ENDPOINT_REST_PRODUCTIVITY = exports.ENDPOINT_REST_TASKS + '/completed/stats';
41
41
  exports.ENDPOINT_REST_ACTIVITIES = 'activities';
42
+ exports.ENDPOINT_REST_UPLOADS = 'uploads';
42
43
  exports.PROJECT_ARCHIVE = 'archive';
43
44
  exports.PROJECT_UNARCHIVE = 'unarchive';
44
45
  exports.ENDPOINT_SYNC_QUICK_ADD = exports.ENDPOINT_REST_TASKS + '/quick';
@@ -46,3 +47,4 @@ exports.ENDPOINT_SYNC = 'sync';
46
47
  exports.ENDPOINT_AUTHORIZATION = 'authorize';
47
48
  exports.ENDPOINT_GET_TOKEN = 'access_token';
48
49
  exports.ENDPOINT_REVOKE_TOKEN = 'access_tokens/revoke';
50
+ exports.ENDPOINT_REVOKE = 'revoke';
@@ -2,4 +2,4 @@ import { AxiosResponse } from 'axios';
2
2
  import { HttpMethod } from './types/http';
3
3
  export declare function paramsSerializer(params: Record<string, unknown>): string;
4
4
  export declare function isSuccess(response: AxiosResponse): boolean;
5
- export declare function request<T>(httpMethod: HttpMethod, baseUri: string, relativePath: string, apiToken?: string, payload?: Record<string, unknown>, requestId?: string, hasSyncCommands?: boolean): Promise<AxiosResponse<T>>;
5
+ export declare function request<T>(httpMethod: HttpMethod, baseUri: string, relativePath: string, apiToken?: string, payload?: Record<string, unknown>, requestId?: string, hasSyncCommands?: boolean, customHeaders?: Record<string, string>): Promise<AxiosResponse<T>>;
@@ -100,14 +100,14 @@ function getTodoistRequestError(error, originalStack) {
100
100
  }
101
101
  return requestError;
102
102
  }
103
- function getRequestConfiguration(baseURL, apiToken, requestId) {
103
+ function getRequestConfiguration(baseURL, apiToken, requestId, customHeaders) {
104
104
  var authHeader = apiToken ? { Authorization: getAuthHeader(apiToken) } : undefined;
105
105
  var requestIdHeader = requestId ? { 'X-Request-Id': requestId } : undefined;
106
- var headers = __assign(__assign(__assign({}, defaultHeaders), authHeader), requestIdHeader);
106
+ var headers = __assign(__assign(__assign(__assign({}, defaultHeaders), authHeader), requestIdHeader), customHeaders);
107
107
  return { baseURL: baseURL, headers: headers };
108
108
  }
109
- function getAxiosClient(baseURL, apiToken, requestId) {
110
- var configuration = getRequestConfiguration(baseURL, apiToken, requestId);
109
+ function getAxiosClient(baseURL, apiToken, requestId, customHeaders) {
110
+ var configuration = getRequestConfiguration(baseURL, apiToken, requestId, customHeaders);
111
111
  var client = (0, axios_case_converter_1.default)(axios_1.default.create(configuration), {
112
112
  caseFunctions: {
113
113
  camel: processing_helpers_1.customCamelCase,
@@ -123,7 +123,7 @@ function getAxiosClient(baseURL, apiToken, requestId) {
123
123
  function isSuccess(response) {
124
124
  return response.status >= 200 && response.status < 300;
125
125
  }
126
- function request(httpMethod, baseUri, relativePath, apiToken, payload, requestId, hasSyncCommands) {
126
+ function request(httpMethod, baseUri, relativePath, apiToken, payload, requestId, hasSyncCommands, customHeaders) {
127
127
  return __awaiter(this, void 0, void 0, function () {
128
128
  var originalStack, axiosClient, _a, error_1;
129
129
  return __generator(this, function (_b) {
@@ -137,7 +137,7 @@ function request(httpMethod, baseUri, relativePath, apiToken, payload, requestId
137
137
  if (httpMethod === 'POST' && !requestId && !baseUri.includes(endpoints_1.API_BASE_URI)) {
138
138
  requestId = (0, uuid_1.v4)();
139
139
  }
140
- axiosClient = getAxiosClient(baseUri, apiToken, requestId);
140
+ axiosClient = getAxiosClient(baseUri, apiToken, requestId, customHeaders);
141
141
  _a = httpMethod;
142
142
  switch (_a) {
143
143
  case 'GET': return [3 /*break*/, 2];
@@ -703,7 +703,7 @@ export declare const ActivityEventSchema: z.ZodObject<{
703
703
  objectId: z.ZodString;
704
704
  eventType: z.ZodString;
705
705
  eventDate: z.ZodString;
706
- id: z.ZodNullable<z.ZodString>;
706
+ id: z.ZodNullable<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>>;
707
707
  parentProjectId: z.ZodNullable<z.ZodString>;
708
708
  parentItemId: z.ZodNullable<z.ZodString>;
709
709
  initiatorId: z.ZodNullable<z.ZodString>;
@@ -310,7 +310,10 @@ exports.ActivityEventSchema = zod_1.z
310
310
  objectId: zod_1.z.string(),
311
311
  eventType: zod_1.z.string(),
312
312
  eventDate: zod_1.z.string(),
313
- id: zod_1.z.string().nullable(),
313
+ id: zod_1.z
314
+ .union([zod_1.z.string(), zod_1.z.number()])
315
+ .transform(function (val) { var _a; return (_a = val === null || val === void 0 ? void 0 : val.toString()) !== null && _a !== void 0 ? _a : null; })
316
+ .nullable(),
314
317
  parentProjectId: zod_1.z.string().nullable(),
315
318
  parentItemId: zod_1.z.string().nullable(),
316
319
  initiatorId: zod_1.z.string().nullable(),
@@ -478,4 +478,36 @@ export type GetActivityLogsResponse = {
478
478
  results: ActivityEvent[];
479
479
  nextCursor: string | null;
480
480
  };
481
+ /**
482
+ * Arguments for uploading a file.
483
+ * @see https://todoist.com/api/v1/docs#tag/Uploads/operation/upload_file_api_v1_uploads_post
484
+ */
485
+ export type UploadFileArgs = {
486
+ /**
487
+ * The file content to upload. Can be:
488
+ * - Buffer: File content as a Buffer (requires fileName)
489
+ * - ReadableStream: File content as a stream (requires fileName)
490
+ * - string: Path to a file on the filesystem (fileName is optional, will be inferred from path)
491
+ */
492
+ file: Buffer | NodeJS.ReadableStream | string;
493
+ /**
494
+ * The name of the file. Required for Buffer and Stream inputs.
495
+ * Optional for file path strings (will be inferred from the path if not provided).
496
+ */
497
+ fileName?: string;
498
+ /**
499
+ * The project ID to associate the upload with.
500
+ */
501
+ projectId?: string | null;
502
+ };
503
+ /**
504
+ * Arguments for deleting an uploaded file.
505
+ * @see https://todoist.com/api/v1/docs#tag/Uploads/operation/delete_upload_api_v1_uploads_delete
506
+ */
507
+ export type DeleteUploadArgs = {
508
+ /**
509
+ * The URL of the file to delete.
510
+ */
511
+ fileUrl: string;
512
+ };
481
513
  export {};
@@ -1,4 +1,4 @@
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';
1
+ import { type Attachment, 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
  /**
@@ -32,3 +32,4 @@ export declare function validateProductivityStats(input: unknown): ProductivityS
32
32
  export declare function validateCurrentUser(input: unknown): CurrentUser;
33
33
  export declare function validateActivityEvent(input: unknown): ActivityEvent;
34
34
  export declare function validateActivityEventArray(input: unknown[]): ActivityEvent[];
35
+ export declare function validateAttachment(input: unknown): Attachment;
@@ -18,6 +18,7 @@ exports.validateProductivityStats = validateProductivityStats;
18
18
  exports.validateCurrentUser = validateCurrentUser;
19
19
  exports.validateActivityEvent = validateActivityEvent;
20
20
  exports.validateActivityEventArray = validateActivityEventArray;
21
+ exports.validateAttachment = validateAttachment;
21
22
  var entities_1 = require("../types/entities");
22
23
  function validateTask(input) {
23
24
  return entities_1.TaskSchema.parse(input);
@@ -91,3 +92,6 @@ function validateActivityEvent(input) {
91
92
  function validateActivityEventArray(input) {
92
93
  return input.map(validateActivityEvent);
93
94
  }
95
+ function validateAttachment(input) {
96
+ return entities_1.AttachmentSchema.parse(input);
97
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/todoist-api-typescript",
3
- "version": "5.7.0",
3
+ "version": "5.8.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",
@@ -28,10 +28,11 @@
28
28
  "axios-case-converter": "^1.0.0",
29
29
  "axios-retry": "^4.0.0",
30
30
  "camelcase": "6.3.0",
31
- "emoji-regex": "10.5.0",
31
+ "emoji-regex": "10.6.0",
32
+ "form-data": "4.0.4",
32
33
  "ts-custom-error": "^3.2.0",
33
34
  "uuid": "11.1.0",
34
- "zod": "4.1.5"
35
+ "zod": "4.1.12"
35
36
  },
36
37
  "devDependencies": {
37
38
  "@doist/eslint-config": "11.1.0",
@@ -50,10 +51,10 @@
50
51
  "npm-run-all2": "8.0.4",
51
52
  "prettier": "3.3.2",
52
53
  "rimraf": "6.0.1",
53
- "ts-jest": "29.4.1",
54
+ "ts-jest": "29.4.5",
54
55
  "ts-node": "10.9.2",
55
56
  "type-fest": "^4.12.0",
56
- "typescript": "5.9.2"
57
+ "typescript": "5.9.3"
57
58
  },
58
59
  "peerDependencies": {
59
60
  "type-fest": "^4.12.0"