@go-labs-sg/bb 1.0.3 → 1.0.4

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/commands.js CHANGED
@@ -67,6 +67,9 @@ export async function listApprovals(opts) {
67
67
  const notifications = await api.budget.getNotifications.query();
68
68
  const pending = notifications.filter(isPendingRequest);
69
69
  const raw = opts.type?.toUpperCase();
70
+ if (raw !== undefined && raw !== "ALL" && !isApprovalType(raw)) {
71
+ throw new Error("Invalid --type. Use one of: budget, supplier, bill, all.");
72
+ }
70
73
  const typeFilter = !opts.type || opts.type.toLowerCase() === "all"
71
74
  ? (_n) => true
72
75
  : (n) => raw !== undefined && isApprovalType(raw) && n.type === raw;
package/dist/index.js CHANGED
@@ -14,6 +14,15 @@ const BUDGET_STATUSES = [
14
14
  "ESTIMATE_REJECTED",
15
15
  "ESTIMATE_CLOSED",
16
16
  ];
17
+ function parsePositiveIntFlag(value, flagName) {
18
+ if (value === undefined)
19
+ return undefined;
20
+ const parsed = Number.parseInt(String(value), 10);
21
+ if (!Number.isFinite(parsed) || parsed <= 0) {
22
+ throw new Error(`${flagName} must be a positive integer.`);
23
+ }
24
+ return parsed;
25
+ }
17
26
  function printHelp() {
18
27
  const help = `
19
28
  bb — Budget Builder CLI (for AI agents / shell)
@@ -57,16 +66,18 @@ async function main() {
57
66
  switch (command) {
58
67
  case "list-budgets": {
59
68
  const statusStr = getFlag(flags, "status");
69
+ const statuses = statusStr !== undefined
70
+ ? String(statusStr)
71
+ .split(",")
72
+ .map((s) => s.trim())
73
+ .filter((s) => s.length > 0)
74
+ : undefined;
60
75
  await listBudgets({
61
76
  projectId: getFlag(flags, "projectId"),
62
77
  name: getFlag(flags, "name"),
63
- statuses: statusStr !== undefined
64
- ? String(statusStr)
65
- .split(",")
66
- .map((s) => s.trim())
67
- : undefined,
68
- page: getFlag(flags, "page", (s) => Number.parseInt(s, 10)),
69
- perPage: getFlag(flags, "perPage", (s) => Number.parseInt(s, 10)),
78
+ statuses,
79
+ page: parsePositiveIntFlag(getFlag(flags, "page"), "--page"),
80
+ perPage: parsePositiveIntFlag(getFlag(flags, "perPage"), "--perPage"),
70
81
  });
71
82
  break;
72
83
  }
@@ -101,8 +112,8 @@ async function main() {
101
112
  projectId: getFlag(flags, "projectId"),
102
113
  budgetId: getFlag(flags, "budgetId"),
103
114
  status: getFlag(flags, "status"),
104
- page: getFlag(flags, "page", (s) => Number.parseInt(s, 10)),
105
- pageSize: getFlag(flags, "pageSize", (s) => Number.parseInt(s, 10)),
115
+ page: parsePositiveIntFlag(getFlag(flags, "page"), "--page"),
116
+ pageSize: parsePositiveIntFlag(getFlag(flags, "pageSize"), "--pageSize"),
106
117
  });
107
118
  break;
108
119
  }
@@ -124,8 +135,8 @@ async function main() {
124
135
  case "list-suppliers": {
125
136
  await listSuppliers({
126
137
  name: getFlag(flags, "name"),
127
- page: getFlag(flags, "page", (s) => Number.parseInt(s, 10)),
128
- perPage: getFlag(flags, "perPage", (s) => Number.parseInt(s, 10)),
138
+ page: parsePositiveIntFlag(getFlag(flags, "page"), "--page"),
139
+ perPage: parsePositiveIntFlag(getFlag(flags, "perPage"), "--perPage"),
129
140
  });
130
141
  break;
131
142
  }
@@ -8,8 +8,15 @@ export function parseArgs(argv) {
8
8
  const flags = {};
9
9
  for (let i = 0; i < args.length; i++) {
10
10
  const arg = args[i];
11
- if (arg === undefined || arg === "--" || arg === "")
11
+ if (arg === undefined || arg === "")
12
12
  continue;
13
+ if (arg === "--") {
14
+ for (const rest of args.slice(i + 1)) {
15
+ if (rest !== "")
16
+ positional.push(rest);
17
+ }
18
+ break;
19
+ }
13
20
  if (arg.startsWith("--")) {
14
21
  const eq = arg.indexOf("=");
15
22
  if (eq > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-labs-sg/bb",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Budget Builder CLI — list budgets, bills, approvals, suppliers; approve bills; change status. For AI agents (e.g. Chuck/OpenClaw).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",