@doist/todoist-sdk 9.2.0-next.1 → 9.3.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 (66) hide show
  1. package/dist/cjs/clients/app-client.js +24 -25
  2. package/dist/cjs/clients/comment-client.js +3 -4
  3. package/dist/cjs/clients/folder-client.js +3 -4
  4. package/dist/cjs/clients/insights-client.js +6 -7
  5. package/dist/cjs/clients/label-client.js +3 -4
  6. package/dist/cjs/clients/project-client.js +8 -9
  7. package/dist/cjs/clients/section-client.js +5 -6
  8. package/dist/cjs/clients/task-client.js +6 -7
  9. package/dist/cjs/clients/ui-extension-client.js +4 -5
  10. package/dist/cjs/clients/workspace-client.js +3 -4
  11. package/dist/cjs/consts/endpoints.js +1 -6
  12. package/dist/cjs/test-utils/test-defaults.js +3 -26
  13. package/dist/cjs/todoist-api.js +0 -33
  14. package/dist/cjs/types/apps/types.js +1 -0
  15. package/dist/cjs/types/index.js +0 -1
  16. package/dist/cjs/types/sync/commands/index.js +0 -1
  17. package/dist/cjs/types/sync/resource-types.js +0 -1
  18. package/dist/cjs/types/sync/response.js +10 -12
  19. package/dist/cjs/utils/validators.js +57 -54
  20. package/dist/esm/clients/app-client.js +25 -26
  21. package/dist/esm/clients/comment-client.js +4 -5
  22. package/dist/esm/clients/folder-client.js +4 -5
  23. package/dist/esm/clients/insights-client.js +7 -8
  24. package/dist/esm/clients/label-client.js +4 -5
  25. package/dist/esm/clients/project-client.js +9 -10
  26. package/dist/esm/clients/section-client.js +6 -7
  27. package/dist/esm/clients/task-client.js +7 -8
  28. package/dist/esm/clients/ui-extension-client.js +5 -6
  29. package/dist/esm/clients/workspace-client.js +4 -5
  30. package/dist/esm/consts/endpoints.js +0 -5
  31. package/dist/esm/test-utils/test-defaults.js +1 -24
  32. package/dist/esm/todoist-api.js +0 -33
  33. package/dist/esm/types/apps/types.js +1 -0
  34. package/dist/esm/types/index.js +0 -1
  35. package/dist/esm/types/sync/commands/index.js +0 -1
  36. package/dist/esm/types/sync/resource-types.js +0 -1
  37. package/dist/esm/types/sync/response.js +0 -2
  38. package/dist/esm/utils/validators.js +5 -2
  39. package/dist/types/clients/app-client.d.ts +1 -1
  40. package/dist/types/consts/endpoints.d.ts +0 -5
  41. package/dist/types/test-utils/test-defaults.d.ts +1 -4
  42. package/dist/types/todoist-api.d.ts +0 -12
  43. package/dist/types/types/apps/types.d.ts +4 -0
  44. package/dist/types/types/index.d.ts +0 -1
  45. package/dist/types/types/sync/commands/index.d.ts +0 -9
  46. package/dist/types/types/sync/resource-types.d.ts +1 -1
  47. package/dist/types/types/sync/resources/view-options.d.ts +6 -6
  48. package/dist/types/types/sync/response.d.ts +4 -29
  49. package/dist/types/types/tasks/requests.d.ts +0 -1
  50. package/dist/types/utils/validators.d.ts +15 -55
  51. package/package.json +1 -1
  52. package/dist/cjs/clients/goals-client.js +0 -145
  53. package/dist/cjs/types/goals/index.js +0 -18
  54. package/dist/cjs/types/goals/requests.js +0 -2
  55. package/dist/cjs/types/goals/types.js +0 -56
  56. package/dist/cjs/types/sync/commands/goals.js +0 -2
  57. package/dist/esm/clients/goals-client.js +0 -141
  58. package/dist/esm/types/goals/index.js +0 -2
  59. package/dist/esm/types/goals/requests.js +0 -1
  60. package/dist/esm/types/goals/types.js +0 -53
  61. package/dist/esm/types/sync/commands/goals.js +0 -1
  62. package/dist/types/clients/goals-client.d.ts +0 -20
  63. package/dist/types/types/goals/index.d.ts +0 -2
  64. package/dist/types/types/goals/requests.d.ts +0 -33
  65. package/dist/types/types/goals/types.d.ts +0 -51
  66. package/dist/types/types/sync/commands/goals.d.ts +0 -33
