@doist/todoist-sdk 9.0.0 → 9.1.0-next.2

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.
Files changed (103) hide show
  1. package/dist/cjs/clients/activity-client.js +63 -0
  2. package/dist/cjs/clients/backup-client.js +65 -0
  3. package/dist/cjs/clients/base-client.js +30 -0
  4. package/dist/cjs/clients/comment-client.js +92 -0
  5. package/dist/cjs/clients/email-client.js +43 -0
  6. package/dist/cjs/clients/folder-client.js +80 -0
  7. package/dist/cjs/clients/goals-client.js +145 -0
  8. package/dist/cjs/clients/id-mapping-client.js +39 -0
  9. package/dist/cjs/clients/insights-client.js +88 -0
  10. package/dist/cjs/clients/label-client.js +127 -0
  11. package/dist/cjs/clients/productivity-client.js +27 -0
  12. package/dist/cjs/clients/project-client.js +232 -0
  13. package/dist/cjs/clients/reminder-client.js +198 -0
  14. package/dist/cjs/clients/section-client.js +118 -0
  15. package/dist/cjs/clients/task-client.js +255 -0
  16. package/dist/cjs/clients/template-client.js +89 -0
  17. package/dist/cjs/clients/upload-client.js +102 -0
  18. package/dist/cjs/clients/workspace-client.js +367 -0
  19. package/dist/cjs/consts/endpoints.js +6 -1
  20. package/dist/cjs/test-utils/test-defaults.js +25 -1
  21. package/dist/cjs/todoist-api.js +186 -1537
  22. package/dist/cjs/transport/sync-request.js +75 -0
  23. package/dist/cjs/types/goals/index.js +18 -0
  24. package/dist/cjs/types/goals/requests.js +2 -0
  25. package/dist/cjs/types/goals/types.js +56 -0
  26. package/dist/cjs/types/index.js +1 -0
  27. package/dist/cjs/types/sync/commands/goals.js +2 -0
  28. package/dist/cjs/types/sync/commands/index.js +1 -0
  29. package/dist/cjs/types/sync/resource-types.js +1 -0
  30. package/dist/cjs/types/sync/response.js +12 -10
  31. package/dist/cjs/utils/headers.js +16 -0
  32. package/dist/cjs/utils/request-helpers.js +21 -0
  33. package/dist/cjs/utils/validators.js +48 -46
  34. package/dist/esm/clients/activity-client.js +59 -0
  35. package/dist/esm/clients/backup-client.js +61 -0
  36. package/dist/esm/clients/base-client.js +26 -0
  37. package/dist/esm/clients/comment-client.js +88 -0
  38. package/dist/esm/clients/email-client.js +39 -0
  39. package/dist/esm/clients/folder-client.js +76 -0
  40. package/dist/esm/clients/goals-client.js +141 -0
  41. package/dist/esm/clients/id-mapping-client.js +35 -0
  42. package/dist/esm/clients/insights-client.js +84 -0
  43. package/dist/esm/clients/label-client.js +123 -0
  44. package/dist/esm/clients/productivity-client.js +23 -0
  45. package/dist/esm/clients/project-client.js +228 -0
  46. package/dist/esm/clients/reminder-client.js +194 -0
  47. package/dist/esm/clients/section-client.js +114 -0
  48. package/dist/esm/clients/task-client.js +251 -0
  49. package/dist/esm/clients/template-client.js +85 -0
  50. package/dist/esm/clients/upload-client.js +98 -0
  51. package/dist/esm/clients/workspace-client.js +363 -0
  52. package/dist/esm/consts/endpoints.js +5 -0
  53. package/dist/esm/test-utils/test-defaults.js +24 -0
  54. package/dist/esm/todoist-api.js +189 -1540
  55. package/dist/esm/transport/sync-request.js +72 -0
  56. package/dist/esm/types/goals/index.js +2 -0
  57. package/dist/esm/types/goals/requests.js +1 -0
  58. package/dist/esm/types/goals/types.js +53 -0
  59. package/dist/esm/types/index.js +1 -0
  60. package/dist/esm/types/sync/commands/goals.js +1 -0
  61. package/dist/esm/types/sync/commands/index.js +1 -0
  62. package/dist/esm/types/sync/resource-types.js +1 -0
  63. package/dist/esm/types/sync/response.js +2 -0
  64. package/dist/esm/utils/headers.js +13 -0
  65. package/dist/esm/utils/request-helpers.js +17 -0
  66. package/dist/esm/utils/validators.js +2 -0
  67. package/dist/types/clients/activity-client.d.ts +12 -0
  68. package/dist/types/clients/backup-client.d.ts +14 -0
  69. package/dist/types/clients/base-client.d.ts +21 -0
  70. package/dist/types/clients/comment-client.d.ts +15 -0
  71. package/dist/types/clients/email-client.d.ts +13 -0
  72. package/dist/types/clients/folder-client.d.ts +16 -0
  73. package/dist/types/clients/goals-client.d.ts +20 -0
  74. package/dist/types/clients/id-mapping-client.d.ts +13 -0
  75. package/dist/types/clients/insights-client.d.ts +18 -0
  76. package/dist/types/clients/label-client.d.ts +19 -0
  77. package/dist/types/clients/productivity-client.d.ts +12 -0
  78. package/dist/types/clients/project-client.d.ts +26 -0
  79. package/dist/types/clients/reminder-client.d.ts +25 -0
  80. package/dist/types/clients/section-client.d.ts +18 -0
  81. package/dist/types/clients/task-client.d.ts +25 -0
  82. package/dist/types/clients/template-client.d.ts +17 -0
  83. package/dist/types/clients/upload-client.d.ts +17 -0
  84. package/dist/types/clients/workspace-client.d.ts +43 -0
  85. package/dist/types/consts/endpoints.d.ts +5 -0
  86. package/dist/types/test-utils/test-defaults.d.ts +4 -1
  87. package/dist/types/todoist-api.d.ts +48 -17
  88. package/dist/types/transport/sync-request.d.ts +27 -0
  89. package/dist/types/types/goals/index.d.ts +2 -0
  90. package/dist/types/types/goals/requests.d.ts +33 -0
  91. package/dist/types/types/goals/types.d.ts +51 -0
  92. package/dist/types/types/http.d.ts +7 -0
  93. package/dist/types/types/index.d.ts +1 -0
  94. package/dist/types/types/sync/commands/goals.d.ts +33 -0
  95. package/dist/types/types/sync/commands/index.d.ts +9 -0
  96. package/dist/types/types/sync/resource-types.d.ts +1 -1
  97. package/dist/types/types/sync/resources/view-options.d.ts +6 -6
  98. package/dist/types/types/sync/response.d.ts +29 -4
  99. package/dist/types/types/tasks/requests.d.ts +1 -0
  100. package/dist/types/utils/headers.d.ts +7 -0
  101. package/dist/types/utils/request-helpers.d.ts +13 -0
  102. package/dist/types/utils/validators.d.ts +55 -8
  103. package/package.json +1 -1
