@zinn-dev/cli 0.42.0 → 0.43.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 (41) hide show
  1. package/package.json +3 -4
  2. package/skills/zinn/SKILL.md +1 -1
  3. package/src/capabilities-schema.d.ts +3 -3
  4. package/src/errors.d.ts +31 -3
  5. package/src/errors.js +75 -20
  6. package/src/lib.d.ts +14 -5
  7. package/src/lib.js +68 -33
  8. package/src/list-continuation.d.ts +11 -0
  9. package/src/list-continuation.js +18 -0
  10. package/src/list-limit.d.ts +11 -0
  11. package/src/list-limit.js +17 -0
  12. package/src/presentation/activity-presentation.js +18 -5
  13. package/src/presentation/description-presentation.d.ts +3 -16
  14. package/src/presentation/description-presentation.js +22 -21
  15. package/src/presentation/project-presentation.d.ts +6 -2
  16. package/src/presentation/project-presentation.js +9 -1
  17. package/src/presentation/relation-presentation.d.ts +6 -1
  18. package/src/presentation/relation-presentation.js +14 -0
  19. package/src/presentation/row-layout.d.ts +1 -1
  20. package/src/presentation/row-layout.js +6 -5
  21. package/src/presentation/task-presentation.js +7 -1
  22. package/src/presentation/text-width.d.ts +2 -0
  23. package/src/presentation/text-width.js +43 -0
  24. package/src/presentation/time.d.ts +3 -1
  25. package/src/presentation/time.js +5 -2
  26. package/src/result-schemas.d.ts +49 -3
  27. package/src/result-schemas.js +12 -3
  28. package/src/routes/activity-router.d.ts +45 -1
  29. package/src/routes/activity-router.js +113 -15
  30. package/src/routes/project-router.d.ts +40 -0
  31. package/src/routes/project-router.js +73 -12
  32. package/src/routes/relation-router.d.ts +7 -3
  33. package/src/routes/relation-router.js +73 -56
  34. package/src/routes/restore-router.js +2 -5
  35. package/src/routes/router.js +54 -27
  36. package/src/routes/routes.d.ts +169 -7
  37. package/src/routes/task-router.d.ts +84 -6
  38. package/src/routes/task-router.js +107 -19
  39. package/src/timestamp-input.d.ts +3 -0
  40. package/src/timestamp-input.js +31 -0
  41. package/src/types.d.ts +3 -3
@@ -45,6 +45,14 @@ export declare const taskRouter: {
45
45
  readonly description: "Omission leaves priority unassigned on creation and unchanged on edit. none clears priority; JSON uses null.";
46
46
  };
47
47
  };
