Skip to content

feat(reports): sync CLI to contract — inventory, attendees, sales/export filters#15

Closed
LucasLeguizamo wants to merge 1 commit into
mainfrom
feat/reports-inventory-sales-filters
Closed

feat(reports): sync CLI to contract — inventory, attendees, sales/export filters#15
LucasLeguizamo wants to merge 1 commit into
mainfrom
feat/reports-inventory-sales-filters

Conversation

@LucasLeguizamo

Copy link
Copy Markdown
Contributor

What

Syncs the CLI to the current B2B contract (free-admin main), surfacing report capabilities that shipped server-side but were not yet exposed by ft.

  • ft reports inventory — aggregate capacity/sold/reserved/available per event/date/ticket type in a single call (replaces per-sale fan-out). Flags: --event, --event-date, --from, --to, --include-drafts, --group-by ticketType|date|event.
  • ft sales list filters: --channel, --event, --event-date, --reference, --buyer, --from, --to.
  • ft reports export buyers|attendees filters: --status, --event, --event-date, --from, --to. attendees is one row per ticket; buyers one row per sale.

How

openapi.json regenerated from the live contract; src/client/ regenerated via openapi-ts. No hand-edits to generated code.

Closes the CLI side of AppFreeticket/free-admin#165, #167, #168.

Test

pnpm typecheck, pnpm test, pnpm build green; --help verified for each new command/flag.

🤖 Generated with Claude Code

…filters

Regenerates the client from the current B2B contract and wires the shipped
report capabilities:
- `ft reports inventory` (--event, --event-date, --from, --to,
  --include-drafts, --group-by) — aggregate capacity/sold/reserved/available
  in a single call instead of per-sale fan-out.
- `ft sales list` filters: --channel, --event, --event-date, --reference,
  --buyer, --from, --to.
- `ft reports export buyers|attendees` filters: --status, --event,
  --event-date, --from, --to (attendees = one row per ticket).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

feat(reports): sync CLI to contract — inventory, attendees, sales/export filters

✨ Enhancement ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Adds ft reports inventory command with aggregate capacity/sold/reserved/available per
 event/date/ticket type, replacing per-sale fan-out; supports --event, --event-date, --from,
 --to, --include-drafts, --group-by flags.
• Adds ft reports export attendees (one row per ticket) alongside existing buyers, both now
 accepting --status, --event, --event-date, --from, --to filters.
• Adds 7 new filter flags to ft sales list: --channel, --event, --event-date, --reference,
 --buyer, --from, --to.
• Regenerates openapi.json (v1.0.0 → v1.3.0) from the live B2B contract, adding
 /reports/inventory, /reports/exports/attendees, auth device-flow endpoints, and reconciliation
 endpoints; regenerates src/client/ via openapi-ts.
Diagram

graph TD
    CLI["ft CLI"] --> sales["ft sales list"]
    CLI --> inv["ft reports inventory"]
    CLI --> exp["ft reports export"]
    exp --> buyers["export buyers"]
    exp --> attendees["export attendees"]
    exp --> subs["export subscribers"]
    sales --> sdk["client/sdk.gen"]
    inv --> sdk
    buyers --> sdk
    attendees --> sdk
    subs --> sdk
    sdk --> api["B2B REST API"]
    openapi["openapi.json v1.3.0"] -.regenerates.-> sdk

    subgraph Legend
      direction LR
      _cmd["CLI Command"] ~~~ _gen["Generated Client"] ~~~ _ext["External API"]
    end
Loading
High-Level Assessment

The approach is optimal: regenerating the client from the live OpenAPI contract (code-gen via openapi-ts) is the standard pattern for keeping a typed CLI in sync with a REST API. Hand-editing the generated client would introduce drift; maintaining a separate abstraction layer would add unnecessary indirection. The query() helper that strips undefined values is a clean, minimal solution to avoid polluting query strings with empty params. No meaningful alternatives exist.

Files changed (3) +5439 / -7

Enhancement (2) +113 / -6
reports.tsAdd 'ft reports inventory' command and 'attendees' export with filters +86/-6

Add 'ft reports inventory' command and 'attendees' export with filters

• Introduces 'ft reports inventory' subcommand that calls 'getReportsInventory' with optional eventId, eventDateId, from, to, includeDrafts, and groupBy query params, printing a tabular view of capacity/sold/reserved/available. Adds 'getReportsExportsAttendees' to the export loop alongside buyers, both now accepting --status, --event, --event-date, --from, --to filters via a new 'query()' helper that strips undefined values. Extracts 'subscribers' out of the shared loop since it has no filters.

src/commands/reports.ts

index.tsAdd 7 filter flags to 'ft sales list' +27/-0

Add 7 filter flags to 'ft sales list'

• Extends the 'sales' resource registration with listFlags for --channel, --event, --event-date, --reference, --buyer, --from, and --to, mapping each to the corresponding query parameter now supported by the B2B API.