@@ -0,0 +1,72 @@
1
+ import { ENDPOINT_SYNC } from '../consts/endpoints.js';
2
+ import { TodoistRequestError } from '../types/index.js';
3
+ import { DATE_FORMAT_TO_API, TIME_FORMAT_TO_API, DAY_OF_WEEK_TO_API, } from '../types/sync/index.js';
4
+ import { spreadIfDefined } from '../utils/request-helpers.js';
5
+ import { parseSyncResponse } from '../utils/validators.js';
6
+ import { request } from './http-client.js';
7
+ function serializeUserUpdateArgs(args) {
8
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, args), spreadIfDefined(args.dateFormat, (v) => ({
9
+ dateFormat: DATE_FORMAT_TO_API[v],
10
+ }))), spreadIfDefined(args.timeFormat, (v) => ({
11
+ timeFormat: TIME_FORMAT_TO_API[v],
12
+ }))), spreadIfDefined(args.startDay, (v) => ({
13
+ startDay: DAY_OF_WEEK_TO_API[v],
14
+ }))), spreadIfDefined(args.nextWeek, (v) => ({
15
+ nextWeek: DAY_OF_WEEK_TO_API[v],
16
+ })));
17
+ }
18
+ function serializeTaskUpdateDateCompleteArgs(args) {
19
+ return Object.assign(Object.assign(Object.assign({}, args), { isForward: args.isForward ? 1 : 0 }), spreadIfDefined(args.resetSubtasks, (v) => ({
20
+ resetSubtasks: v ? 1 : 0,
21
+ })));
22
+ }
23
+ function serializeUpdateGoalsArgs(args) {
24
+ return Object.assign(Object.assign(Object.assign({}, args), spreadIfDefined(args.vacationMode, (v) => ({ vacationMode: v ? 1 : 0 }))), spreadIfDefined(args.karmaDisabled, (v) => ({
25
+ karmaDisabled: v ? 1 : 0,
26
+ })));
27
+ }
28
+ function preprocessSyncCommands(commands) {
29
+ return commands.map((cmd) => {
30
+ if (cmd.type === 'user_update')
31
+ return Object.assign(Object.assign({}, cmd), { args: serializeUserUpdateArgs(cmd.args) });
32
+ if (cmd.type === 'item_update_date_complete')
33
+ return Object.assign(Object.assign({}, cmd), { args: serializeTaskUpdateDateCompleteArgs(cmd.args) });
34
+ if (cmd.type === 'update_goals')
35
+ return Object.assign(Object.assign({}, cmd), { args: serializeUpdateGoalsArgs(cmd.args) });
36
+ return cmd;
37
+ });
38
+ }
39
+ /**
40
+ * Makes a request to the Sync API and handles error checking.
41
+ *
42
+ * @param ctx - HTTP identity (auth token, sync API base URI, optional custom fetch).
43
+ * @param syncRequest - The sync request payload.
44
+ * @param options - Optional request identifier and commands flag.
45
+ * @returns The sync response data.
46
+ * @throws TodoistRequestError if sync status contains errors.
47
+ */
48
+ export async function performSyncRequest(ctx, syncRequest, options = {}) {
49
+ var _a;
50
+ const { requestId, hasSyncCommands = false } = options;
51
+ const processedRequest = ((_a = syncRequest.commands) === null || _a === void 0 ? void 0 : _a.length)
52
+ ? Object.assign(Object.assign({}, syncRequest), { commands: preprocessSyncCommands(syncRequest.commands) }) : syncRequest;
53
+ const response = await request({
54
+ httpMethod: 'POST',
55
+ baseUri: ctx.syncApiBase,
56
+ relativePath: ENDPOINT_SYNC,
57
+ apiToken: ctx.authToken,
58
+ customFetch: ctx.customFetch,
59
+ payload: processedRequest,
60
+ requestId: requestId,
61
+ hasSyncCommands: hasSyncCommands,
62
+ });
63
+ // Check for sync errors and throw if any are found
64
+ if (response.data.syncStatus) {
65
+ Object.entries(response.data.syncStatus).forEach(([_, value]) => {
66
+ if (value === 'ok')
67
+ return;
68
+ throw new TodoistRequestError(value.error, value.httpCode, value.errorExtra);
69
+ });
70
+ }
71
+ return parseSyncResponse(response.data);
72
+ }
@@ -0,0 +1,2 @@
1
+ export * from './types.js';
2
+ export * from './requests.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,53 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { z } from 'zod';
13
+ /** Available goal owner types. */
14
+ export const GOAL_OWNER_TYPES = ['USER', 'WORKSPACE'];
15
+ /**
16
+ * Progress of a {@link Goal}.
17
+ *
18
+ * The REST API returns these counts under `total_item_count` / `completed_item_count`,
19
+ * reflecting the backend's generic "item" terminology. The SDK normalizes them to
20
+ * `totalTaskCount` / `completedTaskCount` so the public surface consistently speaks
21
+ * in "tasks" (matching the rest of the SDK). The `preprocess` step below performs
22
+ * that rename after the transport layer's snake_case → camelCase conversion — do not
23
+ * remove it without also changing the downstream field names.
24
+ */
25
+ export const GoalProgressSchema = z.preprocess((raw) => {
26
+ if (raw === null || raw === undefined || typeof raw !== 'object' || Array.isArray(raw)) {
27
+ return raw;
28
+ }
29
+ const _a = raw, { totalItemCount, completedItemCount, totalTaskCount, completedTaskCount } = _a, rest = __rest(_a, ["totalItemCount", "completedItemCount", "totalTaskCount", "completedTaskCount"]);
30
+ return Object.assign(Object.assign({}, rest), { totalTaskCount: totalTaskCount !== null && totalTaskCount !== void 0 ? totalTaskCount : totalItemCount, completedTaskCount: completedTaskCount !== null && completedTaskCount !== void 0 ? completedTaskCount : completedItemCount });
31
+ }, z.looseObject({
32
+ totalTaskCount: z.number().int(),
33
+ completedTaskCount: z.number().int(),
34
+ percentage: z.number(),
35
+ }));
36
+ export const GoalSchema = z.looseObject({
37
+ id: z.string(),
38
+ ownerType: z.enum(GOAL_OWNER_TYPES),
39
+ ownerId: z.string(),
40
+ name: z.string(),
41
+ description: z.string().nullable(),
42
+ deadline: z.string().nullable(),
43
+ parentGoalId: z.string().nullable(),
44
+ childOrder: z.number().int(),
45
+ isCompleted: z.boolean(),
46
+ completedAt: z.coerce.date().nullable(),
47
+ responsibleUid: z.string().nullable(),
48
+ isDeleted: z.boolean(),
49
+ progress: GoalProgressSchema.optional(),
50
+ creatorUid: z.string(),
51
+ createdAt: z.coerce.date(),
52
+ updatedAt: z.coerce.date(),
53
+ });
@@ -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';
@@ -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';
@@ -29,6 +29,7 @@ export const SYNC_RESOURCE_TYPES = [
29
29
  'role_actions',
30
30
  'folders',
31
31
  'workspace_goals',
32
+ 'goals',
32
33
  'day_orders',
33
34
  'calendars',
34
35
  'calendar_accounts',
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { GoalSchema } from '../goals/types.js';
2
3
  import { LabelSchema } from '../labels/types.js';
3
4
  import { ProjectSchema } from '../projects/types.js';
4
5
  import { SectionSchema } from '../sections/types.js';
@@ -43,6 +44,7 @@ export const SyncResponseSchema = z.looseObject({
43
44
  projectViewOptionsDefaults: z.array(ProjectViewOptionsDefaultsSchema).optional(),
44
45
  roleActions: z.array(z.record(z.string(), z.unknown())).optional(),
45
46
  folders: z.array(FolderSchema).optional(),
47
+ goals: z.array(GoalSchema).optional(),
46
48
  workspaceGoals: z.array(WorkspaceGoalSchema).optional(),
47
49
  dayOrders: z.record(z.string(), z.number()).optional(),
48
50
  calendars: z.array(CalendarSchema).optional(),
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Converts a native Fetch `Headers` object into a plain `Record<string, string>`.
3
+ * Used when wrapping a native `fetch` response into the SDK's `FileResponse`
4
+ * shape (which expects headers as a plain record for symmetry with
5
+ * `CustomFetchResponse`).
6
+ */
7
+ export function headersToRecord(headers) {
8
+ const result = {};
9
+ headers.forEach((value, key) => {
10
+ result[key] = value;
11
+ });
12
+ return result;
13
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Joins path segments using `/` separator.
3
+ * @param segments A list of **valid** path segments.
4
+ * @returns A joined path.
5
+ */
6
+ export function generatePath(...segments) {
7
+ return segments.join('/');
8
+ }
9
+ /**
10
+ * Returns `fn(value)` spread into an object if `value` is defined, otherwise an empty object.
11
+ *
12
+ * Used to conditionally include a property on a payload object without
13
+ * resorting to mutation or ternary-built object literals.
14
+ */
15
+ export function spreadIfDefined(value, fn) {
16
+ return value !== undefined ? fn(value) : {};
17
+ }
@@ -2,6 +2,7 @@ import { z } from 'zod';
2
2
  import { ActivityEventSchema } from '../types/activity/types.js';
3
3
  import { BackupSchema } from '../types/backups/types.js';
4
4
  import { AttachmentSchema, CommentSchema } from '../types/comments/types.js';
5
+ import { GoalSchema } from '../types/goals/types.js';
5
6
  import { IdMappingSchema, MovedIdSchema } from '../types/id-mappings/types.js';
6
7
  import { ProjectActivityStatsSchema, ProjectHealthSchema, ProjectHealthContextSchema, ProjectProgressSchema, WorkspaceInsightsSchema, } from '../types/insights/types.js';
7
8
  import { LabelSchema } from '../types/labels/types.js';
@@ -56,6 +57,7 @@ export const { validate: validateFilter, validateArray: validateFilterArray } =
56
57
  export const { validate: validateCollaborator, validateArray: validateCollaboratorArray } = createValidator(CollaboratorSchema);
57
58
  export const { validate: validateCollaboratorState, validateArray: validateCollaboratorStateArray, } = createValidator(CollaboratorStateSchema);
58
59
  export const { validate: validateFolder, validateArray: validateFolderArray } = createValidator(FolderSchema);
60
+ export const { validate: validateGoal, validateArray: validateGoalArray } = createValidator(GoalSchema);
59
61
  export const { validate: validateNote, validateArray: validateNoteArray } = createValidator(NoteSchema);
60
62
  export const { validate: validateTooltips } = createValidator(TooltipsSchema);
61
63
  export const { validate: validateWorkspaceFilter, validateArray: validateWorkspaceFilterArray } = createValidator(WorkspaceFilterSchema);
@@ -0,0 +1,12 @@
1
+ import type { GetActivityLogsArgs, GetActivityLogsResponse } from '../types/activity/index.js';
2
+ import { BaseClient } from './base-client.js';
3
+ /**
4
+ * Internal sub-client handling the activity-log endpoint.
5
+ *
6
+ * Instantiated by `TodoistApi`; the public `getActivityLogs` method on
7
+ * `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
8
+ * JSDoc.
9
+ */
10
+ export declare class ActivityClient extends BaseClient {
11
+ getActivityLogs(args?: GetActivityLogsArgs): Promise<GetActivityLogsResponse>;
12
+ }
@@ -0,0 +1,14 @@
1
+ import type { Backup, DownloadBackupArgs, GetBackupsArgs } from '../types/backups/index.js';
2
+ import type { FileResponse } from '../types/http.js';
3
+ import { BaseClient } from './base-client.js';
4
+ /**
5
+ * Internal sub-client handling backup-domain endpoints.
6
+ *
7
+ * Instantiated by `TodoistApi`; every public backup method on
8
+ * `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
9
+ * JSDoc.
10
+ */
11
+ export declare class BackupClient extends BaseClient {
12
+ getBackups(args?: GetBackupsArgs): Promise<Backup[]>;
13
+ downloadBackup(args: DownloadBackupArgs): Promise<FileResponse>;
14
+ }
@@ -0,0 +1,21 @@
1
+ import type { SyncRequestContext } from '../transport/sync-request.js';
2
+ import type { CustomFetch } from '../types/http.js';
3
+ /**
4
+ * Internal base class for every domain sub-client (tasks, projects, …).
5
+ *
6
+ * Not exported from the package — sub-clients are an implementation detail
7
+ * of `TodoistApi`. Holds the three pieces of HTTP identity every sub-client
8
+ * needs and exposes a typed accessor to feed the Sync API helper.
9
+ *
10
+ * The constructor takes a {@link SyncRequestContext} — the same record
11
+ * shape used by `performSyncRequest` — so there is a single type describing
12
+ * "the HTTP identity an SDK component needs", not two types that must stay
13
+ * in sync.
14
+ */
15
+ export declare abstract class BaseClient {
16
+ protected readonly authToken: string;
17
+ protected readonly syncApiBase: string;
18
+ protected readonly customFetch?: CustomFetch;
19
+ constructor(context: SyncRequestContext);
20
+ protected get syncContext(): SyncRequestContext;
21
+ }
@@ -0,0 +1,15 @@
1
+ import type { AddCommentArgs, Comment, GetCommentsResponse, GetProjectCommentsArgs, GetTaskCommentsArgs, UpdateCommentArgs } from '../types/comments/index.js';
2
+ import { BaseClient } from './base-client.js';
3
+ /**
4
+ * Internal sub-client handling all comment-domain endpoints.
5
+ *
6
+ * Instantiated by `TodoistApi`; every public comment method on `TodoistApi`
7
+ * delegates here. See `todoist-api.ts` for the user-facing JSDoc.
8
+ */
9
+ export declare class CommentClient extends BaseClient {
10
+ getComments(args: GetTaskCommentsArgs | GetProjectCommentsArgs): Promise<GetCommentsResponse>;
11
+ getComment(id: string): Promise<Comment>;
12
+ addComment(args: AddCommentArgs, requestId?: string): Promise<Comment>;
13
+ updateComment(id: string, args: UpdateCommentArgs, requestId?: string): Promise<Comment>;
14
+ deleteComment(id: string, requestId?: string): Promise<boolean>;
15
+ }
@@ -0,0 +1,13 @@
1
+ import type { DisableEmailArgs, GetOrCreateEmailArgs, GetOrCreateEmailResponse } from '../types/emails/index.js';
2
+ import { BaseClient } from './base-client.js';
3
+ /**
4
+ * Internal sub-client handling email-forwarding endpoints.
5
+ *
6
+ * Instantiated by `TodoistApi`; every public email-forwarding method on
7
+ * `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
8
+ * JSDoc.
9
+ */
10
+ export declare class EmailClient extends BaseClient {
11
+ getOrCreateEmailForwarding(args: GetOrCreateEmailArgs, requestId?: string): Promise<GetOrCreateEmailResponse>;
12
+ disableEmailForwarding(args: DisableEmailArgs, requestId?: string): Promise<boolean>;
13
+ }
@@ -0,0 +1,16 @@
1
+ import type { AddFolderArgs, GetFoldersArgs, GetFoldersResponse, UpdateFolderArgs } from '../types/folders/index.js';
2
+ import type { Folder } from '../types/sync/resources/folders.js';
3
+ import { BaseClient } from './base-client.js';
4
+ /**
5
+ * Internal sub-client handling all folder-domain endpoints.
6
+ *
7
+ * Instantiated by `TodoistApi`; every public folder method on `TodoistApi`
8
+ * delegates here. See `todoist-api.ts` for the user-facing JSDoc.
9
+ */
10
+ export declare class FolderClient extends BaseClient {
11
+ getFolders(args: GetFoldersArgs): Promise<GetFoldersResponse>;
12
+ getFolder(id: string): Promise<Folder>;
13
+ addFolder(args: AddFolderArgs, requestId?: string): Promise<Folder>;
14
+ updateFolder(id: string, args: UpdateFolderArgs, requestId?: string): Promise<Folder>;
15
+ deleteFolder(id: string, requestId?: string): Promise<boolean>;
16
+ }
@@ -0,0 +1,20 @@
1
+ import type { AddGoalArgs, GetGoalsArgs, GetGoalsResponse, Goal, SearchGoalsArgs, TaskLinkingArgs, UpdateGoalArgs } from '../types/goals/index.js';
2
+ import { BaseClient } from './base-client.js';
3
+ /**
4
+ * Internal sub-client handling all goal-domain endpoints.
5
+ *
6
+ * Instantiated by `TodoistApi`; every public goal method on `TodoistApi`
7
+ * delegates here. See `todoist-api.ts` for the user-facing JSDoc.
8
+ */
9
+ export declare class GoalsClient extends BaseClient {
10
+ getGoals(args?: GetGoalsArgs): Promise<GetGoalsResponse>;
11
+ searchGoals(args: SearchGoalsArgs): Promise<GetGoalsResponse>;
12
+ getGoal(id: string): Promise<Goal>;
13
+ addGoal(args: AddGoalArgs, requestId?: string): Promise<Goal>;
14
+ updateGoal(id: string, args: UpdateGoalArgs, requestId?: string): Promise<Goal>;
15
+ deleteGoal(id: string, requestId?: string): Promise<boolean>;
16
+ completeGoal(id: string, requestId?: string): Promise<Goal>;
17
+ uncompleteGoal(id: string, requestId?: string): Promise<Goal>;
18
+ linkTaskToGoal({ goalId, taskId }: TaskLinkingArgs, requestId?: string): Promise<Goal>;
19
+ unlinkTaskFromGoal({ goalId, taskId }: TaskLinkingArgs, requestId?: string): Promise<boolean>;
20
+ }
@@ -0,0 +1,13 @@
1
+ import type { GetIdMappingsArgs, GetMovedIdsArgs, IdMapping, MovedId } from '../types/id-mappings/index.js';
2
+ import { BaseClient } from './base-client.js';
3
+ /**
4
+ * Internal sub-client handling ID-mapping endpoints.
5
+ *
6
+ * Instantiated by `TodoistApi`; every public id-mapping method on
7
+ * `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
8
+ * JSDoc.
9
+ */
10
+ export declare class IdMappingClient extends BaseClient {
11
+ getIdMappings(args: GetIdMappingsArgs): Promise<IdMapping[]>;
12
+ getMovedIds(args: GetMovedIdsArgs): Promise<MovedId[]>;
13
+ }
@@ -0,0 +1,18 @@
1
+ import type { GetProjectActivityStatsArgs, GetWorkspaceInsightsArgs, ProjectActivityStats, ProjectHealth, ProjectHealthContext, ProjectProgress, WorkspaceInsights } from '../types/insights/index.js';
2
+ import { BaseClient } from './base-client.js';
3
+ /**
4
+ * Internal sub-client handling all insights-domain endpoints
5
+ * (project activity stats, health, progress, workspace insights).
6
+ *
7
+ * Instantiated by `TodoistApi`; every public insights method on
8
+ * `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
9
+ * JSDoc.
10
+ */
11
+ export declare class InsightsClient extends BaseClient {
12
+ getProjectActivityStats(projectId: string, args?: GetProjectActivityStatsArgs): Promise<ProjectActivityStats>;
13
+ getProjectHealth(projectId: string): Promise<ProjectHealth>;
14
+ getProjectHealthContext(projectId: string): Promise<ProjectHealthContext>;
15
+ getProjectProgress(projectId: string): Promise<ProjectProgress>;
16
+ getWorkspaceInsights(workspaceId: string, args?: GetWorkspaceInsightsArgs): Promise<WorkspaceInsights>;
17
+ analyzeProjectHealth(projectId: string, requestId?: string): Promise<ProjectHealth>;
18
+ }
@@ -0,0 +1,19 @@
1
+ import type { AddLabelArgs, GetLabelsArgs, GetLabelsResponse, GetSharedLabelsArgs, GetSharedLabelsResponse, Label, RemoveSharedLabelArgs, RenameSharedLabelArgs, SearchLabelsArgs, UpdateLabelArgs } from '../types/labels/index.js';
2
+ import { BaseClient } from './base-client.js';
3
+ /**
4
+ * Internal sub-client handling all label-domain endpoints.
5
+ *
6
+ * Instantiated by `TodoistApi`; every public label method on `TodoistApi`
7
+ * delegates here. See `todoist-api.ts` for the user-facing JSDoc.
8
+ */
9
+ export declare class LabelClient extends BaseClient {
10
+ getLabel(id: string): Promise<Label>;
11
+ getLabels(args?: GetLabelsArgs): Promise<GetLabelsResponse>;
12
+ searchLabels(args: SearchLabelsArgs): Promise<GetLabelsResponse>;
13
+ addLabel(args: AddLabelArgs, requestId?: string): Promise<Label>;
14
+ updateLabel(id: string, args: UpdateLabelArgs, requestId?: string): Promise<Label>;
15
+ deleteLabel(id: string, requestId?: string): Promise<boolean>;
16
+ getSharedLabels(args?: GetSharedLabelsArgs): Promise<GetSharedLabelsResponse>;
17
+ renameSharedLabel(args: RenameSharedLabelArgs): Promise<boolean>;
18
+ removeSharedLabel(args: RemoveSharedLabelArgs): Promise<boolean>;
19
+ }
@@ -0,0 +1,12 @@
1
+ import type { ProductivityStats } from '../types/productivity/index.js';
2
+ import { BaseClient } from './base-client.js';
3
+ /**
4
+ * Internal sub-client handling the productivity-stats endpoint.
5
+ *
6
+ * Instantiated by `TodoistApi`; the public `getProductivityStats` method
7
+ * on `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
8
+ * JSDoc.
9
+ */
10
+ export declare class ProductivityClient extends BaseClient {
11
+ getProductivityStats(): Promise<ProductivityStats>;
12
+ }
@@ -0,0 +1,26 @@
1
+ import type { AddProjectArgs, GetArchivedProjectsArgs, GetArchivedProjectsCountArgs, GetArchivedProjectsCountResponse, GetArchivedProjectsResponse, GetFullProjectArgs, GetFullProjectResponse, GetProjectCollaboratorsArgs, GetProjectCollaboratorsResponse, GetProjectPermissionsResponse, GetProjectsArgs, GetProjectsResponse, JoinProjectResponse, MoveProjectToPersonalArgs, MoveProjectToWorkspaceArgs, PersonalProject, SearchProjectsArgs, UpdateProjectArgs, WorkspaceProject } from '../types/projects/index.js';
2
+ import { BaseClient } from './base-client.js';
3
+ /**
4
+ * Internal sub-client handling all project-domain endpoints.
5
+ *
6
+ * Instantiated by `TodoistApi`; every public project method on `TodoistApi`
7
+ * delegates here. See `todoist-api.ts` for the user-facing JSDoc.
8
+ */
9
+ export declare class ProjectClient extends BaseClient {
10
+ getProject(id: string): Promise<PersonalProject | WorkspaceProject>;
11
+ getProjects(args?: GetProjectsArgs): Promise<GetProjectsResponse>;
12
+ searchProjects(args: SearchProjectsArgs): Promise<GetProjectsResponse>;
13
+ getArchivedProjects(args?: GetArchivedProjectsArgs): Promise<GetArchivedProjectsResponse>;
14
+ addProject(args: AddProjectArgs, requestId?: string): Promise<PersonalProject | WorkspaceProject>;
15
+ updateProject(id: string, args: UpdateProjectArgs, requestId?: string): Promise<PersonalProject | WorkspaceProject>;
16
+ deleteProject(id: string, requestId?: string): Promise<boolean>;
17
+ archiveProject(id: string, requestId?: string): Promise<PersonalProject | WorkspaceProject>;
18
+ unarchiveProject(id: string, requestId?: string): Promise<PersonalProject | WorkspaceProject>;
19
+ moveProjectToWorkspace(args: MoveProjectToWorkspaceArgs, requestId?: string): Promise<PersonalProject | WorkspaceProject>;
20
+ moveProjectToPersonal(args: MoveProjectToPersonalArgs, requestId?: string): Promise<PersonalProject | WorkspaceProject>;
21
+ getArchivedProjectsCount(args?: GetArchivedProjectsCountArgs): Promise<GetArchivedProjectsCountResponse>;
22
+ getProjectPermissions(): Promise<GetProjectPermissionsResponse>;
23
+ getFullProject(id: string, args?: GetFullProjectArgs): Promise<GetFullProjectResponse>;
24
+ joinProject(id: string, requestId?: string): Promise<JoinProjectResponse>;
25
+ getProjectCollaborators(projectId: string, args?: GetProjectCollaboratorsArgs): Promise<GetProjectCollaboratorsResponse>;
26
+ }
@@ -0,0 +1,25 @@
1
+ import type { Reminder } from '../types/index.js';
2
+ import type { AddLocationReminderArgs, AddReminderArgs, GetLocationRemindersArgs, GetLocationRemindersResponse, GetRemindersArgs, GetRemindersResponse, UpdateLocationReminderArgs, UpdateReminderArgs } from '../types/reminders/index.js';
3
+ import { BaseClient } from './base-client.js';
4
+ /**
5
+ * Internal sub-client handling all reminder-domain endpoints
6
+ * (both time-based and location-based reminders).
7
+ *
8
+ * Instantiated by `TodoistApi`; every public reminder method on
9
+ * `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
10
+ * JSDoc. The time-vs-location 404 translation is preserved here so a
11
+ * caller who used the wrong endpoint gets a TodoistArgumentError
12
+ * pointing at the correct method, rather than a bare 404.
13
+ */
14
+ export declare class ReminderClient extends BaseClient {
15
+ getReminders(args?: GetRemindersArgs): Promise<GetRemindersResponse>;
16
+ getLocationReminders(args?: GetLocationRemindersArgs): Promise<GetLocationRemindersResponse>;
17
+ getReminder(id: string): Promise<Reminder>;
18
+ getLocationReminder(id: string): Promise<Reminder>;
19
+ addReminder(args: AddReminderArgs, requestId?: string): Promise<Reminder>;
20
+ addLocationReminder(args: AddLocationReminderArgs, requestId?: string): Promise<Reminder>;
21
+ updateReminder(id: string, args: UpdateReminderArgs, requestId?: string): Promise<Reminder>;
22
+ updateLocationReminder(id: string, args: UpdateLocationReminderArgs, requestId?: string): Promise<Reminder>;
23
+ deleteReminder(id: string, requestId?: string): Promise<boolean>;
24
+ deleteLocationReminder(id: string, requestId?: string): Promise<boolean>;
25
+ }
@@ -0,0 +1,18 @@
1
+ import type { AddSectionArgs, GetSectionsArgs, GetSectionsResponse, SearchSectionsArgs, Section, UpdateSectionArgs } from '../types/sections/index.js';
2
+ import { BaseClient } from './base-client.js';
3
+ /**
4
+ * Internal sub-client handling all section-domain endpoints.
5
+ *
6
+ * Instantiated by `TodoistApi`; every public section method on `TodoistApi`
7
+ * delegates here. See `todoist-api.ts` for the user-facing JSDoc.
8
+ */
9
+ export declare class SectionClient extends BaseClient {
10
+ getSections(args?: GetSectionsArgs): Promise<GetSectionsResponse>;
11
+ searchSections(args: SearchSectionsArgs): Promise<GetSectionsResponse>;
12
+ getSection(id: string): Promise<Section>;
13
+ addSection(args: AddSectionArgs, requestId?: string): Promise<Section>;
14
+ updateSection(id: string, args: UpdateSectionArgs, requestId?: string): Promise<Section>;
15
+ deleteSection(id: string, requestId?: string): Promise<boolean>;
16
+ archiveSection(id: string, requestId?: string): Promise<Section>;
17
+ unarchiveSection(id: string, requestId?: string): Promise<Section>;
18
+ }
@@ -0,0 +1,25 @@
1
+ import type { AddTaskArgs, GetAllCompletedTasksArgs, GetAllCompletedTasksResponse, GetCompletedTasksByCompletionDateArgs, GetCompletedTasksByDueDateArgs, GetCompletedTasksResponse, GetTasksArgs, GetTasksByFilterArgs, GetTasksResponse, MoveTaskArgs, QuickAddTaskArgs, SearchCompletedTasksArgs, Task, UpdateTaskArgs } from '../types/tasks/index.js';
2
+ import { BaseClient } from './base-client.js';
3
+ /**
4
+ * Internal sub-client handling all task-domain endpoints.
5
+ *
6
+ * Instantiated by `TodoistApi`; every public task method on `TodoistApi`
7
+ * delegates here. See `todoist-api.ts` for the user-facing JSDoc.
8
+ */
9
+ export declare class TaskClient extends BaseClient {
10
+ getTask(id: string): Promise<Task>;
11
+ getTasks(args?: GetTasksArgs): Promise<GetTasksResponse>;
12
+ getTasksByFilter(args: GetTasksByFilterArgs): Promise<GetTasksResponse>;
13
+ getCompletedTasksByCompletionDate(args: GetCompletedTasksByCompletionDateArgs): Promise<GetCompletedTasksResponse>;
14
+ getCompletedTasksByDueDate(args: GetCompletedTasksByDueDateArgs): Promise<GetCompletedTasksResponse>;
15
+ searchCompletedTasks(args: SearchCompletedTasksArgs): Promise<GetCompletedTasksResponse>;
16
+ getAllCompletedTasks(args?: GetAllCompletedTasksArgs): Promise<GetAllCompletedTasksResponse>;
17
+ addTask(args: AddTaskArgs, requestId?: string): Promise<Task>;
18
+ quickAddTask(args: QuickAddTaskArgs): Promise<Task>;
19
+ updateTask(id: string, args: UpdateTaskArgs, requestId?: string): Promise<Task>;
20
+ moveTasks(ids: string[], args: MoveTaskArgs, requestId?: string): Promise<Task[]>;
21
+ moveTask(id: string, args: MoveTaskArgs, requestId?: string): Promise<Task>;
22
+ closeTask(id: string, requestId?: string): Promise<boolean>;
23
+ reopenTask(id: string, requestId?: string): Promise<boolean>;
24
+ deleteTask(id: string, requestId?: string): Promise<boolean>;
25
+ }
@@ -0,0 +1,17 @@
1
+ import type { CreateProjectFromTemplateArgs, CreateProjectFromTemplateResponse, ExportTemplateFileArgs, ExportTemplateUrlArgs, ExportTemplateUrlResponse, ImportTemplateFromIdArgs, ImportTemplateIntoProjectArgs, ImportTemplateResponse } from '../types/templates/index.js';
2
+ import { BaseClient } from './base-client.js';
3
+ /**
4
+ * Internal sub-client handling all template-domain endpoints.
5
+ *
6
+ * Instantiated by `TodoistApi`; every public template method on
7
+ * `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
8
+ * JSDoc.
9
+ */
10
+ export declare class TemplateClient extends BaseClient {
11
+ exportTemplateAsFile(args: ExportTemplateFileArgs): Promise<string>;
12
+ exportTemplateAsUrl(args: ExportTemplateUrlArgs): Promise<ExportTemplateUrlResponse>;
13
+ createProjectFromTemplate(args: CreateProjectFromTemplateArgs, requestId?: string): Promise<CreateProjectFromTemplateResponse>;
14
+ importTemplateIntoProject(args: ImportTemplateIntoProjectArgs, requestId?: string): Promise<ImportTemplateResponse>;
15
+ importTemplateFromId(args: ImportTemplateFromIdArgs, requestId?: string): Promise<ImportTemplateResponse>;
16
+ private validateTemplateResponse;
17
+ }
@@ -0,0 +1,17 @@
1
+ import type { Attachment, Comment } from '../types/comments/index.js';
2
+ import type { FileResponse } from '../types/http.js';
3
+ import type { DeleteUploadArgs, UploadFileArgs } from '../types/uploads/index.js';
4
+ import { BaseClient } from './base-client.js';
5
+ /**
6
+ * Internal sub-client handling upload + attachment endpoints
7
+ * (file upload, upload delete, attachment view).
8
+ *
9
+ * Instantiated by `TodoistApi`; every public upload method on
10
+ * `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
11
+ * JSDoc.
12
+ */
13
+ export declare class UploadClient extends BaseClient {
14
+ uploadFile(args: UploadFileArgs, requestId?: string): Promise<Attachment>;
15
+ deleteUpload(args: DeleteUploadArgs, requestId?: string): Promise<boolean>;
16
+ viewAttachment(commentOrUrl: Comment | string): Promise<FileResponse>;
17
+ }
@@ -0,0 +1,43 @@
1
+ import type { GetProjectsResponse } from '../types/projects/index.js';
2
+ import type { AddWorkspaceArgs, AllWorkspaceInvitationsResponse, DeleteWorkspaceInvitationArgs, GetWorkspaceMembersActivityArgs, GetWorkspaceMembersActivityResponse, GetWorkspaceProjectsArgs, GetWorkspaceUserTasksArgs, GetWorkspaceUserTasksResponse, GetWorkspaceUsersArgs, GetWorkspaceUsersResponse, InviteWorkspaceUsersArgs, InviteWorkspaceUsersResponse, JoinWorkspaceArgs, JoinWorkspaceResult, RemoveWorkspaceUserArgs, UpdateWorkspaceArgs, UpdateWorkspaceUserArgs, Workspace, WorkspaceInvitation, WorkspaceInvitationActionArgs, WorkspaceInvitationsResponse, WorkspaceLogoArgs, WorkspaceLogoResponse, WorkspacePlanDetails } from '../types/workspaces/index.js';
3
+ import { BaseClient } from './base-client.js';
4
+ type GetAllWorkspaceInvitationsArgs = {
5
+ workspaceId?: string;
6
+ };
7
+ /**
8
+ * Internal sub-client handling all workspace-domain endpoints —
9
+ * workspaces, invitations, users, plans, logos, and workspace project
10
+ * pagination.
11
+ *
12
+ * Instantiated by `TodoistApi`; every public workspace method on
13
+ * `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
14
+ * JSDoc.
15
+ */
16
+ export declare class WorkspaceClient extends BaseClient {
17
+ getWorkspaceInvitations(args: {
18
+ workspaceId: string;
19
+ }, requestId?: string): Promise<WorkspaceInvitationsResponse>;
20
+ getAllWorkspaceInvitations(args?: GetAllWorkspaceInvitationsArgs, requestId?: string): Promise<AllWorkspaceInvitationsResponse>;
21
+ deleteWorkspaceInvitation(args: DeleteWorkspaceInvitationArgs, requestId?: string): Promise<WorkspaceInvitation>;
22
+ acceptWorkspaceInvitation(args: WorkspaceInvitationActionArgs, requestId?: string): Promise<WorkspaceInvitation>;
23
+ rejectWorkspaceInvitation(args: WorkspaceInvitationActionArgs, requestId?: string): Promise<WorkspaceInvitation>;
24
+ joinWorkspace(args: JoinWorkspaceArgs, requestId?: string): Promise<JoinWorkspaceResult>;
25
+ uploadWorkspaceLogo(args: WorkspaceLogoArgs, requestId?: string): Promise<WorkspaceLogoResponse>;
26
+ getWorkspacePlanDetails(args: {
27
+ workspaceId: string;
28
+ }, requestId?: string): Promise<WorkspacePlanDetails>;
29
+ getWorkspaceUsers(args?: GetWorkspaceUsersArgs, requestId?: string): Promise<GetWorkspaceUsersResponse>;
30
+ getWorkspaces(requestId?: string): Promise<Workspace[]>;
31
+ getWorkspace(id: string, requestId?: string): Promise<Workspace>;
32
+ addWorkspace(args: AddWorkspaceArgs, requestId?: string): Promise<Workspace>;
33
+ updateWorkspace(id: string, args: UpdateWorkspaceArgs, requestId?: string): Promise<Workspace>;
34
+ deleteWorkspace(id: string, requestId?: string): Promise<boolean>;
35
+ getWorkspaceMembersActivity(args: GetWorkspaceMembersActivityArgs, requestId?: string): Promise<GetWorkspaceMembersActivityResponse>;
36
+ getWorkspaceUserTasks(args: GetWorkspaceUserTasksArgs, requestId?: string): Promise<GetWorkspaceUserTasksResponse>;
37
+ inviteWorkspaceUsers(args: InviteWorkspaceUsersArgs, requestId?: string): Promise<InviteWorkspaceUsersResponse>;
38
+ updateWorkspaceUser(args: UpdateWorkspaceUserArgs, requestId?: string): Promise<JoinWorkspaceResult>;
39
+ removeWorkspaceUser(args: RemoveWorkspaceUserArgs, requestId?: string): Promise<boolean>;
40
+ getWorkspaceActiveProjects(args: GetWorkspaceProjectsArgs, requestId?: string): Promise<GetProjectsResponse>;
41
+ getWorkspaceArchivedProjects(args: GetWorkspaceProjectsArgs, requestId?: string): Promise<GetProjectsResponse>;
42
+ }
43
+ export {};
@@ -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";
@@ -1,4 +1,4 @@
1
- import { Label, Section, Task, User, Attachment, Duration, Deadline, RawComment, PersonalProject, WorkspaceProject, Reminder, Folder } from '../types/index.js';
1
+ import { Label, Section, Task, User, Attachment, Duration, Deadline, RawComment, PersonalProject, WorkspaceProject, Reminder, Folder, Goal } from '../types/index.js';
2
2
  import type { Collaborator, CollaboratorState } from '../types/sync/resources/collaborators.js';
3
3
  import type { Note } from '../types/sync/resources/notes.js';
4
4
  export declare const DEFAULT_TASK_ID = "1234";
@@ -264,4 +264,7 @@ export declare const COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT: {
264
264
  export declare const DEFAULT_FOLDER: Folder;
265
265
  export declare const DEFAULT_COLLABORATOR: Collaborator;
266
266
  export declare const DEFAULT_COLLABORATOR_STATE: CollaboratorState;
267
+ export declare const DEFAULT_GOAL_ID = "550e8400-e29b-41d4-a716-446655440000";
268
+ export declare const DEFAULT_GOAL: Goal;
269
+ export declare const DEFAULT_GOAL_NO_PROGRESS: Goal;
267
270
  export declare const DEFAULT_NOTE: Note;