@doist/todoist-sdk 10.5.0 → 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.
- package/dist/cjs/consts/endpoints.js +1 -6
- package/dist/cjs/test-utils/test-defaults.js +2 -26
- package/dist/cjs/test-utils/transport-seam.js +17 -0
- package/dist/cjs/test-utils/webhook-fixtures.js +1 -1
- package/dist/cjs/todoist-api.js +0 -101
- package/dist/cjs/transport/fetch-with-retry.js +19 -7
- package/dist/cjs/transport/http-dispatcher.js +60 -15
- package/dist/cjs/types/index.js +0 -1
- package/dist/cjs/types/sync/commands/index.js +0 -2
- package/dist/cjs/types/sync/resource-types.js +0 -2
- package/dist/cjs/types/sync/resources/index.js +0 -1
- package/dist/cjs/types/sync/response.js +10 -13
- package/dist/cjs/utils/validators.js +50 -54
- package/dist/esm/consts/endpoints.js +0 -5
- package/dist/esm/test-utils/test-defaults.js +0 -24
- package/dist/esm/test-utils/transport-seam.js +15 -0
- package/dist/esm/test-utils/webhook-fixtures.js +1 -1
- package/dist/esm/todoist-api.js +0 -101
- package/dist/esm/transport/fetch-with-retry.js +20 -8
- package/dist/esm/transport/http-dispatcher.js +58 -15
- package/dist/esm/types/index.js +0 -1
- package/dist/esm/types/sync/commands/index.js +0 -2
- package/dist/esm/types/sync/resource-types.js +0 -2
- package/dist/esm/types/sync/resources/index.js +0 -1
- package/dist/esm/types/sync/response.js +1 -4
- package/dist/esm/utils/validators.js +1 -4
- package/dist/types/consts/endpoints.d.ts +0 -5
- package/dist/types/test-utils/test-defaults.d.ts +1 -4
- package/dist/types/todoist-api.d.ts +0 -80
- package/dist/types/transport/http-dispatcher.d.ts +36 -0
- package/dist/types/types/index.d.ts +0 -1
- package/dist/types/types/sync/commands/index.d.ts +0 -16
- package/dist/types/types/sync/resource-types.d.ts +1 -1
- package/dist/types/types/sync/resources/index.d.ts +0 -1
- package/dist/types/types/sync/resources/view-options.d.ts +6 -6
- package/dist/types/types/sync/response.d.ts +4 -45
- package/dist/types/types/tasks/requests.d.ts +0 -1
- package/dist/types/utils/validators.d.ts +8 -90
- package/package.json +1 -1
- package/dist/cjs/clients/goals-client.js +0 -144
- package/dist/cjs/types/goals/index.js +0 -18
- package/dist/cjs/types/goals/requests.js +0 -2
- package/dist/cjs/types/goals/types.js +0 -56
- package/dist/cjs/types/sync/commands/goals.js +0 -2
- package/dist/cjs/types/sync/commands/workspace-goals.js +0 -2
- package/dist/cjs/types/sync/resources/workspace-goals.js +0 -26
- package/dist/esm/clients/goals-client.js +0 -140
- package/dist/esm/types/goals/index.js +0 -2
- package/dist/esm/types/goals/types.js +0 -53
- package/dist/esm/types/sync/commands/goals.js +0 -1
- package/dist/esm/types/sync/commands/workspace-goals.js +0 -1
- package/dist/esm/types/sync/resources/workspace-goals.js +0 -23
- package/dist/types/clients/goals-client.d.ts +0 -20
- package/dist/types/types/goals/index.d.ts +0 -2
- package/dist/types/types/goals/requests.d.ts +0 -33
- package/dist/types/types/goals/types.d.ts +0 -51
- package/dist/types/types/sync/commands/goals.d.ts +0 -33
- package/dist/types/types/sync/commands/workspace-goals.d.ts +0 -24
- package/dist/types/types/sync/resources/workspace-goals.d.ts +0 -29
- /package/dist/{esm/types/goals/requests.js → types/test-utils/transport-seam.d.ts} +0 -0
|
@@ -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,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,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,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,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
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export type WorkspaceGoalAddArgs = {
|
|
2
|
-
workspaceId: string;
|
|
3
|
-
title: string;
|
|
4
|
-
description?: string;
|
|
5
|
-
deadline?: string | null;
|
|
6
|
-
projectIds: string[];
|
|
7
|
-
};
|
|
8
|
-
export type WorkspaceGoalUpdateArgs = {
|
|
9
|
-
id: string;
|
|
10
|
-
title?: string;
|
|
11
|
-
description?: string;
|
|
12
|
-
deadline?: string | null;
|
|
13
|
-
};
|
|
14
|
-
export type WorkspaceGoalDeleteArgs = {
|
|
15
|
-
id: string;
|
|
16
|
-
};
|
|
17
|
-
export type WorkspaceGoalProjectAddArgs = {
|
|
18
|
-
goalId: string;
|
|
19
|
-
projectId: string;
|
|
20
|
-
};
|
|
21
|
-
export type WorkspaceGoalProjectRemoveArgs = {
|
|
22
|
-
goalId: string;
|
|
23
|
-
projectId: string;
|
|
24
|
-
};
|