ticktick-mcp 0.1.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.
@@ -0,0 +1,92 @@
1
+ /**
2
+ * TickTick SDK Error Classes
3
+ *
4
+ * Custom error classes for handling TickTick API errors.
5
+ */
6
+ import type { ApiErrorResponse } from "./types.js";
7
+ /**
8
+ * Base error class for all TickTick SDK errors.
9
+ */
10
+ export declare class TickTickError extends Error {
11
+ /** Error name for instanceof checks */
12
+ name: string;
13
+ constructor(message: string);
14
+ }
15
+ /**
16
+ * Error thrown when an API request fails.
17
+ * Contains HTTP status code and response details.
18
+ */
19
+ export declare class TickTickApiError extends TickTickError {
20
+ name: string;
21
+ /** HTTP status code */
22
+ readonly statusCode: number;
23
+ /** Error code from the API response */
24
+ readonly errorCode?: string;
25
+ /** Raw response body */
26
+ readonly responseBody?: ApiErrorResponse;
27
+ constructor(message: string, statusCode: number, errorCode?: string, responseBody?: ApiErrorResponse);
28
+ /**
29
+ * Create an error from an HTTP response.
30
+ */
31
+ static fromResponse(response: Response): Promise<TickTickApiError>;
32
+ }
33
+ /**
34
+ * Error thrown when authentication fails or the token is invalid/expired.
35
+ */
36
+ export declare class TickTickAuthError extends TickTickApiError {
37
+ name: string;
38
+ constructor(message: string, responseBody?: ApiErrorResponse);
39
+ }
40
+ /**
41
+ * Error thrown when the user doesn't have permission to access a resource.
42
+ */
43
+ export declare class TickTickForbiddenError extends TickTickApiError {
44
+ name: string;
45
+ constructor(message: string, responseBody?: ApiErrorResponse);
46
+ }
47
+ /**
48
+ * Error thrown when a requested resource is not found.
49
+ */
50
+ export declare class TickTickNotFoundError extends TickTickApiError {
51
+ name: string;
52
+ constructor(message: string, responseBody?: ApiErrorResponse);
53
+ }
54
+ /**
55
+ * Error thrown when rate limits are exceeded.
56
+ */
57
+ export declare class TickTickRateLimitError extends TickTickApiError {
58
+ name: string;
59
+ /** Time to wait before retrying (in seconds), if provided by the API */
60
+ readonly retryAfter?: number;
61
+ constructor(message: string, retryAfter?: number, responseBody?: ApiErrorResponse);
62
+ }
63
+ /**
64
+ * Error thrown when the request is invalid (bad parameters, etc.).
65
+ */
66
+ export declare class TickTickBadRequestError extends TickTickApiError {
67
+ name: string;
68
+ constructor(message: string, responseBody?: ApiErrorResponse);
69
+ }
70
+ /**
71
+ * Error thrown when a request times out.
72
+ */
73
+ export declare class TickTickTimeoutError extends TickTickError {
74
+ name: string;
75
+ /** The timeout duration that was exceeded (in milliseconds) */
76
+ readonly timeoutMs: number;
77
+ constructor(message: string, timeoutMs: number);
78
+ }
79
+ /**
80
+ * Error thrown when there's a network connectivity issue.
81
+ */
82
+ export declare class TickTickNetworkError extends TickTickError {
83
+ name: string;
84
+ /** The underlying error that caused the network failure */
85
+ readonly cause?: Error;
86
+ constructor(message: string, cause?: Error);
87
+ }
88
+ /**
89
+ * Create the appropriate error class based on HTTP status code.
90
+ */
91
+ export declare function createErrorFromResponse(response: Response): Promise<TickTickApiError>;
92
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/sdk/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,uCAAuC;IAC9B,IAAI,SAAmB;gBAEpB,OAAO,EAAE,MAAM;CAO5B;AAED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,aAAa;IACxC,IAAI,SAAsB;IAEnC,uBAAuB;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B,uCAAuC;IACvC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B,wBAAwB;IACxB,QAAQ,CAAC,YAAY,CAAC,EAAE,gBAAgB,CAAC;gBAGvC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,SA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AAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAI3C;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,gBAAgB,CAAC,CA4C3B"}
@@ -0,0 +1,187 @@
1
+ /**
2
+ * TickTick SDK Error Classes
3
+ *
4
+ * Custom error classes for handling TickTick API errors.
5
+ */
6
+ /**
7
+ * Base error class for all TickTick SDK errors.
8
+ */
9
+ export class TickTickError extends Error {
10
+ /** Error name for instanceof checks */
11
+ name = "TickTickError";
12
+ constructor(message) {
13
+ super(message);
14
+ // Maintains proper stack trace for where error was thrown (only in V8)
15
+ if (Error.captureStackTrace) {
16
+ Error.captureStackTrace(this, this.constructor);
17
+ }
18
+ }
19
+ }
20
+ /**
21
+ * Error thrown when an API request fails.
22
+ * Contains HTTP status code and response details.
23
+ */
24
+ export class TickTickApiError extends TickTickError {
25
+ name = "TickTickApiError";
26
+ /** HTTP status code */
27
+ statusCode;
28
+ /** Error code from the API response */
29
+ errorCode;
30
+ /** Raw response body */
31
+ responseBody;
32
+ constructor(message, statusCode, errorCode, responseBody) {
33
+ super(message);
34
+ this.statusCode = statusCode;
35
+ this.errorCode = errorCode;
36
+ this.responseBody = responseBody;
37
+ }
38
+ /**
39
+ * Create an error from an HTTP response.
40
+ */
41
+ static async fromResponse(response) {
42
+ let body;
43
+ let message = `HTTP ${response.status}: ${response.statusText}`;
44
+ let errorCode;
45
+ try {
46
+ const text = await response.text();
47
+ if (text) {
48
+ body = JSON.parse(text);
49
+ if (body.error_description) {
50
+ message = body.error_description;
51
+ }
52
+ else if (body.message) {
53
+ message = body.message;
54
+ }
55
+ else if (body.error) {
56
+ message = body.error;
57
+ }
58
+ errorCode = body.error;
59
+ }
60
+ }
61
+ catch {
62
+ // Failed to parse response body - use default message
63
+ }
64
+ return new TickTickApiError(message, response.status, errorCode, body);
65
+ }
66
+ }
67
+ /**
68
+ * Error thrown when authentication fails or the token is invalid/expired.
69
+ */
70
+ export class TickTickAuthError extends TickTickApiError {
71
+ name = "TickTickAuthError";
72
+ constructor(message, responseBody) {
73
+ super(message, 401, "unauthorized", responseBody);
74
+ }
75
+ }
76
+ /**
77
+ * Error thrown when the user doesn't have permission to access a resource.
78
+ */
79
+ export class TickTickForbiddenError extends TickTickApiError {
80
+ name = "TickTickForbiddenError";
81
+ constructor(message, responseBody) {
82
+ super(message, 403, "forbidden", responseBody);
83
+ }
84
+ }
85
+ /**
86
+ * Error thrown when a requested resource is not found.
87
+ */
88
+ export class TickTickNotFoundError extends TickTickApiError {
89
+ name = "TickTickNotFoundError";
90
+ constructor(message, responseBody) {
91
+ super(message, 404, "not_found", responseBody);
92
+ }
93
+ }
94
+ /**
95
+ * Error thrown when rate limits are exceeded.
96
+ */
97
+ export class TickTickRateLimitError extends TickTickApiError {
98
+ name = "TickTickRateLimitError";
99
+ /** Time to wait before retrying (in seconds), if provided by the API */
100
+ retryAfter;
101
+ constructor(message, retryAfter, responseBody) {
102
+ super(message, 429, "rate_limited", responseBody);
103
+ this.retryAfter = retryAfter;
104
+ }
105
+ }
106
+ /**
107
+ * Error thrown when the request is invalid (bad parameters, etc.).
108
+ */
109
+ export class TickTickBadRequestError extends TickTickApiError {
110
+ name = "TickTickBadRequestError";
111
+ constructor(message, responseBody) {
112
+ super(message, 400, "bad_request", responseBody);
113
+ }
114
+ }
115
+ /**
116
+ * Error thrown when a request times out.
117
+ */
118
+ export class TickTickTimeoutError extends TickTickError {
119
+ name = "TickTickTimeoutError";
120
+ /** The timeout duration that was exceeded (in milliseconds) */
121
+ timeoutMs;
122
+ constructor(message, timeoutMs) {
123
+ super(message);
124
+ this.timeoutMs = timeoutMs;
125
+ }
126
+ }
127
+ /**
128
+ * Error thrown when there's a network connectivity issue.
129
+ */
130
+ export class TickTickNetworkError extends TickTickError {
131
+ name = "TickTickNetworkError";
132
+ /** The underlying error that caused the network failure */
133
+ cause;
134
+ constructor(message, cause) {
135
+ super(message);
136
+ this.cause = cause;
137
+ }
138
+ }
139
+ /**
140
+ * Create the appropriate error class based on HTTP status code.
141
+ */
142
+ export async function createErrorFromResponse(response) {
143
+ let body;
144
+ let message = `HTTP ${response.status}: ${response.statusText}`;
145
+ let retryAfter;
146
+ try {
147
+ const text = await response.text();
148
+ if (text) {
149
+ body = JSON.parse(text);
150
+ if (body.error_description) {
151
+ message = body.error_description;
152
+ }
153
+ else if (body.message) {
154
+ message = body.message;
155
+ }
156
+ else if (body.error) {
157
+ message = body.error;
158
+ }
159
+ }
160
+ }
161
+ catch {
162
+ // Failed to parse response body - use default message
163
+ }
164
+ // Try to get retry-after header for rate limit errors
165
+ const retryAfterHeader = response.headers.get("retry-after");
166
+ if (retryAfterHeader) {
167
+ retryAfter = parseInt(retryAfterHeader, 10);
168
+ if (isNaN(retryAfter)) {
169
+ retryAfter = undefined;
170
+ }
171
+ }
172
+ switch (response.status) {
173
+ case 400:
174
+ return new TickTickBadRequestError(message, body);
175
+ case 401:
176
+ return new TickTickAuthError(message, body);
177
+ case 403:
178
+ return new TickTickForbiddenError(message, body);
179
+ case 404:
180
+ return new TickTickNotFoundError(message, body);
181
+ case 429:
182
+ return new TickTickRateLimitError(message, retryAfter, body);
183
+ default:
184
+ return new TickTickApiError(message, response.status, body?.error, body);
185
+ }
186
+ }
187
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/sdk/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,uCAAuC;IAC9B,IAAI,GAAG,eAAe,CAAC;IAEhC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,uEAAuE;QACvE,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC;IACH,C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sD;IACtD,MAAM,gBAAgB,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC7D,IAAI,gBAAgB,EAAE,CAAC;QACrB,UAAU,GAAG,QAAQ,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;QAC5C,IAAI,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;YACtB,UAAU,GAAG,SAAS,CAAC;QACzB,CAAC;IACH,CAAC;IAED,QAAQ,QAAQ,CAAC,MAAM,EAAE,CAAC;QACxB,KAAK,GAAG;YACN,OAAO,IAAI,uBAAuB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACpD,KAAK,GAAG;YACN,OAAO,IAAI,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC9C,KAAK,GAAG;YACN,OAAO,IAAI,sBAAsB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACnD,KAAK,GAAG;YACN,OAAO,IAAI,qBAAqB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAClD,KAAK,GAAG;YACN,OAAO,IAAI,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;QAC/D;YACE,OAAO,IAAI,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * TickTick SDK
3
+ *
4
+ * A TypeScript SDK for interacting with the TickTick Open API.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { TickTickClient, Priority, Status } from './sdk';
9
+ *
10
+ * const client = new TickTickClient({
11
+ * accessToken: 'your-oauth-access-token',
12
+ * region: 'global',
13
+ * });
14
+ *
15
+ * // Get user info
16
+ * const user = await client.getUser();
17
+ *
18
+ * // List projects
19
+ * const projects = await client.listProjects();
20
+ *
21
+ * // Create a task
22
+ * const task = await client.createTask({
23
+ * title: 'My task',
24
+ * projectId: projects[0].id,
25
+ * priority: Priority.High,
26
+ * });
27
+ *
28
+ * // Complete the task
29
+ * await client.completeTask(task.projectId, task.id);
30
+ * ```
31
+ *
32
+ * @packageDocumentation
33
+ */
34
+ export { TickTickClient } from "./client.js";
35
+ export type { User, Project, CreateProjectInput, UpdateProjectInput, ProjectWithTasks, Task, CreateTaskInput, UpdateTaskInput, BatchCreateTasksInput, ChecklistItem, ChecklistItemInput, TokenResponse, OAuthError, TickTickClientConfig, Region, ViewMode, ProjectKind, TaskKind, ApiErrorResponse, } from "./types.js";
36
+ export { Priority, Status } from "./types.js";
37
+ export { TickTickError, TickTickApiError, TickTickAuthError, TickTickForbiddenError, TickTickNotFoundError, TickTickRateLimitError, TickTickBadRequestError, TickTickTimeoutError, TickTickNetworkError, createErrorFromResponse, } from "./errors.js";
38
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAMH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAM7C,YAAY,EAEV,IAAI,EAGJ,OAAO,EACP,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAGhB,IAAI,EACJ,eAAe,EACf,eAAe,EACf,qBAAqB,EAGrB,aAAa,EACb,kBAAkB,EAGlB,aAAa,EACb,UAAU,EAGV,oBAAoB,EACpB,MAAM,EACN,QAAQ,EACR,WAAW,EACX,QAAQ,EAGR,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAM9C,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * TickTick SDK
3
+ *
4
+ * A TypeScript SDK for interacting with the TickTick Open API.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { TickTickClient, Priority, Status } from './sdk';
9
+ *
10
+ * const client = new TickTickClient({
11
+ * accessToken: 'your-oauth-access-token',
12
+ * region: 'global',
13
+ * });
14
+ *
15
+ * // Get user info
16
+ * const user = await client.getUser();
17
+ *
18
+ * // List projects
19
+ * const projects = await client.listProjects();
20
+ *
21
+ * // Create a task
22
+ * const task = await client.createTask({
23
+ * title: 'My task',
24
+ * projectId: projects[0].id,
25
+ * priority: Priority.High,
26
+ * });
27
+ *
28
+ * // Complete the task
29
+ * await client.completeTask(task.projectId, task.id);
30
+ * ```
31
+ *
32
+ * @packageDocumentation
33
+ */
34
+ // =============================================================================
35
+ // Client
36
+ // =============================================================================
37
+ export { TickTickClient } from "./client.js";
38
+ // =============================================================================
39
+ // Enums
40
+ // =============================================================================
41
+ export { Priority, Status } from "./types.js";
42
+ // =============================================================================
43
+ // Error Classes
44
+ // =============================================================================
45
+ export { TickTickError, TickTickApiError, TickTickAuthError, TickTickForbiddenError, TickTickNotFoundError, TickTickRateLimitError, TickTickBadRequestError, TickTickTimeoutError, TickTickNetworkError, createErrorFromResponse, } from "./errors.js";
46
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,gFAAgF;AAChF,SAAS;AACT,gFAAgF;AAEhF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAyC7C,gFAAgF;AAChF,QAAQ;AACR,gFAAgF;AAEhF,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAE9C,gFAAgF;AAChF,gBAAgB;AAChB,gFAAgF;AAEhF,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,308 @@
1
+ /**
2
+ * TickTick SDK Types
3
+ *
4
+ * TypeScript interfaces and types for the TickTick API.
5
+ * Based on the official TickTick Open API documentation.
6
+ */
7
+ /**
8
+ * Task priority levels.
9
+ */
10
+ export declare enum Priority {
11
+ None = 0,
12
+ Low = 1,
13
+ Medium = 3,
14
+ High = 5
15
+ }
16
+ /**
17
+ * Task/checklist item status.
18
+ */
19
+ export declare enum Status {
20
+ Normal = 0,
21
+ Completed = 1
22
+ }
23
+ /**
24
+ * Project view modes.
25
+ */
26
+ export type ViewMode = "list" | "kanban" | "timeline";
27
+ /**
28
+ * Project/task kind.
29
+ */
30
+ export type ProjectKind = "TASK" | "NOTE";
31
+ /**
32
+ * Task kind.
33
+ */
34
+ export type TaskKind = "TEXT";
35
+ /**
36
+ * API region configuration.
37
+ */
38
+ export type Region = "global" | "china";
39
+ /**
40
+ * TickTick user information.
41
+ */
42
+ export interface User {
43
+ /** Unique user identifier */
44
+ id: string;
45
+ /** User's email/username */
46
+ username: string;
47
+ /** User's display name */
48
+ name: string;
49
+ }
50
+ /**
51
+ * A subtask/checklist item within a task.
52
+ */
53
+ export interface ChecklistItem {
54
+ /** Unique item identifier */
55
+ id: string;
56
+ /** Item text/title */
57
+ title: string;
58
+ /** Item status: 0 = unchecked, 1 = checked */
59
+ status: Status;
60
+ /** When the item was completed (ISO 8601) */
61
+ completedTime: string | null;
62
+ /** Whether this has an all-day date */
63
+ isAllDay: boolean;
64
+ /** Start date (ISO 8601) */
65
+ startDate: string | null;
66
+ /** Timezone (IANA format) */
67
+ timeZone: string;
68
+ /** Position in the checklist */
69
+ sortOrder: number;
70
+ }
71
+ /**
72
+ * Input for creating a checklist item.
73
+ */
74
+ export interface ChecklistItemInput {
75
+ /** Item text/title */
76
+ title: string;
77
+ /** Item status: 0 = unchecked, 1 = checked */
78
+ status?: Status;
79
+ /** Whether this has an all-day date */
80
+ isAllDay?: boolean;
81
+ /** Start date (ISO 8601) */
82
+ startDate?: string | null;
83
+ /** Timezone (IANA format) */
84
+ timeZone?: string;
85
+ /** Position in the checklist */
86
+ sortOrder?: number;
87
+ }
88
+ /**
89
+ * Complete Task object as returned by the API.
90
+ */
91
+ export interface Task {
92
+ /** Unique task identifier */
93
+ id: string;
94
+ /** ID of the parent project */
95
+ projectId: string;
96
+ /** Task title */
97
+ title: string;
98
+ /** Task description/notes */
99
+ content: string;
100
+ /** Additional description */
101
+ desc: string;
102
+ /** Whether this is an all-day task */
103
+ allDay: boolean;
104
+ /** Start date (ISO 8601) */
105
+ startDate: string | null;
106
+ /** Due date (ISO 8601) */
107
+ dueDate: string | null;
108
+ /** IANA timezone */
109
+ timeZone: string;
110
+ /** Whether the date is timezone-independent */
111
+ isFloating: boolean;
112
+ /** Array of reminders (iCalendar TRIGGER format) */
113
+ reminders: string[];
114
+ /** Recurrence rule (RRULE format) */
115
+ repeat: string;
116
+ /** Priority: 0=None, 1=Low, 3=Medium, 5=High */
117
+ priority: Priority;
118
+ /** Status: 0=Normal, 1=Completed */
119
+ status: Status;
120
+ /** When task was completed (ISO 8601) */
121
+ completedTime: string | null;
122
+ /** Position in list */
123
+ sortOrder: number;
124
+ /** Array of tag names */
125
+ tags: string[];
126
+ /** Array of subtasks/checklist items */
127
+ items: ChecklistItem[];
128
+ /** Last modification timestamp (ISO 8601) */
129
+ modifiedTime: string;
130
+ /** Creation timestamp (ISO 8601) */
131
+ createdTime: string;
132
+ /** Version identifier for sync */
133
+ etag: string;
134
+ /** Deletion flag (0=not deleted) */
135
+ deleted: number;
136
+ /** User ID of creator */
137
+ creator: number;
138
+ /** Task type */
139
+ kind: TaskKind;
140
+ }
141
+ /**
142
+ * Input for creating a new task.
143
+ */
144
+ export interface CreateTaskInput {
145
+ /** Task title (required) */
146
+ title: string;
147
+ /** Project ID (defaults to inbox if not specified) */
148
+ projectId?: string;
149
+ /** Task description/notes */
150
+ content?: string;
151
+ /** Whether this is an all-day task */
152
+ allDay?: boolean;
153
+ /** Start date (ISO 8601: yyyy-MM-dd'T'HH:mm:ssZ) */
154
+ startDate?: string;
155
+ /** Due date (ISO 8601: yyyy-MM-dd'T'HH:mm:ssZ) */
156
+ dueDate?: string;
157
+ /** IANA timezone (e.g., "America/New_York") */
158
+ timeZone?: string;
159
+ /** Array of reminders in iCalendar TRIGGER format */
160
+ reminders?: string[];
161
+ /** Recurrence rule in RRULE format */
162
+ repeat?: string;
163
+ /** Priority: 0=None, 1=Low, 3=Medium, 5=High */
164
+ priority?: Priority;
165
+ /** Array of subtask/checklist items */
166
+ items?: ChecklistItemInput[];
167
+ }
168
+ /**
169
+ * Input for updating an existing task.
170
+ * All fields are optional - only include fields you want to update.
171
+ */
172
+ export interface UpdateTaskInput {
173
+ /** Task title */
174
+ title?: string;
175
+ /** Project ID (to move task to another project) */
176
+ projectId?: string;
177
+ /** Task description/notes */
178
+ content?: string;
179
+ /** Whether this is an all-day task */
180
+ allDay?: boolean;
181
+ /** Start date (ISO 8601) */
182
+ startDate?: string | null;
183
+ /** Due date (ISO 8601) */
184
+ dueDate?: string | null;
185
+ /** IANA timezone */
186
+ timeZone?: string;
187
+ /** Array of reminders in iCalendar TRIGGER format */
188
+ reminders?: string[];
189
+ /** Recurrence rule in RRULE format */
190
+ repeat?: string;
191
+ /** Priority: 0=None, 1=Low, 3=Medium, 5=High */
192
+ priority?: Priority;
193
+ /** Array of subtask/checklist items */
194
+ items?: ChecklistItemInput[];
195
+ /** Array of tag names */
196
+ tags?: string[];
197
+ }
198
+ /**
199
+ * Complete Project object as returned by the API.
200
+ */
201
+ export interface Project {
202
+ /** Unique project identifier */
203
+ id: string;
204
+ /** Project name */
205
+ name: string;
206
+ /** Hex color code (e.g., "#ff6b6b") */
207
+ color: string;
208
+ /** Position in project list */
209
+ sortOrder: number;
210
+ /** Whether project is archived */
211
+ closed: boolean;
212
+ /** Parent folder ID */
213
+ groupId: string | null;
214
+ /** View mode: "list", "kanban", or "timeline" */
215
+ viewMode: ViewMode;
216
+ /** Project type: "TASK" or "NOTE" */
217
+ kind: ProjectKind;
218
+ }
219
+ /**
220
+ * Input for creating a new project.
221
+ */
222
+ export interface CreateProjectInput {
223
+ /** Project name (required) */
224
+ name: string;
225
+ /** Hex color code (e.g., "#ff6b6b") */
226
+ color?: string;
227
+ /** View mode: "list", "kanban", or "timeline" */
228
+ viewMode?: ViewMode;
229
+ /** Project type: "TASK" or "NOTE" */
230
+ kind?: ProjectKind;
231
+ }
232
+ /**
233
+ * Input for updating an existing project.
234
+ * All fields are optional - only include fields you want to update.
235
+ */
236
+ export interface UpdateProjectInput {
237
+ /** Project name */
238
+ name?: string;
239
+ /** Hex color code */
240
+ color?: string;
241
+ /** View mode */
242
+ viewMode?: ViewMode;
243
+ /** Project type */
244
+ kind?: ProjectKind;
245
+ }
246
+ /**
247
+ * Project data including all tasks.
248
+ */
249
+ export interface ProjectWithTasks {
250
+ /** The project */
251
+ project: Project;
252
+ /** All tasks in the project */
253
+ tasks: Task[];
254
+ }
255
+ /**
256
+ * Input for batch creating tasks.
257
+ */
258
+ export interface BatchCreateTasksInput {
259
+ /** Array of tasks to create */
260
+ add: CreateTaskInput[];
261
+ }
262
+ /**
263
+ * OAuth token response from the token endpoint.
264
+ */
265
+ export interface TokenResponse {
266
+ /** The access token for API requests */
267
+ access_token: string;
268
+ /** Token type (typically "bearer") */
269
+ token_type: string;
270
+ /** Token expiration time in seconds */
271
+ expires_in: number;
272
+ /** Refresh token for obtaining new access tokens */
273
+ refresh_token: string;
274
+ }
275
+ /**
276
+ * OAuth error response.
277
+ */
278
+ export interface OAuthError {
279
+ /** Error code */
280
+ error: string;
281
+ /** Human-readable error description */
282
+ error_description: string;
283
+ }
284
+ /**
285
+ * Configuration options for the TickTick SDK client.
286
+ */
287
+ export interface TickTickClientConfig {
288
+ /** OAuth access token */
289
+ accessToken: string;
290
+ /** API region: "global" (ticktick.com) or "china" (dida365.com) */
291
+ region?: Region;
292
+ /** Optional custom base URL (overrides region setting) */
293
+ baseUrl?: string;
294
+ /** Request timeout in milliseconds (default: 30000) */
295
+ timeout?: number;
296
+ }
297
+ /**
298
+ * Generic API error response structure.
299
+ */
300
+ export interface ApiErrorResponse {
301
+ /** Error code or type */
302
+ error?: string;
303
+ /** Error message */
304
+ message?: string;
305
+ /** Detailed error description */
306
+ error_description?: string;
307
+ }
308
+ //# sourceMappingURL=types.d.ts.map