@freeticket/cli 0.4.1 → 0.6.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 +38 -8
  2. package/dist/index.js +501 -15
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -61,7 +61,11 @@ ft login
61
61
  # 2. Who am I, and which workspaces can I access?
62
62
  ft whoami
63
63
 
64
- # 3. Start exploring
64
+ # 3. Pick the workspace you want to operate on (persisted locally).
65
+ ft workspace list
66
+ ft workspace use my-workspace-slug
67
+
68
+ # 4. Start exploring
65
69
  ft events list
66
70
  ft reports summary --period 30d
67
71
  ft sales list --status CONFIRMED --json
@@ -74,17 +78,36 @@ ft sales list --status CONFIRMED --json
74
78
  | `ft login` | Browser login (device flow); `--key <key>` for CI | VIEWER |
75
79
  | `ft whoami` | Active user and accessible workspaces | VIEWER |
76
80
  | `ft config` · `ft logout` | Show config (masked key) · remove key | — |
81
+ | `ft workspace list` · `use <id\|slug>` · `show` | List, switch, and show the active workspace | VIEWER |
77
82
  | `ft events list` · `get <id>` | Workspace events | VIEWER |
83
+ | `ft events create` · `update <id>` · `delete <id>` | Manage events (`--data <json>`) | ADMIN |
84
+ | `ft events publish <id>` | Publish an event | ADMIN |
85
+ | `ft event-dates list` · `create` · `update` · `delete` | Event dates | ADMIN |
78
86
  | `ft ticket-types list` · `get <id>` | Ticket types (`--event-date-id`) | VIEWER |
79
- | `ft sales list` · `get <id>` | Sales (`--status`) | STAFF |
87
+ | `ft ticket-types create` · `update <id>` · `delete <id>` | Manage ticket types (`--data <json>`) | ADMIN |
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 |
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 |
80
95
  | `ft plans list` · `get <id>` | Membership plans | VIEWER |
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 |
81
101
  | `ft venues list` · `get <id>` | Venues | VIEWER |
82
- | `ft staff list` | Workspace staff | ADMIN |
102
+ | `ft venues create` · `update <id>` · `delete <id>` | Manage venues (`--data <json>`) | ADMIN |
103
+ | `ft staff list` · `create` · `set-role <id>` | Workspace staff (`--data <json>`) | ADMIN |
83
104
  | `ft reports summary` | KPIs (`--period 7d\|30d\|90d\|1y`) | VIEWER |
