@doist/todoist-api-typescript 2.2.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { Task, Project, Label, User, Section, Comment } from './types/entities';
2
- import { AddLabelArgs, AddProjectArgs, AddSectionArgs, AddProjectCommentArgs, AddTaskArgs, AddTaskCommentArgs, GetProjectCommentsArgs, GetTaskCommentsArgs, GetTasksArgs, UpdateCommentArgs, UpdateLabelArgs, UpdateProjectArgs, UpdateSectionArgs, UpdateTaskArgs, QuickAddTaskArgs, RenameSharedLabelArgs, RemoveSharedLabelArgs } from './types/requests';
2
+ import { AddCommentArgs, AddLabelArgs, AddProjectArgs, AddSectionArgs, AddTaskArgs, GetProjectCommentsArgs, GetTaskCommentsArgs, GetTasksArgs, UpdateCommentArgs, UpdateLabelArgs, UpdateProjectArgs, UpdateSectionArgs, UpdateTaskArgs, QuickAddTaskArgs, GetSharedLabelsArgs, RenameSharedLabelArgs, RemoveSharedLabelArgs } from './types/requests';
3
3
  export declare class TodoistApi {
4
4
  authToken: string;
5
5
  constructor(authToken: string, baseUrl?: string);
@@ -44,12 +44,12 @@ export declare class TodoistApi {
44
44
  * Deletes a personal label
45
45
  */
46
46
  deleteLabel(id: string, requestId?: string): Promise<boolean>;
47
- getSharedLabels(): Promise<string[]>;
47
+ getSharedLabels(args?: GetSharedLabelsArgs): Promise<string[]>;
48
48
  renameSharedLabel(args: RenameSharedLabelArgs): Promise<void>;
49
49
  removeSharedLabel(args: RemoveSharedLabelArgs): Promise<void>;
50
50
  getComments(args: GetTaskCommentsArgs | GetProjectCommentsArgs): Promise<Comment[]>;
51
51
  getComment(id: string): Promise<Comment>;
52
- addComment(args: AddTaskCommentArgs | AddProjectCommentArgs, requestId?: string): Promise<Comment>;
52
+ addComment(args: AddCommentArgs, requestId?: string): Promise<Comment>;
53
53
  updateComment(id: string, args: UpdateCommentArgs, requestId?: string): Promise<Comment>;
54
54
  deleteComment(id: string, requestId?: string): Promise<boolean>;
55
55
  }
@@ -418,12 +418,12 @@ var TodoistApi = /** @class */ (function () {
418
418
  });
419
419
  });
420
420
  };
