@wspc/cli 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +118 -25
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +52 -4
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/spec/openapi.json +215 -29
package/dist/cli.js
CHANGED
|
@@ -1206,9 +1206,9 @@ var ConfigStore = class {
|
|
|
1206
1206
|
};
|
|
1207
1207
|
|
|
1208
1208
|
// src/version.ts
|
|
1209
|
-
var VERSION = "0.0.
|
|
1210
|
-
var SPEC_SHA = "
|
|
1211
|
-
var SPEC_FETCHED_AT = "2026-06-
|
|
1209
|
+
var VERSION = "0.0.10";
|
|
1210
|
+
var SPEC_SHA = "e0b67542";
|
|
1211
|
+
var SPEC_FETCHED_AT = "2026-06-09T03:25:50.002Z";
|
|
1212
1212
|
var API_BASE = "https://api.wspc.ai";
|
|
1213
1213
|
|
|
1214
1214
|
// src/index.ts
|
|
@@ -1496,6 +1496,42 @@ function relativeTime(value, now = Date.now()) {
|
|
|
1496
1496
|
}
|
|
1497
1497
|
return future ? `in ${amount}${unit}` : `${amount}${unit} ago`;
|
|
1498
1498
|
}
|
|
1499
|
+
function wrapToWidth(text, width) {
|
|
1500
|
+
const limit = width > 0 ? width : 80;
|
|
1501
|
+
const out = [];
|
|
1502
|
+
for (const line of text.split("\n")) {
|
|
1503
|
+
if (line.length === 0) {
|
|
1504
|
+
out.push("");
|
|
1505
|
+
continue;
|
|
1506
|
+
}
|
|
1507
|
+
let cur = "";
|
|
1508
|
+
for (let word of line.split(" ")) {
|
|
1509
|
+
while (visibleWidth(word) > limit) {
|
|
1510
|
+
let head = "";
|
|
1511
|
+
for (const ch of word) {
|
|
1512
|
+
if (head && visibleWidth(head + ch) > limit) break;
|
|
1513
|
+
head += ch;
|
|
1514
|
+
if (visibleWidth(head) >= limit) break;
|
|
1515
|
+
}
|
|
1516
|
+
if (cur) {
|
|
1517
|
+
out.push(cur);
|
|
1518
|
+
cur = "";
|
|
1519
|
+
}
|
|
1520
|
+
out.push(head);
|
|
1521
|
+
word = word.slice(head.length);
|
|
1522
|
+
}
|
|
1523
|
+
const sep = cur ? " " : "";
|
|
1524
|
+
if (cur && visibleWidth(cur + sep + word) > limit) {
|
|
1525
|
+
out.push(cur);
|
|
1526
|
+
cur = word;
|
|
1527
|
+
} else {
|
|
1528
|
+
cur = cur + sep + word;
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
if (cur) out.push(cur);
|
|
1532
|
+
}
|
|
1533
|
+
return out;
|
|
1534
|
+
}
|
|
1499
1535
|
function table(headers, rows) {
|
|
1500
1536
|
if (rows.length === 0) {
|
|
1501
1537
|
return "";
|
|
@@ -1557,6 +1593,10 @@ function shouldOutputJson() {
|
|
|
1557
1593
|
}
|
|
1558
1594
|
return false;
|
|
1559
1595
|
}
|
|
1596
|
+
function termWidth() {
|
|
1597
|
+
const c = process.stdout.columns;
|
|
1598
|
+
return typeof c === "number" && c > 0 ? c : 80;
|
|
1599
|
+
}
|
|
1560
1600
|
function renderGeneric(data, hints) {
|
|
1561
1601
|
const shape = hints?.shape ?? detectShape(data);
|
|
1562
1602
|
if (shape === "list") {
|
|
@@ -1638,18 +1678,45 @@ function renderObject(data, hints) {
|
|
|
1638
1678
|
const arrayFields = hints?.fields ? [] : Object.keys(obj).filter(
|
|
1639
1679
|
(k) => Array.isArray(obj[k]) && obj[k].length > 0
|
|
1640
1680
|
);
|
|
1681
|
+
const formatted = fields.map((f) => [
|
|
1682
|
+
f,
|
|
1683
|
+
formatCell(obj[f], format[f], hints?.enumColorMap?.[f], { noTruncate: true })
|
|
1684
|
+
]);
|
|
1641
1685
|
const labelWidth = Math.max(
|
|
1642
|
-
...
|
|
1643
|
-
...arrayFields.map((f) => f.length)
|
|
1686
|
+
...formatted.map(([f]) => f.length),
|
|
1687
|
+
...arrayFields.map((f) => f.length),
|
|
1688
|
+
0
|
|
1644
1689
|
);
|
|
1645
|
-
|
|
1646
|
-
|
|
1690
|
+
const tw = termWidth();
|
|
1691
|
+
const avail = tw - (2 + labelWidth + 2);
|
|
1692
|
+
const inlineFinal = [];
|
|
1693
|
+
const blocks = [];
|
|
1694
|
+
for (const [f, value] of formatted) {
|
|
1695
|
+
if (value.includes("\n") || visibleWidth(value) > avail) {
|
|
1696
|
+
blocks.push([f, value]);
|
|
1697
|
+
} else {
|
|
1698
|
+
inlineFinal.push([f, value]);
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
for (const [f, value] of inlineFinal) {
|
|
1647
1702
|
process.stdout.write(` ${dim(f.padEnd(labelWidth))} ${value}
|
|
1648
1703
|
`);
|
|
1649
1704
|
}
|
|
1650
1705
|
for (const f of arrayFields) {
|
|
1651
|
-
|
|
1652
|
-
|
|
1706
|
+
const uncapped = f === "children" || f === "comments";
|
|
1707
|
+
const max = uncapped ? Number.POSITIVE_INFINITY : ARRAY_FIELD_MAX_ITEMS;
|
|
1708
|
+
renderArrayField(f, obj[f], labelWidth, max);
|
|
1709
|
+
}
|
|
1710
|
+
const hadAbove = inlineFinal.length > 0 || arrayFields.length > 0;
|
|
1711
|
+
blocks.forEach(([f, value], i) => {
|
|
1712
|
+
if (hadAbove || i > 0) process.stdout.write("\n");
|
|
1713
|
+
process.stdout.write(` ${dim(f)}
|
|
1714
|
+
`);
|
|
1715
|
+
for (const line of wrapToWidth(value, tw - 4)) {
|
|
1716
|
+
process.stdout.write(` ${line}
|
|
1717
|
+
`);
|
|
1718
|
+
}
|
|
1719
|
+
});
|
|
1653
1720
|
if (hints?.secretField) {
|
|
1654
1721
|
const value = obj[hints.secretField];
|
|
1655
1722
|
if (value !== void 0) {
|
|
@@ -1663,12 +1730,12 @@ function renderObject(data, hints) {
|
|
|
1663
1730
|
}
|
|
1664
1731
|
}
|
|
1665
1732
|
var ARRAY_FIELD_MAX_ITEMS = 10;
|
|
1666
|
-
function renderArrayField(name, items, labelWidth) {
|
|
1733
|
+
function renderArrayField(name, items, labelWidth, max = ARRAY_FIELD_MAX_ITEMS) {
|
|
1667
1734
|
const count = items.length;
|
|
1668
1735
|
const header = `${count} ${count === 1 ? "item" : "items"}`;
|
|
1669
1736
|
process.stdout.write(` ${dim(name.padEnd(labelWidth))} ${header}
|
|
1670
1737
|
`);
|
|
1671
|
-
const shown = items.slice(0,
|
|
1738
|
+
const shown = items.slice(0, max);
|
|
1672
1739
|
shown.forEach((item, i) => {
|
|
1673
1740
|
process.stdout.write(` ${dim(`${i + 1}.`)} ${formatArrayItem(item)}
|
|
1674
1741
|
`);
|
|
@@ -1681,10 +1748,31 @@ function renderArrayField(name, items, labelWidth) {
|
|
|
1681
1748
|
function formatArrayItem(item) {
|
|
1682
1749
|
if (item === null) return dim("null");
|
|
1683
1750
|
if (typeof item !== "object") return String(item);
|
|
1751
|
+
const todo = formatTodoLike(item);
|
|
1752
|
+
if (todo !== null) return todo;
|
|
1753
|
+
const comment = formatCommentLike(item);
|
|
1754
|
+
if (comment !== null) return comment;
|
|
1684
1755
|
const attendee = formatAttendeeLike(item);
|
|
1685
1756
|
if (attendee !== null) return attendee;
|
|
1686
1757
|
return JSON.stringify(item);
|
|
1687
1758
|
}
|
|
1759
|
+
function formatTodoLike(item) {
|
|
1760
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) return null;
|
|
1761
|
+
const rec = item;
|
|
1762
|
+
if (typeof rec.id !== "string" || typeof rec.title !== "string") return null;
|
|
1763
|
+
const id = idShort(rec.id);
|
|
1764
|
+
const status = typeof rec.status === "string" ? statusBadge(rec.status) : "";
|
|
1765
|
+
return status ? `${id} ${status} ${rec.title}` : `${id} ${rec.title}`;
|
|
1766
|
+
}
|
|
1767
|
+
function formatCommentLike(item) {
|
|
1768
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) return null;
|
|
1769
|
+
const rec = item;
|
|
1770
|
+
if (typeof rec.id !== "string" || typeof rec.content !== "string") return null;
|
|
1771
|
+
const id = idShort(rec.id);
|
|
1772
|
+
const when = rec.created_at !== void 0 ? `${relativeTime(rec.created_at)} ` : "";
|
|
1773
|
+
const snippet = truncate(rec.content, 60);
|
|
1774
|
+
return `${id} ${when}${snippet}`;
|
|
1775
|
+
}
|
|
1688
1776
|
function formatAttendeeLike(item) {
|
|
1689
1777
|
if (!item || typeof item !== "object" || Array.isArray(item)) return null;
|
|
1690
1778
|
const rec = item;
|
|
@@ -1711,7 +1799,7 @@ function renderScalar(data) {
|
|
|
1711
1799
|
function isScalar(v) {
|
|
1712
1800
|
return v === null || typeof v !== "object" && typeof v !== "function";
|
|
1713
1801
|
}
|
|
1714
|
-
function formatCell(value, fmt, colorMap) {
|
|
1802
|
+
function formatCell(value, fmt, colorMap, opts) {
|
|
1715
1803
|
if (fmt !== "enum-badge" && (value === void 0 || value === null)) return dim("\u2014");
|
|
1716
1804
|
switch (fmt) {
|
|
1717
1805
|
case "id-short":
|
|
@@ -1721,7 +1809,7 @@ function formatCell(value, fmt, colorMap) {
|
|
|
1721
1809
|
case "relative-time":
|
|
1722
1810
|
return relativeTime(value);
|
|
1723
1811
|
case "truncate":
|
|
1724
|
-
return truncate(String(value), 50);
|
|
1812
|
+
return opts?.noTruncate ? String(value) : truncate(String(value), 50);
|
|
1725
1813
|
case "bool-badge":
|
|
1726
1814
|
return boolBadge(value);
|
|
1727
1815
|
case "enum-badge": {
|
|
@@ -2630,12 +2718,12 @@ var todoCommentCreateCommand = new Command34("add").description("Add a comment t
|
|
|
2630
2718
|
process.exitCode = 1;
|
|
2631
2719
|
return;
|
|
2632
2720
|
}
|
|
2633
|
-
render({ kind: "todo_comment_create", display: { "shape": "object", "format": { "id": "id-short", "todo_id": "id-short", "user_id": "id-short", "
|
|
2721
|
+
render({ kind: "todo_comment_create", display: { "shape": "object", "format": { "id": "id-short", "todo_id": "id-short", "user_id": "id-short", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
|
|
2634
2722
|
});
|
|
2635
2723
|
|
|
2636
2724
|
// src/generated/cli/todo/comment/ls.ts
|
|
2637
2725
|
import { Command as Command35 } from "commander";
|
|
2638
|
-
var todoCommentListCommand = new Command35("ls").description("List comments on a todo").argument("<id>", "id").option("--order <value>", "order").option("--include-deleted <value>", "include_deleted").action(async (id, opts) => {
|
|
2726
|
+
var todoCommentListCommand = new Command35("ls").description("List comments on a todo").argument("<id>", "id").option("--order <value>", "order").option("--include-deleted <value>", "include_deleted").option("--limit <value>", "limit").option("--cursor <value>", "cursor").action(async (id, opts) => {
|
|
2639
2727
|
const client2 = await loadSdkClient();
|
|
2640
2728
|
const result = await todoCommentList({
|
|
2641
2729
|
client: client2._rawClient,
|
|
@@ -2644,7 +2732,9 @@ var todoCommentListCommand = new Command35("ls").description("List comments on a
|
|
|
2644
2732
|
},
|
|
2645
2733
|
query: {
|
|
2646
2734
|
order: opts.order,
|
|
2647
|
-
include_deleted: opts.includeDeleted
|
|
2735
|
+
include_deleted: opts.includeDeleted,
|
|
2736
|
+
limit: opts.limit,
|
|
2737
|
+
cursor: opts.cursor
|
|
2648
2738
|
}
|
|
2649
2739
|
});
|
|
2650
2740
|
if (result.error || !result.response?.ok) {
|
|
@@ -2748,12 +2838,12 @@ var todoCreateCommand = new Command39("add").description("Create a todo").argume
|
|
|
2748
2838
|
process.exitCode = 1;
|
|
2749
2839
|
return;
|
|
2750
2840
|
}
|
|
2751
|
-
render({ kind: "todo_create", display: { "shape": "object", "format": { "id": "id-short", "user_id": "id-short", "project_id": "id-short", "parent_id": "id-short", "type_id": "id-short", "
|
|
2841
|
+
render({ kind: "todo_create", display: { "shape": "object", "format": { "id": "id-short", "user_id": "id-short", "project_id": "id-short", "parent_id": "id-short", "type_id": "id-short", "status": "status-badge", "due_at": "relative-time", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
|
|
2752
2842
|
});
|
|
2753
2843
|
|
|
2754
2844
|
// src/generated/cli/todo/ls.ts
|
|
2755
2845
|
import { Command as Command40 } from "commander";
|
|
2756
|
-
var todoListCommand = new Command40("ls").description("List todos with filters").option("-p, --project <value>", "project_id").option("--user-id <value>", "user_id").option("--parent-id <value>", "parent_id").option("-s, --status <value>", "status").option("--include-deleted <value>", "include_deleted").option("--include-templates <value>", "include_templates").option("--due-after <value>", "due_after").option("--due-before <value>", "due_before").option("--type-id <value>", "type_id").option("--sort-by <value>", "sort_by").option("--order <value>", "order").option("--include-orphan-fields <value>", "include_orphan_fields").action(async (opts) => {
|
|
2846
|
+
var todoListCommand = new Command40("ls").description("List todos with filters").option("-p, --project <value>", "project_id").option("--user-id <value>", "user_id").option("--parent-id <value>", "parent_id").option("-s, --status <value>", "status").option("--include-deleted <value>", "include_deleted").option("--include-templates <value>", "include_templates").option("--due-after <value>", "due_after").option("--due-before <value>", "due_before").option("--type-id <value>", "type_id").option("--sort-by <value>", "sort_by").option("--order <value>", "order").option("--include-orphan-fields <value>", "include_orphan_fields").option("--limit <value>", "limit").option("--cursor <value>", "cursor").action(async (opts) => {
|
|
2757
2847
|
const client2 = await loadSdkClient();
|
|
2758
2848
|
const result = await todoList({
|
|
2759
2849
|
client: client2._rawClient,
|
|
@@ -2769,7 +2859,9 @@ var todoListCommand = new Command40("ls").description("List todos with filters")
|
|
|
2769
2859
|
type_id: opts.typeId,
|
|
2770
2860
|
sort_by: opts.sortBy,
|
|
2771
2861
|
order: opts.order,
|
|
2772
|
-
include_orphan_fields: opts.includeOrphanFields
|
|
2862
|
+
include_orphan_fields: opts.includeOrphanFields,
|
|
2863
|
+
limit: opts.limit,
|
|
2864
|
+
cursor: opts.cursor
|
|
2773
2865
|
}
|
|
2774
2866
|
});
|
|
2775
2867
|
if (result.error || !result.response?.ok) {
|
|
@@ -2824,7 +2916,7 @@ var todoCommentDeleteCommand = new Command42("rm").description("Soft-delete a co
|
|
|
2824
2916
|
process.exitCode = 1;
|
|
2825
2917
|
return;
|
|
2826
2918
|
}
|
|
2827
|
-
render({ kind: "todo_comment_delete", display: { "shape": "object", "format": { "id": "id-short", "todo_id": "id-short", "user_id": "id-short", "
|
|
2919
|
+
render({ kind: "todo_comment_delete", display: { "shape": "object", "format": { "id": "id-short", "todo_id": "id-short", "user_id": "id-short", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
|
|
2828
2920
|
});
|
|
2829
2921
|
|
|
2830
2922
|
// src/generated/cli/todo/comment/edit.ts
|
|
@@ -2848,7 +2940,7 @@ var todoCommentUpdateCommand = new Command43("edit").description("Edit a comment
|
|
|
2848
2940
|
process.exitCode = 1;
|
|
2849
2941
|
return;
|
|
2850
2942
|
}
|
|
2851
|
-
render({ kind: "todo_comment_update", display: { "shape": "object", "format": { "id": "id-short", "todo_id": "id-short", "user_id": "id-short", "
|
|
2943
|
+
render({ kind: "todo_comment_update", display: { "shape": "object", "format": { "id": "id-short", "todo_id": "id-short", "user_id": "id-short", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
|
|
2852
2944
|
});
|
|
2853
2945
|
|
|
2854
2946
|
// src/generated/cli/todo/rm.ts
|
|
@@ -2873,7 +2965,7 @@ var todoDeleteCommand = new Command44("rm").description("Soft-delete a todo").ar
|
|
|
2873
2965
|
process.exitCode = 1;
|
|
2874
2966
|
return;
|
|
2875
2967
|
}
|
|
2876
|
-
render({ kind: "todo_delete", display: { "shape": "object", "format": { "id": "id-short", "user_id": "id-short", "project_id": "id-short", "parent_id": "id-short", "type_id": "id-short", "
|
|
2968
|
+
render({ kind: "todo_delete", display: { "shape": "object", "format": { "id": "id-short", "user_id": "id-short", "project_id": "id-short", "parent_id": "id-short", "type_id": "id-short", "status": "status-badge", "due_at": "relative-time", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
|
|
2877
2969
|
});
|
|
2878
2970
|
|
|
2879
2971
|
// src/generated/cli/todo/show.ts
|
|
@@ -2887,7 +2979,8 @@ var todoGetCommand = new Command45("show").description("Get a todo by id").argum
|
|
|
2887
2979
|
},
|
|
2888
2980
|
query: {
|
|
2889
2981
|
include_deleted: opts.includeDeleted,
|
|
2890
|
-
include_orphan_fields: opts.includeOrphanFields
|
|
2982
|
+
include_orphan_fields: opts.includeOrphanFields,
|
|
2983
|
+
include: "children,comments"
|
|
2891
2984
|
}
|
|
2892
2985
|
});
|
|
2893
2986
|
if (result.error || !result.response?.ok) {
|
|
@@ -2898,7 +2991,7 @@ var todoGetCommand = new Command45("show").description("Get a todo by id").argum
|
|
|
2898
2991
|
process.exitCode = 1;
|
|
2899
2992
|
return;
|
|
2900
2993
|
}
|
|
2901
|
-
render({ kind: "todo_get", display: { "shape": "object", "format": { "id": "id-short", "user_id": "id-short", "project_id": "id-short", "parent_id": "id-short", "type_id": "id-short", "
|
|
2994
|
+
render({ kind: "todo_get", display: { "shape": "object", "format": { "id": "id-short", "user_id": "id-short", "project_id": "id-short", "parent_id": "id-short", "type_id": "id-short", "status": "status-badge", "due_at": "relative-time", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
|
|
2902
2995
|
});
|
|
2903
2996
|
|
|
2904
2997
|
// src/generated/cli/todo/update.ts
|
|
@@ -2930,7 +3023,7 @@ var todoUpdateCommand = new Command46("update").description("Update a todo").arg
|
|
|
2930
3023
|
process.exitCode = 1;
|
|
2931
3024
|
return;
|
|
2932
3025
|
}
|
|
2933
|
-
render({ kind: "todo_update", display: { "shape": "object", "format": { "id": "id-short", "user_id": "id-short", "project_id": "id-short", "parent_id": "id-short", "type_id": "id-short", "
|
|
3026
|
+
render({ kind: "todo_update", display: { "shape": "object", "format": { "id": "id-short", "user_id": "id-short", "project_id": "id-short", "parent_id": "id-short", "type_id": "id-short", "status": "status-badge", "due_at": "relative-time", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
|
|
2934
3027
|
});
|
|
2935
3028
|
|
|
2936
3029
|
// src/generated/cli/index.ts
|