84
- | `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 |
85
107
 
86
- > **Write operations** (create/update/delete) are declared in the contract but
87
- > currently return `501`. They are planned for **phase 2**.
108
+ > **Write operations** (`create`/`update`/`delete` and actions like `publish`,
109
+ > `cancel`, `refund`) send a JSON body via `--data <inline-json>` or
110
+ > `--data @file.json`. `delete` prompts for confirmation unless you pass `--yes`.
88
111
 
89
112
  ### Common flags
90
113
 
@@ -93,6 +116,11 @@ ft sales list --status CONFIRMED --json
93
116
  | `--json` | all commands | Raw JSON output, ideal for `jq` and scripts |
94
117
  | `--workspace <id>` | all commands | Run the command against another workspace |
95
118
  | `--limit <n>` `--cursor <id>` | list commands | Cursor pagination (1-100, default 20) |
119
+ | `--all` | list commands | Auto-paginate: fetch every page (ignores `--cursor`) |
120
+ | `--raw` | list commands | JSON output including the `page` pagination metadata |
121
+ | `--columns <a,b,c>` `--full` | list commands | Pick specific columns · show every field |
122
+ | `--csv` | list commands | CSV output for spreadsheets/accounting |
123
+ | `--data <json>` `--yes` | write commands | JSON body (inline or `@file`) · skip delete confirmation |
96
124
 
97
125
  ## Configuration
98
126
 
@@ -113,8 +141,10 @@ your user can read it) because it stores the API key. See [`.env.example`](./.en
113
141
 
114
142
  ## Pagination, errors, and money
115
143
 
116
- - **Pagination:** list responses include `page.nextCursor`. The CLI prints the
117
- `--cursor <id>` hint to *stderr* so `--json` stays clean on *stdout*.
144
+ - **Pagination:** list responses include `page.nextCursor` / `page.hasMore`. The
145
+ CLI prints the `--cursor <id>` hint to *stderr* so `--json` stays clean on
146
+ *stdout*. Use `--all` to auto-paginate every page, or `--raw` to emit the full
147
+ `{ data, page }` envelope (metadata included) as JSON.
118
148
  - **Errors:** uniform format `{ error: { code, message, details } }`. The CLI
119
149
  translates `401/403/404/501` into actionable messages and exits with code `1`.
120
150
  - **Money:** number in the resource currency (`currency`, usually `COP`).
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.4.1",
9
+ version: "0.6.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,198 @@ 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
+ };
577
809
 
578
810
  // src/admin-client/client.gen.ts
579
811
  import { createClient as createClient2, createConfig as createConfig2 } from "@hey-api/client-fetch";
@@ -946,7 +1178,7 @@ function hintFor(status) {
946
1178
  case 404:
947
1179
  return "The resource does not exist or belongs to another workspace.";
948
1180
  case 501:
949
- return "Write operation: planned for CLI phase 2.";
1181
+ return "The backend has not implemented this operation yet.";
950
1182
  }
951
1183
  }
952
1184
  function fail(message, hint) {
@@ -1033,6 +1265,13 @@ function toCsv(rows, columns) {
1033
1265
  );
1034
1266
  return [head, ...body].join("\n");
1035
1267
  }
1268
+ function resolveColumns(opts, fallback) {
1269
+ if (opts.full) return void 0;
1270
+ if (opts.columns) {
1271
+ return opts.columns.split(",").map((c2) => c2.trim()).filter(Boolean);
1272
+ }
1273
+ return fallback;
1274
+ }
1036
1275
  function printNextCursor(page) {
1037
1276
  if (page?.nextCursor) {
1038
1277
  console.error(chalk.dim(`
@@ -1418,7 +1657,48 @@ function registerReports(program2) {
1418
1657
  );
1419
1658
  print(body.data, { json: opts.json });
1420
1659
  });