48
+ readonly due: {
49
+ readonly type: "string";
50
+ readonly value: {
51
+ readonly kind: "timestamp";
52
+ readonly name: "timestamp";
53
+ readonly description: "Integer epoch milliseconds or YYYY-MM-DDTHH:mm:ss[.SSS] with Z or a numeric offset. Fractions have 1 to 3 digits. none clears the deadline, ignoring case. Omission leaves it unset on creation and unchanged on edit.";
54
+ };
55
+ };
48
56
  readonly label: {
49
57
  readonly type: "string";
50
58
  readonly multiple: true;
@@ -127,6 +135,23 @@ export declare const taskRouter: {
127
135
  };
128
136
  input: {
129
137
  readonly options: {
138
+ readonly limit: {
139
+ readonly type: "string";
140
+ readonly value: {
141
+ readonly kind: "positive-integer";
142
+ readonly name: "n";
143
+ readonly pattern: string;
144
+ };
145
+ readonly description: "Return at most n results after all filters. Use an integer from 1 through 11871.";
146
+ };
147
+ readonly sort: {
148
+ readonly type: "string";
149
+ readonly value: {
150
+ readonly kind: "enum";
151
+ readonly name: "key";
152
+ readonly choices: ("activity" | "due")[];
153
+ };
154
+ };
130
155
  readonly archived: {
131
156
  readonly type: "boolean";
132
157
  };
@@ -151,6 +176,30 @@ export declare const taskRouter: {
151
176
  readonly name: "name";
152
177
  };
153
178
  };
179
+ readonly "starting-after": {
180
+ readonly type: "string";
181
+ readonly value: {
182
+ readonly kind: "task-id";
183
+ readonly name: "id";
184
+ readonly description: "Task UUID or globally unambiguous left prefix with at least 8 hexadecimal digits. Canonical or compact, case-insensitive";
185
+ };
186
+ };
187
+ readonly "due-since": {
188
+ readonly type: "string";
189
+ readonly value: {
190
+ readonly kind: "timestamp";
191
+ readonly name: "timestamp";
192
+ readonly description: "Inclusive lower deadline bound. Integer epoch milliseconds or a timestamp with seconds and Z or a numeric offset. Fractions have 1 to 3 digits. Undated tasks do not match.";
193
+ };
194
+ };
195
+ readonly "due-until": {
196
+ readonly type: "string";
197
+ readonly value: {
198
+ readonly kind: "timestamp";
199
+ readonly name: "timestamp";
200
+ readonly description: "Inclusive upper deadline bound in the same formats as --due-since. Must be at or after --due-since. Undated tasks do not match.";
201
+ };
202
+ };
154
203
  };
155
204
  readonly forms: readonly [{
156
205
  readonly id: "default";
@@ -170,7 +219,7 @@ export declare const taskRouter: {
170
219
  readonly kind: "exclusive";
171
220
  readonly members: readonly ["positional:project-key", "option:all-projects"];
172
221
  }];
173
- readonly notes: readonly ["An omitted project key uses defaultProject, or all projects if unset. --all-projects overrides the default and cannot be combined with a project key."];
222
+ readonly notes: readonly ["An omitted project key uses defaultProject, or all projects if unset. --all-projects overrides the default and cannot be combined with a project key.", "A --starting-after task must match every selection filter. Cursor resolution uses current task identities before list filtering."];
174
223
  };
175
224
  results: import("../results.js").CommandResult[];
176
225
  run: (args: string[]) => void;
@@ -201,8 +250,9 @@ export declare const taskRouter: {
201
250
  readonly value: {
202
251
  readonly kind: "positive-integer";
203
252
  readonly name: "n";
204
- readonly pattern: "^[1-9]\\d{0,14}$";
253
+ readonly pattern: string;
205
254
  };
255
+ readonly description: "Return at most n results after all filters. Use an integer from 1 through 11871.";
206
256
  };
207
257
  readonly label: {
208
258
  readonly type: "string";
@@ -212,6 +262,22 @@ export declare const taskRouter: {
212
262
  readonly name: "name";
213
263
  };
214
264
  };
265
+ readonly "due-since": {
266
+ readonly type: "string";
267
+ readonly value: {
268
+ readonly kind: "timestamp";
269
+ readonly name: "timestamp";
270
+ readonly description: "Inclusive lower deadline bound. Integer epoch milliseconds or a timestamp with seconds and Z or a numeric offset. Fractions have 1 to 3 digits. Undated tasks do not match.";
271
+ };
272
+ };
273
+ readonly "due-until": {
274
+ readonly type: "string";
275
+ readonly value: {
276
+ readonly kind: "timestamp";
277
+ readonly name: "timestamp";
278
+ readonly description: "Inclusive upper deadline bound in the same formats as --due-since. Must be at or after --due-since. Undated tasks do not match.";
279
+ };
280
+ };
215
281
  };
