@doist/todoist-api-typescript 6.5.0 → 6.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/todoist-api.js +32 -4
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/sync/commands/calendars.js +2 -0
- package/dist/cjs/types/sync/commands/filters.js +2 -0
- package/dist/cjs/types/sync/commands/folders.js +2 -0
- package/dist/cjs/types/sync/commands/index.js +35 -0
- package/dist/cjs/types/sync/commands/labels.js +2 -0
- package/dist/cjs/types/sync/commands/notes.js +2 -0
- package/dist/cjs/types/sync/commands/notifications.js +2 -0
- package/dist/cjs/types/sync/commands/others.js +2 -0
- package/dist/cjs/types/sync/commands/project-view-options.js +2 -0
- package/dist/cjs/types/sync/commands/projects.js +2 -0
- package/dist/cjs/types/sync/commands/reminders.js +2 -0
- package/dist/cjs/types/sync/commands/sections.js +2 -0
- package/dist/cjs/types/sync/commands/shared.js +5 -0
- package/dist/cjs/types/sync/commands/sharing.js +2 -0
- package/dist/cjs/types/sync/commands/tasks.js +2 -0
- package/dist/cjs/types/sync/commands/view-options.js +2 -0
- package/dist/cjs/types/sync/commands/workspace-filters.js +2 -0
- package/dist/cjs/types/sync/commands/workspace-goals.js +2 -0
- package/dist/cjs/types/sync/commands/workspaces.js +2 -0
- package/dist/cjs/types/sync/index.js +21 -0
- package/dist/cjs/types/sync/request.js +2 -0
- package/dist/cjs/types/{sync.js → sync/resource-types.js} +9 -0
- package/dist/cjs/types/sync/resources/calendars.js +27 -0
- package/dist/cjs/types/sync/resources/collaborators.js +23 -0
- package/dist/cjs/types/sync/resources/completed-info.js +30 -0
- package/dist/cjs/types/sync/resources/filters.js +16 -0
- package/dist/cjs/types/sync/resources/folders.js +14 -0
- package/dist/cjs/types/sync/resources/index.js +33 -0
- package/dist/cjs/types/sync/resources/live-notifications.js +28 -0
- package/dist/cjs/types/sync/resources/notes.js +23 -0
- package/dist/cjs/types/sync/resources/reminders.js +34 -0
- package/dist/cjs/types/sync/resources/suggestions.js +38 -0
- package/dist/cjs/types/sync/resources/tooltips.js +10 -0
- package/dist/cjs/types/sync/resources/user-plan-limits.js +24 -0
- package/dist/cjs/types/sync/resources/user-settings.js +42 -0
- package/dist/cjs/types/sync/resources/user.js +123 -0
- package/dist/cjs/types/sync/resources/view-options.js +75 -0
- package/dist/cjs/types/sync/resources/workspace-filters.js +21 -0
- package/dist/cjs/types/sync/resources/workspace-goals.js +32 -0
- package/dist/cjs/types/sync/resources/workspaces.js +49 -0
- package/dist/cjs/types/sync/response.js +2 -0
- package/dist/cjs/utils/index.js +3 -1
- package/dist/cjs/utils/multipart-upload.js +93 -42
- package/dist/cjs/utils/sync-helpers.js +22 -0
- package/dist/cjs/utils/validators.js +69 -88
- package/dist/esm/todoist-api.js +32 -4
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/sync/commands/calendars.js +1 -0
- package/dist/esm/types/sync/commands/filters.js +1 -0
- package/dist/esm/types/sync/commands/folders.js +1 -0
- package/dist/esm/types/sync/commands/index.js +19 -0
- package/dist/esm/types/sync/commands/labels.js +1 -0
- package/dist/esm/types/sync/commands/notes.js +1 -0
- package/dist/esm/types/sync/commands/notifications.js +1 -0
- package/dist/esm/types/sync/commands/others.js +1 -0
- package/dist/esm/types/sync/commands/project-view-options.js +1 -0
- package/dist/esm/types/sync/commands/projects.js +1 -0
- package/dist/esm/types/sync/commands/reminders.js +1 -0
- package/dist/esm/types/sync/commands/sections.js +1 -0
- package/dist/esm/types/sync/commands/shared.js +4 -0
- package/dist/esm/types/sync/commands/sharing.js +1 -0
- package/dist/esm/types/sync/commands/tasks.js +1 -0
- package/dist/esm/types/sync/commands/view-options.js +1 -0
- package/dist/esm/types/sync/commands/workspace-filters.js +1 -0
- package/dist/esm/types/sync/commands/workspace-goals.js +1 -0
- package/dist/esm/types/sync/commands/workspaces.js +1 -0
- package/dist/esm/types/sync/index.js +5 -0
- package/dist/esm/types/sync/request.js +1 -0
- package/dist/esm/types/{sync.js → sync/resource-types.js} +9 -0
- package/dist/esm/types/sync/resources/calendars.js +24 -0
- package/dist/esm/types/sync/resources/collaborators.js +20 -0
- package/dist/esm/types/sync/resources/completed-info.js +27 -0
- package/dist/esm/types/sync/resources/filters.js +13 -0
- package/dist/esm/types/sync/resources/folders.js +11 -0
- package/dist/esm/types/sync/resources/index.js +17 -0
- package/dist/esm/types/sync/resources/live-notifications.js +25 -0
- package/dist/esm/types/sync/resources/notes.js +20 -0
- package/dist/esm/types/sync/resources/reminders.js +31 -0
- package/dist/esm/types/sync/resources/suggestions.js +35 -0
- package/dist/esm/types/sync/resources/tooltips.js +7 -0
- package/dist/esm/types/sync/resources/user-plan-limits.js +21 -0
- package/dist/esm/types/sync/resources/user-settings.js +39 -0
- package/dist/esm/types/sync/resources/user.js +120 -0
- package/dist/esm/types/sync/resources/view-options.js +72 -0
- package/dist/esm/types/sync/resources/workspace-filters.js +18 -0
- package/dist/esm/types/sync/resources/workspace-goals.js +29 -0
- package/dist/esm/types/sync/resources/workspaces.js +46 -0
- package/dist/esm/types/sync/response.js +1 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/multipart-upload.js +60 -39
- package/dist/esm/utils/sync-helpers.js +19 -0
- package/dist/esm/utils/validators.js +65 -64
- package/dist/types/todoist-api.d.ts +26 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/requests.d.ts +3 -3
- package/dist/types/types/sync/commands/calendars.d.ts +14 -0
- package/dist/types/types/sync/commands/filters.d.ts +21 -0
- package/dist/types/types/sync/commands/folders.d.ts +18 -0
- package/dist/types/types/sync/commands/index.d.ts +172 -0
- package/dist/types/types/sync/commands/labels.d.ts +27 -0
- package/dist/types/types/sync/commands/notes.d.ts +27 -0
- package/dist/types/types/sync/commands/notifications.d.ts +10 -0
- package/dist/types/types/sync/commands/others.d.ts +14 -0
- package/dist/types/types/sync/commands/project-view-options.d.ts +14 -0
- package/dist/types/types/sync/commands/projects.d.ts +88 -0
- package/dist/types/types/sync/commands/reminders.d.ts +27 -0
- package/dist/types/types/sync/commands/sections.d.ts +31 -0
- package/dist/types/types/sync/commands/shared.d.ts +46 -0
- package/dist/types/types/sync/commands/sharing.d.ts +16 -0
- package/dist/types/types/sync/commands/tasks.d.ts +78 -0
- package/dist/types/types/sync/commands/view-options.d.ts +19 -0
- package/dist/types/types/sync/commands/workspace-filters.d.ts +22 -0
- package/dist/types/types/sync/commands/workspace-goals.d.ts +24 -0
- package/dist/types/types/sync/commands/workspaces.d.ts +79 -0
- package/dist/types/types/sync/index.d.ts +5 -0
- package/dist/types/types/sync/request.d.ts +7 -0
- package/dist/types/types/sync/resource-types.d.ts +5 -0
- package/dist/types/types/sync/resources/calendars.d.ts +30 -0
- package/dist/types/types/sync/resources/collaborators.d.ts +24 -0
- package/dist/types/types/sync/resources/completed-info.d.ts +33 -0
- package/dist/types/types/sync/resources/filters.d.ts +12 -0
- package/dist/types/types/sync/resources/folders.d.ts +10 -0
- package/dist/types/types/sync/resources/index.d.ts +17 -0
- package/dist/types/types/sync/resources/live-notifications.d.ts +23 -0
- package/dist/types/types/sync/resources/notes.d.ts +34 -0
- package/dist/types/types/sync/resources/reminders.d.ts +101 -0
- package/dist/types/types/sync/resources/suggestions.d.ts +54 -0
- package/dist/types/types/sync/resources/tooltips.d.ts +6 -0
- package/dist/types/types/sync/resources/user-plan-limits.d.ts +41 -0
- package/dist/types/types/sync/resources/user-settings.d.ts +32 -0
- package/dist/types/types/sync/resources/user.d.ts +104 -0
- package/dist/types/types/sync/resources/view-options.d.ts +94 -0
- package/dist/types/types/sync/resources/workspace-filters.d.ts +17 -0
- package/dist/types/types/sync/resources/workspace-goals.d.ts +29 -0
- package/dist/types/types/sync/resources/workspaces.d.ts +52 -0
- package/dist/types/types/sync/response.d.ts +47 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/multipart-upload.d.ts +5 -3
- package/dist/types/utils/sync-helpers.d.ts +17 -0
- package/dist/types/utils/validators.d.ts +1163 -23
- package/package.json +8 -8
- package/dist/types/types/sync.d.ts +0 -30
|
@@ -1,39 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateTask =
|
|
4
|
-
exports.
|
|
3
|
+
exports.validateUserPlanLimits = exports.validateProjectViewOptionsDefaultsArray = exports.validateProjectViewOptionsDefaults = exports.validateViewOptionsArray = exports.validateViewOptions = exports.validateCompletedInfoArray = exports.validateCompletedInfo = exports.validateReminderArray = exports.validateReminder = exports.validateCalendarAccountArray = exports.validateCalendarAccount = exports.validateCalendarArray = exports.validateCalendar = exports.validateWorkspaceGoalArray = exports.validateWorkspaceGoal = 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.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 = void 0;
|
|
5
5
|
exports.isWorkspaceProject = isWorkspaceProject;
|
|
6
6
|
exports.isPersonalProject = isPersonalProject;
|
|
7
7
|
exports.validateProject = validateProject;
|
|
8
8
|
exports.validateProjectArray = validateProjectArray;
|
|
9
|
-
exports.validateSection = validateSection;
|
|
10
|
-
exports.validateSectionArray = validateSectionArray;
|
|
11
|
-
exports.validateLabel = validateLabel;
|
|
12
|
-
exports.validateLabelArray = validateLabelArray;
|
|
13
|
-
exports.validateComment = validateComment;
|
|
14
|
-
exports.validateCommentArray = validateCommentArray;
|
|
15
|
-
exports.validateUser = validateUser;
|
|
16
|
-
exports.validateUserArray = validateUserArray;
|
|
17
|
-
exports.validateProductivityStats = validateProductivityStats;
|
|
18
|
-
exports.validateCurrentUser = validateCurrentUser;
|
|
19
|
-
exports.validateActivityEvent = validateActivityEvent;
|
|
20
|
-
exports.validateActivityEventArray = validateActivityEventArray;
|
|
21
|
-
exports.validateAttachment = validateAttachment;
|
|
22
|
-
exports.validateWorkspaceUser = validateWorkspaceUser;
|
|
23
9
|
exports.validateWorkspaceUserArray = validateWorkspaceUserArray;
|
|
24
|
-
exports.validateWorkspaceInvitation = validateWorkspaceInvitation;
|
|
25
|
-
exports.validateWorkspaceInvitationArray = validateWorkspaceInvitationArray;
|
|
26
|
-
exports.validateWorkspacePlanDetails = validateWorkspacePlanDetails;
|
|
27
|
-
exports.validateJoinWorkspaceResult = validateJoinWorkspaceResult;
|
|
28
|
-
exports.validateWorkspace = validateWorkspace;
|
|
29
|
-
exports.validateWorkspaceArray = validateWorkspaceArray;
|
|
30
10
|
const entities_1 = require("../types/entities");
|
|
31
|
-
|
|
32
|
-
|
|
11
|
+
const resources_1 = require("../types/sync/resources");
|
|
12
|
+
function createValidator(schema) {
|
|
13
|
+
return (input) => schema.parse(input);
|
|
33
14
|
}
|
|
34
|
-
function
|
|
35
|
-
return input.map(
|
|
15
|
+
function createArrayValidator(validateItem) {
|
|
16
|
+
return (input) => input.map(validateItem);
|
|
36
17
|
}
|
|
18
|
+
// Entity validators
|
|
19
|
+
exports.validateTask = createValidator(entities_1.TaskSchema);
|
|
20
|
+
exports.validateTaskArray = createArrayValidator(exports.validateTask);
|
|
37
21
|
/**
|
|
38
22
|
* Type guard to check if a project is a workspace project.
|
|
39
23
|
* @param project The project to check
|
|
@@ -64,69 +48,66 @@ function validateProject(input) {
|
|
|
64
48
|
function validateProjectArray(input) {
|
|
65
49
|
return input.map(validateProject);
|
|
66
50
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
function validateCommentArray(input) {
|
|
83
|
-
return input.map(validateComment);
|
|
84
|
-
}
|
|
85
|
-
function validateUser(input) {
|
|
86
|
-
return entities_1.UserSchema.parse(input);
|
|
87
|
-
}
|
|
88
|
-
function validateUserArray(input) {
|
|
89
|
-
return input.map(validateUser);
|
|
90
|
-
}
|
|
91
|
-
function validateProductivityStats(input) {
|
|
92
|
-
return entities_1.ProductivityStatsSchema.parse(input);
|
|
93
|
-
}
|
|
94
|
-
function validateCurrentUser(input) {
|
|
95
|
-
return entities_1.CurrentUserSchema.parse(input);
|
|
96
|
-
}
|
|
97
|
-
function validateActivityEvent(input) {
|
|
98
|
-
return entities_1.ActivityEventSchema.parse(input);
|
|
99
|
-
}
|
|
100
|
-
function validateActivityEventArray(input) {
|
|
101
|
-
return input.map(validateActivityEvent);
|
|
102
|
-
}
|
|
103
|
-
function validateAttachment(input) {
|
|
104
|
-
return entities_1.AttachmentSchema.parse(input);
|
|
105
|
-
}
|
|
106
|
-
function validateWorkspaceUser(input) {
|
|
107
|
-
return entities_1.WorkspaceUserSchema.parse(input);
|
|
108
|
-
}
|
|
51
|
+
exports.validateSection = createValidator(entities_1.SectionSchema);
|
|
52
|
+
exports.validateSectionArray = createArrayValidator(exports.validateSection);
|
|
53
|
+
exports.validateLabel = createValidator(entities_1.LabelSchema);
|
|
54
|
+
exports.validateLabelArray = createArrayValidator(exports.validateLabel);
|
|
55
|
+
exports.validateComment = createValidator(entities_1.CommentSchema);
|
|
56
|
+
exports.validateCommentArray = createArrayValidator(exports.validateComment);
|
|
57
|
+
exports.validateUser = createValidator(entities_1.UserSchema);
|
|
58
|
+
exports.validateUserArray = createArrayValidator(exports.validateUser);
|
|
59
|
+
exports.validateProductivityStats = createValidator(entities_1.ProductivityStatsSchema);
|
|
60
|
+
exports.validateCurrentUser = createValidator(entities_1.CurrentUserSchema);
|
|
61
|
+
exports.validateActivityEvent = createValidator(entities_1.ActivityEventSchema);
|
|
62
|
+
exports.validateActivityEventArray = createArrayValidator(exports.validateActivityEvent);
|
|
63
|
+
exports.validateAttachment = createValidator(entities_1.AttachmentSchema);
|
|
64
|
+
exports.validateWorkspaceUser = createValidator(entities_1.WorkspaceUserSchema);
|
|
109
65
|
function validateWorkspaceUserArray(input) {
|
|
110
66
|
if (!Array.isArray(input)) {
|
|
111
67
|
throw new Error(`Expected array for workspace users, got ${typeof input}`);
|
|
112
68
|
}
|
|
113
|
-
return input.map(validateWorkspaceUser);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
69
|
+
return input.map(exports.validateWorkspaceUser);
|
|
70
|
+
}
|
|
71
|
+
exports.validateWorkspaceInvitation = createValidator(entities_1.WorkspaceInvitationSchema);
|
|
72
|
+
exports.validateWorkspaceInvitationArray = createArrayValidator(exports.validateWorkspaceInvitation);
|
|
73
|
+
exports.validateWorkspacePlanDetails = createValidator(entities_1.WorkspacePlanDetailsSchema);
|
|
74
|
+
exports.validateJoinWorkspaceResult = createValidator(entities_1.JoinWorkspaceResultSchema);
|
|
75
|
+
exports.validateWorkspace = createValidator(entities_1.WorkspaceSchema);
|
|
76
|
+
exports.validateWorkspaceArray = createArrayValidator(exports.validateWorkspace);
|
|
77
|
+
// Sync resource validators
|
|
78
|
+
exports.validateFilter = createValidator(resources_1.FilterSchema);
|
|
79
|
+
exports.validateFilterArray = createArrayValidator(exports.validateFilter);
|
|
80
|
+
exports.validateCollaborator = createValidator(resources_1.CollaboratorSchema);
|
|
81
|
+
exports.validateCollaboratorArray = createArrayValidator(exports.validateCollaborator);
|
|
82
|
+
exports.validateCollaboratorState = createValidator(resources_1.CollaboratorStateSchema);
|
|
83
|
+
exports.validateCollaboratorStateArray = createArrayValidator(exports.validateCollaboratorState);
|
|
84
|
+
exports.validateFolder = createValidator(resources_1.FolderSchema);
|
|
85
|
+
exports.validateFolderArray = createArrayValidator(exports.validateFolder);
|
|
86
|
+
exports.validateNote = createValidator(resources_1.NoteSchema);
|
|
87
|
+
exports.validateNoteArray = createArrayValidator(exports.validateNote);
|
|
88
|
+
exports.validateTooltips = createValidator(resources_1.TooltipsSchema);
|
|
89
|
+
exports.validateWorkspaceFilter = createValidator(resources_1.WorkspaceFilterSchema);
|
|
90
|
+
exports.validateWorkspaceFilterArray = createArrayValidator(exports.validateWorkspaceFilter);
|
|
91
|
+
exports.validateWorkspaceGoal = createValidator(resources_1.WorkspaceGoalSchema);
|
|
92
|
+
exports.validateWorkspaceGoalArray = createArrayValidator(exports.validateWorkspaceGoal);
|
|
93
|
+
exports.validateCalendar = createValidator(resources_1.CalendarSchema);
|
|
94
|
+
exports.validateCalendarArray = createArrayValidator(exports.validateCalendar);
|
|
95
|
+
exports.validateCalendarAccount = createValidator(resources_1.CalendarAccountSchema);
|
|
96
|
+
exports.validateCalendarAccountArray = createArrayValidator(exports.validateCalendarAccount);
|
|
97
|
+
exports.validateReminder = createValidator(resources_1.ReminderSchema);
|
|
98
|
+
exports.validateReminderArray = createArrayValidator(exports.validateReminder);
|
|
99
|
+
exports.validateCompletedInfo = createValidator(resources_1.CompletedInfoSchema);
|
|
100
|
+
exports.validateCompletedInfoArray = createArrayValidator(exports.validateCompletedInfo);
|
|
101
|
+
exports.validateViewOptions = createValidator(resources_1.ViewOptionsSchema);
|
|
102
|
+
exports.validateViewOptionsArray = createArrayValidator(exports.validateViewOptions);
|
|
103
|
+
exports.validateProjectViewOptionsDefaults = createValidator(resources_1.ProjectViewOptionsDefaultsSchema);
|
|
104
|
+
exports.validateProjectViewOptionsDefaultsArray = createArrayValidator(exports.validateProjectViewOptionsDefaults);
|
|
105
|
+
exports.validateUserPlanLimits = createValidator(resources_1.UserPlanLimitsSchema);
|
|
106
|
+
exports.validateLiveNotification = createValidator(resources_1.LiveNotificationSchema);
|
|
107
|
+
exports.validateLiveNotificationArray = createArrayValidator(exports.validateLiveNotification);
|
|
108
|
+
exports.validateSyncWorkspace = createValidator(resources_1.SyncWorkspaceSchema);
|
|
109
|
+
exports.validateSyncWorkspaceArray = createArrayValidator(exports.validateSyncWorkspace);
|
|
110
|
+
exports.validateSyncUser = createValidator(resources_1.SyncUserSchema);
|
|
111
|
+
exports.validateUserSettings = createValidator(resources_1.UserSettingsSchema);
|
|
112
|
+
exports.validateSuggestion = createValidator(resources_1.SuggestionSchema);
|
|
113
|
+
exports.validateSuggestionArray = createArrayValidator(exports.validateSuggestion);
|
package/dist/esm/todoist-api.js
CHANGED
|
@@ -73,6 +73,34 @@ export class TodoistApi {
|
|
|
73
73
|
}
|
|
74
74
|
return response.data;
|
|
75
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Executes a raw Sync API request.
|
|
78
|
+
*
|
|
79
|
+
* This method provides direct access to the Sync API, allowing you to send
|
|
80
|
+
* strongly-typed commands and request specific resource types.
|
|
81
|
+
*
|
|
82
|
+
* @param request - The sync request payload containing commands and/or resource types.
|
|
83
|
+
* @param requestId - Optional custom identifier for the request.
|
|
84
|
+
* @returns A promise that resolves to the sync response.
|
|
85
|
+
* @throws TodoistRequestError if the sync status contains errors.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* import { createCommand } from '@doist/todoist-api-typescript'
|
|
90
|
+
*
|
|
91
|
+
* const response = await api.sync({
|
|
92
|
+
* commands: [
|
|
93
|
+
* createCommand('item_add', { content: 'Buy milk' }),
|
|
94
|
+
* ],
|
|
95
|
+
* resourceTypes: ['items'],
|
|
96
|
+
* syncToken: '*',
|
|
97
|
+
* })
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
async sync(syncRequest, requestId) {
|
|
101
|
+
var _a;
|
|
102
|
+
return this.requestSync(syncRequest, requestId, Boolean((_a = syncRequest.commands) === null || _a === void 0 ? void 0 : _a.length));
|
|
103
|
+
}
|
|
76
104
|
/**
|
|
77
105
|
* Retrieves information about the authenticated user.
|
|
78
106
|
*
|
|
@@ -286,11 +314,11 @@ export class TodoistApi {
|
|
|
286
314
|
const commands = ids.map((id) => ({
|
|
287
315
|
type: 'item_move',
|
|
288
316
|
uuid: uuidv4(),
|
|
289
|
-
args: Object.assign(Object.assign(Object.assign({ id }, (args.projectId
|
|
317
|
+
args: Object.assign(Object.assign(Object.assign({ id }, (args.projectId ? { projectId: args.projectId } : {})), (args.sectionId ? { sectionId: args.sectionId } : {})), (args.parentId ? { parentId: args.parentId } : {})),
|
|
290
318
|
}));
|
|
291
319
|
const syncRequest = {
|
|
292
320
|
commands,
|
|
293
|
-
|
|
321
|
+
resourceTypes: ['items'],
|
|
294
322
|
};
|
|
295
323
|
const syncResponse = await this.requestSync(syncRequest, requestId, true);
|
|
296
324
|
if (!((_a = syncResponse.items) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
@@ -1355,8 +1383,8 @@ export class TodoistApi {
|
|
|
1355
1383
|
*/
|
|
1356
1384
|
async getWorkspaces(requestId) {
|
|
1357
1385
|
const syncRequest = {
|
|
1358
|
-
|
|
1359
|
-
|
|
1386
|
+
syncToken: '*',
|
|
1387
|
+
resourceTypes: ['workspaces'],
|
|
1360
1388
|
};
|
|
1361
1389
|
const syncResponse = await this.requestSync(syncRequest, requestId, false);
|
|
1362
1390
|
const workspacesData = syncResponse.workspaces;
|
package/dist/esm/types/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Re-export all domain types
|
|
2
|
+
export * from './shared.js';
|
|
3
|
+
export * from './tasks.js';
|
|
4
|
+
export * from './projects.js';
|
|
5
|
+
export * from './sections.js';
|
|
6
|
+
export * from './labels.js';
|
|
7
|
+
export * from './filters.js';
|
|
8
|
+
export * from './notes.js';
|
|
9
|
+
export * from './reminders.js';
|
|
10
|
+
export * from './workspaces.js';
|
|
11
|
+
export * from './folders.js';
|
|
12
|
+
export * from './workspace-filters.js';
|
|
13
|
+
export * from './workspace-goals.js';
|
|
14
|
+
export * from './notifications.js';
|
|
15
|
+
export * from './sharing.js';
|
|
16
|
+
export * from './view-options.js';
|
|
17
|
+
export * from './project-view-options.js';
|
|
18
|
+
export * from './calendars.js';
|
|
19
|
+
export * from './others.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,6 +6,7 @@ export const SYNC_RESOURCE_TYPES = [
|
|
|
6
6
|
'projects',
|
|
7
7
|
'items',
|
|
8
8
|
'notes',
|
|
9
|
+
'project_notes',
|
|
9
10
|
'sections',
|
|
10
11
|
'filters',
|
|
11
12
|
'reminders',
|
|
@@ -14,6 +15,7 @@ export const SYNC_RESOURCE_TYPES = [
|
|
|
14
15
|
'user',
|
|
15
16
|
'live_notifications',
|
|
16
17
|
'collaborators',
|
|
18
|
+
'collaborator_states',
|
|
17
19
|
'user_settings',
|
|
18
20
|
'notification_settings',
|
|
19
21
|
'user_plan_limits',
|
|
@@ -25,4 +27,11 @@ export const SYNC_RESOURCE_TYPES = [
|
|
|
25
27
|
'view_options',
|
|
26
28
|
'project_view_options_defaults',
|
|
27
29
|
'role_actions',
|
|
30
|
+
'folders',
|
|
31
|
+
'workspace_goals',
|
|
32
|
+
'day_orders',
|
|
33
|
+
'calendars',
|
|
34
|
+
'calendar_accounts',
|
|
35
|
+
'suggestions',
|
|
36
|
+
'tooltips',
|
|
28
37
|
];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const CalendarSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
id: z.string(),
|
|
5
|
+
summary: z.string(),
|
|
6
|
+
color: z.string().nullable(),
|
|
7
|
+
accountId: z.string(),
|
|
8
|
+
isVisible: z.boolean(),
|
|
9
|
+
isTaskCalendar: z.boolean().optional(),
|
|
10
|
+
})
|
|
11
|
+
.passthrough();
|
|
12
|
+
export const CalendarAccountSchema = z
|
|
13
|
+
.object({
|
|
14
|
+
id: z.string(),
|
|
15
|
+
name: z.string(),
|
|
16
|
+
type: z.enum(['google', 'microsoft', 'apple']),
|
|
17
|
+
isDeleted: z.boolean().optional(),
|
|
18
|
+
isEventsEnabled: z.boolean().optional(),
|
|
19
|
+
isTasksEnabled: z.boolean().optional(),
|
|
20
|
+
isAllDayTasksEnabled: z.boolean().optional(),
|
|
21
|
+
pendingOperationUntil: z.string().nullable().optional(),
|
|
22
|
+
calendarsSyncState: z.enum(['synced', 'syncing', 'error']).optional(),
|
|
23
|
+
})
|
|
24
|
+
.passthrough();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { WorkspaceRoleSchema } from '../../entities.js';
|
|
3
|
+
export const CollaboratorSchema = z
|
|
4
|
+
.object({
|
|
5
|
+
id: z.string(),
|
|
6
|
+
email: z.string(),
|
|
7
|
+
fullName: z.string(),
|
|
8
|
+
timezone: z.string(),
|
|
9
|
+
imageId: z.string().nullable(),
|
|
10
|
+
})
|
|
11
|
+
.passthrough();
|
|
12
|
+
export const CollaboratorStateSchema = z
|
|
13
|
+
.object({
|
|
14
|
+
userId: z.string(),
|
|
15
|
+
projectId: z.string(),
|
|
16
|
+
state: z.enum(['active', 'invited']),
|
|
17
|
+
isDeleted: z.boolean(),
|
|
18
|
+
workspaceRole: WorkspaceRoleSchema.optional(),
|
|
19
|
+
})
|
|
20
|
+
.passthrough();
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const CompletedProjectMetadataSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
projectId: z.string(),
|
|
5
|
+
archivedSections: z.number().int(),
|
|
6
|
+
completedItems: z.number().int(),
|
|
7
|
+
})
|
|
8
|
+
.passthrough();
|
|
9
|
+
export const CompletedSectionMetadataSchema = z
|
|
10
|
+
.object({
|
|
11
|
+
sectionId: z.string(),
|
|
12
|
+
id: z.string(),
|
|
13
|
+
completedItems: z.number().int(),
|
|
14
|
+
})
|
|
15
|
+
.passthrough();
|
|
16
|
+
export const CompletedTaskMetadataSchema = z
|
|
17
|
+
.object({
|
|
18
|
+
itemId: z.string(),
|
|
19
|
+
id: z.string().optional(),
|
|
20
|
+
completedItems: z.number().int(),
|
|
21
|
+
})
|
|
22
|
+
.passthrough();
|
|
23
|
+
export const CompletedInfoSchema = z.union([
|
|
24
|
+
CompletedProjectMetadataSchema,
|
|
25
|
+
CompletedSectionMetadataSchema,
|
|
26
|
+
CompletedTaskMetadataSchema,
|
|
27
|
+
]);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const FilterSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
id: z.string(),
|
|
5
|
+
name: z.string(),
|
|
6
|
+
query: z.string(),
|
|
7
|
+
color: z.string(),
|
|
8
|
+
isDeleted: z.boolean(),
|
|
9
|
+
isFavorite: z.boolean(),
|
|
10
|
+
isFrozen: z.boolean(),
|
|
11
|
+
itemOrder: z.number().int(),
|
|
12
|
+
})
|
|
13
|
+
.passthrough();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './filters.js';
|
|
2
|
+
export * from './collaborators.js';
|
|
3
|
+
export * from './folders.js';
|
|
4
|
+
export * from './tooltips.js';
|
|
5
|
+
export * from './notes.js';
|
|
6
|
+
export * from './workspace-filters.js';
|
|
7
|
+
export * from './workspace-goals.js';
|
|
8
|
+
export * from './calendars.js';
|
|
9
|
+
export * from './reminders.js';
|
|
10
|
+
export * from './completed-info.js';
|
|
11
|
+
export * from './view-options.js';
|
|
12
|
+
export * from './user-plan-limits.js';
|
|
13
|
+
export * from './live-notifications.js';
|
|
14
|
+
export * from './workspaces.js';
|
|
15
|
+
export * from './user.js';
|
|
16
|
+
export * from './user-settings.js';
|
|
17
|
+
export * from './suggestions.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Live notification resource from the Sync API.
|
|
4
|
+
*
|
|
5
|
+
* Uses a base schema with commonly-present fields plus `.passthrough()` for
|
|
6
|
+
* forward compatibility. The Sync API returns 20+ notification variants;
|
|
7
|
+
* fully typing each is too fragile for a library, so we validate the common
|
|
8
|
+
* shape and preserve all extra fields.
|
|
9
|
+
*/
|
|
10
|
+
export const LiveNotificationSchema = z
|
|
11
|
+
.object({
|
|
12
|
+
id: z.string(),
|
|
13
|
+
createdAt: z.string(),
|
|
14
|
+
fromUid: z.string(),
|
|
15
|
+
notificationType: z.string(),
|
|
16
|
+
isUnread: z.boolean(),
|
|
17
|
+
// Commonly present optional fields
|
|
18
|
+
projectId: z.string().optional(),
|
|
19
|
+
invitationId: z.string().optional(),
|
|
20
|
+
itemId: z.string().optional(),
|
|
21
|
+
itemContent: z.string().optional(),
|
|
22
|
+
responsibleUid: z.string().optional(),
|
|
23
|
+
assignedByUid: z.string().optional(),
|
|
24
|
+
})
|
|
25
|
+
.passthrough();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { AttachmentSchema } from '../../entities.js';
|
|
3
|
+
/**
|
|
4
|
+
* Sync API note (comment) resource.
|
|
5
|
+
* Separate from the REST `CommentSchema` which transforms `itemId` to `taskId`.
|
|
6
|
+
*/
|
|
7
|
+
export const NoteSchema = z
|
|
8
|
+
.object({
|
|
9
|
+
id: z.string(),
|
|
10
|
+
itemId: z.string().optional(),
|
|
11
|
+
projectId: z.string().optional(),
|
|
12
|
+
content: z.string(),
|
|
13
|
+
postedAt: z.string(),
|
|
14
|
+
fileAttachment: AttachmentSchema.nullable(),
|
|
15
|
+
postedUid: z.string(),
|
|
16
|
+
uidsToNotify: z.array(z.string()).nullable(),
|
|
17
|
+
reactions: z.record(z.string(), z.array(z.string())).nullable(),
|
|
18
|
+
isDeleted: z.boolean(),
|
|
19
|
+
})
|
|
20
|
+
.passthrough();
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { DueDateSchema } from '../../entities.js';
|
|
3
|
+
const ReminderBaseSchema = z.object({
|
|
4
|
+
id: z.string(),
|
|
5
|
+
notifyUid: z.string(),
|
|
6
|
+
itemId: z.string(),
|
|
7
|
+
projectId: z.string().optional(),
|
|
8
|
+
isDeleted: z.boolean(),
|
|
9
|
+
});
|
|
10
|
+
export const LocationReminderSchema = ReminderBaseSchema.extend({
|
|
11
|
+
type: z.literal('location'),
|
|
12
|
+
name: z.string(),
|
|
13
|
+
locLat: z.string(),
|
|
14
|
+
locLong: z.string(),
|
|
15
|
+
locTrigger: z.enum(['on_enter', 'on_leave']),
|
|
16
|
+
radius: z.number().int(),
|
|
17
|
+
}).passthrough();
|
|
18
|
+
export const AbsoluteReminderSchema = ReminderBaseSchema.extend({
|
|
19
|
+
type: z.literal('absolute'),
|
|
20
|
+
due: DueDateSchema,
|
|
21
|
+
}).passthrough();
|
|
22
|
+
export const RelativeReminderSchema = ReminderBaseSchema.extend({
|
|
23
|
+
type: z.literal('relative'),
|
|
24
|
+
minuteOffset: z.number().int(),
|
|
25
|
+
due: DueDateSchema.optional(),
|
|
26
|
+
}).passthrough();
|
|
27
|
+
export const ReminderSchema = z.discriminatedUnion('type', [
|
|
28
|
+
LocationReminderSchema,
|
|
29
|
+
AbsoluteReminderSchema,
|
|
30
|
+
RelativeReminderSchema,
|
|
31
|
+
]);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const TemplateSuggestionSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
id: z.string(),
|
|
5
|
+
name: z.string(),
|
|
6
|
+
templateType: z.enum(['project', 'setup']),
|
|
7
|
+
})
|
|
8
|
+
.passthrough();
|
|
9
|
+
export const WorkspaceTemplateSuggestionSchema = TemplateSuggestionSchema.extend({
|
|
10
|
+
workspaceId: z.string().nullable(),
|
|
11
|
+
});
|
|
12
|
+
const SyncTemplateSuggestionsSchema = z
|
|
13
|
+
.object({
|
|
14
|
+
type: z.enum(['templates', 'most_used_user_templates']),
|
|
15
|
+
content: z.object({
|
|
16
|
+
templates: z.array(TemplateSuggestionSchema),
|
|
17
|
+
locale: z.string(),
|
|
18
|
+
}),
|
|
19
|
+
isDeleted: z.boolean(),
|
|
20
|
+
})
|
|
21
|
+
.passthrough();
|
|
22
|
+
const SyncWorkspaceTemplateSuggestionsSchema = z
|
|
23
|
+
.object({
|
|
24
|
+
type: z.literal('most_used_workspace_templates'),
|
|
25
|
+
content: z.object({
|
|
26
|
+
templates: z.array(WorkspaceTemplateSuggestionSchema),
|
|
27
|
+
locale: z.string(),
|
|
28
|
+
}),
|
|
29
|
+
isDeleted: z.boolean(),
|
|
30
|
+
})
|
|
31
|
+
.passthrough();
|
|
32
|
+
export const SuggestionSchema = z.union([
|
|
33
|
+
SyncWorkspaceTemplateSuggestionsSchema,
|
|
34
|
+
SyncTemplateSuggestionsSchema,
|
|
35
|
+
]);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const PlanLimitsSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
activeProjects: z.number().int().optional(),
|
|
5
|
+
activityLog: z.number().int().optional(),
|
|
6
|
+
collaboratorsPerProject: z.number().int().optional(),
|
|
7
|
+
commentsPerTask: z.number().int().optional(),
|
|
8
|
+
fileUploadsPerComment: z.number().int().optional(),
|
|
9
|
+
filtersPerUser: z.number().int().optional(),
|
|
10
|
+
labelsPerTask: z.number().int().optional(),
|
|
11
|
+
remindersPerUser: z.number().int().optional(),
|
|
12
|
+
sectionsPerProject: z.number().int().optional(),
|
|
13
|
+
tasksPerProject: z.number().int().optional(),
|
|
14
|
+
})
|
|
15
|
+
.passthrough();
|
|
16
|
+
export const UserPlanLimitsSchema = z
|
|
17
|
+
.object({
|
|
18
|
+
current: PlanLimitsSchema,
|
|
19
|
+
next: PlanLimitsSchema.nullable(),
|
|
20
|
+
})
|
|
21
|
+
.passthrough();
|