Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,327 changes: 5,326 additions & 1 deletion openapi.json

Large diffs are not rendered by default.

92 changes: 86 additions & 6 deletions src/commands/reports.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import type { Command } from "commander";
import {
getReportsExportsAttendees,
getReportsExportsBuyers,
getReportsExportsSubscribers,
getReportsInventory,
getReportsSummary,
} from "../client/sdk.gen";
Comment on lines 2 to 8

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

import { configureClient, unwrap } from "../lib/api";
import { print } from "../lib/output";

// Drops undefined flags so only the filters the user passed hit the query string.
function query(pairs: Record<string, unknown>): Record<string, string> {
const q: Record<string, string> = {};
for (const [k, v] of Object.entries(pairs))
if (v !== undefined) q[k] = String(v);
return q;
}

export function registerReports(program: Command): void {
const root = program.command("reports").description("KPIs and exports");

Expand All @@ -24,23 +34,93 @@ export function registerReports(program: Command): void {
print(body.data, { json: opts.json });
});

root
.command("inventory")
.description("Aggregate inventory (capacity/sold/reserved/available)")
.option("--event <id>", "filter by event id")
.option("--event-date <id>", "filter by event date id")
.option("--from <iso>", "event date from (ISO 8601)")
.option("--to <iso>", "event date to (ISO 8601)")
.option("--include-drafts", "include unpublished events")
.option("--group-by <g>", "ticketType (default) | date | event")
.option("--workspace <id>", "workspace override")
.option("--json", "raw JSON output")
.action(async (opts) => {
configureClient(opts.workspace);
const body = unwrap(
await getReportsInventory({
query: query({
eventId: opts.event,
eventDateId: opts.eventDate,
from: opts.from,
to: opts.to,
includeDrafts: opts.includeDrafts ? "true" : undefined,
groupBy: opts.groupBy,
}),
}),
);
print(body.data, {
json: opts.json,
columns: [
"eventName",
"startsAt",
"ticketTypeName",
"capacity",
"sold",
"reserved",
"available",
],
});
});

const exp = root
.command("export")
.description("Export buyers or subscribers (CSV)");
.description("Export buyers, attendees or subscribers");

for (const [name, fn, label] of [
["buyers", getReportsExportsBuyers, "buyers"],
["subscribers", getReportsExportsSubscribers, "subscribers"],
// buyers (one row per sale) and attendees (one row per ticket) share filters.
for (const [name, fn, describe] of [
["buyers", getReportsExportsBuyers, "Export buyers (one row per sale)"],
[
"attendees",
getReportsExportsAttendees,
"Export attendees (one row per ticket)",
],
] as const) {
exp
.command(name)
.description(`Export ${label}`)
.description(describe)
.option("--status <s>", "sale status (default CONFIRMED)")
.option("--event <id>", "filter by event id")
.option("--event-date <id>", "filter by event date id")
.option("--from <iso>", "created from (ISO 8601)")
.option("--to <iso>", "created to (ISO 8601)")
.option("--workspace <id>", "workspace override")
.option("--json", "raw JSON output")
.action(async (opts) => {
configureClient(opts.workspace);
const body = unwrap(await fn({}));
const body = unwrap(
await fn({
query: query({
status: opts.status,
event: opts.event,
eventDate: opts.eventDate,
from: opts.from,
to: opts.to,
}),
}),
);
print(body.data ?? body, { json: opts.json });
});
}

exp
.command("subscribers")
.description("Export subscribers")
.option("--workspace <id>", "workspace override")
.option("--json", "raw JSON output")
.action(async (opts) => {
configureClient(opts.workspace);
const body = unwrap(await getReportsExportsSubscribers({}));
print(body.data ?? body, { json: opts.json });
});
}
27 changes: 27 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,33 @@ registerResource(program, {
columns: ["id", "reference", "status", "total", "currency", "createdAt"],
listFlags: [
{ flag: "--status <s>", describe: "filter by status", query: "status" },
{
flag: "--channel <c>",
describe: "WEB|MOBILE|POS|ADMIN",
query: "channel",
},
{ flag: "--event <id>", describe: "filter by event id", query: "event" },
{
flag: "--event-date <id>",
describe: "filter by event date id",
query: "eventDate",
},
{
flag: "--reference <ref>",
describe: "partial reference match",
query: "reference",
},
{
flag: "--buyer <q>",
describe: "buyer name or email match",
query: "buyer",
},
{
flag: "--from <iso>",
describe: "created from (ISO 8601)",
query: "from",
},
{ flag: "--to <iso>", describe: "created to (ISO 8601)", query: "to" },
],
});

Expand Down