@doist/todoist-sdk 10.5.1 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/cjs/consts/endpoints.js +1 -6
  2. package/dist/cjs/test-utils/test-defaults.js +2 -26
  3. package/dist/cjs/test-utils/webhook-fixtures.js +1 -1
  4. package/dist/cjs/todoist-api.js +0 -101
  5. package/dist/cjs/types/index.js +0 -1
  6. package/dist/cjs/types/sync/commands/index.js +0 -2
  7. package/dist/cjs/types/sync/resource-types.js +0 -2
  8. package/dist/cjs/types/sync/resources/index.js +0 -1
  9. package/dist/cjs/types/sync/response.js +10 -13
  10. package/dist/cjs/utils/validators.js +50 -54
  11. package/dist/esm/consts/endpoints.js +0 -5
  12. package/dist/esm/test-utils/test-defaults.js +0 -24
  13. package/dist/esm/test-utils/webhook-fixtures.js +1 -1
  14. package/dist/esm/todoist-api.js +0 -101
  15. package/dist/esm/types/index.js +0 -1
  16. package/dist/esm/types/sync/commands/index.js +0 -2
  17. package/dist/esm/types/sync/resource-types.js +0 -2
  18. package/dist/esm/types/sync/resources/index.js +0 -1
  19. package/dist/esm/types/sync/response.js +1 -4
  20. package/dist/esm/utils/validators.js +1 -4
  21. package/dist/types/consts/endpoints.d.ts +0 -5
  22. package/dist/types/test-utils/test-defaults.d.ts +1 -4
  23. package/dist/types/todoist-api.d.ts +0 -80
  24. package/dist/types/types/index.d.ts +0 -1
  25. package/dist/types/types/sync/commands/index.d.ts +0 -16
  26. package/dist/types/types/sync/resource-types.d.ts +1 -1
  27. package/dist/types/types/sync/resources/index.d.ts +0 -1
  28. package/dist/types/types/sync/resources/view-options.d.ts +6 -6
  29. package/dist/types/types/sync/response.d.ts +4 -45
  30. package/dist/types/types/tasks/requests.d.ts +0 -1
  31. package/dist/types/utils/validators.d.ts +8 -90
  32. package/package.json +1 -1
  33. package/dist/cjs/clients/goals-client.js +0 -144
  34. package/dist/cjs/types/goals/index.js +0 -18
  35. package/dist/cjs/types/goals/requests.js +0 -2
  36. package/dist/cjs/types/goals/types.js +0 -56
  37. package/dist/cjs/types/sync/commands/goals.js +0 -2
  38. package/dist/cjs/types/sync/commands/workspace-goals.js +0 -2
  39. package/dist/cjs/types/sync/resources/workspace-goals.js +0 -26
  40. package/dist/esm/clients/goals-client.js +0 -140
  41. package/dist/esm/types/goals/index.js +0 -2
  42. package/dist/esm/types/goals/requests.js +0 -1
  43. package/dist/esm/types/goals/types.js +0 -53
  44. package/dist/esm/types/sync/commands/goals.js +0 -1
  45. package/dist/esm/types/sync/commands/workspace-goals.js +0 -1
  46. package/dist/esm/types/sync/resources/workspace-goals.js +0 -23
  47. package/dist/types/clients/goals-client.d.ts +0 -20
  48. package/dist/types/types/goals/index.d.ts +0 -2
  49. package/dist/types/types/goals/requests.d.ts +0 -33
  50. package/dist/types/types/goals/types.d.ts +0 -51
  51. package/dist/types/types/sync/commands/goals.d.ts +0 -33
  52. package/dist/types/types/sync/commands/workspace-goals.d.ts +0 -24
  53. package/dist/types/types/sync/resources/workspace-goals.d.ts +0 -29
@@ -820,53 +820,6 @@ export declare const validateFolder: (input: unknown) => {
820
820
  defaultOrder: number;
821
821
  childOrder: number;
822
822
  }[];
