@go-labs-sg/bb 1.0.1 → 1.0.3
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/README.md +57 -50
- package/dist/commands.js +14 -10
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,77 +1,84 @@
|
|
|
1
|
-
# bb
|
|
1
|
+
# bb
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Command-line interface for **Budget Builder**. Call budgets, bills, approvals, and suppliers from your terminal or from tools that don’t support MCP (e.g. some AI agents). Responses are JSON on stdout.
|
|
4
4
|
|
|
5
|
-
**
|
|
6
|
-
`workspace:*` only resolves inside your monorepo. When someone installs from npm (`npx @go-labs-sg/bb` or `npm i -g @go-labs-sg/bb`), their environment has no workspace, so the CLI is built with no runtime dependency on `@bb/api`, `@bb/db`, or `@bb/utils`. In the repo we keep `@bb/typescript-config` as a devDependency for typechecking; it is stripped from the tarball when publishing (or use a publish flow that omits workspace devDeps).
|
|
5
|
+
**Registry:** [`@go-labs-sg/bb`](https://www.npmjs.com/package/@go-labs-sg/bb)
|
|
7
6
|
|
|
8
|
-
##
|
|
7
|
+
## Requirements
|
|
9
8
|
|
|
10
|
-
-
|
|
11
|
-
-
|
|
9
|
+
- **Node.js** 18+
|
|
10
|
+
- A **Budget Builder API key** (same key used for the MCP server)
|
|
12
11
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
From the monorepo root:
|
|
12
|
+
## Install
|
|
16
13
|
|
|
17
14
|
```bash
|
|
18
|
-
|
|
19
|
-
bun run bb -- list-budgets
|
|
20
|
-
bun run bb -- get-budget <id>
|
|
21
|
-
bun run bb -- update-budget-status <id> <status>
|
|
22
|
-
bun run bb -- list-bills
|
|
23
|
-
bun run bb -- approve-bill <id>
|
|
24
|
-
bun run bb -- list-approvals
|
|
25
|
-
bun run bb -- list-suppliers
|
|
15
|
+
npm install -g @go-labs-sg/bb
|
|
26
16
|
```
|
|
27
17
|
|
|
28
|
-
Or
|
|
18
|
+
Or run without installing:
|
|
29
19
|
|
|
30
20
|
```bash
|
|
31
|
-
|
|
21
|
+
npx @go-labs-sg/bb <command>
|
|
32
22
|
```
|
|
33
23
|
|
|
34
|
-
##
|
|
24
|
+
## Authentication
|
|
35
25
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
| `list-bills` | List bills. Optional: `--projectId`, `--budgetId`, `--status`, `--page`, `--pageSize` |
|
|
42
|
-
| `approve-bill <id>` | Approve a pending bill |
|
|
43
|
-
| `list-approvals` | Pending approvals. Optional: `--type` (budget \| supplier \| bill \| all) |
|
|
44
|
-
| `list-suppliers` | List suppliers. Optional: `--name`, `--page`, `--perPage` |
|
|
26
|
+
Set your API key before running commands:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
export BB_API_KEY=<your-key>
|
|
30
|
+
```
|
|
45
31
|
|
|
46
|
-
|
|
32
|
+
Create or revoke keys in the web app: **Goracle → API Keys** (MCP API keys).
|
|
47
33
|
|
|
48
|
-
|
|
34
|
+
The CLI talks to the production API: `https://budget-builder.getout.events`.
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
49
37
|
|
|
50
38
|
```bash
|
|
51
|
-
|
|
52
|
-
# or
|
|
53
|
-
npm install -g @go-labs-sg/bb
|
|
39
|
+
bb help
|
|
54
40
|
bb list-budgets
|
|
41
|
+
bb get-budget <budget-id>
|
|
42
|
+
bb update-budget-status <budget-id> <status>
|
|
43
|
+
bb list-bills
|
|
44
|
+
bb approve-bill <bill-id>
|
|
45
|
+
bb list-approvals
|
|
46
|
+
bb list-suppliers
|
|
55
47
|
```
|
|
56
48
|
|
|
57
|
-
|
|
49
|
+
Global options and flags use `--key=value` or `--key value` (see `bb help`).
|
|
58
50
|
|
|
59
|
-
##
|
|
51
|
+
## Commands
|
|
52
|
+
|
|
53
|
+
| Command | Description |
|
|
54
|
+
| --- | --- |
|
|
55
|
+
| `list-budgets` | List budgets. Flags: `--projectId`, `--name`, `--status` (comma-separated), `--page`, `--perPage` |
|
|
56
|
+
| `get-budget <id>` | Budget details and line items |
|
|
57
|
+
| `update-budget-status <id> <status>` | Change budget status (e.g. `APPROVED`, `REJECTED`, `DRAFT`, …) |
|
|
58
|
+
| `list-bills` | List bills. Flags: `--projectId`, `--budgetId`, `--status`, `--page`, `--pageSize` |
|
|
59
|
+
| `approve-bill <id>` | Approve a pending bill (matches your pending bill approvals) |
|
|
60
|
+
| `list-approvals` | Pending approvals. Flag: `--type` = `budget`, `supplier`, `bill`, or `all` |
|
|
61
|
+
| `list-suppliers` | List suppliers. Flags: `--name`, `--page`, `--perPage` |
|
|
62
|
+
|
|
63
|
+
## Output
|
|
60
64
|
|
|
61
|
-
|
|
65
|
+
- **Stdout:** JSON (pretty-printed)
|
|
66
|
+
- **Stderr:** Error objects as JSON on failure
|
|
67
|
+
- **Exit code:** `0` on success, `1` on error
|
|
62
68
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
A `.env` file in the **current working directory** is loaded automatically (for `BB_API_KEY`, etc.).
|
|
70
|
+
|
|
71
|
+
## Developing in this repo
|
|
72
|
+
|
|
73
|
+
From the monorepo root:
|
|
67
74
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
bun run bb -- list-suppliers
|
|
73
|
-
```
|
|
75
|
+
```bash
|
|
76
|
+
export BB_API_KEY=...
|
|
77
|
+
bun run bb -- list-budgets
|
|
78
|
+
```
|
|
74
79
|
|
|
75
|
-
|
|
80
|
+
Or from `packages/cli`:
|
|
76
81
|
|
|
77
|
-
|
|
82
|
+
```bash
|
|
83
|
+
bun run src/index.ts list-budgets
|
|
84
|
+
```
|
package/dist/commands.js
CHANGED
|
@@ -2,6 +2,12 @@ import { api } from "./api-client.js";
|
|
|
2
2
|
const BUDGET = "BUDGET";
|
|
3
3
|
const BILL = "BILL";
|
|
4
4
|
const SUPPLIER = "SUPPLIER";
|
|
5
|
+
function isPendingRequest(n) {
|
|
6
|
+
return n.notificationType === "request" && n.status === "PENDING_APPROVAL";
|
|
7
|
+
}
|
|
8
|
+
function isApprovalType(s) {
|
|
9
|
+
return s === BUDGET || s === BILL || s === SUPPLIER;
|
|
10
|
+
}
|
|
5
11
|
const out = (data) => {
|
|
6
12
|
console.log(JSON.stringify(data, null, 2));
|
|
7
13
|
};
|
|
@@ -43,15 +49,13 @@ export async function listBills(opts) {
|
|
|
43
49
|
out(result);
|
|
44
50
|
}
|
|
45
51
|
export async function approveBill(billId) {
|
|
46
|
-
const notifications =
|
|
47
|
-
const pending = notifications.filter((n) => n
|
|
48
|
-
n.status === "PENDING_APPROVAL" &&
|
|
52
|
+
const notifications = await api.budget.getNotifications.query();
|
|
53
|
+
const pending = notifications.filter((n) => isPendingRequest(n) &&
|
|
49
54
|
n.type === BILL &&
|
|
50
55
|
(n.billId === billId || n.bill?.id === billId));
|
|
51
56
|
const approval = pending[0];
|
|
52
57
|
if (!approval) {
|
|
53
|
-
|
|
54
|
-
process.exit(1);
|
|
58
|
+
throw new Error("No pending bill approval found for this bill.");
|
|
55
59
|
}
|
|
56
60
|
const result = await api.bill.updateApproval.mutate({
|
|
57
61
|
billApprovalId: approval.id,
|
|
@@ -60,12 +64,12 @@ export async function approveBill(billId) {
|
|
|
60
64
|
out({ ...result, success: true, message: "Bill approved" });
|
|
61
65
|
}
|
|
62
66
|
export async function listApprovals(opts) {
|
|
63
|
-
const notifications =
|
|
64
|
-
const pending = notifications.filter(
|
|
65
|
-
const
|
|
67
|
+
const notifications = await api.budget.getNotifications.query();
|
|
68
|
+
const pending = notifications.filter(isPendingRequest);
|
|
69
|
+
const raw = opts.type?.toUpperCase();
|
|
66
70
|
const typeFilter = !opts.type || opts.type.toLowerCase() === "all"
|
|
67
|
-
? () => true
|
|
68
|
-
: (n) => n.type ===
|
|
71
|
+
? (_n) => true
|
|
72
|
+
: (n) => raw !== undefined && isApprovalType(raw) && n.type === raw;
|
|
69
73
|
const filtered = pending.filter(typeFilter);
|
|
70
74
|
const items = filtered.map((n) => {
|
|
71
75
|
let id;
|
package/dist/index.js
CHANGED
|
@@ -48,7 +48,7 @@ Output: JSON to stdout. Errors to stderr and exit code 1.
|
|
|
48
48
|
}
|
|
49
49
|
async function main() {
|
|
50
50
|
const { command, positional, flags } = parseArgs(process.argv);
|
|
51
|
-
if (!command || command === "help" || flags
|
|
51
|
+
if (!command || command === "help" || flags.help === true) {
|
|
52
52
|
printHelp();
|
|
53
53
|
process.exit(0);
|
|
54
54
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@go-labs-sg/bb",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
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",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"check:write": "biome check --write .",
|
|
19
19
|
"run": "bun run src/index.ts",
|
|
20
20
|
"prepublishOnly": "node scripts/strip-workspace-deps.js && bun run build",
|
|
21
|
-
"
|
|
21
|
+
"postpack": "node scripts/restore-package-json.js"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@trpc/client": "^11.10.0",
|