421
- TodoistApi.prototype.getSharedLabels = function () {
421
+ TodoistApi.prototype.getSharedLabels = function (args) {
422
422
  return __awaiter(this, void 0, void 0, function () {
423
423
  var response;
424
424
  return __generator(this, function (_a) {
425
425
  switch (_a.label) {
426
- case 0: return [4 /*yield*/, (0, restClient_1.request)('GET', this.restApiBase, endpoints_1.ENDPOINT_REST_LABELS_SHARED, this.authToken)];
426
+ case 0: return [4 /*yield*/, (0, restClient_1.request)('GET', this.restApiBase, endpoints_1.ENDPOINT_REST_LABELS_SHARED, this.authToken, args)];
427
427
  case 1:
428
428
  response = _a.sent();
429
429
  return [2 /*return*/, response.data];
@@ -1,7 +1,7 @@
1
1
  export type Permission = 'task:add' | 'data:read' | 'data:read_write' | 'data:delete' | 'project:delete';
2
2
  export type AuthTokenResponse = {
3
3
  accessToken: string;
4
- state: string;
4
+ tokenType: string;
5
5
  };
6
6
  export type AuthTokenRequestArgs = {
7
7
  clientId: string;
@@ -33,10 +33,10 @@ export declare const INVALID_TASK: {
33
33
  createdAt: string;
34
34
  url: string;
35
35
  creatorId: string;
36
- duration: {
36
+ duration?: {
37
37
  amount: number;
38
38
  unit: "minute" | "day";
39
- } | null;
39
+ } | null | undefined;
40
40
  assigneeId?: string | null | undefined;
41
41
  assignerId?: string | null | undefined;
42
42
  parentId?: string | null | undefined;
@@ -16,6 +16,7 @@ export declare const DueDate: import("runtypes").Intersect<[Record<{
16
16
  }, false>, Partial<{
17
17
  datetime: Union<[String, Literal<null>]>;
18
18
  timezone: Union<[String, Literal<null>]>;
19
+ lang: Union<[String, Literal<null>]>;
19
20
  }, false>]>;
20
21
  export type DueDate = Static<typeof DueDate>;
21
22
  export declare const Duration: Record<{
@@ -36,10 +37,6 @@ export declare const Task: import("runtypes").Intersect<[Record<{
36
37
  createdAt: String;
37
38
  url: String;
38
39
  creatorId: String;
39
- duration: Union<[Record<{
40
- amount: import("runtypes").Constraint<NumberRunType, number, unknown>;
41
- unit: Union<[Literal<"minute">, Literal<"day">]>;
42
- }, false>, Literal<null>]>;
43
40
  }, false>, Partial<{
44
41
  due: Union<[import("runtypes").Intersect<[Record<{
45
42
  isRecurring: Boolean;
@@ -48,7 +45,12 @@ export declare const Task: import("runtypes").Intersect<[Record<{
48
45
  }, false>, Partial<{
49
46
  datetime: Union<[String, Literal<null>]>;
50
47
  timezone: Union<[String, Literal<null>]>;
48
+ lang: Union<[String, Literal<null>]>;
51
49
  }, false>]>, Literal<null>]>;
50
+ duration: Union<[Record<{
51
+ amount: import("runtypes").Constraint<NumberRunType, number, unknown>;
52
+ unit: Union<[Literal<"minute">, Literal<"day">]>;
53
+ }, false>, Literal<null>]>;
52
54
  assigneeId: Union<[String, Literal<null>]>;
53
55
  assignerId: Union<[String, Literal<null>]>;
54
56
  parentId: Union<[String, Literal<null>]>;
@@ -71,6 +73,7 @@ export declare const Project: import("runtypes").Intersect<[Record<{
71
73
  parentId: Union<[String, Literal<null>]>;
72
74
  }, false>]>;
73
75
  export type Project = Static<typeof Project>;
76
+ export type ProjectViewStyle = 'list' | 'board';
74
77
  export declare const Section: Record<{
75
78
  id: String;
76
79
  order: import("runtypes").Constraint<NumberRunType, number, unknown>;
@@ -10,6 +10,7 @@ exports.DueDate = (0, runtypes_1.Record)({
10
10
  }).And((0, runtypes_1.Partial)({
11
11
  datetime: runtypes_1.String.Or(runtypes_1.Null),
12
12
  timezone: runtypes_1.String.Or(runtypes_1.Null),
13
+ lang: runtypes_1.String.Or(runtypes_1.Null),
13
14
  }));
14
15
  exports.Duration = (0, runtypes_1.Record)({
15
16
  amount: runtypes_1.Number.withConstraint(function (n) { return n > 0 || 'Value should be greater than zero'; }),
@@ -28,9 +29,9 @@ exports.Task = (0, runtypes_1.Record)({
28
29
  createdAt: runtypes_1.String,
29
30
  url: runtypes_1.String,
30
31
  creatorId: runtypes_1.String,
31
- duration: exports.Duration.Or(runtypes_1.Null),
32
32
  }).And((0, runtypes_1.Partial)({
33
33
  due: exports.DueDate.Or(runtypes_1.Null),
34
+ duration: exports.Duration.Or(runtypes_1.Null),
34
35
  assigneeId: runtypes_1.String.Or(runtypes_1.Null),
35
36
  assignerId: runtypes_1.String.Or(runtypes_1.Null),
36
37
  parentId: runtypes_1.String.Or(runtypes_1.Null),
@@ -1,5 +1,5 @@
1
- import type { RequireAllOrNone } from 'type-fest';
2
- import type { Duration } from './entities';
1
+ import type { RequireAllOrNone, RequireOneOrNone, RequireExactlyOne } from 'type-fest';
2
+ import type { Duration, ProjectViewStyle } from './entities';
3
3
  export type AddTaskArgs = {
4
4
  content: string;
5
5
  description?: string;
@@ -9,12 +9,13 @@ export type AddTaskArgs = {
9
9
  order?: number;
10
10
  labels?: string[];
11
11
  priority?: number;
12
- dueString?: string;
13
12
  dueLang?: string;
13
+ assigneeId?: string;
14
+ dueString?: string;
15
+ } & RequireOneOrNone<{
14
16
  dueDate?: string;
15
17
  dueDatetime?: string;
16
- assigneeId?: string;
17
- } & RequireAllOrNone<{
18
+ }> & RequireAllOrNone<{
18
19
  duration?: Duration['amount'];
19
20
  durationUnit?: Duration['unit'];
20
21
  }>;
@@ -37,16 +38,16 @@ export type UpdateTaskArgs = {
37
38
  description?: string;
38
39
  labels?: string[];
39
40
  priority?: number;
40
- dueString?: string | null;
41
41
  dueLang?: string | null;
42
- dueDate?: string | null;
43
- dueDatetime?: string | null;
44
42
  assigneeId?: string | null;
45
- } & RequireAllOrNone<{
43
+ dueString?: string;
44
+ } & RequireOneOrNone<{
45
+ dueDate?: string;
46
+ dueDatetime?: string;
47
+ }> & RequireAllOrNone<{
46
48
  duration?: Duration['amount'];
47
49
  durationUnit?: Duration['unit'];
48
50
  }>;
49
- export type ProjectViewStyle = 'list' | 'board';
50
51
  export type AddProjectArgs = {
51
52
  name: string;
52
53
  parentId?: string;
@@ -88,7 +89,7 @@ export type GetProjectCommentsArgs = {
88
89
  projectId: string;
89
90
  taskId?: never;
90
91
  };
91
- type AddCommentArgs = {
92
+ export type AddCommentArgs = {
92
93
  content: string;
93
94
  attachment?: {
94
95
  fileName?: string;
@@ -96,18 +97,16 @@ type AddCommentArgs = {
96
97
  fileType?: string;
97
98
  resourceType?: string;
98
99
  };
99
- };
100
- export type AddTaskCommentArgs = AddCommentArgs & {
101
- taskId: string;
102
- projectId?: never;
103
- };
104
- export type AddProjectCommentArgs = AddCommentArgs & {
105
- projectId: string;
106
- taskId?: never;
107
- };
100
+ } & RequireExactlyOne<{
101
+ taskId?: string;
102
+ projectId?: string;
103
+ }>;
108
104
  export type UpdateCommentArgs = {
109
105
  content: string;
110
106
  };
107
+ export type GetSharedLabelsArgs = {
108
+ omitPersonal?: boolean;
109
+ };
111
110
  export type RenameSharedLabelArgs = {
112
111
  name: string;
113
112
  newName: string;
@@ -115,4 +114,3 @@ export type RenameSharedLabelArgs = {
115
114
  export type RemoveSharedLabelArgs = {
116
115
  name: string;
117
116
  };
118
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/todoist-api-typescript",
3
- "version": "2.2.0",
3
+ "version": "3.0.1",
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",