216
282
  readonly forms: readonly [{
217
283
  readonly id: "default";
@@ -297,6 +363,14 @@ export declare const taskRouter: {
297
363
  readonly description: "Omission leaves priority unassigned on creation and unchanged on edit. none clears priority; JSON uses null.";
298
364
  };
299
365
  };
366
+ readonly due: {
367
+ readonly type: "string";
368
+ readonly value: {
369
+ readonly kind: "timestamp";
370
+ readonly name: "timestamp";
371
+ readonly description: "Integer epoch milliseconds or YYYY-MM-DDTHH:mm:ss[.SSS] with Z or a numeric offset. Fractions have 1 to 3 digits. none clears the deadline, ignoring case. Omission leaves it unset on creation and unchanged on edit.";
372
+ };
373
+ };
300
374
  readonly "add-label": {
301
375
  readonly type: "string";
302
376
  readonly multiple: true;
@@ -380,7 +454,7 @@ export declare const taskRouter: {
380
454
  readonly requires: "option:replacing";
381
455
  }, {
382
456
  readonly kind: "atLeastOne";
383
- readonly members: readonly ["option:title", "option:description", "option:description-file", "option:priority", "option:add-label", "option:remove-label"];
457
+ readonly members: readonly ["option:title", "option:description", "option:description-file", "option:priority", "option:due", "option:add-label", "option:remove-label"];
384
458
  }];
385
459
  readonly notes: readonly [string];
386
460
  };
