@freeticket/cli 0.13.1 → 0.15.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.
Files changed (3) hide show
  1. package/README.md +161 -1
  2. package/dist/index.js +1381 -165
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -119,15 +119,18 @@ ft sales list --status CONFIRMED --json
119
119
  | `ft reports by-event` · `timeseries` · `inventory` | Revenue/tickets by event, over time, and capacity/availability | VIEWER |
120
120
  | `ft reports export buyers\|attendees\|subscribers\|reconciliation` | Exports as CSV (filters `--event` `--event-date` `--from` `--to` `--status`) | ADMIN |
121
121
  | `ft reports reconciliation` · `financials` | CFO reconciliation (Mercado Pago vs sale vs Siigo invoice) · per-function P&L | ADMIN |
122
- | `ft settlements list` · `get <id>` · `document <id>` | Settlements paid to the organizer · signed download URL for the PDF, 5 min TTL (`--proof <fileName>` for a payment proof) | ADMIN |
122
+ | `ft settlements list` · `get <id>` · `document <id>` | Settlements paid to the organizer (`--kind EVENT\|MEMBERSHIP`, `--event`, `--status`; membership rows carry `period` / `membershipPlan`) · signed download URL for the PDF, 5 min TTL (`--proof <fileName>` for a payment proof) | ADMIN |
123
123
  | `ft content-videos list` · `content-posts list\|create` · `content-lives list\|get\|playback-token` | Organization content; `content-posts create --data` publishes a post or article | ADMIN |
124
124
  | `ft waitlist list [--city <name>]` · `waitlist create --data` | Per-city waitlist of an enterprise landing (export with personal data); `create` needs an enterprise service key | ADMIN |
125
+ | `ft courtesy-requests create --data '{"fullName":"…","email":"…","companion":{"fullName":"…"}}'` | Courtesy invitation request from an enterprise landing (enterprise service key; one per email, a resubmit is 409). The list lives in the dashboard (`/dashboard/cortesias`) | service key |
125
126
  | `ft merch products list` | Merch store products of the workspace's organization, DRAFT and PUBLISHED, with variants (Legend plan) | ADMIN / MERCH_MANAGER |
126
127
  | `ft merch products create` | Create product(s) as DRAFT: `--name` `--price <cop>` `--sizes XS,S,M` `--stock <n>` `--image <path>` (repeatable, uploaded through a signed URL) `--publish`; `--from-json <file>` for several (image paths relative to the file, no symlinks). The whole batch is validated first; `--json` prints `{ created, failed }` | ADMIN / MERCH_MANAGER |
127
128
  | `ft merch products images <id> --image <path>…` | Replace a product's photos with local files (repairs a partial `create`) | ADMIN / MERCH_MANAGER |
128
129
  | `ft merch products publish <id>` · `unpublish <id>` | Show / hide a product in the store (publishing needs the store setup done and an active variant) | ADMIN / MERCH_MANAGER |
129
130
  | `ft api-keys create <name>` · `list` · `revoke <id>` | Self-service API keys (the secret is shown once, never stored) | ADMIN |
130
131
  | `ft admin login` · `me` · `workspaces` · `users` · `plans` · `feature-flags` · `tokens` · `audit-log` | Superadmin, cross-tenant — needs a SUPER_ADMIN session, not an API key. Includes `admin workspaces plan <id>` (assisted plan assignment), `plan-show <id>` (current plan) and `delete <id>` (soft delete; suspend first) and `webTemplate` / `customDomain` on `update` | SUPER_ADMIN |
