@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.
- package/package.json +3 -4
- package/skills/zinn/SKILL.md +1 -1
- package/src/capabilities-schema.d.ts +3 -3
- package/src/errors.d.ts +31 -3
- package/src/errors.js +75 -20
- package/src/lib.d.ts +14 -5
- package/src/lib.js +68 -33
- package/src/list-continuation.d.ts +11 -0
- package/src/list-continuation.js +18 -0
- package/src/list-limit.d.ts +11 -0
- package/src/list-limit.js +17 -0
- package/src/presentation/activity-presentation.js +18 -5
- package/src/presentation/description-presentation.d.ts +3 -16
- package/src/presentation/description-presentation.js +22 -21
- package/src/presentation/project-presentation.d.ts +6 -2
- package/src/presentation/project-presentation.js +9 -1
- package/src/presentation/relation-presentation.d.ts +6 -1
- package/src/presentation/relation-presentation.js +14 -0
- package/src/presentation/row-layout.d.ts +1 -1
- package/src/presentation/row-layout.js +6 -5
- package/src/presentation/task-presentation.js +7 -1
- package/src/presentation/text-width.d.ts +2 -0
- package/src/presentation/text-width.js +43 -0
- package/src/presentation/time.d.ts +3 -1
- package/src/presentation/time.js +5 -2
- package/src/result-schemas.d.ts +49 -3
- package/src/result-schemas.js +12 -3
- package/src/routes/activity-router.d.ts +45 -1
- package/src/routes/activity-router.js +113 -15
- package/src/routes/project-router.d.ts +40 -0
- package/src/routes/project-router.js +73 -12
- package/src/routes/relation-router.d.ts +7 -3
- package/src/routes/relation-router.js +73 -56
- package/src/routes/restore-router.js +2 -5
- package/src/routes/router.js +54 -27
- package/src/routes/routes.d.ts +169 -7
- package/src/routes/task-router.d.ts +84 -6
- package/src/routes/task-router.js +107 -19
- package/src/timestamp-input.d.ts +3 -0
- package/src/timestamp-input.js +31 -0
- package/src/types.d.ts +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { activity, activityTaskKeySchema, column, label, minimumActivityIdLength, project, task, } from "@zinn-dev/core";
|
|
1
|
+
import { activity, activityTaskKeySchema, column, label, minimumActivityIdLength, project, task, timestampSchema, } from "@zinn-dev/core";
|
|
2
2
|
import { formatDescriptionPreview } from "./description-presentation.js";
|
|
3
3
|
import { formatRows } from "./row-layout.js";
|
|
4
4
|
import { formatSection } from "./section.js";
|
|
@@ -10,6 +10,7 @@ const RECORDED_FIELDS = new Set([
|
|
|
10
10
|
"title",
|
|
11
11
|
"description",
|
|
12
12
|
"priority",
|
|
13
|
+
"due_at",
|
|
13
14
|
"color",
|
|
14
15
|
"column",
|
|
15
16
|
"columns",
|
|
@@ -139,7 +140,7 @@ function getTaskNavigation(events, taskKey, taskId) {
|
|
|
139
140
|
}
|
|
140
141
|
}
|
|
141
142
|
if (historicalKeys.size > 0) {
|
|
142
|
-
for (const event of activity.getAll()) {
|
|
143
|
+
for (const event of activity.getAll().events) {
|
|
143
144
|
if (event.action !== "delete") {
|
|
144
145
|
continue;
|
|
145
146
|
}
|
|
@@ -170,7 +171,7 @@ export function presentActivities(events, options = {}) {
|
|
|
170
171
|
projectKey: options.projectKey,
|
|
171
172
|
projectId: options.projectId,
|
|
172
173
|
showDeleted: options.showDeleted,
|
|
173
|
-
})
|
|
174
|
+
}).events
|
|
174
175
|
: events;
|
|
175
176
|
const tasks = getTaskNavigation(navigationEvents, options.taskKey, options.taskId);
|
|
176
177
|
const tasksById = new Map(tasks.map((identity) => [identity.id, identity]));
|
|
@@ -301,6 +302,12 @@ function isRecordedChangePair(event, value) {
|
|
|
301
302
|
Array.isArray(value) &&
|
|
302
303
|
value.length === 2);
|
|
303
304
|
}
|
|
305
|
+
function formatDeadline(value) {
|
|
306
|
+
const parsed = timestampSchema.safeParse(value);
|
|
307
|
+
return parsed.success
|
|
308
|
+
? formatLocalTime(parsed.data, { includesSeconds: true })
|
|
309
|
+
: summarizeValue(value);
|
|
310
|
+
}
|
|
304
311
|
function formatRemovedTasks(entry) {
|
|
305
312
|
return entry.removedTasks.map((identity) => `removed ${identity.key} (${identity.id})`);
|
|
306
313
|
}
|
|
@@ -332,6 +339,11 @@ function formatChangeSummary(entry, options = {}) {
|
|
|
332
339
|
if (field === "title" && options.omitsIdentity && isSnapshot) {
|
|
333
340
|
return summarizeValue(value);
|
|
334
341
|
}
|
|
342
|
+
if (field === "due_at") {
|
|
343
|
+
return isRecordedChangePair(event, value)
|
|
344
|
+
? `${field}: ${formatDeadline(value[0])} → ${formatDeadline(value[1])}`
|
|
345
|
+
: `${field}: ${formatDeadline(value)}`;
|
|
346
|
+
}
|
|
335
347
|
if (isRecordedChangePair(event, value)) {
|
|
336
348
|
return `${field}: ${summarizeValue(value[0])} → ${summarizeValue(value[1])}`;
|
|
337
349
|
}
|
|
@@ -423,9 +435,10 @@ function formatRecordedChanges(event) {
|
|
|
423
435
|
unknownFields[field] = value;
|
|
424
436
|
continue;
|
|
425
437
|
}
|
|
438
|
+
const formatValue = field === "due_at" ? formatDeadline : formatRecordedValue;
|
|
426
439
|
const body = isRecordedChangePair(event, value)
|
|
427
|
-
? `${formatSection("From",
|
|
428
|
-
:
|
|
440
|
+
? `${formatSection("From", formatValue(value[0]))}\n\n${formatSection("To", formatValue(value[1]))}`
|
|
441
|
+
: formatValue(value);
|
|
429
442
|
sections.push(formatSection(field, body));
|
|
430
443
|
}
|
|
431
444
|
if (Object.keys(unknownFields).length > 0) {
|
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Formats a description preview, capped at `maxLength` (80 by default)
|
|
3
|
-
* and ending with an ellipsis when shortened.
|
|
4
|
-
*
|
|
5
|
-
* The cap counts UTF-16 units, which means it can land inside an emoji 😀
|
|
6
|
-
* and cut it in half 🫡.
|
|
7
|
-
* The cut half cannot render, so it is dropped.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* // The cut lands after both halves, so the emoji is kept.
|
|
11
|
-
* formatDescriptionPreview("a😀zz", { maxLength: 4 }); // "a😀…"
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* // The cut lands between the halves, so the orphaned half is dropped.
|
|
15
|
-
* formatDescriptionPreview("a😀z", { maxLength: 3 }); // "a…"
|
|
16
|
-
*/
|
|
1
|
+
/** Formats a visual preview within a terminal-cell budget, including the ellipsis. */
|
|
17
2
|
export declare function formatDescriptionPreview(description: string | null, options?: {
|
|
18
3
|
maxLength?: number;
|
|
19
4
|
firstLineOnly?: boolean;
|
|
20
5
|
}): string;
|
|
6
|
+
/** Keeps parser reasons within their UTF-16-unit budget. */
|
|
7
|
+
export declare function formatParserReasonPreview(reason: string, maxLength: number): string;
|
|
@@ -1,21 +1,6 @@
|
|
|
1
|
+
import { displayWidth, graphemes } from "./text-width.js";
|
|
1
2
|
const DEFAULT_PREVIEW_LENGTH = 80;
|
|
2
|
-
|
|
3
|
-
* Formats a description preview, capped at `maxLength` (80 by default)
|
|
4
|
-
* and ending with an ellipsis when shortened.
|
|
5
|
-
*
|
|
6
|
-
* The cap counts UTF-16 units, which means it can land inside an emoji 😀
|
|
7
|
-
* and cut it in half 🫡.
|
|
8
|
-
* The cut half cannot render, so it is dropped.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* // The cut lands after both halves, so the emoji is kept.
|
|
12
|
-
* formatDescriptionPreview("a😀zz", { maxLength: 4 }); // "a😀…"
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* // The cut lands between the halves, so the orphaned half is dropped.
|
|
16
|
-
* formatDescriptionPreview("a😀z", { maxLength: 3 }); // "a…"
|
|
17
|
-
*/
|
|
18
|
-
export function formatDescriptionPreview(description, options = {}) {
|
|
3
|
+
function formatPreview(description, options, measure) {
|
|
19
4
|
const previewLength = options.maxLength ?? DEFAULT_PREVIEW_LENGTH;
|
|
20
5
|
if (description == null) {
|
|
21
6
|
return "";
|
|
@@ -24,10 +9,26 @@ export function formatDescriptionPreview(description, options = {}) {
|
|
|
24
9
|
const hasMoreLines = lineBreakIndex !== -1;
|
|
25
10
|
const previewText = hasMoreLines ? description.slice(0, lineBreakIndex) : description;
|
|
26
11
|
const normalizedDescription = previewText.replace(/\s+/g, " ").trim();
|
|
27
|
-
if (normalizedDescription
|
|
12
|
+
if (measure(normalizedDescription) <= previewLength && !hasMoreLines) {
|
|
28
13
|
return normalizedDescription;
|
|
29
14
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
15
|
+
let prefix = "";
|
|
16
|
+
let prefixLength = 0;
|
|
17
|
+
for (const { segment } of graphemes(normalizedDescription)) {
|
|
18
|
+
const segmentLength = measure(segment);
|
|
19
|
+
if (prefixLength + segmentLength > previewLength - 1) {
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
prefix += segment;
|
|
23
|
+
prefixLength += segmentLength;
|
|
24
|
+
}
|
|
25
|
+
return `${prefix.trimEnd()}…`;
|
|
26
|
+
}
|
|
27
|
+
/** Formats a visual preview within a terminal-cell budget, including the ellipsis. */
|
|
28
|
+
export function formatDescriptionPreview(description, options = {}) {
|
|
29
|
+
return formatPreview(description, options, displayWidth);
|
|
30
|
+
}
|
|
31
|
+
/** Keeps parser reasons within their UTF-16-unit budget. */
|
|
32
|
+
export function formatParserReasonPreview(reason, maxLength) {
|
|
33
|
+
return formatPreview(reason, { maxLength }, (text) => text.length);
|
|
33
34
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import type { PresentedProject } from "../result-schemas.js";
|
|
1
|
+
import type { PresentedProject, PresentedProjectListEntry } from "../result-schemas.js";
|
|
2
|
+
type ProjectRow = PresentedProject & {
|
|
3
|
+
taskCounts?: PresentedProjectListEntry["taskCounts"];
|
|
4
|
+
};
|
|
2
5
|
type ProjectRowOptions = {
|
|
3
6
|
showsDescriptionPreview?: boolean;
|
|
7
|
+
showsTaskCounts?: boolean;
|
|
4
8
|
};
|
|
5
9
|
export declare function presentProject(projectMatch: PresentedProject): PresentedProject;
|
|
6
|
-
export declare function formatProjectList(presentedProjects: Array<
|
|
10
|
+
export declare function formatProjectList(presentedProjects: Array<ProjectRow>, { showsDescriptionPreview, showsTaskCounts }?: ProjectRowOptions): string;
|
|
7
11
|
export {};
|
|
@@ -8,12 +8,20 @@ export function presentProject(projectMatch) {
|
|
|
8
8
|
description: projectMatch.description,
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
export function formatProjectList(presentedProjects, { showsDescriptionPreview = true } = {}) {
|
|
11
|
+
export function formatProjectList(presentedProjects, { showsDescriptionPreview = true, showsTaskCounts = false } = {}) {
|
|
12
12
|
return formatRows(presentedProjects.map((presented) => {
|
|
13
13
|
const descriptionPreview = showsDescriptionPreview
|
|
14
14
|
? formatDescriptionPreview(presented.description)
|
|
15
15
|
: "";
|
|
16
16
|
const description = descriptionPreview.length > 0 ? `${formatCellSeparator()}${descriptionPreview}` : "";
|
|
17
|
+
if (showsTaskCounts && presented.taskCounts != null) {
|
|
18
|
+
return [
|
|
19
|
+
{ text: presented.key },
|
|
20
|
+
{ text: presented.name },
|
|
21
|
+
{ text: `${presented.taskCounts.active} active` },
|
|
22
|
+
{ text: `${presented.taskCounts.archived} archived${description}` },
|
|
23
|
+
];
|
|
24
|
+
}
|
|
17
25
|
return [{ text: presented.key }, { text: `${presented.name}${description}` }];
|
|
18
26
|
}));
|
|
19
27
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { TaskWithKey } from "@zinn-dev/core";
|
|
2
2
|
import type { PresentedRelation, PresentedRelationChange } from "../result-schemas.js";
|
|
3
|
+
import { relation } from "@zinn-dev/core";
|
|
4
|
+
export declare function presentRelationChange(entry: ReturnType<typeof relation.create>, source: TaskWithKey, target: TaskWithKey): PresentedRelationChange;
|
|
3
5
|
export declare function presentRelations(taskMatch: TaskWithKey): Array<PresentedRelation>;
|
|
4
6
|
export declare function formatRelationList(relations: Array<PresentedRelation>): string;
|
|
5
|
-
export declare function formatRelationChange(change: PresentedRelationChange, options: {
|
|
7
|
+
export declare function formatRelationChange(change: Pick<PresentedRelationChange, "type" | "source" | "target">, options: {
|
|
6
8
|
action: "create" | "delete";
|
|
9
|
+
} | {
|
|
10
|
+
action: "replace";
|
|
11
|
+
replaced: Array<PresentedRelationChange>;
|
|
7
12
|
}): string;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { column, relation } from "@zinn-dev/core";
|
|
2
2
|
import { columnNameCell } from "./column-presentation.js";
|
|
3
3
|
import { formatCellSeparator, formatRows } from "./row-layout.js";
|
|
4
|
+
export function presentRelationChange(entry, source, target) {
|
|
5
|
+
return {
|
|
6
|
+
id: entry.id,
|
|
7
|
+
type: entry.relation_type,
|
|
8
|
+
source: source.key,
|
|
9
|
+
source_task_id: source.id,
|
|
10
|
+
target: target.key,
|
|
11
|
+
target_task_id: target.id,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
4
14
|
export function presentRelations(taskMatch) {
|
|
5
15
|
return relation.getAll(taskMatch.key, { include: { tasks: true } }).map((entry) => {
|
|
6
16
|
const isSource = entry.source_task_id === taskMatch.id;
|
|
@@ -60,6 +70,10 @@ export function formatRelationList(relations) {
|
|
|
60
70
|
}));
|
|
61
71
|
}
|
|
62
72
|
export function formatRelationChange(change, options) {
|
|
73
|
+
if (options.action === "replace") {
|
|
74
|
+
const previous = options.replaced.map((entry) => formatRelationChange(entry, { action: "create" }));
|
|
75
|
+
return `Replace these relations:\n${previous.join("\n")}\nWith:\n${formatRelationChange(change, { action: "create" })}?`;
|
|
76
|
+
}
|
|
63
77
|
if (options.action === "delete") {
|
|
64
78
|
return `Deleted ${change.type} relation from ${change.source} to ${change.target}`;
|
|
65
79
|
}
|
|
@@ -10,7 +10,7 @@ export declare function formatCell(cell: RowCell, width?: number): string;
|
|
|
10
10
|
export declare function formatCellSeparator(): string;
|
|
11
11
|
/**
|
|
12
12
|
* Lines rows up by padding each cell's text to its column's **widest** text.
|
|
13
|
-
* Widths
|
|
13
|
+
* Widths count terminal cells, so wide text and emoji align with ASCII.
|
|
14
14
|
* A row's last cell holds free text such as a title and is left unpadded.
|
|
15
15
|
*
|
|
16
16
|
* With `indentsContinuationLines`, a last cell that spans several lines starts each later line
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { styleOutputText } from "./color.js";
|
|
2
|
+
import { displayWidth } from "./text-width.js";
|
|
2
3
|
const CELL_SEPARATOR = " | ";
|
|
3
4
|
const LINE_BREAK_PATTERN = /\r?\n/;
|
|
4
|
-
export function formatCell(cell, width = cell.text
|
|
5
|
-
const paddedText = cell.text.
|
|
5
|
+
export function formatCell(cell, width = displayWidth(cell.text)) {
|
|
6
|
+
const paddedText = `${cell.text}${" ".repeat(Math.max(0, width - displayWidth(cell.text)))}`;
|
|
6
7
|
if (cell.style == null) {
|
|
7
8
|
return paddedText;
|
|
8
9
|
}
|
|
@@ -19,7 +20,7 @@ function indentContinuationLines(text, indentWidth) {
|
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
21
22
|
* Lines rows up by padding each cell's text to its column's **widest** text.
|
|
22
|
-
* Widths
|
|
23
|
+
* Widths count terminal cells, so wide text and emoji align with ASCII.
|
|
23
24
|
* A row's last cell holds free text such as a title and is left unpadded.
|
|
24
25
|
*
|
|
25
26
|
* With `indentsContinuationLines`, a last cell that spans several lines starts each later line
|
|
@@ -30,7 +31,7 @@ export function formatRows(rows, options = {}) {
|
|
|
30
31
|
const columnWidths = [];
|
|
31
32
|
for (const row of rows) {
|
|
32
33
|
row.forEach((cell, columnIndex) => {
|
|
33
|
-
columnWidths[columnIndex] = Math.max(columnWidths[columnIndex] ?? 0, cell.text
|
|
34
|
+
columnWidths[columnIndex] = Math.max(columnWidths[columnIndex] ?? 0, displayWidth(cell.text));
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
37
|
return rows
|
|
@@ -38,7 +39,7 @@ export function formatRows(rows, options = {}) {
|
|
|
38
39
|
const lastCellIndex = row.length - 1;
|
|
39
40
|
const lastCellStartColumn = columnWidths
|
|
40
41
|
.slice(0, lastCellIndex)
|
|
41
|
-
.reduce((total, width) => total + width + CELL_SEPARATOR
|
|
42
|
+
.reduce((total, width) => total + width + displayWidth(CELL_SEPARATOR), 0);
|
|
42
43
|
return row
|
|
43
44
|
.map((cell, columnIndex) => {
|
|
44
45
|
if (columnIndex !== lastCellIndex) {
|
|
@@ -31,8 +31,11 @@ export function presentTask(taskMatch) {
|
|
|
31
31
|
title: taskMatch.title,
|
|
32
32
|
description: taskMatch.description,
|
|
33
33
|
priority: taskMatch.priority,
|
|
34
|
+
due_at: taskMatch.due_at ?? null,
|
|
34
35
|
labels: labels.map((label) => label.name),
|
|
35
36
|
label_ids: labels.map((label) => label.id),
|
|
37
|
+
created_at: taskMatch.created_at,
|
|
38
|
+
updated_at: taskMatch.updated_at,
|
|
36
39
|
};
|
|
37
40
|
}
|
|
38
41
|
export function formatTaskList(presentedTasks, options = {}) {
|
|
@@ -47,12 +50,15 @@ export function formatTaskList(presentedTasks, options = {}) {
|
|
|
47
50
|
.map((labelName) => formatCell(labelNameCell(labelName, labelColorsByName.get(labelName))))
|
|
48
51
|
.join(LABEL_NAME_SEPARATOR);
|
|
49
52
|
const labels = hasLabels ? `${formatCellSeparator()}${labelNames}` : "";
|
|
53
|
+
const deadline = presentedTask.due_at == null
|
|
54
|
+
? ""
|
|
55
|
+
: `${formatCellSeparator()}Due ${formatLocalTime(presentedTask.due_at, { includesSeconds: true })}`;
|
|
50
56
|
return [
|
|
51
57
|
{ text: `${options.prefix ?? ""}${presentedTask.key}` },
|
|
52
58
|
...statusCells,
|
|
53
59
|
columnNameCell(presentedTask.column),
|
|
54
60
|
taskPriorityCell(presentedTask.priority, options.showsFullPriority ?? false),
|
|
55
|
-
{ text: `${presentedTask.title}${labels}` },
|
|
61
|
+
{ text: `${presentedTask.title}${deadline}${labels}` },
|
|
56
62
|
];
|
|
57
63
|
}));
|
|
58
64
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const PRINTABLE_ASCII = /^[\x20-\x7e]*$/;
|
|
2
|
+
const ZERO_WIDTH_CODE_POINT = /^[\p{Mark}\p{Default_Ignorable_Code_Point}\p{Cc}]$/u;
|
|
3
|
+
// The constructor permits Unicode-set matching with the ES2023 declaration target.
|
|
4
|
+
const RGI_EMOJI = new RegExp("^\\p{RGI_Emoji}$", "v");
|
|
5
|
+
const segmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
6
|
+
export function graphemes(text) {
|
|
7
|
+
return segmenter.segment(text);
|
|
8
|
+
}
|
|
9
|
+
function isWideEastAsian(codePoint) {
|
|
10
|
+
// Unicode EastAsianWidth.txt lists the Hangul, CJK, kana, Yi and fullwidth blocks below.
|
|
11
|
+
// https://www.unicode.org/Public/18.0.0/ucd/EastAsianWidth.txt
|
|
12
|
+
return ((codePoint >= 0x1100 && codePoint <= 0x115f) ||
|
|
13
|
+
codePoint === 0x2329 ||
|
|
14
|
+
codePoint === 0x232a ||
|
|
15
|
+
(codePoint >= 0x2e80 && codePoint <= 0xa4cf) ||
|
|
16
|
+
(codePoint >= 0xac00 && codePoint <= 0xd7a3) ||
|
|
17
|
+
(codePoint >= 0xf900 && codePoint <= 0xfaff) ||
|
|
18
|
+
(codePoint >= 0xfe10 && codePoint <= 0xfe19) ||
|
|
19
|
+
(codePoint >= 0xfe30 && codePoint <= 0xfe6f) ||
|
|
20
|
+
(codePoint >= 0xff01 && codePoint <= 0xff60) ||
|
|
21
|
+
(codePoint >= 0xffe0 && codePoint <= 0xffe6) ||
|
|
22
|
+
(codePoint >= 0x1aff0 && codePoint <= 0x1afff) ||
|
|
23
|
+
(codePoint >= 0x1b000 && codePoint <= 0x1b2ff) ||
|
|
24
|
+
(codePoint >= 0x20000 && codePoint <= 0x3fffd));
|
|
25
|
+
}
|
|
26
|
+
export function displayWidth(text) {
|
|
27
|
+
if (PRINTABLE_ASCII.test(text)) {
|
|
28
|
+
return text.length;
|
|
29
|
+
}
|
|
30
|
+
let width = 0;
|
|
31
|
+
for (const { segment } of graphemes(text)) {
|
|
32
|
+
if ([...segment].every((point) => ZERO_WIDTH_CODE_POINT.test(point))) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (RGI_EMOJI.test(segment) || isWideEastAsian(segment.codePointAt(0))) {
|
|
36
|
+
width += 2;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
width += 1;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return width;
|
|
43
|
+
}
|
package/src/presentation/time.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const MINUTES_PER_HOUR = 60;
|
|
2
|
-
export function formatLocalTime(timestamp) {
|
|
2
|
+
export function formatLocalTime(timestamp, options = {}) {
|
|
3
3
|
const date = new Date(timestamp);
|
|
4
4
|
const offsetMinutes = -date.getTimezoneOffset();
|
|
5
5
|
const offsetSign = offsetMinutes >= 0 ? "+" : "-";
|
|
@@ -7,7 +7,10 @@ export function formatLocalTime(timestamp) {
|
|
|
7
7
|
const offsetHours = Math.floor(absoluteOffsetMinutes / MINUTES_PER_HOUR);
|
|
8
8
|
const remainingOffsetMinutes = absoluteOffsetMinutes % MINUTES_PER_HOUR;
|
|
9
9
|
const pad = (value) => String(value).padStart(2, "0");
|
|
10
|
+
const milliseconds = date.getMilliseconds();
|
|
11
|
+
const fraction = milliseconds === 0 ? "" : `.${String(milliseconds).padStart(3, "0")}`;
|
|
12
|
+
const seconds = options.includesSeconds ? `:${pad(date.getSeconds())}${fraction}` : "";
|
|
10
13
|
return (`${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ` +
|
|
11
|
-
`${pad(date.getHours())}:${pad(date.getMinutes())} ` +
|
|
14
|
+
`${pad(date.getHours())}:${pad(date.getMinutes())}${seconds} ` +
|
|
12
15
|
`${offsetSign}${pad(offsetHours)}:${pad(remainingOffsetMinutes)}`);
|
|
13
16
|
}
|
package/src/result-schemas.d.ts
CHANGED
|
@@ -12,8 +12,11 @@ export declare const taskSchema: z.ZodObject<{
|
|
|
12
12
|
title: z.ZodString;
|
|
13
13
|
description: z.ZodNullable<z.ZodString>;
|
|
14
14
|
priority: z.ZodNullable<z.ZodString>;
|
|
15
|
+
due_at: z.ZodNullable<z.ZodNumber>;
|
|
15
16
|
labels: z.ZodArray<z.ZodString>;
|
|
16
17
|
label_ids: z.ZodArray<z.ZodString>;
|
|
18
|
+
created_at: z.ZodNumber;
|
|
19
|
+
updated_at: z.ZodNumber;
|
|
17
20
|
}, z.core.$strict>;
|
|
18
21
|
export declare const relationSchema: z.ZodObject<{
|
|
19
22
|
id: z.ZodString;
|
|
@@ -92,6 +95,7 @@ export declare const taskDetailSchema: z.ZodObject<{
|
|
|
92
95
|
title: z.ZodString;
|
|
93
96
|
description: z.ZodNullable<z.ZodString>;
|
|
94
97
|
priority: z.ZodNullable<z.ZodString>;
|
|
98
|
+
due_at: z.ZodNullable<z.ZodNumber>;
|
|
95
99
|
labels: z.ZodArray<z.ZodString>;
|
|
96
100
|
label_ids: z.ZodArray<z.ZodString>;
|
|
97
101
|
created_at: z.ZodNumber;
|
|
@@ -138,6 +142,7 @@ export declare const taskDetailHistorySchema: z.ZodObject<{
|
|
|
138
142
|
title: z.ZodString;
|
|
139
143
|
description: z.ZodNullable<z.ZodString>;
|
|
140
144
|
priority: z.ZodNullable<z.ZodString>;
|
|
145
|
+
due_at: z.ZodNullable<z.ZodNumber>;
|
|
141
146
|
labels: z.ZodArray<z.ZodString>;
|
|
142
147
|
label_ids: z.ZodArray<z.ZodString>;
|
|
143
148
|
created_at: z.ZodNumber;
|
|
@@ -201,8 +206,11 @@ export declare const taskChangeSchema: z.ZodObject<{
|
|
|
201
206
|
title: z.ZodString;
|
|
202
207
|
description: z.ZodNullable<z.ZodString>;
|
|
203
208
|
priority: z.ZodNullable<z.ZodString>;
|
|
209
|
+
due_at: z.ZodNullable<z.ZodNumber>;
|
|
204
210
|
labels: z.ZodArray<z.ZodString>;
|
|
205
211
|
label_ids: z.ZodArray<z.ZodString>;
|
|
212
|
+
created_at: z.ZodNumber;
|
|
213
|
+
updated_at: z.ZodNumber;
|
|
206
214
|
changed: z.ZodBoolean;
|
|
207
215
|
}, z.core.$strict>;
|
|
208
216
|
export declare const projectSchema: z.ZodObject<{
|
|
@@ -218,6 +226,16 @@ export declare const projectChangeSchema: z.ZodObject<{
|
|
|
218
226
|
description: z.ZodNullable<z.ZodString>;
|
|
219
227
|
changed: z.ZodBoolean;
|
|
220
228
|
}, z.core.$strict>;
|
|
229
|
+
export declare const projectListEntrySchema: z.ZodObject<{
|
|
230
|
+
id: z.ZodString;
|
|
231
|
+
key: z.ZodString;
|
|
232
|
+
name: z.ZodString;
|
|
233
|
+
description: z.ZodNullable<z.ZodString>;
|
|
234
|
+
taskCounts: z.ZodObject<{
|
|
235
|
+
active: z.ZodNumber;
|
|
236
|
+
archived: z.ZodNumber;
|
|
237
|
+
}, z.core.$strict>;
|
|
238
|
+
}, z.core.$strict>;
|
|
221
239
|
export declare const columnSchema: z.ZodObject<{
|
|
222
240
|
id: z.ZodString;
|
|
223
241
|
project: z.ZodString;
|
|
@@ -457,8 +475,11 @@ export declare const resultSchemas: {
|
|
|
457
475
|
title: z.ZodString;
|
|
458
476
|
description: z.ZodNullable<z.ZodString>;
|
|
459
477
|
priority: z.ZodNullable<z.ZodString>;
|
|
478
|
+
due_at: z.ZodNullable<z.ZodNumber>;
|
|
460
479
|
labels: z.ZodArray<z.ZodString>;
|
|
461
480
|
label_ids: z.ZodArray<z.ZodString>;
|
|
481
|
+
created_at: z.ZodNumber;
|
|
482
|
+
updated_at: z.ZodNumber;
|
|
462
483
|
}, z.core.$strict>;
|
|
463
484
|
TaskList: z.ZodArray<z.ZodObject<{
|
|
464
485
|
id: z.ZodString;
|
|
@@ -473,8 +494,11 @@ export declare const resultSchemas: {
|
|
|
473
494
|
title: z.ZodString;
|
|
474
495
|
description: z.ZodNullable<z.ZodString>;
|
|
475
496
|
priority: z.ZodNullable<z.ZodString>;
|
|
497
|
+
due_at: z.ZodNullable<z.ZodNumber>;
|
|
476
498
|
labels: z.ZodArray<z.ZodString>;
|
|
477
499
|
label_ids: z.ZodArray<z.ZodString>;
|
|
500
|
+
created_at: z.ZodNumber;
|
|
501
|
+
updated_at: z.ZodNumber;
|
|
478
502
|
}, z.core.$strict>>;
|
|
479
503
|
TaskDetail: z.ZodObject<{
|
|
480
504
|
id: z.ZodString;
|
|
@@ -489,6 +513,7 @@ export declare const resultSchemas: {
|
|
|
489
513
|
title: z.ZodString;
|
|
490
514
|
description: z.ZodNullable<z.ZodString>;
|
|
491
515
|
priority: z.ZodNullable<z.ZodString>;
|
|
516
|
+
due_at: z.ZodNullable<z.ZodNumber>;
|
|
492
517
|
labels: z.ZodArray<z.ZodString>;
|
|
493
518
|
label_ids: z.ZodArray<z.ZodString>;
|
|
494
519
|
created_at: z.ZodNumber;
|
|
@@ -535,6 +560,7 @@ export declare const resultSchemas: {
|
|
|
535
560
|
title: z.ZodString;
|
|
536
561
|
description: z.ZodNullable<z.ZodString>;
|
|
537
562
|
priority: z.ZodNullable<z.ZodString>;
|
|
563
|
+
due_at: z.ZodNullable<z.ZodNumber>;
|
|
538
564
|
labels: z.ZodArray<z.ZodString>;
|
|
539
565
|
label_ids: z.ZodArray<z.ZodString>;
|
|
540
566
|
created_at: z.ZodNumber;
|
|
@@ -598,8 +624,11 @@ export declare const resultSchemas: {
|
|
|
598
624
|
title: z.ZodString;
|
|
599
625
|
description: z.ZodNullable<z.ZodString>;
|
|
600
626
|
priority: z.ZodNullable<z.ZodString>;
|
|
627
|
+
due_at: z.ZodNullable<z.ZodNumber>;
|
|
601
628
|
labels: z.ZodArray<z.ZodString>;
|
|
602
629
|
label_ids: z.ZodArray<z.ZodString>;
|
|
630
|
+
created_at: z.ZodNumber;
|
|
631
|
+
updated_at: z.ZodNumber;
|
|
603
632
|
changed: z.ZodBoolean;
|
|
604
633
|
}, z.core.$strict>;
|
|
605
634
|
TaskChanges: z.ZodArray<z.ZodObject<{
|
|
@@ -615,8 +644,11 @@ export declare const resultSchemas: {
|
|
|
615
644
|
title: z.ZodString;
|
|
616
645
|
description: z.ZodNullable<z.ZodString>;
|
|
617
646
|
priority: z.ZodNullable<z.ZodString>;
|
|
647
|
+
due_at: z.ZodNullable<z.ZodNumber>;
|
|
618
648
|
labels: z.ZodArray<z.ZodString>;
|
|
619
649
|
label_ids: z.ZodArray<z.ZodString>;
|
|
650
|
+
created_at: z.ZodNumber;
|
|
651
|
+
updated_at: z.ZodNumber;
|
|
620
652
|
changed: z.ZodBoolean;
|
|
621
653
|
}, z.core.$strict>>;
|
|
622
654
|
Relation: z.ZodObject<{
|
|
@@ -710,6 +742,10 @@ export declare const resultSchemas: {
|
|
|
710
742
|
key: z.ZodString;
|
|
711
743
|
name: z.ZodString;
|
|
712
744
|
description: z.ZodNullable<z.ZodString>;
|
|
745
|
+
taskCounts: z.ZodObject<{
|
|
746
|
+
active: z.ZodNumber;
|
|
747
|
+
archived: z.ZodNumber;
|
|
748
|
+
}, z.core.$strict>;
|
|
713
749
|
}, z.core.$strict>>;
|
|
714
750
|
ProjectView: z.ZodObject<{
|
|
715
751
|
id: z.ZodString;
|
|
@@ -962,18 +998,27 @@ export declare const resultSchemas: {
|
|
|
962
998
|
settingsPath: z.ZodOptional<z.ZodString>;
|
|
963
999
|
reason: z.ZodOptional<z.ZodEnum<{
|
|
964
1000
|
archived: "archived";
|
|
1001
|
+
dash_value: "dash_value";
|
|
1002
|
+
unknown_option: "unknown_option";
|
|
1003
|
+
unknown_command: "unknown_command";
|
|
1004
|
+
missing_command: "missing_command";
|
|
1005
|
+
missing_argument: "missing_argument";
|
|
1006
|
+
unexpected_argument: "unexpected_argument";
|
|
1007
|
+
unquoted_column: "unquoted_column";
|
|
965
1008
|
confirmation_required: "confirmation_required";
|
|
966
1009
|
invalid_json: "invalid_json";
|
|
967
1010
|
invalid_settings: "invalid_settings";
|
|
968
1011
|
invalid_storage: "invalid_storage";
|
|
969
1012
|
already_exists: "already_exists";
|
|
970
1013
|
parent_exists: "parent_exists";
|
|
1014
|
+
relation_changed: "relation_changed";
|
|
971
1015
|
cycle: "cycle";
|
|
972
1016
|
different_project: "different_project";
|
|
973
1017
|
different_column: "different_column";
|
|
974
1018
|
ambiguous_reference: "ambiguous_reference";
|
|
975
1019
|
text_match_count: "text_match_count";
|
|
976
1020
|
no_columns: "no_columns";
|
|
1021
|
+
has_tasks: "has_tasks";
|
|
977
1022
|
unmarked_database: "unmarked_database";
|
|
978
1023
|
newer_database: "newer_database";
|
|
979
1024
|
older_database: "older_database";
|
|
@@ -1111,8 +1156,8 @@ export declare const resultSchemas: {
|
|
|
1111
1156
|
}, z.core.$strict>;
|
|
1112
1157
|
effects: z.ZodObject<{
|
|
1113
1158
|
domain: z.ZodEnum<{
|
|
1114
|
-
read: "read";
|
|
1115
1159
|
create: "create";
|
|
1160
|
+
read: "read";
|
|
1116
1161
|
update: "update";
|
|
1117
1162
|
delete: "delete";
|
|
1118
1163
|
replace: "replace";
|
|
@@ -1120,11 +1165,11 @@ export declare const resultSchemas: {
|
|
|
1120
1165
|
}>;
|
|
1121
1166
|
storage: z.ZodEnum<{
|
|
1122
1167
|
backup: "backup";
|
|
1168
|
+
migrate: "migrate";
|
|
1169
|
+
reindex: "reindex";
|
|
1123
1170
|
none: "none";
|
|
1124
1171
|
"normal-open": "normal-open";
|
|
1125
1172
|
restore: "restore";
|
|
1126
|
-
migrate: "migrate";
|
|
1127
|
-
reindex: "reindex";
|
|
1128
1173
|
inspect: "inspect";
|
|
1129
1174
|
}>;
|
|
1130
1175
|
}, z.core.$strict>;
|
|
@@ -1176,6 +1221,7 @@ export type PresentedRelation = z.infer<typeof relationSchema>;
|
|
|
1176
1221
|
export type PresentedRelationChange = z.infer<typeof relationChangeSchema>;
|
|
1177
1222
|
export type PresentedComment = z.infer<typeof commentSchema>;
|
|
1178
1223
|
export type PresentedProject = z.infer<typeof projectSchema>;
|
|
1224
|
+
export type PresentedProjectListEntry = z.infer<typeof projectListEntrySchema>;
|
|
1179
1225
|
export type PresentedProjectView = z.infer<typeof projectViewSchema>;
|
|
1180
1226
|
export type PresentedColumn = z.infer<typeof columnSchema>;
|
|
1181
1227
|
export type PresentedColumnTaskCount = z.infer<typeof columnTaskCountSchema>;
|
package/src/result-schemas.js
CHANGED
|
@@ -19,8 +19,13 @@ export const taskSchema = z.strictObject({
|
|
|
19
19
|
.string()
|
|
20
20
|
.nullable()
|
|
21
21
|
.describe(`Known priorities: ${taskPrioritySchema.options.join(", ")}. Other stored values may occur.`),
|
|
22
|
+
due_at: timestamp
|
|
23
|
+
.nullable()
|
|
24
|
+
.describe("Exact deadline in epoch milliseconds, or null when unset."),
|
|
22
25
|
labels: z.array(z.string()).describe("Attached label names."),
|
|
23
26
|
label_ids: z.array(z.string()).describe("Attached label IDs, in the same order as labels."),
|
|
27
|
+
created_at: timestamp,
|
|
28
|
+
updated_at: timestamp,
|
|
24
29
|
});
|
|
25
30
|
export const relationSchema = z.strictObject({
|
|
26
31
|
id: z.string().describe("Stored relation ID."),
|
|
@@ -95,8 +100,6 @@ export const actorSchema = activitySchema.pick({
|
|
|
95
100
|
actor_effort: true,
|
|
96
101
|
});
|
|
97
102
|
export const taskDetailSchema = taskSchema.extend({
|
|
98
|
-
created_at: timestamp,
|
|
99
|
-
updated_at: timestamp,
|
|
100
103
|
relations: z.array(relationSchema),
|
|
101
104
|
comments: z.array(commentSchema),
|
|
102
105
|
});
|
|
@@ -117,6 +120,12 @@ export const projectSchema = z.strictObject({
|
|
|
117
120
|
export const projectChangeSchema = projectSchema.extend({
|
|
118
121
|
changed: z.boolean().describe("Whether the project's fields changed."),
|
|
119
122
|
});
|
|
123
|
+
export const projectListEntrySchema = projectSchema.extend({
|
|
124
|
+
taskCounts: z.strictObject({
|
|
125
|
+
active: count.describe("Unarchived tasks in any column."),
|
|
126
|
+
archived: count.describe("Archived tasks."),
|
|
127
|
+
}),
|
|
128
|
+
});
|
|
120
129
|
export const columnSchema = z.strictObject({
|
|
121
130
|
id: z.string().describe("Stored column ID."),
|
|
122
131
|
project: z.string(),
|
|
@@ -222,7 +231,7 @@ export const resultSchemas = {
|
|
|
222
231
|
CommentList: z.array(commentSchema),
|
|
223
232
|
Project: projectSchema,
|
|
224
233
|
ProjectChange: projectChangeSchema,
|
|
225
|
-
ProjectList: z.array(
|
|
234
|
+
ProjectList: z.array(projectListEntrySchema),
|
|
226
235
|
ProjectView: projectViewSchema,
|
|
227
236
|
Column: columnSchema,
|
|
228
237
|
ColumnChange: columnChangeSchema,
|