@@ -604,14 +678,18 @@ export declare const taskRouter: {
604
678
  create: {
605
679
  summary: string;
606
680
  effects: {
607
- domain: "create";
681
+ domain: "replace";
608
682
  storage: "normal-open";
609
683
  };
610
684
  confirmation: {
611
- kind: "none";
685
+ kind: "prompt";
686
+ description: string;
612
687
  };
613
688
  input: {
614
689
  readonly options: {
690
+ readonly yes: {
691
+ readonly type: "boolean";
692
+ };
615
693
  readonly type: {
616
694
  readonly type: "string";
617
695
  readonly required: true;
@@ -645,7 +723,7 @@ export declare const taskRouter: {
645
723
  guessedFlags: {
646
724
  [k: string]: (args: Array<string>) => string[] | undefined;
647
725
  };
648
- run: (args: string[]) => void;
726
+ run: (args: string[]) => Promise<void>;
649
727
  help: string;
650
728
  };
651
729
  list: {
@@ -1,6 +1,9 @@
1
1
  import { jsonResult, taskDetailResults, taskChangeResults } from "../results.js";
2
2
  import { parseArgs } from "node:util";
3
- import { task, project, positiveIntegerPattern, searchLimitMessage, parseTaskKey, taskCreateSchema, taskEditSchema, taskDeleteManySchema, taskPrioritySchema, } from "@zinn-dev/core";
3
+ import { task, project, parseTaskKey, taskCreateSchema, taskEditSchema, taskDeleteManySchema, taskPrioritySchema, taskSortSchema, } from "@zinn-dev/core";
4
+ import { listLimitOption, listLimitDescription, parseListLimit } from "../list-limit.js";
5
+ import { formatListContinuation } from "../list-continuation.js";
6
+ import { parseTimestampInput } from "../timestamp-input.js";
4
7
  import { CliError } from "../errors.js";
5
8
  import { generateCommandUsage, taskKeyPositional, archiveConstraint, getOptionInputs, violatesConstraint, } from "../input.js";
6
9
  import { confirmationDescription, confirmAction, dashValueHelp, diagnostic, output, outputChanges, quit, validatePositionals, validateOrderForms, requireStringOption, renameFlag, validateUniqueOptions, } from "../lib.js";
@@ -37,6 +40,34 @@ const priorityOption = {
37
40
  description: "Omission leaves priority unassigned on creation and unchanged on edit. none clears priority; JSON uses null.",
38
41
  },
39
42
  };
43
+ const dueOption = {
44
+ type: "string",
45
+ value: {
46
+ kind: "timestamp",
47
+ name: "timestamp",
48
+ description: "Integer epoch milliseconds or YYYY-MM-DDTHH:mm:ss[.SSS] with Z or a numeric offset. Fractions have 1 to 3 digits. none clears the deadline, ignoring case. Omission leaves it unset on creation and unchanged on edit.",
49
+ },
50
+ };
51
+ const deadlineFilterOptions = {
52
+ "due-since": {
53
+ type: "string",
54
+ value: {
55
+ kind: "timestamp",
56
+ name: "timestamp",
57
+ description: "Inclusive lower deadline bound. Integer epoch milliseconds or a timestamp with seconds and Z or a numeric offset. Fractions have 1 to 3 digits. Undated tasks do not match.",
58
+ },
59
+ },
60
+ "due-until": {
61
+ type: "string",
62
+ value: {
63
+ kind: "timestamp",
64
+ name: "timestamp",
65
+ description: "Inclusive upper deadline bound in the same formats as --due-since. Must be at or after --due-since. Undated tasks do not match.",
66
+ },
67
+ },
68
+ };
69
+ const deadlineHelp = "--due accepts integer epoch milliseconds or YYYY-MM-DDTHH:mm:ss[.SSS] with Z or a numeric offset such as +01:00. Fractional seconds have 1 to 3 digits. Use --due none to clear it. Omission leaves it unset on creation and unchanged on edit.";
70
+ const deadlineFilterHelp = "--due-since and --due-until select deadlines inclusively, using integer epoch milliseconds or timestamps with seconds and Z or a numeric offset. Fractional seconds have 1 to 3 digits. Either bound may appear alone. --due-until must be at or after --due-since. Undated tasks do not match. All filters apply before --limit.";
40
71
  const taskEditConstraint = {
41
72
  kind: "atLeastOne",
42
73
  members: [
@@ -44,6 +75,7 @@ const taskEditConstraint = {
44
75
  "option:description",
45
76
  "option:description-file",
46
77
  "option:priority",
78
+ "option:due",
47
79
  "option:add-label",
48
80
  "option:remove-label",
49
81
  ],
@@ -55,6 +87,7 @@ const taskInputs = {
55
87
  description: { type: "string", value: { kind: "text", name: "text" } },
56
88
  "description-file": textFileOption,
57
89
  priority: priorityOption,
90
+ due: dueOption,
58
91
  label: { type: "string", multiple: true, value: { kind: "label-name", name: "name" } },
59
92
  column: { type: "string", value: { kind: "column-name", name: "name" } },
60
93
  parent: { type: "string", value: { kind: "task-key", name: "task-key" } },
@@ -77,11 +110,25 @@ const taskInputs = {
77
110
  },
78
111
  list: {
79
112
  options: {
113
+ ...deadlineFilterOptions,
114
+ limit: listLimitOption,
115
+ sort: {
116
+ type: "string",
117
+ value: { kind: "enum", name: "key", choices: taskSortSchema.options },
118
+ },
80
119
  archived: { type: "boolean" },
81
120
  all: { type: "boolean" },
82
121
  "all-projects": { type: "boolean" },
83
122
  label: { type: "string", multiple: true, value: { kind: "label-name", name: "name" } },
84
123
  column: { type: "string", value: { kind: "column-name", name: "name" } },
124
+ "starting-after": {
125
+ type: "string",
126
+ value: {
127
+ kind: "task-id",
128
+ name: "id",
129
+ description: "Task UUID or globally unambiguous left prefix with at least 8 hexadecimal digits. Canonical or compact, case-insensitive",
130
+ },
131
+ },
85
132
  },
86
133
  forms: [
87
134
  {
@@ -90,17 +137,18 @@ const taskInputs = {
90
137
  },
91
138
  ],
92
139
  constraints: [archiveConstraint, projectScopeConstraint],
93
- notes: [projectScopeDescription],
140
+ notes: [
141
+ projectScopeDescription,
142
+ "A --starting-after task must match every selection filter. Cursor resolution uses current task identities before list filtering.",
143
+ ],
94
144
  },
95
145
  search: {
96
146
  options: {
147
+ ...deadlineFilterOptions,
97
148
  archived: { type: "boolean" },
98
149
  all: { type: "boolean" },
99
150
  "all-projects": { type: "boolean" },
100
- limit: {
101
- type: "string",
102
- value: { kind: "positive-integer", name: "n", pattern: `^${positiveIntegerPattern}$` },
103
- },
151
+ limit: listLimitOption,
104
152
  label: { type: "string", multiple: true, value: { kind: "label-name", name: "name" } },
105
153
  },
106
154
  forms: [
@@ -135,6 +183,7 @@ const taskInputs = {
135
183
  "description-file": textFileOption,
136
184
  ...textEditOptions,
137
185
  priority: priorityOption,
186
+ due: dueOption,
138
187
  "add-label": { type: "string", multiple: true, value: { kind: "label-name", name: "name" } },
139
188
  "remove-label": {
140
189
  type: "string",
@@ -275,6 +324,7 @@ export const taskRouter = {
275
324
  const fields = {
276
325
  title,
277
326
  priority,
327
+ due_at: parseDue(values.due),
278
328
  labelNames: values.label,
279
329
  columnName: values.column,
280
330
  relations: parseNewTaskRelations(values),
@@ -297,6 +347,7 @@ Create a task at the bottom of a column. Without --column, it starts in the proj
297
347
  ${requiredProjectDescription}
298
348
 
299
349
  Priority values: ${priorityOption.value.choices.join(", ")}; defaults to none.
350
+ ${deadlineHelp}
300
351
  Repeat --label to attach multiple existing labels.
301
352
  ${textFileHelp("--description")}
302
353
 
@@ -305,6 +356,8 @@ ${dashValueHelp("--description")}
305
356
  The new task is a subtask of --parent, depends on --depends-on,
306
357
  is a duplicate of --duplicate-of, and is related to --related.
307
358
  Repeat --depends-on and --related to name several tasks.
359
+ Each target may have one relation type. Identical repeated requests count once.
360
+ Different relation types for the same target abort creation.
308
361
  Unknown columns, labels or related tasks abort creation.
309
362
 
310
363
  Examples:
@@ -333,13 +386,29 @@ Examples:
333
386
  }
334
387
  const projectKey = resolveProjectKey(positionals[0], { allProjects: values["all-projects"] });
335
388
  const archive = values.all ? "all" : values.archived ? "archived" : "active";
336
- const tasks = task.getAll({
389
+ const limit = parseListLimit(values.limit);
390
+ const sort = taskSortSchema.optional().safeParse(values.sort);
391
+ if (!sort.success) {
392
+ quit(`Unknown sort "${values.sort}". Use ${taskSortSchema.options.join(", ")}`, undefined, {
393
+ argument: "--sort",
394
+ });
395
+ }
396
+ const page = task.getPage({
397
+ ...parseDeadlineFilters(values),
398
+ limit,
399
+ sort: sort.data,
337
400
  projectKey,
338
401
  archive,
339
402
  labelNames: values.label,
340
403
  columnName: values.column,
404
+ startingAfter: values["starting-after"],
341
405
  });
342
- output(tasks.map(presentTask), (presentedTasks) => formatTaskList(presentedTasks, { showsStatus: values.all }));
406
+ output(page.tasks.map(presentTask), (presentedTasks) => formatTaskList(presentedTasks, { showsStatus: values.all }));
407
+ if (page.hasMore) {
408
+ const selectionTokens = tokens.filter((token) => token.kind !== "option" || token.name !== "all-projects");
409
+ const projectScope = projectKey === undefined ? ["--all-projects"] : [projectKey];
410
+ diagnostic(`More tasks. Continue with: ${formatListContinuation(["task", "list"], projectScope, selectionTokens, "starting-after", page.tasks.at(-1).id)}`);
411
+ }
343
412
  },
344
413
  help: `${generateCommandUsage("task list", taskInputs.list)}
345
414
 
@@ -349,6 +418,15 @@ Use --archived to list archived tasks or --all to list both.
349
418
  Repeat --label to require every specified label.
350
419
  --column matches an exact column name. Column and label matching ignore case.
351
420
  All supplied filters must match.
421
+ --sort activity lists the most recently active tasks first, including comments and relations.
422
+ Equal activity times keep board order. Without --sort, board order is preserved.
423
+ --sort due lists earliest deadlines first, with undated tasks last. Equal deadlines keep board order. Task positions stay unchanged.
424
+ ${deadlineFilterHelp}
425
+ --limit <n>: ${listLimitDescription}
426
+ --starting-after <id>: Continue after a current matching task. Accepts a UUID, canonical or compact, case-insensitive.
427
+ Use the task's id from --json output as the cursor.
428
+ The task cursor must match all selection filters. Movement or edits can change current sort positions between commands.
429
+ When additional matches remain after --limit, stderr gives a shell-quoted command to continue, including with --json.
352
430
 
353
431
  Use 'task view' to see a task's full details, including its description.
354
432
 
@@ -375,17 +453,14 @@ Example: zinn task list MDR --label cli`,
375
453
  quit('Use either "--archived" or "--all", not both', undefined, { argument: "--archived" });
376
454
  }
377
455
  const archive = values.all ? "all" : values.archived ? "archived" : "active";
378
- const limitPattern = new RegExp(taskInputs.search.options.limit.value.pattern);
379
- if (values.limit !== undefined && !limitPattern.test(values.limit)) {
380
- quit(searchLimitMessage, undefined, { argument: "--limit" });
381
- }
382
456
  const isTaskKeyQuery = parseTaskKey(query.trim()) !== null;
383
457
  const projectKey = resolveProjectKey(positionals[1], {
384
458
  allProjects: values["all-projects"],
385
459
  useDefault: !isTaskKeyQuery,
386
460
  });
387
- const limit = values.limit === undefined ? undefined : Number(values.limit);
461
+ const limit = parseListLimit(values.limit);
388
462
  const result = task.search({
463
+ ...parseDeadlineFilters(values),
389
464
  query,
390
465
  projectKey,
391
466
  archive,
@@ -409,8 +484,9 @@ Every word must match. Quote a query with several words.
409
484
  A task-key query overrides the configured default project; a typed project key still filters it.
410
485
 
411
486
  By default, only active tasks are searched. Use --archived to search archived tasks or --all to search both.
412
- Use --limit to show at most <n> results.
487
+ --limit <n>: ${listLimitDescription}
413
488
  Repeat --label to require every specified label, ignoring case.
489
+ ${deadlineFilterHelp}
414
490
 
415
491
  Example: zinn task search 'refinement quota' MDR --limit 5`,
416
492
  },
@@ -433,8 +509,6 @@ Example: zinn task search 'refinement quota' MDR --limit 5`,
433
509
  const taskMatch = task.getByKey(positionals[0]);
434
510
  const detail = {
435
511
  ...presentTask(taskMatch),
436
- created_at: taskMatch.created_at,
437
- updated_at: taskMatch.updated_at,
438
512
  relations: presentRelations(taskMatch),
439
513
  comments: presentComments(taskMatch.key),
440
514
  };
@@ -494,7 +568,7 @@ Examples:
494
568
  zinn task view MDR-1 --history`,
495
569
  },
496
570
  edit: {
497
- summary: "Edit a task's title, description, priority, or label attachments.",
571
+ summary: "Edit a task's title, description, priority, deadline, or label attachments.",
498
572
  effects: { domain: "update", storage: "normal-open" },
499
573
  confirmation: { kind: "none" },
500
574
  input: taskInputs.edit,
@@ -514,6 +588,7 @@ Examples:
514
588
  taskKey,
515
589
  title: values.title,
516
590
  priority: parsePriority(values.priority),
591
+ due_at: parseDue(values.due),
517
592
  addLabelNames: values["add-label"],
518
593
  removeLabelNames: values["remove-label"],
519
594
  };
@@ -521,14 +596,15 @@ Examples:
521
596
  const description = await resolveTextEdit(values, "--description");
522
597
  // Without a text source nothing was read, so this usage error still comes before any input.
523
598
  if (violatesConstraint(taskEditConstraint, getOptionInputs(values))) {
524
- quit("Provide at least one edit flag: --title, --description, --description-file, --priority, --add-label, or --remove-label", undefined, { field: [] });
599
+ quit("Provide at least one edit flag: --title, --description, --description-file, --priority, --due, --add-label, or --remove-label", undefined, { field: [] });
525
600
  }
526
601
  const editedTask = task.edit({ ...fields, description }, currentActor());
527
602
  outputChanges([editedTask], (change) => presentTask(change.task), formatTaskList, (entry) => `${entry.key} was unchanged`);
528
603
  },
529
604
  help: `${generateCommandUsage("task edit", taskInputs.edit)}
530
605
 
531
- Edit a task's title, description, priority, or label attachments.
606
+ Edit a task's title, description, priority, deadline, or label attachments.
607
+ ${deadlineHelp}
532
608
  Use --priority none to clear priority.
533
609
  Priority values: ${priorityOption.value.choices.join(", ")}.
534
610
  Provide at least one edit flag. Use --description '' to clear the description.
@@ -779,6 +855,18 @@ function parseNewTaskRelations(flags) {
779
855
  ];
780
856
  return targetsByType.flatMap(([relation_type, targetTaskKeys]) => targetTaskKeys.map((targetTaskKey) => ({ relation_type, targetTaskKey })));
781
857
  }
858
+ function parseDue(value) {
859
+ return value?.toLowerCase() === "none" ? null : parseTimestampInput(value, "--due");
860
+ }
861
+ function parseDeadlineFilters(values) {
862
+ const dueSince = parseTimestampInput(values["due-since"], "--due-since");
863
+ const dueUntil = parseTimestampInput(values["due-until"], "--due-until");
864
+ const hasReversedBounds = dueSince !== undefined && dueUntil !== undefined && dueSince > dueUntil;
865
+ if (hasReversedBounds) {
866
+ quit("--due-until must be at or after --due-since", undefined, { argument: "--due-until" });
867
+ }
868
+ return { dueSince, dueUntil };
869
+ }
782
870
  function parsePriority(value) {
783
871
  const normalizedPriority = value?.toLowerCase();
784
872
  if (normalizedPriority === undefined) {
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+ export declare const timestampInputSchema: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>;
3
+ export declare function parseTimestampInput(value: string | undefined, argument: string): number | undefined;
@@ -0,0 +1,31 @@
1
+ import { z } from "zod";
2
+ import { timestampSchema } from "@zinn-dev/core";
3
+ import { quit } from "./lib.js";
4
+ const timeInputMessage = "Use integer epoch milliseconds or YYYY-MM-DDTHH:mm:ss[.SSS] with Z or a numeric offset such as +01:00. Fractional seconds accept 1 to 3 digits";
5
+ const offsetTimestampSchema = z.iso
6
+ .datetime({ offset: true })
7
+ .refine((value) => !/\.\d{4}/.test(value), timeInputMessage);
8
+ export const timestampInputSchema = z
9
+ .string()
10
+ .refine((value) => value.trim() === value, timeInputMessage)
11
+ .transform((value, context) => {
12
+ if (/^[+-]?\d+$/.test(value)) {
13
+ return Number(value);
14
+ }
15
+ if (!offsetTimestampSchema.safeParse(value).success) {
16
+ context.addIssue({ code: "custom", message: timeInputMessage });
17
+ return z.NEVER;
18
+ }
19
+ return Date.parse(value);
20
+ })
21
+ .pipe(timestampSchema);
22
+ export function parseTimestampInput(value, argument) {
23
+ if (value === undefined) {
24
+ return undefined;
25
+ }
26
+ const parsed = timestampInputSchema.safeParse(value);
27
+ if (!parsed.success) {
28
+ quit(parsed.error.issues[0].message, undefined, { argument });
29
+ }
30
+ return parsed.data;
31
+ }
package/src/types.d.ts CHANGED
@@ -3,8 +3,8 @@ import type { CommandResult } from "./results.js";
3
3
  import { z } from "zod";
4
4
  export declare const commandEffectsSchema: z.ZodObject<{
5
5
  domain: z.ZodEnum<{
6
- read: "read";
7
6
  create: "create";
7
+ read: "read";
8
8
  update: "update";
9
9
  delete: "delete";
10
10
  replace: "replace";
@@ -12,11 +12,11 @@ export declare const commandEffectsSchema: z.ZodObject<{
12
12
  }>;
13
13
  storage: z.ZodEnum<{
14
14
  backup: "backup";
15
+ migrate: "migrate";
16
+ reindex: "reindex";
15
17
  none: "none";
16
18
  "normal-open": "normal-open";
17
19
  restore: "restore";
18
- migrate: "migrate";
19
- reindex: "reindex";
20
20
  inspect: "inspect";
21
21
  }>;
22
22
  }, z.core.$strict>;