@freeticket/cli 0.5.0 → 0.7.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 +17 -6
  2. package/dist/index.js +532 -32
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -85,15 +85,25 @@ ft sales list --status CONFIRMED --json
85
85
  | `ft event-dates list` · `create` · `update` · `delete` | Event dates | ADMIN |
86
86
  | `ft ticket-types list` · `get <id>` | Ticket types (`--event-date-id`) | VIEWER |
87
87
  | `ft ticket-types create` · `update <id>` · `delete <id>` | Manage ticket types (`--data <json>`) | ADMIN |
88
- | `ft sales list` · `get <id>` | Sales (`--status`) | STAFF |
88
+ | `ft sales list` · `get <id>` | Sales (filters: `--status` `--channel` `--event` `--event-date` `--reference` `--buyer` `--from` `--to`) | STAFF |
89
+ | `ft sales create` | Create a sale/order — comps & programmatic sales (`--data <json>`) | ADMIN |
89
90
  | `ft sales cancel <id>` · `refund <id>` | Cancel / refund a sale (`--data` for partial refund) | ADMIN |
91
+ | `ft sales tickets <id>` | List the individual tickets/attendees of a sale | STAFF |
92
+ | `ft tickets access <code>` | Read a ticket's access status (no admit) | STAFF |
93
+ | `ft tickets checkin <code>` | Admit a ticket at the door (idempotent) | STAFF |
94
+ | `ft tickets resend <code>` | Resend the ticket's confirmation email (QR) | ADMIN |
90
95
  | `ft plans list` · `get <id>` | Membership plans | VIEWER |
91
96
  | `ft plans create` · `update <id>` · `delete <id>` | Manage membership plans (`--data <json>`) | ADMIN |
97
+ | `ft plans subscribers <id>` | List a plan's subscribers/members | VIEWER |
98
+ | `ft subscriptions cancel <id>` | Cancel a subscription | ADMIN |
99
+ | `ft discounts list` · `create` · `update <id>` · `delete <id>` | Discount codes / coupons (`--event` `--active`; `--data <json>`) | ADMIN |
100
+ | `ft webhooks list` · `create` · `delete <id>` | Webhook endpoints, HMAC-signed delivery (`--data <json>`) | ADMIN |
92
101
  | `ft venues list` · `get <id>` | Venues | VIEWER |
93
102
  | `ft venues create` · `update <id>` · `delete <id>` | Manage venues (`--data <json>`) | ADMIN |
94
103
  | `ft staff list` · `create` · `set-role <id>` | Workspace staff (`--data <json>`) | ADMIN |
95
104
  | `ft reports summary` | KPIs (`--period 7d\|30d\|90d\|1y`) | VIEWER |
96
- | `ft reports export buyers\|subscribers` | Export buyers / subscribers | ADMIN |
105
+ | `ft reports by-event` · `timeseries` · `inventory` | Revenue/tickets by event, over time, and capacity/availability | VIEWER |
106
+ | `ft reports export buyers\|attendees\|subscribers` | Export buyers / attendees / subscribers (CSV; filters `--event` `--event-date` `--from` `--to` `--status`) | ADMIN |
97
107
 
98
108
  > **Write operations** (`create`/`update`/`delete` and actions like `publish`,
99
109
  > `cancel`, `refund`) send a JSON body via `--data <inline-json>` or
@@ -103,11 +113,11 @@ ft sales list --status CONFIRMED --json
103
113
 
104
114
  | Flag | Applies to | Description |
105
115
  |---|---|---|
106
- | `--json` | all commands | Raw JSON output, ideal for `jq` and scripts |
116
+ | `--json` | all commands | Raw JSON, ideal for `jq`/scripts. On **lists this is the data array only** — use `--raw` for the paginated envelope |
107
117
  | `--workspace <id>` | all commands | Run the command against another workspace |
108
118
  | `--limit <n>` `--cursor <id>` | list commands | Cursor pagination (1-100, default 20) |
109
119
  | `--all` | list commands | Auto-paginate: fetch every page (ignores `--cursor`) |
110
- | `--raw` | list commands | JSON output including the `page` pagination metadata |
120
+ | `--raw` | list commands | JSON `{ data, page }` envelope, including `page.nextCursor` for scripted pagination |
111
121
  | `--columns <a,b,c>` `--full` | list commands | Pick specific columns · show every field |
112
122
  | `--csv` | list commands | CSV output for spreadsheets/accounting |
113
123
  | `--data <json>` `--yes` | write commands | JSON body (inline or `@file`) · skip delete confirmation |
@@ -123,11 +133,12 @@ flags > environment variables > ~/.freeticket/config.json > defaults
123
133
  | Variable | Default | Description |
124
134
  |---|---|---|
125
135
  | `FT_API_URL` | `https://admin.appfreeticket.com` | API base URL (without `/api/v1`) |
