@doist/todoist-api-typescript 7.5.0 → 7.6.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/authentication.js +46 -2
- package/dist/cjs/consts/endpoints.js +54 -2
- package/dist/cjs/todoist-api.js +518 -0
- package/dist/cjs/types/entities.js +116 -1
- package/dist/cjs/types/requests.js +22 -1
- package/dist/cjs/utils/validators.js +19 -2
- package/dist/esm/authentication.js +46 -3
- package/dist/esm/consts/endpoints.js +43 -0
- package/dist/esm/todoist-api.js +520 -2
- package/dist/esm/types/entities.js +114 -0
- package/dist/esm/types/requests.js +21 -0
- package/dist/esm/utils/validators.js +19 -2
- package/dist/types/authentication.d.ts +51 -6
- package/dist/types/consts/endpoints.d.ts +22 -0
- package/dist/types/todoist-api.d.ts +195 -4
- package/dist/types/types/entities.d.ts +254 -14
- package/dist/types/types/requests.d.ts +383 -51
- package/dist/types/types/sync/resources/user.d.ts +2 -2
- package/dist/types/types/sync/resources/view-options.d.ts +5 -5
- package/dist/types/types/sync/user-preferences.d.ts +1 -1
- package/dist/types/utils/validators.d.ts +198 -6
- package/package.json +1 -1
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REMINDER_DELIVERY_SERVICES = void 0;
|
|
3
|
+
exports.MOVED_ID_OBJECT_TYPES = exports.ID_MAPPING_OBJECT_TYPES = exports.EMAIL_OBJECT_TYPES = exports.REMINDER_DELIVERY_SERVICES = void 0;
|
|
4
4
|
/** Available reminder delivery services. */
|
|
5
5
|
exports.REMINDER_DELIVERY_SERVICES = ['email', 'push'];
|
|
6
|
+
// Email forwarding types
|
|
7
|
+
/** Object types that support email forwarding. */
|
|
8
|
+
exports.EMAIL_OBJECT_TYPES = ['project', 'project_comments', 'task'];
|
|
9
|
+
// ID mapping types
|
|
10
|
+
/** Object types that support ID mappings. */
|
|
11
|
+
exports.ID_MAPPING_OBJECT_TYPES = [
|
|
12
|
+
'sections',
|
|
13
|
+
'tasks',
|
|
14
|
+
'comments',
|
|
15
|
+
'reminders',
|
|
16
|
+
'location_reminders',
|
|
17
|
+
'projects',
|
|
18
|
+
];
|
|
19
|
+
/** Object types that support moved ID lookups. */
|
|
20
|
+
exports.MOVED_ID_OBJECT_TYPES = [
|
|
21
|
+
'sections',
|
|
22
|
+
'tasks',
|
|
23
|
+
'comments',
|
|
24
|
+
'reminders',
|
|
25
|
+
'location_reminders',
|
|
26
|
+
];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.validateSuggestionArray = exports.validateSuggestion = exports.validateUserSettings = exports.validateSyncUser = exports.validateSyncWorkspaceArray = exports.validateSyncWorkspace = exports.validateLiveNotificationArray = exports.validateLiveNotification = void 0;
|
|
3
|
+
exports.validateWorkspaceFilterArray = exports.validateWorkspaceFilter = exports.validateTooltips = exports.validateNoteArray = exports.validateNote = exports.validateFolderArray = exports.validateFolder = exports.validateCollaboratorStateArray = exports.validateCollaboratorState = exports.validateCollaboratorArray = exports.validateCollaborator = exports.validateFilterArray = exports.validateFilter = exports.validateMovedIdArray = exports.validateMovedId = exports.validateIdMappingArray = exports.validateIdMapping = exports.validateBackupArray = exports.validateBackup = exports.validateWorkspaceInsights = exports.validateProjectProgress = exports.validateProjectHealthContext = exports.validateProjectHealth = exports.validateProjectActivityStats = exports.validateWorkspaceUserTaskArray = exports.validateWorkspaceUserTask = exports.validateMemberActivityInfoArray = exports.validateMemberActivityInfo = exports.validateWorkspaceArray = exports.validateWorkspace = exports.validateJoinWorkspaceResult = exports.validateWorkspacePlanDetails = exports.validateWorkspaceInvitationArray = exports.validateWorkspaceInvitation = exports.validateWorkspaceUser = exports.validateAttachment = exports.validateActivityEventArray = exports.validateActivityEvent = exports.validateCurrentUser = exports.validateProductivityStats = exports.validateUserArray = exports.validateUser = exports.validateCommentArray = exports.validateComment = exports.validateLabelArray = exports.validateLabel = exports.validateSectionArray = exports.validateSection = exports.validateTaskArray = exports.validateTask = void 0;
|
|
4
|
+
exports.validateSuggestionArray = exports.validateSuggestion = exports.validateUserSettings = exports.validateSyncUser = exports.validateSyncWorkspaceArray = exports.validateSyncWorkspace = exports.validateLiveNotificationArray = exports.validateLiveNotification = exports.validateUserPlanLimits = exports.validateProjectViewOptionsDefaultsArray = exports.validateProjectViewOptionsDefaults = exports.validateViewOptionsArray = exports.validateViewOptions = exports.validateCompletedInfoArray = exports.validateCompletedInfo = exports.validateLocationReminderArray = exports.validateLocationReminder = exports.validateReminderArray = exports.validateReminder = exports.validateCalendarAccountArray = exports.validateCalendarAccount = exports.validateCalendarArray = exports.validateCalendar = exports.validateWorkspaceGoalArray = exports.validateWorkspaceGoal = void 0;
|
|
5
5
|
exports.isWorkspaceProject = isWorkspaceProject;
|
|
6
6
|
exports.isPersonalProject = isPersonalProject;
|
|
7
7
|
exports.validateProject = validateProject;
|
|
@@ -74,6 +74,21 @@ exports.validateWorkspacePlanDetails = createValidator(entities_1.WorkspacePlanD
|
|
|
74
74
|
exports.validateJoinWorkspaceResult = createValidator(entities_1.JoinWorkspaceResultSchema);
|
|
75
75
|
exports.validateWorkspace = createValidator(entities_1.WorkspaceSchema);
|
|
76
76
|
exports.validateWorkspaceArray = createArrayValidator(exports.validateWorkspace);
|
|
77
|
+
exports.validateMemberActivityInfo = createValidator(entities_1.MemberActivityInfoSchema);
|
|
78
|
+
exports.validateMemberActivityInfoArray = createArrayValidator(exports.validateMemberActivityInfo);
|
|
79
|
+
exports.validateWorkspaceUserTask = createValidator(entities_1.WorkspaceUserTaskSchema);
|
|
80
|
+
exports.validateWorkspaceUserTaskArray = createArrayValidator(exports.validateWorkspaceUserTask);
|
|
81
|
+
exports.validateProjectActivityStats = createValidator(entities_1.ProjectActivityStatsSchema);
|
|
82
|
+
exports.validateProjectHealth = createValidator(entities_1.ProjectHealthSchema);
|
|
83
|
+
exports.validateProjectHealthContext = createValidator(entities_1.ProjectHealthContextSchema);
|
|
84
|
+
exports.validateProjectProgress = createValidator(entities_1.ProjectProgressSchema);
|
|
85
|
+
exports.validateWorkspaceInsights = createValidator(entities_1.WorkspaceInsightsSchema);
|
|
86
|
+
exports.validateBackup = createValidator(entities_1.BackupSchema);
|
|
87
|
+
exports.validateBackupArray = createArrayValidator(exports.validateBackup);
|
|
88
|
+
exports.validateIdMapping = createValidator(entities_1.IdMappingSchema);
|
|
89
|
+
exports.validateIdMappingArray = createArrayValidator(exports.validateIdMapping);
|
|
90
|
+
exports.validateMovedId = createValidator(entities_1.MovedIdSchema);
|
|
91
|
+
exports.validateMovedIdArray = createArrayValidator(exports.validateMovedId);
|
|
77
92
|
// Sync resource validators
|
|
78
93
|
exports.validateFilter = createValidator(resources_1.FilterSchema);
|
|
79
94
|
exports.validateFilterArray = createArrayValidator(exports.validateFilter);
|
|
@@ -96,6 +111,8 @@ exports.validateCalendarAccount = createValidator(resources_1.CalendarAccountSch
|
|
|
96
111
|
exports.validateCalendarAccountArray = createArrayValidator(exports.validateCalendarAccount);
|
|
97
112
|
exports.validateReminder = createValidator(resources_1.ReminderSchema);
|
|
98
113
|
exports.validateReminderArray = createArrayValidator(exports.validateReminder);
|
|
114
|
+
exports.validateLocationReminder = createValidator(resources_1.LocationReminderSchema);
|
|
115
|
+
exports.validateLocationReminderArray = createArrayValidator(exports.validateLocationReminder);
|
|
99
116
|
exports.validateCompletedInfo = createValidator(resources_1.CompletedInfoSchema);
|
|
100
117
|
exports.validateCompletedInfoArray = createArrayValidator(exports.validateCompletedInfo);
|
|
101
118
|
exports.validateViewOptions = createValidator(resources_1.ViewOptionsSchema);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { request, isSuccess } from './transport/http-client.js';
|
|
2
2
|
import { v4 as uuid } from 'uuid';
|
|
3
3
|
import { TodoistRequestError } from './types/index.js';
|
|
4
|
-
import { getAuthBaseUri, getSyncBaseUri, ENDPOINT_AUTHORIZATION, ENDPOINT_GET_TOKEN, ENDPOINT_REVOKE, } from './consts/endpoints.js';
|
|
4
|
+
import { getAuthBaseUri, getSyncBaseUri, ENDPOINT_AUTHORIZATION, ENDPOINT_GET_TOKEN, ENDPOINT_REVOKE, ENDPOINT_REST_ACCESS_TOKENS_MIGRATE, } from './consts/endpoints.js';
|
|
5
5
|
/** Available OAuth2 permission scopes. */
|
|
6
6
|
export const PERMISSIONS = [
|
|
7
7
|
'task:add',
|
|
@@ -51,7 +51,7 @@ export function getAuthStateParameter() {
|
|
|
51
51
|
* ```
|
|
52
52
|
*
|
|
53
53
|
* @returns The full authorization URL to redirect users to
|
|
54
|
-
* @see https://todoist.com/api/v1
|
|
54
|
+
* @see https://developer.todoist.com/api/v1/#tag/Authorization/OAuth
|
|
55
55
|
*/
|
|
56
56
|
export function getAuthorizationUrl({ clientId, permissions, state, baseUrl, }) {
|
|
57
57
|
if (!(permissions === null || permissions === void 0 ? void 0 : permissions.length)) {
|
|
@@ -119,7 +119,7 @@ export async function getAuthToken(args, options) {
|
|
|
119
119
|
*
|
|
120
120
|
* @returns True if revocation was successful
|
|
121
121
|
* @see https://datatracker.ietf.org/doc/html/rfc7009
|
|
122
|
-
* @see https://todoist.com/api/v1
|
|
122
|
+
* @see https://developer.todoist.com/api/v1/#tag/Authorization
|
|
123
123
|
*/
|
|
124
124
|
export async function revokeToken(args, options) {
|
|
125
125
|
if (typeof options === 'string') {
|
|
@@ -151,3 +151,46 @@ export async function revokeToken(args, options) {
|
|
|
151
151
|
});
|
|
152
152
|
return isSuccess(response);
|
|
153
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Migrates a personal API token to an OAuth access token.
|
|
156
|
+
*
|
|
157
|
+
* This allows applications to transition users from personal API tokens
|
|
158
|
+
* to proper OAuth tokens without requiring the user to go through the
|
|
159
|
+
* full OAuth authorization flow.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* const { accessToken } = await migratePersonalToken({
|
|
164
|
+
* clientId: 'your-client-id',
|
|
165
|
+
* clientSecret: 'your-client-secret',
|
|
166
|
+
* personalToken: 'user-personal-token',
|
|
167
|
+
* scope: 'data:read_write,data:delete'
|
|
168
|
+
* })
|
|
169
|
+
* ```
|
|
170
|
+
*
|
|
171
|
+
* @returns The new OAuth token response
|
|
172
|
+
* @throws {@link TodoistRequestError} If the migration fails
|
|
173
|
+
*/
|
|
174
|
+
export async function migratePersonalToken(args, options) {
|
|
175
|
+
var _a;
|
|
176
|
+
const baseUrl = options === null || options === void 0 ? void 0 : options.baseUrl;
|
|
177
|
+
const customFetch = options === null || options === void 0 ? void 0 : options.customFetch;
|
|
178
|
+
try {
|
|
179
|
+
const response = await request({
|
|
180
|
+
httpMethod: 'POST',
|
|
181
|
+
baseUri: getSyncBaseUri(baseUrl),
|
|
182
|
+
relativePath: ENDPOINT_REST_ACCESS_TOKENS_MIGRATE,
|
|
183
|
+
apiToken: undefined,
|
|
184
|
+
payload: Object.assign(Object.assign({}, args), { scope: args.scope.join(',') }),
|
|
185
|
+
customFetch,
|
|
186
|
+
});
|
|
187
|
+
if (response.status !== 200 || !((_a = response.data) === null || _a === void 0 ? void 0 : _a.accessToken)) {
|
|
188
|
+
throw new TodoistRequestError('Personal token migration failed.', response.status, response.data);
|
|
189
|
+
}
|
|
190
|
+
return response.data;
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
const err = error;
|
|
194
|
+
throw new TodoistRequestError('Personal token migration failed.', err.httpStatusCode, err.responseData);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
@@ -48,6 +48,18 @@ export const SECTION_ARCHIVE = 'archive';
|
|
|
48
48
|
export const SECTION_UNARCHIVE = 'unarchive';
|
|
49
49
|
export const ENDPOINT_REST_PROJECTS_MOVE_TO_WORKSPACE = ENDPOINT_REST_PROJECTS + '/move_to_workspace';
|
|
50
50
|
export const ENDPOINT_REST_PROJECTS_MOVE_TO_PERSONAL = ENDPOINT_REST_PROJECTS + '/move_to_personal';
|
|
51
|
+
export const ENDPOINT_REST_TASKS_COMPLETED = ENDPOINT_REST_TASKS + '/completed';
|
|
52
|
+
export const ENDPOINT_REST_TEMPLATES_FILE = 'templates/file';
|
|
53
|
+
export const ENDPOINT_REST_TEMPLATES_URL = 'templates/url';
|
|
54
|
+
export const ENDPOINT_REST_TEMPLATES_CREATE_FROM_FILE = 'templates/create_project_from_file';
|
|
55
|
+
export const ENDPOINT_REST_TEMPLATES_IMPORT_FROM_FILE = 'templates/import_into_project_from_file';
|
|
56
|
+
export const ENDPOINT_REST_TEMPLATES_IMPORT_FROM_ID = 'templates/import_into_project_from_template_id';
|
|
57
|
+
export const ENDPOINT_REST_ACCESS_TOKENS_MIGRATE = 'access_tokens/migrate_personal_token';
|
|
58
|
+
export const ENDPOINT_REST_BACKUPS = 'backups';
|
|
59
|
+
export const ENDPOINT_REST_BACKUPS_DOWNLOAD = 'backups/download';
|
|
60
|
+
export const ENDPOINT_REST_EMAILS = 'emails';
|
|
61
|
+
export const ENDPOINT_REST_ID_MAPPINGS = 'id_mappings';
|
|
62
|
+
export const ENDPOINT_REST_MOVED_IDS = 'moved_ids';
|
|
51
63
|
export const ENDPOINT_SYNC_QUICK_ADD = ENDPOINT_REST_TASKS + '/quick';
|
|
52
64
|
export const ENDPOINT_SYNC = 'sync';
|
|
53
65
|
export const ENDPOINT_AUTHORIZATION = 'authorize';
|
|
@@ -69,6 +81,37 @@ export function getWorkspaceInvitationAcceptEndpoint(inviteCode) {
|
|
|
69
81
|
export function getWorkspaceInvitationRejectEndpoint(inviteCode) {
|
|
70
82
|
return `workspaces/invitations/${inviteCode}/reject`;
|
|
71
83
|
}
|
|
84
|
+
// Insights endpoints
|
|
85
|
+
export function getProjectInsightsActivityStatsEndpoint(projectId) {
|
|
86
|
+
return `projects/${projectId}/insights/activity_stats`;
|
|
87
|
+
}
|
|
88
|
+
export function getProjectInsightsHealthEndpoint(projectId) {
|
|
89
|
+
return `projects/${projectId}/insights/health`;
|
|
90
|
+
}
|
|
91
|
+
export function getProjectInsightsHealthContextEndpoint(projectId) {
|
|
92
|
+
return `projects/${projectId}/insights/health/context`;
|
|
93
|
+
}
|
|
94
|
+
export function getProjectInsightsProgressEndpoint(projectId) {
|
|
95
|
+
return `projects/${projectId}/insights/progress`;
|
|
96
|
+
}
|
|
97
|
+
export function getProjectInsightsHealthAnalyzeEndpoint(projectId) {
|
|
98
|
+
return `projects/${projectId}/insights/health/analyze`;
|
|
99
|
+
}
|
|
100
|
+
export function getWorkspaceInsightsEndpoint(workspaceId) {
|
|
101
|
+
return `workspaces/${workspaceId}/insights`;
|
|
102
|
+
}
|
|
103
|
+
// Workspace members
|
|
104
|
+
export const ENDPOINT_WORKSPACE_MEMBERS = 'workspaces/members';
|
|
105
|
+
// Workspace user management (require workspace_id and/or user_id parameters)
|
|
106
|
+
export function getWorkspaceUserTasksEndpoint(workspaceId, userId) {
|
|
107
|
+
return `workspaces/${workspaceId}/users/${userId}/tasks`;
|
|
108
|
+
}
|
|
109
|
+
export function getWorkspaceInviteUsersEndpoint(workspaceId) {
|
|
110
|
+
return `workspaces/${workspaceId}/users/invite`;
|
|
111
|
+
}
|
|
112
|
+
export function getWorkspaceUserEndpoint(workspaceId, userId) {
|
|
113
|
+
return `workspaces/${workspaceId}/users/${userId}`;
|
|
114
|
+
}
|
|
72
115
|
// Workspace projects (require workspace_id parameter)
|
|
73
116
|
export function getWorkspaceActiveProjectsEndpoint(workspaceId) {
|
|
74
117
|
return `workspaces/${workspaceId}/projects/active`;
|