132
+ | `ft admin settlements list` · `get` · `upload` · `create` · `regenerate` · `attach` · `send` · `mark-paid` · `delete` | Organizer settlements across workspaces: create, send, mark as paid. See [`ft admin settlements`](#ft-admin-settlements) | SUPER_ADMIN |
133
+ | `ft admin crm campaigns` · `batches` · `events` · `options` · `quota` · `preview` · `launch` · `test-send` · `suppressions` · `organizations` · `people search` | Master CRM: email / WhatsApp campaigns to buyers across workspaces. See [`ft admin crm`](#ft-admin-crm) | SUPER_ADMIN |
131
134
 
132
135
  > **Write operations** (`create`/`update`/`delete` and actions like `publish`,
133
136
  > `cancel`, `refund`) send a JSON body via `--data <inline-json>` or
@@ -147,6 +150,161 @@ ft sales list --status CONFIRMED --json
147
150
  | `--csv` | list commands | CSV output for spreadsheets/accounting |
148
151
  | `--data <json>` `--yes` | write commands | JSON body (inline or `@file`) · skip delete confirmation |
149
152
 
153
+ ## `ft admin crm`
154
+
155
+ The master CRM for the internal team: email and WhatsApp campaigns to buyers,
156
+ across every workspace, against `/api/admin/crm`. It needs a SUPER_ADMIN
157
+ credential — `FT_ADMIN_TOKEN` (a service token from `ft admin tokens create`)
158
+ or `ft admin login --session`.
159
+
160
+ ```bash
161
+ ft admin crm campaigns list [--channel EMAIL|WHATSAPP] [--status S] [--limit N]
162
+ ft admin crm campaigns get <id>
163
+ ft admin crm campaigns cancel <id> [--yes]
164
+ ft admin crm batches next <id> [--ignore-window] [--yes]
165
+ ft admin crm batches stop <id> [--yes]
166
+ ft admin crm events search <query> [--purpose scope|promote|except] [--sender <workspaceId>]
167
+ ft admin crm events dates <eventId...>
168
+ ft admin crm options
169
+ ft admin crm quota
170
+ ft admin crm preview --filter @filter.json [--sender freeticket|<workspaceId>]
171
+ ft admin crm launch --data @campaign.json [--ignore-window] [--yes]
172
+ ft admin crm test-send --data @message.json [--sender freeticket|<workspaceId>] [--yes]
173
+ ft admin crm suppressions list [--query <email part>] [--scope global|all] [--limit 1-500]
174
+ ft admin crm suppressions add <email>
175
+ ft admin crm suppressions remove <email> [--yes]
176
+ ft admin crm organizations [query]
177
+ ft admin crm people search <query> [--scope '{"level":"orgs","workspaceIds":["…"]}']
178
+ ```
179
+
180
+ `test-send` sends the composed message, with subject `[Prueba]`, to **you**:
181
+ your email, or by WhatsApp the phone on your staff profile (it uses 1 of the
182
+ daily WhatsApp quota). It takes the same fields as `launch` minus the filter
183
+ and timing, asks first and sends `confirm: true`. `suppressions add` stops a
184
+ person from getting master CRM campaigns (idempotent; it does not touch an
185
+ organizer's own campaigns); `suppressions remove` re-enables them, asks first,
186
+ and only works on unsubscribes the team added (`reason: admin`). `people
187
+ search` returns the full email (what the filter's `people` condition takes);
188
+ `organizations` gives ids for `scope.level: "orgs"` or `sender.workspaceId`.
189
+
190
+ **Writes send real messages.** `launch`, `campaigns cancel`, `batches next` and
191
+ `batches stop` first show what they are about to touch — `launch` runs the
192
+ audience preview with the same filter and sender (total, how many have email
193
+ or reachable WhatsApp, the estimated days at the daily quota); the others show
194
+ the campaign — and then ask for confirmation. Without a TTY they refuse unless
195
+ you pass `--yes`. The CLI never retries a write on its own: if a `launch`
196
+ times out, check `campaigns list` before launching again (the backend rejects
197
+ the same channel + sender + subject within 10 minutes with
198
+ `DUPLICATE_CAMPAIGN` and prints the existing id).
199
+
200
+ Named errors get a next step: `OUTSIDE_SEND_WINDOW` (WhatsApp sends only
201
+ 9:00-20:00 Bogotá) prints when the window opens and suggests `--ignore-window` (on `batches next`, and on a
202
+ `launch` by WhatsApp with `timing.mode` `now`);
203
+ `QUOTA_EXHAUSTED` prints when the quota frees up; `INVALID_STATE` means the
204
+ campaign no longer allows that action; a 422 lists each `details[].path`; a 413 `PAYLOAD_TOO_LARGE` means the body is over
205
+ 256 KB.
206
+
207
+ Find the ids for a filter with `events search` and `events dates`, and the
208
+ cities, genre/format codes, plans and WhatsApp templates with `options`.
209
+
210
+ ### `filter.json` (audience filter v2)
211
+
212
+ ```json
213
+ {
214
+ "version": 2,
215
+ "scope": { "level": "platform" },
216
+ "include": [
217
+ { "type": "purchased", "eventIds": ["evt_123"], "window": { "kind": "last_days", "days": 90 } }
218
+ ],
219
+ "except": [
220
+ { "type": "received_campaign", "days": 7, "channel": "any" }
221
+ ]
222
+ }
223
+ ```
224
+
225
+ - `scope` (default `platform`): `{ "level": "orgs", "workspaceIds": [...] }` or
226
+ `{ "level": "events", "eventIds": [...] }`.
227
+ - `include` conditions combine with AND; `except` with OR, evaluated across the
228
+ whole platform. Up to 12 per block, 50 ids per list.
229
+ - Condition types: `purchased`, `abandoned`, `checked_in` (with optional
230
+ `eventIds`, `dateIds` + `dateEventIds`, `window`), `city` (`cities`),
231
+ `facet` (`dimension`: `genre` | `format`, `codes`), `membership` (`state`:
232
+ `active` | `expiring` | `cancelled`, `withinDays` for `expiring`, `planIds`),
233
+ `spend` (`minCop`, `maxCop`), `received_campaign` (`except` only: `days`,
234
+ `channel`), `people` (`include` only: `emails`).
235
+ - `window`: `{ "kind": "any" }` (default), `{ "kind": "last_days", "days": 7|30|90 }`
236
+ or `{ "kind": "range", "from": "2026-09-01", "to": "2026-09-30" }` (Bogotá dates).
237
+ - Without a state condition (`purchased`, `abandoned`, `checked_in`,
238
+ `membership`, `people`) in `include`, the audience defaults to confirmed
239
+ buyers plus active members.
240
+
241
+ ### `campaign.json`
242
+
243
+ ```json
244
+ {
245
+ "channel": "WHATSAPP",
246
+ "sender": { "kind": "freeticket" },
247
+ "templateName": "promo_show",
248
+ "subject": "New date in Medellín",
249
+ "body": "We just opened a second show. Get your tickets before they are gone.",
250
+ "promotedEventId": "evt_123",
251
+ "filter": {
252
+ "version": 2,
253
+ "include": [{ "type": "purchased", "eventIds": ["evt_123"] }],
254
+ "except": []
255
+ },
256
+ "timing": { "mode": "batches", "firstAt": "2026-11-03T10:00:00-05:00", "batchSize": 50, "perDay": 3, "intervalMinutes": 120 }
257
+ }
258
+ ```
259
+
260
+ - `sender`: `{ "kind": "freeticket" }` or `{ "kind": "organization", "workspaceId": "..." }`.
261
+ FreeTicket is mandatory when the scope spans the platform, several
262
+ organizations or events of more than one owner (`preview` tells you).
263
+ - WhatsApp needs an approved `templateName` (see `options`); email rejects one.
264
+ `imageUrl` for WhatsApp must come from the media library.
265
+ - `ignoreSendWindow` (or `--ignore-window`): WhatsApp with `timing.mode` `now`
266
+ only; sends even outside 9:00-20:00 Bogotá instead of failing with
267
+ `OUTSIDE_SEND_WINDOW`.
268
+ - `timing`: `{ "mode": "now" }` (sends on response), `{ "mode": "scheduled", "at": "<ISO with offset>" }`
269
+ or `batches` (WhatsApp only, daily cap 150 when FreeTicket signs, 200 for an
270
+ organization). WhatsApp times are moved into the 9:00-20:00 Bogotá window;
271
+ the response's `scheduledAt` is the real one.
272
+
273
+ ## `ft admin settlements`
274
+
275
+ Settlements of every organization for the internal team, against
276
+ `/api/admin/settlements` (admin contract 1.9). Same SUPER_ADMIN credential as
277
+ `ft admin crm`. `list` shows EVENT settlements only, like the panel.
278
+
279
+ ```bash
280
+ ft admin settlements list [--status S] [--organization <id>] [--all]
281
+ ft admin settlements get <id>
282
+ ft admin settlements upload <file.pdf> --organization <id> # prints storagePath
283
+ ft admin settlements create --data '{"mode":"auto","eventDateId":"…"}' [--yes]
284
+ ft admin settlements create --data @manual.json --pdf liquidacion.pdf [--yes]
285
+ ft admin settlements regenerate <id> [--commission-rate 2.9916] [--fixed-fee 500] [--yes]
286
+ ft admin settlements attach <id> --pdf <file> [--amount N] [--yes] # legacy DRAFT → GENERATED
287
+ ft admin settlements send <id> [--yes] # GENERATED → SENT, emails the organizer
288
+ ft admin settlements mark-paid <id> --proof a.pdf --proof b.pdf [--yes] # AWAITING_PAYMENT → PAID
289
+ ft admin settlements delete <id> [--yes]
290
+ ```
291
+
292
+ `get` and `list` cover event settlements only; a membership settlement id
293
+ returns 404 there. The organizer email on `send` and `mark-paid` is
294
+ best-effort: a 200 means the state changed, not that the email arrived, and a
295
+ retry returns 409 `INVALID_STATE` instead of resending.
296
+
297
+ **Every write moves money or notifies the organizer.** Each one shows the
298
+ settlement (or the body it will create) and asks; without a TTY it refuses
299
+ unless you pass `--yes`. `send`, `mark-paid` and `delete` send the contract's
300
+ `confirm: true` (`attach` only with `--amount`). PDFs (max 3 MB, checked for
301
+ `%PDF` locally) go up with `POST /settlements/files` after you confirm;
302
+ `--pdf` / `--proof` do that for you, or pass an already uploaded `storagePath`
303
+ (`attach --storage-path`, `mark-paid --proofs '[{"storagePath":…,"fileName":…}]'`).
304
+ `create` starts in GENERATED and does not notify anyone; a function with an
305
+ active settlement answers `DUPLICATE_SETTLEMENT` with the existing id. Nothing
306
+ is retried automatically.
307
+
150
308
  ## Configuration
151
309
 
152
310
  `ft` resolves configuration in this precedence order:
@@ -160,6 +318,8 @@ flags > environment variables > ~/.freeticket/config.json > defaults
160
318
  | `FT_API_URL` | `https://admin.appfreeticket.com` | API base URL (without `/api/v1`) |
161
319
  | `FT_API_KEY` | — | CI/headless only — a backend-issued `ft_live_...` token. Browser login (`ft login`) needs no key. When set it is the **only** account: stored logins are ignored, nothing fans out across them, and `--account` is rejected. A workspace pinned with `ft workspace use` still applies |
162
320
  | `FT_WORKSPACE_ID` | *home* | Default active workspace |
321
+ | `FT_ADMIN_TOKEN` | — | `ft admin` only — a platform service token (`ft admin tokens create`), sent as `Authorization: Bearer`. Takes precedence over the session cookie |
322
+ | `FT_ADMIN_SESSION` | — | `ft admin` only — a SUPER_ADMIN `better-auth.session_token` cookie (same as `ft admin login --session`) |
163
323
  | `FT_NO_UPDATE_CHECK` | — | Set to disable the "update available" notice (checked at most once a day; also off in CI, without a TTY, and with `--json`/`--raw`/`--csv`) |
164
324
 
165
325
  Logins are stored per account under `accounts` in `~/.freeticket/config.json`