@perrylink/dsh-ticktick 0.1.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE +201 -0
  3. package/README.es.md +41 -0
  4. package/README.hi.md +33 -0
  5. package/README.md +111 -0
  6. package/README.pt.md +41 -0
  7. package/README.zh.md +111 -0
  8. package/cordis.patch.yml +35 -0
  9. package/lib/client.js +6233 -0
  10. package/lib/client.js.map +1 -0
  11. package/lib/index.js +1349 -0
  12. package/lib/typert.host.js +26 -0
  13. package/lib/types/client/TicktickAction.d.ts +29 -0
  14. package/lib/types/client/TicktickAction.d.ts.map +1 -0
  15. package/lib/types/client/TicktickSettingsCard.d.ts +27 -0
  16. package/lib/types/client/TicktickSettingsCard.d.ts.map +1 -0
  17. package/lib/types/client/api.d.ts +34 -0
  18. package/lib/types/client/api.d.ts.map +1 -0
  19. package/lib/types/client/dates.d.ts +26 -0
  20. package/lib/types/client/dates.d.ts.map +1 -0
  21. package/lib/types/client/index.d.ts +34 -0
  22. package/lib/types/client/index.d.ts.map +1 -0
  23. package/lib/types/client/locales.d.ts +61 -0
  24. package/lib/types/client/locales.d.ts.map +1 -0
  25. package/lib/types/client/order.d.ts +25 -0
  26. package/lib/types/client/order.d.ts.map +1 -0
  27. package/lib/types/client/remote.d.ts +260 -0
  28. package/lib/types/client/remote.d.ts.map +1 -0
  29. package/lib/types/client/styles.d.ts +13 -0
  30. package/lib/types/client/styles.d.ts.map +1 -0
  31. package/lib/types/config.d.ts +64 -0
  32. package/lib/types/config.d.ts.map +1 -0
  33. package/lib/types/domain.d.ts +70 -0
  34. package/lib/types/domain.d.ts.map +1 -0
  35. package/lib/types/index.d.ts +56 -0
  36. package/lib/types/index.d.ts.map +1 -0
  37. package/lib/types/mcp.d.ts +94 -0
  38. package/lib/types/mcp.d.ts.map +1 -0
  39. package/lib/types/service.d.ts +160 -0
  40. package/lib/types/service.d.ts.map +1 -0
  41. package/lib/types/tools.d.ts +18 -0
  42. package/lib/types/tools.d.ts.map +1 -0
  43. package/lib/types/typert.host.d.ts +216 -0
  44. package/lib/types/typert.host.d.ts.map +1 -0
  45. package/lib/types/wire.d.ts +561 -0
  46. package/lib/types/wire.d.ts.map +1 -0
  47. package/lib/wire-C-vDxxnC.js +5288 -0
  48. package/package.json +187 -0
  49. package/probes/lib.mjs +65 -0
  50. package/probes/probe-bootstrap.mjs +10 -0
  51. package/probes/probe-crud.mjs +15 -0
  52. package/probes/probe-due.mjs +28 -0
  53. package/probes/probe-queries.mjs +18 -0
  54. package/probes/probe-reorder.mjs +24 -0
  55. package/src/client/TicktickAction.tsx +356 -0
  56. package/src/client/TicktickSettingsCard.tsx +182 -0
  57. package/src/client/api.ts +56 -0
  58. package/src/client/dates.ts +61 -0
  59. package/src/client/index.ts +119 -0
  60. package/src/client/locales.ts +113 -0
  61. package/src/client/order.ts +37 -0
  62. package/src/client/remote.ts +76 -0
  63. package/src/client/styles.ts +48 -0
  64. package/src/config.ts +136 -0
  65. package/src/domain.ts +224 -0
  66. package/src/index.ts +139 -0
  67. package/src/mcp.ts +213 -0
  68. package/src/service.ts +403 -0
  69. package/src/tools.ts +336 -0
  70. package/src/typert.host.ts +25 -0
  71. package/src/wire.ts +401 -0