1421
- const exp = root.command("export").description("Export buyers, subscribers or reconciliation (CSV)");
1660
+ 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) => {
1661
+ configureClient(opts.workspace);
1662
+ const body = unwrap(
1663
+ await getReportsByEvent({
1664
+ query: { from: opts.from, to: opts.to, status: opts.status }
1665
+ })
1666
+ );
1667
+ print(body.data, { json: opts.json });
1668
+ });
1669
+ 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) => {
1670
+ configureClient(opts.workspace);
1671
+ const body = unwrap(
1672
+ await getReportsTimeseries({
1673
+ query: {
1674
+ interval: opts.interval,
1675
+ from: opts.from,
1676
+ to: opts.to,
1677
+ event: opts.event
1678
+ }
1679
+ })
1680
+ );
1681
+ print(body.data, { json: opts.json });
1682
+ });
1683
+ 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) => {
1684
+ configureClient(opts.workspace);
1685
+ const body = unwrap(
1686
+ await getReportsInventory({
1687
+ query: {
1688
+ eventId: opts.eventId,
1689
+ eventDateId: opts.eventDateId,
1690
+ from: opts.from,
1691
+ to: opts.to,
1692
+ includeDrafts: opts.includeDrafts,
1693
+ groupBy: opts.groupBy
1694
+ }
1695
+ })
1696
+ );
1697
+ print(body.data, { json: opts.json });
1698
+ });
1699
+ const exp = root.command("export").description(
1700
+ "Export buyers, attendees, subscribers or reconciliation (CSV)"
1701
+ );
1422
1702
  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) => {
1423
1703
  configureClient(opts.workspace);
1424
1704
  const body = unwrap(
@@ -1434,15 +1714,30 @@ function registerReports(program2) {
1434
1714
  print(body.data ?? body, { json: opts.json });
1435
1715
  });
1436
1716
  for (const [name, fn, label] of [
1437
- ["buyers", getReportsExportsBuyers, "buyers"],
1438
- ["subscribers", getReportsExportsSubscribers, "subscribers"]
1717
+ ["buyers", getReportsExportsBuyers, "buyers (one row per sale)"],
1718
+ ["attendees", getReportsExportsAttendees, "attendees (one row per ticket)"]
1439
1719
  ]) {
1440
- exp.command(name).description(`Export ${label}`).option("--workspace <id>", "workspace override").option("--json", "raw JSON output").action(async (opts) => {
1720
+ 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) => {
1441
1721
  configureClient(opts.workspace);
1442
- const body = unwrap(await fn({}));
1722
+ const body = unwrap(
1723
+ await fn({
1724
+ query: {
1725
+ event: opts.event,
1726
+ eventDate: opts.eventDate,
1727
+ from: opts.from,
1728
+ to: opts.to,
1729
+ status: opts.status
1730
+ }
1731
+ })
1732
+ );
1443
1733
  print(body.data ?? body, { json: opts.json });
1444
1734
  });
1445
1735
  }
1736
+ exp.command("subscribers").description("Export subscribers").option("--workspace <id>", "workspace override").option("--json", "raw JSON output").action(async (opts) => {
1737
+ configureClient(opts.workspace);
1738
+ const body = unwrap(await getReportsExportsSubscribers({}));
1739
+ print(body.data ?? body, { json: opts.json });
1740
+ });
1446
1741
  }
1447
1742
 
1448
1743
  // src/commands/resource.ts
