@freeticket/cli 0.10.0 → 0.11.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 +11 -7
  2. package/dist/index.js +342 -26
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -85,40 +85,44 @@ ft sales list --status CONFIRMED --json
85
85
 
86
86
  | Command | What it does | Minimum role |
87
87
  |---|---|---|
88
+ | `ft signup --email <e> --name <n>` | Create an account (`--workspace-name` also creates the first workspace); verify via email, then `ft login` | — |
88
89
  | `ft login` | Add an account: browser login (device flow), `--key <key>` for CI, `--account <name>` to name it (default: its email) | VIEWER |
89
90
  | `ft whoami` | User and accessible workspaces of every account in scope | VIEWER |
90
91
  | `ft account list` · `use <name>` · `clear` · `remove <name>` | Stored accounts: list, pin one, unpin (read all), remove | — |
91
92
  | `ft config` · `ft logout` | Show config (masked keys) · remove the pinned/only account (`--account <name>`, `--all`) | — |
92
93
  | `ft workspace list` · `use <id\|slug>` · `clear` · `show` | List workspaces of every account, pin one (and its account), unpin, show the current one | VIEWER |
94
+ | `ft workspace create --name <n> --slug <s>` | Create your own workspace; you become its ADMIN (plan quota applies) | — |
93
95
  | `ft events list` · `get <id>` | Workspace events (`--q` `--status` `--with-total`) | VIEWER |
94
96
  | `ft events create` · `update <id>` · `delete <id>` | Manage events (`--data <json>`) | ADMIN |
95
- | `ft events publish <id>` | Publish an event | ADMIN |
97
+ | `ft events publish <id>` · `cancel <id>` | Publish an event · cancel it and all its dates, keeping sales and tickets (no refunds; `--yes` skips the prompt) | ADMIN |
96
98
  | `ft event-dates list` · `create` · `update` · `delete` | Event dates | ADMIN |
97
99
  | `ft ticket-types list` · `get <id>` | Ticket types (`--event-date-id`) | VIEWER |
98
100
  | `ft ticket-types create` · `update <id>` · `delete <id>` | Manage ticket types (`--data <json>`) | ADMIN |
99
101
  | `ft sales list` · `get <id>` | Sales (filters: `--status` `--channel` `--event` `--event-date` `--reference` `--buyer` `--from` `--to`) | STAFF |
100
102
  | `ft sales create` | Create a sale/order — comps & programmatic sales (`--data <json>`) | ADMIN |
101
103
  | `ft sales cancel <id>` · `refund <id>` | Cancel / refund a sale (`--data` for the `acknowledge_open_payment` / `acknowledge_manual` flags) | ADMIN |
102
- | `ft sales tickets <id>` | List the individual tickets/attendees of a sale | STAFF |
104
+ | `ft sales tickets <id>` · `attempts <id>` | Tickets/attendees of a sale · its payment attempt history (why it did not go through) | STAFF |
103
105
  | `ft tickets access <code>` | Read a ticket's access status (no admit) | STAFF |
104
106
  | `ft tickets checkin <code>` | Admit a ticket at the door (idempotent) | STAFF |
105
107
  | `ft tickets resend <code>` | Resend the ticket's confirmation email (QR) | ADMIN |
108
+ | `ft tickets reassign <code>` | Move a sold ticket to another date and/or type (`--data '{"eventDateId":"…"}'`; no price difference charged/refunded) | ADMIN |
106
109
  | `ft plans list` · `get <id>` | Membership plans | VIEWER |
107
110
  | `ft plans create` · `update <id>` · `delete <id>` | Manage membership plans (`--data <json>`) | ADMIN |
108
111
  | `ft plans subscribers <id>` | List a plan's subscribers/members | VIEWER |
109
112
  | `ft subscriptions cancel <id>` | Cancel a subscription | ADMIN |
110
113
  | `ft discounts list` · `create` · `update <id>` · `delete <id>` | Discount codes / coupons (`--event` `--active`; `--data <json>`) | ADMIN |
111
- | `ft webhooks list` · `create` · `delete <id>` | Webhook endpoints, HMAC-signed delivery (`--data <json>`) | ADMIN |
114
+ | `ft webhooks list` · `create` · `update <id>` · `delete <id>` | Webhook endpoints, HMAC-signed delivery (`--data <json>`) | ADMIN |
112
115
  | `ft venues list` · `get <id>` | Venues | VIEWER |