126
- | `FT_API_KEY` | — | Your `ft_live_...` key |
136
+ | `FT_API_KEY` | — | CI/headless only — a backend-issued `ft_live_...` token. Browser login (`ft login`) needs no key |
127
137
  | `FT_WORKSPACE_ID` | *home* | Default active workspace |
138
+ | `FT_NO_UPDATE_CHECK` | — | Set to disable the "update available" notice |
128
139
 
129
140
  The `~/.freeticket/config.json` file is created with `0600` permissions (only
130
- your user can read it) because it stores the API key. See [`.env.example`](./.env.example).
141
+ your user can read it) because it stores your credentials. See [`.env.example`](./.env.example).
131
142
 
132
143
  ## Pagination, errors, and money
133
144
 
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@freeticket/cli",
9
- version: "0.5.0",
9
+ version: "0.7.0",
10
10
  description: "Official FreeTicket CLI \u2014 consumes the B2B REST API for events, sales, tickets, memberships, venues, staff, and reports.",
11
11
  keywords: [
12
12
  "freeticket",
@@ -70,7 +70,7 @@ var package_default = {
70
70
  // src/client/client.gen.ts
71
71
  import { createClient, createConfig } from "@hey-api/client-fetch";
72
72
  var client = createClient(createConfig({
73
- baseUrl: "https://admin.appfreeticket.com/api/v1"
73
+ baseUrl: "http://localhost:3000/api/v1"
74
74
  }));
75
75
 
76
76
  // src/client/sdk.gen.ts
@@ -306,6 +306,22 @@ var getSales = (options) => {
306
306
  ...options
307
307
  });
308
308
  };