@@ -1,141 +0,0 @@
1
- import { z } from 'zod';
2
- import { ENDPOINT_REST_GOALS, ENDPOINT_REST_GOALS_SEARCH, GOAL_COMPLETE, GOAL_TASKS, GOAL_UNCOMPLETE, } from '../consts/endpoints.js';
3
- import { isSuccess, request } from '../transport/http-client.js';
4
- import { generatePath } from '../utils/request-helpers.js';
5
- import { validateGoal, validateGoalArray } from '../utils/validators.js';
6
- import { BaseClient } from './base-client.js';
7
- /**
8
- * Internal sub-client handling all goal-domain endpoints.
9
- *
10
- * Instantiated by `TodoistApi`; every public goal method on `TodoistApi`
11
- * delegates here. See `todoist-api.ts` for the user-facing JSDoc.
12
- */
13
- export class GoalsClient extends BaseClient {
14
- async getGoals(args) {
15
- const { data: { results, nextCursor }, } = await request({
16
- httpMethod: 'GET',
17
- baseUri: this.syncApiBase,
18
- relativePath: ENDPOINT_REST_GOALS,
19
- apiToken: this.authToken,
20
- customFetch: this.customFetch,
21
- payload: args,
22
- });
23
- return {
24
- results: validateGoalArray(results),
25
- nextCursor,
26
- };
27
- }
28
- async searchGoals(args) {
29
- const { data: { results, nextCursor }, } = await request({
30
- httpMethod: 'GET',
31
- baseUri: this.syncApiBase,
32
- relativePath: ENDPOINT_REST_GOALS_SEARCH,
33
- apiToken: this.authToken,
34
- customFetch: this.customFetch,
35
- payload: args,
36
- });
37
- return {
38
- results: validateGoalArray(results),
39
- nextCursor,
40
- };
41
- }
42
- async getGoal(id) {
43
- z.string().parse(id);
44
- const response = await request({
45
- httpMethod: 'GET',
46
- baseUri: this.syncApiBase,
47
- relativePath: generatePath(ENDPOINT_REST_GOALS, id),
48
- apiToken: this.authToken,
49
- customFetch: this.customFetch,
50
- });
51
- return validateGoal(response.data);
52
- }
53
- async addGoal(args, requestId) {
54
- const response = await request({
55
- httpMethod: 'POST',
56
- baseUri: this.syncApiBase,
57
- relativePath: ENDPOINT_REST_GOALS,
58
- apiToken: this.authToken,
59
- customFetch: this.customFetch,
60
- payload: args,
61
- requestId: requestId,
62
- });
63
- return validateGoal(response.data);
64
- }
65
- async updateGoal(id, args, requestId) {
66
- z.string().parse(id);
67
- const response = await request({
68
- httpMethod: 'POST',
69
- baseUri: this.syncApiBase,
70
- relativePath: generatePath(ENDPOINT_REST_GOALS, id),
71
- apiToken: this.authToken,
72
- customFetch: this.customFetch,
73
- payload: args,
74
- requestId: requestId,
75
- });
76
- return validateGoal(response.data);
77
- }
78
- async deleteGoal(id, requestId) {
79
- z.string().parse(id);
80
- const response = await request({
81
- httpMethod: 'DELETE',
82
- baseUri: this.syncApiBase,
83
- relativePath: generatePath(ENDPOINT_REST_GOALS, id),
84
- apiToken: this.authToken,
85
- customFetch: this.customFetch,
86
- requestId: requestId,
87
- });
88
- return isSuccess(response);
89
- }
90
- async completeGoal(id, requestId) {
91
- z.string().parse(id);
92
- const response = await request({
93
- httpMethod: 'POST',
94
- baseUri: this.syncApiBase,
95
- relativePath: generatePath(ENDPOINT_REST_GOALS, id, GOAL_COMPLETE),
96
- apiToken: this.authToken,
97
- customFetch: this.customFetch,
98
- requestId: requestId,
99
- });
100
- return validateGoal(response.data);
101
- }
102
- async uncompleteGoal(id, requestId) {
103
- z.string().parse(id);
104
- const response = await request({
105
- httpMethod: 'POST',
106
- baseUri: this.syncApiBase,
107
- relativePath: generatePath(ENDPOINT_REST_GOALS, id, GOAL_UNCOMPLETE),
108
- apiToken: this.authToken,
109
- customFetch: this.customFetch,
110
- requestId: requestId,
111
- });
112
- return validateGoal(response.data);
113
- }
114
- async linkTaskToGoal({ goalId, taskId }, requestId) {
115
- z.string().parse(goalId);
116
- z.string().parse(taskId);
117
- const response = await request({
118
- httpMethod: 'POST',
119
- baseUri: this.syncApiBase,
120
- relativePath: generatePath(ENDPOINT_REST_GOALS, goalId, GOAL_TASKS),
121
- apiToken: this.authToken,
122
- customFetch: this.customFetch,
123
- payload: { itemId: taskId },
124
- requestId: requestId,
125
- });
126
- return validateGoal(response.data);
127
- }
128
- async unlinkTaskFromGoal({ goalId, taskId }, requestId) {
129
- z.string().parse(goalId);
130
- z.string().parse(taskId);
131
- const response = await request({
132
- httpMethod: 'DELETE',
133
- baseUri: this.syncApiBase,
134
- relativePath: generatePath(ENDPOINT_REST_GOALS, goalId, GOAL_TASKS, taskId),
135
- apiToken: this.authToken,
136
- customFetch: this.customFetch,
137
- requestId: requestId,
138
- });
139
- return isSuccess(response);
140
- }
141
- }
@@ -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,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';
@@ -1,33 +0,0 @@
1
- import type { SearchArgs } from '../common.js';
2
- import type { Workspace } from '../workspaces/index.js';
3
- import type { Goal, GoalOwnerType } from './types.js';
4
- export type GetGoalsArgs = {
5
- ownerType?: GoalOwnerType;
6
- workspaceId?: Workspace['id'];
7
- cursor?: string | null;
8
- limit?: number;
9
- };
10
- export type SearchGoalsArgs = SearchArgs & {
11
- ownerType?: GoalOwnerType;
12
- };
13
- export type GetGoalsResponse = {
14
- results: Goal[];
15
- nextCursor: string | null;
16
- };
17
- export type AddGoalArgs = {
18
- name: string;
19
- workspaceId?: string;
20
- description?: string | null;
21
- deadline?: string | null;
22
- responsibleUid?: string | null;
23
- };
24
- export type UpdateGoalArgs = {
25
- name?: string;
26
- description?: string | null;
27
- deadline?: string | null;
28
- responsibleUid?: string | null;
29
- };
30
- export type TaskLinkingArgs = {
31
- goalId: string;
32
- taskId: string;
33
- };
@@ -1,51 +0,0 @@
1
- import { z } from 'zod';
2
- /** Available goal owner types. */
3
- export declare const GOAL_OWNER_TYPES: readonly ["USER", "WORKSPACE"];
4
- /** Goal owner type. */
5
- export type GoalOwnerType = (typeof GOAL_OWNER_TYPES)[number];
6
- /**
7
- * Progress of a {@link Goal}.
8
- *
9
- * The REST API returns these counts under `total_item_count` / `completed_item_count`,
10
- * reflecting the backend's generic "item" terminology. The SDK normalizes them to
11
- * `totalTaskCount` / `completedTaskCount` so the public surface consistently speaks
12
- * in "tasks" (matching the rest of the SDK). The `preprocess` step below performs
13
- * that rename after the transport layer's snake_case → camelCase conversion — do not
14
- * remove it without also changing the downstream field names.
15
- */
16
- export declare const GoalProgressSchema: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
17
- totalTaskCount: z.ZodNumber;
18
- completedTaskCount: z.ZodNumber;
19
- percentage: z.ZodNumber;
20
- }, z.core.$loose>>;
21
- export type GoalProgress = z.infer<typeof GoalProgressSchema>;
22
- export declare const GoalSchema: z.ZodObject<{
23
- id: z.ZodString;
24
- ownerType: z.ZodEnum<{
25
- USER: "USER";
26
- WORKSPACE: "WORKSPACE";
27
- }>;
28
- ownerId: z.ZodString;
29
- name: z.ZodString;
30
- description: z.ZodNullable<z.ZodString>;
31
- deadline: z.ZodNullable<z.ZodString>;
32
- parentGoalId: z.ZodNullable<z.ZodString>;
33
- childOrder: z.ZodNumber;
34
- isCompleted: z.ZodBoolean;
35
- completedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
36
- responsibleUid: z.ZodNullable<z.ZodString>;
37
- isDeleted: z.ZodBoolean;
38
- progress: z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
39
- totalTaskCount: z.ZodNumber;
40
- completedTaskCount: z.ZodNumber;
41
- percentage: z.ZodNumber;
42
- }, z.core.$loose>>>;
43
- creatorUid: z.ZodString;
44
- createdAt: z.ZodCoercedDate<unknown>;
45
- updatedAt: z.ZodCoercedDate<unknown>;
46
- }, z.core.$loose>;
47
- /**
48
- * Represents a goal in Todoist.
49
- * Goals support dual ownership: personal (ownerType=USER) and workspace (ownerType=WORKSPACE).
50
- */
51
- export type Goal = z.infer<typeof GoalSchema>;
@@ -1,33 +0,0 @@
1
- import type { GoalOwnerType } from '../../goals/types.js';
2
- export type GoalAddArgs = {
3
- ownerType: GoalOwnerType;
4
- ownerId: string;
5
- name: string;
6
- description?: string | null;
7
- deadline?: string | null;
8
- responsibleUid?: string | null;
9
- };
10
- export type GoalUpdateArgs = {
11
- id: string;
12
- name?: string;
13
- description?: string | null;
14
- deadline?: string | null;
15
- responsibleUid?: string | null;
16
- };
17
- export type GoalCompleteArgs = {
18
- id: string;
19
- };
20
- export type GoalUncompleteArgs = {
21
- id: string;
22
- };
23
- export type GoalDeleteArgs = {
24
- id: string;
25
- };
26
- export type GoalLinkItemArgs = {
27
- goalId: string;
28
- itemId: string;
29
- };
30
- export type GoalUnlinkItemArgs = {
31
- goalId: string;
32
- itemId: string;
33
- };