Skip to content
Merged
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 changes: 5 additions & 0 deletions .changeset/validate-limit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@freeticket/cli": patch
---

`--limit` en los comandos `list` ahora se valida (entero de 1 a 100) y falla con un mensaje claro, en vez de mandarse tal cual y volver en silencio con la página por defecto de 20.
5 changes: 5 additions & 0 deletions .changeset/waitlist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@freeticket/cli": minor
---

Nuevo `ft waitlist list|create`: lista de espera por ciudad de las landings enterprise (contrato 1.24). `list` filtra con `--city`.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ ft sales list --status CONFIRMED --json
| `ft reports reconciliation` · `financials` | CFO reconciliation (Mercado Pago vs sale vs Siigo invoice) · per-function P&L | ADMIN |
| `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 |
| `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 |
| `ft waitlist list [--city <name>]` · `waitlist create --data` | Per-city waitlist of an enterprise landing (export with personal data); `create` needs an enterprise service key | ADMIN |
| `ft api-keys create <name>` · `list` · `revoke <id>` | Self-service API keys (the secret is shown once, never stored) | ADMIN |
| `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 |

Expand Down
9,737 changes: 5,154 additions & 4,583 deletions openapi.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/commands/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
} from "../admin-client/sdk.gen";
import { configureAdminClient, unwrap } from "../lib/api";
import { CONFIG_PATH, loadConfig, saveConfig } from "../lib/config";
import { confirmOrExit, parseData } from "../lib/input";
import { confirmOrExit, parseData, parseLimit } from "../lib/input";
import { print, printNextCursor, resolveColumns, toCsv } from "../lib/output";

type SdkFn = (
Expand Down Expand Up @@ -327,7 +327,7 @@ function registerAdminResource(parent: Command, spec: AdminResource): void {
configureAdminClient();
const query: Record<string, unknown> = {};
if (!spec.noPaging) {
query.limit = Number(opts.limit);
query.limit = parseLimit(opts.limit);
query.cursor = opts.cursor;
}
for (const f of spec.listFlags ?? []) {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/api-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Command } from "commander";
import { deleteApiKeysId, getApiKeys, postApiKeys } from "../client/sdk.gen";
import type { ApiKeyScope } from "../client/types.gen";
import { configureClient, fail, unwrap } from "../lib/api";
import { confirmOrExit } from "../lib/input";
import { confirmOrExit, parseLimit } from "../lib/input";
import {
print,
printEmptyScope,
Expand Down Expand Up @@ -98,7 +98,7 @@ export function registerApiKeys(program: Command): void {
configureClient(opts.workspace);
const columns = resolveColumns(opts, COLUMNS);
const query: Record<string, unknown> = {
limit: opts.limit,
limit: parseLimit(opts.limit),
cursor: opts.cursor,
};

Expand Down
5 changes: 3 additions & 2 deletions src/commands/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
tagRow,
unwrap,
} from "../lib/api";
import { confirmOrExit, parseData } from "../lib/input";
import { confirmOrExit, parseData, parseLimit } from "../lib/input";
import {
print,
printEmptyScope,
Expand Down Expand Up @@ -91,8 +91,9 @@ export function registerResource(program: Command, spec: ResourceSpec): void {
for (const f of spec.listFlags ?? []) cmd.option(f.flag, f.describe);
cmd.action(async (opts) => {
let columns = resolveColumns(opts, spec.columns);
opts.limit = parseLimit(opts.limit);
const query: Record<string, unknown> = {
limit: Number(opts.limit),
limit: opts.limit,
cursor: opts.cursor,
};
for (const f of spec.listFlags ?? []) {
Expand Down
22 changes: 21 additions & 1 deletion src/lib/input.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { confirmOrExit } from "./input";
import { confirmOrExit, parseLimit } from "./input";

/** Issue #24: aborting a destructive command must not exit 0. */
describe("confirmOrExit", () => {
Expand Down Expand Up @@ -42,3 +42,23 @@ describe("confirmOrExit", () => {
expect(exit).not.toHaveBeenCalled();
});
});

/** `--limit 500` used to reach the API and silently come back as 20 rows. */
describe("parseLimit", () => {
afterEach(() => vi.restoreAllMocks());

it("accepts integers 1-100", () => {
expect(parseLimit("1")).toBe(1);
expect(parseLimit("20")).toBe(20);
expect(parseLimit("100")).toBe(100);
});

it.each(["0", "101", "500", "abc", "2.5", ""])("exits 1 on %j", (bad) => {
vi.spyOn(console, "error").mockImplementation(() => {});
const exit = vi.spyOn(process, "exit").mockImplementation((() => {
throw new Error("exited");
}) as never);
expect(() => parseLimit(bad)).toThrow("exited");
expect(exit).toHaveBeenCalledWith(1);
});
});
15 changes: 15 additions & 0 deletions src/lib/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ import { readFileSync } from "node:fs";
import * as readline from "node:readline";
import { fail } from "./api";

/**
* Validates `--limit`: an integer 1-100, as the contract allows. Without this
* `--limit 500` or `--limit abc` went to the API as-is and came back as the
* default page of 20, silently.
*/
export function parseLimit(input: string): number {
const n = Number(input);
if (!Number.isInteger(n) || n < 1 || n > 100)
fail(
`Invalid --limit: ${input}. Use an integer from 1 to 100.`,
"For more rows, add --all to walk every page.",
);
return n;
}

/**
* Parses a `--data` value into a JSON body. Accepts inline JSON (`'{"x":1}'`)
* or `@path/to/file.json` to read from disk. Aborts on missing/invalid input.
Expand Down
9 changes: 9 additions & 0 deletions src/program.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,12 @@ test("contract 1.19 / admin 1.5 commands are wired, destructive ones behind --ye
// `plan <id>` (assign) must survive next to the new read.
expect(longs("admin workspaces plan")).toContain("--data");
});

test("contract 1.24: waitlist list/create are wired, list filters by --city", () => {
const tree = new Map(walk(program));
expect(tree.has("waitlist list")).toBe(true);
expect(tree.has("waitlist create")).toBe(true);
const longs = tree.get("waitlist list")?.options.map((o) => o.long) ?? [];
expect(longs).toContain("--city");
expect(longs).toContain("--account");
});
19 changes: 19 additions & 0 deletions src/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
getTicketTypesId,
getVenues,
getVenuesId,
getWaitlist,
getWebhooks,
patchDiscountsId,
patchEventsId,
Expand All @@ -57,6 +58,7 @@ import {
postSubscriptionsIdCancel,
postTicketTypes,
postVenues,
postWaitlist,
postWebhooks,
} from "./client/sdk.gen";
import { registerAccount } from "./commands/account";
Expand Down Expand Up @@ -409,6 +411,23 @@ registerResource(program, {
},
});

// Per-city waitlist of an enterprise landing (contract 1.24). `list` is the
// staff export (ADMIN, personal data); `create` needs an enterprise service key.
registerResource(program, {
name: "waitlist",
describe: "Per-city waitlist entries of an enterprise landing",
list: getWaitlist,
create: postWaitlist,
columns: ["id", "city", "name", "contact", "source", "createdAt"],
listFlags: [
{
flag: "--city <name>",
describe: "filter by city (accents/case ignored)",
query: "city",
},
],
});

registerTickets(program);
registerReports(program);
registerApiKeys(program);
Expand Down
Loading