309
+ var postSales = (options) => {
310
+ return (options.client ?? client).post({
311
+ security: [
312
+ {
313
+ name: "Authorization",
314
+ type: "apiKey"
315
+ }
316
+ ],
317
+ url: "/sales",
318
+ ...options,
319
+ headers: {
320
+ "Content-Type": "application/json",
321
+ ...options?.headers
322
+ }
323
+ });
324
+ };
309
325
  var getSalesId = (options) => {
310
326
  return (options.client ?? client).get({
311
327
  security: [
@@ -526,6 +542,18 @@ var getReportsSummary = (options) => {
526
542
  ...options
527
543
  });
528
544
  };
545
+ var getReportsInventory = (options) => {
546
+ return (options?.client ?? client).get({
547
+ security: [
548
+ {
549
+ name: "Authorization",
550
+ type: "apiKey"
551
+ }
552
+ ],
553
+ url: "/reports/inventory",
554
+ ...options
555
+ });
556
+ };
529
557
  var getReportsReconciliation = (options) => {
530
558
  return (options.client ?? client).get({
531
559
  security: [
@@ -550,6 +578,18 @@ var getReportsExportsReconciliation = (options) => {
550
578
  ...options
551
579
  });
552
580
  };
581
+ var getReportsExportsAttendees = (options) => {
582
+ return (options?.client ?? client).get({
583
+ security: [
584
+ {
585
+ name: "Authorization",
586
+ type: "apiKey"
587
+ }
588
+ ],
589
+ url: "/reports/exports/attendees",
590
+ ...options
591
+ });
592
+ };
553
593
  var getReportsExportsBuyers = (options) => {
554
594
  return (options?.client ?? client).get({
555
595
  security: [
@@ -574,6 +614,201 @@ var getReportsExportsSubscribers = (options) => {
574
614
  ...options
575
615
  });
576
616
  };
617
+ var getReportsByEvent = (options) => {
618
+ return (options?.client ?? client).get({
619
+ security: [
620
+ {
621
+ name: "Authorization",
622
+ type: "apiKey"
623
+ }
624
+ ],
625
+ url: "/reports/by-event",
626
+ ...options
627
+ });
628
+ };
629
+ var getReportsTimeseries = (options) => {
630
+ return (options.client ?? client).get({
631
+ security: [
632
+ {
633
+ name: "Authorization",
634
+ type: "apiKey"
635
+ }
636
+ ],
637
+ url: "/reports/timeseries",
638
+ ...options
639
+ });
640
+ };
641
+ var getDiscounts = (options) => {
642
+ return (options?.client ?? client).get({
643
+ security: [
644
+ {
645
+ name: "Authorization",
646
+ type: "apiKey"
647
+ }
648
+ ],
649
+ url: "/discounts",
650
+ ...options
651
+ });
652
+ };
653
+ var postDiscounts = (options) => {
654
+ return (options.client ?? client).post({
655
+ security: [
656
+ {
657
+ name: "Authorization",
658
+ type: "apiKey"
659
+ }
660
+ ],
661
+ url: "/discounts",
662
+ ...options,
663
+ headers: {
664
+ "Content-Type": "application/json",
665
+ ...options?.headers
666
+ }
667
+ });
668
+ };
669
+ var deleteDiscountsId = (options) => {
670
+ return (options.client ?? client).delete({
671
+ security: [
672
+ {
673
+ name: "Authorization",
674
+ type: "apiKey"
675
+ }
676
+ ],
677
+ url: "/discounts/{id}",
678
+ ...options
679
+ });
680
+ };
681
+ var patchDiscountsId = (options) => {
682
+ return (options.client ?? client).patch({
683
+ security: [
684
+ {
685
+ name: "Authorization",
686
+ type: "apiKey"
687
+ }
688
+ ],
689
+ url: "/discounts/{id}",
690
+ ...options,
691
+ headers: {
692
+ "Content-Type": "application/json",
693
+ ...options?.headers
694
+ }
695
+ });
696
+ };
697
+ var getWebhooks = (options) => {
698
+ return (options?.client ?? client).get({
699
+ security: [
700
+ {
701
+ name: "Authorization",
702
+ type: "apiKey"
703
+ }
704
+ ],
705
+ url: "/webhooks",
706
+ ...options
707
+ });
708
+ };
709
+ var postWebhooks = (options) => {
710
+ return (options.client ?? client).post({
711
+ security: [
712
+ {
713
+ name: "Authorization",
714
+ type: "apiKey"
715
+ }
716
+ ],
717
+ url: "/webhooks",
718
+ ...options,
719
+ headers: {
720
+ "Content-Type": "application/json",
721
+ ...options?.headers
722
+ }
723
+ });
724
+ };
725
+ var deleteWebhooksId = (options) => {
726
+ return (options.client ?? client).delete({
727
+ security: [
728
+ {
729
+ name: "Authorization",
730
+ type: "apiKey"
731
+ }
732
+ ],
733
+ url: "/webhooks/{id}",
734
+ ...options
735
+ });
736
+ };
737
+ var getMembershipPlansIdSubscribers = (options) => {
738
+ return (options.client ?? client).get({
739
+ security: [
740
+ {
741
+ name: "Authorization",
742
+ type: "apiKey"
743
+ }
744
+ ],
745
+ url: "/membership-plans/{id}/subscribers",
746
+ ...options
747
+ });
748
+ };
749
+ var postSubscriptionsIdCancel = (options) => {
750
+ return (options.client ?? client).post({
751
+ security: [
752
+ {
753
+ name: "Authorization",
754
+ type: "apiKey"
755
+ }
756
+ ],
757
+ url: "/subscriptions/{id}/cancel",
758
+ ...options
759
+ });
760
+ };
761
+ var getSalesIdTickets = (options) => {
762
+ return (options.client ?? client).get({
763
+ security: [
764
+ {
765
+ name: "Authorization",
766
+ type: "apiKey"
767
+ }
768
+ ],
769
+ url: "/sales/{id}/tickets",
770
+ ...options
771
+ });
772
+ };
773
+ var postTicketsTicketCodeCheckin = (options) => {
774
+ return (options.client ?? client).post({
775
+ security: [
776
+ {
777
+ name: "Authorization",
778
+ type: "apiKey"
779
+ }
780
+ ],
781
+ url: "/tickets/{ticketCode}/checkin",
782
+ ...options
783
+ });
784
+ };
785
+ var getTicketsTicketCodeAccess = (options) => {
786
+ return (options.client ?? client).get({
787
+ security: [
788
+ {
789
+ name: "Authorization",
790
+ type: "apiKey"
791
+ }
792
+ ],
793
+ url: "/tickets/{ticketCode}/access",
794
+ ...options
795
+ });
796
+ };
797
+ var postTicketsTicketCodeResend = (options) => {
798
+ return (options.client ?? client).post({
799
+ security: [
800
+ {
801
+ name: "Authorization",
802
+ type: "apiKey"
803
+ }
804
+ ],
805
+ url: "/tickets/{ticketCode}/resend",
806
+ ...options
807
+ });
808
+ };
809
+
810
+ // src/commands/admin.ts
811
+ import chalk2 from "chalk";
577
812
 
578
813
  // src/admin-client/client.gen.ts
579
814
  import { createClient as createClient2, createConfig as createConfig2 } from "@hey-api/client-fetch";
@@ -895,7 +1130,10 @@ function saveConfig(patch) {
895
1130
  function configureClient(workspaceOverride) {
896
1131
  const cfg = loadConfig();
897
1132
  if (!cfg.apiKey) {
898
- fail("No API key configured. Run `ft login` or export FT_API_KEY.");
1133
+ fail(
1134
+ "Not logged in. Run `ft login` to sign in through your browser.",
1135
+ "CI / headless only: set FT_API_KEY (or `ft login --key`) with a backend-issued token."
1136
+ );
899
1137
  }
900
1138
  const workspaceId = workspaceOverride ?? cfg.workspaceId;
901
1139
  client.setConfig({
@@ -940,7 +1178,7 @@ function unwrap(res) {
940
1178
  function hintFor(status) {
941
1179
  switch (status) {
942
1180
  case 401:
943
- return "Invalid, revoked, or expired API key. Run `ft login`.";
1181
+ return "Your session is invalid, revoked, or expired. Run `ft login`.";
944
1182
  case 403:
945
1183
  return "Your role or workspace does not allow this action.";
946
1184
  case 404:
@@ -1019,17 +1257,19 @@ function print(data, opts = {}) {
1019
1257
  process.stdout.write(`${JSON.stringify(data, null, 2)}
1020
1258
  `);
1021
1259
  }
1260
+ function csvEsc(v) {
1261
+ if (v === null || v === void 0) return "";
1262
+ const s = typeof v === "object" ? JSON.stringify(v) : String(v);
1263
+ return /[",\n\r]/.test(s) ? `"${s.replace(/"/g, '""')}"` : s;
1264
+ }
1022
1265
  function toCsv(rows, columns) {
1023
- if (!Array.isArray(rows) || rows.length === 0) return "";
1266
+ if (!Array.isArray(rows) || rows.length === 0) {
1267
+ return columns?.length ? columns.map(csvEsc).join(",") : "";
1268
+ }
1024
1269
  const cols = columns ?? Object.keys(rows[0]);
1025
- const esc = (v) => {
1026
- if (v === null || v === void 0) return "";
1027
- const s = typeof v === "object" ? JSON.stringify(v) : String(v);
1028
- return /[",\n\r]/.test(s) ? `"${s.replace(/"/g, '""')}"` : s;
1029
- };
1030
- const head = cols.map(esc).join(",");
1270
+ const head = cols.map(csvEsc).join(",");
1031
1271
  const body = rows.map(
1032
- (r) => cols.map((c2) => esc(r[c2])).join(",")
1272
+ (r) => cols.map((c2) => csvEsc(r[c2])).join(",")
1033
1273
  );
1034
1274
  return [head, ...body].join("\n");
1035
1275
  }
@@ -1057,7 +1297,41 @@ function fmt(v) {
1057
1297
 
1058
1298
  // src/commands/admin.ts
1059
1299
  function registerAdmin(program2) {
1060
- const admin = program2.command("admin").description("Superadmin (cross-tenant) \u2014 requires FT_ADMIN_SESSION");
1300
+ const admin = program2.command("admin").description("Superadmin (cross-tenant) \u2014 SUPER_ADMIN session required");
1301
+ admin.command("login").description(
1302
+ "Save a SUPER_ADMIN session and validate it against /api/admin/me"
1303
+ ).requiredOption(
1304
+ "--session <token>",
1305
+ "the `better-auth.session_token` cookie value from an authenticated admin browser session"
1306
+ ).option(
1307
+ "--url <url>",
1308
+ "API base URL (default: https://admin.appfreeticket.com)"
1309
+ ).action(async (opts) => {
1310
+ if (opts.url) saveConfig({ apiUrl: opts.url });
1311
+ saveConfig({ adminSession: opts.session });
1312
+ configureAdminClient();
1313
+ const me = unwrap(await getMe2({})).data;
1314
+ console.log(
1315
+ `${chalk2.green("\u2713")} Admin session saved in ${chalk2.dim(CONFIG_PATH)}`
1316
+ );
1317
+ print(me, {});
1318
+ });
1319
+ admin.command("logout").description("Remove the stored superadmin session").action(() => {
1320
+ saveConfig({ adminSession: void 0 });
1321
+ console.log(
1322
+ `${chalk2.green("\u2713")} Admin session removed from ${chalk2.dim(CONFIG_PATH)}`
1323
+ );
1324
+ });
1325
+ admin.command("config").description("Show admin configuration (the session is masked)").action(() => {
1326
+ const cfg = loadConfig();
1327
+ print(
1328
+ {
1329
+ apiUrl: cfg.apiUrl,
1330
+ adminSession: cfg.adminSession ? `${cfg.adminSession.slice(0, 12)}\u2026` : null
1331
+ },
1332
+ {}
1333
+ );
1334
+ });
1061
1335
  admin.command("me").description("Current superadmin identity (GET /api/admin/me)").option("--json", "raw JSON output").action(async (opts) => {
1062
1336
  configureAdminClient();
1063
1337
  const body = unwrap(await getMe2({}));
@@ -1243,7 +1517,7 @@ function camel(s) {
1243
1517
 
1244
1518
  // src/commands/auth.ts
1245
1519
  import { spawn } from "child_process";
1246
- import chalk2 from "chalk";
1520
+ import chalk3 from "chalk";
1247
1521
  function registerAuth(program2) {
1248
1522
  program2.command("login").description(
1249
1523
  "Log in via the browser (device flow) and store the session in ~/.freeticket/config.json"
@@ -1264,7 +1538,7 @@ function registerAuth(program2) {
1264
1538
  configureClient(workspaceId);
1265
1539
  const me = unwrap(await getMe({})).data;
1266
1540
  console.log(
1267
- `${chalk2.green("\u2713")} Session saved in ${chalk2.dim(CONFIG_PATH)}`
1541
+ `${chalk3.green("\u2713")} Session saved in ${chalk3.dim(CONFIG_PATH)}`
1268
1542
  );
1269
1543
  print(me, {});
1270
1544
  });
@@ -1273,18 +1547,19 @@ function registerAuth(program2) {
1273
1547
  const me = unwrap(await getMe({})).data;
1274
1548
  print(me, { json: opts.json });
1275
1549
  });
1276
- program2.command("logout").description("Remove the stored API key").action(() => {
1550
+ program2.command("logout").description("Log out and remove the stored session").action(() => {
1277
1551
  saveConfig({ apiKey: void 0 });
1278
1552
  console.log(
1279
- `${chalk2.green("\u2713")} API key removed from ${chalk2.dim(CONFIG_PATH)}`
1553
+ `${chalk3.green("\u2713")} Logged out \u2014 session removed from ${chalk3.dim(CONFIG_PATH)}`
1280
1554
  );
1281
1555
  });
1282
- program2.command("config").description("Show active configuration (the API key is masked)").action(() => {
1556
+ program2.command("config").description("Show active configuration (the credential is masked)").action(() => {
1283
1557
  const cfg = loadConfig();
1284
1558
  print(
1285
1559
  {
1286
1560
  apiUrl: cfg.apiUrl,
1287
- apiKey: cfg.apiKey ? `${cfg.apiKey.slice(0, 12)}\u2026` : null,
1561
+ // Same field whether it's a device-flow session or a CI API key.
1562
+ session: cfg.apiKey ? `${cfg.apiKey.slice(0, 12)}\u2026` : null,
1288
1563
  workspaceId: cfg.workspaceId ?? null
1289
1564
  },
1290
1565
  {}
@@ -1305,11 +1580,11 @@ async function deviceLogin() {
1305
1580
  const start = unwrap(await postAuthDeviceCode({}));
1306
1581
  console.log(
1307
1582
  `
1308
- Open ${chalk2.cyan(start.verification_uri)} and enter the code:
1583
+ Open ${chalk3.cyan(start.verification_uri)} and enter the code:
1309
1584
 
1310
- ${chalk2.bold(start.user_code)}
1585
+ ${chalk3.bold(start.user_code)}
1311
1586
 
1312
- ${chalk2.dim("Opening your browser\u2026 (Ctrl+C to cancel)")}
1587
+ ${chalk3.dim("Opening your browser\u2026 (Ctrl+C to cancel)")}
1313
1588
  `
1314
1589
  );
1315
1590
  openBrowser(start.verification_uri_complete);
@@ -1329,7 +1604,7 @@ ${chalk2.dim("Opening your browser\u2026 (Ctrl+C to cancel)")}
1329
1604
  if (workspaces.length > 1 && active) {
1330
1605
  console.log(
1331
1606
  `
1332
- ${chalk2.dim("Workspaces:")} ${workspaces.map((w) => w.slug).join(", ")} ${chalk2.dim(`(using ${active.slug}; switch with --workspace)`)}`
1607
+ ${chalk3.dim("Workspaces:")} ${workspaces.map((w) => w.slug).join(", ")} ${chalk3.dim(`(using ${active.slug}; switch with --workspace)`)}`
1333
1608
  );
1334
1609
  }
1335
1610
  return { apiKey: access_token, workspaceId: active?.id };
@@ -1425,7 +1700,48 @@ function registerReports(program2) {
1425
1700
  );
1426
1701
  print(body.data, { json: opts.json });
1427
1702
  });
1428
- const exp = root.command("export").description("Export buyers, subscribers or reconciliation (CSV)");
1703
+ root.command("by-event").description("Revenue / tickets sold / availability grouped by event").option("--from <date>", "created from (ISO 8601)").option("--to <date>", "created to (ISO 8601)").option("--status <s>", "filter by sale status").option("--workspace <id>", "workspace override").option("--json", "raw JSON output").action(async (opts) => {
1704
+ configureClient(opts.workspace);
1705
+ const body = unwrap(
1706
+ await getReportsByEvent({
1707
+ query: { from: opts.from, to: opts.to, status: opts.status }
1708
+ })
1709
+ );
1710
+ print(body.data, { json: opts.json });
1711
+ });
1712
+ root.command("timeseries").description("Revenue / tickets sold bucketed over time").requiredOption("--interval <i>", "day | week | month").option("--from <date>", "created from (ISO 8601)").option("--to <date>", "created to (ISO 8601)").option("--event <id>", "filter by event").option("--workspace <id>", "workspace override").option("--json", "raw JSON output").action(async (opts) => {
1713
+ configureClient(opts.workspace);
1714
+ const body = unwrap(
1715
+ await getReportsTimeseries({
1716
+ query: {
1717
+ interval: opts.interval,
1718
+ from: opts.from,
1719
+ to: opts.to,
1720
+ event: opts.event
1721
+ }
1722
+ })
1723
+ );
1724
+ print(body.data, { json: opts.json });
1725
+ });
1726
+ root.command("inventory").description("Capacity / sold / reserved / available per event\xB7date\xB7type").option("--event-id <id>", "filter by event").option("--event-date-id <id>", "filter by event date").option("--from <date>", "date from (ISO 8601)").option("--to <date>", "date to (ISO 8601)").option("--include-drafts", "include draft events").option("--group-by <g>", "ticketType | date | event").option("--workspace <id>", "workspace override").option("--json", "raw JSON output").action(async (opts) => {
1727
+ configureClient(opts.workspace);
1728
+ const body = unwrap(
1729
+ await getReportsInventory({
1730
+ query: {
1731
+ eventId: opts.eventId,
1732
+ eventDateId: opts.eventDateId,
1733
+ from: opts.from,
1734
+ to: opts.to,
1735
+ includeDrafts: opts.includeDrafts,
1736
+ groupBy: opts.groupBy
1737
+ }
1738
+ })
1739
+ );
1740
+ print(body.data, { json: opts.json });
1741
+ });
1742
+ const exp = root.command("export").description(
1743
+ "Export buyers, attendees, subscribers or reconciliation (CSV)"
1744
+ );
1429
1745
  exp.command("reconciliation").description("Export reconciliation (CSV) for accounting").requiredOption("--from <date>", "date_from (ISO 8601)").requiredOption("--to <date>", "date_to (ISO 8601)").option("--match <status>", "filter by match_status").option("--provider <p>", "filter by payment provider").option("--workspace <id>", "workspace override").option("--json", "raw JSON output").action(async (opts) => {
1430
1746
  configureClient(opts.workspace);
1431
1747
  const body = unwrap(
@@ -1441,15 +1757,30 @@ function registerReports(program2) {
1441
1757
  print(body.data ?? body, { json: opts.json });
1442
1758
  });
1443
1759
  for (const [name, fn, label] of [
1444
- ["buyers", getReportsExportsBuyers, "buyers"],
1445
- ["subscribers", getReportsExportsSubscribers, "subscribers"]
1760
+ ["buyers", getReportsExportsBuyers, "buyers (one row per sale)"],
1761
+ ["attendees", getReportsExportsAttendees, "attendees (one row per ticket)"]
1446
1762
  ]) {
1447
- exp.command(name).description(`Export ${label}`).option("--workspace <id>", "workspace override").option("--json", "raw JSON output").action(async (opts) => {
1763
+ 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("--workspace <id>", "workspace override").option("--json", "raw JSON output").action(async (opts) => {
1448
1764
  configureClient(opts.workspace);
1449
- const body = unwrap(await fn({}));
1765
+ const body = unwrap(
1766
+ await fn({
1767
+ query: {
1768
+ event: opts.event,
1769
+ eventDate: opts.eventDate,
1770
+ from: opts.from,
1771
+ to: opts.to,
1772
+ status: opts.status
1773
+ }
1774
+ })
1775
+ );
1450
1776
  print(body.data ?? body, { json: opts.json });
1451
1777
  });
1452
1778
  }
1779
+ exp.command("subscribers").description("Export subscribers").option("--workspace <id>", "workspace override").option("--json", "raw JSON output").action(async (opts) => {
1780
+ configureClient(opts.workspace);
1781
+ const body = unwrap(await getReportsExportsSubscribers({}));
1782
+ print(body.data ?? body, { json: opts.json });
1783
+ });
1453
1784
  }
1454
1785
 
1455
1786
  // src/commands/resource.ts
@@ -1566,8 +1897,36 @@ function camel2(s) {
1566
1897
  return s.replace(/-([a-z])/g, (_, c2) => c2.toUpperCase());
1567
1898
  }
1568
1899
 
1900
+ // src/commands/tickets.ts
1901
+ function registerTickets(program2) {
1902
+ const root = program2.command("tickets").description("Individual tickets: door check-in, access status, QR resend");
1903
+ 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) => {
1904
+ configureClient(opts.workspace);
1905
+ const body = unwrap(
1906
+ await getTicketsTicketCodeAccess({ path: { ticketCode: code } })
1907
+ );
1908
+ print(body.data ?? body, { json: opts.json });
1909
+ });
1910
+ root.command("checkin <code>").description(
1911
+ "Admit a ticket at the door (idempotent, prevents double entry)"
1912
+ ).option("--workspace <id>", "workspace override").option("--json", "raw JSON output").action(async (code, opts) => {
1913
+ configureClient(opts.workspace);
1914
+ const body = unwrap(
1915
+ await postTicketsTicketCodeCheckin({ path: { ticketCode: code } })
1916
+ );
1917
+ print(body.data ?? body, { json: opts.json });
1918
+ });
1919
+ root.command("resend <code>").description("Resend the ticket's confirmation email (QR)").option("--workspace <id>", "workspace override").option("--json", "raw JSON output").action(async (code, opts) => {
1920
+ configureClient(opts.workspace);
1921
+ const body = unwrap(
1922
+ await postTicketsTicketCodeResend({ path: { ticketCode: code } })
1923
+ );
1924
+ print(body.data ?? body, { json: opts.json });
1925
+ });
1926
+ }
1927
+
1569
1928
  // src/commands/workspace.ts
1570
- import chalk3 from "chalk";
1929
+ import chalk4 from "chalk";
1571
1930
  function registerWorkspace(program2) {
1572
1931
  const root = program2.command("workspace").description("List, switch, and show the active workspace");
1573
1932
  root.command("list").alias("ls").description("List the workspaces you can access (marks the active one)").option("--json", "raw JSON output").action(async (opts) => {
@@ -1601,7 +1960,7 @@ function registerWorkspace(program2) {
1601
1960
  }
1602
1961
  saveConfig({ workspaceId: match.id });
1603
1962
  console.log(
1604
- `${chalk3.green("\u2713")} Active workspace: ${chalk3.bold(match.name)} ${chalk3.dim(`(${match.slug})`)}`
1963
+ `${chalk4.green("\u2713")} Active workspace: ${chalk4.bold(match.name)} ${chalk4.dim(`(${match.slug})`)}`
1605
1964
  );
1606
1965
  });
1607
1966
  root.command("show").description("Show the active workspace").option("--json", "raw JSON output").action(async (opts) => {
@@ -1638,6 +1997,70 @@ function banner() {
1638
1997
  ].join("\n");
1639
1998
  }
1640
1999
 
2000
+ // src/lib/update-check.ts
2001
+ import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
2002
+ import { homedir as homedir2 } from "os";
2003
+ import { dirname as dirname2, join as join2 } from "path";
2004
+ import chalk5 from "chalk";
2005
+ var CACHE_PATH = join2(homedir2(), ".freeticket", "update-check.json");
2006
+ var REGISTRY = "https://registry.npmjs.org/@freeticket/cli/latest";
2007
+ var ONE_DAY = 24 * 60 * 60 * 1e3;
2008
+ var FETCH_TIMEOUT = 1500;
2009
+ async function notifyUpdate(current) {
2010
+ if (!process.stderr.isTTY || process.env.FT_NO_UPDATE_CHECK || process.env.CI) {
2011
+ return;
2012
+ }
2013
+ try {
2014
+ const latest = await getLatest();
2015
+ if (latest && isNewer(latest, current)) {
2016
+ process.stderr.write(
2017
+ `
2018
+ ${chalk5.yellow(`\u26A0 Update available: @freeticket/cli ${current} \u2192 ${latest}`)}
2019
+ ${chalk5.dim(" npm i -g @freeticket/cli@latest \xB7 or use npx @freeticket/cli@latest")}
2020
+
2021
+ `
2022
+ );
2023
+ }
2024
+ } catch {
2025
+ }
2026
+ }
2027
+ async function getLatest() {
2028
+ const cached = readCache();
2029
+ if (cached && Date.now() - cached.at < ONE_DAY) return cached.latest;
2030
+ const res = await fetch(REGISTRY, {
2031
+ signal: AbortSignal.timeout(FETCH_TIMEOUT),
2032
+ headers: { Accept: "application/vnd.npm.install-v1+json" }
2033
+ });
2034
+ if (!res.ok) throw new Error(`registry ${res.status}`);
2035
+ const latest = (await res.json()).version ?? null;
2036
+ if (latest) writeCache({ at: Date.now(), latest });
2037
+ return latest;
2038
+ }
2039
+ function readCache() {
2040
+ if (!existsSync2(CACHE_PATH)) return null;
2041
+ try {
2042
+ return JSON.parse(readFileSync3(CACHE_PATH, "utf8"));
2043
+ } catch {
2044
+ return null;
2045
+ }
2046
+ }
2047
+ function writeCache(v) {
2048
+ try {
2049
+ mkdirSync2(dirname2(CACHE_PATH), { recursive: true });
2050
+ writeFileSync2(CACHE_PATH, JSON.stringify(v));
2051
+ } catch {
2052
+ }
2053
+ }
2054
+ function isNewer(a, b) {
2055
+ const parse = (v) => {
2056
+ const [maj, min, pat] = (v.replace(/^v/, "").split("-")[0] ?? "").split(".").map((n) => Number.parseInt(n, 10) || 0);
2057
+ return [maj ?? 0, min ?? 0, pat ?? 0];
2058
+ };
2059
+ const [aM, aN, aP] = parse(a);
2060
+ const [bM, bN, bP] = parse(b);
2061
+ return aM > bM || aM === bM && (aN > bN || aN === bN && aP > bP);
2062
+ }
2063
+
1641
2064
  // src/index.ts
1642
2065
  var program = new Command();
1643
2066
  program.name("ft").description("Official FreeTicket CLI").version(package_default.version, "-v, --version").addHelpText("beforeAll", banner());
@@ -1668,6 +2091,7 @@ registerResource(program, {
1668
2091
  describe: "Sales",
1669
2092
  list: getSales,
1670
2093
  get: getSalesId,
2094
+ create: postSales,
1671
2095
  actions: [
1672
2096
  { name: "cancel", describe: "Cancel a sale", fn: postSalesIdCancel },
1673
2097
  {
@@ -1675,11 +2099,43 @@ registerResource(program, {
1675
2099
  describe: "Refund a sale (--data for partial amount)",
1676
2100
  fn: postSalesIdRefund,
1677
2101
  body: true
2102
+ },
2103
+ {
2104
+ name: "tickets",
2105
+ describe: "List the individual tickets/attendees of a sale",
2106
+ fn: getSalesIdTickets
1678
2107
  }
1679
2108
  ],
1680
2109
  columns: ["id", "reference", "status", "total", "currency", "createdAt"],
1681
2110
  listFlags: [
1682
- { flag: "--status <s>", describe: "filter by status", query: "status" }
2111
+ { flag: "--status <s>", describe: "filter by status", query: "status" },
2112
+ {
2113
+ flag: "--channel <c>",
2114
+ describe: "filter by sales channel",
2115
+ query: "channel"
2116
+ },
2117
+ { flag: "--event <id>", describe: "filter by event", query: "event" },
2118
+ {
2119
+ flag: "--event-date <id>",
2120
+ describe: "filter by event date",
2121
+ query: "eventDate"
2122
+ },
2123
+ {
2124
+ flag: "--reference <ref>",
2125
+ describe: "filter by reference",
2126
+ query: "reference"
2127
+ },
2128
+ {
2129
+ flag: "--buyer <q>",
2130
+ describe: "filter by buyer name/email",
2131
+ query: "buyer"
2132
+ },
2133
+ {
2134
+ flag: "--from <date>",
2135
+ describe: "created from (ISO 8601)",
2136
+ query: "from"
2137
+ },
2138
+ { flag: "--to <date>", describe: "created to (ISO 8601)", query: "to" }
1683
2139
  ]
1684
2140
  });
1685
2141
  registerResource(program, {
@@ -1707,8 +2163,51 @@ registerResource(program, {
1707
2163
  create: postMembershipPlans,
1708
2164
  update: patchMembershipPlansId,
1709
2165
  del: deleteMembershipPlansId,
2166
+ actions: [
2167
+ {
2168
+ name: "subscribers",
2169
+ describe: "List the subscribers/members of a plan",
2170
+ fn: getMembershipPlansIdSubscribers
2171
+ }
2172
+ ],
1710
2173
  columns: ["id", "name", "price", "currency", "billingCycle"]
1711
2174
  });
2175
+ registerResource(program, {
2176
+ name: "discounts",
2177
+ describe: "Discount codes / coupons",
2178
+ list: getDiscounts,
2179
+ create: postDiscounts,
2180
+ update: patchDiscountsId,
2181
+ del: deleteDiscountsId,
2182
+ columns: ["id", "code", "type", "value", "active", "uses", "maxUses"],
2183
+ listFlags: [
2184
+ { flag: "--event <id>", describe: "filter by event", query: "event" },
2185
+ {
2186
+ flag: "--active <bool>",
2187
+ describe: "filter by active (true/false)",
2188
+ query: "active"
2189
+ }
2190
+ ]
2191
+ });
2192
+ registerResource(program, {
2193
+ name: "webhooks",
2194
+ describe: "Webhook endpoints (HMAC-signed event delivery)",
2195
+ list: getWebhooks,
2196
+ create: postWebhooks,
2197
+ del: deleteWebhooksId,
2198
+ columns: ["id", "url", "events", "active", "createdAt"]
2199
+ });
2200
+ registerResource(program, {
2201
+ name: "subscriptions",
2202
+ describe: "Plan subscriptions",
2203
+ actions: [
2204
+ {
2205
+ name: "cancel",
2206
+ describe: "Cancel a subscription",
2207
+ fn: postSubscriptionsIdCancel
2208
+ }
2209
+ ]
2210
+ });
1712
2211
  registerResource(program, {
1713
2212
  name: "venues",
1714
2213
  describe: "Venues",
@@ -1734,6 +2233,7 @@ registerResource(program, {
1734
2233
  ],
1735
2234
  columns: ["id", "name", "email", "role"]
1736
2235
  });
2236
+ registerTickets(program);
1737
2237
  registerReports(program);
1738
2238
  registerAdmin(program);
1739
2239
  if (process.argv.length <= 2) {
@@ -1741,7 +2241,7 @@ if (process.argv.length <= 2) {
1741
2241
  program.outputHelp();
1742
2242
  process.exit(0);
1743
2243
  }
1744
- program.parseAsync().catch((err) => {
2244
+ program.parseAsync().then(() => notifyUpdate(package_default.version)).catch((err) => {
1745
2245
  console.error(err instanceof Error ? err.message : err);
1746
2246
  process.exit(1);
1747
2247
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@freeticket/cli",
3
- "version": "0.5.0",
3
+ "version": "0.7.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",