@doist/todoist-api-typescript 4.0.0 → 4.0.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.
package/README.md CHANGED
@@ -24,7 +24,7 @@ api.getTasks()
24
24
 
25
25
  ### Documentation
26
26
 
27
- For more detailed reference documentation, have a look at the [Todoist API v1 Documentation](https://todoist.com/api/v1).
27
+ For more detailed reference documentation, have a look at the [Todoist API v1 Documentation](https://todoist.com/api/v1/docs).
28
28
 
29
29
  ### Migration Guide
30
30
 
@@ -55,6 +55,7 @@ var validators_1 = require("./utils/validators");
55
55
  var zod_1 = require("zod");
56
56
  var uuid_1 = require("uuid");
57
57
  var types_1 = require("./types");
58
+ var projectConverter_1 = require("./utils/projectConverter");
58
59
  var MAX_COMMAND_COUNT = 100;
59
60
  /**
60
61
  * Joins path segments using `/` separator.
@@ -110,7 +111,7 @@ var TodoistApi = /** @class */ (function () {
110
111
  */
111
112
  TodoistApi.prototype.getTask = function (id) {
112
113
  return __awaiter(this, void 0, void 0, function () {
113
- var response;
114
+ var response, task;
114
115
  return __generator(this, function (_a) {
115
116
  switch (_a.label) {
116
117
  case 0:
@@ -118,7 +119,8 @@ var TodoistApi = /** @class */ (function () {
118
119
  return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_TASKS, id), this.authToken)];
119
120
  case 1:
120
121
  response = _a.sent();
121
- return [2 /*return*/, (0, validators_1.validateTask)(response.data)];
122
+ task = (0, taskConverters_1.getTaskFromRawTaskResponse)(response.data);
123
+ return [2 /*return*/, (0, validators_1.validateTask)(task)];
122
124
  }
123
125
  });
124
126
  });
@@ -132,12 +134,13 @@ var TodoistApi = /** @class */ (function () {
132
134
  TodoistApi.prototype.getTasks = function (args) {
133
135
  if (args === void 0) { args = {}; }
134
136
  return __awaiter(this, void 0, void 0, function () {
135
- var _a, results, nextCursor;
137
+ var _a, rawResults, nextCursor, results;
136
138
  return __generator(this, function (_b) {
137
139
  switch (_b.label) {
138
140
  case 0: return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, endpoints_1.ENDPOINT_REST_TASKS, this.authToken, args)];
139
141
  case 1:
140
- _a = (_b.sent()).data, results = _a.results, nextCursor = _a.nextCursor;
142
+ _a = (_b.sent()).data, rawResults = _a.results, nextCursor = _a.nextCursor;
143
+ results = rawResults.map(taskConverters_1.getTaskFromRawTaskResponse);
141
144
  return [2 /*return*/, {
142
145
  results: (0, validators_1.validateTaskArray)(results),
143
146
  nextCursor: nextCursor,
@@ -154,12 +157,13 @@ var TodoistApi = /** @class */ (function () {
154
157
  */
155
158
  TodoistApi.prototype.getTasksByFilter = function (args) {
156
159
  return __awaiter(this, void 0, void 0, function () {
157
- var _a, results, nextCursor;
160
+ var _a, rawResults, nextCursor, results;
158
161
  return __generator(this, function (_b) {
159
162
  switch (_b.label) {
160
163
  case 0: return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, endpoints_1.ENDPOINT_REST_TASKS_FILTER, this.authToken, args)];
161
164
  case 1:
162
- _a = (_b.sent()).data, results = _a.results, nextCursor = _a.nextCursor;
165
+ _a = (_b.sent()).data, rawResults = _a.results, nextCursor = _a.nextCursor;
166
+ results = rawResults.map(taskConverters_1.getTaskFromRawTaskResponse);
163
167
  return [2 /*return*/, {
164
168
  results: (0, validators_1.validateTaskArray)(results),
165
169
  nextCursor: nextCursor,
@@ -177,13 +181,14 @@ var TodoistApi = /** @class */ (function () {
177
181
  */
178
182
  TodoistApi.prototype.addTask = function (args, requestId) {
179
183
  return __awaiter(this, void 0, void 0, function () {
180
- var response;
184
+ var response, task;
181
185
  return __generator(this, function (_a) {
182
186
  switch (_a.label) {
183
187
  case 0: return [4 /*yield*/, (0, restClient_1.request)('POST', this.syncApiBase, endpoints_1.ENDPOINT_REST_TASKS, this.authToken, args, requestId)];
184
188
  case 1:
185
189
  response = _a.sent();
186
- return [2 /*return*/, (0, validators_1.validateTask)(response.data)];
190
+ task = (0, taskConverters_1.getTaskFromRawTaskResponse)(response.data);
191
+ return [2 /*return*/, (0, validators_1.validateTask)(task)];
187
192
  }
188
193
  });
189
194
  });
@@ -218,7 +223,7 @@ var TodoistApi = /** @class */ (function () {
218
223
  */
219
224
  TodoistApi.prototype.updateTask = function (id, args, requestId) {
220
225
  return __awaiter(this, void 0, void 0, function () {
221
- var response;
226
+ var response, task;
222
227
  return __generator(this, function (_a) {
223
228
  switch (_a.label) {
224
229
  case 0:
@@ -226,7 +231,8 @@ var TodoistApi = /** @class */ (function () {
226
231
  return [4 /*yield*/, (0, restClient_1.request)('POST', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_TASKS, id), this.authToken, args, requestId)];
227
232
  case 1:
228
233
  response = _a.sent();
229
- return [2 /*return*/, (0, validators_1.validateTask)(response.data)];
234
+ task = (0, taskConverters_1.getTaskFromRawTaskResponse)(response.data);
235
+ return [2 /*return*/, (0, validators_1.validateTask)(task)];
230
236
  }
231
237
  });
232
238
  });
@@ -358,7 +364,7 @@ var TodoistApi = /** @class */ (function () {
358
364
  */
359
365
  TodoistApi.prototype.getProject = function (id) {
360
366
  return __awaiter(this, void 0, void 0, function () {
361
- var response;
367
+ var response, project;
362
368
  return __generator(this, function (_a) {
363
369
  switch (_a.label) {
364
370
  case 0:
@@ -366,7 +372,8 @@ var TodoistApi = /** @class */ (function () {
366
372
  return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, id), this.authToken)];
367
373
  case 1:
368
374
  response = _a.sent();
369
- return [2 /*return*/, (0, validators_1.validateProject)(response.data)];
375
+ project = (0, projectConverter_1.getProjectFromRawProjectResponse)(response.data);
376
+ return [2 /*return*/, (0, validators_1.validateProject)(project)];
370
377
  }
371
378
  });
372
379
  });
@@ -380,12 +387,13 @@ var TodoistApi = /** @class */ (function () {
380
387
  TodoistApi.prototype.getProjects = function (args) {
381
388
  if (args === void 0) { args = {}; }
382
389
  return __awaiter(this, void 0, void 0, function () {
383
- var _a, results, nextCursor;
390
+ var _a, rawResults, nextCursor, results;
384
391
  return __generator(this, function (_b) {
385
392
  switch (_b.label) {
386
393
  case 0: return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, endpoints_1.ENDPOINT_REST_PROJECTS, this.authToken, args)];
387
394
  case 1:
388
- _a = (_b.sent()).data, results = _a.results, nextCursor = _a.nextCursor;
395
+ _a = (_b.sent()).data, rawResults = _a.results, nextCursor = _a.nextCursor;
396
+ results = rawResults.map(projectConverter_1.getProjectFromRawProjectResponse);
389
397
  return [2 /*return*/, {
390
398
  results: (0, validators_1.validateProjectArray)(results),
391
399
  nextCursor: nextCursor,
@@ -403,13 +411,14 @@ var TodoistApi = /** @class */ (function () {
403
411
  */
404
412
  TodoistApi.prototype.addProject = function (args, requestId) {
405
413
  return __awaiter(this, void 0, void 0, function () {
406
- var response;
414
+ var response, project;
407
415
  return __generator(this, function (_a) {
408
416
  switch (_a.label) {
409
417
  case 0: return [4 /*yield*/, (0, restClient_1.request)('POST', this.syncApiBase, endpoints_1.ENDPOINT_REST_PROJECTS, this.authToken, args, requestId)];
410
418
  case 1:
411
419
  response = _a.sent();
412
- return [2 /*return*/, (0, validators_1.validateProject)(response.data)];
420
+ project = (0, projectConverter_1.getProjectFromRawProjectResponse)(response.data);
421
+ return [2 /*return*/, (0, validators_1.validateProject)(project)];
413
422
  }
414
423
  });
415
424
  });
@@ -424,7 +433,7 @@ var TodoistApi = /** @class */ (function () {
424
433
  */
425
434
  TodoistApi.prototype.updateProject = function (id, args, requestId) {
426
435
  return __awaiter(this, void 0, void 0, function () {
427
- var response;
436
+ var response, project;
428
437
  return __generator(this, function (_a) {
429
438
  switch (_a.label) {
430
439
  case 0:
@@ -432,7 +441,8 @@ var TodoistApi = /** @class */ (function () {
432
441
  return [4 /*yield*/, (0, restClient_1.request)('POST', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, id), this.authToken, args, requestId)];
433
442
  case 1:
434
443
  response = _a.sent();
435
- return [2 /*return*/, (0, validators_1.validateProject)(response.data)];
444
+ project = (0, projectConverter_1.getProjectFromRawProjectResponse)(response.data);
445
+ return [2 /*return*/, (0, validators_1.validateProject)(project)];
436
446
  }
437
447
  });
438
448
  });
@@ -2,7 +2,7 @@
2
2
  * Permission scopes that can be requested during OAuth2 authorization.
3
3
  * @see {@link https://todoist.com/api/v1/docs#tag/Authorization}
4
4
  */
5
- export type Permission = 'task:add' | 'data:read' | 'data:read_write' | 'data:delete' | 'project:delete';
5
+ export type Permission = 'task:add' | 'data:read' | 'data:read_write' | 'data:delete' | 'project:delete' | 'backups:read';
6
6
  /**
7
7
  * Parameters required to exchange an authorization code for an access token.
8
8
  * @see https://todoist.com/api/v1/docs#tag/Authorization/OAuth
@@ -1,4 +1,4 @@
1
- import { Label, Project, QuickAddTaskResponse, Section, Task, User, RawComment, Attachment, Duration, Deadline } from '../types';
1
+ import { Label, Project, QuickAddTaskResponse, Section, Task, User, RawComment, Attachment, Duration, Deadline, RawTask, RawProject } from '../types';
2
2
  export declare const DEFAULT_AUTH_TOKEN = "AToken";
3
3
  export declare const DEFAULT_REQUEST_ID = "ARequestID";
4
4
  export declare const INVALID_ENTITY_ID = 1234;
@@ -16,30 +16,30 @@ export declare const DEFAULT_TASK: Task;
16
16
  export declare const INVALID_TASK: {
17
17
  due: string;
18
18
  id: string;
19
- assignerId: string | null;
20
- assigneeId: string | null;
21
19
  projectId: string;
22
20
  sectionId: string | null;
23
21
  parentId: string | null;
24
- order: number;
22
+ labels: string[];
23
+ deadline: {
24
+ date: string;
25
+ lang: string;
26
+ } | null;
27
+ duration: {
28
+ amount: number;
29
+ unit: "minute" | "day";
30
+ } | null;
31
+ priority: number;
25
32
  content: string;
26
33
  description: string;
34
+ assignerId: string | null;
35
+ assigneeId: string | null;
36
+ order: number;
27
37
  isCompleted: boolean;
28
- labels: string[];
29
- priority: number;
30
38
  creatorId: string;
31
39
  createdAt: string;
32
40
  url: string;
33
- duration: {
34
- amount: number;
35
- unit: "minute" | "day";
36
- } | null;
37
- deadline: {
38
- date: string;
39
- lang: string;
40
- } | null;
41
41
  };
42
- export declare const TASK_WITH_OPTIONALS_AS_NULL: Task;
42
+ export declare const TASK_WITH_OPTIONALS_AS_NULL: RawTask;
43
43
  export declare const DEFAULT_PROJECT: Project;
44
44
  export declare const INVALID_PROJECT: {
45
45
  name: number;
@@ -48,26 +48,26 @@ export declare const INVALID_PROJECT: {
48
48
  order: number | null;
49
49
  url: string;
50
50
  color: string;
51
- isShared: boolean;
52
51
  isFavorite: boolean;
52
+ viewStyle: string;
53
+ isShared: boolean;
53
54
  isInboxProject: boolean;
54
55
  isTeamInbox: boolean;
55
- viewStyle: string;
56
56
  };
57
57
  export declare const PROJECT_WITH_OPTIONALS_AS_NULL: Project;
58
58
  export declare const DEFAULT_SECTION: Section;
59
59
  export declare const INVALID_SECTION: {
60
60
  projectId: undefined;
61
- id: string;
62
- name: string;
63
61
  userId: string;
62
+ id: string;
63
+ isDeleted: boolean;
64
64
  addedAt: string;
65
65
  updatedAt: string;
66
+ isCollapsed: boolean;
67
+ isArchived: boolean;
68
+ name: string;
66
69
  archivedAt: string | null;
67
70
  sectionOrder: number;
68
- isArchived: boolean;
69
- isDeleted: boolean;
70
- isCollapsed: boolean;
71
71
  };
72
72
  export declare const DEFAULT_LABEL: Label;
73
73
  export declare const INVALID_LABEL: {
@@ -103,8 +103,8 @@ export declare const DEFAULT_COMMENT: {
103
103
  taskId: string | undefined;
104
104
  itemId: undefined;
105
105
  id: string;
106
- content: string;
107
106
  isDeleted: boolean;
107
+ content: string;
108
108
  postedAt: string;
109
109
  fileAttachment: {
110
110
  resourceType: string;
@@ -155,8 +155,8 @@ export declare const COMMENT_WITH_OPTIONALS_AS_NULL_TASK: {
155
155
  taskId: string | undefined;
156
156
  itemId: undefined;
157
157
  id: string;
158
- content: string;
159
158
  isDeleted: boolean;
159
+ content: string;
160
160
  postedAt: string;
161
161
  fileAttachment: {
162
162
  resourceType: string;
@@ -182,8 +182,8 @@ export declare const COMMENT_WITH_ATTACHMENT_WITH_OPTIONALS_AS_NULL: {
182
182
  taskId: string | undefined;
183
183
  itemId: undefined;
184
184
  id: string;
185
- content: string;
186
185
  isDeleted: boolean;
186
+ content: string;
187
187
  postedAt: string;
188
188
  fileAttachment: {
189
189
  resourceType: string;
@@ -208,8 +208,8 @@ export declare const RAW_COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT: RawComment;
208
208
  export declare const COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT: {
209
209
  taskId: undefined;
210
210
  id: string;
211
- content: string;
212
211
  isDeleted: boolean;
212
+ content: string;
213
213
  postedAt: string;
214
214
  fileAttachment: {
215
215
  resourceType: string;
@@ -231,3 +231,5 @@ export declare const COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT: {
231
231
  projectId?: string | undefined;
232
232
  itemId?: string | undefined;
233
233
  };
234
+ export declare const RAW_DEFAULT_TASK: RawTask;
235
+ export declare const RAW_DEFAULT_PROJECT: RawProject;
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT = exports.RAW_COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT = exports.COMMENT_WITH_ATTACHMENT_WITH_OPTIONALS_AS_NULL = exports.RAW_COMMENT_WITH_ATTACHMENT_WITH_OPTIONALS_AS_NULL = exports.COMMENT_WITH_OPTIONALS_AS_NULL_TASK = exports.RAW_COMMENT_WITH_OPTIONALS_AS_NULL_TASK = exports.INVALID_COMMENT = exports.DEFAULT_COMMENT = exports.DEFAULT_RAW_COMMENT = exports.INVALID_ATTACHMENT = exports.DEFAULT_ATTACHMENT = exports.INVALID_USER = exports.DEFAULT_USER = exports.INVALID_LABEL = exports.DEFAULT_LABEL = exports.INVALID_SECTION = exports.DEFAULT_SECTION = exports.PROJECT_WITH_OPTIONALS_AS_NULL = exports.INVALID_PROJECT = exports.DEFAULT_PROJECT = exports.TASK_WITH_OPTIONALS_AS_NULL = exports.INVALID_TASK = exports.DEFAULT_TASK = exports.DEFAULT_QUICK_ADD_RESPONSE = exports.DEFAULT_DEADLINE = exports.DEFAULT_DURATION = exports.DEFAULT_DUE_DATE = exports.INVALID_ENTITY_ID = exports.DEFAULT_REQUEST_ID = exports.DEFAULT_AUTH_TOKEN = void 0;
14
+ exports.RAW_DEFAULT_PROJECT = exports.RAW_DEFAULT_TASK = exports.COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT = exports.RAW_COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT = exports.COMMENT_WITH_ATTACHMENT_WITH_OPTIONALS_AS_NULL = exports.RAW_COMMENT_WITH_ATTACHMENT_WITH_OPTIONALS_AS_NULL = exports.COMMENT_WITH_OPTIONALS_AS_NULL_TASK = exports.RAW_COMMENT_WITH_OPTIONALS_AS_NULL_TASK = exports.INVALID_COMMENT = exports.DEFAULT_COMMENT = exports.DEFAULT_RAW_COMMENT = exports.INVALID_ATTACHMENT = exports.DEFAULT_ATTACHMENT = exports.INVALID_USER = exports.DEFAULT_USER = exports.INVALID_LABEL = exports.DEFAULT_LABEL = exports.INVALID_SECTION = exports.DEFAULT_SECTION = exports.PROJECT_WITH_OPTIONALS_AS_NULL = exports.INVALID_PROJECT = exports.DEFAULT_PROJECT = exports.TASK_WITH_OPTIONALS_AS_NULL = exports.INVALID_TASK = exports.DEFAULT_TASK = exports.DEFAULT_QUICK_ADD_RESPONSE = exports.DEFAULT_DEADLINE = exports.DEFAULT_DURATION = exports.DEFAULT_DUE_DATE = exports.INVALID_ENTITY_ID = exports.DEFAULT_REQUEST_ID = exports.DEFAULT_AUTH_TOKEN = void 0;
15
15
  var DEFAULT_TASK_ID = '1234';
16
16
  var DEFAULT_TASK_CONTENT = 'This is a task';
17
17
  var DEFAULT_TASK_DESCRIPTION = 'A description';
@@ -100,7 +100,31 @@ exports.DEFAULT_TASK = {
100
100
  deadline: exports.DEFAULT_DEADLINE,
101
101
  };
102
102
  exports.INVALID_TASK = __assign(__assign({}, exports.DEFAULT_TASK), { due: '2020-01-31' });
103
- exports.TASK_WITH_OPTIONALS_AS_NULL = __assign(__assign({}, exports.DEFAULT_TASK), { due: null, assigneeId: null, assignerId: null, parentId: null, sectionId: null, duration: null });
103
+ exports.TASK_WITH_OPTIONALS_AS_NULL = {
104
+ userId: DEFAULT_CREATOR,
105
+ id: DEFAULT_TASK_ID,
106
+ projectId: DEFAULT_PROJECT_ID,
107
+ sectionId: null,
108
+ parentId: null,
109
+ addedByUid: DEFAULT_CREATOR,
110
+ assignedByUid: null,
111
+ responsibleUid: null,
112
+ labels: [],
113
+ deadline: null,
114
+ duration: null,
115
+ checked: false,
116
+ isDeleted: false,
117
+ addedAt: DEFAULT_DATE,
118
+ completedAt: null,
119
+ updatedAt: DEFAULT_DATE,
120
+ due: null,
121
+ priority: DEFAULT_TASK_PRIORITY,
122
+ childOrder: DEFAULT_ORDER,
123
+ content: DEFAULT_TASK_CONTENT,
124
+ description: DEFAULT_TASK_DESCRIPTION,
125
+ dayOrder: DEFAULT_ORDER,
126
+ isCollapsed: false,
127
+ };
104
128
  exports.DEFAULT_PROJECT = {
105
129
  id: DEFAULT_PROJECT_ID,
106
130
  name: DEFAULT_PROJECT_NAME,
@@ -182,3 +206,49 @@ exports.RAW_COMMENT_WITH_ATTACHMENT_WITH_OPTIONALS_AS_NULL = __assign(__assign({
182
206
  exports.COMMENT_WITH_ATTACHMENT_WITH_OPTIONALS_AS_NULL = __assign(__assign({}, exports.RAW_COMMENT_WITH_ATTACHMENT_WITH_OPTIONALS_AS_NULL), { taskId: exports.RAW_COMMENT_WITH_ATTACHMENT_WITH_OPTIONALS_AS_NULL.itemId, itemId: undefined });
183
207
  exports.RAW_COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT = __assign(__assign({}, exports.DEFAULT_RAW_COMMENT), { itemId: undefined, projectId: DEFAULT_PROJECT_ID });
184
208
  exports.COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT = __assign(__assign({}, exports.RAW_COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT), { taskId: undefined });
209
+ exports.RAW_DEFAULT_TASK = {
210
+ userId: DEFAULT_CREATOR,
211
+ id: DEFAULT_TASK_ID,
212
+ projectId: DEFAULT_PROJECT_ID,
213
+ sectionId: DEFAULT_SECTION_ID,
214
+ parentId: DEFAULT_PARENT_ID,
215
+ addedByUid: DEFAULT_CREATOR,
216
+ assignedByUid: DEFAULT_CREATOR,
217
+ responsibleUid: DEFAULT_ASSIGNEE,
218
+ labels: DEFAULT_LABELS,
219
+ deadline: exports.DEFAULT_DEADLINE,
220
+ duration: exports.DEFAULT_DURATION,
221
+ checked: false,
222
+ isDeleted: false,
223
+ addedAt: DEFAULT_DATE,
224
+ completedAt: null,
225
+ updatedAt: DEFAULT_DATE,
226
+ due: exports.DEFAULT_DUE_DATE,
227
+ priority: DEFAULT_TASK_PRIORITY,
228
+ childOrder: DEFAULT_ORDER,
229
+ content: DEFAULT_TASK_CONTENT,
230
+ description: DEFAULT_TASK_DESCRIPTION,
231
+ dayOrder: DEFAULT_ORDER,
232
+ isCollapsed: false,
233
+ };
234
+ exports.RAW_DEFAULT_PROJECT = {
235
+ id: DEFAULT_PROJECT_ID,
236
+ canAssignTasks: true,
237
+ childOrder: DEFAULT_ORDER,
238
+ color: DEFAULT_ENTITY_COLOR,
239
+ createdAt: DEFAULT_DATE,
240
+ isArchived: false,
241
+ isDeleted: false,
242
+ isFavorite: false,
243
+ isFrozen: false,
244
+ name: DEFAULT_PROJECT_NAME,
245
+ updatedAt: DEFAULT_DATE,
246
+ viewStyle: DEFAULT_PROJECT_VIEW_STYLE,
247
+ defaultOrder: DEFAULT_ORDER,
248
+ description: '',
249
+ publicAccess: false,
250
+ parentId: DEFAULT_PROJECT_ID,
251
+ inboxProject: false,
252
+ isCollapsed: false,
253
+ isShared: false,
254
+ };
@@ -59,6 +59,147 @@ export declare const DeadlineSchema: z.ZodObject<{
59
59
  */
60
60
  export interface Deadline extends z.infer<typeof DeadlineSchema> {
61
61
  }
62
+ export declare const RawTaskSchema: z.ZodObject<{
63
+ userId: z.ZodString;
64
+ id: z.ZodString;
65
+ projectId: z.ZodString;
66
+ sectionId: z.ZodNullable<z.ZodString>;
67
+ parentId: z.ZodNullable<z.ZodString>;
68
+ addedByUid: z.ZodString;
69
+ assignedByUid: z.ZodNullable<z.ZodString>;
70
+ responsibleUid: z.ZodNullable<z.ZodString>;
71
+ labels: z.ZodArray<z.ZodString, "many">;
72
+ deadline: z.ZodNullable<z.ZodObject<{
73
+ date: z.ZodString;
74
+ lang: z.ZodString;
75
+ }, "strip", z.ZodTypeAny, {
76
+ date: string;
77
+ lang: string;
78
+ }, {
79
+ date: string;
80
+ lang: string;
81
+ }>>;
82
+ duration: z.ZodNullable<z.ZodObject<{
83
+ amount: z.ZodNumber;
84
+ unit: z.ZodEnum<["minute", "day"]>;
85
+ }, "strip", z.ZodTypeAny, {
86
+ amount: number;
87
+ unit: "minute" | "day";
88
+ }, {
89
+ amount: number;
90
+ unit: "minute" | "day";
91
+ }>>;
92
+ checked: z.ZodBoolean;
93
+ isDeleted: z.ZodBoolean;
94
+ addedAt: z.ZodString;
95
+ completedAt: z.ZodNullable<z.ZodString>;
96
+ updatedAt: z.ZodString;
97
+ due: z.ZodNullable<z.ZodObject<z.objectUtil.extendShape<{
98
+ isRecurring: z.ZodBoolean;
99
+ string: z.ZodString;
100
+ date: z.ZodString;
101
+ }, {
102
+ datetime: z.ZodOptional<z.ZodNullable<z.ZodString>>;
103
+ timezone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
104
+ lang: z.ZodOptional<z.ZodNullable<z.ZodString>>;
105
+ }>, "strip", z.ZodTypeAny, {
106
+ string: string;
107
+ isRecurring: boolean;
108
+ date: string;
109
+ datetime?: string | null | undefined;
110
+ timezone?: string | null | undefined;
111
+ lang?: string | null | undefined;
112
+ }, {
113
+ string: string;
114
+ isRecurring: boolean;
115
+ date: string;
116
+ datetime?: string | null | undefined;
117
+ timezone?: string | null | undefined;
118
+ lang?: string | null | undefined;
119
+ }>>;
120
+ priority: z.ZodNumber;
121
+ childOrder: z.ZodNumber;
122
+ content: z.ZodString;
123
+ description: z.ZodString;
124
+ dayOrder: z.ZodNumber;
125
+ isCollapsed: z.ZodBoolean;
126
+ }, "strip", z.ZodTypeAny, {
127
+ userId: string;
128
+ id: string;
129
+ projectId: string;
130
+ sectionId: string | null;
131
+ parentId: string | null;
132
+ addedByUid: string;
133
+ assignedByUid: string | null;
134
+ responsibleUid: string | null;
135
+ labels: string[];
136
+ deadline: {
137
+ date: string;
138
+ lang: string;
139
+ } | null;
140
+ duration: {
141
+ amount: number;
142
+ unit: "minute" | "day";
143
+ } | null;
144
+ checked: boolean;
145
+ isDeleted: boolean;
146
+ addedAt: string;
147
+ completedAt: string | null;
148
+ updatedAt: string;
149
+ due: {
150
+ string: string;
151
+ isRecurring: boolean;
152
+ date: string;
153
+ datetime?: string | null | undefined;
154
+ timezone?: string | null | undefined;
155
+ lang?: string | null | undefined;
156
+ } | null;
157
+ priority: number;
158
+ childOrder: number;
159
+ content: string;
160
+ description: string;
161
+ dayOrder: number;
162
+ isCollapsed: boolean;
163
+ }, {
164
+ userId: string;
165
+ id: string;
166
+ projectId: string;
167
+ sectionId: string | null;
168
+ parentId: string | null;
169
+ addedByUid: string;
170
+ assignedByUid: string | null;
171
+ responsibleUid: string | null;
172
+ labels: string[];
173
+ deadline: {
174
+ date: string;
175
+ lang: string;
176
+ } | null;
177
+ duration: {
178
+ amount: number;
179
+ unit: "minute" | "day";
180
+ } | null;
181
+ checked: boolean;
182
+ isDeleted: boolean;
183
+ addedAt: string;
184
+ completedAt: string | null;
185
+ updatedAt: string;
186
+ due: {
187
+ string: string;
188
+ isRecurring: boolean;
189
+ date: string;
190
+ datetime?: string | null | undefined;
191
+ timezone?: string | null | undefined;
192
+ lang?: string | null | undefined;
193
+ } | null;
194
+ priority: number;
195
+ childOrder: number;
196
+ content: string;
197
+ description: string;
198
+ dayOrder: number;
199
+ isCollapsed: boolean;
200
+ }>;
201
+ export interface RawTask extends z.infer<typeof RawTaskSchema> {
202
+ }
62
203
  export declare const TaskSchema: z.ZodObject<{
63
204
  id: z.ZodString;
64
205
  assignerId: z.ZodNullable<z.ZodString>;
@@ -120,19 +261,18 @@ export declare const TaskSchema: z.ZodObject<{
120
261
  }>>;
121
262
  }, "strip", z.ZodTypeAny, {
122
263
  id: string;
123
- assignerId: string | null;
124
- assigneeId: string | null;
125
264
  projectId: string;
126
265
  sectionId: string | null;
127
266
  parentId: string | null;
128
- order: number;
129
- content: string;
130
- description: string;
131
- isCompleted: boolean;
132
267
  labels: string[];
133
- priority: number;
134
- creatorId: string;
135
- createdAt: string;
268
+ deadline: {
269
+ date: string;
270
+ lang: string;
271
+ } | null;
272
+ duration: {
273
+ amount: number;
274
+ unit: "minute" | "day";
275
+ } | null;
136
276
  due: {
137
277
  string: string;
138
278
  isRecurring: boolean;
@@ -141,30 +281,30 @@ export declare const TaskSchema: z.ZodObject<{
141
281
  timezone?: string | null | undefined;
142
282
  lang?: string | null | undefined;
143
283
  } | null;
284
+ priority: number;
285
+ content: string;
286
+ description: string;
287
+ assignerId: string | null;
288
+ assigneeId: string | null;
289
+ order: number;
290
+ isCompleted: boolean;
291
+ creatorId: string;
292
+ createdAt: string;
144
293
  url: string;
145
- duration: {
146
- amount: number;
147
- unit: "minute" | "day";
148
- } | null;
149
- deadline: {
150
- date: string;
151
- lang: string;
152
- } | null;
153
294
  }, {
154
295
  id: string;
155
- assignerId: string | null;
156
- assigneeId: string | null;
157
296
  projectId: string;
158
297
  sectionId: string | null;
159
298
  parentId: string | null;
160
- order: number;
161
- content: string;
162
- description: string;
163
- isCompleted: boolean;
164
299
  labels: string[];
165
- priority: number;
166
- creatorId: string;
167
- createdAt: string;
300
+ deadline: {
301
+ date: string;
302
+ lang: string;
303
+ } | null;
304
+ duration: {
305
+ amount: number;
306
+ unit: "minute" | "day";
307
+ } | null;
168
308
  due: {
169
309
  string: string;
170
310
  isRecurring: boolean;
@@ -173,15 +313,16 @@ export declare const TaskSchema: z.ZodObject<{
173
313
  timezone?: string | null | undefined;
174
314
  lang?: string | null | undefined;
175
315
  } | null;
316
+ priority: number;
317
+ content: string;
318
+ description: string;
319
+ assignerId: string | null;
320
+ assigneeId: string | null;
321
+ order: number;
322
+ isCompleted: boolean;
323
+ creatorId: string;
324
+ createdAt: string;
176
325
  url: string;
177
- duration: {
178
- amount: number;
179
- unit: "minute" | "day";
180
- } | null;
181
- deadline: {
182
- date: string;
183
- lang: string;
184
- } | null;
185
326
  }>;
186
327
  /**
187
328
  * Represents a task in Todoist.
@@ -189,6 +330,69 @@ export declare const TaskSchema: z.ZodObject<{
189
330
  */
190
331
  export interface Task extends z.infer<typeof TaskSchema> {
191
332
  }
333
+ export declare const RawProjectSchema: z.ZodObject<{
334
+ id: z.ZodString;
335
+ canAssignTasks: z.ZodBoolean;
336
+ childOrder: z.ZodNullable<z.ZodNumber>;
337
+ color: z.ZodString;
338
+ createdAt: z.ZodString;
339
+ isArchived: z.ZodBoolean;
340
+ isDeleted: z.ZodBoolean;
341
+ isFavorite: z.ZodBoolean;
342
+ isFrozen: z.ZodBoolean;
343
+ name: z.ZodString;
344
+ updatedAt: z.ZodString;
345
+ viewStyle: z.ZodString;
346
+ defaultOrder: z.ZodNullable<z.ZodNumber>;
347
+ description: z.ZodString;
348
+ publicAccess: z.ZodBoolean;
349
+ parentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
350
+ inboxProject: z.ZodOptional<z.ZodBoolean>;
351
+ isCollapsed: z.ZodBoolean;
352
+ isShared: z.ZodBoolean;
353
+ }, "strip", z.ZodTypeAny, {
354
+ id: string;
355
+ isDeleted: boolean;
356
+ updatedAt: string;
357
+ childOrder: number | null;
358
+ description: string;
359
+ isCollapsed: boolean;
360
+ createdAt: string;
361
+ canAssignTasks: boolean;
362
+ color: string;
363
+ isArchived: boolean;
364
+ isFavorite: boolean;
365
+ isFrozen: boolean;
366
+ name: string;
367
+ viewStyle: string;
368
+ defaultOrder: number | null;
369
+ publicAccess: boolean;
370
+ isShared: boolean;
371
+ parentId?: string | null | undefined;
372
+ inboxProject?: boolean | undefined;
373
+ }, {
374
+ id: string;
375
+ isDeleted: boolean;
376
+ updatedAt: string;
377
+ childOrder: number | null;
378
+ description: string;
379
+ isCollapsed: boolean;
380
+ createdAt: string;
381
+ canAssignTasks: boolean;
382
+ color: string;
383
+ isArchived: boolean;
384
+ isFavorite: boolean;
385
+ isFrozen: boolean;
386
+ name: string;
387
+ viewStyle: string;
388
+ defaultOrder: number | null;
389
+ publicAccess: boolean;
390
+ isShared: boolean;
391
+ parentId?: string | null | undefined;
392
+ inboxProject?: boolean | undefined;
393
+ }>;
394
+ export interface RawProject extends z.infer<typeof RawProjectSchema> {
395
+ }
192
396
  export declare const ProjectSchema: z.ZodObject<{
193
397
  id: z.ZodString;
194
398
  parentId: z.ZodNullable<z.ZodString>;
@@ -207,24 +411,24 @@ export declare const ProjectSchema: z.ZodObject<{
207
411
  order: number | null;
208
412
  url: string;
209
413
  color: string;
414
+ isFavorite: boolean;
210
415
  name: string;
416
+ viewStyle: string;
211
417
  isShared: boolean;
212
- isFavorite: boolean;
213
418
  isInboxProject: boolean;
214
419
  isTeamInbox: boolean;
215
- viewStyle: string;
216
420
  }, {
217
421
  id: string;
218
422
  parentId: string | null;
219
423
  order: number | null;
220
424
  url: string;
221
425
  color: string;
426
+ isFavorite: boolean;
222
427
  name: string;
428
+ viewStyle: string;
223
429
  isShared: boolean;
224
- isFavorite: boolean;
225
430
  isInboxProject: boolean;
226
431
  isTeamInbox: boolean;
227
- viewStyle: string;
228
432
  }>;
229
433
  /**
230
434
  * Represents a project in Todoist.
@@ -249,29 +453,29 @@ export declare const SectionSchema: z.ZodObject<{
249
453
  isDeleted: z.ZodBoolean;
250
454
  isCollapsed: z.ZodBoolean;
251
455
  }, "strip", z.ZodTypeAny, {
456
+ userId: string;
252
457
  id: string;
253
458
  projectId: string;
254
- name: string;
255
- userId: string;
459
+ isDeleted: boolean;
256
460
  addedAt: string;
257
461
  updatedAt: string;
462
+ isCollapsed: boolean;
463
+ isArchived: boolean;
464
+ name: string;
258
465
  archivedAt: string | null;
259
466
  sectionOrder: number;
260
- isArchived: boolean;
261
- isDeleted: boolean;
262
- isCollapsed: boolean;
263
467
  }, {
468
+ userId: string;
264
469
  id: string;
265
470
  projectId: string;
266
- name: string;
267
- userId: string;
471
+ isDeleted: boolean;
268
472
  addedAt: string;
269
473
  updatedAt: string;
474
+ isCollapsed: boolean;
475
+ isArchived: boolean;
476
+ name: string;
270
477
  archivedAt: string | null;
271
478
  sectionOrder: number;
272
- isArchived: boolean;
273
- isDeleted: boolean;
274
- isCollapsed: boolean;
275
479
  }>;
276
480
  /**
277
481
  * Represents a section in a Todoist project.
@@ -289,14 +493,14 @@ export declare const LabelSchema: z.ZodObject<{
289
493
  id: string;
290
494
  order: number | null;
291
495
  color: string;
292
- name: string;
293
496
  isFavorite: boolean;
497
+ name: string;
294
498
  }, {
295
499
  id: string;
296
500
  order: number | null;
297
501
  color: string;
298
- name: string;
299
502
  isFavorite: boolean;
503
+ name: string;
300
504
  }>;
301
505
  /**
302
506
  * Represents a label in Todoist.
@@ -404,8 +608,8 @@ export declare const RawCommentSchema: z.ZodEffects<z.ZodObject<{
404
608
  isDeleted: z.ZodBoolean;
405
609
  }, "strip", z.ZodTypeAny, {
406
610
  id: string;
407
- content: string;
408
611
  isDeleted: boolean;
612
+ content: string;
409
613
  postedAt: string;
410
614
  fileAttachment: {
411
615
  resourceType: string;
@@ -428,8 +632,8 @@ export declare const RawCommentSchema: z.ZodEffects<z.ZodObject<{
428
632
  itemId?: string | undefined;
429
633
  }, {
430
634
  id: string;
431
- content: string;
432
635
  isDeleted: boolean;
636
+ content: string;
433
637
  postedAt: string;
434
638
  fileAttachment: {
435
639
  resourceType: string;
@@ -452,8 +656,8 @@ export declare const RawCommentSchema: z.ZodEffects<z.ZodObject<{
452
656
  itemId?: string | undefined;
453
657
  }>, {
454
658
  id: string;
455
- content: string;
456
659
  isDeleted: boolean;
660
+ content: string;
457
661
  postedAt: string;
458
662
  fileAttachment: {
459
663
  resourceType: string;
@@ -476,8 +680,8 @@ export declare const RawCommentSchema: z.ZodEffects<z.ZodObject<{
476
680
  itemId?: string | undefined;
477
681
  }, {
478
682
  id: string;
479
- content: string;
480
683
  isDeleted: boolean;
684
+ content: string;
481
685
  postedAt: string;
482
686
  fileAttachment: {
483
687
  resourceType: string;
@@ -558,8 +762,8 @@ export declare const CommentSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
558
762
  isDeleted: z.ZodBoolean;
559
763
  }, "strip", z.ZodTypeAny, {
560
764
  id: string;
561
- content: string;
562
765
  isDeleted: boolean;
766
+ content: string;
563
767
  postedAt: string;
564
768
  fileAttachment: {
565
769
  resourceType: string;
@@ -582,8 +786,8 @@ export declare const CommentSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
582
786
  itemId?: string | undefined;
583
787
  }, {
584
788
  id: string;
585
- content: string;
586
789
  isDeleted: boolean;
790
+ content: string;
587
791
  postedAt: string;
588
792
  fileAttachment: {
589
793
  resourceType: string;
@@ -606,8 +810,8 @@ export declare const CommentSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
606
810
  itemId?: string | undefined;
607
811
  }>, {
608
812
  id: string;
609
- content: string;
610
813
  isDeleted: boolean;
814
+ content: string;
611
815
  postedAt: string;
612
816
  fileAttachment: {
613
817
  resourceType: string;
@@ -630,8 +834,8 @@ export declare const CommentSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
630
834
  itemId?: string | undefined;
631
835
  }, {
632
836
  id: string;
633
- content: string;
634
837
  isDeleted: boolean;
838
+ content: string;
635
839
  postedAt: string;
636
840
  fileAttachment: {
637
841
  resourceType: string;
@@ -655,8 +859,8 @@ export declare const CommentSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
655
859
  }>, {
656
860
  taskId: string | undefined;
657
861
  id: string;
658
- content: string;
659
862
  isDeleted: boolean;
863
+ content: string;
660
864
  postedAt: string;
661
865
  fileAttachment: {
662
866
  resourceType: string;
@@ -678,8 +882,8 @@ export declare const CommentSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
678
882
  projectId?: string | undefined;
679
883
  }, {
680
884
  id: string;
681
- content: string;
682
885
  isDeleted: boolean;
886
+ content: string;
683
887
  postedAt: string;
684
888
  fileAttachment: {
685
889
  resourceType: string;
@@ -22,7 +22,7 @@ var __rest = (this && this.__rest) || function (s, e) {
22
22
  return t;
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.ColorSchema = exports.UserSchema = exports.CommentSchema = exports.RawCommentSchema = exports.AttachmentSchema = exports.LabelSchema = exports.SectionSchema = exports.ProjectSchema = exports.TaskSchema = exports.DeadlineSchema = exports.DurationSchema = exports.DueDateSchema = void 0;
25
+ exports.ColorSchema = exports.UserSchema = exports.CommentSchema = exports.RawCommentSchema = exports.AttachmentSchema = exports.LabelSchema = exports.SectionSchema = exports.ProjectSchema = exports.RawProjectSchema = exports.TaskSchema = exports.RawTaskSchema = exports.DeadlineSchema = exports.DurationSchema = exports.DueDateSchema = void 0;
26
26
  var zod_1 = require("zod");
27
27
  exports.DueDateSchema = zod_1.z
28
28
  .object({
@@ -43,6 +43,31 @@ exports.DeadlineSchema = zod_1.z.object({
43
43
  date: zod_1.z.string(),
44
44
  lang: zod_1.z.string(),
45
45
  });
46
+ exports.RawTaskSchema = zod_1.z.object({
47
+ userId: zod_1.z.string(),
48
+ id: zod_1.z.string(),
49
+ projectId: zod_1.z.string(),
50
+ sectionId: zod_1.z.string().nullable(),
51
+ parentId: zod_1.z.string().nullable(),
52
+ addedByUid: zod_1.z.string(),
53
+ assignedByUid: zod_1.z.string().nullable(),
54
+ responsibleUid: zod_1.z.string().nullable(),
55
+ labels: zod_1.z.array(zod_1.z.string()),
56
+ deadline: exports.DeadlineSchema.nullable(),
57
+ duration: exports.DurationSchema.nullable(),
58
+ checked: zod_1.z.boolean(),
59
+ isDeleted: zod_1.z.boolean(),
60
+ addedAt: zod_1.z.string(),
61
+ completedAt: zod_1.z.string().nullable(),
62
+ updatedAt: zod_1.z.string(),
63
+ due: exports.DueDateSchema.nullable(),
64
+ priority: zod_1.z.number().int(),
65
+ childOrder: zod_1.z.number().int(),
66
+ content: zod_1.z.string(),
67
+ description: zod_1.z.string(),
68
+ dayOrder: zod_1.z.number().int(),
69
+ isCollapsed: zod_1.z.boolean(),
70
+ });
46
71
  exports.TaskSchema = zod_1.z.object({
47
72
  id: zod_1.z.string(),
48
73
  assignerId: zod_1.z.string().nullable(),
@@ -63,6 +88,27 @@ exports.TaskSchema = zod_1.z.object({
63
88
  duration: exports.DurationSchema.nullable(),
64
89
  deadline: exports.DeadlineSchema.nullable(),
65
90
  });
91
+ exports.RawProjectSchema = zod_1.z.object({
92
+ id: zod_1.z.string(),
93
+ canAssignTasks: zod_1.z.boolean(),
94
+ childOrder: zod_1.z.number().int().nullable(),
95
+ color: zod_1.z.string(),
96
+ createdAt: zod_1.z.string(),
97
+ isArchived: zod_1.z.boolean(),
98
+ isDeleted: zod_1.z.boolean(),
99
+ isFavorite: zod_1.z.boolean(),
100
+ isFrozen: zod_1.z.boolean(),
101
+ name: zod_1.z.string(),
102
+ updatedAt: zod_1.z.string(),
103
+ viewStyle: zod_1.z.string(),
104
+ defaultOrder: zod_1.z.number().int().nullable(),
105
+ description: zod_1.z.string(),
106
+ publicAccess: zod_1.z.boolean(),
107
+ parentId: zod_1.z.string().nullable().optional(),
108
+ inboxProject: zod_1.z.boolean().optional(),
109
+ isCollapsed: zod_1.z.boolean(),
110
+ isShared: zod_1.z.boolean(),
111
+ });
66
112
  exports.ProjectSchema = zod_1.z.object({
67
113
  id: zod_1.z.string(),
68
114
  parentId: zod_1.z.string().nullable(),
@@ -0,0 +1,2 @@
1
+ import { Project, RawProject } from '../types';
2
+ export declare function getProjectFromRawProjectResponse(responseData: RawProject): Project;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getProjectFromRawProjectResponse = void 0;
4
+ var showProjectEndpoint = 'https://todoist.com/showProject';
5
+ function getProjectUrlFromProjectId(projectId) {
6
+ return "".concat(showProjectEndpoint, "?id=").concat(projectId);
7
+ }
8
+ function getProjectFromRawProjectResponse(responseData) {
9
+ var _a, _b;
10
+ var project = {
11
+ id: responseData.id,
12
+ parentId: (_a = responseData.parentId) !== null && _a !== void 0 ? _a : null, // workspace projects do not have a parent
13
+ order: responseData.childOrder,
14
+ color: responseData.color,
15
+ name: responseData.name,
16
+ isShared: responseData.isShared,
17
+ isFavorite: responseData.isFavorite,
18
+ isInboxProject: (_b = responseData.inboxProject) !== null && _b !== void 0 ? _b : false, // workspace projects do not set this flag
19
+ isTeamInbox: false, // this flag is no longer used
20
+ url: getProjectUrlFromProjectId(responseData.id),
21
+ viewStyle: responseData.viewStyle,
22
+ };
23
+ return project;
24
+ }
25
+ exports.getProjectFromRawProjectResponse = getProjectFromRawProjectResponse;
@@ -1,2 +1,3 @@
1
- import { QuickAddTaskResponse, Task } from '../types';
1
+ import { QuickAddTaskResponse, RawTask, Task } from '../types';
2
2
  export declare function getTaskFromQuickAddResponse(responseData: QuickAddTaskResponse): Task;
3
+ export declare function getTaskFromRawTaskResponse(responseData: RawTask): Task;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTaskFromQuickAddResponse = void 0;
3
+ exports.getTaskFromRawTaskResponse = exports.getTaskFromQuickAddResponse = void 0;
4
4
  var showTaskEndpoint = 'https://todoist.com/showTask';
5
- function getTaskUrlFromQuickAddResponse(responseData) {
6
- return "".concat(showTaskEndpoint, "?id=").concat(responseData.id);
5
+ function getTaskUrlFromTaskId(taskId) {
6
+ return "".concat(showTaskEndpoint, "?id=").concat(taskId);
7
7
  }
8
8
  function getTaskFromQuickAddResponse(responseData) {
9
9
  var _a;
@@ -18,7 +18,7 @@ function getTaskFromQuickAddResponse(responseData) {
18
18
  labels: responseData.labels,
19
19
  priority: responseData.priority,
20
20
  createdAt: responseData.addedAt,
21
- url: getTaskUrlFromQuickAddResponse(responseData),
21
+ url: getTaskUrlFromTaskId(responseData.id),
22
22
  creatorId: (_a = responseData.addedByUid) !== null && _a !== void 0 ? _a : '',
23
23
  parentId: responseData.parentId,
24
24
  duration: responseData.duration,
@@ -30,3 +30,27 @@ function getTaskFromQuickAddResponse(responseData) {
30
30
  return task;
31
31
  }
32
32
  exports.getTaskFromQuickAddResponse = getTaskFromQuickAddResponse;
33
+ function getTaskFromRawTaskResponse(responseData) {
34
+ var task = {
35
+ id: responseData.id,
36
+ assignerId: responseData.assignedByUid,
37
+ assigneeId: responseData.responsibleUid,
38
+ projectId: responseData.projectId,
39
+ sectionId: responseData.sectionId,
40
+ parentId: responseData.parentId,
41
+ order: responseData.childOrder,
42
+ content: responseData.content,
43
+ description: responseData.description,
44
+ isCompleted: responseData.checked,
45
+ labels: responseData.labels,
46
+ priority: responseData.priority,
47
+ creatorId: responseData.addedByUid,
48
+ createdAt: responseData.addedAt,
49
+ due: responseData.due,
50
+ url: getTaskUrlFromTaskId(responseData.id),
51
+ duration: responseData.duration,
52
+ deadline: responseData.deadline,
53
+ };
54
+ return task;
55
+ }
56
+ exports.getTaskFromRawTaskResponse = getTaskFromRawTaskResponse;
@@ -2,7 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateUserArray = exports.validateUser = exports.validateCommentArray = exports.validateComment = exports.validateLabelArray = exports.validateLabel = exports.validateSectionArray = exports.validateSection = exports.validateProjectArray = exports.validateProject = exports.validateTaskArray = exports.validateTask = void 0;
4
4
  var entities_1 = require("../types/entities");
5
+ var projectConverter_1 = require("./projectConverter");
6
+ var taskConverters_1 = require("./taskConverters");
5
7
  function validateTask(input) {
8
+ var rawTaskParse = entities_1.RawTaskSchema.safeParse(input);
9
+ if (rawTaskParse.success) {
10
+ var task = (0, taskConverters_1.getTaskFromRawTaskResponse)(rawTaskParse.data);
11
+ return task;
12
+ }
6
13
  return entities_1.TaskSchema.parse(input);
7
14
  }
8
15
  exports.validateTask = validateTask;
@@ -11,6 +18,11 @@ function validateTaskArray(input) {
11
18
  }
12
19
  exports.validateTaskArray = validateTaskArray;
13
20
  function validateProject(input) {
21
+ var rawProjectParse = entities_1.RawProjectSchema.safeParse(input);
22
+ if (rawProjectParse.success) {
23
+ var project = (0, projectConverter_1.getProjectFromRawProjectResponse)(rawProjectParse.data);
24
+ return project;
25
+ }
14
26
  return entities_1.ProjectSchema.parse(input);
15
27
  }
16
28
  exports.validateProject = validateProject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/todoist-api-typescript",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "A typescript wrapper for the Todoist REST API.",
5
5
  "author": "Doist developers",
6
6
  "repository": "git@github.com:doist/todoist-api-typescript.git",