113
116
  | `ft venues create` · `update <id>` · `delete <id>` | Manage venues (`--data <json>`) | ADMIN |
114
- | `ft staff list` · `create` · `set-role <id>` | Workspace staff (`--workspace-ids <ids>` lists up to 25 workspaces in one call; `--data <json>`) | ADMIN |
117
+ | `ft staff list` · `get <id>` · `create` · `set-role <id>` · `delete <id>` | Workspace staff (`--workspace-ids <ids>` lists up to 25 workspaces in one call; `--data <json>`) | ADMIN |
115
118
  | `ft reports summary` | KPIs (`--period 7d\|30d\|90d\|1y`) | VIEWER |
116
119
  | `ft reports by-event` · `timeseries` · `inventory` | Revenue/tickets by event, over time, and capacity/availability | VIEWER |
117
120
  | `ft reports export buyers\|attendees\|subscribers\|reconciliation` | Exports as CSV (filters `--event` `--event-date` `--from` `--to` `--status`) | ADMIN |
118
121
  | `ft reports reconciliation` · `financials` | CFO reconciliation (Mercado Pago vs sale vs Siigo invoice) · per-function P&L | ADMIN |
119
- | `ft settlements list` · `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 · signed download URL for the PDF, 5 min TTL (`--proof <fileName>` for a payment proof) | ADMIN |
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 |
120
124
  | `ft api-keys create <name>` · `list` · `revoke <id>` | Self-service API keys (the secret is shown once, never stored) | ADMIN |
121
- | `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) and `webTemplate` / `customDomain` on `update` | SUPER_ADMIN |
125
+ | `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 |
122
126
 
123
127
  > **Write operations** (`create`/`update`/`delete` and actions like `publish`,
124
128
  > `cancel`, `refund`) send a JSON body via `--data <inline-json>` or
@@ -151,7 +155,7 @@ flags > environment variables > ~/.freeticket/config.json > defaults
151
155
  | `FT_API_URL` | `https://admin.appfreeticket.com` | API base URL (without `/api/v1`) |