@@ -1451,10 +1746,11 @@ function registerResource(program2, spec) {
1451
1746
  const singular = spec.name.replace(/s$/, "");
1452
1747
  if (spec.list) {
1453
1748
  const list = spec.list;
1454
- const cmd = root.command("list").description(`List ${spec.name} from the active workspace`).option("--limit <n>", "results per page (1-100)", "20").option("--cursor <id>", "pagination cursor").option("--workspace <id>", "workspace override").option("--csv", "CSV output (for spreadsheets/accounting)").option("--json", "raw JSON output");
1749
+ const cmd = root.command("list").description(`List ${spec.name} from the active workspace`).option("--limit <n>", "results per page (1-100)", "20").option("--cursor <id>", "pagination cursor").option("--all", "auto-paginate: fetch every page (ignores --cursor)").option("--columns <list>", "comma-separated columns to display").option("--full", "show every field instead of the curated columns").option("--workspace <id>", "workspace override").option("--csv", "CSV output (for spreadsheets/accounting)").option("--json", "raw JSON output (data only)").option("--raw", "raw JSON output including pagination metadata (page)");
1455
1750
  for (const f of spec.listFlags ?? []) cmd.option(f.flag, f.describe);
1456
1751
  cmd.action(async (opts) => {
1457
1752
  configureClient(opts.workspace);
1753
+ const columns = resolveColumns(opts, spec.columns);
1458
1754
  const query = {
1459
1755
  limit: Number(opts.limit),
1460
1756
  cursor: opts.cursor
@@ -1463,13 +1759,42 @@ function registerResource(program2, spec) {
1463
1759
  const v = opts[camel2(f.query)];
1464
1760
  if (v !== void 0) query[f.query] = v;
1465
1761
  }
1762
+ if (opts.all) {
1763
+ const rows = [];
1764
+ let cursor;
1765
+ let page;
1766
+ do {
1767
+ const body2 = unwrap(await list({ query: { ...query, cursor } }));
1768
+ rows.push(...body2.data ?? []);
1769
+ page = body2.page;
1770
+ cursor = page?.nextCursor ?? void 0;
1771
+ } while (page?.hasMore && cursor);
1772
+ if (opts.raw) {
1773
+ print(
1774
+ { data: rows, page: { nextCursor: null, hasMore: false } },
1775
+ { json: true }
1776
+ );
1777
+ return;
1778
+ }
1779
+ if (opts.csv) {
1780
+ process.stdout.write(`${toCsv(rows, columns)}
1781
+ `);
1782
+ return;
1783
+ }
1784
+ print(rows, { json: opts.json, columns });
1785
+ return;
1786
+ }
1466
1787
  const body = unwrap(await list({ query }));
1788
+ if (opts.raw) {
1789
+ print(body, { json: true });
1790
+ return;
1791
+ }
1467
1792
  if (opts.csv) {
1468
- process.stdout.write(`${toCsv(body.data, spec.columns)}
1793
+ process.stdout.write(`${toCsv(body.data, columns)}
1469
1794
  `);
1470
1795
  return;
1471
1796
  }
1472
- print(body.data, { json: opts.json, columns: spec.columns });
1797
+ print(body.data, { json: opts.json, columns });
1473
1798
  if (!opts.json) printNextCursor(body.page);
1474
1799
  });
1475
1800
  }
@@ -1529,6 +1854,88 @@ function camel2(s) {
1529
1854
  return s.replace(/-([a-z])/g, (_, c2) => c2.toUpperCase());
1530
1855
  }
1531
1856
 
1857
+ // src/commands/tickets.ts
1858
+ function registerTickets(program2) {
1859
+ const root = program2.command("tickets").description("Individual tickets: door check-in, access status, QR resend");
1860
+ 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) => {
1861
+ configureClient(opts.workspace);
1862
+ const body = unwrap(
1863
+ await getTicketsTicketCodeAccess({ path: { ticketCode: code } })
1864
+ );
1865
+ print(body.data ?? body, { json: opts.json });
1866
+ });
1867
+ root.command("checkin <code>").description(
1868
+ "Admit a ticket at the door (idempotent, prevents double entry)"
1869
+ ).option("--workspace <id>", "workspace override").option("--json", "raw JSON output").action(async (code, opts) => {
1870
+ configureClient(opts.workspace);
1871
+ const body = unwrap(
1872
+ await postTicketsTicketCodeCheckin({ path: { ticketCode: code } })
1873
+ );
1874
+ print(body.data ?? body, { json: opts.json });
1875
+ });
1876
+ 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) => {
1877
+ configureClient(opts.workspace);
1878
+ const body = unwrap(
1879
+ await postTicketsTicketCodeResend({ path: { ticketCode: code } })
1880
+ );
1881
+ print(body.data ?? body, { json: opts.json });
1882
+ });
1883
+ }
1884
+
1885
+ // src/commands/workspace.ts
1886
+ import chalk3 from "chalk";
1887
+ function registerWorkspace(program2) {
1888
+ const root = program2.command("workspace").description("List, switch, and show the active workspace");
1889
+ root.command("list").alias("ls").description("List the workspaces you can access (marks the active one)").option("--json", "raw JSON output").action(async (opts) => {
1890
+ configureClient();
1891
+ const me = unwrap(await getMe({})).data;
1892
+ const activeId = loadConfig().workspaceId ?? me.activeWorkspaceId;
1893
+ const rows = me.workspaces.map((w) => ({
1894
+ active: w.id === activeId ? "*" : "",
1895
+ id: w.id,
1896
+ name: w.name,
1897
+ slug: w.slug
1898
+ }));
1899
+ print(rows, {
1900
+ json: opts.json,
1901
+ columns: ["active", "id", "name", "slug"]
1902
+ });
1903
+ });
1904
+ root.command("use <idOrSlug>").description(
1905
+ "Set the active workspace (persisted in ~/.freeticket/config.json)"
1906
+ ).action(async (idOrSlug) => {
1907
+ configureClient();
1908
+ const me = unwrap(await getMe({})).data;
1909
+ const match = me.workspaces.find(
1910
+ (w) => w.id === idOrSlug || w.slug === idOrSlug
1911
+ );
1912
+ if (!match) {
1913
+ fail(
1914
+ `No workspace matches "${idOrSlug}".`,
1915
+ `Available: ${me.workspaces.map((w) => w.slug).join(", ") || "(none)"}`
1916
+ );
1917
+ }
1918
+ saveConfig({ workspaceId: match.id });
1919
+ console.log(
1920
+ `${chalk3.green("\u2713")} Active workspace: ${chalk3.bold(match.name)} ${chalk3.dim(`(${match.slug})`)}`
1921
+ );
1922
+ });
1923
+ root.command("show").description("Show the active workspace").option("--json", "raw JSON output").action(async (opts) => {
1924
+ configureClient();
1925
+ const cfg = loadConfig();
1926
+ const me = unwrap(await getMe({})).data;
1927
+ const activeId = cfg.workspaceId ?? me.activeWorkspaceId;
1928
+ const active = me.workspaces.find((w) => w.id === activeId);
1929
+ if (!active) {
1930
+ fail(
1931
+ "No active workspace set.",
1932
+ "Pick one with `ft workspace use <slug>`."
1933
+ );
1934
+ }
1935
+ print(active, { json: opts.json });
1936
+ });
1937
+ }
1938
+
1532
1939
  // src/lib/banner.ts
1533
1940
  import { Chalk } from "chalk";
1534
1941
  var YELLOW = "#FFD500";
@@ -1551,6 +1958,7 @@ function banner() {
1551
1958
  var program = new Command();
1552
1959
  program.name("ft").description("Official FreeTicket CLI").version(package_default.version, "-v, --version").addHelpText("beforeAll", banner());
1553
1960
  registerAuth(program);
1961
+ registerWorkspace(program);
1554
1962
  registerResource(program, {
1555
1963
  name: "events",
1556
1964
  describe: "Events",
@@ -1562,7 +1970,8 @@ registerResource(program, {
1562
1970
  actions: [
1563
1971
  { name: "publish", describe: "Publish an event", fn: postEventsIdPublish }
1564
1972
  ],
1565
- columns: ["id", "name", "status", "startsAt"]
1973
+ // startsAt lives on EventDate, not Event — use createdAt for a temporal column.
1974
+ columns: ["id", "name", "status", "createdAt"]
1566
1975
  });
1567
1976
  registerEventDates(program, {
1568
1977
  list: getEventsIdDates,
@@ -1575,6 +1984,7 @@ registerResource(program, {
1575
1984
  describe: "Sales",
1576
1985
  list: getSales,
1577
1986
  get: getSalesId,
1987
+ create: postSales,
1578
1988
  actions: [
1579
1989
  { name: "cancel", describe: "Cancel a sale", fn: postSalesIdCancel },
1580
1990
  {
@@ -1582,11 +1992,43 @@ registerResource(program, {
1582
1992
  describe: "Refund a sale (--data for partial amount)",
1583
1993
  fn: postSalesIdRefund,
1584
1994
  body: true
1995
+ },
1996
+ {
1997
+ name: "tickets",
1998
+ describe: "List the individual tickets/attendees of a sale",
1999
+ fn: getSalesIdTickets
1585
2000
  }
1586
2001
  ],
1587
2002
  columns: ["id", "reference", "status", "total", "currency", "createdAt"],
1588
2003
  listFlags: [
1589
- { flag: "--status <s>", describe: "filter by status", query: "status" }
2004
+ { flag: "--status <s>", describe: "filter by status", query: "status" },
2005
+ {
2006
+ flag: "--channel <c>",
2007
+ describe: "filter by sales channel",
2008
+ query: "channel"
2009
+ },
2010
+ { flag: "--event <id>", describe: "filter by event", query: "event" },
2011
+ {
2012
+ flag: "--event-date <id>",
2013
+ describe: "filter by event date",
2014
+ query: "eventDate"
2015
+ },
2016
+ {
2017
+ flag: "--reference <ref>",
2018
+ describe: "filter by reference",
2019
+ query: "reference"
2020
+ },
2021
+ {
2022
+ flag: "--buyer <q>",
2023
+ describe: "filter by buyer name/email",
2024
+ query: "buyer"
2025
+ },
2026
+ {
2027
+ flag: "--from <date>",
2028
+ describe: "created from (ISO 8601)",
2029
+ query: "from"
2030
+ },
2031
+ { flag: "--to <date>", describe: "created to (ISO 8601)", query: "to" }
1590
2032
  ]
1591
2033
  });
1592
2034
  registerResource(program, {
@@ -1597,7 +2039,7 @@ registerResource(program, {
1597
2039
  create: postTicketTypes,
1598
2040
  update: patchTicketTypesId,
1599
2041
  del: deleteTicketTypesId,
1600
- columns: ["id", "name", "price", "currency", "stock"],
2042
+ columns: ["id", "name", "price", "currency", "capacity"],
1601
2043
  listFlags: [
1602
2044
  {
1603
2045
  flag: "--event-date-id <id>",
@@ -1614,7 +2056,50 @@ registerResource(program, {
1614
2056
  create: postMembershipPlans,
1615
2057
  update: patchMembershipPlansId,
1616
2058
  del: deleteMembershipPlansId,
1617
- columns: ["id", "name", "price", "currency", "interval"]
2059
+ actions: [
2060
+ {
2061
+ name: "subscribers",
2062
+ describe: "List the subscribers/members of a plan",
2063
+ fn: getMembershipPlansIdSubscribers
2064
+ }
2065
+ ],
2066
+ columns: ["id", "name", "price", "currency", "billingCycle"]
2067
+ });
2068
+ registerResource(program, {
2069
+ name: "discounts",
2070
+ describe: "Discount codes / coupons",
2071
+ list: getDiscounts,
2072
+ create: postDiscounts,
2073
+ update: patchDiscountsId,
2074
+ del: deleteDiscountsId,
2075
+ columns: ["id", "code", "type", "value", "active", "uses", "maxUses"],
2076
+ listFlags: [
2077
+ { flag: "--event <id>", describe: "filter by event", query: "event" },
2078
+ {
2079
+ flag: "--active <bool>",
2080
+ describe: "filter by active (true/false)",
2081
+ query: "active"
2082
+ }
2083
+ ]
2084
+ });
2085
+ registerResource(program, {
2086
+ name: "webhooks",
2087
+ describe: "Webhook endpoints (HMAC-signed event delivery)",
2088
+ list: getWebhooks,
2089
+ create: postWebhooks,
2090
+ del: deleteWebhooksId,
2091
+ columns: ["id", "url", "events", "active", "createdAt"]
2092
+ });
2093
+ registerResource(program, {
2094
+ name: "subscriptions",
2095
+ describe: "Plan subscriptions",
2096
+ actions: [
2097
+ {
2098
+ name: "cancel",
2099
+ describe: "Cancel a subscription",
2100
+ fn: postSubscriptionsIdCancel
2101
+ }
2102
+ ]
1618
2103
  });
1619
2104
  registerResource(program, {
1620
2105
  name: "venues",
@@ -1641,6 +2126,7 @@ registerResource(program, {
1641
2126
  ],
1642
2127
  columns: ["id", "name", "email", "role"]
1643
2128
  });
2129
+ registerTickets(program);
1644
2130
  registerReports(program);
1645
2131
  registerAdmin(program);
1646
2132
  if (process.argv.length <= 2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@freeticket/cli",
3
- "version": "0.4.1",
3
+ "version": "0.6.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",