@doist/todoist-sdk 8.4.0 → 8.5.0-next.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/consts/endpoints.js +6 -1
- package/dist/cjs/todoist-api.js +128 -0
- package/dist/cjs/types/goals/index.js +18 -0
- package/dist/cjs/types/goals/requests.js +2 -0
- package/dist/cjs/types/goals/types.js +29 -0
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/projects/types.js +11 -1
- package/dist/cjs/types/sync/commands/goals.js +2 -0
- package/dist/cjs/types/sync/commands/index.js +1 -0
- package/dist/cjs/types/sync/resource-types.js +1 -0
- package/dist/cjs/types/sync/response.js +55 -0
- package/dist/cjs/utils/validators.js +67 -142
- package/dist/esm/consts/endpoints.js +5 -0
- package/dist/esm/todoist-api.js +130 -2
- package/dist/esm/types/goals/index.js +2 -0
- package/dist/esm/types/goals/requests.js +1 -0
- package/dist/esm/types/goals/types.js +26 -0
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/projects/types.js +10 -0
- package/dist/esm/types/sync/commands/goals.js +1 -0
- package/dist/esm/types/sync/commands/index.js +1 -0
- package/dist/esm/types/sync/resource-types.js +1 -0
- package/dist/esm/types/sync/response.js +54 -1
- package/dist/esm/utils/validators.js +56 -129
- package/dist/types/consts/endpoints.d.ts +5 -0
- package/dist/types/todoist-api.d.ts +11 -0
- package/dist/types/types/goals/index.d.ts +2 -0
- package/dist/types/types/goals/requests.d.ts +33 -0
- package/dist/types/types/goals/types.d.ts +41 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/projects/types.d.ts +55 -0
- package/dist/types/types/sync/commands/goals.d.ts +33 -0
- package/dist/types/types/sync/commands/index.d.ts +9 -0
- package/dist/types/types/sync/resource-types.d.ts +1 -1
- package/dist/types/types/sync/resources/view-options.d.ts +6 -6
- package/dist/types/types/sync/response.d.ts +942 -51
- package/dist/types/types/tasks/requests.d.ts +1 -0
- package/dist/types/utils/validators.d.ts +194 -77
- package/package.json +1 -1
package/dist/esm/todoist-api.js
CHANGED
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { z } from 'zod';
|
|
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';
|
|
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, ENDPOINT_REST_GOALS, ENDPOINT_REST_GOALS_SEARCH, GOAL_COMPLETE, GOAL_UNCOMPLETE, GOAL_TASKS, } 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
16
|
import { normalizeObjectEventTypeForApi, denormalizeObjectTypeFromApi, } from './utils/activity-helpers.js';
|
|
@@ -18,7 +18,7 @@ import { camelCaseKeys } from './utils/case-conversion.js';
|
|
|
18
18
|
import { uploadMultipartFile } from './utils/multipart-upload.js';
|
|
19
19
|
import { processTaskContent } from './utils/uncompletable-helpers.js';
|
|
20
20
|
import { formatDateToYYYYMMDD } from './utils/url-helpers.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';
|
|
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, validateGoal, validateGoalArray, validateCollaboratorArray, validateCollaboratorStateArray, validateNoteArray, validateWorkspaceProject, validateWorkspaceProjectArray, parseSyncResponse, } from './utils/validators.js';
|
|
22
22
|
import { v4 as uuidv4 } from 'uuid';
|
|
23
23
|
import { TodoistArgumentError, TodoistRequestError } from './types/index.js';
|
|
24
24
|
import { DATE_FORMAT_TO_API, TIME_FORMAT_TO_API, DAY_OF_WEEK_TO_API, } from './types/sync/index.js';
|
|
@@ -1916,6 +1916,134 @@ export class TodoistApi {
|
|
|
1916
1916
|
});
|
|
1917
1917
|
return isSuccess(response);
|
|
1918
1918
|
}
|
|
1919
|
+
// ── Goals ──
|
|
1920
|
+
async getGoals(args) {
|
|
1921
|
+
const { data: { results, nextCursor }, } = await request({
|
|
1922
|
+
httpMethod: 'GET',
|
|
1923
|
+
baseUri: this.syncApiBase,
|
|
1924
|
+
relativePath: ENDPOINT_REST_GOALS,
|
|
1925
|
+
apiToken: this.authToken,
|
|
1926
|
+
customFetch: this.customFetch,
|
|
1927
|
+
payload: args,
|
|
1928
|
+
});
|
|
1929
|
+
return {
|
|
1930
|
+
results: validateGoalArray(results),
|
|
1931
|
+
nextCursor,
|
|
1932
|
+
};
|
|
1933
|
+
}
|
|
1934
|
+
async searchGoals(args) {
|
|
1935
|
+
const { data: { results, nextCursor }, } = await request({
|
|
1936
|
+
httpMethod: 'GET',
|
|
1937
|
+
baseUri: this.syncApiBase,
|
|
1938
|
+
relativePath: ENDPOINT_REST_GOALS_SEARCH,
|
|
1939
|
+
apiToken: this.authToken,
|
|
1940
|
+
customFetch: this.customFetch,
|
|
1941
|
+
payload: args,
|
|
1942
|
+
});
|
|
1943
|
+
return {
|
|
1944
|
+
results: validateGoalArray(results),
|
|
1945
|
+
nextCursor,
|
|
1946
|
+
};
|
|
1947
|
+
}
|
|
1948
|
+
async getGoal(id) {
|
|
1949
|
+
z.string().parse(id);
|
|
1950
|
+
const response = await request({
|
|
1951
|
+
httpMethod: 'GET',
|
|
1952
|
+
baseUri: this.syncApiBase,
|
|
1953
|
+
relativePath: generatePath(ENDPOINT_REST_GOALS, id),
|
|
1954
|
+
apiToken: this.authToken,
|
|
1955
|
+
customFetch: this.customFetch,
|
|
1956
|
+
});
|
|
1957
|
+
return validateGoal(response.data);
|
|
1958
|
+
}
|
|
1959
|
+
async addGoal(args, requestId) {
|
|
1960
|
+
const response = await request({
|
|
1961
|
+
httpMethod: 'POST',
|
|
1962
|
+
baseUri: this.syncApiBase,
|
|
1963
|
+
relativePath: ENDPOINT_REST_GOALS,
|
|
1964
|
+
apiToken: this.authToken,
|
|
1965
|
+
customFetch: this.customFetch,
|
|
1966
|
+
payload: args,
|
|
1967
|
+
requestId: requestId,
|
|
1968
|
+
});
|
|
1969
|
+
return validateGoal(response.data);
|
|
1970
|
+
}
|
|
1971
|
+
async updateGoal(id, args, requestId) {
|
|
1972
|
+
z.string().parse(id);
|
|
1973
|
+
const response = await request({
|
|
1974
|
+
httpMethod: 'POST',
|
|
1975
|
+
baseUri: this.syncApiBase,
|
|
1976
|
+
relativePath: generatePath(ENDPOINT_REST_GOALS, id),
|
|
1977
|
+
apiToken: this.authToken,
|
|
1978
|
+
customFetch: this.customFetch,
|
|
1979
|
+
payload: args,
|
|
1980
|
+
requestId: requestId,
|
|
1981
|
+
});
|
|
1982
|
+
return validateGoal(response.data);
|
|
1983
|
+
}
|
|
1984
|
+
async deleteGoal(id, requestId) {
|
|
1985
|
+
z.string().parse(id);
|
|
1986
|
+
const response = await request({
|
|
1987
|
+
httpMethod: 'DELETE',
|
|
1988
|
+
baseUri: this.syncApiBase,
|
|
1989
|
+
relativePath: generatePath(ENDPOINT_REST_GOALS, id),
|
|
1990
|
+
apiToken: this.authToken,
|
|
1991
|
+
customFetch: this.customFetch,
|
|
1992
|
+
requestId: requestId,
|
|
1993
|
+
});
|
|
1994
|
+
return isSuccess(response);
|
|
1995
|
+
}
|
|
1996
|
+
async completeGoal(id, requestId) {
|
|
1997
|
+
z.string().parse(id);
|
|
1998
|
+
const response = await request({
|
|
1999
|
+
httpMethod: 'POST',
|
|
2000
|
+
baseUri: this.syncApiBase,
|
|
2001
|
+
relativePath: generatePath(ENDPOINT_REST_GOALS, id, GOAL_COMPLETE),
|
|
2002
|
+
apiToken: this.authToken,
|
|
2003
|
+
customFetch: this.customFetch,
|
|
2004
|
+
requestId: requestId,
|
|
2005
|
+
});
|
|
2006
|
+
return validateGoal(response.data);
|
|
2007
|
+
}
|
|
2008
|
+
async uncompleteGoal(id, requestId) {
|
|
2009
|
+
z.string().parse(id);
|
|
2010
|
+
const response = await request({
|
|
2011
|
+
httpMethod: 'POST',
|
|
2012
|
+
baseUri: this.syncApiBase,
|
|
2013
|
+
relativePath: generatePath(ENDPOINT_REST_GOALS, id, GOAL_UNCOMPLETE),
|
|
2014
|
+
apiToken: this.authToken,
|
|
2015
|
+
customFetch: this.customFetch,
|
|
2016
|
+
requestId: requestId,
|
|
2017
|
+
});
|
|
2018
|
+
return validateGoal(response.data);
|
|
2019
|
+
}
|
|
2020
|
+
async linkTaskToGoal({ goalId, taskId }, requestId) {
|
|
2021
|
+
z.string().parse(goalId);
|
|
2022
|
+
z.string().parse(taskId);
|
|
2023
|
+
const response = await request({
|
|
2024
|
+
httpMethod: 'POST',
|
|
2025
|
+
baseUri: this.syncApiBase,
|
|
2026
|
+
relativePath: generatePath(ENDPOINT_REST_GOALS, goalId, GOAL_TASKS),
|
|
2027
|
+
apiToken: this.authToken,
|
|
2028
|
+
customFetch: this.customFetch,
|
|
2029
|
+
payload: { itemId: taskId },
|
|
2030
|
+
requestId: requestId,
|
|
2031
|
+
});
|
|
2032
|
+
return validateGoal(response.data);
|
|
2033
|
+
}
|
|
2034
|
+
async unlinkTaskFromGoal({ goalId, taskId }, requestId) {
|
|
2035
|
+
z.string().parse(goalId);
|
|
2036
|
+
z.string().parse(taskId);
|
|
2037
|
+
const response = await request({
|
|
2038
|
+
httpMethod: 'DELETE',
|
|
2039
|
+
baseUri: this.syncApiBase,
|
|
2040
|
+
relativePath: generatePath(ENDPOINT_REST_GOALS, goalId, GOAL_TASKS, taskId),
|
|
2041
|
+
apiToken: this.authToken,
|
|
2042
|
+
customFetch: this.customFetch,
|
|
2043
|
+
requestId: requestId,
|
|
2044
|
+
});
|
|
2045
|
+
return isSuccess(response);
|
|
2046
|
+
}
|
|
1919
2047
|
// ── Backups ──
|
|
1920
2048
|
/**
|
|
1921
2049
|
* Retrieves a list of available backups.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Available goal owner types. */
|
|
3
|
+
export const GOAL_OWNER_TYPES = ['USER', 'WORKSPACE'];
|
|
4
|
+
export const GoalProgressSchema = z.looseObject({
|
|
5
|
+
totalTaskCount: z.number().int(),
|
|
6
|
+
completedTaskCount: z.number().int(),
|
|
7
|
+
percentage: z.number(),
|
|
8
|
+
});
|
|
9
|
+
export const GoalSchema = z.looseObject({
|
|
10
|
+
id: z.string(),
|
|
11
|
+
ownerType: z.enum(GOAL_OWNER_TYPES),
|
|
12
|
+
ownerId: z.string(),
|
|
13
|
+
name: z.string(),
|
|
14
|
+
description: z.string().nullable(),
|
|
15
|
+
deadline: z.string().nullable(),
|
|
16
|
+
parentGoalId: z.string().nullable(),
|
|
17
|
+
childOrder: z.number().int(),
|
|
18
|
+
isCompleted: z.boolean(),
|
|
19
|
+
completedAt: z.coerce.date().nullable(),
|
|
20
|
+
responsibleUid: z.string().nullable(),
|
|
21
|
+
isDeleted: z.boolean(),
|
|
22
|
+
progress: GoalProgressSchema.optional(),
|
|
23
|
+
creatorUid: z.string(),
|
|
24
|
+
createdAt: z.coerce.date(),
|
|
25
|
+
updatedAt: z.coerce.date(),
|
|
26
|
+
});
|
package/dist/esm/types/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export * from './productivity/index.js';
|
|
|
9
9
|
export * from './activity/index.js';
|
|
10
10
|
export * from './workspaces/index.js';
|
|
11
11
|
export * from './folders/index.js';
|
|
12
|
+
export * from './goals/index.js';
|
|
12
13
|
export * from './insights/index.js';
|
|
13
14
|
export * from './backups/index.js';
|
|
14
15
|
export * from './id-mappings/index.js';
|
|
@@ -49,5 +49,15 @@ export const WorkspaceProjectSchema = BaseProjectSchema.extend({
|
|
|
49
49
|
}).transform((data) => {
|
|
50
50
|
return Object.assign(Object.assign({}, data), { url: getProjectUrl(data.id, data.name) });
|
|
51
51
|
});
|
|
52
|
+
/**
|
|
53
|
+
* Schema for any project type in Todoist (personal or workspace).
|
|
54
|
+
* Dispatches to WorkspaceProjectSchema when workspaceId is present, PersonalProjectSchema otherwise.
|
|
55
|
+
*/
|
|
56
|
+
export const ProjectSchema = z.unknown().transform((val) => {
|
|
57
|
+
if (typeof val === 'object' && val !== null && 'workspaceId' in val) {
|
|
58
|
+
return WorkspaceProjectSchema.parse(val);
|
|
59
|
+
}
|
|
60
|
+
return PersonalProjectSchema.parse(val);
|
|
61
|
+
});
|
|
52
62
|
/** Available project view styles. */
|
|
53
63
|
export const PROJECT_VIEW_STYLES = ['list', 'board', 'calendar'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -11,6 +11,7 @@ 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';
|
|
14
15
|
export * from './notifications.js';
|
|
15
16
|
export * from './sharing.js';
|
|
16
17
|
export * from './view-options.js';
|
|
@@ -1 +1,54 @@
|
|
|
1
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { GoalSchema } from '../goals/types.js';
|
|
3
|
+
import { LabelSchema } from '../labels/types.js';
|
|
4
|
+
import { ProjectSchema } from '../projects/types.js';
|
|
5
|
+
import { SectionSchema } from '../sections/types.js';
|
|
6
|
+
import { TaskSchema } from '../tasks/types.js';
|
|
7
|
+
import { WorkspaceUserSchema } from '../workspaces/types.js';
|
|
8
|
+
import { FilterSchema, CollaboratorSchema, CollaboratorStateSchema, FolderSchema, NoteSchema, TooltipsSchema, WorkspaceFilterSchema, WorkspaceGoalSchema, CalendarSchema, CalendarAccountSchema, ReminderSchema, LocationReminderSchema, CompletedInfoSchema, ViewOptionsSchema, ProjectViewOptionsDefaultsSchema, UserPlanLimitsSchema, LiveNotificationSchema, SyncWorkspaceSchema, SyncUserSchema, UserSettingsSchema, SuggestionSchema, } from './resources/index.js';
|
|
9
|
+
export const SyncErrorSchema = z.object({
|
|
10
|
+
error: z.string(),
|
|
11
|
+
errorCode: z.number(),
|
|
12
|
+
errorExtra: z.record(z.string(), z.unknown()),
|
|
13
|
+
errorTag: z.string(),
|
|
14
|
+
httpCode: z.number(),
|
|
15
|
+
});
|
|
16
|
+
export const SyncResponseSchema = z.looseObject({
|
|
17
|
+
syncToken: z.string().optional(),
|
|
18
|
+
fullSync: z.boolean().optional(),
|
|
19
|
+
syncStatus: z.record(z.string(), z.union([z.literal('ok'), SyncErrorSchema])).optional(),
|
|
20
|
+
tempIdMapping: z.record(z.string(), z.string()).optional(),
|
|
21
|
+
items: z.array(TaskSchema).optional(),
|
|
22
|
+
projects: z.array(ProjectSchema).optional(),
|
|
23
|
+
sections: z.array(SectionSchema).optional(),
|
|
24
|
+
labels: z.array(LabelSchema).optional(),
|
|
25
|
+
notes: z.array(NoteSchema).optional(),
|
|
26
|
+
projectNotes: z.array(NoteSchema).optional(),
|
|
27
|
+
filters: z.array(FilterSchema).optional(),
|
|
28
|
+
reminders: z.array(ReminderSchema).optional(),
|
|
29
|
+
remindersLocation: z.array(LocationReminderSchema).optional(),
|
|
30
|
+
locations: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
31
|
+
user: SyncUserSchema.optional(),
|
|
32
|
+
liveNotifications: z.array(LiveNotificationSchema).optional(),
|
|
33
|
+
collaborators: z.array(CollaboratorSchema).optional(),
|
|
34
|
+
collaboratorStates: z.array(CollaboratorStateSchema).optional(),
|
|
35
|
+
userSettings: UserSettingsSchema.optional(),
|
|
36
|
+
notificationSettings: z.record(z.string(), z.boolean()).optional(),
|
|
37
|
+
userPlanLimits: UserPlanLimitsSchema.optional(),
|
|
38
|
+
completedInfo: z.array(CompletedInfoSchema).optional(),
|
|
39
|
+
stats: z.record(z.string(), z.unknown()).optional(),
|
|
40
|
+
workspaces: z.array(SyncWorkspaceSchema).optional(),
|
|
41
|
+
workspaceUsers: z.array(WorkspaceUserSchema).optional(),
|
|
42
|
+
workspaceFilters: z.array(WorkspaceFilterSchema).optional(),
|
|
43
|
+
viewOptions: z.array(ViewOptionsSchema).optional(),
|
|
44
|
+
projectViewOptionsDefaults: z.array(ProjectViewOptionsDefaultsSchema).optional(),
|
|
45
|
+
roleActions: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
46
|
+
folders: z.array(FolderSchema).optional(),
|
|
47
|
+
goals: z.array(GoalSchema).optional(),
|
|
48
|
+
workspaceGoals: z.array(WorkspaceGoalSchema).optional(),
|
|
49
|
+
dayOrders: z.record(z.string(), z.number()).optional(),
|
|
50
|
+
calendars: z.array(CalendarSchema).optional(),
|
|
51
|
+
calendarAccounts: z.array(CalendarAccountSchema).optional(),
|
|
52
|
+
suggestions: z.array(SuggestionSchema).optional(),
|
|
53
|
+
tooltips: TooltipsSchema.optional(),
|
|
54
|
+
});
|
|
@@ -1,153 +1,80 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import { ActivityEventSchema } from '../types/activity/types.js';
|
|
2
3
|
import { BackupSchema } from '../types/backups/types.js';
|
|
3
4
|
import { AttachmentSchema, CommentSchema } from '../types/comments/types.js';
|
|
5
|
+
import { GoalSchema } from '../types/goals/types.js';
|
|
4
6
|
import { IdMappingSchema, MovedIdSchema } from '../types/id-mappings/types.js';
|
|
5
7
|
import { ProjectActivityStatsSchema, ProjectHealthSchema, ProjectHealthContextSchema, ProjectProgressSchema, WorkspaceInsightsSchema, } from '../types/insights/types.js';
|
|
6
8
|
import { LabelSchema } from '../types/labels/types.js';
|
|
7
9
|
import { ProductivityStatsSchema } from '../types/productivity/types.js';
|
|
8
|
-
import {
|
|
10
|
+
import { WorkspaceProjectSchema, ProjectSchema } from '../types/projects/types.js';
|
|
9
11
|
import { SectionSchema } from '../types/sections/types.js';
|
|
12
|
+
import { SyncResponseSchema } from '../types/sync/response.js';
|
|
10
13
|
import { TaskSchema } from '../types/tasks/types.js';
|
|
11
14
|
import { UserSchema, CurrentUserSchema } from '../types/users/types.js';
|
|
12
15
|
import { WorkspaceUserSchema, WorkspaceInvitationSchema, WorkspacePlanDetailsSchema, JoinWorkspaceResultSchema, WorkspaceSchema, MemberActivityInfoSchema, WorkspaceUserTaskSchema, } from '../types/workspaces/types.js';
|
|
13
16
|
import { FilterSchema, CollaboratorSchema, CollaboratorStateSchema, FolderSchema, NoteSchema, TooltipsSchema, WorkspaceFilterSchema, WorkspaceGoalSchema, CalendarSchema, CalendarAccountSchema, ReminderSchema, LocationReminderSchema, CompletedInfoSchema, ViewOptionsSchema, ProjectViewOptionsDefaultsSchema, UserPlanLimitsSchema, LiveNotificationSchema, SyncWorkspaceSchema, SyncUserSchema, UserSettingsSchema, SuggestionSchema, } from '../types/sync/resources/index.js';
|
|
14
17
|
function createValidator(schema) {
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return (input) => {
|
|
19
|
-
if (!Array.isArray(input)) {
|
|
20
|
-
throw new TypeError(`Expected array, got ${typeof input}`);
|
|
21
|
-
}
|
|
22
|
-
return input.map(validateItem);
|
|
18
|
+
return {
|
|
19
|
+
validate: (input) => schema.parse(input),
|
|
20
|
+
validateArray: (input) => z.array(schema).parse(input),
|
|
23
21
|
};
|
|
24
22
|
}
|
|
25
23
|
// Entity validators
|
|
26
|
-
export const validateTask = createValidator(TaskSchema);
|
|
27
|
-
export const validateTaskArray = createArrayValidator(validateTask);
|
|
24
|
+
export const { validate: validateTask, validateArray: validateTaskArray } = createValidator(TaskSchema);
|
|
28
25
|
/**
|
|
29
26
|
* Validates and parses a project input.
|
|
30
27
|
* @param input The input to validate
|
|
31
28
|
* @returns A validated project (either PersonalProject or WorkspaceProject)
|
|
32
29
|
*/
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
export const
|
|
46
|
-
export const
|
|
47
|
-
export const
|
|
48
|
-
export const
|
|
49
|
-
export const
|
|
50
|
-
export const
|
|
51
|
-
export const
|
|
52
|
-
export const
|
|
53
|
-
export const
|
|
54
|
-
export const
|
|
55
|
-
export const
|
|
56
|
-
export const
|
|
57
|
-
export const
|
|
58
|
-
export const validateActivityEventArray = createArrayValidator(validateActivityEvent);
|
|
59
|
-
export const validateAttachment = createValidator(AttachmentSchema);
|
|
60
|
-
export const validateWorkspaceUser = createValidator(WorkspaceUserSchema);
|
|
61
|
-
export function validateWorkspaceUserArray(input) {
|
|
62
|
-
if (!Array.isArray(input)) {
|
|
63
|
-
throw new Error(`Expected array for workspace users, got ${typeof input}`);
|
|
64
|
-
}
|
|
65
|
-
return input.map(validateWorkspaceUser);
|
|
66
|
-
}
|
|
67
|
-
export const validateWorkspaceInvitation = createValidator(WorkspaceInvitationSchema);
|
|
68
|
-
export const validateWorkspaceInvitationArray = createArrayValidator(validateWorkspaceInvitation);
|
|
69
|
-
export const validateWorkspacePlanDetails = createValidator(WorkspacePlanDetailsSchema);
|
|
70
|
-
export const validateJoinWorkspaceResult = createValidator(JoinWorkspaceResultSchema);
|
|
71
|
-
export const validateWorkspace = createValidator(WorkspaceSchema);
|
|
72
|
-
export const validateWorkspaceArray = createArrayValidator(validateWorkspace);
|
|
73
|
-
export const validateMemberActivityInfo = createValidator(MemberActivityInfoSchema);
|
|
74
|
-
export const validateMemberActivityInfoArray = createArrayValidator(validateMemberActivityInfo);
|
|
75
|
-
export const validateWorkspaceUserTask = createValidator(WorkspaceUserTaskSchema);
|
|
76
|
-
export const validateWorkspaceUserTaskArray = createArrayValidator(validateWorkspaceUserTask);
|
|
77
|
-
export const validateProjectActivityStats = createValidator(ProjectActivityStatsSchema);
|
|
78
|
-
export const validateProjectHealth = createValidator(ProjectHealthSchema);
|
|
79
|
-
export const validateProjectHealthContext = createValidator(ProjectHealthContextSchema);
|
|
80
|
-
export const validateProjectProgress = createValidator(ProjectProgressSchema);
|
|
81
|
-
export const validateWorkspaceInsights = createValidator(WorkspaceInsightsSchema);
|
|
82
|
-
export const validateBackup = createValidator(BackupSchema);
|
|
83
|
-
export const validateBackupArray = createArrayValidator(validateBackup);
|
|
84
|
-
export const validateIdMapping = createValidator(IdMappingSchema);
|
|
85
|
-
export const validateIdMappingArray = createArrayValidator(validateIdMapping);
|
|
86
|
-
export const validateMovedId = createValidator(MovedIdSchema);
|
|
87
|
-
export const validateMovedIdArray = createArrayValidator(validateMovedId);
|
|
30
|
+
export const { validate: validateProject, validateArray: validateProjectArray } = createValidator(ProjectSchema);
|
|
31
|
+
export const { validate: validateWorkspaceProject, validateArray: validateWorkspaceProjectArray } = createValidator(WorkspaceProjectSchema);
|
|
32
|
+
export const { validate: validateSection, validateArray: validateSectionArray } = createValidator(SectionSchema);
|
|
33
|
+
export const { validate: validateLabel, validateArray: validateLabelArray } = createValidator(LabelSchema);
|
|
34
|
+
export const { validate: validateComment, validateArray: validateCommentArray } = createValidator(CommentSchema);
|
|
35
|
+
export const { validate: validateUser, validateArray: validateUserArray } = createValidator(UserSchema);
|
|
36
|
+
export const { validate: validateProductivityStats } = createValidator(ProductivityStatsSchema);
|
|
37
|
+
export const { validate: validateCurrentUser } = createValidator(CurrentUserSchema);
|
|
38
|
+
export const { validate: validateActivityEvent, validateArray: validateActivityEventArray } = createValidator(ActivityEventSchema);
|
|
39
|
+
export const { validate: validateAttachment } = createValidator(AttachmentSchema);
|
|
40
|
+
export const { validate: validateWorkspaceUser, validateArray: validateWorkspaceUserArray } = createValidator(WorkspaceUserSchema);
|
|
41
|
+
export const { validate: validateWorkspaceInvitation, validateArray: validateWorkspaceInvitationArray, } = createValidator(WorkspaceInvitationSchema);
|
|
42
|
+
export const { validate: validateWorkspacePlanDetails } = createValidator(WorkspacePlanDetailsSchema);
|
|
43
|
+
export const { validate: validateJoinWorkspaceResult } = createValidator(JoinWorkspaceResultSchema);
|
|
44
|
+
export const { validate: validateWorkspace, validateArray: validateWorkspaceArray } = createValidator(WorkspaceSchema);
|
|
45
|
+
export const { validate: validateMemberActivityInfo, validateArray: validateMemberActivityInfoArray, } = createValidator(MemberActivityInfoSchema);
|
|
46
|
+
export const { validate: validateWorkspaceUserTask, validateArray: validateWorkspaceUserTaskArray, } = createValidator(WorkspaceUserTaskSchema);
|
|
47
|
+
export const { validate: validateProjectActivityStats } = createValidator(ProjectActivityStatsSchema);
|
|
48
|
+
export const { validate: validateProjectHealth } = createValidator(ProjectHealthSchema);
|
|
49
|
+
export const { validate: validateProjectHealthContext } = createValidator(ProjectHealthContextSchema);
|
|
50
|
+
export const { validate: validateProjectProgress } = createValidator(ProjectProgressSchema);
|
|
51
|
+
export const { validate: validateWorkspaceInsights } = createValidator(WorkspaceInsightsSchema);
|
|
52
|
+
export const { validate: validateBackup, validateArray: validateBackupArray } = createValidator(BackupSchema);
|
|
53
|
+
export const { validate: validateIdMapping, validateArray: validateIdMappingArray } = createValidator(IdMappingSchema);
|
|
54
|
+
export const { validate: validateMovedId, validateArray: validateMovedIdArray } = createValidator(MovedIdSchema);
|
|
88
55
|
// Sync resource validators
|
|
89
|
-
export const validateFilter = createValidator(FilterSchema);
|
|
90
|
-
export const
|
|
91
|
-
export const
|
|
92
|
-
export const
|
|
93
|
-
export const
|
|
94
|
-
export const
|
|
95
|
-
export const
|
|
96
|
-
export const
|
|
97
|
-
export const
|
|
98
|
-
export const
|
|
99
|
-
export const
|
|
100
|
-
export const
|
|
101
|
-
export const
|
|
102
|
-
export const
|
|
103
|
-
export const
|
|
104
|
-
export const
|
|
105
|
-
export const
|
|
106
|
-
export const
|
|
107
|
-
export const
|
|
108
|
-
export const
|
|
109
|
-
export const
|
|
110
|
-
export const
|
|
111
|
-
export const validateLocationReminderArray = createArrayValidator(validateLocationReminder);
|
|
112
|
-
export const validateCompletedInfo = createValidator(CompletedInfoSchema);
|
|
113
|
-
export const validateCompletedInfoArray = createArrayValidator(validateCompletedInfo);
|
|
114
|
-
export const validateViewOptions = createValidator(ViewOptionsSchema);
|
|
115
|
-
export const validateViewOptionsArray = createArrayValidator(validateViewOptions);
|
|
116
|
-
export const validateProjectViewOptionsDefaults = createValidator(ProjectViewOptionsDefaultsSchema);
|
|
117
|
-
export const validateProjectViewOptionsDefaultsArray = createArrayValidator(validateProjectViewOptionsDefaults);
|
|
118
|
-
export const validateUserPlanLimits = createValidator(UserPlanLimitsSchema);
|
|
119
|
-
export const validateLiveNotification = createValidator(LiveNotificationSchema);
|
|
120
|
-
export const validateLiveNotificationArray = createArrayValidator(validateLiveNotification);
|
|
121
|
-
export const validateSyncWorkspace = createValidator(SyncWorkspaceSchema);
|
|
122
|
-
export const validateSyncWorkspaceArray = createArrayValidator(validateSyncWorkspace);
|
|
123
|
-
export const validateSyncUser = createValidator(SyncUserSchema);
|
|
124
|
-
export const validateUserSettings = createValidator(UserSettingsSchema);
|
|
125
|
-
export const validateSuggestion = createValidator(SuggestionSchema);
|
|
126
|
-
export const validateSuggestionArray = createArrayValidator(validateSuggestion);
|
|
56
|
+
export const { validate: validateFilter, validateArray: validateFilterArray } = createValidator(FilterSchema);
|
|
57
|
+
export const { validate: validateCollaborator, validateArray: validateCollaboratorArray } = createValidator(CollaboratorSchema);
|
|
58
|
+
export const { validate: validateCollaboratorState, validateArray: validateCollaboratorStateArray, } = createValidator(CollaboratorStateSchema);
|
|
59
|
+
export const { validate: validateFolder, validateArray: validateFolderArray } = createValidator(FolderSchema);
|
|
60
|
+
export const { validate: validateGoal, validateArray: validateGoalArray } = createValidator(GoalSchema);
|
|
61
|
+
export const { validate: validateNote, validateArray: validateNoteArray } = createValidator(NoteSchema);
|
|
62
|
+
export const { validate: validateTooltips } = createValidator(TooltipsSchema);
|
|
63
|
+
export const { validate: validateWorkspaceFilter, validateArray: validateWorkspaceFilterArray } = createValidator(WorkspaceFilterSchema);
|
|
64
|
+
export const { validate: validateWorkspaceGoal, validateArray: validateWorkspaceGoalArray } = createValidator(WorkspaceGoalSchema);
|
|
65
|
+
export const { validate: validateCalendar, validateArray: validateCalendarArray } = createValidator(CalendarSchema);
|
|
66
|
+
export const { validate: validateCalendarAccount, validateArray: validateCalendarAccountArray } = createValidator(CalendarAccountSchema);
|
|
67
|
+
export const { validate: validateReminder, validateArray: validateReminderArray } = createValidator(ReminderSchema);
|
|
68
|
+
export const { validate: validateLocationReminder, validateArray: validateLocationReminderArray } = createValidator(LocationReminderSchema);
|
|
69
|
+
export const { validate: validateCompletedInfo, validateArray: validateCompletedInfoArray } = createValidator(CompletedInfoSchema);
|
|
70
|
+
export const { validate: validateViewOptions, validateArray: validateViewOptionsArray } = createValidator(ViewOptionsSchema);
|
|
71
|
+
export const { validate: validateProjectViewOptionsDefaults, validateArray: validateProjectViewOptionsDefaultsArray, } = createValidator(ProjectViewOptionsDefaultsSchema);
|
|
72
|
+
export const { validate: validateUserPlanLimits } = createValidator(UserPlanLimitsSchema);
|
|
73
|
+
export const { validate: validateLiveNotification, validateArray: validateLiveNotificationArray } = createValidator(LiveNotificationSchema);
|
|
74
|
+
export const { validate: validateSyncWorkspace, validateArray: validateSyncWorkspaceArray } = createValidator(SyncWorkspaceSchema);
|
|
75
|
+
export const { validate: validateSyncUser } = createValidator(SyncUserSchema);
|
|
76
|
+
export const { validate: validateUserSettings } = createValidator(UserSettingsSchema);
|
|
77
|
+
export const { validate: validateSuggestion, validateArray: validateSuggestionArray } = createValidator(SuggestionSchema);
|
|
127
78
|
export function parseSyncResponse(raw) {
|
|
128
|
-
return
|
|
129
|
-
? { remindersLocation: validateLocationReminderArray(raw.remindersLocation) }
|
|
130
|
-
: {})), ('user' in raw ? { user: validateSyncUser(raw.user) } : {})), ('liveNotifications' in raw
|
|
131
|
-
? { liveNotifications: validateLiveNotificationArray(raw.liveNotifications) }
|
|
132
|
-
: {})), ('collaborators' in raw
|
|
133
|
-
? { collaborators: validateCollaboratorArray(raw.collaborators) }
|
|
134
|
-
: {})), ('collaboratorStates' in raw
|
|
135
|
-
? { collaboratorStates: validateCollaboratorStateArray(raw.collaboratorStates) }
|
|
136
|
-
: {})), ('userSettings' in raw ? { userSettings: validateUserSettings(raw.userSettings) } : {})), ('userPlanLimits' in raw
|
|
137
|
-
? { userPlanLimits: validateUserPlanLimits(raw.userPlanLimits) }
|
|
138
|
-
: {})), ('completedInfo' in raw
|
|
139
|
-
? { completedInfo: validateCompletedInfoArray(raw.completedInfo) }
|
|
140
|
-
: {})), ('workspaces' in raw ? { workspaces: validateSyncWorkspaceArray(raw.workspaces) } : {})), ('workspaceUsers' in raw
|
|
141
|
-
? { workspaceUsers: validateWorkspaceUserArray(raw.workspaceUsers) }
|
|
142
|
-
: {})), ('workspaceFilters' in raw
|
|
143
|
-
? { workspaceFilters: validateWorkspaceFilterArray(raw.workspaceFilters) }
|
|
144
|
-
: {})), ('viewOptions' in raw ? { viewOptions: validateViewOptionsArray(raw.viewOptions) } : {})), ('projectViewOptionsDefaults' in raw
|
|
145
|
-
? {
|
|
146
|
-
projectViewOptionsDefaults: validateProjectViewOptionsDefaultsArray(raw.projectViewOptionsDefaults),
|
|
147
|
-
}
|
|
148
|
-
: {})), ('folders' in raw ? { folders: validateFolderArray(raw.folders) } : {})), ('workspaceGoals' in raw
|
|
149
|
-
? { workspaceGoals: validateWorkspaceGoalArray(raw.workspaceGoals) }
|
|
150
|
-
: {})), ('calendars' in raw ? { calendars: validateCalendarArray(raw.calendars) } : {})), ('calendarAccounts' in raw
|
|
151
|
-
? { calendarAccounts: validateCalendarAccountArray(raw.calendarAccounts) }
|
|
152
|
-
: {})), ('suggestions' in raw ? { suggestions: validateSuggestionArray(raw.suggestions) } : {})), ('tooltips' in raw ? { tooltips: validateTooltips(raw.tooltips) } : {}));
|
|
79
|
+
return SyncResponseSchema.parse(raw);
|
|
153
80
|
}
|
|
@@ -58,6 +58,11 @@ export declare const ENDPOINT_GET_TOKEN = "access_token";
|
|
|
58
58
|
export declare const ENDPOINT_REVOKE = "revoke";
|
|
59
59
|
export declare const ENDPOINT_REGISTER = "register";
|
|
60
60
|
export declare const ENDPOINT_REST_FOLDERS = "folders";
|
|
61
|
+
export declare const ENDPOINT_REST_GOALS = "goals";
|
|
62
|
+
export declare const ENDPOINT_REST_GOALS_SEARCH: string;
|
|
63
|
+
export declare const GOAL_COMPLETE = "complete";
|
|
64
|
+
export declare const GOAL_UNCOMPLETE = "uncomplete";
|
|
65
|
+
export declare const GOAL_TASKS = "items";
|
|
61
66
|
export declare const ENDPOINT_REST_WORKSPACES = "workspaces";
|
|
62
67
|
export declare const ENDPOINT_WORKSPACE_INVITATIONS = "workspaces/invitations";
|
|
63
68
|
export declare const ENDPOINT_WORKSPACE_INVITATIONS_ALL = "workspaces/invitations/all";
|
|
@@ -4,6 +4,7 @@ import { Backup, GetBackupsArgs, DownloadBackupArgs } from './types/backups/inde
|
|
|
4
4
|
import { Attachment, Comment, AddCommentArgs, UpdateCommentArgs, GetProjectCommentsArgs, GetTaskCommentsArgs, GetCommentsResponse } from './types/comments/index.js';
|
|
5
5
|
import { GetOrCreateEmailArgs, GetOrCreateEmailResponse, DisableEmailArgs } from './types/emails/index.js';
|
|
6
6
|
import { GetFoldersArgs, GetFoldersResponse, AddFolderArgs, UpdateFolderArgs } from './types/folders/index.js';
|
|
7
|
+
import type { Goal, GetGoalsArgs, GetGoalsResponse, SearchGoalsArgs, AddGoalArgs, UpdateGoalArgs, TaskLinkingArgs } from './types/goals/index.js';
|
|
7
8
|
import { CustomFetch, CustomFetchResponse } from './types/http.js';
|
|
8
9
|
import { IdMapping, MovedId, GetIdMappingsArgs, GetMovedIdsArgs } from './types/id-mappings/index.js';
|
|
9
10
|
import { ProjectActivityStats, ProjectHealth, ProjectHealthContext, ProjectProgress, WorkspaceInsights, GetProjectActivityStatsArgs, GetWorkspaceInsightsArgs } from './types/insights/index.js';
|
|
@@ -763,6 +764,16 @@ export declare class TodoistApi {
|
|
|
763
764
|
* @returns A promise that resolves to `true` if successful.
|
|
764
765
|
*/
|
|
765
766
|
deleteFolder(id: string, requestId?: string): Promise<boolean>;
|
|
767
|
+
getGoals(args?: GetGoalsArgs): Promise<GetGoalsResponse>;
|
|
768
|
+
searchGoals(args: SearchGoalsArgs): Promise<GetGoalsResponse>;
|
|
769
|
+
getGoal(id: string): Promise<Goal>;
|
|
770
|
+
addGoal(args: AddGoalArgs, requestId?: string): Promise<Goal>;
|
|
771
|
+
updateGoal(id: string, args: UpdateGoalArgs, requestId?: string): Promise<Goal>;
|
|
772
|
+
deleteGoal(id: string, requestId?: string): Promise<boolean>;
|
|
773
|
+
completeGoal(id: string, requestId?: string): Promise<Goal>;
|
|
774
|
+
uncompleteGoal(id: string, requestId?: string): Promise<Goal>;
|
|
775
|
+
linkTaskToGoal({ goalId, taskId }: TaskLinkingArgs, requestId?: string): Promise<Goal>;
|
|
776
|
+
unlinkTaskFromGoal({ goalId, taskId }: TaskLinkingArgs, requestId?: string): Promise<boolean>;
|
|
766
777
|
/**
|
|
767
778
|
* Retrieves a list of available backups.
|
|
768
779
|
*
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { SearchArgs } from '../common.js';
|
|
2
|
+
import type { Workspace } from '../workspaces/index.js';
|
|
3
|
+
import type { Goal, GoalOwnerType } from './types.js';
|
|
4
|
+
export type GetGoalsArgs = {
|
|
5
|
+
ownerType?: GoalOwnerType;
|
|
6
|
+
workspaceId?: Workspace['id'];
|
|
7
|
+
cursor?: string | null;
|
|
8
|
+
limit?: number;
|
|
9
|
+
};
|
|
10
|
+
export type SearchGoalsArgs = SearchArgs & {
|
|
11
|
+
ownerType?: GoalOwnerType;
|
|
12
|
+
};
|
|
13
|
+
export type GetGoalsResponse = {
|
|
14
|
+
results: Goal[];
|
|
15
|
+
nextCursor: string | null;
|
|
16
|
+
};
|
|
17
|
+
export type AddGoalArgs = {
|
|
18
|
+
name: string;
|
|
19
|
+
workspaceId?: string;
|
|
20
|
+
description?: string | null;
|
|
21
|
+
deadline?: string | null;
|
|
22
|
+
responsibleUid?: string | null;
|
|
23
|
+
};
|
|
24
|
+
export type UpdateGoalArgs = {
|
|
25
|
+
name?: string;
|
|
26
|
+
description?: string | null;
|
|
27
|
+
deadline?: string | null;
|
|
28
|
+
responsibleUid?: string | null;
|
|
29
|
+
};
|
|
30
|
+
export type TaskLinkingArgs = {
|
|
31
|
+
goalId: string;
|
|
32
|
+
taskId: string;
|
|
33
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Available goal owner types. */
|
|
3
|
+
export declare const GOAL_OWNER_TYPES: readonly ["USER", "WORKSPACE"];
|
|
4
|
+
/** Goal owner type. */
|
|
5
|
+
export type GoalOwnerType = (typeof GOAL_OWNER_TYPES)[number];
|
|
6
|
+
export declare const GoalProgressSchema: z.ZodObject<{
|
|
7
|
+
totalTaskCount: z.ZodNumber;
|
|
8
|
+
completedTaskCount: z.ZodNumber;
|
|
9
|
+
percentage: z.ZodNumber;
|
|
10
|
+
}, z.core.$loose>;
|
|
11
|
+
export type GoalProgress = z.infer<typeof GoalProgressSchema>;
|
|
12
|
+
export declare const GoalSchema: z.ZodObject<{
|
|
13
|
+
id: z.ZodString;
|
|
14
|
+
ownerType: z.ZodEnum<{
|
|
15
|
+
USER: "USER";
|
|
16
|
+
WORKSPACE: "WORKSPACE";
|
|
17
|
+
}>;
|
|
18
|
+
ownerId: z.ZodString;
|
|
19
|
+
name: z.ZodString;
|
|
20
|
+
description: z.ZodNullable<z.ZodString>;
|
|
21
|
+
deadline: z.ZodNullable<z.ZodString>;
|
|
22
|
+
parentGoalId: z.ZodNullable<z.ZodString>;
|
|
23
|
+
childOrder: z.ZodNumber;
|
|
24
|
+
isCompleted: z.ZodBoolean;
|
|
25
|
+
completedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
26
|
+
responsibleUid: z.ZodNullable<z.ZodString>;
|
|
27
|
+
isDeleted: z.ZodBoolean;
|
|
28
|
+
progress: z.ZodOptional<z.ZodObject<{
|
|
29
|
+
totalTaskCount: z.ZodNumber;
|
|
30
|
+
completedTaskCount: z.ZodNumber;
|
|
31
|
+
percentage: z.ZodNumber;
|
|
32
|
+
}, z.core.$loose>>;
|
|
33
|
+
creatorUid: z.ZodString;
|
|
34
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
35
|
+
updatedAt: z.ZodCoercedDate<unknown>;
|
|
36
|
+
}, z.core.$loose>;
|
|
37
|
+
/**
|
|
38
|
+
* Represents a goal in Todoist.
|
|
39
|
+
* Goals support dual ownership: personal (ownerType=USER) and workspace (ownerType=WORKSPACE).
|
|
40
|
+
*/
|
|
41
|
+
export type Goal = z.infer<typeof GoalSchema>;
|