152
156
  | `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 |
153
157
  | `FT_WORKSPACE_ID` | *home* | Default active workspace |
154
- | `FT_NO_UPDATE_CHECK` | — | Set to disable the "update available" notice |
158
+ | `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`) |
155
159
 
156
160
  Logins are stored per account under `accounts` in `~/.freeticket/config.json`
157
161
  (`activeAccount` is the one pinned with `ft account use`). A file written by an
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // package.json
4
4
  var package_default = {
5
5
  name: "@freeticket/cli",
6
- version: "0.10.0",
6
+ version: "0.11.0",
7
7
  description: "Official FreeTicket CLI \u2014 consumes the B2B REST API for events, sales, tickets, memberships, venues, staff, and reports.",
8
8
  keywords: [
9
9
  "freeticket",
@@ -93,30 +93,36 @@ var CACHE_PATH = join(homedir(), ".freeticket", "update-check.json");
93
93
  var REGISTRY = "https://registry.npmjs.org/@freeticket/cli/latest";
94
94
  var ONE_DAY = 24 * 60 * 60 * 1e3;
95
95
  var FETCH_TIMEOUT = 1500;
96
- async function notifyUpdate(current) {
97
- if (!process.stderr.isTTY || process.env.FT_NO_UPDATE_CHECK || process.env.CI) {
98
- return;
99
- }
96
+ async function checkForUpdate(current, argv = process.argv) {
97
+ if (updateCheckDisabled(argv, process.env, Boolean(process.stderr.isTTY)))
98
+ return null;
100
99
  try {
101
100
  const latest = await getLatest();
102
101
  if (latest && isNewer(latest, current)) {
103
- process.stderr.write(
104
- `
102
+ return `
105
103
  ${chalk.yellow(`\u26A0 Update available: @freeticket/cli ${current} \u2192 ${latest}`)}
106
104
  ${chalk.dim(" npm i -g @freeticket/cli@latest \xB7 or use npx @freeticket/cli@latest")}
107
105
 
108
- `
109
- );
106
+ `;
110
107
  }
111
108
  } catch {
112
109
  }
110
+ return null;
111
+ }
112
+ function updateCheckDisabled(argv, env, isTTY) {
113
+ if (!isTTY || env.FT_NO_UPDATE_CHECK || env.CI) return true;
114
+ return argv.some((a) => a === "--json" || a === "--raw" || a === "--csv");
113
115
  }
114
116
  async function getLatest() {
115
117
  const cached = readCache();
116
- if (cached && Date.now() - cached.at < ONE_DAY) return cached.latest;
118
+ const now = Date.now();
119
+ if (cached && cached.at <= now && now - cached.at < ONE_DAY)
120
+ return cached.latest;
117
121
  const res = await fetch(REGISTRY, {
118
122
  signal: AbortSignal.timeout(FETCH_TIMEOUT),
119
- headers: { Accept: "application/vnd.npm.install-v1+json" }
123
+ // Not the abbreviated `application/vnd.npm.install-v1+json`: the
124
+ // `/latest` endpoint answers that with 406, so the notice never fired.
125
+ headers: { Accept: "application/json" }
120
126
  });
121
127
  if (!res.ok) throw new Error(`registry ${res.status}`);
122
128
  const latest = (await res.json()).version ?? null;
@@ -210,6 +216,36 @@ var postAuthDeviceToken = (options) => {
210
216
  }
211
217
  });
212
218
  };
219
+ var postAuthSignup = (options) => {
220
+ return (options.client ?? client).post({
221
+ url: "/auth/signup",
222
+ ...options,
223
+ headers: {
224
+ "Content-Type": "application/json",
225
+ ...options?.headers
226
+ }
227
+ });
228
+ };
229
+ var postWorkspaces = (options) => {
230
+ return (options.client ?? client).post({
231
+ security: [
232
+ {
233
+ name: "Authorization",
234
+ type: "apiKey"
235
+ },
236
+ {
237
+ name: "x-api-key",
238
+ type: "apiKey"
239
+ }
240
+ ],
241
+ url: "/workspaces",
242
+ ...options,
243
+ headers: {
244
+ "Content-Type": "application/json",
245
+ ...options?.headers
246
+ }
247
+ });
248
+ };
213
249
  var getMe = (options) => {
214
250
  return (options?.client ?? client).get({
215
251
  security: [
@@ -330,6 +366,22 @@ var postEventsIdPublish = (options) => {
330
366
  ...options
331
367
  });
332
368
  };
369
+ var postEventsIdCancel = (options) => {
370
+ return (options.client ?? client).post({
371
+ security: [
372
+ {
373
+ name: "Authorization",
374
+ type: "apiKey"
375
+ },
376
+ {
377
+ name: "x-api-key",
378
+ type: "apiKey"
379
+ }
380
+ ],
381
+ url: "/events/{id}/cancel",
382
+ ...options
383
+ });
384
+ };
333
385
  var deleteEventsIdDatesDateId = (options) => {
334
386
  return (options.client ?? client).delete({
335
387
  security: [
@@ -758,6 +810,38 @@ var postStaff = (options) => {
758
810
  }
759
811
  });
760
812
  };
813
+ var deleteStaffId = (options) => {
814
+ return (options.client ?? client).delete({
815
+ security: [
816
+ {
817
+ name: "Authorization",
818
+ type: "apiKey"
819
+ },
820
+ {
821
+ name: "x-api-key",
822
+ type: "apiKey"
823
+ }
824
+ ],
825
+ url: "/staff/{id}",
826
+ ...options
827
+ });
828
+ };
829
+ var getStaffId = (options) => {
830
+ return (options.client ?? client).get({
831
+ security: [
832
+ {
833
+ name: "Authorization",
834
+ type: "apiKey"
835
+ },
836
+ {
837
+ name: "x-api-key",
838
+ type: "apiKey"
839
+ }
840
+ ],
841
+ url: "/staff/{id}",
842
+ ...options
843
+ });
844
+ };
761
845
  var patchStaffIdRole = (options) => {
762
846
  return (options.client ?? client).patch({
763
847
  security: [
@@ -954,6 +1038,22 @@ var getSettlements = (options) => {
954
1038
  ...options
955
1039
  });
956
1040
  };
1041
+ var getSettlementsId = (options) => {
1042
+ return (options.client ?? client).get({
1043
+ security: [
1044
+ {
1045
+ name: "Authorization",
1046
+ type: "apiKey"
1047
+ },
1048
+ {
1049
+ name: "x-api-key",
1050
+ type: "apiKey"
1051
+ }
1052
+ ],
1053
+ url: "/settlements/{id}",
1054
+ ...options
1055
+ });
1056
+ };
957
1057
  var getDiscounts = (options) => {
958
1058
  return (options?.client ?? client).get({
959
1059
  security: [
@@ -1078,6 +1178,26 @@ var deleteWebhooksId = (options) => {
1078
1178
  ...options
1079
1179
  });
1080
1180
  };
1181
+ var patchWebhooksId = (options) => {
1182
+ return (options.client ?? client).patch({
1183
+ security: [
1184
+ {
1185
+ name: "Authorization",
1186
+ type: "apiKey"
1187
+ },
1188
+ {
1189
+ name: "x-api-key",
1190
+ type: "apiKey"
1191
+ }
1192
+ ],
1193
+ url: "/webhooks/{id}",
1194
+ ...options,
1195
+ headers: {
1196
+ "Content-Type": "application/json",
1197
+ ...options?.headers
1198
+ }
1199
+ });
1200
+ };
1081
1201
  var getMembershipPlansIdSubscribers = (options) => {
1082
1202
  return (options.client ?? client).get({
1083
1203
  security: [
@@ -1126,8 +1246,8 @@ var getSalesIdTickets = (options) => {
1126
1246
  ...options
1127
1247
  });
1128
1248
  };
1129
- var postTicketsTicketCodeResend = (options) => {
1130
- return (options.client ?? client).post({
1249
+ var getSalesIdAttempts = (options) => {
1250
+ return (options.client ?? client).get({
1131
1251
  security: [
1132
1252
  {
1133
1253
  name: "Authorization",
@@ -1138,10 +1258,30 @@ var postTicketsTicketCodeResend = (options) => {
1138
1258
  type: "apiKey"
1139
1259
  }
1140
1260
  ],
1141
- url: "/tickets/{ticketCode}/resend",
1261
+ url: "/sales/{id}/attempts",
1142
1262
  ...options
1143
1263
  });
1144
1264
  };
1265
+ var patchTicketsTicketCode = (options) => {
1266
+ return (options.client ?? client).patch({
1267
+ security: [
1268
+ {
1269
+ name: "Authorization",
1270
+ type: "apiKey"
1271
+ },
1272
+ {
1273
+ name: "x-api-key",
1274
+ type: "apiKey"
1275
+ }
1276
+ ],
1277
+ url: "/tickets/{ticketCode}",
1278
+ ...options,
1279
+ headers: {
1280
+ "Content-Type": "application/json",
1281
+ ...options?.headers
1282
+ }
1283
+ });
1284
+ };
1145
1285
  var postTicketsTicketCodeCheckin = (options) => {
1146
1286
  return (options.client ?? client).post({
1147
1287
  security: [
@@ -1155,7 +1295,11 @@ var postTicketsTicketCodeCheckin = (options) => {
1155
1295
  }
1156
1296
  ],
1157
1297
  url: "/tickets/{ticketCode}/checkin",
1158
- ...options
1298
+ ...options,
1299
+ headers: {
1300
+ "Content-Type": "application/json",
1301
+ ...options?.headers
1302
+ }
1159
1303
  });
1160
1304
  };
1161
1305
  var getTicketsTicketCodeAccess = (options) => {
@@ -1258,6 +1402,26 @@ var getContentPosts = (options) => {
1258
1402
  ...options
1259
1403
  });
1260
1404
  };
1405
+ var postContentPosts = (options) => {
1406
+ return (options.client ?? client).post({
1407
+ security: [
1408
+ {
1409
+ name: "Authorization",
1410
+ type: "apiKey"
1411
+ },
1412
+ {
1413
+ name: "x-api-key",
1414
+ type: "apiKey"
1415
+ }
1416
+ ],
1417
+ url: "/content/posts",
1418
+ ...options,
1419
+ headers: {
1420
+ "Content-Type": "application/json",
1421
+ ...options?.headers
1422
+ }
1423
+ });
1424
+ };
1261
1425
  var getContentLives = (options) => {
1262
1426
  return (options?.client ?? client).get({
1263
1427
  security: [
@@ -1310,6 +1474,22 @@ var postContentPlaybackToken = (options) => {
1310
1474
  }
1311
1475
  });
1312
1476
  };
1477
+ var postTicketsTicketCodeResend = (options) => {
1478
+ return (options.client ?? client).post({
1479
+ security: [
1480
+ {
1481
+ name: "Authorization",
1482
+ type: "apiKey"
1483
+ },
1484
+ {
1485
+ name: "x-api-key",
1486
+ type: "apiKey"
1487
+ }
1488
+ ],
1489
+ url: "/tickets/{ticketCode}/resend",
1490
+ ...options
1491
+ });
1492
+ };
1313
1493
 
1314
1494
  // src/commands/account.ts
1315
1495
  import chalk4 from "chalk";
@@ -1797,6 +1977,31 @@ function registerAuth(program2) {
1797
1977
  }
1798
1978
  print(me, { json: opts.json });
1799
1979
  });
1980
+ program2.command("signup").description(
1981
+ "Create a FreeTicket account (sends a verification email; then run `ft login`)"
1982
+ ).requiredOption("--email <email>", "account email").requiredOption("--name <name>", "your name").option(
1983
+ "--workspace-name <name>",
1984
+ "also create your first workspace (free Spark plan)"
1985
+ ).option(
1986
+ "--url <url>",
1987
+ "API base URL (default: https://admin.appfreeticket.com)"
1988
+ ).option("--json", "raw JSON output").action(async (opts) => {
1989
+ const apiUrl = (opts.url ?? process.env.FT_API_URL ?? readConfig().apiUrl ?? DEFAULT_API_URL).replace(/\/$/, "");
1990
+ client.setConfig({ baseUrl: `${apiUrl}/api/v1` });
1991
+ const body = unwrap(
1992
+ await postAuthSignup({
1993
+ body: {
1994
+ email: opts.email,
1995
+ name: opts.name,
1996
+ ...opts.workspaceName ? { workspaceName: opts.workspaceName } : {}
1997
+ }
1998
+ })
1999
+ );
2000
+ console.error(
2001
+ `${chalk3.green("\u2713")} Check ${chalk3.bold(opts.email)} to verify the account and set a password, then run ${chalk3.cyan("ft login")}.`
2002
+ );
2003
+ print(body, { json: opts.json });
2004
+ });
1800
2005
  program2.command("whoami").description(
1801
2006
  "Show the authenticated user and workspaces (GET /me), for every account in scope"
1802
2007
  ).option("--account <name>", "only this account (default: all stored)").option("--json", "raw JSON output").action(async (opts) => {
@@ -2035,7 +2240,7 @@ var getWorkspaces = (options) => {
2035
2240
  ...options
2036
2241
  });
2037
2242
  };
2038
- var postWorkspaces = (options) => {
2243
+ var postWorkspaces2 = (options) => {
2039
2244
  return (options.client ?? client2).post({
2040
2245
  security: [
2041
2246
  {
@@ -2052,6 +2257,19 @@ var postWorkspaces = (options) => {
2052
2257
  }
2053
2258
  });
2054
2259
  };
2260
+ var deleteWorkspacesId = (options) => {
2261
+ return (options.client ?? client2).delete({
2262
+ security: [
2263
+ {
2264
+ in: "cookie",
2265
+ name: "better-auth.session_token",
2266
+ type: "apiKey"
2267
+ }
2268
+ ],
2269
+ url: "/workspaces/{id}",
2270
+ ...options
2271
+ });
2272
+ };
2055
2273
  var getWorkspacesId = (options) => {
2056
2274
  return (options.client ?? client2).get({
2057
2275
  security: [
@@ -2082,6 +2300,19 @@ var patchWorkspacesId = (options) => {
2082
2300
  }
2083
2301
  });
2084
2302
  };
2303
+ var getWorkspacesIdPlan = (options) => {
2304
+ return (options.client ?? client2).get({
2305
+ security: [
2306
+ {
2307
+ in: "cookie",
2308
+ name: "better-auth.session_token",
2309
+ type: "apiKey"
2310
+ }
2311
+ ],
2312
+ url: "/workspaces/{id}/plan",
2313
+ ...options
2314
+ });
2315
+ };
2085
2316
  var postWorkspacesIdPlan = (options) => {
2086
2317
  return (options.client ?? client2).post({
2087
2318
  security: [
@@ -2456,7 +2687,7 @@ function registerAdmin(program2) {
2456
2687
  describe: "Tenants / workspaces",
2457
2688
  list: getWorkspaces,
2458
2689
  get: getWorkspacesId,
2459
- create: postWorkspaces,
2690
+ create: postWorkspaces2,
2460
2691
  update: patchWorkspacesId,
2461
2692
  actions: [
2462
2693
  {
@@ -2479,6 +2710,23 @@ function registerAdmin(program2) {
2479
2710
  fn: postWorkspacesIdPlan,
2480
2711
  body: true,
2481
2712
  confirm: true
2713
+ },
2714
+ {
2715
+ // `plan <id>` is the POST that assigns one, so the read gets its own
2716
+ // verb. `stripeLinked: true` means `plan` will cancel that Stripe
2717
+ // subscription first.
2718
+ name: "plan-show",
2719
+ describe: "Current plan and subscription of a workspace",
2720
+ fn: getWorkspacesIdPlan
2721
+ },
2722
+ {
2723
+ // Soft delete: sets deletedAt, keeps sales/buyers/tickets. The
2724
+ // backend requires the workspace to be suspended first and to have no
2725
+ // CONFIRMED sale (409 otherwise). Does not cancel Stripe.
2726
+ name: "delete",
2727
+ describe: "Soft-delete a workspace (must be suspended first, no confirmed sales)",
2728
+ fn: deleteWorkspacesId,
2729
+ confirm: true
2482
2730
  }
2483
2731
  ],
2484
2732
  columns: ["id", "name", "type", "country", "suspended", "createdAt"],
@@ -2648,11 +2896,11 @@ function registerAdminResource(parent, spec) {
2648
2896
  });
2649
2897
  }
2650
2898
  if (spec.update) {
2651
- const update = spec.update;
2899
+ const update2 = spec.update;
2652
2900
  root.command("update <id>").description(`Update a ${singular} by id`).requiredOption("--data <json>", "JSON body (inline or @file.json)").option("--json", "raw JSON output").action(async (id, opts) => {
2653
2901
  configureAdminClient();
2654
2902
  const body = unwrap(
2655
- await update({ path: { id }, body: parseData(opts.data) })
2903
+ await update2({ path: { id }, body: parseData(opts.data) })
2656
2904
  );
2657
2905
  print(body?.data ?? body, { json: opts.json });
2658
2906
  });
@@ -2970,6 +3218,8 @@ function registerReports(program2) {
2970
3218
  for (const [name, fn, label] of [
2971
3219
  ["buyers", getReportsExportsBuyers, "buyers (one row per sale)"],
2972
3220
  ["attendees", getReportsExportsAttendees, "attendees (one row per ticket)"]
3221
+ // The two responses differ in row shape since the contract typed them
3222
+ // (1.19); printExport only needs rows, so they share one signature here.
2973
3223
  ]) {
2974
3224
  exp.command(name).description(`Export ${label}`).option("--event <id>", "filter by event").option("--event-date <id>", "filter by event date").option("--from <date>", "created from (ISO 8601)").option("--to <date>", "created to (ISO 8601)").option("--status <s>", "filter by sale status").option(
2975
3225
  "--workspace <id>",
@@ -3171,14 +3421,14 @@ function registerResource(program2, spec) {
3171
3421
  });
3172
3422
  }
3173
3423
  if (spec.update) {
3174
- const update = spec.update;
3424
+ const update2 = spec.update;
3175
3425
  root.command("update <id>").description(`Update a ${singular} by id`).requiredOption("--data <json>", "JSON body (inline or @file.json)").option(
3176
3426
  "--workspace <id>",
3177
3427
  "read only this workspace (default: all you can access)"
3178
3428
  ).option("--json", "raw JSON output").action(async (id, opts) => {
3179
3429
  configureClient(opts.workspace);
3180
3430
  const body = unwrap(
3181
- await update({ path: { id }, body: parseData(opts.data) })
3431
+ await update2({ path: { id }, body: parseData(opts.data) })
3182
3432
  );
3183
3433
  print(body.data ?? body, { json: opts.json });
3184
3434
  });
@@ -3203,7 +3453,10 @@ function registerResource(program2, spec) {
3203
3453
  if (action.body) {
3204
3454
  cmd.option("--data <json>", "JSON body (inline or @file.json)");
3205
3455
  }
3456
+ if (action.confirm) cmd.option("--yes", "skip confirmation");
3206
3457
  cmd.action(async (id, opts) => {
3458
+ if (action.confirm)
3459
+ await confirmOrExit(`${action.name} ${singular} ${id}?`, opts.yes);
3207
3460
  configureClient(opts.workspace);
3208
3461
  const payload = { path: { id } };
3209
3462
  if (action.body && opts.data) payload.body = parseData(opts.data);
@@ -3219,7 +3472,9 @@ function camel2(s) {
3219
3472
 
3220
3473
  // src/commands/tickets.ts
3221
3474
  function registerTickets(program2) {
3222
- const root = program2.command("tickets").description("Individual tickets: door check-in, access status, QR resend");
3475
+ const root = program2.command("tickets").description(
3476
+ "Individual tickets: door check-in, access status, QR resend, reassign"
3477
+ );
3223
3478
  root.command("access <code>").description("Read a ticket's access status without admitting it").option("--workspace <id>", "workspace override").option("--json", "raw JSON output").action(async (code, opts) => {
3224
3479
  configureClient(opts.workspace);
3225
3480
  const body = unwrap(
@@ -3232,7 +3487,12 @@ function registerTickets(program2) {
3232
3487
  ).option("--workspace <id>", "workspace override").option("--json", "raw JSON output").action(async (code, opts) => {
3233
3488
  configureClient(opts.workspace);
3234
3489
  const body = unwrap(
3235
- await postTicketsTicketCodeCheckin({ path: { ticketCode: code } })
3490
+ // The contract marks the body required since 1.19 (optional `source`
3491
+ // of the scanned QR); the backend accepts it empty.
3492
+ await postTicketsTicketCodeCheckin({
3493
+ path: { ticketCode: code },
3494
+ body: {}
3495
+ })
3236
3496
  );
3237
3497
  print(body.data ?? body, { json: opts.json });
3238
3498
  });
@@ -3243,12 +3503,24 @@ function registerTickets(program2) {
3243
3503
  );
3244
3504
  print(body.data ?? body, { json: opts.json });
3245
3505
  });
3506
+ root.command("reassign <code>").description(
3507
+ `Move a sold ticket to another date/type (--data '{"eventDateId":"\u2026"}' and/or "ticketTypeId", "seatLabel")`
3508
+ ).requiredOption("--data <json>", "JSON body (inline or @file.json)").option("--workspace <id>", "workspace override").option("--json", "raw JSON output").action(async (code, opts) => {
3509
+ configureClient(opts.workspace);
3510
+ const body = unwrap(
3511
+ await patchTicketsTicketCode({
3512
+ path: { ticketCode: code },
3513
+ body: parseData(opts.data)
3514
+ })
3515
+ );
3516
+ print(body.data ?? body, { json: opts.json });
3517
+ });
3246
3518
  }
3247
3519
 
3248
3520
  // src/commands/workspace.ts
3249
3521
  import chalk8 from "chalk";
3250
3522
  function registerWorkspace(program2) {
3251
- const root = program2.command("workspace").description("List, pin, unpin, and show workspaces");
3523
+ const root = program2.command("workspace").description("List, pin, unpin, show, and create workspaces");
3252
3524
  root.command("list").alias("ls").description(
3253
3525
  "List the workspaces you can access, across every account in scope (marks the pinned one)"
3254
3526
  ).option("--account <name>", "only this account (default: all stored)").option("--json", "raw JSON output").action(async (opts) => {
@@ -3357,6 +3629,20 @@ function registerWorkspace(program2) {
3357
3629
  }
3358
3630
  print(active, { json: opts.json });
3359
3631
  });
3632
+ root.command("create").description("Create your own workspace (you become its ADMIN)").requiredOption("--name <name>", "workspace name").requiredOption("--slug <slug>", "URL slug (lowercase, digits, dashes)").option(
3633
+ "--account <name>",
3634
+ "the account to create it with (needed when several are stored)"
3635
+ ).option("--json", "raw JSON output").action(async (opts) => {
3636
+ const account = resolveAccount();
3637
+ configureClient(void 0, account);
3638
+ const body = unwrap(
3639
+ await postWorkspaces({ body: { name: opts.name, slug: opts.slug } })
3640
+ );
3641
+ console.error(
3642
+ `${chalk8.green("\u2713")} Workspace ${chalk8.bold(opts.name)} created. ${chalk8.dim(`Pin it with \`ft workspace use ${opts.slug}\`.`)}`
3643
+ );
3644
+ print(body?.data ?? body, { json: opts.json });
3645
+ });
3360
3646
  }
3361
3647
 
3362
3648
  // src/program.ts
@@ -3374,7 +3660,16 @@ registerResource(program, {
3374
3660
  update: patchEventsId,
3375
3661
  del: deleteEventsId,
3376
3662
  actions: [
3377
- { name: "publish", describe: "Publish an event", fn: postEventsIdPublish }
3663
+ { name: "publish", describe: "Publish an event", fn: postEventsIdPublish },
3664
+ {
3665
+ // Unlike delete, cancel keeps the event, its sales and tickets (every
3666
+ // date goes CANCELLED, the waiting room turns off). It refunds nothing:
3667
+ // that is `ft sales refund`. Idempotent on the backend, but still asks.
3668
+ name: "cancel",
3669
+ describe: "Cancel an event and all its dates (keeps sales/tickets; no refunds)",
3670
+ fn: postEventsIdCancel,
3671
+ confirm: true
3672
+ }
3378
3673
  ],
3379
3674
  // startsAt lives on EventDate, not Event — use createdAt for a temporal column.
3380
3675
  columns: ["id", "name", "status", "createdAt"],
@@ -3396,6 +3691,7 @@ registerResource(program, {
3396
3691
  name: "settlements",
3397
3692
  describe: "Settlements paid to the organizer",
3398
3693
  list: getSettlements,
3694
+ get: getSettlementsId,
3399
3695
  columns: ["id", "reference", "status", "amount", "currency", "createdAt"],
3400
3696
  listFlags: [
3401
3697
  { flag: "--event <id>", describe: "filter by event", query: "event" },
@@ -3445,6 +3741,13 @@ registerResource(program, {
3445
3741
  name: "tickets",
3446
3742
  describe: "List the individual tickets/attendees of a sale",
3447
3743
  fn: getSalesIdTickets
3744
+ },
3745
+ {
3746
+ // Answers "why didn't this sale go through?": one row per gateway
3747
+ // movement (approved, declined, refunded), newest first (contract 1.19).
3748
+ name: "attempts",
3749
+ describe: "Payment attempt history of a sale (declines, approvals, refunds)",
3750
+ fn: getSalesIdAttempts
3448
3751
  }
3449
3752
  ],
3450
3753
  columns: ["id", "reference", "status", "total", "currency", "createdAt"],
@@ -3535,6 +3838,8 @@ registerResource(program, {
3535
3838
  describe: "Webhook endpoints (HMAC-signed event delivery)",
3536
3839
  list: getWebhooks,
3537
3840
  create: postWebhooks,
3841
+ // PATCH keeps the signingSecret; delete + create would rotate it.
3842
+ update: patchWebhooksId,
3538
3843
  del: deleteWebhooksId,
3539
3844
  columns: ["id", "url", "events", "active", "createdAt"]
3540
3845
  });
@@ -3563,7 +3868,11 @@ registerResource(program, {
3563
3868
  name: "staff",
3564
3869
  describe: "Workspace staff",
3565
3870
  list: getStaff,
3871
+ get: getStaffId,
3566
3872
  create: postStaff,
3873
+ // Revokes access to THIS workspace only; the account and its other
3874
+ // workspaces stay. An ADMIN cannot revoke another admin (403) or itself (409).
3875
+ del: deleteStaffId,
3567
3876
  actions: [
3568
3877
  {
3569
3878
  name: "set-role",
@@ -3591,6 +3900,9 @@ registerResource(program, {
3591
3900
  name: "content-posts",
3592
3901
  describe: "Organization posts",
3593
3902
  list: getContentPosts,
3903
+ // type=ARTICLE needs title + body (Markdown); TEXT/IMAGE need content or
3904
+ // imageUrl. Minimum role ADMIN (contract 1.19).
3905
+ create: postContentPosts,
3594
3906
  columns: ["id", "title", "publishedAt", "memberOnly"]
3595
3907
  });
3596
3908
  registerResource(program, {
@@ -3638,7 +3950,11 @@ if (process.argv.length <= 2) {
3638
3950
  program.outputHelp();
3639
3951
  process.exit(0);
3640
3952
  }
3641
- program.parseAsync().then(() => notifyUpdate(package_default.version)).catch((err) => {
3953
+ var update = checkForUpdate(package_default.version);
3954
+ program.parseAsync().then(async () => {
3955
+ const notice = await update;
3956
+ if (notice) process.stderr.write(notice);
3957
+ }).catch((err) => {
3642
3958
  console.error(err instanceof Error ? err.message : err);
3643
3959
  process.exit(1);
3644
3960
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@freeticket/cli",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Official FreeTicket CLI — consumes the B2B REST API for events, sales, tickets, memberships, venues, staff, and reports.",
5
5
  "keywords": [
6
6
  "freeticket",