@order3000/cli 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Kolaveri Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,179 @@
1
+ # `order3000` — agent-friendly CLI for the order3000 platform
2
+
3
+ A strict, schema-validated command-line interface backed by the
4
+ [`order3000`](../order3000-nodejs) Node.js SDK. Every command is also a
5
+ deterministically-shaped JSON contract suitable for agents (Claude, CI bots,
6
+ internal scripts) to call without writing TypeScript.
7
+
8
+ The CLI's input schemas are generated end-to-end from the order3000 backend's
9
+ `ts-rest` contracts → `openapi.json` → SDK Zod schemas, so the validation a
10
+ caller sees on `order3000 orders place` matches what the backend will accept
11
+ byte-for-byte.
12
+
13
+ ---
14
+
15
+ ## Install via Homebrew (macOS — Apple Silicon or Intel)
16
+
17
+ This is the recommended path. The Homebrew binary bundles the Node runtime,
18
+ so you don't need to install Node yourself.
19
+
20
+ ```sh
21
+ # 1. Add the kolaveri-labs tap (one-time setup)
22
+ brew tap kolaveri-labs/tap
23
+
24
+ # 2. Install the CLI
25
+ brew install order3000
26
+
27
+ # 3. Verify
28
+ order3000 --version
29
+ ```
30
+
31
+ That's it. From here, `order3000` is on your `$PATH` like any other Homebrew
32
+ binary. To upgrade to the latest release later: `brew upgrade order3000`.
33
+
34
+ > **Linux Homebrew users**: the same two commands work. `brew tap …` then
35
+ > `brew install order3000`.
36
+
37
+ ### What if `--keychain` shows "OS keychain unavailable"?
38
+
39
+ The Homebrew binary cannot bundle native modules across architectures, so
40
+ the optional OS-keychain integration (`auth login --keychain`) is only
41
+ available when you install via npm:
42
+
43
+ ```sh
44
+ pnpm i -g @order3000/cli
45
+ ```
46
+
47
+ The default file-based credential storage works perfectly with the brew
48
+ binary — you only need the npm install if you specifically want secrets
49
+ in macOS Keychain / Linux libsecret.
50
+
51
+ ---
52
+
53
+ ## First run: `auth login`
54
+
55
+ ```sh
56
+ order3000 auth login --profile default
57
+ ```
58
+
59
+ You'll be prompted for the robot account's `clientId` and `clientSecret`.
60
+ The CLI verifies them against `/auth/token` before saving, so a typo
61
+ fails fast instead of poisoning the profile.
62
+
63
+ Profile lives at `~/.config/order3000/profiles.json` (file mode `0600`).
64
+ Cached JWT lives at `~/.cache/order3000/tokens.json` (also `0600`).
65
+
66
+ You can also drive the CLI entirely from environment variables — useful in
67
+ CI, scripts, and agent contexts:
68
+
69
+ ```sh
70
+ export ORDER3000_CLIENT_ID=robot_xxxxxx
71
+ export ORDER3000_CLIENT_SECRET=secret_xxxxxx
72
+ export ORDER3000_BASE_URL=https://order3000.com/api
73
+ order3000 auth whoami --json
74
+ ```
75
+
76
+ Resolution order (highest priority first): flags → env vars → profile in
77
+ `profiles.json` → OS keychain (npm install only).
78
+
79
+ ---
80
+
81
+ ## Quick start
82
+
83
+ ```sh
84
+ # Discover the command tree
85
+ order3000 --help
86
+ order3000 orders --help
87
+ order3000 orders get --help
88
+
89
+ # Read the strict JSON Schema for any command (input + output)
90
+ order3000 orders place --schema | jq
91
+
92
+ # Run a read-only command
93
+ order3000 orders getLatest --session-id <session-id> --json
94
+
95
+ # Run a mutating command (in non-TTY mode you must confirm with --yes)
96
+ order3000 orders place \
97
+ --basket-id <id> \
98
+ --session-id <id> \
99
+ --payment-method cash \
100
+ --fulfillment-type pickup \
101
+ --yes
102
+ ```
103
+
104
+ Output adapts automatically: pretty when stdout is a TTY, JSON otherwise.
105
+ Force JSON anywhere with `--json`.
106
+
107
+ ---
108
+
109
+ ## Command surface
110
+
111
+ | Group | Commands |
112
+ |---|---|
113
+ | `auth` | `login`, `logout`, `list`, `use`, `whoami` |
114
+ | `orders` | `getLatest`, `get`, `place`, `confirm` |
115
+ | `baskets` | `get`, `add`, `remove`, `getTotals`, `abandon`, `setDeclaredReturns` |
116
+ | `events` | `list`, `get`, `getByAccessor`, `place` |
117
+ | `menus` | `get`, `getByAccessor`, `getBundles`, `getSubscriptions` |
118
+ | `areas` | `list`, `getByAccessor`, `getAvailability`, `submitBookingRequest` |
119
+ | `reservations` | `make`, `get` |
120
+ | `paymentIntents` | `create`, `createDelta`, `reduceDelta` |
121
+ | `subscriptions` | `get`, `getByAccessor`, `subscribe`, `cancel`, `getCredits` |
122
+ | `teamOrders` | `create`, `get`, `join`, `submit`, `cancel`, `extendDeadline`, `setFulfillmentAt`, `setDiningLocation`, `setDiningTime`, `setOrderLeadSettled`, `autoExtendFulfillmentIfExpired`, `switchFulfillment`, `updateDeliveryAddress` |
123
+ | `system` | `ping` |
124
+
125
+ Every command honours these universal flags:
126
+
127
+ | Flag | Purpose |
128
+ |---|---|
129
+ | `--profile <name>` | Pick a non-default profile from `profiles.json` |
130
+ | `--client-id` / `--client-secret` / `--base-url` / `--venue-id` | Override credentials per-call |
131
+ | `--json`, `--format pretty\|json\|jsonl` | Output format (TTY-aware default) |
132
+ | `--schema` | Print the command's input + output JSON Schema and exit |
133
+ | `--yes` / `-y` | Confirm a mutating command in non-TTY mode |
134
+
135
+ Exit codes: `0` ok · `1` user error · `2` auth · `3` network · `4` server · `99` unexpected.
136
+
137
+ ---
138
+
139
+ ## Exit codes — agents please read
140
+
141
+ JSON-mode output goes to **stdout**; errors and human-friendly diagnostics
142
+ go to **stderr**. Always:
143
+
144
+ - Branch on the **exit code**, never on the presence of stderr text.
145
+ - Parse stdout as JSON when `--json` is passed (or when stdout is not a TTY,
146
+ which is the agent default).
147
+ - Use `--schema` once per command at startup to discover the expected input
148
+ and output shape; cache it.
149
+
150
+ ---
151
+
152
+ ## From source (this monorepo)
153
+
154
+ ```sh
155
+ # Build the SDK + CLI from a local checkout
156
+ pnpm --filter order3000 build
157
+ pnpm --filter @order3000/cli build
158
+
159
+ # Run the just-built binary
160
+ node apps/order3000-cli/dist/cli.js --help
161
+
162
+ # Or compile to a single-file native binary (this Mac)
163
+ pnpm --filter @order3000/cli build:binaries darwin-arm64
164
+ ./apps/order3000-cli/dist/binaries/order3000-darwin-arm64 --help
165
+ ```
166
+
167
+ ---
168
+
169
+ ## Schemas as a public contract
170
+
171
+ Every command's input + output JSON Schema is committed under
172
+ `schemas/v1/` and validated against generated output on every build
173
+ (`pnpm build:schemas:check`). Drift between the CLI's published contract
174
+ and the SDK's runtime is a build-time error, not a runtime surprise.
175
+
176
+ The schemas themselves derive from the order3000 backend's `ts-rest`
177
+ contracts (in `apps/order3000/src/app/api/openapi/contracts/`), which are
178
+ in turn derived from the Drizzle schema via `drizzle-zod`. There is one
179
+ source of truth.