@doist/todoist-sdk 8.3.0-next.1 → 8.3.1
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 +21 -9
- package/dist/cjs/types/sync/commands/index.js +0 -1
- package/dist/cjs/types/sync/resource-types.js +0 -1
- package/dist/cjs/types/sync/resources/calendars.js +4 -8
- package/dist/cjs/types/sync/resources/collaborators.js +4 -8
- package/dist/cjs/types/sync/resources/completed-info.js +6 -12
- package/dist/cjs/types/sync/resources/filters.js +2 -4
- package/dist/cjs/types/sync/resources/folders.js +2 -4
- package/dist/cjs/types/sync/resources/index.js +0 -1
- package/dist/cjs/types/sync/resources/live-notifications.js +6 -8
- package/dist/cjs/types/sync/resources/notes.js +2 -4
- package/dist/cjs/types/sync/resources/reminders.js +4 -4
- package/dist/cjs/types/sync/resources/suggestions.js +6 -12
- package/dist/cjs/types/sync/resources/tooltips.js +2 -4
- package/dist/cjs/types/sync/resources/user-plan-limits.js +4 -8
- package/dist/cjs/types/sync/resources/user-settings.js +4 -6
- package/dist/cjs/types/sync/resources/user.js +10 -20
- package/dist/cjs/types/sync/resources/view-options.js +6 -12
- package/dist/cjs/types/sync/resources/workspace-filters.js +2 -4
- package/dist/cjs/types/sync/resources/workspace-goals.js +6 -12
- package/dist/cjs/types/sync/resources/workspaces.js +1 -2
- package/dist/cjs/utils/validators.js +37 -1
- package/dist/esm/todoist-api.js +22 -10
- package/dist/esm/types/sync/commands/index.js +0 -1
- package/dist/esm/types/sync/resource-types.js +0 -1
- package/dist/esm/types/sync/resources/calendars.js +4 -8
- package/dist/esm/types/sync/resources/collaborators.js +4 -8
- package/dist/esm/types/sync/resources/completed-info.js +6 -12
- package/dist/esm/types/sync/resources/filters.js +2 -4
- package/dist/esm/types/sync/resources/folders.js +2 -4
- package/dist/esm/types/sync/resources/index.js +0 -1
- package/dist/esm/types/sync/resources/live-notifications.js +6 -8
- package/dist/esm/types/sync/resources/notes.js +2 -4
- package/dist/esm/types/sync/resources/reminders.js +4 -4
- package/dist/esm/types/sync/resources/suggestions.js +6 -12
- package/dist/esm/types/sync/resources/tooltips.js +2 -4
- package/dist/esm/types/sync/resources/user-plan-limits.js +4 -8
- package/dist/esm/types/sync/resources/user-settings.js +4 -6
- package/dist/esm/types/sync/resources/user.js +10 -20
- package/dist/esm/types/sync/resources/view-options.js +6 -12
- package/dist/esm/types/sync/resources/workspace-filters.js +2 -4
- package/dist/esm/types/sync/resources/workspace-goals.js +6 -12
- package/dist/esm/types/sync/resources/workspaces.js +1 -2
- package/dist/esm/utils/validators.js +36 -1
- package/dist/types/todoist-api.d.ts +5 -0
- package/dist/types/types/sync/commands/index.d.ts +0 -9
- package/dist/types/types/sync/resource-types.d.ts +1 -1
- package/dist/types/types/sync/resources/index.d.ts +0 -1
- package/dist/types/types/sync/resources/live-notifications.d.ts +4 -4
- package/dist/types/types/sync/resources/reminders.d.ts +1 -1
- package/dist/types/types/sync/resources/view-options.d.ts +6 -6
- package/dist/types/types/sync/response.d.ts +1 -2
- package/dist/types/utils/validators.d.ts +42 -40
- package/package.json +1 -1
- package/dist/cjs/types/sync/commands/goals.js +0 -2
- package/dist/cjs/types/sync/resources/goals.js +0 -33
- package/dist/esm/types/sync/commands/goals.js +0 -1
- package/dist/esm/types/sync/resources/goals.js +0 -30
- package/dist/types/types/sync/commands/goals.d.ts +0 -33
- package/dist/types/types/sync/resources/goals.d.ts +0 -37
package/dist/esm/todoist-api.js
CHANGED
|
@@ -13,13 +13,12 @@ import { z } from 'zod';
|
|
|
13
13
|
import { getSyncBaseUri, ENDPOINT_REST_TASKS, ENDPOINT_REST_TASKS_FILTER, ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE, ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE, ENDPOINT_REST_TASKS_COMPLETED_SEARCH, ENDPOINT_REST_TASKS_COMPLETED, ENDPOINT_REST_TEMPLATES_FILE, ENDPOINT_REST_TEMPLATES_URL, ENDPOINT_REST_TEMPLATES_CREATE_FROM_FILE, ENDPOINT_REST_TEMPLATES_IMPORT_FROM_FILE, ENDPOINT_REST_TEMPLATES_IMPORT_FROM_ID, ENDPOINT_REST_PROJECTS, ENDPOINT_REST_PROJECTS_SEARCH, ENDPOINT_SYNC_QUICK_ADD, ENDPOINT_REST_TASK_CLOSE, ENDPOINT_REST_TASK_REOPEN, ENDPOINT_REST_TASK_MOVE, ENDPOINT_REST_LABELS, ENDPOINT_REST_LABELS_SEARCH, ENDPOINT_REST_PROJECT_COLLABORATORS, ENDPOINT_REST_SECTIONS, ENDPOINT_REST_SECTIONS_SEARCH, ENDPOINT_REST_COMMENTS, ENDPOINT_REST_LOCATION_REMINDERS, ENDPOINT_REST_REMINDERS, ENDPOINT_REST_LABELS_SHARED, ENDPOINT_REST_LABELS_SHARED_RENAME, ENDPOINT_REST_LABELS_SHARED_REMOVE, ENDPOINT_SYNC, PROJECT_ARCHIVE, PROJECT_UNARCHIVE, ENDPOINT_REST_PROJECTS_MOVE_TO_WORKSPACE, ENDPOINT_REST_PROJECTS_MOVE_TO_PERSONAL, ENDPOINT_REST_PROJECTS_ARCHIVED, ENDPOINT_REST_PROJECTS_ARCHIVED_COUNT, ENDPOINT_REST_PROJECTS_PERMISSIONS, ENDPOINT_REST_PROJECT_FULL, ENDPOINT_REST_PROJECT_JOIN, SECTION_ARCHIVE, SECTION_UNARCHIVE, ENDPOINT_REST_USER, ENDPOINT_REST_PRODUCTIVITY, ENDPOINT_REST_ACTIVITIES, ENDPOINT_REST_UPLOADS, getProjectInsightsActivityStatsEndpoint, getProjectInsightsHealthEndpoint, getProjectInsightsHealthContextEndpoint, getProjectInsightsProgressEndpoint, getProjectInsightsHealthAnalyzeEndpoint, getWorkspaceInsightsEndpoint, ENDPOINT_REST_BACKUPS, ENDPOINT_REST_BACKUPS_DOWNLOAD, ENDPOINT_REST_EMAILS, ENDPOINT_REST_ID_MAPPINGS, ENDPOINT_REST_MOVED_IDS, ENDPOINT_REST_WORKSPACES, ENDPOINT_WORKSPACE_MEMBERS, getWorkspaceUserTasksEndpoint, getWorkspaceInviteUsersEndpoint, getWorkspaceUserEndpoint, ENDPOINT_WORKSPACE_INVITATIONS, ENDPOINT_WORKSPACE_INVITATIONS_ALL, ENDPOINT_WORKSPACE_INVITATIONS_DELETE, getWorkspaceInvitationAcceptEndpoint, getWorkspaceInvitationRejectEndpoint, ENDPOINT_WORKSPACE_JOIN, ENDPOINT_WORKSPACE_LOGO, ENDPOINT_WORKSPACE_PLAN_DETAILS, ENDPOINT_WORKSPACE_USERS, getWorkspaceActiveProjectsEndpoint, getWorkspaceArchivedProjectsEndpoint, ENDPOINT_REST_FOLDERS, } from './consts/endpoints.js';
|
|
14
14
|
import { request, isSuccess } from './transport/http-client.js';
|
|
15
15
|
import { UpdateReminderArgsSchema, UpdateLocationReminderArgsSchema, ReminderIdSchema, } from './types/reminders/index.js';
|
|
16
|
-
import { GoalSchema } from './types/sync/resources/goals.js';
|
|
17
16
|
import { normalizeObjectEventTypeForApi, denormalizeObjectTypeFromApi, } from './utils/activity-helpers.js';
|
|
18
17
|
import { camelCaseKeys } from './utils/case-conversion.js';
|
|
19
18
|
import { uploadMultipartFile } from './utils/multipart-upload.js';
|
|
20
19
|
import { processTaskContent } from './utils/uncompletable-helpers.js';
|
|
21
20
|
import { formatDateToYYYYMMDD } from './utils/url-helpers.js';
|
|
22
|
-
import { validateAttachment, validateComment, validateCommentArray, validateCurrentUser, validateLabel, validateLabelArray, validateProject, validateProjectArray, validateSection, validateSectionArray, validateTask, validateTaskArray, validateUserArray, validateProductivityStats, validateReminder, validateReminderArray, validateLocationReminderArray, validateActivityEventArray, validateWorkspaceUserArray, validateWorkspaceInvitation, validateWorkspaceInvitationArray, validateWorkspacePlanDetails, validateJoinWorkspaceResult, validateWorkspace, validateWorkspaceArray, validateMemberActivityInfoArray, validateWorkspaceUserTaskArray, validateProjectActivityStats, validateProjectHealth, validateProjectHealthContext, validateProjectProgress, validateWorkspaceInsights, validateBackupArray, validateIdMappingArray, validateMovedIdArray, validateFolder, validateFolderArray, validateCollaboratorArray, validateCollaboratorStateArray, validateNoteArray, validateWorkspaceProject, validateWorkspaceProjectArray, } from './utils/validators.js';
|
|
21
|
+
import { validateAttachment, validateComment, validateCommentArray, validateCurrentUser, validateLabel, validateLabelArray, validateProject, validateProjectArray, validateSection, validateSectionArray, validateTask, validateTaskArray, validateUserArray, validateProductivityStats, validateReminder, validateReminderArray, validateLocationReminderArray, validateActivityEventArray, validateWorkspaceUserArray, validateWorkspaceInvitation, validateWorkspaceInvitationArray, validateWorkspacePlanDetails, validateJoinWorkspaceResult, validateWorkspace, validateWorkspaceArray, validateMemberActivityInfoArray, validateWorkspaceUserTaskArray, validateProjectActivityStats, validateProjectHealth, validateProjectHealthContext, validateProjectProgress, validateWorkspaceInsights, validateBackupArray, validateIdMappingArray, validateMovedIdArray, validateFolder, validateFolderArray, validateCollaboratorArray, validateCollaboratorStateArray, validateNoteArray, validateWorkspaceProject, validateWorkspaceProjectArray, parseSyncResponse, } from './utils/validators.js';
|
|
23
22
|
import { v4 as uuidv4 } from 'uuid';
|
|
24
23
|
import { TodoistArgumentError, TodoistRequestError } from './types/index.js';
|
|
25
24
|
import { DATE_FORMAT_TO_API, TIME_FORMAT_TO_API, DAY_OF_WEEK_TO_API, } from './types/sync/index.js';
|
|
@@ -36,13 +35,25 @@ function spreadIfDefined(value, fn) {
|
|
|
36
35
|
return value !== undefined ? fn(value) : {};
|
|
37
36
|
}
|
|
38
37
|
function serializeUserUpdateArgs(args) {
|
|
39
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, args), spreadIfDefined(args.dateFormat, (v) => ({
|
|
38
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, args), spreadIfDefined(args.dateFormat, (v) => ({
|
|
39
|
+
dateFormat: DATE_FORMAT_TO_API[v],
|
|
40
|
+
}))), spreadIfDefined(args.timeFormat, (v) => ({
|
|
41
|
+
timeFormat: TIME_FORMAT_TO_API[v],
|
|
42
|
+
}))), spreadIfDefined(args.startDay, (v) => ({
|
|
43
|
+
startDay: DAY_OF_WEEK_TO_API[v],
|
|
44
|
+
}))), spreadIfDefined(args.nextWeek, (v) => ({
|
|
45
|
+
nextWeek: DAY_OF_WEEK_TO_API[v],
|
|
46
|
+
})));
|
|
40
47
|
}
|
|
41
48
|
function serializeTaskUpdateDateCompleteArgs(args) {
|
|
42
|
-
return Object.assign(Object.assign(Object.assign({}, args), { isForward: args.isForward ? 1 : 0 }), spreadIfDefined(args.resetSubtasks, (v) => ({
|
|
49
|
+
return Object.assign(Object.assign(Object.assign({}, args), { isForward: args.isForward ? 1 : 0 }), spreadIfDefined(args.resetSubtasks, (v) => ({
|
|
50
|
+
resetSubtasks: v ? 1 : 0,
|
|
51
|
+
})));
|
|
43
52
|
}
|
|
44
53
|
function serializeUpdateGoalsArgs(args) {
|
|
45
|
-
return Object.assign(Object.assign(Object.assign({}, args), spreadIfDefined(args.vacationMode, (v) => ({ vacationMode: v ? 1 : 0 }))), spreadIfDefined(args.karmaDisabled, (v) => ({
|
|
54
|
+
return Object.assign(Object.assign(Object.assign({}, args), spreadIfDefined(args.vacationMode, (v) => ({ vacationMode: v ? 1 : 0 }))), spreadIfDefined(args.karmaDisabled, (v) => ({
|
|
55
|
+
karmaDisabled: v ? 1 : 0,
|
|
56
|
+
})));
|
|
46
57
|
}
|
|
47
58
|
function preprocessSyncCommands(commands) {
|
|
48
59
|
return commands.map((cmd) => {
|
|
@@ -132,11 +143,7 @@ export class TodoistApi {
|
|
|
132
143
|
throw new TodoistRequestError(value.error, value.httpCode, value.errorExtra);
|
|
133
144
|
});
|
|
134
145
|
}
|
|
135
|
-
|
|
136
|
-
if (data.goals) {
|
|
137
|
-
data.goals = data.goals.map((goal) => GoalSchema.parse(goal));
|
|
138
|
-
}
|
|
139
|
-
return data;
|
|
146
|
+
return parseSyncResponse(response.data);
|
|
140
147
|
}
|
|
141
148
|
/**
|
|
142
149
|
* Executes a raw Sync API request.
|
|
@@ -622,6 +629,11 @@ export class TodoistApi {
|
|
|
622
629
|
/**
|
|
623
630
|
* Deletes a project by its ID.
|
|
624
631
|
*
|
|
632
|
+
* If the project is a workspace project, it must have been
|
|
633
|
+
* archived first before it can be deleted, otherwise calling
|
|
634
|
+
* this function will result in an error. Personal projects can
|
|
635
|
+
* be deleted regardless of their archived status.
|
|
636
|
+
*
|
|
625
637
|
* @param id - The unique identifier of the project to delete.
|
|
626
638
|
* @param requestId - Optional custom identifier for the request.
|
|
627
639
|
* @returns A promise that resolves to `true` if successful.
|
|
@@ -11,7 +11,6 @@ export * from './workspaces.js';
|
|
|
11
11
|
export * from './folders.js';
|
|
12
12
|
export * from './workspace-filters.js';
|
|
13
13
|
export * from './workspace-goals.js';
|
|
14
|
-
export * from './goals.js';
|
|
15
14
|
export * from './notifications.js';
|
|
16
15
|
export * from './sharing.js';
|
|
17
16
|
export * from './view-options.js';
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export const CalendarSchema = z
|
|
3
|
-
.object({
|
|
2
|
+
export const CalendarSchema = z.looseObject({
|
|
4
3
|
id: z.string(),
|
|
5
4
|
summary: z.string(),
|
|
6
5
|
color: z.string().nullable(),
|
|
7
6
|
accountId: z.string(),
|
|
8
7
|
isVisible: z.boolean(),
|
|
9
8
|
isTaskCalendar: z.boolean().optional(),
|
|
10
|
-
})
|
|
11
|
-
.passthrough();
|
|
9
|
+
});
|
|
12
10
|
/** Available calendar account provider types. */
|
|
13
11
|
export const CALENDAR_ACCOUNT_TYPES = ['google', 'microsoft', 'apple'];
|
|
14
12
|
/** Available calendar sync states. */
|
|
15
13
|
export const CALENDAR_SYNC_STATES = ['synced', 'syncing', 'error'];
|
|
16
|
-
export const CalendarAccountSchema = z
|
|
17
|
-
.object({
|
|
14
|
+
export const CalendarAccountSchema = z.looseObject({
|
|
18
15
|
id: z.string(),
|
|
19
16
|
name: z.string(),
|
|
20
17
|
type: z.enum(CALENDAR_ACCOUNT_TYPES),
|
|
@@ -24,5 +21,4 @@ export const CalendarAccountSchema = z
|
|
|
24
21
|
isAllDayTasksEnabled: z.boolean().optional(),
|
|
25
22
|
pendingOperationUntil: z.string().nullable().optional(),
|
|
26
23
|
calendarsSyncState: z.enum(CALENDAR_SYNC_STATES).optional(),
|
|
27
|
-
})
|
|
28
|
-
.passthrough();
|
|
24
|
+
});
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { WorkspaceRoleSchema } from '../../workspaces/types.js';
|
|
3
|
-
export const CollaboratorSchema = z
|
|
4
|
-
.object({
|
|
3
|
+
export const CollaboratorSchema = z.looseObject({
|
|
5
4
|
id: z.string(),
|
|
6
5
|
email: z.string(),
|
|
7
6
|
fullName: z.string(),
|
|
8
7
|
timezone: z.string(),
|
|
9
8
|
imageId: z.string().nullable(),
|
|
10
|
-
})
|
|
11
|
-
.passthrough();
|
|
9
|
+
});
|
|
12
10
|
/** Available collaborator statuses. */
|
|
13
11
|
export const COLLABORATOR_STATUSES = ['active', 'invited'];
|
|
14
|
-
export const CollaboratorStateSchema = z
|
|
15
|
-
.object({
|
|
12
|
+
export const CollaboratorStateSchema = z.looseObject({
|
|
16
13
|
userId: z.string(),
|
|
17
14
|
projectId: z.string(),
|
|
18
15
|
state: z.enum(COLLABORATOR_STATUSES),
|
|
19
16
|
isDeleted: z.boolean(),
|
|
20
17
|
workspaceRole: WorkspaceRoleSchema.optional(),
|
|
21
|
-
})
|
|
22
|
-
.passthrough();
|
|
18
|
+
});
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export const CompletedProjectMetadataSchema = z
|
|
3
|
-
.object({
|
|
2
|
+
export const CompletedProjectMetadataSchema = z.looseObject({
|
|
4
3
|
projectId: z.string(),
|
|
5
4
|
archivedSections: z.number().int(),
|
|
6
5
|
completedItems: z.number().int(),
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
export const CompletedSectionMetadataSchema = z
|
|
10
|
-
.object({
|
|
6
|
+
});
|
|
7
|
+
export const CompletedSectionMetadataSchema = z.looseObject({
|
|
11
8
|
sectionId: z.string(),
|
|
12
9
|
id: z.string(),
|
|
13
10
|
completedItems: z.number().int(),
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
export const CompletedTaskMetadataSchema = z
|
|
17
|
-
.object({
|
|
11
|
+
});
|
|
12
|
+
export const CompletedTaskMetadataSchema = z.looseObject({
|
|
18
13
|
itemId: z.string(),
|
|
19
14
|
id: z.string().optional(),
|
|
20
15
|
completedItems: z.number().int(),
|
|
21
|
-
})
|
|
22
|
-
.passthrough();
|
|
16
|
+
});
|
|
23
17
|
export const CompletedInfoSchema = z.union([
|
|
24
18
|
CompletedProjectMetadataSchema,
|
|
25
19
|
CompletedSectionMetadataSchema,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export const FilterSchema = z
|
|
3
|
-
.object({
|
|
2
|
+
export const FilterSchema = z.looseObject({
|
|
4
3
|
id: z.string(),
|
|
5
4
|
name: z.string(),
|
|
6
5
|
query: z.string(),
|
|
@@ -9,5 +8,4 @@ export const FilterSchema = z
|
|
|
9
8
|
isFavorite: z.boolean(),
|
|
10
9
|
isFrozen: z.boolean(),
|
|
11
10
|
itemOrder: z.number().int(),
|
|
12
|
-
})
|
|
13
|
-
.passthrough();
|
|
11
|
+
});
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export const FolderSchema = z
|
|
3
|
-
.object({
|
|
2
|
+
export const FolderSchema = z.looseObject({
|
|
4
3
|
id: z.string(),
|
|
5
4
|
name: z.string(),
|
|
6
5
|
workspaceId: z.string(),
|
|
7
6
|
isDeleted: z.boolean(),
|
|
8
7
|
defaultOrder: z.number().int(),
|
|
9
8
|
childOrder: z.number().int(),
|
|
10
|
-
})
|
|
11
|
-
.passthrough();
|
|
9
|
+
});
|
|
@@ -5,7 +5,6 @@ export * from './tooltips.js';
|
|
|
5
5
|
export * from './notes.js';
|
|
6
6
|
export * from './workspace-filters.js';
|
|
7
7
|
export * from './workspace-goals.js';
|
|
8
|
-
export * from './goals.js';
|
|
9
8
|
export * from './calendars.js';
|
|
10
9
|
export * from './reminders.js';
|
|
11
10
|
export * from './completed-info.js';
|
|
@@ -2,13 +2,12 @@ import { z } from 'zod';
|
|
|
2
2
|
/**
|
|
3
3
|
* Live notification resource from the Sync API.
|
|
4
4
|
*
|
|
5
|
-
* Uses a
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Uses a loose object schema with commonly-present fields for forward
|
|
6
|
+
* compatibility. The Sync API returns 20+ notification variants; fully typing
|
|
7
|
+
* each is too fragile for a library, so we validate the common shape and
|
|
8
|
+
* preserve all extra fields.
|
|
9
9
|
*/
|
|
10
|
-
export const LiveNotificationSchema = z
|
|
11
|
-
.object({
|
|
10
|
+
export const LiveNotificationSchema = z.looseObject({
|
|
12
11
|
id: z.string(),
|
|
13
12
|
createdAt: z.string(),
|
|
14
13
|
fromUid: z.string(),
|
|
@@ -32,5 +31,4 @@ export const LiveNotificationSchema = z
|
|
|
32
31
|
projectName: z.string().optional(),
|
|
33
32
|
isDeleted: z.boolean().optional(),
|
|
34
33
|
invitationSecret: z.string().optional(),
|
|
35
|
-
})
|
|
36
|
-
.passthrough();
|
|
34
|
+
});
|
|
@@ -4,8 +4,7 @@ import { AttachmentSchema } from '../../comments/types.js';
|
|
|
4
4
|
* Sync API note (comment) resource.
|
|
5
5
|
* Separate from the REST `CommentSchema` which transforms `itemId` to `taskId`.
|
|
6
6
|
*/
|
|
7
|
-
export const NoteSchema = z
|
|
8
|
-
.object({
|
|
7
|
+
export const NoteSchema = z.looseObject({
|
|
9
8
|
id: z.string(),
|
|
10
9
|
itemId: z.string().optional(),
|
|
11
10
|
projectId: z.string().optional(),
|
|
@@ -16,5 +15,4 @@ export const NoteSchema = z
|
|
|
16
15
|
uidsToNotify: z.array(z.string()).nullable(),
|
|
17
16
|
reactions: z.record(z.string(), z.array(z.string())).nullable(),
|
|
18
17
|
isDeleted: z.boolean(),
|
|
19
|
-
})
|
|
20
|
-
.passthrough();
|
|
18
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { DueDateSchema } from '../../tasks/types.js';
|
|
3
|
-
export const ReminderBaseSchema = z.
|
|
3
|
+
export const ReminderBaseSchema = z.looseObject({
|
|
4
4
|
id: z.string(),
|
|
5
5
|
notifyUid: z.string(),
|
|
6
6
|
itemId: z.string(),
|
|
@@ -28,18 +28,18 @@ export const LocationReminderSchema = ReminderBaseSchema.extend({
|
|
|
28
28
|
locLong: z.string(),
|
|
29
29
|
locTrigger: z.enum(LOCATION_TRIGGERS),
|
|
30
30
|
radius: z.number().int(),
|
|
31
|
-
})
|
|
31
|
+
});
|
|
32
32
|
export const AbsoluteReminderSchema = ReminderBaseSchema.extend({
|
|
33
33
|
type: z.literal(ReminderTypeEnum.Absolute),
|
|
34
34
|
due: DueDateSchema,
|
|
35
35
|
isUrgent: z.boolean().optional(),
|
|
36
|
-
})
|
|
36
|
+
});
|
|
37
37
|
export const RelativeReminderSchema = ReminderBaseSchema.extend({
|
|
38
38
|
type: z.literal(ReminderTypeEnum.Relative),
|
|
39
39
|
minuteOffset: z.number().int(),
|
|
40
40
|
due: DueDateSchema.optional(),
|
|
41
41
|
isUrgent: z.boolean().optional(),
|
|
42
|
-
})
|
|
42
|
+
});
|
|
43
43
|
export const ReminderSchema = z.discriminatedUnion('type', [
|
|
44
44
|
LocationReminderSchema,
|
|
45
45
|
AbsoluteReminderSchema,
|
|
@@ -1,38 +1,32 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
/** Available template types. */
|
|
3
3
|
export const TEMPLATE_TYPES = ['project', 'setup'];
|
|
4
|
-
export const TemplateSuggestionSchema = z
|
|
5
|
-
.object({
|
|
4
|
+
export const TemplateSuggestionSchema = z.looseObject({
|
|
6
5
|
id: z.string(),
|
|
7
6
|
name: z.string(),
|
|
8
7
|
templateType: z.enum(TEMPLATE_TYPES),
|
|
9
|
-
})
|
|
10
|
-
.passthrough();
|
|
8
|
+
});
|
|
11
9
|
export const WorkspaceTemplateSuggestionSchema = TemplateSuggestionSchema.extend({
|
|
12
10
|
workspaceId: z.string().nullable(),
|
|
13
11
|
});
|
|
14
12
|
/** Available suggestion section types. */
|
|
15
13
|
export const SUGGESTION_SECTION_TYPES = ['templates', 'most_used_user_templates'];
|
|
16
|
-
export const SyncTemplateSuggestionsSchema = z
|
|
17
|
-
.object({
|
|
14
|
+
export const SyncTemplateSuggestionsSchema = z.looseObject({
|
|
18
15
|
type: z.enum(SUGGESTION_SECTION_TYPES),
|
|
19
16
|
content: z.object({
|
|
20
17
|
templates: z.array(TemplateSuggestionSchema),
|
|
21
18
|
locale: z.string(),
|
|
22
19
|
}),
|
|
23
20
|
isDeleted: z.boolean(),
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
export const SyncWorkspaceTemplateSuggestionsSchema = z
|
|
27
|
-
.object({
|
|
21
|
+
});
|
|
22
|
+
export const SyncWorkspaceTemplateSuggestionsSchema = z.looseObject({
|
|
28
23
|
type: z.literal('most_used_workspace_templates'),
|
|
29
24
|
content: z.object({
|
|
30
25
|
templates: z.array(WorkspaceTemplateSuggestionSchema),
|
|
31
26
|
locale: z.string(),
|
|
32
27
|
}),
|
|
33
28
|
isDeleted: z.boolean(),
|
|
34
|
-
})
|
|
35
|
-
.passthrough();
|
|
29
|
+
});
|
|
36
30
|
export const SuggestionSchema = z.union([
|
|
37
31
|
SyncWorkspaceTemplateSuggestionsSchema,
|
|
38
32
|
SyncTemplateSuggestionsSchema,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export const PlanLimitsSchema = z
|
|
3
|
-
.object({
|
|
2
|
+
export const PlanLimitsSchema = z.looseObject({
|
|
4
3
|
activeProjects: z.number().int().optional(),
|
|
5
4
|
activityLog: z.number().int().optional(),
|
|
6
5
|
collaboratorsPerProject: z.number().int().optional(),
|
|
@@ -11,11 +10,8 @@ export const PlanLimitsSchema = z
|
|
|
11
10
|
remindersPerUser: z.number().int().optional(),
|
|
12
11
|
sectionsPerProject: z.number().int().optional(),
|
|
13
12
|
tasksPerProject: z.number().int().optional(),
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
export const UserPlanLimitsSchema = z
|
|
17
|
-
.object({
|
|
13
|
+
});
|
|
14
|
+
export const UserPlanLimitsSchema = z.looseObject({
|
|
18
15
|
current: PlanLimitsSchema,
|
|
19
16
|
next: PlanLimitsSchema.nullable(),
|
|
20
|
-
})
|
|
21
|
-
.passthrough();
|
|
17
|
+
});
|
|
@@ -10,8 +10,7 @@ export const QuickAddFeatureSchema = z.object({
|
|
|
10
10
|
/**
|
|
11
11
|
* Sync API user settings resource.
|
|
12
12
|
*/
|
|
13
|
-
export const UserSettingsSchema = z
|
|
14
|
-
.object({
|
|
13
|
+
export const UserSettingsSchema = z.looseObject({
|
|
15
14
|
completedSoundDesktop: z.boolean(),
|
|
16
15
|
completedSoundMobile: z.boolean(),
|
|
17
16
|
debugLogSendingEnabledUntil: z.string().nullable(),
|
|
@@ -21,7 +20,7 @@ export const UserSettingsSchema = z
|
|
|
21
20
|
countsShown: z.boolean(),
|
|
22
21
|
features: z.array(NavigationFeatureSchema),
|
|
23
22
|
})
|
|
24
|
-
.
|
|
23
|
+
.loose(),
|
|
25
24
|
reminderDesktop: z.boolean(),
|
|
26
25
|
reminderEmail: z.boolean(),
|
|
27
26
|
reminderPush: z.boolean(),
|
|
@@ -34,6 +33,5 @@ export const UserSettingsSchema = z
|
|
|
34
33
|
labelsShown: z.boolean(),
|
|
35
34
|
features: z.array(QuickAddFeatureSchema),
|
|
36
35
|
})
|
|
37
|
-
.
|
|
38
|
-
})
|
|
39
|
-
.passthrough();
|
|
36
|
+
.loose(),
|
|
37
|
+
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { PREMIUM_STATUSES } from '../../users/types.js';
|
|
3
3
|
import { BooleanFromZeroOneSchema, DateFormatSchema, DayOfWeekSchema, TimeFormatSchema, } from '../user-preferences.js';
|
|
4
|
-
export const FeaturesSchema = z
|
|
5
|
-
.object({
|
|
4
|
+
export const FeaturesSchema = z.looseObject({
|
|
6
5
|
karmaDisabled: z.boolean(),
|
|
7
6
|
restriction: z.number().int(),
|
|
8
7
|
karmaVacation: z.boolean(),
|
|
@@ -13,40 +12,32 @@ export const FeaturesSchema = z
|
|
|
13
12
|
autoInviteDisabled: z.boolean().optional(),
|
|
14
13
|
goldTheme: z.boolean().optional(),
|
|
15
14
|
migratedFromTdb: z.boolean().optional(),
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
export const TzInfoSchema = z
|
|
19
|
-
.object({
|
|
15
|
+
});
|
|
16
|
+
export const TzInfoSchema = z.looseObject({
|
|
20
17
|
timezone: z.string(),
|
|
21
18
|
hours: z.number().int(),
|
|
22
19
|
minutes: z.number().int(),
|
|
23
20
|
isDst: BooleanFromZeroOneSchema,
|
|
24
21
|
gmtString: z.string(),
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
export const JoinableWorkspaceSchema = z
|
|
28
|
-
.object({
|
|
22
|
+
});
|
|
23
|
+
export const JoinableWorkspaceSchema = z.looseObject({
|
|
29
24
|
workspaceId: z.string(),
|
|
30
25
|
workspaceName: z.string(),
|
|
31
26
|
memberCount: z.number().int(),
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
export const GettingStartedGuideProjectSchema = z
|
|
35
|
-
.object({
|
|
27
|
+
});
|
|
28
|
+
export const GettingStartedGuideProjectSchema = z.looseObject({
|
|
36
29
|
onboardingUseCase: z.string(),
|
|
37
30
|
projectId: z.string(),
|
|
38
31
|
completed: z.boolean(),
|
|
39
32
|
closed: z.boolean(),
|
|
40
|
-
})
|
|
41
|
-
.passthrough();
|
|
33
|
+
});
|
|
42
34
|
/**
|
|
43
35
|
* Sync API user resource.
|
|
44
36
|
*
|
|
45
37
|
* This is a superset of the REST `CurrentUserSchema` — the Sync API returns
|
|
46
38
|
* many additional fields for features, onboarding state, and account details.
|
|
47
39
|
*/
|
|
48
|
-
export const SyncUserSchema = z
|
|
49
|
-
.object({
|
|
40
|
+
export const SyncUserSchema = z.looseObject({
|
|
50
41
|
id: z.string(),
|
|
51
42
|
email: z.string(),
|
|
52
43
|
fullName: z.string(),
|
|
@@ -113,5 +104,4 @@ export const SyncUserSchema = z
|
|
|
113
104
|
websocketUrl: z.string(),
|
|
114
105
|
weekendStartDay: z.number().int(),
|
|
115
106
|
weeklyGoal: z.number().int(),
|
|
116
|
-
})
|
|
117
|
-
.passthrough();
|
|
107
|
+
});
|
|
@@ -49,13 +49,10 @@ export const SORT_ORDERS = ['ASC', 'DESC'];
|
|
|
49
49
|
export const SortOrderSchema = z.enum(SORT_ORDERS).nullable();
|
|
50
50
|
/** Available calendar layout modes. */
|
|
51
51
|
export const CALENDAR_LAYOUTS = ['WEEK', 'MONTH'];
|
|
52
|
-
export const CalendarSettingsSchema = z
|
|
53
|
-
.object({
|
|
52
|
+
export const CalendarSettingsSchema = z.looseObject({
|
|
54
53
|
layout: z.enum(CALENDAR_LAYOUTS).optional(),
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
export const ViewOptionsSchema = z
|
|
58
|
-
.object({
|
|
54
|
+
});
|
|
55
|
+
export const ViewOptionsSchema = z.looseObject({
|
|
59
56
|
viewType: ViewTypeSchema,
|
|
60
57
|
objectId: z.string().optional(),
|
|
61
58
|
groupedBy: GroupedBySchema.optional(),
|
|
@@ -64,10 +61,8 @@ export const ViewOptionsSchema = z
|
|
|
64
61
|
showCompletedTasks: z.boolean().optional(),
|
|
65
62
|
sortedBy: SortedBySchema.optional(),
|
|
66
63
|
sortOrder: SortOrderSchema.optional(),
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
export const ProjectViewOptionsDefaultsSchema = z
|
|
70
|
-
.object({
|
|
64
|
+
});
|
|
65
|
+
export const ProjectViewOptionsDefaultsSchema = z.looseObject({
|
|
71
66
|
projectId: z.string(),
|
|
72
67
|
viewMode: ViewModeSchema.nullable().optional(),
|
|
73
68
|
groupedBy: GroupedBySchema.optional(),
|
|
@@ -76,5 +71,4 @@ export const ProjectViewOptionsDefaultsSchema = z
|
|
|
76
71
|
showCompletedTasks: z.boolean().optional(),
|
|
77
72
|
filteredBy: z.string().nullable().optional(),
|
|
78
73
|
calendarSettings: CalendarSettingsSchema.nullable().optional(),
|
|
79
|
-
})
|
|
80
|
-
.passthrough();
|
|
74
|
+
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export const WorkspaceFilterSchema = z
|
|
3
|
-
.object({
|
|
2
|
+
export const WorkspaceFilterSchema = z.looseObject({
|
|
4
3
|
id: z.string(),
|
|
5
4
|
workspaceId: z.string(),
|
|
6
5
|
name: z.string(),
|
|
@@ -14,5 +13,4 @@ export const WorkspaceFilterSchema = z
|
|
|
14
13
|
updaterUid: z.string(),
|
|
15
14
|
createdAt: z.string(),
|
|
16
15
|
updatedAt: z.string(),
|
|
17
|
-
})
|
|
18
|
-
.passthrough();
|
|
16
|
+
});
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export const WorkspaceGoalMilestoneSchema = z
|
|
3
|
-
.object({
|
|
2
|
+
export const WorkspaceGoalMilestoneSchema = z.looseObject({
|
|
4
3
|
id: z.string(),
|
|
5
4
|
title: z.string(),
|
|
6
5
|
isCompleted: z.boolean(),
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
export const WorkspaceGoalProgressSchema = z
|
|
10
|
-
.object({
|
|
6
|
+
});
|
|
7
|
+
export const WorkspaceGoalProgressSchema = z.looseObject({
|
|
11
8
|
completedItems: z.number().int(),
|
|
12
9
|
totalItems: z.number().int(),
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
export const WorkspaceGoalSchema = z
|
|
16
|
-
.object({
|
|
10
|
+
});
|
|
11
|
+
export const WorkspaceGoalSchema = z.looseObject({
|
|
17
12
|
id: z.string(),
|
|
18
13
|
workspaceId: z.string(),
|
|
19
14
|
title: z.string(),
|
|
@@ -25,5 +20,4 @@ export const WorkspaceGoalSchema = z
|
|
|
25
20
|
creatorUid: z.string(),
|
|
26
21
|
createdAt: z.string(),
|
|
27
22
|
updatedAt: z.string(),
|
|
28
|
-
})
|
|
29
|
-
.passthrough();
|
|
23
|
+
});
|
|
@@ -20,7 +20,7 @@ import { WorkspaceRoleSchema, WorkspacePlanSchema, WorkspaceLimitsSchema, Worksp
|
|
|
20
20
|
* domain settings, and sorting preferences.
|
|
21
21
|
*/
|
|
22
22
|
export const SyncWorkspaceSchema = z
|
|
23
|
-
.
|
|
23
|
+
.looseObject({
|
|
24
24
|
id: StringOrNumberSchema,
|
|
25
25
|
name: z.string(),
|
|
26
26
|
description: z.string(),
|
|
@@ -63,7 +63,6 @@ export const SyncWorkspaceSchema = z
|
|
|
63
63
|
.optional(),
|
|
64
64
|
properties: WorkspacePropertiesSchema.optional(),
|
|
65
65
|
})
|
|
66
|
-
.passthrough()
|
|
67
66
|
.transform((_a) => {
|
|
68
67
|
var { dateCreated, createdAt } = _a, rest = __rest(_a, ["dateCreated", "createdAt"]);
|
|
69
68
|
return (Object.assign(Object.assign({}, rest), { createdAt: createdAt !== null && createdAt !== void 0 ? createdAt : dateCreated }));
|
|
@@ -15,7 +15,12 @@ function createValidator(schema) {
|
|
|
15
15
|
return (input) => schema.parse(input);
|
|
16
16
|
}
|
|
17
17
|
function createArrayValidator(validateItem) {
|
|
18
|
-
return (input) =>
|
|
18
|
+
return (input) => {
|
|
19
|
+
if (!Array.isArray(input)) {
|
|
20
|
+
throw new TypeError(`Expected array, got ${typeof input}`);
|
|
21
|
+
}
|
|
22
|
+
return input.map(validateItem);
|
|
23
|
+
};
|
|
19
24
|
}
|
|
20
25
|
// Entity validators
|
|
21
26
|
export const validateTask = createValidator(TaskSchema);
|
|
@@ -48,6 +53,9 @@ export function validateProject(input) {
|
|
|
48
53
|
return PersonalProjectSchema.parse(input);
|
|
49
54
|
}
|
|
50
55
|
export function validateProjectArray(input) {
|
|
56
|
+
if (!Array.isArray(input)) {
|
|
57
|
+
throw new TypeError(`Expected array, got ${typeof input}`);
|
|
58
|
+
}
|
|
51
59
|
return input.map(validateProject);
|
|
52
60
|
}
|
|
53
61
|
export const validateWorkspaceProject = createValidator(WorkspaceProjectSchema);
|
|
@@ -132,3 +140,30 @@ export const validateSyncUser = createValidator(SyncUserSchema);
|
|
|
132
140
|
export const validateUserSettings = createValidator(UserSettingsSchema);
|
|
133
141
|
export const validateSuggestion = createValidator(SuggestionSchema);
|
|
134
142
|
export const validateSuggestionArray = createArrayValidator(validateSuggestion);
|
|
143
|
+
export function parseSyncResponse(raw) {
|
|
144
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, raw), ('items' in raw ? { items: validateTaskArray(raw.items) } : {})), ('projects' in raw ? { projects: validateProjectArray(raw.projects) } : {})), ('sections' in raw ? { sections: validateSectionArray(raw.sections) } : {})), ('labels' in raw ? { labels: validateLabelArray(raw.labels) } : {})), ('notes' in raw ? { notes: validateNoteArray(raw.notes) } : {})), ('projectNotes' in raw ? { projectNotes: validateNoteArray(raw.projectNotes) } : {})), ('filters' in raw ? { filters: validateFilterArray(raw.filters) } : {})), ('reminders' in raw ? { reminders: validateReminderArray(raw.reminders) } : {})), ('remindersLocation' in raw
|
|
145
|
+
? { remindersLocation: validateLocationReminderArray(raw.remindersLocation) }
|
|
146
|
+
: {})), ('user' in raw ? { user: validateSyncUser(raw.user) } : {})), ('liveNotifications' in raw
|
|
147
|
+
? { liveNotifications: validateLiveNotificationArray(raw.liveNotifications) }
|
|
148
|
+
: {})), ('collaborators' in raw
|
|
149
|
+
? { collaborators: validateCollaboratorArray(raw.collaborators) }
|
|
150
|
+
: {})), ('collaboratorStates' in raw
|
|
151
|
+
? { collaboratorStates: validateCollaboratorStateArray(raw.collaboratorStates) }
|
|
152
|
+
: {})), ('userSettings' in raw ? { userSettings: validateUserSettings(raw.userSettings) } : {})), ('userPlanLimits' in raw
|
|
153
|
+
? { userPlanLimits: validateUserPlanLimits(raw.userPlanLimits) }
|
|
154
|
+
: {})), ('completedInfo' in raw
|
|
155
|
+
? { completedInfo: validateCompletedInfoArray(raw.completedInfo) }
|
|
156
|
+
: {})), ('workspaces' in raw ? { workspaces: validateSyncWorkspaceArray(raw.workspaces) } : {})), ('workspaceUsers' in raw
|
|
157
|
+
? { workspaceUsers: validateWorkspaceUserArray(raw.workspaceUsers) }
|
|
158
|
+
: {})), ('workspaceFilters' in raw
|
|
159
|
+
? { workspaceFilters: validateWorkspaceFilterArray(raw.workspaceFilters) }
|
|
160
|
+
: {})), ('viewOptions' in raw ? { viewOptions: validateViewOptionsArray(raw.viewOptions) } : {})), ('projectViewOptionsDefaults' in raw
|
|
161
|
+
? {
|
|
162
|
+
projectViewOptionsDefaults: validateProjectViewOptionsDefaultsArray(raw.projectViewOptionsDefaults),
|
|
163
|
+
}
|
|
164
|
+
: {})), ('folders' in raw ? { folders: validateFolderArray(raw.folders) } : {})), ('workspaceGoals' in raw
|
|
165
|
+
? { workspaceGoals: validateWorkspaceGoalArray(raw.workspaceGoals) }
|
|
166
|
+
: {})), ('calendars' in raw ? { calendars: validateCalendarArray(raw.calendars) } : {})), ('calendarAccounts' in raw
|
|
167
|
+
? { calendarAccounts: validateCalendarAccountArray(raw.calendarAccounts) }
|
|
168
|
+
: {})), ('suggestions' in raw ? { suggestions: validateSuggestionArray(raw.suggestions) } : {})), ('tooltips' in raw ? { tooltips: validateTooltips(raw.tooltips) } : {}));
|
|
169
|
+
}
|
|
@@ -259,6 +259,11 @@ export declare class TodoistApi {
|
|
|
259
259
|
/**
|
|
260
260
|
* Deletes a project by its ID.
|
|
261
261
|
*
|
|
262
|
+
* If the project is a workspace project, it must have been
|
|
263
|
+
* archived first before it can be deleted, otherwise calling
|
|
264
|
+
* this function will result in an error. Personal projects can
|
|
265
|
+
* be deleted regardless of their archived status.
|
|
266
|
+
*
|
|
262
267
|
* @param id - The unique identifier of the project to delete.
|
|
263
268
|
* @param requestId - Optional custom identifier for the request.
|
|
264
269
|
* @returns A promise that resolves to `true` if successful.
|