package/src/wire.ts ADDED
@@ -0,0 +1,401 @@
1
+ /**
2
+ * The TickTick bridge's wire vocabulary: the result types served over the
3
+ * `ticktick` Remote namespace, their zod v4 validation schema (the strict
4
+ * codec both Typert faces carry), and the invocation descriptors shared
5
+ * verbatim by the host `./typert` manifest (`src/typert.host.ts`) and the
6
+ * client Remote contribution (`src/client/remote.ts`). One canonical source
7
+ * for both faces keeps the host and client codecs from ever drifting apart.
8
+ *
9
+ * @module dsh-ticktick/wire
10
+ */
11
+
12
+ import { z } from 'zod'
13
+ import type { InvocationDescriptor } from '@deepseek-ai/dsh-typert-protocol'
14
+
15
+ /** Connection and configuration facts the panel and `ticktick_status` read. */
16
+ export interface TicktickStatus {
17
+ /** A Bearer token is currently resolvable (file or settings). */
18
+ configured: boolean
19
+ /** The MCP client finished its initialize handshake. */
20
+ connected: boolean
21
+ /** Active MCP endpoint. */
22
+ mcpUrl: string
23
+ /** Most recent bridge error, sanitized for display; `null` when none. */
24
+ lastError: string | null
25
+ /** Resolved raw tool names (`''` = unresolved). */
26
+ toolNames: {
27
+ projects: string
28
+ tasks: string
29
+ create: string
30
+ complete: string
31
+ remove: string
32
+ update: string
33
+ move: string
34
+ }
35
+ }
36
+
37
+ /** Strict wire schema for {@link TicktickStatus}. */
38
+ export const TICKTICK_STATUS_SCHEMA = z.object({
39
+ configured: z.boolean(),
40
+ connected: z.boolean(),
41
+ mcpUrl: z.string(),
42
+ lastError: z.string().nullable(),
43
+ toolNames: z.object({
44
+ projects: z.string(),
45
+ tasks: z.string(),
46
+ create: z.string(),
47
+ complete: z.string(),
48
+ remove: z.string(),
49
+ update: z.string(),
50
+ move: z.string(),
51
+ }),
52
+ })
53
+
54
+ /** One project (list) as the widget renders it. */
55
+ export interface TicktickProjectWire {
56
+ id: string
57
+ name: string
58
+ }
59
+
60
+ /** One task as the widget renders it. */
61
+ export interface TicktickTaskWire {
62
+ id: string
63
+ title: string
64
+ done: boolean
65
+ /** Owning project id, or `null` when the server did not carry one. */
66
+ projectId: string | null
67
+ /** ISO due date, or `null` when the task has none. */
68
+ dueDate: string | null
69
+ /** TickTick sort order, or `null` when absent. */
70
+ sortOrder: number | null
71
+ }
72
+
73
+ /** Aggregated undone tasks plus per-list warnings. */
74
+ export interface TicktickTasksResult {
75
+ tasks: readonly TicktickTaskWire[]
76
+ warnings: readonly string[]
77
+ }
78
+
79
+ /** Strict wire schema for {@link TicktickTasksResult}. */
80
+ export const TICKTICK_TASKS_RESULT_SCHEMA = z.object({
81
+ tasks: z.array(z.object({
82
+ id: z.string(),
83
+ title: z.string(),
84
+ done: z.boolean(),
85
+ projectId: z.string().nullable(),
86
+ dueDate: z.string().nullable(),
87
+ sortOrder: z.number().int().nullable(),
88
+ })),
89
+ warnings: z.array(z.string()),
90
+ })
91
+
92
+ /** One created task reference, plus the P2 read-after-write verification. */
93
+ export interface TicktickAddResult {
94
+ task: TicktickTaskWire | null
95
+ /** Read-back warning; `null` when the creation verified clean or no lookup tool exists. */
96
+ verifyWarning: string | null
97
+ }
98
+
99
+ /** Strict wire schema for {@link TicktickAddResult}. */
100
+ export const TICKTICK_ADD_RESULT_SCHEMA = z.object({
101
+ task: z.object({
102
+ id: z.string(),
103
+ title: z.string(),
104
+ done: z.boolean(),
105
+ projectId: z.string().nullable(),
106
+ dueDate: z.string().nullable(),
107
+ sortOrder: z.number().int().nullable(),
108
+ }).nullable(),
109
+ verifyWarning: z.string().nullable(),
110
+ })
111
+
112
+ /** One row of the P2 batch-add payload. */
113
+ export const BATCH_ADD_TASK_SCHEMA = z.object({
114
+ title: z.string(),
115
+ projectId: z.string().optional(),
116
+ dueDate: z.string().optional(),
117
+ })
118
+
119
+ /** Strict wire schema for the `ticktick/batchAdd` result. */
120
+ export const BATCH_ADD_RESULT_SCHEMA = z.object({
121
+ created: z.number().int(),
122
+ })
123
+
124
+ /** One-shot connectivity probe result (settings card test button). */
125
+ export interface TicktickProbeResult {
126
+ ok: boolean
127
+ toolCount: number
128
+ error: string | null
129
+ }
130
+
131
+ /** Strict wire schema for {@link TicktickProbeResult}. */
132
+ export const TICKTICK_PROBE_RESULT_SCHEMA = z.object({
133
+ ok: z.boolean(),
134
+ toolCount: z.number().int(),
135
+ error: z.string().nullable(),
136
+ })
137
+
138
+ /** One accepted mutation. */
139
+ export interface TicktickOkResult {
140
+ ok: boolean
141
+ }
142
+
143
+ /** Strict wire schema for {@link TicktickOkResult}. */
144
+ export const TICKTICK_OK_RESULT_SCHEMA = z.object({
145
+ ok: z.boolean(),
146
+ })
147
+
148
+ /** Settings namespace the browser card edits (paired by this exact key, both faces). */
149
+ export const TICKTICK_SETTINGS_NS = 'ticktick'
150
+
151
+ /**
152
+ * Settings the card owns: token (secret) and token file are live; the
153
+ * endpoint and protected ids apply on restart. Declared here (shared
154
+ * vocabulary) so the client card types against it without importing the
155
+ * Host module.
156
+ */
157
+ export interface TicktickSettings {
158
+ token: string
159
+ tokenFile: string
160
+ mcpUrl: string
161
+ protectedTaskIds: string[]
162
+ }
163
+
164
+ /** Parameter codec helper: one JSON-sourced string parameter. */
165
+ function stringParam(name: string, typeSymbol: string, acceptsUndefined = false): InvocationDescriptor['parameters'][number] {
166
+ return Object.freeze({
167
+ name,
168
+ wire: name,
169
+ source: 'json' as const,
170
+ ...(acceptsUndefined ? { acceptsUndefined: true } : {}),
171
+ codec: Object.freeze({
172
+ mode: 'strict' as const,
173
+ typeSymbol,
174
+ schema: z.string(),
175
+ }),
176
+ })
177
+ }
178
+
179
+ /** Parameter codec helper: one JSON-sourced number parameter. */
180
+ function numberParam(name: string, typeSymbol: string, acceptsUndefined = false): InvocationDescriptor['parameters'][number] {
181
+ return Object.freeze({
182
+ name,
183
+ wire: name,
184
+ source: 'json' as const,
185
+ ...(acceptsUndefined ? { acceptsUndefined: true } : {}),
186
+ codec: Object.freeze({
187
+ mode: 'strict' as const,
188
+ typeSymbol,
189
+ schema: z.number().int(),
190
+ }),
191
+ })
192
+ }
193
+
194
+ /** Result codec helper. */
195
+ function resultCodec(typeSymbol: string, schema: z.ZodType<unknown>): InvocationDescriptor['result'] {
196
+ return Object.freeze({
197
+ mode: 'strict' as const,
198
+ typeSymbol,
199
+ schema,
200
+ })
201
+ }
202
+
203
+ /** The `ticktick/status` invocation descriptor. */
204
+ export const TICKTICK_STATUS_DESCRIPTOR = Object.freeze({
205
+ id: 'dsh-ticktick#ticktick/status',
206
+ service: 'ticktick',
207
+ namespace: 'ticktick',
208
+ method: 'status',
209
+ invocation: Object.freeze({ kind: 'direct' }),
210
+ parameters: Object.freeze([]),
211
+ result: resultCodec('dsh-ticktick/types#TicktickStatus', TICKTICK_STATUS_SCHEMA),
212
+ sourceLocation: Object.freeze({ file: 'src/wire.ts', line: 1, column: 1 }),
213
+ } as const) satisfies InvocationDescriptor
214
+
215
+ /** The `ticktick/projects` invocation descriptor. */
216
+ export const TICKTICK_PROJECTS_DESCRIPTOR = Object.freeze({
217
+ id: 'dsh-ticktick#ticktick/projects',
218
+ service: 'ticktick',
219
+ namespace: 'ticktick',
220
+ method: 'projects',
221
+ invocation: Object.freeze({ kind: 'direct' }),
222
+ parameters: Object.freeze([]),
223
+ result: resultCodec('dsh-ticktick/types#TicktickProjectsResult', z.object({
224
+ projects: z.array(z.object({ id: z.string(), name: z.string() })),
225
+ })),
226
+ sourceLocation: Object.freeze({ file: 'src/wire.ts', line: 1, column: 1 }),
227
+ } as const) satisfies InvocationDescriptor
228
+
229
+ /** The `ticktick/tasks` invocation descriptor (optional list filter). */
230
+ export const TICKTICK_TASKS_DESCRIPTOR = Object.freeze({
231
+ id: 'dsh-ticktick#ticktick/tasks',
232
+ service: 'ticktick',
233
+ namespace: 'ticktick',
234
+ method: 'tasks',
235
+ invocation: Object.freeze({ kind: 'direct' }),
236
+ parameters: Object.freeze([
237
+ stringParam('projectId', 'dsh-ticktick/types#TasksProjectId', true),
238
+ ]),
239
+ result: resultCodec('dsh-ticktick/types#TicktickTasksResult', TICKTICK_TASKS_RESULT_SCHEMA),
240
+ sourceLocation: Object.freeze({ file: 'src/wire.ts', line: 1, column: 1 }),
241
+ } as const) satisfies InvocationDescriptor
242
+
243
+ /** The `ticktick/add` invocation descriptor. */
244
+ export const TICKTICK_ADD_DESCRIPTOR = Object.freeze({
245
+ id: 'dsh-ticktick#ticktick/add',
246
+ service: 'ticktick',
247
+ namespace: 'ticktick',
248
+ method: 'add',
249
+ invocation: Object.freeze({ kind: 'direct' }),
250
+ parameters: Object.freeze([
251
+ stringParam('title', 'dsh-ticktick/types#AddTitle'),
252
+ stringParam('projectId', 'dsh-ticktick/types#AddProjectId', true),
253
+ stringParam('dueDate', 'dsh-ticktick/types#AddDueDate', true),
254
+ ]),
255
+ result: resultCodec('dsh-ticktick/types#TicktickAddResult', TICKTICK_ADD_RESULT_SCHEMA),
256
+ sourceLocation: Object.freeze({ file: 'src/wire.ts', line: 1, column: 1 }),
257
+ } as const) satisfies InvocationDescriptor
258
+
259
+ /** The `ticktick/complete` invocation descriptor. */
260
+ export const TICKTICK_COMPLETE_DESCRIPTOR = Object.freeze({
261
+ id: 'dsh-ticktick#ticktick/complete',
262
+ service: 'ticktick',
263
+ namespace: 'ticktick',
264
+ method: 'complete',
265
+ invocation: Object.freeze({ kind: 'direct' }),
266
+ parameters: Object.freeze([
267
+ stringParam('id', 'dsh-ticktick/types#CompleteId'),
268
+ stringParam('projectId', 'dsh-ticktick/types#CompleteProjectId'),
269
+ ]),
270
+ result: resultCodec('dsh-ticktick/types#TicktickOkResult', TICKTICK_OK_RESULT_SCHEMA),
271
+ sourceLocation: Object.freeze({ file: 'src/wire.ts', line: 1, column: 1 }),
272
+ } as const) satisfies InvocationDescriptor
273
+
274
+ /** The `ticktick/remove` invocation descriptor. */
275
+ export const TICKTICK_REMOVE_DESCRIPTOR = Object.freeze({
276
+ id: 'dsh-ticktick#ticktick/remove',
277
+ service: 'ticktick',
278
+ namespace: 'ticktick',
279
+ method: 'remove',
280
+ invocation: Object.freeze({ kind: 'direct' }),
281
+ parameters: Object.freeze([
282
+ stringParam('id', 'dsh-ticktick/types#RemoveId'),
283
+ stringParam('projectId', 'dsh-ticktick/types#RemoveProjectId'),
284
+ ]),
285
+ result: resultCodec('dsh-ticktick/types#TicktickOkResult', TICKTICK_OK_RESULT_SCHEMA),
286
+ sourceLocation: Object.freeze({ file: 'src/wire.ts', line: 1, column: 1 }),
287
+ } as const) satisfies InvocationDescriptor
288
+
289
+ /** The `ticktick/setDue` invocation descriptor (absent date = clear). */
290
+ export const TICKTICK_SET_DUE_DESCRIPTOR = Object.freeze({
291
+ id: 'dsh-ticktick#ticktick/setDue',
292
+ service: 'ticktick',
293
+ namespace: 'ticktick',
294
+ method: 'setDue',
295
+ invocation: Object.freeze({ kind: 'direct' }),
296
+ parameters: Object.freeze([
297
+ stringParam('id', 'dsh-ticktick/types#SetDueId'),
298
+ stringParam('projectId', 'dsh-ticktick/types#SetDueProjectId', true),
299
+ stringParam('dueDate', 'dsh-ticktick/types#SetDueDate', true),
300
+ ]),
301
+ result: resultCodec('dsh-ticktick/types#TicktickOkResult', TICKTICK_OK_RESULT_SCHEMA),
302
+ sourceLocation: Object.freeze({ file: 'src/wire.ts', line: 1, column: 1 }),
303
+ } as const) satisfies InvocationDescriptor
304
+
305
+ /** The `ticktick/reorder` invocation descriptor. */
306
+ export const TICKTICK_REORDER_DESCRIPTOR = Object.freeze({
307
+ id: 'dsh-ticktick#ticktick/reorder',
308
+ service: 'ticktick',
309
+ namespace: 'ticktick',
310
+ method: 'reorder',
311
+ invocation: Object.freeze({ kind: 'direct' }),
312
+ parameters: Object.freeze([
313
+ stringParam('id', 'dsh-ticktick/types#ReorderId'),
314
+ stringParam('projectId', 'dsh-ticktick/types#ReorderProjectId', true),
315
+ numberParam('sortOrder', 'dsh-ticktick/types#ReorderSortOrder'),
316
+ ]),
317
+ result: resultCodec('dsh-ticktick/types#TicktickOkResult', TICKTICK_OK_RESULT_SCHEMA),
318
+ sourceLocation: Object.freeze({ file: 'src/wire.ts', line: 1, column: 1 }),
319
+ } as const) satisfies InvocationDescriptor
320
+
321
+ /** The `ticktick/completed` invocation descriptor (P2 completed view). */
322
+ export const TICKTICK_COMPLETED_DESCRIPTOR = Object.freeze({
323
+ id: 'dsh-ticktick#ticktick/completed',
324
+ service: 'ticktick',
325
+ namespace: 'ticktick',
326
+ method: 'completed',
327
+ invocation: Object.freeze({ kind: 'direct' }),
328
+ parameters: Object.freeze([
329
+ stringParam('projectId', 'dsh-ticktick/types#CompletedProjectId', true),
330
+ numberParam('days', 'dsh-ticktick/types#CompletedDays', true),
331
+ ]),
332
+ result: resultCodec('dsh-ticktick/types#TicktickTasksResult', TICKTICK_TASKS_RESULT_SCHEMA),
333
+ sourceLocation: Object.freeze({ file: 'src/wire.ts', line: 1, column: 1 }),
334
+ } as const) satisfies InvocationDescriptor
335
+
336
+ /** The `ticktick/search` invocation descriptor (P2 full-text search). */
337
+ export const TICKTICK_SEARCH_DESCRIPTOR = Object.freeze({
338
+ id: 'dsh-ticktick#ticktick/search',
339
+ service: 'ticktick',
340
+ namespace: 'ticktick',
341
+ method: 'search',
342
+ invocation: Object.freeze({ kind: 'direct' }),
343
+ parameters: Object.freeze([
344
+ stringParam('query', 'dsh-ticktick/types#SearchQuery'),
345
+ ]),
346
+ result: resultCodec('dsh-ticktick/types#TicktickTasksResult', TICKTICK_TASKS_RESULT_SCHEMA),
347
+ sourceLocation: Object.freeze({ file: 'src/wire.ts', line: 1, column: 1 }),
348
+ } as const) satisfies InvocationDescriptor
349
+
350
+ /** The `ticktick/batchAdd` invocation descriptor (P2 batch create). */
351
+ export const TICKTICK_BATCH_ADD_DESCRIPTOR = Object.freeze({
352
+ id: 'dsh-ticktick#ticktick/batchAdd',
353
+ service: 'ticktick',
354
+ namespace: 'ticktick',
355
+ method: 'batchAdd',
356
+ invocation: Object.freeze({ kind: 'direct' }),
357
+ parameters: Object.freeze([Object.freeze({
358
+ name: 'tasks',
359
+ wire: 'tasks',
360
+ source: 'json' as const,
361
+ codec: Object.freeze({
362
+ mode: 'strict' as const,
363
+ typeSymbol: 'dsh-ticktick/types#BatchAddTasks',
364
+ schema: z.array(BATCH_ADD_TASK_SCHEMA),
365
+ }),
366
+ } satisfies InvocationDescriptor['parameters'][number])]),
367
+ result: resultCodec('dsh-ticktick/types#BatchAddResult', BATCH_ADD_RESULT_SCHEMA),
368
+ sourceLocation: Object.freeze({ file: 'src/wire.ts', line: 1, column: 1 }),
369
+ } as const) satisfies InvocationDescriptor
370
+
371
+ /** The `ticktick/probe` invocation descriptor (settings-card connectivity test). */
372
+ export const TICKTICK_PROBE_DESCRIPTOR = Object.freeze({
373
+ id: 'dsh-ticktick#ticktick/probe',
374
+ service: 'ticktick',
375
+ namespace: 'ticktick',
376
+ method: 'probe',
377
+ invocation: Object.freeze({ kind: 'direct' }),
378
+ parameters: Object.freeze([]),
379
+ result: resultCodec('dsh-ticktick/types#TicktickProbeResult', TICKTICK_PROBE_RESULT_SCHEMA),
380
+ sourceLocation: Object.freeze({ file: 'src/wire.ts', line: 1, column: 1 }),
381
+ } as const) satisfies InvocationDescriptor
382
+
383
+ /**
384
+ * The canonical invocation list both Typert faces register — the host
385
+ * manifest and the client contribution share these exact descriptor objects,
386
+ * so the two wire codecs can never drift apart.
387
+ */
388
+ export const TICKTICK_INVOCATIONS = Object.freeze([
389
+ TICKTICK_STATUS_DESCRIPTOR,
390
+ TICKTICK_PROJECTS_DESCRIPTOR,
391
+ TICKTICK_TASKS_DESCRIPTOR,
392
+ TICKTICK_ADD_DESCRIPTOR,
393
+ TICKTICK_COMPLETE_DESCRIPTOR,
394
+ TICKTICK_REMOVE_DESCRIPTOR,
395
+ TICKTICK_SET_DUE_DESCRIPTOR,
396
+ TICKTICK_REORDER_DESCRIPTOR,
397
+ TICKTICK_COMPLETED_DESCRIPTOR,
398
+ TICKTICK_SEARCH_DESCRIPTOR,
399
+ TICKTICK_BATCH_ADD_DESCRIPTOR,
400
+ TICKTICK_PROBE_DESCRIPTOR,
401
+ ])