@affonso/cli 0.1.1 → 0.1.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 +194 -0
- package/dist/index.js +1439 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# @affonso/cli
|
|
2
|
+
|
|
3
|
+
Command-line interface for the [Affonso](https://affonso.io) affiliate marketing platform. Manage affiliates, referrals, commissions, payouts, and program settings — from your terminal or through AI agents.
|
|
4
|
+
|
|
5
|
+
## Why a CLI?
|
|
6
|
+
|
|
7
|
+
The Affonso CLI is designed for two audiences:
|
|
8
|
+
|
|
9
|
+
- **Developers** who want to manage their affiliate program without leaving the terminal
|
|
10
|
+
- **AI agents** (OpenClaw, Paperclip, Claude, GPT, custom agents) that can use shell tools to build automated affiliate workflows — approving affiliates, tracking commissions, managing payouts, and more
|
|
11
|
+
|
|
12
|
+
Every command supports `--json` output, making it straightforward for agents to parse responses and chain commands together.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install -g @affonso/cli
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or run directly with npx:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx @affonso/cli <command>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Authentication
|
|
27
|
+
|
|
28
|
+
### OAuth (recommended)
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
affonso login
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Opens your browser for secure authentication via OAuth 2.1 with PKCE. Tokens are stored locally in `~/.config/affonso/auth.json`.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
affonso logout # revoke token and clear credentials
|
|
38
|
+
affonso whoami # show current auth status
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### API key
|
|
42
|
+
|
|
43
|
+
Pass it per-command, set it in your environment, or store it in the CLI config:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Per-command
|
|
47
|
+
affonso affiliates list --api-key sk_live_...
|
|
48
|
+
|
|
49
|
+
# Environment variable
|
|
50
|
+
export AFFONSO_API_KEY=sk_live_...
|
|
51
|
+
|
|
52
|
+
# Store in config
|
|
53
|
+
affonso config set api-key sk_live_...
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Auth priority: `--api-key` flag > `AFFONSO_API_KEY` env var > stored config > OAuth token.
|
|
57
|
+
|
|
58
|
+
## Usage
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
affonso <command> <subcommand> [options]
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Global options
|
|
65
|
+
|
|
66
|
+
| Option | Description |
|
|
67
|
+
|---|---|
|
|
68
|
+
| `--json` | Output as JSON |
|
|
69
|
+
| `--api-key <key>` | API key for this request |
|
|
70
|
+
| `--base-url <url>` | Custom API base URL |
|
|
71
|
+
| `--no-color` | Disable colored output |
|
|
72
|
+
| `--version` | Show version |
|
|
73
|
+
| `--help` | Show help |
|
|
74
|
+
|
|
75
|
+
### Commands
|
|
76
|
+
|
|
77
|
+
#### Affiliates
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
affonso affiliates list [--status pending|approved|rejected] [--search <query>] [--limit <n>] [--page <n>]
|
|
81
|
+
affonso affiliates get <id>
|
|
82
|
+
affonso affiliates create --name <name> --email <email> --program-id <id>
|
|
83
|
+
affonso affiliates update <id> [--name <name>] [--status <status>] [--email <email>]
|
|
84
|
+
affonso affiliates delete <id>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### Referrals
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
affonso referrals list [--affiliate-id <id>] [--status <status>] [--limit <n>]
|
|
91
|
+
affonso referrals get <id>
|
|
92
|
+
affonso referrals create --email <email> --affiliate-id <id>
|
|
93
|
+
affonso referrals update <id> [--status <status>] [--email <email>]
|
|
94
|
+
affonso referrals delete <id>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### Commissions
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
affonso commissions list [--status <status>] [--affiliate-id <id>] [--limit <n>] [--page <n>]
|
|
101
|
+
affonso commissions get <id>
|
|
102
|
+
affonso commissions create --referral-id <id> --sale-amount <n> --sale-amount-currency <code> --commission-amount <n> --commission-currency <code>
|
|
103
|
+
affonso commissions update <id> [--status <status>] [--sale-amount <n>]
|
|
104
|
+
affonso commissions delete <id>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### Coupons
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
affonso coupons list [--affiliate-id <id>] [--search <query>]
|
|
111
|
+
affonso coupons get <id>
|
|
112
|
+
affonso coupons create --affiliate-id <id> --code <code> --discount-type <type> --discount-value <n> --duration <dur>
|
|
113
|
+
affonso coupons delete <id>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### Payouts
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
affonso payouts list [--status <status>] [--affiliate-id <id>]
|
|
120
|
+
affonso payouts get <id>
|
|
121
|
+
affonso payouts update <id> --status <status>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### Clicks
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
affonso clicks create --program-id <id> --tracking-id <id> [--referrer <url>] [--utm-source <val>]
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
#### Embed tokens
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
affonso embed-tokens create [--affiliate-id <id>] [--email <email>]
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### Program settings
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
affonso program get
|
|
140
|
+
affonso program update [--name <name>] [--auto-approve] [--no-auto-approve]
|
|
141
|
+
|
|
142
|
+
# Sub-resources
|
|
143
|
+
affonso program payment-terms get|update
|
|
144
|
+
affonso program tracking get|update
|
|
145
|
+
affonso program restrictions get|update
|
|
146
|
+
affonso program fraud-rules get|update
|
|
147
|
+
affonso program portal get|update
|
|
148
|
+
affonso program notifications list|update <id>
|
|
149
|
+
affonso program groups list|get <id>|create|update <id>|delete <id>
|
|
150
|
+
affonso program creatives list|get <id>|create|update <id>|delete <id>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### Marketplace (public, no auth required)
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
affonso marketplace list [--category <cat>] [--search <query>]
|
|
157
|
+
affonso marketplace get <id>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
#### Config
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
affonso config get <key> # api-key, base-url
|
|
164
|
+
affonso config set <key> <value>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## JSON output
|
|
168
|
+
|
|
169
|
+
Add `--json` to any command for machine-readable output:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
affonso affiliates list --json
|
|
173
|
+
affonso affiliates get aff_123 --json
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
This is especially useful for AI agents that need to parse and act on the data programmatically.
|
|
177
|
+
|
|
178
|
+
## Use with AI agents
|
|
179
|
+
|
|
180
|
+
The CLI works as a tool for any AI agent that can execute shell commands. Set `AFFONSO_API_KEY` in the agent's environment and use `--json` for structured output:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
# An agent can list pending affiliates and approve them
|
|
184
|
+
affonso affiliates list --status pending --json
|
|
185
|
+
affonso affiliates update aff_123 --status approved --json
|
|
186
|
+
|
|
187
|
+
# Track and manage commissions
|
|
188
|
+
affonso commissions list --affiliate-id aff_123 --json
|
|
189
|
+
affonso payouts list --status pending --json
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## License
|
|
193
|
+
|
|
194
|
+
MIT
|