823
- export declare const validateGoal: (input: unknown) => {
824
- [x: string]: unknown;
825
- id: string;
826
- ownerType: "USER" | "WORKSPACE";
827
- ownerId: string;
828
- name: string;
829
- description: string | null;
830
- deadline: string | null;
831
- parentGoalId: string | null;
832
- childOrder: number;
833
- isCompleted: boolean;
834
- completedAt: Date | null;
835
- responsibleUid: string | null;
836
- isDeleted: boolean;
837
- creatorUid: string;
838
- createdAt: Date;
839
- updatedAt: Date;
840
- progress?: {
841
- [x: string]: unknown;
842
- totalTaskCount: number;
843
- completedTaskCount: number;
844
- percentage: number;
845
- } | undefined;
846
- }, validateGoalArray: (input: unknown) => {
847
- [x: string]: unknown;
848
- id: string;
849
- ownerType: "USER" | "WORKSPACE";
850
- ownerId: string;
851
- name: string;
852
- description: string | null;
853
- deadline: string | null;
854
- parentGoalId: string | null;
855
- childOrder: number;
856
- isCompleted: boolean;
857
- completedAt: Date | null;
858
- responsibleUid: string | null;
859
- isDeleted: boolean;
860
- creatorUid: string;
861
- createdAt: Date;
862
- updatedAt: Date;
863
- progress?: {
864
- [x: string]: unknown;
865
- totalTaskCount: number;
866
- completedTaskCount: number;
867
- percentage: number;
868
- } | undefined;
869
- }[];
870
823
  export declare const validateSubscriptionInfo: (input: unknown) => {
871
824
  status: "none" | "autorenew" | "canceled" | "expired" | "trial" | "trial_canceled";
872
825
  plan: "free" | "pro" | "pro_gifted" | "pro_legacy";
@@ -1013,41 +966,6 @@ export declare const validateWorkspaceFilter: (input: unknown) => {
1013
966
  createdAt: Date;
1014
967
  updatedAt: Date;
1015
968
  }[];
1016
- export declare const validateWorkspaceGoal: (input: unknown) => {
1017
- [x: string]: unknown;
1018
- id: string;
1019
- workspaceId: string;
1020
- title: string;
1021
- description: string | null;
1022
- deadline: string | null;
1023
- isDeleted: boolean;
1024
- projectIds: string[];
1025
- progress: {
1026
- [x: string]: unknown;
1027
- completedItems: number;
1028
- totalItems: number;
1029
- } | null;
1030
- creatorUid: string;
1031
- createdAt: Date;
1032
- updatedAt: Date;
1033
- }, validateWorkspaceGoalArray: (input: unknown) => {
1034
- [x: string]: unknown;
1035
- id: string;
1036
- workspaceId: string;
1037
- title: string;
1038
- description: string | null;
1039
- deadline: string | null;
1040
- isDeleted: boolean;
1041
- projectIds: string[];
1042
- progress: {
1043
- [x: string]: unknown;
1044
- completedItems: number;
1045
- totalItems: number;
1046
- } | null;
1047
- creatorUid: string;
1048
- createdAt: Date;
1049
- updatedAt: Date;
1050
- }[];
1051
969
  export declare const validateCalendar: (input: unknown) => {
1052
970
  [x: string]: unknown;
1053
971
  id: string;
@@ -1247,29 +1165,29 @@ export declare const validateViewOptions: (input: unknown) => {
1247
1165
  [x: string]: unknown;
1248
1166
  viewType: "PROJECT" | "TODAY" | "UPCOMING" | "LABEL" | "FILTER" | "WORKSPACE_FILTER" | "SEARCH" | "TEMPLATE_PREVIEW" | "TASK_DETAIL" | "AUTOMATION" | "ASSIGNED" | "OVERDUE" | "WORKSPACE_OVERVIEW";
1249
1167
  objectId?: string | undefined;
1250
- groupedBy?: "WORKSPACE" | "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | null | undefined;
1168
+ groupedBy?: "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | null | undefined;
1251
1169
  filteredBy?: string | null | undefined;
1252
1170
  viewMode?: "LIST" | "BOARD" | "CALENDAR" | undefined;
1253
1171
  showCompletedTasks?: boolean | undefined;
1254
- sortedBy?: "WORKSPACE" | "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
1172
+ sortedBy?: "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
1255
1173
  sortOrder?: "ASC" | "DESC" | null | undefined;
1256
1174
  }, validateViewOptionsArray: (input: unknown) => {
1257
1175
  [x: string]: unknown;
1258
1176
  viewType: "PROJECT" | "TODAY" | "UPCOMING" | "LABEL" | "FILTER" | "WORKSPACE_FILTER" | "SEARCH" | "TEMPLATE_PREVIEW" | "TASK_DETAIL" | "AUTOMATION" | "ASSIGNED" | "OVERDUE" | "WORKSPACE_OVERVIEW";
1259
1177
  objectId?: string | undefined;
1260
- groupedBy?: "WORKSPACE" | "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | null | undefined;
1178
+ groupedBy?: "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | null | undefined;
1261
1179
  filteredBy?: string | null | undefined;
1262
1180
  viewMode?: "LIST" | "BOARD" | "CALENDAR" | undefined;
1263
1181
  showCompletedTasks?: boolean | undefined;
1264
- sortedBy?: "WORKSPACE" | "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
1182
+ sortedBy?: "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
1265
1183
  sortOrder?: "ASC" | "DESC" | null | undefined;
1266
1184
  }[];
1267
1185
  export declare const validateProjectViewOptionsDefaults: (input: unknown) => {
1268
1186
  [x: string]: unknown;
1269
1187
  projectId: string;
1270
1188
  viewMode?: "LIST" | "BOARD" | "CALENDAR" | null | undefined;
1271
- groupedBy?: "WORKSPACE" | "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | null | undefined;
1272
- sortedBy?: "WORKSPACE" | "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
1189
+ groupedBy?: "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | null | undefined;
1190
+ sortedBy?: "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
1273
1191
  sortOrder?: "ASC" | "DESC" | null | undefined;
1274
1192
  showCompletedTasks?: boolean | undefined;
1275
1193
  filteredBy?: string | null | undefined;
@@ -1281,8 +1199,8 @@ export declare const validateProjectViewOptionsDefaults: (input: unknown) => {
1281
1199
  [x: string]: unknown;
1282
1200
  projectId: string;
1283
1201
  viewMode?: "LIST" | "BOARD" | "CALENDAR" | null | undefined;
1284
- groupedBy?: "WORKSPACE" | "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | null | undefined;
1285
- sortedBy?: "WORKSPACE" | "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
1202
+ groupedBy?: "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | null | undefined;
1203
+ sortedBy?: "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
1286
1204
  sortOrder?: "ASC" | "DESC" | null | undefined;
1287
1205
  showCompletedTasks?: boolean | undefined;
1288
1206
  filteredBy?: string | null | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/todoist-sdk",
3
- "version": "10.5.1",
3
+ "version": "11.0.0",
4
4
  "description": "The official TypeScript SDK for the Todoist REST API.",
5
5
  "author": "Doist developers",
6
6
  "repository": "https://github.com/Doist/todoist-sdk-typescript",
@@ -1,144 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GoalsClient = void 0;
4
- const endpoints_1 = require("../consts/endpoints");
5
- const http_client_1 = require("../transport/http-client");
6
- const request_helpers_1 = require("../utils/request-helpers");
7
- const validators_1 = require("../utils/validators");
8
- const base_client_1 = require("./base-client");
9
- /**
10
- * Internal sub-client handling all goal-domain endpoints.
11
- *
12
- * Instantiated by `TodoistApi`; every public goal method on `TodoistApi`
13
- * delegates here. See `todoist-api.ts` for the user-facing JSDoc.
14
- */
15
- class GoalsClient extends base_client_1.BaseClient {
16
- async getGoals(args) {
17
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
18
- httpMethod: 'GET',
19
- baseUri: this.syncApiBase,
20
- relativePath: endpoints_1.ENDPOINT_REST_GOALS,
21
- apiToken: this.authToken,
22
- customFetch: this.customFetch,
23
- payload: args,
24
- });
25
- return {
26
- results: (0, validators_1.validateGoalArray)(results),
27
- nextCursor,
28
- };
29
- }
30
- async searchGoals(args) {
31
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
32
- httpMethod: 'GET',
33
- baseUri: this.syncApiBase,
34
- relativePath: endpoints_1.ENDPOINT_REST_GOALS_SEARCH,
35
- apiToken: this.authToken,
36
- customFetch: this.customFetch,
37
- payload: args,
38
- });
39
- return {
40
- results: (0, validators_1.validateGoalArray)(results),
41
- nextCursor,
42
- };
43
- }
44
- async getGoal(id) {
45
- validators_1.IdSchema.parse(id);
46
- const response = await (0, http_client_1.request)({
47
- httpMethod: 'GET',
48
- baseUri: this.syncApiBase,
49
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, id),
50
- apiToken: this.authToken,
51
- customFetch: this.customFetch,
52
- });
53
- return (0, validators_1.validateGoal)(response.data);
54
- }
55
- async addGoal(args, requestId) {
56
- const response = await (0, http_client_1.request)({
57
- httpMethod: 'POST',
58
- baseUri: this.syncApiBase,
59
- relativePath: endpoints_1.ENDPOINT_REST_GOALS,
60
- apiToken: this.authToken,
61
- customFetch: this.customFetch,
62
- payload: args,
63
- requestId: requestId,
64
- });
65
- return (0, validators_1.validateGoal)(response.data);
66
- }
67
- async updateGoal(id, args, requestId) {
68
- validators_1.IdSchema.parse(id);
69
- const response = await (0, http_client_1.request)({
70
- httpMethod: 'POST',
71
- baseUri: this.syncApiBase,
72
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, id),
73
- apiToken: this.authToken,
74
- customFetch: this.customFetch,
75
- payload: args,
76
- requestId: requestId,
77
- });
78
- return (0, validators_1.validateGoal)(response.data);
79
- }
80
- async deleteGoal(id, requestId) {
81
- validators_1.IdSchema.parse(id);
82
- const response = await (0, http_client_1.request)({
83
- httpMethod: 'DELETE',
84
- baseUri: this.syncApiBase,
85
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, id),
86
- apiToken: this.authToken,
87
- customFetch: this.customFetch,
88
- requestId: requestId,
89
- });
90
- return (0, http_client_1.isSuccess)(response);
91
- }
92
- async completeGoal(id, requestId) {
93
- validators_1.IdSchema.parse(id);
94
- const response = await (0, http_client_1.request)({
95
- httpMethod: 'POST',
96
- baseUri: this.syncApiBase,
97
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, id, endpoints_1.GOAL_COMPLETE),
98
- apiToken: this.authToken,
99
- customFetch: this.customFetch,
100
- requestId: requestId,
101
- });
102
- return (0, validators_1.validateGoal)(response.data);
103
- }
104
- async uncompleteGoal(id, requestId) {
105
- validators_1.IdSchema.parse(id);
106
- const response = await (0, http_client_1.request)({
107
- httpMethod: 'POST',
108
- baseUri: this.syncApiBase,
109
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, id, endpoints_1.GOAL_UNCOMPLETE),
110
- apiToken: this.authToken,
111
- customFetch: this.customFetch,
112
- requestId: requestId,
113
- });
114
- return (0, validators_1.validateGoal)(response.data);
115
- }
116
- async linkTaskToGoal({ goalId, taskId }, requestId) {
117
- validators_1.IdSchema.parse(goalId);
118
- validators_1.IdSchema.parse(taskId);
119
- const response = await (0, http_client_1.request)({
120
- httpMethod: 'POST',
121
- baseUri: this.syncApiBase,
122
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, goalId, endpoints_1.GOAL_TASKS),
123
- apiToken: this.authToken,
124
- customFetch: this.customFetch,
125
- payload: { itemId: taskId },
126
- requestId: requestId,
127
- });
128
- return (0, validators_1.validateGoal)(response.data);
129
- }
130
- async unlinkTaskFromGoal({ goalId, taskId }, requestId) {
131
- validators_1.IdSchema.parse(goalId);
132
- validators_1.IdSchema.parse(taskId);
133
- const response = await (0, http_client_1.request)({
134
- httpMethod: 'DELETE',
135
- baseUri: this.syncApiBase,
136
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, goalId, endpoints_1.GOAL_TASKS, taskId),
137
- apiToken: this.authToken,
138
- customFetch: this.customFetch,
139
- requestId: requestId,
140
- });
141
- return (0, http_client_1.isSuccess)(response);
142
- }
143
- }
144
- exports.GoalsClient = GoalsClient;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types"), exports);
18
- __exportStar(require("./requests"), exports);
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,56 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.GoalSchema = exports.GoalProgressSchema = exports.GOAL_OWNER_TYPES = void 0;
15
- const zod_1 = require("zod");
16
- /** Available goal owner types. */
17
- exports.GOAL_OWNER_TYPES = ['USER', 'WORKSPACE'];
18
- /**
19
- * Progress of a {@link Goal}.
20
- *
21
- * The REST API returns these counts under `total_item_count` / `completed_item_count`,
22
- * reflecting the backend's generic "item" terminology. The SDK normalizes them to
23
- * `totalTaskCount` / `completedTaskCount` so the public surface consistently speaks
24
- * in "tasks" (matching the rest of the SDK). The `preprocess` step below performs
25
- * that rename after the transport layer's snake_case → camelCase conversion — do not
26
- * remove it without also changing the downstream field names.
27
- */
28
- exports.GoalProgressSchema = zod_1.z.preprocess((raw) => {
29
- if (raw === null || raw === undefined || typeof raw !== 'object' || Array.isArray(raw)) {
30
- return raw;
31
- }
32
- const _a = raw, { totalItemCount, completedItemCount, totalTaskCount, completedTaskCount } = _a, rest = __rest(_a, ["totalItemCount", "completedItemCount", "totalTaskCount", "completedTaskCount"]);
33
- return Object.assign(Object.assign({}, rest), { totalTaskCount: totalTaskCount !== null && totalTaskCount !== void 0 ? totalTaskCount : totalItemCount, completedTaskCount: completedTaskCount !== null && completedTaskCount !== void 0 ? completedTaskCount : completedItemCount });
34
- }, zod_1.z.looseObject({
35
- totalTaskCount: zod_1.z.number().int(),
36
- completedTaskCount: zod_1.z.number().int(),
37
- percentage: zod_1.z.number(),
38
- }));
39
- exports.GoalSchema = zod_1.z.looseObject({
40
- id: zod_1.z.string(),
41
- ownerType: zod_1.z.enum(exports.GOAL_OWNER_TYPES),
42
- ownerId: zod_1.z.string(),
43
- name: zod_1.z.string(),
44
- description: zod_1.z.string().nullable(),
45
- deadline: zod_1.z.string().nullable(),
46
- parentGoalId: zod_1.z.string().nullable(),
47
- childOrder: zod_1.z.number().int(),
48
- isCompleted: zod_1.z.boolean(),
49
- completedAt: zod_1.z.coerce.date().nullable(),
50
- responsibleUid: zod_1.z.string().nullable(),
51
- isDeleted: zod_1.z.boolean(),
52
- progress: exports.GoalProgressSchema.optional(),
53
- creatorUid: zod_1.z.string(),
54
- createdAt: zod_1.z.coerce.date(),
55
- updatedAt: zod_1.z.coerce.date(),
56
- });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WorkspaceGoalSchema = exports.WorkspaceGoalProgressSchema = exports.WorkspaceGoalMilestoneSchema = void 0;
4
- const zod_1 = require("zod");
5
- exports.WorkspaceGoalMilestoneSchema = zod_1.z.looseObject({
6
- id: zod_1.z.string(),
7
- title: zod_1.z.string(),
8
- isCompleted: zod_1.z.boolean(),
9
- });
10
- exports.WorkspaceGoalProgressSchema = zod_1.z.looseObject({
11
- completedItems: zod_1.z.number().int(),
12
- totalItems: zod_1.z.number().int(),
13
- });
14
- exports.WorkspaceGoalSchema = zod_1.z.looseObject({
15
- id: zod_1.z.string(),
16
- workspaceId: zod_1.z.string(),
17
- title: zod_1.z.string(),
18
- description: zod_1.z.string().nullable(),
19
- deadline: zod_1.z.string().nullable(),
20
- isDeleted: zod_1.z.boolean(),
21
- projectIds: zod_1.z.array(zod_1.z.string()),
22
- progress: exports.WorkspaceGoalProgressSchema.nullable(),
23
- creatorUid: zod_1.z.string(),
24
- createdAt: zod_1.z.coerce.date(),
25
- updatedAt: zod_1.z.coerce.date(),
26
- });
@@ -1,140 +0,0 @@
1
- import { ENDPOINT_REST_GOALS, ENDPOINT_REST_GOALS_SEARCH, GOAL_COMPLETE, GOAL_TASKS, GOAL_UNCOMPLETE, } from '../consts/endpoints.js';
2
- import { isSuccess, request } from '../transport/http-client.js';
3
- import { generatePath } from '../utils/request-helpers.js';
4
- import { IdSchema, validateGoal, validateGoalArray } from '../utils/validators.js';
5
- import { BaseClient } from './base-client.js';
6
- /**
7
- * Internal sub-client handling all goal-domain endpoints.
8
- *
9
- * Instantiated by `TodoistApi`; every public goal method on `TodoistApi`
10
- * delegates here. See `todoist-api.ts` for the user-facing JSDoc.
11
- */
12
- export class GoalsClient extends BaseClient {
13
- async getGoals(args) {
14
- const { data: { results, nextCursor }, } = await request({
15
- httpMethod: 'GET',
16
- baseUri: this.syncApiBase,
17
- relativePath: ENDPOINT_REST_GOALS,
18
- apiToken: this.authToken,
19
- customFetch: this.customFetch,
20
- payload: args,
21
- });
22
- return {
23
- results: validateGoalArray(results),
24
- nextCursor,
25
- };
26
- }
27
- async searchGoals(args) {
28
- const { data: { results, nextCursor }, } = await request({
29
- httpMethod: 'GET',
30
- baseUri: this.syncApiBase,
31
- relativePath: ENDPOINT_REST_GOALS_SEARCH,
32
- apiToken: this.authToken,
33
- customFetch: this.customFetch,
34
- payload: args,
35
- });
36
- return {
37
- results: validateGoalArray(results),
38
- nextCursor,
39
- };
40
- }
41
- async getGoal(id) {
42
- IdSchema.parse(id);
43
- const response = await request({
44
- httpMethod: 'GET',
45
- baseUri: this.syncApiBase,
46
- relativePath: generatePath(ENDPOINT_REST_GOALS, id),
47
- apiToken: this.authToken,
48
- customFetch: this.customFetch,
49
- });
50
- return validateGoal(response.data);
51
- }
52
- async addGoal(args, requestId) {
53
- const response = await request({
54
- httpMethod: 'POST',
55
- baseUri: this.syncApiBase,
56
- relativePath: ENDPOINT_REST_GOALS,
57
- apiToken: this.authToken,
58
- customFetch: this.customFetch,
59
- payload: args,
60
- requestId: requestId,
61
- });
62
- return validateGoal(response.data);
63
- }
64
- async updateGoal(id, args, requestId) {
65
- IdSchema.parse(id);
66
- const response = await request({
67
- httpMethod: 'POST',
68
- baseUri: this.syncApiBase,
69
- relativePath: generatePath(ENDPOINT_REST_GOALS, id),
70
- apiToken: this.authToken,
71
- customFetch: this.customFetch,
72
- payload: args,
73
- requestId: requestId,
74
- });
75
- return validateGoal(response.data);
76
- }
77
- async deleteGoal(id, requestId) {
78
- IdSchema.parse(id);
79
- const response = await request({
80
- httpMethod: 'DELETE',
81
- baseUri: this.syncApiBase,
82
- relativePath: generatePath(ENDPOINT_REST_GOALS, id),
83
- apiToken: this.authToken,
84
- customFetch: this.customFetch,
85
- requestId: requestId,
86
- });
87
- return isSuccess(response);
88
- }
89
- async completeGoal(id, requestId) {
90
- IdSchema.parse(id);
91
- const response = await request({
92
- httpMethod: 'POST',
93
- baseUri: this.syncApiBase,
94
- relativePath: generatePath(ENDPOINT_REST_GOALS, id, GOAL_COMPLETE),
95
- apiToken: this.authToken,
96
- customFetch: this.customFetch,
97
- requestId: requestId,
98
- });
99
- return validateGoal(response.data);
100
- }
101
- async uncompleteGoal(id, requestId) {
102
- IdSchema.parse(id);
103
- const response = await request({
104
- httpMethod: 'POST',
105
- baseUri: this.syncApiBase,
106
- relativePath: generatePath(ENDPOINT_REST_GOALS, id, GOAL_UNCOMPLETE),
107
- apiToken: this.authToken,
108
- customFetch: this.customFetch,
109
- requestId: requestId,
110
- });
111
- return validateGoal(response.data);
112
- }
113
- async linkTaskToGoal({ goalId, taskId }, requestId) {
114
- IdSchema.parse(goalId);
115
- IdSchema.parse(taskId);
116
- const response = await request({
117
- httpMethod: 'POST',
118
- baseUri: this.syncApiBase,
119
- relativePath: generatePath(ENDPOINT_REST_GOALS, goalId, GOAL_TASKS),
120
- apiToken: this.authToken,
121
- customFetch: this.customFetch,
122
- payload: { itemId: taskId },
123
- requestId: requestId,
124
- });
125
- return validateGoal(response.data);
126
- }
127
- async unlinkTaskFromGoal({ goalId, taskId }, requestId) {
128
- IdSchema.parse(goalId);
129
- IdSchema.parse(taskId);
130
- const response = await request({
131
- httpMethod: 'DELETE',
132
- baseUri: this.syncApiBase,
133
- relativePath: generatePath(ENDPOINT_REST_GOALS, goalId, GOAL_TASKS, taskId),
134
- apiToken: this.authToken,
135
- customFetch: this.customFetch,
136
- requestId: requestId,
137
- });
138
- return isSuccess(response);
139
- }
140
- }
@@ -1,2 +0,0 @@
1
- export * from './types.js';
2
- export * from './requests.js';
@@ -1 +0,0 @@
1
- export {};
@@ -1,53 +0,0 @@
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
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,23 +0,0 @@
1
- import { z } from 'zod';
2
- export const WorkspaceGoalMilestoneSchema = z.looseObject({
3
- id: z.string(),
4
- title: z.string(),
5
- isCompleted: z.boolean(),
6
- });
7
- export const WorkspaceGoalProgressSchema = z.looseObject({
8
- completedItems: z.number().int(),
9
- totalItems: z.number().int(),
10
- });
11
- export const WorkspaceGoalSchema = z.looseObject({
12
- id: z.string(),
13
- workspaceId: z.string(),
14
- title: z.string(),
15
- description: z.string().nullable(),
16
- deadline: z.string().nullable(),
17
- isDeleted: z.boolean(),
18
- projectIds: z.array(z.string()),
19
- progress: WorkspaceGoalProgressSchema.nullable(),
20
- creatorUid: z.string(),
21
- createdAt: z.coerce.date(),
22
- updatedAt: z.coerce.date(),
23
- });
@@ -1,20 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- export * from './types.js';
2
- export * from './requests.js';