src/index.ts

Other (1) +5326 / -1
openapi.jsonRegenerate OpenAPI contract from B2B API v1.3.0 +5326/-1

Regenerate OpenAPI contract from B2B API v1.3.0

• Replaces the minified single-line v1.0.0 contract with a fully-formatted v1.3.0 spec (5326 lines). Adds new paths: '/reports/inventory' (with eventId, eventDateId, from, to, includeDrafts, groupBy params), '/reports/exports/attendees' (with event, eventDate, from, to, status params), '/reports/exports/buyers' filter params, '/reports/reconciliation', and '/auth/device/code|token' endpoints. Also adds new schemas: 'InventoryRow', 'DeviceCodeResponse', 'DeviceTokenRequest', 'DeviceTokenResponse', 'DeviceTokenError'.

openapi.json

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Generated SDK not built 🐞 Bug ☼ Reliability
Description
The CLI imports newly-required SDK functions (e.g. getReportsInventory/getReportsExportsAttendees)
from ../client/sdk.gen, but src/client/ is generated-and-gitignored and the project’s
build/typecheck scripts do not run the generator, so builds/typechecks will fail unless generation
is performed beforehand.
Code

src/commands/reports.ts[R2-8]

import {
+  getReportsExportsAttendees,
  getReportsExportsBuyers,
  getReportsExportsSubscribers,
+  getReportsInventory,
  getReportsSummary,
} from "../client/sdk.gen";
Evidence
The CLI imports generated SDK modules under src/client/*, but the repo is configured to generate
that directory (and ignore it in git) without any package script hook to generate before
build/typecheck, making compilation depend on an out-of-band step.

src/commands/reports.ts[1-8]
src/lib/api.ts[1-21]
openapi-ts.config.ts[3-9]
.gitignore[4-6]
package.json[26-37]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The repository relies on generated OpenAPI client code under `src/client/` (gitignored), but `pnpm build` / `pnpm typecheck` do not run `pnpm generate` first. This PR adds additional SDK imports, increasing the chance of broken builds/typechecks when the generated client is missing or stale.

### Issue Context
- `openapi-ts.config.ts` generates to `src/client/`.
- `.gitignore` excludes `src/client/` from version control.
- `package.json` scripts do not ensure generation occurs before compilation.

### Fix
Pick one:
1) **Ensure generation runs automatically** by adding `prebuild`, `pretypecheck`, and (optionally) `pretest` scripts that run `pnpm generate`.
2) **Commit generated client code** by removing `src/client/` from `.gitignore` (if the repo policy allows committing generated artifacts).

### Fix Focus Areas
- package.json[26-37]
- .gitignore[1-6]
- openapi-ts.config.ts[1-9]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment thread src/commands/reports.ts
Comment on lines 2 to 8
import {
getReportsExportsAttendees,
getReportsExportsBuyers,
getReportsExportsSubscribers,
getReportsInventory,
getReportsSummary,
} from "../client/sdk.gen";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Generated sdk not built 🐞 Bug ☼ Reliability

The CLI imports newly-required SDK functions (e.g. getReportsInventory/getReportsExportsAttendees)
from ../client/sdk.gen, but src/client/ is generated-and-gitignored and the project’s
build/typecheck scripts do not run the generator, so builds/typechecks will fail unless generation
is performed beforehand.
Agent Prompt
### Issue description
The repository relies on generated OpenAPI client code under `src/client/` (gitignored), but `pnpm build` / `pnpm typecheck` do not run `pnpm generate` first. This PR adds additional SDK imports, increasing the chance of broken builds/typechecks when the generated client is missing or stale.

### Issue Context
- `openapi-ts.config.ts` generates to `src/client/`.
- `.gitignore` excludes `src/client/` from version control.
- `package.json` scripts do not ensure generation occurs before compilation.

### Fix
Pick one:
1) **Ensure generation runs automatically** by adding `prebuild`, `pretypecheck`, and (optionally) `pretest` scripts that run `pnpm generate`.
2) **Commit generated client code** by removing `src/client/` from `.gitignore` (if the repo policy allows committing generated artifacts).

### Fix Focus Areas
- package.json[26-37]
- .gitignore[1-6]
- openapi-ts.config.ts[1-9]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@LucasLeguizamo

Copy link
Copy Markdown
Contributor Author

Superseded by #16. That PR is a strict superset of this one — it includes reports inventory, export attendees, and the sales list / export filters shipped here, plus the rest of the contract surfaces (tickets, sales create/tickets, discounts, webhooks, plans subscribers, subscriptions cancel, reports by-event/timeseries) from contract issues #172–#178, all off current main at OpenAPI 1.4.0. This branch conflicts because it was cut from an older main (before reports reconciliation), so closing it in favor of #16 to avoid double review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant